From 5810f9cf209c322e6d1109c1548f94b2c420a6a6 Mon Sep 17 00:00:00 2001 From: yihuang Date: Tue, 5 Jul 2022 11:44:29 +0800 Subject: [PATCH] Problem: interchain-accounts module is not integrated (#541) * Problem: interchain-accounts module is not integrated Closes: #540 Solution: - integrate ica controller module add ica integration tests regen proto temp cleanup fix integration test Update integration_tests/test_ibc.py cleanup icaauth -> icactl gen proto fix integration test fix conflicts add v0.8.0 upgrade test and comment use flake-compat to build v0.7.0 binary for upgrade test fix integration test use flake-compat to build v0.7.0 binary for upgrade test fix integration test fix rebase fix key_name * update swagger ui --- app/app.go | 104 +- integration_tests/test_ibc.py | 89 ++ nix/chainmain.nix | 3 + proto/icactl/v1/genesis.proto | 13 + proto/icactl/v1/params.proto | 20 + proto/icactl/v1/query.proto | 47 + proto/icactl/v1/tx.proto | 55 + x/icactl/client/cli/flags.go | 5 + x/icactl/client/cli/query.go | 26 + .../cli/query_interchain_account_address.go | 47 + x/icactl/client/cli/query_params.go | 34 + x/icactl/client/cli/tx.go | 25 + x/icactl/client/cli/tx_register_account.go | 42 + x/icactl/client/cli/tx_submit_tx.go | 68 + x/icactl/genesis.go | 21 + x/icactl/handler.go | 31 + x/icactl/keeper/grpc_query.go | 7 + .../grpc_query_interchain_account_address.go | 27 + x/icactl/keeper/grpc_query_params.go | 19 + x/icactl/keeper/keeper.go | 120 ++ x/icactl/keeper/msg_server.go | 17 + .../keeper/msg_server_register_account.go | 18 + x/icactl/keeper/msg_server_submit_tx.go | 26 + x/icactl/keeper/params.go | 26 + x/icactl/module.go | 164 +++ x/icactl/module_ibc.go | 143 ++ x/icactl/types/codec.go | 29 + x/icactl/types/genesis.go | 14 + x/icactl/types/genesis.pb.go | 322 +++++ x/icactl/types/keys.go | 21 + x/icactl/types/message_register_account.go | 46 + .../types/message_register_account_test.go | 39 + x/icactl/types/message_submit_tx.go | 103 ++ x/icactl/types/message_submit_tx_test.go | 39 + x/icactl/types/params.go | 69 + x/icactl/types/params.pb.go | 328 +++++ x/icactl/types/query.pb.go | 978 ++++++++++++++ x/icactl/types/query.pb.gw.go | 276 ++++ x/icactl/types/tx.pb.go | 1155 +++++++++++++++++ x/icactl/types/types.go | 13 + 40 files changed, 4610 insertions(+), 19 deletions(-) create mode 100644 nix/chainmain.nix create mode 100644 proto/icactl/v1/genesis.proto create mode 100644 proto/icactl/v1/params.proto create mode 100644 proto/icactl/v1/query.proto create mode 100644 proto/icactl/v1/tx.proto create mode 100644 x/icactl/client/cli/flags.go create mode 100644 x/icactl/client/cli/query.go create mode 100644 x/icactl/client/cli/query_interchain_account_address.go create mode 100644 x/icactl/client/cli/query_params.go create mode 100644 x/icactl/client/cli/tx.go create mode 100644 x/icactl/client/cli/tx_register_account.go create mode 100644 x/icactl/client/cli/tx_submit_tx.go create mode 100644 x/icactl/genesis.go create mode 100644 x/icactl/handler.go create mode 100644 x/icactl/keeper/grpc_query.go create mode 100644 x/icactl/keeper/grpc_query_interchain_account_address.go create mode 100644 x/icactl/keeper/grpc_query_params.go create mode 100644 x/icactl/keeper/keeper.go create mode 100644 x/icactl/keeper/msg_server.go create mode 100644 x/icactl/keeper/msg_server_register_account.go create mode 100644 x/icactl/keeper/msg_server_submit_tx.go create mode 100644 x/icactl/keeper/params.go create mode 100644 x/icactl/module.go create mode 100644 x/icactl/module_ibc.go create mode 100644 x/icactl/types/codec.go create mode 100644 x/icactl/types/genesis.go create mode 100644 x/icactl/types/genesis.pb.go create mode 100644 x/icactl/types/keys.go create mode 100644 x/icactl/types/message_register_account.go create mode 100644 x/icactl/types/message_register_account_test.go create mode 100644 x/icactl/types/message_submit_tx.go create mode 100644 x/icactl/types/message_submit_tx_test.go create mode 100644 x/icactl/types/params.go create mode 100644 x/icactl/types/params.pb.go create mode 100644 x/icactl/types/query.pb.go create mode 100644 x/icactl/types/query.pb.gw.go create mode 100644 x/icactl/types/tx.pb.go create mode 100644 x/icactl/types/types.go diff --git a/app/app.go b/app/app.go index 607aa46d4a..72d1ef2262 100644 --- a/app/app.go +++ b/app/app.go @@ -91,6 +91,11 @@ import ( upgradeclient "github.com/cosmos/cosmos-sdk/x/upgrade/client" upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" + ica "github.com/cosmos/ibc-go/v6/modules/apps/27-interchain-accounts" + icacontroller "github.com/cosmos/ibc-go/v6/modules/apps/27-interchain-accounts/controller" + icacontrollerkeeper "github.com/cosmos/ibc-go/v6/modules/apps/27-interchain-accounts/controller/keeper" + icacontrollertypes "github.com/cosmos/ibc-go/v6/modules/apps/27-interchain-accounts/controller/types" + icatypes "github.com/cosmos/ibc-go/v6/modules/apps/27-interchain-accounts/types" ibcfee "github.com/cosmos/ibc-go/v6/modules/apps/29-fee" ibcfeekeeper "github.com/cosmos/ibc-go/v6/modules/apps/29-fee/keeper" ibcfeetypes "github.com/cosmos/ibc-go/v6/modules/apps/29-fee/types" @@ -124,6 +129,9 @@ import ( gravitytypes "github.com/peggyjv/gravity-bridge/module/v2/x/gravity/types" // this line is used by starport scaffolding # stargate/app/moduleImport + icactlmodule "github.com/crypto-org-chain/cronos/v2/x/icactl" + icactlmodulekeeper "github.com/crypto-org-chain/cronos/v2/x/icactl/keeper" + icactlmoduletypes "github.com/crypto-org-chain/cronos/v2/x/icactl/types" memiavlstore "github.com/crypto-org-chain/cronos/store" memiavlrootmulti "github.com/crypto-org-chain/cronos/store/rootmulti" @@ -190,6 +198,7 @@ var ( govtypes.ModuleName: {authtypes.Burner}, ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner}, ibcfeetypes.ModuleName: nil, + icatypes.ModuleName: nil, evmtypes.ModuleName: {authtypes.Minter, authtypes.Burner}, // used for secure addition and subtraction of balance using module account gravitytypes.ModuleName: {authtypes.Minter, authtypes.Burner}, cronostypes.ModuleName: {authtypes.Minter, authtypes.Burner}, @@ -229,6 +238,8 @@ func GenModuleBasics() module.BasicManager { authzmodule.AppModuleBasic{}, ibc.AppModuleBasic{}, transfer.AppModuleBasic{}, + ica.AppModuleBasic{}, + icactlmodule.AppModuleBasic{}, vesting.AppModuleBasic{}, ibcfee.AppModuleBasic{}, evm.AppModuleBasic{}, @@ -289,27 +300,31 @@ type App struct { memKeys map[string]*storetypes.MemoryStoreKey // keepers - AccountKeeper authkeeper.AccountKeeper - BankKeeper bankkeeper.Keeper - CapabilityKeeper *capabilitykeeper.Keeper - StakingKeeper stakingkeeper.Keeper - SlashingKeeper slashingkeeper.Keeper - MintKeeper mintkeeper.Keeper - DistrKeeper distrkeeper.Keeper - GovKeeper govkeeper.Keeper - CrisisKeeper crisiskeeper.Keeper - UpgradeKeeper upgradekeeper.Keeper - ParamsKeeper paramskeeper.Keeper - IBCKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly - IBCFeeKeeper ibcfeekeeper.Keeper - EvidenceKeeper evidencekeeper.Keeper - TransferKeeper ibctransferkeeper.Keeper - FeeGrantKeeper feegrantkeeper.Keeper - AuthzKeeper authzkeeper.Keeper + AccountKeeper authkeeper.AccountKeeper + BankKeeper bankkeeper.Keeper + CapabilityKeeper *capabilitykeeper.Keeper + StakingKeeper stakingkeeper.Keeper + SlashingKeeper slashingkeeper.Keeper + MintKeeper mintkeeper.Keeper + DistrKeeper distrkeeper.Keeper + GovKeeper govkeeper.Keeper + CrisisKeeper crisiskeeper.Keeper + UpgradeKeeper upgradekeeper.Keeper + ParamsKeeper paramskeeper.Keeper + IBCKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly + IBCFeeKeeper ibcfeekeeper.Keeper + TransferKeeper ibctransferkeeper.Keeper + ICAControllerKeeper icacontrollerkeeper.Keeper + ICAAuthKeeper icactlmodulekeeper.Keeper + EvidenceKeeper evidencekeeper.Keeper + FeeGrantKeeper feegrantkeeper.Keeper + AuthzKeeper authzkeeper.Keeper // make scoped keepers public for test purposes - ScopedIBCKeeper capabilitykeeper.ScopedKeeper - ScopedTransferKeeper capabilitykeeper.ScopedKeeper + ScopedIBCKeeper capabilitykeeper.ScopedKeeper + ScopedTransferKeeper capabilitykeeper.ScopedKeeper + ScopedICAControllerKeeper capabilitykeeper.ScopedKeeper + ScopedICAAuthKeeper capabilitykeeper.ScopedKeeper // Ethermint keepers EvmKeeper *evmkeeper.Keeper @@ -358,6 +373,10 @@ func New( fmt.Printf("failed to load state streaming: %s", err) os.Exit(1) } + if experimental { + storeKeys = append(storeKeys, gravitytypes.StoreKey) + } + keys := sdk.NewKVStoreKeys(storeKeys...) // wire up the versiondb's `StreamingService` and `MultiStore`. streamers := cast.ToStringSlice(appOpts.Get("store.streamers")) @@ -392,6 +411,8 @@ func New( // grant capabilities for the ibc and ibc-transfer modules scopedIBCKeeper := app.CapabilityKeeper.ScopeToModule(ibchost.ModuleName) scopedTransferKeeper := app.CapabilityKeeper.ScopeToModule(ibctransfertypes.ModuleName) + scopedICAControllerKeeper := app.CapabilityKeeper.ScopeToModule(icacontrollertypes.SubModuleName) + scopedICAAuthKeeper := app.CapabilityKeeper.ScopeToModule(icactlmoduletypes.ModuleName) // Applications that wish to enforce statically created ScopedKeepers should call `Seal` after creating // their scoped modules in `NewApp` with `ScopeToModule` app.CapabilityKeeper.Seal() @@ -529,7 +550,19 @@ func New( transferStack = transfer.NewIBCModule(app.TransferKeeper) transferStack = middleware.NewIBCConversionModule(transferStack, app.CronosKeeper) transferStack = ibcfee.NewIBCMiddleware(transferStack, app.IBCFeeKeeper) + app.ICAControllerKeeper = icacontrollerkeeper.NewKeeper( + appCodec, keys[icacontrollertypes.StoreKey], app.GetSubspace(icacontrollertypes.SubModuleName), + app.IBCKeeper.ChannelKeeper, // may be replaced with middleware such as ics29 fee + app.IBCKeeper.ChannelKeeper, &app.IBCKeeper.PortKeeper, + scopedICAControllerKeeper, app.MsgServiceRouter(), + ) + icaModule := ica.NewAppModule(&app.ICAControllerKeeper, nil) + app.ICAAuthKeeper = *icactlmodulekeeper.NewKeeper(appCodec, + app.GetSubspace(icactlmoduletypes.ModuleName), app.ICAControllerKeeper, scopedICAAuthKeeper) + icaAuthModule := icactlmodule.NewAppModule(appCodec, app.ICAAuthKeeper) + icaAuthIBCModule := icactlmodule.NewIBCModule(app.ICAAuthKeeper) + icaControllerIBCModule := icacontroller.NewIBCModule(app.ICAControllerKeeper, icaAuthIBCModule) app.GovKeeper = govkeeper.NewKeeper( appCodec, keys[govtypes.StoreKey], app.GetSubspace(govtypes.ModuleName), app.AccountKeeper, app.BankKeeper, &stakingKeeper, govRouter, app.MsgServiceRouter(), govConfig, @@ -564,6 +597,8 @@ func New( // Create static IBC router, add transfer route, then set and seal it ibcRouter := porttypes.NewRouter() ibcRouter.AddRoute(ibctransfertypes.ModuleName, transferStack) + ibcRouter.AddRoute(icacontrollertypes.SubModuleName, icaControllerIBCModule) + ibcRouter.AddRoute(icactlmoduletypes.ModuleName, icaControllerIBCModule) // this line is used by starport scaffolding # ibc/app/router app.IBCKeeper.SetRouter(ibcRouter) @@ -598,6 +633,8 @@ func New( authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry), ibc.NewAppModule(app.IBCKeeper), transferModule, + icaModule, + icaAuthModule, feeModule, evm.NewAppModule(app.EvmKeeper, app.AccountKeeper, evmS), feemarket.NewAppModule(app.FeeMarketKeeper, feeMarketS), @@ -616,6 +653,8 @@ func New( evidencetypes.ModuleName, stakingtypes.ModuleName, ibchost.ModuleName, ibctransfertypes.ModuleName, ibcfeetypes.ModuleName, + icatypes.ModuleName, + icactlmoduletypes.ModuleName, authtypes.ModuleName, banktypes.ModuleName, govtypes.ModuleName, @@ -634,6 +673,8 @@ func New( ibchost.ModuleName, ibctransfertypes.ModuleName, ibcfeetypes.ModuleName, + icatypes.ModuleName, + icactlmoduletypes.ModuleName, capabilitytypes.ModuleName, authtypes.ModuleName, banktypes.ModuleName, @@ -674,6 +715,8 @@ func New( evidencetypes.ModuleName, ibctransfertypes.ModuleName, ibcfeetypes.ModuleName, + icatypes.ModuleName, + icactlmoduletypes.ModuleName, authz.ModuleName, feegrant.ModuleName, paramstypes.ModuleName, @@ -748,6 +791,25 @@ func New( // upgrade. app.setPostHandler() + planName := "v0.8.0" + app.UpgradeKeeper.SetUpgradeHandler(planName, func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { + return app.mm.RunMigrations(ctx, app.configurator, fromVM) + }) + + upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk() + if err != nil { + panic(fmt.Sprintf("failed to read upgrade info from disk %s", err)) + } + + if upgradeInfo.Name == planName && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) { + storeUpgrades := storetypes.StoreUpgrades{ + Added: []string{icacontrollertypes.StoreKey}, + } + + // configure store loader that checks if version == upgradeHeight and applies store upgrades + app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades)) + } + if loadLatest { if err := app.LoadLatestVersion(); err != nil { tmos.Exit(err.Error()) @@ -764,6 +826,8 @@ func New( app.ScopedIBCKeeper = scopedIBCKeeper app.ScopedTransferKeeper = scopedTransferKeeper + app.ScopedICAControllerKeeper = scopedICAControllerKeeper + app.ScopedICAAuthKeeper = scopedICAAuthKeeper // this line is used by starport scaffolding # stargate/app/beforeInitReturn return app @@ -967,6 +1031,8 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino paramsKeeper.Subspace(crisistypes.ModuleName) paramsKeeper.Subspace(ibctransfertypes.ModuleName) paramsKeeper.Subspace(ibchost.ModuleName) + paramsKeeper.Subspace(icacontrollertypes.SubModuleName) + paramsKeeper.Subspace(icactlmoduletypes.ModuleName) paramsKeeper.Subspace(evmtypes.ModuleName).WithKeyTable(evmtypes.ParamKeyTable()) //nolint: staticcheck paramsKeeper.Subspace(feemarkettypes.ModuleName).WithKeyTable(feemarkettypes.ParamKeyTable()) if !skipGravity { diff --git a/integration_tests/test_ibc.py b/integration_tests/test_ibc.py index ff5a4dceea..cf9703a6e3 100644 --- a/integration_tests/test_ibc.py +++ b/integration_tests/test_ibc.py @@ -1,3 +1,4 @@ +import base64 import hashlib import pytest @@ -433,3 +434,91 @@ def check_contract_balance_change(): def ibc_denom(channel, denom): h = hashlib.sha256(f"transfer/{channel}/{denom}".encode()).hexdigest().upper() return f"ibc/{h}" + + +def test_ica(ibc, tmp_path): + connid = "connection-0" + cli_host = ibc.chainmain.cosmos_cli() + cli_controller = ibc.cronos.cosmos_cli() + + print("register ica account") + rsp = cli_controller.ica_register_account( + connid, from_="signer2", gas="400000", fees="100000000basetcro" + ) + assert rsp["code"] == 0, rsp["raw_log"] + port_id, channel_id = next( + ( + base64.b64decode(evt["attributes"][0]["value"].encode()).decode(), + base64.b64decode(evt["attributes"][1]["value"].encode()).decode(), + ) + for evt in rsp["events"] + if evt["type"] == "channel_open_init" + ) + print("port-id", port_id, "channel-id", channel_id) + + print("wait for ica channel ready") + + def check_channel_ready(): + channels = cli_controller.ibc_query_channels(connid)["channels"] + try: + state = next( + channel["state"] + for channel in channels + if channel["channel_id"] == channel_id + ) + except StopIteration: + return False + return state == "STATE_OPEN" + + wait_for_fn("channel ready", check_channel_ready) + + print("query ica account") + ica_address = cli_controller.ica_query_account( + connid, cli_controller.address("signer2") + )["interchainAccountAddress"] + print("ica address", ica_address) + + # initial balance of interchain account should be zero + assert cli_host.balance(ica_address) == 0 + + # send some funds to interchain account + rsp = cli_host.transfer("signer2", ica_address, "1cro", gas_prices="1000000basecro") + assert rsp["code"] == 0, rsp["raw_log"] + wait_for_new_blocks(cli_host, 1) + + # check if the funds are received in interchain account + assert cli_host.balance(ica_address, denom="basecro") == 100000000 + + # generate a transaction to send to host chain + generated_tx = tmp_path / "generated_tx.txt" + generated_tx_msg = cli_host.transfer( + ica_address, cli_host.address("signer2"), "0.5cro", generate_only=True + ) + + print(generated_tx_msg) + generated_tx.write_text(json.dumps(generated_tx_msg)) + + num_txs = len(cli_host.query_all_txs(ica_address)["txs"]) + + # submit transaction on host chain on behalf of interchain account + rsp = cli_controller.ica_submit_tx( + connid, + generated_tx, + from_="signer2", + ) + assert rsp["code"] == 0, rsp["raw_log"] + packet_seq = next( + int(base64.b64decode(evt["attributes"][4]["value"].encode())) + for evt in rsp["events"] + if evt["type"] == "send_packet" + ) + print("packet sequence", packet_seq) + + def check_ica_tx(): + return len(cli_host.query_all_txs(ica_address)["txs"]) > num_txs + + print("wait for ica tx arrive") + wait_for_fn("ica transfer tx", check_ica_tx) + + # check if the funds are reduced in interchain account + assert cli_host.balance(ica_address, denom="basecro") == 50000000 \ No newline at end of file diff --git a/nix/chainmain.nix b/nix/chainmain.nix new file mode 100644 index 0000000000..cb5e0029da --- /dev/null +++ b/nix/chainmain.nix @@ -0,0 +1,3 @@ +{ pkgs ? import ./default.nix { }, sources ? import ./sources.nix }: +(import sources.chain-main { }).chain-maind + diff --git a/proto/icactl/v1/genesis.proto b/proto/icactl/v1/genesis.proto new file mode 100644 index 0000000000..639ee5d308 --- /dev/null +++ b/proto/icactl/v1/genesis.proto @@ -0,0 +1,13 @@ +syntax = "proto3"; +package cronos.icactl.v1; + +import "gogoproto/gogo.proto"; +import "icactl/v1/params.proto"; + +option go_package = "github.com/crypto-org-chain/cronos/v2/x/icactl/types"; + +// GenesisState defines the icactl module's genesis state. +message GenesisState { + // params defines the genesis parameters + Params params = 1 [ (gogoproto.nullable) = false ]; +} diff --git a/proto/icactl/v1/params.proto b/proto/icactl/v1/params.proto new file mode 100644 index 0000000000..996a81f1f3 --- /dev/null +++ b/proto/icactl/v1/params.proto @@ -0,0 +1,20 @@ +syntax = "proto3"; +package cronos.icactl.v1; + +import "google/protobuf/duration.proto"; +import "gogoproto/gogo.proto"; + +option go_package = "github.com/crypto-org-chain/cronos/v2/x/icactl/types"; + +// Params defines the parameters for the module. +message Params { + option (gogoproto.goproto_stringer) = false; + + // minTimeoutDuration defines the minimum value of packet timeout when + // submitting transactions to host chain on behalf of interchain account + google.protobuf.Duration minTimeoutDuration = 1 [ + (gogoproto.moretags) = "yaml:\"min_timeout_duration\"", + (gogoproto.stdduration) = true, + (gogoproto.nullable) = false + ]; +} \ No newline at end of file diff --git a/proto/icactl/v1/query.proto b/proto/icactl/v1/query.proto new file mode 100644 index 0000000000..651aed9c32 --- /dev/null +++ b/proto/icactl/v1/query.proto @@ -0,0 +1,47 @@ +syntax = "proto3"; +package cronos.icactl.v1; + +import "gogoproto/gogo.proto"; +import "google/api/annotations.proto"; +import "cosmos/base/query/v1beta1/pagination.proto"; +import "icactl/v1/params.proto"; + +option go_package = "github.com/crypto-org-chain/cronos/v2/x/icactl/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 = "/cronos/icactl/v1/params"; + } + + // InterchainAccountAddress queries the interchain account address for given + // `connectionId` and `owner` + rpc InterchainAccountAddress(QueryInterchainAccountAddressRequest) + returns (QueryInterchainAccountAddressResponse) { + option (google.api.http).get = + "/cronos/icactl/v1/interchain_account_address/{connectionId}/{owner}"; + } +} + +// 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 ]; +} + +// QueryInterchainAccountAddressRequest defines the request for the +// InterchainAccountAddress query. +message QueryInterchainAccountAddressRequest { + string connectionId = 1 [ (gogoproto.moretags) = "yaml:\"connection_id\"" ]; + string owner = 2; +} + +// QueryInterchainAccountAddressResponse defines the response for the +// InterchainAccountAddress query. +message QueryInterchainAccountAddressResponse { + string interchainAccountAddress = 1; +} diff --git a/proto/icactl/v1/tx.proto b/proto/icactl/v1/tx.proto new file mode 100644 index 0000000000..c79e1bff44 --- /dev/null +++ b/proto/icactl/v1/tx.proto @@ -0,0 +1,55 @@ +syntax = "proto3"; +package cronos.icactl.v1; + +import "cosmos_proto/cosmos.proto"; +import "google/protobuf/any.proto"; +import "google/protobuf/duration.proto"; +import "gogoproto/gogo.proto"; + +option go_package = "github.com/crypto-org-chain/cronos/v2/x/icactl/types"; + +// Msg defines the Msg service. +service Msg { + // RegisterAccount registers an interchain account on host chain with given + // `connectionId` + rpc RegisterAccount(MsgRegisterAccount) returns (MsgRegisterAccountResponse); + + // SubmitTx submits a transaction to the host chain on behalf of interchain + // account + rpc SubmitTx(MsgSubmitTx) returns (MsgSubmitTxResponse); +} + +// MsgRegisterAccount defines the request message for MsgRegisterAccount +message MsgRegisterAccount { + // owner represents the owner of the interchain account + string owner = 1; + + // connectionId represents the IBC `connectionId` of the host chain + string connectionId = 2 [ (gogoproto.moretags) = "yaml:\"connection_id\"" ]; + string version = 3; +} + +// MsgRegisterAccountResponse defines the response message for +// MsgRegisterAccount +message MsgRegisterAccountResponse {} + +// MsgSubmitTx defines the request message for MsgSubmitTx +message MsgSubmitTx { + // owner represents the owner of the interchain account + string owner = 1; + + // connectionId represents the IBC `connectionId` of the host chain + string connectionId = 2 [ (gogoproto.moretags) = "yaml:\"connection_id\"" ]; + + // msgs represents the transactions to be submitted to the host chain + repeated google.protobuf.Any msgs = 3 + [ (cosmos_proto.accepts_interface) = "sdk.Msg" ]; + + // timeoutDuration represents the timeout duration for the IBC packet from + // last block + google.protobuf.Duration timeoutDuration = 4 + [ (gogoproto.stdduration) = true ]; +} + +// MsgSubmitTxResponse defines the response message for MsgSubmitTx +message MsgSubmitTxResponse {} \ No newline at end of file diff --git a/x/icactl/client/cli/flags.go b/x/icactl/client/cli/flags.go new file mode 100644 index 0000000000..fc58c920d7 --- /dev/null +++ b/x/icactl/client/cli/flags.go @@ -0,0 +1,5 @@ +package cli + +const ( + FlagTimeoutDuration = "timeout-duration" +) diff --git a/x/icactl/client/cli/query.go b/x/icactl/client/cli/query.go new file mode 100644 index 0000000000..8b7d771890 --- /dev/null +++ b/x/icactl/client/cli/query.go @@ -0,0 +1,26 @@ +package cli + +import ( + "fmt" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/crypto-org-chain/cronos/v2/x/icactl/types" + "github.com/spf13/cobra" +) + +// GetQueryCmd returns the cli query commands for this module +func GetQueryCmd(queryRoute string) *cobra.Command { + // Group icactl 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()) + cmd.AddCommand(CmdInterchainAccountAddress()) + + return cmd +} diff --git a/x/icactl/client/cli/query_interchain_account_address.go b/x/icactl/client/cli/query_interchain_account_address.go new file mode 100644 index 0000000000..77125fbac7 --- /dev/null +++ b/x/icactl/client/cli/query_interchain_account_address.go @@ -0,0 +1,47 @@ +package cli + +import ( + "strconv" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/crypto-org-chain/cronos/v2/x/icactl/types" + "github.com/spf13/cobra" +) + +var _ = strconv.Itoa(0) + +func CmdInterchainAccountAddress() *cobra.Command { + cmd := &cobra.Command{ + Use: "interchain-account-address [connection-id] [owner]", + Short: "Gets interchain account address on host chain", + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) (err error) { + reqConnectionID := args[0] + reqOwner := args[1] + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + params := &types.QueryInterchainAccountAddressRequest{ + ConnectionId: reqConnectionID, + Owner: reqOwner, + } + + res, err := queryClient.InterchainAccountAddress(cmd.Context(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/icactl/client/cli/query_params.go b/x/icactl/client/cli/query_params.go new file mode 100644 index 0000000000..94ccbd5cb5 --- /dev/null +++ b/x/icactl/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/crypto-org-chain/cronos/v2/x/icactl/types" + "github.com/spf13/cobra" +) + +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/icactl/client/cli/tx.go b/x/icactl/client/cli/tx.go new file mode 100644 index 0000000000..5e6fa8f050 --- /dev/null +++ b/x/icactl/client/cli/tx.go @@ -0,0 +1,25 @@ +package cli + +import ( + "fmt" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/crypto-org-chain/cronos/v2/x/icactl/types" + "github.com/spf13/cobra" +) + +// 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(CmdRegisterAccount()) + cmd.AddCommand(CmdSubmitTx()) + + return cmd +} diff --git a/x/icactl/client/cli/tx_register_account.go b/x/icactl/client/cli/tx_register_account.go new file mode 100644 index 0000000000..0efa01f22a --- /dev/null +++ b/x/icactl/client/cli/tx_register_account.go @@ -0,0 +1,42 @@ +package cli + +import ( + "strconv" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" + "github.com/crypto-org-chain/cronos/v2/x/icactl/types" + "github.com/spf13/cobra" +) + +var _ = strconv.Itoa(0) + +func CmdRegisterAccount() *cobra.Command { + cmd := &cobra.Command{ + Use: "register-account [connection-id]", + Short: "Registers an interchain account", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) (err error) { + argConnectionID := args[0] + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + msg := types.NewMsgRegisterAccount( + clientCtx.GetFromAddress().String(), + argConnectionID, + ) + if err := msg.ValidateBasic(); err != nil { + return err + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} diff --git a/x/icactl/client/cli/tx_submit_tx.go b/x/icactl/client/cli/tx_submit_tx.go new file mode 100644 index 0000000000..c815530d38 --- /dev/null +++ b/x/icactl/client/cli/tx_submit_tx.go @@ -0,0 +1,68 @@ +package cli + +import ( + "fmt" + "strconv" + "strings" + "time" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" + "github.com/cosmos/cosmos-sdk/version" + authclient "github.com/cosmos/cosmos-sdk/x/auth/client" + "github.com/crypto-org-chain/cronos/v2/x/icactl/types" + "github.com/spf13/cobra" +) + +var _ = strconv.Itoa(0) + +func CmdSubmitTx() *cobra.Command { + cmd := &cobra.Command{ + Use: "submit-tx [connection-id] [msg_tx_json_file]", + Short: "Submit a transaction on host chain on behalf of the interchain account", + Long: strings.TrimSpace( + fmt.Sprintf(`Submit a transaction on host chain on behalf of the interchain account: +Example: + $ %s tx %s submit-tx connection-1 tx.json --from mykey + $ %s tx bank send --generate-only > tx.json && %s tx %s submit-tx connection-1 tx.json --from mykey + `, version.AppName, types.ModuleName, version.AppName, version.AppName, types.ModuleName), + ), + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) (err error) { + argConnectionID := args[0] + argMsg := args[1] + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + theTx, err := authclient.ReadTxFromFile(clientCtx, argMsg) + if err != nil { + return err + } + + timeoutDuration, err := cmd.Flags().GetDuration(FlagTimeoutDuration) + if err != nil { + return err + } + + msg := types.NewMsgSubmitTx( + clientCtx.GetFromAddress().String(), + argConnectionID, + theTx.GetMsgs(), + &timeoutDuration, + ) + if err := msg.ValidateBasic(); err != nil { + return err + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + cmd.Flags().Duration(FlagTimeoutDuration, time.Minute*5, "Timeout duration for the transaction (default: 5 minutes)") + + return cmd +} diff --git a/x/icactl/genesis.go b/x/icactl/genesis.go new file mode 100644 index 0000000000..08caa266c9 --- /dev/null +++ b/x/icactl/genesis.go @@ -0,0 +1,21 @@ +package icactl + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/crypto-org-chain/cronos/v2/x/icactl/keeper" + "github.com/crypto-org-chain/cronos/v2/x/icactl/types" +) + +// InitGenesis initializes the capability module's state from a provided genesis +// state. +func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) { + 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) + + return genesis +} diff --git a/x/icactl/handler.go b/x/icactl/handler.go new file mode 100644 index 0000000000..aab7fdd1f3 --- /dev/null +++ b/x/icactl/handler.go @@ -0,0 +1,31 @@ +package icactl + +import ( + "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/crypto-org-chain/cronos/v2/x/icactl/keeper" + "github.com/crypto-org-chain/cronos/v2/x/icactl/types" +) + +// NewHandler ... +func NewHandler(k keeper.Keeper) sdk.Handler { + msgServer := 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.MsgRegisterAccount: + res, err := msgServer.RegisterAccount(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + case *types.MsgSubmitTx: + res, err := msgServer.SubmitTx(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + default: + errMsg := fmt.Sprintf("unrecognized %s message type: %T", types.ModuleName, msg) + return nil, sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, errMsg) + } + } +} diff --git a/x/icactl/keeper/grpc_query.go b/x/icactl/keeper/grpc_query.go new file mode 100644 index 0000000000..5eb94b6ea9 --- /dev/null +++ b/x/icactl/keeper/grpc_query.go @@ -0,0 +1,7 @@ +package keeper + +import ( + "github.com/crypto-org-chain/cronos/v2/x/icactl/types" +) + +var _ types.QueryServer = Keeper{} diff --git a/x/icactl/keeper/grpc_query_interchain_account_address.go b/x/icactl/keeper/grpc_query_interchain_account_address.go new file mode 100644 index 0000000000..43504177bb --- /dev/null +++ b/x/icactl/keeper/grpc_query_interchain_account_address.go @@ -0,0 +1,27 @@ +package keeper + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/crypto-org-chain/cronos/v2/x/icactl/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +func (k Keeper) InterchainAccountAddress(goCtx context.Context, req *types.QueryInterchainAccountAddressRequest) (*types.QueryInterchainAccountAddressResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + + icaAddress, err := k.GetInterchainAccountAddress(ctx, req.ConnectionId, req.Owner) + if err != nil { + return nil, err + } + + return &types.QueryInterchainAccountAddressResponse{ + InterchainAccountAddress: icaAddress, + }, nil +} diff --git a/x/icactl/keeper/grpc_query_params.go b/x/icactl/keeper/grpc_query_params.go new file mode 100644 index 0000000000..dc4064554f --- /dev/null +++ b/x/icactl/keeper/grpc_query_params.go @@ -0,0 +1,19 @@ +package keeper + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/crypto-org-chain/cronos/v2/x/icactl/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/icactl/keeper/keeper.go b/x/icactl/keeper/keeper.go new file mode 100644 index 0000000000..adb263d5e1 --- /dev/null +++ b/x/icactl/keeper/keeper.go @@ -0,0 +1,120 @@ +package keeper + +import ( + "fmt" + "time" + + "github.com/cosmos/cosmos-sdk/codec" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper" + capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" + icacontrollerkeeper "github.com/cosmos/ibc-go/v6/modules/apps/27-interchain-accounts/controller/keeper" + icatypes "github.com/cosmos/ibc-go/v6/modules/apps/27-interchain-accounts/types" + channeltypes "github.com/cosmos/ibc-go/v6/modules/core/04-channel/types" + host "github.com/cosmos/ibc-go/v6/modules/core/24-host" + "github.com/crypto-org-chain/cronos/v2/x/icactl/types" + proto "github.com/gogo/protobuf/proto" + "github.com/tendermint/tendermint/libs/log" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +type ( + Keeper struct { + cdc codec.BinaryCodec + paramStore paramtypes.Subspace + + icaControllerKeeper icacontrollerkeeper.Keeper + scopedKeeper capabilitykeeper.ScopedKeeper + } +) + +func NewKeeper( + cdc codec.BinaryCodec, + paramStore paramtypes.Subspace, + icaControllerKeeper icacontrollerkeeper.Keeper, + scopedKeeper capabilitykeeper.ScopedKeeper, +) *Keeper { + // set KeyTable if it has not already been set + if !paramStore.HasKeyTable() { + paramStore = paramStore.WithKeyTable(types.ParamKeyTable()) + } + + return &Keeper{ + cdc: cdc, + paramStore: paramStore, + + icaControllerKeeper: icaControllerKeeper, + scopedKeeper: scopedKeeper, + } +} + +// DoSubmitTx submits a transaction to the host chain on behalf of interchain account +func (k *Keeper) DoSubmitTx(ctx sdk.Context, connectionID, owner string, msgs []proto.Message, timeoutDuration time.Duration) error { + portID, err := icatypes.NewControllerPortID(owner) + if err != nil { + return err + } + + channelID, found := k.icaControllerKeeper.GetActiveChannelID(ctx, connectionID, portID) + if !found { + return sdkerrors.Wrapf(icatypes.ErrActiveChannelNotFound, "failed to retrieve active channel for port %s", portID) + } + + channelCapability, found := k.scopedKeeper.GetCapability(ctx, host.ChannelCapabilityPath(portID, channelID)) + if !found { + return sdkerrors.Wrap(channeltypes.ErrChannelCapabilityNotFound, "module does not own channel capability") + } + + data, err := icatypes.SerializeCosmosTx(k.cdc, msgs) + if err != nil { + return err + } + + packetData := icatypes.InterchainAccountPacketData{ + Type: icatypes.EXECUTE_TX, + Data: data, + } + + // timeoutDuration should be constraited by MinTimeoutDuration parameter. + timeoutTimestamp := ctx.BlockTime().Add(timeoutDuration).UnixNano() + + _, err = k.icaControllerKeeper.SendTx(ctx, channelCapability, connectionID, portID, packetData, uint64(timeoutTimestamp)) + if err != nil { + return err + } + + return nil +} + +// RegisterInterchainAccount registers an interchain account with the given `connectionId` and `owner` on the host chain +func (k *Keeper) RegisterInterchainAccount(ctx sdk.Context, connectionID, owner, version string) error { + return k.icaControllerKeeper.RegisterInterchainAccount(ctx, connectionID, owner, version) +} + +// GetInterchainAccountAddress fetches the interchain account address for given `connectionId` and `owner` +func (k *Keeper) GetInterchainAccountAddress(ctx sdk.Context, connectionID, owner string) (string, error) { + portID, err := icatypes.NewControllerPortID(owner) + if err != nil { + return "", status.Errorf(codes.InvalidArgument, "invalid owner address: %s", err) + } + + icaAddress, found := k.icaControllerKeeper.GetInterchainAccountAddress(ctx, connectionID, portID) + + if !found { + return "", status.Errorf(codes.NotFound, "could not find account") + } + + return icaAddress, nil +} + +// ClaimCapability claims the channel capability passed via the OnOpenChanInit callback +func (k *Keeper) ClaimCapability(ctx sdk.Context, cap *capabilitytypes.Capability, name string) error { + return k.scopedKeeper.ClaimCapability(ctx, cap, name) +} + +func (k Keeper) Logger(ctx sdk.Context) log.Logger { + return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) +} diff --git a/x/icactl/keeper/msg_server.go b/x/icactl/keeper/msg_server.go new file mode 100644 index 0000000000..a2b52768c7 --- /dev/null +++ b/x/icactl/keeper/msg_server.go @@ -0,0 +1,17 @@ +package keeper + +import ( + "github.com/crypto-org-chain/cronos/v2/x/icactl/types" +) + +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{} diff --git a/x/icactl/keeper/msg_server_register_account.go b/x/icactl/keeper/msg_server_register_account.go new file mode 100644 index 0000000000..725dbc2cb4 --- /dev/null +++ b/x/icactl/keeper/msg_server_register_account.go @@ -0,0 +1,18 @@ +package keeper + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/crypto-org-chain/cronos/v2/x/icactl/types" +) + +func (k msgServer) RegisterAccount(goCtx context.Context, msg *types.MsgRegisterAccount) (*types.MsgRegisterAccountResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + if err := k.RegisterInterchainAccount(ctx, msg.ConnectionId, msg.Owner, msg.Version); err != nil { + return nil, err + } + + return &types.MsgRegisterAccountResponse{}, nil +} diff --git a/x/icactl/keeper/msg_server_submit_tx.go b/x/icactl/keeper/msg_server_submit_tx.go new file mode 100644 index 0000000000..63966eca56 --- /dev/null +++ b/x/icactl/keeper/msg_server_submit_tx.go @@ -0,0 +1,26 @@ +package keeper + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/crypto-org-chain/cronos/v2/x/icactl/types" +) + +func (k msgServer) SubmitTx(goCtx context.Context, msg *types.MsgSubmitTx) (*types.MsgSubmitTxResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + msgs, err := msg.GetMessages() + if err != nil { + return nil, err + } + + minTimeoutDuration := k.MinTimeoutDuration(ctx) + + err = k.DoSubmitTx(ctx, msg.ConnectionId, msg.Owner, msgs, msg.CalculateTimeoutDuration(minTimeoutDuration)) + if err != nil { + return nil, err + } + + return &types.MsgSubmitTxResponse{}, nil +} diff --git a/x/icactl/keeper/params.go b/x/icactl/keeper/params.go new file mode 100644 index 0000000000..9b5cd11f25 --- /dev/null +++ b/x/icactl/keeper/params.go @@ -0,0 +1,26 @@ +package keeper + +import ( + "time" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/crypto-org-chain/cronos/v2/x/icactl/types" +) + +// GetParams get all parameters as types.Params +func (k Keeper) GetParams(ctx sdk.Context) types.Params { + return types.NewParams( + k.MinTimeoutDuration(ctx), + ) +} + +// SetParams set the params +func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { + k.paramStore.SetParamSet(ctx, ¶ms) +} + +// MinTimeoutDuration returns the MinTimeoutDuration param +func (k Keeper) MinTimeoutDuration(ctx sdk.Context) (res time.Duration) { + k.paramStore.Get(ctx, types.KeyMinTimeoutDuration, &res) + return +} diff --git a/x/icactl/module.go b/x/icactl/module.go new file mode 100644 index 0000000000..daa7b19d29 --- /dev/null +++ b/x/icactl/module.go @@ -0,0 +1,164 @@ +package icactl + +import ( + "encoding/json" + "fmt" + + "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" + "github.com/crypto-org-chain/cronos/v2/x/icactl/client/cli" + "github.com/crypto-org-chain/cronos/v2/x/icactl/keeper" + "github.com/crypto-org-chain/cronos/v2/x/icactl/types" + "github.com/gorilla/mux" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/spf13/cobra" + abci "github.com/tendermint/tendermint/abci/types" +) + +var ( + _ module.AppModule = AppModule{} + _ module.AppModuleBasic = AppModuleBasic{} +) + +// ---------------------------------------------------------------------------- +// AppModuleBasic +// ---------------------------------------------------------------------------- + +// AppModuleBasic implements the AppModuleBasic interface for the capability module. +type AppModuleBasic struct { + cdc codec.BinaryCodec +} + +func NewAppModuleBasic(cdc codec.BinaryCodec) AppModuleBasic { + return AppModuleBasic{cdc: cdc} +} + +// Name returns the capability module's name. +func (AppModuleBasic) Name() string { + return types.ModuleName +} + +func (AppModuleBasic) RegisterCodec(cdc *codec.LegacyAmino) { + types.RegisterCodec(cdc) +} + +func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + types.RegisterCodec(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) {} + +// 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 +} + +func NewAppModule( + cdc codec.BinaryCodec, + keeper keeper.Keeper, +) AppModule { + return AppModule{ + AppModuleBasic: NewAppModuleBasic(cdc), + keeper: keeper, + } +} + +// Name returns the capability module's name. +func (am AppModule) Name() string { + return am.AppModuleBasic.Name() +} + +// Route returns the capability module's message routing key. +func (am AppModule) Route() sdk.Route { + return sdk.NewRoute(types.RouterKey, NewHandler(am.keeper)) +} + +// QuerierRoute returns the capability module's query routing key. +func (AppModule) QuerierRoute() string { return types.QuerierRoute } + +// LegacyQuerierHandler returns the capability module's Querier. +func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sdk.Querier { + return nil +} + +// RegisterServices registers a GRPC query service to respond to the +// module-specific GRPC queries. +func (am AppModule) RegisterServices(cfg module.Configurator) { + types.RegisterQueryServer(cfg.QueryServer(), 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 + + 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 1 } + +// BeginBlock executes all ABCI BeginBlock logic respective to the capability module. +func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {} + +// 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/icactl/module_ibc.go b/x/icactl/module_ibc.go new file mode 100644 index 0000000000..b83b066645 --- /dev/null +++ b/x/icactl/module_ibc.go @@ -0,0 +1,143 @@ +package icactl + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" + icatypes "github.com/cosmos/ibc-go/v6/modules/apps/27-interchain-accounts/types" + channeltypes "github.com/cosmos/ibc-go/v6/modules/core/04-channel/types" + porttypes "github.com/cosmos/ibc-go/v6/modules/core/05-port/types" + host "github.com/cosmos/ibc-go/v6/modules/core/24-host" + ibcexported "github.com/cosmos/ibc-go/v6/modules/core/exported" + "github.com/crypto-org-chain/cronos/v2/x/icactl/keeper" +) + +var ( + _ porttypes.IBCModule = IBCModule{} +) + +// IBCModule implements the ICS26 interface for interchain accounts controller chains +type IBCModule struct { + keeper keeper.Keeper +} + +// NewIBCModule creates a new IBCModule given the keeper +func NewIBCModule(k keeper.Keeper) IBCModule { + return IBCModule{ + keeper: k, + } +} + +// OnChanOpenInit implements the IBCModule interface +func (am IBCModule) OnChanOpenInit( + ctx sdk.Context, + order channeltypes.Order, + connectionHops []string, + portID string, + channelID string, + chanCap *capabilitytypes.Capability, + counterparty channeltypes.Counterparty, + version string, +) error { + // Claim channel capability passed back by IBC module + if err := am.keeper.ClaimCapability(ctx, chanCap, host.ChannelCapabilityPath(portID, channelID)); err != nil { + return err + } + + return nil +} + +// OnChanOpenTry implements the IBCModule interface +func (am IBCModule) OnChanOpenTry( + ctx sdk.Context, + order channeltypes.Order, + connectionHops []string, + portID, + channelID string, + channelCap *capabilitytypes.Capability, + counterparty channeltypes.Counterparty, + counterpartyVersion string, +) (string, error) { + // https://github.com/cosmos/ibc-go/blob/v3.0.0/docs/apps/interchain-accounts/auth-modules.md#ibcmodule-implementation + return "", sdkerrors.Wrap(icatypes.ErrInvalidChannelFlow, "channel handshake must be initiated by controller chain") +} + +// OnChanOpenAck implements the IBCModule interface +func (am IBCModule) OnChanOpenAck( + ctx sdk.Context, + portID, + channelID string, + counterpartyChannelID string, + counterpartyVersion string, +) error { + return nil +} + +// OnChanOpenConfirm implements the IBCModule interface +func (am IBCModule) OnChanOpenConfirm( + ctx sdk.Context, + portID, + channelID string, +) error { + // https://github.com/cosmos/ibc-go/blob/v3.0.0/docs/apps/interchain-accounts/auth-modules.md#ibcmodule-implementation + return sdkerrors.Wrap(icatypes.ErrInvalidChannelFlow, "channel handshake must be initiated by controller chain") +} + +// OnChanCloseInit implements the IBCModule interface +func (am IBCModule) OnChanCloseInit( + ctx sdk.Context, + portID, + channelID string, +) error { + // https://github.com/cosmos/ibc-go/blob/v3.0.0/docs/apps/interchain-accounts/auth-modules.md#ibcmodule-implementation + return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "user cannot close channel") +} + +// OnChanCloseConfirm implements the IBCModule interface +func (am IBCModule) OnChanCloseConfirm( + ctx sdk.Context, + portID, + channelID string, +) error { + return nil +} + +// OnRecvPacket implements the IBCModule interface +func (am IBCModule) OnRecvPacket( + ctx sdk.Context, + packet channeltypes.Packet, + relayer sdk.AccAddress, +) ibcexported.Acknowledgement { + // https://github.com/cosmos/ibc-go/blob/v3.0.0/docs/apps/interchain-accounts/auth-modules.md#ibcmodule-implementation + return channeltypes.NewErrorAcknowledgement("cannot receive packet on controller chain") +} + +// OnAcknowledgementPacket implements the IBCModule interface +func (am IBCModule) OnAcknowledgementPacket( + ctx sdk.Context, + packet channeltypes.Packet, + acknowledgement []byte, + relayer sdk.AccAddress, +) error { + return nil +} + +// OnTimeoutPacket implements the IBCModule interface +func (am IBCModule) OnTimeoutPacket( + ctx sdk.Context, + packet channeltypes.Packet, + relayer sdk.AccAddress, +) error { + return nil +} + +func (am IBCModule) NegotiateAppVersion( + ctx sdk.Context, + order channeltypes.Order, + connectionID string, + portID string, + counterparty channeltypes.Counterparty, + proposedVersion string, +) (version string, err error) { + return proposedVersion, nil +} diff --git a/x/icactl/types/codec.go b/x/icactl/types/codec.go new file mode 100644 index 0000000000..733a5c8a4d --- /dev/null +++ b/x/icactl/types/codec.go @@ -0,0 +1,29 @@ +package types + +import ( + "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/msgservice" +) + +func RegisterCodec(cdc *codec.LegacyAmino) { + cdc.RegisterConcrete(&MsgRegisterAccount{}, "icactl/RegisterAccount", nil) + cdc.RegisterConcrete(&MsgSubmitTx{}, "icactl/SubmitTx", nil) +} + +func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { + registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgRegisterAccount{}, + ) + registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgSubmitTx{}, + ) + + msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) +} + +var ( + Amino = codec.NewLegacyAmino() + ModuleCdc = codec.NewProtoCodec(cdctypes.NewInterfaceRegistry()) +) diff --git a/x/icactl/types/genesis.go b/x/icactl/types/genesis.go new file mode 100644 index 0000000000..ffd96d1aad --- /dev/null +++ b/x/icactl/types/genesis.go @@ -0,0 +1,14 @@ +package types + +// DefaultGenesis returns the default Capability genesis state +func DefaultGenesis() *GenesisState { + return &GenesisState{ + Params: DefaultParams(), + } +} + +// Validate performs basic genesis state validation returning an error upon any +// failure. +func (gs GenesisState) Validate() error { + return gs.Params.Validate() +} diff --git a/x/icactl/types/genesis.pb.go b/x/icactl/types/genesis.pb.go new file mode 100644 index 0000000000..d239420c17 --- /dev/null +++ b/x/icactl/types/genesis.pb.go @@ -0,0 +1,322 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: icactl/v1/genesis.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/gogo/protobuf/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 icactl module's genesis state. +type GenesisState struct { + // params defines the genesis parameters + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` +} + +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_5ec665be7d0534ec, []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 init() { + proto.RegisterType((*GenesisState)(nil), "cronos.icactl.v1.GenesisState") +} + +func init() { proto.RegisterFile("icactl/v1/genesis.proto", fileDescriptor_5ec665be7d0534ec) } + +var fileDescriptor_5ec665be7d0534ec = []byte{ + // 207 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0xcf, 0x4c, 0x4e, 0x4c, + 0x2e, 0xc9, 0xd1, 0x2f, 0x33, 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, + 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x48, 0x2e, 0xca, 0xcf, 0xcb, 0x2f, 0xd6, 0x83, 0xc8, 0xeb, 0x95, + 0x19, 0x4a, 0x89, 0xa4, 0xe7, 0xa7, 0xe7, 0x83, 0x25, 0xf5, 0x41, 0x2c, 0x88, 0x3a, 0x29, 0x31, + 0x84, 0x01, 0x05, 0x89, 0x45, 0x89, 0xb9, 0x50, 0xfd, 0x4a, 0x6e, 0x5c, 0x3c, 0xee, 0x10, 0x03, + 0x83, 0x4b, 0x12, 0x4b, 0x52, 0x85, 0xcc, 0xb8, 0xd8, 0x20, 0xf2, 0x12, 0x8c, 0x0a, 0x8c, 0x1a, + 0xdc, 0x46, 0x12, 0x7a, 0xe8, 0x16, 0xe8, 0x05, 0x80, 0xe5, 0x9d, 0x58, 0x4e, 0xdc, 0x93, 0x67, + 0x08, 0x82, 0xaa, 0x76, 0xf2, 0x3b, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, + 0xe4, 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, 0x86, 0x28, + 0x93, 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0xfd, 0xe4, 0xa2, 0xca, 0x82, + 0x92, 0x7c, 0xdd, 0xfc, 0xa2, 0x74, 0xdd, 0xe4, 0x8c, 0xc4, 0xcc, 0x3c, 0x7d, 0x88, 0xe1, 0xfa, + 0x65, 0x46, 0xfa, 0x15, 0xfa, 0x50, 0x17, 0x96, 0x54, 0x16, 0xa4, 0x16, 0x27, 0xb1, 0x81, 0x9d, + 0x67, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0x89, 0xd0, 0x70, 0xe5, 0xf9, 0x00, 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 + { + 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)) + 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 + 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/icactl/types/keys.go b/x/icactl/types/keys.go new file mode 100644 index 0000000000..d3ad0b5f68 --- /dev/null +++ b/x/icactl/types/keys.go @@ -0,0 +1,21 @@ +package types + +const ( + // ModuleName defines the module name + ModuleName = "icactl" + + // 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_icactl" + + // Version defines the current version the IBC module supports + Version = "icactl-1" +) diff --git a/x/icactl/types/message_register_account.go b/x/icactl/types/message_register_account.go new file mode 100644 index 0000000000..18d416b60b --- /dev/null +++ b/x/icactl/types/message_register_account.go @@ -0,0 +1,46 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +const TypeMsgRegisterAccount = "register_account" + +var _ sdk.Msg = &MsgRegisterAccount{} + +func NewMsgRegisterAccount(owner string, connectionID string) *MsgRegisterAccount { + return &MsgRegisterAccount{ + Owner: owner, + ConnectionId: connectionID, + } +} + +func (msg *MsgRegisterAccount) Route() string { + return RouterKey +} + +func (msg *MsgRegisterAccount) Type() string { + return TypeMsgRegisterAccount +} + +func (msg *MsgRegisterAccount) GetSigners() []sdk.AccAddress { + owner, err := sdk.AccAddressFromBech32(msg.Owner) + if err != nil { + panic(err) + } + return []sdk.AccAddress{owner} +} + +func (msg *MsgRegisterAccount) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +func (msg *MsgRegisterAccount) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.Owner) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid owner address (%s)", err) + } + return nil +} diff --git a/x/icactl/types/message_register_account_test.go b/x/icactl/types/message_register_account_test.go new file mode 100644 index 0000000000..53ee4c929b --- /dev/null +++ b/x/icactl/types/message_register_account_test.go @@ -0,0 +1,39 @@ +package types + +import ( + "testing" + + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/stretchr/testify/require" +) + +func TestMsgRegisterAccount_ValidateBasic(t *testing.T) { + tests := []struct { + name string + msg MsgRegisterAccount + err error + }{ + { + name: "invalid address", + msg: MsgRegisterAccount{ + Owner: "invalid_address", + }, + err: sdkerrors.ErrInvalidAddress, + }, { + name: "valid address", + msg: MsgRegisterAccount{ + Owner: AccAddress(), + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.msg.ValidateBasic() + if tt.err != nil { + require.ErrorIs(t, err, tt.err) + return + } + require.NoError(t, err) + }) + } +} diff --git a/x/icactl/types/message_submit_tx.go b/x/icactl/types/message_submit_tx.go new file mode 100644 index 0000000000..32083ec35b --- /dev/null +++ b/x/icactl/types/message_submit_tx.go @@ -0,0 +1,103 @@ +package types + +import ( + "time" + + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + proto "github.com/gogo/protobuf/proto" +) + +const TypeMsgSubmitTx = "submit_tx" + +var ( + _ sdk.Msg = &MsgSubmitTx{} + _ cdctypes.UnpackInterfacesMessage = &MsgSubmitTx{} +) + +func NewMsgSubmitTx(owner string, connectionID string, msgs []sdk.Msg, timeoutDuration *time.Duration) *MsgSubmitTx { + msgsAny := make([]*cdctypes.Any, len(msgs)) + for i, msg := range msgs { + any, err := cdctypes.NewAnyWithValue(msg) + if err != nil { + panic(err) + } + + msgsAny[i] = any + } + + return &MsgSubmitTx{ + Owner: owner, + ConnectionId: connectionID, + Msgs: msgsAny, + TimeoutDuration: timeoutDuration, + } +} + +func (msg MsgSubmitTx) GetMessages() ([]proto.Message, error) { + msgs := make([]proto.Message, len(msg.Msgs)) + for i, msgAny := range msg.Msgs { + msg, ok := msgAny.GetCachedValue().(sdk.Msg) + if !ok { + return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "messages contains %T which is not a sdk.Msg", msgAny) + } + msgs[i] = msg + } + + return msgs, nil +} + +func (msg MsgSubmitTx) CalculateTimeoutDuration(minTimeoutDuration time.Duration) time.Duration { + var timeoutDuration time.Duration + + if msg.TimeoutDuration != nil && *msg.TimeoutDuration >= minTimeoutDuration { + timeoutDuration = *msg.TimeoutDuration + } else { + timeoutDuration = minTimeoutDuration + } + + return timeoutDuration +} + +func (msg *MsgSubmitTx) Route() string { + return RouterKey +} + +func (msg *MsgSubmitTx) Type() string { + return TypeMsgSubmitTx +} + +func (msg *MsgSubmitTx) GetSigners() []sdk.AccAddress { + owner, err := sdk.AccAddressFromBech32(msg.Owner) + if err != nil { + panic(err) + } + return []sdk.AccAddress{owner} +} + +func (msg *MsgSubmitTx) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +func (msg *MsgSubmitTx) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.Owner) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid owner address (%s)", err) + } + return nil +} + +// UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces +func (msg MsgSubmitTx) UnpackInterfaces(unpacker cdctypes.AnyUnpacker) error { + for _, x := range msg.Msgs { + var msg sdk.Msg + err := unpacker.UnpackAny(x, &msg) + if err != nil { + return err + } + } + + return nil +} diff --git a/x/icactl/types/message_submit_tx_test.go b/x/icactl/types/message_submit_tx_test.go new file mode 100644 index 0000000000..2418414bed --- /dev/null +++ b/x/icactl/types/message_submit_tx_test.go @@ -0,0 +1,39 @@ +package types + +import ( + "testing" + + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/stretchr/testify/require" +) + +func TestMsgSubmitTx_ValidateBasic(t *testing.T) { + tests := []struct { + name string + msg MsgSubmitTx + err error + }{ + { + name: "invalid address", + msg: MsgSubmitTx{ + Owner: "invalid_address", + }, + err: sdkerrors.ErrInvalidAddress, + }, { + name: "valid address", + msg: MsgSubmitTx{ + Owner: AccAddress(), + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.msg.ValidateBasic() + if tt.err != nil { + require.ErrorIs(t, err, tt.err) + return + } + require.NoError(t, err) + }) + } +} diff --git a/x/icactl/types/params.go b/x/icactl/types/params.go new file mode 100644 index 0000000000..4a08bbbb64 --- /dev/null +++ b/x/icactl/types/params.go @@ -0,0 +1,69 @@ +package types + +import ( + "fmt" + "time" + + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" + "gopkg.in/yaml.v2" +) + +var _ paramtypes.ParamSet = (*Params)(nil) + +var ( + KeyMinTimeoutDuration = []byte("MinTimeoutDuration") + DefaultMinTimeoutDuration = time.Hour +) + +// ParamKeyTable the param key table for launch module +func ParamKeyTable() paramtypes.KeyTable { + return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) +} + +// NewParams creates a new Params instance +func NewParams( + minTimeoutDuration time.Duration, +) Params { + return Params{ + MinTimeoutDuration: minTimeoutDuration, + } +} + +// DefaultParams returns a default set of parameters +func DefaultParams() Params { + return NewParams( + DefaultMinTimeoutDuration, + ) +} + +// ParamSetPairs get the params.ParamSet +func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { + return paramtypes.ParamSetPairs{ + paramtypes.NewParamSetPair(KeyMinTimeoutDuration, &p.MinTimeoutDuration, validateMinTimeoutDuration), + } +} + +// Validate validates the set of params +func (p Params) Validate() error { + if err := validateMinTimeoutDuration(p.MinTimeoutDuration); err != nil { + return err + } + + return nil +} + +// String implements the Stringer interface. +func (p Params) String() string { + out, _ := yaml.Marshal(p) // nolint:errcheck + return string(out) +} + +// validateMinTimeoutDuration validates the MinTimeoutDuration param +func validateMinTimeoutDuration(v interface{}) error { + _, ok := v.(time.Duration) + if !ok { + return fmt.Errorf("invalid parameter type: %T", v) + } + + return nil +} diff --git a/x/icactl/types/params.pb.go b/x/icactl/types/params.pb.go new file mode 100644 index 0000000000..8c93cbafe0 --- /dev/null +++ b/x/icactl/types/params.pb.go @@ -0,0 +1,328 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: icactl/v1/params.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/gogo/protobuf/proto" + github_com_gogo_protobuf_types "github.com/gogo/protobuf/types" + _ "google.golang.org/protobuf/types/known/durationpb" + io "io" + math "math" + math_bits "math/bits" + time "time" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf +var _ = time.Kitchen + +// 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 parameters for the module. +type Params struct { + // minTimeoutDuration defines the minimum value of packet timeout when submitting transactions to host chain on + // behalf of interchain account + MinTimeoutDuration time.Duration `protobuf:"bytes,1,opt,name=minTimeoutDuration,proto3,stdduration" json:"minTimeoutDuration" yaml:"min_timeout_duration"` +} + +func (m *Params) Reset() { *m = Params{} } +func (*Params) ProtoMessage() {} +func (*Params) Descriptor() ([]byte, []int) { + return fileDescriptor_b185dbdbffe0473b, []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) GetMinTimeoutDuration() time.Duration { + if m != nil { + return m.MinTimeoutDuration + } + return 0 +} + +func init() { + proto.RegisterType((*Params)(nil), "cronos.icactl.v1.Params") +} + +func init() { proto.RegisterFile("icactl/v1/params.proto", fileDescriptor_b185dbdbffe0473b) } + +var fileDescriptor_b185dbdbffe0473b = []byte{ + // 262 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0xcb, 0x4c, 0x4e, 0x4c, + 0x2e, 0xc9, 0xd1, 0x2f, 0x33, 0xd4, 0x2f, 0x48, 0x2c, 0x4a, 0xcc, 0x2d, 0xd6, 0x2b, 0x28, 0xca, + 0x2f, 0xc9, 0x17, 0x12, 0x48, 0x2e, 0xca, 0xcf, 0xcb, 0x2f, 0xd6, 0x83, 0x48, 0xeb, 0x95, 0x19, + 0x4a, 0xc9, 0xa5, 0xe7, 0xe7, 0xa7, 0xe7, 0xa4, 0xea, 0x83, 0xe5, 0x93, 0x4a, 0xd3, 0xf4, 0x53, + 0x4a, 0x8b, 0x12, 0x4b, 0x32, 0xf3, 0xf3, 0x20, 0x3a, 0xa4, 0x44, 0xd2, 0xf3, 0xd3, 0xf3, 0xc1, + 0x4c, 0x7d, 0x10, 0x0b, 0x22, 0xaa, 0xd4, 0xc4, 0xc8, 0xc5, 0x16, 0x00, 0x36, 0x58, 0xa8, 0x88, + 0x4b, 0x28, 0x37, 0x33, 0x2f, 0x24, 0x33, 0x37, 0x35, 0xbf, 0xb4, 0xc4, 0x05, 0xaa, 0x59, 0x82, + 0x51, 0x81, 0x51, 0x83, 0xdb, 0x48, 0x52, 0x0f, 0x62, 0xba, 0x1e, 0xcc, 0x74, 0x3d, 0x98, 0x02, + 0x27, 0xf5, 0x13, 0xf7, 0xe4, 0x19, 0x3e, 0xdd, 0x93, 0x97, 0xae, 0x4c, 0xcc, 0xcd, 0xb1, 0x52, + 0xca, 0xcd, 0xcc, 0x8b, 0x2f, 0x81, 0x98, 0x11, 0x0f, 0x73, 0x81, 0xd2, 0x8c, 0xfb, 0xf2, 0x8c, + 0x41, 0x58, 0x4c, 0xb7, 0x62, 0x99, 0xb1, 0x40, 0x9e, 0xc1, 0xc9, 0xef, 0xc4, 0x23, 0x39, 0xc6, + 0x0b, 0x8f, 0xe4, 0x18, 0x1f, 0x3c, 0x92, 0x63, 0x9c, 0xf0, 0x58, 0x8e, 0xe1, 0xc2, 0x63, 0x39, + 0x86, 0x1b, 0x8f, 0xe5, 0x18, 0xa2, 0x4c, 0xd2, 0x33, 0x4b, 0x32, 0x4a, 0x93, 0xf4, 0x92, 0xf3, + 0x73, 0xf5, 0x93, 0x8b, 0x2a, 0x0b, 0x4a, 0xf2, 0x75, 0xf3, 0x8b, 0xd2, 0x75, 0x93, 0x33, 0x12, + 0x33, 0xf3, 0xf4, 0x21, 0x41, 0xa0, 0x5f, 0x66, 0xa4, 0x5f, 0xa1, 0x0f, 0x0d, 0xa6, 0x92, 0xca, + 0x82, 0xd4, 0xe2, 0x24, 0x36, 0xb0, 0x2b, 0x8d, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0xfe, 0xf3, + 0xaa, 0xc3, 0x3d, 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 + n1, err1 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.MinTimeoutDuration, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.MinTimeoutDuration):]) + if err1 != nil { + return 0, err1 + } + i -= n1 + i = encodeVarintParams(dAtA, i, uint64(n1)) + 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 + l = github_com_gogo_protobuf_types.SizeOfStdDuration(m.MinTimeoutDuration) + n += 1 + l + sovParams(uint64(l)) + 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 MinTimeoutDuration", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_gogo_protobuf_types.StdDurationUnmarshal(&m.MinTimeoutDuration, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + 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/icactl/types/query.pb.go b/x/icactl/types/query.pb.go new file mode 100644 index 0000000000..c8fa3a3fc9 --- /dev/null +++ b/x/icactl/types/query.pb.go @@ -0,0 +1,978 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: icactl/v1/query.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types/query" + _ "github.com/cosmos/gogoproto/gogoproto" + grpc1 "github.com/gogo/protobuf/grpc" + proto "github.com/gogo/protobuf/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_79bf854812a695aa, []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_79bf854812a695aa, []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{} +} + +// QueryInterchainAccountAddressRequest defines the request for the InterchainAccountAddress query. +type QueryInterchainAccountAddressRequest struct { + ConnectionId string `protobuf:"bytes,1,opt,name=connectionId,proto3" json:"connectionId,omitempty" yaml:"connection_id"` + Owner string `protobuf:"bytes,2,opt,name=owner,proto3" json:"owner,omitempty"` +} + +func (m *QueryInterchainAccountAddressRequest) Reset() { *m = QueryInterchainAccountAddressRequest{} } +func (m *QueryInterchainAccountAddressRequest) String() string { return proto.CompactTextString(m) } +func (*QueryInterchainAccountAddressRequest) ProtoMessage() {} +func (*QueryInterchainAccountAddressRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_79bf854812a695aa, []int{2} +} +func (m *QueryInterchainAccountAddressRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryInterchainAccountAddressRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryInterchainAccountAddressRequest.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 *QueryInterchainAccountAddressRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryInterchainAccountAddressRequest.Merge(m, src) +} +func (m *QueryInterchainAccountAddressRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryInterchainAccountAddressRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryInterchainAccountAddressRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryInterchainAccountAddressRequest proto.InternalMessageInfo + +func (m *QueryInterchainAccountAddressRequest) GetConnectionId() string { + if m != nil { + return m.ConnectionId + } + return "" +} + +func (m *QueryInterchainAccountAddressRequest) GetOwner() string { + if m != nil { + return m.Owner + } + return "" +} + +// QueryInterchainAccountAddressResponse defines the response for the InterchainAccountAddress query. +type QueryInterchainAccountAddressResponse struct { + InterchainAccountAddress string `protobuf:"bytes,1,opt,name=interchainAccountAddress,proto3" json:"interchainAccountAddress,omitempty"` +} + +func (m *QueryInterchainAccountAddressResponse) Reset() { *m = QueryInterchainAccountAddressResponse{} } +func (m *QueryInterchainAccountAddressResponse) String() string { return proto.CompactTextString(m) } +func (*QueryInterchainAccountAddressResponse) ProtoMessage() {} +func (*QueryInterchainAccountAddressResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_79bf854812a695aa, []int{3} +} +func (m *QueryInterchainAccountAddressResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryInterchainAccountAddressResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryInterchainAccountAddressResponse.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 *QueryInterchainAccountAddressResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryInterchainAccountAddressResponse.Merge(m, src) +} +func (m *QueryInterchainAccountAddressResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryInterchainAccountAddressResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryInterchainAccountAddressResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryInterchainAccountAddressResponse proto.InternalMessageInfo + +func (m *QueryInterchainAccountAddressResponse) GetInterchainAccountAddress() string { + if m != nil { + return m.InterchainAccountAddress + } + return "" +} + +func init() { + proto.RegisterType((*QueryParamsRequest)(nil), "cronos.icactl.v1.QueryParamsRequest") + proto.RegisterType((*QueryParamsResponse)(nil), "cronos.icactl.v1.QueryParamsResponse") + proto.RegisterType((*QueryInterchainAccountAddressRequest)(nil), "cronos.icactl.v1.QueryInterchainAccountAddressRequest") + proto.RegisterType((*QueryInterchainAccountAddressResponse)(nil), "cronos.icactl.v1.QueryInterchainAccountAddressResponse") +} + +func init() { proto.RegisterFile("icactl/v1/query.proto", fileDescriptor_79bf854812a695aa) } + +var fileDescriptor_79bf854812a695aa = []byte{ + // 459 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x52, 0x41, 0x6b, 0x13, 0x41, + 0x14, 0xce, 0x06, 0x1b, 0x70, 0xf4, 0x20, 0x63, 0x94, 0x65, 0x91, 0x6d, 0x59, 0x5a, 0x10, 0xa1, + 0x3b, 0x24, 0x4a, 0x85, 0xe2, 0xa5, 0x11, 0x0f, 0x45, 0x14, 0xdd, 0xa3, 0x97, 0x30, 0x99, 0x0c, + 0xdb, 0x81, 0x64, 0xde, 0x76, 0x66, 0x76, 0xeb, 0x5a, 0x7a, 0xf1, 0x17, 0x08, 0xfe, 0xa9, 0x1e, + 0x0b, 0x5e, 0x0a, 0x42, 0x91, 0xc4, 0x5f, 0xe0, 0x2f, 0x90, 0x9d, 0xd9, 0x10, 0x9b, 0xb0, 0x04, + 0x6f, 0xbb, 0xef, 0xfb, 0xbe, 0xf7, 0x7d, 0xef, 0xbd, 0x41, 0x8f, 0x04, 0xa3, 0xcc, 0x4c, 0x48, + 0xd1, 0x23, 0xa7, 0x39, 0x57, 0x65, 0x9c, 0x29, 0x30, 0x80, 0x1f, 0x30, 0x05, 0x12, 0x74, 0xec, + 0xd0, 0xb8, 0xe8, 0x05, 0xdd, 0x14, 0x52, 0xb0, 0x20, 0xa9, 0xbe, 0x1c, 0x2f, 0x78, 0x92, 0x02, + 0xa4, 0x13, 0x4e, 0x68, 0x26, 0x08, 0x95, 0x12, 0x0c, 0x35, 0x02, 0xa4, 0xae, 0xd1, 0x67, 0x0c, + 0xf4, 0x14, 0x34, 0x19, 0x51, 0xcd, 0x5d, 0x7b, 0x52, 0xf4, 0x46, 0xdc, 0xd0, 0x1e, 0xc9, 0x68, + 0x2a, 0xa4, 0x25, 0xd7, 0xdc, 0xc7, 0xcb, 0x20, 0x19, 0x55, 0x74, 0x5a, 0xf7, 0x88, 0xba, 0x08, + 0x7f, 0xac, 0x94, 0x1f, 0x6c, 0x31, 0xe1, 0xa7, 0x39, 0xd7, 0x26, 0x7a, 0x87, 0x1e, 0xde, 0xaa, + 0xea, 0x0c, 0xa4, 0xe6, 0xf8, 0x00, 0x75, 0x9c, 0xd8, 0xf7, 0x76, 0xbc, 0xa7, 0xf7, 0xfa, 0x7e, + 0xbc, 0x3a, 0x47, 0xec, 0x14, 0x83, 0x3b, 0x97, 0x37, 0xdb, 0xad, 0xa4, 0x66, 0x47, 0x5f, 0xd0, + 0xae, 0x6d, 0x77, 0x2c, 0x0d, 0x57, 0xec, 0x84, 0x0a, 0x79, 0xc4, 0x18, 0xe4, 0xd2, 0x1c, 0x8d, + 0xc7, 0x8a, 0xeb, 0x85, 0x2d, 0x7e, 0x85, 0xee, 0x33, 0x90, 0x92, 0xb3, 0x2a, 0xf8, 0xf1, 0xd8, + 0xba, 0xdc, 0x1d, 0xf8, 0x7f, 0x6e, 0xb6, 0xbb, 0x25, 0x9d, 0x4e, 0x0e, 0xa3, 0x25, 0x3a, 0x14, + 0xe3, 0x28, 0xb9, 0xc5, 0xc6, 0x5d, 0xb4, 0x05, 0x67, 0x92, 0x2b, 0xbf, 0x5d, 0xc9, 0x12, 0xf7, + 0x13, 0x31, 0xb4, 0xb7, 0xc1, 0xbb, 0x1e, 0xee, 0x10, 0xf9, 0xa2, 0x81, 0xe3, 0x82, 0x24, 0x8d, + 0x78, 0xff, 0x67, 0x1b, 0x6d, 0x59, 0x17, 0x7c, 0x86, 0x3a, 0x6e, 0x05, 0x78, 0x77, 0x7d, 0x39, + 0xeb, 0x9b, 0x0e, 0xf6, 0x36, 0xb0, 0x5c, 0xb8, 0x68, 0xe7, 0xeb, 0x8f, 0xdf, 0xdf, 0xdb, 0x01, + 0xf6, 0x89, 0xa3, 0x93, 0xd5, 0x73, 0xe2, 0x6b, 0x0f, 0xf9, 0x4d, 0x33, 0xe2, 0x83, 0x06, 0x97, + 0x0d, 0x07, 0x09, 0x5e, 0xfe, 0xb7, 0xae, 0xce, 0xfb, 0xd6, 0xe6, 0x7d, 0x83, 0x5f, 0xaf, 0xe7, + 0x5d, 0x2e, 0x71, 0x48, 0x9d, 0x78, 0x48, 0x9d, 0x9a, 0x9c, 0xff, 0x7b, 0xcf, 0x0b, 0x72, 0x6e, + 0x2f, 0x78, 0x31, 0x78, 0x7f, 0x39, 0x0b, 0xbd, 0xab, 0x59, 0xe8, 0xfd, 0x9a, 0x85, 0xde, 0xb7, + 0x79, 0xd8, 0xba, 0x9a, 0x87, 0xad, 0xeb, 0x79, 0xd8, 0xfa, 0xf4, 0x22, 0x15, 0xe6, 0x24, 0x1f, + 0xc5, 0x0c, 0xa6, 0x84, 0xa9, 0x32, 0x33, 0xb0, 0x0f, 0x2a, 0xdd, 0xb7, 0xdd, 0x17, 0xce, 0x45, + 0x9f, 0x7c, 0x5e, 0xd8, 0x9b, 0x32, 0xe3, 0x7a, 0xd4, 0xb1, 0x4f, 0xff, 0xf9, 0xdf, 0x00, 0x00, + 0x00, 0xff, 0xff, 0x4b, 0x63, 0x5a, 0xb0, 0x9d, 0x03, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// QueryClient is the client API for Query service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type QueryClient interface { + // Parameters queries the parameters of the module. + Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) + // InterchainAccountAddress queries the interchain account address for given `connectionId` and `owner` + InterchainAccountAddress(ctx context.Context, in *QueryInterchainAccountAddressRequest, opts ...grpc.CallOption) (*QueryInterchainAccountAddressResponse, 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, "/cronos.icactl.v1.Query/Params", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) InterchainAccountAddress(ctx context.Context, in *QueryInterchainAccountAddressRequest, opts ...grpc.CallOption) (*QueryInterchainAccountAddressResponse, error) { + out := new(QueryInterchainAccountAddressResponse) + err := c.cc.Invoke(ctx, "/cronos.icactl.v1.Query/InterchainAccountAddress", 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) + // InterchainAccountAddress queries the interchain account address for given `connectionId` and `owner` + InterchainAccountAddress(context.Context, *QueryInterchainAccountAddressRequest) (*QueryInterchainAccountAddressResponse, 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) InterchainAccountAddress(ctx context.Context, req *QueryInterchainAccountAddressRequest) (*QueryInterchainAccountAddressResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method InterchainAccountAddress 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: "/cronos.icactl.v1.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_InterchainAccountAddress_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryInterchainAccountAddressRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).InterchainAccountAddress(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cronos.icactl.v1.Query/InterchainAccountAddress", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).InterchainAccountAddress(ctx, req.(*QueryInterchainAccountAddressRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "cronos.icactl.v1.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Params", + Handler: _Query_Params_Handler, + }, + { + MethodName: "InterchainAccountAddress", + Handler: _Query_InterchainAccountAddress_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "icactl/v1/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 *QueryInterchainAccountAddressRequest) 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 *QueryInterchainAccountAddressRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryInterchainAccountAddressRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Owner) > 0 { + i -= len(m.Owner) + copy(dAtA[i:], m.Owner) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Owner))) + i-- + dAtA[i] = 0x12 + } + if len(m.ConnectionId) > 0 { + i -= len(m.ConnectionId) + copy(dAtA[i:], m.ConnectionId) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ConnectionId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryInterchainAccountAddressResponse) 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 *QueryInterchainAccountAddressResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryInterchainAccountAddressResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.InterchainAccountAddress) > 0 { + i -= len(m.InterchainAccountAddress) + copy(dAtA[i:], m.InterchainAccountAddress) + i = encodeVarintQuery(dAtA, i, uint64(len(m.InterchainAccountAddress))) + 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 *QueryInterchainAccountAddressRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ConnectionId) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.Owner) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryInterchainAccountAddressResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.InterchainAccountAddress) + if l > 0 { + 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 *QueryInterchainAccountAddressRequest) 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: QueryInterchainAccountAddressRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryInterchainAccountAddressRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ConnectionId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ConnectionId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Owner", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Owner = string(dAtA[iNdEx:postIndex]) + 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 *QueryInterchainAccountAddressResponse) 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: QueryInterchainAccountAddressResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryInterchainAccountAddressResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field InterchainAccountAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.InterchainAccountAddress = string(dAtA[iNdEx:postIndex]) + 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/icactl/types/query.pb.gw.go b/x/icactl/types/query.pb.gw.go new file mode 100644 index 0000000000..d2fbff4d0d --- /dev/null +++ b/x/icactl/types/query.pb.gw.go @@ -0,0 +1,276 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: icactl/v1/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 + +} + +func request_Query_InterchainAccountAddress_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryInterchainAccountAddressRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["connectionId"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "connectionId") + } + + protoReq.ConnectionId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "connectionId", err) + } + + val, ok = pathParams["owner"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "owner") + } + + protoReq.Owner, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "owner", err) + } + + msg, err := client.InterchainAccountAddress(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_InterchainAccountAddress_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryInterchainAccountAddressRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["connectionId"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "connectionId") + } + + protoReq.ConnectionId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "connectionId", err) + } + + val, ok = pathParams["owner"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "owner") + } + + protoReq.Owner, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "owner", err) + } + + msg, err := server.InterchainAccountAddress(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_InterchainAccountAddress_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_InterchainAccountAddress_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_InterchainAccountAddress_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_InterchainAccountAddress_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_InterchainAccountAddress_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_InterchainAccountAddress_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{"cronos", "icactl", "v1", "params"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_InterchainAccountAddress_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 1, 0, 4, 1, 5, 5}, []string{"cronos", "icactl", "v1", "interchain_account_address", "connectionId", "owner"}, "", runtime.AssumeColonVerbOpt(false))) +) + +var ( + forward_Query_Params_0 = runtime.ForwardResponseMessage + + forward_Query_InterchainAccountAddress_0 = runtime.ForwardResponseMessage +) diff --git a/x/icactl/types/tx.pb.go b/x/icactl/types/tx.pb.go new file mode 100644 index 0000000000..731f9bd584 --- /dev/null +++ b/x/icactl/types/tx.pb.go @@ -0,0 +1,1155 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: icactl/v1/tx.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + _ "github.com/cosmos/gogoproto/gogoproto" + grpc1 "github.com/gogo/protobuf/grpc" + proto "github.com/gogo/protobuf/proto" + github_com_gogo_protobuf_types "github.com/gogo/protobuf/types" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + _ "google.golang.org/protobuf/types/known/durationpb" + protobuf "google/protobuf" + io "io" + math "math" + math_bits "math/bits" + time "time" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf +var _ = time.Kitchen + +// 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 + +// MsgRegisterAccount defines the request message for MsgRegisterAccount +type MsgRegisterAccount struct { + // owner represents the owner of the interchain account + Owner string `protobuf:"bytes,1,opt,name=owner,proto3" json:"owner,omitempty"` + // connectionId represents the IBC `connectionId` of the host chain + ConnectionId string `protobuf:"bytes,2,opt,name=connectionId,proto3" json:"connectionId,omitempty" yaml:"connection_id"` + Version string `protobuf:"bytes,3,opt,name=version,proto3" json:"version,omitempty"` +} + +func (m *MsgRegisterAccount) Reset() { *m = MsgRegisterAccount{} } +func (m *MsgRegisterAccount) String() string { return proto.CompactTextString(m) } +func (*MsgRegisterAccount) ProtoMessage() {} +func (*MsgRegisterAccount) Descriptor() ([]byte, []int) { + return fileDescriptor_a55f69ec392a1d81, []int{0} +} +func (m *MsgRegisterAccount) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRegisterAccount) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRegisterAccount.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 *MsgRegisterAccount) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRegisterAccount.Merge(m, src) +} +func (m *MsgRegisterAccount) XXX_Size() int { + return m.Size() +} +func (m *MsgRegisterAccount) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRegisterAccount.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRegisterAccount proto.InternalMessageInfo + +func (m *MsgRegisterAccount) GetOwner() string { + if m != nil { + return m.Owner + } + return "" +} + +func (m *MsgRegisterAccount) GetConnectionId() string { + if m != nil { + return m.ConnectionId + } + return "" +} + +func (m *MsgRegisterAccount) GetVersion() string { + if m != nil { + return m.Version + } + return "" +} + +// MsgRegisterAccountResponse defines the response message for MsgRegisterAccount +type MsgRegisterAccountResponse struct { +} + +func (m *MsgRegisterAccountResponse) Reset() { *m = MsgRegisterAccountResponse{} } +func (m *MsgRegisterAccountResponse) String() string { return proto.CompactTextString(m) } +func (*MsgRegisterAccountResponse) ProtoMessage() {} +func (*MsgRegisterAccountResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_a55f69ec392a1d81, []int{1} +} +func (m *MsgRegisterAccountResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRegisterAccountResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRegisterAccountResponse.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 *MsgRegisterAccountResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRegisterAccountResponse.Merge(m, src) +} +func (m *MsgRegisterAccountResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgRegisterAccountResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRegisterAccountResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRegisterAccountResponse proto.InternalMessageInfo + +// MsgSubmitTx defines the request message for MsgSubmitTx +type MsgSubmitTx struct { + // owner represents the owner of the interchain account + Owner string `protobuf:"bytes,1,opt,name=owner,proto3" json:"owner,omitempty"` + // connectionId represents the IBC `connectionId` of the host chain + ConnectionId string `protobuf:"bytes,2,opt,name=connectionId,proto3" json:"connectionId,omitempty" yaml:"connection_id"` + // msgs represents the transactions to be submitted to the host chain + Msgs []*protobuf.Any `protobuf:"bytes,3,rep,name=msgs,proto3" json:"msgs,omitempty"` + // timeoutDuration represents the timeout duration for the IBC packet from last block + TimeoutDuration *time.Duration `protobuf:"bytes,4,opt,name=timeoutDuration,proto3,stdduration" json:"timeoutDuration,omitempty"` +} + +func (m *MsgSubmitTx) Reset() { *m = MsgSubmitTx{} } +func (m *MsgSubmitTx) String() string { return proto.CompactTextString(m) } +func (*MsgSubmitTx) ProtoMessage() {} +func (*MsgSubmitTx) Descriptor() ([]byte, []int) { + return fileDescriptor_a55f69ec392a1d81, []int{2} +} +func (m *MsgSubmitTx) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSubmitTx) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSubmitTx.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 *MsgSubmitTx) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSubmitTx.Merge(m, src) +} +func (m *MsgSubmitTx) XXX_Size() int { + return m.Size() +} +func (m *MsgSubmitTx) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSubmitTx.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSubmitTx proto.InternalMessageInfo + +func (m *MsgSubmitTx) GetOwner() string { + if m != nil { + return m.Owner + } + return "" +} + +func (m *MsgSubmitTx) GetConnectionId() string { + if m != nil { + return m.ConnectionId + } + return "" +} + +func (m *MsgSubmitTx) GetMsgs() []*protobuf.Any { + if m != nil { + return m.Msgs + } + return nil +} + +func (m *MsgSubmitTx) GetTimeoutDuration() *time.Duration { + if m != nil { + return m.TimeoutDuration + } + return nil +} + +// MsgSubmitTxResponse defines the response message for MsgSubmitTx +type MsgSubmitTxResponse struct { +} + +func (m *MsgSubmitTxResponse) Reset() { *m = MsgSubmitTxResponse{} } +func (m *MsgSubmitTxResponse) String() string { return proto.CompactTextString(m) } +func (*MsgSubmitTxResponse) ProtoMessage() {} +func (*MsgSubmitTxResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_a55f69ec392a1d81, []int{3} +} +func (m *MsgSubmitTxResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSubmitTxResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSubmitTxResponse.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 *MsgSubmitTxResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSubmitTxResponse.Merge(m, src) +} +func (m *MsgSubmitTxResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgSubmitTxResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSubmitTxResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSubmitTxResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*MsgRegisterAccount)(nil), "cronos.icactl.v1.MsgRegisterAccount") + proto.RegisterType((*MsgRegisterAccountResponse)(nil), "cronos.icactl.v1.MsgRegisterAccountResponse") + proto.RegisterType((*MsgSubmitTx)(nil), "cronos.icactl.v1.MsgSubmitTx") + proto.RegisterType((*MsgSubmitTxResponse)(nil), "cronos.icactl.v1.MsgSubmitTxResponse") +} + +func init() { proto.RegisterFile("icactl/v1/tx.proto", fileDescriptor_a55f69ec392a1d81) } + +var fileDescriptor_a55f69ec392a1d81 = []byte{ + // 445 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x93, 0x3f, 0x8f, 0xd3, 0x30, + 0x18, 0xc6, 0x6b, 0x5a, 0x38, 0x70, 0x91, 0x0e, 0x99, 0x22, 0xa5, 0x11, 0xe4, 0xaa, 0x08, 0xa4, + 0x0e, 0xd4, 0xd6, 0x15, 0x58, 0x10, 0xcb, 0x55, 0x2c, 0x37, 0x14, 0xa1, 0xc0, 0xc4, 0x72, 0x4a, + 0x5d, 0xe3, 0xb3, 0x68, 0xfc, 0x56, 0xb6, 0x53, 0x9a, 0x95, 0x4f, 0xc0, 0xc8, 0x07, 0x61, 0x66, + 0x46, 0x4c, 0x37, 0x32, 0x01, 0x6a, 0xbf, 0x01, 0x9f, 0x00, 0x35, 0x6e, 0xf8, 0x93, 0x22, 0xc4, + 0x72, 0x5b, 0x9e, 0xfc, 0x1e, 0x3f, 0x79, 0xdf, 0x27, 0x09, 0x26, 0x8a, 0xa7, 0xdc, 0xcd, 0xd8, + 0xe2, 0x90, 0xb9, 0x25, 0x9d, 0x1b, 0x70, 0x40, 0xae, 0x71, 0x03, 0x1a, 0x2c, 0xf5, 0x88, 0x2e, + 0x0e, 0xc3, 0x2e, 0x07, 0x9b, 0x81, 0x3d, 0x29, 0x39, 0xf3, 0xc2, 0x9b, 0xc3, 0xae, 0x04, 0x90, + 0x33, 0xc1, 0x4a, 0x35, 0xc9, 0x5f, 0xb2, 0x54, 0x17, 0x5b, 0x14, 0xd5, 0xd1, 0x34, 0x37, 0xa9, + 0x53, 0xa0, 0xb7, 0xbc, 0x23, 0x41, 0x82, 0x8f, 0xdc, 0x5c, 0xf9, 0xbb, 0xf1, 0x1b, 0x84, 0xc9, + 0xd8, 0xca, 0x44, 0x48, 0x65, 0x9d, 0x30, 0x47, 0x9c, 0x43, 0xae, 0x1d, 0xe9, 0xe0, 0x8b, 0xf0, + 0x5a, 0x0b, 0x13, 0xa0, 0x1e, 0xea, 0x5f, 0x49, 0xbc, 0x20, 0x8f, 0xf0, 0x55, 0x0e, 0x5a, 0x0b, + 0xbe, 0x89, 0x3d, 0x9e, 0x06, 0x17, 0x36, 0x70, 0x14, 0x7c, 0xff, 0x72, 0xd0, 0x29, 0xd2, 0x6c, + 0xf6, 0x30, 0xfe, 0x45, 0x4f, 0xd4, 0x34, 0x4e, 0xfe, 0x70, 0x93, 0x00, 0xef, 0x2d, 0x84, 0xb1, + 0x0a, 0x74, 0xd0, 0x2c, 0x53, 0x2b, 0x19, 0xdf, 0xc4, 0xe1, 0xee, 0x0c, 0x89, 0xb0, 0x73, 0xd0, + 0x56, 0xc4, 0x6b, 0x84, 0xdb, 0x63, 0x2b, 0x9f, 0xe5, 0x93, 0x4c, 0xb9, 0xe7, 0xcb, 0x73, 0x99, + 0xed, 0x01, 0x6e, 0x65, 0x56, 0xda, 0xa0, 0xd9, 0x6b, 0xf6, 0xdb, 0xc3, 0x0e, 0xf5, 0x5d, 0xd2, + 0xaa, 0x4b, 0x7a, 0xa4, 0x8b, 0x51, 0xfb, 0xd3, 0xfb, 0xc1, 0x9e, 0x9d, 0xbe, 0xa2, 0x9b, 0x59, + 0x4b, 0x3b, 0x39, 0xc6, 0xfb, 0x4e, 0x65, 0x02, 0x72, 0xf7, 0x78, 0x5b, 0x76, 0xd0, 0xea, 0xa1, + 0x7e, 0x7b, 0xd8, 0xdd, 0x49, 0xa8, 0x0c, 0xa3, 0xd6, 0xbb, 0xaf, 0x07, 0x28, 0xa9, 0x9f, 0x8b, + 0x6f, 0xe0, 0xeb, 0xbf, 0x2d, 0x59, 0x2d, 0x3f, 0xfc, 0x80, 0x70, 0x73, 0x6c, 0x25, 0x11, 0x78, + 0xbf, 0xfe, 0x8e, 0x6e, 0xd3, 0xfa, 0x97, 0x43, 0x77, 0x5b, 0x0c, 0xef, 0xfe, 0x8f, 0xab, 0x7a, + 0x1c, 0x79, 0x8a, 0x2f, 0xff, 0xec, 0xf9, 0xd6, 0x5f, 0x4f, 0x56, 0x38, 0xbc, 0xf3, 0x4f, 0x5c, + 0x25, 0x8e, 0x9e, 0x7c, 0x5c, 0x45, 0xe8, 0x6c, 0x15, 0xa1, 0x6f, 0xab, 0x08, 0xbd, 0x5d, 0x47, + 0x8d, 0xb3, 0x75, 0xd4, 0xf8, 0xbc, 0x8e, 0x1a, 0x2f, 0xee, 0x4b, 0xe5, 0x4e, 0xf3, 0x09, 0xe5, + 0x90, 0x31, 0x6e, 0x8a, 0xb9, 0x83, 0x01, 0x18, 0x39, 0xe0, 0xa7, 0xa9, 0xd2, 0xcc, 0x67, 0xb3, + 0xc5, 0x90, 0x2d, 0xd9, 0xf6, 0xa7, 0x71, 0xc5, 0x5c, 0xd8, 0xc9, 0xa5, 0xb2, 0xd1, 0x7b, 0x3f, + 0x02, 0x00, 0x00, 0xff, 0xff, 0x67, 0xe5, 0x87, 0x54, 0x4b, 0x03, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// 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 { + // RegisterAccount registers an interchain account on host chain with given `connectionId` + RegisterAccount(ctx context.Context, in *MsgRegisterAccount, opts ...grpc.CallOption) (*MsgRegisterAccountResponse, error) + // SubmitTx submits a transaction to the host chain on behalf of interchain account + SubmitTx(ctx context.Context, in *MsgSubmitTx, opts ...grpc.CallOption) (*MsgSubmitTxResponse, error) +} + +type msgClient struct { + cc grpc1.ClientConn +} + +func NewMsgClient(cc grpc1.ClientConn) MsgClient { + return &msgClient{cc} +} + +func (c *msgClient) RegisterAccount(ctx context.Context, in *MsgRegisterAccount, opts ...grpc.CallOption) (*MsgRegisterAccountResponse, error) { + out := new(MsgRegisterAccountResponse) + err := c.cc.Invoke(ctx, "/cronos.icactl.v1.Msg/RegisterAccount", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) SubmitTx(ctx context.Context, in *MsgSubmitTx, opts ...grpc.CallOption) (*MsgSubmitTxResponse, error) { + out := new(MsgSubmitTxResponse) + err := c.cc.Invoke(ctx, "/cronos.icactl.v1.Msg/SubmitTx", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// MsgServer is the server API for Msg service. +type MsgServer interface { + // RegisterAccount registers an interchain account on host chain with given `connectionId` + RegisterAccount(context.Context, *MsgRegisterAccount) (*MsgRegisterAccountResponse, error) + // SubmitTx submits a transaction to the host chain on behalf of interchain account + SubmitTx(context.Context, *MsgSubmitTx) (*MsgSubmitTxResponse, error) +} + +// UnimplementedMsgServer can be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { +} + +func (*UnimplementedMsgServer) RegisterAccount(ctx context.Context, req *MsgRegisterAccount) (*MsgRegisterAccountResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RegisterAccount not implemented") +} +func (*UnimplementedMsgServer) SubmitTx(ctx context.Context, req *MsgSubmitTx) (*MsgSubmitTxResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SubmitTx not implemented") +} + +func RegisterMsgServer(s grpc1.Server, srv MsgServer) { + s.RegisterService(&_Msg_serviceDesc, srv) +} + +func _Msg_RegisterAccount_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgRegisterAccount) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).RegisterAccount(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cronos.icactl.v1.Msg/RegisterAccount", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).RegisterAccount(ctx, req.(*MsgRegisterAccount)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_SubmitTx_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgSubmitTx) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).SubmitTx(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cronos.icactl.v1.Msg/SubmitTx", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).SubmitTx(ctx, req.(*MsgSubmitTx)) + } + return interceptor(ctx, in, info, handler) +} + +var _Msg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "cronos.icactl.v1.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "RegisterAccount", + Handler: _Msg_RegisterAccount_Handler, + }, + { + MethodName: "SubmitTx", + Handler: _Msg_SubmitTx_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "icactl/v1/tx.proto", +} + +func (m *MsgRegisterAccount) 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 *MsgRegisterAccount) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgRegisterAccount) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Version) > 0 { + i -= len(m.Version) + copy(dAtA[i:], m.Version) + i = encodeVarintTx(dAtA, i, uint64(len(m.Version))) + i-- + dAtA[i] = 0x1a + } + if len(m.ConnectionId) > 0 { + i -= len(m.ConnectionId) + copy(dAtA[i:], m.ConnectionId) + i = encodeVarintTx(dAtA, i, uint64(len(m.ConnectionId))) + i-- + dAtA[i] = 0x12 + } + if len(m.Owner) > 0 { + i -= len(m.Owner) + copy(dAtA[i:], m.Owner) + i = encodeVarintTx(dAtA, i, uint64(len(m.Owner))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgRegisterAccountResponse) 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 *MsgRegisterAccountResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgRegisterAccountResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgSubmitTx) 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 *MsgSubmitTx) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSubmitTx) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.TimeoutDuration != nil { + n1, err1 := github_com_gogo_protobuf_types.StdDurationMarshalTo(*m.TimeoutDuration, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(*m.TimeoutDuration):]) + if err1 != nil { + return 0, err1 + } + i -= n1 + i = encodeVarintTx(dAtA, i, uint64(n1)) + i-- + dAtA[i] = 0x22 + } + if len(m.Msgs) > 0 { + for iNdEx := len(m.Msgs) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Msgs[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + if len(m.ConnectionId) > 0 { + i -= len(m.ConnectionId) + copy(dAtA[i:], m.ConnectionId) + i = encodeVarintTx(dAtA, i, uint64(len(m.ConnectionId))) + i-- + dAtA[i] = 0x12 + } + if len(m.Owner) > 0 { + i -= len(m.Owner) + copy(dAtA[i:], m.Owner) + i = encodeVarintTx(dAtA, i, uint64(len(m.Owner))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgSubmitTxResponse) 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 *MsgSubmitTxResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSubmitTxResponse) 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 *MsgRegisterAccount) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Owner) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.ConnectionId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Version) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgRegisterAccountResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgSubmitTx) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Owner) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.ConnectionId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if len(m.Msgs) > 0 { + for _, e := range m.Msgs { + l = e.Size() + n += 1 + l + sovTx(uint64(l)) + } + } + if m.TimeoutDuration != nil { + l = github_com_gogo_protobuf_types.SizeOfStdDuration(*m.TimeoutDuration) + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgSubmitTxResponse) 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 *MsgRegisterAccount) 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: MsgRegisterAccount: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRegisterAccount: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Owner", 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.Owner = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ConnectionId", 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.ConnectionId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Version", 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.Version = 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 *MsgRegisterAccountResponse) 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: MsgRegisterAccountResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRegisterAccountResponse: 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 *MsgSubmitTx) 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: MsgSubmitTx: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSubmitTx: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Owner", 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.Owner = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ConnectionId", 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.ConnectionId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Msgs", 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 + } + m.Msgs = append(m.Msgs, &protobuf.Any{}) + if err := m.Msgs[len(m.Msgs)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TimeoutDuration", 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 m.TimeoutDuration == nil { + m.TimeoutDuration = new(time.Duration) + } + if err := github_com_gogo_protobuf_types.StdDurationUnmarshal(m.TimeoutDuration, 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 *MsgSubmitTxResponse) 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: MsgSubmitTxResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSubmitTxResponse: 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/icactl/types/types.go b/x/icactl/types/types.go new file mode 100644 index 0000000000..7aec2d129a --- /dev/null +++ b/x/icactl/types/types.go @@ -0,0 +1,13 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/tendermint/tendermint/crypto/ed25519" +) + +// AccAddress returns a sample account address (for use in testing) +func AccAddress() string { + pk := ed25519.GenPrivKey().PubKey() + addr := pk.Address() + return sdk.AccAddress(addr).String() +}