diff --git a/app/keepers/keepers.go b/app/keepers/keepers.go index 4b3ce9c1..24f3c04f 100644 --- a/app/keepers/keepers.go +++ b/app/keepers/keepers.go @@ -81,9 +81,6 @@ import ( "github.com/Nolus-Protocol/nolus-core/x/feerefunder" feerefunderkeeper "github.com/Nolus-Protocol/nolus-core/x/feerefunder/keeper" feetypes "github.com/Nolus-Protocol/nolus-core/x/feerefunder/types" - "github.com/Nolus-Protocol/nolus-core/x/interchainqueries" - interchainquerieskeeper "github.com/Nolus-Protocol/nolus-core/x/interchainqueries/keeper" - interchainqueriestypes "github.com/Nolus-Protocol/nolus-core/x/interchainqueries/types" "github.com/Nolus-Protocol/nolus-core/x/interchaintxs" interchaintxskeeper "github.com/Nolus-Protocol/nolus-core/x/interchaintxs/keeper" interchaintxstypes "github.com/Nolus-Protocol/nolus-core/x/interchaintxs/types" @@ -130,22 +127,20 @@ type AppKeepers struct { TaxKeeper *taxkeeper.Keeper VestingsKeeper *vestingskeeper.Keeper - InterchainTxsKeeper *interchaintxskeeper.Keeper - InterchainQueriesKeeper *interchainquerieskeeper.Keeper - ContractManagerKeeper *contractmanagermodulekeeper.Keeper + InterchainTxsKeeper *interchaintxskeeper.Keeper + ContractManagerKeeper *contractmanagermodulekeeper.Keeper WasmKeeper wasmkeeper.Keeper WasmConfig wasmtypes.WasmConfig // Modules - ContractManagerModule contractmanager.AppModule - InterchainTxsModule interchaintxs.AppModule - InterchainQueriesModule interchainqueries.AppModule - TransferModule transferSudo.AppModule - FeeRefunderModule feerefunder.AppModule - VestingsModule vestings.AppModule - IcaModule ica.AppModule - AuthzModule authzmodule.AppModule + ContractManagerModule contractmanager.AppModule + InterchainTxsModule interchaintxs.AppModule + TransferModule transferSudo.AppModule + FeeRefunderModule feerefunder.AppModule + VestingsModule vestings.AppModule + IcaModule ica.AppModule + AuthzModule authzmodule.AppModule } func (appKeepers *AppKeepers) NewAppKeepers( @@ -385,19 +380,6 @@ func (appKeepers *AppKeepers) NewAppKeepers( appKeepers.IcaModule = ica.NewAppModule(appKeepers.ICAControllerKeeper, appKeepers.ICAHostKeeper) - appKeepers.InterchainQueriesKeeper = interchainquerieskeeper.NewKeeper( - appCodec, - appKeepers.keys[interchainqueriestypes.StoreKey], - appKeepers.keys[interchainqueriestypes.MemStoreKey], - appKeepers.IBCKeeper, - appKeepers.BankKeeper, - appKeepers.ContractManagerKeeper, - interchainquerieskeeper.Verifier{}, - interchainquerieskeeper.TransactionVerifier{}, - authtypes.NewModuleAddress(govtypes.ModuleName).String(), - ) - appKeepers.InterchainQueriesModule = interchainqueries.NewAppModule(appCodec, *appKeepers.InterchainQueriesKeeper, appKeepers.AccountKeeper, appKeepers.BankKeeper) - appKeepers.InterchainTxsKeeper = interchaintxskeeper.NewKeeper( appCodec, appKeepers.keys[interchaintxstypes.StoreKey], @@ -426,7 +408,6 @@ func (appKeepers *AppKeepers) NewAppKeepers( supportedFeatures := []string{"iterator", "stargate", "staking", "neutron", "migrate", "upgrade", "cosmwasm_1_1", "cosmwasm_1_2", "cosmwasm_1_3", "cosmwasm_1_4", "cosmwasm_2_0", "cosmwasm_2_1"} wasmOpts = append(wasmbinding.RegisterCustomPlugins( appKeepers.InterchainTxsKeeper, - appKeepers.InterchainQueriesKeeper, *appKeepers.TransferKeeper, appKeepers.FeeRefunderKeeper, appKeepers.ContractManagerKeeper, @@ -560,7 +541,6 @@ func initParamsKeeper( paramsKeeper.Subspace(govtypes.ModuleName).WithKeyTable(govv1.ParamKeyTable()) //nolint:staticcheck paramsKeeper.Subspace(feetypes.ModuleName).WithKeyTable(feetypes.ParamKeyTable()) paramsKeeper.Subspace(interchaintxstypes.ModuleName).WithKeyTable(interchaintxstypes.ParamKeyTable()) - paramsKeeper.Subspace(interchainqueriestypes.ModuleName).WithKeyTable(interchainqueriestypes.ParamKeyTable()) paramsKeeper.Subspace(vestingstypes.ModuleName) return ¶msKeeper diff --git a/app/keepers/keys.go b/app/keepers/keys.go index 1b8c0287..1ba89e2a 100644 --- a/app/keepers/keys.go +++ b/app/keepers/keys.go @@ -30,7 +30,6 @@ import ( contractmanagermoduletypes "github.com/Nolus-Protocol/nolus-core/x/contractmanager/types" feerefundertypes "github.com/Nolus-Protocol/nolus-core/x/feerefunder/types" - interchainqueriestypes "github.com/Nolus-Protocol/nolus-core/x/interchainqueries/types" interchaintxstypes "github.com/Nolus-Protocol/nolus-core/x/interchaintxs/types" ) @@ -58,7 +57,6 @@ func (appKeepers *AppKeepers) GenerateKeys() { icacontrollertypes.StoreKey, icahosttypes.StoreKey, capabilitytypes.StoreKey, - interchainqueriestypes.StoreKey, contractmanagermoduletypes.StoreKey, interchaintxstypes.StoreKey, wasmtypes.StoreKey, diff --git a/app/modules.go b/app/modules.go index c36ed1ac..f8aca041 100644 --- a/app/modules.go +++ b/app/modules.go @@ -61,8 +61,6 @@ import ( contractmanagermoduletypes "github.com/Nolus-Protocol/nolus-core/x/contractmanager/types" "github.com/Nolus-Protocol/nolus-core/x/feerefunder" feetypes "github.com/Nolus-Protocol/nolus-core/x/feerefunder/types" - "github.com/Nolus-Protocol/nolus-core/x/interchainqueries" - interchainqueriestypes "github.com/Nolus-Protocol/nolus-core/x/interchainqueries/types" "github.com/Nolus-Protocol/nolus-core/x/interchaintxs" interchaintxstypes "github.com/Nolus-Protocol/nolus-core/x/interchaintxs/types" transferSudo "github.com/Nolus-Protocol/nolus-core/x/transfer" @@ -70,18 +68,17 @@ import ( // module account permissions. var maccPerms = map[string][]string{ - authtypes.FeeCollectorName: nil, - distrtypes.ModuleName: nil, - minttypes.ModuleName: {authtypes.Minter}, - stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking}, - stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking}, - govtypes.ModuleName: {authtypes.Burner}, - ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner}, - wasmtypes.ModuleName: {authtypes.Burner}, - vestingstypes.ModuleName: nil, - icatypes.ModuleName: nil, - interchainqueriestypes.ModuleName: nil, - feetypes.ModuleName: nil, + authtypes.FeeCollectorName: nil, + distrtypes.ModuleName: nil, + minttypes.ModuleName: {authtypes.Minter}, + stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking}, + stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking}, + govtypes.ModuleName: {authtypes.Burner}, + ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner}, + wasmtypes.ModuleName: {authtypes.Burner}, + vestingstypes.ModuleName: nil, + icatypes.ModuleName: nil, + feetypes.ModuleName: nil, } // ModuleBasics defines the module BasicManager is in charge of setting up basic, @@ -114,7 +111,6 @@ var ModuleBasics = module.NewBasicManager( tax.AppModuleBasic{}, ica.AppModuleBasic{}, interchaintxs.AppModuleBasic{}, - interchainqueries.AppModuleBasic{}, feerefunder.AppModuleBasic{}, contractmanager.AppModuleBasic{}, authzmodule.AppModuleBasic{}, @@ -157,7 +153,6 @@ func appModules( app.AppKeepers.TransferModule, app.AppKeepers.VestingsModule, app.AppKeepers.IcaModule, - app.AppKeepers.InterchainQueriesModule, app.AppKeepers.InterchainTxsModule, app.AppKeepers.FeeRefunderModule, app.AppKeepers.ContractManagerModule, @@ -191,7 +186,6 @@ func simulationModules( wasm.NewAppModule(appCodec, &app.WasmKeeper, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.MsgServiceRouter(), app.GetSubspace(wasmtypes.ModuleName)), ibc.NewAppModule(app.IBCKeeper), app.AppKeepers.TransferModule, - app.AppKeepers.InterchainQueriesModule, app.AppKeepers.InterchainTxsModule, } } @@ -231,7 +225,6 @@ func orderBeginBlockers() []string { govtypes.ModuleName, icatypes.ModuleName, interchaintxstypes.ModuleName, - interchainqueriestypes.ModuleName, contractmanagermoduletypes.ModuleName, wasmtypes.ModuleName, feetypes.ModuleName, @@ -262,7 +255,6 @@ func orderEndBlockers() []string { vestingstypes.ModuleName, icatypes.ModuleName, interchaintxstypes.ModuleName, - interchainqueriestypes.ModuleName, contractmanagermoduletypes.ModuleName, wasmtypes.ModuleName, feetypes.ModuleName, @@ -300,7 +292,6 @@ func genesisModuleOrder() []string { upgradetypes.ModuleName, ibctransfertypes.ModuleName, icatypes.ModuleName, - interchainqueriestypes.ModuleName, interchaintxstypes.ModuleName, contractmanagermoduletypes.ModuleName, // wasm after ibc transfer diff --git a/app/sim_test.go b/app/sim_test.go index 69121d09..2833071f 100644 --- a/app/sim_test.go +++ b/app/sim_test.go @@ -55,7 +55,6 @@ import ( contractmanagermoduletypes "github.com/Nolus-Protocol/nolus-core/x/contractmanager/types" feetypes "github.com/Nolus-Protocol/nolus-core/x/feerefunder/types" - interchainqueriestypes "github.com/Nolus-Protocol/nolus-core/x/interchainqueries/types" interchaintxstypes "github.com/Nolus-Protocol/nolus-core/x/interchaintxs/types" ) @@ -321,7 +320,6 @@ func TestAppImportExport(t *testing.T) { {keys[taxmoduletypes.StoreKey], newKeys[taxmoduletypes.StoreKey], [][]byte{}}, {keys[interchaintxstypes.StoreKey], newKeys[interchaintxstypes.StoreKey], [][]byte{}}, {keys[contractmanagermoduletypes.StoreKey], newKeys[contractmanagermoduletypes.StoreKey], [][]byte{}}, - {keys[interchainqueriestypes.StoreKey], newKeys[interchainqueriestypes.StoreKey], [][]byte{}}, {keys[icacontrollertypes.StoreKey], newKeys[icacontrollertypes.StoreKey], [][]byte{}}, {keys[wasmtypes.StoreKey], newKeys[wasmtypes.StoreKey], [][]byte{wasmtypes.TXCounterPrefix}}, } diff --git a/app/upgrades/v03/constants.go b/app/upgrades/v03/constants.go deleted file mode 100644 index d3e8abc9..00000000 --- a/app/upgrades/v03/constants.go +++ /dev/null @@ -1,17 +0,0 @@ -package v03 - -import ( - store "cosmossdk.io/store/types" - "github.com/Nolus-Protocol/nolus-core/app/upgrades" -) - -const ( - // UpgradeName defines the on-chain upgrades name. - UpgradeName = "v0.3.0" -) - -var Upgrade = upgrades.Upgrade{ - UpgradeName: UpgradeName, - CreateUpgradeHandler: CreateUpgradeHandler, - StoreUpgrades: store.StoreUpgrades{}, -} diff --git a/app/upgrades/v03/upgrades.go b/app/upgrades/v03/upgrades.go deleted file mode 100644 index 0ef8527e..00000000 --- a/app/upgrades/v03/upgrades.go +++ /dev/null @@ -1,43 +0,0 @@ -package v03 - -import ( - "context" - - "github.com/Nolus-Protocol/nolus-core/app/keepers" - "github.com/Nolus-Protocol/nolus-core/app/params" - - sdkmath "cosmossdk.io/math" - - "github.com/cosmos/cosmos-sdk/codec" - - upgradetypes "cosmossdk.io/x/upgrade/types" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/module" - - icqtypes "github.com/Nolus-Protocol/nolus-core/x/interchainqueries/types" -) - -func CreateUpgradeHandler( - mm *module.Manager, - configurator module.Configurator, - keepers *keepers.AppKeepers, - codec codec.Codec, -) upgradetypes.UpgradeHandler { - return func(c context.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { - ctx := sdk.UnwrapSDKContext(c) - - ctx.Logger().Info("Upgrade handler execution...") - ctx.Logger().Info("Running migrations") - interchainQueriesParams := icqtypes.Params{ - QuerySubmitTimeout: uint64(1036800), - QueryDeposit: sdk.NewCoins(sdk.NewCoin(params.BaseCoinUnit, sdkmath.NewInt(1000000))), - TxQueryRemovalLimit: uint64(10000), - } - err := keepers.InterchainQueriesKeeper.SetParams(ctx, interchainQueriesParams) - if err != nil { - return nil, err - } - - return mm.RunMigrations(ctx, configurator, fromVM) //nolint:contextcheck - } -} diff --git a/app/upgrades/v04/constants.go b/app/upgrades/v04/constants.go deleted file mode 100644 index 01c87039..00000000 --- a/app/upgrades/v04/constants.go +++ /dev/null @@ -1,22 +0,0 @@ -package v04 - -import ( - store "cosmossdk.io/store/types" - "github.com/Nolus-Protocol/nolus-core/app/upgrades" - vestingstypes "github.com/Nolus-Protocol/nolus-core/x/vestings/types" -) - -const ( - // UpgradeName defines the on-chain upgrades name. - UpgradeName = "v0.4.0" -) - -var Upgrade = upgrades.Upgrade{ - UpgradeName: UpgradeName, - CreateUpgradeHandler: CreateUpgradeHandler, - StoreUpgrades: store.StoreUpgrades{ - Added: []string{ - vestingstypes.ModuleName, - }, - }, -} diff --git a/app/upgrades/v04/upgrades.go b/app/upgrades/v04/upgrades.go deleted file mode 100644 index 3852d5d8..00000000 --- a/app/upgrades/v04/upgrades.go +++ /dev/null @@ -1,27 +0,0 @@ -package v04 - -import ( - "context" - - "github.com/Nolus-Protocol/nolus-core/app/keepers" - - upgradetypes "cosmossdk.io/x/upgrade/types" - "github.com/cosmos/cosmos-sdk/codec" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/module" -) - -func CreateUpgradeHandler( - mm *module.Manager, - configurator module.Configurator, - keepers *keepers.AppKeepers, - codec codec.Codec, -) upgradetypes.UpgradeHandler { - return func(c context.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { - ctx := sdk.UnwrapSDKContext(c) - - ctx.Logger().Info("Upgrade handler execution...") - ctx.Logger().Info("Running migrations") - return mm.RunMigrations(ctx, configurator, fromVM) //nolint:contextcheck - } -} diff --git a/app/upgrades/v041/constants.go b/app/upgrades/v041/constants.go deleted file mode 100644 index 9bfd4e34..00000000 --- a/app/upgrades/v041/constants.go +++ /dev/null @@ -1,19 +0,0 @@ -package v041 - -import ( - store "cosmossdk.io/store/types" - "github.com/Nolus-Protocol/nolus-core/app/upgrades" -) - -const ( - // UpgradeName defines the on-chain upgrades name. - UpgradeName = "v0.4.1" -) - -var Upgrade = upgrades.Upgrade{ - UpgradeName: UpgradeName, - CreateUpgradeHandler: CreateUpgradeHandler, - StoreUpgrades: store.StoreUpgrades{ - Added: []string{}, - }, -} diff --git a/app/upgrades/v041/upgrades.go b/app/upgrades/v041/upgrades.go deleted file mode 100644 index 5cc47d04..00000000 --- a/app/upgrades/v041/upgrades.go +++ /dev/null @@ -1,27 +0,0 @@ -package v041 - -import ( - "context" - - "github.com/Nolus-Protocol/nolus-core/app/keepers" - - upgradetypes "cosmossdk.io/x/upgrade/types" - "github.com/cosmos/cosmos-sdk/codec" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/module" -) - -func CreateUpgradeHandler( - mm *module.Manager, - configurator module.Configurator, - keepers *keepers.AppKeepers, - codec codec.Codec, -) upgradetypes.UpgradeHandler { - return func(c context.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { - ctx := sdk.UnwrapSDKContext(c) - - ctx.Logger().Info("Upgrade handler execution...") - ctx.Logger().Info("Running migrations") - return mm.RunMigrations(ctx, configurator, fromVM) //nolint:contextcheck - } -} diff --git a/app/upgrades/v042/constants.go b/app/upgrades/v042/constants.go deleted file mode 100644 index 0b194668..00000000 --- a/app/upgrades/v042/constants.go +++ /dev/null @@ -1,22 +0,0 @@ -package v042 - -import ( - store "cosmossdk.io/store/types" - "github.com/Nolus-Protocol/nolus-core/app/upgrades" - "github.com/cosmos/cosmos-sdk/x/authz" -) - -const ( - // UpgradeName defines the on-chain upgrades name. - UpgradeName = "v0.4.2" -) - -var Upgrade = upgrades.Upgrade{ - UpgradeName: UpgradeName, - CreateUpgradeHandler: CreateUpgradeHandler, - StoreUpgrades: store.StoreUpgrades{ - Added: []string{ - authz.ModuleName, - }, - }, -} diff --git a/app/upgrades/v042/upgrades.go b/app/upgrades/v042/upgrades.go deleted file mode 100644 index d2266238..00000000 --- a/app/upgrades/v042/upgrades.go +++ /dev/null @@ -1,22 +0,0 @@ -package v042 - -import ( - "context" - - "github.com/Nolus-Protocol/nolus-core/app/keepers" - - upgradetypes "cosmossdk.io/x/upgrade/types" - "github.com/cosmos/cosmos-sdk/codec" - "github.com/cosmos/cosmos-sdk/types/module" -) - -func CreateUpgradeHandler( - mm *module.Manager, - configurator module.Configurator, - keepers *keepers.AppKeepers, - codec codec.Codec, -) upgradetypes.UpgradeHandler { - return func(ctx context.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { - return mm.RunMigrations(ctx, configurator, fromVM) - } -} diff --git a/app/upgrades/v05/constants.go b/app/upgrades/v05/constants.go deleted file mode 100644 index ce01369c..00000000 --- a/app/upgrades/v05/constants.go +++ /dev/null @@ -1,25 +0,0 @@ -package v05 - -import ( - "github.com/Nolus-Protocol/nolus-core/app/upgrades" - - store "cosmossdk.io/store/types" - consensusparamstypes "github.com/cosmos/cosmos-sdk/x/consensus/types" - crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types" -) - -const ( - // UpgradeName defines the on-chain upgrades name. - UpgradeName = "v0.5.0" -) - -var Upgrade = upgrades.Upgrade{ - UpgradeName: UpgradeName, - CreateUpgradeHandler: CreateUpgradeHandler, - StoreUpgrades: store.StoreUpgrades{ - Added: []string{ - consensusparamstypes.ModuleName, - crisistypes.ModuleName, - }, - }, -} diff --git a/app/upgrades/v05/legacy_subspaces.go b/app/upgrades/v05/legacy_subspaces.go deleted file mode 100644 index 4b18635b..00000000 --- a/app/upgrades/v05/legacy_subspaces.go +++ /dev/null @@ -1,59 +0,0 @@ -package v05 - -import ( - "github.com/cosmos/cosmos-sdk/baseapp" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types" - distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" - govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" - govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" - paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper" - paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" - slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" - stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - icacontrollertypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller/types" - - minttypes "github.com/Nolus-Protocol/nolus-core/x/mint/types" - taxmoduletypes "github.com/Nolus-Protocol/nolus-core/x/tax/types" -) - -func getLegacySubspaces(paramsKeeper *paramskeeper.Keeper) paramstypes.Subspace { - // Set param key table for params module migration - for _, subspace := range paramsKeeper.GetSubspaces() { - subspace := subspace - - var keyTable paramstypes.KeyTable - switch subspace.Name() { - case authtypes.ModuleName: - keyTable = authtypes.ParamKeyTable() //nolint:staticcheck - case taxmoduletypes.ModuleName: - keyTable = taxmoduletypes.ParamKeyTable() //nolint:staticcheck - case banktypes.ModuleName: - keyTable = banktypes.ParamKeyTable() //nolint:staticcheck - case stakingtypes.ModuleName: - keyTable = stakingtypes.ParamKeyTable() //nolint:staticcheck - case minttypes.ModuleName: - keyTable = minttypes.ParamKeyTable() //nolint:staticcheck - case distrtypes.ModuleName: - keyTable = distrtypes.ParamKeyTable() //nolint:staticcheck - case slashingtypes.ModuleName: - keyTable = slashingtypes.ParamKeyTable() //nolint:staticcheck - case crisistypes.ModuleName: - keyTable = crisistypes.ParamKeyTable() //nolint:staticcheck - case govtypes.ModuleName: - keyTable = govv1.ParamKeyTable() //nolint:staticcheck - case icacontrollertypes.SubModuleName: - keyTable = icacontrollertypes.ParamKeyTable() //nolint:staticcheck - // default modules have not migrated away from x/params or have no params to migrate: ibcexported.ModuleName, ibctransfertypes.ModuleName,vestingstypes.ModuleName - default: - continue - } - - if !subspace.HasKeyTable() { - subspace.WithKeyTable(keyTable) - } - } - - return paramsKeeper.Subspace(baseapp.Paramspace).WithKeyTable(paramstypes.ConsensusParamsKeyTable()) -} diff --git a/app/upgrades/v05/upgrades.go b/app/upgrades/v05/upgrades.go deleted file mode 100644 index 6b4bf2ca..00000000 --- a/app/upgrades/v05/upgrades.go +++ /dev/null @@ -1,290 +0,0 @@ -package v05 - -import ( - "context" - "fmt" - - "github.com/Nolus-Protocol/nolus-core/app/keepers" - "github.com/Nolus-Protocol/nolus-core/app/params" - minttypes "github.com/Nolus-Protocol/nolus-core/x/mint/types" - taxtypes "github.com/Nolus-Protocol/nolus-core/x/tax/types" - - "cosmossdk.io/math" - storetypes "cosmossdk.io/store/types" - upgradetypes "cosmossdk.io/x/upgrade/types" - "github.com/cosmos/cosmos-sdk/baseapp" - "github.com/cosmos/cosmos-sdk/codec" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/module" - paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper" - stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" - icaMigrations "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller/migrations/v6" - exported "github.com/cosmos/ibc-go/v8/modules/core/exported" - ibctmmigrations "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint/migrations" - - contractmanagerkeeper "github.com/Nolus-Protocol/nolus-core/x/contractmanager/keeper" - contractmanagertypes "github.com/Nolus-Protocol/nolus-core/x/contractmanager/types" - feerefundertypes "github.com/Nolus-Protocol/nolus-core/x/feerefunder/types" - icqtypes "github.com/Nolus-Protocol/nolus-core/x/interchainqueries/types" - interchaintxstypes "github.com/Nolus-Protocol/nolus-core/x/interchaintxs/types" - - wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" -) - -func CreateUpgradeHandler( - mm *module.Manager, - configurator module.Configurator, - keepers *keepers.AppKeepers, - codec codec.Codec, -) upgradetypes.UpgradeHandler { - return func(c context.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { - ctx := sdk.UnwrapSDKContext(c) - - ctx.Logger().Info("running upgrade handler") - - // ibc v4-to-v5 - // -- nothing -- - - // ibc v5-to-v6 - ctx.Logger().Info("migrating ics27 channel capability") - err := icaMigrations.MigrateICS27ChannelCapability( - ctx, - codec, - keepers.GetKey(capabilitytypes.StoreKey), - keepers.CapabilityKeeper, - interchaintxstypes.ModuleName, - ) - if err != nil { - return nil, err - } - - // ibc v6-to-v7 - // (optional) prune expired tendermint consensus states to save storage space - ctx.Logger().Info("pruning expired tendermint consensus states for ibc clients") - _, err = ibctmmigrations.PruneExpiredConsensusStates(ctx, codec, keepers.IBCKeeper.ClientKeeper) - if err != nil { - return nil, err - } - - // ibc v7-to-v7.1 - // explicitly update the IBC 02-client params, adding the localhost client type - ctx.Logger().Info("adding localhost client to IBC params") - params := keepers.IBCKeeper.ClientKeeper.GetParams(ctx) - params.AllowedClients = append(params.AllowedClients, exported.Localhost) - keepers.IBCKeeper.ClientKeeper.SetParams(ctx, params) - - // sdk v45-to-v46 - // -- nothing -- - - // sdk v46-to-v47 - // initialize param subspaces for params migration - baseAppLegacySS := getLegacySubspaces(keepers.ParamsKeeper) - // Migrate Tendermint consensus parameters from x/params module to a dedicated x/consensus module. - ctx.Logger().Info("migrating tendermint x/consensus params") - err = baseapp.MigrateParams(ctx, baseAppLegacySS, keepers.ConsensusParamsKeeper.ParamsStore) - if err != nil { - return nil, err - } - - ctx.Logger().Info("running module manager migrations") - - ctx.Logger().Info(fmt.Sprintf("[MM] pre migrate version map: %v", fromVM)) - newVersionMap, err := mm.RunMigrations(ctx, configurator, fromVM) //nolint:contextcheck - if err != nil { - return nil, err - } - ctx.Logger().Info(fmt.Sprintf("[MM] post migrate version map: %v", newVersionMap)) - - ctx.Logger().Info("setting x/staking min commission rate to 5%") - if err = setInitialMinCommissionRate(ctx, keepers); err != nil { //nolint:contextcheck - return nil, err - } - - ctx.Logger().Info("setting x/gov min initial deposit ratio to 25%") - if err = setMinInitialDepositRatio(ctx, keepers); err != nil { //nolint:contextcheck - return nil, err - } - - ctx.Logger().Info("Migrating feerefunder module parameters...") - if err := migrateFeeRefunderParams(ctx, *keepers.ParamsKeeper, keepers.GetKey(feerefundertypes.StoreKey), codec); err != nil { - return nil, err - } - - ctx.Logger().Info("Migrating interchainqueries module parameters...") - if err := migrateInterchainQueriesParams(ctx, *keepers.ParamsKeeper, keepers.GetKey(icqtypes.StoreKey), codec); err != nil { - return nil, err - } - - ctx.Logger().Info("Migrating interchaintxs module parameters...") - if err := setInterchainTxsParams(ctx, *keepers.ParamsKeeper, keepers.GetKey(interchaintxstypes.StoreKey), keepers.GetKey(wasmtypes.StoreKey), codec); err != nil { - return nil, err - } - - ctx.Logger().Info("Migrating mint module parameters...") - if err := migrateMintParams(ctx, *keepers.ParamsKeeper, keepers.GetKey(minttypes.StoreKey), codec); err != nil { - return nil, err - } - - ctx.Logger().Info("Migrating tax module parameters...") - if err := migrateTaxParams(ctx, *keepers.ParamsKeeper, keepers.GetKey(taxtypes.StoreKey), codec); err != nil { - return nil, err - } - - ctx.Logger().Info("Setting sudo callback limit...") - err = setContractManagerParams(ctx, *keepers.ContractManagerKeeper) //nolint:contextcheck - if err != nil { - return nil, err - } - - ctx.Logger().Info(` -$$\ $$\ $$\ $$$$$$\ $$$$$$$\ $$$$$$\ -$$$\ $$ | $$ | $$$ __$$\ $$ ____| $$$ __$$\ -$$$$\ $$ | $$$$$$\ $$ |$$\ $$\ $$$$$$$\ $$\ $$\ $$$$\ $$ | $$ | $$$$\ $$ | -$$ $$\$$ |$$ __$$\ $$ |$$ | $$ |$$ _____| \$$\ $$ |$$\$$\$$ | $$$$$$$\ $$\$$\$$ | -$$ \$$$$ |$$ / $$ |$$ |$$ | $$ |\$$$$$$\ \$$\$$ / $$ \$$$$ | \_____$$\ $$ \$$$$ | -$$ |\$$$ |$$ | $$ |$$ |$$ | $$ | \____$$\ \$$$ / $$ |\$$$ | $$\ $$ | $$ |\$$$ | -$$ | \$$ |\$$$$$$ |$$ |\$$$$$$ |$$$$$$$ | \$ / \$$$$$$ /$$\\$$$$$$ |$$\\$$$$$$ / -\__| \__| \______/ \__| \______/ \_______/ \_/ \______/ \__|\______/ \__|\______/ - - -$$$$$$$$\ $$\ $$\ $$\ $$\ $$\ -\__$$ __| \__|$$ |\__| $$ | $$ | - $$ |$$\ $$\ $$\ $$\ $$ |$$\ $$$$$$\ $$$$$$$\ $$$$$$\ - $$ |$$ | $$ | $$ |$$ |$$ |$$ |$$ __$$\ $$ __$$\\_$$ _| - $$ |$$ | $$ | $$ |$$ |$$ |$$ |$$ / $$ |$$ | $$ | $$ | - $$ |$$ | $$ | $$ |$$ |$$ |$$ |$$ | $$ |$$ | $$ | $$ |$$\ - $$ |\$$$$$\$$$$ |$$ |$$ |$$ |\$$$$$$$ |$$ | $$ | \$$$$ | - \__| \_____\____/ \__|\__|\__| \____$$ |\__| \__| \____/ - $$\ $$ | - \$$$$$$ | - \______/ - - $$\ $$\ $$\ $$$$$$$$\ $$\ - $$ \$$ \ $$ | $$ _____|$$ | -$$$$$$$$$$\ $$ | $$ | $$ | -\_$$ $$ |$$ | $$$$$\ $$ | -$$$$$$$$$$\ $$ | $$ __| $$ | -\_$$ $$ _|$$ | $$ | $$ | - $$ |$$ | $$$$$$$$\ $$ | $$$$$$$$\ - \__|\__| \________|\__| \________| -`) - - return newVersionMap, nil - } -} - -func migrateTaxParams(ctx sdk.Context, paramsKeepers paramskeeper.Keeper, storeKey storetypes.StoreKey, codec codec.Codec) error { - store := ctx.KVStore(storeKey) - var currParams taxtypes.Params - subspace, _ := paramsKeepers.GetSubspace(taxtypes.StoreKey) - subspace.GetParamSet(ctx, &currParams) - - if err := currParams.Validate(); err != nil { - return err - } - - bz := codec.MustMarshal(&currParams) - store.Set(taxtypes.ParamsKey, bz) - return nil -} - -func migrateMintParams(ctx sdk.Context, paramsKeepers paramskeeper.Keeper, storeKey storetypes.StoreKey, codec codec.Codec) error { - store := ctx.KVStore(storeKey) - var currParams minttypes.Params - subspace, _ := paramsKeepers.GetSubspace(minttypes.StoreKey) - subspace.GetParamSet(ctx, &currParams) - - if err := currParams.Validate(); err != nil { - return err - } - - bz := codec.MustMarshal(&currParams) - store.Set(minttypes.ParamsKey, bz) - return nil -} - -func migrateFeeRefunderParams(ctx sdk.Context, paramsKeepers paramskeeper.Keeper, storeKey storetypes.StoreKey, codec codec.Codec) error { - store := ctx.KVStore(storeKey) - var currParams feerefundertypes.Params - subspace, _ := paramsKeepers.GetSubspace(feerefundertypes.StoreKey) - subspace.GetParamSet(ctx, &currParams) - - if err := currParams.Validate(); err != nil { - return err - } - - bz := codec.MustMarshal(&currParams) - store.Set(feerefundertypes.ParamsKey, bz) - return nil -} - -func migrateInterchainQueriesParams(ctx sdk.Context, paramsKeepers paramskeeper.Keeper, storeKey storetypes.StoreKey, codec codec.Codec) error { - store := ctx.KVStore(storeKey) - var currParams icqtypes.Params - subspace, _ := paramsKeepers.GetSubspace(icqtypes.StoreKey) - subspace.GetParamSet(ctx, &currParams) - - currParams.QueryDeposit = sdk.NewCoins(sdk.NewCoin(params.BaseCoinUnit, math.NewInt(1_000_000))) - - if err := currParams.Validate(); err != nil { - return err - } - - bz := codec.MustMarshal(&currParams) - store.Set(icqtypes.ParamsKey, bz) - return nil -} - -func setInterchainTxsParams(ctx sdk.Context, paramsKeepers paramskeeper.Keeper, storeKey, wasmStoreKey storetypes.StoreKey, codec codec.Codec) error { - store := ctx.KVStore(storeKey) - var currParams interchaintxstypes.Params - subspace, _ := paramsKeepers.GetSubspace(interchaintxstypes.StoreKey) - subspace.GetParamSet(ctx, &currParams) - currParams.RegisterFee = interchaintxstypes.DefaultRegisterFee - - if err := currParams.Validate(); err != nil { - return err - } - - bz := codec.MustMarshal(&currParams) - store.Set(interchaintxstypes.ParamsKey, bz) - - // set an extremely high number for the first code id that will be taxed with fee for opening an ICA - // these bytes are equal to 1684300900 when parsed with sdk.BigEndianToUint64. It's a number that is unlikely to be reached as a code id - // if we decide to charge a fee for opening an ICA, we can set this to a lower number in the future - bytesIcaRegistrationFirstCode := []byte{0, 0, 0, 0, 100, 100, 100, 100} - store.Set(interchaintxstypes.ICARegistrationFeeFirstCodeID, bytesIcaRegistrationFirstCode) - return nil -} - -func setContractManagerParams(ctx context.Context, keeper contractmanagerkeeper.Keeper) error { - sudoGasLimit := uint64(3_000_000) - cmParams := contractmanagertypes.Params{ - SudoCallGasLimit: sudoGasLimit, - } - return keeper.SetParams(ctx, cmParams) -} - -func setInitialMinCommissionRate(ctx context.Context, keepers *keepers.AppKeepers) error { - stakingParams, err := keepers.StakingKeeper.GetParams(ctx) - if err != nil { - return fmt.Errorf("failed to get staking params: %w", err) - } - // DefaultMinComission rate is 0% - stakingParams.MinCommissionRate = stakingtypes.DefaultMinCommissionRate - if err := keepers.StakingKeeper.SetParams(ctx, stakingParams); err != nil { - return fmt.Errorf("failed to set MinCommissionRate to 5%%: %w", err) - } - - return nil -} - -func setMinInitialDepositRatio(ctx context.Context, keepers *keepers.AppKeepers) error { - govParams, err := keepers.GovKeeper.Params.Get(ctx) - if err != nil { - return fmt.Errorf("failed to get gov params: %w", err) - } - govParams.MinInitialDepositRatio = "0.25" - return keepers.GovKeeper.Params.Set(ctx, govParams) -} diff --git a/app/upgrades/v051/constants.go b/app/upgrades/v051/constants.go deleted file mode 100644 index c680a744..00000000 --- a/app/upgrades/v051/constants.go +++ /dev/null @@ -1,24 +0,0 @@ -package v051 - -import ( - store "cosmossdk.io/store/types" - "cosmossdk.io/x/feegrant" - "github.com/Nolus-Protocol/nolus-core/app/upgrades" - icahosttypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/host/types" -) - -const ( - // UpgradeName defines the on-chain upgrades name. - UpgradeName = "v0.5.1" -) - -var Upgrade = upgrades.Upgrade{ - UpgradeName: UpgradeName, - CreateUpgradeHandler: CreateUpgradeHandler, - StoreUpgrades: store.StoreUpgrades{ - Added: []string{ - feegrant.ModuleName, - icahosttypes.StoreKey, - }, - }, -} diff --git a/app/upgrades/v051/upgrades.go b/app/upgrades/v051/upgrades.go deleted file mode 100644 index 6fd367a2..00000000 --- a/app/upgrades/v051/upgrades.go +++ /dev/null @@ -1,47 +0,0 @@ -package v051 - -import ( - "context" - - "github.com/Nolus-Protocol/nolus-core/app/keepers" - - upgradetypes "cosmossdk.io/x/upgrade/types" - "github.com/cosmos/cosmos-sdk/codec" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/module" - - ica "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts" - icacontrollertypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller/types" - icahosttypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/host/types" - icatypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/types" -) - -func CreateUpgradeHandler( - mm *module.Manager, - configurator module.Configurator, - keepers *keepers.AppKeepers, - codec codec.Codec, -) upgradetypes.UpgradeHandler { - return func(c context.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { - ctx := sdk.UnwrapSDKContext(c) - - // create ICS27 Host submodule params - hostParams := icahosttypes.Params{ - HostEnabled: true, - AllowMessages: []string{}, - } - - // initialize ICS27 module - icamodule, correctTypecast := mm.Modules[icatypes.ModuleName].(ica.AppModule) - if !correctTypecast { - panic("mm.Modules[icatypes.ModuleName] is not of type ica.AppModule") - } - - // Default icacontroller parameters keep our icacontroller enabled - // The reason to call InitModule here is because we want to enable host functionality on nolus, which was disabled before - // InitModule sets the params for host, binds the hostKeeper to port `icahost` and claims port capability - icamodule.InitModule(ctx, icacontrollertypes.DefaultParams(), hostParams) - - return mm.RunMigrations(ctx, configurator, fromVM) //nolint:contextcheck - } -} diff --git a/app/upgrades/v052/constants.go b/app/upgrades/v052/constants.go deleted file mode 100644 index b66eca95..00000000 --- a/app/upgrades/v052/constants.go +++ /dev/null @@ -1,19 +0,0 @@ -package v052 - -import ( - store "cosmossdk.io/store/types" - "github.com/Nolus-Protocol/nolus-core/app/upgrades" -) - -const ( - // UpgradeName defines the on-chain upgrades name. - UpgradeName = "v0.5.2" -) - -var Upgrade = upgrades.Upgrade{ - UpgradeName: UpgradeName, - CreateUpgradeHandler: CreateUpgradeHandler, - StoreUpgrades: store.StoreUpgrades{ - Added: []string{}, - }, -} diff --git a/app/upgrades/v052/upgrades.go b/app/upgrades/v052/upgrades.go deleted file mode 100644 index 9e3e91b6..00000000 --- a/app/upgrades/v052/upgrades.go +++ /dev/null @@ -1,22 +0,0 @@ -package v052 - -import ( - "context" - - "github.com/Nolus-Protocol/nolus-core/app/keepers" - - upgradetypes "cosmossdk.io/x/upgrade/types" - "github.com/cosmos/cosmos-sdk/codec" - "github.com/cosmos/cosmos-sdk/types/module" -) - -func CreateUpgradeHandler( - mm *module.Manager, - configurator module.Configurator, - keepers *keepers.AppKeepers, - codec codec.Codec, -) upgradetypes.UpgradeHandler { - return func(ctx context.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { - return mm.RunMigrations(ctx, configurator, fromVM) - } -} diff --git a/app/upgrades/v053/constants.go b/app/upgrades/v053/constants.go deleted file mode 100644 index a5920a71..00000000 --- a/app/upgrades/v053/constants.go +++ /dev/null @@ -1,19 +0,0 @@ -package v053 - -import ( - store "cosmossdk.io/store/types" - "github.com/Nolus-Protocol/nolus-core/app/upgrades" -) - -const ( - // UpgradeName defines the on-chain upgrades name. - UpgradeName = "v0.5.3" -) - -var Upgrade = upgrades.Upgrade{ - UpgradeName: UpgradeName, - CreateUpgradeHandler: CreateUpgradeHandler, - StoreUpgrades: store.StoreUpgrades{ - Added: []string{}, - }, -} diff --git a/app/upgrades/v053/upgrades.go b/app/upgrades/v053/upgrades.go deleted file mode 100644 index 30e04129..00000000 --- a/app/upgrades/v053/upgrades.go +++ /dev/null @@ -1,26 +0,0 @@ -package v053 - -import ( - "context" - - "github.com/Nolus-Protocol/nolus-core/app/keepers" - - upgradetypes "cosmossdk.io/x/upgrade/types" - "github.com/cosmos/cosmos-sdk/codec" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/module" -) - -func CreateUpgradeHandler( - mm *module.Manager, - configurator module.Configurator, - keepers *keepers.AppKeepers, - codec codec.Codec, -) upgradetypes.UpgradeHandler { - return func(c context.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { - ctx := sdk.UnwrapSDKContext(c) - - ctx.Logger().Info(`IBC-Go v7.4.0 upgrade handler execution...`) - return mm.RunMigrations(ctx, configurator, fromVM) //nolint:contextcheck - } -} diff --git a/go.mod b/go.mod index f8b6e6d4..3e76719f 100644 --- a/go.mod +++ b/go.mod @@ -37,7 +37,6 @@ require ( github.com/cosmos/cosmos-db v1.0.2 github.com/cosmos/cosmos-proto v1.0.0-beta.5 github.com/cosmos/ibc-go/modules/capability v1.0.1 - github.com/cosmos/ics23/go v0.11.0 github.com/gogo/protobuf v1.3.3 github.com/golang/mock v1.6.0 github.com/hashicorp/go-metrics v0.5.3 @@ -85,6 +84,7 @@ require ( github.com/cosmos/go-bip39 v1.0.0 // indirect github.com/cosmos/gogogateway v1.2.0 // indirect github.com/cosmos/iavl v1.2.0 // indirect + github.com/cosmos/ics23/go v0.11.0 // indirect github.com/cosmos/ledger-cosmos-go v0.13.3 // indirect github.com/creachadair/atomicfile v0.3.3 // indirect github.com/creachadair/tomledit v0.0.26 // indirect diff --git a/proto/nolus/interchainqueries/genesis.proto b/proto/nolus/interchainqueries/genesis.proto deleted file mode 100644 index 1955590e..00000000 --- a/proto/nolus/interchainqueries/genesis.proto +++ /dev/null @@ -1,66 +0,0 @@ -syntax = "proto3"; -package nolus.interchainqueries; - -import "cosmos/base/v1beta1/coin.proto"; -import "gogoproto/gogo.proto"; -import "ibc/core/client/v1/client.proto"; -import "nolus/interchainqueries/params.proto"; - -option go_package = "github.com/Nolus-Protocol/nolus-core/x/interchainqueries/types"; - -// RegisteredQuery defines a query that was registered by a user. -message RegisteredQuery { - // The unique id of the registered query. - uint64 id = 1; - - // The address that registered the query. - string owner = 2; - - // The query type identifier: `kv` or `tx` now - string query_type = 3; - - // The KV-storage keys for which we want to get values from remote chain - repeated KVKey keys = 4; - - // The filter for transaction search ICQ - string transactions_filter = 5; - - // The IBC connection ID for getting ConsensusState to verify proofs - string connection_id = 6; - - // Parameter that defines how often the query must be updated. - uint64 update_period = 7; - - // The local chain last block height when the query result was updated. - uint64 last_submitted_result_local_height = 8; - - // The remote chain last block height when the query result was updated. - ibc.core.client.v1.Height last_submitted_result_remote_height = 9; - - // Amount of coins deposited for the query. - repeated cosmos.base.v1beta1.Coin deposit = 10 [ - (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", - (gogoproto.nullable) = false - ]; - - // Timeout before query becomes available for everybody to remove. - uint64 submit_timeout = 11; - - // The local chain height when the query was registered. - uint64 registered_at_height = 12; -} - -// KVKey defines a key-value pair for KVStore. -message KVKey { - // Path (storage prefix) to the storage where you want to read value by key - // (usually name of cosmos-sdk module: 'staking', 'bank', etc.) - string path = 1; - // Key you want to read from the storage - bytes key = 2; -} - -// GenesisState defines the interchainqueries module's genesis state. -message GenesisState { - Params params = 1 [(gogoproto.nullable) = false]; - repeated RegisteredQuery registered_queries = 2; -} diff --git a/proto/nolus/interchainqueries/params.proto b/proto/nolus/interchainqueries/params.proto deleted file mode 100644 index de20ebd5..00000000 --- a/proto/nolus/interchainqueries/params.proto +++ /dev/null @@ -1,26 +0,0 @@ -syntax = "proto3"; -package nolus.interchainqueries; - -import "cosmos/base/v1beta1/coin.proto"; -import "gogoproto/gogo.proto"; - -option go_package = "github.com/Nolus-Protocol/nolus-core/x/interchainqueries/types"; - -// Params defines the parameters for the module. -message Params { - option (gogoproto.goproto_stringer) = false; - // Defines amount of blocks required before query becomes available for - // removal by anybody - uint64 query_submit_timeout = 1; - - // Amount of coins deposited for the query. - repeated cosmos.base.v1beta1.Coin query_deposit = 2 [ - (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", - (gogoproto.nullable) = false - ]; - - // Amount of tx hashes to be removed during a single EndBlock. Can vary to - // balance between network cleaning speed and EndBlock duration. A zero value - // means no limit. - uint64 tx_query_removal_limit = 3; -} diff --git a/proto/nolus/interchainqueries/query.proto b/proto/nolus/interchainqueries/query.proto deleted file mode 100644 index 4e20a3ae..00000000 --- a/proto/nolus/interchainqueries/query.proto +++ /dev/null @@ -1,100 +0,0 @@ -syntax = "proto3"; -package nolus.interchainqueries; - -import "cosmos/base/query/v1beta1/pagination.proto"; -import "gogoproto/gogo.proto"; -import "google/api/annotations.proto"; -import "nolus/interchainqueries/genesis.proto"; -import "nolus/interchainqueries/params.proto"; -import "nolus/interchainqueries/tx.proto"; - -option go_package = "github.com/Nolus-Protocol/nolus-core/x/interchainqueries/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 = "/nolus/interchainqueries/params"; - } - - // RegisteredQueries queries the registered queries of the module. - rpc RegisteredQueries(QueryRegisteredQueriesRequest) returns (QueryRegisteredQueriesResponse) { - option (google.api.http).get = "/nolus/interchainqueries/registered_queries"; - } - - // RegisteredQuery queries the registered query of the module. - rpc RegisteredQuery(QueryRegisteredQueryRequest) returns (QueryRegisteredQueryResponse) { - option (google.api.http).get = "/nolus/interchainqueries/registered_query"; - } - - // QueryResult queries the result of a registered query. - rpc QueryResult(QueryRegisteredQueryResultRequest) returns (QueryResultResponse) { - option (google.api.http).get = "/nolus/interchainqueries/query_result"; - } - - // LastRemoteHeight queries the last remote height of a connection. - rpc LastRemoteHeight(QueryLastRemoteHeight) returns (QueryLastRemoteHeightResponse) { - option (google.api.http).get = "/nolus/interchainqueries/remote_height"; - } -} - -// 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]; -} - -// QueryRegisteredQueriesRequest is request type for the Query/RegisteredQueries RPC method. -message QueryRegisteredQueriesRequest { - repeated string owners = 1; - string connection_id = 2; - cosmos.base.query.v1beta1.PageRequest pagination = 3; -} - -// QueryRegisteredQueriesResponse is response type for the Query/RegisteredQueries RPC method. -message QueryRegisteredQueriesResponse { - repeated RegisteredQuery registered_queries = 1 [(gogoproto.nullable) = false]; - - // pagination defines the pagination in the response. - cosmos.base.query.v1beta1.PageResponse pagination = 2; -} - -// QueryRegisteredQueryRequest is request type for the Query/RegisteredQuery RPC method. -message QueryRegisteredQueryRequest { - uint64 query_id = 1; -} - -// QueryRegisteredQueryResponse is response type for the Query/RegisteredQuery RPC method. -message QueryRegisteredQueryResponse { - RegisteredQuery registered_query = 1; -} - -// QueryRegisteredQueryResultRequest is request type for the Query/QueryResult RPC method. -message QueryRegisteredQueryResultRequest { - uint64 query_id = 1; -} - -// QueryResultResponse is response type for the Query/QueryResult RPC method. -message QueryResultResponse { - QueryResult result = 1; -} - -// Transaction defines a transaction message for the interchainqueries module. -message Transaction { - uint64 id = 1; - uint64 height = 2; - bytes data = 3; -} - -// QueryLastRemoteHeight is request type for the Query/LastRemoteHeight RPC method. -message QueryLastRemoteHeight { - string connection_id = 1; -} - -// QueryLastRemoteHeightResponse is response type for the Query/LastRemoteHeight RPC method. -message QueryLastRemoteHeightResponse { - uint64 height = 1; -} diff --git a/proto/nolus/interchainqueries/tx.proto b/proto/nolus/interchainqueries/tx.proto deleted file mode 100644 index 5fe9d22b..00000000 --- a/proto/nolus/interchainqueries/tx.proto +++ /dev/null @@ -1,181 +0,0 @@ -syntax = "proto3"; -package nolus.interchainqueries; - -import "amino/amino.proto"; -import "cosmos/msg/v1/msg.proto"; -import "cosmos_proto/cosmos.proto"; -import "gogoproto/gogo.proto"; -import "google/protobuf/any.proto"; -import "nolus/interchainqueries/genesis.proto"; -import "nolus/interchainqueries/params.proto"; -import "tendermint/abci/types.proto"; -import "tendermint/crypto/proof.proto"; - -option go_package = "github.com/Nolus-Protocol/nolus-core/x/interchainqueries/types"; - -// Msg defines the Msg service. -service Msg { - option (cosmos.msg.v1.service) = true; - - // RegisterInterchainQuery registers a new interchain query. - rpc RegisterInterchainQuery(MsgRegisterInterchainQuery) returns (MsgRegisterInterchainQueryResponse); - - // SubmitQueryResult submits a result of an interchain query. - rpc SubmitQueryResult(MsgSubmitQueryResult) returns (MsgSubmitQueryResultResponse); - - // RemoveInterchainQuery removes an interchain query. - rpc RemoveInterchainQuery(MsgRemoveInterchainQueryRequest) returns (MsgRemoveInterchainQueryResponse); - - // UpdateInterchainQuery updates an interchain query. - rpc UpdateInterchainQuery(MsgUpdateInterchainQueryRequest) returns (MsgUpdateInterchainQueryResponse); - - // UpdateParams updates the x/interchainqueries parameters. - rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse); -} - -// MsgRegisterInterchainQuery is the MsgRegisterInterchainQuery request type. -message MsgRegisterInterchainQuery { - option (cosmos.msg.v1.signer) = "sender"; - - // defines a query type: `kv` or `tx` now - string query_type = 1; - - // is used to define KV-storage keys for which we want to get values from - // remote chain - repeated KVKey keys = 2; - - // is used to define a filter for transaction search ICQ - string transactions_filter = 3; - - // is IBC connection ID for getting ConsensusState to verify proofs - string connection_id = 4; - - // is used to specify how often (in nolus blocks) the query must be updated - uint64 update_period = 5; - - // is the signer of the message - string sender = 6; -} - -// MsgRegisterInterchainQueryResponse is the MsgRegisterInterchainQuery response type. -message MsgRegisterInterchainQueryResponse { - uint64 id = 1; -} - -// MsgSubmitQueryResult is the MsgSubmitQueryResult request type. -message MsgSubmitQueryResult { - option (cosmos.msg.v1.signer) = "sender"; - - uint64 query_id = 1; - string sender = 2; - - // is the IBC client ID for an IBC connection between nolus chain and target - // chain (where the result was obtained from) - string client_id = 3; - QueryResult result = 4; -} - -// QueryResult is the result of an interchain query. -message QueryResult { - repeated StorageValue kv_results = 1; - Block block = 2; - uint64 height = 3; - uint64 revision = 4; - bool allow_kv_callbacks = 5; -} - -// StorageValue is the key-value pair for KVStore. -message StorageValue { - // is the substore name (acc, staking, etc.) - string storage_prefix = 1; - - // is the key in IAVL store - bytes key = 2; - - // is the value in IAVL store - bytes value = 3; - - // is the Merkle proof which proves existence of key-value pair in IAVL - // storage - tendermint.crypto.ProofOps proof = 4; -} - -// Block is the block info of the chain needed for the interchainqueries module. -message Block { - // We need to know block X+1 to verify response of transaction for block X - // since LastResultsHash is root hash of all results from the txs from the - // previous block - google.protobuf.Any next_block_header = 1; - - // We need to know block X to verify inclusion of transaction for block X - google.protobuf.Any header = 2; - - TxValue tx = 3; -} - -// TxValue is the transaction info of the chain needed for the interchainqueries module. -message TxValue { - tendermint.abci.ExecTxResult response = 1; - - // is the Merkle Proof which proves existence of response in block with height - // next_block_header.Height - tendermint.crypto.Proof delivery_proof = 2; - - // is the Merkle Proof which proves existence of data in block with height - // header.Height - tendermint.crypto.Proof inclusion_proof = 3; - - // is body of the transaction - bytes data = 4; -} - -// MsgSubmitQueryResultResponse is the MsgSubmitQueryResult response type. -message MsgSubmitQueryResultResponse {} - -// MsgRemoveInterchainQueryRequest is the MsgRemoveInterchainQuery request type. -message MsgRemoveInterchainQueryRequest { - option (cosmos.msg.v1.signer) = "sender"; - uint64 query_id = 1; - string sender = 2; // is the signer of the message -} - -// MsgRemoveInterchainQueryResponse is the MsgRemoveInterchainQuery response type. -message MsgRemoveInterchainQueryResponse {} - -// MsgUpdateInterchainQueryRequest is the MsgUpdateInterchainQuery request type. -message MsgUpdateInterchainQueryRequest { - option (cosmos.msg.v1.signer) = "sender"; - uint64 query_id = 1; - repeated KVKey new_keys = 2; - uint64 new_update_period = 3; - string new_transactions_filter = 4; - string sender = 5; // is the signer of the message -} - -// MsgUpdateInterchainQueryResponse is the MsgUpdateInterchainQuery response type. -message MsgUpdateInterchainQueryResponse {} - -// MsgUpdateParams is the MsgUpdateParams request type. -// -// Since: 0.47 -message MsgUpdateParams { - option (amino.name) = "interchainqueries/MsgUpdateParams"; - option (cosmos.msg.v1.signer) = "authority"; - - // Authority is the address of the governance account. - string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; - - // params defines the x/interchainqueries parameters to update. - // - // NOTE: All parameters must be supplied. - Params params = 2 [ - (gogoproto.nullable) = false, - (amino.dont_omitempty) = true - ]; -} - -// MsgUpdateParamsResponse defines the response structure for executing a -// MsgUpdateParams message. -// -// Since: 0.47 -message MsgUpdateParamsResponse {} diff --git a/scripts/internal/genesis.sh b/scripts/internal/genesis.sh index c3afc1ff..52edcf15 100644 --- a/scripts/internal/genesis.sh +++ b/scripts/internal/genesis.sh @@ -273,7 +273,6 @@ __modify_neutron_modules_params() { | jq '.app_state["feerefunder"]["params"]["min_fee"]["ack_fee"][0]["denom"]="'"$native_currency"'"' \ | jq '.app_state["feerefunder"]["params"]["min_fee"]["timeout_fee"][0]["amount"]="'"$timeout_fee_amount"'"' \ | jq '.app_state["feerefunder"]["params"]["min_fee"]["timeout_fee"][0]["denom"]="'"$native_currency"'"' \ - | jq '.app_state["interchainqueries"]["params"]["query_deposit"][0]["denom"]="'"$native_currency"'"' \ | jq '.app_state["interchaintxs"]["params"]["msg_submit_tx_max_messages"]="16"' \ | jq '.app_state["interchaintxs"]["params"]["register_fee"][0]["amount"]="1"' \ | jq '.app_state["interchaintxs"]["params"]["register_fee"][0]["denom"]="'"$native_currency"'"' > "$genesis_tmp_file" diff --git a/scripts/temp-script.sh b/scripts/temp-script.sh new file mode 100755 index 00000000..508ffb79 --- /dev/null +++ b/scripts/temp-script.sh @@ -0,0 +1,9 @@ +#!/bin/bash +set -euxo pipefail + +USER_DIR="/home/denislavivanov/.nolus" +WASM_CODE_ARTIFACTS_PATH_PLATFORM="/home/denislavivanov/go/github/nolus-money-market/artifacts-v0.7.1-dev/platform" + +source "/home/denislavivanov/go/github/nolus-money-market/scripts/deploy-platform.sh" + +deploy_contracts "$USER_DIR" "$WASM_CODE_ARTIFACTS_PATH_PLATFORM" "1000000000unls" "nolus1unzvj963cha6gfthjcxj5me6cmzr0w6yw3td7d" "nolus18rl557k4jcjjcx7wmcrw47wkg25e3k3vmata54" \ No newline at end of file diff --git a/testutil/contractmanager/network/network.go b/testutil/contractmanager/network/network.go index 05efbf43..f15cca0e 100644 --- a/testutil/contractmanager/network/network.go +++ b/testutil/contractmanager/network/network.go @@ -2,7 +2,6 @@ package network import ( "fmt" - "os" "testing" "time" @@ -46,16 +45,6 @@ func New(t *testing.T, configs ...network.Config) *network.Network { return net } -var tempDir = func() string { - dir, err := os.MkdirTemp("", "nolusd") - if err != nil { - panic("failed to create temp dir: " + err.Error()) - } - defer os.RemoveAll(dir) - - return dir -} - // DefaultConfig will initialize config for the network with custom application, // genesis and single validator. All other parameters are inherited from cosmos-sdk/testutil/network.DefaultConfig. func DefaultConfig() network.Config { diff --git a/testutil/interchainqueries/keeper/interchainqueries.go b/testutil/interchainqueries/keeper/interchainqueries.go deleted file mode 100644 index 327d5b2a..00000000 --- a/testutil/interchainqueries/keeper/interchainqueries.go +++ /dev/null @@ -1,64 +0,0 @@ -package keeper - -import ( - "testing" - - "cosmossdk.io/log" - metrics2 "cosmossdk.io/store/metrics" - adminmoduletypes "github.com/cosmos/admin-module/v2/x/adminmodule/types" - db2 "github.com/cosmos/cosmos-db" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - - ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper" - - "cosmossdk.io/store" - storetypes "cosmossdk.io/store/types" - tmproto "github.com/cometbft/cometbft/proto/tendermint/types" - "github.com/cosmos/cosmos-sdk/codec" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/require" - - "github.com/Nolus-Protocol/nolus-core/x/interchainqueries/keeper" - "github.com/Nolus-Protocol/nolus-core/x/interchainqueries/types" -) - -func InterchainQueriesKeeper( - t testing.TB, - ibcKeeper *ibckeeper.Keeper, - contractManager types.ContractManagerKeeper, - headerVerifier types.HeaderVerifier, - txVerifier types.TransactionVerifier, -) (*keeper.Keeper, sdk.Context) { - storeKey := storetypes.NewKVStoreKey(types.StoreKey) - memStoreKey := storetypes.NewMemoryStoreKey(types.MemStoreKey) - - db := db2.NewMemDB() - stateStore := store.NewCommitMultiStore(db, log.NewNopLogger(), metrics2.NewNoOpMetrics()) - stateStore.MountStoreWithDB(storeKey, storetypes.StoreTypeIAVL, db) - stateStore.MountStoreWithDB(memStoreKey, storetypes.StoreTypeMemory, nil) - require.NoError(t, stateStore.LoadLatestVersion()) - - registry := codectypes.NewInterfaceRegistry() - cdc := codec.NewProtoCodec(registry) - - k := keeper.NewKeeper( - cdc, - storeKey, - memStoreKey, - ibcKeeper, // TODO: do a real ibc keeper - nil, // TODO: do a real wasm keeper - contractManager, - headerVerifier, - txVerifier, - authtypes.NewModuleAddress(adminmoduletypes.ModuleName).String(), - ) - - ctx := sdk.NewContext(stateStore, tmproto.Header{}, false, log.NewNopLogger()) - - // Initialize params - err := k.SetParams(ctx, types.DefaultParams()) - require.NoError(t, err) - - return k, ctx -} diff --git a/testutil/interchainqueries/network/network.go b/testutil/interchainqueries/network/network.go deleted file mode 100644 index e388de69..00000000 --- a/testutil/interchainqueries/network/network.go +++ /dev/null @@ -1,85 +0,0 @@ -package network - -import ( - "fmt" - "testing" - "time" - - pruningtypes "cosmossdk.io/store/pruning/types" - db "github.com/cosmos/cosmos-db" - "github.com/stretchr/testify/require" - - tmrand "github.com/cometbft/cometbft/libs/rand" - "github.com/cosmos/cosmos-sdk/baseapp" - "github.com/cosmos/cosmos-sdk/crypto/hd" - "github.com/cosmos/cosmos-sdk/crypto/keyring" - servertypes "github.com/cosmos/cosmos-sdk/server/types" - "github.com/cosmos/cosmos-sdk/testutil/network" - "github.com/cosmos/cosmos-sdk/testutil/sims" - sdk "github.com/cosmos/cosmos-sdk/types" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - - "github.com/Nolus-Protocol/nolus-core/app" -) - -type ( - Network = network.Network - Config = network.Config -) - -// New creates instance with fully configured cosmos network. -// Accepts optional config, that will be used in place of the DefaultConfig() if provided. -func New(t *testing.T, configs ...network.Config) *network.Network { - if len(configs) > 1 { - panic("at most one config should be provided") - } - var cfg network.Config - if len(configs) == 0 { - cfg = DefaultConfig() - } else { - cfg = configs[0] - } - net, err := network.New(t, t.TempDir(), cfg) - require.NoError(t, err) - t.Cleanup(net.Cleanup) - return net -} - -// DefaultConfig will initialize config for the network with custom application, -// genesis and single validator. All other parameters are inherited from cosmos-sdk/testutil/network.DefaultConfig. -func DefaultConfig() network.Config { - encoding := app.MakeEncodingConfig(app.ModuleBasics) - - chainID := "chain-" + tmrand.NewRand().Str(6) - return network.Config{ - Codec: encoding.Marshaler, - TxConfig: encoding.TxConfig, - LegacyAmino: encoding.Amino, - InterfaceRegistry: encoding.InterfaceRegistry, - AccountRetriever: authtypes.AccountRetriever{}, - AppConstructor: func(val network.ValidatorI) servertypes.Application { - return app.New( - val.GetCtx().Logger, db.NewMemDB(), nil, true, map[int64]bool{}, val.GetCtx().Config.RootDir, 0, - encoding, - sims.EmptyAppOptions{}, - baseapp.SetPruning(pruningtypes.NewPruningOptionsFromString(val.GetAppConfig().Pruning)), - baseapp.SetMinGasPrices(val.GetAppConfig().MinGasPrices), - baseapp.SetChainID(chainID), - ) - }, - GenesisState: app.ModuleBasics.DefaultGenesis(encoding.Marshaler), - TimeoutCommit: 2 * time.Second, - ChainID: chainID, - NumValidators: 1, - BondDenom: sdk.DefaultBondDenom, - MinGasPrices: fmt.Sprintf("0.000006%s", sdk.DefaultBondDenom), - AccountTokens: sdk.TokensFromConsensusPower(1000, sdk.DefaultPowerReduction), - StakingTokens: sdk.TokensFromConsensusPower(500, sdk.DefaultPowerReduction), - BondedTokens: sdk.TokensFromConsensusPower(100, sdk.DefaultPowerReduction), - - PruningStrategy: pruningtypes.PruningOptionNothing, - CleanupDir: true, - SigningAlgo: string(hd.Secp256k1Type), - KeyringOptions: []keyring.Option{}, - } -} diff --git a/testutil/mocks/gomock.go b/testutil/mocks/gomock.go index 0e0aecc5..e4393023 100644 --- a/testutil/mocks/gomock.go +++ b/testutil/mocks/gomock.go @@ -3,7 +3,5 @@ package mocks //go:generate mockgen -source=./../../x/tax/types/expected_keepers.go -destination ./tax/types/expected_keepers.go //go:generate mockgen -source=./../../x/contractmanager/types/expected_keepers.go -destination ./contractmanager/types/expected_keepers.go //go:generate mockgen -source=./../../x/feerefunder/types/expected_keepers.go -destination ./feerefunder/types/keepers.go -//go:generate mockgen -source=./../../x/interchainqueries/types/verify.go -destination ./interchainqueries/keeper/verify.go -//go:generate mockgen -source=./../../x/interchainqueries/types/expected_keepers.go -destination ./interchainqueries/types/expected_keepers.go //go:generate mockgen -source=./../../x/interchaintxs/types/expected_keepers.go -destination ./interchaintxs/types/expected_keepers.go //go:generate mockgen -source=./../../x/transfer/types/expected_keepers.go -destination ./transfer/types/expected_keepers.go diff --git a/testutil/mocks/interchainqueries/keeper/verify.go b/testutil/mocks/interchainqueries/keeper/verify.go deleted file mode 100644 index 571f0026..00000000 --- a/testutil/mocks/interchainqueries/keeper/verify.go +++ /dev/null @@ -1,106 +0,0 @@ -// Code generated by MockGen. DO NOT EDIT. -// Source: ./../../x/interchainqueries/types/verify.go - -// Package mock_types is a generated GoMock package. -package mock_types - -import ( - reflect "reflect" - - types "github.com/Nolus-Protocol/nolus-core/x/interchainqueries/types" - types0 "github.com/cosmos/cosmos-sdk/codec/types" - types1 "github.com/cosmos/cosmos-sdk/types" - keeper "github.com/cosmos/ibc-go/v8/modules/core/02-client/keeper" - exported "github.com/cosmos/ibc-go/v8/modules/core/exported" - tendermint "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" - gomock "github.com/golang/mock/gomock" -) - -// MockHeaderVerifier is a mock of HeaderVerifier interface. -type MockHeaderVerifier struct { - ctrl *gomock.Controller - recorder *MockHeaderVerifierMockRecorder -} - -// MockHeaderVerifierMockRecorder is the mock recorder for MockHeaderVerifier. -type MockHeaderVerifierMockRecorder struct { - mock *MockHeaderVerifier -} - -// NewMockHeaderVerifier creates a new mock instance. -func NewMockHeaderVerifier(ctrl *gomock.Controller) *MockHeaderVerifier { - mock := &MockHeaderVerifier{ctrl: ctrl} - mock.recorder = &MockHeaderVerifierMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockHeaderVerifier) EXPECT() *MockHeaderVerifierMockRecorder { - return m.recorder -} - -// UnpackHeader mocks base method. -func (m *MockHeaderVerifier) UnpackHeader(any *types0.Any) (exported.ClientMessage, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "UnpackHeader", any) - ret0, _ := ret[0].(exported.ClientMessage) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// UnpackHeader indicates an expected call of UnpackHeader. -func (mr *MockHeaderVerifierMockRecorder) UnpackHeader(any interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UnpackHeader", reflect.TypeOf((*MockHeaderVerifier)(nil).UnpackHeader), any) -} - -// VerifyHeaders mocks base method. -func (m *MockHeaderVerifier) VerifyHeaders(ctx types1.Context, cleintkeeper keeper.Keeper, clientID string, header, nextHeader exported.ClientMessage) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "VerifyHeaders", ctx, cleintkeeper, clientID, header, nextHeader) - ret0, _ := ret[0].(error) - return ret0 -} - -// VerifyHeaders indicates an expected call of VerifyHeaders. -func (mr *MockHeaderVerifierMockRecorder) VerifyHeaders(ctx, cleintkeeper, clientID, header, nextHeader interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "VerifyHeaders", reflect.TypeOf((*MockHeaderVerifier)(nil).VerifyHeaders), ctx, cleintkeeper, clientID, header, nextHeader) -} - -// MockTransactionVerifier is a mock of TransactionVerifier interface. -type MockTransactionVerifier struct { - ctrl *gomock.Controller - recorder *MockTransactionVerifierMockRecorder -} - -// MockTransactionVerifierMockRecorder is the mock recorder for MockTransactionVerifier. -type MockTransactionVerifierMockRecorder struct { - mock *MockTransactionVerifier -} - -// NewMockTransactionVerifier creates a new mock instance. -func NewMockTransactionVerifier(ctrl *gomock.Controller) *MockTransactionVerifier { - mock := &MockTransactionVerifier{ctrl: ctrl} - mock.recorder = &MockTransactionVerifierMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockTransactionVerifier) EXPECT() *MockTransactionVerifierMockRecorder { - return m.recorder -} - -// VerifyTransaction mocks base method. -func (m *MockTransactionVerifier) VerifyTransaction(header, nextHeader *tendermint.Header, tx *types.TxValue) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "VerifyTransaction", header, nextHeader, tx) - ret0, _ := ret[0].(error) - return ret0 -} - -// VerifyTransaction indicates an expected call of VerifyTransaction. -func (mr *MockTransactionVerifierMockRecorder) VerifyTransaction(header, nextHeader, tx interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "VerifyTransaction", reflect.TypeOf((*MockTransactionVerifier)(nil).VerifyTransaction), header, nextHeader, tx) -} diff --git a/testutil/mocks/interchainqueries/types/expected_keepers.go b/testutil/mocks/interchainqueries/types/expected_keepers.go deleted file mode 100644 index 652d8517..00000000 --- a/testutil/mocks/interchainqueries/types/expected_keepers.go +++ /dev/null @@ -1,183 +0,0 @@ -// Code generated by MockGen. DO NOT EDIT. -// Source: ./../../x/interchainqueries/types/expected_keepers.go - -// Package mock_types is a generated GoMock package. -package mock_types - -import ( - context "context" - reflect "reflect" - - types "github.com/cosmos/cosmos-sdk/types" - types0 "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" - gomock "github.com/golang/mock/gomock" -) - -// MockAccountKeeper is a mock of AccountKeeper interface. -type MockAccountKeeper struct { - ctrl *gomock.Controller - recorder *MockAccountKeeperMockRecorder -} - -// MockAccountKeeperMockRecorder is the mock recorder for MockAccountKeeper. -type MockAccountKeeperMockRecorder struct { - mock *MockAccountKeeper -} - -// NewMockAccountKeeper creates a new mock instance. -func NewMockAccountKeeper(ctrl *gomock.Controller) *MockAccountKeeper { - mock := &MockAccountKeeper{ctrl: ctrl} - mock.recorder = &MockAccountKeeperMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockAccountKeeper) EXPECT() *MockAccountKeeperMockRecorder { - return m.recorder -} - -// GetAccount mocks base method. -func (m *MockAccountKeeper) GetAccount(ctx context.Context, addr types.AccAddress) types.AccountI { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetAccount", ctx, addr) - ret0, _ := ret[0].(types.AccountI) - return ret0 -} - -// GetAccount indicates an expected call of GetAccount. -func (mr *MockAccountKeeperMockRecorder) GetAccount(ctx, addr interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAccount", reflect.TypeOf((*MockAccountKeeper)(nil).GetAccount), ctx, addr) -} - -// MockBankKeeper is a mock of BankKeeper interface. -type MockBankKeeper struct { - ctrl *gomock.Controller - recorder *MockBankKeeperMockRecorder -} - -// MockBankKeeperMockRecorder is the mock recorder for MockBankKeeper. -type MockBankKeeperMockRecorder struct { - mock *MockBankKeeper -} - -// NewMockBankKeeper creates a new mock instance. -func NewMockBankKeeper(ctrl *gomock.Controller) *MockBankKeeper { - mock := &MockBankKeeper{ctrl: ctrl} - mock.recorder = &MockBankKeeperMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockBankKeeper) EXPECT() *MockBankKeeperMockRecorder { - return m.recorder -} - -// SendCoinsFromAccountToModule mocks base method. -func (m *MockBankKeeper) SendCoinsFromAccountToModule(ctx context.Context, senderAddr types.AccAddress, recipientModule string, amt types.Coins) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SendCoinsFromAccountToModule", ctx, senderAddr, recipientModule, amt) - ret0, _ := ret[0].(error) - return ret0 -} - -// SendCoinsFromAccountToModule indicates an expected call of SendCoinsFromAccountToModule. -func (mr *MockBankKeeperMockRecorder) SendCoinsFromAccountToModule(ctx, senderAddr, recipientModule, amt interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendCoinsFromAccountToModule", reflect.TypeOf((*MockBankKeeper)(nil).SendCoinsFromAccountToModule), ctx, senderAddr, recipientModule, amt) -} - -// SendCoinsFromModuleToAccount mocks base method. -func (m *MockBankKeeper) SendCoinsFromModuleToAccount(ctx context.Context, senderModule string, recipientAddr types.AccAddress, amt types.Coins) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SendCoinsFromModuleToAccount", ctx, senderModule, recipientAddr, amt) - ret0, _ := ret[0].(error) - return ret0 -} - -// SendCoinsFromModuleToAccount indicates an expected call of SendCoinsFromModuleToAccount. -func (mr *MockBankKeeperMockRecorder) SendCoinsFromModuleToAccount(ctx, senderModule, recipientAddr, amt interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendCoinsFromModuleToAccount", reflect.TypeOf((*MockBankKeeper)(nil).SendCoinsFromModuleToAccount), ctx, senderModule, recipientAddr, amt) -} - -// SpendableCoins mocks base method. -func (m *MockBankKeeper) SpendableCoins(ctx context.Context, addr types.AccAddress) types.Coins { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SpendableCoins", ctx, addr) - ret0, _ := ret[0].(types.Coins) - return ret0 -} - -// SpendableCoins indicates an expected call of SpendableCoins. -func (mr *MockBankKeeperMockRecorder) SpendableCoins(ctx, addr interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SpendableCoins", reflect.TypeOf((*MockBankKeeper)(nil).SpendableCoins), ctx, addr) -} - -// MockContractManagerKeeper is a mock of ContractManagerKeeper interface. -type MockContractManagerKeeper struct { - ctrl *gomock.Controller - recorder *MockContractManagerKeeperMockRecorder -} - -// MockContractManagerKeeperMockRecorder is the mock recorder for MockContractManagerKeeper. -type MockContractManagerKeeperMockRecorder struct { - mock *MockContractManagerKeeper -} - -// NewMockContractManagerKeeper creates a new mock instance. -func NewMockContractManagerKeeper(ctrl *gomock.Controller) *MockContractManagerKeeper { - mock := &MockContractManagerKeeper{ctrl: ctrl} - mock.recorder = &MockContractManagerKeeperMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockContractManagerKeeper) EXPECT() *MockContractManagerKeeperMockRecorder { - return m.recorder -} - -// HasContractInfo mocks base method. -func (m *MockContractManagerKeeper) HasContractInfo(ctx context.Context, contractAddress types.AccAddress) bool { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "HasContractInfo", ctx, contractAddress) - ret0, _ := ret[0].(bool) - return ret0 -} - -// HasContractInfo indicates an expected call of HasContractInfo. -func (mr *MockContractManagerKeeperMockRecorder) HasContractInfo(ctx, contractAddress interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HasContractInfo", reflect.TypeOf((*MockContractManagerKeeper)(nil).HasContractInfo), ctx, contractAddress) -} - -// SudoKVQueryResult mocks base method. -func (m *MockContractManagerKeeper) SudoKVQueryResult(ctx context.Context, contractAddress types.AccAddress, queryID uint64) ([]byte, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SudoKVQueryResult", ctx, contractAddress, queryID) - ret0, _ := ret[0].([]byte) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// SudoKVQueryResult indicates an expected call of SudoKVQueryResult. -func (mr *MockContractManagerKeeperMockRecorder) SudoKVQueryResult(ctx, contractAddress, queryID interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SudoKVQueryResult", reflect.TypeOf((*MockContractManagerKeeper)(nil).SudoKVQueryResult), ctx, contractAddress, queryID) -} - -// SudoTxQueryResult mocks base method. -func (m *MockContractManagerKeeper) SudoTxQueryResult(ctx context.Context, contractAddress types.AccAddress, queryID uint64, height types0.Height, data []byte) ([]byte, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SudoTxQueryResult", ctx, contractAddress, queryID, height, data) - ret0, _ := ret[0].([]byte) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// SudoTxQueryResult indicates an expected call of SudoTxQueryResult. -func (mr *MockContractManagerKeeperMockRecorder) SudoTxQueryResult(ctx, contractAddress, queryID, height, data interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SudoTxQueryResult", reflect.TypeOf((*MockContractManagerKeeper)(nil).SudoTxQueryResult), ctx, contractAddress, queryID, height, data) -} diff --git a/testutil/mocks/interchainqueries/types/verify.go b/testutil/mocks/interchainqueries/types/verify.go deleted file mode 100644 index 571f0026..00000000 --- a/testutil/mocks/interchainqueries/types/verify.go +++ /dev/null @@ -1,106 +0,0 @@ -// Code generated by MockGen. DO NOT EDIT. -// Source: ./../../x/interchainqueries/types/verify.go - -// Package mock_types is a generated GoMock package. -package mock_types - -import ( - reflect "reflect" - - types "github.com/Nolus-Protocol/nolus-core/x/interchainqueries/types" - types0 "github.com/cosmos/cosmos-sdk/codec/types" - types1 "github.com/cosmos/cosmos-sdk/types" - keeper "github.com/cosmos/ibc-go/v8/modules/core/02-client/keeper" - exported "github.com/cosmos/ibc-go/v8/modules/core/exported" - tendermint "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" - gomock "github.com/golang/mock/gomock" -) - -// MockHeaderVerifier is a mock of HeaderVerifier interface. -type MockHeaderVerifier struct { - ctrl *gomock.Controller - recorder *MockHeaderVerifierMockRecorder -} - -// MockHeaderVerifierMockRecorder is the mock recorder for MockHeaderVerifier. -type MockHeaderVerifierMockRecorder struct { - mock *MockHeaderVerifier -} - -// NewMockHeaderVerifier creates a new mock instance. -func NewMockHeaderVerifier(ctrl *gomock.Controller) *MockHeaderVerifier { - mock := &MockHeaderVerifier{ctrl: ctrl} - mock.recorder = &MockHeaderVerifierMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockHeaderVerifier) EXPECT() *MockHeaderVerifierMockRecorder { - return m.recorder -} - -// UnpackHeader mocks base method. -func (m *MockHeaderVerifier) UnpackHeader(any *types0.Any) (exported.ClientMessage, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "UnpackHeader", any) - ret0, _ := ret[0].(exported.ClientMessage) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// UnpackHeader indicates an expected call of UnpackHeader. -func (mr *MockHeaderVerifierMockRecorder) UnpackHeader(any interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UnpackHeader", reflect.TypeOf((*MockHeaderVerifier)(nil).UnpackHeader), any) -} - -// VerifyHeaders mocks base method. -func (m *MockHeaderVerifier) VerifyHeaders(ctx types1.Context, cleintkeeper keeper.Keeper, clientID string, header, nextHeader exported.ClientMessage) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "VerifyHeaders", ctx, cleintkeeper, clientID, header, nextHeader) - ret0, _ := ret[0].(error) - return ret0 -} - -// VerifyHeaders indicates an expected call of VerifyHeaders. -func (mr *MockHeaderVerifierMockRecorder) VerifyHeaders(ctx, cleintkeeper, clientID, header, nextHeader interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "VerifyHeaders", reflect.TypeOf((*MockHeaderVerifier)(nil).VerifyHeaders), ctx, cleintkeeper, clientID, header, nextHeader) -} - -// MockTransactionVerifier is a mock of TransactionVerifier interface. -type MockTransactionVerifier struct { - ctrl *gomock.Controller - recorder *MockTransactionVerifierMockRecorder -} - -// MockTransactionVerifierMockRecorder is the mock recorder for MockTransactionVerifier. -type MockTransactionVerifierMockRecorder struct { - mock *MockTransactionVerifier -} - -// NewMockTransactionVerifier creates a new mock instance. -func NewMockTransactionVerifier(ctrl *gomock.Controller) *MockTransactionVerifier { - mock := &MockTransactionVerifier{ctrl: ctrl} - mock.recorder = &MockTransactionVerifierMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockTransactionVerifier) EXPECT() *MockTransactionVerifierMockRecorder { - return m.recorder -} - -// VerifyTransaction mocks base method. -func (m *MockTransactionVerifier) VerifyTransaction(header, nextHeader *tendermint.Header, tx *types.TxValue) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "VerifyTransaction", header, nextHeader, tx) - ret0, _ := ret[0].(error) - return ret0 -} - -// VerifyTransaction indicates an expected call of VerifyTransaction. -func (mr *MockTransactionVerifierMockRecorder) VerifyTransaction(header, nextHeader, tx interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "VerifyTransaction", reflect.TypeOf((*MockTransactionVerifier)(nil).VerifyTransaction), header, nextHeader, tx) -} diff --git a/testutil/test_helpers.go b/testutil/test_helpers.go index 7ced718e..e00a0dd3 100644 --- a/testutil/test_helpers.go +++ b/testutil/test_helpers.go @@ -209,12 +209,6 @@ var tempDir = func() string { return dir } -// fauxMerkleModeOpt returns a BaseApp option to use a dbStoreAdapter instead of -// an IAVLStore for faster simulation speed. -func fauxMerkleModeOpt(bapp *baseapp.BaseApp) { - bapp.SetFauxMerkleMode() -} - // SetupTestingApp initializes the IBC-go testing application. func SetupTestingApp() (ibctesting.TestingApp, map[string]json.RawMessage) { db := db2.NewMemDB() diff --git a/wasmbinding/README.md b/wasmbinding/README.md index b8095fdc..a16f409b 100644 --- a/wasmbinding/README.md +++ b/wasmbinding/README.md @@ -6,16 +6,10 @@ This package allows for custom queries and custom messages sends from contract. ### What is supported - Queries: - - InterchainQueryResult - Get the result of a registered interchain query by query_id - InterchainAccountAddress - Get the interchain account address by owner_id and connection_id - - RegisteredInterchainQueries - all set of registered interchain queries. - - RegisteredInterchainQuery - registered interchain query with specified query_id - Messages: - RegisterInterchainAccount - register an interchain account - SubmitTx - submit a transaction for execution on a remote chain - - RegisterInterchainQuery - register an interchain query - - UpdateInterchainQuery - update an interchain query - - RemoveInterchainQuery - remove an interchain query ## Command line interface (CLI) diff --git a/wasmbinding/bindings/msg.go b/wasmbinding/bindings/msg.go index 7cb67b1b..e6ae2674 100644 --- a/wasmbinding/bindings/msg.go +++ b/wasmbinding/bindings/msg.go @@ -6,7 +6,6 @@ import ( paramChange "github.com/cosmos/cosmos-sdk/x/params/types/proposal" feetypes "github.com/Nolus-Protocol/nolus-core/x/feerefunder/types" - icqtypes "github.com/Nolus-Protocol/nolus-core/x/interchainqueries/types" transferwrappertypes "github.com/Nolus-Protocol/nolus-core/x/transfer/types" ) @@ -22,9 +21,6 @@ type ProtobufAny struct { type NolusMsg struct { SubmitTx *SubmitTx `json:"submit_tx,omitempty"` RegisterInterchainAccount *RegisterInterchainAccount `json:"register_interchain_account,omitempty"` - RegisterInterchainQuery *RegisterInterchainQuery `json:"register_interchain_query,omitempty"` - UpdateInterchainQuery *UpdateInterchainQuery `json:"update_interchain_query,omitempty"` - RemoveInterchainQuery *RemoveInterchainQuery `json:"remove_interchain_query,omitempty"` IBCTransfer *transferwrappertypes.MsgTransfer `json:"ibc_transfer,omitempty"` // Contractmanager types @@ -55,15 +51,6 @@ type RegisterInterchainAccountResponse struct { PortId string `json:"port_id"` } -// RegisterInterchainQuery creates a query for remote chain. -type RegisterInterchainQuery struct { - QueryType string `json:"query_type"` - Keys []*icqtypes.KVKey `json:"keys"` - TransactionsFilter string `json:"transactions_filter"` - ConnectionId string `json:"connection_id"` - UpdatePeriod uint64 `json:"update_period"` -} - type ParamChangeProposal struct { Title string `json:"title"` Description string `json:"description"` @@ -87,26 +74,6 @@ type Plan struct { Info string `json:"info"` } -// RegisterInterchainQueryResponse holds response for RegisterInterchainQuery. -type RegisterInterchainQueryResponse struct { - Id uint64 `json:"id"` -} - -type RemoveInterchainQuery struct { - QueryId uint64 `json:"query_id"` -} - -type RemoveInterchainQueryResponse struct{} - -type UpdateInterchainQuery struct { - QueryId uint64 `json:"query_id,omitempty"` - NewKeys []*icqtypes.KVKey `json:"new_keys,omitempty"` - NewUpdatePeriod uint64 `json:"new_update_period,omitempty"` - NewTransactionsFilter string `json:"new_transactions_filter,omitempty"` -} - -type UpdateInterchainQueryResponse struct{} - // MsgExecuteContract defined separate from wasmtypes since we can get away with just passing the string into bindings. type MsgExecuteContract struct { // Contract is the address of the smart contract diff --git a/wasmbinding/bindings/query.go b/wasmbinding/bindings/query.go index fb0fb605..6681b122 100644 --- a/wasmbinding/bindings/query.go +++ b/wasmbinding/bindings/query.go @@ -6,24 +6,14 @@ import ( contractmanagertypes "github.com/Nolus-Protocol/nolus-core/x/contractmanager/types" feerefundertypes "github.com/Nolus-Protocol/nolus-core/x/feerefunder/types" - sdktypes "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/query" - - ibcclienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" //nolint:staticcheck - - "github.com/Nolus-Protocol/nolus-core/x/interchainqueries/types" + //nolint:staticcheck ) // NolusQuery contains nolus custom queries. type NolusQuery struct { - // Registered Interchain Query Result for specified QueryID - InterchainQueryResult *QueryRegisteredQueryResultRequest `json:"interchain_query_result,omitempty"` // Interchain account address for specified ConnectionID and OwnerAddress InterchainAccountAddress *QueryInterchainAccountAddressRequest `json:"interchain_account_address,omitempty"` - // RegisteredInterchainQueries - RegisteredInterchainQueries *QueryRegisteredQueriesRequest `json:"registered_interchain_queries,omitempty"` - // RegisteredInterchainQuery - RegisteredInterchainQuery *QueryRegisteredQueryRequest `json:"registered_interchain_query,omitempty"` // MinIbcFee MinIbcFee *QueryMinIbcFeeRequest `json:"min_ibc_fee,omitempty"` // Contractmanager queries @@ -33,10 +23,6 @@ type NolusQuery struct { /* Requests */ -type QueryRegisteredQueryResultRequest struct { - QueryID uint64 `json:"query_id,omitempty"` -} - type QueryInterchainAccountAddressRequest struct { // owner_address is the owner of the interchain account on the controller chain OwnerAddress string `json:"owner_address,omitempty"` @@ -46,93 +32,18 @@ type QueryInterchainAccountAddressRequest struct { ConnectionID string `json:"connection_id,omitempty"` } -type QueryRegisteredQueriesRequest struct { - Owners []string `json:"owners,omitempty"` - ConnectionID string `json:"connection_id,omitempty"` - Pagination *query.PageRequest `json:"pagination,omitempty"` -} - -type QueryRegisteredQueryRequest struct { - QueryID uint64 `json:"query_id,omitempty"` -} - -/* Responses */ - -type QueryRegisteredQueryResponse struct { - RegisteredQuery *RegisteredQuery `json:"registered_query,omitempty"` -} - -type QueryRegisteredQueriesResponse struct { - RegisteredQueries []RegisteredQuery `json:"registered_queries"` -} - -type RegisteredQuery struct { - // The unique id of the registered query. - ID uint64 `json:"id"` - // The address that registered the query. - Owner string `json:"owner"` - // The KV-storage keys for which we want to get values from remote chain - Keys []*types.KVKey `json:"keys"` - // The filter for transaction search ICQ - TransactionsFilter string `json:"transactions_filter"` - // The query type identifier (i.e. 'kv' or 'tx' for now). - QueryType string `json:"query_type"` - // The IBC connection ID for getting ConsensusState to verify proofs. - ConnectionID string `json:"connection_id"` - // Parameter that defines how often the query must be updated. - UpdatePeriod uint64 `json:"update_period"` - // The local chain last block height when the query result was updated. - LastSubmittedResultLocalHeight uint64 `json:"last_submitted_result_local_height"` - // The remote chain last block height when the query result was updated. - LastSubmittedResultRemoteHeight *ibcclienttypes.Height `json:"last_submitted_result_remote_height,omitempty"` - // Amount of coins deposited for the query. - Deposit sdktypes.Coins `json:"deposit"` - // Timeout before query becomes available for everybody to remove. - SubmitTimeout uint64 `json:"submit_timeout"` - // The local chain height when the query was registered. - RegisteredAtHeight uint64 `json:"registered_at_height"` -} - type QueryMinIbcFeeRequest struct{} type QueryMinIbcFeeResponse struct { MinFee feerefundertypes.Fee `json:"min_fee"` } -func (rq RegisteredQuery) MarshalJSON() ([]byte, error) { - type AliasRQ RegisteredQuery - - a := struct { - AliasRQ - }{ - AliasRQ: (AliasRQ)(rq), - } - - // We want keys be as empty array in Json ('[]'), not 'null' - // It's easier to work with on smart-contracts side - if a.Keys == nil { - a.Keys = make([]*types.KVKey, 0) - } - - return json.Marshal(a) -} - // Query response for an interchain account address. type QueryInterchainAccountAddressResponse struct { // The corresponding interchain account address on the host chain InterchainAccountAddress string `json:"interchain_account_address,omitempty"` } -type QueryRegisteredQueryResultResponse struct { - Result *QueryResult `json:"result,omitempty"` -} - -type QueryResult struct { - KvResults []*StorageValue `json:"kv_results,omitempty"` - Height uint64 `json:"height,omitempty"` - Revision uint64 `json:"revision,omitempty"` -} - type StorageValue struct { StoragePrefix string `json:"storage_prefix,omitempty"` Key []byte `json:"key"` diff --git a/wasmbinding/custom_querier.go b/wasmbinding/custom_querier.go index 9ced73ce..c5d95fcf 100644 --- a/wasmbinding/custom_querier.go +++ b/wasmbinding/custom_querier.go @@ -19,20 +19,6 @@ func CustomQuerier(qp *QueryPlugin) func(ctx sdk.Context, request json.RawMessag } switch { - case contractQuery.InterchainQueryResult != nil: - queryID := contractQuery.InterchainQueryResult.QueryID - - response, err := qp.GetInterchainQueryResult(ctx, queryID) - if err != nil { - return nil, errors.Wrapf(err, "failed to get interchain query result: %v", err) - } - - bz, err := json.Marshal(response) - if err != nil { - return nil, errors.Wrapf(err, "failed to marshal interchain query result: %v", err) - } - - return bz, nil case contractQuery.InterchainAccountAddress != nil: interchainAccountAddress, err := qp.GetInterchainAccountAddress(ctx, contractQuery.InterchainAccountAddress) @@ -45,30 +31,6 @@ func CustomQuerier(qp *QueryPlugin) func(ctx sdk.Context, request json.RawMessag return nil, errors.Wrapf(err, "failed to marshal interchain account query response: %v", err) } - return bz, nil - case contractQuery.RegisteredInterchainQueries != nil: - registeredQueries, err := qp.GetRegisteredInterchainQueries(ctx, contractQuery.RegisteredInterchainQueries) - if err != nil { - return nil, errors.Wrapf(err, "failed to get registered queries: %v", err) - } - - bz, err := json.Marshal(registeredQueries) - if err != nil { - return nil, errors.Wrapf(err, "failed to marshal interchain account query response: %v", err) - } - - return bz, nil - case contractQuery.RegisteredInterchainQuery != nil: - registeredQuery, err := qp.GetRegisteredInterchainQuery(ctx, contractQuery.RegisteredInterchainQuery) - if err != nil { - return nil, errors.Wrapf(err, "failed to get registered queries: %v", err) - } - - bz, err := json.Marshal(registeredQuery) - if err != nil { - return nil, errors.Wrapf(err, "failed to marshal interchain account query response: %v", err) - } - return bz, nil case contractQuery.MinIbcFee != nil: minFee, err := qp.GetMinIbcFee(ctx, contractQuery.MinIbcFee) diff --git a/wasmbinding/message_plugin.go b/wasmbinding/message_plugin.go index 28af1b80..d6670418 100644 --- a/wasmbinding/message_plugin.go +++ b/wasmbinding/message_plugin.go @@ -13,8 +13,6 @@ import ( "github.com/Nolus-Protocol/nolus-core/wasmbinding/bindings" contractmanagerkeeper "github.com/Nolus-Protocol/nolus-core/x/contractmanager/keeper" - icqkeeper "github.com/Nolus-Protocol/nolus-core/x/interchainqueries/keeper" - icqtypes "github.com/Nolus-Protocol/nolus-core/x/interchainqueries/types" ictxkeeper "github.com/Nolus-Protocol/nolus-core/x/interchaintxs/keeper" ictxtypes "github.com/Nolus-Protocol/nolus-core/x/interchaintxs/types" transferwrapperkeeper "github.com/Nolus-Protocol/nolus-core/x/transfer/keeper" @@ -23,7 +21,6 @@ import ( func CustomMessageDecorator( ictx *ictxkeeper.Keeper, - icq *icqkeeper.Keeper, transferKeeper transferwrapperkeeper.KeeperTransferWrapper, contractmanagerKeeper *contractmanagerkeeper.Keeper, ) func(messenger wasmkeeper.Messenger) wasmkeeper.Messenger { @@ -32,7 +29,6 @@ func CustomMessageDecorator( Keeper: *ictx, Wrapped: old, Ictxmsgserver: ictxkeeper.NewMsgServerImpl(*ictx), - Icqmsgserver: icqkeeper.NewMsgServerImpl(*icq), transferKeeper: transferKeeper, ContractmanagerKeeper: contractmanagerKeeper, } @@ -43,7 +39,6 @@ type CustomMessenger struct { Keeper ictxkeeper.Keeper Wrapped wasmkeeper.Messenger Ictxmsgserver ictxtypes.MsgServer - Icqmsgserver icqtypes.MsgServer transferKeeper transferwrapperkeeper.KeeperTransferWrapper ContractmanagerKeeper *contractmanagerkeeper.Keeper } @@ -68,15 +63,6 @@ func (m *CustomMessenger) DispatchMsg(ctx sdk.Context, contractAddr sdk.AccAddre if contractMsg.RegisterInterchainAccount != nil { return m.registerInterchainAccount(ctx, contractAddr, contractMsg.RegisterInterchainAccount) } - if contractMsg.RegisterInterchainQuery != nil { - return m.registerInterchainQuery(ctx, contractAddr, contractMsg.RegisterInterchainQuery) - } - if contractMsg.UpdateInterchainQuery != nil { - return m.updateInterchainQuery(ctx, contractAddr, contractMsg.UpdateInterchainQuery) - } - if contractMsg.RemoveInterchainQuery != nil { - return m.removeInterchainQuery(ctx, contractAddr, contractMsg.RemoveInterchainQuery) - } if contractMsg.IBCTransfer != nil { return m.ibcTransfer(ctx, contractAddr, *contractMsg.IBCTransfer) } @@ -124,105 +110,6 @@ func (m *CustomMessenger) ibcTransfer(ctx sdk.Context, contractAddr sdk.AccAddre return nil, [][]byte{data}, msgResponses, nil } -func (m *CustomMessenger) updateInterchainQuery(ctx sdk.Context, contractAddr sdk.AccAddress, updateQuery *bindings.UpdateInterchainQuery) ([]sdk.Event, [][]byte, [][]*types.Any, error) { - response, err := m.performUpdateInterchainQuery(ctx, contractAddr, updateQuery) - if err != nil { - ctx.Logger().Debug("performUpdateInterchainQuery: failed to update interchain query", - "from_address", contractAddr.String(), - "msg", updateQuery, - "error", err, - ) - return nil, nil, nil, errors.Wrap(err, "failed to update interchain query") - } - - data, err := json.Marshal(response) - if err != nil { - ctx.Logger().Error("json.Marshal: failed to marshal UpdateInterchainQueryResponse response to JSON", - "from_address", contractAddr.String(), - "msg", updateQuery, - "error", err, - ) - return nil, nil, nil, errors.Wrap(err, "marshal json failed") - } - - ctx.Logger().Debug("interchain query updated", - "from_address", contractAddr.String(), - "msg", updateQuery, - ) - - anyResp, err := types.NewAnyWithValue(response) - if err != nil { - return nil, nil, nil, errors.Wrapf(err, "failed to convert {%T} to Any", response) - } - msgResponses := [][]*types.Any{{anyResp}} - return nil, [][]byte{data}, msgResponses, nil -} - -func (m *CustomMessenger) performUpdateInterchainQuery(ctx sdk.Context, contractAddr sdk.AccAddress, updateQuery *bindings.UpdateInterchainQuery) (*icqtypes.MsgUpdateInterchainQueryResponse, error) { - msg := icqtypes.MsgUpdateInterchainQueryRequest{ - QueryId: updateQuery.QueryId, - NewKeys: updateQuery.NewKeys, - NewUpdatePeriod: updateQuery.NewUpdatePeriod, - NewTransactionsFilter: updateQuery.NewTransactionsFilter, - Sender: contractAddr.String(), - } - - response, err := m.Icqmsgserver.UpdateInterchainQuery(ctx, &msg) - if err != nil { - return nil, errors.Wrap(err, "failed to update interchain query") - } - - return response, nil -} - -func (m *CustomMessenger) removeInterchainQuery(ctx sdk.Context, contractAddr sdk.AccAddress, removeQuery *bindings.RemoveInterchainQuery) ([]sdk.Event, [][]byte, [][]*types.Any, error) { - response, err := m.performRemoveInterchainQuery(ctx, contractAddr, removeQuery) - if err != nil { - ctx.Logger().Debug("performRemoveInterchainQuery: failed to update interchain query", - "from_address", contractAddr.String(), - "msg", removeQuery, - "error", err, - ) - return nil, nil, nil, errors.Wrap(err, "failed to remove interchain query") - } - - data, err := json.Marshal(response) - if err != nil { - ctx.Logger().Error("json.Marshal: failed to marshal RemoveInterchainQueryResponse response to JSON", - "from_address", contractAddr.String(), - "msg", removeQuery, - "error", err, - ) - return nil, nil, nil, errors.Wrap(err, "marshal json failed") - } - - ctx.Logger().Debug("interchain query removed", - "from_address", contractAddr.String(), - "msg", removeQuery, - ) - - anyResp, err := types.NewAnyWithValue(response) - if err != nil { - return nil, nil, nil, errors.Wrapf(err, "failed to convert {%T} to Any", response) - } - msgResponses := [][]*types.Any{{anyResp}} - return nil, [][]byte{data}, msgResponses, nil -} - -func (m *CustomMessenger) performRemoveInterchainQuery(ctx sdk.Context, contractAddr sdk.AccAddress, updateQuery *bindings.RemoveInterchainQuery) (*icqtypes.MsgRemoveInterchainQueryResponse, error) { - msg := icqtypes.MsgRemoveInterchainQueryRequest{ - QueryId: updateQuery.QueryId, - Sender: contractAddr.String(), - } - - response, err := m.Icqmsgserver.RemoveInterchainQuery(ctx, &msg) - if err != nil { - return nil, errors.Wrap(err, "failed to remove interchain query") - } - - return response, nil -} - func (m *CustomMessenger) submitTx(ctx sdk.Context, contractAddr sdk.AccAddress, submitTx *bindings.SubmitTx) ([]sdk.Event, [][]byte, [][]*types.Any, error) { response, err := m.performSubmitTx(ctx, contractAddr, submitTx) if err != nil { @@ -337,70 +224,6 @@ func (m *CustomMessenger) performRegisterInterchainAccount(ctx sdk.Context, cont return response, nil } -func (m *CustomMessenger) registerInterchainQuery(ctx sdk.Context, contractAddr sdk.AccAddress, reg *bindings.RegisterInterchainQuery) ([]sdk.Event, [][]byte, [][]*types.Any, error) { - response, err := m.performRegisterInterchainQuery(ctx, contractAddr, reg) - if err != nil { - ctx.Logger().Debug("performRegisterInterchainQuery: failed to register interchain query", - "from_address", contractAddr.String(), - "query_type", reg.QueryType, - "kv_keys", icqtypes.KVKeys(reg.Keys).String(), - "transactions_filter", reg.TransactionsFilter, - "connection_id", reg.ConnectionId, - "update_period", reg.UpdatePeriod, - "error", err, - ) - return nil, nil, nil, errors.Wrap(err, "failed to register interchain query") - } - - data, err := json.Marshal(response) - if err != nil { - ctx.Logger().Error("json.Marshal: failed to marshal register interchain query response to JSON", - "from_address", contractAddr.String(), - "kv_keys", icqtypes.KVKeys(reg.Keys).String(), - "transactions_filter", reg.TransactionsFilter, - "connection_id", reg.ConnectionId, - "update_period", reg.UpdatePeriod, - "error", err, - ) - return nil, nil, nil, errors.Wrap(err, "marshal json failed") - } - - ctx.Logger().Debug("registered interchain query", - "from_address", contractAddr.String(), - "query_type", reg.QueryType, - "kv_keys", icqtypes.KVKeys(reg.Keys).String(), - "transactions_filter", reg.TransactionsFilter, - "connection_id", reg.ConnectionId, - "update_period", reg.UpdatePeriod, - "query_id", response.Id, - ) - - anyResp, err := types.NewAnyWithValue(response) - if err != nil { - return nil, nil, nil, errors.Wrapf(err, "failed to convert {%T} to Any", response) - } - msgResponses := [][]*types.Any{{anyResp}} - return nil, [][]byte{data}, msgResponses, nil -} - -func (m *CustomMessenger) performRegisterInterchainQuery(ctx sdk.Context, contractAddr sdk.AccAddress, reg *bindings.RegisterInterchainQuery) (*icqtypes.MsgRegisterInterchainQueryResponse, error) { - msg := icqtypes.MsgRegisterInterchainQuery{ - Keys: reg.Keys, - TransactionsFilter: reg.TransactionsFilter, - QueryType: reg.QueryType, - ConnectionId: reg.ConnectionId, - UpdatePeriod: reg.UpdatePeriod, - Sender: contractAddr.String(), - } - - response, err := m.Icqmsgserver.RegisterInterchainQuery(ctx, &msg) - if err != nil { - return nil, errors.Wrap(err, "failed to register interchain query") - } - - return response, nil -} - func (m *CustomMessenger) resubmitFailure(ctx sdk.Context, contractAddr sdk.AccAddress, resubmitFailure *bindings.ResubmitFailure) ([]sdk.Event, [][]byte, [][]*types.Any, error) { failure, err := m.ContractmanagerKeeper.GetFailure(ctx, contractAddr, resubmitFailure.FailureId) if err != nil { diff --git a/wasmbinding/queries.go b/wasmbinding/queries.go index c9d73732..6780f2eb 100644 --- a/wasmbinding/queries.go +++ b/wasmbinding/queries.go @@ -7,35 +7,10 @@ import ( "github.com/Nolus-Protocol/nolus-core/wasmbinding/bindings" - errorsmod "cosmossdk.io/errors" - contractmanagertypes "github.com/Nolus-Protocol/nolus-core/x/contractmanager/types" - "github.com/Nolus-Protocol/nolus-core/x/interchainqueries/types" icatypes "github.com/Nolus-Protocol/nolus-core/x/interchaintxs/types" ) -func (qp *QueryPlugin) GetInterchainQueryResult(ctx sdk.Context, queryID uint64) (*bindings.QueryRegisteredQueryResultResponse, error) { - grpcResp, err := qp.icqKeeper.GetQueryResultByID(ctx, queryID) - if err != nil { - return nil, err - } - resp := bindings.QueryResult{ - KvResults: make([]*bindings.StorageValue, 0, len(grpcResp.KvResults)), - Height: grpcResp.GetHeight(), - Revision: grpcResp.GetRevision(), - } - for _, grpcKv := range grpcResp.GetKvResults() { - kv := bindings.StorageValue{ - StoragePrefix: grpcKv.GetStoragePrefix(), - Key: grpcKv.GetKey(), - Value: grpcKv.GetValue(), - } - resp.KvResults = append(resp.KvResults, &kv) - } - - return &bindings.QueryRegisteredQueryResultResponse{Result: &resp}, nil -} - func (qp *QueryPlugin) GetInterchainAccountAddress(ctx sdk.Context, req *bindings.QueryInterchainAccountAddressRequest) (*bindings.QueryInterchainAccountAddressResponse, error) { grpcReq := icatypes.QueryInterchainAccountAddressRequest{ OwnerAddress: req.OwnerAddress, @@ -51,43 +26,6 @@ func (qp *QueryPlugin) GetInterchainAccountAddress(ctx sdk.Context, req *binding return &bindings.QueryInterchainAccountAddressResponse{InterchainAccountAddress: grpcResp.GetInterchainAccountAddress()}, nil } -func (qp *QueryPlugin) GetRegisteredInterchainQueries(ctx sdk.Context, query *bindings.QueryRegisteredQueriesRequest) (*bindings.QueryRegisteredQueriesResponse, error) { - grpcResp, err := qp.icqKeeper.GetRegisteredQueries(ctx, &types.QueryRegisteredQueriesRequest{ - Owners: query.Owners, - ConnectionId: query.ConnectionID, - Pagination: &sdkquery.PageRequest{ - Key: query.Pagination.Key, - Offset: query.Pagination.Offset, - Limit: query.Pagination.Limit, - CountTotal: query.Pagination.CountTotal, - Reverse: query.Pagination.Reverse, - }, - }) - if err != nil { - return nil, err - } - - resp := bindings.QueryRegisteredQueriesResponse{RegisteredQueries: make([]bindings.RegisteredQuery, 0, len(grpcResp.GetRegisteredQueries()))} - for _, grpcQuery := range grpcResp.GetRegisteredQueries() { - query := mapGRPCRegisteredQueryToWasmBindings(grpcQuery) - resp.RegisteredQueries = append(resp.RegisteredQueries, query) - } - return &resp, nil -} - -func (qp *QueryPlugin) GetRegisteredInterchainQuery(ctx sdk.Context, req *bindings.QueryRegisteredQueryRequest) (*bindings.QueryRegisteredQueryResponse, error) { - grpcResp, err := qp.icqKeeper.GetQueryByID(ctx, req.QueryID) - if err != nil { - return nil, err - } - if grpcResp == nil { - return nil, errorsmod.Wrapf(types.ErrEmptyResult, "interchain query response empty for query id %d", req.QueryID) - } - query := mapGRPCRegisteredQueryToWasmBindings(*grpcResp) - - return &bindings.QueryRegisteredQueryResponse{RegisteredQuery: &query}, nil -} - func (qp *QueryPlugin) GetMinIbcFee(ctx sdk.Context, _ *bindings.QueryMinIbcFeeRequest) (*bindings.QueryMinIbcFeeResponse, error) { fee := qp.feeRefunderKeeper.GetMinFee(ctx) return &bindings.QueryMinIbcFeeResponse{MinFee: fee}, nil @@ -104,20 +42,3 @@ func (qp *QueryPlugin) GetFailures(ctx sdk.Context, address string, pagination * return &bindings.FailuresResponse{Failures: res.Failures}, nil } - -func mapGRPCRegisteredQueryToWasmBindings(grpcQuery types.RegisteredQuery) bindings.RegisteredQuery { - return bindings.RegisteredQuery{ - ID: grpcQuery.GetId(), - Owner: grpcQuery.GetOwner(), - Keys: grpcQuery.GetKeys(), - TransactionsFilter: grpcQuery.GetTransactionsFilter(), - QueryType: grpcQuery.GetQueryType(), - ConnectionID: grpcQuery.GetConnectionId(), - UpdatePeriod: grpcQuery.GetUpdatePeriod(), - LastSubmittedResultLocalHeight: grpcQuery.GetLastSubmittedResultLocalHeight(), - LastSubmittedResultRemoteHeight: grpcQuery.GetLastSubmittedResultRemoteHeight(), - Deposit: grpcQuery.GetDeposit(), - SubmitTimeout: grpcQuery.GetSubmitTimeout(), - RegisteredAtHeight: grpcQuery.GetRegisteredAtHeight(), - } -} diff --git a/wasmbinding/query_plugin.go b/wasmbinding/query_plugin.go index d232f499..11e99866 100644 --- a/wasmbinding/query_plugin.go +++ b/wasmbinding/query_plugin.go @@ -3,13 +3,11 @@ package wasmbinding import ( contractmanagerkeeper "github.com/Nolus-Protocol/nolus-core/x/contractmanager/keeper" feerefunderkeeper "github.com/Nolus-Protocol/nolus-core/x/feerefunder/keeper" - icqkeeper "github.com/Nolus-Protocol/nolus-core/x/interchainqueries/keeper" icacontrollerkeeper "github.com/Nolus-Protocol/nolus-core/x/interchaintxs/keeper" ) type QueryPlugin struct { icaControllerKeeper *icacontrollerkeeper.Keeper - icqKeeper *icqkeeper.Keeper feeRefunderKeeper *feerefunderkeeper.Keeper contractmanagerKeeper *contractmanagerkeeper.Keeper } @@ -17,13 +15,11 @@ type QueryPlugin struct { // NewQueryPlugin returns a reference to a new QueryPlugin. func NewQueryPlugin( icaControllerKeeper *icacontrollerkeeper.Keeper, - icqKeeper *icqkeeper.Keeper, feeRefunderKeeper *feerefunderkeeper.Keeper, contractmanagerKeeper *contractmanagerkeeper.Keeper, ) *QueryPlugin { return &QueryPlugin{ icaControllerKeeper: icaControllerKeeper, - icqKeeper: icqKeeper, feeRefunderKeeper: feeRefunderKeeper, contractmanagerKeeper: contractmanagerKeeper, } diff --git a/wasmbinding/wasm.go b/wasmbinding/wasm.go index 94dc0959..f68eb6de 100644 --- a/wasmbinding/wasm.go +++ b/wasmbinding/wasm.go @@ -5,7 +5,6 @@ import ( contractmanagerkeeper "github.com/Nolus-Protocol/nolus-core/x/contractmanager/keeper" feerefunderkeeper "github.com/Nolus-Protocol/nolus-core/x/feerefunder/keeper" - interchainqueriesmodulekeeper "github.com/Nolus-Protocol/nolus-core/x/interchainqueries/keeper" interchaintransactionsmodulekeeper "github.com/Nolus-Protocol/nolus-core/x/interchaintxs/keeper" transfer "github.com/Nolus-Protocol/nolus-core/x/transfer/keeper" ) @@ -13,18 +12,17 @@ import ( // RegisterCustomPlugins returns wasmkeeper.Option that we can use to connect handlers for implemented custom queries and messages to the App. func RegisterCustomPlugins( ictxKeeper *interchaintransactionsmodulekeeper.Keeper, - icqKeeper *interchainqueriesmodulekeeper.Keeper, transfer transfer.KeeperTransferWrapper, feeRefunderKeeper *feerefunderkeeper.Keeper, contractmanagerKeeper *contractmanagerkeeper.Keeper, ) []wasmkeeper.Option { - wasmQueryPlugin := NewQueryPlugin(ictxKeeper, icqKeeper, feeRefunderKeeper, contractmanagerKeeper) + wasmQueryPlugin := NewQueryPlugin(ictxKeeper, feeRefunderKeeper, contractmanagerKeeper) queryPluginOpt := wasmkeeper.WithQueryPlugins(&wasmkeeper.QueryPlugins{ Custom: CustomQuerier(wasmQueryPlugin), }) messageHandlerDecoratorOpt := wasmkeeper.WithMessageHandlerDecorator( - CustomMessageDecorator(ictxKeeper, icqKeeper, transfer, contractmanagerKeeper), + CustomMessageDecorator(ictxKeeper, transfer, contractmanagerKeeper), ) return []wasmkeeper.Option{ diff --git a/x/feerefunder/types/genesis_test.go b/x/feerefunder/types/genesis_test.go index 8ca126d6..bfcf183c 100644 --- a/x/feerefunder/types/genesis_test.go +++ b/x/feerefunder/types/genesis_test.go @@ -14,9 +14,9 @@ import ( ) const ( - TestAddressNolus = "nolus13xvjxhkkxxhztcugr6weyt76eedj5ucpt4xluv" + TestAddressNolus = "nolus10pslfpsx0l3rt0cm8rhmgg75exnt3ruqrprs28" TestContractAddressJuno = "juno10h0hc64jv006rr8qy0zhlu4jsxct8qwa0vtaleayh0ujz0zynf2s2r7v8q" - TestContractAddressNolus = "nolus14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9s5c2epq" + TestContractAddressNolus = "nolus1f6cu6ypvpyh0p8d7pqnps2pduj87hda5t9v4mqrc8ra67xp28uwq4f4ysz" ) func TestGenesisState_Validate(t *testing.T) { diff --git a/x/interchainqueries/client/cli/query.go b/x/interchainqueries/client/cli/query.go deleted file mode 100644 index ccd3bb38..00000000 --- a/x/interchainqueries/client/cli/query.go +++ /dev/null @@ -1,157 +0,0 @@ -package cli - -import ( - "context" - "fmt" - "strconv" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/spf13/cobra" - - "github.com/Nolus-Protocol/nolus-core/x/interchainqueries/types" -) - -const ( - flagOwners = "owners" - flagConnectionID = "connection_id" -) - -// GetQueryCmd returns the cli query commands for this module. -func GetQueryCmd(_ string) *cobra.Command { - // Group interchainqueries 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(CmdQueryRegisteredQueries()) - cmd.AddCommand(CmdQueryRegisteredQuery()) - cmd.AddCommand(CmdQueryRegisteredQueryResult()) - cmd.AddCommand(CmdQueryLastRemoteHeight()) - - return cmd -} - -func CmdQueryRegisteredQuery() *cobra.Command { - cmd := &cobra.Command{ - Use: "registered-query [id]", - Short: "queries registered interchain query by id", - Args: cobra.ExactArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx := client.GetClientContextFromCmd(cmd) - queryClient := types.NewQueryClient(clientCtx) - - queryID, err := strconv.ParseUint(args[0], 10, 64) - if err != nil { - return fmt.Errorf("failed to parse query id: %w", err) - } - - res, err := queryClient.RegisteredQuery(context.Background(), &types.QueryRegisteredQueryRequest{QueryId: queryID}) - if err != nil { - return err - } - - return clientCtx.PrintProto(res) - }, - } - - flags.AddQueryFlagsToCmd(cmd) - - return cmd -} - -func CmdQueryRegisteredQueries() *cobra.Command { - cmd := &cobra.Command{ - Use: "registered-queries", - Short: "queries all the interchain queries in the module", - Args: cobra.NoArgs, - RunE: func(cmd *cobra.Command, _ []string) error { - clientCtx := client.GetClientContextFromCmd(cmd) - - queryClient := types.NewQueryClient(clientCtx) - - pageReq, err := client.ReadPageRequest(cmd.Flags()) - if err != nil { - return err - } - - owners, _ := cmd.Flags().GetStringArray(flagOwners) - connectionID, _ := cmd.Flags().GetString(flagConnectionID) - - res, err := queryClient.RegisteredQueries(context.Background(), &types.QueryRegisteredQueriesRequest{ - Pagination: pageReq, - Owners: owners, - ConnectionId: connectionID, - }) - if err != nil { - return err - } - - return clientCtx.PrintProto(res) - }, - } - - cmd.Flags().StringArray(flagOwners, []string{}, "(optional) filter by query owners") - cmd.Flags().String(flagConnectionID, "", "(optional) filter by connection id") - flags.AddPaginationFlagsToCmd(cmd, "registered queries") - flags.AddQueryFlagsToCmd(cmd) - - return cmd -} - -func CmdQueryRegisteredQueryResult() *cobra.Command { - cmd := &cobra.Command{ - Use: "query-result [query-id]", - Short: "queries result for registered query", - Args: cobra.ExactArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx := client.GetClientContextFromCmd(cmd) - - queryClient := types.NewQueryClient(clientCtx) - - queryID, err := strconv.ParseUint(args[0], 10, 64) - if err != nil { - return fmt.Errorf("failed to parse query id: %w", err) - } - - res, err := queryClient.QueryResult(context.Background(), &types.QueryRegisteredQueryResultRequest{QueryId: queryID}) - if err != nil { - return err - } - - return clientCtx.PrintProto(res) - }, - } - - flags.AddQueryFlagsToCmd(cmd) - - return cmd -} - -func CmdQueryLastRemoteHeight() *cobra.Command { - cmd := &cobra.Command{ - Use: "query-last-remote-height [connection-id]", - Short: "queries last remote height by connection id", - Args: cobra.ExactArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx := client.GetClientContextFromCmd(cmd) - connectionID := args[0] - queryClient := types.NewQueryClient(clientCtx) - res, err := queryClient.LastRemoteHeight(context.Background(), &types.QueryLastRemoteHeight{ConnectionId: connectionID}) - if err != nil { - return err - } - - return clientCtx.PrintProto(res) - }, - } - - flags.AddQueryFlagsToCmd(cmd) - - return cmd -} diff --git a/x/interchainqueries/client/cli/query_params.go b/x/interchainqueries/client/cli/query_params.go deleted file mode 100644 index e39a4a2d..00000000 --- a/x/interchainqueries/client/cli/query_params.go +++ /dev/null @@ -1,35 +0,0 @@ -package cli - -import ( - "context" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/spf13/cobra" - - "github.com/Nolus-Protocol/nolus-core/x/interchainqueries/types" -) - -func CmdQueryParams() *cobra.Command { - cmd := &cobra.Command{ - Use: "params", - Short: "shows the parameters of the module", - Args: cobra.NoArgs, - RunE: func(cmd *cobra.Command, _ []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/interchainqueries/client/cli/tx.go b/x/interchainqueries/client/cli/tx.go deleted file mode 100644 index baf7670b..00000000 --- a/x/interchainqueries/client/cli/tx.go +++ /dev/null @@ -1,99 +0,0 @@ -package cli - -import ( - "encoding/json" - "fmt" - "os" - "strconv" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/cosmos/cosmos-sdk/client/tx" - "github.com/spf13/cobra" - - "github.com/Nolus-Protocol/nolus-core/x/interchainqueries/types" -) - -// 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(SubmitQueryResultCmd()) - cmd.AddCommand(RemoveInterchainQueryCmd()) - - return cmd -} - -func RemoveInterchainQueryCmd() *cobra.Command { - cmd := &cobra.Command{ - Use: "remove-interchain-query [query-id]", - Short: "Remove interchain query", - Aliases: []string{"remove", "r"}, - Args: cobra.ExactArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - - sender := clientCtx.GetFromAddress().String() - queryID, err := strconv.ParseUint(args[0], 10, 64) - if err != nil { - return fmt.Errorf("failed to parse query id: %w", err) - } - - msg := types.NewMsgRemoveInterchainQuery(sender, queryID) - - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &msg) - }, - } - - flags.AddTxFlagsToCmd(cmd) - - return cmd -} - -func SubmitQueryResultCmd() *cobra.Command { - cmd := &cobra.Command{ - Use: "submit-query-result [query-id] [result-file]", - Short: "Submit query result", - Aliases: []string{"submit", "s"}, - Args: cobra.ExactArgs(2), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - - sender := clientCtx.GetFromAddress() - queryID, err := strconv.ParseUint(args[0], 10, 64) - if err != nil { - return fmt.Errorf("failed to parse query id: %w", err) - } - - resultFile := args[1] - - result, err := os.ReadFile(resultFile) - if err != nil { - return fmt.Errorf("failed to read query result file: %w", err) - } - - msg := types.MsgSubmitQueryResult{QueryId: queryID, Sender: string(sender)} - if err := json.Unmarshal(result, &msg.Result); err != nil { - return fmt.Errorf("failed to unmarshal query result: %w", err) - } - - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &msg) - }, - } - - flags.AddTxFlagsToCmd(cmd) - - return cmd -} diff --git a/x/interchainqueries/genesis.go b/x/interchainqueries/genesis.go deleted file mode 100644 index 40518587..00000000 --- a/x/interchainqueries/genesis.go +++ /dev/null @@ -1,41 +0,0 @@ -package interchainqueries - -import ( - "sort" - - sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/Nolus-Protocol/nolus-core/x/interchainqueries/keeper" - "github.com/Nolus-Protocol/nolus-core/x/interchainqueries/types" -) - -// InitGenesis initializes the capability module's state from a provided genesis -// state. -func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) { - sort.SliceStable(genState.RegisteredQueries, func(i, j int) bool { - return genState.RegisteredQueries[i].Id < genState.RegisteredQueries[j].Id - }) - - // Set all registered queries - for _, elem := range genState.RegisteredQueries { - k.SetLastRegisteredQueryKey(ctx, elem.Id) - if err := k.SaveQuery(ctx, elem); err != nil { - panic(err) - } - } - - err := k.SetParams(ctx, genState.Params) - if err != nil { - panic(err) - } -} - -// 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) - - genesis.RegisteredQueries = k.GetAllRegisteredQueries(ctx) - - return genesis -} diff --git a/x/interchainqueries/genesis_test.go b/x/interchainqueries/genesis_test.go deleted file mode 100644 index 23391b0a..00000000 --- a/x/interchainqueries/genesis_test.go +++ /dev/null @@ -1,299 +0,0 @@ -package interchainqueries_test - -import ( - "testing" - - "github.com/stretchr/testify/require" - - "github.com/Nolus-Protocol/nolus-core/testutil/common/nullify" - keepertest "github.com/Nolus-Protocol/nolus-core/testutil/interchainqueries/keeper" - "github.com/Nolus-Protocol/nolus-core/x/interchainqueries" - "github.com/Nolus-Protocol/nolus-core/x/interchainqueries/types" -) - -func TestGenesis(t *testing.T) { - genesisState := types.GenesisState{ - Params: types.DefaultParams(), - - RegisteredQueries: []*types.RegisteredQuery{ - { - Id: 4, - }, - { - Id: 3, - }, - { - Id: 2, - }, - { - Id: 1, - }, - }, - } - - require.EqualValues(t, genesisState.Params, types.DefaultParams()) - - k, ctx := keepertest.InterchainQueriesKeeper(t, nil, nil, nil, nil) - interchainqueries.InitGenesis(ctx, *k, genesisState) - got := interchainqueries.ExportGenesis(ctx, *k) - lastQueryID := k.GetLastRegisteredQueryKey(ctx) - - require.EqualValues(t, got.Params, types.DefaultParams()) - require.NotNil(t, got) - require.EqualValues(t, 4, lastQueryID) - - nullify.Fill(&genesisState) - nullify.Fill(got) - - require.ElementsMatch(t, genesisState.RegisteredQueries, got.RegisteredQueries) -} - -func TestGenesisNullQueries(t *testing.T) { - genesisState := types.GenesisState{ - Params: types.DefaultParams(), - } - - k, ctx := keepertest.InterchainQueriesKeeper(t, nil, nil, nil, nil) - interchainqueries.InitGenesis(ctx, *k, genesisState) - got := interchainqueries.ExportGenesis(ctx, *k) - - require.ElementsMatch(t, genesisState.RegisteredQueries, got.RegisteredQueries) -} - -func TestGenesisFilledQueries(t *testing.T) { - genesisState := types.GenesisState{ - Params: types.DefaultParams(), - RegisteredQueries: []*types.RegisteredQuery{ - { - Id: 4, - QueryType: "kv", - Owner: "cosmos18g0avxazu3dkgd5n5ea8h8rtl78de0hytsj9vm", - Keys: []*types.KVKey{ - { - Path: "newpath", - Key: []byte("newdata"), - }, - }, - }, - { - Id: 3, - QueryType: "kv", - Owner: "cosmos18g0avxazu3dkgd5n5ea8h8rtl78de0hytsj9vm", - Keys: []*types.KVKey{ - { - Path: "newpath", - Key: []byte("newdata"), - }, - }, - }, - { - Id: 2, - QueryType: "tx", - Owner: "cosmos18g0avxazu3dkgd5n5ea8h8rtl78de0hytsj9vm", - TransactionsFilter: `[{"field":"tx.height","op":"Eq","value":1000}]`, - }, - { - Id: 1, - QueryType: "tx", - Owner: "cosmos18g0avxazu3dkgd5n5ea8h8rtl78de0hytsj9vm", - TransactionsFilter: `[{"field":"tx.height","op":"Eq","value":1000}]`, - }, - }, - } - - k, ctx := keepertest.InterchainQueriesKeeper(t, nil, nil, nil, nil) - interchainqueries.InitGenesis(ctx, *k, genesisState) - got := interchainqueries.ExportGenesis(ctx, *k) - err := got.Validate() - require.NoError(t, err) - - require.ElementsMatch(t, genesisState.RegisteredQueries, got.RegisteredQueries) -} - -func TestGenesisMalformedQueriesInvalidTxFilter(t *testing.T) { - genesisState := types.GenesisState{ - Params: types.DefaultParams(), - RegisteredQueries: []*types.RegisteredQuery{ - { - Id: 4, - QueryType: "kv", - Owner: "cosmos18g0avxazu3dkgd5n5ea8h8rtl78de0hytsj9vm", - Keys: []*types.KVKey{ - { - Path: "newpath", - Key: []byte("newdata"), - }, - }, - }, - { - Id: 3, - QueryType: "kv", - Owner: "cosmos18g0avxazu3dkgd5n5ea8h8rtl78de0hytsj9vm", - Keys: []*types.KVKey{ - { - Path: "newpath", - Key: []byte("newdata"), - }, - }, - }, - { - Id: 2, - QueryType: "tx", - Owner: "cosmos18g0avxazu3dkgd5n5ea8h8rtl78de0hytsj9vm", - TransactionsFilter: `[{"field":"tx.height","op":"Eq","value":1000}]`, - }, - { - Id: 1, - QueryType: "tx", - Owner: "cosmos18g0avxazu3dkgd5n5ea8h8rtl78de0hytsj9vm", - TransactionsFilter: `[{"fi>= limit { - return ids - } - } - if len(ids) == 0 { - return nil - } - return ids -} - -// calculateTxQueryRemoval creates a TxQueryToRemove populated with the data relative to the query -// with the given queryID. The result TxQueryToRemove contains up to the limit tx hashes. If the -// limit is 0, it retrieves all the hashes for the given query. -func (k Keeper) calculateTxQueryRemoval(ctx sdk.Context, queryID, limit uint64) *TxQueryToRemove { - prefixStore := prefix.NewStore(ctx.KVStore(k.storeKey), types.GetSubmittedTransactionIDForQueryKeyPrefix(queryID)) - iterator := prefixStore.Iterator(nil, nil) - defer iterator.Close() - - result := &TxQueryToRemove{ID: queryID, Hashes: make([][]byte, 0, limit)} - for ; iterator.Valid(); iterator.Next() { - result.Hashes = append(result.Hashes, iterator.Key()) - if limit != 0 && uint64(len(result.Hashes)) >= limit { - result.CompleteRemoval = !iterator.Valid() - return result - } - } - result.CompleteRemoval = true - return result -} - -func (k Keeper) GetAuthority() string { - return k.authority -} - -// TxQueryToRemove contains data related to a single query listed for removal and needed in the -// removal process. -type TxQueryToRemove struct { - // ID is the query ID. - ID uint64 - // Hashes is the list of tx hashes previously submitted for the query. It can be either - // the whole list of tx hashes of the query of only a part of them to fit removal limit. - Hashes [][]byte - // CompleteRemoval represents whether all tx hashes (true) of the query or only a part of - // them (false) are collected in the Hashes field. - CompleteRemoval bool -} diff --git a/x/interchainqueries/keeper/keeper_test.go b/x/interchainqueries/keeper/keeper_test.go deleted file mode 100644 index cb8759b5..00000000 --- a/x/interchainqueries/keeper/keeper_test.go +++ /dev/null @@ -1,1778 +0,0 @@ -package keeper_test - -import ( - "encoding/hex" - "fmt" - "testing" - - "cosmossdk.io/math" - ibchost "github.com/cosmos/ibc-go/v8/modules/core/exported" - - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/stretchr/testify/suite" - - "github.com/Nolus-Protocol/nolus-core/app/params" - - wasmKeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" - abci "github.com/cometbft/cometbft/abci/types" - ibcclienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" //nolint:staticcheck - host "github.com/cosmos/ibc-go/v8/modules/core/24-host" - - banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - - "github.com/Nolus-Protocol/nolus-core/testutil" - "github.com/Nolus-Protocol/nolus-core/x/interchainqueries/keeper" - iqtypes "github.com/Nolus-Protocol/nolus-core/x/interchainqueries/types" -) - -var reflectContractPath = "../../../wasmbinding/testdata/reflect.wasm" - -type KeeperTestSuite struct { - testutil.IBCConnectionTestSuite -} - -func (suite *KeeperTestSuite) TestRegisterInterchainQuery() { - var msg iqtypes.MsgRegisterInterchainQuery - - tests := []struct { - name string - topupBalance bool - malleate func(sender string) - expectedErr error - }{ - { - "invalid connection", - true, - func(sender string) { - msg = iqtypes.MsgRegisterInterchainQuery{ - ConnectionId: "unknown", - TransactionsFilter: "[]", - Keys: nil, - QueryType: string(iqtypes.InterchainQueryTypeTX), - UpdatePeriod: 1, - Sender: sender, - } - }, - iqtypes.ErrInvalidConnectionID, - }, - { - "insufficient funds for deposit", - false, - func(sender string) { - msg = iqtypes.MsgRegisterInterchainQuery{ - ConnectionId: suite.Path.EndpointA.ConnectionID, - TransactionsFilter: "[]", - Keys: nil, - QueryType: string(iqtypes.InterchainQueryTypeTX), - UpdatePeriod: 1, - Sender: sender, - } - }, - sdkerrors.ErrInsufficientFunds, - }, - { - "not a contract address", - false, - func(_ string) { - msg = iqtypes.MsgRegisterInterchainQuery{ - ConnectionId: suite.Path.EndpointA.ConnectionID, - TransactionsFilter: "[]", - Keys: nil, - QueryType: string(iqtypes.InterchainQueryTypeTX), - UpdatePeriod: 1, - Sender: wasmKeeper.RandomAccountAddress(suite.T()).String(), - } - }, - iqtypes.ErrNotContract, - }, - { - "invalid bech32 sender address", - false, - func(_ string) { - msg = iqtypes.MsgRegisterInterchainQuery{ - ConnectionId: suite.Path.EndpointA.ConnectionID, - TransactionsFilter: "[]", - Keys: nil, - QueryType: string(iqtypes.InterchainQueryTypeTX), - UpdatePeriod: 1, - Sender: "notbech32", - } - }, - sdkerrors.ErrInvalidAddress, - }, - { - "valid", - true, - func(sender string) { - msg = iqtypes.MsgRegisterInterchainQuery{ - ConnectionId: suite.Path.EndpointA.ConnectionID, - TransactionsFilter: "[]", - Keys: nil, - QueryType: string(iqtypes.InterchainQueryTypeTX), - UpdatePeriod: 1, - Sender: sender, - } - }, - nil, - }, - } - - for _, tt := range tests { - suite.SetupTest() - - var ( - ctx = suite.ChainA.GetContext() - contractOwner = wasmKeeper.RandomAccountAddress(suite.T()) - ) - - // Store code and instantiate reflect contract. - codeID := suite.StoreTestCode(ctx, contractOwner, reflectContractPath) - contractAddress := suite.InstantiateTestContract(ctx, contractOwner, codeID) - suite.Require().NotEmpty(contractAddress) - - err := testutil.SetupICAPath(suite.Path, contractAddress.String()) - suite.Require().NoError(err) - - tt.malleate(contractAddress.String()) - - if tt.topupBalance { - // Top up contract address with native coins for deposit - senderAddress := suite.ChainA.SenderAccounts[0].SenderAccount.GetAddress() - suite.TopUpWallet(ctx, senderAddress, contractAddress) - } - - msgSrv := keeper.NewMsgServerImpl(*suite.GetNolusZoneApp(suite.ChainA).InterchainQueriesKeeper) - - res, err := msgSrv.RegisterInterchainQuery(ctx, &msg) - - if tt.expectedErr != nil { - suite.Require().ErrorIs(err, tt.expectedErr) - suite.Require().Nil(res) - } else { - query, _ := keeper.Keeper.RegisteredQuery( - *suite.GetNolusZoneApp(suite.ChainA).InterchainQueriesKeeper, ctx, - &iqtypes.QueryRegisteredQueryRequest{QueryId: 1}) - - suite.Require().Equal(iqtypes.DefaultQueryDeposit, query.RegisteredQuery.Deposit) - suite.Require().Equal(iqtypes.DefaultQuerySubmitTimeout, query.RegisteredQuery.SubmitTimeout) - suite.Require().NoError(err) - suite.Require().NotNil(res) - } - } -} - -func (suite *KeeperTestSuite) TestUpdateInterchainQuery() { - var msg iqtypes.MsgUpdateInterchainQueryRequest - originalKVQuery := iqtypes.MsgRegisterInterchainQuery{ - QueryType: string(iqtypes.InterchainQueryTypeKV), - Keys: []*iqtypes.KVKey{ - { - Path: "somepath", - Key: []byte("somedata"), - }, - }, - TransactionsFilter: "", - ConnectionId: suite.Path.EndpointA.ConnectionID, - UpdatePeriod: 1, - Sender: "", - } - - originalTXQuery := iqtypes.MsgRegisterInterchainQuery{ - QueryType: string(iqtypes.InterchainQueryTypeTX), - Keys: nil, - TransactionsFilter: "[]", - ConnectionId: suite.Path.EndpointA.ConnectionID, - UpdatePeriod: 1, - Sender: "", - } - - tests := []struct { - name string - malleate func(sender string) - expectedErr error - expectedPeriod uint64 - expectedQueryKeys []*iqtypes.KVKey - expectedQueryTXFilter string - query iqtypes.MsgRegisterInterchainQuery - }{ - { - "valid update period for kv", - func(sender string) { - msg = iqtypes.MsgUpdateInterchainQueryRequest{ - QueryId: 1, - NewKeys: nil, - NewUpdatePeriod: 2, - Sender: sender, - } - }, - nil, - 2, - originalKVQuery.Keys, - "", - originalKVQuery, - }, - { - "valid update period for tx", - func(sender string) { - msg = iqtypes.MsgUpdateInterchainQueryRequest{ - QueryId: 1, - NewKeys: nil, - NewUpdatePeriod: 2, - Sender: sender, - } - }, - nil, - 2, - nil, - originalTXQuery.TransactionsFilter, - originalTXQuery, - }, - { - "valid kv query data", - func(sender string) { - msg = iqtypes.MsgUpdateInterchainQueryRequest{ - QueryId: 1, - NewKeys: []*iqtypes.KVKey{ - { - Path: "newpath", - Key: []byte("newdata"), - }, - }, - NewUpdatePeriod: 0, - Sender: sender, - } - }, - nil, - originalKVQuery.UpdatePeriod, - []*iqtypes.KVKey{ - { - Path: "newpath", - Key: []byte("newdata"), - }, - }, - "", - originalKVQuery, - }, - { - "valid tx filter", - func(sender string) { - msg = iqtypes.MsgUpdateInterchainQueryRequest{ - QueryId: 1, - NewUpdatePeriod: 0, - NewTransactionsFilter: "[]", - Sender: sender, - } - }, - nil, - originalTXQuery.UpdatePeriod, - nil, - "[]", - originalTXQuery, - }, - { - "valid kv query both query keys and update period and ignore tx filter", - func(sender string) { - msg = iqtypes.MsgUpdateInterchainQueryRequest{ - QueryId: 1, - NewKeys: []*iqtypes.KVKey{ - { - Path: "newpath", - Key: []byte("newdata"), - }, - }, - NewUpdatePeriod: 2, - Sender: sender, - } - }, - nil, - 2, - []*iqtypes.KVKey{ - { - Path: "newpath", - Key: []byte("newdata"), - }, - }, - "", - originalKVQuery, - }, - { - "valid tx query both tx filter and update period and ignore query keys", - func(sender string) { - msg = iqtypes.MsgUpdateInterchainQueryRequest{ - QueryId: 1, - NewUpdatePeriod: 2, - NewTransactionsFilter: "[]", - Sender: sender, - } - }, - nil, - 2, - nil, - "[]", - originalTXQuery, - }, - { - "must fail on update filter for a kv query", - func(sender string) { - msg = iqtypes.MsgUpdateInterchainQueryRequest{ - QueryId: 1, - NewUpdatePeriod: 2, - NewTransactionsFilter: "[]", - Sender: sender, - } - }, - sdkerrors.ErrInvalidRequest, - originalKVQuery.UpdatePeriod, - originalKVQuery.Keys, - originalKVQuery.TransactionsFilter, - originalKVQuery, - }, - { - "must fail on update keys for a tx query", - func(sender string) { - msg = iqtypes.MsgUpdateInterchainQueryRequest{ - QueryId: 1, - NewKeys: []*iqtypes.KVKey{ - { - Path: "newpath", - Key: []byte("newdata"), - }, - }, - NewUpdatePeriod: 2, - Sender: sender, - } - }, - sdkerrors.ErrInvalidRequest, - originalTXQuery.UpdatePeriod, - originalTXQuery.Keys, - originalTXQuery.TransactionsFilter, - originalTXQuery, - }, - { - "invalid query id", - func(sender string) { - msg = iqtypes.MsgUpdateInterchainQueryRequest{ - QueryId: 2, - NewKeys: []*iqtypes.KVKey{ - { - Path: "newpath", - Key: []byte("newdata"), - }, - }, - NewUpdatePeriod: 2, - Sender: sender, - } - }, - iqtypes.ErrInvalidQueryID, - originalKVQuery.UpdatePeriod, - originalKVQuery.Keys, - "", - originalKVQuery, - }, - { - "failed due to auth error", - func(_ string) { - var ( - ctx = suite.ChainA.GetContext() - contractOwner = wasmKeeper.RandomAccountAddress(suite.T()) - ) - codeID := suite.StoreTestCode(ctx, contractOwner, reflectContractPath) - newContractAddress := suite.InstantiateTestContract(ctx, contractOwner, codeID) - suite.Require().NotEmpty(newContractAddress) - msg = iqtypes.MsgUpdateInterchainQueryRequest{ - QueryId: 1, - NewKeys: nil, - NewUpdatePeriod: 2, - Sender: newContractAddress.String(), - } - }, - sdkerrors.ErrUnauthorized, - originalKVQuery.UpdatePeriod, - originalKVQuery.Keys, - "", - originalKVQuery, - }, - } - - for i, tt := range tests { - tt := tt - suite.Run(fmt.Sprintf("Case %s, %d/%d tests", tt.name, i+1, len(tests)), func() { - suite.SetupTest() - - var ( - ctx = suite.ChainA.GetContext() - contractOwner = wasmKeeper.RandomAccountAddress(suite.T()) - ) - - // Store code and instantiate reflect contract. - codeID := suite.StoreTestCode(ctx, contractOwner, reflectContractPath) - contractAddress := suite.InstantiateTestContract(ctx, contractOwner, codeID) - suite.Require().NotEmpty(contractAddress) - - err := testutil.SetupICAPath(suite.Path, contractAddress.String()) - suite.Require().NoError(err) - - // Top up contract address with native coins for deposit - senderAddress := suite.ChainA.SenderAccounts[0].SenderAccount.GetAddress() - suite.TopUpWallet(ctx, senderAddress, contractAddress) - - tt.malleate(contractAddress.String()) - - iqkeeper := suite.GetNolusZoneApp(suite.ChainA).InterchainQueriesKeeper - - msgSrv := keeper.NewMsgServerImpl(*iqkeeper) - - tt.query.Sender = contractAddress.String() - resRegister, err := msgSrv.RegisterInterchainQuery(ctx, &tt.query) - suite.Require().NoError(err) - suite.Require().NotNil(resRegister) - - resUpdate, err := msgSrv.UpdateInterchainQuery(ctx, &msg) - - if tt.expectedErr != nil { - suite.Require().ErrorIs(err, tt.expectedErr) - suite.Require().Nil(resUpdate) - } else { - suite.Require().NoError(err) - suite.Require().NotNil(resUpdate) - } - query, err := iqkeeper.GetQueryByID(ctx, 1) - suite.Require().NoError(err) - suite.Require().Equal(tt.expectedQueryKeys, query.GetKeys()) - suite.Require().Equal(tt.expectedQueryTXFilter, query.GetTransactionsFilter()) - suite.Require().Equal(tt.expectedPeriod, query.GetUpdatePeriod()) - }) - } -} - -func (suite *KeeperTestSuite) TestRemoveInterchainQuery() { - suite.SetupTest() - - var msg iqtypes.MsgRemoveInterchainQueryRequest - var query iqtypes.MsgRegisterInterchainQuery - var txQueryHashes [][]byte - - tests := []struct { - name string - malleate func(sender string) - expectedErr error - }{ - { - "valid TX remove", - func(sender string) { - msg = iqtypes.MsgRemoveInterchainQueryRequest{ - QueryId: 1, - Sender: sender, - } - query = iqtypes.MsgRegisterInterchainQuery{ - QueryType: string(iqtypes.InterchainQueryTypeTX), - Keys: nil, - TransactionsFilter: "[]", - ConnectionId: suite.Path.EndpointA.ConnectionID, - UpdatePeriod: 1, - Sender: "", - } - txQueryHashes = [][]byte{ - []byte("txhash_1"), - []byte("txhash_2"), - } - }, - nil, - }, - { - "valid large TX remove", - func(sender string) { - msg = iqtypes.MsgRemoveInterchainQueryRequest{ - QueryId: 1, - Sender: sender, - } - query = iqtypes.MsgRegisterInterchainQuery{ - QueryType: string(iqtypes.InterchainQueryTypeTX), - Keys: nil, - TransactionsFilter: "[]", - ConnectionId: suite.Path.EndpointA.ConnectionID, - UpdatePeriod: 1, - Sender: "", - } - // types.DefaultTxQueryRemovalLimit is used here for it is both big and can be - // removed in a single tx hashes cleanup iteration - hashesCount := int(iqtypes.DefaultTxQueryRemovalLimit) - txQueryHashes = make([][]byte, 0, hashesCount) - for i := 1; i <= hashesCount; i++ { - txQueryHashes = append(txQueryHashes, []byte(fmt.Sprintf("txhash_%d", i))) - } - }, - nil, - }, - { - "valid KV remove", - func(sender string) { - msg = iqtypes.MsgRemoveInterchainQueryRequest{ - QueryId: 1, - Sender: sender, - } - query = iqtypes.MsgRegisterInterchainQuery{ - QueryType: string(iqtypes.InterchainQueryTypeKV), - Keys: []*iqtypes.KVKey{{Key: []byte("key1"), Path: "path1"}}, - TransactionsFilter: "", - ConnectionId: suite.Path.EndpointA.ConnectionID, - UpdatePeriod: 1, - Sender: "", - } - }, - nil, - }, - { - "invalid query id", - func(sender string) { - msg = iqtypes.MsgRemoveInterchainQueryRequest{ - QueryId: 2, - Sender: sender, - } - query = iqtypes.MsgRegisterInterchainQuery{ - QueryType: string(iqtypes.InterchainQueryTypeKV), - Keys: []*iqtypes.KVKey{{Key: []byte("key1"), Path: "path1"}}, - TransactionsFilter: "", - ConnectionId: suite.Path.EndpointA.ConnectionID, - UpdatePeriod: 1, - Sender: "", - } - }, - iqtypes.ErrInvalidQueryID, - }, - { - "failed due to auth error", - func(_ string) { - var ( - ctx = suite.ChainA.GetContext() - contractOwner = wasmKeeper.RandomAccountAddress(suite.T()) - ) - codeID := suite.StoreTestCode(ctx, contractOwner, reflectContractPath) - newContractAddress := suite.InstantiateTestContract(ctx, contractOwner, codeID) - suite.Require().NotEmpty(newContractAddress) - msg = iqtypes.MsgRemoveInterchainQueryRequest{ - QueryId: 1, - Sender: newContractAddress.String(), - } - query = iqtypes.MsgRegisterInterchainQuery{ - QueryType: string(iqtypes.InterchainQueryTypeKV), - Keys: []*iqtypes.KVKey{{Key: []byte("key1"), Path: "path1"}}, - TransactionsFilter: "", - ConnectionId: suite.Path.EndpointA.ConnectionID, - UpdatePeriod: 1, - Sender: "", - } - }, - sdkerrors.ErrUnauthorized, - }, - } - - for i, tt := range tests { - suite.Run(fmt.Sprintf("Case %s, %d/%d tests", tt.name, i+1, len(tests)), func() { - suite.SetupTest() - - var ( - ctx = suite.ChainA.GetContext() - contractOwner = wasmKeeper.RandomAccountAddress(suite.T()) - ) - - // Store code and instantiate reflect contract. - codeID := suite.StoreTestCode(ctx, contractOwner, reflectContractPath) - contractAddress := suite.InstantiateTestContract(ctx, contractOwner, codeID) - suite.Require().NotEmpty(contractAddress) - - err := testutil.SetupICAPath(suite.Path, contractAddress.String()) - suite.Require().NoError(err) - - // Top up contract address with native coins for deposit - bankKeeper := suite.GetNolusZoneApp(suite.ChainA).BankKeeper - senderAddress := suite.ChainA.SenderAccounts[0].SenderAccount.GetAddress() - suite.TopUpWallet(ctx, senderAddress, contractAddress) - - tt.malleate(contractAddress.String()) - iqkeeper := suite.GetNolusZoneApp(suite.ChainA).InterchainQueriesKeeper - - msgSrv := keeper.NewMsgServerImpl(*iqkeeper) - query.Sender = contractAddress.String() - - resRegister, err := msgSrv.RegisterInterchainQuery(ctx, &query) - suite.Require().NoError(err) - suite.Require().NotNil(resRegister) - - balance, balanceErr := bankKeeper.Balance( - ctx, - &banktypes.QueryBalanceRequest{ - Address: contractAddress.String(), - Denom: params.DefaultBondDenom, - }, - ) - expectedCoin := sdk.NewCoin(params.DefaultBondDenom, math.NewInt(int64(0))) - - suite.Require().NoError(balanceErr) - suite.Require().NotNil(balance) - suite.Require().Equal(&expectedCoin, balance.Balance) - - clientKey := host.FullClientStateKey(suite.Path.EndpointB.ClientID) - resp, err := suite.ChainB.App.Query(ctx, &abci.RequestQuery{ - Path: fmt.Sprintf("store/%s/key", ibchost.StoreKey), - Height: suite.ChainB.LastHeader.Header.Height - 1, - Data: clientKey, - Prove: true, - }) - suite.Require().NoError(err) - - queryType := iqtypes.InterchainQueryType(query.GetQueryType()) - switch { - case queryType.IsKV(): - err = iqkeeper.SaveKVQueryResult(ctx, 1, &iqtypes.QueryResult{ - KvResults: []*iqtypes.StorageValue{{ - Key: resp.Key, - Proof: resp.ProofOps, - Value: resp.Value, - StoragePrefix: ibchost.StoreKey, - }}, - Block: nil, - Height: 1, - Revision: 1, - }) - suite.Require().NoError(err) - case queryType.IsTX(): - for _, txQueryHash := range txQueryHashes { - iqkeeper.SaveTransactionAsProcessed(ctx, 1, txQueryHash) - suite.Require().True(iqkeeper.CheckTransactionIsAlreadyProcessed(ctx, 1, txQueryHash)) - } - } - - respRm, err := msgSrv.RemoveInterchainQuery(ctx, &msg) - // TxQueriesCleanup is supposed to be called in the app's EndBlock, but suite.ChainA.NextBlock() - // passes an incorrect context to the EndBlock and thus Keeper's store is empty. So we - // have to call it here manually and directly pass the right context into it. - iqkeeper.TxQueriesCleanup(ctx) - if tt.expectedErr != nil { - suite.Require().ErrorIs(err, tt.expectedErr) - suite.Require().Nil(respRm) - originalQuery, queryErr := iqkeeper.GetQueryByID(ctx, 1) - suite.Require().NoError(queryErr) - suite.Require().NotNil(originalQuery) - - switch { - case queryType.IsKV(): - qr, qrerr := iqkeeper.GetQueryResultByID(ctx, 1) - suite.Require().NoError(qrerr) - suite.Require().NotNil(qr) - case queryType.IsTX(): - for _, txQueryHash := range txQueryHashes { - suite.Require().True(iqkeeper.CheckTransactionIsAlreadyProcessed(ctx, 1, txQueryHash)) - } - } - } else { - balance, balanceErr := bankKeeper.Balance( - ctx, - &banktypes.QueryBalanceRequest{ - Address: contractAddress.String(), - Denom: params.DefaultBondDenom, - }, - ) - expectedCoin := sdk.NewCoin(params.DefaultBondDenom, math.NewInt(int64(1_000_000))) - - suite.Require().NoError(balanceErr) - suite.Require().NotNil(balance) - suite.Require().Equal(&expectedCoin, balance.Balance) - - suite.Require().NoError(err) - suite.Require().NotNil(respRm) - query, queryErr := iqkeeper.GetQueryByID(ctx, 1) - suite.Require().Error(queryErr, iqtypes.ErrInvalidQueryID) - suite.Require().Nil(query) - - switch { - case queryType.IsKV(): - qr, qrerr := iqkeeper.GetQueryResultByID(ctx, 1) - suite.Require().Error(qrerr, iqtypes.ErrNoQueryResult) - suite.Require().Nil(qr) - case queryType.IsTX(): - for _, txQueryHash := range txQueryHashes { - suite.Require().False(iqkeeper.CheckTransactionIsAlreadyProcessed(ctx, 1, txQueryHash)) - } - } - } - }) - } -} - -// Test get all registered queries -func (suite *KeeperTestSuite) TestGetAllRegisteredQueries() { - suite.SetupTest() - - tests := []struct { - name string - queries []*iqtypes.RegisteredQuery - }{ - { - "all registered queries", - []*iqtypes.RegisteredQuery{ - &(iqtypes.RegisteredQuery{ - Id: 1, - QueryType: string(iqtypes.InterchainQueryTypeKV), - }), - &(iqtypes.RegisteredQuery{ - Id: 2, - QueryType: string(iqtypes.InterchainQueryTypeKV), - }), - }, - }, - { - "no registered queries", - nil, - }, - } - - for i, tt := range tests { - suite.Run(fmt.Sprintf("Case %s, %d/%d tests", tt.name, i+1, len(tests)), func() { - suite.SetupTest() - - ctx := suite.ChainA.GetContext() - - iqkeeper := suite.GetNolusZoneApp(suite.ChainA).InterchainQueriesKeeper - for _, query := range tt.queries { - err := iqkeeper.SaveQuery(ctx, query) - suite.Require().NoError(err) - } - - allQueries := iqkeeper.GetAllRegisteredQueries(ctx) - - suite.Require().Equal(tt.queries, allQueries) - }) - } -} - -func (suite *KeeperTestSuite) TestSubmitInterchainQueryResult() { - var msg iqtypes.MsgSubmitQueryResult - - tests := []struct { - name string - malleate func(sender string, ctx sdk.Context) - expectedError error - }{ - { - "invalid query id", - func(sender string, ctx sdk.Context) { - // now we don't care what is really under the value, we just need to be sure that we can verify KV proofs - clientKey := host.FullClientStateKey(suite.Path.EndpointB.ClientID) - resp, err := suite.ChainB.App.Query(ctx, &abci.RequestQuery{ - Path: fmt.Sprintf("store/%s/key", ibchost.StoreKey), - Height: suite.ChainB.LastHeader.Header.Height - 1, - Data: clientKey, - Prove: true, - }) - suite.Require().NoError(err) - - msg = iqtypes.MsgSubmitQueryResult{ - QueryId: 1, - Sender: sender, - ClientId: suite.Path.EndpointA.ClientID, - Result: &iqtypes.QueryResult{ - KvResults: []*iqtypes.StorageValue{{ - Key: resp.Key, - Proof: resp.ProofOps, - Value: resp.Value, - StoragePrefix: ibchost.StoreKey, - }}, - // we don't have tests to test transactions proofs verification since it's a tendermint layer, and we don't have access to it here - Block: nil, - Height: uint64(resp.Height), - Revision: suite.ChainA.LastHeader.GetHeight().GetRevisionNumber(), - }, - } - }, - iqtypes.ErrInvalidQueryID, - }, - { - "valid KV storage proof", - func(sender string, ctx sdk.Context) { - clientKey := host.FullClientStateKey(suite.Path.EndpointB.ClientID) - registerMsg := iqtypes.MsgRegisterInterchainQuery{ - ConnectionId: suite.Path.EndpointA.ConnectionID, - Keys: []*iqtypes.KVKey{ - {Path: ibchost.StoreKey, Key: clientKey}, - }, - QueryType: string(iqtypes.InterchainQueryTypeKV), - UpdatePeriod: 1, - Sender: sender, - } - - msgSrv := keeper.NewMsgServerImpl(*suite.GetNolusZoneApp(suite.ChainA).InterchainQueriesKeeper) - - res, err := msgSrv.RegisterInterchainQuery(ctx, ®isterMsg) - suite.Require().NoError(err) - - // suite.NoError(suite.Path.EndpointB.UpdateClient()) - suite.NoError(suite.Path.EndpointA.UpdateClient()) - - resp, err := suite.ChainB.App.Query(ctx, &abci.RequestQuery{ - Path: fmt.Sprintf("store/%s/key", ibchost.StoreKey), - Height: suite.ChainB.LastHeader.Header.Height - 1, - Data: clientKey, - Prove: true, - }) - suite.Require().NoError(err) - - msg = iqtypes.MsgSubmitQueryResult{ - QueryId: res.Id, - Sender: sender, - ClientId: suite.Path.EndpointA.ClientID, - Result: &iqtypes.QueryResult{ - KvResults: []*iqtypes.StorageValue{{ - Key: resp.Key, - Proof: resp.ProofOps, - Value: resp.Value, - StoragePrefix: ibchost.StoreKey, - }}, - // we don't have tests to test transactions proofs verification since it's a tendermint layer, - // and we don't have access to it here - Block: nil, - Height: uint64(resp.Height), - Revision: suite.ChainA.LastHeader.GetHeight().GetRevisionNumber(), - }, - } - }, - nil, - }, - { - "invalid number of KvResults", - func(sender string, ctx sdk.Context) { - clientKey := host.FullClientStateKey(suite.Path.EndpointB.ClientID) - registerMsg := iqtypes.MsgRegisterInterchainQuery{ - ConnectionId: suite.Path.EndpointA.ConnectionID, - Keys: []*iqtypes.KVKey{ - {Path: ibchost.StoreKey, Key: clientKey}, - }, - QueryType: string(iqtypes.InterchainQueryTypeKV), - UpdatePeriod: 1, - Sender: sender, - } - - msgSrv := keeper.NewMsgServerImpl(*suite.GetNolusZoneApp(suite.ChainA).InterchainQueriesKeeper) - - res, err := msgSrv.RegisterInterchainQuery(ctx, ®isterMsg) - suite.Require().NoError(err) - - // suite.NoError(suite.Path.EndpointB.UpdateClient()) - suite.NoError(suite.Path.EndpointA.UpdateClient()) - - resp, err := suite.ChainB.App.Query(ctx, &abci.RequestQuery{ - Path: fmt.Sprintf("store/%s/key", ibchost.StoreKey), - Height: suite.ChainB.LastHeader.Header.Height - 1, - Data: clientKey, - Prove: true, - }) - suite.Require().NoError(err) - - msg = iqtypes.MsgSubmitQueryResult{ - QueryId: res.Id, - Sender: sender, - ClientId: suite.Path.EndpointA.ClientID, - Result: &iqtypes.QueryResult{ - KvResults: []*iqtypes.StorageValue{{ - Key: resp.Key, - Proof: resp.ProofOps, - Value: resp.Value, - StoragePrefix: ibchost.StoreKey, - }, { - Key: resp.Key, - Proof: resp.ProofOps, - Value: resp.Value, - StoragePrefix: ibchost.StoreKey, - }}, - // we don't have tests to test transactions proofs verification since it's a tendermint layer, - // and we don't have access to it here - Block: nil, - Height: uint64(resp.Height), - Revision: suite.ChainA.LastHeader.GetHeight().GetRevisionNumber(), - }, - } - }, - iqtypes.ErrInvalidSubmittedResult, - }, - { - "invalid query type", - func(sender string, ctx sdk.Context) { - clientKey := host.FullClientStateKey(suite.Path.EndpointB.ClientID) - registerMsg := iqtypes.MsgRegisterInterchainQuery{ - ConnectionId: suite.Path.EndpointA.ConnectionID, - Keys: nil, - TransactionsFilter: "[]", - QueryType: string(iqtypes.InterchainQueryTypeTX), - UpdatePeriod: 1, - Sender: sender, - } - - msgSrv := keeper.NewMsgServerImpl(*suite.GetNolusZoneApp(suite.ChainA).InterchainQueriesKeeper) - - res, err := msgSrv.RegisterInterchainQuery(ctx, ®isterMsg) - suite.Require().NoError(err) - - // suite.NoError(suite.Path.EndpointB.UpdateClient()) - suite.NoError(suite.Path.EndpointA.UpdateClient()) - - resp, err := suite.ChainB.App.Query(ctx, &abci.RequestQuery{ - Path: fmt.Sprintf("store/%s/key", ibchost.StoreKey), - Height: suite.ChainB.LastHeader.Header.Height - 1, - Data: clientKey, - Prove: true, - }) - suite.Require().NoError(err) - - msg = iqtypes.MsgSubmitQueryResult{ - QueryId: res.Id, - Sender: sender, - ClientId: suite.Path.EndpointA.ClientID, - Result: &iqtypes.QueryResult{ - KvResults: []*iqtypes.StorageValue{{ - Key: resp.Key, - Proof: resp.ProofOps, - Value: resp.Value, - StoragePrefix: ibchost.StoreKey, - }}, - // we don't have tests to test transactions proofs verification since it's a tendermint layer, - // and we don't have access to it here - Block: nil, - Height: uint64(resp.Height), - Revision: suite.ChainA.LastHeader.GetHeight().GetRevisionNumber(), - }, - } - }, - iqtypes.ErrInvalidType, - }, - { - "nil proof", - func(sender string, ctx sdk.Context) { - clientKey := host.FullClientStateKey(suite.Path.EndpointB.ClientID) - registerMsg := iqtypes.MsgRegisterInterchainQuery{ - ConnectionId: suite.Path.EndpointA.ConnectionID, - Keys: []*iqtypes.KVKey{ - {Path: ibchost.StoreKey, Key: clientKey}, - }, - QueryType: string(iqtypes.InterchainQueryTypeKV), - UpdatePeriod: 1, - Sender: sender, - } - - msgSrv := keeper.NewMsgServerImpl(*suite.GetNolusZoneApp(suite.ChainA).InterchainQueriesKeeper) - - res, err := msgSrv.RegisterInterchainQuery(ctx, ®isterMsg) - suite.Require().NoError(err) - - // suite.NoError(suite.Path.EndpointB.UpdateClient()) - suite.NoError(suite.Path.EndpointA.UpdateClient()) - - resp, err := suite.ChainB.App.Query(ctx, &abci.RequestQuery{ - Path: fmt.Sprintf("store/%s/key", ibchost.StoreKey), - Height: suite.ChainB.LastHeader.Header.Height - 1, - Data: clientKey, - Prove: true, - }) - suite.Require().NoError(err) - - msg = iqtypes.MsgSubmitQueryResult{ - QueryId: res.Id, - Sender: sender, - ClientId: suite.Path.EndpointA.ClientID, - Result: &iqtypes.QueryResult{ - KvResults: []*iqtypes.StorageValue{{ - Key: resp.Key, - Proof: nil, - Value: resp.Value, - StoragePrefix: ibchost.StoreKey, - }}, - // we don't have tests to test transactions proofs verification since it's a tendermint layer, - // and we don't have access to it here - Block: nil, - Height: uint64(resp.Height), - Revision: suite.ChainA.LastHeader.GetHeight().GetRevisionNumber(), - }, - } - }, - iqtypes.ErrInvalidType, - }, - { - "non-registered key in KV result", - func(sender string, ctx sdk.Context) { - clientKey := host.FullClientStateKey(suite.Path.EndpointB.ClientID) - - registerMsg := iqtypes.MsgRegisterInterchainQuery{ - ConnectionId: suite.Path.EndpointA.ConnectionID, - Keys: []*iqtypes.KVKey{ - {Path: ibchost.StoreKey, Key: clientKey}, - }, - QueryType: string(iqtypes.InterchainQueryTypeKV), - UpdatePeriod: 1, - Sender: sender, - } - - msgSrv := keeper.NewMsgServerImpl(*suite.GetNolusZoneApp(suite.ChainA).InterchainQueriesKeeper) - - res, err := msgSrv.RegisterInterchainQuery(ctx, ®isterMsg) - suite.Require().NoError(err) - - suite.NoError(suite.Path.EndpointA.UpdateClient()) - - resp, err := suite.ChainB.App.Query(ctx, &abci.RequestQuery{ - Path: fmt.Sprintf("store/%s/key", ibchost.StoreKey), - Height: suite.ChainB.LastHeader.Header.Height - 1, - Data: []byte("non-registered key"), - Prove: true, - }) - suite.Require().NoError(err) - - msg = iqtypes.MsgSubmitQueryResult{ - QueryId: res.Id, - Sender: sender, - ClientId: suite.Path.EndpointA.ClientID, - Result: &iqtypes.QueryResult{ - KvResults: []*iqtypes.StorageValue{{ - Key: resp.Key, - Proof: resp.ProofOps, - Value: resp.Value, - StoragePrefix: ibchost.StoreKey, - }}, - // we don't have tests to test transactions proofs verification since it's a tendermint layer, and we don't have access to it here - Block: nil, - Height: uint64(resp.Height), - Revision: suite.ChainA.LastHeader.GetHeight().GetRevisionNumber(), - }, - } - }, - iqtypes.ErrInvalidSubmittedResult, - }, - { - "non-registered path in KV result", - func(sender string, ctx sdk.Context) { - clientKey := host.FullClientStateKey(suite.Path.EndpointB.ClientID) - - registerMsg := iqtypes.MsgRegisterInterchainQuery{ - ConnectionId: suite.Path.EndpointA.ConnectionID, - Keys: []*iqtypes.KVKey{ - {Path: ibchost.StoreKey, Key: clientKey}, - }, - QueryType: string(iqtypes.InterchainQueryTypeKV), - UpdatePeriod: 1, - Sender: sender, - } - - msgSrv := keeper.NewMsgServerImpl(*suite.GetNolusZoneApp(suite.ChainA).InterchainQueriesKeeper) - - res, err := msgSrv.RegisterInterchainQuery(ctx, ®isterMsg) - suite.Require().NoError(err) - - suite.NoError(suite.Path.EndpointB.UpdateClient()) - suite.NoError(suite.Path.EndpointA.UpdateClient()) - - resp, err := suite.ChainB.App.Query(ctx, &abci.RequestQuery{ - Path: fmt.Sprintf("store/%s/key", ibchost.StoreKey), - Height: suite.ChainB.LastHeader.Header.Height - 1, - Data: clientKey, - Prove: true, - }) - suite.Require().NoError(err) - - msg = iqtypes.MsgSubmitQueryResult{ - QueryId: res.Id, - Sender: sender, - ClientId: suite.Path.EndpointA.ClientID, - Result: &iqtypes.QueryResult{ - KvResults: []*iqtypes.StorageValue{{ - Key: resp.Key, - Proof: resp.ProofOps, - Value: resp.Value, - StoragePrefix: "non-registered-path", - }}, - // we don't have tests to test transactions proofs verification since it's a tendermint layer, - // and we don't have access to it here - Block: nil, - Height: uint64(resp.Height), - Revision: suite.ChainA.LastHeader.GetHeight().GetRevisionNumber(), - }, - } - }, - iqtypes.ErrInvalidSubmittedResult, - }, - { - "non existence KV proof", - func(sender string, ctx sdk.Context) { - clientKey := []byte("non_existed_key") - - registerMsg := iqtypes.MsgRegisterInterchainQuery{ - ConnectionId: suite.Path.EndpointA.ConnectionID, - Keys: []*iqtypes.KVKey{ - {Path: ibchost.StoreKey, Key: clientKey}, - }, - QueryType: string(iqtypes.InterchainQueryTypeKV), - UpdatePeriod: 1, - Sender: sender, - } - - msgSrv := keeper.NewMsgServerImpl(*suite.GetNolusZoneApp(suite.ChainA).InterchainQueriesKeeper) - - res, err := msgSrv.RegisterInterchainQuery(ctx, ®isterMsg) - suite.Require().NoError(err) - - // suite.NoError(suite.Path.EndpointB.UpdateClient()) - suite.NoError(suite.Path.EndpointA.UpdateClient()) - - // now we don't care what is really under the value, we just need to be sure that we can verify KV proofs - resp, err := suite.ChainB.App.Query(ctx, &abci.RequestQuery{ - Path: fmt.Sprintf("store/%s/key", ibchost.StoreKey), - Height: suite.ChainB.LastHeader.Header.Height - 1, - Data: clientKey, - Prove: true, - }) - suite.Require().NoError(err) - - msg = iqtypes.MsgSubmitQueryResult{ - QueryId: res.Id, - Sender: sender, // A bit weird that query owner submits the results, but it doesn't really matter - ClientId: suite.Path.EndpointA.ClientID, - Result: &iqtypes.QueryResult{ - KvResults: []*iqtypes.StorageValue{{ - Key: resp.Key, - Proof: resp.ProofOps, - Value: resp.Value, - StoragePrefix: ibchost.StoreKey, - }}, - // we don't have tests to test transactions proofs verification since it's a tendermint layer, - // and we don't have access to it here - Block: nil, - Height: uint64(resp.Height), - Revision: suite.ChainA.LastHeader.GetHeight().GetRevisionNumber(), - }, - } - }, - nil, - }, - { - "header with invalid height", - func(sender string, ctx sdk.Context) { - clientKey := host.FullClientStateKey(suite.Path.EndpointB.ClientID) - registerMsg := iqtypes.MsgRegisterInterchainQuery{ - ConnectionId: suite.Path.EndpointA.ConnectionID, - Keys: []*iqtypes.KVKey{ - {Path: ibchost.StoreKey, Key: clientKey}, - }, - QueryType: string(iqtypes.InterchainQueryTypeKV), - UpdatePeriod: 1, - Sender: sender, - } - - msgSrv := keeper.NewMsgServerImpl(*suite.GetNolusZoneApp(suite.ChainA).InterchainQueriesKeeper) - - res, err := msgSrv.RegisterInterchainQuery(ctx, ®isterMsg) - suite.Require().NoError(err) - - suite.NoError(suite.Path.EndpointB.UpdateClient()) - suite.NoError(suite.Path.EndpointA.UpdateClient()) - - resp, err := suite.ChainB.App.Query(ctx, &abci.RequestQuery{ - Path: fmt.Sprintf("store/%s/key", ibchost.StoreKey), - Height: suite.ChainB.LastHeader.Header.Height, - Data: clientKey, - Prove: true, - }) - suite.Require().NoError(err) - - msg = iqtypes.MsgSubmitQueryResult{ - QueryId: res.Id, - Sender: sender, - ClientId: suite.Path.EndpointA.ClientID, - Result: &iqtypes.QueryResult{ - KvResults: []*iqtypes.StorageValue{{ - Key: resp.Key, - Proof: resp.ProofOps, - Value: resp.Value, - StoragePrefix: ibchost.StoreKey, - }}, - // we don't have tests to test transactions proofs verification since it's a tendermint layer, and we don't have access to it here - Block: nil, - Height: uint64(resp.Height), - Revision: suite.ChainA.LastHeader.GetHeight().GetRevisionNumber(), - }, - } - }, - ibcclienttypes.ErrConsensusStateNotFound, - }, - { - "invalid KV storage value", - func(sender string, ctx sdk.Context) { - clientKey := host.FullClientStateKey(suite.Path.EndpointB.ClientID) - registerMsg := iqtypes.MsgRegisterInterchainQuery{ - ConnectionId: suite.Path.EndpointA.ConnectionID, - Keys: []*iqtypes.KVKey{ - {Path: ibchost.StoreKey, Key: clientKey}, - }, - QueryType: string(iqtypes.InterchainQueryTypeKV), - UpdatePeriod: 1, - Sender: sender, - } - - msgSrv := keeper.NewMsgServerImpl(*suite.GetNolusZoneApp(suite.ChainA).InterchainQueriesKeeper) - - res, err := msgSrv.RegisterInterchainQuery(ctx, ®isterMsg) - suite.Require().NoError(err) - - suite.NoError(suite.Path.EndpointB.UpdateClient()) - suite.NoError(suite.Path.EndpointA.UpdateClient()) - - resp, err := suite.ChainB.App.Query(ctx, &abci.RequestQuery{ - Path: fmt.Sprintf("store/%s/key", ibchost.StoreKey), - Height: suite.ChainB.LastHeader.Header.Height - 1, - Data: clientKey, - Prove: true, - }) - suite.Require().NoError(err) - - msg = iqtypes.MsgSubmitQueryResult{ - QueryId: res.Id, - Sender: sender, - ClientId: suite.Path.EndpointA.ClientID, - Result: &iqtypes.QueryResult{ - KvResults: []*iqtypes.StorageValue{{ - Key: resp.Key, - Proof: resp.ProofOps, - Value: []byte("some evil data"), - StoragePrefix: ibchost.StoreKey, - }}, - // we don't have tests to test transactions proofs verification since it's a tendermint layer, and we don't have access to it here - Block: nil, - Height: uint64(resp.Height), - Revision: suite.ChainA.LastHeader.GetHeight().GetRevisionNumber(), - }, - } - }, - iqtypes.ErrInvalidProof, - }, - { - "query result height is too old", - func(sender string, ctx sdk.Context) { - clientKey := host.FullClientStateKey(suite.Path.EndpointB.ClientID) - - registerMsg := iqtypes.MsgRegisterInterchainQuery{ - ConnectionId: suite.Path.EndpointA.ConnectionID, - Keys: []*iqtypes.KVKey{ - {Path: ibchost.StoreKey, Key: clientKey}, - }, - QueryType: string(iqtypes.InterchainQueryTypeKV), - UpdatePeriod: 1, - Sender: sender, - } - - msgSrv := keeper.NewMsgServerImpl(*suite.GetNolusZoneApp(suite.ChainA).InterchainQueriesKeeper) - - res, err := msgSrv.RegisterInterchainQuery(ctx, ®isterMsg) - suite.Require().NoError(err) - - suite.NoError(suite.Path.EndpointB.UpdateClient()) - suite.NoError(suite.Path.EndpointA.UpdateClient()) - - // pretend like we have a very new query result - suite.NoError(suite.GetNolusZoneApp(suite.ChainA).InterchainQueriesKeeper.UpdateLastRemoteHeight(ctx, res.Id, ibcclienttypes.NewHeight(suite.ChainA.LastHeader.GetHeight().GetRevisionNumber(), 9999))) - - resp, err := suite.ChainB.App.Query(ctx, &abci.RequestQuery{ - Path: fmt.Sprintf("store/%s/key", ibchost.StoreKey), - Height: suite.ChainB.LastHeader.Header.Height - 1, - Data: clientKey, - Prove: true, - }) - suite.Require().NoError(err) - - msg = iqtypes.MsgSubmitQueryResult{ - QueryId: res.Id, - Sender: sender, - ClientId: suite.Path.EndpointA.ClientID, - Result: &iqtypes.QueryResult{ - KvResults: []*iqtypes.StorageValue{{ - Key: resp.Key, - Proof: resp.ProofOps, - Value: resp.Value, - StoragePrefix: ibchost.StoreKey, - }}, - // we don't have tests to test transactions proofs verification since it's a tendermint layer, and we don't have access to it here - Block: nil, - Height: uint64(resp.Height), - Revision: suite.ChainA.LastHeader.GetHeight().GetRevisionNumber(), - }, - } - }, - iqtypes.ErrInvalidHeight, - }, - { - "query result revision number check", - func(sender string, ctx sdk.Context) { - clientKey := host.FullClientStateKey(suite.Path.EndpointB.ClientID) - - registerMsg := iqtypes.MsgRegisterInterchainQuery{ - ConnectionId: suite.Path.EndpointA.ConnectionID, - Keys: []*iqtypes.KVKey{ - {Path: ibchost.StoreKey, Key: clientKey}, - }, - QueryType: string(iqtypes.InterchainQueryTypeKV), - UpdatePeriod: 1, - Sender: sender, - } - - msgSrv := keeper.NewMsgServerImpl(*suite.GetNolusZoneApp(suite.ChainA).InterchainQueriesKeeper) - - res, err := msgSrv.RegisterInterchainQuery(ctx, ®isterMsg) - suite.Require().NoError(err) - - suite.NoError(suite.Path.EndpointB.UpdateClient()) - suite.NoError(suite.Path.EndpointA.UpdateClient()) - - // pretend like we have a very new query result - suite.NoError(suite.GetNolusZoneApp(suite.ChainA).InterchainQueriesKeeper.UpdateLastRemoteHeight(ctx, res.Id, ibcclienttypes.NewHeight(suite.ChainA.LastHeader.GetHeight().GetRevisionNumber(), 9999))) - - // pretend like we have a very new query result with updated revision height - suite.NoError(suite.GetNolusZoneApp(suite.ChainA).InterchainQueriesKeeper.UpdateLastRemoteHeight(ctx, res.Id, ibcclienttypes.NewHeight(suite.ChainA.LastHeader.GetHeight().GetRevisionNumber()+1, 1))) - - resp, err := suite.ChainB.App.Query(ctx, &abci.RequestQuery{ - Path: fmt.Sprintf("store/%s/key", ibchost.StoreKey), - Height: suite.ChainB.LastHeader.Header.Height - 1, - Data: clientKey, - Prove: true, - }) - suite.Require().NoError(err) - - msg = iqtypes.MsgSubmitQueryResult{ - QueryId: res.Id, - Sender: sender, - ClientId: suite.Path.EndpointA.ClientID, - Result: &iqtypes.QueryResult{ - KvResults: []*iqtypes.StorageValue{{ - Key: resp.Key, - Proof: resp.ProofOps, - Value: resp.Value, - StoragePrefix: ibchost.StoreKey, - }}, - // we don't have tests to test transactions proofs verification since it's a tendermint layer, and we don't have access to it here - Block: nil, - Height: uint64(resp.Height), - // we forecefully "updated" revision height - Revision: suite.ChainA.LastHeader.GetHeight().GetRevisionNumber(), - }, - } - }, - iqtypes.ErrInvalidHeight, - }, - // in this test we check that storageValue.Key with special bytes (characters) can be properly verified - { - "non existence KV proof with special bytes in key", - func(sender string, ctx sdk.Context) { - keyWithSpecialBytes, err := hex.DecodeString("0220c746274d3fe20c2c9d06c017e15f8e03f92598fca39d7540aab02244073efe26756a756e6f78") - suite.Require().NoError(err) - - registerMsg := iqtypes.MsgRegisterInterchainQuery{ - ConnectionId: suite.Path.EndpointA.ConnectionID, - Keys: []*iqtypes.KVKey{ - {Path: ibchost.StoreKey, Key: keyWithSpecialBytes}, - }, - QueryType: string(iqtypes.InterchainQueryTypeKV), - UpdatePeriod: 1, - Sender: sender, - } - - msgSrv := keeper.NewMsgServerImpl(*suite.GetNolusZoneApp(suite.ChainA).InterchainQueriesKeeper) - - res, err := msgSrv.RegisterInterchainQuery(ctx, ®isterMsg) - suite.Require().NoError(err) - - // suite.NoError(suite.Path.EndpointB.UpdateClient()) - suite.NoError(suite.Path.EndpointA.UpdateClient()) - - // now we don't care what is really under the value, we just need to be sure that we can verify KV proofs - resp, err := suite.ChainB.App.Query(ctx, &abci.RequestQuery{ - Path: fmt.Sprintf("store/%s/key", ibchost.StoreKey), - Height: suite.ChainB.LastHeader.Header.Height - 1, - Data: keyWithSpecialBytes, - Prove: true, - }) - suite.Require().NoError(err) - - msg = iqtypes.MsgSubmitQueryResult{ - QueryId: res.Id, - Sender: sender, // A bit weird that query owner submits the results, but it doesn't really matter - ClientId: suite.Path.EndpointA.ClientID, - Result: &iqtypes.QueryResult{ - KvResults: []*iqtypes.StorageValue{{ - Key: resp.Key, - Proof: resp.ProofOps, - Value: resp.Value, - StoragePrefix: ibchost.StoreKey, - }}, - // we don't have tests to test transactions proofs verification since it's a tendermint layer, - // and we don't have access to it here - Block: nil, - Height: uint64(resp.Height), - Revision: suite.ChainA.LastHeader.GetHeight().GetRevisionNumber(), - }, - } - }, - nil, - }, - } - - for i, tc := range tests { - tt := tc - suite.Run(fmt.Sprintf("Case %s, %d/%d tests", tt.name, i+1, len(tests)), func() { - suite.SetupTest() - - var ( - ctx = suite.ChainA.GetContext() - contractOwner = wasmKeeper.RandomAccountAddress(suite.T()) - ) - - // Store code and instantiate reflect contract. - codeID := suite.StoreTestCode(ctx, contractOwner, reflectContractPath) - contractAddress := suite.InstantiateTestContract(ctx, contractOwner, codeID) - suite.Require().NotEmpty(contractAddress) - - err := testutil.SetupICAPath(suite.Path, contractAddress.String()) - suite.Require().NoError(err) - - // Top up contract address with native coins for deposit - senderAddress := suite.ChainA.SenderAccounts[0].SenderAccount.GetAddress() - suite.TopUpWallet(ctx, senderAddress, contractAddress) - - tt.malleate(contractAddress.String(), ctx) - - msgSrv := keeper.NewMsgServerImpl(*suite.GetNolusZoneApp(suite.ChainA).InterchainQueriesKeeper) - - res, err := msgSrv.SubmitQueryResult(ctx, &msg) - - if tt.expectedError != nil { - suite.Require().ErrorIs(err, tt.expectedError) - suite.Require().Nil(res) - } else { - suite.Require().NoError(err) - suite.Require().NotNil(res) - } - }) - } -} - -func (suite *KeeperTestSuite) TestTxQueriesCleanup() { - suite.Run("SingleIterSingleQuery", func() { - suite.SetupTest() - iqkeeper := suite.GetNolusZoneApp(suite.ChainA).InterchainQueriesKeeper - ctx := suite.ChainA.GetContext() - - // create a query and add results for it - var queryID uint64 = 1 - query := iqtypes.RegisteredQuery{Id: queryID, QueryType: string(iqtypes.InterchainQueryTypeTX)} - err := iqkeeper.SaveQuery(ctx, &query) - suite.Require().NoError(err) - _, err = iqkeeper.GetQueryByID(ctx, queryID) - suite.Require().Nil(err) - txHashes := suite.buildTxHashes(50) - for _, hash := range txHashes { - iqkeeper.SaveTransactionAsProcessed(ctx, queryID, hash) - suite.Require().True(iqkeeper.CheckTransactionIsAlreadyProcessed(ctx, queryID, hash)) - } - - // remove query and call cleanup - iqkeeper.RemoveQuery(ctx, &query) - iqkeeper.TxQueriesCleanup(ctx) - - // make sure removal and cleanup worked as expected - for _, hash := range txHashes { - suite.Require().Falsef(iqkeeper.CheckTransactionIsAlreadyProcessed(ctx, queryID, hash), "%s expected not to be in the store", hash) - } - suite.Require().Nilf(iqkeeper.GetTxQueriesToRemove(ctx, 0), "expected not to have any TX queries to remove after cleanup") - _, err = iqkeeper.GetQueryByID(ctx, queryID) - suite.Require().ErrorIs(err, iqtypes.ErrInvalidQueryID) - }) - - suite.Run("SingleIterMultipeQueries", func() { - suite.SetupTest() - iqkeeper := suite.GetNolusZoneApp(suite.ChainA).InterchainQueriesKeeper - ctx := suite.ChainA.GetContext() - - txHashes := suite.buildTxHashes(100) - // create a query and add results for it - var queryID1 uint64 = 1 - query1 := iqtypes.RegisteredQuery{Id: queryID1, QueryType: string(iqtypes.InterchainQueryTypeTX)} - err := iqkeeper.SaveQuery(ctx, &query1) - suite.Require().NoError(err) - _, err = iqkeeper.GetQueryByID(ctx, queryID1) - suite.Require().NoError(err) - txHashesQ1 := txHashes[:len(txHashes)/2] // first half of the build hashes come to the first query - for _, hash := range txHashesQ1 { - iqkeeper.SaveTransactionAsProcessed(ctx, queryID1, hash) - suite.Require().True(iqkeeper.CheckTransactionIsAlreadyProcessed(ctx, queryID1, hash)) - } - // create another query and add results for it - var queryID2 uint64 = 2 - query2 := iqtypes.RegisteredQuery{Id: queryID2, QueryType: string(iqtypes.InterchainQueryTypeTX)} - err = iqkeeper.SaveQuery(ctx, &query2) - suite.Require().NoError(err) - _, err = iqkeeper.GetQueryByID(ctx, queryID2) - suite.Require().NoError(err) - txHashesQ2 := txHashes[len(txHashes)/2:] // second half of the build hashes come to the second query - for _, hash := range txHashesQ2 { - iqkeeper.SaveTransactionAsProcessed(ctx, queryID2, hash) - suite.Require().True(iqkeeper.CheckTransactionIsAlreadyProcessed(ctx, queryID2, hash)) - } - - // remove queries and call cleanup - iqkeeper.RemoveQuery(ctx, &query1) - iqkeeper.RemoveQuery(ctx, &query2) - iqkeeper.TxQueriesCleanup(ctx) - - // make sure removal and cleanup worked as expected - for _, hash := range txHashesQ1 { - suite.Require().Falsef(iqkeeper.CheckTransactionIsAlreadyProcessed(ctx, queryID1, hash), "%s expected not to be in the store", hash) - } - for _, hash := range txHashesQ2 { - suite.Require().Falsef(iqkeeper.CheckTransactionIsAlreadyProcessed(ctx, queryID2, hash), "%s expected not to be in the store", hash) - } - suite.Require().Nilf(iqkeeper.GetTxQueriesToRemove(ctx, 0), "expected not to have any TX queries to remove after cleanup") - _, err = iqkeeper.GetQueryByID(ctx, queryID1) - suite.Require().ErrorIs(err, iqtypes.ErrInvalidQueryID) - _, err = iqkeeper.GetQueryByID(ctx, queryID2) - suite.Require().ErrorIs(err, iqtypes.ErrInvalidQueryID) - }) - - suite.Run("MultipleIterSingleQuery", func() { - suite.SetupTest() - iqkeeper := suite.GetNolusZoneApp(suite.ChainA).InterchainQueriesKeeper - ctx := suite.ChainA.GetContext() - - // set TxQueryRemovalLimit to a low value - limit := 50 - params := iqkeeper.GetParams(ctx) - params.TxQueryRemovalLimit = uint64(limit) - err := iqkeeper.SetParams(ctx, params) - suite.Require().NoError(err) - - // create a query and add results for it - var queryID uint64 = 1 - query := iqtypes.RegisteredQuery{Id: queryID, QueryType: string(iqtypes.InterchainQueryTypeTX)} - err = iqkeeper.SaveQuery(ctx, &query) - suite.Require().NoError(err) - _, err = iqkeeper.GetQueryByID(ctx, queryID) - suite.Require().NoError(err) - limitOverflow := 10 - txHashes := suite.buildTxHashes(limit + limitOverflow) // create a bit more hashes than the limit - for _, hash := range txHashes { - iqkeeper.SaveTransactionAsProcessed(ctx, queryID, hash) - suite.Require().True(iqkeeper.CheckTransactionIsAlreadyProcessed(ctx, queryID, hash)) - } - - // remove query and call cleanup - iqkeeper.RemoveQuery(ctx, &query) - iqkeeper.TxQueriesCleanup(ctx) - - // make sure removal and cleanup worked as expected - removed, left := suite.txHashesRemovalProgress(ctx, *iqkeeper, queryID, txHashes) - suite.Require().Equalf(limit, removed, "first cleanup removed hashes count should be as many as limit") - suite.Require().Equalf(limitOverflow, left, "first cleanup left hashes count should be as many as limitOverflow") - suite.Require().Equalf([]uint64{queryID}, iqkeeper.GetTxQueriesToRemove(ctx, 0), "expected to have a TX query to remove after partial cleanup") - _, err = iqkeeper.GetQueryByID(ctx, queryID) - suite.Require().ErrorIs(err, iqtypes.ErrInvalidQueryID) - - // call cleanup one more time and make sure it worked as expected - iqkeeper.TxQueriesCleanup(ctx) - for _, hash := range txHashes { // by this point all hashes should be removed - suite.Require().Falsef(iqkeeper.CheckTransactionIsAlreadyProcessed(ctx, queryID, hash), "%s expected not to be in the store", hash) - } - suite.Require().Nilf(iqkeeper.GetTxQueriesToRemove(ctx, 0), "expected not to have any TX queries to remove after cleanup") - _, err = iqkeeper.GetQueryByID(ctx, queryID) - suite.Require().ErrorIs(err, iqtypes.ErrInvalidQueryID) - }) - - suite.Run("MultipleIterMultipeQueries", func() { - suite.SetupTest() - iqkeeper := suite.GetNolusZoneApp(suite.ChainA).InterchainQueriesKeeper - ctx := suite.ChainA.GetContext() - - // set TxQueryRemovalLimit to a low value - limit := 50 - params := iqkeeper.GetParams(ctx) - params.TxQueryRemovalLimit = uint64(limit) - err := iqkeeper.SetParams(ctx, params) - suite.Require().NoError(err) - - limitOverflow := 10 - txHashes := suite.buildTxHashes(limit + limitOverflow) - txHashesQ1 := txHashes[:len(txHashes)/2] // first half of the build hashes come to the first query - txHashesQ2 := txHashes[len(txHashes)/2:] // second half of the build hashes come to the second query - // create a query and add results for it - var queryID1 uint64 = 1 - query1 := iqtypes.RegisteredQuery{Id: queryID1, QueryType: string(iqtypes.InterchainQueryTypeTX)} - err = iqkeeper.SaveQuery(ctx, &query1) - suite.Require().NoError(err) - _, err = iqkeeper.GetQueryByID(ctx, queryID1) - suite.Require().NoError(err) - for _, hash := range txHashesQ1 { - iqkeeper.SaveTransactionAsProcessed(ctx, queryID1, hash) - suite.Require().True(iqkeeper.CheckTransactionIsAlreadyProcessed(ctx, queryID1, hash)) - } - // create another query and add results for it - var queryID2 uint64 = 2 - query2 := iqtypes.RegisteredQuery{Id: queryID2, QueryType: string(iqtypes.InterchainQueryTypeTX)} - err = iqkeeper.SaveQuery(ctx, &query2) - suite.Require().NoError(err) - _, err = iqkeeper.GetQueryByID(ctx, queryID2) - suite.Require().NoError(err) - for _, hash := range txHashesQ2 { - iqkeeper.SaveTransactionAsProcessed(ctx, queryID2, hash) - suite.Require().True(iqkeeper.CheckTransactionIsAlreadyProcessed(ctx, queryID2, hash)) - } - - // remove queries and call cleanup - iqkeeper.RemoveQuery(ctx, &query1) - iqkeeper.RemoveQuery(ctx, &query2) - iqkeeper.TxQueriesCleanup(ctx) - - // make sure removal and cleanup worked as expected - removedQ1, leftQ1 := suite.txHashesRemovalProgress(ctx, *iqkeeper, queryID1, txHashesQ1) - removedQ2, leftQ2 := suite.txHashesRemovalProgress(ctx, *iqkeeper, queryID2, txHashesQ2) - suite.Require().Equalf(limit, removedQ1+removedQ2, "first cleanup removed hashes count should be as many as limit") - suite.Require().Equalf(limitOverflow, leftQ1+leftQ2, "first cleanup remaining hashes count should be as many as limitOverflow") - suite.Require().Equalf([]uint64{queryID2}, iqkeeper.GetTxQueriesToRemove(ctx, 0), "expected to have one TX query to remove after partial cleanup") - - // call cleanup one more time and make sure it worked as expected - iqkeeper.TxQueriesCleanup(ctx) - removedQ1, leftQ1 = suite.txHashesRemovalProgress(ctx, *iqkeeper, queryID1, txHashesQ1) - removedQ2, leftQ2 = suite.txHashesRemovalProgress(ctx, *iqkeeper, queryID2, txHashesQ2) - suite.Require().Equalf(limit+limitOverflow, removedQ1+removedQ2, "all hashes should be removed after the second cleanup") - suite.Require().Equalf(0, leftQ1+leftQ2, "no hashes should left after the second cleanup") - suite.Require().Nilf(iqkeeper.GetTxQueriesToRemove(ctx, 0), "expected not to have any TX queries to remove after cleanup") - _, err = iqkeeper.GetQueryByID(ctx, queryID1) - suite.Require().ErrorIs(err, iqtypes.ErrInvalidQueryID) - _, err = iqkeeper.GetQueryByID(ctx, queryID2) - suite.Require().ErrorIs(err, iqtypes.ErrInvalidQueryID) - }) - - suite.Run("Unlimited", func() { - suite.SetupTest() - iqkeeper := suite.GetNolusZoneApp(suite.ChainA).InterchainQueriesKeeper - ctx := suite.ChainA.GetContext() - - // set TxQueryRemovalLimit to a low value - params := iqkeeper.GetParams(ctx) - params.TxQueryRemovalLimit = 0 - err := iqkeeper.SetParams(ctx, params) - suite.Require().NoError(err) - suite.Require().Equal(uint64(0), iqkeeper.GetParams(ctx).TxQueryRemovalLimit) - - // create a query and add results for it - var queryID uint64 = 1 - query := iqtypes.RegisteredQuery{Id: queryID, QueryType: string(iqtypes.InterchainQueryTypeTX)} - err = iqkeeper.SaveQuery(ctx, &query) - suite.Require().NoError(err) - _, err = iqkeeper.GetQueryByID(ctx, queryID) - suite.Require().NoError(err) - txHashes := suite.buildTxHashes(int(iqtypes.DefaultTxQueryRemovalLimit) * 2) - for _, hash := range txHashes { - iqkeeper.SaveTransactionAsProcessed(ctx, queryID, hash) - suite.Require().True(iqkeeper.CheckTransactionIsAlreadyProcessed(ctx, queryID, hash)) - } - - // remove query and call cleanup - iqkeeper.RemoveQuery(ctx, &query) - iqkeeper.TxQueriesCleanup(ctx) - - // make sure removal and cleanup worked as expected - for _, hash := range txHashes { - suite.Require().Falsef(iqkeeper.CheckTransactionIsAlreadyProcessed(ctx, queryID, hash), "%s expected not to be in the store", hash) - } - suite.Require().Nilf(iqkeeper.GetTxQueriesToRemove(ctx, 0), "expected not to have any TX queries to remove after cleanup") - _, err = iqkeeper.GetQueryByID(ctx, queryID) - suite.Require().ErrorIs(err, iqtypes.ErrInvalidQueryID) - }) -} - -// TestRemoveFreshlyCreatedICQ mostly makes sure the query's RegisteredAtHeight field works. -func (suite *KeeperTestSuite) TestRemoveFreshlyCreatedICQ() { - suite.SetupTest() - var ( - ctx = suite.ChainA.GetContext() - contractOwner = wasmKeeper.RandomAccountAddress(suite.T()) - ) - - // Store code and instantiate reflect contract. - codeID := suite.StoreTestCode(ctx, contractOwner, reflectContractPath) - contractAddress := suite.InstantiateTestContract(ctx, contractOwner, codeID) - suite.Require().NotEmpty(contractAddress) - - // Top up contract address with native coins for deposit - senderAddress := suite.ChainA.SenderAccounts[0].SenderAccount.GetAddress() - suite.TopUpWallet(ctx, senderAddress, contractAddress) - - iqkeeper := suite.GetNolusZoneApp(suite.ChainA).InterchainQueriesKeeper - params := iqkeeper.GetParams(ctx) - params.QuerySubmitTimeout = 5 - err := iqkeeper.SetParams(ctx, params) - suite.Require().NoError(err) - msgSrv := keeper.NewMsgServerImpl(*iqkeeper) - - resRegister, err := msgSrv.RegisterInterchainQuery(ctx, &iqtypes.MsgRegisterInterchainQuery{ - QueryType: string(iqtypes.InterchainQueryTypeKV), - Keys: []*iqtypes.KVKey{{Key: []byte("key1"), Path: "path1"}}, - TransactionsFilter: "", - ConnectionId: suite.Path.EndpointA.ConnectionID, - UpdatePeriod: 1, - Sender: contractAddress.String(), - }) - suite.Require().NoError(err) - suite.Require().NotNil(resRegister) - - registeredQuery, err := iqkeeper.GetQueryByID(ctx, 1) - suite.Require().NoError(err) - suite.Require().Equal(uint64(ctx.BlockHeight()), registeredQuery.RegisteredAtHeight) - suite.Require().Equal(uint64(0), registeredQuery.LastSubmittedResultLocalHeight) - suite.Require().Equal(params.QuerySubmitTimeout, registeredQuery.SubmitTimeout) - suite.Require().Greater(uint64(ctx.BlockHeight()), registeredQuery.LastSubmittedResultLocalHeight+registeredQuery.SubmitTimeout) - - newContractAddress := suite.InstantiateTestContract(ctx, contractOwner, codeID) - suite.Require().NotEmpty(newContractAddress) - resp, err := msgSrv.RemoveInterchainQuery(ctx, &iqtypes.MsgRemoveInterchainQueryRequest{ - QueryId: 1, - Sender: newContractAddress.String(), - }) - suite.Nil(resp) - suite.ErrorContains(err, "only owner can remove a query within its service period") -} - -func (suite *KeeperTestSuite) TopUpWallet(ctx sdk.Context, sender, contractAddress sdk.AccAddress) { - coinsAmnt := sdk.NewCoins(sdk.NewCoin(params.DefaultBondDenom, math.NewInt(int64(1_000_000)))) - bankKeeper := suite.GetNolusZoneApp(suite.ChainA).BankKeeper - err := bankKeeper.SendCoins(ctx, sender, contractAddress, coinsAmnt) - suite.Require().NoError(err) -} - -// buildTxHashes generates the given amount of fake tx hashes. -func (*KeeperTestSuite) buildTxHashes(amount int) [][]byte { - txHashes := make([][]byte, 0, amount) - for i := 1; i <= amount; i++ { - txHashes = append(txHashes, []byte(fmt.Sprintf("tx_hash_%d", i))) - } - return txHashes -} - -// txHashesRemovalProgress calculates how many hashes have been removed and how many are left in the -// keeper's store for the given query. -func (*KeeperTestSuite) txHashesRemovalProgress(ctx sdk.Context, iqkeeper keeper.Keeper, queryID uint64, initHashes [][]byte) (removed, left int) { - for _, hash := range initHashes { - if iqkeeper.CheckTransactionIsAlreadyProcessed(ctx, queryID, hash) { - left++ - } else { - removed++ - } - } - return removed, left -} - -func TestKeeperTestSuite(t *testing.T) { - suite.Run(t, new(KeeperTestSuite)) -} diff --git a/x/interchainqueries/keeper/msg_server.go b/x/interchainqueries/keeper/msg_server.go deleted file mode 100644 index c9632edc..00000000 --- a/x/interchainqueries/keeper/msg_server.go +++ /dev/null @@ -1,379 +0,0 @@ -package keeper - -import ( - "bytes" - "context" - "fmt" - "strconv" - "time" - - "cosmossdk.io/errors" - tendermint "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" - - "github.com/cosmos/cosmos-sdk/telemetry" - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - ibcclienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" //nolint:staticcheck - ibcconnectiontypes "github.com/cosmos/ibc-go/v8/modules/core/03-connection/types" - ibccommitmenttypes "github.com/cosmos/ibc-go/v8/modules/core/23-commitment/types" - ics23 "github.com/cosmos/ics23/go" - - "github.com/Nolus-Protocol/nolus-core/x/interchainqueries/types" -) - -var _ types.MsgServer = msgServer{} - -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} -} - -func (m msgServer) RegisterInterchainQuery(goCtx context.Context, msg *types.MsgRegisterInterchainQuery) (*types.MsgRegisterInterchainQueryResponse, error) { - defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), LabelRegisterInterchainQuery) - - if err := msg.Validate(); err != nil { - return nil, errors.Wrap(err, "failed to validate MsgRegisterInterchainQuery") - } - - ctx := sdk.UnwrapSDKContext(goCtx) - ctx.Logger().Debug("RegisterInterchainQuery", "msg", msg) - - senderAddr, err := sdk.AccAddressFromBech32(msg.Sender) - if err != nil { - m.Logger(ctx).Debug("RegisterInterchainQuery: failed to parse sender address", "sender_address", msg.Sender) - return nil, errors.Wrapf(sdkerrors.ErrInvalidAddress, "failed to parse address: %s", msg.Sender) - } - - if !m.contractManagerKeeper.HasContractInfo(ctx, senderAddr) { - m.Logger(ctx).Debug("RegisterInterchainQuery: contract not found", "sender_address", msg.Sender) - return nil, errors.Wrapf(types.ErrNotContract, "%s is not a contract address", msg.Sender) - } - - if _, err := m.ibcKeeper.ConnectionKeeper.Connection(goCtx, &ibcconnectiontypes.QueryConnectionRequest{ConnectionId: msg.ConnectionId}); err != nil { - ctx.Logger().Debug("RegisterInterchainQuery: failed to get connection with ID", "message", msg) - return nil, errors.Wrapf(types.ErrInvalidConnectionID, "failed to get connection with ID '%s': %v", msg.ConnectionId, err) - } - - lastID := m.GetLastRegisteredQueryKey(ctx) - lastID++ - - params := m.GetParams(ctx) - - registeredQuery := &types.RegisteredQuery{ - Id: lastID, - Owner: msg.Sender, - TransactionsFilter: msg.TransactionsFilter, - Keys: msg.Keys, - QueryType: msg.QueryType, - UpdatePeriod: msg.UpdatePeriod, - ConnectionId: msg.ConnectionId, - Deposit: params.QueryDeposit, - SubmitTimeout: params.QuerySubmitTimeout, - RegisteredAtHeight: uint64(ctx.BlockHeader().Height), - } - - m.SetLastRegisteredQueryKey(ctx, lastID) - - if err := m.CollectDeposit(ctx, *registeredQuery); err != nil { - ctx.Logger().Debug("RegisterInterchainQuery: failed to collect deposit", "message", &msg, "error", err) - return nil, errors.Wrapf(err, "failed to collect deposit") - } - - if err := m.SaveQuery(ctx, registeredQuery); err != nil { - ctx.Logger().Debug("RegisterInterchainQuery: failed to save query", "message", &msg, "error", err) - return nil, errors.Wrapf(err, "failed to save query: %v", err) - } - - ctx.EventManager().EmitEvents(getEventsQueryUpdated(registeredQuery)) - - return &types.MsgRegisterInterchainQueryResponse{Id: lastID}, nil -} - -func (m msgServer) RemoveInterchainQuery(goCtx context.Context, msg *types.MsgRemoveInterchainQueryRequest) (*types.MsgRemoveInterchainQueryResponse, error) { - if err := msg.Validate(); err != nil { - return nil, errors.Wrap(err, "failed to validate MsgRemoveInterchainQueryRequest") - } - - ctx := sdk.UnwrapSDKContext(goCtx) - ctx.Logger().Debug("RemoveInterchainQuery", "msg", msg) - - query, err := m.GetQueryByID(ctx, msg.GetQueryId()) - if err != nil { - ctx.Logger().Debug("RemoveInterchainQuery: failed to GetQueryByID", - "error", err, "query_id", msg.QueryId) - return nil, errors.Wrapf(err, "failed to get query by query id: %v", err) - } - - if err := query.ValidateRemoval(ctx, msg.GetSender()); err != nil { - ctx.Logger().Debug("RemoveInterchainQuery: authorization failed", - "error", err, "msg", msg) - return nil, errors.Wrap(sdkerrors.ErrUnauthorized, err.Error()) - } - - m.RemoveQuery(ctx, query) - m.MustPayOutDeposit(ctx, query.Deposit, msg.GetSigners()[0]) - ctx.EventManager().EmitEvents(getEventsQueryRemoved(query)) - return &types.MsgRemoveInterchainQueryResponse{}, nil -} - -func (m msgServer) UpdateInterchainQuery(goCtx context.Context, msg *types.MsgUpdateInterchainQueryRequest) (*types.MsgUpdateInterchainQueryResponse, error) { - if err := msg.Validate(); err != nil { - return nil, errors.Wrap(err, "failed to validate MsgUpdateInterchainQueryRequest") - } - - ctx := sdk.UnwrapSDKContext(goCtx) - ctx.Logger().Debug("UpdateInterchainQuery", "msg", msg) - - query, err := m.GetQueryByID(ctx, msg.GetQueryId()) - if err != nil { - ctx.Logger().Debug("UpdateInterchainQuery: failed to GetQueryByID", - "error", err, "query_id", msg.QueryId) - return nil, errors.Wrapf(err, "failed to get query by query id: %v", err) - } - - if query.GetOwner() != msg.GetSender() { - ctx.Logger().Debug("UpdateInterchainQuery: authorization failed", - "msg", msg) - return nil, errors.Wrap(sdkerrors.ErrUnauthorized, "authorization failed") - } - - if err := m.validateUpdateInterchainQueryParams(query, msg); err != nil { - ctx.Logger().Debug("UpdateInterchainQuery: invalid request", - "error", err, "query_id", msg.QueryId) - return nil, errors.Wrap(sdkerrors.ErrInvalidRequest, err.Error()) - } - if msg.GetNewUpdatePeriod() > 0 { - query.UpdatePeriod = msg.GetNewUpdatePeriod() - } - if len(msg.GetNewKeys()) > 0 && types.InterchainQueryType(query.GetQueryType()).IsKV() { - query.Keys = msg.GetNewKeys() - } - if msg.GetNewTransactionsFilter() != "" && types.InterchainQueryType(query.GetQueryType()).IsTX() { - query.TransactionsFilter = msg.GetNewTransactionsFilter() - } - - if err := m.SaveQuery(ctx, query); err != nil { - ctx.Logger().Debug("UpdateInterchainQuery: failed to save query", "message", &msg, "error", err) - return nil, errors.Wrapf(err, "failed to save query by query id: %v", err) - } - - ctx.EventManager().EmitEvents(getEventsQueryUpdated(query)) - - return &types.MsgUpdateInterchainQueryResponse{}, nil -} - -func (m msgServer) SubmitQueryResult(goCtx context.Context, msg *types.MsgSubmitQueryResult) (*types.MsgSubmitQueryResultResponse, error) { - defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), LabelRegisterInterchainQuery) - - if err := msg.Validate(); err != nil { - return nil, errors.Wrap(err, "failed to validate MsgSubmitQueryResult") - } - - ctx := sdk.UnwrapSDKContext(goCtx) - ctx.Logger().Debug("SubmitQueryResult", "query_id", msg.QueryId) - - query, err := m.GetQueryByID(ctx, msg.QueryId) - if err != nil { - ctx.Logger().Debug("SubmitQueryResult: failed to GetQueryByID", - "error", err, "query_id", msg.QueryId) - return nil, errors.Wrapf(err, "failed to get query by id: %v", err) - } - - queryOwner, err := sdk.AccAddressFromBech32(query.Owner) - if err != nil { - ctx.Logger().Error("SubmitQueryResult: failed to decode AccAddressFromBech32", - "error", err, "query", query, "message", msg) - return nil, errors.Wrapf(err, "failed to decode owner contract address (%s)", query.Owner) - } - - if msg.Result.KvResults != nil { - if !types.InterchainQueryType(query.QueryType).IsKV() { - return nil, errors.Wrapf(types.ErrInvalidType, "invalid query result for query type: %s", query.QueryType) - } - if err := m.checkLastRemoteHeight(ctx, *query, ibcclienttypes.NewHeight(msg.Result.Revision, msg.Result.Height)); err != nil { - return nil, errors.Wrap(types.ErrInvalidHeight, err.Error()) - } - if len(msg.Result.KvResults) != len(query.Keys) { - return nil, errors.Wrapf(types.ErrInvalidSubmittedResult, "KV keys length from result is not equal to registered query keys length: %v != %v", len(msg.Result.KvResults), len(query.Keys)) - } - - resp, err := m.ibcKeeper.ConnectionConsensusState(goCtx, &ibcconnectiontypes.QueryConnectionConsensusStateRequest{ - ConnectionId: query.ConnectionId, - RevisionNumber: msg.Result.Revision, - RevisionHeight: msg.Result.Height + 1, - }) - if err != nil { - ctx.Logger().Debug("SubmitQueryResult: failed to get ConnectionConsensusState", - "error", err, "query", query, "message", msg) - return nil, errors.Wrapf(ibcclienttypes.ErrConsensusStateNotFound, "failed to get consensus state: %v", err) - } - consensusStateI, err := ibcclienttypes.UnpackConsensusState(resp.ConsensusState) - if err != nil { - ctx.Logger().Error("SubmitQueryResult: failed to UnpackConsensusState", - "error", err, "query", query, "message", msg) - return nil, fmt.Errorf("failed marshal: %s, %w", consensusStateI.String(), err) - } - - consensusState, ok := consensusStateI.(*tendermint.ConsensusState) - if !ok { - ctx.Logger().Error("SubmitQueryResult: failed to cast exported.ConsensusState to *tendermint.ConsensusState", - "error", err, "query", query, "message", msg) - return nil, errors.Wrapf(sdkerrors.ErrUnpackAny, "failed to cast interface exported.ConsensusState to type *tendermint.ConsensusState") - } - - clientState, err := m.GetClientState(ctx, msg.ClientId) - if err != nil { - return nil, err - } - - for index, result := range msg.Result.KvResults { - proof, err := ibccommitmenttypes.ConvertProofs(result.Proof) - if err != nil { - ctx.Logger().Debug("SubmitQueryResult: failed to ConvertProofs", - "error", err, "query", query, "message", msg) - return nil, errors.Wrapf(types.ErrInvalidType, "failed to convert crypto.ProofOps to MerkleProof: %v", err) - } - - if !bytes.Equal(result.Key, query.Keys[index].Key) { - return nil, errors.Wrapf(types.ErrInvalidSubmittedResult, "KV key from result is not equal to registered query key: %v != %v", result.Key, query.Keys[index].Key) - } - - if result.StoragePrefix != query.Keys[index].Path { - return nil, errors.Wrapf(types.ErrInvalidSubmittedResult, "KV path from result is not equal to registered query storage prefix: %v != %v", result.StoragePrefix, query.Keys[index].Path) - } - - path := ibccommitmenttypes.NewMerklePath(result.StoragePrefix, string(result.Key)) - // identify what kind proofs (non-existence proof always has *ics23.CommitmentProof_Nonexist as the first item) we got - // and call corresponding method to verify it - switch proof.GetProofs()[0].GetProof().(type) { - // we can get non-existence proof if someone queried some key which is not exists in the storage on remote chain - case *ics23.CommitmentProof_Nonexist: - if err := proof.VerifyNonMembership(clientState.ProofSpecs, consensusState.GetRoot(), path); err != nil { - ctx.Logger().Debug("SubmitQueryResult: failed to VerifyNonMembership", - "error", err, "query", query, "message", msg, "path", path) - return nil, errors.Wrapf(types.ErrInvalidProof, "failed to verify proof: %v", err) - } - result.Value = nil - case *ics23.CommitmentProof_Exist: - if err := proof.VerifyMembership(clientState.ProofSpecs, consensusState.GetRoot(), path, result.Value); err != nil { - ctx.Logger().Debug("SubmitQueryResult: failed to VerifyMembership", - "error", err, "query", query, "message", msg, "path", path) - return nil, errors.Wrapf(types.ErrInvalidProof, "failed to verify proof: %v", err) - } - default: - return nil, errors.Wrapf(types.ErrInvalidProof, "unknown proof type %T", proof.GetProofs()[0].GetProof()) - } - } - - if err = m.saveKVQueryResult(ctx, query, msg.Result); err != nil { - ctx.Logger().Error("SubmitQueryResult: failed to SaveKVQueryResult", - "error", err, "query", query, "message", msg) - return nil, errors.Wrapf(err, "failed to SaveKVQueryResult: %v", err) - } - - if msg.Result.GetAllowKvCallbacks() { - // Let the query owner contract process the query result. - if _, err := m.contractManagerKeeper.SudoKVQueryResult(ctx, queryOwner, query.Id); err != nil { - ctx.Logger().Debug("SubmitQueryResult: failed to SudoKVQueryResult", - "error", err, "query_id", query.GetId()) - return nil, errors.Wrapf(err, "contract %s rejected KV query result (query_id: %d)", - queryOwner, query.GetId()) - } - return &types.MsgSubmitQueryResultResponse{}, nil - } - } - - if msg.Result.Block != nil && msg.Result.Block.Tx != nil { - if !types.InterchainQueryType(query.QueryType).IsTX() { - return nil, errors.Wrapf(types.ErrInvalidType, "invalid query result for query type: %s", query.QueryType) - } - - if err := m.ProcessBlock(ctx, queryOwner, msg.QueryId, msg.ClientId, msg.Result.Block); err != nil { - ctx.Logger().Debug("SubmitQueryResult: failed to ProcessBlock", - "error", err, "query", query, "message", msg) - return nil, errors.Wrapf(err, "failed to ProcessBlock: %v", err) - } - - if err = m.UpdateLastLocalHeight(ctx, query.Id, uint64(ctx.BlockHeight())); err != nil { - return nil, errors.Wrapf(err, - "failed to update last local height for a result with id %d: %v", query.Id, err) - } - } - - return &types.MsgSubmitQueryResultResponse{}, nil -} - -// validateUpdateInterchainQueryParams checks whether the parameters to be updated corresponds -// with the query type. -func (m msgServer) validateUpdateInterchainQueryParams( - query *types.RegisteredQuery, - msg *types.MsgUpdateInterchainQueryRequest, -) error { - queryType := types.InterchainQueryType(query.GetQueryType()) - newKvKeysSet := len(msg.GetNewKeys()) != 0 - newTxFilterSet := msg.GetNewTransactionsFilter() != "" - - if queryType.IsKV() && !newKvKeysSet && newTxFilterSet { - return fmt.Errorf("params to update don't correspond with query type: can't update TX filter for a KV query") - } - if queryType.IsTX() && !newTxFilterSet && newKvKeysSet { - return fmt.Errorf("params to update don't correspond with query type: can't update KV keys for a TX query") - } - return nil -} - -// UpdateParams updates the module parameters. -func (k Keeper) UpdateParams(goCtx context.Context, req *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) { - if err := req.Validate(); err != nil { - return nil, errors.Wrap(err, "failed to validate MsgUpdateParams") - } - - authority := k.GetAuthority() - if authority != req.Authority { - return nil, errors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid authority; expected %s, got %s", authority, req.Authority) - } - - ctx := sdk.UnwrapSDKContext(goCtx) - if err := k.SetParams(ctx, req.Params); err != nil { - return nil, err - } - - return &types.MsgUpdateParamsResponse{}, nil -} - -func getEventsQueryUpdated(query *types.RegisteredQuery) sdk.Events { - return sdk.Events{ - sdk.NewEvent( - types.EventTypeNolusMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - sdk.NewAttribute(sdk.AttributeKeyAction, types.AttributeValueQueryUpdated), - sdk.NewAttribute(types.AttributeKeyQueryID, strconv.FormatUint(query.Id, 10)), - sdk.NewAttribute(types.AttributeKeyConnectionID, query.ConnectionId), - sdk.NewAttribute(types.AttributeKeyOwner, query.Owner), - sdk.NewAttribute(types.AttributeKeyQueryType, query.QueryType), - sdk.NewAttribute(types.AttributeTransactionsFilterQuery, query.TransactionsFilter), - sdk.NewAttribute(types.AttributeKeyKVQuery, types.KVKeys(query.Keys).String()), - ), - } -} - -func getEventsQueryRemoved(query *types.RegisteredQuery) sdk.Events { - return sdk.Events{ - sdk.NewEvent( - types.EventTypeNolusMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - sdk.NewAttribute(sdk.AttributeKeyAction, types.AttributeValueQueryRemoved), - sdk.NewAttribute(types.AttributeKeyQueryID, strconv.FormatUint(query.Id, 10)), - sdk.NewAttribute(types.AttributeKeyConnectionID, query.ConnectionId), - sdk.NewAttribute(types.AttributeKeyOwner, query.Owner), - sdk.NewAttribute(types.AttributeKeyQueryType, query.QueryType), - sdk.NewAttribute(types.AttributeTransactionsFilterQuery, query.TransactionsFilter), - sdk.NewAttribute(types.AttributeKeyKVQuery, types.KVKeys(query.Keys).String()), - ), - } -} diff --git a/x/interchainqueries/keeper/msg_server_test.go b/x/interchainqueries/keeper/msg_server_test.go deleted file mode 100644 index 95a92f6a..00000000 --- a/x/interchainqueries/keeper/msg_server_test.go +++ /dev/null @@ -1,537 +0,0 @@ -package keeper_test - -import ( - "testing" - - "github.com/cometbft/cometbft/proto/tendermint/crypto" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - ibchost "github.com/cosmos/ibc-go/v8/modules/core/exported" - "github.com/stretchr/testify/require" - - "github.com/Nolus-Protocol/nolus-core/testutil" - testkeeper "github.com/Nolus-Protocol/nolus-core/testutil/interchainqueries/keeper" - "github.com/Nolus-Protocol/nolus-core/x/interchainqueries/keeper" - "github.com/Nolus-Protocol/nolus-core/x/interchainqueries/types" -) - -func TestMsgRegisterInterchainQueryValidate(t *testing.T) { - k, ctx := testkeeper.InterchainQueriesKeeper(t, nil, nil, nil, nil) - msgServer := keeper.NewMsgServerImpl(*k) - - tests := []struct { - name string - msg types.MsgRegisterInterchainQuery - expectedErr error - }{ - { - "invalid update period", - types.MsgRegisterInterchainQuery{ - QueryType: string(types.InterchainQueryTypeTX), - Keys: nil, - TransactionsFilter: "[]", - ConnectionId: "connection-0", - UpdatePeriod: 0, - Sender: testutil.TestOwnerAddress, - }, - types.ErrInvalidUpdatePeriod, - }, - { - "empty sender", - types.MsgRegisterInterchainQuery{ - QueryType: string(types.InterchainQueryTypeTX), - Keys: nil, - TransactionsFilter: "[]", - ConnectionId: "connection-0", - UpdatePeriod: 1, - Sender: "", - }, - sdkerrors.ErrInvalidAddress, - }, - { - "invalid sender", - types.MsgRegisterInterchainQuery{ - QueryType: string(types.InterchainQueryTypeTX), - Keys: nil, - TransactionsFilter: "[]", - ConnectionId: "connection-0", - UpdatePeriod: 1, - Sender: "cosmos14234_invalid_address", - }, - sdkerrors.ErrInvalidAddress, - }, - { - "empty connection id", - types.MsgRegisterInterchainQuery{ - QueryType: string(types.InterchainQueryTypeTX), - Keys: nil, - TransactionsFilter: "[]", - ConnectionId: "", - UpdatePeriod: 1, - Sender: testutil.TestOwnerAddress, - }, - types.ErrInvalidConnectionID, - }, - { - "invalid query type", - types.MsgRegisterInterchainQuery{ - QueryType: "invalid_type", - Keys: nil, - TransactionsFilter: "[]", - ConnectionId: "connection-0", - UpdatePeriod: 1, - Sender: testutil.TestOwnerAddress, - }, - types.ErrInvalidQueryType, - }, - { - "empty keys", - types.MsgRegisterInterchainQuery{ - QueryType: string(types.InterchainQueryTypeKV), - Keys: nil, - TransactionsFilter: "[]", - ConnectionId: "connection-0", - UpdatePeriod: 1, - Sender: testutil.TestOwnerAddress, - }, - types.ErrEmptyKeys, - }, - { - "too many keys", - types.MsgRegisterInterchainQuery{ - QueryType: string(types.InterchainQueryTypeKV), - Keys: make([]*types.KVKey, types.MaxKVQueryKeysCount+1), - TransactionsFilter: "[]", - ConnectionId: "connection-0", - UpdatePeriod: 1, - Sender: testutil.TestOwnerAddress, - }, - types.ErrTooManyKVQueryKeys, - }, - { - "nil key", - types.MsgRegisterInterchainQuery{ - QueryType: string(types.InterchainQueryTypeKV), - Keys: []*types.KVKey{{Key: []byte("key1"), Path: "path1"}, nil}, - TransactionsFilter: "[]", - ConnectionId: "connection-0", - UpdatePeriod: 1, - Sender: testutil.TestOwnerAddress, - }, - sdkerrors.ErrInvalidType, - }, - { - "duplicated keys", - types.MsgRegisterInterchainQuery{ - QueryType: string(types.InterchainQueryTypeKV), - Keys: []*types.KVKey{{Key: []byte("key1"), Path: "path1"}, {Key: []byte("key1"), Path: "path1"}}, - TransactionsFilter: "[]", - ConnectionId: "connection-0", - UpdatePeriod: 1, - Sender: testutil.TestOwnerAddress, - }, - sdkerrors.ErrInvalidRequest, - }, - { - "empty key path", - types.MsgRegisterInterchainQuery{ - QueryType: string(types.InterchainQueryTypeKV), - Keys: []*types.KVKey{{Key: []byte("key1"), Path: ""}}, - TransactionsFilter: "[]", - ConnectionId: "connection-0", - UpdatePeriod: 1, - Sender: testutil.TestOwnerAddress, - }, - types.ErrEmptyKeyPath, - }, - { - "empty key id", - types.MsgRegisterInterchainQuery{ - QueryType: string(types.InterchainQueryTypeKV), - Keys: []*types.KVKey{{Key: []byte(""), Path: "path"}}, - TransactionsFilter: "[]", - ConnectionId: "connection-0", - UpdatePeriod: 1, - Sender: testutil.TestOwnerAddress, - }, - types.ErrEmptyKeyID, - }, - { - "invalid transactions filter format", - types.MsgRegisterInterchainQuery{ - QueryType: string(types.InterchainQueryTypeTX), - Keys: nil, - TransactionsFilter: "&)(^Y(*&(*&(&(*", - ConnectionId: "connection-0", - UpdatePeriod: 1, - Sender: testutil.TestOwnerAddress, - }, - types.ErrInvalidTransactionsFilter, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - resp, err := msgServer.RegisterInterchainQuery(ctx, &tt.msg) - require.ErrorIs(t, err, tt.expectedErr) - require.Nil(t, resp) - }) - } -} - -func TestMsgSubmitQueryResultValidate(t *testing.T) { - k, ctx := testkeeper.InterchainQueriesKeeper(t, nil, nil, nil, nil) - msgServer := keeper.NewMsgServerImpl(*k) - - tests := []struct { - name string - msg types.MsgSubmitQueryResult - expectedErr error - }{ - { - "empty result", - types.MsgSubmitQueryResult{ - QueryId: 1, - Sender: testutil.TestOwnerAddress, - ClientId: "client-id", - Result: nil, - }, - types.ErrEmptyResult, - }, - { - "empty kv results and block result", - types.MsgSubmitQueryResult{ - QueryId: 1, - Sender: testutil.TestOwnerAddress, - ClientId: "client-id", - Result: &types.QueryResult{ - KvResults: nil, - Block: nil, - Height: 100, - Revision: 1, - }, - }, - types.ErrEmptyResult, - }, - { - "zero query id", - types.MsgSubmitQueryResult{ - QueryId: 0, - Sender: testutil.TestOwnerAddress, - ClientId: "client-id", - Result: &types.QueryResult{ - KvResults: []*types.StorageValue{{ - Key: []byte{10}, - Proof: &crypto.ProofOps{Ops: []crypto.ProofOp{ - { - Type: "type", - Key: []byte{10}, - Data: []byte{10}, - }, - }}, - Value: []byte{10}, - StoragePrefix: ibchost.StoreKey, - }}, - Block: nil, - Height: 100, - Revision: 1, - }, - }, - types.ErrInvalidQueryID, - }, - { - "empty sender", - types.MsgSubmitQueryResult{ - QueryId: 1, - Sender: "", - ClientId: "client-id", - Result: &types.QueryResult{ - KvResults: []*types.StorageValue{{ - Key: []byte{10}, - Proof: &crypto.ProofOps{Ops: []crypto.ProofOp{ - { - Type: "type", - Key: []byte{10}, - Data: []byte{10}, - }, - }}, - Value: []byte{10}, - StoragePrefix: ibchost.StoreKey, - }}, - Block: nil, - Height: 100, - Revision: 1, - }, - }, - sdkerrors.ErrInvalidAddress, - }, - { - "invalid sender", - types.MsgSubmitQueryResult{ - QueryId: 1, - Sender: "invalid_sender", - ClientId: "client-id", - Result: &types.QueryResult{ - KvResults: []*types.StorageValue{{ - Key: []byte{10}, - Proof: &crypto.ProofOps{Ops: []crypto.ProofOp{ - { - Type: "type", - Key: []byte{10}, - Data: []byte{10}, - }, - }}, - Value: []byte{10}, - StoragePrefix: ibchost.StoreKey, - }}, - Block: nil, - Height: 100, - Revision: 1, - }, - }, - sdkerrors.ErrInvalidAddress, - }, - { - "empty client id", - types.MsgSubmitQueryResult{ - QueryId: 1, - Sender: testutil.TestOwnerAddress, - ClientId: "", - Result: &types.QueryResult{ - KvResults: nil, - Block: &types.Block{ - NextBlockHeader: nil, - Header: nil, - Tx: nil, - }, - Height: 100, - Revision: 1, - }, - }, - types.ErrInvalidClientID, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - resp, err := msgServer.SubmitQueryResult(ctx, &tt.msg) - require.ErrorIs(t, err, tt.expectedErr) - require.Nil(t, resp) - }) - } -} - -func TestMsgRemoveInterchainQueryRequestValidate(t *testing.T) { - k, ctx := testkeeper.InterchainQueriesKeeper(t, nil, nil, nil, nil) - msgServer := keeper.NewMsgServerImpl(*k) - - tests := []struct { - name string - msg types.MsgRemoveInterchainQueryRequest - expectedErr error - }{ - { - "invalid query id", - types.MsgRemoveInterchainQueryRequest{ - QueryId: 0, - Sender: testutil.TestOwnerAddress, - }, - types.ErrInvalidQueryID, - }, - { - "empty sender", - types.MsgRemoveInterchainQueryRequest{ - QueryId: 1, - Sender: "", - }, - sdkerrors.ErrInvalidAddress, - }, - { - "invalid sender", - types.MsgRemoveInterchainQueryRequest{ - QueryId: 1, - Sender: "invalid-sender", - }, - sdkerrors.ErrInvalidAddress, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - resp, err := msgServer.RemoveInterchainQuery(ctx, &tt.msg) - require.ErrorIs(t, err, tt.expectedErr) - require.Nil(t, resp) - }) - } -} - -func TestMsgUpdateInterchainQueryRequestValidate(t *testing.T) { - k, ctx := testkeeper.InterchainQueriesKeeper(t, nil, nil, nil, nil) - msgServer := keeper.NewMsgServerImpl(*k) - - tests := []struct { - name string - msg types.MsgUpdateInterchainQueryRequest - expectedErr error - }{ - { - "invalid query id", - types.MsgUpdateInterchainQueryRequest{ - QueryId: 0, - NewKeys: []*types.KVKey{{ - Path: "staking", - Key: []byte{1, 2, 3}, - }}, - NewUpdatePeriod: 10, - Sender: testutil.TestOwnerAddress, - }, - types.ErrInvalidQueryID, - }, - { - "empty keys, update_period and tx filter", - types.MsgUpdateInterchainQueryRequest{ - QueryId: 1, - NewKeys: nil, - NewUpdatePeriod: 0, - NewTransactionsFilter: "", - Sender: testutil.TestOwnerAddress, - }, - sdkerrors.ErrInvalidRequest, - }, - { - "both keys and filter sent", - types.MsgUpdateInterchainQueryRequest{ - QueryId: 1, - NewKeys: []*types.KVKey{{ - Path: "staking", - Key: []byte{1, 2, 3}, - }}, - NewUpdatePeriod: 0, - NewTransactionsFilter: `{"field":"transfer.recipient","op":"eq","value":"cosmos1xxx"}`, - Sender: testutil.TestOwnerAddress, - }, - sdkerrors.ErrInvalidRequest, - }, - { - "too many keys", - types.MsgUpdateInterchainQueryRequest{ - QueryId: 1, - NewKeys: make([]*types.KVKey, types.MaxKVQueryKeysCount+1), - NewUpdatePeriod: 0, - Sender: testutil.TestOwnerAddress, - }, - types.ErrTooManyKVQueryKeys, - }, - { - "nil key", - types.MsgUpdateInterchainQueryRequest{ - QueryId: 1, - NewKeys: []*types.KVKey{{Key: []byte("key1"), Path: "path1"}, nil}, - NewUpdatePeriod: 0, - Sender: testutil.TestOwnerAddress, - }, - sdkerrors.ErrInvalidType, - }, - { - "duplicated keys", - types.MsgUpdateInterchainQueryRequest{ - QueryId: 1, - NewKeys: []*types.KVKey{{Key: []byte("key1"), Path: "path1"}, {Key: []byte("key1"), Path: "path1"}}, - NewUpdatePeriod: 0, - Sender: testutil.TestOwnerAddress, - }, - sdkerrors.ErrInvalidRequest, - }, - { - "empty key path", - types.MsgUpdateInterchainQueryRequest{ - QueryId: 1, - NewKeys: []*types.KVKey{{Key: []byte("key1"), Path: ""}}, - NewUpdatePeriod: 0, - Sender: testutil.TestOwnerAddress, - }, - types.ErrEmptyKeyPath, - }, - { - "empty key id", - types.MsgUpdateInterchainQueryRequest{ - QueryId: 1, - NewKeys: []*types.KVKey{{Key: []byte(""), Path: "path"}}, - NewUpdatePeriod: 0, - Sender: testutil.TestOwnerAddress, - }, - types.ErrEmptyKeyID, - }, - { - "empty sender", - types.MsgUpdateInterchainQueryRequest{ - QueryId: 1, - NewKeys: []*types.KVKey{{ - Path: "staking", - Key: []byte{1, 2, 3}, - }}, - NewUpdatePeriod: 10, - Sender: "", - }, - sdkerrors.ErrInvalidAddress, - }, - { - "invalid sender", - types.MsgUpdateInterchainQueryRequest{ - QueryId: 1, - NewKeys: []*types.KVKey{{ - Path: "staking", - Key: []byte{1, 2, 3}, - }}, - NewUpdatePeriod: 10, - Sender: "invalid-sender", - }, - sdkerrors.ErrInvalidAddress, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - resp, err := msgServer.UpdateInterchainQuery(ctx, &tt.msg) - require.ErrorIs(t, err, tt.expectedErr) - require.Nil(t, resp) - }) - } -} - -func TestMsgUpdateParamsValidate(t *testing.T) { - k, ctx := testkeeper.InterchainQueriesKeeper(t, nil, nil, nil, nil) - - tests := []struct { - name string - msg types.MsgUpdateParams - expectedErr string - }{ - { - "empty authority", - types.MsgUpdateParams{ - Authority: "", - }, - "authority is invalid", - }, - { - "invalid authority", - types.MsgUpdateParams{ - Authority: "invalid authority", - }, - "authority is invalid", - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - resp, err := k.UpdateParams(ctx, &tt.msg) - require.ErrorContains(t, err, tt.expectedErr) - require.Nil(t, resp) - }) - } -} diff --git a/x/interchainqueries/keeper/params.go b/x/interchainqueries/keeper/params.go deleted file mode 100644 index dee8efeb..00000000 --- a/x/interchainqueries/keeper/params.go +++ /dev/null @@ -1,31 +0,0 @@ -package keeper - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/Nolus-Protocol/nolus-core/x/interchainqueries/types" -) - -// GetParams get all parameters as types.Params. -func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) { - store := ctx.KVStore(k.storeKey) - bz := store.Get(types.ParamsKey) - if bz == nil { - return params - } - - k.cdc.MustUnmarshal(bz, ¶ms) - return params -} - -// SetParams set the params. -func (k Keeper) SetParams(ctx sdk.Context, params types.Params) error { - store := ctx.KVStore(k.storeKey) - bz, err := k.cdc.Marshal(¶ms) - if err != nil { - return err - } - - store.Set(types.ParamsKey, bz) - return nil -} diff --git a/x/interchainqueries/keeper/params_test.go b/x/interchainqueries/keeper/params_test.go deleted file mode 100644 index 2849b318..00000000 --- a/x/interchainqueries/keeper/params_test.go +++ /dev/null @@ -1,20 +0,0 @@ -package keeper_test - -import ( - "testing" - - "github.com/stretchr/testify/require" - - testkeeper "github.com/Nolus-Protocol/nolus-core/testutil/interchainqueries/keeper" - "github.com/Nolus-Protocol/nolus-core/x/interchainqueries/types" -) - -func TestGetParams(t *testing.T) { - k, ctx := testkeeper.InterchainQueriesKeeper(t, nil, nil, nil, nil) - params := types.DefaultParams() - - err := k.SetParams(ctx, params) - require.NoError(t, err) - - require.EqualValues(t, params, k.GetParams(ctx)) -} diff --git a/x/interchainqueries/keeper/process_block_results.go b/x/interchainqueries/keeper/process_block_results.go deleted file mode 100644 index c880fcc9..00000000 --- a/x/interchainqueries/keeper/process_block_results.go +++ /dev/null @@ -1,211 +0,0 @@ -package keeper - -import ( - "bytes" - "encoding/hex" - - "cosmossdk.io/errors" - - codectypes "github.com/cosmos/cosmos-sdk/codec/types" - clientkeeper "github.com/cosmos/ibc-go/v8/modules/core/02-client/keeper" - - abci "github.com/cometbft/cometbft/abci/types" - "github.com/cometbft/cometbft/crypto/merkle" - tmtypes "github.com/cometbft/cometbft/types" - sdk "github.com/cosmos/cosmos-sdk/types" - ibcclienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" //nolint:staticcheck - "github.com/cosmos/ibc-go/v8/modules/core/exported" - tendermintLightClientTypes "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" - - "github.com/Nolus-Protocol/nolus-core/x/interchainqueries/types" -) - -// deterministicExecTxResult strips non-deterministic fields from -// ExecTxResult and returns another ExecTxResult. -func deterministicExecTxResult(response *abci.ExecTxResult) *abci.ExecTxResult { - return &abci.ExecTxResult{ - Code: response.Code, - Data: response.Data, - GasWanted: response.GasWanted, - GasUsed: response.GasUsed, - } -} - -// checkHeadersOrder do some basic checks to verify that nextHeader is really next for the header. -func checkHeadersOrder(header, nextHeader *tendermintLightClientTypes.Header) error { - if nextHeader.Header.Height != header.Header.Height+1 { - return errors.Wrapf(types.ErrInvalidHeader, "nextHeader.Height (%d) is not actually next for a header with height %d", nextHeader.Header.Height, header.Header.Height) - } - - tmHeader, err := tmtypes.HeaderFromProto(header.Header) - if err != nil { - return errors.Wrapf(types.ErrInvalidHeader, "failed to get tendermint header from proto header: %v", err) - } - tmNextHeader, err := tmtypes.HeaderFromProto(nextHeader.Header) - if err != nil { - return errors.Wrapf(types.ErrInvalidHeader, "failed to get tendermint header from proto header: %v", err) - } - - if !bytes.Equal(tmHeader.NextValidatorsHash, tmNextHeader.ValidatorsHash) { - return errors.Wrapf(types.ErrInvalidHeader, "header.NextValidatorsHash is not equal to nextHeader.ValidatorsHash: %s != %s", tmHeader.NextValidatorsHash.String(), tmNextHeader.ValidatorsHash.String()) - } - - if !bytes.Equal(tmHeader.Hash(), tmNextHeader.LastBlockID.Hash) { - return errors.Wrapf(types.ErrInvalidHeader, "header.Hash() is not equal to nextHeader.LastBlockID.Hash: %s != %s", tmHeader.Hash().String(), tmNextHeader.LastBlockID.Hash.String()) - } - - return nil -} - -type Verifier struct{} - -// VerifyHeaders verify that headers are valid tendermint headers, checks them on validity by trying call ibcClient.UpdateClient(header) -// to update light client's consensus state and checks that they are sequential (tl;dr header.Height + 1 == nextHeader.Height). -func (v Verifier) VerifyHeaders(ctx sdk.Context, clientKeeper clientkeeper.Keeper, clientID string, header, nextHeader exported.ClientMessage) error { - // this IBC handler updates the consensus state and the state root from a provided header. - // But more importantly in the current situation, it checks that header is valid. - // Honestly we need only to verify headers, but since the check functions are private, and we don't want to duplicate the code, - // we update consensus state at the same time (because why not?) - if err := clientKeeper.UpdateClient(ctx, clientID, header); err != nil { - return errors.Wrapf(err, "failed to update client: %v", err) - } - if err := clientKeeper.UpdateClient(ctx, clientID, nextHeader); err != nil { - return errors.Wrapf(err, "failed to update client: %v", err) - } - - tmHeader, ok := header.(*tendermintLightClientTypes.Header) - if !ok { - return errors.Wrapf(types.ErrInvalidType, "failed to cast header to tendermint Header") - } - - tmNextHeader, ok := nextHeader.(*tendermintLightClientTypes.Header) - if !ok { - return errors.Wrapf(types.ErrInvalidType, "failed to cast header to tendermint Header") - } - - // do some basic check to verify that tmNextHeader is next for the tmHeader - if err := checkHeadersOrder(tmHeader, tmNextHeader); err != nil { - return errors.Wrapf(types.ErrInvalidHeader, "block.NextBlockHeader is not next for the block.Header: %v", err) - } - - return nil -} - -func (v Verifier) UnpackHeader(any *codectypes.Any) (exported.ClientMessage, error) { - return ibcclienttypes.UnpackClientMessage(any) -} - -// ProcessBlock verifies headers and transaction in the block, and then passes the tx query result to -// the querying contract's sudo handler. -func (k Keeper) ProcessBlock(ctx sdk.Context, queryOwner sdk.AccAddress, queryID uint64, clientID string, block *types.Block) error { - header, err := k.headerVerifier.UnpackHeader(block.Header) - if err != nil { - ctx.Logger().Debug("ProcessBlock: failed to unpack block header", "error", err) - return errors.Wrapf(types.ErrProtoUnmarshal, "failed to unpack block header: %v", err) - } - - nextHeader, err := k.headerVerifier.UnpackHeader(block.NextBlockHeader) - if err != nil { - ctx.Logger().Debug("ProcessBlock: failed to unpack block header", "error", err) - return errors.Wrapf(types.ErrProtoUnmarshal, "failed to unpack next block header: %v", err) - } - - if err := k.headerVerifier.VerifyHeaders(ctx, k.ibcKeeper.ClientKeeper, clientID, header, nextHeader); err != nil { - ctx.Logger().Debug("ProcessBlock: failed to verify headers", "error", err) - return errors.Wrapf(types.ErrInvalidHeader, "failed to verify headers: %v", err) - } - - tmHeader, ok := header.(*tendermintLightClientTypes.Header) - if !ok { - ctx.Logger().Debug("ProcessBlock: failed to cast current header to tendermint Header", "query_id", queryID) - return errors.Wrap(types.ErrInvalidType, "failed to cast current header to tendermint Header") - } - - tmNextHeader, ok := nextHeader.(*tendermintLightClientTypes.Header) - if !ok { - ctx.Logger().Debug("ProcessBlock: failed to cast next header to tendermint Header", "query_id", queryID) - return errors.Wrap(types.ErrInvalidType, "failed to cast next header to tendermint header") - } - - var ( - tx = block.GetTx() - txData = tx.GetData() - txHash = tmtypes.Tx(txData).Hash() - ) - if !k.CheckTransactionIsAlreadyProcessed(ctx, queryID, txHash) { - // Check that cryptography is O.K. (tx is included in the block, tx was executed successfully) - if err = k.transactionVerifier.VerifyTransaction(tmHeader, tmNextHeader, tx); err != nil { - ctx.Logger().Debug("ProcessBlock: failed to verifyTransaction", - "error", err, "query_id", queryID, "tx_hash", hex.EncodeToString(txHash)) - return errors.Wrapf(types.ErrInternal, "failed to verifyTransaction %s: %v", hex.EncodeToString(txHash), err) - } - - // Let the query owner contract process the query result. - if _, err := k.contractManagerKeeper.SudoTxQueryResult(ctx, queryOwner, queryID, ibcclienttypes.NewHeight(tmHeader.TrustedHeight.GetRevisionNumber(), uint64(tmHeader.Header.Height)), txData); err != nil { - ctx.Logger().Debug("ProcessBlock: failed to SudoTxQueryResult", - "error", err, "query_id", queryID, "tx_hash", hex.EncodeToString(txHash)) - return errors.Wrapf(err, "contract %s rejected transaction query result (tx_hash: %s)", - queryOwner, hex.EncodeToString(txHash)) - } - - k.SaveTransactionAsProcessed(ctx, queryID, txHash) - } else { - ctx.Logger().Debug("ProcessBlock: transaction was already submitted", - "query_id", queryID, "tx_hash", hex.EncodeToString(txHash)) - } - - return nil -} - -type TransactionVerifier struct{} - -// VerifyTransaction verifies that some transaction is included in block, and the transaction was executed successfully. -// The function checks: -// * transaction is included in block - header.DataHash merkle root contains transactions hash; -// * transactions was executed successfully - transaction's responseDeliveryTx.Code == 0; -// * transaction's responseDeliveryTx is legitimate - nextHeaderLastResultsDataHash merkle root contains -// deterministicExecTxResult(ResponseDeliveryTx).Bytes(). -func (v TransactionVerifier) VerifyTransaction( - header *tendermintLightClientTypes.Header, - nextHeader *tendermintLightClientTypes.Header, - tx *types.TxValue, -) error { - // verify inclusion proof - inclusionProof, err := merkle.ProofFromProto(tx.InclusionProof) - if err != nil { - return errors.Wrapf(types.ErrInvalidType, "failed to convert proto proof to merkle proof: %v", err) - } - - if err = inclusionProof.Verify(header.Header.DataHash, tmtypes.Tx(tx.Data).Hash()); err != nil { - return errors.Wrapf(types.ErrInvalidProof, "failed to verify inclusion proof: %v", err) - } - - // verify delivery proof - deliveryProof, err := merkle.ProofFromProto(tx.DeliveryProof) - if err != nil { - return errors.Wrapf(types.ErrInvalidType, "failed to convert proto proof to merkle proof: %v", err) - } - - responseTx := deterministicExecTxResult(tx.Response) - - responseTxBz, err := responseTx.Marshal() - if err != nil { - return errors.Wrapf(types.ErrProtoMarshal, "failed to marshal ResponseDeliveryTx: %v", err) - } - - if err = deliveryProof.Verify(nextHeader.Header.LastResultsHash, responseTxBz); err != nil { - return errors.Wrapf(types.ErrInvalidProof, "failed to verify delivery proof: %v", err) - } - - // check that transaction was successful - if tx.Response.Code != abci.CodeTypeOK { - return errors.Wrapf(types.ErrInternal, "tx %s is unsuccessful: ResponseDelivery.Code = %d", hex.EncodeToString(tmtypes.Tx(tx.Data).Hash()), tx.Response.Code) - } - - // check that inclusion proof and delivery proof are for the same transaction - if deliveryProof.Index != inclusionProof.Index { - return errors.Wrapf(types.ErrInvalidProof, "inclusion proof index and delivery proof index are not equal: %d != %d", inclusionProof.Index, deliveryProof.Index) - } - - return nil -} diff --git a/x/interchainqueries/keeper/process_block_results_test.go b/x/interchainqueries/keeper/process_block_results_test.go deleted file mode 100644 index d414d988..00000000 --- a/x/interchainqueries/keeper/process_block_results_test.go +++ /dev/null @@ -1,398 +0,0 @@ -package keeper_test - -import ( - "fmt" - "testing" - "time" - - abci "github.com/cometbft/cometbft/abci/types" - - ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper" - "github.com/golang/mock/gomock" - - icqtestkeeper "github.com/Nolus-Protocol/nolus-core/testutil/interchainqueries/keeper" - mock_types "github.com/Nolus-Protocol/nolus-core/testutil/mocks/interchainqueries/types" - - "github.com/CosmWasm/wasmd/x/wasm/keeper" - "github.com/cometbft/cometbft/crypto/tmhash" - tmproto "github.com/cometbft/cometbft/proto/tendermint/types" - tmprotoversion "github.com/cometbft/cometbft/proto/tendermint/version" - tmtypes "github.com/cometbft/cometbft/types" - tmversion "github.com/cometbft/cometbft/version" - "github.com/cosmos/cosmos-sdk/types" - ibcclienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" //nolint:staticcheck - "github.com/cosmos/ibc-go/v8/modules/core/exported" - ibctmtypes "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" - ibctesting "github.com/cosmos/ibc-go/v8/testing" - "github.com/stretchr/testify/require" - - codectypes "github.com/cosmos/cosmos-sdk/codec/types" - clientkeeper "github.com/cosmos/ibc-go/v8/modules/core/02-client/keeper" - - "github.com/Nolus-Protocol/nolus-core/testutil" - iqkeeper "github.com/Nolus-Protocol/nolus-core/x/interchainqueries/keeper" - iqtypes "github.com/Nolus-Protocol/nolus-core/x/interchainqueries/types" -) - -// CreateTMClientHeader creates a TM header to update the TM client. Args are passed in to allow -// caller flexibility to use params that differ from the chain. -func CreateTMClientHeader(chain *ibctesting.TestChain, chainID string, blockHeight int64, trustedHeight ibcclienttypes.Height, timestamp time.Time, tmValSet, tmTrustedVals *tmtypes.ValidatorSet, signers []tmtypes.PrivValidator, previousHeader *tmtypes.Header) *ibctmtypes.Header { - var ( - valSet *tmproto.ValidatorSet - trustedVals *tmproto.ValidatorSet - ) - require.NotNil(chain.TB, tmValSet) - - vsetHash := tmValSet.Hash() - - tmHeader := tmtypes.Header{ - Version: tmprotoversion.Consensus{Block: tmversion.BlockProtocol, App: 2}, - ChainID: chainID, - Height: blockHeight, - Time: timestamp, - LastBlockID: ibctesting.MakeBlockID(previousHeader.Hash(), 10_000, make([]byte, tmhash.Size)), - LastCommitHash: chain.App.LastCommitID().Hash, - DataHash: tmhash.Sum([]byte("data_hash")), - ValidatorsHash: vsetHash, - NextValidatorsHash: vsetHash, - ConsensusHash: tmhash.Sum([]byte("consensus_hash")), - AppHash: chain.CurrentHeader.AppHash, - LastResultsHash: tmhash.Sum([]byte("last_results_hash")), - EvidenceHash: tmhash.Sum([]byte("evidence_hash")), - ProposerAddress: tmValSet.Proposer.Address, //nolint:staticcheck - } - - hhash := tmHeader.Hash() - blockID := ibctesting.MakeBlockID(hhash, 3, tmhash.Sum([]byte("part_set"))) - voteSet := tmtypes.NewVoteSet(chainID, blockHeight, 1, tmproto.PrecommitType, tmValSet) - - commit, err := tmtypes.MakeExtCommit(blockID, blockHeight, 1, voteSet, signers, timestamp, false) - require.NoError(chain.TB, err) - - signedHeader := &tmproto.SignedHeader{ - Header: tmHeader.ToProto(), - Commit: commit.ToCommit().ToProto(), - } - - if tmValSet != nil { //nolint:staticcheck // this checks if a pointer is nil, suggesting that it can be nil but we have this test all over the place - valSet, err = tmValSet.ToProto() - require.NoError(chain.TB, err) - } - - if tmTrustedVals != nil { - trustedVals, err = tmTrustedVals.ToProto() - require.NoError(chain.TB, err) - } - - // The trusted fields may be nil. They may be filled before relaying messages to a client. - // The relayer is responsible for querying client and injecting appropriate trusted fields. - return &ibctmtypes.Header{ - SignedHeader: signedHeader, - ValidatorSet: valSet, - TrustedHeight: trustedHeight, - TrustedValidators: trustedVals, - } -} - -func NextBlock(chain *ibctesting.TestChain) { - _, err := chain.App.FinalizeBlock(&abci.RequestFinalizeBlock{ - Height: chain.CurrentHeader.Height, - Time: chain.CurrentHeader.GetTime(), - NextValidatorsHash: chain.NextVals.Hash(), - }) - require.NoError(chain.TB, err) - - _, err = chain.App.Commit() - require.NoError(chain.TB, err) - - // set the last header to the current header - // use nil trusted fields - ph, err := tmtypes.HeaderFromProto(chain.LastHeader.Header) - require.NoError(chain.TB, err) - - var signers []tmtypes.PrivValidator - for _, val := range chain.Vals.Validators { - signers = append(signers, chain.Signers[val.PubKey.Address().String()]) - } - chain.LastHeader = CreateTMClientHeader(chain, chain.ChainID, chain.CurrentHeader.Height, ibcclienttypes.Height{}, chain.CurrentHeader.Time, chain.Vals, nil, signers, &ph) - - // increment the current header - chain.CurrentHeader = tmproto.Header{ - ChainID: chain.ChainID, - Height: chain.App.LastBlockHeight() + 1, - AppHash: chain.App.LastCommitID().Hash, - // NOTE: the time is increased by the coordinator to maintain time synchrony amongst - // chains. - Time: chain.CurrentHeader.Time, - ValidatorsHash: chain.Vals.Hash(), - NextValidatorsHash: chain.Vals.Hash(), - } -} - -// CommitBlock commits a block on the provided indexes and then increments the global time. -// -// CONTRACT: the passed in list of indexes must not contain duplicates -func CommitBlock(coord *ibctesting.Coordinator, chains ...*ibctesting.TestChain) { - for _, chain := range chains { - NextBlock(chain) - } - coord.IncrementTime() -} - -// UpdateClient updates the IBC client associated with the endpoint. -func UpdateClient(endpoint *ibctesting.Endpoint) (err error) { - var header exported.ClientMessage - - // ensure counterparty has committed state - CommitBlock(endpoint.Chain.Coordinator, endpoint.Counterparty.Chain) - - switch endpoint.ClientConfig.GetClientType() { - case exported.Tendermint: - header, err = endpoint.Chain.ConstructUpdateTMClientHeader(endpoint.Counterparty.Chain, endpoint.ClientID) - - default: - err = fmt.Errorf("client type %s is not supported", endpoint.ClientConfig.GetClientType()) - } - - if err != nil { - return err - } - - msg, err := ibcclienttypes.NewMsgUpdateClient( - endpoint.ClientID, header, - endpoint.Chain.SenderAccount.GetAddress().String(), - ) - require.NoError(endpoint.Chain.TB, err) - - _, err = endpoint.Chain.SendMsgs(msg) - - return err -} - -func (suite *KeeperTestSuite) TestUnpackAndVerifyHeaders() { - tests := []struct { - name string - run func() error - expectedErrorMsg string - }{ - { - "valid headers", - func() error { - suite.Require().NoError(suite.Path.EndpointA.UpdateClient()) - - clientID := suite.Path.EndpointA.ClientID - CommitBlock(suite.Coordinator, suite.ChainB) - header, err := suite.Path.EndpointA.Chain.ConstructUpdateTMClientHeader(suite.Path.EndpointA.Counterparty.Chain, suite.Path.EndpointB.ClientID) - suite.Require().NoError(err) - - CommitBlock(suite.Coordinator, suite.ChainB) - nextHeader, err := suite.Path.EndpointA.Chain.ConstructUpdateTMClientHeader(suite.Path.EndpointA.Counterparty.Chain, suite.Path.EndpointB.ClientID) - suite.Require().NoError(err) - - return iqkeeper.Verifier{}.VerifyHeaders(suite.ChainA.GetContext(), suite.GetNolusZoneApp(suite.ChainA).IBCKeeper.ClientKeeper, clientID, header, nextHeader) - }, - "", - }, - { - "headers are not sequential", - func() error { - suite.Require().NoError(UpdateClient(suite.Path.EndpointA)) - - clientID := suite.Path.EndpointA.ClientID - CommitBlock(suite.Coordinator, suite.ChainB) - - header, err := suite.Path.EndpointA.Chain.ConstructUpdateTMClientHeader(suite.Path.EndpointA.Counterparty.Chain, suite.Path.EndpointB.ClientID) - suite.Require().NoError(err) - - // skip one block to set nextHeader's height + 2 - CommitBlock(suite.Coordinator, suite.ChainB) - CommitBlock(suite.Coordinator, suite.ChainB) - - nextHeader, err := suite.Path.EndpointA.Chain.ConstructUpdateTMClientHeader(suite.Path.EndpointA.Counterparty.Chain, suite.Path.EndpointB.ClientID) - suite.Require().NoError(err) - - return iqkeeper.Verifier{}.VerifyHeaders(suite.ChainA.GetContext(), suite.GetNolusZoneApp(suite.ChainA).IBCKeeper.ClientKeeper, clientID, header, nextHeader) - }, - "block.NextBlockHeader is not next for the block.Header", - }, - { - "header has some malicious field", - func() error { - suite.Require().NoError(UpdateClient(suite.Path.EndpointA)) - - clientID := suite.Path.EndpointA.ClientID - CommitBlock(suite.Coordinator, suite.ChainB) - CommitBlock(suite.Coordinator, suite.ChainB) - - header, err := suite.Path.EndpointA.Chain.ConstructUpdateTMClientHeader(suite.Path.EndpointA.Counterparty.Chain, suite.Path.EndpointB.ClientID) - suite.Require().NoError(err) - - CommitBlock(suite.Coordinator, suite.ChainB) - - header.SignedHeader.Header.LastResultsHash = []byte("malicious hash with length 32!!!") - - nextHeader, err := suite.Path.EndpointA.Chain.ConstructUpdateTMClientHeader(suite.Path.EndpointA.Counterparty.Chain, suite.Path.EndpointB.ClientID) - suite.Require().NoError(err) - - return iqkeeper.Verifier{}.VerifyHeaders(suite.ChainA.GetContext(), suite.GetNolusZoneApp(suite.ChainA).IBCKeeper.ClientKeeper, clientID, header, nextHeader) - }, - "invalid header: untrustedHeader.ValidateBasic failed: commit signs block", - }, - { - "headers from the past (when client on chain A has the most recent consensus state and relayer try to submit old headers from chain B)", - func() error { - suite.Require().NoError(UpdateClient(suite.Path.EndpointA)) - - clientID := suite.Path.EndpointA.ClientID - CommitBlock(suite.Coordinator, suite.ChainB) - - oldHeader := *suite.ChainB.LastHeader - CommitBlock(suite.Coordinator, suite.ChainB) - oldNextHeader := *suite.ChainB.LastHeader - - for i := 0; i < 30; i++ { - suite.Require().NoError(UpdateClient(suite.Path.EndpointA)) - } - headerWithTrustedHeight, err := suite.Path.EndpointA.Chain.ConstructUpdateTMClientHeaderWithTrustedHeight(suite.Path.EndpointA.Counterparty.Chain, suite.Path.EndpointB.ClientID, ibcclienttypes.Height{ - RevisionNumber: 0, - RevisionHeight: 28, - }) - suite.Require().NoError(err) - - oldHeader.TrustedHeight = headerWithTrustedHeight.TrustedHeight - oldHeader.TrustedValidators = headerWithTrustedHeight.TrustedValidators - - oldNextHeader.TrustedHeight = headerWithTrustedHeight.TrustedHeight - oldNextHeader.TrustedValidators = headerWithTrustedHeight.TrustedValidators - - return iqkeeper.Verifier{}.VerifyHeaders(suite.ChainA.GetContext(), suite.GetNolusZoneApp(suite.ChainA).IBCKeeper.ClientKeeper, clientID, &oldHeader, &oldNextHeader) - }, - "", - }, - } - - for i, tc := range tests { - tt := tc - suite.Run(fmt.Sprintf("Case %s, %d/%d tests", tt.name, i+1, len(tests)), func() { - suite.SetupTest() - - var ( - ctx = suite.ChainA.GetContext() - contractOwner = keeper.RandomAccountAddress(suite.T()) // We don't care what this address is - ) - - // Store code and instantiate reflect contract. - codeID := suite.StoreTestCode(ctx, contractOwner, reflectContractPath) - contractAddress := suite.InstantiateTestContract(ctx, contractOwner, codeID) - suite.Require().NotEmpty(contractAddress) - - err := testutil.SetupICAPath(suite.Path, contractAddress.String()) - suite.Require().NoError(err) - - err = tt.run() - if tt.expectedErrorMsg != "" { - suite.Require().ErrorContains(err, tt.expectedErrorMsg) - } else { - suite.Require().NoError(err) - } - }) - } -} - -func TestSudoHasAddress(t *testing.T) { - ctrl := gomock.NewController(t) - defer ctrl.Finish() - - hv := mock_types.NewMockHeaderVerifier(ctrl) - tv := mock_types.NewMockTransactionVerifier(ctrl) - cm := mock_types.NewMockContractManagerKeeper(ctrl) - ibck := ibckeeper.Keeper{ClientKeeper: clientkeeper.Keeper{}} - - k, ctx := icqtestkeeper.InterchainQueriesKeeper(t, &ibck, cm, hv, tv) - address := types.MustAccAddressFromBech32(testutil.TestOwnerAddress) - header := ibctmtypes.Header{ - SignedHeader: &tmproto.SignedHeader{ - Header: &tmproto.Header{Height: 1001}, - }, - TrustedHeight: ibcclienttypes.Height{ - RevisionNumber: 1, - RevisionHeight: 1001, - }, - } - nextHeader := ibctmtypes.Header{ - TrustedHeight: ibcclienttypes.Height{ - RevisionNumber: 1, - RevisionHeight: 1002, - }, - } - packedHeader, err := codectypes.NewAnyWithValue(&header) - require.NoError(t, err) - packedNextHeader, err := codectypes.NewAnyWithValue(&nextHeader) - require.NoError(t, err) - tx := iqtypes.TxValue{ - Response: nil, - DeliveryProof: nil, - InclusionProof: nil, - Data: []byte("txbody"), - } - block := iqtypes.Block{ - NextBlockHeader: packedNextHeader, - Header: packedHeader, - Tx: &tx, - } - - hv.EXPECT().UnpackHeader(packedHeader).Return(nil, fmt.Errorf("failed to unpack packedHeader")) - err = k.ProcessBlock(ctx, address, 1, "tendermint-07", &block) - require.ErrorContains(t, err, "failed to unpack block header") - - hv.EXPECT().UnpackHeader(packedHeader).Return(exported.ClientMessage(&header), nil) - hv.EXPECT().UnpackHeader(packedNextHeader).Return(nil, fmt.Errorf("failed to unpack packedHeader")) - err = k.ProcessBlock(ctx, address, 1, "tendermint-07", &block) - require.ErrorContains(t, err, "failed to unpack next block header") - - hv.EXPECT().UnpackHeader(packedHeader).Return(exported.ClientMessage(&header), nil) - hv.EXPECT().UnpackHeader(packedNextHeader).Return(exported.ClientMessage(&nextHeader), nil) - hv.EXPECT().VerifyHeaders(ctx, clientkeeper.Keeper{}, "tendermint-07", exported.ClientMessage(&header), exported.ClientMessage(&nextHeader)).Return(fmt.Errorf("failed to verify headers")) - err = k.ProcessBlock(ctx, address, 1, "tendermint-07", &block) - require.ErrorContains(t, err, "failed to verify headers") - - hv.EXPECT().UnpackHeader(packedHeader).Return(exported.ClientMessage(&header), nil) - hv.EXPECT().UnpackHeader(packedNextHeader).Return(exported.ClientMessage(&nextHeader), nil) - hv.EXPECT().VerifyHeaders(ctx, clientkeeper.Keeper{}, "tendermint-07", exported.ClientMessage(&header), exported.ClientMessage(&nextHeader)).Return(nil) - tv.EXPECT().VerifyTransaction(&header, &nextHeader, &tx).Return(fmt.Errorf("failed to verify transaction")) - err = k.ProcessBlock(ctx, address, 1, "tendermint-07", &block) - require.ErrorContains(t, err, "failed to verifyTransaction") - - hv.EXPECT().UnpackHeader(packedHeader).Return(exported.ClientMessage(&header), nil) - hv.EXPECT().UnpackHeader(packedNextHeader).Return(exported.ClientMessage(&nextHeader), nil) - hv.EXPECT().VerifyHeaders(ctx, clientkeeper.Keeper{}, "tendermint-07", exported.ClientMessage(&header), exported.ClientMessage(&nextHeader)).Return(nil) - tv.EXPECT().VerifyTransaction(&header, &nextHeader, &tx).Return(nil) - cm.EXPECT().SudoTxQueryResult(ctx, address, uint64(1), ibcclienttypes.NewHeight(1, uint64(header.Header.Height)), tx.GetData()).Return(nil, fmt.Errorf("contract error")) - err = k.ProcessBlock(ctx, address, 1, "tendermint-07", &block) - require.ErrorContains(t, err, "rejected transaction query result") - - // all error flows passed, time to success - hv.EXPECT().UnpackHeader(packedHeader).Return(exported.ClientMessage(&header), nil) - hv.EXPECT().UnpackHeader(packedNextHeader).Return(exported.ClientMessage(&nextHeader), nil) - hv.EXPECT().VerifyHeaders(ctx, clientkeeper.Keeper{}, "tendermint-07", exported.ClientMessage(&header), exported.ClientMessage(&nextHeader)).Return(nil) - tv.EXPECT().VerifyTransaction(&header, &nextHeader, &tx).Return(nil) - cm.EXPECT().SudoTxQueryResult(ctx, address, uint64(1), ibcclienttypes.NewHeight(1, uint64(header.Header.Height)), tx.GetData()).Return(nil, nil) - err = k.ProcessBlock(ctx, address, 1, "tendermint-07", &block) - require.NoError(t, err) - - // no functions calls after VerifyHeaders means we try to process tx second time - hv.EXPECT().UnpackHeader(packedHeader).Return(exported.ClientMessage(&header), nil) - hv.EXPECT().UnpackHeader(packedNextHeader).Return(exported.ClientMessage(&nextHeader), nil) - hv.EXPECT().VerifyHeaders(ctx, clientkeeper.Keeper{}, "tendermint-07", exported.ClientMessage(&header), exported.ClientMessage(&nextHeader)).Return(nil) - err = k.ProcessBlock(ctx, address, 1, "tendermint-07", &block) - require.NoError(t, err) - - // same tx + another queryID - hv.EXPECT().UnpackHeader(packedHeader).Return(exported.ClientMessage(&header), nil) - hv.EXPECT().UnpackHeader(packedNextHeader).Return(exported.ClientMessage(&nextHeader), nil) - hv.EXPECT().VerifyHeaders(ctx, clientkeeper.Keeper{}, "tendermint-07", exported.ClientMessage(&header), exported.ClientMessage(&nextHeader)).Return(nil) - tv.EXPECT().VerifyTransaction(&header, &nextHeader, &tx).Return(nil) - cm.EXPECT().SudoTxQueryResult(ctx, address, uint64(2), ibcclienttypes.NewHeight(1, uint64(header.Header.Height)), tx.GetData()).Return(nil, nil) - err = k.ProcessBlock(ctx, address, 2, "tendermint-07", &block) - require.NoError(t, err) -} diff --git a/x/interchainqueries/module.go b/x/interchainqueries/module.go deleted file mode 100644 index 322f3e41..00000000 --- a/x/interchainqueries/module.go +++ /dev/null @@ -1,181 +0,0 @@ -package interchainqueries - -import ( - "context" - "encoding/json" - "fmt" - - "cosmossdk.io/core/appmodule" - - abci "github.com/cometbft/cometbft/abci/types" - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" - cdctypes "github.com/cosmos/cosmos-sdk/codec/types" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/module" - "github.com/gorilla/mux" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/spf13/cobra" - - "github.com/Nolus-Protocol/nolus-core/x/interchainqueries/client/cli" - "github.com/Nolus-Protocol/nolus-core/x/interchainqueries/keeper" - "github.com/Nolus-Protocol/nolus-core/x/interchainqueries/types" -) - -var ( - _ appmodule.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, _ 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(_ client.Context, _ *mux.Router) { -} - -// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module. -func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { - if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil { - return - } -} - -// 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 -// ---------------------------------------------------------------------------- - -var _ appmodule.AppModule = AppModule{} - -// AppModule implements the AppModule interface for the capability module. -type AppModule struct { - AppModuleBasic - - keeper keeper.Keeper - accountKeeper types.AccountKeeper - bankKeeper types.BankKeeper -} - -func NewAppModule( - cdc codec.Codec, - keeper keeper.Keeper, - accountKeeper types.AccountKeeper, - bankKeeper types.BankKeeper, -) AppModule { - return AppModule{ - AppModuleBasic: NewAppModuleBasic(cdc), - keeper: keeper, - accountKeeper: accountKeeper, - bankKeeper: bankKeeper, - } -} - -// IsOnePerModuleType implements the depinject.OnePerModuleType interface. -func (am AppModule) IsOnePerModuleType() { // marker -} - -// IsAppModule implements the appmodule.AppModule interface. -func (am AppModule) IsAppModule() { // marker -} - -// Name returns the capability module's name. -func (am AppModule) Name() string { - return am.AppModuleBasic.Name() -} - -// QuerierRoute returns the capability module's query routing key. -func (AppModule) QuerierRoute() string { return types.QuerierRoute } - -// RegisterServices registers a GRPC query service to respond to the -// module-specific GRPC queries. -func (am AppModule) RegisterServices(cfg module.Configurator) { - types.RegisterQueryServer(cfg.QueryServer(), am.keeper) - types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) -} - -// RegisterInvariants registers the capability module's invariants. -func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} - -// InitGenesis performs the capability module's genesis initialization It returns -// no validator updates. -func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, gs json.RawMessage) []abci.ValidatorUpdate { - var genState types.GenesisState - // Initialize global index to index in genesis state - cdc.MustUnmarshalJSON(gs, &genState) - - InitGenesis(ctx, am.keeper, genState) - - return []abci.ValidatorUpdate{} -} - -// ExportGenesis returns the capability module's exported genesis state as raw JSON bytes. -func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { - genState := ExportGenesis(ctx, am.keeper) - return cdc.MustMarshalJSON(genState) -} - -// ConsensusVersion implements ConsensusVersion. -func (AppModule) ConsensusVersion() uint64 { return types.ConsensusVersion } - -// BeginBlock executes all ABCI BeginBlock logic respective to the capability module. -func (am AppModule) BeginBlock(_ sdk.Context) {} - -// EndBlock executes all ABCI EndBlock logic respective to the capability module. It -// returns no validator updates. -func (am AppModule) EndBlock(wctx context.Context) ([]abci.ValidatorUpdate, error) { - ctx := sdk.UnwrapSDKContext(wctx) - am.keeper.TxQueriesCleanup(ctx) - return []abci.ValidatorUpdate{}, nil -} diff --git a/x/interchainqueries/module_simulation.go b/x/interchainqueries/module_simulation.go deleted file mode 100644 index f8c66a2a..00000000 --- a/x/interchainqueries/module_simulation.go +++ /dev/null @@ -1,49 +0,0 @@ -package interchainqueries - -import ( - "github.com/cosmos/cosmos-sdk/baseapp" - "github.com/cosmos/cosmos-sdk/testutil/sims" - "github.com/cosmos/cosmos-sdk/types/module" - simtypes "github.com/cosmos/cosmos-sdk/types/simulation" - "github.com/cosmos/cosmos-sdk/x/simulation" - - "github.com/Nolus-Protocol/nolus-core/testutil/common/sample" - interchainqueriessimulation "github.com/Nolus-Protocol/nolus-core/x/interchainqueries/simulation" - "github.com/Nolus-Protocol/nolus-core/x/interchainqueries/types" -) - -// avoid unused import issue. -var ( - _ = sample.AccAddress - _ = interchainqueriessimulation.FindAccount - _ = sims.StakePerAccount - _ = simulation.MsgEntryKind - _ = baseapp.Paramspace -) - -// GenerateGenesisState creates a randomized GenState of the module. -func (AppModule) GenerateGenesisState(simState *module.SimulationState) { - accs := make([]string, len(simState.Accounts)) - for i, acc := range simState.Accounts { - accs[i] = acc.Address.String() - } - interchainqueriesGenesis := types.GenesisState{ - Params: types.DefaultParams(), - } - simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(&interchainqueriesGenesis) -} - -// ProposalContents doesn't return any content functions for governance proposals. -func (AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedProposalMsg { - return nil -} - -// RegisterStoreDecoder registers a decoder. -func (am AppModule) RegisterStoreDecoder(_ simtypes.StoreDecoderRegistry) {} - -// WeightedOperations returns the all the gov module operations with their respective weights. -func (am AppModule) WeightedOperations(_ module.SimulationState) []simtypes.WeightedOperation { - operations := make([]simtypes.WeightedOperation, 0) - - return operations -} diff --git a/x/interchainqueries/simulation/simap.go b/x/interchainqueries/simulation/simap.go deleted file mode 100644 index b222cc5f..00000000 --- a/x/interchainqueries/simulation/simap.go +++ /dev/null @@ -1,15 +0,0 @@ -package simulation - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - simtypes "github.com/cosmos/cosmos-sdk/types/simulation" -) - -// FindAccount find a specific address from an account list. -func FindAccount(accs []simtypes.Account, address string) (simtypes.Account, bool) { - creator, err := sdk.AccAddressFromBech32(address) - if err != nil { - panic(err) - } - return simtypes.FindAccount(accs, creator) -} diff --git a/x/interchainqueries/types/codec.go b/x/interchainqueries/types/codec.go deleted file mode 100644 index 985707a3..00000000 --- a/x/interchainqueries/types/codec.go +++ /dev/null @@ -1,30 +0,0 @@ -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(&MsgRegisterInterchainQuery{}, "interchainqueries/RegisterQuery", nil) - cdc.RegisterConcrete(&MsgUpdateParams{}, "interchainqueries/MsgUpdateParams", nil) -} - -func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { - registry.RegisterImplementations( - (*sdk.Msg)(nil), - &MsgRegisterInterchainQuery{}, - &MsgSubmitQueryResult{}, - &MsgUpdateInterchainQueryRequest{}, - &MsgRemoveInterchainQueryRequest{}, - &MsgUpdateParams{}, - ) - msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) -} - -var ( - Amino = codec.NewLegacyAmino() - ModuleCdc = codec.NewProtoCodec(cdctypes.NewInterfaceRegistry()) -) diff --git a/x/interchainqueries/types/constants.go b/x/interchainqueries/types/constants.go deleted file mode 100644 index 4c93fbef..00000000 --- a/x/interchainqueries/types/constants.go +++ /dev/null @@ -1,3 +0,0 @@ -package types - -const ConsensusVersion = 2 diff --git a/x/interchainqueries/types/errors.go b/x/interchainqueries/types/errors.go deleted file mode 100644 index f9b3f2aa..00000000 --- a/x/interchainqueries/types/errors.go +++ /dev/null @@ -1,31 +0,0 @@ -package types - -import ( - "cosmossdk.io/errors" -) - -// x/interchainqueries module sentinel errors. -var ( - ErrInvalidQueryID = errors.Register(ModuleName, 1100, "invalid query id") - ErrEmptyResult = errors.Register(ModuleName, 1101, "empty result") - ErrInvalidClientID = errors.Register(ModuleName, 1102, "invalid client id") - ErrInvalidUpdatePeriod = errors.Register(ModuleName, 1103, "invalid update period") - ErrInvalidConnectionID = errors.Register(ModuleName, 1104, "invalid connection id") - ErrInvalidQueryType = errors.Register(ModuleName, 1105, "invalid query type") - ErrInvalidTransactionsFilter = errors.Register(ModuleName, 1106, "invalid transactions filter") - ErrInvalidSubmittedResult = errors.Register(ModuleName, 1107, "invalid result") - ErrProtoMarshal = errors.Register(ModuleName, 1108, "failed to marshal protobuf bytes") - ErrProtoUnmarshal = errors.Register(ModuleName, 1109, "failed to unmarshal protobuf bytes") - ErrInvalidType = errors.Register(ModuleName, 1110, "invalid type") - ErrInternal = errors.Register(ModuleName, 1111, "internal error") - ErrInvalidProof = errors.Register(ModuleName, 1112, "merkle proof is invalid") - ErrInvalidHeader = errors.Register(ModuleName, 1113, "header is invalid") - ErrInvalidHeight = errors.Register(ModuleName, 1114, "height is invalid") - ErrNoQueryResult = errors.Register(ModuleName, 1115, "no query result") - ErrNotContract = errors.Register(ModuleName, 1116, "not a contract") - ErrEmptyKeys = errors.Register(ModuleName, 1117, "keys are empty") - ErrEmptyKeyPath = errors.Register(ModuleName, 1118, "key path is empty") - ErrEmptyKeyID = errors.Register(ModuleName, 1119, "key id is empty") - ErrTooManyKVQueryKeys = errors.Register(ModuleName, 1120, "too many keys") - ErrUnexpectedQueryTypeGenesis = errors.Register(ModuleName, 1121, "unexpected query type") -) diff --git a/x/interchainqueries/types/expected_keepers.go b/x/interchainqueries/types/expected_keepers.go deleted file mode 100644 index ef0e8ffd..00000000 --- a/x/interchainqueries/types/expected_keepers.go +++ /dev/null @@ -1,28 +0,0 @@ -package types - -import ( - "context" - - sdk "github.com/cosmos/cosmos-sdk/types" - ibcclienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" //nolint:staticcheck -) - -// AccountKeeper defines the expected account keeper used for simulations (noalias). -type AccountKeeper interface { - GetAccount(ctx context.Context, addr sdk.AccAddress) sdk.AccountI - // Methods imported from account should be defined here -} - -// BankKeeper defines the expected interface needed to retrieve account balances. -type BankKeeper interface { - SpendableCoins(ctx context.Context, addr sdk.AccAddress) sdk.Coins - SendCoinsFromModuleToAccount(ctx context.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error - SendCoinsFromAccountToModule(ctx context.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error - // Methods imported from bank should be defined here -} - -type ContractManagerKeeper interface { - HasContractInfo(ctx context.Context, contractAddress sdk.AccAddress) bool - SudoKVQueryResult(ctx context.Context, contractAddress sdk.AccAddress, queryID uint64) ([]byte, error) - SudoTxQueryResult(ctx context.Context, contractAddress sdk.AccAddress, queryID uint64, height ibcclienttypes.Height, data []byte) ([]byte, error) -} diff --git a/x/interchainqueries/types/genesis.go b/x/interchainqueries/types/genesis.go deleted file mode 100644 index c8ba8f46..00000000 --- a/x/interchainqueries/types/genesis.go +++ /dev/null @@ -1,52 +0,0 @@ -package types - -import ( - "cosmossdk.io/errors" - sdk "github.com/cosmos/cosmos-sdk/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 { - err := gs.Params.Validate() - if err != nil { - return err - } - seenIDs := map[uint64]bool{} - - for _, val := range gs.GetRegisteredQueries() { - if seenIDs[val.Id] { - return errors.Wrapf(ErrInvalidQueryID, "duplicate query id: %d", val.Id) - } - seenIDs[val.Id] = true - - _, err = sdk.AccAddressFromBech32(val.Owner) - if err != nil { - return errors.Wrapf(err, "Invalid owner address (%s)", err) - } - - switch val.QueryType { - case string(InterchainQueryTypeTX): - if err := ValidateTransactionsFilter(val.TransactionsFilter); err != nil { - return errors.Wrap(ErrInvalidTransactionsFilter, err.Error()) - } - case string(InterchainQueryTypeKV): - if len(val.Keys) == 0 { - return errors.Wrap(ErrEmptyKeys, "keys cannot be empty") - } - if err := validateKeys(val.GetKeys()); err != nil { - return err - } - default: - return errors.Wrapf(ErrUnexpectedQueryTypeGenesis, "Unexpected query type: %s", val.QueryType) - } - } - return nil -} diff --git a/x/interchainqueries/types/genesis.pb.go b/x/interchainqueries/types/genesis.pb.go deleted file mode 100644 index 69b482a1..00000000 --- a/x/interchainqueries/types/genesis.pb.go +++ /dev/null @@ -1,1338 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: nolus/interchainqueries/genesis.proto - -package types - -import ( - fmt "fmt" - github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" - types1 "github.com/cosmos/cosmos-sdk/types" - _ "github.com/cosmos/gogoproto/gogoproto" - proto "github.com/cosmos/gogoproto/proto" - types "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" - 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 - -// RegisteredQuery defines a query that was registered by a user. -type RegisteredQuery struct { - // The unique id of the registered query. - Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - // The address that registered the query. - Owner string `protobuf:"bytes,2,opt,name=owner,proto3" json:"owner,omitempty"` - // The query type identifier: `kv` or `tx` now - QueryType string `protobuf:"bytes,3,opt,name=query_type,json=queryType,proto3" json:"query_type,omitempty"` - // The KV-storage keys for which we want to get values from remote chain - Keys []*KVKey `protobuf:"bytes,4,rep,name=keys,proto3" json:"keys,omitempty"` - // The filter for transaction search ICQ - TransactionsFilter string `protobuf:"bytes,5,opt,name=transactions_filter,json=transactionsFilter,proto3" json:"transactions_filter,omitempty"` - // The IBC connection ID for getting ConsensusState to verify proofs - ConnectionId string `protobuf:"bytes,6,opt,name=connection_id,json=connectionId,proto3" json:"connection_id,omitempty"` - // Parameter that defines how often the query must be updated. - UpdatePeriod uint64 `protobuf:"varint,7,opt,name=update_period,json=updatePeriod,proto3" json:"update_period,omitempty"` - // The local chain last block height when the query result was updated. - LastSubmittedResultLocalHeight uint64 `protobuf:"varint,8,opt,name=last_submitted_result_local_height,json=lastSubmittedResultLocalHeight,proto3" json:"last_submitted_result_local_height,omitempty"` - // The remote chain last block height when the query result was updated. - LastSubmittedResultRemoteHeight *types.Height `protobuf:"bytes,9,opt,name=last_submitted_result_remote_height,json=lastSubmittedResultRemoteHeight,proto3" json:"last_submitted_result_remote_height,omitempty"` - // Amount of coins deposited for the query. - Deposit github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,10,rep,name=deposit,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"deposit"` - // Timeout before query becomes available for everybody to remove. - SubmitTimeout uint64 `protobuf:"varint,11,opt,name=submit_timeout,json=submitTimeout,proto3" json:"submit_timeout,omitempty"` - // The local chain height when the query was registered. - RegisteredAtHeight uint64 `protobuf:"varint,12,opt,name=registered_at_height,json=registeredAtHeight,proto3" json:"registered_at_height,omitempty"` -} - -func (m *RegisteredQuery) Reset() { *m = RegisteredQuery{} } -func (m *RegisteredQuery) String() string { return proto.CompactTextString(m) } -func (*RegisteredQuery) ProtoMessage() {} -func (*RegisteredQuery) Descriptor() ([]byte, []int) { - return fileDescriptor_08fbcb001df4c4fa, []int{0} -} -func (m *RegisteredQuery) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *RegisteredQuery) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_RegisteredQuery.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 *RegisteredQuery) XXX_Merge(src proto.Message) { - xxx_messageInfo_RegisteredQuery.Merge(m, src) -} -func (m *RegisteredQuery) XXX_Size() int { - return m.Size() -} -func (m *RegisteredQuery) XXX_DiscardUnknown() { - xxx_messageInfo_RegisteredQuery.DiscardUnknown(m) -} - -var xxx_messageInfo_RegisteredQuery proto.InternalMessageInfo - -func (m *RegisteredQuery) GetId() uint64 { - if m != nil { - return m.Id - } - return 0 -} - -func (m *RegisteredQuery) GetOwner() string { - if m != nil { - return m.Owner - } - return "" -} - -func (m *RegisteredQuery) GetQueryType() string { - if m != nil { - return m.QueryType - } - return "" -} - -func (m *RegisteredQuery) GetKeys() []*KVKey { - if m != nil { - return m.Keys - } - return nil -} - -func (m *RegisteredQuery) GetTransactionsFilter() string { - if m != nil { - return m.TransactionsFilter - } - return "" -} - -func (m *RegisteredQuery) GetConnectionId() string { - if m != nil { - return m.ConnectionId - } - return "" -} - -func (m *RegisteredQuery) GetUpdatePeriod() uint64 { - if m != nil { - return m.UpdatePeriod - } - return 0 -} - -func (m *RegisteredQuery) GetLastSubmittedResultLocalHeight() uint64 { - if m != nil { - return m.LastSubmittedResultLocalHeight - } - return 0 -} - -func (m *RegisteredQuery) GetLastSubmittedResultRemoteHeight() *types.Height { - if m != nil { - return m.LastSubmittedResultRemoteHeight - } - return nil -} - -func (m *RegisteredQuery) GetDeposit() github_com_cosmos_cosmos_sdk_types.Coins { - if m != nil { - return m.Deposit - } - return nil -} - -func (m *RegisteredQuery) GetSubmitTimeout() uint64 { - if m != nil { - return m.SubmitTimeout - } - return 0 -} - -func (m *RegisteredQuery) GetRegisteredAtHeight() uint64 { - if m != nil { - return m.RegisteredAtHeight - } - return 0 -} - -// KVKey defines a key-value pair for KVStore. -type KVKey struct { - // Path (storage prefix) to the storage where you want to read value by key - // (usually name of cosmos-sdk module: 'staking', 'bank', etc.) - Path string `protobuf:"bytes,1,opt,name=path,proto3" json:"path,omitempty"` - // Key you want to read from the storage - Key []byte `protobuf:"bytes,2,opt,name=key,proto3" json:"key,omitempty"` -} - -func (m *KVKey) Reset() { *m = KVKey{} } -func (m *KVKey) String() string { return proto.CompactTextString(m) } -func (*KVKey) ProtoMessage() {} -func (*KVKey) Descriptor() ([]byte, []int) { - return fileDescriptor_08fbcb001df4c4fa, []int{1} -} -func (m *KVKey) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *KVKey) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_KVKey.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 *KVKey) XXX_Merge(src proto.Message) { - xxx_messageInfo_KVKey.Merge(m, src) -} -func (m *KVKey) XXX_Size() int { - return m.Size() -} -func (m *KVKey) XXX_DiscardUnknown() { - xxx_messageInfo_KVKey.DiscardUnknown(m) -} - -var xxx_messageInfo_KVKey proto.InternalMessageInfo - -func (m *KVKey) GetPath() string { - if m != nil { - return m.Path - } - return "" -} - -func (m *KVKey) GetKey() []byte { - if m != nil { - return m.Key - } - return nil -} - -// GenesisState defines the interchainqueries module's genesis state. -type GenesisState struct { - Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` - RegisteredQueries []*RegisteredQuery `protobuf:"bytes,2,rep,name=registered_queries,json=registeredQueries,proto3" json:"registered_queries,omitempty"` -} - -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_08fbcb001df4c4fa, []int{2} -} -func (m *GenesisState) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_GenesisState.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *GenesisState) XXX_Merge(src proto.Message) { - xxx_messageInfo_GenesisState.Merge(m, src) -} -func (m *GenesisState) XXX_Size() int { - return m.Size() -} -func (m *GenesisState) XXX_DiscardUnknown() { - xxx_messageInfo_GenesisState.DiscardUnknown(m) -} - -var xxx_messageInfo_GenesisState proto.InternalMessageInfo - -func (m *GenesisState) GetParams() Params { - if m != nil { - return m.Params - } - return Params{} -} - -func (m *GenesisState) GetRegisteredQueries() []*RegisteredQuery { - if m != nil { - return m.RegisteredQueries - } - return nil -} - -func init() { - proto.RegisterType((*RegisteredQuery)(nil), "nolus.interchainqueries.RegisteredQuery") - proto.RegisterType((*KVKey)(nil), "nolus.interchainqueries.KVKey") - proto.RegisterType((*GenesisState)(nil), "nolus.interchainqueries.GenesisState") -} - -func init() { - proto.RegisterFile("nolus/interchainqueries/genesis.proto", fileDescriptor_08fbcb001df4c4fa) -} - -var fileDescriptor_08fbcb001df4c4fa = []byte{ - // 642 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x53, 0xcf, 0x6e, 0xd3, 0x4e, - 0x10, 0x8e, 0xd3, 0xb4, 0xfd, 0x65, 0x93, 0xf6, 0x07, 0x4b, 0x25, 0x4c, 0x25, 0x9c, 0x28, 0xa5, - 0x52, 0x2e, 0xd9, 0x6d, 0xc2, 0x19, 0x24, 0x8a, 0xc4, 0xbf, 0x22, 0x54, 0xdc, 0x0a, 0x10, 0x17, - 0x6b, 0x63, 0x0f, 0xc9, 0xaa, 0x8e, 0xd7, 0xec, 0xae, 0x0b, 0x7e, 0x0b, 0x9e, 0x82, 0x03, 0x4f, - 0xd2, 0x63, 0x8f, 0x9c, 0x00, 0xb5, 0x8f, 0xc1, 0x05, 0x79, 0xec, 0xd0, 0x02, 0xcd, 0xc9, 0xe3, - 0x6f, 0xbf, 0xf9, 0x76, 0x67, 0xe6, 0x1b, 0xb2, 0x9d, 0xa8, 0x38, 0x33, 0x5c, 0x26, 0x16, 0x74, - 0x38, 0x15, 0x32, 0x79, 0x9f, 0x81, 0x96, 0x60, 0xf8, 0x04, 0x12, 0x30, 0xd2, 0xb0, 0x54, 0x2b, - 0xab, 0xe8, 0x4d, 0xa4, 0xb1, 0x7f, 0x68, 0x9b, 0x5e, 0xa8, 0xcc, 0x4c, 0x19, 0x3e, 0x16, 0x06, - 0xf8, 0xf1, 0x70, 0x0c, 0x56, 0x0c, 0x79, 0xa8, 0x64, 0x52, 0x26, 0x6e, 0x6e, 0x4c, 0xd4, 0x44, - 0x61, 0xc8, 0x8b, 0xa8, 0x42, 0x3b, 0x72, 0x1c, 0xf2, 0x50, 0x69, 0xe0, 0x61, 0x2c, 0x21, 0xb1, - 0xfc, 0x78, 0x58, 0x45, 0x15, 0xe1, 0xce, 0xa2, 0x67, 0xa5, 0x42, 0x8b, 0x59, 0xf5, 0xaa, 0xde, - 0xcf, 0x06, 0xf9, 0xdf, 0x87, 0x89, 0x34, 0x16, 0x34, 0x44, 0x2f, 0x33, 0xd0, 0x39, 0x5d, 0x27, - 0x75, 0x19, 0xb9, 0x4e, 0xd7, 0xe9, 0x37, 0xfc, 0xba, 0x8c, 0xe8, 0x06, 0x59, 0x56, 0x1f, 0x12, - 0xd0, 0x6e, 0xbd, 0xeb, 0xf4, 0x9b, 0x7e, 0xf9, 0x43, 0x6f, 0x13, 0x52, 0x28, 0xe6, 0x81, 0xcd, - 0x53, 0x70, 0x97, 0xf0, 0xa8, 0x89, 0xc8, 0x61, 0x9e, 0x02, 0x1d, 0x91, 0xc6, 0x11, 0xe4, 0xc6, - 0x6d, 0x74, 0x97, 0xfa, 0xad, 0x91, 0xc7, 0x16, 0x54, 0xcf, 0xf6, 0x5e, 0xed, 0x41, 0xee, 0x23, - 0x97, 0x72, 0x72, 0xc3, 0x6a, 0x91, 0x18, 0x11, 0x5a, 0xa9, 0x12, 0x13, 0xbc, 0x93, 0xb1, 0x05, - 0xed, 0x2e, 0xa3, 0x36, 0xbd, 0x7c, 0xf4, 0x08, 0x4f, 0xe8, 0x16, 0x59, 0x0b, 0x55, 0x92, 0x00, - 0x82, 0x81, 0x8c, 0xdc, 0x15, 0xa4, 0xb6, 0x2f, 0xc0, 0xa7, 0x51, 0x41, 0xca, 0xd2, 0x48, 0x58, - 0x08, 0x52, 0xd0, 0x52, 0x45, 0xee, 0x2a, 0x56, 0xd6, 0x2e, 0xc1, 0x7d, 0xc4, 0xe8, 0x33, 0xd2, - 0x8b, 0x85, 0xb1, 0x81, 0xc9, 0xc6, 0x33, 0x69, 0x2d, 0x44, 0x81, 0x06, 0x93, 0xc5, 0x36, 0x88, - 0x55, 0x28, 0xe2, 0x60, 0x0a, 0x72, 0x32, 0xb5, 0xee, 0x7f, 0x98, 0xe9, 0x15, 0xcc, 0x83, 0x39, - 0xd1, 0x47, 0xde, 0xf3, 0x82, 0xf6, 0x04, 0x59, 0x74, 0x4a, 0xb6, 0xae, 0xd6, 0xd2, 0x30, 0x53, - 0x16, 0xe6, 0x62, 0xcd, 0xae, 0xd3, 0x6f, 0x8d, 0x36, 0x99, 0x1c, 0x87, 0xac, 0x18, 0x24, 0xab, - 0xc6, 0x77, 0x3c, 0x64, 0xa5, 0x90, 0xdf, 0xb9, 0xe2, 0x22, 0x1f, 0x35, 0xaa, 0x9b, 0x80, 0xac, - 0x46, 0x90, 0x2a, 0x23, 0xad, 0x4b, 0xb0, 0xcf, 0xb7, 0x58, 0x69, 0x26, 0x56, 0x98, 0x89, 0x55, - 0x66, 0x62, 0x0f, 0x95, 0x4c, 0x76, 0x77, 0x4e, 0xbe, 0x75, 0x6a, 0x5f, 0xbe, 0x77, 0xfa, 0x13, - 0x69, 0xa7, 0xd9, 0x98, 0x85, 0x6a, 0xc6, 0x2b, 0xe7, 0x95, 0x9f, 0x81, 0x89, 0x8e, 0x78, 0x31, - 0x4c, 0x83, 0x09, 0xc6, 0x9f, 0x6b, 0xd3, 0x6d, 0xb2, 0x5e, 0xd6, 0x12, 0x58, 0x39, 0x03, 0x95, - 0x59, 0xb7, 0x85, 0x8d, 0x58, 0x2b, 0xd1, 0xc3, 0x12, 0xa4, 0x3b, 0x64, 0x43, 0xff, 0xb6, 0x52, - 0x20, 0xec, 0xbc, 0xd0, 0x36, 0x92, 0xe9, 0xc5, 0xd9, 0x03, 0x5b, 0xbe, 0xbf, 0x37, 0x20, 0xcb, - 0x38, 0x7f, 0x4a, 0x49, 0x23, 0x15, 0x76, 0x8a, 0xa6, 0x6b, 0xfa, 0x18, 0xd3, 0x6b, 0x64, 0xe9, - 0x08, 0x72, 0x34, 0x5d, 0xdb, 0x2f, 0xc2, 0xde, 0x67, 0x87, 0xb4, 0x1f, 0x97, 0x4b, 0x75, 0x60, - 0x85, 0x05, 0x7a, 0x8f, 0xac, 0x94, 0x6e, 0xc6, 0xc4, 0xd6, 0xa8, 0xb3, 0xd0, 0x66, 0xfb, 0x48, - 0xdb, 0x6d, 0x14, 0x4d, 0xf0, 0xab, 0x24, 0xfa, 0x9a, 0x5c, 0x7a, 0x54, 0x50, 0x51, 0xdd, 0x3a, - 0x76, 0xb2, 0xbf, 0x50, 0xea, 0xaf, 0x75, 0xf1, 0xaf, 0xeb, 0x3f, 0x00, 0x09, 0x66, 0xf7, 0xcd, - 0xc9, 0x99, 0xe7, 0x9c, 0x9e, 0x79, 0xce, 0x8f, 0x33, 0xcf, 0xf9, 0x74, 0xee, 0xd5, 0x4e, 0xcf, - 0xbd, 0xda, 0xd7, 0x73, 0xaf, 0xf6, 0xf6, 0xfe, 0xa5, 0xee, 0xbf, 0x28, 0x2e, 0x18, 0xec, 0x17, - 0x7b, 0x18, 0xaa, 0x98, 0xe3, 0x7d, 0x03, 0x5c, 0xe9, 0x8f, 0x57, 0xac, 0x2d, 0x4e, 0x66, 0xbc, - 0x82, 0x6b, 0x7b, 0xf7, 0x57, 0x00, 0x00, 0x00, 0xff, 0xff, 0xcb, 0xd9, 0x5d, 0xce, 0x75, 0x04, - 0x00, 0x00, -} - -func (m *RegisteredQuery) 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 *RegisteredQuery) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *RegisteredQuery) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.RegisteredAtHeight != 0 { - i = encodeVarintGenesis(dAtA, i, uint64(m.RegisteredAtHeight)) - i-- - dAtA[i] = 0x60 - } - if m.SubmitTimeout != 0 { - i = encodeVarintGenesis(dAtA, i, uint64(m.SubmitTimeout)) - i-- - dAtA[i] = 0x58 - } - if len(m.Deposit) > 0 { - for iNdEx := len(m.Deposit) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Deposit[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x52 - } - } - if m.LastSubmittedResultRemoteHeight != nil { - { - size, err := m.LastSubmittedResultRemoteHeight.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x4a - } - if m.LastSubmittedResultLocalHeight != 0 { - i = encodeVarintGenesis(dAtA, i, uint64(m.LastSubmittedResultLocalHeight)) - i-- - dAtA[i] = 0x40 - } - if m.UpdatePeriod != 0 { - i = encodeVarintGenesis(dAtA, i, uint64(m.UpdatePeriod)) - i-- - dAtA[i] = 0x38 - } - if len(m.ConnectionId) > 0 { - i -= len(m.ConnectionId) - copy(dAtA[i:], m.ConnectionId) - i = encodeVarintGenesis(dAtA, i, uint64(len(m.ConnectionId))) - i-- - dAtA[i] = 0x32 - } - if len(m.TransactionsFilter) > 0 { - i -= len(m.TransactionsFilter) - copy(dAtA[i:], m.TransactionsFilter) - i = encodeVarintGenesis(dAtA, i, uint64(len(m.TransactionsFilter))) - i-- - dAtA[i] = 0x2a - } - if len(m.Keys) > 0 { - for iNdEx := len(m.Keys) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Keys[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - } - } - if len(m.QueryType) > 0 { - i -= len(m.QueryType) - copy(dAtA[i:], m.QueryType) - i = encodeVarintGenesis(dAtA, i, uint64(len(m.QueryType))) - i-- - dAtA[i] = 0x1a - } - if len(m.Owner) > 0 { - i -= len(m.Owner) - copy(dAtA[i:], m.Owner) - i = encodeVarintGenesis(dAtA, i, uint64(len(m.Owner))) - i-- - dAtA[i] = 0x12 - } - if m.Id != 0 { - i = encodeVarintGenesis(dAtA, i, uint64(m.Id)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *KVKey) 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 *KVKey) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *KVKey) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Key) > 0 { - i -= len(m.Key) - copy(dAtA[i:], m.Key) - i = encodeVarintGenesis(dAtA, i, uint64(len(m.Key))) - i-- - dAtA[i] = 0x12 - } - if len(m.Path) > 0 { - i -= len(m.Path) - copy(dAtA[i:], m.Path) - i = encodeVarintGenesis(dAtA, i, uint64(len(m.Path))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *GenesisState) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *GenesisState) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.RegisteredQueries) > 0 { - for iNdEx := len(m.RegisteredQueries) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.RegisteredQueries[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - } - { - size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { - offset -= sovGenesis(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *RegisteredQuery) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Id != 0 { - n += 1 + sovGenesis(uint64(m.Id)) - } - l = len(m.Owner) - if l > 0 { - n += 1 + l + sovGenesis(uint64(l)) - } - l = len(m.QueryType) - if l > 0 { - n += 1 + l + sovGenesis(uint64(l)) - } - if len(m.Keys) > 0 { - for _, e := range m.Keys { - l = e.Size() - n += 1 + l + sovGenesis(uint64(l)) - } - } - l = len(m.TransactionsFilter) - if l > 0 { - n += 1 + l + sovGenesis(uint64(l)) - } - l = len(m.ConnectionId) - if l > 0 { - n += 1 + l + sovGenesis(uint64(l)) - } - if m.UpdatePeriod != 0 { - n += 1 + sovGenesis(uint64(m.UpdatePeriod)) - } - if m.LastSubmittedResultLocalHeight != 0 { - n += 1 + sovGenesis(uint64(m.LastSubmittedResultLocalHeight)) - } - if m.LastSubmittedResultRemoteHeight != nil { - l = m.LastSubmittedResultRemoteHeight.Size() - n += 1 + l + sovGenesis(uint64(l)) - } - if len(m.Deposit) > 0 { - for _, e := range m.Deposit { - l = e.Size() - n += 1 + l + sovGenesis(uint64(l)) - } - } - if m.SubmitTimeout != 0 { - n += 1 + sovGenesis(uint64(m.SubmitTimeout)) - } - if m.RegisteredAtHeight != 0 { - n += 1 + sovGenesis(uint64(m.RegisteredAtHeight)) - } - return n -} - -func (m *KVKey) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Path) - if l > 0 { - n += 1 + l + sovGenesis(uint64(l)) - } - l = len(m.Key) - if l > 0 { - n += 1 + l + sovGenesis(uint64(l)) - } - return n -} - -func (m *GenesisState) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Params.Size() - n += 1 + l + sovGenesis(uint64(l)) - if len(m.RegisteredQueries) > 0 { - for _, e := range m.RegisteredQueries { - l = e.Size() - n += 1 + l + sovGenesis(uint64(l)) - } - } - return n -} - -func sovGenesis(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozGenesis(x uint64) (n int) { - return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *RegisteredQuery) 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: RegisteredQuery: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: RegisteredQuery: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) - } - m.Id = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Id |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - 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 ErrIntOverflowGenesis - } - 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 ErrInvalidLengthGenesis - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthGenesis - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Owner = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field QueryType", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - 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 ErrInvalidLengthGenesis - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthGenesis - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.QueryType = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Keys", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenesis - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthGenesis - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Keys = append(m.Keys, &KVKey{}) - if err := m.Keys[len(m.Keys)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TransactionsFilter", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - 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 ErrInvalidLengthGenesis - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthGenesis - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.TransactionsFilter = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 6: - 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 ErrIntOverflowGenesis - } - 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 ErrInvalidLengthGenesis - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthGenesis - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ConnectionId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 7: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field UpdatePeriod", wireType) - } - m.UpdatePeriod = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.UpdatePeriod |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 8: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field LastSubmittedResultLocalHeight", wireType) - } - m.LastSubmittedResultLocalHeight = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.LastSubmittedResultLocalHeight |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 9: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field LastSubmittedResultRemoteHeight", 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 m.LastSubmittedResultRemoteHeight == nil { - m.LastSubmittedResultRemoteHeight = &types.Height{} - } - if err := m.LastSubmittedResultRemoteHeight.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 10: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Deposit", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenesis - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthGenesis - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Deposit = append(m.Deposit, types1.Coin{}) - if err := m.Deposit[len(m.Deposit)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 11: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field SubmitTimeout", wireType) - } - m.SubmitTimeout = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.SubmitTimeout |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 12: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field RegisteredAtHeight", wireType) - } - m.RegisteredAtHeight = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.RegisteredAtHeight |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - 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 (m *KVKey) 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: KVKey: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: KVKey: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Path", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - 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 ErrInvalidLengthGenesis - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthGenesis - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Path = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthGenesis - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthGenesis - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Key = append(m.Key[:0], dAtA[iNdEx:postIndex]...) - if m.Key == nil { - m.Key = []byte{} - } - 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 (m *GenesisState) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: GenesisState: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenesis - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthGenesis - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RegisteredQueries", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenesis - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthGenesis - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.RegisteredQueries = append(m.RegisteredQueries, &RegisteredQuery{}) - if err := m.RegisteredQueries[len(m.RegisteredQueries)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipGenesis(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthGenesis - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipGenesis(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowGenesis - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowGenesis - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowGenesis - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthGenesis - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupGenesis - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthGenesis - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthGenesis = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowGenesis = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupGenesis = fmt.Errorf("proto: unexpected end of group") -) diff --git a/x/interchainqueries/types/genesis_test.go b/x/interchainqueries/types/genesis_test.go deleted file mode 100644 index bfe5eca4..00000000 --- a/x/interchainqueries/types/genesis_test.go +++ /dev/null @@ -1,37 +0,0 @@ -package types_test - -import ( - "testing" - - "github.com/stretchr/testify/require" - - "github.com/Nolus-Protocol/nolus-core/x/interchainqueries/types" -) - -func TestGenesisState_Validate(t *testing.T) { - for _, tc := range []struct { - desc string - genState *types.GenesisState - valid bool - }{ - { - desc: "default is valid", - genState: types.DefaultGenesis(), - valid: true, - }, - { - desc: "valid genesis state", - genState: &types.GenesisState{}, - valid: true, - }, - } { - t.Run(tc.desc, func(t *testing.T) { - err := tc.genState.Validate() - if tc.valid { - require.NoError(t, err) - } else { - require.Error(t, err) - } - }) - } -} diff --git a/x/interchainqueries/types/keys.go b/x/interchainqueries/types/keys.go deleted file mode 100644 index 91444280..00000000 --- a/x/interchainqueries/types/keys.go +++ /dev/null @@ -1,71 +0,0 @@ -package types - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" -) - -const ( - // ModuleName defines the module name. - ModuleName = "interchainqueries" - - // 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_interchainqueries" -) - -const ( - prefixRegisteredQuery = iota + 1 - prefixRegisteredQueryResult - prefixSubmittedTx - prefixTxQueryToRemove - prefixParamsKey -) - -var ( - // RegisteredQueryKey is the store key for queries registered in the module. - RegisteredQueryKey = []byte{prefixRegisteredQuery} - // RegisteredQueryResultKey is the store key for KV query results. - RegisteredQueryResultKey = []byte{prefixRegisteredQueryResult} - // SubmittedTxKey is the store key for submitted transaction hashes. - SubmittedTxKey = []byte{prefixSubmittedTx} - // TxQueryToRemoveKey is the store key for TX queries marked to be removed. - TxQueryToRemoveKey = []byte{prefixTxQueryToRemove} - // ParamsKey is the store key for the module params. - ParamsKey = []byte{prefixParamsKey} - // LastRegisteredQueryIDKey is the store key for last registered query ID. - LastRegisteredQueryIDKey = []byte{0x64} -) - -// GetRegisteredQueryByIDKey builds a store key to access a registered query by query ID. -func GetRegisteredQueryByIDKey(id uint64) []byte { - return append(RegisteredQueryKey, sdk.Uint64ToBigEndian(id)...) -} - -// GetSubmittedTransactionIDForQueryKeyPrefix builds a store key prefix to access TX query hashes by ID. -func GetSubmittedTransactionIDForQueryKeyPrefix(queryID uint64) []byte { - return append(SubmittedTxKey, sdk.Uint64ToBigEndian(queryID)...) -} - -// GetSubmittedTransactionIDForQueryKey builds a store key to access a submitted transaction hash -// by query ID and hash. -func GetSubmittedTransactionIDForQueryKey(queryID uint64, txHash []byte) []byte { - return append(GetSubmittedTransactionIDForQueryKeyPrefix(queryID), txHash...) -} - -// GetRegisteredQueryResultByIDKey builds a store key to access a KV query result by query ID. -func GetRegisteredQueryResultByIDKey(id uint64) []byte { - return append(RegisteredQueryResultKey, sdk.Uint64ToBigEndian(id)...) -} - -// GetTxQueryToRemoveByIDKey builds a store key to access a TX query marked to be removed. -func GetTxQueryToRemoveByIDKey(id uint64) []byte { - return append(TxQueryToRemoveKey, sdk.Uint64ToBigEndian(id)...) -} diff --git a/x/interchainqueries/types/message_remove_interchain_query.go b/x/interchainqueries/types/message_remove_interchain_query.go deleted file mode 100644 index 632c4a55..00000000 --- a/x/interchainqueries/types/message_remove_interchain_query.go +++ /dev/null @@ -1,55 +0,0 @@ -package types - -import ( - "strings" - - "cosmossdk.io/errors" - - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" -) - -var _ sdk.Msg = &MsgRemoveInterchainQueryRequest{} - -func NewMsgRemoveInterchainQuery(sender string, queryID uint64) MsgRemoveInterchainQueryRequest { - return MsgRemoveInterchainQueryRequest{ - QueryId: queryID, - Sender: sender, - } -} - -func (msg MsgRemoveInterchainQueryRequest) Route() string { - return RouterKey -} - -func (msg MsgRemoveInterchainQueryRequest) Type() string { - return "remove-interchain-query" -} - -func (msg MsgRemoveInterchainQueryRequest) Validate() error { - if msg.GetQueryId() == 0 { - return errors.Wrap(ErrInvalidQueryID, "query_id cannot be empty or equal to 0") - } - - if strings.TrimSpace(msg.Sender) == "" { - return errors.Wrap(sdkerrors.ErrInvalidAddress, "missing sender address") - } - - if _, err := sdk.AccAddressFromBech32(msg.Sender); err != nil { - return errors.Wrapf(sdkerrors.ErrInvalidAddress, "failed to parse address: %s", msg.Sender) - } - - return nil -} - -func (msg MsgRemoveInterchainQueryRequest) GetSignBytes() []byte { - return ModuleCdc.MustMarshalJSON(&msg) -} - -func (msg MsgRemoveInterchainQueryRequest) GetSigners() []sdk.AccAddress { - senderAddr, err := sdk.AccAddressFromBech32(msg.Sender) - if err != nil { // should never happen as valid basic rejects invalid addresses - panic(err.Error()) - } - return []sdk.AccAddress{senderAddr} -} diff --git a/x/interchainqueries/types/params.go b/x/interchainqueries/types/params.go deleted file mode 100644 index 0e2f0f56..00000000 --- a/x/interchainqueries/types/params.go +++ /dev/null @@ -1,79 +0,0 @@ -package types - -import ( - "fmt" - - "cosmossdk.io/math" - sdk "github.com/cosmos/cosmos-sdk/types" - paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" - "gopkg.in/yaml.v2" - - "github.com/Nolus-Protocol/nolus-core/app/params" -) - -var _ paramtypes.ParamSet = (*Params)(nil) - -var ( - KeyQuerySubmitTimeout = []byte("QuerySubmitTimeout") - DefaultQuerySubmitTimeout = uint64(1036800) // One month, with block_time = 2.5s - KeyQueryDeposit = []byte("QueryDeposit") - DefaultQueryDeposit = sdk.NewCoins(sdk.NewCoin(params.DefaultBondDenom, math.NewInt(int64(1_000_000)))) - KeyTxQueryRemovalLimit = []byte("TxQueryRemovalLimit") - DefaultTxQueryRemovalLimit = uint64(10_000) -) - -// ParamKeyTable the param key table for launch module. -func ParamKeyTable() paramtypes.KeyTable { - return paramtypes.NewKeyTable( - paramtypes.NewParamSetPair(KeyQuerySubmitTimeout, DefaultQuerySubmitTimeout, func(_ interface{}) error { return nil }), - paramtypes.NewParamSetPair(KeyQueryDeposit, sdk.Coins{}, validateCoins), - paramtypes.NewParamSetPair(KeyTxQueryRemovalLimit, DefaultTxQueryRemovalLimit, func(_ interface{}) error { return nil }), - ) -} - -// NewParams creates a new Params instance. -func NewParams(querySubmitTimeout uint64, queryDeposit sdk.Coins, txQueryRemovalLimit uint64) Params { - return Params{ - QuerySubmitTimeout: querySubmitTimeout, - QueryDeposit: queryDeposit, - TxQueryRemovalLimit: txQueryRemovalLimit, - } -} - -// DefaultParams returns a default set of parameters. -func DefaultParams() Params { - return NewParams(DefaultQuerySubmitTimeout, DefaultQueryDeposit, DefaultTxQueryRemovalLimit) -} - -// ParamSetPairs get the params.ParamSet. -func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { - return paramtypes.ParamSetPairs{ - paramtypes.NewParamSetPair(KeyQuerySubmitTimeout, &p.QuerySubmitTimeout, func(_ interface{}) error { return nil }), - paramtypes.NewParamSetPair(KeyQueryDeposit, &p.QueryDeposit, validateCoins), - paramtypes.NewParamSetPair(KeyTxQueryRemovalLimit, &p.TxQueryRemovalLimit, func(_ interface{}) error { return nil }), - } -} - -// Validate validates the set of params. -func (p Params) Validate() error { - return nil -} - -// String implements the Stringer interface. -func (p Params) String() string { - out, _ := yaml.Marshal(p) - return string(out) -} - -func validateCoins(i interface{}) error { - v, ok := i.(sdk.Coins) - if !ok { - return fmt.Errorf("invalid parameter type: %T", i) - } - - if !v.IsValid() { - return fmt.Errorf("invalid coins parameter: %s", v) - } - - return nil -} diff --git a/x/interchainqueries/types/params.pb.go b/x/interchainqueries/types/params.pb.go deleted file mode 100644 index 94b6336e..00000000 --- a/x/interchainqueries/types/params.pb.go +++ /dev/null @@ -1,417 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: nolus/interchainqueries/params.proto - -package types - -import ( - fmt "fmt" - github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" - types "github.com/cosmos/cosmos-sdk/types" - _ "github.com/cosmos/gogoproto/gogoproto" - proto "github.com/cosmos/gogoproto/proto" - io "io" - math "math" - math_bits "math/bits" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -// Params defines the parameters for the module. -type Params struct { - // Defines amount of blocks required before query becomes available for - // removal by anybody - QuerySubmitTimeout uint64 `protobuf:"varint,1,opt,name=query_submit_timeout,json=querySubmitTimeout,proto3" json:"query_submit_timeout,omitempty"` - // Amount of coins deposited for the query. - QueryDeposit github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,2,rep,name=query_deposit,json=queryDeposit,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"query_deposit"` - // Amount of tx hashes to be removed during a single EndBlock. Can vary to - // balance between network cleaning speed and EndBlock duration. A zero value - // means no limit. - TxQueryRemovalLimit uint64 `protobuf:"varint,3,opt,name=tx_query_removal_limit,json=txQueryRemovalLimit,proto3" json:"tx_query_removal_limit,omitempty"` -} - -func (m *Params) Reset() { *m = Params{} } -func (*Params) ProtoMessage() {} -func (*Params) Descriptor() ([]byte, []int) { - return fileDescriptor_d55c724307965f46, []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) GetQuerySubmitTimeout() uint64 { - if m != nil { - return m.QuerySubmitTimeout - } - return 0 -} - -func (m *Params) GetQueryDeposit() github_com_cosmos_cosmos_sdk_types.Coins { - if m != nil { - return m.QueryDeposit - } - return nil -} - -func (m *Params) GetTxQueryRemovalLimit() uint64 { - if m != nil { - return m.TxQueryRemovalLimit - } - return 0 -} - -func init() { - proto.RegisterType((*Params)(nil), "nolus.interchainqueries.Params") -} - -func init() { - proto.RegisterFile("nolus/interchainqueries/params.proto", fileDescriptor_d55c724307965f46) -} - -var fileDescriptor_d55c724307965f46 = []byte{ - // 336 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x91, 0x3f, 0x4f, 0xfa, 0x40, - 0x18, 0xc7, 0xdb, 0x1f, 0x84, 0xa1, 0x3f, 0x5d, 0x2a, 0x51, 0x64, 0x38, 0x88, 0x71, 0x60, 0xe1, - 0x0e, 0x64, 0x73, 0x70, 0x40, 0x47, 0x63, 0x10, 0x1d, 0x8c, 0x4b, 0xd3, 0x96, 0x0b, 0x5c, 0xec, - 0xf5, 0xa9, 0xbd, 0xa7, 0x04, 0xde, 0x85, 0xa3, 0xa3, 0xb3, 0xaf, 0x84, 0x91, 0xd1, 0x49, 0x0d, - 0x1d, 0x7c, 0x1b, 0xe6, 0xee, 0x18, 0x4c, 0x74, 0xea, 0x93, 0x7e, 0x9e, 0x3f, 0x9f, 0x7c, 0xcf, - 0x3b, 0x4e, 0x21, 0x29, 0x14, 0x13, 0x29, 0xf2, 0x3c, 0x9e, 0x85, 0x22, 0x7d, 0x2c, 0x78, 0x2e, - 0xb8, 0x62, 0x59, 0x98, 0x87, 0x52, 0xd1, 0x2c, 0x07, 0x04, 0xff, 0xc0, 0x74, 0xd1, 0x5f, 0x5d, - 0x4d, 0x12, 0x83, 0x92, 0xa0, 0x58, 0x14, 0x2a, 0xce, 0xe6, 0xfd, 0x88, 0x63, 0xd8, 0x67, 0x31, - 0x88, 0xd4, 0x0e, 0x36, 0xeb, 0x53, 0x98, 0x82, 0x29, 0x99, 0xae, 0xec, 0xdf, 0xa3, 0x2f, 0xd7, - 0xab, 0x8d, 0xcc, 0x7e, 0xbf, 0xe7, 0xd5, 0xf5, 0xae, 0x65, 0xa0, 0x8a, 0x48, 0x0a, 0x0c, 0x50, - 0x48, 0x0e, 0x05, 0x36, 0xdc, 0xb6, 0xdb, 0xa9, 0x8e, 0x7d, 0xc3, 0x6e, 0x0c, 0xba, 0xb5, 0xc4, - 0xcf, 0xbc, 0x5d, 0x3b, 0x31, 0xe1, 0x19, 0x28, 0x81, 0x8d, 0x7f, 0xed, 0x4a, 0xe7, 0xff, 0xc9, - 0x21, 0xb5, 0x2a, 0x54, 0xab, 0xd0, 0xad, 0x0a, 0x3d, 0x07, 0x91, 0x0e, 0x7b, 0xab, 0xf7, 0x96, - 0xf3, 0xfa, 0xd1, 0xea, 0x4c, 0x05, 0xce, 0x8a, 0x88, 0xc6, 0x20, 0xd9, 0xd6, 0xdb, 0x7e, 0xba, - 0x6a, 0xf2, 0xc0, 0x70, 0x99, 0x71, 0x65, 0x06, 0xd4, 0x78, 0xc7, 0x5c, 0xb8, 0xb0, 0x07, 0xfc, - 0x81, 0xb7, 0x8f, 0x8b, 0xc0, 0x1e, 0xcd, 0xb9, 0x84, 0x79, 0x98, 0x04, 0x89, 0x90, 0x02, 0x1b, - 0x15, 0x63, 0xb9, 0x87, 0x8b, 0x6b, 0x0d, 0xc7, 0x96, 0x5d, 0x6a, 0x74, 0x5a, 0x7d, 0x7e, 0x69, - 0x39, 0xc3, 0xbb, 0xd5, 0x86, 0xb8, 0xeb, 0x0d, 0x71, 0x3f, 0x37, 0xc4, 0x7d, 0x2a, 0x89, 0xb3, - 0x2e, 0x89, 0xf3, 0x56, 0x12, 0xe7, 0xfe, 0xec, 0x87, 0xcc, 0x95, 0x4e, 0xb7, 0x3b, 0xd2, 0xd9, - 0xc4, 0x90, 0x30, 0x13, 0x76, 0x37, 0x86, 0x9c, 0xb3, 0xc5, 0x1f, 0x2f, 0x63, 0x44, 0xa3, 0x9a, - 0x89, 0x72, 0xf0, 0x1d, 0x00, 0x00, 0xff, 0xff, 0x36, 0x58, 0x0d, 0xec, 0xc1, 0x01, 0x00, 0x00, -} - -func (m *Params) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *Params) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.TxQueryRemovalLimit != 0 { - i = encodeVarintParams(dAtA, i, uint64(m.TxQueryRemovalLimit)) - i-- - dAtA[i] = 0x18 - } - if len(m.QueryDeposit) > 0 { - for iNdEx := len(m.QueryDeposit) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.QueryDeposit[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintParams(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - } - if m.QuerySubmitTimeout != 0 { - i = encodeVarintParams(dAtA, i, uint64(m.QuerySubmitTimeout)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func encodeVarintParams(dAtA []byte, offset int, v uint64) int { - offset -= sovParams(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *Params) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.QuerySubmitTimeout != 0 { - n += 1 + sovParams(uint64(m.QuerySubmitTimeout)) - } - if len(m.QueryDeposit) > 0 { - for _, e := range m.QueryDeposit { - l = e.Size() - n += 1 + l + sovParams(uint64(l)) - } - } - if m.TxQueryRemovalLimit != 0 { - n += 1 + sovParams(uint64(m.TxQueryRemovalLimit)) - } - 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 != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field QuerySubmitTimeout", wireType) - } - m.QuerySubmitTimeout = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.QuerySubmitTimeout |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field QueryDeposit", 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 - } - m.QueryDeposit = append(m.QueryDeposit, types.Coin{}) - if err := m.QueryDeposit[len(m.QueryDeposit)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field TxQueryRemovalLimit", wireType) - } - m.TxQueryRemovalLimit = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.TxQueryRemovalLimit |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipParams(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthParams - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipParams(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowParams - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowParams - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowParams - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthParams - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupParams - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthParams - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthParams = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowParams = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupParams = fmt.Errorf("proto: unexpected end of group") -) diff --git a/x/interchainqueries/types/query.pb.go b/x/interchainqueries/types/query.pb.go deleted file mode 100644 index 0b55caeb..00000000 --- a/x/interchainqueries/types/query.pb.go +++ /dev/null @@ -1,2488 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: nolus/interchainqueries/query.proto - -package types - -import ( - context "context" - fmt "fmt" - query "github.com/cosmos/cosmos-sdk/types/query" - _ "github.com/cosmos/gogoproto/gogoproto" - grpc1 "github.com/cosmos/gogoproto/grpc" - proto "github.com/cosmos/gogoproto/proto" - _ "google.golang.org/genproto/googleapis/api/annotations" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" - io "io" - math "math" - math_bits "math/bits" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -// QueryParamsRequest is request type for the Query/Params RPC method. -type QueryParamsRequest struct { -} - -func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} } -func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) } -func (*QueryParamsRequest) ProtoMessage() {} -func (*QueryParamsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_5913889f6e620de0, []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_5913889f6e620de0, []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{} -} - -// QueryRegisteredQueriesRequest is request type for the Query/RegisteredQueries RPC method. -type QueryRegisteredQueriesRequest struct { - Owners []string `protobuf:"bytes,1,rep,name=owners,proto3" json:"owners,omitempty"` - ConnectionId string `protobuf:"bytes,2,opt,name=connection_id,json=connectionId,proto3" json:"connection_id,omitempty"` - Pagination *query.PageRequest `protobuf:"bytes,3,opt,name=pagination,proto3" json:"pagination,omitempty"` -} - -func (m *QueryRegisteredQueriesRequest) Reset() { *m = QueryRegisteredQueriesRequest{} } -func (m *QueryRegisteredQueriesRequest) String() string { return proto.CompactTextString(m) } -func (*QueryRegisteredQueriesRequest) ProtoMessage() {} -func (*QueryRegisteredQueriesRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_5913889f6e620de0, []int{2} -} -func (m *QueryRegisteredQueriesRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryRegisteredQueriesRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryRegisteredQueriesRequest.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 *QueryRegisteredQueriesRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryRegisteredQueriesRequest.Merge(m, src) -} -func (m *QueryRegisteredQueriesRequest) XXX_Size() int { - return m.Size() -} -func (m *QueryRegisteredQueriesRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryRegisteredQueriesRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryRegisteredQueriesRequest proto.InternalMessageInfo - -func (m *QueryRegisteredQueriesRequest) GetOwners() []string { - if m != nil { - return m.Owners - } - return nil -} - -func (m *QueryRegisteredQueriesRequest) GetConnectionId() string { - if m != nil { - return m.ConnectionId - } - return "" -} - -func (m *QueryRegisteredQueriesRequest) GetPagination() *query.PageRequest { - if m != nil { - return m.Pagination - } - return nil -} - -// QueryRegisteredQueriesResponse is response type for the Query/RegisteredQueries RPC method. -type QueryRegisteredQueriesResponse struct { - RegisteredQueries []RegisteredQuery `protobuf:"bytes,1,rep,name=registered_queries,json=registeredQueries,proto3" json:"registered_queries"` - // pagination defines the pagination in the response. - Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` -} - -func (m *QueryRegisteredQueriesResponse) Reset() { *m = QueryRegisteredQueriesResponse{} } -func (m *QueryRegisteredQueriesResponse) String() string { return proto.CompactTextString(m) } -func (*QueryRegisteredQueriesResponse) ProtoMessage() {} -func (*QueryRegisteredQueriesResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_5913889f6e620de0, []int{3} -} -func (m *QueryRegisteredQueriesResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryRegisteredQueriesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryRegisteredQueriesResponse.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 *QueryRegisteredQueriesResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryRegisteredQueriesResponse.Merge(m, src) -} -func (m *QueryRegisteredQueriesResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryRegisteredQueriesResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryRegisteredQueriesResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryRegisteredQueriesResponse proto.InternalMessageInfo - -func (m *QueryRegisteredQueriesResponse) GetRegisteredQueries() []RegisteredQuery { - if m != nil { - return m.RegisteredQueries - } - return nil -} - -func (m *QueryRegisteredQueriesResponse) GetPagination() *query.PageResponse { - if m != nil { - return m.Pagination - } - return nil -} - -// QueryRegisteredQueryRequest is request type for the Query/RegisteredQuery RPC method. -type QueryRegisteredQueryRequest struct { - QueryId uint64 `protobuf:"varint,1,opt,name=query_id,json=queryId,proto3" json:"query_id,omitempty"` -} - -func (m *QueryRegisteredQueryRequest) Reset() { *m = QueryRegisteredQueryRequest{} } -func (m *QueryRegisteredQueryRequest) String() string { return proto.CompactTextString(m) } -func (*QueryRegisteredQueryRequest) ProtoMessage() {} -func (*QueryRegisteredQueryRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_5913889f6e620de0, []int{4} -} -func (m *QueryRegisteredQueryRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryRegisteredQueryRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryRegisteredQueryRequest.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 *QueryRegisteredQueryRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryRegisteredQueryRequest.Merge(m, src) -} -func (m *QueryRegisteredQueryRequest) XXX_Size() int { - return m.Size() -} -func (m *QueryRegisteredQueryRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryRegisteredQueryRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryRegisteredQueryRequest proto.InternalMessageInfo - -func (m *QueryRegisteredQueryRequest) GetQueryId() uint64 { - if m != nil { - return m.QueryId - } - return 0 -} - -// QueryRegisteredQueryResponse is response type for the Query/RegisteredQuery RPC method. -type QueryRegisteredQueryResponse struct { - RegisteredQuery *RegisteredQuery `protobuf:"bytes,1,opt,name=registered_query,json=registeredQuery,proto3" json:"registered_query,omitempty"` -} - -func (m *QueryRegisteredQueryResponse) Reset() { *m = QueryRegisteredQueryResponse{} } -func (m *QueryRegisteredQueryResponse) String() string { return proto.CompactTextString(m) } -func (*QueryRegisteredQueryResponse) ProtoMessage() {} -func (*QueryRegisteredQueryResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_5913889f6e620de0, []int{5} -} -func (m *QueryRegisteredQueryResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryRegisteredQueryResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryRegisteredQueryResponse.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 *QueryRegisteredQueryResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryRegisteredQueryResponse.Merge(m, src) -} -func (m *QueryRegisteredQueryResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryRegisteredQueryResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryRegisteredQueryResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryRegisteredQueryResponse proto.InternalMessageInfo - -func (m *QueryRegisteredQueryResponse) GetRegisteredQuery() *RegisteredQuery { - if m != nil { - return m.RegisteredQuery - } - return nil -} - -// QueryRegisteredQueryResultRequest is request type for the Query/QueryResult RPC method. -type QueryRegisteredQueryResultRequest struct { - QueryId uint64 `protobuf:"varint,1,opt,name=query_id,json=queryId,proto3" json:"query_id,omitempty"` -} - -func (m *QueryRegisteredQueryResultRequest) Reset() { *m = QueryRegisteredQueryResultRequest{} } -func (m *QueryRegisteredQueryResultRequest) String() string { return proto.CompactTextString(m) } -func (*QueryRegisteredQueryResultRequest) ProtoMessage() {} -func (*QueryRegisteredQueryResultRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_5913889f6e620de0, []int{6} -} -func (m *QueryRegisteredQueryResultRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryRegisteredQueryResultRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryRegisteredQueryResultRequest.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 *QueryRegisteredQueryResultRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryRegisteredQueryResultRequest.Merge(m, src) -} -func (m *QueryRegisteredQueryResultRequest) XXX_Size() int { - return m.Size() -} -func (m *QueryRegisteredQueryResultRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryRegisteredQueryResultRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryRegisteredQueryResultRequest proto.InternalMessageInfo - -func (m *QueryRegisteredQueryResultRequest) GetQueryId() uint64 { - if m != nil { - return m.QueryId - } - return 0 -} - -// QueryResultResponse is response type for the Query/QueryResult RPC method. -type QueryResultResponse struct { - Result *QueryResult `protobuf:"bytes,1,opt,name=result,proto3" json:"result,omitempty"` -} - -func (m *QueryResultResponse) Reset() { *m = QueryResultResponse{} } -func (m *QueryResultResponse) String() string { return proto.CompactTextString(m) } -func (*QueryResultResponse) ProtoMessage() {} -func (*QueryResultResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_5913889f6e620de0, []int{7} -} -func (m *QueryResultResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryResultResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryResultResponse.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 *QueryResultResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryResultResponse.Merge(m, src) -} -func (m *QueryResultResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryResultResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryResultResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryResultResponse proto.InternalMessageInfo - -func (m *QueryResultResponse) GetResult() *QueryResult { - if m != nil { - return m.Result - } - return nil -} - -// Transaction defines a transaction message for the interchainqueries module. -type Transaction struct { - Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - Height uint64 `protobuf:"varint,2,opt,name=height,proto3" json:"height,omitempty"` - Data []byte `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` -} - -func (m *Transaction) Reset() { *m = Transaction{} } -func (m *Transaction) String() string { return proto.CompactTextString(m) } -func (*Transaction) ProtoMessage() {} -func (*Transaction) Descriptor() ([]byte, []int) { - return fileDescriptor_5913889f6e620de0, []int{8} -} -func (m *Transaction) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Transaction) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Transaction.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 *Transaction) XXX_Merge(src proto.Message) { - xxx_messageInfo_Transaction.Merge(m, src) -} -func (m *Transaction) XXX_Size() int { - return m.Size() -} -func (m *Transaction) XXX_DiscardUnknown() { - xxx_messageInfo_Transaction.DiscardUnknown(m) -} - -var xxx_messageInfo_Transaction proto.InternalMessageInfo - -func (m *Transaction) GetId() uint64 { - if m != nil { - return m.Id - } - return 0 -} - -func (m *Transaction) GetHeight() uint64 { - if m != nil { - return m.Height - } - return 0 -} - -func (m *Transaction) GetData() []byte { - if m != nil { - return m.Data - } - return nil -} - -// QueryLastRemoteHeight is request type for the Query/LastRemoteHeight RPC method. -type QueryLastRemoteHeight struct { - ConnectionId string `protobuf:"bytes,1,opt,name=connection_id,json=connectionId,proto3" json:"connection_id,omitempty"` -} - -func (m *QueryLastRemoteHeight) Reset() { *m = QueryLastRemoteHeight{} } -func (m *QueryLastRemoteHeight) String() string { return proto.CompactTextString(m) } -func (*QueryLastRemoteHeight) ProtoMessage() {} -func (*QueryLastRemoteHeight) Descriptor() ([]byte, []int) { - return fileDescriptor_5913889f6e620de0, []int{9} -} -func (m *QueryLastRemoteHeight) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryLastRemoteHeight) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryLastRemoteHeight.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 *QueryLastRemoteHeight) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryLastRemoteHeight.Merge(m, src) -} -func (m *QueryLastRemoteHeight) XXX_Size() int { - return m.Size() -} -func (m *QueryLastRemoteHeight) XXX_DiscardUnknown() { - xxx_messageInfo_QueryLastRemoteHeight.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryLastRemoteHeight proto.InternalMessageInfo - -func (m *QueryLastRemoteHeight) GetConnectionId() string { - if m != nil { - return m.ConnectionId - } - return "" -} - -// QueryLastRemoteHeightResponse is response type for the Query/LastRemoteHeight RPC method. -type QueryLastRemoteHeightResponse struct { - Height uint64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"` -} - -func (m *QueryLastRemoteHeightResponse) Reset() { *m = QueryLastRemoteHeightResponse{} } -func (m *QueryLastRemoteHeightResponse) String() string { return proto.CompactTextString(m) } -func (*QueryLastRemoteHeightResponse) ProtoMessage() {} -func (*QueryLastRemoteHeightResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_5913889f6e620de0, []int{10} -} -func (m *QueryLastRemoteHeightResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryLastRemoteHeightResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryLastRemoteHeightResponse.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 *QueryLastRemoteHeightResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryLastRemoteHeightResponse.Merge(m, src) -} -func (m *QueryLastRemoteHeightResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryLastRemoteHeightResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryLastRemoteHeightResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryLastRemoteHeightResponse proto.InternalMessageInfo - -func (m *QueryLastRemoteHeightResponse) GetHeight() uint64 { - if m != nil { - return m.Height - } - return 0 -} - -func init() { - proto.RegisterType((*QueryParamsRequest)(nil), "nolus.interchainqueries.QueryParamsRequest") - proto.RegisterType((*QueryParamsResponse)(nil), "nolus.interchainqueries.QueryParamsResponse") - proto.RegisterType((*QueryRegisteredQueriesRequest)(nil), "nolus.interchainqueries.QueryRegisteredQueriesRequest") - proto.RegisterType((*QueryRegisteredQueriesResponse)(nil), "nolus.interchainqueries.QueryRegisteredQueriesResponse") - proto.RegisterType((*QueryRegisteredQueryRequest)(nil), "nolus.interchainqueries.QueryRegisteredQueryRequest") - proto.RegisterType((*QueryRegisteredQueryResponse)(nil), "nolus.interchainqueries.QueryRegisteredQueryResponse") - proto.RegisterType((*QueryRegisteredQueryResultRequest)(nil), "nolus.interchainqueries.QueryRegisteredQueryResultRequest") - proto.RegisterType((*QueryResultResponse)(nil), "nolus.interchainqueries.QueryResultResponse") - proto.RegisterType((*Transaction)(nil), "nolus.interchainqueries.Transaction") - proto.RegisterType((*QueryLastRemoteHeight)(nil), "nolus.interchainqueries.QueryLastRemoteHeight") - proto.RegisterType((*QueryLastRemoteHeightResponse)(nil), "nolus.interchainqueries.QueryLastRemoteHeightResponse") -} - -func init() { - proto.RegisterFile("nolus/interchainqueries/query.proto", fileDescriptor_5913889f6e620de0) -} - -var fileDescriptor_5913889f6e620de0 = []byte{ - // 763 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x55, 0x4d, 0x4f, 0x13, 0x4d, - 0x1c, 0xef, 0x94, 0x3e, 0x7d, 0x1e, 0xa6, 0x3c, 0x02, 0x23, 0x2a, 0x56, 0x5c, 0x60, 0x79, 0xab, - 0x62, 0x77, 0x03, 0x28, 0x18, 0x83, 0x1c, 0x38, 0xa8, 0x24, 0xc6, 0xc0, 0xc2, 0xc1, 0x98, 0x98, - 0x66, 0xba, 0x9d, 0x6c, 0x37, 0x69, 0x77, 0xca, 0xce, 0x54, 0xd9, 0xab, 0x67, 0x0f, 0x26, 0x7e, - 0x05, 0xe3, 0xc1, 0x9b, 0x47, 0xbf, 0x01, 0x47, 0x12, 0x2f, 0x1e, 0x8c, 0x31, 0xe0, 0x07, 0x31, - 0x3b, 0x33, 0x7d, 0xd9, 0xb6, 0x5b, 0xda, 0xd3, 0xce, 0xcc, 0xfe, 0x7e, 0xff, 0xff, 0xef, 0xff, - 0x36, 0x03, 0x17, 0x3c, 0x5a, 0xa9, 0x33, 0xd3, 0xf5, 0x38, 0xf1, 0xed, 0x32, 0x76, 0xbd, 0xe3, - 0x3a, 0xf1, 0x5d, 0xc2, 0xcc, 0xf0, 0x1b, 0x18, 0x35, 0x9f, 0x72, 0x8a, 0x6e, 0x08, 0x90, 0xd1, - 0x05, 0xca, 0xde, 0xb5, 0x29, 0xab, 0x52, 0x66, 0x16, 0x31, 0x23, 0x92, 0x61, 0xbe, 0x59, 0x2b, - 0x12, 0x8e, 0xd7, 0xcc, 0x1a, 0x76, 0x5c, 0x0f, 0x73, 0x97, 0x7a, 0xd2, 0x48, 0x76, 0xca, 0xa1, - 0x0e, 0x15, 0x4b, 0x33, 0x5c, 0xa9, 0xd3, 0x19, 0x87, 0x52, 0xa7, 0x42, 0x4c, 0x5c, 0x73, 0x4d, - 0xec, 0x79, 0x94, 0x0b, 0x0a, 0x53, 0x7f, 0x97, 0xe2, 0xd4, 0x39, 0xc4, 0x23, 0xcc, 0x6d, 0xc0, - 0x16, 0xe3, 0x60, 0x35, 0xec, 0xe3, 0x6a, 0x03, 0x35, 0x17, 0x87, 0xe2, 0x27, 0x12, 0xa1, 0x4f, - 0x41, 0x74, 0x10, 0x06, 0xb1, 0x2f, 0x68, 0x16, 0x39, 0xae, 0x13, 0xc6, 0xf5, 0x23, 0x78, 0x35, - 0x72, 0xca, 0x6a, 0xd4, 0x63, 0x04, 0x3d, 0x86, 0x69, 0x69, 0x7e, 0x1a, 0xcc, 0x81, 0x5c, 0x66, - 0x7d, 0xd6, 0x88, 0xc9, 0x92, 0x21, 0x89, 0xbb, 0xa9, 0xd3, 0x5f, 0xb3, 0x09, 0x4b, 0x91, 0xf4, - 0x4f, 0x00, 0xde, 0x16, 0x66, 0x2d, 0xe2, 0xb8, 0x8c, 0x13, 0x9f, 0x94, 0x0e, 0x24, 0x5e, 0xf9, - 0x45, 0xd7, 0x61, 0x9a, 0xbe, 0xf5, 0x88, 0x1f, 0x3a, 0x18, 0xc9, 0x8d, 0x5a, 0x6a, 0x87, 0x16, - 0xe0, 0xff, 0x36, 0xf5, 0x3c, 0x62, 0x87, 0x99, 0x2a, 0xb8, 0xa5, 0xe9, 0xe4, 0x1c, 0xc8, 0x8d, - 0x5a, 0x63, 0xad, 0xc3, 0xbd, 0x12, 0x7a, 0x02, 0x61, 0xab, 0x02, 0xd3, 0x23, 0x42, 0xe1, 0xb2, - 0x21, 0xcb, 0x65, 0x84, 0xe5, 0x32, 0x64, 0x81, 0x55, 0xb9, 0x8c, 0x7d, 0xec, 0x10, 0xe5, 0xd8, - 0x6a, 0x63, 0xea, 0xa7, 0x00, 0x6a, 0x71, 0x32, 0x55, 0x22, 0x5e, 0x43, 0xe4, 0x37, 0x7f, 0x16, - 0x54, 0xd0, 0x42, 0x73, 0x66, 0x3d, 0x17, 0x9b, 0x94, 0xa8, 0xbd, 0x40, 0x65, 0x67, 0xd2, 0xef, - 0x74, 0x83, 0x9e, 0x46, 0x22, 0x49, 0x8a, 0x48, 0x56, 0x2e, 0x8d, 0x44, 0x6a, 0x8b, 0x84, 0xf2, - 0x10, 0xde, 0xea, 0x11, 0x49, 0xd0, 0x48, 0xf7, 0x4d, 0xf8, 0x9f, 0x30, 0x14, 0x66, 0x34, 0xac, - 0x68, 0xca, 0xfa, 0x57, 0xec, 0xf7, 0x4a, 0x3a, 0x83, 0x33, 0xbd, 0x99, 0x2a, 0x03, 0x87, 0x70, - 0xa2, 0x23, 0x03, 0x81, 0x6a, 0x8a, 0x81, 0xe3, 0xb7, 0xc6, 0xa3, 0x91, 0x07, 0xfa, 0x0e, 0x9c, - 0x8f, 0x71, 0x5a, 0xaf, 0xf0, 0x01, 0x44, 0x1f, 0xaa, 0xb6, 0x6d, 0x10, 0x94, 0xd6, 0x6d, 0x98, - 0xf6, 0xc5, 0x89, 0x52, 0xb8, 0x18, 0xab, 0xb0, 0x9d, 0xad, 0x38, 0xfa, 0x1e, 0xcc, 0x1c, 0xf9, - 0xd8, 0x63, 0x58, 0xf4, 0x19, 0xba, 0x02, 0x93, 0x4d, 0xc7, 0x49, 0xb7, 0x14, 0xb6, 0x6c, 0x99, - 0xb8, 0x4e, 0x99, 0x8b, 0x3a, 0xa5, 0x2c, 0xb5, 0x43, 0x08, 0xa6, 0x4a, 0x98, 0x63, 0xd1, 0x87, - 0x63, 0x96, 0x58, 0xeb, 0xdb, 0xf0, 0x9a, 0xf0, 0xf0, 0x1c, 0x33, 0x6e, 0x91, 0x2a, 0xe5, 0xe4, - 0x99, 0x04, 0x77, 0xf5, 0x37, 0xe8, 0xee, 0x6f, 0x7d, 0x4b, 0x4d, 0x4f, 0x27, 0xbb, 0x19, 0x67, - 0x4b, 0x0a, 0x68, 0x97, 0xb2, 0xfe, 0x33, 0x0d, 0xff, 0x11, 0x4c, 0xf4, 0x1e, 0xc0, 0xb4, 0x1c, - 0x4d, 0xb4, 0xda, 0x3f, 0x09, 0x91, 0xfb, 0x20, 0x7b, 0x6f, 0x30, 0xb0, 0xd4, 0xa1, 0xaf, 0xbc, - 0xfb, 0xfe, 0xe7, 0x63, 0x72, 0x1e, 0xcd, 0x9a, 0xfd, 0x2f, 0x29, 0xf4, 0x0d, 0xc0, 0xc9, 0xae, - 0x21, 0x43, 0x9b, 0x97, 0x95, 0xa7, 0xf7, 0xe5, 0x91, 0xdd, 0x1a, 0x9a, 0xa7, 0xf4, 0x6e, 0x08, - 0xbd, 0x79, 0xb4, 0x1a, 0xab, 0xb7, 0x7b, 0xd8, 0xd1, 0x57, 0x00, 0xc7, 0x3b, 0xfa, 0x14, 0xdd, - 0x1f, 0x46, 0x41, 0x63, 0x0a, 0xb3, 0x0f, 0x86, 0x64, 0x29, 0xd5, 0x6b, 0x42, 0xf5, 0x2a, 0xba, - 0x33, 0xa8, 0xea, 0x00, 0x7d, 0x06, 0x30, 0xd3, 0xd6, 0xe2, 0xe8, 0xd1, 0xb0, 0x9e, 0x5b, 0x63, - 0x78, 0x59, 0x4b, 0x44, 0x47, 0x50, 0xcf, 0x0b, 0xb1, 0x2b, 0x68, 0xc9, 0xec, 0xfb, 0xf8, 0x16, - 0xe4, 0xcc, 0xa1, 0x2f, 0x00, 0x4e, 0x74, 0x0d, 0x89, 0xd1, 0xdf, 0x63, 0x27, 0x3e, 0xbb, 0x39, - 0x1c, 0xbe, 0xa9, 0xd5, 0x10, 0x5a, 0x73, 0x68, 0xb9, 0x4f, 0x62, 0x43, 0x5a, 0x41, 0x8e, 0xd7, - 0xee, 0xcb, 0xd3, 0x73, 0x0d, 0x9c, 0x9d, 0x6b, 0xe0, 0xf7, 0xb9, 0x06, 0x3e, 0x5c, 0x68, 0x89, - 0xb3, 0x0b, 0x2d, 0xf1, 0xe3, 0x42, 0x4b, 0xbc, 0xda, 0x71, 0x5c, 0x5e, 0xae, 0x17, 0x0d, 0x9b, - 0x56, 0xcd, 0x17, 0xa1, 0xad, 0xfc, 0x7e, 0xf8, 0xe8, 0xda, 0xb4, 0x22, 0x4d, 0xe7, 0x6d, 0xea, - 0x13, 0xf3, 0xa4, 0xd7, 0xfb, 0x1c, 0xd4, 0x08, 0x2b, 0xa6, 0xc5, 0x1b, 0xbd, 0xf1, 0x37, 0x00, - 0x00, 0xff, 0xff, 0x5a, 0x48, 0x6c, 0x32, 0xb2, 0x08, 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) - // RegisteredQueries queries the registered queries of the module. - RegisteredQueries(ctx context.Context, in *QueryRegisteredQueriesRequest, opts ...grpc.CallOption) (*QueryRegisteredQueriesResponse, error) - // RegisteredQuery queries the registered query of the module. - RegisteredQuery(ctx context.Context, in *QueryRegisteredQueryRequest, opts ...grpc.CallOption) (*QueryRegisteredQueryResponse, error) - // QueryResult queries the result of a registered query. - QueryResult(ctx context.Context, in *QueryRegisteredQueryResultRequest, opts ...grpc.CallOption) (*QueryResultResponse, error) - // LastRemoteHeight queries the last remote height of a connection. - LastRemoteHeight(ctx context.Context, in *QueryLastRemoteHeight, opts ...grpc.CallOption) (*QueryLastRemoteHeightResponse, 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, "/nolus.interchainqueries.Query/Params", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *queryClient) RegisteredQueries(ctx context.Context, in *QueryRegisteredQueriesRequest, opts ...grpc.CallOption) (*QueryRegisteredQueriesResponse, error) { - out := new(QueryRegisteredQueriesResponse) - err := c.cc.Invoke(ctx, "/nolus.interchainqueries.Query/RegisteredQueries", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *queryClient) RegisteredQuery(ctx context.Context, in *QueryRegisteredQueryRequest, opts ...grpc.CallOption) (*QueryRegisteredQueryResponse, error) { - out := new(QueryRegisteredQueryResponse) - err := c.cc.Invoke(ctx, "/nolus.interchainqueries.Query/RegisteredQuery", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *queryClient) QueryResult(ctx context.Context, in *QueryRegisteredQueryResultRequest, opts ...grpc.CallOption) (*QueryResultResponse, error) { - out := new(QueryResultResponse) - err := c.cc.Invoke(ctx, "/nolus.interchainqueries.Query/QueryResult", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *queryClient) LastRemoteHeight(ctx context.Context, in *QueryLastRemoteHeight, opts ...grpc.CallOption) (*QueryLastRemoteHeightResponse, error) { - out := new(QueryLastRemoteHeightResponse) - err := c.cc.Invoke(ctx, "/nolus.interchainqueries.Query/LastRemoteHeight", 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) - // RegisteredQueries queries the registered queries of the module. - RegisteredQueries(context.Context, *QueryRegisteredQueriesRequest) (*QueryRegisteredQueriesResponse, error) - // RegisteredQuery queries the registered query of the module. - RegisteredQuery(context.Context, *QueryRegisteredQueryRequest) (*QueryRegisteredQueryResponse, error) - // QueryResult queries the result of a registered query. - QueryResult(context.Context, *QueryRegisteredQueryResultRequest) (*QueryResultResponse, error) - // LastRemoteHeight queries the last remote height of a connection. - LastRemoteHeight(context.Context, *QueryLastRemoteHeight) (*QueryLastRemoteHeightResponse, 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) RegisteredQueries(ctx context.Context, req *QueryRegisteredQueriesRequest) (*QueryRegisteredQueriesResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method RegisteredQueries not implemented") -} -func (*UnimplementedQueryServer) RegisteredQuery(ctx context.Context, req *QueryRegisteredQueryRequest) (*QueryRegisteredQueryResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method RegisteredQuery not implemented") -} -func (*UnimplementedQueryServer) QueryResult(ctx context.Context, req *QueryRegisteredQueryResultRequest) (*QueryResultResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method QueryResult not implemented") -} -func (*UnimplementedQueryServer) LastRemoteHeight(ctx context.Context, req *QueryLastRemoteHeight) (*QueryLastRemoteHeightResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method LastRemoteHeight 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: "/nolus.interchainqueries.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_RegisteredQueries_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryRegisteredQueriesRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).RegisteredQueries(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/nolus.interchainqueries.Query/RegisteredQueries", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).RegisteredQueries(ctx, req.(*QueryRegisteredQueriesRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Query_RegisteredQuery_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryRegisteredQueryRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).RegisteredQuery(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/nolus.interchainqueries.Query/RegisteredQuery", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).RegisteredQuery(ctx, req.(*QueryRegisteredQueryRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Query_QueryResult_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryRegisteredQueryResultRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).QueryResult(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/nolus.interchainqueries.Query/QueryResult", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).QueryResult(ctx, req.(*QueryRegisteredQueryResultRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Query_LastRemoteHeight_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryLastRemoteHeight) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).LastRemoteHeight(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/nolus.interchainqueries.Query/LastRemoteHeight", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).LastRemoteHeight(ctx, req.(*QueryLastRemoteHeight)) - } - return interceptor(ctx, in, info, handler) -} - -var _Query_serviceDesc = grpc.ServiceDesc{ - ServiceName: "nolus.interchainqueries.Query", - HandlerType: (*QueryServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Params", - Handler: _Query_Params_Handler, - }, - { - MethodName: "RegisteredQueries", - Handler: _Query_RegisteredQueries_Handler, - }, - { - MethodName: "RegisteredQuery", - Handler: _Query_RegisteredQuery_Handler, - }, - { - MethodName: "QueryResult", - Handler: _Query_QueryResult_Handler, - }, - { - MethodName: "LastRemoteHeight", - Handler: _Query_LastRemoteHeight_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "nolus/interchainqueries/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 *QueryRegisteredQueriesRequest) 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 *QueryRegisteredQueriesRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryRegisteredQueriesRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Pagination != nil { - { - size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - } - 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] = 0x12 - } - if len(m.Owners) > 0 { - for iNdEx := len(m.Owners) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.Owners[iNdEx]) - copy(dAtA[i:], m.Owners[iNdEx]) - i = encodeVarintQuery(dAtA, i, uint64(len(m.Owners[iNdEx]))) - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *QueryRegisteredQueriesResponse) 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 *QueryRegisteredQueriesResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryRegisteredQueriesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Pagination != nil { - { - size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - if len(m.RegisteredQueries) > 0 { - for iNdEx := len(m.RegisteredQueries) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.RegisteredQueries[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *QueryRegisteredQueryRequest) 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 *QueryRegisteredQueryRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryRegisteredQueryRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.QueryId != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.QueryId)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *QueryRegisteredQueryResponse) 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 *QueryRegisteredQueryResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryRegisteredQueryResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.RegisteredQuery != nil { - { - size, err := m.RegisteredQuery.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 *QueryRegisteredQueryResultRequest) 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 *QueryRegisteredQueryResultRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryRegisteredQueryResultRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.QueryId != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.QueryId)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *QueryResultResponse) 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 *QueryResultResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryResultResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Result != nil { - { - size, err := m.Result.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 *Transaction) 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 *Transaction) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Transaction) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Data) > 0 { - i -= len(m.Data) - copy(dAtA[i:], m.Data) - i = encodeVarintQuery(dAtA, i, uint64(len(m.Data))) - i-- - dAtA[i] = 0x1a - } - if m.Height != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.Height)) - i-- - dAtA[i] = 0x10 - } - if m.Id != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.Id)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *QueryLastRemoteHeight) 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 *QueryLastRemoteHeight) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryLastRemoteHeight) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - 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 *QueryLastRemoteHeightResponse) 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 *QueryLastRemoteHeightResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryLastRemoteHeightResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Height != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.Height)) - i-- - dAtA[i] = 0x8 - } - 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 *QueryRegisteredQueriesRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.Owners) > 0 { - for _, s := range m.Owners { - l = len(s) - n += 1 + l + sovQuery(uint64(l)) - } - } - l = len(m.ConnectionId) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *QueryRegisteredQueriesResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.RegisteredQueries) > 0 { - for _, e := range m.RegisteredQueries { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) - } - } - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *QueryRegisteredQueryRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.QueryId != 0 { - n += 1 + sovQuery(uint64(m.QueryId)) - } - return n -} - -func (m *QueryRegisteredQueryResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.RegisteredQuery != nil { - l = m.RegisteredQuery.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *QueryRegisteredQueryResultRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.QueryId != 0 { - n += 1 + sovQuery(uint64(m.QueryId)) - } - return n -} - -func (m *QueryResultResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Result != nil { - l = m.Result.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *Transaction) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Id != 0 { - n += 1 + sovQuery(uint64(m.Id)) - } - if m.Height != 0 { - n += 1 + sovQuery(uint64(m.Height)) - } - l = len(m.Data) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *QueryLastRemoteHeight) 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)) - } - return n -} - -func (m *QueryLastRemoteHeightResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Height != 0 { - n += 1 + sovQuery(uint64(m.Height)) - } - 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 *QueryRegisteredQueriesRequest) 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: QueryRegisteredQueriesRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryRegisteredQueriesRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Owners", 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.Owners = append(m.Owners, 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 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 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Pagination == nil { - m.Pagination = &query.PageRequest{} - } - if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryRegisteredQueriesResponse) 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: QueryRegisteredQueriesResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryRegisteredQueriesResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RegisteredQueries", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.RegisteredQueries = append(m.RegisteredQueries, RegisteredQuery{}) - if err := m.RegisteredQueries[len(m.RegisteredQueries)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Pagination == nil { - m.Pagination = &query.PageResponse{} - } - if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryRegisteredQueryRequest) 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: QueryRegisteredQueryRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryRegisteredQueryRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field QueryId", wireType) - } - m.QueryId = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.QueryId |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - 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 *QueryRegisteredQueryResponse) 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: QueryRegisteredQueryResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryRegisteredQueryResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RegisteredQuery", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.RegisteredQuery == nil { - m.RegisteredQuery = &RegisteredQuery{} - } - if err := m.RegisteredQuery.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 *QueryRegisteredQueryResultRequest) 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: QueryRegisteredQueryResultRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryRegisteredQueryResultRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field QueryId", wireType) - } - m.QueryId = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.QueryId |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - 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 *QueryResultResponse) 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: QueryResultResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryResultResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Result", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Result == nil { - m.Result = &QueryResult{} - } - if err := m.Result.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 *Transaction) 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: Transaction: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Transaction: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) - } - m.Id = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Id |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) - } - m.Height = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Height |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Data = append(m.Data[:0], dAtA[iNdEx:postIndex]...) - if m.Data == nil { - m.Data = []byte{} - } - 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 *QueryLastRemoteHeight) 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: QueryLastRemoteHeight: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryLastRemoteHeight: 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 - 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 *QueryLastRemoteHeightResponse) 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: QueryLastRemoteHeightResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryLastRemoteHeightResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) - } - m.Height = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Height |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - 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/interchainqueries/types/query.pb.gw.go b/x/interchainqueries/types/query.pb.gw.go deleted file mode 100644 index d2164ff8..00000000 --- a/x/interchainqueries/types/query.pb.gw.go +++ /dev/null @@ -1,485 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: nolus/interchainqueries/query.proto - -/* -Package types is a reverse proxy. - -It translates gRPC into RESTful JSON APIs. -*/ -package types - -import ( - "context" - "io" - "net/http" - - "github.com/golang/protobuf/descriptor" - "github.com/golang/protobuf/proto" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/grpc-ecosystem/grpc-gateway/utilities" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/status" -) - -// Suppress "imported and not used" errors -var _ codes.Code -var _ io.Reader -var _ status.Status -var _ = runtime.String -var _ = utilities.NewDoubleArray -var _ = descriptor.ForMessage -var _ = metadata.Join - -func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryParamsRequest - var metadata runtime.ServerMetadata - - msg, err := client.Params(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryParamsRequest - var metadata runtime.ServerMetadata - - msg, err := server.Params(ctx, &protoReq) - return msg, metadata, err - -} - -var ( - filter_Query_RegisteredQueries_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - -func request_Query_RegisteredQueries_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryRegisteredQueriesRequest - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_RegisteredQueries_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.RegisteredQueries(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_RegisteredQueries_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryRegisteredQueriesRequest - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_RegisteredQueries_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.RegisteredQueries(ctx, &protoReq) - return msg, metadata, err - -} - -var ( - filter_Query_RegisteredQuery_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - -func request_Query_RegisteredQuery_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryRegisteredQueryRequest - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_RegisteredQuery_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.RegisteredQuery(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_RegisteredQuery_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryRegisteredQueryRequest - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_RegisteredQuery_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.RegisteredQuery(ctx, &protoReq) - return msg, metadata, err - -} - -var ( - filter_Query_QueryResult_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - -func request_Query_QueryResult_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryRegisteredQueryResultRequest - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_QueryResult_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.QueryResult(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_QueryResult_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryRegisteredQueryResultRequest - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_QueryResult_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.QueryResult(ctx, &protoReq) - return msg, metadata, err - -} - -var ( - filter_Query_LastRemoteHeight_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - -func request_Query_LastRemoteHeight_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryLastRemoteHeight - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_LastRemoteHeight_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.LastRemoteHeight(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_LastRemoteHeight_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryLastRemoteHeight - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_LastRemoteHeight_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.LastRemoteHeight(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_RegisteredQueries_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_RegisteredQueries_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_RegisteredQueries_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_RegisteredQuery_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_RegisteredQuery_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_RegisteredQuery_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_QueryResult_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_QueryResult_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_QueryResult_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_LastRemoteHeight_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_LastRemoteHeight_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_LastRemoteHeight_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_RegisteredQueries_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_RegisteredQueries_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_RegisteredQueries_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_RegisteredQuery_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_RegisteredQuery_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_RegisteredQuery_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_QueryResult_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_QueryResult_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_QueryResult_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_LastRemoteHeight_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_LastRemoteHeight_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_LastRemoteHeight_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}, []string{"nolus", "interchainqueries", "params"}, "", runtime.AssumeColonVerbOpt(false))) - - pattern_Query_RegisteredQueries_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"nolus", "interchainqueries", "registered_queries"}, "", runtime.AssumeColonVerbOpt(false))) - - pattern_Query_RegisteredQuery_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"nolus", "interchainqueries", "registered_query"}, "", runtime.AssumeColonVerbOpt(false))) - - pattern_Query_QueryResult_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"nolus", "interchainqueries", "query_result"}, "", runtime.AssumeColonVerbOpt(false))) - - pattern_Query_LastRemoteHeight_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"nolus", "interchainqueries", "remote_height"}, "", runtime.AssumeColonVerbOpt(false))) -) - -var ( - forward_Query_Params_0 = runtime.ForwardResponseMessage - - forward_Query_RegisteredQueries_0 = runtime.ForwardResponseMessage - - forward_Query_RegisteredQuery_0 = runtime.ForwardResponseMessage - - forward_Query_QueryResult_0 = runtime.ForwardResponseMessage - - forward_Query_LastRemoteHeight_0 = runtime.ForwardResponseMessage -) diff --git a/x/interchainqueries/types/registered_query.go b/x/interchainqueries/types/registered_query.go deleted file mode 100644 index 1667b6db..00000000 --- a/x/interchainqueries/types/registered_query.go +++ /dev/null @@ -1,38 +0,0 @@ -package types - -import ( - "fmt" - - "cosmossdk.io/errors" - - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" -) - -func (q *RegisteredQuery) GetOwnerAddress() (creator sdk.AccAddress, err error) { - creator, err = sdk.AccAddressFromBech32(q.Owner) - if err != nil { - return nil, errors.Wrapf(sdkerrors.ErrInvalidAddress, "failed to decode owner address: %s", q.Owner) - } - - return creator, nil -} - -// ValidateRemoval checks whether the caller is authorized to remove the query in current -// circumstances. Valid cases are: -// 1. owner removes query at any time; -// 2. anyone removes query if there's been q.SubmitTimeout blocks since last result submission -// height and query registration height. -func (q *RegisteredQuery) ValidateRemoval(ctx sdk.Context, caller string) error { - if q.GetOwner() == caller { - return nil // query owner is authorized to remove their queries at any time - } - - registrationTimeoutBlock := q.RegisteredAtHeight + q.SubmitTimeout - submitTimeoutBlock := q.LastSubmittedResultLocalHeight + q.SubmitTimeout - currentBlock := uint64(ctx.BlockHeader().Height) - if currentBlock <= registrationTimeoutBlock || currentBlock <= submitTimeoutBlock { - return fmt.Errorf("only owner can remove a query within its service period") - } - return nil -} diff --git a/x/interchainqueries/types/tx.go b/x/interchainqueries/types/tx.go deleted file mode 100644 index 32740177..00000000 --- a/x/interchainqueries/types/tx.go +++ /dev/null @@ -1,260 +0,0 @@ -package types - -import ( - "strings" - - "cosmossdk.io/errors" - "github.com/cosmos/ibc-go/v8/modules/core/exported" - - codectypes "github.com/cosmos/cosmos-sdk/codec/types" - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" -) - -const ( - MaxKVQueryKeysCount = 32 -) - -var ( - _ sdk.Msg = &MsgSubmitQueryResult{} - _ codectypes.UnpackInterfacesMessage = MsgSubmitQueryResult{} -) - -func (msg MsgSubmitQueryResult) Route() string { - return RouterKey -} - -func (msg MsgSubmitQueryResult) Type() string { - return "submit-query-result" -} - -func (msg MsgSubmitQueryResult) Validate() error { - if msg.Result == nil { - return errors.Wrap(ErrEmptyResult, "query result can't be empty") - } - - if len(msg.Result.KvResults) == 0 && msg.Result.Block == nil { - return errors.Wrap(ErrEmptyResult, "query result can't be empty") - } - - if msg.QueryId == 0 { - return errors.Wrap(ErrInvalidQueryID, "query id cannot be equal zero") - } - - if strings.TrimSpace(msg.Sender) == "" { - return errors.Wrap(sdkerrors.ErrInvalidAddress, "missing sender address") - } - - if _, err := sdk.AccAddressFromBech32(msg.Sender); err != nil { - return errors.Wrapf(sdkerrors.ErrInvalidAddress, "failed to parse address: %s", msg.Sender) - } - - if strings.TrimSpace(msg.ClientId) == "" { - return errors.Wrap(ErrInvalidClientID, "client id cannot be empty") - } - - return nil -} - -func (msg MsgSubmitQueryResult) GetSignBytes() []byte { - return ModuleCdc.MustMarshalJSON(&msg) -} - -func (msg MsgSubmitQueryResult) GetSigners() []sdk.AccAddress { - senderAddr, err := sdk.AccAddressFromBech32(msg.Sender) - if err != nil { // should never happen as valid basic rejects invalid addresses - panic(err.Error()) - } - return []sdk.AccAddress{senderAddr} -} - -// UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces. -func (msg MsgSubmitQueryResult) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { - var header exported.ClientMessage - if err := unpacker.UnpackAny(msg.Result.GetBlock().GetHeader(), &header); err != nil { - return err - } - - return unpacker.UnpackAny(msg.Result.GetBlock().GetNextBlockHeader(), &header) -} - -//---------------------------------------------------------------- - -var _ sdk.Msg = &MsgRegisterInterchainQuery{} - -func (msg MsgRegisterInterchainQuery) Route() string { - return RouterKey -} - -func (msg MsgRegisterInterchainQuery) Type() string { - return "register-interchain-query" -} - -func (msg MsgRegisterInterchainQuery) Validate() error { - if msg.UpdatePeriod == 0 { - return errors.Wrap(ErrInvalidUpdatePeriod, "update period can not be equal to zero") - } - - if strings.TrimSpace(msg.Sender) == "" { - return errors.Wrap(sdkerrors.ErrInvalidAddress, "missing sender address") - } - - if _, err := sdk.AccAddressFromBech32(msg.Sender); err != nil { - return errors.Wrapf(sdkerrors.ErrInvalidAddress, "failed to parse address: %s", msg.Sender) - } - - if strings.TrimSpace(msg.ConnectionId) == "" { - return errors.Wrap(ErrInvalidConnectionID, "connection id cannot be empty") - } - - if !InterchainQueryType(msg.QueryType).IsValid() { - return errors.Wrap(ErrInvalidQueryType, "invalid query type") - } - - if InterchainQueryType(msg.QueryType).IsKV() { - if len(msg.Keys) == 0 { - return errors.Wrap(ErrEmptyKeys, "keys cannot be empty") - } - if err := validateKeys(msg.GetKeys()); err != nil { - return err - } - } - - if InterchainQueryType(msg.QueryType).IsTX() { - if err := ValidateTransactionsFilter(msg.TransactionsFilter); err != nil { - return errors.Wrap(ErrInvalidTransactionsFilter, err.Error()) - } - } - return nil -} - -func (msg MsgRegisterInterchainQuery) GetSignBytes() []byte { - return ModuleCdc.MustMarshalJSON(&msg) -} - -func (msg MsgRegisterInterchainQuery) GetSigners() []sdk.AccAddress { - senderAddr, err := sdk.AccAddressFromBech32(msg.Sender) - if err != nil { // should never happen as valid basic rejects invalid addresses - panic(err.Error()) - } - return []sdk.AccAddress{senderAddr} -} - -//---------------------------------------------------------------- - -var _ sdk.Msg = &MsgUpdateInterchainQueryRequest{} - -func (msg MsgUpdateInterchainQueryRequest) Validate() error { - if msg.GetQueryId() == 0 { - return errors.Wrap(ErrInvalidQueryID, "query_id cannot be empty or equal to 0") - } - - newKeys := msg.GetNewKeys() - newTxFilter := msg.GetNewTransactionsFilter() - - if len(newKeys) == 0 && newTxFilter == "" && msg.GetNewUpdatePeriod() == 0 { - return errors.Wrap( - sdkerrors.ErrInvalidRequest, - "one of new_keys, new_transactions_filter or new_update_period should be set", - ) - } - - if len(newKeys) != 0 && newTxFilter != "" { - return errors.Wrap( - sdkerrors.ErrInvalidRequest, - "either new_keys or new_transactions_filter should be set", - ) - } - - if len(newKeys) != 0 { - if err := validateKeys(newKeys); err != nil { - return err - } - } - - if newTxFilter != "" { - if err := ValidateTransactionsFilter(newTxFilter); err != nil { - return errors.Wrap(ErrInvalidTransactionsFilter, err.Error()) - } - } - - if strings.TrimSpace(msg.Sender) == "" { - return errors.Wrap(sdkerrors.ErrInvalidAddress, "missing sender address") - } - if _, err := sdk.AccAddressFromBech32(msg.Sender); err != nil { - return errors.Wrapf(sdkerrors.ErrInvalidAddress, "failed to parse address: %s", msg.Sender) - } - return nil -} - -func (msg MsgUpdateInterchainQueryRequest) GetSignBytes() []byte { - return ModuleCdc.MustMarshalJSON(&msg) -} - -func (msg MsgUpdateInterchainQueryRequest) GetSigners() []sdk.AccAddress { - senderAddr, err := sdk.AccAddressFromBech32(msg.Sender) - if err != nil { // should never happen as valid basic rejects invalid addresses - panic(err.Error()) - } - return []sdk.AccAddress{senderAddr} -} - -//---------------------------------------------------------------- - -var _ sdk.Msg = &MsgUpdateParams{} - -func (msg *MsgUpdateParams) Route() string { - return RouterKey -} - -func (msg *MsgUpdateParams) Type() string { - return "update-params" -} - -func (msg *MsgUpdateParams) GetSigners() []sdk.AccAddress { - authority, err := sdk.AccAddressFromBech32(msg.Authority) - if err != nil { // should never happen as valid basic rejects invalid addresses - panic(err.Error()) - } - return []sdk.AccAddress{authority} -} - -func (msg *MsgUpdateParams) GetSignBytes() []byte { - return ModuleCdc.MustMarshalJSON(msg) -} - -func (msg *MsgUpdateParams) Validate() error { - if _, err := sdk.AccAddressFromBech32(msg.Authority); err != nil { - return errors.Wrap(err, "authority is invalid") - } - return nil -} - -func validateKeys(keys []*KVKey) error { - if uint64(len(keys)) > MaxKVQueryKeysCount { - return errors.Wrapf(ErrTooManyKVQueryKeys, "keys count cannot be more than %d", MaxKVQueryKeysCount) - } - - duplicates := make(map[string]struct{}) - for _, key := range keys { - if key == nil { - return errors.Wrap(sdkerrors.ErrInvalidType, "key cannot be nil") - } - - if _, ok := duplicates[key.ToString()]; ok { - return errors.Wrap(sdkerrors.ErrInvalidRequest, "keys cannot be duplicated") - } - - if len(key.Path) == 0 { - return errors.Wrap(ErrEmptyKeyPath, "keys path cannot be empty") - } - - if len(key.Key) == 0 { - return errors.Wrap(ErrEmptyKeyID, "keys id cannot be empty") - } - - duplicates[key.ToString()] = struct{}{} - } - - return nil -} diff --git a/x/interchainqueries/types/tx.pb.go b/x/interchainqueries/types/tx.pb.go deleted file mode 100644 index 34b999c0..00000000 --- a/x/interchainqueries/types/tx.pb.go +++ /dev/null @@ -1,3986 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: nolus/interchainqueries/tx.proto - -package types - -import ( - context "context" - fmt "fmt" - types1 "github.com/cometbft/cometbft/abci/types" - crypto "github.com/cometbft/cometbft/proto/tendermint/crypto" - _ "github.com/cosmos/cosmos-proto" - types "github.com/cosmos/cosmos-sdk/codec/types" - _ "github.com/cosmos/cosmos-sdk/types/msgservice" - _ "github.com/cosmos/cosmos-sdk/types/tx/amino" - _ "github.com/cosmos/gogoproto/gogoproto" - grpc1 "github.com/cosmos/gogoproto/grpc" - proto "github.com/cosmos/gogoproto/proto" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" - io "io" - math "math" - math_bits "math/bits" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -// MsgRegisterInterchainQuery is the MsgRegisterInterchainQuery request type. -type MsgRegisterInterchainQuery struct { - // defines a query type: `kv` or `tx` now - QueryType string `protobuf:"bytes,1,opt,name=query_type,json=queryType,proto3" json:"query_type,omitempty"` - // is used to define KV-storage keys for which we want to get values from - // remote chain - Keys []*KVKey `protobuf:"bytes,2,rep,name=keys,proto3" json:"keys,omitempty"` - // is used to define a filter for transaction search ICQ - TransactionsFilter string `protobuf:"bytes,3,opt,name=transactions_filter,json=transactionsFilter,proto3" json:"transactions_filter,omitempty"` - // is IBC connection ID for getting ConsensusState to verify proofs - ConnectionId string `protobuf:"bytes,4,opt,name=connection_id,json=connectionId,proto3" json:"connection_id,omitempty"` - // is used to specify how often (in nolus blocks) the query must be updated - UpdatePeriod uint64 `protobuf:"varint,5,opt,name=update_period,json=updatePeriod,proto3" json:"update_period,omitempty"` - // is the signer of the message - Sender string `protobuf:"bytes,6,opt,name=sender,proto3" json:"sender,omitempty"` -} - -func (m *MsgRegisterInterchainQuery) Reset() { *m = MsgRegisterInterchainQuery{} } -func (m *MsgRegisterInterchainQuery) String() string { return proto.CompactTextString(m) } -func (*MsgRegisterInterchainQuery) ProtoMessage() {} -func (*MsgRegisterInterchainQuery) Descriptor() ([]byte, []int) { - return fileDescriptor_c0ec4c1e96ae4947, []int{0} -} -func (m *MsgRegisterInterchainQuery) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgRegisterInterchainQuery) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgRegisterInterchainQuery.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 *MsgRegisterInterchainQuery) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgRegisterInterchainQuery.Merge(m, src) -} -func (m *MsgRegisterInterchainQuery) XXX_Size() int { - return m.Size() -} -func (m *MsgRegisterInterchainQuery) XXX_DiscardUnknown() { - xxx_messageInfo_MsgRegisterInterchainQuery.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgRegisterInterchainQuery proto.InternalMessageInfo - -func (m *MsgRegisterInterchainQuery) GetQueryType() string { - if m != nil { - return m.QueryType - } - return "" -} - -func (m *MsgRegisterInterchainQuery) GetKeys() []*KVKey { - if m != nil { - return m.Keys - } - return nil -} - -func (m *MsgRegisterInterchainQuery) GetTransactionsFilter() string { - if m != nil { - return m.TransactionsFilter - } - return "" -} - -func (m *MsgRegisterInterchainQuery) GetConnectionId() string { - if m != nil { - return m.ConnectionId - } - return "" -} - -func (m *MsgRegisterInterchainQuery) GetUpdatePeriod() uint64 { - if m != nil { - return m.UpdatePeriod - } - return 0 -} - -func (m *MsgRegisterInterchainQuery) GetSender() string { - if m != nil { - return m.Sender - } - return "" -} - -// MsgRegisterInterchainQueryResponse is the MsgRegisterInterchainQuery response type. -type MsgRegisterInterchainQueryResponse struct { - Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` -} - -func (m *MsgRegisterInterchainQueryResponse) Reset() { *m = MsgRegisterInterchainQueryResponse{} } -func (m *MsgRegisterInterchainQueryResponse) String() string { return proto.CompactTextString(m) } -func (*MsgRegisterInterchainQueryResponse) ProtoMessage() {} -func (*MsgRegisterInterchainQueryResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_c0ec4c1e96ae4947, []int{1} -} -func (m *MsgRegisterInterchainQueryResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgRegisterInterchainQueryResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgRegisterInterchainQueryResponse.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 *MsgRegisterInterchainQueryResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgRegisterInterchainQueryResponse.Merge(m, src) -} -func (m *MsgRegisterInterchainQueryResponse) XXX_Size() int { - return m.Size() -} -func (m *MsgRegisterInterchainQueryResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgRegisterInterchainQueryResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgRegisterInterchainQueryResponse proto.InternalMessageInfo - -func (m *MsgRegisterInterchainQueryResponse) GetId() uint64 { - if m != nil { - return m.Id - } - return 0 -} - -// MsgSubmitQueryResult is the MsgSubmitQueryResult request type. -type MsgSubmitQueryResult struct { - QueryId uint64 `protobuf:"varint,1,opt,name=query_id,json=queryId,proto3" json:"query_id,omitempty"` - Sender string `protobuf:"bytes,2,opt,name=sender,proto3" json:"sender,omitempty"` - // is the IBC client ID for an IBC connection between nolus chain and target - // chain (where the result was obtained from) - ClientId string `protobuf:"bytes,3,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` - Result *QueryResult `protobuf:"bytes,4,opt,name=result,proto3" json:"result,omitempty"` -} - -func (m *MsgSubmitQueryResult) Reset() { *m = MsgSubmitQueryResult{} } -func (m *MsgSubmitQueryResult) String() string { return proto.CompactTextString(m) } -func (*MsgSubmitQueryResult) ProtoMessage() {} -func (*MsgSubmitQueryResult) Descriptor() ([]byte, []int) { - return fileDescriptor_c0ec4c1e96ae4947, []int{2} -} -func (m *MsgSubmitQueryResult) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgSubmitQueryResult) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgSubmitQueryResult.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 *MsgSubmitQueryResult) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgSubmitQueryResult.Merge(m, src) -} -func (m *MsgSubmitQueryResult) XXX_Size() int { - return m.Size() -} -func (m *MsgSubmitQueryResult) XXX_DiscardUnknown() { - xxx_messageInfo_MsgSubmitQueryResult.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgSubmitQueryResult proto.InternalMessageInfo - -func (m *MsgSubmitQueryResult) GetQueryId() uint64 { - if m != nil { - return m.QueryId - } - return 0 -} - -func (m *MsgSubmitQueryResult) GetSender() string { - if m != nil { - return m.Sender - } - return "" -} - -func (m *MsgSubmitQueryResult) GetClientId() string { - if m != nil { - return m.ClientId - } - return "" -} - -func (m *MsgSubmitQueryResult) GetResult() *QueryResult { - if m != nil { - return m.Result - } - return nil -} - -// QueryResult is the result of an interchain query. -type QueryResult struct { - KvResults []*StorageValue `protobuf:"bytes,1,rep,name=kv_results,json=kvResults,proto3" json:"kv_results,omitempty"` - Block *Block `protobuf:"bytes,2,opt,name=block,proto3" json:"block,omitempty"` - Height uint64 `protobuf:"varint,3,opt,name=height,proto3" json:"height,omitempty"` - Revision uint64 `protobuf:"varint,4,opt,name=revision,proto3" json:"revision,omitempty"` - AllowKvCallbacks bool `protobuf:"varint,5,opt,name=allow_kv_callbacks,json=allowKvCallbacks,proto3" json:"allow_kv_callbacks,omitempty"` -} - -func (m *QueryResult) Reset() { *m = QueryResult{} } -func (m *QueryResult) String() string { return proto.CompactTextString(m) } -func (*QueryResult) ProtoMessage() {} -func (*QueryResult) Descriptor() ([]byte, []int) { - return fileDescriptor_c0ec4c1e96ae4947, []int{3} -} -func (m *QueryResult) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryResult) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryResult.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 *QueryResult) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryResult.Merge(m, src) -} -func (m *QueryResult) XXX_Size() int { - return m.Size() -} -func (m *QueryResult) XXX_DiscardUnknown() { - xxx_messageInfo_QueryResult.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryResult proto.InternalMessageInfo - -func (m *QueryResult) GetKvResults() []*StorageValue { - if m != nil { - return m.KvResults - } - return nil -} - -func (m *QueryResult) GetBlock() *Block { - if m != nil { - return m.Block - } - return nil -} - -func (m *QueryResult) GetHeight() uint64 { - if m != nil { - return m.Height - } - return 0 -} - -func (m *QueryResult) GetRevision() uint64 { - if m != nil { - return m.Revision - } - return 0 -} - -func (m *QueryResult) GetAllowKvCallbacks() bool { - if m != nil { - return m.AllowKvCallbacks - } - return false -} - -// StorageValue is the key-value pair for KVStore. -type StorageValue struct { - // is the substore name (acc, staking, etc.) - StoragePrefix string `protobuf:"bytes,1,opt,name=storage_prefix,json=storagePrefix,proto3" json:"storage_prefix,omitempty"` - // is the key in IAVL store - Key []byte `protobuf:"bytes,2,opt,name=key,proto3" json:"key,omitempty"` - // is the value in IAVL store - Value []byte `protobuf:"bytes,3,opt,name=value,proto3" json:"value,omitempty"` - // is the Merkle proof which proves existence of key-value pair in IAVL - // storage - Proof *crypto.ProofOps `protobuf:"bytes,4,opt,name=proof,proto3" json:"proof,omitempty"` -} - -func (m *StorageValue) Reset() { *m = StorageValue{} } -func (m *StorageValue) String() string { return proto.CompactTextString(m) } -func (*StorageValue) ProtoMessage() {} -func (*StorageValue) Descriptor() ([]byte, []int) { - return fileDescriptor_c0ec4c1e96ae4947, []int{4} -} -func (m *StorageValue) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *StorageValue) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_StorageValue.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 *StorageValue) XXX_Merge(src proto.Message) { - xxx_messageInfo_StorageValue.Merge(m, src) -} -func (m *StorageValue) XXX_Size() int { - return m.Size() -} -func (m *StorageValue) XXX_DiscardUnknown() { - xxx_messageInfo_StorageValue.DiscardUnknown(m) -} - -var xxx_messageInfo_StorageValue proto.InternalMessageInfo - -func (m *StorageValue) GetStoragePrefix() string { - if m != nil { - return m.StoragePrefix - } - return "" -} - -func (m *StorageValue) GetKey() []byte { - if m != nil { - return m.Key - } - return nil -} - -func (m *StorageValue) GetValue() []byte { - if m != nil { - return m.Value - } - return nil -} - -func (m *StorageValue) GetProof() *crypto.ProofOps { - if m != nil { - return m.Proof - } - return nil -} - -// Block is the block info of the chain needed for the interchainqueries module. -type Block struct { - // We need to know block X+1 to verify response of transaction for block X - // since LastResultsHash is root hash of all results from the txs from the - // previous block - NextBlockHeader *types.Any `protobuf:"bytes,1,opt,name=next_block_header,json=nextBlockHeader,proto3" json:"next_block_header,omitempty"` - // We need to know block X to verify inclusion of transaction for block X - Header *types.Any `protobuf:"bytes,2,opt,name=header,proto3" json:"header,omitempty"` - Tx *TxValue `protobuf:"bytes,3,opt,name=tx,proto3" json:"tx,omitempty"` -} - -func (m *Block) Reset() { *m = Block{} } -func (m *Block) String() string { return proto.CompactTextString(m) } -func (*Block) ProtoMessage() {} -func (*Block) Descriptor() ([]byte, []int) { - return fileDescriptor_c0ec4c1e96ae4947, []int{5} -} -func (m *Block) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Block) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Block.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 *Block) XXX_Merge(src proto.Message) { - xxx_messageInfo_Block.Merge(m, src) -} -func (m *Block) XXX_Size() int { - return m.Size() -} -func (m *Block) XXX_DiscardUnknown() { - xxx_messageInfo_Block.DiscardUnknown(m) -} - -var xxx_messageInfo_Block proto.InternalMessageInfo - -func (m *Block) GetNextBlockHeader() *types.Any { - if m != nil { - return m.NextBlockHeader - } - return nil -} - -func (m *Block) GetHeader() *types.Any { - if m != nil { - return m.Header - } - return nil -} - -func (m *Block) GetTx() *TxValue { - if m != nil { - return m.Tx - } - return nil -} - -// TxValue is the transaction info of the chain needed for the interchainqueries module. -type TxValue struct { - Response *types1.ExecTxResult `protobuf:"bytes,1,opt,name=response,proto3" json:"response,omitempty"` - // is the Merkle Proof which proves existence of response in block with height - // next_block_header.Height - DeliveryProof *crypto.Proof `protobuf:"bytes,2,opt,name=delivery_proof,json=deliveryProof,proto3" json:"delivery_proof,omitempty"` - // is the Merkle Proof which proves existence of data in block with height - // header.Height - InclusionProof *crypto.Proof `protobuf:"bytes,3,opt,name=inclusion_proof,json=inclusionProof,proto3" json:"inclusion_proof,omitempty"` - // is body of the transaction - Data []byte `protobuf:"bytes,4,opt,name=data,proto3" json:"data,omitempty"` -} - -func (m *TxValue) Reset() { *m = TxValue{} } -func (m *TxValue) String() string { return proto.CompactTextString(m) } -func (*TxValue) ProtoMessage() {} -func (*TxValue) Descriptor() ([]byte, []int) { - return fileDescriptor_c0ec4c1e96ae4947, []int{6} -} -func (m *TxValue) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *TxValue) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_TxValue.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 *TxValue) XXX_Merge(src proto.Message) { - xxx_messageInfo_TxValue.Merge(m, src) -} -func (m *TxValue) XXX_Size() int { - return m.Size() -} -func (m *TxValue) XXX_DiscardUnknown() { - xxx_messageInfo_TxValue.DiscardUnknown(m) -} - -var xxx_messageInfo_TxValue proto.InternalMessageInfo - -func (m *TxValue) GetResponse() *types1.ExecTxResult { - if m != nil { - return m.Response - } - return nil -} - -func (m *TxValue) GetDeliveryProof() *crypto.Proof { - if m != nil { - return m.DeliveryProof - } - return nil -} - -func (m *TxValue) GetInclusionProof() *crypto.Proof { - if m != nil { - return m.InclusionProof - } - return nil -} - -func (m *TxValue) GetData() []byte { - if m != nil { - return m.Data - } - return nil -} - -// MsgSubmitQueryResultResponse is the MsgSubmitQueryResult response type. -type MsgSubmitQueryResultResponse struct { -} - -func (m *MsgSubmitQueryResultResponse) Reset() { *m = MsgSubmitQueryResultResponse{} } -func (m *MsgSubmitQueryResultResponse) String() string { return proto.CompactTextString(m) } -func (*MsgSubmitQueryResultResponse) ProtoMessage() {} -func (*MsgSubmitQueryResultResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_c0ec4c1e96ae4947, []int{7} -} -func (m *MsgSubmitQueryResultResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgSubmitQueryResultResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgSubmitQueryResultResponse.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 *MsgSubmitQueryResultResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgSubmitQueryResultResponse.Merge(m, src) -} -func (m *MsgSubmitQueryResultResponse) XXX_Size() int { - return m.Size() -} -func (m *MsgSubmitQueryResultResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgSubmitQueryResultResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgSubmitQueryResultResponse proto.InternalMessageInfo - -// MsgRemoveInterchainQueryRequest is the MsgRemoveInterchainQuery request type. -type MsgRemoveInterchainQueryRequest struct { - QueryId uint64 `protobuf:"varint,1,opt,name=query_id,json=queryId,proto3" json:"query_id,omitempty"` - Sender string `protobuf:"bytes,2,opt,name=sender,proto3" json:"sender,omitempty"` -} - -func (m *MsgRemoveInterchainQueryRequest) Reset() { *m = MsgRemoveInterchainQueryRequest{} } -func (m *MsgRemoveInterchainQueryRequest) String() string { return proto.CompactTextString(m) } -func (*MsgRemoveInterchainQueryRequest) ProtoMessage() {} -func (*MsgRemoveInterchainQueryRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_c0ec4c1e96ae4947, []int{8} -} -func (m *MsgRemoveInterchainQueryRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgRemoveInterchainQueryRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgRemoveInterchainQueryRequest.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 *MsgRemoveInterchainQueryRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgRemoveInterchainQueryRequest.Merge(m, src) -} -func (m *MsgRemoveInterchainQueryRequest) XXX_Size() int { - return m.Size() -} -func (m *MsgRemoveInterchainQueryRequest) XXX_DiscardUnknown() { - xxx_messageInfo_MsgRemoveInterchainQueryRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgRemoveInterchainQueryRequest proto.InternalMessageInfo - -func (m *MsgRemoveInterchainQueryRequest) GetQueryId() uint64 { - if m != nil { - return m.QueryId - } - return 0 -} - -func (m *MsgRemoveInterchainQueryRequest) GetSender() string { - if m != nil { - return m.Sender - } - return "" -} - -// MsgRemoveInterchainQueryResponse is the MsgRemoveInterchainQuery response type. -type MsgRemoveInterchainQueryResponse struct { -} - -func (m *MsgRemoveInterchainQueryResponse) Reset() { *m = MsgRemoveInterchainQueryResponse{} } -func (m *MsgRemoveInterchainQueryResponse) String() string { return proto.CompactTextString(m) } -func (*MsgRemoveInterchainQueryResponse) ProtoMessage() {} -func (*MsgRemoveInterchainQueryResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_c0ec4c1e96ae4947, []int{9} -} -func (m *MsgRemoveInterchainQueryResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgRemoveInterchainQueryResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgRemoveInterchainQueryResponse.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 *MsgRemoveInterchainQueryResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgRemoveInterchainQueryResponse.Merge(m, src) -} -func (m *MsgRemoveInterchainQueryResponse) XXX_Size() int { - return m.Size() -} -func (m *MsgRemoveInterchainQueryResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgRemoveInterchainQueryResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgRemoveInterchainQueryResponse proto.InternalMessageInfo - -// MsgUpdateInterchainQueryRequest is the MsgUpdateInterchainQuery request type. -type MsgUpdateInterchainQueryRequest struct { - QueryId uint64 `protobuf:"varint,1,opt,name=query_id,json=queryId,proto3" json:"query_id,omitempty"` - NewKeys []*KVKey `protobuf:"bytes,2,rep,name=new_keys,json=newKeys,proto3" json:"new_keys,omitempty"` - NewUpdatePeriod uint64 `protobuf:"varint,3,opt,name=new_update_period,json=newUpdatePeriod,proto3" json:"new_update_period,omitempty"` - NewTransactionsFilter string `protobuf:"bytes,4,opt,name=new_transactions_filter,json=newTransactionsFilter,proto3" json:"new_transactions_filter,omitempty"` - Sender string `protobuf:"bytes,5,opt,name=sender,proto3" json:"sender,omitempty"` -} - -func (m *MsgUpdateInterchainQueryRequest) Reset() { *m = MsgUpdateInterchainQueryRequest{} } -func (m *MsgUpdateInterchainQueryRequest) String() string { return proto.CompactTextString(m) } -func (*MsgUpdateInterchainQueryRequest) ProtoMessage() {} -func (*MsgUpdateInterchainQueryRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_c0ec4c1e96ae4947, []int{10} -} -func (m *MsgUpdateInterchainQueryRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgUpdateInterchainQueryRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgUpdateInterchainQueryRequest.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 *MsgUpdateInterchainQueryRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgUpdateInterchainQueryRequest.Merge(m, src) -} -func (m *MsgUpdateInterchainQueryRequest) XXX_Size() int { - return m.Size() -} -func (m *MsgUpdateInterchainQueryRequest) XXX_DiscardUnknown() { - xxx_messageInfo_MsgUpdateInterchainQueryRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgUpdateInterchainQueryRequest proto.InternalMessageInfo - -func (m *MsgUpdateInterchainQueryRequest) GetQueryId() uint64 { - if m != nil { - return m.QueryId - } - return 0 -} - -func (m *MsgUpdateInterchainQueryRequest) GetNewKeys() []*KVKey { - if m != nil { - return m.NewKeys - } - return nil -} - -func (m *MsgUpdateInterchainQueryRequest) GetNewUpdatePeriod() uint64 { - if m != nil { - return m.NewUpdatePeriod - } - return 0 -} - -func (m *MsgUpdateInterchainQueryRequest) GetNewTransactionsFilter() string { - if m != nil { - return m.NewTransactionsFilter - } - return "" -} - -func (m *MsgUpdateInterchainQueryRequest) GetSender() string { - if m != nil { - return m.Sender - } - return "" -} - -// MsgUpdateInterchainQueryResponse is the MsgUpdateInterchainQuery response type. -type MsgUpdateInterchainQueryResponse struct { -} - -func (m *MsgUpdateInterchainQueryResponse) Reset() { *m = MsgUpdateInterchainQueryResponse{} } -func (m *MsgUpdateInterchainQueryResponse) String() string { return proto.CompactTextString(m) } -func (*MsgUpdateInterchainQueryResponse) ProtoMessage() {} -func (*MsgUpdateInterchainQueryResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_c0ec4c1e96ae4947, []int{11} -} -func (m *MsgUpdateInterchainQueryResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgUpdateInterchainQueryResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgUpdateInterchainQueryResponse.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 *MsgUpdateInterchainQueryResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgUpdateInterchainQueryResponse.Merge(m, src) -} -func (m *MsgUpdateInterchainQueryResponse) XXX_Size() int { - return m.Size() -} -func (m *MsgUpdateInterchainQueryResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgUpdateInterchainQueryResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgUpdateInterchainQueryResponse proto.InternalMessageInfo - -// MsgUpdateParams is the MsgUpdateParams request type. -// -// Since: 0.47 -type MsgUpdateParams struct { - // Authority is the address of the governance account. - Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` - // params defines the x/interchainqueries parameters to update. - // - // NOTE: All parameters must be supplied. - Params Params `protobuf:"bytes,2,opt,name=params,proto3" json:"params"` -} - -func (m *MsgUpdateParams) Reset() { *m = MsgUpdateParams{} } -func (m *MsgUpdateParams) String() string { return proto.CompactTextString(m) } -func (*MsgUpdateParams) ProtoMessage() {} -func (*MsgUpdateParams) Descriptor() ([]byte, []int) { - return fileDescriptor_c0ec4c1e96ae4947, []int{12} -} -func (m *MsgUpdateParams) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgUpdateParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgUpdateParams.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *MsgUpdateParams) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgUpdateParams.Merge(m, src) -} -func (m *MsgUpdateParams) XXX_Size() int { - return m.Size() -} -func (m *MsgUpdateParams) XXX_DiscardUnknown() { - xxx_messageInfo_MsgUpdateParams.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgUpdateParams proto.InternalMessageInfo - -func (m *MsgUpdateParams) GetAuthority() string { - if m != nil { - return m.Authority - } - return "" -} - -func (m *MsgUpdateParams) GetParams() Params { - if m != nil { - return m.Params - } - return Params{} -} - -// MsgUpdateParamsResponse defines the response structure for executing a -// MsgUpdateParams message. -// -// Since: 0.47 -type MsgUpdateParamsResponse struct { -} - -func (m *MsgUpdateParamsResponse) Reset() { *m = MsgUpdateParamsResponse{} } -func (m *MsgUpdateParamsResponse) String() string { return proto.CompactTextString(m) } -func (*MsgUpdateParamsResponse) ProtoMessage() {} -func (*MsgUpdateParamsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_c0ec4c1e96ae4947, []int{13} -} -func (m *MsgUpdateParamsResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgUpdateParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgUpdateParamsResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *MsgUpdateParamsResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgUpdateParamsResponse.Merge(m, src) -} -func (m *MsgUpdateParamsResponse) XXX_Size() int { - return m.Size() -} -func (m *MsgUpdateParamsResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgUpdateParamsResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgUpdateParamsResponse proto.InternalMessageInfo - -func init() { - proto.RegisterType((*MsgRegisterInterchainQuery)(nil), "nolus.interchainqueries.MsgRegisterInterchainQuery") - proto.RegisterType((*MsgRegisterInterchainQueryResponse)(nil), "nolus.interchainqueries.MsgRegisterInterchainQueryResponse") - proto.RegisterType((*MsgSubmitQueryResult)(nil), "nolus.interchainqueries.MsgSubmitQueryResult") - proto.RegisterType((*QueryResult)(nil), "nolus.interchainqueries.QueryResult") - proto.RegisterType((*StorageValue)(nil), "nolus.interchainqueries.StorageValue") - proto.RegisterType((*Block)(nil), "nolus.interchainqueries.Block") - proto.RegisterType((*TxValue)(nil), "nolus.interchainqueries.TxValue") - proto.RegisterType((*MsgSubmitQueryResultResponse)(nil), "nolus.interchainqueries.MsgSubmitQueryResultResponse") - proto.RegisterType((*MsgRemoveInterchainQueryRequest)(nil), "nolus.interchainqueries.MsgRemoveInterchainQueryRequest") - proto.RegisterType((*MsgRemoveInterchainQueryResponse)(nil), "nolus.interchainqueries.MsgRemoveInterchainQueryResponse") - proto.RegisterType((*MsgUpdateInterchainQueryRequest)(nil), "nolus.interchainqueries.MsgUpdateInterchainQueryRequest") - proto.RegisterType((*MsgUpdateInterchainQueryResponse)(nil), "nolus.interchainqueries.MsgUpdateInterchainQueryResponse") - proto.RegisterType((*MsgUpdateParams)(nil), "nolus.interchainqueries.MsgUpdateParams") - proto.RegisterType((*MsgUpdateParamsResponse)(nil), "nolus.interchainqueries.MsgUpdateParamsResponse") -} - -func init() { proto.RegisterFile("nolus/interchainqueries/tx.proto", fileDescriptor_c0ec4c1e96ae4947) } - -var fileDescriptor_c0ec4c1e96ae4947 = []byte{ - // 1169 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x56, 0x4f, 0x4f, 0x1b, 0x47, - 0x14, 0x67, 0x8d, 0x4d, 0xf0, 0xe0, 0x40, 0x98, 0x92, 0x62, 0x4c, 0x31, 0xae, 0x1b, 0x24, 0x84, - 0xc2, 0x6e, 0x42, 0x68, 0x54, 0xd2, 0xaa, 0x2d, 0xf4, 0x8f, 0x8a, 0x10, 0x2d, 0x5d, 0x48, 0x54, - 0xf5, 0xb2, 0x5a, 0xef, 0x0e, 0xeb, 0xa9, 0xd7, 0x33, 0xce, 0xce, 0xac, 0xed, 0xbd, 0x45, 0x3d, - 0xb6, 0x95, 0x9a, 0x6f, 0xd0, 0x6b, 0x7b, 0xa3, 0x52, 0xbf, 0x41, 0x2f, 0x39, 0x46, 0x3d, 0xf5, - 0x50, 0x55, 0x15, 0x1c, 0x38, 0xf4, 0x4b, 0x54, 0x33, 0xb3, 0x6b, 0x4c, 0xcc, 0x9a, 0xc2, 0x05, - 0xf6, 0xbd, 0xf7, 0x9b, 0x37, 0xbf, 0xf9, 0xcd, 0xbc, 0xf7, 0x0c, 0x2a, 0x84, 0xfa, 0x21, 0x33, - 0x30, 0xe1, 0x28, 0x70, 0xea, 0x36, 0x26, 0x4f, 0x43, 0x14, 0x60, 0xc4, 0x0c, 0xde, 0xd5, 0x5b, - 0x01, 0xe5, 0x14, 0xce, 0x4a, 0x84, 0x3e, 0x80, 0x28, 0x4d, 0xdb, 0x4d, 0x4c, 0xa8, 0x21, 0xff, - 0x2a, 0x6c, 0x69, 0xd6, 0xa1, 0xac, 0x49, 0x99, 0xd1, 0x64, 0x9e, 0xd1, 0xbe, 0x2f, 0xfe, 0xc5, - 0x81, 0x39, 0x15, 0xb0, 0xa4, 0x65, 0x28, 0x23, 0x0e, 0xcd, 0x78, 0xd4, 0xa3, 0xca, 0x2f, 0xbe, - 0x92, 0x05, 0x1e, 0xa5, 0x9e, 0x8f, 0x0c, 0x69, 0xd5, 0xc2, 0x43, 0xc3, 0x26, 0x51, 0x1c, 0x5a, - 0x4a, 0xa3, 0xec, 0x21, 0x82, 0x18, 0x4e, 0xf2, 0xde, 0x49, 0x83, 0xb5, 0xec, 0xc0, 0x6e, 0x26, - 0xa8, 0x79, 0x8e, 0x88, 0x8b, 0x82, 0x26, 0x26, 0xdc, 0xb0, 0x6b, 0x0e, 0x36, 0x78, 0xd4, 0x42, - 0x49, 0x70, 0xa1, 0x2f, 0xe8, 0x04, 0x51, 0x8b, 0x53, 0xc1, 0x87, 0x1e, 0xaa, 0x70, 0xf5, 0xc7, - 0x0c, 0x28, 0xed, 0x32, 0xcf, 0x44, 0x1e, 0x66, 0x1c, 0x05, 0xdb, 0xbd, 0x9d, 0xbe, 0x0c, 0x51, - 0x10, 0xc1, 0x05, 0x00, 0xc4, 0x96, 0x91, 0x25, 0x52, 0x16, 0xb5, 0x8a, 0xb6, 0x9c, 0x37, 0xf3, - 0xd2, 0x73, 0x10, 0xb5, 0x10, 0x5c, 0x03, 0xd9, 0x06, 0x8a, 0x58, 0x31, 0x53, 0x19, 0x5d, 0x9e, - 0x58, 0x2b, 0xeb, 0x29, 0x32, 0xeb, 0x3b, 0x4f, 0x76, 0x50, 0x64, 0x4a, 0x2c, 0x34, 0xc0, 0x6b, - 0x3c, 0xb0, 0x09, 0xb3, 0x1d, 0x8e, 0x29, 0x61, 0xd6, 0x21, 0xf6, 0x39, 0x0a, 0x8a, 0xa3, 0x32, - 0x37, 0xec, 0x0f, 0x7d, 0x2a, 0x23, 0xf0, 0x2d, 0x70, 0xd3, 0xa1, 0x84, 0x20, 0xe9, 0xb4, 0xb0, - 0x5b, 0xcc, 0x4a, 0x68, 0xe1, 0xcc, 0xb9, 0xed, 0x0a, 0x50, 0xd8, 0x72, 0x6d, 0x8e, 0xac, 0x16, - 0x0a, 0x30, 0x75, 0x8b, 0xb9, 0x8a, 0xb6, 0x9c, 0x35, 0x0b, 0xca, 0xb9, 0x27, 0x7d, 0xf0, 0x75, - 0x30, 0xc6, 0xa4, 0x1a, 0xc5, 0x31, 0x99, 0x22, 0xb6, 0x1e, 0x4d, 0x7c, 0x7b, 0x7a, 0xb4, 0x12, - 0x1b, 0xd5, 0x75, 0x50, 0x4d, 0x17, 0xc4, 0x44, 0xac, 0x45, 0x09, 0x43, 0x70, 0x12, 0x64, 0xb0, - 0x2b, 0x05, 0xc9, 0x9a, 0x19, 0xec, 0x56, 0x7f, 0xd5, 0xc0, 0xcc, 0x2e, 0xf3, 0xf6, 0xc3, 0x5a, - 0x13, 0xf3, 0x04, 0x1a, 0xfa, 0x1c, 0xce, 0x81, 0x71, 0xa5, 0x60, 0x0f, 0x7e, 0x43, 0xda, 0xdb, - 0xfd, 0x74, 0x32, 0xfd, 0x74, 0xe0, 0x3c, 0xc8, 0x3b, 0x3e, 0x46, 0x84, 0x8b, 0x35, 0x4a, 0x97, - 0x71, 0xe5, 0xd8, 0x76, 0xe1, 0x7b, 0x60, 0x2c, 0x90, 0x99, 0xa5, 0x0c, 0x13, 0x6b, 0x77, 0x52, - 0x45, 0xef, 0x63, 0x61, 0xc6, 0x6b, 0xce, 0x9f, 0xf4, 0x5f, 0x0d, 0x4c, 0xf4, 0x53, 0xfd, 0x18, - 0x80, 0x46, 0xdb, 0x52, 0x48, 0x56, 0xd4, 0xe4, 0x9d, 0x2e, 0xa5, 0xa6, 0xdf, 0xe7, 0x34, 0xb0, - 0x3d, 0xf4, 0xc4, 0xf6, 0x43, 0x64, 0xe6, 0x1b, 0x6d, 0x95, 0x84, 0xc1, 0x75, 0x90, 0xab, 0xf9, - 0xd4, 0x69, 0xc8, 0x43, 0x0d, 0x7b, 0x14, 0x5b, 0x02, 0x65, 0x2a, 0xb0, 0xd0, 0xa2, 0x8e, 0xb0, - 0x57, 0xe7, 0xf2, 0xc0, 0x59, 0x33, 0xb6, 0x60, 0x09, 0x8c, 0x07, 0xa8, 0x8d, 0x19, 0xa6, 0x44, - 0x1e, 0x38, 0x6b, 0xf6, 0x6c, 0x78, 0x17, 0x40, 0xdb, 0xf7, 0x69, 0xc7, 0x6a, 0xb4, 0x2d, 0xc7, - 0xf6, 0xfd, 0x9a, 0xed, 0x34, 0x98, 0xbc, 0xf8, 0x71, 0xf3, 0x96, 0x8c, 0xec, 0xb4, 0x3f, 0x4a, - 0xfc, 0xd5, 0xe7, 0x1a, 0x28, 0xf4, 0x73, 0x86, 0x4b, 0x60, 0x92, 0x29, 0xdb, 0x6a, 0x05, 0xe8, - 0x10, 0x77, 0xe3, 0xf7, 0x7d, 0x33, 0xf6, 0xee, 0x49, 0x27, 0xbc, 0x05, 0x46, 0x1b, 0x28, 0x92, - 0xa7, 0x29, 0x98, 0xe2, 0x13, 0xce, 0x80, 0x5c, 0x5b, 0x64, 0x90, 0x54, 0x0b, 0xa6, 0x32, 0xe0, - 0x7d, 0x90, 0x93, 0x85, 0x15, 0xdf, 0xcb, 0xbc, 0x7e, 0x56, 0x78, 0xba, 0x2a, 0x3c, 0x7d, 0x4f, - 0xc4, 0xbf, 0x68, 0x31, 0x53, 0x21, 0xab, 0xbf, 0x68, 0x20, 0x27, 0x55, 0x80, 0x1f, 0x82, 0x69, - 0x82, 0xba, 0xdc, 0x92, 0x62, 0x58, 0x75, 0x64, 0x8b, 0x57, 0xa1, 0xc9, 0x44, 0x33, 0xba, 0x6a, - 0x23, 0x7a, 0xd2, 0x46, 0xf4, 0x4d, 0x12, 0x99, 0x53, 0x02, 0x2e, 0xd7, 0x7e, 0x26, 0xc1, 0xf0, - 0xae, 0x10, 0xd0, 0x4e, 0x1e, 0x53, 0xda, 0xb2, 0x18, 0x03, 0xef, 0x81, 0x0c, 0xef, 0x4a, 0xfe, - 0x13, 0x6b, 0x95, 0xd4, 0x1b, 0x3a, 0xe8, 0xaa, 0xdb, 0xcd, 0xf0, 0x6e, 0xf5, 0x2f, 0x0d, 0xdc, - 0x88, 0x6d, 0xb8, 0x21, 0x2e, 0x45, 0x15, 0x42, 0x4c, 0x72, 0xa1, 0xff, 0xb4, 0xa2, 0x07, 0xe9, - 0x9f, 0x74, 0x91, 0x73, 0xd0, 0x8d, 0x9f, 0x5f, 0x0f, 0x0e, 0x3f, 0x00, 0x93, 0x2e, 0xf2, 0x71, - 0x5b, 0x54, 0x84, 0x92, 0x4b, 0xd1, 0x2d, 0xa6, 0xc9, 0x65, 0xde, 0x4c, 0xf0, 0xd2, 0x84, 0x9b, - 0x60, 0x0a, 0x13, 0xc7, 0x0f, 0xc5, 0x0b, 0x88, 0x33, 0x8c, 0x5e, 0x92, 0x61, 0xb2, 0xb7, 0x40, - 0xa5, 0x80, 0x20, 0xeb, 0xda, 0xdc, 0x96, 0x17, 0x55, 0x30, 0xe5, 0x77, 0xb5, 0x0c, 0xde, 0xb8, - 0xa8, 0x7c, 0x93, 0x7a, 0xaf, 0xda, 0x60, 0x51, 0x76, 0x85, 0x26, 0x6d, 0xa3, 0x81, 0x9e, 0xf0, - 0x34, 0x44, 0xec, 0x3a, 0x95, 0x7e, 0xbe, 0x1c, 0xab, 0xa0, 0x92, 0xbe, 0x45, 0x4c, 0xe3, 0x59, - 0x46, 0xf2, 0x78, 0x2c, 0xbb, 0xda, 0xd5, 0x79, 0x6c, 0x80, 0x71, 0x82, 0x3a, 0xd6, 0x15, 0x7a, - 0xf6, 0x0d, 0x82, 0x3a, 0x3b, 0xa2, 0x6d, 0xaf, 0x88, 0x17, 0xda, 0xb1, 0xce, 0x37, 0x59, 0x55, - 0xab, 0x53, 0x04, 0x75, 0x1e, 0xf7, 0xf7, 0xd9, 0x87, 0x60, 0x56, 0x60, 0x2f, 0x6a, 0xf3, 0xaa, - 0x77, 0xdf, 0x26, 0xa8, 0x73, 0x30, 0xd8, 0xe9, 0xcf, 0x64, 0xca, 0x5d, 0x26, 0x53, 0x8a, 0x02, - 0xb1, 0x4c, 0xbf, 0x6b, 0x60, 0xaa, 0x07, 0xda, 0x93, 0xb3, 0x12, 0x3e, 0x04, 0x79, 0x3b, 0xe4, - 0x75, 0x1a, 0x60, 0x1e, 0xa9, 0x4a, 0xdf, 0x2a, 0xfe, 0xf1, 0xdb, 0xea, 0x4c, 0x3c, 0xc8, 0x37, - 0x5d, 0x37, 0x40, 0x8c, 0xed, 0xf3, 0x00, 0x13, 0xcf, 0x3c, 0x83, 0xc2, 0x2d, 0x30, 0xa6, 0xa6, - 0x6d, 0xfc, 0x52, 0x17, 0x53, 0x15, 0x53, 0x1b, 0x6d, 0xe5, 0x5f, 0xfc, 0xbd, 0x38, 0xf2, 0xf3, - 0xe9, 0xd1, 0x8a, 0x66, 0xc6, 0x2b, 0x1f, 0xad, 0x8b, 0x03, 0x9c, 0xe5, 0xfc, 0xee, 0xf4, 0x68, - 0xe5, 0xcd, 0xc1, 0xa1, 0xfe, 0x0a, 0xe3, 0xea, 0x1c, 0x98, 0x7d, 0xc5, 0x95, 0x1c, 0x70, 0xed, - 0xa7, 0x1c, 0x18, 0xdd, 0x65, 0x1e, 0xfc, 0x5e, 0x03, 0xb3, 0x69, 0xb3, 0xfb, 0x41, 0x2a, 0xd1, - 0xf4, 0xf9, 0x56, 0x7a, 0xf7, 0x1a, 0x8b, 0x7a, 0x43, 0x31, 0x02, 0xd3, 0x83, 0x03, 0x70, 0x75, - 0x58, 0xc6, 0x01, 0x78, 0xe9, 0xed, 0x2b, 0xc1, 0x7b, 0x5b, 0xff, 0xa0, 0x81, 0xdb, 0x17, 0x96, - 0x0e, 0x7c, 0x67, 0xf8, 0x89, 0xd2, 0x0b, 0xba, 0xb4, 0x71, 0x8d, 0x95, 0x7d, 0x74, 0x2e, 0x7c, - 0xa2, 0xc3, 0xe9, 0x0c, 0xab, 0xeb, 0xe1, 0x74, 0x86, 0xd6, 0x03, 0xfc, 0x06, 0x14, 0xce, 0xd5, - 0xc2, 0xf2, 0xe5, 0xa9, 0x14, 0xb2, 0x74, 0xef, 0xff, 0x22, 0x93, 0xbd, 0x4a, 0xb9, 0x67, 0xe2, - 0xe9, 0x6f, 0x7d, 0xf5, 0xe2, 0xb8, 0xac, 0xbd, 0x3c, 0x2e, 0x6b, 0xff, 0x1c, 0x97, 0xb5, 0xe7, - 0x27, 0xe5, 0x91, 0x97, 0x27, 0xe5, 0x91, 0x3f, 0x4f, 0xca, 0x23, 0x5f, 0xbf, 0xef, 0x61, 0x5e, - 0x0f, 0x6b, 0xba, 0x43, 0x9b, 0xc6, 0xe7, 0x22, 0xf9, 0xea, 0x9e, 0x18, 0x51, 0x0e, 0xf5, 0x0d, - 0xb9, 0xd7, 0xaa, 0x43, 0x03, 0x64, 0x74, 0x2f, 0xfa, 0x3d, 0x2f, 0x7e, 0xd7, 0xd6, 0xc6, 0xe4, - 0x44, 0x7b, 0xf0, 0x5f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x50, 0xa5, 0x8b, 0x06, 0xf7, 0x0b, 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 { - // RegisterInterchainQuery registers a new interchain query. - RegisterInterchainQuery(ctx context.Context, in *MsgRegisterInterchainQuery, opts ...grpc.CallOption) (*MsgRegisterInterchainQueryResponse, error) - // SubmitQueryResult submits a result of an interchain query. - SubmitQueryResult(ctx context.Context, in *MsgSubmitQueryResult, opts ...grpc.CallOption) (*MsgSubmitQueryResultResponse, error) - // RemoveInterchainQuery removes an interchain query. - RemoveInterchainQuery(ctx context.Context, in *MsgRemoveInterchainQueryRequest, opts ...grpc.CallOption) (*MsgRemoveInterchainQueryResponse, error) - // UpdateInterchainQuery updates an interchain query. - UpdateInterchainQuery(ctx context.Context, in *MsgUpdateInterchainQueryRequest, opts ...grpc.CallOption) (*MsgUpdateInterchainQueryResponse, error) - // UpdateParams updates the x/interchainqueries parameters. - UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) -} - -type msgClient struct { - cc grpc1.ClientConn -} - -func NewMsgClient(cc grpc1.ClientConn) MsgClient { - return &msgClient{cc} -} - -func (c *msgClient) RegisterInterchainQuery(ctx context.Context, in *MsgRegisterInterchainQuery, opts ...grpc.CallOption) (*MsgRegisterInterchainQueryResponse, error) { - out := new(MsgRegisterInterchainQueryResponse) - err := c.cc.Invoke(ctx, "/nolus.interchainqueries.Msg/RegisterInterchainQuery", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *msgClient) SubmitQueryResult(ctx context.Context, in *MsgSubmitQueryResult, opts ...grpc.CallOption) (*MsgSubmitQueryResultResponse, error) { - out := new(MsgSubmitQueryResultResponse) - err := c.cc.Invoke(ctx, "/nolus.interchainqueries.Msg/SubmitQueryResult", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *msgClient) RemoveInterchainQuery(ctx context.Context, in *MsgRemoveInterchainQueryRequest, opts ...grpc.CallOption) (*MsgRemoveInterchainQueryResponse, error) { - out := new(MsgRemoveInterchainQueryResponse) - err := c.cc.Invoke(ctx, "/nolus.interchainqueries.Msg/RemoveInterchainQuery", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *msgClient) UpdateInterchainQuery(ctx context.Context, in *MsgUpdateInterchainQueryRequest, opts ...grpc.CallOption) (*MsgUpdateInterchainQueryResponse, error) { - out := new(MsgUpdateInterchainQueryResponse) - err := c.cc.Invoke(ctx, "/nolus.interchainqueries.Msg/UpdateInterchainQuery", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) { - out := new(MsgUpdateParamsResponse) - err := c.cc.Invoke(ctx, "/nolus.interchainqueries.Msg/UpdateParams", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// MsgServer is the server API for Msg service. -type MsgServer interface { - // RegisterInterchainQuery registers a new interchain query. - RegisterInterchainQuery(context.Context, *MsgRegisterInterchainQuery) (*MsgRegisterInterchainQueryResponse, error) - // SubmitQueryResult submits a result of an interchain query. - SubmitQueryResult(context.Context, *MsgSubmitQueryResult) (*MsgSubmitQueryResultResponse, error) - // RemoveInterchainQuery removes an interchain query. - RemoveInterchainQuery(context.Context, *MsgRemoveInterchainQueryRequest) (*MsgRemoveInterchainQueryResponse, error) - // UpdateInterchainQuery updates an interchain query. - UpdateInterchainQuery(context.Context, *MsgUpdateInterchainQueryRequest) (*MsgUpdateInterchainQueryResponse, error) - // UpdateParams updates the x/interchainqueries parameters. - UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error) -} - -// UnimplementedMsgServer can be embedded to have forward compatible implementations. -type UnimplementedMsgServer struct { -} - -func (*UnimplementedMsgServer) RegisterInterchainQuery(ctx context.Context, req *MsgRegisterInterchainQuery) (*MsgRegisterInterchainQueryResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method RegisterInterchainQuery not implemented") -} -func (*UnimplementedMsgServer) SubmitQueryResult(ctx context.Context, req *MsgSubmitQueryResult) (*MsgSubmitQueryResultResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method SubmitQueryResult not implemented") -} -func (*UnimplementedMsgServer) RemoveInterchainQuery(ctx context.Context, req *MsgRemoveInterchainQueryRequest) (*MsgRemoveInterchainQueryResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method RemoveInterchainQuery not implemented") -} -func (*UnimplementedMsgServer) UpdateInterchainQuery(ctx context.Context, req *MsgUpdateInterchainQueryRequest) (*MsgUpdateInterchainQueryResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method UpdateInterchainQuery not implemented") -} -func (*UnimplementedMsgServer) UpdateParams(ctx context.Context, req *MsgUpdateParams) (*MsgUpdateParamsResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method UpdateParams not implemented") -} - -func RegisterMsgServer(s grpc1.Server, srv MsgServer) { - s.RegisterService(&_Msg_serviceDesc, srv) -} - -func _Msg_RegisterInterchainQuery_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgRegisterInterchainQuery) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).RegisterInterchainQuery(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/nolus.interchainqueries.Msg/RegisterInterchainQuery", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).RegisterInterchainQuery(ctx, req.(*MsgRegisterInterchainQuery)) - } - return interceptor(ctx, in, info, handler) -} - -func _Msg_SubmitQueryResult_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgSubmitQueryResult) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).SubmitQueryResult(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/nolus.interchainqueries.Msg/SubmitQueryResult", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).SubmitQueryResult(ctx, req.(*MsgSubmitQueryResult)) - } - return interceptor(ctx, in, info, handler) -} - -func _Msg_RemoveInterchainQuery_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgRemoveInterchainQueryRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).RemoveInterchainQuery(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/nolus.interchainqueries.Msg/RemoveInterchainQuery", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).RemoveInterchainQuery(ctx, req.(*MsgRemoveInterchainQueryRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Msg_UpdateInterchainQuery_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgUpdateInterchainQueryRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).UpdateInterchainQuery(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/nolus.interchainqueries.Msg/UpdateInterchainQuery", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).UpdateInterchainQuery(ctx, req.(*MsgUpdateInterchainQueryRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Msg_UpdateParams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgUpdateParams) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).UpdateParams(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/nolus.interchainqueries.Msg/UpdateParams", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).UpdateParams(ctx, req.(*MsgUpdateParams)) - } - return interceptor(ctx, in, info, handler) -} - -var _Msg_serviceDesc = grpc.ServiceDesc{ - ServiceName: "nolus.interchainqueries.Msg", - HandlerType: (*MsgServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "RegisterInterchainQuery", - Handler: _Msg_RegisterInterchainQuery_Handler, - }, - { - MethodName: "SubmitQueryResult", - Handler: _Msg_SubmitQueryResult_Handler, - }, - { - MethodName: "RemoveInterchainQuery", - Handler: _Msg_RemoveInterchainQuery_Handler, - }, - { - MethodName: "UpdateInterchainQuery", - Handler: _Msg_UpdateInterchainQuery_Handler, - }, - { - MethodName: "UpdateParams", - Handler: _Msg_UpdateParams_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "nolus/interchainqueries/tx.proto", -} - -func (m *MsgRegisterInterchainQuery) 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 *MsgRegisterInterchainQuery) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgRegisterInterchainQuery) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Sender) > 0 { - i -= len(m.Sender) - copy(dAtA[i:], m.Sender) - i = encodeVarintTx(dAtA, i, uint64(len(m.Sender))) - i-- - dAtA[i] = 0x32 - } - if m.UpdatePeriod != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.UpdatePeriod)) - i-- - dAtA[i] = 0x28 - } - 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] = 0x22 - } - if len(m.TransactionsFilter) > 0 { - i -= len(m.TransactionsFilter) - copy(dAtA[i:], m.TransactionsFilter) - i = encodeVarintTx(dAtA, i, uint64(len(m.TransactionsFilter))) - i-- - dAtA[i] = 0x1a - } - if len(m.Keys) > 0 { - for iNdEx := len(m.Keys) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Keys[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - } - if len(m.QueryType) > 0 { - i -= len(m.QueryType) - copy(dAtA[i:], m.QueryType) - i = encodeVarintTx(dAtA, i, uint64(len(m.QueryType))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MsgRegisterInterchainQueryResponse) 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 *MsgRegisterInterchainQueryResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgRegisterInterchainQueryResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Id != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.Id)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *MsgSubmitQueryResult) 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 *MsgSubmitQueryResult) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgSubmitQueryResult) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Result != nil { - { - size, err := m.Result.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - } - if len(m.ClientId) > 0 { - i -= len(m.ClientId) - copy(dAtA[i:], m.ClientId) - i = encodeVarintTx(dAtA, i, uint64(len(m.ClientId))) - i-- - dAtA[i] = 0x1a - } - if len(m.Sender) > 0 { - i -= len(m.Sender) - copy(dAtA[i:], m.Sender) - i = encodeVarintTx(dAtA, i, uint64(len(m.Sender))) - i-- - dAtA[i] = 0x12 - } - if m.QueryId != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.QueryId)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *QueryResult) 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 *QueryResult) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryResult) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.AllowKvCallbacks { - i-- - if m.AllowKvCallbacks { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x28 - } - if m.Revision != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.Revision)) - i-- - dAtA[i] = 0x20 - } - if m.Height != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.Height)) - i-- - dAtA[i] = 0x18 - } - if m.Block != nil { - { - size, err := m.Block.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - if len(m.KvResults) > 0 { - for iNdEx := len(m.KvResults) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.KvResults[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *StorageValue) 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 *StorageValue) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *StorageValue) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Proof != nil { - { - size, err := m.Proof.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - } - if len(m.Value) > 0 { - i -= len(m.Value) - copy(dAtA[i:], m.Value) - i = encodeVarintTx(dAtA, i, uint64(len(m.Value))) - i-- - dAtA[i] = 0x1a - } - if len(m.Key) > 0 { - i -= len(m.Key) - copy(dAtA[i:], m.Key) - i = encodeVarintTx(dAtA, i, uint64(len(m.Key))) - i-- - dAtA[i] = 0x12 - } - if len(m.StoragePrefix) > 0 { - i -= len(m.StoragePrefix) - copy(dAtA[i:], m.StoragePrefix) - i = encodeVarintTx(dAtA, i, uint64(len(m.StoragePrefix))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *Block) 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 *Block) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Block) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Tx != nil { - { - size, err := m.Tx.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - } - if m.Header != nil { - { - size, err := m.Header.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - if m.NextBlockHeader != nil { - { - size, err := m.NextBlockHeader.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *TxValue) 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 *TxValue) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *TxValue) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Data) > 0 { - i -= len(m.Data) - copy(dAtA[i:], m.Data) - i = encodeVarintTx(dAtA, i, uint64(len(m.Data))) - i-- - dAtA[i] = 0x22 - } - if m.InclusionProof != nil { - { - size, err := m.InclusionProof.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - } - if m.DeliveryProof != nil { - { - size, err := m.DeliveryProof.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - if m.Response != nil { - { - size, err := m.Response.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MsgSubmitQueryResultResponse) 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 *MsgSubmitQueryResultResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgSubmitQueryResultResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func (m *MsgRemoveInterchainQueryRequest) 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 *MsgRemoveInterchainQueryRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgRemoveInterchainQueryRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Sender) > 0 { - i -= len(m.Sender) - copy(dAtA[i:], m.Sender) - i = encodeVarintTx(dAtA, i, uint64(len(m.Sender))) - i-- - dAtA[i] = 0x12 - } - if m.QueryId != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.QueryId)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *MsgRemoveInterchainQueryResponse) 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 *MsgRemoveInterchainQueryResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgRemoveInterchainQueryResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func (m *MsgUpdateInterchainQueryRequest) 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 *MsgUpdateInterchainQueryRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgUpdateInterchainQueryRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Sender) > 0 { - i -= len(m.Sender) - copy(dAtA[i:], m.Sender) - i = encodeVarintTx(dAtA, i, uint64(len(m.Sender))) - i-- - dAtA[i] = 0x2a - } - if len(m.NewTransactionsFilter) > 0 { - i -= len(m.NewTransactionsFilter) - copy(dAtA[i:], m.NewTransactionsFilter) - i = encodeVarintTx(dAtA, i, uint64(len(m.NewTransactionsFilter))) - i-- - dAtA[i] = 0x22 - } - if m.NewUpdatePeriod != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.NewUpdatePeriod)) - i-- - dAtA[i] = 0x18 - } - if len(m.NewKeys) > 0 { - for iNdEx := len(m.NewKeys) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.NewKeys[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - } - if m.QueryId != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.QueryId)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *MsgUpdateInterchainQueryResponse) 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 *MsgUpdateInterchainQueryResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgUpdateInterchainQueryResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func (m *MsgUpdateParams) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *MsgUpdateParams) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgUpdateParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - if len(m.Authority) > 0 { - i -= len(m.Authority) - copy(dAtA[i:], m.Authority) - i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MsgUpdateParamsResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *MsgUpdateParamsResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgUpdateParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func encodeVarintTx(dAtA []byte, offset int, v uint64) int { - offset -= sovTx(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *MsgRegisterInterchainQuery) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.QueryType) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - if len(m.Keys) > 0 { - for _, e := range m.Keys { - l = e.Size() - n += 1 + l + sovTx(uint64(l)) - } - } - l = len(m.TransactionsFilter) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.ConnectionId) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - if m.UpdatePeriod != 0 { - n += 1 + sovTx(uint64(m.UpdatePeriod)) - } - l = len(m.Sender) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - return n -} - -func (m *MsgRegisterInterchainQueryResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Id != 0 { - n += 1 + sovTx(uint64(m.Id)) - } - return n -} - -func (m *MsgSubmitQueryResult) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.QueryId != 0 { - n += 1 + sovTx(uint64(m.QueryId)) - } - l = len(m.Sender) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.ClientId) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - if m.Result != nil { - l = m.Result.Size() - n += 1 + l + sovTx(uint64(l)) - } - return n -} - -func (m *QueryResult) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.KvResults) > 0 { - for _, e := range m.KvResults { - l = e.Size() - n += 1 + l + sovTx(uint64(l)) - } - } - if m.Block != nil { - l = m.Block.Size() - n += 1 + l + sovTx(uint64(l)) - } - if m.Height != 0 { - n += 1 + sovTx(uint64(m.Height)) - } - if m.Revision != 0 { - n += 1 + sovTx(uint64(m.Revision)) - } - if m.AllowKvCallbacks { - n += 2 - } - return n -} - -func (m *StorageValue) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.StoragePrefix) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.Key) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.Value) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - if m.Proof != nil { - l = m.Proof.Size() - n += 1 + l + sovTx(uint64(l)) - } - return n -} - -func (m *Block) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.NextBlockHeader != nil { - l = m.NextBlockHeader.Size() - n += 1 + l + sovTx(uint64(l)) - } - if m.Header != nil { - l = m.Header.Size() - n += 1 + l + sovTx(uint64(l)) - } - if m.Tx != nil { - l = m.Tx.Size() - n += 1 + l + sovTx(uint64(l)) - } - return n -} - -func (m *TxValue) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Response != nil { - l = m.Response.Size() - n += 1 + l + sovTx(uint64(l)) - } - if m.DeliveryProof != nil { - l = m.DeliveryProof.Size() - n += 1 + l + sovTx(uint64(l)) - } - if m.InclusionProof != nil { - l = m.InclusionProof.Size() - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.Data) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - return n -} - -func (m *MsgSubmitQueryResultResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func (m *MsgRemoveInterchainQueryRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.QueryId != 0 { - n += 1 + sovTx(uint64(m.QueryId)) - } - l = len(m.Sender) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - return n -} - -func (m *MsgRemoveInterchainQueryResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func (m *MsgUpdateInterchainQueryRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.QueryId != 0 { - n += 1 + sovTx(uint64(m.QueryId)) - } - if len(m.NewKeys) > 0 { - for _, e := range m.NewKeys { - l = e.Size() - n += 1 + l + sovTx(uint64(l)) - } - } - if m.NewUpdatePeriod != 0 { - n += 1 + sovTx(uint64(m.NewUpdatePeriod)) - } - l = len(m.NewTransactionsFilter) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.Sender) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - return n -} - -func (m *MsgUpdateInterchainQueryResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func (m *MsgUpdateParams) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Authority) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = m.Params.Size() - n += 1 + l + sovTx(uint64(l)) - return n -} - -func (m *MsgUpdateParamsResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func sovTx(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozTx(x uint64) (n int) { - return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *MsgRegisterInterchainQuery) 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: MsgRegisterInterchainQuery: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgRegisterInterchainQuery: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field QueryType", 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.QueryType = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Keys", 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.Keys = append(m.Keys, &KVKey{}) - if err := m.Keys[len(m.Keys)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TransactionsFilter", 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.TransactionsFilter = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 4: - 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 5: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field UpdatePeriod", wireType) - } - m.UpdatePeriod = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.UpdatePeriod |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 6: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Sender", 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.Sender = 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 *MsgRegisterInterchainQueryResponse) 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: MsgRegisterInterchainQueryResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgRegisterInterchainQueryResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) - } - m.Id = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Id |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgSubmitQueryResult) 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: MsgSubmitQueryResult: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgSubmitQueryResult: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field QueryId", wireType) - } - m.QueryId = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.QueryId |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Sender", 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.Sender = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ClientId", 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.ClientId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Result", 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.Result == nil { - m.Result = &QueryResult{} - } - if err := m.Result.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryResult) 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: QueryResult: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryResult: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field KvResults", 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.KvResults = append(m.KvResults, &StorageValue{}) - if err := m.KvResults[len(m.KvResults)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Block", 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.Block == nil { - m.Block = &Block{} - } - if err := m.Block.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) - } - m.Height = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Height |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Revision", wireType) - } - m.Revision = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Revision |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 5: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field AllowKvCallbacks", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.AllowKvCallbacks = bool(v != 0) - 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 *StorageValue) 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: StorageValue: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: StorageValue: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field StoragePrefix", 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.StoragePrefix = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Key = append(m.Key[:0], dAtA[iNdEx:postIndex]...) - if m.Key == nil { - m.Key = []byte{} - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Value = append(m.Value[:0], dAtA[iNdEx:postIndex]...) - if m.Value == nil { - m.Value = []byte{} - } - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Proof", 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.Proof == nil { - m.Proof = &crypto.ProofOps{} - } - if err := m.Proof.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Block) 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: Block: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Block: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field NextBlockHeader", 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.NextBlockHeader == nil { - m.NextBlockHeader = &types.Any{} - } - if err := m.NextBlockHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Header", 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.Header == nil { - m.Header = &types.Any{} - } - if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Tx", 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.Tx == nil { - m.Tx = &TxValue{} - } - if err := m.Tx.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *TxValue) 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: TxValue: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: TxValue: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Response", 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.Response == nil { - m.Response = &types1.ExecTxResult{} - } - if err := m.Response.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DeliveryProof", 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.DeliveryProof == nil { - m.DeliveryProof = &crypto.Proof{} - } - if err := m.DeliveryProof.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field InclusionProof", 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.InclusionProof == nil { - m.InclusionProof = &crypto.Proof{} - } - if err := m.InclusionProof.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Data = append(m.Data[:0], dAtA[iNdEx:postIndex]...) - if m.Data == nil { - m.Data = []byte{} - } - 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 *MsgSubmitQueryResultResponse) 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: MsgSubmitQueryResultResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgSubmitQueryResultResponse: 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 *MsgRemoveInterchainQueryRequest) 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: MsgRemoveInterchainQueryRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgRemoveInterchainQueryRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field QueryId", wireType) - } - m.QueryId = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.QueryId |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Sender", 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.Sender = 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 *MsgRemoveInterchainQueryResponse) 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: MsgRemoveInterchainQueryResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgRemoveInterchainQueryResponse: 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 *MsgUpdateInterchainQueryRequest) 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: MsgUpdateInterchainQueryRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUpdateInterchainQueryRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field QueryId", wireType) - } - m.QueryId = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.QueryId |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field NewKeys", 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.NewKeys = append(m.NewKeys, &KVKey{}) - if err := m.NewKeys[len(m.NewKeys)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field NewUpdatePeriod", wireType) - } - m.NewUpdatePeriod = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.NewUpdatePeriod |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field NewTransactionsFilter", 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.NewTransactionsFilter = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Sender", 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.Sender = 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 *MsgUpdateInterchainQueryResponse) 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: MsgUpdateInterchainQueryResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUpdateInterchainQueryResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgUpdateParams) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: MsgUpdateParams: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUpdateParams: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Authority", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Authority = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgUpdateParamsResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: MsgUpdateParamsResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUpdateParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipTx(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowTx - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowTx - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowTx - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthTx - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupTx - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthTx - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthTx = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowTx = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupTx = fmt.Errorf("proto: unexpected end of group") -) diff --git a/x/interchainqueries/types/tx_test.go b/x/interchainqueries/types/tx_test.go deleted file mode 100644 index 258d4eeb..00000000 --- a/x/interchainqueries/types/tx_test.go +++ /dev/null @@ -1,126 +0,0 @@ -package types_test - -import ( - "testing" - - "github.com/cometbft/cometbft/proto/tendermint/crypto" - sdktypes "github.com/cosmos/cosmos-sdk/types" - ibchost "github.com/cosmos/ibc-go/v8/modules/core/exported" - "github.com/stretchr/testify/require" - - iqtypes "github.com/Nolus-Protocol/nolus-core/x/interchainqueries/types" -) - -const TestAddress = "cosmos10h9stc5v6ntgeygf5xf945njqq5h32r53uquvw" - -func TestMsgRegisterInterchainQueryGetSigners(t *testing.T) { - tests := []struct { - name string - malleate func() sdktypes.LegacyMsg - }{ - { - "valid_signer", - func() sdktypes.LegacyMsg { - return &iqtypes.MsgRegisterInterchainQuery{ - ConnectionId: "connection-0", - TransactionsFilter: "{}", - Keys: nil, - QueryType: string(iqtypes.InterchainQueryTypeTX), - UpdatePeriod: 1, - Sender: TestAddress, - } - }, - }, - } - - for _, tt := range tests { - msg := tt.malleate() - addr, _ := sdktypes.AccAddressFromBech32(TestAddress) - require.Equal(t, msg.GetSigners(), []sdktypes.AccAddress{addr}) - } -} - -func TestMsgSubmitQueryResultGetSigners(t *testing.T) { - tests := []struct { - name string - malleate func() sdktypes.LegacyMsg - }{ - { - "valid_signer", - func() sdktypes.LegacyMsg { - return &iqtypes.MsgSubmitQueryResult{ - QueryId: 1, - Sender: TestAddress, - ClientId: "client-id", - Result: &iqtypes.QueryResult{ - KvResults: []*iqtypes.StorageValue{{ - Key: []byte{10}, - Proof: &crypto.ProofOps{Ops: []crypto.ProofOp{ - { - Type: "type", - Key: []byte{10}, - Data: []byte{10}, - }, - }}, - Value: []byte{10}, - StoragePrefix: ibchost.StoreKey, - }}, - Block: nil, - Height: 100, - Revision: 1, - }, - } - }, - }, - } - - for _, tt := range tests { - msg := tt.malleate() - addr, _ := sdktypes.AccAddressFromBech32(TestAddress) - require.Equal(t, msg.GetSigners(), []sdktypes.AccAddress{addr}) - } -} - -func TestMsgUpdateQueryGetSigners(t *testing.T) { - tests := []struct { - name string - malleate func() sdktypes.LegacyMsg - }{ - { - "valid_signer", - func() sdktypes.LegacyMsg { - return &iqtypes.MsgUpdateInterchainQueryRequest{ - Sender: TestAddress, - } - }, - }, - } - - for _, tt := range tests { - msg := tt.malleate() - addr, _ := sdktypes.AccAddressFromBech32(TestAddress) - require.Equal(t, msg.GetSigners(), []sdktypes.AccAddress{addr}) - } -} - -func TestMsgRemoveQueryGetSigners(t *testing.T) { - tests := []struct { - name string - malleate func() sdktypes.LegacyMsg - }{ - { - "valid_signer", - func() sdktypes.LegacyMsg { - return &iqtypes.MsgRemoveInterchainQueryRequest{ - Sender: TestAddress, - } - }, - }, - } - - for _, tt := range tests { - msg := tt.malleate() - addr, _ := sdktypes.AccAddressFromBech32(TestAddress) - require.Equal(t, msg.GetSigners(), []sdktypes.AccAddress{addr}) - } -} diff --git a/x/interchainqueries/types/types.go b/x/interchainqueries/types/types.go deleted file mode 100644 index 0d230e20..00000000 --- a/x/interchainqueries/types/types.go +++ /dev/null @@ -1,144 +0,0 @@ -package types - -import ( - "encoding/hex" - "encoding/json" - "fmt" - "strings" -) - -const ( - // EventTypeNolusMessage defines the event type used by the Interchain Queries module events. - EventTypeNolusMessage = "nolus" - - // AttributeKeyQueryID represents the key for event attribute delivering the query ID of a - // registered interchain query. - AttributeKeyQueryID = "query_id" - - // AttributeKeyOwner represents the key for event attribute delivering the address of the - // registrator of an interchain query. - AttributeKeyOwner = "owner" - - // AttributeKeyConnectionID represents the key for event attribute delivering the connection ID - // of an interchain query. - AttributeKeyConnectionID = "connection_id" - - // AttributeKeyQueryType represents the key for event attribute delivering the query type - // identifier (e.g. 'kv' or 'tx'). - AttributeKeyQueryType = "type" - - // AttributeKeyKVQuery represents the keys of the storage we want to get from remote chain for event attribute delivering the keys - // of an interchain query. - AttributeKeyKVQuery = "kv_key" - - // AttributeTransactionsFilterQuery represents the transactions filter for event attribute delivering the filter - // of an interchain query. - AttributeTransactionsFilterQuery = "tx_filter" - - // AttributeValueCategory represents the value for the 'module' event attribute. - AttributeValueCategory = ModuleName - - // AttributeValueQueryUpdated represents the value for the 'action' event attribute. - AttributeValueQueryUpdated = "query_updated" - - // AttributeValueQueryRemoved represents the value for the 'action' event attribute. - AttributeValueQueryRemoved = "query_removed" - - // maxTransactionsFilters defines maximum allowed amount of tx filters in msgRegisterInterchainQuery. - maxTransactionsFilters = 32 -) - -const ( - InterchainQueryTypeKV InterchainQueryType = "kv" - InterchainQueryTypeTX InterchainQueryType = "tx" - - kvPathKeyDelimiter = "/" - kvKeysDelimiter = "," -) - -type InterchainQueryType string - -func (icqt InterchainQueryType) IsValid() bool { - return icqt.IsTX() || icqt.IsKV() -} - -func (icqt InterchainQueryType) IsKV() bool { - return icqt == InterchainQueryTypeKV -} - -func (icqt InterchainQueryType) IsTX() bool { - return icqt == InterchainQueryTypeTX -} - -func (kv KVKey) ToString() string { - return kv.Path + kvPathKeyDelimiter + hex.EncodeToString(kv.Key) -} - -type KVKeys []*KVKey - -func (keys KVKeys) String() string { - if len(keys) == 0 { - return "" - } - - var b strings.Builder - b.WriteString(keys[0].ToString()) - - for _, key := range keys[1:] { - b.WriteString(kvKeysDelimiter) - b.WriteString(key.ToString()) - } - - return b.String() -} - -// TransactionsFilter represents the model of transactions filter parameter used in interchain -// queries of type TX. -type TransactionsFilter []TransactionsFilterItem - -// TransactionsFilterItem is a single condition for filtering transactions in search. -type TransactionsFilterItem struct { - // Field is the field used in condition, e.g. tx.height or transfer.recipient. - Field string `json:"field"` - // Op is the operation for filtering, one of the following: eq, gt, gte, lt, lte. - Op string `json:"op"` - // Value is the value for comparison. - Value interface{} `json:"value"` -} - -// ValidateTransactionsFilter checks if the passed string is a valid TransactionsFilter value. -func ValidateTransactionsFilter(s string) error { - const forbiddenCharacters = "\t\n\r\\()\"'=><" - filters := TransactionsFilter{} - if err := json.Unmarshal([]byte(s), &filters); err != nil { - return fmt.Errorf("failed to unmarshal transactions filter: %w", err) - } - if len(filters) > maxTransactionsFilters { - return fmt.Errorf("too many transactions filters, provided=%d, max=%d", len(filters), maxTransactionsFilters) - } - - for idx, f := range filters { - if strings.ContainsAny(f.Field, forbiddenCharacters) { - return fmt.Errorf("transactions filter condition idx=%d is invalid: special symbols %s are not allowed", idx, forbiddenCharacters) - } - if f.Field == "" { - return fmt.Errorf("transactions filter condition idx=%d is invalid: field couldn't be empty", idx) - } - switch value := f.Value.(type) { - case string: - case float64: - // despite json turns numbers into float, decimals are not allowed by tendermint API - if value != float64(int64(value)) { - return fmt.Errorf("transactions filter condition idx=%d is invalid: value %v can't be a decimal number", idx, value) - } - default: - return fmt.Errorf("transactions filter condition idx=%d is invalid: value '%v' is expected to be on of: string, number", idx, f.Value) - } - switch strings.ToLower(f.Op) { - case "eq", "gt", "gte", "lt", "lte": - default: - return fmt.Errorf("transactions filter condition idx=%d is invalid: op '%s' is expected to be one of: eq, gt, gte, lt, lte", idx, f.Op) - } - } - return nil -} diff --git a/x/interchainqueries/types/types_test.go b/x/interchainqueries/types/types_test.go deleted file mode 100644 index 588be9fc..00000000 --- a/x/interchainqueries/types/types_test.go +++ /dev/null @@ -1,59 +0,0 @@ -package types - -import ( - "encoding/json" - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestTransactionFilterValidation(t *testing.T) { - t.Run("Valid", func(t *testing.T) { - // several conditions - assert.NoError(t, ValidateTransactionsFilter(`[{"field":"transfer.recipient","op":"Eq","value":"nolus1mjk79fjjgpplak5wq838w0yd982gzkyf8fxu8u"},{"field":"tx.height","op":"Gte","value":100}]`)) - // all supported operations with a whole operand - assert.NoError(t, ValidateTransactionsFilter(`[{"field":"tx.height","op":"Eq","value":1000}]`)) - assert.NoError(t, ValidateTransactionsFilter(`[{"field":"tx.height","op":"Gt","value":1000}]`)) - assert.NoError(t, ValidateTransactionsFilter(`[{"field":"tx.height","op":"Gte","value":1000}]`)) - assert.NoError(t, ValidateTransactionsFilter(`[{"field":"tx.height","op":"Lt","value":1000}]`)) - assert.NoError(t, ValidateTransactionsFilter(`[{"field":"tx.height","op":"Lte","value":1000}]`)) - }) - t.Run("Invalid", func(t *testing.T) { - // invalid json - assert.ErrorContains(t, ValidateTransactionsFilter(`[{"field":"transfer.recipient","op":"Eq","value":`), "unexpected end of JSON input") - // empty operation - assert.ErrorContains(t, ValidateTransactionsFilter(`[{"field":"transfer.recipient","op":"","value":"nolus1mjk79fjjgpplak5wq838w0yd982gzkyf8fxu8u"}]`), "op '' is expected to be one of: eq, gt, gte, lt, lte") - // empty field - assert.ErrorContains(t, ValidateTransactionsFilter(`[{"field":"","op":"Eq","value":"nolus1mjk79fjjgpplak5wq838w0yd982gzkyf8fxu8u"}]`), "field couldn't be empty") - // field with forbidden symbols - const specialSymbolsAreNotAllowed = "special symbols \t\n\r\\()\"'=>< are not allowed" - assert.ErrorContains(t, ValidateTransactionsFilter(`[{"field":"transfer.\t","op":"Eq","value":"nolus1mjk79fjjgpplak5wq838w0yd982gzkyf8fxu8u"}]`), specialSymbolsAreNotAllowed) - assert.ErrorContains(t, ValidateTransactionsFilter(`[{"field":"transfer.\n","op":"Eq","value":"nolus1mjk79fjjgpplak5wq838w0yd982gzkyf8fxu8u"}]`), specialSymbolsAreNotAllowed) - assert.ErrorContains(t, ValidateTransactionsFilter(`[{"field":"transfer.\r","op":"Eq","value":"nolus1mjk79fjjgpplak5wq838w0yd982gzkyf8fxu8u"}]`), specialSymbolsAreNotAllowed) - assert.ErrorContains(t, ValidateTransactionsFilter(`[{"field":"transfer.\\","op":"Eq","value":"nolus1mjk79fjjgpplak5wq838w0yd982gzkyf8fxu8u"}]`), specialSymbolsAreNotAllowed) - assert.ErrorContains(t, ValidateTransactionsFilter(`[{"field":"transfer.(","op":"Eq","value":"nolus1mjk79fjjgpplak5wq838w0yd982gzkyf8fxu8u"}]`), specialSymbolsAreNotAllowed) - assert.ErrorContains(t, ValidateTransactionsFilter(`[{"field":"transfer.)","op":"Eq","value":"nolus1mjk79fjjgpplak5wq838w0yd982gzkyf8fxu8u"}]`), specialSymbolsAreNotAllowed) - assert.ErrorContains(t, ValidateTransactionsFilter(`[{"field":"transfer.\"","op":"Eq","value":"nolus1mjk79fjjgpplak5wq838w0yd982gzkyf8fxu8u"}]`), specialSymbolsAreNotAllowed) - assert.ErrorContains(t, ValidateTransactionsFilter(`[{"field":"transfer.'","op":"Eq","value":"nolus1mjk79fjjgpplak5wq838w0yd982gzkyf8fxu8u"}]`), specialSymbolsAreNotAllowed) - assert.ErrorContains(t, ValidateTransactionsFilter(`[{"field":"transfer.=","op":"Eq","value":"nolus1mjk79fjjgpplak5wq838w0yd982gzkyf8fxu8u"}]`), specialSymbolsAreNotAllowed) - assert.ErrorContains(t, ValidateTransactionsFilter(`[{"field":"transfer.>","op":"Eq","value":"nolus1mjk79fjjgpplak5wq838w0yd982gzkyf8fxu8u"}]`), specialSymbolsAreNotAllowed) - assert.ErrorContains(t, ValidateTransactionsFilter(`[{"field":"transfer.<","op":"Eq","value":"nolus1mjk79fjjgpplak5wq838w0yd982gzkyf8fxu8u"}]`), specialSymbolsAreNotAllowed) - // decimal number - assert.ErrorContains(t, ValidateTransactionsFilter(`[{"field":"tx.height","op":"Gte","value":15.5}]`), "can't be a decimal number") - assert.ErrorContains(t, ValidateTransactionsFilter(lotsOfTxFilters(t, 40)), "too many transactions filters") - }) -} - -func lotsOfTxFilters(t *testing.T, amount int) string { - filters := make([]TransactionsFilterItem, 0, amount) - for i := 0; i < amount; i++ { - filters = append(filters, TransactionsFilterItem{ - Field: "tx.height", - Op: "Eq", - Value: 1000, - }) - } - filtersStr, err := json.Marshal(filters) - assert.NoError(t, err) - return string(filtersStr) -} diff --git a/x/interchainqueries/types/verify.go b/x/interchainqueries/types/verify.go deleted file mode 100644 index 6e906770..00000000 --- a/x/interchainqueries/types/verify.go +++ /dev/null @@ -1,22 +0,0 @@ -package types - -import ( - codectypes "github.com/cosmos/cosmos-sdk/codec/types" - sdk "github.com/cosmos/cosmos-sdk/types" - clientkeeper "github.com/cosmos/ibc-go/v8/modules/core/02-client/keeper" - "github.com/cosmos/ibc-go/v8/modules/core/exported" - tendermintLightClientTypes "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" -) - -type HeaderVerifier interface { - VerifyHeaders(ctx sdk.Context, cleintkeeper clientkeeper.Keeper, clientID string, header, nextHeader exported.ClientMessage) error - UnpackHeader(any *codectypes.Any) (exported.ClientMessage, error) -} - -type TransactionVerifier interface { - VerifyTransaction( - header *tendermintLightClientTypes.Header, - nextHeader *tendermintLightClientTypes.Header, - tx *TxValue, - ) error -} diff --git a/x/interchaintxs/keeper/ibc_handlers_test.go b/x/interchaintxs/keeper/ibc_handlers_test.go index b3b5d25e..e0074813 100644 --- a/x/interchaintxs/keeper/ibc_handlers_test.go +++ b/x/interchaintxs/keeper/ibc_handlers_test.go @@ -83,7 +83,7 @@ func TestHandleTimeout(t *testing.T) { }) ctx := infCtx.WithGasMeter(types2.NewGasMeter(1_000_000_000_000)) contractAddress := sdk.MustAccAddressFromBech32(testutil.TestOwnerAddress) - relayerBech32 := "nolus1fxudpred77a0grgh69u0j7y84yks5ev4n5050z45kecz792jnd6scqu98z" + relayerBech32 := "nolus1f6cu6ypvpyh0p8d7pqnps2pduj87hda5t9v4mqrc8ra67xp28uwq4f4ysz" relayerAddress := sdk.MustAccAddressFromBech32(relayerBech32) p := channeltypes.Packet{ Sequence: 100, diff --git a/x/interchaintxs/keeper/msg_server_test.go b/x/interchaintxs/keeper/msg_server_test.go index ab0ad144..05ff9d6e 100644 --- a/x/interchaintxs/keeper/msg_server_test.go +++ b/x/interchaintxs/keeper/msg_server_test.go @@ -135,7 +135,7 @@ func TestRegisterInterchainAccount(t *testing.T) { Owner: icaOwner.String(), ConnectionId: msgRegAcc.ConnectionId, Version: "", - Ordering: channeltypes.ORDERED, + Ordering: channeltypes.UNORDERED, } wmKeeper.EXPECT().HasContractInfo(ctx, contractAddress).Return(true)