From 728fcf784c6d66804a1219094cffbbbdaa4ae7bd Mon Sep 17 00:00:00 2001 From: John Letey Date: Mon, 7 Oct 2024 19:37:30 +0200 Subject: [PATCH] feat: support app wiring and autocli --- api/module/v1/module.pulsar.go | 111 ++++++- go.mod | 4 +- proto/aura/module/v1/module.proto | 3 + simapp/app.go | 21 +- simapp/app.yaml | 5 + simapp/simd/cmd/root.go | 3 - x/aura/client/cli/query.go | 194 ----------- x/aura/client/cli/query_blocklist.go | 104 ------ x/aura/client/cli/tx.go | 478 --------------------------- x/aura/client/cli/tx_blocklist.go | 126 ------- x/aura/module.go | 273 ++++++++++++++- 11 files changed, 373 insertions(+), 949 deletions(-) delete mode 100644 x/aura/client/cli/query.go delete mode 100644 x/aura/client/cli/query_blocklist.go delete mode 100644 x/aura/client/cli/tx.go delete mode 100644 x/aura/client/cli/tx_blocklist.go diff --git a/api/module/v1/module.pulsar.go b/api/module/v1/module.pulsar.go index 7910df8..4296097 100644 --- a/api/module/v1/module.pulsar.go +++ b/api/module/v1/module.pulsar.go @@ -14,12 +14,14 @@ import ( ) var ( - md_Module protoreflect.MessageDescriptor + md_Module protoreflect.MessageDescriptor + fd_Module_denom protoreflect.FieldDescriptor ) func init() { file_aura_module_v1_module_proto_init() md_Module = File_aura_module_v1_module_proto.Messages().ByName("Module") + fd_Module_denom = md_Module.Fields().ByName("denom") } var _ protoreflect.Message = (*fastReflection_Module)(nil) @@ -87,6 +89,12 @@ func (x *fastReflection_Module) Interface() protoreflect.ProtoMessage { // While iterating, mutating operations may only be performed // on the current field descriptor. func (x *fastReflection_Module) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.Denom != "" { + value := protoreflect.ValueOfString(x.Denom) + if !f(fd_Module_denom, value) { + return + } + } } // Has reports whether a field is populated. @@ -102,6 +110,8 @@ func (x *fastReflection_Module) Range(f func(protoreflect.FieldDescriptor, proto // a repeated field is populated if it is non-empty. func (x *fastReflection_Module) Has(fd protoreflect.FieldDescriptor) bool { switch fd.FullName() { + case "aura.module.v1.Module.denom": + return x.Denom != "" default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: aura.module.v1.Module")) @@ -118,6 +128,8 @@ func (x *fastReflection_Module) Has(fd protoreflect.FieldDescriptor) bool { // Clear is a mutating operation and unsafe for concurrent use. func (x *fastReflection_Module) Clear(fd protoreflect.FieldDescriptor) { switch fd.FullName() { + case "aura.module.v1.Module.denom": + x.Denom = "" default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: aura.module.v1.Module")) @@ -134,6 +146,9 @@ func (x *fastReflection_Module) Clear(fd protoreflect.FieldDescriptor) { // of the value; to obtain a mutable reference, use Mutable. func (x *fastReflection_Module) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { switch descriptor.FullName() { + case "aura.module.v1.Module.denom": + value := x.Denom + return protoreflect.ValueOfString(value) default: if descriptor.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: aura.module.v1.Module")) @@ -154,6 +169,8 @@ func (x *fastReflection_Module) Get(descriptor protoreflect.FieldDescriptor) pro // Set is a mutating operation and unsafe for concurrent use. func (x *fastReflection_Module) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { switch fd.FullName() { + case "aura.module.v1.Module.denom": + x.Denom = value.Interface().(string) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: aura.module.v1.Module")) @@ -174,6 +191,8 @@ func (x *fastReflection_Module) Set(fd protoreflect.FieldDescriptor, value proto // Mutable is a mutating operation and unsafe for concurrent use. func (x *fastReflection_Module) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { + case "aura.module.v1.Module.denom": + panic(fmt.Errorf("field denom of message aura.module.v1.Module is not mutable")) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: aura.module.v1.Module")) @@ -187,6 +206,8 @@ func (x *fastReflection_Module) Mutable(fd protoreflect.FieldDescriptor) protore // For lists, maps, and messages, this returns a new, empty, mutable value. func (x *fastReflection_Module) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { + case "aura.module.v1.Module.denom": + return protoreflect.ValueOfString("") default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: aura.module.v1.Module")) @@ -256,6 +277,10 @@ func (x *fastReflection_Module) ProtoMethods() *protoiface.Methods { var n int var l int _ = l + l = len(x.Denom) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } if x.unknownFields != nil { n += len(x.unknownFields) } @@ -285,6 +310,13 @@ func (x *fastReflection_Module) ProtoMethods() *protoiface.Methods { i -= len(x.unknownFields) copy(dAtA[i:], x.unknownFields) } + if len(x.Denom) > 0 { + i -= len(x.Denom) + copy(dAtA[i:], x.Denom) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Denom))) + i-- + dAtA[i] = 0xa + } if input.Buf != nil { input.Buf = append(input.Buf, dAtA...) } else { @@ -334,6 +366,38 @@ func (x *fastReflection_Module) ProtoMethods() *protoiface.Methods { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: Module: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { + case 1: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Denom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.Denom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := runtime.Skip(dAtA[iNdEx:]) @@ -387,6 +451,9 @@ type Module struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields + + // denom is the denom this module is allowed to govern, burn, mint, etc. + Denom string `protobuf:"bytes,1,opt,name=denom,proto3" json:"denom,omitempty"` } func (x *Module) Reset() { @@ -409,6 +476,13 @@ func (*Module) Descriptor() ([]byte, []int) { return file_aura_module_v1_module_proto_rawDescGZIP(), []int{0} } +func (x *Module) GetDenom() string { + if x != nil { + return x.Denom + } + return "" +} + var File_aura_module_v1_module_proto protoreflect.FileDescriptor var file_aura_module_v1_module_proto_rawDesc = []byte{ @@ -417,23 +491,24 @@ var file_aura_module_v1_module_proto_rawDesc = []byte{ 0x75, 0x72, 0x61, 0x2e, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x1a, 0x20, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, - 0x3e, 0x0a, 0x06, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x3a, 0x34, 0xba, 0xc0, 0x96, 0xda, 0x01, - 0x2e, 0x0a, 0x2c, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6f, 0x6e, - 0x64, 0x6f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2f, 0x75, 0x73, 0x64, 0x79, 0x2d, - 0x6e, 0x6f, 0x62, 0x6c, 0x65, 0x2f, 0x76, 0x32, 0x2f, 0x78, 0x2f, 0x61, 0x75, 0x72, 0x61, 0x42, - 0xbe, 0x01, 0x0a, 0x12, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x75, 0x72, 0x61, 0x2e, 0x6d, 0x6f, 0x64, - 0x75, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x42, 0x0b, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x50, 0x72, - 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x41, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, - 0x6d, 0x2f, 0x6f, 0x6e, 0x64, 0x6f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2f, 0x75, - 0x73, 0x64, 0x79, 0x2d, 0x6e, 0x6f, 0x62, 0x6c, 0x65, 0x2f, 0x76, 0x32, 0x2f, 0x61, 0x70, 0x69, - 0x2f, 0x61, 0x75, 0x72, 0x61, 0x2f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2f, 0x76, 0x31, 0x3b, - 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x41, 0x4d, 0x58, 0xaa, 0x02, - 0x0e, 0x41, 0x75, 0x72, 0x61, 0x2e, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x56, 0x31, 0xca, - 0x02, 0x0e, 0x41, 0x75, 0x72, 0x61, 0x5c, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x5c, 0x56, 0x31, - 0xe2, 0x02, 0x1a, 0x41, 0x75, 0x72, 0x61, 0x5c, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x5c, 0x56, - 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x10, - 0x41, 0x75, 0x72, 0x61, 0x3a, 0x3a, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x3a, 0x3a, 0x56, 0x31, - 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x54, 0x0a, 0x06, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x64, 0x65, 0x6e, + 0x6f, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x64, 0x65, 0x6e, 0x6f, 0x6d, 0x3a, + 0x34, 0xba, 0xc0, 0x96, 0xda, 0x01, 0x2e, 0x0a, 0x2c, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, + 0x63, 0x6f, 0x6d, 0x2f, 0x6f, 0x6e, 0x64, 0x6f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, + 0x2f, 0x75, 0x73, 0x64, 0x79, 0x2d, 0x6e, 0x6f, 0x62, 0x6c, 0x65, 0x2f, 0x76, 0x32, 0x2f, 0x78, + 0x2f, 0x61, 0x75, 0x72, 0x61, 0x42, 0xbe, 0x01, 0x0a, 0x12, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x75, + 0x72, 0x61, 0x2e, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x42, 0x0b, 0x4d, 0x6f, + 0x64, 0x75, 0x6c, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x41, 0x67, 0x69, 0x74, + 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6f, 0x6e, 0x64, 0x6f, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x63, 0x6f, 0x6c, 0x2f, 0x75, 0x73, 0x64, 0x79, 0x2d, 0x6e, 0x6f, 0x62, 0x6c, 0x65, 0x2f, + 0x76, 0x32, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x75, 0x72, 0x61, 0x2f, 0x6d, 0x6f, 0x64, 0x75, + 0x6c, 0x65, 0x2f, 0x76, 0x31, 0x3b, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x76, 0x31, 0xa2, 0x02, + 0x03, 0x41, 0x4d, 0x58, 0xaa, 0x02, 0x0e, 0x41, 0x75, 0x72, 0x61, 0x2e, 0x4d, 0x6f, 0x64, 0x75, + 0x6c, 0x65, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x0e, 0x41, 0x75, 0x72, 0x61, 0x5c, 0x4d, 0x6f, 0x64, + 0x75, 0x6c, 0x65, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x1a, 0x41, 0x75, 0x72, 0x61, 0x5c, 0x4d, 0x6f, + 0x64, 0x75, 0x6c, 0x65, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, + 0x61, 0x74, 0x61, 0xea, 0x02, 0x10, 0x41, 0x75, 0x72, 0x61, 0x3a, 0x3a, 0x4d, 0x6f, 0x64, 0x75, + 0x6c, 0x65, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/go.mod b/go.mod index 002e3a3..2d02d6d 100644 --- a/go.mod +++ b/go.mod @@ -5,6 +5,7 @@ go 1.22.7 require ( cosmossdk.io/api v0.7.5 cosmossdk.io/core v0.11.1 + cosmossdk.io/depinject v1.0.0 cosmossdk.io/errors v1.0.1 cosmossdk.io/math v1.3.0 cosmossdk.io/store v1.1.1 @@ -16,7 +17,6 @@ require ( github.com/golang/protobuf v1.5.4 github.com/golangci/golangci-lint v1.61.0 github.com/grpc-ecosystem/grpc-gateway v1.16.0 - github.com/spf13/cobra v1.8.1 github.com/stretchr/testify v1.9.0 google.golang.org/genproto/googleapis/api v0.0.0-20240725223205-93522f1f2a9f google.golang.org/grpc v1.66.0 @@ -28,7 +28,6 @@ require ( 4d63.com/gocheckcompilerdirectives v1.2.1 // indirect 4d63.com/gochecknoglobals v0.2.1 // indirect cosmossdk.io/collections v0.4.0 // indirect - cosmossdk.io/depinject v1.0.0 // indirect cosmossdk.io/log v1.4.1 // indirect cosmossdk.io/x/tx v0.13.5 // indirect cosmossdk.io/x/upgrade v0.1.4 // indirect @@ -246,6 +245,7 @@ require ( github.com/sourcegraph/go-diff v0.7.0 // indirect github.com/spf13/afero v1.11.0 // indirect github.com/spf13/cast v1.6.0 // indirect + github.com/spf13/cobra v1.8.1 // indirect github.com/spf13/pflag v1.0.5 // indirect github.com/spf13/viper v1.19.0 // indirect github.com/ssgreg/nlreturn/v2 v2.2.1 // indirect diff --git a/proto/aura/module/v1/module.proto b/proto/aura/module/v1/module.proto index 3437436..e2e551c 100644 --- a/proto/aura/module/v1/module.proto +++ b/proto/aura/module/v1/module.proto @@ -7,4 +7,7 @@ import "cosmos/app/v1alpha1/module.proto"; // Module is the config object of the Aura module. message Module { option (cosmos.app.v1alpha1.module) = {go_import: "github.com/ondoprotocol/usdy-noble/v2/x/aura"}; + + // denom is the denom this module is allowed to govern, burn, mint, etc. + string denom = 1; } diff --git a/simapp/app.go b/simapp/app.go index 0a23c1b..6d6eb33 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -26,6 +26,7 @@ import ( _ "github.com/cosmos/cosmos-sdk/x/consensus" _ "github.com/cosmos/cosmos-sdk/x/params" _ "github.com/cosmos/cosmos-sdk/x/staking" + _ "github.com/ondoprotocol/usdy-noble/v2/x/aura" // Cosmos Modules upgradekeeper "cosmossdk.io/x/upgrade/keeper" @@ -42,9 +43,7 @@ import ( transferkeeper "github.com/cosmos/ibc-go/v8/modules/apps/transfer/keeper" ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper" // Custom Modules - "github.com/ondoprotocol/usdy-noble/v2/x/aura" aurakeeper "github.com/ondoprotocol/usdy-noble/v2/x/aura/keeper" - auratypes "github.com/ondoprotocol/usdy-noble/v2/x/aura/types" ) var DefaultNodeHome string @@ -138,28 +137,14 @@ func NewSimApp( &app.ParamsKeeper, &app.StakingKeeper, &app.UpgradeKeeper, + // Custom Modules + &app.AuraKeeper, ); err != nil { return nil, err } app.App = appBuilder.Build(db, traceStore, baseAppOptions...) - if err := app.RegisterStores(storetypes.NewKVStoreKey(auratypes.ModuleName)); err != nil { - return nil, err - } - app.AuraKeeper = aurakeeper.NewKeeper( - "ausdy", - runtime.NewKVStoreService(app.GetKey(auratypes.ModuleName)), - runtime.ProvideEventService(), - app.AccountKeeper.AddressCodec(), - nil, - ) - app.BankKeeper.AppendSendRestriction(app.AuraKeeper.SendRestrictionFn) - app.AuraKeeper.SetBankKeeper(app.BankKeeper) - if err := app.RegisterModules(aura.NewAppModule(app.AccountKeeper.AddressCodec(), app.AuraKeeper)); err != nil { - return nil, err - } - if err := app.RegisterLegacyModules(); err != nil { return nil, err } diff --git a/simapp/app.yaml b/simapp/app.yaml index d0fa00e..07d4f61 100644 --- a/simapp/app.yaml +++ b/simapp/app.yaml @@ -47,3 +47,8 @@ modules: - name: upgrade config: "@type": cosmos.upgrade.module.v1.Module + + - name: aura + config: + "@type": aura.module.v1.Module + denom: ausdy diff --git a/simapp/simd/cmd/root.go b/simapp/simd/cmd/root.go index 39b61ab..a22f6d6 100644 --- a/simapp/simd/cmd/root.go +++ b/simapp/simd/cmd/root.go @@ -30,8 +30,6 @@ import ( ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported" tendermint "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" "github.com/ondoprotocol/usdy-noble/v2/simapp" - "github.com/ondoprotocol/usdy-noble/v2/x/aura" - auratypes "github.com/ondoprotocol/usdy-noble/v2/x/aura/types" "github.com/spf13/cobra" ) @@ -111,7 +109,6 @@ func NewRootCmd() *cobra.Command { ibcexported.ModuleName: ibc.AppModule{}, transfertypes.ModuleName: transfer.AppModule{}, tendermint.ModuleName: tendermint.AppModule{}, - auratypes.ModuleName: aura.NewAppModule(autoCliOpts.AddressCodec, nil), } for name, mod := range modules { moduleBasicManager[name] = module.CoreAppModuleBasicAdaptor(name, mod) diff --git a/x/aura/client/cli/query.go b/x/aura/client/cli/query.go deleted file mode 100644 index 0d05be7..0000000 --- a/x/aura/client/cli/query.go +++ /dev/null @@ -1,194 +0,0 @@ -package cli - -import ( - "context" - "fmt" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/ondoprotocol/usdy-noble/v2/x/aura/types" - "github.com/spf13/cobra" -) - -func GetQueryCmd() *cobra.Command { - cmd := &cobra.Command{ - Use: types.ModuleName, - Short: fmt.Sprintf("Querying commands for the %s module", types.ModuleName), - DisableFlagParsing: false, - SuggestionsMinimumDistance: 2, - RunE: client.ValidateCmd, - } - - cmd.AddCommand(GetBlocklistQueryCmd()) - - cmd.AddCommand(QueryDenom()) - cmd.AddCommand(QueryPaused()) - cmd.AddCommand(QueryOwner()) - cmd.AddCommand(QueryBurners()) - cmd.AddCommand(QueryMinters()) - cmd.AddCommand(QueryPausers()) - cmd.AddCommand(QueryBlockedChannels()) - - return cmd -} - -func QueryDenom() *cobra.Command { - cmd := &cobra.Command{ - Use: "denom", - Short: "Query the module's denom", - Args: cobra.NoArgs, - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx := client.GetClientContextFromCmd(cmd) - queryClient := types.NewQueryClient(clientCtx) - - res, err := queryClient.Denom(context.Background(), &types.QueryDenom{}) - if err != nil { - return err - } - - return clientCtx.PrintProto(res) - }, - } - - flags.AddQueryFlagsToCmd(cmd) - - return cmd -} - -func QueryPaused() *cobra.Command { - cmd := &cobra.Command{ - Use: "paused", - Short: "Query if the module is paused", - Args: cobra.NoArgs, - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx := client.GetClientContextFromCmd(cmd) - queryClient := types.NewQueryClient(clientCtx) - - res, err := queryClient.Paused(context.Background(), &types.QueryPaused{}) - if err != nil { - return err - } - - return clientCtx.PrintProto(res) - }, - } - - flags.AddQueryFlagsToCmd(cmd) - - return cmd -} - -func QueryOwner() *cobra.Command { - cmd := &cobra.Command{ - Use: "owner", - Short: "Query the module's owner", - Args: cobra.NoArgs, - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx := client.GetClientContextFromCmd(cmd) - queryClient := types.NewQueryClient(clientCtx) - - res, err := queryClient.Owner(context.Background(), &types.QueryOwner{}) - if err != nil { - return err - } - - return clientCtx.PrintProto(res) - }, - } - - flags.AddQueryFlagsToCmd(cmd) - - return cmd -} - -func QueryBurners() *cobra.Command { - cmd := &cobra.Command{ - Use: "burners", - Short: "Query the module's burners", - Args: cobra.NoArgs, - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx := client.GetClientContextFromCmd(cmd) - queryClient := types.NewQueryClient(clientCtx) - - res, err := queryClient.Burners(context.Background(), &types.QueryBurners{}) - if err != nil { - return err - } - - return clientCtx.PrintProto(res) - }, - } - - flags.AddQueryFlagsToCmd(cmd) - - return cmd -} - -func QueryMinters() *cobra.Command { - cmd := &cobra.Command{ - Use: "minters", - Short: "Query the module's minters", - Args: cobra.NoArgs, - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx := client.GetClientContextFromCmd(cmd) - queryClient := types.NewQueryClient(clientCtx) - - res, err := queryClient.Minters(context.Background(), &types.QueryMinters{}) - if err != nil { - return err - } - - return clientCtx.PrintProto(res) - }, - } - - flags.AddQueryFlagsToCmd(cmd) - - return cmd -} - -func QueryPausers() *cobra.Command { - cmd := &cobra.Command{ - Use: "pausers", - Short: "Query the module's pausers", - Args: cobra.NoArgs, - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx := client.GetClientContextFromCmd(cmd) - queryClient := types.NewQueryClient(clientCtx) - - res, err := queryClient.Pausers(context.Background(), &types.QueryPausers{}) - if err != nil { - return err - } - - return clientCtx.PrintProto(res) - }, - } - - flags.AddQueryFlagsToCmd(cmd) - - return cmd -} - -func QueryBlockedChannels() *cobra.Command { - cmd := &cobra.Command{ - Use: "blocked-channels", - Short: "Query the blocked channels", - Args: cobra.NoArgs, - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx := client.GetClientContextFromCmd(cmd) - queryClient := types.NewQueryClient(clientCtx) - - res, err := queryClient.BlockedChannels(context.Background(), &types.QueryBlockedChannels{}) - if err != nil { - return err - } - - return clientCtx.PrintProto(res) - }, - } - - flags.AddQueryFlagsToCmd(cmd) - - return cmd -} diff --git a/x/aura/client/cli/query_blocklist.go b/x/aura/client/cli/query_blocklist.go deleted file mode 100644 index b675326..0000000 --- a/x/aura/client/cli/query_blocklist.go +++ /dev/null @@ -1,104 +0,0 @@ -package cli - -import ( - "context" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/ondoprotocol/usdy-noble/v2/x/aura/types/blocklist" - "github.com/spf13/cobra" -) - -func GetBlocklistQueryCmd() *cobra.Command { - cmd := &cobra.Command{ - Use: "blocklist", - Short: "Querying commands for the blocklist submodule", - DisableFlagParsing: false, - SuggestionsMinimumDistance: 2, - RunE: client.ValidateCmd, - } - - cmd.AddCommand(QueryBlocklistOwner()) - cmd.AddCommand(QueryBlockedAddresses()) - cmd.AddCommand(QueryBlockedAddress()) - - return cmd -} - -func QueryBlocklistOwner() *cobra.Command { - cmd := &cobra.Command{ - Use: "owner", - Short: "Query the submodule's owner", - Args: cobra.NoArgs, - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx := client.GetClientContextFromCmd(cmd) - queryClient := blocklist.NewQueryClient(clientCtx) - - res, err := queryClient.Owner(context.Background(), &blocklist.QueryOwner{}) - if err != nil { - return err - } - - return clientCtx.PrintProto(res) - }, - } - - flags.AddQueryFlagsToCmd(cmd) - - return cmd -} - -func QueryBlockedAddresses() *cobra.Command { - cmd := &cobra.Command{ - Use: "addresses", - Short: "Query for all blocked addresses", - Args: cobra.NoArgs, - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx := client.GetClientContextFromCmd(cmd) - queryClient := blocklist.NewQueryClient(clientCtx) - - pagination, err := client.ReadPageRequest(cmd.Flags()) - if err != nil { - return err - } - - res, err := queryClient.Addresses(context.Background(), &blocklist.QueryAddresses{ - Pagination: pagination, - }) - if err != nil { - return err - } - - return clientCtx.PrintProto(res) - }, - } - - flags.AddQueryFlagsToCmd(cmd) - - return cmd -} - -func QueryBlockedAddress() *cobra.Command { - cmd := &cobra.Command{ - Use: "address", - Short: "Query if an address is blocked", - Args: cobra.ExactArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx := client.GetClientContextFromCmd(cmd) - queryClient := blocklist.NewQueryClient(clientCtx) - - res, err := queryClient.Address(context.Background(), &blocklist.QueryAddress{ - Address: args[0], - }) - if err != nil { - return err - } - - return clientCtx.PrintProto(res) - }, - } - - flags.AddQueryFlagsToCmd(cmd) - - return cmd -} diff --git a/x/aura/client/cli/tx.go b/x/aura/client/cli/tx.go deleted file mode 100644 index 96de69d..0000000 --- a/x/aura/client/cli/tx.go +++ /dev/null @@ -1,478 +0,0 @@ -package cli - -import ( - "errors" - "fmt" - - "cosmossdk.io/math" - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/cosmos/cosmos-sdk/client/tx" - "github.com/ondoprotocol/usdy-noble/v2/x/aura/types" - "github.com/spf13/cobra" -) - -func GetTxCmd() *cobra.Command { - cmd := &cobra.Command{ - Use: types.ModuleName, - Short: fmt.Sprintf("Transactions commands for the %s module", types.ModuleName), - DisableFlagParsing: true, - SuggestionsMinimumDistance: 2, - RunE: client.ValidateCmd, - } - - cmd.AddCommand(GetBlocklistTxCmd()) - - cmd.AddCommand(TxBurn()) - cmd.AddCommand(TxMint()) - cmd.AddCommand(TxPause()) - cmd.AddCommand(TxUnpause()) - cmd.AddCommand(TxTransferOwnership()) - cmd.AddCommand(TxAcceptOwnership()) - cmd.AddCommand(TxAddBurner()) - cmd.AddCommand(TxRemoveBurner()) - cmd.AddCommand(TxSetBurnerAllowance()) - cmd.AddCommand(TxAddMinter()) - cmd.AddCommand(TxRemoveMinter()) - cmd.AddCommand(TxSetMinterAllowance()) - cmd.AddCommand(TxAddPauser()) - cmd.AddCommand(TxRemovePauser()) - cmd.AddCommand(TxAddBlockedChannel()) - cmd.AddCommand(TxRemoveBlockedChannel()) - - return cmd -} - -func TxBurn() *cobra.Command { - cmd := &cobra.Command{ - Use: "burn [from] [amount]", - Short: "Transaction that burns tokens", - Args: cobra.ExactArgs(2), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - - amount, ok := math.NewIntFromString(args[1]) - if !ok { - return errors.New("invalid amount") - } - - msg := &types.MsgBurn{ - Signer: clientCtx.GetFromAddress().String(), - From: args[0], - Amount: amount, - } - - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) - }, - } - - flags.AddTxFlagsToCmd(cmd) - - return cmd -} - -func TxMint() *cobra.Command { - cmd := &cobra.Command{ - Use: "mint [to] [amount]", - Short: "Transaction that mints tokens", - Args: cobra.ExactArgs(2), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - - amount, ok := math.NewIntFromString(args[1]) - if !ok { - return errors.New("invalid amount") - } - - msg := &types.MsgMint{ - Signer: clientCtx.GetFromAddress().String(), - To: args[0], - Amount: amount, - } - - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) - }, - } - - flags.AddTxFlagsToCmd(cmd) - - return cmd -} - -func TxPause() *cobra.Command { - cmd := &cobra.Command{ - Use: "pause", - Short: "Transaction that pauses the module", - Args: cobra.NoArgs, - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - - msg := &types.MsgPause{ - Signer: clientCtx.GetFromAddress().String(), - } - - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) - }, - } - - flags.AddTxFlagsToCmd(cmd) - - return cmd -} - -func TxUnpause() *cobra.Command { - cmd := &cobra.Command{ - Use: "unpause", - Short: "Transaction that unpauses the module", - Args: cobra.NoArgs, - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - - msg := &types.MsgUnpause{ - Signer: clientCtx.GetFromAddress().String(), - } - - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) - }, - } - - flags.AddTxFlagsToCmd(cmd) - - return cmd -} - -func TxTransferOwnership() *cobra.Command { - cmd := &cobra.Command{ - Use: "transfer-ownership [new-owner]", - Short: "Transfer ownership of module", - Args: cobra.ExactArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - - msg := &types.MsgTransferOwnership{ - Signer: clientCtx.GetFromAddress().String(), - NewOwner: args[0], - } - - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) - }, - } - - flags.AddTxFlagsToCmd(cmd) - - return cmd -} - -func TxAcceptOwnership() *cobra.Command { - cmd := &cobra.Command{ - Use: "accept-ownership", - Short: "Accept ownership of module", - Long: "Accept ownership of module, assuming there is an pending ownership transfer", - Args: cobra.NoArgs, - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - - msg := &types.MsgAcceptOwnership{ - Signer: clientCtx.GetFromAddress().String(), - } - - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) - }, - } - - flags.AddTxFlagsToCmd(cmd) - - return cmd -} - -func TxAddBurner() *cobra.Command { - cmd := &cobra.Command{ - Use: "add-burner [burner] [allowance]", - Short: "Add a new burner with an initial allowance", - Args: cobra.ExactArgs(2), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - - allowance, ok := math.NewIntFromString(args[1]) - if !ok { - return errors.New("invalid allowance") - } - - msg := &types.MsgAddBurner{ - Signer: clientCtx.GetFromAddress().String(), - Burner: args[0], - Allowance: allowance, - } - - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) - }, - } - - flags.AddTxFlagsToCmd(cmd) - - return cmd -} - -func TxRemoveBurner() *cobra.Command { - cmd := &cobra.Command{ - Use: "remove-burner [burner]", - Short: "Remove an existing burner", - Args: cobra.ExactArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - - msg := &types.MsgRemoveBurner{ - Signer: clientCtx.GetFromAddress().String(), - Burner: args[0], - } - - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) - }, - } - - flags.AddTxFlagsToCmd(cmd) - - return cmd -} - -func TxSetBurnerAllowance() *cobra.Command { - cmd := &cobra.Command{ - Use: "set-burner-allowance [burner] [allowance]", - Short: "Set an existing burner's allowance", - Args: cobra.ExactArgs(2), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - - allowance, ok := math.NewIntFromString(args[1]) - if !ok { - return errors.New("invalid allowance") - } - - msg := &types.MsgSetBurnerAllowance{ - Signer: clientCtx.GetFromAddress().String(), - Burner: args[0], - Allowance: allowance, - } - - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) - }, - } - - flags.AddTxFlagsToCmd(cmd) - - return cmd -} - -func TxAddMinter() *cobra.Command { - cmd := &cobra.Command{ - Use: "add-minter [minter] [allowance]", - Short: "Add a new minter with an initial allowance", - Args: cobra.ExactArgs(2), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - - allowance, ok := math.NewIntFromString(args[1]) - if !ok { - return errors.New("invalid allowance") - } - - msg := &types.MsgAddMinter{ - Signer: clientCtx.GetFromAddress().String(), - Minter: args[0], - Allowance: allowance, - } - - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) - }, - } - - flags.AddTxFlagsToCmd(cmd) - - return cmd -} - -func TxRemoveMinter() *cobra.Command { - cmd := &cobra.Command{ - Use: "remove-minter [minter]", - Short: "Remove an existing minter", - Args: cobra.ExactArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - - msg := &types.MsgRemoveMinter{ - Signer: clientCtx.GetFromAddress().String(), - Minter: args[0], - } - - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) - }, - } - - flags.AddTxFlagsToCmd(cmd) - - return cmd -} - -func TxSetMinterAllowance() *cobra.Command { - cmd := &cobra.Command{ - Use: "set-minter-allowance [minter] [allowance]", - Short: "Set an existing minter's allowance", - Args: cobra.ExactArgs(2), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - - allowance, ok := math.NewIntFromString(args[1]) - if !ok { - return errors.New("invalid allowance") - } - - msg := &types.MsgSetMinterAllowance{ - Signer: clientCtx.GetFromAddress().String(), - Minter: args[0], - Allowance: allowance, - } - - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) - }, - } - - flags.AddTxFlagsToCmd(cmd) - - return cmd -} - -func TxAddPauser() *cobra.Command { - cmd := &cobra.Command{ - Use: "add-pauser [pauser]", - Short: "Add a new pauser", - Args: cobra.ExactArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - - msg := &types.MsgAddPauser{ - Signer: clientCtx.GetFromAddress().String(), - Pauser: args[0], - } - - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) - }, - } - - flags.AddTxFlagsToCmd(cmd) - - return cmd -} - -func TxRemovePauser() *cobra.Command { - cmd := &cobra.Command{ - Use: "remove-pauser [pauser]", - Short: "Remove an existing pauser", - Args: cobra.ExactArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - - msg := &types.MsgRemovePauser{ - Signer: clientCtx.GetFromAddress().String(), - Pauser: args[0], - } - - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) - }, - } - - flags.AddTxFlagsToCmd(cmd) - - return cmd -} - -func TxAddBlockedChannel() *cobra.Command { - cmd := &cobra.Command{ - Use: "add-blocked-channel [channel]", - Short: "Add a new blocked channel", - Args: cobra.ExactArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - - msg := &types.MsgAddBlockedChannel{ - Signer: clientCtx.GetFromAddress().String(), - Channel: args[0], - } - - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) - }, - } - - flags.AddTxFlagsToCmd(cmd) - - return cmd -} - -func TxRemoveBlockedChannel() *cobra.Command { - cmd := &cobra.Command{ - Use: "remove-blocked-channel [channel]", - Short: "Remove an existing blocked channel", - Args: cobra.ExactArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - - msg := &types.MsgRemoveBlockedChannel{ - Signer: clientCtx.GetFromAddress().String(), - Channel: args[0], - } - - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) - }, - } - - flags.AddTxFlagsToCmd(cmd) - - return cmd -} diff --git a/x/aura/client/cli/tx_blocklist.go b/x/aura/client/cli/tx_blocklist.go deleted file mode 100644 index 1318c18..0000000 --- a/x/aura/client/cli/tx_blocklist.go +++ /dev/null @@ -1,126 +0,0 @@ -package cli - -import ( - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/cosmos/cosmos-sdk/client/tx" - "github.com/ondoprotocol/usdy-noble/v2/x/aura/types/blocklist" - "github.com/spf13/cobra" -) - -func GetBlocklistTxCmd() *cobra.Command { - cmd := &cobra.Command{ - Use: "blocklist", - Short: "Transactions commands for the blocklist submodule", - DisableFlagParsing: true, - SuggestionsMinimumDistance: 2, - RunE: client.ValidateCmd, - } - - cmd.AddCommand(TxBlocklistTransferOwnership()) - cmd.AddCommand(TxBlocklistAcceptOwnership()) - cmd.AddCommand(TxAddToBlocklist()) - cmd.AddCommand(TxRemoveFromBlocklist()) - - return cmd -} - -func TxBlocklistTransferOwnership() *cobra.Command { - cmd := &cobra.Command{ - Use: "transfer-ownership [new-owner]", - Short: "Transfer ownership of submodule", - Args: cobra.ExactArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - - msg := &blocklist.MsgTransferOwnership{ - Signer: clientCtx.GetFromAddress().String(), - NewOwner: args[0], - } - - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) - }, - } - - flags.AddTxFlagsToCmd(cmd) - - return cmd -} - -func TxBlocklistAcceptOwnership() *cobra.Command { - cmd := &cobra.Command{ - Use: "accept-ownership", - Short: "Accept ownership of submodule", - Long: "Accept ownership of submodule, assuming there is an pending ownership transfer", - Args: cobra.NoArgs, - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - - msg := &blocklist.MsgAcceptOwnership{ - Signer: clientCtx.GetFromAddress().String(), - } - - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) - }, - } - - flags.AddTxFlagsToCmd(cmd) - - return cmd -} - -func TxAddToBlocklist() *cobra.Command { - cmd := &cobra.Command{ - Use: "add-to-blocklist [addresses ...]", - Short: "Add a list of accounts to the blocklist", - Args: cobra.MinimumNArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - - msg := &blocklist.MsgAddToBlocklist{ - Signer: clientCtx.GetFromAddress().String(), - Accounts: args, - } - - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) - }, - } - - flags.AddTxFlagsToCmd(cmd) - - return cmd -} - -func TxRemoveFromBlocklist() *cobra.Command { - cmd := &cobra.Command{ - Use: "remove-from-blocklist [addresses ...]", - Short: "Remove a list of accounts from the blocklist", - Args: cobra.MinimumNArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - - msg := &blocklist.MsgRemoveFromBlocklist{ - Signer: clientCtx.GetFromAddress().String(), - Accounts: args, - } - - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) - }, - } - - flags.AddTxFlagsToCmd(cmd) - - return cmd -} diff --git a/x/aura/module.go b/x/aura/module.go index b3468df..542d527 100644 --- a/x/aura/module.go +++ b/x/aura/module.go @@ -5,19 +5,25 @@ import ( "encoding/json" "fmt" + autocliv1 "cosmossdk.io/api/cosmos/autocli/v1" "cosmossdk.io/core/address" "cosmossdk.io/core/appmodule" + "cosmossdk.io/core/event" + "cosmossdk.io/core/store" + "cosmossdk.io/depinject" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/ondoprotocol/usdy-noble/v2/x/aura/client/cli" + blocklistv1 "github.com/ondoprotocol/usdy-noble/v2/api/blocklist/v1" + modulev1 "github.com/ondoprotocol/usdy-noble/v2/api/module/v1" + aurav1 "github.com/ondoprotocol/usdy-noble/v2/api/v1" "github.com/ondoprotocol/usdy-noble/v2/x/aura/keeper" "github.com/ondoprotocol/usdy-noble/v2/x/aura/types" "github.com/ondoprotocol/usdy-noble/v2/x/aura/types/blocklist" - "github.com/spf13/cobra" ) // ConsensusVersion defines the current x/aura module consensus version. @@ -118,10 +124,265 @@ func (m AppModule) RegisterServices(cfg module.Configurator) { // -func (AppModuleBasic) GetTxCmd() *cobra.Command { - return cli.GetTxCmd() +func (AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { + return &autocliv1.ModuleOptions{ + Tx: &autocliv1.ServiceCommandDescriptor{ + Service: aurav1.Msg_ServiceDesc.ServiceName, + RpcCommandOptions: []*autocliv1.RpcCommandOptions{ + { + RpcMethod: "Burn", + Use: "burn [from] [amount]", + Short: "Transaction that burns tokens", + PositionalArgs: []*autocliv1.PositionalArgDescriptor{ + {ProtoField: "from"}, + {ProtoField: "amount"}, + }, + }, + { + RpcMethod: "Mint", + Use: "mint [to] [amount]", + Short: "Transaction that mints tokens", + PositionalArgs: []*autocliv1.PositionalArgDescriptor{ + {ProtoField: "to"}, + {ProtoField: "amount"}, + }, + }, + { + RpcMethod: "Pause", + Use: "pause", + Short: "Transaction that pauses the module", + }, + { + RpcMethod: "Unpause", + Use: "unpause", + Short: "Transaction that unpauses the module", + }, + { + RpcMethod: "TransferOwnership", + Use: "transfer-ownership [new-owner]", + Short: "Transfer ownership of module", + PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "new_owner"}}, + }, + { + RpcMethod: "AcceptOwnership", + Use: "accept-ownership", + Short: "Accept ownership of module", + Long: "Accept ownership of module, assuming there is an pending ownership transfer", + }, + { + RpcMethod: "AddBurner", + Use: "add-burner [burner] [allowance]", + Short: "Add a new burner with an initial allowance", + PositionalArgs: []*autocliv1.PositionalArgDescriptor{ + {ProtoField: "burner"}, + {ProtoField: "allowance"}, + }, + }, + { + RpcMethod: "RemoveBurner", + Use: "remove-burner [burner]", + Short: "Remove an existing burner", + PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "burner"}}, + }, + { + RpcMethod: "SetBurnerAllowance", + Use: "set-burner-allowance [burner] [allowance]", + Short: "Set an existing burner's allowance", + PositionalArgs: []*autocliv1.PositionalArgDescriptor{ + {ProtoField: "burner"}, + {ProtoField: "allowance"}, + }, + }, + { + RpcMethod: "AddMinter", + Use: "add-minter [minter] [allowance]", + Short: "Add a new minter with an initial allowance", + PositionalArgs: []*autocliv1.PositionalArgDescriptor{ + {ProtoField: "minter"}, + {ProtoField: "allowance"}, + }, + }, + { + RpcMethod: "RemoveMinter", + Use: "remove-minter [minter]", + Short: "Remove an existing minter", + PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "minter"}}, + }, + { + RpcMethod: "SetMinterAllowance", + Use: "set-minter-allowance [minter] [allowance]", + Short: "Set an existing minter's allowance", + PositionalArgs: []*autocliv1.PositionalArgDescriptor{ + {ProtoField: "minter"}, + {ProtoField: "allowance"}, + }, + }, + { + RpcMethod: "AddPauser", + Use: "add-pauser [pauser]", + Short: "Add a new pauser", + PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "pauser"}}, + }, + { + RpcMethod: "RemovePauser", + Use: "remove-pauser [pauser]", + Short: "Remove an existing pauser", + PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "pauser"}}, + }, + { + RpcMethod: "AddBlockedChannel", + Use: "add-blocked-channel [channel]", + Short: "Add a new blocked channel", + PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "channel"}}, + }, + { + RpcMethod: "RemoveBlockedChannel", + Use: "remove-blocked-channel [channel]", + Short: "Remove an existing blocked channel", + PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "channel"}}, + }, + }, + SubCommands: map[string]*autocliv1.ServiceCommandDescriptor{ + "blocklist": { + Service: blocklistv1.Msg_ServiceDesc.ServiceName, + Short: "Transactions commands for the blocklist submodule", + RpcCommandOptions: []*autocliv1.RpcCommandOptions{ + { + RpcMethod: "TransferOwnership", + Use: "transfer-ownership [new-owner]", + Short: "Transfer ownership of submodule", + PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "new_owner"}}, + }, + { + RpcMethod: "AcceptOwnership", + Use: "accept-ownership", + Short: "Accept ownership of submodule", + Long: "Accept ownership of submodule, assuming there is an pending ownership transfer", + }, + { + RpcMethod: "AddToBlocklist", + Use: "add-to-blocklist [addresses ...]", + Short: "Add a list of accounts to the blocklist", + PositionalArgs: []*autocliv1.PositionalArgDescriptor{ + {ProtoField: "accounts", Varargs: true}, + }, + }, + { + RpcMethod: "RemoveFromBlocklist", + Use: "remove-from-blocklist [addresses ...]", + Short: "Remove a list of accounts from the blocklist", + PositionalArgs: []*autocliv1.PositionalArgDescriptor{ + {ProtoField: "accounts", Varargs: true}, + }, + }, + }, + }, + }, + }, + Query: &autocliv1.ServiceCommandDescriptor{ + Service: aurav1.Query_ServiceDesc.ServiceName, + RpcCommandOptions: []*autocliv1.RpcCommandOptions{ + { + RpcMethod: "Denom", + Use: "denom", + Short: "Query the module's denom", + }, + { + RpcMethod: "Paused", + Use: "paused", + Short: "Query if the module is paused", + }, + { + RpcMethod: "Owner", + Use: "owner", + Short: "Query the module's owner", + }, + { + RpcMethod: "Burners", + Use: "burners", + Short: "Query the module's burners", + }, + { + RpcMethod: "Minters", + Use: "minters", + Short: "Query the module's minters", + }, + { + RpcMethod: "Pausers", + Use: "pausers", + Short: "Query the module's pausers", + }, + { + RpcMethod: "BlockedChannels", + Use: "blocked-channels", + Short: "Query the blocked channels", + }, + }, + SubCommands: map[string]*autocliv1.ServiceCommandDescriptor{ + "blocklist": { + Service: blocklistv1.Query_ServiceDesc.ServiceName, + Short: "Querying commands for the blocklist submodule", + RpcCommandOptions: []*autocliv1.RpcCommandOptions{ + { + RpcMethod: "Owner", + Use: "owner", + Short: "Query the submodule's owner", + }, + { + RpcMethod: "Addresses", + Use: "addresses", + Short: "Query for all blocked addresses", + }, + { + RpcMethod: "Address", + Use: "address [address]", + Short: "Query if an address is blocked", + PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "address"}}, + }, + }, + }, + }, + }, + } } -func (AppModuleBasic) GetQueryCmd() *cobra.Command { - return cli.GetQueryCmd() +// + +func init() { + appmodule.Register(&modulev1.Module{}, + appmodule.Provide(ProvideModule), + ) +} + +type ModuleInputs struct { + depinject.In + + Config *modulev1.Module + StoreService store.KVStoreService + EventService event.Service + + Cdc codec.Codec + AddressCodec address.Codec + BankKeeper types.BankKeeper +} + +type ModuleOutputs struct { + depinject.Out + + Keeper *keeper.Keeper + Module appmodule.AppModule + Restriction banktypes.SendRestrictionFn +} + +func ProvideModule(in ModuleInputs) ModuleOutputs { + k := keeper.NewKeeper( + in.Config.Denom, + in.StoreService, + in.EventService, + in.AddressCodec, + in.BankKeeper, + ) + m := NewAppModule(in.AddressCodec, k) + + return ModuleOutputs{Keeper: k, Module: m, Restriction: k.SendRestrictionFn} }