From 2d96f7310e85a9669b4e51ac4e00e14a57d82860 Mon Sep 17 00:00:00 2001 From: Chandragupta Singh Date: Fri, 15 Dec 2023 04:11:02 +0530 Subject: [PATCH] common module added --- app/app.go | 24 +- go.mod | 2 +- proto/comdex/common/v1beta1/common.proto | 14 + proto/comdex/common/v1beta1/genesis.proto | 14 + proto/comdex/common/v1beta1/params.proto | 20 + proto/comdex/common/v1beta1/query.proto | 42 + proto/comdex/common/v1beta1/tx.proto | 54 + proto/cosmos/msg/v1/msg.proto | 30 + x/common/abci.go | 24 + x/common/client/cli/query.go | 65 + x/common/client/cli/query_params.go | 34 + x/common/client/cli/tx.go | 102 ++ x/common/expected/keeper.go | 13 + x/common/genesis.go | 24 + x/common/handler.go | 34 + x/common/keeper/grpc_query.go | 60 + x/common/keeper/grpc_query_params.go | 19 + x/common/keeper/keeper.go | 92 ++ x/common/keeper/msg_server.go | 116 ++ x/common/keeper/params.go | 32 + x/common/keeper/store.go | 94 ++ x/common/module.go | 170 ++ x/common/types/codec.go | 48 + x/common/types/common.pb.go | 513 ++++++ x/common/types/errors.go | 13 + x/common/types/events.go | 8 + x/common/types/expected_keepers.go | 20 + x/common/types/genesis.go | 24 + x/common/types/genesis.pb.go | 390 +++++ x/common/types/genesis_test.go | 40 + x/common/types/keys.go | 36 + .../types/message_de_register_contract.go | 50 + x/common/types/message_register_contract.go | 57 + x/common/types/message_update_params.go | 35 + x/common/types/params.go | 62 + x/common/types/params.pb.go | 366 +++++ x/common/types/query.pb.go | 1004 ++++++++++++ x/common/types/query.pb.gw.go | 236 +++ x/common/types/tx.pb.go | 1392 +++++++++++++++++ x/common/types/types.go | 1 + 40 files changed, 5372 insertions(+), 2 deletions(-) create mode 100644 proto/comdex/common/v1beta1/common.proto create mode 100644 proto/comdex/common/v1beta1/genesis.proto create mode 100644 proto/comdex/common/v1beta1/params.proto create mode 100644 proto/comdex/common/v1beta1/query.proto create mode 100644 proto/comdex/common/v1beta1/tx.proto create mode 100644 proto/cosmos/msg/v1/msg.proto create mode 100644 x/common/abci.go create mode 100644 x/common/client/cli/query.go create mode 100644 x/common/client/cli/query_params.go create mode 100644 x/common/client/cli/tx.go create mode 100644 x/common/expected/keeper.go create mode 100644 x/common/genesis.go create mode 100644 x/common/handler.go create mode 100644 x/common/keeper/grpc_query.go create mode 100644 x/common/keeper/grpc_query_params.go create mode 100644 x/common/keeper/keeper.go create mode 100644 x/common/keeper/msg_server.go create mode 100644 x/common/keeper/params.go create mode 100644 x/common/keeper/store.go create mode 100644 x/common/module.go create mode 100644 x/common/types/codec.go create mode 100644 x/common/types/common.pb.go create mode 100644 x/common/types/errors.go create mode 100644 x/common/types/events.go create mode 100644 x/common/types/expected_keepers.go create mode 100644 x/common/types/genesis.go create mode 100644 x/common/types/genesis.pb.go create mode 100644 x/common/types/genesis_test.go create mode 100644 x/common/types/keys.go create mode 100644 x/common/types/message_de_register_contract.go create mode 100644 x/common/types/message_register_contract.go create mode 100644 x/common/types/message_update_params.go create mode 100644 x/common/types/params.go create mode 100644 x/common/types/params.pb.go create mode 100644 x/common/types/query.pb.go create mode 100644 x/common/types/query.pb.gw.go create mode 100644 x/common/types/tx.pb.go create mode 100644 x/common/types/types.go diff --git a/app/app.go b/app/app.go index 3b7eae529..1f5cd1f5b 100644 --- a/app/app.go +++ b/app/app.go @@ -138,6 +138,11 @@ import ( "github.com/comdex-official/comdex/x/collector" collectorkeeper "github.com/comdex-official/comdex/x/collector/keeper" collectortypes "github.com/comdex-official/comdex/x/collector/types" + + "github.com/comdex-official/comdex/x/common" + commonkeeper "github.com/comdex-official/comdex/x/common/keeper" + commontypes "github.com/comdex-official/comdex/x/common/types" + "github.com/comdex-official/comdex/x/esm" esmkeeper "github.com/comdex-official/comdex/x/esm/keeper" esmtypes "github.com/comdex-official/comdex/x/esm/types" @@ -306,6 +311,7 @@ var ( ibcfee.AppModuleBasic{}, liquidationsV2.AppModuleBasic{}, auctionsV2.AppModuleBasic{}, + common.AppModuleBasic{}, icq.AppModuleBasic{}, ibchooks.AppModuleBasic{}, packetforward.AppModuleBasic{}, @@ -388,6 +394,7 @@ type App struct { Rewardskeeper rewardskeeper.Keeper NewliqKeeper liquidationsV2keeper.Keeper NewaucKeeper auctionsV2keeper.Keeper + CommonKeeper commonkeeper.Keeper // IBC modules // transfer module @@ -434,7 +441,7 @@ func New( markettypes.StoreKey, bandoraclemoduletypes.StoreKey, lockertypes.StoreKey, wasm.StoreKey, authzkeeper.StoreKey, auctiontypes.StoreKey, tokenminttypes.StoreKey, rewardstypes.StoreKey, feegrant.StoreKey, liquiditytypes.StoreKey, esmtypes.ModuleName, lendtypes.StoreKey, - liquidationsV2types.StoreKey, auctionsV2types.StoreKey, ibchookstypes.StoreKey, packetforwardtypes.StoreKey, icqtypes.StoreKey, consensusparamtypes.StoreKey, crisistypes.StoreKey, + liquidationsV2types.StoreKey, auctionsV2types.StoreKey, commontypes.StoreKey, ibchookstypes.StoreKey, packetforwardtypes.StoreKey, icqtypes.StoreKey, consensusparamtypes.StoreKey, crisistypes.StoreKey, ) ) @@ -489,6 +496,7 @@ func New( app.ParamsKeeper.Subspace(rewardstypes.ModuleName) app.ParamsKeeper.Subspace(liquidationsV2types.ModuleName) app.ParamsKeeper.Subspace(auctionsV2types.ModuleName) + app.ParamsKeeper.Subspace(commontypes.ModuleName) app.ParamsKeeper.Subspace(icqtypes.ModuleName) app.ParamsKeeper.Subspace(packetforwardtypes.ModuleName).WithKeyTable(packetforwardtypes.ParamKeyTable()) @@ -881,6 +889,15 @@ func New( &app.TokenmintKeeper, ) + app.CommonKeeper = commonkeeper.NewKeeper( + app.cdc, + app.keys[commontypes.StoreKey], + app.keys[commontypes.MemStoreKey], + app.GetSubspace(commontypes.ModuleName), + &app.WasmKeeper, + authtypes.NewModuleAddress(govtypes.ModuleName).String(), + ) + // ICQ Keeper icqKeeper := icqkeeper.NewKeeper( appCodec, @@ -1051,6 +1068,7 @@ func New( liquidity.NewAppModule(app.cdc, app.LiquidityKeeper, app.AccountKeeper, app.BankKeeper, app.AssetKeeper), rewards.NewAppModule(app.cdc, app.Rewardskeeper, app.AccountKeeper, app.BankKeeper), liquidationsV2.NewAppModule(app.cdc, app.NewliqKeeper, app.AccountKeeper, app.BankKeeper), + common.NewAppModule(app.cdc, app.CommonKeeper, app.AccountKeeper, app.BankKeeper, app.WasmKeeper), auctionsV2.NewAppModule(app.cdc, app.NewaucKeeper, app.BankKeeper), ibchooks.NewAppModule(app.AccountKeeper), icq.NewAppModule(*app.ICQKeeper), @@ -1097,6 +1115,7 @@ func New( esmtypes.ModuleName, liquidationsV2types.ModuleName, auctionsV2types.ModuleName, + commontypes.ModuleName, ibchookstypes.ModuleName, icqtypes.ModuleName, packetforwardtypes.ModuleName, @@ -1140,6 +1159,7 @@ func New( esmtypes.ModuleName, liquidationsV2types.ModuleName, auctionsV2types.ModuleName, + commontypes.ModuleName, ibchookstypes.ModuleName, icqtypes.ModuleName, packetforwardtypes.ModuleName, @@ -1187,6 +1207,7 @@ func New( crisistypes.ModuleName, liquidationsV2types.ModuleName, auctionsV2types.ModuleName, + commontypes.ModuleName, ibchookstypes.ModuleName, icqtypes.ModuleName, packetforwardtypes.ModuleName, @@ -1447,6 +1468,7 @@ func (a *App) ModuleAccountsPermissions() map[string][]string { rewardstypes.ModuleName: {authtypes.Minter, authtypes.Burner}, liquidationsV2types.ModuleName: {authtypes.Minter, authtypes.Burner}, auctionsV2types.ModuleName: {authtypes.Minter, authtypes.Burner}, + commontypes.ModuleName: nil, icatypes.ModuleName: nil, ibcfeetypes.ModuleName: nil, assettypes.ModuleName: nil, diff --git a/go.mod b/go.mod index 8cac8fadb..e7607087b 100644 --- a/go.mod +++ b/go.mod @@ -10,6 +10,7 @@ require ( github.com/bandprotocol/bandchain-packet v0.0.3 github.com/cometbft/cometbft v0.37.2 github.com/cometbft/cometbft-db v0.8.0 + github.com/cosmos/cosmos-proto v1.0.0-beta.3 github.com/cosmos/cosmos-sdk v0.47.5 github.com/cosmos/gogoproto v1.4.10 github.com/cosmos/ibc-apps/modules/async-icq/v7 v7.0.0 @@ -92,7 +93,6 @@ require ( github.com/coinbase/rosetta-sdk-go v0.7.9 // indirect github.com/confio/ics23/go v0.9.0 // indirect github.com/cosmos/btcutil v1.0.5 // indirect - github.com/cosmos/cosmos-proto v1.0.0-beta.3 // indirect github.com/cosmos/go-bip39 v1.0.0 // indirect github.com/cosmos/gogogateway v1.2.0 // indirect github.com/cosmos/iavl v0.20.0 // indirect diff --git a/proto/comdex/common/v1beta1/common.proto b/proto/comdex/common/v1beta1/common.proto new file mode 100644 index 000000000..b29cc9b0e --- /dev/null +++ b/proto/comdex/common/v1beta1/common.proto @@ -0,0 +1,14 @@ +syntax = "proto3"; +package comdex.common.v1beta1; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/comdex-official/comdex/x/common/types"; + +message WhitelistedContract { + uint64 game_id = 1; + string security_address = 2; + string contract_admin = 3; + string game_name = 4; + string contract_address = 5; +} diff --git a/proto/comdex/common/v1beta1/genesis.proto b/proto/comdex/common/v1beta1/genesis.proto new file mode 100644 index 000000000..a5fc9bbb4 --- /dev/null +++ b/proto/comdex/common/v1beta1/genesis.proto @@ -0,0 +1,14 @@ +syntax = "proto3"; +package comdex.common.v1beta1; + +import "gogoproto/gogo.proto"; +import "comdex/common/v1beta1/params.proto"; +import "comdex/common/v1beta1/common.proto"; + +option go_package = "github.com/comdex-official/comdex/x/common/types"; + +// GenesisState defines the common module's genesis state. +message GenesisState { + Params params = 1 [(gogoproto.nullable) = false]; + repeated WhitelistedContract whitelisted_contracts = 2 [ (gogoproto.moretags) = "yaml:\"whitelisted_contracts\"" ]; +} diff --git a/proto/comdex/common/v1beta1/params.proto b/proto/comdex/common/v1beta1/params.proto new file mode 100644 index 000000000..1dd8dcde8 --- /dev/null +++ b/proto/comdex/common/v1beta1/params.proto @@ -0,0 +1,20 @@ +syntax = "proto3"; +package comdex.common.v1beta1; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/comdex-official/comdex/x/common/types"; + +// Params defines the set of module parameters. +message Params { + // Security address that can whitelist/delist contract + repeated string security_address = 1 [ + (gogoproto.jsontag) = "security_address,omitempty", + (gogoproto.moretags) = "yaml:\"security_address\"" + ]; + + uint64 contract_gas_limit = 2 [ + (gogoproto.jsontag) = "contract_gas_limit,omitempty", + (gogoproto.moretags) = "yaml:\"contract_gas_limit\"" + ]; +} diff --git a/proto/comdex/common/v1beta1/query.proto b/proto/comdex/common/v1beta1/query.proto new file mode 100644 index 000000000..697d47d84 --- /dev/null +++ b/proto/comdex/common/v1beta1/query.proto @@ -0,0 +1,42 @@ +syntax = "proto3"; +package comdex.common.v1beta1; + +import "gogoproto/gogo.proto"; +import "google/api/annotations.proto"; +import "cosmos/base/query/v1beta1/pagination.proto"; +import "comdex/common/v1beta1/params.proto"; +import "comdex/common/v1beta1/common.proto"; + +option go_package = "github.com/comdex-official/comdex/x/common/types"; + +// Query defines the gRPC querier service. +service Query { + // Parameters queries the parameters of the module. + rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { + option (google.api.http).get = "/comdex/common/v1beta1/params"; + } + rpc QueryWhitelistedContracts(QueryWhitelistedContractsRequest) returns (QueryWhitelistedContractsResponse) { + option (google.api.http).get = "/comdex/common/v1beta1/whitelisted_contracts"; + } +} + +// QueryParamsRequest is request type for the Query/Params RPC method. +message QueryParamsRequest {} + +// QueryParamsResponse is response type for the Query/Params RPC method. +message QueryParamsResponse { + // params holds all the parameters of this module. + Params params = 1 [(gogoproto.nullable) = false]; +} + +message QueryWhitelistedContractsRequest{ + cosmos.base.query.v1beta1.PageRequest pagination = 1 + [(gogoproto.moretags) = "yaml:\"pagination\""]; +} + +message QueryWhitelistedContractsResponse { + repeated WhitelistedContract whilisted_contracts = 1 [(gogoproto.nullable) = false]; + cosmos.base.query.v1beta1.PageResponse pagination = 2 + [(gogoproto.moretags) = "yaml:\"pagination\""]; +} + diff --git a/proto/comdex/common/v1beta1/tx.proto b/proto/comdex/common/v1beta1/tx.proto new file mode 100644 index 000000000..c1eba07e0 --- /dev/null +++ b/proto/comdex/common/v1beta1/tx.proto @@ -0,0 +1,54 @@ +syntax = "proto3"; +package comdex.common.v1beta1; +import "gogoproto/gogo.proto"; + +import "cosmos/msg/v1/msg.proto"; +import "cosmos_proto/cosmos.proto"; +import "comdex/common/v1beta1/params.proto"; + + +option go_package = "github.com/comdex-official/comdex/x/common/types"; + +// Msg defines the Msg service. +service Msg { + rpc RegisterContract(MsgRegisterContract) returns(MsgRegisterContractResponse); + rpc DeRegisterContract(MsgDeRegisterContract) returns(MsgDeRegisterContractResponse); + rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse); +} + +message MsgRegisterContract { + string security_address = 1; + string game_name = 2; + string contract_address = 3; + } + +message MsgRegisterContractResponse {} + +message MsgDeRegisterContract { + string security_address = 1; + uint64 game_id = 2; +} + +message MsgDeRegisterContractResponse {} + + +// MsgUpdateParams is the MsgUpdateParams request type. +// +// Since: 0.47 +message MsgUpdateParams { + option (cosmos.msg.v1.signer) = "authority"; + + // authority is the address that controls the module (defaults to x/gov unless overwritten). + string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + + // params defines the x/auth parameters to update. + // + // NOTE: All parameters must be supplied. + Params params = 2 [(gogoproto.nullable) = false]; +} + +// MsgUpdateParamsResponse defines the response structure for executing a +// MsgUpdateParams message. +// +// Since: 0.47 +message MsgUpdateParamsResponse {} \ No newline at end of file diff --git a/proto/cosmos/msg/v1/msg.proto b/proto/cosmos/msg/v1/msg.proto new file mode 100644 index 000000000..5f26d4c8a --- /dev/null +++ b/proto/cosmos/msg/v1/msg.proto @@ -0,0 +1,30 @@ +syntax = "proto3"; + +package cosmos.msg.v1; + +import "google/protobuf/descriptor.proto"; + +// TODO(fdymylja): once we fully migrate to protov2 the go_package needs to be updated. +// We need this right now because gogoproto codegen needs to import the extension. +option go_package = "github.com/cosmos/cosmos-sdk/types/msgservice"; + +extend google.protobuf.ServiceOptions { + // service indicates that the service is a Msg service and that requests + // must be transported via blockchain transactions rather than gRPC. + // Tooling can use this annotation to distinguish between Msg services and + // other types of services via reflection. + bool service = 11110000; +} + +extend google.protobuf.MessageOptions { + // signer must be used in cosmos messages in order + // to signal to external clients which fields in a + // given cosmos message must be filled with signer + // information (address). + // The field must be the protobuf name of the message + // field extended with this MessageOption. + // The field must either be of string kind, or of message + // kind in case the signer information is contained within + // a message inside the cosmos message. + repeated string signer = 11110000; +} \ No newline at end of file diff --git a/x/common/abci.go b/x/common/abci.go new file mode 100644 index 000000000..9e2ae2a3d --- /dev/null +++ b/x/common/abci.go @@ -0,0 +1,24 @@ +package common + +import ( + "fmt" + "github.com/comdex-official/comdex/x/common/keeper" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func BeginBlocker(ctx sdk.Context, k keeper.Keeper) { + + Msg := []byte(`{"resolve_bet":{}}`) + + allContracts := k.GetAllContract(ctx) + logger := k.Logger(ctx) + + for _, data := range allContracts { + err := k.SudoContractCall(ctx, data.ContractAddress, Msg) + if err != nil { + logger.Error(fmt.Sprintf("Game Id %d contract call error", data.GameId)) + } + logger.Info(fmt.Sprintf("Game Id %d contract call", data.GameId)) + } + +} diff --git a/x/common/client/cli/query.go b/x/common/client/cli/query.go new file mode 100644 index 000000000..e66baeabc --- /dev/null +++ b/x/common/client/cli/query.go @@ -0,0 +1,65 @@ +package cli + +import ( + "fmt" + // "strings" + + "github.com/spf13/cobra" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + + // sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/comdex-official/comdex/x/common/types" +) + +// GetQueryCmd returns the cli query commands for this module +func GetQueryCmd(queryRoute string) *cobra.Command { + // Group common queries under a subcommand + cmd := &cobra.Command{ + Use: types.ModuleName, + Short: fmt.Sprintf("Querying commands for the %s module", types.ModuleName), + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + cmd.AddCommand(CmdQueryParams(), + QueryWhitelistedContracts()) + // this line is used by starport scaffolding # 1 + + return cmd +} + +func QueryWhitelistedContracts() *cobra.Command { + cmd := &cobra.Command{ + Use: "whitelisted-contracts", + Short: "Query all whitelisted contracts", + RunE: func(cmd *cobra.Command, args []string) error { + ctx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + pagination, err := client.ReadPageRequest(cmd.Flags()) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(ctx) + + res, err := queryClient.QueryWhitelistedContracts(cmd.Context(), &types.QueryWhitelistedContractsRequest{ + Pagination: pagination, + }) + if err != nil { + return err + } + return ctx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + flags.AddPaginationFlagsToCmd(cmd, "whitelisted-contracts") + + return cmd +} diff --git a/x/common/client/cli/query_params.go b/x/common/client/cli/query_params.go new file mode 100644 index 000000000..d47a30299 --- /dev/null +++ b/x/common/client/cli/query_params.go @@ -0,0 +1,34 @@ +package cli + +import ( + "context" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/spf13/cobra" + "github.com/comdex-official/comdex/x/common/types" +) + +func CmdQueryParams() *cobra.Command { + cmd := &cobra.Command{ + Use: "params", + Short: "shows the parameters of the module", + Args: cobra.NoArgs, + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + + queryClient := types.NewQueryClient(clientCtx) + + res, err := queryClient.Params(context.Background(), &types.QueryParamsRequest{}) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/common/client/cli/tx.go b/x/common/client/cli/tx.go new file mode 100644 index 000000000..132cf0beb --- /dev/null +++ b/x/common/client/cli/tx.go @@ -0,0 +1,102 @@ +package cli + +import ( + "fmt" + "strconv" + "time" + + "github.com/spf13/cobra" + + "github.com/comdex-official/comdex/x/common/types" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" +) + +var ( + DefaultRelativePacketTimeoutTimestamp = uint64((time.Duration(10) * time.Minute).Nanoseconds()) +) + +const ( + flagPacketTimeoutTimestamp = "packet-timeout-timestamp" + listSeparator = "," +) + +// GetTxCmd returns the transaction commands for this module +func GetTxCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: types.ModuleName, + Short: fmt.Sprintf("%s transactions subcommands", types.ModuleName), + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + cmd.AddCommand(CmdRegisterContract(), + CmdDeRegisterContract()) + + // this line is used by starport scaffolding # 1 + + return cmd +} + +func CmdRegisterContract() *cobra.Command { + cmd := &cobra.Command{ + Use: "register-contract [game name] [contract address]", + Short: "Register game contract", + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) (err error) { + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + msg := types.NewMsgRegisterContract( + clientCtx.GetFromAddress().String(), + args[0], + args[1], + ) + if err := msg.ValidateBasic(); err != nil { + return err + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + +func CmdDeRegisterContract() *cobra.Command { + cmd := &cobra.Command{ + Use: "de-register-contract [game id]", + Short: "De Register game contract", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) (err error) { + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + gameId, err := strconv.ParseUint(args[0], 10, 64) + if err != nil { + return fmt.Errorf("game-id '%s' not a valid uint", args[1]) + } + + msg := types.NewMsgDeRegisterContract( + clientCtx.GetFromAddress().String(), + gameId, + ) + if err := msg.ValidateBasic(); err != nil { + return err + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} diff --git a/x/common/expected/keeper.go b/x/common/expected/keeper.go new file mode 100644 index 000000000..57bc99ede --- /dev/null +++ b/x/common/expected/keeper.go @@ -0,0 +1,13 @@ +package expected + +import ( + wasmvmtypes "github.com/CosmWasm/wasmd/x/wasm/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// ContractOpsKeeper contains mutable operations on a contract. +type ContractOpsKeeper interface { + // Sudo allows to call privileged entry point of a contract. + Sudo(ctx sdk.Context, contractAddress sdk.AccAddress, msg []byte) ([]byte, error) + GetContractInfo(ctx sdk.Context, contractAddress sdk.AccAddress) *wasmvmtypes.ContractInfo +} \ No newline at end of file diff --git a/x/common/genesis.go b/x/common/genesis.go new file mode 100644 index 000000000..9c94d4c4b --- /dev/null +++ b/x/common/genesis.go @@ -0,0 +1,24 @@ +package common + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/comdex-official/comdex/x/common/keeper" + "github.com/comdex-official/comdex/x/common/types" +) + +// InitGenesis initializes the capability module's state from a provided genesis +// state. +func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) { + // this line is used by starport scaffolding # genesis/module/init + k.SetParams(ctx, genState.Params) +} + +// ExportGenesis returns the capability module's exported genesis. +func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { + genesis := types.DefaultGenesis() + genesis.Params = k.GetParams(ctx) + + // this line is used by starport scaffolding # genesis/module/export + + return genesis +} diff --git a/x/common/handler.go b/x/common/handler.go new file mode 100644 index 000000000..115600027 --- /dev/null +++ b/x/common/handler.go @@ -0,0 +1,34 @@ +package common + +import ( + "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/comdex-official/comdex/x/common/keeper" + "github.com/comdex-official/comdex/x/common/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +// NewHandler ... +func NewHandler(k keeper.Keeper) sdk.Handler { + // this line is used by starport scaffolding # handler/msgServer + + server := keeper.NewMsgServerImpl(k) + + return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { + ctx = ctx.WithEventManager(sdk.NewEventManager()) + + switch msg := msg.(type) { + case *types.MsgRegisterContract: + res, err := server.RegisterContract(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + case *types.MsgDeRegisterContract: + res, err := server.DeRegisterContract(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + // this line is used by starport scaffolding # 1 + default: + errMsg := fmt.Sprintf("unrecognized %s message type: %T", types.ModuleName, msg) + return nil, sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, errMsg) + } + } +} diff --git a/x/common/keeper/grpc_query.go b/x/common/keeper/grpc_query.go new file mode 100644 index 000000000..101c4dcca --- /dev/null +++ b/x/common/keeper/grpc_query.go @@ -0,0 +1,60 @@ +package keeper + +import ( + "context" + + "github.com/comdex-official/comdex/x/common/types" + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/query" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +var _ types.QueryServer = QueryServer{} + +type QueryServer struct { + Keeper +} + +func NewQueryServerImpl(k Keeper) types.QueryServer { + return &QueryServer{ + Keeper: k, + } +} + +func (q QueryServer) QueryWhitelistedContracts(c context.Context, req *types.QueryWhitelistedContractsRequest) (*types.QueryWhitelistedContractsResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "request cannot be empty") + } + + var ( + items []types.WhitelistedContract + ctx = sdk.UnwrapSDKContext(c) + ) + + pagination, err := query.FilteredPaginate( + prefix.NewStore(q.Store(ctx), types.SetContractKeyPrefix), + req.Pagination, + func(_, value []byte, accumulate bool) (bool, error) { + var item types.WhitelistedContract + if err := q.cdc.Unmarshal(value, &item); err != nil { + return false, err + } + + if accumulate { + items = append(items, item) + } + + return true, nil + }, + ) + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } + + return &types.QueryWhitelistedContractsResponse{ + WhilistedContracts: items, + Pagination: pagination, + }, nil +} diff --git a/x/common/keeper/grpc_query_params.go b/x/common/keeper/grpc_query_params.go new file mode 100644 index 000000000..a868e5999 --- /dev/null +++ b/x/common/keeper/grpc_query_params.go @@ -0,0 +1,19 @@ +package keeper + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/comdex-official/comdex/x/common/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +func (k Keeper) Params(c context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + ctx := sdk.UnwrapSDKContext(c) + + return &types.QueryParamsResponse{Params: k.GetParams(ctx)}, nil +} diff --git a/x/common/keeper/keeper.go b/x/common/keeper/keeper.go new file mode 100644 index 000000000..6ed7e70b4 --- /dev/null +++ b/x/common/keeper/keeper.go @@ -0,0 +1,92 @@ +package keeper + +import ( + "fmt" + + "encoding/hex" + "github.com/cometbft/cometbft/libs/log" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + + "github.com/comdex-official/comdex/x/common/expected" + "github.com/comdex-official/comdex/x/common/types" + "github.com/cosmos/cosmos-sdk/codec" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" +) + +type ( + Keeper struct { + cdc codec.BinaryCodec + storeKey storetypes.StoreKey + memKey storetypes.StoreKey + paramstore paramtypes.Subspace + conOps expected.ContractOpsKeeper + // the address capable of executing a MsgUpdateParams message. Typically, this + // should be the x/gov module account. + authority string + } +) + +func NewKeeper( + cdc codec.BinaryCodec, + storeKey, + memKey storetypes.StoreKey, + ps paramtypes.Subspace, + conOps expected.ContractOpsKeeper, + authority string, + +) Keeper { + + return Keeper{ + + cdc: cdc, + storeKey: storeKey, + memKey: memKey, + paramstore: ps, + conOps: conOps, + authority: authority, + } +} + +// GetAuthority returns the x/common module's authority. +func (k Keeper) GetAuthority() string { + return k.authority +} + +func (k Keeper) Logger(ctx sdk.Context) log.Logger { + return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) +} + +//nolint:staticcheck +func (k Keeper) SudoContractCall(ctx sdk.Context, contractAddress string, p []byte) error { + + contractAddr, err := sdk.AccAddressFromBech32(contractAddress) + if err != nil { + return sdkerrors.Wrapf(err, "contract") + } + data, err := k.conOps.Sudo(ctx, contractAddr, p) + if err != nil { + return err + } + + ctx.EventManager().EmitEvent(sdk.NewEvent( + types.EventTypeContractSudoMsg, + sdk.NewAttribute(types.AttributeKeyResultDataHex, hex.EncodeToString(data)), + )) + return nil +} + +func (k Keeper) CheckSecurityAddress(ctx sdk.Context, from string) bool { + params := k.GetParams(ctx) + for _, addr := range params.SecurityAddress { + if addr == from { + return true + } + } + return false +} + +func (k Keeper) Store(ctx sdk.Context) sdk.KVStore { + return ctx.KVStore(k.storeKey) +} diff --git a/x/common/keeper/msg_server.go b/x/common/keeper/msg_server.go new file mode 100644 index 000000000..d023d53af --- /dev/null +++ b/x/common/keeper/msg_server.go @@ -0,0 +1,116 @@ +package keeper + +import ( + "context" + "fmt" + + "cosmossdk.io/errors" + "github.com/comdex-official/comdex/x/common/types" + sdk "github.com/cosmos/cosmos-sdk/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +type msgServer struct { + Keeper +} + +// NewMsgServerImpl returns an implementation of the MsgServer interface +// for the provided Keeper. +func NewMsgServerImpl(keeper Keeper) types.MsgServer { + return &msgServer{Keeper: keeper} +} + +var _ types.MsgServer = msgServer{} + +func (k msgServer) RegisterContract(goCtx context.Context, msg *types.MsgRegisterContract) (*types.MsgRegisterContractResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + if err := msg.ValidateBasic(); err != nil { + ctx.Logger().Error(fmt.Sprintf("request invalid: %s", err)) + return &types.MsgRegisterContractResponse{}, err + } + + // Validation such that only the user who instantiated the contract can register contract + contractAddr, err := sdk.AccAddressFromBech32(msg.ContractAddress) + if err != nil { + return &types.MsgRegisterContractResponse{}, sdkerrors.ErrInvalidAddress + } + contractInfo := k.conOps.GetContractInfo(ctx, contractAddr) + + // check if sender is authorized + exists := k.CheckSecurityAddress(ctx, msg.SecurityAddress) + if !exists { + return &types.MsgRegisterContractResponse{}, sdkerrors.ErrUnauthorized + } + + allContracts := k.GetAllContract(ctx) + + for _, data := range allContracts { + if data.ContractAddress == msg.ContractAddress{ + return &types.MsgRegisterContractResponse{}, sdkerrors.Wrapf(sdkerrors.ErrNotFound, "contract already registered") + } + } + gameID := k.GetGameID(ctx) + contract := types.WhitelistedContract { + GameId: gameID+1, + SecurityAddress: msg.SecurityAddress, + ContractAdmin: contractInfo.Admin, + GameName: msg.GameName, + ContractAddress: msg.ContractAddress, + } + + err = k.SetContract(ctx, contract) + if err != nil { + ctx.Logger().Error("failed to set new contract") + return &types.MsgRegisterContractResponse{}, err + } + k.SetGameID(ctx, gameID+1) + + return &types.MsgRegisterContractResponse{}, nil +} + +func (k msgServer) DeRegisterContract(goCtx context.Context, msg *types.MsgDeRegisterContract) (*types.MsgDeRegisterContractResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + if err := msg.ValidateBasic(); err != nil { + ctx.Logger().Error(fmt.Sprintf("request invalid: %s", err)) + return &types.MsgDeRegisterContractResponse{}, err + } + + // Get Game info from Game Id + gameInfo, found := k.GetContract(ctx, msg.GameId) + if !found { + return &types.MsgDeRegisterContractResponse{}, sdkerrors.Wrapf(sdkerrors.ErrNotFound, "no contract found for this game ID") + } + + // Validation such that only the user who instantiated the contract can register contract + contractAddr, err := sdk.AccAddressFromBech32(gameInfo.ContractAddress) + if err != nil { + return &types.MsgDeRegisterContractResponse{}, sdkerrors.ErrInvalidAddress + } + contractInfo := k.conOps.GetContractInfo(ctx, contractAddr) + + // check if sender is authorized + exists := k.CheckSecurityAddress(ctx, msg.SecurityAddress) + if !exists && contractInfo.Admin != msg.SecurityAddress{ + return &types.MsgDeRegisterContractResponse{}, sdkerrors.ErrUnauthorized + } + + k.DeleteContract(ctx, msg.GameId) + + return &types.MsgDeRegisterContractResponse{}, nil +} + +func (k msgServer) UpdateParams(goCtx context.Context, req *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) { + if k.authority != req.Authority { + return nil, errors.Wrapf(govtypes.ErrInvalidSigner, "invalid authority; expected %s, got %s", k.authority, req.Authority) + } + + ctx := sdk.UnwrapSDKContext(goCtx) + if err := k.SetParams(ctx, req.Params); err != nil { + return nil, err + } + + return &types.MsgUpdateParamsResponse{}, nil +} \ No newline at end of file diff --git a/x/common/keeper/params.go b/x/common/keeper/params.go new file mode 100644 index 000000000..13e7289a4 --- /dev/null +++ b/x/common/keeper/params.go @@ -0,0 +1,32 @@ +package keeper + +import ( + "github.com/comdex-official/comdex/x/common/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// SetParams sets the x/common module parameters. +func (k Keeper) SetParams(ctx sdk.Context, p types.Params) error { + if err := p.Validate(); err != nil { + return err + } + + store := ctx.KVStore(k.storeKey) + bz := k.cdc.MustMarshal(&p) + store.Set(types.ParamsKey, bz) + + return nil +} + +// GetParams returns the current x/common module parameters. +func (k Keeper) GetParams(ctx sdk.Context) (p types.Params) { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.ParamsKey) + if bz == nil { + return p + } + + k.cdc.MustUnmarshal(bz, &p) + return p +} + diff --git a/x/common/keeper/store.go b/x/common/keeper/store.go new file mode 100644 index 000000000..e7484be8b --- /dev/null +++ b/x/common/keeper/store.go @@ -0,0 +1,94 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/comdex-official/comdex/x/common/types" + protobuftypes "github.com/cosmos/gogoproto/types" +) + +func (k Keeper) SetGameID(ctx sdk.Context, id uint64) { + var ( + store = k.Store(ctx) + key = types.GameIDKey + value = k.cdc.MustMarshal( + &protobuftypes.UInt64Value{ + Value: id, + }, + ) + ) + + store.Set(key, value) +} + +func (k Keeper) GetGameID(ctx sdk.Context) uint64 { + var ( + store = k.Store(ctx) + key = types.GameIDKey + value = store.Get(key) + ) + + if value == nil { + return 0 + } + + var id protobuftypes.UInt64Value + k.cdc.MustUnmarshal(value, &id) + + return id.GetValue() +} + +func (k Keeper) SetContract(ctx sdk.Context, msg types.WhitelistedContract) error { + var ( + store = k.Store(ctx) + key = types.ContractKey(msg.GameId) + value = k.cdc.MustMarshal(&msg) + ) + + store.Set(key, value) + return nil +} + +func (k Keeper) GetContract(ctx sdk.Context, gameID uint64) (contract types.WhitelistedContract, found bool) { + var ( + store = k.Store(ctx) + key = types.ContractKey(gameID) + value = store.Get(key) + ) + + if value == nil { + return contract, false + } + + k.cdc.MustUnmarshal(value, &contract) + return contract, true +} + +func (k Keeper) DeleteContract(ctx sdk.Context, gameID uint64) { + var ( + store = k.Store(ctx) + key = types.ContractKey(gameID) + ) + + store.Delete(key) +} + +func (k Keeper) GetAllContract(ctx sdk.Context) (contracts []types.WhitelistedContract) { + var ( + store = k.Store(ctx) + iter = sdk.KVStorePrefixIterator(store, types.SetContractKeyPrefix) + ) + + defer func(iter sdk.Iterator) { + err := iter.Close() + if err != nil { + return + } + }(iter) + + for ; iter.Valid(); iter.Next() { + var contract types.WhitelistedContract + k.cdc.MustUnmarshal(iter.Value(), &contract) + contracts = append(contracts, contract) + } + return contracts +} \ No newline at end of file diff --git a/x/common/module.go b/x/common/module.go new file mode 100644 index 000000000..639ff8fdd --- /dev/null +++ b/x/common/module.go @@ -0,0 +1,170 @@ +package common + +import ( + "context" + "encoding/json" + "fmt" + // this line is used by starport scaffolding # 1 + + "github.com/gorilla/mux" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/spf13/cobra" + + abci "github.com/cometbft/cometbft/abci/types" + + "github.com/comdex-official/comdex/x/common/client/cli" + "github.com/comdex-official/comdex/x/common/expected" + "github.com/comdex-official/comdex/x/common/keeper" + "github.com/comdex-official/comdex/x/common/types" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/codec" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" +) + +var ( + _ module.AppModule = AppModule{} + _ module.AppModuleBasic = AppModuleBasic{} +) + +// ---------------------------------------------------------------------------- +// AppModuleBasic +// ---------------------------------------------------------------------------- + +// AppModuleBasic implements the AppModuleBasic interface for the capability module. +type AppModuleBasic struct { + cdc codec.Codec +} + +func NewAppModuleBasic(cdc codec.Codec) AppModuleBasic { + return AppModuleBasic{cdc: cdc} +} + +// Name returns the capability module's name. +func (AppModuleBasic) Name() string { + return types.ModuleName +} + +func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + types.RegisterLegacyAminoCodec(cdc) +} + +// RegisterInterfaces registers the module's interface types +func (a AppModuleBasic) RegisterInterfaces(reg cdctypes.InterfaceRegistry) { + types.RegisterInterfaces(reg) +} + +// DefaultGenesis returns the capability module's default genesis state. +func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { + return cdc.MustMarshalJSON(types.DefaultGenesis()) +} + +// ValidateGenesis performs genesis state validation for the capability module. +func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, bz json.RawMessage) error { + var genState types.GenesisState + if err := cdc.UnmarshalJSON(bz, &genState); err != nil { + return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err) + } + return genState.Validate() +} + +// RegisterRESTRoutes registers the capability module's REST service handlers. +func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router) { +} + +// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module. +func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { + _ = types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) + // this line is used by starport scaffolding # 2 +} + +// GetTxCmd returns the capability module's root tx command. +func (a AppModuleBasic) GetTxCmd() *cobra.Command { + return cli.GetTxCmd() +} + +// GetQueryCmd returns the capability module's root query command. +func (AppModuleBasic) GetQueryCmd() *cobra.Command { + return cli.GetQueryCmd(types.StoreKey) +} + +// ---------------------------------------------------------------------------- +// AppModule +// ---------------------------------------------------------------------------- + +// AppModule implements the AppModule interface for the capability module. +type AppModule struct { + AppModuleBasic + + keeper keeper.Keeper + accountKeeper types.AccountKeeper + bankKeeper types.BankKeeper + conOps expected.ContractOpsKeeper +} + +func NewAppModule( + cdc codec.Codec, + keeper keeper.Keeper, + accountKeeper types.AccountKeeper, + bankKeeper types.BankKeeper, + conOps expected.ContractOpsKeeper, +) AppModule { + return AppModule{ + AppModuleBasic: NewAppModuleBasic(cdc), + keeper: keeper, + accountKeeper: accountKeeper, + bankKeeper: bankKeeper, + conOps: conOps, + } +} + +// Name returns the capability module's name. +func (am AppModule) Name() string { + return am.AppModuleBasic.Name() +} + +// QuerierRoute returns the capability module's query routing key. +func (AppModule) QuerierRoute() string { return types.QuerierRoute } + +// RegisterServices registers a GRPC query service to respond to the +// module-specific GRPC queries. +func (am AppModule) RegisterServices(cfg module.Configurator) { + types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) + types.RegisterQueryServer(cfg.QueryServer(), keeper.NewQueryServerImpl(am.keeper)) +} + +// RegisterInvariants registers the capability module's invariants. +func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} + +// InitGenesis performs the capability module's genesis initialization It returns +// no validator updates. +func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, gs json.RawMessage) []abci.ValidatorUpdate { + var genState types.GenesisState + // Initialize global index to index in genesis state + cdc.MustUnmarshalJSON(gs, &genState) + + InitGenesis(ctx, am.keeper, genState) + + return []abci.ValidatorUpdate{} +} + +// ExportGenesis returns the capability module's exported genesis state as raw JSON bytes. +func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { + genState := ExportGenesis(ctx, am.keeper) + return cdc.MustMarshalJSON(genState) +} + +// ConsensusVersion implements ConsensusVersion. +func (AppModule) ConsensusVersion() uint64 { return 2 } + +// BeginBlock executes all ABCI BeginBlock logic respective to the capability module. +func (am AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) { + BeginBlocker(ctx, am.keeper) +} + +// EndBlock executes all ABCI EndBlock logic respective to the capability module. It +// returns no validator updates. +func (am AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { + return []abci.ValidatorUpdate{} +} diff --git a/x/common/types/codec.go b/x/common/types/codec.go new file mode 100644 index 000000000..e8979fa0a --- /dev/null +++ b/x/common/types/codec.go @@ -0,0 +1,48 @@ +package types + +import ( + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/codec/legacy" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" + // this line is used by starport scaffolding # 1 + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/msgservice" + authzcodec "github.com/cosmos/cosmos-sdk/x/authz/codec" + govcodec "github.com/cosmos/cosmos-sdk/x/gov/codec" +) + +func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + // this line is used by starport scaffolding # 2 + cdc.RegisterConcrete(&MsgRegisterContract{}, "comdex/common/MsgRegisterContract", nil) + cdc.RegisterConcrete(&MsgDeRegisterContract{}, "comdex/common/MsgDeRegisterContract", nil) + cdc.RegisterConcrete(&Params{}, "comdex/common/Params", nil) + legacy.RegisterAminoMsg(cdc, &MsgUpdateParams{}, "comdex/common/MsgUpdateParams") + +} + +func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { + // this line is used by starport scaffolding # 3 + registry.RegisterImplementations( + (*sdk.Msg)(nil), + &MsgRegisterContract{}, + &MsgDeRegisterContract{}, + &MsgUpdateParams{}, + ) + + msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) +} + +var ( + Amino = codec.NewLegacyAmino() + ModuleCdc = codec.NewAminoCodec(Amino) + // ModuleCdc = codec.NewProtoCodec(cdctypes.NewInterfaceRegistry()) +) + +func init() { + RegisterLegacyAminoCodec(Amino) + cryptocodec.RegisterCrypto(Amino) + RegisterLegacyAminoCodec(authzcodec.Amino) + RegisterLegacyAminoCodec(govcodec.Amino) + Amino.Seal() +} diff --git a/x/common/types/common.pb.go b/x/common/types/common.pb.go new file mode 100644 index 000000000..e9ab53f59 --- /dev/null +++ b/x/common/types/common.pb.go @@ -0,0 +1,513 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: comdex/common/v1beta1/common.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + 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 WhitelistedContract struct { + GameId uint64 `protobuf:"varint,1,opt,name=game_id,json=gameId,proto3" json:"game_id,omitempty"` + SecurityAddress string `protobuf:"bytes,2,opt,name=security_address,json=securityAddress,proto3" json:"security_address,omitempty"` + ContractAdmin string `protobuf:"bytes,3,opt,name=contract_admin,json=contractAdmin,proto3" json:"contract_admin,omitempty"` + GameName string `protobuf:"bytes,4,opt,name=game_name,json=gameName,proto3" json:"game_name,omitempty"` + ContractAddress string `protobuf:"bytes,5,opt,name=contract_address,json=contractAddress,proto3" json:"contract_address,omitempty"` +} + +func (m *WhitelistedContract) Reset() { *m = WhitelistedContract{} } +func (m *WhitelistedContract) String() string { return proto.CompactTextString(m) } +func (*WhitelistedContract) ProtoMessage() {} +func (*WhitelistedContract) Descriptor() ([]byte, []int) { + return fileDescriptor_3c9dacbe026f0484, []int{0} +} +func (m *WhitelistedContract) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *WhitelistedContract) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_WhitelistedContract.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 *WhitelistedContract) XXX_Merge(src proto.Message) { + xxx_messageInfo_WhitelistedContract.Merge(m, src) +} +func (m *WhitelistedContract) XXX_Size() int { + return m.Size() +} +func (m *WhitelistedContract) XXX_DiscardUnknown() { + xxx_messageInfo_WhitelistedContract.DiscardUnknown(m) +} + +var xxx_messageInfo_WhitelistedContract proto.InternalMessageInfo + +func (m *WhitelistedContract) GetGameId() uint64 { + if m != nil { + return m.GameId + } + return 0 +} + +func (m *WhitelistedContract) GetSecurityAddress() string { + if m != nil { + return m.SecurityAddress + } + return "" +} + +func (m *WhitelistedContract) GetContractAdmin() string { + if m != nil { + return m.ContractAdmin + } + return "" +} + +func (m *WhitelistedContract) GetGameName() string { + if m != nil { + return m.GameName + } + return "" +} + +func (m *WhitelistedContract) GetContractAddress() string { + if m != nil { + return m.ContractAddress + } + return "" +} + +func init() { + proto.RegisterType((*WhitelistedContract)(nil), "comdex.common.v1beta1.WhitelistedContract") +} + +func init() { + proto.RegisterFile("comdex/common/v1beta1/common.proto", fileDescriptor_3c9dacbe026f0484) +} + +var fileDescriptor_3c9dacbe026f0484 = []byte{ + // 277 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x90, 0xcd, 0x4a, 0x03, 0x31, + 0x14, 0x85, 0x1b, 0xad, 0xd5, 0x06, 0xfc, 0x61, 0x54, 0x1c, 0x14, 0x42, 0x29, 0x08, 0x75, 0x61, + 0x63, 0xf1, 0x09, 0xaa, 0x2b, 0x5d, 0xb8, 0xe8, 0x46, 0x70, 0x33, 0x64, 0x92, 0xdb, 0x69, 0xa0, + 0x99, 0x94, 0x49, 0x2a, 0xf6, 0x2d, 0x7c, 0xac, 0x2e, 0xbb, 0x74, 0x29, 0x33, 0x2f, 0x22, 0xf9, + 0xa9, 0xba, 0xbb, 0xf7, 0xe3, 0xe3, 0x1c, 0x38, 0xb8, 0xcf, 0xb5, 0x12, 0xf0, 0x41, 0xb9, 0x56, + 0x4a, 0x97, 0xf4, 0x7d, 0x94, 0x83, 0x65, 0xa3, 0xf8, 0x0e, 0x17, 0x95, 0xb6, 0x3a, 0x39, 0x0f, + 0xce, 0x30, 0xc2, 0xe8, 0x5c, 0x9e, 0x15, 0xba, 0xd0, 0xde, 0xa0, 0xee, 0x0a, 0x72, 0x7f, 0x8d, + 0xf0, 0xe9, 0xeb, 0x4c, 0x5a, 0x98, 0x4b, 0x63, 0x41, 0x3c, 0xea, 0xd2, 0x56, 0x8c, 0xdb, 0xe4, + 0x02, 0xef, 0x17, 0x4c, 0x41, 0x26, 0x45, 0x8a, 0x7a, 0x68, 0xd0, 0x9e, 0x74, 0xdc, 0xfb, 0x24, + 0x92, 0x1b, 0x7c, 0x62, 0x80, 0x2f, 0x2b, 0x69, 0x57, 0x19, 0x13, 0xa2, 0x02, 0x63, 0xd2, 0x9d, + 0x1e, 0x1a, 0x74, 0x27, 0xc7, 0x5b, 0x3e, 0x0e, 0x38, 0xb9, 0xc6, 0x47, 0x3c, 0xe6, 0x65, 0x4c, + 0x28, 0x59, 0xa6, 0xbb, 0x5e, 0x3c, 0xdc, 0xd2, 0xb1, 0x83, 0xc9, 0x15, 0xee, 0xfa, 0xaa, 0x92, + 0x29, 0x48, 0xdb, 0xde, 0x38, 0x70, 0xe0, 0x85, 0x29, 0x70, 0x75, 0xff, 0x32, 0x42, 0xdd, 0x5e, + 0xa8, 0xfb, 0x4b, 0xf1, 0xf8, 0xe1, 0x79, 0x5d, 0x13, 0xb4, 0xa9, 0x09, 0xfa, 0xae, 0x09, 0xfa, + 0x6c, 0x48, 0x6b, 0xd3, 0x90, 0xd6, 0x57, 0x43, 0x5a, 0x6f, 0x77, 0x85, 0xb4, 0xb3, 0x65, 0xee, + 0x16, 0xa1, 0x61, 0x9c, 0x5b, 0x3d, 0x9d, 0x4a, 0x2e, 0xd9, 0x3c, 0xfe, 0xf4, 0x77, 0x52, 0xbb, + 0x5a, 0x80, 0xc9, 0x3b, 0x7e, 0x9d, 0xfb, 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x60, 0xf1, 0x39, + 0x15, 0x70, 0x01, 0x00, 0x00, +} + +func (m *WhitelistedContract) 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 *WhitelistedContract) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *WhitelistedContract) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ContractAddress) > 0 { + i -= len(m.ContractAddress) + copy(dAtA[i:], m.ContractAddress) + i = encodeVarintCommon(dAtA, i, uint64(len(m.ContractAddress))) + i-- + dAtA[i] = 0x2a + } + if len(m.GameName) > 0 { + i -= len(m.GameName) + copy(dAtA[i:], m.GameName) + i = encodeVarintCommon(dAtA, i, uint64(len(m.GameName))) + i-- + dAtA[i] = 0x22 + } + if len(m.ContractAdmin) > 0 { + i -= len(m.ContractAdmin) + copy(dAtA[i:], m.ContractAdmin) + i = encodeVarintCommon(dAtA, i, uint64(len(m.ContractAdmin))) + i-- + dAtA[i] = 0x1a + } + if len(m.SecurityAddress) > 0 { + i -= len(m.SecurityAddress) + copy(dAtA[i:], m.SecurityAddress) + i = encodeVarintCommon(dAtA, i, uint64(len(m.SecurityAddress))) + i-- + dAtA[i] = 0x12 + } + if m.GameId != 0 { + i = encodeVarintCommon(dAtA, i, uint64(m.GameId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintCommon(dAtA []byte, offset int, v uint64) int { + offset -= sovCommon(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *WhitelistedContract) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.GameId != 0 { + n += 1 + sovCommon(uint64(m.GameId)) + } + l = len(m.SecurityAddress) + if l > 0 { + n += 1 + l + sovCommon(uint64(l)) + } + l = len(m.ContractAdmin) + if l > 0 { + n += 1 + l + sovCommon(uint64(l)) + } + l = len(m.GameName) + if l > 0 { + n += 1 + l + sovCommon(uint64(l)) + } + l = len(m.ContractAddress) + if l > 0 { + n += 1 + l + sovCommon(uint64(l)) + } + return n +} + +func sovCommon(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozCommon(x uint64) (n int) { + return sovCommon(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *WhitelistedContract) 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 ErrIntOverflowCommon + } + 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: WhitelistedContract: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: WhitelistedContract: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field GameId", wireType) + } + m.GameId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCommon + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.GameId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SecurityAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCommon + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthCommon + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthCommon + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SecurityAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ContractAdmin", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCommon + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthCommon + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthCommon + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ContractAdmin = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field GameName", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCommon + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthCommon + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthCommon + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.GameName = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ContractAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCommon + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthCommon + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthCommon + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ContractAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipCommon(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthCommon + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipCommon(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, ErrIntOverflowCommon + } + 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, ErrIntOverflowCommon + } + 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, ErrIntOverflowCommon + } + 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, ErrInvalidLengthCommon + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupCommon + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthCommon + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthCommon = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowCommon = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupCommon = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/common/types/errors.go b/x/common/types/errors.go new file mode 100644 index 000000000..ff0dee22a --- /dev/null +++ b/x/common/types/errors.go @@ -0,0 +1,13 @@ +package types + +// DONTCOVER + +import ( + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +// x/common module sentinel errors +var ( + ErrSample = sdkerrors.Register(ModuleName, 1100, "sample error") + +) diff --git a/x/common/types/events.go b/x/common/types/events.go new file mode 100644 index 000000000..c928ff1c4 --- /dev/null +++ b/x/common/types/events.go @@ -0,0 +1,8 @@ +package types + +const ( + CommonModuleEventType = "common" + + EventTypeContractSudoMsg = "sudo_msg" + AttributeKeyResultDataHex = "result" +) diff --git a/x/common/types/expected_keepers.go b/x/common/types/expected_keepers.go new file mode 100644 index 000000000..04a3b5acd --- /dev/null +++ b/x/common/types/expected_keepers.go @@ -0,0 +1,20 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/auth/types" +) + + + +// AccountKeeper defines the expected account keeper used for simulations (noalias) +type AccountKeeper interface { + GetAccount(ctx sdk.Context, addr sdk.AccAddress) types.AccountI + // Methods imported from account should be defined here +} + +// BankKeeper defines the expected interface needed to retrieve account balances. +type BankKeeper interface { + SpendableCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins + // Methods imported from bank should be defined here +} \ No newline at end of file diff --git a/x/common/types/genesis.go b/x/common/types/genesis.go new file mode 100644 index 000000000..aa82115f8 --- /dev/null +++ b/x/common/types/genesis.go @@ -0,0 +1,24 @@ +package types + +import ( +// this line is used by starport scaffolding # genesis/types/import +) + +// DefaultIndex is the default capability global index +const DefaultIndex uint64 = 1 + +// DefaultGenesis returns the default Capability genesis state +func DefaultGenesis() *GenesisState { + return &GenesisState{ + // this line is used by starport scaffolding # genesis/types/default + Params: DefaultParams(), + } +} + +// Validate performs basic genesis state validation returning an error upon any +// failure. +func (gs GenesisState) Validate() error { + // this line is used by starport scaffolding # genesis/types/validate + + return gs.Params.Validate() +} diff --git a/x/common/types/genesis.pb.go b/x/common/types/genesis.pb.go new file mode 100644 index 000000000..5a93f8cd2 --- /dev/null +++ b/x/common/types/genesis.pb.go @@ -0,0 +1,390 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: comdex/common/v1beta1/genesis.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + 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 + +// GenesisState defines the common module's genesis state. +type GenesisState struct { + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` + WhitelistedContracts []*WhitelistedContract `protobuf:"bytes,2,rep,name=whitelisted_contracts,json=whitelistedContracts,proto3" json:"whitelisted_contracts,omitempty" yaml:"whitelisted_contracts"` +} + +func (m *GenesisState) Reset() { *m = GenesisState{} } +func (m *GenesisState) String() string { return proto.CompactTextString(m) } +func (*GenesisState) ProtoMessage() {} +func (*GenesisState) Descriptor() ([]byte, []int) { + return fileDescriptor_6226eee8ed557a35, []int{0} +} +func (m *GenesisState) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GenesisState.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 *GenesisState) XXX_Merge(src proto.Message) { + xxx_messageInfo_GenesisState.Merge(m, src) +} +func (m *GenesisState) XXX_Size() int { + return m.Size() +} +func (m *GenesisState) XXX_DiscardUnknown() { + xxx_messageInfo_GenesisState.DiscardUnknown(m) +} + +var xxx_messageInfo_GenesisState proto.InternalMessageInfo + +func (m *GenesisState) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +func (m *GenesisState) GetWhitelistedContracts() []*WhitelistedContract { + if m != nil { + return m.WhitelistedContracts + } + return nil +} + +func init() { + proto.RegisterType((*GenesisState)(nil), "comdex.common.v1beta1.GenesisState") +} + +func init() { + proto.RegisterFile("comdex/common/v1beta1/genesis.proto", fileDescriptor_6226eee8ed557a35) +} + +var fileDescriptor_6226eee8ed557a35 = []byte{ + // 274 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4e, 0xce, 0xcf, 0x4d, + 0x49, 0xad, 0xd0, 0x4f, 0xce, 0xcf, 0xcd, 0xcd, 0xcf, 0xd3, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, + 0x34, 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, + 0x12, 0x85, 0x28, 0xd2, 0x83, 0x28, 0xd2, 0x83, 0x2a, 0x92, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, + 0xab, 0xd0, 0x07, 0xb1, 0x20, 0x8a, 0xa5, 0x94, 0xb0, 0x9b, 0x58, 0x90, 0x58, 0x94, 0x98, 0x5b, + 0x8c, 0x5f, 0x0d, 0xd4, 0x7c, 0xb0, 0x1a, 0xa5, 0xf3, 0x8c, 0x5c, 0x3c, 0xee, 0x10, 0x67, 0x04, + 0x97, 0x24, 0x96, 0xa4, 0x0a, 0x59, 0x73, 0xb1, 0x41, 0x0c, 0x91, 0x60, 0x54, 0x60, 0xd4, 0xe0, + 0x36, 0x92, 0xd5, 0xc3, 0xea, 0x2c, 0xbd, 0x00, 0xb0, 0x22, 0x27, 0x96, 0x13, 0xf7, 0xe4, 0x19, + 0x82, 0xa0, 0x5a, 0x84, 0x1a, 0x19, 0xb9, 0x44, 0xcb, 0x33, 0x32, 0x4b, 0x52, 0x73, 0x32, 0x8b, + 0x4b, 0x52, 0x53, 0xe2, 0x93, 0xf3, 0xf3, 0x4a, 0x8a, 0x12, 0x93, 0x4b, 0x8a, 0x25, 0x98, 0x14, + 0x98, 0x35, 0xb8, 0x8d, 0xb4, 0x70, 0x18, 0x16, 0x8e, 0xd0, 0xe3, 0x0c, 0xd5, 0xe2, 0xa4, 0xf0, + 0xe9, 0x9e, 0xbc, 0x4c, 0x65, 0x62, 0x6e, 0x8e, 0x95, 0x12, 0x56, 0x23, 0x95, 0x82, 0x44, 0xca, + 0x31, 0xb5, 0x15, 0x3b, 0x79, 0x9d, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, + 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3, 0xb1, 0x1c, 0x43, 0x94, + 0x41, 0x7a, 0x66, 0x49, 0x46, 0x69, 0x12, 0xc8, 0x72, 0x7d, 0x88, 0x3b, 0x74, 0xf3, 0xd3, 0xd2, + 0x32, 0x93, 0x33, 0x13, 0x73, 0xa0, 0x7c, 0x7d, 0x78, 0x60, 0x95, 0x54, 0x16, 0xa4, 0x16, 0x27, + 0xb1, 0x81, 0x03, 0xc9, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0xdb, 0xfc, 0x50, 0xd4, 0xc0, 0x01, + 0x00, 0x00, +} + +func (m *GenesisState) 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 *GenesisState) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.WhitelistedContracts) > 0 { + for iNdEx := len(m.WhitelistedContracts) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.WhitelistedContracts[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { + offset -= sovGenesis(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *GenesisState) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovGenesis(uint64(l)) + if len(m.WhitelistedContracts) > 0 { + for _, e := range m.WhitelistedContracts { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + return n +} + +func sovGenesis(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozGenesis(x uint64) (n int) { + return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *GenesisState) 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 ErrIntOverflowGenesis + } + 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: GenesisState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field WhitelistedContracts", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.WhitelistedContracts = append(m.WhitelistedContracts, &WhitelistedContract{}) + if err := m.WhitelistedContracts[len(m.WhitelistedContracts)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipGenesis(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, ErrIntOverflowGenesis + } + 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, ErrIntOverflowGenesis + } + 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, ErrIntOverflowGenesis + } + 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, ErrInvalidLengthGenesis + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupGenesis + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthGenesis + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthGenesis = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowGenesis = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupGenesis = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/common/types/genesis_test.go b/x/common/types/genesis_test.go new file mode 100644 index 000000000..878f2fb32 --- /dev/null +++ b/x/common/types/genesis_test.go @@ -0,0 +1,40 @@ +package types_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + "github.com/comdex-official/comdex/x/common/types" +) + +func TestGenesisState_Validate(t *testing.T) { + for _, tc := range []struct { + desc string + genState *types.GenesisState + valid bool + } { + { + desc: "default is valid", + genState: types.DefaultGenesis(), + valid: true, + }, + { + desc: "valid genesis state", + genState: &types.GenesisState{ + + // this line is used by starport scaffolding # types/genesis/validField + }, + valid: true, + }, + // this line is used by starport scaffolding # types/genesis/testcase + } { + t.Run(tc.desc, func(t *testing.T) { + err := tc.genState.Validate() + if tc.valid { + require.NoError(t, err) + } else { + require.Error(t, err) + } + }) + } +} \ No newline at end of file diff --git a/x/common/types/keys.go b/x/common/types/keys.go new file mode 100644 index 000000000..28d4f9557 --- /dev/null +++ b/x/common/types/keys.go @@ -0,0 +1,36 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" +) + +const ( + // ModuleName defines the module name + ModuleName = "common" + + // StoreKey defines the primary module store key + StoreKey = ModuleName + + // RouterKey is the message route for slashing + RouterKey = ModuleName + + // QuerierRoute defines the module's query routing key + QuerierRoute = ModuleName + + // MemStoreKey defines the in-memory store key + MemStoreKey = "mem_common" +) + +var ( + SetContractKeyPrefix = []byte{0x11} + GameIDKey = []byte{0x12} + ParamsKey = []byte{0x13} +) + +func KeyPrefix(p string) []byte { + return []byte(p) +} + +func ContractKey(gameId uint64) []byte { + return append(SetContractKeyPrefix, sdk.Uint64ToBigEndian(gameId)...) +} diff --git a/x/common/types/message_de_register_contract.go b/x/common/types/message_de_register_contract.go new file mode 100644 index 000000000..bdbf78f42 --- /dev/null +++ b/x/common/types/message_de_register_contract.go @@ -0,0 +1,50 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +const TypeMsgDeRegisterContract = "de_register_contract" + +var _ sdk.Msg = &MsgDeRegisterContract{} + +func NewMsgDeRegisterContract( + securityAddress string, + gameId uint64, +) *MsgDeRegisterContract { + return &MsgDeRegisterContract{ + SecurityAddress: securityAddress, + GameId: gameId, + } +} + +func (msg *MsgDeRegisterContract) Route() string { + return RouterKey +} + +func (msg *MsgDeRegisterContract) Type() string { + return TypeMsgDeRegisterContract +} + +func (msg *MsgDeRegisterContract) GetSigners() []sdk.AccAddress { + creator, err := sdk.AccAddressFromBech32(msg.SecurityAddress) + if err != nil { + panic(err) + } + return []sdk.AccAddress{creator} +} + +func (msg *MsgDeRegisterContract) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +func (msg *MsgDeRegisterContract) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.SecurityAddress) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) + } + + return nil +} diff --git a/x/common/types/message_register_contract.go b/x/common/types/message_register_contract.go new file mode 100644 index 000000000..394b65842 --- /dev/null +++ b/x/common/types/message_register_contract.go @@ -0,0 +1,57 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +const TypeMsgRegisterContract = "register_contract" + +var _ sdk.Msg = &MsgRegisterContract{} + +func NewMsgRegisterContract( + securityAddress string, + gameName string, + contractAddress string, +) *MsgRegisterContract { + return &MsgRegisterContract{ + SecurityAddress: securityAddress, + GameName: gameName, + ContractAddress: contractAddress, + } +} + +func (msg *MsgRegisterContract) Route() string { + return RouterKey +} + +func (msg *MsgRegisterContract) Type() string { + return TypeMsgRegisterContract +} + +func (msg *MsgRegisterContract) GetSigners() []sdk.AccAddress { + creator, err := sdk.AccAddressFromBech32(msg.SecurityAddress) + if err != nil { + panic(err) + } + return []sdk.AccAddress{creator} +} + +func (msg *MsgRegisterContract) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +func (msg *MsgRegisterContract) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.SecurityAddress) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) + } + + _, err = sdk.AccAddressFromBech32(msg.ContractAddress) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid contract address (%s)", err) + } + + return nil +} diff --git a/x/common/types/message_update_params.go b/x/common/types/message_update_params.go new file mode 100644 index 000000000..9c12198b2 --- /dev/null +++ b/x/common/types/message_update_params.go @@ -0,0 +1,35 @@ +package types + +import ( + errorsmod "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +var _ sdk.Msg = &MsgUpdateParams{} + +func (msg *MsgUpdateParams) Route() string { + return RouterKey +} + +func (msg *MsgUpdateParams) Type() string { + return "update-params" +} + +func (msg *MsgUpdateParams) GetSigners() []sdk.AccAddress { + authority, err := sdk.AccAddressFromBech32(msg.Authority) + if err != nil { // should never happen as valid basic rejects invalid addresses + panic(err.Error()) + } + return []sdk.AccAddress{authority} +} + +func (msg *MsgUpdateParams) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(msg)) +} + +func (msg *MsgUpdateParams) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(msg.Authority); err != nil { + return errorsmod.Wrap(err, "authority is invalid") + } + return nil +} diff --git a/x/common/types/params.go b/x/common/types/params.go new file mode 100644 index 000000000..d2ac8996a --- /dev/null +++ b/x/common/types/params.go @@ -0,0 +1,62 @@ +package types + +import ( + errorsmod "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +func NewParams( + securityAddress []string, contractGasLimit uint64, +) Params { + return Params{ + SecurityAddress: securityAddress, + ContractGasLimit: contractGasLimit, + } +} + +// default minting module parameters +func DefaultParams() Params { + return Params{ + SecurityAddress: []string{"comdex1tadhnvwa0sqzwr3m60f7dsjw4ua77qsz3ptcyw"}, + ContractGasLimit: uint64(1000000000), + } +} + +// validate params +func (p Params) Validate() error { + minimumGas := uint64(100_000) + if p.ContractGasLimit < minimumGas { + return errorsmod.Wrapf( + sdkerrors.ErrInvalidRequest, + "invalid contract gas limit: %d. Must be above %d", p.ContractGasLimit, minimumGas, + ) + } + + for _, addr := range p.SecurityAddress { + // Valid address check + if _, err := sdk.AccAddressFromBech32(addr); err != nil { + return errorsmod.Wrapf( + sdkerrors.ErrInvalidAddress, + "invalid security address: %s", err.Error(), + ) + } + + // duplicate address check + count := 0 + for _, addr2 := range p.SecurityAddress { + if addr == addr2 { + count++ + } + + if count > 1 { + return errorsmod.Wrapf( + sdkerrors.ErrInvalidAddress, + "duplicate contract address: %s", addr, + ) + } + } + } + + return nil +} diff --git a/x/common/types/params.pb.go b/x/common/types/params.pb.go new file mode 100644 index 000000000..231e6853a --- /dev/null +++ b/x/common/types/params.pb.go @@ -0,0 +1,366 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: comdex/common/v1beta1/params.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + 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 + +// Params defines the set of module parameters. +type Params struct { + // Security address that can whitelist/delist contract + SecurityAddress []string `protobuf:"bytes,1,rep,name=security_address,json=securityAddress,proto3" json:"security_address,omitempty" yaml:"security_address"` + ContractGasLimit uint64 `protobuf:"varint,2,opt,name=contract_gas_limit,json=contractGasLimit,proto3" json:"contract_gas_limit,omitempty" yaml:"contract_gas_limit"` +} + +func (m *Params) Reset() { *m = Params{} } +func (m *Params) String() string { return proto.CompactTextString(m) } +func (*Params) ProtoMessage() {} +func (*Params) Descriptor() ([]byte, []int) { + return fileDescriptor_06465d9b92afff70, []int{0} +} +func (m *Params) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Params.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 *Params) XXX_Merge(src proto.Message) { + xxx_messageInfo_Params.Merge(m, src) +} +func (m *Params) XXX_Size() int { + return m.Size() +} +func (m *Params) XXX_DiscardUnknown() { + xxx_messageInfo_Params.DiscardUnknown(m) +} + +var xxx_messageInfo_Params proto.InternalMessageInfo + +func (m *Params) GetSecurityAddress() []string { + if m != nil { + return m.SecurityAddress + } + return nil +} + +func (m *Params) GetContractGasLimit() uint64 { + if m != nil { + return m.ContractGasLimit + } + return 0 +} + +func init() { + proto.RegisterType((*Params)(nil), "comdex.common.v1beta1.Params") +} + +func init() { + proto.RegisterFile("comdex/common/v1beta1/params.proto", fileDescriptor_06465d9b92afff70) +} + +var fileDescriptor_06465d9b92afff70 = []byte{ + // 276 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4a, 0xce, 0xcf, 0x4d, + 0x49, 0xad, 0xd0, 0x4f, 0xce, 0xcf, 0xcd, 0xcd, 0xcf, 0xd3, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, + 0x34, 0xd4, 0x2f, 0x48, 0x2c, 0x4a, 0xcc, 0x2d, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, + 0x85, 0xa8, 0xd1, 0x83, 0xa8, 0xd1, 0x83, 0xaa, 0x91, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0xab, + 0xd0, 0x07, 0xb1, 0x20, 0x8a, 0x95, 0x6e, 0x33, 0x72, 0xb1, 0x05, 0x80, 0x75, 0x0b, 0xa5, 0x70, + 0x09, 0x14, 0xa7, 0x26, 0x97, 0x16, 0x65, 0x96, 0x54, 0xc6, 0x27, 0xa6, 0xa4, 0x14, 0xa5, 0x16, + 0x17, 0x4b, 0x30, 0x2a, 0x30, 0x6b, 0x70, 0x3a, 0x59, 0xbe, 0xba, 0x27, 0x2f, 0x85, 0x2e, 0xa7, + 0x93, 0x9f, 0x9b, 0x59, 0x92, 0x9a, 0x5b, 0x50, 0x52, 0xf9, 0xe9, 0x9e, 0xbc, 0x78, 0x65, 0x62, + 0x6e, 0x8e, 0x95, 0x12, 0xba, 0x1a, 0xa5, 0x20, 0x7e, 0x98, 0x90, 0x23, 0x44, 0x44, 0x28, 0x9b, + 0x4b, 0x28, 0x39, 0x3f, 0xaf, 0xa4, 0x28, 0x31, 0xb9, 0x24, 0x3e, 0x3d, 0xb1, 0x38, 0x3e, 0x27, + 0x33, 0x37, 0xb3, 0x44, 0x82, 0x49, 0x81, 0x51, 0x83, 0xc5, 0xc9, 0xf6, 0xd5, 0x3d, 0x79, 0x19, + 0x4c, 0x59, 0x14, 0x9b, 0x24, 0x21, 0x36, 0x61, 0xaa, 0x52, 0x0a, 0x12, 0x80, 0x09, 0xba, 0x27, + 0x16, 0xfb, 0x80, 0x84, 0x9c, 0xbc, 0x4e, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, + 0x23, 0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, + 0xca, 0x20, 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x09, 0x14, 0x48, 0xfa, 0x90, 0xf0, 0xd2, 0xcd, 0x4f, + 0x4b, 0xcb, 0x4c, 0xce, 0x4c, 0xcc, 0x81, 0xf2, 0xf5, 0xe1, 0xa1, 0x5c, 0x52, 0x59, 0x90, 0x5a, + 0x9c, 0xc4, 0x06, 0x0e, 0x30, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x70, 0x67, 0x0b, 0x1e, + 0x83, 0x01, 0x00, 0x00, +} + +func (m *Params) 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 *Params) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.ContractGasLimit != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.ContractGasLimit)) + i-- + dAtA[i] = 0x10 + } + if len(m.SecurityAddress) > 0 { + for iNdEx := len(m.SecurityAddress) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.SecurityAddress[iNdEx]) + copy(dAtA[i:], m.SecurityAddress[iNdEx]) + i = encodeVarintParams(dAtA, i, uint64(len(m.SecurityAddress[iNdEx]))) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func encodeVarintParams(dAtA []byte, offset int, v uint64) int { + offset -= sovParams(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Params) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.SecurityAddress) > 0 { + for _, s := range m.SecurityAddress { + l = len(s) + n += 1 + l + sovParams(uint64(l)) + } + } + if m.ContractGasLimit != 0 { + n += 1 + sovParams(uint64(m.ContractGasLimit)) + } + return n +} + +func sovParams(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozParams(x uint64) (n int) { + return sovParams(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Params) 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 ErrIntOverflowParams + } + 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: Params: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SecurityAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SecurityAddress = append(m.SecurityAddress, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ContractGasLimit", wireType) + } + m.ContractGasLimit = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ContractGasLimit |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipParams(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthParams + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipParams(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, ErrIntOverflowParams + } + 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, ErrIntOverflowParams + } + 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, ErrIntOverflowParams + } + 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, ErrInvalidLengthParams + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupParams + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthParams + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthParams = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowParams = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupParams = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/common/types/query.pb.go b/x/common/types/query.pb.go new file mode 100644 index 000000000..405e2be12 --- /dev/null +++ b/x/common/types/query.pb.go @@ -0,0 +1,1004 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: comdex/common/v1beta1/query.proto + +package types + +import ( + context "context" + fmt "fmt" + query "github.com/cosmos/cosmos-sdk/types/query" + _ "github.com/cosmos/gogoproto/gogoproto" + 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" + 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 + +// QueryParamsRequest is request type for the Query/Params RPC method. +type QueryParamsRequest struct { +} + +func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} } +func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryParamsRequest) ProtoMessage() {} +func (*QueryParamsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_6fca43c4ee348693, []int{0} +} +func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryParamsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryParamsRequest.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 *QueryParamsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsRequest.Merge(m, src) +} +func (m *QueryParamsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryParamsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryParamsRequest proto.InternalMessageInfo + +// QueryParamsResponse is response type for the Query/Params RPC method. +type QueryParamsResponse struct { + // params holds all the parameters of this module. + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` +} + +func (m *QueryParamsResponse) Reset() { *m = QueryParamsResponse{} } +func (m *QueryParamsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryParamsResponse) ProtoMessage() {} +func (*QueryParamsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_6fca43c4ee348693, []int{1} +} +func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryParamsResponse.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 *QueryParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsResponse.Merge(m, src) +} +func (m *QueryParamsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryParamsResponse proto.InternalMessageInfo + +func (m *QueryParamsResponse) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +type QueryWhitelistedContractsRequest struct { + Pagination *query.PageRequest `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination,omitempty" yaml:"pagination"` +} + +func (m *QueryWhitelistedContractsRequest) Reset() { *m = QueryWhitelistedContractsRequest{} } +func (m *QueryWhitelistedContractsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryWhitelistedContractsRequest) ProtoMessage() {} +func (*QueryWhitelistedContractsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_6fca43c4ee348693, []int{2} +} +func (m *QueryWhitelistedContractsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryWhitelistedContractsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryWhitelistedContractsRequest.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 *QueryWhitelistedContractsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryWhitelistedContractsRequest.Merge(m, src) +} +func (m *QueryWhitelistedContractsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryWhitelistedContractsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryWhitelistedContractsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryWhitelistedContractsRequest proto.InternalMessageInfo + +func (m *QueryWhitelistedContractsRequest) GetPagination() *query.PageRequest { + if m != nil { + return m.Pagination + } + return nil +} + +type QueryWhitelistedContractsResponse struct { + WhilistedContracts []WhitelistedContract `protobuf:"bytes,1,rep,name=whilisted_contracts,json=whilistedContracts,proto3" json:"whilisted_contracts"` + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty" yaml:"pagination"` +} + +func (m *QueryWhitelistedContractsResponse) Reset() { *m = QueryWhitelistedContractsResponse{} } +func (m *QueryWhitelistedContractsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryWhitelistedContractsResponse) ProtoMessage() {} +func (*QueryWhitelistedContractsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_6fca43c4ee348693, []int{3} +} +func (m *QueryWhitelistedContractsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryWhitelistedContractsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryWhitelistedContractsResponse.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 *QueryWhitelistedContractsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryWhitelistedContractsResponse.Merge(m, src) +} +func (m *QueryWhitelistedContractsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryWhitelistedContractsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryWhitelistedContractsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryWhitelistedContractsResponse proto.InternalMessageInfo + +func (m *QueryWhitelistedContractsResponse) GetWhilistedContracts() []WhitelistedContract { + if m != nil { + return m.WhilistedContracts + } + return nil +} + +func (m *QueryWhitelistedContractsResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination + } + return nil +} + +func init() { + proto.RegisterType((*QueryParamsRequest)(nil), "comdex.common.v1beta1.QueryParamsRequest") + proto.RegisterType((*QueryParamsResponse)(nil), "comdex.common.v1beta1.QueryParamsResponse") + proto.RegisterType((*QueryWhitelistedContractsRequest)(nil), "comdex.common.v1beta1.QueryWhitelistedContractsRequest") + proto.RegisterType((*QueryWhitelistedContractsResponse)(nil), "comdex.common.v1beta1.QueryWhitelistedContractsResponse") +} + +func init() { proto.RegisterFile("comdex/common/v1beta1/query.proto", fileDescriptor_6fca43c4ee348693) } + +var fileDescriptor_6fca43c4ee348693 = []byte{ + // 468 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x53, 0x3f, 0x6f, 0xd3, 0x40, + 0x14, 0xcf, 0x05, 0xc8, 0x70, 0x9d, 0xb8, 0xb6, 0x52, 0x89, 0xa8, 0x93, 0x9e, 0x04, 0x94, 0x08, + 0xee, 0x68, 0x40, 0x02, 0xc1, 0x16, 0x36, 0x26, 0xc8, 0x82, 0x84, 0x04, 0xe8, 0xe2, 0x5e, 0x9d, + 0x93, 0x62, 0x3f, 0xd7, 0x77, 0xa1, 0x64, 0x84, 0x81, 0x19, 0x89, 0xaf, 0xc4, 0xd0, 0xb1, 0x12, + 0x03, 0x4c, 0x15, 0x4a, 0x10, 0x1f, 0x80, 0x4f, 0x80, 0x7c, 0x77, 0xb1, 0xa9, 0x88, 0x4d, 0xd9, + 0x2c, 0xbf, 0xdf, 0xdf, 0xe7, 0x67, 0xbc, 0x13, 0x42, 0xbc, 0x2f, 0xdf, 0xf2, 0x10, 0xe2, 0x18, + 0x12, 0xfe, 0x66, 0x6f, 0x24, 0x8d, 0xd8, 0xe3, 0x87, 0x53, 0x99, 0xcd, 0x58, 0x9a, 0x81, 0x01, + 0xb2, 0xe9, 0x20, 0xcc, 0x41, 0x98, 0x87, 0xb4, 0x37, 0x22, 0x88, 0xc0, 0x22, 0x78, 0xfe, 0xe4, + 0xc0, 0xed, 0xab, 0x11, 0x40, 0x34, 0x91, 0x5c, 0xa4, 0x8a, 0x8b, 0x24, 0x01, 0x23, 0x8c, 0x82, + 0x44, 0xfb, 0x69, 0x2f, 0x04, 0x1d, 0x83, 0xe6, 0x23, 0xa1, 0xa5, 0xf3, 0x28, 0x1c, 0x53, 0x11, + 0xa9, 0xc4, 0x82, 0x3d, 0x96, 0xae, 0x4e, 0x96, 0x8a, 0x4c, 0xc4, 0xba, 0x1e, 0xe3, 0x93, 0x5a, + 0x0c, 0xdd, 0xc0, 0xe4, 0x59, 0xee, 0xf4, 0xd4, 0x12, 0x87, 0xf2, 0x70, 0x2a, 0xb5, 0xa1, 0x43, + 0xbc, 0x7e, 0xe6, 0xad, 0x4e, 0x21, 0xd1, 0x92, 0x3c, 0xc2, 0x2d, 0x67, 0xb0, 0x85, 0xba, 0x68, + 0x77, 0xad, 0xbf, 0xcd, 0x56, 0x96, 0x67, 0x8e, 0x36, 0xb8, 0x78, 0x7c, 0xda, 0x69, 0x0c, 0x3d, + 0x85, 0xbe, 0x43, 0xb8, 0x6b, 0x45, 0x9f, 0x8f, 0x95, 0x91, 0x13, 0xa5, 0x8d, 0xdc, 0x7f, 0x0c, + 0x89, 0xc9, 0x44, 0x68, 0x96, 0xc6, 0xe4, 0x25, 0xc6, 0x65, 0x55, 0xef, 0x72, 0x9d, 0xb9, 0xbd, + 0xb0, 0x7c, 0x2f, 0xcc, 0xed, 0xbe, 0x74, 0x8a, 0xa4, 0xe7, 0x0e, 0x36, 0x7f, 0x9d, 0x76, 0x2e, + 0xcf, 0x44, 0x3c, 0x79, 0x48, 0x4b, 0x0d, 0x3a, 0xfc, 0x43, 0x90, 0xfe, 0x44, 0x78, 0xa7, 0x26, + 0x83, 0xaf, 0x29, 0xf0, 0xfa, 0xd1, 0x58, 0xb9, 0xe9, 0xeb, 0x70, 0x39, 0xde, 0x42, 0xdd, 0x0b, + 0xbb, 0x6b, 0xfd, 0x5e, 0x45, 0xe7, 0x15, 0x8a, 0x7e, 0x01, 0xa4, 0x10, 0x2b, 0xac, 0xc8, 0xab, + 0x33, 0x3d, 0x9b, 0xb6, 0xe7, 0x8d, 0x7f, 0xf6, 0x74, 0xf9, 0xce, 0x51, 0xb4, 0xff, 0xb5, 0x89, + 0x2f, 0xd9, 0xa2, 0xe4, 0x03, 0xc2, 0x2d, 0xf7, 0x3d, 0xc8, 0xcd, 0x8a, 0xe8, 0x7f, 0x1f, 0x40, + 0xbb, 0x77, 0x1e, 0xa8, 0x8b, 0x43, 0xaf, 0xbd, 0xff, 0xf2, 0xe3, 0x53, 0xb3, 0x43, 0xb6, 0x79, + 0xdd, 0x4d, 0x92, 0xcf, 0x08, 0x5f, 0xa9, 0xdc, 0x3d, 0xb9, 0x5f, 0x67, 0x58, 0x73, 0x31, 0xed, + 0x07, 0xff, 0x4f, 0xf4, 0xb9, 0xef, 0xd9, 0xdc, 0x8c, 0xdc, 0xaa, 0xc8, 0x7d, 0x54, 0x92, 0xcb, + 0x2b, 0x18, 0x3c, 0x39, 0x9e, 0x07, 0xe8, 0x64, 0x1e, 0xa0, 0xef, 0xf3, 0x00, 0x7d, 0x5c, 0x04, + 0x8d, 0x93, 0x45, 0xd0, 0xf8, 0xb6, 0x08, 0x1a, 0x2f, 0xee, 0x44, 0xca, 0x8c, 0xa7, 0xa3, 0x3c, + 0x88, 0x57, 0xbc, 0x0d, 0x07, 0x07, 0x2a, 0x54, 0x62, 0xb2, 0x74, 0x28, 0x3c, 0xcc, 0x2c, 0x95, + 0x7a, 0xd4, 0xb2, 0xff, 0xe0, 0xdd, 0xdf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x94, 0x2e, 0x9c, 0xb4, + 0x67, 0x04, 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 { + // Parameters queries the parameters of the module. + Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) + QueryWhitelistedContracts(ctx context.Context, in *QueryWhitelistedContractsRequest, opts ...grpc.CallOption) (*QueryWhitelistedContractsResponse, error) +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) { + out := new(QueryParamsResponse) + err := c.cc.Invoke(ctx, "/comdex.common.v1beta1.Query/Params", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) QueryWhitelistedContracts(ctx context.Context, in *QueryWhitelistedContractsRequest, opts ...grpc.CallOption) (*QueryWhitelistedContractsResponse, error) { + out := new(QueryWhitelistedContractsResponse) + err := c.cc.Invoke(ctx, "/comdex.common.v1beta1.Query/QueryWhitelistedContracts", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +type QueryServer interface { + // Parameters queries the parameters of the module. + Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) + QueryWhitelistedContracts(context.Context, *QueryWhitelistedContractsRequest) (*QueryWhitelistedContractsResponse, error) +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") +} +func (*UnimplementedQueryServer) QueryWhitelistedContracts(ctx context.Context, req *QueryWhitelistedContractsRequest) (*QueryWhitelistedContractsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method QueryWhitelistedContracts not implemented") +} + +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) +} + +func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryParamsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Params(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/comdex.common.v1beta1.Query/Params", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_QueryWhitelistedContracts_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryWhitelistedContractsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).QueryWhitelistedContracts(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/comdex.common.v1beta1.Query/QueryWhitelistedContracts", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).QueryWhitelistedContracts(ctx, req.(*QueryWhitelistedContractsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "comdex.common.v1beta1.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Params", + Handler: _Query_Params_Handler, + }, + { + MethodName: "QueryWhitelistedContracts", + Handler: _Query_QueryWhitelistedContracts_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "comdex/common/v1beta1/query.proto", +} + +func (m *QueryParamsRequest) 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 *QueryParamsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryParamsResponse) 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 *QueryParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *QueryWhitelistedContractsRequest) 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 *QueryWhitelistedContractsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryWhitelistedContractsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryWhitelistedContractsResponse) 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 *QueryWhitelistedContractsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryWhitelistedContractsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.WhilistedContracts) > 0 { + for iNdEx := len(m.WhilistedContracts) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.WhilistedContracts[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { + offset -= sovQuery(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *QueryParamsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryWhitelistedContractsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryWhitelistedContractsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.WhilistedContracts) > 0 { + for _, e := range m.WhilistedContracts { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func sovQuery(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QueryParamsRequest) 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 ErrIntOverflowQuery + } + 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: QueryParamsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryParamsResponse) 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 ErrIntOverflowQuery + } + 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: QueryParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryWhitelistedContractsRequest) 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 ErrIntOverflowQuery + } + 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: QueryWhitelistedContractsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryWhitelistedContractsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryWhitelistedContractsResponse) 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 ErrIntOverflowQuery + } + 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: QueryWhitelistedContractsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryWhitelistedContractsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field WhilistedContracts", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.WhilistedContracts = append(m.WhilistedContracts, WhitelistedContract{}) + if err := m.WhilistedContracts[len(m.WhilistedContracts)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipQuery(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, ErrIntOverflowQuery + } + 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, ErrIntOverflowQuery + } + 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, ErrIntOverflowQuery + } + 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, ErrInvalidLengthQuery + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupQuery + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthQuery + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthQuery = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowQuery = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/common/types/query.pb.gw.go b/x/common/types/query.pb.gw.go new file mode 100644 index 000000000..11b1e4ad8 --- /dev/null +++ b/x/common/types/query.pb.gw.go @@ -0,0 +1,236 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: comdex/common/v1beta1/query.proto + +/* +Package types is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package types + +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 + +func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsRequest + var metadata runtime.ServerMetadata + + msg, err := client.Params(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsRequest + var metadata runtime.ServerMetadata + + msg, err := server.Params(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_QueryWhitelistedContracts_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Query_QueryWhitelistedContracts_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryWhitelistedContractsRequest + 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_QueryWhitelistedContracts_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.QueryWhitelistedContracts(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_QueryWhitelistedContracts_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryWhitelistedContractsRequest + 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_QueryWhitelistedContracts_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.QueryWhitelistedContracts(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_Params_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_Params_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_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_QueryWhitelistedContracts_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_QueryWhitelistedContracts_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_QueryWhitelistedContracts_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_Params_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_Params_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_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_QueryWhitelistedContracts_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_QueryWhitelistedContracts_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_QueryWhitelistedContracts_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"comdex", "common", "v1beta1", "params"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_QueryWhitelistedContracts_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"comdex", "common", "v1beta1", "whitelisted_contracts"}, "", runtime.AssumeColonVerbOpt(false))) +) + +var ( + forward_Query_Params_0 = runtime.ForwardResponseMessage + + forward_Query_QueryWhitelistedContracts_0 = runtime.ForwardResponseMessage +) diff --git a/x/common/types/tx.pb.go b/x/common/types/tx.pb.go new file mode 100644 index 000000000..7882f0cf5 --- /dev/null +++ b/x/common/types/tx.pb.go @@ -0,0 +1,1392 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: comdex/common/v1beta1/tx.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + _ "github.com/cosmos/cosmos-sdk/types/msgservice" + _ "github.com/cosmos/gogoproto/gogoproto" + 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" + 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 MsgRegisterContract struct { + SecurityAddress string `protobuf:"bytes,1,opt,name=security_address,json=securityAddress,proto3" json:"security_address,omitempty"` + GameName string `protobuf:"bytes,2,opt,name=game_name,json=gameName,proto3" json:"game_name,omitempty"` + ContractAddress string `protobuf:"bytes,3,opt,name=contract_address,json=contractAddress,proto3" json:"contract_address,omitempty"` +} + +func (m *MsgRegisterContract) Reset() { *m = MsgRegisterContract{} } +func (m *MsgRegisterContract) String() string { return proto.CompactTextString(m) } +func (*MsgRegisterContract) ProtoMessage() {} +func (*MsgRegisterContract) Descriptor() ([]byte, []int) { + return fileDescriptor_63826287044af113, []int{0} +} +func (m *MsgRegisterContract) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRegisterContract) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRegisterContract.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 *MsgRegisterContract) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRegisterContract.Merge(m, src) +} +func (m *MsgRegisterContract) XXX_Size() int { + return m.Size() +} +func (m *MsgRegisterContract) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRegisterContract.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRegisterContract proto.InternalMessageInfo + +func (m *MsgRegisterContract) GetSecurityAddress() string { + if m != nil { + return m.SecurityAddress + } + return "" +} + +func (m *MsgRegisterContract) GetGameName() string { + if m != nil { + return m.GameName + } + return "" +} + +func (m *MsgRegisterContract) GetContractAddress() string { + if m != nil { + return m.ContractAddress + } + return "" +} + +type MsgRegisterContractResponse struct { +} + +func (m *MsgRegisterContractResponse) Reset() { *m = MsgRegisterContractResponse{} } +func (m *MsgRegisterContractResponse) String() string { return proto.CompactTextString(m) } +func (*MsgRegisterContractResponse) ProtoMessage() {} +func (*MsgRegisterContractResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_63826287044af113, []int{1} +} +func (m *MsgRegisterContractResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRegisterContractResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRegisterContractResponse.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 *MsgRegisterContractResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRegisterContractResponse.Merge(m, src) +} +func (m *MsgRegisterContractResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgRegisterContractResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRegisterContractResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRegisterContractResponse proto.InternalMessageInfo + +type MsgDeRegisterContract struct { + SecurityAddress string `protobuf:"bytes,1,opt,name=security_address,json=securityAddress,proto3" json:"security_address,omitempty"` + GameId uint64 `protobuf:"varint,2,opt,name=game_id,json=gameId,proto3" json:"game_id,omitempty"` +} + +func (m *MsgDeRegisterContract) Reset() { *m = MsgDeRegisterContract{} } +func (m *MsgDeRegisterContract) String() string { return proto.CompactTextString(m) } +func (*MsgDeRegisterContract) ProtoMessage() {} +func (*MsgDeRegisterContract) Descriptor() ([]byte, []int) { + return fileDescriptor_63826287044af113, []int{2} +} +func (m *MsgDeRegisterContract) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgDeRegisterContract) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgDeRegisterContract.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 *MsgDeRegisterContract) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgDeRegisterContract.Merge(m, src) +} +func (m *MsgDeRegisterContract) XXX_Size() int { + return m.Size() +} +func (m *MsgDeRegisterContract) XXX_DiscardUnknown() { + xxx_messageInfo_MsgDeRegisterContract.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgDeRegisterContract proto.InternalMessageInfo + +func (m *MsgDeRegisterContract) GetSecurityAddress() string { + if m != nil { + return m.SecurityAddress + } + return "" +} + +func (m *MsgDeRegisterContract) GetGameId() uint64 { + if m != nil { + return m.GameId + } + return 0 +} + +type MsgDeRegisterContractResponse struct { +} + +func (m *MsgDeRegisterContractResponse) Reset() { *m = MsgDeRegisterContractResponse{} } +func (m *MsgDeRegisterContractResponse) String() string { return proto.CompactTextString(m) } +func (*MsgDeRegisterContractResponse) ProtoMessage() {} +func (*MsgDeRegisterContractResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_63826287044af113, []int{3} +} +func (m *MsgDeRegisterContractResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgDeRegisterContractResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgDeRegisterContractResponse.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 *MsgDeRegisterContractResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgDeRegisterContractResponse.Merge(m, src) +} +func (m *MsgDeRegisterContractResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgDeRegisterContractResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgDeRegisterContractResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgDeRegisterContractResponse proto.InternalMessageInfo + +// MsgUpdateParams is the MsgUpdateParams request type. +// +// Since: 0.47 +type MsgUpdateParams struct { + // authority is the address that controls the module (defaults to x/gov unless overwritten). + Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` + // params defines the x/auth parameters to update. + // + // NOTE: All parameters must be supplied. + Params Params `protobuf:"bytes,2,opt,name=params,proto3" json:"params"` +} + +func (m *MsgUpdateParams) Reset() { *m = MsgUpdateParams{} } +func (m *MsgUpdateParams) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateParams) ProtoMessage() {} +func (*MsgUpdateParams) Descriptor() ([]byte, []int) { + return fileDescriptor_63826287044af113, []int{4} +} +func (m *MsgUpdateParams) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateParams.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 *MsgUpdateParams) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateParams.Merge(m, src) +} +func (m *MsgUpdateParams) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateParams) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateParams.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateParams proto.InternalMessageInfo + +func (m *MsgUpdateParams) GetAuthority() string { + if m != nil { + return m.Authority + } + return "" +} + +func (m *MsgUpdateParams) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +// MsgUpdateParamsResponse defines the response structure for executing a +// MsgUpdateParams message. +// +// Since: 0.47 +type MsgUpdateParamsResponse struct { +} + +func (m *MsgUpdateParamsResponse) Reset() { *m = MsgUpdateParamsResponse{} } +func (m *MsgUpdateParamsResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateParamsResponse) ProtoMessage() {} +func (*MsgUpdateParamsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_63826287044af113, []int{5} +} +func (m *MsgUpdateParamsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateParamsResponse.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 *MsgUpdateParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateParamsResponse.Merge(m, src) +} +func (m *MsgUpdateParamsResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateParamsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateParamsResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*MsgRegisterContract)(nil), "comdex.common.v1beta1.MsgRegisterContract") + proto.RegisterType((*MsgRegisterContractResponse)(nil), "comdex.common.v1beta1.MsgRegisterContractResponse") + proto.RegisterType((*MsgDeRegisterContract)(nil), "comdex.common.v1beta1.MsgDeRegisterContract") + proto.RegisterType((*MsgDeRegisterContractResponse)(nil), "comdex.common.v1beta1.MsgDeRegisterContractResponse") + proto.RegisterType((*MsgUpdateParams)(nil), "comdex.common.v1beta1.MsgUpdateParams") + proto.RegisterType((*MsgUpdateParamsResponse)(nil), "comdex.common.v1beta1.MsgUpdateParamsResponse") +} + +func init() { proto.RegisterFile("comdex/common/v1beta1/tx.proto", fileDescriptor_63826287044af113) } + +var fileDescriptor_63826287044af113 = []byte{ + // 480 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x93, 0x31, 0x6f, 0xd3, 0x40, + 0x14, 0xc7, 0xe3, 0xb6, 0x0a, 0xe4, 0x81, 0x68, 0x75, 0xb4, 0x4a, 0xea, 0x2a, 0x2e, 0xf2, 0x80, + 0xa0, 0xa2, 0x3e, 0x12, 0x10, 0x03, 0x4c, 0x04, 0x16, 0x90, 0x82, 0x90, 0x11, 0x0b, 0x0c, 0xd1, + 0xc5, 0xbe, 0x5c, 0x2d, 0x71, 0x3e, 0xeb, 0xee, 0x52, 0xa5, 0x2b, 0x13, 0x23, 0x13, 0x9f, 0x83, + 0x81, 0x0f, 0xd1, 0xb1, 0x62, 0x42, 0x42, 0x42, 0x28, 0x19, 0xf8, 0x1a, 0xc8, 0xbe, 0xb3, 0x0b, + 0xd4, 0x91, 0x8a, 0x3a, 0x25, 0xef, 0xbd, 0xff, 0xfd, 0xfe, 0x7f, 0xdd, 0xf3, 0x81, 0x17, 0x09, + 0x1e, 0xd3, 0x19, 0x8e, 0x04, 0xe7, 0x22, 0xc5, 0x87, 0xbd, 0x31, 0xd5, 0xa4, 0x87, 0xf5, 0x2c, + 0xc8, 0xa4, 0xd0, 0x02, 0x6d, 0x99, 0x79, 0x60, 0xe6, 0x81, 0x9d, 0xbb, 0x9b, 0x4c, 0x30, 0x51, + 0x28, 0x70, 0xfe, 0xcf, 0x88, 0xdd, 0x76, 0x24, 0x14, 0x17, 0x0a, 0x73, 0xc5, 0xf0, 0x61, 0x2f, + 0xff, 0xb1, 0x83, 0x6d, 0x33, 0x18, 0x99, 0x13, 0xa6, 0xb0, 0x23, 0xbf, 0x3e, 0x40, 0x46, 0x24, + 0xe1, 0x56, 0xe3, 0x7f, 0x70, 0xe0, 0xfa, 0x50, 0xb1, 0x90, 0xb2, 0x44, 0x69, 0x2a, 0x9f, 0x88, + 0x54, 0x4b, 0x12, 0x69, 0x74, 0x1b, 0x36, 0x14, 0x8d, 0xa6, 0x32, 0xd1, 0x47, 0x23, 0x12, 0xc7, + 0x92, 0x2a, 0xd5, 0x71, 0x6e, 0x38, 0xb7, 0x5a, 0xe1, 0x7a, 0xd9, 0x7f, 0x6c, 0xda, 0x68, 0x07, + 0x5a, 0x8c, 0x70, 0x3a, 0x4a, 0x09, 0xa7, 0x9d, 0x95, 0x42, 0x73, 0x39, 0x6f, 0xbc, 0x20, 0x9c, + 0xe6, 0x9c, 0xc8, 0x32, 0x2b, 0xce, 0xaa, 0xe1, 0x94, 0x7d, 0xcb, 0xf1, 0xbb, 0xb0, 0x53, 0x93, + 0x24, 0xa4, 0x2a, 0x13, 0xa9, 0xa2, 0xfe, 0x5b, 0xd8, 0x1a, 0x2a, 0xf6, 0x94, 0x5e, 0x24, 0x6a, + 0x1b, 0x2e, 0x15, 0x51, 0x93, 0xb8, 0x08, 0xba, 0x16, 0x36, 0xf3, 0xf2, 0x59, 0xec, 0xef, 0x42, + 0xb7, 0x16, 0x5e, 0xb9, 0x7f, 0x72, 0x60, 0x7d, 0xa8, 0xd8, 0xeb, 0x2c, 0x26, 0x9a, 0xbe, 0x2c, + 0x6e, 0x10, 0x3d, 0x80, 0x16, 0x99, 0xea, 0x03, 0x91, 0x3b, 0x18, 0xc7, 0x41, 0xe7, 0xeb, 0x97, + 0xfd, 0x4d, 0xbb, 0x04, 0x6b, 0xfa, 0x4a, 0xcb, 0x24, 0x65, 0xe1, 0xa9, 0x14, 0x3d, 0x82, 0xa6, + 0xd9, 0x41, 0x11, 0xe2, 0x4a, 0xbf, 0x1b, 0xd4, 0x7e, 0x09, 0x81, 0xb1, 0x19, 0xac, 0x1d, 0xff, + 0xd8, 0x6d, 0x84, 0xf6, 0xc8, 0xc3, 0x6b, 0xef, 0x7f, 0x7d, 0xde, 0x3b, 0x85, 0xf9, 0xdb, 0xd0, + 0xfe, 0x27, 0x57, 0x99, 0xb9, 0xff, 0x7d, 0x05, 0x56, 0x87, 0x8a, 0x21, 0x09, 0x1b, 0x67, 0x2e, + 0x6d, 0x6f, 0x89, 0x67, 0xcd, 0x06, 0xdc, 0xfe, 0xf9, 0xb5, 0xa5, 0x37, 0x9a, 0x01, 0xaa, 0x59, + 0xd5, 0x9d, 0xe5, 0xa4, 0xb3, 0x6a, 0xf7, 0xfe, 0xff, 0xa8, 0x2b, 0xe7, 0x09, 0x5c, 0xfd, 0x6b, + 0x4b, 0x37, 0x97, 0x53, 0xfe, 0xd4, 0xb9, 0xc1, 0xf9, 0x74, 0xa5, 0xcf, 0xe0, 0xf9, 0xf1, 0xdc, + 0x73, 0x4e, 0xe6, 0x9e, 0xf3, 0x73, 0xee, 0x39, 0x1f, 0x17, 0x5e, 0xe3, 0x64, 0xe1, 0x35, 0xbe, + 0x2d, 0xbc, 0xc6, 0x9b, 0xbb, 0x2c, 0xd1, 0x07, 0xd3, 0x71, 0x0e, 0xc2, 0x86, 0xb9, 0x2f, 0x26, + 0x93, 0x24, 0x4a, 0xc8, 0x3b, 0x5b, 0xe3, 0xea, 0x51, 0xea, 0xa3, 0x8c, 0xaa, 0x71, 0xb3, 0x78, + 0x8c, 0xf7, 0x7e, 0x07, 0x00, 0x00, 0xff, 0xff, 0x9a, 0xaf, 0x79, 0xaf, 0x33, 0x04, 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 + +// MsgClient is the client API for Msg service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type MsgClient interface { + RegisterContract(ctx context.Context, in *MsgRegisterContract, opts ...grpc.CallOption) (*MsgRegisterContractResponse, error) + DeRegisterContract(ctx context.Context, in *MsgDeRegisterContract, opts ...grpc.CallOption) (*MsgDeRegisterContractResponse, error) + UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) +} + +type msgClient struct { + cc grpc1.ClientConn +} + +func NewMsgClient(cc grpc1.ClientConn) MsgClient { + return &msgClient{cc} +} + +func (c *msgClient) RegisterContract(ctx context.Context, in *MsgRegisterContract, opts ...grpc.CallOption) (*MsgRegisterContractResponse, error) { + out := new(MsgRegisterContractResponse) + err := c.cc.Invoke(ctx, "/comdex.common.v1beta1.Msg/RegisterContract", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) DeRegisterContract(ctx context.Context, in *MsgDeRegisterContract, opts ...grpc.CallOption) (*MsgDeRegisterContractResponse, error) { + out := new(MsgDeRegisterContractResponse) + err := c.cc.Invoke(ctx, "/comdex.common.v1beta1.Msg/DeRegisterContract", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) { + out := new(MsgUpdateParamsResponse) + err := c.cc.Invoke(ctx, "/comdex.common.v1beta1.Msg/UpdateParams", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// MsgServer is the server API for Msg service. +type MsgServer interface { + RegisterContract(context.Context, *MsgRegisterContract) (*MsgRegisterContractResponse, error) + DeRegisterContract(context.Context, *MsgDeRegisterContract) (*MsgDeRegisterContractResponse, error) + UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error) +} + +// UnimplementedMsgServer can be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { +} + +func (*UnimplementedMsgServer) RegisterContract(ctx context.Context, req *MsgRegisterContract) (*MsgRegisterContractResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RegisterContract not implemented") +} +func (*UnimplementedMsgServer) DeRegisterContract(ctx context.Context, req *MsgDeRegisterContract) (*MsgDeRegisterContractResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method DeRegisterContract not implemented") +} +func (*UnimplementedMsgServer) UpdateParams(ctx context.Context, req *MsgUpdateParams) (*MsgUpdateParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateParams not implemented") +} + +func RegisterMsgServer(s grpc1.Server, srv MsgServer) { + s.RegisterService(&_Msg_serviceDesc, srv) +} + +func _Msg_RegisterContract_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgRegisterContract) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).RegisterContract(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/comdex.common.v1beta1.Msg/RegisterContract", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).RegisterContract(ctx, req.(*MsgRegisterContract)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_DeRegisterContract_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgDeRegisterContract) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).DeRegisterContract(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/comdex.common.v1beta1.Msg/DeRegisterContract", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).DeRegisterContract(ctx, req.(*MsgDeRegisterContract)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_UpdateParams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpdateParams) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).UpdateParams(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/comdex.common.v1beta1.Msg/UpdateParams", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UpdateParams(ctx, req.(*MsgUpdateParams)) + } + return interceptor(ctx, in, info, handler) +} + +var _Msg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "comdex.common.v1beta1.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "RegisterContract", + Handler: _Msg_RegisterContract_Handler, + }, + { + MethodName: "DeRegisterContract", + Handler: _Msg_DeRegisterContract_Handler, + }, + { + MethodName: "UpdateParams", + Handler: _Msg_UpdateParams_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "comdex/common/v1beta1/tx.proto", +} + +func (m *MsgRegisterContract) 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 *MsgRegisterContract) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgRegisterContract) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ContractAddress) > 0 { + i -= len(m.ContractAddress) + copy(dAtA[i:], m.ContractAddress) + i = encodeVarintTx(dAtA, i, uint64(len(m.ContractAddress))) + i-- + dAtA[i] = 0x1a + } + if len(m.GameName) > 0 { + i -= len(m.GameName) + copy(dAtA[i:], m.GameName) + i = encodeVarintTx(dAtA, i, uint64(len(m.GameName))) + i-- + dAtA[i] = 0x12 + } + if len(m.SecurityAddress) > 0 { + i -= len(m.SecurityAddress) + copy(dAtA[i:], m.SecurityAddress) + i = encodeVarintTx(dAtA, i, uint64(len(m.SecurityAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgRegisterContractResponse) 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 *MsgRegisterContractResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgRegisterContractResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgDeRegisterContract) 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 *MsgDeRegisterContract) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgDeRegisterContract) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.GameId != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.GameId)) + i-- + dAtA[i] = 0x10 + } + if len(m.SecurityAddress) > 0 { + i -= len(m.SecurityAddress) + copy(dAtA[i:], m.SecurityAddress) + i = encodeVarintTx(dAtA, i, uint64(len(m.SecurityAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgDeRegisterContractResponse) 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 *MsgDeRegisterContractResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgDeRegisterContractResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgUpdateParams) 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 *MsgUpdateParams) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.Authority) > 0 { + i -= len(m.Authority) + copy(dAtA[i:], m.Authority) + i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgUpdateParamsResponse) 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 *MsgUpdateParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func encodeVarintTx(dAtA []byte, offset int, v uint64) int { + offset -= sovTx(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *MsgRegisterContract) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.SecurityAddress) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.GameName) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.ContractAddress) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgRegisterContractResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgDeRegisterContract) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.SecurityAddress) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.GameId != 0 { + n += 1 + sovTx(uint64(m.GameId)) + } + return n +} + +func (m *MsgDeRegisterContractResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgUpdateParams) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Authority) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.Params.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + +func (m *MsgUpdateParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func sovTx(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozTx(x uint64) (n int) { + return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *MsgRegisterContract) 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 ErrIntOverflowTx + } + 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: MsgRegisterContract: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRegisterContract: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SecurityAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SecurityAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field GameName", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.GameName = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ContractAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ContractAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgRegisterContractResponse) 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 ErrIntOverflowTx + } + 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: MsgRegisterContractResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRegisterContractResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgDeRegisterContract) 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 ErrIntOverflowTx + } + 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: MsgDeRegisterContract: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgDeRegisterContract: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SecurityAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SecurityAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field GameId", wireType) + } + m.GameId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.GameId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgDeRegisterContractResponse) 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 ErrIntOverflowTx + } + 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: MsgDeRegisterContractResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgDeRegisterContractResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUpdateParams) 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 ErrIntOverflowTx + } + 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: MsgUpdateParams: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateParams: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Authority", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Authority = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUpdateParamsResponse) 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 ErrIntOverflowTx + } + 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: MsgUpdateParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipTx(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, ErrIntOverflowTx + } + 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, ErrIntOverflowTx + } + 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, ErrIntOverflowTx + } + 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, ErrInvalidLengthTx + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupTx + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthTx + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthTx = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowTx = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupTx = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/common/types/types.go b/x/common/types/types.go new file mode 100644 index 000000000..ab1254f4c --- /dev/null +++ b/x/common/types/types.go @@ -0,0 +1 @@ +package types