refactor: remove unused code related to whitelisted assets

This commit is contained in:
Prad Nukala
2024-09-27 20:58:05 -04:00
parent 88a3d9da1c
commit 92ff87cc2c
57 changed files with 25331 additions and 15090 deletions
File diff suppressed because it is too large Load Diff
+1243 -26
View File
File diff suppressed because it is too large Load Diff
+78 -78
View File
@@ -9,123 +9,123 @@ import (
ormerrors "cosmossdk.io/orm/types/ormerrors"
)
type AliasTable interface {
Insert(ctx context.Context, alias *Alias) error
Update(ctx context.Context, alias *Alias) error
Save(ctx context.Context, alias *Alias) error
Delete(ctx context.Context, alias *Alias) error
Has(ctx context.Context, id string) (found bool, err error)
type AuthenticationTable interface {
Insert(ctx context.Context, authentication *Authentication) error
Update(ctx context.Context, authentication *Authentication) error
Save(ctx context.Context, authentication *Authentication) error
Delete(ctx context.Context, authentication *Authentication) error
Has(ctx context.Context, did string) (found bool, err error)
// Get returns nil and an error which responds true to ormerrors.IsNotFound() if the record was not found.
Get(ctx context.Context, id string) (*Alias, error)
HasBySubjectOrigin(ctx context.Context, subject string, origin string) (found bool, err error)
// GetBySubjectOrigin returns nil and an error which responds true to ormerrors.IsNotFound() if the record was not found.
GetBySubjectOrigin(ctx context.Context, subject string, origin string) (*Alias, error)
List(ctx context.Context, prefixKey AliasIndexKey, opts ...ormlist.Option) (AliasIterator, error)
ListRange(ctx context.Context, from, to AliasIndexKey, opts ...ormlist.Option) (AliasIterator, error)
DeleteBy(ctx context.Context, prefixKey AliasIndexKey) error
DeleteRange(ctx context.Context, from, to AliasIndexKey) error
Get(ctx context.Context, did string) (*Authentication, error)
HasByControllerSubject(ctx context.Context, controller string, subject string) (found bool, err error)
// GetByControllerSubject returns nil and an error which responds true to ormerrors.IsNotFound() if the record was not found.
GetByControllerSubject(ctx context.Context, controller string, subject string) (*Authentication, error)
List(ctx context.Context, prefixKey AuthenticationIndexKey, opts ...ormlist.Option) (AuthenticationIterator, error)
ListRange(ctx context.Context, from, to AuthenticationIndexKey, opts ...ormlist.Option) (AuthenticationIterator, error)
DeleteBy(ctx context.Context, prefixKey AuthenticationIndexKey) error
DeleteRange(ctx context.Context, from, to AuthenticationIndexKey) error
doNotImplement()
}
type AliasIterator struct {
type AuthenticationIterator struct {
ormtable.Iterator
}
func (i AliasIterator) Value() (*Alias, error) {
var alias Alias
err := i.UnmarshalMessage(&alias)
return &alias, err
func (i AuthenticationIterator) Value() (*Authentication, error) {
var authentication Authentication
err := i.UnmarshalMessage(&authentication)
return &authentication, err
}
type AliasIndexKey interface {
type AuthenticationIndexKey interface {
id() uint32
values() []interface{}
aliasIndexKey()
authenticationIndexKey()
}
// primary key starting index..
type AliasPrimaryKey = AliasIdIndexKey
type AuthenticationPrimaryKey = AuthenticationDidIndexKey
type AliasIdIndexKey struct {
type AuthenticationDidIndexKey struct {
vs []interface{}
}
func (x AliasIdIndexKey) id() uint32 { return 0 }
func (x AliasIdIndexKey) values() []interface{} { return x.vs }
func (x AliasIdIndexKey) aliasIndexKey() {}
func (x AuthenticationDidIndexKey) id() uint32 { return 0 }
func (x AuthenticationDidIndexKey) values() []interface{} { return x.vs }
func (x AuthenticationDidIndexKey) authenticationIndexKey() {}
func (this AliasIdIndexKey) WithId(id string) AliasIdIndexKey {
this.vs = []interface{}{id}
func (this AuthenticationDidIndexKey) WithDid(did string) AuthenticationDidIndexKey {
this.vs = []interface{}{did}
return this
}
type AliasSubjectOriginIndexKey struct {
type AuthenticationControllerSubjectIndexKey struct {
vs []interface{}
}
func (x AliasSubjectOriginIndexKey) id() uint32 { return 1 }
func (x AliasSubjectOriginIndexKey) values() []interface{} { return x.vs }
func (x AliasSubjectOriginIndexKey) aliasIndexKey() {}
func (x AuthenticationControllerSubjectIndexKey) id() uint32 { return 1 }
func (x AuthenticationControllerSubjectIndexKey) values() []interface{} { return x.vs }
func (x AuthenticationControllerSubjectIndexKey) authenticationIndexKey() {}
func (this AliasSubjectOriginIndexKey) WithSubject(subject string) AliasSubjectOriginIndexKey {
this.vs = []interface{}{subject}
func (this AuthenticationControllerSubjectIndexKey) WithController(controller string) AuthenticationControllerSubjectIndexKey {
this.vs = []interface{}{controller}
return this
}
func (this AliasSubjectOriginIndexKey) WithSubjectOrigin(subject string, origin string) AliasSubjectOriginIndexKey {
this.vs = []interface{}{subject, origin}
func (this AuthenticationControllerSubjectIndexKey) WithControllerSubject(controller string, subject string) AuthenticationControllerSubjectIndexKey {
this.vs = []interface{}{controller, subject}
return this
}
type aliasTable struct {
type authenticationTable struct {
table ormtable.Table
}
func (this aliasTable) Insert(ctx context.Context, alias *Alias) error {
return this.table.Insert(ctx, alias)
func (this authenticationTable) Insert(ctx context.Context, authentication *Authentication) error {
return this.table.Insert(ctx, authentication)
}
func (this aliasTable) Update(ctx context.Context, alias *Alias) error {
return this.table.Update(ctx, alias)
func (this authenticationTable) Update(ctx context.Context, authentication *Authentication) error {
return this.table.Update(ctx, authentication)
}
func (this aliasTable) Save(ctx context.Context, alias *Alias) error {
return this.table.Save(ctx, alias)
func (this authenticationTable) Save(ctx context.Context, authentication *Authentication) error {
return this.table.Save(ctx, authentication)
}
func (this aliasTable) Delete(ctx context.Context, alias *Alias) error {
return this.table.Delete(ctx, alias)
func (this authenticationTable) Delete(ctx context.Context, authentication *Authentication) error {
return this.table.Delete(ctx, authentication)
}
func (this aliasTable) Has(ctx context.Context, id string) (found bool, err error) {
return this.table.PrimaryKey().Has(ctx, id)
func (this authenticationTable) Has(ctx context.Context, did string) (found bool, err error) {
return this.table.PrimaryKey().Has(ctx, did)
}
func (this aliasTable) Get(ctx context.Context, id string) (*Alias, error) {
var alias Alias
found, err := this.table.PrimaryKey().Get(ctx, &alias, id)
func (this authenticationTable) Get(ctx context.Context, did string) (*Authentication, error) {
var authentication Authentication
found, err := this.table.PrimaryKey().Get(ctx, &authentication, did)
if err != nil {
return nil, err
}
if !found {
return nil, ormerrors.NotFound
}
return &alias, nil
return &authentication, nil
}
func (this aliasTable) HasBySubjectOrigin(ctx context.Context, subject string, origin string) (found bool, err error) {
func (this authenticationTable) HasByControllerSubject(ctx context.Context, controller string, subject string) (found bool, err error) {
return this.table.GetIndexByID(1).(ormtable.UniqueIndex).Has(ctx,
controller,
subject,
origin,
)
}
func (this aliasTable) GetBySubjectOrigin(ctx context.Context, subject string, origin string) (*Alias, error) {
var alias Alias
found, err := this.table.GetIndexByID(1).(ormtable.UniqueIndex).Get(ctx, &alias,
func (this authenticationTable) GetByControllerSubject(ctx context.Context, controller string, subject string) (*Authentication, error) {
var authentication Authentication
found, err := this.table.GetIndexByID(1).(ormtable.UniqueIndex).Get(ctx, &authentication,
controller,
subject,
origin,
)
if err != nil {
return nil, err
@@ -133,37 +133,37 @@ func (this aliasTable) GetBySubjectOrigin(ctx context.Context, subject string, o
if !found {
return nil, ormerrors.NotFound
}
return &alias, nil
return &authentication, nil
}
func (this aliasTable) List(ctx context.Context, prefixKey AliasIndexKey, opts ...ormlist.Option) (AliasIterator, error) {
func (this authenticationTable) List(ctx context.Context, prefixKey AuthenticationIndexKey, opts ...ormlist.Option) (AuthenticationIterator, error) {
it, err := this.table.GetIndexByID(prefixKey.id()).List(ctx, prefixKey.values(), opts...)
return AliasIterator{it}, err
return AuthenticationIterator{it}, err
}
func (this aliasTable) ListRange(ctx context.Context, from, to AliasIndexKey, opts ...ormlist.Option) (AliasIterator, error) {
func (this authenticationTable) ListRange(ctx context.Context, from, to AuthenticationIndexKey, opts ...ormlist.Option) (AuthenticationIterator, error) {
it, err := this.table.GetIndexByID(from.id()).ListRange(ctx, from.values(), to.values(), opts...)
return AliasIterator{it}, err
return AuthenticationIterator{it}, err
}
func (this aliasTable) DeleteBy(ctx context.Context, prefixKey AliasIndexKey) error {
func (this authenticationTable) DeleteBy(ctx context.Context, prefixKey AuthenticationIndexKey) error {
return this.table.GetIndexByID(prefixKey.id()).DeleteBy(ctx, prefixKey.values()...)
}
func (this aliasTable) DeleteRange(ctx context.Context, from, to AliasIndexKey) error {
func (this authenticationTable) DeleteRange(ctx context.Context, from, to AuthenticationIndexKey) error {
return this.table.GetIndexByID(from.id()).DeleteRange(ctx, from.values(), to.values())
}
func (this aliasTable) doNotImplement() {}
func (this authenticationTable) doNotImplement() {}
var _ AliasTable = aliasTable{}
var _ AuthenticationTable = authenticationTable{}
func NewAliasTable(db ormtable.Schema) (AliasTable, error) {
table := db.GetTable(&Alias{})
func NewAuthenticationTable(db ormtable.Schema) (AuthenticationTable, error) {
table := db.GetTable(&Authentication{})
if table == nil {
return nil, ormerrors.TableNotFound.Wrap(string((&Alias{}).ProtoReflect().Descriptor().FullName()))
return nil, ormerrors.TableNotFound.Wrap(string((&Authentication{}).ProtoReflect().Descriptor().FullName()))
}
return aliasTable{table}, nil
return authenticationTable{table}, nil
}
type ControllerTable interface {
@@ -692,7 +692,7 @@ func NewVerificationTable(db ormtable.Schema) (VerificationTable, error) {
}
type StateStore interface {
AliasTable() AliasTable
AuthenticationTable() AuthenticationTable
ControllerTable() ControllerTable
VerificationTable() VerificationTable
@@ -700,13 +700,13 @@ type StateStore interface {
}
type stateStore struct {
alias AliasTable
controller ControllerTable
verification VerificationTable
authentication AuthenticationTable
controller ControllerTable
verification VerificationTable
}
func (x stateStore) AliasTable() AliasTable {
return x.alias
func (x stateStore) AuthenticationTable() AuthenticationTable {
return x.authentication
}
func (x stateStore) ControllerTable() ControllerTable {
@@ -722,7 +722,7 @@ func (stateStore) doNotImplement() {}
var _ StateStore = stateStore{}
func NewStateStore(db ormtable.Schema) (StateStore, error) {
aliasTable, err := NewAliasTable(db)
authenticationTable, err := NewAuthenticationTable(db)
if err != nil {
return nil, err
}
@@ -738,7 +738,7 @@ func NewStateStore(db ormtable.Schema) (StateStore, error) {
}
return stateStore{
aliasTable,
authenticationTable,
controllerTable,
verificationTable,
}, nil
+2593 -235
View File
File diff suppressed because it is too large Load Diff
+51 -2657
View File
File diff suppressed because it is too large Load Diff
-82
View File
@@ -19,10 +19,8 @@ import (
const _ = grpc.SupportPackageIsVersion7
const (
Msg_AuthorizeService_FullMethodName = "/did.v1.Msg/AuthorizeService"
Msg_ExecuteTx_FullMethodName = "/did.v1.Msg/ExecuteTx"
Msg_RegisterController_FullMethodName = "/did.v1.Msg/RegisterController"
Msg_RegisterService_FullMethodName = "/did.v1.Msg/RegisterService"
Msg_UpdateParams_FullMethodName = "/did.v1.Msg/UpdateParams"
)
@@ -30,18 +28,12 @@ const (
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
type MsgClient interface {
// AuthorizeService asserts the given controller is the owner of the given
// address.
AuthorizeService(ctx context.Context, in *MsgAuthorizeService, opts ...grpc.CallOption) (*MsgAuthorizeServiceResponse, error)
// ExecuteTx executes a transaction on the Sonr Blockchain. It leverages
// Macaroon for verification.
ExecuteTx(ctx context.Context, in *MsgExecuteTx, opts ...grpc.CallOption) (*MsgExecuteTxResponse, error)
// RegisterController initializes a controller with the given authentication
// set, address, cid, publicKey, and user-defined alias.
RegisterController(ctx context.Context, in *MsgRegisterController, opts ...grpc.CallOption) (*MsgRegisterControllerResponse, error)
// RegisterService initializes a Service with a given permission scope and
// URI. The domain must have a valid TXT record containing the public key.
RegisterService(ctx context.Context, in *MsgRegisterService, opts ...grpc.CallOption) (*MsgRegisterServiceResponse, error)
// UpdateParams defines a governance operation for updating the parameters.
UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error)
}
@@ -54,15 +46,6 @@ func NewMsgClient(cc grpc.ClientConnInterface) MsgClient {
return &msgClient{cc}
}
func (c *msgClient) AuthorizeService(ctx context.Context, in *MsgAuthorizeService, opts ...grpc.CallOption) (*MsgAuthorizeServiceResponse, error) {
out := new(MsgAuthorizeServiceResponse)
err := c.cc.Invoke(ctx, Msg_AuthorizeService_FullMethodName, in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *msgClient) ExecuteTx(ctx context.Context, in *MsgExecuteTx, opts ...grpc.CallOption) (*MsgExecuteTxResponse, error) {
out := new(MsgExecuteTxResponse)
err := c.cc.Invoke(ctx, Msg_ExecuteTx_FullMethodName, in, out, opts...)
@@ -81,15 +64,6 @@ func (c *msgClient) RegisterController(ctx context.Context, in *MsgRegisterContr
return out, nil
}
func (c *msgClient) RegisterService(ctx context.Context, in *MsgRegisterService, opts ...grpc.CallOption) (*MsgRegisterServiceResponse, error) {
out := new(MsgRegisterServiceResponse)
err := c.cc.Invoke(ctx, Msg_RegisterService_FullMethodName, in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) {
out := new(MsgUpdateParamsResponse)
err := c.cc.Invoke(ctx, Msg_UpdateParams_FullMethodName, in, out, opts...)
@@ -103,18 +77,12 @@ func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts
// All implementations must embed UnimplementedMsgServer
// for forward compatibility
type MsgServer interface {
// AuthorizeService asserts the given controller is the owner of the given
// address.
AuthorizeService(context.Context, *MsgAuthorizeService) (*MsgAuthorizeServiceResponse, error)
// ExecuteTx executes a transaction on the Sonr Blockchain. It leverages
// Macaroon for verification.
ExecuteTx(context.Context, *MsgExecuteTx) (*MsgExecuteTxResponse, error)
// RegisterController initializes a controller with the given authentication
// set, address, cid, publicKey, and user-defined alias.
RegisterController(context.Context, *MsgRegisterController) (*MsgRegisterControllerResponse, error)
// RegisterService initializes a Service with a given permission scope and
// URI. The domain must have a valid TXT record containing the public key.
RegisterService(context.Context, *MsgRegisterService) (*MsgRegisterServiceResponse, error)
// UpdateParams defines a governance operation for updating the parameters.
UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error)
mustEmbedUnimplementedMsgServer()
@@ -124,18 +92,12 @@ type MsgServer interface {
type UnimplementedMsgServer struct {
}
func (UnimplementedMsgServer) AuthorizeService(context.Context, *MsgAuthorizeService) (*MsgAuthorizeServiceResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method AuthorizeService not implemented")
}
func (UnimplementedMsgServer) ExecuteTx(context.Context, *MsgExecuteTx) (*MsgExecuteTxResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method ExecuteTx not implemented")
}
func (UnimplementedMsgServer) RegisterController(context.Context, *MsgRegisterController) (*MsgRegisterControllerResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method RegisterController not implemented")
}
func (UnimplementedMsgServer) RegisterService(context.Context, *MsgRegisterService) (*MsgRegisterServiceResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method RegisterService not implemented")
}
func (UnimplementedMsgServer) UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method UpdateParams not implemented")
}
@@ -152,24 +114,6 @@ func RegisterMsgServer(s grpc.ServiceRegistrar, srv MsgServer) {
s.RegisterService(&Msg_ServiceDesc, srv)
}
func _Msg_AuthorizeService_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(MsgAuthorizeService)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(MsgServer).AuthorizeService(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Msg_AuthorizeService_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(MsgServer).AuthorizeService(ctx, req.(*MsgAuthorizeService))
}
return interceptor(ctx, in, info, handler)
}
func _Msg_ExecuteTx_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(MsgExecuteTx)
if err := dec(in); err != nil {
@@ -206,24 +150,6 @@ func _Msg_RegisterController_Handler(srv interface{}, ctx context.Context, dec f
return interceptor(ctx, in, info, handler)
}
func _Msg_RegisterService_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(MsgRegisterService)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(MsgServer).RegisterService(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Msg_RegisterService_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(MsgServer).RegisterService(ctx, req.(*MsgRegisterService))
}
return interceptor(ctx, in, info, handler)
}
func _Msg_UpdateParams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(MsgUpdateParams)
if err := dec(in); err != nil {
@@ -249,10 +175,6 @@ var Msg_ServiceDesc = grpc.ServiceDesc{
ServiceName: "did.v1.Msg",
HandlerType: (*MsgServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "AuthorizeService",
Handler: _Msg_AuthorizeService_Handler,
},
{
MethodName: "ExecuteTx",
Handler: _Msg_ExecuteTx_Handler,
@@ -261,10 +183,6 @@ var Msg_ServiceDesc = grpc.ServiceDesc{
MethodName: "RegisterController",
Handler: _Msg_RegisterController_Handler,
},
{
MethodName: "RegisterService",
Handler: _Msg_RegisterService_Handler,
},
{
MethodName: "UpdateParams",
Handler: _Msg_UpdateParams_Handler,