diff --git a/go.mod b/go.mod index 9bb027094..cbd61d7bd 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/AssetMantle/schema v0.0.0-20240206102051-27352b802163 github.com/CosmWasm/wasmd v0.45.0 github.com/Shopify/sarama v1.19.0 - github.com/cometbft/cometbft v0.37.5 + github.com/cometbft/cometbft v0.37.7 github.com/cometbft/cometbft-db v0.8.0 github.com/cosmos/cosmos-sdk v0.47.11 github.com/cosmos/gogoproto v1.4.10 @@ -22,7 +22,7 @@ require ( google.golang.org/grpc v1.62.1 ) -replace github.com/AssetMantle/schema => ../schema +//replace github.com/AssetMantle/schema => ../schema require ( cloud.google.com/go v0.112.0 // indirect @@ -115,6 +115,7 @@ require ( github.com/hashicorp/go-safetemp v1.0.0 // indirect github.com/hashicorp/go-version v1.6.0 // indirect github.com/hashicorp/golang-lru v1.0.2 // indirect + github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect github.com/hashicorp/hcl v1.0.0 // indirect github.com/hdevalence/ed25519consensus v0.1.0 // indirect github.com/huandu/skiplist v1.2.0 // indirect diff --git a/go.sum b/go.sum index 1d8dbcb6f..eb563e423 100644 --- a/go.sum +++ b/go.sum @@ -377,8 +377,8 @@ github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE github.com/coinbase/kryptology v1.8.0/go.mod h1:RYXOAPdzOGUe3qlSFkMGn58i3xUA8hmxYHksuq+8ciI= github.com/coinbase/rosetta-sdk-go v0.7.9 h1:lqllBjMnazTjIqYrOGv8h8jxjg9+hJazIGZr9ZvoCcA= github.com/coinbase/rosetta-sdk-go v0.7.9/go.mod h1:0/knutI7XGVqXmmH4OQD8OckFrbQ8yMsUZTG7FXCR2M= -github.com/cometbft/cometbft v0.37.5 h1:/U/TlgMh4NdnXNo+YU9T2NMCWyhXNDF34Mx582jlvq0= -github.com/cometbft/cometbft v0.37.5/go.mod h1:QC+mU0lBhKn8r9qvmnq53Dmf3DWBt4VtkcKw2C81wxY= +github.com/cometbft/cometbft v0.37.7 h1:pwC0PNfGcbKbAKyK/sWm+LwuiYmT00C3bF2nEnnjJ/k= +github.com/cometbft/cometbft v0.37.7/go.mod h1:gFGCFXNGDci6tMLemANPGTfU+j4+oH63PjeLe0iIjJk= github.com/cometbft/cometbft-db v0.8.0 h1:vUMDaH3ApkX8m0KZvOFFy9b5DZHBAjsnEuo9AKVZpjo= github.com/cometbft/cometbft-db v0.8.0/go.mod h1:6ASCP4pfhmrCBpfk01/9E1SI29nD3HfVHrY4PG8x5c0= github.com/confio/ics23/go v0.9.0 h1:cWs+wdbS2KRPZezoaaj+qBleXgUk5WOQFMP3CQFGTr4= @@ -774,6 +774,8 @@ github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= github.com/hashicorp/golang-lru v1.0.2 h1:dV3g9Z/unq5DpblPpw+Oqcv4dU/1omnb4Ok8iPY6p1c= github.com/hashicorp/golang-lru v1.0.2/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= +github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k= +github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= diff --git a/helpers/base/cli_command.go b/helpers/base/cli_command.go index 948421a6a..6d9a9b361 100644 --- a/helpers/base/cli_command.go +++ b/helpers/base/cli_command.go @@ -5,11 +5,8 @@ package base import ( "fmt" - "github.com/AssetMantle/modules/utilities/rest" - "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/spf13/cobra" "github.com/AssetMantle/modules/helpers" @@ -85,12 +82,8 @@ func (cliCommand cliCommand) ReadString(cliFlag helpers.CLIFlag) string { panic(fmt.Errorf("uregistered flag %v type %T", cliFlag.GetName(), cliFlag.GetValue())) } -func (cliCommand cliCommand) ReadBaseReq(context client.Context) rest.BaseReq { - return rest.BaseReq{ - From: context.GetFromAddress().String(), - ChainID: context.ChainID, - Simulate: context.Simulate, - } +func (cliCommand cliCommand) ReadCommonTransactionRequest(context client.Context) helpers.CommonTransactionRequest { + return helpers.NewCommonTransactionRequestFromContext(context) } func (cliCommand cliCommand) CreateCommand(runE func(command *cobra.Command, args []string) error) *cobra.Command { command := &cobra.Command{ diff --git a/helpers/base/cli_command_test.go b/helpers/base/cli_command_test.go index 8c4180ae7..926abae4d 100644 --- a/helpers/base/cli_command_test.go +++ b/helpers/base/cli_command_test.go @@ -4,7 +4,6 @@ package base import ( - "github.com/AssetMantle/modules/utilities/rest" "reflect" "testing" @@ -103,11 +102,11 @@ func Test_cliCommand_ReadBaseReq(t *testing.T) { name string fields fields args args - want rest.BaseReq + want helpers.CommonTransactionRequest }{ - {"+ve", fields{"", "", "", testCliFlagList}, args{client.Context{ChainID: "chainID"}}, rest.BaseReq{ChainID: "chainID"}}, - {"-ve for nil", fields{"", "", "", nil}, args{client.Context{ChainID: ""}}, rest.BaseReq{ChainID: ""}}, + {"+ve", fields{"", "", "", testCliFlagList}, args{client.Context{ChainID: "chainID"}}, helpers.PrototypeCommonTransactionRequest()}, + {"-ve for nil", fields{"", "", "", nil}, args{client.Context{ChainID: ""}}, helpers.PrototypeCommonTransactionRequest()}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -117,8 +116,8 @@ func Test_cliCommand_ReadBaseReq(t *testing.T) { long: tt.fields.long, cliFlagList: tt.fields.cliFlagList, } - if got := cliCommand.ReadBaseReq(tt.args.context); !reflect.DeepEqual(got, tt.want) { - t.Errorf("ReadBaseReq() = %v, want %v", got, tt.want) + if got := cliCommand.ReadCommonTransactionRequest(tt.args.context); !reflect.DeepEqual(got, tt.want) { + t.Errorf("ReadCommonTransactionRequest() = %v, want %v", got, tt.want) } }) } diff --git a/helpers/base/cli_flag.go b/helpers/base/cli_flag.go index 7c836b821..b4d216c6b 100644 --- a/helpers/base/cli_flag.go +++ b/helpers/base/cli_flag.go @@ -5,7 +5,6 @@ package base import ( "fmt" - "github.com/spf13/cobra" "github.com/spf13/viper" diff --git a/helpers/base/codec.go b/helpers/base/codec.go index 1bf24e46c..47a5e72b8 100644 --- a/helpers/base/codec.go +++ b/helpers/base/codec.go @@ -2,8 +2,6 @@ package base import ( "github.com/AssetMantle/modules/helpers" - "github.com/AssetMantle/modules/utilities/rest/id_getters/docs" - schemaCodec "github.com/AssetMantle/schema/codec" sdkClient "github.com/cosmos/cosmos-sdk/client" sdkCodec "github.com/cosmos/cosmos-sdk/codec" sdkCodecTypes "github.com/cosmos/cosmos-sdk/codec/types" @@ -33,9 +31,6 @@ func (codec codec) InterfaceRegistry() sdkCodecTypes.InterfaceRegistry { func (codec codec) Initialize(moduleManager helpers.ModuleManager) helpers.Codec { std.RegisterLegacyAminoCodec(codec.legacyAmino) std.RegisterInterfaces(codec.interfaceRegistry) - helpers.RegisterLegacyAminoCodec(codec.legacyAmino) - schemaCodec.RegisterLegacyAminoCodec(codec.legacyAmino) - docs.RegisterLegacyAminoCodec(codec.legacyAmino) moduleManager.RegisterLegacyAminoCodec(codec.legacyAmino) moduleManager.RegisterInterfaces(codec.interfaceRegistry) return codec diff --git a/helpers/base/collection.go b/helpers/base/collection.go index 9bc574541..c6ca496ea 100644 --- a/helpers/base/collection.go +++ b/helpers/base/collection.go @@ -5,7 +5,6 @@ package base import ( "context" - "github.com/AssetMantle/modules/helpers" ) diff --git a/helpers/base/invariants.go b/helpers/base/invariants.go index 3611c8d70..401138a48 100644 --- a/helpers/base/invariants.go +++ b/helpers/base/invariants.go @@ -1,9 +1,8 @@ package base import ( - sdkTypes "github.com/cosmos/cosmos-sdk/types" - "github.com/AssetMantle/modules/helpers" + sdkTypes "github.com/cosmos/cosmos-sdk/types" ) type invariants struct { diff --git a/helpers/base/mapper.go b/helpers/base/mapper.go index 54db19975..9eb34641a 100644 --- a/helpers/base/mapper.go +++ b/helpers/base/mapper.go @@ -7,10 +7,9 @@ import ( "bytes" "context" "fmt" - sdkTypes "github.com/cosmos/cosmos-sdk/types" - prefixStore "github.com/cosmos/cosmos-sdk/store/prefix" storeTypes "github.com/cosmos/cosmos-sdk/store/types" + sdkTypes "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/kv" "github.com/AssetMantle/modules/helpers" diff --git a/helpers/base/module.go b/helpers/base/module.go index fb3e3a839..172df31a3 100644 --- a/helpers/base/module.go +++ b/helpers/base/module.go @@ -6,13 +6,11 @@ package base import ( "encoding/json" "fmt" - storeTypes "github.com/cosmos/cosmos-sdk/store/types" - "math/rand" - abciTypes "github.com/cometbft/cometbft/abci/types" "github.com/cosmos/cosmos-sdk/client" sdkCodec "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/types" + storeTypes "github.com/cosmos/cosmos-sdk/store/types" sdkTypes "github.com/cosmos/cosmos-sdk/types" sdkModuleTypes "github.com/cosmos/cosmos-sdk/types/module" simulationTypes "github.com/cosmos/cosmos-sdk/types/simulation" @@ -20,6 +18,7 @@ import ( "github.com/gorilla/mux" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" + "math/rand" "github.com/AssetMantle/modules/helpers" ) @@ -49,26 +48,13 @@ type module struct { var _ helpers.Module = (*module)(nil) -func (module module) IsOnePerModuleType() { - //TODO implement me - panic("implement me") -} - -func (module module) IsAppModule() { - //TODO implement me - panic("implement me") -} func (module module) Name() string { return module.name } func (module module) GetTransactions() helpers.Transactions { return module.transactions } -func (module module) RegisterLegacyAminoCodec(legacyAmino *sdkCodec.LegacyAmino) { - for _, transaction := range module.transactionsPrototype().Get() { - transaction.RegisterLegacyAminoCodec(legacyAmino) - } -} +func (module module) RegisterLegacyAminoCodec(_ *sdkCodec.LegacyAmino) {} func (module module) RegisterInterfaces(interfaceRegistry types.InterfaceRegistry) { for _, transaction := range module.transactionsPrototype().Get() { transaction.RegisterInterfaces(interfaceRegistry) @@ -82,29 +68,19 @@ func (module module) ValidateGenesis(jsonCodec sdkCodec.JSONCodec, _ client.TxEn return genesisState.ValidateBasic(module.parameterManagerPrototype()) } func (module module) RegisterRESTRoutes(context client.Context, router *mux.Router) { - router.HandleFunc("/"+module.Name()+"/parameters", module.parameterManagerPrototype().RESTQueryHandler(context)).Methods("GET") - - for _, query := range module.queriesPrototype().Get() { - router.HandleFunc("/"+module.Name()+"/"+query.GetName(), query.RESTQueryHandler(context)).Methods("GET") - } - - for _, transaction := range module.transactionsPrototype().Get() { - router.HandleFunc("/"+module.Name()+"/"+transaction.GetName(), transaction.RESTRequestHandler(context)).Methods("POST") - } -} -func (module module) RegisterGRPCGatewayRoutes(context client.Context, serveMux *runtime.ServeMux) { for _, query := range module.queriesPrototype().Get() { - query.RegisterGRPCGatewayRoute(context, serveMux) + router.HandleFunc(query.GetServicePath(), query.RESTQueryHandler(context)).Methods("GET") } for _, transaction := range module.transactionsPrototype().Get() { - transaction.RegisterGRPCGatewayRoute(context, serveMux) + router.HandleFunc(transaction.GetServicePath(), transaction.RESTRequestHandler(context)).Methods("POST") } } +func (module module) RegisterGRPCGatewayRoutes(_ client.Context, _ *runtime.ServeMux) {} func (module module) GetTxCmd() *cobra.Command { rootTransactionCommand := &cobra.Command{ Use: module.name, - Short: "GetProperty root transaction command.", + Short: module.name + " root transaction command.", DisableFlagParsing: true, SuggestionsMinimumDistance: 2, RunE: client.ValidateCmd, @@ -124,7 +100,7 @@ func (module module) GetTxCmd() *cobra.Command { func (module module) GetQueryCmd() *cobra.Command { rootQueryCommand := &cobra.Command{ Use: module.name, - Short: "GetProperty root query command.", + Short: module.Name() + " root query command.", DisableFlagParsing: true, SuggestionsMinimumDistance: 2, RunE: client.ValidateCmd, @@ -145,62 +121,23 @@ func (module module) GenerateGenesisState(simulationState *sdkModuleTypes.Simula module.simulatorPrototype().RandomizedGenesisState(simulationState) } func (module module) ProposalMsgs(simulationState sdkModuleTypes.SimulationState) []simulationTypes.WeightedProposalMsg { - //TODO implement me - panic("implement me") -} -func (module module) ProposalContents(simulationState sdkModuleTypes.SimulationState) []simulationTypes.WeightedProposalContent { - return module.simulatorPrototype().WeightedProposalContentList(simulationState) + return module.simulatorPrototype().ProposalMessages(simulationState) } func (module module) RandomizedParams(r *rand.Rand) []simulationTypes.LegacyParamChange { return module.simulatorPrototype().ParamChangeList(r) } -func (module module) RegisterStoreDecoder(storeDecoderRegistry sdkTypes.StoreDecoderRegistry) { - storeDecoderRegistry[module.name] = module.mapperPrototype().StoreDecoder -} func (module module) WeightedOperations(simulationState sdkModuleTypes.SimulationState) []simulationTypes.WeightedOperation { return module.simulatorPrototype().WeightedOperations(simulationState, module) } +func (module module) RegisterStoreDecoder(storeDecoderRegistry sdkTypes.StoreDecoderRegistry) { + storeDecoderRegistry[module.name] = module.mapperPrototype().StoreDecoder +} func (module module) RegisterInvariants(invariantRegistry sdkTypes.InvariantRegistry) { module.invariantsPrototype().Register(invariantRegistry) } - -// TODO remove if unnecessary -// -// func (module module) Route() sdkTypes.Route { -// return sdkTypes.NewRoute(module.Name(), func(context sdkTypes.Context, msg sdkTypes.Msg) (*sdkTypes.Result, error) { -// if module.transactions == nil { -// panic(fmt.Errorf("transactions for module %s not initialized", module.Name())) -// } -// -// if message, ok := msg.(helpers.Message); ok { -// if transaction := module.transactions.GetTransaction(message.Type()); transaction != nil { -// return transaction.HandleMessage(sdkTypes.WrapSDKContext(context.WithEventManager(sdkTypes.NewEventManager())), message) -// } -// } -// return nil, fmt.Errorf("message type %T is not supported by module %s", msg, module.Name()) -// }) -// } func (module module) QuerierRoute() string { return module.name } - -// func (module module) LegacyQuerierHandler(_ *sdkCodec.LegacyAmino) sdkTypes.Querier { -// return func(context sdkTypes.Context, path []string, requestQuery abciTypes.RequestQuery) ([]byte, error) { -// if module.queries == nil { -// panic(fmt.Errorf("queries for module %s not initialized", module.Name())) -// } -// -// if query := module.queries.GetQuery(path[0]); query != nil { -// return query.HandleQuery(sdkTypes.WrapSDKContext(context), requestQuery) -// } -// -// if path[0] == "parameters" { -// return CodecPrototype().MarshalJSON(module.parameterManager.Fetch(sdkTypes.WrapSDKContext(context)).Get()) -// } -// -// return nil, fmt.Errorf("unknown query path, %v for module %v", path[0], module.Name()) -// } -// } func (module module) RegisterServices(configurator sdkModuleTypes.Configurator) { for _, query := range module.queries.Get() { query.RegisterService(configurator) @@ -247,13 +184,6 @@ func (module module) GetAuxiliary(auxiliaryName string) helpers.Auxiliary { panic(fmt.Errorf("auxiliary %v not found/initialized", auxiliaryName)) } -func (module module) DecodeModuleTransactionRequest(transactionName string, rawMessage json.RawMessage) (sdkTypes.Msg, error) { - if transaction := module.transactionsPrototype().GetTransaction(transactionName); transaction != nil { - return transaction.DecodeTransactionRequest(rawMessage) - } - - return nil, fmt.Errorf("transaction %s is not supported by module %s", transactionName, module.Name()) -} func (module module) Initialize(kvStoreKey *storeTypes.KVStoreKey, paramsSubspace paramsTypes.Subspace, auxiliaryKeepers ...interface{}) helpers.Module { module.mapper = module.mapperPrototype().Initialize(kvStoreKey) diff --git a/helpers/base/module_manager.go b/helpers/base/module_manager.go index b632c4cd5..ee4a4f816 100644 --- a/helpers/base/module_manager.go +++ b/helpers/base/module_manager.go @@ -9,6 +9,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec/types" sdkTypes "github.com/cosmos/cosmos-sdk/types" sdkModuleTypes "github.com/cosmos/cosmos-sdk/types/module" + "github.com/gorilla/mux" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" ) @@ -19,7 +20,6 @@ type moduleManager struct { orderExportGenesis []string orderBeginBlockers []string orderEndBlockers []string - orderMigrations []string } var _ helpers.ModuleManager = (*moduleManager)(nil) @@ -39,46 +39,66 @@ func (moduleManager moduleManager) AddQueryCommands(rootQueryCmd *cobra.Command) } } func (moduleManager moduleManager) InitGenesis(context sdkTypes.Context, jsonCodec sdkCodec.JSONCodec, genesisData map[string]json.RawMessage) abciTypes.ResponseInitChain { - return moduleManager.getModuleManager().InitGenesis(context, jsonCodec, genesisData) + return moduleManager.getManager().InitGenesis(context, jsonCodec, genesisData) } func (moduleManager moduleManager) GetVersionMap() sdkModuleTypes.VersionMap { - return moduleManager.getModuleManager().GetVersionMap() + return moduleManager.getManager().GetVersionMap() } func (moduleManager moduleManager) RegisterServices(configurator sdkModuleTypes.Configurator) { - moduleManager.getModuleManager().RegisterServices(configurator) + moduleManager.getManager().RegisterServices(configurator) } -func (moduleManager moduleManager) SetOrderBeginBlockers(moduleName ...string) { - sdkModuleManager := moduleManager.getModuleManager() +func (moduleManager moduleManager) SetOrderBeginBlockers(moduleName ...string) helpers.ModuleManager { + sdkModuleManager := moduleManager.getManager() sdkModuleManager.SetOrderBeginBlockers(moduleName...) moduleManager.orderBeginBlockers = sdkModuleManager.OrderBeginBlockers + + return moduleManager } -func (moduleManager moduleManager) SetOrderEndBlockers(moduleName ...string) { - sdkModuleManager := moduleManager.getModuleManager() +func (moduleManager moduleManager) SetOrderEndBlockers(moduleName ...string) helpers.ModuleManager { + sdkModuleManager := moduleManager.getManager() sdkModuleManager.SetOrderEndBlockers(moduleName...) moduleManager.orderEndBlockers = sdkModuleManager.OrderEndBlockers + + return moduleManager } -func (moduleManager moduleManager) SetOrderInitGenesis(moduleName ...string) { - sdkModuleManager := moduleManager.getModuleManager() +func (moduleManager moduleManager) SetOrderInitGenesis(moduleName ...string) helpers.ModuleManager { + sdkModuleManager := moduleManager.getManager() sdkModuleManager.SetOrderInitGenesis(moduleName...) moduleManager.orderInitGenesis = sdkModuleManager.OrderInitGenesis + + return moduleManager +} +func (moduleManager moduleManager) SetOrderExportGenesis(moduleName ...string) helpers.ModuleManager { + sdkModuleManager := moduleManager.getManager() + sdkModuleManager.SetOrderExportGenesis(moduleName...) + moduleManager.orderExportGenesis = sdkModuleManager.OrderExportGenesis + + return moduleManager } func (moduleManager moduleManager) BeginBlock(context sdkTypes.Context, requestBeginBlock abciTypes.RequestBeginBlock) abciTypes.ResponseBeginBlock { - return moduleManager.getModuleManager().BeginBlock(context, requestBeginBlock) + return moduleManager.getManager().BeginBlock(context, requestBeginBlock) } func (moduleManager moduleManager) EndBlock(context sdkTypes.Context, requestEndBlock abciTypes.RequestEndBlock) abciTypes.ResponseEndBlock { - return moduleManager.getModuleManager().EndBlock(context, requestEndBlock) + return moduleManager.getManager().EndBlock(context, requestEndBlock) } func (moduleManager moduleManager) RunMigrations(context sdkTypes.Context, configurator sdkModuleTypes.Configurator, versionMap sdkModuleTypes.VersionMap) (sdkModuleTypes.VersionMap, error) { - return moduleManager.getModuleManager().RunMigrations(context, configurator, versionMap) + return moduleManager.getManager().RunMigrations(context, configurator, versionMap) } func (moduleManager moduleManager) RegisterInvariants(invariantRegistry sdkTypes.InvariantRegistry) { - moduleManager.getModuleManager().RegisterInvariants(invariantRegistry) + moduleManager.getManager().RegisterInvariants(invariantRegistry) } func (moduleManager moduleManager) GetBasicManager() sdkModuleTypes.BasicManager { return sdkModuleTypes.NewBasicManager(moduleManager.getAppModulesBasic()...) } func (moduleManager moduleManager) ExportGenesisForModules(context sdkTypes.Context, jsonCodec sdkCodec.JSONCodec, moduleNames []string) map[string]json.RawMessage { - return moduleManager.getModuleManager().ExportGenesisForModules(context, jsonCodec, moduleNames) + return moduleManager.getManager().ExportGenesisForModules(context, jsonCodec, moduleNames) +} +func (moduleManager moduleManager) RegisterRESTRoutes(context client.Context, router *mux.Router) { + for _, basicModule := range moduleManager.basicModules { + if module, ok := basicModule.(helpers.Module); ok { + module.RegisterRESTRoutes(context, router) + } + } } func (moduleManager moduleManager) RegisterGRPCGatewayRoutes(context client.Context, serverMux *runtime.ServeMux) { for _, basicModule := range moduleManager.basicModules { @@ -95,12 +115,28 @@ func (moduleManager moduleManager) RegisterInterfaces(interfaceRegistry types.In basicModule.RegisterInterfaces(interfaceRegistry) } } -func (moduleManager moduleManager) getModuleManager() *sdkModuleTypes.Manager { +func (moduleManager moduleManager) getManager() *sdkModuleTypes.Manager { appModules := make([]sdkModuleTypes.AppModule, len(moduleManager.basicModules)) for i, basicModule := range moduleManager.basicModules { appModules[i] = basicModule } - return sdkModuleTypes.NewManager(appModules...) + + manager := sdkModuleTypes.NewManager(appModules...) + + if len(moduleManager.orderInitGenesis) > 0 { + manager.SetOrderInitGenesis(moduleManager.orderInitGenesis...) + } + if len(moduleManager.orderExportGenesis) > 0 { + manager.SetOrderExportGenesis(moduleManager.orderExportGenesis...) + } + if len(moduleManager.orderBeginBlockers) > 0 { + manager.SetOrderBeginBlockers(moduleManager.orderBeginBlockers...) + } + if len(moduleManager.orderEndBlockers) > 0 { + manager.SetOrderEndBlockers(moduleManager.orderEndBlockers...) + } + + return manager } func (moduleManager moduleManager) getAppModulesBasic() []sdkModuleTypes.AppModuleBasic { appModules := make([]sdkModuleTypes.AppModuleBasic, len(moduleManager.basicModules)) diff --git a/helpers/base/parameter_manager.go b/helpers/base/parameter_manager.go index 1c840a534..f316ac948 100644 --- a/helpers/base/parameter_manager.go +++ b/helpers/base/parameter_manager.go @@ -5,16 +5,11 @@ package base import ( "fmt" - "github.com/AssetMantle/modules/utilities/rest" - "net/http" - "github.com/AssetMantle/schema/ids" "github.com/AssetMantle/schema/lists" baseLists "github.com/AssetMantle/schema/lists/base" "github.com/AssetMantle/schema/parameters" - "github.com/cosmos/cosmos-sdk/client" sdkTypes "github.com/cosmos/cosmos-sdk/types" - paramsTypes "github.com/cosmos/cosmos-sdk/x/params/types" "golang.org/x/net/context" @@ -22,7 +17,6 @@ import ( ) type parameterManager struct { - moduleName string validatableParameters []helpers.ValidatableParameter paramsSubspace paramsTypes.Subspace } @@ -93,30 +87,13 @@ func (parameterManager parameterManager) ParamSetPairs() paramsTypes.ParamSetPai func (parameterManager parameterManager) GetKeyTable() paramsTypes.KeyTable { return paramsTypes.NewKeyTable().RegisterParamSet(parameterManager) } -func (parameterManager parameterManager) RESTQueryHandler(clientContext client.Context) http.HandlerFunc { - return func(responseWriter http.ResponseWriter, request *http.Request) { - clientContext, ok := rest.ParseQueryHeightOrReturnBadRequest(responseWriter, clientContext, request) - if !ok { - return - } - - responseBytes, height, err := clientContext.QueryWithData(fmt.Sprintf("custom/%s/parameters", parameterManager.moduleName), nil) - if rest.CheckInternalServerError(responseWriter, err) { - return - } - - clientContext = clientContext.WithHeight(height) - rest.PostProcessResponse(responseWriter, clientContext, responseBytes) - } -} func (parameterManager parameterManager) Initialize(subspace paramsTypes.Subspace) helpers.ParameterManager { parameterManager.paramsSubspace = subspace return parameterManager } -func NewParameterManager(moduleName string, validatableParameters ...helpers.ValidatableParameter) helpers.ParameterManager { +func NewParameterManager(validatableParameters ...helpers.ValidatableParameter) helpers.ParameterManager { return parameterManager{ - moduleName: moduleName, validatableParameters: validatableParameters, } } diff --git a/helpers/base/queries.go b/helpers/base/queries.go index 4cb71a960..2f6c1e179 100644 --- a/helpers/base/queries.go +++ b/helpers/base/queries.go @@ -11,9 +11,9 @@ type queries struct { var _ helpers.Queries = (*queries)(nil) -func (queries queries) GetQuery(name string) helpers.Query { +func (queries queries) GetQuery(servicePath string) helpers.Query { for _, query := range queries.Get() { - if query.GetName() == name { + if query.GetServicePath() == servicePath { return query } } diff --git a/helpers/base/queries_test.go b/helpers/base/queries_test.go index c412da048..f9f4e8cbb 100644 --- a/helpers/base/queries_test.go +++ b/helpers/base/queries_test.go @@ -16,7 +16,7 @@ func TestQueries(t *testing.T) { Queries2 := NewQueries() // GetProperty - require.Equal(t, "", Queries1.GetQuery("").GetName()) + require.Equal(t, "", Queries1.GetQuery("").GetServicePath()) require.Equal(t, nil, Queries2.GetQuery("")) // GetAuxiliary diff --git a/helpers/base/query.go b/helpers/base/query.go index 4c2b0614d..18b012aed 100644 --- a/helpers/base/query.go +++ b/helpers/base/query.go @@ -6,13 +6,12 @@ package base import ( "fmt" "github.com/AssetMantle/modules/utilities/rest" - "net/http" - "github.com/cosmos/cosmos-sdk/client" sdkModuleTypes "github.com/cosmos/cosmos-sdk/types/module" + "net/http" + "strings" abciTypes "github.com/cometbft/cometbft/abci/types" - "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" "golang.org/x/net/context" "google.golang.org/grpc" @@ -21,61 +20,51 @@ import ( ) type query struct { - name string - cliCommand helpers.CLICommand - moduleName string - queryKeeper helpers.QueryKeeper - requestPrototype func() helpers.QueryRequest - responsePrototype func() helpers.QueryResponse - keeperPrototype func() helpers.QueryKeeper - serviceRegistrar func(grpc.ServiceRegistrar, helpers.QueryKeeper) - grpcGatewayRegistrar func(client.Context, *runtime.ServeMux) error + serviceName string + cliCommand helpers.CLICommand + queryKeeper helpers.QueryKeeper + requestPrototype func() helpers.QueryRequest + responsePrototype func() helpers.QueryResponse + keeperPrototype func() helpers.QueryKeeper + serviceRegistrar func(grpc.ServiceRegistrar, helpers.QueryKeeper) } var _ helpers.Query = (*query)(nil) func (query query) RegisterService(configurator sdkModuleTypes.Configurator) { if query.queryKeeper == nil { - panic(fmt.Errorf("query keeper for query %s not initialized", query.name)) + panic(fmt.Errorf("query keeper for query %s not initialized", query.serviceName)) } query.serviceRegistrar(configurator.QueryServer(), query.queryKeeper) } -func (query query) RegisterGRPCGatewayRoute(context client.Context, serveMux *runtime.ServeMux) { - if err := query.grpcGatewayRegistrar(context, serveMux); err != nil { - panic(err) - } +func (query query) GetServicePath() string { + splits := strings.Split(query.serviceName, ".") + return "/" + splits[3] + "/" + splits[5] } -func (query query) GetName() string { return query.name } func (query query) Command() *cobra.Command { runE := func(command *cobra.Command, args []string) error { clientContext, err := client.GetClientTxContext(command) if err != nil { return err } - queryRequest, err := query.requestPrototype().FromCLI(query.cliCommand, clientContext) if err != nil { return err } - responseBytes, _, err := query.query(queryRequest, clientContext) - if err != nil { + queryResponse := query.responsePrototype() + if err := clientContext.Invoke(context.Background(), query.serviceName+"/Handle", queryRequest, queryResponse); err != nil { return err } - response, err := query.responsePrototype().Decode(responseBytes) - if err != nil { - return err - } - - return clientContext.PrintProto(response) + return clientContext.PrintProto(queryResponse) } return query.cliCommand.CreateCommand(runE) } func (query query) HandleQuery(context context.Context, requestQuery abciTypes.RequestQuery) ([]byte, error) { - request, err := query.requestPrototype().Decode(requestQuery.Data) - if err != nil { + request := query.requestPrototype() + if err := CodecPrototype().UnmarshalJSON(requestQuery.Data, request); err != nil { return nil, err } @@ -86,11 +75,11 @@ func (query query) HandleQuery(context context.Context, requestQuery abciTypes.R return result.Encode() } -func (query query) RESTQueryHandler(context client.Context) http.HandlerFunc { +func (query query) RESTQueryHandler(Context client.Context) http.HandlerFunc { return func(responseWriter http.ResponseWriter, httpRequest *http.Request) { responseWriter.Header().Set("Content-Type", "application/json") - clientContext, ok := rest.ParseQueryHeightOrReturnBadRequest(responseWriter, context, httpRequest) + clientContext, ok := rest.ParseQueryHeightOrReturnBadRequest(responseWriter, Context, httpRequest) if !ok { return } @@ -104,14 +93,13 @@ func (query query) RESTQueryHandler(context client.Context) http.HandlerFunc { rest.WriteErrorResponse(responseWriter, http.StatusBadRequest, err.Error()) } - response, height, err := query.query(queryRequest, clientContext) - if err != nil { + queryResponse := query.responsePrototype() + if err := clientContext.Invoke(context.Background(), query.serviceName+"/Handle", queryRequest, queryResponse); err != nil { rest.WriteErrorResponse(responseWriter, http.StatusInternalServerError, err.Error()) return } - clientContext = clientContext.WithHeight(height) - rest.PostProcessResponse(responseWriter, clientContext, response) + rest.PostProcessResponse(responseWriter, clientContext, queryResponse) } } func (query query) Initialize(mapper helpers.Mapper, parameterManager helpers.ParameterManager, auxiliaryKeepers ...interface{}) helpers.Query { @@ -119,24 +107,14 @@ func (query query) Initialize(mapper helpers.Mapper, parameterManager helpers.Pa return query } -func (query query) query(queryRequest helpers.QueryRequest, context client.Context) ([]byte, int64, error) { - bytes, err := queryRequest.Encode() - if err != nil { - return nil, 0, err - } - - return context.QueryWithData("custom"+"/"+query.moduleName+"/"+query.name, bytes) -} - -func NewQuery(name string, short string, long string, moduleName string, requestPrototype func() helpers.QueryRequest, responsePrototype func() helpers.QueryResponse, keeperPrototype func() helpers.QueryKeeper, serviceRegistrar func(grpc.ServiceRegistrar, helpers.QueryKeeper), grpcGatewayRegistrar func(client.Context, *runtime.ServeMux) error, flagList ...helpers.CLIFlag) helpers.Query { +func NewQuery(serviceName string, short string, long string, requestPrototype func() helpers.QueryRequest, responsePrototype func() helpers.QueryResponse, keeperPrototype func() helpers.QueryKeeper, serviceRegistrar func(grpc.ServiceRegistrar, helpers.QueryKeeper), flagList ...helpers.CLIFlag) helpers.Query { + splits := strings.Split(serviceName, ".") return query{ - name: name, - cliCommand: NewCLICommand(name, short, long, flagList), - moduleName: moduleName, - requestPrototype: requestPrototype, - responsePrototype: responsePrototype, - keeperPrototype: keeperPrototype, - serviceRegistrar: serviceRegistrar, - grpcGatewayRegistrar: grpcGatewayRegistrar, + serviceName: serviceName, + cliCommand: NewCLICommand(splits[5], short, long, flagList), + requestPrototype: requestPrototype, + responsePrototype: responsePrototype, + keeperPrototype: keeperPrototype, + serviceRegistrar: serviceRegistrar, } } diff --git a/helpers/base/transaction.go b/helpers/base/transaction.go index 607f93f1d..b8d7ae8d4 100644 --- a/helpers/base/transaction.go +++ b/helpers/base/transaction.go @@ -5,39 +5,38 @@ package base import ( "context" - "encoding/json" "fmt" "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/utilities/rest" "github.com/AssetMantle/modules/utilities/rest/queuing" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/tx" - sdkCodec "github.com/cosmos/cosmos-sdk/codec" codecTypes "github.com/cosmos/cosmos-sdk/codec/types" sdkTypes "github.com/cosmos/cosmos-sdk/types" sdkModuleTypes "github.com/cosmos/cosmos-sdk/types/module" + "net/http" + "strings" - "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" "google.golang.org/grpc" - "net/http" - "reflect" ) type transaction struct { - name string - cliCommand helpers.CLICommand - keeper helpers.TransactionKeeper - requestPrototype func() helpers.TransactionRequest - messagePrototype func() helpers.Message - keeperPrototype func() helpers.TransactionKeeper - serviceRegistrar func(grpc.ServiceRegistrar, helpers.TransactionKeeper) - grpcGatewayRegistrar func(client.Context, *runtime.ServeMux) error + serviceName string + cliCommand helpers.CLICommand + keeper helpers.TransactionKeeper + requestPrototype func() helpers.TransactionRequest + messagePrototype func() helpers.Message + keeperPrototype func() helpers.TransactionKeeper + serviceRegistrar func(grpc.ServiceRegistrar, helpers.TransactionKeeper) } var _ helpers.Transaction = (*transaction)(nil) -func (transaction transaction) GetName() string { return transaction.name } +func (transaction transaction) GetServicePath() string { + splits := strings.Split(transaction.serviceName, ".") + return "/" + splits[3] + "/" + splits[5] +} func (transaction transaction) Command() *cobra.Command { runE := func(command *cobra.Command, args []string) error { Context, err := client.GetClientTxContext(command) @@ -77,19 +76,19 @@ func (transaction transaction) HandleMessage(context context.Context, message he } func (transaction transaction) RESTRequestHandler(context client.Context) http.HandlerFunc { return func(responseWriter http.ResponseWriter, httpRequest *http.Request) { - transactionRequest := transaction.requestPrototype() - if !rest.ReadRESTReq(responseWriter, httpRequest, context.LegacyAmino, &transactionRequest) { - return - } else if reflect.TypeOf(transaction.requestPrototype()) != reflect.TypeOf(transactionRequest) { - rest.CheckBadRequestError(responseWriter, fmt.Errorf("expected %s, got %s", reflect.TypeOf(transaction.requestPrototype()), reflect.TypeOf(transactionRequest))) + transactionRequest, err := transaction.requestPrototype().FromHTTPRequest(httpRequest) + if err != nil { + rest.CheckBadRequestError(responseWriter, err) return - } else if rest.CheckBadRequestError(responseWriter, transactionRequest.Validate()) { + } + + if rest.CheckBadRequestError(responseWriter, transactionRequest.Validate()) { return } - baseReq := transactionRequest.GetBaseReq().Sanitize() - if !baseReq.ValidateBasic(responseWriter) { - rest.CheckBadRequestError(responseWriter, fmt.Errorf("invalid base request")) + commonTransactionRequest := transactionRequest.GetCommonTransactionRequest().Sanitize() + if !commonTransactionRequest.ValidateBasic(responseWriter) { + rest.CheckBadRequestError(responseWriter, fmt.Errorf("invalid base request ")) } msg, err := transactionRequest.MakeMsg() @@ -98,50 +97,33 @@ func (transaction transaction) RESTRequestHandler(context client.Context) http.H return } - if rest.CheckInternalServerError(responseWriter, queuing.QueueOrBroadcastTransaction(context.WithOutput(responseWriter), baseReq, msg)) { + if rest.CheckInternalServerError(responseWriter, queuing.QueueOrBroadcastTransaction(context.WithOutput(responseWriter), commonTransactionRequest, msg)) { return } } } -func (transaction transaction) RegisterLegacyAminoCodec(legacyAmino *sdkCodec.LegacyAmino) { - transaction.messagePrototype().RegisterLegacyAminoCodec(legacyAmino) - transaction.requestPrototype().RegisterLegacyAminoCodec(legacyAmino) -} func (transaction transaction) RegisterInterfaces(interfaceRegistry codecTypes.InterfaceRegistry) { transaction.messagePrototype().RegisterInterface(interfaceRegistry) } func (transaction transaction) RegisterService(configurator sdkModuleTypes.Configurator) { if transaction.keeper == nil { - panic(fmt.Errorf("keeper for transaction %s is not initialized", transaction.name)) + panic(fmt.Errorf("keeper for transaction %s is not initialized", transaction.serviceName)) } transaction.serviceRegistrar(configurator.MsgServer(), transaction.keeper) } -func (transaction transaction) RegisterGRPCGatewayRoute(context client.Context, serveMux *runtime.ServeMux) { - if err := transaction.grpcGatewayRegistrar(context, serveMux); err != nil { - panic(err) - } -} -func (transaction transaction) DecodeTransactionRequest(rawMessage json.RawMessage) (sdkTypes.Msg, error) { - transactionRequest, err := transaction.requestPrototype().FromJSON(rawMessage) - if err != nil { - return nil, err - } - - return transactionRequest.MakeMsg() -} func (transaction transaction) InitializeKeeper(mapper helpers.Mapper, parameterManager helpers.ParameterManager, auxiliaryKeepers ...interface{}) helpers.Transaction { transaction.keeper = transaction.keeperPrototype().Initialize(mapper, parameterManager, auxiliaryKeepers).(helpers.TransactionKeeper) return transaction } -func NewTransaction(name string, short string, long string, requestPrototype func() helpers.TransactionRequest, messagePrototype func() helpers.Message, keeperPrototype func() helpers.TransactionKeeper, serviceRegistrar func(grpc.ServiceRegistrar, helpers.TransactionKeeper), grpcGatewayRegistrar func(client.Context, *runtime.ServeMux) error, flagList ...helpers.CLIFlag) helpers.Transaction { +func NewTransaction(serviceName string, short string, long string, requestPrototype func() helpers.TransactionRequest, messagePrototype func() helpers.Message, keeperPrototype func() helpers.TransactionKeeper, serviceRegistrar func(grpc.ServiceRegistrar, helpers.TransactionKeeper), flagList ...helpers.CLIFlag) helpers.Transaction { + splits := strings.Split(serviceName, ".") return transaction{ - name: name, - cliCommand: NewCLICommand(name, short, long, flagList), - requestPrototype: requestPrototype, - messagePrototype: messagePrototype, - keeperPrototype: keeperPrototype, - serviceRegistrar: serviceRegistrar, - grpcGatewayRegistrar: grpcGatewayRegistrar, + serviceName: serviceName, + cliCommand: NewCLICommand(splits[5], short, long, flagList), + requestPrototype: requestPrototype, + messagePrototype: messagePrototype, + keeperPrototype: keeperPrototype, + serviceRegistrar: serviceRegistrar, } } diff --git a/helpers/base/transactions.go b/helpers/base/transactions.go index 665cc8247..0b47ba570 100644 --- a/helpers/base/transactions.go +++ b/helpers/base/transactions.go @@ -11,9 +11,9 @@ type transactions struct { var _ helpers.Transactions = (*transactions)(nil) -func (transactions transactions) GetTransaction(name string) helpers.Transaction { +func (transactions transactions) GetTransaction(servicePath string) helpers.Transaction { for _, transaction := range transactions.transactionList { - if transaction.GetName() == name { + if transaction.GetServicePath() == servicePath { return transaction } } diff --git a/helpers/base/transactions_test.go b/helpers/base/transactions_test.go index dec36533a..6c9d55416 100644 --- a/helpers/base/transactions_test.go +++ b/helpers/base/transactions_test.go @@ -17,7 +17,7 @@ func TestNewTransactions(t *testing.T) { // GetName require.Equal(t, nil, Transactions1.GetTransaction("")) - require.Equal(t, "", Transactions2.GetTransaction("").GetName()) + require.Equal(t, "", Transactions2.GetTransaction("").GetServicePath()) // GetAuxiliary require.Equal(t, []helpers.Transaction(nil), Transactions1.Get()) diff --git a/helpers/base/validatable_parameter.go b/helpers/base/validatable_parameter.go index 4f99ee11c..f287d83b6 100644 --- a/helpers/base/validatable_parameter.go +++ b/helpers/base/validatable_parameter.go @@ -1,10 +1,9 @@ package base import ( + "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/schema/data" "github.com/AssetMantle/schema/parameters" - - "github.com/AssetMantle/modules/helpers" ) type validatableParameter struct { diff --git a/helpers/base/wasm_message.go b/helpers/base/wasm_message.go index 68031b345..cc1fd40d9 100644 --- a/helpers/base/wasm_message.go +++ b/helpers/base/wasm_message.go @@ -5,7 +5,6 @@ package base import ( "encoding/json" - "github.com/AssetMantle/modules/helpers" ) diff --git a/helpers/block.go b/helpers/block.go index 3bc82c256..998050635 100644 --- a/helpers/block.go +++ b/helpers/block.go @@ -5,7 +5,6 @@ package helpers import ( "context" - abciTypes "github.com/cometbft/cometbft/abci/types" ) diff --git a/helpers/cli_command.go b/helpers/cli_command.go index 9d1d01d6d..1b2c0dcd9 100644 --- a/helpers/cli_command.go +++ b/helpers/cli_command.go @@ -4,9 +4,7 @@ package helpers import ( - "github.com/AssetMantle/modules/utilities/rest" "github.com/cosmos/cosmos-sdk/client" - "github.com/spf13/cobra" ) @@ -15,7 +13,7 @@ type CLICommand interface { ReadInt(CLIFlag) int ReadBool(CLIFlag) bool ReadString(CLIFlag) string - ReadBaseReq(client.Context) rest.BaseReq + ReadCommonTransactionRequest(client.Context) CommonTransactionRequest CreateCommand(func(command *cobra.Command, args []string) error) *cobra.Command } diff --git a/helpers/common_transaction_request.go b/helpers/common_transaction_request.go new file mode 100644 index 000000000..4b3d38886 --- /dev/null +++ b/helpers/common_transaction_request.go @@ -0,0 +1,145 @@ +package helpers + +import ( + "fmt" + "github.com/AssetMantle/modules/utilities/rest" + "github.com/cosmos/cosmos-sdk/client" + sdkTypes "github.com/cosmos/cosmos-sdk/types" + "net/http" + "strings" +) + +type CommonTransactionRequest struct { + From string `json:"from"` + Memo string `json:"memo"` + TimeoutHeight uint64 `json:"timeoutHeight"` + AccountNumber uint64 `json:"accountNumber"` + Sequence uint64 `json:"sequence"` + ChainID string `json:"chainID"` + Gas string `json:"gas"` + Fees string `json:"fees"` + GasPrices string `json:"gasPrices"` + Simulate bool `json:"simulate"` + GasAdjustment string `json:"gasAdjustment"` +} + +func (commonTransactionRequest CommonTransactionRequest) SetFrom(from string) CommonTransactionRequest { + commonTransactionRequest.From = from + return commonTransactionRequest +} +func (commonTransactionRequest CommonTransactionRequest) SetAccountNumber(accountNumber uint64) CommonTransactionRequest { + commonTransactionRequest.AccountNumber = accountNumber + return commonTransactionRequest +} +func (commonTransactionRequest CommonTransactionRequest) GetAccountNumber() uint64 { + return commonTransactionRequest.AccountNumber +} +func (commonTransactionRequest CommonTransactionRequest) GetGas() string { + return commonTransactionRequest.Gas +} +func (commonTransactionRequest CommonTransactionRequest) GetGasAdjustment() string { + return commonTransactionRequest.GasAdjustment +} +func (commonTransactionRequest CommonTransactionRequest) GetMemo() string { + return commonTransactionRequest.Memo +} +func (commonTransactionRequest CommonTransactionRequest) GetSequence() uint64 { + return commonTransactionRequest.Sequence +} +func (commonTransactionRequest CommonTransactionRequest) GetTimeoutHeight() uint64 { + return commonTransactionRequest.TimeoutHeight +} +func (commonTransactionRequest CommonTransactionRequest) GetGasPrices() sdkTypes.DecCoins { + decCoins, err := sdkTypes.ParseDecCoins(commonTransactionRequest.GasPrices) + if err != nil { + panic(err) + } + + return decCoins +} +func (commonTransactionRequest CommonTransactionRequest) IsSimulated() bool { + return commonTransactionRequest.Simulate +} +func (commonTransactionRequest CommonTransactionRequest) GetFrom() string { + return commonTransactionRequest.From +} +func (commonTransactionRequest CommonTransactionRequest) GetChainID() string { + return commonTransactionRequest.ChainID +} +func (commonTransactionRequest CommonTransactionRequest) SetChainID(chainIDString string) CommonTransactionRequest { + commonTransactionRequest.ChainID = chainIDString + return commonTransactionRequest +} +func (commonTransactionRequest CommonTransactionRequest) GetFees() sdkTypes.Coins { + coins, err := sdkTypes.ParseCoinsNormalized(commonTransactionRequest.Fees) + if err != nil { + panic(err) + } + + return coins +} +func (commonTransactionRequest CommonTransactionRequest) Validate() error { + if _, err := sdkTypes.AccAddressFromBech32(commonTransactionRequest.From); err != nil || len(commonTransactionRequest.From) == 0 { + return fmt.Errorf("invalid from address: %s", commonTransactionRequest.From) + } + + if _, err := sdkTypes.ParseDecCoins(commonTransactionRequest.GasPrices); err != nil { + return fmt.Errorf("invalid gas prices %s", commonTransactionRequest.GasPrices) + } + + if _, err := sdkTypes.ParseCoinsNormalized(commonTransactionRequest.Fees); err != nil { + return fmt.Errorf("invalid fees %s", commonTransactionRequest.Fees) + } + + if !commonTransactionRequest.Simulate { + if len(commonTransactionRequest.ChainID) == 0 { + return fmt.Errorf("chain-id required but not specified") + } + if !commonTransactionRequest.GetFees().IsZero() && !commonTransactionRequest.GetGasPrices().IsZero() { + return fmt.Errorf("cannot provide both fees and gas prices") + } + if !commonTransactionRequest.GetFees().IsValid() && !commonTransactionRequest.GetGasPrices().IsValid() { + return fmt.Errorf("invalid fees or gas prices provided") + } + } + + return nil +} +func (commonTransactionRequest CommonTransactionRequest) Sanitize() CommonTransactionRequest { + return NewCommonTransactionRequest(commonTransactionRequest.From, commonTransactionRequest.Memo, commonTransactionRequest.ChainID, commonTransactionRequest.Gas, commonTransactionRequest.GasAdjustment, commonTransactionRequest.AccountNumber, commonTransactionRequest.TimeoutHeight, commonTransactionRequest.Sequence, commonTransactionRequest.Fees, commonTransactionRequest.GasPrices, commonTransactionRequest.Simulate) +} +func (commonTransactionRequest CommonTransactionRequest) ValidateBasic(responseWriter http.ResponseWriter) bool { + if err := commonTransactionRequest.Validate(); err != nil { + rest.WriteErrorResponse(responseWriter, http.StatusBadRequest, err.Error()) + return false + } + + return true +} + +func NewCommonTransactionRequest(from, memo, chainID, gas, gasAdjustment string, accountNumber, sequence, timeOutHeight uint64, fees, gasPrices string, simulate bool) CommonTransactionRequest { + return CommonTransactionRequest{ + From: strings.TrimSpace(from), + Memo: strings.TrimSpace(memo), + ChainID: strings.TrimSpace(chainID), + Fees: strings.TrimSpace(fees), + GasPrices: strings.TrimSpace(gasPrices), + Gas: strings.TrimSpace(gas), + GasAdjustment: strings.TrimSpace(gasAdjustment), + AccountNumber: accountNumber, + Sequence: sequence, + TimeoutHeight: timeOutHeight, + Simulate: simulate, + } +} +func PrototypeCommonTransactionRequest() CommonTransactionRequest { + return CommonTransactionRequest{} +} + +func NewCommonTransactionRequestFromContext(context client.Context) CommonTransactionRequest { + return CommonTransactionRequest{ + From: context.FromAddress.String(), + ChainID: context.ChainID, + Simulate: context.Simulate, + } +} diff --git a/helpers/genesis.go b/helpers/genesis.go index ab43d7d1d..2e185c883 100644 --- a/helpers/genesis.go +++ b/helpers/genesis.go @@ -2,7 +2,6 @@ package helpers import ( "context" - "github.com/AssetMantle/schema/lists" sdkCodec "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/gogoproto/proto" diff --git a/helpers/grpc_request.go b/helpers/grpc_request.go new file mode 100644 index 000000000..31a204255 --- /dev/null +++ b/helpers/grpc_request.go @@ -0,0 +1,11 @@ +// Copyright [2021] - [2022], AssetMantle Pte. Ltd. and the code contributors +// SPDX-License-Identifier: Apache-2.0 + +package helpers + +import "github.com/cosmos/gogoproto/proto" + +type GRPCRequest interface { + proto.Message + Request +} diff --git a/helpers/legacy_codec.go b/helpers/legacy_codec.go deleted file mode 100644 index 9f9a52933..000000000 --- a/helpers/legacy_codec.go +++ /dev/null @@ -1,15 +0,0 @@ -package helpers - -import ( - "github.com/cosmos/cosmos-sdk/codec" -) - -func RegisterLegacyAminoCodec(legacyAmino *codec.LegacyAmino) { - legacyAmino.RegisterInterface((*Mappable)(nil), nil) - legacyAmino.RegisterInterface((*QueryResponse)(nil), nil) - legacyAmino.RegisterInterface((*QueryRequest)(nil), nil) - legacyAmino.RegisterInterface((*TransactionRequest)(nil), nil) - legacyAmino.RegisterInterface((*Request)(nil), nil) - legacyAmino.RegisterInterface((*Error)(nil), nil) - legacyAmino.RegisterInterface((*error)(nil), nil) -} diff --git a/helpers/legacy_codec_test.go b/helpers/legacy_codec_test.go deleted file mode 100644 index 3d764ee82..000000000 --- a/helpers/legacy_codec_test.go +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright [2021] - [2022], AssetMantle Pte. Ltd. and the code contributors -// SPDX-License-Identifier: Apache-2.0 - -package helpers - -import ( - "testing" - - "github.com/cosmos/cosmos-sdk/codec" -) - -func TestRegisterCodec(t *testing.T) { - type args struct { - legacyAmino *codec.LegacyAmino - } - tests := []struct { - name string - args args - }{ - - {"+ve", args{codec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} diff --git a/helpers/mappable.go b/helpers/mappable.go index 4deec920f..f4125c0a7 100644 --- a/helpers/mappable.go +++ b/helpers/mappable.go @@ -9,6 +9,5 @@ import ( type Mappable interface { codec.ProtoMarshaler - RegisterLegacyAminoCodec(*codec.LegacyAmino) ValidateBasic() error } diff --git a/helpers/mapper.go b/helpers/mapper.go index b43812fef..44ea34498 100644 --- a/helpers/mapper.go +++ b/helpers/mapper.go @@ -5,7 +5,6 @@ package helpers import ( "context" - storeTypes "github.com/cosmos/cosmos-sdk/store/types" "github.com/cosmos/cosmos-sdk/types/kv" ) diff --git a/helpers/message.go b/helpers/message.go index 97d9ebc39..ed8a7a328 100644 --- a/helpers/message.go +++ b/helpers/message.go @@ -4,16 +4,11 @@ package helpers import ( - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/types" sdkTypes "github.com/cosmos/cosmos-sdk/types" ) type Message interface { - // TODO check if register message code is required - RegisterLegacyAminoCodec(*codec.LegacyAmino) RegisterInterface(types.InterfaceRegistry) - Type() string - GetFromAddress() sdkTypes.AccAddress sdkTypes.Msg } diff --git a/helpers/module.go b/helpers/module.go index 2e5fbd6b2..fd11c7598 100644 --- a/helpers/module.go +++ b/helpers/module.go @@ -4,12 +4,11 @@ package helpers import ( - "encoding/json" - sdkTypes "github.com/cosmos/cosmos-sdk/types" - + "github.com/cosmos/cosmos-sdk/client" storeTypes "github.com/cosmos/cosmos-sdk/store/types" sdkModuleTypes "github.com/cosmos/cosmos-sdk/types/module" paramsTypes "github.com/cosmos/cosmos-sdk/x/params/types" + "github.com/gorilla/mux" ) type Module interface { @@ -23,14 +22,13 @@ type Module interface { sdkModuleTypes.HasServices sdkModuleTypes.AppModuleSimulation - sdkModuleTypes.HasProposalContents sdkModuleTypes.HasProposalMsgs GetAuxiliary(string) Auxiliary - DecodeModuleTransactionRequest(string, json.RawMessage) (sdkTypes.Msg, error) - Initialize(*storeTypes.KVStoreKey, paramsTypes.Subspace, ...interface{}) Module GetTransactions() Transactions + + RegisterRESTRoutes(client.Context, *mux.Router) } diff --git a/helpers/module_manager.go b/helpers/module_manager.go index b1a74e51b..4dff1f940 100644 --- a/helpers/module_manager.go +++ b/helpers/module_manager.go @@ -8,6 +8,7 @@ import ( sdkCodecTypes "github.com/cosmos/cosmos-sdk/codec/types" sdkTypes "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" + "github.com/gorilla/mux" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" ) @@ -24,13 +25,16 @@ type ModuleManager interface { RegisterServices(module.Configurator) RegisterGRPCGatewayRoutes(client.Context, *runtime.ServeMux) + RegisterRESTRoutes(client.Context, *mux.Router) + RegisterInvariants(sdkTypes.InvariantRegistry) RegisterInterfaces(sdkCodecTypes.InterfaceRegistry) RegisterLegacyAminoCodec(*codec.LegacyAmino) - SetOrderBeginBlockers(...string) - SetOrderEndBlockers(...string) - SetOrderInitGenesis(...string) + SetOrderBeginBlockers(...string) ModuleManager + SetOrderEndBlockers(...string) ModuleManager + SetOrderInitGenesis(...string) ModuleManager + SetOrderExportGenesis(...string) ModuleManager BeginBlock(sdkTypes.Context, abciTypes.RequestBeginBlock) abciTypes.ResponseBeginBlock EndBlock(sdkTypes.Context, abciTypes.RequestEndBlock) abciTypes.ResponseEndBlock diff --git a/helpers/parameter_manager.go b/helpers/parameter_manager.go index 21f1c21d2..4aaddfb14 100644 --- a/helpers/parameter_manager.go +++ b/helpers/parameter_manager.go @@ -5,12 +5,9 @@ package helpers import ( "context" - "net/http" - "github.com/AssetMantle/schema/ids" "github.com/AssetMantle/schema/lists" "github.com/AssetMantle/schema/parameters" - "github.com/cosmos/cosmos-sdk/client" paramsTypes "github.com/cosmos/cosmos-sdk/x/params/types" ) @@ -24,6 +21,5 @@ type ParameterManager interface { Set(context.Context, lists.ParameterList) ParameterManager GetKeyTable() paramsTypes.KeyTable - RESTQueryHandler(client.Context) http.HandlerFunc Initialize(paramsTypes.Subspace) ParameterManager } diff --git a/helpers/query.go b/helpers/query.go index 9f2bb2da8..d40f29eb5 100644 --- a/helpers/query.go +++ b/helpers/query.go @@ -10,16 +10,14 @@ import ( abciTypes "github.com/cometbft/cometbft/abci/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/types/module" - "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" ) type Query interface { - GetName() string + GetServicePath() string Command() *cobra.Command HandleQuery(context.Context, abciTypes.RequestQuery) ([]byte, error) RESTQueryHandler(client.Context) http.HandlerFunc RegisterService(module.Configurator) - RegisterGRPCGatewayRoute(client.Context, *runtime.ServeMux) Initialize(Mapper, ParameterManager, ...interface{}) Query } diff --git a/helpers/query_request.go b/helpers/query_request.go index 73077f88a..dcc020c50 100644 --- a/helpers/query_request.go +++ b/helpers/query_request.go @@ -10,9 +10,7 @@ import ( ) type QueryRequest interface { - Request + GRPCRequest FromCLI(CLICommand, client.Context) (QueryRequest, error) FromHTTPRequest(*http.Request) (QueryRequest, error) - Encode() ([]byte, error) - Decode([]byte) (QueryRequest, error) } diff --git a/helpers/request.go b/helpers/request.go index 9a5b88ed3..c2b9e0377 100644 --- a/helpers/request.go +++ b/helpers/request.go @@ -1,6 +1,3 @@ -// Copyright [2021] - [2022], AssetMantle Pte. Ltd. and the code contributors -// SPDX-License-Identifier: Apache-2.0 - package helpers type Request interface { diff --git a/helpers/simulator.go b/helpers/simulator.go index 449cbf92c..155adb39f 100644 --- a/helpers/simulator.go +++ b/helpers/simulator.go @@ -4,16 +4,15 @@ package helpers import ( - "math/rand" - "github.com/cosmos/cosmos-sdk/types/module" simulationTypes "github.com/cosmos/cosmos-sdk/types/simulation" "github.com/cosmos/cosmos-sdk/x/simulation" + "math/rand" ) type Simulator interface { RandomizedGenesisState(*module.SimulationState) WeightedOperations(module.SimulationState, Module) simulation.WeightedOperations - WeightedProposalContentList(module.SimulationState) []simulationTypes.WeightedProposalContent ParamChangeList(*rand.Rand) []simulationTypes.LegacyParamChange + ProposalMessages(module.SimulationState) []simulationTypes.WeightedProposalMsg } diff --git a/helpers/transaction.go b/helpers/transaction.go index 81495b01c..5f2473025 100644 --- a/helpers/transaction.go +++ b/helpers/transaction.go @@ -5,27 +5,21 @@ package helpers import ( "context" - "encoding/json" "net/http" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/types" sdkTypes "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" - "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" ) type Transaction interface { - GetName() string + GetServicePath() string Command() *cobra.Command HandleMessage(context.Context, Message) (*sdkTypes.Result, error) RESTRequestHandler(client.Context) http.HandlerFunc - RegisterLegacyAminoCodec(amino *codec.LegacyAmino) RegisterInterfaces(types.InterfaceRegistry) RegisterService(module.Configurator) - RegisterGRPCGatewayRoute(client.Context, *runtime.ServeMux) - DecodeTransactionRequest(json.RawMessage) (sdkTypes.Msg, error) InitializeKeeper(Mapper, ParameterManager, ...interface{}) Transaction } diff --git a/helpers/transaction_request.go b/helpers/transaction_request.go index b89d993bb..563494b94 100644 --- a/helpers/transaction_request.go +++ b/helpers/transaction_request.go @@ -4,20 +4,16 @@ package helpers import ( - "encoding/json" - "github.com/AssetMantle/modules/utilities/rest" - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" + "net/http" ) type TransactionRequest interface { - GetBaseReq() rest.BaseReq + GetCommonTransactionRequest() CommonTransactionRequest FromCLI(CLICommand, client.Context) (TransactionRequest, error) - FromJSON(json.RawMessage) (TransactionRequest, error) + FromHTTPRequest(*http.Request) (TransactionRequest, error) MakeMsg() (sdkTypes.Msg, error) - RegisterLegacyAminoCodec(*codec.LegacyAmino) Request } diff --git a/proto/AssetMantle/modules/x/assets/queries/asset/service.proto b/proto/AssetMantle/modules/x/assets/queries/asset/service.proto index 239878561..1c6134223 100644 --- a/proto/AssetMantle/modules/x/assets/queries/asset/service.proto +++ b/proto/AssetMantle/modules/x/assets/queries/asset/service.proto @@ -3,10 +3,7 @@ package AssetMantle.modules.x.assets.queries.asset; import "AssetMantle/modules/x/assets/queries/asset/query_request.proto"; import "AssetMantle/modules/x/assets/queries/asset/query_response.proto"; -import "google/api/annotations.proto"; service Query { - rpc Handle(QueryRequest) returns (QueryResponse) { - option (google.api.http).get = "/mantle/assets/v1beta1/asset"; - } + rpc Handle(QueryRequest) returns (QueryResponse) {} } \ No newline at end of file diff --git a/proto/AssetMantle/modules/x/assets/queries/assets/service.proto b/proto/AssetMantle/modules/x/assets/queries/assets/service.proto index d938521c5..ca10b3a1b 100644 --- a/proto/AssetMantle/modules/x/assets/queries/assets/service.proto +++ b/proto/AssetMantle/modules/x/assets/queries/assets/service.proto @@ -3,10 +3,7 @@ package AssetMantle.modules.x.assets.queries.assets; import "AssetMantle/modules/x/assets/queries/assets/query_request.proto"; import "AssetMantle/modules/x/assets/queries/assets/query_response.proto"; -import "google/api/annotations.proto"; service Query { - rpc Handle(QueryRequest) returns (QueryResponse) { - option (google.api.http).get = "/mantle/assets/v1beta1/assets"; - } + rpc Handle(QueryRequest) returns (QueryResponse) {} } \ No newline at end of file diff --git a/proto/AssetMantle/modules/x/assets/queries/parameters/query_request.proto b/proto/AssetMantle/modules/x/assets/queries/parameters/query_request.proto new file mode 100644 index 000000000..e64e2a08d --- /dev/null +++ b/proto/AssetMantle/modules/x/assets/queries/parameters/query_request.proto @@ -0,0 +1,4 @@ +syntax = "proto3"; +package AssetMantle.modules.x.assets.queries.parameters; + +message QueryRequest {} \ No newline at end of file diff --git a/proto/AssetMantle/modules/x/assets/queries/parameters/query_response.proto b/proto/AssetMantle/modules/x/assets/queries/parameters/query_response.proto new file mode 100644 index 000000000..5f727d145 --- /dev/null +++ b/proto/AssetMantle/modules/x/assets/queries/parameters/query_response.proto @@ -0,0 +1,8 @@ +syntax = "proto3"; +package AssetMantle.modules.x.assets.queries.parameters; + +import "AssetMantle/schema/lists/base/parameter_list.proto"; + +message QueryResponse { + AssetMantle.schema.lists.base.ParameterList parameter_list = 1; +} diff --git a/proto/AssetMantle/modules/x/assets/queries/parameters/service.proto b/proto/AssetMantle/modules/x/assets/queries/parameters/service.proto new file mode 100644 index 000000000..271962488 --- /dev/null +++ b/proto/AssetMantle/modules/x/assets/queries/parameters/service.proto @@ -0,0 +1,9 @@ +syntax = "proto3"; +package AssetMantle.modules.x.assets.queries.parameters; + +import "AssetMantle/modules/x/assets/queries/parameters/query_request.proto"; +import "AssetMantle/modules/x/assets/queries/parameters/query_response.proto"; + +service Query { + rpc Handle(QueryRequest) returns (QueryResponse) {} +} \ No newline at end of file diff --git a/proto/AssetMantle/modules/x/assets/transactions/burn/service.proto b/proto/AssetMantle/modules/x/assets/transactions/burn/service.proto index bea0fab47..3c577f254 100644 --- a/proto/AssetMantle/modules/x/assets/transactions/burn/service.proto +++ b/proto/AssetMantle/modules/x/assets/transactions/burn/service.proto @@ -1,12 +1,11 @@ syntax = "proto3"; package AssetMantle.modules.x.assets.transactions.burn; -import "google/api/annotations.proto"; +import "cosmos/msg/v1/msg.proto"; import "AssetMantle/modules/x/assets/transactions/burn/message.proto"; import "AssetMantle/modules/x/assets/transactions/burn/transaction_response.proto"; service Msg { - rpc Handle(Message) returns (TransactionResponse) { - option (google.api.http).post = "/mantle/assets/burn"; - } + option (cosmos.msg.v1.service) = true; + rpc Handle(Message) returns (TransactionResponse) {} } \ No newline at end of file diff --git a/proto/AssetMantle/modules/x/assets/transactions/define/service.proto b/proto/AssetMantle/modules/x/assets/transactions/define/service.proto index 6b7247c72..c4451e45a 100644 --- a/proto/AssetMantle/modules/x/assets/transactions/define/service.proto +++ b/proto/AssetMantle/modules/x/assets/transactions/define/service.proto @@ -1,12 +1,11 @@ syntax = "proto3"; package AssetMantle.modules.x.assets.transactions.define; -import "google/api/annotations.proto"; +import "cosmos/msg/v1/msg.proto"; import "AssetMantle/modules/x/assets/transactions/define/message.proto"; import "AssetMantle/modules/x/assets/transactions/define/transaction_response.proto"; service Msg { - rpc Handle(Message) returns (TransactionResponse) { - option (google.api.http).post = "/mantle/assets/define"; - } + option (cosmos.msg.v1.service) = true; + rpc Handle(Message) returns (TransactionResponse) {} } \ No newline at end of file diff --git a/proto/AssetMantle/modules/x/assets/transactions/deputize/service.proto b/proto/AssetMantle/modules/x/assets/transactions/deputize/service.proto index bc965c715..826158b5e 100644 --- a/proto/AssetMantle/modules/x/assets/transactions/deputize/service.proto +++ b/proto/AssetMantle/modules/x/assets/transactions/deputize/service.proto @@ -1,12 +1,11 @@ syntax = "proto3"; package AssetMantle.modules.x.assets.transactions.deputize; -import "google/api/annotations.proto"; +import "cosmos/msg/v1/msg.proto"; import "AssetMantle/modules/x/assets/transactions/deputize/message.proto"; import "AssetMantle/modules/x/assets/transactions/deputize/transaction_response.proto"; service Msg { - rpc Handle(Message) returns (TransactionResponse) { - option (google.api.http).post = "/mantle/assets/deputize"; - } + option (cosmos.msg.v1.service) = true; + rpc Handle(Message) returns (TransactionResponse) {} } \ No newline at end of file diff --git a/proto/AssetMantle/modules/x/assets/transactions/mint/service.proto b/proto/AssetMantle/modules/x/assets/transactions/mint/service.proto index 8f940e1b9..21ed2e29d 100644 --- a/proto/AssetMantle/modules/x/assets/transactions/mint/service.proto +++ b/proto/AssetMantle/modules/x/assets/transactions/mint/service.proto @@ -1,12 +1,11 @@ syntax = "proto3"; package AssetMantle.modules.x.assets.transactions.mint; -import "google/api/annotations.proto"; +import "cosmos/msg/v1/msg.proto"; import "AssetMantle/modules/x/assets/transactions/mint/message.proto"; import "AssetMantle/modules/x/assets/transactions/mint/transaction_response.proto"; service Msg { - rpc Handle(Message) returns (TransactionResponse) { - option (google.api.http).post = "/mantle/assets/mint"; - } + option (cosmos.msg.v1.service) = true; + rpc Handle(Message) returns (TransactionResponse) {} } \ No newline at end of file diff --git a/proto/AssetMantle/modules/x/assets/transactions/mutate/service.proto b/proto/AssetMantle/modules/x/assets/transactions/mutate/service.proto index 5f944dfa7..4fad3ecf1 100644 --- a/proto/AssetMantle/modules/x/assets/transactions/mutate/service.proto +++ b/proto/AssetMantle/modules/x/assets/transactions/mutate/service.proto @@ -1,12 +1,11 @@ syntax = "proto3"; package AssetMantle.modules.x.assets.transactions.mutate; -import "google/api/annotations.proto"; +import "cosmos/msg/v1/msg.proto"; import "AssetMantle/modules/x/assets/transactions/mutate/message.proto"; import "AssetMantle/modules/x/assets/transactions/mutate/transaction_response.proto"; service Msg { - rpc Handle(Message) returns (TransactionResponse) { - option (google.api.http).post = "/mantle/assets/mutate"; - } + option (cosmos.msg.v1.service) = true; + rpc Handle(Message) returns (TransactionResponse) {} } \ No newline at end of file diff --git a/proto/AssetMantle/modules/x/assets/transactions/renumerate/service.proto b/proto/AssetMantle/modules/x/assets/transactions/renumerate/service.proto index 11e4e3104..f6e20a4c4 100644 --- a/proto/AssetMantle/modules/x/assets/transactions/renumerate/service.proto +++ b/proto/AssetMantle/modules/x/assets/transactions/renumerate/service.proto @@ -1,12 +1,11 @@ syntax = "proto3"; package AssetMantle.modules.x.assets.transactions.renumerate; -import "google/api/annotations.proto"; +import "cosmos/msg/v1/msg.proto"; import "AssetMantle/modules/x/assets/transactions/renumerate/message.proto"; import "AssetMantle/modules/x/assets/transactions/renumerate/transaction_response.proto"; service Msg { - rpc Handle(Message) returns (TransactionResponse) { - option (google.api.http).post = "/mantle/assets/renumerate"; - } + option (cosmos.msg.v1.service) = true; + rpc Handle(Message) returns (TransactionResponse) {} } \ No newline at end of file diff --git a/proto/AssetMantle/modules/x/assets/transactions/revoke/service.proto b/proto/AssetMantle/modules/x/assets/transactions/revoke/service.proto index 3f96f967d..dec63d2ab 100644 --- a/proto/AssetMantle/modules/x/assets/transactions/revoke/service.proto +++ b/proto/AssetMantle/modules/x/assets/transactions/revoke/service.proto @@ -1,12 +1,11 @@ syntax = "proto3"; package AssetMantle.modules.x.assets.transactions.revoke; -import "google/api/annotations.proto"; +import "cosmos/msg/v1/msg.proto"; import "AssetMantle/modules/x/assets/transactions/revoke/message.proto"; import "AssetMantle/modules/x/assets/transactions/revoke/transaction_response.proto"; service Msg { - rpc Handle(Message) returns (TransactionResponse) { - option (google.api.http).post = "/mantle/assets/revoke"; - } + option (cosmos.msg.v1.service) = true; + rpc Handle(Message) returns (TransactionResponse) {} } \ No newline at end of file diff --git a/proto/AssetMantle/modules/x/assets/transactions/send/service.proto b/proto/AssetMantle/modules/x/assets/transactions/send/service.proto index 042df99f1..629dcfe73 100644 --- a/proto/AssetMantle/modules/x/assets/transactions/send/service.proto +++ b/proto/AssetMantle/modules/x/assets/transactions/send/service.proto @@ -1,12 +1,11 @@ syntax = "proto3"; package AssetMantle.modules.x.assets.transactions.send; -import "google/api/annotations.proto"; +import "cosmos/msg/v1/msg.proto"; import "AssetMantle/modules/x/assets/transactions/send/message.proto"; import "AssetMantle/modules/x/assets/transactions/send/transaction_response.proto"; service Msg { - rpc Handle(Message) returns (TransactionResponse) { - option (google.api.http).post = "/mantle/assets/send"; - } + option (cosmos.msg.v1.service) = true; + rpc Handle(Message) returns (TransactionResponse) {} } \ No newline at end of file diff --git a/proto/AssetMantle/modules/x/assets/transactions/unwrap/service.proto b/proto/AssetMantle/modules/x/assets/transactions/unwrap/service.proto index 5af84a5da..e275b7cbd 100644 --- a/proto/AssetMantle/modules/x/assets/transactions/unwrap/service.proto +++ b/proto/AssetMantle/modules/x/assets/transactions/unwrap/service.proto @@ -1,12 +1,11 @@ syntax = "proto3"; package AssetMantle.modules.x.assets.transactions.unwrap; -import "google/api/annotations.proto"; +import "cosmos/msg/v1/msg.proto"; import "AssetMantle/modules/x/assets/transactions/unwrap/message.proto"; import "AssetMantle/modules/x/assets/transactions/unwrap/transaction_response.proto"; service Msg { - rpc Handle(Message) returns (TransactionResponse) { - option (google.api.http).post = "/mantle/assets/unwrap"; - } + option (cosmos.msg.v1.service) = true; + rpc Handle(Message) returns (TransactionResponse) {} } \ No newline at end of file diff --git a/proto/AssetMantle/modules/x/assets/transactions/wrap/service.proto b/proto/AssetMantle/modules/x/assets/transactions/wrap/service.proto index c07823424..4f77245dd 100644 --- a/proto/AssetMantle/modules/x/assets/transactions/wrap/service.proto +++ b/proto/AssetMantle/modules/x/assets/transactions/wrap/service.proto @@ -1,12 +1,11 @@ syntax = "proto3"; package AssetMantle.modules.x.assets.transactions.wrap; -import "google/api/annotations.proto"; +import "cosmos/msg/v1/msg.proto"; import "AssetMantle/modules/x/assets/transactions/wrap/message.proto"; import "AssetMantle/modules/x/assets/transactions/wrap/transaction_response.proto"; service Msg { - rpc Handle(Message) returns (TransactionResponse) { - option (google.api.http).post = "/mantle/assets/wrap"; - } + option (cosmos.msg.v1.service) = true; + rpc Handle(Message) returns (TransactionResponse) {} } \ No newline at end of file diff --git a/proto/AssetMantle/modules/x/classifications/queries/classification/service.proto b/proto/AssetMantle/modules/x/classifications/queries/classification/service.proto index 8a238c240..4d467bc7c 100644 --- a/proto/AssetMantle/modules/x/classifications/queries/classification/service.proto +++ b/proto/AssetMantle/modules/x/classifications/queries/classification/service.proto @@ -1,12 +1,9 @@ syntax = "proto3"; package AssetMantle.modules.x.classifications.queries.classification; -import "google/api/annotations.proto"; import "AssetMantle/modules/x/classifications/queries/classification/query_request.proto"; import "AssetMantle/modules/x/classifications/queries/classification/query_response.proto"; service Query { - rpc Handle(QueryRequest) returns(QueryResponse){ - option (google.api.http).get = "/mantle/classifications/v1beta1/classification"; - } + rpc Handle(QueryRequest) returns(QueryResponse){} } \ No newline at end of file diff --git a/proto/AssetMantle/modules/x/classifications/queries/classifications/service.proto b/proto/AssetMantle/modules/x/classifications/queries/classifications/service.proto index 0329b8690..7e34a2296 100644 --- a/proto/AssetMantle/modules/x/classifications/queries/classifications/service.proto +++ b/proto/AssetMantle/modules/x/classifications/queries/classifications/service.proto @@ -1,12 +1,9 @@ syntax = "proto3"; package AssetMantle.modules.x.classifications.queries.classifications; -import "google/api/annotations.proto"; import "AssetMantle/modules/x/classifications/queries/classifications/query_request.proto"; import "AssetMantle/modules/x/classifications/queries/classifications/query_response.proto"; service Query { - rpc Handle(QueryRequest) returns(QueryResponse){ - option (google.api.http).get = "/mantle/classifications/v1beta1/classifications"; - } + rpc Handle(QueryRequest) returns(QueryResponse){} } \ No newline at end of file diff --git a/proto/AssetMantle/modules/x/classifications/queries/parameters/query_request.proto b/proto/AssetMantle/modules/x/classifications/queries/parameters/query_request.proto new file mode 100644 index 000000000..6f9b52364 --- /dev/null +++ b/proto/AssetMantle/modules/x/classifications/queries/parameters/query_request.proto @@ -0,0 +1,4 @@ +syntax = "proto3"; +package AssetMantle.modules.x.classifications.queries.parameters; + +message QueryRequest {} \ No newline at end of file diff --git a/proto/AssetMantle/modules/x/classifications/queries/parameters/query_response.proto b/proto/AssetMantle/modules/x/classifications/queries/parameters/query_response.proto new file mode 100644 index 000000000..17a2a5b36 --- /dev/null +++ b/proto/AssetMantle/modules/x/classifications/queries/parameters/query_response.proto @@ -0,0 +1,8 @@ +syntax = "proto3"; +package AssetMantle.modules.x.classifications.queries.parameters; + +import "AssetMantle/schema/lists/base/parameter_list.proto"; + +message QueryResponse { + AssetMantle.schema.lists.base.ParameterList parameter_list = 1; +} diff --git a/proto/AssetMantle/modules/x/classifications/queries/parameters/service.proto b/proto/AssetMantle/modules/x/classifications/queries/parameters/service.proto new file mode 100644 index 000000000..a2adc3e84 --- /dev/null +++ b/proto/AssetMantle/modules/x/classifications/queries/parameters/service.proto @@ -0,0 +1,9 @@ +syntax = "proto3"; +package AssetMantle.modules.x.classifications.queries.parameters; + +import "AssetMantle/modules/x/classifications/queries/parameters/query_request.proto"; +import "AssetMantle/modules/x/classifications/queries/parameters/query_response.proto"; + +service Query { + rpc Handle(QueryRequest) returns (QueryResponse) {} +} \ No newline at end of file diff --git a/proto/AssetMantle/modules/x/identities/queries/identities/service.proto b/proto/AssetMantle/modules/x/identities/queries/identities/service.proto index 72db49f08..ceada9af9 100644 --- a/proto/AssetMantle/modules/x/identities/queries/identities/service.proto +++ b/proto/AssetMantle/modules/x/identities/queries/identities/service.proto @@ -1,12 +1,9 @@ syntax = "proto3"; package AssetMantle.modules.x.identities.queries.identities; -import "google/api/annotations.proto"; import "AssetMantle/modules/x/identities/queries/identities/query_request.proto"; import "AssetMantle/modules/x/identities/queries/identities/query_response.proto"; service Query { - rpc Handle(QueryRequest) returns(QueryResponse){ - option (google.api.http).get = "/mantle/identities/v1beta1/identities"; - } + rpc Handle(QueryRequest) returns(QueryResponse){} } \ No newline at end of file diff --git a/proto/AssetMantle/modules/x/identities/queries/identity/service.proto b/proto/AssetMantle/modules/x/identities/queries/identity/service.proto index 749f61cc7..09ba89f05 100644 --- a/proto/AssetMantle/modules/x/identities/queries/identity/service.proto +++ b/proto/AssetMantle/modules/x/identities/queries/identity/service.proto @@ -1,12 +1,9 @@ syntax = "proto3"; package AssetMantle.modules.x.identities.queries.identity; -import "google/api/annotations.proto"; import "AssetMantle/modules/x/identities/queries/identity/query_request.proto"; import "AssetMantle/modules/x/identities/queries/identity/query_response.proto"; service Query { - rpc Handle(QueryRequest) returns(QueryResponse){ - option (google.api.http).get = "/mantle/identities/v1beta1/identity"; - } + rpc Handle(QueryRequest) returns(QueryResponse){} } \ No newline at end of file diff --git a/proto/AssetMantle/modules/x/identities/queries/parameters/query_request.proto b/proto/AssetMantle/modules/x/identities/queries/parameters/query_request.proto new file mode 100644 index 000000000..d6afe27f3 --- /dev/null +++ b/proto/AssetMantle/modules/x/identities/queries/parameters/query_request.proto @@ -0,0 +1,4 @@ +syntax = "proto3"; +package AssetMantle.modules.x.identities.queries.parameters; + +message QueryRequest {} \ No newline at end of file diff --git a/proto/AssetMantle/modules/x/identities/queries/parameters/query_response.proto b/proto/AssetMantle/modules/x/identities/queries/parameters/query_response.proto new file mode 100644 index 000000000..9e2a6158e --- /dev/null +++ b/proto/AssetMantle/modules/x/identities/queries/parameters/query_response.proto @@ -0,0 +1,8 @@ +syntax = "proto3"; +package AssetMantle.modules.x.identities.queries.parameters; + +import "AssetMantle/schema/lists/base/parameter_list.proto"; + +message QueryResponse { + AssetMantle.schema.lists.base.ParameterList parameter_list = 1; +} diff --git a/proto/AssetMantle/modules/x/identities/queries/parameters/service.proto b/proto/AssetMantle/modules/x/identities/queries/parameters/service.proto new file mode 100644 index 000000000..635e01fcc --- /dev/null +++ b/proto/AssetMantle/modules/x/identities/queries/parameters/service.proto @@ -0,0 +1,9 @@ +syntax = "proto3"; +package AssetMantle.modules.x.identities.queries.parameters; + +import "AssetMantle/modules/x/identities/queries/parameters/query_request.proto"; +import "AssetMantle/modules/x/identities/queries/parameters/query_response.proto"; + +service Query { + rpc Handle(QueryRequest) returns (QueryResponse) {} +} \ No newline at end of file diff --git a/proto/AssetMantle/modules/x/identities/transactions/define/service.proto b/proto/AssetMantle/modules/x/identities/transactions/define/service.proto index aea6f9a4f..cffe58b4e 100644 --- a/proto/AssetMantle/modules/x/identities/transactions/define/service.proto +++ b/proto/AssetMantle/modules/x/identities/transactions/define/service.proto @@ -1,12 +1,11 @@ syntax = "proto3"; package AssetMantle.modules.x.identities.transactions.define; -import "google/api/annotations.proto"; +import "cosmos/msg/v1/msg.proto"; import "AssetMantle/modules/x/identities/transactions/define/message.proto"; import "AssetMantle/modules/x/identities/transactions/define/transaction_response.proto"; service Msg { - rpc Handle(Message) returns (TransactionResponse) { - option (google.api.http).post = "/mantle/identities/define"; - } + option (cosmos.msg.v1.service) = true; + rpc Handle(Message) returns (TransactionResponse) {} } \ No newline at end of file diff --git a/proto/AssetMantle/modules/x/identities/transactions/deputize/service.proto b/proto/AssetMantle/modules/x/identities/transactions/deputize/service.proto index e998852cb..1a7ac609d 100644 --- a/proto/AssetMantle/modules/x/identities/transactions/deputize/service.proto +++ b/proto/AssetMantle/modules/x/identities/transactions/deputize/service.proto @@ -1,12 +1,11 @@ syntax = "proto3"; package AssetMantle.modules.x.identities.transactions.deputize; -import "google/api/annotations.proto"; +import "cosmos/msg/v1/msg.proto"; import "AssetMantle/modules/x/identities/transactions/deputize/message.proto"; import "AssetMantle/modules/x/identities/transactions/deputize/transaction_response.proto"; service Msg { - rpc Handle(Message) returns (TransactionResponse) { - option (google.api.http).post = "/mantle/identities/deputize"; - } + option (cosmos.msg.v1.service) = true; + rpc Handle(Message) returns (TransactionResponse) {} } \ No newline at end of file diff --git a/proto/AssetMantle/modules/x/identities/transactions/issue/service.proto b/proto/AssetMantle/modules/x/identities/transactions/issue/service.proto index 27fbb3fab..19c03a5ba 100644 --- a/proto/AssetMantle/modules/x/identities/transactions/issue/service.proto +++ b/proto/AssetMantle/modules/x/identities/transactions/issue/service.proto @@ -1,12 +1,11 @@ syntax = "proto3"; package AssetMantle.modules.x.identities.transactions.issue; -import "google/api/annotations.proto"; +import "cosmos/msg/v1/msg.proto"; import "AssetMantle/modules/x/identities/transactions/issue/message.proto"; import "AssetMantle/modules/x/identities/transactions/issue/transaction_response.proto"; service Msg { - rpc Handle(Message) returns (TransactionResponse) { - option (google.api.http).post = "/mantle/identities/issue"; - } + option (cosmos.msg.v1.service) = true; + rpc Handle(Message) returns (TransactionResponse) {} } \ No newline at end of file diff --git a/proto/AssetMantle/modules/x/identities/transactions/name/service.proto b/proto/AssetMantle/modules/x/identities/transactions/name/service.proto index a17b6967f..460258171 100644 --- a/proto/AssetMantle/modules/x/identities/transactions/name/service.proto +++ b/proto/AssetMantle/modules/x/identities/transactions/name/service.proto @@ -1,12 +1,11 @@ syntax = "proto3"; package AssetMantle.modules.x.identities.transactions.name; -import "google/api/annotations.proto"; +import "cosmos/msg/v1/msg.proto"; import "AssetMantle/modules/x/identities/transactions/name/message.proto"; import "AssetMantle/modules/x/identities/transactions/name/transaction_response.proto"; service Msg { - rpc Handle(Message) returns (TransactionResponse) { - option (google.api.http).post = "/mantle/identities/name"; - } + option (cosmos.msg.v1.service) = true; + rpc Handle(Message) returns (TransactionResponse) {} } \ No newline at end of file diff --git a/proto/AssetMantle/modules/x/identities/transactions/provision/service.proto b/proto/AssetMantle/modules/x/identities/transactions/provision/service.proto index 04c36a738..7bb67cd3f 100644 --- a/proto/AssetMantle/modules/x/identities/transactions/provision/service.proto +++ b/proto/AssetMantle/modules/x/identities/transactions/provision/service.proto @@ -1,12 +1,11 @@ syntax = "proto3"; package AssetMantle.modules.x.identities.transactions.provision; -import "google/api/annotations.proto"; +import "cosmos/msg/v1/msg.proto"; import "AssetMantle/modules/x/identities/transactions/provision/message.proto"; import "AssetMantle/modules/x/identities/transactions/provision/transaction_response.proto"; service Msg { - rpc Handle(Message) returns (TransactionResponse) { - option (google.api.http).post = "/mantle/identities/provision"; - } + option (cosmos.msg.v1.service) = true; + rpc Handle(Message) returns (TransactionResponse) {} } \ No newline at end of file diff --git a/proto/AssetMantle/modules/x/identities/transactions/quash/service.proto b/proto/AssetMantle/modules/x/identities/transactions/quash/service.proto index 0ceaf7c9a..2b8e21a1d 100644 --- a/proto/AssetMantle/modules/x/identities/transactions/quash/service.proto +++ b/proto/AssetMantle/modules/x/identities/transactions/quash/service.proto @@ -1,12 +1,11 @@ syntax = "proto3"; package AssetMantle.modules.x.identities.transactions.quash; -import "google/api/annotations.proto"; +import "cosmos/msg/v1/msg.proto"; import "AssetMantle/modules/x/identities/transactions/quash/message.proto"; import "AssetMantle/modules/x/identities/transactions/quash/transaction_response.proto"; service Msg { - rpc Handle(Message) returns (TransactionResponse) { - option (google.api.http).post = "/mantle/identities/quash"; - } + option (cosmos.msg.v1.service) = true; + rpc Handle(Message) returns (TransactionResponse) {} } \ No newline at end of file diff --git a/proto/AssetMantle/modules/x/identities/transactions/revoke/service.proto b/proto/AssetMantle/modules/x/identities/transactions/revoke/service.proto index c31f672b1..9352660a2 100644 --- a/proto/AssetMantle/modules/x/identities/transactions/revoke/service.proto +++ b/proto/AssetMantle/modules/x/identities/transactions/revoke/service.proto @@ -1,12 +1,11 @@ syntax = "proto3"; package AssetMantle.modules.x.identities.transactions.revoke; -import "google/api/annotations.proto"; +import "cosmos/msg/v1/msg.proto"; import "AssetMantle/modules/x/identities/transactions/revoke/message.proto"; import "AssetMantle/modules/x/identities/transactions/revoke/transaction_response.proto"; service Msg { - rpc Handle(Message) returns (TransactionResponse) { - option (google.api.http).post = "/mantle/identities/revoke"; - } + option (cosmos.msg.v1.service) = true; + rpc Handle(Message) returns (TransactionResponse) {} } \ No newline at end of file diff --git a/proto/AssetMantle/modules/x/identities/transactions/unprovision/service.proto b/proto/AssetMantle/modules/x/identities/transactions/unprovision/service.proto index 5d095e63a..8fd6cabed 100644 --- a/proto/AssetMantle/modules/x/identities/transactions/unprovision/service.proto +++ b/proto/AssetMantle/modules/x/identities/transactions/unprovision/service.proto @@ -1,12 +1,11 @@ syntax = "proto3"; package AssetMantle.modules.x.identities.transactions.unprovision; -import "google/api/annotations.proto"; +import "cosmos/msg/v1/msg.proto"; import "AssetMantle/modules/x/identities/transactions/unprovision/message.proto"; import "AssetMantle/modules/x/identities/transactions/unprovision/transaction_response.proto"; service Msg { - rpc Handle(Message) returns (TransactionResponse) { - option (google.api.http).post = "/mantle/identities/unprovision"; - } + option (cosmos.msg.v1.service) = true; + rpc Handle(Message) returns (TransactionResponse) {} } \ No newline at end of file diff --git a/proto/AssetMantle/modules/x/identities/transactions/update/service.proto b/proto/AssetMantle/modules/x/identities/transactions/update/service.proto index c3097be2e..eaf99f299 100644 --- a/proto/AssetMantle/modules/x/identities/transactions/update/service.proto +++ b/proto/AssetMantle/modules/x/identities/transactions/update/service.proto @@ -1,12 +1,11 @@ syntax = "proto3"; package AssetMantle.modules.x.identities.transactions.update; -import "google/api/annotations.proto"; +import "cosmos/msg/v1/msg.proto"; import "AssetMantle/modules/x/identities/transactions/update/message.proto"; import "AssetMantle/modules/x/identities/transactions/update/transaction_response.proto"; service Msg { - rpc Handle(Message) returns (TransactionResponse) { - option (google.api.http).post = "/mantle/identities/update"; - } + option (cosmos.msg.v1.service) = true; + rpc Handle(Message) returns (TransactionResponse) {} } \ No newline at end of file diff --git a/proto/AssetMantle/modules/x/maintainers/queries/maintainer/service.proto b/proto/AssetMantle/modules/x/maintainers/queries/maintainer/service.proto index da7a1008c..6a9ac73e4 100644 --- a/proto/AssetMantle/modules/x/maintainers/queries/maintainer/service.proto +++ b/proto/AssetMantle/modules/x/maintainers/queries/maintainer/service.proto @@ -1,12 +1,9 @@ syntax = "proto3"; package AssetMantle.modules.x.maintainers.queries.maintainer; -import "google/api/annotations.proto"; import "AssetMantle/modules/x/maintainers/queries/maintainer/query_request.proto"; import "AssetMantle/modules/x/maintainers/queries/maintainer/query_response.proto"; service Query { - rpc Handle(QueryRequest) returns(QueryResponse){ - option (google.api.http).get = "/mantle/maintainers/v1beta1/maintainer"; - } + rpc Handle(QueryRequest) returns(QueryResponse){} } \ No newline at end of file diff --git a/proto/AssetMantle/modules/x/maintainers/queries/maintainers/service.proto b/proto/AssetMantle/modules/x/maintainers/queries/maintainers/service.proto index 360adac4f..994f9bb06 100644 --- a/proto/AssetMantle/modules/x/maintainers/queries/maintainers/service.proto +++ b/proto/AssetMantle/modules/x/maintainers/queries/maintainers/service.proto @@ -1,12 +1,9 @@ syntax = "proto3"; package AssetMantle.modules.x.maintainers.queries.maintainers; -import "google/api/annotations.proto"; import "AssetMantle/modules/x/maintainers/queries/maintainers/query_request.proto"; import "AssetMantle/modules/x/maintainers/queries/maintainers/query_response.proto"; service Query { - rpc Handle(QueryRequest) returns(QueryResponse){ - option (google.api.http).get = "/mantle/maintainers/v1beta1/maintainers"; - } + rpc Handle(QueryRequest) returns(QueryResponse){} } \ No newline at end of file diff --git a/proto/AssetMantle/modules/x/maintainers/queries/parameters/query_request.proto b/proto/AssetMantle/modules/x/maintainers/queries/parameters/query_request.proto new file mode 100644 index 000000000..9324de52e --- /dev/null +++ b/proto/AssetMantle/modules/x/maintainers/queries/parameters/query_request.proto @@ -0,0 +1,4 @@ +syntax = "proto3"; +package AssetMantle.modules.x.maintainers.queries.parameters; + +message QueryRequest {} \ No newline at end of file diff --git a/proto/AssetMantle/modules/x/maintainers/queries/parameters/query_response.proto b/proto/AssetMantle/modules/x/maintainers/queries/parameters/query_response.proto new file mode 100644 index 000000000..08e4c90e1 --- /dev/null +++ b/proto/AssetMantle/modules/x/maintainers/queries/parameters/query_response.proto @@ -0,0 +1,8 @@ +syntax = "proto3"; +package AssetMantle.modules.x.maintainers.queries.parameters; + +import "AssetMantle/schema/lists/base/parameter_list.proto"; + +message QueryResponse { + AssetMantle.schema.lists.base.ParameterList parameter_list = 1; +} diff --git a/proto/AssetMantle/modules/x/maintainers/queries/parameters/service.proto b/proto/AssetMantle/modules/x/maintainers/queries/parameters/service.proto new file mode 100644 index 000000000..2af0dbefe --- /dev/null +++ b/proto/AssetMantle/modules/x/maintainers/queries/parameters/service.proto @@ -0,0 +1,9 @@ +syntax = "proto3"; +package AssetMantle.modules.x.maintainers.queries.parameters; + +import "AssetMantle/modules/x/maintainers/queries/parameters/query_request.proto"; +import "AssetMantle/modules/x/maintainers/queries/parameters/query_response.proto"; + +service Query { + rpc Handle(QueryRequest) returns (QueryResponse) {} +} \ No newline at end of file diff --git a/proto/AssetMantle/modules/x/metas/queries/meta/service.proto b/proto/AssetMantle/modules/x/metas/queries/meta/service.proto index 4bc2f8f40..a3a8c4d27 100644 --- a/proto/AssetMantle/modules/x/metas/queries/meta/service.proto +++ b/proto/AssetMantle/modules/x/metas/queries/meta/service.proto @@ -1,12 +1,9 @@ syntax = "proto3"; package AssetMantle.modules.x.metas.queries.meta; -import "google/api/annotations.proto"; import "AssetMantle/modules/x/metas/queries/meta/query_request.proto"; import "AssetMantle/modules/x/metas/queries/meta/query_response.proto"; service Query { - rpc Handle(QueryRequest) returns(QueryResponse){ - option (google.api.http).get = "/mantle/metas/v1beta1/meta"; - } + rpc Handle(QueryRequest) returns(QueryResponse){} } \ No newline at end of file diff --git a/proto/AssetMantle/modules/x/metas/queries/metas/service.proto b/proto/AssetMantle/modules/x/metas/queries/metas/service.proto index 544d75f41..d9851760e 100644 --- a/proto/AssetMantle/modules/x/metas/queries/metas/service.proto +++ b/proto/AssetMantle/modules/x/metas/queries/metas/service.proto @@ -1,12 +1,9 @@ syntax = "proto3"; package AssetMantle.modules.x.metas.queries.metas; -import "google/api/annotations.proto"; import "AssetMantle/modules/x/metas/queries/metas/query_request.proto"; import "AssetMantle/modules/x/metas/queries/metas/query_response.proto"; service Query { - rpc Handle(QueryRequest) returns(QueryResponse){ - option (google.api.http).get = "/mantle/metas/v1beta1/metas"; - } + rpc Handle(QueryRequest) returns(QueryResponse){} } \ No newline at end of file diff --git a/proto/AssetMantle/modules/x/metas/queries/parameters/query_request.proto b/proto/AssetMantle/modules/x/metas/queries/parameters/query_request.proto new file mode 100644 index 000000000..bbd5c01e3 --- /dev/null +++ b/proto/AssetMantle/modules/x/metas/queries/parameters/query_request.proto @@ -0,0 +1,4 @@ +syntax = "proto3"; +package AssetMantle.modules.x.metas.queries.parameters; + +message QueryRequest {} \ No newline at end of file diff --git a/proto/AssetMantle/modules/x/metas/queries/parameters/query_response.proto b/proto/AssetMantle/modules/x/metas/queries/parameters/query_response.proto new file mode 100644 index 000000000..8424b901c --- /dev/null +++ b/proto/AssetMantle/modules/x/metas/queries/parameters/query_response.proto @@ -0,0 +1,8 @@ +syntax = "proto3"; +package AssetMantle.modules.x.metas.queries.parameters; + +import "AssetMantle/schema/lists/base/parameter_list.proto"; + +message QueryResponse { + AssetMantle.schema.lists.base.ParameterList parameter_list = 1; +} diff --git a/proto/AssetMantle/modules/x/metas/queries/parameters/service.proto b/proto/AssetMantle/modules/x/metas/queries/parameters/service.proto new file mode 100644 index 000000000..56609688a --- /dev/null +++ b/proto/AssetMantle/modules/x/metas/queries/parameters/service.proto @@ -0,0 +1,9 @@ +syntax = "proto3"; +package AssetMantle.modules.x.metas.queries.parameters; + +import "AssetMantle/modules/x/metas/queries/parameters/query_request.proto"; +import "AssetMantle/modules/x/metas/queries/parameters/query_response.proto"; + +service Query { + rpc Handle(QueryRequest) returns (QueryResponse) {} +} \ No newline at end of file diff --git a/proto/AssetMantle/modules/x/metas/transactions/reveal/service.proto b/proto/AssetMantle/modules/x/metas/transactions/reveal/service.proto index 38eb685ea..e026bae20 100644 --- a/proto/AssetMantle/modules/x/metas/transactions/reveal/service.proto +++ b/proto/AssetMantle/modules/x/metas/transactions/reveal/service.proto @@ -1,12 +1,11 @@ syntax = "proto3"; package AssetMantle.modules.x.metas.transactions.reveal; -import "google/api/annotations.proto"; +import "cosmos/msg/v1/msg.proto"; import "AssetMantle/modules/x/metas/transactions/reveal/message.proto"; import "AssetMantle/modules/x/metas/transactions/reveal/transaction_response.proto"; service Msg { - rpc Handle(Message) returns (TransactionResponse) { - option (google.api.http).post = "/mantle/metas/reveal"; - } + option (cosmos.msg.v1.service) = true; + rpc Handle(Message) returns (TransactionResponse) {} } \ No newline at end of file diff --git a/proto/AssetMantle/modules/x/orders/queries/order/service.proto b/proto/AssetMantle/modules/x/orders/queries/order/service.proto index 18183b5a3..662c0c26e 100644 --- a/proto/AssetMantle/modules/x/orders/queries/order/service.proto +++ b/proto/AssetMantle/modules/x/orders/queries/order/service.proto @@ -1,12 +1,9 @@ syntax = "proto3"; package AssetMantle.modules.x.orders.queries.order; -import "google/api/annotations.proto"; import "AssetMantle/modules/x/orders/queries/order/query_request.proto"; import "AssetMantle/modules/x/orders/queries/order/query_response.proto"; service Query { - rpc Handle(QueryRequest) returns(QueryResponse){ - option (google.api.http).get = "/mantle/orders/v1beta1/order"; - } + rpc Handle(QueryRequest) returns(QueryResponse){} } \ No newline at end of file diff --git a/proto/AssetMantle/modules/x/orders/queries/orders/service.proto b/proto/AssetMantle/modules/x/orders/queries/orders/service.proto index a82842e35..7cebcf4fe 100644 --- a/proto/AssetMantle/modules/x/orders/queries/orders/service.proto +++ b/proto/AssetMantle/modules/x/orders/queries/orders/service.proto @@ -1,12 +1,9 @@ syntax = "proto3"; package AssetMantle.modules.x.orders.queries.orders; -import "google/api/annotations.proto"; import "AssetMantle/modules/x/orders/queries/orders/query_request.proto"; import "AssetMantle/modules/x/orders/queries/orders/query_response.proto"; service Query { - rpc Handle(QueryRequest) returns (QueryResponse) { - option (google.api.http).get = "/mantle/orders/v1beta1/orders"; - } + rpc Handle(QueryRequest) returns (QueryResponse) {} } \ No newline at end of file diff --git a/proto/AssetMantle/modules/x/orders/queries/parameters/query_request.proto b/proto/AssetMantle/modules/x/orders/queries/parameters/query_request.proto new file mode 100644 index 000000000..ecd340ee2 --- /dev/null +++ b/proto/AssetMantle/modules/x/orders/queries/parameters/query_request.proto @@ -0,0 +1,4 @@ +syntax = "proto3"; +package AssetMantle.modules.x.orders.queries.parameters; + +message QueryRequest {} \ No newline at end of file diff --git a/proto/AssetMantle/modules/x/orders/queries/parameters/query_response.proto b/proto/AssetMantle/modules/x/orders/queries/parameters/query_response.proto new file mode 100644 index 000000000..3c2087ba0 --- /dev/null +++ b/proto/AssetMantle/modules/x/orders/queries/parameters/query_response.proto @@ -0,0 +1,8 @@ +syntax = "proto3"; +package AssetMantle.modules.x.orders.queries.parameters; + +import "AssetMantle/schema/lists/base/parameter_list.proto"; + +message QueryResponse { + AssetMantle.schema.lists.base.ParameterList parameter_list = 1; +} diff --git a/proto/AssetMantle/modules/x/orders/queries/parameters/service.proto b/proto/AssetMantle/modules/x/orders/queries/parameters/service.proto new file mode 100644 index 000000000..a49fbdf39 --- /dev/null +++ b/proto/AssetMantle/modules/x/orders/queries/parameters/service.proto @@ -0,0 +1,9 @@ +syntax = "proto3"; +package AssetMantle.modules.x.orders.queries.parameters; + +import "AssetMantle/modules/x/orders/queries/parameters/query_request.proto"; +import "AssetMantle/modules/x/orders/queries/parameters/query_response.proto"; + +service Query { + rpc Handle(QueryRequest) returns (QueryResponse) {} +} \ No newline at end of file diff --git a/proto/AssetMantle/modules/x/orders/transactions/cancel/service.proto b/proto/AssetMantle/modules/x/orders/transactions/cancel/service.proto index cbc547c0f..390ce7596 100644 --- a/proto/AssetMantle/modules/x/orders/transactions/cancel/service.proto +++ b/proto/AssetMantle/modules/x/orders/transactions/cancel/service.proto @@ -1,12 +1,11 @@ syntax = "proto3"; package AssetMantle.modules.x.orders.transactions.cancel; -import "google/api/annotations.proto"; +import "cosmos/msg/v1/msg.proto"; import "AssetMantle/modules/x/orders/transactions/cancel/message.proto"; import "AssetMantle/modules/x/orders/transactions/cancel/transaction_response.proto"; service Msg { - rpc Handle(Message) returns (TransactionResponse) { - option (google.api.http).post = "/mantle/orders/cancel"; - } + option (cosmos.msg.v1.service) = true; + rpc Handle(Message) returns (TransactionResponse) {} } \ No newline at end of file diff --git a/proto/AssetMantle/modules/x/orders/transactions/define/service.proto b/proto/AssetMantle/modules/x/orders/transactions/define/service.proto index 0998b6177..2774f0ca9 100644 --- a/proto/AssetMantle/modules/x/orders/transactions/define/service.proto +++ b/proto/AssetMantle/modules/x/orders/transactions/define/service.proto @@ -1,12 +1,11 @@ syntax = "proto3"; package AssetMantle.modules.x.orders.transactions.define; -import "google/api/annotations.proto"; +import "cosmos/msg/v1/msg.proto"; import "AssetMantle/modules/x/orders/transactions/define/message.proto"; import "AssetMantle/modules/x/orders/transactions/define/transaction_response.proto"; service Msg { - rpc Handle(Message) returns (TransactionResponse) { - option (google.api.http).post = "/mantle/orders/define"; - } + option (cosmos.msg.v1.service) = true; + rpc Handle(Message) returns (TransactionResponse) {} } \ No newline at end of file diff --git a/proto/AssetMantle/modules/x/orders/transactions/deputize/service.proto b/proto/AssetMantle/modules/x/orders/transactions/deputize/service.proto index e2c0be378..9bf1dda32 100644 --- a/proto/AssetMantle/modules/x/orders/transactions/deputize/service.proto +++ b/proto/AssetMantle/modules/x/orders/transactions/deputize/service.proto @@ -1,12 +1,11 @@ syntax = "proto3"; package AssetMantle.modules.x.orders.transactions.deputize; -import "google/api/annotations.proto"; +import "cosmos/msg/v1/msg.proto"; import "AssetMantle/modules/x/orders/transactions/deputize/message.proto"; import "AssetMantle/modules/x/orders/transactions/deputize/transaction_response.proto"; service Msg { - rpc Handle(Message) returns (TransactionResponse) { - option (google.api.http).post = "/mantle/orders/deputize"; - } + option (cosmos.msg.v1.service) = true; + rpc Handle(Message) returns (TransactionResponse) {} } \ No newline at end of file diff --git a/proto/AssetMantle/modules/x/orders/transactions/get/service.proto b/proto/AssetMantle/modules/x/orders/transactions/get/service.proto index 3bbecbea1..fbf128450 100644 --- a/proto/AssetMantle/modules/x/orders/transactions/get/service.proto +++ b/proto/AssetMantle/modules/x/orders/transactions/get/service.proto @@ -1,12 +1,11 @@ syntax = "proto3"; package AssetMantle.modules.x.orders.transactions.get; -import "google/api/annotations.proto"; +import "cosmos/msg/v1/msg.proto"; import "AssetMantle/modules/x/orders/transactions/get/message.proto"; import "AssetMantle/modules/x/orders/transactions/get/transaction_response.proto"; service Msg { - rpc Handle(Message) returns (TransactionResponse) { - option (google.api.http).post = "/mantle/orders/get"; - } + option (cosmos.msg.v1.service) = true; + rpc Handle(Message) returns (TransactionResponse) {} } \ No newline at end of file diff --git a/proto/AssetMantle/modules/x/orders/transactions/immediate/service.proto b/proto/AssetMantle/modules/x/orders/transactions/immediate/service.proto index 41308c955..72b37dd49 100644 --- a/proto/AssetMantle/modules/x/orders/transactions/immediate/service.proto +++ b/proto/AssetMantle/modules/x/orders/transactions/immediate/service.proto @@ -1,12 +1,11 @@ syntax = "proto3"; package AssetMantle.modules.x.orders.transactions.immediate; -import "google/api/annotations.proto"; +import "cosmos/msg/v1/msg.proto"; import "AssetMantle/modules/x/orders/transactions/immediate/message.proto"; import "AssetMantle/modules/x/orders/transactions/immediate/transaction_response.proto"; service Msg { - rpc Handle(Message) returns (TransactionResponse) { - option (google.api.http).post = "/mantle/orders/immediate"; - } + option (cosmos.msg.v1.service) = true; + rpc Handle(Message) returns (TransactionResponse) {} } \ No newline at end of file diff --git a/proto/AssetMantle/modules/x/orders/transactions/make/service.proto b/proto/AssetMantle/modules/x/orders/transactions/make/service.proto index ca2a50e6e..f39070024 100644 --- a/proto/AssetMantle/modules/x/orders/transactions/make/service.proto +++ b/proto/AssetMantle/modules/x/orders/transactions/make/service.proto @@ -1,12 +1,11 @@ syntax = "proto3"; package AssetMantle.modules.x.orders.transactions.make; -import "google/api/annotations.proto"; +import "cosmos/msg/v1/msg.proto"; import "AssetMantle/modules/x/orders/transactions/make/message.proto"; import "AssetMantle/modules/x/orders/transactions/make/transaction_response.proto"; service Msg { - rpc Handle(Message) returns (TransactionResponse) { - option (google.api.http).post = "/mantle/orders/make"; - } + option (cosmos.msg.v1.service) = true; + rpc Handle(Message) returns (TransactionResponse) {} } \ No newline at end of file diff --git a/proto/AssetMantle/modules/x/orders/transactions/modify/service.proto b/proto/AssetMantle/modules/x/orders/transactions/modify/service.proto index 0ab307995..420ee675b 100644 --- a/proto/AssetMantle/modules/x/orders/transactions/modify/service.proto +++ b/proto/AssetMantle/modules/x/orders/transactions/modify/service.proto @@ -1,12 +1,11 @@ syntax = "proto3"; package AssetMantle.modules.x.orders.transactions.modify; -import "google/api/annotations.proto"; +import "cosmos/msg/v1/msg.proto"; import "AssetMantle/modules/x/orders/transactions/modify/message.proto"; import "AssetMantle/modules/x/orders/transactions/modify/transaction_response.proto"; service Msg { - rpc Handle(Message) returns (TransactionResponse) { - option (google.api.http).post = "/mantle/orders/modify"; - } + option (cosmos.msg.v1.service) = true; + rpc Handle(Message) returns (TransactionResponse) {} } \ No newline at end of file diff --git a/proto/AssetMantle/modules/x/orders/transactions/put/service.proto b/proto/AssetMantle/modules/x/orders/transactions/put/service.proto index 1b8210d75..3cf3c903f 100644 --- a/proto/AssetMantle/modules/x/orders/transactions/put/service.proto +++ b/proto/AssetMantle/modules/x/orders/transactions/put/service.proto @@ -1,12 +1,11 @@ syntax = "proto3"; package AssetMantle.modules.x.orders.transactions.put; -import "google/api/annotations.proto"; +import "cosmos/msg/v1/msg.proto"; import "AssetMantle/modules/x/orders/transactions/put/message.proto"; import "AssetMantle/modules/x/orders/transactions/put/transaction_response.proto"; service Msg { - rpc Handle(Message) returns (TransactionResponse) { - option (google.api.http).post = "/mantle/orders/put"; - } + option (cosmos.msg.v1.service) = true; + rpc Handle(Message) returns (TransactionResponse) {} } \ No newline at end of file diff --git a/proto/AssetMantle/modules/x/orders/transactions/revoke/service.proto b/proto/AssetMantle/modules/x/orders/transactions/revoke/service.proto index 0b174c1fd..34975693e 100644 --- a/proto/AssetMantle/modules/x/orders/transactions/revoke/service.proto +++ b/proto/AssetMantle/modules/x/orders/transactions/revoke/service.proto @@ -1,12 +1,11 @@ syntax = "proto3"; package AssetMantle.modules.x.orders.transactions.revoke; -import "google/api/annotations.proto"; +import "cosmos/msg/v1/msg.proto"; import "AssetMantle/modules/x/orders/transactions/revoke/message.proto"; import "AssetMantle/modules/x/orders/transactions/revoke/transaction_response.proto"; service Msg { - rpc Handle(Message) returns (TransactionResponse) { - option (google.api.http).post = "/mantle/orders/revoke"; - } + option (cosmos.msg.v1.service) = true; + rpc Handle(Message) returns (TransactionResponse) {} } \ No newline at end of file diff --git a/proto/AssetMantle/modules/x/orders/transactions/take/service.proto b/proto/AssetMantle/modules/x/orders/transactions/take/service.proto index a47e398f9..dc331fb62 100644 --- a/proto/AssetMantle/modules/x/orders/transactions/take/service.proto +++ b/proto/AssetMantle/modules/x/orders/transactions/take/service.proto @@ -1,12 +1,11 @@ syntax = "proto3"; package AssetMantle.modules.x.orders.transactions.take; -import "google/api/annotations.proto"; +import "cosmos/msg/v1/msg.proto"; import "AssetMantle/modules/x/orders/transactions/take/message.proto"; import "AssetMantle/modules/x/orders/transactions/take/transaction_response.proto"; service Msg { - rpc Handle(Message) returns (TransactionResponse) { - option (google.api.http).post = "/mantle/orders/take"; - } + option (cosmos.msg.v1.service) = true; + rpc Handle(Message) returns (TransactionResponse) {} } \ No newline at end of file diff --git a/proto/AssetMantle/modules/x/splits/queries/balances/service.proto b/proto/AssetMantle/modules/x/splits/queries/balances/service.proto index b7448f05c..d291e3a17 100644 --- a/proto/AssetMantle/modules/x/splits/queries/balances/service.proto +++ b/proto/AssetMantle/modules/x/splits/queries/balances/service.proto @@ -1,12 +1,9 @@ syntax = "proto3"; package AssetMantle.modules.x.splits.queries.balances; -import "google/api/annotations.proto"; import "AssetMantle/modules/x/splits/queries/balances/query_request.proto"; import "AssetMantle/modules/x/splits/queries/balances/query_response.proto"; service Query { - rpc Handle(QueryRequest) returns (QueryResponse) { - option (google.api.http).get = "/mantle/splits/v1beta1/balances"; - } + rpc Handle(QueryRequest) returns (QueryResponse) {} } \ No newline at end of file diff --git a/proto/AssetMantle/modules/x/splits/queries/parameters/query_request.proto b/proto/AssetMantle/modules/x/splits/queries/parameters/query_request.proto new file mode 100644 index 000000000..0e886f7fd --- /dev/null +++ b/proto/AssetMantle/modules/x/splits/queries/parameters/query_request.proto @@ -0,0 +1,4 @@ +syntax = "proto3"; +package AssetMantle.modules.x.splits.queries.parameters; + +message QueryRequest {} \ No newline at end of file diff --git a/proto/AssetMantle/modules/x/splits/queries/parameters/query_response.proto b/proto/AssetMantle/modules/x/splits/queries/parameters/query_response.proto new file mode 100644 index 000000000..62884440a --- /dev/null +++ b/proto/AssetMantle/modules/x/splits/queries/parameters/query_response.proto @@ -0,0 +1,8 @@ +syntax = "proto3"; +package AssetMantle.modules.x.splits.queries.parameters; + +import "AssetMantle/schema/lists/base/parameter_list.proto"; + +message QueryResponse { + AssetMantle.schema.lists.base.ParameterList parameter_list = 1; +} diff --git a/proto/AssetMantle/modules/x/splits/queries/parameters/service.proto b/proto/AssetMantle/modules/x/splits/queries/parameters/service.proto new file mode 100644 index 000000000..c426dd6db --- /dev/null +++ b/proto/AssetMantle/modules/x/splits/queries/parameters/service.proto @@ -0,0 +1,9 @@ +syntax = "proto3"; +package AssetMantle.modules.x.splits.queries.parameters; + +import "AssetMantle/modules/x/splits/queries/parameters/query_request.proto"; +import "AssetMantle/modules/x/splits/queries/parameters/query_response.proto"; + +service Query { + rpc Handle(QueryRequest) returns (QueryResponse) {} +} \ No newline at end of file diff --git a/proto/AssetMantle/modules/x/splits/queries/split/service.proto b/proto/AssetMantle/modules/x/splits/queries/split/service.proto index 28271df3e..81dace100 100644 --- a/proto/AssetMantle/modules/x/splits/queries/split/service.proto +++ b/proto/AssetMantle/modules/x/splits/queries/split/service.proto @@ -1,12 +1,9 @@ syntax = "proto3"; package AssetMantle.modules.x.splits.queries.split; -import "google/api/annotations.proto"; import "AssetMantle/modules/x/splits/queries/split/query_request.proto"; import "AssetMantle/modules/x/splits/queries/split/query_response.proto"; service Query { - rpc Handle(QueryRequest) returns(QueryResponse){ - option (google.api.http).get = "/mantle/splits/v1beta1/split"; - } + rpc Handle(QueryRequest) returns(QueryResponse){} } \ No newline at end of file diff --git a/proto/AssetMantle/modules/x/splits/queries/splits/service.proto b/proto/AssetMantle/modules/x/splits/queries/splits/service.proto index 9aaaa2214..f83783247 100644 --- a/proto/AssetMantle/modules/x/splits/queries/splits/service.proto +++ b/proto/AssetMantle/modules/x/splits/queries/splits/service.proto @@ -1,12 +1,9 @@ syntax = "proto3"; package AssetMantle.modules.x.splits.queries.splits; -import "google/api/annotations.proto"; import "AssetMantle/modules/x/splits/queries/splits/query_request.proto"; import "AssetMantle/modules/x/splits/queries/splits/query_response.proto"; service Query { - rpc Handle(QueryRequest) returns(QueryResponse){ - option (google.api.http).get = "/mantle/splits/v1beta1/splits"; - } + rpc Handle(QueryRequest) returns(QueryResponse){} } \ No newline at end of file diff --git a/proto/AssetMantle/modules/x/splits/queries/supply/service.proto b/proto/AssetMantle/modules/x/splits/queries/supply/service.proto index 5c380a324..3be634ede 100644 --- a/proto/AssetMantle/modules/x/splits/queries/supply/service.proto +++ b/proto/AssetMantle/modules/x/splits/queries/supply/service.proto @@ -1,12 +1,9 @@ syntax = "proto3"; package AssetMantle.modules.x.splits.queries.supply; -import "google/api/annotations.proto"; import "AssetMantle/modules/x/splits/queries/supply/query_request.proto"; import "AssetMantle/modules/x/splits/queries/supply/query_response.proto"; service Query { - rpc Handle(QueryRequest) returns (QueryResponse) { - option (google.api.http).get = "/mantle/splits/v1beta1/supply"; - } + rpc Handle(QueryRequest) returns (QueryResponse) {} } \ No newline at end of file diff --git a/proto/buf.gen.yaml b/proto/buf.gen.yaml index 8e18d867c..810df92a7 100644 --- a/proto/buf.gen.yaml +++ b/proto/buf.gen.yaml @@ -13,6 +13,3 @@ plugins: - name: gocosmos out: ../ opt: plugins=grpc - - name: grpc-gateway - out: ../ - opt: allow_colon_final_segments=true diff --git a/simulation/schema/types/base/properties.go b/simulation/schema/types/base/properties.go index 15de0f853..19750d9da 100644 --- a/simulation/schema/types/base/properties.go +++ b/simulation/schema/types/base/properties.go @@ -4,12 +4,11 @@ package base import ( - "math" - "math/rand" - "github.com/AssetMantle/schema/lists" baseLists "github.com/AssetMantle/schema/lists/base" "github.com/AssetMantle/schema/properties" + "math" + "math/rand" ) func GenerateRandomPropertyList(r *rand.Rand) lists.PropertyList { diff --git a/simulation/schema/types/base/property.go b/simulation/schema/types/base/property.go index 586aadc5e..34b3e8e07 100644 --- a/simulation/schema/types/base/property.go +++ b/simulation/schema/types/base/property.go @@ -4,13 +4,12 @@ package base import ( - "math" - "math/rand" - baseIDs "github.com/AssetMantle/schema/ids/base" "github.com/AssetMantle/schema/properties" baseProperties "github.com/AssetMantle/schema/properties/base" simulationTypes "github.com/cosmos/cosmos-sdk/types/simulation" + "math" + "math/rand" "github.com/AssetMantle/modules/utilities/random" ) diff --git a/utilities/client/methods.go b/utilities/client/methods.go deleted file mode 100644 index df9a77641..000000000 --- a/utilities/client/methods.go +++ /dev/null @@ -1,11 +0,0 @@ -package clientUtils - -import ( - "github.com/cosmos/cosmos-sdk/client" - "net/http" -) - -func ParseQueryHeightOrReturnBadRequest(responseWriter http.ResponseWriter, clientContext client.Context, request *http.Request) (client.Context, bool) { - // TODO correct - return clientContext, true -} diff --git a/utilities/encoding/decode.go b/utilities/encoding/decode.go new file mode 100644 index 000000000..94b81e563 --- /dev/null +++ b/utilities/encoding/decode.go @@ -0,0 +1,10 @@ +package encoding + +import ( + "github.com/AssetMantle/modules/helpers/base" + "github.com/cosmos/gogoproto/proto" +) + +func Decode[Message proto.Message](data []byte, message Message) error { + return base.CodecPrototype().UnmarshalJSON(data, message) +} diff --git a/utilities/encoding/encode.go b/utilities/encoding/encode.go new file mode 100644 index 000000000..e151da3c0 --- /dev/null +++ b/utilities/encoding/encode.go @@ -0,0 +1,10 @@ +package encoding + +import ( + "github.com/AssetMantle/modules/helpers/base" + "github.com/cosmos/gogoproto/proto" +) + +func Encode[Message proto.Message](message Message) ([]byte, error) { + return base.CodecPrototype().MarshalJSON(message) +} diff --git a/utilities/rest/baseReq.go b/utilities/rest/baseReq.go deleted file mode 100644 index d499a6d6a..000000000 --- a/utilities/rest/baseReq.go +++ /dev/null @@ -1,48 +0,0 @@ -package rest - -import ( - "github.com/cosmos/cosmos-sdk/types" - "net/http" -) - -type BaseReq struct { - From string `json:"from"` - Memo string `json:"memo"` - TimeoutHeight uint64 `json:"timeout_height"` - AccountNumber uint64 `json:"account_number"` - Sequence uint64 `json:"sequence"` - ChainID string `json:"chain_id"` - Gas string `json:"gas"` - Fees types.Coins `json:"fees"` - GasPrices types.DecCoins `json:"gas_prices"` - Simulate bool `json:"simulate"` - GasAdjustment string `json:"gas_adjustment"` -} - -func (BaseReq) Validate() error { - return nil -} - -func (BaseReq) Sanitize() BaseReq { - return BaseReq{} -} - -func (BaseReq) ValidateBasic(w http.ResponseWriter) bool { - return false -} - -func NewBaseReq(from, memo, chainID, gas, gasAdjustment string, timeoutHeight, accountNumber, sequence uint64, fees types.Coins, gasPrices types.DecCoins, simulate bool) BaseReq { - return BaseReq{ - From: from, - Memo: memo, - TimeoutHeight: timeoutHeight, - AccountNumber: accountNumber, - Sequence: sequence, - ChainID: chainID, - Gas: gas, - Fees: fees, - GasPrices: gasPrices, - Simulate: simulate, - GasAdjustment: gasAdjustment, - } -} diff --git a/utilities/rest/id_getters/docs/common.go b/utilities/rest/id_getters/docs/common.go index f12749437..8362a61ef 100644 --- a/utilities/rest/id_getters/docs/common.go +++ b/utilities/rest/id_getters/docs/common.go @@ -1,10 +1,11 @@ package docs import ( + "encoding/json" "github.com/AssetMantle/modules/utilities/rest" + "io" "net/http" - codecUtilities "github.com/AssetMantle/schema/codec/utilities" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" "github.com/AssetMantle/schema/lists" @@ -12,16 +13,11 @@ import ( "github.com/AssetMantle/schema/qualified" "github.com/AssetMantle/schema/qualified/base" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" "github.com/gorilla/mux" ) -func RegisterLegacyAminoCodec(legacyAmino *codec.LegacyAmino) { - codecUtilities.RegisterModuleConcrete(legacyAmino, request{}) -} - func GetTotalWeight(immutables qualified.Immutables, mutables qualified.Mutables) sdkTypes.Int { totalWeight := sdkTypes.ZeroInt() for _, property := range append(immutables.GetImmutablePropertyList().Get(), mutables.GetMutablePropertyList().Get()...) { @@ -40,31 +36,32 @@ func ReadAndProcess(context client.Context, responseWriter http.ResponseWriter, } func read(context client.Context, responseWriter http.ResponseWriter, httpRequest *http.Request) (request, ids.ClassificationID, lists.PropertyList, lists.PropertyList, lists.PropertyList, lists.PropertyList) { - transactionRequest := Prototype() - if !rest.ReadRESTReq(responseWriter, httpRequest, context.LegacyAmino, &transactionRequest) { + body, err := io.ReadAll(httpRequest.Body) + if err != nil { + rest.WriteErrorResponse(responseWriter, http.StatusBadRequest, err.Error()) return request{}, nil, nil, nil, nil, nil } - if rest.CheckBadRequestError(responseWriter, transactionRequest.Validate()) { - return request{}, nil, nil, nil, nil, nil + request := request{} + if err := json.Unmarshal(body, &request); err != nil { + rest.WriteErrorResponse(responseWriter, http.StatusBadRequest, err.Error()) + return request, nil, nil, nil, nil, nil } - req := transactionRequest.(request) - - immutableMetaProperties, _ := baseLists.NewPropertyList().FromMetaPropertiesString(req.ImmutableMetaProperties) + immutableMetaProperties, _ := baseLists.NewPropertyList().FromMetaPropertiesString(request.ImmutableMetaProperties) - immutableProperties, _ := baseLists.NewPropertyList().FromMetaPropertiesString(req.ImmutableProperties) + immutableProperties, _ := baseLists.NewPropertyList().FromMetaPropertiesString(request.ImmutableProperties) immutableProperties = immutableProperties.ScrubData() - mutableMetaProperties, _ := baseLists.NewPropertyList().FromMetaPropertiesString(req.MutableMetaProperties) + mutableMetaProperties, _ := baseLists.NewPropertyList().FromMetaPropertiesString(request.MutableMetaProperties) - mutableProperties, _ := baseLists.NewPropertyList().FromMetaPropertiesString(req.MutableProperties) + mutableProperties, _ := baseLists.NewPropertyList().FromMetaPropertiesString(request.MutableProperties) mutableProperties = mutableProperties.ScrubData() - classificationID, _ := baseIDs.PrototypeClassificationID().FromString(req.ClassificationID) - return req, classificationID.(ids.ClassificationID), immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties + classificationID, _ := baseIDs.PrototypeClassificationID().FromString(request.ClassificationID) + return request, classificationID.(ids.ClassificationID), immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties } func Process(immutableMetaPropertyList, immutablePropertyList, mutableMetaPropertyList, mutablePropertyList lists.PropertyList) (qualified.Immutables, qualified.Mutables) { diff --git a/utilities/rest/id_getters/docs/identity.go b/utilities/rest/id_getters/docs/identity.go index 79c10ed76..a69e6a46e 100644 --- a/utilities/rest/id_getters/docs/identity.go +++ b/utilities/rest/id_getters/docs/identity.go @@ -1,8 +1,9 @@ package docs import ( - "fmt" + "encoding/json" "github.com/AssetMantle/modules/utilities/rest" + "io" "net/http" baseData "github.com/AssetMantle/schema/data/base" @@ -13,16 +14,19 @@ import ( func nameIdentityIDHandler(context client.Context) http.HandlerFunc { return func(responseWriter http.ResponseWriter, httpRequest *http.Request) { - transactionRequest := Prototype() - if !rest.ReadRESTReq(responseWriter, httpRequest, context.LegacyAmino, &transactionRequest) { - panic(fmt.Errorf("failed to read request")) + body, err := io.ReadAll(httpRequest.Body) + if err != nil { + rest.WriteErrorResponse(responseWriter, http.StatusBadRequest, err.Error()) + return } - if rest.CheckBadRequestError(responseWriter, transactionRequest.Validate()) { - panic(fmt.Errorf("failed to validate request")) + request := request{} + if err := json.Unmarshal(body, &request); err != nil { + rest.WriteErrorResponse(responseWriter, http.StatusBadRequest, err.Error()) + return } - rest.PostProcessResponse(responseWriter, context, newResponse(baseDocuments.NewNameIdentity(baseIDs.NewStringID(transactionRequest.(request).Name), baseData.PrototypeListData()).GetNameIdentityID().AsString(), nil)) + rest.PostProcessResponse(responseWriter, context, newResponse(baseDocuments.NewNameIdentity(baseIDs.NewStringID(request.Name), baseData.PrototypeListData()).GetNameIdentityID().AsString(), nil)) } } diff --git a/utilities/rest/id_getters/docs/request.go b/utilities/rest/id_getters/docs/request.go index e4f1d875a..e338f2530 100644 --- a/utilities/rest/id_getters/docs/request.go +++ b/utilities/rest/id_getters/docs/request.go @@ -3,40 +3,20 @@ package docs -import ( - "github.com/AssetMantle/modules/helpers" - "github.com/AssetMantle/modules/utilities/rest" -) - type request struct { - BaseReq rest.BaseReq `json:"baseReq"` - FromID string `json:"fromID" valid:"optional"` - ImmutableMetaProperties string `json:"immutableMetaProperties" valid:"optional"` - ImmutableProperties string `json:"immutableProperties" valid:"optional"` - MutableMetaProperties string `json:"mutableMetaProperties" valid:"optional"` - MutableProperties string `json:"mutableProperties" valid:"optional"` - ClassificationID string `json:"classificationID" valid:"optional"` - MakerAssetID string `json:"makerAssetID" valid:"optional"` - TakerAssetID string `json:"takerAssetID" valid:"optional"` - MakerSplit string `json:"makerSplit" valid:"optional"` - TakerSplit string `json:"takerSplit" valid:"optional"` - ExpiresIn string `json:"expiresIn" valid:"optional"` - Height string `json:"height" valid:"optional"` - TakerID string `json:"takerID" valid:"optional"` - Name string `json:"name" valid:"optional"` - Coins string `json:"coins" valid:"optional"` -} - -var _ helpers.Request = &request{} - -func (request request) Validate() error { - return nil -} - -func (request request) GetBaseReq() rest.BaseReq { - return request.BaseReq -} - -func Prototype() helpers.Request { - return request{} + FromID string `json:"fromID" valid:"optional"` + ImmutableMetaProperties string `json:"immutableMetaProperties" valid:"optional"` + ImmutableProperties string `json:"immutableProperties" valid:"optional"` + MutableMetaProperties string `json:"mutableMetaProperties" valid:"optional"` + MutableProperties string `json:"mutableProperties" valid:"optional"` + ClassificationID string `json:"classificationID" valid:"optional"` + MakerAssetID string `json:"makerAssetID" valid:"optional"` + TakerAssetID string `json:"takerAssetID" valid:"optional"` + MakerSplit string `json:"makerSplit" valid:"optional"` + TakerSplit string `json:"takerSplit" valid:"optional"` + ExpiresIn string `json:"expiresIn" valid:"optional"` + Height string `json:"height" valid:"optional"` + TakerID string `json:"takerID" valid:"optional"` + Name string `json:"name" valid:"optional"` + Coins string `json:"coins" valid:"optional"` } diff --git a/utilities/rest/id_getters/docs/split.go b/utilities/rest/id_getters/docs/split.go index d756aa2bd..dd245051f 100644 --- a/utilities/rest/id_getters/docs/split.go +++ b/utilities/rest/id_getters/docs/split.go @@ -1,33 +1,34 @@ package docs import ( - "fmt" + "encoding/json" "github.com/AssetMantle/modules/utilities/rest" baseDocuments "github.com/AssetMantle/schema/documents/base" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" "github.com/cosmos/cosmos-sdk/client" sdkTypes "github.com/cosmos/cosmos-sdk/types" - + "io" "net/http" ) func splitIDHandler(context client.Context) http.HandlerFunc { return func(responseWriter http.ResponseWriter, httpRequest *http.Request) { - transactionRequest := Prototype() - if !rest.ReadRESTReq(responseWriter, httpRequest, context.LegacyAmino, &transactionRequest) { - panic(fmt.Errorf("failed to read request")) + body, err := io.ReadAll(httpRequest.Body) + if err != nil { + rest.WriteErrorResponse(responseWriter, http.StatusBadRequest, err.Error()) + return } - if rest.CheckBadRequestError(responseWriter, transactionRequest.Validate()) { - panic(fmt.Errorf("failed to validate request")) + request := request{} + if err := json.Unmarshal(body, &request); err != nil { + rest.WriteErrorResponse(responseWriter, http.StatusBadRequest, err.Error()) + return } - req := transactionRequest.(request) - - fromID, _ := baseIDs.PrototypeIdentityID().FromString(req.FromID) + fromID, _ := baseIDs.PrototypeIdentityID().FromString(request.FromID) - coins, _ := sdkTypes.ParseCoinsNormalized(req.Coins) + coins, _ := sdkTypes.ParseCoinsNormalized(request.Coins) var coinID ids.AssetID for _, coin := range coins { diff --git a/utilities/rest/methods.go b/utilities/rest/methods.go index ebf1bd466..db96e1230 100644 --- a/utilities/rest/methods.go +++ b/utilities/rest/methods.go @@ -2,10 +2,7 @@ package rest import ( "encoding/json" - clientUtils "github.com/AssetMantle/modules/utilities/client" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" - "io" "net/http" ) @@ -16,21 +13,6 @@ func PostProcessResponse(responseWriter http.ResponseWriter, context client.Cont _ = json.NewEncoder(responseWriter).Encode(response) } -func ReadRESTReq(responseWriter http.ResponseWriter, httpRequest *http.Request, legacyAmino *codec.LegacyAmino, request interface{}) bool { - body, err := io.ReadAll(httpRequest.Body) - if err != nil { - responseWriter.WriteHeader(http.StatusBadRequest) - _, _ = responseWriter.Write([]byte(err.Error())) - return false - } - if err := legacyAmino.UnmarshalJSON(body, request); err != nil { - responseWriter.WriteHeader(http.StatusBadRequest) - _, _ = responseWriter.Write([]byte(err.Error())) - return false - } - return true -} - func CheckBadRequestError(responseWriter http.ResponseWriter, err error) bool { if err != nil { responseWriter.WriteHeader(http.StatusBadRequest) @@ -41,10 +23,7 @@ func CheckBadRequestError(responseWriter http.ResponseWriter, err error) bool { } func ParseQueryHeightOrReturnBadRequest(responseWriter http.ResponseWriter, clientContext client.Context, request *http.Request) (client.Context, bool) { - clientContext, ok := clientUtils.ParseQueryHeightOrReturnBadRequest(responseWriter, clientContext, request) - if !ok { - return clientContext, false - } + // TODO correct return clientContext, true } diff --git a/utilities/rest/queuing/broadcast.go b/utilities/rest/queuing/broadcast.go index a25211bac..da9b0dea2 100644 --- a/utilities/rest/queuing/broadcast.go +++ b/utilities/rest/queuing/broadcast.go @@ -1,7 +1,7 @@ package queuing import ( - "github.com/AssetMantle/modules/utilities/rest" + "github.com/AssetMantle/modules/helpers" "reflect" "strconv" @@ -13,16 +13,16 @@ import ( "github.com/AssetMantle/modules/utilities/random" ) -func QueueOrBroadcastTransaction(context client.Context, baseReq rest.BaseReq, msg sdkTypes.Msg) (err error) { - fromAddress, fromName, _, err := client.GetFromFields(context, context.Keyring, baseReq.From) +func QueueOrBroadcastTransaction(context client.Context, commonTransactionRequest helpers.CommonTransactionRequest, msg sdkTypes.Msg) (err error) { + fromAddress, fromName, _, err := client.GetFromFields(context, context.Keyring, commonTransactionRequest.GetFrom()) if err != nil { return err } - context = context.WithFromAddress(fromAddress).WithFromName(fromName).WithSkipConfirmation(true).WithGenerateOnly(baseReq.Simulate) + context = context.WithFromAddress(fromAddress).WithFromName(fromName).WithSkipConfirmation(true).WithGenerateOnly(commonTransactionRequest.IsSimulated()) if KafkaState.IsEnabled { - if err = context.PrintBytes(SendToKafka(NewKafkaMsgFromRest(msg, TicketID(random.GenerateUniqueIdentifier(reflect.TypeOf(msg).String())), baseReq, context), context.LegacyAmino)); err != nil { + if err = context.PrintBytes(SendToKafka(newKafkaMsgFromRest(msg, TicketID(random.GenerateUniqueIdentifier(reflect.TypeOf(msg).String())), commonTransactionRequest, context), context.LegacyAmino)); err != nil { return err } else { return nil @@ -30,30 +30,30 @@ func QueueOrBroadcastTransaction(context client.Context, baseReq rest.BaseReq, m } gasAdjustment := flags.DefaultGasAdjustment - if len(baseReq.GasAdjustment) != 0 { - if gasAdjustment, err = strconv.ParseFloat(baseReq.GasAdjustment, 64); err != nil { + if len(commonTransactionRequest.GetGasAdjustment()) != 0 { + if gasAdjustment, err = strconv.ParseFloat(commonTransactionRequest.GetGasAdjustment(), 64); err != nil { return err } } - gasSetting, err := flags.ParseGasSetting(baseReq.Gas) + gasSetting, err := flags.ParseGasSetting(commonTransactionRequest.GetGas()) if err != nil { return err } transactionFactory := tx.Factory{}. - WithFees(baseReq.Fees.String()). - WithGasPrices(baseReq.GasPrices.String()). - WithAccountNumber(baseReq.AccountNumber). + WithFees(commonTransactionRequest.GetFees().String()). + WithGasPrices(commonTransactionRequest.GetGasPrices().String()). + WithAccountNumber(commonTransactionRequest.GetAccountNumber()). WithAccountRetriever(context.AccountRetriever). - WithSequence(baseReq.Sequence). + WithSequence(commonTransactionRequest.GetSequence()). WithGas(gasSetting.Gas). WithGasAdjustment(gasAdjustment). - WithMemo(baseReq.Memo). - WithChainID(baseReq.ChainID). - WithSimulateAndExecute(gasSetting.Simulate || baseReq.Simulate). + WithMemo(commonTransactionRequest.GetMemo()). + WithChainID(commonTransactionRequest.GetChainID()). + WithSimulateAndExecute(gasSetting.Simulate || commonTransactionRequest.IsSimulated()). WithTxConfig(context.TxConfig). - WithTimeoutHeight(baseReq.TimeoutHeight). + WithTimeoutHeight(commonTransactionRequest.GetTimeoutHeight()). WithKeybase(context.Keyring) if context.GenerateOnly { diff --git a/utilities/rest/queuing/init.go b/utilities/rest/queuing/init.go index c09a4e5bb..8a7fea575 100644 --- a/utilities/rest/queuing/init.go +++ b/utilities/rest/queuing/init.go @@ -10,7 +10,7 @@ import ( ) func InitializeKafka(nodeList []string, context client.Context) { - KafkaState = *NewKafkaState(nodeList) + KafkaState = *newKafkaState(nodeList) if KafkaState.IsEnabled { go func() { for { diff --git a/utilities/rest/queuing/kafka_consumer_test.go b/utilities/rest/queuing/kafka_consumer_test.go index 3beb216a5..0c9d733fe 100644 --- a/utilities/rest/queuing/kafka_consumer_test.go +++ b/utilities/rest/queuing/kafka_consumer_test.go @@ -16,7 +16,7 @@ func TestKafkaTopicConsumer(t *testing.T) { testConsumers := []string{"testConsumers"} require.Panics(t, func() { - testKafkaState := NewKafkaState(testConsumers) + testKafkaState := newKafkaState(testConsumers) partitionConsumer := testKafkaState.Consumers["Topic"] var kafkaStore kafkaMsg diff --git a/utilities/rest/queuing/kafka_types.go b/utilities/rest/queuing/kafka_types.go index 783b85283..7a362dc7a 100755 --- a/utilities/rest/queuing/kafka_types.go +++ b/utilities/rest/queuing/kafka_types.go @@ -4,12 +4,11 @@ package queuing import ( - "github.com/AssetMantle/modules/utilities/rest" + "github.com/AssetMantle/modules/helpers" "github.com/Shopify/sarama" + dbm "github.com/cometbft/cometbft-db" "github.com/cosmos/cosmos-sdk/client" sdk "github.com/cosmos/cosmos-sdk/types" - - dbm "github.com/cometbft/cometbft-db" ) // TicketID : is a type that implements string @@ -17,14 +16,14 @@ type TicketID string // kafkaMsg : is a store that can be stored in kafka queues type kafkaMsg struct { - Msg sdk.Msg `json:"msg"` - TicketID TicketID `json:"TicketID"` - BaseRequest rest.BaseReq `json:"base_req"` - KafkaCliCtx kafkaCliCtx `json:"kafkaCliCtx"` + sdk.Msg `json:"msg"` + TicketID `json:"TicketID"` + helpers.CommonTransactionRequest `json:"commonTransactionRequest"` + KafkaCliCtx kafkaCliCtx } -// NewKafkaMsgFromRest : makes a msg to send to kafka queue -func NewKafkaMsgFromRest(msg sdk.Msg, ticketID TicketID, baseRequest rest.BaseReq, context client.Context) kafkaMsg { +// newKafkaMsgFromRest : makes a msg to send to kafka queue +func newKafkaMsgFromRest(msg sdk.Msg, ticketID TicketID, commonTransactionRequest helpers.CommonTransactionRequest, context client.Context) kafkaMsg { kafkaCtx := kafkaCliCtx{ OutputFormat: context.OutputFormat, ChainID: context.ChainID, @@ -43,10 +42,10 @@ func NewKafkaMsgFromRest(msg sdk.Msg, ticketID TicketID, baseRequest rest.BaseRe // TODO return pointer return kafkaMsg{ - Msg: msg, - TicketID: ticketID, - BaseRequest: baseRequest, - KafkaCliCtx: kafkaCtx, + Msg: msg, + TicketID: ticketID, + CommonTransactionRequest: commonTransactionRequest, + KafkaCliCtx: kafkaCtx, } } @@ -99,8 +98,8 @@ type kafkaState struct { IsEnabled bool } -// NewKafkaState : returns a kafka state -func NewKafkaState(nodeList []string) *kafkaState { +// newKafkaState : returns a kafka state +func newKafkaState(nodeList []string) *kafkaState { kafkaDB, _ := dbm.NewGoLevelDB("KafkaDB", defaultCLIHome) admin := kafkaAdmin(nodeList) producer := newProducer(nodeList) diff --git a/utilities/rest/queuing/sign_and_broadcast.go b/utilities/rest/queuing/sign_and_broadcast.go index d458911db..ae515c4cc 100755 --- a/utilities/rest/queuing/sign_and_broadcast.go +++ b/utilities/rest/queuing/sign_and_broadcast.go @@ -28,12 +28,12 @@ func signAndBroadcastMultiple(kafkaMsgList []kafkaMsg, context client.Context) ( for i, kafkaMsg := range kafkaMsgList { context := cliCtxFromKafkaMsg(kafkaMsg, context) - gasAdj, err := parseGasAdjustment(kafkaMsg.BaseRequest.GasAdjustment) + gasAdj, err := parseGasAdjustment(kafkaMsg.CommonTransactionRequest.GetGasAdjustment()) if err != nil { return nil, err } - gasSetting, err := flags.ParseGasSetting(kafkaMsg.BaseRequest.Gas) + gasSetting, err := flags.ParseGasSetting(kafkaMsg.CommonTransactionRequest.GetGas()) if err != nil { return nil, err } @@ -48,12 +48,12 @@ func signAndBroadcastMultiple(kafkaMsgList []kafkaMsg, context client.Context) ( return nil, err } - kafkaMsg.BaseRequest.AccountNumber = accountNumber + kafkaMsg.CommonTransactionRequest = kafkaMsg.CommonTransactionRequest.SetAccountNumber(accountNumber) var count = uint64(0) for j := 0; j < i; j++ { - if accountNumber == kafkaMsgList[j].BaseRequest.AccountNumber { + if accountNumber == kafkaMsgList[j].CommonTransactionRequest.GetAccountNumber() { count++ } } @@ -61,20 +61,20 @@ func signAndBroadcastMultiple(kafkaMsgList []kafkaMsg, context client.Context) ( sequence += count txFactory := tx.Factory{}. - WithAccountNumber(kafkaMsg.BaseRequest.AccountNumber). - WithSequence(kafkaMsg.BaseRequest.Sequence). + WithAccountNumber(kafkaMsg.CommonTransactionRequest.GetAccountNumber()). + WithSequence(kafkaMsg.CommonTransactionRequest.GetSequence()). WithGas(gasSetting.Gas). WithGasAdjustment(gasAdj). - WithMemo(kafkaMsg.BaseRequest.Memo). - WithChainID(kafkaMsg.BaseRequest.ChainID). - WithSimulateAndExecute(kafkaMsg.BaseRequest.Simulate). + WithMemo(kafkaMsg.CommonTransactionRequest.GetMemo()). + WithChainID(kafkaMsg.CommonTransactionRequest.GetChainID()). + WithSimulateAndExecute(kafkaMsg.CommonTransactionRequest.IsSimulated()). WithTxConfig(context.TxConfig). - WithTimeoutHeight(kafkaMsg.BaseRequest.TimeoutHeight). - WithFees(kafkaMsg.BaseRequest.Fees.String()). - WithGasPrices(kafkaMsg.BaseRequest.GasPrices.String()). + WithTimeoutHeight(kafkaMsg.CommonTransactionRequest.GetTimeoutHeight()). + WithFees(kafkaMsg.CommonTransactionRequest.GetFees().String()). + WithGasPrices(kafkaMsg.CommonTransactionRequest.GetGasPrices().String()). WithKeybase(keyBase) - if kafkaMsg.BaseRequest.Simulate || gasSetting.Simulate { + if kafkaMsg.CommonTransactionRequest.IsSimulated() || gasSetting.Simulate { if gasAdj < 0 { return nil, errors.New("Error invalid gas adjustment") } @@ -87,7 +87,7 @@ func signAndBroadcastMultiple(kafkaMsgList []kafkaMsg, context client.Context) ( txFactory = txFactory.WithGas(adjusted) - if kafkaMsg.BaseRequest.Simulate { + if kafkaMsg.CommonTransactionRequest.IsSimulated() { val, _ := simulationResponse(context.LegacyAmino, txFactory.Gas()) return val, nil } diff --git a/utilities/wasm/custom_encoder.go b/utilities/wasm/custom_encoder.go deleted file mode 100644 index afb866d61..000000000 --- a/utilities/wasm/custom_encoder.go +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright [2021] - [2022], AssetMantle Pte. Ltd. and the code contributors -// SPDX-License-Identifier: Apache-2.0 - -package wasm - -import ( - "encoding/json" - errorConstants "github.com/AssetMantle/modules/helpers/constants" - "strings" - - "github.com/CosmWasm/wasmd/x/wasm" - sdkTypes "github.com/cosmos/cosmos-sdk/types" - - "github.com/AssetMantle/modules/helpers" - baseHelpers "github.com/AssetMantle/modules/helpers/base" -) - -func CustomEncoder(moduleList ...helpers.Module) wasm.CustomEncoder { - return func(sender sdkTypes.AccAddress, rawMessage json.RawMessage) ([]sdkTypes.Msg, error) { - wasmMessage := baseHelpers.WasmMessagePrototype() - - err := json.Unmarshal(rawMessage, &wasmMessage) - if err != nil { - return nil, errorConstants.InvalidMessage.Wrapf(err.Error()) - } - - path := strings.Split(wasmMessage.GetType(), "/") - - for _, module := range moduleList { - if module.Name() == path[0] { - msg, err := module.DecodeModuleTransactionRequest(path[1], wasmMessage.GetRawMessage()) - if err != nil { - return nil, err - } - - return []sdkTypes.Msg{msg}, nil - } - } - - return nil, errorConstants.InvalidMessage.Wrapf("module not found") - } -} diff --git a/x/assets/block/block.go b/x/assets/block/block.go index 1cbdcc3d6..36d85c5ae 100644 --- a/x/assets/block/block.go +++ b/x/assets/block/block.go @@ -5,7 +5,6 @@ package block import ( "context" - abciTypes "github.com/cometbft/cometbft/abci/types" "github.com/AssetMantle/modules/helpers" diff --git a/x/assets/genesis/genesis.go b/x/assets/genesis/genesis.go index 3553f8fcb..9b2cabc39 100644 --- a/x/assets/genesis/genesis.go +++ b/x/assets/genesis/genesis.go @@ -3,7 +3,6 @@ package genesis import ( "context" errorConstants "github.com/AssetMantle/modules/helpers/constants" - "github.com/AssetMantle/schema/lists" "github.com/AssetMantle/schema/lists/base" sdkCodec "github.com/cosmos/cosmos-sdk/codec" diff --git a/x/assets/key/key.go b/x/assets/key/key.go index 74a4eb974..8d4edc6a9 100644 --- a/x/assets/key/key.go +++ b/x/assets/key/key.go @@ -4,11 +4,10 @@ package key import ( + "github.com/AssetMantle/modules/helpers" errorConstants "github.com/AssetMantle/modules/helpers/constants" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" - - "github.com/AssetMantle/modules/helpers" ) var _ helpers.Key = (*Key)(nil) @@ -22,7 +21,7 @@ func (key *Key) ValidateBasic() error { return nil } func (key *Key) GenerateStorePrefixBytes() []byte { - return []byte{} + return []byte{0x0} } func (key *Key) GenerateStoreKeyBytes() []byte { return key.AssetID.Bytes() diff --git a/x/assets/mappable/mappable.go b/x/assets/mappable/mappable.go index f7dbea391..7c865e5aa 100644 --- a/x/assets/mappable/mappable.go +++ b/x/assets/mappable/mappable.go @@ -4,12 +4,9 @@ package mappable import ( - codecUtilities "github.com/AssetMantle/schema/codec/utilities" + "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/schema/documents" "github.com/AssetMantle/schema/documents/base" - "github.com/cosmos/cosmos-sdk/codec" - - "github.com/AssetMantle/modules/helpers" ) var _ helpers.Mappable = (*Mappable)(nil) @@ -17,9 +14,6 @@ var _ helpers.Mappable = (*Mappable)(nil) func (mappable *Mappable) ValidateBasic() error { return mappable.Asset.ValidateBasic() } -func (*Mappable) RegisterLegacyAminoCodec(legacyAmino *codec.LegacyAmino) { - codecUtilities.RegisterModuleConcrete(legacyAmino, Mappable{}) -} func Prototype() helpers.Mappable { return &Mappable{} diff --git a/x/assets/mappable/mappable_test.go b/x/assets/mappable/mappable_test.go index 803ce009d..0a24dcd42 100644 --- a/x/assets/mappable/mappable_test.go +++ b/x/assets/mappable/mappable_test.go @@ -7,6 +7,7 @@ import ( "reflect" "testing" + "github.com/AssetMantle/modules/helpers" baseData "github.com/AssetMantle/schema/data/base" documentsSchema "github.com/AssetMantle/schema/documents" baseDocuments "github.com/AssetMantle/schema/documents/base" @@ -16,9 +17,6 @@ import ( baseProperties "github.com/AssetMantle/schema/properties/base" "github.com/AssetMantle/schema/qualified" baseQualified "github.com/AssetMantle/schema/qualified/base" - "github.com/cosmos/cosmos-sdk/codec" - - "github.com/AssetMantle/modules/helpers" ) func createTestInput() (ids.ClassificationID, qualified.Immutables, qualified.Mutables, *Mappable) { @@ -65,29 +63,3 @@ func TestNewMappable(t *testing.T) { }) } } - -func Test_mappable_RegisterCodec(t *testing.T) { - _, _, _, testMappable := createTestInput() - type fields struct { - Document *Mappable - } - type args struct { - legacyAmino *codec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{testMappable}, args{legacyAmino: codec.NewLegacyAmino()}}, - {"+ve nil", fields{&Mappable{nil}}, args{legacyAmino: codec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - as := &Mappable{ - Asset: tt.fields.Document.Asset, - } - as.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} diff --git a/x/assets/parameters/burn_enabled/parameter.go b/x/assets/parameters/burn_enabled/parameter.go index 81cdc538d..2ff45e1d1 100644 --- a/x/assets/parameters/burn_enabled/parameter.go +++ b/x/assets/parameters/burn_enabled/parameter.go @@ -4,13 +4,12 @@ package burn_enabled import ( + baseHelpers "github.com/AssetMantle/modules/helpers/base" errorConstants "github.com/AssetMantle/modules/helpers/constants" baseData "github.com/AssetMantle/schema/data/base" baseParameters "github.com/AssetMantle/schema/parameters/base" "github.com/AssetMantle/schema/properties/base" constantProperties "github.com/AssetMantle/schema/properties/constants" - - baseHelpers "github.com/AssetMantle/modules/helpers/base" ) var ID = constantProperties.BurnEnabledProperty.GetKey() diff --git a/x/assets/parameters/mint_enabled/parameter.go b/x/assets/parameters/mint_enabled/parameter.go index 0c598171c..d4c8c4161 100644 --- a/x/assets/parameters/mint_enabled/parameter.go +++ b/x/assets/parameters/mint_enabled/parameter.go @@ -4,13 +4,12 @@ package mint_enabled import ( + baseHelpers "github.com/AssetMantle/modules/helpers/base" errorConstants "github.com/AssetMantle/modules/helpers/constants" baseData "github.com/AssetMantle/schema/data/base" baseParameters "github.com/AssetMantle/schema/parameters/base" "github.com/AssetMantle/schema/properties/base" constantProperties "github.com/AssetMantle/schema/properties/constants" - - baseHelpers "github.com/AssetMantle/modules/helpers/base" ) var ID = constantProperties.MintEnabledProperty.GetKey() diff --git a/x/assets/parameters/prototype.go b/x/assets/parameters/prototype.go index cb53e1c69..6d4977d0f 100644 --- a/x/assets/parameters/prototype.go +++ b/x/assets/parameters/prototype.go @@ -6,7 +6,6 @@ package parameters import ( "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" - "github.com/AssetMantle/modules/x/assets/constants" "github.com/AssetMantle/modules/x/assets/parameters/burn_enabled" "github.com/AssetMantle/modules/x/assets/parameters/mint_enabled" "github.com/AssetMantle/modules/x/assets/parameters/renumerate_enabled" @@ -15,5 +14,5 @@ import ( ) func Prototype() helpers.ParameterManager { - return baseHelpers.NewParameterManager(constants.ModuleName, burn_enabled.ValidatableParameter, mint_enabled.ValidatableParameter, renumerate_enabled.ValidatableParameter, unwrap_allowed_coins.ValidatableParameter, wrap_allowed_coins.ValidatableParameter) + return baseHelpers.NewParameterManager(burn_enabled.ValidatableParameter, mint_enabled.ValidatableParameter, renumerate_enabled.ValidatableParameter, unwrap_allowed_coins.ValidatableParameter, wrap_allowed_coins.ValidatableParameter) } diff --git a/x/assets/parameters/prototype_test.go b/x/assets/parameters/prototype_test.go index 22ec8ce67..68b0ca640 100644 --- a/x/assets/parameters/prototype_test.go +++ b/x/assets/parameters/prototype_test.go @@ -9,7 +9,6 @@ import ( "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" - "github.com/AssetMantle/modules/x/assets/constants" "github.com/AssetMantle/modules/x/assets/parameters/burn_enabled" "github.com/AssetMantle/modules/x/assets/parameters/mint_enabled" "github.com/AssetMantle/modules/x/assets/parameters/renumerate_enabled" @@ -21,7 +20,7 @@ func TestPrototype(t *testing.T) { want helpers.ParameterManager wantError error }{ - {"+ve", baseHelpers.NewParameterManager(constants.ModuleName, burn_enabled.ValidatableParameter, mint_enabled.ValidatableParameter, renumerate_enabled.ValidatableParameter), nil}, + {"+ve", baseHelpers.NewParameterManager(burn_enabled.ValidatableParameter, mint_enabled.ValidatableParameter, renumerate_enabled.ValidatableParameter), nil}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { diff --git a/x/assets/parameters/renumerate_enabled/parameter.go b/x/assets/parameters/renumerate_enabled/parameter.go index 103a4626b..69e478c9b 100644 --- a/x/assets/parameters/renumerate_enabled/parameter.go +++ b/x/assets/parameters/renumerate_enabled/parameter.go @@ -4,13 +4,12 @@ package renumerate_enabled import ( + baseHelpers "github.com/AssetMantle/modules/helpers/base" errorConstants "github.com/AssetMantle/modules/helpers/constants" baseData "github.com/AssetMantle/schema/data/base" baseParameters "github.com/AssetMantle/schema/parameters/base" "github.com/AssetMantle/schema/properties/base" constantProperties "github.com/AssetMantle/schema/properties/constants" - - baseHelpers "github.com/AssetMantle/modules/helpers/base" ) var ID = constantProperties.RenumerateEnabledProperty.GetKey() diff --git a/x/assets/parameters/unwrap_allowed_coins/parameter.go b/x/assets/parameters/unwrap_allowed_coins/parameter.go index f53b80124..183585bb4 100644 --- a/x/assets/parameters/unwrap_allowed_coins/parameter.go +++ b/x/assets/parameters/unwrap_allowed_coins/parameter.go @@ -4,6 +4,7 @@ package unwrap_allowed_coins import ( + baseHelpers "github.com/AssetMantle/modules/helpers/base" errorConstants "github.com/AssetMantle/modules/helpers/constants" "github.com/AssetMantle/schema/data" baseData "github.com/AssetMantle/schema/data/base" @@ -11,8 +12,6 @@ import ( "github.com/AssetMantle/schema/properties/base" constantProperties "github.com/AssetMantle/schema/properties/constants" sdkTypes "github.com/cosmos/cosmos-sdk/types" - - baseHelpers "github.com/AssetMantle/modules/helpers/base" ) var ID = constantProperties.UnwrapAllowedCoinsProperty.GetKey() diff --git a/x/assets/parameters/wrap_allowed_coins/parameter.go b/x/assets/parameters/wrap_allowed_coins/parameter.go index f66c48cab..fa4e8b2e0 100644 --- a/x/assets/parameters/wrap_allowed_coins/parameter.go +++ b/x/assets/parameters/wrap_allowed_coins/parameter.go @@ -4,6 +4,7 @@ package wrap_allowed_coins import ( + baseHelpers "github.com/AssetMantle/modules/helpers/base" errorConstants "github.com/AssetMantle/modules/helpers/constants" "github.com/AssetMantle/schema/data" baseData "github.com/AssetMantle/schema/data/base" @@ -11,8 +12,6 @@ import ( "github.com/AssetMantle/schema/properties/base" constantProperties "github.com/AssetMantle/schema/properties/constants" sdkTypes "github.com/cosmos/cosmos-sdk/types" - - baseHelpers "github.com/AssetMantle/modules/helpers/base" ) var ID = constantProperties.WrapAllowedCoinsProperty.GetKey() diff --git a/x/assets/queries/asset/query.go b/x/assets/queries/asset/query.go index 3f65928b2..23341e718 100644 --- a/x/assets/queries/asset/query.go +++ b/x/assets/queries/asset/query.go @@ -4,28 +4,17 @@ package asset import ( - "context" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "google.golang.org/grpc" - "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" helperConstants "github.com/AssetMantle/modules/helpers/constants" - "github.com/AssetMantle/modules/utilities/name" - "github.com/AssetMantle/modules/x/assets/constants" + "google.golang.org/grpc" ) -type dummy struct{} - var Query = baseHelpers.NewQuery( - name.GetPackageName(dummy{}), + _Query_serviceDesc.ServiceName, "", "", - constants.ModuleName, - requestPrototype, responsePrototype, keeperPrototype, @@ -33,9 +22,6 @@ var Query = baseHelpers.NewQuery( func(server grpc.ServiceRegistrar, QueryKeeper helpers.QueryKeeper) { RegisterQueryServer(server, QueryKeeper.(queryKeeper)) }, - func(clientContext client.Context, serveMux *runtime.ServeMux) error { - return RegisterQueryHandlerClient(context.Background(), serveMux, NewQueryClient(clientContext)) - }, helperConstants.AssetID, ) diff --git a/x/assets/queries/asset/query_keeper.go b/x/assets/queries/asset/query_keeper.go index 18f3585b0..0957d6e42 100644 --- a/x/assets/queries/asset/query_keeper.go +++ b/x/assets/queries/asset/query_keeper.go @@ -5,7 +5,6 @@ package asset import ( "context" - "github.com/AssetMantle/modules/helpers" ) @@ -16,7 +15,7 @@ type queryKeeper struct { var _ helpers.QueryKeeper = (*queryKeeper)(nil) func (queryKeeper queryKeeper) Enquire(context context.Context, queryRequest helpers.QueryRequest) (helpers.QueryResponse, error) { - queryResponse, err := queryKeeper.Handle(context, queryRequestFromInterface(queryRequest)) + queryResponse, err := queryKeeper.Handle(context, queryRequest.(*QueryRequest)) return queryResponse, err } func (queryKeeper queryKeeper) Handle(context context.Context, queryRequest *QueryRequest) (*QueryResponse, error) { diff --git a/x/assets/queries/asset/query_request.go b/x/assets/queries/asset/query_request.go index 25d623a5a..eb75859d9 100644 --- a/x/assets/queries/asset/query_request.go +++ b/x/assets/queries/asset/query_request.go @@ -11,7 +11,6 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/AssetMantle/modules/helpers" - "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/helpers/constants" "github.com/AssetMantle/modules/x/assets/key" ) @@ -49,28 +48,11 @@ func (*QueryRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.QueryRe return newQueryRequest(assetID.(ids.AssetID)), nil } } -func (queryRequest *QueryRequest) Encode() ([]byte, error) { - return base.CodecPrototype().MarshalJSON(queryRequest) -} - -func (queryRequest *QueryRequest) Decode(bytes []byte) (helpers.QueryRequest, error) { - if err := base.CodecPrototype().UnmarshalJSON(bytes, queryRequest); err != nil { - return nil, err - } - return queryRequest, nil -} func requestPrototype() helpers.QueryRequest { return &QueryRequest{} } -func queryRequestFromInterface(request helpers.QueryRequest) *QueryRequest { - switch value := request.(type) { - case *QueryRequest: - return value - default: - return &QueryRequest{} - } -} + func newQueryRequest(assetID ids.AssetID) helpers.QueryRequest { return &QueryRequest{Key: key.NewKey(assetID).(*key.Key)} } diff --git a/x/assets/queries/asset/query_request_test.go b/x/assets/queries/asset/query_request_test.go index 5a60dd3fe..9a2e71a77 100644 --- a/x/assets/queries/asset/query_request_test.go +++ b/x/assets/queries/asset/query_request_test.go @@ -16,7 +16,6 @@ import ( baseQualified "github.com/AssetMantle/schema/qualified/base" "github.com/cosmos/cosmos-sdk/client" "github.com/spf13/viper" - "github.com/stretchr/testify/require" "reflect" "testing" ) @@ -63,85 +62,13 @@ func Test_queryRequestFromInterface(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - if got := queryRequestFromInterface(tt.args.request); !reflect.DeepEqual(got, tt.want) { + if got := tt.args.request.(*QueryRequest); !reflect.DeepEqual(got, tt.want) { t.Errorf("queryRequestFromInterface() = %v, want %v", got, tt.want) } }) } } -func Test_queryRequest_Decode(t *testing.T) { - encodedQuery, err := base.CodecPrototype().GetLegacyAmino().MarshalJSON(newQueryRequest(testAssetID)) - require.NoError(t, err) - encodedQuery1, err := base.CodecPrototype().GetLegacyAmino().MarshalJSON(newQueryRequest(baseIDs.PrototypeAssetID().(*baseIDs.AssetID))) - require.NoError(t, err) - type fields struct { - Key *key.Key - } - type args struct { - bytes []byte - } - tests := []struct { - name string - fields fields - args args - want helpers.QueryRequest - wantErr bool - }{ - {"+ve", fields{testKey}, args{encodedQuery}, newQueryRequest(testAssetID), false}, - {"+ve", fields{key.NewKey(baseIDs.PrototypeAssetID()).(*key.Key)}, args{encodedQuery1}, newQueryRequest(baseIDs.PrototypeAssetID().(*baseIDs.AssetID)), false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - queryRequest := &QueryRequest{ - Key: tt.fields.Key, - } - got, err := queryRequest.Decode(tt.args.bytes) - if (err != nil) != tt.wantErr { - t.Errorf("Decode() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("Decode() got = %v, want %v", got, tt.want) - } - }) - } -} - -func Test_queryRequest_Encode(t *testing.T) { - encodedQuery, err := base.CodecPrototype().GetLegacyAmino().MarshalJSON(newQueryRequest(testAssetID)) - require.NoError(t, err) - encodedQuery1, err := base.CodecPrototype().GetLegacyAmino().MarshalJSON(newQueryRequest(baseIDs.PrototypeAssetID().(*baseIDs.AssetID))) - require.NoError(t, err) - type fields struct { - Key *key.Key - } - tests := []struct { - name string - fields fields - want []byte - wantErr bool - }{ - {"+ve", fields{testKey}, encodedQuery, false}, - {"+ve with nil", fields{key.NewKey(baseIDs.PrototypeAssetID().(*baseIDs.AssetID)).(*key.Key)}, encodedQuery1, false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - queryRequest := &QueryRequest{ - Key: tt.fields.Key, - } - got, err := queryRequest.Encode() - if (err != nil) != tt.wantErr { - t.Errorf("Encode() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("Encode() got = %v, want %v", got, tt.want) - } - }) - } -} - func Test_queryRequest_FromCLI(t *testing.T) { cliCommand := base.NewCLICommand("", "", "", []helpers.CLIFlag{constants.AssetID}) diff --git a/x/assets/queries/asset/service.pb.go b/x/assets/queries/asset/service.pb.go index c1c94f135..c08f6476c 100644 --- a/x/assets/queries/asset/service.pb.go +++ b/x/assets/queries/asset/service.pb.go @@ -8,7 +8,6 @@ import ( fmt "fmt" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" - _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -31,30 +30,27 @@ func init() { } var fileDescriptor_a9cb246b41332473 = []byte{ - // 356 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x92, 0x31, 0x4b, 0xc3, 0x40, - 0x18, 0x86, 0x9b, 0x80, 0x1d, 0x82, 0x53, 0xc6, 0x50, 0x6e, 0x10, 0x27, 0x87, 0x3b, 0xaa, 0x28, - 0xf5, 0x06, 0x25, 0x5d, 0x74, 0x09, 0xb4, 0xba, 0x04, 0x09, 0xc8, 0xb5, 0xfd, 0xa8, 0x81, 0x34, - 0xd7, 0xe6, 0x2e, 0xa5, 0xae, 0xfe, 0x02, 0xc1, 0x7f, 0xa0, 0x9b, 0xe0, 0xff, 0x10, 0xa7, 0x82, - 0x8b, 0x8b, 0x20, 0xa9, 0x93, 0xbf, 0x42, 0x92, 0xef, 0x86, 0x76, 0x6b, 0x3b, 0xbe, 0x97, 0xf7, - 0xc9, 0xfb, 0xbd, 0x77, 0x9f, 0xd3, 0xf2, 0x95, 0x02, 0x1d, 0x88, 0x54, 0x27, 0xc0, 0x46, 0x72, - 0x90, 0x27, 0xa0, 0xd8, 0x8c, 0x89, 0xf2, 0x54, 0xb1, 0x49, 0x0e, 0x59, 0x0c, 0x0a, 0x25, 0x53, - 0x90, 0x4d, 0xe3, 0x3e, 0xd0, 0x71, 0x26, 0xb5, 0x74, 0x0f, 0x96, 0x48, 0x6a, 0x48, 0x3a, 0xa3, - 0x48, 0x52, 0x43, 0xa2, 0xf4, 0xce, 0x36, 0x48, 0x29, 0xd5, 0xfd, 0x6d, 0x06, 0x93, 0x1c, 0x94, - 0xc6, 0x2c, 0xef, 0x7c, 0x0b, 0x5e, 0x8d, 0x65, 0xaa, 0xcc, 0xb0, 0x5e, 0x63, 0x28, 0xe5, 0x30, - 0x01, 0x26, 0xc6, 0x31, 0x13, 0x69, 0x2a, 0xb5, 0xd0, 0xb1, 0x4c, 0x15, 0x7e, 0x3d, 0x7c, 0xb3, - 0x9c, 0x9d, 0x6e, 0x89, 0xb9, 0x2f, 0x96, 0x53, 0xbf, 0x14, 0xe9, 0x20, 0x01, 0xb7, 0x45, 0xd7, - 0x2f, 0x48, 0x2b, 0xfa, 0x0a, 0x67, 0xf6, 0x4e, 0xb7, 0x20, 0x71, 0xda, 0xbd, 0xfd, 0x87, 0xcf, - 0xdf, 0x27, 0x9b, 0xb8, 0x0d, 0x36, 0xc2, 0xb2, 0xa6, 0xe2, 0xb4, 0xd9, 0x03, 0x2d, 0x9a, 0x28, - 0xdb, 0xdf, 0xf6, 0x7b, 0x41, 0xac, 0x79, 0x41, 0xac, 0x9f, 0x82, 0x58, 0x8f, 0x0b, 0x52, 0x9b, - 0x2f, 0x48, 0xed, 0x6b, 0x41, 0x6a, 0x0e, 0xed, 0xcb, 0xd1, 0x06, 0xf1, 0xed, 0xdd, 0x6b, 0x7c, - 0xd4, 0x4e, 0x79, 0x11, 0x1d, 0xeb, 0xe6, 0x78, 0x18, 0xeb, 0xbb, 0xbc, 0x57, 0xfe, 0x86, 0xad, - 0x7f, 0xe9, 0xcf, 0x76, 0xdd, 0x0f, 0x42, 0xbf, 0xeb, 0xbf, 0xda, 0x2b, 0x6b, 0x11, 0x98, 0xf0, - 0x10, 0x47, 0x52, 0x55, 0xdb, 0x32, 0xbc, 0x92, 0x1f, 0x2b, 0xe6, 0xc8, 0x98, 0xa3, 0x30, 0x42, - 0x73, 0x64, 0xcc, 0x28, 0x0b, 0xfb, 0x64, 0x7d, 0x73, 0x74, 0xd1, 0x69, 0x07, 0xa0, 0xc5, 0x40, - 0x68, 0xf1, 0x67, 0x2f, 0x17, 0xe1, 0xdc, 0x90, 0x9c, 0x87, 0x9c, 0x23, 0xcb, 0xb9, 0x81, 0xcd, - 0x41, 0xaf, 0x5e, 0xad, 0xc5, 0xd1, 0x7f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x6c, 0x4f, 0x87, 0x0e, - 0x1d, 0x03, 0x00, 0x00, + // 308 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xb2, 0x70, 0x2c, 0x2e, 0x4e, + 0x2d, 0xf1, 0x4d, 0xcc, 0x2b, 0xc9, 0x49, 0xd5, 0xcf, 0xcd, 0x4f, 0x29, 0xcd, 0x49, 0x2d, 0xd6, + 0xaf, 0xd0, 0x4f, 0x04, 0x89, 0x16, 0xeb, 0x17, 0x96, 0xa6, 0x16, 0x65, 0xa6, 0x16, 0x43, 0xb8, + 0xfa, 0xc5, 0xa9, 0x45, 0x65, 0x99, 0xc9, 0xa9, 0x7a, 0x05, 0x45, 0xf9, 0x25, 0xf9, 0x42, 0x5a, + 0x48, 0x3a, 0xf5, 0xa0, 0x3a, 0xf5, 0x2a, 0xf4, 0x20, 0x3a, 0xf5, 0xa0, 0x3a, 0x21, 0x5c, 0x29, + 0x3b, 0x12, 0x6c, 0x01, 0xf1, 0x2a, 0xe3, 0x8b, 0x52, 0x0b, 0x4b, 0x53, 0x8b, 0x4b, 0x20, 0x76, + 0x49, 0xd9, 0x93, 0xa1, 0xbf, 0xb8, 0x20, 0x3f, 0xaf, 0x18, 0xea, 0x58, 0xa3, 0x0e, 0x46, 0x2e, + 0xd6, 0x40, 0x90, 0x84, 0x50, 0x3d, 0x17, 0x9b, 0x47, 0x62, 0x5e, 0x4a, 0x4e, 0xaa, 0x90, 0x85, + 0x1e, 0xf1, 0x3e, 0xd0, 0x03, 0x6b, 0x0e, 0x82, 0x38, 0x4a, 0xca, 0x92, 0x0c, 0x9d, 0x10, 0xe7, + 0x28, 0x31, 0x38, 0xdd, 0x65, 0x3a, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, + 0xe4, 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, 0x06, 0x2e, + 0xbd, 0xe4, 0xfc, 0x5c, 0x12, 0x8c, 0x76, 0xe2, 0x09, 0x86, 0xc4, 0x48, 0x00, 0xc8, 0x8f, 0x01, + 0x8c, 0x51, 0xa6, 0xe9, 0x99, 0x25, 0x19, 0xa5, 0x49, 0x20, 0x63, 0xf4, 0x89, 0x0f, 0xb1, 0x45, + 0x4c, 0x6c, 0x8e, 0xbe, 0x11, 0x8e, 0x81, 0x8e, 0xab, 0x98, 0x50, 0xe2, 0xd4, 0x17, 0x6a, 0x79, + 0x04, 0xc4, 0x49, 0xc5, 0x60, 0x9f, 0x80, 0x2c, 0x07, 0x73, 0x4f, 0xa1, 0x28, 0x8e, 0x81, 0x2a, + 0x8e, 0x89, 0x88, 0x81, 0x28, 0x8e, 0x81, 0x2a, 0x86, 0x70, 0x1f, 0x31, 0x99, 0x11, 0xaf, 0x38, + 0xc6, 0x3d, 0xc0, 0xc9, 0x37, 0xb5, 0x24, 0x31, 0x25, 0xb1, 0x24, 0xf1, 0x15, 0x13, 0xb2, 0x47, + 0xac, 0xac, 0xa0, 0x3a, 0xad, 0xac, 0x22, 0xac, 0xac, 0x20, 0x7a, 0xad, 0xac, 0xa0, 0x9a, 0xa1, + 0x02, 0x49, 0x6c, 0xe0, 0x18, 0x37, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0x7b, 0x74, 0x5c, 0xec, + 0xda, 0x02, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/assets/queries/asset/service.pb.gw.go b/x/assets/queries/asset/service.pb.gw.go deleted file mode 100644 index c2a0630cd..000000000 --- a/x/assets/queries/asset/service.pb.gw.go +++ /dev/null @@ -1,171 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: AssetMantle/modules/x/assets/queries/asset/service.proto - -/* -Package asset is a reverse proxy. - -It translates gRPC into RESTful JSON APIs. -*/ -package asset - -import ( - "context" - "io" - "net/http" - - "github.com/golang/protobuf/descriptor" - "github.com/golang/protobuf/proto" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/grpc-ecosystem/grpc-gateway/utilities" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/status" -) - -// Suppress "imported and not used" errors -var _ codes.Code -var _ io.Reader -var _ status.Status -var _ = runtime.String -var _ = utilities.NewDoubleArray -var _ = descriptor.ForMessage -var _ = metadata.Join - -var ( - filter_Query_Handle_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - -func request_Query_Handle_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryRequest - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.Handle(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_Handle_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryRequest - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.Handle(ctx, &protoReq) - return msg, metadata, err - -} - -// RegisterQueryHandlerServer registers the http handlers for service Query to "mux". -// UnaryRPC :call QueryServer directly. -// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. -func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { - - mux.Handle("GET", pattern_Query_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Query_Handle_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but -// automatically dials to "endpoint" and closes the connection when "ctx" gets done. -func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.Dial(endpoint, opts...) - if err != nil { - return err - } - defer func() { - if err != nil { - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - return - } - go func() { - <-ctx.Done() - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - }() - }() - - return RegisterQueryHandler(ctx, mux, conn) -} - -// RegisterQueryHandler registers the http handlers for service Query to "mux". -// The handlers forward requests to the grpc endpoint over "conn". -func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { - return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn)) -} - -// RegisterQueryHandlerClient registers the http handlers for service Query -// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient". -// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient" -// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "QueryClient" to call the correct interceptors. -func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { - - mux.Handle("GET", pattern_Query_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Query_Handle_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -var ( - pattern_Query_Handle_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"mantle", "assets", "v1beta1", "asset"}, "", runtime.AssumeColonVerbOpt(false))) -) - -var ( - forward_Query_Handle_0 = runtime.ForwardResponseMessage -) diff --git a/x/assets/queries/assets/query.go b/x/assets/queries/assets/query.go index caf0f1971..0f4b6787f 100644 --- a/x/assets/queries/assets/query.go +++ b/x/assets/queries/assets/query.go @@ -4,28 +4,17 @@ package assets import ( - "context" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "google.golang.org/grpc" - "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" helperConstants "github.com/AssetMantle/modules/helpers/constants" - "github.com/AssetMantle/modules/utilities/name" - "github.com/AssetMantle/modules/x/assets/constants" + "google.golang.org/grpc" ) -type dummy struct{} - var Query = baseHelpers.NewQuery( - name.GetPackageName(dummy{}), + _Query_serviceDesc.ServiceName, "", "", - constants.ModuleName, - requestPrototype, responsePrototype, keeperPrototype, @@ -33,9 +22,6 @@ var Query = baseHelpers.NewQuery( func(server grpc.ServiceRegistrar, QueryKeeper helpers.QueryKeeper) { RegisterQueryServer(server, QueryKeeper.(queryKeeper)) }, - func(clientContext client.Context, serveMux *runtime.ServeMux) error { - return RegisterQueryHandlerClient(context.Background(), serveMux, NewQueryClient(clientContext)) - }, helperConstants.AssetID, helperConstants.Limit, diff --git a/x/assets/queries/assets/query_keeper.go b/x/assets/queries/assets/query_keeper.go index 67e954caa..455af4cde 100644 --- a/x/assets/queries/assets/query_keeper.go +++ b/x/assets/queries/assets/query_keeper.go @@ -5,7 +5,6 @@ package assets import ( "context" - "github.com/AssetMantle/modules/helpers" ) @@ -16,7 +15,7 @@ type queryKeeper struct { var _ helpers.QueryKeeper = (*queryKeeper)(nil) func (queryKeeper queryKeeper) Enquire(context context.Context, queryRequest helpers.QueryRequest) (helpers.QueryResponse, error) { - queryResponse, err := queryKeeper.Handle(context, queryRequestFromInterface(queryRequest)) + queryResponse, err := queryKeeper.Handle(context, queryRequest.(*QueryRequest)) return queryResponse, err } func (queryKeeper queryKeeper) Handle(context context.Context, queryRequest *QueryRequest) (*QueryResponse, error) { diff --git a/x/assets/queries/assets/query_request.go b/x/assets/queries/assets/query_request.go index 27d80e3bb..02858c50b 100644 --- a/x/assets/queries/assets/query_request.go +++ b/x/assets/queries/assets/query_request.go @@ -13,7 +13,6 @@ import ( "github.com/cosmos/cosmos-sdk/types/query" "github.com/AssetMantle/modules/helpers" - "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/helpers/constants" "github.com/AssetMantle/modules/x/assets/key" ) @@ -68,28 +67,11 @@ func (*QueryRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.QueryRe return newQueryRequest(assetID.(ids.AssetID), int32(limit)), nil } -func (queryRequest *QueryRequest) Encode() ([]byte, error) { - return base.CodecPrototype().MarshalJSON(queryRequest) -} - -func (queryRequest *QueryRequest) Decode(bytes []byte) (helpers.QueryRequest, error) { - if err := base.CodecPrototype().UnmarshalJSON(bytes, queryRequest); err != nil { - return nil, err - } - return queryRequest, nil -} func requestPrototype() helpers.QueryRequest { return &QueryRequest{} } -func queryRequestFromInterface(request helpers.QueryRequest) *QueryRequest { - switch value := request.(type) { - case *QueryRequest: - return value - default: - return &QueryRequest{} - } -} + func newQueryRequest(assetID ids.AssetID, limit int32) helpers.QueryRequest { return &QueryRequest{Key: key.NewKey(assetID).(*key.Key), Limit: limit} } diff --git a/x/assets/queries/assets/service.pb.go b/x/assets/queries/assets/service.pb.go index 1b0dbe0d2..79e4091f3 100644 --- a/x/assets/queries/assets/service.pb.go +++ b/x/assets/queries/assets/service.pb.go @@ -8,7 +8,6 @@ import ( fmt "fmt" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" - _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -31,30 +30,27 @@ func init() { } var fileDescriptor_c8b1b0efe74062b4 = []byte{ - // 356 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x92, 0x31, 0x4b, 0xc3, 0x40, - 0x18, 0x86, 0x9b, 0x80, 0x1d, 0x82, 0x53, 0xc6, 0xa0, 0x11, 0x04, 0x27, 0xe1, 0xce, 0x2a, 0x28, - 0xbd, 0x45, 0xd3, 0x45, 0x97, 0x40, 0xab, 0x4b, 0x90, 0x80, 0x5c, 0xdb, 0x8f, 0x1a, 0x48, 0x72, - 0x6d, 0xee, 0x52, 0xea, 0xea, 0x2f, 0x10, 0xfc, 0x07, 0x0e, 0x0e, 0x4e, 0xfe, 0x0c, 0x71, 0x2a, - 0xb8, 0x38, 0x4a, 0xe2, 0xe4, 0xaf, 0x90, 0xf4, 0xbe, 0x42, 0x3b, 0xa6, 0xe3, 0x7b, 0xf7, 0x3e, - 0xf9, 0xde, 0xf7, 0xf2, 0x59, 0x6d, 0x4f, 0x4a, 0x50, 0x3e, 0x4f, 0x55, 0x0c, 0x34, 0x11, 0xc3, - 0x3c, 0x06, 0x49, 0x67, 0x94, 0x57, 0xa7, 0x92, 0x4e, 0x72, 0xc8, 0x22, 0x90, 0x4b, 0x29, 0x21, - 0x9b, 0x46, 0x03, 0x20, 0xe3, 0x4c, 0x28, 0x61, 0x1f, 0xae, 0xa0, 0x04, 0x51, 0x32, 0x23, 0xda, - 0x4b, 0x10, 0x45, 0xe9, 0x9c, 0xd7, 0x99, 0x53, 0xc9, 0x87, 0xbb, 0x0c, 0x26, 0x39, 0x48, 0xa5, - 0xa7, 0x39, 0x17, 0x9b, 0x7c, 0x40, 0x8e, 0x45, 0x2a, 0x31, 0xaf, 0xb3, 0x33, 0x12, 0x62, 0x14, - 0x03, 0xe5, 0xe3, 0x88, 0xf2, 0x34, 0x15, 0x8a, 0xab, 0x48, 0xa4, 0x52, 0xdf, 0x1e, 0xbf, 0x1b, - 0xd6, 0x56, 0xaf, 0xc2, 0xec, 0x57, 0xc3, 0x6a, 0x5e, 0xf1, 0x74, 0x18, 0x83, 0xdd, 0x26, 0x35, - 0x3a, 0x92, 0x05, 0x7e, 0xad, 0x53, 0x3b, 0x6c, 0x13, 0x54, 0xe7, 0xdd, 0x3f, 0x78, 0xfc, 0xfa, - 0x7d, 0x36, 0xf7, 0xec, 0x5d, 0x9a, 0xe8, 0xbe, 0x58, 0x6b, 0xda, 0xea, 0x83, 0xe2, 0x2d, 0x94, - 0x9d, 0xd2, 0xfc, 0x28, 0x5c, 0x63, 0x5e, 0xb8, 0xc6, 0x4f, 0xe1, 0x1a, 0x4f, 0xa5, 0xdb, 0x98, - 0x97, 0x6e, 0xe3, 0xbb, 0x74, 0x1b, 0x16, 0x1d, 0x88, 0xa4, 0x4e, 0x80, 0xce, 0xf6, 0x8d, 0xfe, - 0xb7, 0xdd, 0xea, 0x31, 0xba, 0xc6, 0xed, 0xe9, 0x28, 0x52, 0xf7, 0x79, 0x9f, 0x0c, 0x44, 0x42, - 0x6b, 0xbc, 0xfc, 0x8b, 0xd9, 0xf4, 0xfc, 0xc0, 0xeb, 0x79, 0x6f, 0xe6, 0xda, 0x7a, 0xf8, 0x38, - 0x3e, 0xd0, 0xa1, 0x74, 0xe1, 0x6a, 0xbc, 0x96, 0x9f, 0x6b, 0xee, 0x10, 0xdd, 0x61, 0x10, 0xea, - 0xeb, 0x10, 0xdd, 0x28, 0x0b, 0xf3, 0xac, 0x86, 0x3b, 0xbc, 0xec, 0x76, 0x7c, 0x50, 0x7c, 0xc8, - 0x15, 0xff, 0x33, 0x8f, 0x56, 0x48, 0xc6, 0x10, 0x65, 0x2c, 0x60, 0x4c, 0xbb, 0x19, 0x43, 0x7a, - 0x79, 0xd0, 0x6f, 0x2e, 0xf6, 0xe3, 0xe4, 0x3f, 0x00, 0x00, 0xff, 0xff, 0x56, 0x5a, 0xf8, 0x16, - 0x2a, 0x03, 0x00, 0x00, + // 310 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xb2, 0x74, 0x2c, 0x2e, 0x4e, + 0x2d, 0xf1, 0x4d, 0xcc, 0x2b, 0xc9, 0x49, 0xd5, 0xcf, 0xcd, 0x4f, 0x29, 0xcd, 0x49, 0x2d, 0xd6, + 0xaf, 0xd0, 0x4f, 0x04, 0x89, 0x16, 0xeb, 0x17, 0x96, 0xa6, 0x16, 0x65, 0xa6, 0x16, 0xc3, 0xb8, + 0xc5, 0xa9, 0x45, 0x65, 0x99, 0xc9, 0xa9, 0x7a, 0x05, 0x45, 0xf9, 0x25, 0xf9, 0x42, 0xda, 0x48, + 0x5a, 0xf5, 0xa0, 0x5a, 0xf5, 0x2a, 0xf4, 0x20, 0x6a, 0xf5, 0xa0, 0x5a, 0xa1, 0x5c, 0x29, 0x7b, + 0x52, 0xec, 0x01, 0x71, 0x2b, 0xe3, 0x8b, 0x52, 0x0b, 0x4b, 0x53, 0x8b, 0x4b, 0x20, 0xb6, 0x49, + 0x39, 0x90, 0x63, 0x40, 0x71, 0x41, 0x7e, 0x5e, 0x31, 0xd4, 0xbd, 0x46, 0xdd, 0x8c, 0x5c, 0xac, + 0x81, 0x20, 0x09, 0xa1, 0x46, 0x46, 0x2e, 0x36, 0x8f, 0xc4, 0xbc, 0x94, 0x9c, 0x54, 0x21, 0x4b, + 0x3d, 0x12, 0x7c, 0xa1, 0x07, 0xd6, 0x1e, 0x04, 0x71, 0x97, 0x94, 0x15, 0x39, 0x5a, 0x21, 0x2e, + 0x52, 0x62, 0x70, 0x7a, 0xcc, 0x74, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, + 0xc9, 0x31, 0x4e, 0x78, 0x2c, 0xc7, 0x70, 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, 0x0c, 0x5c, + 0xfa, 0xc9, 0xf9, 0xb9, 0xa4, 0x98, 0xed, 0xc4, 0x13, 0x0c, 0x89, 0x98, 0x00, 0x90, 0x3f, 0x03, + 0x18, 0xa3, 0xcc, 0xd2, 0x33, 0x4b, 0x32, 0x4a, 0x93, 0xf4, 0x92, 0xf3, 0x73, 0xf5, 0x49, 0x08, + 0xb6, 0x45, 0x4c, 0x6c, 0x8e, 0xbe, 0x11, 0x8e, 0x81, 0x8e, 0xab, 0x98, 0x50, 0xe2, 0xd6, 0x17, + 0x6a, 0x7d, 0x04, 0xc4, 0x51, 0x10, 0xbf, 0x80, 0xac, 0x87, 0x70, 0x4f, 0xa1, 0xa8, 0x8e, 0x81, + 0xaa, 0x8e, 0x89, 0x88, 0x81, 0x48, 0xc7, 0x40, 0x55, 0x43, 0xb9, 0x8f, 0x98, 0xcc, 0x49, 0x50, + 0x1d, 0xe3, 0x1e, 0xe0, 0xe4, 0x9b, 0x5a, 0x92, 0x98, 0x92, 0x58, 0x92, 0xf8, 0x8a, 0xc9, 0x00, + 0x49, 0xa7, 0x95, 0x15, 0x54, 0xab, 0x95, 0x55, 0x84, 0x95, 0x15, 0x44, 0xb5, 0x95, 0x15, 0x54, + 0x37, 0x4c, 0x20, 0x89, 0x0d, 0x1c, 0xf5, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0xba, 0x20, + 0x71, 0x6d, 0xe7, 0x02, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/assets/queries/assets/service.pb.gw.go b/x/assets/queries/assets/service.pb.gw.go deleted file mode 100644 index fcf7054d6..000000000 --- a/x/assets/queries/assets/service.pb.gw.go +++ /dev/null @@ -1,171 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: AssetMantle/modules/x/assets/queries/assets/service.proto - -/* -Package assets is a reverse proxy. - -It translates gRPC into RESTful JSON APIs. -*/ -package assets - -import ( - "context" - "io" - "net/http" - - "github.com/golang/protobuf/descriptor" - "github.com/golang/protobuf/proto" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/grpc-ecosystem/grpc-gateway/utilities" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/status" -) - -// Suppress "imported and not used" errors -var _ codes.Code -var _ io.Reader -var _ status.Status -var _ = runtime.String -var _ = utilities.NewDoubleArray -var _ = descriptor.ForMessage -var _ = metadata.Join - -var ( - filter_Query_Handle_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - -func request_Query_Handle_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryRequest - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.Handle(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_Handle_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryRequest - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.Handle(ctx, &protoReq) - return msg, metadata, err - -} - -// RegisterQueryHandlerServer registers the http handlers for service Query to "mux". -// UnaryRPC :call QueryServer directly. -// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. -func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { - - mux.Handle("GET", pattern_Query_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Query_Handle_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but -// automatically dials to "endpoint" and closes the connection when "ctx" gets done. -func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.Dial(endpoint, opts...) - if err != nil { - return err - } - defer func() { - if err != nil { - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - return - } - go func() { - <-ctx.Done() - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - }() - }() - - return RegisterQueryHandler(ctx, mux, conn) -} - -// RegisterQueryHandler registers the http handlers for service Query to "mux". -// The handlers forward requests to the grpc endpoint over "conn". -func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { - return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn)) -} - -// RegisterQueryHandlerClient registers the http handlers for service Query -// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient". -// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient" -// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "QueryClient" to call the correct interceptors. -func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { - - mux.Handle("GET", pattern_Query_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Query_Handle_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -var ( - pattern_Query_Handle_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 1}, []string{"mantle", "assets", "v1beta1"}, "", runtime.AssumeColonVerbOpt(false))) -) - -var ( - forward_Query_Handle_0 = runtime.ForwardResponseMessage -) diff --git a/x/assets/queries/parameters/query.go b/x/assets/queries/parameters/query.go new file mode 100644 index 000000000..cfe5be8fe --- /dev/null +++ b/x/assets/queries/parameters/query.go @@ -0,0 +1,21 @@ +package parameters + +import ( + "github.com/AssetMantle/modules/helpers" + baseHelpers "github.com/AssetMantle/modules/helpers/base" + "google.golang.org/grpc" +) + +var Query = baseHelpers.NewQuery( + _Query_serviceDesc.ServiceName, + "", + "", + + requestPrototype, + responsePrototype, + keeperPrototype, + + func(server grpc.ServiceRegistrar, QueryKeeper helpers.QueryKeeper) { + RegisterQueryServer(server, QueryKeeper.(queryKeeper)) + }, +) diff --git a/x/assets/queries/parameters/query_keeper.go b/x/assets/queries/parameters/query_keeper.go new file mode 100644 index 000000000..5ff196b53 --- /dev/null +++ b/x/assets/queries/parameters/query_keeper.go @@ -0,0 +1,31 @@ +package parameters + +import ( + "context" + "github.com/AssetMantle/modules/helpers" +) + +type queryKeeper struct { + parameterManager helpers.ParameterManager +} + +var _ helpers.QueryKeeper = (*queryKeeper)(nil) + +func (queryKeeper queryKeeper) Enquire(context context.Context, queryRequest helpers.QueryRequest) (helpers.QueryResponse, error) { + queryResponse, err := queryKeeper.Handle(context, queryRequest.(*QueryRequest)) + return queryResponse, err +} +func (queryKeeper queryKeeper) Handle(context context.Context, queryRequest *QueryRequest) (*QueryResponse, error) { + if err := queryRequest.Validate(); err != nil { + return nil, err + } + return newQueryResponse(queryKeeper.parameterManager.Fetch(context).Get()), nil +} +func (queryKeeper queryKeeper) Initialize(_ helpers.Mapper, parameterManager helpers.ParameterManager, _ []interface{}) helpers.Keeper { + queryKeeper.parameterManager = parameterManager + return queryKeeper +} + +func keeperPrototype() helpers.QueryKeeper { + return queryKeeper{} +} diff --git a/x/assets/queries/parameters/query_request.go b/x/assets/queries/parameters/query_request.go new file mode 100644 index 000000000..9f99e7a01 --- /dev/null +++ b/x/assets/queries/parameters/query_request.go @@ -0,0 +1,25 @@ +package parameters + +import ( + "github.com/AssetMantle/modules/helpers" + "github.com/cosmos/cosmos-sdk/client" + "net/http" +) + +var _ helpers.QueryRequest = (*QueryRequest)(nil) + +func (queryRequest *QueryRequest) Validate() error { + return nil +} + +func (queryRequest *QueryRequest) FromCLI(_ helpers.CLICommand, _ client.Context) (helpers.QueryRequest, error) { + return requestPrototype(), nil +} + +func (queryRequest *QueryRequest) FromHTTPRequest(_ *http.Request) (helpers.QueryRequest, error) { + return requestPrototype(), nil +} + +func requestPrototype() helpers.QueryRequest { + return &QueryRequest{} +} diff --git a/x/assets/queries/parameters/query_request.pb.go b/x/assets/queries/parameters/query_request.pb.go new file mode 100644 index 000000000..b4642b192 --- /dev/null +++ b/x/assets/queries/parameters/query_request.pb.go @@ -0,0 +1,272 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: AssetMantle/modules/x/assets/queries/parameters/query_request.proto + +package parameters + +import ( + fmt "fmt" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type QueryRequest struct { +} + +func (m *QueryRequest) Reset() { *m = QueryRequest{} } +func (m *QueryRequest) String() string { return proto.CompactTextString(m) } +func (*QueryRequest) ProtoMessage() {} +func (*QueryRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_e5bc33246fe70812, []int{0} +} +func (m *QueryRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryRequest.Merge(m, src) +} +func (m *QueryRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryRequest proto.InternalMessageInfo + +func init() { + proto.RegisterType((*QueryRequest)(nil), "AssetMantle.modules.x.assets.queries.parameters.QueryRequest") +} + +func init() { + proto.RegisterFile("AssetMantle/modules/x/assets/queries/parameters/query_request.proto", fileDescriptor_e5bc33246fe70812) +} + +var fileDescriptor_e5bc33246fe70812 = []byte{ + // 271 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x72, 0x76, 0x2c, 0x2e, 0x4e, + 0x2d, 0xf1, 0x4d, 0xcc, 0x2b, 0xc9, 0x49, 0xd5, 0xcf, 0xcd, 0x4f, 0x29, 0xcd, 0x49, 0x2d, 0xd6, + 0xaf, 0xd0, 0x4f, 0x04, 0x89, 0x16, 0xeb, 0x17, 0x96, 0xa6, 0x16, 0x65, 0xa6, 0x16, 0xeb, 0x17, + 0x24, 0x16, 0x25, 0xe6, 0xa6, 0x96, 0xa4, 0x16, 0x41, 0x84, 0x2a, 0xe3, 0x8b, 0x52, 0x0b, 0x4b, + 0x53, 0x8b, 0x4b, 0xf4, 0x0a, 0x8a, 0xf2, 0x4b, 0xf2, 0x85, 0xf4, 0x91, 0x0c, 0xd1, 0x83, 0x1a, + 0xa2, 0x57, 0xa1, 0x07, 0x31, 0x44, 0x0f, 0x6a, 0x88, 0x1e, 0xc2, 0x10, 0x25, 0x3e, 0x2e, 0x9e, + 0x40, 0x90, 0x39, 0x41, 0x10, 0x63, 0x9c, 0x1a, 0x98, 0x4f, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, + 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1, + 0x58, 0x8e, 0x81, 0xcb, 0x38, 0x39, 0x3f, 0x57, 0x8f, 0x44, 0xf3, 0x9d, 0x04, 0x91, 0x4d, 0x0f, + 0x00, 0xb9, 0x31, 0x80, 0x31, 0xca, 0x2a, 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, + 0x57, 0x9f, 0x44, 0x5f, 0x2f, 0x62, 0x62, 0x73, 0xf4, 0x8d, 0x70, 0x0c, 0x0c, 0x58, 0xc5, 0x84, + 0xe2, 0x57, 0x5f, 0xa8, 0x5b, 0x22, 0x20, 0x2e, 0x2c, 0xd6, 0x0b, 0x84, 0xba, 0x25, 0x00, 0xae, + 0xf5, 0x14, 0x8a, 0x8e, 0x18, 0xa8, 0x8e, 0x98, 0x88, 0x18, 0x88, 0x8e, 0x18, 0xa8, 0x8e, 0x18, + 0x84, 0x8e, 0x47, 0x4c, 0xd6, 0x24, 0xea, 0x88, 0x71, 0x0f, 0x70, 0xf2, 0x4d, 0x2d, 0x49, 0x4c, + 0x49, 0x2c, 0x49, 0x7c, 0xc5, 0x64, 0x82, 0xa4, 0xdb, 0xca, 0x0a, 0xaa, 0xdd, 0xca, 0x2a, 0xc2, + 0xca, 0x0a, 0x62, 0x80, 0x95, 0x15, 0xd4, 0x04, 0x2b, 0x2b, 0x84, 0x11, 0x49, 0x6c, 0xe0, 0xa8, + 0x34, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0x28, 0xa2, 0x12, 0x1e, 0x11, 0x02, 0x00, 0x00, +} + +func (m *QueryRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func encodeVarintQueryRequest(dAtA []byte, offset int, v uint64) int { + offset -= sovQueryRequest(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *QueryRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func sovQueryRequest(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQueryRequest(x uint64) (n int) { + return sovQueryRequest(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QueryRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQueryRequest + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQueryRequest(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQueryRequest + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipQueryRequest(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQueryRequest + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQueryRequest + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQueryRequest + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthQueryRequest + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupQueryRequest + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthQueryRequest + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthQueryRequest = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowQueryRequest = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupQueryRequest = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/assets/queries/parameters/query_response.go b/x/assets/queries/parameters/query_response.go new file mode 100644 index 000000000..4d34b8543 --- /dev/null +++ b/x/assets/queries/parameters/query_response.go @@ -0,0 +1,29 @@ +package parameters + +import ( + "github.com/AssetMantle/modules/helpers" + "github.com/AssetMantle/modules/helpers/base" + "github.com/AssetMantle/schema/lists" + baseLists "github.com/AssetMantle/schema/lists/base" +) + +var _ helpers.QueryResponse = (*QueryResponse)(nil) + +func (queryResponse *QueryResponse) Encode() ([]byte, error) { + return base.CodecPrototype().MarshalJSON(queryResponse) +} +func (queryResponse *QueryResponse) Decode(bytes []byte) (helpers.QueryResponse, error) { + if err := base.CodecPrototype().UnmarshalJSON(bytes, queryResponse); err != nil { + return nil, err + } + + return queryResponse, nil +} +func responsePrototype() helpers.QueryResponse { + return &QueryResponse{} +} +func newQueryResponse(parameterList lists.ParameterList) *QueryResponse { + return &QueryResponse{ + ParameterList: parameterList.(*baseLists.ParameterList), + } +} diff --git a/x/assets/queries/parameters/query_response.pb.go b/x/assets/queries/parameters/query_response.pb.go new file mode 100644 index 000000000..b9a1d6706 --- /dev/null +++ b/x/assets/queries/parameters/query_response.pb.go @@ -0,0 +1,337 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: AssetMantle/modules/x/assets/queries/parameters/query_response.proto + +package parameters + +import ( + fmt "fmt" + base "github.com/AssetMantle/schema/lists/base" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type QueryResponse struct { + ParameterList *base.ParameterList `protobuf:"bytes,1,opt,name=parameter_list,json=parameterList,proto3" json:"parameter_list,omitempty"` +} + +func (m *QueryResponse) Reset() { *m = QueryResponse{} } +func (m *QueryResponse) String() string { return proto.CompactTextString(m) } +func (*QueryResponse) ProtoMessage() {} +func (*QueryResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_620c81f7bde9bff0, []int{0} +} +func (m *QueryResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryResponse.Merge(m, src) +} +func (m *QueryResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryResponse proto.InternalMessageInfo + +func (m *QueryResponse) GetParameterList() *base.ParameterList { + if m != nil { + return m.ParameterList + } + return nil +} + +func init() { + proto.RegisterType((*QueryResponse)(nil), "AssetMantle.modules.x.assets.queries.parameters.QueryResponse") +} + +func init() { + proto.RegisterFile("AssetMantle/modules/x/assets/queries/parameters/query_response.proto", fileDescriptor_620c81f7bde9bff0) +} + +var fileDescriptor_620c81f7bde9bff0 = []byte{ + // 334 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x91, 0xb1, 0x4b, 0xfb, 0x40, + 0x14, 0xc7, 0x9b, 0xfc, 0xa0, 0x43, 0x7e, 0xd4, 0xa1, 0x93, 0x38, 0x1c, 0xe2, 0xe4, 0x20, 0xef, + 0xa0, 0x75, 0x3a, 0xa7, 0x16, 0xc1, 0xc5, 0x40, 0x5a, 0x97, 0x20, 0x07, 0xe5, 0xda, 0x3e, 0x6c, + 0xa0, 0xe9, 0xc5, 0xbc, 0x2b, 0xd4, 0xd1, 0xff, 0xc0, 0xbf, 0xc1, 0xd1, 0xbf, 0x44, 0x9c, 0x3a, + 0x3a, 0x4a, 0xba, 0xf9, 0x57, 0x48, 0x7a, 0xa7, 0x49, 0xc6, 0x8e, 0x79, 0xe4, 0xf3, 0xf9, 0x7e, + 0xdf, 0xbd, 0xe0, 0x7a, 0x40, 0x84, 0x26, 0x54, 0x2b, 0xb3, 0x44, 0x9e, 0xea, 0xf9, 0x7a, 0x89, + 0xc4, 0x37, 0x5c, 0x95, 0x53, 0xe2, 0x8f, 0x6b, 0xcc, 0x13, 0x24, 0x9e, 0xa9, 0x5c, 0xa5, 0x68, + 0x30, 0xb7, 0xa3, 0xa7, 0x49, 0x8e, 0x94, 0xe9, 0x15, 0x21, 0x64, 0xb9, 0x36, 0xba, 0xcb, 0x6b, + 0x16, 0x70, 0x16, 0xd8, 0x80, 0xb5, 0x80, 0xb3, 0x40, 0x65, 0x39, 0xe9, 0xd5, 0x63, 0x69, 0xb6, + 0xc0, 0x54, 0xf1, 0x65, 0x42, 0x86, 0xf8, 0x54, 0x11, 0x56, 0x79, 0x93, 0x72, 0x68, 0x43, 0xce, + 0xe6, 0x41, 0x67, 0x54, 0x86, 0x8f, 0x5d, 0x76, 0xf7, 0x2e, 0x38, 0x6a, 0xfe, 0x78, 0xec, 0x9d, + 0x7a, 0xe7, 0xff, 0x7b, 0x17, 0x50, 0xaf, 0x63, 0xed, 0xb0, 0xb7, 0x43, 0x69, 0x87, 0xe8, 0x17, + 0xba, 0x4d, 0xc8, 0x8c, 0x3b, 0x59, 0xfd, 0x73, 0xf8, 0xfc, 0xef, 0xbd, 0x60, 0xde, 0xb6, 0x60, + 0xde, 0x57, 0xc1, 0xbc, 0x97, 0x1d, 0x6b, 0x6d, 0x77, 0xac, 0xf5, 0xb9, 0x63, 0xad, 0xa0, 0x3f, + 0xd3, 0x29, 0x1c, 0xb8, 0xe9, 0xb0, 0xdb, 0xe8, 0x1c, 0x95, 0x9b, 0x44, 0xde, 0xbd, 0x78, 0x48, + 0xcc, 0x62, 0x3d, 0x85, 0x99, 0x4e, 0xf9, 0x81, 0x17, 0x78, 0xf5, 0xdb, 0x83, 0x30, 0x1e, 0x8c, + 0xa2, 0x37, 0xbf, 0xf1, 0xec, 0xa1, 0x2b, 0x13, 0xdb, 0x8a, 0x04, 0x23, 0x57, 0xe6, 0x6f, 0x5d, + 0xfa, 0x68, 0x10, 0xd2, 0x11, 0x32, 0x96, 0x96, 0x90, 0x8e, 0x90, 0x15, 0x51, 0xf8, 0x57, 0x07, + 0x12, 0xf2, 0x26, 0x1a, 0x86, 0x68, 0xd4, 0x5c, 0x19, 0xf5, 0xed, 0x5f, 0xd6, 0x68, 0x21, 0x1c, + 0x2e, 0x44, 0x2c, 0x84, 0x15, 0x08, 0xe1, 0x0c, 0x42, 0x54, 0x8a, 0x69, 0x7b, 0x7f, 0xf0, 0xfe, + 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x6b, 0x8a, 0x13, 0x9a, 0x9d, 0x02, 0x00, 0x00, +} + +func (m *QueryResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.ParameterList != nil { + { + size, err := m.ParameterList.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQueryResponse(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintQueryResponse(dAtA []byte, offset int, v uint64) int { + offset -= sovQueryResponse(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *QueryResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ParameterList != nil { + l = m.ParameterList.Size() + n += 1 + l + sovQueryResponse(uint64(l)) + } + return n +} + +func sovQueryResponse(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQueryResponse(x uint64) (n int) { + return sovQueryResponse(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QueryResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQueryResponse + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ParameterList", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQueryResponse + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQueryResponse + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQueryResponse + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.ParameterList == nil { + m.ParameterList = &base.ParameterList{} + } + if err := m.ParameterList.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQueryResponse(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQueryResponse + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipQueryResponse(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQueryResponse + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQueryResponse + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQueryResponse + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthQueryResponse + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupQueryResponse + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthQueryResponse + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthQueryResponse = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowQueryResponse = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupQueryResponse = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/assets/queries/parameters/service.pb.go b/x/assets/queries/parameters/service.pb.go new file mode 100644 index 000000000..2de6f2a78 --- /dev/null +++ b/x/assets/queries/parameters/service.pb.go @@ -0,0 +1,135 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: AssetMantle/modules/x/assets/queries/parameters/service.proto + +package parameters + +import ( + context "context" + fmt "fmt" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + math "math" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +func init() { + proto.RegisterFile("AssetMantle/modules/x/assets/queries/parameters/service.proto", fileDescriptor_d720f17bfda39b7b) +} + +var fileDescriptor_d720f17bfda39b7b = []byte{ + // 323 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0xd2, 0xb1, 0x4a, 0xc3, 0x40, + 0x18, 0x07, 0xf0, 0x5c, 0xc0, 0x0e, 0xc1, 0xa9, 0x63, 0x87, 0x1b, 0x7c, 0x80, 0x3b, 0xb0, 0x4e, + 0x27, 0x15, 0x5a, 0x05, 0x5d, 0x02, 0xa9, 0x2e, 0x41, 0x0e, 0xe4, 0xda, 0x7e, 0x68, 0x20, 0xc9, + 0xa5, 0x77, 0x17, 0xa9, 0x8f, 0xe0, 0x26, 0xf8, 0x06, 0x8e, 0x3e, 0x89, 0x38, 0x75, 0x74, 0x94, + 0x64, 0xf3, 0x15, 0x5c, 0x24, 0xbd, 0xc3, 0xb4, 0x63, 0xba, 0x5e, 0xf8, 0xfd, 0xef, 0xff, 0xe5, + 0xbb, 0x60, 0x34, 0xd6, 0x1a, 0x4c, 0x28, 0x72, 0x93, 0x02, 0xcd, 0xe4, 0xa2, 0x4c, 0x41, 0xd3, + 0x15, 0x15, 0xcd, 0xa9, 0xa6, 0xcb, 0x12, 0x54, 0x02, 0x9a, 0x16, 0x42, 0x89, 0x0c, 0x0c, 0x28, + 0x4d, 0x35, 0xa8, 0xc7, 0x64, 0x0e, 0xa4, 0x50, 0xd2, 0xc8, 0x3e, 0xdd, 0xe2, 0xc4, 0x71, 0xb2, + 0x22, 0x96, 0x13, 0xc7, 0x49, 0xcb, 0x07, 0xe7, 0x5d, 0xef, 0x6b, 0x8e, 0x9e, 0xee, 0x14, 0x2c, + 0x4b, 0xd0, 0xc6, 0xde, 0x3a, 0xb8, 0xd8, 0x37, 0x44, 0x17, 0x32, 0xd7, 0xae, 0xfb, 0xf1, 0x2b, + 0x0a, 0x0e, 0xa6, 0xcd, 0x87, 0xfe, 0x33, 0x0a, 0x7a, 0x57, 0x22, 0x5f, 0xa4, 0xd0, 0x1f, 0x91, + 0x8e, 0x13, 0x91, 0x4d, 0xc4, 0xb5, 0xed, 0x37, 0x38, 0xdb, 0x97, 0xdb, 0x66, 0x47, 0xde, 0xe4, + 0xd7, 0xff, 0xa8, 0x30, 0x5a, 0x57, 0x18, 0x7d, 0x57, 0x18, 0xbd, 0xd4, 0xd8, 0x5b, 0xd7, 0xd8, + 0xfb, 0xaa, 0xb1, 0x17, 0x0c, 0xe7, 0x32, 0xeb, 0x9a, 0x3f, 0x39, 0xbc, 0xb1, 0x0b, 0x8b, 0x9a, + 0x99, 0x23, 0x74, 0xcb, 0xee, 0x13, 0xf3, 0x50, 0xce, 0xc8, 0x5c, 0x66, 0xb4, 0xe3, 0x6f, 0x7c, + 0xf3, 0x7b, 0xe3, 0x30, 0x1e, 0x4f, 0xa3, 0x77, 0x7f, 0x67, 0xef, 0xa1, 0xab, 0x11, 0xdb, 0x72, + 0x76, 0xa6, 0xa6, 0x46, 0xf4, 0x4f, 0x3f, 0x77, 0x04, 0x77, 0x82, 0xc7, 0xdc, 0x0a, 0xee, 0x04, + 0x6f, 0x45, 0xe5, 0x9f, 0x76, 0x14, 0xfc, 0x32, 0x9a, 0x84, 0x60, 0xc4, 0x42, 0x18, 0xf1, 0xe3, + 0x9f, 0x6c, 0x69, 0xc6, 0x1c, 0x67, 0x2c, 0x66, 0xcc, 0x06, 0x30, 0xe6, 0x12, 0x18, 0x6b, 0x23, + 0x66, 0xbd, 0xcd, 0xd3, 0x18, 0xfe, 0x05, 0x00, 0x00, 0xff, 0xff, 0xfd, 0x4b, 0x56, 0x33, 0x17, + 0x03, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// QueryClient is the client API for Query service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type QueryClient interface { + Handle(ctx context.Context, in *QueryRequest, opts ...grpc.CallOption) (*QueryResponse, error) +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +func (c *queryClient) Handle(ctx context.Context, in *QueryRequest, opts ...grpc.CallOption) (*QueryResponse, error) { + out := new(QueryResponse) + err := c.cc.Invoke(ctx, "/AssetMantle.modules.x.assets.queries.parameters.Query/Handle", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +type QueryServer interface { + Handle(context.Context, *QueryRequest) (*QueryResponse, error) +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func (*UnimplementedQueryServer) Handle(ctx context.Context, req *QueryRequest) (*QueryResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Handle not implemented") +} + +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) +} + +func _Query_Handle_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Handle(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/AssetMantle.modules.x.assets.queries.parameters.Query/Handle", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Handle(ctx, req.(*QueryRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "AssetMantle.modules.x.assets.queries.parameters.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Handle", + Handler: _Query_Handle_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "AssetMantle/modules/x/assets/queries/parameters/service.proto", +} diff --git a/x/assets/queries/prototype.go b/x/assets/queries/prototype.go index f3e015ca7..aa9b8254e 100644 --- a/x/assets/queries/prototype.go +++ b/x/assets/queries/prototype.go @@ -8,11 +8,13 @@ import ( baseHelpers "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/x/assets/queries/asset" "github.com/AssetMantle/modules/x/assets/queries/assets" + "github.com/AssetMantle/modules/x/assets/queries/parameters" ) func Prototype() helpers.Queries { return baseHelpers.NewQueries( asset.Query, assets.Query, + parameters.Query, ) } diff --git a/x/assets/queries/prototype_test.go b/x/assets/queries/prototype_test.go index 84290c598..b49040341 100644 --- a/x/assets/queries/prototype_test.go +++ b/x/assets/queries/prototype_test.go @@ -17,11 +17,11 @@ func TestPrototype(t *testing.T) { getString string }{ - {"+ve", asset.Query.GetName(), "assets"}, + {"+ve", asset.Query.GetServicePath(), "assets"}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - if got := Prototype(); !reflect.DeepEqual(got.GetQuery(tt.getString).GetName(), tt.want) { + if got := Prototype(); !reflect.DeepEqual(got.GetQuery(tt.getString).GetServicePath(), tt.want) { t.Errorf("Prototype() = %v, want %v", got, tt.want) } }) diff --git a/x/assets/record/record.go b/x/assets/record/record.go index a5f367e60..d1e8d0fd2 100644 --- a/x/assets/record/record.go +++ b/x/assets/record/record.go @@ -1,14 +1,13 @@ package record import ( - "github.com/AssetMantle/schema/documents" - baseIDs "github.com/AssetMantle/schema/ids/base" - sdkTypes "github.com/cosmos/cosmos-sdk/types" - "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/x/assets/key" "github.com/AssetMantle/modules/x/assets/mappable" + "github.com/AssetMantle/schema/documents" + baseIDs "github.com/AssetMantle/schema/ids/base" + sdkTypes "github.com/cosmos/cosmos-sdk/types" ) var _ helpers.Record = (*Record)(nil) diff --git a/x/assets/simulator/genesis.go b/x/assets/simulator/genesis.go index 9d884dee1..0673392ca 100644 --- a/x/assets/simulator/genesis.go +++ b/x/assets/simulator/genesis.go @@ -4,8 +4,6 @@ package simulator import ( - "math/rand" - "github.com/AssetMantle/schema/data" baseData "github.com/AssetMantle/schema/data/base" baseDocuments "github.com/AssetMantle/schema/documents/base" @@ -16,6 +14,7 @@ import ( baseQualified "github.com/AssetMantle/schema/qualified/base" sdkTypes "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" + "math/rand" "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" diff --git a/x/assets/simulator/operations.go b/x/assets/simulator/operations.go index 11b718a60..a0c6afbf1 100644 --- a/x/assets/simulator/operations.go +++ b/x/assets/simulator/operations.go @@ -4,8 +4,6 @@ package simulator import ( - "math/rand" - "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" baseLists "github.com/AssetMantle/schema/lists/base" @@ -16,6 +14,7 @@ import ( "github.com/cosmos/cosmos-sdk/types/module" simulationTypes "github.com/cosmos/cosmos-sdk/types/simulation" "github.com/cosmos/cosmos-sdk/x/simulation" + "math/rand" "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/helpers/base" diff --git a/x/assets/simulator/proposals.go b/x/assets/simulator/proposals.go index 776c4f2bc..53aac918f 100644 --- a/x/assets/simulator/proposals.go +++ b/x/assets/simulator/proposals.go @@ -4,28 +4,28 @@ package simulator import ( - "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" - "math/rand" - sdkTypes "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" simulationTypes "github.com/cosmos/cosmos-sdk/types/simulation" + govSimulation "github.com/cosmos/cosmos-sdk/x/gov/simulation" + "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" "github.com/cosmos/cosmos-sdk/x/simulation" + "math/rand" ) -func (simulator) WeightedProposalContentList(module.SimulationState) []simulationTypes.WeightedProposalContent { - return []simulationTypes.WeightedProposalContent{ - simulation.NewWeightedProposalContent( +func (simulator) ProposalMessages(_ module.SimulationState) []simulationTypes.WeightedProposalMsg { + return []simulationTypes.WeightedProposalMsg{ + simulation.NewWeightedProposalMsg( OpWeightSubmitTextProposal, DefaultWeightTextProposal, - simulateTextProposalContent, + func(r *rand.Rand, _ sdkTypes.Context, simulationAccounts []simulationTypes.Account) sdkTypes.Msg { + msgSubmitProposal, err := v1beta1.NewMsgSubmitProposal(v1beta1.NewTextProposal(simulationTypes.RandStringOfLength(r, 140), simulationTypes.RandStringOfLength(r, 5000)), govSimulation.GenDepositParamsMinDeposit(r), simulationAccounts[r.Intn(len(simulationAccounts))].Address) + if err != nil { + panic(err) + } + + return msgSubmitProposal + }, ), } } - -func simulateTextProposalContent(r *rand.Rand, _ sdkTypes.Context, _ []simulationTypes.Account) simulationTypes.Content { - return v1beta1.NewTextProposal( - simulationTypes.RandStringOfLength(r, 140), - simulationTypes.RandStringOfLength(r, 5000), - ) -} diff --git a/x/assets/transactions/burn/message.go b/x/assets/transactions/burn/message.go index 3a0dabd86..3c17f1e42 100644 --- a/x/assets/transactions/burn/message.go +++ b/x/assets/transactions/burn/message.go @@ -4,26 +4,15 @@ package burn import ( - codecUtilities "github.com/AssetMantle/schema/codec/utilities" + "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" - sdkCodec "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/types" sdkTypes "github.com/cosmos/cosmos-sdk/types" - - "github.com/AssetMantle/modules/helpers" ) var _ helpers.Message = (*Message)(nil) -func (message *Message) Type() string { return Transaction.GetName() } -func (message *Message) GetFromAddress() sdkTypes.AccAddress { - from, err := sdkTypes.AccAddressFromBech32(message.From) - if err != nil { - panic(err) - } - return from -} func (message *Message) ValidateBasic() error { if _, err := sdkTypes.AccAddressFromBech32(message.From); err != nil { return err @@ -43,21 +32,10 @@ func (message *Message) GetSigners() []sdkTypes.AccAddress { } return []sdkTypes.AccAddress{from} } -func (*Message) RegisterLegacyAminoCodec(legacyAmino *sdkCodec.LegacyAmino) { - codecUtilities.RegisterModuleConcrete(legacyAmino, Message{}) -} func (message *Message) RegisterInterface(interfaceRegistry types.InterfaceRegistry) { interfaceRegistry.RegisterImplementations((*sdkTypes.Msg)(nil), message) } -func messageFromInterface(msg sdkTypes.Msg) *Message { - switch value := msg.(type) { - case *Message: - return value - default: - return &Message{} - } -} func messagePrototype() helpers.Message { return &Message{} } diff --git a/x/assets/transactions/burn/message_test.go b/x/assets/transactions/burn/message_test.go index a2b686447..f7cc73a2f 100644 --- a/x/assets/transactions/burn/message_test.go +++ b/x/assets/transactions/burn/message_test.go @@ -13,7 +13,6 @@ import ( baseLists "github.com/AssetMantle/schema/lists/base" baseProperties "github.com/AssetMantle/schema/properties/base" baseQualified "github.com/AssetMantle/schema/qualified/base" - sdkCodec "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" "github.com/AssetMantle/modules/helpers" @@ -29,26 +28,6 @@ var ( fromID = baseIDs.NewIdentityID(classificationID, immutables) ) -func Test_messageFromInterface(t *testing.T) { - type args struct { - msg sdkTypes.Msg - } - tests := []struct { - name string - args args - want helpers.Message - }{ - {"+ve", args{NewMessage(fromAccAddress, fromID, testAssetID)}, NewMessage(fromAccAddress, fromID, testAssetID).(*Message)}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := messageFromInterface(tt.args.msg); !reflect.DeepEqual(got, tt.want) { - t.Errorf("messageFromInterface() = %v, want %v", got, tt.want) - } - }) - } -} - func Test_messagePrototype(t *testing.T) { tests := []struct { name string @@ -92,62 +71,6 @@ func Test_message_GetSigners(t *testing.T) { } } -func Test_message_RegisterCodec(t *testing.T) { - type fields struct { - From sdkTypes.AccAddress - FromID ids.IdentityID - AssetID ids.AssetID - } - type args struct { - legacyAmino *sdkCodec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{fromAccAddress, fromID, testAssetID}, args{sdkCodec.NewLegacyAmino()}}, - {"+ve", fields{}, args{sdkCodec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - me := &Message{ - From: tt.fields.From.String(), - FromID: tt.fields.FromID.(*baseIDs.IdentityID), - AssetID: tt.fields.AssetID.(*baseIDs.AssetID), - } - me.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - -func Test_message_Type(t *testing.T) { - type fields struct { - From sdkTypes.AccAddress - FromID ids.IdentityID - AssetID ids.AssetID - } - tests := []struct { - name string - fields fields - want string - }{ - {"+ve", fields{fromAccAddress, fromID, testAssetID}, Transaction.GetName()}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - message := &Message{ - From: tt.fields.From.String(), - FromID: tt.fields.FromID.(*baseIDs.IdentityID), - AssetID: tt.fields.AssetID.(*baseIDs.AssetID), - } - if got := message.Type(); got != tt.want { - t.Errorf("Type() = %v, want %v", got, tt.want) - } - }) - } -} - func Test_message_ValidateBasic(t *testing.T) { type fields struct { From sdkTypes.AccAddress diff --git a/x/assets/transactions/burn/service.pb.go b/x/assets/transactions/burn/service.pb.go index e6c010ed1..8cf1c4d83 100644 --- a/x/assets/transactions/burn/service.pb.go +++ b/x/assets/transactions/burn/service.pb.go @@ -6,9 +6,9 @@ package burn import ( context "context" fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types/msgservice" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" - _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -31,30 +31,29 @@ func init() { } var fileDescriptor_64d6f26faf8cce14 = []byte{ - // 354 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0xd2, 0xb1, 0x4a, 0xc3, 0x40, - 0x18, 0x07, 0xf0, 0x26, 0x42, 0x87, 0xe0, 0x54, 0x71, 0x89, 0x92, 0xa1, 0x0f, 0x70, 0x07, 0xed, - 0x20, 0x1e, 0x2e, 0x8d, 0x83, 0x3a, 0x04, 0x8a, 0x76, 0x08, 0x12, 0x90, 0x6b, 0x7a, 0xc4, 0x40, - 0x72, 0x57, 0xf2, 0x5d, 0xa4, 0xb3, 0x4f, 0x20, 0xf8, 0x06, 0xba, 0xe9, 0x8b, 0x88, 0x53, 0xc1, - 0xc5, 0x51, 0x12, 0x27, 0x77, 0x77, 0x49, 0xef, 0xc0, 0xeb, 0x78, 0xeb, 0x17, 0x7e, 0xff, 0xfc, - 0xbf, 0x2f, 0xf1, 0x4e, 0x26, 0x00, 0x4c, 0x46, 0x94, 0xcb, 0x82, 0xe1, 0x52, 0x2c, 0xea, 0x82, - 0x01, 0x5e, 0x61, 0xda, 0x4d, 0x01, 0xcb, 0x8a, 0x72, 0xa0, 0xa9, 0xcc, 0x05, 0x07, 0x3c, 0xaf, - 0x2b, 0x8e, 0x81, 0x55, 0x77, 0x79, 0xca, 0xd0, 0xb2, 0x12, 0x52, 0x0c, 0x90, 0xa1, 0x91, 0xd6, - 0x68, 0x85, 0x94, 0x46, 0xa6, 0x46, 0x9d, 0xf6, 0x0f, 0x33, 0x21, 0xb2, 0x82, 0x61, 0xba, 0xcc, - 0x31, 0xe5, 0x5c, 0x48, 0xaa, 0x1e, 0x6e, 0xd2, 0x7c, 0xdb, 0x2e, 0x25, 0x03, 0xa0, 0x99, 0xee, - 0xe2, 0x5f, 0x58, 0x6a, 0x63, 0x72, 0x53, 0x31, 0x58, 0x0a, 0x0e, 0x3a, 0x6a, 0xf4, 0xea, 0x78, - 0x3b, 0x11, 0x64, 0x83, 0x67, 0xc7, 0xeb, 0x9f, 0x53, 0xbe, 0x28, 0xd8, 0xe0, 0xc8, 0x72, 0x55, - 0x14, 0xa9, 0x72, 0xfe, 0xa9, 0x2d, 0x9c, 0xfd, 0x4f, 0x2e, 0x75, 0xad, 0xe1, 0xc1, 0xfd, 0xc7, - 0xf7, 0xa3, 0xbb, 0x3f, 0xdc, 0xc3, 0xa5, 0xda, 0x4f, 0x6f, 0xd5, 0x81, 0xf0, 0xd7, 0x7d, 0x6b, - 0x02, 0x67, 0xdd, 0x04, 0xce, 0x57, 0x13, 0x38, 0x0f, 0x6d, 0xd0, 0x5b, 0xb7, 0x41, 0xef, 0xb3, - 0x0d, 0x7a, 0xde, 0x28, 0x15, 0xa5, 0xe5, 0xfb, 0xc3, 0xdd, 0x2b, 0xf5, 0x89, 0xa7, 0xdd, 0x29, - 0xa6, 0xce, 0xf5, 0x71, 0x96, 0xcb, 0xdb, 0x7a, 0x8e, 0x52, 0x51, 0x62, 0xbb, 0x13, 0x3f, 0xb9, - 0xfd, 0x49, 0x14, 0x4f, 0x66, 0xe1, 0x8b, 0xbb, 0x55, 0x22, 0xd2, 0x25, 0x62, 0x35, 0x05, 0x73, - 0x65, 0x40, 0x61, 0x5d, 0xf1, 0xf7, 0x2d, 0x90, 0x68, 0x90, 0xc4, 0x89, 0x02, 0x89, 0x09, 0x92, - 0x0e, 0x34, 0x2e, 0xb1, 0x03, 0xc9, 0xd9, 0x34, 0x8c, 0x98, 0xa4, 0x0b, 0x2a, 0xe9, 0x8f, 0x3b, - 0x36, 0x30, 0x21, 0x5a, 0x13, 0x12, 0x13, 0x95, 0x0a, 0x84, 0x98, 0x01, 0x84, 0x74, 0x09, 0xf3, - 0xfe, 0xe6, 0x67, 0x19, 0xff, 0x05, 0x00, 0x00, 0xff, 0xff, 0x01, 0x3b, 0x12, 0xe9, 0x43, 0x03, - 0x00, 0x00, + // 343 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0xd2, 0xb1, 0x4b, 0xc3, 0x40, + 0x14, 0x06, 0xf0, 0x5c, 0xc4, 0x0e, 0xc1, 0xa9, 0x8b, 0x90, 0x21, 0x83, 0xa3, 0xc3, 0x1d, 0xb6, + 0x83, 0x78, 0xb8, 0x34, 0x0e, 0xea, 0x10, 0x28, 0xda, 0x21, 0x48, 0x40, 0xae, 0xe9, 0x11, 0x0b, + 0xcd, 0x5d, 0xc9, 0xbb, 0x94, 0x8e, 0x8e, 0x8e, 0x6e, 0xee, 0x8e, 0x4e, 0xfe, 0x19, 0xe2, 0xd4, + 0xd1, 0x51, 0x92, 0x41, 0x70, 0x77, 0x97, 0x78, 0x07, 0x5e, 0xc7, 0x9b, 0x02, 0x0f, 0x7e, 0x5f, + 0xbe, 0x77, 0x77, 0xc1, 0xe9, 0x08, 0x80, 0xab, 0x84, 0x09, 0xb5, 0xe0, 0xa4, 0x94, 0xb3, 0x7a, + 0xc1, 0x81, 0xac, 0x09, 0xeb, 0xa6, 0x40, 0x54, 0xc5, 0x04, 0xb0, 0x5c, 0xcd, 0xa5, 0x00, 0x32, + 0xad, 0x2b, 0x41, 0x80, 0x57, 0xab, 0x79, 0xce, 0xf1, 0xb2, 0x92, 0x4a, 0xf6, 0xb1, 0xa5, 0xb1, + 0xd1, 0x78, 0x8d, 0xb5, 0xc6, 0xb6, 0xc6, 0x9d, 0x0e, 0xf7, 0x73, 0x09, 0xa5, 0x04, 0x52, 0x42, + 0x41, 0x56, 0x47, 0xdd, 0x47, 0x07, 0x85, 0xae, 0x35, 0x4a, 0x0e, 0xc0, 0x0a, 0x53, 0x23, 0xbc, + 0x74, 0xd4, 0xd6, 0xe4, 0xb6, 0xe2, 0xb0, 0x94, 0x02, 0x4c, 0xd4, 0xe0, 0x09, 0x05, 0x3b, 0x09, + 0x14, 0xfd, 0x07, 0x14, 0xf4, 0x2e, 0x98, 0x98, 0x2d, 0x78, 0xff, 0xd8, 0x71, 0x4b, 0x9c, 0xe8, + 0x72, 0xe1, 0x99, 0x2b, 0x9c, 0xfc, 0x4f, 0xae, 0x4c, 0xad, 0x03, 0x2f, 0xdc, 0xbd, 0xff, 0x7a, + 0x3d, 0x44, 0xf1, 0x8f, 0xff, 0xd6, 0x44, 0x68, 0xd3, 0x44, 0xe8, 0xb3, 0x89, 0xd0, 0x63, 0x1b, + 0x79, 0x9b, 0x36, 0xf2, 0x3e, 0xda, 0xc8, 0x0b, 0x06, 0xb9, 0x2c, 0x1d, 0xff, 0x15, 0xef, 0x5d, + 0xeb, 0x9b, 0x1c, 0x77, 0x6b, 0x8f, 0xd1, 0xcd, 0x49, 0x31, 0x57, 0x77, 0xf5, 0x14, 0xe7, 0xb2, + 0x24, 0x6e, 0xc7, 0xf9, 0xec, 0xf7, 0x46, 0x49, 0x3a, 0x9a, 0xc4, 0x2f, 0xfe, 0x56, 0x89, 0xc4, + 0x94, 0x48, 0xf5, 0x14, 0xec, 0xf5, 0x00, 0xc7, 0x75, 0x25, 0xde, 0xb7, 0x40, 0x66, 0x40, 0x96, + 0x66, 0x1a, 0x64, 0x36, 0xc8, 0x3a, 0xd0, 0xf8, 0xd4, 0x0d, 0x64, 0xe7, 0xe3, 0x38, 0xe1, 0x8a, + 0xcd, 0x98, 0x62, 0xdf, 0xfe, 0xd0, 0xc2, 0x94, 0x1a, 0x4d, 0x69, 0x4a, 0x75, 0x2a, 0x50, 0x6a, + 0x07, 0x50, 0xda, 0x25, 0x4c, 0x7b, 0x7f, 0x0f, 0x63, 0xf8, 0x1b, 0x00, 0x00, 0xff, 0xff, 0x3c, + 0x01, 0xd8, 0xbc, 0x2a, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/assets/transactions/burn/service.pb.gw.go b/x/assets/transactions/burn/service.pb.gw.go deleted file mode 100644 index 4428f889e..000000000 --- a/x/assets/transactions/burn/service.pb.gw.go +++ /dev/null @@ -1,171 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: AssetMantle/modules/x/assets/transactions/burn/service.proto - -/* -Package burn is a reverse proxy. - -It translates gRPC into RESTful JSON APIs. -*/ -package burn - -import ( - "context" - "io" - "net/http" - - "github.com/golang/protobuf/descriptor" - "github.com/golang/protobuf/proto" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/grpc-ecosystem/grpc-gateway/utilities" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/status" -) - -// Suppress "imported and not used" errors -var _ codes.Code -var _ io.Reader -var _ status.Status -var _ = runtime.String -var _ = utilities.NewDoubleArray -var _ = descriptor.ForMessage -var _ = metadata.Join - -var ( - filter_Msg_Handle_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - -func request_Msg_Handle_0(ctx context.Context, marshaler runtime.Marshaler, client MsgClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq Message - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.Handle(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Msg_Handle_0(ctx context.Context, marshaler runtime.Marshaler, server MsgServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq Message - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.Handle(ctx, &protoReq) - return msg, metadata, err - -} - -// RegisterMsgHandlerServer registers the http handlers for service Msg to "mux". -// UnaryRPC :call MsgServer directly. -// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterMsgHandlerFromEndpoint instead. -func RegisterMsgHandlerServer(ctx context.Context, mux *runtime.ServeMux, server MsgServer) error { - - mux.Handle("POST", pattern_Msg_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Msg_Handle_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Msg_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -// RegisterMsgHandlerFromEndpoint is same as RegisterMsgHandler but -// automatically dials to "endpoint" and closes the connection when "ctx" gets done. -func RegisterMsgHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.Dial(endpoint, opts...) - if err != nil { - return err - } - defer func() { - if err != nil { - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - return - } - go func() { - <-ctx.Done() - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - }() - }() - - return RegisterMsgHandler(ctx, mux, conn) -} - -// RegisterMsgHandler registers the http handlers for service Msg to "mux". -// The handlers forward requests to the grpc endpoint over "conn". -func RegisterMsgHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { - return RegisterMsgHandlerClient(ctx, mux, NewMsgClient(conn)) -} - -// RegisterMsgHandlerClient registers the http handlers for service Msg -// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "MsgClient". -// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "MsgClient" -// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "MsgClient" to call the correct interceptors. -func RegisterMsgHandlerClient(ctx context.Context, mux *runtime.ServeMux, client MsgClient) error { - - mux.Handle("POST", pattern_Msg_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Msg_Handle_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Msg_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -var ( - pattern_Msg_Handle_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"mantle", "assets", "burn"}, "", runtime.AssumeColonVerbOpt(false))) -) - -var ( - forward_Msg_Handle_0 = runtime.ForwardResponseMessage -) diff --git a/x/assets/transactions/burn/transaction.go b/x/assets/transactions/burn/transaction.go index 79d5bfeef..5ef26e1a4 100644 --- a/x/assets/transactions/burn/transaction.go +++ b/x/assets/transactions/burn/transaction.go @@ -4,22 +4,14 @@ package burn import ( - "context" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "google.golang.org/grpc" - "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/helpers/constants" - "github.com/AssetMantle/modules/utilities/name" + "google.golang.org/grpc" ) -type dummy struct{} - var Transaction = baseHelpers.NewTransaction( - name.GetPackageName(dummy{}), + _Msg_serviceDesc.ServiceName, "", "", @@ -30,9 +22,6 @@ var Transaction = baseHelpers.NewTransaction( func(server grpc.ServiceRegistrar, keeper helpers.TransactionKeeper) { RegisterMsgServer(server, keeper.(transactionKeeper)) }, - func(clientCtx client.Context, mux *runtime.ServeMux) error { - return RegisterMsgHandlerClient(context.Background(), mux, NewMsgClient(clientCtx)) - }, constants.FromIdentityID, constants.AssetID, diff --git a/x/assets/transactions/burn/transaction_keeper.go b/x/assets/transactions/burn/transaction_keeper.go index e57e146a5..48a160fab 100644 --- a/x/assets/transactions/burn/transaction_keeper.go +++ b/x/assets/transactions/burn/transaction_keeper.go @@ -6,7 +6,6 @@ package burn import ( "context" errorConstants "github.com/AssetMantle/modules/helpers/constants" - "github.com/AssetMantle/schema/data" "github.com/AssetMantle/schema/properties" propertyConstants "github.com/AssetMantle/schema/properties/constants" diff --git a/x/assets/transactions/burn/transaction_request.go b/x/assets/transactions/burn/transaction_request.go index 597919d36..ed20d3898 100644 --- a/x/assets/transactions/burn/transaction_request.go +++ b/x/assets/transactions/burn/transaction_request.go @@ -5,23 +5,21 @@ package burn import ( "encoding/json" - "github.com/AssetMantle/modules/utilities/rest" - - codecUtilities "github.com/AssetMantle/schema/codec/utilities" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" "github.com/cosmos/cosmos-sdk/client" - sdkCodec "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" + "io" + "net/http" "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/helpers/constants" ) type transactionRequest struct { - BaseReq rest.BaseReq `json:"baseReq"` - FromID string `json:"fromID"` - AssetID string `json:"assetID"` + helpers.CommonTransactionRequest `json:"commonTransactionRequest"` + FromID string `json:"fromID"` + AssetID string `json:"assetID"` } var _ helpers.TransactionRequest = (*transactionRequest)(nil) @@ -47,23 +45,28 @@ func (transactionRequest transactionRequest) Validate() error { } func (transactionRequest transactionRequest) FromCLI(cliCommand helpers.CLICommand, context client.Context) (helpers.TransactionRequest, error) { return newTransactionRequest( - cliCommand.ReadBaseReq(context), + cliCommand.ReadCommonTransactionRequest(context), cliCommand.ReadString(constants.FromIdentityID), cliCommand.ReadString(constants.AssetID), ), nil } -func (transactionRequest transactionRequest) FromJSON(rawMessage json.RawMessage) (helpers.TransactionRequest, error) { - if err := json.Unmarshal(rawMessage, &transactionRequest); err != nil { +func (transactionRequest transactionRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.TransactionRequest, error) { + body, err := io.ReadAll(httpRequest.Body) + if err != nil { + return nil, err + } + + if err := json.Unmarshal(body, &transactionRequest); err != nil { return nil, err } return transactionRequest, nil } -func (transactionRequest transactionRequest) GetBaseReq() rest.BaseReq { - return transactionRequest.BaseReq +func (transactionRequest transactionRequest) GetCommonTransactionRequest() helpers.CommonTransactionRequest { + return transactionRequest.CommonTransactionRequest } func (transactionRequest transactionRequest) MakeMsg() (sdkTypes.Msg, error) { - from, err := sdkTypes.AccAddressFromBech32(transactionRequest.GetBaseReq().From) + from, err := sdkTypes.AccAddressFromBech32(transactionRequest.GetCommonTransactionRequest().GetFrom()) if err != nil { return nil, err } @@ -84,16 +87,13 @@ func (transactionRequest transactionRequest) MakeMsg() (sdkTypes.Msg, error) { assetID.(ids.AssetID), ), nil } -func (transactionRequest) RegisterLegacyAminoCodec(legacyAmino *sdkCodec.LegacyAmino) { - codecUtilities.RegisterModuleConcrete(legacyAmino, transactionRequest{}) -} func requestPrototype() helpers.TransactionRequest { return transactionRequest{} } -func newTransactionRequest(baseReq rest.BaseReq, fromID string, assetID string) helpers.TransactionRequest { +func newTransactionRequest(commonTransactionRequest helpers.CommonTransactionRequest, fromID string, assetID string) helpers.TransactionRequest { return transactionRequest{ - BaseReq: baseReq, - FromID: fromID, - AssetID: assetID, + CommonTransactionRequest: commonTransactionRequest, + FromID: fromID, + AssetID: assetID, } } diff --git a/x/assets/transactions/burn/transaction_request_test.go b/x/assets/transactions/burn/transaction_request_test.go index a990f39c6..d5ffc1fa0 100644 --- a/x/assets/transactions/burn/transaction_request_test.go +++ b/x/assets/transactions/burn/transaction_request_test.go @@ -4,44 +4,40 @@ package burn import ( - "encoding/json" "fmt" - "github.com/AssetMantle/modules/utilities/rest" "reflect" "testing" - baseIDs "github.com/AssetMantle/schema/ids/base" "github.com/cosmos/cosmos-sdk/client" - sdkCodec "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" "github.com/spf13/viper" "github.com/AssetMantle/modules/helpers" - "github.com/AssetMantle/modules/helpers/base" + baseHelpers "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/helpers/constants" ) var ( - testBaseRequest = rest.BaseReq{From: fromAddress, ChainID: "test", Fees: sdkTypes.NewCoins()} + commonTransactionRequest = helpers.PrototypeCommonTransactionRequest() ) func Test_newTransactionRequest(t *testing.T) { type args struct { - baseReq rest.BaseReq - fromID string - assetID string + commonTransactionRequest helpers.CommonTransactionRequest + fromID string + assetID string } tests := []struct { name string args args want helpers.TransactionRequest }{ - {"+ve", args{testBaseRequest, fromID.AsString(), testAssetID.AsString()}, transactionRequest{testBaseRequest, fromID.AsString(), testAssetID.AsString()}}, + {"+ve", args{commonTransactionRequest, fromID.AsString(), testAssetID.AsString()}, transactionRequest{commonTransactionRequest, fromID.AsString(), testAssetID.AsString()}}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - if got := newTransactionRequest(tt.args.baseReq, tt.args.fromID, tt.args.assetID); !reflect.DeepEqual(got, tt.want) { + if got := newTransactionRequest(tt.args.commonTransactionRequest, tt.args.fromID, tt.args.assetID); !reflect.DeepEqual(got, tt.want) { t.Errorf("newTransactionRequest() = %v, want %v", got, tt.want) } }) @@ -65,14 +61,14 @@ func Test_requestPrototype(t *testing.T) { } func Test_transactionRequest_FromCLI(t *testing.T) { - cliCommand := base.NewCLICommand("", "", "", []helpers.CLIFlag{constants.AssetID, constants.FromIdentityID}) + cliCommand := baseHelpers.NewCLICommand("", "", "", []helpers.CLIFlag{constants.AssetID, constants.FromIdentityID}) viper.Set(constants.AssetID.GetName(), testAssetID.AsString()) viper.Set(constants.FromIdentityID.GetName(), fromID.AsString()) type fields struct { - BaseReq rest.BaseReq - FromID string - AssetID string + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + AssetID string } type args struct { cliCommand helpers.CLICommand @@ -85,14 +81,14 @@ func Test_transactionRequest_FromCLI(t *testing.T) { want helpers.TransactionRequest wantErr bool }{ - {"+ve", fields{BaseReq: testBaseRequest, FromID: fromID.AsString(), AssetID: testAssetID.AsString()}, args{cliCommand, client.Context{}.WithCodec(base.CodecPrototype())}, newTransactionRequest(testBaseRequest, fromID.AsString(), testAssetID.AsString()), false}, + {"+ve", fields{commonTransactionRequest: commonTransactionRequest, FromID: fromID.AsString(), AssetID: testAssetID.AsString()}, args{cliCommand, client.Context{}.WithCodec(baseHelpers.CodecPrototype())}, newTransactionRequest(commonTransactionRequest, fromID.AsString(), testAssetID.AsString()), false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - AssetID: tt.fields.AssetID, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + AssetID: tt.fields.AssetID, } got, err := transactionRequest.FromCLI(tt.args.cliCommand, tt.args.context) if (err != nil) != tt.wantErr { @@ -106,65 +102,28 @@ func Test_transactionRequest_FromCLI(t *testing.T) { } } -func Test_transactionRequest_FromJSON(t *testing.T) { - type fields struct { - BaseReq rest.BaseReq - FromID string - AssetID string - } - type args struct { - rawMessage json.RawMessage - } - tests := []struct { - name string - fields fields - args args - want helpers.TransactionRequest - wantErr bool - }{ - {"+ve", fields{testBaseRequest, fromID.AsString(), testAssetID.AsString()}, args{sdkTypes.MustSortJSON(base.CodecPrototype().MustMarshalJSON(&Message{fromAccAddress.String(), fromID.(*baseIDs.IdentityID), testAssetID.(*baseIDs.AssetID)}))}, newTransactionRequest(testBaseRequest, fromID.AsString(), testAssetID.AsString()), false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - AssetID: tt.fields.AssetID, - } - got, err := transactionRequest.FromJSON(tt.args.rawMessage) - if (err != nil) != tt.wantErr { - t.Errorf("FromJSON() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("FromJSON() got = %v, want %v", got, tt.want) - } - }) - } -} - func Test_transactionRequest_GetBaseReq(t *testing.T) { type fields struct { - BaseReq rest.BaseReq - FromID string - AssetID string + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + AssetID string } tests := []struct { name string fields fields - want rest.BaseReq + want helpers.CommonTransactionRequest }{ - {"+ve", fields{testBaseRequest, fromID.AsString(), testAssetID.AsString()}, testBaseRequest}, + {"+ve", fields{commonTransactionRequest, fromID.AsString(), testAssetID.AsString()}, commonTransactionRequest}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - AssetID: tt.fields.AssetID, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + AssetID: tt.fields.AssetID, } - if got := transactionRequest.GetBaseReq(); !reflect.DeepEqual(got, tt.want) { - t.Errorf("GetBaseReq() = %v, want %v", got, tt.want) + if got := transactionRequest.GetCommonTransactionRequest(); !reflect.DeepEqual(got, tt.want) { + t.Errorf("GetCommonTransactionRequest() = %v, want %v", got, tt.want) } }) } @@ -172,9 +131,9 @@ func Test_transactionRequest_GetBaseReq(t *testing.T) { func Test_transactionRequest_MakeMsg(t *testing.T) { type fields struct { - BaseReq rest.BaseReq - FromID string - AssetID string + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + AssetID string } tests := []struct { name string @@ -182,14 +141,14 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { want sdkTypes.Msg wantErr bool }{ - {"+ve", fields{testBaseRequest, fromID.AsString(), testAssetID.AsString()}, NewMessage(fromAccAddress, fromID, testAssetID), false}, + {"+ve", fields{commonTransactionRequest, fromID.AsString(), testAssetID.AsString()}, NewMessage(fromAccAddress, fromID, testAssetID), false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - AssetID: tt.fields.AssetID, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + AssetID: tt.fields.AssetID, } got, err := transactionRequest.MakeMsg() if (err != nil) != tt.wantErr { @@ -203,54 +162,26 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { } } -func Test_transactionRequest_RegisterCodec(t *testing.T) { - type fields struct { - BaseReq rest.BaseReq - FromID string - AssetID string - } - type args struct { - legacyAmino *sdkCodec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{testBaseRequest, fromID.AsString(), testAssetID.AsString()}, args{sdkCodec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - tr := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - AssetID: tt.fields.AssetID, - } - tr.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - func Test_transactionRequest_Validate(t *testing.T) { type fields struct { - BaseReq rest.BaseReq - FromID string - AssetID string + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + AssetID string } tests := []struct { name string fields fields wantErr bool }{ - {"+ve", fields{testBaseRequest, fromID.AsString(), testAssetID.AsString()}, false}, + {"+ve", fields{commonTransactionRequest, fromID.AsString(), testAssetID.AsString()}, false}, // {"+ve", fields{}, true}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - AssetID: tt.fields.AssetID, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + AssetID: tt.fields.AssetID, } if err := transactionRequest.Validate(); (err != nil) != tt.wantErr { t.Errorf("ValidateBasic() error = %v, wantErr %v", err, tt.wantErr) diff --git a/x/assets/transactions/burn/transaction_response.go b/x/assets/transactions/burn/transaction_response.go index b269d2181..efdc2534e 100644 --- a/x/assets/transactions/burn/transaction_response.go +++ b/x/assets/transactions/burn/transaction_response.go @@ -4,9 +4,8 @@ package burn import ( - sdkTypes "github.com/cosmos/cosmos-sdk/types" - "github.com/AssetMantle/modules/helpers" + sdkTypes "github.com/cosmos/cosmos-sdk/types" ) var _ helpers.TransactionResponse = (*TransactionResponse)(nil) diff --git a/x/assets/transactions/define/message.go b/x/assets/transactions/define/message.go index 020db6f25..de8274451 100644 --- a/x/assets/transactions/define/message.go +++ b/x/assets/transactions/define/message.go @@ -4,28 +4,17 @@ package define import ( - codecUtilities "github.com/AssetMantle/schema/codec/utilities" + "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" "github.com/AssetMantle/schema/lists" baseLists "github.com/AssetMantle/schema/lists/base" - sdkCodec "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/types" sdkTypes "github.com/cosmos/cosmos-sdk/types" - - "github.com/AssetMantle/modules/helpers" ) var _ helpers.Message = (*Message)(nil) -func (message *Message) Type() string { return Transaction.GetName() } -func (message *Message) GetFromAddress() sdkTypes.AccAddress { - from, err := sdkTypes.AccAddressFromBech32(message.From) - if err != nil { - panic(err) - } - return from -} func (message *Message) ValidateBasic() error { if _, err := sdkTypes.AccAddressFromBech32(message.From); err != nil { return err @@ -54,21 +43,10 @@ func (message *Message) GetSigners() []sdkTypes.AccAddress { } return []sdkTypes.AccAddress{from} } -func (*Message) RegisterLegacyAminoCodec(legacyAmino *sdkCodec.LegacyAmino) { - codecUtilities.RegisterModuleConcrete(legacyAmino, Message{}) -} func (message *Message) RegisterInterface(interfaceRegistry types.InterfaceRegistry) { interfaceRegistry.RegisterImplementations((*sdkTypes.Msg)(nil), message) } -func messageFromInterface(msg sdkTypes.Msg) *Message { - switch value := msg.(type) { - case *Message: - return value - default: - return &Message{} - } -} func messagePrototype() helpers.Message { return &Message{} } diff --git a/x/assets/transactions/define/message_test.go b/x/assets/transactions/define/message_test.go index eb3843e55..24963779c 100644 --- a/x/assets/transactions/define/message_test.go +++ b/x/assets/transactions/define/message_test.go @@ -14,7 +14,6 @@ import ( baseLists "github.com/AssetMantle/schema/lists/base" baseProperties "github.com/AssetMantle/schema/properties/base" baseQualified "github.com/AssetMantle/schema/qualified/base" - sdkCodec "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" "github.com/AssetMantle/modules/helpers" @@ -42,26 +41,6 @@ type fields struct { MutableProperties *baseLists.PropertyList } -func Test_messageFromInterface(t *testing.T) { - type args struct { - msg sdkTypes.Msg - } - tests := []struct { - name string - args args - want helpers.Message - }{ - {"+ve", args{NewMessage(fromAccAddress, fromID, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties)}, NewMessage(fromAccAddress, fromID, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties).(*Message)}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := messageFromInterface(tt.args.msg); !reflect.DeepEqual(got, tt.want) { - t.Errorf("messageFromInterface() = %v, want %v", got, tt.want) - } - }) - } -} - func Test_messagePrototype(t *testing.T) { tests := []struct { name string @@ -104,59 +83,6 @@ func Test_message_GetSigners(t *testing.T) { } } -func Test_message_RegisterCodec(t *testing.T) { - - type args struct { - legacyAmino *sdkCodec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{fromAccAddress.String(), fromID, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties}, args{sdkCodec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - me := &Message{ - From: tt.fields.From, - FromID: tt.fields.FromID, - ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, - ImmutableProperties: tt.fields.ImmutableProperties, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, - } - me.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - -func Test_message_Type(t *testing.T) { - - tests := []struct { - name string - fields fields - want string - }{ - {"+ve", fields{fromAccAddress.String(), fromID, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties}, Transaction.GetName()}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - message := &Message{ - From: tt.fields.From, - FromID: tt.fields.FromID, - ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, - ImmutableProperties: tt.fields.ImmutableProperties, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, - } - if got := message.Type(); got != tt.want { - t.Errorf("Type() = %v, want %v", got, tt.want) - } - }) - } -} - func Test_message_ValidateBasic(t *testing.T) { tests := []struct { diff --git a/x/assets/transactions/define/service.pb.go b/x/assets/transactions/define/service.pb.go index b1ca794e3..2856d8f6e 100644 --- a/x/assets/transactions/define/service.pb.go +++ b/x/assets/transactions/define/service.pb.go @@ -6,9 +6,9 @@ package define import ( context "context" fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types/msgservice" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" - _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -31,30 +31,29 @@ func init() { } var fileDescriptor_1e8e48cb5e3393e4 = []byte{ - // 360 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0xd2, 0x3f, 0x4b, 0xc3, 0x40, - 0x18, 0x06, 0xf0, 0x26, 0x85, 0x0e, 0xc1, 0xa9, 0x20, 0x42, 0xd0, 0x0c, 0xfd, 0x00, 0x77, 0xe2, - 0x9f, 0xc1, 0x53, 0x84, 0x96, 0x8a, 0x82, 0x04, 0x8a, 0x76, 0x08, 0x12, 0x90, 0x6b, 0x72, 0xc6, - 0x40, 0x72, 0x57, 0xf2, 0x5e, 0xa5, 0xab, 0x7e, 0x02, 0xc1, 0x6f, 0xe0, 0xa6, 0x9b, 0xdf, 0x42, - 0x9c, 0x0a, 0x2e, 0x8e, 0x92, 0x3a, 0xf9, 0x29, 0xa4, 0xbd, 0x03, 0xaf, 0xe3, 0xad, 0x6f, 0xf8, - 0x3d, 0x3c, 0xef, 0xe5, 0xf5, 0x8e, 0xbb, 0x00, 0x4c, 0x86, 0x94, 0xcb, 0x82, 0xe1, 0x52, 0xa4, - 0x93, 0x82, 0x01, 0x9e, 0x62, 0xba, 0x98, 0x02, 0x96, 0x15, 0xe5, 0x40, 0x13, 0x99, 0x0b, 0x0e, - 0x38, 0x65, 0x37, 0x39, 0x67, 0x18, 0x58, 0x75, 0x97, 0x27, 0x0c, 0x8d, 0x2b, 0x21, 0x45, 0x7b, - 0xdb, 0xf0, 0x48, 0x7b, 0x34, 0x45, 0xca, 0x23, 0xd3, 0x23, 0xe5, 0xfd, 0xcd, 0x4c, 0x88, 0xac, - 0x60, 0x98, 0x8e, 0x73, 0x4c, 0x39, 0x17, 0x92, 0xaa, 0xcf, 0xcb, 0x3c, 0xdf, 0xbe, 0x4f, 0xc9, - 0x00, 0x68, 0xa6, 0xfb, 0xf8, 0xe7, 0xd6, 0xde, 0x98, 0x5d, 0x57, 0x0c, 0xc6, 0x82, 0x83, 0x0e, - 0xdb, 0x79, 0x73, 0xbc, 0x66, 0x08, 0x59, 0xfb, 0xc5, 0xf1, 0x5a, 0x67, 0x94, 0xa7, 0x05, 0x6b, - 0x1f, 0x20, 0xdb, 0x85, 0x51, 0xa8, 0x0a, 0xfa, 0x27, 0xf6, 0x74, 0xf8, 0x3f, 0xbb, 0xd0, 0xd5, - 0x3a, 0x5b, 0x0f, 0x9f, 0x3f, 0x4f, 0xee, 0x46, 0x67, 0x1d, 0x97, 0x6a, 0x4b, 0xbd, 0x9b, 0x22, - 0xbd, 0xfb, 0xe6, 0x7b, 0x1d, 0x38, 0xb3, 0x3a, 0x70, 0xbe, 0xeb, 0xc0, 0x79, 0x9c, 0x07, 0x8d, - 0xd9, 0x3c, 0x68, 0x7c, 0xcd, 0x83, 0x86, 0xb7, 0x97, 0x88, 0xd2, 0xba, 0x43, 0x6f, 0xed, 0x52, - 0xfd, 0xf0, 0xc1, 0xe2, 0x49, 0x06, 0xce, 0xd5, 0x61, 0x96, 0xcb, 0xdb, 0xc9, 0x08, 0x25, 0xa2, - 0xc4, 0xb6, 0x8f, 0xfd, 0xec, 0xb6, 0xba, 0x61, 0xd4, 0x1d, 0xf6, 0x5f, 0xdd, 0x95, 0xc3, 0x09, - 0x75, 0x91, 0x48, 0xd5, 0x03, 0x73, 0x71, 0x40, 0xfd, 0xa5, 0xfd, 0x58, 0x21, 0xb1, 0x26, 0x71, - 0x14, 0x2b, 0x12, 0x9b, 0x24, 0x56, 0xa4, 0x76, 0x8f, 0x6c, 0x49, 0x7c, 0x3a, 0xe8, 0x85, 0x4c, - 0xd2, 0x94, 0x4a, 0xfa, 0xeb, 0xee, 0x1b, 0x9c, 0x10, 0xed, 0x09, 0x89, 0x08, 0x51, 0x09, 0x84, - 0x98, 0x11, 0x84, 0xa8, 0x8c, 0x51, 0x6b, 0x79, 0x3e, 0xbb, 0x7f, 0x01, 0x00, 0x00, 0xff, 0xff, - 0xea, 0xc0, 0xb9, 0x27, 0x5d, 0x03, 0x00, 0x00, + // 350 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0xd2, 0x3f, 0x4b, 0xfb, 0x40, + 0x18, 0x07, 0xf0, 0x5c, 0xca, 0xaf, 0x43, 0xf8, 0x4d, 0x5d, 0x84, 0x0c, 0x19, 0x1c, 0x1d, 0xee, + 0xfc, 0x3b, 0x78, 0x8a, 0xd0, 0x52, 0x51, 0x90, 0x40, 0xd1, 0x0e, 0x41, 0x02, 0x72, 0x4d, 0xce, + 0x18, 0x68, 0x72, 0x25, 0xcf, 0xb5, 0x74, 0xd4, 0xdd, 0xc1, 0xdd, 0xcd, 0xd1, 0xc9, 0x97, 0x21, + 0x4e, 0x1d, 0x1d, 0x25, 0x1d, 0x04, 0x5f, 0x85, 0xa4, 0x77, 0xe0, 0x75, 0xbc, 0x29, 0xf0, 0xc0, + 0xe7, 0x9b, 0xef, 0x93, 0x3c, 0xde, 0x49, 0x17, 0x80, 0xcb, 0x90, 0x95, 0x72, 0xcc, 0x49, 0x21, + 0xd2, 0xe9, 0x98, 0x03, 0x99, 0x13, 0xd6, 0x4c, 0x81, 0xc8, 0x8a, 0x95, 0xc0, 0x12, 0x99, 0x8b, + 0x12, 0x48, 0xca, 0x6f, 0xf3, 0x92, 0x13, 0xe0, 0xd5, 0x2c, 0x4f, 0x38, 0x9e, 0x54, 0x42, 0x8a, + 0xce, 0xb6, 0xe1, 0xb1, 0xf6, 0x78, 0x8e, 0x95, 0xc7, 0xa6, 0xc7, 0xca, 0xfb, 0x1b, 0x89, 0x80, + 0x42, 0x00, 0x29, 0x20, 0x23, 0xb3, 0x9d, 0xe6, 0xa1, 0xa2, 0x7c, 0xfb, 0x2a, 0x05, 0x07, 0x60, + 0x99, 0xae, 0xe2, 0x5f, 0x58, 0x7b, 0x63, 0x76, 0x53, 0x71, 0x98, 0x88, 0x12, 0x74, 0xd8, 0xee, + 0x33, 0xf2, 0x5a, 0x21, 0x64, 0x9d, 0x47, 0xe4, 0xb5, 0xcf, 0x59, 0x99, 0x8e, 0x79, 0xe7, 0x10, + 0xdb, 0xee, 0x8a, 0x43, 0x55, 0xd0, 0x3f, 0xb5, 0xa7, 0xc3, 0xbf, 0xd9, 0xa5, 0xae, 0xb6, 0xe9, + 0xf8, 0xff, 0xee, 0xbf, 0xdf, 0xb6, 0x50, 0xef, 0xa1, 0xf5, 0x5e, 0x07, 0x68, 0x51, 0x07, 0xe8, + 0xab, 0x0e, 0xd0, 0xd3, 0x32, 0x70, 0x16, 0xcb, 0xc0, 0xf9, 0x5c, 0x06, 0x8e, 0xb7, 0x9f, 0x88, + 0xc2, 0xfa, 0x6d, 0xbd, 0xff, 0x57, 0xea, 0xaf, 0x0e, 0x9a, 0xe5, 0x07, 0xe8, 0xfa, 0x28, 0xcb, + 0xe5, 0xdd, 0x74, 0x84, 0x13, 0x51, 0x10, 0xdb, 0xcf, 0xfa, 0xe2, 0xb6, 0xbb, 0x61, 0xd4, 0x1d, + 0xf6, 0x5f, 0xdd, 0xb5, 0xeb, 0x08, 0x75, 0x91, 0x48, 0xd5, 0x03, 0x73, 0x45, 0xc0, 0xfd, 0x95, + 0xfd, 0x58, 0x23, 0xb1, 0x26, 0x71, 0x14, 0x2b, 0x12, 0x9b, 0x24, 0x56, 0xa4, 0x76, 0x8f, 0x6d, + 0x49, 0x7c, 0x36, 0xe8, 0x85, 0x5c, 0xb2, 0x94, 0x49, 0xf6, 0xe3, 0x1e, 0x18, 0x9c, 0x52, 0xed, + 0x29, 0x8d, 0x28, 0x55, 0x09, 0x94, 0x9a, 0x11, 0x94, 0xaa, 0x8c, 0x51, 0x7b, 0x75, 0x28, 0x7b, + 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x4e, 0x26, 0xd5, 0x35, 0x42, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/assets/transactions/define/service.pb.gw.go b/x/assets/transactions/define/service.pb.gw.go deleted file mode 100644 index b7be2b06d..000000000 --- a/x/assets/transactions/define/service.pb.gw.go +++ /dev/null @@ -1,171 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: AssetMantle/modules/x/assets/transactions/define/service.proto - -/* -Package define is a reverse proxy. - -It translates gRPC into RESTful JSON APIs. -*/ -package define - -import ( - "context" - "io" - "net/http" - - "github.com/golang/protobuf/descriptor" - "github.com/golang/protobuf/proto" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/grpc-ecosystem/grpc-gateway/utilities" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/status" -) - -// Suppress "imported and not used" errors -var _ codes.Code -var _ io.Reader -var _ status.Status -var _ = runtime.String -var _ = utilities.NewDoubleArray -var _ = descriptor.ForMessage -var _ = metadata.Join - -var ( - filter_Msg_Handle_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - -func request_Msg_Handle_0(ctx context.Context, marshaler runtime.Marshaler, client MsgClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq Message - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.Handle(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Msg_Handle_0(ctx context.Context, marshaler runtime.Marshaler, server MsgServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq Message - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.Handle(ctx, &protoReq) - return msg, metadata, err - -} - -// RegisterMsgHandlerServer registers the http handlers for service Msg to "mux". -// UnaryRPC :call MsgServer directly. -// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterMsgHandlerFromEndpoint instead. -func RegisterMsgHandlerServer(ctx context.Context, mux *runtime.ServeMux, server MsgServer) error { - - mux.Handle("POST", pattern_Msg_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Msg_Handle_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Msg_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -// RegisterMsgHandlerFromEndpoint is same as RegisterMsgHandler but -// automatically dials to "endpoint" and closes the connection when "ctx" gets done. -func RegisterMsgHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.Dial(endpoint, opts...) - if err != nil { - return err - } - defer func() { - if err != nil { - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - return - } - go func() { - <-ctx.Done() - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - }() - }() - - return RegisterMsgHandler(ctx, mux, conn) -} - -// RegisterMsgHandler registers the http handlers for service Msg to "mux". -// The handlers forward requests to the grpc endpoint over "conn". -func RegisterMsgHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { - return RegisterMsgHandlerClient(ctx, mux, NewMsgClient(conn)) -} - -// RegisterMsgHandlerClient registers the http handlers for service Msg -// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "MsgClient". -// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "MsgClient" -// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "MsgClient" to call the correct interceptors. -func RegisterMsgHandlerClient(ctx context.Context, mux *runtime.ServeMux, client MsgClient) error { - - mux.Handle("POST", pattern_Msg_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Msg_Handle_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Msg_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -var ( - pattern_Msg_Handle_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"mantle", "assets", "define"}, "", runtime.AssumeColonVerbOpt(false))) -) - -var ( - forward_Msg_Handle_0 = runtime.ForwardResponseMessage -) diff --git a/x/assets/transactions/define/transaction.go b/x/assets/transactions/define/transaction.go index 6242b9071..dac93a936 100644 --- a/x/assets/transactions/define/transaction.go +++ b/x/assets/transactions/define/transaction.go @@ -4,22 +4,14 @@ package define import ( - "context" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "google.golang.org/grpc" - "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/helpers/constants" - "github.com/AssetMantle/modules/utilities/name" + "google.golang.org/grpc" ) -type dummy struct{} - var Transaction = baseHelpers.NewTransaction( - name.GetPackageName(dummy{}), + _Msg_serviceDesc.ServiceName, "", "", @@ -30,9 +22,6 @@ var Transaction = baseHelpers.NewTransaction( func(server grpc.ServiceRegistrar, keeper helpers.TransactionKeeper) { RegisterMsgServer(server, keeper.(transactionKeeper)) }, - func(clientCtx client.Context, mux *runtime.ServeMux) error { - return RegisterMsgHandlerClient(context.Background(), mux, NewMsgClient(clientCtx)) - }, constants.FromIdentityID, constants.ImmutableMetaProperties, diff --git a/x/assets/transactions/define/transaction_keeper.go b/x/assets/transactions/define/transaction_keeper.go index bc3e4d797..8ed438f24 100644 --- a/x/assets/transactions/define/transaction_keeper.go +++ b/x/assets/transactions/define/transaction_keeper.go @@ -5,7 +5,6 @@ package define import ( "context" - "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/x/assets/utilities" "github.com/AssetMantle/modules/x/classifications/auxiliaries/define" @@ -29,7 +28,7 @@ func (transactionKeeper transactionKeeper) Transact(context context.Context, mes } func (transactionKeeper transactionKeeper) Handle(context context.Context, message *Message) (*TransactionResponse, error) { - fromAddress := message.GetFromAddress() + fromAddress := message.GetSigners()[0] if _, err := transactionKeeper.authenticateAuxiliary.GetKeeper().Help(context, authenticate.NewAuxiliaryRequest(fromAddress, message.FromID)); err != nil { return nil, err diff --git a/x/assets/transactions/define/transaction_request.go b/x/assets/transactions/define/transaction_request.go index 87c33eaf2..6dad1da67 100644 --- a/x/assets/transactions/define/transaction_request.go +++ b/x/assets/transactions/define/transaction_request.go @@ -5,27 +5,25 @@ package define import ( "encoding/json" - "github.com/AssetMantle/modules/utilities/rest" - - codecUtilities "github.com/AssetMantle/schema/codec/utilities" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" "github.com/AssetMantle/schema/lists/base" "github.com/cosmos/cosmos-sdk/client" - sdkCodec "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" + "io" + "net/http" "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/helpers/constants" ) type transactionRequest struct { - BaseReq rest.BaseReq `json:"baseReq"` - FromID string `json:"fromID"` - ImmutableMetaProperties string `json:"immutableMetaProperties"` - ImmutableProperties string `json:"immutableProperties"` - MutableMetaProperties string `json:"mutableMetaProperties"` - MutableProperties string `json:"mutableProperties"` + helpers.CommonTransactionRequest `json:"commonTransactionRequest"` + FromID string `json:"fromID"` + ImmutableMetaProperties string `json:"immutableMetaProperties"` + ImmutableProperties string `json:"immutableProperties"` + MutableMetaProperties string `json:"mutableMetaProperties"` + MutableProperties string `json:"mutableProperties"` } var _ helpers.TransactionRequest = (*transactionRequest)(nil) @@ -51,7 +49,7 @@ func (transactionRequest transactionRequest) Validate() error { } func (transactionRequest transactionRequest) FromCLI(cliCommand helpers.CLICommand, context client.Context) (helpers.TransactionRequest, error) { return newTransactionRequest( - cliCommand.ReadBaseReq(context), + cliCommand.ReadCommonTransactionRequest(context), cliCommand.ReadString(constants.FromIdentityID), cliCommand.ReadString(constants.ImmutableMetaProperties), cliCommand.ReadString(constants.ImmutableProperties), @@ -59,18 +57,23 @@ func (transactionRequest transactionRequest) FromCLI(cliCommand helpers.CLIComma cliCommand.ReadString(constants.MutableProperties), ), nil } -func (transactionRequest transactionRequest) FromJSON(rawMessage json.RawMessage) (helpers.TransactionRequest, error) { - if err := json.Unmarshal(rawMessage, &transactionRequest); err != nil { +func (transactionRequest transactionRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.TransactionRequest, error) { + body, err := io.ReadAll(httpRequest.Body) + if err != nil { + return nil, err + } + + if err := json.Unmarshal(body, &transactionRequest); err != nil { return nil, err } return transactionRequest, nil } -func (transactionRequest transactionRequest) GetBaseReq() rest.BaseReq { - return transactionRequest.BaseReq +func (transactionRequest transactionRequest) GetCommonTransactionRequest() helpers.CommonTransactionRequest { + return transactionRequest.CommonTransactionRequest } func (transactionRequest transactionRequest) MakeMsg() (sdkTypes.Msg, error) { - from, err := sdkTypes.AccAddressFromBech32(transactionRequest.GetBaseReq().From) + from, err := sdkTypes.AccAddressFromBech32(transactionRequest.GetCommonTransactionRequest().GetFrom()) if err != nil { return nil, err } @@ -111,20 +114,17 @@ func (transactionRequest transactionRequest) MakeMsg() (sdkTypes.Msg, error) { mutableProperties, ), nil } -func (transactionRequest) RegisterLegacyAminoCodec(legacyAmino *sdkCodec.LegacyAmino) { - codecUtilities.RegisterModuleConcrete(legacyAmino, transactionRequest{}) -} func requestPrototype() helpers.TransactionRequest { return transactionRequest{} } -func newTransactionRequest(baseReq rest.BaseReq, fromID string, immutableMetaProperties string, immutableProperties string, mutableMetaProperties string, mutableProperties string) helpers.TransactionRequest { +func newTransactionRequest(commonTransactionRequest helpers.CommonTransactionRequest, fromID string, immutableMetaProperties string, immutableProperties string, mutableMetaProperties string, mutableProperties string) helpers.TransactionRequest { return transactionRequest{ - BaseReq: baseReq, - FromID: fromID, - ImmutableMetaProperties: immutableMetaProperties, - ImmutableProperties: immutableProperties, - MutableMetaProperties: mutableMetaProperties, - MutableProperties: mutableProperties, + CommonTransactionRequest: commonTransactionRequest, + FromID: fromID, + ImmutableMetaProperties: immutableMetaProperties, + ImmutableProperties: immutableProperties, + MutableMetaProperties: mutableMetaProperties, + MutableProperties: mutableProperties, } } diff --git a/x/assets/transactions/define/transaction_request_test.go b/x/assets/transactions/define/transaction_request_test.go index d5b762988..8b269e218 100644 --- a/x/assets/transactions/define/transaction_request_test.go +++ b/x/assets/transactions/define/transaction_request_test.go @@ -4,29 +4,26 @@ package define import ( - "encoding/json" "fmt" - "github.com/AssetMantle/modules/utilities/rest" - "reflect" - "testing" - baseData "github.com/AssetMantle/schema/data/base" baseIDs "github.com/AssetMantle/schema/ids/base" baseLists "github.com/AssetMantle/schema/lists/base" baseProperties "github.com/AssetMantle/schema/properties/base" + "reflect" + "testing" + "github.com/cosmos/cosmos-sdk/client" - sdkCodec "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/types" "github.com/spf13/viper" "github.com/AssetMantle/modules/helpers" - "github.com/AssetMantle/modules/helpers/base" + baseHelpers "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/helpers/constants" ) var ( - testBaseRequest = rest.BaseReq{From: fromAddress, ChainID: "test", Fees: types.NewCoins()} + commonTransactionRequest = helpers.PrototypeCommonTransactionRequest() immutableMetaPropertiesString = "testImmutableMeta1:S|immutableMeta" immutableMetaProperties1 = baseLists.NewPropertyList(baseProperties.NewMetaProperty(baseIDs.NewStringID("testImmutableMeta1"), baseData.NewStringData("immutableMeta"))) immutablePropertiesString = "testImmutable1:S|immutable" @@ -39,23 +36,23 @@ var ( func Test_newTransactionRequest(t *testing.T) { type args struct { - baseReq rest.BaseReq - fromID string - immutableMetaProperties string - immutableProperties string - mutableMetaProperties string - mutableProperties string + commonTransactionRequest helpers.CommonTransactionRequest + fromID string + immutableMetaProperties string + immutableProperties string + mutableMetaProperties string + mutableProperties string } tests := []struct { name string args args want helpers.TransactionRequest }{ - {"+ve", args{testBaseRequest, fromID.AsString(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, transactionRequest{testBaseRequest, fromID.AsString(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}}, + {"+ve", args{commonTransactionRequest, fromID.AsString(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, transactionRequest{commonTransactionRequest, fromID.AsString(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - if got := newTransactionRequest(tt.args.baseReq, tt.args.fromID, tt.args.immutableMetaProperties, tt.args.immutableProperties, tt.args.mutableMetaProperties, tt.args.mutableProperties); !reflect.DeepEqual(got, tt.want) { + if got := newTransactionRequest(tt.args.commonTransactionRequest, tt.args.fromID, tt.args.immutableMetaProperties, tt.args.immutableProperties, tt.args.mutableMetaProperties, tt.args.mutableProperties); !reflect.DeepEqual(got, tt.want) { t.Errorf("newTransactionRequest() = %v, want %v", got, tt.want) } }) @@ -79,7 +76,7 @@ func Test_requestPrototype(t *testing.T) { } func Test_transactionRequest_FromCLI(t *testing.T) { - cliCommand := base.NewCLICommand("", "", "", []helpers.CLIFlag{constants.FromIdentityID, constants.ImmutableMetaProperties, constants.ImmutableProperties, constants.MutableMetaProperties, constants.MutableProperties}) + cliCommand := baseHelpers.NewCLICommand("", "", "", []helpers.CLIFlag{constants.FromIdentityID, constants.ImmutableMetaProperties, constants.ImmutableProperties, constants.MutableMetaProperties, constants.MutableProperties}) viper.Set(constants.ImmutableMetaProperties.GetName(), immutableMetaPropertiesString) viper.Set(constants.ImmutableProperties.GetName(), immutablePropertiesString) @@ -87,12 +84,12 @@ func Test_transactionRequest_FromCLI(t *testing.T) { viper.Set(constants.MutableProperties.GetName(), mutablePropertiesString) viper.Set(constants.FromIdentityID.GetName(), fromID.AsString()) type fields struct { - BaseReq rest.BaseReq - FromID string - ImmutableMetaProperties string - ImmutableProperties string - MutableMetaProperties string - MutableProperties string + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + ImmutableMetaProperties string + ImmutableProperties string + MutableMetaProperties string + MutableProperties string } type args struct { cliCommand helpers.CLICommand @@ -105,17 +102,17 @@ func Test_transactionRequest_FromCLI(t *testing.T) { want helpers.TransactionRequest wantErr bool }{ - {"+ve", fields{testBaseRequest, fromID.AsString(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, args{cliCommand, client.Context{}.WithCodec(base.CodecPrototype())}, transactionRequest{testBaseRequest, fromID.AsString(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, false}, + {"+ve", fields{commonTransactionRequest, fromID.AsString(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, args{cliCommand, client.Context{}.WithCodec(baseHelpers.CodecPrototype())}, transactionRequest{commonTransactionRequest, fromID.AsString(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, - ImmutableProperties: tt.fields.ImmutableProperties, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, + ImmutableProperties: tt.fields.ImmutableProperties, + MutableMetaProperties: tt.fields.MutableMetaProperties, + MutableProperties: tt.fields.MutableProperties, } got, err := transactionRequest.FromCLI(tt.args.cliCommand, tt.args.context) if (err != nil) != tt.wantErr { @@ -129,77 +126,34 @@ func Test_transactionRequest_FromCLI(t *testing.T) { } } -func Test_transactionRequest_FromJSON(t *testing.T) { - type fields struct { - BaseReq rest.BaseReq - FromID string - ImmutableMetaProperties string - ImmutableProperties string - MutableMetaProperties string - MutableProperties string - } - type args struct { - rawMessage json.RawMessage - } - tests := []struct { - name string - fields fields - args args - want helpers.TransactionRequest - wantErr bool - }{ - {"+ve", fields{testBaseRequest, fromID.AsString(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, args{types.MustSortJSON(base.CodecPrototype().MustMarshalJSON(&Message{fromAccAddress.String(), fromID, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties}))}, newTransactionRequest(testBaseRequest, fromID.AsString(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString), false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, - ImmutableProperties: tt.fields.ImmutableProperties, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, - } - got, err := transactionRequest.FromJSON(tt.args.rawMessage) - if (err != nil) != tt.wantErr { - t.Errorf("FromJSON() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("FromJSON() got = %v, want %v", got, tt.want) - } - }) - } -} - func Test_transactionRequest_GetBaseReq(t *testing.T) { type fields struct { - BaseReq rest.BaseReq - FromID string - ImmutableMetaProperties string - ImmutableProperties string - MutableMetaProperties string - MutableProperties string + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + ImmutableMetaProperties string + ImmutableProperties string + MutableMetaProperties string + MutableProperties string } tests := []struct { name string fields fields - want rest.BaseReq + want helpers.CommonTransactionRequest }{ - {"+ve", fields{testBaseRequest, fromID.AsString(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, testBaseRequest}, + {"+ve", fields{commonTransactionRequest, fromID.AsString(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, commonTransactionRequest}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, - ImmutableProperties: tt.fields.ImmutableProperties, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, + ImmutableProperties: tt.fields.ImmutableProperties, + MutableMetaProperties: tt.fields.MutableMetaProperties, + MutableProperties: tt.fields.MutableProperties, } - if got := transactionRequest.GetBaseReq(); !reflect.DeepEqual(got, tt.want) { - t.Errorf("GetBaseReq() = %v, want %v", got, tt.want) + if got := transactionRequest.GetCommonTransactionRequest(); !reflect.DeepEqual(got, tt.want) { + t.Errorf("GetCommonTransactionRequest() = %v, want %v", got, tt.want) } }) } @@ -207,12 +161,12 @@ func Test_transactionRequest_GetBaseReq(t *testing.T) { func Test_transactionRequest_MakeMsg(t *testing.T) { type fields struct { - BaseReq rest.BaseReq - FromID string - ImmutableMetaProperties string - ImmutableProperties string - MutableMetaProperties string - MutableProperties string + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + ImmutableMetaProperties string + ImmutableProperties string + MutableMetaProperties string + MutableProperties string } tests := []struct { name string @@ -220,17 +174,17 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { want types.Msg wantErr bool }{ - {"+ve", fields{testBaseRequest, fromID.AsString(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, NewMessage(fromAccAddress, fromID, immutableMetaProperties1, immutableProperties1.ScrubData(), mutableMetaProperties1, mutableProperties1.ScrubData()), false}, + {"+ve", fields{commonTransactionRequest, fromID.AsString(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, NewMessage(fromAccAddress, fromID, immutableMetaProperties1, immutableProperties1.ScrubData(), mutableMetaProperties1, mutableProperties1.ScrubData()), false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, - ImmutableProperties: tt.fields.ImmutableProperties, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, + ImmutableProperties: tt.fields.ImmutableProperties, + MutableMetaProperties: tt.fields.MutableMetaProperties, + MutableProperties: tt.fields.MutableProperties, } got, err := transactionRequest.MakeMsg() if (err != nil) != tt.wantErr { @@ -244,65 +198,31 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { } } -func Test_transactionRequest_RegisterCodec(t *testing.T) { - type fields struct { - BaseReq rest.BaseReq - FromID string - ImmutableMetaProperties string - ImmutableProperties string - MutableMetaProperties string - MutableProperties string - } - type args struct { - legacyAmino *sdkCodec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{testBaseRequest, fromID.AsString(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, args{sdkCodec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - tr := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, - ImmutableProperties: tt.fields.ImmutableProperties, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, - } - tr.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - func Test_transactionRequest_Validate(t *testing.T) { type fields struct { - BaseReq rest.BaseReq - FromID string - ImmutableMetaProperties string - ImmutableProperties string - MutableMetaProperties string - MutableProperties string + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + ImmutableMetaProperties string + ImmutableProperties string + MutableMetaProperties string + MutableProperties string } tests := []struct { name string fields fields wantErr bool }{ - {"+ve", fields{testBaseRequest, fromID.AsString(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, false}, + {"+ve", fields{commonTransactionRequest, fromID.AsString(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, - ImmutableProperties: tt.fields.ImmutableProperties, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, + ImmutableProperties: tt.fields.ImmutableProperties, + MutableMetaProperties: tt.fields.MutableMetaProperties, + MutableProperties: tt.fields.MutableProperties, } if err := transactionRequest.Validate(); (err != nil) != tt.wantErr { t.Errorf("ValidateBasic() error = %v, wantErr %v", err, tt.wantErr) diff --git a/x/assets/transactions/define/transaction_response.go b/x/assets/transactions/define/transaction_response.go index 967e6fe64..f6ca39134 100644 --- a/x/assets/transactions/define/transaction_response.go +++ b/x/assets/transactions/define/transaction_response.go @@ -4,11 +4,10 @@ package define import ( + "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" sdkTypes "github.com/cosmos/cosmos-sdk/types" - - "github.com/AssetMantle/modules/helpers" ) var _ helpers.TransactionResponse = (*TransactionResponse)(nil) diff --git a/x/assets/transactions/deputize/message.go b/x/assets/transactions/deputize/message.go index 4e664c65e..591038184 100644 --- a/x/assets/transactions/deputize/message.go +++ b/x/assets/transactions/deputize/message.go @@ -4,28 +4,17 @@ package deputize import ( - codecUtilities "github.com/AssetMantle/schema/codec/utilities" + "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" "github.com/AssetMantle/schema/lists" baseLists "github.com/AssetMantle/schema/lists/base" - sdkCodec "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/types" sdkTypes "github.com/cosmos/cosmos-sdk/types" - - "github.com/AssetMantle/modules/helpers" ) var _ helpers.Message = (*Message)(nil) -func (message *Message) Type() string { return Transaction.GetName() } -func (message *Message) GetFromAddress() sdkTypes.AccAddress { - from, err := sdkTypes.AccAddressFromBech32(message.From) - if err != nil { - panic(err) - } - return from -} func (message *Message) ValidateBasic() error { if _, err := sdkTypes.AccAddressFromBech32(message.From); err != nil { return err @@ -51,21 +40,10 @@ func (message *Message) GetSigners() []sdkTypes.AccAddress { } return []sdkTypes.AccAddress{from} } -func (*Message) RegisterLegacyAminoCodec(legacyAmino *sdkCodec.LegacyAmino) { - codecUtilities.RegisterModuleConcrete(legacyAmino, Message{}) -} func (message *Message) RegisterInterface(interfaceRegistry types.InterfaceRegistry) { interfaceRegistry.RegisterImplementations((*sdkTypes.Msg)(nil), message) } -func messageFromInterface(msg sdkTypes.Msg) *Message { - switch value := msg.(type) { - case *Message: - return value - default: - return &Message{} - } -} func messagePrototype() helpers.Message { return &Message{} } diff --git a/x/assets/transactions/deputize/message_test.go b/x/assets/transactions/deputize/message_test.go index 420554cba..9e4c89009 100644 --- a/x/assets/transactions/deputize/message_test.go +++ b/x/assets/transactions/deputize/message_test.go @@ -14,7 +14,6 @@ import ( baseLists "github.com/AssetMantle/schema/lists/base" baseProperties "github.com/AssetMantle/schema/properties/base" baseQualified "github.com/AssetMantle/schema/qualified/base" - sdkCodec "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" "github.com/AssetMantle/modules/helpers" @@ -44,26 +43,6 @@ type fields struct { CanMutateMaintainer bool } -func Test_messageFromInterface(t *testing.T) { - type args struct { - msg sdkTypes.Msg - } - tests := []struct { - name string - args args - want helpers.Message - }{ - {"+ve", args{NewMessage(fromAccAddress, fromID, fromID, classificationID, mutableMetaProperties, true, true, true, true, true, true).(*Message)}, NewMessage(fromAccAddress, fromID, fromID, classificationID, mutableMetaProperties, true, true, true, true, true, true).(*Message)}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := messageFromInterface(tt.args.msg); !reflect.DeepEqual(got, tt.want) { - t.Errorf("messageFromInterface() = %v, want %v", got, tt.want) - } - }) - } -} - func Test_messagePrototype(t *testing.T) { tests := []struct { name string @@ -111,70 +90,6 @@ func Test_message_GetSigners(t *testing.T) { } } -func Test_message_RegisterCodec(t *testing.T) { - - type args struct { - legacyAmino *sdkCodec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve with nil", fields{}, args{sdkCodec.NewLegacyAmino()}}, - {"+ve", fields{fromAccAddress.String(), fromID, fromID, classificationID, mutableMetaProperties, true, true, true, true, true, true}, args{sdkCodec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - me := &Message{ - From: tt.fields.From, - FromID: tt.fields.FromID, - ToID: tt.fields.ToID, - ClassificationID: tt.fields.ClassificationID, - MaintainedProperties: tt.fields.MaintainedProperties, - CanMintAsset: tt.fields.CanMintAsset, - CanBurnAsset: tt.fields.CanBurnAsset, - CanRenumerateAsset: tt.fields.CanRenumerateAsset, - CanAddMaintainer: tt.fields.CanAddMaintainer, - CanRemoveMaintainer: tt.fields.CanRemoveMaintainer, - CanMutateMaintainer: tt.fields.CanMutateMaintainer, - } - me.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - -func Test_message_Type(t *testing.T) { - - tests := []struct { - name string - fields fields - want string - }{ - {"+ve", fields{fromAccAddress.String(), fromID, fromID, classificationID, mutableMetaProperties, true, true, true, true, true, true}, Transaction.GetName()}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - message := &Message{ - From: tt.fields.From, - FromID: tt.fields.FromID, - ToID: tt.fields.ToID, - ClassificationID: tt.fields.ClassificationID, - MaintainedProperties: tt.fields.MaintainedProperties, - CanMintAsset: tt.fields.CanMintAsset, - CanBurnAsset: tt.fields.CanBurnAsset, - CanRenumerateAsset: tt.fields.CanRenumerateAsset, - CanAddMaintainer: tt.fields.CanAddMaintainer, - CanRemoveMaintainer: tt.fields.CanRemoveMaintainer, - CanMutateMaintainer: tt.fields.CanMutateMaintainer, - } - if got := message.Type(); got != tt.want { - t.Errorf("Type() = %v, want %v", got, tt.want) - } - }) - } -} - func Test_message_ValidateBasic(t *testing.T) { tests := []struct { diff --git a/x/assets/transactions/deputize/service.pb.go b/x/assets/transactions/deputize/service.pb.go index 87033b529..3a8994ef8 100644 --- a/x/assets/transactions/deputize/service.pb.go +++ b/x/assets/transactions/deputize/service.pb.go @@ -6,9 +6,9 @@ package deputize import ( context "context" fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types/msgservice" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" - _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -31,30 +31,30 @@ func init() { } var fileDescriptor_da0b5d193ea2455f = []byte{ - // 368 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x92, 0xc1, 0x4a, 0xeb, 0x40, - 0x14, 0x86, 0x9b, 0x14, 0xba, 0x08, 0x77, 0xd5, 0xcd, 0xe5, 0x86, 0x4b, 0x2e, 0xf4, 0x01, 0x66, - 0xa0, 0x17, 0x14, 0x46, 0x14, 0x5b, 0x0a, 0x75, 0x13, 0x28, 0xda, 0x45, 0x90, 0x80, 0x4c, 0x93, - 0x21, 0x06, 0x92, 0x99, 0x90, 0x33, 0x95, 0xe2, 0xd2, 0xbd, 0x20, 0xf8, 0x06, 0x2e, 0xdd, 0xb8, - 0xf4, 0x15, 0xc4, 0x55, 0xc1, 0x8d, 0x4b, 0x49, 0x5d, 0xf9, 0x14, 0xd2, 0xce, 0x04, 0xa7, 0xcb, - 0x66, 0x7b, 0x98, 0xef, 0xe3, 0xff, 0xcf, 0x1c, 0xe7, 0x78, 0x00, 0xc0, 0xa4, 0x4f, 0xb9, 0xcc, - 0x18, 0xce, 0x45, 0x3c, 0xcf, 0x18, 0xe0, 0x05, 0xa6, 0xeb, 0x29, 0x60, 0x59, 0x52, 0x0e, 0x34, - 0x92, 0xa9, 0xe0, 0x80, 0x63, 0x56, 0xcc, 0x65, 0x7a, 0xcd, 0x30, 0xb0, 0xf2, 0x2a, 0x8d, 0x18, - 0x2a, 0x4a, 0x21, 0x45, 0xb7, 0x6f, 0x18, 0x90, 0x36, 0xa0, 0x05, 0x52, 0x06, 0x64, 0x1a, 0x50, - 0x6d, 0x70, 0xff, 0x26, 0x42, 0x24, 0x19, 0xc3, 0xb4, 0x48, 0x31, 0xe5, 0x5c, 0x48, 0xaa, 0x1e, - 0x6c, 0x8c, 0x6e, 0x93, 0x4c, 0x39, 0x03, 0xa0, 0x89, 0xce, 0xe4, 0xfa, 0x0d, 0x0c, 0xc6, 0xf4, - 0xa2, 0x64, 0x50, 0x08, 0x0e, 0x5a, 0xd7, 0x7f, 0xb6, 0x9c, 0xb6, 0x0f, 0x49, 0xf7, 0xc9, 0x72, - 0x3a, 0x27, 0x94, 0xc7, 0x19, 0xeb, 0x1e, 0xa0, 0xdd, 0x6b, 0x23, 0x5f, 0x85, 0x74, 0xc7, 0x4d, - 0xe0, 0xe9, 0xcf, 0xf4, 0x54, 0xc7, 0xeb, 0xfd, 0xbb, 0x79, 0xfb, 0xbc, 0xb7, 0xff, 0xf4, 0x7e, - 0xe3, 0x5c, 0x75, 0xd5, 0x0d, 0x6b, 0x68, 0x78, 0xdb, 0x7e, 0xa9, 0x3c, 0x6b, 0x59, 0x79, 0xd6, - 0x47, 0xe5, 0x59, 0x77, 0x2b, 0xaf, 0xb5, 0x5c, 0x79, 0xad, 0xf7, 0x95, 0xd7, 0x72, 0xf6, 0x22, - 0x91, 0x37, 0xc8, 0x31, 0xfc, 0x75, 0xa6, 0xbe, 0x7f, 0xb2, 0x5e, 0xcd, 0xc4, 0x3a, 0x3f, 0x4c, - 0x52, 0x79, 0x39, 0x9f, 0xa1, 0x48, 0xe4, 0x78, 0xf7, 0xb5, 0x3f, 0xd8, 0x9d, 0x81, 0x1f, 0x0c, - 0xa6, 0xa3, 0x47, 0x7b, 0xeb, 0x90, 0x7c, 0x1d, 0x26, 0x50, 0x11, 0xc1, 0xac, 0x0f, 0x68, 0xa4, - 0xe9, 0xd7, 0x2d, 0x28, 0xd4, 0x50, 0x18, 0x84, 0x0a, 0x0a, 0x4d, 0x28, 0xac, 0xa1, 0xca, 0x3e, - 0xda, 0x1d, 0x0a, 0xc7, 0x93, 0xa1, 0xcf, 0x24, 0x8d, 0xa9, 0xa4, 0x5f, 0xf6, 0xbe, 0x21, 0x20, - 0x44, 0x1b, 0x08, 0x09, 0x08, 0x51, 0x0e, 0x42, 0x4c, 0x09, 0x21, 0xb5, 0x65, 0xd6, 0xd9, 0x1c, - 0xd4, 0xff, 0xef, 0x00, 0x00, 0x00, 0xff, 0xff, 0x4c, 0xcf, 0xe6, 0xfa, 0x77, 0x03, 0x00, 0x00, + // 355 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x92, 0x31, 0x4b, 0xf3, 0x40, + 0x18, 0xc7, 0x73, 0x29, 0x6f, 0x87, 0xf0, 0x4e, 0x5d, 0x84, 0x0c, 0x19, 0x1c, 0x1d, 0xee, 0xb0, + 0x82, 0xc2, 0x89, 0x62, 0x4b, 0xa1, 0x2e, 0x07, 0x45, 0x3b, 0x04, 0x09, 0xc8, 0x35, 0x39, 0x62, + 0xa0, 0xc9, 0x95, 0x3c, 0xd7, 0x52, 0x9c, 0xfc, 0x02, 0x42, 0xbf, 0x81, 0xe0, 0xe8, 0xe4, 0xc7, + 0x10, 0xa7, 0x8e, 0x8e, 0x92, 0x0e, 0x82, 0x9f, 0x42, 0xea, 0x5d, 0xf1, 0x3a, 0x36, 0x53, 0xe0, + 0x0f, 0xbf, 0x5f, 0xfe, 0xcf, 0x73, 0x8f, 0x77, 0xd1, 0x01, 0x10, 0x8a, 0xf1, 0x42, 0x8d, 0x05, + 0xc9, 0x65, 0x32, 0x1d, 0x0b, 0x20, 0x73, 0xc2, 0xd7, 0x29, 0x10, 0x55, 0xf2, 0x02, 0x78, 0xac, + 0x32, 0x59, 0x00, 0x49, 0xc4, 0x64, 0xaa, 0xb2, 0x7b, 0x41, 0x40, 0x94, 0xb3, 0x2c, 0x16, 0x78, + 0x52, 0x4a, 0x25, 0x5b, 0x6d, 0xcb, 0x80, 0x8d, 0x01, 0xcf, 0xb1, 0x36, 0x60, 0xdb, 0x80, 0x37, + 0x06, 0x7f, 0x2f, 0x96, 0x90, 0x4b, 0x20, 0x39, 0xa4, 0x64, 0x76, 0xb8, 0xfe, 0x68, 0x99, 0x5f, + 0xa7, 0x4e, 0x2e, 0x00, 0x78, 0x6a, 0xea, 0xf8, 0xac, 0x86, 0xc1, 0x4a, 0x6f, 0x4b, 0x01, 0x13, + 0x59, 0x80, 0xd1, 0xb5, 0x9f, 0x90, 0xd7, 0x60, 0x90, 0xb6, 0x16, 0xc8, 0x6b, 0x5e, 0xf2, 0x22, + 0x19, 0x8b, 0xd6, 0x29, 0xde, 0x7d, 0x62, 0xcc, 0x74, 0x49, 0xbf, 0x5f, 0x07, 0x1e, 0xfe, 0xa5, + 0x57, 0xa6, 0xde, 0xbe, 0xe3, 0xff, 0x7b, 0xf8, 0x7a, 0x3d, 0x40, 0xdd, 0xc7, 0xc6, 0x5b, 0x15, + 0xa0, 0x65, 0x15, 0xa0, 0xcf, 0x2a, 0x40, 0x8b, 0x55, 0xe0, 0x2c, 0x57, 0x81, 0xf3, 0xb1, 0x0a, + 0x1c, 0xef, 0x38, 0x96, 0x79, 0x8d, 0xff, 0x75, 0xff, 0x5f, 0xeb, 0x17, 0x1e, 0xac, 0x57, 0x30, + 0x40, 0x37, 0x67, 0x69, 0xa6, 0xee, 0xa6, 0x23, 0x1c, 0xcb, 0x9c, 0xec, 0xbe, 0xde, 0x67, 0xb7, + 0xd9, 0x61, 0x61, 0x67, 0xd8, 0x7b, 0x71, 0xb7, 0x6e, 0x85, 0x99, 0x32, 0xa1, 0xae, 0x08, 0xf6, + 0x98, 0x80, 0x7b, 0x86, 0x7e, 0xdf, 0x82, 0x22, 0x03, 0x45, 0x61, 0xa4, 0xa1, 0xc8, 0x86, 0xa2, + 0x0d, 0x54, 0xb9, 0xe7, 0xbb, 0x43, 0x51, 0x7f, 0xd0, 0x65, 0x42, 0xf1, 0x84, 0x2b, 0xfe, 0xed, + 0x9e, 0x58, 0x02, 0x4a, 0x8d, 0x81, 0xd2, 0x90, 0x52, 0xed, 0xa0, 0xd4, 0x96, 0x50, 0xba, 0xb1, + 0x8c, 0x9a, 0xbf, 0x87, 0x73, 0xf4, 0x13, 0x00, 0x00, 0xff, 0xff, 0xfa, 0x85, 0x92, 0x4c, 0x5a, + 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/assets/transactions/deputize/service.pb.gw.go b/x/assets/transactions/deputize/service.pb.gw.go deleted file mode 100644 index f7c701db4..000000000 --- a/x/assets/transactions/deputize/service.pb.gw.go +++ /dev/null @@ -1,171 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: AssetMantle/modules/x/assets/transactions/deputize/service.proto - -/* -Package deputize is a reverse proxy. - -It translates gRPC into RESTful JSON APIs. -*/ -package deputize - -import ( - "context" - "io" - "net/http" - - "github.com/golang/protobuf/descriptor" - "github.com/golang/protobuf/proto" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/grpc-ecosystem/grpc-gateway/utilities" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/status" -) - -// Suppress "imported and not used" errors -var _ codes.Code -var _ io.Reader -var _ status.Status -var _ = runtime.String -var _ = utilities.NewDoubleArray -var _ = descriptor.ForMessage -var _ = metadata.Join - -var ( - filter_Msg_Handle_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - -func request_Msg_Handle_0(ctx context.Context, marshaler runtime.Marshaler, client MsgClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq Message - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.Handle(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Msg_Handle_0(ctx context.Context, marshaler runtime.Marshaler, server MsgServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq Message - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.Handle(ctx, &protoReq) - return msg, metadata, err - -} - -// RegisterMsgHandlerServer registers the http handlers for service Msg to "mux". -// UnaryRPC :call MsgServer directly. -// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterMsgHandlerFromEndpoint instead. -func RegisterMsgHandlerServer(ctx context.Context, mux *runtime.ServeMux, server MsgServer) error { - - mux.Handle("POST", pattern_Msg_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Msg_Handle_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Msg_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -// RegisterMsgHandlerFromEndpoint is same as RegisterMsgHandler but -// automatically dials to "endpoint" and closes the connection when "ctx" gets done. -func RegisterMsgHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.Dial(endpoint, opts...) - if err != nil { - return err - } - defer func() { - if err != nil { - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - return - } - go func() { - <-ctx.Done() - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - }() - }() - - return RegisterMsgHandler(ctx, mux, conn) -} - -// RegisterMsgHandler registers the http handlers for service Msg to "mux". -// The handlers forward requests to the grpc endpoint over "conn". -func RegisterMsgHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { - return RegisterMsgHandlerClient(ctx, mux, NewMsgClient(conn)) -} - -// RegisterMsgHandlerClient registers the http handlers for service Msg -// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "MsgClient". -// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "MsgClient" -// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "MsgClient" to call the correct interceptors. -func RegisterMsgHandlerClient(ctx context.Context, mux *runtime.ServeMux, client MsgClient) error { - - mux.Handle("POST", pattern_Msg_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Msg_Handle_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Msg_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -var ( - pattern_Msg_Handle_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"mantle", "assets", "deputize"}, "", runtime.AssumeColonVerbOpt(false))) -) - -var ( - forward_Msg_Handle_0 = runtime.ForwardResponseMessage -) diff --git a/x/assets/transactions/deputize/transaction.go b/x/assets/transactions/deputize/transaction.go index 4d856611f..5e3fbe2f0 100644 --- a/x/assets/transactions/deputize/transaction.go +++ b/x/assets/transactions/deputize/transaction.go @@ -4,22 +4,14 @@ package deputize import ( - "context" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "google.golang.org/grpc" - "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/helpers/constants" - "github.com/AssetMantle/modules/utilities/name" + "google.golang.org/grpc" ) -type dummy struct{} - var Transaction = baseHelpers.NewTransaction( - name.GetPackageName(dummy{}), + _Msg_serviceDesc.ServiceName, "", "", @@ -30,9 +22,6 @@ var Transaction = baseHelpers.NewTransaction( func(server grpc.ServiceRegistrar, keeper helpers.TransactionKeeper) { RegisterMsgServer(server, keeper.(transactionKeeper)) }, - func(clientCtx client.Context, mux *runtime.ServeMux) error { - return RegisterMsgHandlerClient(context.Background(), mux, NewMsgClient(clientCtx)) - }, constants.FromIdentityID, constants.ToIdentityID, diff --git a/x/assets/transactions/deputize/transaction_keeper.go b/x/assets/transactions/deputize/transaction_keeper.go index fa59c26be..7006bc035 100644 --- a/x/assets/transactions/deputize/transaction_keeper.go +++ b/x/assets/transactions/deputize/transaction_keeper.go @@ -5,7 +5,6 @@ package deputize import ( "context" - "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/x/assets/utilities" "github.com/AssetMantle/modules/x/identities/auxiliaries/authenticate" @@ -26,7 +25,7 @@ func (transactionKeeper transactionKeeper) Transact(context context.Context, mes } func (transactionKeeper transactionKeeper) Handle(context context.Context, message *Message) (*TransactionResponse, error) { - fromAddress := message.GetFromAddress() + fromAddress := message.GetSigners()[0] if _, err := transactionKeeper.authenticateAuxiliary.GetKeeper().Help(context, authenticate.NewAuxiliaryRequest(fromAddress, message.FromID)); err != nil { return nil, err diff --git a/x/assets/transactions/deputize/transaction_request.go b/x/assets/transactions/deputize/transaction_request.go index f64f2e69f..e154b0c63 100644 --- a/x/assets/transactions/deputize/transaction_request.go +++ b/x/assets/transactions/deputize/transaction_request.go @@ -5,32 +5,30 @@ package deputize import ( "encoding/json" - "github.com/AssetMantle/modules/utilities/rest" - - codecUtilities "github.com/AssetMantle/schema/codec/utilities" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" "github.com/AssetMantle/schema/lists/base" "github.com/cosmos/cosmos-sdk/client" - sdkCodec "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" + "io" + "net/http" "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/helpers/constants" ) type transactionRequest struct { - BaseReq rest.BaseReq `json:"baseReq"` - FromID string `json:"fromID"` - ToID string `json:"toID"` - ClassificationID string `json:"classificationID"` - MaintainedProperties string `json:"maintainedProperties"` - CanMintAsset bool `json:"canMintAsset"` - CanRenumerateAsset bool `json:"canRenumerateAsset"` - CanBurnAsset bool `json:"canBurnAsset"` - CanAddMaintainer bool `json:"canAddMaintainer"` - CanRemoveMaintainer bool `json:"canRemoveMaintainer"` - CanMutateMaintainer bool `json:"canMutateMaintainer"` + helpers.CommonTransactionRequest `json:"commonTransactionRequest"` + FromID string `json:"fromID"` + ToID string `json:"toID"` + ClassificationID string `json:"classificationID"` + MaintainedProperties string `json:"maintainedProperties"` + CanMintAsset bool `json:"canMintAsset"` + CanRenumerateAsset bool `json:"canRenumerateAsset"` + CanBurnAsset bool `json:"canBurnAsset"` + CanAddMaintainer bool `json:"canAddMaintainer"` + CanRemoveMaintainer bool `json:"canRemoveMaintainer"` + CanMutateMaintainer bool `json:"canMutateMaintainer"` } var _ helpers.TransactionRequest = (*transactionRequest)(nil) @@ -56,7 +54,7 @@ func (transactionRequest transactionRequest) Validate() error { } func (transactionRequest transactionRequest) FromCLI(cliCommand helpers.CLICommand, context client.Context) (helpers.TransactionRequest, error) { return newTransactionRequest( - cliCommand.ReadBaseReq(context), + cliCommand.ReadCommonTransactionRequest(context), cliCommand.ReadString(constants.FromIdentityID), cliCommand.ReadString(constants.ToIdentityID), cliCommand.ReadString(constants.ClassificationID), @@ -69,18 +67,23 @@ func (transactionRequest transactionRequest) FromCLI(cliCommand helpers.CLIComma cliCommand.ReadBool(constants.CanMutateMaintainer), ), nil } -func (transactionRequest transactionRequest) FromJSON(rawMessage json.RawMessage) (helpers.TransactionRequest, error) { - if err := json.Unmarshal(rawMessage, &transactionRequest); err != nil { +func (transactionRequest transactionRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.TransactionRequest, error) { + body, err := io.ReadAll(httpRequest.Body) + if err != nil { + return nil, err + } + + if err := json.Unmarshal(body, &transactionRequest); err != nil { return nil, err } return transactionRequest, nil } -func (transactionRequest transactionRequest) GetBaseReq() rest.BaseReq { - return transactionRequest.BaseReq +func (transactionRequest transactionRequest) GetCommonTransactionRequest() helpers.CommonTransactionRequest { + return transactionRequest.CommonTransactionRequest } func (transactionRequest transactionRequest) MakeMsg() (sdkTypes.Msg, error) { - from, err := sdkTypes.AccAddressFromBech32(transactionRequest.GetBaseReq().From) + from, err := sdkTypes.AccAddressFromBech32(transactionRequest.GetCommonTransactionRequest().GetFrom()) if err != nil { return nil, err } @@ -119,25 +122,22 @@ func (transactionRequest transactionRequest) MakeMsg() (sdkTypes.Msg, error) { transactionRequest.CanMutateMaintainer, ), nil } -func (transactionRequest) RegisterLegacyAminoCodec(legacyAmino *sdkCodec.LegacyAmino) { - codecUtilities.RegisterModuleConcrete(legacyAmino, transactionRequest{}) -} func requestPrototype() helpers.TransactionRequest { return transactionRequest{} } -func newTransactionRequest(baseReq rest.BaseReq, fromID string, toID string, classificationID string, maintainedProperties string, canMintAsset bool, canRenumerateAsset bool, canBurnAsset bool, canAddMaintainer bool, canRemoveMaintainer bool, canMutateMaintainer bool) helpers.TransactionRequest { +func newTransactionRequest(commonTransactionRequest helpers.CommonTransactionRequest, fromID string, toID string, classificationID string, maintainedProperties string, canMintAsset bool, canRenumerateAsset bool, canBurnAsset bool, canAddMaintainer bool, canRemoveMaintainer bool, canMutateMaintainer bool) helpers.TransactionRequest { return transactionRequest{ - BaseReq: baseReq, - FromID: fromID, - ToID: toID, - ClassificationID: classificationID, - MaintainedProperties: maintainedProperties, - CanMintAsset: canMintAsset, - CanRenumerateAsset: canRenumerateAsset, - CanBurnAsset: canBurnAsset, - CanAddMaintainer: canAddMaintainer, - CanRemoveMaintainer: canRemoveMaintainer, - CanMutateMaintainer: canMutateMaintainer, + CommonTransactionRequest: commonTransactionRequest, + FromID: fromID, + ToID: toID, + ClassificationID: classificationID, + MaintainedProperties: maintainedProperties, + CanMintAsset: canMintAsset, + CanRenumerateAsset: canRenumerateAsset, + CanBurnAsset: canBurnAsset, + CanAddMaintainer: canAddMaintainer, + CanRemoveMaintainer: canRemoveMaintainer, + CanMutateMaintainer: canMutateMaintainer, } } diff --git a/x/assets/transactions/deputize/transaction_request_test.go b/x/assets/transactions/deputize/transaction_request_test.go index 2e48388c3..d30ed0bc9 100644 --- a/x/assets/transactions/deputize/transaction_request_test.go +++ b/x/assets/transactions/deputize/transaction_request_test.go @@ -4,57 +4,54 @@ package deputize import ( - "encoding/json" "fmt" - "github.com/AssetMantle/modules/utilities/rest" - "reflect" - "testing" - baseData "github.com/AssetMantle/schema/data/base" baseIDs "github.com/AssetMantle/schema/ids/base" baseLists "github.com/AssetMantle/schema/lists/base" baseProperties "github.com/AssetMantle/schema/properties/base" + "reflect" + "testing" + "github.com/cosmos/cosmos-sdk/client" - sdkCodec "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" "github.com/spf13/viper" "github.com/AssetMantle/modules/helpers" - "github.com/AssetMantle/modules/helpers/base" + baseHelpers "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/helpers/constants" ) var ( - testBaseRequest = rest.BaseReq{From: fromAddress, ChainID: "test", Fees: sdkTypes.NewCoins()} + commonTransactionRequest = helpers.PrototypeCommonTransactionRequest() mutableMetaPropertiesString = "testMutableMeta1:S|mutableMeta" mutableMetaProperties1 = baseLists.NewPropertyList(baseProperties.NewMetaProperty(baseIDs.NewStringID("testMutableMeta1"), baseData.NewStringData("mutableMeta"))) ) func Test_newTransactionRequest(t *testing.T) { type args struct { - baseReq rest.BaseReq - fromID string - toID string - classificationID string - maintainedProperties string - canMintAsset bool - canBurnAsset bool - canRenumerateAsset bool - canAddMaintainer bool - canRemoveMaintainer bool - canMutateMaintainer bool + commonTransactionRequest helpers.CommonTransactionRequest + fromID string + toID string + classificationID string + maintainedProperties string + canMintAsset bool + canBurnAsset bool + canRenumerateAsset bool + canAddMaintainer bool + canRemoveMaintainer bool + canMutateMaintainer bool } tests := []struct { name string args args want helpers.TransactionRequest }{ - {"+ve", args{testBaseRequest, fromID.AsString(), fromID.AsString(), classificationID.AsString(), fmt.Sprint(mutableMetaProperties), true, true, true, true, true, true}, transactionRequest{testBaseRequest, fromID.AsString(), fromID.AsString(), classificationID.AsString(), fmt.Sprint(mutableMetaProperties), true, true, true, true, true, true}}, + {"+ve", args{commonTransactionRequest, fromID.AsString(), fromID.AsString(), classificationID.AsString(), fmt.Sprint(mutableMetaProperties), true, true, true, true, true, true}, transactionRequest{commonTransactionRequest, fromID.AsString(), fromID.AsString(), classificationID.AsString(), fmt.Sprint(mutableMetaProperties), true, true, true, true, true, true}}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - if got := newTransactionRequest(tt.args.baseReq, tt.args.fromID, tt.args.toID, tt.args.classificationID, tt.args.maintainedProperties, tt.args.canMintAsset, tt.args.canBurnAsset, tt.args.canRenumerateAsset, tt.args.canAddMaintainer, tt.args.canRemoveMaintainer, tt.args.canMutateMaintainer); !reflect.DeepEqual(got, tt.want) { + if got := newTransactionRequest(tt.args.commonTransactionRequest, tt.args.fromID, tt.args.toID, tt.args.classificationID, tt.args.maintainedProperties, tt.args.canMintAsset, tt.args.canBurnAsset, tt.args.canRenumerateAsset, tt.args.canAddMaintainer, tt.args.canRemoveMaintainer, tt.args.canMutateMaintainer); !reflect.DeepEqual(got, tt.want) { t.Errorf("newTransactionRequest() = %v, want %v", got, tt.want) } }) @@ -78,7 +75,7 @@ func Test_requestPrototype(t *testing.T) { } func Test_transactionRequest_FromCLI(t *testing.T) { - cliCommand := base.NewCLICommand("", "", "", []helpers.CLIFlag{constants.ToIdentityID, constants.FromIdentityID, constants.ClassificationID, constants.MaintainedProperties, constants.CanMintAsset, constants.CanBurnAsset, constants.CanRenumerateAsset, constants.CanAddMaintainer, constants.CanRemoveMaintainer, constants.CanMutateMaintainer}) + cliCommand := baseHelpers.NewCLICommand("", "", "", []helpers.CLIFlag{constants.ToIdentityID, constants.FromIdentityID, constants.ClassificationID, constants.MaintainedProperties, constants.CanMintAsset, constants.CanBurnAsset, constants.CanRenumerateAsset, constants.CanAddMaintainer, constants.CanRemoveMaintainer, constants.CanMutateMaintainer}) viper.Set(constants.ToIdentityID.GetName(), fromID.AsString()) viper.Set(constants.FromIdentityID.GetName(), fromID.AsString()) @@ -91,17 +88,17 @@ func Test_transactionRequest_FromCLI(t *testing.T) { viper.Set(constants.CanRemoveMaintainer.GetName(), true) viper.Set(constants.CanMutateMaintainer.GetName(), true) type fields struct { - BaseReq rest.BaseReq - FromID string - ToID string - ClassificationID string - MaintainedProperties string - CanMintAsset bool - CanBurnAsset bool - CanRenumerateAsset bool - CanAddMaintainer bool - CanRemoveMaintainer bool - CanMutateMaintainer bool + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + ToID string + ClassificationID string + MaintainedProperties string + CanMintAsset bool + CanBurnAsset bool + CanRenumerateAsset bool + CanAddMaintainer bool + CanRemoveMaintainer bool + CanMutateMaintainer bool } type args struct { cliCommand helpers.CLICommand @@ -114,22 +111,22 @@ func Test_transactionRequest_FromCLI(t *testing.T) { want helpers.TransactionRequest wantErr bool }{ - {"+ve", fields{}, args{cliCommand, client.Context{}.WithCodec(base.CodecPrototype())}, transactionRequest{testBaseRequest, fromID.AsString(), fromID.AsString(), classificationID.AsString(), mutableMetaPropertiesString, true, true, true, true, true, true}, false}, + {"+ve", fields{}, args{cliCommand, client.Context{}.WithCodec(baseHelpers.CodecPrototype())}, transactionRequest{commonTransactionRequest, fromID.AsString(), fromID.AsString(), classificationID.AsString(), mutableMetaPropertiesString, true, true, true, true, true, true}, false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - ToID: tt.fields.ToID, - ClassificationID: tt.fields.ClassificationID, - MaintainedProperties: tt.fields.MaintainedProperties, - CanMintAsset: tt.fields.CanMintAsset, - CanBurnAsset: tt.fields.CanBurnAsset, - CanRenumerateAsset: tt.fields.CanRenumerateAsset, - CanAddMaintainer: tt.fields.CanAddMaintainer, - CanRemoveMaintainer: tt.fields.CanRemoveMaintainer, - CanMutateMaintainer: tt.fields.CanMutateMaintainer, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + ToID: tt.fields.ToID, + ClassificationID: tt.fields.ClassificationID, + MaintainedProperties: tt.fields.MaintainedProperties, + CanMintAsset: tt.fields.CanMintAsset, + CanBurnAsset: tt.fields.CanBurnAsset, + CanRenumerateAsset: tt.fields.CanRenumerateAsset, + CanAddMaintainer: tt.fields.CanAddMaintainer, + CanRemoveMaintainer: tt.fields.CanRemoveMaintainer, + CanMutateMaintainer: tt.fields.CanMutateMaintainer, } got, err := transactionRequest.FromCLI(tt.args.cliCommand, tt.args.context) if (err != nil) != tt.wantErr { @@ -143,97 +140,44 @@ func Test_transactionRequest_FromCLI(t *testing.T) { } } -func Test_transactionRequest_FromJSON(t *testing.T) { - type fields struct { - BaseReq rest.BaseReq - FromID string - ToID string - ClassificationID string - MaintainedProperties string - CanMintAsset bool - CanBurnAsset bool - CanRenumerateAsset bool - CanAddMaintainer bool - CanRemoveMaintainer bool - CanMutateMaintainer bool - } - type args struct { - rawMessage json.RawMessage - } - tests := []struct { - name string - fields fields - args args - want helpers.TransactionRequest - wantErr bool - }{ - {"+ve", fields{testBaseRequest, fromID.AsString(), fromID.AsString(), classificationID.AsString(), fmt.Sprint(mutableMetaProperties), true, true, true, true, true, true}, args{sdkTypes.MustSortJSON(base.CodecPrototype().MustMarshalJSON(&Message{fromAccAddress.String(), fromID, fromID, classificationID, mutableMetaProperties, true, true, true, true, true, true}))}, transactionRequest{testBaseRequest, fromID.AsString(), fromID.AsString(), classificationID.AsString(), fmt.Sprint(mutableMetaProperties), true, true, true, true, true, true}, false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - ToID: tt.fields.ToID, - ClassificationID: tt.fields.ClassificationID, - MaintainedProperties: tt.fields.MaintainedProperties, - CanMintAsset: tt.fields.CanMintAsset, - CanBurnAsset: tt.fields.CanBurnAsset, - CanRenumerateAsset: tt.fields.CanRenumerateAsset, - CanAddMaintainer: tt.fields.CanAddMaintainer, - CanRemoveMaintainer: tt.fields.CanRemoveMaintainer, - CanMutateMaintainer: tt.fields.CanMutateMaintainer, - } - got, err := transactionRequest.FromJSON(tt.args.rawMessage) - if (err != nil) != tt.wantErr { - t.Errorf("FromJSON() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("FromJSON() got = %v, want %v", got, tt.want) - } - }) - } -} - func Test_transactionRequest_GetBaseReq(t *testing.T) { type fields struct { - BaseReq rest.BaseReq - FromID string - ToID string - ClassificationID string - MaintainedProperties string - CanMintAsset bool - CanBurnAsset bool - CanRenumerateAsset bool - CanAddMaintainer bool - CanRemoveMaintainer bool - CanMutateMaintainer bool + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + ToID string + ClassificationID string + MaintainedProperties string + CanMintAsset bool + CanBurnAsset bool + CanRenumerateAsset bool + CanAddMaintainer bool + CanRemoveMaintainer bool + CanMutateMaintainer bool } tests := []struct { name string fields fields - want rest.BaseReq + want helpers.CommonTransactionRequest }{ - {"+ve", fields{testBaseRequest, fromID.AsString(), fromID.AsString(), classificationID.AsString(), fmt.Sprint(mutableMetaProperties), true, true, true, true, true, true}, testBaseRequest}, + {"+ve", fields{commonTransactionRequest, fromID.AsString(), fromID.AsString(), classificationID.AsString(), fmt.Sprint(mutableMetaProperties), true, true, true, true, true, true}, commonTransactionRequest}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - ToID: tt.fields.ToID, - ClassificationID: tt.fields.ClassificationID, - MaintainedProperties: tt.fields.MaintainedProperties, - CanMintAsset: tt.fields.CanMintAsset, - CanBurnAsset: tt.fields.CanBurnAsset, - CanRenumerateAsset: tt.fields.CanRenumerateAsset, - CanAddMaintainer: tt.fields.CanAddMaintainer, - CanRemoveMaintainer: tt.fields.CanRemoveMaintainer, - CanMutateMaintainer: tt.fields.CanMutateMaintainer, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + ToID: tt.fields.ToID, + ClassificationID: tt.fields.ClassificationID, + MaintainedProperties: tt.fields.MaintainedProperties, + CanMintAsset: tt.fields.CanMintAsset, + CanBurnAsset: tt.fields.CanBurnAsset, + CanRenumerateAsset: tt.fields.CanRenumerateAsset, + CanAddMaintainer: tt.fields.CanAddMaintainer, + CanRemoveMaintainer: tt.fields.CanRemoveMaintainer, + CanMutateMaintainer: tt.fields.CanMutateMaintainer, } - if got := transactionRequest.GetBaseReq(); !reflect.DeepEqual(got, tt.want) { - t.Errorf("GetBaseReq() = %v, want %v", got, tt.want) + if got := transactionRequest.GetCommonTransactionRequest(); !reflect.DeepEqual(got, tt.want) { + t.Errorf("GetCommonTransactionRequest() = %v, want %v", got, tt.want) } }) } @@ -241,17 +185,17 @@ func Test_transactionRequest_GetBaseReq(t *testing.T) { func Test_transactionRequest_MakeMsg(t *testing.T) { type fields struct { - BaseReq rest.BaseReq - FromID string - ToID string - ClassificationID string - MaintainedProperties string - CanMintAsset bool - CanBurnAsset bool - CanRenumerateAsset bool - CanAddMaintainer bool - CanRemoveMaintainer bool - CanMutateMaintainer bool + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + ToID string + ClassificationID string + MaintainedProperties string + CanMintAsset bool + CanBurnAsset bool + CanRenumerateAsset bool + CanAddMaintainer bool + CanRemoveMaintainer bool + CanMutateMaintainer bool } tests := []struct { name string @@ -259,22 +203,22 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { want sdkTypes.Msg wantErr bool }{ - {"+ve", fields{testBaseRequest, fromID.AsString(), fromID.AsString(), classificationID.AsString(), mutableMetaPropertiesString, true, true, true, true, true, true}, NewMessage(fromAccAddress, fromID, fromID, classificationID, mutableMetaProperties1, true, true, true, true, true, true), false}, + {"+ve", fields{commonTransactionRequest, fromID.AsString(), fromID.AsString(), classificationID.AsString(), mutableMetaPropertiesString, true, true, true, true, true, true}, NewMessage(fromAccAddress, fromID, fromID, classificationID, mutableMetaProperties1, true, true, true, true, true, true), false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - ToID: tt.fields.ToID, - ClassificationID: tt.fields.ClassificationID, - MaintainedProperties: tt.fields.MaintainedProperties, - CanMintAsset: tt.fields.CanMintAsset, - CanBurnAsset: tt.fields.CanBurnAsset, - CanRenumerateAsset: tt.fields.CanRenumerateAsset, - CanAddMaintainer: tt.fields.CanAddMaintainer, - CanRemoveMaintainer: tt.fields.CanRemoveMaintainer, - CanMutateMaintainer: tt.fields.CanMutateMaintainer, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + ToID: tt.fields.ToID, + ClassificationID: tt.fields.ClassificationID, + MaintainedProperties: tt.fields.MaintainedProperties, + CanMintAsset: tt.fields.CanMintAsset, + CanBurnAsset: tt.fields.CanBurnAsset, + CanRenumerateAsset: tt.fields.CanRenumerateAsset, + CanAddMaintainer: tt.fields.CanAddMaintainer, + CanRemoveMaintainer: tt.fields.CanRemoveMaintainer, + CanMutateMaintainer: tt.fields.CanMutateMaintainer, } got, err := transactionRequest.MakeMsg() if (err != nil) != tt.wantErr { @@ -288,63 +232,19 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { } } -func Test_transactionRequest_RegisterCodec(t *testing.T) { - type fields struct { - BaseReq rest.BaseReq - FromID string - ToID string - ClassificationID string - MaintainedProperties string - CanMintAsset bool - CanBurnAsset bool - CanRenumerateAsset bool - CanAddMaintainer bool - CanRemoveMaintainer bool - CanMutateMaintainer bool - } - type args struct { - legacyAmino *sdkCodec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{testBaseRequest, fromID.AsString(), fromID.AsString(), classificationID.AsString(), fmt.Sprint(mutableMetaProperties), true, true, true, true, true, true}, args{sdkCodec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - tr := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - ToID: tt.fields.ToID, - ClassificationID: tt.fields.ClassificationID, - MaintainedProperties: tt.fields.MaintainedProperties, - CanMintAsset: tt.fields.CanMintAsset, - CanBurnAsset: tt.fields.CanBurnAsset, - CanRenumerateAsset: tt.fields.CanRenumerateAsset, - CanAddMaintainer: tt.fields.CanAddMaintainer, - CanRemoveMaintainer: tt.fields.CanRemoveMaintainer, - CanMutateMaintainer: tt.fields.CanMutateMaintainer, - } - tr.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - func Test_transactionRequest_Validate(t *testing.T) { type fields struct { - BaseReq rest.BaseReq - FromID string - ToID string - ClassificationID string - MaintainedProperties string - CanMintAsset bool - CanBurnAsset bool - CanRenumerateAsset bool - CanAddMaintainer bool - CanRemoveMaintainer bool - CanMutateMaintainer bool + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + ToID string + ClassificationID string + MaintainedProperties string + CanMintAsset bool + CanBurnAsset bool + CanRenumerateAsset bool + CanAddMaintainer bool + CanRemoveMaintainer bool + CanMutateMaintainer bool } tests := []struct { name string @@ -352,22 +252,22 @@ func Test_transactionRequest_Validate(t *testing.T) { wantErr bool }{ {"+ve with nil", fields{}, true}, - {"+ve", fields{testBaseRequest, fromID.AsString(), fromID.AsString(), classificationID.AsString(), fmt.Sprint(mutableMetaProperties), true, true, true, true, true, true}, false}, + {"+ve", fields{commonTransactionRequest, fromID.AsString(), fromID.AsString(), classificationID.AsString(), fmt.Sprint(mutableMetaProperties), true, true, true, true, true, true}, false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - ToID: tt.fields.ToID, - ClassificationID: tt.fields.ClassificationID, - MaintainedProperties: tt.fields.MaintainedProperties, - CanMintAsset: tt.fields.CanMintAsset, - CanBurnAsset: tt.fields.CanBurnAsset, - CanRenumerateAsset: tt.fields.CanRenumerateAsset, - CanAddMaintainer: tt.fields.CanAddMaintainer, - CanRemoveMaintainer: tt.fields.CanRemoveMaintainer, - CanMutateMaintainer: tt.fields.CanMutateMaintainer, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + ToID: tt.fields.ToID, + ClassificationID: tt.fields.ClassificationID, + MaintainedProperties: tt.fields.MaintainedProperties, + CanMintAsset: tt.fields.CanMintAsset, + CanBurnAsset: tt.fields.CanBurnAsset, + CanRenumerateAsset: tt.fields.CanRenumerateAsset, + CanAddMaintainer: tt.fields.CanAddMaintainer, + CanRemoveMaintainer: tt.fields.CanRemoveMaintainer, + CanMutateMaintainer: tt.fields.CanMutateMaintainer, } if err := transactionRequest.Validate(); (err != nil) != tt.wantErr { t.Errorf("ValidateBasic() error = %v, wantErr %v", err, tt.wantErr) diff --git a/x/assets/transactions/deputize/transaction_response.go b/x/assets/transactions/deputize/transaction_response.go index 8642b0b49..1af3c6455 100644 --- a/x/assets/transactions/deputize/transaction_response.go +++ b/x/assets/transactions/deputize/transaction_response.go @@ -4,9 +4,8 @@ package deputize import ( - sdkTypes "github.com/cosmos/cosmos-sdk/types" - "github.com/AssetMantle/modules/helpers" + sdkTypes "github.com/cosmos/cosmos-sdk/types" ) var _ helpers.TransactionResponse = (*TransactionResponse)(nil) diff --git a/x/assets/transactions/mint/message.go b/x/assets/transactions/mint/message.go index d6283a62d..0668438c6 100644 --- a/x/assets/transactions/mint/message.go +++ b/x/assets/transactions/mint/message.go @@ -4,28 +4,17 @@ package mint import ( - codecUtilities "github.com/AssetMantle/schema/codec/utilities" + "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" "github.com/AssetMantle/schema/lists" baseLists "github.com/AssetMantle/schema/lists/base" - sdkCodec "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/types" sdkTypes "github.com/cosmos/cosmos-sdk/types" - - "github.com/AssetMantle/modules/helpers" ) var _ helpers.Message = (*Message)(nil) -func (message *Message) Type() string { return Transaction.GetName() } -func (message *Message) GetFromAddress() sdkTypes.AccAddress { - from, err := sdkTypes.AccAddressFromBech32(message.From) - if err != nil { - panic(err) - } - return from -} func (message *Message) ValidateBasic() error { if _, err := sdkTypes.AccAddressFromBech32(message.From); err != nil { return err @@ -60,21 +49,10 @@ func (message *Message) GetSigners() []sdkTypes.AccAddress { } return []sdkTypes.AccAddress{from} } -func (*Message) RegisterLegacyAminoCodec(legacyAmino *sdkCodec.LegacyAmino) { - codecUtilities.RegisterModuleConcrete(legacyAmino, Message{}) -} func (message *Message) RegisterInterface(interfaceRegistry types.InterfaceRegistry) { interfaceRegistry.RegisterImplementations((*sdkTypes.Msg)(nil), message) } -func messageFromInterface(msg sdkTypes.Msg) *Message { - switch value := msg.(type) { - case *Message: - return value - default: - return &Message{} - } -} func messagePrototype() helpers.Message { return &Message{} } diff --git a/x/assets/transactions/mint/message_test.go b/x/assets/transactions/mint/message_test.go index fa8353995..d15413add 100644 --- a/x/assets/transactions/mint/message_test.go +++ b/x/assets/transactions/mint/message_test.go @@ -4,7 +4,6 @@ package mint import ( - sdkCodec "github.com/cosmos/cosmos-sdk/codec" "reflect" "testing" @@ -44,26 +43,6 @@ type fields struct { MutableProperties *baseLists.PropertyList } -func Test_messageFromInterface(t *testing.T) { - type args struct { - msg sdkTypes.Msg - } - tests := []struct { - name string - args args - want helpers.Message - }{ - {"+ve", args{NewMessage(fromAccAddress, fromID, fromID, classificationID, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties)}, NewMessage(fromAccAddress, fromID, fromID, classificationID, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties).(*Message)}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := messageFromInterface(tt.args.msg); !reflect.DeepEqual(got, tt.want) { - t.Errorf("messageFromInterface() = %v, want %v", got, tt.want) - } - }) - } -} - func Test_messagePrototype(t *testing.T) { tests := []struct { name string @@ -108,64 +87,6 @@ func Test_message_GetSigners(t *testing.T) { } } -func Test_message_RegisterCodec(t *testing.T) { - - type args struct { - legacyAmino *sdkCodec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve with nil", fields{}, args{sdkCodec.NewLegacyAmino()}}, - {"+ve", fields{fromAccAddress.String(), fromID, fromID, classificationID, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties}, args{sdkCodec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - me := &Message{ - From: tt.fields.From, - FromID: tt.fields.FromID, - ToID: tt.fields.ToID, - ClassificationID: tt.fields.ClassificationID, - ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, - ImmutableProperties: tt.fields.ImmutableProperties, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, - } - me.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - -func Test_message_Type(t *testing.T) { - - tests := []struct { - name string - fields fields - want string - }{ - {"+ve", fields{fromAccAddress.String(), fromID, fromID, classificationID, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties}, Transaction.GetName()}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - message := &Message{ - From: tt.fields.From, - FromID: tt.fields.FromID, - ToID: tt.fields.ToID, - ClassificationID: tt.fields.ClassificationID, - ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, - ImmutableProperties: tt.fields.ImmutableProperties, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, - } - if got := message.Type(); got != tt.want { - t.Errorf("Type() = %v, want %v", got, tt.want) - } - }) - } -} - func Test_message_ValidateBasic(t *testing.T) { tests := []struct { diff --git a/x/assets/transactions/mint/service.pb.go b/x/assets/transactions/mint/service.pb.go index b9fcbd87c..fab9c75f8 100644 --- a/x/assets/transactions/mint/service.pb.go +++ b/x/assets/transactions/mint/service.pb.go @@ -6,9 +6,9 @@ package mint import ( context "context" fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types/msgservice" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" - _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -31,30 +31,29 @@ func init() { } var fileDescriptor_eea46adca244dcb0 = []byte{ - // 353 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0xd2, 0xb1, 0x4a, 0xc3, 0x40, - 0x18, 0x07, 0xf0, 0x26, 0x42, 0x87, 0xe0, 0x54, 0x71, 0x89, 0x92, 0xa1, 0x0f, 0x70, 0x07, 0xed, - 0x20, 0x1e, 0x2e, 0xad, 0x83, 0x3a, 0x1c, 0x14, 0xed, 0x10, 0x24, 0x20, 0xd7, 0xf4, 0x88, 0x81, - 0xe4, 0xae, 0xe4, 0xbb, 0x4a, 0x67, 0x9f, 0x40, 0xf0, 0x0d, 0x74, 0xd3, 0x17, 0x11, 0xa7, 0x82, - 0x8b, 0xa3, 0x24, 0x4e, 0xee, 0xee, 0x92, 0xde, 0x81, 0xd7, 0xf1, 0xd6, 0x2f, 0xfc, 0xfe, 0xf9, - 0x7f, 0x5f, 0x12, 0x9c, 0x8c, 0x00, 0xb8, 0xa2, 0x4c, 0xa8, 0x82, 0xe3, 0x52, 0xce, 0x97, 0x05, - 0x07, 0xbc, 0xc2, 0xac, 0x9d, 0x02, 0x56, 0x15, 0x13, 0xc0, 0x52, 0x95, 0x4b, 0x01, 0xb8, 0xcc, - 0x85, 0xc2, 0xc0, 0xab, 0xbb, 0x3c, 0xe5, 0x68, 0x51, 0x49, 0x25, 0x7b, 0xc8, 0xd2, 0xc8, 0x68, - 0xb4, 0x42, 0x5a, 0x23, 0x5b, 0xa3, 0x56, 0x87, 0x87, 0x99, 0x94, 0x59, 0xc1, 0x31, 0x5b, 0xe4, - 0x98, 0x09, 0x21, 0x15, 0xd3, 0x0f, 0x37, 0x69, 0xa1, 0x6b, 0x97, 0x92, 0x03, 0xb0, 0xcc, 0x74, - 0x09, 0x2f, 0x1c, 0xb5, 0x35, 0xb9, 0xa9, 0x38, 0x2c, 0xa4, 0x00, 0x13, 0x35, 0x78, 0xf5, 0x82, - 0x1d, 0x0a, 0x59, 0xef, 0xd9, 0x0b, 0xba, 0xe7, 0x4c, 0xcc, 0x0b, 0xde, 0x3b, 0x72, 0x5c, 0x15, - 0x51, 0x5d, 0x2e, 0x3c, 0x75, 0x85, 0xd3, 0xff, 0xc9, 0xa5, 0xa9, 0xd5, 0x3f, 0xb8, 0xff, 0xf8, - 0x7e, 0xf4, 0xf7, 0xfb, 0x7b, 0xb8, 0xd4, 0xfb, 0x99, 0xad, 0x5a, 0x30, 0xfe, 0xf5, 0xdf, 0xea, - 0xc8, 0x5b, 0xd7, 0x91, 0xf7, 0x55, 0x47, 0xde, 0x43, 0x13, 0x75, 0xd6, 0x4d, 0xd4, 0xf9, 0x6c, - 0xa2, 0x4e, 0x30, 0x48, 0x65, 0xe9, 0xf8, 0xfe, 0xf1, 0xee, 0x95, 0xfe, 0xc4, 0x93, 0xf6, 0x14, - 0x13, 0xef, 0xfa, 0x38, 0xcb, 0xd5, 0xed, 0x72, 0x86, 0x52, 0x59, 0x62, 0xb7, 0x13, 0x3f, 0xf9, - 0xdd, 0x11, 0x8d, 0x47, 0x53, 0xfa, 0xe2, 0x6f, 0x95, 0xa0, 0xa6, 0x44, 0xac, 0xa7, 0x60, 0xaf, - 0x0c, 0x88, 0xe6, 0x42, 0xbd, 0x6f, 0x81, 0xc4, 0x80, 0x24, 0x4e, 0x34, 0x48, 0x6c, 0x90, 0xb4, - 0xa0, 0xf6, 0x89, 0x1b, 0x48, 0xce, 0x26, 0x63, 0xca, 0x15, 0x9b, 0x33, 0xc5, 0x7e, 0xfc, 0xa1, - 0x85, 0x09, 0x31, 0x9a, 0x90, 0x98, 0xe8, 0x54, 0x20, 0xc4, 0x0e, 0x20, 0xa4, 0x4d, 0x98, 0x75, - 0x37, 0x3f, 0xcb, 0xf0, 0x2f, 0x00, 0x00, 0xff, 0xff, 0xe6, 0x21, 0x69, 0xe7, 0x43, 0x03, 0x00, - 0x00, + // 343 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0xd2, 0xb1, 0x4b, 0x03, 0x31, + 0x14, 0x06, 0xf0, 0xbb, 0x13, 0x3b, 0x1c, 0x4e, 0x5d, 0x84, 0x1b, 0x6e, 0x70, 0x74, 0x48, 0xb0, + 0x1d, 0xc4, 0xe0, 0xd2, 0x3a, 0xa8, 0x43, 0xa0, 0x68, 0x87, 0x43, 0x0e, 0x24, 0xbd, 0x86, 0xf3, + 0xa0, 0x49, 0xca, 0xbd, 0xb4, 0x74, 0x74, 0x74, 0x74, 0x73, 0x77, 0x74, 0xf2, 0xcf, 0x10, 0xa7, + 0x8e, 0x8e, 0x72, 0x1d, 0x04, 0x77, 0x77, 0x39, 0x13, 0x30, 0x1d, 0x33, 0x1d, 0x3c, 0xf8, 0x7d, + 0xf7, 0xbd, 0x24, 0xf1, 0xe9, 0x00, 0x80, 0x6b, 0xca, 0xa4, 0x9e, 0x71, 0x2c, 0xd4, 0x74, 0x31, + 0xe3, 0x80, 0x57, 0x98, 0xb5, 0x53, 0xc0, 0xba, 0x66, 0x12, 0x58, 0xa1, 0x2b, 0x25, 0x01, 0x8b, + 0x4a, 0x6a, 0x0c, 0xbc, 0x5e, 0x56, 0x05, 0x47, 0xf3, 0x5a, 0x69, 0xd5, 0x45, 0x8e, 0x46, 0x56, + 0xa3, 0x15, 0x32, 0x1a, 0xb9, 0x1a, 0xb5, 0x3a, 0xd9, 0x2f, 0x14, 0x08, 0x05, 0x58, 0x40, 0x89, + 0x97, 0x47, 0xed, 0xc7, 0x04, 0x25, 0xbe, 0x35, 0x04, 0x07, 0x60, 0xa5, 0xad, 0x91, 0x5c, 0x7a, + 0x6a, 0x67, 0x72, 0x5b, 0x73, 0x98, 0x2b, 0x09, 0x36, 0xaa, 0xf7, 0x14, 0xc6, 0x3b, 0x14, 0xca, + 0xee, 0x43, 0x18, 0x77, 0x2e, 0x98, 0x9c, 0xce, 0x78, 0xf7, 0xd8, 0x73, 0x4b, 0x44, 0x4d, 0xb9, + 0xe4, 0xcc, 0x17, 0x8e, 0xff, 0x27, 0x57, 0xb6, 0xd6, 0x41, 0x90, 0xec, 0xde, 0x7f, 0xbd, 0x1e, + 0x86, 0xc3, 0x9f, 0xe8, 0xad, 0x49, 0xc3, 0x75, 0x93, 0x86, 0x9f, 0x4d, 0x1a, 0x3e, 0x6e, 0xd2, + 0x60, 0xbd, 0x49, 0x83, 0x8f, 0x4d, 0x1a, 0xc4, 0xbd, 0x42, 0x09, 0xcf, 0x7f, 0x0d, 0xf7, 0xae, + 0xcd, 0x4d, 0x8e, 0xda, 0xb5, 0x47, 0xe1, 0xcd, 0x49, 0x59, 0xe9, 0xbb, 0xc5, 0x04, 0x15, 0x4a, + 0x60, 0xbf, 0xe3, 0x7c, 0x8e, 0x3a, 0x03, 0x9a, 0x0d, 0xc6, 0xf4, 0x25, 0xda, 0x2a, 0x41, 0x6d, + 0x89, 0xcc, 0x4c, 0xc1, 0x5d, 0x0f, 0x10, 0xad, 0xa4, 0x7e, 0xdf, 0x02, 0xb9, 0x05, 0x79, 0x96, + 0x1b, 0x90, 0xbb, 0x20, 0x6f, 0x41, 0x13, 0x11, 0x3f, 0x90, 0x9f, 0x8f, 0x86, 0x94, 0x6b, 0x36, + 0x65, 0x9a, 0x7d, 0x47, 0x7d, 0x07, 0x13, 0x62, 0x35, 0x21, 0x19, 0x31, 0xa9, 0x40, 0x88, 0x1b, + 0x40, 0x48, 0x9b, 0x30, 0xe9, 0xfc, 0x3d, 0x8c, 0xfe, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x25, + 0x93, 0xb3, 0x7e, 0x2a, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/assets/transactions/mint/service.pb.gw.go b/x/assets/transactions/mint/service.pb.gw.go deleted file mode 100644 index ea198c498..000000000 --- a/x/assets/transactions/mint/service.pb.gw.go +++ /dev/null @@ -1,171 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: AssetMantle/modules/x/assets/transactions/mint/service.proto - -/* -Package mint is a reverse proxy. - -It translates gRPC into RESTful JSON APIs. -*/ -package mint - -import ( - "context" - "io" - "net/http" - - "github.com/golang/protobuf/descriptor" - "github.com/golang/protobuf/proto" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/grpc-ecosystem/grpc-gateway/utilities" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/status" -) - -// Suppress "imported and not used" errors -var _ codes.Code -var _ io.Reader -var _ status.Status -var _ = runtime.String -var _ = utilities.NewDoubleArray -var _ = descriptor.ForMessage -var _ = metadata.Join - -var ( - filter_Msg_Handle_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - -func request_Msg_Handle_0(ctx context.Context, marshaler runtime.Marshaler, client MsgClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq Message - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.Handle(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Msg_Handle_0(ctx context.Context, marshaler runtime.Marshaler, server MsgServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq Message - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.Handle(ctx, &protoReq) - return msg, metadata, err - -} - -// RegisterMsgHandlerServer registers the http handlers for service Msg to "mux". -// UnaryRPC :call MsgServer directly. -// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterMsgHandlerFromEndpoint instead. -func RegisterMsgHandlerServer(ctx context.Context, mux *runtime.ServeMux, server MsgServer) error { - - mux.Handle("POST", pattern_Msg_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Msg_Handle_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Msg_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -// RegisterMsgHandlerFromEndpoint is same as RegisterMsgHandler but -// automatically dials to "endpoint" and closes the connection when "ctx" gets done. -func RegisterMsgHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.Dial(endpoint, opts...) - if err != nil { - return err - } - defer func() { - if err != nil { - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - return - } - go func() { - <-ctx.Done() - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - }() - }() - - return RegisterMsgHandler(ctx, mux, conn) -} - -// RegisterMsgHandler registers the http handlers for service Msg to "mux". -// The handlers forward requests to the grpc endpoint over "conn". -func RegisterMsgHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { - return RegisterMsgHandlerClient(ctx, mux, NewMsgClient(conn)) -} - -// RegisterMsgHandlerClient registers the http handlers for service Msg -// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "MsgClient". -// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "MsgClient" -// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "MsgClient" to call the correct interceptors. -func RegisterMsgHandlerClient(ctx context.Context, mux *runtime.ServeMux, client MsgClient) error { - - mux.Handle("POST", pattern_Msg_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Msg_Handle_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Msg_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -var ( - pattern_Msg_Handle_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"mantle", "assets", "mint"}, "", runtime.AssumeColonVerbOpt(false))) -) - -var ( - forward_Msg_Handle_0 = runtime.ForwardResponseMessage -) diff --git a/x/assets/transactions/mint/transaction.go b/x/assets/transactions/mint/transaction.go index c45800e1d..2c44fab7e 100644 --- a/x/assets/transactions/mint/transaction.go +++ b/x/assets/transactions/mint/transaction.go @@ -4,22 +4,14 @@ package mint import ( - "context" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "google.golang.org/grpc" - "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/helpers/constants" - "github.com/AssetMantle/modules/utilities/name" + "google.golang.org/grpc" ) -type dummy struct{} - var Transaction = baseHelpers.NewTransaction( - name.GetPackageName(dummy{}), + _Msg_serviceDesc.ServiceName, "", "", @@ -30,9 +22,6 @@ var Transaction = baseHelpers.NewTransaction( func(server grpc.ServiceRegistrar, keeper helpers.TransactionKeeper) { RegisterMsgServer(server, keeper.(transactionKeeper)) }, - func(clientCtx client.Context, mux *runtime.ServeMux) error { - return RegisterMsgHandlerClient(context.Background(), mux, NewMsgClient(clientCtx)) - }, constants.ToIdentityID, constants.FromIdentityID, diff --git a/x/assets/transactions/mint/transaction_keeper.go b/x/assets/transactions/mint/transaction_keeper.go index 283062cd5..c35e06dd4 100644 --- a/x/assets/transactions/mint/transaction_keeper.go +++ b/x/assets/transactions/mint/transaction_keeper.go @@ -6,7 +6,6 @@ package mint import ( "context" errorConstants "github.com/AssetMantle/modules/helpers/constants" - "github.com/AssetMantle/schema/data" "github.com/AssetMantle/schema/documents/base" baseIDs "github.com/AssetMantle/schema/ids/base" @@ -53,7 +52,7 @@ func (transactionKeeper transactionKeeper) Handle(context context.Context, messa return nil, err } - fromAddress := message.GetFromAddress() + fromAddress := message.GetSigners()[0] if _, err := transactionKeeper.authenticateAuxiliary.GetKeeper().Help(context, authenticate.NewAuxiliaryRequest(fromAddress, message.FromID)); err != nil { return nil, err diff --git a/x/assets/transactions/mint/transaction_request.go b/x/assets/transactions/mint/transaction_request.go index b31323164..402ed3577 100644 --- a/x/assets/transactions/mint/transaction_request.go +++ b/x/assets/transactions/mint/transaction_request.go @@ -5,29 +5,27 @@ package mint import ( "encoding/json" - "github.com/AssetMantle/modules/utilities/rest" - - codecUtilities "github.com/AssetMantle/schema/codec/utilities" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" "github.com/AssetMantle/schema/lists/base" "github.com/cosmos/cosmos-sdk/client" - sdkCodec "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" + "io" + "net/http" "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/helpers/constants" ) type transactionRequest struct { - BaseReq rest.BaseReq `json:"baseReq"` - FromID string `json:"fromID"` - ToID string `json:"toID"` - ClassificationID string `json:"classificationID"` - ImmutableMetaProperties string `json:"immutableMetaProperties"` - ImmutableProperties string `json:"immutableProperties"` - MutableMetaProperties string `json:"mutableMetaProperties"` - MutableProperties string `json:"mutableProperties"` + helpers.CommonTransactionRequest `json:"commonTransactionRequest"` + FromID string `json:"fromID"` + ToID string `json:"toID"` + ClassificationID string `json:"classificationID"` + ImmutableMetaProperties string `json:"immutableMetaProperties"` + ImmutableProperties string `json:"immutableProperties"` + MutableMetaProperties string `json:"mutableMetaProperties"` + MutableProperties string `json:"mutableProperties"` } var _ helpers.TransactionRequest = (*transactionRequest)(nil) @@ -53,7 +51,7 @@ func (transactionRequest transactionRequest) Validate() error { } func (transactionRequest transactionRequest) FromCLI(cliCommand helpers.CLICommand, context client.Context) (helpers.TransactionRequest, error) { return newTransactionRequest( - cliCommand.ReadBaseReq(context), + cliCommand.ReadCommonTransactionRequest(context), cliCommand.ReadString(constants.FromIdentityID), cliCommand.ReadString(constants.ToIdentityID), cliCommand.ReadString(constants.ClassificationID), @@ -63,18 +61,23 @@ func (transactionRequest transactionRequest) FromCLI(cliCommand helpers.CLIComma cliCommand.ReadString(constants.MutableProperties), ), nil } -func (transactionRequest transactionRequest) FromJSON(rawMessage json.RawMessage) (helpers.TransactionRequest, error) { - if err := json.Unmarshal(rawMessage, &transactionRequest); err != nil { +func (transactionRequest transactionRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.TransactionRequest, error) { + body, err := io.ReadAll(httpRequest.Body) + if err != nil { + return nil, err + } + + if err := json.Unmarshal(body, &transactionRequest); err != nil { return nil, err } return transactionRequest, nil } -func (transactionRequest transactionRequest) GetBaseReq() rest.BaseReq { - return transactionRequest.BaseReq +func (transactionRequest transactionRequest) GetCommonTransactionRequest() helpers.CommonTransactionRequest { + return transactionRequest.CommonTransactionRequest } func (transactionRequest transactionRequest) MakeMsg() (sdkTypes.Msg, error) { - from, err := sdkTypes.AccAddressFromBech32(transactionRequest.GetBaseReq().From) + from, err := sdkTypes.AccAddressFromBech32(transactionRequest.GetCommonTransactionRequest().GetFrom()) if err != nil { return nil, err } @@ -127,22 +130,19 @@ func (transactionRequest transactionRequest) MakeMsg() (sdkTypes.Msg, error) { mutableProperties, ), nil } -func (transactionRequest) RegisterLegacyAminoCodec(legacyAmino *sdkCodec.LegacyAmino) { - codecUtilities.RegisterModuleConcrete(legacyAmino, transactionRequest{}) -} func requestPrototype() helpers.TransactionRequest { return transactionRequest{} } -func newTransactionRequest(baseReq rest.BaseReq, fromID string, toID string, classificationID string, immutableMetaProperties string, immutableProperties string, mutableMetaProperties string, mutableProperties string) helpers.TransactionRequest { +func newTransactionRequest(commonTransactionRequest helpers.CommonTransactionRequest, fromID string, toID string, classificationID string, immutableMetaProperties string, immutableProperties string, mutableMetaProperties string, mutableProperties string) helpers.TransactionRequest { return transactionRequest{ - BaseReq: baseReq, - FromID: fromID, - ToID: toID, - ClassificationID: classificationID, - ImmutableMetaProperties: immutableMetaProperties, - ImmutableProperties: immutableProperties, - MutableMetaProperties: mutableMetaProperties, - MutableProperties: mutableProperties, + CommonTransactionRequest: commonTransactionRequest, + FromID: fromID, + ToID: toID, + ClassificationID: classificationID, + ImmutableMetaProperties: immutableMetaProperties, + ImmutableProperties: immutableProperties, + MutableMetaProperties: mutableMetaProperties, + MutableProperties: mutableProperties, } } diff --git a/x/assets/transactions/mint/transaction_request_test.go b/x/assets/transactions/mint/transaction_request_test.go index 80964b396..c62fbd4fb 100644 --- a/x/assets/transactions/mint/transaction_request_test.go +++ b/x/assets/transactions/mint/transaction_request_test.go @@ -4,29 +4,26 @@ package mint import ( - "encoding/json" "fmt" - "github.com/AssetMantle/modules/utilities/rest" - sdkCodec "github.com/cosmos/cosmos-sdk/codec" - "reflect" - "testing" - baseData "github.com/AssetMantle/schema/data/base" baseIDs "github.com/AssetMantle/schema/ids/base" baseLists "github.com/AssetMantle/schema/lists/base" baseProperties "github.com/AssetMantle/schema/properties/base" + "reflect" + "testing" + "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/types" "github.com/spf13/viper" "github.com/AssetMantle/modules/helpers" - "github.com/AssetMantle/modules/helpers/base" + baseHelpers "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/helpers/constants" ) var ( - testBaseRequest = rest.BaseReq{From: fromAddress, ChainID: "test", Fees: types.NewCoins()} + commonTransactionRequest = helpers.PrototypeCommonTransactionRequest() immutableMetaPropertiesString = "testImmutableMeta1:S|immutableMeta" immutableMetaProperties1 = baseLists.NewPropertyList(baseProperties.NewMetaProperty(baseIDs.NewStringID("testImmutableMeta1"), baseData.NewStringData("immutableMeta"))) immutablePropertiesString = "testImmutable1:S|immutable" @@ -39,25 +36,25 @@ var ( func Test_newTransactionRequest(t *testing.T) { type args struct { - baseReq rest.BaseReq - fromID string - toID string - classificationID string - immutableMetaProperties string - immutableProperties string - mutableMetaProperties string - mutableProperties string + commonTransactionRequest helpers.CommonTransactionRequest + fromID string + toID string + classificationID string + immutableMetaProperties string + immutableProperties string + mutableMetaProperties string + mutableProperties string } tests := []struct { name string args args want helpers.TransactionRequest }{ - {"+ve", args{testBaseRequest, fromID.AsString(), fromID.AsString(), classificationID.AsString(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, transactionRequest{testBaseRequest, fromID.AsString(), fromID.AsString(), classificationID.AsString(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}}, + {"+ve", args{commonTransactionRequest, fromID.AsString(), fromID.AsString(), classificationID.AsString(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, transactionRequest{commonTransactionRequest, fromID.AsString(), fromID.AsString(), classificationID.AsString(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - if got := newTransactionRequest(tt.args.baseReq, tt.args.fromID, tt.args.toID, tt.args.classificationID, tt.args.immutableMetaProperties, tt.args.immutableProperties, tt.args.mutableMetaProperties, tt.args.mutableProperties); !reflect.DeepEqual(got, tt.want) { + if got := newTransactionRequest(tt.args.commonTransactionRequest, tt.args.fromID, tt.args.toID, tt.args.classificationID, tt.args.immutableMetaProperties, tt.args.immutableProperties, tt.args.mutableMetaProperties, tt.args.mutableProperties); !reflect.DeepEqual(got, tt.want) { t.Errorf("newTransactionRequest() = %v, want %v", got, tt.want) } }) @@ -81,7 +78,7 @@ func Test_requestPrototype(t *testing.T) { } func Test_transactionRequest_FromCLI(t *testing.T) { - cliCommand := base.NewCLICommand("", "", "", []helpers.CLIFlag{constants.AssetID, constants.FromIdentityID, constants.ToIdentityID, constants.ClassificationID, constants.ImmutableMetaProperties, constants.ImmutableProperties, constants.MutableMetaProperties, constants.MutableProperties}) + cliCommand := baseHelpers.NewCLICommand("", "", "", []helpers.CLIFlag{constants.AssetID, constants.FromIdentityID, constants.ToIdentityID, constants.ClassificationID, constants.ImmutableMetaProperties, constants.ImmutableProperties, constants.MutableMetaProperties, constants.MutableProperties}) viper.Set(constants.FromIdentityID.GetName(), fromID.AsString()) viper.Set(constants.ToIdentityID.GetName(), fromID.AsString()) @@ -91,14 +88,14 @@ func Test_transactionRequest_FromCLI(t *testing.T) { viper.Set(constants.MutableMetaProperties.GetName(), mutableMetaPropertiesString) viper.Set(constants.MutableProperties.GetName(), mutablePropertiesString) type fields struct { - BaseReq rest.BaseReq - FromID string - ToID string - ClassificationID string - ImmutableMetaProperties string - ImmutableProperties string - MutableMetaProperties string - MutableProperties string + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + ToID string + ClassificationID string + ImmutableMetaProperties string + ImmutableProperties string + MutableMetaProperties string + MutableProperties string } type args struct { cliCommand helpers.CLICommand @@ -111,19 +108,19 @@ func Test_transactionRequest_FromCLI(t *testing.T) { want helpers.TransactionRequest wantErr bool }{ - {"+ve", fields{}, args{cliCommand, client.Context{}.WithCodec(base.CodecPrototype())}, transactionRequest{testBaseRequest, fromID.AsString(), fromID.AsString(), classificationID.AsString(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, false}, + {"+ve", fields{}, args{cliCommand, client.Context{}.WithCodec(baseHelpers.CodecPrototype())}, transactionRequest{commonTransactionRequest, fromID.AsString(), fromID.AsString(), classificationID.AsString(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - ToID: tt.fields.ToID, - ClassificationID: tt.fields.ClassificationID, - ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, - ImmutableProperties: tt.fields.ImmutableProperties, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + ToID: tt.fields.ToID, + ClassificationID: tt.fields.ClassificationID, + ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, + ImmutableProperties: tt.fields.ImmutableProperties, + MutableMetaProperties: tt.fields.MutableMetaProperties, + MutableProperties: tt.fields.MutableProperties, } got, err := transactionRequest.FromCLI(tt.args.cliCommand, tt.args.context) if (err != nil) != tt.wantErr { @@ -137,85 +134,38 @@ func Test_transactionRequest_FromCLI(t *testing.T) { } } -func Test_transactionRequest_FromJSON(t *testing.T) { - type fields struct { - BaseReq rest.BaseReq - FromID string - ToID string - ClassificationID string - ImmutableMetaProperties string - ImmutableProperties string - MutableMetaProperties string - MutableProperties string - } - type args struct { - rawMessage json.RawMessage - } - tests := []struct { - name string - fields fields - args args - want helpers.TransactionRequest - wantErr bool - }{ - {"+ve", fields{testBaseRequest, fromID.AsString(), fromID.AsString(), classificationID.AsString(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, args{types.MustSortJSON(base.CodecPrototype().MustMarshalJSON(&Message{fromAccAddress.String(), fromID, fromID, classificationID, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties}))}, newTransactionRequest(testBaseRequest, fromID.AsString(), fromID.AsString(), classificationID.AsString(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString), false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - ToID: tt.fields.ToID, - ClassificationID: tt.fields.ClassificationID, - ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, - ImmutableProperties: tt.fields.ImmutableProperties, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, - } - got, err := transactionRequest.FromJSON(tt.args.rawMessage) - if (err != nil) != tt.wantErr { - t.Errorf("FromJSON() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("FromJSON() got = %v, want %v", got, tt.want) - } - }) - } -} - func Test_transactionRequest_GetBaseReq(t *testing.T) { type fields struct { - BaseReq rest.BaseReq - FromID string - ToID string - ClassificationID string - ImmutableMetaProperties string - ImmutableProperties string - MutableMetaProperties string - MutableProperties string + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + ToID string + ClassificationID string + ImmutableMetaProperties string + ImmutableProperties string + MutableMetaProperties string + MutableProperties string } tests := []struct { name string fields fields - want rest.BaseReq + want helpers.CommonTransactionRequest }{ - {"+ve", fields{testBaseRequest, fromID.AsString(), fromID.AsString(), classificationID.AsString(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, testBaseRequest}, + {"+ve", fields{commonTransactionRequest, fromID.AsString(), fromID.AsString(), classificationID.AsString(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, commonTransactionRequest}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - ToID: tt.fields.ToID, - ClassificationID: tt.fields.ClassificationID, - ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, - ImmutableProperties: tt.fields.ImmutableProperties, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, - } - if got := transactionRequest.GetBaseReq(); !reflect.DeepEqual(got, tt.want) { - t.Errorf("GetBaseReq() = %v, want %v", got, tt.want) + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + ToID: tt.fields.ToID, + ClassificationID: tt.fields.ClassificationID, + ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, + ImmutableProperties: tt.fields.ImmutableProperties, + MutableMetaProperties: tt.fields.MutableMetaProperties, + MutableProperties: tt.fields.MutableProperties, + } + if got := transactionRequest.GetCommonTransactionRequest(); !reflect.DeepEqual(got, tt.want) { + t.Errorf("GetCommonTransactionRequest() = %v, want %v", got, tt.want) } }) } @@ -223,14 +173,14 @@ func Test_transactionRequest_GetBaseReq(t *testing.T) { func Test_transactionRequest_MakeMsg(t *testing.T) { type fields struct { - BaseReq rest.BaseReq - FromID string - ToID string - ClassificationID string - ImmutableMetaProperties string - ImmutableProperties string - MutableMetaProperties string - MutableProperties string + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + ToID string + ClassificationID string + ImmutableMetaProperties string + ImmutableProperties string + MutableMetaProperties string + MutableProperties string } tests := []struct { name string @@ -238,19 +188,19 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { want types.Msg wantErr bool }{ - {"+ve", fields{testBaseRequest, fromID.AsString(), fromID.AsString(), classificationID.AsString(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, NewMessage(fromAccAddress, fromID, fromID, classificationID, immutableMetaProperties1, immutableProperties1.ScrubData(), mutableMetaProperties1, mutableProperties1.ScrubData()), false}, + {"+ve", fields{commonTransactionRequest, fromID.AsString(), fromID.AsString(), classificationID.AsString(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, NewMessage(fromAccAddress, fromID, fromID, classificationID, immutableMetaProperties1, immutableProperties1.ScrubData(), mutableMetaProperties1, mutableProperties1.ScrubData()), false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - ToID: tt.fields.ToID, - ClassificationID: tt.fields.ClassificationID, - ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, - ImmutableProperties: tt.fields.ImmutableProperties, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + ToID: tt.fields.ToID, + ClassificationID: tt.fields.ClassificationID, + ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, + ImmutableProperties: tt.fields.ImmutableProperties, + MutableMetaProperties: tt.fields.MutableMetaProperties, + MutableProperties: tt.fields.MutableProperties, } got, err := transactionRequest.MakeMsg() if (err != nil) != tt.wantErr { @@ -264,73 +214,35 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { } } -func Test_transactionRequest_RegisterCodec(t *testing.T) { - type fields struct { - BaseReq rest.BaseReq - FromID string - ToID string - ClassificationID string - ImmutableMetaProperties string - ImmutableProperties string - MutableMetaProperties string - MutableProperties string - } - type args struct { - legacyAmino *sdkCodec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{testBaseRequest, fromID.AsString(), fromID.AsString(), classificationID.AsString(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, args{sdkCodec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - tr := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - ToID: tt.fields.ToID, - ClassificationID: tt.fields.ClassificationID, - ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, - ImmutableProperties: tt.fields.ImmutableProperties, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, - } - tr.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - func Test_transactionRequest_Validate(t *testing.T) { type fields struct { - BaseReq rest.BaseReq - FromID string - ToID string - ClassificationID string - ImmutableMetaProperties string - ImmutableProperties string - MutableMetaProperties string - MutableProperties string + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + ToID string + ClassificationID string + ImmutableMetaProperties string + ImmutableProperties string + MutableMetaProperties string + MutableProperties string } tests := []struct { name string fields fields wantErr bool }{ - {"+ve", fields{testBaseRequest, fromID.AsString(), fromID.AsString(), classificationID.AsString(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, false}, + {"+ve", fields{commonTransactionRequest, fromID.AsString(), fromID.AsString(), classificationID.AsString(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - ToID: tt.fields.ToID, - ClassificationID: tt.fields.ClassificationID, - ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, - ImmutableProperties: tt.fields.ImmutableProperties, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + ToID: tt.fields.ToID, + ClassificationID: tt.fields.ClassificationID, + ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, + ImmutableProperties: tt.fields.ImmutableProperties, + MutableMetaProperties: tt.fields.MutableMetaProperties, + MutableProperties: tt.fields.MutableProperties, } if err := transactionRequest.Validate(); (err != nil) != tt.wantErr { t.Errorf("ValidateBasic() error = %v, wantErr %v", err, tt.wantErr) diff --git a/x/assets/transactions/mint/transaction_response.go b/x/assets/transactions/mint/transaction_response.go index 4bc62f2d4..e652e1499 100644 --- a/x/assets/transactions/mint/transaction_response.go +++ b/x/assets/transactions/mint/transaction_response.go @@ -4,11 +4,10 @@ package mint import ( + "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" sdkTypes "github.com/cosmos/cosmos-sdk/types" - - "github.com/AssetMantle/modules/helpers" ) var _ helpers.TransactionResponse = (*TransactionResponse)(nil) diff --git a/x/assets/transactions/mutate/message.go b/x/assets/transactions/mutate/message.go index 85ffe12bd..66104b62a 100644 --- a/x/assets/transactions/mutate/message.go +++ b/x/assets/transactions/mutate/message.go @@ -4,28 +4,17 @@ package mutate import ( - codecUtilities "github.com/AssetMantle/schema/codec/utilities" + "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" "github.com/AssetMantle/schema/lists" baseLists "github.com/AssetMantle/schema/lists/base" - sdkCodec "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/types" sdkTypes "github.com/cosmos/cosmos-sdk/types" - - "github.com/AssetMantle/modules/helpers" ) var _ helpers.Message = (*Message)(nil) -func (message *Message) Type() string { return Transaction.GetName() } -func (message *Message) GetFromAddress() sdkTypes.AccAddress { - from, err := sdkTypes.AccAddressFromBech32(message.From) - if err != nil { - panic(err) - } - return from -} func (message *Message) ValidateBasic() error { if _, err := sdkTypes.AccAddressFromBech32(message.From); err != nil { return err @@ -51,21 +40,10 @@ func (message *Message) GetSigners() []sdkTypes.AccAddress { } return []sdkTypes.AccAddress{from} } -func (*Message) RegisterLegacyAminoCodec(legacyAmino *sdkCodec.LegacyAmino) { - codecUtilities.RegisterModuleConcrete(legacyAmino, Message{}) -} func (message *Message) RegisterInterface(interfaceRegistry types.InterfaceRegistry) { interfaceRegistry.RegisterImplementations((*sdkTypes.Msg)(nil), message) } -func messageFromInterface(msg sdkTypes.Msg) *Message { - switch value := msg.(type) { - case *Message: - return value - default: - return &Message{} - } -} func messagePrototype() helpers.Message { return &Message{} } diff --git a/x/assets/transactions/mutate/message_test.go b/x/assets/transactions/mutate/message_test.go index 32c490843..d9cca394c 100644 --- a/x/assets/transactions/mutate/message_test.go +++ b/x/assets/transactions/mutate/message_test.go @@ -14,7 +14,6 @@ import ( baseLists "github.com/AssetMantle/schema/lists/base" baseProperties "github.com/AssetMantle/schema/properties/base" baseQualified "github.com/AssetMantle/schema/qualified/base" - sdkCodec "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" "github.com/AssetMantle/modules/helpers" @@ -41,26 +40,6 @@ type fields struct { MutableProperties *baseLists.PropertyList } -func Test_messageFromInterface(t *testing.T) { - type args struct { - msg sdkTypes.Msg - } - tests := []struct { - name string - args args - want helpers.Message - }{ - {"+ve", args{NewMessage(fromAccAddress, fromID, testAssetID, mutableMetaProperties, mutableProperties)}, NewMessage(fromAccAddress, fromID, testAssetID, mutableMetaProperties, mutableProperties).(*Message)}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := messageFromInterface(tt.args.msg); !reflect.DeepEqual(got, tt.want) { - t.Errorf("messageFromInterface() = %v, want %v", got, tt.want) - } - }) - } -} - func Test_messagePrototype(t *testing.T) { tests := []struct { name string @@ -102,57 +81,6 @@ func Test_message_GetSigners(t *testing.T) { } } -func Test_message_RegisterCodec(t *testing.T) { - - type args struct { - legacyAmino *sdkCodec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{fromAccAddress.String(), fromID, testAssetID, mutableMetaProperties, mutableProperties}, args{sdkCodec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - me := &Message{ - From: tt.fields.From, - FromID: tt.fields.FromID, - AssetID: tt.fields.AssetID, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, - } - me.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - -func Test_message_Type(t *testing.T) { - - tests := []struct { - name string - fields fields - want string - }{ - {"+ve", fields{fromAccAddress.String(), fromID, testAssetID, mutableMetaProperties, mutableProperties}, Transaction.GetName()}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - message := &Message{ - From: tt.fields.From, - FromID: tt.fields.FromID, - AssetID: tt.fields.AssetID, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, - } - if got := message.Type(); got != tt.want { - t.Errorf("Type() = %v, want %v", got, tt.want) - } - }) - } -} - func Test_message_ValidateBasic(t *testing.T) { tests := []struct { diff --git a/x/assets/transactions/mutate/service.pb.go b/x/assets/transactions/mutate/service.pb.go index db5cfd106..c60db7f78 100644 --- a/x/assets/transactions/mutate/service.pb.go +++ b/x/assets/transactions/mutate/service.pb.go @@ -6,9 +6,9 @@ package mutate import ( context "context" fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types/msgservice" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" - _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -31,30 +31,29 @@ func init() { } var fileDescriptor_0cec9114e6ce7c03 = []byte{ - // 360 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0xd2, 0xcf, 0x4a, 0xeb, 0x40, - 0x14, 0x06, 0xf0, 0x26, 0x85, 0x2e, 0xc2, 0x5d, 0x15, 0x2e, 0x42, 0xd0, 0x2c, 0xfa, 0x00, 0x33, - 0xe2, 0x9f, 0x85, 0xa3, 0x08, 0x2d, 0x88, 0x82, 0x0c, 0x14, 0xed, 0x22, 0x48, 0x40, 0xa6, 0xe9, - 0x10, 0x03, 0xc9, 0x4c, 0xc9, 0x99, 0x4a, 0xb7, 0xfa, 0x04, 0x82, 0x6f, 0xe0, 0x4e, 0x77, 0xbe, - 0x85, 0xb8, 0x2a, 0xb8, 0x71, 0x29, 0xa9, 0x2b, 0x9f, 0x42, 0x9a, 0x19, 0x70, 0xba, 0x9c, 0xed, - 0x09, 0xbf, 0x8f, 0xef, 0x4c, 0x4e, 0x70, 0xdc, 0x07, 0xe0, 0x8a, 0x32, 0xa1, 0x0a, 0x8e, 0x4b, - 0x39, 0x99, 0x15, 0x1c, 0xf0, 0x1c, 0xb3, 0xd5, 0x14, 0xb0, 0xaa, 0x98, 0x00, 0x96, 0xaa, 0x5c, - 0x0a, 0xc0, 0xe5, 0x4c, 0x31, 0xc5, 0x31, 0xf0, 0xea, 0x36, 0x4f, 0x39, 0x9a, 0x56, 0x52, 0xc9, - 0xee, 0xb6, 0xe5, 0x91, 0xf1, 0x68, 0x8e, 0xb4, 0x47, 0xb6, 0x47, 0xda, 0x87, 0x9b, 0x99, 0x94, - 0x59, 0xc1, 0x31, 0x9b, 0xe6, 0x98, 0x09, 0x21, 0x15, 0xd3, 0x9f, 0x9b, 0xbc, 0xd0, 0xbd, 0x4f, - 0xc9, 0x01, 0x58, 0x66, 0xfa, 0x84, 0xe7, 0xce, 0xde, 0x9a, 0x5d, 0x57, 0x1c, 0xa6, 0x52, 0x80, - 0x09, 0xdb, 0x79, 0xf5, 0x82, 0x36, 0x85, 0xac, 0xfb, 0xec, 0x05, 0x9d, 0x33, 0x26, 0x26, 0x05, - 0xef, 0x1e, 0x20, 0xd7, 0x85, 0x11, 0xd5, 0x05, 0xc3, 0x13, 0x77, 0x3a, 0xfa, 0x9b, 0x5d, 0x98, - 0x6a, 0xbd, 0xad, 0xfb, 0x8f, 0xef, 0x47, 0x7f, 0xa3, 0xf7, 0x1f, 0x97, 0x7a, 0x4b, 0xb3, 0x9b, - 0x26, 0x83, 0xbb, 0xf6, 0x5b, 0x1d, 0x79, 0x8b, 0x3a, 0xf2, 0xbe, 0xea, 0xc8, 0x7b, 0x58, 0x46, - 0xad, 0xc5, 0x32, 0x6a, 0x7d, 0x2e, 0xa3, 0x56, 0xb0, 0x97, 0xca, 0xd2, 0xb9, 0xc3, 0xe0, 0xdf, - 0xa5, 0xfe, 0xe1, 0xc3, 0xd5, 0x93, 0x0c, 0xbd, 0xab, 0xc3, 0x2c, 0x57, 0x37, 0xb3, 0x31, 0x4a, - 0x65, 0x89, 0x5d, 0x1f, 0xfb, 0xc9, 0xef, 0xf4, 0x69, 0xdc, 0x1f, 0xd1, 0x17, 0x7f, 0xed, 0x70, - 0xa8, 0x29, 0x12, 0xeb, 0x7a, 0x60, 0x2f, 0x0e, 0x88, 0x36, 0xf6, 0x7d, 0x8d, 0x24, 0x86, 0x24, - 0x71, 0xa2, 0x49, 0x62, 0x93, 0x44, 0x93, 0xda, 0x3f, 0x72, 0x25, 0xc9, 0xe9, 0x70, 0x40, 0xb9, - 0x62, 0x13, 0xa6, 0xd8, 0x8f, 0xbf, 0x6f, 0x71, 0x42, 0x8c, 0x27, 0x24, 0x26, 0x44, 0x27, 0x10, - 0x62, 0x47, 0x10, 0xa2, 0x33, 0xc6, 0x9d, 0xe6, 0x7c, 0x76, 0x7f, 0x03, 0x00, 0x00, 0xff, 0xff, - 0x80, 0x6e, 0xa3, 0xb9, 0x5d, 0x03, 0x00, 0x00, + // 347 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0xd2, 0xbf, 0x4b, 0xc3, 0x40, + 0x14, 0x07, 0xf0, 0x5c, 0x8a, 0x1d, 0x82, 0x53, 0x17, 0x21, 0x43, 0x06, 0x47, 0x87, 0x3b, 0x7f, + 0x0e, 0x9e, 0x22, 0xb4, 0x20, 0x0a, 0x72, 0x50, 0xb4, 0x43, 0x90, 0x80, 0x5c, 0xd3, 0x23, 0x16, + 0x7a, 0xb9, 0x92, 0x77, 0x2d, 0x1d, 0x75, 0x77, 0x70, 0x77, 0x73, 0x74, 0xf2, 0xcf, 0x10, 0xa7, + 0x8e, 0x8e, 0x92, 0x0e, 0x82, 0x7f, 0x85, 0xb4, 0x77, 0xe0, 0x75, 0xbc, 0x29, 0xf0, 0xe0, 0xf3, + 0xcd, 0xf7, 0x25, 0x2f, 0x3a, 0x6b, 0x03, 0x08, 0xcd, 0x78, 0xa9, 0x47, 0x82, 0x48, 0x35, 0x98, + 0x8c, 0x04, 0x90, 0x19, 0xe1, 0xcb, 0x29, 0x10, 0x5d, 0xf1, 0x12, 0x78, 0xae, 0x87, 0xaa, 0x04, + 0x22, 0x27, 0x9a, 0x6b, 0x41, 0x40, 0x54, 0xd3, 0x61, 0x2e, 0xf0, 0xb8, 0x52, 0x5a, 0xb5, 0x76, + 0x1d, 0x8f, 0xad, 0xc7, 0x33, 0x6c, 0x3c, 0x76, 0x3d, 0x36, 0x3e, 0xde, 0xca, 0x15, 0x48, 0x05, + 0x44, 0x42, 0x41, 0xa6, 0x7b, 0xcb, 0x87, 0x89, 0x8a, 0xfd, 0xab, 0x48, 0x01, 0xc0, 0x0b, 0x5b, + 0x25, 0xbe, 0xf2, 0xf6, 0xce, 0xec, 0xae, 0x12, 0x30, 0x56, 0x25, 0xd8, 0xb0, 0xfd, 0x17, 0x14, + 0x35, 0x18, 0x14, 0xad, 0x27, 0x14, 0x35, 0x2f, 0x79, 0x39, 0x18, 0x89, 0xd6, 0x31, 0xf6, 0xdd, + 0x15, 0x33, 0x53, 0x30, 0x3e, 0xf7, 0xa7, 0xbd, 0xff, 0xd9, 0xb5, 0xad, 0xb6, 0x1d, 0xc4, 0x1b, + 0x0f, 0x3f, 0xef, 0x3b, 0xa8, 0xf3, 0xd8, 0xf8, 0xa8, 0x13, 0x34, 0xaf, 0x13, 0xf4, 0x5d, 0x27, + 0xe8, 0x79, 0x91, 0x04, 0xf3, 0x45, 0x12, 0x7c, 0x2d, 0x92, 0x20, 0x3a, 0xcc, 0x95, 0xf4, 0x7e, + 0x5b, 0x67, 0xf3, 0xc6, 0xfc, 0xd5, 0xee, 0x72, 0xf9, 0x2e, 0xba, 0x3d, 0x29, 0x86, 0xfa, 0x7e, + 0xd2, 0xc7, 0xb9, 0x92, 0xc4, 0xf7, 0xb3, 0xbe, 0x86, 0xcd, 0x36, 0x4b, 0xdb, 0x3d, 0xf6, 0x16, + 0xae, 0x5d, 0x07, 0xb3, 0x45, 0x52, 0x53, 0x0f, 0xdc, 0x15, 0x01, 0xb3, 0x95, 0xfd, 0x5c, 0x23, + 0x99, 0x25, 0x59, 0x9a, 0x19, 0x92, 0xb9, 0x24, 0x33, 0xa4, 0x0e, 0x4f, 0x7d, 0x49, 0x76, 0xd1, + 0xed, 0x30, 0xa1, 0xf9, 0x80, 0x6b, 0xfe, 0x1b, 0x1e, 0x39, 0x9c, 0x52, 0xeb, 0x29, 0x4d, 0x29, + 0x35, 0x09, 0x94, 0xba, 0x11, 0x94, 0x9a, 0x8c, 0x7e, 0x73, 0x75, 0x28, 0x07, 0x7f, 0x01, 0x00, + 0x00, 0xff, 0xff, 0xee, 0x04, 0xf7, 0x63, 0x42, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/assets/transactions/mutate/service.pb.gw.go b/x/assets/transactions/mutate/service.pb.gw.go deleted file mode 100644 index e326df841..000000000 --- a/x/assets/transactions/mutate/service.pb.gw.go +++ /dev/null @@ -1,171 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: AssetMantle/modules/x/assets/transactions/mutate/service.proto - -/* -Package mutate is a reverse proxy. - -It translates gRPC into RESTful JSON APIs. -*/ -package mutate - -import ( - "context" - "io" - "net/http" - - "github.com/golang/protobuf/descriptor" - "github.com/golang/protobuf/proto" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/grpc-ecosystem/grpc-gateway/utilities" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/status" -) - -// Suppress "imported and not used" errors -var _ codes.Code -var _ io.Reader -var _ status.Status -var _ = runtime.String -var _ = utilities.NewDoubleArray -var _ = descriptor.ForMessage -var _ = metadata.Join - -var ( - filter_Msg_Handle_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - -func request_Msg_Handle_0(ctx context.Context, marshaler runtime.Marshaler, client MsgClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq Message - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.Handle(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Msg_Handle_0(ctx context.Context, marshaler runtime.Marshaler, server MsgServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq Message - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.Handle(ctx, &protoReq) - return msg, metadata, err - -} - -// RegisterMsgHandlerServer registers the http handlers for service Msg to "mux". -// UnaryRPC :call MsgServer directly. -// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterMsgHandlerFromEndpoint instead. -func RegisterMsgHandlerServer(ctx context.Context, mux *runtime.ServeMux, server MsgServer) error { - - mux.Handle("POST", pattern_Msg_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Msg_Handle_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Msg_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -// RegisterMsgHandlerFromEndpoint is same as RegisterMsgHandler but -// automatically dials to "endpoint" and closes the connection when "ctx" gets done. -func RegisterMsgHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.Dial(endpoint, opts...) - if err != nil { - return err - } - defer func() { - if err != nil { - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - return - } - go func() { - <-ctx.Done() - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - }() - }() - - return RegisterMsgHandler(ctx, mux, conn) -} - -// RegisterMsgHandler registers the http handlers for service Msg to "mux". -// The handlers forward requests to the grpc endpoint over "conn". -func RegisterMsgHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { - return RegisterMsgHandlerClient(ctx, mux, NewMsgClient(conn)) -} - -// RegisterMsgHandlerClient registers the http handlers for service Msg -// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "MsgClient". -// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "MsgClient" -// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "MsgClient" to call the correct interceptors. -func RegisterMsgHandlerClient(ctx context.Context, mux *runtime.ServeMux, client MsgClient) error { - - mux.Handle("POST", pattern_Msg_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Msg_Handle_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Msg_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -var ( - pattern_Msg_Handle_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"mantle", "assets", "mutate"}, "", runtime.AssumeColonVerbOpt(false))) -) - -var ( - forward_Msg_Handle_0 = runtime.ForwardResponseMessage -) diff --git a/x/assets/transactions/mutate/transaction.go b/x/assets/transactions/mutate/transaction.go index 6986e06ac..7408c6fa9 100644 --- a/x/assets/transactions/mutate/transaction.go +++ b/x/assets/transactions/mutate/transaction.go @@ -4,22 +4,14 @@ package mutate import ( - "context" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "google.golang.org/grpc" - "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/helpers/constants" - "github.com/AssetMantle/modules/utilities/name" + "google.golang.org/grpc" ) -type dummy struct{} - var Transaction = baseHelpers.NewTransaction( - name.GetPackageName(dummy{}), + _Msg_serviceDesc.ServiceName, "", "", @@ -30,9 +22,6 @@ var Transaction = baseHelpers.NewTransaction( func(server grpc.ServiceRegistrar, keeper helpers.TransactionKeeper) { RegisterMsgServer(server, keeper.(transactionKeeper)) }, - func(clientCtx client.Context, mux *runtime.ServeMux) error { - return RegisterMsgHandlerClient(context.Background(), mux, NewMsgClient(clientCtx)) - }, constants.AssetID, constants.FromIdentityID, diff --git a/x/assets/transactions/mutate/transaction_keeper.go b/x/assets/transactions/mutate/transaction_keeper.go index 4e0f1e2bf..07142c151 100644 --- a/x/assets/transactions/mutate/transaction_keeper.go +++ b/x/assets/transactions/mutate/transaction_keeper.go @@ -5,9 +5,8 @@ package mutate import ( "context" - errorConstants "github.com/AssetMantle/modules/helpers/constants" - "github.com/AssetMantle/modules/helpers" + errorConstants "github.com/AssetMantle/modules/helpers/constants" "github.com/AssetMantle/modules/x/assets/key" "github.com/AssetMantle/modules/x/assets/mappable" "github.com/AssetMantle/modules/x/assets/record" @@ -33,7 +32,7 @@ func (transactionKeeper transactionKeeper) Transact(context context.Context, mes } func (transactionKeeper transactionKeeper) Handle(context context.Context, message *Message) (*TransactionResponse, error) { - fromAddress := message.GetFromAddress() + fromAddress := message.GetSigners()[0] if _, err := transactionKeeper.authenticateAuxiliary.GetKeeper().Help(context, authenticate.NewAuxiliaryRequest(fromAddress, message.FromID)); err != nil { return nil, err diff --git a/x/assets/transactions/mutate/transaction_request.go b/x/assets/transactions/mutate/transaction_request.go index 471bf5dd6..5f0f56a3e 100644 --- a/x/assets/transactions/mutate/transaction_request.go +++ b/x/assets/transactions/mutate/transaction_request.go @@ -5,26 +5,24 @@ package mutate import ( "encoding/json" - "github.com/AssetMantle/modules/utilities/rest" - - codecUtilities "github.com/AssetMantle/schema/codec/utilities" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" "github.com/AssetMantle/schema/lists/base" "github.com/cosmos/cosmos-sdk/client" - sdkCodec "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" + "io" + "net/http" "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/helpers/constants" ) type transactionRequest struct { - BaseReq rest.BaseReq `json:"baseReq"` - FromID string `json:"fromID"` - AssetID string `json:"assetID"` - MutableMetaProperties string `json:"mutableMetaProperties"` - MutableProperties string `json:"mutableProperties"` + helpers.CommonTransactionRequest `json:"commonTransactionRequest"` + FromID string `json:"fromID"` + AssetID string `json:"assetID"` + MutableMetaProperties string `json:"mutableMetaProperties"` + MutableProperties string `json:"mutableProperties"` } var _ helpers.TransactionRequest = (*transactionRequest)(nil) @@ -50,25 +48,30 @@ func (transactionRequest transactionRequest) Validate() error { } func (transactionRequest transactionRequest) FromCLI(cliCommand helpers.CLICommand, context client.Context) (helpers.TransactionRequest, error) { return newTransactionRequest( - cliCommand.ReadBaseReq(context), + cliCommand.ReadCommonTransactionRequest(context), cliCommand.ReadString(constants.FromIdentityID), cliCommand.ReadString(constants.AssetID), cliCommand.ReadString(constants.MutableMetaProperties), cliCommand.ReadString(constants.MutableProperties), ), nil } -func (transactionRequest transactionRequest) FromJSON(rawMessage json.RawMessage) (helpers.TransactionRequest, error) { - if err := json.Unmarshal(rawMessage, &transactionRequest); err != nil { +func (transactionRequest transactionRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.TransactionRequest, error) { + body, err := io.ReadAll(httpRequest.Body) + if err != nil { + return nil, err + } + + if err := json.Unmarshal(body, &transactionRequest); err != nil { return nil, err } return transactionRequest, nil } -func (transactionRequest transactionRequest) GetBaseReq() rest.BaseReq { - return transactionRequest.BaseReq +func (transactionRequest transactionRequest) GetCommonTransactionRequest() helpers.CommonTransactionRequest { + return transactionRequest.CommonTransactionRequest } func (transactionRequest transactionRequest) MakeMsg() (sdkTypes.Msg, error) { - from, err := sdkTypes.AccAddressFromBech32(transactionRequest.GetBaseReq().From) + from, err := sdkTypes.AccAddressFromBech32(transactionRequest.GetCommonTransactionRequest().GetFrom()) if err != nil { return nil, err } @@ -102,19 +105,16 @@ func (transactionRequest transactionRequest) MakeMsg() (sdkTypes.Msg, error) { mutableProperties, ), nil } -func (transactionRequest) RegisterLegacyAminoCodec(legacyAmino *sdkCodec.LegacyAmino) { - codecUtilities.RegisterModuleConcrete(legacyAmino, transactionRequest{}) -} func requestPrototype() helpers.TransactionRequest { return transactionRequest{} } -func newTransactionRequest(baseReq rest.BaseReq, fromID string, assetID string, mutableMetaProperties string, mutableProperties string) helpers.TransactionRequest { +func newTransactionRequest(commonTransactionRequest helpers.CommonTransactionRequest, fromID string, assetID string, mutableMetaProperties string, mutableProperties string) helpers.TransactionRequest { return transactionRequest{ - BaseReq: baseReq, - FromID: fromID, - AssetID: assetID, - MutableMetaProperties: mutableMetaProperties, - MutableProperties: mutableProperties, + CommonTransactionRequest: commonTransactionRequest, + FromID: fromID, + AssetID: assetID, + MutableMetaProperties: mutableMetaProperties, + MutableProperties: mutableProperties, } } diff --git a/x/assets/transactions/mutate/transaction_request_test.go b/x/assets/transactions/mutate/transaction_request_test.go index 80870c86f..c7c9b7a6f 100644 --- a/x/assets/transactions/mutate/transaction_request_test.go +++ b/x/assets/transactions/mutate/transaction_request_test.go @@ -4,9 +4,7 @@ package mutate import ( - "encoding/json" "fmt" - "github.com/AssetMantle/modules/utilities/rest" "reflect" "testing" @@ -15,18 +13,17 @@ import ( baseLists "github.com/AssetMantle/schema/lists/base" baseProperties "github.com/AssetMantle/schema/properties/base" "github.com/cosmos/cosmos-sdk/client" - sdkCodec "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" "github.com/spf13/viper" "github.com/AssetMantle/modules/helpers" - "github.com/AssetMantle/modules/helpers/base" + baseHelpers "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/helpers/constants" ) var ( - testBaseRequest = rest.BaseReq{From: fromAddress, ChainID: "test", Fees: sdkTypes.NewCoins()} + commonTransactionRequest = helpers.PrototypeCommonTransactionRequest() mutableMetaPropertiesString = "testMutableMeta1:S|mutableMeta" mutableMetaProperties1 = baseLists.NewPropertyList(baseProperties.NewMetaProperty(baseIDs.NewStringID("testMutableMeta1"), baseData.NewStringData("mutableMeta"))) mutablePropertiesString = "testMutable1:S|mutable" @@ -35,22 +32,22 @@ var ( func Test_newTransactionRequest(t *testing.T) { type args struct { - baseReq rest.BaseReq - fromID string - assetID string - mutableMetaProperties string - mutableProperties string + commonTransactionRequest helpers.CommonTransactionRequest + fromID string + assetID string + mutableMetaProperties string + mutableProperties string } tests := []struct { name string args args want helpers.TransactionRequest }{ - {"+ve", args{testBaseRequest, fromID.AsString(), testAssetID.AsString(), mutableMetaPropertiesString, mutablePropertiesString}, transactionRequest{testBaseRequest, fromID.AsString(), testAssetID.AsString(), mutableMetaPropertiesString, mutablePropertiesString}}, + {"+ve", args{commonTransactionRequest, fromID.AsString(), testAssetID.AsString(), mutableMetaPropertiesString, mutablePropertiesString}, transactionRequest{commonTransactionRequest, fromID.AsString(), testAssetID.AsString(), mutableMetaPropertiesString, mutablePropertiesString}}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - if got := newTransactionRequest(tt.args.baseReq, tt.args.fromID, tt.args.assetID, tt.args.mutableMetaProperties, tt.args.mutableProperties); !reflect.DeepEqual(got, tt.want) { + if got := newTransactionRequest(tt.args.commonTransactionRequest, tt.args.fromID, tt.args.assetID, tt.args.mutableMetaProperties, tt.args.mutableProperties); !reflect.DeepEqual(got, tt.want) { t.Errorf("newTransactionRequest() = %v, want %v", got, tt.want) } }) @@ -74,18 +71,18 @@ func Test_requestPrototype(t *testing.T) { } func Test_transactionRequest_FromCLI(t *testing.T) { - cliCommand := base.NewCLICommand("", "", "", []helpers.CLIFlag{constants.AssetID, constants.FromIdentityID, constants.MutableMetaProperties, constants.MutableProperties}) + cliCommand := baseHelpers.NewCLICommand("", "", "", []helpers.CLIFlag{constants.AssetID, constants.FromIdentityID, constants.MutableMetaProperties, constants.MutableProperties}) viper.Set(constants.AssetID.GetName(), testAssetID.AsString()) viper.Set(constants.FromIdentityID.GetName(), fromID.AsString()) viper.Set(constants.MutableMetaProperties.GetName(), mutableMetaPropertiesString) viper.Set(constants.MutableProperties.GetName(), mutablePropertiesString) type fields struct { - BaseReq rest.BaseReq - FromID string - AssetID string - MutableMetaProperties string - MutableProperties string + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + AssetID string + MutableMetaProperties string + MutableProperties string } type args struct { cliCommand helpers.CLICommand @@ -98,16 +95,16 @@ func Test_transactionRequest_FromCLI(t *testing.T) { want helpers.TransactionRequest wantErr bool }{ - {"+ve", fields{testBaseRequest, fromID.AsString(), testAssetID.AsString(), mutableMetaPropertiesString, mutablePropertiesString}, args{cliCommand, client.Context{}.WithCodec(base.CodecPrototype())}, transactionRequest{testBaseRequest, fromID.AsString(), testAssetID.AsString(), mutableMetaPropertiesString, mutablePropertiesString}, false}, + {"+ve", fields{commonTransactionRequest, fromID.AsString(), testAssetID.AsString(), mutableMetaPropertiesString, mutablePropertiesString}, args{cliCommand, client.Context{}.WithCodec(baseHelpers.CodecPrototype())}, transactionRequest{commonTransactionRequest, fromID.AsString(), testAssetID.AsString(), mutableMetaPropertiesString, mutablePropertiesString}, false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - AssetID: tt.fields.AssetID, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + AssetID: tt.fields.AssetID, + MutableMetaProperties: tt.fields.MutableMetaProperties, + MutableProperties: tt.fields.MutableProperties, } got, err := transactionRequest.FromCLI(tt.args.cliCommand, tt.args.context) if (err != nil) != tt.wantErr { @@ -120,74 +117,32 @@ func Test_transactionRequest_FromCLI(t *testing.T) { }) } } - -func Test_transactionRequest_FromJSON(t *testing.T) { - type fields struct { - BaseReq rest.BaseReq - FromID string - AssetID string - MutableMetaProperties string - MutableProperties string - } - type args struct { - rawMessage json.RawMessage - } - tests := []struct { - name string - fields fields - args args - want helpers.TransactionRequest - wantErr bool - }{ - {"+ve", fields{testBaseRequest, fromID.AsString(), testAssetID.AsString(), mutableMetaPropertiesString, mutablePropertiesString}, args{sdkTypes.MustSortJSON(base.CodecPrototype().MustMarshalJSON(&Message{fromAccAddress.String(), fromID, testAssetID, mutableMetaProperties, mutableProperties}))}, newTransactionRequest(testBaseRequest, fromID.AsString(), testAssetID.AsString(), mutableMetaPropertiesString, mutablePropertiesString), false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - AssetID: tt.fields.AssetID, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, - } - got, err := transactionRequest.FromJSON(tt.args.rawMessage) - if (err != nil) != tt.wantErr { - t.Errorf("FromJSON() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("FromJSON() got = %v, want %v", got, tt.want) - } - }) - } -} - func Test_transactionRequest_GetBaseReq(t *testing.T) { type fields struct { - BaseReq rest.BaseReq - FromID string - AssetID string - MutableMetaProperties string - MutableProperties string + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + AssetID string + MutableMetaProperties string + MutableProperties string } tests := []struct { name string fields fields - want rest.BaseReq + want helpers.CommonTransactionRequest }{ - {"+ve", fields{testBaseRequest, fromID.AsString(), testAssetID.AsString(), mutableMetaPropertiesString, mutablePropertiesString}, testBaseRequest}, + {"+ve", fields{commonTransactionRequest, fromID.AsString(), testAssetID.AsString(), mutableMetaPropertiesString, mutablePropertiesString}, commonTransactionRequest}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - AssetID: tt.fields.AssetID, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + AssetID: tt.fields.AssetID, + MutableMetaProperties: tt.fields.MutableMetaProperties, + MutableProperties: tt.fields.MutableProperties, } - if got := transactionRequest.GetBaseReq(); !reflect.DeepEqual(got, tt.want) { - t.Errorf("GetBaseReq() = %v, want %v", got, tt.want) + if got := transactionRequest.GetCommonTransactionRequest(); !reflect.DeepEqual(got, tt.want) { + t.Errorf("GetCommonTransactionRequest() = %v, want %v", got, tt.want) } }) } @@ -195,11 +150,11 @@ func Test_transactionRequest_GetBaseReq(t *testing.T) { func Test_transactionRequest_MakeMsg(t *testing.T) { type fields struct { - BaseReq rest.BaseReq - FromID string - AssetID string - MutableMetaProperties string - MutableProperties string + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + AssetID string + MutableMetaProperties string + MutableProperties string } tests := []struct { name string @@ -207,16 +162,16 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { want sdkTypes.Msg wantErr bool }{ - {"+ve", fields{testBaseRequest, fromID.AsString(), testAssetID.AsString(), mutableMetaPropertiesString, mutablePropertiesString}, NewMessage(fromAccAddress, fromID, testAssetID, mutableMetaProperties1, mutableProperties1.ScrubData()), false}, + {"+ve", fields{commonTransactionRequest, fromID.AsString(), testAssetID.AsString(), mutableMetaPropertiesString, mutablePropertiesString}, NewMessage(fromAccAddress, fromID, testAssetID, mutableMetaProperties1, mutableProperties1.ScrubData()), false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - AssetID: tt.fields.AssetID, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + AssetID: tt.fields.AssetID, + MutableMetaProperties: tt.fields.MutableMetaProperties, + MutableProperties: tt.fields.MutableProperties, } got, err := transactionRequest.MakeMsg() if (err != nil) != tt.wantErr { @@ -230,61 +185,29 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { } } -func Test_transactionRequest_RegisterCodec(t *testing.T) { - type fields struct { - BaseReq rest.BaseReq - FromID string - AssetID string - MutableMetaProperties string - MutableProperties string - } - type args struct { - legacyAmino *sdkCodec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{testBaseRequest, fromID.AsString(), testAssetID.AsString(), mutableMetaPropertiesString, mutablePropertiesString}, args{sdkCodec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - tr := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - AssetID: tt.fields.AssetID, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, - } - tr.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - func Test_transactionRequest_Validate(t *testing.T) { type fields struct { - BaseReq rest.BaseReq - FromID string - AssetID string - MutableMetaProperties string - MutableProperties string + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + AssetID string + MutableMetaProperties string + MutableProperties string } tests := []struct { name string fields fields wantErr bool }{ - {"+ve", fields{testBaseRequest, fromID.AsString(), testAssetID.AsString(), mutableMetaPropertiesString, mutablePropertiesString}, false}, + {"+ve", fields{commonTransactionRequest, fromID.AsString(), testAssetID.AsString(), mutableMetaPropertiesString, mutablePropertiesString}, false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - AssetID: tt.fields.AssetID, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + AssetID: tt.fields.AssetID, + MutableMetaProperties: tt.fields.MutableMetaProperties, + MutableProperties: tt.fields.MutableProperties, } if err := transactionRequest.Validate(); (err != nil) != tt.wantErr { t.Errorf("ValidateBasic() error = %v, wantErr %v", err, tt.wantErr) diff --git a/x/assets/transactions/mutate/transaction_response.go b/x/assets/transactions/mutate/transaction_response.go index c41a27426..cba850907 100644 --- a/x/assets/transactions/mutate/transaction_response.go +++ b/x/assets/transactions/mutate/transaction_response.go @@ -4,9 +4,8 @@ package mutate import ( - sdkTypes "github.com/cosmos/cosmos-sdk/types" - "github.com/AssetMantle/modules/helpers" + sdkTypes "github.com/cosmos/cosmos-sdk/types" ) var _ helpers.TransactionResponse = (*TransactionResponse)(nil) diff --git a/x/assets/transactions/renumerate/message.go b/x/assets/transactions/renumerate/message.go index 40b88772f..74cac82b9 100644 --- a/x/assets/transactions/renumerate/message.go +++ b/x/assets/transactions/renumerate/message.go @@ -4,26 +4,15 @@ package renumerate import ( - codecUtilities "github.com/AssetMantle/schema/codec/utilities" + "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" - sdkCodec "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/types" sdkTypes "github.com/cosmos/cosmos-sdk/types" - - "github.com/AssetMantle/modules/helpers" ) var _ helpers.Message = (*Message)(nil) -func (message *Message) Type() string { return Transaction.GetName() } -func (message *Message) GetFromAddress() sdkTypes.AccAddress { - from, err := sdkTypes.AccAddressFromBech32(message.From) - if err != nil { - panic(err) - } - return from -} func (message *Message) ValidateBasic() error { if _, err := sdkTypes.AccAddressFromBech32(message.From); err != nil { return err @@ -43,21 +32,10 @@ func (message *Message) GetSigners() []sdkTypes.AccAddress { } return []sdkTypes.AccAddress{from} } -func (*Message) RegisterLegacyAminoCodec(legacyAmino *sdkCodec.LegacyAmino) { - codecUtilities.RegisterModuleConcrete(legacyAmino, Message{}) -} func (message *Message) RegisterInterface(interfaceRegistry types.InterfaceRegistry) { interfaceRegistry.RegisterImplementations((*sdkTypes.Msg)(nil), message) } -func messageFromInterface(msg sdkTypes.Msg) *Message { - switch value := msg.(type) { - case *Message: - return value - default: - return &Message{} - } -} func messagePrototype() helpers.Message { return &Message{} } diff --git a/x/assets/transactions/renumerate/message_test.go b/x/assets/transactions/renumerate/message_test.go index c81cef8e0..7739c1115 100644 --- a/x/assets/transactions/renumerate/message_test.go +++ b/x/assets/transactions/renumerate/message_test.go @@ -13,7 +13,6 @@ import ( baseLists "github.com/AssetMantle/schema/lists/base" baseProperties "github.com/AssetMantle/schema/properties/base" baseQualified "github.com/AssetMantle/schema/qualified/base" - sdkCodec "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" "github.com/AssetMantle/modules/helpers" @@ -37,26 +36,6 @@ type fields struct { AssetID *baseIDs.AssetID } -func Test_messageFromInterface(t *testing.T) { - type args struct { - msg sdkTypes.Msg - } - tests := []struct { - name string - args args - want helpers.Message - }{ - {"+ve", args{NewMessage(fromAccAddress, fromID, testAssetID)}, NewMessage(fromAccAddress, fromID, testAssetID).(*Message)}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := messageFromInterface(tt.args.msg); !reflect.DeepEqual(got, tt.want) { - t.Errorf("messageFromInterface() = %v, want %v", got, tt.want) - } - }) - } -} - func Test_messagePrototype(t *testing.T) { tests := []struct { name string @@ -96,53 +75,6 @@ func Test_message_GetSigners(t *testing.T) { } } -func Test_message_RegisterCodec(t *testing.T) { - - type args struct { - legacyAmino *sdkCodec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{fromAccAddress.String(), fromID, testAssetID}, args{sdkCodec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - me := &Message{ - From: tt.fields.From, - FromID: tt.fields.FromID, - AssetID: tt.fields.AssetID, - } - me.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - -func Test_message_Type(t *testing.T) { - - tests := []struct { - name string - fields fields - want string - }{ - {"+ve", fields{fromAccAddress.String(), fromID, testAssetID}, Transaction.GetName()}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - message := &Message{ - From: tt.fields.From, - FromID: tt.fields.FromID, - AssetID: tt.fields.AssetID, - } - if got := message.Type(); got != tt.want { - t.Errorf("Type() = %v, want %v", got, tt.want) - } - }) - } -} - func Test_message_ValidateBasic(t *testing.T) { tests := []struct { diff --git a/x/assets/transactions/renumerate/service.pb.go b/x/assets/transactions/renumerate/service.pb.go index 0b30a071b..53e83bace 100644 --- a/x/assets/transactions/renumerate/service.pb.go +++ b/x/assets/transactions/renumerate/service.pb.go @@ -6,9 +6,9 @@ package renumerate import ( context "context" fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types/msgservice" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" - _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -31,30 +31,30 @@ func init() { } var fileDescriptor_88dc66d07d98c2a7 = []byte{ - // 363 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x92, 0x31, 0x4b, 0xf3, 0x40, - 0x18, 0x80, 0x9b, 0x14, 0x3a, 0x84, 0x6f, 0xea, 0xf6, 0x45, 0x09, 0xd8, 0x1f, 0x70, 0x07, 0xea, - 0xa0, 0x07, 0xa2, 0xcd, 0xa2, 0x0e, 0xc1, 0x52, 0x3b, 0x04, 0x09, 0xc8, 0x35, 0x3d, 0x62, 0x20, - 0xb9, 0x2b, 0x79, 0xaf, 0xd2, 0xd9, 0x5f, 0x20, 0x38, 0xb9, 0x3a, 0xba, 0x3b, 0xba, 0x8b, 0x53, - 0xc1, 0xc5, 0x51, 0x52, 0x27, 0x7f, 0x85, 0xb4, 0x77, 0x98, 0xeb, 0x7a, 0xeb, 0x4b, 0x9e, 0x87, - 0xe7, 0xbd, 0xbc, 0x5e, 0xd8, 0x07, 0x60, 0x32, 0xa2, 0x5c, 0x16, 0x0c, 0x97, 0x62, 0x32, 0x2b, - 0x18, 0xe0, 0x39, 0xa6, 0xab, 0x29, 0x60, 0x59, 0x51, 0x0e, 0x34, 0x95, 0xb9, 0xe0, 0x80, 0x2b, - 0xc6, 0x67, 0x25, 0xab, 0xa8, 0x64, 0x18, 0x58, 0x75, 0x9b, 0xa7, 0x0c, 0x4d, 0x2b, 0x21, 0x45, - 0x77, 0xdf, 0x70, 0x20, 0xed, 0x40, 0x73, 0xa4, 0x1c, 0xc8, 0x74, 0xa0, 0xc6, 0xe1, 0x6f, 0x67, - 0x42, 0x64, 0x05, 0xc3, 0x74, 0x9a, 0x63, 0xca, 0xb9, 0x90, 0x54, 0x7d, 0xb2, 0x76, 0xfa, 0x76, - 0x5d, 0x25, 0x03, 0xa0, 0x99, 0xee, 0xf2, 0x2f, 0xac, 0x1c, 0xc6, 0xfc, 0xba, 0x62, 0x30, 0x15, - 0x1c, 0xb4, 0x70, 0xf7, 0xd5, 0xf1, 0xda, 0x11, 0x64, 0xdd, 0x17, 0xc7, 0xeb, 0x9c, 0x51, 0x3e, - 0x29, 0x58, 0xf7, 0x08, 0xd9, 0x2c, 0x8f, 0x22, 0x15, 0xea, 0x9f, 0xdb, 0xe1, 0xa3, 0x66, 0x3e, - 0xd4, 0x89, 0xbd, 0x9d, 0xbb, 0x8f, 0xef, 0x07, 0x77, 0xab, 0xf7, 0x1f, 0x97, 0x6a, 0x63, 0xbd, - 0x67, 0x83, 0x85, 0x8f, 0xed, 0xb7, 0x3a, 0x70, 0x16, 0x75, 0xe0, 0x7c, 0xd5, 0x81, 0x73, 0xbf, - 0x0c, 0x5a, 0x8b, 0x65, 0xd0, 0xfa, 0x5c, 0x06, 0x2d, 0xef, 0x20, 0x15, 0xa5, 0x55, 0x4b, 0xf8, - 0xef, 0x52, 0x1d, 0xc3, 0x60, 0xf5, 0x44, 0x03, 0xe7, 0xea, 0x38, 0xcb, 0xe5, 0xcd, 0x6c, 0x8c, - 0x52, 0x51, 0x62, 0x9b, 0x1f, 0xf0, 0xe4, 0x76, 0xfa, 0x51, 0xdc, 0x1f, 0x0d, 0x9f, 0xdd, 0x8d, - 0xc3, 0x8a, 0x74, 0x50, 0xac, 0x32, 0xc1, 0x7c, 0x04, 0x40, 0xc3, 0x3f, 0xfe, 0x7d, 0x03, 0x4b, - 0x34, 0x96, 0xc4, 0x89, 0xc2, 0x12, 0x13, 0x4b, 0x1a, 0xac, 0x76, 0x4f, 0x6c, 0xb0, 0xe4, 0x74, - 0x10, 0x46, 0x4c, 0xd2, 0x09, 0x95, 0xf4, 0xc7, 0x3d, 0x34, 0x14, 0x84, 0x68, 0x07, 0x21, 0x31, - 0x21, 0xca, 0x42, 0x88, 0xa9, 0x21, 0xa4, 0xf1, 0x8c, 0x3b, 0xeb, 0x13, 0xdb, 0xfb, 0x0d, 0x00, - 0x00, 0xff, 0xff, 0xf2, 0x78, 0x99, 0xb1, 0x91, 0x03, 0x00, 0x00, + // 355 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x92, 0x3f, 0x4b, 0xfb, 0x40, + 0x18, 0xc7, 0x73, 0x29, 0xbf, 0x0e, 0xe1, 0x37, 0x75, 0x11, 0x32, 0x64, 0x70, 0x74, 0xb8, 0xc3, + 0x3f, 0x83, 0x1e, 0x88, 0x36, 0x8b, 0x3a, 0x04, 0x4b, 0xed, 0x10, 0x24, 0x20, 0xd7, 0xf4, 0x88, + 0x85, 0x5e, 0xae, 0xe4, 0xb9, 0x96, 0x8e, 0xbe, 0x04, 0x07, 0x17, 0x57, 0xdd, 0x9c, 0x7c, 0x19, + 0xe2, 0xd4, 0xd1, 0x51, 0xd2, 0x41, 0xf0, 0x55, 0x48, 0xbd, 0xc3, 0x5c, 0xd7, 0x9b, 0x02, 0x5f, + 0xf8, 0x7c, 0xf2, 0x7d, 0x9e, 0x7b, 0x82, 0xb8, 0x0b, 0xc0, 0x55, 0xc2, 0x4a, 0x35, 0xe1, 0x44, + 0xc8, 0xd1, 0x6c, 0xc2, 0x81, 0x2c, 0x08, 0x5b, 0xa7, 0x40, 0x54, 0xc5, 0x4a, 0x60, 0xb9, 0x1a, + 0xcb, 0x12, 0x48, 0xc5, 0xcb, 0x99, 0xe0, 0x15, 0x53, 0x9c, 0x00, 0xaf, 0xe6, 0xe3, 0x9c, 0xe3, + 0x69, 0x25, 0x95, 0xec, 0x1c, 0x58, 0x0e, 0x6c, 0x1c, 0x78, 0x81, 0xb5, 0x03, 0xdb, 0x0e, 0xdc, + 0x38, 0xc2, 0xad, 0x5c, 0x82, 0x90, 0x40, 0x04, 0x14, 0x64, 0xbe, 0xbb, 0xfe, 0x68, 0x5d, 0xe8, + 0x56, 0x49, 0x70, 0x00, 0x56, 0x98, 0x4a, 0xe1, 0xa5, 0x93, 0xc3, 0xca, 0x6f, 0x2a, 0x0e, 0x53, + 0x59, 0x82, 0x11, 0xee, 0x3d, 0xa3, 0xa0, 0x95, 0x40, 0xd1, 0x79, 0x40, 0x41, 0xfb, 0x9c, 0x95, + 0xa3, 0x09, 0xef, 0x1c, 0x63, 0x97, 0xb9, 0x71, 0xa2, 0x8b, 0x86, 0x17, 0x6e, 0xf8, 0xa0, 0xc9, + 0xfb, 0xa6, 0xe2, 0xb6, 0x17, 0xfe, 0xbb, 0xfb, 0x7a, 0xdd, 0x41, 0xf1, 0x63, 0xeb, 0xad, 0x8e, + 0xd0, 0xb2, 0x8e, 0xd0, 0x67, 0x1d, 0xa1, 0xfb, 0x55, 0xe4, 0x2d, 0x57, 0x91, 0xf7, 0xb1, 0x8a, + 0xbc, 0xe0, 0x30, 0x97, 0xc2, 0xe9, 0x8f, 0xf1, 0xff, 0x2b, 0xfd, 0xda, 0xbd, 0xf5, 0x22, 0x7a, + 0xe8, 0xfa, 0xa4, 0x18, 0xab, 0xdb, 0xd9, 0x10, 0xe7, 0x52, 0x10, 0x97, 0x35, 0x3f, 0xf9, 0xed, + 0x6e, 0x92, 0x76, 0x07, 0xfd, 0x17, 0x7f, 0xe3, 0x72, 0x12, 0x53, 0x28, 0xd5, 0x35, 0xc1, 0x1e, + 0x15, 0x70, 0xff, 0x8f, 0x7f, 0xdf, 0xc0, 0x32, 0x83, 0x65, 0x69, 0xa6, 0xb1, 0xcc, 0xc6, 0xb2, + 0x06, 0xab, 0xfd, 0x53, 0x17, 0x2c, 0x3b, 0xeb, 0xc5, 0x09, 0x57, 0x6c, 0xc4, 0x14, 0xfb, 0xf6, + 0x8f, 0x2c, 0x05, 0xa5, 0xc6, 0x41, 0x69, 0x4a, 0xa9, 0xb6, 0x50, 0x6a, 0x6b, 0x28, 0x6d, 0x3c, + 0xc3, 0xf6, 0xef, 0x21, 0xed, 0xff, 0x04, 0x00, 0x00, 0xff, 0xff, 0xff, 0xf4, 0xee, 0xcb, 0x72, + 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/assets/transactions/renumerate/service.pb.gw.go b/x/assets/transactions/renumerate/service.pb.gw.go deleted file mode 100644 index ff7df7666..000000000 --- a/x/assets/transactions/renumerate/service.pb.gw.go +++ /dev/null @@ -1,171 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: AssetMantle/modules/x/assets/transactions/renumerate/service.proto - -/* -Package renumerate is a reverse proxy. - -It translates gRPC into RESTful JSON APIs. -*/ -package renumerate - -import ( - "context" - "io" - "net/http" - - "github.com/golang/protobuf/descriptor" - "github.com/golang/protobuf/proto" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/grpc-ecosystem/grpc-gateway/utilities" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/status" -) - -// Suppress "imported and not used" errors -var _ codes.Code -var _ io.Reader -var _ status.Status -var _ = runtime.String -var _ = utilities.NewDoubleArray -var _ = descriptor.ForMessage -var _ = metadata.Join - -var ( - filter_Msg_Handle_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - -func request_Msg_Handle_0(ctx context.Context, marshaler runtime.Marshaler, client MsgClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq Message - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.Handle(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Msg_Handle_0(ctx context.Context, marshaler runtime.Marshaler, server MsgServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq Message - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.Handle(ctx, &protoReq) - return msg, metadata, err - -} - -// RegisterMsgHandlerServer registers the http handlers for service Msg to "mux". -// UnaryRPC :call MsgServer directly. -// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterMsgHandlerFromEndpoint instead. -func RegisterMsgHandlerServer(ctx context.Context, mux *runtime.ServeMux, server MsgServer) error { - - mux.Handle("POST", pattern_Msg_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Msg_Handle_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Msg_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -// RegisterMsgHandlerFromEndpoint is same as RegisterMsgHandler but -// automatically dials to "endpoint" and closes the connection when "ctx" gets done. -func RegisterMsgHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.Dial(endpoint, opts...) - if err != nil { - return err - } - defer func() { - if err != nil { - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - return - } - go func() { - <-ctx.Done() - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - }() - }() - - return RegisterMsgHandler(ctx, mux, conn) -} - -// RegisterMsgHandler registers the http handlers for service Msg to "mux". -// The handlers forward requests to the grpc endpoint over "conn". -func RegisterMsgHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { - return RegisterMsgHandlerClient(ctx, mux, NewMsgClient(conn)) -} - -// RegisterMsgHandlerClient registers the http handlers for service Msg -// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "MsgClient". -// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "MsgClient" -// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "MsgClient" to call the correct interceptors. -func RegisterMsgHandlerClient(ctx context.Context, mux *runtime.ServeMux, client MsgClient) error { - - mux.Handle("POST", pattern_Msg_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Msg_Handle_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Msg_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -var ( - pattern_Msg_Handle_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"mantle", "assets", "renumerate"}, "", runtime.AssumeColonVerbOpt(false))) -) - -var ( - forward_Msg_Handle_0 = runtime.ForwardResponseMessage -) diff --git a/x/assets/transactions/renumerate/transaction.go b/x/assets/transactions/renumerate/transaction.go index 565c21da7..2fc4ab482 100644 --- a/x/assets/transactions/renumerate/transaction.go +++ b/x/assets/transactions/renumerate/transaction.go @@ -4,22 +4,14 @@ package renumerate import ( - "context" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "google.golang.org/grpc" - "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/helpers/constants" - "github.com/AssetMantle/modules/utilities/name" + "google.golang.org/grpc" ) -type dummy struct{} - var Transaction = baseHelpers.NewTransaction( - name.GetPackageName(dummy{}), + _Msg_serviceDesc.ServiceName, "", "", @@ -30,9 +22,6 @@ var Transaction = baseHelpers.NewTransaction( func(server grpc.ServiceRegistrar, keeper helpers.TransactionKeeper) { RegisterMsgServer(server, keeper.(transactionKeeper)) }, - func(clientCtx client.Context, mux *runtime.ServeMux) error { - return RegisterMsgHandlerClient(context.Background(), mux, NewMsgClient(clientCtx)) - }, constants.FromIdentityID, constants.AssetID, diff --git a/x/assets/transactions/renumerate/transaction_keeper.go b/x/assets/transactions/renumerate/transaction_keeper.go index e8a94e64f..257fb1723 100644 --- a/x/assets/transactions/renumerate/transaction_keeper.go +++ b/x/assets/transactions/renumerate/transaction_keeper.go @@ -5,9 +5,8 @@ package renumerate import ( "context" - errorConstants "github.com/AssetMantle/modules/helpers/constants" - "github.com/AssetMantle/modules/helpers" + errorConstants "github.com/AssetMantle/modules/helpers/constants" "github.com/AssetMantle/modules/x/assets/constants" "github.com/AssetMantle/modules/x/assets/key" "github.com/AssetMantle/modules/x/assets/mappable" @@ -40,7 +39,7 @@ func (transactionKeeper transactionKeeper) Handle(context context.Context, messa return nil, errorConstants.NotAuthorized.Wrapf("renumerate is not enabled") } - fromAddress := message.GetFromAddress() + fromAddress := message.GetSigners()[0] if _, err := transactionKeeper.authenticateAuxiliary.GetKeeper().Help(context, authenticate.NewAuxiliaryRequest(fromAddress, message.FromID)); err != nil { return nil, err diff --git a/x/assets/transactions/renumerate/transaction_request.go b/x/assets/transactions/renumerate/transaction_request.go index 8bc87d46f..cf63e78b0 100644 --- a/x/assets/transactions/renumerate/transaction_request.go +++ b/x/assets/transactions/renumerate/transaction_request.go @@ -5,23 +5,21 @@ package renumerate import ( "encoding/json" - "github.com/AssetMantle/modules/utilities/rest" - - codecUtilities "github.com/AssetMantle/schema/codec/utilities" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" "github.com/cosmos/cosmos-sdk/client" - sdkCodec "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" + "io" + "net/http" "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/helpers/constants" ) type transactionRequest struct { - BaseReq rest.BaseReq `json:"baseReq"` - FromID string `json:"fromID"` - AssetID string `json:"assetID"` + helpers.CommonTransactionRequest `json:"commonTransactionRequest"` + FromID string `json:"fromID"` + AssetID string `json:"assetID"` } var _ helpers.TransactionRequest = (*transactionRequest)(nil) @@ -47,23 +45,28 @@ func (transactionRequest transactionRequest) Validate() error { } func (transactionRequest transactionRequest) FromCLI(cliCommand helpers.CLICommand, context client.Context) (helpers.TransactionRequest, error) { return newTransactionRequest( - cliCommand.ReadBaseReq(context), + cliCommand.ReadCommonTransactionRequest(context), cliCommand.ReadString(constants.FromIdentityID), cliCommand.ReadString(constants.AssetID), ), nil } -func (transactionRequest transactionRequest) FromJSON(rawMessage json.RawMessage) (helpers.TransactionRequest, error) { - if err := json.Unmarshal(rawMessage, &transactionRequest); err != nil { +func (transactionRequest transactionRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.TransactionRequest, error) { + body, err := io.ReadAll(httpRequest.Body) + if err != nil { + return nil, err + } + + if err := json.Unmarshal(body, &transactionRequest); err != nil { return nil, err } return transactionRequest, nil } -func (transactionRequest transactionRequest) GetBaseReq() rest.BaseReq { - return transactionRequest.BaseReq +func (transactionRequest transactionRequest) GetCommonTransactionRequest() helpers.CommonTransactionRequest { + return transactionRequest.CommonTransactionRequest } func (transactionRequest transactionRequest) MakeMsg() (sdkTypes.Msg, error) { - from, err := sdkTypes.AccAddressFromBech32(transactionRequest.GetBaseReq().From) + from, err := sdkTypes.AccAddressFromBech32(transactionRequest.GetCommonTransactionRequest().GetFrom()) if err != nil { return nil, err } @@ -84,16 +87,13 @@ func (transactionRequest transactionRequest) MakeMsg() (sdkTypes.Msg, error) { assetID.(ids.AssetID), ), nil } -func (transactionRequest) RegisterLegacyAminoCodec(legacyAmino *sdkCodec.LegacyAmino) { - codecUtilities.RegisterModuleConcrete(legacyAmino, transactionRequest{}) -} func requestPrototype() helpers.TransactionRequest { return transactionRequest{} } -func newTransactionRequest(baseReq rest.BaseReq, fromID string, assetID string) helpers.TransactionRequest { +func newTransactionRequest(commonTransactionRequest helpers.CommonTransactionRequest, fromID string, assetID string) helpers.TransactionRequest { return transactionRequest{ - BaseReq: baseReq, - FromID: fromID, - AssetID: assetID, + CommonTransactionRequest: commonTransactionRequest, + FromID: fromID, + AssetID: assetID, } } diff --git a/x/assets/transactions/renumerate/transaction_request_test.go b/x/assets/transactions/renumerate/transaction_request_test.go index 25526b06b..a1e4a8437 100644 --- a/x/assets/transactions/renumerate/transaction_request_test.go +++ b/x/assets/transactions/renumerate/transaction_request_test.go @@ -4,43 +4,40 @@ package renumerate import ( - "encoding/json" "fmt" - "github.com/AssetMantle/modules/utilities/rest" "reflect" "testing" "github.com/cosmos/cosmos-sdk/client" - sdkCodec "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/types" "github.com/spf13/viper" "github.com/AssetMantle/modules/helpers" - "github.com/AssetMantle/modules/helpers/base" + baseHelpers "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/helpers/constants" ) var ( - testBaseRequest = rest.BaseReq{From: fromAddress, ChainID: "test", Fees: types.NewCoins()} + commonTransactionRequest = helpers.PrototypeCommonTransactionRequest() ) func Test_newTransactionRequest(t *testing.T) { type args struct { - baseReq rest.BaseReq - fromID string - assetID string + commonTransactionRequest helpers.CommonTransactionRequest + fromID string + assetID string } tests := []struct { name string args args want helpers.TransactionRequest }{ - {"+ve", args{testBaseRequest, fromID.AsString(), testAssetID.AsString()}, transactionRequest{testBaseRequest, fromID.AsString(), testAssetID.AsString()}}, + {"+ve", args{commonTransactionRequest, fromID.AsString(), testAssetID.AsString()}, transactionRequest{commonTransactionRequest, fromID.AsString(), testAssetID.AsString()}}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - if got := newTransactionRequest(tt.args.baseReq, tt.args.fromID, tt.args.assetID); !reflect.DeepEqual(got, tt.want) { + if got := newTransactionRequest(tt.args.commonTransactionRequest, tt.args.fromID, tt.args.assetID); !reflect.DeepEqual(got, tt.want) { t.Errorf("newTransactionRequest() = %v, want %v", got, tt.want) } }) @@ -64,14 +61,14 @@ func Test_requestPrototype(t *testing.T) { } func Test_transactionRequest_FromCLI(t *testing.T) { - cliCommand := base.NewCLICommand("", "", "", []helpers.CLIFlag{constants.AssetID, constants.FromIdentityID}) + cliCommand := baseHelpers.NewCLICommand("", "", "", []helpers.CLIFlag{constants.AssetID, constants.FromIdentityID}) viper.Set(constants.AssetID.GetName(), testAssetID.AsString()) viper.Set(constants.FromIdentityID.GetName(), fromID.AsString()) type fields struct { - BaseReq rest.BaseReq - FromID string - AssetID string + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + AssetID string } type args struct { cliCommand helpers.CLICommand @@ -84,14 +81,14 @@ func Test_transactionRequest_FromCLI(t *testing.T) { want helpers.TransactionRequest wantErr bool }{ - {"+ve", fields{testBaseRequest, fromID.AsString(), testAssetID.AsString()}, args{cliCommand, client.Context{}.WithCodec(base.CodecPrototype())}, newTransactionRequest(testBaseRequest, fromID.AsString(), testAssetID.AsString()), false}, + {"+ve", fields{commonTransactionRequest, fromID.AsString(), testAssetID.AsString()}, args{cliCommand, client.Context{}.WithCodec(baseHelpers.CodecPrototype())}, newTransactionRequest(commonTransactionRequest, fromID.AsString(), testAssetID.AsString()), false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - AssetID: tt.fields.AssetID, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + AssetID: tt.fields.AssetID, } got, err := transactionRequest.FromCLI(tt.args.cliCommand, tt.args.context) if (err != nil) != tt.wantErr { @@ -105,65 +102,28 @@ func Test_transactionRequest_FromCLI(t *testing.T) { } } -func Test_transactionRequest_FromJSON(t *testing.T) { - type fields struct { - BaseReq rest.BaseReq - FromID string - AssetID string - } - type args struct { - rawMessage json.RawMessage - } - tests := []struct { - name string - fields fields - args args - want helpers.TransactionRequest - wantErr bool - }{ - {"+ve", fields{testBaseRequest, fromID.AsString(), testAssetID.AsString()}, args{types.MustSortJSON(base.CodecPrototype().MustMarshalJSON(&Message{fromAccAddress.String(), fromID, testAssetID}))}, newTransactionRequest(testBaseRequest, fromID.AsString(), testAssetID.AsString()), false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - AssetID: tt.fields.AssetID, - } - got, err := transactionRequest.FromJSON(tt.args.rawMessage) - if (err != nil) != tt.wantErr { - t.Errorf("FromJSON() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("FromJSON() got = %v, want %v", got, tt.want) - } - }) - } -} - func Test_transactionRequest_GetBaseReq(t *testing.T) { type fields struct { - BaseReq rest.BaseReq - FromID string - AssetID string + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + AssetID string } tests := []struct { name string fields fields - want rest.BaseReq + want helpers.CommonTransactionRequest }{ - {"+ve", fields{testBaseRequest, fromID.AsString(), testAssetID.AsString()}, testBaseRequest}, + {"+ve", fields{commonTransactionRequest, fromID.AsString(), testAssetID.AsString()}, commonTransactionRequest}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - AssetID: tt.fields.AssetID, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + AssetID: tt.fields.AssetID, } - if got := transactionRequest.GetBaseReq(); !reflect.DeepEqual(got, tt.want) { - t.Errorf("GetBaseReq() = %v, want %v", got, tt.want) + if got := transactionRequest.GetCommonTransactionRequest(); !reflect.DeepEqual(got, tt.want) { + t.Errorf("GetCommonTransactionRequest() = %v, want %v", got, tt.want) } }) } @@ -171,9 +131,9 @@ func Test_transactionRequest_GetBaseReq(t *testing.T) { func Test_transactionRequest_MakeMsg(t *testing.T) { type fields struct { - BaseReq rest.BaseReq - FromID string - AssetID string + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + AssetID string } tests := []struct { name string @@ -181,14 +141,14 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { want types.Msg wantErr bool }{ - {"+ve", fields{testBaseRequest, fromID.AsString(), testAssetID.AsString()}, NewMessage(fromAccAddress, fromID, testAssetID), false}, + {"+ve", fields{commonTransactionRequest, fromID.AsString(), testAssetID.AsString()}, NewMessage(fromAccAddress, fromID, testAssetID), false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - AssetID: tt.fields.AssetID, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + AssetID: tt.fields.AssetID, } got, err := transactionRequest.MakeMsg() if (err != nil) != tt.wantErr { @@ -202,53 +162,25 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { } } -func Test_transactionRequest_RegisterCodec(t *testing.T) { - type fields struct { - BaseReq rest.BaseReq - FromID string - AssetID string - } - type args struct { - legacyAmino *sdkCodec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{testBaseRequest, fromID.AsString(), testAssetID.AsString()}, args{sdkCodec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - tr := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - AssetID: tt.fields.AssetID, - } - tr.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - func Test_transactionRequest_Validate(t *testing.T) { type fields struct { - BaseReq rest.BaseReq - FromID string - AssetID string + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + AssetID string } tests := []struct { name string fields fields wantErr bool }{ - {"+ve", fields{testBaseRequest, fromID.AsString(), testAssetID.AsString()}, false}, + {"+ve", fields{commonTransactionRequest, fromID.AsString(), testAssetID.AsString()}, false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - AssetID: tt.fields.AssetID, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + AssetID: tt.fields.AssetID, } if err := transactionRequest.Validate(); (err != nil) != tt.wantErr { t.Errorf("ValidateBasic() error = %v, wantErr %v", err, tt.wantErr) diff --git a/x/assets/transactions/renumerate/transaction_response.go b/x/assets/transactions/renumerate/transaction_response.go index 54df55808..b1371aed2 100644 --- a/x/assets/transactions/renumerate/transaction_response.go +++ b/x/assets/transactions/renumerate/transaction_response.go @@ -4,9 +4,8 @@ package renumerate import ( - sdkTypes "github.com/cosmos/cosmos-sdk/types" - "github.com/AssetMantle/modules/helpers" + sdkTypes "github.com/cosmos/cosmos-sdk/types" ) var _ helpers.TransactionResponse = (*TransactionResponse)(nil) diff --git a/x/assets/transactions/revoke/message.go b/x/assets/transactions/revoke/message.go index 96369741b..c69516d95 100644 --- a/x/assets/transactions/revoke/message.go +++ b/x/assets/transactions/revoke/message.go @@ -4,26 +4,15 @@ package revoke import ( - codecUtilities "github.com/AssetMantle/schema/codec/utilities" + "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" - sdkCodec "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/types" sdkTypes "github.com/cosmos/cosmos-sdk/types" - - "github.com/AssetMantle/modules/helpers" ) var _ helpers.Message = (*Message)(nil) -func (message *Message) Type() string { return Transaction.GetName() } -func (message *Message) GetFromAddress() sdkTypes.AccAddress { - from, err := sdkTypes.AccAddressFromBech32(message.From) - if err != nil { - panic(err) - } - return from -} func (message *Message) ValidateBasic() error { if _, err := sdkTypes.AccAddressFromBech32(message.From); err != nil { return err @@ -46,21 +35,10 @@ func (message *Message) GetSigners() []sdkTypes.AccAddress { } return []sdkTypes.AccAddress{from} } -func (*Message) RegisterLegacyAminoCodec(legacyAmino *sdkCodec.LegacyAmino) { - codecUtilities.RegisterModuleConcrete(legacyAmino, Message{}) -} func (message *Message) RegisterInterface(interfaceRegistry types.InterfaceRegistry) { interfaceRegistry.RegisterImplementations((*sdkTypes.Msg)(nil), message) } -func messageFromInterface(msg sdkTypes.Msg) *Message { - switch value := msg.(type) { - case *Message: - return value - default: - return &Message{} - } -} func messagePrototype() helpers.Message { return &Message{} } diff --git a/x/assets/transactions/revoke/message_test.go b/x/assets/transactions/revoke/message_test.go index d415e8ed1..b07da0523 100644 --- a/x/assets/transactions/revoke/message_test.go +++ b/x/assets/transactions/revoke/message_test.go @@ -13,7 +13,6 @@ import ( baseLists "github.com/AssetMantle/schema/lists/base" baseProperties "github.com/AssetMantle/schema/properties/base" baseQualified "github.com/AssetMantle/schema/qualified/base" - sdkCodec "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" "github.com/AssetMantle/modules/helpers" @@ -37,26 +36,6 @@ type fields struct { ClassificationID *baseIDs.ClassificationID } -func Test_messageFromInterface(t *testing.T) { - type args struct { - msg sdkTypes.Msg - } - tests := []struct { - name string - args args - want helpers.Message - }{ - {"+ve", args{NewMessage(fromAccAddress, fromID, fromID, classificationID)}, NewMessage(fromAccAddress, fromID, fromID, classificationID).(*Message)}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := messageFromInterface(tt.args.msg); !reflect.DeepEqual(got, tt.want) { - t.Errorf("messageFromInterface() = %v, want %v", got, tt.want) - } - }) - } -} - func Test_messagePrototype(t *testing.T) { tests := []struct { name string @@ -96,53 +75,6 @@ func Test_message_GetSigners(t *testing.T) { } } -func Test_message_RegisterCodec(t *testing.T) { - type args struct { - legacyAmino *sdkCodec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{fromAccAddress.String(), fromID, fromID, classificationID}, args{sdkCodec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - me := &Message{ - From: tt.fields.From, - FromID: tt.fields.FromID, - ToID: tt.fields.ToID, - ClassificationID: tt.fields.ClassificationID, - } - me.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - -func Test_message_Type(t *testing.T) { - tests := []struct { - name string - fields fields - want string - }{ - {"+ve", fields{fromAccAddress.String(), fromID, fromID, classificationID}, Transaction.GetName()}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - message := &Message{ - From: tt.fields.From, - FromID: tt.fields.FromID, - ToID: tt.fields.ToID, - ClassificationID: tt.fields.ClassificationID, - } - if got := message.Type(); got != tt.want { - t.Errorf("Type() = %v, want %v", got, tt.want) - } - }) - } -} - func Test_message_ValidateBasic(t *testing.T) { tests := []struct { name string diff --git a/x/assets/transactions/revoke/service.pb.go b/x/assets/transactions/revoke/service.pb.go index 022cc9cde..425d9583a 100644 --- a/x/assets/transactions/revoke/service.pb.go +++ b/x/assets/transactions/revoke/service.pb.go @@ -6,9 +6,9 @@ package revoke import ( context "context" fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types/msgservice" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" - _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -31,30 +31,29 @@ func init() { } var fileDescriptor_5cc15353cc44c580 = []byte{ - // 360 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0xd2, 0x3f, 0x4b, 0xc3, 0x40, - 0x18, 0x06, 0xf0, 0x26, 0x85, 0x0e, 0xc1, 0xa9, 0x20, 0x42, 0xd0, 0x0c, 0xfd, 0x00, 0x77, 0xe2, - 0x9f, 0xc1, 0x53, 0x84, 0x16, 0x44, 0x41, 0x02, 0xa5, 0x76, 0x08, 0x12, 0x90, 0x6b, 0x7a, 0xc4, - 0x60, 0x72, 0x57, 0xf2, 0x5e, 0x4b, 0x57, 0xfd, 0x04, 0x82, 0xdf, 0xc0, 0x4d, 0x37, 0xbf, 0x85, - 0x38, 0x15, 0x5c, 0x1c, 0x25, 0x75, 0xf2, 0x53, 0x48, 0x73, 0x07, 0x5e, 0xc7, 0x5b, 0xdf, 0xf0, - 0x7b, 0x78, 0xde, 0xcb, 0xeb, 0x9d, 0x76, 0x01, 0x98, 0x0c, 0x29, 0x97, 0x39, 0xc3, 0x85, 0x18, - 0x4f, 0x73, 0x06, 0x78, 0x8e, 0xe9, 0x6a, 0x0a, 0x58, 0x96, 0x94, 0x03, 0x4d, 0x64, 0x26, 0x38, - 0xe0, 0x92, 0xcd, 0xc4, 0x1d, 0xc3, 0xc0, 0xca, 0x59, 0x96, 0x30, 0x34, 0x29, 0x85, 0x14, 0xed, - 0x5d, 0xc3, 0x23, 0xed, 0xd1, 0x1c, 0x29, 0x8f, 0x4c, 0x8f, 0x94, 0xf7, 0xb7, 0x53, 0x21, 0xd2, - 0x9c, 0x61, 0x3a, 0xc9, 0x30, 0xe5, 0x5c, 0x48, 0xaa, 0x3e, 0xd7, 0x79, 0xbe, 0x7d, 0x9f, 0x82, - 0x01, 0xd0, 0x54, 0xf7, 0xf1, 0x2f, 0xad, 0xbd, 0x31, 0xbb, 0x29, 0x19, 0x4c, 0x04, 0x07, 0x1d, - 0xb6, 0xf7, 0xe6, 0x78, 0xcd, 0x10, 0xd2, 0xf6, 0x8b, 0xe3, 0xb5, 0x2e, 0x28, 0x1f, 0xe7, 0xac, - 0x7d, 0x84, 0x6c, 0x17, 0x46, 0xa1, 0x2a, 0xe8, 0x9f, 0xd9, 0xd3, 0xe1, 0xff, 0x6c, 0xa0, 0xab, - 0x75, 0x76, 0x1e, 0x3e, 0x7f, 0x9e, 0xdc, 0xad, 0xce, 0x26, 0x2e, 0xd4, 0x96, 0x7a, 0x37, 0x45, - 0x7a, 0xf7, 0xcd, 0xf7, 0x2a, 0x70, 0x16, 0x55, 0xe0, 0x7c, 0x57, 0x81, 0xf3, 0xb8, 0x0c, 0x1a, - 0x8b, 0x65, 0xd0, 0xf8, 0x5a, 0x06, 0x0d, 0xef, 0x20, 0x11, 0x85, 0x75, 0x87, 0xde, 0xc6, 0x95, - 0xfa, 0xe1, 0xfd, 0xd5, 0x93, 0xf4, 0x9d, 0xeb, 0xe3, 0x34, 0x93, 0xb7, 0xd3, 0x11, 0x4a, 0x44, - 0x81, 0x6d, 0x1f, 0xfb, 0xd9, 0x6d, 0x75, 0xc3, 0xa8, 0x3b, 0x1c, 0xbc, 0xba, 0x6b, 0x87, 0x13, - 0xea, 0x22, 0x91, 0xaa, 0x07, 0xe6, 0xe2, 0x80, 0x06, 0xb5, 0xfd, 0x58, 0x23, 0xb1, 0x26, 0x71, - 0x14, 0x2b, 0x12, 0x9b, 0x24, 0x56, 0xa4, 0x72, 0x4f, 0x6c, 0x49, 0x7c, 0xde, 0xef, 0x85, 0x4c, - 0xd2, 0x31, 0x95, 0xf4, 0xd7, 0x3d, 0x34, 0x38, 0x21, 0xda, 0x13, 0x12, 0x11, 0xa2, 0x12, 0x08, - 0x31, 0x23, 0x08, 0x51, 0x19, 0xa3, 0x56, 0x7d, 0x3e, 0xfb, 0x7f, 0x01, 0x00, 0x00, 0xff, 0xff, - 0x1a, 0x70, 0x8e, 0x02, 0x5d, 0x03, 0x00, 0x00, + // 348 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0xd2, 0xbf, 0x4b, 0xc3, 0x40, + 0x14, 0x07, 0xf0, 0x5c, 0x8a, 0x1d, 0x82, 0x53, 0x17, 0x21, 0x43, 0x06, 0x47, 0x87, 0x3b, 0x7f, + 0x0e, 0x9e, 0x22, 0xb4, 0x20, 0x0a, 0x12, 0x28, 0xb5, 0x43, 0x90, 0x80, 0x5c, 0xd3, 0x23, 0x16, + 0x7b, 0xb9, 0x92, 0x77, 0x2d, 0x1d, 0x75, 0x77, 0x70, 0x77, 0x73, 0x74, 0xf2, 0xcf, 0x10, 0xa7, + 0x8e, 0x8e, 0x92, 0x0e, 0x82, 0x7f, 0x85, 0xa4, 0x77, 0xe0, 0x75, 0xbc, 0x29, 0xf0, 0xe0, 0xf3, + 0xcd, 0xf7, 0x25, 0x2f, 0x38, 0x6b, 0x03, 0x70, 0x15, 0xb3, 0x42, 0x8d, 0x39, 0x11, 0x72, 0x38, + 0x1d, 0x73, 0x20, 0x73, 0xc2, 0xea, 0x29, 0x10, 0x55, 0xb2, 0x02, 0x58, 0xa6, 0x46, 0xb2, 0x00, + 0x52, 0xf2, 0x99, 0xbc, 0xe7, 0x04, 0x78, 0x39, 0x1b, 0x65, 0x1c, 0x4f, 0x4a, 0xa9, 0x64, 0x6b, + 0xd7, 0xf2, 0xd8, 0x78, 0x3c, 0xc7, 0xda, 0x63, 0xdb, 0x63, 0xed, 0xc3, 0xad, 0x4c, 0x82, 0x90, + 0x40, 0x04, 0xe4, 0x64, 0xb6, 0x57, 0x3f, 0x74, 0x54, 0xe8, 0x5e, 0x45, 0x70, 0x00, 0x96, 0x9b, + 0x2a, 0xe1, 0x95, 0xb3, 0xb7, 0x66, 0xb7, 0x25, 0x87, 0x89, 0x2c, 0xc0, 0x84, 0xed, 0xbf, 0xa0, + 0xa0, 0x11, 0x43, 0xde, 0x7a, 0x42, 0x41, 0xf3, 0x92, 0x15, 0xc3, 0x31, 0x6f, 0x1d, 0x63, 0xd7, + 0x5d, 0x71, 0xac, 0x0b, 0x86, 0xe7, 0xee, 0xb4, 0xff, 0x3f, 0xeb, 0x99, 0x6a, 0xdb, 0x5e, 0xb8, + 0xf1, 0xf0, 0xf3, 0xbe, 0x83, 0x3a, 0x8f, 0x8d, 0x8f, 0x2a, 0x42, 0x8b, 0x2a, 0x42, 0xdf, 0x55, + 0x84, 0x9e, 0x97, 0x91, 0xb7, 0x58, 0x46, 0xde, 0xd7, 0x32, 0xf2, 0x82, 0xc3, 0x4c, 0x0a, 0xe7, + 0xb7, 0x75, 0x36, 0xaf, 0xf5, 0x5f, 0xed, 0xd6, 0xcb, 0x77, 0xd1, 0xcd, 0x49, 0x3e, 0x52, 0x77, + 0xd3, 0x01, 0xce, 0xa4, 0x20, 0xae, 0x9f, 0xf5, 0xd5, 0x6f, 0xb6, 0xe3, 0xa4, 0xdd, 0xef, 0xbd, + 0xf9, 0x6b, 0xd7, 0x11, 0x9b, 0x22, 0x89, 0xae, 0x07, 0xf6, 0x8a, 0x80, 0x7b, 0x2b, 0xfb, 0xb9, + 0x46, 0x52, 0x43, 0xd2, 0x24, 0xd5, 0x24, 0xb5, 0x49, 0xaa, 0x49, 0xe5, 0x9f, 0xba, 0x92, 0xf4, + 0xa2, 0xdb, 0x89, 0xb9, 0x62, 0x43, 0xa6, 0xd8, 0xaf, 0x7f, 0x64, 0x71, 0x4a, 0x8d, 0xa7, 0x34, + 0xa1, 0x54, 0x27, 0x50, 0x6a, 0x47, 0x50, 0xaa, 0x33, 0x06, 0xcd, 0xd5, 0xa1, 0x1c, 0xfc, 0x05, + 0x00, 0x00, 0xff, 0xff, 0x4b, 0x04, 0x61, 0x12, 0x42, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/assets/transactions/revoke/service.pb.gw.go b/x/assets/transactions/revoke/service.pb.gw.go deleted file mode 100644 index f0e01b32a..000000000 --- a/x/assets/transactions/revoke/service.pb.gw.go +++ /dev/null @@ -1,171 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: AssetMantle/modules/x/assets/transactions/revoke/service.proto - -/* -Package revoke is a reverse proxy. - -It translates gRPC into RESTful JSON APIs. -*/ -package revoke - -import ( - "context" - "io" - "net/http" - - "github.com/golang/protobuf/descriptor" - "github.com/golang/protobuf/proto" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/grpc-ecosystem/grpc-gateway/utilities" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/status" -) - -// Suppress "imported and not used" errors -var _ codes.Code -var _ io.Reader -var _ status.Status -var _ = runtime.String -var _ = utilities.NewDoubleArray -var _ = descriptor.ForMessage -var _ = metadata.Join - -var ( - filter_Msg_Handle_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - -func request_Msg_Handle_0(ctx context.Context, marshaler runtime.Marshaler, client MsgClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq Message - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.Handle(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Msg_Handle_0(ctx context.Context, marshaler runtime.Marshaler, server MsgServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq Message - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.Handle(ctx, &protoReq) - return msg, metadata, err - -} - -// RegisterMsgHandlerServer registers the http handlers for service Msg to "mux". -// UnaryRPC :call MsgServer directly. -// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterMsgHandlerFromEndpoint instead. -func RegisterMsgHandlerServer(ctx context.Context, mux *runtime.ServeMux, server MsgServer) error { - - mux.Handle("POST", pattern_Msg_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Msg_Handle_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Msg_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -// RegisterMsgHandlerFromEndpoint is same as RegisterMsgHandler but -// automatically dials to "endpoint" and closes the connection when "ctx" gets done. -func RegisterMsgHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.Dial(endpoint, opts...) - if err != nil { - return err - } - defer func() { - if err != nil { - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - return - } - go func() { - <-ctx.Done() - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - }() - }() - - return RegisterMsgHandler(ctx, mux, conn) -} - -// RegisterMsgHandler registers the http handlers for service Msg to "mux". -// The handlers forward requests to the grpc endpoint over "conn". -func RegisterMsgHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { - return RegisterMsgHandlerClient(ctx, mux, NewMsgClient(conn)) -} - -// RegisterMsgHandlerClient registers the http handlers for service Msg -// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "MsgClient". -// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "MsgClient" -// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "MsgClient" to call the correct interceptors. -func RegisterMsgHandlerClient(ctx context.Context, mux *runtime.ServeMux, client MsgClient) error { - - mux.Handle("POST", pattern_Msg_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Msg_Handle_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Msg_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -var ( - pattern_Msg_Handle_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"mantle", "assets", "revoke"}, "", runtime.AssumeColonVerbOpt(false))) -) - -var ( - forward_Msg_Handle_0 = runtime.ForwardResponseMessage -) diff --git a/x/assets/transactions/revoke/transaction.go b/x/assets/transactions/revoke/transaction.go index c32599e72..0e9712af4 100644 --- a/x/assets/transactions/revoke/transaction.go +++ b/x/assets/transactions/revoke/transaction.go @@ -4,22 +4,14 @@ package revoke import ( - "context" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "google.golang.org/grpc" - "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/helpers/constants" - "github.com/AssetMantle/modules/utilities/name" + "google.golang.org/grpc" ) -type dummy struct{} - var Transaction = baseHelpers.NewTransaction( - name.GetPackageName(dummy{}), + _Msg_serviceDesc.ServiceName, "", "", @@ -30,9 +22,6 @@ var Transaction = baseHelpers.NewTransaction( func(server grpc.ServiceRegistrar, keeper helpers.TransactionKeeper) { RegisterMsgServer(server, keeper.(transactionKeeper)) }, - func(clientCtx client.Context, mux *runtime.ServeMux) error { - return RegisterMsgHandlerClient(context.Background(), mux, NewMsgClient(clientCtx)) - }, constants.FromIdentityID, constants.ToIdentityID, diff --git a/x/assets/transactions/revoke/transaction_keeper.go b/x/assets/transactions/revoke/transaction_keeper.go index 318da9a39..51a45d65f 100644 --- a/x/assets/transactions/revoke/transaction_keeper.go +++ b/x/assets/transactions/revoke/transaction_keeper.go @@ -5,7 +5,6 @@ package revoke import ( "context" - "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/x/identities/auxiliaries/authenticate" "github.com/AssetMantle/modules/x/maintainers/auxiliaries/revoke" @@ -25,7 +24,7 @@ func (transactionKeeper transactionKeeper) Transact(context context.Context, mes } func (transactionKeeper transactionKeeper) Handle(context context.Context, message *Message) (*TransactionResponse, error) { - fromAddress := message.GetFromAddress() + fromAddress := message.GetSigners()[0] if _, err := transactionKeeper.authenticateAuxiliary.GetKeeper().Help(context, authenticate.NewAuxiliaryRequest(fromAddress, message.FromID)); err != nil { return nil, err diff --git a/x/assets/transactions/revoke/transaction_request.go b/x/assets/transactions/revoke/transaction_request.go index b172c7ec4..ae86e635d 100644 --- a/x/assets/transactions/revoke/transaction_request.go +++ b/x/assets/transactions/revoke/transaction_request.go @@ -5,24 +5,22 @@ package revoke import ( "encoding/json" - "github.com/AssetMantle/modules/utilities/rest" - - codecUtilities "github.com/AssetMantle/schema/codec/utilities" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" "github.com/cosmos/cosmos-sdk/client" - sdkCodec "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" + "io" + "net/http" "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/helpers/constants" ) type transactionRequest struct { - BaseReq rest.BaseReq `json:"baseReq"` - FromID string `json:"fromID"` - ToID string `json:"toID"` - ClassificationID string `json:"classificationID"` + helpers.CommonTransactionRequest `json:"commonTransactionRequest"` + FromID string `json:"fromID"` + ToID string `json:"toID"` + ClassificationID string `json:"classificationID"` } var _ helpers.TransactionRequest = (*transactionRequest)(nil) @@ -48,24 +46,29 @@ func (transactionRequest transactionRequest) Validate() error { } func (transactionRequest transactionRequest) FromCLI(cliCommand helpers.CLICommand, context client.Context) (helpers.TransactionRequest, error) { return newTransactionRequest( - cliCommand.ReadBaseReq(context), + cliCommand.ReadCommonTransactionRequest(context), cliCommand.ReadString(constants.FromIdentityID), cliCommand.ReadString(constants.ToIdentityID), cliCommand.ReadString(constants.ClassificationID), ), nil } -func (transactionRequest transactionRequest) FromJSON(rawMessage json.RawMessage) (helpers.TransactionRequest, error) { - if err := json.Unmarshal(rawMessage, &transactionRequest); err != nil { +func (transactionRequest transactionRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.TransactionRequest, error) { + body, err := io.ReadAll(httpRequest.Body) + if err != nil { + return nil, err + } + + if err := json.Unmarshal(body, &transactionRequest); err != nil { return nil, err } return transactionRequest, nil } -func (transactionRequest transactionRequest) GetBaseReq() rest.BaseReq { - return transactionRequest.BaseReq +func (transactionRequest transactionRequest) GetCommonTransactionRequest() helpers.CommonTransactionRequest { + return transactionRequest.CommonTransactionRequest } func (transactionRequest transactionRequest) MakeMsg() (sdkTypes.Msg, error) { - from, err := sdkTypes.AccAddressFromBech32(transactionRequest.GetBaseReq().From) + from, err := sdkTypes.AccAddressFromBech32(transactionRequest.GetCommonTransactionRequest().GetFrom()) if err != nil { return nil, err } @@ -92,18 +95,15 @@ func (transactionRequest transactionRequest) MakeMsg() (sdkTypes.Msg, error) { classificationID.(ids.ClassificationID), ), nil } -func (transactionRequest) RegisterLegacyAminoCodec(legacyAmino *sdkCodec.LegacyAmino) { - codecUtilities.RegisterModuleConcrete(legacyAmino, transactionRequest{}) -} func requestPrototype() helpers.TransactionRequest { return transactionRequest{} } -func newTransactionRequest(baseReq rest.BaseReq, fromID string, toID string, classificationID string) helpers.TransactionRequest { +func newTransactionRequest(commonTransactionRequest helpers.CommonTransactionRequest, fromID string, toID string, classificationID string) helpers.TransactionRequest { return transactionRequest{ - BaseReq: baseReq, - FromID: fromID, - ToID: toID, - ClassificationID: classificationID, + CommonTransactionRequest: commonTransactionRequest, + FromID: fromID, + ToID: toID, + ClassificationID: classificationID, } } diff --git a/x/assets/transactions/revoke/transaction_request_test.go b/x/assets/transactions/revoke/transaction_request_test.go index 3f57db540..a55c8ef8e 100644 --- a/x/assets/transactions/revoke/transaction_request_test.go +++ b/x/assets/transactions/revoke/transaction_request_test.go @@ -4,44 +4,41 @@ package revoke import ( - "encoding/json" "fmt" - "github.com/AssetMantle/modules/utilities/rest" "reflect" "testing" "github.com/cosmos/cosmos-sdk/client" - sdkCodec "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" "github.com/spf13/viper" "github.com/AssetMantle/modules/helpers" - "github.com/AssetMantle/modules/helpers/base" + baseHelpers "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/helpers/constants" ) var ( - testBaseRequest = rest.BaseReq{From: fromAddress, ChainID: "test", Fees: sdkTypes.NewCoins()} + commonTransactionRequest = helpers.PrototypeCommonTransactionRequest() ) func Test_newTransactionRequest(t *testing.T) { type args struct { - baseReq rest.BaseReq - fromID string - toID string - classificationID string + commonTransactionRequest helpers.CommonTransactionRequest + fromID string + toID string + classificationID string } tests := []struct { name string args args want helpers.TransactionRequest }{ - {"+ve", args{testBaseRequest, fromID.AsString(), fromID.AsString(), classificationID.AsString()}, transactionRequest{testBaseRequest, fromID.AsString(), fromID.AsString(), classificationID.AsString()}}, + {"+ve", args{commonTransactionRequest, fromID.AsString(), fromID.AsString(), classificationID.AsString()}, transactionRequest{commonTransactionRequest, fromID.AsString(), fromID.AsString(), classificationID.AsString()}}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - if got := newTransactionRequest(tt.args.baseReq, tt.args.fromID, tt.args.toID, tt.args.classificationID); !reflect.DeepEqual(got, tt.want) { + if got := newTransactionRequest(tt.args.commonTransactionRequest, tt.args.fromID, tt.args.toID, tt.args.classificationID); !reflect.DeepEqual(got, tt.want) { t.Errorf("newTransactionRequest() = %v, want %v", got, tt.want) } }) @@ -65,16 +62,16 @@ func Test_requestPrototype(t *testing.T) { } func Test_transactionRequest_FromCLI(t *testing.T) { - cliCommand := base.NewCLICommand("", "", "", []helpers.CLIFlag{constants.FromIdentityID, constants.ToIdentityID, constants.ClassificationID}) + cliCommand := baseHelpers.NewCLICommand("", "", "", []helpers.CLIFlag{constants.FromIdentityID, constants.ToIdentityID, constants.ClassificationID}) viper.Set(constants.FromIdentityID.GetName(), fromID.AsString()) viper.Set(constants.ToIdentityID.GetName(), fromID.AsString()) viper.Set(constants.ClassificationID.GetName(), classificationID.AsString()) type fields struct { - BaseReq rest.BaseReq - FromID string - ToID string - ClassificationID string + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + ToID string + ClassificationID string } type args struct { cliCommand helpers.CLICommand @@ -87,15 +84,15 @@ func Test_transactionRequest_FromCLI(t *testing.T) { want helpers.TransactionRequest wantErr bool }{ - {"+ve", fields{testBaseRequest, fromID.AsString(), fromID.AsString(), classificationID.AsString()}, args{cliCommand, client.Context{}.WithCodec(base.CodecPrototype())}, newTransactionRequest(testBaseRequest, fromID.AsString(), fromID.AsString(), classificationID.AsString()), false}, + {"+ve", fields{commonTransactionRequest, fromID.AsString(), fromID.AsString(), classificationID.AsString()}, args{cliCommand, client.Context{}.WithCodec(baseHelpers.CodecPrototype())}, newTransactionRequest(commonTransactionRequest, fromID.AsString(), fromID.AsString(), classificationID.AsString()), false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - ToID: tt.fields.ToID, - ClassificationID: tt.fields.ClassificationID, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + ToID: tt.fields.ToID, + ClassificationID: tt.fields.ClassificationID, } got, err := transactionRequest.FromCLI(tt.args.cliCommand, tt.args.context) if (err != nil) != tt.wantErr { @@ -109,69 +106,30 @@ func Test_transactionRequest_FromCLI(t *testing.T) { } } -func Test_transactionRequest_FromJSON(t *testing.T) { - type fields struct { - BaseReq rest.BaseReq - FromID string - ToID string - ClassificationID string - } - type args struct { - rawMessage json.RawMessage - } - tests := []struct { - name string - fields fields - args args - want helpers.TransactionRequest - wantErr bool - }{ - {"+ve", fields{testBaseRequest, fromID.AsString(), fromID.AsString(), classificationID.AsString()}, args{sdkTypes.MustSortJSON(base.CodecPrototype().MustMarshalJSON(&Message{fromAccAddress.String(), fromID, fromID, classificationID}))}, newTransactionRequest(testBaseRequest, fromID.AsString(), fromID.AsString(), classificationID.AsString()), false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - ToID: tt.fields.ToID, - ClassificationID: tt.fields.ClassificationID, - } - got, err := transactionRequest.FromJSON(tt.args.rawMessage) - if (err != nil) != tt.wantErr { - t.Errorf("FromJSON() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("FromJSON() got = %v, want %v", got, tt.want) - } - }) - } -} - func Test_transactionRequest_GetBaseReq(t *testing.T) { type fields struct { - BaseReq rest.BaseReq - FromID string - ToID string - ClassificationID string + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + ToID string + ClassificationID string } tests := []struct { name string fields fields - want rest.BaseReq + want helpers.CommonTransactionRequest }{ - {"+ve", fields{testBaseRequest, fromID.AsString(), fromID.AsString(), classificationID.AsString()}, testBaseRequest}, + {"+ve", fields{commonTransactionRequest, fromID.AsString(), fromID.AsString(), classificationID.AsString()}, commonTransactionRequest}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - ToID: tt.fields.ToID, - ClassificationID: tt.fields.ClassificationID, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + ToID: tt.fields.ToID, + ClassificationID: tt.fields.ClassificationID, } - if got := transactionRequest.GetBaseReq(); !reflect.DeepEqual(got, tt.want) { - t.Errorf("GetBaseReq() = %v, want %v", got, tt.want) + if got := transactionRequest.GetCommonTransactionRequest(); !reflect.DeepEqual(got, tt.want) { + t.Errorf("GetCommonTransactionRequest() = %v, want %v", got, tt.want) } }) } @@ -179,10 +137,10 @@ func Test_transactionRequest_GetBaseReq(t *testing.T) { func Test_transactionRequest_MakeMsg(t *testing.T) { type fields struct { - BaseReq rest.BaseReq - FromID string - ToID string - ClassificationID string + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + ToID string + ClassificationID string } tests := []struct { name string @@ -190,15 +148,15 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { want sdkTypes.Msg wantErr bool }{ - {"+ve", fields{testBaseRequest, fromID.AsString(), fromID.AsString(), classificationID.AsString()}, NewMessage(fromAccAddress, fromID, fromID, classificationID), false}, + {"+ve", fields{commonTransactionRequest, fromID.AsString(), fromID.AsString(), classificationID.AsString()}, NewMessage(fromAccAddress, fromID, fromID, classificationID), false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - ToID: tt.fields.ToID, - ClassificationID: tt.fields.ClassificationID, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + ToID: tt.fields.ToID, + ClassificationID: tt.fields.ClassificationID, } got, err := transactionRequest.MakeMsg() if (err != nil) != tt.wantErr { @@ -212,57 +170,27 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { } } -func Test_transactionRequest_RegisterCodec(t *testing.T) { - type fields struct { - BaseReq rest.BaseReq - FromID string - ToID string - ClassificationID string - } - type args struct { - legacyAmino *sdkCodec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{testBaseRequest, fromID.AsString(), fromID.AsString(), classificationID.AsString()}, args{sdkCodec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - tr := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - ToID: tt.fields.ToID, - ClassificationID: tt.fields.ClassificationID, - } - tr.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - func Test_transactionRequest_Validate(t *testing.T) { type fields struct { - BaseReq rest.BaseReq - FromID string - ToID string - ClassificationID string + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + ToID string + ClassificationID string } tests := []struct { name string fields fields wantErr bool }{ - {"+ve", fields{testBaseRequest, fromID.AsString(), fromID.AsString(), classificationID.AsString()}, false}, + {"+ve", fields{commonTransactionRequest, fromID.AsString(), fromID.AsString(), classificationID.AsString()}, false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - ToID: tt.fields.ToID, - ClassificationID: tt.fields.ClassificationID, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + ToID: tt.fields.ToID, + ClassificationID: tt.fields.ClassificationID, } if err := transactionRequest.Validate(); (err != nil) != tt.wantErr { t.Errorf("ValidateBasic() error = %v, wantErr %v", err, tt.wantErr) diff --git a/x/assets/transactions/revoke/transaction_response.go b/x/assets/transactions/revoke/transaction_response.go index 53eebfc72..272941180 100644 --- a/x/assets/transactions/revoke/transaction_response.go +++ b/x/assets/transactions/revoke/transaction_response.go @@ -4,9 +4,8 @@ package revoke import ( - sdkTypes "github.com/cosmos/cosmos-sdk/types" - "github.com/AssetMantle/modules/helpers" + sdkTypes "github.com/cosmos/cosmos-sdk/types" ) var _ helpers.TransactionResponse = (*TransactionResponse)(nil) diff --git a/x/assets/transactions/send/message.go b/x/assets/transactions/send/message.go index 7347beb20..2e486dbde 100644 --- a/x/assets/transactions/send/message.go +++ b/x/assets/transactions/send/message.go @@ -4,15 +4,12 @@ package send import ( + "github.com/AssetMantle/modules/helpers" errorConstants "github.com/AssetMantle/modules/helpers/constants" - codecUtilities "github.com/AssetMantle/schema/codec/utilities" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" - sdkCodec "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/types" sdkTypes "github.com/cosmos/cosmos-sdk/types" - - "github.com/AssetMantle/modules/helpers" ) var _ helpers.Message = (*Message)(nil) @@ -27,14 +24,7 @@ func (message *Message) GetValueAsInt() (sdkTypes.Int, error) { return value, nil } -func (message *Message) Type() string { return Transaction.GetName() } -func (message *Message) GetFromAddress() sdkTypes.AccAddress { - from, err := sdkTypes.AccAddressFromBech32(message.From) - if err != nil { - panic(err) - } - return from -} + func (message *Message) ValidateBasic() error { if _, err := sdkTypes.AccAddressFromBech32(message.From); err != nil { return errorConstants.InvalidMessage.Wrapf("invalid from address %s", err.Error()) @@ -60,21 +50,10 @@ func (message *Message) GetSigners() []sdkTypes.AccAddress { } return []sdkTypes.AccAddress{from} } -func (*Message) RegisterLegacyAminoCodec(legacyAmino *sdkCodec.LegacyAmino) { - codecUtilities.RegisterModuleConcrete(legacyAmino, Message{}) -} func (message *Message) RegisterInterface(interfaceRegistry types.InterfaceRegistry) { interfaceRegistry.RegisterImplementations((*sdkTypes.Msg)(nil), message) } -func messageFromInterface(msg sdkTypes.Msg) *Message { - switch value := msg.(type) { - case *Message: - return value - default: - return &Message{} - } -} func messagePrototype() helpers.Message { return &Message{} } diff --git a/x/assets/transactions/send/message_test.go b/x/assets/transactions/send/message_test.go index f65db4d0e..a9287168f 100644 --- a/x/assets/transactions/send/message_test.go +++ b/x/assets/transactions/send/message_test.go @@ -12,7 +12,6 @@ import ( "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" - sdkCodec "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/types" "github.com/AssetMantle/modules/helpers" @@ -119,26 +118,6 @@ func TestMessage_ValidateBasic(t *testing.T) { } } -func Test_messageFromInterface(t *testing.T) { - type args struct { - msg types.Msg - } - tests := []struct { - name string - args args - want *Message - }{ - {"+ve", args{NewMessage(fromAccAddress, fromID, fromID, assetID, testRate)}, &Message{fromAccAddress.String(), fromID, fromID, assetID, testRate.String()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := messageFromInterface(tt.args.msg); !reflect.DeepEqual(got, tt.want) { - t.Errorf("messageFromInterface() = %v, want %v", got, tt.want) - } - }) - } -} - func Test_messagePrototype(t *testing.T) { tests := []struct { name string @@ -186,69 +165,6 @@ func Test_message_GetSigners(t *testing.T) { } } -func Test_message_RegisterCodec(t *testing.T) { - type fields struct { - From string - FromID *baseIDs.IdentityID - ToID *baseIDs.IdentityID - AssetID *baseIDs.AssetID - Value types.Int - } - type args struct { - legacyAmino *sdkCodec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{fromAccAddress.String(), fromID, fromID, assetID, testRate}, args{codec.GetLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - me := &Message{ - From: tt.fields.From, - FromID: tt.fields.FromID, - ToID: tt.fields.ToID, - AssetID: tt.fields.AssetID, - Value: tt.fields.Value.String(), - } - me.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - -func Test_message_Type(t *testing.T) { - type fields struct { - From string - FromID *baseIDs.IdentityID - ToID *baseIDs.IdentityID - AssetID *baseIDs.AssetID - Value types.Int - } - tests := []struct { - name string - fields fields - want string - }{ - {"+ve", fields{fromAccAddress.String(), fromID, fromID, assetID, testRate}, Transaction.GetName()}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - message := &Message{ - From: tt.fields.From, - FromID: tt.fields.FromID, - ToID: tt.fields.ToID, - AssetID: tt.fields.AssetID, - Value: tt.fields.Value.String(), - } - if got := message.Type(); got != tt.want { - t.Errorf("Type() = %v, want %v", got, tt.want) - } - }) - } -} - func Test_NewMessage(t *testing.T) { type args struct { from types.AccAddress diff --git a/x/assets/transactions/send/service.pb.go b/x/assets/transactions/send/service.pb.go index fadd5aae8..abab54e15 100644 --- a/x/assets/transactions/send/service.pb.go +++ b/x/assets/transactions/send/service.pb.go @@ -6,9 +6,9 @@ package send import ( context "context" fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types/msgservice" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" - _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -31,30 +31,29 @@ func init() { } var fileDescriptor_95a46fce5d59d239 = []byte{ - // 355 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0xd2, 0x31, 0x4b, 0xf3, 0x40, - 0x18, 0x07, 0xf0, 0x26, 0x2f, 0x74, 0x08, 0xef, 0x54, 0x71, 0x89, 0x92, 0xa1, 0x1f, 0xe0, 0x0e, - 0xda, 0x41, 0x3c, 0x5c, 0x5a, 0x07, 0x75, 0x08, 0x14, 0xdb, 0x21, 0x48, 0x40, 0xae, 0xc9, 0x11, - 0x03, 0xc9, 0x5d, 0xc9, 0x73, 0x95, 0xce, 0x7e, 0x02, 0xc1, 0x6f, 0xa0, 0x9b, 0x7e, 0x11, 0x71, - 0x2a, 0xb8, 0x38, 0x4a, 0xea, 0xe4, 0xee, 0x2e, 0xd7, 0x3b, 0xf0, 0x3a, 0xde, 0xfa, 0x84, 0xdf, - 0x3f, 0xff, 0xe7, 0x49, 0x82, 0x93, 0x11, 0x00, 0x93, 0x31, 0xe5, 0xb2, 0x62, 0xb8, 0x16, 0xf9, - 0xb2, 0x62, 0x80, 0x57, 0x98, 0xaa, 0x29, 0x60, 0xd9, 0x50, 0x0e, 0x34, 0x93, 0xa5, 0xe0, 0x80, - 0x81, 0xf1, 0x1c, 0x03, 0x6b, 0x6e, 0xcb, 0x8c, 0xa1, 0x45, 0x23, 0xa4, 0xe8, 0x21, 0x4b, 0x23, - 0xa3, 0xd1, 0x0a, 0x69, 0x8d, 0x6c, 0x8d, 0x94, 0x0e, 0x0f, 0x0b, 0x21, 0x8a, 0x8a, 0x61, 0xba, - 0x28, 0x31, 0xe5, 0x5c, 0x48, 0xaa, 0x1f, 0x6e, 0xd3, 0x42, 0xd7, 0x2e, 0x35, 0x03, 0xa0, 0x85, - 0xe9, 0x12, 0x5e, 0x38, 0x6a, 0x6b, 0x72, 0xdd, 0x30, 0x58, 0x08, 0x0e, 0x26, 0x6a, 0xf0, 0xe2, - 0x05, 0xff, 0x62, 0x28, 0x7a, 0x4f, 0x5e, 0xd0, 0x3d, 0xa7, 0x3c, 0xaf, 0x58, 0xef, 0xc8, 0x71, - 0x55, 0x14, 0xeb, 0x72, 0xe1, 0xa9, 0x2b, 0x9c, 0xfd, 0x4d, 0x2e, 0x4d, 0xad, 0xfe, 0xc1, 0xdd, - 0xfb, 0xd7, 0x83, 0xbf, 0xdf, 0xdf, 0xc3, 0xb5, 0xde, 0xcf, 0x6c, 0xa5, 0xc0, 0xf8, 0xc7, 0x7f, - 0x6d, 0x23, 0x6f, 0xdd, 0x46, 0xde, 0x67, 0x1b, 0x79, 0xf7, 0x9b, 0xa8, 0xb3, 0xde, 0x44, 0x9d, - 0x8f, 0x4d, 0xd4, 0x09, 0x06, 0x99, 0xa8, 0x1d, 0xdf, 0x3f, 0xfe, 0x3f, 0xd5, 0x9f, 0x78, 0xa2, - 0x4e, 0x31, 0xf1, 0xae, 0x8e, 0x8b, 0x52, 0xde, 0x2c, 0xe7, 0x28, 0x13, 0x35, 0x76, 0x3b, 0xf1, - 0xa3, 0xdf, 0x1d, 0xc5, 0xc9, 0x68, 0x36, 0x7d, 0xf6, 0x77, 0x4a, 0xc4, 0xa6, 0x44, 0xa2, 0xa7, - 0x60, 0xaf, 0x0c, 0x68, 0xca, 0x78, 0xfe, 0xb6, 0x03, 0x52, 0x03, 0xd2, 0x24, 0xd5, 0x20, 0xb5, - 0x41, 0xaa, 0x40, 0xeb, 0x13, 0x37, 0x90, 0x9e, 0x4d, 0xc6, 0x31, 0x93, 0x34, 0xa7, 0x92, 0x7e, - 0xfb, 0x43, 0x0b, 0x13, 0x62, 0x34, 0x21, 0x09, 0xd1, 0xa9, 0x40, 0x88, 0x1d, 0x40, 0x88, 0x4a, - 0x98, 0x77, 0xb7, 0x3f, 0xcb, 0xf0, 0x37, 0x00, 0x00, 0xff, 0xff, 0xd1, 0x51, 0xd5, 0xee, 0x43, - 0x03, 0x00, 0x00, + // 344 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0xd2, 0xb1, 0x4b, 0x33, 0x31, + 0x18, 0x06, 0xf0, 0xcb, 0x7d, 0x7c, 0x1d, 0x0e, 0xa7, 0x2e, 0xc2, 0x0d, 0x37, 0x38, 0x3a, 0x24, + 0xd8, 0x0e, 0x62, 0x70, 0x69, 0x1d, 0xd4, 0xe1, 0xa0, 0xd8, 0x0e, 0x87, 0x1c, 0x48, 0x7a, 0x17, + 0xce, 0x42, 0x2f, 0x29, 0xf7, 0xa6, 0xa5, 0xa3, 0xa3, 0xa3, 0x9b, 0xbb, 0xa3, 0x93, 0x7f, 0x86, + 0x38, 0x75, 0x74, 0x94, 0xeb, 0x20, 0xb8, 0xbb, 0x4b, 0x4c, 0xc0, 0x74, 0xcc, 0x74, 0xf0, 0xc2, + 0xef, 0xb9, 0xe7, 0x4d, 0x12, 0x9d, 0x0e, 0x00, 0xb8, 0x4a, 0x99, 0x50, 0x73, 0x4e, 0x6a, 0x59, + 0x2e, 0xe7, 0x1c, 0xc8, 0x9a, 0x30, 0x3d, 0x05, 0xa2, 0x1a, 0x26, 0x80, 0x15, 0x6a, 0x26, 0x05, + 0x10, 0xe0, 0xa2, 0x24, 0xc0, 0x9b, 0xd5, 0xac, 0xe0, 0x78, 0xd1, 0x48, 0x25, 0xbb, 0xd8, 0xd1, + 0xd8, 0x6a, 0xbc, 0xc6, 0x46, 0x63, 0x57, 0x63, 0xad, 0xe3, 0xfd, 0x42, 0x42, 0x2d, 0x81, 0xd4, + 0x50, 0x91, 0xd5, 0x91, 0xfe, 0x98, 0xa0, 0xd8, 0xb7, 0x46, 0xcd, 0x01, 0x58, 0x65, 0x6b, 0xc4, + 0x97, 0x9e, 0xda, 0x99, 0xdc, 0x34, 0x1c, 0x16, 0x52, 0x80, 0x8d, 0xea, 0x3d, 0xa2, 0xe8, 0x5f, + 0x0a, 0x55, 0xf7, 0x1e, 0x45, 0x9d, 0x0b, 0x26, 0xca, 0x39, 0xef, 0x1e, 0x7b, 0x6e, 0x89, 0x53, + 0x53, 0x2e, 0x3e, 0xf3, 0x85, 0x93, 0xbf, 0xc9, 0x95, 0xad, 0x75, 0x10, 0xc4, 0xff, 0xef, 0x3e, + 0x5f, 0x0e, 0xd1, 0xf0, 0x3b, 0x7c, 0x6d, 0x13, 0xb4, 0x69, 0x13, 0xf4, 0xd1, 0x26, 0xe8, 0x61, + 0x9b, 0x04, 0x9b, 0x6d, 0x12, 0xbc, 0x6f, 0x93, 0x20, 0xea, 0x15, 0xb2, 0xf6, 0xfc, 0xd7, 0x70, + 0x6f, 0x6c, 0x6e, 0x72, 0xa4, 0xd7, 0x1e, 0xa1, 0xeb, 0x93, 0x6a, 0xa6, 0x6e, 0x97, 0x53, 0x5c, + 0xc8, 0x9a, 0xf8, 0x1d, 0xe7, 0x53, 0xd8, 0x19, 0xa4, 0xd9, 0x60, 0x32, 0x7e, 0x0e, 0x77, 0x4a, + 0xa4, 0xb6, 0x44, 0x66, 0xa6, 0xe0, 0xae, 0x07, 0x78, 0xcc, 0x45, 0xf9, 0xb6, 0x03, 0x72, 0x0b, + 0xf2, 0x2c, 0x37, 0x20, 0x77, 0x41, 0xae, 0x41, 0x1b, 0x52, 0x3f, 0x90, 0x9f, 0x8f, 0x86, 0x29, + 0x57, 0xac, 0x64, 0x8a, 0x7d, 0x85, 0x7d, 0x07, 0x53, 0x6a, 0x35, 0xa5, 0x19, 0x35, 0xa9, 0x40, + 0xa9, 0x1b, 0x40, 0xa9, 0x4e, 0x98, 0x76, 0x7e, 0x1f, 0x46, 0xff, 0x27, 0x00, 0x00, 0xff, 0xff, + 0x9f, 0x53, 0x86, 0xbd, 0x2a, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/assets/transactions/send/service.pb.gw.go b/x/assets/transactions/send/service.pb.gw.go deleted file mode 100644 index 856a7b8c2..000000000 --- a/x/assets/transactions/send/service.pb.gw.go +++ /dev/null @@ -1,171 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: AssetMantle/modules/x/assets/transactions/send/service.proto - -/* -Package send is a reverse proxy. - -It translates gRPC into RESTful JSON APIs. -*/ -package send - -import ( - "context" - "io" - "net/http" - - "github.com/golang/protobuf/descriptor" - "github.com/golang/protobuf/proto" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/grpc-ecosystem/grpc-gateway/utilities" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/status" -) - -// Suppress "imported and not used" errors -var _ codes.Code -var _ io.Reader -var _ status.Status -var _ = runtime.String -var _ = utilities.NewDoubleArray -var _ = descriptor.ForMessage -var _ = metadata.Join - -var ( - filter_Msg_Handle_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - -func request_Msg_Handle_0(ctx context.Context, marshaler runtime.Marshaler, client MsgClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq Message - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.Handle(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Msg_Handle_0(ctx context.Context, marshaler runtime.Marshaler, server MsgServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq Message - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.Handle(ctx, &protoReq) - return msg, metadata, err - -} - -// RegisterMsgHandlerServer registers the http handlers for service Msg to "mux". -// UnaryRPC :call MsgServer directly. -// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterMsgHandlerFromEndpoint instead. -func RegisterMsgHandlerServer(ctx context.Context, mux *runtime.ServeMux, server MsgServer) error { - - mux.Handle("POST", pattern_Msg_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Msg_Handle_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Msg_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -// RegisterMsgHandlerFromEndpoint is same as RegisterMsgHandler but -// automatically dials to "endpoint" and closes the connection when "ctx" gets done. -func RegisterMsgHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.Dial(endpoint, opts...) - if err != nil { - return err - } - defer func() { - if err != nil { - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - return - } - go func() { - <-ctx.Done() - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - }() - }() - - return RegisterMsgHandler(ctx, mux, conn) -} - -// RegisterMsgHandler registers the http handlers for service Msg to "mux". -// The handlers forward requests to the grpc endpoint over "conn". -func RegisterMsgHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { - return RegisterMsgHandlerClient(ctx, mux, NewMsgClient(conn)) -} - -// RegisterMsgHandlerClient registers the http handlers for service Msg -// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "MsgClient". -// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "MsgClient" -// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "MsgClient" to call the correct interceptors. -func RegisterMsgHandlerClient(ctx context.Context, mux *runtime.ServeMux, client MsgClient) error { - - mux.Handle("POST", pattern_Msg_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Msg_Handle_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Msg_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -var ( - pattern_Msg_Handle_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"mantle", "assets", "send"}, "", runtime.AssumeColonVerbOpt(false))) -) - -var ( - forward_Msg_Handle_0 = runtime.ForwardResponseMessage -) diff --git a/x/assets/transactions/send/transaction.go b/x/assets/transactions/send/transaction.go index 263c9308d..fa0712fae 100644 --- a/x/assets/transactions/send/transaction.go +++ b/x/assets/transactions/send/transaction.go @@ -4,22 +4,14 @@ package send import ( - "context" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "google.golang.org/grpc" - "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/helpers/constants" - "github.com/AssetMantle/modules/utilities/name" + "google.golang.org/grpc" ) -type dummy struct{} - var Transaction = baseHelpers.NewTransaction( - name.GetPackageName(dummy{}), + _Msg_serviceDesc.ServiceName, "", "", @@ -30,9 +22,6 @@ var Transaction = baseHelpers.NewTransaction( func(server grpc.ServiceRegistrar, keeper helpers.TransactionKeeper) { RegisterMsgServer(server, keeper.(transactionKeeper)) }, - func(clientCtx client.Context, mux *runtime.ServeMux) error { - return RegisterMsgHandlerClient(context.Background(), mux, NewMsgClient(clientCtx)) - }, constants.FromIdentityID, constants.ToIdentityID, diff --git a/x/assets/transactions/send/transaction_keeper.go b/x/assets/transactions/send/transaction_keeper.go index 44366d97e..ecea9200a 100644 --- a/x/assets/transactions/send/transaction_keeper.go +++ b/x/assets/transactions/send/transaction_keeper.go @@ -65,7 +65,7 @@ func (transactionKeeper transactionKeeper) Transact(context context.Context, mes // // Note: The errorConstants and propertyConstants are used for error handling and property checking respectively. func (transactionKeeper transactionKeeper) Handle(context context.Context, message *Message) (*TransactionResponse, error) { - if _, err := transactionKeeper.authenticateAuxiliary.GetKeeper().Help(context, authenticate.NewAuxiliaryRequest(message.GetFromAddress(), message.FromID)); err != nil { + if _, err := transactionKeeper.authenticateAuxiliary.GetKeeper().Help(context, authenticate.NewAuxiliaryRequest(message.GetSigners()[0], message.FromID)); err != nil { return nil, err } diff --git a/x/assets/transactions/send/transaction_request.go b/x/assets/transactions/send/transaction_request.go index e79b71c56..396c3171c 100644 --- a/x/assets/transactions/send/transaction_request.go +++ b/x/assets/transactions/send/transaction_request.go @@ -5,25 +5,23 @@ package send import ( "encoding/json" - "github.com/AssetMantle/modules/utilities/rest" - - codecUtilities "github.com/AssetMantle/schema/codec/utilities" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" "github.com/cosmos/cosmos-sdk/client" - sdkCodec "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" + "io" + "net/http" "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/helpers/constants" ) type transactionRequest struct { - BaseReq rest.BaseReq `json:"baseReq"` - FromID string `json:"fromID"` - ToID string `json:"toID"` - AssetID string `json:"assetID"` - Value string `json:"value"` + helpers.CommonTransactionRequest `json:"commonTransactionRequest"` + FromID string `json:"fromID"` + ToID string `json:"toID"` + AssetID string `json:"assetID"` + Value string `json:"value"` } var _ helpers.TransactionRequest = (*transactionRequest)(nil) @@ -49,25 +47,30 @@ func (transactionRequest transactionRequest) Validate() error { } func (transactionRequest transactionRequest) FromCLI(cliCommand helpers.CLICommand, context client.Context) (helpers.TransactionRequest, error) { return newTransactionRequest( - cliCommand.ReadBaseReq(context), + cliCommand.ReadCommonTransactionRequest(context), cliCommand.ReadString(constants.FromIdentityID), cliCommand.ReadString(constants.ToIdentityID), cliCommand.ReadString(constants.AssetID), cliCommand.ReadString(constants.Value), ), nil } -func (transactionRequest transactionRequest) FromJSON(rawMessage json.RawMessage) (helpers.TransactionRequest, error) { - if err := json.Unmarshal(rawMessage, &transactionRequest); err != nil { +func (transactionRequest transactionRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.TransactionRequest, error) { + body, err := io.ReadAll(httpRequest.Body) + if err != nil { + return nil, err + } + + if err := json.Unmarshal(body, &transactionRequest); err != nil { return nil, err } return transactionRequest, nil } -func (transactionRequest transactionRequest) GetBaseReq() rest.BaseReq { - return transactionRequest.BaseReq +func (transactionRequest transactionRequest) GetCommonTransactionRequest() helpers.CommonTransactionRequest { + return transactionRequest.CommonTransactionRequest } func (transactionRequest transactionRequest) MakeMsg() (sdkTypes.Msg, error) { - from, err := sdkTypes.AccAddressFromBech32(transactionRequest.GetBaseReq().From) + from, err := sdkTypes.AccAddressFromBech32(transactionRequest.GetCommonTransactionRequest().GetFrom()) if err != nil { return nil, err } @@ -100,18 +103,15 @@ func (transactionRequest transactionRequest) MakeMsg() (sdkTypes.Msg, error) { value, ), nil } -func (transactionRequest) RegisterLegacyAminoCodec(legacyAmino *sdkCodec.LegacyAmino) { - codecUtilities.RegisterModuleConcrete(legacyAmino, transactionRequest{}) -} func requestPrototype() helpers.TransactionRequest { return transactionRequest{} } -func newTransactionRequest(baseReq rest.BaseReq, fromID string, toID string, assetID string, value string) helpers.TransactionRequest { +func newTransactionRequest(commonTransactionRequest helpers.CommonTransactionRequest, fromID string, toID string, assetID string, value string) helpers.TransactionRequest { return transactionRequest{ - BaseReq: baseReq, - FromID: fromID, - ToID: toID, - AssetID: assetID, - Value: value, + CommonTransactionRequest: commonTransactionRequest, + FromID: fromID, + ToID: toID, + AssetID: assetID, + Value: value, } } diff --git a/x/assets/transactions/send/transaction_request_test.go b/x/assets/transactions/send/transaction_request_test.go index a13ed9b9f..f88ba5577 100644 --- a/x/assets/transactions/send/transaction_request_test.go +++ b/x/assets/transactions/send/transaction_request_test.go @@ -4,50 +4,45 @@ package send import ( - "encoding/json" "fmt" - "github.com/AssetMantle/modules/utilities/rest" + baseIDs "github.com/AssetMantle/schema/ids/base" "reflect" "testing" - baseIDs "github.com/AssetMantle/schema/ids/base" "github.com/cosmos/cosmos-sdk/client" - sdkCodec "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/types" - "github.com/spf13/viper" - "github.com/stretchr/testify/require" - "github.com/AssetMantle/modules/helpers" - "github.com/AssetMantle/modules/helpers/base" + baseHelpers "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/helpers/constants" + "github.com/spf13/viper" ) var ( - fromAccAddress, _ = types.AccAddressFromBech32(fromAddress.String()) - testBaseRequest = rest.BaseReq{From: fromAddress.String(), ChainID: "test", Fees: types.NewCoins()} - fromID = baseIDs.PrototypeIdentityID().(*baseIDs.IdentityID) - testRate = types.OneInt() + fromAccAddress, _ = types.AccAddressFromBech32(fromAddress.String()) + commonTransactionRequest = helpers.PrototypeCommonTransactionRequest() + fromID = baseIDs.PrototypeIdentityID().(*baseIDs.IdentityID) + testRate = types.OneInt() ) func Test_newTransactionRequest(t *testing.T) { type args struct { - baseReq rest.BaseReq - fromID string - toID string - assetID string - value string + commonTransactionRequest helpers.CommonTransactionRequest + fromID string + toID string + assetID string + value string } tests := []struct { name string args args want helpers.TransactionRequest }{ - {"+ve", args{testBaseRequest, fromID.AsString(), fromID.AsString(), assetID.AsString(), testRate.String()}, transactionRequest{testBaseRequest, fromID.AsString(), fromID.AsString(), assetID.AsString(), testRate.String()}}, + {"+ve", args{commonTransactionRequest, fromID.AsString(), fromID.AsString(), assetID.AsString(), testRate.String()}, transactionRequest{commonTransactionRequest, fromID.AsString(), fromID.AsString(), assetID.AsString(), testRate.String()}}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - if got := newTransactionRequest(tt.args.baseReq, tt.args.fromID, tt.args.toID, tt.args.assetID, tt.args.value); !reflect.DeepEqual(got, tt.want) { + if got := newTransactionRequest(tt.args.commonTransactionRequest, tt.args.fromID, tt.args.toID, tt.args.assetID, tt.args.value); !reflect.DeepEqual(got, tt.want) { t.Errorf("newTransactionRequest() = %v, want %v", got, tt.want) } }) @@ -71,18 +66,18 @@ func Test_requestPrototype(t *testing.T) { } func Test_transactionRequest_FromCLI(t *testing.T) { - cliCommand := base.NewCLICommand("", "", "", []helpers.CLIFlag{constants.ToIdentityID, constants.FromIdentityID, constants.AssetID, constants.Value}) + cliCommand := baseHelpers.NewCLICommand("", "", "", []helpers.CLIFlag{constants.ToIdentityID, constants.FromIdentityID, constants.AssetID, constants.Value}) viper.Set(constants.FromIdentityID.GetName(), fromID.AsString()) viper.Set(constants.ToIdentityID.GetName(), fromID.AsString()) viper.Set(constants.AssetID.GetName(), assetID.AsString()) viper.Set(constants.Value.GetName(), testRate.String()) type fields struct { - BaseReq rest.BaseReq - FromID string - ToID string - AssetID string - Value string + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + ToID string + AssetID string + Value string } type args struct { cliCommand helpers.CLICommand @@ -95,16 +90,16 @@ func Test_transactionRequest_FromCLI(t *testing.T) { want helpers.TransactionRequest wantErr bool }{ - {"+ve", fields{testBaseRequest, fromID.AsString(), fromID.AsString(), assetID.AsString(), testRate.String()}, args{cliCommand, client.Context{}.WithCodec(base.CodecPrototype())}, transactionRequest{testBaseRequest, fromID.AsString(), fromID.AsString(), assetID.AsString(), testRate.String()}, false}, + {"+ve", fields{commonTransactionRequest, fromID.AsString(), fromID.AsString(), assetID.AsString(), testRate.String()}, args{cliCommand, client.Context{}.WithCodec(baseHelpers.CodecPrototype())}, transactionRequest{commonTransactionRequest, fromID.AsString(), fromID.AsString(), assetID.AsString(), testRate.String()}, false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - ToID: tt.fields.ToID, - AssetID: tt.fields.AssetID, - Value: tt.fields.Value, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + ToID: tt.fields.ToID, + AssetID: tt.fields.AssetID, + Value: tt.fields.Value, } got, err := transactionRequest.FromCLI(tt.args.cliCommand, tt.args.context) if (err != nil) != tt.wantErr { @@ -118,75 +113,32 @@ func Test_transactionRequest_FromCLI(t *testing.T) { } } -func Test_transactionRequest_FromJSON(t *testing.T) { - jsonMessage, err := json.Marshal(newTransactionRequest(testBaseRequest, fromID.AsString(), fromID.AsString(), assetID.AsString(), testRate.String())) - require.NoError(t, err) - type fields struct { - BaseReq rest.BaseReq - FromID string - ToID string - AssetID string - Value string - } - type args struct { - rawMessage json.RawMessage - } - tests := []struct { - name string - fields fields - args args - want helpers.TransactionRequest - wantErr bool - }{ - {"+ve", fields{testBaseRequest, fromID.AsString(), fromID.AsString(), assetID.AsString(), testRate.String()}, args{jsonMessage}, transactionRequest{testBaseRequest, fromID.AsString(), fromID.AsString(), assetID.AsString(), testRate.String()}, false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - ToID: tt.fields.ToID, - AssetID: tt.fields.AssetID, - Value: tt.fields.Value, - } - got, err := transactionRequest.FromJSON(tt.args.rawMessage) - if (err != nil) != tt.wantErr { - t.Errorf("FromJSON() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("FromJSON() got = %v, want %v", got, tt.want) - } - }) - } -} - func Test_transactionRequest_GetBaseReq(t *testing.T) { type fields struct { - BaseReq rest.BaseReq - FromID string - ToID string - AssetID string - Value string + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + ToID string + AssetID string + Value string } tests := []struct { name string fields fields - want rest.BaseReq + want helpers.CommonTransactionRequest }{ - {"+ve", fields{testBaseRequest, fromID.AsString(), fromID.AsString(), assetID.AsString(), testRate.String()}, testBaseRequest}, + {"+ve", fields{commonTransactionRequest, fromID.AsString(), fromID.AsString(), assetID.AsString(), testRate.String()}, commonTransactionRequest}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - ToID: tt.fields.ToID, - AssetID: tt.fields.AssetID, - Value: tt.fields.Value, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + ToID: tt.fields.ToID, + AssetID: tt.fields.AssetID, + Value: tt.fields.Value, } - if got := transactionRequest.GetBaseReq(); !reflect.DeepEqual(got, tt.want) { - t.Errorf("GetBaseReq() = %v, want %v", got, tt.want) + if got := transactionRequest.GetCommonTransactionRequest(); !reflect.DeepEqual(got, tt.want) { + t.Errorf("GetCommonTransactionRequest() = %v, want %v", got, tt.want) } }) } @@ -194,11 +146,11 @@ func Test_transactionRequest_GetBaseReq(t *testing.T) { func Test_transactionRequest_MakeMsg(t *testing.T) { type fields struct { - BaseReq rest.BaseReq - FromID string - ToID string - AssetID string - Value string + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + ToID string + AssetID string + Value string } tests := []struct { name string @@ -206,16 +158,16 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { want types.Msg wantErr bool }{ - {"+ve", fields{testBaseRequest, fromID.AsString(), fromID.AsString(), assetID.AsString(), testRate.String()}, NewMessage(fromAccAddress, fromID, fromID, assetID, testRate), false}, + {"+ve", fields{commonTransactionRequest, fromID.AsString(), fromID.AsString(), assetID.AsString(), testRate.String()}, NewMessage(fromAccAddress, fromID, fromID, assetID, testRate), false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - ToID: tt.fields.ToID, - AssetID: tt.fields.AssetID, - Value: tt.fields.Value, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + ToID: tt.fields.ToID, + AssetID: tt.fields.AssetID, + Value: tt.fields.Value, } got, err := transactionRequest.MakeMsg() if (err != nil) != tt.wantErr { @@ -229,61 +181,29 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { } } -func Test_transactionRequest_RegisterCodec(t *testing.T) { - type fields struct { - BaseReq rest.BaseReq - FromID string - ToID string - AssetID string - Value string - } - type args struct { - legacyAmino *sdkCodec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{testBaseRequest, fromID.AsString(), fromID.AsString(), assetID.AsString(), testRate.String()}, args{codec.GetLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - tr := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - ToID: tt.fields.ToID, - AssetID: tt.fields.AssetID, - Value: tt.fields.Value, - } - tr.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - func Test_transactionRequest_Validate(t *testing.T) { type fields struct { - BaseReq rest.BaseReq - FromID string - ToID string - AssetID string - Value string + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + ToID string + AssetID string + Value string } tests := []struct { name string fields fields wantErr bool }{ - {"+ve", fields{testBaseRequest, fromID.AsString(), fromID.AsString(), assetID.AsString(), testRate.String()}, false}, + {"+ve", fields{commonTransactionRequest, fromID.AsString(), fromID.AsString(), assetID.AsString(), testRate.String()}, false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - ToID: tt.fields.ToID, - AssetID: tt.fields.AssetID, - Value: tt.fields.Value, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + ToID: tt.fields.ToID, + AssetID: tt.fields.AssetID, + Value: tt.fields.Value, } if err := transactionRequest.Validate(); (err != nil) != tt.wantErr { t.Errorf("ValidateBasic() error = %v, wantErr %v", err, tt.wantErr) diff --git a/x/assets/transactions/send/transaction_response.go b/x/assets/transactions/send/transaction_response.go index 251ff9b5c..1cf371f2f 100644 --- a/x/assets/transactions/send/transaction_response.go +++ b/x/assets/transactions/send/transaction_response.go @@ -4,9 +4,8 @@ package send import ( - sdkTypes "github.com/cosmos/cosmos-sdk/types" - "github.com/AssetMantle/modules/helpers" + sdkTypes "github.com/cosmos/cosmos-sdk/types" ) var _ helpers.TransactionResponse = (*TransactionResponse)(nil) diff --git a/x/assets/transactions/unwrap/message.go b/x/assets/transactions/unwrap/message.go index 9bdf1df5e..15272d12c 100644 --- a/x/assets/transactions/unwrap/message.go +++ b/x/assets/transactions/unwrap/message.go @@ -4,28 +4,17 @@ package unwrap import ( + "github.com/AssetMantle/modules/helpers" errorConstants "github.com/AssetMantle/modules/helpers/constants" "github.com/AssetMantle/modules/x/assets/constants" - codecUtilities "github.com/AssetMantle/schema/codec/utilities" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" - sdkCodec "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/types" sdkTypes "github.com/cosmos/cosmos-sdk/types" - - "github.com/AssetMantle/modules/helpers" ) var _ helpers.Message = (*Message)(nil) -func (message *Message) Type() string { return Transaction.GetName() } -func (message *Message) GetFromAddress() sdkTypes.AccAddress { - from, err := sdkTypes.AccAddressFromBech32(message.From) - if err != nil { - panic(err) - } - return from -} func (message *Message) ValidateBasic() error { if _, err := sdkTypes.AccAddressFromBech32(message.From); err != nil { return errorConstants.InvalidMessage.Wrapf("invalid from address %s", err.Error()) @@ -48,21 +37,10 @@ func (message *Message) GetSigners() []sdkTypes.AccAddress { } return []sdkTypes.AccAddress{from} } -func (*Message) RegisterLegacyAminoCodec(legacyAmino *sdkCodec.LegacyAmino) { - codecUtilities.RegisterModuleConcrete(legacyAmino, Message{}) -} func (message *Message) RegisterInterface(interfaceRegistry types.InterfaceRegistry) { interfaceRegistry.RegisterImplementations((*sdkTypes.Msg)(nil), message) } -func messageFromInterface(msg sdkTypes.Msg) *Message { - switch value := msg.(type) { - case *Message: - return value - default: - return &Message{} - } -} func messagePrototype() helpers.Message { return &Message{} } diff --git a/x/assets/transactions/unwrap/message_test.go b/x/assets/transactions/unwrap/message_test.go index 6d96f10d4..79156cf65 100644 --- a/x/assets/transactions/unwrap/message_test.go +++ b/x/assets/transactions/unwrap/message_test.go @@ -9,7 +9,6 @@ import ( "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" "github.com/cometbft/cometbft/crypto/ed25519" - sdkCodec "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/types" "reflect" "testing" @@ -143,25 +142,6 @@ func TestMessage_ValidateBasic(t *testing.T) { }) } } -func Test_messageFromInterface(t *testing.T) { - type args struct { - msg helpers.Message - } - tests := []struct { - name string - args args - want *Message - }{ - {"+ve", args{NewMessage(fromAccAddress, fromID, coins).(*Message)}, &Message{fromAccAddress.String(), fromID, coins}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := messageFromInterface(tt.args.msg); !reflect.DeepEqual(got, tt.want) { - t.Errorf("messageFromInterface() = %v, want %v", got, tt.want) - } - }) - } -} func Test_messagePrototype(t *testing.T) { tests := []struct { @@ -206,61 +186,6 @@ func Test_message_GetSigners(t *testing.T) { } } -func Test_message_RegisterCodec(t *testing.T) { - type fields struct { - From string - FromID *baseIDs.IdentityID - Coins types.Coins - } - type args struct { - legacyAmino *sdkCodec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{fromAccAddress.String(), fromID, coins}, args{codec.GetLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - me := &Message{ - From: tt.fields.From, - FromID: tt.fields.FromID, - Coins: tt.fields.Coins, - } - me.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - -func Test_message_Type(t *testing.T) { - type fields struct { - From string - FromID *baseIDs.IdentityID - Coins types.Coins - } - tests := []struct { - name string - fields fields - want string - }{ - {"+ve", fields{fromAccAddress.String(), fromID, coins}, Transaction.GetName()}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - message := &Message{ - From: tt.fields.From, - FromID: tt.fields.FromID, - Coins: tt.fields.Coins, - } - if got := message.Type(); got != tt.want { - t.Errorf("Type() = %v, want %v", got, tt.want) - } - }) - } -} - func Test_NewMessage(t *testing.T) { type args struct { from types.AccAddress diff --git a/x/assets/transactions/unwrap/service.pb.go b/x/assets/transactions/unwrap/service.pb.go index c5d0a20d2..561715217 100644 --- a/x/assets/transactions/unwrap/service.pb.go +++ b/x/assets/transactions/unwrap/service.pb.go @@ -6,9 +6,9 @@ package unwrap import ( context "context" fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types/msgservice" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" - _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -31,30 +31,29 @@ func init() { } var fileDescriptor_590bf0044c41d756 = []byte{ - // 360 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0xd2, 0x4f, 0x4a, 0xc3, 0x40, - 0x14, 0x06, 0xf0, 0x26, 0x85, 0x2e, 0x82, 0xab, 0x82, 0x08, 0x41, 0xb3, 0xe8, 0x01, 0x66, 0xc4, - 0x3f, 0x0b, 0x47, 0x11, 0x5a, 0x10, 0x05, 0x09, 0x14, 0x6d, 0x21, 0x48, 0x40, 0xa6, 0xe9, 0x10, - 0x03, 0xc9, 0x4c, 0xc8, 0x9b, 0x6a, 0xb7, 0x7a, 0x02, 0xc1, 0x1b, 0xb8, 0xd3, 0x9d, 0xb7, 0x10, - 0x57, 0x05, 0x37, 0x2e, 0x25, 0x75, 0xe5, 0x29, 0xa4, 0x9d, 0x01, 0xa7, 0xcb, 0xd9, 0xbe, 0xf0, - 0xfb, 0xf8, 0xde, 0xe4, 0x79, 0xc7, 0x5d, 0x00, 0x26, 0x43, 0xca, 0x65, 0xce, 0x70, 0x21, 0xc6, - 0x93, 0x9c, 0x01, 0x9e, 0x62, 0xba, 0x98, 0x02, 0x96, 0x15, 0xe5, 0x40, 0x13, 0x99, 0x09, 0x0e, - 0x78, 0xc2, 0xef, 0x2a, 0x5a, 0x62, 0x60, 0xd5, 0x6d, 0x96, 0x30, 0x54, 0x56, 0x42, 0x8a, 0xf6, - 0xb6, 0xe1, 0x91, 0xf6, 0x68, 0x8a, 0x94, 0x47, 0xa6, 0x47, 0xca, 0xfb, 0x9b, 0xa9, 0x10, 0x69, - 0xce, 0x30, 0x2d, 0x33, 0x4c, 0x39, 0x17, 0x92, 0xaa, 0xcf, 0xcb, 0x3c, 0xdf, 0xbe, 0x4f, 0xc1, - 0x00, 0x68, 0xaa, 0xfb, 0xf8, 0xe7, 0xd6, 0xde, 0x98, 0x5d, 0x57, 0x0c, 0x4a, 0xc1, 0x41, 0x87, - 0xed, 0xbc, 0x39, 0x5e, 0x33, 0x84, 0xb4, 0xfd, 0xe2, 0x78, 0xad, 0x33, 0xca, 0xc7, 0x39, 0x6b, - 0x1f, 0x20, 0xdb, 0x85, 0x51, 0xa8, 0x0a, 0xfa, 0x27, 0xf6, 0x74, 0xf0, 0x3f, 0xbb, 0xd0, 0xd5, - 0x3a, 0x5b, 0x0f, 0x9f, 0x3f, 0x4f, 0xee, 0x46, 0x67, 0x1d, 0x17, 0x6a, 0x4b, 0xbd, 0x9b, 0x22, - 0xbd, 0xfb, 0xe6, 0x7b, 0x1d, 0x38, 0xb3, 0x3a, 0x70, 0xbe, 0xeb, 0xc0, 0x79, 0x9c, 0x07, 0x8d, - 0xd9, 0x3c, 0x68, 0x7c, 0xcd, 0x83, 0x86, 0xb7, 0x97, 0x88, 0xc2, 0xba, 0x43, 0x6f, 0xed, 0x52, - 0xfd, 0xf0, 0xfe, 0xe2, 0x49, 0xfa, 0xce, 0xd5, 0x61, 0x9a, 0xc9, 0x9b, 0xc9, 0x08, 0x25, 0xa2, - 0xc0, 0xb6, 0x8f, 0xfd, 0xec, 0xb6, 0xba, 0x61, 0xd4, 0x1d, 0x0c, 0x5f, 0xdd, 0x95, 0xc3, 0x09, - 0x75, 0x91, 0x48, 0xd5, 0x03, 0x73, 0x71, 0x40, 0xc3, 0xa5, 0xfd, 0x58, 0x21, 0xb1, 0x26, 0x71, - 0x14, 0x2b, 0x12, 0x9b, 0x24, 0x56, 0xa4, 0x76, 0x8f, 0x6c, 0x49, 0x7c, 0xda, 0xef, 0x85, 0x4c, - 0xd2, 0x31, 0x95, 0xf4, 0xd7, 0xdd, 0x37, 0x38, 0x21, 0xda, 0x13, 0x12, 0x11, 0xa2, 0x12, 0x08, - 0x31, 0x23, 0x08, 0x51, 0x19, 0xa3, 0xd6, 0xf2, 0x7c, 0x76, 0xff, 0x02, 0x00, 0x00, 0xff, 0xff, - 0x4a, 0xe6, 0x26, 0x51, 0x5d, 0x03, 0x00, 0x00, + // 350 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0xd2, 0x3f, 0x4b, 0xfb, 0x40, + 0x18, 0x07, 0xf0, 0x5c, 0xca, 0xaf, 0x43, 0xf8, 0x4d, 0x5d, 0x84, 0x0c, 0x19, 0x1c, 0x1d, 0xee, + 0xfc, 0x3b, 0x78, 0x8a, 0xd0, 0x82, 0x28, 0x48, 0xa0, 0x68, 0x0b, 0x41, 0x02, 0x72, 0x4d, 0x8f, + 0x58, 0x68, 0xee, 0x4a, 0x9e, 0x6b, 0xed, 0xa8, 0xbb, 0x83, 0xbb, 0x9b, 0xa3, 0x93, 0x2f, 0x43, + 0x9c, 0x3a, 0x3a, 0x4a, 0x3a, 0x08, 0xbe, 0x0a, 0x49, 0xef, 0xc0, 0xeb, 0x78, 0x53, 0xe0, 0x81, + 0xcf, 0x37, 0xdf, 0x27, 0x79, 0x82, 0x93, 0x36, 0x00, 0x57, 0x31, 0x13, 0x6a, 0xcc, 0x49, 0x21, + 0x87, 0xd3, 0x31, 0x07, 0x32, 0x27, 0xac, 0x9e, 0x02, 0x51, 0x25, 0x13, 0xc0, 0x32, 0x35, 0x92, + 0x02, 0xc8, 0x54, 0xdc, 0x95, 0x6c, 0x42, 0x80, 0x97, 0xb3, 0x51, 0xc6, 0xf1, 0xa4, 0x94, 0x4a, + 0xb6, 0xb6, 0x2d, 0x8f, 0x8d, 0xc7, 0x73, 0xac, 0x3d, 0xb6, 0x3d, 0xd6, 0x3e, 0xdc, 0xc8, 0x24, + 0x14, 0x12, 0x48, 0x01, 0x39, 0x99, 0xed, 0xd4, 0x0f, 0x1d, 0x15, 0xba, 0x57, 0x29, 0x38, 0x00, + 0xcb, 0x4d, 0x95, 0xf0, 0xc2, 0xd9, 0x5b, 0xb3, 0x9b, 0x92, 0xc3, 0x44, 0x0a, 0x30, 0x61, 0xbb, + 0xcf, 0x28, 0x68, 0xc4, 0x90, 0xb7, 0x1e, 0x51, 0xd0, 0x3c, 0x67, 0x62, 0x38, 0xe6, 0xad, 0x43, + 0xec, 0xba, 0x2b, 0x8e, 0x75, 0xc1, 0xf0, 0xd4, 0x9d, 0xf6, 0xfe, 0x66, 0x97, 0xa6, 0xda, 0xa6, + 0x17, 0xfe, 0xbb, 0xff, 0x7e, 0xdb, 0x42, 0x9d, 0x87, 0xc6, 0x7b, 0x15, 0xa1, 0x45, 0x15, 0xa1, + 0xaf, 0x2a, 0x42, 0x4f, 0xcb, 0xc8, 0x5b, 0x2c, 0x23, 0xef, 0x73, 0x19, 0x79, 0xc1, 0x7e, 0x26, + 0x0b, 0xe7, 0xb7, 0x75, 0xfe, 0x5f, 0xe9, 0xbf, 0xda, 0xad, 0x97, 0xef, 0xa2, 0xeb, 0xa3, 0x7c, + 0xa4, 0x6e, 0xa7, 0x03, 0x9c, 0xc9, 0x82, 0xb8, 0x7e, 0xd6, 0x17, 0xbf, 0xd9, 0x8e, 0x93, 0x76, + 0xaf, 0xff, 0xea, 0xaf, 0x5d, 0x47, 0x6c, 0x8a, 0x24, 0xba, 0x1e, 0xd8, 0x2b, 0x02, 0xee, 0xaf, + 0xec, 0xc7, 0x1a, 0x49, 0x0d, 0x49, 0x93, 0x54, 0x93, 0xd4, 0x26, 0xa9, 0x26, 0x95, 0x7f, 0xec, + 0x4a, 0xd2, 0xb3, 0x6e, 0x27, 0xe6, 0x8a, 0x0d, 0x99, 0x62, 0x3f, 0xfe, 0x81, 0xc5, 0x29, 0x35, + 0x9e, 0xd2, 0x84, 0x52, 0x9d, 0x40, 0xa9, 0x1d, 0x41, 0xa9, 0xce, 0x18, 0x34, 0x57, 0x87, 0xb2, + 0xf7, 0x1b, 0x00, 0x00, 0xff, 0xff, 0x41, 0xde, 0xa5, 0x08, 0x42, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/assets/transactions/unwrap/service.pb.gw.go b/x/assets/transactions/unwrap/service.pb.gw.go deleted file mode 100644 index e19aada74..000000000 --- a/x/assets/transactions/unwrap/service.pb.gw.go +++ /dev/null @@ -1,171 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: AssetMantle/modules/x/assets/transactions/unwrap/service.proto - -/* -Package unwrap is a reverse proxy. - -It translates gRPC into RESTful JSON APIs. -*/ -package unwrap - -import ( - "context" - "io" - "net/http" - - "github.com/golang/protobuf/descriptor" - "github.com/golang/protobuf/proto" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/grpc-ecosystem/grpc-gateway/utilities" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/status" -) - -// Suppress "imported and not used" errors -var _ codes.Code -var _ io.Reader -var _ status.Status -var _ = runtime.String -var _ = utilities.NewDoubleArray -var _ = descriptor.ForMessage -var _ = metadata.Join - -var ( - filter_Msg_Handle_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - -func request_Msg_Handle_0(ctx context.Context, marshaler runtime.Marshaler, client MsgClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq Message - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.Handle(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Msg_Handle_0(ctx context.Context, marshaler runtime.Marshaler, server MsgServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq Message - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.Handle(ctx, &protoReq) - return msg, metadata, err - -} - -// RegisterMsgHandlerServer registers the http handlers for service Msg to "mux". -// UnaryRPC :call MsgServer directly. -// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterMsgHandlerFromEndpoint instead. -func RegisterMsgHandlerServer(ctx context.Context, mux *runtime.ServeMux, server MsgServer) error { - - mux.Handle("POST", pattern_Msg_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Msg_Handle_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Msg_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -// RegisterMsgHandlerFromEndpoint is same as RegisterMsgHandler but -// automatically dials to "endpoint" and closes the connection when "ctx" gets done. -func RegisterMsgHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.Dial(endpoint, opts...) - if err != nil { - return err - } - defer func() { - if err != nil { - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - return - } - go func() { - <-ctx.Done() - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - }() - }() - - return RegisterMsgHandler(ctx, mux, conn) -} - -// RegisterMsgHandler registers the http handlers for service Msg to "mux". -// The handlers forward requests to the grpc endpoint over "conn". -func RegisterMsgHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { - return RegisterMsgHandlerClient(ctx, mux, NewMsgClient(conn)) -} - -// RegisterMsgHandlerClient registers the http handlers for service Msg -// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "MsgClient". -// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "MsgClient" -// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "MsgClient" to call the correct interceptors. -func RegisterMsgHandlerClient(ctx context.Context, mux *runtime.ServeMux, client MsgClient) error { - - mux.Handle("POST", pattern_Msg_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Msg_Handle_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Msg_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -var ( - pattern_Msg_Handle_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"mantle", "assets", "unwrap"}, "", runtime.AssumeColonVerbOpt(false))) -) - -var ( - forward_Msg_Handle_0 = runtime.ForwardResponseMessage -) diff --git a/x/assets/transactions/unwrap/transaction.go b/x/assets/transactions/unwrap/transaction.go index b855276fb..85dc58386 100644 --- a/x/assets/transactions/unwrap/transaction.go +++ b/x/assets/transactions/unwrap/transaction.go @@ -4,22 +4,14 @@ package unwrap import ( - "context" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "google.golang.org/grpc" - "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/helpers/constants" - "github.com/AssetMantle/modules/utilities/name" + "google.golang.org/grpc" ) -type dummy struct{} - var Transaction = baseHelpers.NewTransaction( - name.GetPackageName(dummy{}), + _Msg_serviceDesc.ServiceName, "", "", @@ -30,9 +22,6 @@ var Transaction = baseHelpers.NewTransaction( func(server grpc.ServiceRegistrar, keeper helpers.TransactionKeeper) { RegisterMsgServer(server, keeper.(transactionKeeper)) }, - func(clientCtx client.Context, mux *runtime.ServeMux) error { - return RegisterMsgHandlerClient(context.Background(), mux, NewMsgClient(clientCtx)) - }, constants.FromIdentityID, constants.Coins, diff --git a/x/assets/transactions/unwrap/transaction_keeper.go b/x/assets/transactions/unwrap/transaction_keeper.go index bd8d0a0d4..1cd1ea3eb 100644 --- a/x/assets/transactions/unwrap/transaction_keeper.go +++ b/x/assets/transactions/unwrap/transaction_keeper.go @@ -7,7 +7,6 @@ import ( "context" errorConstants "github.com/AssetMantle/modules/helpers/constants" "github.com/AssetMantle/modules/x/assets/constants" - "github.com/AssetMantle/schema/data/base" baseDocuments "github.com/AssetMantle/schema/documents/base" constantProperties "github.com/AssetMantle/schema/properties/constants" @@ -60,7 +59,7 @@ func (transactionKeeper transactionKeeper) Transact(context context.Context, mes // // 4. If the process completes successfully for all coins, it returns a new TransactionResponse object. func (transactionKeeper transactionKeeper) Handle(context context.Context, message *Message) (*TransactionResponse, error) { - if _, err := transactionKeeper.authenticateAuxiliary.GetKeeper().Help(context, authenticate.NewAuxiliaryRequest(message.GetFromAddress(), message.FromID)); err != nil { + if _, err := transactionKeeper.authenticateAuxiliary.GetKeeper().Help(context, authenticate.NewAuxiliaryRequest(message.GetSigners()[0], message.FromID)); err != nil { return nil, err } @@ -89,7 +88,7 @@ func (transactionKeeper transactionKeeper) Handle(context context.Context, messa return nil, err } - if err := transactionKeeper.bankKeeper.SendCoinsFromModuleToAccount(sdkTypes.UnwrapSDKContext(context), constants.ModuleName, message.GetFromAddress(), sdkTypes.NewCoins(coin)); err != nil { + if err := transactionKeeper.bankKeeper.SendCoinsFromModuleToAccount(sdkTypes.UnwrapSDKContext(context), constants.ModuleName, message.GetSigners()[0], sdkTypes.NewCoins(coin)); err != nil { return nil, err } } diff --git a/x/assets/transactions/unwrap/transaction_keeper_test.go b/x/assets/transactions/unwrap/transaction_keeper_test.go index 8fc6063b2..918874d04 100644 --- a/x/assets/transactions/unwrap/transaction_keeper_test.go +++ b/x/assets/transactions/unwrap/transaction_keeper_test.go @@ -5,11 +5,8 @@ package unwrap import ( "context" - baseHelpers "github.com/AssetMantle/modules/helpers/base" - storeTypes "github.com/cosmos/cosmos-sdk/store/types" - govTypes "github.com/cosmos/cosmos-sdk/x/gov/types" - "github.com/AssetMantle/modules/helpers" + baseHelpers "github.com/AssetMantle/modules/helpers/base" errorConstants "github.com/AssetMantle/modules/helpers/constants" "github.com/AssetMantle/modules/utilities/random" "github.com/AssetMantle/modules/x/assets/constants" @@ -31,12 +28,14 @@ import ( "github.com/cometbft/cometbft/libs/log" protoTendermintTypes "github.com/cometbft/cometbft/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/store" + storeTypes "github.com/cosmos/cosmos-sdk/store/types" sdkTypes "github.com/cosmos/cosmos-sdk/types" sdkErrors "github.com/cosmos/cosmos-sdk/types/errors" authKeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" authTypes "github.com/cosmos/cosmos-sdk/x/auth/types" bankKeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" bankTypes "github.com/cosmos/cosmos-sdk/x/bank/types" + govTypes "github.com/cosmos/cosmos-sdk/x/gov/types" paramsKeeper "github.com/cosmos/cosmos-sdk/x/params/keeper" paramsTypes "github.com/cosmos/cosmos-sdk/x/params/types" "github.com/stretchr/testify/mock" diff --git a/x/assets/transactions/unwrap/transaction_request.go b/x/assets/transactions/unwrap/transaction_request.go index 73b5377bc..4b9f4c2e7 100644 --- a/x/assets/transactions/unwrap/transaction_request.go +++ b/x/assets/transactions/unwrap/transaction_request.go @@ -5,23 +5,21 @@ package unwrap import ( "encoding/json" - "github.com/AssetMantle/modules/utilities/rest" - - codecUtilities "github.com/AssetMantle/schema/codec/utilities" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" "github.com/cosmos/cosmos-sdk/client" - sdkCodec "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" + "io" + "net/http" "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/helpers/constants" ) type transactionRequest struct { - BaseReq rest.BaseReq `json:"baseReq"` - FromID string `json:"fromID"` - Coins string `json:"coins"` + helpers.CommonTransactionRequest `json:"commonTransactionRequest"` + FromID string `json:"fromID"` + Coins string `json:"coins"` } var _ helpers.TransactionRequest = (*transactionRequest)(nil) @@ -47,23 +45,28 @@ func (transactionRequest transactionRequest) Validate() error { } func (transactionRequest transactionRequest) FromCLI(cliCommand helpers.CLICommand, context client.Context) (helpers.TransactionRequest, error) { return newTransactionRequest( - cliCommand.ReadBaseReq(context), + cliCommand.ReadCommonTransactionRequest(context), cliCommand.ReadString(constants.FromIdentityID), cliCommand.ReadString(constants.Coins), ), nil } -func (transactionRequest transactionRequest) FromJSON(rawMessage json.RawMessage) (helpers.TransactionRequest, error) { - if err := json.Unmarshal(rawMessage, &transactionRequest); err != nil { +func (transactionRequest transactionRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.TransactionRequest, error) { + body, err := io.ReadAll(httpRequest.Body) + if err != nil { + return nil, err + } + + if err := json.Unmarshal(body, &transactionRequest); err != nil { return nil, err } return transactionRequest, nil } -func (transactionRequest transactionRequest) GetBaseReq() rest.BaseReq { - return transactionRequest.BaseReq +func (transactionRequest transactionRequest) GetCommonTransactionRequest() helpers.CommonTransactionRequest { + return transactionRequest.CommonTransactionRequest } func (transactionRequest transactionRequest) MakeMsg() (sdkTypes.Msg, error) { - from, err := sdkTypes.AccAddressFromBech32(transactionRequest.GetBaseReq().From) + from, err := sdkTypes.AccAddressFromBech32(transactionRequest.GetCommonTransactionRequest().GetFrom()) if err != nil { return nil, err } @@ -84,16 +87,13 @@ func (transactionRequest transactionRequest) MakeMsg() (sdkTypes.Msg, error) { coins, ), nil } -func (transactionRequest) RegisterLegacyAminoCodec(legacyAmino *sdkCodec.LegacyAmino) { - codecUtilities.RegisterModuleConcrete(legacyAmino, transactionRequest{}) -} func requestPrototype() helpers.TransactionRequest { return transactionRequest{} } -func newTransactionRequest(baseReq rest.BaseReq, fromID string, coins string) helpers.TransactionRequest { +func newTransactionRequest(commonTransactionRequest helpers.CommonTransactionRequest, fromID string, coins string) helpers.TransactionRequest { return transactionRequest{ - BaseReq: baseReq, - FromID: fromID, - Coins: coins, + CommonTransactionRequest: commonTransactionRequest, + FromID: fromID, + Coins: coins, } } diff --git a/x/assets/transactions/unwrap/transaction_request_test.go b/x/assets/transactions/unwrap/transaction_request_test.go index 968d221fb..835f858bf 100644 --- a/x/assets/transactions/unwrap/transaction_request_test.go +++ b/x/assets/transactions/unwrap/transaction_request_test.go @@ -4,12 +4,10 @@ package unwrap import ( - "encoding/json" "fmt" "github.com/AssetMantle/modules/helpers" - "github.com/AssetMantle/modules/helpers/base" + baseHelpers "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/helpers/constants" - "github.com/AssetMantle/modules/utilities/rest" baseData "github.com/AssetMantle/schema/data/base" baseDocuments "github.com/AssetMantle/schema/documents/base" baseIDs "github.com/AssetMantle/schema/ids/base" @@ -17,46 +15,43 @@ import ( baseProperties "github.com/AssetMantle/schema/properties/base" baseQualified "github.com/AssetMantle/schema/qualified/base" "github.com/cosmos/cosmos-sdk/client" - sdkCodec "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/types" - "github.com/spf13/viper" - "github.com/stretchr/testify/require" "reflect" "testing" ) var ( - fromAddress = "cosmos1pkkayn066msg6kn33wnl5srhdt3tnu2vzasz9c" - fromAccAddress, _ = types.AccAddressFromBech32(fromAddress) - testBaseRequest = rest.BaseReq{From: fromAddress, ChainID: "test", Fees: types.NewCoins()} - immutables = baseQualified.NewImmutables(baseLists.NewPropertyList(baseProperties.NewMetaProperty(baseIDs.NewStringID("ID1"), baseData.NewStringData("ImmutableData")))) - mutables = baseQualified.NewMutables(baseLists.NewPropertyList(baseProperties.NewMetaProperty(baseIDs.NewStringID("authentication"), baseData.NewListData()))) - classificationID = baseIDs.NewClassificationID(immutables, mutables) - fromID = baseIDs.NewIdentityID(classificationID, immutables).(*baseIDs.IdentityID) - coinAsset = baseDocuments.NewCoinAsset("stake") - testRate = types.NewInt(100) - assetID = coinAsset.GetCoinAssetID().(*baseIDs.AssetID) - coin = types.NewCoin(coinAsset.GetDenom(), testRate) - coins = types.NewCoins(coin) + fromAddress = "cosmos1pkkayn066msg6kn33wnl5srhdt3tnu2vzasz9c" + fromAccAddress, _ = types.AccAddressFromBech32(fromAddress) + commonTransactionRequest = helpers.PrototypeCommonTransactionRequest() + immutables = baseQualified.NewImmutables(baseLists.NewPropertyList(baseProperties.NewMetaProperty(baseIDs.NewStringID("ID1"), baseData.NewStringData("ImmutableData")))) + mutables = baseQualified.NewMutables(baseLists.NewPropertyList(baseProperties.NewMetaProperty(baseIDs.NewStringID("authentication"), baseData.NewListData()))) + classificationID = baseIDs.NewClassificationID(immutables, mutables) + fromID = baseIDs.NewIdentityID(classificationID, immutables).(*baseIDs.IdentityID) + coinAsset = baseDocuments.NewCoinAsset("stake") + testRate = types.NewInt(100) + assetID = coinAsset.GetCoinAssetID().(*baseIDs.AssetID) + coin = types.NewCoin(coinAsset.GetDenom(), testRate) + coins = types.NewCoins(coin) ) func Test_newTransactionRequest(t *testing.T) { type args struct { - baseReq rest.BaseReq - fromID string - Coins string + commonTransactionRequest helpers.CommonTransactionRequest + fromID string + Coins string } tests := []struct { name string args args want helpers.TransactionRequest }{ - {"+ve", args{testBaseRequest, fromID.AsString(), coins.String()}, transactionRequest{testBaseRequest, fromID.AsString(), coins.String()}}, + {"+ve", args{commonTransactionRequest, fromID.AsString(), coins.String()}, transactionRequest{commonTransactionRequest, fromID.AsString(), coins.String()}}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - if got := newTransactionRequest(tt.args.baseReq, tt.args.fromID, tt.args.Coins); !reflect.DeepEqual(got, tt.want) { + if got := newTransactionRequest(tt.args.commonTransactionRequest, tt.args.fromID, tt.args.Coins); !reflect.DeepEqual(got, tt.want) { t.Errorf("newTransactionRequest() = %v, want %v", got, tt.want) } }) @@ -80,15 +75,15 @@ func Test_requestPrototype(t *testing.T) { } func Test_transactionRequest_FromCLI(t *testing.T) { - cliCommand := base.NewCLICommand("", "", "", []helpers.CLIFlag{constants.AssetID, constants.FromIdentityID, constants.Value}) + cliCommand := baseHelpers.NewCLICommand("", "", "", []helpers.CLIFlag{constants.AssetID, constants.FromIdentityID, constants.Value}) viper.Set(constants.FromIdentityID.GetName(), fromID.AsString()) viper.Set(constants.AssetID.GetName(), assetID.AsString()) viper.Set(constants.Value.GetName(), testRate.String()) type fields struct { - BaseReq rest.BaseReq - FromID string - Coins string + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + Coins string } type args struct { cliCommand helpers.CLICommand @@ -101,14 +96,14 @@ func Test_transactionRequest_FromCLI(t *testing.T) { want helpers.TransactionRequest wantErr bool }{ - {"+ve", fields{testBaseRequest, fromID.AsString(), coins.String()}, args{cliCommand, client.Context{}.WithCodec(base.CodecPrototype())}, transactionRequest{testBaseRequest, fromID.AsString(), coins.String()}, false}, + {"+ve", fields{commonTransactionRequest, fromID.AsString(), coins.String()}, args{cliCommand, client.Context{}.WithCodec(baseHelpers.CodecPrototype())}, transactionRequest{commonTransactionRequest, fromID.AsString(), coins.String()}, false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - Coins: tt.fields.Coins, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + Coins: tt.fields.Coins, } got, err := transactionRequest.FromCLI(tt.args.cliCommand, tt.args.context) if (err != nil) != tt.wantErr { @@ -122,67 +117,28 @@ func Test_transactionRequest_FromCLI(t *testing.T) { } } -func Test_transactionRequest_FromJSON(t *testing.T) { - jsonMessage, err := json.Marshal(newTransactionRequest(testBaseRequest, fromID.AsString(), coins.String())) - require.NoError(t, err) - type fields struct { - BaseReq rest.BaseReq - FromID string - Coins string - } - type args struct { - rawMessage json.RawMessage - } - tests := []struct { - name string - fields fields - args args - want helpers.TransactionRequest - wantErr bool - }{ - {"+ve", fields{testBaseRequest, fromID.AsString(), coins.String()}, args{jsonMessage}, newTransactionRequest(testBaseRequest, fromID.AsString(), coins.String()), false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - Coins: tt.fields.Coins, - } - got, err := transactionRequest.FromJSON(tt.args.rawMessage) - if (err != nil) != tt.wantErr { - t.Errorf("FromJSON() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("FromJSON() got = %v, want %v", got, tt.want) - } - }) - } -} - func Test_transactionRequest_GetBaseReq(t *testing.T) { type fields struct { - BaseReq rest.BaseReq - FromID string - Coins string + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + Coins string } tests := []struct { name string fields fields - want rest.BaseReq + want helpers.CommonTransactionRequest }{ - {"+ve", fields{testBaseRequest, fromID.AsString(), coins.String()}, testBaseRequest}, + {"+ve", fields{commonTransactionRequest, fromID.AsString(), coins.String()}, commonTransactionRequest}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - Coins: tt.fields.Coins, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + Coins: tt.fields.Coins, } - if got := transactionRequest.GetBaseReq(); !reflect.DeepEqual(got, tt.want) { - t.Errorf("GetBaseReq() = %v, want %v", got, tt.want) + if got := transactionRequest.GetCommonTransactionRequest(); !reflect.DeepEqual(got, tt.want) { + t.Errorf("GetCommonTransactionRequest() = %v, want %v", got, tt.want) } }) } @@ -190,9 +146,9 @@ func Test_transactionRequest_GetBaseReq(t *testing.T) { func Test_transactionRequest_MakeMsg(t *testing.T) { type fields struct { - BaseReq rest.BaseReq - FromID string - Coins string + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + Coins string } tests := []struct { name string @@ -200,14 +156,14 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { want types.Msg wantErr bool }{ - {"+ve", fields{testBaseRequest, fromID.AsString(), coins.String()}, NewMessage(fromAccAddress, fromID, coins), false}, + {"+ve", fields{commonTransactionRequest, fromID.AsString(), coins.String()}, NewMessage(fromAccAddress, fromID, coins), false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - Coins: tt.fields.Coins, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + Coins: tt.fields.Coins, } got, err := transactionRequest.MakeMsg() if (err != nil) != tt.wantErr { @@ -221,53 +177,25 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { } } -func Test_transactionRequest_RegisterCodec(t *testing.T) { - type fields struct { - BaseReq rest.BaseReq - FromID string - Coins string - } - type args struct { - legacyAmino *sdkCodec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{testBaseRequest, fromID.AsString(), coins.String()}, args{codec.GetLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - tr := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - Coins: tt.fields.Coins, - } - tr.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - func Test_transactionRequest_Validate(t *testing.T) { type fields struct { - BaseReq rest.BaseReq - FromID string - Coins string + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + Coins string } tests := []struct { name string fields fields wantErr bool }{ - {"+ve", fields{testBaseRequest, fromID.AsString(), coins.String()}, false}, + {"+ve", fields{commonTransactionRequest, fromID.AsString(), coins.String()}, false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - Coins: tt.fields.Coins, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + Coins: tt.fields.Coins, } if err := transactionRequest.Validate(); (err != nil) != tt.wantErr { t.Errorf("ValidateBasic() error = %v, wantErr %v", err, tt.wantErr) diff --git a/x/assets/transactions/unwrap/transaction_response.go b/x/assets/transactions/unwrap/transaction_response.go index b1090862f..6e1187835 100644 --- a/x/assets/transactions/unwrap/transaction_response.go +++ b/x/assets/transactions/unwrap/transaction_response.go @@ -4,9 +4,8 @@ package unwrap import ( - sdkTypes "github.com/cosmos/cosmos-sdk/types" - "github.com/AssetMantle/modules/helpers" + sdkTypes "github.com/cosmos/cosmos-sdk/types" ) var _ helpers.TransactionResponse = (*TransactionResponse)(nil) diff --git a/x/assets/transactions/wrap/message.go b/x/assets/transactions/wrap/message.go index f89e645b5..21128345c 100644 --- a/x/assets/transactions/wrap/message.go +++ b/x/assets/transactions/wrap/message.go @@ -4,28 +4,17 @@ package wrap import ( + "github.com/AssetMantle/modules/helpers" errorConstants "github.com/AssetMantle/modules/helpers/constants" "github.com/AssetMantle/modules/x/assets/constants" - codecUtilities "github.com/AssetMantle/schema/codec/utilities" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" - sdkCodec "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/types" sdkTypes "github.com/cosmos/cosmos-sdk/types" - - "github.com/AssetMantle/modules/helpers" ) var _ helpers.Message = (*Message)(nil) -func (message *Message) Type() string { return Transaction.GetName() } -func (message *Message) GetFromAddress() sdkTypes.AccAddress { - from, err := sdkTypes.AccAddressFromBech32(message.From) - if err != nil { - panic(err) - } - return from -} func (message *Message) ValidateBasic() error { if _, err := sdkTypes.AccAddressFromBech32(message.From); err != nil { return errorConstants.InvalidMessage.Wrapf("invalid from address %s", err.Error()) @@ -48,21 +37,10 @@ func (message *Message) GetSigners() []sdkTypes.AccAddress { } return []sdkTypes.AccAddress{from} } -func (*Message) RegisterLegacyAminoCodec(legacyAmino *sdkCodec.LegacyAmino) { - codecUtilities.RegisterModuleConcrete(legacyAmino, Message{}) -} func (message *Message) RegisterInterface(interfaceRegistry types.InterfaceRegistry) { interfaceRegistry.RegisterImplementations((*sdkTypes.Msg)(nil), message) } -func messageFromInterface(msg sdkTypes.Msg) *Message { - switch value := msg.(type) { - case *Message: - return value - default: - return &Message{} - } -} func messagePrototype() helpers.Message { return &Message{} } diff --git a/x/assets/transactions/wrap/message_test.go b/x/assets/transactions/wrap/message_test.go index f6938098e..0f7a9cf9b 100644 --- a/x/assets/transactions/wrap/message_test.go +++ b/x/assets/transactions/wrap/message_test.go @@ -11,7 +11,6 @@ import ( "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" - sdkCodec "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/types" "github.com/AssetMantle/modules/helpers" @@ -146,26 +145,6 @@ func TestMessage_ValidateBasic(t *testing.T) { } } -func Test_messageFromInterface(t *testing.T) { - type args struct { - msg helpers.Message - } - tests := []struct { - name string - args args - want *Message - }{ - {"+ve", args{NewMessage(fromAccAddress, fromID, coins).(*Message)}, &Message{fromAccAddress.String(), fromID, coins}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := messageFromInterface(tt.args.msg); !reflect.DeepEqual(got, tt.want) { - t.Errorf("messageFromInterface() = %v, want %v", got, tt.want) - } - }) - } -} - func Test_messagePrototype(t *testing.T) { tests := []struct { name string @@ -209,61 +188,6 @@ func Test_message_GetSigners(t *testing.T) { } } -func Test_message_RegisterCodec(t *testing.T) { - type fields struct { - From string - FromID *baseIDs.IdentityID - Coins types.Coins - } - type args struct { - legacyAmino *sdkCodec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{fromAccAddress.String(), fromID, coins}, args{codec.GetLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - me := &Message{ - From: tt.fields.From, - FromID: tt.fields.FromID, - Coins: tt.fields.Coins, - } - me.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - -func Test_message_Type(t *testing.T) { - type fields struct { - From string - FromID *baseIDs.IdentityID - Coins types.Coins - } - tests := []struct { - name string - fields fields - want string - }{ - {"+ve", fields{fromAccAddress.String(), fromID, coins}, Transaction.GetName()}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - message := &Message{ - From: tt.fields.From, - FromID: tt.fields.FromID, - Coins: tt.fields.Coins, - } - if got := message.Type(); got != tt.want { - t.Errorf("Type() = %v, want %v", got, tt.want) - } - }) - } -} - func Test_NewMessage(t *testing.T) { type args struct { from types.AccAddress diff --git a/x/assets/transactions/wrap/service.pb.go b/x/assets/transactions/wrap/service.pb.go index 5d1c1fed9..ebee5a55c 100644 --- a/x/assets/transactions/wrap/service.pb.go +++ b/x/assets/transactions/wrap/service.pb.go @@ -6,9 +6,9 @@ package wrap import ( context "context" fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types/msgservice" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" - _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -31,30 +31,29 @@ func init() { } var fileDescriptor_ccaf91d5b35dd610 = []byte{ - // 359 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0xd2, 0x31, 0x4b, 0xeb, 0x50, - 0x14, 0x07, 0xf0, 0x26, 0x0f, 0x3a, 0x84, 0x37, 0xf5, 0xf1, 0x96, 0xbc, 0x47, 0x86, 0x7e, 0x80, - 0x7b, 0xa1, 0x1d, 0xc4, 0x8b, 0x4b, 0xeb, 0xa0, 0x0e, 0x81, 0xa2, 0x85, 0x06, 0x09, 0xc8, 0x69, - 0x7a, 0x89, 0x81, 0x24, 0x37, 0xe4, 0xdc, 0x6a, 0x67, 0x3f, 0x81, 0xe0, 0x37, 0xd0, 0x4d, 0xbf, - 0x88, 0x38, 0x15, 0x5c, 0x1c, 0x25, 0x75, 0x72, 0x77, 0x97, 0xf4, 0x5e, 0xf0, 0x76, 0xbc, 0xeb, - 0x09, 0xbf, 0x7f, 0xfe, 0xe7, 0x24, 0xde, 0xc1, 0x08, 0x91, 0xcb, 0x10, 0x4a, 0x99, 0x73, 0x5a, - 0x88, 0xc5, 0x32, 0xe7, 0x48, 0x57, 0x14, 0xda, 0x29, 0x52, 0x59, 0x43, 0x89, 0x90, 0xc8, 0x4c, - 0x94, 0x48, 0xaf, 0x6b, 0xa8, 0x28, 0xf2, 0xfa, 0x2a, 0x4b, 0x38, 0xa9, 0x6a, 0x21, 0x45, 0x8f, - 0x18, 0x9a, 0x68, 0x4d, 0x56, 0x44, 0x69, 0x62, 0x6a, 0xd2, 0x6a, 0xff, 0x7f, 0x2a, 0x44, 0x9a, - 0x73, 0x0a, 0x55, 0x46, 0xa1, 0x2c, 0x85, 0x04, 0xf5, 0x70, 0x9b, 0xe6, 0xdb, 0x76, 0x29, 0x38, - 0x22, 0xa4, 0xba, 0x8b, 0x7f, 0x62, 0xa9, 0x8d, 0xc9, 0x45, 0xcd, 0xb1, 0x12, 0x25, 0xea, 0xa8, - 0xc1, 0x93, 0xe3, 0xfd, 0x0a, 0x31, 0xed, 0x3d, 0x38, 0x5e, 0xf7, 0x18, 0xca, 0x45, 0xce, 0x7b, - 0x7b, 0x96, 0xab, 0x92, 0x50, 0x95, 0xf3, 0x0f, 0x6d, 0xe1, 0xf4, 0x67, 0x72, 0xaa, 0x6b, 0xf5, - 0xff, 0xdd, 0xbc, 0x7e, 0xdc, 0xb9, 0x7f, 0xfb, 0x7f, 0x68, 0xa1, 0xf6, 0xd3, 0x5b, 0xb5, 0x60, - 0xfc, 0xe5, 0x3e, 0x37, 0x81, 0xb3, 0x6e, 0x02, 0xe7, 0xbd, 0x09, 0x9c, 0xdb, 0x4d, 0xd0, 0x59, - 0x6f, 0x82, 0xce, 0xdb, 0x26, 0xe8, 0x78, 0x83, 0x44, 0x14, 0x96, 0xef, 0x1f, 0xff, 0x3e, 0x53, - 0x9f, 0x78, 0xd2, 0x9e, 0x62, 0xe2, 0x9c, 0xef, 0xa7, 0x99, 0xbc, 0x5c, 0xce, 0x49, 0x22, 0x0a, - 0x6a, 0x77, 0xe2, 0x7b, 0xb7, 0x3b, 0x0a, 0xa3, 0xd1, 0x74, 0xf6, 0xe8, 0xee, 0x94, 0x08, 0x75, - 0x89, 0x48, 0x4d, 0xd1, 0x5c, 0x19, 0xc9, 0xac, 0x86, 0xea, 0x65, 0x07, 0xc4, 0x1a, 0xc4, 0x51, - 0xac, 0x40, 0x6c, 0x82, 0xb8, 0x05, 0x8d, 0xcb, 0xec, 0x40, 0x7c, 0x34, 0x19, 0x87, 0x5c, 0xc2, - 0x02, 0x24, 0x7c, 0xba, 0x43, 0x03, 0x33, 0xa6, 0x35, 0x63, 0x11, 0x53, 0xa9, 0xc8, 0x98, 0x19, - 0xc0, 0x58, 0x9b, 0x30, 0xef, 0x6e, 0x7f, 0x96, 0xe1, 0x77, 0x00, 0x00, 0x00, 0xff, 0xff, 0x48, - 0x5a, 0x3a, 0xb2, 0x43, 0x03, 0x00, 0x00, + // 346 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0xd2, 0xb1, 0x4b, 0xf3, 0x40, + 0x18, 0x06, 0xf0, 0x5c, 0x3e, 0xbe, 0x0e, 0xc1, 0xa9, 0x8b, 0x90, 0x21, 0x83, 0xa3, 0xc3, 0x1d, + 0xb6, 0x83, 0x78, 0xb8, 0xb4, 0x0e, 0xea, 0x10, 0x28, 0x5a, 0x68, 0x90, 0x80, 0x5c, 0xd3, 0x23, + 0x16, 0x9a, 0x5c, 0xc8, 0x7b, 0xad, 0x1d, 0x1d, 0x1d, 0xdd, 0xdc, 0x1d, 0x9d, 0xfc, 0x33, 0xc4, + 0xa9, 0xa3, 0xa3, 0x24, 0x83, 0xe0, 0xee, 0x2e, 0xe7, 0x1d, 0x78, 0x1d, 0x6f, 0x0a, 0xbc, 0xf0, + 0x7b, 0xf2, 0xbc, 0x77, 0x17, 0x1c, 0x0f, 0x00, 0xb8, 0x8c, 0x59, 0x29, 0x17, 0x9c, 0x14, 0x62, + 0xb6, 0x5c, 0x70, 0x20, 0x6b, 0xc2, 0xd4, 0x14, 0x88, 0xac, 0x59, 0x09, 0x2c, 0x93, 0x73, 0x51, + 0x02, 0xb9, 0xad, 0x59, 0x45, 0x80, 0xd7, 0xab, 0x79, 0xc6, 0x71, 0x55, 0x0b, 0x29, 0xba, 0xd8, + 0xd2, 0xd8, 0x68, 0xbc, 0xc6, 0x5a, 0x63, 0x5b, 0x63, 0xa5, 0xc3, 0xdd, 0x4c, 0x40, 0x21, 0x80, + 0x14, 0x90, 0x93, 0xd5, 0x81, 0xfa, 0xe8, 0xa0, 0xd0, 0xb5, 0x46, 0xc1, 0x01, 0x58, 0x6e, 0x6a, + 0x84, 0xe7, 0x8e, 0xda, 0x9a, 0x5c, 0xd7, 0x1c, 0x2a, 0x51, 0x82, 0x89, 0xea, 0x3d, 0xa2, 0xe0, + 0x5f, 0x0c, 0x79, 0xf7, 0x1e, 0x05, 0x9d, 0x33, 0x56, 0xce, 0x16, 0xbc, 0x7b, 0xe8, 0xb8, 0x25, + 0x8e, 0x75, 0xb9, 0xf0, 0xc4, 0x15, 0x8e, 0xff, 0x26, 0x17, 0xa6, 0xd6, 0x9e, 0x17, 0xfe, 0xbf, + 0xfb, 0x7c, 0xd9, 0x47, 0xc3, 0x6f, 0xff, 0xb5, 0x89, 0xd0, 0xa6, 0x89, 0xd0, 0x47, 0x13, 0xa1, + 0x87, 0x36, 0xf2, 0x36, 0x6d, 0xe4, 0xbd, 0xb7, 0x91, 0x17, 0xf4, 0x32, 0x51, 0x38, 0xfe, 0x6b, + 0xb8, 0x73, 0xa9, 0x6f, 0x72, 0xa4, 0xd6, 0x1e, 0xa1, 0xab, 0xa3, 0x7c, 0x2e, 0x6f, 0x96, 0x53, + 0x9c, 0x89, 0x82, 0xb8, 0x1d, 0xe7, 0x93, 0xdf, 0x19, 0xc4, 0xc9, 0x60, 0x3c, 0x79, 0xf6, 0xb7, + 0x4a, 0xc4, 0xa6, 0x44, 0xa2, 0xa7, 0x60, 0xaf, 0x07, 0x78, 0x52, 0xb3, 0xea, 0x6d, 0x0b, 0xa4, + 0x06, 0xa4, 0x49, 0xaa, 0x41, 0x6a, 0x83, 0x54, 0x81, 0xc6, 0xa7, 0x6e, 0x20, 0x3d, 0x1d, 0x0d, + 0x63, 0x2e, 0xd9, 0x8c, 0x49, 0xf6, 0xe5, 0xf7, 0x2d, 0x4c, 0xa9, 0xd1, 0x94, 0x26, 0x54, 0xa7, + 0x02, 0xa5, 0x76, 0x00, 0xa5, 0x2a, 0x61, 0xda, 0xf9, 0x7d, 0x18, 0xfd, 0x9f, 0x00, 0x00, 0x00, + 0xff, 0xff, 0x9b, 0x20, 0x68, 0x98, 0x2a, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/assets/transactions/wrap/service.pb.gw.go b/x/assets/transactions/wrap/service.pb.gw.go deleted file mode 100644 index dd59a9ee2..000000000 --- a/x/assets/transactions/wrap/service.pb.gw.go +++ /dev/null @@ -1,171 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: AssetMantle/modules/x/assets/transactions/wrap/service.proto - -/* -Package wrap is a reverse proxy. - -It translates gRPC into RESTful JSON APIs. -*/ -package wrap - -import ( - "context" - "io" - "net/http" - - "github.com/golang/protobuf/descriptor" - "github.com/golang/protobuf/proto" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/grpc-ecosystem/grpc-gateway/utilities" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/status" -) - -// Suppress "imported and not used" errors -var _ codes.Code -var _ io.Reader -var _ status.Status -var _ = runtime.String -var _ = utilities.NewDoubleArray -var _ = descriptor.ForMessage -var _ = metadata.Join - -var ( - filter_Msg_Handle_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - -func request_Msg_Handle_0(ctx context.Context, marshaler runtime.Marshaler, client MsgClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq Message - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.Handle(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Msg_Handle_0(ctx context.Context, marshaler runtime.Marshaler, server MsgServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq Message - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.Handle(ctx, &protoReq) - return msg, metadata, err - -} - -// RegisterMsgHandlerServer registers the http handlers for service Msg to "mux". -// UnaryRPC :call MsgServer directly. -// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterMsgHandlerFromEndpoint instead. -func RegisterMsgHandlerServer(ctx context.Context, mux *runtime.ServeMux, server MsgServer) error { - - mux.Handle("POST", pattern_Msg_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Msg_Handle_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Msg_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -// RegisterMsgHandlerFromEndpoint is same as RegisterMsgHandler but -// automatically dials to "endpoint" and closes the connection when "ctx" gets done. -func RegisterMsgHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.Dial(endpoint, opts...) - if err != nil { - return err - } - defer func() { - if err != nil { - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - return - } - go func() { - <-ctx.Done() - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - }() - }() - - return RegisterMsgHandler(ctx, mux, conn) -} - -// RegisterMsgHandler registers the http handlers for service Msg to "mux". -// The handlers forward requests to the grpc endpoint over "conn". -func RegisterMsgHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { - return RegisterMsgHandlerClient(ctx, mux, NewMsgClient(conn)) -} - -// RegisterMsgHandlerClient registers the http handlers for service Msg -// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "MsgClient". -// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "MsgClient" -// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "MsgClient" to call the correct interceptors. -func RegisterMsgHandlerClient(ctx context.Context, mux *runtime.ServeMux, client MsgClient) error { - - mux.Handle("POST", pattern_Msg_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Msg_Handle_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Msg_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -var ( - pattern_Msg_Handle_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"mantle", "assets", "wrap"}, "", runtime.AssumeColonVerbOpt(false))) -) - -var ( - forward_Msg_Handle_0 = runtime.ForwardResponseMessage -) diff --git a/x/assets/transactions/wrap/transaction.go b/x/assets/transactions/wrap/transaction.go index 0e2999331..1aa978b1e 100644 --- a/x/assets/transactions/wrap/transaction.go +++ b/x/assets/transactions/wrap/transaction.go @@ -4,22 +4,14 @@ package wrap import ( - "context" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "google.golang.org/grpc" - "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/helpers/constants" - "github.com/AssetMantle/modules/utilities/name" + "google.golang.org/grpc" ) -type dummy struct{} - var Transaction = baseHelpers.NewTransaction( - name.GetPackageName(dummy{}), + _Msg_serviceDesc.ServiceName, "", "", @@ -30,9 +22,6 @@ var Transaction = baseHelpers.NewTransaction( func(server grpc.ServiceRegistrar, keeper helpers.TransactionKeeper) { RegisterMsgServer(server, keeper.(transactionKeeper)) }, - func(clientCtx client.Context, mux *runtime.ServeMux) error { - return RegisterMsgHandlerClient(context.Background(), mux, NewMsgClient(clientCtx)) - }, constants.FromIdentityID, constants.Coins, diff --git a/x/assets/transactions/wrap/transaction_keeper.go b/x/assets/transactions/wrap/transaction_keeper.go index 0d28120ab..00bd7e0e5 100644 --- a/x/assets/transactions/wrap/transaction_keeper.go +++ b/x/assets/transactions/wrap/transaction_keeper.go @@ -60,7 +60,7 @@ func (transactionKeeper transactionKeeper) Transact(context context.Context, mes // // 4. If the process completes successfully for all coins, it returns a new transaction response object. func (transactionKeeper transactionKeeper) Handle(context context.Context, message *Message) (*TransactionResponse, error) { - if _, err := transactionKeeper.authenticateAuxiliary.GetKeeper().Help(context, authenticate.NewAuxiliaryRequest(message.GetFromAddress(), message.FromID)); err != nil { + if _, err := transactionKeeper.authenticateAuxiliary.GetKeeper().Help(context, authenticate.NewAuxiliaryRequest(message.GetSigners()[0], message.FromID)); err != nil { return nil, err } @@ -89,7 +89,7 @@ func (transactionKeeper transactionKeeper) Handle(context context.Context, messa assets.Add(record.NewRecord(coinAsset)) } - if err := transactionKeeper.bankKeeper.SendCoinsFromAccountToModule(sdkTypes.UnwrapSDKContext(context), message.GetFromAddress(), constants.ModuleName, sdkTypes.NewCoins(coin)); err != nil { + if err := transactionKeeper.bankKeeper.SendCoinsFromAccountToModule(sdkTypes.UnwrapSDKContext(context), message.GetSigners()[0], constants.ModuleName, sdkTypes.NewCoins(coin)); err != nil { return nil, err } } diff --git a/x/assets/transactions/wrap/transaction_request.go b/x/assets/transactions/wrap/transaction_request.go index 921444d11..9eff6956a 100644 --- a/x/assets/transactions/wrap/transaction_request.go +++ b/x/assets/transactions/wrap/transaction_request.go @@ -5,23 +5,21 @@ package wrap import ( "encoding/json" - "github.com/AssetMantle/modules/utilities/rest" - - codecUtilities "github.com/AssetMantle/schema/codec/utilities" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" "github.com/cosmos/cosmos-sdk/client" - sdkCodec "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" + "io" + "net/http" "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/helpers/constants" ) type transactionRequest struct { - BaseReq rest.BaseReq `json:"baseReq"` - FromID string `json:"fromID"` - Coins string `json:"coins"` + helpers.CommonTransactionRequest `json:"commonTransactionRequest"` + FromID string `json:"fromID"` + Coins string `json:"coins"` } var _ helpers.TransactionRequest = (*transactionRequest)(nil) @@ -47,23 +45,28 @@ func (transactionRequest transactionRequest) Validate() error { } func (transactionRequest transactionRequest) FromCLI(cliCommand helpers.CLICommand, context client.Context) (helpers.TransactionRequest, error) { return newTransactionRequest( - cliCommand.ReadBaseReq(context), + cliCommand.ReadCommonTransactionRequest(context), cliCommand.ReadString(constants.FromIdentityID), cliCommand.ReadString(constants.Coins), ), nil } -func (transactionRequest transactionRequest) FromJSON(rawMessage json.RawMessage) (helpers.TransactionRequest, error) { - if err := json.Unmarshal(rawMessage, &transactionRequest); err != nil { +func (transactionRequest transactionRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.TransactionRequest, error) { + body, err := io.ReadAll(httpRequest.Body) + if err != nil { + return nil, err + } + + if err := json.Unmarshal(body, &transactionRequest); err != nil { return nil, err } return transactionRequest, nil } -func (transactionRequest transactionRequest) GetBaseReq() rest.BaseReq { - return transactionRequest.BaseReq +func (transactionRequest transactionRequest) GetCommonTransactionRequest() helpers.CommonTransactionRequest { + return transactionRequest.CommonTransactionRequest } func (transactionRequest transactionRequest) MakeMsg() (sdkTypes.Msg, error) { - from, err := sdkTypes.AccAddressFromBech32(transactionRequest.GetBaseReq().From) + from, err := sdkTypes.AccAddressFromBech32(transactionRequest.GetCommonTransactionRequest().GetFrom()) if err != nil { return nil, err } @@ -84,16 +87,13 @@ func (transactionRequest transactionRequest) MakeMsg() (sdkTypes.Msg, error) { coins, ), nil } -func (transactionRequest) RegisterLegacyAminoCodec(legacyAmino *sdkCodec.LegacyAmino) { - codecUtilities.RegisterModuleConcrete(legacyAmino, transactionRequest{}) -} func requestPrototype() helpers.TransactionRequest { return transactionRequest{} } -func newTransactionRequest(baseReq rest.BaseReq, fromID string, coins string) helpers.TransactionRequest { +func newTransactionRequest(commonTransactionRequest helpers.CommonTransactionRequest, fromID string, coins string) helpers.TransactionRequest { return transactionRequest{ - BaseReq: baseReq, - FromID: fromID, - Coins: coins, + CommonTransactionRequest: commonTransactionRequest, + FromID: fromID, + Coins: coins, } } diff --git a/x/assets/transactions/wrap/transaction_request_test.go b/x/assets/transactions/wrap/transaction_request_test.go index 40fdedbf9..4a1493820 100644 --- a/x/assets/transactions/wrap/transaction_request_test.go +++ b/x/assets/transactions/wrap/transaction_request_test.go @@ -4,56 +4,51 @@ package wrap import ( - "encoding/json" "fmt" - "github.com/AssetMantle/modules/utilities/rest" - sdkCodec "github.com/cosmos/cosmos-sdk/codec" - "reflect" - "testing" - baseData "github.com/AssetMantle/schema/data/base" baseIDs "github.com/AssetMantle/schema/ids/base" baseLists "github.com/AssetMantle/schema/lists/base" baseProperties "github.com/AssetMantle/schema/properties/base" baseQualified "github.com/AssetMantle/schema/qualified/base" + "reflect" + "testing" + "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/types" - "github.com/spf13/viper" - "github.com/stretchr/testify/require" - "github.com/AssetMantle/modules/helpers" - "github.com/AssetMantle/modules/helpers/base" + baseHelpers "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/helpers/constants" + "github.com/spf13/viper" ) var ( - fromAddress = "cosmos1pkkayn066msg6kn33wnl5srhdt3tnu2vzasz9c" - fromAccAddress, _ = types.AccAddressFromBech32(fromAddress) - testBaseRequest = rest.BaseReq{From: fromAddress, ChainID: "test", Fees: types.NewCoins()} - immutables = baseQualified.NewImmutables(baseLists.NewPropertyList(baseProperties.NewMetaProperty(baseIDs.NewStringID("ID1"), baseData.NewStringData("ImmutableData")))) - mutables = baseQualified.NewMutables(baseLists.NewPropertyList(baseProperties.NewMetaProperty(baseIDs.NewStringID("authentication"), baseData.NewListData()))) - classificationID = baseIDs.NewClassificationID(immutables, mutables).(*baseIDs.ClassificationID) - fromID = baseIDs.NewIdentityID(classificationID, immutables).(*baseIDs.IdentityID) - coins = types.NewCoins(types.NewCoin("stake", types.NewInt(100))) + fromAddress = "cosmos1pkkayn066msg6kn33wnl5srhdt3tnu2vzasz9c" + fromAccAddress, _ = types.AccAddressFromBech32(fromAddress) + commonTransactionRequest = helpers.PrototypeCommonTransactionRequest() + immutables = baseQualified.NewImmutables(baseLists.NewPropertyList(baseProperties.NewMetaProperty(baseIDs.NewStringID("ID1"), baseData.NewStringData("ImmutableData")))) + mutables = baseQualified.NewMutables(baseLists.NewPropertyList(baseProperties.NewMetaProperty(baseIDs.NewStringID("authentication"), baseData.NewListData()))) + classificationID = baseIDs.NewClassificationID(immutables, mutables).(*baseIDs.ClassificationID) + fromID = baseIDs.NewIdentityID(classificationID, immutables).(*baseIDs.IdentityID) + coins = types.NewCoins(types.NewCoin("stake", types.NewInt(100))) ) func Test_newTransactionRequest(t *testing.T) { type args struct { - baseReq rest.BaseReq - fromID string - coins string + commonTransactionRequest helpers.CommonTransactionRequest + fromID string + coins string } tests := []struct { name string args args want helpers.TransactionRequest }{ - {"+ve", args{testBaseRequest, fromID.AsString(), coins.String()}, transactionRequest{testBaseRequest, fromID.AsString(), coins.String()}}, + {"+ve", args{commonTransactionRequest, fromID.AsString(), coins.String()}, transactionRequest{commonTransactionRequest, fromID.AsString(), coins.String()}}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - if got := newTransactionRequest(tt.args.baseReq, tt.args.fromID, tt.args.coins); !reflect.DeepEqual(got, tt.want) { + if got := newTransactionRequest(tt.args.commonTransactionRequest, tt.args.fromID, tt.args.coins); !reflect.DeepEqual(got, tt.want) { t.Errorf("newTransactionRequest() = %v, want %v", got, tt.want) } }) @@ -77,14 +72,14 @@ func Test_requestPrototype(t *testing.T) { } func Test_transactionRequest_FromCLI(t *testing.T) { - cliCommand := base.NewCLICommand("", "", "", []helpers.CLIFlag{constants.Coins, constants.FromIdentityID}) + cliCommand := baseHelpers.NewCLICommand("", "", "", []helpers.CLIFlag{constants.Coins, constants.FromIdentityID}) viper.Set(constants.FromIdentityID.GetName(), fromID.AsString()) viper.Set(constants.Coins.GetName(), coins.String()) type fields struct { - BaseReq rest.BaseReq - FromID string - Coins string + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + Coins string } type args struct { cliCommand helpers.CLICommand @@ -97,14 +92,14 @@ func Test_transactionRequest_FromCLI(t *testing.T) { want helpers.TransactionRequest wantErr bool }{ - {"+ve", fields{testBaseRequest, fromID.AsString(), coins.String()}, args{cliCommand, client.Context{}.WithCodec(base.CodecPrototype())}, transactionRequest{testBaseRequest, fromID.AsString(), coins.String()}, false}, + {"+ve", fields{commonTransactionRequest, fromID.AsString(), coins.String()}, args{cliCommand, client.Context{}.WithCodec(baseHelpers.CodecPrototype())}, transactionRequest{commonTransactionRequest, fromID.AsString(), coins.String()}, false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - Coins: tt.fields.Coins, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + Coins: tt.fields.Coins, } got, err := transactionRequest.FromCLI(tt.args.cliCommand, tt.args.context) if (err != nil) != tt.wantErr { @@ -118,67 +113,28 @@ func Test_transactionRequest_FromCLI(t *testing.T) { } } -func Test_transactionRequest_FromJSON(t *testing.T) { - jsonMessage, err := json.Marshal(newTransactionRequest(testBaseRequest, fromID.AsString(), coins.String())) - require.NoError(t, err) - type fields struct { - BaseReq rest.BaseReq - FromID string - Coins string - } - type args struct { - rawMessage json.RawMessage - } - tests := []struct { - name string - fields fields - args args - want helpers.TransactionRequest - wantErr bool - }{ - {"+ve", fields{testBaseRequest, fromID.AsString(), coins.String()}, args{jsonMessage}, newTransactionRequest(testBaseRequest, fromID.AsString(), coins.String()), false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - Coins: tt.fields.Coins, - } - got, err := transactionRequest.FromJSON(tt.args.rawMessage) - if (err != nil) != tt.wantErr { - t.Errorf("FromJSON() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("FromJSON() got = %v, want %v", got, tt.want) - } - }) - } -} - func Test_transactionRequest_GetBaseReq(t *testing.T) { type fields struct { - BaseReq rest.BaseReq - FromID string - Coins string + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + Coins string } tests := []struct { name string fields fields - want rest.BaseReq + want helpers.CommonTransactionRequest }{ - {"+ve", fields{testBaseRequest, fromID.AsString(), coins.String()}, testBaseRequest}, + {"+ve", fields{commonTransactionRequest, fromID.AsString(), coins.String()}, commonTransactionRequest}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - Coins: tt.fields.Coins, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + Coins: tt.fields.Coins, } - if got := transactionRequest.GetBaseReq(); !reflect.DeepEqual(got, tt.want) { - t.Errorf("GetBaseReq() = %v, want %v", got, tt.want) + if got := transactionRequest.GetCommonTransactionRequest(); !reflect.DeepEqual(got, tt.want) { + t.Errorf("GetCommonTransactionRequest() = %v, want %v", got, tt.want) } }) } @@ -186,9 +142,9 @@ func Test_transactionRequest_GetBaseReq(t *testing.T) { func Test_transactionRequest_MakeMsg(t *testing.T) { type fields struct { - BaseReq rest.BaseReq - FromID string - Coins string + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + Coins string } tests := []struct { name string @@ -196,14 +152,14 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { want types.Msg wantErr bool }{ - {"+ve", fields{testBaseRequest, fromID.AsString(), coins.String()}, NewMessage(fromAccAddress, fromID, coins), false}, + {"+ve", fields{commonTransactionRequest, fromID.AsString(), coins.String()}, NewMessage(fromAccAddress, fromID, coins), false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - Coins: tt.fields.Coins, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + Coins: tt.fields.Coins, } got, err := transactionRequest.MakeMsg() if (err != nil) != tt.wantErr { @@ -217,53 +173,25 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { } } -func Test_transactionRequest_RegisterCodec(t *testing.T) { - type fields struct { - BaseReq rest.BaseReq - FromID string - Coins string - } - type args struct { - legacyAmino *sdkCodec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{testBaseRequest, fromID.AsString(), coins.String()}, args{codec.GetLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - tr := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - Coins: tt.fields.Coins, - } - tr.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - func Test_transactionRequest_Validate(t *testing.T) { type fields struct { - BaseReq rest.BaseReq - FromID string - Coins string + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + Coins string } tests := []struct { name string fields fields wantErr bool }{ - {"+ve", fields{testBaseRequest, fromID.AsString(), coins.String()}, false}, + {"+ve", fields{commonTransactionRequest, fromID.AsString(), coins.String()}, false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - Coins: tt.fields.Coins, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + Coins: tt.fields.Coins, } if err := transactionRequest.Validate(); (err != nil) != tt.wantErr { t.Errorf("ValidateBasic() error = %v, wantErr %v", err, tt.wantErr) diff --git a/x/assets/transactions/wrap/transaction_response.go b/x/assets/transactions/wrap/transaction_response.go index ddac0e69c..43ae7add5 100644 --- a/x/assets/transactions/wrap/transaction_response.go +++ b/x/assets/transactions/wrap/transaction_response.go @@ -4,9 +4,8 @@ package wrap import ( - sdkTypes "github.com/cosmos/cosmos-sdk/types" - "github.com/AssetMantle/modules/helpers" + sdkTypes "github.com/cosmos/cosmos-sdk/types" ) var _ helpers.TransactionResponse = (*TransactionResponse)(nil) diff --git a/x/assets/utilities/permissions.go b/x/assets/utilities/permissions.go index e43f04562..47a88e493 100644 --- a/x/assets/utilities/permissions.go +++ b/x/assets/utilities/permissions.go @@ -1,9 +1,8 @@ package utilities import ( - "github.com/AssetMantle/schema/ids" - "github.com/AssetMantle/modules/x/assets/constants" + "github.com/AssetMantle/schema/ids" ) func SetModulePermissions(canMintAsset bool, canRenumerateAsset bool, canBurnAsset bool) []ids.StringID { diff --git a/x/classifications/auxiliaries/bond/auxiliary_keeper.go b/x/classifications/auxiliaries/bond/auxiliary_keeper.go index 75255685f..897b38c86 100644 --- a/x/classifications/auxiliaries/bond/auxiliary_keeper.go +++ b/x/classifications/auxiliaries/bond/auxiliary_keeper.go @@ -6,7 +6,6 @@ package bond import ( "context" errorConstants "github.com/AssetMantle/modules/helpers/constants" - sdkTypes "github.com/cosmos/cosmos-sdk/types" bankKeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" stakingKeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" diff --git a/x/classifications/auxiliaries/bond/auxiliary_request.go b/x/classifications/auxiliaries/bond/auxiliary_request.go index f63ff93d2..862dbd9f5 100644 --- a/x/classifications/auxiliaries/bond/auxiliary_request.go +++ b/x/classifications/auxiliaries/bond/auxiliary_request.go @@ -4,11 +4,10 @@ package bond import ( + "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/helpers/constants" "github.com/AssetMantle/schema/ids" sdkTypes "github.com/cosmos/cosmos-sdk/types" - - "github.com/AssetMantle/modules/helpers" ) type auxiliaryRequest struct { diff --git a/x/classifications/auxiliaries/burn/auxiliary_keeper.go b/x/classifications/auxiliaries/burn/auxiliary_keeper.go index c48187b70..3b37a5e40 100644 --- a/x/classifications/auxiliaries/burn/auxiliary_keeper.go +++ b/x/classifications/auxiliaries/burn/auxiliary_keeper.go @@ -6,7 +6,6 @@ package burn import ( "context" errorConstants "github.com/AssetMantle/modules/helpers/constants" - sdkTypes "github.com/cosmos/cosmos-sdk/types" bankKeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" stakingKeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" diff --git a/x/classifications/auxiliaries/burn/auxiliary_request.go b/x/classifications/auxiliaries/burn/auxiliary_request.go index 49c01a3cb..5e38b065b 100644 --- a/x/classifications/auxiliaries/burn/auxiliary_request.go +++ b/x/classifications/auxiliaries/burn/auxiliary_request.go @@ -4,11 +4,10 @@ package burn import ( + "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/helpers/constants" "github.com/AssetMantle/schema/ids" sdkTypes "github.com/cosmos/cosmos-sdk/types" - - "github.com/AssetMantle/modules/helpers" ) type auxiliaryRequest struct { diff --git a/x/classifications/auxiliaries/conform/auxiliary_keeper.go b/x/classifications/auxiliaries/conform/auxiliary_keeper.go index b95515184..572fdb15d 100644 --- a/x/classifications/auxiliaries/conform/auxiliary_keeper.go +++ b/x/classifications/auxiliaries/conform/auxiliary_keeper.go @@ -5,12 +5,11 @@ package conform import ( "context" - errorConstants "github.com/AssetMantle/modules/helpers/constants" - baseIDs "github.com/AssetMantle/schema/ids/base" - "github.com/AssetMantle/modules/helpers" + errorConstants "github.com/AssetMantle/modules/helpers/constants" "github.com/AssetMantle/modules/x/classifications/key" "github.com/AssetMantle/modules/x/classifications/mappable" + baseIDs "github.com/AssetMantle/schema/ids/base" ) type auxiliaryKeeper struct { diff --git a/x/classifications/auxiliaries/define/auxiliary_keeper.go b/x/classifications/auxiliaries/define/auxiliary_keeper.go index 8e3f67836..146014542 100644 --- a/x/classifications/auxiliaries/define/auxiliary_keeper.go +++ b/x/classifications/auxiliaries/define/auxiliary_keeper.go @@ -5,7 +5,11 @@ package define import ( "context" + "github.com/AssetMantle/modules/helpers" errorConstants "github.com/AssetMantle/modules/helpers/constants" + "github.com/AssetMantle/modules/x/classifications/constants" + "github.com/AssetMantle/modules/x/classifications/key" + "github.com/AssetMantle/modules/x/classifications/record" "github.com/AssetMantle/schema/data" baseData "github.com/AssetMantle/schema/data/base" "github.com/AssetMantle/schema/documents/base" @@ -17,11 +21,6 @@ import ( sdkTypes "github.com/cosmos/cosmos-sdk/types" bankKeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" stakingKeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" - - "github.com/AssetMantle/modules/helpers" - "github.com/AssetMantle/modules/x/classifications/constants" - "github.com/AssetMantle/modules/x/classifications/key" - "github.com/AssetMantle/modules/x/classifications/record" ) type auxiliaryKeeper struct { diff --git a/x/classifications/auxiliaries/define/auxiliary_request.go b/x/classifications/auxiliaries/define/auxiliary_request.go index 71d890ab5..fe679c8d1 100644 --- a/x/classifications/auxiliaries/define/auxiliary_request.go +++ b/x/classifications/auxiliaries/define/auxiliary_request.go @@ -4,11 +4,10 @@ package define import ( + "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/helpers/constants" "github.com/AssetMantle/schema/qualified" sdkTypes "github.com/cosmos/cosmos-sdk/types" - - "github.com/AssetMantle/modules/helpers" ) type auxiliaryRequest struct { diff --git a/x/classifications/auxiliaries/define/auxiliary_response.go b/x/classifications/auxiliaries/define/auxiliary_response.go index 52a35cb1e..b4a6ea003 100644 --- a/x/classifications/auxiliaries/define/auxiliary_response.go +++ b/x/classifications/auxiliaries/define/auxiliary_response.go @@ -4,10 +4,9 @@ package define import ( + "github.com/AssetMantle/modules/helpers" errorConstants "github.com/AssetMantle/modules/helpers/constants" "github.com/AssetMantle/schema/ids" - - "github.com/AssetMantle/modules/helpers" ) type auxiliaryResponse struct { diff --git a/x/classifications/auxiliaries/member/auxiliary_keeper.go b/x/classifications/auxiliaries/member/auxiliary_keeper.go index bc5072b8d..ad849d87e 100644 --- a/x/classifications/auxiliaries/member/auxiliary_keeper.go +++ b/x/classifications/auxiliaries/member/auxiliary_keeper.go @@ -6,7 +6,6 @@ package member import ( "context" errorConstants "github.com/AssetMantle/modules/helpers/constants" - baseIDs "github.com/AssetMantle/schema/ids/base" "github.com/AssetMantle/modules/helpers" diff --git a/x/classifications/auxiliaries/unbond/auxiliary_keeper.go b/x/classifications/auxiliaries/unbond/auxiliary_keeper.go index 900ff6889..6a2ccf812 100644 --- a/x/classifications/auxiliaries/unbond/auxiliary_keeper.go +++ b/x/classifications/auxiliaries/unbond/auxiliary_keeper.go @@ -6,7 +6,6 @@ package unbond import ( "context" errorConstants "github.com/AssetMantle/modules/helpers/constants" - sdkTypes "github.com/cosmos/cosmos-sdk/types" bankKeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" stakingKeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" diff --git a/x/classifications/auxiliaries/unbond/auxiliary_request.go b/x/classifications/auxiliaries/unbond/auxiliary_request.go index 587a4c03d..fc4a13f8b 100644 --- a/x/classifications/auxiliaries/unbond/auxiliary_request.go +++ b/x/classifications/auxiliaries/unbond/auxiliary_request.go @@ -4,11 +4,10 @@ package unbond import ( + "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/helpers/constants" "github.com/AssetMantle/schema/ids" sdkTypes "github.com/cosmos/cosmos-sdk/types" - - "github.com/AssetMantle/modules/helpers" ) type auxiliaryRequest struct { diff --git a/x/classifications/block/block.go b/x/classifications/block/block.go index 1cbdcc3d6..36d85c5ae 100644 --- a/x/classifications/block/block.go +++ b/x/classifications/block/block.go @@ -5,7 +5,6 @@ package block import ( "context" - abciTypes "github.com/cometbft/cometbft/abci/types" "github.com/AssetMantle/modules/helpers" diff --git a/x/classifications/genesis/genesis.go b/x/classifications/genesis/genesis.go index 79c08a760..206b3460c 100644 --- a/x/classifications/genesis/genesis.go +++ b/x/classifications/genesis/genesis.go @@ -3,7 +3,6 @@ package genesis import ( "context" errorConstants "github.com/AssetMantle/modules/helpers/constants" - baseDocuments "github.com/AssetMantle/schema/documents/base" "github.com/AssetMantle/schema/lists" "github.com/AssetMantle/schema/lists/base" diff --git a/x/classifications/key/key.go b/x/classifications/key/key.go index db8b63f8a..4d5492a06 100644 --- a/x/classifications/key/key.go +++ b/x/classifications/key/key.go @@ -4,11 +4,10 @@ package key import ( + "github.com/AssetMantle/modules/helpers" errorConstants "github.com/AssetMantle/modules/helpers/constants" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" - - "github.com/AssetMantle/modules/helpers" ) var _ helpers.Key = (*Key)(nil) @@ -22,7 +21,7 @@ func (key *Key) ValidateBasic() error { return nil } func (key *Key) GenerateStorePrefixBytes() []byte { - return []byte{} + return []byte{0x0} } func (key *Key) GenerateStoreKeyBytes() []byte { return key.ClassificationID.Bytes() diff --git a/x/classifications/mappable/mappable.go b/x/classifications/mappable/mappable.go index e9f6afd1e..28f41980f 100644 --- a/x/classifications/mappable/mappable.go +++ b/x/classifications/mappable/mappable.go @@ -4,12 +4,9 @@ package mappable import ( - codecUtilities "github.com/AssetMantle/schema/codec/utilities" + "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/schema/documents" "github.com/AssetMantle/schema/documents/base" - "github.com/cosmos/cosmos-sdk/codec" - - "github.com/AssetMantle/modules/helpers" ) var _ helpers.Mappable = (*Mappable)(nil) @@ -17,9 +14,6 @@ var _ helpers.Mappable = (*Mappable)(nil) func (mappable *Mappable) ValidateBasic() error { return mappable.Classification.ValidateBasic() } -func (*Mappable) RegisterLegacyAminoCodec(legacyAmino *codec.LegacyAmino) { - codecUtilities.RegisterModuleConcrete(legacyAmino, Mappable{}) -} func NewMappable(classification documents.Classification) helpers.Mappable { return &Mappable{ Classification: classification.Get().(*base.Document), diff --git a/x/classifications/mappable/mappable_test.go b/x/classifications/mappable/mappable_test.go index 43ad9511b..116ed5810 100644 --- a/x/classifications/mappable/mappable_test.go +++ b/x/classifications/mappable/mappable_test.go @@ -7,6 +7,7 @@ import ( "reflect" "testing" + "github.com/AssetMantle/modules/helpers" baseData "github.com/AssetMantle/schema/data/base" documentsSchema "github.com/AssetMantle/schema/documents" baseDocuments "github.com/AssetMantle/schema/documents/base" @@ -16,9 +17,6 @@ import ( baseProperties "github.com/AssetMantle/schema/properties/base" "github.com/AssetMantle/schema/qualified" baseQualified "github.com/AssetMantle/schema/qualified/base" - "github.com/cosmos/cosmos-sdk/codec" - - "github.com/AssetMantle/modules/helpers" ) func createTestInput() (ids.ClassificationID, qualified.Immutables, qualified.Mutables, *Mappable) { @@ -65,29 +63,3 @@ func TestPrototype(t *testing.T) { }) } } - -func Test_mappable_RegisterCodec(t *testing.T) { - _, _, _, testMappable := createTestInput() - type fields struct { - Document *Mappable - } - type args struct { - legacyAmino *codec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{testMappable}, args{legacyAmino: codec.NewLegacyAmino()}}, - {"+ve nil", fields{&Mappable{nil}}, args{legacyAmino: codec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - as := &Mappable{ - Classification: tt.fields.Document.Classification, - } - as.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} diff --git a/x/classifications/parameters/bond_rate/parameter.go b/x/classifications/parameters/bond_rate/parameter.go index 2f60a6092..cf8f346d6 100644 --- a/x/classifications/parameters/bond_rate/parameter.go +++ b/x/classifications/parameters/bond_rate/parameter.go @@ -4,14 +4,13 @@ package bond_rate import ( + baseHelpers "github.com/AssetMantle/modules/helpers/base" errorConstants "github.com/AssetMantle/modules/helpers/constants" baseData "github.com/AssetMantle/schema/data/base" baseParameters "github.com/AssetMantle/schema/parameters/base" "github.com/AssetMantle/schema/properties/base" constantProperties "github.com/AssetMantle/schema/properties/constants" "github.com/cosmos/cosmos-sdk/types" - - baseHelpers "github.com/AssetMantle/modules/helpers/base" ) var ID = constantProperties.BondRateProperty.GetKey() diff --git a/x/classifications/parameters/define_enabled/parameter.go b/x/classifications/parameters/define_enabled/parameter.go index 747d7ecb6..63ae8a0bc 100644 --- a/x/classifications/parameters/define_enabled/parameter.go +++ b/x/classifications/parameters/define_enabled/parameter.go @@ -4,13 +4,12 @@ package define_enabled import ( + baseHelpers "github.com/AssetMantle/modules/helpers/base" errorConstants "github.com/AssetMantle/modules/helpers/constants" baseData "github.com/AssetMantle/schema/data/base" baseParameters "github.com/AssetMantle/schema/parameters/base" "github.com/AssetMantle/schema/properties/base" constantProperties "github.com/AssetMantle/schema/properties/constants" - - baseHelpers "github.com/AssetMantle/modules/helpers/base" ) var ID = constantProperties.DefineEnabledProperty.GetKey() diff --git a/x/classifications/parameters/max_property_count/parameter.go b/x/classifications/parameters/max_property_count/parameter.go index 61643882c..477671cb1 100644 --- a/x/classifications/parameters/max_property_count/parameter.go +++ b/x/classifications/parameters/max_property_count/parameter.go @@ -4,14 +4,13 @@ package max_property_count import ( + baseHelpers "github.com/AssetMantle/modules/helpers/base" errorConstants "github.com/AssetMantle/modules/helpers/constants" baseData "github.com/AssetMantle/schema/data/base" baseParameters "github.com/AssetMantle/schema/parameters/base" "github.com/AssetMantle/schema/properties/base" constantProperties "github.com/AssetMantle/schema/properties/constants" "github.com/cosmos/cosmos-sdk/types" - - baseHelpers "github.com/AssetMantle/modules/helpers/base" ) var ID = constantProperties.MaxPropertyCountProperty.GetKey() diff --git a/x/classifications/parameters/prototype.go b/x/classifications/parameters/prototype.go index 602962e46..046a15895 100644 --- a/x/classifications/parameters/prototype.go +++ b/x/classifications/parameters/prototype.go @@ -6,12 +6,11 @@ package parameters import ( "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" - "github.com/AssetMantle/modules/x/classifications/constants" "github.com/AssetMantle/modules/x/classifications/parameters/bond_rate" "github.com/AssetMantle/modules/x/classifications/parameters/define_enabled" "github.com/AssetMantle/modules/x/classifications/parameters/max_property_count" ) func Prototype() helpers.ParameterManager { - return baseHelpers.NewParameterManager(constants.ModuleName, bond_rate.ValidatableParameter, define_enabled.ValidatableParameter, max_property_count.ValidatableParameter) + return baseHelpers.NewParameterManager(bond_rate.ValidatableParameter, define_enabled.ValidatableParameter, max_property_count.ValidatableParameter) } diff --git a/x/classifications/parameters/prototype_test.go b/x/classifications/parameters/prototype_test.go index 6e2fa705b..9aae7870b 100644 --- a/x/classifications/parameters/prototype_test.go +++ b/x/classifications/parameters/prototype_test.go @@ -9,7 +9,6 @@ import ( "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" - "github.com/AssetMantle/modules/x/classifications/constants" "github.com/AssetMantle/modules/x/classifications/parameters/bond_rate" "github.com/AssetMantle/modules/x/classifications/parameters/max_property_count" ) @@ -20,7 +19,7 @@ func TestPrototype(t *testing.T) { want helpers.ParameterManager wantError error }{ - {"+ve", baseHelpers.NewParameterManager(constants.ModuleName, bond_rate.ValidatableParameter, max_property_count.ValidatableParameter), nil}, + {"+ve", baseHelpers.NewParameterManager(bond_rate.ValidatableParameter, max_property_count.ValidatableParameter), nil}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { diff --git a/x/classifications/queries/classification/query.go b/x/classifications/queries/classification/query.go index 3e9a23870..d2421c8a5 100644 --- a/x/classifications/queries/classification/query.go +++ b/x/classifications/queries/classification/query.go @@ -4,28 +4,17 @@ package classification import ( - "context" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "google.golang.org/grpc" - "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" helperConstants "github.com/AssetMantle/modules/helpers/constants" - "github.com/AssetMantle/modules/utilities/name" - "github.com/AssetMantle/modules/x/classifications/constants" + "google.golang.org/grpc" ) -type dummy struct{} - var Query = baseHelpers.NewQuery( - name.GetPackageName(dummy{}), + _Query_serviceDesc.ServiceName, "", "", - constants.ModuleName, - requestPrototype, responsePrototype, keeperPrototype, @@ -33,9 +22,6 @@ var Query = baseHelpers.NewQuery( func(server grpc.ServiceRegistrar, QueryKeeper helpers.QueryKeeper) { RegisterQueryServer(server, QueryKeeper.(queryKeeper)) }, - func(clientContext client.Context, serveMux *runtime.ServeMux) error { - return RegisterQueryHandlerClient(context.Background(), serveMux, NewQueryClient(clientContext)) - }, helperConstants.ClassificationID, ) diff --git a/x/classifications/queries/classification/query_keeper.go b/x/classifications/queries/classification/query_keeper.go index edf37f41f..526a29853 100644 --- a/x/classifications/queries/classification/query_keeper.go +++ b/x/classifications/queries/classification/query_keeper.go @@ -5,7 +5,6 @@ package classification import ( "context" - "github.com/AssetMantle/modules/helpers" ) @@ -16,7 +15,7 @@ type queryKeeper struct { var _ helpers.QueryKeeper = (*queryKeeper)(nil) func (queryKeeper queryKeeper) Enquire(context context.Context, queryRequest helpers.QueryRequest) (helpers.QueryResponse, error) { - queryResponse, err := queryKeeper.Handle(context, queryRequestFromInterface(queryRequest)) + queryResponse, err := queryKeeper.Handle(context, queryRequest.(*QueryRequest)) return queryResponse, err } func (queryKeeper queryKeeper) Handle(context context.Context, queryRequest *QueryRequest) (*QueryResponse, error) { diff --git a/x/classifications/queries/classification/query_request.go b/x/classifications/queries/classification/query_request.go index 944bc8f77..2ac51ec95 100644 --- a/x/classifications/queries/classification/query_request.go +++ b/x/classifications/queries/classification/query_request.go @@ -11,7 +11,6 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/AssetMantle/modules/helpers" - "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/helpers/constants" "github.com/AssetMantle/modules/x/classifications/key" ) @@ -49,27 +48,9 @@ func (*QueryRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.QueryRe return newQueryRequest(classificationID.(ids.ClassificationID)), nil } } -func (queryRequest *QueryRequest) Encode() ([]byte, error) { - return base.CodecPrototype().MarshalJSON(queryRequest) -} -func (queryRequest *QueryRequest) Decode(bytes []byte) (helpers.QueryRequest, error) { - if err := base.CodecPrototype().UnmarshalJSON(bytes, queryRequest); err != nil { - return nil, err - } - - return queryRequest, nil -} func requestPrototype() helpers.QueryRequest { return &QueryRequest{} } -func queryRequestFromInterface(request helpers.QueryRequest) *QueryRequest { - switch value := request.(type) { - case *QueryRequest: - return value - default: - return &QueryRequest{} - } -} func newQueryRequest(classificationID ids.ClassificationID) helpers.QueryRequest { return &QueryRequest{Key: key.NewKey(classificationID).(*key.Key)} } diff --git a/x/classifications/queries/classification/service.pb.go b/x/classifications/queries/classification/service.pb.go index 32255f815..66c3d66dd 100644 --- a/x/classifications/queries/classification/service.pb.go +++ b/x/classifications/queries/classification/service.pb.go @@ -8,7 +8,6 @@ import ( fmt "fmt" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" - _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -31,30 +30,28 @@ func init() { } var fileDescriptor_e5438836dfa39dff = []byte{ - // 363 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x92, 0xb1, 0x4a, 0xc3, 0x40, - 0x18, 0xc7, 0x9b, 0x88, 0x1d, 0x82, 0x53, 0xc6, 0x22, 0x19, 0x7c, 0x80, 0x3b, 0xab, 0xe0, 0x70, - 0x38, 0xd8, 0x76, 0x68, 0xa9, 0x04, 0x12, 0x5d, 0x82, 0x04, 0xe4, 0x9a, 0x7e, 0xd6, 0x83, 0x24, - 0xd7, 0xe6, 0x2e, 0xa5, 0xae, 0x3e, 0x81, 0xe0, 0x1b, 0x38, 0xfa, 0x24, 0xea, 0x54, 0x70, 0xd1, - 0x4d, 0x12, 0x27, 0x9f, 0x42, 0xda, 0xdc, 0xd0, 0xde, 0x9a, 0xae, 0xff, 0x2f, 0xff, 0x1f, 0xbf, - 0x7c, 0xf7, 0x59, 0xc3, 0x8e, 0x10, 0x20, 0x5d, 0x9a, 0xca, 0x18, 0x70, 0xc2, 0xc7, 0x79, 0x0c, - 0x02, 0x2f, 0x70, 0x14, 0x53, 0x21, 0xd8, 0x1d, 0x8b, 0xa8, 0x64, 0x3c, 0x15, 0x78, 0x96, 0x43, - 0xc6, 0x40, 0x68, 0x39, 0x16, 0x90, 0xcd, 0x59, 0x04, 0x68, 0x9a, 0x71, 0xc9, 0xed, 0xf3, 0x0d, - 0x16, 0x52, 0x2c, 0xb4, 0x40, 0x1a, 0x0b, 0x29, 0x96, 0x96, 0xb7, 0x0e, 0x27, 0x9c, 0x4f, 0x62, - 0xc0, 0x74, 0xca, 0x30, 0x4d, 0x53, 0x2e, 0xd5, 0xe7, 0x6b, 0x76, 0xcb, 0xab, 0xe5, 0xb9, 0x8a, - 0x1f, 0x6e, 0x33, 0x98, 0xe5, 0x20, 0xa4, 0x22, 0xfa, 0x3b, 0x21, 0x8a, 0x29, 0x4f, 0x85, 0x5a, - 0xc0, 0x49, 0x69, 0x58, 0xfb, 0xfe, 0x6a, 0x60, 0x7f, 0x1b, 0x56, 0x73, 0x40, 0xd3, 0x71, 0x0c, - 0xf6, 0x10, 0xd5, 0x59, 0x0b, 0x5a, 0xf3, 0xae, 0x2a, 0xf3, 0xd6, 0xe5, 0x4e, 0x58, 0x95, 0xf3, - 0xd1, 0xd9, 0xe3, 0xe7, 0xef, 0xb3, 0x79, 0x6c, 0x23, 0x9c, 0x54, 0x4b, 0xd0, 0x7f, 0x7d, 0xde, - 0x1e, 0x81, 0xa4, 0x6d, 0x2d, 0xef, 0xbe, 0xef, 0xbd, 0x15, 0x8e, 0xb1, 0x2c, 0x1c, 0xe3, 0xa7, - 0x70, 0x8c, 0xa7, 0xd2, 0x69, 0x2c, 0x4b, 0xa7, 0xf1, 0x55, 0x3a, 0x0d, 0xeb, 0x22, 0xe2, 0x49, - 0x2d, 0xc5, 0xee, 0xc1, 0x75, 0x75, 0x52, 0xde, 0x6a, 0xa1, 0x9e, 0x71, 0xd3, 0x9f, 0x30, 0x79, - 0x9f, 0x8f, 0x50, 0xc4, 0x13, 0x5c, 0xe7, 0xc1, 0x5e, 0xcc, 0x66, 0xc7, 0x0d, 0x7a, 0x7e, 0xef, - 0xd5, 0xdc, 0x3a, 0x53, 0x57, 0x09, 0x06, 0xa8, 0xa7, 0x09, 0xfa, 0x4a, 0x70, 0x3b, 0xff, 0xd8, - 0xaa, 0x87, 0xaa, 0x1e, 0x06, 0xa1, 0x56, 0x0f, 0x55, 0x5d, 0xcb, 0x0b, 0x73, 0x50, 0xa7, 0x1e, - 0xf6, 0xbd, 0xae, 0x0b, 0x92, 0x8e, 0xa9, 0xa4, 0x7f, 0x66, 0x67, 0x03, 0x45, 0x88, 0x62, 0x11, - 0x12, 0x10, 0xa2, 0xd1, 0x08, 0x51, 0x38, 0x7d, 0x32, 0x6a, 0xae, 0x0f, 0xf7, 0xf4, 0x3f, 0x00, - 0x00, 0xff, 0xff, 0xbb, 0x34, 0xaa, 0x80, 0x07, 0x04, 0x00, 0x00, + // 323 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x92, 0x31, 0x4e, 0xc3, 0x30, + 0x14, 0x86, 0xe3, 0x20, 0x3a, 0x44, 0x4c, 0x1d, 0x3b, 0x78, 0xe0, 0x00, 0xb6, 0x04, 0x9b, 0xc5, + 0x40, 0x93, 0xa1, 0x55, 0x51, 0xa4, 0x04, 0x96, 0x08, 0x45, 0x42, 0x6e, 0x62, 0xc0, 0x52, 0x12, + 0xb7, 0xb1, 0x83, 0xca, 0x2d, 0x38, 0x03, 0x6c, 0x48, 0xdc, 0x03, 0x98, 0x3a, 0x32, 0xa2, 0x64, + 0xe3, 0x14, 0x28, 0x8d, 0x87, 0xc6, 0x6b, 0xba, 0xfe, 0xd6, 0xff, 0xe5, 0x7b, 0x2f, 0xcf, 0x59, + 0x4c, 0xa5, 0x64, 0xca, 0xa7, 0x85, 0xca, 0x18, 0xce, 0x45, 0x5a, 0x65, 0x4c, 0xe2, 0x0d, 0x4e, + 0x32, 0x2a, 0x25, 0xbf, 0xe7, 0x09, 0x55, 0x5c, 0x14, 0x12, 0xaf, 0x2b, 0x56, 0x72, 0x26, 0x8d, + 0x1c, 0x4b, 0x56, 0x3e, 0xf1, 0x84, 0xa1, 0x55, 0x29, 0x94, 0x18, 0x5f, 0xec, 0xb1, 0x90, 0x66, + 0xa1, 0x0d, 0x32, 0x58, 0x48, 0xb3, 0x8c, 0x7c, 0x12, 0x0c, 0x32, 0x69, 0xe3, 0xe7, 0xbb, 0x92, + 0xad, 0x2b, 0x26, 0x55, 0xe7, 0x33, 0x09, 0x0f, 0x42, 0x94, 0x2b, 0x51, 0x48, 0x3d, 0xe2, 0xd9, + 0x07, 0x70, 0x8e, 0xc3, 0xf6, 0x61, 0xfc, 0x06, 0x9c, 0xd1, 0x9c, 0x16, 0x69, 0xc6, 0xc6, 0x0b, + 0x34, 0x64, 0x70, 0xb4, 0xe3, 0x5d, 0x77, 0xe6, 0x93, 0xab, 0x83, 0xb0, 0x3a, 0xe7, 0x53, 0xcb, + 0xfd, 0x3a, 0xfa, 0xac, 0x21, 0xd8, 0xd6, 0x10, 0xfc, 0xd6, 0x10, 0xbc, 0x34, 0xd0, 0xda, 0x36, + 0xd0, 0xfa, 0x69, 0xa0, 0xe5, 0x5c, 0x26, 0x22, 0x1f, 0xf4, 0x31, 0xf7, 0xe4, 0xa6, 0xfb, 0xfd, + 0x41, 0xbb, 0x9a, 0x00, 0xdc, 0xce, 0x1e, 0xb8, 0x7a, 0xac, 0x96, 0x28, 0x11, 0x39, 0x1e, 0xb2, + 0xfa, 0x57, 0x7b, 0x34, 0xf5, 0x23, 0x2f, 0xf4, 0xde, 0xed, 0xde, 0x49, 0xf9, 0x5a, 0x30, 0x42, + 0x9e, 0x21, 0x18, 0x6a, 0xc1, 0x7e, 0xfe, 0xdd, 0xab, 0xc7, 0xba, 0x1e, 0x47, 0xb1, 0x51, 0x8f, + 0x75, 0xdd, 0xc8, 0x6b, 0x7b, 0x3e, 0xa4, 0x1e, 0xcf, 0x02, 0xd7, 0x67, 0x8a, 0xa6, 0x54, 0xd1, + 0x3f, 0x7b, 0xba, 0x87, 0x22, 0x44, 0xb3, 0x08, 0x89, 0x08, 0x31, 0x68, 0x84, 0x68, 0x9c, 0xf9, + 0xb2, 0x1c, 0xed, 0x4e, 0xf0, 0xfc, 0x3f, 0x00, 0x00, 0xff, 0xff, 0x70, 0x12, 0x4a, 0x27, 0xb3, + 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/classifications/queries/classification/service.pb.gw.go b/x/classifications/queries/classification/service.pb.gw.go deleted file mode 100644 index 84980b631..000000000 --- a/x/classifications/queries/classification/service.pb.gw.go +++ /dev/null @@ -1,171 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: AssetMantle/modules/x/classifications/queries/classification/service.proto - -/* -Package classification is a reverse proxy. - -It translates gRPC into RESTful JSON APIs. -*/ -package classification - -import ( - "context" - "io" - "net/http" - - "github.com/golang/protobuf/descriptor" - "github.com/golang/protobuf/proto" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/grpc-ecosystem/grpc-gateway/utilities" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/status" -) - -// Suppress "imported and not used" errors -var _ codes.Code -var _ io.Reader -var _ status.Status -var _ = runtime.String -var _ = utilities.NewDoubleArray -var _ = descriptor.ForMessage -var _ = metadata.Join - -var ( - filter_Query_Handle_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - -func request_Query_Handle_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryRequest - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.Handle(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_Handle_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryRequest - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.Handle(ctx, &protoReq) - return msg, metadata, err - -} - -// RegisterQueryHandlerServer registers the http handlers for service Query to "mux". -// UnaryRPC :call QueryServer directly. -// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. -func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { - - mux.Handle("GET", pattern_Query_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Query_Handle_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but -// automatically dials to "endpoint" and closes the connection when "ctx" gets done. -func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.Dial(endpoint, opts...) - if err != nil { - return err - } - defer func() { - if err != nil { - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - return - } - go func() { - <-ctx.Done() - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - }() - }() - - return RegisterQueryHandler(ctx, mux, conn) -} - -// RegisterQueryHandler registers the http handlers for service Query to "mux". -// The handlers forward requests to the grpc endpoint over "conn". -func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { - return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn)) -} - -// RegisterQueryHandlerClient registers the http handlers for service Query -// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient". -// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient" -// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "QueryClient" to call the correct interceptors. -func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { - - mux.Handle("GET", pattern_Query_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Query_Handle_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -var ( - pattern_Query_Handle_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"mantle", "classifications", "v1beta1", "classification"}, "", runtime.AssumeColonVerbOpt(false))) -) - -var ( - forward_Query_Handle_0 = runtime.ForwardResponseMessage -) diff --git a/x/classifications/queries/classifications/query.go b/x/classifications/queries/classifications/query.go index 1e4be0a02..e02896bf6 100644 --- a/x/classifications/queries/classifications/query.go +++ b/x/classifications/queries/classifications/query.go @@ -4,26 +4,16 @@ package classifications import ( - "context" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "google.golang.org/grpc" - "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" helperConstants "github.com/AssetMantle/modules/helpers/constants" - "github.com/AssetMantle/modules/utilities/name" - "github.com/AssetMantle/modules/x/classifications/constants" + "google.golang.org/grpc" ) -type dummy struct{} - var Query = baseHelpers.NewQuery( - name.GetPackageName(dummy{}), + _Query_serviceDesc.ServiceName, "", "", - constants.ModuleName, requestPrototype, responsePrototype, @@ -32,9 +22,6 @@ var Query = baseHelpers.NewQuery( func(server grpc.ServiceRegistrar, QueryKeeper helpers.QueryKeeper) { RegisterQueryServer(server, QueryKeeper.(queryKeeper)) }, - func(clientContext client.Context, serveMux *runtime.ServeMux) error { - return RegisterQueryHandlerClient(context.Background(), serveMux, NewQueryClient(clientContext)) - }, helperConstants.ClassificationID, helperConstants.Limit, diff --git a/x/classifications/queries/classifications/query_keeper.go b/x/classifications/queries/classifications/query_keeper.go index d05b5b58b..39933d8d3 100644 --- a/x/classifications/queries/classifications/query_keeper.go +++ b/x/classifications/queries/classifications/query_keeper.go @@ -5,7 +5,6 @@ package classifications import ( "context" - "github.com/AssetMantle/modules/helpers" ) @@ -16,7 +15,7 @@ type queryKeeper struct { var _ helpers.QueryKeeper = (*queryKeeper)(nil) func (queryKeeper queryKeeper) Enquire(context context.Context, queryRequest helpers.QueryRequest) (helpers.QueryResponse, error) { - queryResponse, err := queryKeeper.Handle(context, queryRequestFromInterface(queryRequest)) + queryResponse, err := queryKeeper.Handle(context, queryRequest.(*QueryRequest)) return queryResponse, err } func (queryKeeper queryKeeper) Handle(context context.Context, queryRequest *QueryRequest) (*QueryResponse, error) { diff --git a/x/classifications/queries/classifications/query_request.go b/x/classifications/queries/classifications/query_request.go index ba39d9949..248bdc57b 100644 --- a/x/classifications/queries/classifications/query_request.go +++ b/x/classifications/queries/classifications/query_request.go @@ -13,7 +13,6 @@ import ( "github.com/cosmos/cosmos-sdk/types/query" "github.com/AssetMantle/modules/helpers" - "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/helpers/constants" "github.com/AssetMantle/modules/x/classifications/key" ) @@ -68,27 +67,10 @@ func (*QueryRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.QueryRe return newQueryRequest(classificationID.(ids.ClassificationID), int32(limit)), nil } -func (queryRequest *QueryRequest) Encode() ([]byte, error) { - return base.CodecPrototype().MarshalJSON(queryRequest) -} -func (queryRequest *QueryRequest) Decode(bytes []byte) (helpers.QueryRequest, error) { - if err := base.CodecPrototype().UnmarshalJSON(bytes, queryRequest); err != nil { - return nil, err - } - - return queryRequest, nil -} func requestPrototype() helpers.QueryRequest { return &QueryRequest{} } -func queryRequestFromInterface(request helpers.QueryRequest) *QueryRequest { - switch value := request.(type) { - case *QueryRequest: - return value - default: - return &QueryRequest{} - } -} + func newQueryRequest(classificationID ids.ClassificationID, limit int32) helpers.QueryRequest { return &QueryRequest{Key: key.NewKey(classificationID).(*key.Key), Limit: limit} } diff --git a/x/classifications/queries/classifications/service.pb.go b/x/classifications/queries/classifications/service.pb.go index a6c39f2b0..ca6db69e1 100644 --- a/x/classifications/queries/classifications/service.pb.go +++ b/x/classifications/queries/classifications/service.pb.go @@ -8,7 +8,6 @@ import ( fmt "fmt" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" - _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -31,30 +30,28 @@ func init() { } var fileDescriptor_52483da8b4452def = []byte{ - // 368 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x92, 0x31, 0x4b, 0xfb, 0x40, - 0x18, 0xc6, 0x9b, 0xfc, 0xf9, 0x77, 0x08, 0x4e, 0x19, 0x8b, 0x64, 0xf0, 0x03, 0xdc, 0x51, 0x1d, - 0x84, 0x03, 0x87, 0xa6, 0x83, 0x95, 0x1a, 0x68, 0xeb, 0x12, 0x24, 0x20, 0xd7, 0xf4, 0xb5, 0x1e, - 0x24, 0xb9, 0x36, 0x77, 0x29, 0x75, 0xf5, 0x13, 0x08, 0x7e, 0x03, 0x47, 0x3f, 0x89, 0xb8, 0x58, - 0x70, 0x71, 0x70, 0x90, 0x54, 0x1c, 0xfc, 0x14, 0x92, 0xe6, 0x86, 0xf6, 0xea, 0x96, 0xae, 0xcf, - 0xfb, 0x3e, 0x3f, 0x9e, 0x7b, 0xee, 0xb5, 0xba, 0x2d, 0x21, 0x40, 0x7a, 0x34, 0x91, 0x11, 0xe0, - 0x98, 0x8f, 0xb2, 0x08, 0x04, 0x9e, 0xe3, 0x30, 0xa2, 0x42, 0xb0, 0x6b, 0x16, 0x52, 0xc9, 0x78, - 0x22, 0xf0, 0x34, 0x83, 0x94, 0x81, 0xd8, 0xd2, 0x05, 0xa4, 0x33, 0x16, 0x02, 0x9a, 0xa4, 0x5c, - 0x72, 0xfb, 0x64, 0x0d, 0x86, 0x14, 0x0c, 0xcd, 0x91, 0x66, 0x42, 0x0a, 0xa6, 0xeb, 0x8d, 0xfd, - 0x31, 0xe7, 0xe3, 0x08, 0x30, 0x9d, 0x30, 0x4c, 0x93, 0x84, 0x4b, 0xb5, 0xbf, 0x82, 0x37, 0xfa, - 0xd5, 0x92, 0x16, 0xfa, 0xed, 0x55, 0x0a, 0xd3, 0x0c, 0x84, 0x54, 0xc8, 0xc1, 0x6e, 0x90, 0x62, - 0xc2, 0x13, 0xa1, 0x3a, 0x38, 0xfc, 0x36, 0xac, 0xff, 0xfd, 0x62, 0x60, 0x7f, 0x18, 0x56, 0xbd, - 0x43, 0x93, 0x51, 0x04, 0x76, 0x17, 0x55, 0x6a, 0x06, 0xad, 0x80, 0x83, 0x32, 0x7b, 0xe3, 0x7c, - 0x37, 0xb0, 0x32, 0xf5, 0xc1, 0xf1, 0xdd, 0xdb, 0xd7, 0x83, 0xd9, 0xb4, 0x31, 0x8e, 0xcb, 0x1e, - 0xf4, 0x57, 0xce, 0x9a, 0x43, 0x90, 0xb4, 0xa9, 0xeb, 0xee, 0xeb, 0xbf, 0xe7, 0xdc, 0x31, 0x16, - 0xb9, 0x63, 0x7c, 0xe6, 0x8e, 0x71, 0xbf, 0x74, 0x6a, 0x8b, 0xa5, 0x53, 0x7b, 0x5f, 0x3a, 0x35, - 0xab, 0x15, 0xf2, 0xb8, 0x5a, 0x48, 0x77, 0xef, 0xa2, 0xbc, 0xac, 0x5e, 0x51, 0x6a, 0xcf, 0xb8, - 0xec, 0x8c, 0x99, 0xbc, 0xc9, 0x86, 0x28, 0xe4, 0x31, 0xae, 0xf4, 0x6b, 0x8f, 0x66, 0xbd, 0xe5, - 0xf9, 0xed, 0x7e, 0xfb, 0xc9, 0xdc, 0x38, 0x57, 0x4f, 0x45, 0xf4, 0x51, 0xfb, 0x8f, 0xbe, 0x8a, - 0x88, 0x9a, 0xfe, 0xb2, 0xe1, 0x0f, 0x94, 0x3f, 0xf0, 0x03, 0x6d, 0x2f, 0x50, 0x7e, 0x5d, 0xcf, - 0xcd, 0xb3, 0x4a, 0xfe, 0xe0, 0xb4, 0xe7, 0x7a, 0x20, 0xe9, 0x88, 0x4a, 0xfa, 0x63, 0xba, 0x6b, - 0x2c, 0x42, 0x14, 0x8c, 0x10, 0x9f, 0x10, 0xcd, 0x46, 0x88, 0xe2, 0x6d, 0x4d, 0x86, 0xf5, 0xd5, - 0x05, 0x1f, 0xfd, 0x06, 0x00, 0x00, 0xff, 0xff, 0x80, 0xf7, 0xaa, 0x60, 0x14, 0x04, 0x00, 0x00, + // 325 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xf2, 0x76, 0x2c, 0x2e, 0x4e, + 0x2d, 0xf1, 0x4d, 0xcc, 0x2b, 0xc9, 0x49, 0xd5, 0xcf, 0xcd, 0x4f, 0x29, 0xcd, 0x49, 0x2d, 0xd6, + 0xaf, 0xd0, 0x4f, 0xce, 0x49, 0x2c, 0x2e, 0xce, 0x4c, 0xcb, 0x4c, 0x4e, 0x2c, 0xc9, 0xcc, 0xcf, + 0x2b, 0xd6, 0x2f, 0x2c, 0x4d, 0x2d, 0xca, 0x4c, 0x2d, 0xc6, 0x10, 0x2f, 0x4e, 0x2d, 0x2a, 0xcb, + 0x4c, 0x4e, 0xd5, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xb2, 0x45, 0x32, 0x4c, 0x0f, 0x6a, 0x98, + 0x5e, 0x85, 0x1e, 0x9a, 0x26, 0x3d, 0xa8, 0x61, 0xe8, 0xe2, 0x52, 0x81, 0x94, 0xb9, 0x05, 0x24, + 0x5e, 0x19, 0x5f, 0x94, 0x5a, 0x58, 0x9a, 0x5a, 0x5c, 0x02, 0x71, 0x91, 0x54, 0x10, 0x75, 0x8c, + 0x2c, 0x2e, 0xc8, 0xcf, 0x2b, 0x86, 0xfa, 0xd2, 0x68, 0x3d, 0x23, 0x17, 0x6b, 0x20, 0x48, 0x42, + 0x68, 0x29, 0x23, 0x17, 0x9b, 0x47, 0x62, 0x5e, 0x4a, 0x4e, 0xaa, 0x90, 0xb7, 0x1e, 0x45, 0x7e, + 0xd7, 0x03, 0x1b, 0x18, 0x04, 0x71, 0xbb, 0x94, 0x0f, 0x75, 0x0c, 0x83, 0xb8, 0x5a, 0x89, 0xc1, + 0xe9, 0x3c, 0xf3, 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, + 0xe1, 0xb1, 0x1c, 0xc3, 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x70, 0x39, 0x26, 0xe7, + 0xe7, 0x52, 0x66, 0x9b, 0x13, 0x4f, 0x30, 0x24, 0x11, 0x04, 0x80, 0x42, 0x27, 0x80, 0x31, 0xca, + 0x23, 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x57, 0x9f, 0xa2, 0xe0, 0x5f, 0xc4, + 0xc4, 0xe6, 0xe8, 0x1b, 0xe1, 0x1c, 0xe8, 0xbc, 0x8a, 0x09, 0x25, 0x65, 0xf9, 0x42, 0x9d, 0x18, + 0xa1, 0xe7, 0x8c, 0xc5, 0xe3, 0x20, 0x27, 0xa2, 0x89, 0x9f, 0x42, 0xd1, 0x1f, 0x03, 0xd5, 0x1f, + 0x13, 0x11, 0x83, 0xa6, 0x2e, 0x06, 0xaa, 0x1f, 0x5d, 0xfc, 0x11, 0x93, 0x27, 0x45, 0xfa, 0x63, + 0xdc, 0x03, 0x9c, 0x7c, 0x53, 0x4b, 0x12, 0x53, 0x12, 0x4b, 0x12, 0x5f, 0x31, 0x39, 0x21, 0x99, + 0x65, 0x65, 0x05, 0x35, 0xcc, 0xca, 0x2a, 0xc2, 0xca, 0x0a, 0x4d, 0x9b, 0x95, 0x15, 0xd4, 0x3c, + 0x0c, 0x99, 0x24, 0x36, 0x70, 0x52, 0x34, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0x41, 0x61, 0xa4, + 0x8a, 0xbf, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/classifications/queries/classifications/service.pb.gw.go b/x/classifications/queries/classifications/service.pb.gw.go deleted file mode 100644 index 6e07dbca1..000000000 --- a/x/classifications/queries/classifications/service.pb.gw.go +++ /dev/null @@ -1,171 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: AssetMantle/modules/x/classifications/queries/classifications/service.proto - -/* -Package classifications is a reverse proxy. - -It translates gRPC into RESTful JSON APIs. -*/ -package classifications - -import ( - "context" - "io" - "net/http" - - "github.com/golang/protobuf/descriptor" - "github.com/golang/protobuf/proto" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/grpc-ecosystem/grpc-gateway/utilities" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/status" -) - -// Suppress "imported and not used" errors -var _ codes.Code -var _ io.Reader -var _ status.Status -var _ = runtime.String -var _ = utilities.NewDoubleArray -var _ = descriptor.ForMessage -var _ = metadata.Join - -var ( - filter_Query_Handle_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - -func request_Query_Handle_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryRequest - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.Handle(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_Handle_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryRequest - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.Handle(ctx, &protoReq) - return msg, metadata, err - -} - -// RegisterQueryHandlerServer registers the http handlers for service Query to "mux". -// UnaryRPC :call QueryServer directly. -// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. -func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { - - mux.Handle("GET", pattern_Query_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Query_Handle_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but -// automatically dials to "endpoint" and closes the connection when "ctx" gets done. -func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.Dial(endpoint, opts...) - if err != nil { - return err - } - defer func() { - if err != nil { - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - return - } - go func() { - <-ctx.Done() - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - }() - }() - - return RegisterQueryHandler(ctx, mux, conn) -} - -// RegisterQueryHandler registers the http handlers for service Query to "mux". -// The handlers forward requests to the grpc endpoint over "conn". -func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { - return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn)) -} - -// RegisterQueryHandlerClient registers the http handlers for service Query -// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient". -// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient" -// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "QueryClient" to call the correct interceptors. -func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { - - mux.Handle("GET", pattern_Query_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Query_Handle_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -var ( - pattern_Query_Handle_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 1}, []string{"mantle", "classifications", "v1beta1"}, "", runtime.AssumeColonVerbOpt(false))) -) - -var ( - forward_Query_Handle_0 = runtime.ForwardResponseMessage -) diff --git a/x/classifications/queries/parameters/query.go b/x/classifications/queries/parameters/query.go new file mode 100644 index 000000000..cfe5be8fe --- /dev/null +++ b/x/classifications/queries/parameters/query.go @@ -0,0 +1,21 @@ +package parameters + +import ( + "github.com/AssetMantle/modules/helpers" + baseHelpers "github.com/AssetMantle/modules/helpers/base" + "google.golang.org/grpc" +) + +var Query = baseHelpers.NewQuery( + _Query_serviceDesc.ServiceName, + "", + "", + + requestPrototype, + responsePrototype, + keeperPrototype, + + func(server grpc.ServiceRegistrar, QueryKeeper helpers.QueryKeeper) { + RegisterQueryServer(server, QueryKeeper.(queryKeeper)) + }, +) diff --git a/x/classifications/queries/parameters/query_keeper.go b/x/classifications/queries/parameters/query_keeper.go new file mode 100644 index 000000000..5ff196b53 --- /dev/null +++ b/x/classifications/queries/parameters/query_keeper.go @@ -0,0 +1,31 @@ +package parameters + +import ( + "context" + "github.com/AssetMantle/modules/helpers" +) + +type queryKeeper struct { + parameterManager helpers.ParameterManager +} + +var _ helpers.QueryKeeper = (*queryKeeper)(nil) + +func (queryKeeper queryKeeper) Enquire(context context.Context, queryRequest helpers.QueryRequest) (helpers.QueryResponse, error) { + queryResponse, err := queryKeeper.Handle(context, queryRequest.(*QueryRequest)) + return queryResponse, err +} +func (queryKeeper queryKeeper) Handle(context context.Context, queryRequest *QueryRequest) (*QueryResponse, error) { + if err := queryRequest.Validate(); err != nil { + return nil, err + } + return newQueryResponse(queryKeeper.parameterManager.Fetch(context).Get()), nil +} +func (queryKeeper queryKeeper) Initialize(_ helpers.Mapper, parameterManager helpers.ParameterManager, _ []interface{}) helpers.Keeper { + queryKeeper.parameterManager = parameterManager + return queryKeeper +} + +func keeperPrototype() helpers.QueryKeeper { + return queryKeeper{} +} diff --git a/x/classifications/queries/parameters/query_request.go b/x/classifications/queries/parameters/query_request.go new file mode 100644 index 000000000..9f99e7a01 --- /dev/null +++ b/x/classifications/queries/parameters/query_request.go @@ -0,0 +1,25 @@ +package parameters + +import ( + "github.com/AssetMantle/modules/helpers" + "github.com/cosmos/cosmos-sdk/client" + "net/http" +) + +var _ helpers.QueryRequest = (*QueryRequest)(nil) + +func (queryRequest *QueryRequest) Validate() error { + return nil +} + +func (queryRequest *QueryRequest) FromCLI(_ helpers.CLICommand, _ client.Context) (helpers.QueryRequest, error) { + return requestPrototype(), nil +} + +func (queryRequest *QueryRequest) FromHTTPRequest(_ *http.Request) (helpers.QueryRequest, error) { + return requestPrototype(), nil +} + +func requestPrototype() helpers.QueryRequest { + return &QueryRequest{} +} diff --git a/x/classifications/queries/parameters/query_request.pb.go b/x/classifications/queries/parameters/query_request.pb.go new file mode 100644 index 000000000..73cc3e099 --- /dev/null +++ b/x/classifications/queries/parameters/query_request.pb.go @@ -0,0 +1,273 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: AssetMantle/modules/x/classifications/queries/parameters/query_request.proto + +package parameters + +import ( + fmt "fmt" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type QueryRequest struct { +} + +func (m *QueryRequest) Reset() { *m = QueryRequest{} } +func (m *QueryRequest) String() string { return proto.CompactTextString(m) } +func (*QueryRequest) ProtoMessage() {} +func (*QueryRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_ff4255da0aa143e2, []int{0} +} +func (m *QueryRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryRequest.Merge(m, src) +} +func (m *QueryRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryRequest proto.InternalMessageInfo + +func init() { + proto.RegisterType((*QueryRequest)(nil), "AssetMantle.modules.x.classifications.queries.parameters.QueryRequest") +} + +func init() { + proto.RegisterFile("AssetMantle/modules/x/classifications/queries/parameters/query_request.proto", fileDescriptor_ff4255da0aa143e2) +} + +var fileDescriptor_ff4255da0aa143e2 = []byte{ + // 284 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xf2, 0x71, 0x2c, 0x2e, 0x4e, + 0x2d, 0xf1, 0x4d, 0xcc, 0x2b, 0xc9, 0x49, 0xd5, 0xcf, 0xcd, 0x4f, 0x29, 0xcd, 0x49, 0x2d, 0xd6, + 0xaf, 0xd0, 0x4f, 0xce, 0x49, 0x2c, 0x2e, 0xce, 0x4c, 0xcb, 0x4c, 0x4e, 0x2c, 0xc9, 0xcc, 0xcf, + 0x2b, 0xd6, 0x2f, 0x2c, 0x4d, 0x2d, 0xca, 0x4c, 0x2d, 0xd6, 0x2f, 0x48, 0x2c, 0x4a, 0xcc, 0x4d, + 0x2d, 0x49, 0x2d, 0x82, 0x08, 0x55, 0xc6, 0x17, 0xa5, 0x16, 0x96, 0xa6, 0x16, 0x97, 0xe8, 0x15, + 0x14, 0xe5, 0x97, 0xe4, 0x0b, 0x59, 0x20, 0x99, 0xa6, 0x07, 0x35, 0x4d, 0xaf, 0x42, 0x0f, 0xcd, + 0x34, 0x3d, 0xa8, 0x69, 0x7a, 0x08, 0xd3, 0x94, 0xf8, 0xb8, 0x78, 0x02, 0x41, 0x06, 0x06, 0x41, + 0xcc, 0x73, 0xda, 0xc6, 0x7c, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, 0xc9, + 0x31, 0x4e, 0x78, 0x2c, 0xc7, 0x70, 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, 0x0c, 0x5c, 0x36, + 0xc9, 0xf9, 0xb9, 0x7a, 0xe4, 0x5a, 0xe4, 0x24, 0x88, 0x6c, 0x4d, 0x00, 0xc8, 0xd5, 0x01, 0x8c, + 0x51, 0xce, 0xe9, 0x99, 0x25, 0x19, 0xa5, 0x49, 0x7a, 0xc9, 0xf9, 0xb9, 0xfa, 0xe4, 0x06, 0xc8, + 0x22, 0x26, 0x36, 0x47, 0xdf, 0x08, 0xe7, 0xc0, 0x80, 0x55, 0x4c, 0x28, 0xc1, 0xe0, 0x0b, 0x75, + 0x5d, 0x84, 0x9e, 0x33, 0x9a, 0xeb, 0x02, 0xa1, 0xae, 0x0b, 0x80, 0x9b, 0x71, 0x0a, 0x45, 0x6b, + 0x0c, 0x54, 0x6b, 0x4c, 0x44, 0x0c, 0x9a, 0xd6, 0x18, 0xa8, 0xd6, 0x18, 0x84, 0xd6, 0x47, 0x4c, + 0x2e, 0xe4, 0x6a, 0x8d, 0x71, 0x0f, 0x70, 0xf2, 0x4d, 0x2d, 0x49, 0x4c, 0x49, 0x2c, 0x49, 0x7c, + 0xc5, 0x64, 0x8b, 0x64, 0x8c, 0x95, 0x15, 0xd4, 0x1c, 0x2b, 0xab, 0x08, 0x2b, 0x2b, 0x34, 0x93, + 0xac, 0xac, 0xa0, 0x46, 0x59, 0x59, 0x21, 0xcc, 0x4a, 0x62, 0x03, 0xa7, 0x04, 0x63, 0x40, 0x00, + 0x00, 0x00, 0xff, 0xff, 0xfa, 0xe1, 0x8e, 0x72, 0x59, 0x02, 0x00, 0x00, +} + +func (m *QueryRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func encodeVarintQueryRequest(dAtA []byte, offset int, v uint64) int { + offset -= sovQueryRequest(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *QueryRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func sovQueryRequest(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQueryRequest(x uint64) (n int) { + return sovQueryRequest(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QueryRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQueryRequest + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQueryRequest(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQueryRequest + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipQueryRequest(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQueryRequest + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQueryRequest + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQueryRequest + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthQueryRequest + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupQueryRequest + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthQueryRequest + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthQueryRequest = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowQueryRequest = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupQueryRequest = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/classifications/queries/parameters/query_response.go b/x/classifications/queries/parameters/query_response.go new file mode 100644 index 000000000..4d34b8543 --- /dev/null +++ b/x/classifications/queries/parameters/query_response.go @@ -0,0 +1,29 @@ +package parameters + +import ( + "github.com/AssetMantle/modules/helpers" + "github.com/AssetMantle/modules/helpers/base" + "github.com/AssetMantle/schema/lists" + baseLists "github.com/AssetMantle/schema/lists/base" +) + +var _ helpers.QueryResponse = (*QueryResponse)(nil) + +func (queryResponse *QueryResponse) Encode() ([]byte, error) { + return base.CodecPrototype().MarshalJSON(queryResponse) +} +func (queryResponse *QueryResponse) Decode(bytes []byte) (helpers.QueryResponse, error) { + if err := base.CodecPrototype().UnmarshalJSON(bytes, queryResponse); err != nil { + return nil, err + } + + return queryResponse, nil +} +func responsePrototype() helpers.QueryResponse { + return &QueryResponse{} +} +func newQueryResponse(parameterList lists.ParameterList) *QueryResponse { + return &QueryResponse{ + ParameterList: parameterList.(*baseLists.ParameterList), + } +} diff --git a/x/classifications/queries/parameters/query_response.pb.go b/x/classifications/queries/parameters/query_response.pb.go new file mode 100644 index 000000000..bd5276a60 --- /dev/null +++ b/x/classifications/queries/parameters/query_response.pb.go @@ -0,0 +1,338 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: AssetMantle/modules/x/classifications/queries/parameters/query_response.proto + +package parameters + +import ( + fmt "fmt" + base "github.com/AssetMantle/schema/lists/base" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type QueryResponse struct { + ParameterList *base.ParameterList `protobuf:"bytes,1,opt,name=parameter_list,json=parameterList,proto3" json:"parameter_list,omitempty"` +} + +func (m *QueryResponse) Reset() { *m = QueryResponse{} } +func (m *QueryResponse) String() string { return proto.CompactTextString(m) } +func (*QueryResponse) ProtoMessage() {} +func (*QueryResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_84d0e8b7cbb0d9b5, []int{0} +} +func (m *QueryResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryResponse.Merge(m, src) +} +func (m *QueryResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryResponse proto.InternalMessageInfo + +func (m *QueryResponse) GetParameterList() *base.ParameterList { + if m != nil { + return m.ParameterList + } + return nil +} + +func init() { + proto.RegisterType((*QueryResponse)(nil), "AssetMantle.modules.x.classifications.queries.parameters.QueryResponse") +} + +func init() { + proto.RegisterFile("AssetMantle/modules/x/classifications/queries/parameters/query_response.proto", fileDescriptor_84d0e8b7cbb0d9b5) +} + +var fileDescriptor_84d0e8b7cbb0d9b5 = []byte{ + // 346 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x92, 0xbf, 0x4e, 0xc3, 0x30, + 0x10, 0x87, 0x9b, 0x20, 0x75, 0x08, 0x2a, 0x43, 0x27, 0xc4, 0x10, 0x21, 0x26, 0x06, 0x74, 0x96, + 0xca, 0x82, 0x2c, 0x18, 0xda, 0x22, 0xb1, 0x10, 0x29, 0x2d, 0x4b, 0x84, 0x2c, 0x55, 0x6e, 0x6a, + 0xa8, 0xa5, 0xa4, 0x0e, 0x39, 0x57, 0x2a, 0x6f, 0xc1, 0x33, 0x30, 0xf2, 0x02, 0xbc, 0x02, 0x62, + 0xea, 0xc8, 0x88, 0xd2, 0x8d, 0xa7, 0x40, 0x69, 0x0d, 0xf9, 0x33, 0x66, 0xf4, 0xc9, 0xbf, 0xef, + 0xbe, 0xf3, 0xd9, 0xf1, 0xfa, 0x88, 0x42, 0x7b, 0x7c, 0xa1, 0x23, 0x41, 0x62, 0x35, 0x5b, 0x46, + 0x02, 0xc9, 0x8a, 0x84, 0x11, 0x47, 0x94, 0x0f, 0x32, 0xe4, 0x5a, 0xaa, 0x05, 0x92, 0xa7, 0xa5, + 0x48, 0xa5, 0x40, 0x92, 0xf0, 0x94, 0xc7, 0x42, 0x8b, 0x74, 0x57, 0x7a, 0x9e, 0xa4, 0x02, 0x13, + 0xb5, 0x40, 0x01, 0x49, 0xaa, 0xb4, 0xea, 0x5e, 0x94, 0x70, 0x60, 0x70, 0xb0, 0x82, 0x1a, 0x0e, + 0x0c, 0x0e, 0x0a, 0xdc, 0x51, 0xaf, 0x2c, 0x82, 0xe1, 0x5c, 0xc4, 0x9c, 0x44, 0x12, 0x35, 0x92, + 0x29, 0x47, 0x51, 0x34, 0x9e, 0xe4, 0xc5, 0x5d, 0xb7, 0x93, 0x99, 0xd3, 0x19, 0xe5, 0x16, 0x63, + 0x23, 0xd1, 0xbd, 0x73, 0x0e, 0xaa, 0x17, 0x0f, 0xad, 0x63, 0xeb, 0x74, 0xbf, 0x77, 0x06, 0x65, + 0xaf, 0x1d, 0x1d, 0xb6, 0x74, 0xc8, 0xe9, 0xe0, 0xff, 0x85, 0x6e, 0x25, 0xea, 0x71, 0x27, 0x29, + 0x1f, 0x07, 0xef, 0x7b, 0x1f, 0x99, 0x6b, 0xad, 0x33, 0xd7, 0xfa, 0xce, 0x5c, 0xeb, 0x65, 0xe3, + 0xb6, 0xd6, 0x1b, 0xb7, 0xf5, 0xb5, 0x71, 0x5b, 0xce, 0x65, 0xa8, 0x62, 0x68, 0x3a, 0xf2, 0xa0, + 0x5b, 0x91, 0xf7, 0xf3, 0x91, 0x7c, 0xeb, 0x7e, 0xf8, 0x28, 0xf5, 0x7c, 0x39, 0x85, 0x50, 0xc5, + 0xa4, 0xe9, 0x72, 0x5e, 0xed, 0x76, 0xdf, 0x0b, 0x86, 0x23, 0xff, 0xcd, 0xae, 0x6c, 0xc4, 0x33, + 0x7a, 0x01, 0x0c, 0x6b, 0x7a, 0x23, 0xa3, 0xf7, 0xff, 0x12, 0xf8, 0x59, 0x89, 0x32, 0x13, 0x65, + 0x01, 0xab, 0x45, 0x99, 0x89, 0xb2, 0x22, 0x9a, 0xd9, 0xd7, 0x4d, 0xa3, 0xec, 0xc6, 0x1f, 0x78, + 0x42, 0xf3, 0x19, 0xd7, 0xfc, 0xc7, 0xbe, 0x2a, 0x61, 0x28, 0x35, 0x1c, 0x4a, 0x03, 0x4a, 0x6b, + 0x24, 0x4a, 0x0d, 0x8a, 0xd2, 0x82, 0x35, 0x6d, 0x6f, 0xbf, 0xc9, 0xf9, 0x6f, 0x00, 0x00, 0x00, + 0xff, 0xff, 0x6c, 0x7f, 0x56, 0xa4, 0xe5, 0x02, 0x00, 0x00, +} + +func (m *QueryResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.ParameterList != nil { + { + size, err := m.ParameterList.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQueryResponse(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintQueryResponse(dAtA []byte, offset int, v uint64) int { + offset -= sovQueryResponse(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *QueryResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ParameterList != nil { + l = m.ParameterList.Size() + n += 1 + l + sovQueryResponse(uint64(l)) + } + return n +} + +func sovQueryResponse(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQueryResponse(x uint64) (n int) { + return sovQueryResponse(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QueryResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQueryResponse + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ParameterList", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQueryResponse + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQueryResponse + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQueryResponse + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.ParameterList == nil { + m.ParameterList = &base.ParameterList{} + } + if err := m.ParameterList.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQueryResponse(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQueryResponse + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipQueryResponse(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQueryResponse + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQueryResponse + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQueryResponse + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthQueryResponse + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupQueryResponse + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthQueryResponse + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthQueryResponse = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowQueryResponse = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupQueryResponse = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/classifications/queries/parameters/service.pb.go b/x/classifications/queries/parameters/service.pb.go new file mode 100644 index 000000000..f92e3151d --- /dev/null +++ b/x/classifications/queries/parameters/service.pb.go @@ -0,0 +1,135 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: AssetMantle/modules/x/classifications/queries/parameters/service.proto + +package parameters + +import ( + context "context" + fmt "fmt" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + math "math" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +func init() { + proto.RegisterFile("AssetMantle/modules/x/classifications/queries/parameters/service.proto", fileDescriptor_1bb312b6553bb004) +} + +var fileDescriptor_1bb312b6553bb004 = []byte{ + // 336 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0xd2, 0x31, 0x4b, 0xc3, 0x40, + 0x14, 0x07, 0xf0, 0x24, 0x62, 0x87, 0xe0, 0xd4, 0xb1, 0x43, 0x06, 0x3f, 0xc0, 0x1d, 0xe8, 0x22, + 0x87, 0x0e, 0x6d, 0xa5, 0x75, 0x30, 0x90, 0xea, 0x12, 0x24, 0x20, 0xd7, 0xf4, 0xa9, 0x07, 0x49, + 0xae, 0xbd, 0x77, 0x91, 0xfa, 0x2d, 0xdc, 0xdd, 0x04, 0x17, 0x37, 0xbf, 0x85, 0x38, 0x75, 0x74, + 0x94, 0x74, 0xf3, 0x53, 0x48, 0x9b, 0xc3, 0xb4, 0x19, 0xd3, 0x35, 0xe1, 0xff, 0xcb, 0xff, 0xbd, + 0x3c, 0x77, 0xd0, 0x45, 0x04, 0xed, 0xf3, 0x4c, 0x27, 0x40, 0x53, 0x39, 0xc9, 0x13, 0x40, 0x3a, + 0xa7, 0x71, 0xc2, 0x11, 0xc5, 0x9d, 0x88, 0xb9, 0x16, 0x32, 0x43, 0x3a, 0xcb, 0x41, 0x09, 0x40, + 0x3a, 0xe5, 0x8a, 0xa7, 0xa0, 0x41, 0x21, 0x45, 0x50, 0x8f, 0x22, 0x06, 0x32, 0x55, 0x52, 0xcb, + 0xf6, 0xc9, 0x86, 0x43, 0x8c, 0x43, 0xe6, 0xa4, 0xe6, 0x10, 0xe3, 0x90, 0xca, 0xe9, 0x5c, 0x36, + 0x6e, 0xb0, 0x7a, 0xf4, 0x74, 0xab, 0x60, 0x96, 0x03, 0xea, 0xb2, 0x47, 0xc7, 0xdf, 0x59, 0xc3, + 0xa9, 0xcc, 0xd0, 0x8c, 0x75, 0xf4, 0x66, 0xbb, 0xfb, 0xa3, 0xd5, 0x8b, 0xf6, 0x8b, 0xed, 0xb6, + 0x2e, 0x78, 0x36, 0x49, 0xa0, 0x3d, 0x20, 0x4d, 0x87, 0x25, 0x6b, 0xeb, 0xaa, 0x6c, 0xdc, 0x19, + 0xee, 0xec, 0x94, 0x5d, 0x0f, 0xad, 0xde, 0xc7, 0xde, 0x67, 0xe1, 0xd9, 0x8b, 0xc2, 0xb3, 0x7f, + 0x0a, 0xcf, 0x7e, 0x5e, 0x7a, 0xd6, 0x62, 0xe9, 0x59, 0xdf, 0x4b, 0xcf, 0x72, 0x4f, 0x63, 0x99, + 0x36, 0xfe, 0x50, 0xef, 0xe0, 0xba, 0xfc, 0xcd, 0xc1, 0x6a, 0x1d, 0x81, 0x7d, 0xd3, 0xbf, 0x17, + 0xfa, 0x21, 0x1f, 0x93, 0x58, 0xa6, 0xb4, 0xe9, 0xaa, 0x5f, 0x9d, 0x56, 0xd7, 0x0f, 0xfb, 0xa3, + 0xe0, 0xdd, 0xd9, 0x3a, 0x1b, 0xdf, 0x14, 0x0b, 0x49, 0xbf, 0x56, 0x6c, 0x64, 0x8a, 0x05, 0xff, + 0xc6, 0xd7, 0x56, 0x34, 0x32, 0xd1, 0x28, 0x8c, 0x6a, 0xd1, 0xc8, 0x44, 0xa3, 0x2a, 0x5a, 0x38, + 0xe7, 0x4d, 0xa3, 0xd1, 0x30, 0xe8, 0xf9, 0xa0, 0xf9, 0x84, 0x6b, 0xfe, 0xeb, 0x9c, 0x6d, 0x30, + 0x8c, 0x19, 0x87, 0xb1, 0x90, 0xb1, 0x9a, 0xc4, 0x98, 0xa1, 0x18, 0xab, 0xac, 0x71, 0x6b, 0x7d, + 0x62, 0xc7, 0x7f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x39, 0x21, 0xd1, 0xbb, 0x83, 0x03, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// QueryClient is the client API for Query service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type QueryClient interface { + Handle(ctx context.Context, in *QueryRequest, opts ...grpc.CallOption) (*QueryResponse, error) +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +func (c *queryClient) Handle(ctx context.Context, in *QueryRequest, opts ...grpc.CallOption) (*QueryResponse, error) { + out := new(QueryResponse) + err := c.cc.Invoke(ctx, "/AssetMantle.modules.x.classifications.queries.parameters.Query/Handle", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +type QueryServer interface { + Handle(context.Context, *QueryRequest) (*QueryResponse, error) +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func (*UnimplementedQueryServer) Handle(ctx context.Context, req *QueryRequest) (*QueryResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Handle not implemented") +} + +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) +} + +func _Query_Handle_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Handle(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/AssetMantle.modules.x.classifications.queries.parameters.Query/Handle", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Handle(ctx, req.(*QueryRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "AssetMantle.modules.x.classifications.queries.parameters.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Handle", + Handler: _Query_Handle_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "AssetMantle/modules/x/classifications/queries/parameters/service.proto", +} diff --git a/x/classifications/queries/prototype.go b/x/classifications/queries/prototype.go index 39b3be48c..83e8ac392 100644 --- a/x/classifications/queries/prototype.go +++ b/x/classifications/queries/prototype.go @@ -8,11 +8,13 @@ import ( baseHelpers "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/x/classifications/queries/classification" "github.com/AssetMantle/modules/x/classifications/queries/classifications" + "github.com/AssetMantle/modules/x/classifications/queries/parameters" ) func Prototype() helpers.Queries { return baseHelpers.NewQueries( classification.Query, classifications.Query, + parameters.Query, ) } diff --git a/x/classifications/queries/prototype_test.go b/x/classifications/queries/prototype_test.go index cdf7edc6c..7208b15ee 100644 --- a/x/classifications/queries/prototype_test.go +++ b/x/classifications/queries/prototype_test.go @@ -14,8 +14,8 @@ import ( func TestPrototype(t *testing.T) { require.Panics(t, func() { - require.Equal(t, Prototype().GetQuery("classification").GetName(), baseHelpers.NewQueries( + require.Equal(t, Prototype().GetQuery("classification").GetServicePath(), baseHelpers.NewQueries( classification.Query, - ).GetQuery("classification").GetName()) + ).GetQuery("classification").GetServicePath()) }) } diff --git a/x/classifications/record/record.go b/x/classifications/record/record.go index 68f59c1fb..a7192eb16 100644 --- a/x/classifications/record/record.go +++ b/x/classifications/record/record.go @@ -1,13 +1,12 @@ package record import ( - "github.com/AssetMantle/schema/documents" - sdkTypes "github.com/cosmos/cosmos-sdk/types" - "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/x/classifications/key" "github.com/AssetMantle/modules/x/classifications/mappable" + "github.com/AssetMantle/schema/documents" + sdkTypes "github.com/cosmos/cosmos-sdk/types" ) func (record *Record) GetKey() helpers.Key { @@ -36,7 +35,7 @@ func (record *Record) Read(kvStore sdkTypes.KVStore) helpers.Record { if record.GetKey() == nil || len(record.GetKey().GeneratePrefixedStoreKeyBytes()) == 0 { return Prototype() } - Bytes := kvStore.Get(record.GetKey().GenerateStoreKeyBytes()) + Bytes := kvStore.Get(record.GetKey().GeneratePrefixedStoreKeyBytes()) if Bytes == nil { return Prototype() } @@ -51,7 +50,7 @@ func (record *Record) Write(kvStore sdkTypes.KVStore) helpers.Record { return record } func (record *Record) Delete(kvStore sdkTypes.KVStore) { - kvStore.Delete(record.GetKey().GenerateStoreKeyBytes()) + kvStore.Delete(record.GetKey().GeneratePrefixedStoreKeyBytes()) } func RecordsFromInterface(records []helpers.Record) []*Record { diff --git a/x/classifications/simulator/genesis.go b/x/classifications/simulator/genesis.go index d6e49e27d..ed72dffdb 100644 --- a/x/classifications/simulator/genesis.go +++ b/x/classifications/simulator/genesis.go @@ -4,8 +4,6 @@ package simulator import ( - "math/rand" - "github.com/AssetMantle/schema/data" baseData "github.com/AssetMantle/schema/data/base" "github.com/AssetMantle/schema/documents/base" @@ -14,6 +12,7 @@ import ( baseQualified "github.com/AssetMantle/schema/qualified/base" sdkTypes "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" + "math/rand" "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" diff --git a/x/classifications/simulator/operations.go b/x/classifications/simulator/operations.go index 9b2ee1b23..524fa0e87 100644 --- a/x/classifications/simulator/operations.go +++ b/x/classifications/simulator/operations.go @@ -4,10 +4,9 @@ package simulator import ( - "math/rand" - "github.com/cosmos/cosmos-sdk/types/module" "github.com/cosmos/cosmos-sdk/x/simulation" + "math/rand" "github.com/AssetMantle/modules/helpers" ) diff --git a/x/classifications/simulator/params.go b/x/classifications/simulator/params.go index 218ebbea7..7bb8f8022 100644 --- a/x/classifications/simulator/params.go +++ b/x/classifications/simulator/params.go @@ -4,11 +4,10 @@ package simulator import ( - "math" - "math/rand" - simulationTypes "github.com/cosmos/cosmos-sdk/types/simulation" "github.com/cosmos/cosmos-sdk/x/simulation" + "math" + "math/rand" baseHelpers "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/x/classifications/constants" diff --git a/x/classifications/simulator/proposals.go b/x/classifications/simulator/proposals.go index 72d20f254..53aac918f 100644 --- a/x/classifications/simulator/proposals.go +++ b/x/classifications/simulator/proposals.go @@ -4,28 +4,28 @@ package simulator import ( - "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" - "math/rand" - - sdk "github.com/cosmos/cosmos-sdk/types" + sdkTypes "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" simulationTypes "github.com/cosmos/cosmos-sdk/types/simulation" + govSimulation "github.com/cosmos/cosmos-sdk/x/gov/simulation" + "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" "github.com/cosmos/cosmos-sdk/x/simulation" + "math/rand" ) -func (simulator) WeightedProposalContentList(module.SimulationState) []simulationTypes.WeightedProposalContent { - return []simulationTypes.WeightedProposalContent{ - simulation.NewWeightedProposalContent( +func (simulator) ProposalMessages(_ module.SimulationState) []simulationTypes.WeightedProposalMsg { + return []simulationTypes.WeightedProposalMsg{ + simulation.NewWeightedProposalMsg( OpWeightSubmitTextProposal, DefaultWeightTextProposal, - simulateTextProposalContent, + func(r *rand.Rand, _ sdkTypes.Context, simulationAccounts []simulationTypes.Account) sdkTypes.Msg { + msgSubmitProposal, err := v1beta1.NewMsgSubmitProposal(v1beta1.NewTextProposal(simulationTypes.RandStringOfLength(r, 140), simulationTypes.RandStringOfLength(r, 5000)), govSimulation.GenDepositParamsMinDeposit(r), simulationAccounts[r.Intn(len(simulationAccounts))].Address) + if err != nil { + panic(err) + } + + return msgSubmitProposal + }, ), } } - -func simulateTextProposalContent(r *rand.Rand, _ sdk.Context, _ []simulationTypes.Account) simulationTypes.Content { - return v1beta1.NewTextProposal( - simulationTypes.RandStringOfLength(r, 140), - simulationTypes.RandStringOfLength(r, 5000), - ) -} diff --git a/x/identities/auxiliaries/authenticate/auxiliary_keeper.go b/x/identities/auxiliaries/authenticate/auxiliary_keeper.go index f4931941d..b515aabf2 100644 --- a/x/identities/auxiliaries/authenticate/auxiliary_keeper.go +++ b/x/identities/auxiliaries/authenticate/auxiliary_keeper.go @@ -5,9 +5,8 @@ package authenticate import ( "context" - errorConstants "github.com/AssetMantle/modules/helpers/constants" - "github.com/AssetMantle/modules/helpers" + errorConstants "github.com/AssetMantle/modules/helpers/constants" "github.com/AssetMantle/modules/x/identities/key" "github.com/AssetMantle/modules/x/identities/mappable" "github.com/AssetMantle/modules/x/metas/auxiliaries/supplement" diff --git a/x/identities/auxiliaries/authenticate/auxiliary_request.go b/x/identities/auxiliaries/authenticate/auxiliary_request.go index 7c2c3f543..bd9c8b1f3 100644 --- a/x/identities/auxiliaries/authenticate/auxiliary_request.go +++ b/x/identities/auxiliaries/authenticate/auxiliary_request.go @@ -4,11 +4,10 @@ package authenticate import ( + "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/helpers/constants" "github.com/AssetMantle/schema/ids" sdkTypes "github.com/cosmos/cosmos-sdk/types" - - "github.com/AssetMantle/modules/helpers" ) type auxiliaryRequest struct { diff --git a/x/identities/block/block.go b/x/identities/block/block.go index 1cbdcc3d6..36d85c5ae 100644 --- a/x/identities/block/block.go +++ b/x/identities/block/block.go @@ -5,7 +5,6 @@ package block import ( "context" - abciTypes "github.com/cometbft/cometbft/abci/types" "github.com/AssetMantle/modules/helpers" diff --git a/x/identities/genesis/genesis.go b/x/identities/genesis/genesis.go index f4226b0aa..591f25d67 100644 --- a/x/identities/genesis/genesis.go +++ b/x/identities/genesis/genesis.go @@ -3,7 +3,6 @@ package genesis import ( "context" errorConstants "github.com/AssetMantle/modules/helpers/constants" - baseDocuments "github.com/AssetMantle/schema/documents/base" "github.com/AssetMantle/schema/lists" "github.com/AssetMantle/schema/lists/base" diff --git a/x/identities/key/key.go b/x/identities/key/key.go index 45ecb2c01..7b89de551 100644 --- a/x/identities/key/key.go +++ b/x/identities/key/key.go @@ -4,11 +4,10 @@ package key import ( + "github.com/AssetMantle/modules/helpers" errorConstants "github.com/AssetMantle/modules/helpers/constants" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" - - "github.com/AssetMantle/modules/helpers" ) var _ helpers.Key = (*Key)(nil) @@ -22,7 +21,7 @@ func (key *Key) ValidateBasic() error { return nil } func (key *Key) GenerateStorePrefixBytes() []byte { - return []byte{} + return []byte{0x0} } func (key *Key) GenerateStoreKeyBytes() []byte { return key.IdentityID.Bytes() diff --git a/x/identities/mappable/mappable.go b/x/identities/mappable/mappable.go index 3c131fc58..817fec96a 100644 --- a/x/identities/mappable/mappable.go +++ b/x/identities/mappable/mappable.go @@ -4,12 +4,9 @@ package mappable import ( - codecUtilities "github.com/AssetMantle/schema/codec/utilities" + "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/schema/documents" "github.com/AssetMantle/schema/documents/base" - "github.com/cosmos/cosmos-sdk/codec" - - "github.com/AssetMantle/modules/helpers" ) var _ helpers.Mappable = (*Mappable)(nil) @@ -17,9 +14,6 @@ var _ helpers.Mappable = (*Mappable)(nil) func (mappable *Mappable) ValidateBasic() error { return mappable.Identity.ValidateBasic() } -func (*Mappable) RegisterLegacyAminoCodec(legacyAmino *codec.LegacyAmino) { - codecUtilities.RegisterModuleConcrete(legacyAmino, Mappable{}) -} func NewMappable(identity documents.Identity) helpers.Mappable { return &Mappable{ diff --git a/x/identities/mappable/mappable_test.go b/x/identities/mappable/mappable_test.go index 9fc182331..16843fabb 100644 --- a/x/identities/mappable/mappable_test.go +++ b/x/identities/mappable/mappable_test.go @@ -7,6 +7,7 @@ import ( "reflect" "testing" + "github.com/AssetMantle/modules/helpers" baseData "github.com/AssetMantle/schema/data/base" "github.com/AssetMantle/schema/documents" baseDocuments "github.com/AssetMantle/schema/documents/base" @@ -16,9 +17,6 @@ import ( baseProperties "github.com/AssetMantle/schema/properties/base" "github.com/AssetMantle/schema/qualified" baseQualified "github.com/AssetMantle/schema/qualified/base" - "github.com/cosmos/cosmos-sdk/codec" - - "github.com/AssetMantle/modules/helpers" ) func createTestInput() (documents.Identity, ids.ClassificationID, qualified.Immutables, qualified.Mutables) { @@ -68,30 +66,3 @@ func TestPrototype(t *testing.T) { }) } } - -func Test_identity_RegisterCodec(t *testing.T) { - testIdentity, _, _, _ := createTestInput() - - type fields struct { - Document documents.Identity - } - type args struct { - legacyAmino *codec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{testIdentity}, args{codec.NewLegacyAmino()}}, - {"+ve nil", fields{nil}, args{codec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - id := &Mappable{ - Identity: tt.fields.Document.Get().(*baseDocuments.Document), - } - id.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} diff --git a/x/identities/parameters/issue_enabled/parameter.go b/x/identities/parameters/issue_enabled/parameter.go index e2e674fa1..a03cd3498 100644 --- a/x/identities/parameters/issue_enabled/parameter.go +++ b/x/identities/parameters/issue_enabled/parameter.go @@ -4,13 +4,12 @@ package issue_enabled import ( + baseHelpers "github.com/AssetMantle/modules/helpers/base" errorConstants "github.com/AssetMantle/modules/helpers/constants" baseData "github.com/AssetMantle/schema/data/base" baseParameters "github.com/AssetMantle/schema/parameters/base" "github.com/AssetMantle/schema/properties/base" constantProperties "github.com/AssetMantle/schema/properties/constants" - - baseHelpers "github.com/AssetMantle/modules/helpers/base" ) var ID = constantProperties.IssueEnabledProperty.GetKey() diff --git a/x/identities/parameters/max_provision_address_count/parameter.go b/x/identities/parameters/max_provision_address_count/parameter.go index 2eba1171e..f6c4b7287 100644 --- a/x/identities/parameters/max_provision_address_count/parameter.go +++ b/x/identities/parameters/max_provision_address_count/parameter.go @@ -4,6 +4,7 @@ package max_provision_address_count import ( + baseHelpers "github.com/AssetMantle/modules/helpers/base" errorConstants "github.com/AssetMantle/modules/helpers/constants" baseData "github.com/AssetMantle/schema/data/base" "github.com/AssetMantle/schema/data/constants" @@ -11,8 +12,6 @@ import ( "github.com/AssetMantle/schema/properties/base" constantProperties "github.com/AssetMantle/schema/properties/constants" sdkTypes "github.com/cosmos/cosmos-sdk/types" - - baseHelpers "github.com/AssetMantle/modules/helpers/base" ) var ID = constantProperties.MaxProvisionAddressCountProperty.GetKey() diff --git a/x/identities/parameters/prototype.go b/x/identities/parameters/prototype.go index 4a09561ab..428e0edf5 100644 --- a/x/identities/parameters/prototype.go +++ b/x/identities/parameters/prototype.go @@ -6,12 +6,11 @@ package parameters import ( "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" - "github.com/AssetMantle/modules/x/identities/constants" "github.com/AssetMantle/modules/x/identities/parameters/issue_enabled" "github.com/AssetMantle/modules/x/identities/parameters/max_provision_address_count" "github.com/AssetMantle/modules/x/identities/parameters/quash_enabled" ) func Prototype() helpers.ParameterManager { - return baseHelpers.NewParameterManager(constants.ModuleName, issue_enabled.ValidatableParameter, max_provision_address_count.ValidatableParameter, quash_enabled.ValidatableParameter) + return baseHelpers.NewParameterManager(issue_enabled.ValidatableParameter, max_provision_address_count.ValidatableParameter, quash_enabled.ValidatableParameter) } diff --git a/x/identities/parameters/prototype_test.go b/x/identities/parameters/prototype_test.go index a4075975d..031efad01 100644 --- a/x/identities/parameters/prototype_test.go +++ b/x/identities/parameters/prototype_test.go @@ -9,7 +9,6 @@ import ( "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" - "github.com/AssetMantle/modules/x/identities/constants" "github.com/AssetMantle/modules/x/identities/parameters/max_provision_address_count" ) @@ -19,7 +18,7 @@ func TestPrototype(t *testing.T) { want helpers.ParameterManager }{ - {"+ve", baseHelpers.NewParameterManager(constants.ModuleName, max_provision_address_count.ValidatableParameter)}, + {"+ve", baseHelpers.NewParameterManager(max_provision_address_count.ValidatableParameter)}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { diff --git a/x/identities/parameters/quash_enabled/parameter.go b/x/identities/parameters/quash_enabled/parameter.go index 537c21572..74a1bae56 100644 --- a/x/identities/parameters/quash_enabled/parameter.go +++ b/x/identities/parameters/quash_enabled/parameter.go @@ -4,13 +4,12 @@ package quash_enabled import ( + baseHelpers "github.com/AssetMantle/modules/helpers/base" errorConstants "github.com/AssetMantle/modules/helpers/constants" baseData "github.com/AssetMantle/schema/data/base" baseParameters "github.com/AssetMantle/schema/parameters/base" "github.com/AssetMantle/schema/properties/base" constantProperties "github.com/AssetMantle/schema/properties/constants" - - baseHelpers "github.com/AssetMantle/modules/helpers/base" ) var ID = constantProperties.QuashEnabledProperty.GetKey() diff --git a/x/identities/queries/identities/query.go b/x/identities/queries/identities/query.go index 052a6253a..93a1c297d 100644 --- a/x/identities/queries/identities/query.go +++ b/x/identities/queries/identities/query.go @@ -1,26 +1,16 @@ package identities import ( - "context" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "google.golang.org/grpc" - "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" helperConstants "github.com/AssetMantle/modules/helpers/constants" - "github.com/AssetMantle/modules/utilities/name" - "github.com/AssetMantle/modules/x/identities/constants" + "google.golang.org/grpc" ) -type dummy struct{} - var Query = baseHelpers.NewQuery( - name.GetPackageName(dummy{}), + _Query_serviceDesc.ServiceName, "", "", - constants.ModuleName, requestPrototype, responsePrototype, @@ -29,9 +19,6 @@ var Query = baseHelpers.NewQuery( func(server grpc.ServiceRegistrar, QueryKeeper helpers.QueryKeeper) { RegisterQueryServer(server, QueryKeeper.(queryKeeper)) }, - func(clientContext client.Context, serveMux *runtime.ServeMux) error { - return RegisterQueryHandlerClient(context.Background(), serveMux, NewQueryClient(clientContext)) - }, helperConstants.IdentityID, helperConstants.Limit, diff --git a/x/identities/queries/identities/query_keeper.go b/x/identities/queries/identities/query_keeper.go index 35de5c225..24e42ebc7 100644 --- a/x/identities/queries/identities/query_keeper.go +++ b/x/identities/queries/identities/query_keeper.go @@ -5,7 +5,6 @@ package identities import ( "context" - "github.com/AssetMantle/modules/helpers" ) @@ -16,7 +15,7 @@ type queryKeeper struct { var _ helpers.QueryKeeper = (*queryKeeper)(nil) func (queryKeeper queryKeeper) Enquire(context context.Context, queryRequest helpers.QueryRequest) (helpers.QueryResponse, error) { - queryResponse, err := queryKeeper.Handle(context, queryRequestFromInterface(queryRequest)) + queryResponse, err := queryKeeper.Handle(context, queryRequest.(*QueryRequest)) return queryResponse, err } func (queryKeeper queryKeeper) Handle(context context.Context, queryRequest *QueryRequest) (*QueryResponse, error) { diff --git a/x/identities/queries/identities/query_request.go b/x/identities/queries/identities/query_request.go index 00f10e1d9..83731c1a4 100644 --- a/x/identities/queries/identities/query_request.go +++ b/x/identities/queries/identities/query_request.go @@ -13,7 +13,6 @@ import ( "github.com/cosmos/cosmos-sdk/types/query" "github.com/AssetMantle/modules/helpers" - "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/helpers/constants" "github.com/AssetMantle/modules/x/identities/key" ) @@ -67,27 +66,10 @@ func (*QueryRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.QueryRe } return newQueryRequest(identityID.(ids.IdentityID), int32(limit)), nil } -func (queryRequest *QueryRequest) Encode() ([]byte, error) { - return base.CodecPrototype().MarshalJSON(queryRequest) -} -func (queryRequest *QueryRequest) Decode(bytes []byte) (helpers.QueryRequest, error) { - if err := base.CodecPrototype().UnmarshalJSON(bytes, queryRequest); err != nil { - return nil, err - } - - return queryRequest, nil -} func requestPrototype() helpers.QueryRequest { return &QueryRequest{} } -func queryRequestFromInterface(request helpers.QueryRequest) *QueryRequest { - switch value := request.(type) { - case *QueryRequest: - return value - default: - return &QueryRequest{} - } -} + func newQueryRequest(identityID ids.IdentityID, limit int32) helpers.QueryRequest { return &QueryRequest{Key: key.NewKey(identityID).(*key.Key), Limit: limit} } diff --git a/x/identities/queries/identities/service.pb.go b/x/identities/queries/identities/service.pb.go index 96b7f0747..ed64dfbf0 100644 --- a/x/identities/queries/identities/service.pb.go +++ b/x/identities/queries/identities/service.pb.go @@ -8,7 +8,6 @@ import ( fmt "fmt" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" - _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -31,30 +30,27 @@ func init() { } var fileDescriptor_4aeac867eb0910c3 = []byte{ - // 365 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x92, 0xb1, 0x6a, 0xeb, 0x30, - 0x14, 0x86, 0x63, 0x5f, 0x6e, 0x06, 0x73, 0x27, 0x8f, 0xe1, 0xe2, 0xe1, 0xc2, 0xa5, 0x53, 0x25, - 0xd2, 0x0c, 0x2d, 0x1a, 0x5a, 0xec, 0x25, 0xc9, 0x60, 0x48, 0xda, 0xc5, 0x14, 0x43, 0x51, 0xe2, - 0x43, 0x6a, 0xb0, 0xa5, 0xc4, 0x92, 0x43, 0xba, 0xf6, 0x09, 0x0a, 0x79, 0x83, 0x8e, 0x7d, 0x88, - 0xce, 0xa1, 0x53, 0xa0, 0x4b, 0xc7, 0xe2, 0x74, 0xea, 0x53, 0x14, 0xc7, 0x02, 0x2b, 0xab, 0x33, - 0x09, 0x7e, 0x9f, 0xff, 0xe3, 0xff, 0x8f, 0x8f, 0xe5, 0xba, 0x42, 0x80, 0xf4, 0x29, 0x93, 0x09, - 0xe0, 0x94, 0x47, 0x79, 0x02, 0x02, 0xaf, 0x70, 0x1c, 0x01, 0x93, 0xb1, 0x8c, 0x41, 0xe0, 0x45, - 0x0e, 0x59, 0xf9, 0x6a, 0x92, 0x80, 0x6c, 0x19, 0x4f, 0x01, 0xcd, 0x33, 0x2e, 0xb9, 0xdd, 0xd3, - 0x10, 0x48, 0x21, 0xd0, 0x0a, 0xd5, 0xf3, 0x48, 0x21, 0x34, 0xa9, 0xf3, 0x77, 0xc6, 0xf9, 0x2c, - 0x01, 0x4c, 0xe7, 0x31, 0xa6, 0x8c, 0x71, 0x49, 0x65, 0xcc, 0x99, 0xa8, 0x90, 0x9d, 0x7e, 0x93, - 0x54, 0xa5, 0xf4, 0x70, 0x97, 0xc1, 0x22, 0x07, 0x21, 0x15, 0x68, 0x70, 0x0c, 0x48, 0xcc, 0x39, - 0x13, 0xaa, 0xe5, 0xd9, 0xc6, 0xb0, 0x7e, 0x8f, 0xcb, 0x0f, 0xf6, 0xab, 0x61, 0xb5, 0x07, 0x94, - 0x45, 0x09, 0xd8, 0x2e, 0x6a, 0xd0, 0x1d, 0xed, 0x31, 0xd7, 0x55, 0xce, 0x8e, 0x77, 0x0c, 0xa2, - 0x4a, 0xf8, 0xef, 0xf4, 0xf1, 0xfd, 0x6b, 0x6d, 0x9e, 0xd8, 0xff, 0x71, 0x5a, 0x35, 0xd5, 0xca, - 0x2c, 0xbb, 0x13, 0x90, 0xb4, 0xab, 0x49, 0xde, 0xfa, 0xd7, 0xa6, 0x70, 0x8c, 0x6d, 0xe1, 0x18, - 0x9f, 0x85, 0x63, 0x3c, 0xed, 0x9c, 0xd6, 0x76, 0xe7, 0xb4, 0x3e, 0x76, 0x4e, 0xcb, 0x3a, 0x9f, - 0xf2, 0xb4, 0x49, 0x20, 0xef, 0xcf, 0x4d, 0x75, 0x13, 0xa3, 0x72, 0x59, 0x23, 0xe3, 0xf6, 0x72, - 0x16, 0xcb, 0xfb, 0x7c, 0x82, 0xa6, 0x3c, 0xc5, 0x0d, 0xfe, 0xc1, 0xb3, 0xd9, 0x76, 0xfd, 0x60, - 0x38, 0x1e, 0xbe, 0x98, 0x07, 0xe7, 0xe5, 0xab, 0x38, 0x01, 0x1a, 0x1e, 0x2e, 0xa3, 0x7c, 0x6b, - 0xe9, 0xed, 0xc0, 0x15, 0x2a, 0x57, 0x18, 0x84, 0xf5, 0x48, 0xa8, 0x5c, 0x9a, 0x54, 0x98, 0x57, - 0x0d, 0x5c, 0x61, 0x7f, 0xe4, 0xf9, 0x20, 0x69, 0x44, 0x25, 0xfd, 0x36, 0x2f, 0x34, 0x02, 0x21, - 0x0a, 0x41, 0x48, 0x40, 0x48, 0xed, 0x20, 0x44, 0x51, 0x74, 0x71, 0xd2, 0xde, 0xdf, 0x59, 0xef, - 0x27, 0x00, 0x00, 0xff, 0xff, 0x9d, 0x9e, 0xc8, 0x96, 0x92, 0x03, 0x00, 0x00, + // 317 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x72, 0x74, 0x2c, 0x2e, 0x4e, + 0x2d, 0xf1, 0x4d, 0xcc, 0x2b, 0xc9, 0x49, 0xd5, 0xcf, 0xcd, 0x4f, 0x29, 0xcd, 0x49, 0x2d, 0xd6, + 0xaf, 0xd0, 0xcf, 0x4c, 0x49, 0xcd, 0x2b, 0xc9, 0x2c, 0xc9, 0x4c, 0x2d, 0xd6, 0x2f, 0x2c, 0x4d, + 0x2d, 0x02, 0xd1, 0x48, 0x42, 0xc5, 0xa9, 0x45, 0x65, 0x99, 0xc9, 0xa9, 0x7a, 0x05, 0x45, 0xf9, + 0x25, 0xf9, 0x42, 0xc6, 0x48, 0x46, 0xe8, 0x41, 0x8d, 0xd0, 0xab, 0xd0, 0x43, 0xa8, 0xd7, 0x83, + 0x1a, 0x81, 0x24, 0x24, 0xe5, 0x4e, 0x8e, 0xbd, 0x20, 0xa1, 0xca, 0xf8, 0xa2, 0xd4, 0xc2, 0xd2, + 0xd4, 0xe2, 0x12, 0x88, 0xed, 0x52, 0x1e, 0x94, 0x18, 0x54, 0x5c, 0x90, 0x9f, 0x57, 0x0c, 0xf5, + 0x87, 0xd1, 0x6c, 0x46, 0x2e, 0xd6, 0x40, 0x90, 0x84, 0xd0, 0x44, 0x46, 0x2e, 0x36, 0x8f, 0xc4, + 0xbc, 0x94, 0x9c, 0x54, 0x21, 0x47, 0x3d, 0x32, 0x7c, 0xa7, 0x07, 0x36, 0x26, 0x08, 0xe2, 0x4e, + 0x29, 0x27, 0x4a, 0x8c, 0x80, 0xb8, 0x50, 0x89, 0xc1, 0x69, 0x32, 0xf3, 0x89, 0x47, 0x72, 0x8c, + 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0xc3, 0x85, 0xc7, 0x72, + 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x70, 0x99, 0x27, 0xe7, 0xe7, 0x92, 0x63, 0x87, 0x13, 0x4f, 0x30, + 0x24, 0x22, 0x03, 0x40, 0xfe, 0x0f, 0x60, 0x8c, 0xb2, 0x4b, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, + 0x4b, 0xce, 0xcf, 0xd5, 0x27, 0x23, 0x58, 0x17, 0x31, 0xb1, 0x39, 0xfa, 0x46, 0x78, 0x06, 0x7a, + 0xae, 0x62, 0x42, 0x49, 0x13, 0xbe, 0x50, 0xe7, 0x44, 0xe8, 0x79, 0xa2, 0xfa, 0x0f, 0x44, 0x23, + 0x84, 0x4e, 0xa1, 0xe8, 0x8a, 0x81, 0xea, 0x8a, 0x89, 0x88, 0x41, 0x28, 0x89, 0x81, 0xea, 0x42, + 0x12, 0x7a, 0xc4, 0x64, 0x4f, 0x86, 0xae, 0x18, 0xf7, 0x00, 0x27, 0xdf, 0xd4, 0x92, 0xc4, 0x94, + 0xc4, 0x92, 0xc4, 0x57, 0x4c, 0x16, 0x48, 0x26, 0x58, 0x59, 0x41, 0x8d, 0xb0, 0xb2, 0x8a, 0xb0, + 0xb2, 0x42, 0xe8, 0xb0, 0xb2, 0x82, 0x9a, 0x82, 0x2c, 0x98, 0xc4, 0x06, 0x4e, 0x3a, 0xc6, 0x80, + 0x00, 0x00, 0x00, 0xff, 0xff, 0xba, 0x94, 0xaf, 0xd6, 0x47, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/identities/queries/identities/service.pb.gw.go b/x/identities/queries/identities/service.pb.gw.go deleted file mode 100644 index 14859fd46..000000000 --- a/x/identities/queries/identities/service.pb.gw.go +++ /dev/null @@ -1,171 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: AssetMantle/modules/x/identities/queries/identities/service.proto - -/* -Package identities is a reverse proxy. - -It translates gRPC into RESTful JSON APIs. -*/ -package identities - -import ( - "context" - "io" - "net/http" - - "github.com/golang/protobuf/descriptor" - "github.com/golang/protobuf/proto" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/grpc-ecosystem/grpc-gateway/utilities" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/status" -) - -// Suppress "imported and not used" errors -var _ codes.Code -var _ io.Reader -var _ status.Status -var _ = runtime.String -var _ = utilities.NewDoubleArray -var _ = descriptor.ForMessage -var _ = metadata.Join - -var ( - filter_Query_Handle_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - -func request_Query_Handle_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryRequest - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.Handle(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_Handle_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryRequest - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.Handle(ctx, &protoReq) - return msg, metadata, err - -} - -// RegisterQueryHandlerServer registers the http handlers for service Query to "mux". -// UnaryRPC :call QueryServer directly. -// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. -func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { - - mux.Handle("GET", pattern_Query_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Query_Handle_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but -// automatically dials to "endpoint" and closes the connection when "ctx" gets done. -func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.Dial(endpoint, opts...) - if err != nil { - return err - } - defer func() { - if err != nil { - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - return - } - go func() { - <-ctx.Done() - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - }() - }() - - return RegisterQueryHandler(ctx, mux, conn) -} - -// RegisterQueryHandler registers the http handlers for service Query to "mux". -// The handlers forward requests to the grpc endpoint over "conn". -func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { - return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn)) -} - -// RegisterQueryHandlerClient registers the http handlers for service Query -// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient". -// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient" -// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "QueryClient" to call the correct interceptors. -func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { - - mux.Handle("GET", pattern_Query_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Query_Handle_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -var ( - pattern_Query_Handle_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 1}, []string{"mantle", "identities", "v1beta1"}, "", runtime.AssumeColonVerbOpt(false))) -) - -var ( - forward_Query_Handle_0 = runtime.ForwardResponseMessage -) diff --git a/x/identities/queries/identity/query.go b/x/identities/queries/identity/query.go index 2831fffeb..146f96394 100644 --- a/x/identities/queries/identity/query.go +++ b/x/identities/queries/identity/query.go @@ -4,28 +4,17 @@ package identity import ( - "context" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "google.golang.org/grpc" - "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" helperConstants "github.com/AssetMantle/modules/helpers/constants" - "github.com/AssetMantle/modules/utilities/name" - "github.com/AssetMantle/modules/x/identities/constants" + "google.golang.org/grpc" ) -type dummy struct{} - var Query = baseHelpers.NewQuery( - name.GetPackageName(dummy{}), + _Query_serviceDesc.ServiceName, "", "", - constants.ModuleName, - requestPrototype, responsePrototype, keeperPrototype, @@ -33,9 +22,6 @@ var Query = baseHelpers.NewQuery( func(server grpc.ServiceRegistrar, QueryKeeper helpers.QueryKeeper) { RegisterQueryServer(server, QueryKeeper.(queryKeeper)) }, - func(clientContext client.Context, serveMux *runtime.ServeMux) error { - return RegisterQueryHandlerClient(context.Background(), serveMux, NewQueryClient(clientContext)) - }, helperConstants.IdentityID, ) diff --git a/x/identities/queries/identity/query_keeper.go b/x/identities/queries/identity/query_keeper.go index 1e6ca171d..89e5ba7fa 100644 --- a/x/identities/queries/identity/query_keeper.go +++ b/x/identities/queries/identity/query_keeper.go @@ -5,7 +5,6 @@ package identity import ( "context" - "github.com/AssetMantle/modules/helpers" ) @@ -16,7 +15,7 @@ type queryKeeper struct { var _ helpers.QueryKeeper = (*queryKeeper)(nil) func (queryKeeper queryKeeper) Enquire(context context.Context, queryRequest helpers.QueryRequest) (helpers.QueryResponse, error) { - queryResponse, err := queryKeeper.Handle(context, queryRequestFromInterface(queryRequest)) + queryResponse, err := queryKeeper.Handle(context, queryRequest.(*QueryRequest)) return queryResponse, err } func (queryKeeper queryKeeper) Handle(context context.Context, queryRequest *QueryRequest) (*QueryResponse, error) { diff --git a/x/identities/queries/identity/query_request.go b/x/identities/queries/identity/query_request.go index ca7588a91..de416eca7 100644 --- a/x/identities/queries/identity/query_request.go +++ b/x/identities/queries/identity/query_request.go @@ -11,7 +11,6 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/AssetMantle/modules/helpers" - "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/helpers/constants" "github.com/AssetMantle/modules/x/identities/key" ) @@ -49,27 +48,10 @@ func (*QueryRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.QueryRe return newQueryRequest(identityID.(ids.IdentityID)), nil } } -func (queryRequest *QueryRequest) Encode() ([]byte, error) { - return base.CodecPrototype().MarshalJSON(queryRequest) -} -func (queryRequest *QueryRequest) Decode(bytes []byte) (helpers.QueryRequest, error) { - if err := base.CodecPrototype().UnmarshalJSON(bytes, queryRequest); err != nil { - return nil, err - } - - return queryRequest, nil -} func requestPrototype() helpers.QueryRequest { return &QueryRequest{} } -func queryRequestFromInterface(request helpers.QueryRequest) *QueryRequest { - switch value := request.(type) { - case *QueryRequest: - return value - default: - return &QueryRequest{} - } -} + func newQueryRequest(identityID ids.IdentityID) helpers.QueryRequest { return &QueryRequest{Key: key.NewKey(identityID).(*key.Key)} } diff --git a/x/identities/queries/identity/service.pb.go b/x/identities/queries/identity/service.pb.go index 519a7558a..5bc34becc 100644 --- a/x/identities/queries/identity/service.pb.go +++ b/x/identities/queries/identity/service.pb.go @@ -8,7 +8,6 @@ import ( fmt "fmt" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" - _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -31,31 +30,28 @@ func init() { } var fileDescriptor_6e63cefd0e75caab = []byte{ - // 373 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x92, 0x3f, 0x4b, 0xf3, 0x40, - 0x1c, 0xc7, 0x9b, 0x3c, 0x3c, 0x1d, 0xc2, 0x33, 0x65, 0x2c, 0x0f, 0x19, 0x14, 0x27, 0xe1, 0x8e, - 0x2a, 0x3a, 0x1c, 0x4a, 0x6d, 0xc1, 0x3f, 0x1d, 0x02, 0xad, 0x2e, 0x41, 0x02, 0x72, 0x6d, 0x7e, - 0xd4, 0x40, 0x72, 0xd7, 0xe6, 0x2e, 0xa5, 0x59, 0x5d, 0x5c, 0x05, 0xdf, 0x81, 0xa3, 0xaf, 0xc0, - 0xd9, 0x49, 0x9c, 0x0a, 0x2e, 0x8e, 0x92, 0x3a, 0xf9, 0x2a, 0x24, 0xcd, 0xb5, 0x69, 0xc7, 0x74, - 0x0a, 0x7c, 0xc3, 0xf7, 0xc3, 0xe7, 0x7b, 0xfc, 0x8c, 0x46, 0x53, 0x08, 0x90, 0x36, 0x65, 0x32, - 0x00, 0x1c, 0x72, 0x2f, 0x0e, 0x40, 0xe0, 0x09, 0xf6, 0x3d, 0x60, 0xd2, 0x97, 0x3e, 0x08, 0x3c, - 0x8a, 0x21, 0xca, 0xbe, 0x2a, 0x4a, 0xb0, 0x80, 0x68, 0xec, 0xf7, 0x01, 0x0d, 0x23, 0x2e, 0xb9, - 0x59, 0x5f, 0x01, 0x20, 0x05, 0x40, 0x13, 0x54, 0x00, 0x90, 0x02, 0x2c, 0xa2, 0xa4, 0xf6, 0x7f, - 0xc0, 0xf9, 0x20, 0x00, 0x4c, 0x87, 0x3e, 0xa6, 0x8c, 0x71, 0x49, 0xa5, 0xcf, 0x99, 0xc8, 0x81, - 0xb5, 0xd3, 0xf2, 0x46, 0x59, 0x90, 0xdc, 0x44, 0x30, 0x8a, 0x41, 0x48, 0x85, 0x39, 0xdb, 0x1c, - 0x23, 0x86, 0x9c, 0x09, 0xb5, 0x6f, 0xef, 0x55, 0x33, 0xfe, 0x76, 0xb3, 0x1f, 0xe6, 0x8b, 0x66, - 0x54, 0x2f, 0x28, 0xf3, 0x02, 0x30, 0x1b, 0xa8, 0xf4, 0x6a, 0x34, 0x87, 0x5c, 0xe6, 0x8e, 0xb5, - 0x93, 0xcd, 0x01, 0xb9, 0xdd, 0xd6, 0xee, 0xdd, 0xc7, 0xf7, 0xa3, 0xbe, 0x63, 0x6e, 0xe3, 0x30, - 0xdf, 0xb8, 0xb2, 0x6c, 0x5c, 0xef, 0x81, 0xa4, 0xf5, 0xe5, 0xb2, 0xd6, 0xfd, 0x9f, 0xb7, 0xd4, - 0xd2, 0xa6, 0xa9, 0xa5, 0x7d, 0xa5, 0x96, 0xf6, 0x30, 0xb3, 0x2a, 0xd3, 0x99, 0x55, 0xf9, 0x9c, - 0x59, 0x15, 0xe3, 0xa0, 0xcf, 0xc3, 0xf2, 0x32, 0xad, 0x7f, 0x57, 0xf9, 0x15, 0x74, 0xb2, 0x47, - 0xea, 0x68, 0xd7, 0x47, 0x03, 0x5f, 0xde, 0xc6, 0x3d, 0xd4, 0xe7, 0x21, 0x2e, 0xfd, 0xf2, 0x4f, - 0x7a, 0xb5, 0x69, 0x3b, 0xed, 0x6e, 0xfb, 0x59, 0x5f, 0x3b, 0x27, 0x5b, 0xa9, 0x38, 0xa8, 0x5d, - 0xa8, 0x74, 0x95, 0x8a, 0x8a, 0x92, 0xf7, 0xb5, 0x8e, 0xab, 0x3a, 0xae, 0xe3, 0x16, 0x1d, 0x57, - 0x75, 0x16, 0x51, 0x92, 0xea, 0xc7, 0xa5, 0x3b, 0xee, 0x79, 0xa7, 0x65, 0x83, 0xa4, 0x1e, 0x95, - 0xf4, 0x47, 0x3f, 0x5c, 0xe9, 0x13, 0xa2, 0x00, 0x84, 0x38, 0x84, 0x14, 0x08, 0x42, 0x14, 0x63, - 0x19, 0x26, 0xbd, 0xea, 0xfc, 0xaa, 0xf6, 0x7f, 0x03, 0x00, 0x00, 0xff, 0xff, 0xa3, 0x52, 0xbc, - 0xd3, 0x78, 0x03, 0x00, 0x00, + // 324 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xb2, 0x77, 0x2c, 0x2e, 0x4e, + 0x2d, 0xf1, 0x4d, 0xcc, 0x2b, 0xc9, 0x49, 0xd5, 0xcf, 0xcd, 0x4f, 0x29, 0xcd, 0x49, 0x2d, 0xd6, + 0xaf, 0xd0, 0xcf, 0x4c, 0x49, 0xcd, 0x2b, 0xc9, 0x2c, 0xc9, 0x4c, 0x2d, 0xd6, 0x2f, 0x2c, 0x4d, + 0x2d, 0x02, 0xd1, 0x50, 0xa1, 0x4a, 0xfd, 0xe2, 0xd4, 0xa2, 0xb2, 0xcc, 0xe4, 0x54, 0xbd, 0x82, + 0xa2, 0xfc, 0x92, 0x7c, 0x21, 0x43, 0x24, 0x03, 0xf4, 0xa0, 0x06, 0xe8, 0x55, 0xe8, 0x21, 0x0c, + 0xd0, 0x83, 0x1a, 0x00, 0x13, 0xaa, 0x94, 0x72, 0x25, 0xdd, 0x4e, 0x90, 0x40, 0x65, 0x7c, 0x51, + 0x6a, 0x61, 0x69, 0x6a, 0x71, 0x09, 0xc4, 0x66, 0x29, 0x37, 0xf2, 0x8d, 0x29, 0x2e, 0xc8, 0xcf, + 0x2b, 0x86, 0xfa, 0xc0, 0x68, 0x3a, 0x23, 0x17, 0x6b, 0x20, 0x48, 0x42, 0xa8, 0x97, 0x91, 0x8b, + 0xcd, 0x23, 0x31, 0x2f, 0x25, 0x27, 0x55, 0xc8, 0x5e, 0x8f, 0x64, 0x7f, 0xe9, 0x81, 0x0d, 0x09, + 0x82, 0xb8, 0x51, 0xca, 0x81, 0x7c, 0x03, 0x20, 0xae, 0x53, 0x62, 0x70, 0x6a, 0x67, 0x3e, 0xf1, + 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4, 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8, + 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, 0x06, 0x2e, 0xd3, 0xe4, 0xfc, 0x5c, 0xd2, 0x6d, 0x70, + 0xe2, 0x09, 0x86, 0x44, 0x5e, 0x00, 0xc8, 0xe7, 0x01, 0x8c, 0x51, 0x36, 0xe9, 0x99, 0x25, 0x19, + 0xa5, 0x49, 0x7a, 0xc9, 0xf9, 0xb9, 0xfa, 0x24, 0x07, 0xe7, 0x22, 0x26, 0x36, 0x47, 0xdf, 0x08, + 0xcf, 0x40, 0xcf, 0x55, 0x4c, 0x28, 0xa9, 0xc0, 0x17, 0xea, 0x94, 0x08, 0x3d, 0x4f, 0x84, 0x53, + 0x02, 0xa1, 0x4e, 0x81, 0x0a, 0x55, 0x9e, 0x42, 0xd1, 0x13, 0x03, 0xd5, 0x13, 0x13, 0x11, 0x83, + 0xd0, 0x13, 0x03, 0xd5, 0x03, 0x13, 0xaa, 0x7c, 0xc4, 0x64, 0x4b, 0xb2, 0x9e, 0x18, 0xf7, 0x00, + 0x27, 0xdf, 0xd4, 0x92, 0xc4, 0x94, 0xc4, 0x92, 0xc4, 0x57, 0x4c, 0x66, 0x48, 0xfa, 0xad, 0xac, + 0xa0, 0x06, 0x58, 0x59, 0x45, 0x58, 0x59, 0x21, 0x8c, 0xb0, 0xb2, 0x82, 0x9a, 0x01, 0x17, 0xac, + 0x4c, 0x62, 0x03, 0x27, 0x15, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x14, 0x08, 0x28, 0xa7, + 0x2f, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/identities/queries/identity/service.pb.gw.go b/x/identities/queries/identity/service.pb.gw.go deleted file mode 100644 index faef0f54f..000000000 --- a/x/identities/queries/identity/service.pb.gw.go +++ /dev/null @@ -1,171 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: AssetMantle/modules/x/identities/queries/identity/service.proto - -/* -Package identity is a reverse proxy. - -It translates gRPC into RESTful JSON APIs. -*/ -package identity - -import ( - "context" - "io" - "net/http" - - "github.com/golang/protobuf/descriptor" - "github.com/golang/protobuf/proto" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/grpc-ecosystem/grpc-gateway/utilities" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/status" -) - -// Suppress "imported and not used" errors -var _ codes.Code -var _ io.Reader -var _ status.Status -var _ = runtime.String -var _ = utilities.NewDoubleArray -var _ = descriptor.ForMessage -var _ = metadata.Join - -var ( - filter_Query_Handle_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - -func request_Query_Handle_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryRequest - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.Handle(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_Handle_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryRequest - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.Handle(ctx, &protoReq) - return msg, metadata, err - -} - -// RegisterQueryHandlerServer registers the http handlers for service Query to "mux". -// UnaryRPC :call QueryServer directly. -// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. -func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { - - mux.Handle("GET", pattern_Query_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Query_Handle_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but -// automatically dials to "endpoint" and closes the connection when "ctx" gets done. -func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.Dial(endpoint, opts...) - if err != nil { - return err - } - defer func() { - if err != nil { - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - return - } - go func() { - <-ctx.Done() - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - }() - }() - - return RegisterQueryHandler(ctx, mux, conn) -} - -// RegisterQueryHandler registers the http handlers for service Query to "mux". -// The handlers forward requests to the grpc endpoint over "conn". -func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { - return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn)) -} - -// RegisterQueryHandlerClient registers the http handlers for service Query -// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient". -// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient" -// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "QueryClient" to call the correct interceptors. -func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { - - mux.Handle("GET", pattern_Query_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Query_Handle_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -var ( - pattern_Query_Handle_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"mantle", "identities", "v1beta1", "identity"}, "", runtime.AssumeColonVerbOpt(false))) -) - -var ( - forward_Query_Handle_0 = runtime.ForwardResponseMessage -) diff --git a/x/identities/queries/parameters/query.go b/x/identities/queries/parameters/query.go new file mode 100644 index 000000000..cfe5be8fe --- /dev/null +++ b/x/identities/queries/parameters/query.go @@ -0,0 +1,21 @@ +package parameters + +import ( + "github.com/AssetMantle/modules/helpers" + baseHelpers "github.com/AssetMantle/modules/helpers/base" + "google.golang.org/grpc" +) + +var Query = baseHelpers.NewQuery( + _Query_serviceDesc.ServiceName, + "", + "", + + requestPrototype, + responsePrototype, + keeperPrototype, + + func(server grpc.ServiceRegistrar, QueryKeeper helpers.QueryKeeper) { + RegisterQueryServer(server, QueryKeeper.(queryKeeper)) + }, +) diff --git a/x/identities/queries/parameters/query_keeper.go b/x/identities/queries/parameters/query_keeper.go new file mode 100644 index 000000000..5ff196b53 --- /dev/null +++ b/x/identities/queries/parameters/query_keeper.go @@ -0,0 +1,31 @@ +package parameters + +import ( + "context" + "github.com/AssetMantle/modules/helpers" +) + +type queryKeeper struct { + parameterManager helpers.ParameterManager +} + +var _ helpers.QueryKeeper = (*queryKeeper)(nil) + +func (queryKeeper queryKeeper) Enquire(context context.Context, queryRequest helpers.QueryRequest) (helpers.QueryResponse, error) { + queryResponse, err := queryKeeper.Handle(context, queryRequest.(*QueryRequest)) + return queryResponse, err +} +func (queryKeeper queryKeeper) Handle(context context.Context, queryRequest *QueryRequest) (*QueryResponse, error) { + if err := queryRequest.Validate(); err != nil { + return nil, err + } + return newQueryResponse(queryKeeper.parameterManager.Fetch(context).Get()), nil +} +func (queryKeeper queryKeeper) Initialize(_ helpers.Mapper, parameterManager helpers.ParameterManager, _ []interface{}) helpers.Keeper { + queryKeeper.parameterManager = parameterManager + return queryKeeper +} + +func keeperPrototype() helpers.QueryKeeper { + return queryKeeper{} +} diff --git a/x/identities/queries/parameters/query_request.go b/x/identities/queries/parameters/query_request.go new file mode 100644 index 000000000..9f99e7a01 --- /dev/null +++ b/x/identities/queries/parameters/query_request.go @@ -0,0 +1,25 @@ +package parameters + +import ( + "github.com/AssetMantle/modules/helpers" + "github.com/cosmos/cosmos-sdk/client" + "net/http" +) + +var _ helpers.QueryRequest = (*QueryRequest)(nil) + +func (queryRequest *QueryRequest) Validate() error { + return nil +} + +func (queryRequest *QueryRequest) FromCLI(_ helpers.CLICommand, _ client.Context) (helpers.QueryRequest, error) { + return requestPrototype(), nil +} + +func (queryRequest *QueryRequest) FromHTTPRequest(_ *http.Request) (helpers.QueryRequest, error) { + return requestPrototype(), nil +} + +func requestPrototype() helpers.QueryRequest { + return &QueryRequest{} +} diff --git a/x/identities/queries/parameters/query_request.pb.go b/x/identities/queries/parameters/query_request.pb.go new file mode 100644 index 000000000..2d38a96ca --- /dev/null +++ b/x/identities/queries/parameters/query_request.pb.go @@ -0,0 +1,273 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: AssetMantle/modules/x/identities/queries/parameters/query_request.proto + +package parameters + +import ( + fmt "fmt" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type QueryRequest struct { +} + +func (m *QueryRequest) Reset() { *m = QueryRequest{} } +func (m *QueryRequest) String() string { return proto.CompactTextString(m) } +func (*QueryRequest) ProtoMessage() {} +func (*QueryRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_4c871cbdf1a0c549, []int{0} +} +func (m *QueryRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryRequest.Merge(m, src) +} +func (m *QueryRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryRequest proto.InternalMessageInfo + +func init() { + proto.RegisterType((*QueryRequest)(nil), "AssetMantle.modules.x.identities.queries.parameters.QueryRequest") +} + +func init() { + proto.RegisterFile("AssetMantle/modules/x/identities/queries/parameters/query_request.proto", fileDescriptor_4c871cbdf1a0c549) +} + +var fileDescriptor_4c871cbdf1a0c549 = []byte{ + // 275 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x72, 0x77, 0x2c, 0x2e, 0x4e, + 0x2d, 0xf1, 0x4d, 0xcc, 0x2b, 0xc9, 0x49, 0xd5, 0xcf, 0xcd, 0x4f, 0x29, 0xcd, 0x49, 0x2d, 0xd6, + 0xaf, 0xd0, 0xcf, 0x4c, 0x49, 0xcd, 0x2b, 0xc9, 0x2c, 0xc9, 0x4c, 0x2d, 0xd6, 0x2f, 0x2c, 0x4d, + 0x2d, 0x02, 0xd1, 0x05, 0x89, 0x45, 0x89, 0xb9, 0xa9, 0x25, 0xa9, 0x45, 0x10, 0xa1, 0xca, 0xf8, + 0xa2, 0xd4, 0xc2, 0xd2, 0xd4, 0xe2, 0x12, 0xbd, 0x82, 0xa2, 0xfc, 0x92, 0x7c, 0x21, 0x63, 0x24, + 0x83, 0xf4, 0xa0, 0x06, 0xe9, 0x55, 0xe8, 0x21, 0x0c, 0xd2, 0x83, 0x1a, 0xa4, 0x87, 0x30, 0x48, + 0x89, 0x8f, 0x8b, 0x27, 0x10, 0x64, 0x56, 0x10, 0xc4, 0x28, 0xa7, 0x19, 0xcc, 0x27, 0x1e, 0xc9, + 0x31, 0x5e, 0x78, 0x24, 0xc7, 0xf8, 0xe0, 0x91, 0x1c, 0xe3, 0x84, 0xc7, 0x72, 0x0c, 0x17, 0x1e, + 0xcb, 0x31, 0xdc, 0x78, 0x2c, 0xc7, 0xc0, 0x65, 0x9e, 0x9c, 0x9f, 0xab, 0x47, 0x86, 0x1d, 0x4e, + 0x82, 0xc8, 0x36, 0x04, 0x80, 0xdc, 0x1a, 0xc0, 0x18, 0x65, 0x97, 0x9e, 0x59, 0x92, 0x51, 0x9a, + 0xa4, 0x97, 0x9c, 0x9f, 0xab, 0x4f, 0x46, 0x08, 0x2c, 0x62, 0x62, 0x73, 0xf4, 0x8d, 0xf0, 0x0c, + 0x0c, 0x58, 0xc5, 0x84, 0xe2, 0x6f, 0x5f, 0xa8, 0x9b, 0x22, 0xf4, 0x3c, 0x11, 0x6e, 0x0a, 0x84, + 0xba, 0x29, 0x00, 0xae, 0xfd, 0x14, 0x8a, 0xae, 0x18, 0xa8, 0xae, 0x98, 0x88, 0x18, 0x84, 0xae, + 0x18, 0xa8, 0xae, 0x18, 0x84, 0xae, 0x47, 0x4c, 0xf6, 0x64, 0xe8, 0x8a, 0x71, 0x0f, 0x70, 0xf2, + 0x4d, 0x2d, 0x49, 0x4c, 0x49, 0x2c, 0x49, 0x7c, 0xc5, 0x64, 0x81, 0x64, 0x82, 0x95, 0x15, 0xd4, + 0x08, 0x2b, 0xab, 0x08, 0x2b, 0x2b, 0x84, 0x21, 0x56, 0x56, 0x50, 0x53, 0xac, 0xac, 0x10, 0xc6, + 0x24, 0xb1, 0x81, 0xa3, 0xd9, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0x09, 0x77, 0x98, 0x11, 0x31, + 0x02, 0x00, 0x00, +} + +func (m *QueryRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func encodeVarintQueryRequest(dAtA []byte, offset int, v uint64) int { + offset -= sovQueryRequest(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *QueryRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func sovQueryRequest(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQueryRequest(x uint64) (n int) { + return sovQueryRequest(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QueryRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQueryRequest + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQueryRequest(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQueryRequest + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipQueryRequest(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQueryRequest + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQueryRequest + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQueryRequest + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthQueryRequest + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupQueryRequest + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthQueryRequest + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthQueryRequest = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowQueryRequest = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupQueryRequest = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/identities/queries/parameters/query_response.go b/x/identities/queries/parameters/query_response.go new file mode 100644 index 000000000..4d34b8543 --- /dev/null +++ b/x/identities/queries/parameters/query_response.go @@ -0,0 +1,29 @@ +package parameters + +import ( + "github.com/AssetMantle/modules/helpers" + "github.com/AssetMantle/modules/helpers/base" + "github.com/AssetMantle/schema/lists" + baseLists "github.com/AssetMantle/schema/lists/base" +) + +var _ helpers.QueryResponse = (*QueryResponse)(nil) + +func (queryResponse *QueryResponse) Encode() ([]byte, error) { + return base.CodecPrototype().MarshalJSON(queryResponse) +} +func (queryResponse *QueryResponse) Decode(bytes []byte) (helpers.QueryResponse, error) { + if err := base.CodecPrototype().UnmarshalJSON(bytes, queryResponse); err != nil { + return nil, err + } + + return queryResponse, nil +} +func responsePrototype() helpers.QueryResponse { + return &QueryResponse{} +} +func newQueryResponse(parameterList lists.ParameterList) *QueryResponse { + return &QueryResponse{ + ParameterList: parameterList.(*baseLists.ParameterList), + } +} diff --git a/x/identities/queries/parameters/query_response.pb.go b/x/identities/queries/parameters/query_response.pb.go new file mode 100644 index 000000000..3f5e85eba --- /dev/null +++ b/x/identities/queries/parameters/query_response.pb.go @@ -0,0 +1,338 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: AssetMantle/modules/x/identities/queries/parameters/query_response.proto + +package parameters + +import ( + fmt "fmt" + base "github.com/AssetMantle/schema/lists/base" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type QueryResponse struct { + ParameterList *base.ParameterList `protobuf:"bytes,1,opt,name=parameter_list,json=parameterList,proto3" json:"parameter_list,omitempty"` +} + +func (m *QueryResponse) Reset() { *m = QueryResponse{} } +func (m *QueryResponse) String() string { return proto.CompactTextString(m) } +func (*QueryResponse) ProtoMessage() {} +func (*QueryResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_4aeff1220f332df1, []int{0} +} +func (m *QueryResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryResponse.Merge(m, src) +} +func (m *QueryResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryResponse proto.InternalMessageInfo + +func (m *QueryResponse) GetParameterList() *base.ParameterList { + if m != nil { + return m.ParameterList + } + return nil +} + +func init() { + proto.RegisterType((*QueryResponse)(nil), "AssetMantle.modules.x.identities.queries.parameters.QueryResponse") +} + +func init() { + proto.RegisterFile("AssetMantle/modules/x/identities/queries/parameters/query_response.proto", fileDescriptor_4aeff1220f332df1) +} + +var fileDescriptor_4aeff1220f332df1 = []byte{ + // 340 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x92, 0x31, 0x4b, 0xf3, 0x50, + 0x14, 0x86, 0x9b, 0x7c, 0xd0, 0x21, 0x1f, 0x75, 0xe8, 0x24, 0x0e, 0x41, 0x9c, 0x1c, 0xe4, 0x5c, + 0x68, 0x07, 0xe5, 0x0e, 0x4a, 0xbb, 0x68, 0xc1, 0x40, 0x5a, 0x97, 0x20, 0x81, 0x72, 0xdb, 0x1c, + 0xec, 0x85, 0xa6, 0x37, 0xe6, 0xdc, 0x42, 0xfd, 0x17, 0xae, 0xae, 0x8e, 0xfe, 0x12, 0x71, 0xea, + 0xe8, 0x28, 0xe9, 0xe6, 0xaf, 0x90, 0xb4, 0x57, 0x6f, 0xb2, 0x76, 0x0a, 0x39, 0xe4, 0x79, 0xde, + 0xf7, 0x70, 0xe2, 0xdd, 0xf4, 0x88, 0x50, 0x07, 0x62, 0xa1, 0xe7, 0xc8, 0x52, 0x95, 0x2c, 0xe7, + 0x48, 0x6c, 0xc5, 0x64, 0x82, 0x0b, 0x2d, 0xb5, 0x44, 0x62, 0x8f, 0x4b, 0xcc, 0xcb, 0x67, 0x26, + 0x72, 0x91, 0xa2, 0xc6, 0x7c, 0x37, 0x7a, 0x1a, 0xe7, 0x48, 0x99, 0x5a, 0x10, 0x42, 0x96, 0x2b, + 0xad, 0xda, 0xdd, 0x8a, 0x09, 0x8c, 0x09, 0x56, 0x60, 0x4d, 0x60, 0x4c, 0x60, 0x4d, 0x47, 0x9d, + 0x6a, 0x3c, 0x4d, 0x67, 0x98, 0x0a, 0x36, 0x97, 0xa4, 0x89, 0x4d, 0x04, 0xa1, 0xcd, 0x1c, 0x97, + 0xc3, 0x5d, 0xd0, 0x49, 0xe2, 0xb5, 0x86, 0x65, 0x81, 0x91, 0xc9, 0x6f, 0xdf, 0x79, 0x07, 0xf5, + 0x0f, 0x0f, 0x9d, 0x63, 0xe7, 0xf4, 0x7f, 0xe7, 0x0c, 0xaa, 0x95, 0x76, 0x76, 0xd8, 0xda, 0xa1, + 0xb4, 0x43, 0xf8, 0x0b, 0xdd, 0x4a, 0xd2, 0xa3, 0x56, 0x56, 0x7d, 0xed, 0xbf, 0xfc, 0x7b, 0x2f, + 0x7c, 0x67, 0x5d, 0xf8, 0xce, 0x57, 0xe1, 0x3b, 0xcf, 0x1b, 0xbf, 0xb1, 0xde, 0xf8, 0x8d, 0xcf, + 0x8d, 0xdf, 0xf0, 0xce, 0xa7, 0x2a, 0x85, 0x3d, 0xb6, 0xed, 0xb7, 0x6b, 0xbd, 0xc3, 0x72, 0x9b, + 0xd0, 0xb9, 0xbf, 0x7c, 0x90, 0x7a, 0xb6, 0x9c, 0xc0, 0x54, 0xa5, 0x6c, 0x8f, 0x6b, 0xbc, 0xba, + 0xcd, 0x5e, 0x10, 0x0d, 0x86, 0xe1, 0x9b, 0x5b, 0x3b, 0x41, 0x60, 0x4a, 0x45, 0x30, 0xb0, 0xa5, + 0x86, 0xa6, 0xd4, 0xdf, 0xea, 0xf4, 0x51, 0xa3, 0x62, 0x43, 0xc5, 0x51, 0x6c, 0xa9, 0xd8, 0x50, + 0xb1, 0xa5, 0x0a, 0xf7, 0x6a, 0x0f, 0x2a, 0xbe, 0x0e, 0xfb, 0x01, 0x6a, 0x91, 0x08, 0x2d, 0xbe, + 0xdd, 0x8b, 0x8a, 0x81, 0x73, 0xa3, 0xe0, 0x3c, 0xe2, 0xdc, 0x4a, 0x38, 0x37, 0x16, 0xce, 0xad, + 0x66, 0xd2, 0xdc, 0xfe, 0x08, 0xdd, 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xde, 0x48, 0xd6, 0x3b, + 0xbd, 0x02, 0x00, 0x00, +} + +func (m *QueryResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.ParameterList != nil { + { + size, err := m.ParameterList.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQueryResponse(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintQueryResponse(dAtA []byte, offset int, v uint64) int { + offset -= sovQueryResponse(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *QueryResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ParameterList != nil { + l = m.ParameterList.Size() + n += 1 + l + sovQueryResponse(uint64(l)) + } + return n +} + +func sovQueryResponse(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQueryResponse(x uint64) (n int) { + return sovQueryResponse(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QueryResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQueryResponse + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ParameterList", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQueryResponse + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQueryResponse + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQueryResponse + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.ParameterList == nil { + m.ParameterList = &base.ParameterList{} + } + if err := m.ParameterList.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQueryResponse(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQueryResponse + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipQueryResponse(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQueryResponse + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQueryResponse + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQueryResponse + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthQueryResponse + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupQueryResponse + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthQueryResponse + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthQueryResponse = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowQueryResponse = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupQueryResponse = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/identities/queries/parameters/service.pb.go b/x/identities/queries/parameters/service.pb.go new file mode 100644 index 000000000..3dae86c06 --- /dev/null +++ b/x/identities/queries/parameters/service.pb.go @@ -0,0 +1,135 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: AssetMantle/modules/x/identities/queries/parameters/service.proto + +package parameters + +import ( + context "context" + fmt "fmt" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + math "math" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +func init() { + proto.RegisterFile("AssetMantle/modules/x/identities/queries/parameters/service.proto", fileDescriptor_899e37c996c98b07) +} + +var fileDescriptor_899e37c996c98b07 = []byte{ + // 328 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x92, 0x31, 0x4e, 0xc3, 0x30, + 0x14, 0x86, 0x93, 0x20, 0x3a, 0x44, 0x4c, 0x1d, 0x3b, 0x78, 0xe0, 0x00, 0xb6, 0x44, 0x07, 0x90, + 0x07, 0x50, 0xb2, 0xb4, 0x1d, 0x22, 0xa5, 0xb0, 0x44, 0xc8, 0x12, 0x72, 0x9b, 0x27, 0x88, 0xd4, + 0xc4, 0xad, 0xed, 0xa0, 0x72, 0x0b, 0x10, 0x23, 0x1b, 0x23, 0x27, 0x41, 0x4c, 0x1d, 0x19, 0x51, + 0xb2, 0x71, 0x0a, 0x94, 0xc6, 0xc2, 0xed, 0x9a, 0x4e, 0x91, 0x62, 0x7d, 0xdf, 0xfb, 0x7f, 0xfb, + 0xf9, 0x41, 0xa0, 0x14, 0xe8, 0x88, 0x17, 0x7a, 0x01, 0x24, 0x17, 0x69, 0xb9, 0x00, 0x45, 0xd6, + 0x24, 0x4b, 0xa1, 0xd0, 0x99, 0xce, 0x40, 0x91, 0x55, 0x09, 0xb2, 0xf9, 0x2e, 0xb9, 0xe4, 0x39, + 0x68, 0x90, 0x8a, 0x28, 0x90, 0x8f, 0xd9, 0x1c, 0xf0, 0x52, 0x0a, 0x2d, 0xfa, 0xc3, 0x1d, 0x05, + 0x36, 0x0a, 0xbc, 0xc6, 0x56, 0x81, 0x8d, 0x02, 0x5b, 0xc5, 0x60, 0xd4, 0x65, 0x6e, 0xf3, 0xeb, + 0xe9, 0x4e, 0xc2, 0xaa, 0x04, 0xa5, 0xdb, 0xe9, 0x83, 0xf1, 0x21, 0x22, 0xb5, 0x14, 0x85, 0x32, + 0x3d, 0xce, 0xde, 0x5c, 0xff, 0x78, 0xda, 0x1c, 0xf4, 0x5f, 0x5c, 0xbf, 0x37, 0xe6, 0x45, 0xba, + 0x80, 0x7e, 0x80, 0x3b, 0xb4, 0xc3, 0x5b, 0xcd, 0x75, 0x9b, 0x73, 0x10, 0x1e, 0xa2, 0x68, 0x13, + 0x9e, 0x3a, 0xe1, 0xeb, 0xd1, 0x67, 0x85, 0xdc, 0x4d, 0x85, 0xdc, 0x9f, 0x0a, 0xb9, 0xcf, 0x35, + 0x72, 0x36, 0x35, 0x72, 0xbe, 0x6b, 0xe4, 0xf8, 0xe7, 0x73, 0x91, 0x77, 0x99, 0x11, 0x9e, 0xdc, + 0xb4, 0x0f, 0x19, 0x37, 0xfd, 0x63, 0xf7, 0xf6, 0xf2, 0x3e, 0xd3, 0x0f, 0xe5, 0x0c, 0xcf, 0x45, + 0x4e, 0x3a, 0x5c, 0xeb, 0xbb, 0xd7, 0x0b, 0xa2, 0x64, 0x32, 0x8d, 0x3f, 0xbc, 0xbd, 0x9d, 0x88, + 0x4c, 0x9c, 0x04, 0x4f, 0x6c, 0x9c, 0xa9, 0x89, 0x13, 0xff, 0xe3, 0x5f, 0x7b, 0x14, 0x33, 0x14, + 0x4b, 0x98, 0xa5, 0x98, 0xa1, 0x98, 0xa5, 0x2a, 0xef, 0xaa, 0x03, 0xc5, 0x46, 0x71, 0x18, 0x81, + 0xe6, 0x29, 0xd7, 0xfc, 0xd7, 0xbb, 0xd8, 0x31, 0x50, 0x6a, 0x14, 0x94, 0x26, 0x94, 0x5a, 0x09, + 0xa5, 0xc6, 0x42, 0xa9, 0xd5, 0xcc, 0x7a, 0xdb, 0xd5, 0x19, 0xfe, 0x05, 0x00, 0x00, 0xff, 0xff, + 0xab, 0x23, 0x88, 0xac, 0x47, 0x03, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// QueryClient is the client API for Query service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type QueryClient interface { + Handle(ctx context.Context, in *QueryRequest, opts ...grpc.CallOption) (*QueryResponse, error) +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +func (c *queryClient) Handle(ctx context.Context, in *QueryRequest, opts ...grpc.CallOption) (*QueryResponse, error) { + out := new(QueryResponse) + err := c.cc.Invoke(ctx, "/AssetMantle.modules.x.identities.queries.parameters.Query/Handle", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +type QueryServer interface { + Handle(context.Context, *QueryRequest) (*QueryResponse, error) +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func (*UnimplementedQueryServer) Handle(ctx context.Context, req *QueryRequest) (*QueryResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Handle not implemented") +} + +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) +} + +func _Query_Handle_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Handle(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/AssetMantle.modules.x.identities.queries.parameters.Query/Handle", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Handle(ctx, req.(*QueryRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "AssetMantle.modules.x.identities.queries.parameters.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Handle", + Handler: _Query_Handle_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "AssetMantle/modules/x/identities/queries/parameters/service.proto", +} diff --git a/x/identities/queries/prototype.go b/x/identities/queries/prototype.go index ee32b32e0..1cc87a727 100644 --- a/x/identities/queries/prototype.go +++ b/x/identities/queries/prototype.go @@ -8,11 +8,13 @@ import ( baseHelpers "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/x/identities/queries/identities" "github.com/AssetMantle/modules/x/identities/queries/identity" + "github.com/AssetMantle/modules/x/identities/queries/parameters" ) func Prototype() helpers.Queries { return baseHelpers.NewQueries( identity.Query, identities.Query, + parameters.Query, ) } diff --git a/x/identities/record/record.go b/x/identities/record/record.go index c198fbeda..41256e850 100644 --- a/x/identities/record/record.go +++ b/x/identities/record/record.go @@ -1,14 +1,13 @@ package record import ( - "github.com/AssetMantle/schema/documents" - baseIDs "github.com/AssetMantle/schema/ids/base" - sdkTypes "github.com/cosmos/cosmos-sdk/types" - "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/x/identities/key" "github.com/AssetMantle/modules/x/identities/mappable" + "github.com/AssetMantle/schema/documents" + baseIDs "github.com/AssetMantle/schema/ids/base" + sdkTypes "github.com/cosmos/cosmos-sdk/types" ) func (record *Record) GetKey() helpers.Key { diff --git a/x/identities/simulator/genesis.go b/x/identities/simulator/genesis.go index 8c9f0088c..89b1e253a 100644 --- a/x/identities/simulator/genesis.go +++ b/x/identities/simulator/genesis.go @@ -4,8 +4,6 @@ package simulator import ( - "math/rand" - "github.com/AssetMantle/schema/data" baseData "github.com/AssetMantle/schema/data/base" "github.com/AssetMantle/schema/documents/base" @@ -15,6 +13,7 @@ import ( baseQualified "github.com/AssetMantle/schema/qualified/base" sdkTypes "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" + "math/rand" "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" diff --git a/x/identities/simulator/operations.go b/x/identities/simulator/operations.go index 59913ccd2..563544643 100644 --- a/x/identities/simulator/operations.go +++ b/x/identities/simulator/operations.go @@ -4,8 +4,6 @@ package simulator import ( - "math/rand" - baseData "github.com/AssetMantle/schema/data/base" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" @@ -18,6 +16,7 @@ import ( "github.com/cosmos/cosmos-sdk/types/module" simulationTypes "github.com/cosmos/cosmos-sdk/types/simulation" "github.com/cosmos/cosmos-sdk/x/simulation" + "math/rand" "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" diff --git a/x/identities/simulator/params.go b/x/identities/simulator/params.go index 815cc9714..bc9c056d3 100644 --- a/x/identities/simulator/params.go +++ b/x/identities/simulator/params.go @@ -4,12 +4,11 @@ package simulator import ( - "math" - "math/rand" - "github.com/AssetMantle/schema/data" simulationTypes "github.com/cosmos/cosmos-sdk/types/simulation" "github.com/cosmos/cosmos-sdk/x/simulation" + "math" + "math/rand" baseHelpers "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/x/identities/constants" diff --git a/x/identities/simulator/proposals.go b/x/identities/simulator/proposals.go index 72d20f254..53aac918f 100644 --- a/x/identities/simulator/proposals.go +++ b/x/identities/simulator/proposals.go @@ -4,28 +4,28 @@ package simulator import ( - "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" - "math/rand" - - sdk "github.com/cosmos/cosmos-sdk/types" + sdkTypes "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" simulationTypes "github.com/cosmos/cosmos-sdk/types/simulation" + govSimulation "github.com/cosmos/cosmos-sdk/x/gov/simulation" + "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" "github.com/cosmos/cosmos-sdk/x/simulation" + "math/rand" ) -func (simulator) WeightedProposalContentList(module.SimulationState) []simulationTypes.WeightedProposalContent { - return []simulationTypes.WeightedProposalContent{ - simulation.NewWeightedProposalContent( +func (simulator) ProposalMessages(_ module.SimulationState) []simulationTypes.WeightedProposalMsg { + return []simulationTypes.WeightedProposalMsg{ + simulation.NewWeightedProposalMsg( OpWeightSubmitTextProposal, DefaultWeightTextProposal, - simulateTextProposalContent, + func(r *rand.Rand, _ sdkTypes.Context, simulationAccounts []simulationTypes.Account) sdkTypes.Msg { + msgSubmitProposal, err := v1beta1.NewMsgSubmitProposal(v1beta1.NewTextProposal(simulationTypes.RandStringOfLength(r, 140), simulationTypes.RandStringOfLength(r, 5000)), govSimulation.GenDepositParamsMinDeposit(r), simulationAccounts[r.Intn(len(simulationAccounts))].Address) + if err != nil { + panic(err) + } + + return msgSubmitProposal + }, ), } } - -func simulateTextProposalContent(r *rand.Rand, _ sdk.Context, _ []simulationTypes.Account) simulationTypes.Content { - return v1beta1.NewTextProposal( - simulationTypes.RandStringOfLength(r, 140), - simulationTypes.RandStringOfLength(r, 5000), - ) -} diff --git a/x/identities/transactions/define/message.go b/x/identities/transactions/define/message.go index 7a7e2af6e..de8274451 100644 --- a/x/identities/transactions/define/message.go +++ b/x/identities/transactions/define/message.go @@ -4,28 +4,17 @@ package define import ( - codecUtilities "github.com/AssetMantle/schema/codec/utilities" + "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" "github.com/AssetMantle/schema/lists" baseLists "github.com/AssetMantle/schema/lists/base" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/types" sdkTypes "github.com/cosmos/cosmos-sdk/types" - - "github.com/AssetMantle/modules/helpers" ) var _ helpers.Message = (*Message)(nil) -func (message *Message) Type() string { return Transaction.GetName() } -func (message *Message) GetFromAddress() sdkTypes.AccAddress { - from, err := sdkTypes.AccAddressFromBech32(message.From) - if err != nil { - panic(err) - } - return from -} func (message *Message) ValidateBasic() error { if _, err := sdkTypes.AccAddressFromBech32(message.From); err != nil { return err @@ -54,21 +43,10 @@ func (message *Message) GetSigners() []sdkTypes.AccAddress { } return []sdkTypes.AccAddress{from} } -func (*Message) RegisterLegacyAminoCodec(legacyAmino *codec.LegacyAmino) { - codecUtilities.RegisterModuleConcrete(legacyAmino, Message{}) -} func (message *Message) RegisterInterface(interfaceRegistry types.InterfaceRegistry) { interfaceRegistry.RegisterImplementations((*sdkTypes.Msg)(nil), message) } -func messageFromInterface(msg sdkTypes.Msg) *Message { - switch value := msg.(type) { - case *Message: - return value - default: - return &Message{} - } -} func messagePrototype() helpers.Message { return &Message{} } diff --git a/x/identities/transactions/define/message_test.go b/x/identities/transactions/define/message_test.go index e9d98178a..3bd850047 100644 --- a/x/identities/transactions/define/message_test.go +++ b/x/identities/transactions/define/message_test.go @@ -11,7 +11,6 @@ import ( baseIDs "github.com/AssetMantle/schema/ids/base" "github.com/AssetMantle/schema/lists" baseLists "github.com/AssetMantle/schema/lists/base" - "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" @@ -27,51 +26,6 @@ type fields struct { MutableProperties *baseLists.PropertyList } -func Test_messageFromInterface(t *testing.T) { - fromID, err := baseIDs.PrototypeIdentityID().FromString("CBepOLnJFnKO9NEyZlSv7r80nKNZFFXRqHfnsObZ_KU=") - testFromID := fromID.(*baseIDs.IdentityID) - require.NoError(t, err) - fromAddress := "cosmos1pkkayn066msg6kn33wnl5srhdt3tnu2vzasz9c" - fromAccAddress, err := sdkTypes.AccAddressFromBech32(fromAddress) - require.Nil(t, err) - - immutableMetaPropertiesInterface, err := baseLists.NewPropertyList().FromMetaPropertiesString("defaultImmutableMeta1:S|defaultImmutableMeta1") - require.Equal(t, nil, err) - immutableMetaProperties := immutableMetaPropertiesInterface.(*baseLists.PropertyList) - - immutablePropertiesInterface, err := baseLists.NewPropertyList().FromMetaPropertiesString("defaultImmutable1:S|defaultImmutable1") - require.Equal(t, nil, err) - immutableProperties := immutablePropertiesInterface.(*baseLists.PropertyList) - - mutableMetaPropertiesInterface, err := baseLists.NewPropertyList().FromMetaPropertiesString("defaultMutableMeta1:S|defaultMutableMeta1") - require.Equal(t, nil, err) - mutableMetaProperties := mutableMetaPropertiesInterface.(*baseLists.PropertyList) - - mutablePropertiesInterface, err := baseLists.NewPropertyList().FromMetaPropertiesString("defaultMutable1:S|defaultMutable1") - require.Equal(t, nil, err) - mutableProperties := mutablePropertiesInterface.(*baseLists.PropertyList) - - type args struct { - msg sdkTypes.Msg - } - tests := []struct { - name string - args args - want *Message - }{ - - {"+ve", args{&Message{fromAccAddress.String(), testFromID, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties}}, &Message{fromAccAddress.String(), testFromID, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties}}, - {"+ve with nil", args{nil}, &Message{}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := messageFromInterface(tt.args.msg); !reflect.DeepEqual(got, tt.want) { - t.Errorf("messageFromInterface() = %v, want %v", got, tt.want) - } - }) - } -} - func Test_messagePrototype(t *testing.T) { tests := []struct { name string @@ -138,105 +92,6 @@ func Test_message_GetSigners(t *testing.T) { } } -func Test_message_RegisterCodec(t *testing.T) { - fromID, err := baseIDs.PrototypeIdentityID().FromString("CBepOLnJFnKO9NEyZlSv7r80nKNZFFXRqHfnsObZ_KU=") - testFromID := fromID.(*baseIDs.IdentityID) - require.NoError(t, err) - fromAddress := "cosmos1pkkayn066msg6kn33wnl5srhdt3tnu2vzasz9c" - fromAccAddress, err := sdkTypes.AccAddressFromBech32(fromAddress) - require.Nil(t, err) - - immutableMetaPropertiesInterface, err := baseLists.NewPropertyList().FromMetaPropertiesString("defaultImmutableMeta1:S|defaultImmutableMeta1") - require.Equal(t, nil, err) - immutableMetaProperties := immutableMetaPropertiesInterface.(*baseLists.PropertyList) - - immutablePropertiesInterface, err := baseLists.NewPropertyList().FromMetaPropertiesString("defaultImmutable1:S|defaultImmutable1") - require.Equal(t, nil, err) - immutableProperties := immutablePropertiesInterface.(*baseLists.PropertyList) - - mutableMetaPropertiesInterface, err := baseLists.NewPropertyList().FromMetaPropertiesString("defaultMutableMeta1:S|defaultMutableMeta1") - require.Equal(t, nil, err) - mutableMetaProperties := mutableMetaPropertiesInterface.(*baseLists.PropertyList) - - mutablePropertiesInterface, err := baseLists.NewPropertyList().FromMetaPropertiesString("defaultMutable1:S|defaultMutable1") - require.Equal(t, nil, err) - mutableProperties := mutablePropertiesInterface.(*baseLists.PropertyList) - - type args struct { - legacyAmino *codec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - - {"+ve", fields{fromAccAddress.String(), testFromID, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties}, args{codec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - me := &Message{ - From: tt.fields.From, - FromID: tt.fields.FromID, - ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, - ImmutableProperties: tt.fields.ImmutableProperties, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, - } - me.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - -func Test_message_Type(t *testing.T) { - fromID, err := baseIDs.PrototypeIdentityID().FromString("CBepOLnJFnKO9NEyZlSv7r80nKNZFFXRqHfnsObZ_KU=") - testFromID := fromID.(*baseIDs.IdentityID) - require.NoError(t, err) - fromAddress := "cosmos1pkkayn066msg6kn33wnl5srhdt3tnu2vzasz9c" - fromAccAddress, err := sdkTypes.AccAddressFromBech32(fromAddress) - require.Nil(t, err) - - immutableMetaPropertiesInterface, err := baseLists.NewPropertyList().FromMetaPropertiesString("defaultImmutableMeta1:S|defaultImmutableMeta1") - require.Equal(t, nil, err) - immutableMetaProperties := immutableMetaPropertiesInterface.(*baseLists.PropertyList) - - immutablePropertiesInterface, err := baseLists.NewPropertyList().FromMetaPropertiesString("defaultImmutable1:S|defaultImmutable1") - require.Equal(t, nil, err) - immutableProperties := immutablePropertiesInterface.(*baseLists.PropertyList) - - mutableMetaPropertiesInterface, err := baseLists.NewPropertyList().FromMetaPropertiesString("defaultMutableMeta1:S|defaultMutableMeta1") - require.Equal(t, nil, err) - mutableMetaProperties := mutableMetaPropertiesInterface.(*baseLists.PropertyList) - - mutablePropertiesInterface, err := baseLists.NewPropertyList().FromMetaPropertiesString("defaultMutable1:S|defaultMutable1") - require.Equal(t, nil, err) - mutableProperties := mutablePropertiesInterface.(*baseLists.PropertyList) - - tests := []struct { - name string - fields fields - want string - }{ - - {"+ve", fields{fromAccAddress.String(), testFromID, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties}, Transaction.GetName()}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - message := &Message{ - From: tt.fields.From, - FromID: tt.fields.FromID, - ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, - ImmutableProperties: tt.fields.ImmutableProperties, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, - } - if got := message.Type(); got != tt.want { - t.Errorf("Type() = %v, want %v", got, tt.want) - } - }) - } -} - func Test_message_ValidateBasic(t *testing.T) { fromID, err := baseIDs.PrototypeIdentityID().FromString("CBepOLnJFnKO9NEyZlSv7r80nKNZFFXRqHfnsObZ_KU=") testFromID := fromID.(*baseIDs.IdentityID) diff --git a/x/identities/transactions/define/service.pb.go b/x/identities/transactions/define/service.pb.go index c10ff3c43..bcf000ecd 100644 --- a/x/identities/transactions/define/service.pb.go +++ b/x/identities/transactions/define/service.pb.go @@ -6,9 +6,9 @@ package define import ( context "context" fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types/msgservice" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" - _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -31,30 +31,30 @@ func init() { } var fileDescriptor_0c544b9b622019f8 = []byte{ - // 363 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x92, 0x31, 0x4b, 0xc3, 0x40, - 0x14, 0x80, 0x9b, 0x14, 0x3a, 0x04, 0xa7, 0x6e, 0x46, 0x09, 0xd8, 0x1f, 0x70, 0x07, 0xea, 0xa0, - 0x07, 0xa2, 0x0d, 0x05, 0xed, 0x10, 0x2c, 0xda, 0x21, 0x48, 0x40, 0xae, 0xc9, 0x33, 0x1e, 0x24, - 0x77, 0x25, 0x77, 0x95, 0xce, 0xfe, 0x02, 0xc1, 0xc9, 0xd5, 0xd1, 0xdd, 0xd1, 0x5d, 0x9c, 0x0a, - 0x2e, 0x8e, 0x92, 0x3a, 0xf9, 0x2b, 0xc4, 0x5e, 0x20, 0xd7, 0x35, 0xeb, 0x0b, 0xdf, 0xc7, 0xf7, - 0x72, 0xcf, 0xf1, 0xfb, 0x52, 0x82, 0x0a, 0x28, 0x57, 0x19, 0xe0, 0x5c, 0x24, 0xb3, 0x0c, 0x24, - 0x9e, 0x63, 0x96, 0x00, 0x57, 0x4c, 0x31, 0x90, 0x58, 0x15, 0x94, 0x4b, 0x1a, 0x2b, 0x26, 0xb8, - 0xc4, 0x09, 0xdc, 0x30, 0x0e, 0x58, 0x42, 0x71, 0xc7, 0x62, 0x40, 0xd3, 0x42, 0x28, 0xd1, 0xdd, - 0x37, 0x1c, 0xa8, 0x72, 0xa0, 0x39, 0xaa, 0x1d, 0xc8, 0x74, 0x20, 0xed, 0x70, 0xb7, 0x53, 0x21, - 0xd2, 0x0c, 0x30, 0x9d, 0x32, 0x4c, 0x39, 0x17, 0x8a, 0xea, 0xcf, 0x2b, 0xa7, 0xdb, 0xac, 0x2b, - 0x07, 0x29, 0x69, 0x5a, 0x75, 0xb9, 0xe7, 0x8d, 0x1c, 0xc6, 0xec, 0xba, 0x00, 0x39, 0x15, 0x5c, - 0x56, 0xc2, 0xdd, 0x37, 0xcb, 0x69, 0x07, 0x32, 0xed, 0xbe, 0x5a, 0x4e, 0xe7, 0x8c, 0xf2, 0x24, - 0x83, 0xee, 0x11, 0x6a, 0xb2, 0x3c, 0x0a, 0x74, 0xa8, 0x3b, 0x6c, 0x86, 0x8f, 0xeb, 0xd9, 0x45, - 0x95, 0xd8, 0xdb, 0xb9, 0xff, 0xfc, 0x79, 0xb4, 0xb7, 0x7a, 0x9b, 0x38, 0xd7, 0x1b, 0x1b, 0x7b, - 0x6a, 0xcc, 0x7f, 0x6a, 0xbf, 0x97, 0x9e, 0xb5, 0x28, 0x3d, 0xeb, 0xbb, 0xf4, 0xac, 0x87, 0xa5, - 0xd7, 0x5a, 0x2c, 0xbd, 0xd6, 0xd7, 0xd2, 0x6b, 0x39, 0x07, 0xb1, 0xc8, 0x1b, 0xb5, 0xf8, 0x1b, - 0x97, 0xfa, 0x18, 0x46, 0xff, 0xbf, 0x68, 0x64, 0x5d, 0x1d, 0xa7, 0x4c, 0xdd, 0xce, 0x26, 0x28, - 0x16, 0x39, 0x6e, 0xf2, 0x00, 0xcf, 0x76, 0xa7, 0x1f, 0x84, 0xc3, 0xf1, 0xe0, 0xc5, 0x5e, 0x3b, - 0xac, 0xa0, 0x0a, 0x0a, 0xd1, 0xb0, 0x0e, 0x1a, 0x9b, 0x41, 0x83, 0x15, 0xff, 0xb1, 0x86, 0x45, - 0x15, 0x16, 0x85, 0x51, 0x8d, 0x45, 0x26, 0x16, 0x69, 0xac, 0xb4, 0x4f, 0x9a, 0x60, 0xd1, 0xe9, - 0xc8, 0x0f, 0x40, 0xd1, 0x84, 0x2a, 0xfa, 0x6b, 0x1f, 0x1a, 0x0a, 0x42, 0x2a, 0x07, 0x21, 0x21, - 0x21, 0xb5, 0x85, 0x10, 0x53, 0x43, 0x88, 0xf6, 0x4c, 0x3a, 0xab, 0x13, 0xdb, 0xfb, 0x0b, 0x00, - 0x00, 0xff, 0xff, 0x25, 0x4e, 0x10, 0x53, 0x91, 0x03, 0x00, 0x00, + // 355 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x92, 0x3f, 0x4b, 0xc3, 0x40, + 0x14, 0xc0, 0x93, 0x14, 0x3b, 0x04, 0xa7, 0x2e, 0x42, 0x86, 0x0c, 0x8e, 0x0e, 0x77, 0xf8, 0x67, + 0xd0, 0x03, 0xd1, 0x86, 0x82, 0x76, 0x08, 0x16, 0xed, 0x10, 0x24, 0x20, 0xd7, 0xe4, 0x8c, 0x81, + 0xe6, 0xae, 0xe4, 0x5d, 0x4b, 0x47, 0x3f, 0x82, 0x83, 0x8b, 0xab, 0x6e, 0x4e, 0x7e, 0x0c, 0x71, + 0xea, 0xe8, 0x28, 0xe9, 0x20, 0xf8, 0x29, 0xa4, 0xcd, 0x41, 0xae, 0xeb, 0x4d, 0x81, 0x07, 0xbf, + 0x5f, 0x7e, 0x79, 0x79, 0x6e, 0xd0, 0x05, 0x60, 0x32, 0xa4, 0x5c, 0x8e, 0x19, 0x2e, 0x44, 0x3a, + 0x1d, 0x33, 0xc0, 0x73, 0x9c, 0xa7, 0x8c, 0xcb, 0x5c, 0xe6, 0x0c, 0xb0, 0x2c, 0x29, 0x07, 0x9a, + 0xc8, 0x5c, 0x70, 0xc0, 0x29, 0xbb, 0xcf, 0x39, 0xc3, 0xc0, 0xca, 0x59, 0x9e, 0x30, 0x34, 0x29, + 0x85, 0x14, 0x9d, 0x23, 0xcd, 0x81, 0x94, 0x03, 0xcd, 0x51, 0xe3, 0x40, 0xba, 0x03, 0xd5, 0x0e, + 0x6f, 0x27, 0x11, 0x50, 0x08, 0xc0, 0x05, 0x64, 0x78, 0xb6, 0xbf, 0x7a, 0xd4, 0x3a, 0xcf, 0x2c, + 0xa9, 0x60, 0x00, 0x34, 0x53, 0x49, 0xde, 0x95, 0x91, 0x43, 0x9b, 0xdd, 0x95, 0x0c, 0x26, 0x82, + 0x83, 0x12, 0x1e, 0xbc, 0xd9, 0x6e, 0x2b, 0x84, 0xac, 0xf3, 0x6c, 0xbb, 0xed, 0x4b, 0xca, 0xd3, + 0x31, 0xeb, 0x9c, 0x22, 0x93, 0xef, 0x46, 0x61, 0x1d, 0xea, 0xf5, 0xcd, 0xf0, 0x61, 0x33, 0xbb, + 0x56, 0x89, 0xbb, 0x96, 0xb7, 0xf5, 0xf8, 0xfb, 0xb1, 0x67, 0x07, 0x2f, 0xad, 0xcf, 0xca, 0xb7, + 0x17, 0x95, 0x6f, 0xff, 0x54, 0xbe, 0xfd, 0xb4, 0xf4, 0xad, 0xc5, 0xd2, 0xb7, 0xbe, 0x97, 0xbe, + 0xe5, 0x1e, 0x27, 0xa2, 0x30, 0x7a, 0x63, 0xb0, 0x7d, 0x53, 0xff, 0xed, 0xc1, 0x6a, 0x11, 0x03, + 0xfb, 0xf6, 0x2c, 0xcb, 0xe5, 0xc3, 0x74, 0x84, 0x12, 0x51, 0x60, 0x93, 0x35, 0xbf, 0x3a, 0xed, + 0x6e, 0x18, 0xf5, 0x87, 0xbd, 0x77, 0x67, 0xe3, 0x72, 0x42, 0x15, 0x14, 0xa1, 0x7e, 0x13, 0x34, + 0xd4, 0x83, 0x7a, 0x6b, 0xfe, 0x6b, 0x03, 0x8b, 0x15, 0x16, 0x47, 0x71, 0x83, 0xc5, 0x3a, 0x16, + 0xd7, 0x58, 0xe5, 0x9c, 0x9b, 0x60, 0xf1, 0xc5, 0x20, 0x08, 0x99, 0xa4, 0x29, 0x95, 0xf4, 0xcf, + 0x39, 0xd1, 0x14, 0x84, 0x28, 0x07, 0x21, 0x11, 0x21, 0x8d, 0x85, 0x10, 0x5d, 0x43, 0x48, 0xed, + 0x19, 0xb5, 0xd7, 0x87, 0x74, 0xf8, 0x1f, 0x00, 0x00, 0xff, 0xff, 0xb8, 0x61, 0x79, 0xb1, 0x72, + 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/identities/transactions/define/service.pb.gw.go b/x/identities/transactions/define/service.pb.gw.go deleted file mode 100644 index 91b32e954..000000000 --- a/x/identities/transactions/define/service.pb.gw.go +++ /dev/null @@ -1,171 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: AssetMantle/modules/x/identities/transactions/define/service.proto - -/* -Package define is a reverse proxy. - -It translates gRPC into RESTful JSON APIs. -*/ -package define - -import ( - "context" - "io" - "net/http" - - "github.com/golang/protobuf/descriptor" - "github.com/golang/protobuf/proto" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/grpc-ecosystem/grpc-gateway/utilities" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/status" -) - -// Suppress "imported and not used" errors -var _ codes.Code -var _ io.Reader -var _ status.Status -var _ = runtime.String -var _ = utilities.NewDoubleArray -var _ = descriptor.ForMessage -var _ = metadata.Join - -var ( - filter_Msg_Handle_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - -func request_Msg_Handle_0(ctx context.Context, marshaler runtime.Marshaler, client MsgClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq Message - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.Handle(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Msg_Handle_0(ctx context.Context, marshaler runtime.Marshaler, server MsgServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq Message - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.Handle(ctx, &protoReq) - return msg, metadata, err - -} - -// RegisterMsgHandlerServer registers the http handlers for service Msg to "mux". -// UnaryRPC :call MsgServer directly. -// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterMsgHandlerFromEndpoint instead. -func RegisterMsgHandlerServer(ctx context.Context, mux *runtime.ServeMux, server MsgServer) error { - - mux.Handle("POST", pattern_Msg_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Msg_Handle_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Msg_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -// RegisterMsgHandlerFromEndpoint is same as RegisterMsgHandler but -// automatically dials to "endpoint" and closes the connection when "ctx" gets done. -func RegisterMsgHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.Dial(endpoint, opts...) - if err != nil { - return err - } - defer func() { - if err != nil { - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - return - } - go func() { - <-ctx.Done() - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - }() - }() - - return RegisterMsgHandler(ctx, mux, conn) -} - -// RegisterMsgHandler registers the http handlers for service Msg to "mux". -// The handlers forward requests to the grpc endpoint over "conn". -func RegisterMsgHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { - return RegisterMsgHandlerClient(ctx, mux, NewMsgClient(conn)) -} - -// RegisterMsgHandlerClient registers the http handlers for service Msg -// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "MsgClient". -// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "MsgClient" -// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "MsgClient" to call the correct interceptors. -func RegisterMsgHandlerClient(ctx context.Context, mux *runtime.ServeMux, client MsgClient) error { - - mux.Handle("POST", pattern_Msg_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Msg_Handle_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Msg_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -var ( - pattern_Msg_Handle_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"mantle", "identities", "define"}, "", runtime.AssumeColonVerbOpt(false))) -) - -var ( - forward_Msg_Handle_0 = runtime.ForwardResponseMessage -) diff --git a/x/identities/transactions/define/transaction.go b/x/identities/transactions/define/transaction.go index 6242b9071..dac93a936 100644 --- a/x/identities/transactions/define/transaction.go +++ b/x/identities/transactions/define/transaction.go @@ -4,22 +4,14 @@ package define import ( - "context" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "google.golang.org/grpc" - "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/helpers/constants" - "github.com/AssetMantle/modules/utilities/name" + "google.golang.org/grpc" ) -type dummy struct{} - var Transaction = baseHelpers.NewTransaction( - name.GetPackageName(dummy{}), + _Msg_serviceDesc.ServiceName, "", "", @@ -30,9 +22,6 @@ var Transaction = baseHelpers.NewTransaction( func(server grpc.ServiceRegistrar, keeper helpers.TransactionKeeper) { RegisterMsgServer(server, keeper.(transactionKeeper)) }, - func(clientCtx client.Context, mux *runtime.ServeMux) error { - return RegisterMsgHandlerClient(context.Background(), mux, NewMsgClient(clientCtx)) - }, constants.FromIdentityID, constants.ImmutableMetaProperties, diff --git a/x/identities/transactions/define/transaction_keeper.go b/x/identities/transactions/define/transaction_keeper.go index b13409623..e4ca3b0f6 100644 --- a/x/identities/transactions/define/transaction_keeper.go +++ b/x/identities/transactions/define/transaction_keeper.go @@ -6,7 +6,6 @@ package define import ( "context" errorConstants "github.com/AssetMantle/modules/helpers/constants" - baseLists "github.com/AssetMantle/schema/lists/base" "github.com/AssetMantle/schema/properties/constants" "github.com/AssetMantle/schema/qualified/base" diff --git a/x/identities/transactions/define/transaction_request.go b/x/identities/transactions/define/transaction_request.go index 5a9c72509..b06a75799 100644 --- a/x/identities/transactions/define/transaction_request.go +++ b/x/identities/transactions/define/transaction_request.go @@ -5,27 +5,25 @@ package define import ( "encoding/json" - "github.com/AssetMantle/modules/utilities/rest" - - codecUtilities "github.com/AssetMantle/schema/codec/utilities" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" "github.com/AssetMantle/schema/lists/base" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" + "io" + "net/http" "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/helpers/constants" ) type transactionRequest struct { - BaseReq rest.BaseReq `json:"baseReq"` - FromID string `json:"fromID"` - ImmutableMetaProperties string `json:"immutableMetaProperties"` - ImmutableProperties string `json:"immutableProperties"` - MutableMetaProperties string `json:"mutableMetaProperties"` - MutableProperties string `json:"mutableProperties"` + helpers.CommonTransactionRequest `json:"commonTransactionRequest"` + FromID string `json:"fromID"` + ImmutableMetaProperties string `json:"immutableMetaProperties"` + ImmutableProperties string `json:"immutableProperties"` + MutableMetaProperties string `json:"mutableMetaProperties"` + MutableProperties string `json:"mutableProperties"` } var _ helpers.TransactionRequest = (*transactionRequest)(nil) @@ -51,7 +49,7 @@ func (transactionRequest transactionRequest) Validate() error { } func (transactionRequest transactionRequest) FromCLI(cliCommand helpers.CLICommand, context client.Context) (helpers.TransactionRequest, error) { return newTransactionRequest( - cliCommand.ReadBaseReq(context), + cliCommand.ReadCommonTransactionRequest(context), cliCommand.ReadString(constants.FromIdentityID), cliCommand.ReadString(constants.ImmutableMetaProperties), cliCommand.ReadString(constants.ImmutableProperties), @@ -59,19 +57,24 @@ func (transactionRequest transactionRequest) FromCLI(cliCommand helpers.CLIComma cliCommand.ReadString(constants.MutableProperties), ), nil } -func (transactionRequest transactionRequest) FromJSON(rawMessage json.RawMessage) (helpers.TransactionRequest, error) { - if err := json.Unmarshal(rawMessage, &transactionRequest); err != nil { +func (transactionRequest transactionRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.TransactionRequest, error) { + body, err := io.ReadAll(httpRequest.Body) + if err != nil { + return nil, err + } + + if err := json.Unmarshal(body, &transactionRequest); err != nil { return nil, err } return transactionRequest, nil } -func (transactionRequest transactionRequest) GetBaseReq() rest.BaseReq { - return transactionRequest.BaseReq +func (transactionRequest transactionRequest) GetCommonTransactionRequest() helpers.CommonTransactionRequest { + return transactionRequest.CommonTransactionRequest } func (transactionRequest transactionRequest) MakeMsg() (sdkTypes.Msg, error) { - from, err := sdkTypes.AccAddressFromBech32(transactionRequest.GetBaseReq().From) + from, err := sdkTypes.AccAddressFromBech32(transactionRequest.GetCommonTransactionRequest().GetFrom()) if err != nil { return nil, err } @@ -112,19 +115,16 @@ func (transactionRequest transactionRequest) MakeMsg() (sdkTypes.Msg, error) { mutableProperties, ), nil } -func (transactionRequest) RegisterLegacyAminoCodec(legacyAmino *codec.LegacyAmino) { - codecUtilities.RegisterModuleConcrete(legacyAmino, transactionRequest{}) -} func requestPrototype() helpers.TransactionRequest { return transactionRequest{} } -func newTransactionRequest(baseReq rest.BaseReq, fromID string, immutableMetaProperties string, immutableProperties string, mutableMetaProperties string, mutableProperties string) helpers.TransactionRequest { +func newTransactionRequest(commonTransactionRequest helpers.CommonTransactionRequest, fromID string, immutableMetaProperties string, immutableProperties string, mutableMetaProperties string, mutableProperties string) helpers.TransactionRequest { return transactionRequest{ - BaseReq: baseReq, - FromID: fromID, - ImmutableMetaProperties: immutableMetaProperties, - ImmutableProperties: immutableProperties, - MutableMetaProperties: mutableMetaProperties, - MutableProperties: mutableProperties, + CommonTransactionRequest: commonTransactionRequest, + FromID: fromID, + ImmutableMetaProperties: immutableMetaProperties, + ImmutableProperties: immutableProperties, + MutableMetaProperties: mutableMetaProperties, + MutableProperties: mutableProperties, } } diff --git a/x/identities/transactions/define/transaction_request_test.go b/x/identities/transactions/define/transaction_request_test.go index f5def70fd..f50772450 100644 --- a/x/identities/transactions/define/transaction_request_test.go +++ b/x/identities/transactions/define/transaction_request_test.go @@ -4,8 +4,6 @@ package define import ( - "encoding/json" - "github.com/AssetMantle/modules/utilities/rest" "reflect" "testing" @@ -14,7 +12,6 @@ import ( "github.com/AssetMantle/schema/properties/base" baseQualified "github.com/AssetMantle/schema/qualified/base" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" @@ -31,14 +28,14 @@ func Test_newTransactionRequest(t *testing.T) { mutableMetaPropertiesString := "defaultMutableMeta1:S|defaultMutableMeta1" mutablePropertiesString := "defaultMutable1:S|defaultMutable1" fromAddress := "cosmos1pkkayn066msg6kn33wnl5srhdt3tnu2vzasz9c" - testBaseReq := rest.BaseReq{From: fromAddress, ChainID: "test", Fees: sdkTypes.NewCoins()} + commonTransactionRequest := helpers.PrototypeCommonTransactionRequest().SetFrom(fromAddress) type args struct { - baseReq rest.BaseReq - fromID string - immutableMetaProperties string - immutableProperties string - mutableMetaProperties string - mutableProperties string + commonTransactionRequest helpers.CommonTransactionRequest + fromID string + immutableMetaProperties string + immutableProperties string + mutableMetaProperties string + mutableProperties string } tests := []struct { name string @@ -46,11 +43,11 @@ func Test_newTransactionRequest(t *testing.T) { want helpers.TransactionRequest }{ - {"+ve", args{testBaseReq, "fromID", immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, transactionRequest{BaseReq: testBaseReq, FromID: "fromID", ImmutableMetaProperties: immutableMetaPropertiesString, ImmutableProperties: immutablePropertiesString, MutableMetaProperties: mutableMetaPropertiesString, MutableProperties: mutablePropertiesString}}, + {"+ve", args{commonTransactionRequest, "fromID", immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, transactionRequest{CommonTransactionRequest: commonTransactionRequest, FromID: "fromID", ImmutableMetaProperties: immutableMetaPropertiesString, ImmutableProperties: immutablePropertiesString, MutableMetaProperties: mutableMetaPropertiesString, MutableProperties: mutablePropertiesString}}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - if got := newTransactionRequest(tt.args.baseReq, tt.args.fromID, tt.args.immutableMetaProperties, tt.args.immutableProperties, tt.args.mutableMetaProperties, tt.args.mutableProperties); !reflect.DeepEqual(got, tt.want) { + if got := newTransactionRequest(tt.args.commonTransactionRequest, tt.args.fromID, tt.args.immutableMetaProperties, tt.args.immutableProperties, tt.args.mutableMetaProperties, tt.args.mutableProperties); !reflect.DeepEqual(got, tt.want) { t.Errorf("newTransactionRequest() = %v, want %v", got, tt.want) } }) @@ -78,14 +75,14 @@ func Test_transactionRequest_FromCLI(t *testing.T) { cliCommand := baseHelpers.NewCLICommand("", "", "", []helpers.CLIFlag{constants.FromIdentityID, constants.ImmutableMetaProperties, constants.ImmutableProperties, constants.MutableMetaProperties, constants.MutableProperties}) fromAddress := "cosmos1pkkayn066msg6kn33wnl5srhdt3tnu2vzasz9c" - testBaseReq := rest.BaseReq{From: fromAddress, ChainID: "test", Fees: sdkTypes.NewCoins()} + commonTransactionRequest := helpers.PrototypeCommonTransactionRequest().SetFrom(fromAddress) type fields struct { - BaseReq rest.BaseReq - FromID string - ImmutableMetaProperties string - ImmutableProperties string - MutableMetaProperties string - MutableProperties string + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + ImmutableMetaProperties string + ImmutableProperties string + MutableMetaProperties string + MutableProperties string } type args struct { cliCommand helpers.CLICommand @@ -99,17 +96,17 @@ func Test_transactionRequest_FromCLI(t *testing.T) { wantErr bool }{ - {"+ve", fields{BaseReq: testBaseReq, FromID: "", ImmutableMetaProperties: "", ImmutableProperties: "", MutableMetaProperties: "", MutableProperties: ""}, args{cliCommand, client.Context{}.WithCodec(baseHelpers.CodecPrototype())}, transactionRequest{cliCommand.ReadBaseReq(client.Context{}.WithCodec(baseHelpers.CodecPrototype())), cliCommand.ReadString(constants.FromIdentityID), cliCommand.ReadString(constants.ImmutableMetaProperties), cliCommand.ReadString(constants.ImmutableProperties), cliCommand.ReadString(constants.MutableMetaProperties), cliCommand.ReadString(constants.MutableProperties)}, false}, + {"+ve", fields{commonTransactionRequest: commonTransactionRequest, FromID: "", ImmutableMetaProperties: "", ImmutableProperties: "", MutableMetaProperties: "", MutableProperties: ""}, args{cliCommand, client.Context{}.WithCodec(baseHelpers.CodecPrototype())}, transactionRequest{cliCommand.ReadCommonTransactionRequest(client.Context{}.WithCodec(baseHelpers.CodecPrototype())), cliCommand.ReadString(constants.FromIdentityID), cliCommand.ReadString(constants.ImmutableMetaProperties), cliCommand.ReadString(constants.ImmutableProperties), cliCommand.ReadString(constants.MutableMetaProperties), cliCommand.ReadString(constants.MutableProperties)}, false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, - ImmutableProperties: tt.fields.ImmutableProperties, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, + ImmutableProperties: tt.fields.ImmutableProperties, + MutableMetaProperties: tt.fields.MutableMetaProperties, + MutableProperties: tt.fields.MutableProperties, } got, err := transactionRequest.FromCLI(tt.args.cliCommand, tt.args.context) if (err != nil) != tt.wantErr { @@ -123,91 +120,40 @@ func Test_transactionRequest_FromCLI(t *testing.T) { } } -func Test_transactionRequest_FromJSON(t *testing.T) { - immutableMetaPropertiesString := "defaultImmutableMeta1:S|defaultImmutableMeta1" - immutablePropertiesString := "defaultMutableMeta1:S|defaultMutableMeta1" - mutableMetaPropertiesString := "defaultMutableMeta1:S|defaultMutableMeta1" - mutablePropertiesString := "defaultMutable1:S|defaultMutable1" - fromAddress := "cosmos1pkkayn066msg6kn33wnl5srhdt3tnu2vzasz9c" - testBaseReq := rest.BaseReq{From: fromAddress, ChainID: "test", Fees: sdkTypes.NewCoins()} - jsonMessage, _ := json.Marshal(transactionRequest{testBaseReq, "fromID", immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}) - - type fields struct { - BaseReq rest.BaseReq - FromID string - ImmutableMetaProperties string - ImmutableProperties string - MutableMetaProperties string - MutableProperties string - } - type args struct { - rawMessage json.RawMessage - } - tests := []struct { - name string - fields fields - args args - want helpers.TransactionRequest - wantErr bool - }{ - {"+ve", fields{BaseReq: testBaseReq, FromID: "fromID", ImmutableMetaProperties: immutableMetaPropertiesString, ImmutableProperties: immutablePropertiesString, MutableMetaProperties: mutableMetaPropertiesString, MutableProperties: mutablePropertiesString}, args{jsonMessage}, transactionRequest{BaseReq: testBaseReq, FromID: "fromID", ImmutableMetaProperties: immutableMetaPropertiesString, ImmutableProperties: immutablePropertiesString, MutableMetaProperties: mutableMetaPropertiesString, MutableProperties: mutablePropertiesString}, false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, - ImmutableProperties: tt.fields.ImmutableProperties, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, - } - got, err := transactionRequest.FromJSON(tt.args.rawMessage) - if (err != nil) != tt.wantErr { - t.Errorf("FromJSON() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("FromJSON() got = %v, want %v", got, tt.want) - } - }) - } -} - func Test_transactionRequest_GetBaseReq(t *testing.T) { immutableMetaPropertiesString := "defaultImmutableMeta1:S|defaultImmutableMeta1" immutablePropertiesString := "defaultMutableMeta1:S|defaultMutableMeta1" mutableMetaPropertiesString := "defaultMutableMeta1:S|defaultMutableMeta1" mutablePropertiesString := "defaultMutable1:S|defaultMutable1" fromAddress := "cosmos1pkkayn066msg6kn33wnl5srhdt3tnu2vzasz9c" - testBaseReq := rest.BaseReq{From: fromAddress, ChainID: "test", Fees: sdkTypes.NewCoins()} + commonTransactionRequest := helpers.PrototypeCommonTransactionRequest().SetFrom(fromAddress) type fields struct { - BaseReq rest.BaseReq - FromID string - ImmutableMetaProperties string - ImmutableProperties string - MutableMetaProperties string - MutableProperties string + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + ImmutableMetaProperties string + ImmutableProperties string + MutableMetaProperties string + MutableProperties string } tests := []struct { name string fields fields - want rest.BaseReq + want helpers.CommonTransactionRequest }{ - {"+ve", fields{BaseReq: testBaseReq, FromID: "fromID", ImmutableMetaProperties: immutableMetaPropertiesString, ImmutableProperties: immutablePropertiesString, MutableMetaProperties: mutableMetaPropertiesString, MutableProperties: mutablePropertiesString}, testBaseReq}, + {"+ve", fields{commonTransactionRequest: commonTransactionRequest, FromID: "fromID", ImmutableMetaProperties: immutableMetaPropertiesString, ImmutableProperties: immutablePropertiesString, MutableMetaProperties: mutableMetaPropertiesString, MutableProperties: mutablePropertiesString}, commonTransactionRequest}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, - ImmutableProperties: tt.fields.ImmutableProperties, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, + ImmutableProperties: tt.fields.ImmutableProperties, + MutableMetaProperties: tt.fields.MutableMetaProperties, + MutableProperties: tt.fields.MutableProperties, } - if got := transactionRequest.GetBaseReq(); !reflect.DeepEqual(got, tt.want) { - t.Errorf("GetBaseReq() = %v, want %v", got, tt.want) + if got := transactionRequest.GetCommonTransactionRequest(); !reflect.DeepEqual(got, tt.want) { + t.Errorf("GetCommonTransactionRequest() = %v, want %v", got, tt.want) } }) } @@ -232,17 +178,17 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { fromAccAddress, err := sdkTypes.AccAddressFromBech32(fromAddress) require.Nil(t, err) - testBaseReq := rest.BaseReq{From: fromAddress, ChainID: "test", Fees: sdkTypes.NewCoins()} + commonTransactionRequest := helpers.PrototypeCommonTransactionRequest() testIdentity := baseIDs.NewIdentityID(baseIDs.NewClassificationID(baseQualified.NewImmutables(immutableProperties), baseQualified.NewMutables(mutableProperties)), baseQualified.NewImmutables(immutableProperties)) type fields struct { - BaseReq rest.BaseReq - FromID string - ImmutableMetaProperties string - ImmutableProperties string - MutableMetaProperties string - MutableProperties string + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + ImmutableMetaProperties string + ImmutableProperties string + MutableMetaProperties string + MutableProperties string } tests := []struct { name string @@ -250,18 +196,18 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { want sdkTypes.Msg wantErr bool }{ - {"+ve", fields{BaseReq: testBaseReq, FromID: testIdentity.AsString(), ImmutableMetaProperties: immutableMetaPropertiesString, ImmutableProperties: immutablePropertiesString, MutableMetaProperties: mutableMetaPropertiesString, MutableProperties: mutablePropertiesString}, NewMessage(fromAccAddress, testIdentity, baseLists.NewPropertyList(immutableMetaProperties), immutableProperties.ScrubData(), baseLists.NewPropertyList(mutableMetaProperties), mutableProperties.ScrubData()), false}, - {"-ve wrong Identity", fields{BaseReq: testBaseReq, FromID: "WrongIdentity", ImmutableMetaProperties: immutableMetaPropertiesString, ImmutableProperties: immutablePropertiesString, MutableMetaProperties: mutableMetaPropertiesString, MutableProperties: mutablePropertiesString}, nil, true}, + {"+ve", fields{commonTransactionRequest: commonTransactionRequest, FromID: testIdentity.AsString(), ImmutableMetaProperties: immutableMetaPropertiesString, ImmutableProperties: immutablePropertiesString, MutableMetaProperties: mutableMetaPropertiesString, MutableProperties: mutablePropertiesString}, NewMessage(fromAccAddress, testIdentity, baseLists.NewPropertyList(immutableMetaProperties), immutableProperties.ScrubData(), baseLists.NewPropertyList(mutableMetaProperties), mutableProperties.ScrubData()), false}, + {"-ve wrong Identity", fields{commonTransactionRequest: commonTransactionRequest, FromID: "WrongIdentity", ImmutableMetaProperties: immutableMetaPropertiesString, ImmutableProperties: immutablePropertiesString, MutableMetaProperties: mutableMetaPropertiesString, MutableProperties: mutablePropertiesString}, nil, true}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, - ImmutableProperties: tt.fields.ImmutableProperties, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, + ImmutableProperties: tt.fields.ImmutableProperties, + MutableMetaProperties: tt.fields.MutableMetaProperties, + MutableProperties: tt.fields.MutableProperties, } got, err := transactionRequest.MakeMsg() if (err != nil) != tt.wantErr { @@ -275,77 +221,37 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { } } -func Test_transactionRequest_RegisterCodec(t *testing.T) { - immutableMetaPropertiesString := "defaultImmutableMeta1:S|defaultImmutableMeta1" - immutablePropertiesString := "defaultMutableMeta1:S|defaultMutableMeta1" - mutableMetaPropertiesString := "defaultMutableMeta1:S|defaultMutableMeta1" - mutablePropertiesString := "defaultMutable1:S|defaultMutable1" - fromAddress := "cosmos1pkkayn066msg6kn33wnl5srhdt3tnu2vzasz9c" - testBaseReq := rest.BaseReq{From: fromAddress, ChainID: "test", Fees: sdkTypes.NewCoins()} - type fields struct { - BaseReq rest.BaseReq - FromID string - ImmutableMetaProperties string - ImmutableProperties string - MutableMetaProperties string - MutableProperties string - } - type args struct { - legacyAmino *codec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{BaseReq: testBaseReq, FromID: "fromID", ImmutableMetaProperties: immutableMetaPropertiesString, ImmutableProperties: immutablePropertiesString, MutableMetaProperties: mutableMetaPropertiesString, MutableProperties: mutablePropertiesString}, args{codec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - tr := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, - ImmutableProperties: tt.fields.ImmutableProperties, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, - } - tr.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - func Test_transactionRequest_Validate(t *testing.T) { immutableMetaPropertiesString := "defaultImmutableMeta1:S|defaultImmutableMeta1" immutablePropertiesString := "defaultMutableMeta1:S|defaultMutableMeta1" mutableMetaPropertiesString := "defaultMutableMeta1:S|defaultMutableMeta1" mutablePropertiesString := "defaultMutable1:S|defaultMutable1" fromAddress := "cosmos1pkkayn066msg6kn33wnl5srhdt3tnu2vzasz9c" - testBaseReq := rest.BaseReq{From: fromAddress, ChainID: "test", Fees: sdkTypes.NewCoins()} + commonTransactionRequest := helpers.PrototypeCommonTransactionRequest().SetFrom(fromAddress) type fields struct { - BaseReq rest.BaseReq - FromID string - ImmutableMetaProperties string - ImmutableProperties string - MutableMetaProperties string - MutableProperties string + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + ImmutableMetaProperties string + ImmutableProperties string + MutableMetaProperties string + MutableProperties string } tests := []struct { name string fields fields wantErr bool }{ - {"+ve", fields{BaseReq: testBaseReq, FromID: "fromID", ImmutableMetaProperties: immutableMetaPropertiesString, ImmutableProperties: immutablePropertiesString, MutableMetaProperties: mutableMetaPropertiesString, MutableProperties: mutablePropertiesString}, false}, + {"+ve", fields{commonTransactionRequest: commonTransactionRequest, FromID: "fromID", ImmutableMetaProperties: immutableMetaPropertiesString, ImmutableProperties: immutablePropertiesString, MutableMetaProperties: mutableMetaPropertiesString, MutableProperties: mutablePropertiesString}, false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, - ImmutableProperties: tt.fields.ImmutableProperties, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, + ImmutableProperties: tt.fields.ImmutableProperties, + MutableMetaProperties: tt.fields.MutableMetaProperties, + MutableProperties: tt.fields.MutableProperties, } if err := transactionRequest.Validate(); (err != nil) != tt.wantErr { t.Errorf("ValidateBasic() error = %v, wantErr %v", err, tt.wantErr) diff --git a/x/identities/transactions/define/transaction_response.go b/x/identities/transactions/define/transaction_response.go index 967e6fe64..f6ca39134 100644 --- a/x/identities/transactions/define/transaction_response.go +++ b/x/identities/transactions/define/transaction_response.go @@ -4,11 +4,10 @@ package define import ( + "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" sdkTypes "github.com/cosmos/cosmos-sdk/types" - - "github.com/AssetMantle/modules/helpers" ) var _ helpers.TransactionResponse = (*TransactionResponse)(nil) diff --git a/x/identities/transactions/deputize/message.go b/x/identities/transactions/deputize/message.go index 3841e9f1a..1af0c276a 100644 --- a/x/identities/transactions/deputize/message.go +++ b/x/identities/transactions/deputize/message.go @@ -4,28 +4,17 @@ package deputize import ( - codecUtilities "github.com/AssetMantle/schema/codec/utilities" + "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" "github.com/AssetMantle/schema/lists" baseLists "github.com/AssetMantle/schema/lists/base" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/types" sdkTypes "github.com/cosmos/cosmos-sdk/types" - - "github.com/AssetMantle/modules/helpers" ) var _ helpers.Message = (*Message)(nil) -func (message *Message) Type() string { return Transaction.GetName() } -func (message *Message) GetFromAddress() sdkTypes.AccAddress { - from, err := sdkTypes.AccAddressFromBech32(message.From) - if err != nil { - panic(err) - } - return from -} func (message *Message) ValidateBasic() error { if _, err := sdkTypes.AccAddressFromBech32(message.From); err != nil { return err @@ -51,21 +40,10 @@ func (message *Message) GetSigners() []sdkTypes.AccAddress { } return []sdkTypes.AccAddress{from} } -func (*Message) RegisterLegacyAminoCodec(legacyAmino *codec.LegacyAmino) { - codecUtilities.RegisterModuleConcrete(legacyAmino, Message{}) -} func (message *Message) RegisterInterface(interfaceRegistry types.InterfaceRegistry) { interfaceRegistry.RegisterImplementations((*sdkTypes.Msg)(nil), message) } -func messageFromInterface(msg sdkTypes.Msg) *Message { - switch value := msg.(type) { - case *Message: - return value - default: - return &Message{} - } -} func messagePrototype() helpers.Message { return &Message{} } diff --git a/x/identities/transactions/deputize/message_test.go b/x/identities/transactions/deputize/message_test.go index b65f238b4..8ae0217b4 100644 --- a/x/identities/transactions/deputize/message_test.go +++ b/x/identities/transactions/deputize/message_test.go @@ -14,7 +14,6 @@ import ( baseLists "github.com/AssetMantle/schema/lists/base" baseProperties "github.com/AssetMantle/schema/properties/base" baseQualified "github.com/AssetMantle/schema/qualified/base" - "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" @@ -49,28 +48,6 @@ func createTestInput(t *testing.T) (*baseIDs.IdentityID, *baseIDs.IdentityID, *b return testFromID.(*baseIDs.IdentityID), testToID.(*baseIDs.IdentityID), testClassificationID.(*baseIDs.ClassificationID), fromAccAddress, maintainedProperties.(*baseLists.PropertyList) } -func Test_messageFromInterface(t *testing.T) { - testFromID, testToID, testClassificationID, fromAccAddress, maintainedProperties := createTestInput(t) - type args struct { - msg sdkTypes.Msg - } - tests := []struct { - name string - args args - want *Message - }{ - - {"+ve", args{&Message{fromAccAddress.String(), testFromID, testToID, testClassificationID, maintainedProperties, false, false, false, false, false}}, &Message{fromAccAddress.String(), testFromID, testToID, testClassificationID, maintainedProperties, false, false, false, false, false}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := messageFromInterface(tt.args.msg); !reflect.DeepEqual(got, tt.want) { - t.Errorf("messageFromInterface() = %v, want %v", got, tt.want) - } - }) - } -} - func Test_messagePrototype(t *testing.T) { tests := []struct { name string @@ -118,69 +95,6 @@ func Test_message_GetSigners(t *testing.T) { } } -func Test_message_RegisterCodec(t *testing.T) { - testFromID, testToID, testClassificationID, fromAccAddress, maintainedProperties := createTestInput(t) - - type args struct { - legacyAmino *codec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - - {"+ve", fields{fromAccAddress.String(), testFromID, testToID, testClassificationID, maintainedProperties, false, false, false, false, false}, args{codec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - me := &Message{ - From: tt.fields.From, - FromID: tt.fields.FromID, - ToID: tt.fields.ToID, - ClassificationID: tt.fields.ClassificationID, - MaintainedProperties: tt.fields.MaintainedProperties, - CanAddMaintainer: tt.fields.CanAddMaintainer, - CanRemoveMaintainer: tt.fields.CanRemoveMaintainer, - CanMutateMaintainer: tt.fields.CanMutateMaintainer, - } - me.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - -func Test_message_Type(t *testing.T) { - testFromID, testToID, testClassificationID, fromAccAddress, maintainedProperties := createTestInput(t) - - tests := []struct { - name string - fields fields - want string - }{ - - {"+ve", fields{fromAccAddress.String(), testFromID, testToID, testClassificationID, maintainedProperties, false, false, false, false, false}, Transaction.GetName()}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - message := &Message{ - From: tt.fields.From, - FromID: tt.fields.FromID, - ToID: tt.fields.ToID, - ClassificationID: tt.fields.ClassificationID, - MaintainedProperties: tt.fields.MaintainedProperties, - CanIssueIdentity: tt.fields.CanIssueIdentity, - CanQuashIdentity: tt.fields.CanQuashIdentity, - CanAddMaintainer: tt.fields.CanAddMaintainer, - CanRemoveMaintainer: tt.fields.CanRemoveMaintainer, - CanMutateMaintainer: tt.fields.CanMutateMaintainer, - } - if got := message.Type(); got != tt.want { - t.Errorf("Type() = %v, want %v", got, tt.want) - } - }) - } -} - func Test_message_ValidateBasic(t *testing.T) { testFromID, testToID, testClassificationID, fromAccAddress, maintainedProperties := createTestInput(t) diff --git a/x/identities/transactions/deputize/service.pb.go b/x/identities/transactions/deputize/service.pb.go index ee451e8c0..8b5318ead 100644 --- a/x/identities/transactions/deputize/service.pb.go +++ b/x/identities/transactions/deputize/service.pb.go @@ -6,9 +6,9 @@ package deputize import ( context "context" fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types/msgservice" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" - _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -31,30 +31,30 @@ func init() { } var fileDescriptor_c6e0a52473ac78cc = []byte{ - // 368 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0xd2, 0xb1, 0x4a, 0xc3, 0x40, - 0x18, 0x07, 0xf0, 0x26, 0x85, 0x0e, 0xc1, 0xa9, 0x63, 0xd4, 0x0c, 0x75, 0xbf, 0x03, 0x05, 0x87, - 0x73, 0x90, 0x86, 0x82, 0x16, 0x09, 0x54, 0xed, 0x10, 0x24, 0x20, 0xd7, 0xe4, 0x88, 0x07, 0xc9, - 0x5d, 0xc8, 0x5d, 0xa5, 0x38, 0xfa, 0x04, 0x82, 0x6f, 0x20, 0xb8, 0xf8, 0x0a, 0x8e, 0x2e, 0xe2, - 0x54, 0x70, 0x71, 0x94, 0xd4, 0xc9, 0xa7, 0x10, 0x9b, 0x0b, 0xb9, 0xae, 0xb7, 0x1e, 0xf9, 0xff, - 0xf8, 0x7f, 0x5f, 0x3e, 0x67, 0x34, 0x14, 0x82, 0xc8, 0x00, 0x33, 0x99, 0x11, 0x98, 0xf3, 0x64, - 0x9e, 0x11, 0x01, 0x17, 0x90, 0x26, 0x84, 0x49, 0x2a, 0x29, 0x11, 0x50, 0x96, 0x98, 0x09, 0x1c, - 0x4b, 0xca, 0x99, 0x80, 0x09, 0x29, 0xe6, 0x92, 0xde, 0x11, 0x28, 0x48, 0x79, 0x4b, 0x63, 0x02, - 0x8a, 0x92, 0x4b, 0xde, 0x3f, 0xd4, 0x14, 0xa0, 0x14, 0xb0, 0x00, 0xad, 0x02, 0x74, 0x05, 0x34, - 0x8a, 0xbb, 0x93, 0x72, 0x9e, 0x66, 0x04, 0xe2, 0x82, 0x42, 0xcc, 0x18, 0x97, 0xb8, 0xfe, 0x60, - 0xad, 0xba, 0xa6, 0xdd, 0x72, 0x22, 0x04, 0x4e, 0x55, 0x37, 0xf7, 0xdc, 0x50, 0xd1, 0x5e, 0xaf, - 0x4b, 0x22, 0x0a, 0xce, 0x84, 0x22, 0xf7, 0xdf, 0x2c, 0xa7, 0x1b, 0x88, 0xb4, 0xff, 0x6a, 0x39, - 0xbd, 0x53, 0xcc, 0x92, 0x8c, 0xf4, 0x8f, 0x81, 0xd9, 0x0a, 0x40, 0x50, 0x97, 0x75, 0xcf, 0x4c, - 0x81, 0x69, 0xfb, 0x7a, 0xa1, 0x6a, 0x0e, 0xf6, 0xee, 0x3f, 0x7f, 0x1e, 0xed, 0xdd, 0xc1, 0x36, - 0xcc, 0xeb, 0xb9, 0xb5, 0x69, 0x9b, 0xa0, 0xff, 0xdc, 0x7d, 0xaf, 0x3c, 0x6b, 0x59, 0x79, 0xd6, - 0x77, 0xe5, 0x59, 0x0f, 0x2b, 0xaf, 0xb3, 0x5c, 0x79, 0x9d, 0xaf, 0x95, 0xd7, 0x71, 0x50, 0xcc, - 0x73, 0xc3, 0x3e, 0xfe, 0xd6, 0x65, 0x7d, 0x1a, 0x93, 0xff, 0x55, 0x4d, 0xac, 0xab, 0x61, 0x4a, - 0xe5, 0xcd, 0x7c, 0x06, 0x62, 0x9e, 0x43, 0xb3, 0x5f, 0xf1, 0x64, 0xf7, 0x86, 0x41, 0x38, 0x9e, - 0x8e, 0x5e, 0xec, 0x8d, 0x43, 0x0b, 0x54, 0xa9, 0x10, 0x8c, 0xdb, 0x52, 0x53, 0xbd, 0xd4, 0x48, - 0x09, 0x1f, 0x1b, 0xc1, 0x48, 0x05, 0xa3, 0x30, 0x6a, 0x83, 0x91, 0x1e, 0x8c, 0x9a, 0x60, 0x65, - 0xfb, 0x66, 0xc1, 0xe8, 0x64, 0xe2, 0x07, 0x44, 0xe2, 0x04, 0x4b, 0xfc, 0x6b, 0x1f, 0x69, 0x08, - 0x42, 0x4a, 0x41, 0x28, 0x44, 0xa8, 0x75, 0x10, 0xd2, 0x21, 0x84, 0x1a, 0x69, 0xd6, 0x5b, 0x1f, - 0xdd, 0xc1, 0x5f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xb2, 0x77, 0xb6, 0xbb, 0xab, 0x03, 0x00, 0x00, + // 359 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0xd2, 0x31, 0x4b, 0xf3, 0x40, + 0x18, 0x07, 0xf0, 0x5c, 0xca, 0xdb, 0x21, 0xbc, 0x53, 0x17, 0x21, 0x43, 0x06, 0x47, 0x87, 0x3b, + 0x54, 0x70, 0x38, 0x07, 0x69, 0x28, 0x68, 0x91, 0x40, 0xd5, 0x0e, 0x41, 0x02, 0x72, 0x4d, 0x8e, + 0x78, 0xd0, 0xe4, 0x4a, 0x9e, 0x6b, 0x29, 0x4e, 0x7e, 0x04, 0x47, 0x67, 0x41, 0x04, 0x27, 0x3f, + 0x86, 0x38, 0x75, 0x74, 0x94, 0x74, 0x10, 0xfc, 0x14, 0x52, 0x7b, 0x25, 0xd7, 0xf5, 0xa6, 0xc0, + 0x03, 0xff, 0x5f, 0xfe, 0x79, 0xf2, 0x78, 0xbd, 0x2e, 0x00, 0x57, 0x11, 0x2b, 0xd5, 0x98, 0x93, + 0x42, 0x66, 0xd3, 0x31, 0x07, 0x32, 0x27, 0x22, 0xe3, 0xa5, 0x12, 0x4a, 0x70, 0x20, 0xaa, 0x62, + 0x25, 0xb0, 0x54, 0x09, 0x59, 0x02, 0xc9, 0xf8, 0x64, 0xaa, 0xc4, 0x1d, 0x27, 0xc0, 0xab, 0x99, + 0x48, 0x39, 0x9e, 0x54, 0x52, 0xc9, 0xce, 0x91, 0xa1, 0x60, 0xad, 0xe0, 0x39, 0x6e, 0x14, 0x6c, + 0x2a, 0x78, 0xa3, 0xf8, 0x3b, 0xa9, 0x84, 0x42, 0x02, 0x29, 0x20, 0x27, 0xb3, 0xfd, 0xd5, 0x63, + 0x0d, 0xfa, 0xb6, 0xb5, 0x0a, 0x0e, 0xc0, 0x72, 0x5d, 0xcb, 0xbf, 0xb0, 0x54, 0x8c, 0xe9, 0x4d, + 0xc5, 0x61, 0x22, 0x4b, 0xd0, 0xe4, 0xc1, 0x0b, 0xf2, 0x5a, 0x11, 0xe4, 0x9d, 0x47, 0xe4, 0xb5, + 0xcf, 0x58, 0x99, 0x8d, 0x79, 0xe7, 0x04, 0xdb, 0x7d, 0x3d, 0x8e, 0xd6, 0x65, 0xfd, 0x73, 0x5b, + 0x60, 0xd8, 0x4c, 0x2f, 0x75, 0xcd, 0x5d, 0xc7, 0xff, 0x77, 0xff, 0xfd, 0xb6, 0x87, 0xc2, 0xe7, + 0xd6, 0x7b, 0x1d, 0xa0, 0x45, 0x1d, 0xa0, 0xaf, 0x3a, 0x40, 0x0f, 0xcb, 0xc0, 0x59, 0x2c, 0x03, + 0xe7, 0x73, 0x19, 0x38, 0x1e, 0x4d, 0x65, 0x61, 0xf9, 0xce, 0xf0, 0xff, 0xd5, 0xfa, 0xcf, 0x0f, + 0x56, 0xeb, 0x18, 0xa0, 0xeb, 0x6e, 0x2e, 0xd4, 0xed, 0x74, 0x84, 0x53, 0x59, 0x10, 0xbb, 0x75, + 0x3f, 0xb9, 0xed, 0x6e, 0x14, 0xf7, 0x87, 0xbd, 0x57, 0x77, 0xeb, 0x8e, 0x22, 0x5d, 0x2a, 0xc6, + 0xfd, 0xa6, 0xd4, 0xd0, 0x2c, 0xd5, 0xd3, 0xc2, 0xc7, 0x56, 0x30, 0xd1, 0xc1, 0x24, 0x4e, 0x9a, + 0x60, 0x62, 0x06, 0x93, 0x4d, 0xb0, 0x76, 0x43, 0xbb, 0x60, 0x72, 0x3a, 0x08, 0x23, 0xae, 0x58, + 0xc6, 0x14, 0xfb, 0x71, 0x8f, 0x0d, 0x84, 0x52, 0xad, 0x50, 0x1a, 0x53, 0xda, 0x38, 0x94, 0x9a, + 0x10, 0xa5, 0x1b, 0x69, 0xd4, 0xfe, 0x3b, 0xac, 0xc3, 0xdf, 0x00, 0x00, 0x00, 0xff, 0xff, 0xbd, + 0x42, 0x77, 0x7b, 0x8a, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/identities/transactions/deputize/service.pb.gw.go b/x/identities/transactions/deputize/service.pb.gw.go deleted file mode 100644 index bbeb56616..000000000 --- a/x/identities/transactions/deputize/service.pb.gw.go +++ /dev/null @@ -1,171 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: AssetMantle/modules/x/identities/transactions/deputize/service.proto - -/* -Package deputize is a reverse proxy. - -It translates gRPC into RESTful JSON APIs. -*/ -package deputize - -import ( - "context" - "io" - "net/http" - - "github.com/golang/protobuf/descriptor" - "github.com/golang/protobuf/proto" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/grpc-ecosystem/grpc-gateway/utilities" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/status" -) - -// Suppress "imported and not used" errors -var _ codes.Code -var _ io.Reader -var _ status.Status -var _ = runtime.String -var _ = utilities.NewDoubleArray -var _ = descriptor.ForMessage -var _ = metadata.Join - -var ( - filter_Msg_Handle_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - -func request_Msg_Handle_0(ctx context.Context, marshaler runtime.Marshaler, client MsgClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq Message - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.Handle(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Msg_Handle_0(ctx context.Context, marshaler runtime.Marshaler, server MsgServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq Message - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.Handle(ctx, &protoReq) - return msg, metadata, err - -} - -// RegisterMsgHandlerServer registers the http handlers for service Msg to "mux". -// UnaryRPC :call MsgServer directly. -// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterMsgHandlerFromEndpoint instead. -func RegisterMsgHandlerServer(ctx context.Context, mux *runtime.ServeMux, server MsgServer) error { - - mux.Handle("POST", pattern_Msg_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Msg_Handle_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Msg_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -// RegisterMsgHandlerFromEndpoint is same as RegisterMsgHandler but -// automatically dials to "endpoint" and closes the connection when "ctx" gets done. -func RegisterMsgHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.Dial(endpoint, opts...) - if err != nil { - return err - } - defer func() { - if err != nil { - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - return - } - go func() { - <-ctx.Done() - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - }() - }() - - return RegisterMsgHandler(ctx, mux, conn) -} - -// RegisterMsgHandler registers the http handlers for service Msg to "mux". -// The handlers forward requests to the grpc endpoint over "conn". -func RegisterMsgHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { - return RegisterMsgHandlerClient(ctx, mux, NewMsgClient(conn)) -} - -// RegisterMsgHandlerClient registers the http handlers for service Msg -// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "MsgClient". -// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "MsgClient" -// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "MsgClient" to call the correct interceptors. -func RegisterMsgHandlerClient(ctx context.Context, mux *runtime.ServeMux, client MsgClient) error { - - mux.Handle("POST", pattern_Msg_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Msg_Handle_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Msg_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -var ( - pattern_Msg_Handle_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"mantle", "identities", "deputize"}, "", runtime.AssumeColonVerbOpt(false))) -) - -var ( - forward_Msg_Handle_0 = runtime.ForwardResponseMessage -) diff --git a/x/identities/transactions/deputize/transaction.go b/x/identities/transactions/deputize/transaction.go index 4ec5cb127..a02c4815b 100644 --- a/x/identities/transactions/deputize/transaction.go +++ b/x/identities/transactions/deputize/transaction.go @@ -4,22 +4,14 @@ package deputize import ( - "context" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "google.golang.org/grpc" - "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/helpers/constants" - "github.com/AssetMantle/modules/utilities/name" + "google.golang.org/grpc" ) -type dummy struct{} - var Transaction = baseHelpers.NewTransaction( - name.GetPackageName(dummy{}), + _Msg_serviceDesc.ServiceName, "", "", @@ -30,9 +22,6 @@ var Transaction = baseHelpers.NewTransaction( func(server grpc.ServiceRegistrar, keeper helpers.TransactionKeeper) { RegisterMsgServer(server, keeper.(transactionKeeper)) }, - func(clientCtx client.Context, mux *runtime.ServeMux) error { - return RegisterMsgHandlerClient(context.Background(), mux, NewMsgClient(clientCtx)) - }, constants.FromIdentityID, constants.ToIdentityID, diff --git a/x/identities/transactions/deputize/transaction_keeper.go b/x/identities/transactions/deputize/transaction_keeper.go index a964e4eb6..225919b36 100644 --- a/x/identities/transactions/deputize/transaction_keeper.go +++ b/x/identities/transactions/deputize/transaction_keeper.go @@ -5,9 +5,8 @@ package deputize import ( "context" - errorConstants "github.com/AssetMantle/modules/helpers/constants" - "github.com/AssetMantle/modules/helpers" + errorConstants "github.com/AssetMantle/modules/helpers/constants" "github.com/AssetMantle/modules/x/identities/key" "github.com/AssetMantle/modules/x/identities/mappable" "github.com/AssetMantle/modules/x/identities/utilities" @@ -27,7 +26,7 @@ func (transactionKeeper transactionKeeper) Transact(context context.Context, mes } func (transactionKeeper transactionKeeper) Handle(context context.Context, message *Message) (*TransactionResponse, error) { - fromAddress := message.GetFromAddress() + fromAddress := message.GetSigners()[0] if Mappable := transactionKeeper.mapper.NewCollection(context).Fetch(key.NewKey(message.FromID)).GetMappable(key.NewKey(message.FromID)); Mappable == nil { return nil, errorConstants.EntityNotFound.Wrapf("identity with ID %s not found", message.FromID.AsString()) diff --git a/x/identities/transactions/deputize/transaction_request.go b/x/identities/transactions/deputize/transaction_request.go index ff7ecb4b5..54f14ded8 100644 --- a/x/identities/transactions/deputize/transaction_request.go +++ b/x/identities/transactions/deputize/transaction_request.go @@ -5,31 +5,29 @@ package deputize import ( "encoding/json" - "github.com/AssetMantle/modules/utilities/rest" - - codecUtilities "github.com/AssetMantle/schema/codec/utilities" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" "github.com/AssetMantle/schema/lists/base" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" + "io" + "net/http" "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/helpers/constants" ) type transactionRequest struct { - BaseReq rest.BaseReq `json:"baseReq"` - FromID string `json:"fromID"` - ToID string `json:"toID"` - ClassificationID string `json:"classificationID"` - MaintainedProperties string `json:"maintainedProperties"` - CanIssueIdentity bool `json:"canIssueIdentity"` - CanQuashIdentity bool `json:"canQuashIdentity"` - CanAddMaintainer bool `json:"canAddMaintainer"` - CanRemoveMaintainer bool `json:"canRemoveMaintainer"` - CanMutateMaintainer bool `json:"canMutateMaintainer"` + helpers.CommonTransactionRequest `json:"commonTransactionRequest"` + FromID string `json:"fromID"` + ToID string `json:"toID"` + ClassificationID string `json:"classificationID"` + MaintainedProperties string `json:"maintainedProperties"` + CanIssueIdentity bool `json:"canIssueIdentity"` + CanQuashIdentity bool `json:"canQuashIdentity"` + CanAddMaintainer bool `json:"canAddMaintainer"` + CanRemoveMaintainer bool `json:"canRemoveMaintainer"` + CanMutateMaintainer bool `json:"canMutateMaintainer"` } var _ helpers.TransactionRequest = (*transactionRequest)(nil) @@ -55,7 +53,7 @@ func (transactionRequest transactionRequest) Validate() error { } func (transactionRequest transactionRequest) FromCLI(cliCommand helpers.CLICommand, context client.Context) (helpers.TransactionRequest, error) { return newTransactionRequest( - cliCommand.ReadBaseReq(context), + cliCommand.ReadCommonTransactionRequest(context), cliCommand.ReadString(constants.FromIdentityID), cliCommand.ReadString(constants.ToIdentityID), cliCommand.ReadString(constants.ClassificationID), @@ -67,18 +65,23 @@ func (transactionRequest transactionRequest) FromCLI(cliCommand helpers.CLIComma cliCommand.ReadBool(constants.CanMutateMaintainer), ), nil } -func (transactionRequest transactionRequest) FromJSON(rawMessage json.RawMessage) (helpers.TransactionRequest, error) { - if err := json.Unmarshal(rawMessage, &transactionRequest); err != nil { +func (transactionRequest transactionRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.TransactionRequest, error) { + body, err := io.ReadAll(httpRequest.Body) + if err != nil { + return nil, err + } + + if err := json.Unmarshal(body, &transactionRequest); err != nil { return nil, err } return transactionRequest, nil } -func (transactionRequest transactionRequest) GetBaseReq() rest.BaseReq { - return transactionRequest.BaseReq +func (transactionRequest transactionRequest) GetCommonTransactionRequest() helpers.CommonTransactionRequest { + return transactionRequest.CommonTransactionRequest } func (transactionRequest transactionRequest) MakeMsg() (sdkTypes.Msg, error) { - from, err := sdkTypes.AccAddressFromBech32(transactionRequest.GetBaseReq().From) + from, err := sdkTypes.AccAddressFromBech32(transactionRequest.GetCommonTransactionRequest().GetFrom()) if err != nil { return nil, err } @@ -116,23 +119,20 @@ func (transactionRequest transactionRequest) MakeMsg() (sdkTypes.Msg, error) { transactionRequest.CanMutateMaintainer, ), nil } -func (transactionRequest) RegisterLegacyAminoCodec(legacyAmino *codec.LegacyAmino) { - codecUtilities.RegisterModuleConcrete(legacyAmino, transactionRequest{}) -} func requestPrototype() helpers.TransactionRequest { return transactionRequest{} } -func newTransactionRequest(baseReq rest.BaseReq, fromID string, toID string, classificationID string, maintainedProperties string, canIssueIdentity bool, canQuashIdentity bool, canAddMaintainer bool, canRemoveMaintainer bool, canMutateMaintainer bool) helpers.TransactionRequest { +func newTransactionRequest(commonTransactionRequest helpers.CommonTransactionRequest, fromID string, toID string, classificationID string, maintainedProperties string, canIssueIdentity bool, canQuashIdentity bool, canAddMaintainer bool, canRemoveMaintainer bool, canMutateMaintainer bool) helpers.TransactionRequest { return transactionRequest{ - BaseReq: baseReq, - FromID: fromID, - ToID: toID, - ClassificationID: classificationID, - MaintainedProperties: maintainedProperties, - CanIssueIdentity: canIssueIdentity, - CanQuashIdentity: canQuashIdentity, - CanAddMaintainer: canAddMaintainer, - CanRemoveMaintainer: canRemoveMaintainer, - CanMutateMaintainer: canMutateMaintainer, + CommonTransactionRequest: commonTransactionRequest, + FromID: fromID, + ToID: toID, + ClassificationID: classificationID, + MaintainedProperties: maintainedProperties, + CanIssueIdentity: canIssueIdentity, + CanQuashIdentity: canQuashIdentity, + CanAddMaintainer: canAddMaintainer, + CanRemoveMaintainer: canRemoveMaintainer, + CanMutateMaintainer: canMutateMaintainer, } } diff --git a/x/identities/transactions/deputize/transaction_request_test.go b/x/identities/transactions/deputize/transaction_request_test.go index 4bde34e4b..1fdbff2bf 100644 --- a/x/identities/transactions/deputize/transaction_request_test.go +++ b/x/identities/transactions/deputize/transaction_request_test.go @@ -4,13 +4,10 @@ package deputize import ( - "encoding/json" - "github.com/AssetMantle/modules/utilities/rest" "reflect" "testing" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" "github.com/AssetMantle/modules/helpers" @@ -22,29 +19,29 @@ func Test_newTransactionRequest(t *testing.T) { fromAddress := "cosmos1pkkayn066msg6kn33wnl5srhdt3tnu2vzasz9c" maintainedProperty := "maintainedProperties:S|maintainedProperties" - testBaseReq := rest.BaseReq{From: fromAddress, ChainID: "test", Fees: sdkTypes.NewCoins()} + commonTransactionRequest := helpers.PrototypeCommonTransactionRequest().SetFrom(fromAddress).SetFrom(fromAddress) type args struct { - baseReq rest.BaseReq - fromID string - toID string - classificationID string - maintainedProperties string - CanIssueIdentity bool - CanQuashIdentity bool - CanAddMaintainer bool - CanRemoveMaintainer bool - CanMutateMaintainer bool + commonTransactionRequest helpers.CommonTransactionRequest + fromID string + toID string + classificationID string + maintainedProperties string + CanIssueIdentity bool + CanQuashIdentity bool + CanAddMaintainer bool + CanRemoveMaintainer bool + CanMutateMaintainer bool } tests := []struct { name string args args want helpers.TransactionRequest }{ - {"+ve", args{testBaseReq, "fromID", "toID", "classificationID", maintainedProperty, false, false, false, false, false}, transactionRequest{testBaseReq, "fromID", "toID", "classificationID", maintainedProperty, false, false, false, false, false}}, + {"+ve", args{commonTransactionRequest, "fromID", "toID", "classificationID", maintainedProperty, false, false, false, false, false}, transactionRequest{commonTransactionRequest, "fromID", "toID", "classificationID", maintainedProperty, false, false, false, false, false}}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - if got := newTransactionRequest(tt.args.baseReq, tt.args.fromID, tt.args.toID, tt.args.classificationID, tt.args.maintainedProperties, tt.args.CanIssueIdentity, tt.args.CanQuashIdentity, tt.args.CanAddMaintainer, tt.args.CanRemoveMaintainer, tt.args.CanMutateMaintainer); !reflect.DeepEqual(got, tt.want) { + if got := newTransactionRequest(tt.args.commonTransactionRequest, tt.args.fromID, tt.args.toID, tt.args.classificationID, tt.args.maintainedProperties, tt.args.CanIssueIdentity, tt.args.CanQuashIdentity, tt.args.CanAddMaintainer, tt.args.CanRemoveMaintainer, tt.args.CanMutateMaintainer); !reflect.DeepEqual(got, tt.want) { t.Errorf("newTransactionRequest() = %v, want %v", got, tt.want) } }) @@ -71,16 +68,16 @@ func Test_transactionRequest_FromCLI(t *testing.T) { cliCommand := baseHelpers.NewCLICommand("", "", "", []helpers.CLIFlag{constants.FromIdentityID, constants.ToIdentityID, constants.ClassificationID, constants.MaintainedProperties, constants.CanMintAsset, constants.CanBurnAsset, constants.CanRenumerateAsset, constants.CanAddMaintainer, constants.CanRemoveMaintainer, constants.CanMutateMaintainer}) type fields struct { - BaseReq rest.BaseReq - FromID string - ToID string - ClassificationID string - MaintainedProperties string - CanIssueIdentity bool `json:"canIssueIdentity"` - CanQuashIdentity bool `json:"canQuashIdentity"` - CanAddMaintainer bool `json:"canAddMaintainer"` - CanRemoveMaintainer bool `json:"canRemoveMaintainer"` - CanMutateMaintainer bool `json:"canMutateMaintainer"` + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + ToID string + ClassificationID string + MaintainedProperties string + CanIssueIdentity bool `json:"canIssueIdentity"` + CanQuashIdentity bool `json:"canQuashIdentity"` + CanAddMaintainer bool `json:"canAddMaintainer"` + CanRemoveMaintainer bool `json:"canRemoveMaintainer"` + CanMutateMaintainer bool `json:"canMutateMaintainer"` } type args struct { cliCommand helpers.CLICommand @@ -94,19 +91,20 @@ func Test_transactionRequest_FromCLI(t *testing.T) { wantErr bool }{ {"+ve", - fields{BaseReq: rest.BaseReq{From: client.Context{}.WithCodec(baseHelpers.CodecPrototype()).GetFromAddress().String(), ChainID: client.Context{}.WithCodec(baseHelpers.CodecPrototype()).ChainID, Simulate: client.Context{}.WithCodec(baseHelpers.CodecPrototype()).Simulate}, FromID: "", ToID: "", ClassificationID: "", MaintainedProperties: "", CanIssueIdentity: false, CanQuashIdentity: false, CanAddMaintainer: false, CanRemoveMaintainer: false, CanMutateMaintainer: false}, + fields{commonTransactionRequest: helpers.PrototypeCommonTransactionRequest(), FromID: "", ToID: "", ClassificationID: "", MaintainedProperties: "", CanIssueIdentity: false, CanQuashIdentity: false, CanAddMaintainer: false, CanRemoveMaintainer: false, CanMutateMaintainer: false}, args{cliCommand, client.Context{}.WithCodec(baseHelpers.CodecPrototype())}, - transactionRequest{BaseReq: rest.BaseReq{From: client.Context{}.WithCodec(baseHelpers.CodecPrototype()).GetFromAddress().String(), ChainID: client.Context{}.WithCodec(baseHelpers.CodecPrototype()).ChainID, Simulate: client.Context{}.WithCodec(baseHelpers.CodecPrototype()).Simulate}, FromID: "", ToID: "", ClassificationID: "", MaintainedProperties: "", CanIssueIdentity: false, CanQuashIdentity: false, CanAddMaintainer: false, CanRemoveMaintainer: false, CanMutateMaintainer: false}, - false}} + transactionRequest{CommonTransactionRequest: helpers.PrototypeCommonTransactionRequest(), FromID: "", ToID: "", ClassificationID: "", MaintainedProperties: "", CanIssueIdentity: false, CanQuashIdentity: false, CanAddMaintainer: false, CanRemoveMaintainer: false, CanMutateMaintainer: false}, + false, + }} for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - ToID: tt.fields.ToID, - ClassificationID: tt.fields.ClassificationID, - MaintainedProperties: tt.fields.MaintainedProperties, - CanIssueIdentity: tt.fields.CanIssueIdentity, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + ToID: tt.fields.ToID, + ClassificationID: tt.fields.ClassificationID, + MaintainedProperties: tt.fields.MaintainedProperties, + CanIssueIdentity: tt.fields.CanIssueIdentity, } got, err := transactionRequest.FromCLI(tt.args.cliCommand, tt.args.context) if (err != nil) != tt.wantErr { @@ -120,102 +118,46 @@ func Test_transactionRequest_FromCLI(t *testing.T) { } } -func Test_transactionRequest_FromJSON(t *testing.T) { - - fromAddress := "cosmos1pkkayn066msg6kn33wnl5srhdt3tnu2vzasz9c" - maintainedProperty := "maintainedProperties:S|maintainedProperties" - testBaseReq := rest.BaseReq{From: fromAddress, ChainID: "test", Fees: sdkTypes.NewCoins()} - jsonMessage, _ := json.Marshal(newTransactionRequest(testBaseReq, "fromID", "toID", "classificationID", maintainedProperty, false, false, false, false, false)) - type fields struct { - BaseReq rest.BaseReq - FromID string - ToID string - ClassificationID string - MaintainedProperties string - CanIssueIdentity bool `json:"canIssueIdentity"` - CanQuashIdentity bool `json:"canQuashIdentity"` - CanAddMaintainer bool `json:"canAddMaintainer"` - CanRemoveMaintainer bool `json:"canRemoveMaintainer"` - CanMutateMaintainer bool `json:"canMutateMaintainer"` - } - type args struct { - rawMessage json.RawMessage - } - tests := []struct { - name string - fields fields - args args - want helpers.TransactionRequest - wantErr bool - }{ - {"+ve", fields{testBaseReq, "fromID", "toID", "classificationID", maintainedProperty, false, false, false, false, false}, args{jsonMessage}, transactionRequest{testBaseReq, "fromID", "toID", "classificationID", maintainedProperty, false, false, false, false, false}, false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - ToID: tt.fields.ToID, - ClassificationID: tt.fields.ClassificationID, - MaintainedProperties: tt.fields.MaintainedProperties, - CanIssueIdentity: tt.fields.CanIssueIdentity, - CanQuashIdentity: tt.fields.CanQuashIdentity, - CanAddMaintainer: tt.fields.CanAddMaintainer, - CanRemoveMaintainer: tt.fields.CanRemoveMaintainer, - CanMutateMaintainer: tt.fields.CanMutateMaintainer, - } - got, err := transactionRequest.FromJSON(tt.args.rawMessage) - if (err != nil) != tt.wantErr { - t.Errorf("FromJSON() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("FromJSON() got = %v, want %v", got, tt.want) - } - }) - } -} - func Test_transactionRequest_GetBaseReq(t *testing.T) { fromAddress := "cosmos1pkkayn066msg6kn33wnl5srhdt3tnu2vzasz9c" maintainedProperty := "maintainedProperties:S|maintainedProperties" - testBaseReq := rest.BaseReq{From: fromAddress, ChainID: "test", Fees: sdkTypes.NewCoins()} + commonTransactionRequest := helpers.PrototypeCommonTransactionRequest().SetFrom(fromAddress) type fields struct { - BaseReq rest.BaseReq - FromID string - ToID string - ClassificationID string - MaintainedProperties string - CanIssueIdentity bool `json:"canIssueIdentity"` - CanQuashIdentity bool `json:"canQuashIdentity"` - CanAddMaintainer bool `json:"canAddMaintainer"` - CanRemoveMaintainer bool `json:"canRemoveMaintainer"` - CanMutateMaintainer bool `json:"canMutateMaintainer"` + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + ToID string + ClassificationID string + MaintainedProperties string + CanIssueIdentity bool `json:"canIssueIdentity"` + CanQuashIdentity bool `json:"canQuashIdentity"` + CanAddMaintainer bool `json:"canAddMaintainer"` + CanRemoveMaintainer bool `json:"canRemoveMaintainer"` + CanMutateMaintainer bool `json:"canMutateMaintainer"` } tests := []struct { name string fields fields - want rest.BaseReq + want helpers.CommonTransactionRequest }{ - {"+ve", fields{testBaseReq, "fromID", "toID", "classificationID", maintainedProperty, false, false, false, false, false}, testBaseReq}, + {"+ve", fields{commonTransactionRequest, "fromID", "toID", "classificationID", maintainedProperty, false, false, false, false, false}, commonTransactionRequest}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - ToID: tt.fields.ToID, - ClassificationID: tt.fields.ClassificationID, - MaintainedProperties: tt.fields.MaintainedProperties, - CanIssueIdentity: tt.fields.CanIssueIdentity, - CanQuashIdentity: tt.fields.CanQuashIdentity, - CanAddMaintainer: tt.fields.CanAddMaintainer, - CanRemoveMaintainer: tt.fields.CanRemoveMaintainer, - CanMutateMaintainer: tt.fields.CanMutateMaintainer, - } - if got := transactionRequest.GetBaseReq(); !reflect.DeepEqual(got, tt.want) { - t.Errorf("GetBaseReq() = %v, want %v", got, tt.want) + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + ToID: tt.fields.ToID, + ClassificationID: tt.fields.ClassificationID, + MaintainedProperties: tt.fields.MaintainedProperties, + CanIssueIdentity: tt.fields.CanIssueIdentity, + CanQuashIdentity: tt.fields.CanQuashIdentity, + CanAddMaintainer: tt.fields.CanAddMaintainer, + CanRemoveMaintainer: tt.fields.CanRemoveMaintainer, + CanMutateMaintainer: tt.fields.CanMutateMaintainer, + } + if got := transactionRequest.GetCommonTransactionRequest(); !reflect.DeepEqual(got, tt.want) { + t.Errorf("GetCommonTransactionRequest() = %v, want %v", got, tt.want) } }) } @@ -225,18 +167,18 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { testFromID, testToID, testClassificationID, fromAccAddress, maintainedProperties := createTestInput(t) - testBaseReq := rest.BaseReq{From: "cosmos1pkkayn066msg6kn33wnl5srhdt3tnu2vzasz9c", ChainID: "test", Fees: sdkTypes.NewCoins()} + commonTransactionRequest := helpers.PrototypeCommonTransactionRequest() type fields struct { - BaseReq rest.BaseReq - FromID string - ToID string - ClassificationID string - MaintainedProperties string - CanIssueIdentity bool `json:"canIssueIdentity"` - CanQuashIdentity bool `json:"canQuashIdentity"` - CanAddMaintainer bool `json:"canAddMaintainer"` - CanRemoveMaintainer bool `json:"canRemoveMaintainer"` - CanMutateMaintainer bool `json:"canMutateMaintainer"` + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + ToID string + ClassificationID string + MaintainedProperties string + CanIssueIdentity bool `json:"canIssueIdentity"` + CanQuashIdentity bool `json:"canQuashIdentity"` + CanAddMaintainer bool `json:"canAddMaintainer"` + CanRemoveMaintainer bool `json:"canRemoveMaintainer"` + CanMutateMaintainer bool `json:"canMutateMaintainer"` } tests := []struct { name string @@ -244,16 +186,16 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { want sdkTypes.Msg wantErr bool }{ - {"+ve", fields{testBaseReq, testFromID.AsString(), testFromID.AsString(), testClassificationID.AsString(), "maintainedProperty:S|maintainedProperty", false, false, false, false, false}, NewMessage(fromAccAddress, testFromID, testToID, testClassificationID, maintainedProperties, false, false, false, false, false), false}, // TODO: issue==> getting MetaDataError that is not expected + {"+ve", fields{commonTransactionRequest, testFromID.AsString(), testFromID.AsString(), testClassificationID.AsString(), "maintainedProperty:S|maintainedProperty", false, false, false, false, false}, NewMessage(fromAccAddress, testFromID, testToID, testClassificationID, maintainedProperties, false, false, false, false, false), false}, // TODO: issue==> getting MetaDataError that is not expected } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - ToID: tt.fields.ToID, - ClassificationID: tt.fields.ClassificationID, - MaintainedProperties: tt.fields.MaintainedProperties, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + ToID: tt.fields.ToID, + ClassificationID: tt.fields.ClassificationID, + MaintainedProperties: tt.fields.MaintainedProperties, } got, err := transactionRequest.MakeMsg() if (err != nil) != tt.wantErr { @@ -267,89 +209,43 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { } } -func Test_transactionRequest_RegisterCodec(t *testing.T) { - - fromAddress := "cosmos1pkkayn066msg6kn33wnl5srhdt3tnu2vzasz9c" - maintainedProperty := "maintainedProperties:S|maintainedProperties" - testBaseReq := rest.BaseReq{From: fromAddress, ChainID: "test", Fees: sdkTypes.NewCoins()} - type fields struct { - BaseReq rest.BaseReq - FromID string - ToID string - ClassificationID string - MaintainedProperties string - CanIssueIdentity bool `json:"canIssueIdentity"` - CanQuashIdentity bool `json:"canQuashIdentity"` - CanAddMaintainer bool `json:"canAddMaintainer"` - CanRemoveMaintainer bool `json:"canRemoveMaintainer"` - CanMutateMaintainer bool `json:"canMutateMaintainer"` - } - type args struct { - legacyAmino *codec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{testBaseReq, "fromID", "toID", "classificationID", maintainedProperty, false, false, false, false, false}, args{codec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - tr := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - ToID: tt.fields.ToID, - ClassificationID: tt.fields.ClassificationID, - MaintainedProperties: tt.fields.MaintainedProperties, - CanIssueIdentity: tt.fields.CanIssueIdentity, - CanQuashIdentity: tt.fields.CanQuashIdentity, - CanAddMaintainer: tt.fields.CanAddMaintainer, - CanRemoveMaintainer: tt.fields.CanRemoveMaintainer, - CanMutateMaintainer: tt.fields.CanMutateMaintainer, - } - tr.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - func Test_transactionRequest_Validate(t *testing.T) { fromAddress := "cosmos1pkkayn066msg6kn33wnl5srhdt3tnu2vzasz9c" maintainedProperty := "maintainedProperties:S|maintainedProperties" - testBaseReq := rest.BaseReq{From: fromAddress, ChainID: "test", Fees: sdkTypes.NewCoins()} + commonTransactionRequest := helpers.PrototypeCommonTransactionRequest().SetFrom(fromAddress) type fields struct { - BaseReq rest.BaseReq - FromID string - ToID string - ClassificationID string - MaintainedProperties string - CanIssueIdentity bool `json:"canIssueIdentity"` - CanQuashIdentity bool `json:"canQuashIdentity"` - CanAddMaintainer bool `json:"canAddMaintainer"` - CanRemoveMaintainer bool `json:"canRemoveMaintainer"` - CanMutateMaintainer bool `json:"canMutateMaintainer"` + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + ToID string + ClassificationID string + MaintainedProperties string + CanIssueIdentity bool `json:"canIssueIdentity"` + CanQuashIdentity bool `json:"canQuashIdentity"` + CanAddMaintainer bool `json:"canAddMaintainer"` + CanRemoveMaintainer bool `json:"canRemoveMaintainer"` + CanMutateMaintainer bool `json:"canMutateMaintainer"` } tests := []struct { name string fields fields wantErr bool }{ - {"+ve", fields{testBaseReq, "fromID", "toID", "classificationID", maintainedProperty, false, false, false, false, false}, false}, + {"+ve", fields{commonTransactionRequest, "fromID", "toID", "classificationID", maintainedProperty, false, false, false, false, false}, false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - ToID: tt.fields.ToID, - ClassificationID: tt.fields.ClassificationID, - MaintainedProperties: tt.fields.MaintainedProperties, - CanIssueIdentity: tt.fields.CanIssueIdentity, - CanQuashIdentity: tt.fields.CanQuashIdentity, - CanAddMaintainer: tt.fields.CanAddMaintainer, - CanRemoveMaintainer: tt.fields.CanRemoveMaintainer, - CanMutateMaintainer: tt.fields.CanMutateMaintainer, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + ToID: tt.fields.ToID, + ClassificationID: tt.fields.ClassificationID, + MaintainedProperties: tt.fields.MaintainedProperties, + CanIssueIdentity: tt.fields.CanIssueIdentity, + CanQuashIdentity: tt.fields.CanQuashIdentity, + CanAddMaintainer: tt.fields.CanAddMaintainer, + CanRemoveMaintainer: tt.fields.CanRemoveMaintainer, + CanMutateMaintainer: tt.fields.CanMutateMaintainer, } if err := transactionRequest.Validate(); (err != nil) != tt.wantErr { t.Errorf("ValidateBasic() error = %v, wantErr %v", err, tt.wantErr) diff --git a/x/identities/transactions/deputize/transaction_response.go b/x/identities/transactions/deputize/transaction_response.go index 8642b0b49..1af3c6455 100644 --- a/x/identities/transactions/deputize/transaction_response.go +++ b/x/identities/transactions/deputize/transaction_response.go @@ -4,9 +4,8 @@ package deputize import ( - sdkTypes "github.com/cosmos/cosmos-sdk/types" - "github.com/AssetMantle/modules/helpers" + sdkTypes "github.com/cosmos/cosmos-sdk/types" ) var _ helpers.TransactionResponse = (*TransactionResponse)(nil) diff --git a/x/identities/transactions/issue/message.go b/x/identities/transactions/issue/message.go index 6da5898e8..87d889b25 100644 --- a/x/identities/transactions/issue/message.go +++ b/x/identities/transactions/issue/message.go @@ -4,28 +4,17 @@ package issue import ( - codecUtilities "github.com/AssetMantle/schema/codec/utilities" + "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" "github.com/AssetMantle/schema/lists" baseLists "github.com/AssetMantle/schema/lists/base" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/types" sdkTypes "github.com/cosmos/cosmos-sdk/types" - - "github.com/AssetMantle/modules/helpers" ) var _ helpers.Message = (*Message)(nil) -func (message *Message) Type() string { return Transaction.GetName() } -func (message *Message) GetFromAddress() sdkTypes.AccAddress { - from, err := sdkTypes.AccAddressFromBech32(message.From) - if err != nil { - panic(err) - } - return from -} func (message *Message) ValidateBasic() error { if _, err := sdkTypes.AccAddressFromBech32(message.From); err != nil { return err @@ -57,21 +46,10 @@ func (message *Message) GetSigners() []sdkTypes.AccAddress { } return []sdkTypes.AccAddress{from} } -func (*Message) RegisterLegacyAminoCodec(legacyAmino *codec.LegacyAmino) { - codecUtilities.RegisterModuleConcrete(legacyAmino, Message{}) -} func (message *Message) RegisterInterface(interfaceRegistry types.InterfaceRegistry) { interfaceRegistry.RegisterImplementations((*sdkTypes.Msg)(nil), message) } -func messageFromInterface(msg sdkTypes.Msg) *Message { - switch value := msg.(type) { - case *Message: - return value - default: - return &Message{} - } -} func messagePrototype() helpers.Message { return &Message{} } diff --git a/x/identities/transactions/issue/message_test.go b/x/identities/transactions/issue/message_test.go index fd7bb91c6..1d5597506 100644 --- a/x/identities/transactions/issue/message_test.go +++ b/x/identities/transactions/issue/message_test.go @@ -14,7 +14,6 @@ import ( baseLists "github.com/AssetMantle/schema/lists/base" baseProperties "github.com/AssetMantle/schema/properties/base" baseQualified "github.com/AssetMantle/schema/qualified/base" - "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" @@ -65,29 +64,6 @@ func createTestInput(t *testing.T) (*baseIDs.IdentityID, *baseIDs.Classification return testFromID.(*baseIDs.IdentityID), testClassificationID.(*baseIDs.ClassificationID), fromAddress, fromAccAddress, toAddress, toAccAddress, immutableMetaProperties.(*baseLists.PropertyList), immutableProperties.(*baseLists.PropertyList), mutableMetaProperties.(*baseLists.PropertyList), mutableProperties.(*baseLists.PropertyList) } -func Test_messageFromInterface(t *testing.T) { - testFromID, testClassificationID, _, fromAccAddress, _, _, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties := createTestInput(t) - type args struct { - msg sdkTypes.Msg - } - tests := []struct { - name string - args args - want *Message - }{ - - {"+ve", args{NewMessage(fromAccAddress, testFromID, testClassificationID, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties)}, &Message{fromAccAddress.String(), testFromID, testClassificationID, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties}}, - {"+ve with nil", args{}, &Message{}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := messageFromInterface(tt.args.msg); !reflect.DeepEqual(got, tt.want) { - t.Errorf("messageFromInterface() = %v, want %v", got, tt.want) - } - }) - } -} - func Test_messagePrototype(t *testing.T) { tests := []struct { name string @@ -133,63 +109,6 @@ func Test_message_GetSigners(t *testing.T) { } } -func Test_message_RegisterCodec(t *testing.T) { - testFromID, testClassificationID, _, fromAccAddress, _, _, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties := createTestInput(t) - - type args struct { - legacyAmino *codec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{fromAccAddress.String(), testFromID, testClassificationID, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties}, args{codec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - me := &Message{ - From: tt.fields.From, - FromID: tt.fields.FromID, - ClassificationID: tt.fields.ClassificationID, - ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, - ImmutableProperties: tt.fields.ImmutableProperties, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, - } - me.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - -func Test_message_Type(t *testing.T) { - testFromID, testClassificationID, _, fromAccAddress, _, _, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties := createTestInput(t) - - tests := []struct { - name string - fields fields - want string - }{ - {"+ve", fields{fromAccAddress.String(), testFromID, testClassificationID, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties}, Transaction.GetName()}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - message := &Message{ - From: tt.fields.From, - FromID: tt.fields.FromID, - ClassificationID: tt.fields.ClassificationID, - ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, - ImmutableProperties: tt.fields.ImmutableProperties, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, - } - if got := message.Type(); got != tt.want { - t.Errorf("Type() = %v, want %v", got, tt.want) - } - }) - } -} - func Test_message_ValidateBasic(t *testing.T) { testFromID, testClassificationID, _, fromAccAddress, _, _, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties := createTestInput(t) diff --git a/x/identities/transactions/issue/service.pb.go b/x/identities/transactions/issue/service.pb.go index aa839fcd5..c5939adfb 100644 --- a/x/identities/transactions/issue/service.pb.go +++ b/x/identities/transactions/issue/service.pb.go @@ -6,9 +6,9 @@ package issue import ( context "context" fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types/msgservice" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" - _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -31,30 +31,30 @@ func init() { } var fileDescriptor_67f6e03c262c4d59 = []byte{ - // 362 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x92, 0xb1, 0x4a, 0xc3, 0x40, - 0x18, 0x80, 0x9b, 0x14, 0x3a, 0x04, 0xa7, 0x4e, 0x12, 0x24, 0x48, 0x1f, 0xe0, 0x0e, 0xec, 0xa0, - 0x1c, 0xa2, 0xb4, 0x8b, 0xcd, 0x10, 0x29, 0xda, 0x21, 0x48, 0x40, 0xae, 0xc9, 0x11, 0x0f, 0x92, - 0xbb, 0x92, 0xff, 0x2a, 0x9d, 0x7d, 0x02, 0xa1, 0x6f, 0xe0, 0xe8, 0xe8, 0xe8, 0x13, 0x88, 0x53, - 0xc1, 0xc5, 0x51, 0x52, 0x27, 0x9f, 0x42, 0x9a, 0x04, 0x72, 0x5d, 0x6f, 0xbd, 0xe3, 0xfb, 0xf8, - 0xfe, 0x9f, 0xdf, 0x19, 0x8d, 0x00, 0x98, 0x0a, 0xa8, 0x50, 0x19, 0xc3, 0xb9, 0x4c, 0x96, 0x19, - 0x03, 0xbc, 0xc2, 0x3c, 0x61, 0x42, 0x71, 0xc5, 0x19, 0x60, 0x55, 0x50, 0x01, 0x34, 0x56, 0x5c, - 0x0a, 0xc0, 0x1c, 0x60, 0xc9, 0x30, 0xb0, 0xe2, 0x91, 0xc7, 0x0c, 0x2d, 0x0a, 0xa9, 0x64, 0x7f, - 0xa8, 0x29, 0x50, 0xa3, 0x40, 0x2b, 0xd4, 0x2a, 0x90, 0xae, 0x40, 0x95, 0xc2, 0x3d, 0x4a, 0xa5, - 0x4c, 0x33, 0x86, 0xe9, 0x82, 0x63, 0x2a, 0x84, 0x54, 0xb4, 0xfe, 0xad, 0x94, 0xae, 0x51, 0x55, - 0xce, 0x00, 0x68, 0xda, 0x54, 0xb9, 0xd7, 0x26, 0x0a, 0xed, 0xe9, 0xbe, 0x60, 0xb0, 0x90, 0x02, - 0x1a, 0xdf, 0xc9, 0xbb, 0xe5, 0x74, 0x03, 0x48, 0xfb, 0x6f, 0x96, 0xd3, 0x9b, 0x50, 0x91, 0x64, - 0xac, 0x7f, 0x8e, 0x0c, 0x26, 0x47, 0x41, 0x9d, 0xe9, 0x4e, 0x8c, 0xe8, 0x59, 0xfb, 0x74, 0xd3, - 0x04, 0x0e, 0x8e, 0x9f, 0xbe, 0x7e, 0xd7, 0xb6, 0x3b, 0x38, 0xc4, 0x79, 0x3d, 0xae, 0x36, 0x64, - 0x45, 0x8d, 0xd7, 0xdd, 0x8f, 0xd2, 0xb3, 0x36, 0xa5, 0x67, 0xfd, 0x94, 0x9e, 0xf5, 0xbc, 0xf5, - 0x3a, 0x9b, 0xad, 0xd7, 0xf9, 0xde, 0x7a, 0x1d, 0xe7, 0x34, 0x96, 0xb9, 0x49, 0xc9, 0xf8, 0xe0, - 0xb6, 0xbe, 0x82, 0xe9, 0x6e, 0x3d, 0x53, 0xeb, 0xee, 0x22, 0xe5, 0xea, 0x61, 0x39, 0x47, 0xb1, - 0xcc, 0xb1, 0xc1, 0xee, 0x5f, 0xec, 0xde, 0x28, 0x08, 0xfd, 0x99, 0xff, 0x6a, 0xef, 0x1d, 0x54, - 0xd0, 0xe4, 0x84, 0xc8, 0x6f, 0x73, 0x66, 0x7a, 0x8e, 0xbf, 0xc3, 0x3f, 0xf7, 0xa8, 0xa8, 0xa1, - 0xa2, 0x30, 0x6a, 0xa9, 0x48, 0xa7, 0xa2, 0x8a, 0x2a, 0xed, 0x4b, 0x03, 0x2a, 0xba, 0x9a, 0x8e, - 0x03, 0xa6, 0x68, 0x42, 0x15, 0xfd, 0xb3, 0xcf, 0x34, 0x03, 0x21, 0x8d, 0x82, 0x90, 0x90, 0x90, - 0x56, 0x42, 0x88, 0x6e, 0x21, 0xa4, 0xd2, 0xcc, 0x7b, 0xd5, 0x65, 0x0d, 0xff, 0x03, 0x00, 0x00, - 0xff, 0xff, 0x01, 0x5a, 0xf6, 0xd3, 0x84, 0x03, 0x00, 0x00, + // 355 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x92, 0x31, 0x4b, 0xf3, 0x40, + 0x18, 0x80, 0x73, 0x29, 0x5f, 0x87, 0xf0, 0x4d, 0x5d, 0x3e, 0xc8, 0x90, 0xe1, 0x1b, 0x1d, 0xee, + 0xd0, 0x0e, 0xca, 0x21, 0x4a, 0xbb, 0xd8, 0x0c, 0x91, 0xa2, 0x1d, 0x82, 0x04, 0xe4, 0x9a, 0x1c, + 0xf1, 0xa0, 0xc9, 0x95, 0xbc, 0xd7, 0xd2, 0xd1, 0x9f, 0x20, 0xfa, 0x0b, 0x74, 0x74, 0xf2, 0x67, + 0x88, 0x53, 0x47, 0x47, 0x49, 0x07, 0xc1, 0x5f, 0x21, 0x4d, 0x0f, 0x72, 0x5d, 0x6f, 0x0a, 0xbc, + 0xf0, 0x3c, 0x79, 0xf2, 0xe6, 0xf5, 0x06, 0x03, 0x00, 0xae, 0x22, 0x56, 0xaa, 0x19, 0x27, 0x85, + 0xcc, 0x16, 0x33, 0x0e, 0x64, 0x45, 0x44, 0xc6, 0x4b, 0x25, 0x94, 0xe0, 0x40, 0x54, 0xc5, 0x4a, + 0x60, 0xa9, 0x12, 0xb2, 0x04, 0x22, 0x00, 0x16, 0x9c, 0x00, 0xaf, 0x96, 0x22, 0xe5, 0x78, 0x5e, + 0x49, 0x25, 0x7b, 0x7d, 0x43, 0x81, 0xb5, 0x02, 0xaf, 0x70, 0xab, 0xc0, 0xa6, 0x02, 0x37, 0x0a, + 0xff, 0x5f, 0x2a, 0xa1, 0x90, 0x40, 0x0a, 0xc8, 0xc9, 0xf2, 0x70, 0xfb, 0xd8, 0xd9, 0x7c, 0xab, + 0xa0, 0x82, 0x03, 0xb0, 0x5c, 0x07, 0xf9, 0x97, 0x36, 0x0a, 0x63, 0x74, 0x5b, 0x71, 0x98, 0xcb, + 0x12, 0xb4, 0xef, 0xe8, 0x19, 0x79, 0x9d, 0x08, 0xf2, 0xde, 0x23, 0xf2, 0xba, 0x23, 0x56, 0x66, + 0x33, 0xde, 0x3b, 0xc5, 0x16, 0x1f, 0x8d, 0xa3, 0x5d, 0xa6, 0x3f, 0xb2, 0xa2, 0x27, 0xed, 0xe8, + 0x4a, 0x07, 0xfe, 0x77, 0xfc, 0x3f, 0xf7, 0xdf, 0x6f, 0x07, 0x68, 0xf8, 0xd4, 0x79, 0xaf, 0x03, + 0xb4, 0xae, 0x03, 0xf4, 0x55, 0x07, 0xe8, 0x61, 0x13, 0x38, 0xeb, 0x4d, 0xe0, 0x7c, 0x6e, 0x02, + 0xc7, 0x3b, 0x4e, 0x65, 0x61, 0xf3, 0xc2, 0xe1, 0xdf, 0xeb, 0xdd, 0x7f, 0x1e, 0x6f, 0xb7, 0x30, + 0x46, 0x37, 0x67, 0xb9, 0x50, 0x77, 0x8b, 0x29, 0x4e, 0x65, 0x41, 0x2c, 0x56, 0xfc, 0xe2, 0x76, + 0x07, 0x51, 0x1c, 0x4e, 0xc2, 0x57, 0x77, 0xef, 0x64, 0x22, 0x9d, 0x13, 0xe3, 0xb0, 0xcd, 0x99, + 0x98, 0x39, 0xe1, 0x16, 0xff, 0xd8, 0xa3, 0x12, 0x4d, 0x25, 0x71, 0xd2, 0x52, 0x89, 0x49, 0x25, + 0x0d, 0x55, 0xbb, 0xe7, 0x16, 0x54, 0x72, 0x31, 0x1e, 0x46, 0x5c, 0xb1, 0x8c, 0x29, 0xf6, 0xe3, + 0x9e, 0x18, 0x06, 0x4a, 0xb5, 0x82, 0xd2, 0x98, 0xd2, 0x56, 0x42, 0xa9, 0x69, 0xa1, 0xb4, 0xd1, + 0x4c, 0xbb, 0xcd, 0x01, 0xf5, 0x7f, 0x03, 0x00, 0x00, 0xff, 0xff, 0x3f, 0x85, 0x8c, 0xf6, 0x66, + 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/identities/transactions/issue/service.pb.gw.go b/x/identities/transactions/issue/service.pb.gw.go deleted file mode 100644 index 8dd4ae82d..000000000 --- a/x/identities/transactions/issue/service.pb.gw.go +++ /dev/null @@ -1,171 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: AssetMantle/modules/x/identities/transactions/issue/service.proto - -/* -Package issue is a reverse proxy. - -It translates gRPC into RESTful JSON APIs. -*/ -package issue - -import ( - "context" - "io" - "net/http" - - "github.com/golang/protobuf/descriptor" - "github.com/golang/protobuf/proto" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/grpc-ecosystem/grpc-gateway/utilities" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/status" -) - -// Suppress "imported and not used" errors -var _ codes.Code -var _ io.Reader -var _ status.Status -var _ = runtime.String -var _ = utilities.NewDoubleArray -var _ = descriptor.ForMessage -var _ = metadata.Join - -var ( - filter_Msg_Handle_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - -func request_Msg_Handle_0(ctx context.Context, marshaler runtime.Marshaler, client MsgClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq Message - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.Handle(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Msg_Handle_0(ctx context.Context, marshaler runtime.Marshaler, server MsgServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq Message - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.Handle(ctx, &protoReq) - return msg, metadata, err - -} - -// RegisterMsgHandlerServer registers the http handlers for service Msg to "mux". -// UnaryRPC :call MsgServer directly. -// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterMsgHandlerFromEndpoint instead. -func RegisterMsgHandlerServer(ctx context.Context, mux *runtime.ServeMux, server MsgServer) error { - - mux.Handle("POST", pattern_Msg_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Msg_Handle_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Msg_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -// RegisterMsgHandlerFromEndpoint is same as RegisterMsgHandler but -// automatically dials to "endpoint" and closes the connection when "ctx" gets done. -func RegisterMsgHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.Dial(endpoint, opts...) - if err != nil { - return err - } - defer func() { - if err != nil { - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - return - } - go func() { - <-ctx.Done() - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - }() - }() - - return RegisterMsgHandler(ctx, mux, conn) -} - -// RegisterMsgHandler registers the http handlers for service Msg to "mux". -// The handlers forward requests to the grpc endpoint over "conn". -func RegisterMsgHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { - return RegisterMsgHandlerClient(ctx, mux, NewMsgClient(conn)) -} - -// RegisterMsgHandlerClient registers the http handlers for service Msg -// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "MsgClient". -// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "MsgClient" -// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "MsgClient" to call the correct interceptors. -func RegisterMsgHandlerClient(ctx context.Context, mux *runtime.ServeMux, client MsgClient) error { - - mux.Handle("POST", pattern_Msg_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Msg_Handle_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Msg_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -var ( - pattern_Msg_Handle_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"mantle", "identities", "issue"}, "", runtime.AssumeColonVerbOpt(false))) -) - -var ( - forward_Msg_Handle_0 = runtime.ForwardResponseMessage -) diff --git a/x/identities/transactions/issue/transaction.go b/x/identities/transactions/issue/transaction.go index 0b2fedde2..49b77de4e 100644 --- a/x/identities/transactions/issue/transaction.go +++ b/x/identities/transactions/issue/transaction.go @@ -4,22 +4,14 @@ package issue import ( - "context" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "google.golang.org/grpc" - "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/helpers/constants" - "github.com/AssetMantle/modules/utilities/name" + "google.golang.org/grpc" ) -type dummy struct{} - var Transaction = baseHelpers.NewTransaction( - name.GetPackageName(dummy{}), + _Msg_serviceDesc.ServiceName, "", "", @@ -30,9 +22,6 @@ var Transaction = baseHelpers.NewTransaction( func(server grpc.ServiceRegistrar, keeper helpers.TransactionKeeper) { RegisterMsgServer(server, keeper.(transactionKeeper)) }, - func(clientCtx client.Context, mux *runtime.ServeMux) error { - return RegisterMsgHandlerClient(context.Background(), mux, NewMsgClient(clientCtx)) - }, constants.FromIdentityID, constants.ClassificationID, diff --git a/x/identities/transactions/issue/transaction_keeper.go b/x/identities/transactions/issue/transaction_keeper.go index c399cd1a9..cd74eb2f8 100644 --- a/x/identities/transactions/issue/transaction_keeper.go +++ b/x/identities/transactions/issue/transaction_keeper.go @@ -6,7 +6,6 @@ package issue import ( "context" errorConstants "github.com/AssetMantle/modules/helpers/constants" - "github.com/AssetMantle/schema/data" "github.com/AssetMantle/schema/documents/base" baseIDs "github.com/AssetMantle/schema/ids/base" diff --git a/x/identities/transactions/issue/transaction_request.go b/x/identities/transactions/issue/transaction_request.go index 4d9c666d2..99ab0bfab 100644 --- a/x/identities/transactions/issue/transaction_request.go +++ b/x/identities/transactions/issue/transaction_request.go @@ -5,28 +5,26 @@ package issue import ( "encoding/json" - "github.com/AssetMantle/modules/utilities/rest" - - codecUtilities "github.com/AssetMantle/schema/codec/utilities" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" "github.com/AssetMantle/schema/lists/base" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" + "io" + "net/http" "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/helpers/constants" ) type transactionRequest struct { - BaseReq rest.BaseReq `json:"baseReq"` - FromID string `json:"fromID"` - ClassificationID string `json:"classificationID"` - ImmutableMetaProperties string `json:"immutableMetaProperties"` - ImmutableProperties string `json:"immutableProperties"` - MutableMetaProperties string `json:"mutableMetaProperties"` - MutableProperties string `json:"mutableProperties"` + helpers.CommonTransactionRequest `json:"commonTransactionRequest"` + FromID string `json:"fromID"` + ClassificationID string `json:"classificationID"` + ImmutableMetaProperties string `json:"immutableMetaProperties"` + ImmutableProperties string `json:"immutableProperties"` + MutableMetaProperties string `json:"mutableMetaProperties"` + MutableProperties string `json:"mutableProperties"` } var _ helpers.TransactionRequest = (*transactionRequest)(nil) @@ -52,7 +50,7 @@ func (transactionRequest transactionRequest) Validate() error { } func (transactionRequest transactionRequest) FromCLI(cliCommand helpers.CLICommand, context client.Context) (helpers.TransactionRequest, error) { return newTransactionRequest( - cliCommand.ReadBaseReq(context), + cliCommand.ReadCommonTransactionRequest(context), cliCommand.ReadString(constants.FromIdentityID), cliCommand.ReadString(constants.ClassificationID), cliCommand.ReadString(constants.ImmutableMetaProperties), @@ -61,18 +59,23 @@ func (transactionRequest transactionRequest) FromCLI(cliCommand helpers.CLIComma cliCommand.ReadString(constants.MutableProperties), ), nil } -func (transactionRequest transactionRequest) FromJSON(rawMessage json.RawMessage) (helpers.TransactionRequest, error) { - if err := json.Unmarshal(rawMessage, &transactionRequest); err != nil { +func (transactionRequest transactionRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.TransactionRequest, error) { + body, err := io.ReadAll(httpRequest.Body) + if err != nil { + return nil, err + } + + if err := json.Unmarshal(body, &transactionRequest); err != nil { return nil, err } return transactionRequest, nil } -func (transactionRequest transactionRequest) GetBaseReq() rest.BaseReq { - return transactionRequest.BaseReq +func (transactionRequest transactionRequest) GetCommonTransactionRequest() helpers.CommonTransactionRequest { + return transactionRequest.CommonTransactionRequest } func (transactionRequest transactionRequest) MakeMsg() (sdkTypes.Msg, error) { - from, err := sdkTypes.AccAddressFromBech32(transactionRequest.GetBaseReq().From) + from, err := sdkTypes.AccAddressFromBech32(transactionRequest.GetCommonTransactionRequest().GetFrom()) if err != nil { return nil, err } @@ -118,20 +121,17 @@ func (transactionRequest transactionRequest) MakeMsg() (sdkTypes.Msg, error) { mutableProperties, ), nil } -func (transactionRequest) RegisterLegacyAminoCodec(legacyAmino *codec.LegacyAmino) { - codecUtilities.RegisterModuleConcrete(legacyAmino, transactionRequest{}) -} func requestPrototype() helpers.TransactionRequest { return transactionRequest{} } -func newTransactionRequest(baseReq rest.BaseReq, fromID string, classificationID string, immutableMetaProperties string, immutableProperties string, mutableMetaProperties string, mutableProperties string) helpers.TransactionRequest { +func newTransactionRequest(commonTransactionRequest helpers.CommonTransactionRequest, fromID string, classificationID string, immutableMetaProperties string, immutableProperties string, mutableMetaProperties string, mutableProperties string) helpers.TransactionRequest { return transactionRequest{ - BaseReq: baseReq, - FromID: fromID, - ClassificationID: classificationID, - ImmutableMetaProperties: immutableMetaProperties, - ImmutableProperties: immutableProperties, - MutableMetaProperties: mutableMetaProperties, - MutableProperties: mutableProperties, + CommonTransactionRequest: commonTransactionRequest, + FromID: fromID, + ClassificationID: classificationID, + ImmutableMetaProperties: immutableMetaProperties, + ImmutableProperties: immutableProperties, + MutableMetaProperties: mutableMetaProperties, + MutableProperties: mutableProperties, } } diff --git a/x/identities/transactions/issue/transaction_request_test.go b/x/identities/transactions/issue/transaction_request_test.go index 1700a55ef..644a2db1e 100644 --- a/x/identities/transactions/issue/transaction_request_test.go +++ b/x/identities/transactions/issue/transaction_request_test.go @@ -4,9 +4,7 @@ package issue import ( - "encoding/json" "fmt" - "github.com/AssetMantle/modules/utilities/rest" "reflect" "testing" @@ -27,7 +25,7 @@ import ( "github.com/AssetMantle/modules/helpers/constants" ) -func createTestInputForRequest(t *testing.T) (*codec.LegacyAmino, helpers.CLICommand, client.Context, string, string, string, string, lists.PropertyList, lists.PropertyList, lists.PropertyList, lists.PropertyList, string, sdkTypes.AccAddress, string, sdkTypes.AccAddress, rest.BaseReq) { +func createTestInputForRequest(t *testing.T) (*codec.LegacyAmino, helpers.CLICommand, client.Context, string, string, string, string, lists.PropertyList, lists.PropertyList, lists.PropertyList, lists.PropertyList, string, sdkTypes.AccAddress, string, sdkTypes.AccAddress, helpers.CommonTransactionRequest) { var legacyAmino = baseHelpers.CodecPrototype().GetLegacyAmino() cliCommand := baseHelpers.NewCLICommand("", "", "", []helpers.CLIFlag{constants.FromIdentityID, constants.To, constants.ClassificationID, constants.ImmutableMetaProperties, constants.ImmutableProperties, constants.MutableMetaProperties, constants.MutableProperties}) @@ -61,22 +59,22 @@ func createTestInputForRequest(t *testing.T) (*codec.LegacyAmino, helpers.CLICom toAccAddress, err = sdkTypes.AccAddressFromBech32(fromAddress) require.Nil(t, err) - testBaseReq := rest.BaseReq{From: fromAddress, ChainID: "test", Fees: sdkTypes.NewCoins()} + commonTransactionRequest := helpers.PrototypeCommonTransactionRequest() - return legacyAmino, cliCommand, client.Context{}.WithCodec(baseHelpers.CodecPrototype()), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties, fromAddress, fromAccAddress, toAddress, toAccAddress, testBaseReq + return legacyAmino, cliCommand, client.Context{}.WithCodec(baseHelpers.CodecPrototype()), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties, fromAddress, fromAccAddress, toAddress, toAccAddress, commonTransactionRequest } func Test_newTransactionRequest(t *testing.T) { - _, _, _, immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString, _, _, _, _, _, _, toAddress, _, testBaseReq := createTestInputForRequest(t) + _, _, _, immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString, _, _, _, _, _, _, toAddress, _, commonTransactionRequest := createTestInputForRequest(t) type args struct { - baseReq rest.BaseReq - to string - fromID string - classificationID string - immutableMetaProperties string - immutableProperties string - mutableMetaProperties string - mutableProperties string + commonTransactionRequest helpers.CommonTransactionRequest + to string + fromID string + classificationID string + immutableMetaProperties string + immutableProperties string + mutableMetaProperties string + mutableProperties string } tests := []struct { name string @@ -84,11 +82,11 @@ func Test_newTransactionRequest(t *testing.T) { want helpers.TransactionRequest }{ - {"+ve", args{testBaseReq, toAddress, "fromID", "classificationID", immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, transactionRequest{testBaseReq, "fromID", "classificationID", immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}}, + {"+ve", args{commonTransactionRequest, toAddress, "fromID", "classificationID", immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, transactionRequest{commonTransactionRequest, "fromID", "classificationID", immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - if got := newTransactionRequest(tt.args.baseReq, tt.args.fromID, tt.args.classificationID, tt.args.immutableMetaProperties, tt.args.immutableProperties, tt.args.mutableMetaProperties, tt.args.mutableProperties); !reflect.DeepEqual(got, tt.want) { + if got := newTransactionRequest(tt.args.commonTransactionRequest, tt.args.fromID, tt.args.classificationID, tt.args.immutableMetaProperties, tt.args.immutableProperties, tt.args.mutableMetaProperties, tt.args.mutableProperties); !reflect.DeepEqual(got, tt.want) { t.Errorf("newTransactionRequest() = %v, want %v", got, tt.want) } }) @@ -113,16 +111,16 @@ func Test_requestPrototype(t *testing.T) { } func Test_transactionRequest_FromCLI(t *testing.T) { - _, cliCommand, context, immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString, _, _, _, _, _, _, toAddress, _, testBaseReq := createTestInputForRequest(t) + _, cliCommand, context, immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString, _, _, _, _, _, _, toAddress, _, commonTransactionRequest := createTestInputForRequest(t) type fields struct { - BaseReq rest.BaseReq - To string - FromID string - ClassificationID string - ImmutableMetaProperties string - ImmutableProperties string - MutableMetaProperties string - MutableProperties string + commonTransactionRequest helpers.CommonTransactionRequest + To string + FromID string + ClassificationID string + ImmutableMetaProperties string + ImmutableProperties string + MutableMetaProperties string + MutableProperties string } type args struct { cliCommand helpers.CLICommand @@ -135,18 +133,18 @@ func Test_transactionRequest_FromCLI(t *testing.T) { want helpers.TransactionRequest wantErr bool }{ - {"+ve", fields{testBaseReq, toAddress, "fromID", "classificationID", immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, args{cliCommand, client.Context{}.WithCodec(baseHelpers.CodecPrototype())}, transactionRequest{cliCommand.ReadBaseReq(context), cliCommand.ReadString(constants.FromIdentityID), cliCommand.ReadString(constants.ClassificationID), cliCommand.ReadString(constants.ImmutableMetaProperties), cliCommand.ReadString(constants.ImmutableProperties), cliCommand.ReadString(constants.MutableMetaProperties), cliCommand.ReadString(constants.MutableProperties)}, false}, + {"+ve", fields{commonTransactionRequest, toAddress, "fromID", "classificationID", immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, args{cliCommand, client.Context{}.WithCodec(baseHelpers.CodecPrototype())}, transactionRequest{cliCommand.ReadCommonTransactionRequest(context), cliCommand.ReadString(constants.FromIdentityID), cliCommand.ReadString(constants.ClassificationID), cliCommand.ReadString(constants.ImmutableMetaProperties), cliCommand.ReadString(constants.ImmutableProperties), cliCommand.ReadString(constants.MutableMetaProperties), cliCommand.ReadString(constants.MutableProperties)}, false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - ClassificationID: tt.fields.ClassificationID, - ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, - ImmutableProperties: tt.fields.ImmutableProperties, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + ClassificationID: tt.fields.ClassificationID, + ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, + ImmutableProperties: tt.fields.ImmutableProperties, + MutableMetaProperties: tt.fields.MutableMetaProperties, + MutableProperties: tt.fields.MutableProperties, } got, err := transactionRequest.FromCLI(tt.args.cliCommand, tt.args.context) if (err != nil) != tt.wantErr { @@ -160,112 +158,59 @@ func Test_transactionRequest_FromCLI(t *testing.T) { } } -func Test_transactionRequest_FromJSON(t *testing.T) { - _, _, _, immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString, _, _, _, _, _, _, toAddress, _, testBaseReq := createTestInputForRequest(t) - jsonMessage, err := json.Marshal(newTransactionRequest(testBaseReq, "fromID", "classificationID", immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString)) - require.Equal(t, nil, err) - jsonMessage1, err := json.Marshal(newTransactionRequest(testBaseReq, "", "", immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString)) - require.Equal(t, nil, err) - type fields struct { - BaseReq rest.BaseReq - To string - FromID string - ClassificationID string - ImmutableMetaProperties string - ImmutableProperties string - MutableMetaProperties string - MutableProperties string - } - type args struct { - rawMessage json.RawMessage - } - tests := []struct { - name string - fields fields - args args - want helpers.TransactionRequest - wantErr bool - }{ - - {"+ve", fields{testBaseReq, toAddress, "fromID", "classificationID", immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, args{jsonMessage}, transactionRequest{testBaseReq, "fromID", "classificationID", immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, false}, - {"+ve", fields{testBaseReq, toAddress, "fromID", "classificationID", immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, args{jsonMessage1}, transactionRequest{testBaseReq, "fromID", "classificationID", immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - ClassificationID: tt.fields.ClassificationID, - ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, - ImmutableProperties: tt.fields.ImmutableProperties, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, - } - got, err := transactionRequest.FromJSON(tt.args.rawMessage) - if (err != nil) != tt.wantErr { - t.Errorf("FromJSON() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("FromJSON() got = %v, want %v", got, tt.want) - } - }) - } -} - func Test_transactionRequest_GetBaseReq(t *testing.T) { - _, _, _, immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString, _, _, _, _, _, _, toAddress, _, testBaseReq := createTestInputForRequest(t) + _, _, _, immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString, _, _, _, _, _, _, toAddress, _, commonTransactionRequest := createTestInputForRequest(t) type fields struct { - BaseReq rest.BaseReq - To string - FromID string - ClassificationID string - ImmutableMetaProperties string - ImmutableProperties string - MutableMetaProperties string - MutableProperties string + commonTransactionRequest helpers.CommonTransactionRequest + To string + FromID string + ClassificationID string + ImmutableMetaProperties string + ImmutableProperties string + MutableMetaProperties string + MutableProperties string } tests := []struct { name string fields fields - want rest.BaseReq + want helpers.CommonTransactionRequest }{ - {"+ve", fields{testBaseReq, toAddress, "fromID", "classificationID", immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, testBaseReq}, + {"+ve", fields{commonTransactionRequest, toAddress, "fromID", "classificationID", immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, commonTransactionRequest}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - ClassificationID: tt.fields.ClassificationID, - ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, - ImmutableProperties: tt.fields.ImmutableProperties, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + ClassificationID: tt.fields.ClassificationID, + ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, + ImmutableProperties: tt.fields.ImmutableProperties, + MutableMetaProperties: tt.fields.MutableMetaProperties, + MutableProperties: tt.fields.MutableProperties, } - if got := transactionRequest.GetBaseReq(); !reflect.DeepEqual(got, tt.want) { - t.Errorf("GetBaseReq() = %v, want %v", got, tt.want) + if got := transactionRequest.GetCommonTransactionRequest(); !reflect.DeepEqual(got, tt.want) { + t.Errorf("GetCommonTransactionRequest() = %v, want %v", got, tt.want) } }) } } func Test_transactionRequest_MakeMsg(t *testing.T) { - _, _, _, immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties, _, fromAccAddress, toAddress, _, testBaseReq := createTestInputForRequest(t) + _, _, _, immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties, _, fromAccAddress, toAddress, _, commonTransactionRequest := createTestInputForRequest(t) immutables := baseQualified.NewImmutables(baseLists.NewPropertyList(baseProperties.NewMesaProperty(baseIDs.NewStringID("ID2"), baseData.NewStringData("Data2")))) mutables := baseQualified.NewMutables(baseLists.NewPropertyList(baseProperties.NewMesaProperty(baseIDs.NewStringID("ID1"), baseData.NewStringData("Data1")))) testClassificationID := baseIDs.NewClassificationID(immutables, mutables) testFromID := baseIDs.NewIdentityID(testClassificationID, immutables) type fields struct { - BaseReq rest.BaseReq - To string - FromID string - ClassificationID string - ImmutableMetaProperties string - ImmutableProperties string - MutableMetaProperties string - MutableProperties string + commonTransactionRequest helpers.CommonTransactionRequest + To string + FromID string + ClassificationID string + ImmutableMetaProperties string + ImmutableProperties string + MutableMetaProperties string + MutableProperties string } tests := []struct { name string @@ -273,18 +218,18 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { want sdkTypes.Msg wantErr bool }{ - {"+ve", fields{testBaseReq, toAddress, "9UNIA3_tulK2vRE0nSmsHKNzhDxoCBHI4z8XXfLO1FM=", "9UNIA3_tulK2vRE0nSmsHKNzhDxoCBHI4z8XXfLO1FM=", immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, NewMessage(fromAccAddress, testFromID, testClassificationID, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties), false}, // TODO: issue==> getting MetaDataError that is not expected + {"+ve", fields{commonTransactionRequest, toAddress, "9UNIA3_tulK2vRE0nSmsHKNzhDxoCBHI4z8XXfLO1FM=", "9UNIA3_tulK2vRE0nSmsHKNzhDxoCBHI4z8XXfLO1FM=", immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, NewMessage(fromAccAddress, testFromID, testClassificationID, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties), false}, // TODO: issue==> getting MetaDataError that is not expected } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - ClassificationID: tt.fields.ClassificationID, - ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, - ImmutableProperties: tt.fields.ImmutableProperties, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + ClassificationID: tt.fields.ClassificationID, + ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, + ImmutableProperties: tt.fields.ImmutableProperties, + MutableMetaProperties: tt.fields.MutableMetaProperties, + MutableProperties: tt.fields.MutableProperties, } got, err := transactionRequest.MakeMsg() if (err != nil) != tt.wantErr { @@ -298,77 +243,39 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { } } -func Test_transactionRequest_RegisterCodec(t *testing.T) { - _, _, _, immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString, _, _, _, _, _, _, toAddress, _, testBaseReq := createTestInputForRequest(t) - type fields struct { - BaseReq rest.BaseReq - To string - FromID string - ClassificationID string - ImmutableMetaProperties string - ImmutableProperties string - MutableMetaProperties string - MutableProperties string - } - type args struct { - legacyAmino *codec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{testBaseReq, toAddress, "fromID", "classificationID", immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, args{codec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - tr := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - ClassificationID: tt.fields.ClassificationID, - ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, - ImmutableProperties: tt.fields.ImmutableProperties, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, - } - tr.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - func Test_transactionRequest_Validate(t *testing.T) { - _, _, _, immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString, _, _, _, _, _, _, toAddress, _, testBaseReq := createTestInputForRequest(t) - testBaseReq1 := rest.BaseReq{} + _, _, _, immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString, _, _, _, _, _, _, toAddress, _, commonTransactionRequest := createTestInputForRequest(t) + commonTransactionRequest1 := helpers.PrototypeCommonTransactionRequest() type fields struct { - BaseReq rest.BaseReq - To string - FromID string - ClassificationID string - ImmutableMetaProperties string - ImmutableProperties string - MutableMetaProperties string - MutableProperties string + commonTransactionRequest helpers.CommonTransactionRequest + To string + FromID string + ClassificationID string + ImmutableMetaProperties string + ImmutableProperties string + MutableMetaProperties string + MutableProperties string } tests := []struct { name string fields fields wantErr bool }{ - {"+ve", fields{testBaseReq, toAddress, "fromID", "classificationID", immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, false}, - {"+ve", fields{testBaseReq1, toAddress, "fromID", "classificationID", immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, false}, + {"+ve", fields{commonTransactionRequest, toAddress, "fromID", "classificationID", immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, false}, + {"+ve", fields{commonTransactionRequest1, toAddress, "fromID", "classificationID", immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, false}, {"-ve", fields{ClassificationID: ""}, true}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - ClassificationID: tt.fields.ClassificationID, - ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, - ImmutableProperties: tt.fields.ImmutableProperties, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + ClassificationID: tt.fields.ClassificationID, + ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, + ImmutableProperties: tt.fields.ImmutableProperties, + MutableMetaProperties: tt.fields.MutableMetaProperties, + MutableProperties: tt.fields.MutableProperties, } if err := transactionRequest.Validate(); (err != nil) != tt.wantErr { t.Errorf("ValidateBasic() error = %v, wantErr %v", err, tt.wantErr) diff --git a/x/identities/transactions/issue/transaction_response.go b/x/identities/transactions/issue/transaction_response.go index cab246b7f..86df9c7d6 100644 --- a/x/identities/transactions/issue/transaction_response.go +++ b/x/identities/transactions/issue/transaction_response.go @@ -4,11 +4,10 @@ package issue import ( + "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" sdkTypes "github.com/cosmos/cosmos-sdk/types" - - "github.com/AssetMantle/modules/helpers" ) var _ helpers.TransactionResponse = (*TransactionResponse)(nil) diff --git a/x/identities/transactions/name/message.go b/x/identities/transactions/name/message.go index 7c4b42af1..315ec3d1e 100644 --- a/x/identities/transactions/name/message.go +++ b/x/identities/transactions/name/message.go @@ -4,27 +4,16 @@ package name import ( + "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/helpers/constants" - codecUtilities "github.com/AssetMantle/schema/codec/utilities" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/types" sdkTypes "github.com/cosmos/cosmos-sdk/types" - - "github.com/AssetMantle/modules/helpers" ) var _ helpers.Message = (*Message)(nil) -func (message *Message) Type() string { return Transaction.GetName() } -func (message *Message) GetFromAddress() sdkTypes.AccAddress { - from, err := sdkTypes.AccAddressFromBech32(message.From) - if err != nil { - panic(err) - } - return from -} func (message *Message) ValidateBasic() error { if _, err := sdkTypes.AccAddressFromBech32(message.From); err != nil { return err @@ -47,21 +36,10 @@ func (message *Message) GetSigners() []sdkTypes.AccAddress { } return []sdkTypes.AccAddress{from} } -func (*Message) RegisterLegacyAminoCodec(legacyAmino *codec.LegacyAmino) { - codecUtilities.RegisterModuleConcrete(legacyAmino, Message{}) -} func (message *Message) RegisterInterface(interfaceRegistry types.InterfaceRegistry) { interfaceRegistry.RegisterImplementations((*sdkTypes.Msg)(nil), message) } -func messageFromInterface(msg sdkTypes.Msg) *Message { - switch value := msg.(type) { - case *Message: - return value - default: - return &Message{} - } -} func messagePrototype() helpers.Message { return &Message{} } diff --git a/x/identities/transactions/name/message_test.go b/x/identities/transactions/name/message_test.go index 3de51d2ad..dd7ea8532 100644 --- a/x/identities/transactions/name/message_test.go +++ b/x/identities/transactions/name/message_test.go @@ -9,7 +9,6 @@ import ( "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" - "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" @@ -31,28 +30,6 @@ func createTestInput(t *testing.T) (*baseIDs.StringID, string, sdkTypes.AccAddre return testNubID.(*baseIDs.StringID), fromAddress, fromAccAddress } -func Test_messageFromInterface(t *testing.T) { - testNubID, _, fromAccAddress := createTestInput(t) - type args struct { - msg sdkTypes.Msg - } - tests := []struct { - name string - args args - want *Message - }{ - {"+ve", args{&Message{fromAccAddress.String(), testNubID}}, &Message{fromAccAddress.String(), testNubID}}, - {"+ve", args{nil}, &Message{}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := messageFromInterface(tt.args.msg); !reflect.DeepEqual(got, tt.want) { - t.Errorf("messageFromInterface() = %v, want %v", got, tt.want) - } - }) - } -} - func Test_messagePrototype(t *testing.T) { tests := []struct { name string @@ -92,53 +69,6 @@ func Test_message_GetSigners(t *testing.T) { } } -func Test_message_RegisterCodec(t *testing.T) { - testNubID, _, fromAccAddress := createTestInput(t) - - type args struct { - legacyAmino *codec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{fromAccAddress.String(), testNubID}, args{codec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - me := &Message{ - tt.fields.From, - tt.fields.NubID, - } - me.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - -func Test_message_Type(t *testing.T) { - testNubID, _, fromAccAddress := createTestInput(t) - - tests := []struct { - name string - fields fields - want string - }{ - {"+ve", fields{fromAccAddress.String(), testNubID}, Transaction.GetName()}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - message := &Message{ - tt.fields.From, - tt.fields.NubID, - } - if got := message.Type(); got != tt.want { - t.Errorf("Type() = %v, want %v", got, tt.want) - } - }) - } -} - func Test_message_ValidateBasic(t *testing.T) { testNubID, _, fromAccAddress := createTestInput(t) diff --git a/x/identities/transactions/name/service.pb.go b/x/identities/transactions/name/service.pb.go index aa3223290..837c199eb 100644 --- a/x/identities/transactions/name/service.pb.go +++ b/x/identities/transactions/name/service.pb.go @@ -6,9 +6,9 @@ package name import ( context "context" fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types/msgservice" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" - _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -31,30 +31,30 @@ func init() { } var fileDescriptor_5f93b42fa6f5fa12 = []byte{ - // 368 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x92, 0x31, 0x4b, 0xf3, 0x40, - 0x18, 0x80, 0x9b, 0x14, 0x3a, 0x84, 0x6f, 0xea, 0xf2, 0xf1, 0x85, 0x8f, 0x7c, 0xd0, 0x1f, 0x70, - 0x07, 0xfd, 0x40, 0xe1, 0x44, 0xb1, 0x5d, 0x6a, 0x87, 0x94, 0xa2, 0x1d, 0x82, 0x04, 0xe4, 0x9a, - 0xbc, 0xc4, 0x40, 0xee, 0xae, 0xe4, 0xae, 0xd2, 0xd9, 0x5d, 0x10, 0xfc, 0x07, 0x8e, 0x2e, 0x8e, - 0xfe, 0x05, 0x71, 0x2a, 0xb8, 0x38, 0x4a, 0xea, 0xe4, 0xaf, 0x90, 0x34, 0x07, 0xb9, 0x8e, 0xcd, - 0x7a, 0xe1, 0x79, 0x78, 0xde, 0x37, 0xaf, 0x73, 0x3a, 0x90, 0x12, 0x94, 0x4f, 0xb9, 0xca, 0x00, - 0x33, 0x11, 0x2f, 0x33, 0x90, 0x78, 0x85, 0xd3, 0x18, 0xb8, 0x4a, 0x55, 0x0a, 0x12, 0xab, 0x9c, - 0x72, 0x49, 0x23, 0x95, 0x0a, 0x2e, 0x31, 0xa7, 0x0c, 0xb0, 0x84, 0xfc, 0x26, 0x8d, 0x00, 0x2d, - 0x72, 0xa1, 0x44, 0xb7, 0x6f, 0x18, 0x90, 0x36, 0xa0, 0x15, 0xaa, 0x0d, 0xc8, 0x34, 0xa0, 0xd2, - 0xe0, 0xfe, 0x4d, 0x84, 0x48, 0x32, 0xc0, 0x74, 0x91, 0x62, 0xca, 0xb9, 0x50, 0xb4, 0xfa, 0xb8, - 0x35, 0xba, 0x4d, 0x9a, 0x18, 0x48, 0x49, 0x13, 0xdd, 0xe4, 0xfa, 0x0d, 0x0c, 0xc6, 0xcb, 0x55, - 0x0e, 0x72, 0x21, 0xb8, 0xd4, 0xba, 0xfe, 0x8b, 0xe5, 0xb4, 0x7d, 0x99, 0x74, 0x9f, 0x2d, 0xa7, - 0x73, 0x46, 0x79, 0x9c, 0x41, 0xf7, 0x08, 0xed, 0x3f, 0x36, 0xf2, 0xab, 0x48, 0x77, 0xd4, 0x04, - 0x9e, 0xd5, 0x2f, 0xe7, 0x3a, 0xaf, 0xf7, 0xef, 0xf6, 0xfd, 0xeb, 0xc1, 0xfe, 0xd3, 0xfb, 0x8d, - 0x59, 0x35, 0xab, 0x31, 0x61, 0x09, 0x0d, 0xef, 0xda, 0xaf, 0x85, 0x67, 0xad, 0x0b, 0xcf, 0xfa, - 0x2c, 0x3c, 0xeb, 0x7e, 0xe3, 0xb5, 0xd6, 0x1b, 0xaf, 0xf5, 0xb1, 0xf1, 0x5a, 0xce, 0x41, 0x24, - 0x58, 0x83, 0x8e, 0xe1, 0xaf, 0x8b, 0xea, 0xf7, 0x4f, 0xcb, 0xd5, 0x4c, 0xad, 0xcb, 0xe3, 0x24, - 0x55, 0xd7, 0xcb, 0x39, 0x8a, 0x04, 0xc3, 0xfb, 0xaf, 0xfd, 0xd1, 0xee, 0x0c, 0xfc, 0x60, 0x3c, - 0x9b, 0x3c, 0xd9, 0x3b, 0x87, 0xe4, 0xeb, 0x98, 0x00, 0x8d, 0xeb, 0x98, 0x99, 0x19, 0x33, 0xa1, - 0x0c, 0xde, 0x76, 0xa0, 0x50, 0x43, 0x61, 0x10, 0xd6, 0x50, 0x68, 0x42, 0x61, 0x09, 0x15, 0xf6, - 0xc9, 0xfe, 0x50, 0x38, 0x9a, 0x0e, 0x7d, 0x50, 0x34, 0xa6, 0x8a, 0x7e, 0xdb, 0x87, 0x86, 0x80, - 0x10, 0x6d, 0x20, 0x24, 0x20, 0xa4, 0x76, 0x10, 0x62, 0x4a, 0x08, 0x29, 0x2d, 0xf3, 0xce, 0xf6, - 0xa0, 0xfe, 0xff, 0x04, 0x00, 0x00, 0xff, 0xff, 0xbb, 0x6c, 0x35, 0x57, 0x77, 0x03, 0x00, 0x00, + // 357 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x92, 0xb1, 0x6a, 0xeb, 0x30, + 0x14, 0x40, 0x6d, 0x87, 0x97, 0xc1, 0xbc, 0x29, 0xcb, 0x03, 0x0f, 0x1e, 0xde, 0xf8, 0x06, 0x89, + 0x97, 0x42, 0x0b, 0x2a, 0x2d, 0x4d, 0x96, 0x34, 0x83, 0x42, 0x68, 0x33, 0x98, 0x62, 0x28, 0x8a, + 0x2d, 0x5c, 0x43, 0x24, 0x05, 0x5f, 0x25, 0x64, 0xec, 0x0f, 0x14, 0xf2, 0x07, 0x85, 0x8e, 0x9d, + 0xfa, 0x19, 0xa5, 0x53, 0xc6, 0x8e, 0xc5, 0x19, 0x0a, 0xfd, 0x8a, 0xe2, 0x46, 0x60, 0x65, 0x8c, + 0x27, 0xc3, 0x85, 0x73, 0x7c, 0x7c, 0x7d, 0xfd, 0x8b, 0x1e, 0x00, 0xd7, 0x94, 0x49, 0x3d, 0xe3, + 0x58, 0xa8, 0x74, 0x31, 0xe3, 0x80, 0x57, 0x38, 0x4f, 0xb9, 0xd4, 0xb9, 0xce, 0x39, 0x60, 0x5d, + 0x30, 0x09, 0x2c, 0xd1, 0xb9, 0x92, 0x80, 0x25, 0x13, 0x1c, 0x03, 0x2f, 0x96, 0x79, 0xc2, 0xd1, + 0xbc, 0x50, 0x5a, 0x75, 0xba, 0x96, 0x01, 0x19, 0x03, 0x5a, 0xa1, 0xda, 0x80, 0x6c, 0x03, 0xaa, + 0x0c, 0xc1, 0x9f, 0x44, 0x81, 0x50, 0x80, 0x05, 0x64, 0x78, 0xf9, 0xbf, 0x7a, 0xec, 0x64, 0x41, + 0x93, 0x1c, 0xc1, 0x01, 0x58, 0x66, 0x72, 0x02, 0xda, 0xc0, 0x60, 0x4d, 0x6e, 0x0b, 0x0e, 0x73, + 0x25, 0xc1, 0xe8, 0xba, 0x8f, 0xae, 0xdf, 0xa2, 0x90, 0x75, 0xd6, 0xae, 0xdf, 0xbe, 0x64, 0x32, + 0x9d, 0xf1, 0xce, 0x29, 0x3a, 0xfc, 0x8b, 0x11, 0xdd, 0x45, 0x06, 0x83, 0x26, 0xf0, 0xa4, 0x9e, + 0x5c, 0x99, 0xbc, 0xbf, 0x4e, 0xf0, 0xeb, 0xfe, 0xf3, 0xe5, 0x9f, 0xdb, 0x7f, 0x68, 0xbd, 0x96, + 0xa1, 0xbb, 0x29, 0x43, 0xf7, 0xa3, 0x0c, 0xdd, 0xf5, 0x36, 0x74, 0x36, 0xdb, 0xd0, 0x79, 0xdf, + 0x86, 0x8e, 0x7f, 0x9c, 0x28, 0xd1, 0xe0, 0x7d, 0xfd, 0xdf, 0xd7, 0xbb, 0x3f, 0x3c, 0xae, 0x56, + 0x30, 0x76, 0x6f, 0xce, 0xb2, 0x5c, 0xdf, 0x2d, 0xa6, 0x28, 0x51, 0x02, 0x1f, 0xbe, 0xde, 0x27, + 0xaf, 0xdd, 0xa3, 0xd1, 0x70, 0x32, 0x7a, 0xf6, 0xf6, 0x6e, 0x85, 0x9a, 0x98, 0x08, 0x0d, 0xeb, + 0x98, 0x89, 0x1d, 0x33, 0x62, 0x82, 0xbf, 0xed, 0x41, 0xb1, 0x81, 0xe2, 0x28, 0xae, 0xa1, 0xd8, + 0x86, 0xe2, 0x0a, 0x2a, 0xbd, 0xf3, 0xc3, 0xa1, 0x78, 0x30, 0xee, 0x53, 0xae, 0x59, 0xca, 0x34, + 0xfb, 0xf2, 0x4e, 0x2c, 0x01, 0x21, 0xc6, 0x40, 0x48, 0x44, 0x48, 0xed, 0x20, 0xc4, 0x96, 0x10, + 0x52, 0x59, 0xa6, 0xed, 0x9f, 0xc3, 0x39, 0xfa, 0x0e, 0x00, 0x00, 0xff, 0xff, 0xcc, 0x2e, 0x2c, + 0xae, 0x5a, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/identities/transactions/name/service.pb.gw.go b/x/identities/transactions/name/service.pb.gw.go deleted file mode 100644 index 491e155f5..000000000 --- a/x/identities/transactions/name/service.pb.gw.go +++ /dev/null @@ -1,171 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: AssetMantle/modules/x/identities/transactions/name/service.proto - -/* -Package name is a reverse proxy. - -It translates gRPC into RESTful JSON APIs. -*/ -package name - -import ( - "context" - "io" - "net/http" - - "github.com/golang/protobuf/descriptor" - "github.com/golang/protobuf/proto" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/grpc-ecosystem/grpc-gateway/utilities" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/status" -) - -// Suppress "imported and not used" errors -var _ codes.Code -var _ io.Reader -var _ status.Status -var _ = runtime.String -var _ = utilities.NewDoubleArray -var _ = descriptor.ForMessage -var _ = metadata.Join - -var ( - filter_Msg_Handle_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - -func request_Msg_Handle_0(ctx context.Context, marshaler runtime.Marshaler, client MsgClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq Message - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.Handle(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Msg_Handle_0(ctx context.Context, marshaler runtime.Marshaler, server MsgServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq Message - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.Handle(ctx, &protoReq) - return msg, metadata, err - -} - -// RegisterMsgHandlerServer registers the http handlers for service Msg to "mux". -// UnaryRPC :call MsgServer directly. -// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterMsgHandlerFromEndpoint instead. -func RegisterMsgHandlerServer(ctx context.Context, mux *runtime.ServeMux, server MsgServer) error { - - mux.Handle("POST", pattern_Msg_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Msg_Handle_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Msg_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -// RegisterMsgHandlerFromEndpoint is same as RegisterMsgHandler but -// automatically dials to "endpoint" and closes the connection when "ctx" gets done. -func RegisterMsgHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.Dial(endpoint, opts...) - if err != nil { - return err - } - defer func() { - if err != nil { - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - return - } - go func() { - <-ctx.Done() - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - }() - }() - - return RegisterMsgHandler(ctx, mux, conn) -} - -// RegisterMsgHandler registers the http handlers for service Msg to "mux". -// The handlers forward requests to the grpc endpoint over "conn". -func RegisterMsgHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { - return RegisterMsgHandlerClient(ctx, mux, NewMsgClient(conn)) -} - -// RegisterMsgHandlerClient registers the http handlers for service Msg -// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "MsgClient". -// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "MsgClient" -// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "MsgClient" to call the correct interceptors. -func RegisterMsgHandlerClient(ctx context.Context, mux *runtime.ServeMux, client MsgClient) error { - - mux.Handle("POST", pattern_Msg_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Msg_Handle_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Msg_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -var ( - pattern_Msg_Handle_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"mantle", "identities", "name"}, "", runtime.AssumeColonVerbOpt(false))) -) - -var ( - forward_Msg_Handle_0 = runtime.ForwardResponseMessage -) diff --git a/x/identities/transactions/name/transaction.go b/x/identities/transactions/name/transaction.go index a360343a2..469d28cf5 100644 --- a/x/identities/transactions/name/transaction.go +++ b/x/identities/transactions/name/transaction.go @@ -4,22 +4,14 @@ package name import ( - "context" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "google.golang.org/grpc" - "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/helpers/constants" - "github.com/AssetMantle/modules/utilities/name" + "google.golang.org/grpc" ) -type dummy struct{} - var Transaction = baseHelpers.NewTransaction( - name.GetPackageName(dummy{}), + _Msg_serviceDesc.ServiceName, "", "", @@ -30,9 +22,6 @@ var Transaction = baseHelpers.NewTransaction( func(server grpc.ServiceRegistrar, keeper helpers.TransactionKeeper) { RegisterMsgServer(server, keeper.(transactionKeeper)) }, - func(clientCtx client.Context, mux *runtime.ServeMux) error { - return RegisterMsgHandlerClient(context.Background(), mux, NewMsgClient(clientCtx)) - }, constants.Name, ) diff --git a/x/identities/transactions/name/transaction_keeper.go b/x/identities/transactions/name/transaction_keeper.go index d874fca83..d17e2f253 100644 --- a/x/identities/transactions/name/transaction_keeper.go +++ b/x/identities/transactions/name/transaction_keeper.go @@ -6,7 +6,6 @@ package name import ( "context" errorConstants "github.com/AssetMantle/modules/helpers/constants" - baseData "github.com/AssetMantle/schema/data/base" "github.com/AssetMantle/schema/documents/base" "github.com/cosmos/cosmos-sdk/types" diff --git a/x/identities/transactions/name/transaction_request.go b/x/identities/transactions/name/transaction_request.go index 90768136e..439f71086 100644 --- a/x/identities/transactions/name/transaction_request.go +++ b/x/identities/transactions/name/transaction_request.go @@ -5,21 +5,19 @@ package name import ( "encoding/json" - "github.com/AssetMantle/modules/utilities/rest" - - codecUtilities "github.com/AssetMantle/schema/codec/utilities" baseIDs "github.com/AssetMantle/schema/ids/base" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" + "io" + "net/http" "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/helpers/constants" ) type transactionRequest struct { - BaseReq rest.BaseReq `json:"baseReq"` - Name string `json:"name"` + helpers.CommonTransactionRequest `json:"commonTransactionRequest"` + Name string `json:"name"` } var _ helpers.TransactionRequest = (*transactionRequest)(nil) @@ -30,7 +28,7 @@ var _ helpers.TransactionRequest = (*transactionRequest)(nil) // @Accept text/plain // @Produce json // @Tags Identities -// @Param body transactionRequest true "A transaction to name a base identity." +// @Param body transactionRequest true "A transaction to name a baseHelpers identity." // @Success 200 {object} transactionResponse "Message for a successful response." // @Failure default {object} transactionResponse "Message for an unexpected error response." // @Router /identities/name [post] @@ -45,22 +43,27 @@ func (transactionRequest transactionRequest) Validate() error { } func (transactionRequest transactionRequest) FromCLI(cliCommand helpers.CLICommand, context client.Context) (helpers.TransactionRequest, error) { return newTransactionRequest( - cliCommand.ReadBaseReq(context), + cliCommand.ReadCommonTransactionRequest(context), cliCommand.ReadString(constants.Name), ), nil } -func (transactionRequest transactionRequest) FromJSON(rawMessage json.RawMessage) (helpers.TransactionRequest, error) { - if err := json.Unmarshal(rawMessage, &transactionRequest); err != nil { +func (transactionRequest transactionRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.TransactionRequest, error) { + body, err := io.ReadAll(httpRequest.Body) + if err != nil { + return nil, err + } + + if err := json.Unmarshal(body, &transactionRequest); err != nil { return nil, err } return transactionRequest, nil } -func (transactionRequest transactionRequest) GetBaseReq() rest.BaseReq { - return transactionRequest.BaseReq +func (transactionRequest transactionRequest) GetCommonTransactionRequest() helpers.CommonTransactionRequest { + return transactionRequest.CommonTransactionRequest } func (transactionRequest transactionRequest) MakeMsg() (sdkTypes.Msg, error) { - from, err := sdkTypes.AccAddressFromBech32(transactionRequest.GetBaseReq().From) + from, err := sdkTypes.AccAddressFromBech32(transactionRequest.GetCommonTransactionRequest().GetFrom()) if err != nil { return nil, err } @@ -70,15 +73,12 @@ func (transactionRequest transactionRequest) MakeMsg() (sdkTypes.Msg, error) { baseIDs.NewStringID(transactionRequest.Name), ), nil } -func (transactionRequest) RegisterLegacyAminoCodec(legacyAmino *codec.LegacyAmino) { - codecUtilities.RegisterModuleConcrete(legacyAmino, transactionRequest{}) -} func requestPrototype() helpers.TransactionRequest { return transactionRequest{} } -func newTransactionRequest(baseReq rest.BaseReq, name string) helpers.TransactionRequest { +func newTransactionRequest(commonTransactionRequest helpers.CommonTransactionRequest, name string) helpers.TransactionRequest { return transactionRequest{ - BaseReq: baseReq, - Name: name, + CommonTransactionRequest: commonTransactionRequest, + Name: name, } } diff --git a/x/identities/transactions/name/transaction_request_test.go b/x/identities/transactions/name/transaction_request_test.go index 6ad6176e5..9eda9eff0 100644 --- a/x/identities/transactions/name/transaction_request_test.go +++ b/x/identities/transactions/name/transaction_request_test.go @@ -4,8 +4,6 @@ package name import ( - "encoding/json" - "github.com/AssetMantle/modules/utilities/rest" "reflect" "testing" @@ -21,7 +19,7 @@ import ( "github.com/AssetMantle/modules/helpers/constants" ) -func CreateTestInputForRequest(t *testing.T) (*codec.LegacyAmino, helpers.CLICommand, client.Context, string, sdkTypes.AccAddress, rest.BaseReq) { +func CreateTestInputForRequest(t *testing.T) (*codec.LegacyAmino, helpers.CLICommand, client.Context, string, sdkTypes.AccAddress, helpers.CommonTransactionRequest) { var legacyAmino = baseHelpers.CodecPrototype().GetLegacyAmino() cliCommand := baseHelpers.NewCLICommand("", "", "", []helpers.CLIFlag{constants.Name}) @@ -30,27 +28,26 @@ func CreateTestInputForRequest(t *testing.T) (*codec.LegacyAmino, helpers.CLICom fromAccAddress, err := sdkTypes.AccAddressFromBech32(fromAddress) require.Nil(t, err) - testBaseReq := rest.BaseReq{From: fromAddress, ChainID: "test", Fees: sdkTypes.NewCoins()} + commonTransactionRequest := helpers.PrototypeCommonTransactionRequest() - return legacyAmino, cliCommand, client.Context{}.WithCodec(baseHelpers.CodecPrototype()), fromAddress, fromAccAddress, testBaseReq + return legacyAmino, cliCommand, client.Context{}.WithCodec(baseHelpers.CodecPrototype()), fromAddress, fromAccAddress, commonTransactionRequest } - func Test_newTransactionRequest(t *testing.T) { - _, _, _, _, _, testBaseReq := CreateTestInputForRequest(t) + _, _, _, _, _, commonTransactionRequest := CreateTestInputForRequest(t) type args struct { - baseReq rest.BaseReq - nubID string + commonTransactionRequest helpers.CommonTransactionRequest + nubID string } tests := []struct { name string args args want helpers.TransactionRequest }{ - {"+ve", args{testBaseReq, "nubID"}, transactionRequest{testBaseReq, "nubID"}}, + {"+ve", args{commonTransactionRequest, "nubID"}, transactionRequest{commonTransactionRequest, "nubID"}}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - if got := newTransactionRequest(tt.args.baseReq, tt.args.nubID); !reflect.DeepEqual(got, tt.want) { + if got := newTransactionRequest(tt.args.commonTransactionRequest, tt.args.nubID); !reflect.DeepEqual(got, tt.want) { t.Errorf("newTransactionRequest() = %v, want %v", got, tt.want) } }) @@ -74,11 +71,11 @@ func Test_requestPrototype(t *testing.T) { } func Test_transactionRequest_FromCLI(t *testing.T) { - _, cliCommand, context, _, _, testBaseReq := CreateTestInputForRequest(t) + _, cliCommand, context, _, _, commonTransactionRequest := CreateTestInputForRequest(t) type fields struct { - BaseReq rest.BaseReq - NubID string + commonTransactionRequest helpers.CommonTransactionRequest + NubID string } type args struct { cliCommand helpers.CLICommand @@ -91,13 +88,13 @@ func Test_transactionRequest_FromCLI(t *testing.T) { want helpers.TransactionRequest wantErr bool }{ - {"+ve", fields{testBaseReq, "nubID"}, args{cliCommand, client.Context{}.WithCodec(baseHelpers.CodecPrototype())}, transactionRequest{cliCommand.ReadBaseReq(context), cliCommand.ReadString(constants.Name)}, false}, + {"+ve", fields{commonTransactionRequest, "nubID"}, args{cliCommand, client.Context{}.WithCodec(baseHelpers.CodecPrototype())}, transactionRequest{cliCommand.ReadCommonTransactionRequest(context), cliCommand.ReadString(constants.Name)}, false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - Name: tt.fields.NubID, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + Name: tt.fields.NubID, } got, err := transactionRequest.FromCLI(tt.args.cliCommand, tt.args.context) if (err != nil) != tt.wantErr { @@ -111,76 +108,39 @@ func Test_transactionRequest_FromCLI(t *testing.T) { } } -func Test_transactionRequest_FromJSON(t *testing.T) { - _, _, _, _, fromAccAddress, testBaseReq := CreateTestInputForRequest(t) - - type fields struct { - BaseReq rest.BaseReq - NubID string - } - type args struct { - rawMessage json.RawMessage - } - tests := []struct { - name string - fields fields - args args - want helpers.TransactionRequest - wantErr bool - }{ - {"+ve", fields{testBaseReq, "nubID"}, args{sdkTypes.MustSortJSON(baseHelpers.CodecPrototype().MustMarshalJSON(&Message{fromAccAddress.String(), baseIDs.NewStringID("nubID").(*baseIDs.StringID)}))}, transactionRequest{testBaseReq, "nubID"}, false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - Name: tt.fields.NubID, - } - got, err := transactionRequest.FromJSON(tt.args.rawMessage) - if (err != nil) != tt.wantErr { - t.Errorf("FromJSON() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("FromJSON() got = %v, want %v", got, tt.want) - } - }) - } -} - func Test_transactionRequest_GetBaseReq(t *testing.T) { - _, _, _, _, _, testBaseReq := CreateTestInputForRequest(t) + _, _, _, _, _, commonTransactionRequest := CreateTestInputForRequest(t) type fields struct { - BaseReq rest.BaseReq - NubID string + commonTransactionRequest helpers.CommonTransactionRequest + NubID string } tests := []struct { name string fields fields - want rest.BaseReq + want helpers.CommonTransactionRequest }{ - {"+ve", fields{testBaseReq, "nubID"}, testBaseReq}, + {"+ve", fields{commonTransactionRequest, "nubID"}, commonTransactionRequest}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - Name: tt.fields.NubID, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + Name: tt.fields.NubID, } - if got := transactionRequest.GetBaseReq(); !reflect.DeepEqual(got, tt.want) { - t.Errorf("GetBaseReq() = %v, want %v", got, tt.want) + if got := transactionRequest.GetCommonTransactionRequest(); !reflect.DeepEqual(got, tt.want) { + t.Errorf("GetCommonTransactionRequest() = %v, want %v", got, tt.want) } }) } } func Test_transactionRequest_MakeMsg(t *testing.T) { - _, _, _, _, fromAccAddress, testBaseReq := CreateTestInputForRequest(t) + _, _, _, _, fromAccAddress, commonTransactionRequest := CreateTestInputForRequest(t) type fields struct { - BaseReq rest.BaseReq - NubID string + commonTransactionRequest helpers.CommonTransactionRequest + NubID string } tests := []struct { name string @@ -188,13 +148,13 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { want sdkTypes.Msg wantErr bool }{ - {"+ve", fields{testBaseReq, "nubID"}, &Message{fromAccAddress.String(), baseIDs.NewStringID("nubID").(*baseIDs.StringID)}, false}, + {"+ve", fields{commonTransactionRequest, "nubID"}, &Message{fromAccAddress.String(), baseIDs.NewStringID("nubID").(*baseIDs.StringID)}, false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - Name: tt.fields.NubID, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + Name: tt.fields.NubID, } got, err := transactionRequest.MakeMsg() if (err != nil) != tt.wantErr { @@ -208,53 +168,25 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { } } -func Test_transactionRequest_RegisterCodec(t *testing.T) { - _, _, _, _, _, testBaseReq := CreateTestInputForRequest(t) - - type fields struct { - BaseReq rest.BaseReq - NubID string - } - type args struct { - legacyAmino *codec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{testBaseReq, "nubID"}, args{codec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - tr := transactionRequest{ - BaseReq: tt.fields.BaseReq, - Name: tt.fields.NubID, - } - tr.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - func Test_transactionRequest_Validate(t *testing.T) { - _, _, _, _, _, testBaseReq := CreateTestInputForRequest(t) + _, _, _, _, _, commonTransactionRequest := CreateTestInputForRequest(t) type fields struct { - BaseReq rest.BaseReq - NubID string + commonTransactionRequest helpers.CommonTransactionRequest + NubID string } tests := []struct { name string fields fields wantErr bool }{ - {"+ve", fields{testBaseReq, "nubID"}, false}, + {"+ve", fields{commonTransactionRequest, "nubID"}, false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - Name: tt.fields.NubID, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + Name: tt.fields.NubID, } if err := transactionRequest.Validate(); (err != nil) != tt.wantErr { t.Errorf("ValidateBasic() error = %v, wantErr %v", err, tt.wantErr) diff --git a/x/identities/transactions/name/transaction_response.go b/x/identities/transactions/name/transaction_response.go index a25d43961..2e027e814 100644 --- a/x/identities/transactions/name/transaction_response.go +++ b/x/identities/transactions/name/transaction_response.go @@ -4,11 +4,10 @@ package name import ( + "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" sdkTypes "github.com/cosmos/cosmos-sdk/types" - - "github.com/AssetMantle/modules/helpers" ) var _ helpers.TransactionResponse = (*TransactionResponse)(nil) diff --git a/x/identities/transactions/prototype_test.go b/x/identities/transactions/prototype_test.go index df37b33d0..8b7ee0731 100644 --- a/x/identities/transactions/prototype_test.go +++ b/x/identities/transactions/prototype_test.go @@ -19,7 +19,7 @@ import ( ) func TestPrototype(t *testing.T) { - require.Equal(t, Prototype().GetTransaction("unprovision").GetName(), baseHelpers.NewTransactions( + require.Equal(t, Prototype().GetTransaction("unprovision").GetServicePath(), baseHelpers.NewTransactions( define.Transaction, deputize.Transaction, issue.Transaction, @@ -27,5 +27,5 @@ func TestPrototype(t *testing.T) { provision.Transaction, revoke.Transaction, unprovision.Transaction, - ).GetTransaction("unprovision").GetName()) + ).GetTransaction("unprovision").GetServicePath()) } diff --git a/x/identities/transactions/provision/message.go b/x/identities/transactions/provision/message.go index dba360cc3..09bdb6a27 100644 --- a/x/identities/transactions/provision/message.go +++ b/x/identities/transactions/provision/message.go @@ -4,26 +4,15 @@ package provision import ( - codecUtilities "github.com/AssetMantle/schema/codec/utilities" + "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/types" sdkTypes "github.com/cosmos/cosmos-sdk/types" - - "github.com/AssetMantle/modules/helpers" ) var _ helpers.Message = (*Message)(nil) -func (message *Message) Type() string { return Transaction.GetName() } -func (message *Message) GetFromAddress() sdkTypes.AccAddress { - from, err := sdkTypes.AccAddressFromBech32(message.From) - if err != nil { - panic(err) - } - return from -} func (message *Message) ValidateBasic() error { if _, err := sdkTypes.AccAddressFromBech32(message.From); err != nil { return err @@ -43,21 +32,10 @@ func (message *Message) GetSigners() []sdkTypes.AccAddress { } return []sdkTypes.AccAddress{from} } -func (*Message) RegisterLegacyAminoCodec(legacyAmino *codec.LegacyAmino) { - codecUtilities.RegisterModuleConcrete(legacyAmino, Message{}) -} func (message *Message) RegisterInterface(interfaceRegistry types.InterfaceRegistry) { interfaceRegistry.RegisterImplementations((*sdkTypes.Msg)(nil), message) } -func messageFromInterface(msg sdkTypes.Msg) *Message { - switch value := msg.(type) { - case *Message: - return value - default: - return &Message{} - } -} func messagePrototype() helpers.Message { return &Message{} } diff --git a/x/identities/transactions/provision/message_test.go b/x/identities/transactions/provision/message_test.go index 851b72ec1..1c71bb877 100644 --- a/x/identities/transactions/provision/message_test.go +++ b/x/identities/transactions/provision/message_test.go @@ -13,7 +13,6 @@ import ( baseLists "github.com/AssetMantle/schema/lists/base" baseProperties "github.com/AssetMantle/schema/properties/base" baseQualified "github.com/AssetMantle/schema/qualified/base" - "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" @@ -45,27 +44,6 @@ func createInputForMessage(t *testing.T) (*baseIDs.IdentityID, string, sdkTypes. return testIdentityID.(*baseIDs.IdentityID), fromAddress, fromAccAddress, toAddress, toAccAddress, testMessage } -func Test_messageFromInterface(t *testing.T) { - testIdentityID, _, fromAccAddress, _, toAccAddress, testMessage := createInputForMessage(t) - type args struct { - msg sdkTypes.Msg - } - tests := []struct { - name string - args args - want *Message - }{ - {"+ve", args{testMessage}, &Message{fromAccAddress.String(), toAccAddress.String(), testIdentityID}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := messageFromInterface(tt.args.msg); !reflect.DeepEqual(got, tt.want) { - t.Errorf("messageFromInterface() = %v, want %v", got, tt.want) - } - }) - } -} - func Test_messagePrototype(t *testing.T) { tests := []struct { name string @@ -106,55 +84,6 @@ func Test_message_GetSigners(t *testing.T) { } } -func Test_message_RegisterCodec(t *testing.T) { - testIdentityID, _, fromAccAddress, _, toAccAddress, _ := createInputForMessage(t) - - type args struct { - legacyAmino *codec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{fromAccAddress.String(), toAccAddress.String(), testIdentityID}, args{codec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - me := &Message{ - From: tt.fields.From, - To: tt.fields.To, - IdentityID: tt.fields.IdentityID, - } - me.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - -func Test_message_Type(t *testing.T) { - testIdentityID, _, fromAccAddress, _, toAccAddress, _ := createInputForMessage(t) - - tests := []struct { - name string - fields fields - want string - }{ - {"+ve", fields{fromAccAddress.String(), toAccAddress.String(), testIdentityID}, Transaction.GetName()}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - message := &Message{ - From: tt.fields.From, - To: tt.fields.To, - IdentityID: tt.fields.IdentityID, - } - if got := message.Type(); got != tt.want { - t.Errorf("Type() = %v, want %v", got, tt.want) - } - }) - } -} - func Test_message_ValidateBasic(t *testing.T) { testIdentityID, _, fromAccAddress, _, toAccAddress, _ := createInputForMessage(t) diff --git a/x/identities/transactions/provision/service.pb.go b/x/identities/transactions/provision/service.pb.go index b89865a1f..6831459ed 100644 --- a/x/identities/transactions/provision/service.pb.go +++ b/x/identities/transactions/provision/service.pb.go @@ -6,9 +6,9 @@ package provision import ( context "context" fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types/msgservice" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" - _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -31,30 +31,30 @@ func init() { } var fileDescriptor_d21f8e25d50e279b = []byte{ - // 365 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x92, 0xb1, 0x4a, 0xc3, 0x40, - 0x18, 0x80, 0x9b, 0x14, 0x3a, 0x04, 0xa7, 0x8e, 0xa1, 0x64, 0x28, 0xce, 0x77, 0xa0, 0x83, 0x70, - 0x3a, 0xd8, 0x88, 0x68, 0xc1, 0x40, 0xa8, 0x1d, 0x82, 0x04, 0xe4, 0x9a, 0x1c, 0xf1, 0x20, 0xb9, - 0x0b, 0xb9, 0x6b, 0xe9, 0xec, 0x13, 0x08, 0xbe, 0x81, 0xa3, 0xbe, 0x83, 0xa3, 0x88, 0x53, 0xc1, - 0xc5, 0x51, 0x52, 0x27, 0x9f, 0x42, 0xb4, 0x67, 0x72, 0x5d, 0x6f, 0x3d, 0xf2, 0x7d, 0x7c, 0xff, - 0x9f, 0xdf, 0x39, 0x1d, 0x09, 0x41, 0x64, 0x80, 0x99, 0xcc, 0x09, 0x2c, 0x78, 0x3a, 0xcf, 0x89, - 0x80, 0x4b, 0x48, 0x53, 0xc2, 0x24, 0x95, 0x94, 0x08, 0x28, 0x2b, 0xcc, 0x04, 0x4e, 0x24, 0xe5, - 0x4c, 0xc0, 0xb2, 0xe2, 0x0b, 0x2a, 0x28, 0x67, 0x50, 0x90, 0x6a, 0x41, 0x13, 0x02, 0xca, 0x8a, - 0x4b, 0xde, 0x3f, 0xd0, 0x34, 0x40, 0x69, 0xc0, 0x12, 0xb4, 0x1a, 0xa0, 0x6b, 0x40, 0xa3, 0x71, - 0x07, 0x19, 0xe7, 0x59, 0x4e, 0x20, 0x2e, 0x29, 0xc4, 0x8c, 0x71, 0x89, 0x9b, 0x2f, 0x24, 0x77, - 0x8d, 0xeb, 0x0a, 0x22, 0x04, 0xce, 0x54, 0x9d, 0x3b, 0x31, 0xd5, 0x68, 0xcf, 0xd7, 0x15, 0x11, - 0x25, 0x67, 0x42, 0x39, 0xf7, 0x5e, 0x2c, 0xa7, 0x1b, 0x88, 0xac, 0xff, 0x6c, 0x39, 0xbd, 0x73, - 0xcc, 0xd2, 0x9c, 0xf4, 0x8f, 0x81, 0xe1, 0x16, 0x40, 0xb0, 0xc9, 0x75, 0x2f, 0x8c, 0x0d, 0xd3, - 0xf6, 0x79, 0xa2, 0x42, 0x87, 0xbb, 0xb7, 0xef, 0x5f, 0xf7, 0xb6, 0x37, 0x1c, 0xc0, 0x62, 0x33, - 0xba, 0x36, 0x70, 0x43, 0xfa, 0x4f, 0xdd, 0xd7, 0xda, 0xb3, 0x56, 0xb5, 0x67, 0x7d, 0xd6, 0x9e, - 0x75, 0xb7, 0xf6, 0x3a, 0xab, 0xb5, 0xd7, 0xf9, 0x58, 0x7b, 0x1d, 0xe7, 0x30, 0xe1, 0x85, 0x69, - 0x91, 0xbf, 0x73, 0xb9, 0xb9, 0x90, 0xf0, 0x77, 0x5d, 0xa1, 0x75, 0xe5, 0x67, 0x54, 0xde, 0xcc, - 0x67, 0x20, 0xe1, 0x05, 0x34, 0xfc, 0x1f, 0x0f, 0x76, 0x6f, 0x14, 0x44, 0xe3, 0x69, 0xf8, 0x68, - 0x6f, 0x1d, 0x5c, 0xa0, 0xb2, 0x22, 0x30, 0x6e, 0xb3, 0xa6, 0x7a, 0x56, 0xf8, 0xaf, 0x78, 0xdb, - 0x22, 0x63, 0x45, 0xc6, 0x51, 0xdc, 0x92, 0xb1, 0x4e, 0xc6, 0x0d, 0x59, 0xdb, 0x27, 0x86, 0x64, - 0x7c, 0x16, 0xfa, 0x01, 0x91, 0x38, 0xc5, 0x12, 0x7f, 0xdb, 0x47, 0x9a, 0x05, 0x21, 0xa5, 0x41, - 0x28, 0x42, 0xa8, 0x15, 0x21, 0xa4, 0x9b, 0x10, 0x6a, 0x54, 0xb3, 0xde, 0xdf, 0xf5, 0xed, 0xff, - 0x04, 0x00, 0x00, 0xff, 0xff, 0xec, 0xbe, 0xb8, 0x74, 0xb8, 0x03, 0x00, 0x00, + // 357 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0xd2, 0x31, 0x4b, 0xc3, 0x40, + 0x14, 0x07, 0xf0, 0x24, 0xc5, 0x0e, 0xc1, 0xa9, 0x8b, 0x90, 0x21, 0x83, 0xa3, 0xc3, 0x1d, 0xea, + 0x20, 0x9c, 0x0e, 0x36, 0x22, 0x5a, 0x30, 0x10, 0x6a, 0x87, 0x20, 0x01, 0xb9, 0x26, 0x47, 0x3c, + 0x68, 0x72, 0x25, 0xef, 0x5a, 0x3a, 0xfa, 0x11, 0x9c, 0x1d, 0xdd, 0xd4, 0xc5, 0x8f, 0x21, 0x4e, + 0x1d, 0x1d, 0x25, 0x1d, 0x04, 0x3f, 0x85, 0xd4, 0x9e, 0xcd, 0x75, 0xbd, 0x29, 0xf0, 0xe0, 0xff, + 0xcb, 0x9f, 0x77, 0xcf, 0x3d, 0xef, 0x02, 0x30, 0x19, 0xd2, 0x52, 0x8e, 0x18, 0x2e, 0x44, 0x36, + 0x19, 0x31, 0xc0, 0x33, 0xcc, 0x33, 0x56, 0x4a, 0x2e, 0x39, 0x03, 0x2c, 0x2b, 0x5a, 0x02, 0x4d, + 0x25, 0x17, 0x25, 0xe0, 0x71, 0x25, 0xa6, 0x1c, 0xb8, 0x28, 0x31, 0xb0, 0x6a, 0xca, 0x53, 0x86, + 0xc6, 0x95, 0x90, 0xa2, 0x73, 0xa4, 0x31, 0x48, 0x31, 0x68, 0x86, 0x1a, 0x06, 0xe9, 0x0c, 0x5a, + 0x33, 0xde, 0x4e, 0x2a, 0xa0, 0x10, 0x80, 0x0b, 0xc8, 0xf1, 0x74, 0x7f, 0xf9, 0x59, 0x89, 0x9e, + 0x71, 0xb1, 0x82, 0x01, 0xd0, 0x5c, 0x15, 0xf3, 0xfa, 0xa6, 0x8c, 0x36, 0xbe, 0xad, 0x18, 0x8c, + 0x45, 0x09, 0xca, 0x3c, 0x78, 0xb6, 0xdd, 0x56, 0x08, 0x79, 0xe7, 0xd1, 0x76, 0xdb, 0x97, 0xb4, + 0xcc, 0x46, 0xac, 0x73, 0x8a, 0x0c, 0x17, 0x80, 0xc2, 0x55, 0x5d, 0xef, 0xca, 0x58, 0x18, 0x34, + 0xe3, 0xbe, 0x2a, 0xba, 0x6b, 0x79, 0x5b, 0xf7, 0xdf, 0x6f, 0x7b, 0x76, 0xf0, 0xda, 0x7a, 0xaf, + 0x7d, 0x7b, 0x5e, 0xfb, 0xf6, 0x57, 0xed, 0xdb, 0x0f, 0x0b, 0xdf, 0x9a, 0x2f, 0x7c, 0xeb, 0x73, + 0xe1, 0x5b, 0xee, 0x71, 0x2a, 0x0a, 0xd3, 0x9f, 0x06, 0xdb, 0xd7, 0xab, 0xf7, 0x8f, 0x96, 0x1b, + 0x89, 0xec, 0x9b, 0x20, 0xe7, 0xf2, 0x6e, 0x32, 0x44, 0xa9, 0x28, 0xb0, 0xe1, 0xca, 0x9f, 0x9c, + 0x76, 0x37, 0x8c, 0x7b, 0x83, 0xe8, 0xc5, 0xd9, 0x38, 0xa7, 0x50, 0xd5, 0x8a, 0x51, 0xaf, 0xa9, + 0x35, 0xd0, 0x6b, 0x45, 0xff, 0xc4, 0xc7, 0x46, 0x32, 0x51, 0xc9, 0x24, 0x4e, 0x9a, 0x64, 0xa2, + 0x27, 0x93, 0x75, 0xb2, 0x76, 0xce, 0x0c, 0x93, 0xc9, 0x45, 0x14, 0x84, 0x4c, 0xd2, 0x8c, 0x4a, + 0xfa, 0xe3, 0x9c, 0x68, 0x0a, 0x21, 0x8a, 0x21, 0x24, 0x26, 0xa4, 0x81, 0x08, 0xd1, 0x25, 0x42, + 0xd6, 0xd4, 0xb0, 0xfd, 0x77, 0x60, 0x87, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x06, 0x2d, 0xbd, + 0xfe, 0x96, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/identities/transactions/provision/service.pb.gw.go b/x/identities/transactions/provision/service.pb.gw.go deleted file mode 100644 index b22b0b3af..000000000 --- a/x/identities/transactions/provision/service.pb.gw.go +++ /dev/null @@ -1,171 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: AssetMantle/modules/x/identities/transactions/provision/service.proto - -/* -Package provision is a reverse proxy. - -It translates gRPC into RESTful JSON APIs. -*/ -package provision - -import ( - "context" - "io" - "net/http" - - "github.com/golang/protobuf/descriptor" - "github.com/golang/protobuf/proto" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/grpc-ecosystem/grpc-gateway/utilities" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/status" -) - -// Suppress "imported and not used" errors -var _ codes.Code -var _ io.Reader -var _ status.Status -var _ = runtime.String -var _ = utilities.NewDoubleArray -var _ = descriptor.ForMessage -var _ = metadata.Join - -var ( - filter_Msg_Handle_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - -func request_Msg_Handle_0(ctx context.Context, marshaler runtime.Marshaler, client MsgClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq Message - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.Handle(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Msg_Handle_0(ctx context.Context, marshaler runtime.Marshaler, server MsgServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq Message - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.Handle(ctx, &protoReq) - return msg, metadata, err - -} - -// RegisterMsgHandlerServer registers the http handlers for service Msg to "mux". -// UnaryRPC :call MsgServer directly. -// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterMsgHandlerFromEndpoint instead. -func RegisterMsgHandlerServer(ctx context.Context, mux *runtime.ServeMux, server MsgServer) error { - - mux.Handle("POST", pattern_Msg_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Msg_Handle_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Msg_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -// RegisterMsgHandlerFromEndpoint is same as RegisterMsgHandler but -// automatically dials to "endpoint" and closes the connection when "ctx" gets done. -func RegisterMsgHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.Dial(endpoint, opts...) - if err != nil { - return err - } - defer func() { - if err != nil { - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - return - } - go func() { - <-ctx.Done() - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - }() - }() - - return RegisterMsgHandler(ctx, mux, conn) -} - -// RegisterMsgHandler registers the http handlers for service Msg to "mux". -// The handlers forward requests to the grpc endpoint over "conn". -func RegisterMsgHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { - return RegisterMsgHandlerClient(ctx, mux, NewMsgClient(conn)) -} - -// RegisterMsgHandlerClient registers the http handlers for service Msg -// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "MsgClient". -// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "MsgClient" -// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "MsgClient" to call the correct interceptors. -func RegisterMsgHandlerClient(ctx context.Context, mux *runtime.ServeMux, client MsgClient) error { - - mux.Handle("POST", pattern_Msg_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Msg_Handle_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Msg_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -var ( - pattern_Msg_Handle_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"mantle", "identities", "provision"}, "", runtime.AssumeColonVerbOpt(false))) -) - -var ( - forward_Msg_Handle_0 = runtime.ForwardResponseMessage -) diff --git a/x/identities/transactions/provision/transaction.go b/x/identities/transactions/provision/transaction.go index 2adc8ef9d..f75668980 100644 --- a/x/identities/transactions/provision/transaction.go +++ b/x/identities/transactions/provision/transaction.go @@ -4,22 +4,14 @@ package provision import ( - "context" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "google.golang.org/grpc" - "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/helpers/constants" - "github.com/AssetMantle/modules/utilities/name" + "google.golang.org/grpc" ) -type dummy struct{} - var Transaction = baseHelpers.NewTransaction( - name.GetPackageName(dummy{}), + _Msg_serviceDesc.ServiceName, "", "", @@ -30,9 +22,6 @@ var Transaction = baseHelpers.NewTransaction( func(server grpc.ServiceRegistrar, keeper helpers.TransactionKeeper) { RegisterMsgServer(server, keeper.(transactionKeeper)) }, - func(clientCtx client.Context, mux *runtime.ServeMux) error { - return RegisterMsgHandlerClient(context.Background(), mux, NewMsgClient(clientCtx)) - }, constants.To, constants.IdentityID, diff --git a/x/identities/transactions/provision/transaction_keeper.go b/x/identities/transactions/provision/transaction_keeper.go index 8fa562199..0a54425ae 100644 --- a/x/identities/transactions/provision/transaction_keeper.go +++ b/x/identities/transactions/provision/transaction_keeper.go @@ -6,7 +6,6 @@ package provision import ( "context" errorConstants "github.com/AssetMantle/modules/helpers/constants" - "github.com/AssetMantle/schema/data" "github.com/AssetMantle/schema/properties/constants" sdkTypes "github.com/cosmos/cosmos-sdk/types" @@ -43,7 +42,7 @@ func (transactionKeeper transactionKeeper) Handle(context context.Context, messa return nil, errorConstants.NotAuthorized.Wrapf("identity with ID %s has reached the maximum allowed number of provision-able addresses %d", message.IdentityID.AsString(), transactionKeeper.parameterManager.Fetch(context).GetParameter(constants.MaxProvisionAddressCountProperty.GetID()).GetMetaProperty().GetData().Get().(data.NumberData).Get()) } - fromAddress := message.GetFromAddress() + fromAddress := message.GetSigners()[0] toAddress, err := sdkTypes.AccAddressFromBech32(message.To) if err != nil { diff --git a/x/identities/transactions/provision/transaction_request.go b/x/identities/transactions/provision/transaction_request.go index 9312b98fa..d38ba0ff1 100644 --- a/x/identities/transactions/provision/transaction_request.go +++ b/x/identities/transactions/provision/transaction_request.go @@ -5,23 +5,21 @@ package provision import ( "encoding/json" - "github.com/AssetMantle/modules/utilities/rest" - - codecUtilities "github.com/AssetMantle/schema/codec/utilities" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" + "io" + "net/http" "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/helpers/constants" ) type transactionRequest struct { - BaseReq rest.BaseReq `json:"baseReq"` - To string `json:"to"` - IdentityID string `json:"identityID"` + helpers.CommonTransactionRequest `json:"commonTransactionRequest"` + To string `json:"to"` + IdentityID string `json:"identityID"` } var _ helpers.TransactionRequest = (*transactionRequest)(nil) @@ -47,23 +45,28 @@ func (transactionRequest transactionRequest) Validate() error { } func (transactionRequest transactionRequest) FromCLI(cliCommand helpers.CLICommand, context client.Context) (helpers.TransactionRequest, error) { return newTransactionRequest( - cliCommand.ReadBaseReq(context), + cliCommand.ReadCommonTransactionRequest(context), cliCommand.ReadString(constants.To), cliCommand.ReadString(constants.IdentityID), ), nil } -func (transactionRequest transactionRequest) FromJSON(rawMessage json.RawMessage) (helpers.TransactionRequest, error) { - if err := json.Unmarshal(rawMessage, &transactionRequest); err != nil { +func (transactionRequest transactionRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.TransactionRequest, error) { + body, err := io.ReadAll(httpRequest.Body) + if err != nil { + return nil, err + } + + if err := json.Unmarshal(body, &transactionRequest); err != nil { return nil, err } return transactionRequest, nil } -func (transactionRequest transactionRequest) GetBaseReq() rest.BaseReq { - return transactionRequest.BaseReq +func (transactionRequest transactionRequest) GetCommonTransactionRequest() helpers.CommonTransactionRequest { + return transactionRequest.CommonTransactionRequest } func (transactionRequest transactionRequest) MakeMsg() (sdkTypes.Msg, error) { - from, err := sdkTypes.AccAddressFromBech32(transactionRequest.GetBaseReq().From) + from, err := sdkTypes.AccAddressFromBech32(transactionRequest.GetCommonTransactionRequest().GetFrom()) if err != nil { return nil, err } @@ -84,16 +87,13 @@ func (transactionRequest transactionRequest) MakeMsg() (sdkTypes.Msg, error) { identityID.(ids.IdentityID), ), nil } -func (transactionRequest) RegisterLegacyAminoCodec(legacyAmino *codec.LegacyAmino) { - codecUtilities.RegisterModuleConcrete(legacyAmino, transactionRequest{}) -} func requestPrototype() helpers.TransactionRequest { return transactionRequest{} } -func newTransactionRequest(baseReq rest.BaseReq, to string, identityID string) helpers.TransactionRequest { +func newTransactionRequest(commonTransactionRequest helpers.CommonTransactionRequest, to string, identityID string) helpers.TransactionRequest { return transactionRequest{ - BaseReq: baseReq, - To: to, - IdentityID: identityID, + CommonTransactionRequest: commonTransactionRequest, + To: to, + IdentityID: identityID, } } diff --git a/x/identities/transactions/provision/transaction_request_test.go b/x/identities/transactions/provision/transaction_request_test.go index ae4f54191..3432f68fa 100644 --- a/x/identities/transactions/provision/transaction_request_test.go +++ b/x/identities/transactions/provision/transaction_request_test.go @@ -4,8 +4,6 @@ package provision import ( - "encoding/json" - "github.com/AssetMantle/modules/utilities/rest" "reflect" "testing" @@ -15,7 +13,6 @@ import ( baseProperties "github.com/AssetMantle/schema/properties/base" baseQualified "github.com/AssetMantle/schema/qualified/base" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" @@ -25,23 +22,23 @@ import ( "github.com/AssetMantle/modules/helpers/constants" ) -func createTestInput(t *testing.T) (rest.BaseReq, string, *baseIDs.IdentityID) { +func createTestInput(t *testing.T) (helpers.CommonTransactionRequest, string, *baseIDs.IdentityID) { immutables := baseQualified.NewImmutables(baseLists.NewPropertyList(baseProperties.NewMesaProperty(baseIDs.NewStringID("ID2"), baseData.NewStringData("Data2")))) mutables := baseQualified.NewMutables(baseLists.NewPropertyList(baseProperties.NewMesaProperty(baseIDs.NewStringID("ID1"), baseData.NewStringData("Data1")))) testClassificationID := baseIDs.NewClassificationID(immutables, mutables) testFromID := baseIDs.NewIdentityID(testClassificationID, immutables) fromAddress := "cosmos1pkkayn066msg6kn33wnl5srhdt3tnu2vzasz9c" - testBaseReq := rest.BaseReq{From: fromAddress, ChainID: "test", Fees: sdkTypes.NewCoins()} + commonTransactionRequest := helpers.PrototypeCommonTransactionRequest().SetFrom(fromAddress) testToAddress := "cosmos1vx8knpllrj7n963p9ttd80w47kpacrhuts497x" - return testBaseReq, testToAddress, testFromID.(*baseIDs.IdentityID) + return commonTransactionRequest, testToAddress, testFromID.(*baseIDs.IdentityID) } func Test_newTransactionRequest(t *testing.T) { - testBaseReq, testToAddress, testFromID := createTestInput(t) + commonTransactionRequest, testToAddress, testFromID := createTestInput(t) type args struct { - baseReq rest.BaseReq - to string - identityID string + commonTransactionRequest helpers.CommonTransactionRequest + to string + identityID string } tests := []struct { name string @@ -49,11 +46,11 @@ func Test_newTransactionRequest(t *testing.T) { want helpers.TransactionRequest }{ {"+ve with nil", args{}, transactionRequest{}}, - {"+ve", args{testBaseReq, testToAddress, testFromID.AsString()}, transactionRequest{testBaseReq, testToAddress, testFromID.AsString()}}, + {"+ve", args{commonTransactionRequest, testToAddress, testFromID.AsString()}, transactionRequest{commonTransactionRequest, testToAddress, testFromID.AsString()}}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - if got := newTransactionRequest(tt.args.baseReq, tt.args.to, tt.args.identityID); !reflect.DeepEqual(got, tt.want) { + if got := newTransactionRequest(tt.args.commonTransactionRequest, tt.args.to, tt.args.identityID); !reflect.DeepEqual(got, tt.want) { t.Errorf("newTransactionRequest() = %v, want %v", got, tt.want) } }) @@ -79,11 +76,11 @@ func Test_requestPrototype(t *testing.T) { func Test_transactionRequest_FromCLI(t *testing.T) { cliCommand := baseHelpers.NewCLICommand("", "", "", []helpers.CLIFlag{constants.To, constants.IdentityID}) - testBaseReq, testToAddress, testFromID := createTestInput(t) + commonTransactionRequest, testToAddress, testFromID := createTestInput(t) type fields struct { - BaseReq rest.BaseReq - To string - IdentityID string + commonTransactionRequest helpers.CommonTransactionRequest + To string + IdentityID string } type args struct { cliCommand helpers.CLICommand @@ -96,14 +93,14 @@ func Test_transactionRequest_FromCLI(t *testing.T) { want helpers.TransactionRequest wantErr bool }{ - {"+ve", fields{testBaseReq, testToAddress, testFromID.AsString()}, args{cliCommand: cliCommand, context: client.Context{}.WithCodec(baseHelpers.CodecPrototype())}, transactionRequest{cliCommand.ReadBaseReq(client.Context{}.WithCodec(baseHelpers.CodecPrototype())), cliCommand.ReadString(constants.To), cliCommand.ReadString(constants.IdentityID)}, false}, + {"+ve", fields{commonTransactionRequest, testToAddress, testFromID.AsString()}, args{cliCommand: cliCommand, context: client.Context{}.WithCodec(baseHelpers.CodecPrototype())}, transactionRequest{cliCommand.ReadCommonTransactionRequest(client.Context{}.WithCodec(baseHelpers.CodecPrototype())), cliCommand.ReadString(constants.To), cliCommand.ReadString(constants.IdentityID)}, false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - To: tt.fields.To, - IdentityID: tt.fields.IdentityID, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + To: tt.fields.To, + IdentityID: tt.fields.IdentityID, } got, err := transactionRequest.FromCLI(tt.args.cliCommand, tt.args.context) if (err != nil) != tt.wantErr { @@ -117,83 +114,45 @@ func Test_transactionRequest_FromCLI(t *testing.T) { } } -func Test_transactionRequest_FromJSON(t *testing.T) { - testBaseReq, testToAddress, testFromID := createTestInput(t) - type fields struct { - BaseReq rest.BaseReq - To string - IdentityID string - } - type args struct { - rawMessage json.RawMessage - } - tests := []struct { - name string - fields fields - args args - want helpers.TransactionRequest - wantErr bool - }{ - {"+ve", fields{testBaseReq, testToAddress, testFromID.AsString()}, args{sdkTypes.MustSortJSON(baseHelpers.CodecPrototype().MustMarshalJSON(&Message{sdkTypes.AccAddress("cosmos1pkkayn066msg6kn33wnl5srhdt3tnu2vzasz9c").String(), sdkTypes.AccAddress(testToAddress).String(), testFromID}))}, transactionRequest{testBaseReq, testToAddress, testFromID.AsString()}, false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - To: tt.fields.To, - IdentityID: tt.fields.IdentityID, - } - got, err := transactionRequest.FromJSON(tt.args.rawMessage) - if (err != nil) != tt.wantErr { - t.Errorf("FromJSON() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("FromJSON() got = %v, want %v", got, tt.want) - } - }) - } -} - func Test_transactionRequest_GetBaseReq(t *testing.T) { - testBaseReq, testToAddress, testFromID := createTestInput(t) + commonTransactionRequest, testToAddress, testFromID := createTestInput(t) type fields struct { - BaseReq rest.BaseReq - To string - IdentityID string + commonTransactionRequest helpers.CommonTransactionRequest + To string + IdentityID string } tests := []struct { name string fields fields - want rest.BaseReq + want helpers.CommonTransactionRequest }{ - {"+ve", fields{testBaseReq, testToAddress, testFromID.AsString()}, testBaseReq}, + {"+ve", fields{commonTransactionRequest, testToAddress, testFromID.AsString()}, commonTransactionRequest}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - To: tt.fields.To, - IdentityID: tt.fields.IdentityID, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + To: tt.fields.To, + IdentityID: tt.fields.IdentityID, } - if got := transactionRequest.GetBaseReq(); !reflect.DeepEqual(got, tt.want) { - t.Errorf("GetBaseReq() = %v, want %v", got, tt.want) + if got := transactionRequest.GetCommonTransactionRequest(); !reflect.DeepEqual(got, tt.want) { + t.Errorf("GetCommonTransactionRequest() = %v, want %v", got, tt.want) } }) } } func Test_transactionRequest_MakeMsg(t *testing.T) { - testBaseReq, testToAddress, testFromID := createTestInput(t) + commonTransactionRequest, testToAddress, testFromID := createTestInput(t) fromAddress := "cosmos1pkkayn066msg6kn33wnl5srhdt3tnu2vzasz9c" fromAccAddress, err := sdkTypes.AccAddressFromBech32(fromAddress) require.Nil(t, err) toAccAddress, err := sdkTypes.AccAddressFromBech32(testToAddress) require.Nil(t, err) type fields struct { - BaseReq rest.BaseReq - To string - IdentityID string + commonTransactionRequest helpers.CommonTransactionRequest + To string + IdentityID string } tests := []struct { name string @@ -201,14 +160,14 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { want sdkTypes.Msg wantErr bool }{ - {"+ve", fields{testBaseReq, testToAddress, testFromID.AsString()}, &Message{fromAccAddress.String(), toAccAddress.String(), testFromID}, false}, + {"+ve", fields{commonTransactionRequest, testToAddress, testFromID.AsString()}, &Message{fromAccAddress.String(), toAccAddress.String(), testFromID}, false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - To: tt.fields.To, - IdentityID: tt.fields.IdentityID, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + To: tt.fields.To, + IdentityID: tt.fields.IdentityID, } got, err := transactionRequest.MakeMsg() if (err != nil) != tt.wantErr { @@ -222,42 +181,12 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { } } -func Test_transactionRequest_RegisterCodec(t *testing.T) { - testBaseReq, testToAddress, testFromID := createTestInput(t) - type fields struct { - BaseReq rest.BaseReq - To string - IdentityID string - } - type args struct { - legacyAmino *codec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve with nil", fields{}, args{codec.NewLegacyAmino()}}, - {"+ve", fields{testBaseReq, testToAddress, testFromID.AsString()}, args{codec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - tr := transactionRequest{ - BaseReq: tt.fields.BaseReq, - To: tt.fields.To, - IdentityID: tt.fields.IdentityID, - } - tr.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - func Test_transactionRequest_Validate(t *testing.T) { - testBaseReq, testToAddress, testFromID := createTestInput(t) + commonTransactionRequest, testToAddress, testFromID := createTestInput(t) type fields struct { - BaseReq rest.BaseReq - To string - IdentityID string + commonTransactionRequest helpers.CommonTransactionRequest + To string + IdentityID string } tests := []struct { name string @@ -265,14 +194,14 @@ func Test_transactionRequest_Validate(t *testing.T) { wantErr bool }{ {"+ve with nil", fields{}, true}, - {"+ve", fields{testBaseReq, testToAddress, testFromID.AsString()}, false}, + {"+ve", fields{commonTransactionRequest, testToAddress, testFromID.AsString()}, false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - To: tt.fields.To, - IdentityID: tt.fields.IdentityID, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + To: tt.fields.To, + IdentityID: tt.fields.IdentityID, } if err := transactionRequest.Validate(); (err != nil) != tt.wantErr { t.Errorf("ValidateBasic() error = %v, wantErr %v", err, tt.wantErr) diff --git a/x/identities/transactions/provision/transaction_response.go b/x/identities/transactions/provision/transaction_response.go index 02b905726..c29c67c66 100644 --- a/x/identities/transactions/provision/transaction_response.go +++ b/x/identities/transactions/provision/transaction_response.go @@ -4,9 +4,8 @@ package provision import ( - sdkTypes "github.com/cosmos/cosmos-sdk/types" - "github.com/AssetMantle/modules/helpers" + sdkTypes "github.com/cosmos/cosmos-sdk/types" ) var _ helpers.TransactionResponse = (*TransactionResponse)(nil) diff --git a/x/identities/transactions/quash/message.go b/x/identities/transactions/quash/message.go index b5ded96ec..016d74ebb 100644 --- a/x/identities/transactions/quash/message.go +++ b/x/identities/transactions/quash/message.go @@ -4,26 +4,15 @@ package quash import ( - codecUtilities "github.com/AssetMantle/schema/codec/utilities" + "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/types" sdkTypes "github.com/cosmos/cosmos-sdk/types" - - "github.com/AssetMantle/modules/helpers" ) var _ helpers.Message = (*Message)(nil) -func (message *Message) Type() string { return Transaction.GetName() } -func (message *Message) GetFromAddress() sdkTypes.AccAddress { - from, err := sdkTypes.AccAddressFromBech32(message.From) - if err != nil { - panic(err) - } - return from -} func (message *Message) ValidateBasic() error { if _, err := sdkTypes.AccAddressFromBech32(message.From); err != nil { return err @@ -43,21 +32,10 @@ func (message *Message) GetSigners() []sdkTypes.AccAddress { } return []sdkTypes.AccAddress{from} } -func (*Message) RegisterLegacyAminoCodec(legacyAmino *codec.LegacyAmino) { - codecUtilities.RegisterModuleConcrete(legacyAmino, Message{}) -} func (message *Message) RegisterInterface(interfaceRegistry types.InterfaceRegistry) { interfaceRegistry.RegisterImplementations((*sdkTypes.Msg)(nil), message) } -func messageFromInterface(msg sdkTypes.Msg) *Message { - switch value := msg.(type) { - case *Message: - return value - default: - return &Message{} - } -} func messagePrototype() helpers.Message { return &Message{} } diff --git a/x/identities/transactions/quash/message_test.go b/x/identities/transactions/quash/message_test.go index f5d13b85e..799f51961 100644 --- a/x/identities/transactions/quash/message_test.go +++ b/x/identities/transactions/quash/message_test.go @@ -13,7 +13,6 @@ import ( baseLists "github.com/AssetMantle/schema/lists/base" baseProperties "github.com/AssetMantle/schema/properties/base" baseQualified "github.com/AssetMantle/schema/qualified/base" - "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" @@ -42,27 +41,6 @@ func createInputForMessage(t *testing.T) (*baseIDs.IdentityID, *baseIDs.Identity return testIdentityID.(*baseIDs.IdentityID), testFromID.(*baseIDs.IdentityID), fromAccAddress, testMessage } -func Test_messageFromInterface(t *testing.T) { - testIdentityID, testFromID, fromAccAddress, testMessage := createInputForMessage(t) - type args struct { - msg sdkTypes.Msg - } - tests := []struct { - name string - args args - want *Message - }{ - {"+ve", args{testMessage}, &Message{fromAccAddress.String(), testFromID, testIdentityID}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := messageFromInterface(tt.args.msg); !reflect.DeepEqual(got, tt.want) { - t.Errorf("messageFromInterface() = %v, want %v", got, tt.want) - } - }) - } -} - func Test_messagePrototype(t *testing.T) { tests := []struct { name string @@ -103,55 +81,6 @@ func Test_message_GetSigners(t *testing.T) { } } -func Test_message_RegisterCodec(t *testing.T) { - testIdentityID, testFromID, fromAccAddress, _ := createInputForMessage(t) - - type args struct { - legacyAmino *codec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{fromAccAddress.String(), testFromID, testIdentityID}, args{codec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - me := &Message{ - From: tt.fields.From, - FromID: tt.fields.FromID, - IdentityID: tt.fields.IdentityID, - } - me.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - -func Test_message_Type(t *testing.T) { - testIdentityID, testFromID, fromAccAddress, _ := createInputForMessage(t) - - tests := []struct { - name string - fields fields - want string - }{ - {"+ve", fields{fromAccAddress.String(), testFromID, testIdentityID}, Transaction.GetName()}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - message := &Message{ - From: tt.fields.From, - FromID: tt.fields.FromID, - IdentityID: tt.fields.IdentityID, - } - if got := message.Type(); got != tt.want { - t.Errorf("Type() = %v, want %v", got, tt.want) - } - }) - } -} - func Test_message_ValidateBasic(t *testing.T) { testIdentityID, testFromID, fromAccAddress, _ := createInputForMessage(t) diff --git a/x/identities/transactions/quash/service.pb.go b/x/identities/transactions/quash/service.pb.go index ff1a67556..53dda44c0 100644 --- a/x/identities/transactions/quash/service.pb.go +++ b/x/identities/transactions/quash/service.pb.go @@ -6,9 +6,9 @@ package quash import ( context "context" fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types/msgservice" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" - _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -31,30 +31,30 @@ func init() { } var fileDescriptor_8f0ffa14eacab991 = []byte{ - // 364 bytes of a gzipped FileDescriptorProto + // 354 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x92, 0xb1, 0x4a, 0xc3, 0x40, - 0x18, 0x80, 0x9b, 0x14, 0x3a, 0x04, 0xa7, 0x4e, 0x12, 0x24, 0x48, 0x1f, 0xe0, 0x0e, 0xec, 0xa0, - 0x1c, 0xa2, 0xb4, 0x8b, 0xed, 0x10, 0x69, 0xb5, 0x43, 0x90, 0x80, 0x5c, 0x93, 0x23, 0x3d, 0x48, - 0xee, 0x6a, 0xee, 0x2a, 0x9d, 0x7d, 0x02, 0xa1, 0x6f, 0xe0, 0xe8, 0xe8, 0xe8, 0x13, 0x88, 0x53, - 0xc1, 0xc5, 0x51, 0x12, 0x27, 0x9f, 0x42, 0x9a, 0x1c, 0xe4, 0xba, 0xde, 0x7a, 0xc7, 0xf7, 0xf1, - 0xfd, 0x3f, 0xbf, 0x33, 0x18, 0x08, 0x41, 0xa4, 0x8f, 0x99, 0x4c, 0x09, 0xcc, 0x78, 0xbc, 0x4a, - 0x89, 0x80, 0x6b, 0x48, 0x63, 0xc2, 0x24, 0x95, 0x94, 0x08, 0x28, 0x73, 0xcc, 0x04, 0x8e, 0x24, - 0xe5, 0x4c, 0xc0, 0x87, 0x15, 0x16, 0x0b, 0x28, 0x48, 0xfe, 0x48, 0x23, 0x02, 0x96, 0x39, 0x97, - 0xbc, 0xdb, 0xd7, 0x14, 0x40, 0x29, 0xc0, 0x1a, 0x34, 0x0a, 0xa0, 0x2b, 0x40, 0xa5, 0x70, 0x8f, - 0x12, 0xce, 0x93, 0x94, 0x40, 0xbc, 0xa4, 0x10, 0x33, 0xc6, 0x25, 0xae, 0x7f, 0x2b, 0xa5, 0x6b, - 0x54, 0x95, 0x11, 0x21, 0x70, 0xa2, 0xaa, 0xdc, 0x6b, 0x13, 0x85, 0xf6, 0x74, 0x9f, 0x13, 0xb1, - 0xe4, 0x4c, 0x28, 0xdf, 0xc9, 0xbb, 0xe5, 0xb4, 0x7d, 0x91, 0x74, 0xdf, 0x2c, 0xa7, 0x33, 0xc2, - 0x2c, 0x4e, 0x49, 0xf7, 0x1c, 0x18, 0x4c, 0x0e, 0xfc, 0x3a, 0xd3, 0x1d, 0x19, 0xd1, 0xb3, 0xe6, - 0xe9, 0x46, 0x05, 0xf6, 0x8e, 0x9f, 0xbe, 0x7e, 0x37, 0xb6, 0xdb, 0x3b, 0x84, 0x59, 0x3d, 0xae, - 0x36, 0x64, 0x45, 0x0d, 0x37, 0xed, 0x8f, 0xc2, 0xb3, 0xb6, 0x85, 0x67, 0xfd, 0x14, 0x9e, 0xf5, - 0x5c, 0x7a, 0xad, 0x6d, 0xe9, 0xb5, 0xbe, 0x4b, 0xaf, 0xe5, 0x9c, 0x46, 0x3c, 0x33, 0x29, 0x19, - 0x1e, 0xdc, 0xd6, 0x57, 0x30, 0xd9, 0xad, 0x67, 0x62, 0xdd, 0x5d, 0x24, 0x54, 0x2e, 0x56, 0x73, - 0x10, 0xf1, 0x0c, 0x1a, 0xec, 0xfe, 0xc5, 0xee, 0x0c, 0xfc, 0x60, 0x3c, 0x9b, 0xbe, 0xda, 0x7b, - 0x07, 0xe5, 0xab, 0x9c, 0x00, 0x8c, 0x9b, 0x9c, 0x99, 0x9e, 0x33, 0xdd, 0xe1, 0x9f, 0x7b, 0x54, - 0xa8, 0xa8, 0x30, 0x08, 0x1b, 0x2a, 0xd4, 0xa9, 0xb0, 0xa2, 0x0a, 0xfb, 0xd2, 0x80, 0x0a, 0xaf, - 0x26, 0x43, 0x9f, 0x48, 0x1c, 0x63, 0x89, 0xff, 0xec, 0x33, 0xcd, 0x80, 0x90, 0x52, 0x20, 0x14, - 0x20, 0xd4, 0x48, 0x10, 0xd2, 0x2d, 0x08, 0x55, 0x9a, 0x79, 0xa7, 0xba, 0xac, 0xfe, 0x7f, 0x00, - 0x00, 0x00, 0xff, 0xff, 0x44, 0xb6, 0x4b, 0xdc, 0x84, 0x03, 0x00, 0x00, + 0x18, 0x80, 0x73, 0x29, 0x76, 0x08, 0x4e, 0x5d, 0x84, 0x0c, 0x19, 0x1c, 0x1d, 0xee, 0xd0, 0x0e, + 0xca, 0x21, 0x4a, 0xbb, 0xd8, 0x0e, 0x91, 0x56, 0x3b, 0x04, 0x09, 0xc8, 0x35, 0x39, 0xd2, 0x40, + 0x93, 0xab, 0xf9, 0xaf, 0xa5, 0xa3, 0x8f, 0x20, 0xfa, 0x04, 0x3a, 0x3a, 0xf9, 0x18, 0xe2, 0xd4, + 0xd1, 0x51, 0xd2, 0x41, 0xf0, 0x29, 0xa4, 0xe9, 0x41, 0xae, 0xeb, 0x4d, 0x81, 0x1f, 0xbe, 0x2f, + 0x5f, 0xfe, 0xfc, 0x4e, 0xa7, 0x03, 0xc0, 0xa5, 0xcf, 0x72, 0x39, 0xe5, 0x24, 0x13, 0xf1, 0x7c, + 0xca, 0x81, 0x2c, 0x49, 0x1a, 0xf3, 0x5c, 0xa6, 0x32, 0xe5, 0x40, 0x64, 0xc1, 0x72, 0x60, 0x91, + 0x4c, 0x45, 0x0e, 0xe4, 0x61, 0xce, 0x60, 0x42, 0x80, 0x17, 0x8b, 0x34, 0xe2, 0x78, 0x56, 0x08, + 0x29, 0x5a, 0x6d, 0x4d, 0x81, 0x95, 0x02, 0x2f, 0x71, 0xad, 0xc0, 0xba, 0x02, 0x57, 0x0a, 0xf7, + 0x20, 0x12, 0x90, 0x09, 0x20, 0x19, 0x24, 0x64, 0x71, 0xbc, 0x79, 0x6c, 0x6d, 0xae, 0x51, 0x50, + 0xc6, 0x01, 0x58, 0xa2, 0x82, 0xdc, 0x6b, 0x13, 0x85, 0x36, 0xba, 0x2f, 0x38, 0xcc, 0x44, 0x0e, + 0xca, 0x77, 0xf2, 0x8a, 0x9c, 0x86, 0x0f, 0x49, 0xeb, 0x19, 0x39, 0xcd, 0x1e, 0xcb, 0xe3, 0x29, + 0x6f, 0x9d, 0x63, 0x83, 0x8f, 0xc6, 0xfe, 0x36, 0xd3, 0xed, 0x19, 0xd1, 0xa3, 0x7a, 0x74, 0xa3, + 0x02, 0x0f, 0x2d, 0x77, 0xef, 0xf1, 0xf7, 0xe3, 0x08, 0x75, 0x5f, 0x1a, 0x9f, 0xa5, 0x87, 0x56, + 0xa5, 0x87, 0x7e, 0x4a, 0x0f, 0x3d, 0xad, 0x3d, 0x6b, 0xb5, 0xf6, 0xac, 0xef, 0xb5, 0x67, 0x39, + 0xa7, 0x91, 0xc8, 0x4c, 0x5e, 0xd8, 0xdd, 0xbf, 0xdd, 0xfe, 0xe7, 0xc1, 0x66, 0x0b, 0x03, 0x74, + 0x77, 0x91, 0xa4, 0x72, 0x32, 0x1f, 0xe3, 0x48, 0x64, 0xc4, 0x60, 0xc5, 0x6f, 0x76, 0xb3, 0xe3, + 0x07, 0xfd, 0xd1, 0xf0, 0xdd, 0xde, 0x39, 0x19, 0x5f, 0xe5, 0x04, 0xb8, 0x5f, 0xe7, 0x8c, 0xf4, + 0x9c, 0xe1, 0x06, 0xff, 0xda, 0xa1, 0x42, 0x45, 0x85, 0x41, 0x58, 0x53, 0xa1, 0x4e, 0x85, 0x15, + 0x55, 0xda, 0x97, 0x06, 0x54, 0x78, 0x35, 0xe8, 0xfa, 0x5c, 0xb2, 0x98, 0x49, 0xf6, 0x67, 0x9f, + 0x69, 0x06, 0x4a, 0x95, 0x82, 0xd2, 0x80, 0xd2, 0x5a, 0x42, 0xa9, 0x6e, 0xa1, 0xb4, 0xd2, 0x8c, + 0x9b, 0xd5, 0x01, 0xb5, 0xff, 0x03, 0x00, 0x00, 0xff, 0xff, 0x88, 0xf0, 0x37, 0x31, 0x66, 0x03, + 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/identities/transactions/quash/service.pb.gw.go b/x/identities/transactions/quash/service.pb.gw.go deleted file mode 100644 index 23f0ca11c..000000000 --- a/x/identities/transactions/quash/service.pb.gw.go +++ /dev/null @@ -1,171 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: AssetMantle/modules/x/identities/transactions/quash/service.proto - -/* -Package quash is a reverse proxy. - -It translates gRPC into RESTful JSON APIs. -*/ -package quash - -import ( - "context" - "io" - "net/http" - - "github.com/golang/protobuf/descriptor" - "github.com/golang/protobuf/proto" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/grpc-ecosystem/grpc-gateway/utilities" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/status" -) - -// Suppress "imported and not used" errors -var _ codes.Code -var _ io.Reader -var _ status.Status -var _ = runtime.String -var _ = utilities.NewDoubleArray -var _ = descriptor.ForMessage -var _ = metadata.Join - -var ( - filter_Msg_Handle_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - -func request_Msg_Handle_0(ctx context.Context, marshaler runtime.Marshaler, client MsgClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq Message - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.Handle(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Msg_Handle_0(ctx context.Context, marshaler runtime.Marshaler, server MsgServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq Message - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.Handle(ctx, &protoReq) - return msg, metadata, err - -} - -// RegisterMsgHandlerServer registers the http handlers for service Msg to "mux". -// UnaryRPC :call MsgServer directly. -// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterMsgHandlerFromEndpoint instead. -func RegisterMsgHandlerServer(ctx context.Context, mux *runtime.ServeMux, server MsgServer) error { - - mux.Handle("POST", pattern_Msg_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Msg_Handle_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Msg_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -// RegisterMsgHandlerFromEndpoint is same as RegisterMsgHandler but -// automatically dials to "endpoint" and closes the connection when "ctx" gets done. -func RegisterMsgHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.Dial(endpoint, opts...) - if err != nil { - return err - } - defer func() { - if err != nil { - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - return - } - go func() { - <-ctx.Done() - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - }() - }() - - return RegisterMsgHandler(ctx, mux, conn) -} - -// RegisterMsgHandler registers the http handlers for service Msg to "mux". -// The handlers forward requests to the grpc endpoint over "conn". -func RegisterMsgHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { - return RegisterMsgHandlerClient(ctx, mux, NewMsgClient(conn)) -} - -// RegisterMsgHandlerClient registers the http handlers for service Msg -// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "MsgClient". -// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "MsgClient" -// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "MsgClient" to call the correct interceptors. -func RegisterMsgHandlerClient(ctx context.Context, mux *runtime.ServeMux, client MsgClient) error { - - mux.Handle("POST", pattern_Msg_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Msg_Handle_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Msg_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -var ( - pattern_Msg_Handle_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"mantle", "identities", "quash"}, "", runtime.AssumeColonVerbOpt(false))) -) - -var ( - forward_Msg_Handle_0 = runtime.ForwardResponseMessage -) diff --git a/x/identities/transactions/quash/transaction.go b/x/identities/transactions/quash/transaction.go index 3134d2a0b..834f9c601 100644 --- a/x/identities/transactions/quash/transaction.go +++ b/x/identities/transactions/quash/transaction.go @@ -4,22 +4,14 @@ package quash import ( - "context" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "google.golang.org/grpc" - "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/helpers/constants" - "github.com/AssetMantle/modules/utilities/name" + "google.golang.org/grpc" ) -type dummy struct{} - var Transaction = baseHelpers.NewTransaction( - name.GetPackageName(dummy{}), + _Msg_serviceDesc.ServiceName, "", "", @@ -30,9 +22,6 @@ var Transaction = baseHelpers.NewTransaction( func(server grpc.ServiceRegistrar, keeper helpers.TransactionKeeper) { RegisterMsgServer(server, keeper.(transactionKeeper)) }, - func(clientCtx client.Context, mux *runtime.ServeMux) error { - return RegisterMsgHandlerClient(context.Background(), mux, NewMsgClient(clientCtx)) - }, constants.FromIdentityID, constants.IdentityID, diff --git a/x/identities/transactions/quash/transaction_keeper.go b/x/identities/transactions/quash/transaction_keeper.go index 7cb480a98..eece7ced8 100644 --- a/x/identities/transactions/quash/transaction_keeper.go +++ b/x/identities/transactions/quash/transaction_keeper.go @@ -6,7 +6,6 @@ package quash import ( "context" errorConstants "github.com/AssetMantle/modules/helpers/constants" - "github.com/AssetMantle/schema/data" "github.com/AssetMantle/schema/properties" constantProperties "github.com/AssetMantle/schema/properties/constants" @@ -42,7 +41,7 @@ func (transactionKeeper transactionKeeper) Handle(context context.Context, messa return nil, errorConstants.NotAuthorized.Wrapf("identity quashing is not enabled") } - fromAddress := message.GetFromAddress() + fromAddress := message.GetSigners()[0] if Mappable := transactionKeeper.mapper.NewCollection(context).Fetch(key.NewKey(message.FromID)).GetMappable(key.NewKey(message.FromID)); Mappable == nil { return nil, errorConstants.EntityNotFound.Wrapf("identity with ID %s not found", message.FromID.AsString()) diff --git a/x/identities/transactions/quash/transaction_request.go b/x/identities/transactions/quash/transaction_request.go index cd9f490dd..7f63a2c98 100644 --- a/x/identities/transactions/quash/transaction_request.go +++ b/x/identities/transactions/quash/transaction_request.go @@ -5,23 +5,21 @@ package quash import ( "encoding/json" - "github.com/AssetMantle/modules/utilities/rest" - - codecUtilities "github.com/AssetMantle/schema/codec/utilities" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" + "io" + "net/http" "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/helpers/constants" ) type transactionRequest struct { - BaseReq rest.BaseReq `json:"baseReq"` - FromID string `json:"fromID"` - IdentityID string `json:"identityID"` + helpers.CommonTransactionRequest `json:"commonTransactionRequest"` + FromID string `json:"fromID"` + IdentityID string `json:"identityID"` } var _ helpers.TransactionRequest = (*transactionRequest)(nil) @@ -47,23 +45,28 @@ func (transactionRequest transactionRequest) Validate() error { } func (transactionRequest transactionRequest) FromCLI(cliCommand helpers.CLICommand, context client.Context) (helpers.TransactionRequest, error) { return newTransactionRequest( - cliCommand.ReadBaseReq(context), + cliCommand.ReadCommonTransactionRequest(context), cliCommand.ReadString(constants.FromIdentityID), cliCommand.ReadString(constants.IdentityID), ), nil } -func (transactionRequest transactionRequest) FromJSON(rawMessage json.RawMessage) (helpers.TransactionRequest, error) { - if err := json.Unmarshal(rawMessage, &transactionRequest); err != nil { +func (transactionRequest transactionRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.TransactionRequest, error) { + body, err := io.ReadAll(httpRequest.Body) + if err != nil { + return nil, err + } + + if err := json.Unmarshal(body, &transactionRequest); err != nil { return nil, err } return transactionRequest, nil } -func (transactionRequest transactionRequest) GetBaseReq() rest.BaseReq { - return transactionRequest.BaseReq +func (transactionRequest transactionRequest) GetCommonTransactionRequest() helpers.CommonTransactionRequest { + return transactionRequest.CommonTransactionRequest } func (transactionRequest transactionRequest) MakeMsg() (sdkTypes.Msg, error) { - from, err := sdkTypes.AccAddressFromBech32(transactionRequest.GetBaseReq().From) + from, err := sdkTypes.AccAddressFromBech32(transactionRequest.GetCommonTransactionRequest().GetFrom()) if err != nil { return nil, err } @@ -84,16 +87,13 @@ func (transactionRequest transactionRequest) MakeMsg() (sdkTypes.Msg, error) { identityID.(ids.IdentityID), ), nil } -func (transactionRequest) RegisterLegacyAminoCodec(legacyAmino *codec.LegacyAmino) { - codecUtilities.RegisterModuleConcrete(legacyAmino, transactionRequest{}) -} func requestPrototype() helpers.TransactionRequest { return transactionRequest{} } -func newTransactionRequest(baseReq rest.BaseReq, fromID string, identityID string) helpers.TransactionRequest { +func newTransactionRequest(commonTransactionRequest helpers.CommonTransactionRequest, fromID string, identityID string) helpers.TransactionRequest { return transactionRequest{ - BaseReq: baseReq, - FromID: fromID, - IdentityID: identityID, + CommonTransactionRequest: commonTransactionRequest, + FromID: fromID, + IdentityID: identityID, } } diff --git a/x/identities/transactions/quash/transaction_request_test.go b/x/identities/transactions/quash/transaction_request_test.go index a5e5f094e..32e8562c1 100644 --- a/x/identities/transactions/quash/transaction_request_test.go +++ b/x/identities/transactions/quash/transaction_request_test.go @@ -4,8 +4,6 @@ package quash import ( - "encoding/json" - "github.com/AssetMantle/modules/utilities/rest" "reflect" "testing" @@ -15,7 +13,6 @@ import ( baseProperties "github.com/AssetMantle/schema/properties/base" baseQualified "github.com/AssetMantle/schema/qualified/base" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" @@ -25,23 +22,23 @@ import ( "github.com/AssetMantle/modules/helpers/constants" ) -func createTestInput(t *testing.T) (rest.BaseReq, string, *baseIDs.IdentityID) { +func createTestInput(t *testing.T) (helpers.CommonTransactionRequest, string, *baseIDs.IdentityID) { immutables := baseQualified.NewImmutables(baseLists.NewPropertyList(baseProperties.NewMesaProperty(baseIDs.NewStringID("ID2"), baseData.NewStringData("Data2")))) mutables := baseQualified.NewMutables(baseLists.NewPropertyList(baseProperties.NewMesaProperty(baseIDs.NewStringID("ID1"), baseData.NewStringData("Data1")))) testClassificationID := baseIDs.NewClassificationID(immutables, mutables) testFromID := baseIDs.NewIdentityID(testClassificationID, immutables) fromAddress := "cosmos1pkkayn066msg6kn33wnl5srhdt3tnu2vzasz9c" - testBaseReq := rest.BaseReq{From: fromAddress, ChainID: "test", Fees: types.NewCoins()} + commonTransactionRequest := helpers.PrototypeCommonTransactionRequest().SetFrom(fromAddress) testToAddress := "cosmos1vx8knpllrj7n963p9ttd80w47kpacrhuts497x" - return testBaseReq, testToAddress, testFromID.(*baseIDs.IdentityID) + return commonTransactionRequest, testToAddress, testFromID.(*baseIDs.IdentityID) } func Test_newTransactionRequest(t *testing.T) { - testBaseReq, testToAddress, testFromID := createTestInput(t) + commonTransactionRequest, testToAddress, testFromID := createTestInput(t) type args struct { - baseReq rest.BaseReq - fromID string - identityID string + commonTransactionRequest helpers.CommonTransactionRequest + fromID string + identityID string } tests := []struct { name string @@ -49,11 +46,11 @@ func Test_newTransactionRequest(t *testing.T) { want helpers.TransactionRequest }{ {"+ve with nil", args{}, transactionRequest{}}, - {"+ve", args{testBaseReq, testToAddress, testFromID.AsString()}, transactionRequest{testBaseReq, testToAddress, testFromID.AsString()}}, + {"+ve", args{commonTransactionRequest, testToAddress, testFromID.AsString()}, transactionRequest{commonTransactionRequest, testToAddress, testFromID.AsString()}}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - if got := newTransactionRequest(tt.args.baseReq, tt.args.fromID, tt.args.identityID); !reflect.DeepEqual(got, tt.want) { + if got := newTransactionRequest(tt.args.commonTransactionRequest, tt.args.fromID, tt.args.identityID); !reflect.DeepEqual(got, tt.want) { t.Errorf("newTransactionRequest() = %v, want %v", got, tt.want) } }) @@ -79,11 +76,11 @@ func Test_requestPrototype(t *testing.T) { func Test_transactionRequest_FromCLI(t *testing.T) { cliCommand := baseHelpers.NewCLICommand("", "", "", []helpers.CLIFlag{constants.FromIdentityID, constants.IdentityID}) - testBaseReq, _, testFromID := createTestInput(t) + commonTransactionRequest, _, testFromID := createTestInput(t) type fields struct { - BaseReq rest.BaseReq - FromID string - IdentityID string + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + IdentityID string } type args struct { cliCommand helpers.CLICommand @@ -96,14 +93,14 @@ func Test_transactionRequest_FromCLI(t *testing.T) { want helpers.TransactionRequest wantErr bool }{ - {"+ve", fields{testBaseReq, testFromID.AsString(), testFromID.AsString()}, args{cliCommand: cliCommand, context: client.Context{}.WithCodec(baseHelpers.CodecPrototype())}, transactionRequest{cliCommand.ReadBaseReq(client.Context{}.WithCodec(baseHelpers.CodecPrototype())), cliCommand.ReadString(constants.FromIdentityID), cliCommand.ReadString(constants.IdentityID)}, false}, + {"+ve", fields{commonTransactionRequest, testFromID.AsString(), testFromID.AsString()}, args{cliCommand: cliCommand, context: client.Context{}.WithCodec(baseHelpers.CodecPrototype())}, transactionRequest{cliCommand.ReadCommonTransactionRequest(client.Context{}.WithCodec(baseHelpers.CodecPrototype())), cliCommand.ReadString(constants.FromIdentityID), cliCommand.ReadString(constants.IdentityID)}, false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - IdentityID: tt.fields.IdentityID, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + IdentityID: tt.fields.IdentityID, } got, err := transactionRequest.FromCLI(tt.args.cliCommand, tt.args.context) if (err != nil) != tt.wantErr { @@ -117,81 +114,43 @@ func Test_transactionRequest_FromCLI(t *testing.T) { } } -func Test_transactionRequest_FromJSON(t *testing.T) { - testBaseReq, testToAddress, testFromID := createTestInput(t) - type fields struct { - BaseReq rest.BaseReq - FromID string - IdentityID string - } - type args struct { - rawMessage json.RawMessage - } - tests := []struct { - name string - fields fields - args args - want helpers.TransactionRequest - wantErr bool - }{ - {"+ve", fields{testBaseReq, testToAddress, testFromID.AsString()}, args{types.MustSortJSON(baseHelpers.CodecPrototype().MustMarshalJSON(&Message{types.AccAddress("cosmos1pkkayn066msg6kn33wnl5srhdt3tnu2vzasz9c").String(), testFromID, testFromID}))}, transactionRequest{testBaseReq, testToAddress, testFromID.AsString()}, false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - IdentityID: tt.fields.IdentityID, - } - got, err := transactionRequest.FromJSON(tt.args.rawMessage) - if (err != nil) != tt.wantErr { - t.Errorf("FromJSON() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("FromJSON() got = %v, want %v", got, tt.want) - } - }) - } -} - func Test_transactionRequest_GetBaseReq(t *testing.T) { - testBaseReq, testToAddress, testFromID := createTestInput(t) + commonTransactionRequest, testToAddress, testFromID := createTestInput(t) type fields struct { - BaseReq rest.BaseReq - FromID string - IdentityID string + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + IdentityID string } tests := []struct { name string fields fields - want rest.BaseReq + want helpers.CommonTransactionRequest }{ - {"+ve", fields{testBaseReq, testToAddress, testFromID.AsString()}, testBaseReq}, + {"+ve", fields{commonTransactionRequest, testToAddress, testFromID.AsString()}, commonTransactionRequest}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - IdentityID: tt.fields.IdentityID, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + IdentityID: tt.fields.IdentityID, } - if got := transactionRequest.GetBaseReq(); !reflect.DeepEqual(got, tt.want) { - t.Errorf("GetBaseReq() = %v, want %v", got, tt.want) + if got := transactionRequest.GetCommonTransactionRequest(); !reflect.DeepEqual(got, tt.want) { + t.Errorf("GetCommonTransactionRequest() = %v, want %v", got, tt.want) } }) } } func Test_transactionRequest_MakeMsg(t *testing.T) { - testBaseReq, _, testFromID := createTestInput(t) + commonTransactionRequest, _, testFromID := createTestInput(t) fromAddress := "cosmos1pkkayn066msg6kn33wnl5srhdt3tnu2vzasz9c" fromAccAddress, err := types.AccAddressFromBech32(fromAddress) require.Nil(t, err) type fields struct { - BaseReq rest.BaseReq - FromID string - IdentityID string + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + IdentityID string } tests := []struct { name string @@ -199,14 +158,14 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { want helpers.Message wantErr bool }{ - {"+ve", fields{testBaseReq, testFromID.AsString(), testFromID.AsString()}, &Message{fromAccAddress.String(), testFromID, testFromID}, false}, + {"+ve", fields{commonTransactionRequest, testFromID.AsString(), testFromID.AsString()}, &Message{fromAccAddress.String(), testFromID, testFromID}, false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - IdentityID: tt.fields.IdentityID, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + IdentityID: tt.fields.IdentityID, } got, err := transactionRequest.MakeMsg() if (err != nil) != tt.wantErr { @@ -220,42 +179,12 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { } } -func Test_transactionRequest_RegisterCodec(t *testing.T) { - testBaseReq, testToAddress, testFromID := createTestInput(t) - type fields struct { - BaseReq rest.BaseReq - FromID string - IdentityID string - } - type args struct { - legacyAmino *codec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve with nil", fields{}, args{codec.NewLegacyAmino()}}, - {"+ve", fields{testBaseReq, testToAddress, testFromID.AsString()}, args{codec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - tr := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - IdentityID: tt.fields.IdentityID, - } - tr.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - func Test_transactionRequest_Validate(t *testing.T) { - testBaseReq, testToAddress, testFromID := createTestInput(t) + commonTransactionRequest, testToAddress, testFromID := createTestInput(t) type fields struct { - BaseReq rest.BaseReq - FromID string - IdentityID string + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + IdentityID string } tests := []struct { name string @@ -263,14 +192,14 @@ func Test_transactionRequest_Validate(t *testing.T) { wantErr bool }{ {"+ve with nil", fields{}, true}, - {"+ve", fields{testBaseReq, testToAddress, testFromID.AsString()}, false}, + {"+ve", fields{commonTransactionRequest, testToAddress, testFromID.AsString()}, false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - IdentityID: tt.fields.IdentityID, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + IdentityID: tt.fields.IdentityID, } if err := transactionRequest.Validate(); (err != nil) != tt.wantErr { t.Errorf("ValidateBasic() error = %v, wantErr %v", err, tt.wantErr) diff --git a/x/identities/transactions/quash/transaction_response.go b/x/identities/transactions/quash/transaction_response.go index 9ca640132..41457dad8 100644 --- a/x/identities/transactions/quash/transaction_response.go +++ b/x/identities/transactions/quash/transaction_response.go @@ -4,9 +4,8 @@ package quash import ( - sdkTypes "github.com/cosmos/cosmos-sdk/types" - "github.com/AssetMantle/modules/helpers" + sdkTypes "github.com/cosmos/cosmos-sdk/types" ) var _ helpers.TransactionResponse = (*TransactionResponse)(nil) diff --git a/x/identities/transactions/revoke/message.go b/x/identities/transactions/revoke/message.go index 78c8daf85..c69516d95 100644 --- a/x/identities/transactions/revoke/message.go +++ b/x/identities/transactions/revoke/message.go @@ -4,26 +4,15 @@ package revoke import ( - codecUtilities "github.com/AssetMantle/schema/codec/utilities" + "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/types" sdkTypes "github.com/cosmos/cosmos-sdk/types" - - "github.com/AssetMantle/modules/helpers" ) var _ helpers.Message = (*Message)(nil) -func (message *Message) Type() string { return Transaction.GetName() } -func (message *Message) GetFromAddress() sdkTypes.AccAddress { - from, err := sdkTypes.AccAddressFromBech32(message.From) - if err != nil { - panic(err) - } - return from -} func (message *Message) ValidateBasic() error { if _, err := sdkTypes.AccAddressFromBech32(message.From); err != nil { return err @@ -46,21 +35,10 @@ func (message *Message) GetSigners() []sdkTypes.AccAddress { } return []sdkTypes.AccAddress{from} } -func (*Message) RegisterLegacyAminoCodec(legacyAmino *codec.LegacyAmino) { - codecUtilities.RegisterModuleConcrete(legacyAmino, Message{}) -} func (message *Message) RegisterInterface(interfaceRegistry types.InterfaceRegistry) { interfaceRegistry.RegisterImplementations((*sdkTypes.Msg)(nil), message) } -func messageFromInterface(msg sdkTypes.Msg) *Message { - switch value := msg.(type) { - case *Message: - return value - default: - return &Message{} - } -} func messagePrototype() helpers.Message { return &Message{} } diff --git a/x/identities/transactions/revoke/message_test.go b/x/identities/transactions/revoke/message_test.go index efc44c85f..25c6d2ebb 100644 --- a/x/identities/transactions/revoke/message_test.go +++ b/x/identities/transactions/revoke/message_test.go @@ -13,7 +13,6 @@ import ( baseLists "github.com/AssetMantle/schema/lists/base" baseProperties "github.com/AssetMantle/schema/properties/base" baseQualified "github.com/AssetMantle/schema/qualified/base" - "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" @@ -45,27 +44,6 @@ func CreateTestInputForMessage(t *testing.T) (*baseIDs.IdentityID, *baseIDs.Iden return testFromID.(*baseIDs.IdentityID), testToID.(*baseIDs.IdentityID), testClassificationID.(*baseIDs.ClassificationID), fromAccAddress, testMessage } -func Test_messageFromInterface(t *testing.T) { - testFromID, testToID, testClassificationID, fromAccAddress, testMessage := CreateTestInputForMessage(t) - type args struct { - msg sdkTypes.Msg - } - tests := []struct { - name string - args args - want *Message - }{ - {"+ve", args{testMessage}, &Message{fromAccAddress.String(), testFromID, testToID, testClassificationID}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := messageFromInterface(tt.args.msg); !reflect.DeepEqual(got, tt.want) { - t.Errorf("messageFromInterface() = %v, want %v", got, tt.want) - } - }) - } -} - func Test_messagePrototype(t *testing.T) { tests := []struct { name string @@ -107,57 +85,6 @@ func Test_message_GetSigners(t *testing.T) { } } -func Test_message_RegisterCodec(t *testing.T) { - testFromID, testToID, testClassificationID, fromAccAddress, _ := CreateTestInputForMessage(t) - - type args struct { - legacyAmino *codec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{fromAccAddress.String(), testFromID, testToID, testClassificationID}, args{codec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - me := &Message{ - From: tt.fields.From, - FromID: tt.fields.FromID, - ToID: tt.fields.ToID, - ClassificationID: tt.fields.ClassificationID, - } - me.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - -func Test_message_Type(t *testing.T) { - testFromID, testToID, testClassificationID, fromAccAddress, _ := CreateTestInputForMessage(t) - - tests := []struct { - name string - fields fields - want string - }{ - {"+ve", fields{fromAccAddress.String(), testFromID, testToID, testClassificationID}, Transaction.GetName()}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - message := &Message{ - From: tt.fields.From, - FromID: tt.fields.FromID, - ToID: tt.fields.ToID, - ClassificationID: tt.fields.ClassificationID, - } - if got := message.Type(); got != tt.want { - t.Errorf("Type() = %v, want %v", got, tt.want) - } - }) - } -} - func Test_message_ValidateBasic(t *testing.T) { testFromID, testToID, testClassificationID, fromAccAddress, _ := CreateTestInputForMessage(t) diff --git a/x/identities/transactions/revoke/service.pb.go b/x/identities/transactions/revoke/service.pb.go index c0206af82..611099dbe 100644 --- a/x/identities/transactions/revoke/service.pb.go +++ b/x/identities/transactions/revoke/service.pb.go @@ -6,9 +6,9 @@ package revoke import ( context "context" fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types/msgservice" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" - _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -31,30 +31,30 @@ func init() { } var fileDescriptor_e76110c17ab23cba = []byte{ - // 363 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x92, 0x31, 0x4b, 0xc3, 0x40, - 0x14, 0x80, 0x9b, 0x14, 0x3a, 0x04, 0xa7, 0x6e, 0x46, 0x09, 0xd8, 0x1f, 0x70, 0x07, 0xea, 0xa0, - 0x07, 0xa2, 0xcd, 0xa2, 0x1d, 0x82, 0xa5, 0x76, 0x08, 0x12, 0x90, 0x6b, 0xf2, 0x88, 0xc1, 0xe4, - 0xae, 0xe4, 0xae, 0xa5, 0xb3, 0xbf, 0x40, 0x70, 0x72, 0x75, 0x74, 0x77, 0x74, 0x17, 0xa7, 0x82, - 0x8b, 0xa3, 0xa4, 0x4e, 0xfe, 0x0a, 0xb1, 0x17, 0xc8, 0x75, 0xbd, 0xf5, 0x85, 0xef, 0xe3, 0x7b, - 0xb9, 0xe7, 0xf8, 0x7d, 0x21, 0x40, 0x06, 0x94, 0xc9, 0x1c, 0x70, 0xc1, 0x93, 0x59, 0x0e, 0x02, - 0x2f, 0x70, 0x96, 0x00, 0x93, 0x99, 0xcc, 0x40, 0x60, 0x59, 0x52, 0x26, 0x68, 0x2c, 0x33, 0xce, - 0x04, 0x2e, 0x61, 0xce, 0xef, 0x00, 0x0b, 0x28, 0xe7, 0x59, 0x0c, 0x68, 0x5a, 0x72, 0xc9, 0xbb, - 0x87, 0x9a, 0x03, 0xd5, 0x0e, 0xb4, 0x40, 0x8d, 0x03, 0xe9, 0x0e, 0xa4, 0x1c, 0xee, 0x6e, 0xca, - 0x79, 0x9a, 0x03, 0xa6, 0xd3, 0x0c, 0x53, 0xc6, 0xb8, 0xa4, 0xea, 0xf3, 0xda, 0xe9, 0x9a, 0x75, - 0x15, 0x20, 0x04, 0x4d, 0xeb, 0x2e, 0xf7, 0xd2, 0xc8, 0xa1, 0xcd, 0x6e, 0x4a, 0x10, 0x53, 0xce, - 0x44, 0x2d, 0xdc, 0x7f, 0xb3, 0x9c, 0x76, 0x20, 0xd2, 0xee, 0xab, 0xe5, 0x74, 0x2e, 0x28, 0x4b, - 0x72, 0xe8, 0x9e, 0x20, 0x93, 0xe5, 0x51, 0xa0, 0x42, 0xdd, 0x81, 0x19, 0x3e, 0x6e, 0x66, 0xa3, - 0x3a, 0xb1, 0xb7, 0x77, 0xff, 0xf9, 0xf3, 0x68, 0xef, 0xf4, 0xb6, 0x71, 0xa1, 0x36, 0xd6, 0xf6, - 0x54, 0x98, 0xff, 0xd4, 0x7e, 0xaf, 0x3c, 0x6b, 0x59, 0x79, 0xd6, 0x77, 0xe5, 0x59, 0x0f, 0x2b, - 0xaf, 0xb5, 0x5c, 0x79, 0xad, 0xaf, 0x95, 0xd7, 0x72, 0x8e, 0x62, 0x5e, 0x18, 0xb5, 0xf8, 0x5b, - 0x57, 0xea, 0x18, 0x86, 0xff, 0xbf, 0x68, 0x68, 0x5d, 0x9f, 0xa6, 0x99, 0xbc, 0x9d, 0x4d, 0x50, - 0xcc, 0x0b, 0x6c, 0xf2, 0x00, 0xcf, 0x76, 0xa7, 0x1f, 0x84, 0x83, 0xf1, 0xe8, 0xc5, 0xde, 0x38, - 0xac, 0xa0, 0x0e, 0x0a, 0xd1, 0xa0, 0x09, 0x1a, 0xeb, 0x41, 0xa3, 0x35, 0xff, 0xb1, 0x81, 0x45, - 0x35, 0x16, 0x85, 0x51, 0x83, 0x45, 0x3a, 0x16, 0x29, 0xac, 0xb2, 0xcf, 0x4c, 0xb0, 0xe8, 0x7c, - 0xe8, 0x07, 0x20, 0x69, 0x42, 0x25, 0xfd, 0xb5, 0x8f, 0x35, 0x05, 0x21, 0xb5, 0x83, 0x90, 0x90, - 0x90, 0xc6, 0x42, 0x88, 0xae, 0x21, 0x44, 0x79, 0x26, 0x9d, 0xf5, 0x89, 0x1d, 0xfc, 0x05, 0x00, - 0x00, 0xff, 0xff, 0x60, 0x1b, 0xdf, 0xa1, 0x91, 0x03, 0x00, 0x00, + // 356 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x92, 0x3f, 0x4b, 0xfb, 0x40, + 0x18, 0x80, 0x73, 0x29, 0xbf, 0x0e, 0xe1, 0x37, 0x75, 0x11, 0x32, 0x64, 0x70, 0x74, 0xb8, 0xc3, + 0x3f, 0x83, 0x1e, 0x88, 0x36, 0x8b, 0x76, 0x08, 0x96, 0xda, 0x21, 0x48, 0x40, 0xae, 0xc9, 0x11, + 0x83, 0x4d, 0xae, 0xe4, 0xbd, 0x96, 0x8e, 0x7e, 0x04, 0x07, 0x17, 0x57, 0xdd, 0x9c, 0xfc, 0x18, + 0xe2, 0xd4, 0xd1, 0x51, 0x92, 0x41, 0xf0, 0x53, 0x48, 0x9b, 0x83, 0x5c, 0xd7, 0x9b, 0x02, 0x2f, + 0x3c, 0x4f, 0x9e, 0xbc, 0x79, 0x1d, 0xbf, 0x0f, 0xc0, 0x65, 0xc0, 0x0a, 0x39, 0xe5, 0x24, 0x17, + 0xc9, 0x7c, 0xca, 0x81, 0x2c, 0x49, 0x96, 0xf0, 0x42, 0x66, 0x32, 0xe3, 0x40, 0x64, 0xc9, 0x0a, + 0x60, 0xb1, 0xcc, 0x44, 0x01, 0xa4, 0xe4, 0x0b, 0x71, 0xcf, 0x09, 0xf0, 0x72, 0x91, 0xc5, 0x1c, + 0xcf, 0x4a, 0x21, 0x45, 0xef, 0x48, 0x73, 0x60, 0xe5, 0xc0, 0x4b, 0xdc, 0x3a, 0xb0, 0xee, 0xc0, + 0x8d, 0xc3, 0xdd, 0x89, 0x05, 0xe4, 0x02, 0x48, 0x0e, 0x29, 0x59, 0xec, 0xaf, 0x1f, 0x8d, 0xce, + 0x35, 0x4b, 0xca, 0x39, 0x00, 0x4b, 0x55, 0x92, 0x7b, 0x65, 0xe4, 0xd0, 0x66, 0xb7, 0x25, 0x87, + 0x99, 0x28, 0x40, 0x09, 0x0f, 0x5e, 0x91, 0xd3, 0x09, 0x20, 0xed, 0x3d, 0x21, 0xa7, 0x7b, 0xc9, + 0x8a, 0x64, 0xca, 0x7b, 0xa7, 0xd8, 0xe4, 0xbb, 0x71, 0xd0, 0x84, 0xba, 0x03, 0x33, 0x7c, 0xdc, + 0xce, 0x46, 0x2a, 0x71, 0xd7, 0x72, 0xff, 0x3d, 0xfc, 0xbc, 0xef, 0x21, 0xff, 0xb9, 0xf3, 0x51, + 0x79, 0x68, 0x55, 0x79, 0xe8, 0xbb, 0xf2, 0xd0, 0x63, 0xed, 0x59, 0xab, 0xda, 0xb3, 0xbe, 0x6a, + 0xcf, 0x72, 0x8e, 0x63, 0x91, 0x1b, 0xbd, 0xd1, 0xff, 0x7f, 0xdd, 0xfc, 0xed, 0xe1, 0x7a, 0x11, + 0x43, 0x74, 0x73, 0x96, 0x66, 0xf2, 0x6e, 0x3e, 0xc1, 0xb1, 0xc8, 0x89, 0xc9, 0x9a, 0x5f, 0xec, + 0x6e, 0x3f, 0x08, 0x07, 0xe3, 0xd1, 0x9b, 0xbd, 0x75, 0x39, 0x81, 0x0a, 0x0a, 0xf1, 0xa0, 0x0d, + 0x1a, 0xeb, 0x41, 0xa3, 0x0d, 0xff, 0xb9, 0x85, 0x45, 0x0a, 0x8b, 0xc2, 0xa8, 0xc5, 0x22, 0x1d, + 0x8b, 0x1a, 0xac, 0xb2, 0xcf, 0x4d, 0xb0, 0xe8, 0x62, 0xe8, 0x07, 0x5c, 0xb2, 0x84, 0x49, 0xf6, + 0x6b, 0x9f, 0x68, 0x0a, 0x4a, 0x95, 0x83, 0xd2, 0x90, 0xd2, 0xd6, 0x42, 0xa9, 0xae, 0xa1, 0xb4, + 0xf1, 0x4c, 0xba, 0x9b, 0x43, 0x3a, 0xfc, 0x0b, 0x00, 0x00, 0xff, 0xff, 0x34, 0x96, 0x21, 0xc8, + 0x72, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/identities/transactions/revoke/service.pb.gw.go b/x/identities/transactions/revoke/service.pb.gw.go deleted file mode 100644 index 719cb6b46..000000000 --- a/x/identities/transactions/revoke/service.pb.gw.go +++ /dev/null @@ -1,171 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: AssetMantle/modules/x/identities/transactions/revoke/service.proto - -/* -Package revoke is a reverse proxy. - -It translates gRPC into RESTful JSON APIs. -*/ -package revoke - -import ( - "context" - "io" - "net/http" - - "github.com/golang/protobuf/descriptor" - "github.com/golang/protobuf/proto" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/grpc-ecosystem/grpc-gateway/utilities" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/status" -) - -// Suppress "imported and not used" errors -var _ codes.Code -var _ io.Reader -var _ status.Status -var _ = runtime.String -var _ = utilities.NewDoubleArray -var _ = descriptor.ForMessage -var _ = metadata.Join - -var ( - filter_Msg_Handle_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - -func request_Msg_Handle_0(ctx context.Context, marshaler runtime.Marshaler, client MsgClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq Message - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.Handle(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Msg_Handle_0(ctx context.Context, marshaler runtime.Marshaler, server MsgServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq Message - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.Handle(ctx, &protoReq) - return msg, metadata, err - -} - -// RegisterMsgHandlerServer registers the http handlers for service Msg to "mux". -// UnaryRPC :call MsgServer directly. -// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterMsgHandlerFromEndpoint instead. -func RegisterMsgHandlerServer(ctx context.Context, mux *runtime.ServeMux, server MsgServer) error { - - mux.Handle("POST", pattern_Msg_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Msg_Handle_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Msg_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -// RegisterMsgHandlerFromEndpoint is same as RegisterMsgHandler but -// automatically dials to "endpoint" and closes the connection when "ctx" gets done. -func RegisterMsgHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.Dial(endpoint, opts...) - if err != nil { - return err - } - defer func() { - if err != nil { - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - return - } - go func() { - <-ctx.Done() - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - }() - }() - - return RegisterMsgHandler(ctx, mux, conn) -} - -// RegisterMsgHandler registers the http handlers for service Msg to "mux". -// The handlers forward requests to the grpc endpoint over "conn". -func RegisterMsgHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { - return RegisterMsgHandlerClient(ctx, mux, NewMsgClient(conn)) -} - -// RegisterMsgHandlerClient registers the http handlers for service Msg -// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "MsgClient". -// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "MsgClient" -// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "MsgClient" to call the correct interceptors. -func RegisterMsgHandlerClient(ctx context.Context, mux *runtime.ServeMux, client MsgClient) error { - - mux.Handle("POST", pattern_Msg_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Msg_Handle_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Msg_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -var ( - pattern_Msg_Handle_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"mantle", "identities", "revoke"}, "", runtime.AssumeColonVerbOpt(false))) -) - -var ( - forward_Msg_Handle_0 = runtime.ForwardResponseMessage -) diff --git a/x/identities/transactions/revoke/transaction.go b/x/identities/transactions/revoke/transaction.go index c32599e72..0e9712af4 100644 --- a/x/identities/transactions/revoke/transaction.go +++ b/x/identities/transactions/revoke/transaction.go @@ -4,22 +4,14 @@ package revoke import ( - "context" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "google.golang.org/grpc" - "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/helpers/constants" - "github.com/AssetMantle/modules/utilities/name" + "google.golang.org/grpc" ) -type dummy struct{} - var Transaction = baseHelpers.NewTransaction( - name.GetPackageName(dummy{}), + _Msg_serviceDesc.ServiceName, "", "", @@ -30,9 +22,6 @@ var Transaction = baseHelpers.NewTransaction( func(server grpc.ServiceRegistrar, keeper helpers.TransactionKeeper) { RegisterMsgServer(server, keeper.(transactionKeeper)) }, - func(clientCtx client.Context, mux *runtime.ServeMux) error { - return RegisterMsgHandlerClient(context.Background(), mux, NewMsgClient(clientCtx)) - }, constants.FromIdentityID, constants.ToIdentityID, diff --git a/x/identities/transactions/revoke/transaction_keeper.go b/x/identities/transactions/revoke/transaction_keeper.go index 4165cca5c..b5b81afd0 100644 --- a/x/identities/transactions/revoke/transaction_keeper.go +++ b/x/identities/transactions/revoke/transaction_keeper.go @@ -5,9 +5,8 @@ package revoke import ( "context" - errorConstants "github.com/AssetMantle/modules/helpers/constants" - "github.com/AssetMantle/modules/helpers" + errorConstants "github.com/AssetMantle/modules/helpers/constants" "github.com/AssetMantle/modules/x/identities/key" "github.com/AssetMantle/modules/x/identities/mappable" "github.com/AssetMantle/modules/x/maintainers/auxiliaries/revoke" @@ -26,7 +25,7 @@ func (transactionKeeper transactionKeeper) Transact(context context.Context, mes } func (transactionKeeper transactionKeeper) Handle(context context.Context, message *Message) (*TransactionResponse, error) { - fromAddress := message.GetFromAddress() + fromAddress := message.GetSigners()[0] if Mappable := transactionKeeper.mapper.NewCollection(context).Fetch(key.NewKey(message.FromID)).GetMappable(key.NewKey(message.FromID)); Mappable == nil { return nil, errorConstants.EntityNotFound.Wrapf("identity with ID %s not found", message.FromID.AsString()) diff --git a/x/identities/transactions/revoke/transaction_request.go b/x/identities/transactions/revoke/transaction_request.go index 390655ff7..2e93f9030 100644 --- a/x/identities/transactions/revoke/transaction_request.go +++ b/x/identities/transactions/revoke/transaction_request.go @@ -5,24 +5,22 @@ package revoke import ( "encoding/json" - "github.com/AssetMantle/modules/utilities/rest" - - codecUtilities "github.com/AssetMantle/schema/codec/utilities" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" + "io" + "net/http" "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/helpers/constants" ) type transactionRequest struct { - BaseReq rest.BaseReq `json:"baseReq"` - FromID string `json:"fromID"` - ToID string `json:"toID"` - ClassificationID string `json:"classificationID"` + helpers.CommonTransactionRequest `json:"commonTransactionRequest"` + FromID string `json:"fromID"` + ToID string `json:"toID"` + ClassificationID string `json:"classificationID"` } var _ helpers.TransactionRequest = (*transactionRequest)(nil) @@ -48,24 +46,29 @@ func (transactionRequest transactionRequest) Validate() error { } func (transactionRequest transactionRequest) FromCLI(cliCommand helpers.CLICommand, context client.Context) (helpers.TransactionRequest, error) { return newTransactionRequest( - cliCommand.ReadBaseReq(context), + cliCommand.ReadCommonTransactionRequest(context), cliCommand.ReadString(constants.FromIdentityID), cliCommand.ReadString(constants.ToIdentityID), cliCommand.ReadString(constants.ClassificationID), ), nil } -func (transactionRequest transactionRequest) FromJSON(rawMessage json.RawMessage) (helpers.TransactionRequest, error) { - if err := json.Unmarshal(rawMessage, &transactionRequest); err != nil { +func (transactionRequest transactionRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.TransactionRequest, error) { + body, err := io.ReadAll(httpRequest.Body) + if err != nil { + return nil, err + } + + if err := json.Unmarshal(body, &transactionRequest); err != nil { return nil, err } return transactionRequest, nil } -func (transactionRequest transactionRequest) GetBaseReq() rest.BaseReq { - return transactionRequest.BaseReq +func (transactionRequest transactionRequest) GetCommonTransactionRequest() helpers.CommonTransactionRequest { + return transactionRequest.CommonTransactionRequest } func (transactionRequest transactionRequest) MakeMsg() (sdkTypes.Msg, error) { - from, err := sdkTypes.AccAddressFromBech32(transactionRequest.GetBaseReq().From) + from, err := sdkTypes.AccAddressFromBech32(transactionRequest.GetCommonTransactionRequest().GetFrom()) if err != nil { return nil, err } @@ -91,17 +94,14 @@ func (transactionRequest transactionRequest) MakeMsg() (sdkTypes.Msg, error) { classificationID.(ids.ClassificationID), ), nil } -func (transactionRequest) RegisterLegacyAminoCodec(legacyAmino *codec.LegacyAmino) { - codecUtilities.RegisterModuleConcrete(legacyAmino, transactionRequest{}) -} func requestPrototype() helpers.TransactionRequest { return transactionRequest{} } -func newTransactionRequest(baseReq rest.BaseReq, fromID string, toID string, classificationID string) helpers.TransactionRequest { +func newTransactionRequest(commonTransactionRequest helpers.CommonTransactionRequest, fromID string, toID string, classificationID string) helpers.TransactionRequest { return transactionRequest{ - BaseReq: baseReq, - FromID: fromID, - ToID: toID, - ClassificationID: classificationID, + CommonTransactionRequest: commonTransactionRequest, + FromID: fromID, + ToID: toID, + ClassificationID: classificationID, } } diff --git a/x/identities/transactions/revoke/transaction_request_test.go b/x/identities/transactions/revoke/transaction_request_test.go index 1384288f1..11b89486b 100644 --- a/x/identities/transactions/revoke/transaction_request_test.go +++ b/x/identities/transactions/revoke/transaction_request_test.go @@ -4,9 +4,7 @@ package revoke import ( - "encoding/json" "fmt" - "github.com/AssetMantle/modules/utilities/rest" "reflect" "testing" @@ -16,7 +14,6 @@ import ( baseProperties "github.com/AssetMantle/schema/properties/base" baseQualified "github.com/AssetMantle/schema/qualified/base" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" @@ -26,25 +23,25 @@ import ( "github.com/AssetMantle/modules/helpers/constants" ) -func createTestInput(t *testing.T) (rest.BaseReq, string, *baseIDs.IdentityID, *baseIDs.IdentityID, *baseIDs.ClassificationID) { +func createTestInput(t *testing.T) (helpers.CommonTransactionRequest, string, *baseIDs.IdentityID, *baseIDs.IdentityID, *baseIDs.ClassificationID) { immutables := baseQualified.NewImmutables(baseLists.NewPropertyList(baseProperties.NewMesaProperty(baseIDs.NewStringID("ID2"), baseData.NewStringData("Data2")))) mutables := baseQualified.NewMutables(baseLists.NewPropertyList(baseProperties.NewMesaProperty(baseIDs.NewStringID("ID1"), baseData.NewStringData("Data1")))) testClassificationID := baseIDs.NewClassificationID(immutables, mutables) testFromID := baseIDs.NewIdentityID(testClassificationID, immutables) testToID := baseIDs.NewIdentityID(testClassificationID, immutables) fromAddress := "cosmos1pkkayn066msg6kn33wnl5srhdt3tnu2vzasz9c" - testBaseReq := rest.BaseReq{From: fromAddress, ChainID: "test", Fees: sdkTypes.NewCoins()} + commonTransactionRequest := helpers.PrototypeCommonTransactionRequest().SetFrom(fromAddress) testToAddress := "cosmos1vx8knpllrj7n963p9ttd80w47kpacrhuts497x" - return testBaseReq, testToAddress, testFromID.(*baseIDs.IdentityID), testToID.(*baseIDs.IdentityID), testClassificationID.(*baseIDs.ClassificationID) + return commonTransactionRequest, testToAddress, testFromID.(*baseIDs.IdentityID), testToID.(*baseIDs.IdentityID), testClassificationID.(*baseIDs.ClassificationID) } func Test_newTransactionRequest(t *testing.T) { - testBaseReq, _, testFromID, testToID, testClassificationID := createTestInput(t) + commonTransactionRequest, _, testFromID, testToID, testClassificationID := createTestInput(t) type args struct { - baseReq rest.BaseReq - fromID string - toID string - classificationID string + commonTransactionRequest helpers.CommonTransactionRequest + fromID string + toID string + classificationID string } tests := []struct { name string @@ -52,11 +49,11 @@ func Test_newTransactionRequest(t *testing.T) { want helpers.TransactionRequest }{ {"+ve with nil", args{}, transactionRequest{}}, - {"+ve", args{testBaseReq, testFromID.AsString(), testToID.AsString(), testClassificationID.AsString()}, transactionRequest{testBaseReq, testFromID.AsString(), testToID.AsString(), testClassificationID.AsString()}}, + {"+ve", args{commonTransactionRequest, testFromID.AsString(), testToID.AsString(), testClassificationID.AsString()}, transactionRequest{commonTransactionRequest, testFromID.AsString(), testToID.AsString(), testClassificationID.AsString()}}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - if got := newTransactionRequest(tt.args.baseReq, tt.args.fromID, tt.args.toID, tt.args.classificationID); !reflect.DeepEqual(got, tt.want) { + if got := newTransactionRequest(tt.args.commonTransactionRequest, tt.args.fromID, tt.args.toID, tt.args.classificationID); !reflect.DeepEqual(got, tt.want) { t.Errorf("newTransactionRequest() = %v, want %v", got, tt.want) } }) @@ -82,12 +79,12 @@ func Test_requestPrototype(t *testing.T) { func Test_transactionRequest_FromCLI(t *testing.T) { cliCommand := baseHelpers.NewCLICommand("", "", "", []helpers.CLIFlag{constants.FromIdentityID, constants.ToIdentityID, constants.ClassificationID}) - testBaseReq, _, testFromID, testToID, testClassificationID := createTestInput(t) + commonTransactionRequest, _, testFromID, testToID, testClassificationID := createTestInput(t) type fields struct { - BaseReq rest.BaseReq - FromID string - ToID string - ClassificationID string + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + ToID string + ClassificationID string } type args struct { cliCommand helpers.CLICommand @@ -100,15 +97,15 @@ func Test_transactionRequest_FromCLI(t *testing.T) { want helpers.TransactionRequest wantErr bool }{ - {"+ve", fields{testBaseReq, testFromID.AsString(), testToID.AsString(), testClassificationID.AsString()}, args{cliCommand, client.Context{}.WithCodec(baseHelpers.CodecPrototype())}, transactionRequest{cliCommand.ReadBaseReq(client.Context{}.WithCodec(baseHelpers.CodecPrototype())), cliCommand.ReadString(constants.FromIdentityID), cliCommand.ReadString(constants.ToIdentityID), cliCommand.ReadString(constants.ClassificationID)}, false}, + {"+ve", fields{commonTransactionRequest, testFromID.AsString(), testToID.AsString(), testClassificationID.AsString()}, args{cliCommand, client.Context{}.WithCodec(baseHelpers.CodecPrototype())}, transactionRequest{cliCommand.ReadCommonTransactionRequest(client.Context{}.WithCodec(baseHelpers.CodecPrototype())), cliCommand.ReadString(constants.FromIdentityID), cliCommand.ReadString(constants.ToIdentityID), cliCommand.ReadString(constants.ClassificationID)}, false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - ToID: tt.fields.ToID, - ClassificationID: tt.fields.ClassificationID, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + ToID: tt.fields.ToID, + ClassificationID: tt.fields.ClassificationID, } got, err := transactionRequest.FromCLI(tt.args.cliCommand, tt.args.context) if (err != nil) != tt.wantErr { @@ -122,87 +119,45 @@ func Test_transactionRequest_FromCLI(t *testing.T) { } } -func Test_transactionRequest_FromJSON(t *testing.T) { - testBaseReq, fromAddress, testFromID, testToID, testClassificationID := createTestInput(t) - fromAccAddress, err := sdkTypes.AccAddressFromBech32(fromAddress) - require.Nil(t, err) - type fields struct { - BaseReq rest.BaseReq - FromID string - ToID string - ClassificationID string - } - type args struct { - rawMessage json.RawMessage - } - tests := []struct { - name string - fields fields - args args - want helpers.TransactionRequest - wantErr bool - }{ - {"+ve", fields{testBaseReq, testFromID.AsString(), testToID.AsString(), testClassificationID.AsString()}, args{sdkTypes.MustSortJSON(baseHelpers.CodecPrototype().MustMarshalJSON(&Message{fromAccAddress.String(), testFromID, testToID, testClassificationID}))}, transactionRequest{testBaseReq, testFromID.AsString(), testToID.AsString(), testClassificationID.AsString()}, false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - ToID: tt.fields.ToID, - ClassificationID: tt.fields.ClassificationID, - } - got, err := transactionRequest.FromJSON(tt.args.rawMessage) - if (err != nil) != tt.wantErr { - t.Errorf("FromJSON() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("FromJSON() got = %v, want %v", got, tt.want) - } - }) - } -} - func Test_transactionRequest_GetBaseReq(t *testing.T) { - testBaseReq, _, testFromID, testToID, testClassificationID := createTestInput(t) + commonTransactionRequest, _, testFromID, testToID, testClassificationID := createTestInput(t) type fields struct { - BaseReq rest.BaseReq - FromID string - ToID string - ClassificationID string + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + ToID string + ClassificationID string } tests := []struct { name string fields fields - want rest.BaseReq + want helpers.CommonTransactionRequest }{ - {"+ve", fields{testBaseReq, testFromID.AsString(), testToID.AsString(), testClassificationID.AsString()}, testBaseReq}, + {"+ve", fields{commonTransactionRequest, testFromID.AsString(), testToID.AsString(), testClassificationID.AsString()}, commonTransactionRequest}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - ToID: tt.fields.ToID, - ClassificationID: tt.fields.ClassificationID, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + ToID: tt.fields.ToID, + ClassificationID: tt.fields.ClassificationID, } - if got := transactionRequest.GetBaseReq(); !reflect.DeepEqual(got, tt.want) { - t.Errorf("GetBaseReq() = %v, want %v", got, tt.want) + if got := transactionRequest.GetCommonTransactionRequest(); !reflect.DeepEqual(got, tt.want) { + t.Errorf("GetCommonTransactionRequest() = %v, want %v", got, tt.want) } }) } } func Test_transactionRequest_MakeMsg(t *testing.T) { - testBaseReq, fromAccAddress, testFromID, testToID, testClassificationID := createTestInput(t) + commonTransactionRequest, fromAccAddress, testFromID, testToID, testClassificationID := createTestInput(t) testFromAccAddress, err := sdkTypes.AccAddressFromBech32(fromAccAddress) require.Nil(t, err) type fields struct { - BaseReq rest.BaseReq - FromID string - ToID string - ClassificationID string + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + ToID string + ClassificationID string } tests := []struct { name string @@ -211,15 +166,15 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { wantErr bool }{ // TODO: Type & Data same but Not matching - {"+ve", fields{testBaseReq, testFromID.AsString(), testToID.AsString(), testClassificationID.AsString()}, &Message{testFromAccAddress.String(), testFromID, testToID, testClassificationID}, false}, + {"+ve", fields{commonTransactionRequest, testFromID.AsString(), testToID.AsString(), testClassificationID.AsString()}, &Message{testFromAccAddress.String(), testFromID, testToID, testClassificationID}, false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - ToID: tt.fields.ToID, - ClassificationID: tt.fields.ClassificationID, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + ToID: tt.fields.ToID, + ClassificationID: tt.fields.ClassificationID, } got, err := transactionRequest.MakeMsg() if (err != nil) != tt.wantErr { @@ -233,45 +188,13 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { } } -func Test_transactionRequest_RegisterCodec(t *testing.T) { - testBaseReq, _, testFromID, testToID, testClassificationID := createTestInput(t) - type fields struct { - BaseReq rest.BaseReq - FromID string - ToID string - ClassificationID string - } - type args struct { - legacyAmino *codec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve with nil", fields{}, args{codec.NewLegacyAmino()}}, - {"+ve", fields{testBaseReq, testFromID.AsString(), testToID.AsString(), testClassificationID.AsString()}, args{codec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - tr := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - ToID: tt.fields.ToID, - ClassificationID: tt.fields.ClassificationID, - } - tr.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - func Test_transactionRequest_Validate(t *testing.T) { - testBaseReq, _, testFromID, testToID, testClassificationID := createTestInput(t) + commonTransactionRequest, _, testFromID, testToID, testClassificationID := createTestInput(t) type fields struct { - BaseReq rest.BaseReq - FromID string - ToID string - ClassificationID string + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + ToID string + ClassificationID string } tests := []struct { name string @@ -279,15 +202,15 @@ func Test_transactionRequest_Validate(t *testing.T) { wantErr bool }{ {"+ve with nil", fields{}, true}, - {"+ve", fields{testBaseReq, testFromID.AsString(), testToID.AsString(), testClassificationID.AsString()}, false}, + {"+ve", fields{commonTransactionRequest, testFromID.AsString(), testToID.AsString(), testClassificationID.AsString()}, false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - ToID: tt.fields.ToID, - ClassificationID: tt.fields.ClassificationID, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + ToID: tt.fields.ToID, + ClassificationID: tt.fields.ClassificationID, } if err := transactionRequest.Validate(); (err != nil) != tt.wantErr { t.Errorf("ValidateBasic() error = %v, wantErr %v", err, tt.wantErr) diff --git a/x/identities/transactions/revoke/transaction_response.go b/x/identities/transactions/revoke/transaction_response.go index 53eebfc72..272941180 100644 --- a/x/identities/transactions/revoke/transaction_response.go +++ b/x/identities/transactions/revoke/transaction_response.go @@ -4,9 +4,8 @@ package revoke import ( - sdkTypes "github.com/cosmos/cosmos-sdk/types" - "github.com/AssetMantle/modules/helpers" + sdkTypes "github.com/cosmos/cosmos-sdk/types" ) var _ helpers.TransactionResponse = (*TransactionResponse)(nil) diff --git a/x/identities/transactions/unprovision/message.go b/x/identities/transactions/unprovision/message.go index f05d2b67c..55ce8f296 100644 --- a/x/identities/transactions/unprovision/message.go +++ b/x/identities/transactions/unprovision/message.go @@ -4,26 +4,15 @@ package unprovision import ( - codecUtilities "github.com/AssetMantle/schema/codec/utilities" + "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/types" sdkTypes "github.com/cosmos/cosmos-sdk/types" - - "github.com/AssetMantle/modules/helpers" ) var _ helpers.Message = (*Message)(nil) -func (message *Message) Type() string { return Transaction.GetName() } -func (message *Message) GetFromAddress() sdkTypes.AccAddress { - from, err := sdkTypes.AccAddressFromBech32(message.From) - if err != nil { - panic(err) - } - return from -} func (message *Message) ValidateBasic() error { if _, err := sdkTypes.AccAddressFromBech32(message.From); err != nil { return err @@ -43,21 +32,10 @@ func (message *Message) GetSigners() []sdkTypes.AccAddress { } return []sdkTypes.AccAddress{from} } -func (*Message) RegisterLegacyAminoCodec(legacyAmino *codec.LegacyAmino) { - codecUtilities.RegisterModuleConcrete(legacyAmino, Message{}) -} func (message *Message) RegisterInterface(interfaceRegistry types.InterfaceRegistry) { interfaceRegistry.RegisterImplementations((*sdkTypes.Msg)(nil), message) } -func messageFromInterface(msg sdkTypes.Msg) *Message { - switch value := msg.(type) { - case *Message: - return value - default: - return &Message{} - } -} func messagePrototype() helpers.Message { return &Message{} } diff --git a/x/identities/transactions/unprovision/message_test.go b/x/identities/transactions/unprovision/message_test.go index 7d1d2b148..799534803 100644 --- a/x/identities/transactions/unprovision/message_test.go +++ b/x/identities/transactions/unprovision/message_test.go @@ -13,7 +13,6 @@ import ( baseLists "github.com/AssetMantle/schema/lists/base" baseProperties "github.com/AssetMantle/schema/properties/base" baseQualified "github.com/AssetMantle/schema/qualified/base" - "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" @@ -44,27 +43,6 @@ func CreateTestInputForMessage(t *testing.T) (*baseIDs.IdentityID, sdkTypes.AccA return testIdentityID.(*baseIDs.IdentityID), fromAccAddress, toAccAddress, testMessage } -func Test_messageFromInterface(t *testing.T) { - testIdentityID, fromAccAddress, toAccAddress, testMessage := CreateTestInputForMessage(t) - type args struct { - msg sdkTypes.Msg - } - tests := []struct { - name string - args args - want *Message - }{ - {"+ve", args{testMessage}, &Message{fromAccAddress.String(), toAccAddress.String(), testIdentityID}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := messageFromInterface(tt.args.msg); !reflect.DeepEqual(got, tt.want) { - t.Errorf("messageFromInterface() = %v, want %v", got, tt.want) - } - }) - } -} - func Test_messagePrototype(t *testing.T) { tests := []struct { name string @@ -105,55 +83,6 @@ func Test_message_GetSigners(t *testing.T) { } } -func Test_message_RegisterCodec(t *testing.T) { - testIdentityID, fromAccAddress, toAccAddress, _ := CreateTestInputForMessage(t) - - type args struct { - legacyAmino *codec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{fromAccAddress.String(), toAccAddress.String(), testIdentityID}, args{codec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - me := &Message{ - From: tt.fields.From, - To: tt.fields.To, - IdentityID: tt.fields.IdentityID, - } - me.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - -func Test_message_Type(t *testing.T) { - testIdentityID, fromAccAddress, toAccAddress, _ := CreateTestInputForMessage(t) - - tests := []struct { - name string - fields fields - want string - }{ - {"+ve", fields{fromAccAddress.String(), toAccAddress.String(), testIdentityID}, Transaction.GetName()}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - message := &Message{ - From: tt.fields.From, - To: tt.fields.To, - IdentityID: tt.fields.IdentityID, - } - if got := message.Type(); got != tt.want { - t.Errorf("Type() = %v, want %v", got, tt.want) - } - }) - } -} - func Test_message_ValidateBasic(t *testing.T) { testIdentityID, fromAccAddress, toAccAddress, _ := CreateTestInputForMessage(t) diff --git a/x/identities/transactions/unprovision/service.pb.go b/x/identities/transactions/unprovision/service.pb.go index ac320fe28..37020c1e8 100644 --- a/x/identities/transactions/unprovision/service.pb.go +++ b/x/identities/transactions/unprovision/service.pb.go @@ -6,9 +6,9 @@ package unprovision import ( context "context" fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types/msgservice" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" - _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -31,31 +31,30 @@ func init() { } var fileDescriptor_cb37a005e91ee120 = []byte{ - // 371 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0xd2, 0xb1, 0x4a, 0xfb, 0x40, - 0x1c, 0x07, 0xf0, 0x26, 0x85, 0x0e, 0xe1, 0x3f, 0x75, 0x0c, 0x7f, 0x0e, 0xe9, 0xe0, 0x78, 0x07, - 0x3a, 0x79, 0xa0, 0xd0, 0xa0, 0xd4, 0x0e, 0x91, 0xa2, 0x29, 0x04, 0x09, 0xc8, 0x35, 0x39, 0xe2, - 0x41, 0x72, 0x17, 0x72, 0xd7, 0xd2, 0xd9, 0x27, 0x10, 0x7c, 0x03, 0x47, 0x5f, 0xc0, 0x17, 0x70, - 0x10, 0x71, 0x28, 0xb8, 0x38, 0x4a, 0xea, 0xe4, 0x53, 0x88, 0xcd, 0x41, 0xae, 0x6b, 0x3a, 0xff, - 0xf2, 0xfd, 0xf0, 0xcd, 0xef, 0x7e, 0xce, 0x68, 0x28, 0x25, 0x55, 0x3e, 0xe1, 0x2a, 0xa3, 0x28, - 0x17, 0xc9, 0x3c, 0xa3, 0x12, 0x2d, 0x11, 0x4b, 0x28, 0x57, 0x4c, 0x31, 0x2a, 0x91, 0x2a, 0x09, - 0x97, 0x24, 0x56, 0x4c, 0x70, 0x89, 0xe6, 0xbc, 0x28, 0xc5, 0x82, 0x49, 0x26, 0x38, 0x92, 0xb4, - 0x5c, 0xb0, 0x98, 0xc2, 0xa2, 0x14, 0x4a, 0xf4, 0x8f, 0x0c, 0x08, 0x6a, 0x08, 0x2e, 0x61, 0x03, - 0x41, 0x13, 0x82, 0x06, 0xe4, 0xfe, 0x4f, 0x85, 0x48, 0x33, 0x8a, 0x48, 0xc1, 0x10, 0xe1, 0x5c, - 0x28, 0x52, 0x7f, 0xb3, 0x81, 0xdd, 0x1d, 0x1a, 0xe6, 0x54, 0x4a, 0x92, 0xea, 0x86, 0x6e, 0xd0, - 0x1e, 0x32, 0x06, 0x37, 0x25, 0x95, 0x85, 0xe0, 0x52, 0xab, 0x07, 0xef, 0x96, 0xd3, 0xf5, 0x65, - 0xda, 0x7f, 0xb1, 0x9c, 0xde, 0x39, 0xe1, 0x49, 0x46, 0xfb, 0x1e, 0x6c, 0xbd, 0x0b, 0xe8, 0xd7, - 0x95, 0xdd, 0x8b, 0x1d, 0x8c, 0xa0, 0x19, 0x5c, 0xea, 0xb2, 0x83, 0xfd, 0xbb, 0x8f, 0xef, 0x07, - 0x7b, 0x6f, 0x00, 0x50, 0x5e, 0x2f, 0xc0, 0xf8, 0x6d, 0x23, 0xeb, 0x3d, 0x77, 0x5f, 0x2b, 0x60, - 0xad, 0x2a, 0x60, 0x7d, 0x55, 0xc0, 0xba, 0x5f, 0x83, 0xce, 0x6a, 0x0d, 0x3a, 0x9f, 0x6b, 0xd0, - 0x71, 0x8e, 0x63, 0x91, 0xb7, 0x6f, 0xe5, 0xfd, 0xbb, 0xaa, 0xef, 0x65, 0xf2, 0xb7, 0xb6, 0x89, - 0x75, 0x7d, 0x9a, 0x32, 0x75, 0x3b, 0x9f, 0xc1, 0x58, 0xe4, 0xa8, 0xf5, 0xcb, 0x3c, 0xda, 0xbd, - 0xa1, 0x1f, 0x8e, 0x83, 0xe9, 0x93, 0xbd, 0x75, 0x80, 0xbe, 0xae, 0x16, 0xc2, 0x71, 0x53, 0x2d, - 0x30, 0xab, 0x4d, 0x1b, 0xe4, 0x6d, 0x2b, 0x1b, 0xe9, 0x6c, 0x14, 0x46, 0x4d, 0x36, 0x32, 0xb3, - 0x91, 0x91, 0xad, 0xec, 0xb3, 0xd6, 0xd9, 0x68, 0x34, 0xf1, 0x7c, 0xaa, 0x48, 0x42, 0x14, 0xf9, - 0xb1, 0x4f, 0x0c, 0x07, 0x63, 0x0d, 0x61, 0x1c, 0x62, 0xdc, 0x50, 0x18, 0x9b, 0x16, 0xc6, 0x06, - 0x36, 0xeb, 0x6d, 0xee, 0xf1, 0xf0, 0x37, 0x00, 0x00, 0xff, 0xff, 0x17, 0x9e, 0x8e, 0x0d, 0xd2, - 0x03, 0x00, 0x00, + // 359 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0xd2, 0xb1, 0x4a, 0xc3, 0x40, + 0x18, 0x07, 0xf0, 0x24, 0xc5, 0x0e, 0xc1, 0xa9, 0x8b, 0x90, 0x21, 0x83, 0xa3, 0xc3, 0x1d, 0xea, + 0xe4, 0x81, 0x42, 0x83, 0x52, 0x3b, 0x44, 0x8a, 0xa6, 0x10, 0x24, 0x20, 0xd7, 0xe4, 0x88, 0x07, + 0xcd, 0x5d, 0xc9, 0x77, 0x2d, 0x1d, 0x7d, 0x04, 0x9f, 0xc0, 0xc1, 0x51, 0x10, 0xdc, 0x7c, 0x05, + 0x71, 0xea, 0xe8, 0x28, 0xe9, 0x20, 0xf8, 0x14, 0x52, 0x7b, 0x90, 0xeb, 0x9a, 0x4e, 0x37, 0x7c, + 0xfc, 0x7f, 0xf7, 0xe7, 0xe3, 0x73, 0x7b, 0x5d, 0x00, 0xa6, 0x42, 0x2a, 0xd4, 0x98, 0xe1, 0x42, + 0x66, 0xd3, 0x31, 0x03, 0x3c, 0xc7, 0x3c, 0x63, 0x42, 0x71, 0xc5, 0x19, 0x60, 0x55, 0x52, 0x01, + 0x34, 0x55, 0x5c, 0x0a, 0xc0, 0x53, 0x31, 0x29, 0xe5, 0x8c, 0x03, 0x97, 0x02, 0x03, 0x2b, 0x67, + 0x3c, 0x65, 0x68, 0x52, 0x4a, 0x25, 0x3b, 0x27, 0x06, 0x84, 0x34, 0x84, 0xe6, 0xa8, 0x86, 0x90, + 0x09, 0x21, 0x03, 0xf2, 0xf6, 0x52, 0x09, 0x85, 0x04, 0x5c, 0x40, 0x8e, 0x67, 0x87, 0xab, 0x67, + 0x6d, 0x7a, 0x5b, 0x94, 0x2b, 0x18, 0x00, 0xcd, 0x75, 0x39, 0x2f, 0x6a, 0x0e, 0x19, 0x83, 0xbb, + 0x92, 0xc1, 0x44, 0x0a, 0xd0, 0xea, 0xd1, 0xab, 0xed, 0xb6, 0x42, 0xc8, 0x3b, 0x4f, 0xb6, 0xdb, + 0xbe, 0xa4, 0x22, 0x1b, 0xb3, 0x4e, 0x80, 0x1a, 0xaf, 0x01, 0x85, 0xeb, 0xca, 0xde, 0xd5, 0x16, + 0x46, 0x54, 0x0f, 0xae, 0x75, 0xd9, 0x7d, 0xcb, 0xdb, 0x79, 0xf8, 0x79, 0x3b, 0xb0, 0x83, 0xf7, + 0xd6, 0x47, 0xe5, 0xdb, 0x8b, 0xca, 0xb7, 0xbf, 0x2b, 0xdf, 0x7e, 0x5c, 0xfa, 0xd6, 0x62, 0xe9, + 0x5b, 0x5f, 0x4b, 0xdf, 0x72, 0x4f, 0x53, 0x59, 0x34, 0xff, 0x36, 0xd8, 0xbd, 0x59, 0xdf, 0xc2, + 0x60, 0xb5, 0x97, 0x81, 0x7d, 0x7b, 0x9e, 0x73, 0x75, 0x3f, 0x1d, 0xa1, 0x54, 0x16, 0xb8, 0xf1, + 0xea, 0x9f, 0x9d, 0x76, 0x37, 0x8c, 0xfb, 0xd1, 0xf0, 0xc5, 0xd9, 0x38, 0xae, 0x50, 0x57, 0x8b, + 0x51, 0xbf, 0xae, 0x16, 0x99, 0xd5, 0x86, 0x35, 0xf2, 0xb9, 0x91, 0x4d, 0x74, 0x36, 0x89, 0x93, + 0x3a, 0x9b, 0x98, 0xd9, 0xc4, 0xc8, 0x56, 0xce, 0x45, 0xe3, 0x6c, 0xd2, 0x1b, 0x04, 0x21, 0x53, + 0x34, 0xa3, 0x8a, 0xfe, 0x3a, 0x67, 0x86, 0x43, 0x88, 0x86, 0x08, 0x89, 0x09, 0xa9, 0x29, 0x42, + 0x4c, 0x8b, 0x10, 0x03, 0x1b, 0xb5, 0xff, 0x0f, 0xee, 0xf8, 0x2f, 0x00, 0x00, 0xff, 0xff, 0xfa, + 0x54, 0x02, 0x58, 0xae, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/identities/transactions/unprovision/service.pb.gw.go b/x/identities/transactions/unprovision/service.pb.gw.go deleted file mode 100644 index 56c2d6262..000000000 --- a/x/identities/transactions/unprovision/service.pb.gw.go +++ /dev/null @@ -1,171 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: AssetMantle/modules/x/identities/transactions/unprovision/service.proto - -/* -Package unprovision is a reverse proxy. - -It translates gRPC into RESTful JSON APIs. -*/ -package unprovision - -import ( - "context" - "io" - "net/http" - - "github.com/golang/protobuf/descriptor" - "github.com/golang/protobuf/proto" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/grpc-ecosystem/grpc-gateway/utilities" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/status" -) - -// Suppress "imported and not used" errors -var _ codes.Code -var _ io.Reader -var _ status.Status -var _ = runtime.String -var _ = utilities.NewDoubleArray -var _ = descriptor.ForMessage -var _ = metadata.Join - -var ( - filter_Msg_Handle_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - -func request_Msg_Handle_0(ctx context.Context, marshaler runtime.Marshaler, client MsgClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq Message - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.Handle(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Msg_Handle_0(ctx context.Context, marshaler runtime.Marshaler, server MsgServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq Message - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.Handle(ctx, &protoReq) - return msg, metadata, err - -} - -// RegisterMsgHandlerServer registers the http handlers for service Msg to "mux". -// UnaryRPC :call MsgServer directly. -// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterMsgHandlerFromEndpoint instead. -func RegisterMsgHandlerServer(ctx context.Context, mux *runtime.ServeMux, server MsgServer) error { - - mux.Handle("POST", pattern_Msg_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Msg_Handle_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Msg_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -// RegisterMsgHandlerFromEndpoint is same as RegisterMsgHandler but -// automatically dials to "endpoint" and closes the connection when "ctx" gets done. -func RegisterMsgHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.Dial(endpoint, opts...) - if err != nil { - return err - } - defer func() { - if err != nil { - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - return - } - go func() { - <-ctx.Done() - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - }() - }() - - return RegisterMsgHandler(ctx, mux, conn) -} - -// RegisterMsgHandler registers the http handlers for service Msg to "mux". -// The handlers forward requests to the grpc endpoint over "conn". -func RegisterMsgHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { - return RegisterMsgHandlerClient(ctx, mux, NewMsgClient(conn)) -} - -// RegisterMsgHandlerClient registers the http handlers for service Msg -// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "MsgClient". -// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "MsgClient" -// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "MsgClient" to call the correct interceptors. -func RegisterMsgHandlerClient(ctx context.Context, mux *runtime.ServeMux, client MsgClient) error { - - mux.Handle("POST", pattern_Msg_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Msg_Handle_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Msg_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -var ( - pattern_Msg_Handle_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"mantle", "identities", "unprovision"}, "", runtime.AssumeColonVerbOpt(false))) -) - -var ( - forward_Msg_Handle_0 = runtime.ForwardResponseMessage -) diff --git a/x/identities/transactions/unprovision/transaction.go b/x/identities/transactions/unprovision/transaction.go index 198474e64..da1a95139 100644 --- a/x/identities/transactions/unprovision/transaction.go +++ b/x/identities/transactions/unprovision/transaction.go @@ -4,22 +4,14 @@ package unprovision import ( - "context" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "google.golang.org/grpc" - "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/helpers/constants" - "github.com/AssetMantle/modules/utilities/name" + "google.golang.org/grpc" ) -type dummy struct{} - var Transaction = baseHelpers.NewTransaction( - name.GetPackageName(dummy{}), + _Msg_serviceDesc.ServiceName, "", "", @@ -30,9 +22,6 @@ var Transaction = baseHelpers.NewTransaction( func(server grpc.ServiceRegistrar, keeper helpers.TransactionKeeper) { RegisterMsgServer(server, keeper.(transactionKeeper)) }, - func(clientCtx client.Context, mux *runtime.ServeMux) error { - return RegisterMsgHandlerClient(context.Background(), mux, NewMsgClient(clientCtx)) - }, constants.To, constants.IdentityID, diff --git a/x/identities/transactions/unprovision/transaction_keeper.go b/x/identities/transactions/unprovision/transaction_keeper.go index d077a5353..c40872901 100644 --- a/x/identities/transactions/unprovision/transaction_keeper.go +++ b/x/identities/transactions/unprovision/transaction_keeper.go @@ -6,7 +6,6 @@ package unprovision import ( "context" errorConstants "github.com/AssetMantle/modules/helpers/constants" - sdkTypes "github.com/cosmos/cosmos-sdk/types" "github.com/AssetMantle/modules/helpers" @@ -37,7 +36,7 @@ func (transactionKeeper transactionKeeper) Handle(context context.Context, messa } identity := mappable.GetIdentity(Mappable) - fromAddress := message.GetFromAddress() + fromAddress := message.GetSigners()[0] toAddress, err := sdkTypes.AccAddressFromBech32(message.To) if err != nil { diff --git a/x/identities/transactions/unprovision/transaction_request.go b/x/identities/transactions/unprovision/transaction_request.go index 55969e685..f9e6caae5 100644 --- a/x/identities/transactions/unprovision/transaction_request.go +++ b/x/identities/transactions/unprovision/transaction_request.go @@ -5,23 +5,21 @@ package unprovision import ( "encoding/json" - "github.com/AssetMantle/modules/utilities/rest" - - codecUtilities "github.com/AssetMantle/schema/codec/utilities" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" + "io" + "net/http" "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/helpers/constants" ) type transactionRequest struct { - BaseReq rest.BaseReq `json:"baseReq"` - To string `json:"to"` - IdentityID string `json:"identityID"` + helpers.CommonTransactionRequest `json:"commonTransactionRequest"` + To string `json:"to"` + IdentityID string `json:"identityID"` } var _ helpers.TransactionRequest = (*transactionRequest)(nil) @@ -47,23 +45,28 @@ func (transactionRequest transactionRequest) Validate() error { } func (transactionRequest transactionRequest) FromCLI(cliCommand helpers.CLICommand, context client.Context) (helpers.TransactionRequest, error) { return newTransactionRequest( - cliCommand.ReadBaseReq(context), + cliCommand.ReadCommonTransactionRequest(context), cliCommand.ReadString(constants.To), cliCommand.ReadString(constants.IdentityID), ), nil } -func (transactionRequest transactionRequest) FromJSON(rawMessage json.RawMessage) (helpers.TransactionRequest, error) { - if err := json.Unmarshal(rawMessage, &transactionRequest); err != nil { +func (transactionRequest transactionRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.TransactionRequest, error) { + body, err := io.ReadAll(httpRequest.Body) + if err != nil { + return nil, err + } + + if err := json.Unmarshal(body, &transactionRequest); err != nil { return nil, err } return transactionRequest, nil } -func (transactionRequest transactionRequest) GetBaseReq() rest.BaseReq { - return transactionRequest.BaseReq +func (transactionRequest transactionRequest) GetCommonTransactionRequest() helpers.CommonTransactionRequest { + return transactionRequest.CommonTransactionRequest } func (transactionRequest transactionRequest) MakeMsg() (sdkTypes.Msg, error) { - from, err := sdkTypes.AccAddressFromBech32(transactionRequest.GetBaseReq().From) + from, err := sdkTypes.AccAddressFromBech32(transactionRequest.GetCommonTransactionRequest().GetFrom()) if err != nil { return nil, err } @@ -84,16 +87,13 @@ func (transactionRequest transactionRequest) MakeMsg() (sdkTypes.Msg, error) { identityID.(ids.IdentityID), ), nil } -func (transactionRequest) RegisterLegacyAminoCodec(legacyAmino *codec.LegacyAmino) { - codecUtilities.RegisterModuleConcrete(legacyAmino, transactionRequest{}) -} func requestPrototype() helpers.TransactionRequest { return transactionRequest{} } -func newTransactionRequest(baseReq rest.BaseReq, to string, identityID string) helpers.TransactionRequest { +func newTransactionRequest(commonTransactionRequest helpers.CommonTransactionRequest, to string, identityID string) helpers.TransactionRequest { return transactionRequest{ - BaseReq: baseReq, - To: to, - IdentityID: identityID, + CommonTransactionRequest: commonTransactionRequest, + To: to, + IdentityID: identityID, } } diff --git a/x/identities/transactions/unprovision/transaction_request_test.go b/x/identities/transactions/unprovision/transaction_request_test.go index f4f508ff3..dcd1b5671 100644 --- a/x/identities/transactions/unprovision/transaction_request_test.go +++ b/x/identities/transactions/unprovision/transaction_request_test.go @@ -4,8 +4,6 @@ package unprovision import ( - "encoding/json" - "github.com/AssetMantle/modules/utilities/rest" "reflect" "testing" @@ -15,7 +13,6 @@ import ( baseProperties "github.com/AssetMantle/schema/properties/base" baseQualified "github.com/AssetMantle/schema/qualified/base" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" @@ -25,7 +22,7 @@ import ( "github.com/AssetMantle/modules/helpers/constants" ) -func createInputForMessage(t *testing.T) (*baseIDs.IdentityID, string, types.AccAddress, types.Msg, rest.BaseReq) { +func createInputForMessage(t *testing.T) (*baseIDs.IdentityID, string, types.AccAddress, types.Msg, helpers.CommonTransactionRequest) { immutables := baseQualified.NewImmutables(baseLists.NewPropertyList(baseProperties.NewMesaProperty(baseIDs.NewStringID("ID2"), baseData.NewStringData("Data2")))) mutables := baseQualified.NewMutables(baseLists.NewPropertyList(baseProperties.NewMesaProperty(baseIDs.NewStringID("ID1"), baseData.NewStringData("Data1")))) testClassificationID := baseIDs.NewClassificationID(immutables, mutables) @@ -39,19 +36,19 @@ func createInputForMessage(t *testing.T) (*baseIDs.IdentityID, string, types.Acc toAccAddress, err := types.AccAddressFromBech32(toAddress) require.Nil(t, err) - testBaseReq := rest.BaseReq{From: fromAddress, ChainID: "test", Fees: types.NewCoins()} + commonTransactionRequest := helpers.PrototypeCommonTransactionRequest() testMessage := NewMessage(fromAccAddress, toAccAddress, testIdentityID) - return testIdentityID.(*baseIDs.IdentityID), toAddress, toAccAddress, testMessage, testBaseReq + return testIdentityID.(*baseIDs.IdentityID), toAddress, toAccAddress, testMessage, commonTransactionRequest } func Test_newTransactionRequest(t *testing.T) { - testIdentityID, toAddress, _, _, testBaseReq := createInputForMessage(t) + testIdentityID, toAddress, _, _, commonTransactionRequest := createInputForMessage(t) type args struct { - baseReq rest.BaseReq - to string - identityID string + commonTransactionRequest helpers.CommonTransactionRequest + to string + identityID string } tests := []struct { name string @@ -59,11 +56,11 @@ func Test_newTransactionRequest(t *testing.T) { want helpers.TransactionRequest }{ {"+ve wit nil", args{}, transactionRequest{}}, - {"+ve", args{testBaseReq, toAddress, testIdentityID.AsString()}, transactionRequest{testBaseReq, toAddress, testIdentityID.AsString()}}, + {"+ve", args{commonTransactionRequest, toAddress, testIdentityID.AsString()}, transactionRequest{commonTransactionRequest, toAddress, testIdentityID.AsString()}}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - if got := newTransactionRequest(tt.args.baseReq, tt.args.to, tt.args.identityID); !reflect.DeepEqual(got, tt.want) { + if got := newTransactionRequest(tt.args.commonTransactionRequest, tt.args.to, tt.args.identityID); !reflect.DeepEqual(got, tt.want) { t.Errorf("newTransactionRequest() = %v, want %v", got, tt.want) } }) @@ -89,11 +86,11 @@ func Test_requestPrototype(t *testing.T) { func Test_transactionRequest_FromCLI(t *testing.T) { cliCommand := baseHelpers.NewCLICommand("", "", "", []helpers.CLIFlag{constants.To, constants.IdentityID}) - testIdentityID, toAddress, _, _, testBaseReq := createInputForMessage(t) + testIdentityID, toAddress, _, _, commonTransactionRequest := createInputForMessage(t) type fields struct { - BaseReq rest.BaseReq - To string - IdentityID string + commonTransactionRequest helpers.CommonTransactionRequest + To string + IdentityID string } type args struct { cliCommand helpers.CLICommand @@ -106,14 +103,14 @@ func Test_transactionRequest_FromCLI(t *testing.T) { want helpers.TransactionRequest wantErr bool }{ - {"+ve", fields{testBaseReq, toAddress, testIdentityID.AsString()}, args{cliCommand, client.Context{}.WithCodec(baseHelpers.CodecPrototype())}, transactionRequest{cliCommand.ReadBaseReq(client.Context{}.WithCodec(baseHelpers.CodecPrototype())), cliCommand.ReadString(constants.To), cliCommand.ReadString(constants.IdentityID)}, false}, + {"+ve", fields{commonTransactionRequest, toAddress, testIdentityID.AsString()}, args{cliCommand, client.Context{}.WithCodec(baseHelpers.CodecPrototype())}, transactionRequest{cliCommand.ReadCommonTransactionRequest(client.Context{}.WithCodec(baseHelpers.CodecPrototype())), cliCommand.ReadString(constants.To), cliCommand.ReadString(constants.IdentityID)}, false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - To: tt.fields.To, - IdentityID: tt.fields.IdentityID, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + To: tt.fields.To, + IdentityID: tt.fields.IdentityID, } got, err := transactionRequest.FromCLI(tt.args.cliCommand, tt.args.context) if (err != nil) != tt.wantErr { @@ -127,81 +124,43 @@ func Test_transactionRequest_FromCLI(t *testing.T) { } } -func Test_transactionRequest_FromJSON(t *testing.T) { - testIdentityID, toAddress, toAccAddress, _, testBaseReq := createInputForMessage(t) - type fields struct { - BaseReq rest.BaseReq - To string - IdentityID string - } - type args struct { - rawMessage json.RawMessage - } - tests := []struct { - name string - fields fields - args args - want helpers.TransactionRequest - wantErr bool - }{ - {"+ve", fields{testBaseReq, toAddress, testIdentityID.AsString()}, args{types.MustSortJSON(baseHelpers.CodecPrototype().MustMarshalJSON(&Message{types.AccAddress("cosmos1pkkayn066msg6kn33wnl5srhdt3tnu2vzasz9c").String(), toAccAddress.String(), testIdentityID}))}, transactionRequest{testBaseReq, toAddress, testIdentityID.AsString()}, false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - To: tt.fields.To, - IdentityID: tt.fields.IdentityID, - } - got, err := transactionRequest.FromJSON(tt.args.rawMessage) - if (err != nil) != tt.wantErr { - t.Errorf("FromJSON() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("FromJSON() got = %v, want %v", got, tt.want) - } - }) - } -} - func Test_transactionRequest_GetBaseReq(t *testing.T) { - testIdentityID, toAddress, _, _, testBaseReq := createInputForMessage(t) + testIdentityID, toAddress, _, _, commonTransactionRequest := createInputForMessage(t) type fields struct { - BaseReq rest.BaseReq - To string - IdentityID string + commonTransactionRequest helpers.CommonTransactionRequest + To string + IdentityID string } tests := []struct { name string fields fields - want rest.BaseReq + want helpers.CommonTransactionRequest }{ - {"+ve", fields{testBaseReq, toAddress, testIdentityID.AsString()}, testBaseReq}, + {"+ve", fields{commonTransactionRequest, toAddress, testIdentityID.AsString()}, commonTransactionRequest}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - To: tt.fields.To, - IdentityID: tt.fields.IdentityID, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + To: tt.fields.To, + IdentityID: tt.fields.IdentityID, } - if got := transactionRequest.GetBaseReq(); !reflect.DeepEqual(got, tt.want) { - t.Errorf("GetBaseReq() = %v, want %v", got, tt.want) + if got := transactionRequest.GetCommonTransactionRequest(); !reflect.DeepEqual(got, tt.want) { + t.Errorf("GetCommonTransactionRequest() = %v, want %v", got, tt.want) } }) } } func Test_transactionRequest_MakeMsg(t *testing.T) { - testIdentityID, toAddress, toAccAddress, _, testBaseReq := createInputForMessage(t) + testIdentityID, toAddress, toAccAddress, _, commonTransactionRequest := createInputForMessage(t) fromAddress := "cosmos1pkkayn066msg6kn33wnl5srhdt3tnu2vzasz9c" fromAccAddress, err := types.AccAddressFromBech32(fromAddress) require.Nil(t, err) type fields struct { - BaseReq rest.BaseReq - To string - IdentityID string + commonTransactionRequest helpers.CommonTransactionRequest + To string + IdentityID string } tests := []struct { name string @@ -209,14 +168,14 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { want types.Msg wantErr bool }{ - {"+ve", fields{testBaseReq, toAddress, testIdentityID.AsString()}, &Message{fromAccAddress.String(), toAccAddress.String(), testIdentityID}, false}, + {"+ve", fields{commonTransactionRequest, toAddress, testIdentityID.AsString()}, &Message{fromAccAddress.String(), toAccAddress.String(), testIdentityID}, false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - To: tt.fields.To, - IdentityID: tt.fields.IdentityID, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + To: tt.fields.To, + IdentityID: tt.fields.IdentityID, } got, err := transactionRequest.MakeMsg() if (err != nil) != tt.wantErr { @@ -230,42 +189,12 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { } } -func Test_transactionRequest_RegisterCodec(t *testing.T) { - testIdentityID, toAddress, _, _, testBaseReq := createInputForMessage(t) - type fields struct { - BaseReq rest.BaseReq - To string - IdentityID string - } - type args struct { - legacyAmino *codec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve wit nil", fields{}, args{codec.NewLegacyAmino()}}, - {"+ve", fields{testBaseReq, toAddress, testIdentityID.AsString()}, args{codec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - tr := transactionRequest{ - BaseReq: tt.fields.BaseReq, - To: tt.fields.To, - IdentityID: tt.fields.IdentityID, - } - tr.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - func Test_transactionRequest_Validate(t *testing.T) { - testIdentityID, toAddress, _, _, testBaseReq := createInputForMessage(t) + testIdentityID, toAddress, _, _, commonTransactionRequest := createInputForMessage(t) type fields struct { - BaseReq rest.BaseReq - To string - IdentityID string + commonTransactionRequest helpers.CommonTransactionRequest + To string + IdentityID string } tests := []struct { name string @@ -273,14 +202,14 @@ func Test_transactionRequest_Validate(t *testing.T) { wantErr bool }{ {"+ve wit nil", fields{}, true}, - {"+ve", fields{testBaseReq, toAddress, testIdentityID.AsString()}, false}, + {"+ve", fields{commonTransactionRequest, toAddress, testIdentityID.AsString()}, false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - To: tt.fields.To, - IdentityID: tt.fields.IdentityID, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + To: tt.fields.To, + IdentityID: tt.fields.IdentityID, } if err := transactionRequest.Validate(); (err != nil) != tt.wantErr { t.Errorf("ValidateBasic() error = %v, wantErr %v", err, tt.wantErr) diff --git a/x/identities/transactions/unprovision/transaction_response.go b/x/identities/transactions/unprovision/transaction_response.go index 6259467bc..70dbe26a4 100644 --- a/x/identities/transactions/unprovision/transaction_response.go +++ b/x/identities/transactions/unprovision/transaction_response.go @@ -4,9 +4,8 @@ package unprovision import ( - sdkTypes "github.com/cosmos/cosmos-sdk/types" - "github.com/AssetMantle/modules/helpers" + sdkTypes "github.com/cosmos/cosmos-sdk/types" ) var _ helpers.TransactionResponse = (*TransactionResponse)(nil) diff --git a/x/identities/transactions/update/message.go b/x/identities/transactions/update/message.go index c4752de63..ad37fffe6 100644 --- a/x/identities/transactions/update/message.go +++ b/x/identities/transactions/update/message.go @@ -4,28 +4,17 @@ package update import ( - codecUtilities "github.com/AssetMantle/schema/codec/utilities" + "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" "github.com/AssetMantle/schema/lists" baseLists "github.com/AssetMantle/schema/lists/base" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/types" sdkTypes "github.com/cosmos/cosmos-sdk/types" - - "github.com/AssetMantle/modules/helpers" ) var _ helpers.Message = (*Message)(nil) -func (message *Message) Type() string { return Transaction.GetName() } -func (message *Message) GetFromAddress() sdkTypes.AccAddress { - from, err := sdkTypes.AccAddressFromBech32(message.From) - if err != nil { - panic(err) - } - return from -} func (message *Message) ValidateBasic() error { if _, err := sdkTypes.AccAddressFromBech32(message.From); err != nil { return err @@ -51,21 +40,10 @@ func (message *Message) GetSigners() []sdkTypes.AccAddress { } return []sdkTypes.AccAddress{from} } -func (*Message) RegisterLegacyAminoCodec(legacyAmino *codec.LegacyAmino) { - codecUtilities.RegisterModuleConcrete(legacyAmino, Message{}) -} func (message *Message) RegisterInterface(interfaceRegistry types.InterfaceRegistry) { interfaceRegistry.RegisterImplementations((*sdkTypes.Msg)(nil), message) } -func messageFromInterface(msg sdkTypes.Msg) *Message { - switch value := msg.(type) { - case *Message: - return value - default: - return &Message{} - } -} func messagePrototype() helpers.Message { return &Message{} } diff --git a/x/identities/transactions/update/message_test.go b/x/identities/transactions/update/message_test.go index da6b724bd..defd6e341 100644 --- a/x/identities/transactions/update/message_test.go +++ b/x/identities/transactions/update/message_test.go @@ -15,7 +15,6 @@ import ( "github.com/AssetMantle/schema/properties" baseProperties "github.com/AssetMantle/schema/properties/base" baseQualified "github.com/AssetMantle/schema/qualified/base" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" @@ -46,28 +45,6 @@ func createTestInputForMessage(t *testing.T) (types.AccAddress, *baseIDs.Identit return testFrom, testFromID.(*baseIDs.IdentityID), testIdentityID.(*baseIDs.IdentityID), testMutableMetaProperties.(*baseLists.PropertyList), testMutableProperties.(*baseLists.PropertyList) } -func Test_messageFromInterface(t *testing.T) { - testFrom, testFromID, testIdentityID, testMutableMetaProperties, testMutableProperties := createTestInputForMessage(t) - type args struct { - msg types.Msg - } - tests := []struct { - name string - args args - want *Message - }{ - {"+ve with nil", args{}, &Message{}}, - {"+ve", args{&Message{testFrom.String(), testFromID, testIdentityID, testMutableMetaProperties, testMutableProperties}}, &Message{testFrom.String(), testFromID, testIdentityID, testMutableMetaProperties, testMutableProperties}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := messageFromInterface(tt.args.msg); !reflect.DeepEqual(got, tt.want) { - t.Errorf("messageFromInterface() = %v, want %v", got, tt.want) - } - }) - } -} - func Test_messagePrototype(t *testing.T) { tests := []struct { name string @@ -111,61 +88,6 @@ func Test_message_GetSigners(t *testing.T) { } } -func Test_message_RegisterCodec(t *testing.T) { - testFrom, testFromID, testIdentityID, testMutableMetaProperties, testMutableProperties := createTestInputForMessage(t) - - type args struct { - legacyAmino *codec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve with nil", fields{}, args{codec.NewLegacyAmino()}}, - {"+ve", fields{testFrom.String(), testFromID, testIdentityID, testMutableMetaProperties, testMutableProperties}, args{codec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - me := &Message{ - From: tt.fields.From, - FromID: tt.fields.FromID, - IdentityID: tt.fields.IdentityID, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, - } - me.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - -func Test_message_Type(t *testing.T) { - testFrom, testFromID, testIdentityID, testMutableMetaProperties, testMutableProperties := createTestInputForMessage(t) - - tests := []struct { - name string - fields fields - want string - }{ - {"+ve with nil", fields{}, Transaction.GetName()}, - {"+ve", fields{testFrom.String(), testFromID, testIdentityID, testMutableMetaProperties, testMutableProperties}, Transaction.GetName()}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - message := &Message{ - From: tt.fields.From, - FromID: tt.fields.FromID, - IdentityID: tt.fields.IdentityID, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, - } - if got := message.Type(); got != tt.want { - t.Errorf("Type() = %v, want %v", got, tt.want) - } - }) - } -} - func Test_message_ValidateBasic(t *testing.T) { testFrom, testFromID, testIdentityID, testMutableMetaProperties, testMutableProperties := createTestInputForMessage(t) diff --git a/x/identities/transactions/update/service.pb.go b/x/identities/transactions/update/service.pb.go index 1041c976f..2468e5f8b 100644 --- a/x/identities/transactions/update/service.pb.go +++ b/x/identities/transactions/update/service.pb.go @@ -6,9 +6,9 @@ package update import ( context "context" fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types/msgservice" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" - _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -31,30 +31,30 @@ func init() { } var fileDescriptor_188ef3d964dd38f9 = []byte{ - // 364 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x92, 0x31, 0x4b, 0xf3, 0x40, - 0x18, 0x80, 0x9b, 0x14, 0x3a, 0x84, 0x6f, 0xea, 0xf6, 0x45, 0x09, 0xd8, 0x1f, 0x70, 0x07, 0xea, - 0xa0, 0x07, 0xa2, 0xcd, 0xa2, 0x1d, 0x82, 0x45, 0x5b, 0x08, 0x12, 0x90, 0x6b, 0x72, 0xc4, 0x83, - 0xe4, 0x2e, 0xe4, 0xae, 0xd2, 0xd9, 0x5f, 0x20, 0x38, 0xb9, 0x3a, 0xba, 0x3b, 0xba, 0x8b, 0x53, - 0xc1, 0xc5, 0x51, 0x52, 0x27, 0x7f, 0x85, 0xd8, 0x3b, 0xc8, 0x75, 0xbd, 0xf5, 0x0d, 0xcf, 0xc3, - 0xf3, 0xe6, 0x5e, 0x2f, 0x1c, 0x0a, 0x41, 0x64, 0x84, 0x99, 0x2c, 0x08, 0x2c, 0x79, 0x36, 0x2f, - 0x88, 0x80, 0x0b, 0x48, 0x33, 0xc2, 0x24, 0x95, 0x94, 0x08, 0x28, 0x6b, 0xcc, 0x04, 0x4e, 0x25, - 0xe5, 0x4c, 0xc0, 0x79, 0x95, 0x61, 0x49, 0xa0, 0x20, 0xf5, 0x2d, 0x4d, 0x09, 0xa8, 0x6a, 0x2e, - 0x79, 0x7f, 0xdf, 0x70, 0x00, 0xed, 0x00, 0x0b, 0xd0, 0x3a, 0x80, 0xe9, 0x00, 0xca, 0xe1, 0x6f, - 0xe7, 0x9c, 0xe7, 0x05, 0x81, 0xb8, 0xa2, 0x10, 0x33, 0xc6, 0x25, 0x56, 0x9f, 0xd7, 0x4e, 0xdf, - 0xae, 0xab, 0x24, 0x42, 0xe0, 0x5c, 0x77, 0xf9, 0xe7, 0x56, 0x0e, 0x63, 0x76, 0x5d, 0x13, 0x51, - 0x71, 0x26, 0xb4, 0x70, 0xf7, 0xd5, 0xf1, 0xba, 0x91, 0xc8, 0xfb, 0x2f, 0x8e, 0xd7, 0x3b, 0xc3, - 0x2c, 0x2b, 0x48, 0xff, 0x08, 0xd8, 0x2c, 0x0f, 0x22, 0x15, 0xea, 0x8f, 0xec, 0xf0, 0x49, 0x3b, - 0xbb, 0xd0, 0x89, 0x83, 0x9d, 0xbb, 0x8f, 0xef, 0x07, 0x77, 0x6b, 0xf0, 0x1f, 0x96, 0x6a, 0x63, - 0x63, 0x4f, 0x85, 0x85, 0x8f, 0xdd, 0xb7, 0x26, 0x70, 0x96, 0x4d, 0xe0, 0x7c, 0x35, 0x81, 0x73, - 0xbf, 0x0a, 0x3a, 0xcb, 0x55, 0xd0, 0xf9, 0x5c, 0x05, 0x1d, 0xef, 0x20, 0xe5, 0xa5, 0x55, 0x4b, - 0xf8, 0xef, 0x52, 0x1d, 0xc3, 0xf8, 0xef, 0x17, 0x8d, 0x9d, 0xab, 0xe3, 0x9c, 0xca, 0x9b, 0xf9, - 0x0c, 0xa4, 0xbc, 0x84, 0x36, 0x0f, 0xf0, 0xe4, 0xf6, 0x86, 0x51, 0x3c, 0x9a, 0x4c, 0x9f, 0xdd, - 0x8d, 0xc3, 0x8a, 0x74, 0x50, 0x0c, 0x46, 0x6d, 0xd0, 0xc4, 0x0c, 0x9a, 0xae, 0xf9, 0xf7, 0x0d, - 0x2c, 0xd1, 0x58, 0x12, 0x27, 0x2d, 0x96, 0x98, 0x58, 0xa2, 0xb0, 0xc6, 0x3d, 0xb1, 0xc1, 0x92, - 0xd3, 0x71, 0x18, 0x11, 0x89, 0x33, 0x2c, 0xf1, 0x8f, 0x7b, 0x68, 0x28, 0x10, 0xd2, 0x0e, 0x84, - 0x62, 0x84, 0x5a, 0x0b, 0x42, 0xa6, 0x06, 0x21, 0xe5, 0x99, 0xf5, 0xd6, 0x27, 0xb6, 0xf7, 0x1b, - 0x00, 0x00, 0xff, 0xff, 0x3d, 0x50, 0x9e, 0x46, 0x91, 0x03, 0x00, 0x00, + // 356 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x92, 0x3f, 0x4b, 0xfb, 0x40, + 0x18, 0x80, 0x73, 0x29, 0xbf, 0x0e, 0xe1, 0x37, 0x75, 0x11, 0x32, 0x64, 0x70, 0x74, 0xb8, 0xc3, + 0x3f, 0x83, 0x1e, 0x88, 0x36, 0x8b, 0x76, 0x08, 0x16, 0x6d, 0x21, 0x48, 0x40, 0xae, 0xc9, 0x11, + 0x03, 0x4d, 0xae, 0xe4, 0xbd, 0x96, 0x8e, 0x7e, 0x04, 0x07, 0x17, 0x57, 0xdd, 0x9c, 0xfc, 0x18, + 0xe2, 0xd4, 0xd1, 0x51, 0x92, 0x41, 0xf0, 0x53, 0x48, 0x9b, 0x83, 0x5c, 0xd7, 0x9b, 0x02, 0x2f, + 0x3c, 0x4f, 0x9e, 0xbc, 0x79, 0x1d, 0xbf, 0x0f, 0xc0, 0x65, 0xc0, 0x0a, 0x39, 0xe5, 0x24, 0x17, + 0xc9, 0x7c, 0xca, 0x81, 0x2c, 0x49, 0x96, 0xf0, 0x42, 0x66, 0x32, 0xe3, 0x40, 0x64, 0xc9, 0x0a, + 0x60, 0xb1, 0xcc, 0x44, 0x01, 0x64, 0x3e, 0x4b, 0x98, 0xe4, 0x04, 0x78, 0xb9, 0xc8, 0x62, 0x8e, + 0x67, 0xa5, 0x90, 0xa2, 0x77, 0xa4, 0x39, 0xb0, 0x72, 0xe0, 0x25, 0x6e, 0x1d, 0x58, 0x77, 0xe0, + 0xc6, 0xe1, 0xee, 0xc4, 0x02, 0x72, 0x01, 0x24, 0x87, 0x94, 0x2c, 0xf6, 0xd7, 0x8f, 0x46, 0xe7, + 0x9a, 0x25, 0xe5, 0x1c, 0x80, 0xa5, 0x2a, 0xc9, 0xbd, 0x32, 0x72, 0x68, 0xb3, 0xbb, 0x92, 0xc3, + 0x4c, 0x14, 0xa0, 0x84, 0x07, 0xaf, 0xc8, 0xe9, 0x04, 0x90, 0xf6, 0x9e, 0x90, 0xd3, 0xbd, 0x64, + 0x45, 0x32, 0xe5, 0xbd, 0x53, 0x6c, 0xf2, 0xdd, 0x38, 0x68, 0x42, 0xdd, 0x81, 0x19, 0x3e, 0x6a, + 0x67, 0xd7, 0x2a, 0x71, 0xd7, 0x72, 0xff, 0x3d, 0xfc, 0xbc, 0xef, 0x21, 0xff, 0xb9, 0xf3, 0x51, + 0x79, 0x68, 0x55, 0x79, 0xe8, 0xbb, 0xf2, 0xd0, 0x63, 0xed, 0x59, 0xab, 0xda, 0xb3, 0xbe, 0x6a, + 0xcf, 0x72, 0x8e, 0x63, 0x91, 0x1b, 0xbd, 0xd1, 0xff, 0x7f, 0xd3, 0xfc, 0xed, 0xe1, 0x7a, 0x11, + 0x43, 0x74, 0x7b, 0x96, 0x66, 0xf2, 0x7e, 0x3e, 0xc1, 0xb1, 0xc8, 0x89, 0xc9, 0x9a, 0x5f, 0xec, + 0x6e, 0x3f, 0x08, 0x07, 0xa3, 0xf1, 0x9b, 0xbd, 0x75, 0x39, 0x81, 0x0a, 0x0a, 0xf1, 0xa0, 0x0d, + 0x1a, 0xe9, 0x41, 0xe3, 0x0d, 0xff, 0xb9, 0x85, 0x45, 0x0a, 0x8b, 0xc2, 0xa8, 0xc5, 0x22, 0x1d, + 0x8b, 0x1a, 0xac, 0xb2, 0xcf, 0x4d, 0xb0, 0xe8, 0x62, 0xe8, 0x07, 0x5c, 0xb2, 0x84, 0x49, 0xf6, + 0x6b, 0x9f, 0x68, 0x0a, 0x4a, 0x95, 0x83, 0xd2, 0x90, 0xd2, 0xd6, 0x42, 0xa9, 0xae, 0xa1, 0xb4, + 0xf1, 0x4c, 0xba, 0x9b, 0x43, 0x3a, 0xfc, 0x0b, 0x00, 0x00, 0xff, 0xff, 0x67, 0xa8, 0x09, 0xce, + 0x72, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/identities/transactions/update/service.pb.gw.go b/x/identities/transactions/update/service.pb.gw.go deleted file mode 100644 index 701b803e0..000000000 --- a/x/identities/transactions/update/service.pb.gw.go +++ /dev/null @@ -1,171 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: AssetMantle/modules/x/identities/transactions/update/service.proto - -/* -Package update is a reverse proxy. - -It translates gRPC into RESTful JSON APIs. -*/ -package update - -import ( - "context" - "io" - "net/http" - - "github.com/golang/protobuf/descriptor" - "github.com/golang/protobuf/proto" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/grpc-ecosystem/grpc-gateway/utilities" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/status" -) - -// Suppress "imported and not used" errors -var _ codes.Code -var _ io.Reader -var _ status.Status -var _ = runtime.String -var _ = utilities.NewDoubleArray -var _ = descriptor.ForMessage -var _ = metadata.Join - -var ( - filter_Msg_Handle_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - -func request_Msg_Handle_0(ctx context.Context, marshaler runtime.Marshaler, client MsgClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq Message - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.Handle(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Msg_Handle_0(ctx context.Context, marshaler runtime.Marshaler, server MsgServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq Message - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.Handle(ctx, &protoReq) - return msg, metadata, err - -} - -// RegisterMsgHandlerServer registers the http handlers for service Msg to "mux". -// UnaryRPC :call MsgServer directly. -// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterMsgHandlerFromEndpoint instead. -func RegisterMsgHandlerServer(ctx context.Context, mux *runtime.ServeMux, server MsgServer) error { - - mux.Handle("POST", pattern_Msg_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Msg_Handle_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Msg_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -// RegisterMsgHandlerFromEndpoint is same as RegisterMsgHandler but -// automatically dials to "endpoint" and closes the connection when "ctx" gets done. -func RegisterMsgHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.Dial(endpoint, opts...) - if err != nil { - return err - } - defer func() { - if err != nil { - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - return - } - go func() { - <-ctx.Done() - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - }() - }() - - return RegisterMsgHandler(ctx, mux, conn) -} - -// RegisterMsgHandler registers the http handlers for service Msg to "mux". -// The handlers forward requests to the grpc endpoint over "conn". -func RegisterMsgHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { - return RegisterMsgHandlerClient(ctx, mux, NewMsgClient(conn)) -} - -// RegisterMsgHandlerClient registers the http handlers for service Msg -// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "MsgClient". -// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "MsgClient" -// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "MsgClient" to call the correct interceptors. -func RegisterMsgHandlerClient(ctx context.Context, mux *runtime.ServeMux, client MsgClient) error { - - mux.Handle("POST", pattern_Msg_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Msg_Handle_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Msg_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -var ( - pattern_Msg_Handle_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"mantle", "identities", "update"}, "", runtime.AssumeColonVerbOpt(false))) -) - -var ( - forward_Msg_Handle_0 = runtime.ForwardResponseMessage -) diff --git a/x/identities/transactions/update/transaction.go b/x/identities/transactions/update/transaction.go index 177ed2536..d72d75ff1 100644 --- a/x/identities/transactions/update/transaction.go +++ b/x/identities/transactions/update/transaction.go @@ -4,22 +4,14 @@ package update import ( - "context" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "google.golang.org/grpc" - "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/helpers/constants" - "github.com/AssetMantle/modules/utilities/name" + "google.golang.org/grpc" ) -type dummy struct{} - var Transaction = baseHelpers.NewTransaction( - name.GetPackageName(dummy{}), + _Msg_serviceDesc.ServiceName, "", "", @@ -30,9 +22,6 @@ var Transaction = baseHelpers.NewTransaction( func(server grpc.ServiceRegistrar, keeper helpers.TransactionKeeper) { RegisterMsgServer(server, keeper.(transactionKeeper)) }, - func(clientCtx client.Context, mux *runtime.ServeMux) error { - return RegisterMsgHandlerClient(context.Background(), mux, NewMsgClient(clientCtx)) - }, constants.IdentityID, constants.FromIdentityID, diff --git a/x/identities/transactions/update/transaction_keeper.go b/x/identities/transactions/update/transaction_keeper.go index db96d2430..ff822a89a 100644 --- a/x/identities/transactions/update/transaction_keeper.go +++ b/x/identities/transactions/update/transaction_keeper.go @@ -5,9 +5,8 @@ package update import ( "context" - errorConstants "github.com/AssetMantle/modules/helpers/constants" - "github.com/AssetMantle/modules/helpers" + errorConstants "github.com/AssetMantle/modules/helpers/constants" "github.com/AssetMantle/modules/x/classifications/auxiliaries/member" "github.com/AssetMantle/modules/x/identities/key" "github.com/AssetMantle/modules/x/identities/mappable" @@ -31,7 +30,7 @@ func (transactionKeeper transactionKeeper) Transact(context context.Context, mes } func (transactionKeeper transactionKeeper) Handle(context context.Context, message *Message) (*TransactionResponse, error) { - fromAddress := message.GetFromAddress() + fromAddress := message.GetSigners()[0] if Mappable := transactionKeeper.mapper.NewCollection(context).Fetch(key.NewKey(message.FromID)).GetMappable(key.NewKey(message.FromID)); Mappable == nil { return nil, errorConstants.EntityNotFound.Wrapf("identity with ID %s not found", message.FromID.AsString()) diff --git a/x/identities/transactions/update/transaction_request.go b/x/identities/transactions/update/transaction_request.go index a57755ee3..e45b759e1 100644 --- a/x/identities/transactions/update/transaction_request.go +++ b/x/identities/transactions/update/transaction_request.go @@ -5,26 +5,24 @@ package update import ( "encoding/json" - "github.com/AssetMantle/modules/utilities/rest" - - codecUtilities "github.com/AssetMantle/schema/codec/utilities" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" "github.com/AssetMantle/schema/lists/base" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" + "io" + "net/http" "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/helpers/constants" ) type transactionRequest struct { - BaseReq rest.BaseReq `json:"baseReq"` - FromID string `json:"fromID"` - IdentityID string `json:"identityID"` - MutableMetaProperties string `json:"mutableMetaProperties"` - MutableProperties string `json:"mutableProperties"` + helpers.CommonTransactionRequest `json:"commonTransactionRequest"` + FromID string `json:"fromID"` + IdentityID string `json:"identityID"` + MutableMetaProperties string `json:"mutableMetaProperties"` + MutableProperties string `json:"mutableProperties"` } var _ helpers.TransactionRequest = (*transactionRequest)(nil) @@ -50,25 +48,30 @@ func (transactionRequest transactionRequest) Validate() error { } func (transactionRequest transactionRequest) FromCLI(cliCommand helpers.CLICommand, context client.Context) (helpers.TransactionRequest, error) { return newTransactionRequest( - cliCommand.ReadBaseReq(context), + cliCommand.ReadCommonTransactionRequest(context), cliCommand.ReadString(constants.FromIdentityID), cliCommand.ReadString(constants.IdentityID), cliCommand.ReadString(constants.MutableMetaProperties), cliCommand.ReadString(constants.MutableProperties), ), nil } -func (transactionRequest transactionRequest) FromJSON(rawMessage json.RawMessage) (helpers.TransactionRequest, error) { - if err := json.Unmarshal(rawMessage, &transactionRequest); err != nil { +func (transactionRequest transactionRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.TransactionRequest, error) { + body, err := io.ReadAll(httpRequest.Body) + if err != nil { + return nil, err + } + + if err := json.Unmarshal(body, &transactionRequest); err != nil { return nil, err } return transactionRequest, nil } -func (transactionRequest transactionRequest) GetBaseReq() rest.BaseReq { - return transactionRequest.BaseReq +func (transactionRequest transactionRequest) GetCommonTransactionRequest() helpers.CommonTransactionRequest { + return transactionRequest.CommonTransactionRequest } func (transactionRequest transactionRequest) MakeMsg() (sdkTypes.Msg, error) { - from, err := sdkTypes.AccAddressFromBech32(transactionRequest.GetBaseReq().From) + from, err := sdkTypes.AccAddressFromBech32(transactionRequest.GetCommonTransactionRequest().GetFrom()) if err != nil { return nil, err } @@ -102,18 +105,15 @@ func (transactionRequest transactionRequest) MakeMsg() (sdkTypes.Msg, error) { mutableProperties, ), nil } -func (transactionRequest) RegisterLegacyAminoCodec(legacyAmino *codec.LegacyAmino) { - codecUtilities.RegisterModuleConcrete(legacyAmino, transactionRequest{}) -} func requestPrototype() helpers.TransactionRequest { return transactionRequest{} } -func newTransactionRequest(baseReq rest.BaseReq, fromID string, identityID string, mutableMetaProperties string, mutableProperties string) helpers.TransactionRequest { +func newTransactionRequest(commonTransactionRequest helpers.CommonTransactionRequest, fromID string, identityID string, mutableMetaProperties string, mutableProperties string) helpers.TransactionRequest { return transactionRequest{ - BaseReq: baseReq, - FromID: fromID, - IdentityID: identityID, - MutableMetaProperties: mutableMetaProperties, - MutableProperties: mutableProperties, + CommonTransactionRequest: commonTransactionRequest, + FromID: fromID, + IdentityID: identityID, + MutableMetaProperties: mutableMetaProperties, + MutableProperties: mutableProperties, } } diff --git a/x/identities/transactions/update/transaction_request_test.go b/x/identities/transactions/update/transaction_request_test.go index f33507f61..4c08eaf8b 100644 --- a/x/identities/transactions/update/transaction_request_test.go +++ b/x/identities/transactions/update/transaction_request_test.go @@ -4,8 +4,6 @@ package update import ( - "encoding/json" - "github.com/AssetMantle/modules/utilities/rest" "reflect" "testing" @@ -26,7 +24,7 @@ import ( "github.com/AssetMantle/modules/helpers/constants" ) -func createTestInput(t *testing.T) (*codec.LegacyAmino, helpers.CLICommand, client.Context, string, string, lists.PropertyList, lists.PropertyList, string, sdkTypes.AccAddress, rest.BaseReq) { +func createTestInput(t *testing.T) (*codec.LegacyAmino, helpers.CLICommand, client.Context, string, string, lists.PropertyList, lists.PropertyList, string, sdkTypes.AccAddress, helpers.CommonTransactionRequest) { var legacyAmino = baseHelpers.CodecPrototype().GetLegacyAmino() cliCommand := baseHelpers.NewCLICommand("", "", "", []helpers.CLIFlag{constants.FromIdentityID, constants.IdentityID, constants.MutableMetaProperties, constants.MutableProperties}) @@ -42,31 +40,31 @@ func createTestInput(t *testing.T) (*codec.LegacyAmino, helpers.CLICommand, clie fromAccAddress, err := sdkTypes.AccAddressFromBech32(fromAddress) require.Nil(t, err) - testBaseReq := rest.BaseReq{From: fromAddress, ChainID: "test", Fees: sdkTypes.NewCoins()} + commonTransactionRequest := helpers.PrototypeCommonTransactionRequest() - return legacyAmino, cliCommand, client.Context{}.WithCodec(baseHelpers.CodecPrototype()), mutableMetaPropertiesString, mutablePropertiesString, mutableMetaProperties, mutableProperties, fromAddress, fromAccAddress, testBaseReq + return legacyAmino, cliCommand, client.Context{}.WithCodec(baseHelpers.CodecPrototype()), mutableMetaPropertiesString, mutablePropertiesString, mutableMetaProperties, mutableProperties, fromAddress, fromAccAddress, commonTransactionRequest } func Test_newTransactionRequest(t *testing.T) { - _, _, _, mutableMetaPropertiesString, mutablePropertiesString, _, _, _, _, testBaseReq := createTestInput(t) + _, _, _, mutableMetaPropertiesString, mutablePropertiesString, _, _, _, _, commonTransactionRequest := createTestInput(t) type args struct { - baseReq rest.BaseReq - fromID string - identityID string - mutableMetaProperties string - mutableProperties string + commonTransactionRequest helpers.CommonTransactionRequest + fromID string + identityID string + mutableMetaProperties string + mutableProperties string } tests := []struct { name string args args want helpers.TransactionRequest }{ - {"+ve", args{testBaseReq, "fromID", "identityID", mutableMetaPropertiesString, mutablePropertiesString}, transactionRequest{testBaseReq, "fromID", "identityID", mutableMetaPropertiesString, mutablePropertiesString}}, + {"+ve", args{commonTransactionRequest, "fromID", "identityID", mutableMetaPropertiesString, mutablePropertiesString}, transactionRequest{commonTransactionRequest, "fromID", "identityID", mutableMetaPropertiesString, mutablePropertiesString}}, {"-ve with nil", args{}, transactionRequest{}}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - if got := newTransactionRequest(tt.args.baseReq, tt.args.fromID, tt.args.identityID, tt.args.mutableMetaProperties, tt.args.mutableProperties); !reflect.DeepEqual(got, tt.want) { + if got := newTransactionRequest(tt.args.commonTransactionRequest, tt.args.fromID, tt.args.identityID, tt.args.mutableMetaProperties, tt.args.mutableProperties); !reflect.DeepEqual(got, tt.want) { t.Errorf("newTransactionRequest() = %v, want %v", got, tt.want) } }) @@ -90,13 +88,13 @@ func Test_requestPrototype(t *testing.T) { } func Test_transactionRequest_FromCLI(t *testing.T) { - _, cliCommand, context, mutableMetaPropertiesString, mutablePropertiesString, _, _, _, _, testBaseReq := createTestInput(t) + _, cliCommand, context, mutableMetaPropertiesString, mutablePropertiesString, _, _, _, _, commonTransactionRequest := createTestInput(t) type fields struct { - BaseReq rest.BaseReq - FromID string - IdentityID string - MutableMetaProperties string - MutableProperties string + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + IdentityID string + MutableMetaProperties string + MutableProperties string } type args struct { cliCommand helpers.CLICommand @@ -109,16 +107,16 @@ func Test_transactionRequest_FromCLI(t *testing.T) { want helpers.TransactionRequest wantErr bool }{ - {"+ve", fields{testBaseReq, "fromID", "identityID", mutableMetaPropertiesString, mutablePropertiesString}, args{cliCommand: cliCommand, context: context}, transactionRequest{cliCommand.ReadBaseReq(context), cliCommand.ReadString(constants.FromIdentityID), cliCommand.ReadString(constants.IdentityID), cliCommand.ReadString(constants.MutableMetaProperties), cliCommand.ReadString(constants.MutableProperties)}, false}, + {"+ve", fields{commonTransactionRequest, "fromID", "identityID", mutableMetaPropertiesString, mutablePropertiesString}, args{cliCommand: cliCommand, context: context}, transactionRequest{cliCommand.ReadCommonTransactionRequest(context), cliCommand.ReadString(constants.FromIdentityID), cliCommand.ReadString(constants.IdentityID), cliCommand.ReadString(constants.MutableMetaProperties), cliCommand.ReadString(constants.MutableProperties)}, false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - IdentityID: tt.fields.IdentityID, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + IdentityID: tt.fields.IdentityID, + MutableMetaProperties: tt.fields.MutableMetaProperties, + MutableProperties: tt.fields.MutableProperties, } got, err := transactionRequest.FromCLI(tt.args.cliCommand, tt.args.context) if (err != nil) != tt.wantErr { @@ -132,96 +130,52 @@ func Test_transactionRequest_FromCLI(t *testing.T) { } } -func Test_transactionRequest_FromJSON(t *testing.T) { - _, _, _, mutableMetaPropertiesString, mutablePropertiesString, _, _, _, _, testBaseReq := createTestInput(t) - jsonMessage, _ := json.Marshal(transactionRequest{testBaseReq, "fromID", "identityID", mutableMetaPropertiesString, mutablePropertiesString}) - - type fields struct { - BaseReq rest.BaseReq - FromID string - IdentityID string - MutableMetaProperties string - MutableProperties string - } - type args struct { - rawMessage json.RawMessage - } - tests := []struct { - name string - fields fields - args args - want helpers.TransactionRequest - wantErr bool - }{ - {"+ve", fields{testBaseReq, "fromID", "identityID", mutableMetaPropertiesString, mutablePropertiesString}, args{jsonMessage}, transactionRequest{testBaseReq, "fromID", "identityID", mutableMetaPropertiesString, mutablePropertiesString}, false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - IdentityID: tt.fields.IdentityID, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, - } - got, err := transactionRequest.FromJSON(tt.args.rawMessage) - if (err != nil) != tt.wantErr { - t.Errorf("FromJSON() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("FromJSON() got = %v, want %v", got, tt.want) - } - }) - } -} - func Test_transactionRequest_GetBaseReq(t *testing.T) { - _, _, context, mutableMetaPropertiesString, mutablePropertiesString, _, _, _, _, testBaseReq := createTestInput(t) + _, _, _, mutableMetaPropertiesString, mutablePropertiesString, _, _, _, _, commonTransactionRequest := createTestInput(t) type fields struct { - BaseReq rest.BaseReq - FromID string - IdentityID string - MutableMetaProperties string - MutableProperties string + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + IdentityID string + MutableMetaProperties string + MutableProperties string } tests := []struct { name string fields fields - want rest.BaseReq + want helpers.CommonTransactionRequest }{ - {"+ve", fields{}, rest.BaseReq{From: context.GetFromAddress().String(), ChainID: context.ChainID, Simulate: context.Simulate}}, - {"+ve", fields{testBaseReq, "fromID", "identityID", mutableMetaPropertiesString, mutablePropertiesString}, testBaseReq}, + {"+ve", fields{}, helpers.PrototypeCommonTransactionRequest()}, + {"+ve", fields{commonTransactionRequest, "fromID", "identityID", mutableMetaPropertiesString, mutablePropertiesString}, commonTransactionRequest}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - IdentityID: tt.fields.IdentityID, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + IdentityID: tt.fields.IdentityID, + MutableMetaProperties: tt.fields.MutableMetaProperties, + MutableProperties: tt.fields.MutableProperties, } - if got := transactionRequest.GetBaseReq(); !reflect.DeepEqual(got, tt.want) { - t.Errorf("GetBaseReq() = %v, want %v", got, tt.want) + if got := transactionRequest.GetCommonTransactionRequest(); !reflect.DeepEqual(got, tt.want) { + t.Errorf("GetCommonTransactionRequest() = %v, want %v", got, tt.want) } }) } } func Test_transactionRequest_MakeMsg(t *testing.T) { - _, _, _, mutableMetaPropertiesString, mutablePropertiesString, mutableMetaProperties, mutableProperties, _, fromAccAddress, testBaseReq := createTestInput(t) + _, _, _, mutableMetaPropertiesString, mutablePropertiesString, mutableMetaProperties, mutableProperties, _, fromAccAddress, commonTransactionRequest := createTestInput(t) immutables := baseQualified.NewImmutables(baseLists.NewPropertyList(baseProperties.NewMesaProperty(baseIDs.NewStringID("ID2"), baseData.NewStringData("Data2")))) mutables := baseQualified.NewMutables(baseLists.NewPropertyList(baseProperties.NewMesaProperty(baseIDs.NewStringID("ID1"), baseData.NewStringData("Data1")))) testClassificationID := baseIDs.NewClassificationID(immutables, mutables) testFromID := baseIDs.NewIdentityID(testClassificationID, immutables) type fields struct { - BaseReq rest.BaseReq - FromID string - IdentityID string - MutableMetaProperties string - MutableProperties string + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + IdentityID string + MutableMetaProperties string + MutableProperties string } tests := []struct { name string @@ -229,16 +183,16 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { want sdkTypes.Msg wantErr bool }{ - {"+ve", fields{testBaseReq, testFromID.AsString(), testFromID.AsString(), mutableMetaPropertiesString, mutablePropertiesString}, NewMessage(fromAccAddress, testFromID, testFromID, mutableMetaProperties, mutableProperties.ScrubData()), false}, + {"+ve", fields{commonTransactionRequest, testFromID.AsString(), testFromID.AsString(), mutableMetaPropertiesString, mutablePropertiesString}, NewMessage(fromAccAddress, testFromID, testFromID, mutableMetaProperties, mutableProperties.ScrubData()), false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - IdentityID: tt.fields.IdentityID, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + IdentityID: tt.fields.IdentityID, + MutableMetaProperties: tt.fields.MutableMetaProperties, + MutableProperties: tt.fields.MutableProperties, } got, err := transactionRequest.MakeMsg() if (err != nil) != tt.wantErr { @@ -252,66 +206,32 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { } } -func Test_transactionRequest_RegisterCodec(t *testing.T) { - _, _, _, mutableMetaPropertiesString, mutablePropertiesString, _, _, _, _, testBaseReq := createTestInput(t) - - type fields struct { - BaseReq rest.BaseReq - FromID string - IdentityID string - MutableMetaProperties string - MutableProperties string - } - type args struct { - legacyAmino *codec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{testBaseReq, "fromID", "identityID", mutableMetaPropertiesString, mutablePropertiesString}, args{codec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - tr := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - IdentityID: tt.fields.IdentityID, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, - } - tr.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - func Test_transactionRequest_Validate(t *testing.T) { - _, _, _, mutableMetaPropertiesString, mutablePropertiesString, _, _, _, _, testBaseReq := createTestInput(t) + _, _, _, mutableMetaPropertiesString, mutablePropertiesString, _, _, _, _, commonTransactionRequest := createTestInput(t) type fields struct { - BaseReq rest.BaseReq - FromID string - IdentityID string - MutableMetaProperties string - MutableProperties string + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + IdentityID string + MutableMetaProperties string + MutableProperties string } tests := []struct { name string fields fields wantErr bool }{ - {"+ve", fields{testBaseReq, "fromID", "identityID", mutableMetaPropertiesString, mutablePropertiesString}, false}, + {"+ve", fields{commonTransactionRequest, "fromID", "identityID", mutableMetaPropertiesString, mutablePropertiesString}, false}, {"+ve with nil", fields{}, true}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - IdentityID: tt.fields.IdentityID, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + IdentityID: tt.fields.IdentityID, + MutableMetaProperties: tt.fields.MutableMetaProperties, + MutableProperties: tt.fields.MutableProperties, } if err := transactionRequest.Validate(); (err != nil) != tt.wantErr { t.Errorf("ValidateBasic() error = %v, wantErr %v", err, tt.wantErr) diff --git a/x/identities/transactions/update/transaction_response.go b/x/identities/transactions/update/transaction_response.go index 14c3b21ee..8e7c751f1 100644 --- a/x/identities/transactions/update/transaction_response.go +++ b/x/identities/transactions/update/transaction_response.go @@ -4,9 +4,8 @@ package update import ( - sdkTypes "github.com/cosmos/cosmos-sdk/types" - "github.com/AssetMantle/modules/helpers" + sdkTypes "github.com/cosmos/cosmos-sdk/types" ) var _ helpers.TransactionResponse = (*TransactionResponse)(nil) diff --git a/x/identities/utilities/permissions.go b/x/identities/utilities/permissions.go index b3d36b5f0..980d4a4fe 100644 --- a/x/identities/utilities/permissions.go +++ b/x/identities/utilities/permissions.go @@ -1,9 +1,8 @@ package utilities import ( - "github.com/AssetMantle/schema/ids" - "github.com/AssetMantle/modules/x/identities/constants" + "github.com/AssetMantle/schema/ids" ) func SetModulePermissions(canIssueIdentity bool, canQuashIdentity bool) []ids.StringID { diff --git a/x/maintainers/auxiliaries/authorize/auxiliary_keeper.go b/x/maintainers/auxiliaries/authorize/auxiliary_keeper.go index 2fc974315..1054ee450 100644 --- a/x/maintainers/auxiliaries/authorize/auxiliary_keeper.go +++ b/x/maintainers/auxiliaries/authorize/auxiliary_keeper.go @@ -6,7 +6,6 @@ package authorize import ( "context" errorConstants "github.com/AssetMantle/modules/helpers/constants" - baseData "github.com/AssetMantle/schema/data/base" "github.com/AssetMantle/schema/documents/base" baseIDs "github.com/AssetMantle/schema/ids/base" diff --git a/x/maintainers/auxiliaries/deputize/auxiliary_keeper.go b/x/maintainers/auxiliaries/deputize/auxiliary_keeper.go index a341fd376..28dc07b05 100644 --- a/x/maintainers/auxiliaries/deputize/auxiliary_keeper.go +++ b/x/maintainers/auxiliaries/deputize/auxiliary_keeper.go @@ -6,7 +6,6 @@ package deputize import ( "context" errorConstants "github.com/AssetMantle/modules/helpers/constants" - "github.com/AssetMantle/schema/data" baseData "github.com/AssetMantle/schema/data/base" "github.com/AssetMantle/schema/documents/base" diff --git a/x/maintainers/auxiliaries/maintain/auxiliary_keeper.go b/x/maintainers/auxiliaries/maintain/auxiliary_keeper.go index 9163e1c0a..6030fb3ed 100644 --- a/x/maintainers/auxiliaries/maintain/auxiliary_keeper.go +++ b/x/maintainers/auxiliaries/maintain/auxiliary_keeper.go @@ -6,7 +6,6 @@ package maintain import ( "context" errorConstants "github.com/AssetMantle/modules/helpers/constants" - baseData "github.com/AssetMantle/schema/data/base" "github.com/AssetMantle/schema/documents/base" baseIDs "github.com/AssetMantle/schema/ids/base" diff --git a/x/maintainers/auxiliaries/revoke/auxiliary_keeper.go b/x/maintainers/auxiliaries/revoke/auxiliary_keeper.go index 299494007..e7060ac18 100644 --- a/x/maintainers/auxiliaries/revoke/auxiliary_keeper.go +++ b/x/maintainers/auxiliaries/revoke/auxiliary_keeper.go @@ -6,7 +6,6 @@ package revoke import ( "context" errorConstants "github.com/AssetMantle/modules/helpers/constants" - baseData "github.com/AssetMantle/schema/data/base" "github.com/AssetMantle/schema/documents/base" baseIDs "github.com/AssetMantle/schema/ids/base" diff --git a/x/maintainers/auxiliaries/super/auxiliary_keeper.go b/x/maintainers/auxiliaries/super/auxiliary_keeper.go index b0d6c169e..59470d3ba 100644 --- a/x/maintainers/auxiliaries/super/auxiliary_keeper.go +++ b/x/maintainers/auxiliaries/super/auxiliary_keeper.go @@ -6,7 +6,6 @@ package super import ( "context" errorConstants "github.com/AssetMantle/modules/helpers/constants" - baseData "github.com/AssetMantle/schema/data/base" "github.com/AssetMantle/schema/documents/base" baseIDs "github.com/AssetMantle/schema/ids/base" diff --git a/x/maintainers/block/block.go b/x/maintainers/block/block.go index 1cbdcc3d6..36d85c5ae 100644 --- a/x/maintainers/block/block.go +++ b/x/maintainers/block/block.go @@ -5,7 +5,6 @@ package block import ( "context" - abciTypes "github.com/cometbft/cometbft/abci/types" "github.com/AssetMantle/modules/helpers" diff --git a/x/maintainers/genesis/genesis.go b/x/maintainers/genesis/genesis.go index effbb79f1..3521a3dc0 100644 --- a/x/maintainers/genesis/genesis.go +++ b/x/maintainers/genesis/genesis.go @@ -3,7 +3,6 @@ package genesis import ( "context" errorConstants "github.com/AssetMantle/modules/helpers/constants" - "github.com/AssetMantle/schema/lists" "github.com/AssetMantle/schema/lists/base" sdkCodec "github.com/cosmos/cosmos-sdk/codec" diff --git a/x/maintainers/key/key.go b/x/maintainers/key/key.go index dbbc1676c..5f7a664a1 100644 --- a/x/maintainers/key/key.go +++ b/x/maintainers/key/key.go @@ -4,11 +4,10 @@ package key import ( + "github.com/AssetMantle/modules/helpers" errorConstants "github.com/AssetMantle/modules/helpers/constants" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" - - "github.com/AssetMantle/modules/helpers" ) var _ helpers.Key = (*Key)(nil) @@ -22,7 +21,7 @@ func (key *Key) ValidateBasic() error { return nil } func (key *Key) GenerateStorePrefixBytes() []byte { - return []byte{} + return []byte{0x0} } func (key *Key) GenerateStoreKeyBytes() []byte { return key.MaintainerID.Bytes() diff --git a/x/maintainers/mappable/mappable.go b/x/maintainers/mappable/mappable.go index 3577809f3..a9d7eae85 100644 --- a/x/maintainers/mappable/mappable.go +++ b/x/maintainers/mappable/mappable.go @@ -4,12 +4,9 @@ package mappable import ( - codecUtilities "github.com/AssetMantle/schema/codec/utilities" + "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/schema/documents" baseDocuments "github.com/AssetMantle/schema/documents/base" - "github.com/cosmos/cosmos-sdk/codec" - - "github.com/AssetMantle/modules/helpers" ) var _ helpers.Mappable = (*Mappable)(nil) @@ -17,9 +14,6 @@ var _ helpers.Mappable = (*Mappable)(nil) func (mappable *Mappable) ValidateBasic() error { return mappable.Maintainer.ValidateBasic() } -func (*Mappable) RegisterLegacyAminoCodec(legacyAmino *codec.LegacyAmino) { - codecUtilities.RegisterModuleConcrete(legacyAmino, Mappable{}) -} func NewMappable(maintainer documents.Maintainer) helpers.Mappable { return &Mappable{Maintainer: maintainer.Get().(*baseDocuments.Document)} diff --git a/x/maintainers/mappable/mappable_test.go b/x/maintainers/mappable/mappable_test.go index bcbf8e701..8ad07ac46 100644 --- a/x/maintainers/mappable/mappable_test.go +++ b/x/maintainers/mappable/mappable_test.go @@ -7,6 +7,7 @@ import ( "reflect" "testing" + "github.com/AssetMantle/modules/helpers" baseData "github.com/AssetMantle/schema/data/base" "github.com/AssetMantle/schema/documents" "github.com/AssetMantle/schema/documents/base" @@ -14,9 +15,6 @@ import ( baseLists "github.com/AssetMantle/schema/lists/base" baseProperties "github.com/AssetMantle/schema/properties/base" baseQualified "github.com/AssetMantle/schema/qualified/base" - "github.com/cosmos/cosmos-sdk/codec" - - "github.com/AssetMantle/modules/helpers" ) func createTestData() documents.Maintainer { @@ -64,28 +62,3 @@ func TestPrototype(t *testing.T) { }) } } - -func Test_mappable_RegisterCodec(t *testing.T) { - testMaintainer := createTestData() - type fields struct { - Maintainer documents.Maintainer - } - type args struct { - legacyAmino *codec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{testMaintainer}, args{codec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - ma := &Mappable{ - Maintainer: tt.fields.Maintainer.Get().(*base.Document), - } - ma.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} diff --git a/x/maintainers/parameters/deputize_allowed/parameter.go b/x/maintainers/parameters/deputize_allowed/parameter.go index 944575c5f..2454042e0 100644 --- a/x/maintainers/parameters/deputize_allowed/parameter.go +++ b/x/maintainers/parameters/deputize_allowed/parameter.go @@ -4,13 +4,12 @@ package deputize_allowed import ( + baseHelpers "github.com/AssetMantle/modules/helpers/base" errorConstants "github.com/AssetMantle/modules/helpers/constants" baseData "github.com/AssetMantle/schema/data/base" baseParameters "github.com/AssetMantle/schema/parameters/base" "github.com/AssetMantle/schema/properties/base" constantProperties "github.com/AssetMantle/schema/properties/constants" - - baseHelpers "github.com/AssetMantle/modules/helpers/base" ) var ID = constantProperties.DeputizeAllowedProperty.GetKey() diff --git a/x/maintainers/parameters/prototype.go b/x/maintainers/parameters/prototype.go index 8dcdc24cd..d52f7e79d 100644 --- a/x/maintainers/parameters/prototype.go +++ b/x/maintainers/parameters/prototype.go @@ -6,10 +6,9 @@ package parameters import ( "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" - "github.com/AssetMantle/modules/x/maintainers/constants" "github.com/AssetMantle/modules/x/maintainers/parameters/deputize_allowed" ) func Prototype() helpers.ParameterManager { - return baseHelpers.NewParameterManager(constants.ModuleName, deputize_allowed.ValidatableParameter) + return baseHelpers.NewParameterManager(deputize_allowed.ValidatableParameter) } diff --git a/x/maintainers/parameters/prototype_test.go b/x/maintainers/parameters/prototype_test.go index 42d9528e1..40c949dc6 100644 --- a/x/maintainers/parameters/prototype_test.go +++ b/x/maintainers/parameters/prototype_test.go @@ -9,7 +9,6 @@ import ( "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" - "github.com/AssetMantle/modules/x/maintainers/constants" "github.com/AssetMantle/modules/x/maintainers/parameters/deputize_allowed" ) @@ -18,7 +17,7 @@ func TestPrototype(t *testing.T) { name string want helpers.ParameterManager }{ - {"+ve", baseHelpers.NewParameterManager(constants.ModuleName, deputize_allowed.ValidatableParameter)}, + {"+ve", baseHelpers.NewParameterManager(deputize_allowed.ValidatableParameter)}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { diff --git a/x/maintainers/queries/maintainer/query.go b/x/maintainers/queries/maintainer/query.go index b225b5b78..c3e474be7 100644 --- a/x/maintainers/queries/maintainer/query.go +++ b/x/maintainers/queries/maintainer/query.go @@ -4,28 +4,17 @@ package maintainer import ( - "context" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "google.golang.org/grpc" - "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" helperConstants "github.com/AssetMantle/modules/helpers/constants" - "github.com/AssetMantle/modules/utilities/name" - "github.com/AssetMantle/modules/x/maintainers/constants" + "google.golang.org/grpc" ) -type dummy struct{} - var Query = baseHelpers.NewQuery( - name.GetPackageName(dummy{}), + _Query_serviceDesc.ServiceName, "", "", - constants.ModuleName, - requestPrototype, responsePrototype, keeperPrototype, @@ -33,9 +22,6 @@ var Query = baseHelpers.NewQuery( func(server grpc.ServiceRegistrar, QueryKeeper helpers.QueryKeeper) { RegisterQueryServer(server, QueryKeeper.(queryKeeper)) }, - func(clientContext client.Context, serveMux *runtime.ServeMux) error { - return RegisterQueryHandlerClient(context.Background(), serveMux, NewQueryClient(clientContext)) - }, helperConstants.MaintainerID, ) diff --git a/x/maintainers/queries/maintainer/query_keeper.go b/x/maintainers/queries/maintainer/query_keeper.go index 6db6151ba..1f78d2383 100644 --- a/x/maintainers/queries/maintainer/query_keeper.go +++ b/x/maintainers/queries/maintainer/query_keeper.go @@ -5,7 +5,6 @@ package maintainer import ( "context" - "github.com/AssetMantle/modules/helpers" ) @@ -16,7 +15,7 @@ type queryKeeper struct { var _ helpers.QueryKeeper = (*queryKeeper)(nil) func (queryKeeper queryKeeper) Enquire(context context.Context, queryRequest helpers.QueryRequest) (helpers.QueryResponse, error) { - queryResponse, err := queryKeeper.Handle(context, queryRequestFromInterface(queryRequest)) + queryResponse, err := queryKeeper.Handle(context, queryRequest.(*QueryRequest)) return queryResponse, err } func (queryKeeper queryKeeper) Handle(context context.Context, queryRequest *QueryRequest) (*QueryResponse, error) { diff --git a/x/maintainers/queries/maintainer/query_request.go b/x/maintainers/queries/maintainer/query_request.go index b3fea771a..fd73596bc 100644 --- a/x/maintainers/queries/maintainer/query_request.go +++ b/x/maintainers/queries/maintainer/query_request.go @@ -11,7 +11,6 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/AssetMantle/modules/helpers" - "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/helpers/constants" "github.com/AssetMantle/modules/x/maintainers/key" ) @@ -52,30 +51,10 @@ func (*QueryRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.QueryRe } } -func (queryRequest *QueryRequest) Encode() ([]byte, error) { - return base.CodecPrototype().MarshalJSON(queryRequest) -} - -func (queryRequest *QueryRequest) Decode(bytes []byte) (helpers.QueryRequest, error) { - if err := base.CodecPrototype().UnmarshalJSON(bytes, queryRequest); err != nil { - return nil, err - } - - return queryRequest, nil -} func requestPrototype() helpers.QueryRequest { return &QueryRequest{} } -func queryRequestFromInterface(request helpers.QueryRequest) *QueryRequest { - switch value := request.(type) { - case *QueryRequest: - return value - default: - return &QueryRequest{} - } -} - func newQueryRequest(maintainerID ids.MaintainerID) helpers.QueryRequest { return &QueryRequest{Key: key.NewKey(maintainerID).(*key.Key)} } diff --git a/x/maintainers/queries/maintainer/query_request_test.go b/x/maintainers/queries/maintainer/query_request_test.go index 106e6a94f..ecd79e5b7 100644 --- a/x/maintainers/queries/maintainer/query_request_test.go +++ b/x/maintainers/queries/maintainer/query_request_test.go @@ -8,15 +8,13 @@ import ( "reflect" "testing" + "github.com/AssetMantle/modules/helpers" + "github.com/AssetMantle/modules/helpers/base" + "github.com/AssetMantle/modules/helpers/constants" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" "github.com/cosmos/cosmos-sdk/client" "github.com/spf13/viper" - "github.com/stretchr/testify/require" - - "github.com/AssetMantle/modules/helpers" - "github.com/AssetMantle/modules/helpers/base" - "github.com/AssetMantle/modules/helpers/constants" ) var ( @@ -61,85 +59,13 @@ func Test_queryRequestFromInterface(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - if got := queryRequestFromInterface(tt.args.request); !reflect.DeepEqual(got, tt.want) { + if got := tt.args.request.(*QueryRequest); !reflect.DeepEqual(got, tt.want) { t.Errorf("queryRequestFromInterface() = %v, want %v", got, tt.want) } }) } } -func Test_queryRequest_Decode(t *testing.T) { - encodedQuery, err := (&QueryRequest{testKey}).Encode() - require.NoError(t, err) - encodedQuery1, err := (&QueryRequest{testKey1}).Encode() - require.NoError(t, err) - type fields struct { - key *key.Key - } - type args struct { - bytes []byte - } - tests := []struct { - name string - fields fields - args args - want helpers.QueryRequest - wantErr bool - }{ - {"+ve", fields{testKey}, args{encodedQuery}, &QueryRequest{testKey}, false}, - {"+ve", fields{testKey1}, args{encodedQuery1}, &QueryRequest{testKey1}, false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - queryRequest := &QueryRequest{ - Key: tt.fields.key, - } - got, err := queryRequest.Decode(tt.args.bytes) - if (err != nil) != tt.wantErr { - t.Errorf("Decode() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("Decode() got = %v, want %v", got, tt.want) - } - }) - } -} - -func Test_queryRequest_Encode(t *testing.T) { - encodedQuery, err := base.CodecPrototype().GetLegacyAmino().MarshalJSON(&QueryRequest{testKey}) - require.NoError(t, err) - encodedQuery1, err := base.CodecPrototype().GetLegacyAmino().MarshalJSON(&QueryRequest{testKey1}) - require.NoError(t, err) - type fields struct { - key *key.Key - } - tests := []struct { - name string - fields fields - want []byte - wantErr bool - }{ - {"+ve", fields{testKey}, encodedQuery, false}, - {"+ve with nil", fields{testKey1}, encodedQuery1, false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - queryRequest := &QueryRequest{ - Key: tt.fields.key, - } - got, err := queryRequest.Encode() - if (err != nil) != tt.wantErr { - t.Errorf("Encode() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("Encode() got = %v, want %v", got, tt.want) - } - }) - } -} - func Test_queryRequest_FromCLI(t *testing.T) { cliCommand := base.NewCLICommand("", "", "", []helpers.CLIFlag{constants.MaintainerID}) viper.Set(constants.MaintainerID.GetName(), testMaintainerID.AsString()) diff --git a/x/maintainers/queries/maintainer/service.pb.go b/x/maintainers/queries/maintainer/service.pb.go index cda232622..f15e8a99c 100644 --- a/x/maintainers/queries/maintainer/service.pb.go +++ b/x/maintainers/queries/maintainer/service.pb.go @@ -8,7 +8,6 @@ import ( fmt "fmt" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" - _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -31,30 +30,28 @@ func init() { } var fileDescriptor_c025cc7a1d39ab0c = []byte{ - // 361 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x92, 0x31, 0x4b, 0xc3, 0x40, - 0x18, 0x86, 0x9b, 0x88, 0x1d, 0x82, 0x53, 0xc6, 0x22, 0x19, 0x1c, 0xc4, 0xe9, 0x8e, 0xaa, 0x83, - 0xde, 0xa2, 0x8d, 0x83, 0x75, 0x38, 0x68, 0x75, 0x09, 0x12, 0x90, 0x6b, 0xfb, 0x51, 0x0f, 0x92, - 0xbb, 0x36, 0x77, 0x29, 0x75, 0xf5, 0x17, 0x08, 0x4e, 0xae, 0x8e, 0xfe, 0x0b, 0x37, 0xd1, 0xa5, - 0xe0, 0xe2, 0x28, 0xa9, 0x93, 0xbf, 0x42, 0xda, 0x1c, 0x78, 0x5d, 0xd3, 0xf5, 0x0d, 0xef, 0xc3, - 0xf3, 0xe6, 0x3e, 0x2f, 0x6c, 0x29, 0x05, 0x9a, 0x32, 0xa1, 0x13, 0xc0, 0xa9, 0x1c, 0xe4, 0x09, - 0x28, 0x3c, 0xc5, 0x29, 0xe3, 0x42, 0x33, 0x2e, 0x20, 0x53, 0x78, 0x9c, 0x43, 0xc6, 0x41, 0x59, - 0x19, 0x56, 0x90, 0x4d, 0x78, 0x1f, 0xd0, 0x28, 0x93, 0x5a, 0xfa, 0x87, 0x16, 0x03, 0x19, 0x06, - 0x9a, 0x22, 0x8b, 0x81, 0x0c, 0xc3, 0xca, 0x1a, 0xdb, 0x43, 0x29, 0x87, 0x09, 0x60, 0x36, 0xe2, - 0x98, 0x09, 0x21, 0x35, 0xd3, 0x5c, 0x0a, 0x55, 0x32, 0x1b, 0xed, 0x4a, 0x5e, 0x8b, 0xe8, 0xee, - 0x26, 0x83, 0x71, 0x0e, 0x4a, 0x1b, 0xd2, 0xc5, 0x5a, 0x24, 0x35, 0x92, 0x42, 0x99, 0xa1, 0xfb, - 0x1f, 0x8e, 0xb7, 0xd9, 0x5d, 0x7c, 0xf0, 0x5f, 0x1d, 0xaf, 0xde, 0x66, 0x62, 0x90, 0x80, 0x1f, - 0xa2, 0x2a, 0xf3, 0xd1, 0x92, 0x73, 0x59, 0x9a, 0x36, 0xce, 0xd6, 0x62, 0x94, 0x8e, 0x3b, 0xe8, - 0xfe, 0xf3, 0xe7, 0xd1, 0xdd, 0xf3, 0x77, 0x71, 0x6a, 0xc6, 0x5a, 0x13, 0x27, 0xcd, 0x1e, 0x68, - 0xd6, 0xb4, 0xb2, 0xf0, 0x69, 0xe3, 0xad, 0x08, 0x9c, 0x59, 0x11, 0x38, 0xdf, 0x45, 0xe0, 0x3c, - 0xcc, 0x83, 0xda, 0x6c, 0x1e, 0xd4, 0xbe, 0xe6, 0x41, 0xcd, 0x3b, 0xea, 0xcb, 0xb4, 0x92, 0x52, - 0xb8, 0x75, 0x55, 0x9e, 0x46, 0x67, 0xf1, 0xc3, 0x3a, 0xce, 0xf5, 0xc9, 0x90, 0xeb, 0xdb, 0xbc, - 0x87, 0xfa, 0x32, 0xc5, 0x55, 0x1e, 0xe2, 0xd9, 0xad, 0xb7, 0x68, 0x44, 0xbb, 0xf4, 0xc5, 0x5d, - 0x39, 0x33, 0x6a, 0x84, 0x22, 0x44, 0x2d, 0xa1, 0xae, 0x11, 0xfa, 0xcf, 0xde, 0x57, 0x6a, 0xb1, - 0xa9, 0xc5, 0x51, 0x6c, 0xd5, 0x62, 0x53, 0xb3, 0xb2, 0xc2, 0x3d, 0xad, 0x52, 0x8b, 0xcf, 0x3b, - 0x21, 0x05, 0xcd, 0x06, 0x4c, 0xb3, 0x5f, 0xf7, 0xd8, 0x42, 0x10, 0x62, 0x18, 0x84, 0x44, 0x84, - 0x58, 0x14, 0x42, 0x0c, 0xc6, 0x4e, 0x7b, 0xf5, 0xe5, 0xc1, 0x1d, 0xfc, 0x05, 0x00, 0x00, 0xff, - 0xff, 0xcc, 0x0e, 0xfc, 0x4f, 0x9f, 0x03, 0x00, 0x00, + // 322 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x92, 0xb1, 0x4e, 0xf3, 0x30, + 0x14, 0x85, 0xe3, 0xfc, 0xfa, 0x3b, 0x44, 0x4c, 0x1d, 0x3b, 0x78, 0xe0, 0x01, 0x6c, 0x09, 0x18, + 0xc0, 0x0b, 0x34, 0x0c, 0x94, 0xc1, 0x52, 0x02, 0x4b, 0x84, 0x22, 0x21, 0x37, 0xb9, 0x82, 0x48, + 0x49, 0xdc, 0xc6, 0x0e, 0x2a, 0x6f, 0x81, 0xc4, 0xc4, 0xc0, 0xc2, 0xc8, 0x93, 0x20, 0xa6, 0x8e, + 0x8c, 0x28, 0xd9, 0x78, 0x0a, 0x94, 0xc6, 0x12, 0xee, 0x9a, 0xae, 0xc7, 0x3a, 0xdf, 0x39, 0xf7, + 0xfa, 0x7a, 0xfe, 0x54, 0x29, 0xd0, 0x5c, 0x94, 0x3a, 0x07, 0x5a, 0xc8, 0xb4, 0xce, 0x41, 0xd1, + 0x15, 0x2d, 0x44, 0x56, 0x6a, 0x91, 0x95, 0x50, 0x29, 0xba, 0xac, 0xa1, 0xca, 0x40, 0x59, 0x1a, + 0x55, 0x50, 0x3d, 0x64, 0x09, 0x90, 0x45, 0x25, 0xb5, 0x1c, 0x1f, 0x59, 0x0c, 0x62, 0x18, 0x64, + 0x45, 0x2c, 0x06, 0x31, 0x0c, 0x4b, 0x9b, 0xcc, 0x06, 0x25, 0x77, 0xd2, 0xe3, 0x6d, 0x05, 0xcb, + 0x1a, 0x94, 0xee, 0xf3, 0x27, 0x97, 0x3b, 0x91, 0xd4, 0x42, 0x96, 0xca, 0x8c, 0x72, 0xf0, 0x8a, + 0xbc, 0xff, 0x61, 0xf7, 0x30, 0x7e, 0x46, 0xde, 0x68, 0x26, 0xca, 0x34, 0x87, 0xb1, 0x4f, 0x86, + 0x0c, 0x48, 0x36, 0x9c, 0xab, 0xbe, 0xe9, 0xe4, 0x7c, 0x27, 0x46, 0xdf, 0x71, 0xdf, 0xf1, 0x5f, + 0xfe, 0x7d, 0x34, 0x18, 0xad, 0x1b, 0x8c, 0xbe, 0x1b, 0x8c, 0x9e, 0x5a, 0xec, 0xac, 0x5b, 0xec, + 0x7c, 0xb5, 0xd8, 0xf1, 0x8e, 0x13, 0x59, 0x0c, 0x0a, 0xf1, 0xf7, 0xae, 0xfb, 0xef, 0x0c, 0xba, + 0x15, 0x04, 0xe8, 0xe6, 0xf4, 0x2e, 0xd3, 0xf7, 0xf5, 0x9c, 0x24, 0xb2, 0xa0, 0x43, 0x56, 0xfb, + 0xe6, 0x8e, 0xa6, 0x3c, 0xe2, 0x21, 0x7f, 0x77, 0xb7, 0x4e, 0x83, 0x9b, 0x42, 0x11, 0xe1, 0x56, + 0xa1, 0xd0, 0x14, 0xfa, 0xd3, 0x3e, 0xb7, 0x6c, 0xb1, 0xb1, 0xc5, 0x51, 0x6c, 0xd9, 0x62, 0x63, + 0xb3, 0xb4, 0xc6, 0x3d, 0x1b, 0x62, 0x8b, 0x2f, 0x02, 0x9f, 0x83, 0x16, 0xa9, 0xd0, 0xe2, 0xc7, + 0x3d, 0xb1, 0x10, 0x8c, 0x19, 0x06, 0x63, 0x11, 0x63, 0x16, 0x85, 0x31, 0x83, 0xb1, 0xd5, 0xf9, + 0x68, 0x73, 0x42, 0x87, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x59, 0xcb, 0x51, 0x13, 0x53, 0x03, + 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/maintainers/queries/maintainer/service.pb.gw.go b/x/maintainers/queries/maintainer/service.pb.gw.go deleted file mode 100644 index 12689aa53..000000000 --- a/x/maintainers/queries/maintainer/service.pb.gw.go +++ /dev/null @@ -1,171 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: AssetMantle/modules/x/maintainers/queries/maintainer/service.proto - -/* -Package maintainer is a reverse proxy. - -It translates gRPC into RESTful JSON APIs. -*/ -package maintainer - -import ( - "context" - "io" - "net/http" - - "github.com/golang/protobuf/descriptor" - "github.com/golang/protobuf/proto" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/grpc-ecosystem/grpc-gateway/utilities" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/status" -) - -// Suppress "imported and not used" errors -var _ codes.Code -var _ io.Reader -var _ status.Status -var _ = runtime.String -var _ = utilities.NewDoubleArray -var _ = descriptor.ForMessage -var _ = metadata.Join - -var ( - filter_Query_Handle_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - -func request_Query_Handle_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryRequest - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.Handle(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_Handle_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryRequest - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.Handle(ctx, &protoReq) - return msg, metadata, err - -} - -// RegisterQueryHandlerServer registers the http handlers for service Query to "mux". -// UnaryRPC :call QueryServer directly. -// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. -func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { - - mux.Handle("GET", pattern_Query_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Query_Handle_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but -// automatically dials to "endpoint" and closes the connection when "ctx" gets done. -func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.Dial(endpoint, opts...) - if err != nil { - return err - } - defer func() { - if err != nil { - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - return - } - go func() { - <-ctx.Done() - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - }() - }() - - return RegisterQueryHandler(ctx, mux, conn) -} - -// RegisterQueryHandler registers the http handlers for service Query to "mux". -// The handlers forward requests to the grpc endpoint over "conn". -func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { - return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn)) -} - -// RegisterQueryHandlerClient registers the http handlers for service Query -// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient". -// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient" -// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "QueryClient" to call the correct interceptors. -func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { - - mux.Handle("GET", pattern_Query_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Query_Handle_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -var ( - pattern_Query_Handle_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"mantle", "maintainers", "v1beta1", "maintainer"}, "", runtime.AssumeColonVerbOpt(false))) -) - -var ( - forward_Query_Handle_0 = runtime.ForwardResponseMessage -) diff --git a/x/maintainers/queries/maintainers/query.go b/x/maintainers/queries/maintainers/query.go index 9210f7f0c..2dca5337a 100644 --- a/x/maintainers/queries/maintainers/query.go +++ b/x/maintainers/queries/maintainers/query.go @@ -4,26 +4,16 @@ package maintainers import ( - "context" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "google.golang.org/grpc" - "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" helperConstants "github.com/AssetMantle/modules/helpers/constants" - "github.com/AssetMantle/modules/utilities/name" - "github.com/AssetMantle/modules/x/maintainers/constants" + "google.golang.org/grpc" ) -type dummy struct{} - var Query = baseHelpers.NewQuery( - name.GetPackageName(dummy{}), + _Query_serviceDesc.ServiceName, "", "", - constants.ModuleName, requestPrototype, responsePrototype, @@ -32,9 +22,6 @@ var Query = baseHelpers.NewQuery( func(server grpc.ServiceRegistrar, QueryKeeper helpers.QueryKeeper) { RegisterQueryServer(server, QueryKeeper.(queryKeeper)) }, - func(clientContext client.Context, serveMux *runtime.ServeMux) error { - return RegisterQueryHandlerClient(context.Background(), serveMux, NewQueryClient(clientContext)) - }, helperConstants.MaintainerID, helperConstants.Limit, diff --git a/x/maintainers/queries/maintainers/query_keeper.go b/x/maintainers/queries/maintainers/query_keeper.go index 6bd48a10f..b89db8fd5 100644 --- a/x/maintainers/queries/maintainers/query_keeper.go +++ b/x/maintainers/queries/maintainers/query_keeper.go @@ -5,7 +5,6 @@ package maintainers import ( "context" - "github.com/AssetMantle/modules/helpers" ) @@ -16,7 +15,7 @@ type queryKeeper struct { var _ helpers.QueryKeeper = (*queryKeeper)(nil) func (queryKeeper queryKeeper) Enquire(context context.Context, queryRequest helpers.QueryRequest) (helpers.QueryResponse, error) { - queryResponse, err := queryKeeper.Handle(context, queryRequestFromInterface(queryRequest)) + queryResponse, err := queryKeeper.Handle(context, queryRequest.(*QueryRequest)) return queryResponse, err } func (queryKeeper queryKeeper) Handle(context context.Context, queryRequest *QueryRequest) (*QueryResponse, error) { diff --git a/x/maintainers/queries/maintainers/query_request.go b/x/maintainers/queries/maintainers/query_request.go index 00575bd3e..336b1ed59 100644 --- a/x/maintainers/queries/maintainers/query_request.go +++ b/x/maintainers/queries/maintainers/query_request.go @@ -13,7 +13,6 @@ import ( "github.com/cosmos/cosmos-sdk/types/query" "github.com/AssetMantle/modules/helpers" - "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/helpers/constants" "github.com/AssetMantle/modules/x/maintainers/key" ) @@ -71,30 +70,10 @@ func (*QueryRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.QueryRe return newQueryRequest(maintainerID.(ids.MaintainerID), int32(limit)), nil } -func (queryRequest *QueryRequest) Encode() ([]byte, error) { - return base.CodecPrototype().MarshalJSON(queryRequest) -} - -func (queryRequest *QueryRequest) Decode(bytes []byte) (helpers.QueryRequest, error) { - if err := base.CodecPrototype().UnmarshalJSON(bytes, queryRequest); err != nil { - return nil, err - } - - return queryRequest, nil -} func requestPrototype() helpers.QueryRequest { return &QueryRequest{} } -func queryRequestFromInterface(request helpers.QueryRequest) *QueryRequest { - switch value := request.(type) { - case *QueryRequest: - return value - default: - return &QueryRequest{} - } -} - func newQueryRequest(maintainerID ids.MaintainerID, limit int32) helpers.QueryRequest { return &QueryRequest{Key: key.NewKey(maintainerID).(*key.Key), Limit: limit} } diff --git a/x/maintainers/queries/maintainers/service.pb.go b/x/maintainers/queries/maintainers/service.pb.go index 71ab16b19..37d764696 100644 --- a/x/maintainers/queries/maintainers/service.pb.go +++ b/x/maintainers/queries/maintainers/service.pb.go @@ -8,7 +8,6 @@ import ( fmt "fmt" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" - _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -31,30 +30,27 @@ func init() { } var fileDescriptor_67e152e12e117b6c = []byte{ - // 366 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x92, 0x3f, 0x4b, 0xf3, 0x40, - 0x1c, 0xc7, 0x9b, 0x3c, 0x3c, 0x1d, 0xc2, 0x33, 0x65, 0x2c, 0x0f, 0x19, 0x5c, 0xc4, 0xe5, 0x8e, - 0x2a, 0x0e, 0xde, 0x64, 0x5b, 0xc1, 0x3f, 0x70, 0xd0, 0xea, 0x12, 0x24, 0x20, 0xd7, 0xf6, 0x47, - 0x3d, 0x48, 0xee, 0xda, 0xdc, 0xa5, 0xd4, 0xd5, 0x57, 0x20, 0xf8, 0x02, 0x04, 0x47, 0x5f, 0x87, - 0x83, 0x38, 0x48, 0xc1, 0xc5, 0x51, 0x52, 0x27, 0x5f, 0x85, 0xa4, 0xb9, 0xe1, 0xe2, 0x98, 0xae, - 0x9f, 0xe4, 0xfb, 0xe1, 0xfb, 0xfb, 0xdd, 0xcf, 0xeb, 0x75, 0x94, 0x02, 0x4d, 0x99, 0xd0, 0x31, - 0xe0, 0x44, 0x8e, 0xb3, 0x18, 0x14, 0x5e, 0xe0, 0x84, 0x71, 0xa1, 0x19, 0x17, 0x90, 0x2a, 0x3c, - 0xcb, 0x20, 0xe5, 0xa0, 0x2a, 0x4c, 0x41, 0x3a, 0xe7, 0x23, 0x40, 0xd3, 0x54, 0x6a, 0xe9, 0xef, - 0x5b, 0x12, 0x64, 0x24, 0x68, 0x81, 0xac, 0x00, 0x32, 0x12, 0x9b, 0xb5, 0xfe, 0x4f, 0xa4, 0x9c, - 0xc4, 0x80, 0xd9, 0x94, 0x63, 0x26, 0x84, 0xd4, 0x4c, 0x73, 0x29, 0x54, 0x29, 0x6d, 0x9d, 0xd6, - 0x6b, 0x56, 0xb0, 0x9b, 0xab, 0x14, 0x66, 0x19, 0x28, 0x6d, 0x54, 0x67, 0x9b, 0xa9, 0xd4, 0x54, - 0x0a, 0x65, 0x66, 0xdd, 0x7d, 0x73, 0xbc, 0xbf, 0x83, 0xe2, 0x83, 0xff, 0xec, 0x78, 0xcd, 0x13, - 0x26, 0xc6, 0x31, 0xf8, 0x3d, 0x54, 0x6b, 0x03, 0x68, 0x2d, 0x3a, 0x2f, 0xbb, 0xb6, 0x8e, 0x36, - 0x93, 0x94, 0x2d, 0xb7, 0xf0, 0xed, 0xfb, 0xd7, 0xbd, 0xbb, 0xe3, 0x6f, 0xe3, 0xc4, 0xcc, 0x6b, - 0x4d, 0x34, 0x6f, 0x0f, 0x41, 0xb3, 0xb6, 0xcd, 0xba, 0x0f, 0x7f, 0x5e, 0xf2, 0xc0, 0x59, 0xe6, - 0x81, 0xf3, 0x99, 0x07, 0xce, 0xdd, 0x2a, 0x68, 0x2c, 0x57, 0x41, 0xe3, 0x63, 0x15, 0x34, 0xbc, - 0x83, 0x91, 0x4c, 0xea, 0x95, 0xea, 0xfe, 0xbb, 0x28, 0x2f, 0xa4, 0x5f, 0x2c, 0xad, 0xef, 0x5c, - 0x1e, 0x4e, 0xb8, 0xbe, 0xce, 0x86, 0x68, 0x24, 0x13, 0x5c, 0xeb, 0x35, 0x1e, 0xdd, 0x66, 0x87, - 0x86, 0x74, 0x40, 0x9f, 0xdc, 0xca, 0xb9, 0x51, 0x53, 0x29, 0x44, 0xf4, 0xd7, 0x4e, 0x8a, 0x4a, - 0x16, 0x7b, 0xad, 0xe4, 0x22, 0x93, 0x8b, 0xc2, 0xc8, 0xfa, 0x27, 0x32, 0x39, 0x9b, 0xe5, 0x6e, - 0xa7, 0x56, 0x2e, 0x3a, 0xee, 0x77, 0x29, 0x68, 0x36, 0x66, 0x9a, 0x7d, 0xbb, 0xc4, 0x72, 0x10, - 0x62, 0x24, 0x84, 0x84, 0x84, 0x58, 0x11, 0x42, 0x8c, 0xa7, 0x42, 0x87, 0xcd, 0xf5, 0xe5, 0xed, - 0xfd, 0x04, 0x00, 0x00, 0xff, 0xff, 0x3f, 0x6e, 0xb6, 0x8c, 0xac, 0x03, 0x00, 0x00, + // 320 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x72, 0x76, 0x2c, 0x2e, 0x4e, + 0x2d, 0xf1, 0x4d, 0xcc, 0x2b, 0xc9, 0x49, 0xd5, 0xcf, 0xcd, 0x4f, 0x29, 0xcd, 0x49, 0x2d, 0xd6, + 0xaf, 0xd0, 0xcf, 0x4d, 0xcc, 0xcc, 0x2b, 0x49, 0xcc, 0xcc, 0x4b, 0x2d, 0x2a, 0xd6, 0x2f, 0x2c, + 0x4d, 0x2d, 0xca, 0x4c, 0x2d, 0x46, 0x11, 0x2b, 0x4e, 0x2d, 0x2a, 0xcb, 0x4c, 0x4e, 0xd5, 0x2b, + 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x32, 0x45, 0x32, 0x44, 0x0f, 0x6a, 0x88, 0x5e, 0x85, 0x1e, 0x92, + 0x06, 0x3d, 0xa8, 0x21, 0xc8, 0x62, 0x52, 0x9e, 0xe4, 0xd9, 0x0d, 0x12, 0xab, 0x8c, 0x2f, 0x4a, + 0x2d, 0x2c, 0x4d, 0x2d, 0x2e, 0x81, 0xb8, 0x40, 0xca, 0x8b, 0x32, 0xa3, 0x8a, 0x0b, 0xf2, 0xf3, + 0x8a, 0xa1, 0xbe, 0x31, 0x9a, 0xcf, 0xc8, 0xc5, 0x1a, 0x08, 0x92, 0x10, 0x9a, 0xca, 0xc8, 0xc5, + 0xe6, 0x91, 0x98, 0x97, 0x92, 0x93, 0x2a, 0xe4, 0xac, 0x47, 0x96, 0x1f, 0xf5, 0xc0, 0x06, 0x05, + 0x41, 0xdc, 0x2a, 0xe5, 0x42, 0x99, 0x21, 0x10, 0x57, 0x2a, 0x31, 0x38, 0xcd, 0x67, 0x3e, 0xf1, + 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4, 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8, + 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, 0x06, 0x2e, 0xcb, 0xe4, 0xfc, 0x5c, 0xf2, 0x6c, 0x71, + 0xe2, 0x09, 0x86, 0x44, 0x6a, 0x00, 0x28, 0x14, 0x02, 0x18, 0xa3, 0x1c, 0xd2, 0x33, 0x4b, 0x32, + 0x4a, 0x93, 0xf4, 0x92, 0xf3, 0x73, 0xf5, 0xc9, 0x0a, 0xde, 0x45, 0x4c, 0x6c, 0x8e, 0xbe, 0x11, + 0xbe, 0x81, 0xbe, 0xab, 0x98, 0x50, 0x52, 0x88, 0x2f, 0xd4, 0x49, 0x11, 0x7a, 0xbe, 0x68, 0x9e, + 0x04, 0x39, 0x09, 0x49, 0xec, 0x14, 0x8a, 0xbe, 0x18, 0xa8, 0xbe, 0x98, 0x88, 0x18, 0x24, 0x35, + 0x31, 0x50, 0x7d, 0xc8, 0x62, 0x8f, 0x98, 0x1c, 0xc9, 0xd2, 0x17, 0xe3, 0x1e, 0xe0, 0xe4, 0x9b, + 0x5a, 0x92, 0x98, 0x92, 0x58, 0x92, 0xf8, 0x8a, 0xc9, 0x0a, 0xc9, 0x0c, 0x2b, 0x2b, 0xa8, 0x21, + 0x56, 0x56, 0x11, 0x56, 0x56, 0x48, 0x5a, 0xac, 0xac, 0xa0, 0xe6, 0xa0, 0x88, 0x26, 0xb1, 0x81, + 0x93, 0x92, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0xd2, 0xe5, 0x11, 0x91, 0x5f, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/maintainers/queries/maintainers/service.pb.gw.go b/x/maintainers/queries/maintainers/service.pb.gw.go deleted file mode 100644 index ec517dff6..000000000 --- a/x/maintainers/queries/maintainers/service.pb.gw.go +++ /dev/null @@ -1,171 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: AssetMantle/modules/x/maintainers/queries/maintainers/service.proto - -/* -Package maintainers is a reverse proxy. - -It translates gRPC into RESTful JSON APIs. -*/ -package maintainers - -import ( - "context" - "io" - "net/http" - - "github.com/golang/protobuf/descriptor" - "github.com/golang/protobuf/proto" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/grpc-ecosystem/grpc-gateway/utilities" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/status" -) - -// Suppress "imported and not used" errors -var _ codes.Code -var _ io.Reader -var _ status.Status -var _ = runtime.String -var _ = utilities.NewDoubleArray -var _ = descriptor.ForMessage -var _ = metadata.Join - -var ( - filter_Query_Handle_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - -func request_Query_Handle_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryRequest - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.Handle(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_Handle_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryRequest - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.Handle(ctx, &protoReq) - return msg, metadata, err - -} - -// RegisterQueryHandlerServer registers the http handlers for service Query to "mux". -// UnaryRPC :call QueryServer directly. -// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. -func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { - - mux.Handle("GET", pattern_Query_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Query_Handle_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but -// automatically dials to "endpoint" and closes the connection when "ctx" gets done. -func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.Dial(endpoint, opts...) - if err != nil { - return err - } - defer func() { - if err != nil { - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - return - } - go func() { - <-ctx.Done() - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - }() - }() - - return RegisterQueryHandler(ctx, mux, conn) -} - -// RegisterQueryHandler registers the http handlers for service Query to "mux". -// The handlers forward requests to the grpc endpoint over "conn". -func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { - return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn)) -} - -// RegisterQueryHandlerClient registers the http handlers for service Query -// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient". -// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient" -// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "QueryClient" to call the correct interceptors. -func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { - - mux.Handle("GET", pattern_Query_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Query_Handle_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -var ( - pattern_Query_Handle_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 1}, []string{"mantle", "maintainers", "v1beta1"}, "", runtime.AssumeColonVerbOpt(false))) -) - -var ( - forward_Query_Handle_0 = runtime.ForwardResponseMessage -) diff --git a/x/maintainers/queries/parameters/query.go b/x/maintainers/queries/parameters/query.go new file mode 100644 index 000000000..cfe5be8fe --- /dev/null +++ b/x/maintainers/queries/parameters/query.go @@ -0,0 +1,21 @@ +package parameters + +import ( + "github.com/AssetMantle/modules/helpers" + baseHelpers "github.com/AssetMantle/modules/helpers/base" + "google.golang.org/grpc" +) + +var Query = baseHelpers.NewQuery( + _Query_serviceDesc.ServiceName, + "", + "", + + requestPrototype, + responsePrototype, + keeperPrototype, + + func(server grpc.ServiceRegistrar, QueryKeeper helpers.QueryKeeper) { + RegisterQueryServer(server, QueryKeeper.(queryKeeper)) + }, +) diff --git a/x/maintainers/queries/parameters/query_keeper.go b/x/maintainers/queries/parameters/query_keeper.go new file mode 100644 index 000000000..5ff196b53 --- /dev/null +++ b/x/maintainers/queries/parameters/query_keeper.go @@ -0,0 +1,31 @@ +package parameters + +import ( + "context" + "github.com/AssetMantle/modules/helpers" +) + +type queryKeeper struct { + parameterManager helpers.ParameterManager +} + +var _ helpers.QueryKeeper = (*queryKeeper)(nil) + +func (queryKeeper queryKeeper) Enquire(context context.Context, queryRequest helpers.QueryRequest) (helpers.QueryResponse, error) { + queryResponse, err := queryKeeper.Handle(context, queryRequest.(*QueryRequest)) + return queryResponse, err +} +func (queryKeeper queryKeeper) Handle(context context.Context, queryRequest *QueryRequest) (*QueryResponse, error) { + if err := queryRequest.Validate(); err != nil { + return nil, err + } + return newQueryResponse(queryKeeper.parameterManager.Fetch(context).Get()), nil +} +func (queryKeeper queryKeeper) Initialize(_ helpers.Mapper, parameterManager helpers.ParameterManager, _ []interface{}) helpers.Keeper { + queryKeeper.parameterManager = parameterManager + return queryKeeper +} + +func keeperPrototype() helpers.QueryKeeper { + return queryKeeper{} +} diff --git a/x/maintainers/queries/parameters/query_request.go b/x/maintainers/queries/parameters/query_request.go new file mode 100644 index 000000000..9f99e7a01 --- /dev/null +++ b/x/maintainers/queries/parameters/query_request.go @@ -0,0 +1,25 @@ +package parameters + +import ( + "github.com/AssetMantle/modules/helpers" + "github.com/cosmos/cosmos-sdk/client" + "net/http" +) + +var _ helpers.QueryRequest = (*QueryRequest)(nil) + +func (queryRequest *QueryRequest) Validate() error { + return nil +} + +func (queryRequest *QueryRequest) FromCLI(_ helpers.CLICommand, _ client.Context) (helpers.QueryRequest, error) { + return requestPrototype(), nil +} + +func (queryRequest *QueryRequest) FromHTTPRequest(_ *http.Request) (helpers.QueryRequest, error) { + return requestPrototype(), nil +} + +func requestPrototype() helpers.QueryRequest { + return &QueryRequest{} +} diff --git a/x/maintainers/queries/parameters/query_request.pb.go b/x/maintainers/queries/parameters/query_request.pb.go new file mode 100644 index 000000000..179a61610 --- /dev/null +++ b/x/maintainers/queries/parameters/query_request.pb.go @@ -0,0 +1,273 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: AssetMantle/modules/x/maintainers/queries/parameters/query_request.proto + +package parameters + +import ( + fmt "fmt" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type QueryRequest struct { +} + +func (m *QueryRequest) Reset() { *m = QueryRequest{} } +func (m *QueryRequest) String() string { return proto.CompactTextString(m) } +func (*QueryRequest) ProtoMessage() {} +func (*QueryRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_b36a0b42da9d73d2, []int{0} +} +func (m *QueryRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryRequest.Merge(m, src) +} +func (m *QueryRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryRequest proto.InternalMessageInfo + +func init() { + proto.RegisterType((*QueryRequest)(nil), "AssetMantle.modules.x.maintainers.queries.parameters.QueryRequest") +} + +func init() { + proto.RegisterFile("AssetMantle/modules/x/maintainers/queries/parameters/query_request.proto", fileDescriptor_b36a0b42da9d73d2) +} + +var fileDescriptor_b36a0b42da9d73d2 = []byte{ + // 277 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xf2, 0x70, 0x2c, 0x2e, 0x4e, + 0x2d, 0xf1, 0x4d, 0xcc, 0x2b, 0xc9, 0x49, 0xd5, 0xcf, 0xcd, 0x4f, 0x29, 0xcd, 0x49, 0x2d, 0xd6, + 0xaf, 0xd0, 0xcf, 0x4d, 0xcc, 0xcc, 0x2b, 0x49, 0xcc, 0xcc, 0x4b, 0x2d, 0x2a, 0xd6, 0x2f, 0x2c, + 0x4d, 0x2d, 0xca, 0x4c, 0x2d, 0xd6, 0x2f, 0x48, 0x2c, 0x4a, 0xcc, 0x4d, 0x2d, 0x81, 0x09, 0x55, + 0xc6, 0x17, 0xa5, 0x16, 0x96, 0xa6, 0x16, 0x97, 0xe8, 0x15, 0x14, 0xe5, 0x97, 0xe4, 0x0b, 0x99, + 0x20, 0x99, 0xa4, 0x07, 0x35, 0x49, 0xaf, 0x42, 0x0f, 0xc9, 0x24, 0x3d, 0xa8, 0x49, 0x7a, 0x08, + 0x93, 0x94, 0xf8, 0xb8, 0x78, 0x02, 0x41, 0x86, 0x05, 0x41, 0xcc, 0x72, 0x9a, 0xc7, 0x7c, 0xe2, + 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, 0xc9, 0x31, 0x4e, 0x78, 0x2c, 0xc7, 0x70, + 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, 0x0c, 0x5c, 0x16, 0xc9, 0xf9, 0xb9, 0x7a, 0xe4, 0x58, + 0xe2, 0x24, 0x88, 0x6c, 0x45, 0x00, 0xc8, 0xb5, 0x01, 0x8c, 0x51, 0xf6, 0xe9, 0x99, 0x25, 0x19, + 0xa5, 0x49, 0x7a, 0xc9, 0xf9, 0xb9, 0xfa, 0xe4, 0x04, 0xc2, 0x22, 0x26, 0x36, 0x47, 0xdf, 0x08, + 0xdf, 0xc0, 0x80, 0x55, 0x4c, 0x28, 0x5e, 0xf7, 0x85, 0xba, 0x2a, 0x42, 0xcf, 0x17, 0xc9, 0x55, + 0x81, 0x50, 0x57, 0x05, 0xc0, 0xf5, 0x9f, 0x42, 0xd1, 0x16, 0x03, 0xd5, 0x16, 0x13, 0x11, 0x83, + 0xa4, 0x2d, 0x06, 0xaa, 0x2d, 0x06, 0xa1, 0xed, 0x11, 0x93, 0x03, 0x39, 0xda, 0x62, 0xdc, 0x03, + 0x9c, 0x7c, 0x53, 0x4b, 0x12, 0x53, 0x12, 0x4b, 0x12, 0x5f, 0x31, 0x59, 0x22, 0x19, 0x61, 0x65, + 0x05, 0x35, 0xc3, 0xca, 0x2a, 0xc2, 0xca, 0x0a, 0xc9, 0x14, 0x2b, 0x2b, 0xa8, 0x31, 0x56, 0x56, + 0x08, 0x73, 0x92, 0xd8, 0xc0, 0xb1, 0x6d, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0x3f, 0xb6, 0x5a, + 0x9d, 0x39, 0x02, 0x00, 0x00, +} + +func (m *QueryRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func encodeVarintQueryRequest(dAtA []byte, offset int, v uint64) int { + offset -= sovQueryRequest(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *QueryRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func sovQueryRequest(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQueryRequest(x uint64) (n int) { + return sovQueryRequest(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QueryRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQueryRequest + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQueryRequest(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQueryRequest + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipQueryRequest(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQueryRequest + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQueryRequest + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQueryRequest + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthQueryRequest + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupQueryRequest + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthQueryRequest + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthQueryRequest = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowQueryRequest = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupQueryRequest = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/maintainers/queries/parameters/query_response.go b/x/maintainers/queries/parameters/query_response.go new file mode 100644 index 000000000..4d34b8543 --- /dev/null +++ b/x/maintainers/queries/parameters/query_response.go @@ -0,0 +1,29 @@ +package parameters + +import ( + "github.com/AssetMantle/modules/helpers" + "github.com/AssetMantle/modules/helpers/base" + "github.com/AssetMantle/schema/lists" + baseLists "github.com/AssetMantle/schema/lists/base" +) + +var _ helpers.QueryResponse = (*QueryResponse)(nil) + +func (queryResponse *QueryResponse) Encode() ([]byte, error) { + return base.CodecPrototype().MarshalJSON(queryResponse) +} +func (queryResponse *QueryResponse) Decode(bytes []byte) (helpers.QueryResponse, error) { + if err := base.CodecPrototype().UnmarshalJSON(bytes, queryResponse); err != nil { + return nil, err + } + + return queryResponse, nil +} +func responsePrototype() helpers.QueryResponse { + return &QueryResponse{} +} +func newQueryResponse(parameterList lists.ParameterList) *QueryResponse { + return &QueryResponse{ + ParameterList: parameterList.(*baseLists.ParameterList), + } +} diff --git a/x/maintainers/queries/parameters/query_response.pb.go b/x/maintainers/queries/parameters/query_response.pb.go new file mode 100644 index 000000000..f56874c80 --- /dev/null +++ b/x/maintainers/queries/parameters/query_response.pb.go @@ -0,0 +1,338 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: AssetMantle/modules/x/maintainers/queries/parameters/query_response.proto + +package parameters + +import ( + fmt "fmt" + base "github.com/AssetMantle/schema/lists/base" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type QueryResponse struct { + ParameterList *base.ParameterList `protobuf:"bytes,1,opt,name=parameter_list,json=parameterList,proto3" json:"parameter_list,omitempty"` +} + +func (m *QueryResponse) Reset() { *m = QueryResponse{} } +func (m *QueryResponse) String() string { return proto.CompactTextString(m) } +func (*QueryResponse) ProtoMessage() {} +func (*QueryResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_59b5887fbbb5c9f6, []int{0} +} +func (m *QueryResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryResponse.Merge(m, src) +} +func (m *QueryResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryResponse proto.InternalMessageInfo + +func (m *QueryResponse) GetParameterList() *base.ParameterList { + if m != nil { + return m.ParameterList + } + return nil +} + +func init() { + proto.RegisterType((*QueryResponse)(nil), "AssetMantle.modules.x.maintainers.queries.parameters.QueryResponse") +} + +func init() { + proto.RegisterFile("AssetMantle/modules/x/maintainers/queries/parameters/query_response.proto", fileDescriptor_59b5887fbbb5c9f6) +} + +var fileDescriptor_59b5887fbbb5c9f6 = []byte{ + // 337 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x92, 0x31, 0x4b, 0xc3, 0x40, + 0x14, 0x80, 0x9b, 0x08, 0x1d, 0x22, 0x75, 0xe8, 0x24, 0x0e, 0x41, 0x9c, 0x1c, 0xe4, 0x1d, 0x54, + 0x07, 0xbd, 0x45, 0xdb, 0x45, 0x04, 0x03, 0x69, 0x5d, 0x82, 0x04, 0xca, 0xb5, 0x7d, 0xd8, 0x40, + 0x2f, 0x17, 0xf3, 0xae, 0x50, 0xff, 0x85, 0xff, 0x40, 0x70, 0xf4, 0x97, 0x88, 0x53, 0x47, 0x47, + 0x49, 0x37, 0x7f, 0x85, 0xa4, 0xbd, 0x9a, 0xcb, 0xda, 0x31, 0x47, 0xbe, 0xef, 0xbe, 0xc7, 0x3b, + 0xef, 0xae, 0x4b, 0x84, 0x3a, 0x10, 0xa9, 0x9e, 0x21, 0x93, 0x6a, 0x32, 0x9f, 0x21, 0xb1, 0x05, + 0x93, 0x22, 0x49, 0xb5, 0x48, 0x52, 0xcc, 0x89, 0x3d, 0xcf, 0x31, 0x4f, 0x90, 0x58, 0x26, 0x72, + 0x21, 0x51, 0x6f, 0x8f, 0x5e, 0x86, 0x39, 0x52, 0xa6, 0x52, 0x42, 0xc8, 0x72, 0xa5, 0x55, 0xfb, + 0xc2, 0x52, 0x81, 0x51, 0xc1, 0x02, 0x2c, 0x15, 0x18, 0x15, 0x54, 0xaa, 0xa3, 0x8e, 0x1d, 0x40, + 0xe3, 0x29, 0x4a, 0xc1, 0x66, 0x09, 0x69, 0x62, 0x23, 0x41, 0x58, 0x5d, 0x3a, 0x2c, 0x0f, 0x37, + 0x37, 0x9d, 0x4c, 0xbc, 0x56, 0xbf, 0x2c, 0x18, 0x98, 0x80, 0xf6, 0x83, 0x77, 0x50, 0xff, 0xf1, + 0xd0, 0x39, 0x76, 0x4e, 0xf7, 0x3b, 0x67, 0x60, 0x37, 0x6d, 0xec, 0xb0, 0xb6, 0x43, 0x69, 0x87, + 0x70, 0x0b, 0xdd, 0x27, 0xa4, 0x07, 0xad, 0xcc, 0xfe, 0xec, 0xbd, 0xed, 0x7d, 0x16, 0xbe, 0xb3, + 0x2c, 0x7c, 0xe7, 0xa7, 0xf0, 0x9d, 0xd7, 0x95, 0xdf, 0x58, 0xae, 0xfc, 0xc6, 0xf7, 0xca, 0x6f, + 0x78, 0x97, 0x63, 0x25, 0x61, 0x97, 0x71, 0x7b, 0xed, 0x5a, 0x78, 0x58, 0x8e, 0x13, 0x3a, 0x8f, + 0xd7, 0x4f, 0x89, 0x9e, 0xce, 0x47, 0x30, 0x56, 0x92, 0xed, 0xb2, 0x90, 0x77, 0xb7, 0xd9, 0x0d, + 0xa2, 0xa0, 0x1f, 0x7e, 0xb8, 0xb5, 0x2d, 0x04, 0x26, 0x2b, 0x82, 0xc0, 0xca, 0xea, 0x9b, 0xac, + 0xff, 0xe9, 0xe9, 0xab, 0x86, 0xc5, 0x06, 0x8b, 0xa3, 0xd8, 0xc2, 0x62, 0x83, 0xc5, 0x15, 0x56, + 0xb8, 0x37, 0xbb, 0x60, 0xf1, 0x6d, 0xd8, 0x0b, 0x50, 0x8b, 0x89, 0xd0, 0xe2, 0xd7, 0xbd, 0xb2, + 0x14, 0x9c, 0x1b, 0x07, 0xe7, 0x11, 0xe7, 0x96, 0x85, 0x73, 0xa3, 0xe1, 0xbc, 0xf2, 0x8c, 0x9a, + 0xeb, 0xe7, 0x70, 0xfe, 0x17, 0x00, 0x00, 0xff, 0xff, 0xe0, 0x40, 0x68, 0x17, 0xc5, 0x02, 0x00, + 0x00, +} + +func (m *QueryResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.ParameterList != nil { + { + size, err := m.ParameterList.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQueryResponse(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintQueryResponse(dAtA []byte, offset int, v uint64) int { + offset -= sovQueryResponse(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *QueryResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ParameterList != nil { + l = m.ParameterList.Size() + n += 1 + l + sovQueryResponse(uint64(l)) + } + return n +} + +func sovQueryResponse(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQueryResponse(x uint64) (n int) { + return sovQueryResponse(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QueryResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQueryResponse + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ParameterList", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQueryResponse + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQueryResponse + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQueryResponse + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.ParameterList == nil { + m.ParameterList = &base.ParameterList{} + } + if err := m.ParameterList.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQueryResponse(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQueryResponse + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipQueryResponse(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQueryResponse + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQueryResponse + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQueryResponse + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthQueryResponse + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupQueryResponse + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthQueryResponse + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthQueryResponse = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowQueryResponse = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupQueryResponse = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/maintainers/queries/parameters/service.pb.go b/x/maintainers/queries/parameters/service.pb.go new file mode 100644 index 000000000..88fe45abd --- /dev/null +++ b/x/maintainers/queries/parameters/service.pb.go @@ -0,0 +1,135 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: AssetMantle/modules/x/maintainers/queries/parameters/service.proto + +package parameters + +import ( + context "context" + fmt "fmt" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + math "math" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +func init() { + proto.RegisterFile("AssetMantle/modules/x/maintainers/queries/parameters/service.proto", fileDescriptor_704b067079f061fa) +} + +var fileDescriptor_704b067079f061fa = []byte{ + // 331 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x92, 0xb1, 0x4e, 0xf3, 0x30, + 0x10, 0xc7, 0xe3, 0x7c, 0xfa, 0x3a, 0x44, 0x4c, 0x1d, 0x3b, 0x78, 0xe0, 0x01, 0x6c, 0x09, 0x18, + 0xc0, 0x0b, 0x34, 0x0c, 0x94, 0xc1, 0x52, 0x0a, 0x4b, 0x84, 0x2c, 0x21, 0xb7, 0x3d, 0x41, 0xa4, + 0x26, 0x6e, 0x6d, 0x07, 0x95, 0xb7, 0x40, 0x62, 0x62, 0x60, 0x61, 0xe4, 0x49, 0x10, 0x53, 0x47, + 0x46, 0x94, 0x6e, 0x3c, 0x05, 0x4a, 0x63, 0x51, 0x77, 0x4d, 0xd7, 0xb3, 0x7e, 0xbf, 0xfb, 0xdf, + 0xf9, 0xa2, 0xb8, 0x6f, 0x0c, 0x58, 0x2e, 0x0b, 0x3b, 0x05, 0x9a, 0xab, 0x49, 0x39, 0x05, 0x43, + 0x17, 0x34, 0x97, 0x59, 0x61, 0x65, 0x56, 0x80, 0x36, 0x74, 0x5e, 0x82, 0xce, 0xc0, 0xd0, 0x99, + 0xd4, 0x32, 0x07, 0x5b, 0x97, 0x0c, 0xe8, 0x87, 0x6c, 0x0c, 0x64, 0xa6, 0x95, 0x55, 0xdd, 0x23, + 0xcf, 0x41, 0x9c, 0x83, 0x2c, 0x88, 0xe7, 0x20, 0xce, 0x41, 0x36, 0x8e, 0xde, 0xa0, 0x55, 0xe7, + 0xba, 0xf4, 0x78, 0xab, 0x61, 0x5e, 0x82, 0xb1, 0x4d, 0xff, 0xde, 0xe5, 0x4e, 0x26, 0x33, 0x53, + 0x85, 0x71, 0xa3, 0x1c, 0xbc, 0xa2, 0xe8, 0xff, 0xb0, 0x7e, 0xe8, 0x3e, 0xa3, 0xa8, 0x33, 0x90, + 0xc5, 0x64, 0x0a, 0xdd, 0x98, 0xb4, 0x19, 0x90, 0xac, 0x3d, 0x57, 0x4d, 0xd2, 0xde, 0xf9, 0x4e, + 0x8e, 0x26, 0xe3, 0x7e, 0x10, 0xbf, 0xfc, 0xfb, 0xa8, 0x30, 0x5a, 0x56, 0x18, 0x7d, 0x57, 0x18, + 0x3d, 0xad, 0x70, 0xb0, 0x5c, 0xe1, 0xe0, 0x6b, 0x85, 0x83, 0xe8, 0x78, 0xac, 0xf2, 0x56, 0x4d, + 0xe2, 0xbd, 0xeb, 0xe6, 0x3b, 0x93, 0x7a, 0x05, 0x09, 0xba, 0x39, 0xbd, 0xcb, 0xec, 0x7d, 0x39, + 0x22, 0x63, 0x95, 0xd3, 0x36, 0xab, 0x7d, 0x0b, 0x3b, 0x7d, 0x9e, 0xf2, 0x61, 0xf2, 0x1e, 0x6e, + 0x9d, 0x06, 0x77, 0x81, 0x52, 0xc2, 0xbd, 0x40, 0x43, 0x17, 0x28, 0xf9, 0xe3, 0x3f, 0xb7, 0x30, + 0xe1, 0x30, 0x91, 0x0a, 0x0f, 0x13, 0x0e, 0x13, 0x1b, 0xac, 0x0a, 0xcf, 0xda, 0x60, 0xe2, 0x22, + 0x89, 0x39, 0x58, 0x39, 0x91, 0x56, 0xfe, 0x84, 0x27, 0x9e, 0x82, 0x31, 0xe7, 0x60, 0x2c, 0x65, + 0xcc, 0xb3, 0x30, 0xe6, 0x34, 0x8c, 0x6d, 0x3c, 0xa3, 0xce, 0xfa, 0x84, 0x0e, 0x7f, 0x03, 0x00, + 0x00, 0xff, 0xff, 0xef, 0x5f, 0xa7, 0xa7, 0x53, 0x03, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// QueryClient is the client API for Query service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type QueryClient interface { + Handle(ctx context.Context, in *QueryRequest, opts ...grpc.CallOption) (*QueryResponse, error) +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +func (c *queryClient) Handle(ctx context.Context, in *QueryRequest, opts ...grpc.CallOption) (*QueryResponse, error) { + out := new(QueryResponse) + err := c.cc.Invoke(ctx, "/AssetMantle.modules.x.maintainers.queries.parameters.Query/Handle", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +type QueryServer interface { + Handle(context.Context, *QueryRequest) (*QueryResponse, error) +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func (*UnimplementedQueryServer) Handle(ctx context.Context, req *QueryRequest) (*QueryResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Handle not implemented") +} + +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) +} + +func _Query_Handle_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Handle(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/AssetMantle.modules.x.maintainers.queries.parameters.Query/Handle", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Handle(ctx, req.(*QueryRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "AssetMantle.modules.x.maintainers.queries.parameters.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Handle", + Handler: _Query_Handle_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "AssetMantle/modules/x/maintainers/queries/parameters/service.proto", +} diff --git a/x/maintainers/queries/prototype.go b/x/maintainers/queries/prototype.go index dde99b17d..25fa018ea 100644 --- a/x/maintainers/queries/prototype.go +++ b/x/maintainers/queries/prototype.go @@ -8,11 +8,13 @@ import ( baseHelpers "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/x/maintainers/queries/maintainer" "github.com/AssetMantle/modules/x/maintainers/queries/maintainers" + "github.com/AssetMantle/modules/x/maintainers/queries/parameters" ) func Prototype() helpers.Queries { return baseHelpers.NewQueries( maintainer.Query, maintainers.Query, + parameters.Query, ) } diff --git a/x/maintainers/queries/prototype_test.go b/x/maintainers/queries/prototype_test.go index 54ab8b1f6..52bebac4f 100644 --- a/x/maintainers/queries/prototype_test.go +++ b/x/maintainers/queries/prototype_test.go @@ -14,8 +14,8 @@ import ( func TestPrototype(t *testing.T) { require.Panics(t, func() { - require.Equal(t, Prototype().GetQuery("maintainer").GetName(), baseHelpers.NewQueries( + require.Equal(t, Prototype().GetQuery("maintainer").GetServicePath(), baseHelpers.NewQueries( maintainer.Query, - ).GetQuery("maintainer").GetName()) + ).GetQuery("maintainer").GetServicePath()) }) } diff --git a/x/maintainers/record/record.go b/x/maintainers/record/record.go index 1b7517c4a..a02dd30eb 100644 --- a/x/maintainers/record/record.go +++ b/x/maintainers/record/record.go @@ -1,6 +1,10 @@ package record import ( + "github.com/AssetMantle/modules/helpers" + "github.com/AssetMantle/modules/helpers/base" + "github.com/AssetMantle/modules/x/maintainers/key" + "github.com/AssetMantle/modules/x/maintainers/mappable" baseData "github.com/AssetMantle/schema/data/base" "github.com/AssetMantle/schema/documents" baseDocuments "github.com/AssetMantle/schema/documents/base" @@ -10,11 +14,6 @@ import ( constantProperties "github.com/AssetMantle/schema/properties/constants" baseQualified "github.com/AssetMantle/schema/qualified/base" sdkTypes "github.com/cosmos/cosmos-sdk/types" - - "github.com/AssetMantle/modules/helpers" - "github.com/AssetMantle/modules/helpers/base" - "github.com/AssetMantle/modules/x/maintainers/key" - "github.com/AssetMantle/modules/x/maintainers/mappable" ) func (record *Record) GetKey() helpers.Key { diff --git a/x/maintainers/simulator/genesis.go b/x/maintainers/simulator/genesis.go index e063f96aa..f6c8fe5cd 100644 --- a/x/maintainers/simulator/genesis.go +++ b/x/maintainers/simulator/genesis.go @@ -4,8 +4,6 @@ package simulator import ( - "math/rand" - "github.com/AssetMantle/schema/data" baseData "github.com/AssetMantle/schema/data/base" "github.com/AssetMantle/schema/documents/base" @@ -16,6 +14,7 @@ import ( baseQualified "github.com/AssetMantle/schema/qualified/base" sdkTypes "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" + "math/rand" "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" diff --git a/x/maintainers/simulator/operations.go b/x/maintainers/simulator/operations.go index 9b2ee1b23..524fa0e87 100644 --- a/x/maintainers/simulator/operations.go +++ b/x/maintainers/simulator/operations.go @@ -4,10 +4,9 @@ package simulator import ( - "math/rand" - "github.com/cosmos/cosmos-sdk/types/module" "github.com/cosmos/cosmos-sdk/x/simulation" + "math/rand" "github.com/AssetMantle/modules/helpers" ) diff --git a/x/maintainers/simulator/proposals.go b/x/maintainers/simulator/proposals.go index 72d20f254..53aac918f 100644 --- a/x/maintainers/simulator/proposals.go +++ b/x/maintainers/simulator/proposals.go @@ -4,28 +4,28 @@ package simulator import ( - "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" - "math/rand" - - sdk "github.com/cosmos/cosmos-sdk/types" + sdkTypes "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" simulationTypes "github.com/cosmos/cosmos-sdk/types/simulation" + govSimulation "github.com/cosmos/cosmos-sdk/x/gov/simulation" + "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" "github.com/cosmos/cosmos-sdk/x/simulation" + "math/rand" ) -func (simulator) WeightedProposalContentList(module.SimulationState) []simulationTypes.WeightedProposalContent { - return []simulationTypes.WeightedProposalContent{ - simulation.NewWeightedProposalContent( +func (simulator) ProposalMessages(_ module.SimulationState) []simulationTypes.WeightedProposalMsg { + return []simulationTypes.WeightedProposalMsg{ + simulation.NewWeightedProposalMsg( OpWeightSubmitTextProposal, DefaultWeightTextProposal, - simulateTextProposalContent, + func(r *rand.Rand, _ sdkTypes.Context, simulationAccounts []simulationTypes.Account) sdkTypes.Msg { + msgSubmitProposal, err := v1beta1.NewMsgSubmitProposal(v1beta1.NewTextProposal(simulationTypes.RandStringOfLength(r, 140), simulationTypes.RandStringOfLength(r, 5000)), govSimulation.GenDepositParamsMinDeposit(r), simulationAccounts[r.Intn(len(simulationAccounts))].Address) + if err != nil { + panic(err) + } + + return msgSubmitProposal + }, ), } } - -func simulateTextProposalContent(r *rand.Rand, _ sdk.Context, _ []simulationTypes.Account) simulationTypes.Content { - return v1beta1.NewTextProposal( - simulationTypes.RandStringOfLength(r, 140), - simulationTypes.RandStringOfLength(r, 5000), - ) -} diff --git a/x/maintainers/utilities/permissions.go b/x/maintainers/utilities/permissions.go index 868235415..8d9782d18 100644 --- a/x/maintainers/utilities/permissions.go +++ b/x/maintainers/utilities/permissions.go @@ -1,10 +1,9 @@ package utilities import ( + "github.com/AssetMantle/modules/x/maintainers/constants" "github.com/AssetMantle/schema/lists" "github.com/AssetMantle/schema/lists/base" - - "github.com/AssetMantle/modules/x/maintainers/constants" ) func SetModulePermissions(canAddMaintainer bool, canMutateMaintainer bool, canRemoveMaintainer bool) lists.IDList { diff --git a/x/metas/auxiliaries/scrub/auxiliary_keeper.go b/x/metas/auxiliaries/scrub/auxiliary_keeper.go index cb86e3675..8abe5cef8 100644 --- a/x/metas/auxiliaries/scrub/auxiliary_keeper.go +++ b/x/metas/auxiliaries/scrub/auxiliary_keeper.go @@ -6,7 +6,6 @@ package scrub import ( "context" "github.com/AssetMantle/modules/helpers/constants" - baseIDs "github.com/AssetMantle/schema/ids/base" baseLists "github.com/AssetMantle/schema/lists/base" "github.com/AssetMantle/schema/properties" diff --git a/x/metas/auxiliaries/scrub/auxiliary_response.go b/x/metas/auxiliaries/scrub/auxiliary_response.go index 26622f677..3806333c8 100644 --- a/x/metas/auxiliaries/scrub/auxiliary_response.go +++ b/x/metas/auxiliaries/scrub/auxiliary_response.go @@ -4,10 +4,9 @@ package scrub import ( + "github.com/AssetMantle/modules/helpers" errorConstants "github.com/AssetMantle/modules/helpers/constants" "github.com/AssetMantle/schema/lists" - - "github.com/AssetMantle/modules/helpers" ) type auxiliaryResponse struct { diff --git a/x/metas/auxiliaries/supplement/auxiliary_keeper.go b/x/metas/auxiliaries/supplement/auxiliary_keeper.go index 1be7f3e29..e0c1e6ded 100644 --- a/x/metas/auxiliaries/supplement/auxiliary_keeper.go +++ b/x/metas/auxiliaries/supplement/auxiliary_keeper.go @@ -5,15 +5,14 @@ package supplement import ( "context" + "github.com/AssetMantle/modules/helpers" errorConstants "github.com/AssetMantle/modules/helpers/constants" + "github.com/AssetMantle/modules/x/metas/key" + "github.com/AssetMantle/modules/x/metas/mappable" "github.com/AssetMantle/schema/data/base" baseIDs "github.com/AssetMantle/schema/ids/base" baseLists "github.com/AssetMantle/schema/lists/base" baseProperties "github.com/AssetMantle/schema/properties/base" - - "github.com/AssetMantle/modules/helpers" - "github.com/AssetMantle/modules/x/metas/key" - "github.com/AssetMantle/modules/x/metas/mappable" ) type auxiliaryKeeper struct { diff --git a/x/metas/auxiliaries/supplement/auxiliary_response.go b/x/metas/auxiliaries/supplement/auxiliary_response.go index dc1aa29e1..8b6804fb0 100644 --- a/x/metas/auxiliaries/supplement/auxiliary_response.go +++ b/x/metas/auxiliaries/supplement/auxiliary_response.go @@ -4,10 +4,9 @@ package supplement import ( + "github.com/AssetMantle/modules/helpers" errorConstants "github.com/AssetMantle/modules/helpers/constants" "github.com/AssetMantle/schema/lists" - - "github.com/AssetMantle/modules/helpers" ) type auxiliaryResponse struct { diff --git a/x/metas/block/block.go b/x/metas/block/block.go index 1cbdcc3d6..36d85c5ae 100644 --- a/x/metas/block/block.go +++ b/x/metas/block/block.go @@ -5,7 +5,6 @@ package block import ( "context" - abciTypes "github.com/cometbft/cometbft/abci/types" "github.com/AssetMantle/modules/helpers" diff --git a/x/metas/genesis/genesis.go b/x/metas/genesis/genesis.go index cbdd2bc19..6f6f797c1 100644 --- a/x/metas/genesis/genesis.go +++ b/x/metas/genesis/genesis.go @@ -3,7 +3,6 @@ package genesis import ( "context" errorConstants "github.com/AssetMantle/modules/helpers/constants" - "github.com/AssetMantle/schema/lists" "github.com/AssetMantle/schema/lists/base" sdkCodec "github.com/cosmos/cosmos-sdk/codec" diff --git a/x/metas/key/key.go b/x/metas/key/key.go index c6259a7e6..cb557e5ac 100644 --- a/x/metas/key/key.go +++ b/x/metas/key/key.go @@ -4,11 +4,10 @@ package key import ( + "github.com/AssetMantle/modules/helpers" errorConstants "github.com/AssetMantle/modules/helpers/constants" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" - - "github.com/AssetMantle/modules/helpers" ) var _ helpers.Key = (*Key)(nil) diff --git a/x/metas/mappable/mappable.go b/x/metas/mappable/mappable.go index a9424731d..c7eee824d 100644 --- a/x/metas/mappable/mappable.go +++ b/x/metas/mappable/mappable.go @@ -4,12 +4,9 @@ package mappable import ( - codecUtilities "github.com/AssetMantle/schema/codec/utilities" + "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/schema/data" baseData "github.com/AssetMantle/schema/data/base" - "github.com/cosmos/cosmos-sdk/codec" - - "github.com/AssetMantle/modules/helpers" ) var _ helpers.Mappable = (*Mappable)(nil) @@ -17,9 +14,6 @@ var _ helpers.Mappable = (*Mappable)(nil) func (mappable *Mappable) ValidateBasic() error { return mappable.Data.ValidateBasic() } -func (*Mappable) RegisterLegacyAminoCodec(legacyAmino *codec.LegacyAmino) { - codecUtilities.RegisterModuleConcrete(legacyAmino, Mappable{}) -} func NewMappable(data data.Data) helpers.Mappable { return &Mappable{Data: data.ToAnyData().(*baseData.AnyData)} diff --git a/x/metas/mappable/mappable_test.go b/x/metas/mappable/mappable_test.go index 99be94491..a0fd502d9 100644 --- a/x/metas/mappable/mappable_test.go +++ b/x/metas/mappable/mappable_test.go @@ -7,11 +7,9 @@ import ( "reflect" "testing" + "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/schema/data" "github.com/AssetMantle/schema/data/base" - "github.com/cosmos/cosmos-sdk/codec" - - "github.com/AssetMantle/modules/helpers" ) func TestNewMappable(t *testing.T) { @@ -50,27 +48,3 @@ func TestPrototype(t *testing.T) { }) } } - -func Test_mappable_RegisterCodec(t *testing.T) { - type fields struct { - Data data.Data - } - type args struct { - legacyAmino *codec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{base.NewStringData("Data")}, args{codec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - ma := &Mappable{ - Data: tt.fields.Data.ToAnyData().(*base.AnyData), - } - ma.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} diff --git a/x/metas/parameters/prototype.go b/x/metas/parameters/prototype.go index 9f103dbcd..dc7447a1a 100644 --- a/x/metas/parameters/prototype.go +++ b/x/metas/parameters/prototype.go @@ -6,10 +6,9 @@ package parameters import ( "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" - "github.com/AssetMantle/modules/x/metas/constants" "github.com/AssetMantle/modules/x/metas/parameters/reveal_enabled" ) func Prototype() helpers.ParameterManager { - return baseHelpers.NewParameterManager(constants.ModuleName, reveal_enabled.ValidatableParameter) + return baseHelpers.NewParameterManager(reveal_enabled.ValidatableParameter) } diff --git a/x/metas/parameters/prototype_test.go b/x/metas/parameters/prototype_test.go index 164040a45..69e965d4a 100644 --- a/x/metas/parameters/prototype_test.go +++ b/x/metas/parameters/prototype_test.go @@ -9,7 +9,6 @@ import ( "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" - "github.com/AssetMantle/modules/x/metas/constants" "github.com/AssetMantle/modules/x/metas/parameters/reveal_enabled" ) @@ -18,7 +17,7 @@ func TestPrototype(t *testing.T) { name string want helpers.ParameterManager }{ - {"+ve", baseHelpers.NewParameterManager(constants.ModuleName, reveal_enabled.ValidatableParameter)}, + {"+ve", baseHelpers.NewParameterManager(reveal_enabled.ValidatableParameter)}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { diff --git a/x/metas/parameters/reveal_enabled/parameter.go b/x/metas/parameters/reveal_enabled/parameter.go index fd8e17550..2c389e715 100644 --- a/x/metas/parameters/reveal_enabled/parameter.go +++ b/x/metas/parameters/reveal_enabled/parameter.go @@ -4,13 +4,12 @@ package reveal_enabled import ( + baseHelpers "github.com/AssetMantle/modules/helpers/base" errorConstants "github.com/AssetMantle/modules/helpers/constants" baseData "github.com/AssetMantle/schema/data/base" baseParameters "github.com/AssetMantle/schema/parameters/base" "github.com/AssetMantle/schema/properties/base" constantProperties "github.com/AssetMantle/schema/properties/constants" - - baseHelpers "github.com/AssetMantle/modules/helpers/base" ) var ID = constantProperties.RevealEnabledProperty.GetKey() diff --git a/x/metas/queries/meta/query.go b/x/metas/queries/meta/query.go index dfa1773de..ce0a382a2 100644 --- a/x/metas/queries/meta/query.go +++ b/x/metas/queries/meta/query.go @@ -4,28 +4,17 @@ package meta import ( - "context" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "google.golang.org/grpc" - "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" helperConstants "github.com/AssetMantle/modules/helpers/constants" - "github.com/AssetMantle/modules/utilities/name" - "github.com/AssetMantle/modules/x/metas/constants" + "google.golang.org/grpc" ) -type dummy struct{} - var Query = baseHelpers.NewQuery( - name.GetPackageName(dummy{}), + _Query_serviceDesc.ServiceName, "", "", - constants.ModuleName, - requestPrototype, responsePrototype, keeperPrototype, @@ -33,9 +22,6 @@ var Query = baseHelpers.NewQuery( func(server grpc.ServiceRegistrar, QueryKeeper helpers.QueryKeeper) { RegisterQueryServer(server, QueryKeeper.(queryKeeper)) }, - func(clientContext client.Context, serveMux *runtime.ServeMux) error { - return RegisterQueryHandlerClient(context.Background(), serveMux, NewQueryClient(clientContext)) - }, helperConstants.DataID, ) diff --git a/x/metas/queries/meta/query_keeper.go b/x/metas/queries/meta/query_keeper.go index 9fa15aaac..472c5ddd2 100644 --- a/x/metas/queries/meta/query_keeper.go +++ b/x/metas/queries/meta/query_keeper.go @@ -5,7 +5,6 @@ package meta import ( "context" - "github.com/AssetMantle/modules/helpers" ) @@ -16,7 +15,7 @@ type queryKeeper struct { var _ helpers.QueryKeeper = (*queryKeeper)(nil) func (queryKeeper queryKeeper) Enquire(context context.Context, queryRequest helpers.QueryRequest) (helpers.QueryResponse, error) { - queryResponse, err := queryKeeper.Handle(context, queryRequestFromInterface(queryRequest)) + queryResponse, err := queryKeeper.Handle(context, queryRequest.(*QueryRequest)) return queryResponse, err } func (queryKeeper queryKeeper) Handle(context context.Context, queryRequest *QueryRequest) (*QueryResponse, error) { diff --git a/x/metas/queries/meta/query_keeper_test.go b/x/metas/queries/meta/query_keeper_test.go index d89459fd3..335788a96 100644 --- a/x/metas/queries/meta/query_keeper_test.go +++ b/x/metas/queries/meta/query_keeper_test.go @@ -129,7 +129,7 @@ func Test_queryKeeper_Enquire(t *testing.T) { want helpers.QueryResponse wantErr bool }{ - {"+ve", fields{Mapper}, args{Context.Context(), newQueryRequest(testDataID)}, newQueryResponse(keepers.MetaKeeper.(queryKeeper).mapper.NewCollection(sdkTypes.WrapSDKContext(Context)).Fetch(queryRequestFromInterface(newQueryRequest(testDataID)).Key).FetchRecord(queryRequestFromInterface(newQueryRequest(testDataID)).Key)), false}, + {"+ve", fields{Mapper}, args{Context.Context(), newQueryRequest(testDataID)}, newQueryResponse(keepers.MetaKeeper.(queryKeeper).mapper.NewCollection(sdkTypes.WrapSDKContext(Context)).Fetch(newQueryRequest(testDataID).(*QueryRequest).Key).FetchRecord(newQueryRequest(testDataID).(*QueryRequest).Key)), false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { diff --git a/x/metas/queries/meta/query_request.go b/x/metas/queries/meta/query_request.go index e0c0ff7e0..6c6332346 100644 --- a/x/metas/queries/meta/query_request.go +++ b/x/metas/queries/meta/query_request.go @@ -11,7 +11,6 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/AssetMantle/modules/helpers" - "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/helpers/constants" "github.com/AssetMantle/modules/x/metas/key" ) @@ -49,27 +48,10 @@ func (*QueryRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.QueryRe return newQueryRequest(dataID.(ids.DataID)), nil } } -func (queryRequest *QueryRequest) Encode() ([]byte, error) { - return base.CodecPrototype().MarshalJSON(queryRequest) -} -func (queryRequest *QueryRequest) Decode(bytes []byte) (helpers.QueryRequest, error) { - if err := base.CodecPrototype().UnmarshalJSON(bytes, queryRequest); err != nil { - return nil, err - } - - return queryRequest, nil -} func requestPrototype() helpers.QueryRequest { return &QueryRequest{} } -func queryRequestFromInterface(request helpers.QueryRequest) *QueryRequest { - switch value := request.(type) { - case *QueryRequest: - return value - default: - return &QueryRequest{} - } -} + func newQueryRequest(dataID ids.DataID) helpers.QueryRequest { return &QueryRequest{Key: key.NewKey(dataID).(*key.Key)} } diff --git a/x/metas/queries/meta/query_request_test.go b/x/metas/queries/meta/query_request_test.go index 2386183ea..e0cc7283a 100644 --- a/x/metas/queries/meta/query_request_test.go +++ b/x/metas/queries/meta/query_request_test.go @@ -8,16 +8,14 @@ import ( "reflect" "testing" + "github.com/AssetMantle/modules/helpers" + baseHelpers "github.com/AssetMantle/modules/helpers/base" + "github.com/AssetMantle/modules/helpers/constants" baseData "github.com/AssetMantle/schema/data/base" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" "github.com/cosmos/cosmos-sdk/client" "github.com/spf13/viper" - "github.com/stretchr/testify/require" - - "github.com/AssetMantle/modules/helpers" - baseHelpers "github.com/AssetMantle/modules/helpers/base" - "github.com/AssetMantle/modules/helpers/constants" ) var ( @@ -59,85 +57,12 @@ func Test_queryRequestFromInterface(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - if got := queryRequestFromInterface(tt.args.request); !reflect.DeepEqual(got, tt.want) { + if got := tt.args.request.(*QueryRequest); !reflect.DeepEqual(got, tt.want) { t.Errorf("queryRequestFromInterface() = %v, want %v", got, tt.want) } }) } } - -func Test_queryRequest_Decode(t *testing.T) { - encodedQuery, err := baseHelpers.CodecPrototype().GetLegacyAmino().MarshalJSON(newQueryRequest(testDataID)) - require.NoError(t, err) - encodedQuery1, err := baseHelpers.CodecPrototype().GetLegacyAmino().MarshalJSON(newQueryRequest(baseIDs.PrototypeDataID().(*baseIDs.DataID))) - require.NoError(t, err) - type fields struct { - Key *key.Key - } - type args struct { - bytes []byte - } - tests := []struct { - name string - fields fields - args args - want helpers.QueryRequest - wantErr bool - }{ - {"+ve", fields{testKey}, args{encodedQuery}, newQueryRequest(testDataID), false}, - {"+ve with nil", fields{key.NewKey(baseIDs.PrototypeDataID()).(*key.Key)}, args{encodedQuery1}, newQueryRequest(baseIDs.PrototypeDataID().(*baseIDs.DataID)), false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - queryRequest := &QueryRequest{ - Key: tt.fields.Key, - } - got, err := queryRequest.Decode(tt.args.bytes) - if (err != nil) != tt.wantErr { - t.Errorf("Decode() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("Decode() got = %v, want %v", got, tt.want) - } - }) - } -} - -func Test_queryRequest_Encode(t *testing.T) { - encodedQuery, err := baseHelpers.CodecPrototype().GetLegacyAmino().MarshalJSON(newQueryRequest(testDataID)) - require.NoError(t, err) - encodedQuery1, err := baseHelpers.CodecPrototype().GetLegacyAmino().MarshalJSON(newQueryRequest(baseIDs.PrototypeDataID().(*baseIDs.DataID))) - require.NoError(t, err) - type fields struct { - Key *key.Key - } - tests := []struct { - name string - fields fields - want []byte - wantErr bool - }{ - {"+ve", fields{testKey}, encodedQuery, false}, - {"+ve with nil", fields{key.NewKey(baseIDs.PrototypeDataID()).(*key.Key)}, encodedQuery1, false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - queryRequest := &QueryRequest{ - Key: tt.fields.Key, - } - got, err := queryRequest.Encode() - if (err != nil) != tt.wantErr { - t.Errorf("Encode() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("Encode() got = %v, want %v", got, tt.want) - } - }) - } -} - func Test_queryRequest_FromCLI(t *testing.T) { cliCommand := baseHelpers.NewCLICommand("", "", "", []helpers.CLIFlag{constants.DataID}) viper.Set(constants.DataID.GetName(), testKey) diff --git a/x/metas/queries/meta/service.pb.go b/x/metas/queries/meta/service.pb.go index 5b2f87e3f..c371ca6ba 100644 --- a/x/metas/queries/meta/service.pb.go +++ b/x/metas/queries/meta/service.pb.go @@ -8,7 +8,6 @@ import ( fmt "fmt" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" - _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -31,30 +30,27 @@ func init() { } var fileDescriptor_aef7a6cab4cafd46 = []byte{ - // 355 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x92, 0x31, 0x4b, 0xc3, 0x40, - 0x14, 0xc7, 0x9b, 0x80, 0x1d, 0x82, 0x53, 0xc6, 0x50, 0x32, 0x74, 0x72, 0xd0, 0x3b, 0x6a, 0xa5, - 0xc2, 0xa1, 0x43, 0xbb, 0xe8, 0x72, 0xd0, 0xea, 0x12, 0x24, 0x20, 0xd7, 0xf6, 0x51, 0x03, 0xc9, - 0x5d, 0x9b, 0xbb, 0x94, 0xba, 0xfa, 0x09, 0x04, 0x67, 0x17, 0x17, 0xc1, 0x4f, 0x22, 0x4e, 0x15, - 0x17, 0x47, 0x49, 0x9c, 0xfc, 0x14, 0x92, 0xcb, 0x0d, 0xed, 0x96, 0x4e, 0xc7, 0x9f, 0xfb, 0xff, - 0xee, 0xff, 0xde, 0xbb, 0xe7, 0xf4, 0xfa, 0x52, 0x82, 0xa2, 0x8c, 0xab, 0x18, 0x70, 0x22, 0xa6, - 0x59, 0x0c, 0x12, 0xaf, 0x70, 0x02, 0x8a, 0x49, 0xbc, 0xc8, 0x20, 0x8d, 0x40, 0x6a, 0x85, 0x25, - 0xa4, 0xcb, 0x68, 0x02, 0x68, 0x9e, 0x0a, 0x25, 0xdc, 0x83, 0x0d, 0x0e, 0x19, 0x0e, 0xad, 0x90, - 0xe6, 0x90, 0xe1, 0xb4, 0xf2, 0x5a, 0x33, 0x21, 0x66, 0x31, 0x60, 0x36, 0x8f, 0x30, 0xe3, 0x5c, - 0x28, 0xa6, 0x22, 0xc1, 0x65, 0xf5, 0x8e, 0x77, 0x56, 0x3b, 0xbf, 0x14, 0xf7, 0xb7, 0x29, 0x2c, - 0x32, 0x90, 0xca, 0xd0, 0xe7, 0x3b, 0xd3, 0x72, 0x2e, 0xb8, 0x34, 0x4d, 0x1c, 0xbf, 0x5a, 0xce, - 0xde, 0xa8, 0xbc, 0x70, 0x9f, 0x2d, 0xa7, 0x79, 0xc9, 0xf8, 0x34, 0x06, 0xb7, 0x87, 0xea, 0xb6, - 0x86, 0x34, 0x7b, 0x55, 0x55, 0xe4, 0x9d, 0xee, 0xcc, 0x55, 0xb5, 0xb4, 0xdb, 0x0f, 0x5f, 0xbf, - 0x4f, 0x76, 0xcb, 0xf5, 0x70, 0x62, 0x1a, 0xd1, 0xe5, 0x2f, 0x3b, 0x63, 0x50, 0xac, 0xa3, 0xd5, - 0xe0, 0xd3, 0x7e, 0xcf, 0x7d, 0x6b, 0x9d, 0xfb, 0xd6, 0x4f, 0xee, 0x5b, 0x8f, 0x85, 0xdf, 0x58, - 0x17, 0x7e, 0xe3, 0xbb, 0xf0, 0x1b, 0xce, 0xe1, 0x44, 0x24, 0xb5, 0xa3, 0x07, 0xfb, 0xd7, 0xd5, - 0x37, 0x0e, 0xcb, 0x01, 0x0c, 0xad, 0x9b, 0xee, 0x2c, 0x52, 0x77, 0xd9, 0x18, 0x4d, 0x44, 0x82, - 0xeb, 0x0e, 0xf3, 0xc5, 0x6e, 0xf6, 0x69, 0x40, 0x47, 0xf4, 0xcd, 0xde, 0x5a, 0x03, 0x6a, 0x82, - 0x03, 0x44, 0x75, 0xf0, 0xc8, 0x04, 0x97, 0xea, 0x63, 0xcb, 0x1a, 0x1a, 0x6b, 0x18, 0x84, 0xda, - 0x1a, 0x1a, 0xab, 0x56, 0xb9, 0x7d, 0x52, 0xd7, 0x1a, 0x5e, 0x0c, 0x07, 0xe5, 0x39, 0x65, 0x8a, - 0xfd, 0xd9, 0x47, 0x1b, 0x18, 0x21, 0x86, 0x23, 0x24, 0x20, 0x44, 0x93, 0x84, 0x18, 0xb4, 0xd2, - 0xe3, 0xa6, 0x5e, 0x82, 0xee, 0x7f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xe4, 0xba, 0xbb, 0x45, 0x03, - 0x03, 0x00, 0x00, + // 309 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x32, 0x73, 0x2c, 0x2e, 0x4e, + 0x2d, 0xf1, 0x4d, 0xcc, 0x2b, 0xc9, 0x49, 0xd5, 0xcf, 0xcd, 0x4f, 0x29, 0xcd, 0x49, 0x2d, 0xd6, + 0xaf, 0xd0, 0xcf, 0x4d, 0x2d, 0x49, 0x2c, 0xd6, 0x2f, 0x2c, 0x4d, 0x2d, 0xca, 0x4c, 0x2d, 0x06, + 0xf3, 0xf4, 0x8b, 0x53, 0x8b, 0xca, 0x32, 0x93, 0x53, 0xf5, 0x0a, 0x8a, 0xf2, 0x4b, 0xf2, 0x85, + 0x34, 0x90, 0xf4, 0xe9, 0x41, 0xf5, 0xe9, 0x55, 0xe8, 0x81, 0xf5, 0xe9, 0x41, 0xf5, 0x81, 0x79, + 0x52, 0x36, 0x44, 0xdb, 0x00, 0xe2, 0x54, 0xc6, 0x17, 0xa5, 0x16, 0x96, 0xa6, 0x16, 0x97, 0x40, + 0xec, 0x91, 0xb2, 0x25, 0x59, 0x77, 0x71, 0x41, 0x7e, 0x5e, 0x31, 0xd4, 0x99, 0x46, 0x2d, 0x8c, + 0x5c, 0xac, 0x81, 0x20, 0x09, 0xa1, 0x6a, 0x2e, 0x36, 0x8f, 0xc4, 0xbc, 0x94, 0x9c, 0x54, 0x21, + 0x33, 0x3d, 0x62, 0xdd, 0xae, 0x07, 0xd6, 0x1a, 0x04, 0x71, 0x90, 0x94, 0x39, 0xc9, 0xfa, 0x20, + 0x4e, 0x51, 0x62, 0x70, 0xba, 0xc8, 0x74, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, + 0x1e, 0xc9, 0x31, 0x4e, 0x78, 0x2c, 0xc7, 0x70, 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, 0x0c, + 0x5c, 0x3a, 0xc9, 0xf9, 0xb9, 0x44, 0x1b, 0xec, 0xc4, 0x13, 0x0c, 0x89, 0x85, 0x00, 0x90, 0xef, + 0x02, 0x18, 0xa3, 0x8c, 0xd3, 0x33, 0x4b, 0x32, 0x4a, 0x93, 0xf4, 0x92, 0xf3, 0x73, 0xf5, 0x89, + 0x0d, 0xa9, 0x45, 0x4c, 0x6c, 0x8e, 0xbe, 0x11, 0xbe, 0x81, 0xbe, 0xab, 0x98, 0x50, 0x62, 0xd1, + 0x17, 0x6a, 0x71, 0x84, 0x9e, 0x2f, 0xd8, 0xe2, 0x40, 0xa8, 0xc5, 0x20, 0xde, 0x29, 0x14, 0xa5, + 0x31, 0x50, 0xa5, 0x31, 0x11, 0x31, 0x60, 0xa5, 0x31, 0x50, 0xa5, 0x60, 0xde, 0x23, 0x26, 0x13, + 0x62, 0x95, 0xc6, 0xb8, 0x07, 0x38, 0x81, 0xe8, 0x94, 0xc4, 0x92, 0xc4, 0x57, 0x4c, 0xba, 0x48, + 0xda, 0xac, 0xac, 0xa0, 0xfa, 0xac, 0xac, 0x22, 0xac, 0xac, 0xc0, 0x3a, 0xad, 0xac, 0xa0, 0x5a, + 0x21, 0xfc, 0x24, 0x36, 0x70, 0x0c, 0x1b, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0xc7, 0xd1, 0x6c, + 0xa3, 0xc2, 0x02, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/metas/queries/meta/service.pb.gw.go b/x/metas/queries/meta/service.pb.gw.go deleted file mode 100644 index d449a9311..000000000 --- a/x/metas/queries/meta/service.pb.gw.go +++ /dev/null @@ -1,171 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: AssetMantle/modules/x/metas/queries/meta/service.proto - -/* -Package meta is a reverse proxy. - -It translates gRPC into RESTful JSON APIs. -*/ -package meta - -import ( - "context" - "io" - "net/http" - - "github.com/golang/protobuf/descriptor" - "github.com/golang/protobuf/proto" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/grpc-ecosystem/grpc-gateway/utilities" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/status" -) - -// Suppress "imported and not used" errors -var _ codes.Code -var _ io.Reader -var _ status.Status -var _ = runtime.String -var _ = utilities.NewDoubleArray -var _ = descriptor.ForMessage -var _ = metadata.Join - -var ( - filter_Query_Handle_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - -func request_Query_Handle_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryRequest - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.Handle(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_Handle_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryRequest - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.Handle(ctx, &protoReq) - return msg, metadata, err - -} - -// RegisterQueryHandlerServer registers the http handlers for service Query to "mux". -// UnaryRPC :call QueryServer directly. -// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. -func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { - - mux.Handle("GET", pattern_Query_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Query_Handle_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but -// automatically dials to "endpoint" and closes the connection when "ctx" gets done. -func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.Dial(endpoint, opts...) - if err != nil { - return err - } - defer func() { - if err != nil { - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - return - } - go func() { - <-ctx.Done() - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - }() - }() - - return RegisterQueryHandler(ctx, mux, conn) -} - -// RegisterQueryHandler registers the http handlers for service Query to "mux". -// The handlers forward requests to the grpc endpoint over "conn". -func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { - return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn)) -} - -// RegisterQueryHandlerClient registers the http handlers for service Query -// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient". -// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient" -// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "QueryClient" to call the correct interceptors. -func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { - - mux.Handle("GET", pattern_Query_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Query_Handle_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -var ( - pattern_Query_Handle_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"mantle", "metas", "v1beta1", "meta"}, "", runtime.AssumeColonVerbOpt(false))) -) - -var ( - forward_Query_Handle_0 = runtime.ForwardResponseMessage -) diff --git a/x/metas/queries/metas/query.go b/x/metas/queries/metas/query.go index 7f9385935..02ff2466c 100644 --- a/x/metas/queries/metas/query.go +++ b/x/metas/queries/metas/query.go @@ -4,26 +4,16 @@ package metas import ( - "context" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "google.golang.org/grpc" - "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" helperConstants "github.com/AssetMantle/modules/helpers/constants" - "github.com/AssetMantle/modules/utilities/name" - "github.com/AssetMantle/modules/x/metas/constants" + "google.golang.org/grpc" ) -type dummy struct{} - var Query = baseHelpers.NewQuery( - name.GetPackageName(dummy{}), + _Query_serviceDesc.ServiceName, "", "", - constants.ModuleName, requestPrototype, responsePrototype, @@ -32,9 +22,6 @@ var Query = baseHelpers.NewQuery( func(server grpc.ServiceRegistrar, QueryKeeper helpers.QueryKeeper) { RegisterQueryServer(server, QueryKeeper.(queryKeeper)) }, - func(clientContext client.Context, serveMux *runtime.ServeMux) error { - return RegisterQueryHandlerClient(context.Background(), serveMux, NewQueryClient(clientContext)) - }, helperConstants.DataID, helperConstants.Limit, diff --git a/x/metas/queries/metas/query_keeper.go b/x/metas/queries/metas/query_keeper.go index 40c2e0f2b..a6f8f16e4 100644 --- a/x/metas/queries/metas/query_keeper.go +++ b/x/metas/queries/metas/query_keeper.go @@ -5,7 +5,6 @@ package metas import ( "context" - "github.com/AssetMantle/modules/helpers" ) @@ -16,7 +15,7 @@ type queryKeeper struct { var _ helpers.QueryKeeper = (*queryKeeper)(nil) func (queryKeeper queryKeeper) Enquire(context context.Context, queryRequest helpers.QueryRequest) (helpers.QueryResponse, error) { - queryResponse, err := queryKeeper.Handle(context, queryRequestFromInterface(queryRequest)) + queryResponse, err := queryKeeper.Handle(context, queryRequest.(*QueryRequest)) return queryResponse, err } func (queryKeeper queryKeeper) Handle(context context.Context, queryRequest *QueryRequest) (*QueryResponse, error) { diff --git a/x/metas/queries/metas/query_request.go b/x/metas/queries/metas/query_request.go index 60c4a5ed4..84b10971e 100644 --- a/x/metas/queries/metas/query_request.go +++ b/x/metas/queries/metas/query_request.go @@ -13,7 +13,6 @@ import ( "github.com/cosmos/cosmos-sdk/types/query" "github.com/AssetMantle/modules/helpers" - "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/helpers/constants" "github.com/AssetMantle/modules/x/metas/key" ) @@ -68,27 +67,10 @@ func (*QueryRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.QueryRe return newQueryRequest(dataID.(ids.DataID), int32(limit)), nil } -func (queryRequest *QueryRequest) Encode() ([]byte, error) { - return base.CodecPrototype().MarshalJSON(queryRequest) -} -func (queryRequest *QueryRequest) Decode(bytes []byte) (helpers.QueryRequest, error) { - if err := base.CodecPrototype().UnmarshalJSON(bytes, queryRequest); err != nil { - return nil, err - } - - return queryRequest, nil -} func requestPrototype() helpers.QueryRequest { return &QueryRequest{} } -func queryRequestFromInterface(request helpers.QueryRequest) *QueryRequest { - switch value := request.(type) { - case *QueryRequest: - return value - default: - return &QueryRequest{} - } -} + func newQueryRequest(dataID ids.DataID, limit int32) helpers.QueryRequest { return &QueryRequest{Key: key.NewKey(dataID).(*key.Key), Limit: limit} } diff --git a/x/metas/queries/metas/service.pb.go b/x/metas/queries/metas/service.pb.go index 8aba58ace..2c19abae4 100644 --- a/x/metas/queries/metas/service.pb.go +++ b/x/metas/queries/metas/service.pb.go @@ -8,7 +8,6 @@ import ( fmt "fmt" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" - _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -31,30 +30,27 @@ func init() { } var fileDescriptor_b733e355d827f495 = []byte{ - // 356 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x92, 0xcf, 0x4a, 0xf3, 0x40, - 0x14, 0xc5, 0x9b, 0xc0, 0xd7, 0x45, 0xf8, 0x56, 0x59, 0x56, 0xcd, 0x42, 0x57, 0x2e, 0x9c, 0xa1, - 0xfe, 0xa1, 0x32, 0xa0, 0xd0, 0x6e, 0x74, 0x13, 0x68, 0x75, 0x13, 0x24, 0x20, 0xd3, 0xf6, 0x52, - 0x03, 0x49, 0xa6, 0xcd, 0x4c, 0x4a, 0xdd, 0xfa, 0x04, 0x82, 0x2f, 0x20, 0x2e, 0xfb, 0x24, 0xe2, - 0xaa, 0xe0, 0x42, 0x97, 0x92, 0xba, 0xf2, 0x29, 0x24, 0x33, 0x17, 0x69, 0x77, 0xe9, 0x2e, 0x87, - 0x39, 0xbf, 0xdc, 0x73, 0xee, 0x8c, 0xd3, 0x6a, 0x4b, 0x09, 0xca, 0xe7, 0xa9, 0x8a, 0x81, 0x26, - 0x62, 0x98, 0xc7, 0x20, 0xe9, 0x8c, 0x26, 0xa0, 0xb8, 0xa4, 0x93, 0x1c, 0xb2, 0x08, 0x24, 0x2a, - 0x09, 0xd9, 0x34, 0x1a, 0x00, 0x19, 0x67, 0x42, 0x09, 0x77, 0x7f, 0x05, 0x24, 0x08, 0x92, 0x19, - 0xd1, 0x56, 0x82, 0xa0, 0x51, 0x8d, 0xed, 0x91, 0x10, 0xa3, 0x18, 0x28, 0x1f, 0x47, 0x94, 0xa7, - 0xa9, 0x50, 0x5c, 0x45, 0x22, 0x95, 0xe6, 0x47, 0x8d, 0xb3, 0xea, 0x09, 0x4a, 0x75, 0x7f, 0x9b, - 0xc1, 0x24, 0x07, 0xa9, 0x10, 0x3f, 0xdf, 0x1c, 0x97, 0x63, 0x91, 0x4a, 0xec, 0x71, 0x38, 0xb7, - 0x9c, 0x7f, 0xbd, 0xf2, 0xc0, 0x7d, 0xb6, 0x9c, 0xfa, 0x25, 0x4f, 0x87, 0x31, 0xb8, 0x2d, 0x52, - 0xb9, 0x1d, 0xd1, 0xf0, 0x95, 0xc9, 0xd4, 0x38, 0xdd, 0x1c, 0x34, 0x69, 0x76, 0xf7, 0x1e, 0xde, - 0xbf, 0x9f, 0xec, 0x1d, 0x77, 0x8b, 0x26, 0xd8, 0x45, 0x67, 0x9e, 0x36, 0xfb, 0xa0, 0x78, 0xd3, - 0xa8, 0xce, 0x87, 0xfd, 0x5a, 0x78, 0xd6, 0xa2, 0xf0, 0xac, 0xaf, 0xc2, 0xb3, 0x1e, 0x97, 0x5e, - 0x6d, 0xb1, 0xf4, 0x6a, 0x9f, 0x4b, 0xaf, 0xe6, 0x1c, 0x0c, 0x44, 0x52, 0x7d, 0x78, 0xe7, 0xff, - 0xb5, 0xb9, 0xcd, 0x6e, 0xb9, 0x84, 0xae, 0x75, 0x73, 0x3c, 0x8a, 0xd4, 0x5d, 0xde, 0x27, 0x03, - 0x91, 0xd0, 0xca, 0x1b, 0x7d, 0xb1, 0xeb, 0x6d, 0x3f, 0xf0, 0x7b, 0xfe, 0xdc, 0x5e, 0x7b, 0x0e, - 0x3e, 0x8e, 0x0e, 0x88, 0xff, 0xd7, 0xb4, 0x1c, 0xad, 0xd5, 0xdb, 0x9a, 0x37, 0x44, 0x6f, 0x18, - 0x84, 0xfa, 0x34, 0x44, 0xaf, 0x51, 0x85, 0x7d, 0x52, 0xd9, 0x1b, 0x5e, 0x74, 0x3b, 0xe5, 0xc7, - 0x90, 0x2b, 0xfe, 0x63, 0xaf, 0xae, 0x82, 0x31, 0x04, 0x19, 0x0b, 0x18, 0xd3, 0x66, 0xc6, 0x90, - 0x45, 0xdd, 0xaf, 0xeb, 0xd7, 0x70, 0xf4, 0x1b, 0x00, 0x00, 0xff, 0xff, 0x71, 0x48, 0xe6, 0xa0, - 0x10, 0x03, 0x00, 0x00, + // 306 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x32, 0x77, 0x2c, 0x2e, 0x4e, + 0x2d, 0xf1, 0x4d, 0xcc, 0x2b, 0xc9, 0x49, 0xd5, 0xcf, 0xcd, 0x4f, 0x29, 0xcd, 0x49, 0x2d, 0xd6, + 0xaf, 0xd0, 0xcf, 0x4d, 0x2d, 0x49, 0x2c, 0xd6, 0x2f, 0x2c, 0x4d, 0x2d, 0xca, 0x4c, 0x2d, 0x86, + 0xf2, 0x8a, 0x53, 0x8b, 0xca, 0x32, 0x93, 0x53, 0xf5, 0x0a, 0x8a, 0xf2, 0x4b, 0xf2, 0x85, 0x34, + 0x91, 0x34, 0xea, 0x41, 0x35, 0xea, 0x55, 0xe8, 0x81, 0x95, 0xea, 0x41, 0x35, 0x42, 0x78, 0x52, + 0xb6, 0xc4, 0xdb, 0x01, 0xe2, 0x55, 0xc6, 0x17, 0xa5, 0x16, 0x96, 0xa6, 0x16, 0x97, 0x40, 0x6c, + 0x92, 0xb2, 0x23, 0x5d, 0x7b, 0x71, 0x41, 0x7e, 0x5e, 0x31, 0xd4, 0xa5, 0x46, 0x6d, 0x8c, 0x5c, + 0xac, 0x81, 0x20, 0x09, 0xa1, 0x5a, 0x2e, 0x36, 0x8f, 0xc4, 0xbc, 0x94, 0x9c, 0x54, 0x21, 0x73, + 0x3d, 0xa2, 0x9d, 0xaf, 0x07, 0xd6, 0x1b, 0x04, 0x71, 0x92, 0x94, 0x05, 0xe9, 0x1a, 0x21, 0x8e, + 0x51, 0x62, 0x70, 0xba, 0xce, 0x74, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, + 0xc9, 0x31, 0x4e, 0x78, 0x2c, 0xc7, 0x70, 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, 0x0c, 0x5c, + 0xba, 0xc9, 0xf9, 0xb9, 0xc4, 0x9b, 0xec, 0xc4, 0x13, 0x0c, 0x89, 0x8b, 0x00, 0x90, 0x07, 0x03, + 0x18, 0xa3, 0x4c, 0xd2, 0x33, 0x4b, 0x32, 0x4a, 0x93, 0xf4, 0x92, 0xf3, 0x73, 0xf5, 0x89, 0x0e, + 0xad, 0x45, 0x4c, 0x6c, 0x8e, 0xbe, 0x11, 0xbe, 0x81, 0xbe, 0xab, 0x98, 0x50, 0x22, 0xd3, 0x17, + 0x6a, 0x75, 0x84, 0x9e, 0x2f, 0xdc, 0x1b, 0x20, 0xab, 0xc1, 0xbc, 0x53, 0x28, 0x6a, 0x63, 0xa0, + 0x6a, 0x63, 0x22, 0x62, 0xc0, 0xb2, 0x31, 0x50, 0xb5, 0x10, 0xde, 0x23, 0x26, 0x53, 0xa2, 0xd5, + 0xc6, 0xb8, 0x07, 0x38, 0x81, 0x18, 0x29, 0x89, 0x25, 0x89, 0xaf, 0x98, 0x90, 0x83, 0xc2, 0xca, + 0x0a, 0xaa, 0xd1, 0xca, 0x2a, 0xc2, 0xca, 0x0a, 0xac, 0xd8, 0xca, 0x0a, 0xaa, 0x17, 0xca, 0x4f, + 0x62, 0x03, 0xc7, 0xb4, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x8e, 0x19, 0xd1, 0xd2, 0xce, 0x02, + 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/metas/queries/metas/service.pb.gw.go b/x/metas/queries/metas/service.pb.gw.go deleted file mode 100644 index 34425014e..000000000 --- a/x/metas/queries/metas/service.pb.gw.go +++ /dev/null @@ -1,171 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: AssetMantle/modules/x/metas/queries/metas/service.proto - -/* -Package metas is a reverse proxy. - -It translates gRPC into RESTful JSON APIs. -*/ -package metas - -import ( - "context" - "io" - "net/http" - - "github.com/golang/protobuf/descriptor" - "github.com/golang/protobuf/proto" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/grpc-ecosystem/grpc-gateway/utilities" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/status" -) - -// Suppress "imported and not used" errors -var _ codes.Code -var _ io.Reader -var _ status.Status -var _ = runtime.String -var _ = utilities.NewDoubleArray -var _ = descriptor.ForMessage -var _ = metadata.Join - -var ( - filter_Query_Handle_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - -func request_Query_Handle_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryRequest - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.Handle(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_Handle_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryRequest - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.Handle(ctx, &protoReq) - return msg, metadata, err - -} - -// RegisterQueryHandlerServer registers the http handlers for service Query to "mux". -// UnaryRPC :call QueryServer directly. -// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. -func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { - - mux.Handle("GET", pattern_Query_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Query_Handle_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but -// automatically dials to "endpoint" and closes the connection when "ctx" gets done. -func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.Dial(endpoint, opts...) - if err != nil { - return err - } - defer func() { - if err != nil { - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - return - } - go func() { - <-ctx.Done() - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - }() - }() - - return RegisterQueryHandler(ctx, mux, conn) -} - -// RegisterQueryHandler registers the http handlers for service Query to "mux". -// The handlers forward requests to the grpc endpoint over "conn". -func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { - return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn)) -} - -// RegisterQueryHandlerClient registers the http handlers for service Query -// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient". -// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient" -// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "QueryClient" to call the correct interceptors. -func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { - - mux.Handle("GET", pattern_Query_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Query_Handle_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -var ( - pattern_Query_Handle_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 1}, []string{"mantle", "metas", "v1beta1"}, "", runtime.AssumeColonVerbOpt(false))) -) - -var ( - forward_Query_Handle_0 = runtime.ForwardResponseMessage -) diff --git a/x/metas/queries/parameters/query.go b/x/metas/queries/parameters/query.go new file mode 100644 index 000000000..cfe5be8fe --- /dev/null +++ b/x/metas/queries/parameters/query.go @@ -0,0 +1,21 @@ +package parameters + +import ( + "github.com/AssetMantle/modules/helpers" + baseHelpers "github.com/AssetMantle/modules/helpers/base" + "google.golang.org/grpc" +) + +var Query = baseHelpers.NewQuery( + _Query_serviceDesc.ServiceName, + "", + "", + + requestPrototype, + responsePrototype, + keeperPrototype, + + func(server grpc.ServiceRegistrar, QueryKeeper helpers.QueryKeeper) { + RegisterQueryServer(server, QueryKeeper.(queryKeeper)) + }, +) diff --git a/x/metas/queries/parameters/query_keeper.go b/x/metas/queries/parameters/query_keeper.go new file mode 100644 index 000000000..5ff196b53 --- /dev/null +++ b/x/metas/queries/parameters/query_keeper.go @@ -0,0 +1,31 @@ +package parameters + +import ( + "context" + "github.com/AssetMantle/modules/helpers" +) + +type queryKeeper struct { + parameterManager helpers.ParameterManager +} + +var _ helpers.QueryKeeper = (*queryKeeper)(nil) + +func (queryKeeper queryKeeper) Enquire(context context.Context, queryRequest helpers.QueryRequest) (helpers.QueryResponse, error) { + queryResponse, err := queryKeeper.Handle(context, queryRequest.(*QueryRequest)) + return queryResponse, err +} +func (queryKeeper queryKeeper) Handle(context context.Context, queryRequest *QueryRequest) (*QueryResponse, error) { + if err := queryRequest.Validate(); err != nil { + return nil, err + } + return newQueryResponse(queryKeeper.parameterManager.Fetch(context).Get()), nil +} +func (queryKeeper queryKeeper) Initialize(_ helpers.Mapper, parameterManager helpers.ParameterManager, _ []interface{}) helpers.Keeper { + queryKeeper.parameterManager = parameterManager + return queryKeeper +} + +func keeperPrototype() helpers.QueryKeeper { + return queryKeeper{} +} diff --git a/x/metas/queries/parameters/query_request.go b/x/metas/queries/parameters/query_request.go new file mode 100644 index 000000000..9f99e7a01 --- /dev/null +++ b/x/metas/queries/parameters/query_request.go @@ -0,0 +1,25 @@ +package parameters + +import ( + "github.com/AssetMantle/modules/helpers" + "github.com/cosmos/cosmos-sdk/client" + "net/http" +) + +var _ helpers.QueryRequest = (*QueryRequest)(nil) + +func (queryRequest *QueryRequest) Validate() error { + return nil +} + +func (queryRequest *QueryRequest) FromCLI(_ helpers.CLICommand, _ client.Context) (helpers.QueryRequest, error) { + return requestPrototype(), nil +} + +func (queryRequest *QueryRequest) FromHTTPRequest(_ *http.Request) (helpers.QueryRequest, error) { + return requestPrototype(), nil +} + +func requestPrototype() helpers.QueryRequest { + return &QueryRequest{} +} diff --git a/x/metas/queries/parameters/query_request.pb.go b/x/metas/queries/parameters/query_request.pb.go new file mode 100644 index 000000000..fe4205d24 --- /dev/null +++ b/x/metas/queries/parameters/query_request.pb.go @@ -0,0 +1,272 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: AssetMantle/modules/x/metas/queries/parameters/query_request.proto + +package parameters + +import ( + fmt "fmt" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type QueryRequest struct { +} + +func (m *QueryRequest) Reset() { *m = QueryRequest{} } +func (m *QueryRequest) String() string { return proto.CompactTextString(m) } +func (*QueryRequest) ProtoMessage() {} +func (*QueryRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_a4aa1936e6a1ea67, []int{0} +} +func (m *QueryRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryRequest.Merge(m, src) +} +func (m *QueryRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryRequest proto.InternalMessageInfo + +func init() { + proto.RegisterType((*QueryRequest)(nil), "AssetMantle.modules.x.metas.queries.parameters.QueryRequest") +} + +func init() { + proto.RegisterFile("AssetMantle/modules/x/metas/queries/parameters/query_request.proto", fileDescriptor_a4aa1936e6a1ea67) +} + +var fileDescriptor_a4aa1936e6a1ea67 = []byte{ + // 267 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0xd1, 0xb1, 0x4a, 0x03, 0x31, + 0x1c, 0xc7, 0xf1, 0x5e, 0x86, 0x0e, 0x87, 0x08, 0xfa, 0x00, 0x19, 0x7c, 0x80, 0x04, 0xec, 0xe4, + 0x7f, 0xeb, 0x2d, 0x4e, 0x81, 0x9c, 0xd3, 0x21, 0x01, 0x49, 0xdb, 0x3f, 0x5a, 0x68, 0x4c, 0x9b, + 0xe4, 0xa0, 0xbe, 0x85, 0xcf, 0xe0, 0xe8, 0x93, 0x88, 0x53, 0x47, 0x47, 0xb9, 0xdb, 0x7c, 0x04, + 0x27, 0xb9, 0x34, 0x78, 0xd7, 0xf1, 0xd6, 0x84, 0xef, 0x87, 0x5f, 0x48, 0x5e, 0xcc, 0xbd, 0xc7, + 0x20, 0xf4, 0x73, 0xd8, 0x20, 0x37, 0x76, 0x55, 0x6f, 0xd0, 0xf3, 0x3d, 0x37, 0x18, 0xb4, 0xe7, + 0xbb, 0x1a, 0xdd, 0x1a, 0x3d, 0xdf, 0x6a, 0xa7, 0x0d, 0x06, 0x74, 0xc7, 0xa3, 0x97, 0x07, 0x87, + 0xbb, 0x1a, 0x7d, 0x60, 0x5b, 0x67, 0x83, 0xbd, 0x64, 0x03, 0x83, 0x25, 0x83, 0xed, 0x59, 0x34, + 0x58, 0x32, 0x58, 0x6f, 0x5c, 0x9d, 0xe7, 0x67, 0x65, 0xc7, 0xdc, 0x1d, 0x95, 0xe2, 0x97, 0x7c, + 0x34, 0x34, 0x3b, 0x34, 0x34, 0xfb, 0x6e, 0x68, 0xf6, 0xda, 0xd2, 0xc9, 0xa1, 0xa5, 0x93, 0xaf, + 0x96, 0x4e, 0xf2, 0xeb, 0xa5, 0x35, 0x23, 0xf9, 0xe2, 0x62, 0x88, 0xcb, 0x6e, 0xa1, 0xcc, 0xee, + 0x6f, 0x1e, 0xd7, 0xe1, 0xa9, 0x5e, 0xb0, 0xa5, 0x35, 0x7c, 0xdc, 0x93, 0xdf, 0xc8, 0x74, 0x2e, + 0x2a, 0x51, 0xca, 0x77, 0x72, 0xb2, 0x44, 0xa4, 0x25, 0x15, 0x13, 0x71, 0x49, 0x99, 0x96, 0xc8, + 0xff, 0xf2, 0xf3, 0x24, 0x50, 0x29, 0x50, 0x95, 0x8a, 0x81, 0x4a, 0x81, 0xea, 0x83, 0x86, 0xc0, + 0xb8, 0x40, 0xdd, 0xca, 0xa2, 0xbb, 0x5b, 0xe9, 0xa0, 0x7f, 0xc8, 0x6c, 0x10, 0x03, 0xa4, 0x1a, + 0xa0, 0x02, 0x88, 0x3d, 0x40, 0x02, 0x00, 0x7a, 0x61, 0x31, 0x8d, 0x7f, 0x38, 0xfb, 0x0b, 0x00, + 0x00, 0xff, 0xff, 0x06, 0x4b, 0x1a, 0x74, 0x09, 0x02, 0x00, 0x00, +} + +func (m *QueryRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func encodeVarintQueryRequest(dAtA []byte, offset int, v uint64) int { + offset -= sovQueryRequest(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *QueryRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func sovQueryRequest(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQueryRequest(x uint64) (n int) { + return sovQueryRequest(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QueryRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQueryRequest + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQueryRequest(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQueryRequest + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipQueryRequest(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQueryRequest + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQueryRequest + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQueryRequest + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthQueryRequest + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupQueryRequest + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthQueryRequest + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthQueryRequest = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowQueryRequest = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupQueryRequest = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/metas/queries/parameters/query_response.go b/x/metas/queries/parameters/query_response.go new file mode 100644 index 000000000..4d34b8543 --- /dev/null +++ b/x/metas/queries/parameters/query_response.go @@ -0,0 +1,29 @@ +package parameters + +import ( + "github.com/AssetMantle/modules/helpers" + "github.com/AssetMantle/modules/helpers/base" + "github.com/AssetMantle/schema/lists" + baseLists "github.com/AssetMantle/schema/lists/base" +) + +var _ helpers.QueryResponse = (*QueryResponse)(nil) + +func (queryResponse *QueryResponse) Encode() ([]byte, error) { + return base.CodecPrototype().MarshalJSON(queryResponse) +} +func (queryResponse *QueryResponse) Decode(bytes []byte) (helpers.QueryResponse, error) { + if err := base.CodecPrototype().UnmarshalJSON(bytes, queryResponse); err != nil { + return nil, err + } + + return queryResponse, nil +} +func responsePrototype() helpers.QueryResponse { + return &QueryResponse{} +} +func newQueryResponse(parameterList lists.ParameterList) *QueryResponse { + return &QueryResponse{ + ParameterList: parameterList.(*baseLists.ParameterList), + } +} diff --git a/x/metas/queries/parameters/query_response.pb.go b/x/metas/queries/parameters/query_response.pb.go new file mode 100644 index 000000000..680ff223a --- /dev/null +++ b/x/metas/queries/parameters/query_response.pb.go @@ -0,0 +1,337 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: AssetMantle/modules/x/metas/queries/parameters/query_response.proto + +package parameters + +import ( + fmt "fmt" + base "github.com/AssetMantle/schema/lists/base" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type QueryResponse struct { + ParameterList *base.ParameterList `protobuf:"bytes,1,opt,name=parameter_list,json=parameterList,proto3" json:"parameter_list,omitempty"` +} + +func (m *QueryResponse) Reset() { *m = QueryResponse{} } +func (m *QueryResponse) String() string { return proto.CompactTextString(m) } +func (*QueryResponse) ProtoMessage() {} +func (*QueryResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_228dc148ba4f4466, []int{0} +} +func (m *QueryResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryResponse.Merge(m, src) +} +func (m *QueryResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryResponse proto.InternalMessageInfo + +func (m *QueryResponse) GetParameterList() *base.ParameterList { + if m != nil { + return m.ParameterList + } + return nil +} + +func init() { + proto.RegisterType((*QueryResponse)(nil), "AssetMantle.modules.x.metas.queries.parameters.QueryResponse") +} + +func init() { + proto.RegisterFile("AssetMantle/modules/x/metas/queries/parameters/query_response.proto", fileDescriptor_228dc148ba4f4466) +} + +var fileDescriptor_228dc148ba4f4466 = []byte{ + // 330 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x91, 0xb1, 0x4e, 0xeb, 0x30, + 0x14, 0x86, 0x9b, 0x0c, 0x1d, 0x72, 0xd5, 0x3b, 0x74, 0x42, 0x0c, 0x11, 0x62, 0x62, 0x40, 0xc7, + 0x52, 0x3b, 0xe1, 0xad, 0x65, 0x60, 0x21, 0x52, 0x5a, 0x96, 0x08, 0x59, 0xaa, 0xdc, 0xf6, 0x88, + 0x46, 0xaa, 0xeb, 0x90, 0xe3, 0x4a, 0xe5, 0x2d, 0x78, 0x06, 0x46, 0x9e, 0x04, 0x31, 0x75, 0x64, + 0x44, 0xe9, 0xc6, 0x2b, 0xb0, 0xa0, 0xb8, 0x86, 0x24, 0x63, 0xc6, 0x9c, 0xf8, 0xfb, 0xfe, 0xff, + 0xd8, 0xc1, 0xf5, 0x88, 0x08, 0x4d, 0x24, 0x37, 0x66, 0x8d, 0x4c, 0xe9, 0xe5, 0x76, 0x8d, 0xc4, + 0x76, 0x4c, 0xa1, 0x91, 0xc4, 0x1e, 0xb7, 0x98, 0xa7, 0x48, 0x2c, 0x93, 0xb9, 0x54, 0x68, 0x30, + 0x3f, 0x8e, 0x9e, 0x66, 0x39, 0x52, 0xa6, 0x37, 0x84, 0x90, 0xe5, 0xda, 0xe8, 0x3e, 0xd4, 0x24, + 0xe0, 0x24, 0xb0, 0x03, 0x2b, 0x01, 0x27, 0x81, 0x4a, 0x72, 0x3a, 0xa8, 0x87, 0xd2, 0x62, 0x85, + 0x4a, 0xb2, 0x75, 0x4a, 0x86, 0xd8, 0x5c, 0x12, 0x56, 0x71, 0xb3, 0x72, 0x78, 0xcc, 0x38, 0x5f, + 0x06, 0xbd, 0x49, 0x99, 0x3d, 0x75, 0xd1, 0xfd, 0xbb, 0xe0, 0x7f, 0xf3, 0xe0, 0x89, 0x77, 0xe6, + 0x5d, 0xfc, 0x1b, 0x5c, 0x36, 0xda, 0x1c, 0xed, 0x60, 0xed, 0x50, 0xda, 0x21, 0xfe, 0x85, 0x6e, + 0x53, 0x32, 0xd3, 0x5e, 0x56, 0xff, 0x1c, 0x7f, 0xfb, 0x6f, 0x45, 0xe8, 0xed, 0x8b, 0xd0, 0xfb, + 0x2c, 0x42, 0xef, 0xf9, 0x10, 0x76, 0xf6, 0x87, 0xb0, 0xf3, 0x71, 0x08, 0x3b, 0xc1, 0x60, 0xa1, + 0x55, 0xcb, 0x45, 0xc7, 0xfd, 0x46, 0xe5, 0xb8, 0x5c, 0x24, 0xf6, 0xee, 0xaf, 0x1e, 0x52, 0xb3, + 0xda, 0xce, 0x61, 0xa1, 0x15, 0x6b, 0x77, 0xfd, 0x2f, 0x7e, 0x77, 0x14, 0x25, 0xd1, 0x24, 0x7e, + 0xf5, 0x1b, 0x55, 0x22, 0x57, 0x25, 0x81, 0xc8, 0x56, 0x99, 0xb8, 0x2a, 0x7f, 0xbb, 0xd2, 0x7b, + 0x03, 0x10, 0x0e, 0x10, 0x89, 0xb0, 0x80, 0x70, 0x80, 0xa8, 0x80, 0xc2, 0xe7, 0xed, 0x00, 0x71, + 0x13, 0x8f, 0xcb, 0x7f, 0x4b, 0x69, 0xe4, 0x97, 0x3f, 0xac, 0xc1, 0x9c, 0x3b, 0x9a, 0xf3, 0x84, + 0x73, 0xcb, 0x73, 0xee, 0x04, 0x9c, 0x57, 0x86, 0x79, 0xd7, 0x3e, 0xf5, 0xf0, 0x27, 0x00, 0x00, + 0xff, 0xff, 0xbc, 0xda, 0x7e, 0x00, 0x95, 0x02, 0x00, 0x00, +} + +func (m *QueryResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.ParameterList != nil { + { + size, err := m.ParameterList.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQueryResponse(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintQueryResponse(dAtA []byte, offset int, v uint64) int { + offset -= sovQueryResponse(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *QueryResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ParameterList != nil { + l = m.ParameterList.Size() + n += 1 + l + sovQueryResponse(uint64(l)) + } + return n +} + +func sovQueryResponse(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQueryResponse(x uint64) (n int) { + return sovQueryResponse(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QueryResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQueryResponse + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ParameterList", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQueryResponse + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQueryResponse + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQueryResponse + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.ParameterList == nil { + m.ParameterList = &base.ParameterList{} + } + if err := m.ParameterList.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQueryResponse(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQueryResponse + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipQueryResponse(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQueryResponse + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQueryResponse + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQueryResponse + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthQueryResponse + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupQueryResponse + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthQueryResponse + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthQueryResponse = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowQueryResponse = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupQueryResponse = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/metas/queries/parameters/service.pb.go b/x/metas/queries/parameters/service.pb.go new file mode 100644 index 000000000..e0ea3736f --- /dev/null +++ b/x/metas/queries/parameters/service.pb.go @@ -0,0 +1,135 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: AssetMantle/modules/x/metas/queries/parameters/service.proto + +package parameters + +import ( + context "context" + fmt "fmt" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + math "math" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +func init() { + proto.RegisterFile("AssetMantle/modules/x/metas/queries/parameters/service.proto", fileDescriptor_9108a8da77f2a61f) +} + +var fileDescriptor_9108a8da77f2a61f = []byte{ + // 321 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0xd2, 0xb1, 0x4e, 0xeb, 0x30, + 0x14, 0x06, 0xe0, 0x38, 0xd2, 0xed, 0x10, 0xdd, 0xa9, 0x63, 0x07, 0x0f, 0x3c, 0x80, 0x2d, 0xb5, + 0x13, 0x56, 0x19, 0x1a, 0x06, 0x58, 0x22, 0xa5, 0xb0, 0x44, 0xc8, 0x12, 0x72, 0xdb, 0x23, 0xa8, + 0x94, 0xc4, 0xa9, 0xed, 0xa0, 0xf2, 0x04, 0xac, 0xf0, 0x0a, 0x8c, 0x3c, 0x09, 0x62, 0xea, 0xc8, + 0x88, 0x92, 0x8d, 0x9d, 0x1d, 0xc5, 0xb1, 0x48, 0x3b, 0xa6, 0x6b, 0x8e, 0xbe, 0xff, 0xfc, 0x27, + 0x49, 0x30, 0x9d, 0x69, 0x0d, 0x26, 0x12, 0xb9, 0x49, 0x81, 0x66, 0x72, 0x55, 0xa6, 0xa0, 0xe9, + 0x96, 0x66, 0x60, 0x84, 0xa6, 0x9b, 0x12, 0xd4, 0x1a, 0x34, 0x2d, 0x84, 0x12, 0x19, 0x18, 0x50, + 0x9a, 0x6a, 0x50, 0x0f, 0xeb, 0x25, 0x90, 0x42, 0x49, 0x23, 0x87, 0x64, 0x4f, 0x13, 0xa7, 0xc9, + 0x96, 0x58, 0x4d, 0x9c, 0x26, 0x9d, 0x1e, 0x85, 0x3d, 0xb7, 0x35, 0x8f, 0x1e, 0x6f, 0x15, 0x6c, + 0x4a, 0xd0, 0xa6, 0xdd, 0x39, 0x3a, 0x3f, 0x32, 0x43, 0x17, 0x32, 0xd7, 0xae, 0xf8, 0xf8, 0x05, + 0x05, 0xff, 0xe6, 0xcd, 0x60, 0xf8, 0x84, 0x82, 0xc1, 0xa5, 0xc8, 0x57, 0x29, 0x0c, 0xa7, 0x3d, + 0xcf, 0x21, 0x36, 0xe1, 0xaa, 0x6d, 0x37, 0x3a, 0x3b, 0x52, 0xb7, 0xbd, 0x4e, 0xbc, 0xf0, 0xc7, + 0x7f, 0xaf, 0x30, 0xda, 0x55, 0x18, 0x7d, 0x55, 0x18, 0x3d, 0xd7, 0xd8, 0xdb, 0xd5, 0xd8, 0xfb, + 0xac, 0xb1, 0x17, 0x8c, 0x97, 0x32, 0xeb, 0x19, 0x1f, 0xfe, 0xbf, 0x6e, 0x3f, 0x55, 0xdc, 0x1c, + 0x1c, 0xa3, 0x9b, 0xd3, 0xbb, 0xb5, 0xb9, 0x2f, 0x17, 0x64, 0x29, 0x33, 0xda, 0xef, 0x15, 0xbe, + 0xfa, 0x83, 0x59, 0x94, 0x44, 0xf3, 0xf8, 0xcd, 0x3f, 0x28, 0x11, 0xb9, 0x12, 0x09, 0x89, 0x6c, + 0x89, 0xb9, 0x2b, 0x11, 0xff, 0xc9, 0x8f, 0x03, 0xc0, 0x1d, 0xe0, 0x09, 0xb7, 0x80, 0x3b, 0xc0, + 0x3b, 0x50, 0xf9, 0xac, 0x1f, 0xe0, 0x17, 0x71, 0xd8, 0xcc, 0x56, 0xc2, 0x88, 0x6f, 0x7f, 0xb2, + 0x87, 0x19, 0x73, 0x9a, 0xb1, 0x84, 0x31, 0xeb, 0x19, 0x73, 0x01, 0x8c, 0x75, 0x09, 0x8b, 0x81, + 0xfd, 0x25, 0x26, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x64, 0xc4, 0x78, 0xfa, 0x0b, 0x03, 0x00, + 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// QueryClient is the client API for Query service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type QueryClient interface { + Handle(ctx context.Context, in *QueryRequest, opts ...grpc.CallOption) (*QueryResponse, error) +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +func (c *queryClient) Handle(ctx context.Context, in *QueryRequest, opts ...grpc.CallOption) (*QueryResponse, error) { + out := new(QueryResponse) + err := c.cc.Invoke(ctx, "/AssetMantle.modules.x.metas.queries.parameters.Query/Handle", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +type QueryServer interface { + Handle(context.Context, *QueryRequest) (*QueryResponse, error) +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func (*UnimplementedQueryServer) Handle(ctx context.Context, req *QueryRequest) (*QueryResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Handle not implemented") +} + +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) +} + +func _Query_Handle_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Handle(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/AssetMantle.modules.x.metas.queries.parameters.Query/Handle", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Handle(ctx, req.(*QueryRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "AssetMantle.modules.x.metas.queries.parameters.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Handle", + Handler: _Query_Handle_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "AssetMantle/modules/x/metas/queries/parameters/service.proto", +} diff --git a/x/metas/queries/prototype.go b/x/metas/queries/prototype.go index 199c5f521..599c92589 100644 --- a/x/metas/queries/prototype.go +++ b/x/metas/queries/prototype.go @@ -8,11 +8,13 @@ import ( baseHelpers "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/x/metas/queries/meta" "github.com/AssetMantle/modules/x/metas/queries/metas" + "github.com/AssetMantle/modules/x/metas/queries/parameters" ) func Prototype() helpers.Queries { return baseHelpers.NewQueries( meta.Query, metas.Query, + parameters.Query, ) } diff --git a/x/metas/queries/prototype_test.go b/x/metas/queries/prototype_test.go index 3b15a28e4..654e3a64b 100644 --- a/x/metas/queries/prototype_test.go +++ b/x/metas/queries/prototype_test.go @@ -13,7 +13,7 @@ import ( ) func TestPrototype(t *testing.T) { - require.Equal(t, Prototype().GetQuery("metas").GetName(), baseHelpers.NewQueries( + require.Equal(t, Prototype().GetQuery("metas").GetServicePath(), baseHelpers.NewQueries( meta.Query, - ).GetQuery("metas").GetName()) + ).GetQuery("metas").GetServicePath()) } diff --git a/x/metas/record/record.go b/x/metas/record/record.go index d5a8c741d..943a999ac 100644 --- a/x/metas/record/record.go +++ b/x/metas/record/record.go @@ -1,14 +1,13 @@ package record import ( - "github.com/AssetMantle/schema/data" - baseIDs "github.com/AssetMantle/schema/ids/base" - sdkTypes "github.com/cosmos/cosmos-sdk/types" - "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/x/metas/key" "github.com/AssetMantle/modules/x/metas/mappable" + "github.com/AssetMantle/schema/data" + baseIDs "github.com/AssetMantle/schema/ids/base" + sdkTypes "github.com/cosmos/cosmos-sdk/types" ) func (record *Record) GetKey() helpers.Key { diff --git a/x/metas/simulator/genesis.go b/x/metas/simulator/genesis.go index a34f49b9b..6901bc215 100644 --- a/x/metas/simulator/genesis.go +++ b/x/metas/simulator/genesis.go @@ -4,14 +4,13 @@ package simulator import ( - "math" - "math/rand" - "github.com/AssetMantle/schema/data" baseData "github.com/AssetMantle/schema/data/base" "github.com/AssetMantle/schema/lists/base" sdkTypes "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" + "math" + "math/rand" "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" diff --git a/x/metas/simulator/operations.go b/x/metas/simulator/operations.go index 81df6e4af..f017d4c43 100644 --- a/x/metas/simulator/operations.go +++ b/x/metas/simulator/operations.go @@ -4,13 +4,12 @@ package simulator import ( - "math/rand" - "github.com/cosmos/cosmos-sdk/baseapp" sdkTypes "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" simulationTypes "github.com/cosmos/cosmos-sdk/types/simulation" "github.com/cosmos/cosmos-sdk/x/simulation" + "math/rand" "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/helpers/base" diff --git a/x/metas/simulator/proposals.go b/x/metas/simulator/proposals.go index 776c4f2bc..53aac918f 100644 --- a/x/metas/simulator/proposals.go +++ b/x/metas/simulator/proposals.go @@ -4,28 +4,28 @@ package simulator import ( - "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" - "math/rand" - sdkTypes "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" simulationTypes "github.com/cosmos/cosmos-sdk/types/simulation" + govSimulation "github.com/cosmos/cosmos-sdk/x/gov/simulation" + "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" "github.com/cosmos/cosmos-sdk/x/simulation" + "math/rand" ) -func (simulator) WeightedProposalContentList(module.SimulationState) []simulationTypes.WeightedProposalContent { - return []simulationTypes.WeightedProposalContent{ - simulation.NewWeightedProposalContent( +func (simulator) ProposalMessages(_ module.SimulationState) []simulationTypes.WeightedProposalMsg { + return []simulationTypes.WeightedProposalMsg{ + simulation.NewWeightedProposalMsg( OpWeightSubmitTextProposal, DefaultWeightTextProposal, - simulateTextProposalContent, + func(r *rand.Rand, _ sdkTypes.Context, simulationAccounts []simulationTypes.Account) sdkTypes.Msg { + msgSubmitProposal, err := v1beta1.NewMsgSubmitProposal(v1beta1.NewTextProposal(simulationTypes.RandStringOfLength(r, 140), simulationTypes.RandStringOfLength(r, 5000)), govSimulation.GenDepositParamsMinDeposit(r), simulationAccounts[r.Intn(len(simulationAccounts))].Address) + if err != nil { + panic(err) + } + + return msgSubmitProposal + }, ), } } - -func simulateTextProposalContent(r *rand.Rand, _ sdkTypes.Context, _ []simulationTypes.Account) simulationTypes.Content { - return v1beta1.NewTextProposal( - simulationTypes.RandStringOfLength(r, 140), - simulationTypes.RandStringOfLength(r, 5000), - ) -} diff --git a/x/metas/transactions/prototype_test.go b/x/metas/transactions/prototype_test.go index 12d33dfbc..da40651ef 100644 --- a/x/metas/transactions/prototype_test.go +++ b/x/metas/transactions/prototype_test.go @@ -13,7 +13,7 @@ import ( ) func TestPrototype(t *testing.T) { - require.Equal(t, Prototype().GetTransaction("reveal").GetName(), baseHelpers.NewTransactions( + require.Equal(t, Prototype().GetTransaction("reveal").GetServicePath(), baseHelpers.NewTransactions( reveal.Transaction, - ).GetTransaction("reveal").GetName()) + ).GetTransaction("reveal").GetServicePath()) } diff --git a/x/metas/transactions/reveal/message.go b/x/metas/transactions/reveal/message.go index d9c1ab02e..8f3ffe258 100644 --- a/x/metas/transactions/reveal/message.go +++ b/x/metas/transactions/reveal/message.go @@ -4,26 +4,15 @@ package reveal import ( - codecUtilities "github.com/AssetMantle/schema/codec/utilities" + "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/schema/data" baseData "github.com/AssetMantle/schema/data/base" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/types" sdkTypes "github.com/cosmos/cosmos-sdk/types" - - "github.com/AssetMantle/modules/helpers" ) var _ helpers.Message = (*Message)(nil) -func (message *Message) Type() string { return Transaction.GetName() } -func (message *Message) GetFromAddress() sdkTypes.AccAddress { - from, err := sdkTypes.AccAddressFromBech32(message.From) - if err != nil { - panic(err) - } - return from -} func (message *Message) ValidateBasic() error { if _, err := sdkTypes.AccAddressFromBech32(message.From); err != nil { return err @@ -40,21 +29,10 @@ func (message *Message) GetSigners() []sdkTypes.AccAddress { } return []sdkTypes.AccAddress{from} } -func (*Message) RegisterLegacyAminoCodec(legacyAmino *codec.LegacyAmino) { - codecUtilities.RegisterModuleConcrete(legacyAmino, Message{}) -} func (message *Message) RegisterInterface(interfaceRegistry types.InterfaceRegistry) { interfaceRegistry.RegisterImplementations((*sdkTypes.Msg)(nil), message) } -func messageFromInterface(msg sdkTypes.Msg) *Message { - switch value := msg.(type) { - case *Message: - return value - default: - return &Message{} - } -} func messagePrototype() helpers.Message { return &Message{} } diff --git a/x/metas/transactions/reveal/message_test.go b/x/metas/transactions/reveal/message_test.go index 72f364fba..b3c1ca7ff 100644 --- a/x/metas/transactions/reveal/message_test.go +++ b/x/metas/transactions/reveal/message_test.go @@ -22,12 +22,9 @@ func Test_Reveal_Message(t *testing.T) { testMessage := NewMessage(fromAccAddress, newData).(*Message) require.Equal(t, &Message{From: fromAccAddress.String(), Data: newData.ToAnyData().(*baseData.AnyData)}, testMessage) - require.Equal(t, Transaction.GetName(), testMessage.Type()) require.Equal(t, nil, testMessage.ValidateBasic()) require.NotNil(t, (&Message{}).ValidateBasic()) require.Equal(t, []sdkTypes.AccAddress{fromAccAddress}, testMessage.GetSigners()) - require.Equal(t, testMessage, messageFromInterface(testMessage)) - require.Equal(t, &Message{}, messageFromInterface(nil)) require.Equal(t, &Message{}, messagePrototype()) } diff --git a/x/metas/transactions/reveal/service.pb.go b/x/metas/transactions/reveal/service.pb.go index 46888a0db..9f1ae312c 100644 --- a/x/metas/transactions/reveal/service.pb.go +++ b/x/metas/transactions/reveal/service.pb.go @@ -6,9 +6,9 @@ package reveal import ( context "context" fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types/msgservice" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" - _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -31,30 +31,29 @@ func init() { } var fileDescriptor_afd3f92ba94b138a = []byte{ - // 358 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0xd2, 0xb1, 0x4a, 0x03, 0x31, - 0x18, 0x07, 0xf0, 0xde, 0x09, 0x1d, 0x0e, 0xa7, 0x22, 0x0e, 0x47, 0xb9, 0xa1, 0x0f, 0x90, 0x80, - 0x75, 0x90, 0x88, 0x43, 0x8b, 0xa0, 0x08, 0x81, 0x52, 0x3b, 0x1c, 0x72, 0x20, 0xe9, 0x35, 0x9c, - 0x07, 0x97, 0xa4, 0x5c, 0xd2, 0xd2, 0xd9, 0x27, 0x10, 0x7c, 0x03, 0x07, 0x07, 0x07, 0x9f, 0x43, - 0x9c, 0x0a, 0x2e, 0x8e, 0x72, 0x75, 0xf2, 0x15, 0x5c, 0xa4, 0x49, 0xc0, 0x74, 0xcc, 0x9a, 0xf0, - 0xfb, 0xf3, 0xff, 0x92, 0x2f, 0x3a, 0x1b, 0x48, 0x49, 0x15, 0x26, 0x5c, 0x55, 0x14, 0x32, 0x31, - 0x5b, 0x54, 0x54, 0xc2, 0x15, 0x64, 0x54, 0x11, 0x09, 0x55, 0x4d, 0xb8, 0x24, 0xb9, 0x2a, 0x05, - 0x97, 0xb0, 0xa6, 0x4b, 0x4a, 0x2a, 0x28, 0x69, 0xbd, 0x2c, 0x73, 0x0a, 0xe6, 0xb5, 0x50, 0xa2, - 0x03, 0x1d, 0x0e, 0x2c, 0x07, 0x2b, 0xa0, 0x39, 0x70, 0x39, 0x30, 0x3c, 0xee, 0x16, 0x42, 0x14, - 0x15, 0x85, 0x64, 0x5e, 0x42, 0xc2, 0xb9, 0x50, 0xc4, 0x5c, 0xeb, 0xb8, 0xd8, 0xbb, 0x0d, 0xa3, - 0x52, 0x92, 0xc2, 0xb6, 0x89, 0xaf, 0x7c, 0xb9, 0x73, 0x76, 0x5b, 0x53, 0x39, 0x17, 0x5c, 0xda, - 0xac, 0xa3, 0xd7, 0x20, 0xda, 0xc3, 0xb2, 0xe8, 0x3c, 0x07, 0x51, 0xfb, 0x92, 0xf0, 0x59, 0x45, - 0x3b, 0x27, 0xc0, 0x73, 0x5a, 0x80, 0x4d, 0xbd, 0xf8, 0xdc, 0x5b, 0x4e, 0xfe, 0xcf, 0xc6, 0xb6, - 0x58, 0xaf, 0x7b, 0xff, 0xf1, 0xfd, 0x18, 0x1e, 0xf6, 0x0e, 0x20, 0xb3, 0x23, 0xea, 0xc1, 0x8c, - 0x18, 0xfe, 0x86, 0x6f, 0x4d, 0x12, 0xac, 0x9b, 0x24, 0xf8, 0x6a, 0x92, 0xe0, 0x61, 0x93, 0xb4, - 0xd6, 0x9b, 0xa4, 0xf5, 0xb9, 0x49, 0x5a, 0x51, 0x3f, 0x17, 0xcc, 0xb7, 0xc1, 0x70, 0xff, 0xda, - 0xfc, 0xf4, 0x68, 0xfb, 0x1c, 0xa3, 0xe0, 0x06, 0x15, 0xa5, 0xba, 0x5b, 0x4c, 0x41, 0x2e, 0x18, - 0xf4, 0x7c, 0xe7, 0xa7, 0xb0, 0x3d, 0xc0, 0x29, 0x9e, 0x8c, 0x5f, 0xc2, 0x9d, 0x85, 0xc1, 0xb6, - 0x46, 0x0a, 0xb0, 0xae, 0x31, 0x71, 0x6b, 0x8c, 0x35, 0x7d, 0xdf, 0x11, 0x99, 0x15, 0x59, 0x9a, - 0x69, 0x91, 0xb9, 0x22, 0x33, 0xa2, 0x09, 0x4f, 0x3d, 0x45, 0x76, 0x31, 0x1a, 0x6e, 0x2f, 0x67, - 0x44, 0x91, 0x9f, 0xf0, 0xd8, 0xd1, 0x08, 0x59, 0x8e, 0x50, 0x8a, 0x90, 0x0e, 0x40, 0xc8, 0x4d, - 0x40, 0xc8, 0x44, 0x4c, 0xdb, 0x7a, 0x6b, 0xfa, 0x7f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xe2, 0x9c, - 0x0e, 0xa0, 0x50, 0x03, 0x00, 0x00, + // 347 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0xd2, 0x31, 0x4b, 0xc3, 0x40, + 0x14, 0x07, 0xf0, 0x5c, 0xc4, 0x0e, 0xc1, 0xa9, 0x8b, 0x90, 0x21, 0x83, 0xa3, 0xc3, 0x1d, 0x5a, + 0x07, 0x39, 0x71, 0x68, 0x11, 0x14, 0xe1, 0xa0, 0xd4, 0x0e, 0x41, 0x02, 0x72, 0x4d, 0x8f, 0x58, + 0xc8, 0xe5, 0x4a, 0xde, 0xb5, 0x74, 0x74, 0x76, 0x72, 0x75, 0x75, 0x74, 0xf2, 0x63, 0x88, 0x53, + 0x47, 0x47, 0x49, 0x07, 0xc1, 0xaf, 0xe0, 0x22, 0x49, 0x0e, 0xbc, 0x8e, 0x37, 0x05, 0x2e, 0xfc, + 0xfe, 0xf9, 0xbf, 0xdc, 0x0b, 0xce, 0xfb, 0x00, 0x42, 0x33, 0x5e, 0xe8, 0x5c, 0x10, 0xa9, 0xa6, + 0x8b, 0x5c, 0x00, 0x59, 0x11, 0x29, 0x34, 0x07, 0xa2, 0x4b, 0x5e, 0x00, 0x4f, 0xf5, 0x4c, 0x15, + 0x40, 0x4a, 0xb1, 0x14, 0x3c, 0x27, 0x20, 0xca, 0xe5, 0x2c, 0x15, 0x78, 0x5e, 0x2a, 0xad, 0xba, + 0xc4, 0xe2, 0xd8, 0x70, 0xbc, 0xc2, 0x0d, 0xc7, 0x36, 0xc7, 0x2d, 0x0f, 0xf7, 0x53, 0x05, 0x52, + 0x01, 0x91, 0x90, 0x91, 0xe5, 0x51, 0xfd, 0x68, 0x93, 0x42, 0xe7, 0x22, 0x52, 0x00, 0xf0, 0xcc, + 0x14, 0x09, 0xaf, 0x5d, 0xb9, 0x75, 0x76, 0x57, 0x0a, 0x98, 0xab, 0x02, 0x4c, 0xd6, 0xf1, 0x33, + 0x0a, 0x76, 0x18, 0x64, 0xdd, 0x47, 0x14, 0x74, 0xae, 0x78, 0x31, 0xcd, 0x45, 0xf7, 0x14, 0x3b, + 0x0e, 0x8a, 0x59, 0x5b, 0x2f, 0xbc, 0x70, 0x96, 0xe3, 0xff, 0xb3, 0x91, 0x29, 0x76, 0xe0, 0x85, + 0xbb, 0x0f, 0xdf, 0x6f, 0x87, 0x68, 0xf0, 0xeb, 0xbf, 0x57, 0x11, 0x5a, 0x57, 0x11, 0xfa, 0xaa, + 0x22, 0xf4, 0xb4, 0x89, 0xbc, 0xf5, 0x26, 0xf2, 0x3e, 0x37, 0x91, 0x17, 0xf4, 0x52, 0x25, 0x5d, + 0x3f, 0x36, 0xd8, 0xbb, 0x69, 0xef, 0x73, 0x58, 0x4f, 0x3e, 0x44, 0xb7, 0x34, 0x9b, 0xe9, 0xfb, + 0xc5, 0x04, 0xa7, 0x4a, 0x12, 0xc7, 0x5f, 0xfa, 0xe2, 0x77, 0xfa, 0x2c, 0x66, 0xe3, 0xd1, 0xab, + 0xbf, 0xb5, 0x16, 0xcc, 0xd4, 0x88, 0x31, 0x6b, 0x6a, 0x8c, 0xed, 0x1a, 0xa3, 0x86, 0x7e, 0x6c, + 0x89, 0xc4, 0x88, 0x24, 0x4e, 0x1a, 0x91, 0xd8, 0x22, 0x69, 0x45, 0xe5, 0x9f, 0x39, 0x8a, 0xe4, + 0x72, 0x38, 0xa8, 0x5f, 0x4e, 0xb9, 0xe6, 0x3f, 0xfe, 0x89, 0xa5, 0x29, 0x35, 0x9c, 0xd2, 0x98, + 0xd2, 0x26, 0x80, 0x52, 0x3b, 0x81, 0xd2, 0x36, 0x62, 0xd2, 0x69, 0x16, 0xa4, 0xf7, 0x17, 0x00, + 0x00, 0xff, 0xff, 0x5e, 0x91, 0xda, 0x02, 0x36, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/metas/transactions/reveal/service.pb.gw.go b/x/metas/transactions/reveal/service.pb.gw.go deleted file mode 100644 index c1f032e62..000000000 --- a/x/metas/transactions/reveal/service.pb.gw.go +++ /dev/null @@ -1,171 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: AssetMantle/modules/x/metas/transactions/reveal/service.proto - -/* -Package reveal is a reverse proxy. - -It translates gRPC into RESTful JSON APIs. -*/ -package reveal - -import ( - "context" - "io" - "net/http" - - "github.com/golang/protobuf/descriptor" - "github.com/golang/protobuf/proto" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/grpc-ecosystem/grpc-gateway/utilities" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/status" -) - -// Suppress "imported and not used" errors -var _ codes.Code -var _ io.Reader -var _ status.Status -var _ = runtime.String -var _ = utilities.NewDoubleArray -var _ = descriptor.ForMessage -var _ = metadata.Join - -var ( - filter_Msg_Handle_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - -func request_Msg_Handle_0(ctx context.Context, marshaler runtime.Marshaler, client MsgClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq Message - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.Handle(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Msg_Handle_0(ctx context.Context, marshaler runtime.Marshaler, server MsgServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq Message - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.Handle(ctx, &protoReq) - return msg, metadata, err - -} - -// RegisterMsgHandlerServer registers the http handlers for service Msg to "mux". -// UnaryRPC :call MsgServer directly. -// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterMsgHandlerFromEndpoint instead. -func RegisterMsgHandlerServer(ctx context.Context, mux *runtime.ServeMux, server MsgServer) error { - - mux.Handle("POST", pattern_Msg_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Msg_Handle_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Msg_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -// RegisterMsgHandlerFromEndpoint is same as RegisterMsgHandler but -// automatically dials to "endpoint" and closes the connection when "ctx" gets done. -func RegisterMsgHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.Dial(endpoint, opts...) - if err != nil { - return err - } - defer func() { - if err != nil { - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - return - } - go func() { - <-ctx.Done() - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - }() - }() - - return RegisterMsgHandler(ctx, mux, conn) -} - -// RegisterMsgHandler registers the http handlers for service Msg to "mux". -// The handlers forward requests to the grpc endpoint over "conn". -func RegisterMsgHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { - return RegisterMsgHandlerClient(ctx, mux, NewMsgClient(conn)) -} - -// RegisterMsgHandlerClient registers the http handlers for service Msg -// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "MsgClient". -// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "MsgClient" -// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "MsgClient" to call the correct interceptors. -func RegisterMsgHandlerClient(ctx context.Context, mux *runtime.ServeMux, client MsgClient) error { - - mux.Handle("POST", pattern_Msg_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Msg_Handle_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Msg_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -var ( - pattern_Msg_Handle_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"mantle", "metas", "reveal"}, "", runtime.AssumeColonVerbOpt(false))) -) - -var ( - forward_Msg_Handle_0 = runtime.ForwardResponseMessage -) diff --git a/x/metas/transactions/reveal/transaction.go b/x/metas/transactions/reveal/transaction.go index b6b53e694..f698f74a1 100644 --- a/x/metas/transactions/reveal/transaction.go +++ b/x/metas/transactions/reveal/transaction.go @@ -4,22 +4,14 @@ package reveal import ( - "context" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "google.golang.org/grpc" - "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/helpers/constants" - "github.com/AssetMantle/modules/utilities/name" + "google.golang.org/grpc" ) -type dummy struct{} - var Transaction = baseHelpers.NewTransaction( - name.GetPackageName(dummy{}), + _Msg_serviceDesc.ServiceName, "", "", @@ -30,9 +22,6 @@ var Transaction = baseHelpers.NewTransaction( func(server grpc.ServiceRegistrar, keeper helpers.TransactionKeeper) { RegisterMsgServer(server, keeper.(transactionKeeper)) }, - func(clientCtx client.Context, mux *runtime.ServeMux) error { - return RegisterMsgHandlerClient(context.Background(), mux, NewMsgClient(clientCtx)) - }, constants.Data, ) diff --git a/x/metas/transactions/reveal/transaction_keeper.go b/x/metas/transactions/reveal/transaction_keeper.go index cbc0980d6..9c9960d98 100644 --- a/x/metas/transactions/reveal/transaction_keeper.go +++ b/x/metas/transactions/reveal/transaction_keeper.go @@ -6,7 +6,6 @@ package reveal import ( "context" errorConstants "github.com/AssetMantle/modules/helpers/constants" - "github.com/AssetMantle/schema/data" baseIDs "github.com/AssetMantle/schema/ids/base" constantProperties "github.com/AssetMantle/schema/properties/constants" diff --git a/x/metas/transactions/reveal/transaction_request.go b/x/metas/transactions/reveal/transaction_request.go index 17cffb0fa..2e4beda82 100644 --- a/x/metas/transactions/reveal/transaction_request.go +++ b/x/metas/transactions/reveal/transaction_request.go @@ -5,21 +5,19 @@ package reveal import ( "encoding/json" - "github.com/AssetMantle/modules/utilities/rest" - - codecUtilities "github.com/AssetMantle/schema/codec/utilities" "github.com/AssetMantle/schema/data/base" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" + "io" + "net/http" "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/helpers/constants" ) type transactionRequest struct { - BaseReq rest.BaseReq `json:"baseReq"` - Data string `json:"data"` + helpers.CommonTransactionRequest `json:"commonTransactionRequest"` + Data string `json:"data"` } var _ helpers.TransactionRequest = (*transactionRequest)(nil) @@ -45,22 +43,27 @@ func (transactionRequest transactionRequest) Validate() error { } func (transactionRequest transactionRequest) FromCLI(cliCommand helpers.CLICommand, context client.Context) (helpers.TransactionRequest, error) { return newTransactionRequest( - cliCommand.ReadBaseReq(context), + cliCommand.ReadCommonTransactionRequest(context), cliCommand.ReadString(constants.Data), ), nil } -func (transactionRequest transactionRequest) FromJSON(rawMessage json.RawMessage) (helpers.TransactionRequest, error) { - if err := json.Unmarshal(rawMessage, &transactionRequest); err != nil { +func (transactionRequest transactionRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.TransactionRequest, error) { + body, err := io.ReadAll(httpRequest.Body) + if err != nil { + return nil, err + } + + if err := json.Unmarshal(body, &transactionRequest); err != nil { return nil, err } return transactionRequest, nil } -func (transactionRequest transactionRequest) GetBaseReq() rest.BaseReq { - return transactionRequest.BaseReq +func (transactionRequest transactionRequest) GetCommonTransactionRequest() helpers.CommonTransactionRequest { + return transactionRequest.CommonTransactionRequest } func (transactionRequest transactionRequest) MakeMsg() (sdkTypes.Msg, error) { - from, err := sdkTypes.AccAddressFromBech32(transactionRequest.GetBaseReq().From) + from, err := sdkTypes.AccAddressFromBech32(transactionRequest.GetCommonTransactionRequest().GetFrom()) if err != nil { return nil, err } @@ -75,15 +78,12 @@ func (transactionRequest transactionRequest) MakeMsg() (sdkTypes.Msg, error) { data, ), nil } -func (transactionRequest) RegisterLegacyAminoCodec(legacyAmino *codec.LegacyAmino) { - codecUtilities.RegisterModuleConcrete(legacyAmino, transactionRequest{}) -} func requestPrototype() helpers.TransactionRequest { return transactionRequest{} } -func newTransactionRequest(baseReq rest.BaseReq, data string) helpers.TransactionRequest { +func newTransactionRequest(commonTransactionRequest helpers.CommonTransactionRequest, data string) helpers.TransactionRequest { return transactionRequest{ - BaseReq: baseReq, - Data: data, + CommonTransactionRequest: commonTransactionRequest, + Data: data, } } diff --git a/x/metas/transactions/reveal/transaction_request_test.go b/x/metas/transactions/reveal/transaction_request_test.go index 873eb080b..ea8610bcc 100644 --- a/x/metas/transactions/reveal/transaction_request_test.go +++ b/x/metas/transactions/reveal/transaction_request_test.go @@ -2,61 +2,3 @@ // SPDX-License-Identifier: Apache-2.0 package reveal - -import ( - "encoding/json" - "github.com/AssetMantle/modules/utilities/rest" - "github.com/cosmos/cosmos-sdk/client" - "testing" - - "github.com/cosmos/cosmos-sdk/codec" - sdkTypes "github.com/cosmos/cosmos-sdk/types" - - "github.com/stretchr/testify/require" - - "github.com/AssetMantle/modules/helpers" - baseHelpers "github.com/AssetMantle/modules/helpers/base" - "github.com/AssetMantle/modules/helpers/constants" -) - -func Test_Reveal_Request(t *testing.T) { - cliCommand := baseHelpers.NewCLICommand("", "", "", []helpers.CLIFlag{constants.Data}) - - fromAddress := "cosmos1pkkayn066msg6kn33wnl5srhdt3tnu2vzasz9c" - data := "S|newData" - testBaseReq := rest.BaseReq{From: fromAddress, ChainID: "test", Fees: sdkTypes.NewCoins()} - testTransactionRequest := newTransactionRequest(testBaseReq, data) - - require.Equal(t, transactionRequest{BaseReq: testBaseReq, Data: data}, testTransactionRequest) - require.Equal(t, nil, testTransactionRequest.Validate()) - - requestFromCLI, err := transactionRequest{}.FromCLI(cliCommand, client.Context{}.WithCodec(baseHelpers.CodecPrototype())) - require.Equal(t, nil, err) - require.Equal(t, transactionRequest{BaseReq: rest.BaseReq{From: client.Context{}.WithCodec(baseHelpers.CodecPrototype()).GetFromAddress().String(), ChainID: client.Context{}.WithCodec(baseHelpers.CodecPrototype()).ChainID, Simulate: client.Context{}.WithCodec(baseHelpers.CodecPrototype()).Simulate}, Data: ""}, requestFromCLI) - - jsonMessage, _ := json.Marshal(testTransactionRequest) - transactionRequestUnmarshalled, err := transactionRequest{}.FromJSON(jsonMessage) - require.Equal(t, nil, err) - require.Equal(t, testTransactionRequest, transactionRequestUnmarshalled) - - randomUnmarshall, err := transactionRequest{}.FromJSON([]byte{}) - require.Equal(t, nil, randomUnmarshall) - require.NotNil(t, err) - - require.Equal(t, testBaseReq, testTransactionRequest.GetBaseReq()) - - require.Nil(t, err) - - msg2, err := newTransactionRequest(rest.BaseReq{From: "randomFromAddress", ChainID: "test"}, data).MakeMsg() - require.NotNil(t, err) - require.Nil(t, msg2) - - msg2, err = newTransactionRequest(rest.BaseReq{From: fromAddress, ChainID: "test"}, "randomString").MakeMsg() - require.NotNil(t, err) - require.Nil(t, msg2) - - require.Equal(t, transactionRequest{}, requestPrototype()) - require.NotPanics(t, func() { - requestPrototype().RegisterLegacyAminoCodec(codec.NewLegacyAmino()) - }) -} diff --git a/x/metas/transactions/reveal/transaction_response.go b/x/metas/transactions/reveal/transaction_response.go index 69806b91f..bb0763e31 100644 --- a/x/metas/transactions/reveal/transaction_response.go +++ b/x/metas/transactions/reveal/transaction_response.go @@ -4,9 +4,8 @@ package reveal import ( - sdkTypes "github.com/cosmos/cosmos-sdk/types" - "github.com/AssetMantle/modules/helpers" + sdkTypes "github.com/cosmos/cosmos-sdk/types" ) var _ helpers.TransactionResponse = (*TransactionResponse)(nil) diff --git a/x/orders/block/block.go b/x/orders/block/block.go index 7337cd69c..7d9de455c 100755 --- a/x/orders/block/block.go +++ b/x/orders/block/block.go @@ -5,7 +5,6 @@ package block import ( "context" - "github.com/AssetMantle/schema/types/base" abciTypes "github.com/cometbft/cometbft/abci/types" diff --git a/x/orders/constants/module.go b/x/orders/constants/module.go index eef13c9b0..ee996a74b 100644 --- a/x/orders/constants/module.go +++ b/x/orders/constants/module.go @@ -4,9 +4,8 @@ package constants import ( - "github.com/AssetMantle/schema/documents/base" - "github.com/AssetMantle/modules/utilities/name" + "github.com/AssetMantle/schema/documents/base" ) type dummy struct{} diff --git a/x/orders/genesis/genesis.go b/x/orders/genesis/genesis.go index eeef7eb49..b3f752ba8 100644 --- a/x/orders/genesis/genesis.go +++ b/x/orders/genesis/genesis.go @@ -3,7 +3,6 @@ package genesis import ( "context" errorConstants "github.com/AssetMantle/modules/helpers/constants" - "github.com/AssetMantle/schema/lists" "github.com/AssetMantle/schema/lists/base" sdkCodec "github.com/cosmos/cosmos-sdk/codec" diff --git a/x/orders/key/key.go b/x/orders/key/key.go index 63544a956..061d5f363 100644 --- a/x/orders/key/key.go +++ b/x/orders/key/key.go @@ -4,11 +4,10 @@ package key import ( + "github.com/AssetMantle/modules/helpers" errorConstants "github.com/AssetMantle/modules/helpers/constants" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" - - "github.com/AssetMantle/modules/helpers" ) var _ helpers.Key = (*Key)(nil) @@ -22,7 +21,7 @@ func (key *Key) ValidateBasic() error { return nil } func (key *Key) GenerateStorePrefixBytes() []byte { - return []byte{} + return []byte{0x0} } func (key *Key) GenerateStoreKeyBytes() []byte { return key.OrderID.Bytes() diff --git a/x/orders/mappable/mappable.go b/x/orders/mappable/mappable.go index ebc5368f1..8d6c2111b 100644 --- a/x/orders/mappable/mappable.go +++ b/x/orders/mappable/mappable.go @@ -4,12 +4,9 @@ package mappable import ( - codecUtilities "github.com/AssetMantle/schema/codec/utilities" + "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/schema/documents" "github.com/AssetMantle/schema/documents/base" - "github.com/cosmos/cosmos-sdk/codec" - - "github.com/AssetMantle/modules/helpers" ) var _ helpers.Mappable = (*Mappable)(nil) @@ -17,9 +14,6 @@ var _ helpers.Mappable = (*Mappable)(nil) func (mappable *Mappable) ValidateBasic() error { return mappable.Order.ValidateBasic() } -func (*Mappable) RegisterLegacyAminoCodec(legacyAmino *codec.LegacyAmino) { - codecUtilities.RegisterModuleConcrete(legacyAmino, Mappable{}) -} func NewMappable(order documents.Order) helpers.Mappable { return &Mappable{Order: order.Get().(*base.Document)} diff --git a/x/orders/mappable/mappable_test.go b/x/orders/mappable/mappable_test.go index 4a3d9b87d..dcdd63f3f 100644 --- a/x/orders/mappable/mappable_test.go +++ b/x/orders/mappable/mappable_test.go @@ -7,6 +7,7 @@ import ( "reflect" "testing" + "github.com/AssetMantle/modules/helpers" baseData "github.com/AssetMantle/schema/data/base" "github.com/AssetMantle/schema/documents" baseDocuments "github.com/AssetMantle/schema/documents/base" @@ -14,9 +15,6 @@ import ( baseLists "github.com/AssetMantle/schema/lists/base" baseProperties "github.com/AssetMantle/schema/properties/base" baseQualified "github.com/AssetMantle/schema/qualified/base" - "github.com/cosmos/cosmos-sdk/codec" - - "github.com/AssetMantle/modules/helpers" ) var ( @@ -62,28 +60,3 @@ func TestPrototype(t *testing.T) { }) } } - -func Test_mappable_RegisterCodec(t *testing.T) { - type fields struct { - Order documents.Order - } - type args struct { - legacyAmino *codec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{testOrder}, args{codec.NewLegacyAmino()}}, - {"+ve nil", fields{nil}, args{codec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - ma := &Mappable{ - Order: tt.fields.Order.Get().(*baseDocuments.Document), - } - ma.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} diff --git a/x/orders/parameters/max_order_life/parameter.go b/x/orders/parameters/max_order_life/parameter.go index 7e7a3e147..8be32ef33 100644 --- a/x/orders/parameters/max_order_life/parameter.go +++ b/x/orders/parameters/max_order_life/parameter.go @@ -4,14 +4,13 @@ package max_order_life import ( + baseHelpers "github.com/AssetMantle/modules/helpers/base" errorConstants "github.com/AssetMantle/modules/helpers/constants" baseData "github.com/AssetMantle/schema/data/base" baseParameters "github.com/AssetMantle/schema/parameters/base" baseProperties "github.com/AssetMantle/schema/properties/base" constantProperties "github.com/AssetMantle/schema/properties/constants" baseTypes "github.com/AssetMantle/schema/types/base" - - baseHelpers "github.com/AssetMantle/modules/helpers/base" ) var ID = constantProperties.MaxOrderLifeProperty.GetKey() diff --git a/x/orders/parameters/prototype.go b/x/orders/parameters/prototype.go index 6f0cb4540..f69f7a5c1 100644 --- a/x/orders/parameters/prototype.go +++ b/x/orders/parameters/prototype.go @@ -6,11 +6,10 @@ package parameters import ( "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" - "github.com/AssetMantle/modules/x/orders/constants" "github.com/AssetMantle/modules/x/orders/parameters/max_order_life" "github.com/AssetMantle/modules/x/orders/parameters/put_enabled" ) func Prototype() helpers.ParameterManager { - return baseHelpers.NewParameterManager(constants.ModuleName, max_order_life.ValidatableParameter, put_enabled.ValidatableParameter) + return baseHelpers.NewParameterManager(max_order_life.ValidatableParameter, put_enabled.ValidatableParameter) } diff --git a/x/orders/parameters/prototype_test.go b/x/orders/parameters/prototype_test.go index 3fab7f444..3a6bc1efa 100644 --- a/x/orders/parameters/prototype_test.go +++ b/x/orders/parameters/prototype_test.go @@ -9,7 +9,6 @@ import ( "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" - "github.com/AssetMantle/modules/x/orders/constants" "github.com/AssetMantle/modules/x/orders/parameters/max_order_life" ) @@ -18,7 +17,7 @@ func TestPrototype(t *testing.T) { name string want helpers.ParameterManager }{ - {"+ve", baseHelpers.NewParameterManager(constants.ModuleName, max_order_life.ValidatableParameter)}, + {"+ve", baseHelpers.NewParameterManager(max_order_life.ValidatableParameter)}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { diff --git a/x/orders/parameters/put_enabled/parameter.go b/x/orders/parameters/put_enabled/parameter.go index 008b9a00d..8a691161e 100644 --- a/x/orders/parameters/put_enabled/parameter.go +++ b/x/orders/parameters/put_enabled/parameter.go @@ -4,13 +4,12 @@ package put_enabled import ( + baseHelpers "github.com/AssetMantle/modules/helpers/base" errorConstants "github.com/AssetMantle/modules/helpers/constants" baseData "github.com/AssetMantle/schema/data/base" baseParameters "github.com/AssetMantle/schema/parameters/base" "github.com/AssetMantle/schema/properties/base" constantProperties "github.com/AssetMantle/schema/properties/constants" - - baseHelpers "github.com/AssetMantle/modules/helpers/base" ) var ID = constantProperties.PutEnabledProperty.GetKey() diff --git a/x/orders/queries/order/query.go b/x/orders/queries/order/query.go index a68662056..ec75a24f3 100644 --- a/x/orders/queries/order/query.go +++ b/x/orders/queries/order/query.go @@ -4,28 +4,17 @@ package order import ( - "context" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "google.golang.org/grpc" - "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" helperConstants "github.com/AssetMantle/modules/helpers/constants" - "github.com/AssetMantle/modules/utilities/name" - "github.com/AssetMantle/modules/x/orders/constants" + "google.golang.org/grpc" ) -type dummy struct{} - var Query = baseHelpers.NewQuery( - name.GetPackageName(dummy{}), + _Query_serviceDesc.ServiceName, "", "", - constants.ModuleName, - requestPrototype, responsePrototype, keeperPrototype, @@ -33,9 +22,6 @@ var Query = baseHelpers.NewQuery( func(server grpc.ServiceRegistrar, QueryKeeper helpers.QueryKeeper) { RegisterQueryServer(server, QueryKeeper.(queryKeeper)) }, - func(clientContext client.Context, serveMux *runtime.ServeMux) error { - return RegisterQueryHandlerClient(context.Background(), serveMux, NewQueryClient(clientContext)) - }, helperConstants.OrderID, ) diff --git a/x/orders/queries/order/query_keeper.go b/x/orders/queries/order/query_keeper.go index f5f5faacf..4a2638943 100644 --- a/x/orders/queries/order/query_keeper.go +++ b/x/orders/queries/order/query_keeper.go @@ -5,7 +5,6 @@ package order import ( "context" - "github.com/AssetMantle/modules/helpers" ) @@ -16,7 +15,7 @@ type queryKeeper struct { var _ helpers.QueryKeeper = (*queryKeeper)(nil) func (queryKeeper queryKeeper) Enquire(context context.Context, queryRequest helpers.QueryRequest) (helpers.QueryResponse, error) { - queryResponse, err := queryKeeper.Handle(context, queryRequestFromInterface(queryRequest)) + queryResponse, err := queryKeeper.Handle(context, queryRequest.(*QueryRequest)) return queryResponse, err } func (queryKeeper queryKeeper) Handle(context context.Context, queryRequest *QueryRequest) (*QueryResponse, error) { diff --git a/x/orders/queries/order/query_request.go b/x/orders/queries/order/query_request.go index 0ed7f12a2..5600d8681 100644 --- a/x/orders/queries/order/query_request.go +++ b/x/orders/queries/order/query_request.go @@ -11,7 +11,6 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/AssetMantle/modules/helpers" - "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/helpers/constants" "github.com/AssetMantle/modules/x/orders/key" ) @@ -49,27 +48,10 @@ func (*QueryRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.QueryRe return newQueryRequest(orderID.(ids.OrderID)), nil } } -func (queryRequest *QueryRequest) Encode() ([]byte, error) { - return base.CodecPrototype().MarshalJSON(queryRequest) -} -func (queryRequest *QueryRequest) Decode(bytes []byte) (helpers.QueryRequest, error) { - if err := base.CodecPrototype().UnmarshalJSON(bytes, queryRequest); err != nil { - return nil, err - } - - return queryRequest, nil -} func requestPrototype() helpers.QueryRequest { return &QueryRequest{} } -func queryRequestFromInterface(request helpers.QueryRequest) *QueryRequest { - switch value := request.(type) { - case *QueryRequest: - return value - default: - return &QueryRequest{} - } -} + func newQueryRequest(orderID ids.OrderID) helpers.QueryRequest { return &QueryRequest{Key: key.NewKey(orderID).(*key.Key)} } diff --git a/x/orders/queries/order/query_request_test.go b/x/orders/queries/order/query_request_test.go index 6fb8bca87..2848ce6f4 100644 --- a/x/orders/queries/order/query_request_test.go +++ b/x/orders/queries/order/query_request_test.go @@ -8,6 +8,9 @@ import ( "reflect" "testing" + "github.com/AssetMantle/modules/helpers" + baseHelpers "github.com/AssetMantle/modules/helpers/base" + "github.com/AssetMantle/modules/helpers/constants" baseData "github.com/AssetMantle/schema/data/base" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" @@ -16,11 +19,6 @@ import ( baseQualified "github.com/AssetMantle/schema/qualified/base" "github.com/cosmos/cosmos-sdk/client" "github.com/spf13/viper" - "github.com/stretchr/testify/require" - - "github.com/AssetMantle/modules/helpers" - baseHelpers "github.com/AssetMantle/modules/helpers/base" - "github.com/AssetMantle/modules/helpers/constants" ) var ( @@ -68,85 +66,13 @@ func Test_queryRequestFromInterface(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - if got := queryRequestFromInterface(tt.args.request); !reflect.DeepEqual(got, tt.want) { + if got := tt.args.request.(*QueryRequest); !reflect.DeepEqual(got, tt.want) { t.Errorf("queryRequestFromInterface() = %v, want %v", got, tt.want) } }) } } -func Test_queryRequest_Decode(t *testing.T) { - encodedReq, err := baseHelpers.CodecPrototype().GetLegacyAmino().MarshalJSON(newQueryRequest(testOrderID)) - require.NoError(t, err) - encodedReq1, err1 := baseHelpers.CodecPrototype().GetLegacyAmino().MarshalJSON(newQueryRequest(testOrderID1)) - require.NoError(t, err1) - type fields struct { - Key *key.Key - } - type args struct { - bytes []byte - } - tests := []struct { - name string - fields fields - args args - want helpers.QueryRequest - wantErr bool - }{ - {"+ve", fields{testKey}, args{encodedReq}, newQueryRequest(testOrderID), false}, - {"+ve", fields{testKey1}, args{encodedReq1}, newQueryRequest(testOrderID1), false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - queryRequest := &QueryRequest{ - Key: tt.fields.Key, - } - got, err := queryRequest.Decode(tt.args.bytes) - if (err != nil) != tt.wantErr { - t.Errorf("Decode() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("Decode() got = %v, want %v", got, tt.want) - } - }) - } -} - -func Test_queryRequest_Encode(t *testing.T) { - encodedReq, err := baseHelpers.CodecPrototype().GetLegacyAmino().MarshalJSON(newQueryRequest(testOrderID)) - require.NoError(t, err) - encodedReq1, err1 := baseHelpers.CodecPrototype().GetLegacyAmino().MarshalJSON(newQueryRequest(testOrderID1)) - require.NoError(t, err1) - type fields struct { - Key *key.Key - } - tests := []struct { - name string - fields fields - want []byte - wantErr bool - }{ - {"+ve", fields{testKey}, encodedReq, false}, - {"+ve", fields{testKey1}, encodedReq1, false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - queryRequest := &QueryRequest{ - Key: tt.fields.Key, - } - got, err := queryRequest.Encode() - if (err != nil) != tt.wantErr { - t.Errorf("Encode() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("Encode() got = %v, want %v", got, tt.want) - } - }) - } -} - func Test_queryRequest_FromCLI(t *testing.T) { cliCommand := baseHelpers.NewCLICommand("", "", "", []helpers.CLIFlag{constants.OrderID}) diff --git a/x/orders/queries/order/service.pb.go b/x/orders/queries/order/service.pb.go index 7ddbb9a12..4488fa888 100644 --- a/x/orders/queries/order/service.pb.go +++ b/x/orders/queries/order/service.pb.go @@ -8,7 +8,6 @@ import ( fmt "fmt" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" - _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -31,30 +30,27 @@ func init() { } var fileDescriptor_c8a16121f34d51bd = []byte{ - // 356 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x92, 0x31, 0x4b, 0xc3, 0x40, - 0x18, 0x86, 0x9b, 0x80, 0x1d, 0x82, 0x53, 0xc6, 0x52, 0x6e, 0x10, 0x27, 0x87, 0x3b, 0xaa, 0x28, - 0xf5, 0x06, 0xa5, 0x5d, 0x74, 0x09, 0x6d, 0x75, 0x09, 0x12, 0x90, 0x6b, 0xf3, 0x51, 0x03, 0x69, - 0xae, 0xcd, 0x5d, 0x4a, 0x5d, 0xfd, 0x05, 0x82, 0xff, 0x40, 0x37, 0xc1, 0xff, 0x21, 0x4e, 0x05, - 0x17, 0x17, 0x41, 0x52, 0x27, 0x7f, 0x85, 0xa4, 0xdf, 0x0d, 0xed, 0x96, 0x76, 0x7c, 0x93, 0xf7, - 0xb9, 0xf7, 0x7b, 0xef, 0x3e, 0xa7, 0xd9, 0x52, 0x0a, 0xb4, 0x27, 0x12, 0x1d, 0x03, 0x1b, 0xc9, - 0x30, 0x8b, 0x41, 0xb1, 0x19, 0x93, 0x69, 0x08, 0xa9, 0x62, 0x93, 0x0c, 0xd2, 0x08, 0x14, 0x4a, - 0xa6, 0x20, 0x9d, 0x46, 0x03, 0xa0, 0xe3, 0x54, 0x6a, 0xe9, 0x1e, 0xac, 0x90, 0xd4, 0x90, 0x74, - 0x46, 0x91, 0xa4, 0x86, 0x44, 0x59, 0xab, 0x0f, 0xa5, 0x1c, 0xc6, 0xc0, 0xc4, 0x38, 0x62, 0x22, - 0x49, 0xa4, 0x16, 0x3a, 0x92, 0x89, 0xc2, 0x93, 0x6a, 0x67, 0x1b, 0xcc, 0x50, 0xa8, 0xfb, 0xdb, - 0x14, 0x26, 0x19, 0x28, 0x6d, 0xf8, 0xf3, 0x2d, 0x78, 0x35, 0x96, 0x89, 0x32, 0x55, 0x0e, 0xdf, - 0x2c, 0x67, 0xa7, 0x57, 0xfc, 0x70, 0x5f, 0x2c, 0xa7, 0x7a, 0x29, 0x92, 0x30, 0x06, 0xb7, 0x49, - 0xcb, 0x17, 0xa4, 0x4b, 0xfa, 0x0a, 0xa7, 0xaa, 0x9d, 0x6e, 0x41, 0xe2, 0x3c, 0x7b, 0xfb, 0x0f, - 0x9f, 0xbf, 0x4f, 0x36, 0x71, 0xeb, 0x6c, 0x84, 0x75, 0x4c, 0x89, 0x69, 0xa3, 0x0f, 0x5a, 0x34, - 0x50, 0xb6, 0xbf, 0xed, 0xf7, 0x9c, 0x58, 0xf3, 0x9c, 0x58, 0x3f, 0x39, 0xb1, 0x1e, 0x17, 0xa4, - 0x32, 0x5f, 0x90, 0xca, 0xd7, 0x82, 0x54, 0x1c, 0x3a, 0x90, 0xa3, 0x0d, 0xe2, 0xdb, 0xbb, 0xd7, - 0xf8, 0xa8, 0xdd, 0xe2, 0x22, 0xba, 0xd6, 0xcd, 0xf1, 0x30, 0xd2, 0x77, 0x59, 0xbf, 0x38, 0x86, - 0x95, 0xbf, 0xd6, 0x67, 0xbb, 0xda, 0xf2, 0xfc, 0x4e, 0xaf, 0xf3, 0x6a, 0xaf, 0xad, 0x85, 0x67, - 0xc2, 0x7d, 0xda, 0xc1, 0xf0, 0x9e, 0x09, 0x5f, 0xca, 0x8f, 0x35, 0x73, 0x60, 0xcc, 0x81, 0x1f, - 0xa0, 0x39, 0x30, 0x66, 0x94, 0xb9, 0x7d, 0x52, 0xde, 0x1c, 0x5c, 0x74, 0xdb, 0x1e, 0x68, 0x11, - 0x0a, 0x2d, 0xfe, 0xec, 0xd5, 0x22, 0x9c, 0x1b, 0x92, 0x73, 0x9f, 0x73, 0x64, 0x39, 0x37, 0xb0, - 0xf9, 0xd0, 0xaf, 0x2e, 0xd7, 0xe2, 0xe8, 0x3f, 0x00, 0x00, 0xff, 0xff, 0x4a, 0xfa, 0x7c, 0x1a, - 0x1d, 0x03, 0x00, 0x00, + // 310 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xb2, 0x70, 0x2c, 0x2e, 0x4e, + 0x2d, 0xf1, 0x4d, 0xcc, 0x2b, 0xc9, 0x49, 0xd5, 0xcf, 0xcd, 0x4f, 0x29, 0xcd, 0x49, 0x2d, 0xd6, + 0xaf, 0xd0, 0xcf, 0x2f, 0x4a, 0x49, 0x2d, 0x2a, 0xd6, 0x2f, 0x2c, 0x4d, 0x2d, 0xca, 0x4c, 0x2d, + 0x86, 0x70, 0xf5, 0x8b, 0x53, 0x8b, 0xca, 0x32, 0x93, 0x53, 0xf5, 0x0a, 0x8a, 0xf2, 0x4b, 0xf2, + 0x85, 0xb4, 0x90, 0x74, 0xea, 0x41, 0x75, 0xea, 0x55, 0xe8, 0x41, 0x74, 0xea, 0x41, 0x75, 0x42, + 0xb8, 0x52, 0x76, 0x24, 0xd8, 0x02, 0xe2, 0x55, 0xc6, 0x17, 0xa5, 0x16, 0x96, 0xa6, 0x16, 0x97, + 0x40, 0xec, 0x92, 0xb2, 0x27, 0x43, 0x7f, 0x71, 0x41, 0x7e, 0x5e, 0x31, 0xd4, 0xb1, 0x46, 0x1d, + 0x8c, 0x5c, 0xac, 0x81, 0x20, 0x09, 0xa1, 0x7a, 0x2e, 0x36, 0x8f, 0xc4, 0xbc, 0x94, 0x9c, 0x54, + 0x21, 0x0b, 0x3d, 0xe2, 0x7d, 0xa0, 0x07, 0xd6, 0x1c, 0x04, 0x71, 0x94, 0x94, 0x25, 0x19, 0x3a, + 0x21, 0xce, 0x51, 0x62, 0x70, 0xba, 0xcb, 0x74, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, + 0x0f, 0x1e, 0xc9, 0x31, 0x4e, 0x78, 0x2c, 0xc7, 0x70, 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, + 0x0c, 0x5c, 0x7a, 0xc9, 0xf9, 0xb9, 0x24, 0x18, 0xed, 0xc4, 0x13, 0x0c, 0x89, 0x91, 0x00, 0x90, + 0x1f, 0x03, 0x18, 0xa3, 0x4c, 0xd3, 0x33, 0x4b, 0x32, 0x4a, 0x93, 0x40, 0xc6, 0xe8, 0x13, 0x1f, + 0x62, 0x8b, 0x98, 0xd8, 0x1c, 0x7d, 0x23, 0xfc, 0x03, 0xfd, 0x57, 0x31, 0xa1, 0xc4, 0xa9, 0x2f, + 0xd4, 0xf2, 0x08, 0x3d, 0x7f, 0x88, 0xe5, 0x81, 0x50, 0xcb, 0xc1, 0xdc, 0x53, 0x28, 0x8a, 0x63, + 0xa0, 0x8a, 0x63, 0x22, 0x62, 0x20, 0x8a, 0x63, 0xa0, 0x8a, 0x21, 0xdc, 0x47, 0x4c, 0x66, 0xc4, + 0x2b, 0x8e, 0x71, 0x0f, 0x70, 0xf2, 0x4d, 0x2d, 0x49, 0x4c, 0x49, 0x2c, 0x49, 0x7c, 0xc5, 0x84, + 0xec, 0x11, 0x2b, 0x2b, 0xa8, 0x4e, 0x2b, 0xab, 0x08, 0x2b, 0x2b, 0x88, 0x5e, 0x2b, 0x2b, 0xa8, + 0x66, 0xa8, 0x40, 0x12, 0x1b, 0x38, 0xc6, 0x8d, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0xd6, 0xc4, + 0x0f, 0x9d, 0xda, 0x02, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/orders/queries/order/service.pb.gw.go b/x/orders/queries/order/service.pb.gw.go deleted file mode 100644 index 10e34b17a..000000000 --- a/x/orders/queries/order/service.pb.gw.go +++ /dev/null @@ -1,171 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: AssetMantle/modules/x/orders/queries/order/service.proto - -/* -Package order is a reverse proxy. - -It translates gRPC into RESTful JSON APIs. -*/ -package order - -import ( - "context" - "io" - "net/http" - - "github.com/golang/protobuf/descriptor" - "github.com/golang/protobuf/proto" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/grpc-ecosystem/grpc-gateway/utilities" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/status" -) - -// Suppress "imported and not used" errors -var _ codes.Code -var _ io.Reader -var _ status.Status -var _ = runtime.String -var _ = utilities.NewDoubleArray -var _ = descriptor.ForMessage -var _ = metadata.Join - -var ( - filter_Query_Handle_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - -func request_Query_Handle_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryRequest - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.Handle(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_Handle_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryRequest - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.Handle(ctx, &protoReq) - return msg, metadata, err - -} - -// RegisterQueryHandlerServer registers the http handlers for service Query to "mux". -// UnaryRPC :call QueryServer directly. -// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. -func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { - - mux.Handle("GET", pattern_Query_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Query_Handle_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but -// automatically dials to "endpoint" and closes the connection when "ctx" gets done. -func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.Dial(endpoint, opts...) - if err != nil { - return err - } - defer func() { - if err != nil { - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - return - } - go func() { - <-ctx.Done() - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - }() - }() - - return RegisterQueryHandler(ctx, mux, conn) -} - -// RegisterQueryHandler registers the http handlers for service Query to "mux". -// The handlers forward requests to the grpc endpoint over "conn". -func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { - return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn)) -} - -// RegisterQueryHandlerClient registers the http handlers for service Query -// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient". -// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient" -// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "QueryClient" to call the correct interceptors. -func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { - - mux.Handle("GET", pattern_Query_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Query_Handle_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -var ( - pattern_Query_Handle_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"mantle", "orders", "v1beta1", "order"}, "", runtime.AssumeColonVerbOpt(false))) -) - -var ( - forward_Query_Handle_0 = runtime.ForwardResponseMessage -) diff --git a/x/orders/queries/orders/query.go b/x/orders/queries/orders/query.go index f0ab5c94f..834d1d554 100644 --- a/x/orders/queries/orders/query.go +++ b/x/orders/queries/orders/query.go @@ -4,26 +4,16 @@ package orders import ( - "context" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "google.golang.org/grpc" - "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" helperConstants "github.com/AssetMantle/modules/helpers/constants" - "github.com/AssetMantle/modules/utilities/name" - "github.com/AssetMantle/modules/x/orders/constants" + "google.golang.org/grpc" ) -type dummy struct{} - var Query = baseHelpers.NewQuery( - name.GetPackageName(dummy{}), + _Query_serviceDesc.ServiceName, "", "", - constants.ModuleName, requestPrototype, responsePrototype, @@ -32,9 +22,6 @@ var Query = baseHelpers.NewQuery( func(server grpc.ServiceRegistrar, QueryKeeper helpers.QueryKeeper) { RegisterQueryServer(server, QueryKeeper.(queryKeeper)) }, - func(clientContext client.Context, serveMux *runtime.ServeMux) error { - return RegisterQueryHandlerClient(context.Background(), serveMux, NewQueryClient(clientContext)) - }, helperConstants.OrderID, helperConstants.Limit, diff --git a/x/orders/queries/orders/query_keeper.go b/x/orders/queries/orders/query_keeper.go index 5dc2e54f6..cc3f3fc84 100644 --- a/x/orders/queries/orders/query_keeper.go +++ b/x/orders/queries/orders/query_keeper.go @@ -5,7 +5,6 @@ package orders import ( "context" - "github.com/AssetMantle/modules/helpers" ) @@ -16,7 +15,7 @@ type queryKeeper struct { var _ helpers.QueryKeeper = (*queryKeeper)(nil) func (queryKeeper queryKeeper) Enquire(context context.Context, queryRequest helpers.QueryRequest) (helpers.QueryResponse, error) { - queryResponse, err := queryKeeper.Handle(context, queryRequestFromInterface(queryRequest)) + queryResponse, err := queryKeeper.Handle(context, queryRequest.(*QueryRequest)) return queryResponse, err } func (queryKeeper queryKeeper) Handle(context context.Context, queryRequest *QueryRequest) (*QueryResponse, error) { diff --git a/x/orders/queries/orders/query_request.go b/x/orders/queries/orders/query_request.go index ead45b15e..676fb3dcc 100644 --- a/x/orders/queries/orders/query_request.go +++ b/x/orders/queries/orders/query_request.go @@ -13,7 +13,6 @@ import ( "github.com/cosmos/cosmos-sdk/types/query" "github.com/AssetMantle/modules/helpers" - "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/helpers/constants" "github.com/AssetMantle/modules/x/orders/key" ) @@ -68,27 +67,10 @@ func (*QueryRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.QueryRe return newQueryRequest(orderID.(ids.OrderID), int32(limit)), nil } -func (queryRequest *QueryRequest) Encode() ([]byte, error) { - return base.CodecPrototype().MarshalJSON(queryRequest) -} -func (queryRequest *QueryRequest) Decode(bytes []byte) (helpers.QueryRequest, error) { - if err := base.CodecPrototype().UnmarshalJSON(bytes, queryRequest); err != nil { - return nil, err - } - - return queryRequest, nil -} func requestPrototype() helpers.QueryRequest { return &QueryRequest{} } -func queryRequestFromInterface(request helpers.QueryRequest) *QueryRequest { - switch value := request.(type) { - case *QueryRequest: - return value - default: - return &QueryRequest{} - } -} + func newQueryRequest(orderID ids.OrderID, limit int32) helpers.QueryRequest { return &QueryRequest{Key: key.NewKey(orderID).(*key.Key), Limit: limit} } diff --git a/x/orders/queries/orders/service.pb.go b/x/orders/queries/orders/service.pb.go index 8ea65c4c2..8bbcfdd55 100644 --- a/x/orders/queries/orders/service.pb.go +++ b/x/orders/queries/orders/service.pb.go @@ -8,7 +8,6 @@ import ( fmt "fmt" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" - _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -31,30 +30,27 @@ func init() { } var fileDescriptor_53678e05903a1112 = []byte{ - // 359 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x92, 0x31, 0x4b, 0xfb, 0x40, - 0x18, 0xc6, 0x9b, 0xc0, 0xbf, 0x43, 0xf8, 0x4f, 0x19, 0x8b, 0x46, 0x10, 0x9c, 0x84, 0x3b, 0xab, - 0xa0, 0xf4, 0x16, 0x6d, 0x17, 0x5d, 0x42, 0x5b, 0x5d, 0x82, 0x04, 0xe4, 0xda, 0xbc, 0xd4, 0x40, - 0x92, 0x6b, 0x73, 0x97, 0x52, 0x57, 0x3f, 0x81, 0xe0, 0x37, 0x70, 0x70, 0x70, 0xf2, 0x63, 0x88, - 0x53, 0xc1, 0xc5, 0x51, 0x12, 0x27, 0x3f, 0x85, 0xa4, 0xf7, 0x16, 0xdb, 0x31, 0x1d, 0x9f, 0xdc, - 0xf3, 0x7b, 0xef, 0x79, 0x2e, 0xaf, 0xd5, 0x6a, 0x4b, 0x09, 0xca, 0xe5, 0x89, 0x8a, 0x80, 0xc6, - 0x22, 0xc8, 0x22, 0x90, 0x74, 0x46, 0x45, 0x1a, 0x40, 0x2a, 0xe9, 0x24, 0x83, 0x34, 0x04, 0xb9, - 0x94, 0x12, 0xd2, 0x69, 0x38, 0x04, 0x32, 0x4e, 0x85, 0x12, 0xf6, 0xfe, 0x0a, 0x4a, 0x10, 0x25, - 0x33, 0xa2, 0xbd, 0x04, 0x51, 0x94, 0x8d, 0xad, 0x91, 0x10, 0xa3, 0x08, 0x28, 0x1f, 0x87, 0x94, - 0x27, 0x89, 0x50, 0x5c, 0x85, 0x22, 0x91, 0x7a, 0x54, 0xe3, 0xb4, 0x4a, 0x8a, 0x52, 0xde, 0xdd, - 0xa4, 0x30, 0xc9, 0x40, 0x2a, 0x1c, 0x70, 0xb6, 0xc9, 0x00, 0x39, 0x16, 0x89, 0xc4, 0x36, 0x87, - 0xaf, 0x86, 0xf5, 0xaf, 0x5f, 0x1e, 0xd8, 0xcf, 0x86, 0x55, 0xbf, 0xe0, 0x49, 0x10, 0x81, 0xdd, - 0x22, 0x15, 0x3a, 0x92, 0x05, 0x7e, 0xa9, 0x73, 0x35, 0xd8, 0x26, 0xa8, 0x4e, 0xb4, 0xbb, 0x77, - 0xff, 0xf1, 0xfd, 0x68, 0xee, 0xd8, 0xdb, 0x34, 0xd6, 0x8d, 0x30, 0xf8, 0xb4, 0x39, 0x00, 0xc5, - 0x9b, 0x28, 0x3b, 0x85, 0xf9, 0x96, 0x3b, 0xc6, 0x3c, 0x77, 0x8c, 0xaf, 0xdc, 0x31, 0x1e, 0x0a, - 0xa7, 0x36, 0x2f, 0x9c, 0xda, 0x67, 0xe1, 0xd4, 0x2c, 0x3a, 0x14, 0x71, 0x95, 0x00, 0x9d, 0xff, - 0x57, 0xfa, 0xdf, 0xf6, 0xca, 0xc7, 0xe8, 0x19, 0xd7, 0xc7, 0xa3, 0x50, 0xdd, 0x66, 0x03, 0x32, - 0x14, 0x31, 0xad, 0xf0, 0xb6, 0x4f, 0x66, 0xbd, 0xed, 0x7a, 0xdd, 0x7e, 0xf7, 0xc5, 0x5c, 0x5b, - 0x0f, 0x17, 0xaf, 0xf7, 0x48, 0xf7, 0xaf, 0x70, 0x79, 0xbd, 0x96, 0xef, 0x6b, 0x6e, 0x1f, 0xdd, - 0xbe, 0xe7, 0xeb, 0x63, 0x1f, 0xdd, 0x28, 0x73, 0xf3, 0xa4, 0x82, 0xdb, 0x3f, 0xef, 0x75, 0x5c, - 0x50, 0x3c, 0xe0, 0x8a, 0xff, 0x98, 0x07, 0x2b, 0x24, 0x63, 0x88, 0x32, 0xe6, 0x31, 0xa6, 0xdd, - 0x8c, 0x21, 0xbd, 0xfc, 0x30, 0xa8, 0x2f, 0xf6, 0xe3, 0xe8, 0x37, 0x00, 0x00, 0xff, 0xff, 0x20, - 0x3d, 0x75, 0x59, 0x2a, 0x03, 0x00, 0x00, + // 312 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xb2, 0x74, 0x2c, 0x2e, 0x4e, + 0x2d, 0xf1, 0x4d, 0xcc, 0x2b, 0xc9, 0x49, 0xd5, 0xcf, 0xcd, 0x4f, 0x29, 0xcd, 0x49, 0x2d, 0xd6, + 0xaf, 0xd0, 0xcf, 0x2f, 0x4a, 0x49, 0x2d, 0x2a, 0xd6, 0x2f, 0x2c, 0x4d, 0x2d, 0xca, 0x4c, 0x2d, + 0x86, 0x71, 0x8b, 0x53, 0x8b, 0xca, 0x32, 0x93, 0x53, 0xf5, 0x0a, 0x8a, 0xf2, 0x4b, 0xf2, 0x85, + 0xb4, 0x91, 0xb4, 0xea, 0x41, 0xb5, 0xea, 0x55, 0xe8, 0x41, 0xd4, 0xea, 0x41, 0xb5, 0x42, 0xb9, + 0x52, 0xf6, 0xa4, 0xd8, 0x03, 0xe2, 0x56, 0xc6, 0x17, 0xa5, 0x16, 0x96, 0xa6, 0x16, 0x97, 0x40, + 0x6c, 0x93, 0x72, 0x20, 0xc7, 0x80, 0xe2, 0x82, 0xfc, 0xbc, 0x62, 0xa8, 0x7b, 0x8d, 0xba, 0x19, + 0xb9, 0x58, 0x03, 0x41, 0x12, 0x42, 0x8d, 0x8c, 0x5c, 0x6c, 0x1e, 0x89, 0x79, 0x29, 0x39, 0xa9, + 0x42, 0x96, 0x7a, 0x24, 0xf8, 0x42, 0x0f, 0xac, 0x3d, 0x08, 0xe2, 0x2e, 0x29, 0x2b, 0x72, 0xb4, + 0x42, 0x5c, 0xa4, 0xc4, 0xe0, 0xf4, 0x98, 0xe9, 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, 0x18, + 0x1f, 0x3c, 0x92, 0x63, 0x9c, 0xf0, 0x58, 0x8e, 0xe1, 0xc2, 0x63, 0x39, 0x86, 0x1b, 0x8f, 0xe5, + 0x18, 0xb8, 0xf4, 0x93, 0xf3, 0x73, 0x49, 0x31, 0xdb, 0x89, 0x27, 0x18, 0x12, 0x31, 0x01, 0x20, + 0x7f, 0x06, 0x30, 0x46, 0x99, 0xa5, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, + 0x93, 0x10, 0x6c, 0x8b, 0x98, 0xd8, 0x1c, 0x7d, 0x23, 0xfc, 0x03, 0xfd, 0x57, 0x31, 0xa1, 0xc4, + 0xad, 0x2f, 0xd4, 0xfa, 0x08, 0x3d, 0x7f, 0x84, 0x5f, 0x40, 0xd6, 0x43, 0xb8, 0xa7, 0x50, 0x54, + 0xc7, 0x40, 0x55, 0xc7, 0x44, 0xc4, 0x40, 0xa4, 0x63, 0xa0, 0xaa, 0xa1, 0xdc, 0x47, 0x4c, 0xe6, + 0x24, 0xa8, 0x8e, 0x71, 0x0f, 0x70, 0xf2, 0x4d, 0x2d, 0x49, 0x4c, 0x49, 0x2c, 0x49, 0x7c, 0xc5, + 0x64, 0x80, 0xa4, 0xd3, 0xca, 0x0a, 0xaa, 0xd5, 0xca, 0x2a, 0xc2, 0xca, 0x0a, 0xa2, 0xda, 0xca, + 0x0a, 0xaa, 0x1b, 0x26, 0x90, 0xc4, 0x06, 0x8e, 0x7a, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, + 0x16, 0x9c, 0xf0, 0x32, 0xe7, 0x02, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/orders/queries/orders/service.pb.gw.go b/x/orders/queries/orders/service.pb.gw.go deleted file mode 100644 index 415ca98d3..000000000 --- a/x/orders/queries/orders/service.pb.gw.go +++ /dev/null @@ -1,171 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: AssetMantle/modules/x/orders/queries/orders/service.proto - -/* -Package orders is a reverse proxy. - -It translates gRPC into RESTful JSON APIs. -*/ -package orders - -import ( - "context" - "io" - "net/http" - - "github.com/golang/protobuf/descriptor" - "github.com/golang/protobuf/proto" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/grpc-ecosystem/grpc-gateway/utilities" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/status" -) - -// Suppress "imported and not used" errors -var _ codes.Code -var _ io.Reader -var _ status.Status -var _ = runtime.String -var _ = utilities.NewDoubleArray -var _ = descriptor.ForMessage -var _ = metadata.Join - -var ( - filter_Query_Handle_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - -func request_Query_Handle_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryRequest - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.Handle(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_Handle_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryRequest - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.Handle(ctx, &protoReq) - return msg, metadata, err - -} - -// RegisterQueryHandlerServer registers the http handlers for service Query to "mux". -// UnaryRPC :call QueryServer directly. -// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. -func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { - - mux.Handle("GET", pattern_Query_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Query_Handle_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but -// automatically dials to "endpoint" and closes the connection when "ctx" gets done. -func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.Dial(endpoint, opts...) - if err != nil { - return err - } - defer func() { - if err != nil { - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - return - } - go func() { - <-ctx.Done() - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - }() - }() - - return RegisterQueryHandler(ctx, mux, conn) -} - -// RegisterQueryHandler registers the http handlers for service Query to "mux". -// The handlers forward requests to the grpc endpoint over "conn". -func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { - return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn)) -} - -// RegisterQueryHandlerClient registers the http handlers for service Query -// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient". -// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient" -// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "QueryClient" to call the correct interceptors. -func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { - - mux.Handle("GET", pattern_Query_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Query_Handle_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -var ( - pattern_Query_Handle_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 1}, []string{"mantle", "orders", "v1beta1"}, "", runtime.AssumeColonVerbOpt(false))) -) - -var ( - forward_Query_Handle_0 = runtime.ForwardResponseMessage -) diff --git a/x/orders/queries/parameters/query.go b/x/orders/queries/parameters/query.go new file mode 100644 index 000000000..cfe5be8fe --- /dev/null +++ b/x/orders/queries/parameters/query.go @@ -0,0 +1,21 @@ +package parameters + +import ( + "github.com/AssetMantle/modules/helpers" + baseHelpers "github.com/AssetMantle/modules/helpers/base" + "google.golang.org/grpc" +) + +var Query = baseHelpers.NewQuery( + _Query_serviceDesc.ServiceName, + "", + "", + + requestPrototype, + responsePrototype, + keeperPrototype, + + func(server grpc.ServiceRegistrar, QueryKeeper helpers.QueryKeeper) { + RegisterQueryServer(server, QueryKeeper.(queryKeeper)) + }, +) diff --git a/x/orders/queries/parameters/query_keeper.go b/x/orders/queries/parameters/query_keeper.go new file mode 100644 index 000000000..5ff196b53 --- /dev/null +++ b/x/orders/queries/parameters/query_keeper.go @@ -0,0 +1,31 @@ +package parameters + +import ( + "context" + "github.com/AssetMantle/modules/helpers" +) + +type queryKeeper struct { + parameterManager helpers.ParameterManager +} + +var _ helpers.QueryKeeper = (*queryKeeper)(nil) + +func (queryKeeper queryKeeper) Enquire(context context.Context, queryRequest helpers.QueryRequest) (helpers.QueryResponse, error) { + queryResponse, err := queryKeeper.Handle(context, queryRequest.(*QueryRequest)) + return queryResponse, err +} +func (queryKeeper queryKeeper) Handle(context context.Context, queryRequest *QueryRequest) (*QueryResponse, error) { + if err := queryRequest.Validate(); err != nil { + return nil, err + } + return newQueryResponse(queryKeeper.parameterManager.Fetch(context).Get()), nil +} +func (queryKeeper queryKeeper) Initialize(_ helpers.Mapper, parameterManager helpers.ParameterManager, _ []interface{}) helpers.Keeper { + queryKeeper.parameterManager = parameterManager + return queryKeeper +} + +func keeperPrototype() helpers.QueryKeeper { + return queryKeeper{} +} diff --git a/x/orders/queries/parameters/query_request.go b/x/orders/queries/parameters/query_request.go new file mode 100644 index 000000000..9f99e7a01 --- /dev/null +++ b/x/orders/queries/parameters/query_request.go @@ -0,0 +1,25 @@ +package parameters + +import ( + "github.com/AssetMantle/modules/helpers" + "github.com/cosmos/cosmos-sdk/client" + "net/http" +) + +var _ helpers.QueryRequest = (*QueryRequest)(nil) + +func (queryRequest *QueryRequest) Validate() error { + return nil +} + +func (queryRequest *QueryRequest) FromCLI(_ helpers.CLICommand, _ client.Context) (helpers.QueryRequest, error) { + return requestPrototype(), nil +} + +func (queryRequest *QueryRequest) FromHTTPRequest(_ *http.Request) (helpers.QueryRequest, error) { + return requestPrototype(), nil +} + +func requestPrototype() helpers.QueryRequest { + return &QueryRequest{} +} diff --git a/x/orders/queries/parameters/query_request.pb.go b/x/orders/queries/parameters/query_request.pb.go new file mode 100644 index 000000000..00cf0c1c7 --- /dev/null +++ b/x/orders/queries/parameters/query_request.pb.go @@ -0,0 +1,272 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: AssetMantle/modules/x/orders/queries/parameters/query_request.proto + +package parameters + +import ( + fmt "fmt" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type QueryRequest struct { +} + +func (m *QueryRequest) Reset() { *m = QueryRequest{} } +func (m *QueryRequest) String() string { return proto.CompactTextString(m) } +func (*QueryRequest) ProtoMessage() {} +func (*QueryRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_9c73f95e4468983c, []int{0} +} +func (m *QueryRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryRequest.Merge(m, src) +} +func (m *QueryRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryRequest proto.InternalMessageInfo + +func init() { + proto.RegisterType((*QueryRequest)(nil), "AssetMantle.modules.x.orders.queries.parameters.QueryRequest") +} + +func init() { + proto.RegisterFile("AssetMantle/modules/x/orders/queries/parameters/query_request.proto", fileDescriptor_9c73f95e4468983c) +} + +var fileDescriptor_9c73f95e4468983c = []byte{ + // 271 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0xd1, 0x31, 0x4e, 0xc3, 0x30, + 0x14, 0xc6, 0xf1, 0x26, 0x48, 0x1d, 0x22, 0x84, 0x04, 0x07, 0xf0, 0xc0, 0x01, 0x9e, 0x87, 0x32, + 0x3d, 0xa6, 0x86, 0x81, 0x29, 0xaa, 0xc3, 0x14, 0x21, 0x4b, 0xc8, 0x6d, 0x9e, 0xa0, 0x52, 0x83, + 0x5b, 0xdb, 0x91, 0xca, 0xc6, 0x11, 0x38, 0x03, 0x23, 0x27, 0x41, 0x4c, 0x1d, 0x19, 0x51, 0xb2, + 0x71, 0x0a, 0x54, 0x6c, 0x48, 0x3a, 0x66, 0xb5, 0xf4, 0xff, 0xe9, 0x7b, 0x72, 0x72, 0x35, 0xb5, + 0x96, 0x5c, 0xa6, 0x1e, 0xdd, 0x8a, 0x78, 0xa5, 0xcb, 0x7a, 0x45, 0x96, 0x6f, 0xb9, 0x36, 0x25, + 0x19, 0xcb, 0x37, 0x35, 0x99, 0x25, 0x59, 0xbe, 0x56, 0x46, 0x55, 0xe4, 0xfe, 0x9e, 0x9e, 0xee, + 0x0c, 0x6d, 0x6a, 0xb2, 0x0e, 0xd6, 0x46, 0x3b, 0x7d, 0xc6, 0x7b, 0x08, 0x04, 0x04, 0xb6, 0xe0, + 0x11, 0x08, 0x08, 0x74, 0xc8, 0xf9, 0x49, 0x72, 0x9c, 0xef, 0x9d, 0x1b, 0xcf, 0xa4, 0xcf, 0x47, + 0xef, 0x0d, 0x8b, 0x76, 0x0d, 0x8b, 0xbe, 0x1a, 0x16, 0xbd, 0xb4, 0x6c, 0xb4, 0x6b, 0xd9, 0xe8, + 0xb3, 0x65, 0xa3, 0x64, 0xb2, 0xd0, 0x15, 0x0c, 0xf4, 0xd3, 0xd3, 0xbe, 0x2e, 0xf6, 0x1b, 0x45, + 0x74, 0x8b, 0xf7, 0x4b, 0xf7, 0x50, 0xcf, 0x61, 0xa1, 0x2b, 0x3e, 0xf0, 0xea, 0xd7, 0x78, 0x3c, + 0xcd, 0x8a, 0x59, 0x2e, 0xde, 0xe2, 0x83, 0x5b, 0xb3, 0xb0, 0xa5, 0x80, 0x99, 0xdf, 0x92, 0x87, + 0x2d, 0xe2, 0x3f, 0xfd, 0x38, 0x28, 0x64, 0x28, 0x64, 0x21, 0x7d, 0x21, 0x43, 0x21, 0xbb, 0xa2, + 0x89, 0x2f, 0x07, 0x16, 0xf2, 0x5a, 0xa4, 0x19, 0x39, 0x55, 0x2a, 0xa7, 0xbe, 0xe3, 0x8b, 0x5e, + 0x8d, 0x18, 0x72, 0xc4, 0x02, 0xd1, 0x03, 0x88, 0x41, 0x40, 0xec, 0x88, 0xf9, 0xf8, 0xf7, 0x2b, + 0x27, 0x3f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xd2, 0xe5, 0xb1, 0x26, 0x11, 0x02, 0x00, 0x00, +} + +func (m *QueryRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func encodeVarintQueryRequest(dAtA []byte, offset int, v uint64) int { + offset -= sovQueryRequest(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *QueryRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func sovQueryRequest(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQueryRequest(x uint64) (n int) { + return sovQueryRequest(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QueryRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQueryRequest + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQueryRequest(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQueryRequest + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipQueryRequest(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQueryRequest + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQueryRequest + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQueryRequest + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthQueryRequest + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupQueryRequest + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthQueryRequest + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthQueryRequest = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowQueryRequest = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupQueryRequest = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/orders/queries/parameters/query_response.go b/x/orders/queries/parameters/query_response.go new file mode 100644 index 000000000..4d34b8543 --- /dev/null +++ b/x/orders/queries/parameters/query_response.go @@ -0,0 +1,29 @@ +package parameters + +import ( + "github.com/AssetMantle/modules/helpers" + "github.com/AssetMantle/modules/helpers/base" + "github.com/AssetMantle/schema/lists" + baseLists "github.com/AssetMantle/schema/lists/base" +) + +var _ helpers.QueryResponse = (*QueryResponse)(nil) + +func (queryResponse *QueryResponse) Encode() ([]byte, error) { + return base.CodecPrototype().MarshalJSON(queryResponse) +} +func (queryResponse *QueryResponse) Decode(bytes []byte) (helpers.QueryResponse, error) { + if err := base.CodecPrototype().UnmarshalJSON(bytes, queryResponse); err != nil { + return nil, err + } + + return queryResponse, nil +} +func responsePrototype() helpers.QueryResponse { + return &QueryResponse{} +} +func newQueryResponse(parameterList lists.ParameterList) *QueryResponse { + return &QueryResponse{ + ParameterList: parameterList.(*baseLists.ParameterList), + } +} diff --git a/x/orders/queries/parameters/query_response.pb.go b/x/orders/queries/parameters/query_response.pb.go new file mode 100644 index 000000000..67a2b63bc --- /dev/null +++ b/x/orders/queries/parameters/query_response.pb.go @@ -0,0 +1,337 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: AssetMantle/modules/x/orders/queries/parameters/query_response.proto + +package parameters + +import ( + fmt "fmt" + base "github.com/AssetMantle/schema/lists/base" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type QueryResponse struct { + ParameterList *base.ParameterList `protobuf:"bytes,1,opt,name=parameter_list,json=parameterList,proto3" json:"parameter_list,omitempty"` +} + +func (m *QueryResponse) Reset() { *m = QueryResponse{} } +func (m *QueryResponse) String() string { return proto.CompactTextString(m) } +func (*QueryResponse) ProtoMessage() {} +func (*QueryResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_c0d47f2da339925b, []int{0} +} +func (m *QueryResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryResponse.Merge(m, src) +} +func (m *QueryResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryResponse proto.InternalMessageInfo + +func (m *QueryResponse) GetParameterList() *base.ParameterList { + if m != nil { + return m.ParameterList + } + return nil +} + +func init() { + proto.RegisterType((*QueryResponse)(nil), "AssetMantle.modules.x.orders.queries.parameters.QueryResponse") +} + +func init() { + proto.RegisterFile("AssetMantle/modules/x/orders/queries/parameters/query_response.proto", fileDescriptor_c0d47f2da339925b) +} + +var fileDescriptor_c0d47f2da339925b = []byte{ + // 333 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x91, 0x31, 0x4b, 0xc3, 0x40, + 0x14, 0xc7, 0x9b, 0x08, 0x1d, 0x22, 0x75, 0xe8, 0x24, 0x0e, 0x41, 0x9c, 0x1c, 0xe4, 0x1d, 0xb4, + 0x4e, 0xe7, 0xd4, 0x22, 0xb8, 0x18, 0x9a, 0xd6, 0x25, 0x48, 0xa0, 0x5c, 0x9b, 0x87, 0x0d, 0x34, + 0xbd, 0x98, 0x77, 0x85, 0x3a, 0xfa, 0x0d, 0xfc, 0x0c, 0x8e, 0x7e, 0x12, 0x71, 0xea, 0xe8, 0x28, + 0xe9, 0xe6, 0xa7, 0x90, 0xf4, 0xae, 0x26, 0x19, 0x33, 0xe6, 0x91, 0xdf, 0xef, 0xff, 0x7f, 0xf7, + 0x9c, 0xdb, 0x01, 0x11, 0x2a, 0x4f, 0xac, 0xd4, 0x12, 0x59, 0x22, 0xa3, 0xf5, 0x12, 0x89, 0x6d, + 0x98, 0xcc, 0x22, 0xcc, 0x88, 0x3d, 0xaf, 0x31, 0x8b, 0x91, 0x58, 0x2a, 0x32, 0x91, 0xa0, 0x3a, + 0x8c, 0x5e, 0xa6, 0x19, 0x52, 0x2a, 0x57, 0x84, 0x90, 0x66, 0x52, 0xc9, 0x2e, 0xab, 0x58, 0xc0, + 0x58, 0x60, 0x03, 0xda, 0x02, 0xc6, 0x02, 0xa5, 0xe5, 0xac, 0x57, 0x8d, 0xa5, 0xf9, 0x02, 0x13, + 0xc1, 0x96, 0x31, 0x29, 0x62, 0x33, 0x41, 0x58, 0xe6, 0x4d, 0x8b, 0xa1, 0x0e, 0xb9, 0x88, 0x9c, + 0xce, 0xb8, 0x08, 0x9f, 0x98, 0xec, 0xee, 0x83, 0x73, 0x52, 0xff, 0xf1, 0xd4, 0x3a, 0xb7, 0x2e, + 0x8f, 0x7b, 0x57, 0x50, 0xad, 0xa3, 0xed, 0xb0, 0xb7, 0x43, 0x61, 0x07, 0xff, 0x00, 0xdd, 0xc7, + 0xa4, 0x26, 0x9d, 0xb4, 0xfa, 0x39, 0x7c, 0x3d, 0xfa, 0xcc, 0x5d, 0x6b, 0x9b, 0xbb, 0xd6, 0x4f, + 0xee, 0x5a, 0x6f, 0x3b, 0xb7, 0xb5, 0xdd, 0xb9, 0xad, 0xef, 0x9d, 0xdb, 0x72, 0xfa, 0x73, 0x99, + 0x40, 0xc3, 0x4d, 0x87, 0xdd, 0x5a, 0x67, 0xbf, 0xd8, 0xc4, 0xb7, 0x1e, 0xf9, 0x53, 0xac, 0x16, + 0xeb, 0x19, 0xcc, 0x65, 0xc2, 0x1a, 0x5e, 0xe0, 0xdd, 0x6e, 0x0f, 0xbc, 0x60, 0x34, 0xf6, 0x3f, + 0xec, 0xda, 0xb3, 0x7b, 0xa6, 0x4c, 0x00, 0x23, 0x5d, 0x66, 0x6c, 0xca, 0xfc, 0xaf, 0x4b, 0x5f, + 0x35, 0x22, 0x34, 0x44, 0x18, 0x84, 0x9a, 0x08, 0x0d, 0x11, 0x96, 0x44, 0x6e, 0xdf, 0x34, 0x24, + 0xc2, 0x3b, 0x7f, 0xe8, 0xa1, 0x12, 0x91, 0x50, 0xe2, 0xd7, 0xbe, 0xae, 0xd0, 0x9c, 0x1b, 0x9c, + 0xf3, 0x80, 0x73, 0x2d, 0xe0, 0xdc, 0x18, 0x38, 0x2f, 0x15, 0xb3, 0xf6, 0xfe, 0xe0, 0xfd, 0xbf, + 0x00, 0x00, 0x00, 0xff, 0xff, 0xd2, 0x0f, 0xe6, 0x48, 0x9d, 0x02, 0x00, 0x00, +} + +func (m *QueryResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.ParameterList != nil { + { + size, err := m.ParameterList.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQueryResponse(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintQueryResponse(dAtA []byte, offset int, v uint64) int { + offset -= sovQueryResponse(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *QueryResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ParameterList != nil { + l = m.ParameterList.Size() + n += 1 + l + sovQueryResponse(uint64(l)) + } + return n +} + +func sovQueryResponse(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQueryResponse(x uint64) (n int) { + return sovQueryResponse(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QueryResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQueryResponse + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ParameterList", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQueryResponse + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQueryResponse + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQueryResponse + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.ParameterList == nil { + m.ParameterList = &base.ParameterList{} + } + if err := m.ParameterList.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQueryResponse(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQueryResponse + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipQueryResponse(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQueryResponse + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQueryResponse + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQueryResponse + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthQueryResponse + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupQueryResponse + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthQueryResponse + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthQueryResponse = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowQueryResponse = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupQueryResponse = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/orders/queries/parameters/service.pb.go b/x/orders/queries/parameters/service.pb.go new file mode 100644 index 000000000..4ca70c8ff --- /dev/null +++ b/x/orders/queries/parameters/service.pb.go @@ -0,0 +1,135 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: AssetMantle/modules/x/orders/queries/parameters/service.proto + +package parameters + +import ( + context "context" + fmt "fmt" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + math "math" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +func init() { + proto.RegisterFile("AssetMantle/modules/x/orders/queries/parameters/service.proto", fileDescriptor_b0ac58a27116a57a) +} + +var fileDescriptor_b0ac58a27116a57a = []byte{ + // 324 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0xd2, 0xb1, 0x4a, 0xc3, 0x40, + 0x18, 0x07, 0xf0, 0x5c, 0xc0, 0x0e, 0xc1, 0xa9, 0x63, 0x87, 0x1b, 0x7c, 0x80, 0x3b, 0xb0, 0x4e, + 0x27, 0x15, 0x5a, 0x05, 0x5d, 0x42, 0x53, 0x5d, 0x82, 0x1c, 0xc8, 0xb5, 0xf9, 0xd0, 0x42, 0x93, + 0x4b, 0xef, 0x2e, 0x52, 0x1f, 0xc1, 0x4d, 0xf0, 0x0d, 0x1c, 0x7d, 0x12, 0x71, 0xea, 0xe8, 0x28, + 0xc9, 0xe6, 0x2b, 0xb8, 0x48, 0x7a, 0x87, 0x69, 0xc7, 0x74, 0xbd, 0xf0, 0xfb, 0xdf, 0xff, 0xcb, + 0x77, 0xc1, 0x60, 0xa8, 0x35, 0x98, 0x50, 0x64, 0x66, 0x01, 0x34, 0x95, 0x49, 0xb1, 0x00, 0x4d, + 0x57, 0x54, 0xaa, 0x04, 0x94, 0xa6, 0xcb, 0x02, 0xd4, 0x1c, 0x34, 0xcd, 0x85, 0x12, 0x29, 0x98, + 0xfa, 0x48, 0x83, 0x7a, 0x9c, 0xcf, 0x80, 0xe4, 0x4a, 0x1a, 0xd9, 0xa5, 0x5b, 0x9c, 0x38, 0x4e, + 0x56, 0xc4, 0x72, 0xe2, 0x38, 0x69, 0x78, 0xef, 0xbc, 0xed, 0x7d, 0xf5, 0xd1, 0xd3, 0x9d, 0x82, + 0x65, 0x01, 0xda, 0xd8, 0x5b, 0x7b, 0x17, 0xfb, 0x86, 0xe8, 0x5c, 0x66, 0xda, 0x75, 0x3f, 0x7e, + 0x45, 0xc1, 0xc1, 0xa4, 0xfe, 0xd0, 0x7d, 0x46, 0x41, 0xe7, 0x4a, 0x64, 0xc9, 0x02, 0xba, 0x03, + 0xd2, 0x72, 0x22, 0xb2, 0x89, 0xb8, 0xb6, 0xfd, 0x7a, 0x67, 0xfb, 0x72, 0xdb, 0xec, 0xc8, 0x1b, + 0xfd, 0xfa, 0x1f, 0x25, 0x46, 0xeb, 0x12, 0xa3, 0xef, 0x12, 0xa3, 0x97, 0x0a, 0x7b, 0xeb, 0x0a, + 0x7b, 0x5f, 0x15, 0xf6, 0x82, 0xfe, 0x4c, 0xa6, 0x6d, 0xf3, 0x47, 0x87, 0x37, 0x76, 0x61, 0x51, + 0x3d, 0x73, 0x84, 0x6e, 0xd9, 0xfd, 0xdc, 0x3c, 0x14, 0x53, 0x32, 0x93, 0x29, 0x6d, 0xf9, 0x1b, + 0xdf, 0xfc, 0xce, 0x30, 0x8c, 0xc7, 0x93, 0xe8, 0xdd, 0xdf, 0xd9, 0x7b, 0xe8, 0x6a, 0xc4, 0x64, + 0x6c, 0x6b, 0x4c, 0x5c, 0x8d, 0xe8, 0x9f, 0x7e, 0xee, 0x08, 0xee, 0x04, 0x8f, 0xb9, 0x15, 0xdc, + 0x09, 0xde, 0x88, 0xd2, 0x3f, 0x6d, 0x29, 0xf8, 0x65, 0x34, 0x0a, 0xc1, 0x88, 0x44, 0x18, 0xf1, + 0xe3, 0x9f, 0x6c, 0x69, 0xc6, 0x1c, 0x67, 0x2c, 0x66, 0xcc, 0x06, 0x30, 0xe6, 0x12, 0x18, 0x6b, + 0x22, 0xa6, 0x9d, 0xcd, 0xd3, 0xe8, 0xff, 0x05, 0x00, 0x00, 0xff, 0xff, 0xfd, 0x72, 0x76, 0x8f, + 0x17, 0x03, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// QueryClient is the client API for Query service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type QueryClient interface { + Handle(ctx context.Context, in *QueryRequest, opts ...grpc.CallOption) (*QueryResponse, error) +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +func (c *queryClient) Handle(ctx context.Context, in *QueryRequest, opts ...grpc.CallOption) (*QueryResponse, error) { + out := new(QueryResponse) + err := c.cc.Invoke(ctx, "/AssetMantle.modules.x.orders.queries.parameters.Query/Handle", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +type QueryServer interface { + Handle(context.Context, *QueryRequest) (*QueryResponse, error) +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func (*UnimplementedQueryServer) Handle(ctx context.Context, req *QueryRequest) (*QueryResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Handle not implemented") +} + +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) +} + +func _Query_Handle_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Handle(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/AssetMantle.modules.x.orders.queries.parameters.Query/Handle", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Handle(ctx, req.(*QueryRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "AssetMantle.modules.x.orders.queries.parameters.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Handle", + Handler: _Query_Handle_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "AssetMantle/modules/x/orders/queries/parameters/service.proto", +} diff --git a/x/orders/queries/prototype.go b/x/orders/queries/prototype.go index 2c47a4b4b..f9485c223 100644 --- a/x/orders/queries/prototype.go +++ b/x/orders/queries/prototype.go @@ -8,11 +8,13 @@ import ( baseHelpers "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/x/orders/queries/order" "github.com/AssetMantle/modules/x/orders/queries/orders" + "github.com/AssetMantle/modules/x/orders/queries/parameters" ) func Prototype() helpers.Queries { return baseHelpers.NewQueries( order.Query, orders.Query, + parameters.Query, ) } diff --git a/x/orders/queries/prototype_test.go b/x/orders/queries/prototype_test.go index 62ec1a898..d912ba57d 100644 --- a/x/orders/queries/prototype_test.go +++ b/x/orders/queries/prototype_test.go @@ -13,7 +13,7 @@ import ( ) func TestPrototype(t *testing.T) { - require.Equal(t, Prototype().GetQuery("orders").GetName(), baseHelpers.NewQueries( + require.Equal(t, Prototype().GetQuery("orders").GetServicePath(), baseHelpers.NewQueries( order.Query, - ).GetQuery("orders").GetName()) + ).GetQuery("orders").GetServicePath()) } diff --git a/x/orders/record/record.go b/x/orders/record/record.go index 5eb40701d..43ddd610f 100644 --- a/x/orders/record/record.go +++ b/x/orders/record/record.go @@ -1,14 +1,13 @@ package record import ( - "github.com/AssetMantle/schema/documents" - baseIDs "github.com/AssetMantle/schema/ids/base" - sdkTypes "github.com/cosmos/cosmos-sdk/types" - "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/x/orders/key" "github.com/AssetMantle/modules/x/orders/mappable" + "github.com/AssetMantle/schema/documents" + baseIDs "github.com/AssetMantle/schema/ids/base" + sdkTypes "github.com/cosmos/cosmos-sdk/types" ) func (record *Record) GetKey() helpers.Key { diff --git a/x/orders/simulator/genesis.go b/x/orders/simulator/genesis.go index d711dc983..c96157dc4 100644 --- a/x/orders/simulator/genesis.go +++ b/x/orders/simulator/genesis.go @@ -4,8 +4,6 @@ package simulator import ( - "math/rand" - "github.com/AssetMantle/schema/data" baseData "github.com/AssetMantle/schema/data/base" "github.com/AssetMantle/schema/documents/base" @@ -15,6 +13,7 @@ import ( baseQualified "github.com/AssetMantle/schema/qualified/base" sdkTypes "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" + "math/rand" "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" diff --git a/x/orders/simulator/operations.go b/x/orders/simulator/operations.go index 5a49f201a..d15703428 100644 --- a/x/orders/simulator/operations.go +++ b/x/orders/simulator/operations.go @@ -4,8 +4,6 @@ package simulator import ( - "math/rand" - baseDocuments "github.com/AssetMantle/schema/documents/base" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" @@ -18,6 +16,7 @@ import ( "github.com/cosmos/cosmos-sdk/types/module" simulationTypes "github.com/cosmos/cosmos-sdk/types/simulation" "github.com/cosmos/cosmos-sdk/x/simulation" + "math/rand" "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/helpers/base" diff --git a/x/orders/simulator/params.go b/x/orders/simulator/params.go index 69b28204c..1d4caaab8 100644 --- a/x/orders/simulator/params.go +++ b/x/orders/simulator/params.go @@ -4,11 +4,10 @@ package simulator import ( - "math" - "math/rand" - simulationTypes "github.com/cosmos/cosmos-sdk/types/simulation" "github.com/cosmos/cosmos-sdk/x/simulation" + "math" + "math/rand" baseHelpers "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/x/orders/constants" diff --git a/x/orders/simulator/proposals.go b/x/orders/simulator/proposals.go index 776c4f2bc..53aac918f 100644 --- a/x/orders/simulator/proposals.go +++ b/x/orders/simulator/proposals.go @@ -4,28 +4,28 @@ package simulator import ( - "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" - "math/rand" - sdkTypes "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" simulationTypes "github.com/cosmos/cosmos-sdk/types/simulation" + govSimulation "github.com/cosmos/cosmos-sdk/x/gov/simulation" + "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" "github.com/cosmos/cosmos-sdk/x/simulation" + "math/rand" ) -func (simulator) WeightedProposalContentList(module.SimulationState) []simulationTypes.WeightedProposalContent { - return []simulationTypes.WeightedProposalContent{ - simulation.NewWeightedProposalContent( +func (simulator) ProposalMessages(_ module.SimulationState) []simulationTypes.WeightedProposalMsg { + return []simulationTypes.WeightedProposalMsg{ + simulation.NewWeightedProposalMsg( OpWeightSubmitTextProposal, DefaultWeightTextProposal, - simulateTextProposalContent, + func(r *rand.Rand, _ sdkTypes.Context, simulationAccounts []simulationTypes.Account) sdkTypes.Msg { + msgSubmitProposal, err := v1beta1.NewMsgSubmitProposal(v1beta1.NewTextProposal(simulationTypes.RandStringOfLength(r, 140), simulationTypes.RandStringOfLength(r, 5000)), govSimulation.GenDepositParamsMinDeposit(r), simulationAccounts[r.Intn(len(simulationAccounts))].Address) + if err != nil { + panic(err) + } + + return msgSubmitProposal + }, ), } } - -func simulateTextProposalContent(r *rand.Rand, _ sdkTypes.Context, _ []simulationTypes.Account) simulationTypes.Content { - return v1beta1.NewTextProposal( - simulationTypes.RandStringOfLength(r, 140), - simulationTypes.RandStringOfLength(r, 5000), - ) -} diff --git a/x/orders/transactions/cancel/message.go b/x/orders/transactions/cancel/message.go index 31662050d..32fd19b0b 100644 --- a/x/orders/transactions/cancel/message.go +++ b/x/orders/transactions/cancel/message.go @@ -4,26 +4,15 @@ package cancel import ( - codecUtilities "github.com/AssetMantle/schema/codec/utilities" + "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/types" sdkTypes "github.com/cosmos/cosmos-sdk/types" - - "github.com/AssetMantle/modules/helpers" ) var _ helpers.Message = (*Message)(nil) -func (message *Message) Type() string { return Transaction.GetName() } -func (message *Message) GetFromAddress() sdkTypes.AccAddress { - from, err := sdkTypes.AccAddressFromBech32(message.From) - if err != nil { - panic(err) - } - return from -} func (message *Message) ValidateBasic() error { if _, err := sdkTypes.AccAddressFromBech32(message.From); err != nil { return err @@ -43,21 +32,10 @@ func (message *Message) GetSigners() []sdkTypes.AccAddress { } return []sdkTypes.AccAddress{from} } -func (*Message) RegisterLegacyAminoCodec(legacyAmino *codec.LegacyAmino) { - codecUtilities.RegisterModuleConcrete(legacyAmino, Message{}) -} func (message *Message) RegisterInterface(interfaceRegistry types.InterfaceRegistry) { interfaceRegistry.RegisterImplementations((*sdkTypes.Msg)(nil), message) } -func messageFromInterface(msg sdkTypes.Msg) *Message { - switch value := msg.(type) { - case *Message: - return value - default: - return &Message{} - } -} func messagePrototype() helpers.Message { return &Message{} } diff --git a/x/orders/transactions/cancel/message_test.go b/x/orders/transactions/cancel/message_test.go index adbdae509..744c5d4be 100644 --- a/x/orders/transactions/cancel/message_test.go +++ b/x/orders/transactions/cancel/message_test.go @@ -13,7 +13,6 @@ import ( "github.com/AssetMantle/schema/lists/base" baseProperties "github.com/AssetMantle/schema/properties/base" baseQualified "github.com/AssetMantle/schema/qualified/base" - "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" @@ -45,27 +44,6 @@ func CreateTestInputForMessages(t *testing.T) (*baseIDs.OrderID, *baseIDs.Identi return testOrderID.(*baseIDs.OrderID), testFromID.(*baseIDs.IdentityID), fromAccAddress, testMessage } -func Test_messageFromInterface(t *testing.T) { - testOrderID, testFromID, fromAccAddress, testMessage := CreateTestInputForMessages(t) - type args struct { - msg sdkTypes.Msg - } - tests := []struct { - name string - args args - want *Message - }{ - {"+ve", args{testMessage}, &Message{fromAccAddress.String(), testFromID, testOrderID}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := messageFromInterface(tt.args.msg); !reflect.DeepEqual(got, tt.want) { - t.Errorf("messageFromInterface() = %v, want %v", got, tt.want) - } - }) - } -} - func Test_messagePrototype(t *testing.T) { tests := []struct { name string @@ -106,55 +84,6 @@ func Test_message_GetSigners(t *testing.T) { } } -func Test_message_RegisterCodec(t *testing.T) { - testOrderID, testFromID, fromAccAddress, _ := CreateTestInputForMessages(t) - - type args struct { - legacyAmino *codec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{fromAccAddress.String(), testFromID, testOrderID}, args{codec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - me := &Message{ - From: tt.fields.From, - FromID: tt.fields.FromID, - OrderID: tt.fields.OrderID, - } - me.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - -func Test_message_Type(t *testing.T) { - testOrderID, testFromID, fromAccAddress, _ := CreateTestInputForMessages(t) - - tests := []struct { - name string - fields fields - want string - }{ - {"+ve", fields{fromAccAddress.String(), testFromID, testOrderID}, Transaction.GetName()}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - message := &Message{ - From: tt.fields.From, - FromID: tt.fields.FromID, - OrderID: tt.fields.OrderID, - } - if got := message.Type(); got != tt.want { - t.Errorf("Type() = %v, want %v", got, tt.want) - } - }) - } -} - func Test_message_ValidateBasic(t *testing.T) { testOrderID, testFromID, fromAccAddress, _ := CreateTestInputForMessages(t) diff --git a/x/orders/transactions/cancel/service.pb.go b/x/orders/transactions/cancel/service.pb.go index 84cb90d84..71b15e9c0 100644 --- a/x/orders/transactions/cancel/service.pb.go +++ b/x/orders/transactions/cancel/service.pb.go @@ -6,9 +6,9 @@ package cancel import ( context "context" fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types/msgservice" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" - _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -31,30 +31,29 @@ func init() { } var fileDescriptor_309677b1d8455ef4 = []byte{ - // 361 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0xd2, 0x3f, 0x4b, 0xc3, 0x40, - 0x18, 0x06, 0xf0, 0x26, 0x85, 0x0e, 0xc1, 0xa9, 0x20, 0x42, 0xd0, 0x0c, 0xfd, 0x00, 0x77, 0xe2, - 0x9f, 0xc1, 0x53, 0x84, 0xb6, 0x88, 0x82, 0x84, 0x16, 0xed, 0x10, 0x24, 0x20, 0xd7, 0xe4, 0x88, - 0x81, 0xe4, 0xae, 0xe4, 0xae, 0xd2, 0x55, 0x3f, 0x81, 0xe0, 0x37, 0x70, 0xd3, 0xcd, 0x6f, 0x21, - 0x4e, 0x05, 0x17, 0x47, 0x49, 0x9d, 0xfc, 0x14, 0x62, 0xdf, 0x03, 0xaf, 0xe3, 0xad, 0x17, 0x7e, - 0x0f, 0xcf, 0xfb, 0xe6, 0xf5, 0x8e, 0xbb, 0x52, 0x32, 0x15, 0x52, 0xae, 0x0a, 0x86, 0x4b, 0x91, - 0x4e, 0x0b, 0x26, 0xf1, 0x0c, 0x8b, 0x2a, 0x65, 0x95, 0xc4, 0xaa, 0xa2, 0x5c, 0xd2, 0x44, 0xe5, - 0x82, 0x4b, 0x9c, 0x50, 0x9e, 0xb0, 0x02, 0x4b, 0x56, 0xdd, 0xe6, 0x09, 0x43, 0x93, 0x4a, 0x28, - 0xd1, 0xde, 0x36, 0x3c, 0xd2, 0x1e, 0xcd, 0x10, 0x78, 0x64, 0x7a, 0x04, 0xde, 0xdf, 0xcc, 0x84, - 0xc8, 0x0a, 0x86, 0xe9, 0x24, 0xc7, 0x94, 0x73, 0xa1, 0x28, 0x7c, 0x5e, 0xe6, 0xf9, 0xf6, 0x7d, - 0x4a, 0x26, 0x25, 0xcd, 0x74, 0x1f, 0xff, 0xdc, 0xda, 0x1b, 0x6f, 0xd7, 0x15, 0x93, 0x13, 0xc1, - 0xa5, 0x0e, 0xdb, 0x79, 0x75, 0xbc, 0x66, 0x28, 0xb3, 0xf6, 0xb3, 0xe3, 0xb5, 0xce, 0x28, 0x4f, - 0x0b, 0xd6, 0x3e, 0x40, 0xb6, 0x03, 0xa3, 0x10, 0x0a, 0xfa, 0x27, 0xf6, 0x74, 0xf4, 0xff, 0x76, - 0xa1, 0xab, 0x75, 0xb6, 0xee, 0x3f, 0xbe, 0x1f, 0xdd, 0x8d, 0xce, 0x3a, 0x2e, 0x61, 0x4a, 0x3d, - 0x1b, 0x90, 0xde, 0x5d, 0xf3, 0xad, 0x0e, 0x9c, 0x79, 0x1d, 0x38, 0x5f, 0x75, 0xe0, 0x3c, 0x2c, - 0x82, 0xc6, 0x7c, 0x11, 0x34, 0x3e, 0x17, 0x41, 0xc3, 0xdb, 0x4b, 0x44, 0x69, 0xdd, 0xa1, 0xb7, - 0x76, 0x09, 0x3f, 0x7c, 0xf8, 0xb7, 0x92, 0xa1, 0x73, 0x75, 0x98, 0xe5, 0xea, 0x66, 0x3a, 0x46, - 0x89, 0x28, 0xb1, 0xed, 0xb2, 0x9f, 0xdc, 0x56, 0x37, 0x8c, 0x06, 0xa3, 0xfe, 0x8b, 0xbb, 0x72, - 0x38, 0xa1, 0x2e, 0x12, 0xa1, 0x01, 0x14, 0x19, 0x99, 0x45, 0xfa, 0x4b, 0xfb, 0xbe, 0x42, 0x62, - 0x4d, 0xe2, 0x28, 0x06, 0x12, 0x9b, 0x24, 0x06, 0x52, 0xbb, 0x47, 0xb6, 0x24, 0x3e, 0x1d, 0xf6, - 0x42, 0xa6, 0x68, 0x4a, 0x15, 0xfd, 0x71, 0xf7, 0x0d, 0x4e, 0x88, 0xf6, 0x84, 0x44, 0x84, 0x40, - 0x02, 0x21, 0x66, 0x04, 0x21, 0x90, 0x31, 0x6e, 0x2d, 0xcf, 0x67, 0xf7, 0x37, 0x00, 0x00, 0xff, - 0xff, 0x85, 0x70, 0x97, 0x0c, 0x5d, 0x03, 0x00, 0x00, + // 350 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0xd2, 0xbf, 0x4b, 0xc3, 0x40, + 0x14, 0x07, 0xf0, 0x24, 0xc5, 0x0e, 0xc1, 0xa9, 0x8b, 0x90, 0x21, 0x83, 0xa3, 0xc3, 0x9d, 0x3f, + 0x07, 0x4f, 0x11, 0xda, 0x22, 0x0a, 0x12, 0x5a, 0xb4, 0x43, 0x90, 0x80, 0x5c, 0x2f, 0x47, 0x2c, + 0x24, 0xb9, 0x92, 0x77, 0x2d, 0x1d, 0x75, 0x77, 0x70, 0x77, 0x73, 0x74, 0xf2, 0xcf, 0x10, 0xa7, + 0x8e, 0x8e, 0x92, 0x0e, 0x82, 0x7f, 0x85, 0xb4, 0x77, 0xe0, 0x75, 0xbc, 0x29, 0xf0, 0xe0, 0xf3, + 0xcd, 0xf7, 0x25, 0xcf, 0x3f, 0x6b, 0x03, 0x70, 0x19, 0xd1, 0x52, 0xe6, 0x1c, 0x17, 0x22, 0x9d, + 0xe4, 0x1c, 0xf0, 0x0c, 0x8b, 0x2a, 0xe5, 0x15, 0x60, 0x59, 0xd1, 0x12, 0x28, 0x93, 0x23, 0x51, + 0x02, 0x66, 0xb4, 0x64, 0x3c, 0xc7, 0xc0, 0xab, 0xe9, 0x88, 0x71, 0x34, 0xae, 0x84, 0x14, 0xad, + 0x5d, 0xc3, 0x23, 0xed, 0xd1, 0x0c, 0x29, 0x8f, 0x4c, 0x8f, 0x94, 0x0f, 0xb6, 0x98, 0x80, 0x42, + 0x00, 0x2e, 0x20, 0xc3, 0xd3, 0xbd, 0xe5, 0x43, 0x45, 0x05, 0xf6, 0x55, 0x0a, 0x0e, 0x40, 0x33, + 0x5d, 0x25, 0xb8, 0xb2, 0xf6, 0xc6, 0xec, 0xae, 0xe2, 0x30, 0x16, 0x25, 0xe8, 0xb0, 0xfd, 0x17, + 0xd7, 0x6f, 0x44, 0x90, 0xb5, 0x9e, 0x5c, 0xbf, 0x79, 0x49, 0xcb, 0x34, 0xe7, 0xad, 0x63, 0x64, + 0xbb, 0x2b, 0x8a, 0x54, 0xc1, 0xe0, 0xdc, 0x9e, 0x0e, 0xfe, 0x67, 0xd7, 0xba, 0xda, 0xb6, 0x13, + 0x6c, 0x3c, 0xfc, 0xbc, 0xef, 0xb8, 0x9d, 0xc7, 0xc6, 0x47, 0x1d, 0xba, 0xf3, 0x3a, 0x74, 0xbf, + 0xeb, 0xd0, 0x7d, 0x5e, 0x84, 0xce, 0x7c, 0x11, 0x3a, 0x5f, 0x8b, 0xd0, 0xf1, 0x0f, 0x99, 0x28, + 0xac, 0xdf, 0xd6, 0xd9, 0xbc, 0x51, 0x7f, 0xb5, 0xbf, 0x5c, 0xbe, 0xef, 0xde, 0x9e, 0x64, 0x23, + 0x79, 0x3f, 0x19, 0x22, 0x26, 0x0a, 0x6c, 0xfb, 0x59, 0x5f, 0xbd, 0x66, 0x3b, 0x8a, 0x7b, 0x83, + 0xee, 0x9b, 0xb7, 0x76, 0x1d, 0x91, 0x2e, 0x12, 0xa3, 0x9e, 0x2a, 0x32, 0x30, 0x8b, 0x74, 0x57, + 0xf6, 0x73, 0x8d, 0x24, 0x9a, 0x24, 0x71, 0xa2, 0x48, 0x62, 0x92, 0x44, 0x91, 0xda, 0x3b, 0xb5, + 0x25, 0xc9, 0x45, 0xbf, 0x13, 0x71, 0x49, 0x53, 0x2a, 0xe9, 0xaf, 0x77, 0x64, 0x70, 0x42, 0xb4, + 0x27, 0x24, 0x26, 0x44, 0x25, 0x10, 0x62, 0x46, 0x10, 0xa2, 0x32, 0x86, 0xcd, 0xd5, 0xa1, 0x1c, + 0xfc, 0x05, 0x00, 0x00, 0xff, 0xff, 0x5a, 0xb5, 0x1b, 0xf8, 0x42, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/orders/transactions/cancel/service.pb.gw.go b/x/orders/transactions/cancel/service.pb.gw.go deleted file mode 100644 index 961de57cd..000000000 --- a/x/orders/transactions/cancel/service.pb.gw.go +++ /dev/null @@ -1,171 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: AssetMantle/modules/x/orders/transactions/cancel/service.proto - -/* -Package cancel is a reverse proxy. - -It translates gRPC into RESTful JSON APIs. -*/ -package cancel - -import ( - "context" - "io" - "net/http" - - "github.com/golang/protobuf/descriptor" - "github.com/golang/protobuf/proto" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/grpc-ecosystem/grpc-gateway/utilities" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/status" -) - -// Suppress "imported and not used" errors -var _ codes.Code -var _ io.Reader -var _ status.Status -var _ = runtime.String -var _ = utilities.NewDoubleArray -var _ = descriptor.ForMessage -var _ = metadata.Join - -var ( - filter_Msg_Handle_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - -func request_Msg_Handle_0(ctx context.Context, marshaler runtime.Marshaler, client MsgClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq Message - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.Handle(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Msg_Handle_0(ctx context.Context, marshaler runtime.Marshaler, server MsgServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq Message - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.Handle(ctx, &protoReq) - return msg, metadata, err - -} - -// RegisterMsgHandlerServer registers the http handlers for service Msg to "mux". -// UnaryRPC :call MsgServer directly. -// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterMsgHandlerFromEndpoint instead. -func RegisterMsgHandlerServer(ctx context.Context, mux *runtime.ServeMux, server MsgServer) error { - - mux.Handle("POST", pattern_Msg_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Msg_Handle_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Msg_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -// RegisterMsgHandlerFromEndpoint is same as RegisterMsgHandler but -// automatically dials to "endpoint" and closes the connection when "ctx" gets done. -func RegisterMsgHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.Dial(endpoint, opts...) - if err != nil { - return err - } - defer func() { - if err != nil { - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - return - } - go func() { - <-ctx.Done() - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - }() - }() - - return RegisterMsgHandler(ctx, mux, conn) -} - -// RegisterMsgHandler registers the http handlers for service Msg to "mux". -// The handlers forward requests to the grpc endpoint over "conn". -func RegisterMsgHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { - return RegisterMsgHandlerClient(ctx, mux, NewMsgClient(conn)) -} - -// RegisterMsgHandlerClient registers the http handlers for service Msg -// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "MsgClient". -// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "MsgClient" -// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "MsgClient" to call the correct interceptors. -func RegisterMsgHandlerClient(ctx context.Context, mux *runtime.ServeMux, client MsgClient) error { - - mux.Handle("POST", pattern_Msg_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Msg_Handle_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Msg_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -var ( - pattern_Msg_Handle_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"mantle", "orders", "cancel"}, "", runtime.AssumeColonVerbOpt(false))) -) - -var ( - forward_Msg_Handle_0 = runtime.ForwardResponseMessage -) diff --git a/x/orders/transactions/cancel/transaction.go b/x/orders/transactions/cancel/transaction.go index 6ed7ae156..a9a93666a 100644 --- a/x/orders/transactions/cancel/transaction.go +++ b/x/orders/transactions/cancel/transaction.go @@ -4,22 +4,14 @@ package cancel import ( - "context" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "google.golang.org/grpc" - "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/helpers/constants" - "github.com/AssetMantle/modules/utilities/name" + "google.golang.org/grpc" ) -type dummy struct{} - var Transaction = baseHelpers.NewTransaction( - name.GetPackageName(dummy{}), + _Msg_serviceDesc.ServiceName, "", "", @@ -30,9 +22,7 @@ var Transaction = baseHelpers.NewTransaction( func(server grpc.ServiceRegistrar, keeper helpers.TransactionKeeper) { RegisterMsgServer(server, keeper.(transactionKeeper)) }, - func(clientCtx client.Context, mux *runtime.ServeMux) error { - return RegisterMsgHandlerClient(context.Background(), mux, NewMsgClient(clientCtx)) - }, + constants.OrderID, constants.FromIdentityID, ) diff --git a/x/orders/transactions/cancel/transaction_keeper.go b/x/orders/transactions/cancel/transaction_keeper.go index 8ff2e6102..fece1f3a5 100644 --- a/x/orders/transactions/cancel/transaction_keeper.go +++ b/x/orders/transactions/cancel/transaction_keeper.go @@ -5,9 +5,8 @@ package cancel import ( "context" - errorConstants "github.com/AssetMantle/modules/helpers/constants" - "github.com/AssetMantle/modules/helpers" + errorConstants "github.com/AssetMantle/modules/helpers/constants" "github.com/AssetMantle/modules/x/classifications/auxiliaries/unbond" "github.com/AssetMantle/modules/x/identities/auxiliaries/authenticate" "github.com/AssetMantle/modules/x/maintainers/auxiliaries/authorize" @@ -36,7 +35,7 @@ func (transactionKeeper transactionKeeper) Transact(context context.Context, mes } func (transactionKeeper transactionKeeper) Handle(context context.Context, message *Message) (*TransactionResponse, error) { - fromAddress := message.GetFromAddress() + fromAddress := message.GetSigners()[0] if _, err := transactionKeeper.authenticateAuxiliary.GetKeeper().Help(context, authenticate.NewAuxiliaryRequest(fromAddress, message.FromID)); err != nil { return nil, err diff --git a/x/orders/transactions/cancel/transaction_request.go b/x/orders/transactions/cancel/transaction_request.go index 44e9b20be..6aea81553 100644 --- a/x/orders/transactions/cancel/transaction_request.go +++ b/x/orders/transactions/cancel/transaction_request.go @@ -5,23 +5,21 @@ package cancel import ( "encoding/json" - "github.com/AssetMantle/modules/utilities/rest" - - codecUtilities "github.com/AssetMantle/schema/codec/utilities" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" + "io" + "net/http" "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/helpers/constants" ) type transactionRequest struct { - BaseReq rest.BaseReq `json:"baseReq"` - FromID string `json:"fromID"` - OrderID string `json:"orderID"` + helpers.CommonTransactionRequest `json:"commonTransactionRequest"` + FromID string `json:"fromID"` + OrderID string `json:"orderID"` } var _ helpers.TransactionRequest = (*transactionRequest)(nil) @@ -47,23 +45,28 @@ func (transactionRequest transactionRequest) Validate() error { } func (transactionRequest transactionRequest) FromCLI(cliCommand helpers.CLICommand, context client.Context) (helpers.TransactionRequest, error) { return newTransactionRequest( - cliCommand.ReadBaseReq(context), + cliCommand.ReadCommonTransactionRequest(context), cliCommand.ReadString(constants.FromIdentityID), cliCommand.ReadString(constants.OrderID), ), nil } -func (transactionRequest transactionRequest) FromJSON(rawMessage json.RawMessage) (helpers.TransactionRequest, error) { - if err := json.Unmarshal(rawMessage, &transactionRequest); err != nil { +func (transactionRequest transactionRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.TransactionRequest, error) { + body, err := io.ReadAll(httpRequest.Body) + if err != nil { + return nil, err + } + + if err := json.Unmarshal(body, &transactionRequest); err != nil { return nil, err } return transactionRequest, nil } -func (transactionRequest transactionRequest) GetBaseReq() rest.BaseReq { - return transactionRequest.BaseReq +func (transactionRequest transactionRequest) GetCommonTransactionRequest() helpers.CommonTransactionRequest { + return transactionRequest.CommonTransactionRequest } func (transactionRequest transactionRequest) MakeMsg() (sdkTypes.Msg, error) { - from, err := sdkTypes.AccAddressFromBech32(transactionRequest.GetBaseReq().From) + from, err := sdkTypes.AccAddressFromBech32(transactionRequest.GetCommonTransactionRequest().GetFrom()) if err != nil { return nil, err } @@ -84,16 +87,13 @@ func (transactionRequest transactionRequest) MakeMsg() (sdkTypes.Msg, error) { orderID.(ids.OrderID), ), nil } -func (transactionRequest) RegisterLegacyAminoCodec(legacyAmino *codec.LegacyAmino) { - codecUtilities.RegisterModuleConcrete(legacyAmino, transactionRequest{}) -} func requestPrototype() helpers.TransactionRequest { return transactionRequest{} } -func newTransactionRequest(baseReq rest.BaseReq, fromID string, orderID string) helpers.TransactionRequest { +func newTransactionRequest(commonTransactionRequest helpers.CommonTransactionRequest, fromID string, orderID string) helpers.TransactionRequest { return transactionRequest{ - BaseReq: baseReq, - FromID: fromID, - OrderID: orderID, + CommonTransactionRequest: commonTransactionRequest, + FromID: fromID, + OrderID: orderID, } } diff --git a/x/orders/transactions/cancel/transaction_request_test.go b/x/orders/transactions/cancel/transaction_request_test.go index 29e3cd9f0..d499139f9 100644 --- a/x/orders/transactions/cancel/transaction_request_test.go +++ b/x/orders/transactions/cancel/transaction_request_test.go @@ -4,9 +4,7 @@ package cancel import ( - "encoding/json" "fmt" - "github.com/AssetMantle/modules/utilities/rest" "reflect" "testing" @@ -16,15 +14,12 @@ import ( baseProperties "github.com/AssetMantle/schema/properties/base" baseQualified "github.com/AssetMantle/schema/qualified/base" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/types" - "github.com/spf13/viper" - "github.com/stretchr/testify/require" - "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/helpers/constants" + "github.com/spf13/viper" ) var ( @@ -33,30 +28,30 @@ var ( immutables = baseQualified.NewImmutables(base.NewPropertyList(baseProperties.NewMesaProperty(baseIDs.NewStringID("ID2"), baseData.NewStringData("Data2")))) mutables = baseQualified.NewMutables(base.NewPropertyList(baseProperties.NewMesaProperty(baseIDs.NewStringID("ID1"), baseData.NewStringData("Data1")))) - testClassificationID = baseIDs.NewClassificationID(immutables, mutables) - testFromID = baseIDs.NewIdentityID(testClassificationID, immutables) - testOrderID = baseIDs.NewOrderID(testClassificationID, immutables) - testOrderID1 = baseIDs.PrototypeOrderID() - testBaseRequest = rest.BaseReq{From: fromAddress, ChainID: "test", Fees: types.NewCoins()} + testClassificationID = baseIDs.NewClassificationID(immutables, mutables) + testFromID = baseIDs.NewIdentityID(testClassificationID, immutables) + testOrderID = baseIDs.NewOrderID(testClassificationID, immutables) + testOrderID1 = baseIDs.PrototypeOrderID() + commonTransactionRequest = helpers.PrototypeCommonTransactionRequest() ) func Test_newTransactionRequest(t *testing.T) { type args struct { - baseReq rest.BaseReq - fromID string - orderID string + commonTransactionRequest helpers.CommonTransactionRequest + fromID string + orderID string } tests := []struct { name string args args want helpers.TransactionRequest }{ - {"+ve", args{testBaseRequest, testFromID.AsString(), testOrderID.AsString()}, newTransactionRequest(testBaseRequest, testFromID.AsString(), testOrderID.AsString())}, - {"+ve", args{testBaseRequest, testFromID.AsString(), testOrderID1.AsString()}, newTransactionRequest(testBaseRequest, testFromID.AsString(), testOrderID1.AsString())}, + {"+ve", args{commonTransactionRequest, testFromID.AsString(), testOrderID.AsString()}, newTransactionRequest(commonTransactionRequest, testFromID.AsString(), testOrderID.AsString())}, + {"+ve", args{commonTransactionRequest, testFromID.AsString(), testOrderID1.AsString()}, newTransactionRequest(commonTransactionRequest, testFromID.AsString(), testOrderID1.AsString())}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - if got := newTransactionRequest(tt.args.baseReq, tt.args.fromID, tt.args.orderID); !reflect.DeepEqual(got, tt.want) { + if got := newTransactionRequest(tt.args.commonTransactionRequest, tt.args.fromID, tt.args.orderID); !reflect.DeepEqual(got, tt.want) { t.Errorf("newTransactionRequest() = %v, want %v", got, tt.want) } }) @@ -85,9 +80,9 @@ func Test_transactionRequest_FromCLI(t *testing.T) { viper.Set(constants.FromIdentityID.GetName(), testFromID.AsString()) viper.Set(constants.OrderID.GetName(), testOrderID.AsString()) type fields struct { - BaseReq rest.BaseReq - FromID string - OrderID string + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + OrderID string } type args struct { cliCommand helpers.CLICommand @@ -100,14 +95,14 @@ func Test_transactionRequest_FromCLI(t *testing.T) { want helpers.TransactionRequest wantErr bool }{ - {"+ve", fields{testBaseRequest, testFromID.AsString(), testOrderID.AsString()}, args{cliCommand, client.Context{}.WithCodec(baseHelpers.CodecPrototype())}, newTransactionRequest(testBaseRequest, testFromID.AsString(), testOrderID.AsString()), false}, + {"+ve", fields{commonTransactionRequest, testFromID.AsString(), testOrderID.AsString()}, args{cliCommand, client.Context{}.WithCodec(baseHelpers.CodecPrototype())}, newTransactionRequest(commonTransactionRequest, testFromID.AsString(), testOrderID.AsString()), false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - OrderID: tt.fields.OrderID, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + OrderID: tt.fields.OrderID, } got, err := transactionRequest.FromCLI(tt.args.cliCommand, tt.args.context) if (err != nil) != tt.wantErr { @@ -121,72 +116,29 @@ func Test_transactionRequest_FromCLI(t *testing.T) { } } -func Test_transactionRequest_FromJSON(t *testing.T) { - jsonMessage, err := json.Marshal(newTransactionRequest(testBaseRequest, testFromID.AsString(), testOrderID.AsString())) - require.NoError(t, err) - jsonMessage1, err := json.Marshal(newTransactionRequest(testBaseRequest, testFromID.AsString(), testOrderID1.AsString())) - require.NoError(t, err) - - type fields struct { - BaseReq rest.BaseReq - FromID string - OrderID string - } - type args struct { - rawMessage json.RawMessage - } - tests := []struct { - name string - fields fields - args args - want helpers.TransactionRequest - wantErr bool - }{ - {"+ve", fields{testBaseRequest, testFromID.AsString(), testOrderID.AsString()}, args{jsonMessage}, transactionRequest{testBaseRequest, testFromID.AsString(), testOrderID.AsString()}, false}, - {"+ve with nil", fields{testBaseRequest, testFromID.AsString(), testOrderID1.AsString()}, args{jsonMessage1}, transactionRequest{testBaseRequest, testFromID.AsString(), testOrderID1.AsString()}, false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - OrderID: tt.fields.OrderID, - } - got, err := transactionRequest.FromJSON(tt.args.rawMessage) - if (err != nil) != tt.wantErr { - t.Errorf("FromJSON() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("FromJSON() got = %v, want %v", got, tt.want) - } - }) - } -} - func Test_transactionRequest_GetBaseReq(t *testing.T) { type fields struct { - BaseReq rest.BaseReq - FromID string - OrderID string + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + OrderID string } tests := []struct { name string fields fields - want rest.BaseReq + want helpers.CommonTransactionRequest }{ - {"+ve", fields{testBaseRequest, testFromID.AsString(), testOrderID.AsString()}, testBaseRequest}, - {"+ve with nil", fields{testBaseRequest, testFromID.AsString(), testOrderID1.AsString()}, testBaseRequest}, + {"+ve", fields{commonTransactionRequest, testFromID.AsString(), testOrderID.AsString()}, commonTransactionRequest}, + {"+ve with nil", fields{commonTransactionRequest, testFromID.AsString(), testOrderID1.AsString()}, commonTransactionRequest}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - OrderID: tt.fields.OrderID, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + OrderID: tt.fields.OrderID, } - if got := transactionRequest.GetBaseReq(); !reflect.DeepEqual(got, tt.want) { - t.Errorf("GetBaseReq() = %v, want %v", got, tt.want) + if got := transactionRequest.GetCommonTransactionRequest(); !reflect.DeepEqual(got, tt.want) { + t.Errorf("GetCommonTransactionRequest() = %v, want %v", got, tt.want) } }) } @@ -194,9 +146,9 @@ func Test_transactionRequest_GetBaseReq(t *testing.T) { func Test_transactionRequest_MakeMsg(t *testing.T) { type fields struct { - BaseReq rest.BaseReq - FromID string - OrderID string + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + OrderID string } tests := []struct { name string @@ -204,14 +156,14 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { want types.Msg wantErr bool }{ - {"+ve", fields{testBaseRequest, testFromID.AsString(), testOrderID.AsString()}, NewMessage(fromAccAddress, testFromID, testOrderID), false}, + {"+ve", fields{commonTransactionRequest, testFromID.AsString(), testOrderID.AsString()}, NewMessage(fromAccAddress, testFromID, testOrderID), false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - OrderID: tt.fields.OrderID, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + OrderID: tt.fields.OrderID, } got, err := transactionRequest.MakeMsg() if (err != nil) != tt.wantErr { @@ -225,55 +177,26 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { } } -func Test_transactionRequest_RegisterCodec(t *testing.T) { - type fields struct { - BaseReq rest.BaseReq - FromID string - OrderID string - } - type args struct { - legacyAmino *codec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{testBaseRequest, testFromID.AsString(), testOrderID.AsString()}, args{codec.NewLegacyAmino()}}, - {"+ve with nil", fields{testBaseRequest, testFromID.AsString(), testOrderID1.AsString()}, args{codec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - tr := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - OrderID: tt.fields.OrderID, - } - tr.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - func Test_transactionRequest_Validate(t *testing.T) { type fields struct { - BaseReq rest.BaseReq - FromID string - OrderID string + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + OrderID string } tests := []struct { name string fields fields wantErr bool }{ - {"+ve", fields{testBaseRequest, testFromID.AsString(), testOrderID.AsString()}, false}, - {"+ve with nil", fields{testBaseRequest, testFromID.AsString(), testOrderID1.AsString()}, true}, + {"+ve", fields{commonTransactionRequest, testFromID.AsString(), testOrderID.AsString()}, false}, + {"+ve with nil", fields{commonTransactionRequest, testFromID.AsString(), testOrderID1.AsString()}, true}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - OrderID: tt.fields.OrderID, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + OrderID: tt.fields.OrderID, } if err := transactionRequest.Validate(); (err != nil) != tt.wantErr { t.Errorf("ValidateBasic() error = %v, wantErr %v", err, tt.wantErr) diff --git a/x/orders/transactions/cancel/transaction_response.go b/x/orders/transactions/cancel/transaction_response.go index 6c9cd7d00..6d28d27ee 100644 --- a/x/orders/transactions/cancel/transaction_response.go +++ b/x/orders/transactions/cancel/transaction_response.go @@ -4,9 +4,8 @@ package cancel import ( - sdkTypes "github.com/cosmos/cosmos-sdk/types" - "github.com/AssetMantle/modules/helpers" + sdkTypes "github.com/cosmos/cosmos-sdk/types" ) var _ helpers.TransactionResponse = (*TransactionResponse)(nil) diff --git a/x/orders/transactions/define/message.go b/x/orders/transactions/define/message.go index 7a7e2af6e..de8274451 100644 --- a/x/orders/transactions/define/message.go +++ b/x/orders/transactions/define/message.go @@ -4,28 +4,17 @@ package define import ( - codecUtilities "github.com/AssetMantle/schema/codec/utilities" + "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" "github.com/AssetMantle/schema/lists" baseLists "github.com/AssetMantle/schema/lists/base" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/types" sdkTypes "github.com/cosmos/cosmos-sdk/types" - - "github.com/AssetMantle/modules/helpers" ) var _ helpers.Message = (*Message)(nil) -func (message *Message) Type() string { return Transaction.GetName() } -func (message *Message) GetFromAddress() sdkTypes.AccAddress { - from, err := sdkTypes.AccAddressFromBech32(message.From) - if err != nil { - panic(err) - } - return from -} func (message *Message) ValidateBasic() error { if _, err := sdkTypes.AccAddressFromBech32(message.From); err != nil { return err @@ -54,21 +43,10 @@ func (message *Message) GetSigners() []sdkTypes.AccAddress { } return []sdkTypes.AccAddress{from} } -func (*Message) RegisterLegacyAminoCodec(legacyAmino *codec.LegacyAmino) { - codecUtilities.RegisterModuleConcrete(legacyAmino, Message{}) -} func (message *Message) RegisterInterface(interfaceRegistry types.InterfaceRegistry) { interfaceRegistry.RegisterImplementations((*sdkTypes.Msg)(nil), message) } -func messageFromInterface(msg sdkTypes.Msg) *Message { - switch value := msg.(type) { - case *Message: - return value - default: - return &Message{} - } -} func messagePrototype() helpers.Message { return &Message{} } diff --git a/x/orders/transactions/define/message_test.go b/x/orders/transactions/define/message_test.go index 94900b39a..d3b35acb8 100644 --- a/x/orders/transactions/define/message_test.go +++ b/x/orders/transactions/define/message_test.go @@ -11,7 +11,6 @@ import ( baseIDs "github.com/AssetMantle/schema/ids/base" "github.com/AssetMantle/schema/lists" baseLists "github.com/AssetMantle/schema/lists/base" - "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" "github.com/AssetMantle/modules/helpers" @@ -30,26 +29,6 @@ type fields struct { MutableProperties *baseLists.PropertyList } -func Test_messageFromInterface(t *testing.T) { - type args struct { - msg sdkTypes.Msg - } - tests := []struct { - name string - args args - want *Message - }{ - {"+ve", args{testMessage}, &Message{fromAccAddress.String(), testFromID, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := messageFromInterface(tt.args.msg); !reflect.DeepEqual(got, tt.want) { - t.Errorf("messageFromInterface() = %v, want %v", got, tt.want) - } - }) - } -} - func Test_messagePrototype(t *testing.T) { tests := []struct { name string @@ -92,59 +71,6 @@ func Test_message_GetSigners(t *testing.T) { } } -func Test_message_RegisterCodec(t *testing.T) { - - type args struct { - legacyAmino *codec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{fromAccAddress.String(), testFromID, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties}, args{codec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - me := &Message{ - From: tt.fields.From, - FromID: tt.fields.FromID, - ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, - ImmutableProperties: tt.fields.ImmutableProperties, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, - } - me.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - -func Test_message_Type(t *testing.T) { - - tests := []struct { - name string - fields fields - want string - }{ - {"+ve", fields{fromAccAddress.String(), testFromID, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties}, Transaction.GetName()}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - message := &Message{ - From: tt.fields.From, - FromID: tt.fields.FromID, - ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, - ImmutableProperties: tt.fields.ImmutableProperties, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, - } - if got := message.Type(); got != tt.want { - t.Errorf("Type() = %v, want %v", got, tt.want) - } - }) - } -} - func Test_message_ValidateBasic(t *testing.T) { tests := []struct { diff --git a/x/orders/transactions/define/service.pb.go b/x/orders/transactions/define/service.pb.go index f89516db4..e5d27a56a 100644 --- a/x/orders/transactions/define/service.pb.go +++ b/x/orders/transactions/define/service.pb.go @@ -6,9 +6,9 @@ package define import ( context "context" fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types/msgservice" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" - _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -31,30 +31,29 @@ func init() { } var fileDescriptor_81719b2aa52d08bc = []byte{ - // 363 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0xd2, 0xcf, 0x4a, 0xeb, 0x40, - 0x14, 0x06, 0xf0, 0x26, 0x85, 0x2e, 0xc2, 0x5d, 0x15, 0x2e, 0x42, 0xd0, 0x2c, 0xfa, 0x00, 0x33, - 0xe2, 0x9f, 0x85, 0xa3, 0x08, 0x2d, 0x15, 0x05, 0x09, 0x2d, 0xda, 0x45, 0x90, 0x80, 0x4c, 0x93, - 0x63, 0x0c, 0x24, 0x33, 0x25, 0x33, 0x95, 0x6e, 0xf5, 0x09, 0x04, 0xdf, 0xc0, 0x9d, 0xee, 0x7c, - 0x0b, 0x71, 0x55, 0x70, 0xe3, 0x52, 0x52, 0x57, 0x3e, 0x85, 0xd8, 0x19, 0x70, 0xba, 0x9c, 0xed, - 0x84, 0xdf, 0xc7, 0x77, 0x4e, 0x8e, 0x77, 0xd8, 0x15, 0x02, 0x64, 0x48, 0x99, 0x2c, 0x00, 0x97, - 0x3c, 0x9d, 0x16, 0x20, 0xf0, 0x0c, 0xf3, 0x2a, 0x85, 0x4a, 0x60, 0x59, 0x51, 0x26, 0x68, 0x22, - 0x73, 0xce, 0x04, 0x4e, 0xe1, 0x2a, 0x67, 0x80, 0x05, 0x54, 0x37, 0x79, 0x02, 0x68, 0x52, 0x71, - 0xc9, 0xdb, 0x9b, 0x86, 0x47, 0xda, 0xa3, 0x19, 0x52, 0x1e, 0x99, 0x1e, 0x29, 0xef, 0xaf, 0x67, - 0x9c, 0x67, 0x05, 0x60, 0x3a, 0xc9, 0x31, 0x65, 0x8c, 0x4b, 0xaa, 0x3e, 0x2f, 0xf3, 0x7c, 0xfb, - 0x3e, 0x25, 0x08, 0x41, 0x33, 0xdd, 0xc7, 0x3f, 0xb5, 0xf6, 0xc6, 0xdb, 0x65, 0x05, 0x62, 0xc2, - 0x99, 0xd0, 0x61, 0x5b, 0x2f, 0x8e, 0xd7, 0x0c, 0x45, 0xd6, 0x7e, 0x72, 0xbc, 0xd6, 0x09, 0x65, - 0x69, 0x01, 0xed, 0x3d, 0x64, 0x3b, 0x30, 0x0a, 0x55, 0x41, 0xff, 0xc8, 0x9e, 0x8e, 0xfe, 0xde, - 0xce, 0x74, 0xb5, 0xce, 0xc6, 0xdd, 0xfb, 0xd7, 0x83, 0xbb, 0xd6, 0xf9, 0x8f, 0x4b, 0x35, 0xa5, - 0x9e, 0x4d, 0x91, 0xde, 0x6d, 0xf3, 0xb5, 0x0e, 0x9c, 0x79, 0x1d, 0x38, 0x9f, 0x75, 0xe0, 0xdc, - 0x2f, 0x82, 0xc6, 0x7c, 0x11, 0x34, 0x3e, 0x16, 0x41, 0xc3, 0xdb, 0x49, 0x78, 0x69, 0xdd, 0xa1, - 0xf7, 0xef, 0x5c, 0xfd, 0xf0, 0xe1, 0xef, 0x4a, 0x86, 0xce, 0xc5, 0x7e, 0x96, 0xcb, 0xeb, 0xe9, - 0x18, 0x25, 0xbc, 0xc4, 0xb6, 0xcb, 0x7e, 0x74, 0x5b, 0xdd, 0x30, 0x1a, 0x8c, 0xfa, 0xcf, 0xee, - 0xca, 0xe1, 0x84, 0xba, 0x48, 0x84, 0x06, 0xaa, 0xc8, 0xc8, 0x2c, 0xd2, 0x5f, 0xda, 0xb7, 0x15, - 0x12, 0x6b, 0x12, 0x47, 0xb1, 0x22, 0xb1, 0x49, 0x62, 0x45, 0x6a, 0xf7, 0xc0, 0x96, 0xc4, 0xc7, - 0xc3, 0x5e, 0x08, 0x92, 0xa6, 0x54, 0xd2, 0x6f, 0x77, 0xd7, 0xe0, 0x84, 0x68, 0x4f, 0x48, 0x44, - 0x88, 0x4a, 0x20, 0xc4, 0x8c, 0x20, 0x44, 0x65, 0x8c, 0x5b, 0xcb, 0xf3, 0xd9, 0xfe, 0x09, 0x00, - 0x00, 0xff, 0xff, 0x0a, 0xba, 0xb6, 0x32, 0x5d, 0x03, 0x00, 0x00, + // 352 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0xd2, 0x3f, 0x4b, 0xfb, 0x40, + 0x18, 0x07, 0xf0, 0x5c, 0xca, 0xaf, 0x43, 0xf8, 0x4d, 0x5d, 0x84, 0x0c, 0x19, 0x1c, 0x1d, 0xee, + 0xfc, 0x3b, 0x78, 0x8a, 0xd0, 0x52, 0x51, 0x90, 0xd0, 0xa2, 0x1d, 0x82, 0x04, 0xe4, 0x9a, 0x9c, + 0x31, 0xd0, 0xe4, 0x4a, 0x9e, 0x6b, 0xe9, 0xa8, 0xbb, 0x83, 0xbb, 0x9b, 0xa3, 0x93, 0x2f, 0x43, + 0x9c, 0x3a, 0x3a, 0x4a, 0x3a, 0x08, 0xbe, 0x0a, 0x69, 0xef, 0xc0, 0xeb, 0x78, 0x53, 0xe0, 0x81, + 0xcf, 0x37, 0xdf, 0x27, 0x79, 0xbc, 0x93, 0x36, 0x00, 0x97, 0x21, 0x2b, 0xe5, 0x88, 0x93, 0x42, + 0xa4, 0x93, 0x11, 0x07, 0x32, 0x23, 0xa2, 0x4a, 0x79, 0x05, 0x44, 0x56, 0xac, 0x04, 0x96, 0xc8, + 0x5c, 0x94, 0x40, 0x52, 0x7e, 0x9b, 0x97, 0x9c, 0x00, 0xaf, 0xa6, 0x79, 0xc2, 0xf1, 0xb8, 0x12, + 0x52, 0xb4, 0xb6, 0x0d, 0x8f, 0xb5, 0xc7, 0x33, 0xac, 0x3c, 0x36, 0x3d, 0x56, 0xde, 0xdf, 0x48, + 0x04, 0x14, 0x02, 0x48, 0x01, 0x19, 0x99, 0xee, 0x2c, 0x1f, 0x2a, 0xca, 0xb7, 0xaf, 0x52, 0x70, + 0x00, 0x96, 0xe9, 0x2a, 0xfe, 0x85, 0xb5, 0x37, 0x66, 0x37, 0x15, 0x87, 0xb1, 0x28, 0x41, 0x87, + 0xed, 0x3e, 0x23, 0xaf, 0x11, 0x42, 0xd6, 0x7a, 0x44, 0x5e, 0xf3, 0x9c, 0x95, 0xe9, 0x88, 0xb7, + 0x0e, 0xb1, 0xed, 0xae, 0x38, 0x54, 0x05, 0xfd, 0x53, 0x7b, 0x3a, 0xf8, 0x9b, 0x5d, 0xea, 0x6a, + 0x9b, 0x8e, 0xff, 0xef, 0xfe, 0xfb, 0x6d, 0x0b, 0x75, 0x1e, 0x1a, 0xef, 0x75, 0x80, 0xe6, 0x75, + 0x80, 0xbe, 0xea, 0x00, 0x3d, 0x2d, 0x02, 0x67, 0xbe, 0x08, 0x9c, 0xcf, 0x45, 0xe0, 0x78, 0xfb, + 0x89, 0x28, 0xac, 0xdf, 0xd6, 0xf9, 0x7f, 0xa5, 0xfe, 0x6a, 0x7f, 0xb9, 0x7c, 0x1f, 0x5d, 0x1f, + 0x65, 0xb9, 0xbc, 0x9b, 0x0c, 0x71, 0x22, 0x0a, 0x62, 0xfb, 0x59, 0x5f, 0xdc, 0x66, 0x3b, 0x8c, + 0x7a, 0x83, 0xee, 0xab, 0xbb, 0x76, 0x1d, 0xa1, 0x2e, 0x12, 0xe1, 0x9e, 0x2a, 0x32, 0x30, 0x8b, + 0x74, 0x57, 0xf6, 0x63, 0x8d, 0xc4, 0x9a, 0xc4, 0x51, 0xac, 0x48, 0x6c, 0x92, 0x58, 0x91, 0xda, + 0x3d, 0xb6, 0x25, 0xf1, 0x59, 0xbf, 0x13, 0x72, 0xc9, 0x52, 0x26, 0xd9, 0x8f, 0x7b, 0x60, 0x70, + 0x4a, 0xb5, 0xa7, 0x34, 0xa2, 0x54, 0x25, 0x50, 0x6a, 0x46, 0x50, 0xaa, 0x32, 0x86, 0xcd, 0xd5, + 0xa1, 0xec, 0xfd, 0x06, 0x00, 0x00, 0xff, 0xff, 0x35, 0x30, 0xd3, 0x57, 0x42, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/orders/transactions/define/service.pb.gw.go b/x/orders/transactions/define/service.pb.gw.go deleted file mode 100644 index 5533444a0..000000000 --- a/x/orders/transactions/define/service.pb.gw.go +++ /dev/null @@ -1,171 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: AssetMantle/modules/x/orders/transactions/define/service.proto - -/* -Package define is a reverse proxy. - -It translates gRPC into RESTful JSON APIs. -*/ -package define - -import ( - "context" - "io" - "net/http" - - "github.com/golang/protobuf/descriptor" - "github.com/golang/protobuf/proto" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/grpc-ecosystem/grpc-gateway/utilities" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/status" -) - -// Suppress "imported and not used" errors -var _ codes.Code -var _ io.Reader -var _ status.Status -var _ = runtime.String -var _ = utilities.NewDoubleArray -var _ = descriptor.ForMessage -var _ = metadata.Join - -var ( - filter_Msg_Handle_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - -func request_Msg_Handle_0(ctx context.Context, marshaler runtime.Marshaler, client MsgClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq Message - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.Handle(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Msg_Handle_0(ctx context.Context, marshaler runtime.Marshaler, server MsgServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq Message - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.Handle(ctx, &protoReq) - return msg, metadata, err - -} - -// RegisterMsgHandlerServer registers the http handlers for service Msg to "mux". -// UnaryRPC :call MsgServer directly. -// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterMsgHandlerFromEndpoint instead. -func RegisterMsgHandlerServer(ctx context.Context, mux *runtime.ServeMux, server MsgServer) error { - - mux.Handle("POST", pattern_Msg_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Msg_Handle_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Msg_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -// RegisterMsgHandlerFromEndpoint is same as RegisterMsgHandler but -// automatically dials to "endpoint" and closes the connection when "ctx" gets done. -func RegisterMsgHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.Dial(endpoint, opts...) - if err != nil { - return err - } - defer func() { - if err != nil { - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - return - } - go func() { - <-ctx.Done() - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - }() - }() - - return RegisterMsgHandler(ctx, mux, conn) -} - -// RegisterMsgHandler registers the http handlers for service Msg to "mux". -// The handlers forward requests to the grpc endpoint over "conn". -func RegisterMsgHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { - return RegisterMsgHandlerClient(ctx, mux, NewMsgClient(conn)) -} - -// RegisterMsgHandlerClient registers the http handlers for service Msg -// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "MsgClient". -// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "MsgClient" -// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "MsgClient" to call the correct interceptors. -func RegisterMsgHandlerClient(ctx context.Context, mux *runtime.ServeMux, client MsgClient) error { - - mux.Handle("POST", pattern_Msg_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Msg_Handle_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Msg_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -var ( - pattern_Msg_Handle_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"mantle", "orders", "define"}, "", runtime.AssumeColonVerbOpt(false))) -) - -var ( - forward_Msg_Handle_0 = runtime.ForwardResponseMessage -) diff --git a/x/orders/transactions/define/transaction.go b/x/orders/transactions/define/transaction.go index 6242b9071..dac93a936 100644 --- a/x/orders/transactions/define/transaction.go +++ b/x/orders/transactions/define/transaction.go @@ -4,22 +4,14 @@ package define import ( - "context" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "google.golang.org/grpc" - "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/helpers/constants" - "github.com/AssetMantle/modules/utilities/name" + "google.golang.org/grpc" ) -type dummy struct{} - var Transaction = baseHelpers.NewTransaction( - name.GetPackageName(dummy{}), + _Msg_serviceDesc.ServiceName, "", "", @@ -30,9 +22,6 @@ var Transaction = baseHelpers.NewTransaction( func(server grpc.ServiceRegistrar, keeper helpers.TransactionKeeper) { RegisterMsgServer(server, keeper.(transactionKeeper)) }, - func(clientCtx client.Context, mux *runtime.ServeMux) error { - return RegisterMsgHandlerClient(context.Background(), mux, NewMsgClient(clientCtx)) - }, constants.FromIdentityID, constants.ImmutableMetaProperties, diff --git a/x/orders/transactions/define/transaction_keeper.go b/x/orders/transactions/define/transaction_keeper.go index 1f6dcacd8..4cfa52bfe 100644 --- a/x/orders/transactions/define/transaction_keeper.go +++ b/x/orders/transactions/define/transaction_keeper.go @@ -5,7 +5,6 @@ package define import ( "context" - baseLists "github.com/AssetMantle/schema/lists/base" "github.com/AssetMantle/schema/properties/constants" "github.com/AssetMantle/schema/qualified/base" diff --git a/x/orders/transactions/define/transaction_request.go b/x/orders/transactions/define/transaction_request.go index 06deea476..53cc10286 100644 --- a/x/orders/transactions/define/transaction_request.go +++ b/x/orders/transactions/define/transaction_request.go @@ -5,27 +5,25 @@ package define import ( "encoding/json" - "github.com/AssetMantle/modules/utilities/rest" - - codecUtilities "github.com/AssetMantle/schema/codec/utilities" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" "github.com/AssetMantle/schema/lists/base" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" + "io" + "net/http" "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/helpers/constants" ) type transactionRequest struct { - BaseReq rest.BaseReq `json:"baseReq"` - FromID string `json:"fromID"` - ImmutableMetaProperties string `json:"immutableMetaProperties"` - ImmutableProperties string `json:"immutableProperties"` - MutableMetaProperties string `json:"mutableMetaProperties"` - MutableProperties string `json:"mutableProperties"` + helpers.CommonTransactionRequest `json:"commonTransactionRequest"` + FromID string `json:"fromID"` + ImmutableMetaProperties string `json:"immutableMetaProperties"` + ImmutableProperties string `json:"immutableProperties"` + MutableMetaProperties string `json:"mutableMetaProperties"` + MutableProperties string `json:"mutableProperties"` } var _ helpers.TransactionRequest = (*transactionRequest)(nil) @@ -51,7 +49,7 @@ func (transactionRequest transactionRequest) Validate() error { } func (transactionRequest transactionRequest) FromCLI(cliCommand helpers.CLICommand, context client.Context) (helpers.TransactionRequest, error) { return newTransactionRequest( - cliCommand.ReadBaseReq(context), + cliCommand.ReadCommonTransactionRequest(context), cliCommand.ReadString(constants.FromIdentityID), cliCommand.ReadString(constants.ImmutableMetaProperties), cliCommand.ReadString(constants.ImmutableProperties), @@ -59,18 +57,23 @@ func (transactionRequest transactionRequest) FromCLI(cliCommand helpers.CLIComma cliCommand.ReadString(constants.MutableProperties), ), nil } -func (transactionRequest transactionRequest) FromJSON(rawMessage json.RawMessage) (helpers.TransactionRequest, error) { - if err := json.Unmarshal(rawMessage, &transactionRequest); err != nil { +func (transactionRequest transactionRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.TransactionRequest, error) { + body, err := io.ReadAll(httpRequest.Body) + if err != nil { + return nil, err + } + + if err := json.Unmarshal(body, &transactionRequest); err != nil { return nil, err } return transactionRequest, nil } -func (transactionRequest transactionRequest) GetBaseReq() rest.BaseReq { - return transactionRequest.BaseReq +func (transactionRequest transactionRequest) GetCommonTransactionRequest() helpers.CommonTransactionRequest { + return transactionRequest.CommonTransactionRequest } func (transactionRequest transactionRequest) MakeMsg() (sdkTypes.Msg, error) { - from, err := sdkTypes.AccAddressFromBech32(transactionRequest.GetBaseReq().From) + from, err := sdkTypes.AccAddressFromBech32(transactionRequest.GetCommonTransactionRequest().GetFrom()) if err != nil { return nil, err } @@ -111,19 +114,16 @@ func (transactionRequest transactionRequest) MakeMsg() (sdkTypes.Msg, error) { mutableProperties, ), nil } -func (transactionRequest) RegisterLegacyAminoCodec(legacyAmino *codec.LegacyAmino) { - codecUtilities.RegisterModuleConcrete(legacyAmino, transactionRequest{}) -} func requestPrototype() helpers.TransactionRequest { return transactionRequest{} } -func newTransactionRequest(baseReq rest.BaseReq, fromID string, immutableMetaProperties string, immutableProperties string, mutableMetaProperties string, mutableProperties string) helpers.TransactionRequest { +func newTransactionRequest(commonTransactionRequest helpers.CommonTransactionRequest, fromID string, immutableMetaProperties string, immutableProperties string, mutableMetaProperties string, mutableProperties string) helpers.TransactionRequest { return transactionRequest{ - BaseReq: baseReq, - FromID: fromID, - ImmutableMetaProperties: immutableMetaProperties, - ImmutableProperties: immutableProperties, - MutableMetaProperties: mutableMetaProperties, - MutableProperties: mutableProperties, + CommonTransactionRequest: commonTransactionRequest, + FromID: fromID, + ImmutableMetaProperties: immutableMetaProperties, + ImmutableProperties: immutableProperties, + MutableMetaProperties: mutableMetaProperties, + MutableProperties: mutableProperties, } } diff --git a/x/orders/transactions/define/transaction_request_test.go b/x/orders/transactions/define/transaction_request_test.go index b0e23032b..fbec54862 100644 --- a/x/orders/transactions/define/transaction_request_test.go +++ b/x/orders/transactions/define/transaction_request_test.go @@ -4,9 +4,7 @@ package define import ( - "encoding/json" "fmt" - "github.com/AssetMantle/modules/utilities/rest" "reflect" "testing" @@ -14,15 +12,12 @@ import ( baseLists "github.com/AssetMantle/schema/lists/base" "github.com/AssetMantle/schema/qualified/base" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/types" - "github.com/spf13/viper" - "github.com/stretchr/testify/require" - "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/helpers/constants" + "github.com/spf13/viper" ) var ( @@ -45,28 +40,28 @@ var ( mutables = base.NewMutables(mutableProperties) testClassificationID = baseIDs.NewClassificationID(immutables, mutables) testFromID = baseIDs.NewIdentityID(testClassificationID, immutables).(*baseIDs.IdentityID) - testBaseRequest = rest.BaseReq{From: fromAddress, ChainID: "test", Fees: types.NewCoins()} + commonTransactionRequest = helpers.PrototypeCommonTransactionRequest() ) func Test_newTransactionRequest(t *testing.T) { type args struct { - baseReq rest.BaseReq - fromID string - immutableMetaProperties string - immutableProperties string - mutableMetaProperties string - mutableProperties string + commonTransactionRequest helpers.CommonTransactionRequest + fromID string + immutableMetaProperties string + immutableProperties string + mutableMetaProperties string + mutableProperties string } tests := []struct { name string args args want helpers.TransactionRequest }{ - {"+ve", args{testBaseRequest, testFromID.AsString(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, newTransactionRequest(testBaseRequest, testFromID.AsString(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString)}, + {"+ve", args{commonTransactionRequest, testFromID.AsString(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, newTransactionRequest(commonTransactionRequest, testFromID.AsString(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString)}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - if got := newTransactionRequest(tt.args.baseReq, tt.args.fromID, tt.args.immutableMetaProperties, tt.args.immutableProperties, tt.args.mutableMetaProperties, tt.args.mutableProperties); !reflect.DeepEqual(got, tt.want) { + if got := newTransactionRequest(tt.args.commonTransactionRequest, tt.args.fromID, tt.args.immutableMetaProperties, tt.args.immutableProperties, tt.args.mutableMetaProperties, tt.args.mutableProperties); !reflect.DeepEqual(got, tt.want) { t.Errorf("newTransactionRequest() = %v, want %v", got, tt.want) } }) @@ -98,12 +93,12 @@ func Test_transactionRequest_FromCLI(t *testing.T) { viper.Set(constants.MutableProperties.GetName(), mutablePropertiesString) viper.Set(constants.FromIdentityID.GetName(), testFromID.AsString()) type fields struct { - BaseReq rest.BaseReq - FromID string - ImmutableMetaProperties string - ImmutableProperties string - MutableMetaProperties string - MutableProperties string + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + ImmutableMetaProperties string + ImmutableProperties string + MutableMetaProperties string + MutableProperties string } type args struct { cliCommand helpers.CLICommand @@ -116,17 +111,17 @@ func Test_transactionRequest_FromCLI(t *testing.T) { want helpers.TransactionRequest wantErr bool }{ - {"+ve", fields{testBaseRequest, testFromID.AsString(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, args{cliCommand, client.Context{}.WithCodec(baseHelpers.CodecPrototype())}, newTransactionRequest(testBaseRequest, testFromID.AsString(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString), false}, + {"+ve", fields{commonTransactionRequest, testFromID.AsString(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, args{cliCommand, client.Context{}.WithCodec(baseHelpers.CodecPrototype())}, newTransactionRequest(commonTransactionRequest, testFromID.AsString(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString), false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, - ImmutableProperties: tt.fields.ImmutableProperties, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, + ImmutableProperties: tt.fields.ImmutableProperties, + MutableMetaProperties: tt.fields.MutableMetaProperties, + MutableProperties: tt.fields.MutableProperties, } got, err := transactionRequest.FromCLI(tt.args.cliCommand, tt.args.context) if (err != nil) != tt.wantErr { @@ -140,79 +135,34 @@ func Test_transactionRequest_FromCLI(t *testing.T) { } } -func Test_transactionRequest_FromJSON(t *testing.T) { - jsonMessage, err := json.Marshal(newTransactionRequest(testBaseRequest, testFromID.AsString(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString)) - require.NoError(t, err) - type fields struct { - BaseReq rest.BaseReq - FromID string - ImmutableMetaProperties string - ImmutableProperties string - MutableMetaProperties string - MutableProperties string - } - type args struct { - rawMessage json.RawMessage - } - tests := []struct { - name string - fields fields - args args - want helpers.TransactionRequest - wantErr bool - }{ - {"+ve", fields{testBaseRequest, testFromID.AsString(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, args{jsonMessage}, transactionRequest{testBaseRequest, testFromID.AsString(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, - ImmutableProperties: tt.fields.ImmutableProperties, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, - } - got, err := transactionRequest.FromJSON(tt.args.rawMessage) - if (err != nil) != tt.wantErr { - t.Errorf("FromJSON() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("FromJSON() got = %v, want %v", got, tt.want) - } - }) - } -} - func Test_transactionRequest_GetBaseReq(t *testing.T) { type fields struct { - BaseReq rest.BaseReq - FromID string - ImmutableMetaProperties string - ImmutableProperties string - MutableMetaProperties string - MutableProperties string + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + ImmutableMetaProperties string + ImmutableProperties string + MutableMetaProperties string + MutableProperties string } tests := []struct { name string fields fields - want rest.BaseReq + want helpers.CommonTransactionRequest }{ - {"+ve", fields{testBaseRequest, testFromID.AsString(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, testBaseRequest}, + {"+ve", fields{commonTransactionRequest, testFromID.AsString(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, commonTransactionRequest}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, - ImmutableProperties: tt.fields.ImmutableProperties, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, + ImmutableProperties: tt.fields.ImmutableProperties, + MutableMetaProperties: tt.fields.MutableMetaProperties, + MutableProperties: tt.fields.MutableProperties, } - if got := transactionRequest.GetBaseReq(); !reflect.DeepEqual(got, tt.want) { - t.Errorf("GetBaseReq() = %v, want %v", got, tt.want) + if got := transactionRequest.GetCommonTransactionRequest(); !reflect.DeepEqual(got, tt.want) { + t.Errorf("GetCommonTransactionRequest() = %v, want %v", got, tt.want) } }) } @@ -220,12 +170,12 @@ func Test_transactionRequest_GetBaseReq(t *testing.T) { func Test_transactionRequest_MakeMsg(t *testing.T) { type fields struct { - BaseReq rest.BaseReq - FromID string - ImmutableMetaProperties string - ImmutableProperties string - MutableMetaProperties string - MutableProperties string + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + ImmutableMetaProperties string + ImmutableProperties string + MutableMetaProperties string + MutableProperties string } tests := []struct { name string @@ -233,17 +183,17 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { want types.Msg wantErr bool }{ - {"+ve", fields{testBaseRequest, testFromID.AsString(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, NewMessage(fromAccAddress, testFromID, immutableMetaProperties, immutableProperties.ScrubData(), mutableMetaProperties, mutableProperties.ScrubData()), false}, + {"+ve", fields{commonTransactionRequest, testFromID.AsString(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, NewMessage(fromAccAddress, testFromID, immutableMetaProperties, immutableProperties.ScrubData(), mutableMetaProperties, mutableProperties.ScrubData()), false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, - ImmutableProperties: tt.fields.ImmutableProperties, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, + ImmutableProperties: tt.fields.ImmutableProperties, + MutableMetaProperties: tt.fields.MutableMetaProperties, + MutableProperties: tt.fields.MutableProperties, } got, err := transactionRequest.MakeMsg() if (err != nil) != tt.wantErr { @@ -257,65 +207,31 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { } } -func Test_transactionRequest_RegisterCodec(t *testing.T) { - type fields struct { - BaseReq rest.BaseReq - FromID string - ImmutableMetaProperties string - ImmutableProperties string - MutableMetaProperties string - MutableProperties string - } - type args struct { - legacyAmino *codec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{testBaseRequest, testFromID.AsString(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, args{codec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - tr := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, - ImmutableProperties: tt.fields.ImmutableProperties, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, - } - tr.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - func Test_transactionRequest_Validate(t *testing.T) { type fields struct { - BaseReq rest.BaseReq - FromID string - ImmutableMetaProperties string - ImmutableProperties string - MutableMetaProperties string - MutableProperties string + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + ImmutableMetaProperties string + ImmutableProperties string + MutableMetaProperties string + MutableProperties string } tests := []struct { name string fields fields wantErr bool }{ - {"+ve", fields{testBaseRequest, testFromID.AsString(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, false}, + {"+ve", fields{commonTransactionRequest, testFromID.AsString(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, - ImmutableProperties: tt.fields.ImmutableProperties, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, + ImmutableProperties: tt.fields.ImmutableProperties, + MutableMetaProperties: tt.fields.MutableMetaProperties, + MutableProperties: tt.fields.MutableProperties, } if err := transactionRequest.Validate(); (err != nil) != tt.wantErr { t.Errorf("ValidateBasic() error = %v, wantErr %v", err, tt.wantErr) diff --git a/x/orders/transactions/define/transaction_response.go b/x/orders/transactions/define/transaction_response.go index 967e6fe64..f6ca39134 100644 --- a/x/orders/transactions/define/transaction_response.go +++ b/x/orders/transactions/define/transaction_response.go @@ -4,11 +4,10 @@ package define import ( + "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" sdkTypes "github.com/cosmos/cosmos-sdk/types" - - "github.com/AssetMantle/modules/helpers" ) var _ helpers.TransactionResponse = (*TransactionResponse)(nil) diff --git a/x/orders/transactions/deputize/message.go b/x/orders/transactions/deputize/message.go index ca63920d8..c139975eb 100644 --- a/x/orders/transactions/deputize/message.go +++ b/x/orders/transactions/deputize/message.go @@ -4,28 +4,17 @@ package deputize import ( - codecUtilities "github.com/AssetMantle/schema/codec/utilities" + "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" "github.com/AssetMantle/schema/lists" baseLists "github.com/AssetMantle/schema/lists/base" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/types" sdkTypes "github.com/cosmos/cosmos-sdk/types" - - "github.com/AssetMantle/modules/helpers" ) var _ helpers.Message = (*Message)(nil) -func (message *Message) Type() string { return Transaction.GetName() } -func (message *Message) GetFromAddress() sdkTypes.AccAddress { - from, err := sdkTypes.AccAddressFromBech32(message.From) - if err != nil { - panic(err) - } - return from -} func (message *Message) ValidateBasic() error { if _, err := sdkTypes.AccAddressFromBech32(message.From); err != nil { return err @@ -51,21 +40,10 @@ func (message *Message) GetSigners() []sdkTypes.AccAddress { } return []sdkTypes.AccAddress{from} } -func (*Message) RegisterLegacyAminoCodec(legacyAmino *codec.LegacyAmino) { - codecUtilities.RegisterModuleConcrete(legacyAmino, Message{}) -} func (message *Message) RegisterInterface(interfaceRegistry types.InterfaceRegistry) { interfaceRegistry.RegisterImplementations((*sdkTypes.Msg)(nil), message) } -func messageFromInterface(msg sdkTypes.Msg) *Message { - switch value := msg.(type) { - case *Message: - return value - default: - return &Message{} - } -} func messagePrototype() helpers.Message { return &Message{} } diff --git a/x/orders/transactions/deputize/message_test.go b/x/orders/transactions/deputize/message_test.go index 71416a428..3498654ba 100644 --- a/x/orders/transactions/deputize/message_test.go +++ b/x/orders/transactions/deputize/message_test.go @@ -12,7 +12,6 @@ import ( "github.com/AssetMantle/schema/lists/base" baseProperties "github.com/AssetMantle/schema/properties/base" baseQualified "github.com/AssetMantle/schema/qualified/base" - "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" @@ -56,27 +55,6 @@ func CreateTestInputForMessage(t *testing.T) (*baseIDs.IdentityID, *baseIDs.Iden return testFromID.(*baseIDs.IdentityID), testToID.(*baseIDs.IdentityID), testClassificationID.(*baseIDs.ClassificationID), fromAccAddress, maintainedProperties.(*base.PropertyList), testMessage } -func Test_messageFromInterface(t *testing.T) { - testFromID, testToID, testClassificationID, fromAccAddress, maintainedProperties, testMessage := CreateTestInputForMessage(t) - type args struct { - msg sdkTypes.Msg - } - tests := []struct { - name string - args args - want *Message - }{ - {"+ve", args{testMessage}, &Message{fromAccAddress.String(), testFromID, testToID, testClassificationID, maintainedProperties, true, true, true, true, true}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := messageFromInterface(tt.args.msg); !reflect.DeepEqual(got, tt.want) { - t.Errorf("messageFromInterface() = %v, want %v", got, tt.want) - } - }) - } -} - func Test_messagePrototype(t *testing.T) { tests := []struct { name string @@ -124,69 +102,6 @@ func Test_message_GetSigners(t *testing.T) { } } -func Test_message_RegisterCodec(t *testing.T) { - testFromID, testToID, testClassificationID, fromAccAddress, maintainedProperties, _ := CreateTestInputForMessage(t) - - type args struct { - legacyAmino *codec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{fromAccAddress.String(), testFromID, testToID, testClassificationID, maintainedProperties, true, true, true, true, true}, args{codec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - me := &Message{ - tt.fields.From, - tt.fields.FromID, - tt.fields.ToID, - tt.fields.ClassificationID, - tt.fields.MaintainedProperties, - tt.fields.CanMakeOrder, - tt.fields.CanCancelOrder, - tt.fields.CanAddMaintainer, - tt.fields.CanRemoveMaintainer, - tt.fields.CanMutateMaintainer, - } - me.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - -func Test_message_Type(t *testing.T) { - testFromID, testToID, testClassificationID, fromAccAddress, maintainedProperties, _ := CreateTestInputForMessage(t) - - tests := []struct { - name string - fields fields - want string - }{ - {"+ve", fields{fromAccAddress.String(), testFromID, testToID, testClassificationID, maintainedProperties, true, true, true, true, true}, Transaction.GetName()}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - message := &Message{ - tt.fields.From, - tt.fields.FromID, - tt.fields.ToID, - tt.fields.ClassificationID, - tt.fields.MaintainedProperties, - tt.fields.CanMakeOrder, - tt.fields.CanCancelOrder, - tt.fields.CanAddMaintainer, - tt.fields.CanRemoveMaintainer, - tt.fields.CanMutateMaintainer, - } - if got := message.Type(); got != tt.want { - t.Errorf("Type() = %v, want %v", got, tt.want) - } - }) - } -} - func Test_message_ValidateBasic(t *testing.T) { testFromID, testToID, testClassificationID, fromAccAddress, maintainedProperties, _ := CreateTestInputForMessage(t) diff --git a/x/orders/transactions/deputize/service.pb.go b/x/orders/transactions/deputize/service.pb.go index 718ab3c73..95236e57f 100644 --- a/x/orders/transactions/deputize/service.pb.go +++ b/x/orders/transactions/deputize/service.pb.go @@ -6,9 +6,9 @@ package deputize import ( context "context" fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types/msgservice" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" - _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -31,30 +31,30 @@ func init() { } var fileDescriptor_7f61c89944722a3a = []byte{ - // 365 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x92, 0xb1, 0x4a, 0xc3, 0x40, - 0x18, 0x80, 0x9b, 0x14, 0x3a, 0x04, 0xa7, 0x2e, 0x62, 0x90, 0x08, 0x7d, 0x80, 0x3b, 0xa8, 0xa0, - 0x70, 0xa2, 0xd8, 0x52, 0xa8, 0xcb, 0xd1, 0xa2, 0x1d, 0x82, 0x04, 0xe4, 0x9a, 0x1c, 0x31, 0x90, - 0xdc, 0x85, 0xdc, 0x55, 0x8a, 0xa3, 0xbb, 0x20, 0xf8, 0x06, 0x8e, 0x2e, 0x8e, 0xbe, 0x82, 0x38, - 0x15, 0x5c, 0x1c, 0x25, 0x75, 0xf2, 0x29, 0xc4, 0xde, 0x05, 0xaf, 0x63, 0xb3, 0x1e, 0xf9, 0x3e, - 0xbe, 0xff, 0xcf, 0xef, 0x9c, 0xf6, 0x84, 0xa0, 0x12, 0x13, 0x26, 0x53, 0x0a, 0x33, 0x1e, 0xcd, - 0x52, 0x2a, 0xe0, 0x1c, 0xf2, 0x22, 0xa2, 0x85, 0x80, 0xb2, 0x20, 0x4c, 0x90, 0x50, 0x26, 0x9c, - 0x09, 0x18, 0xd1, 0x7c, 0x26, 0x93, 0x5b, 0x0a, 0x05, 0x2d, 0x6e, 0x92, 0x90, 0x82, 0xbc, 0xe0, - 0x92, 0xb7, 0xbb, 0x86, 0x01, 0x68, 0x03, 0x98, 0x03, 0x65, 0x00, 0xa6, 0x01, 0x54, 0x06, 0x77, - 0x37, 0xe6, 0x3c, 0x4e, 0x29, 0x24, 0x79, 0x02, 0x09, 0x63, 0x5c, 0x12, 0xf5, 0xc1, 0xca, 0xe8, - 0xd6, 0x69, 0xca, 0xa8, 0x10, 0x24, 0xd6, 0x4d, 0x2e, 0xae, 0x61, 0x30, 0x5e, 0xaf, 0x0a, 0x2a, - 0x72, 0xce, 0x84, 0xd6, 0x75, 0x5f, 0x2d, 0xa7, 0x89, 0x45, 0xdc, 0x7e, 0xb1, 0x9c, 0xd6, 0x19, - 0x61, 0x51, 0x4a, 0xdb, 0x47, 0x60, 0xf3, 0xb1, 0x01, 0x56, 0x91, 0xee, 0xb0, 0x0e, 0x3c, 0xf9, - 0x7f, 0x3d, 0xd7, 0x79, 0x9d, 0xbd, 0xbb, 0x8f, 0xef, 0x47, 0x7b, 0xa7, 0xb3, 0x0d, 0x33, 0x35, - 0xab, 0x9e, 0xb0, 0x82, 0xfa, 0xf7, 0xcd, 0xb7, 0xd2, 0xb3, 0x16, 0xa5, 0x67, 0x7d, 0x95, 0x9e, - 0xf5, 0xb0, 0xf4, 0x1a, 0x8b, 0xa5, 0xd7, 0xf8, 0x5c, 0x7a, 0x0d, 0xe7, 0x20, 0xe4, 0x59, 0x8d, - 0x8e, 0xfe, 0xd6, 0x85, 0xfa, 0xfd, 0xe3, 0xbf, 0xd5, 0x8c, 0xad, 0xcb, 0xe3, 0x38, 0x91, 0xd7, - 0xb3, 0x29, 0x08, 0x79, 0x06, 0x37, 0x5f, 0xfb, 0x93, 0xdd, 0xea, 0x61, 0x7f, 0x34, 0x19, 0x3c, - 0xdb, 0x6b, 0x87, 0x84, 0x75, 0x8c, 0x0f, 0x46, 0x2a, 0x66, 0x62, 0xc6, 0x0c, 0x34, 0xfd, 0xbe, - 0x06, 0x05, 0x1a, 0x0a, 0xfc, 0x40, 0x41, 0x81, 0x09, 0x05, 0x15, 0x54, 0xda, 0x27, 0x9b, 0x43, - 0xc1, 0x70, 0xdc, 0xc7, 0x54, 0x92, 0x88, 0x48, 0xf2, 0x63, 0x1f, 0x1a, 0x02, 0x84, 0xb4, 0x01, - 0x21, 0x1f, 0x21, 0xe5, 0x40, 0xc8, 0x94, 0x20, 0x54, 0x59, 0xa6, 0xad, 0xd5, 0x41, 0xed, 0xff, - 0x06, 0x00, 0x00, 0xff, 0xff, 0x45, 0x5b, 0xa0, 0x3b, 0x77, 0x03, 0x00, 0x00, + // 359 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x92, 0x31, 0x4b, 0xf3, 0x40, + 0x18, 0x80, 0x73, 0x29, 0x5f, 0x87, 0xf0, 0x4d, 0x5d, 0x3e, 0xc8, 0x90, 0xe1, 0x1b, 0xbf, 0xe1, + 0x8e, 0xaf, 0x82, 0xc2, 0x89, 0x62, 0x4b, 0xa1, 0x2e, 0x47, 0x8b, 0x76, 0x08, 0x12, 0x90, 0x6b, + 0x72, 0xc4, 0x40, 0x93, 0x2b, 0x79, 0xaf, 0xa5, 0x38, 0xf9, 0x07, 0x84, 0xfe, 0x03, 0xc1, 0xd1, + 0xc9, 0x9f, 0x21, 0x4e, 0x1d, 0x1d, 0x25, 0x1d, 0x04, 0x7f, 0x85, 0xd4, 0xbb, 0xe2, 0x75, 0x6c, + 0xa6, 0xc0, 0x0b, 0xcf, 0x93, 0x27, 0x6f, 0x5e, 0xef, 0xac, 0x03, 0x20, 0x14, 0xe3, 0x85, 0x9a, + 0x08, 0x92, 0xcb, 0x64, 0x36, 0x11, 0x40, 0x16, 0x44, 0x96, 0x89, 0x28, 0x81, 0xa8, 0x92, 0x17, + 0xc0, 0x63, 0x95, 0xc9, 0x02, 0x48, 0x22, 0xa6, 0x33, 0x95, 0xdd, 0x0a, 0x02, 0xa2, 0x9c, 0x67, + 0xb1, 0xc0, 0xd3, 0x52, 0x2a, 0xd9, 0x6a, 0x5b, 0x06, 0x6c, 0x0c, 0x78, 0x81, 0xb5, 0x01, 0xdb, + 0x06, 0xbc, 0x35, 0xf8, 0x7f, 0x62, 0x09, 0xb9, 0x04, 0x92, 0x43, 0x4a, 0xe6, 0xff, 0x37, 0x0f, + 0x2d, 0xf3, 0xeb, 0xe4, 0xe4, 0x02, 0x80, 0xa7, 0x26, 0xc7, 0x67, 0x35, 0x0c, 0xd6, 0xf4, 0xba, + 0x14, 0x30, 0x95, 0x05, 0x18, 0x5d, 0xfb, 0x01, 0x79, 0x0d, 0x06, 0x69, 0x6b, 0x89, 0xbc, 0xe6, + 0x39, 0x2f, 0x92, 0x89, 0x68, 0x1d, 0xe3, 0xfd, 0xbf, 0x18, 0x33, 0x1d, 0xe9, 0xf7, 0xeb, 0xc0, + 0xa3, 0x9f, 0xe9, 0x85, 0xc9, 0xfb, 0xeb, 0xf8, 0xbf, 0xee, 0x3e, 0x9e, 0xff, 0xa1, 0xee, 0x7d, + 0xe3, 0xa5, 0x0a, 0xd0, 0xaa, 0x0a, 0xd0, 0x7b, 0x15, 0xa0, 0xe5, 0x3a, 0x70, 0x56, 0xeb, 0xc0, + 0x79, 0x5b, 0x07, 0x8e, 0x77, 0x18, 0xcb, 0xbc, 0xc6, 0xfb, 0xba, 0xbf, 0x2f, 0xf5, 0x1f, 0x1e, + 0x6e, 0x56, 0x30, 0x44, 0x57, 0x27, 0x69, 0xa6, 0x6e, 0x66, 0x63, 0x1c, 0xcb, 0x9c, 0xec, 0xbf, + 0xde, 0x47, 0xb7, 0xd9, 0x61, 0xe1, 0x60, 0xd4, 0x7b, 0x72, 0x77, 0x6e, 0x85, 0x99, 0x98, 0x10, + 0x0f, 0x74, 0xcc, 0xc8, 0x8e, 0xe9, 0x19, 0xfa, 0x75, 0x07, 0x8a, 0x0c, 0x14, 0x85, 0x91, 0x86, + 0x22, 0x1b, 0x8a, 0xb6, 0x50, 0xe5, 0x9e, 0xee, 0x0f, 0x45, 0xfd, 0x61, 0x97, 0x09, 0xc5, 0x13, + 0xae, 0xf8, 0xa7, 0x7b, 0x64, 0x09, 0x28, 0x35, 0x06, 0x4a, 0x43, 0x4a, 0xb5, 0x83, 0x52, 0x5b, + 0x42, 0xe9, 0xd6, 0x32, 0x6e, 0x7e, 0x1f, 0xce, 0xc1, 0x57, 0x00, 0x00, 0x00, 0xff, 0xff, 0xa7, + 0x74, 0x1a, 0xbd, 0x5a, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/orders/transactions/deputize/service.pb.gw.go b/x/orders/transactions/deputize/service.pb.gw.go deleted file mode 100644 index 3c2cfa9e9..000000000 --- a/x/orders/transactions/deputize/service.pb.gw.go +++ /dev/null @@ -1,171 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: AssetMantle/modules/x/orders/transactions/deputize/service.proto - -/* -Package deputize is a reverse proxy. - -It translates gRPC into RESTful JSON APIs. -*/ -package deputize - -import ( - "context" - "io" - "net/http" - - "github.com/golang/protobuf/descriptor" - "github.com/golang/protobuf/proto" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/grpc-ecosystem/grpc-gateway/utilities" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/status" -) - -// Suppress "imported and not used" errors -var _ codes.Code -var _ io.Reader -var _ status.Status -var _ = runtime.String -var _ = utilities.NewDoubleArray -var _ = descriptor.ForMessage -var _ = metadata.Join - -var ( - filter_Msg_Handle_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - -func request_Msg_Handle_0(ctx context.Context, marshaler runtime.Marshaler, client MsgClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq Message - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.Handle(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Msg_Handle_0(ctx context.Context, marshaler runtime.Marshaler, server MsgServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq Message - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.Handle(ctx, &protoReq) - return msg, metadata, err - -} - -// RegisterMsgHandlerServer registers the http handlers for service Msg to "mux". -// UnaryRPC :call MsgServer directly. -// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterMsgHandlerFromEndpoint instead. -func RegisterMsgHandlerServer(ctx context.Context, mux *runtime.ServeMux, server MsgServer) error { - - mux.Handle("POST", pattern_Msg_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Msg_Handle_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Msg_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -// RegisterMsgHandlerFromEndpoint is same as RegisterMsgHandler but -// automatically dials to "endpoint" and closes the connection when "ctx" gets done. -func RegisterMsgHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.Dial(endpoint, opts...) - if err != nil { - return err - } - defer func() { - if err != nil { - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - return - } - go func() { - <-ctx.Done() - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - }() - }() - - return RegisterMsgHandler(ctx, mux, conn) -} - -// RegisterMsgHandler registers the http handlers for service Msg to "mux". -// The handlers forward requests to the grpc endpoint over "conn". -func RegisterMsgHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { - return RegisterMsgHandlerClient(ctx, mux, NewMsgClient(conn)) -} - -// RegisterMsgHandlerClient registers the http handlers for service Msg -// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "MsgClient". -// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "MsgClient" -// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "MsgClient" to call the correct interceptors. -func RegisterMsgHandlerClient(ctx context.Context, mux *runtime.ServeMux, client MsgClient) error { - - mux.Handle("POST", pattern_Msg_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Msg_Handle_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Msg_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -var ( - pattern_Msg_Handle_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"mantle", "orders", "deputize"}, "", runtime.AssumeColonVerbOpt(false))) -) - -var ( - forward_Msg_Handle_0 = runtime.ForwardResponseMessage -) diff --git a/x/orders/transactions/deputize/transaction.go b/x/orders/transactions/deputize/transaction.go index ddae6b9fd..bf9c1c956 100644 --- a/x/orders/transactions/deputize/transaction.go +++ b/x/orders/transactions/deputize/transaction.go @@ -4,22 +4,14 @@ package deputize import ( - "context" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "google.golang.org/grpc" - "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/helpers/constants" - "github.com/AssetMantle/modules/utilities/name" + "google.golang.org/grpc" ) -type dummy struct{} - var Transaction = baseHelpers.NewTransaction( - name.GetPackageName(dummy{}), + _Msg_serviceDesc.ServiceName, "", "", @@ -30,9 +22,6 @@ var Transaction = baseHelpers.NewTransaction( func(server grpc.ServiceRegistrar, keeper helpers.TransactionKeeper) { RegisterMsgServer(server, keeper.(transactionKeeper)) }, - func(clientCtx client.Context, mux *runtime.ServeMux) error { - return RegisterMsgHandlerClient(context.Background(), mux, NewMsgClient(clientCtx)) - }, constants.FromIdentityID, constants.ToIdentityID, diff --git a/x/orders/transactions/deputize/transaction_keeper.go b/x/orders/transactions/deputize/transaction_keeper.go index 4ec96e902..02a013a1b 100644 --- a/x/orders/transactions/deputize/transaction_keeper.go +++ b/x/orders/transactions/deputize/transaction_keeper.go @@ -5,7 +5,6 @@ package deputize import ( "context" - "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/x/identities/auxiliaries/authenticate" "github.com/AssetMantle/modules/x/maintainers/auxiliaries/deputize" @@ -26,7 +25,7 @@ func (transactionKeeper transactionKeeper) Transact(context context.Context, mes } func (transactionKeeper transactionKeeper) Handle(context context.Context, message *Message) (*TransactionResponse, error) { - fromAddress := message.GetFromAddress() + fromAddress := message.GetSigners()[0] if _, err := transactionKeeper.authenticateAuxiliary.GetKeeper().Help(context, authenticate.NewAuxiliaryRequest(fromAddress, message.FromID)); err != nil { return nil, err diff --git a/x/orders/transactions/deputize/transaction_request.go b/x/orders/transactions/deputize/transaction_request.go index e784f4f25..a0233718a 100644 --- a/x/orders/transactions/deputize/transaction_request.go +++ b/x/orders/transactions/deputize/transaction_request.go @@ -5,31 +5,29 @@ package deputize import ( "encoding/json" - "github.com/AssetMantle/modules/utilities/rest" - - codecUtilities "github.com/AssetMantle/schema/codec/utilities" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" "github.com/AssetMantle/schema/lists/base" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" + "io" + "net/http" "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/helpers/constants" ) type transactionRequest struct { - BaseReq rest.BaseReq `json:"baseReq"` - FromID string `json:"fromID"` - ToID string `json:"toID"` - ClassificationID string `json:"classificationID"` - MaintainedProperties string `json:"maintainedProperties"` - CanMakeOrder bool `json:"canMakeOrder"` - CanCancelOrder bool `json:"canCancelOrder"` - CanAddMaintainer bool `json:"canAddMaintainer"` - CanRemoveMaintainer bool `json:"canRemoveMaintainer"` - CanMutateMaintainer bool `json:"canMutateMaintainer"` + helpers.CommonTransactionRequest `json:"commonTransactionRequest"` + FromID string `json:"fromID"` + ToID string `json:"toID"` + ClassificationID string `json:"classificationID"` + MaintainedProperties string `json:"maintainedProperties"` + CanMakeOrder bool `json:"canMakeOrder"` + CanCancelOrder bool `json:"canCancelOrder"` + CanAddMaintainer bool `json:"canAddMaintainer"` + CanRemoveMaintainer bool `json:"canRemoveMaintainer"` + CanMutateMaintainer bool `json:"canMutateMaintainer"` } var _ helpers.TransactionRequest = (*transactionRequest)(nil) @@ -55,7 +53,7 @@ func (transactionRequest transactionRequest) Validate() error { } func (transactionRequest transactionRequest) FromCLI(cliCommand helpers.CLICommand, context client.Context) (helpers.TransactionRequest, error) { return newTransactionRequest( - cliCommand.ReadBaseReq(context), + cliCommand.ReadCommonTransactionRequest(context), cliCommand.ReadString(constants.FromIdentityID), cliCommand.ReadString(constants.ToIdentityID), cliCommand.ReadString(constants.ClassificationID), @@ -67,18 +65,23 @@ func (transactionRequest transactionRequest) FromCLI(cliCommand helpers.CLIComma cliCommand.ReadBool(constants.CanMutateMaintainer), ), nil } -func (transactionRequest transactionRequest) FromJSON(rawMessage json.RawMessage) (helpers.TransactionRequest, error) { - if err := json.Unmarshal(rawMessage, &transactionRequest); err != nil { +func (transactionRequest transactionRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.TransactionRequest, error) { + body, err := io.ReadAll(httpRequest.Body) + if err != nil { + return nil, err + } + + if err := json.Unmarshal(body, &transactionRequest); err != nil { return nil, err } return transactionRequest, nil } -func (transactionRequest transactionRequest) GetBaseReq() rest.BaseReq { - return transactionRequest.BaseReq +func (transactionRequest transactionRequest) GetCommonTransactionRequest() helpers.CommonTransactionRequest { + return transactionRequest.CommonTransactionRequest } func (transactionRequest transactionRequest) MakeMsg() (sdkTypes.Msg, error) { - from, err := sdkTypes.AccAddressFromBech32(transactionRequest.GetBaseReq().From) + from, err := sdkTypes.AccAddressFromBech32(transactionRequest.GetCommonTransactionRequest().GetFrom()) if err != nil { return nil, err } @@ -116,23 +119,20 @@ func (transactionRequest transactionRequest) MakeMsg() (sdkTypes.Msg, error) { transactionRequest.CanMutateMaintainer, ), nil } -func (transactionRequest) RegisterLegacyAminoCodec(legacyAmino *codec.LegacyAmino) { - codecUtilities.RegisterModuleConcrete(legacyAmino, transactionRequest{}) -} func requestPrototype() helpers.TransactionRequest { return transactionRequest{} } -func newTransactionRequest(baseReq rest.BaseReq, fromID string, toID string, classificationID string, maintainedProperties string, canMakeOrder bool, canCancelOrder bool, canAddMaintainer bool, canRemoveMaintainer bool, canMutateMaintainer bool) helpers.TransactionRequest { +func newTransactionRequest(commonTransactionRequest helpers.CommonTransactionRequest, fromID string, toID string, classificationID string, maintainedProperties string, canMakeOrder bool, canCancelOrder bool, canAddMaintainer bool, canRemoveMaintainer bool, canMutateMaintainer bool) helpers.TransactionRequest { return transactionRequest{ - BaseReq: baseReq, - FromID: fromID, - ToID: toID, - ClassificationID: classificationID, - MaintainedProperties: maintainedProperties, - CanMakeOrder: canMakeOrder, - CanCancelOrder: canCancelOrder, - CanAddMaintainer: canAddMaintainer, - CanRemoveMaintainer: canRemoveMaintainer, - CanMutateMaintainer: canMutateMaintainer, + CommonTransactionRequest: commonTransactionRequest, + FromID: fromID, + ToID: toID, + ClassificationID: classificationID, + MaintainedProperties: maintainedProperties, + CanMakeOrder: canMakeOrder, + CanCancelOrder: canCancelOrder, + CanAddMaintainer: canAddMaintainer, + CanRemoveMaintainer: canRemoveMaintainer, + CanMutateMaintainer: canMutateMaintainer, } } diff --git a/x/orders/transactions/deputize/transaction_request_test.go b/x/orders/transactions/deputize/transaction_request_test.go index eebcbce60..98943ed06 100644 --- a/x/orders/transactions/deputize/transaction_request_test.go +++ b/x/orders/transactions/deputize/transaction_request_test.go @@ -4,9 +4,7 @@ package deputize import ( - "encoding/json" "fmt" - "github.com/AssetMantle/modules/utilities/rest" "reflect" "testing" @@ -16,15 +14,12 @@ import ( baseProperties "github.com/AssetMantle/schema/properties/base" baseQualified "github.com/AssetMantle/schema/qualified/base" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/types" - "github.com/spf13/viper" - "github.com/stretchr/testify/require" - "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/helpers/constants" + "github.com/spf13/viper" ) var ( @@ -37,32 +32,32 @@ var ( testFromID = baseIDs.NewIdentityID(testClassificationID, immutables) maintainedPropertyString = "maintainedProperty:S|maintainedProperty" maintainedProperties, _ = base.NewPropertyList().FromMetaPropertiesString(maintainedPropertyString) - testBaseRequest = rest.BaseReq{From: fromAddress, ChainID: "test", Fees: types.NewCoins()} + commonTransactionRequest = helpers.PrototypeCommonTransactionRequest() ) func Test_newTransactionRequest(t *testing.T) { type args struct { - baseReq rest.BaseReq - fromID string - toID string - classificationID string - maintainedProperties string - CanMakeOrder bool `json:"canMakeOrder"` - CanCancelOrder bool `json:"canCancelOrder"` - CanAddMaintainer bool `json:"canAddMaintainer"` - CanRemoveMaintainer bool `json:"canRemoveMaintainer"` - CanMutateMaintainer bool `json:"canMutateMaintainer"` + commonTransactionRequest helpers.CommonTransactionRequest + fromID string + toID string + classificationID string + maintainedProperties string + CanMakeOrder bool `json:"canMakeOrder"` + CanCancelOrder bool `json:"canCancelOrder"` + CanAddMaintainer bool `json:"canAddMaintainer"` + CanRemoveMaintainer bool `json:"canRemoveMaintainer"` + CanMutateMaintainer bool `json:"canMutateMaintainer"` } tests := []struct { name string args args want helpers.TransactionRequest }{ - {"+ve", args{testBaseRequest, testFromID.AsString(), testFromID.AsString(), testClassificationID.AsString(), maintainedPropertyString, true, true, true, true, true}, newTransactionRequest(testBaseRequest, testFromID.AsString(), testFromID.AsString(), testClassificationID.AsString(), maintainedPropertyString, true, true, true, true, true)}, + {"+ve", args{commonTransactionRequest, testFromID.AsString(), testFromID.AsString(), testClassificationID.AsString(), maintainedPropertyString, true, true, true, true, true}, newTransactionRequest(commonTransactionRequest, testFromID.AsString(), testFromID.AsString(), testClassificationID.AsString(), maintainedPropertyString, true, true, true, true, true)}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - if got := newTransactionRequest(tt.args.baseReq, tt.args.fromID, tt.args.toID, tt.args.classificationID, tt.args.maintainedProperties, tt.args.CanMakeOrder, tt.args.CanCancelOrder, tt.args.CanAddMaintainer, tt.args.CanRemoveMaintainer, tt.args.CanMutateMaintainer); !reflect.DeepEqual(got, tt.want) { + if got := newTransactionRequest(tt.args.commonTransactionRequest, tt.args.fromID, tt.args.toID, tt.args.classificationID, tt.args.maintainedProperties, tt.args.CanMakeOrder, tt.args.CanCancelOrder, tt.args.CanAddMaintainer, tt.args.CanRemoveMaintainer, tt.args.CanMutateMaintainer); !reflect.DeepEqual(got, tt.want) { t.Errorf("newTransactionRequest() = %v, want %v", got, tt.want) } }) @@ -99,16 +94,16 @@ func Test_transactionRequest_FromCLI(t *testing.T) { viper.Set(constants.CanRemoveMaintainer.GetName(), true) viper.Set(constants.CanMutateMaintainer.GetName(), true) type fields struct { - BaseReq rest.BaseReq - FromID string - ToID string - ClassificationID string - MaintainedProperties string - CanMakeOrder bool `json:"canMakeOrder"` - CanCancelOrder bool `json:"canCancelOrder"` - CanAddMaintainer bool `json:"canAddMaintainer"` - CanRemoveMaintainer bool `json:"canRemoveMaintainer"` - CanMutateMaintainer bool `json:"canMutateMaintainer"` + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + ToID string + ClassificationID string + MaintainedProperties string + CanMakeOrder bool `json:"canMakeOrder"` + CanCancelOrder bool `json:"canCancelOrder"` + CanAddMaintainer bool `json:"canAddMaintainer"` + CanRemoveMaintainer bool `json:"canRemoveMaintainer"` + CanMutateMaintainer bool `json:"canMutateMaintainer"` } type args struct { cliCommand helpers.CLICommand @@ -121,21 +116,21 @@ func Test_transactionRequest_FromCLI(t *testing.T) { want helpers.TransactionRequest wantErr bool }{ - {"+ve", fields{testBaseRequest, testFromID.AsString(), testFromID.AsString(), testClassificationID.AsString(), maintainedPropertyString, true, true, true, true, true}, args{cliCommand, client.Context{}.WithCodec(baseHelpers.CodecPrototype())}, newTransactionRequest(testBaseRequest, testFromID.AsString(), testFromID.AsString(), testClassificationID.AsString(), maintainedPropertyString, true, true, true, true, true), false}, + {"+ve", fields{commonTransactionRequest, testFromID.AsString(), testFromID.AsString(), testClassificationID.AsString(), maintainedPropertyString, true, true, true, true, true}, args{cliCommand, client.Context{}.WithCodec(baseHelpers.CodecPrototype())}, newTransactionRequest(commonTransactionRequest, testFromID.AsString(), testFromID.AsString(), testClassificationID.AsString(), maintainedPropertyString, true, true, true, true, true), false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - ToID: tt.fields.ToID, - ClassificationID: tt.fields.ClassificationID, - MaintainedProperties: tt.fields.MaintainedProperties, - CanMakeOrder: tt.fields.CanMakeOrder, - CanCancelOrder: tt.fields.CanCancelOrder, - CanAddMaintainer: tt.fields.CanAddMaintainer, - CanRemoveMaintainer: tt.fields.CanRemoveMaintainer, - CanMutateMaintainer: tt.fields.CanMutateMaintainer, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + ToID: tt.fields.ToID, + ClassificationID: tt.fields.ClassificationID, + MaintainedProperties: tt.fields.MaintainedProperties, + CanMakeOrder: tt.fields.CanMakeOrder, + CanCancelOrder: tt.fields.CanCancelOrder, + CanAddMaintainer: tt.fields.CanAddMaintainer, + CanRemoveMaintainer: tt.fields.CanRemoveMaintainer, + CanMutateMaintainer: tt.fields.CanMutateMaintainer, } got, err := transactionRequest.FromCLI(tt.args.cliCommand, tt.args.context) if (err != nil) != tt.wantErr { @@ -149,95 +144,42 @@ func Test_transactionRequest_FromCLI(t *testing.T) { } } -func Test_transactionRequest_FromJSON(t *testing.T) { - jsonMessage, err := json.Marshal(newTransactionRequest(testBaseRequest, testFromID.AsString(), testFromID.AsString(), testClassificationID.AsString(), maintainedPropertyString, true, true, true, true, true)) - require.NoError(t, err) - type fields struct { - BaseReq rest.BaseReq - FromID string - ToID string - ClassificationID string - MaintainedProperties string - CanMakeOrder bool `json:"canMakeOrder"` - CanCancelOrder bool `json:"canCancelOrder"` - CanAddMaintainer bool `json:"canAddMaintainer"` - CanRemoveMaintainer bool `json:"canRemoveMaintainer"` - CanMutateMaintainer bool `json:"canMutateMaintainer"` - } - type args struct { - rawMessage json.RawMessage - } - tests := []struct { - name string - fields fields - args args - want helpers.TransactionRequest - wantErr bool - }{ - {"+ve", fields{testBaseRequest, testFromID.AsString(), testFromID.AsString(), testClassificationID.AsString(), maintainedPropertyString, true, true, true, true, true}, args{jsonMessage}, newTransactionRequest(testBaseRequest, testFromID.AsString(), testFromID.AsString(), testClassificationID.AsString(), maintainedPropertyString, true, true, true, true, true), false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - ToID: tt.fields.ToID, - ClassificationID: tt.fields.ClassificationID, - MaintainedProperties: tt.fields.MaintainedProperties, - CanMakeOrder: tt.fields.CanMakeOrder, - CanCancelOrder: tt.fields.CanCancelOrder, - CanAddMaintainer: tt.fields.CanAddMaintainer, - CanRemoveMaintainer: tt.fields.CanRemoveMaintainer, - CanMutateMaintainer: tt.fields.CanMutateMaintainer, - } - got, err := transactionRequest.FromJSON(tt.args.rawMessage) - if (err != nil) != tt.wantErr { - t.Errorf("FromJSON() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("FromJSON() got = %v, want %v", got, tt.want) - } - }) - } -} - func Test_transactionRequest_GetBaseReq(t *testing.T) { type fields struct { - BaseReq rest.BaseReq - FromID string - ToID string - ClassificationID string - MaintainedProperties string - CanMakeOrder bool `json:"canMakeOrder"` - CanCancelOrder bool `json:"canCancelOrder"` - CanAddMaintainer bool `json:"canAddMaintainer"` - CanRemoveMaintainer bool `json:"canRemoveMaintainer"` - CanMutateMaintainer bool `json:"canMutateMaintainer"` + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + ToID string + ClassificationID string + MaintainedProperties string + CanMakeOrder bool `json:"canMakeOrder"` + CanCancelOrder bool `json:"canCancelOrder"` + CanAddMaintainer bool `json:"canAddMaintainer"` + CanRemoveMaintainer bool `json:"canRemoveMaintainer"` + CanMutateMaintainer bool `json:"canMutateMaintainer"` } tests := []struct { name string fields fields - want rest.BaseReq + want helpers.CommonTransactionRequest }{ - {"+ve", fields{testBaseRequest, testFromID.AsString(), testFromID.AsString(), testClassificationID.AsString(), maintainedPropertyString, true, true, true, true, true}, testBaseRequest}, + {"+ve", fields{commonTransactionRequest, testFromID.AsString(), testFromID.AsString(), testClassificationID.AsString(), maintainedPropertyString, true, true, true, true, true}, commonTransactionRequest}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - ToID: tt.fields.ToID, - ClassificationID: tt.fields.ClassificationID, - MaintainedProperties: tt.fields.MaintainedProperties, - CanMakeOrder: tt.fields.CanMakeOrder, - CanCancelOrder: tt.fields.CanCancelOrder, - CanAddMaintainer: tt.fields.CanAddMaintainer, - CanRemoveMaintainer: tt.fields.CanRemoveMaintainer, - CanMutateMaintainer: tt.fields.CanMutateMaintainer, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + ToID: tt.fields.ToID, + ClassificationID: tt.fields.ClassificationID, + MaintainedProperties: tt.fields.MaintainedProperties, + CanMakeOrder: tt.fields.CanMakeOrder, + CanCancelOrder: tt.fields.CanCancelOrder, + CanAddMaintainer: tt.fields.CanAddMaintainer, + CanRemoveMaintainer: tt.fields.CanRemoveMaintainer, + CanMutateMaintainer: tt.fields.CanMutateMaintainer, } - if got := transactionRequest.GetBaseReq(); !reflect.DeepEqual(got, tt.want) { - t.Errorf("GetBaseReq() = %v, want %v", got, tt.want) + if got := transactionRequest.GetCommonTransactionRequest(); !reflect.DeepEqual(got, tt.want) { + t.Errorf("GetCommonTransactionRequest() = %v, want %v", got, tt.want) } }) } @@ -245,16 +187,16 @@ func Test_transactionRequest_GetBaseReq(t *testing.T) { func Test_transactionRequest_MakeMsg(t *testing.T) { type fields struct { - BaseReq rest.BaseReq - FromID string - ToID string - ClassificationID string - MaintainedProperties string - CanMakeOrder bool `json:"canMakeOrder"` - CanCancelOrder bool `json:"canCancelOrder"` - CanAddMaintainer bool `json:"canAddMaintainer"` - CanRemoveMaintainer bool `json:"canRemoveMaintainer"` - CanMutateMaintainer bool `json:"canMutateMaintainer"` + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + ToID string + ClassificationID string + MaintainedProperties string + CanMakeOrder bool `json:"canMakeOrder"` + CanCancelOrder bool `json:"canCancelOrder"` + CanAddMaintainer bool `json:"canAddMaintainer"` + CanRemoveMaintainer bool `json:"canRemoveMaintainer"` + CanMutateMaintainer bool `json:"canMutateMaintainer"` } tests := []struct { name string @@ -262,21 +204,21 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { want types.Msg wantErr bool }{ - {"+ve", fields{testBaseRequest, testFromID.AsString(), testFromID.AsString(), testClassificationID.AsString(), maintainedPropertyString, true, true, true, true, true}, NewMessage(fromAccAddress, testFromID, testFromID, testClassificationID, maintainedProperties, true, true, true, true, true), false}, + {"+ve", fields{commonTransactionRequest, testFromID.AsString(), testFromID.AsString(), testClassificationID.AsString(), maintainedPropertyString, true, true, true, true, true}, NewMessage(fromAccAddress, testFromID, testFromID, testClassificationID, maintainedProperties, true, true, true, true, true), false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - ToID: tt.fields.ToID, - ClassificationID: tt.fields.ClassificationID, - MaintainedProperties: tt.fields.MaintainedProperties, - CanMakeOrder: tt.fields.CanMakeOrder, - CanCancelOrder: tt.fields.CanCancelOrder, - CanAddMaintainer: tt.fields.CanAddMaintainer, - CanRemoveMaintainer: tt.fields.CanRemoveMaintainer, - CanMutateMaintainer: tt.fields.CanMutateMaintainer, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + ToID: tt.fields.ToID, + ClassificationID: tt.fields.ClassificationID, + MaintainedProperties: tt.fields.MaintainedProperties, + CanMakeOrder: tt.fields.CanMakeOrder, + CanCancelOrder: tt.fields.CanCancelOrder, + CanAddMaintainer: tt.fields.CanAddMaintainer, + CanRemoveMaintainer: tt.fields.CanRemoveMaintainer, + CanMutateMaintainer: tt.fields.CanMutateMaintainer, } got, err := transactionRequest.MakeMsg() if (err != nil) != tt.wantErr { @@ -290,81 +232,39 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { } } -func Test_transactionRequest_RegisterCodec(t *testing.T) { - type fields struct { - BaseReq rest.BaseReq - FromID string - ToID string - ClassificationID string - MaintainedProperties string - CanMakeOrder bool `json:"canMakeOrder"` - CanCancelOrder bool `json:"canCancelOrder"` - CanAddMaintainer bool `json:"canAddMaintainer"` - CanRemoveMaintainer bool `json:"canRemoveMaintainer"` - CanMutateMaintainer bool `json:"canMutateMaintainer"` - } - type args struct { - legacyAmino *codec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{testBaseRequest, testFromID.AsString(), testFromID.AsString(), testClassificationID.AsString(), maintainedPropertyString, true, true, true, true, true}, args{codec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - tr := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - ToID: tt.fields.ToID, - ClassificationID: tt.fields.ClassificationID, - MaintainedProperties: tt.fields.MaintainedProperties, - CanMakeOrder: tt.fields.CanMakeOrder, - CanCancelOrder: tt.fields.CanCancelOrder, - CanAddMaintainer: tt.fields.CanAddMaintainer, - CanRemoveMaintainer: tt.fields.CanRemoveMaintainer, - CanMutateMaintainer: tt.fields.CanMutateMaintainer, - } - tr.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - func Test_transactionRequest_Validate(t *testing.T) { type fields struct { - BaseReq rest.BaseReq - FromID string - ToID string - ClassificationID string - MaintainedProperties string - CanMakeOrder bool `json:"canMakeOrder"` - CanCancelOrder bool `json:"canCancelOrder"` - CanAddMaintainer bool `json:"canAddMaintainer"` - CanRemoveMaintainer bool `json:"canRemoveMaintainer"` - CanMutateMaintainer bool `json:"canMutateMaintainer"` + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + ToID string + ClassificationID string + MaintainedProperties string + CanMakeOrder bool `json:"canMakeOrder"` + CanCancelOrder bool `json:"canCancelOrder"` + CanAddMaintainer bool `json:"canAddMaintainer"` + CanRemoveMaintainer bool `json:"canRemoveMaintainer"` + CanMutateMaintainer bool `json:"canMutateMaintainer"` } tests := []struct { name string fields fields wantErr bool }{ - {"+ve", fields{testBaseRequest, testFromID.AsString(), testFromID.AsString(), testClassificationID.AsString(), maintainedPropertyString, true, true, true, true, true}, false}, + {"+ve", fields{commonTransactionRequest, testFromID.AsString(), testFromID.AsString(), testClassificationID.AsString(), maintainedPropertyString, true, true, true, true, true}, false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - ToID: tt.fields.ToID, - ClassificationID: tt.fields.ClassificationID, - MaintainedProperties: tt.fields.MaintainedProperties, - CanMakeOrder: tt.fields.CanMakeOrder, - CanCancelOrder: tt.fields.CanCancelOrder, - CanAddMaintainer: tt.fields.CanAddMaintainer, - CanRemoveMaintainer: tt.fields.CanRemoveMaintainer, - CanMutateMaintainer: tt.fields.CanMutateMaintainer, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + ToID: tt.fields.ToID, + ClassificationID: tt.fields.ClassificationID, + MaintainedProperties: tt.fields.MaintainedProperties, + CanMakeOrder: tt.fields.CanMakeOrder, + CanCancelOrder: tt.fields.CanCancelOrder, + CanAddMaintainer: tt.fields.CanAddMaintainer, + CanRemoveMaintainer: tt.fields.CanRemoveMaintainer, + CanMutateMaintainer: tt.fields.CanMutateMaintainer, } if err := transactionRequest.Validate(); (err != nil) != tt.wantErr { t.Errorf("ValidateBasic() error = %v, wantErr %v", err, tt.wantErr) diff --git a/x/orders/transactions/deputize/transaction_response.go b/x/orders/transactions/deputize/transaction_response.go index 8642b0b49..1af3c6455 100644 --- a/x/orders/transactions/deputize/transaction_response.go +++ b/x/orders/transactions/deputize/transaction_response.go @@ -4,9 +4,8 @@ package deputize import ( - sdkTypes "github.com/cosmos/cosmos-sdk/types" - "github.com/AssetMantle/modules/helpers" + sdkTypes "github.com/cosmos/cosmos-sdk/types" ) var _ helpers.TransactionResponse = (*TransactionResponse)(nil) diff --git a/x/orders/transactions/get/message.go b/x/orders/transactions/get/message.go index f86c06d44..b5da63ab6 100644 --- a/x/orders/transactions/get/message.go +++ b/x/orders/transactions/get/message.go @@ -4,26 +4,15 @@ package get import ( - codecUtilities "github.com/AssetMantle/schema/codec/utilities" + "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/types" sdkTypes "github.com/cosmos/cosmos-sdk/types" - - "github.com/AssetMantle/modules/helpers" ) var _ helpers.Message = (*Message)(nil) -func (message *Message) Type() string { return Transaction.GetName() } -func (message *Message) GetFromAddress() sdkTypes.AccAddress { - from, err := sdkTypes.AccAddressFromBech32(message.From) - if err != nil { - panic(err) - } - return from -} func (message *Message) ValidateBasic() error { if _, err := sdkTypes.AccAddressFromBech32(message.From); err != nil { return err @@ -46,21 +35,10 @@ func (message *Message) GetSigners() []sdkTypes.AccAddress { } return []sdkTypes.AccAddress{from} } -func (*Message) RegisterLegacyAminoCodec(legacyAmino *codec.LegacyAmino) { - codecUtilities.RegisterModuleConcrete(legacyAmino, Message{}) -} func (message *Message) RegisterInterface(interfaceRegistry types.InterfaceRegistry) { interfaceRegistry.RegisterImplementations((*sdkTypes.Msg)(nil), message) } -func messageFromInterface(msg sdkTypes.Msg) *Message { - switch value := msg.(type) { - case *Message: - return value - default: - return &Message{} - } -} func messagePrototype() helpers.Message { return &Message{} } diff --git a/x/orders/transactions/get/message_test.go b/x/orders/transactions/get/message_test.go index c29b31031..037b776b1 100644 --- a/x/orders/transactions/get/message_test.go +++ b/x/orders/transactions/get/message_test.go @@ -9,7 +9,6 @@ import ( "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/types" "github.com/AssetMantle/modules/helpers" @@ -26,26 +25,6 @@ type fields struct { OrderID *baseIDs.OrderID } -func Test_messageFromInterface(t *testing.T) { - type args struct { - msg types.Msg - } - tests := []struct { - name string - args args - want *Message - }{ - {"+ve", args{testMessage}, &Message{fromAccAddress.String(), testFromID, testOrderID}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := messageFromInterface(tt.args.msg); !reflect.DeepEqual(got, tt.want) { - t.Errorf("messageFromInterface() = %v, want %v", got, tt.want) - } - }) - } -} - func Test_messagePrototype(t *testing.T) { tests := []struct { name string @@ -85,53 +64,6 @@ func Test_message_GetSigners(t *testing.T) { } } -func Test_message_RegisterCodec(t *testing.T) { - - type args struct { - legacyAmino *codec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{fromAccAddress.String(), testFromID, takerSplit, testOrderID}, args{codec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - me := &Message{ - From: tt.fields.From, - FromID: tt.fields.FromID, - OrderID: tt.fields.OrderID, - } - me.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - -func Test_message_Type(t *testing.T) { - - tests := []struct { - name string - fields fields - want string - }{ - {"+ve", fields{fromAccAddress.String(), testFromID, takerSplit, testOrderID}, Transaction.GetName()}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - message := &Message{ - From: tt.fields.From, - FromID: tt.fields.FromID, - OrderID: tt.fields.OrderID, - } - if got := message.Type(); got != tt.want { - t.Errorf("Type() = %v, want %v", got, tt.want) - } - }) - } -} - func Test_message_ValidateBasic(t *testing.T) { tests := []struct { diff --git a/x/orders/transactions/get/service.pb.go b/x/orders/transactions/get/service.pb.go index 57cbb6888..c249d7add 100644 --- a/x/orders/transactions/get/service.pb.go +++ b/x/orders/transactions/get/service.pb.go @@ -6,9 +6,9 @@ package get import ( context "context" fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types/msgservice" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" - _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -31,30 +31,29 @@ func init() { } var fileDescriptor_643e03a23de377cc = []byte{ - // 359 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x92, 0xb1, 0x4b, 0xfb, 0x40, - 0x14, 0xc7, 0x9b, 0xfc, 0xa0, 0x43, 0xf8, 0x4d, 0xc1, 0x29, 0x48, 0x86, 0xee, 0xde, 0x61, 0x05, - 0xd1, 0x73, 0x6a, 0x96, 0x74, 0x09, 0x2d, 0xda, 0x21, 0x48, 0x40, 0xae, 0xc9, 0xe3, 0x0c, 0x24, - 0xb9, 0x92, 0x7b, 0x95, 0xce, 0xfe, 0x05, 0x82, 0xff, 0x80, 0x38, 0x89, 0x7f, 0x89, 0x38, 0x15, - 0x5c, 0x1c, 0x25, 0x75, 0x72, 0xf1, 0x5f, 0x10, 0x7b, 0x07, 0xa6, 0x63, 0xd6, 0x97, 0xef, 0xe7, - 0xe5, 0xf3, 0xde, 0x3d, 0xe7, 0x6c, 0xa4, 0x14, 0x60, 0xc4, 0x2b, 0x2c, 0x80, 0x96, 0x32, 0x5b, - 0x16, 0xa0, 0xe8, 0x8a, 0xca, 0x3a, 0x83, 0x5a, 0x51, 0xac, 0x79, 0xa5, 0x78, 0x8a, 0xb9, 0xac, - 0x14, 0x15, 0x80, 0x54, 0x41, 0x7d, 0x93, 0xa7, 0x40, 0x16, 0xb5, 0x44, 0xe9, 0x1e, 0xb4, 0x60, - 0x62, 0x60, 0xb2, 0x22, 0x1a, 0x26, 0x6d, 0x98, 0x08, 0x40, 0x6f, 0x5f, 0x48, 0x29, 0x0a, 0xa0, - 0x7c, 0x91, 0x53, 0x5e, 0x55, 0x12, 0xb9, 0xfe, 0xb6, 0x6d, 0xe6, 0x75, 0x34, 0x29, 0x41, 0x29, - 0x2e, 0x8c, 0x89, 0x37, 0xee, 0x06, 0xb7, 0x0a, 0x57, 0x35, 0xa8, 0x85, 0xac, 0x94, 0xe9, 0x34, - 0x7c, 0xb2, 0x9c, 0x7f, 0x91, 0x12, 0xee, 0x83, 0xe5, 0xf4, 0xc7, 0xbc, 0xca, 0x0a, 0x70, 0x8f, - 0x49, 0xa7, 0x39, 0x49, 0xa4, 0xd5, 0xbc, 0xa0, 0x23, 0x37, 0xfb, 0x2b, 0x9c, 0x1b, 0xa9, 0x81, - 0x77, 0xfb, 0xf6, 0x79, 0x6f, 0xef, 0x0d, 0x5c, 0x5a, 0xea, 0xe1, 0xcc, 0x48, 0x02, 0x30, 0xf8, - 0xb6, 0x5f, 0x1a, 0xdf, 0x5a, 0x37, 0xbe, 0xf5, 0xd1, 0xf8, 0xd6, 0xdd, 0xc6, 0xef, 0xad, 0x37, - 0x7e, 0xef, 0x7d, 0xe3, 0xf7, 0x9c, 0xc3, 0x54, 0x96, 0xdd, 0xfe, 0x1e, 0xfc, 0xbf, 0xd0, 0x6f, - 0x3b, 0xfd, 0x5d, 0xc3, 0xd4, 0xba, 0x3c, 0x11, 0x39, 0x5e, 0x2f, 0xe7, 0x24, 0x95, 0x25, 0xed, - 0xb4, 0xdd, 0x47, 0xbb, 0x3f, 0x8a, 0xe2, 0xc9, 0x2c, 0x7c, 0xb6, 0x77, 0x0e, 0x24, 0x32, 0x0a, - 0x31, 0x99, 0x68, 0x85, 0x59, 0x5b, 0x21, 0x04, 0x7c, 0xdd, 0xc9, 0x27, 0x26, 0x9f, 0xc4, 0x89, - 0xce, 0x27, 0xed, 0x7c, 0x12, 0x02, 0x36, 0xf6, 0x69, 0xa7, 0x7c, 0x12, 0x4e, 0x83, 0x08, 0x90, - 0x67, 0x1c, 0xf9, 0x97, 0x3d, 0x6c, 0xb1, 0x8c, 0x19, 0x98, 0xb1, 0x98, 0x31, 0x8d, 0x33, 0xd6, - 0xe6, 0x19, 0x0b, 0x01, 0xe7, 0xfd, 0xed, 0x8d, 0x1c, 0xfd, 0x04, 0x00, 0x00, 0xff, 0xff, 0x8c, - 0x8d, 0xd7, 0x68, 0x36, 0x03, 0x00, 0x00, + // 352 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x92, 0x31, 0x4b, 0xf3, 0x40, + 0x18, 0xc7, 0x93, 0xbc, 0xbc, 0x1d, 0xc2, 0x3b, 0x75, 0x79, 0x21, 0x43, 0x06, 0x47, 0xc1, 0x3b, + 0x5a, 0x41, 0xf4, 0x9c, 0x9a, 0x25, 0x5d, 0x42, 0x8b, 0x76, 0x08, 0x12, 0x90, 0x6b, 0xf2, 0x10, + 0x0b, 0x4d, 0xae, 0xe4, 0xb9, 0x96, 0x8e, 0x4e, 0xce, 0x2e, 0x7e, 0x01, 0x47, 0x27, 0x3f, 0x86, + 0x38, 0x75, 0x74, 0x94, 0x74, 0x10, 0x5c, 0xfc, 0x0a, 0x52, 0xef, 0xc0, 0xeb, 0x78, 0xd3, 0xc1, + 0xc3, 0xff, 0xf7, 0xdc, 0xef, 0xb9, 0x7b, 0xfc, 0xf3, 0x01, 0x22, 0xc8, 0x84, 0xd7, 0x72, 0x0e, + 0xb4, 0x12, 0xc5, 0x72, 0x0e, 0x48, 0xd7, 0x54, 0x34, 0x05, 0x34, 0x48, 0x65, 0xc3, 0x6b, 0xe4, + 0xb9, 0x9c, 0x89, 0x1a, 0x69, 0x09, 0x92, 0x22, 0x34, 0xab, 0x59, 0x0e, 0x64, 0xd1, 0x08, 0x29, + 0xba, 0x47, 0x06, 0x4c, 0x34, 0x4c, 0xd6, 0x44, 0xc1, 0xc4, 0x84, 0x49, 0x09, 0x32, 0xf8, 0x9f, + 0x0b, 0xac, 0x04, 0xd2, 0x0a, 0x4b, 0xba, 0xea, 0xed, 0x0e, 0xd5, 0x27, 0xb0, 0x94, 0xa8, 0x00, + 0x91, 0x97, 0x5a, 0x22, 0x18, 0xda, 0xc1, 0x46, 0xe1, 0xba, 0x01, 0x5c, 0x88, 0x1a, 0x75, 0xa7, + 0xfe, 0x83, 0xeb, 0xff, 0x49, 0xb0, 0xec, 0xde, 0xb9, 0x7e, 0x67, 0xc8, 0xeb, 0x62, 0x0e, 0xdd, + 0x13, 0x62, 0x35, 0x22, 0x49, 0x94, 0x5a, 0x10, 0x59, 0x72, 0x93, 0xdf, 0xc2, 0x85, 0x96, 0x3a, + 0x70, 0x82, 0xbf, 0xb7, 0x1f, 0xcf, 0x87, 0x6e, 0xf4, 0xe5, 0xbd, 0xb4, 0xa1, 0xbb, 0x69, 0x43, + 0xf7, 0xbd, 0x0d, 0xdd, 0xfb, 0x6d, 0xe8, 0x6c, 0xb6, 0xa1, 0xf3, 0xb6, 0x0d, 0x1d, 0xbf, 0x97, + 0x8b, 0xca, 0xee, 0xaa, 0xe8, 0xdf, 0xa5, 0xfa, 0xc3, 0xf1, 0x6e, 0xe6, 0xb1, 0x7b, 0x75, 0x5a, + 0xce, 0xe4, 0xcd, 0x72, 0x4a, 0x72, 0x51, 0x51, 0xab, 0xa7, 0x7c, 0xf4, 0x3a, 0x83, 0x24, 0x1d, + 0x4d, 0xe2, 0x27, 0x6f, 0x6f, 0x11, 0x12, 0xad, 0x90, 0x92, 0x91, 0x52, 0x98, 0x98, 0x0a, 0x31, + 0xc8, 0xd7, 0xbd, 0x7c, 0xa6, 0xf3, 0x59, 0x9a, 0xa9, 0x7c, 0x66, 0xe6, 0xb3, 0x18, 0x64, 0xeb, + 0x9d, 0x59, 0xe5, 0xb3, 0x78, 0x1c, 0x25, 0x20, 0x79, 0xc1, 0x25, 0xff, 0xf4, 0xfa, 0x06, 0xcb, + 0x98, 0x86, 0x19, 0x4b, 0x19, 0x53, 0x38, 0x63, 0x26, 0xcf, 0x58, 0x0c, 0x72, 0xda, 0xf9, 0x59, + 0x88, 0xe3, 0xef, 0x00, 0x00, 0x00, 0xff, 0xff, 0xc8, 0x64, 0x4c, 0xdb, 0x1e, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/orders/transactions/get/service.pb.gw.go b/x/orders/transactions/get/service.pb.gw.go deleted file mode 100644 index 82f66b9a4..000000000 --- a/x/orders/transactions/get/service.pb.gw.go +++ /dev/null @@ -1,171 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: AssetMantle/modules/x/orders/transactions/get/service.proto - -/* -Package get is a reverse proxy. - -It translates gRPC into RESTful JSON APIs. -*/ -package get - -import ( - "context" - "io" - "net/http" - - "github.com/golang/protobuf/descriptor" - "github.com/golang/protobuf/proto" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/grpc-ecosystem/grpc-gateway/utilities" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/status" -) - -// Suppress "imported and not used" errors -var _ codes.Code -var _ io.Reader -var _ status.Status -var _ = runtime.String -var _ = utilities.NewDoubleArray -var _ = descriptor.ForMessage -var _ = metadata.Join - -var ( - filter_Msg_Handle_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - -func request_Msg_Handle_0(ctx context.Context, marshaler runtime.Marshaler, client MsgClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq Message - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.Handle(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Msg_Handle_0(ctx context.Context, marshaler runtime.Marshaler, server MsgServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq Message - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.Handle(ctx, &protoReq) - return msg, metadata, err - -} - -// RegisterMsgHandlerServer registers the http handlers for service Msg to "mux". -// UnaryRPC :call MsgServer directly. -// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterMsgHandlerFromEndpoint instead. -func RegisterMsgHandlerServer(ctx context.Context, mux *runtime.ServeMux, server MsgServer) error { - - mux.Handle("POST", pattern_Msg_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Msg_Handle_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Msg_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -// RegisterMsgHandlerFromEndpoint is same as RegisterMsgHandler but -// automatically dials to "endpoint" and closes the connection when "ctx" gets done. -func RegisterMsgHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.Dial(endpoint, opts...) - if err != nil { - return err - } - defer func() { - if err != nil { - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - return - } - go func() { - <-ctx.Done() - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - }() - }() - - return RegisterMsgHandler(ctx, mux, conn) -} - -// RegisterMsgHandler registers the http handlers for service Msg to "mux". -// The handlers forward requests to the grpc endpoint over "conn". -func RegisterMsgHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { - return RegisterMsgHandlerClient(ctx, mux, NewMsgClient(conn)) -} - -// RegisterMsgHandlerClient registers the http handlers for service Msg -// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "MsgClient". -// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "MsgClient" -// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "MsgClient" to call the correct interceptors. -func RegisterMsgHandlerClient(ctx context.Context, mux *runtime.ServeMux, client MsgClient) error { - - mux.Handle("POST", pattern_Msg_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Msg_Handle_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Msg_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -var ( - pattern_Msg_Handle_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"mantle", "orders", "get"}, "", runtime.AssumeColonVerbOpt(false))) -) - -var ( - forward_Msg_Handle_0 = runtime.ForwardResponseMessage -) diff --git a/x/orders/transactions/get/transaction.go b/x/orders/transactions/get/transaction.go index 7ff1d9dbf..e7723e1df 100644 --- a/x/orders/transactions/get/transaction.go +++ b/x/orders/transactions/get/transaction.go @@ -4,22 +4,14 @@ package get import ( - "context" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "google.golang.org/grpc" - "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/helpers/constants" - "github.com/AssetMantle/modules/utilities/name" + "google.golang.org/grpc" ) -type dummy struct{} - var Transaction = baseHelpers.NewTransaction( - name.GetPackageName(dummy{}), + _Msg_serviceDesc.ServiceName, "", "", @@ -30,9 +22,6 @@ var Transaction = baseHelpers.NewTransaction( func(server grpc.ServiceRegistrar, keeper helpers.TransactionKeeper) { RegisterMsgServer(server, keeper.(transactionKeeper)) }, - func(clientCtx client.Context, mux *runtime.ServeMux) error { - return RegisterMsgHandlerClient(context.Background(), mux, NewMsgClient(clientCtx)) - }, constants.FromIdentityID, constants.OrderID, diff --git a/x/orders/transactions/get/transaction_keeper.go b/x/orders/transactions/get/transaction_keeper.go index 98465073e..6fdffaa3c 100644 --- a/x/orders/transactions/get/transaction_keeper.go +++ b/x/orders/transactions/get/transaction_keeper.go @@ -6,7 +6,6 @@ package get import ( "context" errorConstants "github.com/AssetMantle/modules/helpers/constants" - sdkTypes "github.com/cosmos/cosmos-sdk/types" "github.com/AssetMantle/modules/helpers" diff --git a/x/orders/transactions/get/transaction_request.go b/x/orders/transactions/get/transaction_request.go index 22819021b..697d47f15 100644 --- a/x/orders/transactions/get/transaction_request.go +++ b/x/orders/transactions/get/transaction_request.go @@ -5,23 +5,21 @@ package get import ( "encoding/json" - "github.com/AssetMantle/modules/utilities/rest" - - codecUtilities "github.com/AssetMantle/schema/codec/utilities" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" + "io" + "net/http" "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/helpers/constants" ) type transactionRequest struct { - BaseReq rest.BaseReq `json:"baseReq"` - FromID string `json:"fromID"` - OrderID string `json:"orderID"` + helpers.CommonTransactionRequest `json:"commonTransactionRequest"` + FromID string `json:"fromID"` + OrderID string `json:"orderID"` } var _ helpers.TransactionRequest = (*transactionRequest)(nil) @@ -47,23 +45,28 @@ func (transactionRequest transactionRequest) Validate() error { } func (transactionRequest transactionRequest) FromCLI(cliCommand helpers.CLICommand, context client.Context) (helpers.TransactionRequest, error) { return newTransactionRequest( - cliCommand.ReadBaseReq(context), + cliCommand.ReadCommonTransactionRequest(context), cliCommand.ReadString(constants.FromIdentityID), cliCommand.ReadString(constants.OrderID), ), nil } -func (transactionRequest transactionRequest) FromJSON(rawMessage json.RawMessage) (helpers.TransactionRequest, error) { - if err := json.Unmarshal(rawMessage, &transactionRequest); err != nil { +func (transactionRequest transactionRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.TransactionRequest, error) { + body, err := io.ReadAll(httpRequest.Body) + if err != nil { + return nil, err + } + + if err := json.Unmarshal(body, &transactionRequest); err != nil { return nil, err } return transactionRequest, nil } -func (transactionRequest transactionRequest) GetBaseReq() rest.BaseReq { - return transactionRequest.BaseReq +func (transactionRequest transactionRequest) GetCommonTransactionRequest() helpers.CommonTransactionRequest { + return transactionRequest.CommonTransactionRequest } func (transactionRequest transactionRequest) MakeMsg() (sdkTypes.Msg, error) { - from, err := sdkTypes.AccAddressFromBech32(transactionRequest.GetBaseReq().From) + from, err := sdkTypes.AccAddressFromBech32(transactionRequest.GetCommonTransactionRequest().GetFrom()) if err != nil { return nil, err } @@ -84,16 +87,13 @@ func (transactionRequest transactionRequest) MakeMsg() (sdkTypes.Msg, error) { orderID.(ids.OrderID), ), nil } -func (transactionRequest) RegisterLegacyAminoCodec(legacyAmino *codec.LegacyAmino) { - codecUtilities.RegisterModuleConcrete(legacyAmino, transactionRequest{}) -} func requestPrototype() helpers.TransactionRequest { return transactionRequest{} } -func newTransactionRequest(baseReq rest.BaseReq, fromID string, orderID string) helpers.TransactionRequest { +func newTransactionRequest(commonTransactionRequest helpers.CommonTransactionRequest, fromID string, orderID string) helpers.TransactionRequest { return transactionRequest{ - BaseReq: baseReq, - FromID: fromID, - OrderID: orderID, + CommonTransactionRequest: commonTransactionRequest, + FromID: fromID, + OrderID: orderID, } } diff --git a/x/orders/transactions/get/transaction_request_test.go b/x/orders/transactions/get/transaction_request_test.go index eed070ac8..ee8b124cb 100644 --- a/x/orders/transactions/get/transaction_request_test.go +++ b/x/orders/transactions/get/transaction_request_test.go @@ -4,9 +4,7 @@ package get import ( - "encoding/json" "fmt" - "github.com/AssetMantle/modules/utilities/rest" "reflect" "testing" @@ -16,15 +14,12 @@ import ( baseProperties "github.com/AssetMantle/schema/properties/base" baseQualified "github.com/AssetMantle/schema/qualified/base" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/types" - "github.com/spf13/viper" - "github.com/stretchr/testify/require" - "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/helpers/constants" + "github.com/spf13/viper" ) var ( @@ -33,17 +28,17 @@ var ( immutables = baseQualified.NewImmutables(base.NewPropertyList(baseProperties.NewMesaProperty(baseIDs.NewStringID("ID2"), baseData.NewStringData("Data2")))) mutables = baseQualified.NewMutables(base.NewPropertyList(baseProperties.NewMesaProperty(baseIDs.NewStringID("ID1"), baseData.NewStringData("Data1")))) - testClassificationID = baseIDs.NewClassificationID(immutables, mutables) - testFromID = baseIDs.NewIdentityID(testClassificationID, immutables).(*baseIDs.IdentityID) - testOrderID = baseIDs.NewOrderID(testClassificationID, immutables).(*baseIDs.OrderID) - testBaseRequest = rest.BaseReq{From: fromAddress, ChainID: "test", Fees: types.NewCoins()} - takerSplit = types.NewInt(60) + testClassificationID = baseIDs.NewClassificationID(immutables, mutables) + testFromID = baseIDs.NewIdentityID(testClassificationID, immutables).(*baseIDs.IdentityID) + testOrderID = baseIDs.NewOrderID(testClassificationID, immutables).(*baseIDs.OrderID) + commonTransactionRequest = helpers.PrototypeCommonTransactionRequest() + takerSplit = types.NewInt(60) ) func Test_newTransactionRequest(t *testing.T) { type args struct { - baseReq rest.BaseReq - fromID string + commonTransactionRequest helpers.CommonTransactionRequest + fromID string orderID string } @@ -52,11 +47,11 @@ func Test_newTransactionRequest(t *testing.T) { args args want helpers.TransactionRequest }{ - {"+ve", args{testBaseRequest, testFromID.AsString(), testOrderID.AsString()}, transactionRequest{testBaseRequest, testFromID.AsString(), testOrderID.AsString()}}, + {"+ve", args{commonTransactionRequest, testFromID.AsString(), testOrderID.AsString()}, transactionRequest{commonTransactionRequest, testFromID.AsString(), testOrderID.AsString()}}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - if got := newTransactionRequest(tt.args.baseReq, tt.args.fromID, tt.args.orderID); !reflect.DeepEqual(got, tt.want) { + if got := newTransactionRequest(tt.args.commonTransactionRequest, tt.args.fromID, tt.args.orderID); !reflect.DeepEqual(got, tt.want) { t.Errorf("newTransactionRequest() = %v, want %v", got, tt.want) } }) @@ -85,8 +80,8 @@ func Test_transactionRequest_FromCLI(t *testing.T) { viper.Set(constants.FromIdentityID.GetName(), testFromID.AsString()) viper.Set(constants.OrderID.GetName(), testOrderID.AsString()) type fields struct { - BaseReq rest.BaseReq - FromID string + commonTransactionRequest helpers.CommonTransactionRequest + FromID string OrderID string } @@ -101,14 +96,14 @@ func Test_transactionRequest_FromCLI(t *testing.T) { want helpers.TransactionRequest wantErr bool }{ - {"+ve", fields{testBaseRequest, testFromID.AsString(), testOrderID.AsString()}, args{cliCommand, client.Context{}.WithCodec(baseHelpers.CodecPrototype())}, transactionRequest{testBaseRequest, testFromID.AsString(), testOrderID.AsString()}, false}, + {"+ve", fields{commonTransactionRequest, testFromID.AsString(), testOrderID.AsString()}, args{cliCommand, client.Context{}.WithCodec(baseHelpers.CodecPrototype())}, transactionRequest{commonTransactionRequest, testFromID.AsString(), testOrderID.AsString()}, false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - OrderID: tt.fields.OrderID, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + OrderID: tt.fields.OrderID, } got, err := transactionRequest.FromCLI(tt.args.cliCommand, tt.args.context) if (err != nil) != tt.wantErr { @@ -122,68 +117,29 @@ func Test_transactionRequest_FromCLI(t *testing.T) { } } -func Test_transactionRequest_FromJSON(t *testing.T) { - jsonMessage, err := json.Marshal(newTransactionRequest(testBaseRequest, testFromID.AsString(), testOrderID.AsString())) - require.NoError(t, err) - type fields struct { - BaseReq rest.BaseReq - FromID string - OrderID string - } - type args struct { - rawMessage json.RawMessage - } - tests := []struct { - name string - fields fields - args args - want helpers.TransactionRequest - wantErr bool - }{ - {"+ve", fields{testBaseRequest, testFromID.AsString(), testOrderID.AsString()}, args{jsonMessage}, newTransactionRequest(testBaseRequest, testFromID.AsString(), testOrderID.AsString()), false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - OrderID: tt.fields.OrderID, - } - got, err := transactionRequest.FromJSON(tt.args.rawMessage) - if (err != nil) != tt.wantErr { - t.Errorf("FromJSON() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("FromJSON() got = %v, want %v", got, tt.want) - } - }) - } -} - func Test_transactionRequest_GetBaseReq(t *testing.T) { type fields struct { - BaseReq rest.BaseReq - FromID string + commonTransactionRequest helpers.CommonTransactionRequest + FromID string OrderID string } tests := []struct { name string fields fields - want rest.BaseReq + want helpers.CommonTransactionRequest }{ - {"+ve", fields{testBaseRequest, testFromID.AsString(), testOrderID.AsString()}, testBaseRequest}, + {"+ve", fields{commonTransactionRequest, testFromID.AsString(), testOrderID.AsString()}, commonTransactionRequest}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - OrderID: tt.fields.OrderID, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + OrderID: tt.fields.OrderID, } - if got := transactionRequest.GetBaseReq(); !reflect.DeepEqual(got, tt.want) { - t.Errorf("GetBaseReq() = %v, want %v", got, tt.want) + if got := transactionRequest.GetCommonTransactionRequest(); !reflect.DeepEqual(got, tt.want) { + t.Errorf("GetCommonTransactionRequest() = %v, want %v", got, tt.want) } }) } @@ -191,8 +147,8 @@ func Test_transactionRequest_GetBaseReq(t *testing.T) { func Test_transactionRequest_MakeMsg(t *testing.T) { type fields struct { - BaseReq rest.BaseReq - FromID string + commonTransactionRequest helpers.CommonTransactionRequest + FromID string OrderID string } @@ -202,14 +158,14 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { want types.Msg wantErr bool }{ - {"+ve", fields{testBaseRequest, testFromID.AsString(), testOrderID.AsString()}, NewMessage(fromAccAddress, testFromID, testOrderID), false}, + {"+ve", fields{commonTransactionRequest, testFromID.AsString(), testOrderID.AsString()}, NewMessage(fromAccAddress, testFromID, testOrderID), false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - OrderID: tt.fields.OrderID, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + OrderID: tt.fields.OrderID, } got, err := transactionRequest.MakeMsg() if (err != nil) != tt.wantErr { @@ -223,38 +179,10 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { } } -func Test_transactionRequest_RegisterCodec(t *testing.T) { - type fields struct { - BaseReq rest.BaseReq - FromID string - OrderID string - } - type args struct { - legacyAmino *codec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{testBaseRequest, testFromID.AsString(), testOrderID.AsString()}, args{codec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - tr := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - OrderID: tt.fields.OrderID, - } - tr.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - func Test_transactionRequest_Validate(t *testing.T) { type fields struct { - BaseReq rest.BaseReq - FromID string + commonTransactionRequest helpers.CommonTransactionRequest + FromID string OrderID string } @@ -263,14 +191,14 @@ func Test_transactionRequest_Validate(t *testing.T) { fields fields wantErr bool }{ - {"+ve", fields{testBaseRequest, testFromID.AsString(), testOrderID.AsString()}, false}, + {"+ve", fields{commonTransactionRequest, testFromID.AsString(), testOrderID.AsString()}, false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - OrderID: tt.fields.OrderID, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + OrderID: tt.fields.OrderID, } if err := transactionRequest.Validate(); (err != nil) != tt.wantErr { t.Errorf("ValidateBasic() error = %v, wantErr %v", err, tt.wantErr) diff --git a/x/orders/transactions/get/transaction_response.go b/x/orders/transactions/get/transaction_response.go index 11e7acdbd..ca085c64d 100644 --- a/x/orders/transactions/get/transaction_response.go +++ b/x/orders/transactions/get/transaction_response.go @@ -4,9 +4,8 @@ package get import ( - sdkTypes "github.com/cosmos/cosmos-sdk/types" - "github.com/AssetMantle/modules/helpers" + sdkTypes "github.com/cosmos/cosmos-sdk/types" ) var _ helpers.TransactionResponse = (*TransactionResponse)(nil) diff --git a/x/orders/transactions/immediate/message.go b/x/orders/transactions/immediate/message.go index 975b68334..a2fd76288 100644 --- a/x/orders/transactions/immediate/message.go +++ b/x/orders/transactions/immediate/message.go @@ -4,31 +4,20 @@ package immediate import ( + "github.com/AssetMantle/modules/helpers" errorConstants "github.com/AssetMantle/modules/helpers/constants" - codecUtilities "github.com/AssetMantle/schema/codec/utilities" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" "github.com/AssetMantle/schema/lists" baseLists "github.com/AssetMantle/schema/lists/base" typesSchema "github.com/AssetMantle/schema/types" baseTypes "github.com/AssetMantle/schema/types/base" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/types" sdkTypes "github.com/cosmos/cosmos-sdk/types" - - "github.com/AssetMantle/modules/helpers" ) var _ helpers.Message = (*Message)(nil) -func (message *Message) Type() string { return Transaction.GetName() } -func (message *Message) GetFromAddress() sdkTypes.AccAddress { - from, err := sdkTypes.AccAddressFromBech32(message.From) - if err != nil { - panic(err) - } - return from -} func (message *Message) ValidateBasic() error { if _, err := sdkTypes.AccAddressFromBech32(message.From); err != nil { return err @@ -77,21 +66,10 @@ func (message *Message) GetSigners() []sdkTypes.AccAddress { } return []sdkTypes.AccAddress{from} } -func (*Message) RegisterLegacyAminoCodec(legacyAmino *codec.LegacyAmino) { - codecUtilities.RegisterModuleConcrete(legacyAmino, Message{}) -} func (message *Message) RegisterInterface(interfaceRegistry types.InterfaceRegistry) { interfaceRegistry.RegisterImplementations((*sdkTypes.Msg)(nil), message) } -func messageFromInterface(msg sdkTypes.Msg) *Message { - switch value := msg.(type) { - case *Message: - return value - default: - return &Message{} - } -} func messagePrototype() helpers.Message { return &Message{} } diff --git a/x/orders/transactions/immediate/message_test.go b/x/orders/transactions/immediate/message_test.go index b89a4a081..71b9ad337 100644 --- a/x/orders/transactions/immediate/message_test.go +++ b/x/orders/transactions/immediate/message_test.go @@ -13,7 +13,6 @@ import ( baseLists "github.com/AssetMantle/schema/lists/base" "github.com/AssetMantle/schema/types" "github.com/AssetMantle/schema/types/base" - "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" "github.com/AssetMantle/modules/helpers" @@ -40,26 +39,6 @@ type fields struct { MutableProperties *baseLists.PropertyList } -func Test_messageFromInterface(t *testing.T) { - type args struct { - msg sdkTypes.Msg - } - tests := []struct { - name string - args args - want *Message - }{ - {"+ve", args{testMessage}, &Message{fromAccAddress.String(), testFromID, testClassificationID, testFromID, makerAssetID, takerAssetID, expiresInHeight, makerSplit.String(), takerSplit.String(), immutableMetaProperties.(*baseLists.PropertyList), immutableProperties.(*baseLists.PropertyList), mutableMetaProperties.(*baseLists.PropertyList), mutableProperties.(*baseLists.PropertyList)}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := messageFromInterface(tt.args.msg); !reflect.DeepEqual(got, tt.want) { - t.Errorf("messageFromInterface() = %v, want %v", got, tt.want) - } - }) - } -} - func Test_messagePrototype(t *testing.T) { tests := []struct { name string @@ -109,73 +88,6 @@ func Test_message_GetSigners(t *testing.T) { } } -func Test_message_RegisterCodec(t *testing.T) { - - type args struct { - legacyAmino *codec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{fromAccAddress.String(), testFromID, testClassificationID, testFromID, makerAssetID, takerAssetID, expiresInHeight, makerSplit, takerSplit, immutableMetaProperties.(*baseLists.PropertyList), immutableProperties.(*baseLists.PropertyList), mutableMetaProperties.(*baseLists.PropertyList), mutableProperties.(*baseLists.PropertyList)}, args{codec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - me := &Message{ - From: tt.fields.From, - FromID: tt.fields.FromID, - ClassificationID: tt.fields.ClassificationID, - TakerID: tt.fields.TakerID, - MakerAssetID: tt.fields.MakerAssetID, - TakerAssetID: tt.fields.TakerAssetID, - ExpiresIn: tt.fields.ExpiresIn, - MakerSplit: tt.fields.MakerSplit.String(), - TakerSplit: tt.fields.TakerSplit.String(), - ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, - ImmutableProperties: tt.fields.ImmutableProperties, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, - } - me.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - -func Test_message_Type(t *testing.T) { - - tests := []struct { - name string - fields fields - want string - }{ - {"+ve", fields{fromAccAddress.String(), testFromID, testClassificationID, testFromID, makerAssetID, takerAssetID, expiresInHeight, makerSplit, takerSplit, immutableMetaProperties.(*baseLists.PropertyList), immutableProperties.(*baseLists.PropertyList), mutableMetaProperties.(*baseLists.PropertyList), mutableProperties.(*baseLists.PropertyList)}, Transaction.GetName()}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - message := &Message{ - From: tt.fields.From, - FromID: tt.fields.FromID, - ClassificationID: tt.fields.ClassificationID, - TakerID: tt.fields.TakerID, - MakerAssetID: tt.fields.MakerAssetID, - TakerAssetID: tt.fields.TakerAssetID, - ExpiresIn: tt.fields.ExpiresIn, - MakerSplit: tt.fields.MakerSplit.String(), - TakerSplit: tt.fields.TakerSplit.String(), - ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, - ImmutableProperties: tt.fields.ImmutableProperties, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, - } - if got := message.Type(); got != tt.want { - t.Errorf("Type() = %v, want %v", got, tt.want) - } - }) - } -} - func Test_message_ValidateBasic(t *testing.T) { tests := []struct { diff --git a/x/orders/transactions/immediate/service.pb.go b/x/orders/transactions/immediate/service.pb.go index aa8e0030a..89a7ec303 100644 --- a/x/orders/transactions/immediate/service.pb.go +++ b/x/orders/transactions/immediate/service.pb.go @@ -6,9 +6,9 @@ package immediate import ( context "context" fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types/msgservice" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" - _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -31,30 +31,30 @@ func init() { } var fileDescriptor_0dcccd3b865dd390 = []byte{ - // 365 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x92, 0xb1, 0x4a, 0xfb, 0x40, - 0x18, 0xc0, 0x9b, 0x14, 0x3a, 0x84, 0xff, 0xd4, 0xe9, 0x4f, 0x90, 0x20, 0x7d, 0x80, 0x3b, 0xb0, - 0x83, 0x72, 0x88, 0xd2, 0x2e, 0xb6, 0x43, 0x6c, 0xd1, 0x0e, 0x41, 0x02, 0x72, 0x4d, 0x8e, 0x18, - 0xc8, 0xdd, 0x95, 0xdc, 0x55, 0x3a, 0xfb, 0x04, 0x42, 0xdf, 0xc0, 0xd1, 0xd1, 0xd1, 0x27, 0x10, - 0xa7, 0x82, 0x8b, 0xa3, 0x24, 0x4e, 0x3e, 0x85, 0xd8, 0x3b, 0xe3, 0x75, 0xbd, 0xf5, 0xb8, 0xdf, - 0x8f, 0xdf, 0xf7, 0xf1, 0x79, 0x83, 0x81, 0x10, 0x44, 0x86, 0x98, 0xc9, 0x82, 0x40, 0xca, 0xd3, - 0x65, 0x41, 0x04, 0x5c, 0x41, 0x5e, 0xa6, 0xa4, 0x14, 0x50, 0x96, 0x98, 0x09, 0x9c, 0xc8, 0x9c, - 0x33, 0x01, 0x73, 0x4a, 0x49, 0x9a, 0x63, 0x49, 0xa0, 0x20, 0xe5, 0x6d, 0x9e, 0x10, 0xb0, 0x28, - 0xb9, 0xe4, 0xdd, 0xbe, 0xa1, 0x00, 0x5a, 0x01, 0x56, 0x40, 0x29, 0x80, 0xa9, 0x00, 0x8d, 0xc2, - 0xdf, 0xcb, 0x38, 0xcf, 0x0a, 0x02, 0xf1, 0x22, 0x87, 0x98, 0x31, 0x2e, 0xb1, 0xfa, 0xb1, 0x55, - 0xfa, 0x56, 0x55, 0x94, 0x08, 0x81, 0x33, 0x5d, 0xe5, 0x9f, 0xdb, 0x28, 0x8c, 0xe7, 0xeb, 0x92, - 0x88, 0x05, 0x67, 0x42, 0xfb, 0x0e, 0x9e, 0x1d, 0xaf, 0x1d, 0x8a, 0xac, 0xfb, 0xe4, 0x78, 0x9d, - 0x11, 0x66, 0x69, 0x41, 0xba, 0xc7, 0xc0, 0x62, 0x72, 0x10, 0xaa, 0x4c, 0x7f, 0x64, 0x45, 0xcf, - 0xfe, 0x9e, 0x2f, 0x74, 0x60, 0x6f, 0xff, 0xee, 0xed, 0x73, 0xed, 0xfa, 0xbd, 0xff, 0x90, 0xaa, - 0x71, 0xf5, 0x90, 0x0d, 0x35, 0x5c, 0xb7, 0x5f, 0xaa, 0xc0, 0xd9, 0x54, 0x81, 0xf3, 0x51, 0x05, - 0xce, 0x7d, 0x1d, 0xb4, 0x36, 0x75, 0xd0, 0x7a, 0xaf, 0x83, 0x96, 0x77, 0x98, 0x70, 0x6a, 0x53, - 0x32, 0xfc, 0x77, 0xa9, 0xae, 0x60, 0xfa, 0xb3, 0x9e, 0xa9, 0x73, 0x75, 0x92, 0xe5, 0xf2, 0x66, - 0x39, 0x07, 0x09, 0xa7, 0xd0, 0x62, 0xf7, 0x0f, 0x6e, 0x67, 0x10, 0x46, 0x93, 0xd9, 0xf8, 0xd1, - 0xdd, 0x39, 0xa8, 0x50, 0xe7, 0x44, 0x60, 0xa2, 0x72, 0x66, 0x66, 0xce, 0xf8, 0x17, 0x7f, 0xdd, - 0xa1, 0x62, 0x4d, 0xc5, 0x51, 0xac, 0xa8, 0xd8, 0xa4, 0xe2, 0x86, 0xaa, 0xdc, 0x53, 0x0b, 0x2a, - 0x3e, 0x9b, 0x0e, 0x43, 0x22, 0x71, 0x8a, 0x25, 0xfe, 0x72, 0x8f, 0x0c, 0x03, 0x42, 0x5a, 0x81, - 0x50, 0x84, 0x90, 0x92, 0x20, 0x64, 0x5a, 0x10, 0x6a, 0x34, 0xf3, 0xce, 0xf6, 0xb2, 0xfa, 0xdf, - 0x01, 0x00, 0x00, 0xff, 0xff, 0x8d, 0xa2, 0xe0, 0x1f, 0x84, 0x03, 0x00, 0x00, + // 355 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x92, 0x31, 0x4b, 0xf3, 0x40, + 0x18, 0x80, 0x93, 0x94, 0xaf, 0x43, 0xf8, 0xa6, 0x2e, 0x42, 0x86, 0x0c, 0x8e, 0x0e, 0x77, 0x68, + 0x07, 0xe5, 0x10, 0xa5, 0x5d, 0x6c, 0x87, 0xd8, 0xa2, 0x1d, 0x82, 0x04, 0xe4, 0x9a, 0x1c, 0x31, + 0xd0, 0xcb, 0x95, 0xbc, 0xd7, 0xd2, 0xd1, 0x9f, 0x20, 0xfa, 0x0b, 0x74, 0x74, 0xf2, 0x67, 0x88, + 0x53, 0x47, 0x47, 0x49, 0x07, 0xc1, 0x5f, 0x21, 0xf5, 0xce, 0x7a, 0x5d, 0x6f, 0x0a, 0xbc, 0xf0, + 0x3c, 0x79, 0xf2, 0xe6, 0xf5, 0x3b, 0x1d, 0x00, 0x26, 0x23, 0x5a, 0xca, 0x09, 0xc3, 0x5c, 0x64, + 0xb3, 0x09, 0x03, 0xbc, 0xc0, 0xa2, 0xca, 0x58, 0x05, 0x58, 0x56, 0xb4, 0x04, 0x9a, 0xca, 0x42, + 0x94, 0x80, 0x0b, 0xce, 0x59, 0x56, 0x50, 0xc9, 0x30, 0xb0, 0x6a, 0x5e, 0xa4, 0x0c, 0x4d, 0x2b, + 0x21, 0x45, 0xab, 0x6d, 0x28, 0x90, 0x56, 0xa0, 0x05, 0x52, 0x0a, 0x64, 0x2a, 0xd0, 0x46, 0x11, + 0xec, 0xa4, 0x02, 0xb8, 0x00, 0xcc, 0x21, 0xc7, 0xf3, 0xfd, 0xf5, 0x43, 0xd9, 0x02, 0xab, 0x20, + 0xce, 0x00, 0x68, 0xae, 0x83, 0x82, 0x73, 0x1b, 0x85, 0x31, 0xbe, 0xae, 0x18, 0x4c, 0x45, 0x09, + 0xda, 0x77, 0xf0, 0xe8, 0xfa, 0x8d, 0x08, 0xf2, 0xd6, 0xbd, 0xeb, 0x37, 0x7b, 0xb4, 0xcc, 0x26, + 0xac, 0x75, 0x8c, 0x2c, 0x3e, 0x1a, 0x45, 0x2a, 0x33, 0xe8, 0x59, 0xd1, 0xa3, 0xbf, 0xf1, 0x85, + 0x0e, 0xdc, 0x75, 0x82, 0x7f, 0xb7, 0x9f, 0x2f, 0x7b, 0x6e, 0xf7, 0xa1, 0xf1, 0x5a, 0x87, 0xee, + 0xb2, 0x0e, 0xdd, 0x8f, 0x3a, 0x74, 0xef, 0x56, 0xa1, 0xb3, 0x5c, 0x85, 0xce, 0xfb, 0x2a, 0x74, + 0xfc, 0xc3, 0x54, 0x70, 0x9b, 0x17, 0x76, 0xff, 0x5f, 0xaa, 0xff, 0x3c, 0x5c, 0x6f, 0x61, 0xe8, + 0x5e, 0x9d, 0xe4, 0x85, 0xbc, 0x99, 0x8d, 0x51, 0x2a, 0x38, 0xb6, 0x58, 0xf1, 0x93, 0xd7, 0xec, + 0x44, 0xf1, 0x60, 0xd4, 0x7f, 0xf6, 0xb6, 0x4e, 0x26, 0xd2, 0x39, 0x31, 0x1a, 0xa8, 0x9c, 0x91, + 0x99, 0xd3, 0xff, 0xc5, 0xdf, 0xb6, 0xa8, 0x44, 0x53, 0x49, 0x9c, 0x28, 0x2a, 0x31, 0xa9, 0x64, + 0x43, 0xd5, 0xde, 0xa9, 0x05, 0x95, 0x9c, 0x0d, 0xbb, 0x11, 0x93, 0x34, 0xa3, 0x92, 0x7e, 0x79, + 0x47, 0x86, 0x81, 0x10, 0xad, 0x20, 0x24, 0x26, 0x44, 0x49, 0x08, 0x31, 0x2d, 0x84, 0x6c, 0x34, + 0xe3, 0xe6, 0xcf, 0x01, 0xb5, 0xbf, 0x03, 0x00, 0x00, 0xff, 0xff, 0xe0, 0xcb, 0x1b, 0xdf, 0x66, + 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/orders/transactions/immediate/service.pb.gw.go b/x/orders/transactions/immediate/service.pb.gw.go deleted file mode 100644 index 61cc7fcbe..000000000 --- a/x/orders/transactions/immediate/service.pb.gw.go +++ /dev/null @@ -1,171 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: AssetMantle/modules/x/orders/transactions/immediate/service.proto - -/* -Package immediate is a reverse proxy. - -It translates gRPC into RESTful JSON APIs. -*/ -package immediate - -import ( - "context" - "io" - "net/http" - - "github.com/golang/protobuf/descriptor" - "github.com/golang/protobuf/proto" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/grpc-ecosystem/grpc-gateway/utilities" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/status" -) - -// Suppress "imported and not used" errors -var _ codes.Code -var _ io.Reader -var _ status.Status -var _ = runtime.String -var _ = utilities.NewDoubleArray -var _ = descriptor.ForMessage -var _ = metadata.Join - -var ( - filter_Msg_Handle_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - -func request_Msg_Handle_0(ctx context.Context, marshaler runtime.Marshaler, client MsgClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq Message - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.Handle(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Msg_Handle_0(ctx context.Context, marshaler runtime.Marshaler, server MsgServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq Message - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.Handle(ctx, &protoReq) - return msg, metadata, err - -} - -// RegisterMsgHandlerServer registers the http handlers for service Msg to "mux". -// UnaryRPC :call MsgServer directly. -// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterMsgHandlerFromEndpoint instead. -func RegisterMsgHandlerServer(ctx context.Context, mux *runtime.ServeMux, server MsgServer) error { - - mux.Handle("POST", pattern_Msg_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Msg_Handle_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Msg_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -// RegisterMsgHandlerFromEndpoint is same as RegisterMsgHandler but -// automatically dials to "endpoint" and closes the connection when "ctx" gets done. -func RegisterMsgHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.Dial(endpoint, opts...) - if err != nil { - return err - } - defer func() { - if err != nil { - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - return - } - go func() { - <-ctx.Done() - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - }() - }() - - return RegisterMsgHandler(ctx, mux, conn) -} - -// RegisterMsgHandler registers the http handlers for service Msg to "mux". -// The handlers forward requests to the grpc endpoint over "conn". -func RegisterMsgHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { - return RegisterMsgHandlerClient(ctx, mux, NewMsgClient(conn)) -} - -// RegisterMsgHandlerClient registers the http handlers for service Msg -// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "MsgClient". -// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "MsgClient" -// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "MsgClient" to call the correct interceptors. -func RegisterMsgHandlerClient(ctx context.Context, mux *runtime.ServeMux, client MsgClient) error { - - mux.Handle("POST", pattern_Msg_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Msg_Handle_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Msg_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -var ( - pattern_Msg_Handle_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"mantle", "orders", "immediate"}, "", runtime.AssumeColonVerbOpt(false))) -) - -var ( - forward_Msg_Handle_0 = runtime.ForwardResponseMessage -) diff --git a/x/orders/transactions/immediate/transaction.go b/x/orders/transactions/immediate/transaction.go index 637b17a73..7d411704a 100644 --- a/x/orders/transactions/immediate/transaction.go +++ b/x/orders/transactions/immediate/transaction.go @@ -4,22 +4,14 @@ package immediate import ( - "context" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "google.golang.org/grpc" - "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/helpers/constants" - "github.com/AssetMantle/modules/utilities/name" + "google.golang.org/grpc" ) -type dummy struct{} - var Transaction = baseHelpers.NewTransaction( - name.GetPackageName(dummy{}), + _Msg_serviceDesc.ServiceName, "", "", @@ -30,9 +22,6 @@ var Transaction = baseHelpers.NewTransaction( func(server grpc.ServiceRegistrar, keeper helpers.TransactionKeeper) { RegisterMsgServer(server, keeper.(transactionKeeper)) }, - func(clientCtx client.Context, mux *runtime.ServeMux) error { - return RegisterMsgHandlerClient(context.Background(), mux, NewMsgClient(clientCtx)) - }, constants.FromIdentityID, constants.ClassificationID, diff --git a/x/orders/transactions/immediate/transaction_keeper.go b/x/orders/transactions/immediate/transaction_keeper.go index 0c5c7893d..cbb1729fc 100644 --- a/x/orders/transactions/immediate/transaction_keeper.go +++ b/x/orders/transactions/immediate/transaction_keeper.go @@ -6,7 +6,6 @@ package immediate import ( "context" errorConstants "github.com/AssetMantle/modules/helpers/constants" - "github.com/AssetMantle/schema/data" baseData "github.com/AssetMantle/schema/data/base" "github.com/AssetMantle/schema/documents/base" @@ -45,7 +44,7 @@ func (transactionKeeper transactionKeeper) Transact(context context.Context, mes } func (transactionKeeper transactionKeeper) Handle(context context.Context, message *Message) (*TransactionResponse, error) { - fromAddress := message.GetFromAddress() + fromAddress := message.GetSigners()[0] if _, err := transactionKeeper.authenticateAuxiliary.GetKeeper().Help(context, authenticate.NewAuxiliaryRequest(fromAddress, message.FromID)); err != nil { return nil, err diff --git a/x/orders/transactions/immediate/transaction_request.go b/x/orders/transactions/immediate/transaction_request.go index 49c567dc6..001392c33 100644 --- a/x/orders/transactions/immediate/transaction_request.go +++ b/x/orders/transactions/immediate/transaction_request.go @@ -5,35 +5,33 @@ package immediate import ( "encoding/json" - "github.com/AssetMantle/modules/utilities/rest" - - codecUtilities "github.com/AssetMantle/schema/codec/utilities" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" "github.com/AssetMantle/schema/lists/base" baseTypes "github.com/AssetMantle/schema/types/base" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" + "io" + "net/http" "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/helpers/constants" ) type transactionRequest struct { - BaseReq rest.BaseReq `json:"baseReq"` - FromID string `json:"fromID"` - ClassificationID string `json:"classificationID"` - TakerID string `json:"takerID"` - MakerAssetID string `json:"makerAssetID"` - TakerAssetID string `json:"takerAssetID"` - ExpiresIn int64 `json:"expiresIn"` - MakerSplit string `json:"makerSplit"` - TakerSplit string `json:"takerSplit"` - ImmutableMetaProperties string `json:"immutableMetaProperties"` - ImmutableProperties string `json:"immutableProperties"` - MutableMetaProperties string `json:"mutableMetaProperties"` - MutableProperties string `json:"mutableProperties"` + helpers.CommonTransactionRequest `json:"commonTransactionRequest"` + FromID string `json:"fromID"` + ClassificationID string `json:"classificationID"` + TakerID string `json:"takerID"` + MakerAssetID string `json:"makerAssetID"` + TakerAssetID string `json:"takerAssetID"` + ExpiresIn int64 `json:"expiresIn"` + MakerSplit string `json:"makerSplit"` + TakerSplit string `json:"takerSplit"` + ImmutableMetaProperties string `json:"immutableMetaProperties"` + ImmutableProperties string `json:"immutableProperties"` + MutableMetaProperties string `json:"mutableMetaProperties"` + MutableProperties string `json:"mutableProperties"` } var _ helpers.TransactionRequest = (*transactionRequest)(nil) @@ -59,7 +57,7 @@ func (transactionRequest transactionRequest) Validate() error { } func (transactionRequest transactionRequest) FromCLI(cliCommand helpers.CLICommand, context client.Context) (helpers.TransactionRequest, error) { return newTransactionRequest( - cliCommand.ReadBaseReq(context), + cliCommand.ReadCommonTransactionRequest(context), cliCommand.ReadString(constants.FromIdentityID), cliCommand.ReadString(constants.ClassificationID), cliCommand.ReadString(constants.TakerID), @@ -74,19 +72,24 @@ func (transactionRequest transactionRequest) FromCLI(cliCommand helpers.CLIComma cliCommand.ReadString(constants.MutableProperties), ), nil } -func (transactionRequest transactionRequest) FromJSON(rawMessage json.RawMessage) (helpers.TransactionRequest, error) { - if err := json.Unmarshal(rawMessage, &transactionRequest); err != nil { +func (transactionRequest transactionRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.TransactionRequest, error) { + body, err := io.ReadAll(httpRequest.Body) + if err != nil { + return nil, err + } + + if err := json.Unmarshal(body, &transactionRequest); err != nil { return nil, err } return transactionRequest, nil } -func (transactionRequest transactionRequest) GetBaseReq() rest.BaseReq { - return transactionRequest.BaseReq +func (transactionRequest transactionRequest) GetCommonTransactionRequest() helpers.CommonTransactionRequest { + return transactionRequest.CommonTransactionRequest } func (transactionRequest transactionRequest) MakeMsg() (sdkTypes.Msg, error) { - from, err := sdkTypes.AccAddressFromBech32(transactionRequest.GetBaseReq().From) + from, err := sdkTypes.AccAddressFromBech32(transactionRequest.GetCommonTransactionRequest().GetFrom()) if err != nil { return nil, err } @@ -164,27 +167,24 @@ func (transactionRequest transactionRequest) MakeMsg() (sdkTypes.Msg, error) { mutableProperties, ), nil } -func (transactionRequest) RegisterLegacyAminoCodec(legacyAmino *codec.LegacyAmino) { - codecUtilities.RegisterModuleConcrete(legacyAmino, transactionRequest{}) -} func requestPrototype() helpers.TransactionRequest { return transactionRequest{} } -func newTransactionRequest(baseReq rest.BaseReq, fromID string, classificationID string, takerID string, makerAssetID string, takerAssetID string, expiresIn int64, makerSplit, takerSplit string, immutableMetaProperties string, immutableProperties string, mutableMetaProperties string, mutableProperties string) helpers.TransactionRequest { +func newTransactionRequest(commonTransactionRequest helpers.CommonTransactionRequest, fromID string, classificationID string, takerID string, makerAssetID string, takerAssetID string, expiresIn int64, makerSplit, takerSplit string, immutableMetaProperties string, immutableProperties string, mutableMetaProperties string, mutableProperties string) helpers.TransactionRequest { return transactionRequest{ - BaseReq: baseReq, - FromID: fromID, - ClassificationID: classificationID, - TakerID: takerID, - MakerAssetID: makerAssetID, - TakerAssetID: takerAssetID, - ExpiresIn: expiresIn, - MakerSplit: makerSplit, - TakerSplit: takerSplit, - ImmutableMetaProperties: immutableMetaProperties, - ImmutableProperties: immutableProperties, - MutableMetaProperties: mutableMetaProperties, - MutableProperties: mutableProperties, + CommonTransactionRequest: commonTransactionRequest, + FromID: fromID, + ClassificationID: classificationID, + TakerID: takerID, + MakerAssetID: makerAssetID, + TakerAssetID: takerAssetID, + ExpiresIn: expiresIn, + MakerSplit: makerSplit, + TakerSplit: takerSplit, + ImmutableMetaProperties: immutableMetaProperties, + ImmutableProperties: immutableProperties, + MutableMetaProperties: mutableMetaProperties, + MutableProperties: mutableProperties, } } diff --git a/x/orders/transactions/immediate/transaction_request_test.go b/x/orders/transactions/immediate/transaction_request_test.go index 8cd725a28..6020ee70f 100644 --- a/x/orders/transactions/immediate/transaction_request_test.go +++ b/x/orders/transactions/immediate/transaction_request_test.go @@ -4,9 +4,7 @@ package immediate import ( - "encoding/json" "fmt" - "github.com/AssetMantle/modules/utilities/rest" "reflect" "testing" @@ -16,15 +14,12 @@ import ( baseQualified "github.com/AssetMantle/schema/qualified/base" "github.com/AssetMantle/schema/types/base" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/types" - "github.com/spf13/viper" - "github.com/stretchr/testify/require" - "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/helpers/constants" + "github.com/spf13/viper" ) var ( @@ -44,7 +39,7 @@ var ( testFromID = baseIDs.NewIdentityID(testClassificationID, immutables).(*baseIDs.IdentityID) makerAssetID = baseDocuments.NewCoinAsset("MakerAssetID").GetCoinAssetID().(*baseIDs.AssetID) takerAssetID = baseDocuments.NewCoinAsset("TakerAssetId").GetCoinAssetID().(*baseIDs.AssetID) - testBaseRequest = rest.BaseReq{From: fromAddress, ChainID: "test", Fees: types.NewCoins()} + commonTransactionRequest = helpers.PrototypeCommonTransactionRequest() expiresIn = int64(60) makerSplit = types.NewInt(60) takerSplit = types.NewInt(60) @@ -52,19 +47,19 @@ var ( func Test_newTransactionRequest(t *testing.T) { type args struct { - baseReq rest.BaseReq - fromID string - classificationID string - takerID string - makerAssetID string - takerAssetID string - expiresIn int64 - makerSplit string - takerSplit string - immutableMetaProperties string - immutableProperties string - mutableMetaProperties string - mutableProperties string + commonTransactionRequest helpers.CommonTransactionRequest + fromID string + classificationID string + takerID string + makerAssetID string + takerAssetID string + expiresIn int64 + makerSplit string + takerSplit string + immutableMetaProperties string + immutableProperties string + mutableMetaProperties string + mutableProperties string } tests := []struct { name string @@ -72,11 +67,11 @@ func Test_newTransactionRequest(t *testing.T) { want helpers.TransactionRequest }{ - {"+ve", args{testBaseRequest, testFromID.AsString(), testClassificationID.AsString(), testFromID.AsString(), makerAssetID.AsString(), takerAssetID.AsString(), expiresIn, makerSplit.String(), takerSplit.String(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, newTransactionRequest(testBaseRequest, testFromID.AsString(), testClassificationID.AsString(), testFromID.AsString(), makerAssetID.AsString(), takerAssetID.AsString(), expiresIn, makerSplit.String(), takerSplit.String(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString)}, + {"+ve", args{commonTransactionRequest, testFromID.AsString(), testClassificationID.AsString(), testFromID.AsString(), makerAssetID.AsString(), takerAssetID.AsString(), expiresIn, makerSplit.String(), takerSplit.String(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, newTransactionRequest(commonTransactionRequest, testFromID.AsString(), testClassificationID.AsString(), testFromID.AsString(), makerAssetID.AsString(), takerAssetID.AsString(), expiresIn, makerSplit.String(), takerSplit.String(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString)}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - if got := newTransactionRequest(tt.args.baseReq, tt.args.fromID, tt.args.classificationID, tt.args.takerID, tt.args.makerAssetID, tt.args.takerAssetID, tt.args.expiresIn, tt.args.makerSplit, tt.args.takerSplit, tt.args.immutableMetaProperties, tt.args.immutableProperties, tt.args.mutableMetaProperties, tt.args.mutableProperties); !reflect.DeepEqual(got, tt.want) { + if got := newTransactionRequest(tt.args.commonTransactionRequest, tt.args.fromID, tt.args.classificationID, tt.args.takerID, tt.args.makerAssetID, tt.args.takerAssetID, tt.args.expiresIn, tt.args.makerSplit, tt.args.takerSplit, tt.args.immutableMetaProperties, tt.args.immutableProperties, tt.args.mutableMetaProperties, tt.args.mutableProperties); !reflect.DeepEqual(got, tt.want) { t.Errorf("newTransactionRequest() = %v, want %v", got, tt.want) } }) @@ -116,19 +111,19 @@ func Test_transactionRequest_FromCLI(t *testing.T) { viper.Set(constants.MutableMetaProperties.GetName(), mutableMetaPropertiesString) viper.Set(constants.MutableProperties.GetName(), mutablePropertiesString) type fields struct { - BaseReq rest.BaseReq - FromID string - ClassificationID string - TakerID string - MakerAssetID string - TakerAssetID string - ExpiresIn int64 - MakerSplit string - TakerSplit string - ImmutableMetaProperties string - ImmutableProperties string - MutableMetaProperties string - MutableProperties string + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + ClassificationID string + TakerID string + MakerAssetID string + TakerAssetID string + ExpiresIn int64 + MakerSplit string + TakerSplit string + ImmutableMetaProperties string + ImmutableProperties string + MutableMetaProperties string + MutableProperties string } type args struct { cliCommand helpers.CLICommand @@ -141,24 +136,24 @@ func Test_transactionRequest_FromCLI(t *testing.T) { want helpers.TransactionRequest wantErr bool }{ - {"+ve", fields{testBaseRequest, testFromID.AsString(), testClassificationID.AsString(), testFromID.AsString(), makerAssetID.AsString(), takerAssetID.AsString(), expiresIn, makerSplit.String(), takerSplit.String(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, args{cliCommand, client.Context{}.WithCodec(baseHelpers.CodecPrototype())}, newTransactionRequest(testBaseRequest, testFromID.AsString(), testClassificationID.AsString(), testFromID.AsString(), makerAssetID.AsString(), takerAssetID.AsString(), expiresIn, makerSplit.String(), takerSplit.String(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString), false}, + {"+ve", fields{commonTransactionRequest, testFromID.AsString(), testClassificationID.AsString(), testFromID.AsString(), makerAssetID.AsString(), takerAssetID.AsString(), expiresIn, makerSplit.String(), takerSplit.String(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, args{cliCommand, client.Context{}.WithCodec(baseHelpers.CodecPrototype())}, newTransactionRequest(commonTransactionRequest, testFromID.AsString(), testClassificationID.AsString(), testFromID.AsString(), makerAssetID.AsString(), takerAssetID.AsString(), expiresIn, makerSplit.String(), takerSplit.String(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString), false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - ClassificationID: tt.fields.ClassificationID, - TakerID: tt.fields.TakerID, - MakerAssetID: tt.fields.MakerAssetID, - TakerAssetID: tt.fields.TakerAssetID, - ExpiresIn: tt.fields.ExpiresIn, - MakerSplit: tt.fields.MakerSplit, - TakerSplit: tt.fields.TakerSplit, - ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, - ImmutableProperties: tt.fields.ImmutableProperties, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + ClassificationID: tt.fields.ClassificationID, + TakerID: tt.fields.TakerID, + MakerAssetID: tt.fields.MakerAssetID, + TakerAssetID: tt.fields.TakerAssetID, + ExpiresIn: tt.fields.ExpiresIn, + MakerSplit: tt.fields.MakerSplit, + TakerSplit: tt.fields.TakerSplit, + ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, + ImmutableProperties: tt.fields.ImmutableProperties, + MutableMetaProperties: tt.fields.MutableMetaProperties, + MutableProperties: tt.fields.MutableProperties, } got, err := transactionRequest.FromCLI(tt.args.cliCommand, tt.args.context) if (err != nil) != tt.wantErr { @@ -172,107 +167,48 @@ func Test_transactionRequest_FromCLI(t *testing.T) { } } -func Test_transactionRequest_FromJSON(t *testing.T) { - jsonMessage, err := json.Marshal(newTransactionRequest(testBaseRequest, testFromID.AsString(), testClassificationID.AsString(), testFromID.AsString(), makerAssetID.AsString(), takerAssetID.AsString(), expiresIn, makerSplit.String(), takerSplit.String(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString)) - require.NoError(t, err) - type fields struct { - BaseReq rest.BaseReq - FromID string - ClassificationID string - TakerID string - MakerAssetID string - TakerAssetID string - ExpiresIn int64 - MakerSplit string - TakerSplit string - ImmutableMetaProperties string - ImmutableProperties string - MutableMetaProperties string - MutableProperties string - } - type args struct { - rawMessage json.RawMessage - } - tests := []struct { - name string - fields fields - args args - want helpers.TransactionRequest - wantErr bool - }{ - {"+ve", fields{testBaseRequest, testFromID.AsString(), testClassificationID.AsString(), testFromID.AsString(), makerAssetID.AsString(), takerAssetID.AsString(), expiresIn, makerSplit.String(), takerSplit.String(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, args{jsonMessage}, newTransactionRequest(testBaseRequest, testFromID.AsString(), testClassificationID.AsString(), testFromID.AsString(), makerAssetID.AsString(), takerAssetID.AsString(), expiresIn, makerSplit.String(), takerSplit.String(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString), false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - ClassificationID: tt.fields.ClassificationID, - TakerID: tt.fields.TakerID, - MakerAssetID: tt.fields.MakerAssetID, - TakerAssetID: tt.fields.TakerAssetID, - ExpiresIn: tt.fields.ExpiresIn, - MakerSplit: tt.fields.MakerSplit, - TakerSplit: tt.fields.TakerSplit, - ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, - ImmutableProperties: tt.fields.ImmutableProperties, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, - } - got, err := transactionRequest.FromJSON(tt.args.rawMessage) - if (err != nil) != tt.wantErr { - t.Errorf("FromJSON() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("FromJSON() got = %v, want %v", got, tt.want) - } - }) - } -} - func Test_transactionRequest_GetBaseReq(t *testing.T) { type fields struct { - BaseReq rest.BaseReq - FromID string - ClassificationID string - TakerID string - MakerAssetID string - TakerAssetID string - ExpiresIn int64 - MakerSplit string - TakerSplit string - ImmutableMetaProperties string - ImmutableProperties string - MutableMetaProperties string - MutableProperties string + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + ClassificationID string + TakerID string + MakerAssetID string + TakerAssetID string + ExpiresIn int64 + MakerSplit string + TakerSplit string + ImmutableMetaProperties string + ImmutableProperties string + MutableMetaProperties string + MutableProperties string } tests := []struct { name string fields fields - want rest.BaseReq + want helpers.CommonTransactionRequest }{ - {"+ve", fields{testBaseRequest, testFromID.AsString(), testClassificationID.AsString(), testFromID.AsString(), makerAssetID.AsString(), takerAssetID.AsString(), expiresIn, makerSplit.String(), takerSplit.String(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, testBaseRequest}, + {"+ve", fields{commonTransactionRequest, testFromID.AsString(), testClassificationID.AsString(), testFromID.AsString(), makerAssetID.AsString(), takerAssetID.AsString(), expiresIn, makerSplit.String(), takerSplit.String(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, commonTransactionRequest}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - ClassificationID: tt.fields.ClassificationID, - TakerID: tt.fields.TakerID, - MakerAssetID: tt.fields.MakerAssetID, - TakerAssetID: tt.fields.TakerAssetID, - ExpiresIn: tt.fields.ExpiresIn, - MakerSplit: tt.fields.MakerSplit, - TakerSplit: tt.fields.TakerSplit, - ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, - ImmutableProperties: tt.fields.ImmutableProperties, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + ClassificationID: tt.fields.ClassificationID, + TakerID: tt.fields.TakerID, + MakerAssetID: tt.fields.MakerAssetID, + TakerAssetID: tt.fields.TakerAssetID, + ExpiresIn: tt.fields.ExpiresIn, + MakerSplit: tt.fields.MakerSplit, + TakerSplit: tt.fields.TakerSplit, + ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, + ImmutableProperties: tt.fields.ImmutableProperties, + MutableMetaProperties: tt.fields.MutableMetaProperties, + MutableProperties: tt.fields.MutableProperties, } - if got := transactionRequest.GetBaseReq(); !reflect.DeepEqual(got, tt.want) { - t.Errorf("GetBaseReq() = %v, want %v", got, tt.want) + if got := transactionRequest.GetCommonTransactionRequest(); !reflect.DeepEqual(got, tt.want) { + t.Errorf("GetCommonTransactionRequest() = %v, want %v", got, tt.want) } }) } @@ -280,19 +216,19 @@ func Test_transactionRequest_GetBaseReq(t *testing.T) { func Test_transactionRequest_MakeMsg(t *testing.T) { type fields struct { - BaseReq rest.BaseReq - FromID string - ClassificationID string - TakerID string - MakerAssetID string - TakerAssetID string - ExpiresIn int64 - MakerSplit string - TakerSplit string - ImmutableMetaProperties string - ImmutableProperties string - MutableMetaProperties string - MutableProperties string + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + ClassificationID string + TakerID string + MakerAssetID string + TakerAssetID string + ExpiresIn int64 + MakerSplit string + TakerSplit string + ImmutableMetaProperties string + ImmutableProperties string + MutableMetaProperties string + MutableProperties string } tests := []struct { name string @@ -300,24 +236,24 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { want types.Msg wantErr bool }{ - {"+ve", fields{testBaseRequest, testFromID.AsString(), testClassificationID.AsString(), testFromID.AsString(), makerAssetID.AsString(), takerAssetID.AsString(), expiresIn, makerSplit.String(), takerSplit.String(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, NewMessage(fromAccAddress, testFromID, testClassificationID, testFromID, makerAssetID, takerAssetID, base.NewHeight(60), makerSplit, takerSplit, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties), false}, + {"+ve", fields{commonTransactionRequest, testFromID.AsString(), testClassificationID.AsString(), testFromID.AsString(), makerAssetID.AsString(), takerAssetID.AsString(), expiresIn, makerSplit.String(), takerSplit.String(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, NewMessage(fromAccAddress, testFromID, testClassificationID, testFromID, makerAssetID, takerAssetID, base.NewHeight(60), makerSplit, takerSplit, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties), false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - ClassificationID: tt.fields.ClassificationID, - TakerID: tt.fields.TakerID, - MakerAssetID: tt.fields.MakerAssetID, - TakerAssetID: tt.fields.TakerAssetID, - ExpiresIn: tt.fields.ExpiresIn, - MakerSplit: tt.fields.MakerSplit, - TakerSplit: tt.fields.TakerSplit, - ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, - ImmutableProperties: tt.fields.ImmutableProperties, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + ClassificationID: tt.fields.ClassificationID, + TakerID: tt.fields.TakerID, + MakerAssetID: tt.fields.MakerAssetID, + TakerAssetID: tt.fields.TakerAssetID, + ExpiresIn: tt.fields.ExpiresIn, + MakerSplit: tt.fields.MakerSplit, + TakerSplit: tt.fields.TakerSplit, + ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, + ImmutableProperties: tt.fields.ImmutableProperties, + MutableMetaProperties: tt.fields.MutableMetaProperties, + MutableProperties: tt.fields.MutableProperties, } got, err := transactionRequest.MakeMsg() if (err != nil) != tt.wantErr { @@ -331,93 +267,45 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { } } -func Test_transactionRequest_RegisterCodec(t *testing.T) { - type fields struct { - BaseReq rest.BaseReq - FromID string - ClassificationID string - TakerID string - MakerAssetID string - TakerAssetID string - ExpiresIn int64 - MakerSplit string - TakerSplit string - ImmutableMetaProperties string - ImmutableProperties string - MutableMetaProperties string - MutableProperties string - } - type args struct { - legacyAmino *codec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{testBaseRequest, testFromID.AsString(), testClassificationID.AsString(), testFromID.AsString(), makerAssetID.AsString(), takerAssetID.AsString(), expiresIn, makerSplit.String(), takerSplit.String(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, args{codec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - tr := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - ClassificationID: tt.fields.ClassificationID, - TakerID: tt.fields.TakerID, - MakerAssetID: tt.fields.MakerAssetID, - TakerAssetID: tt.fields.TakerAssetID, - ExpiresIn: tt.fields.ExpiresIn, - MakerSplit: tt.fields.MakerSplit, - TakerSplit: tt.fields.TakerSplit, - ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, - ImmutableProperties: tt.fields.ImmutableProperties, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, - } - tr.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - func Test_transactionRequest_Validate(t *testing.T) { type fields struct { - BaseReq rest.BaseReq - FromID string - ClassificationID string - TakerID string - MakerAssetID string - TakerAssetID string - ExpiresIn int64 - MakerSplit string - TakerSplit string - ImmutableMetaProperties string - ImmutableProperties string - MutableMetaProperties string - MutableProperties string + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + ClassificationID string + TakerID string + MakerAssetID string + TakerAssetID string + ExpiresIn int64 + MakerSplit string + TakerSplit string + ImmutableMetaProperties string + ImmutableProperties string + MutableMetaProperties string + MutableProperties string } tests := []struct { name string fields fields wantErr bool }{ - {"+ve", fields{testBaseRequest, testFromID.AsString(), testClassificationID.AsString(), testFromID.AsString(), makerAssetID.AsString(), takerAssetID.AsString(), expiresIn, makerSplit.String(), takerSplit.String(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, false}, + {"+ve", fields{commonTransactionRequest, testFromID.AsString(), testClassificationID.AsString(), testFromID.AsString(), makerAssetID.AsString(), takerAssetID.AsString(), expiresIn, makerSplit.String(), takerSplit.String(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - ClassificationID: tt.fields.ClassificationID, - TakerID: tt.fields.TakerID, - MakerAssetID: tt.fields.MakerAssetID, - TakerAssetID: tt.fields.TakerAssetID, - ExpiresIn: tt.fields.ExpiresIn, - MakerSplit: tt.fields.MakerSplit, - TakerSplit: tt.fields.TakerSplit, - ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, - ImmutableProperties: tt.fields.ImmutableProperties, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + ClassificationID: tt.fields.ClassificationID, + TakerID: tt.fields.TakerID, + MakerAssetID: tt.fields.MakerAssetID, + TakerAssetID: tt.fields.TakerAssetID, + ExpiresIn: tt.fields.ExpiresIn, + MakerSplit: tt.fields.MakerSplit, + TakerSplit: tt.fields.TakerSplit, + ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, + ImmutableProperties: tt.fields.ImmutableProperties, + MutableMetaProperties: tt.fields.MutableMetaProperties, + MutableProperties: tt.fields.MutableProperties, } if err := transactionRequest.Validate(); (err != nil) != tt.wantErr { t.Errorf("ValidateBasic() error = %v, wantErr %v", err, tt.wantErr) diff --git a/x/orders/transactions/immediate/transaction_response.go b/x/orders/transactions/immediate/transaction_response.go index 2516ae53d..28614e8e8 100644 --- a/x/orders/transactions/immediate/transaction_response.go +++ b/x/orders/transactions/immediate/transaction_response.go @@ -4,9 +4,8 @@ package immediate import ( - sdkTypes "github.com/cosmos/cosmos-sdk/types" - "github.com/AssetMantle/modules/helpers" + sdkTypes "github.com/cosmos/cosmos-sdk/types" ) var _ helpers.TransactionResponse = (*TransactionResponse)(nil) diff --git a/x/orders/transactions/make/message.go b/x/orders/transactions/make/message.go index 24f166dff..ebff520a8 100644 --- a/x/orders/transactions/make/message.go +++ b/x/orders/transactions/make/message.go @@ -4,31 +4,20 @@ package make import ( + "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/helpers/constants" - codecUtilities "github.com/AssetMantle/schema/codec/utilities" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" "github.com/AssetMantle/schema/lists" baseLists "github.com/AssetMantle/schema/lists/base" typesSchema "github.com/AssetMantle/schema/types" baseTypes "github.com/AssetMantle/schema/types/base" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/types" sdkTypes "github.com/cosmos/cosmos-sdk/types" - - "github.com/AssetMantle/modules/helpers" ) var _ helpers.Message = (*Message)(nil) -func (message *Message) Type() string { return Transaction.GetName() } -func (message *Message) GetFromAddress() sdkTypes.AccAddress { - from, err := sdkTypes.AccAddressFromBech32(message.From) - if err != nil { - panic(err) - } - return from -} func (message *Message) ValidateBasic() error { if _, err := sdkTypes.AccAddressFromBech32(message.From); err != nil { return err @@ -77,21 +66,10 @@ func (message *Message) GetSigners() []sdkTypes.AccAddress { } return []sdkTypes.AccAddress{from} } -func (*Message) RegisterLegacyAminoCodec(legacyAmino *codec.LegacyAmino) { - codecUtilities.RegisterModuleConcrete(legacyAmino, Message{}) -} func (message *Message) RegisterInterface(interfaceRegistry types.InterfaceRegistry) { interfaceRegistry.RegisterImplementations((*sdkTypes.Msg)(nil), message) } -func messageFromInterface(msg sdkTypes.Msg) *Message { - switch value := msg.(type) { - case *Message: - return value - default: - return &Message{} - } -} func messagePrototype() helpers.Message { return &Message{} } diff --git a/x/orders/transactions/make/message_test.go b/x/orders/transactions/make/message_test.go index 1a8a59a51..64be27749 100644 --- a/x/orders/transactions/make/message_test.go +++ b/x/orders/transactions/make/message_test.go @@ -13,7 +13,6 @@ import ( baseLists "github.com/AssetMantle/schema/lists/base" "github.com/AssetMantle/schema/types" "github.com/AssetMantle/schema/types/base" - "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" "github.com/AssetMantle/modules/helpers" @@ -40,26 +39,6 @@ type fields struct { MutableProperties *baseLists.PropertyList } -func Test_messageFromInterface(t *testing.T) { - type args struct { - msg sdkTypes.Msg - } - tests := []struct { - name string - args args - want *Message - }{ - {"+ve", args{testMessage}, &Message{fromAccAddress.String(), testFromID, testClassificationID, testFromID, makerAssetID.(*baseIDs.AssetID), takerAssetID.(*baseIDs.AssetID), expiresInHeight, makerSplit.String(), takerSplit.String(), immutableMetaProperties.(*baseLists.PropertyList), immutableProperties.(*baseLists.PropertyList), mutableMetaProperties.(*baseLists.PropertyList), mutableProperties.(*baseLists.PropertyList)}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := messageFromInterface(tt.args.msg); !reflect.DeepEqual(got, tt.want) { - t.Errorf("messageFromInterface() = %v, want %v", got, tt.want) - } - }) - } -} - func Test_messagePrototype(t *testing.T) { tests := []struct { name string @@ -109,73 +88,6 @@ func Test_message_GetSigners(t *testing.T) { } } -func Test_message_RegisterCodec(t *testing.T) { - - type args struct { - legacyAmino *codec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{fromAccAddress.String(), testFromID, testClassificationID, testFromID, makerAssetID.(*baseIDs.AssetID), takerAssetID.(*baseIDs.AssetID), expiresInHeight, makerSplit, takerSplit, immutableMetaProperties.(*baseLists.PropertyList), immutableProperties.(*baseLists.PropertyList), mutableMetaProperties.(*baseLists.PropertyList), mutableProperties.(*baseLists.PropertyList)}, args{codec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - me := &Message{ - From: tt.fields.From, - FromID: tt.fields.FromID, - ClassificationID: tt.fields.ClassificationID, - TakerID: tt.fields.TakerID, - MakerAssetID: tt.fields.MakerAssetID, - TakerAssetID: tt.fields.TakerAssetID, - ExpiresIn: tt.fields.ExpiresIn, - MakerSplit: tt.fields.MakerSplit.String(), - TakerSplit: tt.fields.TakerSplit.String(), - ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, - ImmutableProperties: tt.fields.ImmutableProperties, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, - } - me.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - -func Test_message_Type(t *testing.T) { - - tests := []struct { - name string - fields fields - want string - }{ - {"+ve", fields{fromAccAddress.String(), testFromID, testClassificationID, testFromID, makerAssetID.(*baseIDs.AssetID), takerAssetID.(*baseIDs.AssetID), expiresInHeight, makerSplit, takerSplit, immutableMetaProperties.(*baseLists.PropertyList), immutableProperties.(*baseLists.PropertyList), mutableMetaProperties.(*baseLists.PropertyList), mutableProperties.(*baseLists.PropertyList)}, Transaction.GetName()}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - message := &Message{ - From: tt.fields.From, - FromID: tt.fields.FromID, - ClassificationID: tt.fields.ClassificationID, - TakerID: tt.fields.TakerID, - MakerAssetID: tt.fields.MakerAssetID, - TakerAssetID: tt.fields.TakerAssetID, - ExpiresIn: tt.fields.ExpiresIn, - MakerSplit: tt.fields.MakerSplit.String(), - TakerSplit: tt.fields.TakerSplit.String(), - ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, - ImmutableProperties: tt.fields.ImmutableProperties, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, - } - if got := message.Type(); got != tt.want { - t.Errorf("Type() = %v, want %v", got, tt.want) - } - }) - } -} - func Test_message_ValidateBasic(t *testing.T) { tests := []struct { diff --git a/x/orders/transactions/make/service.pb.go b/x/orders/transactions/make/service.pb.go index 7d10377d8..e53b6cf24 100644 --- a/x/orders/transactions/make/service.pb.go +++ b/x/orders/transactions/make/service.pb.go @@ -6,9 +6,9 @@ package make import ( context "context" fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types/msgservice" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" - _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -31,30 +31,29 @@ func init() { } var fileDescriptor_fbbf961e1e7c95c7 = []byte{ - // 356 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0xd2, 0xb1, 0x4a, 0xc3, 0x40, - 0x18, 0xc0, 0xf1, 0x26, 0x42, 0x87, 0xe0, 0x54, 0x71, 0x89, 0x92, 0xa1, 0x0f, 0x70, 0x07, 0xed, - 0x20, 0x1e, 0x2e, 0xad, 0x83, 0x3a, 0x1c, 0x2d, 0xda, 0x21, 0x48, 0x40, 0xae, 0xc9, 0x47, 0x0c, - 0x4d, 0x72, 0x25, 0x77, 0x95, 0xce, 0x3e, 0x81, 0xe0, 0x1b, 0xe8, 0xa6, 0x2f, 0x22, 0x4e, 0x05, - 0x17, 0x47, 0x49, 0x9d, 0xdc, 0xdd, 0x25, 0xbd, 0x03, 0xaf, 0xe3, 0xad, 0x17, 0x7e, 0x5f, 0xfe, - 0xdf, 0x25, 0xde, 0xc9, 0x40, 0x08, 0x90, 0x94, 0x95, 0x32, 0x07, 0x5c, 0xf0, 0x64, 0x91, 0x83, - 0xc0, 0x4b, 0xcc, 0xab, 0x04, 0x2a, 0x81, 0x65, 0xc5, 0x4a, 0xc1, 0x62, 0x99, 0xf1, 0x52, 0xe0, - 0x82, 0xcd, 0x00, 0x0b, 0xa8, 0xee, 0xb2, 0x18, 0xd0, 0xbc, 0xe2, 0x92, 0x77, 0x90, 0xa1, 0x91, - 0xd6, 0x68, 0x89, 0x94, 0x46, 0xa6, 0x46, 0x8d, 0xf6, 0x0f, 0x53, 0xce, 0xd3, 0x1c, 0x30, 0x9b, - 0x67, 0x98, 0x95, 0x25, 0x97, 0x4c, 0x3d, 0xdc, 0x4c, 0xf3, 0x6d, 0x5b, 0x0a, 0x10, 0x82, 0xa5, - 0xba, 0xc5, 0xbf, 0xb0, 0xd4, 0xc6, 0xc9, 0x4d, 0x05, 0x62, 0xce, 0x4b, 0xa1, 0x47, 0xf5, 0x5e, - 0x1d, 0x6f, 0x87, 0x8a, 0xb4, 0xf3, 0xec, 0x78, 0xed, 0x73, 0x56, 0x26, 0x39, 0x74, 0x8e, 0x2c, - 0x57, 0x45, 0x54, 0xc5, 0xf9, 0xa7, 0xb6, 0x70, 0xf2, 0x7f, 0x72, 0xa9, 0xb3, 0xba, 0x07, 0xf7, - 0x1f, 0xdf, 0x8f, 0xee, 0x7e, 0x77, 0x0f, 0x17, 0x6a, 0x3f, 0xbd, 0x55, 0x03, 0x86, 0xbf, 0xee, - 0x5b, 0x1d, 0x38, 0xab, 0x3a, 0x70, 0xbe, 0xea, 0xc0, 0x79, 0x58, 0x07, 0xad, 0xd5, 0x3a, 0x68, - 0x7d, 0xae, 0x83, 0x96, 0xd7, 0x8b, 0x79, 0x61, 0xf9, 0xfe, 0xe1, 0xee, 0x95, 0xfa, 0xc4, 0xe3, - 0xe6, 0x2a, 0xc6, 0xce, 0xf5, 0x71, 0x9a, 0xc9, 0xdb, 0xc5, 0x14, 0xc5, 0xbc, 0xc0, 0x76, 0x57, - 0xfc, 0xe4, 0xb6, 0x07, 0x34, 0x1c, 0x4d, 0xe8, 0x8b, 0xbb, 0x15, 0x41, 0x75, 0x44, 0x88, 0x46, - 0x2a, 0x62, 0x62, 0x46, 0x50, 0x36, 0x83, 0xf7, 0x2d, 0x10, 0x69, 0x10, 0x85, 0x91, 0x02, 0x91, - 0x09, 0xa2, 0x06, 0xd4, 0x2e, 0xb1, 0x03, 0xd1, 0xd9, 0x78, 0x48, 0x41, 0xb2, 0x84, 0x49, 0xf6, - 0xe3, 0xf6, 0x0d, 0x4c, 0x88, 0xd6, 0x84, 0x84, 0x84, 0x28, 0x4f, 0x88, 0x39, 0x80, 0x90, 0x66, - 0xc2, 0xb4, 0xbd, 0xf9, 0x59, 0xfa, 0x7f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x71, 0xb6, 0xf0, 0xc3, - 0x43, 0x03, 0x00, 0x00, + // 345 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0xd2, 0x31, 0x4b, 0xc3, 0x40, + 0x14, 0xc0, 0xf1, 0x24, 0x62, 0x87, 0xe0, 0xd4, 0x45, 0xc8, 0x90, 0xc1, 0xd1, 0xe1, 0x0e, 0xdb, + 0x41, 0x3c, 0x5c, 0x5a, 0x07, 0x75, 0x38, 0x5a, 0xb4, 0x43, 0x90, 0x80, 0x5c, 0x93, 0x23, 0x96, + 0xf6, 0x72, 0x25, 0xef, 0x5a, 0x3a, 0x3a, 0x3a, 0xba, 0xb9, 0x3b, 0x3a, 0xf9, 0x31, 0xc4, 0xa9, + 0xa3, 0xa3, 0xa4, 0x83, 0xe0, 0xee, 0x2e, 0xf1, 0x0e, 0xbc, 0x8e, 0x37, 0x05, 0x0e, 0x7e, 0x2f, + 0xff, 0x97, 0x5c, 0x78, 0xda, 0x03, 0xe0, 0x8a, 0xb2, 0x52, 0xcd, 0x38, 0x16, 0x32, 0x5f, 0xcc, + 0x38, 0xe0, 0x15, 0x96, 0x55, 0xce, 0x2b, 0xc0, 0xaa, 0x62, 0x25, 0xb0, 0x4c, 0x4d, 0x64, 0x09, + 0x58, 0xb0, 0x29, 0xc7, 0xc0, 0xab, 0xe5, 0x24, 0xe3, 0x68, 0x5e, 0x49, 0x25, 0xdb, 0xc8, 0xd2, + 0xc8, 0x68, 0xb4, 0x42, 0x5a, 0x23, 0x5b, 0xa3, 0x46, 0x47, 0xfb, 0x99, 0x04, 0x21, 0x01, 0x0b, + 0x28, 0xf0, 0xf2, 0xa8, 0x79, 0xe8, 0x41, 0x91, 0x6b, 0x86, 0xe0, 0x00, 0xac, 0x30, 0x19, 0xd1, + 0xa5, 0xa3, 0xb6, 0x4e, 0x6e, 0x2b, 0x0e, 0x73, 0x59, 0x82, 0x19, 0xd5, 0x79, 0xf2, 0xc3, 0x1d, + 0x0a, 0x45, 0xfb, 0xc1, 0x0f, 0x5b, 0x17, 0xac, 0xcc, 0x67, 0xbc, 0x7d, 0xec, 0xb8, 0x25, 0xa2, + 0x3a, 0x2e, 0x3a, 0x73, 0x85, 0xa3, 0xff, 0x93, 0x2b, 0x93, 0x75, 0xe0, 0x45, 0xbb, 0xf7, 0x5f, + 0xaf, 0x87, 0x7e, 0xff, 0x27, 0x78, 0xab, 0x63, 0x7f, 0x5d, 0xc7, 0xfe, 0x67, 0x1d, 0xfb, 0x8f, + 0x9b, 0xd8, 0x5b, 0x6f, 0x62, 0xef, 0x63, 0x13, 0x7b, 0x61, 0x27, 0x93, 0xc2, 0xf1, 0x5d, 0xfd, + 0xbd, 0x6b, 0xfd, 0x27, 0x87, 0xcd, 0xda, 0x43, 0xff, 0xe6, 0xa4, 0x98, 0xa8, 0xbb, 0xc5, 0x18, + 0x65, 0x52, 0x60, 0xb7, 0xcf, 0xf9, 0x1c, 0xb4, 0x7a, 0x34, 0x19, 0x8c, 0xe8, 0x4b, 0xb0, 0x15, + 0x41, 0x4d, 0x44, 0x82, 0x06, 0x3a, 0x62, 0x64, 0x47, 0x50, 0x36, 0xe5, 0xef, 0x5b, 0x20, 0x35, + 0x20, 0x4d, 0x52, 0x0d, 0x52, 0x1b, 0xa4, 0x0d, 0xa8, 0x03, 0xe2, 0x06, 0xd2, 0xf3, 0x61, 0x9f, + 0x72, 0xc5, 0x72, 0xa6, 0xd8, 0x77, 0xd0, 0xb5, 0x30, 0x21, 0x46, 0x13, 0x92, 0x10, 0xa2, 0x3d, + 0x21, 0xf6, 0x00, 0x42, 0x9a, 0x09, 0xe3, 0xd6, 0xdf, 0xc5, 0xe8, 0xfe, 0x06, 0x00, 0x00, 0xff, + 0xff, 0x0c, 0x66, 0x18, 0x81, 0x2a, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/orders/transactions/make/service.pb.gw.go b/x/orders/transactions/make/service.pb.gw.go deleted file mode 100644 index 600841b6c..000000000 --- a/x/orders/transactions/make/service.pb.gw.go +++ /dev/null @@ -1,171 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: AssetMantle/modules/x/orders/transactions/make/service.proto - -/* -Package make is a reverse proxy. - -It translates gRPC into RESTful JSON APIs. -*/ -package make - -import ( - "context" - "io" - "net/http" - - "github.com/golang/protobuf/descriptor" - "github.com/golang/protobuf/proto" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/grpc-ecosystem/grpc-gateway/utilities" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/status" -) - -// Suppress "imported and not used" errors -var _ codes.Code -var _ io.Reader -var _ status.Status -var _ = runtime.String -var _ = utilities.NewDoubleArray -var _ = descriptor.ForMessage -var _ = metadata.Join - -var ( - filter_Msg_Handle_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - -func request_Msg_Handle_0(ctx context.Context, marshaler runtime.Marshaler, client MsgClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq Message - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.Handle(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Msg_Handle_0(ctx context.Context, marshaler runtime.Marshaler, server MsgServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq Message - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.Handle(ctx, &protoReq) - return msg, metadata, err - -} - -// RegisterMsgHandlerServer registers the http handlers for service Msg to "mux". -// UnaryRPC :call MsgServer directly. -// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterMsgHandlerFromEndpoint instead. -func RegisterMsgHandlerServer(ctx context.Context, mux *runtime.ServeMux, server MsgServer) error { - - mux.Handle("POST", pattern_Msg_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Msg_Handle_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Msg_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -// RegisterMsgHandlerFromEndpoint is same as RegisterMsgHandler but -// automatically dials to "endpoint" and closes the connection when "ctx" gets done. -func RegisterMsgHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.Dial(endpoint, opts...) - if err != nil { - return err - } - defer func() { - if err != nil { - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - return - } - go func() { - <-ctx.Done() - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - }() - }() - - return RegisterMsgHandler(ctx, mux, conn) -} - -// RegisterMsgHandler registers the http handlers for service Msg to "mux". -// The handlers forward requests to the grpc endpoint over "conn". -func RegisterMsgHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { - return RegisterMsgHandlerClient(ctx, mux, NewMsgClient(conn)) -} - -// RegisterMsgHandlerClient registers the http handlers for service Msg -// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "MsgClient". -// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "MsgClient" -// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "MsgClient" to call the correct interceptors. -func RegisterMsgHandlerClient(ctx context.Context, mux *runtime.ServeMux, client MsgClient) error { - - mux.Handle("POST", pattern_Msg_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Msg_Handle_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Msg_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -var ( - pattern_Msg_Handle_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"mantle", "orders", "make"}, "", runtime.AssumeColonVerbOpt(false))) -) - -var ( - forward_Msg_Handle_0 = runtime.ForwardResponseMessage -) diff --git a/x/orders/transactions/make/transaction.go b/x/orders/transactions/make/transaction.go index 8b7bea24c..2680e1763 100644 --- a/x/orders/transactions/make/transaction.go +++ b/x/orders/transactions/make/transaction.go @@ -4,22 +4,14 @@ package make import ( - "context" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "google.golang.org/grpc" - "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/helpers/constants" - "github.com/AssetMantle/modules/utilities/name" + "google.golang.org/grpc" ) -type dummy struct{} - var Transaction = baseHelpers.NewTransaction( - name.GetPackageName(dummy{}), + _Msg_serviceDesc.ServiceName, "", "", @@ -30,9 +22,6 @@ var Transaction = baseHelpers.NewTransaction( func(server grpc.ServiceRegistrar, keeper helpers.TransactionKeeper) { RegisterMsgServer(server, keeper.(transactionKeeper)) }, - func(clientCtx client.Context, mux *runtime.ServeMux) error { - return RegisterMsgHandlerClient(context.Background(), mux, NewMsgClient(clientCtx)) - }, constants.ClassificationID, constants.ExpiresIn, diff --git a/x/orders/transactions/make/transaction_keeper.go b/x/orders/transactions/make/transaction_keeper.go index a78bcbd84..b8236a2fd 100644 --- a/x/orders/transactions/make/transaction_keeper.go +++ b/x/orders/transactions/make/transaction_keeper.go @@ -6,7 +6,6 @@ package make import ( "context" errorConstants "github.com/AssetMantle/modules/helpers/constants" - "github.com/AssetMantle/schema/data" baseData "github.com/AssetMantle/schema/data/base" "github.com/AssetMantle/schema/documents/base" @@ -59,7 +58,7 @@ func (transactionKeeper transactionKeeper) Handle(context context.Context, messa // return nil, err } - fromAddress := message.GetFromAddress() + fromAddress := message.GetSigners()[0] if _, err := transactionKeeper.authenticateAuxiliary.GetKeeper().Help(context, authenticate.NewAuxiliaryRequest(fromAddress, message.FromID)); err != nil { return nil, err diff --git a/x/orders/transactions/make/transaction_request.go b/x/orders/transactions/make/transaction_request.go index 6fe3bce11..73d0b12fe 100644 --- a/x/orders/transactions/make/transaction_request.go +++ b/x/orders/transactions/make/transaction_request.go @@ -5,35 +5,33 @@ package make import ( "encoding/json" - "github.com/AssetMantle/modules/utilities/rest" - - codecUtilities "github.com/AssetMantle/schema/codec/utilities" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" "github.com/AssetMantle/schema/lists/base" baseTypes "github.com/AssetMantle/schema/types/base" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" + "io" + "net/http" "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/helpers/constants" ) type transactionRequest struct { - BaseReq rest.BaseReq `json:"baseReq"` - FromID string `json:"fromID"` - ClassificationID string `json:"classificationID"` - TakerID string `json:"takerID"` - MakerAssetID string `json:"makerAssetID"` - TakerAssetID string `json:"takerAssetID"` - ExpiresIn int64 `json:"expiresIn"` - MakerSplit string `json:"makerSplit"` - TakerSplit string `json:"takerSplit"` - ImmutableMetaProperties string `json:"immutableMetaProperties"` - ImmutableProperties string `json:"immutableProperties"` - MutableMetaProperties string `json:"mutableMetaProperties"` - MutableProperties string `json:"mutableProperties"` + helpers.CommonTransactionRequest `json:"commonTransactionRequest"` + FromID string `json:"fromID"` + ClassificationID string `json:"classificationID"` + TakerID string `json:"takerID"` + MakerAssetID string `json:"makerAssetID"` + TakerAssetID string `json:"takerAssetID"` + ExpiresIn int64 `json:"expiresIn"` + MakerSplit string `json:"makerSplit"` + TakerSplit string `json:"takerSplit"` + ImmutableMetaProperties string `json:"immutableMetaProperties"` + ImmutableProperties string `json:"immutableProperties"` + MutableMetaProperties string `json:"mutableMetaProperties"` + MutableProperties string `json:"mutableProperties"` } var _ helpers.TransactionRequest = (*transactionRequest)(nil) @@ -59,7 +57,7 @@ func (transactionRequest transactionRequest) Validate() error { } func (transactionRequest transactionRequest) FromCLI(cliCommand helpers.CLICommand, context client.Context) (helpers.TransactionRequest, error) { return newTransactionRequest( - cliCommand.ReadBaseReq(context), + cliCommand.ReadCommonTransactionRequest(context), cliCommand.ReadString(constants.FromIdentityID), cliCommand.ReadString(constants.ClassificationID), cliCommand.ReadString(constants.TakerID), @@ -74,19 +72,24 @@ func (transactionRequest transactionRequest) FromCLI(cliCommand helpers.CLIComma cliCommand.ReadString(constants.MutableProperties), ), nil } -func (transactionRequest transactionRequest) FromJSON(rawMessage json.RawMessage) (helpers.TransactionRequest, error) { - if err := json.Unmarshal(rawMessage, &transactionRequest); err != nil { +func (transactionRequest transactionRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.TransactionRequest, error) { + body, err := io.ReadAll(httpRequest.Body) + if err != nil { + return nil, err + } + + if err := json.Unmarshal(body, &transactionRequest); err != nil { return nil, err } return transactionRequest, nil } -func (transactionRequest transactionRequest) GetBaseReq() rest.BaseReq { - return transactionRequest.BaseReq +func (transactionRequest transactionRequest) GetCommonTransactionRequest() helpers.CommonTransactionRequest { + return transactionRequest.CommonTransactionRequest } func (transactionRequest transactionRequest) MakeMsg() (sdkTypes.Msg, error) { - from, err := sdkTypes.AccAddressFromBech32(transactionRequest.GetBaseReq().From) + from, err := sdkTypes.AccAddressFromBech32(transactionRequest.GetCommonTransactionRequest().GetFrom()) if err != nil { return nil, err } @@ -164,27 +167,24 @@ func (transactionRequest transactionRequest) MakeMsg() (sdkTypes.Msg, error) { mutableProperties, ), nil } -func (transactionRequest) RegisterLegacyAminoCodec(legacyAmino *codec.LegacyAmino) { - codecUtilities.RegisterModuleConcrete(legacyAmino, transactionRequest{}) -} func requestPrototype() helpers.TransactionRequest { return transactionRequest{} } -func newTransactionRequest(baseReq rest.BaseReq, fromID string, classificationID string, takerID string, makerAssetID string, takerAssetID string, expiresIn int64, makerSplit, takerSplit string, immutableMetaProperties string, immutableProperties string, mutableMetaProperties string, mutableProperties string) helpers.TransactionRequest { +func newTransactionRequest(commonTransactionRequest helpers.CommonTransactionRequest, fromID string, classificationID string, takerID string, makerAssetID string, takerAssetID string, expiresIn int64, makerSplit, takerSplit string, immutableMetaProperties string, immutableProperties string, mutableMetaProperties string, mutableProperties string) helpers.TransactionRequest { return transactionRequest{ - BaseReq: baseReq, - FromID: fromID, - ClassificationID: classificationID, - TakerID: takerID, - MakerAssetID: makerAssetID, - TakerAssetID: takerAssetID, - ExpiresIn: expiresIn, - MakerSplit: makerSplit, - TakerSplit: takerSplit, - ImmutableMetaProperties: immutableMetaProperties, - ImmutableProperties: immutableProperties, - MutableMetaProperties: mutableMetaProperties, - MutableProperties: mutableProperties, + CommonTransactionRequest: commonTransactionRequest, + FromID: fromID, + ClassificationID: classificationID, + TakerID: takerID, + MakerAssetID: makerAssetID, + TakerAssetID: takerAssetID, + ExpiresIn: expiresIn, + MakerSplit: makerSplit, + TakerSplit: takerSplit, + ImmutableMetaProperties: immutableMetaProperties, + ImmutableProperties: immutableProperties, + MutableMetaProperties: mutableMetaProperties, + MutableProperties: mutableProperties, } } diff --git a/x/orders/transactions/make/transaction_request_test.go b/x/orders/transactions/make/transaction_request_test.go index 9e0ff5e8c..29420b90f 100644 --- a/x/orders/transactions/make/transaction_request_test.go +++ b/x/orders/transactions/make/transaction_request_test.go @@ -4,9 +4,7 @@ package make import ( - "encoding/json" "fmt" - "github.com/AssetMantle/modules/utilities/rest" "reflect" "testing" @@ -16,15 +14,12 @@ import ( baseQualified "github.com/AssetMantle/schema/qualified/base" "github.com/AssetMantle/schema/types/base" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" - "github.com/spf13/viper" - "github.com/stretchr/testify/require" - "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/helpers/constants" + "github.com/spf13/viper" ) var ( @@ -44,7 +39,7 @@ var ( testFromID = baseIDs.NewIdentityID(testClassificationID, immutables).(*baseIDs.IdentityID) makerAssetID = baseDocuments.NewCoinAsset("makerAssetID").GetCoinAssetID() takerAssetID = baseDocuments.NewCoinAsset("takerAssetID").GetCoinAssetID() - testBaseRequest = rest.BaseReq{From: fromAddress, ChainID: "test", Fees: sdkTypes.NewCoins()} + commonTransactionRequest = helpers.PrototypeCommonTransactionRequest() expiresIn = int64(60) makerSplit = sdkTypes.NewInt(60) takerSplit = sdkTypes.NewInt(60) @@ -52,30 +47,30 @@ var ( func Test_newTransactionRequest(t *testing.T) { type args struct { - baseReq rest.BaseReq - fromID string - classificationID string - takerID string - makerAssetID string - takerAssetID string - expiresIn int64 - makerSplit string - takerSplit string - immutableMetaProperties string - immutableProperties string - mutableMetaProperties string - mutableProperties string + commonTransactionRequest helpers.CommonTransactionRequest + fromID string + classificationID string + takerID string + makerAssetID string + takerAssetID string + expiresIn int64 + makerSplit string + takerSplit string + immutableMetaProperties string + immutableProperties string + mutableMetaProperties string + mutableProperties string } tests := []struct { name string args args want helpers.TransactionRequest }{ - {"+ve", args{testBaseRequest, testFromID.AsString(), testClassificationID.AsString(), testFromID.AsString(), makerAssetID.AsString(), takerAssetID.AsString(), expiresIn, makerSplit.String(), takerSplit.String(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, newTransactionRequest(testBaseRequest, testFromID.AsString(), testClassificationID.AsString(), testFromID.AsString(), makerAssetID.AsString(), takerAssetID.AsString(), expiresIn, makerSplit.String(), takerSplit.String(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString)}, + {"+ve", args{commonTransactionRequest, testFromID.AsString(), testClassificationID.AsString(), testFromID.AsString(), makerAssetID.AsString(), takerAssetID.AsString(), expiresIn, makerSplit.String(), takerSplit.String(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, newTransactionRequest(commonTransactionRequest, testFromID.AsString(), testClassificationID.AsString(), testFromID.AsString(), makerAssetID.AsString(), takerAssetID.AsString(), expiresIn, makerSplit.String(), takerSplit.String(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString)}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - if got := newTransactionRequest(tt.args.baseReq, tt.args.fromID, tt.args.classificationID, tt.args.takerID, tt.args.makerAssetID, tt.args.takerAssetID, tt.args.expiresIn, tt.args.makerSplit, tt.args.takerSplit, tt.args.immutableMetaProperties, tt.args.immutableProperties, tt.args.mutableMetaProperties, tt.args.mutableProperties); !reflect.DeepEqual(got, tt.want) { + if got := newTransactionRequest(tt.args.commonTransactionRequest, tt.args.fromID, tt.args.classificationID, tt.args.takerID, tt.args.makerAssetID, tt.args.takerAssetID, tt.args.expiresIn, tt.args.makerSplit, tt.args.takerSplit, tt.args.immutableMetaProperties, tt.args.immutableProperties, tt.args.mutableMetaProperties, tt.args.mutableProperties); !reflect.DeepEqual(got, tt.want) { t.Errorf("newTransactionRequest() = %v, want %v", got, tt.want) } }) @@ -114,19 +109,19 @@ func Test_transactionRequest_FromCLI(t *testing.T) { viper.Set(constants.MutableMetaProperties.GetName(), mutableMetaPropertiesString) viper.Set(constants.MutableProperties.GetName(), mutablePropertiesString) type fields struct { - BaseReq rest.BaseReq - FromID string - ClassificationID string - TakerID string - MakerAssetID string - TakerAssetID string - ExpiresIn int64 - MakerSplit string - TakerSplit string - ImmutableMetaProperties string - ImmutableProperties string - MutableMetaProperties string - MutableProperties string + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + ClassificationID string + TakerID string + MakerAssetID string + TakerAssetID string + ExpiresIn int64 + MakerSplit string + TakerSplit string + ImmutableMetaProperties string + ImmutableProperties string + MutableMetaProperties string + MutableProperties string } type args struct { cliCommand helpers.CLICommand @@ -139,24 +134,24 @@ func Test_transactionRequest_FromCLI(t *testing.T) { want helpers.TransactionRequest wantErr bool }{ - {"+ve", fields{testBaseRequest, testFromID.AsString(), testClassificationID.AsString(), testFromID.AsString(), makerAssetID.AsString(), takerAssetID.AsString(), expiresIn, makerSplit.String(), takerSplit.String(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, args{cliCommand, client.Context{}.WithCodec(baseHelpers.CodecPrototype())}, newTransactionRequest(testBaseRequest, testFromID.AsString(), testClassificationID.AsString(), testFromID.AsString(), makerAssetID.AsString(), takerAssetID.AsString(), expiresIn, makerSplit.String(), takerSplit.String(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString), false}, + {"+ve", fields{commonTransactionRequest, testFromID.AsString(), testClassificationID.AsString(), testFromID.AsString(), makerAssetID.AsString(), takerAssetID.AsString(), expiresIn, makerSplit.String(), takerSplit.String(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, args{cliCommand, client.Context{}.WithCodec(baseHelpers.CodecPrototype())}, newTransactionRequest(commonTransactionRequest, testFromID.AsString(), testClassificationID.AsString(), testFromID.AsString(), makerAssetID.AsString(), takerAssetID.AsString(), expiresIn, makerSplit.String(), takerSplit.String(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString), false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - ClassificationID: tt.fields.ClassificationID, - TakerID: tt.fields.TakerID, - MakerAssetID: tt.fields.MakerAssetID, - TakerAssetID: tt.fields.TakerAssetID, - ExpiresIn: tt.fields.ExpiresIn, - MakerSplit: tt.fields.MakerSplit, - TakerSplit: tt.fields.TakerSplit, - ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, - ImmutableProperties: tt.fields.ImmutableProperties, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + ClassificationID: tt.fields.ClassificationID, + TakerID: tt.fields.TakerID, + MakerAssetID: tt.fields.MakerAssetID, + TakerAssetID: tt.fields.TakerAssetID, + ExpiresIn: tt.fields.ExpiresIn, + MakerSplit: tt.fields.MakerSplit, + TakerSplit: tt.fields.TakerSplit, + ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, + ImmutableProperties: tt.fields.ImmutableProperties, + MutableMetaProperties: tt.fields.MutableMetaProperties, + MutableProperties: tt.fields.MutableProperties, } got, err := transactionRequest.FromCLI(tt.args.cliCommand, tt.args.context) if (err != nil) != tt.wantErr { @@ -170,107 +165,48 @@ func Test_transactionRequest_FromCLI(t *testing.T) { } } -func Test_transactionRequest_FromJSON(t *testing.T) { - jsonMessage, err := json.Marshal(newTransactionRequest(testBaseRequest, testFromID.AsString(), testClassificationID.AsString(), testFromID.AsString(), makerAssetID.AsString(), takerAssetID.AsString(), expiresIn, makerSplit.String(), takerSplit.String(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString)) - require.NoError(t, err) - type fields struct { - BaseReq rest.BaseReq - FromID string - ClassificationID string - TakerID string - MakerAssetID string - TakerAssetID string - ExpiresIn int64 - MakerSplit string - TakerSplit string - ImmutableMetaProperties string - ImmutableProperties string - MutableMetaProperties string - MutableProperties string - } - type args struct { - rawMessage json.RawMessage - } - tests := []struct { - name string - fields fields - args args - want helpers.TransactionRequest - wantErr bool - }{ - {"+ve", fields{testBaseRequest, testFromID.AsString(), testClassificationID.AsString(), testFromID.AsString(), makerAssetID.AsString(), takerAssetID.AsString(), expiresIn, makerSplit.String(), takerSplit.String(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, args{jsonMessage}, newTransactionRequest(testBaseRequest, testFromID.AsString(), testClassificationID.AsString(), testFromID.AsString(), makerAssetID.AsString(), takerAssetID.AsString(), expiresIn, makerSplit.String(), takerSplit.String(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString), false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - ClassificationID: tt.fields.ClassificationID, - TakerID: tt.fields.TakerID, - MakerAssetID: tt.fields.MakerAssetID, - TakerAssetID: tt.fields.TakerAssetID, - ExpiresIn: tt.fields.ExpiresIn, - MakerSplit: tt.fields.MakerSplit, - TakerSplit: tt.fields.TakerSplit, - ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, - ImmutableProperties: tt.fields.ImmutableProperties, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, - } - got, err := transactionRequest.FromJSON(tt.args.rawMessage) - if (err != nil) != tt.wantErr { - t.Errorf("FromJSON() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("FromJSON() got = %v, want %v", got, tt.want) - } - }) - } -} - func Test_transactionRequest_GetBaseReq(t *testing.T) { type fields struct { - BaseReq rest.BaseReq - FromID string - ClassificationID string - TakerID string - MakerAssetID string - TakerAssetID string - ExpiresIn int64 - MakerSplit string - TakerSplit string - ImmutableMetaProperties string - ImmutableProperties string - MutableMetaProperties string - MutableProperties string + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + ClassificationID string + TakerID string + MakerAssetID string + TakerAssetID string + ExpiresIn int64 + MakerSplit string + TakerSplit string + ImmutableMetaProperties string + ImmutableProperties string + MutableMetaProperties string + MutableProperties string } tests := []struct { name string fields fields - want rest.BaseReq + want helpers.CommonTransactionRequest }{ - {"+ve", fields{testBaseRequest, testFromID.AsString(), testClassificationID.AsString(), testFromID.AsString(), makerAssetID.AsString(), takerAssetID.AsString(), expiresIn, makerSplit.String(), takerSplit.String(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, testBaseRequest}, + {"+ve", fields{commonTransactionRequest, testFromID.AsString(), testClassificationID.AsString(), testFromID.AsString(), makerAssetID.AsString(), takerAssetID.AsString(), expiresIn, makerSplit.String(), takerSplit.String(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, commonTransactionRequest}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - ClassificationID: tt.fields.ClassificationID, - TakerID: tt.fields.TakerID, - MakerAssetID: tt.fields.MakerAssetID, - TakerAssetID: tt.fields.TakerAssetID, - ExpiresIn: tt.fields.ExpiresIn, - MakerSplit: tt.fields.MakerSplit, - TakerSplit: tt.fields.TakerSplit, - ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, - ImmutableProperties: tt.fields.ImmutableProperties, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + ClassificationID: tt.fields.ClassificationID, + TakerID: tt.fields.TakerID, + MakerAssetID: tt.fields.MakerAssetID, + TakerAssetID: tt.fields.TakerAssetID, + ExpiresIn: tt.fields.ExpiresIn, + MakerSplit: tt.fields.MakerSplit, + TakerSplit: tt.fields.TakerSplit, + ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, + ImmutableProperties: tt.fields.ImmutableProperties, + MutableMetaProperties: tt.fields.MutableMetaProperties, + MutableProperties: tt.fields.MutableProperties, } - if got := transactionRequest.GetBaseReq(); !reflect.DeepEqual(got, tt.want) { - t.Errorf("GetBaseReq() = %v, want %v", got, tt.want) + if got := transactionRequest.GetCommonTransactionRequest(); !reflect.DeepEqual(got, tt.want) { + t.Errorf("GetCommonTransactionRequest() = %v, want %v", got, tt.want) } }) } @@ -278,19 +214,19 @@ func Test_transactionRequest_GetBaseReq(t *testing.T) { func Test_transactionRequest_MakeMsg(t *testing.T) { type fields struct { - BaseReq rest.BaseReq - FromID string - ClassificationID string - TakerID string - MakerAssetID string - TakerAssetID string - ExpiresIn int64 - MakerSplit string - TakerSplit string - ImmutableMetaProperties string - ImmutableProperties string - MutableMetaProperties string - MutableProperties string + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + ClassificationID string + TakerID string + MakerAssetID string + TakerAssetID string + ExpiresIn int64 + MakerSplit string + TakerSplit string + ImmutableMetaProperties string + ImmutableProperties string + MutableMetaProperties string + MutableProperties string } tests := []struct { name string @@ -298,24 +234,24 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { want sdkTypes.Msg wantErr bool }{ - {"+ve", fields{testBaseRequest, testFromID.AsString(), testClassificationID.AsString(), testFromID.AsString(), makerAssetID.AsString(), takerAssetID.AsString(), expiresIn, makerSplit.String(), takerSplit.String(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, NewMessage(fromAccAddress, testFromID, testClassificationID, testFromID, makerAssetID, takerAssetID, base.NewHeight(60), makerSplit, takerSplit, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties), false}, + {"+ve", fields{commonTransactionRequest, testFromID.AsString(), testClassificationID.AsString(), testFromID.AsString(), makerAssetID.AsString(), takerAssetID.AsString(), expiresIn, makerSplit.String(), takerSplit.String(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, NewMessage(fromAccAddress, testFromID, testClassificationID, testFromID, makerAssetID, takerAssetID, base.NewHeight(60), makerSplit, takerSplit, immutableMetaProperties, immutableProperties, mutableMetaProperties, mutableProperties), false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - ClassificationID: tt.fields.ClassificationID, - TakerID: tt.fields.TakerID, - MakerAssetID: tt.fields.MakerAssetID, - TakerAssetID: tt.fields.TakerAssetID, - ExpiresIn: tt.fields.ExpiresIn, - MakerSplit: tt.fields.MakerSplit, - TakerSplit: tt.fields.TakerSplit, - ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, - ImmutableProperties: tt.fields.ImmutableProperties, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + ClassificationID: tt.fields.ClassificationID, + TakerID: tt.fields.TakerID, + MakerAssetID: tt.fields.MakerAssetID, + TakerAssetID: tt.fields.TakerAssetID, + ExpiresIn: tt.fields.ExpiresIn, + MakerSplit: tt.fields.MakerSplit, + TakerSplit: tt.fields.TakerSplit, + ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, + ImmutableProperties: tt.fields.ImmutableProperties, + MutableMetaProperties: tt.fields.MutableMetaProperties, + MutableProperties: tt.fields.MutableProperties, } got, err := transactionRequest.MakeMsg() if (err != nil) != tt.wantErr { @@ -329,93 +265,45 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { } } -func Test_transactionRequest_RegisterCodec(t *testing.T) { - type fields struct { - BaseReq rest.BaseReq - FromID string - ClassificationID string - TakerID string - MakerAssetID string - TakerAssetID string - ExpiresIn int64 - MakerSplit string - TakerSplit string - ImmutableMetaProperties string - ImmutableProperties string - MutableMetaProperties string - MutableProperties string - } - type args struct { - legacyAmino *codec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{testBaseRequest, testFromID.AsString(), testClassificationID.AsString(), testFromID.AsString(), makerAssetID.AsString(), takerAssetID.AsString(), expiresIn, makerSplit.String(), takerSplit.String(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, args{codec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - tr := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - ClassificationID: tt.fields.ClassificationID, - TakerID: tt.fields.TakerID, - MakerAssetID: tt.fields.MakerAssetID, - TakerAssetID: tt.fields.TakerAssetID, - ExpiresIn: tt.fields.ExpiresIn, - MakerSplit: tt.fields.MakerSplit, - TakerSplit: tt.fields.TakerSplit, - ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, - ImmutableProperties: tt.fields.ImmutableProperties, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, - } - tr.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - func Test_transactionRequest_Validate(t *testing.T) { type fields struct { - BaseReq rest.BaseReq - FromID string - ClassificationID string - TakerID string - MakerAssetID string - TakerAssetID string - ExpiresIn int64 - MakerSplit string - TakerSplit string - ImmutableMetaProperties string - ImmutableProperties string - MutableMetaProperties string - MutableProperties string + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + ClassificationID string + TakerID string + MakerAssetID string + TakerAssetID string + ExpiresIn int64 + MakerSplit string + TakerSplit string + ImmutableMetaProperties string + ImmutableProperties string + MutableMetaProperties string + MutableProperties string } tests := []struct { name string fields fields wantErr bool }{ - {"+ve", fields{testBaseRequest, testFromID.AsString(), testClassificationID.AsString(), testFromID.AsString(), makerAssetID.AsString(), takerAssetID.AsString(), expiresIn, makerSplit.String(), takerSplit.String(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, false}, + {"+ve", fields{commonTransactionRequest, testFromID.AsString(), testClassificationID.AsString(), testFromID.AsString(), makerAssetID.AsString(), takerAssetID.AsString(), expiresIn, makerSplit.String(), takerSplit.String(), immutableMetaPropertiesString, immutablePropertiesString, mutableMetaPropertiesString, mutablePropertiesString}, false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - ClassificationID: tt.fields.ClassificationID, - TakerID: tt.fields.TakerID, - MakerAssetID: tt.fields.MakerAssetID, - TakerAssetID: tt.fields.TakerAssetID, - ExpiresIn: tt.fields.ExpiresIn, - MakerSplit: tt.fields.MakerSplit, - TakerSplit: tt.fields.TakerSplit, - ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, - ImmutableProperties: tt.fields.ImmutableProperties, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + ClassificationID: tt.fields.ClassificationID, + TakerID: tt.fields.TakerID, + MakerAssetID: tt.fields.MakerAssetID, + TakerAssetID: tt.fields.TakerAssetID, + ExpiresIn: tt.fields.ExpiresIn, + MakerSplit: tt.fields.MakerSplit, + TakerSplit: tt.fields.TakerSplit, + ImmutableMetaProperties: tt.fields.ImmutableMetaProperties, + ImmutableProperties: tt.fields.ImmutableProperties, + MutableMetaProperties: tt.fields.MutableMetaProperties, + MutableProperties: tt.fields.MutableProperties, } if err := transactionRequest.Validate(); (err != nil) != tt.wantErr { t.Errorf("ValidateBasic() error = %v, wantErr %v", err, tt.wantErr) diff --git a/x/orders/transactions/make/transaction_response.go b/x/orders/transactions/make/transaction_response.go index 0f646fcce..34767a9c1 100644 --- a/x/orders/transactions/make/transaction_response.go +++ b/x/orders/transactions/make/transaction_response.go @@ -4,11 +4,10 @@ package make import ( + "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" sdkTypes "github.com/cosmos/cosmos-sdk/types" - - "github.com/AssetMantle/modules/helpers" ) var _ helpers.TransactionResponse = (*TransactionResponse)(nil) diff --git a/x/orders/transactions/modify/message.go b/x/orders/transactions/modify/message.go index ee38db03f..480ef6d90 100644 --- a/x/orders/transactions/modify/message.go +++ b/x/orders/transactions/modify/message.go @@ -4,31 +4,20 @@ package modify import ( + "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/helpers/constants" - codecUtilities "github.com/AssetMantle/schema/codec/utilities" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" "github.com/AssetMantle/schema/lists" baseLists "github.com/AssetMantle/schema/lists/base" typesSchema "github.com/AssetMantle/schema/types" baseTypes "github.com/AssetMantle/schema/types/base" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/types" sdkTypes "github.com/cosmos/cosmos-sdk/types" - - "github.com/AssetMantle/modules/helpers" ) var _ helpers.Message = (*Message)(nil) -func (message *Message) Type() string { return Transaction.GetName() } -func (message *Message) GetFromAddress() sdkTypes.AccAddress { - from, err := sdkTypes.AccAddressFromBech32(message.From) - if err != nil { - panic(err) - } - return from -} func (message *Message) ValidateBasic() error { if _, err := sdkTypes.AccAddressFromBech32(message.From); err != nil { return err @@ -62,21 +51,10 @@ func (message *Message) GetSigners() []sdkTypes.AccAddress { } return []sdkTypes.AccAddress{from} } -func (*Message) RegisterLegacyAminoCodec(legacyAmino *codec.LegacyAmino) { - codecUtilities.RegisterModuleConcrete(legacyAmino, Message{}) -} func (message *Message) RegisterInterface(interfaceRegistry types.InterfaceRegistry) { interfaceRegistry.RegisterImplementations((*sdkTypes.Msg)(nil), message) } -func messageFromInterface(msg sdkTypes.Msg) *Message { - switch value := msg.(type) { - case *Message: - return value - default: - return &Message{} - } -} func messagePrototype() helpers.Message { return &Message{} } diff --git a/x/orders/transactions/modify/message_test.go b/x/orders/transactions/modify/message_test.go index 49b5f08a0..3c2211c1f 100644 --- a/x/orders/transactions/modify/message_test.go +++ b/x/orders/transactions/modify/message_test.go @@ -13,7 +13,6 @@ import ( baseLists "github.com/AssetMantle/schema/lists/base" "github.com/AssetMantle/schema/types" "github.com/AssetMantle/schema/types/base" - "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" "github.com/AssetMantle/modules/helpers" @@ -35,26 +34,6 @@ type fields struct { MutableProperties *baseLists.PropertyList } -func Test_messageFromInterface(t *testing.T) { - type args struct { - msg sdkTypes.Msg - } - tests := []struct { - name string - args args - want *Message - }{ - {"+ve", args{testMessage}, &Message{fromAccAddress.String(), testFromID, testOrderID, takerSplit.String(), makerSplit.String(), expiresInHeight, mutableMetaProperties.(*baseLists.PropertyList), mutableProperties.(*baseLists.PropertyList)}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := messageFromInterface(tt.args.msg); !reflect.DeepEqual(got, tt.want) { - t.Errorf("messageFromInterface() = %v, want %v", got, tt.want) - } - }) - } -} - func Test_messagePrototype(t *testing.T) { tests := []struct { name string @@ -99,63 +78,6 @@ func Test_message_GetSigners(t *testing.T) { } } -func Test_message_RegisterCodec(t *testing.T) { - - type args struct { - legacyAmino *codec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{fromAccAddress.String(), testFromID, testOrderID, takerSplit, makerSplit, expiresInHeight, mutableMetaProperties.(*baseLists.PropertyList), mutableProperties.(*baseLists.PropertyList)}, args{codec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - me := &Message{ - From: tt.fields.From, - FromID: tt.fields.FromID, - OrderID: tt.fields.OrderID, - MakerSplit: tt.fields.MakerSplit.String(), - TakerSplit: tt.fields.TakerSplit.String(), - ExpiresIn: tt.fields.ExpiresIn, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, - } - me.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - -func Test_message_Type(t *testing.T) { - - tests := []struct { - name string - fields fields - want string - }{ - {"+ve", fields{fromAccAddress.String(), testFromID, testOrderID, takerSplit, makerSplit, expiresInHeight, mutableMetaProperties.(*baseLists.PropertyList), mutableProperties.(*baseLists.PropertyList)}, Transaction.GetName()}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - message := &Message{ - From: tt.fields.From, - FromID: tt.fields.FromID, - OrderID: tt.fields.OrderID, - MakerSplit: tt.fields.MakerSplit.String(), - TakerSplit: tt.fields.TakerSplit.String(), - ExpiresIn: tt.fields.ExpiresIn, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, - } - if got := message.Type(); got != tt.want { - t.Errorf("Type() = %v, want %v", got, tt.want) - } - }) - } -} - func Test_message_ValidateBasic(t *testing.T) { tests := []struct { diff --git a/x/orders/transactions/modify/service.pb.go b/x/orders/transactions/modify/service.pb.go index fb898bf22..7829f0aa6 100644 --- a/x/orders/transactions/modify/service.pb.go +++ b/x/orders/transactions/modify/service.pb.go @@ -6,9 +6,9 @@ package modify import ( context "context" fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types/msgservice" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" - _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -31,30 +31,30 @@ func init() { } var fileDescriptor_8ff4398d92b669f7 = []byte{ - // 364 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0xd2, 0x4f, 0x4b, 0xf3, 0x30, - 0x1c, 0x07, 0xf0, 0xb5, 0x83, 0x1d, 0xca, 0x73, 0x1a, 0x3c, 0x08, 0x45, 0x7b, 0xd8, 0x0b, 0x48, - 0xc4, 0x3f, 0x07, 0xa3, 0x08, 0x1b, 0x88, 0x82, 0x84, 0x0d, 0xdd, 0xa1, 0x48, 0x41, 0xb2, 0x36, - 0xab, 0x85, 0x36, 0x19, 0x4d, 0x26, 0xdb, 0x51, 0x5f, 0x81, 0xe0, 0x3b, 0xf0, 0xa6, 0x37, 0xdf, - 0x85, 0x78, 0x1a, 0x78, 0xf1, 0x28, 0x9d, 0x27, 0x5f, 0x85, 0xac, 0x09, 0x98, 0x1d, 0x73, 0x4d, - 0xfa, 0xf9, 0xf2, 0xfd, 0xa5, 0x3f, 0xef, 0xb8, 0x2b, 0x04, 0x95, 0x98, 0x30, 0x99, 0x53, 0x58, - 0xf0, 0x64, 0x9a, 0x53, 0x01, 0x67, 0x90, 0x97, 0x09, 0x2d, 0x05, 0x94, 0x25, 0x61, 0x82, 0xc4, - 0x32, 0xe3, 0x4c, 0xac, 0x6e, 0xb3, 0xf1, 0x1c, 0x0a, 0x5a, 0xde, 0x66, 0x31, 0x05, 0x93, 0x92, - 0x4b, 0xde, 0xde, 0x36, 0x3c, 0xd0, 0x1e, 0xcc, 0x80, 0xf2, 0xc0, 0xf4, 0x40, 0x79, 0x7f, 0x33, - 0xe5, 0x3c, 0xcd, 0x29, 0x24, 0x93, 0x0c, 0x12, 0xc6, 0xb8, 0x24, 0xea, 0xba, 0xce, 0xf3, 0xed, - 0xfb, 0x14, 0x54, 0x08, 0x92, 0xea, 0x3e, 0xfe, 0xb9, 0xb5, 0x37, 0xce, 0xae, 0x4b, 0x2a, 0x26, - 0x9c, 0x09, 0x1d, 0xb6, 0xf3, 0xea, 0x78, 0x4d, 0x2c, 0xd2, 0xf6, 0xb3, 0xe3, 0xb5, 0xce, 0x08, - 0x4b, 0x72, 0xda, 0x3e, 0x00, 0xb6, 0x03, 0x03, 0xac, 0x0a, 0xfa, 0x27, 0xf6, 0x74, 0xf8, 0x77, - 0x76, 0xa1, 0xab, 0x75, 0xb6, 0xee, 0x3f, 0xbe, 0x1f, 0xdd, 0x8d, 0xce, 0x7f, 0x58, 0xa8, 0x29, - 0xf5, 0x6c, 0x8a, 0xf4, 0xee, 0x9a, 0x6f, 0x55, 0xe0, 0x2c, 0xaa, 0xc0, 0xf9, 0xaa, 0x02, 0xe7, - 0x61, 0x19, 0x34, 0x16, 0xcb, 0xa0, 0xf1, 0xb9, 0x0c, 0x1a, 0xde, 0x5e, 0xcc, 0x0b, 0xeb, 0x0e, - 0xbd, 0x7f, 0x97, 0xea, 0x87, 0x0f, 0x56, 0x4f, 0x32, 0x70, 0xae, 0x0e, 0xd3, 0x4c, 0xde, 0x4c, - 0x47, 0x20, 0xe6, 0x05, 0xb4, 0x7d, 0xec, 0x27, 0xb7, 0xd5, 0xc5, 0x61, 0x7f, 0x88, 0x5f, 0xdc, - 0xb5, 0xc5, 0xc1, 0xba, 0x48, 0x08, 0xfa, 0xaa, 0xc8, 0xd0, 0x2c, 0x82, 0x6b, 0xfb, 0xbe, 0x46, - 0x22, 0x4d, 0xa2, 0x30, 0x52, 0x24, 0x32, 0x49, 0xa4, 0x48, 0xe5, 0x1e, 0xd9, 0x92, 0xe8, 0x74, - 0xd0, 0xc3, 0x54, 0x92, 0x84, 0x48, 0xf2, 0xe3, 0xee, 0x1b, 0x1c, 0x21, 0xed, 0x11, 0x0a, 0x11, - 0x52, 0x09, 0x08, 0x99, 0x11, 0xf5, 0x17, 0xd9, 0x78, 0x3e, 0x6a, 0xd5, 0xeb, 0xb3, 0xfb, 0x1b, - 0x00, 0x00, 0xff, 0xff, 0x21, 0xe2, 0xed, 0x06, 0x5d, 0x03, 0x00, 0x00, + // 355 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0xd2, 0xbf, 0x4b, 0xf3, 0x40, + 0x18, 0x07, 0xf0, 0x24, 0xe5, 0xed, 0x10, 0xde, 0xa9, 0xcb, 0x0b, 0x19, 0x32, 0xbc, 0xa3, 0xc3, + 0x9d, 0x3f, 0x07, 0x4f, 0x11, 0x5a, 0x10, 0x05, 0x39, 0x5a, 0xb4, 0x43, 0x90, 0x80, 0x5c, 0x93, + 0x6b, 0x0c, 0x34, 0xb9, 0x92, 0xe7, 0x5a, 0xda, 0x4d, 0x77, 0x07, 0x77, 0x37, 0x47, 0x27, 0xff, + 0x0c, 0x71, 0xea, 0xe8, 0x28, 0xe9, 0x20, 0xf8, 0x57, 0x48, 0x7b, 0x07, 0x5e, 0xc7, 0x9b, 0x02, + 0x97, 0x7c, 0xbe, 0xf9, 0x3e, 0xc9, 0xe3, 0x9f, 0xb4, 0x01, 0xb8, 0xa4, 0xac, 0x94, 0x23, 0x8e, + 0x0b, 0x91, 0x4e, 0x46, 0x1c, 0xf0, 0x0c, 0x8b, 0x2a, 0xe5, 0x15, 0x60, 0x59, 0xb1, 0x12, 0x58, + 0x22, 0x73, 0x51, 0xc2, 0xea, 0x6e, 0x3e, 0x9c, 0x63, 0xe0, 0xd5, 0x34, 0x4f, 0x38, 0x1a, 0x57, + 0x42, 0x8a, 0xd6, 0xb6, 0xe1, 0x91, 0xf6, 0x68, 0x86, 0x94, 0x47, 0xa6, 0x47, 0xca, 0x07, 0xff, + 0x12, 0x01, 0x85, 0x00, 0x5c, 0x40, 0x86, 0xa7, 0x3b, 0xab, 0x8b, 0x8a, 0x0a, 0xec, 0xab, 0x14, + 0x1c, 0x80, 0x65, 0xba, 0x4a, 0x70, 0x61, 0xed, 0x8d, 0xb3, 0x9b, 0x8a, 0xc3, 0x58, 0x94, 0xa0, + 0xc3, 0x76, 0x9f, 0x5c, 0xbf, 0x41, 0x21, 0x6b, 0x3d, 0xb8, 0x7e, 0xf3, 0x9c, 0x95, 0xe9, 0x88, + 0xb7, 0x0e, 0x91, 0xed, 0xac, 0x88, 0xaa, 0x82, 0xc1, 0xa9, 0x3d, 0xed, 0xff, 0x9e, 0x5d, 0xea, + 0x6a, 0xff, 0x9d, 0xe0, 0xcf, 0xdd, 0xd7, 0xeb, 0x96, 0xdb, 0xb9, 0x6f, 0xbc, 0xd5, 0xa1, 0xbb, + 0xa8, 0x43, 0xf7, 0xb3, 0x0e, 0xdd, 0xc7, 0x65, 0xe8, 0x2c, 0x96, 0xa1, 0xf3, 0xb1, 0x0c, 0x1d, + 0x7f, 0x3f, 0x11, 0x85, 0xf5, 0xdb, 0x3a, 0x7f, 0xaf, 0xd4, 0x5f, 0xed, 0xad, 0x86, 0xef, 0xb9, + 0xd7, 0x47, 0x59, 0x2e, 0x6f, 0x27, 0x03, 0x94, 0x88, 0x02, 0xdb, 0x7e, 0xd6, 0x67, 0xaf, 0xd9, + 0xa6, 0x51, 0xb7, 0x4f, 0x5f, 0xbc, 0x8d, 0xed, 0xa0, 0xba, 0x48, 0x84, 0xba, 0xaa, 0x48, 0xdf, + 0x2c, 0x42, 0xd7, 0xf6, 0x7d, 0x83, 0xc4, 0x9a, 0xc4, 0x51, 0xac, 0x48, 0x6c, 0x92, 0x58, 0x91, + 0xda, 0x3b, 0xb6, 0x25, 0xf1, 0x59, 0xaf, 0x43, 0xb9, 0x64, 0x29, 0x93, 0xec, 0xdb, 0x3b, 0x30, + 0x38, 0x21, 0xda, 0x13, 0x12, 0x11, 0xa2, 0x12, 0x08, 0x31, 0x23, 0xd6, 0x4f, 0xe4, 0xc3, 0xf9, + 0xa0, 0xb9, 0x5e, 0x94, 0xbd, 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xc3, 0x98, 0x4d, 0x5b, 0x42, + 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/orders/transactions/modify/service.pb.gw.go b/x/orders/transactions/modify/service.pb.gw.go deleted file mode 100644 index aa9a824fb..000000000 --- a/x/orders/transactions/modify/service.pb.gw.go +++ /dev/null @@ -1,171 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: AssetMantle/modules/x/orders/transactions/modify/service.proto - -/* -Package modify is a reverse proxy. - -It translates gRPC into RESTful JSON APIs. -*/ -package modify - -import ( - "context" - "io" - "net/http" - - "github.com/golang/protobuf/descriptor" - "github.com/golang/protobuf/proto" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/grpc-ecosystem/grpc-gateway/utilities" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/status" -) - -// Suppress "imported and not used" errors -var _ codes.Code -var _ io.Reader -var _ status.Status -var _ = runtime.String -var _ = utilities.NewDoubleArray -var _ = descriptor.ForMessage -var _ = metadata.Join - -var ( - filter_Msg_Handle_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - -func request_Msg_Handle_0(ctx context.Context, marshaler runtime.Marshaler, client MsgClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq Message - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.Handle(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Msg_Handle_0(ctx context.Context, marshaler runtime.Marshaler, server MsgServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq Message - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.Handle(ctx, &protoReq) - return msg, metadata, err - -} - -// RegisterMsgHandlerServer registers the http handlers for service Msg to "mux". -// UnaryRPC :call MsgServer directly. -// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterMsgHandlerFromEndpoint instead. -func RegisterMsgHandlerServer(ctx context.Context, mux *runtime.ServeMux, server MsgServer) error { - - mux.Handle("POST", pattern_Msg_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Msg_Handle_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Msg_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -// RegisterMsgHandlerFromEndpoint is same as RegisterMsgHandler but -// automatically dials to "endpoint" and closes the connection when "ctx" gets done. -func RegisterMsgHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.Dial(endpoint, opts...) - if err != nil { - return err - } - defer func() { - if err != nil { - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - return - } - go func() { - <-ctx.Done() - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - }() - }() - - return RegisterMsgHandler(ctx, mux, conn) -} - -// RegisterMsgHandler registers the http handlers for service Msg to "mux". -// The handlers forward requests to the grpc endpoint over "conn". -func RegisterMsgHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { - return RegisterMsgHandlerClient(ctx, mux, NewMsgClient(conn)) -} - -// RegisterMsgHandlerClient registers the http handlers for service Msg -// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "MsgClient". -// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "MsgClient" -// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "MsgClient" to call the correct interceptors. -func RegisterMsgHandlerClient(ctx context.Context, mux *runtime.ServeMux, client MsgClient) error { - - mux.Handle("POST", pattern_Msg_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Msg_Handle_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Msg_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -var ( - pattern_Msg_Handle_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"mantle", "orders", "modify"}, "", runtime.AssumeColonVerbOpt(false))) -) - -var ( - forward_Msg_Handle_0 = runtime.ForwardResponseMessage -) diff --git a/x/orders/transactions/modify/transaction.go b/x/orders/transactions/modify/transaction.go index d053218b9..f3fc561a3 100644 --- a/x/orders/transactions/modify/transaction.go +++ b/x/orders/transactions/modify/transaction.go @@ -4,22 +4,14 @@ package modify import ( - "context" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "google.golang.org/grpc" - "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/helpers/constants" - "github.com/AssetMantle/modules/utilities/name" + "google.golang.org/grpc" ) -type dummy struct{} - var Transaction = baseHelpers.NewTransaction( - name.GetPackageName(dummy{}), + _Msg_serviceDesc.ServiceName, "", "", @@ -30,9 +22,6 @@ var Transaction = baseHelpers.NewTransaction( func(server grpc.ServiceRegistrar, keeper helpers.TransactionKeeper) { RegisterMsgServer(server, keeper.(transactionKeeper)) }, - func(clientCtx client.Context, mux *runtime.ServeMux) error { - return RegisterMsgHandlerClient(context.Background(), mux, NewMsgClient(clientCtx)) - }, constants.FromIdentityID, constants.OrderID, diff --git a/x/orders/transactions/modify/transaction_keeper.go b/x/orders/transactions/modify/transaction_keeper.go index a0c55fcb6..4f408f346 100644 --- a/x/orders/transactions/modify/transaction_keeper.go +++ b/x/orders/transactions/modify/transaction_keeper.go @@ -6,7 +6,6 @@ package modify import ( "context" errorConstants "github.com/AssetMantle/modules/helpers/constants" - baseData "github.com/AssetMantle/schema/data/base" "github.com/AssetMantle/schema/documents/base" baseLists "github.com/AssetMantle/schema/lists/base" @@ -42,7 +41,7 @@ func (transactionKeeper transactionKeeper) Transact(context context.Context, mes } func (transactionKeeper transactionKeeper) Handle(context context.Context, message *Message) (*TransactionResponse, error) { - fromAddress := message.GetFromAddress() + fromAddress := message.GetSigners()[0] if _, err := transactionKeeper.authenticateAuxiliary.GetKeeper().Help(context, authenticate.NewAuxiliaryRequest(fromAddress, message.FromID)); err != nil { return nil, err diff --git a/x/orders/transactions/modify/transaction_request.go b/x/orders/transactions/modify/transaction_request.go index 08e65b30b..0eae5dd1b 100644 --- a/x/orders/transactions/modify/transaction_request.go +++ b/x/orders/transactions/modify/transaction_request.go @@ -5,30 +5,28 @@ package modify import ( "encoding/json" - "github.com/AssetMantle/modules/utilities/rest" - - codecUtilities "github.com/AssetMantle/schema/codec/utilities" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" "github.com/AssetMantle/schema/lists/base" baseTypes "github.com/AssetMantle/schema/types/base" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" + "io" + "net/http" "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/helpers/constants" ) type transactionRequest struct { - BaseReq rest.BaseReq `json:"baseReq"` - FromID string `json:"fromID"` - OrderID string `json:"orderID"` - TakerSplit string `json:"takerSplit"` - MakerSplit string `json:"makerSplit"` - ExpiresIn int64 `json:"expiresIn"` - MutableMetaProperties string `json:"mutableMetaProperties"` - MutableProperties string `json:"mutableProperties"` + helpers.CommonTransactionRequest `json:"commonTransactionRequest"` + FromID string `json:"fromID"` + OrderID string `json:"orderID"` + TakerSplit string `json:"takerSplit"` + MakerSplit string `json:"makerSplit"` + ExpiresIn int64 `json:"expiresIn"` + MutableMetaProperties string `json:"mutableMetaProperties"` + MutableProperties string `json:"mutableProperties"` } var _ helpers.TransactionRequest = (*transactionRequest)(nil) @@ -54,7 +52,7 @@ func (transactionRequest transactionRequest) Validate() error { } func (transactionRequest transactionRequest) FromCLI(cliCommand helpers.CLICommand, context client.Context) (helpers.TransactionRequest, error) { return newTransactionRequest( - cliCommand.ReadBaseReq(context), + cliCommand.ReadCommonTransactionRequest(context), cliCommand.ReadString(constants.FromIdentityID), cliCommand.ReadString(constants.OrderID), cliCommand.ReadString(constants.TakerSplit), @@ -64,19 +62,24 @@ func (transactionRequest transactionRequest) FromCLI(cliCommand helpers.CLIComma cliCommand.ReadString(constants.MutableProperties), ), nil } -func (transactionRequest transactionRequest) FromJSON(rawMessage json.RawMessage) (helpers.TransactionRequest, error) { - if err := json.Unmarshal(rawMessage, &transactionRequest); err != nil { +func (transactionRequest transactionRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.TransactionRequest, error) { + body, err := io.ReadAll(httpRequest.Body) + if err != nil { + return nil, err + } + + if err := json.Unmarshal(body, &transactionRequest); err != nil { return nil, err } return transactionRequest, nil } -func (transactionRequest transactionRequest) GetBaseReq() rest.BaseReq { - return transactionRequest.BaseReq +func (transactionRequest transactionRequest) GetCommonTransactionRequest() helpers.CommonTransactionRequest { + return transactionRequest.CommonTransactionRequest } func (transactionRequest transactionRequest) MakeMsg() (sdkTypes.Msg, error) { - from, err := sdkTypes.AccAddressFromBech32(transactionRequest.GetBaseReq().From) + from, err := sdkTypes.AccAddressFromBech32(transactionRequest.GetCommonTransactionRequest().GetFrom()) if err != nil { return nil, err } @@ -123,22 +126,19 @@ func (transactionRequest transactionRequest) MakeMsg() (sdkTypes.Msg, error) { mutableProperties, ), nil } -func (transactionRequest) RegisterLegacyAminoCodec(legacyAmino *codec.LegacyAmino) { - codecUtilities.RegisterModuleConcrete(legacyAmino, transactionRequest{}) -} func requestPrototype() helpers.TransactionRequest { return transactionRequest{} } -func newTransactionRequest(baseReq rest.BaseReq, fromID string, orderID string, takerSplit string, makerSplit string, expiresIn int64, mutableMetaProperties string, mutableProperties string) helpers.TransactionRequest { +func newTransactionRequest(commonTransactionRequest helpers.CommonTransactionRequest, fromID string, orderID string, takerSplit string, makerSplit string, expiresIn int64, mutableMetaProperties string, mutableProperties string) helpers.TransactionRequest { return transactionRequest{ - BaseReq: baseReq, - FromID: fromID, - OrderID: orderID, - TakerSplit: takerSplit, - MakerSplit: makerSplit, - ExpiresIn: expiresIn, - MutableMetaProperties: mutableMetaProperties, - MutableProperties: mutableProperties, + CommonTransactionRequest: commonTransactionRequest, + FromID: fromID, + OrderID: orderID, + TakerSplit: takerSplit, + MakerSplit: makerSplit, + ExpiresIn: expiresIn, + MutableMetaProperties: mutableMetaProperties, + MutableProperties: mutableProperties, } } diff --git a/x/orders/transactions/modify/transaction_request_test.go b/x/orders/transactions/modify/transaction_request_test.go index 54e24dba1..083ebc8a5 100644 --- a/x/orders/transactions/modify/transaction_request_test.go +++ b/x/orders/transactions/modify/transaction_request_test.go @@ -4,9 +4,7 @@ package modify import ( - "encoding/json" "fmt" - "github.com/AssetMantle/modules/utilities/rest" "reflect" "testing" @@ -15,15 +13,12 @@ import ( baseQualified "github.com/AssetMantle/schema/qualified/base" "github.com/AssetMantle/schema/types/base" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/types" - "github.com/spf13/viper" - "github.com/stretchr/testify/require" - "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/helpers/constants" + "github.com/spf13/viper" ) var ( @@ -40,36 +35,36 @@ var ( immutables = baseQualified.NewImmutables(immutableProperties) mutables = baseQualified.NewMutables(mutableProperties) - testClassificationID = baseIDs.NewClassificationID(immutables, mutables).(*baseIDs.ClassificationID) - testFromID = baseIDs.NewIdentityID(testClassificationID, immutables).(*baseIDs.IdentityID) - testOrderID = baseIDs.NewOrderID(testClassificationID, immutables).(*baseIDs.OrderID) - testBaseRequest = rest.BaseReq{From: fromAddress, ChainID: "test", Fees: types.NewCoins()} - expiresIn = int64(60) - makerSplit = types.NewInt(60) - takerSplit = types.NewInt(60) + testClassificationID = baseIDs.NewClassificationID(immutables, mutables).(*baseIDs.ClassificationID) + testFromID = baseIDs.NewIdentityID(testClassificationID, immutables).(*baseIDs.IdentityID) + testOrderID = baseIDs.NewOrderID(testClassificationID, immutables).(*baseIDs.OrderID) + commonTransactionRequest = helpers.PrototypeCommonTransactionRequest() + expiresIn = int64(60) + makerSplit = types.NewInt(60) + takerSplit = types.NewInt(60) ) func Test_newTransactionRequest(t *testing.T) { type args struct { - baseReq rest.BaseReq - fromID string - orderID string - takerSplit string - makerSplit string - expiresIn int64 - mutableMetaProperties string - mutableProperties string + commonTransactionRequest helpers.CommonTransactionRequest + fromID string + orderID string + takerSplit string + makerSplit string + expiresIn int64 + mutableMetaProperties string + mutableProperties string } tests := []struct { name string args args want helpers.TransactionRequest }{ - {"+ve", args{testBaseRequest, testFromID.AsString(), testOrderID.AsString(), takerSplit.String(), makerSplit.String(), expiresIn, mutableMetaPropertiesString, mutablePropertiesString}, transactionRequest{testBaseRequest, testFromID.AsString(), testOrderID.AsString(), takerSplit.String(), makerSplit.String(), expiresIn, mutableMetaPropertiesString, mutablePropertiesString}}, + {"+ve", args{commonTransactionRequest, testFromID.AsString(), testOrderID.AsString(), takerSplit.String(), makerSplit.String(), expiresIn, mutableMetaPropertiesString, mutablePropertiesString}, transactionRequest{commonTransactionRequest, testFromID.AsString(), testOrderID.AsString(), takerSplit.String(), makerSplit.String(), expiresIn, mutableMetaPropertiesString, mutablePropertiesString}}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - if got := newTransactionRequest(tt.args.baseReq, tt.args.fromID, tt.args.orderID, tt.args.takerSplit, tt.args.makerSplit, tt.args.expiresIn, tt.args.mutableMetaProperties, tt.args.mutableProperties); !reflect.DeepEqual(got, tt.want) { + if got := newTransactionRequest(tt.args.commonTransactionRequest, tt.args.fromID, tt.args.orderID, tt.args.takerSplit, tt.args.makerSplit, tt.args.expiresIn, tt.args.mutableMetaProperties, tt.args.mutableProperties); !reflect.DeepEqual(got, tt.want) { t.Errorf("newTransactionRequest() = %v, want %v", got, tt.want) } }) @@ -103,14 +98,14 @@ func Test_transactionRequest_FromCLI(t *testing.T) { viper.Set(constants.MutableMetaProperties.GetName(), mutableMetaPropertiesString) viper.Set(constants.MutableProperties.GetName(), mutablePropertiesString) type fields struct { - BaseReq rest.BaseReq - FromID string - OrderID string - TakerSplit string - MakerSplit string - ExpiresIn int64 - MutableMetaProperties string - MutableProperties string + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + OrderID string + TakerSplit string + MakerSplit string + ExpiresIn int64 + MutableMetaProperties string + MutableProperties string } type args struct { cliCommand helpers.CLICommand @@ -123,19 +118,19 @@ func Test_transactionRequest_FromCLI(t *testing.T) { want helpers.TransactionRequest wantErr bool }{ - {"+ve", fields{testBaseRequest, testFromID.AsString(), testOrderID.AsString(), takerSplit.String(), makerSplit.String(), expiresIn, mutableMetaPropertiesString, mutablePropertiesString}, args{cliCommand, client.Context{}.WithCodec(baseHelpers.CodecPrototype())}, transactionRequest{testBaseRequest, testFromID.AsString(), testOrderID.AsString(), takerSplit.String(), makerSplit.String(), expiresIn, mutableMetaPropertiesString, mutablePropertiesString}, false}, + {"+ve", fields{commonTransactionRequest, testFromID.AsString(), testOrderID.AsString(), takerSplit.String(), makerSplit.String(), expiresIn, mutableMetaPropertiesString, mutablePropertiesString}, args{cliCommand, client.Context{}.WithCodec(baseHelpers.CodecPrototype())}, transactionRequest{commonTransactionRequest, testFromID.AsString(), testOrderID.AsString(), takerSplit.String(), makerSplit.String(), expiresIn, mutableMetaPropertiesString, mutablePropertiesString}, false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - OrderID: tt.fields.OrderID, - TakerSplit: tt.fields.TakerSplit, - MakerSplit: tt.fields.MakerSplit, - ExpiresIn: tt.fields.ExpiresIn, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + OrderID: tt.fields.OrderID, + TakerSplit: tt.fields.TakerSplit, + MakerSplit: tt.fields.MakerSplit, + ExpiresIn: tt.fields.ExpiresIn, + MutableMetaProperties: tt.fields.MutableMetaProperties, + MutableProperties: tt.fields.MutableProperties, } got, err := transactionRequest.FromCLI(tt.args.cliCommand, tt.args.context) if (err != nil) != tt.wantErr { @@ -149,87 +144,38 @@ func Test_transactionRequest_FromCLI(t *testing.T) { } } -func Test_transactionRequest_FromJSON(t *testing.T) { - jsonMessage, err := json.Marshal(newTransactionRequest(testBaseRequest, testFromID.AsString(), testOrderID.AsString(), takerSplit.String(), makerSplit.String(), expiresIn, mutableMetaPropertiesString, mutablePropertiesString)) - require.NoError(t, err) - type fields struct { - BaseReq rest.BaseReq - FromID string - OrderID string - TakerSplit string - MakerSplit string - ExpiresIn int64 - MutableMetaProperties string - MutableProperties string - } - type args struct { - rawMessage json.RawMessage - } - tests := []struct { - name string - fields fields - args args - want helpers.TransactionRequest - wantErr bool - }{ - {"+ve", fields{testBaseRequest, testFromID.AsString(), testOrderID.AsString(), takerSplit.String(), makerSplit.String(), expiresIn, mutableMetaPropertiesString, mutablePropertiesString}, args{jsonMessage}, newTransactionRequest(testBaseRequest, testFromID.AsString(), testOrderID.AsString(), takerSplit.String(), makerSplit.String(), expiresIn, mutableMetaPropertiesString, mutablePropertiesString), false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - OrderID: tt.fields.OrderID, - TakerSplit: tt.fields.TakerSplit, - MakerSplit: tt.fields.MakerSplit, - ExpiresIn: tt.fields.ExpiresIn, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, - } - got, err := transactionRequest.FromJSON(tt.args.rawMessage) - if (err != nil) != tt.wantErr { - t.Errorf("FromJSON() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("FromJSON() got = %v, want %v", got, tt.want) - } - }) - } -} - func Test_transactionRequest_GetBaseReq(t *testing.T) { type fields struct { - BaseReq rest.BaseReq - FromID string - OrderID string - TakerSplit string - MakerSplit string - ExpiresIn int64 - MutableMetaProperties string - MutableProperties string + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + OrderID string + TakerSplit string + MakerSplit string + ExpiresIn int64 + MutableMetaProperties string + MutableProperties string } tests := []struct { name string fields fields - want rest.BaseReq + want helpers.CommonTransactionRequest }{ - {"+ve", fields{testBaseRequest, testFromID.AsString(), testOrderID.AsString(), takerSplit.String(), makerSplit.String(), expiresIn, mutableMetaPropertiesString, mutablePropertiesString}, testBaseRequest}, + {"+ve", fields{commonTransactionRequest, testFromID.AsString(), testOrderID.AsString(), takerSplit.String(), makerSplit.String(), expiresIn, mutableMetaPropertiesString, mutablePropertiesString}, commonTransactionRequest}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - OrderID: tt.fields.OrderID, - TakerSplit: tt.fields.TakerSplit, - MakerSplit: tt.fields.MakerSplit, - ExpiresIn: tt.fields.ExpiresIn, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + OrderID: tt.fields.OrderID, + TakerSplit: tt.fields.TakerSplit, + MakerSplit: tt.fields.MakerSplit, + ExpiresIn: tt.fields.ExpiresIn, + MutableMetaProperties: tt.fields.MutableMetaProperties, + MutableProperties: tt.fields.MutableProperties, } - if got := transactionRequest.GetBaseReq(); !reflect.DeepEqual(got, tt.want) { - t.Errorf("GetBaseReq() = %v, want %v", got, tt.want) + if got := transactionRequest.GetCommonTransactionRequest(); !reflect.DeepEqual(got, tt.want) { + t.Errorf("GetCommonTransactionRequest() = %v, want %v", got, tt.want) } }) } @@ -237,14 +183,14 @@ func Test_transactionRequest_GetBaseReq(t *testing.T) { func Test_transactionRequest_MakeMsg(t *testing.T) { type fields struct { - BaseReq rest.BaseReq - FromID string - OrderID string - TakerSplit string - MakerSplit string - ExpiresIn int64 - MutableMetaProperties string - MutableProperties string + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + OrderID string + TakerSplit string + MakerSplit string + ExpiresIn int64 + MutableMetaProperties string + MutableProperties string } tests := []struct { name string @@ -252,19 +198,19 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { want types.Msg wantErr bool }{ - {"+ve", fields{testBaseRequest, testFromID.AsString(), testOrderID.AsString(), takerSplit.String(), makerSplit.String(), expiresIn, mutableMetaPropertiesString, mutablePropertiesString}, NewMessage(fromAccAddress, testFromID, testOrderID, takerSplit, makerSplit, base.NewHeight(60), mutableMetaProperties, mutableProperties), false}, + {"+ve", fields{commonTransactionRequest, testFromID.AsString(), testOrderID.AsString(), takerSplit.String(), makerSplit.String(), expiresIn, mutableMetaPropertiesString, mutablePropertiesString}, NewMessage(fromAccAddress, testFromID, testOrderID, takerSplit, makerSplit, base.NewHeight(60), mutableMetaProperties, mutableProperties), false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - OrderID: tt.fields.OrderID, - TakerSplit: tt.fields.TakerSplit, - MakerSplit: tt.fields.MakerSplit, - ExpiresIn: tt.fields.ExpiresIn, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + OrderID: tt.fields.OrderID, + TakerSplit: tt.fields.TakerSplit, + MakerSplit: tt.fields.MakerSplit, + ExpiresIn: tt.fields.ExpiresIn, + MutableMetaProperties: tt.fields.MutableMetaProperties, + MutableProperties: tt.fields.MutableProperties, } got, err := transactionRequest.MakeMsg() if (err != nil) != tt.wantErr { @@ -278,73 +224,35 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { } } -func Test_transactionRequest_RegisterCodec(t *testing.T) { - type fields struct { - BaseReq rest.BaseReq - FromID string - OrderID string - TakerSplit string - MakerSplit string - ExpiresIn int64 - MutableMetaProperties string - MutableProperties string - } - type args struct { - legacyAmino *codec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{testBaseRequest, testFromID.AsString(), testOrderID.AsString(), takerSplit.String(), makerSplit.String(), expiresIn, mutableMetaPropertiesString, mutablePropertiesString}, args{codec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - tr := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - OrderID: tt.fields.OrderID, - TakerSplit: tt.fields.TakerSplit, - MakerSplit: tt.fields.MakerSplit, - ExpiresIn: tt.fields.ExpiresIn, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, - } - tr.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - func Test_transactionRequest_Validate(t *testing.T) { type fields struct { - BaseReq rest.BaseReq - FromID string - OrderID string - TakerSplit string - MakerSplit string - ExpiresIn int64 - MutableMetaProperties string - MutableProperties string + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + OrderID string + TakerSplit string + MakerSplit string + ExpiresIn int64 + MutableMetaProperties string + MutableProperties string } tests := []struct { name string fields fields wantErr bool }{ - {"+ve", fields{testBaseRequest, testFromID.AsString(), testOrderID.AsString(), takerSplit.String(), makerSplit.String(), expiresIn, mutableMetaPropertiesString, mutablePropertiesString}, false}, + {"+ve", fields{commonTransactionRequest, testFromID.AsString(), testOrderID.AsString(), takerSplit.String(), makerSplit.String(), expiresIn, mutableMetaPropertiesString, mutablePropertiesString}, false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - OrderID: tt.fields.OrderID, - TakerSplit: tt.fields.TakerSplit, - MakerSplit: tt.fields.MakerSplit, - ExpiresIn: tt.fields.ExpiresIn, - MutableMetaProperties: tt.fields.MutableMetaProperties, - MutableProperties: tt.fields.MutableProperties, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + OrderID: tt.fields.OrderID, + TakerSplit: tt.fields.TakerSplit, + MakerSplit: tt.fields.MakerSplit, + ExpiresIn: tt.fields.ExpiresIn, + MutableMetaProperties: tt.fields.MutableMetaProperties, + MutableProperties: tt.fields.MutableProperties, } if err := transactionRequest.Validate(); (err != nil) != tt.wantErr { t.Errorf("ValidateBasic() error = %v, wantErr %v", err, tt.wantErr) diff --git a/x/orders/transactions/modify/transaction_response.go b/x/orders/transactions/modify/transaction_response.go index 83f6ab745..cf6e8bd50 100644 --- a/x/orders/transactions/modify/transaction_response.go +++ b/x/orders/transactions/modify/transaction_response.go @@ -4,9 +4,8 @@ package modify import ( - sdkTypes "github.com/cosmos/cosmos-sdk/types" - "github.com/AssetMantle/modules/helpers" + sdkTypes "github.com/cosmos/cosmos-sdk/types" ) var _ helpers.TransactionResponse = (*TransactionResponse)(nil) diff --git a/x/orders/transactions/prototype_test.go b/x/orders/transactions/prototype_test.go index 246aea524..57a087fee 100644 --- a/x/orders/transactions/prototype_test.go +++ b/x/orders/transactions/prototype_test.go @@ -16,29 +16,29 @@ import ( ) func TestPrototype(t *testing.T) { - require.Equal(t, Prototype().GetTransaction("cancel").GetName(), baseHelpers.NewTransactions( + require.Equal(t, Prototype().GetTransaction("cancel").GetServicePath(), baseHelpers.NewTransactions( take.Transaction, cancel.Transaction, define.Transaction, make2.Transaction, - ).GetTransaction("cancel").GetName()) - require.Equal(t, Prototype().GetTransaction("define").GetName(), baseHelpers.NewTransactions( + ).GetTransaction("cancel").GetServicePath()) + require.Equal(t, Prototype().GetTransaction("define").GetServicePath(), baseHelpers.NewTransactions( take.Transaction, cancel.Transaction, define.Transaction, make2.Transaction, - ).GetTransaction("define").GetName()) - require.Equal(t, Prototype().GetTransaction("make").GetName(), baseHelpers.NewTransactions( + ).GetTransaction("define").GetServicePath()) + require.Equal(t, Prototype().GetTransaction("make").GetServicePath(), baseHelpers.NewTransactions( take.Transaction, cancel.Transaction, define.Transaction, make2.Transaction, - ).GetTransaction("make").GetName()) - require.Equal(t, Prototype().GetTransaction("take").GetName(), baseHelpers.NewTransactions( + ).GetTransaction("make").GetServicePath()) + require.Equal(t, Prototype().GetTransaction("take").GetServicePath(), baseHelpers.NewTransactions( take.Transaction, cancel.Transaction, define.Transaction, make2.Transaction, - ).GetTransaction("take").GetName()) + ).GetTransaction("take").GetServicePath()) } diff --git a/x/orders/transactions/put/message.go b/x/orders/transactions/put/message.go index 9d2345ba7..a63791afa 100644 --- a/x/orders/transactions/put/message.go +++ b/x/orders/transactions/put/message.go @@ -4,29 +4,18 @@ package put import ( + "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/helpers/constants" - codecUtilities "github.com/AssetMantle/schema/codec/utilities" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" typesSchema "github.com/AssetMantle/schema/types" baseTypes "github.com/AssetMantle/schema/types/base" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/types" sdkTypes "github.com/cosmos/cosmos-sdk/types" - - "github.com/AssetMantle/modules/helpers" ) var _ helpers.Message = (*Message)(nil) -func (message *Message) Type() string { return Transaction.GetName() } -func (message *Message) GetFromAddress() sdkTypes.AccAddress { - from, err := sdkTypes.AccAddressFromBech32(message.From) - if err != nil { - panic(err) - } - return from -} func (message *Message) ValidateBasic() error { if _, err := sdkTypes.AccAddressFromBech32(message.From); err != nil { return err @@ -65,20 +54,10 @@ func (message *Message) GetSigners() []sdkTypes.AccAddress { } return []sdkTypes.AccAddress{from} } -func (*Message) RegisterLegacyAminoCodec(legacyAmino *codec.LegacyAmino) { - codecUtilities.RegisterModuleConcrete(legacyAmino, Message{}) -} func (message *Message) RegisterInterface(interfaceRegistry types.InterfaceRegistry) { interfaceRegistry.RegisterImplementations((*sdkTypes.Msg)(nil), message) } -func messageFromInterface(msg sdkTypes.Msg) *Message { - switch value := msg.(type) { - case *Message: - return value - default: - return &Message{} - } -} + func messagePrototype() helpers.Message { return &Message{} } diff --git a/x/orders/transactions/put/message_test.go b/x/orders/transactions/put/message_test.go index 3b635a508..c28633374 100644 --- a/x/orders/transactions/put/message_test.go +++ b/x/orders/transactions/put/message_test.go @@ -11,7 +11,6 @@ import ( baseIDs "github.com/AssetMantle/schema/ids/base" "github.com/AssetMantle/schema/types" "github.com/AssetMantle/schema/types/base" - "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" "github.com/AssetMantle/modules/helpers" @@ -32,26 +31,6 @@ type fields struct { ExpiryHeight *base.Height } -func Test_messageFromInterface(t *testing.T) { - type args struct { - msg sdkTypes.Msg - } - tests := []struct { - name string - args args - want *Message - }{ - {"+ve", args{testMessage}, &Message{fromAccAddress.String(), testFromID, makerAssetID, takerAssetID, makerSplit.String(), takerSplit.String(), expiresInHeight}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := messageFromInterface(tt.args.msg); !reflect.DeepEqual(got, tt.want) { - t.Errorf("messageFromInterface() = %v, want %v", got, tt.want) - } - }) - } -} - func Test_messagePrototype(t *testing.T) { tests := []struct { name string @@ -90,61 +69,6 @@ func Test_message_GetSigners(t *testing.T) { } } -func Test_message_RegisterCodec(t *testing.T) { - - type args struct { - legacyAmino *codec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{fromAccAddress.String(), testFromID, makerAssetID, takerAssetID, makerSplit, takerSplit, expiresInHeight}, args{codec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - me := &Message{ - tt.fields.From, - tt.fields.FromID, - tt.fields.MakerAssetID, - tt.fields.TakerAssetID, - tt.fields.MakerSplit.String(), - tt.fields.TakerSplit.String(), - tt.fields.ExpiryHeight, - } - me.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - -func Test_message_Type(t *testing.T) { - - tests := []struct { - name string - fields fields - want string - }{ - {"+ve", fields{fromAccAddress.String(), testFromID, makerAssetID, takerAssetID, makerSplit, takerSplit, expiresInHeight}, Transaction.GetName()}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - message := &Message{ - tt.fields.From, - tt.fields.FromID, - tt.fields.MakerAssetID, - tt.fields.TakerAssetID, - tt.fields.MakerSplit.String(), - tt.fields.TakerSplit.String(), - tt.fields.ExpiryHeight, - } - if got := message.Type(); got != tt.want { - t.Errorf("Type() = %v, want %v", got, tt.want) - } - }) - } -} - func Test_message_ValidateBasic(t *testing.T) { tests := []struct { diff --git a/x/orders/transactions/put/service.pb.go b/x/orders/transactions/put/service.pb.go index d2b6bd0a6..a61a1a4ff 100644 --- a/x/orders/transactions/put/service.pb.go +++ b/x/orders/transactions/put/service.pb.go @@ -6,9 +6,9 @@ package put import ( context "context" fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types/msgservice" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" - _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -31,30 +31,29 @@ func init() { } var fileDescriptor_ca7dda5a8ae78412 = []byte{ - // 358 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x92, 0x31, 0x4b, 0xc3, 0x40, - 0x14, 0xc7, 0x9b, 0x08, 0x1d, 0x82, 0x53, 0x70, 0x0a, 0x92, 0xa1, 0xbb, 0x77, 0x58, 0x41, 0xf4, - 0x9c, 0x9a, 0xc5, 0x2e, 0xa1, 0x41, 0x3b, 0x04, 0x09, 0xc8, 0x35, 0x39, 0x62, 0x20, 0xc9, 0x85, - 0xdc, 0x3b, 0xe9, 0xec, 0x27, 0x10, 0xfc, 0x02, 0xe2, 0x24, 0x7e, 0x12, 0x71, 0x2a, 0xb8, 0x38, - 0x4a, 0xea, 0xe4, 0xe2, 0x57, 0x90, 0x9a, 0x03, 0xaf, 0xe3, 0xad, 0x2f, 0xff, 0xdf, 0xcb, 0xef, - 0xbd, 0x7b, 0xce, 0xd9, 0x44, 0x08, 0x06, 0x21, 0xad, 0xa1, 0x64, 0xb8, 0xe2, 0x99, 0x2c, 0x99, - 0xc0, 0x4b, 0xcc, 0xdb, 0x8c, 0xb5, 0x02, 0x43, 0x4b, 0x6b, 0x41, 0x53, 0x28, 0x78, 0x2d, 0x70, - 0x23, 0x01, 0x0b, 0xd6, 0xde, 0x16, 0x29, 0x43, 0x4d, 0xcb, 0x81, 0xbb, 0x07, 0x1a, 0x8c, 0x14, - 0x8c, 0x96, 0xa8, 0x87, 0x91, 0x0e, 0xa3, 0x46, 0x82, 0xb7, 0x9f, 0x73, 0x9e, 0x97, 0x0c, 0xd3, - 0xa6, 0xc0, 0xb4, 0xae, 0x39, 0x50, 0xf5, 0x6d, 0xd3, 0xcc, 0x33, 0x34, 0xa9, 0x98, 0x10, 0x34, - 0x57, 0x26, 0xde, 0xd4, 0x0c, 0xd6, 0x0a, 0xd7, 0x2d, 0x13, 0x0d, 0xaf, 0x85, 0xea, 0x34, 0x7e, - 0xb6, 0x9c, 0x9d, 0x50, 0xe4, 0xee, 0xa3, 0xe5, 0x0c, 0xa7, 0xb4, 0xce, 0x4a, 0xe6, 0x1e, 0x23, - 0xa3, 0x39, 0x51, 0xd8, 0xab, 0x79, 0x81, 0x21, 0x37, 0xff, 0x2f, 0x5c, 0x28, 0xa9, 0x91, 0x77, - 0xf7, 0xfe, 0xf5, 0x60, 0xef, 0x8d, 0x5c, 0x5c, 0xf5, 0xc3, 0xa9, 0x91, 0x1a, 0x09, 0xc1, 0x8f, - 0xfd, 0xda, 0xf9, 0xd6, 0xaa, 0xf3, 0xad, 0xcf, 0xce, 0xb7, 0xee, 0xd7, 0xfe, 0x60, 0xb5, 0xf6, - 0x07, 0x1f, 0x6b, 0x7f, 0xe0, 0x1c, 0xa6, 0xbc, 0x32, 0xfb, 0x7b, 0xb0, 0x7b, 0xd9, 0xbf, 0x6d, - 0xb4, 0x59, 0x43, 0x64, 0x5d, 0x9d, 0xe4, 0x05, 0xdc, 0xc8, 0x05, 0x4a, 0x79, 0x85, 0x8d, 0xb6, - 0xfb, 0x64, 0x0f, 0x27, 0x61, 0x3c, 0x9b, 0x47, 0x2f, 0xf6, 0xd6, 0x81, 0x84, 0x4a, 0x21, 0x46, - 0xb3, 0x5e, 0x61, 0xae, 0x2b, 0x44, 0x12, 0xde, 0xb6, 0xf2, 0x89, 0xca, 0x27, 0x71, 0xd2, 0xe7, - 0x13, 0x3d, 0x9f, 0x44, 0x12, 0x3a, 0xfb, 0xd4, 0x28, 0x9f, 0x9c, 0x47, 0x41, 0xc8, 0x80, 0x66, - 0x14, 0xe8, 0xb7, 0x3d, 0xd6, 0x58, 0x42, 0x14, 0x4c, 0x48, 0x4c, 0x48, 0x8f, 0x13, 0xa2, 0xf3, - 0x84, 0x44, 0x12, 0x16, 0xc3, 0xbf, 0x1b, 0x39, 0xfa, 0x0d, 0x00, 0x00, 0xff, 0xff, 0xac, 0x88, - 0x4d, 0xfb, 0x36, 0x03, 0x00, 0x00, + // 351 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x92, 0xb1, 0x4b, 0xfb, 0x40, + 0x14, 0xc7, 0x93, 0xfc, 0xf8, 0x75, 0x08, 0x4e, 0x5d, 0x84, 0x0c, 0x19, 0x1c, 0x05, 0xef, 0x68, + 0x05, 0xd1, 0x73, 0x6a, 0x16, 0xbb, 0x84, 0x06, 0xed, 0x10, 0x24, 0x20, 0xd7, 0xe4, 0x88, 0x85, + 0x26, 0x17, 0xf2, 0xee, 0x4a, 0x47, 0x27, 0x67, 0x17, 0xff, 0x01, 0x47, 0x27, 0xff, 0x0c, 0x71, + 0xea, 0xe8, 0x28, 0xe9, 0x20, 0xb8, 0xf8, 0x2f, 0x48, 0xbd, 0x03, 0xaf, 0xe3, 0x4d, 0x07, 0x8f, + 0xef, 0xe7, 0xdd, 0xe7, 0xdd, 0x3d, 0xff, 0x7c, 0x04, 0xc0, 0x44, 0x4c, 0x6b, 0xb1, 0x60, 0xb8, + 0xe2, 0x85, 0x5c, 0x30, 0xc0, 0x2b, 0xcc, 0xdb, 0x82, 0xb5, 0x80, 0x45, 0x4b, 0x6b, 0xa0, 0xb9, + 0x98, 0xf3, 0x1a, 0x70, 0x23, 0x05, 0x06, 0xd6, 0x2e, 0xe7, 0x39, 0x43, 0x4d, 0xcb, 0x05, 0xef, + 0x1f, 0x19, 0x30, 0xd2, 0x30, 0x5a, 0x21, 0x05, 0x23, 0x13, 0x46, 0x8d, 0x14, 0xc1, 0x7e, 0xce, + 0xa1, 0xe2, 0x80, 0x2b, 0x28, 0xf1, 0x72, 0xb0, 0x3d, 0x54, 0x9f, 0xc0, 0x52, 0xa2, 0x62, 0x00, + 0xb4, 0xd4, 0x12, 0xc1, 0xd8, 0x0e, 0x36, 0x0a, 0x37, 0x2d, 0x83, 0x86, 0xd7, 0xa0, 0x3b, 0x0d, + 0x1f, 0x5d, 0xff, 0x5f, 0x0c, 0x65, 0xff, 0xde, 0xf5, 0x7b, 0x63, 0x5a, 0x17, 0x0b, 0xd6, 0x3f, + 0x41, 0x56, 0x23, 0xa2, 0x58, 0xa9, 0x05, 0x91, 0x25, 0x37, 0xfd, 0x2b, 0x5c, 0x6a, 0xa9, 0x03, + 0x27, 0xf8, 0x7f, 0xf7, 0xf9, 0x72, 0xe8, 0x46, 0xdf, 0xde, 0x6b, 0x17, 0xba, 0xeb, 0x2e, 0x74, + 0x3f, 0xba, 0xd0, 0x7d, 0xd8, 0x84, 0xce, 0x7a, 0x13, 0x3a, 0xef, 0x9b, 0xd0, 0xf1, 0x07, 0x39, + 0xaf, 0xec, 0xae, 0x8a, 0xf6, 0xae, 0xd4, 0x1f, 0x26, 0xdb, 0x99, 0x13, 0xf7, 0xfa, 0xb4, 0x9c, + 0x8b, 0x5b, 0x39, 0x43, 0x39, 0xaf, 0xb0, 0xd5, 0x53, 0x3e, 0x79, 0xbd, 0x51, 0x9c, 0x4e, 0xa6, + 0xc9, 0xb3, 0xb7, 0xb3, 0x08, 0xb1, 0x56, 0x48, 0xd1, 0x44, 0x29, 0x4c, 0x4d, 0x85, 0x44, 0x8a, + 0xb7, 0x9d, 0x7c, 0xa6, 0xf3, 0x59, 0x9a, 0xa9, 0x7c, 0x66, 0xe6, 0xb3, 0x44, 0x8a, 0xce, 0x3b, + 0xb3, 0xca, 0x67, 0x17, 0x49, 0x14, 0x33, 0x41, 0x0b, 0x2a, 0xe8, 0x97, 0x37, 0x34, 0x58, 0x42, + 0x34, 0x4c, 0x48, 0x4a, 0x88, 0xc2, 0x09, 0x31, 0x79, 0x42, 0x12, 0x29, 0x66, 0xbd, 0xdf, 0x85, + 0x38, 0xfe, 0x09, 0x00, 0x00, 0xff, 0xff, 0xd5, 0x77, 0x99, 0xc6, 0x1e, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/orders/transactions/put/service.pb.gw.go b/x/orders/transactions/put/service.pb.gw.go deleted file mode 100644 index abcc4c4e4..000000000 --- a/x/orders/transactions/put/service.pb.gw.go +++ /dev/null @@ -1,171 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: AssetMantle/modules/x/orders/transactions/put/service.proto - -/* -Package put is a reverse proxy. - -It translates gRPC into RESTful JSON APIs. -*/ -package put - -import ( - "context" - "io" - "net/http" - - "github.com/golang/protobuf/descriptor" - "github.com/golang/protobuf/proto" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/grpc-ecosystem/grpc-gateway/utilities" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/status" -) - -// Suppress "imported and not used" errors -var _ codes.Code -var _ io.Reader -var _ status.Status -var _ = runtime.String -var _ = utilities.NewDoubleArray -var _ = descriptor.ForMessage -var _ = metadata.Join - -var ( - filter_Msg_Handle_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - -func request_Msg_Handle_0(ctx context.Context, marshaler runtime.Marshaler, client MsgClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq Message - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.Handle(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Msg_Handle_0(ctx context.Context, marshaler runtime.Marshaler, server MsgServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq Message - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.Handle(ctx, &protoReq) - return msg, metadata, err - -} - -// RegisterMsgHandlerServer registers the http handlers for service Msg to "mux". -// UnaryRPC :call MsgServer directly. -// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterMsgHandlerFromEndpoint instead. -func RegisterMsgHandlerServer(ctx context.Context, mux *runtime.ServeMux, server MsgServer) error { - - mux.Handle("POST", pattern_Msg_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Msg_Handle_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Msg_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -// RegisterMsgHandlerFromEndpoint is same as RegisterMsgHandler but -// automatically dials to "endpoint" and closes the connection when "ctx" gets done. -func RegisterMsgHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.Dial(endpoint, opts...) - if err != nil { - return err - } - defer func() { - if err != nil { - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - return - } - go func() { - <-ctx.Done() - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - }() - }() - - return RegisterMsgHandler(ctx, mux, conn) -} - -// RegisterMsgHandler registers the http handlers for service Msg to "mux". -// The handlers forward requests to the grpc endpoint over "conn". -func RegisterMsgHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { - return RegisterMsgHandlerClient(ctx, mux, NewMsgClient(conn)) -} - -// RegisterMsgHandlerClient registers the http handlers for service Msg -// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "MsgClient". -// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "MsgClient" -// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "MsgClient" to call the correct interceptors. -func RegisterMsgHandlerClient(ctx context.Context, mux *runtime.ServeMux, client MsgClient) error { - - mux.Handle("POST", pattern_Msg_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Msg_Handle_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Msg_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -var ( - pattern_Msg_Handle_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"mantle", "orders", "put"}, "", runtime.AssumeColonVerbOpt(false))) -) - -var ( - forward_Msg_Handle_0 = runtime.ForwardResponseMessage -) diff --git a/x/orders/transactions/put/transaction.go b/x/orders/transactions/put/transaction.go index f2658161d..817572c04 100644 --- a/x/orders/transactions/put/transaction.go +++ b/x/orders/transactions/put/transaction.go @@ -4,22 +4,14 @@ package put import ( - "context" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "google.golang.org/grpc" - "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/helpers/constants" - "github.com/AssetMantle/modules/utilities/name" + "google.golang.org/grpc" ) -type dummy struct{} - var Transaction = baseHelpers.NewTransaction( - name.GetPackageName(dummy{}), + _Msg_serviceDesc.ServiceName, "", "", @@ -30,9 +22,6 @@ var Transaction = baseHelpers.NewTransaction( func(server grpc.ServiceRegistrar, keeper helpers.TransactionKeeper) { RegisterMsgServer(server, keeper.(transactionKeeper)) }, - func(clientCtx client.Context, mux *runtime.ServeMux) error { - return RegisterMsgHandlerClient(context.Background(), mux, NewMsgClient(clientCtx)) - }, constants.FromIdentityID, constants.MakerAssetID, diff --git a/x/orders/transactions/put/transaction_keeper.go b/x/orders/transactions/put/transaction_keeper.go index bb3bd12bc..ac2beb748 100644 --- a/x/orders/transactions/put/transaction_keeper.go +++ b/x/orders/transactions/put/transaction_keeper.go @@ -6,7 +6,6 @@ package put import ( "context" errorConstants "github.com/AssetMantle/modules/helpers/constants" - "github.com/AssetMantle/schema/data" "github.com/AssetMantle/schema/documents/base" propertyConstants "github.com/AssetMantle/schema/properties/constants" @@ -41,7 +40,7 @@ func (transactionKeeper transactionKeeper) Handle(context context.Context, messa return nil, errorConstants.NotAuthorized.Wrapf("put orders not enabled") } - fromAddress := message.GetFromAddress() + fromAddress := message.GetSigners()[0] if _, err := transactionKeeper.authenticateAuxiliary.GetKeeper().Help(context, authenticate.NewAuxiliaryRequest(fromAddress, message.FromID)); err != nil { return nil, err diff --git a/x/orders/transactions/put/transaction_request.go b/x/orders/transactions/put/transaction_request.go index 9c5959d32..c3eae6585 100644 --- a/x/orders/transactions/put/transaction_request.go +++ b/x/orders/transactions/put/transaction_request.go @@ -5,28 +5,26 @@ package put import ( "encoding/json" - "github.com/AssetMantle/modules/utilities/rest" - - codecUtilities "github.com/AssetMantle/schema/codec/utilities" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" baseTypes "github.com/AssetMantle/schema/types/base" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" + "io" + "net/http" "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/helpers/constants" ) type transactionRequest struct { - BaseReq rest.BaseReq `json:"baseReq"` - FromID string `json:"fromID"` - MakerAssetID string `json:"makerAssetID"` - TakerAssetID string `json:"takerAssetID"` - MakerSplit string `json:"makerSplit"` - TakerSplit string `json:"takerSplit"` - ExpiryHeight int64 `json:"expiryHeight"` + helpers.CommonTransactionRequest `json:"commonTransactionRequest"` + FromID string `json:"fromID"` + MakerAssetID string `json:"makerAssetID"` + TakerAssetID string `json:"takerAssetID"` + MakerSplit string `json:"makerSplit"` + TakerSplit string `json:"takerSplit"` + ExpiryHeight int64 `json:"expiryHeight"` } var _ helpers.TransactionRequest = (*transactionRequest)(nil) @@ -52,7 +50,7 @@ func (transactionRequest transactionRequest) Validate() error { } func (transactionRequest transactionRequest) FromCLI(cliCommand helpers.CLICommand, context client.Context) (helpers.TransactionRequest, error) { return newTransactionRequest( - cliCommand.ReadBaseReq(context), + cliCommand.ReadCommonTransactionRequest(context), cliCommand.ReadString(constants.FromIdentityID), cliCommand.ReadString(constants.MakerAssetID), cliCommand.ReadString(constants.TakerAssetID), @@ -61,19 +59,24 @@ func (transactionRequest transactionRequest) FromCLI(cliCommand helpers.CLIComma cliCommand.ReadInt64(constants.ExpiryHeight), ), nil } -func (transactionRequest transactionRequest) FromJSON(rawMessage json.RawMessage) (helpers.TransactionRequest, error) { - if err := json.Unmarshal(rawMessage, &transactionRequest); err != nil { +func (transactionRequest transactionRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.TransactionRequest, error) { + body, err := io.ReadAll(httpRequest.Body) + if err != nil { + return nil, err + } + + if err := json.Unmarshal(body, &transactionRequest); err != nil { return nil, err } return transactionRequest, nil } -func (transactionRequest transactionRequest) GetBaseReq() rest.BaseReq { - return transactionRequest.BaseReq +func (transactionRequest transactionRequest) GetCommonTransactionRequest() helpers.CommonTransactionRequest { + return transactionRequest.CommonTransactionRequest } func (transactionRequest transactionRequest) MakeMsg() (sdkTypes.Msg, error) { - from, err := sdkTypes.AccAddressFromBech32(transactionRequest.GetBaseReq().From) + from, err := sdkTypes.AccAddressFromBech32(transactionRequest.GetCommonTransactionRequest().GetFrom()) if err != nil { return nil, err } @@ -113,21 +116,18 @@ func (transactionRequest transactionRequest) MakeMsg() (sdkTypes.Msg, error) { baseTypes.NewHeight(transactionRequest.ExpiryHeight), ), nil } -func (transactionRequest) RegisterLegacyAminoCodec(legacyAmino *codec.LegacyAmino) { - codecUtilities.RegisterModuleConcrete(legacyAmino, transactionRequest{}) -} func requestPrototype() helpers.TransactionRequest { return transactionRequest{} } -func newTransactionRequest(baseReq rest.BaseReq, fromID string, makerAssetID string, takerAssetID string, makerSplit, takerSplit string, expiryHeight int64) helpers.TransactionRequest { +func newTransactionRequest(commonTransactionRequest helpers.CommonTransactionRequest, fromID string, makerAssetID string, takerAssetID string, makerSplit, takerSplit string, expiryHeight int64) helpers.TransactionRequest { return transactionRequest{ - BaseReq: baseReq, - FromID: fromID, - MakerAssetID: makerAssetID, - TakerAssetID: takerAssetID, - MakerSplit: makerSplit, - TakerSplit: takerSplit, - ExpiryHeight: expiryHeight, + CommonTransactionRequest: commonTransactionRequest, + FromID: fromID, + MakerAssetID: makerAssetID, + TakerAssetID: takerAssetID, + MakerSplit: makerSplit, + TakerSplit: takerSplit, + ExpiryHeight: expiryHeight, } } diff --git a/x/orders/transactions/put/transaction_request_test.go b/x/orders/transactions/put/transaction_request_test.go index 419b14db0..5c0254309 100644 --- a/x/orders/transactions/put/transaction_request_test.go +++ b/x/orders/transactions/put/transaction_request_test.go @@ -4,9 +4,7 @@ package put import ( - "encoding/json" "fmt" - "github.com/AssetMantle/modules/utilities/rest" "reflect" "testing" @@ -16,15 +14,12 @@ import ( baseQualified "github.com/AssetMantle/schema/qualified/base" "github.com/AssetMantle/schema/types/base" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" - "github.com/spf13/viper" - "github.com/stretchr/testify/require" - "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/helpers/constants" + "github.com/spf13/viper" ) var ( @@ -44,7 +39,7 @@ var ( testFromID = baseIDs.NewIdentityID(testClassificationID, immutables).(*baseIDs.IdentityID) makerAssetID = baseDocuments.NewCoinAsset("makerAssetID").GetCoinAssetID().(*baseIDs.AssetID) takerAssetID = baseDocuments.NewCoinAsset("takerAssetID").GetCoinAssetID().(*baseIDs.AssetID) - testBaseRequest = rest.BaseReq{From: fromAddress, ChainID: "test", Fees: sdkTypes.NewCoins()} + commonTransactionRequest = helpers.PrototypeCommonTransactionRequest() expiryHeight = int64(60) makerSplit = sdkTypes.NewInt(60) takerSplit = sdkTypes.NewInt(60) @@ -52,24 +47,24 @@ var ( func Test_newTransactionRequest(t *testing.T) { type args struct { - BaseReq rest.BaseReq - FromID string - MakerAssetID string - TakerAssetID string - MakerSplit string - TakerSplit string - ExpiryHeight int64 + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + MakerAssetID string + TakerAssetID string + MakerSplit string + TakerSplit string + ExpiryHeight int64 } tests := []struct { name string args args want helpers.TransactionRequest }{ - {"+ve", args{testBaseRequest, testFromID.AsString(), makerAssetID.AsString(), takerAssetID.AsString(), makerSplit.String(), takerSplit.String(), expiryHeight}, newTransactionRequest(testBaseRequest, testFromID.AsString(), makerAssetID.AsString(), takerAssetID.AsString(), makerSplit.String(), takerSplit.String(), expiryHeight)}, + {"+ve", args{commonTransactionRequest, testFromID.AsString(), makerAssetID.AsString(), takerAssetID.AsString(), makerSplit.String(), takerSplit.String(), expiryHeight}, newTransactionRequest(commonTransactionRequest, testFromID.AsString(), makerAssetID.AsString(), takerAssetID.AsString(), makerSplit.String(), takerSplit.String(), expiryHeight)}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - if got := newTransactionRequest(tt.args.BaseReq, tt.args.FromID, tt.args.MakerAssetID, tt.args.TakerAssetID, tt.args.MakerSplit, tt.args.TakerSplit, tt.args.ExpiryHeight); !reflect.DeepEqual(got, tt.want) { + if got := newTransactionRequest(tt.args.commonTransactionRequest, tt.args.FromID, tt.args.MakerAssetID, tt.args.TakerAssetID, tt.args.MakerSplit, tt.args.TakerSplit, tt.args.ExpiryHeight); !reflect.DeepEqual(got, tt.want) { t.Errorf("newTransactionRequest() = %v, want %v", got, tt.want) } }) @@ -108,13 +103,13 @@ func Test_transactionRequest_FromCLI(t *testing.T) { viper.Set(constants.MutableMetaProperties.GetName(), mutableMetaPropertiesString) viper.Set(constants.MutableProperties.GetName(), mutablePropertiesString) type fields struct { - BaseReq rest.BaseReq - FromID string - MakerAssetID string - TakerAssetID string - MakerSplit string - TakerSplit string - ExpiryHeight int64 + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + MakerAssetID string + TakerAssetID string + MakerSplit string + TakerSplit string + ExpiryHeight int64 } type args struct { cliCommand helpers.CLICommand @@ -127,13 +122,13 @@ func Test_transactionRequest_FromCLI(t *testing.T) { want helpers.TransactionRequest wantErr bool }{ - {"+ve", fields{testBaseRequest, testFromID.AsString(), makerAssetID.AsString(), takerAssetID.AsString(), makerSplit.String(), takerSplit.String(), expiryHeight}, args{cliCommand, client.Context{}.WithCodec(baseHelpers.CodecPrototype())}, newTransactionRequest(testBaseRequest, testFromID.AsString(), makerAssetID.AsString(), takerAssetID.AsString(), makerSplit.String(), takerSplit.String(), expiryHeight), false}, + {"+ve", fields{commonTransactionRequest, testFromID.AsString(), makerAssetID.AsString(), takerAssetID.AsString(), makerSplit.String(), takerSplit.String(), expiryHeight}, args{cliCommand, client.Context{}.WithCodec(baseHelpers.CodecPrototype())}, newTransactionRequest(commonTransactionRequest, testFromID.AsString(), makerAssetID.AsString(), takerAssetID.AsString(), makerSplit.String(), takerSplit.String(), expiryHeight), false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, } got, err := transactionRequest.FromCLI(tt.args.cliCommand, tt.args.context) if (err != nil) != tt.wantErr { @@ -147,74 +142,27 @@ func Test_transactionRequest_FromCLI(t *testing.T) { } } -func Test_transactionRequest_FromJSON(t *testing.T) { - jsonMessage, err := json.Marshal(newTransactionRequest(testBaseRequest, testFromID.AsString(), makerAssetID.AsString(), takerAssetID.AsString(), makerSplit.String(), takerSplit.String(), expiryHeight)) - require.NoError(t, err) - type fields struct { - BaseReq rest.BaseReq - FromID string - MakerAssetID string - TakerAssetID string - MakerSplit string - TakerSplit string - ExpiryHeight int64 - } - type args struct { - rawMessage json.RawMessage - } - tests := []struct { - name string - fields fields - args args - want helpers.TransactionRequest - wantErr bool - }{ - {"+ve", fields{testBaseRequest, testFromID.AsString(), makerAssetID.AsString(), takerAssetID.AsString(), makerSplit.String(), takerSplit.String(), expiryHeight}, args{jsonMessage}, newTransactionRequest(testBaseRequest, testFromID.AsString(), makerAssetID.AsString(), takerAssetID.AsString(), makerSplit.String(), takerSplit.String(), expiryHeight), false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - transactionRequest := transactionRequest{ - tt.fields.BaseReq, - tt.fields.FromID, - tt.fields.MakerAssetID, - tt.fields.TakerAssetID, - tt.fields.MakerSplit, - tt.fields.TakerSplit, - tt.fields.ExpiryHeight, - } - got, err := transactionRequest.FromJSON(tt.args.rawMessage) - if (err != nil) != tt.wantErr { - t.Errorf("FromJSON() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("FromJSON() got = %v, want %v", got, tt.want) - } - }) - } -} - func Test_transactionRequest_GetBaseReq(t *testing.T) { type fields struct { - BaseReq rest.BaseReq - FromID string - MakerAssetID string - TakerAssetID string - MakerSplit string - TakerSplit string - ExpiryHeight int64 + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + MakerAssetID string + TakerAssetID string + MakerSplit string + TakerSplit string + ExpiryHeight int64 } tests := []struct { name string fields fields - want rest.BaseReq + want helpers.CommonTransactionRequest }{ - {"+ve", fields{testBaseRequest, testFromID.AsString(), makerAssetID.AsString(), takerAssetID.AsString(), makerSplit.String(), takerSplit.String(), expiryHeight}, testBaseRequest}, + {"+ve", fields{commonTransactionRequest, testFromID.AsString(), makerAssetID.AsString(), takerAssetID.AsString(), makerSplit.String(), takerSplit.String(), expiryHeight}, commonTransactionRequest}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - tt.fields.BaseReq, + tt.fields.commonTransactionRequest, tt.fields.FromID, tt.fields.MakerAssetID, tt.fields.TakerAssetID, @@ -222,8 +170,8 @@ func Test_transactionRequest_GetBaseReq(t *testing.T) { tt.fields.TakerSplit, tt.fields.ExpiryHeight, } - if got := transactionRequest.GetBaseReq(); !reflect.DeepEqual(got, tt.want) { - t.Errorf("GetBaseReq() = %v, want %v", got, tt.want) + if got := transactionRequest.GetCommonTransactionRequest(); !reflect.DeepEqual(got, tt.want) { + t.Errorf("GetCommonTransactionRequest() = %v, want %v", got, tt.want) } }) } @@ -231,13 +179,13 @@ func Test_transactionRequest_GetBaseReq(t *testing.T) { func Test_transactionRequest_MakeMsg(t *testing.T) { type fields struct { - BaseReq rest.BaseReq - FromID string - MakerAssetID string - TakerAssetID string - MakerSplit string - TakerSplit string - ExpiryHeight int64 + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + MakerAssetID string + TakerAssetID string + MakerSplit string + TakerSplit string + ExpiryHeight int64 } tests := []struct { name string @@ -245,12 +193,12 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { want sdkTypes.Msg wantErr bool }{ - {"+ve", fields{testBaseRequest, testFromID.AsString(), makerAssetID.AsString(), takerAssetID.AsString(), makerSplit.String(), takerSplit.String(), expiryHeight}, NewMessage(fromAccAddress, testFromID, makerAssetID, takerAssetID, makerSplit, takerSplit, base.NewHeight(60)), false}, + {"+ve", fields{commonTransactionRequest, testFromID.AsString(), makerAssetID.AsString(), takerAssetID.AsString(), makerSplit.String(), takerSplit.String(), expiryHeight}, NewMessage(fromAccAddress, testFromID, makerAssetID, takerAssetID, makerSplit, takerSplit, base.NewHeight(60)), false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - tt.fields.BaseReq, + tt.fields.commonTransactionRequest, tt.fields.FromID, tt.fields.MakerAssetID, tt.fields.TakerAssetID, @@ -270,63 +218,27 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { } } -func Test_transactionRequest_RegisterCodec(t *testing.T) { - type fields struct { - BaseReq rest.BaseReq - FromID string - MakerAssetID string - TakerAssetID string - MakerSplit string - TakerSplit string - ExpiryHeight int64 - } - type args struct { - legacyAmino *codec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{testBaseRequest, testFromID.AsString(), makerAssetID.AsString(), takerAssetID.AsString(), makerSplit.String(), takerSplit.String(), expiryHeight}, args{codec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - tr := transactionRequest{ - tt.fields.BaseReq, - tt.fields.FromID, - tt.fields.MakerAssetID, - tt.fields.TakerAssetID, - tt.fields.MakerSplit, - tt.fields.TakerSplit, - tt.fields.ExpiryHeight, - } - tr.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - func Test_transactionRequest_Validate(t *testing.T) { type fields struct { - BaseReq rest.BaseReq - FromID string - MakerAssetID string - TakerAssetID string - MakerSplit string - TakerSplit string - ExpiryHeight int64 + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + MakerAssetID string + TakerAssetID string + MakerSplit string + TakerSplit string + ExpiryHeight int64 } tests := []struct { name string fields fields wantErr bool }{ - {"+ve", fields{testBaseRequest, testFromID.AsString(), makerAssetID.AsString(), takerAssetID.AsString(), makerSplit.String(), takerSplit.String(), expiryHeight}, false}, + {"+ve", fields{commonTransactionRequest, testFromID.AsString(), makerAssetID.AsString(), takerAssetID.AsString(), makerSplit.String(), takerSplit.String(), expiryHeight}, false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - tt.fields.BaseReq, + tt.fields.commonTransactionRequest, tt.fields.FromID, tt.fields.MakerAssetID, tt.fields.TakerAssetID, diff --git a/x/orders/transactions/put/transaction_response.go b/x/orders/transactions/put/transaction_response.go index 0092d1f2b..4c491f30b 100644 --- a/x/orders/transactions/put/transaction_response.go +++ b/x/orders/transactions/put/transaction_response.go @@ -4,11 +4,10 @@ package put import ( + "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" sdkTypes "github.com/cosmos/cosmos-sdk/types" - - "github.com/AssetMantle/modules/helpers" ) var _ helpers.TransactionResponse = (*TransactionResponse)(nil) diff --git a/x/orders/transactions/revoke/message.go b/x/orders/transactions/revoke/message.go index 78c8daf85..c69516d95 100644 --- a/x/orders/transactions/revoke/message.go +++ b/x/orders/transactions/revoke/message.go @@ -4,26 +4,15 @@ package revoke import ( - codecUtilities "github.com/AssetMantle/schema/codec/utilities" + "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/types" sdkTypes "github.com/cosmos/cosmos-sdk/types" - - "github.com/AssetMantle/modules/helpers" ) var _ helpers.Message = (*Message)(nil) -func (message *Message) Type() string { return Transaction.GetName() } -func (message *Message) GetFromAddress() sdkTypes.AccAddress { - from, err := sdkTypes.AccAddressFromBech32(message.From) - if err != nil { - panic(err) - } - return from -} func (message *Message) ValidateBasic() error { if _, err := sdkTypes.AccAddressFromBech32(message.From); err != nil { return err @@ -46,21 +35,10 @@ func (message *Message) GetSigners() []sdkTypes.AccAddress { } return []sdkTypes.AccAddress{from} } -func (*Message) RegisterLegacyAminoCodec(legacyAmino *codec.LegacyAmino) { - codecUtilities.RegisterModuleConcrete(legacyAmino, Message{}) -} func (message *Message) RegisterInterface(interfaceRegistry types.InterfaceRegistry) { interfaceRegistry.RegisterImplementations((*sdkTypes.Msg)(nil), message) } -func messageFromInterface(msg sdkTypes.Msg) *Message { - switch value := msg.(type) { - case *Message: - return value - default: - return &Message{} - } -} func messagePrototype() helpers.Message { return &Message{} } diff --git a/x/orders/transactions/revoke/message_test.go b/x/orders/transactions/revoke/message_test.go index f2efb0ca5..af3b61320 100644 --- a/x/orders/transactions/revoke/message_test.go +++ b/x/orders/transactions/revoke/message_test.go @@ -9,7 +9,6 @@ import ( "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/types" "github.com/AssetMantle/modules/helpers" @@ -26,26 +25,6 @@ type fields struct { ClassificationID *baseIDs.ClassificationID } -func Test_messageFromInterface(t *testing.T) { - type args struct { - msg types.Msg - } - tests := []struct { - name string - args args - want *Message - }{ - {"+ve", args{testMessage}, &Message{fromAccAddress.String(), testFromID, testFromID, testClassificationID}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := messageFromInterface(tt.args.msg); !reflect.DeepEqual(got, tt.want) { - t.Errorf("messageFromInterface() = %v, want %v", got, tt.want) - } - }) - } -} - func Test_messagePrototype(t *testing.T) { tests := []struct { name string @@ -86,55 +65,6 @@ func Test_message_GetSigners(t *testing.T) { } } -func Test_message_RegisterCodec(t *testing.T) { - - type args struct { - legacyAmino *codec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{fromAccAddress.String(), testFromID, testFromID, testClassificationID}, args{codec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - me := &Message{ - From: tt.fields.From, - FromID: tt.fields.FromID, - ToID: tt.fields.ToID, - ClassificationID: tt.fields.ClassificationID, - } - me.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - -func Test_message_Type(t *testing.T) { - - tests := []struct { - name string - fields fields - want string - }{ - {"+ve", fields{fromAccAddress.String(), testFromID, testFromID, testClassificationID}, Transaction.GetName()}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - message := &Message{ - From: tt.fields.From, - FromID: tt.fields.FromID, - ToID: tt.fields.ToID, - ClassificationID: tt.fields.ClassificationID, - } - if got := message.Type(); got != tt.want { - t.Errorf("Type() = %v, want %v", got, tt.want) - } - }) - } -} - func Test_message_ValidateBasic(t *testing.T) { tests := []struct { diff --git a/x/orders/transactions/revoke/service.pb.go b/x/orders/transactions/revoke/service.pb.go index 01151309f..07716844b 100644 --- a/x/orders/transactions/revoke/service.pb.go +++ b/x/orders/transactions/revoke/service.pb.go @@ -6,9 +6,9 @@ package revoke import ( context "context" fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types/msgservice" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" - _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -31,30 +31,30 @@ func init() { } var fileDescriptor_d9b7810b72c042ec = []byte{ - // 363 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0xd2, 0xcf, 0x4a, 0xeb, 0x40, - 0x14, 0x06, 0xf0, 0x26, 0x85, 0x2e, 0xc2, 0x5d, 0x15, 0x2e, 0x42, 0xd0, 0x2c, 0xfa, 0x00, 0x33, - 0xe2, 0x9f, 0x85, 0xa3, 0x08, 0x2d, 0x88, 0x82, 0x84, 0x96, 0xda, 0x45, 0x90, 0x80, 0x4c, 0x93, - 0x43, 0x0c, 0x26, 0x99, 0x32, 0x33, 0x2d, 0xdd, 0xea, 0x13, 0x08, 0xbe, 0x81, 0x3b, 0xdd, 0xf9, - 0x16, 0xe2, 0xaa, 0xe0, 0xc6, 0xa5, 0xa4, 0xae, 0x7c, 0x0a, 0xb1, 0x33, 0xe0, 0x74, 0x39, 0xdb, - 0x09, 0xbf, 0x8f, 0xef, 0x9c, 0x1c, 0xef, 0xb8, 0x2b, 0x04, 0xc8, 0x90, 0x56, 0xb2, 0x00, 0x5c, - 0xb2, 0x74, 0x5a, 0x80, 0xc0, 0x73, 0xcc, 0x78, 0x0a, 0x5c, 0x60, 0xc9, 0x69, 0x25, 0x68, 0x22, - 0x73, 0x56, 0x09, 0xcc, 0x61, 0xc6, 0x6e, 0x00, 0x0b, 0xe0, 0xb3, 0x3c, 0x01, 0x34, 0xe1, 0x4c, - 0xb2, 0xf6, 0xb6, 0xe1, 0x91, 0xf6, 0x68, 0x8e, 0x94, 0x47, 0xa6, 0x47, 0xca, 0xfb, 0x9b, 0x19, - 0x63, 0x59, 0x01, 0x98, 0x4e, 0x72, 0x4c, 0xab, 0x8a, 0x49, 0xaa, 0x3e, 0xaf, 0xf2, 0x7c, 0xfb, - 0x3e, 0x25, 0x08, 0x41, 0x33, 0xdd, 0xc7, 0x3f, 0xb7, 0xf6, 0xc6, 0xdb, 0x15, 0x07, 0x31, 0x61, - 0x95, 0xd0, 0x61, 0x3b, 0x2f, 0x8e, 0xd7, 0x0c, 0x45, 0xd6, 0x7e, 0x72, 0xbc, 0xd6, 0x19, 0xad, - 0xd2, 0x02, 0xda, 0x07, 0xc8, 0x76, 0x60, 0x14, 0xaa, 0x82, 0xfe, 0x89, 0x3d, 0x1d, 0xfd, 0xbd, - 0x0d, 0x75, 0xb5, 0xce, 0xd6, 0xdd, 0xfb, 0xd7, 0x83, 0xbb, 0xd1, 0xf9, 0x8f, 0x4b, 0x35, 0xa5, - 0x9e, 0x4d, 0x91, 0xde, 0x6d, 0xf3, 0xb5, 0x0e, 0x9c, 0x45, 0x1d, 0x38, 0x9f, 0x75, 0xe0, 0xdc, - 0x2f, 0x83, 0xc6, 0x62, 0x19, 0x34, 0x3e, 0x96, 0x41, 0xc3, 0xdb, 0x4b, 0x58, 0x69, 0xdd, 0xa1, - 0xf7, 0xef, 0x42, 0xfd, 0xf0, 0xc1, 0xef, 0x4a, 0x06, 0xce, 0xe5, 0x61, 0x96, 0xcb, 0xeb, 0xe9, - 0x18, 0x25, 0xac, 0xc4, 0xb6, 0xcb, 0x7e, 0x74, 0x5b, 0xdd, 0x30, 0xea, 0x8f, 0x86, 0xcf, 0xee, - 0xda, 0xe1, 0x84, 0xba, 0x48, 0x84, 0xfa, 0xaa, 0xc8, 0xc8, 0x2c, 0x32, 0x5c, 0xd9, 0xb7, 0x35, - 0x12, 0x6b, 0x12, 0x47, 0xb1, 0x22, 0xb1, 0x49, 0x62, 0x45, 0x6a, 0xf7, 0xc8, 0x96, 0xc4, 0xa7, - 0x83, 0x5e, 0x08, 0x92, 0xa6, 0x54, 0xd2, 0x6f, 0x77, 0xdf, 0xe0, 0x84, 0x68, 0x4f, 0x48, 0x44, - 0x88, 0x4a, 0x20, 0xc4, 0x8c, 0x20, 0x44, 0x65, 0x8c, 0x5b, 0xab, 0xf3, 0xd9, 0xfd, 0x09, 0x00, - 0x00, 0xff, 0xff, 0xfa, 0x0a, 0x81, 0x17, 0x5d, 0x03, 0x00, 0x00, + // 353 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0xd2, 0xbf, 0x4b, 0xf3, 0x40, + 0x18, 0x07, 0xf0, 0x5c, 0xca, 0xdb, 0x21, 0xbc, 0x53, 0x97, 0x17, 0x32, 0x64, 0x78, 0x47, 0x87, + 0x3b, 0x7f, 0x0e, 0x9e, 0x22, 0xb4, 0x20, 0x0a, 0x12, 0x5a, 0x6a, 0x87, 0x20, 0x01, 0xb9, 0x26, + 0x47, 0x2c, 0x36, 0xb9, 0x72, 0xcf, 0xb5, 0x74, 0xd4, 0xdd, 0xc1, 0xdd, 0xcd, 0xd1, 0xc9, 0x3f, + 0x43, 0x9c, 0x3a, 0x3a, 0x4a, 0x3a, 0x08, 0xfe, 0x15, 0xd2, 0xde, 0x81, 0xd7, 0xf1, 0xa6, 0xc0, + 0x03, 0x9f, 0x6f, 0xbe, 0x4f, 0xf2, 0x04, 0x27, 0x6d, 0x00, 0xae, 0x62, 0x56, 0xa9, 0x31, 0x27, + 0xa5, 0xc8, 0xa7, 0x63, 0x0e, 0x64, 0x4e, 0x84, 0xcc, 0xb9, 0x04, 0xa2, 0x24, 0xab, 0x80, 0x65, + 0x6a, 0x24, 0x2a, 0x20, 0x92, 0xcf, 0xc4, 0x2d, 0x27, 0xc0, 0xe5, 0x6c, 0x94, 0x71, 0x3c, 0x91, + 0x42, 0x89, 0xd6, 0xb6, 0xe5, 0xb1, 0xf1, 0x78, 0x8e, 0xb5, 0xc7, 0xb6, 0xc7, 0xda, 0x87, 0xff, + 0x32, 0x01, 0xa5, 0x00, 0x52, 0x42, 0x41, 0x66, 0x3b, 0xab, 0x87, 0x8e, 0x0a, 0xdd, 0xab, 0x94, + 0x1c, 0x80, 0x15, 0xa6, 0x4a, 0x78, 0xe1, 0xec, 0xad, 0xd9, 0xb5, 0xe4, 0x30, 0x11, 0x15, 0x98, + 0xb0, 0xdd, 0x27, 0x14, 0x34, 0x62, 0x28, 0x5a, 0x0f, 0x28, 0x68, 0x9e, 0xb3, 0x2a, 0x1f, 0xf3, + 0xd6, 0x21, 0x76, 0xdd, 0x15, 0xc7, 0xba, 0x60, 0x78, 0xea, 0x4e, 0x07, 0xbf, 0xb3, 0xbe, 0xa9, + 0xf6, 0xdf, 0x0b, 0xff, 0xdc, 0x7d, 0xbd, 0x6e, 0xa1, 0xce, 0x7d, 0xe3, 0xad, 0x8e, 0xd0, 0xa2, + 0x8e, 0xd0, 0x67, 0x1d, 0xa1, 0xc7, 0x65, 0xe4, 0x2d, 0x96, 0x91, 0xf7, 0xb1, 0x8c, 0xbc, 0x60, + 0x3f, 0x13, 0xa5, 0xf3, 0xdb, 0x3a, 0x7f, 0x2f, 0xf5, 0x5f, 0xed, 0xad, 0x96, 0xef, 0xa1, 0xab, + 0xa3, 0x62, 0xa4, 0x6e, 0xa6, 0x43, 0x9c, 0x89, 0x92, 0xb8, 0x7e, 0xd6, 0x67, 0xbf, 0xd9, 0x8e, + 0x93, 0xee, 0xa0, 0xff, 0xe2, 0x6f, 0x5c, 0x47, 0x6c, 0x8a, 0x24, 0xb8, 0xab, 0x8b, 0x0c, 0xec, + 0x22, 0xfd, 0xb5, 0x7d, 0xdf, 0x20, 0xa9, 0x21, 0x69, 0x92, 0x6a, 0x92, 0xda, 0x24, 0xd5, 0xa4, + 0xf6, 0x8f, 0x5d, 0x49, 0x7a, 0xd6, 0xeb, 0xc4, 0x5c, 0xb1, 0x9c, 0x29, 0xf6, 0xed, 0x1f, 0x58, + 0x9c, 0x52, 0xe3, 0x29, 0x4d, 0x28, 0xd5, 0x09, 0x94, 0xda, 0x11, 0x94, 0xea, 0x8c, 0x61, 0x73, + 0x7d, 0x28, 0x7b, 0x3f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x30, 0x12, 0x67, 0x70, 0x42, 0x03, 0x00, + 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/orders/transactions/revoke/service.pb.gw.go b/x/orders/transactions/revoke/service.pb.gw.go deleted file mode 100644 index 2e772ae33..000000000 --- a/x/orders/transactions/revoke/service.pb.gw.go +++ /dev/null @@ -1,171 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: AssetMantle/modules/x/orders/transactions/revoke/service.proto - -/* -Package revoke is a reverse proxy. - -It translates gRPC into RESTful JSON APIs. -*/ -package revoke - -import ( - "context" - "io" - "net/http" - - "github.com/golang/protobuf/descriptor" - "github.com/golang/protobuf/proto" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/grpc-ecosystem/grpc-gateway/utilities" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/status" -) - -// Suppress "imported and not used" errors -var _ codes.Code -var _ io.Reader -var _ status.Status -var _ = runtime.String -var _ = utilities.NewDoubleArray -var _ = descriptor.ForMessage -var _ = metadata.Join - -var ( - filter_Msg_Handle_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - -func request_Msg_Handle_0(ctx context.Context, marshaler runtime.Marshaler, client MsgClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq Message - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.Handle(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Msg_Handle_0(ctx context.Context, marshaler runtime.Marshaler, server MsgServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq Message - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.Handle(ctx, &protoReq) - return msg, metadata, err - -} - -// RegisterMsgHandlerServer registers the http handlers for service Msg to "mux". -// UnaryRPC :call MsgServer directly. -// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterMsgHandlerFromEndpoint instead. -func RegisterMsgHandlerServer(ctx context.Context, mux *runtime.ServeMux, server MsgServer) error { - - mux.Handle("POST", pattern_Msg_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Msg_Handle_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Msg_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -// RegisterMsgHandlerFromEndpoint is same as RegisterMsgHandler but -// automatically dials to "endpoint" and closes the connection when "ctx" gets done. -func RegisterMsgHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.Dial(endpoint, opts...) - if err != nil { - return err - } - defer func() { - if err != nil { - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - return - } - go func() { - <-ctx.Done() - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - }() - }() - - return RegisterMsgHandler(ctx, mux, conn) -} - -// RegisterMsgHandler registers the http handlers for service Msg to "mux". -// The handlers forward requests to the grpc endpoint over "conn". -func RegisterMsgHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { - return RegisterMsgHandlerClient(ctx, mux, NewMsgClient(conn)) -} - -// RegisterMsgHandlerClient registers the http handlers for service Msg -// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "MsgClient". -// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "MsgClient" -// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "MsgClient" to call the correct interceptors. -func RegisterMsgHandlerClient(ctx context.Context, mux *runtime.ServeMux, client MsgClient) error { - - mux.Handle("POST", pattern_Msg_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Msg_Handle_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Msg_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -var ( - pattern_Msg_Handle_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"mantle", "orders", "revoke"}, "", runtime.AssumeColonVerbOpt(false))) -) - -var ( - forward_Msg_Handle_0 = runtime.ForwardResponseMessage -) diff --git a/x/orders/transactions/revoke/transaction.go b/x/orders/transactions/revoke/transaction.go index c32599e72..0e9712af4 100644 --- a/x/orders/transactions/revoke/transaction.go +++ b/x/orders/transactions/revoke/transaction.go @@ -4,22 +4,14 @@ package revoke import ( - "context" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "google.golang.org/grpc" - "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/helpers/constants" - "github.com/AssetMantle/modules/utilities/name" + "google.golang.org/grpc" ) -type dummy struct{} - var Transaction = baseHelpers.NewTransaction( - name.GetPackageName(dummy{}), + _Msg_serviceDesc.ServiceName, "", "", @@ -30,9 +22,6 @@ var Transaction = baseHelpers.NewTransaction( func(server grpc.ServiceRegistrar, keeper helpers.TransactionKeeper) { RegisterMsgServer(server, keeper.(transactionKeeper)) }, - func(clientCtx client.Context, mux *runtime.ServeMux) error { - return RegisterMsgHandlerClient(context.Background(), mux, NewMsgClient(clientCtx)) - }, constants.FromIdentityID, constants.ToIdentityID, diff --git a/x/orders/transactions/revoke/transaction_keeper.go b/x/orders/transactions/revoke/transaction_keeper.go index 0e0e10b10..b397997a0 100644 --- a/x/orders/transactions/revoke/transaction_keeper.go +++ b/x/orders/transactions/revoke/transaction_keeper.go @@ -5,7 +5,6 @@ package revoke import ( "context" - "github.com/cosmos/cosmos-sdk/types" "github.com/AssetMantle/modules/helpers" diff --git a/x/orders/transactions/revoke/transaction_request.go b/x/orders/transactions/revoke/transaction_request.go index 509d3f989..d45358ed4 100644 --- a/x/orders/transactions/revoke/transaction_request.go +++ b/x/orders/transactions/revoke/transaction_request.go @@ -5,24 +5,22 @@ package revoke import ( "encoding/json" - "github.com/AssetMantle/modules/utilities/rest" - - codecUtilities "github.com/AssetMantle/schema/codec/utilities" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" + "io" + "net/http" "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/helpers/constants" ) type transactionRequest struct { - BaseReq rest.BaseReq `json:"baseReq"` - FromID string `json:"fromID"` - ToID string `json:"toID"` - ClassificationID string `json:"classificationID"` + helpers.CommonTransactionRequest `json:"commonTransactionRequest"` + FromID string `json:"fromID"` + ToID string `json:"toID"` + ClassificationID string `json:"classificationID"` } var _ helpers.TransactionRequest = (*transactionRequest)(nil) @@ -48,24 +46,29 @@ func (transactionRequest transactionRequest) Validate() error { } func (transactionRequest transactionRequest) FromCLI(cliCommand helpers.CLICommand, context client.Context) (helpers.TransactionRequest, error) { return newTransactionRequest( - cliCommand.ReadBaseReq(context), + cliCommand.ReadCommonTransactionRequest(context), cliCommand.ReadString(constants.FromIdentityID), cliCommand.ReadString(constants.ToIdentityID), cliCommand.ReadString(constants.ClassificationID), ), nil } -func (transactionRequest transactionRequest) FromJSON(rawMessage json.RawMessage) (helpers.TransactionRequest, error) { - if err := json.Unmarshal(rawMessage, &transactionRequest); err != nil { +func (transactionRequest transactionRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.TransactionRequest, error) { + body, err := io.ReadAll(httpRequest.Body) + if err != nil { + return nil, err + } + + if err := json.Unmarshal(body, &transactionRequest); err != nil { return nil, err } return transactionRequest, nil } -func (transactionRequest transactionRequest) GetBaseReq() rest.BaseReq { - return transactionRequest.BaseReq +func (transactionRequest transactionRequest) GetCommonTransactionRequest() helpers.CommonTransactionRequest { + return transactionRequest.CommonTransactionRequest } func (transactionRequest transactionRequest) MakeMsg() (sdkTypes.Msg, error) { - from, err := sdkTypes.AccAddressFromBech32(transactionRequest.GetBaseReq().From) + from, err := sdkTypes.AccAddressFromBech32(transactionRequest.GetCommonTransactionRequest().GetFrom()) if err != nil { return nil, err } @@ -92,18 +95,15 @@ func (transactionRequest transactionRequest) MakeMsg() (sdkTypes.Msg, error) { classificationID.(ids.ClassificationID), ), nil } -func (transactionRequest) RegisterLegacyAminoCodec(legacyAmino *codec.LegacyAmino) { - codecUtilities.RegisterModuleConcrete(legacyAmino, transactionRequest{}) -} func requestPrototype() helpers.TransactionRequest { return transactionRequest{} } -func newTransactionRequest(baseReq rest.BaseReq, fromID string, toID string, classificationID string) helpers.TransactionRequest { +func newTransactionRequest(commonTransactionRequest helpers.CommonTransactionRequest, fromID string, toID string, classificationID string) helpers.TransactionRequest { return transactionRequest{ - BaseReq: baseReq, - FromID: fromID, - ToID: toID, - ClassificationID: classificationID, + CommonTransactionRequest: commonTransactionRequest, + FromID: fromID, + ToID: toID, + ClassificationID: classificationID, } } diff --git a/x/orders/transactions/revoke/transaction_request_test.go b/x/orders/transactions/revoke/transaction_request_test.go index 8bca95311..db5d19af1 100644 --- a/x/orders/transactions/revoke/transaction_request_test.go +++ b/x/orders/transactions/revoke/transaction_request_test.go @@ -4,9 +4,7 @@ package revoke import ( - "encoding/json" "fmt" - "github.com/AssetMantle/modules/utilities/rest" "reflect" "testing" @@ -16,15 +14,12 @@ import ( baseProperties "github.com/AssetMantle/schema/properties/base" baseQualified "github.com/AssetMantle/schema/qualified/base" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/types" - "github.com/spf13/viper" - "github.com/stretchr/testify/require" - "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/helpers/constants" + "github.com/spf13/viper" ) var ( @@ -33,28 +28,28 @@ var ( immutables = baseQualified.NewImmutables(base.NewPropertyList(baseProperties.NewMesaProperty(baseIDs.NewStringID("ID2"), baseData.NewStringData("Data2")))) mutables = baseQualified.NewMutables(base.NewPropertyList(baseProperties.NewMesaProperty(baseIDs.NewStringID("ID1"), baseData.NewStringData("Data1")))) - testClassificationID = baseIDs.NewClassificationID(immutables, mutables).(*baseIDs.ClassificationID) - testFromID = baseIDs.NewIdentityID(testClassificationID, immutables).(*baseIDs.IdentityID) - testBaseRequest = rest.BaseReq{From: fromAddress, ChainID: "test", Fees: types.NewCoins()} + testClassificationID = baseIDs.NewClassificationID(immutables, mutables).(*baseIDs.ClassificationID) + testFromID = baseIDs.NewIdentityID(testClassificationID, immutables).(*baseIDs.IdentityID) + commonTransactionRequest = helpers.PrototypeCommonTransactionRequest() ) func Test_newTransactionRequest(t *testing.T) { type args struct { - baseReq rest.BaseReq - fromID string - toID string - classificationID string + commonTransactionRequest helpers.CommonTransactionRequest + fromID string + toID string + classificationID string } tests := []struct { name string args args want helpers.TransactionRequest }{ - {"+ve", args{testBaseRequest, testFromID.AsString(), testFromID.AsString(), testClassificationID.AsString()}, transactionRequest{testBaseRequest, testFromID.AsString(), testFromID.AsString(), testClassificationID.AsString()}}, + {"+ve", args{commonTransactionRequest, testFromID.AsString(), testFromID.AsString(), testClassificationID.AsString()}, transactionRequest{commonTransactionRequest, testFromID.AsString(), testFromID.AsString(), testClassificationID.AsString()}}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - if got := newTransactionRequest(tt.args.baseReq, tt.args.fromID, tt.args.toID, tt.args.classificationID); !reflect.DeepEqual(got, tt.want) { + if got := newTransactionRequest(tt.args.commonTransactionRequest, tt.args.fromID, tt.args.toID, tt.args.classificationID); !reflect.DeepEqual(got, tt.want) { t.Errorf("newTransactionRequest() = %v, want %v", got, tt.want) } }) @@ -84,10 +79,10 @@ func Test_transactionRequest_FromCLI(t *testing.T) { viper.Set(constants.ToIdentityID.GetName(), testFromID.AsString()) viper.Set(constants.ClassificationID.GetName(), testClassificationID.AsString()) type fields struct { - BaseReq rest.BaseReq - FromID string - ToID string - ClassificationID string + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + ToID string + ClassificationID string } type args struct { cliCommand helpers.CLICommand @@ -100,15 +95,15 @@ func Test_transactionRequest_FromCLI(t *testing.T) { want helpers.TransactionRequest wantErr bool }{ - {"+ve", fields{testBaseRequest, testFromID.AsString(), testFromID.AsString(), testClassificationID.AsString()}, args{cliCommand, client.Context{}.WithCodec(baseHelpers.CodecPrototype())}, transactionRequest{testBaseRequest, testFromID.AsString(), testFromID.AsString(), testClassificationID.AsString()}, false}, + {"+ve", fields{commonTransactionRequest, testFromID.AsString(), testFromID.AsString(), testClassificationID.AsString()}, args{cliCommand, client.Context{}.WithCodec(baseHelpers.CodecPrototype())}, transactionRequest{commonTransactionRequest, testFromID.AsString(), testFromID.AsString(), testClassificationID.AsString()}, false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - ToID: tt.fields.ToID, - ClassificationID: tt.fields.ClassificationID, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + ToID: tt.fields.ToID, + ClassificationID: tt.fields.ClassificationID, } got, err := transactionRequest.FromCLI(tt.args.cliCommand, tt.args.context) if (err != nil) != tt.wantErr { @@ -122,71 +117,30 @@ func Test_transactionRequest_FromCLI(t *testing.T) { } } -func Test_transactionRequest_FromJSON(t *testing.T) { - jsonMessage, err := json.Marshal(newTransactionRequest(testBaseRequest, testFromID.AsString(), testFromID.AsString(), testClassificationID.AsString())) - require.NoError(t, err) - type fields struct { - BaseReq rest.BaseReq - FromID string - ToID string - ClassificationID string - } - type args struct { - rawMessage json.RawMessage - } - tests := []struct { - name string - fields fields - args args - want helpers.TransactionRequest - wantErr bool - }{ - {"+ve", fields{testBaseRequest, testFromID.AsString(), testFromID.AsString(), testClassificationID.AsString()}, args{jsonMessage}, newTransactionRequest(testBaseRequest, testFromID.AsString(), testFromID.AsString(), testClassificationID.AsString()), false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - ToID: tt.fields.ToID, - ClassificationID: tt.fields.ClassificationID, - } - got, err := transactionRequest.FromJSON(tt.args.rawMessage) - if (err != nil) != tt.wantErr { - t.Errorf("FromJSON() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("FromJSON() got = %v, want %v", got, tt.want) - } - }) - } -} - func Test_transactionRequest_GetBaseReq(t *testing.T) { type fields struct { - BaseReq rest.BaseReq - FromID string - ToID string - ClassificationID string + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + ToID string + ClassificationID string } tests := []struct { name string fields fields - want rest.BaseReq + want helpers.CommonTransactionRequest }{ - {"+ve", fields{testBaseRequest, testFromID.AsString(), testFromID.AsString(), testClassificationID.AsString()}, testBaseRequest}, + {"+ve", fields{commonTransactionRequest, testFromID.AsString(), testFromID.AsString(), testClassificationID.AsString()}, commonTransactionRequest}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - ToID: tt.fields.ToID, - ClassificationID: tt.fields.ClassificationID, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + ToID: tt.fields.ToID, + ClassificationID: tt.fields.ClassificationID, } - if got := transactionRequest.GetBaseReq(); !reflect.DeepEqual(got, tt.want) { - t.Errorf("GetBaseReq() = %v, want %v", got, tt.want) + if got := transactionRequest.GetCommonTransactionRequest(); !reflect.DeepEqual(got, tt.want) { + t.Errorf("GetCommonTransactionRequest() = %v, want %v", got, tt.want) } }) } @@ -194,10 +148,10 @@ func Test_transactionRequest_GetBaseReq(t *testing.T) { func Test_transactionRequest_MakeMsg(t *testing.T) { type fields struct { - BaseReq rest.BaseReq - FromID string - ToID string - ClassificationID string + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + ToID string + ClassificationID string } tests := []struct { name string @@ -205,15 +159,15 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { want types.Msg wantErr bool }{ - {"+ve", fields{testBaseRequest, testFromID.AsString(), testFromID.AsString(), testClassificationID.AsString()}, NewMessage(fromAccAddress, testFromID, testFromID, testClassificationID), false}, + {"+ve", fields{commonTransactionRequest, testFromID.AsString(), testFromID.AsString(), testClassificationID.AsString()}, NewMessage(fromAccAddress, testFromID, testFromID, testClassificationID), false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - ToID: tt.fields.ToID, - ClassificationID: tt.fields.ClassificationID, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + ToID: tt.fields.ToID, + ClassificationID: tt.fields.ClassificationID, } got, err := transactionRequest.MakeMsg() if (err != nil) != tt.wantErr { @@ -227,57 +181,27 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { } } -func Test_transactionRequest_RegisterCodec(t *testing.T) { - type fields struct { - BaseReq rest.BaseReq - FromID string - ToID string - ClassificationID string - } - type args struct { - legacyAmino *codec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{testBaseRequest, testFromID.AsString(), testFromID.AsString(), testClassificationID.AsString()}, args{codec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - tr := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - ToID: tt.fields.ToID, - ClassificationID: tt.fields.ClassificationID, - } - tr.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - func Test_transactionRequest_Validate(t *testing.T) { type fields struct { - BaseReq rest.BaseReq - FromID string - ToID string - ClassificationID string + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + ToID string + ClassificationID string } tests := []struct { name string fields fields wantErr bool }{ - {"+ve", fields{testBaseRequest, testFromID.AsString(), testFromID.AsString(), testClassificationID.AsString()}, false}, + {"+ve", fields{commonTransactionRequest, testFromID.AsString(), testFromID.AsString(), testClassificationID.AsString()}, false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - ToID: tt.fields.ToID, - ClassificationID: tt.fields.ClassificationID, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + ToID: tt.fields.ToID, + ClassificationID: tt.fields.ClassificationID, } if err := transactionRequest.Validate(); (err != nil) != tt.wantErr { t.Errorf("ValidateBasic() error = %v, wantErr %v", err, tt.wantErr) diff --git a/x/orders/transactions/revoke/transaction_response.go b/x/orders/transactions/revoke/transaction_response.go index 53eebfc72..272941180 100644 --- a/x/orders/transactions/revoke/transaction_response.go +++ b/x/orders/transactions/revoke/transaction_response.go @@ -4,9 +4,8 @@ package revoke import ( - sdkTypes "github.com/cosmos/cosmos-sdk/types" - "github.com/AssetMantle/modules/helpers" + sdkTypes "github.com/cosmos/cosmos-sdk/types" ) var _ helpers.TransactionResponse = (*TransactionResponse)(nil) diff --git a/x/orders/transactions/take/message.go b/x/orders/transactions/take/message.go index 664267888..a0a249ec9 100644 --- a/x/orders/transactions/take/message.go +++ b/x/orders/transactions/take/message.go @@ -4,27 +4,16 @@ package take import ( + "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/helpers/constants" - codecUtilities "github.com/AssetMantle/schema/codec/utilities" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/types" sdkTypes "github.com/cosmos/cosmos-sdk/types" - - "github.com/AssetMantle/modules/helpers" ) var _ helpers.Message = (*Message)(nil) -func (message *Message) Type() string { return Transaction.GetName() } -func (message *Message) GetFromAddress() sdkTypes.AccAddress { - from, err := sdkTypes.AccAddressFromBech32(message.From) - if err != nil { - panic(err) - } - return from -} func (message *Message) ValidateBasic() error { if _, err := sdkTypes.AccAddressFromBech32(message.From); err != nil { return err @@ -47,21 +36,10 @@ func (message *Message) GetSigners() []sdkTypes.AccAddress { } return []sdkTypes.AccAddress{from} } -func (*Message) RegisterLegacyAminoCodec(legacyAmino *codec.LegacyAmino) { - codecUtilities.RegisterModuleConcrete(legacyAmino, Message{}) -} func (message *Message) RegisterInterface(interfaceRegistry types.InterfaceRegistry) { interfaceRegistry.RegisterImplementations((*sdkTypes.Msg)(nil), message) } -func messageFromInterface(msg sdkTypes.Msg) *Message { - switch value := msg.(type) { - case *Message: - return value - default: - return &Message{} - } -} func messagePrototype() helpers.Message { return &Message{} } diff --git a/x/orders/transactions/take/message_test.go b/x/orders/transactions/take/message_test.go index 1449d0f69..d9140c71d 100644 --- a/x/orders/transactions/take/message_test.go +++ b/x/orders/transactions/take/message_test.go @@ -9,7 +9,6 @@ import ( "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/types" "github.com/AssetMantle/modules/helpers" @@ -26,26 +25,6 @@ type fields struct { OrderID *baseIDs.OrderID } -func Test_messageFromInterface(t *testing.T) { - type args struct { - msg types.Msg - } - tests := []struct { - name string - args args - want *Message - }{ - {"+ve", args{testMessage}, &Message{fromAccAddress.String(), testFromID, takerSplit.String(), testOrderID}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := messageFromInterface(tt.args.msg); !reflect.DeepEqual(got, tt.want) { - t.Errorf("messageFromInterface() = %v, want %v", got, tt.want) - } - }) - } -} - func Test_messagePrototype(t *testing.T) { tests := []struct { name string @@ -86,55 +65,6 @@ func Test_message_GetSigners(t *testing.T) { } } -func Test_message_RegisterCodec(t *testing.T) { - - type args struct { - legacyAmino *codec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{fromAccAddress.String(), testFromID, takerSplit, testOrderID}, args{codec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - me := &Message{ - From: tt.fields.From, - FromID: tt.fields.FromID, - TakerSplit: tt.fields.TakerSplit.String(), - OrderID: tt.fields.OrderID, - } - me.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - -func Test_message_Type(t *testing.T) { - - tests := []struct { - name string - fields fields - want string - }{ - {"+ve", fields{fromAccAddress.String(), testFromID, takerSplit, testOrderID}, Transaction.GetName()}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - message := &Message{ - From: tt.fields.From, - FromID: tt.fields.FromID, - TakerSplit: tt.fields.TakerSplit.String(), - OrderID: tt.fields.OrderID, - } - if got := message.Type(); got != tt.want { - t.Errorf("Type() = %v, want %v", got, tt.want) - } - }) - } -} - func Test_message_ValidateBasic(t *testing.T) { tests := []struct { diff --git a/x/orders/transactions/take/service.pb.go b/x/orders/transactions/take/service.pb.go index 1d535be1d..463b0f1a1 100644 --- a/x/orders/transactions/take/service.pb.go +++ b/x/orders/transactions/take/service.pb.go @@ -6,9 +6,9 @@ package take import ( context "context" fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types/msgservice" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" - _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -31,30 +31,29 @@ func init() { } var fileDescriptor_bef3612b3af5a204 = []byte{ - // 361 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0xd2, 0x31, 0x4b, 0xf3, 0x40, - 0x18, 0xc0, 0xf1, 0x26, 0x2f, 0x74, 0x08, 0xef, 0xd4, 0x97, 0x77, 0xc9, 0xfb, 0x92, 0xa1, 0x1f, - 0xe0, 0x0e, 0xda, 0x41, 0x3c, 0x5c, 0x5a, 0x07, 0x75, 0x08, 0x2d, 0x9a, 0x21, 0x48, 0x40, 0x9e, - 0x26, 0x0f, 0x31, 0x34, 0xc9, 0x95, 0xdc, 0x55, 0x3a, 0xfb, 0x09, 0x04, 0xbf, 0x81, 0x6e, 0xfa, - 0x45, 0xc4, 0xa9, 0xe0, 0xe2, 0x28, 0xa9, 0x93, 0xbb, 0xbb, 0xa4, 0x17, 0xf1, 0x3a, 0xde, 0x7a, - 0xe1, 0xf7, 0xe4, 0xff, 0x5c, 0xe2, 0x1c, 0x8c, 0x84, 0x40, 0xe9, 0x43, 0x29, 0x73, 0xa4, 0x05, - 0x4f, 0x96, 0x39, 0x0a, 0xba, 0xa2, 0xbc, 0x4a, 0xb0, 0x12, 0x54, 0x56, 0x50, 0x0a, 0x88, 0x65, - 0xc6, 0x4b, 0x41, 0x25, 0xcc, 0x91, 0x0a, 0xac, 0xae, 0xb2, 0x18, 0xc9, 0xa2, 0xe2, 0x92, 0xf7, - 0x88, 0xa6, 0x49, 0xab, 0xc9, 0x8a, 0x28, 0x4d, 0x74, 0x4d, 0x1a, 0xed, 0xfe, 0x4f, 0x39, 0x4f, - 0x73, 0xa4, 0xb0, 0xc8, 0x28, 0x94, 0x25, 0x97, 0xa0, 0x1e, 0x6e, 0xa7, 0xb9, 0xa6, 0x2d, 0x05, - 0x0a, 0x01, 0x69, 0xdb, 0xe2, 0x9e, 0x18, 0x6a, 0xed, 0xe4, 0xa2, 0x42, 0xb1, 0xe0, 0xa5, 0x68, - 0x47, 0x0d, 0x1e, 0x2d, 0xe7, 0x97, 0x2f, 0xd2, 0xde, 0xbd, 0xe5, 0x74, 0x8f, 0xa1, 0x4c, 0x72, - 0xec, 0xed, 0x19, 0xae, 0x4a, 0x7c, 0x15, 0xe7, 0x1e, 0x9a, 0xc2, 0xe0, 0xe7, 0xe4, 0xb4, 0xcd, - 0xea, 0xff, 0xbb, 0x7e, 0x79, 0xbf, 0xb5, 0xff, 0xf6, 0xff, 0xd0, 0x42, 0xed, 0xf7, 0xbd, 0x15, - 0xcc, 0x71, 0xfc, 0x69, 0x3f, 0xd5, 0x9e, 0xb5, 0xae, 0x3d, 0xeb, 0xad, 0xf6, 0xac, 0x9b, 0x8d, - 0xd7, 0x59, 0x6f, 0xbc, 0xce, 0xeb, 0xc6, 0xeb, 0x38, 0x83, 0x98, 0x17, 0x86, 0xef, 0x1f, 0xff, - 0x3e, 0x53, 0x9f, 0x78, 0xda, 0x5c, 0xc5, 0xd4, 0x3a, 0xdf, 0x4f, 0x33, 0x79, 0xb9, 0x9c, 0x91, - 0x98, 0x17, 0xd4, 0xec, 0x8a, 0xef, 0xec, 0xee, 0xc8, 0x0f, 0x27, 0x41, 0xf0, 0x60, 0xef, 0x44, - 0xf8, 0x6d, 0x44, 0x48, 0x26, 0x2a, 0x22, 0xd0, 0x23, 0x02, 0x98, 0xe3, 0xf3, 0x0e, 0x88, 0x5a, - 0x10, 0x85, 0x91, 0x02, 0x91, 0x0e, 0xa2, 0x06, 0xd4, 0x36, 0x33, 0x03, 0xd1, 0xd1, 0x74, 0xec, - 0xa3, 0x84, 0x04, 0x24, 0x7c, 0xd8, 0x43, 0x0d, 0x33, 0xd6, 0x6a, 0xc6, 0x42, 0xc6, 0x94, 0x67, - 0x4c, 0x1f, 0xc0, 0x58, 0x33, 0x61, 0xd6, 0xdd, 0xfe, 0x2c, 0xc3, 0xaf, 0x00, 0x00, 0x00, 0xff, - 0xff, 0xa1, 0xd4, 0x58, 0xc6, 0x43, 0x03, 0x00, 0x00, + // 345 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0xd2, 0x31, 0x4b, 0xc3, 0x40, + 0x14, 0xc0, 0xf1, 0x5c, 0xc4, 0x0e, 0xc1, 0xa9, 0x8b, 0x90, 0x21, 0x83, 0xa3, 0xc3, 0x1d, 0xb6, + 0x83, 0x78, 0xb8, 0xb4, 0x0e, 0xea, 0x10, 0x5a, 0x34, 0x43, 0x90, 0x80, 0x5c, 0x93, 0x23, 0x96, + 0x36, 0xb9, 0x92, 0x77, 0x2d, 0x1d, 0x1d, 0x1d, 0xdd, 0xdc, 0x1d, 0x9d, 0xfc, 0x18, 0xe2, 0xd4, + 0xd1, 0x51, 0x92, 0x41, 0x70, 0x77, 0x97, 0x78, 0x07, 0x5e, 0xc7, 0x9b, 0x02, 0x07, 0xbf, 0x97, + 0xff, 0x4b, 0xce, 0x3b, 0x1d, 0x00, 0x70, 0x19, 0xb2, 0x52, 0xce, 0x39, 0x29, 0x44, 0xb6, 0x9c, + 0x73, 0x20, 0x6b, 0x22, 0xaa, 0x8c, 0x57, 0x40, 0x64, 0xc5, 0x4a, 0x60, 0xa9, 0x9c, 0x8a, 0x12, + 0x88, 0x64, 0x33, 0x4e, 0x80, 0x57, 0xab, 0x69, 0xca, 0xf1, 0xa2, 0x12, 0x52, 0x74, 0xb1, 0xa1, + 0xb1, 0xd6, 0x78, 0x8d, 0x95, 0xc6, 0xa6, 0xc6, 0xad, 0xf6, 0xf7, 0x53, 0x01, 0x85, 0x00, 0x52, + 0x40, 0x4e, 0x56, 0x47, 0xed, 0x43, 0x0d, 0xf2, 0x6d, 0x33, 0x0a, 0x0e, 0xc0, 0x72, 0x9d, 0xe1, + 0x5f, 0x5a, 0x6a, 0xe3, 0xe4, 0xb6, 0xe2, 0xb0, 0x10, 0x25, 0xe8, 0x51, 0xbd, 0x27, 0xe4, 0xed, + 0x84, 0x90, 0x77, 0x1f, 0x90, 0xd7, 0xb9, 0x60, 0x65, 0x36, 0xe7, 0xdd, 0x63, 0xcb, 0x2d, 0x71, + 0xa8, 0xe2, 0xfc, 0x33, 0x5b, 0x18, 0xfd, 0x9f, 0x5c, 0xe9, 0xac, 0x03, 0xc7, 0xdf, 0xbd, 0xff, + 0x7a, 0x3d, 0x44, 0xc3, 0x1f, 0xf7, 0xad, 0x0e, 0xd0, 0xa6, 0x0e, 0xd0, 0x67, 0x1d, 0xa0, 0xc7, + 0x26, 0x70, 0x36, 0x4d, 0xe0, 0x7c, 0x34, 0x81, 0xe3, 0xf5, 0x52, 0x51, 0x58, 0xbe, 0x6b, 0xb8, + 0x77, 0xad, 0xfe, 0xe4, 0xb8, 0x5d, 0x7b, 0x8c, 0x6e, 0x4e, 0xf2, 0xa9, 0xbc, 0x5b, 0x4e, 0x70, + 0x2a, 0x0a, 0x62, 0xf7, 0x39, 0x9f, 0xdd, 0xce, 0x20, 0x8c, 0x47, 0x51, 0xf4, 0xe2, 0x6e, 0x45, + 0x84, 0x3a, 0x22, 0xc6, 0x23, 0x15, 0x11, 0x99, 0x11, 0x11, 0x9b, 0xf1, 0xf7, 0x2d, 0x90, 0x68, + 0x90, 0xc4, 0x89, 0x02, 0x89, 0x09, 0x92, 0x16, 0xd4, 0x2e, 0xb5, 0x03, 0xc9, 0xf9, 0x78, 0x18, + 0x72, 0xc9, 0x32, 0x26, 0xd9, 0xb7, 0xdb, 0x37, 0x30, 0xa5, 0x5a, 0x53, 0x1a, 0x53, 0xaa, 0x3c, + 0xa5, 0xe6, 0x00, 0x4a, 0xdb, 0x09, 0x93, 0xce, 0xdf, 0xc5, 0xe8, 0xff, 0x06, 0x00, 0x00, 0xff, + 0xff, 0xc4, 0x53, 0x10, 0x96, 0x2a, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/orders/transactions/take/service.pb.gw.go b/x/orders/transactions/take/service.pb.gw.go deleted file mode 100644 index 1a351d367..000000000 --- a/x/orders/transactions/take/service.pb.gw.go +++ /dev/null @@ -1,171 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: AssetMantle/modules/x/orders/transactions/take/service.proto - -/* -Package take is a reverse proxy. - -It translates gRPC into RESTful JSON APIs. -*/ -package take - -import ( - "context" - "io" - "net/http" - - "github.com/golang/protobuf/descriptor" - "github.com/golang/protobuf/proto" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/grpc-ecosystem/grpc-gateway/utilities" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/status" -) - -// Suppress "imported and not used" errors -var _ codes.Code -var _ io.Reader -var _ status.Status -var _ = runtime.String -var _ = utilities.NewDoubleArray -var _ = descriptor.ForMessage -var _ = metadata.Join - -var ( - filter_Msg_Handle_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - -func request_Msg_Handle_0(ctx context.Context, marshaler runtime.Marshaler, client MsgClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq Message - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.Handle(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Msg_Handle_0(ctx context.Context, marshaler runtime.Marshaler, server MsgServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq Message - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.Handle(ctx, &protoReq) - return msg, metadata, err - -} - -// RegisterMsgHandlerServer registers the http handlers for service Msg to "mux". -// UnaryRPC :call MsgServer directly. -// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterMsgHandlerFromEndpoint instead. -func RegisterMsgHandlerServer(ctx context.Context, mux *runtime.ServeMux, server MsgServer) error { - - mux.Handle("POST", pattern_Msg_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Msg_Handle_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Msg_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -// RegisterMsgHandlerFromEndpoint is same as RegisterMsgHandler but -// automatically dials to "endpoint" and closes the connection when "ctx" gets done. -func RegisterMsgHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.Dial(endpoint, opts...) - if err != nil { - return err - } - defer func() { - if err != nil { - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - return - } - go func() { - <-ctx.Done() - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - }() - }() - - return RegisterMsgHandler(ctx, mux, conn) -} - -// RegisterMsgHandler registers the http handlers for service Msg to "mux". -// The handlers forward requests to the grpc endpoint over "conn". -func RegisterMsgHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { - return RegisterMsgHandlerClient(ctx, mux, NewMsgClient(conn)) -} - -// RegisterMsgHandlerClient registers the http handlers for service Msg -// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "MsgClient". -// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "MsgClient" -// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "MsgClient" to call the correct interceptors. -func RegisterMsgHandlerClient(ctx context.Context, mux *runtime.ServeMux, client MsgClient) error { - - mux.Handle("POST", pattern_Msg_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Msg_Handle_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Msg_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -var ( - pattern_Msg_Handle_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"mantle", "orders", "take"}, "", runtime.AssumeColonVerbOpt(false))) -) - -var ( - forward_Msg_Handle_0 = runtime.ForwardResponseMessage -) diff --git a/x/orders/transactions/take/transaction.go b/x/orders/transactions/take/transaction.go index 1fd419388..9c5d8e958 100644 --- a/x/orders/transactions/take/transaction.go +++ b/x/orders/transactions/take/transaction.go @@ -4,22 +4,14 @@ package take import ( - "context" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "google.golang.org/grpc" - "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/helpers/constants" - "github.com/AssetMantle/modules/utilities/name" + "google.golang.org/grpc" ) -type dummy struct{} - var Transaction = baseHelpers.NewTransaction( - name.GetPackageName(dummy{}), + _Msg_serviceDesc.ServiceName, "", "", @@ -30,9 +22,6 @@ var Transaction = baseHelpers.NewTransaction( func(server grpc.ServiceRegistrar, keeper helpers.TransactionKeeper) { RegisterMsgServer(server, keeper.(transactionKeeper)) }, - func(clientCtx client.Context, mux *runtime.ServeMux) error { - return RegisterMsgHandlerClient(context.Background(), mux, NewMsgClient(clientCtx)) - }, constants.FromIdentityID, constants.TakerSplit, diff --git a/x/orders/transactions/take/transaction_keeper.go b/x/orders/transactions/take/transaction_keeper.go index 248d3d12b..ee4c2ba5d 100644 --- a/x/orders/transactions/take/transaction_keeper.go +++ b/x/orders/transactions/take/transaction_keeper.go @@ -6,7 +6,6 @@ package take import ( "context" errorConstants "github.com/AssetMantle/modules/helpers/constants" - "github.com/AssetMantle/schema/data" baseData "github.com/AssetMantle/schema/data/base" "github.com/AssetMantle/schema/documents/base" diff --git a/x/orders/transactions/take/transaction_request.go b/x/orders/transactions/take/transaction_request.go index 13843a7b3..da68b05bd 100644 --- a/x/orders/transactions/take/transaction_request.go +++ b/x/orders/transactions/take/transaction_request.go @@ -5,24 +5,22 @@ package take import ( "encoding/json" - "github.com/AssetMantle/modules/utilities/rest" - - codecUtilities "github.com/AssetMantle/schema/codec/utilities" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" + "io" + "net/http" "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/helpers/constants" ) type transactionRequest struct { - BaseReq rest.BaseReq `json:"baseReq"` - FromID string `json:"fromID"` - TakerSplit string `json:"takerSplit"` - OrderID string `json:"orderID"` + helpers.CommonTransactionRequest `json:"commonTransactionRequest"` + FromID string `json:"fromID"` + TakerSplit string `json:"takerSplit"` + OrderID string `json:"orderID"` } var _ helpers.TransactionRequest = (*transactionRequest)(nil) @@ -48,24 +46,29 @@ func (transactionRequest transactionRequest) Validate() error { } func (transactionRequest transactionRequest) FromCLI(cliCommand helpers.CLICommand, context client.Context) (helpers.TransactionRequest, error) { return newTransactionRequest( - cliCommand.ReadBaseReq(context), + cliCommand.ReadCommonTransactionRequest(context), cliCommand.ReadString(constants.FromIdentityID), cliCommand.ReadString(constants.TakerSplit), cliCommand.ReadString(constants.OrderID), ), nil } -func (transactionRequest transactionRequest) FromJSON(rawMessage json.RawMessage) (helpers.TransactionRequest, error) { - if err := json.Unmarshal(rawMessage, &transactionRequest); err != nil { +func (transactionRequest transactionRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.TransactionRequest, error) { + body, err := io.ReadAll(httpRequest.Body) + if err != nil { + return nil, err + } + + if err := json.Unmarshal(body, &transactionRequest); err != nil { return nil, err } return transactionRequest, nil } -func (transactionRequest transactionRequest) GetBaseReq() rest.BaseReq { - return transactionRequest.BaseReq +func (transactionRequest transactionRequest) GetCommonTransactionRequest() helpers.CommonTransactionRequest { + return transactionRequest.CommonTransactionRequest } func (transactionRequest transactionRequest) MakeMsg() (sdkTypes.Msg, error) { - from, err := sdkTypes.AccAddressFromBech32(transactionRequest.GetBaseReq().From) + from, err := sdkTypes.AccAddressFromBech32(transactionRequest.GetCommonTransactionRequest().GetFrom()) if err != nil { return nil, err } @@ -92,17 +95,14 @@ func (transactionRequest transactionRequest) MakeMsg() (sdkTypes.Msg, error) { orderID.(ids.OrderID), ), nil } -func (transactionRequest) RegisterLegacyAminoCodec(legacyAmino *codec.LegacyAmino) { - codecUtilities.RegisterModuleConcrete(legacyAmino, transactionRequest{}) -} func requestPrototype() helpers.TransactionRequest { return transactionRequest{} } -func newTransactionRequest(baseReq rest.BaseReq, fromID string, takerSplit string, orderID string) helpers.TransactionRequest { +func newTransactionRequest(commonTransactionRequest helpers.CommonTransactionRequest, fromID string, takerSplit string, orderID string) helpers.TransactionRequest { return transactionRequest{ - BaseReq: baseReq, - FromID: fromID, - TakerSplit: takerSplit, - OrderID: orderID, + CommonTransactionRequest: commonTransactionRequest, + FromID: fromID, + TakerSplit: takerSplit, + OrderID: orderID, } } diff --git a/x/orders/transactions/take/transaction_request_test.go b/x/orders/transactions/take/transaction_request_test.go index 10d94f932..08ff28164 100644 --- a/x/orders/transactions/take/transaction_request_test.go +++ b/x/orders/transactions/take/transaction_request_test.go @@ -4,9 +4,7 @@ package take import ( - "encoding/json" "fmt" - "github.com/AssetMantle/modules/utilities/rest" "reflect" "testing" @@ -16,15 +14,12 @@ import ( baseProperties "github.com/AssetMantle/schema/properties/base" baseQualified "github.com/AssetMantle/schema/qualified/base" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/types" - "github.com/spf13/viper" - "github.com/stretchr/testify/require" - "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/helpers/constants" + "github.com/spf13/viper" ) var ( @@ -33,30 +28,30 @@ var ( immutables = baseQualified.NewImmutables(base.NewPropertyList(baseProperties.NewMesaProperty(baseIDs.NewStringID("ID2"), baseData.NewStringData("Data2")))) mutables = baseQualified.NewMutables(base.NewPropertyList(baseProperties.NewMesaProperty(baseIDs.NewStringID("ID1"), baseData.NewStringData("Data1")))) - testClassificationID = baseIDs.NewClassificationID(immutables, mutables) - testFromID = baseIDs.NewIdentityID(testClassificationID, immutables).(*baseIDs.IdentityID) - testOrderID = baseIDs.NewOrderID(testClassificationID, immutables).(*baseIDs.OrderID) - testBaseRequest = rest.BaseReq{From: fromAddress, ChainID: "test", Fees: types.NewCoins()} - takerSplit = types.NewInt(60) + testClassificationID = baseIDs.NewClassificationID(immutables, mutables) + testFromID = baseIDs.NewIdentityID(testClassificationID, immutables).(*baseIDs.IdentityID) + testOrderID = baseIDs.NewOrderID(testClassificationID, immutables).(*baseIDs.OrderID) + commonTransactionRequest = helpers.PrototypeCommonTransactionRequest() + takerSplit = types.NewInt(60) ) func Test_newTransactionRequest(t *testing.T) { type args struct { - baseReq rest.BaseReq - fromID string - takerSplit string - orderID string + commonTransactionRequest helpers.CommonTransactionRequest + fromID string + takerSplit string + orderID string } tests := []struct { name string args args want helpers.TransactionRequest }{ - {"+ve", args{testBaseRequest, testFromID.AsString(), takerSplit.String(), testOrderID.AsString()}, transactionRequest{testBaseRequest, testFromID.AsString(), takerSplit.String(), testOrderID.AsString()}}, + {"+ve", args{commonTransactionRequest, testFromID.AsString(), takerSplit.String(), testOrderID.AsString()}, transactionRequest{commonTransactionRequest, testFromID.AsString(), takerSplit.String(), testOrderID.AsString()}}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - if got := newTransactionRequest(tt.args.baseReq, tt.args.fromID, tt.args.takerSplit, tt.args.orderID); !reflect.DeepEqual(got, tt.want) { + if got := newTransactionRequest(tt.args.commonTransactionRequest, tt.args.fromID, tt.args.takerSplit, tt.args.orderID); !reflect.DeepEqual(got, tt.want) { t.Errorf("newTransactionRequest() = %v, want %v", got, tt.want) } }) @@ -86,10 +81,10 @@ func Test_transactionRequest_FromCLI(t *testing.T) { viper.Set(constants.TakerSplit.GetName(), takerSplit.String()) viper.Set(constants.OrderID.GetName(), testOrderID.AsString()) type fields struct { - BaseReq rest.BaseReq - FromID string - TakerSplit string - OrderID string + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + TakerSplit string + OrderID string } type args struct { cliCommand helpers.CLICommand @@ -102,15 +97,15 @@ func Test_transactionRequest_FromCLI(t *testing.T) { want helpers.TransactionRequest wantErr bool }{ - {"+ve", fields{testBaseRequest, testFromID.AsString(), takerSplit.String(), testOrderID.AsString()}, args{cliCommand, client.Context{}.WithCodec(baseHelpers.CodecPrototype())}, transactionRequest{testBaseRequest, testFromID.AsString(), takerSplit.String(), testOrderID.AsString()}, false}, + {"+ve", fields{commonTransactionRequest, testFromID.AsString(), takerSplit.String(), testOrderID.AsString()}, args{cliCommand, client.Context{}.WithCodec(baseHelpers.CodecPrototype())}, transactionRequest{commonTransactionRequest, testFromID.AsString(), takerSplit.String(), testOrderID.AsString()}, false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - TakerSplit: tt.fields.TakerSplit, - OrderID: tt.fields.OrderID, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + TakerSplit: tt.fields.TakerSplit, + OrderID: tt.fields.OrderID, } got, err := transactionRequest.FromCLI(tt.args.cliCommand, tt.args.context) if (err != nil) != tt.wantErr { @@ -124,71 +119,30 @@ func Test_transactionRequest_FromCLI(t *testing.T) { } } -func Test_transactionRequest_FromJSON(t *testing.T) { - jsonMessage, err := json.Marshal(newTransactionRequest(testBaseRequest, testFromID.AsString(), takerSplit.String(), testOrderID.AsString())) - require.NoError(t, err) - type fields struct { - BaseReq rest.BaseReq - FromID string - TakerSplit string - OrderID string - } - type args struct { - rawMessage json.RawMessage - } - tests := []struct { - name string - fields fields - args args - want helpers.TransactionRequest - wantErr bool - }{ - {"+ve", fields{testBaseRequest, testFromID.AsString(), takerSplit.String(), testOrderID.AsString()}, args{jsonMessage}, newTransactionRequest(testBaseRequest, testFromID.AsString(), takerSplit.String(), testOrderID.AsString()), false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - TakerSplit: tt.fields.TakerSplit, - OrderID: tt.fields.OrderID, - } - got, err := transactionRequest.FromJSON(tt.args.rawMessage) - if (err != nil) != tt.wantErr { - t.Errorf("FromJSON() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("FromJSON() got = %v, want %v", got, tt.want) - } - }) - } -} - func Test_transactionRequest_GetBaseReq(t *testing.T) { type fields struct { - BaseReq rest.BaseReq - FromID string - TakerSplit string - OrderID string + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + TakerSplit string + OrderID string } tests := []struct { name string fields fields - want rest.BaseReq + want helpers.CommonTransactionRequest }{ - {"+ve", fields{testBaseRequest, testFromID.AsString(), takerSplit.String(), testOrderID.AsString()}, testBaseRequest}, + {"+ve", fields{commonTransactionRequest, testFromID.AsString(), takerSplit.String(), testOrderID.AsString()}, commonTransactionRequest}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - TakerSplit: tt.fields.TakerSplit, - OrderID: tt.fields.OrderID, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + TakerSplit: tt.fields.TakerSplit, + OrderID: tt.fields.OrderID, } - if got := transactionRequest.GetBaseReq(); !reflect.DeepEqual(got, tt.want) { - t.Errorf("GetBaseReq() = %v, want %v", got, tt.want) + if got := transactionRequest.GetCommonTransactionRequest(); !reflect.DeepEqual(got, tt.want) { + t.Errorf("GetCommonTransactionRequest() = %v, want %v", got, tt.want) } }) } @@ -196,10 +150,10 @@ func Test_transactionRequest_GetBaseReq(t *testing.T) { func Test_transactionRequest_MakeMsg(t *testing.T) { type fields struct { - BaseReq rest.BaseReq - FromID string - TakerSplit string - OrderID string + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + TakerSplit string + OrderID string } tests := []struct { name string @@ -207,15 +161,15 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { want types.Msg wantErr bool }{ - {"+ve", fields{testBaseRequest, testFromID.AsString(), takerSplit.String(), testOrderID.AsString()}, NewMessage(fromAccAddress, testFromID, takerSplit, testOrderID), false}, + {"+ve", fields{commonTransactionRequest, testFromID.AsString(), takerSplit.String(), testOrderID.AsString()}, NewMessage(fromAccAddress, testFromID, takerSplit, testOrderID), false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - TakerSplit: tt.fields.TakerSplit, - OrderID: tt.fields.OrderID, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + TakerSplit: tt.fields.TakerSplit, + OrderID: tt.fields.OrderID, } got, err := transactionRequest.MakeMsg() if (err != nil) != tt.wantErr { @@ -229,57 +183,27 @@ func Test_transactionRequest_MakeMsg(t *testing.T) { } } -func Test_transactionRequest_RegisterCodec(t *testing.T) { - type fields struct { - BaseReq rest.BaseReq - FromID string - TakerSplit string - OrderID string - } - type args struct { - legacyAmino *codec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{testBaseRequest, testFromID.AsString(), takerSplit.String(), testOrderID.AsString()}, args{codec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - tr := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - TakerSplit: tt.fields.TakerSplit, - OrderID: tt.fields.OrderID, - } - tr.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} - func Test_transactionRequest_Validate(t *testing.T) { type fields struct { - BaseReq rest.BaseReq - FromID string - TakerSplit string - OrderID string + commonTransactionRequest helpers.CommonTransactionRequest + FromID string + TakerSplit string + OrderID string } tests := []struct { name string fields fields wantErr bool }{ - {"+ve", fields{testBaseRequest, testFromID.AsString(), takerSplit.String(), testOrderID.AsString()}, false}, + {"+ve", fields{commonTransactionRequest, testFromID.AsString(), takerSplit.String(), testOrderID.AsString()}, false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { transactionRequest := transactionRequest{ - BaseReq: tt.fields.BaseReq, - FromID: tt.fields.FromID, - TakerSplit: tt.fields.TakerSplit, - OrderID: tt.fields.OrderID, + CommonTransactionRequest: tt.fields.commonTransactionRequest, + FromID: tt.fields.FromID, + TakerSplit: tt.fields.TakerSplit, + OrderID: tt.fields.OrderID, } if err := transactionRequest.Validate(); (err != nil) != tt.wantErr { t.Errorf("ValidateBasic() error = %v, wantErr %v", err, tt.wantErr) diff --git a/x/orders/transactions/take/transaction_response.go b/x/orders/transactions/take/transaction_response.go index 2ac97e257..bec83749a 100644 --- a/x/orders/transactions/take/transaction_response.go +++ b/x/orders/transactions/take/transaction_response.go @@ -4,9 +4,8 @@ package take import ( - sdkTypes "github.com/cosmos/cosmos-sdk/types" - "github.com/AssetMantle/modules/helpers" + sdkTypes "github.com/cosmos/cosmos-sdk/types" ) var _ helpers.TransactionResponse = (*TransactionResponse)(nil) diff --git a/x/orders/utilities/permissions.go b/x/orders/utilities/permissions.go index 9f567de00..59a34540b 100644 --- a/x/orders/utilities/permissions.go +++ b/x/orders/utilities/permissions.go @@ -1,9 +1,8 @@ package utilities import ( - "github.com/AssetMantle/schema/ids" - "github.com/AssetMantle/modules/x/orders/constants" + "github.com/AssetMantle/schema/ids" ) func SetModulePermissions(canMakeOrder bool, canCancelOrder bool) []ids.StringID { diff --git a/x/splits/auxiliaries/burn/auxiliary_request.go b/x/splits/auxiliaries/burn/auxiliary_request.go index 45407c0f4..f01f66108 100644 --- a/x/splits/auxiliaries/burn/auxiliary_request.go +++ b/x/splits/auxiliaries/burn/auxiliary_request.go @@ -4,11 +4,10 @@ package burn import ( + "github.com/AssetMantle/modules/helpers" errorConstants "github.com/AssetMantle/modules/helpers/constants" "github.com/AssetMantle/schema/ids" sdkTypes "github.com/cosmos/cosmos-sdk/types" - - "github.com/AssetMantle/modules/helpers" ) type auxiliaryRequest struct { diff --git a/x/splits/auxiliaries/mint/auxiliary_request.go b/x/splits/auxiliaries/mint/auxiliary_request.go index 90299fc83..61233b917 100644 --- a/x/splits/auxiliaries/mint/auxiliary_request.go +++ b/x/splits/auxiliaries/mint/auxiliary_request.go @@ -4,11 +4,10 @@ package mint import ( + "github.com/AssetMantle/modules/helpers" errorConstants "github.com/AssetMantle/modules/helpers/constants" "github.com/AssetMantle/schema/ids" sdkTypes "github.com/cosmos/cosmos-sdk/types" - - "github.com/AssetMantle/modules/helpers" ) type auxiliaryRequest struct { diff --git a/x/splits/auxiliaries/prototype_test.go b/x/splits/auxiliaries/prototype_test.go index ae341adb8..4f4fe295d 100644 --- a/x/splits/auxiliaries/prototype_test.go +++ b/x/splits/auxiliaries/prototype_test.go @@ -5,9 +5,9 @@ package auxiliaries import ( "testing" - + "github.com/stretchr/testify/require" - + baseHelpers "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/x/splits/auxiliaries/mint" "github.com/AssetMantle/modules/x/splits/auxiliaries/purge" diff --git a/x/splits/auxiliaries/purge/auxiliary_keeper.go b/x/splits/auxiliaries/purge/auxiliary_keeper.go index 8c864b429..637aa3cd1 100644 --- a/x/splits/auxiliaries/purge/auxiliary_keeper.go +++ b/x/splits/auxiliaries/purge/auxiliary_keeper.go @@ -5,14 +5,13 @@ package purge import ( "context" - errorConstants "github.com/AssetMantle/modules/helpers/constants" - baseIDs "github.com/AssetMantle/schema/ids/base" - "github.com/AssetMantle/modules/helpers" + errorConstants "github.com/AssetMantle/modules/helpers/constants" "github.com/AssetMantle/modules/x/splits/key" "github.com/AssetMantle/modules/x/splits/mappable" "github.com/AssetMantle/modules/x/splits/record" "github.com/AssetMantle/modules/x/splits/utilities" + baseIDs "github.com/AssetMantle/schema/ids/base" ) type auxiliaryKeeper struct { diff --git a/x/splits/auxiliaries/purge/auxiliary_request.go b/x/splits/auxiliaries/purge/auxiliary_request.go index 2f4a72f68..a53b5c0f7 100644 --- a/x/splits/auxiliaries/purge/auxiliary_request.go +++ b/x/splits/auxiliaries/purge/auxiliary_request.go @@ -4,11 +4,10 @@ package purge import ( + "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/helpers/constants" "github.com/AssetMantle/schema/ids" sdkTypes "github.com/cosmos/cosmos-sdk/types" - - "github.com/AssetMantle/modules/helpers" ) type auxiliaryRequest struct { diff --git a/x/splits/auxiliaries/renumerate/auxiliary_keeper.go b/x/splits/auxiliaries/renumerate/auxiliary_keeper.go index b35edf581..36f39fef8 100644 --- a/x/splits/auxiliaries/renumerate/auxiliary_keeper.go +++ b/x/splits/auxiliaries/renumerate/auxiliary_keeper.go @@ -5,11 +5,10 @@ package renumerate import ( "context" - errorConstants "github.com/AssetMantle/modules/helpers/constants" - sdkTypes "github.com/cosmos/cosmos-sdk/types" - "github.com/AssetMantle/modules/helpers" + errorConstants "github.com/AssetMantle/modules/helpers/constants" "github.com/AssetMantle/modules/x/splits/utilities" + sdkTypes "github.com/cosmos/cosmos-sdk/types" ) type auxiliaryKeeper struct { diff --git a/x/splits/auxiliaries/transfer/auxiliary_keeper.go b/x/splits/auxiliaries/transfer/auxiliary_keeper.go index bf1298728..1ed800fe2 100644 --- a/x/splits/auxiliaries/transfer/auxiliary_keeper.go +++ b/x/splits/auxiliaries/transfer/auxiliary_keeper.go @@ -5,12 +5,11 @@ package transfer import ( "context" + "github.com/AssetMantle/modules/helpers" errorConstants "github.com/AssetMantle/modules/helpers/constants" + "github.com/AssetMantle/modules/x/splits/utilities" "github.com/AssetMantle/schema/data" propertyConstants "github.com/AssetMantle/schema/properties/constants" - - "github.com/AssetMantle/modules/helpers" - "github.com/AssetMantle/modules/x/splits/utilities" ) type auxiliaryKeeper struct { diff --git a/x/splits/auxiliaries/transfer/auxiliary_request.go b/x/splits/auxiliaries/transfer/auxiliary_request.go index 4f21dc43d..78730ea23 100644 --- a/x/splits/auxiliaries/transfer/auxiliary_request.go +++ b/x/splits/auxiliaries/transfer/auxiliary_request.go @@ -4,11 +4,10 @@ package transfer import ( + "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/helpers/constants" "github.com/AssetMantle/schema/ids" sdkTypes "github.com/cosmos/cosmos-sdk/types" - - "github.com/AssetMantle/modules/helpers" ) type auxiliaryRequest struct { diff --git a/x/splits/block/block.go b/x/splits/block/block.go index 1cbdcc3d6..36d85c5ae 100644 --- a/x/splits/block/block.go +++ b/x/splits/block/block.go @@ -5,7 +5,6 @@ package block import ( "context" - abciTypes "github.com/cometbft/cometbft/abci/types" "github.com/AssetMantle/modules/helpers" diff --git a/x/splits/genesis/genesis.go b/x/splits/genesis/genesis.go index 6d8808b9f..7ad85a728 100644 --- a/x/splits/genesis/genesis.go +++ b/x/splits/genesis/genesis.go @@ -3,7 +3,6 @@ package genesis import ( "context" errorConstants "github.com/AssetMantle/modules/helpers/constants" - "github.com/AssetMantle/schema/lists" "github.com/AssetMantle/schema/lists/base" sdkCodec "github.com/cosmos/cosmos-sdk/codec" diff --git a/x/splits/key/key.go b/x/splits/key/key.go index fffb41f9a..87b491941 100644 --- a/x/splits/key/key.go +++ b/x/splits/key/key.go @@ -4,11 +4,10 @@ package key import ( + "github.com/AssetMantle/modules/helpers" errorConstants "github.com/AssetMantle/modules/helpers/constants" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" - - "github.com/AssetMantle/modules/helpers" ) var _ helpers.Key = (*Key)(nil) diff --git a/x/splits/mappable/mappable.go b/x/splits/mappable/mappable.go index 1f3fdb779..f40690a7d 100644 --- a/x/splits/mappable/mappable.go +++ b/x/splits/mappable/mappable.go @@ -4,12 +4,9 @@ package mappable import ( - codecUtilities "github.com/AssetMantle/schema/codec/utilities" + "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/schema/types" baseTypes "github.com/AssetMantle/schema/types/base" - "github.com/cosmos/cosmos-sdk/codec" - - "github.com/AssetMantle/modules/helpers" ) var _ helpers.Mappable = (*Mappable)(nil) @@ -17,9 +14,6 @@ var _ helpers.Mappable = (*Mappable)(nil) func (mappable *Mappable) ValidateBasic() error { return mappable.Split.ValidateBasic() } -func (*Mappable) RegisterLegacyAminoCodec(legacyAmino *codec.LegacyAmino) { - codecUtilities.RegisterModuleConcrete(legacyAmino, Mappable{}) -} func NewMappable(split types.Split) helpers.Mappable { return &Mappable{Split: split.(*baseTypes.Split)} diff --git a/x/splits/mappable/mappable_test.go b/x/splits/mappable/mappable_test.go index 8de671acd..b7b4609a3 100644 --- a/x/splits/mappable/mappable_test.go +++ b/x/splits/mappable/mappable_test.go @@ -9,7 +9,6 @@ import ( "github.com/AssetMantle/schema/types" baseTypes "github.com/AssetMantle/schema/types/base" - "github.com/cosmos/cosmos-sdk/codec" sdkTypes "github.com/cosmos/cosmos-sdk/types" "github.com/AssetMantle/modules/helpers" @@ -55,27 +54,3 @@ func TestPrototype(t *testing.T) { }) } } - -func Test_mappable_RegisterCodec(t *testing.T) { - type fields struct { - Split *baseTypes.Split - } - type args struct { - legacyAmino *codec.LegacyAmino - } - tests := []struct { - name string - fields fields - args args - }{ - {"+ve", fields{split}, args{codec.NewLegacyAmino()}}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - ma := &Mappable{ - Split: tt.fields.Split, - } - ma.RegisterLegacyAminoCodec(tt.args.legacyAmino) - }) - } -} diff --git a/x/splits/parameters/prototype.go b/x/splits/parameters/prototype.go index de19fddfc..c5ace5a78 100644 --- a/x/splits/parameters/prototype.go +++ b/x/splits/parameters/prototype.go @@ -6,10 +6,9 @@ package parameters import ( "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" - "github.com/AssetMantle/modules/x/splits/constants" "github.com/AssetMantle/modules/x/splits/parameters/transfer_enabled" ) func Prototype() helpers.ParameterManager { - return baseHelpers.NewParameterManager(constants.ModuleName, transfer_enabled.ValidatableParameter) + return baseHelpers.NewParameterManager(transfer_enabled.ValidatableParameter) } diff --git a/x/splits/parameters/prototype_test.go b/x/splits/parameters/prototype_test.go index 394a2f8ed..36c5813d6 100644 --- a/x/splits/parameters/prototype_test.go +++ b/x/splits/parameters/prototype_test.go @@ -10,7 +10,6 @@ import ( "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/x/assets/parameters/wrap_allowed_coins" - "github.com/AssetMantle/modules/x/splits/constants" ) func TestPrototype(t *testing.T) { @@ -18,7 +17,7 @@ func TestPrototype(t *testing.T) { name string want helpers.ParameterManager }{ - {"+ve", baseHelpers.NewParameterManager(constants.ModuleName, wrap_allowed_coins.ValidatableParameter)}, + {"+ve", baseHelpers.NewParameterManager(wrap_allowed_coins.ValidatableParameter)}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { diff --git a/x/splits/parameters/transfer_enabled/parameter.go b/x/splits/parameters/transfer_enabled/parameter.go index ef3e36bea..bdb24f1d5 100644 --- a/x/splits/parameters/transfer_enabled/parameter.go +++ b/x/splits/parameters/transfer_enabled/parameter.go @@ -4,13 +4,12 @@ package transfer_enabled import ( + baseHelpers "github.com/AssetMantle/modules/helpers/base" errorConstants "github.com/AssetMantle/modules/helpers/constants" baseData "github.com/AssetMantle/schema/data/base" baseParameters "github.com/AssetMantle/schema/parameters/base" "github.com/AssetMantle/schema/properties/base" constantProperties "github.com/AssetMantle/schema/properties/constants" - - baseHelpers "github.com/AssetMantle/modules/helpers/base" ) var ID = constantProperties.TransferEnabledProperty.GetKey() diff --git a/x/splits/queries/balances/query.go b/x/splits/queries/balances/query.go index a07a12273..d905ba25c 100644 --- a/x/splits/queries/balances/query.go +++ b/x/splits/queries/balances/query.go @@ -4,28 +4,17 @@ package balances import ( - "context" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "google.golang.org/grpc" - "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" helperConstants "github.com/AssetMantle/modules/helpers/constants" - "github.com/AssetMantle/modules/utilities/name" - "github.com/AssetMantle/modules/x/splits/constants" + "google.golang.org/grpc" ) -type dummy struct{} - var Query = baseHelpers.NewQuery( - name.GetPackageName(dummy{}), + _Query_serviceDesc.ServiceName, "", "", - constants.ModuleName, - requestPrototype, responsePrototype, keeperPrototype, @@ -33,9 +22,6 @@ var Query = baseHelpers.NewQuery( func(server grpc.ServiceRegistrar, QueryKeeper helpers.QueryKeeper) { RegisterQueryServer(server, QueryKeeper.(queryKeeper)) }, - func(clientContext client.Context, serveMux *runtime.ServeMux) error { - return RegisterQueryHandlerClient(context.Background(), serveMux, NewQueryClient(clientContext)) - }, helperConstants.IdentityID, helperConstants.SplitID, diff --git a/x/splits/queries/balances/query_keeper.go b/x/splits/queries/balances/query_keeper.go index 9fffa3698..97c19789f 100644 --- a/x/splits/queries/balances/query_keeper.go +++ b/x/splits/queries/balances/query_keeper.go @@ -5,7 +5,6 @@ package balances import ( "context" - "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/x/splits/utilities" ) @@ -17,7 +16,7 @@ type queryKeeper struct { var _ helpers.QueryKeeper = (*queryKeeper)(nil) func (queryKeeper queryKeeper) Enquire(context context.Context, queryRequest helpers.QueryRequest) (helpers.QueryResponse, error) { - queryResponse, err := queryKeeper.Handle(context, queryRequestFromInterface(queryRequest)) + queryResponse, err := queryKeeper.Handle(context, queryRequest.(*QueryRequest)) return queryResponse, err } func (queryKeeper queryKeeper) Handle(context context.Context, queryRequest *QueryRequest) (*QueryResponse, error) { diff --git a/x/splits/queries/balances/query_request.go b/x/splits/queries/balances/query_request.go index 0b4cbe6ba..09c916537 100644 --- a/x/splits/queries/balances/query_request.go +++ b/x/splits/queries/balances/query_request.go @@ -11,7 +11,6 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/AssetMantle/modules/helpers" - "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/helpers/constants" ) @@ -63,27 +62,10 @@ func (*QueryRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.QueryRe return newQueryRequest(identityID.(ids.IdentityID)), nil } } -func (queryRequest *QueryRequest) Encode() ([]byte, error) { - return base.CodecPrototype().MarshalJSON(queryRequest) -} -func (queryRequest *QueryRequest) Decode(bytes []byte) (helpers.QueryRequest, error) { - if err := base.CodecPrototype().UnmarshalJSON(bytes, queryRequest); err != nil { - return nil, err - } - - return queryRequest, nil -} func requestPrototype() helpers.QueryRequest { return &QueryRequest{} } -func queryRequestFromInterface(request helpers.QueryRequest) *QueryRequest { - switch value := request.(type) { - case *QueryRequest: - return value - default: - return &QueryRequest{} - } -} + func newQueryRequest(identityID ids.IdentityID) helpers.QueryRequest { return &QueryRequest{IdentityID: identityID.(*baseIDs.IdentityID)} } diff --git a/x/splits/queries/balances/query_request_test.go b/x/splits/queries/balances/query_request_test.go index 3baab58a7..578a261bd 100644 --- a/x/splits/queries/balances/query_request_test.go +++ b/x/splits/queries/balances/query_request_test.go @@ -7,15 +7,13 @@ import ( "reflect" "testing" + "github.com/AssetMantle/modules/helpers" + "github.com/AssetMantle/modules/helpers/base" + "github.com/AssetMantle/modules/helpers/constants" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" "github.com/cosmos/cosmos-sdk/client" "github.com/spf13/viper" - "github.com/stretchr/testify/require" - - "github.com/AssetMantle/modules/helpers" - "github.com/AssetMantle/modules/helpers/base" - "github.com/AssetMantle/modules/helpers/constants" ) var ( @@ -55,85 +53,13 @@ func Test_queryRequestFromInterface(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - if got := queryRequestFromInterface(tt.args.request); !reflect.DeepEqual(got, tt.want) { + if got := tt.args.request.(*QueryRequest); !reflect.DeepEqual(got, tt.want) { t.Errorf("queryRequestFromInterface() = %v, want %v", got, tt.want) } }) } } -func Test_queryRequest_Decode(t *testing.T) { - encodedReq, err := base.CodecPrototype().GetLegacyAmino().MarshalJSON(newQueryRequest(testIdentityID)) - require.NoError(t, err) - encodedReq1, err1 := base.CodecPrototype().GetLegacyAmino().MarshalJSON(newQueryRequest(baseIDs.PrototypeIdentityID())) - require.NoError(t, err1) - type fields struct { - identityID ids.IdentityID - } - type args struct { - bytes []byte - } - tests := []struct { - name string - fields fields - args args - want helpers.QueryRequest - wantErr bool - }{ - {"+ve", fields{testIdentityID}, args{encodedReq}, newQueryRequest(testIdentityID), false}, - {"+ve", fields{baseIDs.PrototypeIdentityID()}, args{encodedReq1}, newQueryRequest(baseIDs.PrototypeIdentityID()), false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - queryRequest := &QueryRequest{ - IdentityID: tt.fields.identityID.(*baseIDs.IdentityID), - } - got, err := queryRequest.Decode(tt.args.bytes) - if (err != nil) != tt.wantErr { - t.Errorf("Decode() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("Decode() got = %v, want %v", got, tt.want) - } - }) - } -} - -func Test_queryRequest_Encode(t *testing.T) { - encodedReq, err := base.CodecPrototype().GetLegacyAmino().MarshalJSON(newQueryRequest(testIdentityID)) - require.NoError(t, err) - encodedReq1, err1 := base.CodecPrototype().GetLegacyAmino().MarshalJSON(newQueryRequest(baseIDs.PrototypeIdentityID())) - require.NoError(t, err1) - type fields struct { - identityID ids.IdentityID - } - tests := []struct { - name string - fields fields - want []byte - wantErr bool - }{ - {"+ve", fields{testIdentityID}, encodedReq, false}, - {"+ve", fields{baseIDs.PrototypeIdentityID().(*baseIDs.IdentityID)}, encodedReq1, false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - queryRequest := &QueryRequest{ - IdentityID: tt.fields.identityID.(*baseIDs.IdentityID), - } - got, err := queryRequest.Encode() - if (err != nil) != tt.wantErr { - t.Errorf("Encode() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("Encode() got = %v, want %v", got, tt.want) - } - }) - } -} - func Test_queryRequest_FromCLI(t *testing.T) { cliCommand := base.NewCLICommand("", "", "", []helpers.CLIFlag{constants.AssetID}) diff --git a/x/splits/queries/balances/service.pb.go b/x/splits/queries/balances/service.pb.go index 5093b337d..a7868183a 100644 --- a/x/splits/queries/balances/service.pb.go +++ b/x/splits/queries/balances/service.pb.go @@ -8,7 +8,6 @@ import ( fmt "fmt" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" - _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -31,30 +30,28 @@ func init() { } var fileDescriptor_853cff3c2933ae7a = []byte{ - // 366 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x92, 0xb1, 0x4a, 0xc3, 0x40, - 0x1c, 0xc6, 0x9b, 0x80, 0x1d, 0x82, 0x53, 0xc6, 0x22, 0x11, 0x5d, 0x9c, 0xbc, 0xa3, 0x75, 0xd1, - 0xab, 0x4b, 0xb3, 0xe8, 0x12, 0x68, 0xed, 0x12, 0x24, 0x20, 0x97, 0xf4, 0x4f, 0x0d, 0x24, 0x77, - 0x69, 0xee, 0x52, 0xea, 0xea, 0x13, 0x08, 0xbe, 0x81, 0xa3, 0x38, 0xfb, 0x0c, 0xe2, 0x54, 0x70, - 0x71, 0x94, 0xd4, 0xc9, 0xc5, 0x57, 0x90, 0xf6, 0x2e, 0xd2, 0x8e, 0xe9, 0x9a, 0x7c, 0xbf, 0x8f, - 0xdf, 0x77, 0x77, 0x56, 0xb7, 0x27, 0x04, 0x48, 0x8f, 0x32, 0x99, 0x00, 0x4e, 0xf9, 0xa8, 0x48, - 0x40, 0xe0, 0x19, 0x16, 0x59, 0x12, 0x4b, 0x81, 0x27, 0x05, 0xe4, 0x31, 0x08, 0x1c, 0xd2, 0x84, - 0xb2, 0x08, 0x04, 0x16, 0x90, 0x4f, 0xe3, 0x08, 0x50, 0x96, 0x73, 0xc9, 0xed, 0xe3, 0x35, 0x18, - 0x69, 0x18, 0xcd, 0x90, 0x82, 0x91, 0x86, 0x51, 0x05, 0xb7, 0xf6, 0xc6, 0x9c, 0x8f, 0x13, 0xc0, - 0x34, 0x8b, 0x31, 0x65, 0x8c, 0x4b, 0x2a, 0x63, 0xce, 0x84, 0x2a, 0x6b, 0xf5, 0xea, 0x99, 0x2c, - 0x3f, 0xdc, 0xdd, 0xe4, 0x30, 0x29, 0x40, 0x48, 0x5d, 0xe1, 0x6e, 0x57, 0x21, 0x32, 0xce, 0x84, - 0xde, 0xd4, 0x79, 0x35, 0xac, 0x9d, 0xc1, 0xf2, 0x87, 0xfd, 0x62, 0x58, 0xcd, 0x4b, 0xca, 0x46, - 0x09, 0xd8, 0x5d, 0x54, 0x6b, 0x29, 0x5a, 0x15, 0x5c, 0x29, 0xb7, 0xd6, 0xf9, 0x76, 0xb0, 0xb2, - 0x3a, 0x3c, 0xba, 0xff, 0xf8, 0x7e, 0x34, 0x0f, 0xec, 0x7d, 0x9c, 0xaa, 0x5d, 0x7a, 0xcd, 0xb4, - 0x1d, 0x82, 0xa4, 0xed, 0xff, 0x35, 0xee, 0xaf, 0xf9, 0x56, 0x3a, 0xc6, 0xbc, 0x74, 0x8c, 0xaf, - 0xd2, 0x31, 0x1e, 0x16, 0x4e, 0x63, 0xbe, 0x70, 0x1a, 0x9f, 0x0b, 0xa7, 0x61, 0xb5, 0x23, 0x9e, - 0xd6, 0x93, 0x70, 0x77, 0x87, 0xea, 0xa6, 0xfb, 0xcb, 0x43, 0xe9, 0x1b, 0xd7, 0xa7, 0xe3, 0x58, - 0xde, 0x16, 0x21, 0x8a, 0x78, 0x8a, 0x6b, 0x9d, 0xf2, 0x93, 0xd9, 0xec, 0x79, 0xfe, 0x70, 0xe0, - 0x3e, 0x9b, 0x1b, 0xcf, 0xc5, 0xd3, 0x0a, 0x3e, 0x1a, 0x2a, 0x85, 0x81, 0x56, 0x70, 0x35, 0xf8, - 0xbe, 0x91, 0x0f, 0x74, 0x3e, 0xf0, 0x03, 0x95, 0x0f, 0x74, 0x3e, 0xa8, 0xf2, 0xa5, 0x79, 0x56, - 0x2b, 0x1f, 0x5c, 0xf4, 0x5d, 0x0f, 0x24, 0x1d, 0x51, 0x49, 0x7f, 0xcc, 0xce, 0x1a, 0x4b, 0x88, - 0x86, 0x09, 0xf1, 0x09, 0x51, 0x38, 0x21, 0x9a, 0x27, 0xa4, 0x2a, 0x08, 0x9b, 0xab, 0x17, 0x73, - 0xf2, 0x17, 0x00, 0x00, 0xff, 0xff, 0x81, 0xb5, 0xed, 0xfb, 0x44, 0x03, 0x00, 0x00, + // 323 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x92, 0x31, 0x4e, 0xc3, 0x30, + 0x14, 0x86, 0xe3, 0x48, 0x74, 0x88, 0x98, 0x3a, 0x76, 0xf0, 0xc0, 0x8e, 0x2d, 0xca, 0x02, 0x2e, + 0x4b, 0xbd, 0xc0, 0x12, 0xa9, 0xa5, 0x4b, 0x84, 0x2c, 0x21, 0x37, 0x7d, 0x82, 0x48, 0x69, 0x9c, + 0xc6, 0x0e, 0x2a, 0x07, 0x60, 0x86, 0x33, 0x30, 0x72, 0x12, 0xc4, 0xd4, 0x91, 0x11, 0x25, 0x1b, + 0x0b, 0x57, 0x40, 0xa9, 0x1d, 0xa9, 0x1d, 0xd3, 0x35, 0xf9, 0xbf, 0xff, 0x7d, 0x2f, 0x2f, 0xc1, + 0x68, 0xac, 0x35, 0x98, 0x50, 0x66, 0x26, 0x05, 0xba, 0x54, 0x8b, 0x32, 0x05, 0x4d, 0xd7, 0x54, + 0xe7, 0x69, 0x62, 0x34, 0x5d, 0x95, 0x50, 0x24, 0xa0, 0xe9, 0x5c, 0xa6, 0x32, 0x8b, 0x41, 0x53, + 0x0d, 0xc5, 0x53, 0x12, 0x03, 0xc9, 0x0b, 0x65, 0x54, 0xff, 0x74, 0x07, 0x26, 0x0e, 0x26, 0x6b, + 0x62, 0x61, 0xe2, 0x60, 0xd2, 0xc2, 0x83, 0x71, 0xb7, 0x59, 0xcd, 0x83, 0xe7, 0xfb, 0x02, 0x56, + 0x25, 0x68, 0x63, 0x27, 0x0e, 0xf8, 0x61, 0x15, 0x3a, 0x57, 0x99, 0x76, 0xd6, 0xc3, 0x57, 0x14, + 0x1c, 0x4d, 0x9b, 0x17, 0xfd, 0x17, 0x14, 0xf4, 0x6e, 0x64, 0xb6, 0x48, 0xa1, 0x3f, 0x22, 0x9d, + 0x76, 0x21, 0xdb, 0x82, 0x5b, 0xeb, 0x36, 0xb8, 0x3a, 0x0c, 0xb6, 0x56, 0x27, 0x1e, 0xff, 0xf3, + 0x3f, 0x2b, 0x8c, 0x36, 0x15, 0x46, 0x3f, 0x15, 0x46, 0x6f, 0x35, 0xf6, 0x36, 0x35, 0xf6, 0xbe, + 0x6b, 0xec, 0x05, 0x67, 0xb1, 0x5a, 0x76, 0x6b, 0xe7, 0xc7, 0x33, 0x7b, 0xa4, 0x49, 0xb3, 0xed, + 0x04, 0xdd, 0x5d, 0x3c, 0x24, 0xe6, 0xb1, 0x9c, 0x93, 0x58, 0x2d, 0x69, 0xa7, 0xcf, 0xf7, 0xee, + 0xf7, 0xc6, 0x61, 0x34, 0x9b, 0xf2, 0x0f, 0x7f, 0xef, 0xd2, 0xa1, 0x53, 0x88, 0xc8, 0xcc, 0x2a, + 0x4c, 0x9d, 0x02, 0x77, 0xe0, 0xd7, 0x5e, 0x5e, 0xb8, 0xbc, 0x88, 0x84, 0xcd, 0x0b, 0x97, 0x17, + 0x6d, 0xbe, 0xf2, 0x2f, 0x3b, 0xe5, 0xc5, 0xf5, 0x84, 0x87, 0x60, 0xe4, 0x42, 0x1a, 0xf9, 0xeb, + 0x0f, 0x77, 0x58, 0xc6, 0x1c, 0xcc, 0x58, 0xc4, 0x98, 0xc5, 0x19, 0x73, 0x3c, 0x63, 0x6d, 0xc1, + 0xbc, 0xb7, 0xfd, 0x15, 0xce, 0xff, 0x03, 0x00, 0x00, 0xff, 0xff, 0x88, 0xb2, 0xdd, 0x4a, 0xff, + 0x02, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/splits/queries/balances/service.pb.gw.go b/x/splits/queries/balances/service.pb.gw.go deleted file mode 100644 index 9cf320c4a..000000000 --- a/x/splits/queries/balances/service.pb.gw.go +++ /dev/null @@ -1,171 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: AssetMantle/modules/x/splits/queries/balances/service.proto - -/* -Package balances is a reverse proxy. - -It translates gRPC into RESTful JSON APIs. -*/ -package balances - -import ( - "context" - "io" - "net/http" - - "github.com/golang/protobuf/descriptor" - "github.com/golang/protobuf/proto" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/grpc-ecosystem/grpc-gateway/utilities" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/status" -) - -// Suppress "imported and not used" errors -var _ codes.Code -var _ io.Reader -var _ status.Status -var _ = runtime.String -var _ = utilities.NewDoubleArray -var _ = descriptor.ForMessage -var _ = metadata.Join - -var ( - filter_Query_Handle_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - -func request_Query_Handle_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryRequest - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.Handle(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_Handle_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryRequest - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.Handle(ctx, &protoReq) - return msg, metadata, err - -} - -// RegisterQueryHandlerServer registers the http handlers for service Query to "mux". -// UnaryRPC :call QueryServer directly. -// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. -func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { - - mux.Handle("GET", pattern_Query_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Query_Handle_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but -// automatically dials to "endpoint" and closes the connection when "ctx" gets done. -func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.Dial(endpoint, opts...) - if err != nil { - return err - } - defer func() { - if err != nil { - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - return - } - go func() { - <-ctx.Done() - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - }() - }() - - return RegisterQueryHandler(ctx, mux, conn) -} - -// RegisterQueryHandler registers the http handlers for service Query to "mux". -// The handlers forward requests to the grpc endpoint over "conn". -func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { - return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn)) -} - -// RegisterQueryHandlerClient registers the http handlers for service Query -// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient". -// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient" -// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "QueryClient" to call the correct interceptors. -func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { - - mux.Handle("GET", pattern_Query_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Query_Handle_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -var ( - pattern_Query_Handle_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"mantle", "splits", "v1beta1", "balances"}, "", runtime.AssumeColonVerbOpt(false))) -) - -var ( - forward_Query_Handle_0 = runtime.ForwardResponseMessage -) diff --git a/x/splits/queries/parameters/query.go b/x/splits/queries/parameters/query.go new file mode 100644 index 000000000..cfe5be8fe --- /dev/null +++ b/x/splits/queries/parameters/query.go @@ -0,0 +1,21 @@ +package parameters + +import ( + "github.com/AssetMantle/modules/helpers" + baseHelpers "github.com/AssetMantle/modules/helpers/base" + "google.golang.org/grpc" +) + +var Query = baseHelpers.NewQuery( + _Query_serviceDesc.ServiceName, + "", + "", + + requestPrototype, + responsePrototype, + keeperPrototype, + + func(server grpc.ServiceRegistrar, QueryKeeper helpers.QueryKeeper) { + RegisterQueryServer(server, QueryKeeper.(queryKeeper)) + }, +) diff --git a/x/splits/queries/parameters/query_keeper.go b/x/splits/queries/parameters/query_keeper.go new file mode 100644 index 000000000..5ff196b53 --- /dev/null +++ b/x/splits/queries/parameters/query_keeper.go @@ -0,0 +1,31 @@ +package parameters + +import ( + "context" + "github.com/AssetMantle/modules/helpers" +) + +type queryKeeper struct { + parameterManager helpers.ParameterManager +} + +var _ helpers.QueryKeeper = (*queryKeeper)(nil) + +func (queryKeeper queryKeeper) Enquire(context context.Context, queryRequest helpers.QueryRequest) (helpers.QueryResponse, error) { + queryResponse, err := queryKeeper.Handle(context, queryRequest.(*QueryRequest)) + return queryResponse, err +} +func (queryKeeper queryKeeper) Handle(context context.Context, queryRequest *QueryRequest) (*QueryResponse, error) { + if err := queryRequest.Validate(); err != nil { + return nil, err + } + return newQueryResponse(queryKeeper.parameterManager.Fetch(context).Get()), nil +} +func (queryKeeper queryKeeper) Initialize(_ helpers.Mapper, parameterManager helpers.ParameterManager, _ []interface{}) helpers.Keeper { + queryKeeper.parameterManager = parameterManager + return queryKeeper +} + +func keeperPrototype() helpers.QueryKeeper { + return queryKeeper{} +} diff --git a/x/splits/queries/parameters/query_request.go b/x/splits/queries/parameters/query_request.go new file mode 100644 index 000000000..9f99e7a01 --- /dev/null +++ b/x/splits/queries/parameters/query_request.go @@ -0,0 +1,25 @@ +package parameters + +import ( + "github.com/AssetMantle/modules/helpers" + "github.com/cosmos/cosmos-sdk/client" + "net/http" +) + +var _ helpers.QueryRequest = (*QueryRequest)(nil) + +func (queryRequest *QueryRequest) Validate() error { + return nil +} + +func (queryRequest *QueryRequest) FromCLI(_ helpers.CLICommand, _ client.Context) (helpers.QueryRequest, error) { + return requestPrototype(), nil +} + +func (queryRequest *QueryRequest) FromHTTPRequest(_ *http.Request) (helpers.QueryRequest, error) { + return requestPrototype(), nil +} + +func requestPrototype() helpers.QueryRequest { + return &QueryRequest{} +} diff --git a/x/splits/queries/parameters/query_request.pb.go b/x/splits/queries/parameters/query_request.pb.go new file mode 100644 index 000000000..5a1dfe940 --- /dev/null +++ b/x/splits/queries/parameters/query_request.pb.go @@ -0,0 +1,272 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: AssetMantle/modules/x/splits/queries/parameters/query_request.proto + +package parameters + +import ( + fmt "fmt" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type QueryRequest struct { +} + +func (m *QueryRequest) Reset() { *m = QueryRequest{} } +func (m *QueryRequest) String() string { return proto.CompactTextString(m) } +func (*QueryRequest) ProtoMessage() {} +func (*QueryRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_a5f308e7e8a3b4c0, []int{0} +} +func (m *QueryRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryRequest.Merge(m, src) +} +func (m *QueryRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryRequest proto.InternalMessageInfo + +func init() { + proto.RegisterType((*QueryRequest)(nil), "AssetMantle.modules.x.splits.queries.parameters.QueryRequest") +} + +func init() { + proto.RegisterFile("AssetMantle/modules/x/splits/queries/parameters/query_request.proto", fileDescriptor_a5f308e7e8a3b4c0) +} + +var fileDescriptor_a5f308e7e8a3b4c0 = []byte{ + // 272 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0xd1, 0xb1, 0x4a, 0xc4, 0x30, + 0x1c, 0xc7, 0xf1, 0xb6, 0xc2, 0x0d, 0x45, 0x04, 0x7d, 0x80, 0x0c, 0x3e, 0x40, 0x32, 0x9c, 0xd3, + 0xdf, 0xe9, 0xea, 0xe0, 0x54, 0x48, 0xbd, 0xa5, 0x48, 0x40, 0x72, 0x77, 0x7f, 0xb4, 0xd0, 0x9a, + 0x5e, 0x92, 0xc2, 0xb9, 0xf9, 0x08, 0x3e, 0x83, 0xa3, 0x4f, 0x22, 0x4e, 0x37, 0x3a, 0x4a, 0xbb, + 0xf9, 0x14, 0x72, 0x26, 0x5c, 0xdb, 0xb1, 0x6b, 0xe0, 0xfb, 0xe1, 0xf7, 0x27, 0xf1, 0xcd, 0xc2, + 0x18, 0xb4, 0xa9, 0x7c, 0xb6, 0x25, 0xb2, 0x4a, 0x6d, 0x9a, 0x12, 0x0d, 0xdb, 0x31, 0x53, 0x97, + 0x85, 0x35, 0x6c, 0xdb, 0xa0, 0x2e, 0xd0, 0xb0, 0x5a, 0x6a, 0x59, 0xa1, 0x45, 0xed, 0x9e, 0x5e, + 0x1e, 0x34, 0x6e, 0x1b, 0x34, 0x96, 0xd6, 0x5a, 0x59, 0x75, 0xc1, 0x06, 0x08, 0xf5, 0x08, 0xdd, + 0x51, 0x87, 0x50, 0x8f, 0xd0, 0x1e, 0xb9, 0x3c, 0x8b, 0x4f, 0xb3, 0x83, 0x73, 0xe7, 0x98, 0xe4, + 0xf5, 0xe4, 0xb3, 0x25, 0xe1, 0xbe, 0x25, 0xe1, 0x4f, 0x4b, 0xc2, 0xb7, 0x8e, 0x04, 0xfb, 0x8e, + 0x04, 0xdf, 0x1d, 0x09, 0xe2, 0xf9, 0x5a, 0x55, 0x74, 0xa2, 0x9f, 0x9c, 0x0f, 0x75, 0x7e, 0xd8, + 0xc8, 0xc3, 0x7b, 0x78, 0x2c, 0xec, 0x53, 0xb3, 0xa2, 0x6b, 0x55, 0xb1, 0x89, 0x57, 0xbf, 0x47, + 0xb3, 0x45, 0x9a, 0x2f, 0x33, 0xfe, 0x11, 0x8d, 0x6e, 0x4d, 0xfd, 0x96, 0x9c, 0x2e, 0xdd, 0x96, + 0xcc, 0x6f, 0xe1, 0xc7, 0xf4, 0x6b, 0x54, 0x08, 0x5f, 0x88, 0x5c, 0xb8, 0x42, 0xf8, 0x42, 0xf4, + 0x45, 0x1b, 0x5d, 0x4f, 0x2c, 0xc4, 0x2d, 0x4f, 0x52, 0xb4, 0x72, 0x23, 0xad, 0xfc, 0x8d, 0xae, + 0x06, 0x35, 0x80, 0xcf, 0x01, 0x72, 0x00, 0x07, 0x00, 0x78, 0x01, 0xa0, 0x27, 0x56, 0xb3, 0xff, + 0xaf, 0x9c, 0xff, 0x05, 0x00, 0x00, 0xff, 0xff, 0x94, 0x2b, 0x54, 0x48, 0x11, 0x02, 0x00, 0x00, +} + +func (m *QueryRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func encodeVarintQueryRequest(dAtA []byte, offset int, v uint64) int { + offset -= sovQueryRequest(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *QueryRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func sovQueryRequest(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQueryRequest(x uint64) (n int) { + return sovQueryRequest(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QueryRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQueryRequest + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQueryRequest(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQueryRequest + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipQueryRequest(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQueryRequest + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQueryRequest + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQueryRequest + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthQueryRequest + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupQueryRequest + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthQueryRequest + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthQueryRequest = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowQueryRequest = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupQueryRequest = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/splits/queries/parameters/query_response.go b/x/splits/queries/parameters/query_response.go new file mode 100644 index 000000000..4d34b8543 --- /dev/null +++ b/x/splits/queries/parameters/query_response.go @@ -0,0 +1,29 @@ +package parameters + +import ( + "github.com/AssetMantle/modules/helpers" + "github.com/AssetMantle/modules/helpers/base" + "github.com/AssetMantle/schema/lists" + baseLists "github.com/AssetMantle/schema/lists/base" +) + +var _ helpers.QueryResponse = (*QueryResponse)(nil) + +func (queryResponse *QueryResponse) Encode() ([]byte, error) { + return base.CodecPrototype().MarshalJSON(queryResponse) +} +func (queryResponse *QueryResponse) Decode(bytes []byte) (helpers.QueryResponse, error) { + if err := base.CodecPrototype().UnmarshalJSON(bytes, queryResponse); err != nil { + return nil, err + } + + return queryResponse, nil +} +func responsePrototype() helpers.QueryResponse { + return &QueryResponse{} +} +func newQueryResponse(parameterList lists.ParameterList) *QueryResponse { + return &QueryResponse{ + ParameterList: parameterList.(*baseLists.ParameterList), + } +} diff --git a/x/splits/queries/parameters/query_response.pb.go b/x/splits/queries/parameters/query_response.pb.go new file mode 100644 index 000000000..1c0d1c67a --- /dev/null +++ b/x/splits/queries/parameters/query_response.pb.go @@ -0,0 +1,337 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: AssetMantle/modules/x/splits/queries/parameters/query_response.proto + +package parameters + +import ( + fmt "fmt" + base "github.com/AssetMantle/schema/lists/base" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type QueryResponse struct { + ParameterList *base.ParameterList `protobuf:"bytes,1,opt,name=parameter_list,json=parameterList,proto3" json:"parameter_list,omitempty"` +} + +func (m *QueryResponse) Reset() { *m = QueryResponse{} } +func (m *QueryResponse) String() string { return proto.CompactTextString(m) } +func (*QueryResponse) ProtoMessage() {} +func (*QueryResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_6a41cc553798a56c, []int{0} +} +func (m *QueryResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryResponse.Merge(m, src) +} +func (m *QueryResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryResponse proto.InternalMessageInfo + +func (m *QueryResponse) GetParameterList() *base.ParameterList { + if m != nil { + return m.ParameterList + } + return nil +} + +func init() { + proto.RegisterType((*QueryResponse)(nil), "AssetMantle.modules.x.splits.queries.parameters.QueryResponse") +} + +func init() { + proto.RegisterFile("AssetMantle/modules/x/splits/queries/parameters/query_response.proto", fileDescriptor_6a41cc553798a56c) +} + +var fileDescriptor_6a41cc553798a56c = []byte{ + // 333 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x91, 0x31, 0x4b, 0xc3, 0x40, + 0x14, 0xc7, 0x9b, 0x08, 0x1d, 0x22, 0x75, 0xe8, 0x24, 0x0e, 0x41, 0x9c, 0x1c, 0xe4, 0x1d, 0xb4, + 0x4e, 0xe7, 0xd4, 0x22, 0xb8, 0x18, 0x48, 0xdb, 0x25, 0xc8, 0x41, 0xb9, 0xb6, 0x0f, 0x1b, 0x48, + 0x7a, 0x31, 0xef, 0x0a, 0x75, 0xf4, 0x1b, 0xf8, 0x19, 0x1c, 0xfd, 0x24, 0xe2, 0xd4, 0xd1, 0x51, + 0xd2, 0xcd, 0x4f, 0x21, 0xe9, 0x9d, 0x26, 0x19, 0x3b, 0xe6, 0x91, 0xdf, 0xef, 0xff, 0x7f, 0xf7, + 0xbc, 0xdb, 0x01, 0x11, 0xea, 0x40, 0xae, 0x74, 0x82, 0x2c, 0x55, 0x8b, 0x75, 0x82, 0xc4, 0x36, + 0x8c, 0xb2, 0x24, 0xd6, 0xc4, 0x9e, 0xd6, 0x98, 0xc7, 0x48, 0x2c, 0x93, 0xb9, 0x4c, 0x51, 0x63, + 0x6e, 0x46, 0xcf, 0xd3, 0x1c, 0x29, 0x53, 0x2b, 0x42, 0xc8, 0x72, 0xa5, 0x55, 0x97, 0xd5, 0x2c, + 0x60, 0x2d, 0xb0, 0x01, 0x63, 0x01, 0x6b, 0x81, 0xca, 0x72, 0xd6, 0xab, 0xc7, 0xd2, 0x7c, 0x89, + 0xa9, 0x64, 0x49, 0x4c, 0x9a, 0xd8, 0x4c, 0x12, 0x56, 0x79, 0xd3, 0x72, 0x68, 0x42, 0x2e, 0x16, + 0x5e, 0x67, 0x54, 0x86, 0x8f, 0x6d, 0x76, 0x77, 0xe2, 0x9d, 0x34, 0x7f, 0x3c, 0x75, 0xce, 0x9d, + 0xcb, 0xe3, 0xde, 0x15, 0xd4, 0xeb, 0x18, 0x3b, 0xec, 0xed, 0x50, 0xda, 0x21, 0xfc, 0x83, 0xee, + 0x63, 0xd2, 0xe3, 0x4e, 0x56, 0xff, 0x1c, 0xbe, 0x1c, 0x7d, 0x14, 0xbe, 0xb3, 0x2d, 0x7c, 0xe7, + 0xbb, 0xf0, 0x9d, 0xd7, 0x9d, 0xdf, 0xda, 0xee, 0xfc, 0xd6, 0xd7, 0xce, 0x6f, 0x79, 0xfd, 0xb9, + 0x4a, 0xe1, 0xc0, 0x4d, 0x87, 0xdd, 0x46, 0xe7, 0xb0, 0xdc, 0x24, 0x74, 0x1e, 0xf8, 0x63, 0xac, + 0x97, 0xeb, 0x19, 0xcc, 0x55, 0xca, 0x0e, 0xbc, 0xc0, 0x9b, 0xdb, 0x1e, 0x04, 0xd1, 0x64, 0x14, + 0xbe, 0xbb, 0x8d, 0x67, 0x0f, 0x6c, 0x99, 0x08, 0x26, 0xa6, 0xcc, 0xc8, 0x96, 0xf9, 0x5f, 0x97, + 0x3e, 0x1b, 0x84, 0xb0, 0x84, 0x88, 0x84, 0x21, 0x84, 0x25, 0x44, 0x45, 0x14, 0xee, 0xcd, 0x81, + 0x84, 0xb8, 0x0b, 0x87, 0x01, 0x6a, 0xb9, 0x90, 0x5a, 0xfe, 0xb8, 0xd7, 0x35, 0x9a, 0x73, 0x8b, + 0x73, 0x1e, 0x71, 0x6e, 0x04, 0x9c, 0x5b, 0x03, 0xe7, 0x95, 0x62, 0xd6, 0xde, 0x1f, 0xbc, 0xff, + 0x1b, 0x00, 0x00, 0xff, 0xff, 0x39, 0x8d, 0x2e, 0xb6, 0x9d, 0x02, 0x00, 0x00, +} + +func (m *QueryResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.ParameterList != nil { + { + size, err := m.ParameterList.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQueryResponse(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintQueryResponse(dAtA []byte, offset int, v uint64) int { + offset -= sovQueryResponse(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *QueryResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ParameterList != nil { + l = m.ParameterList.Size() + n += 1 + l + sovQueryResponse(uint64(l)) + } + return n +} + +func sovQueryResponse(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQueryResponse(x uint64) (n int) { + return sovQueryResponse(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QueryResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQueryResponse + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ParameterList", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQueryResponse + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQueryResponse + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQueryResponse + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.ParameterList == nil { + m.ParameterList = &base.ParameterList{} + } + if err := m.ParameterList.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQueryResponse(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQueryResponse + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipQueryResponse(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQueryResponse + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQueryResponse + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQueryResponse + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthQueryResponse + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupQueryResponse + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthQueryResponse + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthQueryResponse = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowQueryResponse = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupQueryResponse = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/splits/queries/parameters/service.pb.go b/x/splits/queries/parameters/service.pb.go new file mode 100644 index 000000000..8ea3b0bc8 --- /dev/null +++ b/x/splits/queries/parameters/service.pb.go @@ -0,0 +1,135 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: AssetMantle/modules/x/splits/queries/parameters/service.proto + +package parameters + +import ( + context "context" + fmt "fmt" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + math "math" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +func init() { + proto.RegisterFile("AssetMantle/modules/x/splits/queries/parameters/service.proto", fileDescriptor_9b6cc8022dd588ef) +} + +var fileDescriptor_9b6cc8022dd588ef = []byte{ + // 326 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0xd2, 0x31, 0x4b, 0xf3, 0x40, + 0x18, 0x07, 0xf0, 0x5c, 0xe0, 0xed, 0x10, 0xde, 0xa9, 0x63, 0x87, 0x1b, 0xfc, 0x00, 0x77, 0x60, + 0x9d, 0x4e, 0x2a, 0xb4, 0x0a, 0xba, 0x04, 0x52, 0xbb, 0x04, 0x39, 0x90, 0x6b, 0xfb, 0xa0, 0x81, + 0x24, 0x97, 0xde, 0x5d, 0xa4, 0x7e, 0x04, 0x37, 0xc1, 0x6f, 0xe0, 0xe8, 0x27, 0x11, 0xa7, 0x8e, + 0x8e, 0x92, 0x6c, 0x7e, 0x05, 0x17, 0x49, 0xef, 0x30, 0xed, 0x98, 0xae, 0x09, 0xbf, 0xff, 0xf3, + 0x7f, 0xf2, 0x24, 0x18, 0x8d, 0xb5, 0x06, 0x13, 0x8a, 0xdc, 0xa4, 0x40, 0x33, 0xb9, 0x2c, 0x53, + 0xd0, 0x74, 0x4d, 0x75, 0x91, 0x26, 0x46, 0xd3, 0x55, 0x09, 0x2a, 0x01, 0x4d, 0x0b, 0xa1, 0x44, + 0x06, 0x06, 0x94, 0xa6, 0x1a, 0xd4, 0x43, 0xb2, 0x00, 0x52, 0x28, 0x69, 0x64, 0x9f, 0xee, 0x70, + 0xe2, 0x38, 0x59, 0x13, 0xcb, 0x89, 0xe3, 0xa4, 0xe5, 0x83, 0xf3, 0xae, 0xf3, 0x9a, 0x47, 0x8f, + 0xb7, 0x0a, 0x56, 0x25, 0x68, 0x63, 0xa7, 0x0e, 0x2e, 0x0e, 0x0d, 0xd1, 0x85, 0xcc, 0xb5, 0xeb, + 0x7e, 0xfc, 0x82, 0x82, 0x7f, 0xd3, 0xe6, 0x45, 0xff, 0x09, 0x05, 0xbd, 0x2b, 0x91, 0x2f, 0x53, + 0xe8, 0x8f, 0x48, 0xc7, 0x8d, 0xc8, 0x36, 0xe2, 0xda, 0xf6, 0x1b, 0x9c, 0x1d, 0xca, 0x6d, 0xb3, + 0x23, 0x6f, 0xf2, 0xe3, 0xbf, 0x57, 0x18, 0x6d, 0x2a, 0x8c, 0xbe, 0x2a, 0x8c, 0x9e, 0x6b, 0xec, + 0x6d, 0x6a, 0xec, 0x7d, 0xd6, 0xd8, 0x0b, 0x86, 0x0b, 0x99, 0x75, 0xcd, 0x9f, 0xfc, 0x9f, 0xd9, + 0x83, 0x45, 0xcd, 0xce, 0x11, 0xba, 0x61, 0x77, 0x89, 0xb9, 0x2f, 0xe7, 0x64, 0x21, 0x33, 0xda, + 0xf1, 0x33, 0xbe, 0xfa, 0xbd, 0x71, 0x18, 0xcf, 0xa6, 0xd1, 0x9b, 0xbf, 0x77, 0xf7, 0xd0, 0xd5, + 0x88, 0xc9, 0xcc, 0xd6, 0x98, 0xba, 0x1a, 0xd1, 0x1f, 0xfd, 0xd8, 0x13, 0xdc, 0x09, 0x1e, 0x73, + 0x2b, 0xb8, 0x13, 0xbc, 0x15, 0x95, 0x7f, 0xda, 0x51, 0xf0, 0xcb, 0x68, 0x12, 0x82, 0x11, 0x4b, + 0x61, 0xc4, 0xb7, 0x7f, 0xb2, 0xa3, 0x19, 0x73, 0x9c, 0xb1, 0x98, 0x31, 0x1b, 0xc0, 0x98, 0x4b, + 0x60, 0xac, 0x8d, 0x98, 0xf7, 0xb6, 0xbf, 0xc6, 0xf0, 0x37, 0x00, 0x00, 0xff, 0xff, 0x99, 0x53, + 0x92, 0x98, 0x17, 0x03, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// QueryClient is the client API for Query service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type QueryClient interface { + Handle(ctx context.Context, in *QueryRequest, opts ...grpc.CallOption) (*QueryResponse, error) +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +func (c *queryClient) Handle(ctx context.Context, in *QueryRequest, opts ...grpc.CallOption) (*QueryResponse, error) { + out := new(QueryResponse) + err := c.cc.Invoke(ctx, "/AssetMantle.modules.x.splits.queries.parameters.Query/Handle", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +type QueryServer interface { + Handle(context.Context, *QueryRequest) (*QueryResponse, error) +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func (*UnimplementedQueryServer) Handle(ctx context.Context, req *QueryRequest) (*QueryResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Handle not implemented") +} + +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) +} + +func _Query_Handle_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Handle(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/AssetMantle.modules.x.splits.queries.parameters.Query/Handle", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Handle(ctx, req.(*QueryRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "AssetMantle.modules.x.splits.queries.parameters.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Handle", + Handler: _Query_Handle_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "AssetMantle/modules/x/splits/queries/parameters/service.proto", +} diff --git a/x/splits/queries/prototype.go b/x/splits/queries/prototype.go index 4e21ca61f..75518940e 100644 --- a/x/splits/queries/prototype.go +++ b/x/splits/queries/prototype.go @@ -7,6 +7,7 @@ import ( "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/x/splits/queries/balances" + "github.com/AssetMantle/modules/x/splits/queries/parameters" "github.com/AssetMantle/modules/x/splits/queries/split" "github.com/AssetMantle/modules/x/splits/queries/splits" "github.com/AssetMantle/modules/x/splits/queries/supply" @@ -18,5 +19,6 @@ func Prototype() helpers.Queries { split.Query, splits.Query, supply.Query, + parameters.Query, ) } diff --git a/x/splits/queries/prototype_test.go b/x/splits/queries/prototype_test.go index d20d6d72a..8ae25facc 100644 --- a/x/splits/queries/prototype_test.go +++ b/x/splits/queries/prototype_test.go @@ -15,13 +15,13 @@ import ( func TestPrototype(t *testing.T) { require.Panics(t, func() { - require.Equal(t, Prototype().GetQuery("splits").GetName(), baseHelpers.NewQueries( + require.Equal(t, Prototype().GetQuery("splits").GetServicePath(), baseHelpers.NewQueries( split.Query, balances.Query, - ).GetQuery("splits").GetName()) - require.Equal(t, Prototype().GetQuery("balances").GetName(), baseHelpers.NewQueries( + ).GetQuery("splits").GetServicePath()) + require.Equal(t, Prototype().GetQuery("balances").GetServicePath(), baseHelpers.NewQueries( split.Query, balances.Query, - ).GetQuery("balances").GetName()) + ).GetQuery("balances").GetServicePath()) }) } diff --git a/x/splits/queries/split/query.go b/x/splits/queries/split/query.go index 7911c45c0..38028276a 100644 --- a/x/splits/queries/split/query.go +++ b/x/splits/queries/split/query.go @@ -4,28 +4,17 @@ package split import ( - "context" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "google.golang.org/grpc" - "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" helperConstants "github.com/AssetMantle/modules/helpers/constants" - "github.com/AssetMantle/modules/utilities/name" - "github.com/AssetMantle/modules/x/splits/constants" + "google.golang.org/grpc" ) -type dummy struct{} - var Query = baseHelpers.NewQuery( - name.GetPackageName(dummy{}), + _Query_serviceDesc.ServiceName, "", "", - constants.ModuleName, - requestPrototype, responsePrototype, keeperPrototype, @@ -33,9 +22,6 @@ var Query = baseHelpers.NewQuery( func(server grpc.ServiceRegistrar, QueryKeeper helpers.QueryKeeper) { RegisterQueryServer(server, QueryKeeper.(queryKeeper)) }, - func(clientContext client.Context, serveMux *runtime.ServeMux) error { - return RegisterQueryHandlerClient(context.Background(), serveMux, NewQueryClient(clientContext)) - }, helperConstants.SplitID, ) diff --git a/x/splits/queries/split/query_keeper.go b/x/splits/queries/split/query_keeper.go index 2d430163a..c2af053e1 100644 --- a/x/splits/queries/split/query_keeper.go +++ b/x/splits/queries/split/query_keeper.go @@ -5,7 +5,6 @@ package split import ( "context" - "github.com/AssetMantle/modules/helpers" ) @@ -16,7 +15,7 @@ type queryKeeper struct { var _ helpers.QueryKeeper = (*queryKeeper)(nil) func (queryKeeper queryKeeper) Enquire(context context.Context, queryRequest helpers.QueryRequest) (helpers.QueryResponse, error) { - queryResponse, err := queryKeeper.Handle(context, queryRequestFromInterface(queryRequest)) + queryResponse, err := queryKeeper.Handle(context, queryRequest.(*QueryRequest)) return queryResponse, err } func (queryKeeper queryKeeper) Handle(context context.Context, queryRequest *QueryRequest) (*QueryResponse, error) { diff --git a/x/splits/queries/split/query_request.go b/x/splits/queries/split/query_request.go index e56e9c7ca..677972dfb 100644 --- a/x/splits/queries/split/query_request.go +++ b/x/splits/queries/split/query_request.go @@ -11,7 +11,6 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/AssetMantle/modules/helpers" - "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/helpers/constants" "github.com/AssetMantle/modules/x/splits/key" ) @@ -50,27 +49,10 @@ func (*QueryRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.QueryRe return newQueryRequest(splitID.(ids.SplitID)), nil } } -func (queryRequest *QueryRequest) Encode() ([]byte, error) { - return base.CodecPrototype().MarshalJSON(queryRequest) -} -func (queryRequest *QueryRequest) Decode(bytes []byte) (helpers.QueryRequest, error) { - if err := base.CodecPrototype().UnmarshalJSON(bytes, queryRequest); err != nil { - return nil, err - } - - return queryRequest, nil -} func requestPrototype() helpers.QueryRequest { return &QueryRequest{} } -func queryRequestFromInterface(request helpers.QueryRequest) *QueryRequest { - switch value := request.(type) { - case *QueryRequest: - return value - default: - return &QueryRequest{} - } -} + func newQueryRequest(splitID ids.SplitID) helpers.QueryRequest { return &QueryRequest{Key: key.NewKey(splitID).(*key.Key)} } diff --git a/x/splits/queries/split/query_request_test.go b/x/splits/queries/split/query_request_test.go index 17ddf7e39..4824d3c64 100644 --- a/x/splits/queries/split/query_request_test.go +++ b/x/splits/queries/split/query_request_test.go @@ -9,6 +9,9 @@ import ( "reflect" "testing" + "github.com/AssetMantle/modules/helpers" + "github.com/AssetMantle/modules/helpers/base" + "github.com/AssetMantle/modules/helpers/constants" baseData "github.com/AssetMantle/schema/data/base" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" @@ -17,11 +20,6 @@ import ( baseQualified "github.com/AssetMantle/schema/qualified/base" "github.com/cosmos/cosmos-sdk/client" "github.com/spf13/viper" - "github.com/stretchr/testify/require" - - "github.com/AssetMantle/modules/helpers" - "github.com/AssetMantle/modules/helpers/base" - "github.com/AssetMantle/modules/helpers/constants" ) var ( @@ -66,85 +64,13 @@ func Test_queryRequestFromInterface(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - if got := queryRequestFromInterface(tt.args.request); !reflect.DeepEqual(got, tt.want) { + if got := tt.args.request.(*QueryRequest); !reflect.DeepEqual(got, tt.want) { t.Errorf("queryRequestFromInterface() = %v, want %v", got, tt.want) } }) } } -func Test_queryRequest_Decode(t *testing.T) { - encodedReq, err := base.CodecPrototype().GetLegacyAmino().MarshalJSON(newQueryRequest(splitID)) - require.NoError(t, err) - encodedReq1, err1 := base.CodecPrototype().GetLegacyAmino().MarshalJSON(newQueryRequest(baseIDs.PrototypeSplitID())) - require.NoError(t, err1) - type fields struct { - SplitID *baseIDs.SplitID - } - type args struct { - bytes []byte - } - tests := []struct { - name string - fields fields - args args - want helpers.QueryRequest - wantErr bool - }{ - {"+ve", fields{splitID}, args{encodedReq}, newQueryRequest(splitID), false}, - {"+ve", fields{baseIDs.PrototypeSplitID().(*baseIDs.SplitID)}, args{encodedReq1}, newQueryRequest(baseIDs.PrototypeSplitID()), false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - queryRequest := &QueryRequest{ - Key: key.NewKey(tt.fields.SplitID).(*key.Key), - } - got, err := queryRequest.Decode(tt.args.bytes) - if (err != nil) != tt.wantErr { - t.Errorf("Decode() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("Decode() got = %v, want %v", got, tt.want) - } - }) - } -} - -func Test_queryRequest_Encode(t *testing.T) { - encodedReq, err := base.CodecPrototype().GetLegacyAmino().MarshalJSON(newQueryRequest(splitID)) - require.NoError(t, err) - encodedReq1, err1 := base.CodecPrototype().GetLegacyAmino().MarshalJSON(newQueryRequest(baseIDs.PrototypeSplitID())) - require.NoError(t, err1) - type fields struct { - SplitID *baseIDs.SplitID - } - tests := []struct { - name string - fields fields - want []byte - wantErr bool - }{ - {"+ve", fields{splitID}, encodedReq, false}, - {"+ve", fields{baseIDs.PrototypeSplitID().(*baseIDs.SplitID)}, encodedReq1, false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - queryRequest := &QueryRequest{ - Key: key.NewKey(tt.fields.SplitID).(*key.Key), - } - got, err := queryRequest.Encode() - if (err != nil) != tt.wantErr { - t.Errorf("Encode() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("Encode() got = %v, want %v", got, tt.want) - } - }) - } -} - func Test_queryRequest_FromCLI(t *testing.T) { cliCommand := base.NewCLICommand("", "", "", []helpers.CLIFlag{constants.SplitID}) diff --git a/x/splits/queries/split/service.pb.go b/x/splits/queries/split/service.pb.go index bce7c13b4..b75fb115a 100644 --- a/x/splits/queries/split/service.pb.go +++ b/x/splits/queries/split/service.pb.go @@ -8,7 +8,6 @@ import ( fmt "fmt" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" - _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -31,30 +30,27 @@ func init() { } var fileDescriptor_69974d2b5d423779 = []byte{ - // 358 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x92, 0x31, 0x4b, 0xfb, 0x40, - 0x18, 0xc6, 0x9b, 0xc0, 0xbf, 0x43, 0xf8, 0x4f, 0x19, 0x4b, 0xb9, 0x41, 0x9c, 0x1c, 0xee, 0xa8, - 0xa2, 0xd4, 0x1b, 0x94, 0x76, 0xd1, 0x25, 0xd0, 0x9a, 0x25, 0x48, 0x40, 0xae, 0xed, 0x4b, 0x0d, - 0xa4, 0xb9, 0x34, 0x77, 0x29, 0x75, 0xf5, 0x13, 0x08, 0x7e, 0x03, 0xdd, 0x04, 0xbf, 0x87, 0x38, - 0x15, 0x5c, 0x5c, 0x04, 0x49, 0x9d, 0xfc, 0x14, 0x92, 0xbe, 0x37, 0xb4, 0x5b, 0xda, 0xf1, 0x49, - 0x9e, 0xdf, 0x3d, 0xef, 0x73, 0xf7, 0x3a, 0xed, 0x8e, 0x52, 0xa0, 0x3d, 0x91, 0xe8, 0x18, 0xd8, - 0x44, 0x8e, 0xf2, 0x18, 0x14, 0x9b, 0x33, 0x95, 0xc6, 0x91, 0x56, 0x6c, 0x9a, 0x43, 0x16, 0x81, - 0x42, 0xc9, 0x14, 0x64, 0xb3, 0x68, 0x08, 0x34, 0xcd, 0xa4, 0x96, 0xee, 0xc1, 0x1a, 0x49, 0x0d, - 0x49, 0xe7, 0x14, 0x49, 0x6a, 0x48, 0x94, 0x8d, 0xe6, 0x58, 0xca, 0x71, 0x0c, 0x4c, 0xa4, 0x11, - 0x13, 0x49, 0x22, 0xb5, 0xd0, 0x91, 0x4c, 0x14, 0x9e, 0xd4, 0x38, 0xdb, 0x62, 0x86, 0x52, 0xdd, - 0xdd, 0x64, 0x30, 0xcd, 0x41, 0x69, 0xc3, 0x9f, 0xef, 0xc0, 0xab, 0x54, 0x26, 0xca, 0x54, 0x39, - 0x7c, 0xb5, 0x9c, 0x7f, 0xfd, 0xf2, 0x87, 0xfb, 0x6c, 0x39, 0xf5, 0x4b, 0x91, 0x8c, 0x62, 0x70, - 0xdb, 0xb4, 0x7a, 0x41, 0xba, 0xa2, 0xaf, 0x70, 0xaa, 0xc6, 0xe9, 0x0e, 0x24, 0xce, 0xb3, 0xb7, - 0x7f, 0xff, 0xf1, 0xf3, 0x68, 0x13, 0xb7, 0xc9, 0x26, 0x58, 0xc7, 0x94, 0x98, 0xb5, 0x06, 0xa0, - 0x45, 0x0b, 0x65, 0xf7, 0xcb, 0x7e, 0x2b, 0x88, 0xb5, 0x28, 0x88, 0xf5, 0x5d, 0x10, 0xeb, 0x61, - 0x49, 0x6a, 0x8b, 0x25, 0xa9, 0x7d, 0x2e, 0x49, 0xcd, 0xa1, 0x43, 0x39, 0xd9, 0x22, 0xbe, 0xfb, - 0xdf, 0xc7, 0x47, 0xed, 0x95, 0x17, 0xd1, 0xb3, 0xae, 0x8f, 0xc7, 0x91, 0xbe, 0xcd, 0x07, 0xe5, - 0x31, 0xac, 0xfa, 0xb5, 0x3e, 0xd9, 0xf5, 0x8e, 0x17, 0xf8, 0x7d, 0xff, 0xc5, 0xde, 0x58, 0x0b, - 0xcf, 0x84, 0x07, 0xd4, 0xc7, 0xf0, 0xbe, 0x09, 0x5f, 0xc9, 0xf7, 0x0d, 0x73, 0x68, 0xcc, 0x61, - 0x10, 0xa2, 0x39, 0x34, 0x66, 0x94, 0x85, 0x7d, 0x52, 0xdd, 0x1c, 0x5e, 0xf4, 0xba, 0x1e, 0x68, - 0x31, 0x12, 0x5a, 0xfc, 0xda, 0xeb, 0x45, 0x38, 0x37, 0x24, 0xe7, 0x01, 0xe7, 0xc8, 0x72, 0x6e, - 0x60, 0xf3, 0x61, 0x50, 0x5f, 0xad, 0xc5, 0xd1, 0x5f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x97, 0x80, - 0x80, 0x99, 0x1d, 0x03, 0x00, 0x00, + // 310 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xb2, 0x70, 0x2c, 0x2e, 0x4e, + 0x2d, 0xf1, 0x4d, 0xcc, 0x2b, 0xc9, 0x49, 0xd5, 0xcf, 0xcd, 0x4f, 0x29, 0xcd, 0x49, 0x2d, 0xd6, + 0xaf, 0xd0, 0x2f, 0x2e, 0xc8, 0xc9, 0x2c, 0x29, 0xd6, 0x2f, 0x2c, 0x4d, 0x2d, 0xca, 0x4c, 0x2d, + 0x86, 0x70, 0xf5, 0x8b, 0x53, 0x8b, 0xca, 0x32, 0x93, 0x53, 0xf5, 0x0a, 0x8a, 0xf2, 0x4b, 0xf2, + 0x85, 0xb4, 0x90, 0x74, 0xea, 0x41, 0x75, 0xea, 0x55, 0xe8, 0x41, 0x74, 0xea, 0x41, 0x75, 0x42, + 0xb8, 0x52, 0x76, 0x24, 0xd8, 0x02, 0xe2, 0x55, 0xc6, 0x17, 0xa5, 0x16, 0x96, 0xa6, 0x16, 0x97, + 0x40, 0xec, 0x92, 0xb2, 0x27, 0x43, 0x7f, 0x71, 0x41, 0x7e, 0x5e, 0x31, 0xd4, 0xb1, 0x46, 0x1d, + 0x8c, 0x5c, 0xac, 0x81, 0x20, 0x09, 0xa1, 0x7a, 0x2e, 0x36, 0x8f, 0xc4, 0xbc, 0x94, 0x9c, 0x54, + 0x21, 0x0b, 0x3d, 0xe2, 0x7d, 0xa0, 0x07, 0xd6, 0x1c, 0x04, 0x71, 0x94, 0x94, 0x25, 0x19, 0x3a, + 0x21, 0xce, 0x51, 0x62, 0x70, 0xba, 0xcb, 0x74, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, + 0x0f, 0x1e, 0xc9, 0x31, 0x4e, 0x78, 0x2c, 0xc7, 0x70, 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, + 0x0c, 0x5c, 0x7a, 0xc9, 0xf9, 0xb9, 0x24, 0x18, 0xed, 0xc4, 0x13, 0x0c, 0x89, 0x91, 0x00, 0x90, + 0x1f, 0x03, 0x18, 0xa3, 0x4c, 0xd3, 0x33, 0x4b, 0x32, 0x4a, 0x93, 0x40, 0xc6, 0xe8, 0x13, 0x1f, + 0x62, 0x8b, 0x98, 0xd8, 0x1c, 0x7d, 0x23, 0x82, 0x03, 0x83, 0x57, 0x31, 0xa1, 0xc4, 0xa9, 0x2f, + 0xd4, 0xf2, 0x08, 0xbd, 0x60, 0x88, 0xe5, 0x81, 0x50, 0xcb, 0xc1, 0xdc, 0x53, 0x28, 0x8a, 0x63, + 0xa0, 0x8a, 0x63, 0x22, 0x62, 0x20, 0x8a, 0x63, 0xa0, 0x8a, 0x21, 0xdc, 0x47, 0x4c, 0x66, 0xc4, + 0x2b, 0x8e, 0x71, 0x0f, 0x70, 0xf2, 0x4d, 0x2d, 0x49, 0x4c, 0x49, 0x2c, 0x49, 0x7c, 0xc5, 0x84, + 0xec, 0x11, 0x2b, 0x2b, 0xa8, 0x4e, 0x2b, 0xab, 0x08, 0x2b, 0x2b, 0x88, 0x5e, 0x2b, 0x2b, 0xa8, + 0x66, 0xa8, 0x40, 0x12, 0x1b, 0x38, 0xc6, 0x8d, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0x4d, 0x7a, + 0x6d, 0x6b, 0xda, 0x02, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/splits/queries/split/service.pb.gw.go b/x/splits/queries/split/service.pb.gw.go deleted file mode 100644 index 2c6318f80..000000000 --- a/x/splits/queries/split/service.pb.gw.go +++ /dev/null @@ -1,171 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: AssetMantle/modules/x/splits/queries/split/service.proto - -/* -Package split is a reverse proxy. - -It translates gRPC into RESTful JSON APIs. -*/ -package split - -import ( - "context" - "io" - "net/http" - - "github.com/golang/protobuf/descriptor" - "github.com/golang/protobuf/proto" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/grpc-ecosystem/grpc-gateway/utilities" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/status" -) - -// Suppress "imported and not used" errors -var _ codes.Code -var _ io.Reader -var _ status.Status -var _ = runtime.String -var _ = utilities.NewDoubleArray -var _ = descriptor.ForMessage -var _ = metadata.Join - -var ( - filter_Query_Handle_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - -func request_Query_Handle_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryRequest - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.Handle(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_Handle_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryRequest - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.Handle(ctx, &protoReq) - return msg, metadata, err - -} - -// RegisterQueryHandlerServer registers the http handlers for service Query to "mux". -// UnaryRPC :call QueryServer directly. -// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. -func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { - - mux.Handle("GET", pattern_Query_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Query_Handle_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but -// automatically dials to "endpoint" and closes the connection when "ctx" gets done. -func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.Dial(endpoint, opts...) - if err != nil { - return err - } - defer func() { - if err != nil { - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - return - } - go func() { - <-ctx.Done() - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - }() - }() - - return RegisterQueryHandler(ctx, mux, conn) -} - -// RegisterQueryHandler registers the http handlers for service Query to "mux". -// The handlers forward requests to the grpc endpoint over "conn". -func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { - return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn)) -} - -// RegisterQueryHandlerClient registers the http handlers for service Query -// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient". -// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient" -// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "QueryClient" to call the correct interceptors. -func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { - - mux.Handle("GET", pattern_Query_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Query_Handle_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -var ( - pattern_Query_Handle_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"mantle", "splits", "v1beta1", "split"}, "", runtime.AssumeColonVerbOpt(false))) -) - -var ( - forward_Query_Handle_0 = runtime.ForwardResponseMessage -) diff --git a/x/splits/queries/splits/query.go b/x/splits/queries/splits/query.go index b3736cb10..cd9e22b49 100644 --- a/x/splits/queries/splits/query.go +++ b/x/splits/queries/splits/query.go @@ -4,28 +4,17 @@ package splits import ( - "context" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "google.golang.org/grpc" - "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" helperConstants "github.com/AssetMantle/modules/helpers/constants" - "github.com/AssetMantle/modules/utilities/name" - "github.com/AssetMantle/modules/x/splits/constants" + "google.golang.org/grpc" ) -type dummy struct{} - var Query = baseHelpers.NewQuery( - name.GetPackageName(dummy{}), + _Query_serviceDesc.ServiceName, "", "", - constants.ModuleName, - requestPrototype, responsePrototype, keeperPrototype, @@ -33,9 +22,6 @@ var Query = baseHelpers.NewQuery( func(server grpc.ServiceRegistrar, QueryKeeper helpers.QueryKeeper) { RegisterQueryServer(server, QueryKeeper.(queryKeeper)) }, - func(clientContext client.Context, serveMux *runtime.ServeMux) error { - return RegisterQueryHandlerClient(context.Background(), serveMux, NewQueryClient(clientContext)) - }, helperConstants.SplitID, helperConstants.Limit, diff --git a/x/splits/queries/splits/query_keeper.go b/x/splits/queries/splits/query_keeper.go index 51a3b3f03..300b6d395 100644 --- a/x/splits/queries/splits/query_keeper.go +++ b/x/splits/queries/splits/query_keeper.go @@ -5,7 +5,6 @@ package splits import ( "context" - "github.com/AssetMantle/modules/helpers" ) @@ -16,7 +15,7 @@ type queryKeeper struct { var _ helpers.QueryKeeper = (*queryKeeper)(nil) func (queryKeeper queryKeeper) Enquire(context context.Context, queryRequest helpers.QueryRequest) (helpers.QueryResponse, error) { - queryResponse, err := queryKeeper.Handle(context, queryRequestFromInterface(queryRequest)) + queryResponse, err := queryKeeper.Handle(context, queryRequest.(*QueryRequest)) return queryResponse, err } func (queryKeeper queryKeeper) Handle(context context.Context, queryRequest *QueryRequest) (*QueryResponse, error) { diff --git a/x/splits/queries/splits/query_request.go b/x/splits/queries/splits/query_request.go index 975287afb..bb89aa999 100644 --- a/x/splits/queries/splits/query_request.go +++ b/x/splits/queries/splits/query_request.go @@ -13,7 +13,6 @@ import ( "github.com/cosmos/cosmos-sdk/types/query" "github.com/AssetMantle/modules/helpers" - "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/helpers/constants" "github.com/AssetMantle/modules/x/splits/key" ) @@ -69,27 +68,10 @@ func (*QueryRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.QueryRe return newQueryRequest(splitID.(ids.SplitID), int32(limit)), nil } -func (queryRequest *QueryRequest) Encode() ([]byte, error) { - return base.CodecPrototype().MarshalJSON(queryRequest) -} -func (queryRequest *QueryRequest) Decode(bytes []byte) (helpers.QueryRequest, error) { - if err := base.CodecPrototype().UnmarshalJSON(bytes, queryRequest); err != nil { - return nil, err - } - - return queryRequest, nil -} func requestPrototype() helpers.QueryRequest { return &QueryRequest{} } -func queryRequestFromInterface(request helpers.QueryRequest) *QueryRequest { - switch value := request.(type) { - case *QueryRequest: - return value - default: - return &QueryRequest{} - } -} + func newQueryRequest(splitID ids.SplitID, limit int32) helpers.QueryRequest { return &QueryRequest{Key: key.NewKey(splitID).(*key.Key), Limit: limit} } diff --git a/x/splits/queries/splits/service.pb.go b/x/splits/queries/splits/service.pb.go index 084f85ac8..82baa4dc9 100644 --- a/x/splits/queries/splits/service.pb.go +++ b/x/splits/queries/splits/service.pb.go @@ -8,7 +8,6 @@ import ( fmt "fmt" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" - _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -31,30 +30,27 @@ func init() { } var fileDescriptor_99bae0ab2f4f64e9 = []byte{ - // 360 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x92, 0x31, 0x4b, 0xf3, 0x40, - 0x18, 0xc7, 0x9b, 0xc0, 0xdb, 0x21, 0xbc, 0x53, 0xc6, 0xf2, 0xbe, 0x11, 0x04, 0x27, 0xe1, 0xce, - 0x2a, 0x28, 0xbd, 0x45, 0xdb, 0x45, 0x97, 0x40, 0x6b, 0x96, 0x20, 0x01, 0xb9, 0xb6, 0x0f, 0x35, - 0x90, 0xe4, 0xd2, 0xdc, 0xa5, 0xd4, 0xd5, 0x4f, 0x20, 0xf8, 0x0d, 0x1c, 0x1c, 0x9c, 0xfc, 0x18, - 0xe2, 0x54, 0x70, 0x71, 0x94, 0xc4, 0xc9, 0x4f, 0x21, 0xe9, 0x3d, 0xc5, 0x76, 0x4c, 0xc7, 0x7f, - 0xee, 0xff, 0x7b, 0xee, 0xff, 0xbf, 0x3c, 0x56, 0xa7, 0x2b, 0x25, 0x28, 0x97, 0x27, 0x2a, 0x02, - 0x1a, 0x8b, 0x71, 0x1e, 0x81, 0xa4, 0x73, 0x2a, 0xd3, 0x28, 0x54, 0x92, 0x4e, 0x73, 0xc8, 0x42, - 0x90, 0x2b, 0x29, 0x21, 0x9b, 0x85, 0x23, 0x20, 0x69, 0x26, 0x94, 0xb0, 0xf7, 0xd7, 0x50, 0x82, - 0x28, 0x99, 0x13, 0xed, 0x25, 0x88, 0xa2, 0x6c, 0xfd, 0x9b, 0x08, 0x31, 0x89, 0x80, 0xf2, 0x34, - 0xa4, 0x3c, 0x49, 0x84, 0xe2, 0x2a, 0x14, 0x89, 0xd4, 0xa3, 0x5a, 0xa7, 0x75, 0x52, 0x54, 0xf2, - 0xf6, 0x3a, 0x83, 0x69, 0x0e, 0x52, 0xe1, 0x80, 0xb3, 0x6d, 0x06, 0xc8, 0x54, 0x24, 0x12, 0xdb, - 0x1c, 0xbe, 0x18, 0xd6, 0x9f, 0x41, 0x75, 0x60, 0x3f, 0x19, 0x56, 0xf3, 0x82, 0x27, 0xe3, 0x08, - 0xec, 0x0e, 0xa9, 0xd1, 0x91, 0x2c, 0xf1, 0x4b, 0x9d, 0xab, 0xc5, 0xb6, 0x41, 0x75, 0xa2, 0xdd, - 0xbd, 0xbb, 0xf7, 0xaf, 0x07, 0x73, 0xc7, 0xfe, 0x4f, 0x63, 0xdd, 0x08, 0x83, 0xcf, 0xda, 0x43, - 0x50, 0xbc, 0x8d, 0xb2, 0x57, 0x9a, 0xaf, 0x85, 0x63, 0x2c, 0x0a, 0xc7, 0xf8, 0x2c, 0x1c, 0xe3, - 0xbe, 0x74, 0x1a, 0x8b, 0xd2, 0x69, 0x7c, 0x94, 0x4e, 0xc3, 0xa2, 0x23, 0x11, 0xd7, 0x09, 0xd0, - 0xfb, 0xeb, 0xe9, 0x7f, 0xdb, 0xaf, 0x1e, 0xa3, 0x6f, 0x5c, 0x1d, 0x4f, 0x42, 0x75, 0x93, 0x0f, - 0xc9, 0x48, 0xc4, 0xb4, 0xc6, 0xdb, 0x3e, 0x9a, 0xcd, 0xae, 0xeb, 0x7b, 0x03, 0xef, 0xd9, 0xdc, - 0x58, 0x0f, 0x17, 0xaf, 0xf7, 0x89, 0xf7, 0x5b, 0xb8, 0xba, 0x5e, 0xcb, 0xb7, 0x0d, 0x77, 0x80, - 0xee, 0xc0, 0x0f, 0xf4, 0x71, 0x80, 0x6e, 0x94, 0x85, 0x79, 0x52, 0xc3, 0x1d, 0x9c, 0xf7, 0x7b, - 0x2e, 0x28, 0x3e, 0xe6, 0x8a, 0x7f, 0x9b, 0x07, 0x6b, 0x24, 0x63, 0x88, 0x32, 0xe6, 0x33, 0xa6, - 0xdd, 0x8c, 0x21, 0xbd, 0xfa, 0x30, 0x6c, 0x2e, 0xf7, 0xe3, 0xe8, 0x27, 0x00, 0x00, 0xff, 0xff, - 0xfd, 0xcb, 0x99, 0xa8, 0x2a, 0x03, 0x00, 0x00, + // 312 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xb2, 0x74, 0x2c, 0x2e, 0x4e, + 0x2d, 0xf1, 0x4d, 0xcc, 0x2b, 0xc9, 0x49, 0xd5, 0xcf, 0xcd, 0x4f, 0x29, 0xcd, 0x49, 0x2d, 0xd6, + 0xaf, 0xd0, 0x2f, 0x2e, 0xc8, 0xc9, 0x2c, 0x29, 0xd6, 0x2f, 0x2c, 0x4d, 0x2d, 0xca, 0x4c, 0x2d, + 0x86, 0x71, 0x8b, 0x53, 0x8b, 0xca, 0x32, 0x93, 0x53, 0xf5, 0x0a, 0x8a, 0xf2, 0x4b, 0xf2, 0x85, + 0xb4, 0x91, 0xb4, 0xea, 0x41, 0xb5, 0xea, 0x55, 0xe8, 0x41, 0xd4, 0xea, 0x41, 0xb5, 0x42, 0xb9, + 0x52, 0xf6, 0xa4, 0xd8, 0x03, 0xe2, 0x56, 0xc6, 0x17, 0xa5, 0x16, 0x96, 0xa6, 0x16, 0x97, 0x40, + 0x6c, 0x93, 0x72, 0x20, 0xc7, 0x80, 0xe2, 0x82, 0xfc, 0xbc, 0x62, 0xa8, 0x7b, 0x8d, 0xba, 0x19, + 0xb9, 0x58, 0x03, 0x41, 0x12, 0x42, 0x8d, 0x8c, 0x5c, 0x6c, 0x1e, 0x89, 0x79, 0x29, 0x39, 0xa9, + 0x42, 0x96, 0x7a, 0x24, 0xf8, 0x42, 0x0f, 0xac, 0x3d, 0x08, 0xe2, 0x2e, 0x29, 0x2b, 0x72, 0xb4, + 0x42, 0x5c, 0xa4, 0xc4, 0xe0, 0xf4, 0x98, 0xe9, 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, 0x18, + 0x1f, 0x3c, 0x92, 0x63, 0x9c, 0xf0, 0x58, 0x8e, 0xe1, 0xc2, 0x63, 0x39, 0x86, 0x1b, 0x8f, 0xe5, + 0x18, 0xb8, 0xf4, 0x93, 0xf3, 0x73, 0x49, 0x31, 0xdb, 0x89, 0x27, 0x18, 0x12, 0x31, 0x01, 0x20, + 0x7f, 0x06, 0x30, 0x46, 0x99, 0xa5, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, + 0x93, 0x10, 0x6c, 0x8b, 0x98, 0xd8, 0x1c, 0x7d, 0x23, 0x82, 0x03, 0x83, 0x57, 0x31, 0xa1, 0xc4, + 0xad, 0x2f, 0xd4, 0xfa, 0x08, 0xbd, 0x60, 0x84, 0x5f, 0x40, 0xd6, 0x43, 0xb8, 0xa7, 0x50, 0x54, + 0xc7, 0x40, 0x55, 0xc7, 0x44, 0xc4, 0x40, 0xa4, 0x63, 0xa0, 0xaa, 0xa1, 0xdc, 0x47, 0x4c, 0xe6, + 0x24, 0xa8, 0x8e, 0x71, 0x0f, 0x70, 0xf2, 0x4d, 0x2d, 0x49, 0x4c, 0x49, 0x2c, 0x49, 0x7c, 0xc5, + 0x64, 0x80, 0xa4, 0xd3, 0xca, 0x0a, 0xaa, 0xd5, 0xca, 0x2a, 0xc2, 0xca, 0x0a, 0xa2, 0xda, 0xca, + 0x0a, 0xaa, 0x1b, 0x26, 0x90, 0xc4, 0x06, 0x8e, 0x7a, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, + 0x95, 0xb4, 0xd6, 0xbc, 0xe7, 0x02, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/splits/queries/splits/service.pb.gw.go b/x/splits/queries/splits/service.pb.gw.go deleted file mode 100644 index ea84e753e..000000000 --- a/x/splits/queries/splits/service.pb.gw.go +++ /dev/null @@ -1,171 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: AssetMantle/modules/x/splits/queries/splits/service.proto - -/* -Package splits is a reverse proxy. - -It translates gRPC into RESTful JSON APIs. -*/ -package splits - -import ( - "context" - "io" - "net/http" - - "github.com/golang/protobuf/descriptor" - "github.com/golang/protobuf/proto" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/grpc-ecosystem/grpc-gateway/utilities" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/status" -) - -// Suppress "imported and not used" errors -var _ codes.Code -var _ io.Reader -var _ status.Status -var _ = runtime.String -var _ = utilities.NewDoubleArray -var _ = descriptor.ForMessage -var _ = metadata.Join - -var ( - filter_Query_Handle_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - -func request_Query_Handle_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryRequest - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.Handle(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_Handle_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryRequest - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.Handle(ctx, &protoReq) - return msg, metadata, err - -} - -// RegisterQueryHandlerServer registers the http handlers for service Query to "mux". -// UnaryRPC :call QueryServer directly. -// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. -func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { - - mux.Handle("GET", pattern_Query_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Query_Handle_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but -// automatically dials to "endpoint" and closes the connection when "ctx" gets done. -func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.Dial(endpoint, opts...) - if err != nil { - return err - } - defer func() { - if err != nil { - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - return - } - go func() { - <-ctx.Done() - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - }() - }() - - return RegisterQueryHandler(ctx, mux, conn) -} - -// RegisterQueryHandler registers the http handlers for service Query to "mux". -// The handlers forward requests to the grpc endpoint over "conn". -func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { - return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn)) -} - -// RegisterQueryHandlerClient registers the http handlers for service Query -// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient". -// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient" -// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "QueryClient" to call the correct interceptors. -func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { - - mux.Handle("GET", pattern_Query_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Query_Handle_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -var ( - pattern_Query_Handle_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 1}, []string{"mantle", "splits", "v1beta1"}, "", runtime.AssumeColonVerbOpt(false))) -) - -var ( - forward_Query_Handle_0 = runtime.ForwardResponseMessage -) diff --git a/x/splits/queries/supply/query.go b/x/splits/queries/supply/query.go index 3f99e21b7..cc3df5b46 100644 --- a/x/splits/queries/supply/query.go +++ b/x/splits/queries/supply/query.go @@ -4,28 +4,17 @@ package supply import ( - "context" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "google.golang.org/grpc" - "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" helperConstants "github.com/AssetMantle/modules/helpers/constants" - "github.com/AssetMantle/modules/utilities/name" - "github.com/AssetMantle/modules/x/splits/constants" + "google.golang.org/grpc" ) -type dummy struct{} - var Query = baseHelpers.NewQuery( - name.GetPackageName(dummy{}), + _Query_serviceDesc.ServiceName, "", "", - constants.ModuleName, - requestPrototype, responsePrototype, keeperPrototype, @@ -33,9 +22,6 @@ var Query = baseHelpers.NewQuery( func(server grpc.ServiceRegistrar, QueryKeeper helpers.QueryKeeper) { RegisterQueryServer(server, QueryKeeper.(queryKeeper)) }, - func(clientContext client.Context, serveMux *runtime.ServeMux) error { - return RegisterQueryHandlerClient(context.Background(), serveMux, NewQueryClient(clientContext)) - }, helperConstants.AssetID, ) diff --git a/x/splits/queries/supply/query_keeper.go b/x/splits/queries/supply/query_keeper.go index efc254803..f35102293 100644 --- a/x/splits/queries/supply/query_keeper.go +++ b/x/splits/queries/supply/query_keeper.go @@ -5,7 +5,6 @@ package supply import ( "context" - "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/x/splits/utilities" ) @@ -17,7 +16,7 @@ type queryKeeper struct { var _ helpers.QueryKeeper = (*queryKeeper)(nil) func (queryKeeper queryKeeper) Enquire(context context.Context, queryRequest helpers.QueryRequest) (helpers.QueryResponse, error) { - queryResponse, err := queryKeeper.Handle(context, queryRequestFromInterface(queryRequest)) + queryResponse, err := queryKeeper.Handle(context, queryRequest.(*QueryRequest)) return queryResponse, err } func (queryKeeper queryKeeper) Handle(context context.Context, queryRequest *QueryRequest) (*QueryResponse, error) { diff --git a/x/splits/queries/supply/query_request.go b/x/splits/queries/supply/query_request.go index 7a8511b15..42871d9c8 100644 --- a/x/splits/queries/supply/query_request.go +++ b/x/splits/queries/supply/query_request.go @@ -5,7 +5,6 @@ package supply import ( "github.com/AssetMantle/modules/helpers" - "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/helpers/constants" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" @@ -47,27 +46,10 @@ func (*QueryRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.QueryRe return newQueryRequest(assetID.(ids.AssetID)), nil } } -func (queryRequest *QueryRequest) Encode() ([]byte, error) { - return base.CodecPrototype().MarshalJSON(queryRequest) -} -func (queryRequest *QueryRequest) Decode(bytes []byte) (helpers.QueryRequest, error) { - if err := base.CodecPrototype().UnmarshalJSON(bytes, queryRequest); err != nil { - return nil, err - } - - return queryRequest, nil -} func requestPrototype() helpers.QueryRequest { return &QueryRequest{} } -func queryRequestFromInterface(request helpers.QueryRequest) *QueryRequest { - switch value := request.(type) { - case *QueryRequest: - return value - default: - return &QueryRequest{} - } -} + func newQueryRequest(assetID ids.AssetID) helpers.QueryRequest { return &QueryRequest{AssetID: assetID.(*baseIDs.AssetID)} } diff --git a/x/splits/queries/supply/query_request_test.go b/x/splits/queries/supply/query_request_test.go index 503926bcd..bc9430e93 100644 --- a/x/splits/queries/supply/query_request_test.go +++ b/x/splits/queries/supply/query_request_test.go @@ -7,16 +7,14 @@ import ( "reflect" "testing" + "github.com/AssetMantle/modules/helpers" + "github.com/AssetMantle/modules/helpers/base" + "github.com/AssetMantle/modules/helpers/constants" baseDocuments "github.com/AssetMantle/schema/documents/base" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" "github.com/cosmos/cosmos-sdk/client" "github.com/spf13/viper" - "github.com/stretchr/testify/require" - - "github.com/AssetMantle/modules/helpers" - "github.com/AssetMantle/modules/helpers/base" - "github.com/AssetMantle/modules/helpers/constants" ) var ( @@ -56,85 +54,13 @@ func Test_queryRequestFromInterface(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - if got := queryRequestFromInterface(tt.args.request); !reflect.DeepEqual(got, tt.want) { + if got := tt.args.request.(*QueryRequest); !reflect.DeepEqual(got, tt.want) { t.Errorf("queryRequestFromInterface() = %v, want %v", got, tt.want) } }) } } -func Test_queryRequest_Decode(t *testing.T) { - encodedReq, err := base.CodecPrototype().GetLegacyAmino().MarshalJSON(newQueryRequest(testAssetID)) - require.NoError(t, err) - encodedReq1, err1 := base.CodecPrototype().GetLegacyAmino().MarshalJSON(newQueryRequest(baseIDs.PrototypeAssetID())) - require.NoError(t, err1) - type fields struct { - AssetID *baseIDs.AssetID - } - type args struct { - bytes []byte - } - tests := []struct { - name string - fields fields - args args - want helpers.QueryRequest - wantErr bool - }{ - {"+ve", fields{testAssetID}, args{encodedReq}, newQueryRequest(testAssetID), false}, - {"+ve", fields{baseIDs.PrototypeAssetID().(*baseIDs.AssetID)}, args{encodedReq1}, newQueryRequest(baseIDs.PrototypeAssetID()), false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - queryRequest := &QueryRequest{ - AssetID: tt.fields.AssetID, - } - got, err := queryRequest.Decode(tt.args.bytes) - if (err != nil) != tt.wantErr { - t.Errorf("Decode() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("Decode() got = %v, want %v", got, tt.want) - } - }) - } -} - -func Test_queryRequest_Encode(t *testing.T) { - encodedReq, err := base.CodecPrototype().GetLegacyAmino().MarshalJSON(newQueryRequest(testAssetID)) - require.NoError(t, err) - encodedReq1, err1 := base.CodecPrototype().GetLegacyAmino().MarshalJSON(newQueryRequest(baseIDs.PrototypeAssetID())) - require.NoError(t, err1) - type fields struct { - AssetID *baseIDs.AssetID - } - tests := []struct { - name string - fields fields - want []byte - wantErr bool - }{ - {"+ve", fields{testAssetID}, encodedReq, false}, - {"+ve", fields{baseIDs.PrototypeAssetID().(*baseIDs.AssetID)}, encodedReq1, false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - queryRequest := &QueryRequest{ - AssetID: tt.fields.AssetID, - } - got, err := queryRequest.Encode() - if (err != nil) != tt.wantErr { - t.Errorf("Encode() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("Encode() got = %v, want %v", got, tt.want) - } - }) - } -} - func Test_queryRequest_FromCLI(t *testing.T) { cliCommand := base.NewCLICommand("", "", "", []helpers.CLIFlag{constants.AssetID}) diff --git a/x/splits/queries/supply/query_response.go b/x/splits/queries/supply/query_response.go index f195f26d5..6f6f6ac75 100644 --- a/x/splits/queries/supply/query_response.go +++ b/x/splits/queries/supply/query_response.go @@ -4,10 +4,9 @@ package supply import ( - sdkTypes "github.com/cosmos/cosmos-sdk/types" - "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/helpers/base" + sdkTypes "github.com/cosmos/cosmos-sdk/types" ) var _ helpers.QueryResponse = (*QueryResponse)(nil) diff --git a/x/splits/queries/supply/service.pb.go b/x/splits/queries/supply/service.pb.go index b05654ea2..ca273fc2e 100644 --- a/x/splits/queries/supply/service.pb.go +++ b/x/splits/queries/supply/service.pb.go @@ -8,7 +8,6 @@ import ( fmt "fmt" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" - _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -31,30 +30,27 @@ func init() { } var fileDescriptor_b40cde5518a1c1ba = []byte{ - // 365 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x92, 0x31, 0x4b, 0xc3, 0x40, - 0x14, 0xc7, 0x9b, 0x80, 0x1d, 0x82, 0x53, 0xc6, 0xa2, 0x11, 0x04, 0x27, 0xe1, 0xce, 0x2a, 0x28, - 0xbd, 0x45, 0xdb, 0x45, 0x97, 0x40, 0x6b, 0x96, 0x20, 0x01, 0xb9, 0xb6, 0x8f, 0x1a, 0x48, 0x72, - 0x69, 0xee, 0x52, 0xda, 0xd5, 0x4f, 0x20, 0xf8, 0x0d, 0x1c, 0x1c, 0x9c, 0xfc, 0x18, 0xe2, 0x54, - 0x70, 0x71, 0x94, 0xc4, 0xc9, 0x4f, 0x21, 0xcd, 0xbd, 0xa1, 0x1d, 0xd3, 0x31, 0xe4, 0xff, 0x7b, - 0xff, 0xff, 0xff, 0xdd, 0xb3, 0x3a, 0x5d, 0x29, 0x41, 0xb9, 0x3c, 0x51, 0x11, 0xd0, 0x58, 0x8c, - 0xf3, 0x08, 0x24, 0x9d, 0x53, 0x99, 0x46, 0xa1, 0x92, 0x74, 0x9a, 0x43, 0x16, 0x82, 0xa4, 0x32, - 0x4f, 0xd3, 0x68, 0x41, 0x25, 0x64, 0xb3, 0x70, 0x04, 0x24, 0xcd, 0x84, 0x12, 0xf6, 0xf1, 0x1a, - 0x4a, 0x10, 0x25, 0x73, 0xa2, 0x51, 0x82, 0x28, 0xd1, 0x68, 0x6b, 0x6f, 0x22, 0xc4, 0x24, 0x02, - 0xca, 0xd3, 0x90, 0xf2, 0x24, 0x11, 0x8a, 0xab, 0x50, 0x24, 0x52, 0x8f, 0x6a, 0x5d, 0xd6, 0x49, - 0xb1, 0xfa, 0x5c, 0xdc, 0x67, 0x30, 0xcd, 0x41, 0x2a, 0x1c, 0x70, 0xb5, 0xcd, 0x00, 0x99, 0x8a, - 0x44, 0x62, 0x9b, 0xd3, 0x77, 0xc3, 0xda, 0x19, 0xac, 0x7e, 0xd8, 0xaf, 0x86, 0xd5, 0xbc, 0xe1, - 0xc9, 0x38, 0x02, 0xbb, 0x43, 0x6a, 0x74, 0x24, 0x15, 0x7e, 0xab, 0x73, 0xb5, 0xd8, 0x36, 0xa8, - 0x4e, 0x74, 0x78, 0xf4, 0xf8, 0xf5, 0xfb, 0x6c, 0x1e, 0xd8, 0xfb, 0x34, 0xd6, 0x8d, 0xb0, 0xc7, - 0xac, 0x3d, 0x04, 0xc5, 0xdb, 0xd8, 0xa3, 0x57, 0x9a, 0x1f, 0x85, 0x63, 0x2c, 0x0b, 0xc7, 0xf8, - 0x29, 0x1c, 0xe3, 0xa9, 0x74, 0x1a, 0xcb, 0xd2, 0x69, 0x7c, 0x97, 0x4e, 0xc3, 0xa2, 0x23, 0x11, - 0xd7, 0x09, 0xd0, 0xdb, 0xf5, 0xf4, 0xdb, 0xf6, 0x57, 0xcb, 0xe8, 0x1b, 0x77, 0xe7, 0x93, 0x50, - 0x3d, 0xe4, 0x43, 0x32, 0x12, 0x31, 0xad, 0xb1, 0xdb, 0x17, 0xb3, 0xd9, 0x75, 0x7d, 0x6f, 0xe0, - 0xbd, 0x99, 0x1b, 0xe7, 0xe1, 0xa2, 0xbd, 0x4f, 0x3c, 0x6d, 0x3f, 0x40, 0x7b, 0xaf, 0xc2, 0x3e, - 0x37, 0xd4, 0x01, 0xaa, 0x03, 0x3f, 0xd0, 0xea, 0x00, 0xd5, 0x81, 0x56, 0x17, 0xe6, 0x45, 0x0d, - 0x75, 0x70, 0xdd, 0xef, 0xb9, 0xa0, 0xf8, 0x98, 0x2b, 0xfe, 0x67, 0x9e, 0xac, 0x91, 0x8c, 0x21, - 0xca, 0x98, 0xcf, 0x98, 0x86, 0x19, 0x43, 0x9a, 0x31, 0x8d, 0x0f, 0x9b, 0xd5, 0x7d, 0x9c, 0xfd, - 0x07, 0x00, 0x00, 0xff, 0xff, 0xc7, 0xae, 0x0f, 0x9c, 0x2a, 0x03, 0x00, 0x00, + // 319 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0xd1, 0xb1, 0x4e, 0x84, 0x30, + 0x18, 0x07, 0x70, 0x4a, 0xe2, 0x0d, 0xc4, 0xe9, 0xc6, 0x1b, 0x3a, 0xb8, 0x9a, 0xb4, 0x46, 0x13, + 0xcd, 0x75, 0xd1, 0x63, 0xd1, 0x85, 0x04, 0x64, 0x21, 0xa6, 0x89, 0xe1, 0xa0, 0x51, 0x12, 0xa0, + 0x1c, 0x2d, 0xe6, 0x6e, 0x74, 0x76, 0xf1, 0x19, 0x1c, 0x7d, 0x12, 0xe3, 0x74, 0xa3, 0xa3, 0x81, + 0xcd, 0xa7, 0x30, 0xf0, 0x75, 0xb8, 0x1b, 0xb9, 0x91, 0xf0, 0xff, 0xf5, 0xff, 0xb5, 0x9f, 0x33, + 0x5f, 0x28, 0x25, 0xb4, 0x17, 0x97, 0x3a, 0x17, 0xb4, 0x90, 0x69, 0x93, 0x0b, 0x45, 0xd7, 0x54, + 0x55, 0x79, 0xa6, 0x15, 0x5d, 0x35, 0xa2, 0xce, 0x84, 0xa2, 0xaa, 0xa9, 0xaa, 0x7c, 0x43, 0x95, + 0xa8, 0x5f, 0xb2, 0x44, 0x90, 0xaa, 0x96, 0x5a, 0x4e, 0x4f, 0x77, 0x28, 0x31, 0x94, 0xac, 0x09, + 0x50, 0x62, 0x28, 0x01, 0x3a, 0xbb, 0x1e, 0xd3, 0xd3, 0x7f, 0x6e, 0x1e, 0x6b, 0xb1, 0x6a, 0x84, + 0xd2, 0xd0, 0x36, 0xbb, 0x39, 0xe4, 0x00, 0x55, 0xc9, 0x52, 0x99, 0x79, 0xcf, 0xdf, 0x90, 0x73, + 0x14, 0xf4, 0x3f, 0xa6, 0xaf, 0xc8, 0x99, 0xdc, 0xc5, 0x65, 0x9a, 0x8b, 0xe9, 0x9c, 0x8c, 0xb8, + 0x05, 0x19, 0xf8, 0x3d, 0xcc, 0x35, 0x63, 0x87, 0x50, 0x98, 0xe8, 0xc4, 0x72, 0x3b, 0xfb, 0xab, + 0xc5, 0x68, 0xdb, 0x62, 0xf4, 0xdb, 0x62, 0xf4, 0xde, 0x61, 0x6b, 0xdb, 0x61, 0xeb, 0xa7, 0xc3, + 0x96, 0x43, 0x13, 0x59, 0x8c, 0x39, 0xdb, 0x3d, 0x0e, 0x61, 0x31, 0x7e, 0x7f, 0x4f, 0x1f, 0x3d, + 0x5c, 0x3e, 0x65, 0xfa, 0xb9, 0x59, 0x92, 0x44, 0x16, 0x74, 0xc4, 0xb3, 0x7d, 0xd8, 0x93, 0x85, + 0x17, 0x85, 0x41, 0xf8, 0x69, 0xef, 0xed, 0xd6, 0x33, 0xf5, 0x11, 0x09, 0xa1, 0x3e, 0x30, 0xf5, + 0xe1, 0xc0, 0xbe, 0xf7, 0xd2, 0xdc, 0xa4, 0x79, 0xc4, 0x21, 0xcd, 0x4d, 0x9a, 0x43, 0xba, 0xb5, + 0xaf, 0x46, 0xa4, 0xf9, 0xad, 0xef, 0x7a, 0x42, 0xc7, 0x69, 0xac, 0xe3, 0x3f, 0xfb, 0x6c, 0x47, + 0x32, 0x66, 0x28, 0x63, 0x11, 0x63, 0x80, 0x19, 0x33, 0x9a, 0x31, 0xe0, 0xcb, 0xc9, 0xb0, 0xfa, + 0x8b, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0x6d, 0x1b, 0x2c, 0x54, 0xe7, 0x02, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/splits/queries/supply/service.pb.gw.go b/x/splits/queries/supply/service.pb.gw.go deleted file mode 100644 index e01c4684d..000000000 --- a/x/splits/queries/supply/service.pb.gw.go +++ /dev/null @@ -1,171 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: AssetMantle/modules/x/splits/queries/supply/service.proto - -/* -Package supply is a reverse proxy. - -It translates gRPC into RESTful JSON APIs. -*/ -package supply - -import ( - "context" - "io" - "net/http" - - "github.com/golang/protobuf/descriptor" - "github.com/golang/protobuf/proto" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/grpc-ecosystem/grpc-gateway/utilities" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/status" -) - -// Suppress "imported and not used" errors -var _ codes.Code -var _ io.Reader -var _ status.Status -var _ = runtime.String -var _ = utilities.NewDoubleArray -var _ = descriptor.ForMessage -var _ = metadata.Join - -var ( - filter_Query_Handle_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - -func request_Query_Handle_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryRequest - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.Handle(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_Handle_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryRequest - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Handle_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.Handle(ctx, &protoReq) - return msg, metadata, err - -} - -// RegisterQueryHandlerServer registers the http handlers for service Query to "mux". -// UnaryRPC :call QueryServer directly. -// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. -func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { - - mux.Handle("GET", pattern_Query_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Query_Handle_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but -// automatically dials to "endpoint" and closes the connection when "ctx" gets done. -func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.Dial(endpoint, opts...) - if err != nil { - return err - } - defer func() { - if err != nil { - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - return - } - go func() { - <-ctx.Done() - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - }() - }() - - return RegisterQueryHandler(ctx, mux, conn) -} - -// RegisterQueryHandler registers the http handlers for service Query to "mux". -// The handlers forward requests to the grpc endpoint over "conn". -func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { - return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn)) -} - -// RegisterQueryHandlerClient registers the http handlers for service Query -// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient". -// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient" -// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "QueryClient" to call the correct interceptors. -func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { - - mux.Handle("GET", pattern_Query_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Query_Handle_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_Handle_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -var ( - pattern_Query_Handle_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"mantle", "splits", "v1beta1", "supply"}, "", runtime.AssumeColonVerbOpt(false))) -) - -var ( - forward_Query_Handle_0 = runtime.ForwardResponseMessage -) diff --git a/x/splits/record/record.go b/x/splits/record/record.go index a38c07719..a0b0a0b2c 100644 --- a/x/splits/record/record.go +++ b/x/splits/record/record.go @@ -1,15 +1,14 @@ package record import ( - "github.com/AssetMantle/schema/ids" - baseIDs "github.com/AssetMantle/schema/ids/base" - "github.com/AssetMantle/schema/types" - sdkTypes "github.com/cosmos/cosmos-sdk/types" - "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/x/splits/key" "github.com/AssetMantle/modules/x/splits/mappable" + "github.com/AssetMantle/schema/ids" + baseIDs "github.com/AssetMantle/schema/ids/base" + "github.com/AssetMantle/schema/types" + sdkTypes "github.com/cosmos/cosmos-sdk/types" ) func (record *Record) GetKey() helpers.Key { diff --git a/x/splits/simulator/genesis.go b/x/splits/simulator/genesis.go index a30834808..1581b5da2 100644 --- a/x/splits/simulator/genesis.go +++ b/x/splits/simulator/genesis.go @@ -4,8 +4,6 @@ package simulator import ( - "math/rand" - "github.com/AssetMantle/schema/data" baseData "github.com/AssetMantle/schema/data/base" baseDocuments "github.com/AssetMantle/schema/documents/base" @@ -15,6 +13,7 @@ import ( baseTypes "github.com/AssetMantle/schema/types/base" sdkTypes "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" + "math/rand" "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" diff --git a/x/splits/simulator/operations.go b/x/splits/simulator/operations.go index 9b2ee1b23..524fa0e87 100644 --- a/x/splits/simulator/operations.go +++ b/x/splits/simulator/operations.go @@ -4,10 +4,9 @@ package simulator import ( - "math/rand" - "github.com/cosmos/cosmos-sdk/types/module" "github.com/cosmos/cosmos-sdk/x/simulation" + "math/rand" "github.com/AssetMantle/modules/helpers" ) diff --git a/x/splits/simulator/params.go b/x/splits/simulator/params.go index ef6132d6e..6a5d99d4f 100644 --- a/x/splits/simulator/params.go +++ b/x/splits/simulator/params.go @@ -4,10 +4,9 @@ package simulator import ( - "math/rand" - simulationTypes "github.com/cosmos/cosmos-sdk/types/simulation" "github.com/cosmos/cosmos-sdk/x/simulation" + "math/rand" baseHelpers "github.com/AssetMantle/modules/helpers/base" "github.com/AssetMantle/modules/simulation/schema/types/base" diff --git a/x/splits/simulator/proposals.go b/x/splits/simulator/proposals.go index 72d20f254..53aac918f 100644 --- a/x/splits/simulator/proposals.go +++ b/x/splits/simulator/proposals.go @@ -4,28 +4,28 @@ package simulator import ( - "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" - "math/rand" - - sdk "github.com/cosmos/cosmos-sdk/types" + sdkTypes "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" simulationTypes "github.com/cosmos/cosmos-sdk/types/simulation" + govSimulation "github.com/cosmos/cosmos-sdk/x/gov/simulation" + "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" "github.com/cosmos/cosmos-sdk/x/simulation" + "math/rand" ) -func (simulator) WeightedProposalContentList(module.SimulationState) []simulationTypes.WeightedProposalContent { - return []simulationTypes.WeightedProposalContent{ - simulation.NewWeightedProposalContent( +func (simulator) ProposalMessages(_ module.SimulationState) []simulationTypes.WeightedProposalMsg { + return []simulationTypes.WeightedProposalMsg{ + simulation.NewWeightedProposalMsg( OpWeightSubmitTextProposal, DefaultWeightTextProposal, - simulateTextProposalContent, + func(r *rand.Rand, _ sdkTypes.Context, simulationAccounts []simulationTypes.Account) sdkTypes.Msg { + msgSubmitProposal, err := v1beta1.NewMsgSubmitProposal(v1beta1.NewTextProposal(simulationTypes.RandStringOfLength(r, 140), simulationTypes.RandStringOfLength(r, 5000)), govSimulation.GenDepositParamsMinDeposit(r), simulationAccounts[r.Intn(len(simulationAccounts))].Address) + if err != nil { + panic(err) + } + + return msgSubmitProposal + }, ), } } - -func simulateTextProposalContent(r *rand.Rand, _ sdk.Context, _ []simulationTypes.Account) simulationTypes.Content { - return v1beta1.NewTextProposal( - simulationTypes.RandStringOfLength(r, 140), - simulationTypes.RandStringOfLength(r, 5000), - ) -} diff --git a/x/splits/transactions/prototype_test.go b/x/splits/transactions/prototype_test.go index 2111560ca..19db02301 100644 --- a/x/splits/transactions/prototype_test.go +++ b/x/splits/transactions/prototype_test.go @@ -7,7 +7,7 @@ import ( "fmt" "reflect" "testing" - + "github.com/AssetMantle/modules/helpers" baseHelpers "github.com/AssetMantle/modules/helpers/base" ) diff --git a/x/splits/utilities/balances.go b/x/splits/utilities/balances.go index 0bb4664f5..c5cc3865a 100644 --- a/x/splits/utilities/balances.go +++ b/x/splits/utilities/balances.go @@ -1,10 +1,9 @@ package utilities import ( - "github.com/AssetMantle/schema/ids" - "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/x/splits/key" + "github.com/AssetMantle/schema/ids" ) func GetAllBalancesForIdentity(collection helpers.Collection, ownerID ids.IdentityID) helpers.Collection { diff --git a/x/splits/utilities/split.go b/x/splits/utilities/split.go index 93be339f3..058578b20 100644 --- a/x/splits/utilities/split.go +++ b/x/splits/utilities/split.go @@ -4,16 +4,15 @@ package utilities import ( + "github.com/AssetMantle/modules/helpers" errorConstants "github.com/AssetMantle/modules/helpers/constants" + "github.com/AssetMantle/modules/x/splits/key" + "github.com/AssetMantle/modules/x/splits/mappable" + "github.com/AssetMantle/modules/x/splits/record" "github.com/AssetMantle/schema/ids" baseIDs "github.com/AssetMantle/schema/ids/base" "github.com/AssetMantle/schema/types/base" sdkTypes "github.com/cosmos/cosmos-sdk/types" - - "github.com/AssetMantle/modules/helpers" - "github.com/AssetMantle/modules/x/splits/key" - "github.com/AssetMantle/modules/x/splits/mappable" - "github.com/AssetMantle/modules/x/splits/record" ) func AddSplits(splits helpers.Collection, ownerID ids.IdentityID, assetID ids.AssetID, value sdkTypes.Int) (helpers.Collection, error) { diff --git a/x/splits/utilities/supply.go b/x/splits/utilities/supply.go index 139aa3c76..06030505d 100644 --- a/x/splits/utilities/supply.go +++ b/x/splits/utilities/supply.go @@ -4,13 +4,12 @@ package utilities import ( - "github.com/AssetMantle/schema/ids" - baseIDs "github.com/AssetMantle/schema/ids/base" - sdkTypes "github.com/cosmos/cosmos-sdk/types" - "github.com/AssetMantle/modules/helpers" "github.com/AssetMantle/modules/x/splits/key" "github.com/AssetMantle/modules/x/splits/mappable" + "github.com/AssetMantle/schema/ids" + baseIDs "github.com/AssetMantle/schema/ids/base" + sdkTypes "github.com/cosmos/cosmos-sdk/types" ) func GetTotalSupply(collection helpers.Collection, assetID ids.AssetID) sdkTypes.Int {