diff --git a/README.md b/README.md index f08182e1d..d79262e5a 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # sekai + KIRA Relay Chain ## Quick setup from Github @@ -67,59 +68,110 @@ TOOLS_VERSION="v0.0.12.4" && mkdir -p /usr/keys && FILE_NAME="bash-utils.sh" && ```sh sh env.sh ``` + # Get version info + [scripts/commands/version.sh](scripts/commands/version.sh) + # Adding more validators + [scripts/commands/adding-validators.sh](scripts/commands/adding-validators.sh) + ## Set ChangeTxFee permission + [scripts/commands/set-permission.sh](scripts/commands/set-permission.sh) + ## Set network properties + [scripts/commands/set-network-properties.sh](scripts/commands/set-network-properties.sh) + ## Set Execution Fee + [scripts/commands/set-execution-fee.sh](scripts/commands/set-execution-fee.sh) + ## Upsert token rates + [scripts/commands/upsert-token-rates.sh](scripts/commands/upsert-token-rates.sh) + ## Upsert token alias + [scripts/commands/upsert-token-alias.sh](scripts/commands/upsert-token-alias.sh) + # Fee payment in foreign currency + [scripts/commands/foreign-fee-payments.sh](scripts/commands/foreign-fee-payments.sh) + # Fee payment in foreign currency returning failure - execution fee in foreign currency + [scripts/commands/foreign-fee-payments-failure-return.sh](scripts/commands/foreign-fee-payments-failure-return.sh) + ## Query permission of an address + [scripts/commands/query-permission.sh](scripts/commands/query-permission.sh) + ## Query network properties + [scripts/commands/query-network-properties.sh](scripts/commands/query-network-properties.sh) + ## Query execution fee + [scripts/commands/query-execution-fee.sh](scripts/commands/query-execution-fee.sh) + # Query token alias + [scripts/commands/query-token-alias.sh](scripts/commands/query-token-alias.sh) + # Query token rate + [scripts/commands/query-token-rate.sh](scripts/commands/query-token-rate.sh) + # Query validator account + [scripts/commands/query-validator.sh](scripts/commands/query-validator.sh) + # Query for current frozen / unfronzen tokens + **Notes**: these values are valid only when specific network property is enabled [scripts/commands/query-frozen-token.sh](scripts/commands/query-frozen-token.sh) + # Query poor network messages + [scripts/commands/query-poor-network-messages.sh](scripts/commands/query-poor-network-messages.sh) + # Query signing infos per validator's consensus address + [scripts/commands/query-signing-infos.sh](scripts/commands/query-signing-infos.sh) + # Common commands for governance process + [scripts/commands/governance/common.sh](scripts/commands/governance/common.sh) + ### Set permission via governance process + [scripts/commands/governance/assign-permission.sh](scripts/commands/governance/assign-permission.sh) + ## Upsert token alias via governance process + [scripts/commands/governance/upsert-token-alias.sh](scripts/commands/governance/upsert-token-alias.sh) + ## Upsert token rates via governance process + [scripts/commands/governance/upsert-token-rates.sh](scripts/commands/governance/upsert-token-rates.sh) + # Commands for poor network management via governance process + [scripts/commands/governance/poor-network-messages.sh](scripts/commands/governance/poor-network-messages.sh) + # Freeze / unfreeze tokens via governance process + [scripts/commands/governance/token-freeze.sh](scripts/commands/governance/token-freeze.sh) + # Set network property proposal via governance process + [scripts/commands/governance/set-network-property.sh](scripts/commands/governance/set-network-property.sh) # Set application upgrade proposal via governance process + [scripts/commands/governance/upgrade-plan.sh](scripts/commands/governance/upgrade-plan.sh) Export the status of chain before halt (should kill the daemon process at the time of genesis export) @@ -134,12 +186,14 @@ At each time of upgrade, genesis upgrade command will be built and infra could r Note: state export command is not exporting the upgrade plan and if all validators run with exported genesis with the previous binary, consensus failure won't happen. # Identity registrar + [scripts/commands/identity-registrar.sh](scripts/commands/identity-registrar.sh) # Unjail via governance process Modify genesis json to have jailed validator for Unjail testing Add jailed validator key to kms. + ```sh sekaid keys add jailed_validator --keyring-backend=test --home=$HOME/.sekaid --recover "dish rather zoo connect cross inhale security utility occur spell price cute one catalog coconut sort shuffle palm crop surface label foster slender inherit" @@ -156,5 +210,6 @@ In order to manually generate new genesis file when the hard fork is activated, 3. Replace current upgrade plan in the app_state.upgrade with next plan and set next plan to null Using a command it can be done in this way. + 1. sekaid export > exported-genesis.json -2. sekaid new-genesis-from-exported exported-genesis.json new-genesis.json +2. sekaid new-genesis-from-exported exported-genesis.json new-genesis.json --json-minimize=true diff --git a/RELEASE.md b/RELEASE.md index eda3932a7..6b0a5b352 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -1,6 +1,9 @@ Features: -- update validator fee share from int to dec -- move commission rewards from validator object to multistaking pool -- Update fields from int to decimal for inactive_rank_decrease_percent,… -- convert slash percentage from int to decimal +- Dapp operator performance counter +- LP token return on verifier exit +- Liquidation for dapp when fall below threshold +- Swap, redeem, convert on lp tokens +- Bridge registrar +- Minting feature +- Add CLI commands and unit tests diff --git a/app/ante/ante_test.go b/app/ante/ante_test.go index c8f9b6b0f..74cf8cb88 100644 --- a/app/ante/ante_test.go +++ b/app/ante/ante_test.go @@ -553,6 +553,7 @@ func (suite *AnteTestSuite) TestPoorNetworkManagementDecorator() { sdk.ZeroDec(), sdk.ZeroInt(), false, + false, ), } return msgs, privs[0:1], accNums[0:1], []uint64{0}, sdk.NewCoins(sdk.NewInt64Coin("ukex", 100)) diff --git a/app/app.go b/app/app.go index 7702743d5..b11cfef8a 100644 --- a/app/app.go +++ b/app/app.go @@ -31,9 +31,15 @@ import ( customgov "github.com/KiraCore/sekai/x/gov" customgovkeeper "github.com/KiraCore/sekai/x/gov/keeper" govtypes "github.com/KiraCore/sekai/x/gov/types" + "github.com/KiraCore/sekai/x/layer2" + layer2keeper "github.com/KiraCore/sekai/x/layer2/keeper" + layer2types "github.com/KiraCore/sekai/x/layer2/types" "github.com/KiraCore/sekai/x/multistaking" multistakingkeeper "github.com/KiraCore/sekai/x/multistaking/keeper" multistakingtypes "github.com/KiraCore/sekai/x/multistaking/types" + recovery "github.com/KiraCore/sekai/x/recovery" + recoverykeeper "github.com/KiraCore/sekai/x/recovery/keeper" + recoverytypes "github.com/KiraCore/sekai/x/recovery/types" customslashing "github.com/KiraCore/sekai/x/slashing" customslashingkeeper "github.com/KiraCore/sekai/x/slashing/keeper" slashingtypes "github.com/KiraCore/sekai/x/slashing/types" @@ -104,6 +110,7 @@ var ( params.AppModuleBasic{}, upgrade.AppModuleBasic{}, customslashing.AppModuleBasic{}, + recovery.AppModuleBasic{}, customstaking.AppModuleBasic{}, customgov.AppModuleBasic{}, spending.AppModuleBasic{}, @@ -116,6 +123,7 @@ var ( custody.AppModuleBasic{}, multistaking.AppModuleBasic{}, collectives.AppModuleBasic{}, + layer2.AppModuleBasic{}, ) // module account permissions @@ -128,6 +136,8 @@ var ( baskettypes.ModuleName: {authtypes.Minter, authtypes.Burner}, multistakingtypes.ModuleName: {authtypes.Burner}, collectivestypes.ModuleName: nil, + layer2types.ModuleName: {authtypes.Minter, authtypes.Burner}, + recoverytypes.ModuleName: {authtypes.Minter, authtypes.Burner}, } // module accounts that are allowed to receive tokens @@ -158,6 +168,7 @@ type SekaiApp struct { CustomGovKeeper customgovkeeper.Keeper CustomStakingKeeper customstakingkeeper.Keeper CustomSlashingKeeper customslashingkeeper.Keeper + RecoveryKeeper recoverykeeper.Keeper TokensKeeper tokenskeeper.Keeper FeeProcessingKeeper feeprocessingkeeper.Keeper EvidenceKeeper evidencekeeper.Keeper @@ -167,6 +178,7 @@ type SekaiApp struct { BasketKeeper basketkeeper.Keeper MultiStakingKeeper multistakingkeeper.Keeper CollectivesKeeper collectiveskeeper.Keeper + Layer2Keeper layer2keeper.Keeper // Module Manager mm *module.Manager @@ -205,6 +217,7 @@ func NewInitApp( banktypes.StoreKey, paramstypes.StoreKey, upgradetypes.StoreKey, + recoverytypes.ModuleName, slashingtypes.ModuleName, stakingtypes.ModuleName, govtypes.ModuleName, @@ -218,6 +231,7 @@ func NewInitApp( evidencetypes.StoreKey, custodytypes.StoreKey, collectivestypes.ModuleName, + layer2types.ModuleName, ) tKeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey) @@ -258,17 +272,10 @@ func NewInitApp( app.GetSubspace(slashingtypes.ModuleName), ) app.SpendingKeeper = spendingkeeper.NewKeeper(keys[spendingtypes.ModuleName], appCodec, app.BankKeeper, app.CustomGovKeeper) - app.UbiKeeper = ubikeeper.NewKeeper(keys[ubitypes.ModuleName], appCodec, app.BankKeeper, app.SpendingKeeper) // NOTE: customStakingKeeper above is passed by reference, so that it will contain these hooks app.CustomStakingKeeper = *customStakingKeeper.SetHooks( stakingtypes.NewMultiStakingHooks(app.CustomSlashingKeeper.Hooks()), ) - app.DistrKeeper = distributorkeeper.NewKeeper( - keys[distributortypes.ModuleName], appCodec, - app.AccountKeeper, app.BankKeeper, - app.CustomStakingKeeper, app.CustomGovKeeper, - app.MultiStakingKeeper) - app.MultiStakingKeeper.SetDistrKeeper(app.DistrKeeper) app.BasketKeeper = basketkeeper.NewKeeper( keys[baskettypes.ModuleName], appCodec, @@ -286,6 +293,14 @@ func NewInitApp( app.SpendingKeeper, ) + app.Layer2Keeper = layer2keeper.NewKeeper( + keys[collectivestypes.StoreKey], appCodec, + app.BankKeeper, + app.CustomStakingKeeper, + app.CustomGovKeeper, + app.SpendingKeeper, + ) + app.UpgradeKeeper = upgradekeeper.NewKeeper(keys[upgradetypes.StoreKey], appCodec, app.CustomStakingKeeper) // app.upgradeKeeper.SetUpgradeHandler( @@ -303,6 +318,27 @@ func NewInitApp( app.CustodyKeeper = custodykeeper.NewKeeper(keys[custodytypes.StoreKey], appCodec, app.CustomGovKeeper, app.BankKeeper) + app.RecoveryKeeper = recoverykeeper.NewKeeper( + appCodec, + keys[slashingtypes.StoreKey], + app.AccountKeeper, + app.BankKeeper, + &customStakingKeeper, + app.CustomGovKeeper, + app.MultiStakingKeeper, + app.CollectivesKeeper, + app.SpendingKeeper, + app.CustodyKeeper, + ) + + app.DistrKeeper = distributorkeeper.NewKeeper( + keys[distributortypes.ModuleName], appCodec, + app.AccountKeeper, app.BankKeeper, + app.CustomStakingKeeper, app.CustomGovKeeper, + app.MultiStakingKeeper, app.RecoveryKeeper) + app.MultiStakingKeeper.SetDistrKeeper(app.DistrKeeper) + app.UbiKeeper = ubikeeper.NewKeeper(keys[ubitypes.ModuleName], appCodec, app.BankKeeper, app.SpendingKeeper, app.DistrKeeper) + proposalRouter := govtypes.NewProposalRouter( []govtypes.ProposalHandler{ customgov.NewApplyWhitelistAccountPermissionProposalHandler(app.CustomGovKeeper), @@ -342,6 +378,8 @@ func NewInitApp( collectives.NewApplyCollectiveSendDonationProposalHandler(app.CollectivesKeeper), collectives.NewApplyCollectiveUpdateProposalHandler(app.CollectivesKeeper), collectives.NewApplyCollectiveRemoveProposalHandler(app.CollectivesKeeper), + layer2.NewApplyJoinDappProposalHandler(app.Layer2Keeper), + layer2.NewApplyUpsertDappProposalHandler(app.Layer2Keeper), }) app.CustomGovKeeper.SetProposalRouter(proposalRouter) @@ -360,6 +398,7 @@ func NewInitApp( upgrade.NewAppModule(app.UpgradeKeeper, app.CustomGovKeeper), params.NewAppModule(app.ParamsKeeper), customslashing.NewAppModule(appCodec, app.CustomSlashingKeeper, app.AccountKeeper, app.BankKeeper, app.CustomStakingKeeper), + recovery.NewAppModule(appCodec, app.RecoveryKeeper, app.AccountKeeper, app.CustomStakingKeeper), customstaking.NewAppModule(app.CustomStakingKeeper, app.CustomGovKeeper), multistaking.NewAppModule(app.MultiStakingKeeper, app.BankKeeper, app.CustomGovKeeper, app.CustomStakingKeeper), customgov.NewAppModule(app.CustomGovKeeper), @@ -372,6 +411,7 @@ func NewInitApp( evidence.NewAppModule(app.EvidenceKeeper), custody.NewAppModule(app.CustodyKeeper, app.CustomGovKeeper, app.BankKeeper), collectives.NewAppModule(app.CollectivesKeeper), + layer2.NewAppModule(app.Layer2Keeper), ) // During begin block slashing happens after distr.BeginBlocker so that @@ -380,7 +420,7 @@ func NewInitApp( app.mm.SetOrderBeginBlockers( genutiltypes.ModuleName, paramstypes.ModuleName, govtypes.ModuleName, tokenstypes.ModuleName, authtypes.ModuleName, feeprocessingtypes.ModuleName, banktypes.ModuleName, - upgradetypes.ModuleName, slashingtypes.ModuleName, + upgradetypes.ModuleName, slashingtypes.ModuleName, recoverytypes.ModuleName, evidencetypes.ModuleName, stakingtypes.ModuleName, spendingtypes.ModuleName, ubitypes.ModuleName, distributortypes.ModuleName, multistakingtypes.ModuleName, custodytypes.ModuleName, @@ -388,11 +428,12 @@ func NewInitApp( distributortypes.ModuleName, multistakingtypes.ModuleName, custodytypes.ModuleName, baskettypes.ModuleName, collectivestypes.ModuleName, + layer2types.ModuleName, ) app.mm.SetOrderEndBlockers( banktypes.ModuleName, upgradetypes.ModuleName, tokenstypes.ModuleName, evidencetypes.ModuleName, genutiltypes.ModuleName, paramstypes.ModuleName, - slashingtypes.ModuleName, authtypes.ModuleName, + slashingtypes.ModuleName, authtypes.ModuleName, recoverytypes.ModuleName, govtypes.ModuleName, stakingtypes.ModuleName, feeprocessingtypes.ModuleName, @@ -400,6 +441,7 @@ func NewInitApp( distributortypes.ModuleName, multistakingtypes.ModuleName, custodytypes.ModuleName, baskettypes.ModuleName, collectivestypes.ModuleName, + layer2types.ModuleName, ) // NOTE: The genutils moodule must occur after staking so that pools are @@ -413,6 +455,7 @@ func NewInitApp( govtypes.ModuleName, // staking module is using the moniker identity registrar and gov module should be initialized before stakingtypes.ModuleName, slashingtypes.ModuleName, + recoverytypes.ModuleName, tokenstypes.ModuleName, feeprocessingtypes.ModuleName, genutiltypes.ModuleName, @@ -426,6 +469,7 @@ func NewInitApp( multistakingtypes.ModuleName, baskettypes.ModuleName, collectivestypes.ModuleName, + layer2types.ModuleName, ) app.mm.RegisterRoutes(app.Router(), app.QueryRouter(), encodingConfig.Amino) @@ -442,6 +486,7 @@ func NewInitApp( auth.NewAppModule(appCodec, app.AccountKeeper, simulation.RandomGenesisAccounts), bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper), customslashing.NewAppModule(appCodec, app.CustomSlashingKeeper, app.AccountKeeper, app.BankKeeper, app.CustomStakingKeeper), + recovery.NewAppModule(appCodec, app.RecoveryKeeper, app.AccountKeeper, app.CustomStakingKeeper), params.NewAppModule(app.ParamsKeeper), evidence.NewAppModule(app.EvidenceKeeper), ) diff --git a/cmd/sekaid/main.go b/cmd/sekaid/main.go index 935526e65..21cedeb3e 100644 --- a/cmd/sekaid/main.go +++ b/cmd/sekaid/main.go @@ -1,12 +1,16 @@ package main import ( + "encoding/json" + "fmt" "io" "os" "path/filepath" "github.com/KiraCore/sekai/app" + functionmeta "github.com/KiraCore/sekai/function_meta" genutilcli "github.com/KiraCore/sekai/x/genutil/client/cli" + govtypes "github.com/KiraCore/sekai/x/gov/types" customstaking "github.com/KiraCore/sekai/x/staking/client/cli" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" @@ -147,6 +151,7 @@ func initRootCmd(rootCmd *cobra.Command, encodingConfig params.EncodingConfig) { genutilcli.CollectGenTxsCmd(banktypes.GenesisBalancesIterator{}, app.DefaultNodeHome), genutilcli.GenTxCmd(app.ModuleBasics, encodingConfig.TxConfig, banktypes.GenesisBalancesIterator{}, app.DefaultNodeHome), genutilcli.GetNewGenesisFromExportedCmd(app.ModuleBasics, encodingConfig.TxConfig), + genutilcli.GetStandardGenesisExportedCmd(app.ModuleBasics, encodingConfig.TxConfig), customstaking.GenTxClaimCmd(banktypes.GenesisBalancesIterator{}, app.DefaultNodeHome), genutilcli.ValidateGenesisCmd(app.ModuleBasics), AddGenesisAccountCmd(app.DefaultNodeHome), @@ -166,6 +171,7 @@ func initRootCmd(rootCmd *cobra.Command, encodingConfig params.EncodingConfig) { keys.Commands(app.DefaultNodeHome), GetValAddressFromAddressCmd(), GetValConsAddressFromAddressCmd(), + GetExportMetadataCmd(), ) // add rosetta @@ -217,6 +223,29 @@ func GetValAddressFromAddressCmd() *cobra.Command { return cmd } +func GetExportMetadataCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "export-metadata", + Short: "Get metadata for client interaction to the node", + Args: cobra.ExactArgs(0), + RunE: func(cmd *cobra.Command, args []string) error { + metadata := make(map[string]interface{}) + metadata["transactions"] = functionmeta.GetFunctionList() + metadata["permissions"] = govtypes.PermMetadata + metadata["properties"] = govtypes.PropertyMetadata + + bz, err := json.MarshalIndent(metadata, "", " ") + if err != nil { + return err + } + fmt.Println(string(bz)) + return nil + }, + } + + return cmd +} + // GetValConsAddressFromAddressCmd returns a ValConsAddress from general address, used for conversion func GetValConsAddressFromAddressCmd() *cobra.Command { cmd := &cobra.Command{ diff --git a/go.mod b/go.mod index dc24e3ff9..6386a18d0 100644 --- a/go.mod +++ b/go.mod @@ -21,6 +21,7 @@ require ( github.com/tendermint/go-amino v0.16.0 github.com/tendermint/tendermint v0.34.22 github.com/tendermint/tm-db v0.6.6 + golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e google.golang.org/genproto v0.0.0-20220725144611-272f38e5d71b google.golang.org/grpc v1.50.0 google.golang.org/protobuf v1.28.1 diff --git a/proto/kira/distributor/genesis.proto b/proto/kira/distributor/genesis.proto index 657a2fa01..241157232 100644 --- a/proto/kira/distributor/genesis.proto +++ b/proto/kira/distributor/genesis.proto @@ -10,6 +10,14 @@ message ValidatorVote { int64 height = 2; } +message YearStartSnapshot { + int64 snapshot_time = 1; + string snapshot_amount = 2 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; +} + // GenesisState defines the distributor module's genesis state. message GenesisState { // fees that are kept in treasury that is not distributed yet - community pool @@ -28,6 +36,8 @@ message GenesisState { repeated ValidatorVote validator_votes = 4 [(gogoproto.nullable) = false]; // previous proposer string previous_proposer = 5; + // year start snapshot + YearStartSnapshot year_start_snapshot = 6 [(gogoproto.nullable) = false]; } // https://www.notion.so/kira-network/KIP-73-Fee-Reward-Distributor-v1-32b3d1dc90024befa7bb9680c6a425cd diff --git a/proto/kira/distributor/query.proto b/proto/kira/distributor/query.proto index 5b010d0d1..3ac39350b 100644 --- a/proto/kira/distributor/query.proto +++ b/proto/kira/distributor/query.proto @@ -5,6 +5,7 @@ import "cosmos/base/query/v1beta1/pagination.proto"; import "gogoproto/gogo.proto"; import "google/protobuf/any.proto"; import "google/api/annotations.proto"; +import "kira/distributor/genesis.proto"; option go_package = "github.com/KiraCore/sekai/x/distributor/types"; @@ -27,6 +28,10 @@ service Query { rpc SnapshotPeriodPerformance(QuerySnapshotPeriodPerformanceRequest) returns (QuerySnapshotPeriodPerformanceResponse) { option (google.api.http).get = "/kira/distributor/v1beta1/snapshot_period_performance/{validator_address}"; } + // Year start snapshot query + rpc YearStartSnapshot(QueryYearStartSnapshotRequest) returns (QueryYearStartSnapshotResponse) { + option (google.api.http).get = "/kira/distributor/v1beta1/year_start_snapshot"; + } } message QueryFeesTreasuryRequest { @@ -62,3 +67,8 @@ message QuerySnapshotPeriodPerformanceResponse { int64 performance = 1; int64 snapshot_period = 2; } + +message QueryYearStartSnapshotRequest {} +message QueryYearStartSnapshotResponse { + YearStartSnapshot snapshot = 1 [(gogoproto.nullable) = false]; +} diff --git a/proto/kira/gov/actor.proto b/proto/kira/gov/actor.proto index d0d5af2b9..81a3c6069 100644 --- a/proto/kira/gov/actor.proto +++ b/proto/kira/gov/actor.proto @@ -1,105 +1,105 @@ -syntax = "proto3"; -package kira.gov; - -import "gogoproto/gogo.proto"; -import "kira/gov/proposal.proto"; - -option go_package = "github.com/KiraCore/sekai/x/gov/types"; - -enum ActorStatus { - option (gogoproto.goproto_enum_prefix) = false; - - // Undefined status - UNDEFINED = 0 [(gogoproto.enumvalue_customname) = "Undefined"]; - - // Unclaimed status - UNCLAIMED = 1 [(gogoproto.enumvalue_customname) = "Unclaimed"]; - - // Active status - ACTIVE = 2 [(gogoproto.enumvalue_customname) = "Active"]; - - // Paused status - PAUSED = 3 [(gogoproto.enumvalue_customname) = "Paused"]; - - // Inactive status - INACTIVE = 4 [(gogoproto.enumvalue_customname) = "Inactive"]; - - // Jailed status - JAILED = 5 [(gogoproto.enumvalue_customname) = "Jailed"]; - - // Removed status - REMOVED = 6 [(gogoproto.enumvalue_customname) = "Removed"]; -} - -message Permissions { - repeated uint32 blacklist = 1; - repeated uint32 whitelist = 2; -} - -message NetworkActor { - bytes address = 1 [ - (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress", - (gogoproto.moretags) = "yaml:\"address\"" - ]; - - repeated uint64 roles = 2; - ActorStatus status = 3; - repeated VoteOption votes = 4; - Permissions permissions = 5; - uint64 skin = 6; -} - -message MsgWhitelistPermissions { - option (gogoproto.equal) = true; - - bytes proposer = 1 [ - (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress" - ]; - - bytes address = 2 [ - (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress", - (gogoproto.moretags) = "yaml:\"address\"" - ]; - - uint32 permission = 3; -} - -message MsgRemoveWhitelistedPermissions { - option (gogoproto.equal) = true; - - bytes proposer = 1 [ (gogoproto.casttype) = - "github.com/cosmos/cosmos-sdk/types.AccAddress" ]; - - bytes address = 2 [ - (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress", - (gogoproto.moretags) = "yaml:\"address\"" - ]; - - uint32 permission = 3; -} - -message MsgBlacklistPermissions { - bytes proposer = 1 [ - (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress" - ]; - - bytes address = 2 [ - (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress", - (gogoproto.moretags) = "yaml:\"address\"" - ]; - - uint32 permission = 3; -} - -message MsgRemoveBlacklistedPermissions { - bytes proposer = 1 [ - (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress" - ]; - - bytes address = 2 [ - (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress", - (gogoproto.moretags) = "yaml:\"address\"" - ]; - - uint32 permission = 3; +syntax = "proto3"; +package kira.gov; + +import "gogoproto/gogo.proto"; +import "kira/gov/proposal.proto"; + +option go_package = "github.com/KiraCore/sekai/x/gov/types"; + +enum ActorStatus { + option (gogoproto.goproto_enum_prefix) = false; + + // Undefined status + UNDEFINED = 0 [(gogoproto.enumvalue_customname) = "Undefined"]; + + // Unclaimed status + UNCLAIMED = 1 [(gogoproto.enumvalue_customname) = "Unclaimed"]; + + // Active status + ACTIVE = 2 [(gogoproto.enumvalue_customname) = "Active"]; + + // Paused status + PAUSED = 3 [(gogoproto.enumvalue_customname) = "Paused"]; + + // Inactive status + INACTIVE = 4 [(gogoproto.enumvalue_customname) = "Inactive"]; + + // Jailed status + JAILED = 5 [(gogoproto.enumvalue_customname) = "Jailed"]; + + // Removed status + REMOVED = 6 [(gogoproto.enumvalue_customname) = "Removed"]; +} + +message Permissions { + repeated uint32 blacklist = 1; + repeated uint32 whitelist = 2; +} + +message NetworkActor { + bytes address = 1 [ + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress", + (gogoproto.moretags) = "yaml:\"address\"" + ]; + + repeated uint64 roles = 2; + ActorStatus status = 3; + repeated VoteOption votes = 4; + Permissions permissions = 5; + uint64 skin = 6; +} + +message MsgWhitelistPermissions { + option (gogoproto.equal) = true; + + bytes proposer = 1 [ + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress" + ]; + + bytes address = 2 [ + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress", + (gogoproto.moretags) = "yaml:\"address\"" + ]; + + uint32 permission = 3; +} + +message MsgRemoveWhitelistedPermissions { + option (gogoproto.equal) = true; + + bytes proposer = 1 [ (gogoproto.casttype) = + "github.com/cosmos/cosmos-sdk/types.AccAddress" ]; + + bytes address = 2 [ + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress", + (gogoproto.moretags) = "yaml:\"address\"" + ]; + + uint32 permission = 3; +} + +message MsgBlacklistPermissions { + bytes proposer = 1 [ + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress" + ]; + + bytes address = 2 [ + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress", + (gogoproto.moretags) = "yaml:\"address\"" + ]; + + uint32 permission = 3; +} + +message MsgRemoveBlacklistedPermissions { + bytes proposer = 1 [ + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress" + ]; + + bytes address = 2 [ + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress", + (gogoproto.moretags) = "yaml:\"address\"" + ]; + + uint32 permission = 3; } \ No newline at end of file diff --git a/proto/kira/gov/allowed_messages.proto b/proto/kira/gov/allowed_messages.proto index 40124842e..64efc2058 100644 --- a/proto/kira/gov/allowed_messages.proto +++ b/proto/kira/gov/allowed_messages.proto @@ -1,12 +1,12 @@ -syntax = "proto3"; -package kira.gov; - -import "gogoproto/gogo.proto"; - -option go_package = "github.com/KiraCore/sekai/x/gov/types"; - -// defines allowed messages by network status, we only use this for poor network where -// number of validators is less than min_validators network property -message AllowedMessages { - repeated string messages = 1; -} +syntax = "proto3"; +package kira.gov; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/KiraCore/sekai/x/gov/types"; + +// defines allowed messages by network status, we only use this for poor network where +// number of validators is less than min_validators network property +message AllowedMessages { + repeated string messages = 1; +} diff --git a/proto/kira/gov/councilor.proto b/proto/kira/gov/councilor.proto index 91b699a05..fe61867f0 100644 --- a/proto/kira/gov/councilor.proto +++ b/proto/kira/gov/councilor.proto @@ -1,50 +1,50 @@ -syntax = "proto3"; -package kira.gov; - -import "gogoproto/gogo.proto"; - -option go_package = "github.com/KiraCore/sekai/x/gov/types"; - -message MsgClaimCouncilor { - option (gogoproto.equal) = true; - - bytes address = 1 [ - (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress", - (gogoproto.moretags) = "yaml:\"address\"" - ]; - string moniker = 2; - string username = 3; // friendly gov member name, MUST be globally unique (just like moniker) - string description = 4; // (optional), a longer description of the councilor - string social = 5; // (optional), comma-separated URL list of any social profiles such as Twitter, Telegram, etc… - string contact = 6; // (optional), email address, url, or another emergency contact - string avatar = 7; // (optional), URL to .SVG image or gif -} - -enum CouncilorStatus { - option (gogoproto.goproto_enum_prefix) = false; - - // Waiting status - WAITING = 0 [ (gogoproto.enumvalue_customname) = "CouncilorWaiting" ]; - - // Active status - ACTIVE = 1 [ (gogoproto.enumvalue_customname) = "CouncilorActive" ]; - - // Inactive status - INACTIVE = 2 [ (gogoproto.enumvalue_customname) = "CouncilorInactive" ]; - - // Paused status - PAUSED = 3 [ (gogoproto.enumvalue_customname) = "CouncilorPaused" ]; - - // Jailed status - JAILED = 4 [ (gogoproto.enumvalue_customname) = "CouncilorJailed" ]; -} - -message Councilor { - bytes address = 1 [ - (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress", - (gogoproto.moretags) = "yaml:\"address\"" - ]; - CouncilorStatus status = 2; - int64 rank = 3; - int64 abstention_counter = 4; -} +syntax = "proto3"; +package kira.gov; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/KiraCore/sekai/x/gov/types"; + +message MsgClaimCouncilor { + option (gogoproto.equal) = true; + + bytes address = 1 [ + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress", + (gogoproto.moretags) = "yaml:\"address\"" + ]; + string moniker = 2; + string username = 3; // friendly gov member name, MUST be globally unique (just like moniker) + string description = 4; // (optional), a longer description of the councilor + string social = 5; // (optional), comma-separated URL list of any social profiles such as Twitter, Telegram, etc… + string contact = 6; // (optional), email address, url, or another emergency contact + string avatar = 7; // (optional), URL to .SVG image or gif +} + +enum CouncilorStatus { + option (gogoproto.goproto_enum_prefix) = false; + + // Waiting status + COUNCILOR_WAITING = 0 [ (gogoproto.enumvalue_customname) = "CouncilorWaiting" ]; + + // Active status + COUNCILOR_ACTIVE = 1 [ (gogoproto.enumvalue_customname) = "CouncilorActive" ]; + + // Inactive status + COUNCILOR_INACTIVE = 2 [ (gogoproto.enumvalue_customname) = "CouncilorInactive" ]; + + // Paused status + COUNCILOR_PAUSED = 3 [ (gogoproto.enumvalue_customname) = "CouncilorPaused" ]; + + // Jailed status + COUNCILOR_JAILED = 4 [ (gogoproto.enumvalue_customname) = "CouncilorJailed" ]; +} + +message Councilor { + bytes address = 1 [ + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress", + (gogoproto.moretags) = "yaml:\"address\"" + ]; + CouncilorStatus status = 2; + int64 rank = 3; + int64 abstention_counter = 4; +} diff --git a/proto/kira/gov/execution_fee.proto b/proto/kira/gov/execution_fee.proto index 3a7474ff9..77d257f23 100644 --- a/proto/kira/gov/execution_fee.proto +++ b/proto/kira/gov/execution_fee.proto @@ -1,26 +1,26 @@ -syntax = "proto3"; -package kira.gov; - -import "gogoproto/gogo.proto"; - -option go_package = "github.com/KiraCore/sekai/x/gov/types"; - -message ExecutionFee { - string transaction_type = 1; // Type of the transaction that given permission allows to execute - uint64 execution_fee = 2; // How much user should pay for executing this specific function - uint64 failure_fee = 3; // How much user should pay if function fails to execute - uint64 timeout = 4; // After what time function execution should fail - uint64 default_parameters = 5; // Default values that the function in question will consume as input parameters before execution -} - -message MsgSetExecutionFee { - string transaction_type = 1; - uint64 execution_fee = 2; - uint64 failure_fee = 3; - uint64 timeout = 4; - uint64 default_parameters = 5; - bytes proposer = 6 [ - (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress" - ]; -} +syntax = "proto3"; +package kira.gov; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/KiraCore/sekai/x/gov/types"; + +message ExecutionFee { + string transaction_type = 1; // Type of the transaction that given permission allows to execute + uint64 execution_fee = 2; // How much user should pay for executing this specific function + uint64 failure_fee = 3; // How much user should pay if function fails to execute + uint64 timeout = 4; // After what time function execution should fail + uint64 default_parameters = 5; // Default values that the function in question will consume as input parameters before execution +} + +message MsgSetExecutionFee { + string transaction_type = 1; + uint64 execution_fee = 2; + uint64 failure_fee = 3; + uint64 timeout = 4; + uint64 default_parameters = 5; + bytes proposer = 6 [ + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress" + ]; +} \ No newline at end of file diff --git a/proto/kira/gov/genesis.proto b/proto/kira/gov/genesis.proto index 2a2b3e464..53171464e 100644 --- a/proto/kira/gov/genesis.proto +++ b/proto/kira/gov/genesis.proto @@ -1,41 +1,41 @@ -syntax = "proto3"; -package kira.gov; - -import "gogoproto/gogo.proto"; -import "kira/gov/actor.proto"; -import "kira/gov/role.proto"; -import "kira/gov/proposal.proto"; -import "kira/gov/data_registry.proto"; -import "kira/gov/execution_fee.proto"; -import "kira/gov/network_properties.proto"; -import "kira/gov/allowed_messages.proto"; -import "kira/gov/identity_registrar.proto"; - -option go_package = "github.com/KiraCore/sekai/x/gov/types"; - -message GenesisState { - // starting_proposal_id is the ID of the starting proposal. - uint64 starting_proposal_id = 1; - uint64 next_role_id = 2; - repeated Role roles = 3 [ (gogoproto.nullable) = false ]; - // role_permissions is the roles that are active from genesis. - map role_permissions = 4; - // NetworkActors are the actors that are saved from genesis. - repeated NetworkActor network_actors = 5; - - NetworkProperties network_properties = 6; - repeated ExecutionFee execution_fees = 7 [ (gogoproto.nullable) = false ]; - AllowedMessages poor_network_messages = 8; - - repeated Proposal proposals = 9 [ (gogoproto.nullable) = false ]; - repeated Vote votes = 10 [ (gogoproto.nullable) = false ]; - map data_registry = 11; - - repeated kira.gov.IdentityRecord identity_records = 12 [ (gogoproto.nullable) = false ]; - uint64 last_identity_record_id = 13; - - repeated kira.gov.IdentityRecordsVerify id_records_verify_requests = 14 [ (gogoproto.nullable) = false ]; - uint64 last_id_record_verify_request_id = 15; - - map proposal_durations = 16; -} +syntax = "proto3"; +package kira.gov; + +import "gogoproto/gogo.proto"; +import "kira/gov/actor.proto"; +import "kira/gov/role.proto"; +import "kira/gov/proposal.proto"; +import "kira/gov/data_registry.proto"; +import "kira/gov/execution_fee.proto"; +import "kira/gov/network_properties.proto"; +import "kira/gov/allowed_messages.proto"; +import "kira/gov/identity_registrar.proto"; + +option go_package = "github.com/KiraCore/sekai/x/gov/types"; + +message GenesisState { + // starting_proposal_id is the ID of the starting proposal. + uint64 starting_proposal_id = 1; + uint64 next_role_id = 2; + repeated Role roles = 3 [ (gogoproto.nullable) = false ]; + // role_permissions is the roles that are active from genesis. + map role_permissions = 4; + // NetworkActors are the actors that are saved from genesis. + repeated NetworkActor network_actors = 5; + + NetworkProperties network_properties = 6; + repeated ExecutionFee execution_fees = 7 [ (gogoproto.nullable) = false ]; + AllowedMessages poor_network_messages = 8; + + repeated Proposal proposals = 9 [ (gogoproto.nullable) = false ]; + repeated Vote votes = 10 [ (gogoproto.nullable) = false ]; + map data_registry = 11; + + repeated kira.gov.IdentityRecord identity_records = 12 [ (gogoproto.nullable) = false ]; + uint64 last_identity_record_id = 13; + + repeated kira.gov.IdentityRecordsVerify id_records_verify_requests = 14 [ (gogoproto.nullable) = false ]; + uint64 last_id_record_verify_request_id = 15; + + map proposal_durations = 16; +} diff --git a/proto/kira/gov/identity_registrar.proto b/proto/kira/gov/identity_registrar.proto index 7c5804186..6f77fa8fe 100644 --- a/proto/kira/gov/identity_registrar.proto +++ b/proto/kira/gov/identity_registrar.proto @@ -1,81 +1,81 @@ -syntax = "proto3"; -package kira.gov; - -import "gogoproto/gogo.proto"; -import "google/protobuf/timestamp.proto"; - -option go_package = "github.com/KiraCore/sekai/x/gov/types"; - -message IdentityRecord { - uint64 id = 1; - string address = 2; - string key = 3; - string value = 4; - google.protobuf.Timestamp date = 5 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false]; - repeated string verifiers = 6 ; -} - -message IdentityInfoEntry { - string key = 1; - string info = 2; -} - -message MsgRegisterIdentityRecords { - bytes address = 1 [ - (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress", - (gogoproto.moretags) = "yaml:\"address\"" - ]; - repeated IdentityInfoEntry infos = 2 [ (gogoproto.nullable) = false ]; -} - -message MsgDeleteIdentityRecords { - bytes address = 1 [ - (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress", - (gogoproto.moretags) = "yaml:\"address\"" - ]; - repeated string keys = 2; -} - -message IdentityRecordsVerify { - uint64 id = 1; - string address = 2; - string verifier = 3; - repeated uint64 recordIds = 4; - string tip = 5 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Coin", - (gogoproto.nullable) = false - ]; - google.protobuf.Timestamp lastRecordEditDate = 6 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false]; -} - -message MsgRequestIdentityRecordsVerify { - bytes address = 1 [ - (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress", - (gogoproto.moretags) = "yaml:\"address\"" - ]; - bytes verifier = 2 [ - (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress", - (gogoproto.moretags) = "yaml:\"verifier\"" - ]; - repeated uint64 record_ids = 3; - string tip = 4 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Coin", - (gogoproto.nullable) = false - ]; -} - -message MsgHandleIdentityRecordsVerifyRequest { - bytes verifier = 1 [ - (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress", - (gogoproto.moretags) = "yaml:\"verifier\"" - ]; - uint64 verify_request_id = 2; - bool yes = 3; -} -message MsgCancelIdentityRecordsVerifyRequest { - bytes executor = 1 [ - (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress", - (gogoproto.moretags) = "yaml:\"executor\"" - ]; - uint64 verify_request_id = 2; +syntax = "proto3"; +package kira.gov; + +import "gogoproto/gogo.proto"; +import "google/protobuf/timestamp.proto"; + +option go_package = "github.com/KiraCore/sekai/x/gov/types"; + +message IdentityRecord { + uint64 id = 1; + string address = 2; + string key = 3; + string value = 4; + google.protobuf.Timestamp date = 5 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false]; + repeated string verifiers = 6 ; +} + +message IdentityInfoEntry { + string key = 1; + string info = 2; +} + +message MsgRegisterIdentityRecords { + bytes address = 1 [ + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress", + (gogoproto.moretags) = "yaml:\"address\"" + ]; + repeated IdentityInfoEntry infos = 2 [ (gogoproto.nullable) = false ]; +} + +message MsgDeleteIdentityRecords { + bytes address = 1 [ + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress", + (gogoproto.moretags) = "yaml:\"address\"" + ]; + repeated string keys = 2; +} + +message IdentityRecordsVerify { + uint64 id = 1; + string address = 2; + string verifier = 3; + repeated uint64 recordIds = 4; + string tip = 5 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Coin", + (gogoproto.nullable) = false + ]; + google.protobuf.Timestamp lastRecordEditDate = 6 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false]; +} + +message MsgRequestIdentityRecordsVerify { + bytes address = 1 [ + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress", + (gogoproto.moretags) = "yaml:\"address\"" + ]; + bytes verifier = 2 [ + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress", + (gogoproto.moretags) = "yaml:\"verifier\"" + ]; + repeated uint64 record_ids = 3; + string tip = 4 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Coin", + (gogoproto.nullable) = false + ]; +} + +message MsgHandleIdentityRecordsVerifyRequest { + bytes verifier = 1 [ + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress", + (gogoproto.moretags) = "yaml:\"verifier\"" + ]; + uint64 verify_request_id = 2; + bool yes = 3; +} +message MsgCancelIdentityRecordsVerifyRequest { + bytes executor = 1 [ + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress", + (gogoproto.moretags) = "yaml:\"executor\"" + ]; + uint64 verify_request_id = 2; } \ No newline at end of file diff --git a/proto/kira/gov/network_properties.proto b/proto/kira/gov/network_properties.proto index a83824c7d..d1ecaa72e 100644 --- a/proto/kira/gov/network_properties.proto +++ b/proto/kira/gov/network_properties.proto @@ -53,6 +53,27 @@ enum NetworkProperty { MIN_COLLECTIVE_BONDING_TIME = 35 [(gogoproto.enumvalue_customname) = "MinCollectiveBondingTime"]; // allowed time to reach min_collective_bond default: 86400s MAX_COLLECTIVE_OUTPUTS = 36 [(gogoproto.enumvalue_customname) = "MaxCollectiveOutputs"]; // limitation the maximum number of spending pools configuration per collective MIN_COLLECTIVE_CLAIM_PERIOD = 37 [(gogoproto.enumvalue_customname) = "MinCollectiveClaimPeriod"]; // in seconds, default 14400 - 4 hours + VALIDATOR_RECOVERY_BOND = 38 [(gogoproto.enumvalue_customname) = "ValidatorRecoveryBond"]; // amount of KEX to spend for issuing validator recovery token + MAX_ANNUAL_INFLATION = 39 [(gogoproto.enumvalue_customname) = "MaxAnnualInflation"]; // range of 0 and 0.35 + MAX_PROPOSAL_TITLE_SIZE = 40 [(gogoproto.enumvalue_customname) = "MaxProposalTitleSize"]; // maximum poll title size + MAX_PROPOSAL_DESCRIPTION_SIZE = 41 [(gogoproto.enumvalue_customname) = "MaxProposalDescriptionSize"]; // maximum poll description size + MAX_PROPOSAL_POLL_OPTION_SIZE = 42 [(gogoproto.enumvalue_customname) = "MaxProposalPollOptionSize"]; // maximum poll option size + MAX_PROPOSAL_POLL_OPTION_COUNT = 43 [(gogoproto.enumvalue_customname) = "MaxProposalPollOptionCount"]; // maximum poll option count + MAX_PROPOSAL_REFERENCE_SIZE = 44 [(gogoproto.enumvalue_customname) = "MaxProposalReferenceSize"]; // maximum poll reference size + MAX_PROPOSAL_CHECKSUM_SIZE = 45 [(gogoproto.enumvalue_customname) = "MaxProposalChecksumSize"]; // maximum poll checksum size + MIN_DAPP_BOND = 46 [(gogoproto.enumvalue_customname) = "MinDappBond"]; // default 1’000’000 KEX + MAX_DAPP_BOND = 47 [(gogoproto.enumvalue_customname) = "MaxDappBond"]; // default 10’000’000 KEX + DAPP_LIQUIDATION_THRESHOLD = 48 [(gogoproto.enumvalue_customname) = "DappLiquidationThreshold"]; // default 100’000 KEX + DAPP_LIQUIDATION_PERIOD = 49 [(gogoproto.enumvalue_customname) = "DappLiquidationPeriod"]; // default 2419200, ~28d + DAPP_BOND_DURATION = 50 [(gogoproto.enumvalue_customname) = "DappBondDuration"]; // default 7d - 604800s + DAPP_VERIFIER_BOND = 51 [(gogoproto.enumvalue_customname) = "DappVerifierBond"]; // percentage of lp token supply to be put to be the verifier of the dapp by default 0.1% + DAPP_AUTO_DENOUNCE_TIME = 52 [(gogoproto.enumvalue_customname) = "DappAutoDenounceTime"]; // in seconds (default 60), time the dapp leader allowed to send `execute-dapp-tx` + DAPP_MISCHANCE_RANK_DECREASE_AMOUNT = 53 [(gogoproto.enumvalue_customname) = "DappMischanceRankDecreaseAmount"]; + DAPP_MAX_MISCHANCE = 54 [(gogoproto.enumvalue_customname) = "DappMaxMischance"]; + DAPP_INACTIVE_RANK_DECREASE_PERCENT = 55 [(gogoproto.enumvalue_customname) = "DappInactiveRankDecreasePercent"]; + DAPP_POOL_SLIPPAGE_DEFAULT = 56 [(gogoproto.enumvalue_customname) = "DappPoolSlippageDefault"]; + MINTING_FT_FEE = 57 [ (gogoproto.enumvalue_customname) = "MintingFtFee" ]; + MINTING_NFT_FEE = 58 [ (gogoproto.enumvalue_customname) = "MintingNftFee" ]; } message NetworkPropertyValue { @@ -116,4 +137,34 @@ message NetworkProperties { uint64 min_collective_bonding_time = 36; // allowed time to reach min_collective_bond default: 86400s uint64 max_collective_outputs = 37; // limitation the maximum number of spending pools configuration per collective uint64 min_collective_claim_period = 38; // in seconds, default 14400 - 4 hours + uint64 validator_recovery_bond = 39; // amount of KEX to spend for issuing validator recovery token + string max_annual_inflation = 40 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; // maximum % of kex by which supply can increase over the period of 1 year + uint64 max_proposal_title_size = 41; // maximum title size in the proposal + uint64 max_proposal_description_size = 42; // maximum description size in the proposal + uint64 max_proposal_poll_option_size = 43; // maximum option size in the proposal + uint64 max_proposal_poll_option_count = 44; // maximum possible choices in the proposal + uint64 max_proposal_reference_size = 45; // maximum reference size in the proposal + uint64 max_proposal_checksum_size = 46; // maximum checksum size in the proposal + uint64 min_dapp_bond = 47; // default 1’000’000 KEX + uint64 max_dapp_bond = 48; // default 10’000’000 KEX + uint64 dapp_liquidation_threshold = 49; // default 100’000 KEX + uint64 dapp_liquidation_period = 50; // default 2419200, ~28d + uint64 dapp_bond_duration = 51; // default 7d - 604800s + string dapp_verifier_bond = 52 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; // percentage of lp token supply to be put to be the verifier of the dapp by default 0.1% + uint64 dapp_auto_denounce_time = 53; // in seconds (default 60), time the dapp leader allowed to send `execute-dapp-tx` + uint64 dapp_mischance_rank_decrease_amount = 54; + uint64 dapp_max_mischance = 55; + uint64 dapp_inactive_rank_decrease_percent = 56; + string dapp_pool_slippage_default = 57 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; // default 0.1, that is 10% + uint64 minting_ft_fee = 58; // default 100’000’000’000 ukex - 100k KEX + uint64 minting_nft_fee = 59; // default 100’000’000’000 ukex - 100k KEX } diff --git a/proto/kira/gov/permission.proto b/proto/kira/gov/permission.proto index f064cc9ad..b41538ef9 100644 --- a/proto/kira/gov/permission.proto +++ b/proto/kira/gov/permission.proto @@ -220,4 +220,10 @@ enum PermValue { // PERMISSION_VOTE_JAIL_COUNCILOR_PROPOSAL defines the permission needed to vote on jail councilors proposal PERMISSION_VOTE_JAIL_COUNCILOR_PROPOSAL = 65 [(gogoproto.enumvalue_customname) = "PermVoteJailCouncilorProposal"]; + + // PERMISSION_CREATE_POLL_PROPOSAL defines the permission needed to create a poll proposal. + PERMISSION_CREATE_POLL_PROPOSAL = 66 [(gogoproto.enumvalue_customname) = "PermCreatePollProposal"]; + + // PERMISSION_CREATE_DAPP_PROPOSAL_WITHOUT_BOND defines the permission needed to create a dapp proposal without bond + PERMISSION_CREATE_DAPP_PROPOSAL_WITHOUT_BOND = 67 [(gogoproto.enumvalue_customname) = "PermCreateDappProposalWithoutBond"]; } diff --git a/proto/kira/gov/poll.proto b/proto/kira/gov/poll.proto new file mode 100644 index 000000000..d4a366eed --- /dev/null +++ b/proto/kira/gov/poll.proto @@ -0,0 +1,114 @@ +syntax = "proto3"; +package kira.gov; + +import "gogoproto/gogo.proto"; +import "google/protobuf/timestamp.proto"; +import "google/protobuf/any.proto"; +import "cosmos_proto/cosmos.proto"; +import "kira/gov/role.proto"; +import "kira/gov/permission.proto"; +import "kira/gov/network_properties.proto"; + +option go_package = "github.com/KiraCore/sekai/x/gov/types"; + +enum PollVoteOption { + option (gogoproto.goproto_enum_prefix) = false; + + // VOTE_OPTION_UNSPECIFIED defines a no-op vote option. + POLL_VOTE_OPTION_UNSPECIFIED = 0 [(gogoproto.enumvalue_customname) = "PollOptionEmpty"]; + // VOTE_OPTION_ABSTAIN defines an abstain vote option. + POLL_VOTE_OPTION_ABSTAIN = 1 [(gogoproto.enumvalue_customname) = "PollOptionAbstain"]; + // VOTE_OPTION_NO defines a no vote option. + POLL_VOTE_OPTION_CUSTOM = 2 [(gogoproto.enumvalue_customname) = "PollOptionCustom"]; + // VOTE_OPTION_NO_WITH_VETO defines a no with veto vote option. + POLL_VOTE_OPTION_NO_WITH_VETO = 3 [(gogoproto.enumvalue_customname) = "PollOptionNoWithVeto"]; +} + +enum PollResult { + option (gogoproto.goproto_enum_prefix) = false; + + POLL_RESULT_UNKNOWN = 0 [(gogoproto.enumvalue_customname) = "PollUnknown"]; + POLL_RESULT_PASSED = 1 [(gogoproto.enumvalue_customname) = "PollPassed"]; + POLL_RESULT_REJECTED = 2 [(gogoproto.enumvalue_customname) = "PollRejected"]; + POLL_RESULT_REJECTED_WITH_VETO = 3 [(gogoproto.enumvalue_customname) = "PollRejectedWithVeto"]; + POLL_PENDING = 4 [(gogoproto.enumvalue_customname) = "PollPending"]; + POLL_RESULT_QUORUM_NOT_REACHED = 5 [(gogoproto.enumvalue_customname) = "PollQuorumNotReached"]; +} + +message PollVote { + uint64 poll_id = 1; + + bytes voter = 2 [ + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress" + ]; + + PollVoteOption option = 3; + string custom_value = 5; +} + +message PollOptions { + repeated string values = 1; + uint64 count = 2; + string type = 3; + uint64 choices = 4; +} + +message AddressPolls { + bytes address = 1 [ + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress", + (gogoproto.moretags) = "yaml:\"address\"" + ]; + + repeated uint64 ids = 2; +} + +message Poll { + option (gogoproto.goproto_getters) = false; + uint64 poll_id = 1; + + bytes creator = 2 [ + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress" + ]; + + string title = 3; + string description = 4; + string reference = 5; + string checksum = 6; + repeated uint64 roles = 7; + PollOptions options = 8; + + google.protobuf.Timestamp voting_end_time = 9 + [(gogoproto.stdtime) = true, (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"voting_end_time\""]; + + PollResult result = 10; +} + +message MsgPollVote { + uint64 poll_id = 1; + + bytes voter = 2 [ + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress" + ]; + + PollVoteOption option = 3; + string value = 4; +} + +message MsgPollCreate { + option (gogoproto.goproto_getters) = false; + + bytes creator = 1 [ + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress" + ]; + + string title = 2; + string description = 3; + string reference = 4; + string checksum = 5; + repeated string roles = 6; + repeated string poll_values = 7; + uint64 value_count = 8; + string value_type = 9; + uint64 possible_choices = 10; + string duration = 11; +} diff --git a/proto/kira/gov/proposal.proto b/proto/kira/gov/proposal.proto index c87fa5b4c..c31edf301 100644 --- a/proto/kira/gov/proposal.proto +++ b/proto/kira/gov/proposal.proto @@ -1,255 +1,255 @@ -syntax = "proto3"; -package kira.gov; - -import "gogoproto/gogo.proto"; -import "google/protobuf/timestamp.proto"; -import "google/protobuf/any.proto"; -import "cosmos_proto/cosmos.proto"; -import "kira/gov/role.proto"; -import "kira/gov/permission.proto"; -import "kira/gov/network_properties.proto"; - -option go_package = "github.com/KiraCore/sekai/x/gov/types"; - -// VoteOption enumerates the valid vote options for a given governance proposal. -enum VoteOption { - option (gogoproto.goproto_enum_prefix) = false; - - // VOTE_OPTION_UNSPECIFIED defines a no-op vote option. - VOTE_OPTION_UNSPECIFIED = 0 [(gogoproto.enumvalue_customname) = "OptionEmpty"]; - // VOTE_OPTION_YES defines a yes vote option. - VOTE_OPTION_YES = 1 [(gogoproto.enumvalue_customname) = "OptionYes"]; - // VOTE_OPTION_ABSTAIN defines an abstain vote option. - VOTE_OPTION_ABSTAIN = 2 [(gogoproto.enumvalue_customname) = "OptionAbstain"]; - // VOTE_OPTION_NO defines a no vote option. - VOTE_OPTION_NO = 3 [(gogoproto.enumvalue_customname) = "OptionNo"]; - // VOTE_OPTION_NO_WITH_VETO defines a no with veto vote option. - VOTE_OPTION_NO_WITH_VETO = 4 [(gogoproto.enumvalue_customname) = "OptionNoWithVeto"]; -} - -enum VoteResult { - option (gogoproto.goproto_enum_prefix) = false; - - VOTE_RESULT_UNKNOWN = 0 [(gogoproto.enumvalue_customname) = "Unknown"]; - VOTE_RESULT_PASSED = 1 [(gogoproto.enumvalue_customname) = "Passed"]; - VOTE_RESULT_REJECTED = 2 [(gogoproto.enumvalue_customname) = "Rejected"]; - VOTE_RESULT_REJECTED_WITH_VETO = 3 [(gogoproto.enumvalue_customname) = "RejectedWithVeto"]; - VOTE_PENDING = 4 [(gogoproto.enumvalue_customname) = "Pending"]; - VOTE_RESULT_QUORUM_NOT_REACHED = 5 [(gogoproto.enumvalue_customname) = "QuorumNotReached"]; - VOTE_RESULT_ENACTMENT = 6 [(gogoproto.enumvalue_customname) = "Enactment"]; - VOTE_RESULT_PASSED_WITH_EXEC_FAIL = 7 [(gogoproto.enumvalue_customname) = "PassedWithExecFail"]; -} - -message Vote { - uint64 proposal_id = 1; - - bytes voter = 2 [ - (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress" - ]; - - VoteOption option = 3; - string slash = 4 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = false - ]; // Note: SlashProposal requires this field to determine average value -} - -message MsgVoteProposal { - uint64 proposal_id = 1; - - bytes voter = 2 [ - (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress" - ]; - - VoteOption option = 3; - string slash = 4 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = false - ]; // Note: SlashProposal requires this field to determine average value -} - - -message Proposal { - option (gogoproto.goproto_getters) = false; - uint64 proposal_id = 1; - - string title = 2; - string description = 3; - google.protobuf.Any content = 4 [(cosmos_proto.accepts_interface) = "Content"]; - - google.protobuf.Timestamp submit_time = 5 - [(gogoproto.stdtime) = true, (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"submit_time\""]; - google.protobuf.Timestamp voting_end_time = 6 - [(gogoproto.stdtime) = true, (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"voting_end_time\""]; - google.protobuf.Timestamp enactment_end_time = 7 - [(gogoproto.stdtime) = true, (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"enactment_end_time\""]; - - int64 min_voting_end_block_height = 8; - int64 min_enactment_end_block_height = 9; - - VoteResult result = 10; - string exec_result = 11; // describes execution result -} - -message WhitelistAccountPermissionProposal { - option (cosmos_proto.implements_interface) = "Content"; - option (gogoproto.equal) = true; - - bytes address = 1 [ - (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress", - (gogoproto.moretags) = "yaml:\"address\"" - ]; - - PermValue permission = 2; -} - -message BlacklistAccountPermissionProposal { - option (cosmos_proto.implements_interface) = "Content"; - option (gogoproto.equal) = true; - - bytes address = 1 [ - (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress", - (gogoproto.moretags) = "yaml:\"address\"" - ]; - PermValue permission = 2; -} - -message RemoveWhitelistedAccountPermissionProposal { - option (cosmos_proto.implements_interface) = "Content"; - option (gogoproto.equal) = true; - - bytes address = 1 [ - (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress", - (gogoproto.moretags) = "yaml:\"address\"" - ]; - PermValue permission = 2; -} - -message RemoveBlacklistedAccountPermissionProposal { - option (cosmos_proto.implements_interface) = "Content"; - option (gogoproto.equal) = true; - - bytes address = 1 [ - (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress", - (gogoproto.moretags) = "yaml:\"address\"" - ]; - PermValue permission = 2; -} - -message AssignRoleToAccountProposal { - option (cosmos_proto.implements_interface) = "Content"; - option (gogoproto.equal) = true; - - bytes address = 1 [ - (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress", - (gogoproto.moretags) = "yaml:\"address\"" - ]; - string role_identifier = 2; -} - -message UnassignRoleFromAccountProposal { - option (cosmos_proto.implements_interface) = "Content"; - option (gogoproto.equal) = true; - - bytes address = 1 [ - (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress", - (gogoproto.moretags) = "yaml:\"address\"" - ]; - string role_identifier = 2; -} - -message WhitelistRolePermissionProposal { - option (cosmos_proto.implements_interface) = "Content"; - option (gogoproto.equal) = true; - - string role_identifier = 1; - PermValue permission = 2; -} - -message BlacklistRolePermissionProposal { - option (cosmos_proto.implements_interface) = "Content"; - option (gogoproto.equal) = true; - - string role_identifier = 1; - PermValue permission = 2; -} - -message RemoveWhitelistedRolePermissionProposal { - option (cosmos_proto.implements_interface) = "Content"; - option (gogoproto.equal) = true; - - string role_sid = 1; - PermValue permission = 2; -} - -message RemoveBlacklistedRolePermissionProposal { - option (cosmos_proto.implements_interface) = "Content"; - option (gogoproto.equal) = true; - - string role_sid = 1; - PermValue permission = 2; -} - -message SetNetworkPropertyProposal { - option (cosmos_proto.implements_interface) = "Content"; - option (gogoproto.equal) = true; - - NetworkProperty network_property = 1; - NetworkPropertyValue value = 2 [(gogoproto.nullable) = false]; -} - -message UpsertDataRegistryProposal { - option (cosmos_proto.implements_interface) = "Content"; - option (gogoproto.equal) = true; - - string key = 1; - - string hash = 2; - - string reference = 3; - - string encoding = 4; - - uint64 size = 5; -} - -message SetPoorNetworkMessagesProposal { - repeated string messages = 1; -} - -message CreateRoleProposal { - option (cosmos_proto.implements_interface) = "Content"; - option (gogoproto.equal) = true; - - string role_sid = 1; - string role_description = 2; - repeated PermValue whitelisted_permissions = 3; - repeated PermValue blacklisted_permissions = 4; -} - -message RemoveRoleProposal { - option (cosmos_proto.implements_interface) = "Content"; - option (gogoproto.equal) = true; - - string role_sid = 1; -} - -message SetProposalDurationsProposal { - repeated string typeof_proposals = 1; - repeated uint64 proposal_durations = 2; -} - -message ProposalResetWholeCouncilorRank { - bytes proposer = 1 [ - (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress" - ]; - string description = 2; -} - -message ProposalJailCouncilor { - bytes proposer = 1 [ - (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress" - ]; - string description = 2; - repeated string councilors = 3; +syntax = "proto3"; +package kira.gov; + +import "gogoproto/gogo.proto"; +import "google/protobuf/timestamp.proto"; +import "google/protobuf/any.proto"; +import "cosmos_proto/cosmos.proto"; +import "kira/gov/role.proto"; +import "kira/gov/permission.proto"; +import "kira/gov/network_properties.proto"; + +option go_package = "github.com/KiraCore/sekai/x/gov/types"; + +// VoteOption enumerates the valid vote options for a given governance proposal. +enum VoteOption { + option (gogoproto.goproto_enum_prefix) = false; + + // VOTE_OPTION_UNSPECIFIED defines a no-op vote option. + VOTE_OPTION_UNSPECIFIED = 0 [(gogoproto.enumvalue_customname) = "OptionEmpty"]; + // VOTE_OPTION_YES defines a yes vote option. + VOTE_OPTION_YES = 1 [(gogoproto.enumvalue_customname) = "OptionYes"]; + // VOTE_OPTION_ABSTAIN defines an abstain vote option. + VOTE_OPTION_ABSTAIN = 2 [(gogoproto.enumvalue_customname) = "OptionAbstain"]; + // VOTE_OPTION_NO defines a no vote option. + VOTE_OPTION_NO = 3 [(gogoproto.enumvalue_customname) = "OptionNo"]; + // VOTE_OPTION_NO_WITH_VETO defines a no with veto vote option. + VOTE_OPTION_NO_WITH_VETO = 4 [(gogoproto.enumvalue_customname) = "OptionNoWithVeto"]; +} + +enum VoteResult { + option (gogoproto.goproto_enum_prefix) = false; + + VOTE_RESULT_UNKNOWN = 0 [(gogoproto.enumvalue_customname) = "Unknown"]; + VOTE_RESULT_PASSED = 1 [(gogoproto.enumvalue_customname) = "Passed"]; + VOTE_RESULT_REJECTED = 2 [(gogoproto.enumvalue_customname) = "Rejected"]; + VOTE_RESULT_REJECTED_WITH_VETO = 3 [(gogoproto.enumvalue_customname) = "RejectedWithVeto"]; + VOTE_PENDING = 4 [(gogoproto.enumvalue_customname) = "Pending"]; + VOTE_RESULT_QUORUM_NOT_REACHED = 5 [(gogoproto.enumvalue_customname) = "QuorumNotReached"]; + VOTE_RESULT_ENACTMENT = 6 [(gogoproto.enumvalue_customname) = "Enactment"]; + VOTE_RESULT_PASSED_WITH_EXEC_FAIL = 7 [(gogoproto.enumvalue_customname) = "PassedWithExecFail"]; +} + +message Vote { + uint64 proposal_id = 1; + + bytes voter = 2 [ + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress" + ]; + + VoteOption option = 3; + string slash = 4 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; // Note: SlashProposal requires this field to determine average value +} + +message MsgVoteProposal { + uint64 proposal_id = 1; + + bytes voter = 2 [ + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress" + ]; + + VoteOption option = 3; + string slash = 4 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; // Note: SlashProposal requires this field to determine average value +} + + +message Proposal { + option (gogoproto.goproto_getters) = false; + uint64 proposal_id = 1; + + string title = 2; + string description = 3; + google.protobuf.Any content = 4 [(cosmos_proto.accepts_interface) = "Content"]; + + google.protobuf.Timestamp submit_time = 5 + [(gogoproto.stdtime) = true, (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"submit_time\""]; + google.protobuf.Timestamp voting_end_time = 6 + [(gogoproto.stdtime) = true, (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"voting_end_time\""]; + google.protobuf.Timestamp enactment_end_time = 7 + [(gogoproto.stdtime) = true, (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"enactment_end_time\""]; + + int64 min_voting_end_block_height = 8; + int64 min_enactment_end_block_height = 9; + + VoteResult result = 10; + string exec_result = 11; // describes execution result +} + +message WhitelistAccountPermissionProposal { + option (cosmos_proto.implements_interface) = "Content"; + option (gogoproto.equal) = true; + + bytes address = 1 [ + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress", + (gogoproto.moretags) = "yaml:\"address\"" + ]; + + PermValue permission = 2; +} + +message BlacklistAccountPermissionProposal { + option (cosmos_proto.implements_interface) = "Content"; + option (gogoproto.equal) = true; + + bytes address = 1 [ + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress", + (gogoproto.moretags) = "yaml:\"address\"" + ]; + PermValue permission = 2; +} + +message RemoveWhitelistedAccountPermissionProposal { + option (cosmos_proto.implements_interface) = "Content"; + option (gogoproto.equal) = true; + + bytes address = 1 [ + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress", + (gogoproto.moretags) = "yaml:\"address\"" + ]; + PermValue permission = 2; +} + +message RemoveBlacklistedAccountPermissionProposal { + option (cosmos_proto.implements_interface) = "Content"; + option (gogoproto.equal) = true; + + bytes address = 1 [ + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress", + (gogoproto.moretags) = "yaml:\"address\"" + ]; + PermValue permission = 2; +} + +message AssignRoleToAccountProposal { + option (cosmos_proto.implements_interface) = "Content"; + option (gogoproto.equal) = true; + + bytes address = 1 [ + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress", + (gogoproto.moretags) = "yaml:\"address\"" + ]; + string role_identifier = 2; +} + +message UnassignRoleFromAccountProposal { + option (cosmos_proto.implements_interface) = "Content"; + option (gogoproto.equal) = true; + + bytes address = 1 [ + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress", + (gogoproto.moretags) = "yaml:\"address\"" + ]; + string role_identifier = 2; +} + +message WhitelistRolePermissionProposal { + option (cosmos_proto.implements_interface) = "Content"; + option (gogoproto.equal) = true; + + string role_identifier = 1; + PermValue permission = 2; +} + +message BlacklistRolePermissionProposal { + option (cosmos_proto.implements_interface) = "Content"; + option (gogoproto.equal) = true; + + string role_identifier = 1; + PermValue permission = 2; +} + +message RemoveWhitelistedRolePermissionProposal { + option (cosmos_proto.implements_interface) = "Content"; + option (gogoproto.equal) = true; + + string role_sid = 1; + PermValue permission = 2; +} + +message RemoveBlacklistedRolePermissionProposal { + option (cosmos_proto.implements_interface) = "Content"; + option (gogoproto.equal) = true; + + string role_sid = 1; + PermValue permission = 2; +} + +message SetNetworkPropertyProposal { + option (cosmos_proto.implements_interface) = "Content"; + option (gogoproto.equal) = true; + + NetworkProperty network_property = 1; + NetworkPropertyValue value = 2 [(gogoproto.nullable) = false]; +} + +message UpsertDataRegistryProposal { + option (cosmos_proto.implements_interface) = "Content"; + option (gogoproto.equal) = true; + + string key = 1; + + string hash = 2; + + string reference = 3; + + string encoding = 4; + + uint64 size = 5; +} + +message SetPoorNetworkMessagesProposal { + repeated string messages = 1; +} + +message CreateRoleProposal { + option (cosmos_proto.implements_interface) = "Content"; + option (gogoproto.equal) = true; + + string role_sid = 1; + string role_description = 2; + repeated PermValue whitelisted_permissions = 3; + repeated PermValue blacklisted_permissions = 4; +} + +message RemoveRoleProposal { + option (cosmos_proto.implements_interface) = "Content"; + option (gogoproto.equal) = true; + + string role_sid = 1; +} + +message SetProposalDurationsProposal { + repeated string typeof_proposals = 1; + repeated uint64 proposal_durations = 2; +} + +message ProposalResetWholeCouncilorRank { + bytes proposer = 1 [ + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress" + ]; + string description = 2; +} + +message ProposalJailCouncilor { + bytes proposer = 1 [ + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress" + ]; + string description = 2; + repeated string councilors = 3; } \ No newline at end of file diff --git a/proto/kira/gov/query.proto b/proto/kira/gov/query.proto index acf8183d1..09efa48f9 100644 --- a/proto/kira/gov/query.proto +++ b/proto/kira/gov/query.proto @@ -9,6 +9,7 @@ import "kira/gov/role.proto"; import "kira/gov/execution_fee.proto"; import "kira/gov/network_properties.proto"; import "kira/gov/proposal.proto"; +import "kira/gov/poll.proto"; import "kira/gov/identity_registrar.proto"; import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; @@ -125,27 +126,54 @@ service Query { rpc ProposalDuration(QueryProposalDuration) returns (QueryProposalDurationResponse) { option (google.api.http).get = "/kira/gov/proposal_duration/{proposal_type}"; } - // QueryCouncilorslist - all councilors (waiting or not), including their corresponding statuses, + // Councilors - all councilors (waiting or not), including their corresponding statuses, // ranks & abstenation counters - add sub-query to search by specific KIRA address - rpc QueryCouncilors(QueryCouncilors) returns (QueryCouncilorsResponse) { + rpc Councilors(QueryCouncilors) returns (QueryCouncilorsResponse) { option (google.api.http).get = "/kira/gov/councilors/{address}"; } - // QueryNonCouncilors - list all governance members that are NOT Councilors - rpc QueryNonCouncilors(QueryNonCouncilors) returns (QueryNonCouncilorsResponse) { + // NonCouncilors - list all governance members that are NOT Councilors + rpc NonCouncilors(QueryNonCouncilors) returns (QueryNonCouncilorsResponse) { option (google.api.http).get = "/kira/gov/non_councilors"; } - // QueryAddressesByWhitelistedPermission - list all KIRA addresses by a specific whitelisted permission (address does NOT have to be a Councilor) - rpc QueryAddressesByWhitelistedPermission(QueryAddressesByWhitelistedPermission) returns (QueryAddressesByWhitelistedPermissionResponse) { + // AddressesByWhitelistedPermission - list all KIRA addresses by a specific whitelisted permission (address does NOT have to be a Councilor) + rpc AddressesByWhitelistedPermission(QueryAddressesByWhitelistedPermission) returns (QueryAddressesByWhitelistedPermissionResponse) { option (google.api.http).get = "/kira/gov/addresses_by_whitelisted_permission/{permission}"; } - // QueryAddressesByBlacklistedPermission - list all KIRA addresses by a specific blacklisted permission (address does NOT have to be a Councilor) - rpc QueryAddressesByBlacklistedPermission(QueryAddressesByBlacklistedPermission) returns (QueryAddressesByBlacklistedPermissionResponse) { + // AddressesByBlacklistedPermission - list all KIRA addresses by a specific blacklisted permission (address does NOT have to be a Councilor) + rpc AddressesByBlacklistedPermission(QueryAddressesByBlacklistedPermission) returns (QueryAddressesByBlacklistedPermissionResponse) { option (google.api.http).get = "/kira/gov/addresses_by_blacklisted_permission/{permission}"; } - // QueryAddressesByWhitelistedRole - list all kira addresses by a specific whitelisted role (address does NOT have to be a Councilor) - rpc QueryAddressesByWhitelistedRole(QueryAddressesByWhitelistedRole) returns (QueryAddressesByWhitelistedRoleResponse) { + // AddressesByWhitelistedRole - list all kira addresses by a specific whitelisted role (address does NOT have to be a Councilor) + rpc AddressesByWhitelistedRole(QueryAddressesByWhitelistedRole) returns (QueryAddressesByWhitelistedRoleResponse) { option (google.api.http).get = "/kira/gov/addresses_by_whitelisted_role/{role}"; } + //Query list of all polls by address + rpc PollsListByAddress(QueryPollsListByAddress) returns (QueryPollsListByAddressResponse) { + option (google.api.http).get = "/kira/gov/proposal_polls/{creator}"; + } + + rpc PollsVotesByPollId(QueryPollsVotesByPollId) returns (QueryPollsVotesByPollIdResponse) { + option (google.api.http).get = "/kira/gov/proposal_poll/votes/{poll_id}"; + } +} + +message QueryPollsVotesByPollId { + uint64 poll_id = 1; +} + +message QueryPollsVotesByPollIdResponse { + repeated PollVote votes = 1 [(gogoproto.nullable) = false]; +} + +message QueryPollsListByAddress { + bytes creator = 1 [ + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress", + (gogoproto.moretags) = "yaml:\"creator\"" + ]; +} + +message QueryPollsListByAddressResponse { + repeated kira.gov.Poll polls = 1 [(gogoproto.nullable) = false]; } message NetworkPropertiesRequest {} diff --git a/proto/kira/gov/role.proto b/proto/kira/gov/role.proto index 0c670fd92..f485e279f 100644 --- a/proto/kira/gov/role.proto +++ b/proto/kira/gov/role.proto @@ -1,75 +1,75 @@ -syntax = "proto3"; -package kira.gov; - -import "gogoproto/gogo.proto"; - -option go_package = "github.com/KiraCore/sekai/x/gov/types"; - -message MsgCreateRole { - bytes proposer = 1 [ - (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress" - ]; - string role_sid = 2; - string role_description = 3; -} - -message MsgAssignRole { - bytes proposer = 1 [ - (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress" - ]; - bytes address = 2 [ - (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress", - (gogoproto.moretags) = "yaml:\"address\"" - ]; - uint32 roleId = 3; -} - -message MsgRemoveRole { - bytes proposer = 1 [ - (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress" - ]; - bytes address = 2 [ - (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress", - (gogoproto.moretags) = "yaml:\"address\"" - ]; - uint32 roleId = 3; -} - -message MsgWhitelistRolePermission { - bytes proposer = 1 [ - (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress" - ]; - - string roleIdentifier = 2; // sid or id - uint32 permission = 3; -} - -message MsgBlacklistRolePermission { - bytes proposer = 1 [ - (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress" - ]; - string roleIdentifier = 2; // sid or id - uint32 permission = 3; -} - -message MsgRemoveWhitelistRolePermission { - bytes proposer = 1 [ - (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress" - ]; - string roleIdentifier = 2; // sid or id - uint32 permission = 3; -} - -message MsgRemoveBlacklistRolePermission { - bytes proposer = 1 [ - (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress" - ]; - string roleIdentifier = 2; // sid or id - uint32 permission = 3; -} - -message Role { - uint32 id = 1; // (integer) - auto assigned - string sid = 2; // string identifier unique variable name - string description = 3; -} +syntax = "proto3"; +package kira.gov; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/KiraCore/sekai/x/gov/types"; + +message MsgCreateRole { + bytes proposer = 1 [ + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress" + ]; + string role_sid = 2; + string role_description = 3; +} + +message MsgAssignRole { + bytes proposer = 1 [ + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress" + ]; + bytes address = 2 [ + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress", + (gogoproto.moretags) = "yaml:\"address\"" + ]; + uint32 roleId = 3; +} + +message MsgRemoveRole { + bytes proposer = 1 [ + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress" + ]; + bytes address = 2 [ + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress", + (gogoproto.moretags) = "yaml:\"address\"" + ]; + uint32 roleId = 3; +} + +message MsgWhitelistRolePermission { + bytes proposer = 1 [ + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress" + ]; + + string roleIdentifier = 2; // sid or id + uint32 permission = 3; +} + +message MsgBlacklistRolePermission { + bytes proposer = 1 [ + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress" + ]; + string roleIdentifier = 2; // sid or id + uint32 permission = 3; +} + +message MsgRemoveWhitelistRolePermission { + bytes proposer = 1 [ + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress" + ]; + string roleIdentifier = 2; // sid or id + uint32 permission = 3; +} + +message MsgRemoveBlacklistRolePermission { + bytes proposer = 1 [ + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress" + ]; + string roleIdentifier = 2; // sid or id + uint32 permission = 3; +} + +message Role { + uint32 id = 1; // (integer) - auto assigned + string sid = 2; // string identifier unique variable name + string description = 3; +} diff --git a/proto/kira/gov/tx.proto b/proto/kira/gov/tx.proto index 2b6ed5c5f..94ca00709 100644 --- a/proto/kira/gov/tx.proto +++ b/proto/kira/gov/tx.proto @@ -7,6 +7,7 @@ import "google/protobuf/any.proto"; import "kira/gov/actor.proto"; import "kira/gov/councilor.proto"; import "kira/gov/proposal.proto"; +import "kira/gov/poll.proto"; import "kira/gov/role.proto"; import "kira/gov/execution_fee.proto"; import "kira/gov/network_properties.proto"; @@ -65,6 +66,10 @@ service Msg { rpc CouncilorUnpause(MsgCouncilorUnpause) returns (MsgCouncilorUnpauseResponse); // CouncilorActivate - signal to the network that Councilor wishes to regain voting ability after unannounced absence rpc CouncilorActivate(MsgCouncilorActivate) returns (MsgCouncilorActivateResponse); + // PollCreate defines a method to create a new poll proposal + rpc PollCreate(MsgPollCreate) returns (MsgPollCreateResponse); + // PollVote defines a method for voting a poll proposal + rpc PollVote(MsgPollVote) returns (MsgPollVoteResponse); } @@ -75,7 +80,7 @@ message MsgSubmitProposal { option (gogoproto.goproto_stringer) = false; option (gogoproto.stringer) = false; option (gogoproto.goproto_getters) = false; - + bytes proposer = 1 [ (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress" ]; @@ -126,3 +131,8 @@ message MsgCouncilorActivate { string sender = 1; } message MsgCouncilorActivateResponse {} + +message MsgPollCreateResponse { + uint64 pollID = 1; +} +message MsgPollVoteResponse {} diff --git a/proto/kira/layer2/genesis.proto b/proto/kira/layer2/genesis.proto new file mode 100644 index 000000000..6cea6b31b --- /dev/null +++ b/proto/kira/layer2/genesis.proto @@ -0,0 +1,16 @@ +syntax = "proto3"; +package kira.layer2; + +option go_package = "github.com/KiraCore/sekai/x/layer2/types"; + +import "gogoproto/gogo.proto"; +import "kira/layer2/layer2.proto"; + +// GenesisState defines the layer2 module's genesis state. +message GenesisState { + // dapps registered on the module + repeated Dapp dapps = 1 [ (gogoproto.nullable) = false ]; + BridgeRegistrar bridge = 2 [ (gogoproto.nullable) = false ]; +} + +// https://www.notion.so/kira-network/KIP-84-Layer-2-90379a918a3a4394908d814c7455fbdb \ No newline at end of file diff --git a/proto/kira/layer2/layer2.proto b/proto/kira/layer2/layer2.proto new file mode 100644 index 000000000..78155d0e0 --- /dev/null +++ b/proto/kira/layer2/layer2.proto @@ -0,0 +1,294 @@ +syntax = "proto3"; +package kira.layer2; + +option go_package = "github.com/KiraCore/sekai/x/layer2/types"; +option (gogoproto.equal_all) = true; + +import "google/protobuf/any.proto"; +import "gogoproto/gogo.proto"; +import "google/protobuf/timestamp.proto"; + +enum DappStatus { + option (gogoproto.goproto_enum_prefix) = false; + + BOOTSTRAP = 0 [ (gogoproto.enumvalue_customname) = "Bootstrap" ]; + ACTIVE = 1 [ (gogoproto.enumvalue_customname) = "Active" ]; + PAUSED = 2 [ (gogoproto.enumvalue_customname) = "Paused" ]; + HALTED = 3 [ (gogoproto.enumvalue_customname) = "Halted" ]; +} + +message AccountRange { + repeated string addresses = 1; + repeated uint64 roles = 2; +} + +message Controllers { + AccountRange whitelist = 1 [ (gogoproto.nullable) = false ]; + AccountRange blacklist = 2 [ (gogoproto.nullable) = false ]; +} + +message BinaryInfo { + string name = 1; // filename identifying source such as container, executable, config, finality gadget, etc. + string hash = 2; // hash of the file + string source = 3; // link to the source (from where the file should be fetched) + string reference = 4; // link to github repository or audit + string type = 5; // optional file type, e.g. binary, archive, text, image, etc. +} + +message LpPoolConfig { + string ratio = 1 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; // amount of dp_ to be issued per each 1 KEX contributed + string deposit = 2; // spending pool id/name from where lp coins can be claimed + uint64 drip = 3; // time over which tokens should be distributed (can not be modified) +} + +message IssuranceConfig { + string deposit = 1; // spending pool id/name or kira address for extra dp deposit + string premint = 2 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; // Amount of dp_ to premint (can not be modified) + string postmint = 3 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; // Amount of dp_ to postmint (can not be modified) + uint64 time = 4; // unix timestamp when to issue postminted dp tokens (can not be modified) +} + +message Dapp { + string name = 1; // application name, must be globally unique and follow the same safety rules as usernames & validator moniker (can NOT be changed) + string denom = 2; // native dApp token denom substring, min 3 and max 8 lowercase alphabetic characters only (a-z) + string description = 3; // short description of the dApp, max 512 characters. + string website = 4; // official website/info about dApp, max 128 characters. + string logo = 5; // dapp logo url/cid + string social = 6; // comma separated list of official social media urls + string docs = 7; // url to the resources documenting dApp operation + Controllers controllers = 8 [ (gogoproto.nullable) = false ]; // list of dApp owners, who can curate the execution record + repeated BinaryInfo bin = 9 [ (gogoproto.nullable) = false ]; // array of files & their details essential for launching the dApp + LpPoolConfig pool = 10 [ (gogoproto.nullable) = false ]; // lp pool configuration (can not be modified) + IssuranceConfig issurance = 11 [ (gogoproto.nullable) = false ]; // extra dApp (dp) token issuance configuration + uint64 update_time_max = 12; // maximum time the dApp leader has to update his session (can be no more then 86400 - 24h) + uint64 executors_min = 13; // minimum number of validators that will be executing the dApp code (default 1) + uint64 executors_max = 14; // maximum number of validators that will be executing the dApp code (default 21) + uint64 verifiers_min = 15; // minimum number of nodes that must approve dApp state change + string total_bond = 16 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Coin", + (gogoproto.nullable) = false + ]; // total bonds put on the dapp + uint64 creation_time = 17; // dapp creation time + DappStatus status = 18; // dapp status + uint64 vote_quorum = 19; // percentage - default: 51%, collective-specific % of owner accounts that must vote YES or NO for any of the collective proposals to be valid + uint64 vote_period = 20; // seconds - default: 600s, period of time in seconds that any of the collective proposals must last before passing or being rejected + uint64 vote_enactment = 21; // seconds - default: 300s, period of time that must pass before any of the collective proposals is enacted + uint64 liquidation_start = 22; // liquidation start time + string pool_fee = 23 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; // default 1% swap, deposits, redemptions + string team_reserve = 24; // team multisig + uint64 premint_time = 25; // timestamp for premint + bool post_mint_paid = 26; // flag to show post mint paid or not +} + +message UserDappBond { + string user = 1; + string dapp_name = 2; + string bond = 3 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Coin", + (gogoproto.nullable) = false + ]; +} + +enum OperatorStatus { + option (gogoproto.goproto_enum_prefix) = false; + + OPERATOR_ACTIVE = 0 [ (gogoproto.enumvalue_customname) = "OperatorActive" ]; + OPERATOR_PAUSED = 1 [ (gogoproto.enumvalue_customname) = "OperatorPaused" ]; + OPERATOR_INACTIVE = 2 [ (gogoproto.enumvalue_customname) = "OperatorInactive" ]; + OPERATOR_EXITING = 3 [ (gogoproto.enumvalue_customname) = "OperatorExiting" ]; + OPERATOR_JAILED = 4 [ (gogoproto.enumvalue_customname) = "OperatorJailed" ]; +} + +// - `active` - the operator is active and ready to run the application +// - `paused` - the operator is signaling that he is not ready and needs some time for maintenance and is now omitted until his internal issues are resolved. The paused status is also a default status of every operator immediately after being approved to execute or verify the application. +// - `inactive` - executor missed his dApp session round too many times and is now omitted until his internal issues are resolved +// - `exiting` - the operator decided to stop running the dApp and is leaving the set of dApp operators completely +// - `jailed` - verifiers reported that executor published an invalid dApp state or if the verifier is jailed it means that he reported dApp to execute incorrectly and his stake must be slashed. Jailed verifiers can’t be unjailed. + +message DappOperator { + string dapp_name = 1; + string operator = 2; + bool executor = 3; // can only be set by validators, raises proposal that controllers must approve + bool verifier = 4; // can be set by anyone, sending this tx does not require any approvals however requires a bond in `lp_` tokens no less than `dapp_verifier_bond` + string interx = 5; // must be set to a valid kira address + OperatorStatus status = 6; + int64 rank = 7; + int64 streak = 8; + int64 mischance = 9; + int64 verified_sessions = 10; + int64 missed_sessions = 11; + string bonded_lp_amount = 12 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; +} + +message DappLeaderDenouncement { + string dapp_name = 1; + string leader = 2; + string sender = 3; + string denouncement = 4; +} + +enum SessionStatus { + option (gogoproto.goproto_enum_prefix) = false; + + SESSION_UNSCHEDULED = 0 [ (gogoproto.enumvalue_customname) = "SessionUnscheduled" ]; + SESSION_SCHEDULED = 1 [ (gogoproto.enumvalue_customname) = "SessionScheduled" ]; + SESSION_ONGOING = 2 [ (gogoproto.enumvalue_customname) = "SessionOngoing" ]; + SESSION_ACCEPTED = 3 [ (gogoproto.enumvalue_customname) = "SessionAccepted" ]; + SESSION_DENOUNCED = 4 [ (gogoproto.enumvalue_customname) = "SessionDenounced" ]; + SESSION_HALTED = 5 [ (gogoproto.enumvalue_customname) = "SessionHalted" ]; + SESSION_FAILED = 6 [ (gogoproto.enumvalue_customname) = "SessionFailed" ]; +} + +message DappSession { + string leader = 1; + uint64 start = 2; + string status_hash = 3; + SessionStatus status = 4; + string gateway = 5; + repeated google.protobuf.Any onchain_messages = 6; // dapp mints, xam creations, xam accepts +} + +message DappSessionApproval { + string dapp_name = 1; + string approver = 2; + bool is_approved = 3; +} + +message ExecutionRegistrar { + string dapp_name = 1; + DappSession prev_session = 2; // a session that was completed and caused changes to the blockchain + DappSession curr_session = 3; // a session that is currently ongoing or was just finalized but is NOT a part of the changes applied to the blockchain state + DappSession next_session = 4; // a session that is about to begin after the current session ended +} + +// To signal that dApp expects SEKAI to execute something, a tx as escaped JSON string must be placed in the `xam` field and `dst` set to `0`. +// Users MUST NOT be allowed to set `xam` by sending `transfer-dapp-tx` with `dst == 0`, this can only be done by the applications themselves +// and included as part of `xamdata`. +// Applications also are NOT allowed to send tx on behalf of other tx, meaning that ABR must interpret all tx with `dst == 0` +// as execution requests as long as `xam` is NOT an empty string. +// The only difference between user tx and application tx should be that the application tx will not have a signature. + +message BridgeRegistrarHelper { + uint64 next_user = 1; // default 1, defines what should be the next index of the user or application account + uint64 next_xam = 2; // default 1, defines what should be the next cross-application transaction id - xid + uint64 next_token = 3; // default 2, defines what should be the next token denom identifier +} + +message BridgeRegistrar { + BridgeRegistrarHelper helper = 1; // contains next values for user, xam, token + repeated BridgeAccount accounts = 2 [ (gogoproto.nullable) = false ]; // used only on genesis export + repeated BridgeToken tokens = 3 [ (gogoproto.nullable) = false ]; // used only on genesis export + repeated XAM xams = 4 [ (gogoproto.nullable) = false ]; // used only on genesis export +} + +message BridgeBalance { + uint64 bridge_token_index = 1; + string amount = 2 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; +} + +message BridgeAccount { + uint64 index = 1; + string address = 2; + string dapp_name = 3; // set to app name if app account + repeated BridgeBalance balances = 4 [ (gogoproto.nullable) = false ]; +} + +message BridgeToken { + uint64 index = 1; + string denom = 2; +} + +message XAMRequest { + repeated BridgeBalance amounts = 1 [ (gogoproto.nullable) = false ];; // coin amount - { "333333": "222222" } to send 222222 ubtc + uint64 source_dapp = 2; // source app + uint64 source_account = 3; // source beneficiary + uint64 dest_dapp = 4; // destination app + uint64 dest_beneficiary = 5; // destination beneficiary + string xam = 6; // string with message (optional) +} + +message XAMResponse { + uint64 xid = 1; + uint64 irc = 2; // Internal error or response code + uint64 src = 3; // Source application error or response code + uint64 drc = 4; // Destination application error or response code + uint64 irm = 5; // Internal response message + uint64 srm = 6; // Source response message + uint64 drm = 7; // Destination response message +} + +message XAM { + uint64 req_time = 1; + XAMRequest req = 2 [ (gogoproto.nullable) = false ]; + XAMResponse res = 3 [ (gogoproto.nullable) = false ]; +} + +// Application Bridge Registrar Structure Example +// { +// "next_index": , // default 1, defines what should be the next index of the user or application account +// "next_xam": , // default 1, defines what should be the next cross-application transaction id - xid +// "next_token": , // default 2, defines what should be the next token denom identifier +// "users": { // mapping of uint256 identifiers to addresses, value '0' MUST be reserved +// "1":"kiraXXX...XXX", +// "2":"kiraYYY...YYY", +// ... +// }, +// "apps": { // mapping of uint64 identifiers to apps dApp, value '0' MUST be reserved +// "1045": "kiraMMM...MMM", +// ... +// }, +// "tokens": { // mapping of denom to identifiers, index 1 is reserved for KEX +// "1": "ukex", +// "2": "", ... +// } +// "balances": { // user or application account balances +// "": { // explicit account address +// "index": , // index as defined as in the users or apps array +// "deposits": { +// "": { // dictionary mapping denom to applications by and the corresponding amount locked to that dApp +// "": "", ... +// }, ... +// } +// }, { ... }, ... +// }, +// "xams": { // cross application messages +// "": [ // list of transactions originating from specific kira address (user or application) +// { +// "xid": , // iterative, unique cross-application message identifier +// "val": { // dictionary of tokens and corresponding ammounts to be transferred (if any) +// "": "", ... +// }, +// "time": , // unix timestamp of the block when the transfer/withdrawl/message was sent +// "src": , // source APPlication of funds FROM which application index funds should be moved, if set to 0 implies deposit to ABR +// "acc": , // ACCount index FROM which funds should be sent +// "dst": , // APPlication TO which funds should be transferred, if set to 0 implies withdrawl from ABR back to KIRA bank module +// "ben": , // beneficiary/destination account to which funds must be sent +// "irc": , // Internal error or response code +// "src": , // Source application error or response code +// "drc": , // Destination application error or response code +// "xam": "", // Cross-application message +// "irm": "", // Internal response message +// "srm": "", // Source response message +// "drm": "" // Destination response message +// }, { ... }, ... +// ] +// } +// } diff --git a/proto/kira/layer2/mint.proto b/proto/kira/layer2/mint.proto new file mode 100644 index 000000000..2d966f88e --- /dev/null +++ b/proto/kira/layer2/mint.proto @@ -0,0 +1,36 @@ +syntax = "proto3"; +package kira.layer2; + +option go_package = "github.com/KiraCore/sekai/x/layer2/types"; +option (gogoproto.equal_all) = true; + +import "gogoproto/gogo.proto"; +import "google/protobuf/timestamp.proto"; + +message TokenInfo { + string token_type = 1; // Token Type / Compatibility (can NOT be changed or owner defined) + string denom = 2; // full denom, e.g. ap_kirabridge_btc or class identifier (can NOT be changed) + string name = 3; // full name, eg. Bitcoin, (can only be changed by the proposal-upsert-alias) + string symbol = 4; // symbnol, eg. KEX, BTC, (can only be changed by the proposal-upsert-alias) + string icon = 5; // url 256 chars max, (can be changed by owner or proposal-upsert-alias) + string description = 6; // 512 chars max, (can be changed by owner or proposal-upsert-alias) + string website = 7; // url 256 chars max, (can be changed by owner or proposal-upsert-alias) + string social = 8; // url 256 chars max, (can be changed by owner or proposal-upsert-alias) + uint64 decimals = 9; // min 0, max 255, (can NOT be changed) + string cap = 10 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; // maximum supply that can be issued, max 2^256 - 1, (can NOT be INCREASED or decreased below current circulatin supply) + string supply = 11 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; // current circulating supply can NOT be more then CAP + uint64 holders = 12; + string fee = 13 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; // cost of minting 10^decimals per X ukex, can only increase (can be changed by owner only) + string owner = 14; // owner address or "" if noone should be able to modify most important properties + string metadata = 15; // metadata url or CID + string hash = 16; // hexadecimal metadata checksum +} diff --git a/proto/kira/layer2/proposal.proto b/proto/kira/layer2/proposal.proto new file mode 100644 index 000000000..b1035b839 --- /dev/null +++ b/proto/kira/layer2/proposal.proto @@ -0,0 +1,34 @@ +syntax = "proto3"; +package kira.layer2; + +import "gogoproto/gogo.proto"; +import "cosmos_proto/cosmos.proto"; +import "kira/layer2/layer2.proto"; + +option go_package = "github.com/KiraCore/sekai/x/layer2/types"; + +// Allows joining applications as executor or fisherman. By default all +// executors are also verifiers so it should not be possible to set both +// executor and verifier flags to true at the same time. This tx MUST also allow +// to define or update a globally unique INTERX address that will be tasked with +// operating the application. Tx should also fail if someone already joined +// application and is applying for a different role, in other words all +// operators must be unique for each dApp although different applications can +// have the same operators. +message ProposalJoinDapp { + option (cosmos_proto.implements_interface) = "Content"; + option (gogoproto.equal) = true; + + string sender = 1; + string dapp_name = 2; + bool executor = 3; // can only be set by validators, raises proposal that controllers must approve + bool verifier = 4; // can be set by anyone, sending this tx does not require any approvals however requires a bond in `lp_` tokens no less than `dapp_verifier_bond` + string interx = 5; // must be set to a valid kira address +} + +// can only be sent by the dApp controllers, allowing to upgrade binaries, +// controlled and modify all other properties +message ProposalUpsertDapp { + string sender = 1; + Dapp dapp = 2 [ (gogoproto.nullable) = false ]; +} diff --git a/proto/kira/layer2/query.proto b/proto/kira/layer2/query.proto new file mode 100644 index 000000000..341a7197d --- /dev/null +++ b/proto/kira/layer2/query.proto @@ -0,0 +1,60 @@ +syntax = "proto3"; +package kira.layer2; + +import "cosmos/base/query/v1beta1/pagination.proto"; +import "gogoproto/gogo.proto"; +import "google/protobuf/any.proto"; +import "google/api/annotations.proto"; +import "kira/layer2/layer2.proto"; +import "kira/layer2/mint.proto"; + +option go_package = "github.com/KiraCore/sekai/x/layer2/types"; + +// Query defines the gRPC querier service. +service Query { + // query info of a specific application by dApp ID or name + rpc ExecutionRegistrar(QueryExecutionRegistrarRequest) returns (QueryExecutionRegistrarResponse) { + option (google.api.http).get = "/kira/layer2/execution_registrar/{identifier}"; + } + // list IDs of all execution registrars and allow search by + // executor or verifier kira public key (e.g. list all dApps run by address kiraXXX…YYY) + rpc AllDapps(QueryAllDappsRequest) returns (QueryAllDappsResponse) { + option (google.api.http).get = "/kira/layer2/all_dapps"; + } + // query XAMs’ records by either account address, account index, xid or + // transaction hash in which cross-app transaction was added to the ABR. + rpc TransferDapps(QueryTransferDappsRequest) returns (QueryTransferDappsResponse) { + option (google.api.http).get = "/kira/layer2/transfer_dapp"; + } + // query list of all token denoms on the network including those created in + // the genesis (ukex, samolean etc..) as well as those in the minting module, + // lp tokens, validator recovery tokens and so on. If the flag with specific + // name is specified provide a detailed information about the token including + // its current circulating supply etc. + rpc GlobalTokens(QueryGlobalTokensRequest) returns (QueryGlobalTokensResponse) { + option (google.api.http).get = "/kira/layer2/global_tokens"; + } +} + +message QueryExecutionRegistrarRequest { + string identifier = 1; // dApp ID or name +} +message QueryExecutionRegistrarResponse { + Dapp dapp = 1; + ExecutionRegistrar execution_registrar = 2; +} + +message QueryAllDappsRequest {} +message QueryAllDappsResponse { + repeated Dapp dapps = 1 [ (gogoproto.nullable) = false ]; +} + +message QueryTransferDappsRequest {} +message QueryTransferDappsResponse { + repeated XAM XAMs = 1 [ (gogoproto.nullable) = false ]; +} + +message QueryGlobalTokensRequest {} +message QueryGlobalTokensResponse { + repeated TokenInfo tokens = 1 [ (gogoproto.nullable) = false ]; +} diff --git a/proto/kira/layer2/tx.proto b/proto/kira/layer2/tx.proto new file mode 100644 index 000000000..92fdbad14 --- /dev/null +++ b/proto/kira/layer2/tx.proto @@ -0,0 +1,310 @@ +syntax = "proto3"; +package kira.layer2; + +option go_package = "github.com/KiraCore/sekai/x/layer2/types"; +option (gogoproto.equal_all) = true; + +import "gogoproto/gogo.proto"; +import "google/protobuf/any.proto"; +import "cosmos_proto/cosmos.proto"; +import "kira/layer2/layer2.proto"; + +// Msg defines the layer2 Msg service. +service Msg { + rpc CreateDappProposal(MsgCreateDappProposal) returns (MsgCreateDappProposalResponse); + rpc BondDappProposal(MsgBondDappProposal) returns (MsgBondDappProposalResponse); + rpc ReclaimDappBondProposal(MsgReclaimDappBondProposal) returns (MsgReclaimDappBondProposalResponse); + rpc JoinDappVerifierWithBond(MsgJoinDappVerifierWithBond) returns (MsgJoinDappVerifierWithBondResponse); + rpc ExitDapp(MsgExitDapp) returns (MsgExitDappResponse); + rpc RedeemDappPoolTx(MsgRedeemDappPoolTx) returns (MsgRedeemDappPoolTxResponse); + rpc SwapDappPoolTx(MsgSwapDappPoolTx) returns (MsgSwapDappPoolTxResponse); + rpc ConvertDappPoolTx(MsgConvertDappPoolTx) returns (MsgConvertDappPoolTxResponse); + rpc PauseDappTx(MsgPauseDappTx) returns (MsgPauseDappTxResponse); + rpc UnPauseDappTx(MsgUnPauseDappTx) returns (MsgUnPauseDappTxResponse); + rpc ReactivateDappTx(MsgReactivateDappTx) returns (MsgReactivateDappTxResponse); + rpc ExecuteDappTx(MsgExecuteDappTx) returns (MsgExecuteDappTxResponse); + rpc DenounceLeaderTx(MsgDenounceLeaderTx) returns (MsgDenounceLeaderTxResponse); + rpc TransitionDappTx(MsgTransitionDappTx) returns (MsgTransitionDappTxResponse); + rpc ApproveDappTransitionTx(MsgApproveDappTransitionTx) returns (MsgApproveDappTransitionTxResponse); + rpc RejectDappTransitionTx(MsgRejectDappTransitionTx) returns (MsgRejectDappTransitionTxResponse); + rpc TransferDappTx(MsgTransferDappTx) returns (MsgTransferDappTxResponse); + rpc AckTransferDappTx(MsgAckTransferDappTx) returns (MsgAckTransferDappTxResponse); + rpc MintCreateFtTx(MsgMintCreateFtTx) returns (MsgMintCreateFtTxResponse); + rpc MintCreateNftTx(MsgMintCreateNftTx) returns (MsgMintCreateNftTxResponse); + rpc MintIssueTx(MsgMintIssueTx) returns (MsgMintIssueTxResponse); + rpc MintBurnTx(MsgMintBurnTx) returns (MsgMintBurnTxResponse); +} + +// allow to raise dApp launch proposal using a token +// bond or with a dedicated permission (where no starting 1% bond needed). Fail +// proposal if min_dapp_bond is not reached. This proposal does NOT require +// governance approval only sufficient number of bonded tokens. +message MsgCreateDappProposal { + string sender = 1; + Dapp dapp = 2 [ (gogoproto.nullable) = false ]; + string bond = 3 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Coin", + (gogoproto.nullable) = false + ]; +} +message MsgCreateDappProposalResponse {} + +// allow KEX holders to bond extra tokens to dApp +// proposal unless max_dapp_bond is reached in which case fail the tx. +message MsgBondDappProposal { + string sender = 1; + string dapp_name = 2; + string bond = 3 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Coin", + (gogoproto.nullable) = false + ]; +} +message MsgBondDappProposalResponse {} + +// claim your KEX back from dApp proposal, should +// be possible to execute regardless if the proposal is still ongoing or failed +message MsgReclaimDappBondProposal{ + string sender = 1; + string dapp_name = 2; + string bond = 3 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Coin", + (gogoproto.nullable) = false + ]; +} +message MsgReclaimDappBondProposalResponse {} + +message MsgJoinDappVerifierWithBond { + string sender = 1; + string dapp_name = 2; + string interx = 3; // must be set to a valid kira address +} +message MsgJoinDappVerifierWithBondResponse {} + +// stop being a dApp operator and remove the record in the Execution Registrar. +// Return bonded funds if the operator is a verifier. +message MsgExitDapp { + string sender = 1; + string dapp_name = 2; +} +message MsgExitDappResponse {} + +// return lp_ tokens to the pool and redeem KEX or dp_ token +// unless slippage is exceeded then fail the tx. +message MsgRedeemDappPoolTx { + string sender = 1; + string dapp_name = 2; + string lp_token = 3 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Coin", + (gogoproto.nullable) = false + ]; + string slippage = 4 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; +} +message MsgRedeemDappPoolTxResponse {} + +// send KEX and receive dp_ or send dp_ and receive KEX unless +// slippage is exceeded then fail the tx. +message MsgSwapDappPoolTx { + string sender = 1; + string dapp_name = 2; + string token = 3 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Coin", + (gogoproto.nullable) = false + ]; + string slippage = 4 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; +} +message MsgSwapDappPoolTxResponse {} + +// allow user to convert any dp_ for any other dp_ token unless +// slippage is exceeded then fail the tx. +message MsgConvertDappPoolTx { + string sender = 1; + string dapp_name = 2; + string target_dapp_name = 3; + string lp_token = 4 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Coin", + (gogoproto.nullable) = false + ]; + string slippage = 5 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; +} +message MsgConvertDappPoolTxResponse {} + +// allow executors to change their status to paused. This tx does NOT pause the +// dApp, it only pauses the ability of an executor to continue running the dApp +// in the next session. If the executor is currently running the session then he +// needs to finish it before paused status is applied. +message MsgPauseDappTx { + string sender = 1; + string dapp_name = 2; +} +message MsgPauseDappTxResponse {} + +// exit maintenance mode to signal that verifier or executor is ready to operate +// the dApp again. +message MsgUnPauseDappTx { + string sender = 1; + string dapp_name = 2; +} +message MsgUnPauseDappTxResponse {} + +// re-activate deactivated dApp operator +message MsgReactivateDappTx { + string sender = 1; + string dapp_name = 2; +} +message MsgReactivateDappTxResponse {} + +// allow next session leader to announce or update his IP address and start +// execution. +message MsgExecuteDappTx { + string sender = 1; + string dapp_name = 2; + string gateway = 3; +} +message MsgExecuteDappTxResponse {} + +// allow executors to denounce the current session leader, should take a +// session id as a parameter as well as a true or false flag to allow vote +// change. +message MsgDenounceLeaderTx { + string sender = 1; + string dapp_name = 2; + string leader = 3; + string denounce_text = 4; + string version = 5; +} +message MsgDenounceLeaderTxResponse {} + +// update CURRENT session state (can only be sent by current session leader), +// this tx MUST include dApp version. +message MsgTransitionDappTx { + string sender = 1; + string dapp_name = 2; + string status_hash = 3; + repeated google.protobuf.Any onchain_messages = 4; // dapp mints, xam creations, xam accepts + string version = 5; +} +message MsgTransitionDappTxResponse {} + +// approve CURRENT session state (can only be sent by the verifiers or executors +// who are NOT a leader), this tx MUST include dApp version. +message MsgApproveDappTransitionTx { + string sender = 1; + string dapp_name = 2; + string version = 3; +} +message MsgApproveDappTransitionTxResponse {} + +// reject session transition and immediately set the state of the current +// session to halted, this tx MUST include dApp version and session id. +message MsgRejectDappTransitionTx { + string sender = 1; + string dapp_name = 2; + string version = 3; +} +message MsgRejectDappTransitionTxResponse {} + +// allow user to manually deposit/transfer/withdrawal funds to / from / within +// ABR and communicate with apps by including xam string message. +message MsgTransferDappTx { + string sender = 1; + repeated XAMRequest requests = 2 [ (gogoproto.nullable) = false ]; +} +message MsgTransferDappTxResponse {} + +// acknowledgement of transfer dapp tx +message MsgAckTransferDappTx { + string sender = 1; + repeated XAMResponse responses = 2 [ (gogoproto.nullable) = false ]; +} +message MsgAckTransferDappTxResponse {} + +// create new fungible token record in the minting module +message MsgMintCreateFtTx { + string sender = 1; + string denom_suffix = 2; // suffix that must be applied to the token, min 3 and max 8 lowercase alphabetic characters only (a-z) + string name = 3; // full name, eg. Bitcoin, (can only be changed by the proposal-upsert-alias) + string symbol = 4; // symbnol, eg. KEX, BTC, (can only be changed by the proposal-upsert-alias) + string icon = 5; // url 256 chars max, (can be changed by owner or proposal-upsert-alias) + string description = 6; // 512 chars max, (can be changed by owner or proposal-upsert-alias) + string website = 7; // url 256 chars max, (can be changed by owner or proposal-upsert-alias) + string social = 8; // url 256 chars max, (can be changed by owner or proposal-upsert-alias) + uint64 decimals = 9; // min 0, max 255, (can NOT be changed) + string cap = 10 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; // maximum supply that can be issued, max 2^256 - 1, (can NOT be INCREASED or decreased below current circulatin supply) + string supply = 11 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; // current circulating supply can NOT be more then CAP + uint64 holders = 12; + string fee = 13 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; // cost of minting 10^decimals per X ukex, can only increase (can be changed by owner only) + string owner = 14; // owner address or "" if noone should be able to modify most important properties +} +message MsgMintCreateFtTxResponse {} + +// create new non-fungible token record in the minting module +message MsgMintCreateNftTx { + string sender = 1; + string denom_suffix = 2; // suffix that must be applied to the token, min 3 and max 8 lowercase alphabetic characters only (a-z) + string name = 3; // full name, eg. Bitcoin, (can only be changed by the proposal-upsert-alias) + string symbol = 4; // symbnol, eg. KEX, BTC, (can only be changed by the proposal-upsert-alias) + string icon = 5; // url 256 chars max, (can be changed by owner or proposal-upsert-alias) + string description = 6; // 512 chars max, (can be changed by owner or proposal-upsert-alias) + string website = 7; // url 256 chars max, (can be changed by owner or proposal-upsert-alias) + string social = 8; // url 256 chars max, (can be changed by owner or proposal-upsert-alias) + uint64 decimals = 9; // min 0, max 255, (can NOT be changed) + string cap = 10 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; // maximum supply that can be issued, max 2^256 - 1, (can NOT be INCREASED or decreased below current circulatin supply) + string supply = 11 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; // current circulating supply can NOT be more then CAP + uint64 holders = 12; + string fee = 13 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; // cost of minting 10^decimals per X ukex, can only increase (can be changed by owner only) + string owner = 14; // owner address or "" if noone should be able to modify most important properties + string metadata = 15; // metadata url or CID + string hash = 16; // hexadecimal metadata checksum +} +message MsgMintCreateNftTxResponse {} + +// allow owner to mint new tokens or anyone if the minting-fee is set to value +// other then 0. +message MsgMintIssueTx { + string sender = 1; + string denom = 2; + string amount = 3 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; + string receiver = 4; +} +message MsgMintIssueTxResponse {} + +// allow anyone burn the tokens they own +message MsgMintBurnTx { + string sender = 1; + string denom = 2; + string amount = 3 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; +} +message MsgMintBurnTxResponse {} diff --git a/proto/kira/recovery/genesis.proto b/proto/kira/recovery/genesis.proto new file mode 100644 index 000000000..39ac2bcba --- /dev/null +++ b/proto/kira/recovery/genesis.proto @@ -0,0 +1,19 @@ +syntax = "proto3"; +package kira.recovery; + +option go_package = "github.com/KiraCore/sekai/x/recovery/types"; + +import "gogoproto/gogo.proto"; +import "google/protobuf/any.proto"; +import "kira/recovery/recovery.proto"; + +// GenesisState defines the recovery module's genesis state. +message GenesisState { + repeated kira.recovery.RecoveryRecord recovery_records = 1 + [ (gogoproto.nullable) = false ]; + repeated kira.recovery.RecoveryToken recovery_tokens = 2 + [ (gogoproto.nullable) = false ]; + repeated kira.recovery.Rewards rewards = 3 [ (gogoproto.nullable) = false ]; + repeated kira.recovery.Rotation rotations = 4 + [ (gogoproto.nullable) = false ]; +} diff --git a/proto/kira/recovery/query.proto b/proto/kira/recovery/query.proto new file mode 100644 index 000000000..e1abb8351 --- /dev/null +++ b/proto/kira/recovery/query.proto @@ -0,0 +1,60 @@ +syntax = "proto3"; +package kira.recovery; + +import "cosmos/base/query/v1beta1/pagination.proto"; +import "gogoproto/gogo.proto"; +import "google/protobuf/any.proto"; +import "google/api/annotations.proto"; +import "kira/recovery/recovery.proto"; + +option go_package = "github.com/KiraCore/sekai/x/recovery/types"; + +// Query defines the gRPC querier service. +service Query { + // given KIRA public address as parameter return data from the recovery registrar + rpc RecoveryRecord(QueryRecoveryRecordRequest) returns (QueryRecoveryRecordResponse) { + option (google.api.http).get = "/kira/recovery/v1beta1/recovery_record/{address}"; + } + rpc RecoveryToken(QueryRecoveryTokenRequest) returns (QueryRecoveryTokenResponse) { + option (google.api.http).get = "/kira/recovery/v1beta1/recovery_token/{address}"; + } + rpc RRHolderRewards(QueryRRHolderRewardsRequest) returns (QueryRRHolderRewardsResponse) { + option (google.api.http).get = "/kira/recovery/v1beta1/recovery_token_rewards/{address}"; + } + rpc RegisteredRRTokenHolders(QueryRegisteredRRTokenHoldersRequest) returns (QueryRegisteredRRTokenHoldersResponse) { + option (google.api.http).get = "/kira/recovery/v1beta1/recovery_token_holders/{recovery_token}"; + } +} + +message QueryRecoveryRecordRequest { + string address = 1; +} + +message QueryRecoveryRecordResponse { + kira.recovery.RecoveryRecord record = 1 [(gogoproto.nullable) = false]; +} + +message QueryRecoveryTokenRequest { + string address = 1; +} + +message QueryRecoveryTokenResponse { + kira.recovery.RecoveryToken token = 1 [ (gogoproto.nullable) = false ]; +} + +message QueryRRHolderRewardsRequest { + string address = 1; +} +message QueryRRHolderRewardsResponse { + repeated string rewards = 1 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Coin", + (gogoproto.nullable) = false + ]; +} + +message QueryRegisteredRRTokenHoldersRequest { + string recovery_token = 1; +} +message QueryRegisteredRRTokenHoldersResponse { + repeated string holders = 1; +} diff --git a/proto/kira/recovery/recovery.proto b/proto/kira/recovery/recovery.proto new file mode 100644 index 000000000..4c257dc2c --- /dev/null +++ b/proto/kira/recovery/recovery.proto @@ -0,0 +1,41 @@ + +syntax = "proto3"; +package kira.recovery; + +option go_package = "github.com/KiraCore/sekai/x/recovery/types"; +option (gogoproto.equal_all) = true; + +import "gogoproto/gogo.proto"; +import "google/protobuf/timestamp.proto"; + +message RecoveryRecord { + string address = 1; // address registering recovery challenge + string challenge = 2; // recovery challenge S_H2, if the same S_H2 already exists then fail tx + string nonce = 3; // nonce must be a valid nonce +} + +message RecoveryToken { + string address = 1; + string token = 2; + string rr_supply = 3 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; + repeated string underlying_tokens = 4 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Coin", + (gogoproto.nullable) = false + ]; +} + +message Rotation { + string address = 1; + string rotated = 2; +} + +message Rewards { + string holder = 1; + repeated string rewards = 2 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Coin", + (gogoproto.nullable) = false + ]; +} \ No newline at end of file diff --git a/proto/kira/recovery/tx.proto b/proto/kira/recovery/tx.proto new file mode 100644 index 000000000..32afa6ce1 --- /dev/null +++ b/proto/kira/recovery/tx.proto @@ -0,0 +1,79 @@ +syntax = "proto3"; +package kira.recovery; + +option go_package = "github.com/KiraCore/sekai/x/recovery/types"; +option (gogoproto.equal_all) = true; + +import "gogoproto/gogo.proto"; +import "google/protobuf/any.proto"; +import "cosmos_proto/cosmos.proto"; +import "kira/recovery/recovery.proto"; + +// Msg defines the recovery Msg service. +service Msg { + // allow ANY user to register or modify existing recovery secret & verify if the nonce is correct + rpc RegisterRecoverySecret(MsgRegisterRecoverySecret) returns (MsgRegisterRecoverySecretResponse); + // allow ANY KIRA address that knows the recovery secret to rotate the address + rpc RotateRecoveryAddress(MsgRotateRecoveryAddress) returns (MsgRotateRecoveryAddressResponse); + // mint `rr_` tokens and deposit them to the validator account. + // This function will require putting up a bond in the amount of `validator_recovery_bond` otherwise should fail + rpc IssueRecoveryTokens(MsgIssueRecoveryTokens) returns (MsgIssueRecoveryTokensResponse); + // burn tokens and redeem KEX + rpc BurnRecoveryTokens(MsgBurnRecoveryTokens) returns (MsgBurnRecoveryTokensResponse); + // claim rewards + rpc ClaimRRHolderRewards(MsgClaimRRHolderRewards) returns (MsgClaimRRHolderRewardsResponse); + // register RR token holder + rpc RegisterRRTokenHolder(MsgRegisterRRTokenHolder) returns (MsgRegisterRRTokenHolderResponse); + // allow ANY KIRA address has a sufficient number of RR tokens to rotate the address + rpc RotateValidatorByHalfRRTokenHolder(MsgRotateValidatorByHalfRRTokenHolder) returns (MsgRotateValidatorByHalfRRTokenHolderResponse); +} + +message MsgRegisterRecoverySecret { + string address = 1; // address registering recovery challenge + string challenge = 2; // recovery challenge S_H2, if the same S_H2 already exists then fail tx + string nonce = 3; // nonce must be a valid nonce + string proof = 4; // [OPTIONAL] proof of knowing the recovery secret to modify the old challenge +} +message MsgRegisterRecoverySecretResponse {} + +message MsgRotateRecoveryAddress { + string fee_payer = 1; + string address = 2; + string recovery = 3; + string proof = 4; +} +message MsgRotateRecoveryAddressResponse {} + +message MsgIssueRecoveryTokens { + string address = 1; +} +message MsgIssueRecoveryTokensResponse {} + +message MsgBurnRecoveryTokens { + string address = 1; + string rr_coin = 2 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Coin", + (gogoproto.nullable) = false + ]; +} +message MsgBurnRecoveryTokensResponse {} + +message MsgClaimRRHolderRewards { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + string sender = 1; +} +message MsgClaimRRHolderRewardsResponse {} + +message MsgRegisterRRTokenHolder { + string holder = 1; +} +message MsgRegisterRRTokenHolderResponse {} + +message MsgRotateValidatorByHalfRRTokenHolder { + string rr_holder = 1; + string address = 2; + string recovery = 3; +} +message MsgRotateValidatorByHalfRRTokenHolderResponse {} diff --git a/proto/kira/spending/pool.proto b/proto/kira/spending/pool.proto index bf69ad8aa..a57f2a5e1 100644 --- a/proto/kira/spending/pool.proto +++ b/proto/kira/spending/pool.proto @@ -43,27 +43,28 @@ message SpendingPool { // claim-start & claim-end - defines the exact time period (Unix timestamps) between which tokens can be claimed from the pool, allowing for a precise funds distribution. uint64 claim_start = 2; uint64 claim_end = 3; + uint64 claim_expiry = 4; // rate of distribution in the smallest token denomination per 1 second (this value can be a float number, smaller than actual denomination) - repeated string rates = 4 [ + repeated string rates = 5 [ (gogoproto.moretags) = "yaml:\"rates\"", (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.DecCoin", (gogoproto.nullable) = false ]; // pool specific % of owner accounts that must vote YES or NO for any of the pool proposals to be valid. - uint64 vote_quorum = 5; // percentage, # default: 51% + uint64 vote_quorum = 6; // percentage, # default: 51% // period of time in seconds that any of the pool proposals must last before passing or being rejected - uint64 vote_period = 6; // seconds, # default: 600s + uint64 vote_period = 7; // seconds, # default: 600s // period of time that must pass before any of the pool proposal is enacted - uint64 vote_enactment = 7; // seconds, # default: 300s + uint64 vote_enactment = 8; // seconds, # default: 300s // defines a list of accounts/roles controlling the spending pool via “governance-like” proposals - PermInfo owners = 8; + PermInfo owners = 9; // defines set of accounts/roles to which funds can be distributed - WeightedPermInfo beneficiaries = 9; - repeated string balances = 10 [ + WeightedPermInfo beneficiaries = 10; + repeated string balances = 11 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Coin", (gogoproto.nullable) = false ]; - bool dynamic_rate = 11; // (default false) defines if the rate of token distribution should be dynamic - uint64 dynamic_rate_period = 12; // time in seconds defining every what period dynamic rates are calculated - uint64 last_dynamic_rate_calc_time = 13; // timestamp that last dynamic rate was calculated + bool dynamic_rate = 12; // (default false) defines if the rate of token distribution should be dynamic + uint64 dynamic_rate_period = 13; // time in seconds defining every what period dynamic rates are calculated + uint64 last_dynamic_rate_calc_time = 14; // timestamp that last dynamic rate was calculated } \ No newline at end of file diff --git a/proto/kira/spending/tx.proto b/proto/kira/spending/tx.proto index abf7d7bc2..95d68a71e 100644 --- a/proto/kira/spending/tx.proto +++ b/proto/kira/spending/tx.proto @@ -32,25 +32,26 @@ message MsgCreateSpendingPool { // claim-start & claim-end - defines the exact time period (Unix timestamps) between which tokens can be claimed from the pool, allowing for a precise funds distribution. uint64 claim_start = 2; uint64 claim_end = 3; + uint64 claim_expiry = 4; // rate of distribution in the smallest token denomination per 1 second (this value can be a float number, smaller than actual denomination) - repeated string rates = 4 [ + repeated string rates = 5 [ (gogoproto.moretags) = "yaml:\"rates\"", (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.DecCoin", (gogoproto.nullable) = false ]; // pool specific % of owner accounts that must vote YES or NO for any of the pool proposals to be valid. - uint64 vote_quorum = 5; // percentage, # default: 51% + uint64 vote_quorum = 6; // percentage, # default: 51% // period of time in seconds that any of the pool proposals must last before passing or being rejected - uint64 vote_period = 6; // seconds, # default: 600s + uint64 vote_period = 7; // seconds, # default: 600s // period of time that must pass before any of the pool proposal is enacted - uint64 vote_enactment = 7; // seconds, # default: 300s + uint64 vote_enactment = 8; // seconds, # default: 300s // defines a list of accounts/roles controlling the spending pool via “governance-like” proposals - PermInfo owners = 8 [ (gogoproto.nullable) = false ]; + PermInfo owners = 9 [ (gogoproto.nullable) = false ]; // defines set of accounts/roles to which funds can be distributed - WeightedPermInfo beneficiaries = 9 [ (gogoproto.nullable) = false ]; - string sender = 10; - bool dynamic_rate = 11; - uint64 dynamic_rate_period = 12; + WeightedPermInfo beneficiaries = 10 [ (gogoproto.nullable) = false ]; + string sender = 11; + bool dynamic_rate = 12; + uint64 dynamic_rate_period = 13; } message MsgCreateSpendingPoolResponse {} diff --git a/proto/kira/tokens/alias.proto b/proto/kira/tokens/alias.proto index 72cbe697f..be0b4cdbc 100644 --- a/proto/kira/tokens/alias.proto +++ b/proto/kira/tokens/alias.proto @@ -11,6 +11,7 @@ message TokenAlias { string icon = 3; // Graphical Symbol (url link to graphics) uint32 decimals = 4; // Integer number of max decimals repeated string denoms = 5; // An array of token denoms to be aliased + bool invalidated = 6; // flag that the token is invalidated or not } message MsgUpsertTokenAlias { @@ -19,7 +20,8 @@ message MsgUpsertTokenAlias { string icon = 3; // Graphical Symbol (url link to graphics) uint32 decimals = 4; // Integer number of max decimals repeated string denoms = 5; // An array of token denoms to be aliased - bytes proposer = 6 [ + bool invalidated = 6; // flag that the token is invalidated or not + bytes proposer = 7 [ (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress", (gogoproto.moretags) = "yaml:\"proposer\"" ]; diff --git a/proto/kira/tokens/proposal.proto b/proto/kira/tokens/proposal.proto index 9e36bfcde..fc6608806 100644 --- a/proto/kira/tokens/proposal.proto +++ b/proto/kira/tokens/proposal.proto @@ -16,6 +16,7 @@ message ProposalUpsertTokenAlias { string icon = 3; uint32 decimals = 4; repeated string denoms = 5; + bool invalidated = 6; } message ProposalUpsertTokenRates { @@ -40,4 +41,5 @@ message ProposalUpsertTokenRates { (gogoproto.nullable) = false ]; bool stake_token = 6; + bool invalidated = 7; } diff --git a/proto/kira/tokens/rate.proto b/proto/kira/tokens/rate.proto index 5aa452d15..6095e616a 100644 --- a/proto/kira/tokens/rate.proto +++ b/proto/kira/tokens/rate.proto @@ -24,6 +24,7 @@ message TokenRate { (gogoproto.nullable) = false ]; bool stake_token = 6; + bool invalidated = 7; // flag that the token is invalidated or not } message MsgUpsertTokenRate { @@ -45,7 +46,8 @@ message MsgUpsertTokenRate { (gogoproto.nullable) = false ]; bool stake_token = 6; - bytes proposer = 7 [ + bool invalidated = 7; // flag that the token is invalidated or not + bytes proposer = 8 [ (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress", (gogoproto.moretags) = "yaml:\"proposer\"" ]; diff --git a/scripts/commands/collectives.sh b/scripts/commands/collectives.sh index 2833b2c93..0d54f5401 100644 --- a/scripts/commands/collectives.sh +++ b/scripts/commands/collectives.sh @@ -18,7 +18,7 @@ sekaid tx multistaking upsert-staking-pool kiravaloper1ak6c3jl4svl5vw5y9xu3yrq4s sekaid tx multistaking delegate kiravaloper1ak6c3jl4svl5vw5y9xu3yrq4susvkckwurn4sc 10000000000000ukex --from=validator --keyring-backend=test --fees=100ukex --chain-id=testing -y --broadcast-mode=block ## create dynamic spending pool -sekaid tx spending create-spending-pool --name="UserIncentivesPool" --claim-start=$(($(date -u +%s))) --claim-end=0 --rates=0.1ukex --vote-quorum="33" --vote-period="60" --vote-enactment="30" --owner-roles="" --owner-accounts=$(sekaid keys show -a validator --keyring-backend=test --home=$HOME/.sekaid) --beneficiary-roles="1" --beneficiary-role-weights="1" --beneficiary-accounts="" --beneficiary-account-weights="" --dynamic-rate=true --dynamic-rate-period=43200 --from=validator --chain-id=testing --fees=100ukex --keyring-backend=test --home=$HOME/.sekaid --yes --broadcast-mode=block +sekaid tx spending create-spending-pool --name="UserIncentivesPool" --claim-start=$(($(date -u +%s))) --claim-end=0 --claim-expiry=43200 --rates=0.1ukex --vote-quorum="33" --vote-period="60" --vote-enactment="30" --owner-roles="" --owner-accounts=$(sekaid keys show -a validator --keyring-backend=test --home=$HOME/.sekaid) --beneficiary-roles="1" --beneficiary-role-weights="1" --beneficiary-accounts="" --beneficiary-account-weights="" --dynamic-rate=true --dynamic-rate-period=43200 --from=validator --chain-id=testing --fees=100ukex --keyring-backend=test --home=$HOME/.sekaid --yes --broadcast-mode=block ## register as beneficiary sekaid tx spending register-spending-pool-beneficiary --name="UserIncentivesPool" --from=validator --chain-id=testing --fees=100ukex --keyring-backend=test --home=$HOME/.sekaid --yes --broadcast-mode=block diff --git a/scripts/commands/governance/upgrade-plan.sh b/scripts/commands/governance/upgrade-plan.sh index 14a2e0145..343268fda 100644 --- a/scripts/commands/governance/upgrade-plan.sh +++ b/scripts/commands/governance/upgrade-plan.sh @@ -45,4 +45,7 @@ sekaid query customgov proposals # upgrade to new json for hard-fork case sekaid export > exported-genesis.json -sekaid new-genesis-from-exported exported-genesis.json new-genesis.json +sekaid new-genesis-from-exported exported-genesis.json new-genesis.json --json-minimize=true + +# manual minize if required +sekaid export-minimized-genesis exported-genesis.json minimized.json \ No newline at end of file diff --git a/scripts/commands/governance/upsert-token-alias.sh b/scripts/commands/governance/upsert-token-alias.sh index 343dba114..4db0a6003 100644 --- a/scripts/commands/governance/upsert-token-alias.sh +++ b/scripts/commands/governance/upsert-token-alias.sh @@ -2,7 +2,7 @@ # upsert alias by governance ## proposal -sekaid tx tokens proposal-upsert-alias --from=validator --keyring-backend=test --title="upsert alias" --description="upsert alias proposal" --symbol="ETH" --name="Ethereum" --icon="myiconurl" --decimals=6 --denoms="finney" --chain-id=testing --fees=100ukex --home=$HOME/.sekaid --yes +sekaid tx tokens proposal-upsert-alias --from=validator --keyring-backend=test --title="upsert alias" --description="upsert alias proposal" --invalidated=false --symbol="ETH" --name="Ethereum" --icon="myiconurl" --decimals=6 --denoms="finney" --chain-id=testing --fees=100ukex --home=$HOME/.sekaid --yes ## query sekaid query proposals ## vote diff --git a/scripts/commands/governance/upsert-token-rates.sh b/scripts/commands/governance/upsert-token-rates.sh index 04fc415f2..f40854f86 100644 --- a/scripts/commands/governance/upsert-token-rates.sh +++ b/scripts/commands/governance/upsert-token-rates.sh @@ -2,7 +2,7 @@ # upsert rate by governance ## proposal -sekaid tx tokens proposal-upsert-rate --from=validator --keyring-backend=test --title="upsert rate" --description="upsert rate description" --denom="mykex" --rate="1.5" --fee_payments=true --chain-id=testing --fees=100ukex --home=$HOME/.sekaid --yes +sekaid tx tokens proposal-upsert-rate --from=validator --keyring-backend=test --title="upsert rate" --description="upsert rate description" --invalidated=false --denom="mykex" --rate="1.5" --fee_payments=true --chain-id=testing --fees=100ukex --home=$HOME/.sekaid --yes ## query sekaid query proposals diff --git a/scripts/commands/layer2.sh b/scripts/commands/layer2.sh new file mode 100644 index 000000000..4c43209a5 --- /dev/null +++ b/scripts/commands/layer2.sh @@ -0,0 +1,77 @@ +#!/bin/bash + +# queries +sekaid query layer2 all-dapps +sekaid query layer2 execution-registrar l2dex +sekaid query layer2 transfer-dapps +sekaid query layer2 global-tokens + +# transactions +sekaid tx layer2 create-dapp-proposal --dapp-name="l2dex" --denom="ul2d" --dapp-description="layer2 dex" \ + --website="website" --logo="logo" --social="social" --docs="docs" \ + --controller-roles="1" --controller-accounts="" --vote-quorum=30 --vote-period=86400 --vote-enactment=1000 \ + --bond="1000000ukex" \ + --issurance-config='{"premint":"10000","postmint":"10000","time":"1680044405"}' \ + --lp-pool-config='{"ratio": "1.0", "drip": 86400}' \ + --executors-min=1 --executors-max=3 --verifiers-min=1 \ + --binary-info='{"name":"layer2dex","hash":"0cc0","source":"github.com","reference":"","type":"exec"}' \ + --from=validator --chain-id=testing --fees=100ukex --keyring-backend=test --home=$HOME/.sekaid --yes --broadcast-mode=block + +sekaid tx layer2 bond-dapp-proposal --dapp-name="l2dex" --bond="1000000ukex" \ + --from=validator --chain-id=testing --fees=100ukex --keyring-backend=test --home=$HOME/.sekaid --yes --broadcast-mode=block + +sekaid tx layer2 reclaim-dapp-proposal --dapp-name="l2dex" --bond="1000000ukex" \ + --from=validator --chain-id=testing --fees=100ukex --keyring-backend=test --home=$HOME/.sekaid --yes --broadcast-mode=block + +INTERX=$(sekaid keys show -a validator --keyring-backend=test) +sekaid tx layer2 join-dapp-verifier-with-bond "l2dex" $INTERX \ + --from=validator --chain-id=testing --fees=100ukex --keyring-backend=test --home=$HOME/.sekaid --yes --broadcast-mode=block + +sekaid tx layer2 exit-dapp "l2dex" \ + --from=validator --chain-id=testing --fees=100ukex --keyring-backend=test --home=$HOME/.sekaid --yes --broadcast-mode=block + +sekaid tx layer2 execute-dapp-tx "l2dex" "l2dex.com" \ + --from=validator --chain-id=testing --fees=100ukex --keyring-backend=test --home=$HOME/.sekaid --yes --broadcast-mode=block + +LEADER=$(sekaid keys show -a validator --keyring-backend=test) +sekaid tx layer2 denounce-leader "l2dex" $LEADER "bad actor" "v1" \ + --from=validator --chain-id=testing --fees=100ukex --keyring-backend=test --home=$HOME/.sekaid --yes --broadcast-mode=block + +sekaid tx layer2 transition-dapp "l2dex" "08080818" "v1" \ + --from=validator --chain-id=testing --fees=100ukex --keyring-backend=test --home=$HOME/.sekaid --yes --broadcast-mode=block + +sekaid tx layer2 approve-dapp-transition "l2dex" "v1" \ + --from=validator --chain-id=testing --fees=100ukex --keyring-backend=test --home=$HOME/.sekaid --yes --broadcast-mode=block + +sekaid tx layer2 reject-dapp-transition "l2dex" "v1" \ + --from=validator --chain-id=testing --fees=100ukex --keyring-backend=test --home=$HOME/.sekaid --yes --broadcast-mode=block + +sekaid tx layer2 proposal-join-dapp "l2dex" true true $INTERX --title="title" --description="description" \ + --from=validator --chain-id=testing --fees=100ukex --keyring-backend=test --home=$HOME/.sekaid --yes --broadcast-mode=block +sekaid query customgov proposals +sekaid tx customgov proposal vote 1 1 --from validator --keyring-backend=test --home=$HOME/.sekaid --chain-id=testing --fees=100ukex --yes --broadcast-mode=block + +sekaid tx layer2 proposal-upsert-dapp --title="title" --description="description" \ + --dapp-name="l2dex" --denom="ul2d" --dapp-description="layer2 dex" \ + --website="website" --logo="logo" --social="social" --docs="docs" \ + --controller-roles="1" --controller-accounts="" --vote-quorum=30 --vote-period=86400 --vote-enactment=1000 \ + --bond="1000000ukex" \ + --issurance-config='{"premint":"10000","postmint":"10000","time":"1680044405"}' \ + --lp-pool-config='{"ratio": "1.0", "drip": 86400}' \ + --binary-info='{"name":"layer2dex","hash":"0cc0","source":"github.com","reference":"","type":"exec"}' \ + --from=validator --chain-id=testing --fees=100ukex --keyring-backend=test --home=$HOME/.sekaid --yes --broadcast-mode=block +sekaid query customgov proposals +sekaid tx customgov proposal vote 2 1 --from validator --keyring-backend=test --home=$HOME/.sekaid --chain-id=testing --fees=100ukex --yes --broadcast-mode=block + +sekaid tx layer2 redeem-dapp-pool l2dex 10lp/ul2d 0.1 --from=validator --chain-id=testing --fees=100ukex --keyring-backend=test --home=$HOME/.sekaid --yes --broadcast-mode=block +sekaid tx layer2 swap-dapp-pool l2dex 10ukex 0.1 --from=validator --chain-id=testing --fees=100ukex --keyring-backend=test --home=$HOME/.sekaid --yes --broadcast-mode=block +sekaid tx layer2 convert-dapp-pool l2dex l2agg 10lp/ul2d 0.1 --from=validator --chain-id=testing --fees=100ukex --keyring-backend=test --home=$HOME/.sekaid --yes --broadcast-mode=block +sekaid tx layer2 pause-dapp l2dex --from=validator --chain-id=testing --fees=100ukex --keyring-backend=test --home=$HOME/.sekaid --yes --broadcast-mode=block +sekaid tx layer2 unpause-dapp l2dex --from=validator --chain-id=testing --fees=100ukex --keyring-backend=test --home=$HOME/.sekaid --yes --broadcast-mode=block +sekaid tx layer2 reactivate-dapp l2dex --from=validator --chain-id=testing --fees=100ukex --keyring-backend=test --home=$HOME/.sekaid --yes --broadcast-mode=block +sekaid tx layer2 transfer-dapp '{"amounts":[{"bridge_token_index":"1","amount":"100000"}],"source_dapp":"1","source_account":"1","dest_dapp":"2","dest_beneficiary":"2","xam":""}' --from=validator --chain-id=testing --fees=100ukex --keyring-backend=test --home=$HOME/.sekaid --yes --broadcast-mode=block + +sekaid tx layer2 mint-create-ft-tx l2gov "L2 Governance Token" "L2GOV" "" "" "" "" 6 10000000 0 1000 $(sekaid keys show -a validator --keyring-backend=test) --from=validator --chain-id=testing --fees=100ukex --keyring-backend=test --home=$HOME/.sekaid --yes --broadcast-mode=block +sekaid tx layer2 mint-create-nft-tx l2gov "L2 Governance Token" "L2GOV" "" "" "" "" 6 10000000 0 1000 $(sekaid keys show -a validator --keyring-backend=test) "" "" --from=validator --chain-id=testing --fees=100ukex --keyring-backend=test --home=$HOME/.sekaid --yes --broadcast-mode=block +sekaid tx layer2 mint-issue-tx ku/l2gov 1000000 $(sekaid keys show -a validator --keyring-backend=test) --from=validator --chain-id=testing --fees=100ukex --keyring-backend=test --home=$HOME/.sekaid --yes --broadcast-mode=block +sekaid tx layer2 burn-issue-tx ku/l2gov 900000 --from=validator --chain-id=testing --fees=100ukex --keyring-backend=test --home=$HOME/.sekaid --yes --broadcast-mode=block diff --git a/scripts/commands/metadata.sh b/scripts/commands/metadata.sh new file mode 100644 index 000000000..f13518cd9 --- /dev/null +++ b/scripts/commands/metadata.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +sekaid export-metadata diff --git a/scripts/commands/query-distributor.sh b/scripts/commands/query-distributor.sh index 5413781cd..89dd61687 100644 --- a/scripts/commands/query-distributor.sh +++ b/scripts/commands/query-distributor.sh @@ -10,4 +10,7 @@ sekaid query distributor fees-treasury sekaid query distributor snapshot-period # query validator performance -sekaid query distributor snapshot-period-performance kiravaloper177endc8f4tnl44q0x2qct6g9l5af6nm2vlzxd6 \ No newline at end of file +sekaid query distributor snapshot-period-performance kiravaloper177endc8f4tnl44q0x2qct6g9l5af6nm2vlzxd6 + +# query year start snapshot to check inflation from snapshot time +sekaid query distributor year-start-snapshot \ No newline at end of file diff --git a/scripts/commands/recovery.sh b/scripts/commands/recovery.sh new file mode 100644 index 000000000..d678fb68d --- /dev/null +++ b/scripts/commands/recovery.sh @@ -0,0 +1,51 @@ +#!/bin/bash + +# command to generate recovery secret +sekaid tx recovery generate-recovery-secret 10a0fbe01030000122300000000000 +NONCE=00 +PROOF=29eeb09666c4792c314e631063932621f573cbb07af7274657d1314e1892eb93 +CHALLENGE=220c7e47a53ef4c2161035308d4fdc52f619e54f8a657b208ba3708139fdc03d + +# commmand to create an account +sekaid keys add recovery --keyring-backend=test +RECOVERY=$(sekaid keys show -a recovery --keyring-backend=test) + +# commands to query +sekaid query recovery recovery-record $(sekaid keys show -a validator --keyring-backend=test) + +# command to register recovery secret +sekaid tx recovery register-recovery-secret $CHALLENGE $NONCE $PROOF --from=validator --keyring-backend=test --chain-id=testing --fees=1000ukex -y --home=$HOME/.sekaid --broadcast-mode=block + +# command to rotate +sekaid tx recovery rotate-recovery-address $RECOVERY $PROOF --from=validator --chain-id=testing --keyring-backend=test --fees=1000ukex -y --home=$HOME/.sekaid --yes --broadcast-mode=block + +# command to check validators after rotation +sekaid query customstaking validators --moniker="" --addr="" --val-addr="" --moniker="" --status="" --pubkey="" --proposer="" + +# upsert staking pool before rotation +sekaid tx multistaking upsert-staking-pool kiravaloper18ka9xpvwh75sgldgke69jmxsnkhjm0wa3ns9xa --commission=0.5 --from=validator --keyring-backend=test --fees=100ukex --chain-id=testing -y --broadcast-mode=block + +# recovery token queries +sekaid query recovery rr-holder-rewards $(sekaid keys show -a validator --keyring-backend=test) +sekaid query recovery rr-holders rr/hello +sekaid query bank balances $(sekaid keys show -a validator --keyring-backend=test) + +# recovery token txs +sekaid keys add recovery --keyring-backend=test +sekaid keys add recovery2 --keyring-backend=test +RECOVERY=$(sekaid keys show -a recovery --keyring-backend=test) +RECOVERY2=$(sekaid keys show -a recovery2 --keyring-backend=test) +VALIDATOR=$(sekaid keys show -a validator --keyring-backend=test) + +sekaid tx recovery issue-recovery-tokens --from=validator --keyring-backend=test --chain-id=testing --fees=1000ukex -y --home=$HOME/.sekaid --broadcast-mode=block +sekaid tx recovery burn-recovery-tokens 10000000rr/hello --from=validator --keyring-backend=test --chain-id=testing --fees=1000ukex -y --home=$HOME/.sekaid --broadcast-mode=block +sekaid tx recovery register-rrtoken-holder --from=validator --keyring-backend=test --chain-id=testing --fees=1000ukex -y --home=$HOME/.sekaid --broadcast-mode=block +sekaid tx recovery claim-rrtoken-rewards --from=validator --keyring-backend=test --chain-id=testing --fees=1000ukex -y --home=$HOME/.sekaid --broadcast-mode=block +sekaid tx recovery rotate-validator-by-half-rr-holder $VALIDATOR $RECOVERY --from=validator --keyring-backend=test --chain-id=testing --fees=1000ukex -y --home=$HOME/.sekaid --broadcast-mode=block + +# upsert-staking-pool after recovery +sekaid tx bank send validator $RECOVERY 10000000000000rr/hello,100000ukex --from=validator --keyring-backend=test --chain-id=testing --fees=1000ukex -y --home=$HOME/.sekaid --broadcast-mode=block + +sekaid tx multistaking upsert-staking-pool kiravaloper1zwyxw66aw0fd3xv9e9ewyk58c0qdcn5synp3dt --commission=0.5 --from=recovery --keyring-backend=test --fees=100ukex --chain-id=testing -y --broadcast-mode=block +sekaid tx recovery rotate-validator-by-half-rr-holder $RECOVERY $VALIDATOR --from=recovery --keyring-backend=test --chain-id=testing --fees=1000ukex -y --home=$HOME/.sekaid --broadcast-mode=block +sekaid tx recovery rotate-validator-by-half-rr-holder $RECOVERY $RECOVERY2 --from=recovery --keyring-backend=test --chain-id=testing --fees=1000ukex -y --home=$HOME/.sekaid --broadcast-mode=block diff --git a/scripts/commands/spending-pool.sh b/scripts/commands/spending-pool.sh index 1c32ac48f..807adafb0 100644 --- a/scripts/commands/spending-pool.sh +++ b/scripts/commands/spending-pool.sh @@ -1,6 +1,6 @@ #!/bin/bash -sekaid tx spending create-spending-pool --name="ValidatorRewardsPool" --claim-start=$(($(date -u +%s))) --claim-end=0 --rates=0.1ukex --vote-quorum="33" --vote-period="60" --vote-enactment="30" --owner-roles="" --owner-accounts=$(sekaid keys show -a validator --keyring-backend=test --home=$HOME/.sekaid) --beneficiary-roles="1" --beneficiary-role-weights="1" --from=validator --chain-id=testing --fees=100ukex --keyring-backend=test --home=$HOME/.sekaid --yes --broadcast-mode=block +sekaid tx spending create-spending-pool --name="ValidatorRewardsPool" --claim-start=$(($(date -u +%s))) --claim-end=0 --claim-expiry=43200 --rates=0.1ukex --vote-quorum="33" --vote-period="60" --vote-enactment="30" --owner-roles="" --owner-accounts=$(sekaid keys show -a validator --keyring-backend=test --home=$HOME/.sekaid) --beneficiary-roles="1" --beneficiary-role-weights="1" --from=validator --chain-id=testing --fees=100ukex --keyring-backend=test --home=$HOME/.sekaid --yes --broadcast-mode=block sekaid tx spending deposit-spending-pool --name="ValidatorRewardsPool" --amount=1000000ukex --from=validator --chain-id=testing --fees=100ukex --keyring-backend=test --home=$HOME/.sekaid --yes --broadcast-mode=block diff --git a/scripts/commands/ubi.sh b/scripts/commands/ubi.sh index bd9d8972b..46ef777cf 100644 --- a/scripts/commands/ubi.sh +++ b/scripts/commands/ubi.sh @@ -30,5 +30,5 @@ sekaid tx customgov proposal vote 2 1 --from validator --keyring-backend=test -- sekaid tx customgov proposal vote 3 1 --from validator --keyring-backend=test --home=$HOME/.sekaid --chain-id=testing --fees=100ukex --yes --broadcast-mode=block # check ubi is only allowed for bond denom pools -sekaid tx spending create-spending-pool --name="ValTokenRewardsPool" --claim-start=$(($(date -u +%s))) --claim-end=0 --rates=0.1valtoken --vote-quorum="33" --vote-period="60" --vote-enactment="30" --owner-roles="" --owner-accounts=$(sekaid keys show -a validator --keyring-backend=test --home=$HOME/.sekaid) --beneficiary-roles="1" --beneficiary-role-weights="1" --from=validator --chain-id=testing --fees=100ukex --keyring-backend=test --home=$HOME/.sekaid --yes --broadcast-mode=block +sekaid tx spending create-spending-pool --name="ValTokenRewardsPool" --claim-start=$(($(date -u +%s))) --claim-end=0 --claim-expiry=43200 --rates=0.1valtoken --vote-quorum="33" --vote-period="60" --vote-enactment="30" --owner-roles="" --owner-accounts=$(sekaid keys show -a validator --keyring-backend=test --home=$HOME/.sekaid) --beneficiary-roles="1" --beneficiary-role-weights="1" --from=validator --chain-id=testing --fees=100ukex --keyring-backend=test --home=$HOME/.sekaid --yes --broadcast-mode=block sekaid tx ubi proposal-upsert-ubi --title="title" --description="description" --name="ValidatorPerMinuteIncome" --distr-start=0 --distr-end=0 --amount=15 --period=60 --pool-name="ValTokenRewardsPool" --from=validator --keyring-backend=test --home=$HOME/.sekaid --chain-id=testing --fees=100ukex --yes --broadcast-mode=block diff --git a/scripts/protocgen.sh b/scripts/protocgen.sh index c1cead6fd..ea307fb16 100755 --- a/scripts/protocgen.sh +++ b/scripts/protocgen.sh @@ -7,7 +7,7 @@ set -o pipefail go get github.com/regen-network/cosmos-proto/protoc-gen-gocosmos 2>/dev/null # get cosmos sdk from github -go get github.com/cosmos/cosmos-sdk@v0.45.4 2>/dev/null +go get github.com/cosmos/cosmos-sdk@v0.45.10 2>/dev/null # Get the path of the cosmos-sdk repo from go/pkg/mod cosmos_sdk_dir=$(go list -f '{{ .Dir }}' -m github.com/cosmos/cosmos-sdk) diff --git a/scripts/sekai-utils.sh b/scripts/sekai-utils.sh index 7dac385eb..26c96ec5e 100755 --- a/scripts/sekai-utils.sh +++ b/scripts/sekai-utils.sh @@ -1299,4 +1299,69 @@ function passwordConfirmTransaction() { local FEE_DENOM="$6" sekaid tx custody confirm --from=$FROM $ADDRESS $HASH $PASSWORD --keyring-backend=test --chain-id=$NETWORK_NAME --fees "${FEE_AMOUNT}${FEE_DENOM}" --output=json --yes --home=$SEKAID_HOME | txAwait 180 +} + +#createPoll +function createPoll() { + local FROM=$1 + local ROLES=$2 + local OPTIONS=$3 + local TYPE=$4 + local CHOICES=$5 + local COUNT=$6 + local DURATION=$7 + + sekaid tx customgov poll create --from=$FROM --title="TITLE" --description="DESCRIPTION" --poll-roles=$ROLES --poll-options=$OPTIONS --poll-count=$COUNT --poll-type=$TYPE --poll-choices=$CHOICES --poll-duration=$DURATION --keyring-backend=test --chain-id=$NETWORK_NAME --fees="100ukex" --output=json --yes --home=$SEKAID_HOME +} + +function getPolls() { + local FROM=$1 + local RESULT="" + + RESULT=$(sekaid query customgov polls $FROM --output=json --home=$SEKAID_HOME 2> /dev/null | jsonParse "polls" 2> /dev/null || echo -n "") + + echo "$RESULT" +} + +function getPollResult() { + local FROM=$1 + local ID=$2 + local RESULT="" + + RESULT=$(sekaid query customgov polls $FROM --output=json --home=$SEKAID_HOME 2> /dev/null | jsonParse "polls.$ID.result" 2> /dev/null || echo -n "") + + echo "$RESULT" +} + + +function getPollTimeout() { + local FROM=$1 + local ID=$2 + local RESULT="" + + RESULT=$(sekaid query customgov polls $FROM --output=json --home=$SEKAID_HOME 2> /dev/null | jsonParse "polls.$ID.voting_end_time" 2> /dev/null || echo -n "") + + echo "$RESULT" +} + +function addVote() { + local FROM=$1 + local ID=$2 + local VALUE=$3 + local CVALUE=$4 + local RESULT="" + + sekaid tx customgov poll vote $ID $VALUE --poll-custom-value=$CVALUE --from=$FROM --keyring-backend=test --chain-id=$NETWORK_NAME --fees="100ukex" --output=json --yes --home=$SEKAID_HOME | txAwait 180 +} + +function getPollVotes() { + local FROM=$1 + local ID=$2 + local RESULT="" + + sekaid query customgov poll-votes $ID --output=json --home=$SEKAID_HOME + + RESULT=$(sekaid query customgov poll-votes $ID --output=json --home=$SEKAID_HOME 2> /dev/null | jsonParse "" 2> /dev/null || echo -n "") + + echo "$RESULT" } \ No newline at end of file diff --git a/scripts/test-local.sh b/scripts/test-local.sh index 1176d7812..a2e04313e 100755 --- a/scripts/test-local.sh +++ b/scripts/test-local.sh @@ -34,6 +34,9 @@ echoInfo "INFO: Launching local network..." echoInfo "INFO: Testing wallets & transfers..." ./scripts/test-local/token-transfers.sh || ( systemctl2 stop sekai && exit 1 ) +echoInfo "INFO: Testing polls..." +./scripts/test-local/poll-processes.sh || ( systemctl2 stop sekai && exit 1 ) + echoInfo "INFO: Testing account permissions whitelist, blacklist & clear..." ./scripts/test-local/account-permissions.sh || ( systemctl2 stop sekai && exit 1 ) diff --git a/scripts/test-local/poll-processes.sh b/scripts/test-local/poll-processes.sh new file mode 100644 index 000000000..592f890d8 --- /dev/null +++ b/scripts/test-local/poll-processes.sh @@ -0,0 +1,105 @@ +#!/usr/bin/env bash +# To run test locally: make network-start && ./scripts/test-local/token-transfers.sh +set -e +set -x +. /etc/profile +. ./scripts/sekai-env.sh + +TEST_NAME="POLL" && timerStart $TEST_NAME +echoInfo "INFO: $TEST_NAME - Integration Test - START" + +addAccount polltester1 +addAccount polltester2 +addAccount polltester3 +addAccount polltester4 +addAccount polltester5 + +ACCOUNT1_ADDRESS=$(showAddress polltester1) +ACCOUNT2_ADDRESS=$(showAddress polltester2) +ACCOUNT3_ADDRESS=$(showAddress polltester3) +ACCOUNT4_ADDRESS=$(showAddress polltester4) +ACCOUNT5_ADDRESS=$(showAddress polltester5) + +sendTokens validator "$ACCOUNT1_ADDRESS" 1000000000000 ukex 100 ukex +sendTokens validator "$ACCOUNT2_ADDRESS" 1000000000000 ukex 100 ukex +sendTokens validator "$ACCOUNT3_ADDRESS" 1000000000000 ukex 100 ukex +sendTokens validator "$ACCOUNT4_ADDRESS" 1000000000000 ukex 100 ukex +sendTokens validator "$ACCOUNT5_ADDRESS" 1000000000000 ukex 100 ukex + +createRole validator poll_voter description +assignRole validator poll_voter polltester1 +assignRole validator poll_voter polltester2 +assignRole validator poll_voter polltester3 +assignRole validator poll_voter polltester4 +assignRole validator poll_voter polltester5 + +whitelistPermission validator 66 polltester1 +whitelistPermission validator 66 polltester2 +whitelistPermission validator 66 polltester3 +whitelistPermission validator 66 polltester4 +whitelistPermission validator 66 polltester5 + +#createPoll 1 +createPoll polltester1 poll_voter yes,no,mbe string 1 3 1m + +#checkPollResult 1 +POLL_RESULT=$(getPollResult "$ACCOUNT1_ADDRESS" 0) + +[ "$POLL_RESULT" != "POLL_PENDING" ] && echoErr "ERROR: Expected result 0 to be POLL_PENDING, but got '$POLL_RESULT'" && exit 1 +# ------------ +sleep 60s +POLL_RESULT=$(getPollResult "$ACCOUNT1_ADDRESS" 0) + +[ "$POLL_RESULT" != "POLL_RESULT_QUORUM_NOT_REACHED" ] && echoErr "ERROR: Expected result 1 should be POLL_RESULT_QUORUM_NOT_REACHED, but got '$POLL_RESULT'" && exit 1 +# ------------ + +#createPoll 2 +createPoll polltester1 poll_voter yes,no,mbe string 1 3 1m + +addVote polltester2 2 2 yes +addVote polltester3 2 2 yes +addVote polltester4 2 2 yes +addVote polltester5 2 2 yes + +sleep 60s +POLL_RESULT=$(getPollResult "$ACCOUNT1_ADDRESS" 1) + +[ "$POLL_RESULT" != "POLL_RESULT_PASSED" ] && echoErr "ERROR: Expected result 2 to be POLL_RESULT_PASSED, but got '$POLL_RESULT'" && exit 1 +# ------------ + +createPoll polltester1 poll_voter yes,no,mbe string 1 3 1m +addVote polltester2 3 3 +addVote polltester3 3 3 +addVote polltester4 3 3 +addVote polltester5 3 2 mbe + +sleep 60s +POLL_RESULT=$(getPollResult "$ACCOUNT1_ADDRESS" 2) + +[ "$POLL_RESULT" != "POLL_RESULT_REJECTED_WITH_VETO" ] && echoErr "ERROR: Expected result 3 to be POLL_RESULT_REJECTED_WITH_VETO, but got '$POLL_RESULT'" && exit 1 +# ------------ + +createPoll polltester1 poll_voter yes,no,mbe string 1 3 1m +addVote polltester2 4 1 +addVote polltester3 4 1 +addVote polltester4 4 3 +addVote polltester5 4 2 mbe + +sleep 60s +POLL_RESULT=$(getPollResult "$ACCOUNT1_ADDRESS" 3) + +[ "$POLL_RESULT" != "POLL_RESULT_REJECTED" ] && echoErr "ERROR: Expected result 4 to be POLL_RESULT_REJECTED, but got '$POLL_RESULT'" && exit 1 +# ------------ + +createPoll polltester1 poll_voter 1,2,3 int 1 4 1m +addVote polltester2 5 2 4 +addVote polltester3 5 2 4 +addVote polltester4 5 2 4 + +sleep 60s +POLL_RESULT=$(getPollResult "$ACCOUNT1_ADDRESS" 4) + +[ "$POLL_RESULT" != "POLL_RESULT_PASSED" ] && echoErr "ERROR: Expected result 6 to be POLL_RESULT_PASSED, but got '$POLL_RESULT'" && exit 1 +# ------------ + +echoInfo "INFO: $TEST_NAME - Integration Test - END, elapsed: $(prettyTime "$(timerSpan $TEST_NAME)")" \ No newline at end of file diff --git a/types/Msg.go b/types/Msg.go index 2c1d377a0..ede78bb8a 100644 --- a/types/Msg.go +++ b/types/Msg.go @@ -13,6 +13,9 @@ const ( // governance MsgTypeSubmitProposal = "submit-proposal" MsgTypeVoteProposal = "vote-proposal" + MsgTypeCreatePoll = "create-poll" + MsgTypeVotePoll = "vote-poll" + MsgTypeAddressPoll = "address-poll" MsgTypeWhitelistPermissions = "whitelist-permissions" MsgTypeBlacklistPermissions = "blacklist-permissions" @@ -66,6 +69,15 @@ const ( MsgTypePause = "pause" MsgTypeUnpause = "unpause" + // recovery module + MsgTypeRegisterRecoverySecret = "register-recovery-secret" + MsgTypeRotateRecoveryAddress = "rotate-recovery-address" + MsgTypeIssueRecoveryTokens = "issue-recovery-tokens" + MsgTypeBurnRecoveryTokens = "burn-recovery-tokens" + MsgTypeRegisterRRTokenHolder = "register-rrtoken-holder" + MsgTypeClaimRRHolderRewards = "claim-rrholder-rewards" + MsgTypeRotateValidatorByHalfRRTokenHolder = "rotate-validator-by-half-rr-token-holder" + //upgrade module // spending module @@ -93,6 +105,33 @@ const ( MsgTypeBondCollective = "bond-collective" MsgTypeDonateCollective = "donate-collective" MsgTypeWithdrawCollective = "withdraw-collective" + + // layer2 module + MsgTypeCreateDappProposal = "create-dapp-proposal" + MsgTypeBondDappProposal = "bond-dapp-proposal" + MsgTypeReclaimDappBondProposal = "reclaim-dapp-bond-proposal" + MsgTypeJoinDappVerifierWithBond = "join-dapp-verifier-with-bond" + MsgTypeExitDapp = "exit-dapp" + MsgTypeVoteDappOperatorTx = "vote-dapp-operator-tx" + MsgTypeRedeemDappPoolTx = "redeem-dapp-pool-tx" + MsgTypeSwapDappPoolTx = "swap-dapp-pool-tx" + MsgTypeConvertDappPoolTx = "convert-dapp-pool-tx" + MsgTypePauseDappTx = "pause-dapp-tx" + MsgTypeUnPauseDappTx = "unpause-dapp-tx" + MsgTypeReactivateDappTx = "reactivate-dapp-tx" + MsgTypeExecuteDappTx = "execute-dapp-tx" + MsgTypeDenounceLeaderTx = "denounce-leader-tx" + MsgTypeTransitionDappTx = "transition-dapp-tx" + MsgTypeApproveDappTransitionTx = "approve-dapp-transition-tx" + MsgTypeRejectDappTransitionTx = "reject-dapp-transition-tx" + MsgTypeUpsertDappProposalTx = "upsert-dapp-proposal-tx" + MsgTypeVoteUpsertDappProposalTx = "vote-upsert-dapp-proposal-tx" + MsgTypeTransferDappTx = "transfer-dapp-tx" + MsgTypeAckTransferDappTx = "ack-transfer-dapp-tx" + MsgTypeMintCreateFtTx = "mint-create-ft-tx" + MsgTypeMintCreateNftTx = "mint-create-nft-tx" + MsgTypeMintIssueTx = "mint-issue-tx" + MsgTypeMintBurnTx = "mint-burn-tx" ) // Msg defines the interface a transaction message must fulfill. diff --git a/types/Proposal.go b/types/Proposal.go index ee400c2c5..c42ed4865 100644 --- a/types/Proposal.go +++ b/types/Proposal.go @@ -41,6 +41,10 @@ const ( ProposalTypeCollectiveSendDonation = "CollectiveSendDonation" ProposalTypeCollectiveUpdate = "CollectiveUpdate" ProposalTypeCollectiveRemove = "CollectiveRemove" + + ProposalTypeJoinDapp = "JoinDapp" + ProposalTypeTransitionDapp = "TransitionDapp" + ProposalTypeUpsertDapp = "UpsertDapp" ) var AllProposalTypes []string = []string{ diff --git a/types/constants.go b/types/constants.go index bc272416c..81c9e599a 100644 --- a/types/constants.go +++ b/types/constants.go @@ -3,6 +3,6 @@ package types const ( // we set page iteration limit for safety PageIterationLimit = 512 - SekaiVersion = "v0.3.7.31" + SekaiVersion = "v0.3.15.1" CosmosVersion = "v0.45.10" ) diff --git a/x/collectives/keeper/collective.go b/x/collectives/keeper/collective.go index 9c00aaab3..26cd8b709 100644 --- a/x/collectives/keeper/collective.go +++ b/x/collectives/keeper/collective.go @@ -67,7 +67,7 @@ func (k Keeper) GetCollectiveContributer(ctx sdk.Context, name string, contribut return cc } -func (k Keeper) GetAllCollectiveContributers(ctx sdk.Context, name string) []types.CollectiveContributor { +func (k Keeper) GetCollectiveContributers(ctx sdk.Context, name string) []types.CollectiveContributor { store := ctx.KVStore(k.storeKey) cclist := []types.CollectiveContributor{} @@ -82,6 +82,21 @@ func (k Keeper) GetAllCollectiveContributers(ctx sdk.Context, name string) []typ return cclist } +func (k Keeper) GetAllCollectiveContributers(ctx sdk.Context) []types.CollectiveContributor { + store := ctx.KVStore(k.storeKey) + + cclist := []types.CollectiveContributor{} + it := sdk.KVStorePrefixIterator(store, []byte(types.PrefixCollectiveContributerKey)) + defer it.Close() + + for ; it.Valid(); it.Next() { + cc := types.CollectiveContributor{} + k.cdc.MustUnmarshal(it.Value(), &cc) + cclist = append(cclist, cc) + } + return cclist +} + func (k Keeper) SendDonation(ctx sdk.Context, name string, account sdk.AccAddress, coins sdk.Coins) error { collective := k.GetCollective(ctx, name) if collective.Name == "" { @@ -151,7 +166,7 @@ func (k Keeper) ExecuteCollectiveRemove(ctx sdk.Context, collective types.Collec return err } - for _, cc := range k.GetAllCollectiveContributers(ctx, collective.Name) { + for _, cc := range k.GetCollectiveContributers(ctx, collective.Name) { err := k.WithdrawCollective(ctx, collective, cc) if err != nil { return err diff --git a/x/collectives/keeper/collective_test.go b/x/collectives/keeper/collective_test.go index 2cabda44f..3f0c4b1ba 100644 --- a/x/collectives/keeper/collective_test.go +++ b/x/collectives/keeper/collective_test.go @@ -116,12 +116,12 @@ func (suite *KeeperTestSuite) TestCollectiveContributerSetGetDelete() { suite.Require().Equal(c, contributer) } - allContributers := suite.app.CollectivesKeeper.GetAllCollectiveContributers(suite.ctx, contributers[0].Name) + allContributers := suite.app.CollectivesKeeper.GetCollectiveContributers(suite.ctx, contributers[0].Name) suite.Require().Len(allContributers, 1) suite.app.CollectivesKeeper.DeleteCollectiveContributer(suite.ctx, contributers[0].Name, contributers[0].Address) - allContributers = suite.app.CollectivesKeeper.GetAllCollectiveContributers(suite.ctx, contributers[0].Name) + allContributers = suite.app.CollectivesKeeper.GetCollectiveContributers(suite.ctx, contributers[0].Name) suite.Require().Len(allContributers, 0) contributer := suite.app.CollectivesKeeper.GetCollectiveContributer(suite.ctx, contributers[0].Name, contributers[0].Address) diff --git a/x/collectives/keeper/grpc_query.go b/x/collectives/keeper/grpc_query.go index 2c6606a31..70cf8ee84 100644 --- a/x/collectives/keeper/grpc_query.go +++ b/x/collectives/keeper/grpc_query.go @@ -24,7 +24,7 @@ func (q Querier) Collective(c context.Context, request *types.CollectiveRequest) ctx := sdk.UnwrapSDKContext(c) return &types.CollectiveResponse{ Collective: q.keeper.GetCollective(ctx, request.Name), - Contributers: q.keeper.GetAllCollectiveContributers(ctx, request.Name), + Contributers: q.keeper.GetCollectiveContributers(ctx, request.Name), }, nil } diff --git a/x/custody/keeper/custody.go b/x/custody/keeper/custody.go index c71c9dc50..8a892a135 100644 --- a/x/custody/keeper/custody.go +++ b/x/custody/keeper/custody.go @@ -150,6 +150,12 @@ func (k Keeper) AddToCustodyLimitsStatus(ctx sdk.Context, record types.CustodyLi store.Set(key, k.cdc.MustMarshal(record.CustodyStatuses)) } +func (k Keeper) DropCustodyLimitsStatus(ctx sdk.Context, addr sdk.AccAddress) { + store := ctx.KVStore(k.storeKey) + key := append([]byte(types.PrefixKeyCustodyLimitsStatus), addr...) + store.Delete(key) +} + func (k Keeper) AddToCustodyPool(ctx sdk.Context, record types.CustodyPool) { store := ctx.KVStore(k.storeKey) key := append([]byte(types.PrefixKeyCustodyPool), record.Address...) @@ -157,6 +163,12 @@ func (k Keeper) AddToCustodyPool(ctx sdk.Context, record types.CustodyPool) { store.Set(key, k.cdc.MustMarshal(record.Transactions)) } +func (k Keeper) DropCustodyPool(ctx sdk.Context, addr sdk.AccAddress) { + store := ctx.KVStore(k.storeKey) + key := append([]byte(types.PrefixKeyCustodyPool), addr...) + store.Delete(key) +} + func (k Keeper) GetCustodyPoolByAddress(ctx sdk.Context, address sdk.AccAddress) *types.TransactionPool { prefixStore := prefix.NewStore(ctx.KVStore(k.storeKey), []byte(types.PrefixKeyCustodyPool)) bz := prefixStore.Get(address) diff --git a/x/distributor/client/cli/query.go b/x/distributor/client/cli/query.go index 889260f7f..69265d858 100644 --- a/x/distributor/client/cli/query.go +++ b/x/distributor/client/cli/query.go @@ -22,6 +22,7 @@ func NewQueryCmd() *cobra.Command { GetCmdQueryFeesCollected(), GetCmdSnapshotPeriod(), GetCmdValidatorSnapshotPerformance(), + GetCmdYearStartSnapshot(), ) return queryCmd @@ -120,3 +121,26 @@ func GetCmdValidatorSnapshotPerformance() *cobra.Command { return cmd } + +func GetCmdYearStartSnapshot() *cobra.Command { + cmd := &cobra.Command{ + Use: "year-start-snapshot", + Short: "Year start snapshot", + Args: cobra.MinimumNArgs(0), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + + queryClient := types.NewQueryClient(clientCtx) + res, err := queryClient.YearStartSnapshot(context.Background(), &types.QueryYearStartSnapshotRequest{}) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/distributor/keeper/abci.go b/x/distributor/keeper/abci.go index ea259f77a..c9f7fda4e 100644 --- a/x/distributor/keeper/abci.go +++ b/x/distributor/keeper/abci.go @@ -66,4 +66,16 @@ func (k Keeper) EndBlocker(ctx sdk.Context) { k.DeleteValidatorVote(ctx, consAddr, vote.Height) } } + + yearSnapshot := k.GetYearStartSnapshot(ctx) + month := int64(86400 * 30) + year := month * 12 + if yearSnapshot.SnapshotTime == 0 || yearSnapshot.SnapshotTime+year < ctx.BlockTime().Unix() { + supply := k.bk.GetSupply(ctx, k.BondDenom(ctx)) + yearSnapshot = types.YearStartSnapshot{ + SnapshotTime: ctx.BlockTime().Unix(), + SnapshotAmount: supply.Amount, + } + k.SetYearStartSnapshot(ctx, yearSnapshot) + } } diff --git a/x/distributor/keeper/annual_inflation.go b/x/distributor/keeper/annual_inflation.go new file mode 100644 index 000000000..fdbed9cae --- /dev/null +++ b/x/distributor/keeper/annual_inflation.go @@ -0,0 +1,47 @@ +package keeper + +import ( + "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/KiraCore/sekai/x/distributor/types" +) + +func (k Keeper) GetYearStartSnapshot(ctx sdk.Context) types.YearStartSnapshot { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.KeyYearStartSnapshot) + if bz == nil { + return types.YearStartSnapshot{} + } + + snapshot := types.YearStartSnapshot{} + k.cdc.MustUnmarshal(bz, &snapshot) + return snapshot +} + +func (k Keeper) SetYearStartSnapshot(ctx sdk.Context, snapshot types.YearStartSnapshot) { + store := ctx.KVStore(k.storeKey) + store.Set(types.KeyYearStartSnapshot, k.cdc.MustMarshal(&snapshot)) +} + +func (k Keeper) InflationPossible(ctx sdk.Context) bool { + snapshot := k.GetYearStartSnapshot(ctx) + if snapshot.SnapshotAmount.IsNil() || snapshot.SnapshotAmount.IsZero() { + return true + } + yearlyInflation := k.gk.GetNetworkProperties(ctx).MaxAnnualInflation + currSupply := k.bk.GetSupply(ctx, k.BondDenom(ctx)) + + month := int64(86400 * 30) + currTimeGone := ctx.BlockTime().Unix() - snapshot.SnapshotTime + monthIndex := (currTimeGone + month - 1) / month + currInflation := currSupply.Amount.ToDec().Quo(sdk.Dec(snapshot.SnapshotAmount.ToDec())).Sub(sdk.OneDec()) + fmt.Println("currInflation", currInflation.String()) + fmt.Println("monthIndex", monthIndex) + fmt.Println("est.Inflation", yearlyInflation.Mul(sdk.NewDec(monthIndex)).Quo(sdk.NewDec(12)).String()) + if currInflation.GTE(yearlyInflation.Mul(sdk.NewDec(monthIndex)).Quo(sdk.NewDec(12))) { + return false + } + return true +} diff --git a/x/distributor/keeper/annual_inflation_test.go b/x/distributor/keeper/annual_inflation_test.go new file mode 100644 index 000000000..f4b6db29c --- /dev/null +++ b/x/distributor/keeper/annual_inflation_test.go @@ -0,0 +1,33 @@ +package keeper_test + +import ( + "time" + + "github.com/KiraCore/sekai/x/distributor/types" + sdk "github.com/cosmos/cosmos-sdk/types" + minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" +) + +func (suite *KeeperTestSuite) TestYearStartSnapshot() { + ctx := suite.ctx + now := time.Now().UTC() + snapshot := suite.app.DistrKeeper.GetYearStartSnapshot(ctx) + suite.Require().Equal(snapshot.SnapshotTime, int64(0)) + + newSnapshot := types.YearStartSnapshot{ + SnapshotTime: now.Unix(), + SnapshotAmount: sdk.NewInt(1000000), + } + suite.app.DistrKeeper.SetYearStartSnapshot(ctx, newSnapshot) + snapshot = suite.app.DistrKeeper.GetYearStartSnapshot(ctx) + suite.Require().Equal(snapshot, newSnapshot) + + ctx = ctx.WithBlockTime(now) + inflationPossible := suite.app.DistrKeeper.InflationPossible(ctx) + suite.Require().True(inflationPossible) + + err := suite.app.BankKeeper.MintCoins(ctx, minttypes.ModuleName, sdk.Coins{sdk.NewInt64Coin("ukex", 2000000)}) + suite.Require().NoError(err) + inflationPossible = suite.app.DistrKeeper.InflationPossible(ctx) + suite.Require().False(inflationPossible) +} diff --git a/x/distributor/keeper/distributor.go b/x/distributor/keeper/distributor.go index f54019f2e..6c80c92bf 100644 --- a/x/distributor/keeper/distributor.go +++ b/x/distributor/keeper/distributor.go @@ -3,6 +3,7 @@ package keeper import ( "fmt" + recoverytypes "github.com/KiraCore/sekai/x/recovery/types" stakingtypes "github.com/KiraCore/sekai/x/staking/types" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" @@ -18,7 +19,9 @@ func (k Keeper) AllocateTokens( ctx sdk.Context, sumPreviousPrecommitPower, totalPreviousPower int64, previousProposer sdk.ConsAddress, bondedVotes []abci.VoteInfo, ) { - + if !k.InflationPossible(ctx) { + return + } // fetch and clear the collected fees for distribution, since this is // called in BeginBlock, collected fees will be from the previous block // (and distributed to the previous proposer) @@ -113,11 +116,26 @@ func (k Keeper) AllocateTokens( // AllocateTokensToValidator allocate tokens to a particular validator, splitting according to commission func (k Keeper) AllocateTokensToValidator(ctx sdk.Context, val stakingtypes.Validator, tokens sdk.Coins) { - // send coins from fee pool to validator account - err := k.bk.SendCoinsFromModuleToAccount(ctx, authtypes.FeeCollectorName, sdk.AccAddress(val.GetValKey()), tokens) - if err != nil { - panic(err) + acc := sdk.AccAddress(val.GetValKey()) + _, err := k.rk.GetRecoveryToken(ctx, acc.String()) + if err == nil { + // send tokens to recovery module in case validator issued recovery token + err := k.bk.SendCoinsFromModuleToModule(ctx, authtypes.FeeCollectorName, recoverytypes.ModuleName, tokens) + if err != nil { + panic(err) + } + err = k.rk.IncreaseRecoveryTokenUnderlying(ctx, acc, tokens) + if err != nil { + panic(err) + } + } else { + // send coins from fee pool to validator account + err := k.bk.SendCoinsFromModuleToAccount(ctx, authtypes.FeeCollectorName, acc, tokens) + if err != nil { + panic(err) + } } + } // GetPreviousProposerConsAddr returns the proposer consensus address for the diff --git a/x/distributor/keeper/distributor_test.go b/x/distributor/keeper/distributor_test.go index e3842d319..e99d72f80 100644 --- a/x/distributor/keeper/distributor_test.go +++ b/x/distributor/keeper/distributor_test.go @@ -1,12 +1,55 @@ package keeper_test import ( + recoverytypes "github.com/KiraCore/sekai/x/recovery/types" + stakingtypes "github.com/KiraCore/sekai/x/staking/types" + "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" abci "github.com/tendermint/tendermint/abci/types" "github.com/tendermint/tendermint/crypto/ed25519" ) +func (suite *KeeperTestSuite) TestAllocateTokensToRecoveryTokenValidator() { + suite.SetupTest() + addr1 := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address().Bytes()) + addr2 := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address().Bytes()) + + valAddr := sdk.ValAddress(addr1) + pubkeys := simapp.CreateTestPubKeys(1) + pubKey := pubkeys[0] + consAddr := sdk.ConsAddress(pubKey.Address()) + val, err := stakingtypes.NewValidator(valAddr, pubKey) + suite.Require().NoError(err) + + coins := sdk.Coins{sdk.NewInt64Coin("ukex", 10000000)} + + suite.app.CustomStakingKeeper.AddValidator(suite.ctx, val) + suite.app.RecoveryKeeper.SetRecoveryToken(suite.ctx, recoverytypes.RecoveryToken{ + Address: addr1.String(), + Token: "rr/validator1", + RrSupply: sdk.NewInt(1000_000), + UnderlyingTokens: coins, + }) + + err = suite.app.BankKeeper.MintCoins(suite.ctx, minttypes.ModuleName, coins) + suite.Require().NoError(err) + err = suite.app.BankKeeper.SendCoinsFromModuleToAccount(suite.ctx, minttypes.ModuleName, addr1, coins) + suite.Require().NoError(err) + err = suite.app.BankKeeper.MintCoins(suite.ctx, minttypes.ModuleName, coins) + suite.Require().NoError(err) + err = suite.app.BankKeeper.SendCoinsFromModuleToAccount(suite.ctx, minttypes.ModuleName, addr2, coins) + suite.Require().NoError(err) + + suite.app.DistrKeeper.AllocateTokens(suite.ctx, 10, 10, consAddr, []abci.VoteInfo{}) + balance := suite.app.BankKeeper.GetAllBalances(suite.ctx, addr1) + suite.Require().Equal(balance, coins) + + // recoveryToken, err := suite.app.RecoveryKeeper.GetRecoveryToken(suite.ctx, addr1.String()) + // suite.Require().NoError(err) + // suite.Require().NotEqual(coins.String(), sdk.Coins(recoveryToken.UnderlyingTokens).String()) +} + func (suite *KeeperTestSuite) TestAllocateTokens() { suite.SetupTest() addr1 := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address().Bytes()) diff --git a/x/distributor/keeper/grpc_query.go b/x/distributor/keeper/grpc_query.go index 5bb38f858..541f13c9d 100644 --- a/x/distributor/keeper/grpc_query.go +++ b/x/distributor/keeper/grpc_query.go @@ -55,3 +55,11 @@ func (q Querier) SnapshotPeriodPerformance(c context.Context, request *types.Que Performance: performance, }, nil } + +func (q Querier) YearStartSnapshot(c context.Context, request *types.QueryYearStartSnapshotRequest) (*types.QueryYearStartSnapshotResponse, error) { + ctx := sdk.UnwrapSDKContext(c) + + return &types.QueryYearStartSnapshotResponse{ + Snapshot: q.keeper.GetYearStartSnapshot(ctx), + }, nil +} diff --git a/x/distributor/keeper/keeper.go b/x/distributor/keeper/keeper.go index 9d4641340..cbdbbda75 100644 --- a/x/distributor/keeper/keeper.go +++ b/x/distributor/keeper/keeper.go @@ -15,10 +15,11 @@ type Keeper struct { sk types.StakingKeeper gk types.CustomGovKeeper mk types.MultiStakingKeeper + rk types.RecoveryKeeper } // NewKeeper returns instance of a keeper -func NewKeeper(storeKey sdk.StoreKey, cdc codec.BinaryCodec, ak types.AccountKeeper, bk types.BankKeeper, sk types.StakingKeeper, gk types.CustomGovKeeper, mk types.MultiStakingKeeper) Keeper { +func NewKeeper(storeKey sdk.StoreKey, cdc codec.BinaryCodec, ak types.AccountKeeper, bk types.BankKeeper, sk types.StakingKeeper, gk types.CustomGovKeeper, mk types.MultiStakingKeeper, rk types.RecoveryKeeper) Keeper { return Keeper{ cdc: cdc, storeKey: storeKey, @@ -27,6 +28,7 @@ func NewKeeper(storeKey sdk.StoreKey, cdc codec.BinaryCodec, ak types.AccountKee sk: sk, gk: gk, mk: mk, + rk: rk, } } diff --git a/x/distributor/module.go b/x/distributor/module.go index 04b0ddd0b..368fb23f2 100644 --- a/x/distributor/module.go +++ b/x/distributor/module.go @@ -99,6 +99,7 @@ func (am AppModule) InitGenesis( am.distributorKeeper.SetFeesCollected(ctx, genesisState.FeesCollected) am.distributorKeeper.SetFeesTreasury(ctx, genesisState.FeesTreasury) am.distributorKeeper.SetSnapPeriod(ctx, genesisState.SnapPeriod) + am.distributorKeeper.SetYearStartSnapshot(ctx, genesisState.YearStartSnapshot) for _, vote := range genesisState.ValidatorVotes { consAddr, err := sdk.ConsAddressFromBech32(vote.ConsAddr) @@ -126,6 +127,7 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw genesisState.SnapPeriod = am.distributorKeeper.GetSnapPeriod(ctx) genesisState.ValidatorVotes = am.distributorKeeper.GetAllValidatorVotes(ctx) genesisState.PreviousProposer = am.distributorKeeper.GetPreviousProposerConsAddr(ctx).String() + genesisState.YearStartSnapshot = am.distributorKeeper.GetYearStartSnapshot(ctx) return cdc.MustMarshalJSON(&genesisState) } diff --git a/x/distributor/types/expected_keepers.go b/x/distributor/types/expected_keepers.go index e7b50eb86..d6e09eff9 100644 --- a/x/distributor/types/expected_keepers.go +++ b/x/distributor/types/expected_keepers.go @@ -3,6 +3,7 @@ package types import ( govtypes "github.com/KiraCore/sekai/x/gov/types" multistakingtypes "github.com/KiraCore/sekai/x/multistaking/types" + recoverytypes "github.com/KiraCore/sekai/x/recovery/types" spendingtypes "github.com/KiraCore/sekai/x/spending/types" stakingtypes "github.com/KiraCore/sekai/x/staking/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -41,3 +42,8 @@ type MultiStakingKeeper interface { GetStakingPoolByValidator(ctx sdk.Context, validator string) (pool multistakingtypes.StakingPool, found bool) IncreasePoolRewards(ctx sdk.Context, pool multistakingtypes.StakingPool, rewards sdk.Coins) } + +type RecoveryKeeper interface { + GetRecoveryToken(ctx sdk.Context, address string) (recoverytypes.RecoveryToken, error) + IncreaseRecoveryTokenUnderlying(ctx sdk.Context, addr sdk.AccAddress, amount sdk.Coins) error +} diff --git a/x/distributor/types/genesis.pb.go b/x/distributor/types/genesis.pb.go index dbf055e5c..188c7cf10 100644 --- a/x/distributor/types/genesis.pb.go +++ b/x/distributor/types/genesis.pb.go @@ -76,6 +76,51 @@ func (m *ValidatorVote) GetHeight() int64 { return 0 } +type YearStartSnapshot struct { + SnapshotTime int64 `protobuf:"varint,1,opt,name=snapshot_time,json=snapshotTime,proto3" json:"snapshot_time,omitempty"` + SnapshotAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=snapshot_amount,json=snapshotAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"snapshot_amount"` +} + +func (m *YearStartSnapshot) Reset() { *m = YearStartSnapshot{} } +func (m *YearStartSnapshot) String() string { return proto.CompactTextString(m) } +func (*YearStartSnapshot) ProtoMessage() {} +func (*YearStartSnapshot) Descriptor() ([]byte, []int) { + return fileDescriptor_e815530f0f0e0b78, []int{1} +} +func (m *YearStartSnapshot) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *YearStartSnapshot) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_YearStartSnapshot.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 *YearStartSnapshot) XXX_Merge(src proto.Message) { + xxx_messageInfo_YearStartSnapshot.Merge(m, src) +} +func (m *YearStartSnapshot) XXX_Size() int { + return m.Size() +} +func (m *YearStartSnapshot) XXX_DiscardUnknown() { + xxx_messageInfo_YearStartSnapshot.DiscardUnknown(m) +} + +var xxx_messageInfo_YearStartSnapshot proto.InternalMessageInfo + +func (m *YearStartSnapshot) GetSnapshotTime() int64 { + if m != nil { + return m.SnapshotTime + } + return 0 +} + // GenesisState defines the distributor module's genesis state. type GenesisState struct { // fees that are kept in treasury that is not distributed yet - community pool @@ -88,13 +133,15 @@ type GenesisState struct { ValidatorVotes []ValidatorVote `protobuf:"bytes,4,rep,name=validator_votes,json=validatorVotes,proto3" json:"validator_votes"` // previous proposer PreviousProposer string `protobuf:"bytes,5,opt,name=previous_proposer,json=previousProposer,proto3" json:"previous_proposer,omitempty"` + // year start snapshot + YearStartSnapshot YearStartSnapshot `protobuf:"bytes,6,opt,name=year_start_snapshot,json=yearStartSnapshot,proto3" json:"year_start_snapshot"` } 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_e815530f0f0e0b78, []int{1} + return fileDescriptor_e815530f0f0e0b78, []int{2} } func (m *GenesisState) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -144,40 +191,53 @@ func (m *GenesisState) GetPreviousProposer() string { return "" } +func (m *GenesisState) GetYearStartSnapshot() YearStartSnapshot { + if m != nil { + return m.YearStartSnapshot + } + return YearStartSnapshot{} +} + func init() { proto.RegisterType((*ValidatorVote)(nil), "kira.distributor.ValidatorVote") + proto.RegisterType((*YearStartSnapshot)(nil), "kira.distributor.YearStartSnapshot") proto.RegisterType((*GenesisState)(nil), "kira.distributor.GenesisState") } func init() { proto.RegisterFile("kira/distributor/genesis.proto", fileDescriptor_e815530f0f0e0b78) } var fileDescriptor_e815530f0f0e0b78 = []byte{ - // 385 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x92, 0x4f, 0x6b, 0xdb, 0x30, - 0x18, 0xc6, 0xed, 0xb8, 0x2b, 0x8b, 0xfa, 0x67, 0x9d, 0x18, 0xc3, 0x6c, 0x60, 0x9b, 0x5e, 0x66, - 0x18, 0xb5, 0x60, 0xfb, 0x04, 0x4b, 0x06, 0x3d, 0x0c, 0x46, 0xf1, 0x4a, 0x0e, 0xbb, 0x18, 0xc5, - 0x7a, 0xe7, 0x88, 0xa4, 0x7e, 0x8d, 0x5e, 0xd9, 0xac, 0xdf, 0x62, 0x1f, 0xab, 0xc7, 0x1e, 0x47, - 0x0f, 0x65, 0x24, 0x5f, 0x64, 0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0xc2, 0x63, 0x76, 0x44, 0xb5, - 0x6c, 0x8a, 0x06, 0x8c, 0x46, 0x15, 0x06, 0x2e, 0x1b, 0xeb, 0xa5, 0x2b, 0xa7, 0xf0, 0xaf, 0xec, - 0x45, 0xb7, 0x6d, 0xa9, 0xe8, 0xd0, 0x02, 0x85, 0x07, 0x49, 0x90, 0x1e, 0x7d, 0x88, 0xb3, 0x7f, - 0x7b, 0xce, 0xf6, 0xea, 0x9c, 0x1c, 0xf4, 0xa3, 0xe5, 0xa7, 0xdd, 0xae, 0x48, 0xfc, 0x3d, 0x7b, - 0xd9, 0x18, 0xe8, 0x34, 0xb6, 0x54, 0x34, 0x06, 0x1b, 0x24, 0x30, 0xe1, 0x33, 0x57, 0xf6, 0xd9, - 0xd6, 0xb8, 0x1a, 0xf4, 0xc9, 0xe5, 0xdd, 0x3a, 0xf2, 0xef, 0xd7, 0x91, 0xff, 0x67, 0x1d, 0xf9, - 0xbf, 0x36, 0x91, 0x77, 0xbf, 0x89, 0xbc, 0xdf, 0x9b, 0xc8, 0xfb, 0x7e, 0xb1, 0x93, 0xf7, 0x8b, - 0x36, 0x72, 0x8a, 0x06, 0x04, 0xc1, 0x52, 0x6a, 0xf1, 0x73, 0xef, 0x6d, 0xb8, 0xe8, 0xf3, 0x43, - 0x77, 0xe5, 0x1f, 0xff, 0x06, 0x00, 0x00, 0xff, 0xff, 0xe3, 0x6d, 0xce, 0xc6, 0x3c, 0x02, 0x00, - 0x00, + // 480 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x93, 0xdf, 0x8a, 0xd3, 0x40, + 0x14, 0xc6, 0x9b, 0xcd, 0x5a, 0xec, 0xf4, 0xcf, 0x6e, 0x47, 0x91, 0xa0, 0x90, 0x96, 0x2e, 0x68, + 0x40, 0x36, 0x81, 0xf5, 0x09, 0xb6, 0x15, 0x16, 0x11, 0x64, 0x49, 0x4b, 0x65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 0x9e, 0xcf, 0xdc, 0x10, 0x13, 0x2f, 0x44, 0x99, 0xa0, 0x2c, 0x1f, 0xe7, 0x32, + 0x5a, 0x78, 0x6a, 0x9d, 0x81, 0x74, 0xdf, 0xa5, 0xca, 0xef, 0x54, 0x98, 0x4b, 0x4d, 0x19, 0x7c, + 0x37, 0x49, 0xeb, 0x6a, 0x97, 0xc9, 0x58, 0x31, 0x05, 0x74, 0x42, 0xda, 0x9f, 0x01, 0x64, 0xa0, + 0x04, 0x30, 0x99, 0x8b, 0xb5, 0x65, 0xf4, 0x4d, 0xa7, 0x31, 0xf4, 0xca, 0x3a, 0xaf, 0xfe, 0xa1, + 0xce, 0x08, 0x79, 0xea, 0xb7, 0x0a, 0xca, 0xa4, 0x84, 0xd0, 0x29, 0xe9, 0x68, 0x6a, 0x88, 0xcb, + 0x25, 0x84, 0x0a, 0x22, 0xeb, 0xe8, 0xff, 0xb0, 0xba, 0xb9, 0x51, 0x45, 0xa1, 0x3d, 0xd2, 0x2c, + 0x3e, 0x28, 0xc8, 0x40, 0x70, 0x8c, 0x2c, 0x53, 0x47, 0x47, 0x0a, 0xe9, 0x5a, 0x2b, 0xf4, 0x03, + 0x39, 0x59, 0x55, 0x93, 0x0b, 0x56, 0xa8, 0x40, 0x5a, 0xc7, 0x7d, 0xd3, 0x69, 0x5e, 0xf4, 0xdc, + 0xbf, 0x67, 0xef, 0x3e, 0x18, 0xf1, 0xf0, 0xb8, 0x68, 0xcd, 0xef, 0xac, 0xf6, 0x45, 0x49, 0x5f, + 0x93, 0x6e, 0x26, 0x60, 0xc5, 0x31, 0x97, 0x41, 0x26, 0x30, 0x43, 0x09, 0xc2, 0x7a, 0xa4, 0x17, + 0xe0, 0xb4, 0x32, 0xae, 0x4b, 0x9d, 0xde, 0x90, 0x27, 0x6b, 0x60, 0x22, 0x90, 0xc5, 0xc0, 0x83, + 0x2a, 0x79, 0xab, 0xde, 0x37, 0x9c, 0xe6, 0xc5, 0xd9, 0x61, 0x03, 0x07, 0xcb, 0x51, 0x36, 0xd1, + 0x5d, 0x1f, 0x18, 0x57, 0xb7, 0x1b, 0xdb, 0xb8, 0xdb, 0xd8, 0xc6, 0xaf, 0x8d, 0x6d, 0x7c, 0xdd, + 0xda, 0xb5, 0xbb, 0xad, 0x5d, 0xfb, 0xb1, 0xb5, 0x6b, 0x9f, 0xce, 0xf7, 0xa2, 0x7c, 0xcf, 0x05, + 0x1b, 0xa1, 0x00, 0x4f, 0xc2, 0x82, 0x71, 0xef, 0xcb, 0x83, 0x5f, 0x41, 0xa7, 0x3a, 0xab, 0xeb, + 0x0d, 0x7f, 0xf3, 0x3b, 0x00, 0x00, 0xff, 0xff, 0xc1, 0x06, 0x50, 0xe4, 0x2b, 0x03, 0x00, 0x00, } func (m *ValidatorVote) Marshal() (dAtA []byte, err error) { @@ -215,6 +275,44 @@ func (m *ValidatorVote) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *YearStartSnapshot) 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 *YearStartSnapshot) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *YearStartSnapshot) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.SnapshotAmount.Size() + i -= size + if _, err := m.SnapshotAmount.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if m.SnapshotTime != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.SnapshotTime)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + func (m *GenesisState) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -235,6 +333,16 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + { + size, err := m.YearStartSnapshot.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 if len(m.PreviousProposer) > 0 { i -= len(m.PreviousProposer) copy(dAtA[i:], m.PreviousProposer) @@ -319,6 +427,20 @@ func (m *ValidatorVote) Size() (n int) { return n } +func (m *YearStartSnapshot) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.SnapshotTime != 0 { + n += 1 + sovGenesis(uint64(m.SnapshotTime)) + } + l = m.SnapshotAmount.Size() + n += 1 + l + sovGenesis(uint64(l)) + return n +} + func (m *GenesisState) Size() (n int) { if m == nil { return 0 @@ -350,6 +472,8 @@ func (m *GenesisState) Size() (n int) { if l > 0 { n += 1 + l + sovGenesis(uint64(l)) } + l = m.YearStartSnapshot.Size() + n += 1 + l + sovGenesis(uint64(l)) return n } @@ -460,6 +584,109 @@ func (m *ValidatorVote) Unmarshal(dAtA []byte) error { } return nil } +func (m *YearStartSnapshot) 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: YearStartSnapshot: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: YearStartSnapshot: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field SnapshotTime", wireType) + } + m.SnapshotTime = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.SnapshotTime |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SnapshotAmount", 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 + } + if err := m.SnapshotAmount.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 (m *GenesisState) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -646,6 +873,39 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { } m.PreviousProposer = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field YearStartSnapshot", 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.YearStartSnapshot.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) diff --git a/x/distributor/types/keys.go b/x/distributor/types/keys.go index a5ffdc10c..fb77d2366 100644 --- a/x/distributor/types/keys.go +++ b/x/distributor/types/keys.go @@ -12,4 +12,5 @@ var ( SnapPeriodKey = []byte("snap_period") ProposerKey = []byte("proposer_key") PrefixKeyValidatorVote = []byte("validator_vote_prefix") + KeyYearStartSnapshot = []byte("year_start_snapshot") ) diff --git a/x/distributor/types/query.pb.go b/x/distributor/types/query.pb.go index a9baf598f..4585f1f64 100644 --- a/x/distributor/types/query.pb.go +++ b/x/distributor/types/query.pb.go @@ -356,6 +356,86 @@ func (m *QuerySnapshotPeriodPerformanceResponse) GetSnapshotPeriod() int64 { return 0 } +type QueryYearStartSnapshotRequest struct { +} + +func (m *QueryYearStartSnapshotRequest) Reset() { *m = QueryYearStartSnapshotRequest{} } +func (m *QueryYearStartSnapshotRequest) String() string { return proto.CompactTextString(m) } +func (*QueryYearStartSnapshotRequest) ProtoMessage() {} +func (*QueryYearStartSnapshotRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_4d334d1f8d9e2298, []int{8} +} +func (m *QueryYearStartSnapshotRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryYearStartSnapshotRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryYearStartSnapshotRequest.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 *QueryYearStartSnapshotRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryYearStartSnapshotRequest.Merge(m, src) +} +func (m *QueryYearStartSnapshotRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryYearStartSnapshotRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryYearStartSnapshotRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryYearStartSnapshotRequest proto.InternalMessageInfo + +type QueryYearStartSnapshotResponse struct { + Snapshot YearStartSnapshot `protobuf:"bytes,1,opt,name=snapshot,proto3" json:"snapshot"` +} + +func (m *QueryYearStartSnapshotResponse) Reset() { *m = QueryYearStartSnapshotResponse{} } +func (m *QueryYearStartSnapshotResponse) String() string { return proto.CompactTextString(m) } +func (*QueryYearStartSnapshotResponse) ProtoMessage() {} +func (*QueryYearStartSnapshotResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_4d334d1f8d9e2298, []int{9} +} +func (m *QueryYearStartSnapshotResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryYearStartSnapshotResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryYearStartSnapshotResponse.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 *QueryYearStartSnapshotResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryYearStartSnapshotResponse.Merge(m, src) +} +func (m *QueryYearStartSnapshotResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryYearStartSnapshotResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryYearStartSnapshotResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryYearStartSnapshotResponse proto.InternalMessageInfo + +func (m *QueryYearStartSnapshotResponse) GetSnapshot() YearStartSnapshot { + if m != nil { + return m.Snapshot + } + return YearStartSnapshot{} +} + func init() { proto.RegisterType((*QueryFeesTreasuryRequest)(nil), "kira.distributor.QueryFeesTreasuryRequest") proto.RegisterType((*QueryFeesTreasuryResponse)(nil), "kira.distributor.QueryFeesTreasuryResponse") @@ -365,48 +445,56 @@ func init() { proto.RegisterType((*QuerySnapshotPeriodResponse)(nil), "kira.distributor.QuerySnapshotPeriodResponse") proto.RegisterType((*QuerySnapshotPeriodPerformanceRequest)(nil), "kira.distributor.QuerySnapshotPeriodPerformanceRequest") proto.RegisterType((*QuerySnapshotPeriodPerformanceResponse)(nil), "kira.distributor.QuerySnapshotPeriodPerformanceResponse") + proto.RegisterType((*QueryYearStartSnapshotRequest)(nil), "kira.distributor.QueryYearStartSnapshotRequest") + proto.RegisterType((*QueryYearStartSnapshotResponse)(nil), "kira.distributor.QueryYearStartSnapshotResponse") } func init() { proto.RegisterFile("kira/distributor/query.proto", fileDescriptor_4d334d1f8d9e2298) } var fileDescriptor_4d334d1f8d9e2298 = []byte{ - // 576 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x94, 0x41, 0x6f, 0xd3, 0x3e, - 0x18, 0xc6, 0x9b, 0x4d, 0xfb, 0x4b, 0xf3, 0x1f, 0xc6, 0xb0, 0x38, 0xac, 0x59, 0x95, 0x55, 0x91, - 0xa0, 0x5d, 0x4b, 0x63, 0x0a, 0x07, 0xb8, 0xb2, 0x8a, 0x21, 0xb4, 0xcb, 0x56, 0x76, 0xe2, 0x52, - 0x39, 0x89, 0x9b, 0x59, 0x6d, 0xe3, 0xcc, 0x76, 0x26, 0x2a, 0xc4, 0x85, 0x4f, 0x80, 0xc4, 0x85, - 0x03, 0x07, 0x3e, 0x4e, 0x8f, 0x93, 0xb8, 0x20, 0x0e, 0x13, 0xb4, 0x7c, 0x10, 0x54, 0xc7, 0x2d, - 0x69, 0x9b, 0xb2, 0x22, 0x71, 0x6a, 0xea, 0xc7, 0xef, 0xfb, 0xfc, 0x5e, 0xf9, 0xb1, 0x41, 0xa1, - 0x43, 0x39, 0x46, 0x3e, 0x15, 0x92, 0x53, 0x37, 0x96, 0x8c, 0xa3, 0xf3, 0x98,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, 0x4e, 0x38, 0x77, 0xf8, 0xf0, 0x87, 0x01, - 0xf2, 0x4b, 0x73, 0x05, 0x1f, 0xaf, 0xe4, 0xbf, 0x98, 0x6f, 0xf3, 0xc9, 0xdf, 0x17, 0xea, 0x19, - 0x4e, 0xd4, 0x0c, 0x47, 0xf0, 0xc5, 0xca, 0x33, 0xb4, 0x52, 0xf9, 0x46, 0x6f, 0x16, 0xae, 0xd5, - 0xdb, 0x83, 0xe7, 0x83, 0xa1, 0x65, 0x5c, 0x0e, 0x2d, 0xe3, 0xfb, 0xd0, 0x32, 0xde, 0x8f, 0xac, - 0xdc, 0xe5, 0xc8, 0xca, 0x7d, 0x1d, 0x59, 0xb9, 0x57, 0xb5, 0xd4, 0x2b, 0x72, 0x44, 0x39, 0x6e, - 0x30, 0x4e, 0x90, 0x20, 0x1d, 0x4c, 0xd1, 0xeb, 0x19, 0x6b, 0xf5, 0xa0, 0xb8, 0xff, 0xa9, 0xd7, - 0xf4, 0xd1, 0xaf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x8c, 0x41, 0x40, 0x77, 0xfa, 0x05, 0x00, 0x00, + // 665 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x95, 0x4f, 0x4f, 0x13, 0x4f, + 0x18, 0xc7, 0xbb, 0xf0, 0x83, 0xfc, 0x18, 0x14, 0x61, 0xe2, 0x01, 0x16, 0x5c, 0x48, 0x8d, 0xf2, + 0xcf, 0x76, 0x00, 0x63, 0xf4, 0x2a, 0x44, 0x8c, 0xe1, 0x02, 0x85, 0x8b, 0x5e, 0x9a, 0xd9, 0xed, + 0xc3, 0x32, 0xa1, 0xec, 0x2c, 0x33, 0x53, 0x62, 0x63, 0xbc, 0xf8, 0x0a, 0x4c, 0xbc, 0x78, 0xf0, + 0xe0, 0x1b, 0xf0, 0x7d, 0x70, 0x24, 0xf1, 0x62, 0x3c, 0x10, 0x05, 0x5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0x72, 0xe9, + 0x94, 0x5e, 0x54, 0x12, 0xf7, 0xef, 0x16, 0x13, 0x74, 0x83, 0x0b, 0x20, 0x12, 0x0e, 0x29, 0x23, + 0x2f, 0x7b, 0xca, 0xeb, 0xab, 0xd8, 0x1d, 0xd6, 0xff, 0x43, 0xf7, 0x7f, 0x05, 0x00, 0x00, 0xff, + 0xff, 0x83, 0xdf, 0x11, 0xbb, 0x54, 0x07, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -429,6 +517,8 @@ type QueryClient interface { SnapshotPeriod(ctx context.Context, in *QuerySnapshotPeriodRequest, opts ...grpc.CallOption) (*QuerySnapshotPeriodResponse, error) // SnapPeriodPerformance queries number of blocks signed during the snap period SnapshotPeriodPerformance(ctx context.Context, in *QuerySnapshotPeriodPerformanceRequest, opts ...grpc.CallOption) (*QuerySnapshotPeriodPerformanceResponse, error) + // Year start snapshot query + YearStartSnapshot(ctx context.Context, in *QueryYearStartSnapshotRequest, opts ...grpc.CallOption) (*QueryYearStartSnapshotResponse, error) } type queryClient struct { @@ -475,6 +565,15 @@ func (c *queryClient) SnapshotPeriodPerformance(ctx context.Context, in *QuerySn return out, nil } +func (c *queryClient) YearStartSnapshot(ctx context.Context, in *QueryYearStartSnapshotRequest, opts ...grpc.CallOption) (*QueryYearStartSnapshotResponse, error) { + out := new(QueryYearStartSnapshotResponse) + err := c.cc.Invoke(ctx, "/kira.distributor.Query/YearStartSnapshot", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // QueryServer is the server API for Query service. type QueryServer interface { // FeesTreasury queries fee treasury @@ -485,6 +584,8 @@ type QueryServer interface { SnapshotPeriod(context.Context, *QuerySnapshotPeriodRequest) (*QuerySnapshotPeriodResponse, error) // SnapPeriodPerformance queries number of blocks signed during the snap period SnapshotPeriodPerformance(context.Context, *QuerySnapshotPeriodPerformanceRequest) (*QuerySnapshotPeriodPerformanceResponse, error) + // Year start snapshot query + YearStartSnapshot(context.Context, *QueryYearStartSnapshotRequest) (*QueryYearStartSnapshotResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -503,6 +604,9 @@ func (*UnimplementedQueryServer) SnapshotPeriod(ctx context.Context, req *QueryS func (*UnimplementedQueryServer) SnapshotPeriodPerformance(ctx context.Context, req *QuerySnapshotPeriodPerformanceRequest) (*QuerySnapshotPeriodPerformanceResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method SnapshotPeriodPerformance not implemented") } +func (*UnimplementedQueryServer) YearStartSnapshot(ctx context.Context, req *QueryYearStartSnapshotRequest) (*QueryYearStartSnapshotResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method YearStartSnapshot not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -580,6 +684,24 @@ func _Query_SnapshotPeriodPerformance_Handler(srv interface{}, ctx context.Conte return interceptor(ctx, in, info, handler) } +func _Query_YearStartSnapshot_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryYearStartSnapshotRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).YearStartSnapshot(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/kira.distributor.Query/YearStartSnapshot", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).YearStartSnapshot(ctx, req.(*QueryYearStartSnapshotRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "kira.distributor.Query", HandlerType: (*QueryServer)(nil), @@ -600,6 +722,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "SnapshotPeriodPerformance", Handler: _Query_SnapshotPeriodPerformance_Handler, }, + { + MethodName: "YearStartSnapshot", + Handler: _Query_YearStartSnapshot_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "kira/distributor/query.proto", @@ -839,6 +965,62 @@ func (m *QuerySnapshotPeriodPerformanceResponse) MarshalToSizedBuffer(dAtA []byt return len(dAtA) - i, nil } +func (m *QueryYearStartSnapshotRequest) 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 *QueryYearStartSnapshotRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryYearStartSnapshotRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryYearStartSnapshotResponse) 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 *QueryYearStartSnapshotResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryYearStartSnapshotResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Snapshot.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { offset -= sovQuery(v) base := offset @@ -947,6 +1129,26 @@ func (m *QuerySnapshotPeriodPerformanceResponse) Size() (n int) { return n } +func (m *QueryYearStartSnapshotRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryYearStartSnapshotResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Snapshot.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -1514,6 +1716,139 @@ func (m *QuerySnapshotPeriodPerformanceResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryYearStartSnapshotRequest) 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: QueryYearStartSnapshotRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryYearStartSnapshotRequest: 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 *QueryYearStartSnapshotResponse) 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: QueryYearStartSnapshotResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryYearStartSnapshotResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Snapshot", 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.Snapshot.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipQuery(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/distributor/types/query.pb.gw.go b/x/distributor/types/query.pb.gw.go index 51a1a9216..dc80fc711 100644 --- a/x/distributor/types/query.pb.gw.go +++ b/x/distributor/types/query.pb.gw.go @@ -139,6 +139,24 @@ func local_request_Query_SnapshotPeriodPerformance_0(ctx context.Context, marsha } +func request_Query_YearStartSnapshot_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryYearStartSnapshotRequest + var metadata runtime.ServerMetadata + + msg, err := client.YearStartSnapshot(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_YearStartSnapshot_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryYearStartSnapshotRequest + var metadata runtime.ServerMetadata + + msg, err := server.YearStartSnapshot(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. @@ -225,6 +243,26 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_YearStartSnapshot_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.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_YearStartSnapshot_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_YearStartSnapshot_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -346,6 +384,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_YearStartSnapshot_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_YearStartSnapshot_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_YearStartSnapshot_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -357,6 +415,8 @@ var ( pattern_Query_SnapshotPeriod_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"kira", "distributor", "v1beta1", "snapshot_period"}, "", runtime.AssumeColonVerbOpt(true))) pattern_Query_SnapshotPeriodPerformance_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"kira", "distributor", "v1beta1", "snapshot_period_performance", "validator_address"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_YearStartSnapshot_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"kira", "distributor", "v1beta1", "year_start_snapshot"}, "", runtime.AssumeColonVerbOpt(true))) ) var ( @@ -367,4 +427,6 @@ var ( forward_Query_SnapshotPeriod_0 = runtime.ForwardResponseMessage forward_Query_SnapshotPeriodPerformance_0 = runtime.ForwardResponseMessage + + forward_Query_YearStartSnapshot_0 = runtime.ForwardResponseMessage ) diff --git a/x/feeprocessing/keeper/keeper_test.go b/x/feeprocessing/keeper/keeper_test.go index 151edacdb..563b9f78f 100644 --- a/x/feeprocessing/keeper/keeper_test.go +++ b/x/feeprocessing/keeper/keeper_test.go @@ -48,12 +48,13 @@ func TestNewKeeper_Executions(t *testing.T) { sdk.ZeroDec(), sdk.ZeroInt(), false, + false, ) app.FeeProcessingKeeper.AddExecutionStart(ctx, msg1) executions = app.FeeProcessingKeeper.GetExecutionsStatus(ctx) require.True(t, len(executions) == 1) - msg2 := tokenstypes.NewMsgUpsertTokenAlias(addr, "KEX", "Kira", "", 10, []string{"ukex"}) + msg2 := tokenstypes.NewMsgUpsertTokenAlias(addr, "KEX", "Kira", "", 10, []string{"ukex"}, false) app.FeeProcessingKeeper.AddExecutionStart(ctx, msg2) executions = app.FeeProcessingKeeper.GetExecutionsStatus(ctx) require.True(t, len(executions) == 2) @@ -63,6 +64,7 @@ func TestNewKeeper_Executions(t *testing.T) { sdk.ZeroDec(), sdk.ZeroInt(), false, + false, ) app.FeeProcessingKeeper.AddExecutionStart(ctx, msg3) executions = app.FeeProcessingKeeper.GetExecutionsStatus(ctx) @@ -177,6 +179,7 @@ func TestNewKeeper_ProcessExecutionFeeReturn(t *testing.T) { sdk.ZeroDec(), sdk.ZeroInt(), false, + false, ) app.FeeProcessingKeeper.AddExecutionStart(ctx, msg) app.FeeProcessingKeeper.ProcessExecutionFeeReturn(ctx) @@ -208,12 +211,14 @@ func TestNewKeeper_ProcessExecutionFeeReturn(t *testing.T) { sdk.ZeroDec(), sdk.ZeroInt(), false, + false, ) msg3 := tokenstypes.NewMsgUpsertTokenRate( addr3, "ukex", sdk.NewDec(1), true, sdk.ZeroDec(), sdk.ZeroInt(), false, + false, ) app.FeeProcessingKeeper.AddExecutionStart(ctx, msg3) app.FeeProcessingKeeper.AddExecutionStart(ctx, msg2) diff --git a/x/genutil/client/cli/standard_genesis_export.go b/x/genutil/client/cli/standard_genesis_export.go new file mode 100644 index 000000000..60af0ca61 --- /dev/null +++ b/x/genutil/client/cli/standard_genesis_export.go @@ -0,0 +1,66 @@ +package cli + +import ( + "encoding/json" + "fmt" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/types/module" + "github.com/cosmos/cosmos-sdk/version" + "github.com/pkg/errors" + "github.com/spf13/cobra" + tmtypes "github.com/tendermint/tendermint/types" + + tmjson "github.com/tendermint/tendermint/libs/json" + tmos "github.com/tendermint/tendermint/libs/os" +) + +// GetStandardGenesisExportedCmd returns standard genesis from genesis with spaces +func GetStandardGenesisExportedCmd(mbm module.BasicManager, txEncCfg client.TxEncodingConfig) *cobra.Command { + cmd := &cobra.Command{ + Use: "export-minimized-genesis [path-to-exported.json] [path-to-standard.json]", + Short: "Get minimized genesis from genesis with spaces", + Args: cobra.ExactArgs(2), + Long: fmt.Sprintf(`Get minimized genesis from not standard genesis. +Example: +$ %s export-minimized-genesis exported-genesis.json new-genesis.json +`, version.AppName, + ), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + cdc := clientCtx.JSONCodec + + genDoc, err := tmtypes.GenesisDocFromFile(args[0]) + if err != nil { + return errors.Wrapf(err, "failed to read genesis file %s", args[0]) + } + + var genesisState map[string]json.RawMessage + if err = json.Unmarshal(genDoc.AppState, &genesisState); err != nil { + return errors.Wrap(err, "failed to unmarshal genesis state") + } + + if err = mbm.ValidateGenesis(cdc, txEncCfg, genesisState); err != nil { + return errors.Wrap(err, "failed to validate genesis state") + } + + appState, err := json.MarshalIndent(genesisState, "", " ") + if err != nil { + return errors.Wrap(err, "Failed to marshall default genesis state") + } + + genDoc.AppState = appState + + genDocBytes, err := tmjson.Marshal(genDoc) + if err != nil { + return err + } + return tmos.WriteFile(args[1], genDocBytes, 0644) + }, + } + + return cmd +} diff --git a/x/genutil/client/cli/upgrade_genesis.go b/x/genutil/client/cli/upgrade_genesis.go index c49f8fb59..ad55ee1cd 100644 --- a/x/genutil/client/cli/upgrade_genesis.go +++ b/x/genutil/client/cli/upgrade_genesis.go @@ -15,9 +15,15 @@ import ( "github.com/cosmos/cosmos-sdk/version" "github.com/pkg/errors" "github.com/spf13/cobra" + tmjson "github.com/tendermint/tendermint/libs/json" + tmos "github.com/tendermint/tendermint/libs/os" tmtypes "github.com/tendermint/tendermint/types" ) +const ( + FlagJsonMinimize = "json-minimize" +) + func upgradedPlan(plan *v03123upgradetypes.PlanV03123) *upgradetypes.Plan { if plan == nil { return nil @@ -134,44 +140,61 @@ $ %s new-genesis-from-exported exported-genesis.json new-genesis.json RolePermissions: govGenesisV01228.Permissions, NetworkActors: govGenesisV01228.NetworkActors, NetworkProperties: &govtypes.NetworkProperties{ - MinTxFee: govGenesisV01228.NetworkProperties.MinTxFee, - MaxTxFee: govGenesisV01228.NetworkProperties.MaxTxFee, - VoteQuorum: govGenesisV01228.NetworkProperties.VoteQuorum, - MinimumProposalEndTime: govGenesisV01228.NetworkProperties.ProposalEndTime, - ProposalEnactmentTime: govGenesisV01228.NetworkProperties.ProposalEnactmentTime, - MinProposalEndBlocks: govGenesisV01228.NetworkProperties.MinProposalEndBlocks, - MinProposalEnactmentBlocks: govGenesisV01228.NetworkProperties.MinProposalEnactmentBlocks, - EnableForeignFeePayments: govGenesisV01228.NetworkProperties.EnableForeignFeePayments, - MischanceRankDecreaseAmount: govGenesisV01228.NetworkProperties.MischanceRankDecreaseAmount, - MaxMischance: govGenesisV01228.NetworkProperties.MaxMischance, - MischanceConfidence: govGenesisV01228.NetworkProperties.MischanceConfidence, - InactiveRankDecreasePercent: sdk.NewDecWithPrec(int64(govGenesisV01228.NetworkProperties.InactiveRankDecreasePercent), 2), - MinValidators: govGenesisV01228.NetworkProperties.MinValidators, - PoorNetworkMaxBankSend: govGenesisV01228.NetworkProperties.PoorNetworkMaxBankSend, - UnjailMaxTime: govGenesisV01228.NetworkProperties.JailMaxTime, - EnableTokenWhitelist: govGenesisV01228.NetworkProperties.EnableTokenWhitelist, - EnableTokenBlacklist: govGenesisV01228.NetworkProperties.EnableTokenBlacklist, - MinIdentityApprovalTip: govGenesisV01228.NetworkProperties.MinIdentityApprovalTip, - UniqueIdentityKeys: govGenesisV01228.NetworkProperties.UniqueIdentityKeys, - UbiHardcap: 6000_000, - ValidatorsFeeShare: sdk.NewDecWithPrec(50, 2), // 50% - InflationRate: sdk.NewDecWithPrec(18, 2), // 18% - InflationPeriod: 31557600, // 1 year - UnstakingPeriod: 2629800, // 1 month - MaxDelegators: 100, - MinDelegationPushout: 10, - SlashingPeriod: 3600, - MaxJailedPercentage: sdk.NewDecWithPrec(25, 2), - MaxSlashingPercentage: sdk.NewDecWithPrec(1, 2), - MinCustodyReward: 200, - MaxCustodyTxSize: 8192, - MaxCustodyBufferSize: 10, - AbstentionRankDecreaseAmount: 1, - MaxAbstention: 2, - MinCollectiveBond: 100_000, // in KEX - MinCollectiveBondingTime: 86400, // in seconds - MaxCollectiveOutputs: 10, - MinCollectiveClaimPeriod: 14400, // 4hrs + MinTxFee: govGenesisV01228.NetworkProperties.MinTxFee, + MaxTxFee: govGenesisV01228.NetworkProperties.MaxTxFee, + VoteQuorum: govGenesisV01228.NetworkProperties.VoteQuorum, + MinimumProposalEndTime: govGenesisV01228.NetworkProperties.ProposalEndTime, + ProposalEnactmentTime: govGenesisV01228.NetworkProperties.ProposalEnactmentTime, + MinProposalEndBlocks: govGenesisV01228.NetworkProperties.MinProposalEndBlocks, + MinProposalEnactmentBlocks: govGenesisV01228.NetworkProperties.MinProposalEnactmentBlocks, + EnableForeignFeePayments: govGenesisV01228.NetworkProperties.EnableForeignFeePayments, + MischanceRankDecreaseAmount: govGenesisV01228.NetworkProperties.MischanceRankDecreaseAmount, + MaxMischance: govGenesisV01228.NetworkProperties.MaxMischance, + MischanceConfidence: govGenesisV01228.NetworkProperties.MischanceConfidence, + InactiveRankDecreasePercent: sdk.NewDecWithPrec(int64(govGenesisV01228.NetworkProperties.InactiveRankDecreasePercent), 2), + MinValidators: govGenesisV01228.NetworkProperties.MinValidators, + PoorNetworkMaxBankSend: govGenesisV01228.NetworkProperties.PoorNetworkMaxBankSend, + UnjailMaxTime: govGenesisV01228.NetworkProperties.JailMaxTime, + EnableTokenWhitelist: govGenesisV01228.NetworkProperties.EnableTokenWhitelist, + EnableTokenBlacklist: govGenesisV01228.NetworkProperties.EnableTokenBlacklist, + MinIdentityApprovalTip: govGenesisV01228.NetworkProperties.MinIdentityApprovalTip, + UniqueIdentityKeys: govGenesisV01228.NetworkProperties.UniqueIdentityKeys, + UbiHardcap: 6000_000, + ValidatorsFeeShare: sdk.NewDecWithPrec(50, 2), // 50% + InflationRate: sdk.NewDecWithPrec(18, 2), // 18% + InflationPeriod: 31557600, // 1 year + UnstakingPeriod: 2629800, // 1 month + MaxDelegators: 100, + MinDelegationPushout: 10, + SlashingPeriod: 3600, + MaxJailedPercentage: sdk.NewDecWithPrec(25, 2), + MaxSlashingPercentage: sdk.NewDecWithPrec(1, 2), + MinCustodyReward: 200, + MaxCustodyTxSize: 8192, + MaxCustodyBufferSize: 10, + AbstentionRankDecreaseAmount: 1, + MaxAbstention: 2, + MinCollectiveBond: 100_000, // in KEX + MinCollectiveBondingTime: 86400, // in seconds + MaxCollectiveOutputs: 10, + MinCollectiveClaimPeriod: 14400, // 4hrs + ValidatorRecoveryBond: 300000, // 300k KEX + MaxAnnualInflation: sdk.NewDecWithPrec(35, 2), + MaxProposalTitleSize: 128, + MaxProposalDescriptionSize: 1024, + MaxProposalPollOptionSize: 64, + MaxProposalPollOptionCount: 128, + MinDappBond: 1000000, + MaxDappBond: 10000000, + DappBondDuration: 604800, + DappVerifierBond: sdk.NewDecWithPrec(1, 3), //0.1% + DappAutoDenounceTime: 60, // 60s + DappMischanceRankDecreaseAmount: 1, + DappMaxMischance: 10, + DappInactiveRankDecreasePercent: 10, + DappPoolSlippageDefault: sdk.NewDecWithPrec(1, 1), // 10% + MintingFtFee: 100_000_000_000_000, + MintingNftFee: 100_000_000_000_000, }, ExecutionFees: govGenesisV01228.ExecutionFees, PoorNetworkMessages: govGenesisV01228.PoorNetworkMessages, @@ -220,12 +243,23 @@ $ %s new-genesis-from-exported exported-genesis.json new-genesis.json } genDoc.AppState = appState + + if jsonMinimize, _ := cmd.Flags().GetBool(FlagJsonMinimize); jsonMinimize { + + genDocBytes, err := tmjson.Marshal(genDoc) + if err != nil { + return err + } + return tmos.WriteFile(args[1], genDocBytes, 0644) + } + if err = genutil.ExportGenesisFile(genDoc, args[1]); err != nil { return errors.Wrap(err, "Failed to export genesis file") } return nil }, } + cmd.Flags().Bool(FlagJsonMinimize, true, "flag to export genesis in minimized version") return cmd } diff --git a/x/gov/abci.go b/x/gov/abci.go index 3e5e613f6..c3e57e1b1 100644 --- a/x/gov/abci.go +++ b/x/gov/abci.go @@ -1,137 +1,188 @@ -package gov - -import ( - "fmt" - - "github.com/KiraCore/sekai/x/gov/keeper" - "github.com/KiraCore/sekai/x/gov/types" - sdk "github.com/cosmos/cosmos-sdk/types" -) - -func EndBlocker(ctx sdk.Context, k keeper.Keeper) { - enactmentIterator := k.GetEnactmentProposalsWithFinishedEnactmentEndTimeIterator(ctx, ctx.BlockTime()) - defer enactmentIterator.Close() - for ; enactmentIterator.Valid(); enactmentIterator.Next() { - proposalID := keeper.BytesToProposalID(enactmentIterator.Value()) - slash := k.GetAverageVotesSlash(ctx, proposalID) - processEnactmentProposal(ctx, k, proposalID, slash) - } - - activeIterator := k.GetActiveProposalsWithFinishedVotingEndTimeIterator(ctx, ctx.BlockTime()) - defer activeIterator.Close() - for ; activeIterator.Valid(); activeIterator.Next() { - processProposal(ctx, k, keeper.BytesToProposalID(activeIterator.Value())) - } -} - -func processProposal(ctx sdk.Context, k keeper.Keeper, proposalID uint64) { - proposal, found := k.GetProposal(ctx, proposalID) - if !found { - panic("proposal was expected to exist") - } - - // skip execution if block height condition does not meet - if proposal.MinVotingEndBlockHeight > ctx.BlockHeight() { - return - } - - votes := k.GetProposalVotes(ctx, proposalID) - - availableVoters := k.GetNetworkActorsByAbsoluteWhitelistPermission(ctx, proposal.GetContent().VotePermission()) - totalVoters := len(availableVoters) - - // councilor rank update function on absent - voteMap := make(map[string]bool) - for _, voter := range availableVoters { - voteMap[voter.Address.String()] = true - } - councilors := k.GetAllCouncilors(ctx) - for _, councilor := range councilors { - if !voteMap[councilor.Address.String()] { - k.OnCouncilorAbsent(ctx, councilor.Address) - } - } - - // update to spending pool users if it's spending pool proposal - content := proposal.GetContent() - if content.VotePermission() == types.PermZero { - router := k.GetProposalRouter() - totalVoters = len(router.AllowedAddressesDynamicProposal(ctx, content)) - if totalVoters == 0 { - totalVoters = 1 - } - } - numVotes := len(votes) - - properties := k.GetNetworkProperties(ctx) - - quorum := properties.VoteQuorum - if content.VotePermission() == types.PermZero { - router := k.GetProposalRouter() - quorum = router.QuorumDynamicProposal(ctx, content) - } - - isQuorum, err := types.IsQuorum(quorum, uint64(numVotes), uint64(totalVoters)) - if err != nil { - panic(fmt.Sprintf("Invalid quorum on proposal: proposalID=%d, proposalType=%s, err=%+v", proposalID, proposal.GetContent().ProposalType(), err)) - } - - if isQuorum { - numActorsWithVeto := len(types.GetActorsWithVoteWithVeto(availableVoters)) - calculatedVote := types.CalculateVotes(votes, uint64(numActorsWithVeto)) - - proposal.Result = calculatedVote.ProcessResult() - if proposal.Result == types.Passed { // This is done in order to show that proposal is in enactment, but after enactment passes it will be passed. - proposal.Result = types.Enactment - } - } else { - proposal.Result = types.QuorumNotReached - } - - // enactment time should be at least 1 block from voting period finish - proposal.MinEnactmentEndBlockHeight = ctx.BlockHeight() + int64(properties.MinProposalEnactmentBlocks) - k.SaveProposal(ctx, proposal) - k.RemoveActiveProposal(ctx, proposal) - k.AddToEnactmentProposals(ctx, proposal) - - ctx.EventManager().EmitEvent( - sdk.NewEvent( - types.EventTypeAddToEnactment, - sdk.NewAttribute(types.AttributeKeyProposalId, fmt.Sprintf("%d", proposal.ProposalId)), - sdk.NewAttribute(types.AttributeKeyProposalDescription, proposal.Description), - ), - ) -} - -func processEnactmentProposal(ctx sdk.Context, k keeper.Keeper, proposalID uint64, slash sdk.Dec) { - router := k.GetProposalRouter() - proposal, found := k.GetProposal(ctx, proposalID) - if !found { - panic("proposal was expected to exist") - } - - // skip execution if block height condition does not meet - if proposal.MinEnactmentEndBlockHeight > ctx.BlockHeight() { - return - } - - if proposal.Result == types.Enactment { - err := router.ApplyProposal(ctx, proposalID, proposal.GetContent(), slash) - if err != nil { - proposal.ExecResult = "execution failed" - } else { - proposal.ExecResult = "executed successfully" - } - proposal.Result = types.Passed - k.SaveProposal(ctx, proposal) - } - - k.RemoveEnactmentProposal(ctx, proposal) - ctx.EventManager().EmitEvent( - sdk.NewEvent( - types.EventTypeRemoveEnactment, - sdk.NewAttribute(types.AttributeKeyProposalId, fmt.Sprintf("%d", proposal.ProposalId)), - sdk.NewAttribute(types.AttributeKeyProposalDescription, proposal.Description), - ), - ) -} +package gov + +import ( + "fmt" + "time" + + "github.com/KiraCore/sekai/x/gov/keeper" + "github.com/KiraCore/sekai/x/gov/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func EndBlocker(ctx sdk.Context, k keeper.Keeper) { + enactmentIterator := k.GetEnactmentProposalsWithFinishedEnactmentEndTimeIterator(ctx, ctx.BlockTime()) + defer enactmentIterator.Close() + for ; enactmentIterator.Valid(); enactmentIterator.Next() { + proposalID := keeper.BytesToProposalID(enactmentIterator.Value()) + slash := k.GetAverageVotesSlash(ctx, proposalID) + processEnactmentProposal(ctx, k, proposalID, slash) + } + + activeIterator := k.GetActiveProposalsWithFinishedVotingEndTimeIterator(ctx, ctx.BlockTime()) + defer activeIterator.Close() + for ; activeIterator.Valid(); activeIterator.Next() { + processProposal(ctx, k, keeper.BytesToProposalID(activeIterator.Value())) + } + + pollIterator := k.GetPollsWithFinishedVotingEndTimeIterator(ctx, time.Now()) + defer pollIterator.Close() + for ; pollIterator.Valid(); pollIterator.Next() { + processPoll(ctx, k, sdk.BigEndianToUint64(pollIterator.Value())) + } +} + +func processPoll(ctx sdk.Context, k keeper.Keeper, pollID uint64) { + var totalVoters int + var actors []types.NetworkActor + var duplicateMap = make(map[string]bool) + + poll, err := k.GetPoll(ctx, pollID) + if err != nil { + panic(err) + } + + for _, role := range poll.Roles { + availableVoters := k.GetNetworkActorsByRole(ctx, role) + + for ; availableVoters.Valid(); availableVoters.Next() { + if _, ok := duplicateMap[sdk.AccAddress(availableVoters.Value()).String()]; !ok { + duplicateMap[sdk.AccAddress(availableVoters.Value()).String()] = true + actors = append(actors, k.GetNetworkActorOrFail(ctx, availableVoters.Value())) + } + } + } + + votes := k.GetPollVotes(ctx, pollID) + totalVoters += len(actors) + numVotes := len(votes) + properties := k.GetNetworkProperties(ctx) + quorum := properties.VoteQuorum + + isQuorum, err := types.IsQuorum(quorum, uint64(numVotes), uint64(totalVoters)) + if err != nil { + panic(fmt.Sprintf("Invalid quorum on proposal: pollID=%d, err=%+v", pollID, err)) + } + + if isQuorum { + numActorsWithVeto := len(types.GetActorsWithVoteWithVeto(actors)) + calculatedVote := types.CalculatePollVotes(votes, uint64(numActorsWithVeto)) + poll.Result = calculatedVote.ProcessResult() + } else { + poll.Result = types.PollQuorumNotReached + } + + k.SavePoll(ctx, poll) + k.RemoveActivePoll(ctx, poll) +} + +func processProposal(ctx sdk.Context, k keeper.Keeper, proposalID uint64) { + proposal, found := k.GetProposal(ctx, proposalID) + if !found { + panic("proposal was expected to exist") + } + + // skip execution if block height condition does not meet + if proposal.MinVotingEndBlockHeight > ctx.BlockHeight() { + return + } + + votes := k.GetProposalVotes(ctx, proposalID) + + availableVoters := k.GetNetworkActorsByAbsoluteWhitelistPermission(ctx, proposal.GetContent().VotePermission()) + totalVoters := len(availableVoters) + + // councilor rank update function on absent + voteMap := make(map[string]bool) + for _, voter := range availableVoters { + voteMap[voter.Address.String()] = true + } + councilors := k.GetAllCouncilors(ctx) + for _, councilor := range councilors { + if !voteMap[councilor.Address.String()] { + k.OnCouncilorAbsent(ctx, councilor.Address) + } + } + + // update to spending pool users if it's spending pool proposal + content := proposal.GetContent() + if content.VotePermission() == types.PermZero { + router := k.GetProposalRouter() + totalVoters = len(router.AllowedAddressesDynamicProposal(ctx, content)) + if totalVoters == 0 { + totalVoters = 1 + } + } + numVotes := len(votes) + + properties := k.GetNetworkProperties(ctx) + + quorum := properties.VoteQuorum + if content.VotePermission() == types.PermZero { + router := k.GetProposalRouter() + quorum = router.QuorumDynamicProposal(ctx, content) + } + + isQuorum, err := types.IsQuorum(quorum, uint64(numVotes), uint64(totalVoters)) + if err != nil { + panic(fmt.Sprintf("Invalid quorum on proposal: proposalID=%d, proposalType=%s, err=%+v", proposalID, proposal.GetContent().ProposalType(), err)) + } + + if isQuorum { + numActorsWithVeto := len(types.GetActorsWithVoteWithVeto(availableVoters)) + calculatedVote := types.CalculateVotes(votes, uint64(numActorsWithVeto)) + + proposal.Result = calculatedVote.ProcessResult() + if proposal.Result == types.Passed { // This is done in order to show that proposal is in enactment, but after enactment passes it will be passed. + proposal.Result = types.Enactment + } + } else { + proposal.Result = types.QuorumNotReached + } + + // enactment time should be at least 1 block from voting period finish + proposal.MinEnactmentEndBlockHeight = ctx.BlockHeight() + int64(properties.MinProposalEnactmentBlocks) + k.SaveProposal(ctx, proposal) + k.RemoveActiveProposal(ctx, proposal) + k.AddToEnactmentProposals(ctx, proposal) + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventTypeAddToEnactment, + sdk.NewAttribute(types.AttributeKeyProposalId, fmt.Sprintf("%d", proposal.ProposalId)), + sdk.NewAttribute(types.AttributeKeyProposalDescription, proposal.Description), + ), + ) +} + +func processEnactmentProposal(ctx sdk.Context, k keeper.Keeper, proposalID uint64, slash sdk.Dec) { + router := k.GetProposalRouter() + proposal, found := k.GetProposal(ctx, proposalID) + if !found { + panic("proposal was expected to exist") + } + + // skip execution if block height condition does not meet + if proposal.MinEnactmentEndBlockHeight > ctx.BlockHeight() { + return + } + + if proposal.Result == types.Enactment { + err := router.ApplyProposal(ctx, proposalID, proposal.GetContent(), slash) + if err != nil { + proposal.ExecResult = "execution failed" + } else { + proposal.ExecResult = "executed successfully" + } + proposal.Result = types.Passed + k.SaveProposal(ctx, proposal) + } + + k.RemoveEnactmentProposal(ctx, proposal) + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventTypeRemoveEnactment, + sdk.NewAttribute(types.AttributeKeyProposalId, fmt.Sprintf("%d", proposal.ProposalId)), + sdk.NewAttribute(types.AttributeKeyProposalDescription, proposal.Description), + ), + ) +} diff --git a/x/gov/abci_test.go b/x/gov/abci_test.go index e26757154..e9b61e048 100644 --- a/x/gov/abci_test.go +++ b/x/gov/abci_test.go @@ -1,684 +1,686 @@ -package gov_test - -import ( - "testing" - "time" - - simapp "github.com/KiraCore/sekai/app" - "github.com/KiraCore/sekai/x/gov" - "github.com/KiraCore/sekai/x/gov/types" - stakingtypes "github.com/KiraCore/sekai/x/staking/types" - tokenstypes "github.com/KiraCore/sekai/x/tokens/types" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/require" - tmproto "github.com/tendermint/tendermint/proto/tendermint/types" -) - -func TestEndBlocker_ActiveProposal(t *testing.T) { - tests := []struct { - name string - prepareScenario func(app *simapp.SekaiApp, ctx sdk.Context) []sdk.AccAddress - validateScenario func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context, addrs []sdk.AccAddress) - blockHeightChange int64 - }{ - { - name: "proposal passes: min block height for proposal voting time not reached", - prepareScenario: func(app *simapp.SekaiApp, ctx sdk.Context) []sdk.AccAddress { - addrs := simapp.AddTestAddrsIncremental(app, ctx, 10, sdk.NewInt(100)) - - proposalID := uint64(1234) - proposal, err := types.NewProposal( - proposalID, - "title", - "some desc", - types.NewWhitelistAccountPermissionProposal( - addrs[0], - types.PermSetPermissions, - ), - time.Now(), - time.Now().Add(10*time.Second), - time.Now().Add(20*time.Second), - ctx.BlockHeight()+2, - ctx.BlockHeight()+3, - ) - require.NoError(t, err) - - app.CustomGovKeeper.SaveProposal(ctx, proposal) - require.NoError(t, err) - app.CustomGovKeeper.AddToActiveProposals(ctx, proposal) - - // We set permissions to Vote The proposal to all the actors. 10 in total. - for i, addr := range addrs { - actor := types.NewDefaultActor(addr) - err := app.CustomGovKeeper.AddWhitelistPermission(ctx, actor, types.PermVoteWhitelistAccountPermissionProposal) - require.NoError(t, err) - - // Only 4 first users vote yes. We reach quorum but not half of the votes are yes. - if i < 4 { - vote := types.NewVote(proposalID, addr, types.OptionYes, sdk.ZeroDec()) - app.CustomGovKeeper.SaveVote(ctx, vote) - } - } - - iterator := app.CustomGovKeeper.GetActiveProposalsWithFinishedVotingEndTimeIterator(ctx, time.Now().Add(10*time.Second)) - requireIteratorCount(t, iterator, 1) - - iterator = app.CustomGovKeeper.GetEnactmentProposalsWithFinishedEnactmentEndTimeIterator(ctx, time.Now().Add(25*time.Second)) - requireIteratorCount(t, iterator, 0) - - return addrs - }, - validateScenario: func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context, addrs []sdk.AccAddress) { - actor, found := app.CustomGovKeeper.GetNetworkActorByAddress(ctx, addrs[0]) - require.True(t, found) - require.False(t, actor.Permissions.IsWhitelisted(types.PermSetPermissions)) - - // We check that is not in the ActiveProposals - iterator := app.CustomGovKeeper.GetActiveProposalsWithFinishedVotingEndTimeIterator(ctx, time.Now().Add(15*time.Second)) - requireIteratorCount(t, iterator, 1) - - // And it is in the EnactmentProposals - iterator = app.CustomGovKeeper.GetEnactmentProposalsWithFinishedEnactmentEndTimeIterator(ctx, time.Now().Add(25*time.Second)) - requireIteratorCount(t, iterator, 0) - - proposal, found := app.CustomGovKeeper.GetProposal(ctx, 1234) - require.True(t, found) - require.Equal(t, types.Pending, proposal.Result) - }, - blockHeightChange: 1, - }, - { - name: "proposal passes: quorum not reached", - prepareScenario: func(app *simapp.SekaiApp, ctx sdk.Context) []sdk.AccAddress { - addrs := simapp.AddTestAddrsIncremental(app, ctx, 10, sdk.NewInt(100)) - - proposalID := uint64(1234) - proposal, err := types.NewProposal( - proposalID, - "title", - "some desc", - types.NewWhitelistAccountPermissionProposal( - addrs[0], - types.PermSetPermissions, - ), - time.Now(), - time.Now(), - time.Now(), - ctx.BlockHeight()+2, - ctx.BlockHeight()+3, - ) - require.NoError(t, err) - - app.CustomGovKeeper.SaveProposal(ctx, proposal) - app.CustomGovKeeper.AddToActiveProposals(ctx, proposal) - - // We set permissions to Vote The proposal to all the actors. 10 in total. - for i, addr := range addrs { - actor := types.NewDefaultActor(addr) - err := app.CustomGovKeeper.AddWhitelistPermission(ctx, actor, types.PermVoteWhitelistAccountPermissionProposal) - require.NoError(t, err) - - // Only 3 first users vote yes. We dont reach Quorum. - if i < 3 { - vote := types.NewVote(proposalID, addr, types.OptionYes, sdk.ZeroDec()) - app.CustomGovKeeper.SaveVote(ctx, vote) - } - } - - return addrs - }, - validateScenario: func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context, addrs []sdk.AccAddress) { - actor, found := app.CustomGovKeeper.GetNetworkActorByAddress(ctx, addrs[0]) - require.True(t, found) - require.False(t, actor.Permissions.IsWhitelisted(types.PermSetPermissions)) - - // We check that is not in the ActiveProposals - iterator := app.CustomGovKeeper.GetActiveProposalsWithFinishedVotingEndTimeIterator(ctx, time.Now().Add(15*time.Second)) - requireIteratorCount(t, iterator, 0) - - // And it is in the EnactmentProposals - iterator = app.CustomGovKeeper.GetEnactmentProposalsWithFinishedEnactmentEndTimeIterator(ctx, time.Now().Add(25*time.Second)) - requireIteratorCount(t, iterator, 1) - - proposal, found := app.CustomGovKeeper.GetProposal(ctx, 1234) - require.True(t, found) - require.Equal(t, types.QuorumNotReached, proposal.Result) - }, - blockHeightChange: 3, - }, - { - name: "proposal passes and joins Enactment place", - prepareScenario: func(app *simapp.SekaiApp, ctx sdk.Context) []sdk.AccAddress { - addrs := simapp.AddTestAddrsIncremental(app, ctx, 10, sdk.NewInt(100)) - - proposalID := uint64(1234) - proposal, err := types.NewProposal( - proposalID, - "title", - "some desc", - types.NewWhitelistAccountPermissionProposal( - addrs[0], - types.PermSetPermissions, - ), - time.Now(), - time.Now().Add(10*time.Second), - time.Now().Add(20*time.Second), - ctx.BlockHeight()+2, - ctx.BlockHeight()+3, - ) - require.NoError(t, err) - - app.CustomGovKeeper.SaveProposal(ctx, proposal) - require.NoError(t, err) - app.CustomGovKeeper.AddToActiveProposals(ctx, proposal) - - // We set permissions to Vote The proposal to all the actors. 10 in total. - for i, addr := range addrs { - actor := types.NewDefaultActor(addr) - err := app.CustomGovKeeper.AddWhitelistPermission(ctx, actor, types.PermVoteWhitelistAccountPermissionProposal) - require.NoError(t, err) - - // Only 4 first users vote yes. We reach quorum but not half of the votes are yes. - if i < 4 { - vote := types.NewVote(proposalID, addr, types.OptionYes, sdk.ZeroDec()) - app.CustomGovKeeper.SaveVote(ctx, vote) - } - } - - iterator := app.CustomGovKeeper.GetActiveProposalsWithFinishedVotingEndTimeIterator(ctx, time.Now().Add(10*time.Second)) - requireIteratorCount(t, iterator, 1) - - iterator = app.CustomGovKeeper.GetEnactmentProposalsWithFinishedEnactmentEndTimeIterator(ctx, time.Now().Add(25*time.Second)) - requireIteratorCount(t, iterator, 0) - - return addrs - }, - validateScenario: func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context, addrs []sdk.AccAddress) { - actor, found := app.CustomGovKeeper.GetNetworkActorByAddress(ctx, addrs[0]) - require.True(t, found) - require.False(t, actor.Permissions.IsWhitelisted(types.PermSetPermissions)) - - // We check that is not in the ActiveProposals - iterator := app.CustomGovKeeper.GetActiveProposalsWithFinishedVotingEndTimeIterator(ctx, time.Now().Add(15*time.Second)) - requireIteratorCount(t, iterator, 0) - - // And it is in the EnactmentProposals - iterator = app.CustomGovKeeper.GetEnactmentProposalsWithFinishedEnactmentEndTimeIterator(ctx, time.Now().Add(25*time.Second)) - requireIteratorCount(t, iterator, 1) - - proposal, found := app.CustomGovKeeper.GetProposal(ctx, 1234) - require.True(t, found) - require.Equal(t, types.Enactment, proposal.Result) - }, - blockHeightChange: 3, - }, - { - name: "Passed proposal in enactment is applied and min block height for enactment not reached", - prepareScenario: func(app *simapp.SekaiApp, ctx sdk.Context) []sdk.AccAddress { - addrs := simapp.AddTestAddrsIncremental(app, ctx, 10, sdk.NewInt(100)) - - actor := types.NewDefaultActor(addrs[0]) - app.CustomGovKeeper.SaveNetworkActor(ctx, actor) - - proposalID := uint64(1234) - proposal, err := types.NewProposal( - proposalID, - "title", - "some desc", - types.NewWhitelistAccountPermissionProposal( - addrs[0], - types.PermSetPermissions, - ), - time.Now(), - time.Now().Add(10*time.Second), - time.Now().Add(20*time.Second), - ctx.BlockHeight()+2, - ctx.BlockHeight()+3, - ) - require.NoError(t, err) - - proposal.Result = types.Enactment - app.CustomGovKeeper.SaveProposal(ctx, proposal) - - app.CustomGovKeeper.AddToEnactmentProposals(ctx, proposal) - - iterator := app.CustomGovKeeper.GetEnactmentProposalsWithFinishedEnactmentEndTimeIterator(ctx, time.Now().Add(25*time.Second)) - requireIteratorCount(t, iterator, 1) - - return addrs - }, - validateScenario: func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context, addrs []sdk.AccAddress) { - iterator := app.CustomGovKeeper.GetEnactmentProposalsWithFinishedEnactmentEndTimeIterator(ctx, time.Now().Add(25*time.Second)) - requireIteratorCount(t, iterator, 1) - }, - blockHeightChange: 0, - }, - { - name: "Passed proposal in enactment is applied and removed from enactment list: Assign permission", - prepareScenario: func(app *simapp.SekaiApp, ctx sdk.Context) []sdk.AccAddress { - addrs := simapp.AddTestAddrsIncremental(app, ctx, 10, sdk.NewInt(100)) - - actor := types.NewDefaultActor(addrs[0]) - app.CustomGovKeeper.SaveNetworkActor(ctx, actor) - - proposalID := uint64(1234) - proposal, err := types.NewProposal( - proposalID, - "title", - "some desc", - types.NewWhitelistAccountPermissionProposal( - addrs[0], - types.PermSetPermissions, - ), - time.Now(), - time.Now().Add(10*time.Second), - time.Now().Add(20*time.Second), - ctx.BlockHeight()+2, - ctx.BlockHeight()+3, - ) - require.NoError(t, err) - - proposal.Result = types.Enactment - app.CustomGovKeeper.SaveProposal(ctx, proposal) - - app.CustomGovKeeper.AddToEnactmentProposals(ctx, proposal) - - iterator := app.CustomGovKeeper.GetEnactmentProposalsWithFinishedEnactmentEndTimeIterator(ctx, time.Now().Add(25*time.Second)) - requireIteratorCount(t, iterator, 1) - - return addrs - }, - validateScenario: func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context, addrs []sdk.AccAddress) { - iterator := app.CustomGovKeeper.GetEnactmentProposalsWithFinishedEnactmentEndTimeIterator(ctx, time.Now().Add(25*time.Second)) - requireIteratorCount(t, iterator, 0) - - actor, found := app.CustomGovKeeper.GetNetworkActorByAddress(ctx, addrs[0]) - require.True(t, found) - - require.True(t, actor.Permissions.IsWhitelisted(types.PermSetPermissions)) - }, - blockHeightChange: 3, - }, - { - name: "Passed proposal in enactment is applied and removed from enactment list, actor does not exist", - prepareScenario: func(app *simapp.SekaiApp, ctx sdk.Context) []sdk.AccAddress { - addrs := simapp.AddTestAddrsIncremental(app, ctx, 10, sdk.NewInt(100)) - - proposalID := uint64(1234) - proposal, err := types.NewProposal( - proposalID, - "title", - "some desc", - types.NewWhitelistAccountPermissionProposal( - addrs[0], - types.PermSetPermissions, - ), - time.Now(), - time.Now().Add(10*time.Second), - time.Now().Add(20*time.Second), - ctx.BlockHeight()+2, - ctx.BlockHeight()+3, - ) - require.NoError(t, err) - - proposal.Result = types.Enactment - app.CustomGovKeeper.SaveProposal(ctx, proposal) - - app.CustomGovKeeper.AddToEnactmentProposals(ctx, proposal) - - iterator := app.CustomGovKeeper.GetEnactmentProposalsWithFinishedEnactmentEndTimeIterator(ctx, time.Now().Add(25*time.Second)) - requireIteratorCount(t, iterator, 1) - - return addrs - }, - validateScenario: func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context, addrs []sdk.AccAddress) { - iterator := app.CustomGovKeeper.GetEnactmentProposalsWithFinishedEnactmentEndTimeIterator(ctx, time.Now().Add(25*time.Second)) - requireIteratorCount(t, iterator, 0) - - actor, found := app.CustomGovKeeper.GetNetworkActorByAddress(ctx, addrs[0]) - require.True(t, found) - - require.True(t, actor.Permissions.IsWhitelisted(types.PermSetPermissions)) - }, - blockHeightChange: 3, - }, - { - name: "Passed proposal in enactment is applied and removed from enactment list: Upsert Data Registry", - prepareScenario: func(app *simapp.SekaiApp, ctx sdk.Context) []sdk.AccAddress { - addrs := simapp.AddTestAddrsIncremental(app, ctx, 10, sdk.NewInt(100)) - - actor := types.NewDefaultActor(addrs[0]) - app.CustomGovKeeper.SaveNetworkActor(ctx, actor) - - proposalID := uint64(1234) - proposal, err := types.NewProposal( - proposalID, - "title", - "some desc", - types.NewUpsertDataRegistryProposal( - "theKey", - "theHash", - "theReference", - "theEncoding", - 1234, - ), - time.Now(), - time.Now().Add(10*time.Second), - time.Now().Add(20*time.Second), - ctx.BlockHeight()+2, - ctx.BlockHeight()+3, - ) - require.NoError(t, err) - - proposal.Result = types.Enactment - app.CustomGovKeeper.SaveProposal(ctx, proposal) - - app.CustomGovKeeper.AddToEnactmentProposals(ctx, proposal) - - iterator := app.CustomGovKeeper.GetEnactmentProposalsWithFinishedEnactmentEndTimeIterator(ctx, time.Now().Add(25*time.Second)) - requireIteratorCount(t, iterator, 1) - - return addrs - }, - validateScenario: func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context, addrs []sdk.AccAddress) { - iterator := app.CustomGovKeeper.GetEnactmentProposalsWithFinishedEnactmentEndTimeIterator(ctx, time.Now().Add(25*time.Second)) - requireIteratorCount(t, iterator, 0) - - entry, found := app.CustomGovKeeper.GetDataRegistryEntry(ctx, "theKey") - require.True(t, found) - - require.Equal(t, "theHash", entry.Hash) - require.Equal(t, "theEncoding", entry.Encoding) - require.Equal(t, "theReference", entry.Reference) - require.Equal(t, uint64(1234), entry.Size_) - }, - blockHeightChange: 3, - }, - { - name: "Passed proposal in enactment is applied and removed from enactment list: Set Network Property", - prepareScenario: func(app *simapp.SekaiApp, ctx sdk.Context) []sdk.AccAddress { - addrs := simapp.AddTestAddrsIncremental(app, ctx, 10, sdk.NewInt(100)) - - actor := types.NewDefaultActor(addrs[0]) - app.CustomGovKeeper.SaveNetworkActor(ctx, actor) - - proposalID := uint64(1234) - proposal, err := types.NewProposal( - proposalID, - "title", - "some desc", - types.NewSetNetworkPropertyProposal( - types.MinTxFee, - types.NetworkPropertyValue{Value: 300}, - ), - time.Now(), - time.Now().Add(10*time.Second), - time.Now().Add(20*time.Second), - ctx.BlockHeight()+2, - ctx.BlockHeight()+3, - ) - require.NoError(t, err) - - proposal.Result = types.Enactment - app.CustomGovKeeper.SaveProposal(ctx, proposal) - - app.CustomGovKeeper.AddToEnactmentProposals(ctx, proposal) - - iterator := app.CustomGovKeeper.GetEnactmentProposalsWithFinishedEnactmentEndTimeIterator(ctx, time.Now().Add(25*time.Second)) - requireIteratorCount(t, iterator, 1) - - return addrs - }, - validateScenario: func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context, addrs []sdk.AccAddress) { - iterator := app.CustomGovKeeper.GetEnactmentProposalsWithFinishedEnactmentEndTimeIterator(ctx, time.Now().Add(25*time.Second)) - requireIteratorCount(t, iterator, 0) - - minTxFee, err := app.CustomGovKeeper.GetNetworkProperty(ctx, types.MinTxFee) - require.NoError(t, err) - - require.Equal(t, uint64(300), minTxFee.Value) - }, - blockHeightChange: 3, - }, - { - name: "Passed proposal in enactment is applied and removed from enactment list: Set Token Alias", - prepareScenario: func(app *simapp.SekaiApp, ctx sdk.Context) []sdk.AccAddress { - addrs := simapp.AddTestAddrsIncremental(app, ctx, 10, sdk.NewInt(100)) - - actor := types.NewDefaultActor(addrs[0]) - app.CustomGovKeeper.SaveNetworkActor(ctx, actor) - - proposalID := uint64(1234) - proposal, err := types.NewProposal( - proposalID, - "title", - "some desc", - tokenstypes.NewUpsertTokenAliasProposal( - "EUR", - "Euro", - "http://www.google.es", - 12, - []string{ - "eur", - "€", - }, - ), - time.Now(), - time.Now().Add(10*time.Second), - time.Now().Add(20*time.Second), - ctx.BlockHeight()+2, - ctx.BlockHeight()+3, - ) - require.NoError(t, err) - - proposal.Result = types.Enactment - app.CustomGovKeeper.SaveProposal(ctx, proposal) - - app.CustomGovKeeper.AddToEnactmentProposals(ctx, proposal) - - iterator := app.CustomGovKeeper.GetEnactmentProposalsWithFinishedEnactmentEndTimeIterator(ctx, time.Now().Add(25*time.Second)) - requireIteratorCount(t, iterator, 1) - - return addrs - }, - validateScenario: func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context, addrs []sdk.AccAddress) { - iterator := app.CustomGovKeeper.GetEnactmentProposalsWithFinishedEnactmentEndTimeIterator(ctx, time.Now().Add(25*time.Second)) - requireIteratorCount(t, iterator, 0) - - token := app.TokensKeeper.GetTokenAlias(ctx, "EUR") - require.Equal(t, "Euro", token.Name) - }, - blockHeightChange: 3, - }, - { - name: "Passed proposal in enactment is applied and removed from enactment list: Set Token Rates", - prepareScenario: func(app *simapp.SekaiApp, ctx sdk.Context) []sdk.AccAddress { - addrs := simapp.AddTestAddrsIncremental(app, ctx, 10, sdk.NewInt(100)) - - actor := types.NewDefaultActor(addrs[0]) - app.CustomGovKeeper.SaveNetworkActor(ctx, actor) - - proposalID := uint64(1234) - proposal, err := types.NewProposal( - proposalID, - "title", - "some desc", - tokenstypes.NewUpsertTokenRatesProposal( - "btc", - sdk.NewDec(1234), - false, - sdk.ZeroDec(), - sdk.ZeroInt(), - false, - ), - time.Now(), - time.Now().Add(10*time.Second), - time.Now().Add(20*time.Second), - ctx.BlockHeight()+2, - ctx.BlockHeight()+3, - ) - require.NoError(t, err) - - proposal.Result = types.Enactment - app.CustomGovKeeper.SaveProposal(ctx, proposal) - - app.CustomGovKeeper.AddToEnactmentProposals(ctx, proposal) - - iterator := app.CustomGovKeeper.GetEnactmentProposalsWithFinishedEnactmentEndTimeIterator(ctx, time.Now().Add(25*time.Second)) - requireIteratorCount(t, iterator, 1) - - return addrs - }, - validateScenario: func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context, addrs []sdk.AccAddress) { - iterator := app.CustomGovKeeper.GetEnactmentProposalsWithFinishedEnactmentEndTimeIterator(ctx, time.Now().Add(25*time.Second)) - requireIteratorCount(t, iterator, 0) - - token := app.TokensKeeper.GetTokenRate(ctx, "btc") - require.Equal(t, sdk.NewDec(1234), token.FeeRate) - require.Equal(t, "btc", token.Denom) - require.Equal(t, false, token.FeePayments) - }, - blockHeightChange: 3, - }, - { - name: "Passed proposal in enactment is applied and removed from enactment list: Unjail Validator", - prepareScenario: func(app *simapp.SekaiApp, ctx sdk.Context) []sdk.AccAddress { - addrs := simapp.AddTestAddrsIncremental(app, ctx, 1, sdk.NewInt(100)) - valAddr := sdk.ValAddress(addrs[0]) - pubkeys := simapp.CreateTestPubKeys(1) - pubKey := pubkeys[0] - - actor := types.NewDefaultActor(addrs[0]) - app.CustomGovKeeper.SaveNetworkActor(ctx, actor) - - val, err := stakingtypes.NewValidator(valAddr, pubKey) - require.NoError(t, err) - app.CustomStakingKeeper.AddValidator(ctx, val) - err = app.CustomStakingKeeper.Jail(ctx, val.ValKey) - require.NoError(t, err) - - proposalID := uint64(1234) - proposal, err := types.NewProposal( - proposalID, - "title", - "some desc", - stakingtypes.NewUnjailValidatorProposal( - addrs[0], - valAddr, - "theProposal", - ), - time.Now(), - time.Now().Add(10*time.Second), - time.Now().Add(20*time.Second), - ctx.BlockHeight()+2, - ctx.BlockHeight()+3, - ) - require.NoError(t, err) - - proposal.Result = types.Enactment - app.CustomGovKeeper.SaveProposal(ctx, proposal) - - app.CustomGovKeeper.AddToEnactmentProposals(ctx, proposal) - - iterator := app.CustomGovKeeper.GetEnactmentProposalsWithFinishedEnactmentEndTimeIterator(ctx, time.Now().Add(25*time.Second)) - requireIteratorCount(t, iterator, 1) - - return addrs - }, - validateScenario: func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context, addrs []sdk.AccAddress) { - iterator := app.CustomGovKeeper.GetEnactmentProposalsWithFinishedEnactmentEndTimeIterator(ctx, time.Now().Add(25*time.Second)) - requireIteratorCount(t, iterator, 0) - - validator, err := app.CustomStakingKeeper.GetValidator(ctx, sdk.ValAddress(addrs[0])) - require.NoError(t, err) - - require.False(t, validator.IsJailed()) - }, - blockHeightChange: 3, - }, - { - name: "Passed proposal in enactment is applied and removed from enactment list: Create Role", - prepareScenario: func(app *simapp.SekaiApp, ctx sdk.Context) []sdk.AccAddress { - addrs := simapp.AddTestAddrsIncremental(app, ctx, 1, sdk.NewInt(100)) - - actor := types.NewDefaultActor(addrs[0]) - app.CustomGovKeeper.SaveNetworkActor(ctx, actor) - - proposalID := uint64(1234) - proposal, err := types.NewProposal( - proposalID, - "title", - "some desc", - types.NewCreateRoleProposal( - "role1000", - "role1000 description", - []types.PermValue{ - types.PermClaimValidator, - }, - []types.PermValue{ - types.PermChangeTxFee, - }, - ), - time.Now(), - time.Now().Add(10*time.Second), - time.Now().Add(20*time.Second), - ctx.BlockHeight()+2, - ctx.BlockHeight()+3, - ) - require.NoError(t, err) - - proposal.Result = types.Enactment - app.CustomGovKeeper.SaveProposal(ctx, proposal) - - app.CustomGovKeeper.AddToEnactmentProposals(ctx, proposal) - - iterator := app.CustomGovKeeper.GetEnactmentProposalsWithFinishedEnactmentEndTimeIterator(ctx, time.Now().Add(25*time.Second)) - requireIteratorCount(t, iterator, 1) - - _, err = app.CustomGovKeeper.GetRoleBySid(ctx, "role1000") - require.Error(t, err) - - return addrs - }, - validateScenario: func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context, addrs []sdk.AccAddress) { - iterator := app.CustomGovKeeper.GetEnactmentProposalsWithFinishedEnactmentEndTimeIterator(ctx, time.Now().Add(25*time.Second)) - requireIteratorCount(t, iterator, 0) - - role, err := app.CustomGovKeeper.GetRoleBySid(ctx, "role1000") - require.NoError(t, err) - perms, found := app.CustomGovKeeper.GetPermissionsForRole(ctx, uint64(role.Id)) - require.True(t, found) - require.True(t, perms.IsWhitelisted(types.PermClaimValidator)) - require.True(t, perms.IsBlacklisted(types.PermChangeTxFee)) - }, - blockHeightChange: 3, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - app := simapp.Setup(false) - ctx := app.NewContext(false, tmproto.Header{}) - ctx = ctx.WithBlockTime(time.Now()) - - addrs := tt.prepareScenario(app, ctx) - - ctx = ctx.WithBlockTime(time.Now().Add(time.Second * 25)) - ctx = ctx.WithBlockHeight(ctx.BlockHeight() + tt.blockHeightChange) - - gov.EndBlocker(ctx, app.CustomGovKeeper) - - tt.validateScenario(t, app, ctx, addrs) - }) - } -} - -func requireIteratorCount(t *testing.T, iterator sdk.Iterator, expectedCount int) { - c := 0 - for ; iterator.Valid(); iterator.Next() { - c++ - } - - require.Equal(t, expectedCount, c) -} +package gov_test + +import ( + "testing" + "time" + + simapp "github.com/KiraCore/sekai/app" + "github.com/KiraCore/sekai/x/gov" + "github.com/KiraCore/sekai/x/gov/types" + stakingtypes "github.com/KiraCore/sekai/x/staking/types" + tokenstypes "github.com/KiraCore/sekai/x/tokens/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" +) + +func TestEndBlocker_ActiveProposal(t *testing.T) { + tests := []struct { + name string + prepareScenario func(app *simapp.SekaiApp, ctx sdk.Context) []sdk.AccAddress + validateScenario func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context, addrs []sdk.AccAddress) + blockHeightChange int64 + }{ + { + name: "proposal passes: min block height for proposal voting time not reached", + prepareScenario: func(app *simapp.SekaiApp, ctx sdk.Context) []sdk.AccAddress { + addrs := simapp.AddTestAddrsIncremental(app, ctx, 10, sdk.NewInt(100)) + + proposalID := uint64(1234) + proposal, err := types.NewProposal( + proposalID, + "title", + "some desc", + types.NewWhitelistAccountPermissionProposal( + addrs[0], + types.PermSetPermissions, + ), + time.Now(), + time.Now().Add(10*time.Second), + time.Now().Add(20*time.Second), + ctx.BlockHeight()+2, + ctx.BlockHeight()+3, + ) + require.NoError(t, err) + + app.CustomGovKeeper.SaveProposal(ctx, proposal) + require.NoError(t, err) + app.CustomGovKeeper.AddToActiveProposals(ctx, proposal) + + // We set permissions to Vote The proposal to all the actors. 10 in total. + for i, addr := range addrs { + actor := types.NewDefaultActor(addr) + err := app.CustomGovKeeper.AddWhitelistPermission(ctx, actor, types.PermVoteWhitelistAccountPermissionProposal) + require.NoError(t, err) + + // Only 4 first users vote yes. We reach quorum but not half of the votes are yes. + if i < 4 { + vote := types.NewVote(proposalID, addr, types.OptionYes, sdk.ZeroDec()) + app.CustomGovKeeper.SaveVote(ctx, vote) + } + } + + iterator := app.CustomGovKeeper.GetActiveProposalsWithFinishedVotingEndTimeIterator(ctx, time.Now().Add(10*time.Second)) + requireIteratorCount(t, iterator, 1) + + iterator = app.CustomGovKeeper.GetEnactmentProposalsWithFinishedEnactmentEndTimeIterator(ctx, time.Now().Add(25*time.Second)) + requireIteratorCount(t, iterator, 0) + + return addrs + }, + validateScenario: func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context, addrs []sdk.AccAddress) { + actor, found := app.CustomGovKeeper.GetNetworkActorByAddress(ctx, addrs[0]) + require.True(t, found) + require.False(t, actor.Permissions.IsWhitelisted(types.PermSetPermissions)) + + // We check that is not in the ActiveProposals + iterator := app.CustomGovKeeper.GetActiveProposalsWithFinishedVotingEndTimeIterator(ctx, time.Now().Add(15*time.Second)) + requireIteratorCount(t, iterator, 1) + + // And it is in the EnactmentProposals + iterator = app.CustomGovKeeper.GetEnactmentProposalsWithFinishedEnactmentEndTimeIterator(ctx, time.Now().Add(25*time.Second)) + requireIteratorCount(t, iterator, 0) + + proposal, found := app.CustomGovKeeper.GetProposal(ctx, 1234) + require.True(t, found) + require.Equal(t, types.Pending, proposal.Result) + }, + blockHeightChange: 1, + }, + { + name: "proposal passes: quorum not reached", + prepareScenario: func(app *simapp.SekaiApp, ctx sdk.Context) []sdk.AccAddress { + addrs := simapp.AddTestAddrsIncremental(app, ctx, 10, sdk.NewInt(100)) + + proposalID := uint64(1234) + proposal, err := types.NewProposal( + proposalID, + "title", + "some desc", + types.NewWhitelistAccountPermissionProposal( + addrs[0], + types.PermSetPermissions, + ), + time.Now(), + time.Now(), + time.Now(), + ctx.BlockHeight()+2, + ctx.BlockHeight()+3, + ) + require.NoError(t, err) + + app.CustomGovKeeper.SaveProposal(ctx, proposal) + app.CustomGovKeeper.AddToActiveProposals(ctx, proposal) + + // We set permissions to Vote The proposal to all the actors. 10 in total. + for i, addr := range addrs { + actor := types.NewDefaultActor(addr) + err := app.CustomGovKeeper.AddWhitelistPermission(ctx, actor, types.PermVoteWhitelistAccountPermissionProposal) + require.NoError(t, err) + + // Only 3 first users vote yes. We dont reach Quorum. + if i < 3 { + vote := types.NewVote(proposalID, addr, types.OptionYes, sdk.ZeroDec()) + app.CustomGovKeeper.SaveVote(ctx, vote) + } + } + + return addrs + }, + validateScenario: func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context, addrs []sdk.AccAddress) { + actor, found := app.CustomGovKeeper.GetNetworkActorByAddress(ctx, addrs[0]) + require.True(t, found) + require.False(t, actor.Permissions.IsWhitelisted(types.PermSetPermissions)) + + // We check that is not in the ActiveProposals + iterator := app.CustomGovKeeper.GetActiveProposalsWithFinishedVotingEndTimeIterator(ctx, time.Now().Add(15*time.Second)) + requireIteratorCount(t, iterator, 0) + + // And it is in the EnactmentProposals + iterator = app.CustomGovKeeper.GetEnactmentProposalsWithFinishedEnactmentEndTimeIterator(ctx, time.Now().Add(25*time.Second)) + requireIteratorCount(t, iterator, 1) + + proposal, found := app.CustomGovKeeper.GetProposal(ctx, 1234) + require.True(t, found) + require.Equal(t, types.QuorumNotReached, proposal.Result) + }, + blockHeightChange: 3, + }, + { + name: "proposal passes and joins Enactment place", + prepareScenario: func(app *simapp.SekaiApp, ctx sdk.Context) []sdk.AccAddress { + addrs := simapp.AddTestAddrsIncremental(app, ctx, 10, sdk.NewInt(100)) + + proposalID := uint64(1234) + proposal, err := types.NewProposal( + proposalID, + "title", + "some desc", + types.NewWhitelistAccountPermissionProposal( + addrs[0], + types.PermSetPermissions, + ), + time.Now(), + time.Now().Add(10*time.Second), + time.Now().Add(20*time.Second), + ctx.BlockHeight()+2, + ctx.BlockHeight()+3, + ) + require.NoError(t, err) + + app.CustomGovKeeper.SaveProposal(ctx, proposal) + require.NoError(t, err) + app.CustomGovKeeper.AddToActiveProposals(ctx, proposal) + + // We set permissions to Vote The proposal to all the actors. 10 in total. + for i, addr := range addrs { + actor := types.NewDefaultActor(addr) + err := app.CustomGovKeeper.AddWhitelistPermission(ctx, actor, types.PermVoteWhitelistAccountPermissionProposal) + require.NoError(t, err) + + // Only 4 first users vote yes. We reach quorum but not half of the votes are yes. + if i < 4 { + vote := types.NewVote(proposalID, addr, types.OptionYes, sdk.ZeroDec()) + app.CustomGovKeeper.SaveVote(ctx, vote) + } + } + + iterator := app.CustomGovKeeper.GetActiveProposalsWithFinishedVotingEndTimeIterator(ctx, time.Now().Add(10*time.Second)) + requireIteratorCount(t, iterator, 1) + + iterator = app.CustomGovKeeper.GetEnactmentProposalsWithFinishedEnactmentEndTimeIterator(ctx, time.Now().Add(25*time.Second)) + requireIteratorCount(t, iterator, 0) + + return addrs + }, + validateScenario: func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context, addrs []sdk.AccAddress) { + actor, found := app.CustomGovKeeper.GetNetworkActorByAddress(ctx, addrs[0]) + require.True(t, found) + require.False(t, actor.Permissions.IsWhitelisted(types.PermSetPermissions)) + + // We check that is not in the ActiveProposals + iterator := app.CustomGovKeeper.GetActiveProposalsWithFinishedVotingEndTimeIterator(ctx, time.Now().Add(15*time.Second)) + requireIteratorCount(t, iterator, 0) + + // And it is in the EnactmentProposals + iterator = app.CustomGovKeeper.GetEnactmentProposalsWithFinishedEnactmentEndTimeIterator(ctx, time.Now().Add(25*time.Second)) + requireIteratorCount(t, iterator, 1) + + proposal, found := app.CustomGovKeeper.GetProposal(ctx, 1234) + require.True(t, found) + require.Equal(t, types.Enactment, proposal.Result) + }, + blockHeightChange: 3, + }, + { + name: "Passed proposal in enactment is applied and min block height for enactment not reached", + prepareScenario: func(app *simapp.SekaiApp, ctx sdk.Context) []sdk.AccAddress { + addrs := simapp.AddTestAddrsIncremental(app, ctx, 10, sdk.NewInt(100)) + + actor := types.NewDefaultActor(addrs[0]) + app.CustomGovKeeper.SaveNetworkActor(ctx, actor) + + proposalID := uint64(1234) + proposal, err := types.NewProposal( + proposalID, + "title", + "some desc", + types.NewWhitelistAccountPermissionProposal( + addrs[0], + types.PermSetPermissions, + ), + time.Now(), + time.Now().Add(10*time.Second), + time.Now().Add(20*time.Second), + ctx.BlockHeight()+2, + ctx.BlockHeight()+3, + ) + require.NoError(t, err) + + proposal.Result = types.Enactment + app.CustomGovKeeper.SaveProposal(ctx, proposal) + + app.CustomGovKeeper.AddToEnactmentProposals(ctx, proposal) + + iterator := app.CustomGovKeeper.GetEnactmentProposalsWithFinishedEnactmentEndTimeIterator(ctx, time.Now().Add(25*time.Second)) + requireIteratorCount(t, iterator, 1) + + return addrs + }, + validateScenario: func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context, addrs []sdk.AccAddress) { + iterator := app.CustomGovKeeper.GetEnactmentProposalsWithFinishedEnactmentEndTimeIterator(ctx, time.Now().Add(25*time.Second)) + requireIteratorCount(t, iterator, 1) + }, + blockHeightChange: 0, + }, + { + name: "Passed proposal in enactment is applied and removed from enactment list: Assign permission", + prepareScenario: func(app *simapp.SekaiApp, ctx sdk.Context) []sdk.AccAddress { + addrs := simapp.AddTestAddrsIncremental(app, ctx, 10, sdk.NewInt(100)) + + actor := types.NewDefaultActor(addrs[0]) + app.CustomGovKeeper.SaveNetworkActor(ctx, actor) + + proposalID := uint64(1234) + proposal, err := types.NewProposal( + proposalID, + "title", + "some desc", + types.NewWhitelistAccountPermissionProposal( + addrs[0], + types.PermSetPermissions, + ), + time.Now(), + time.Now().Add(10*time.Second), + time.Now().Add(20*time.Second), + ctx.BlockHeight()+2, + ctx.BlockHeight()+3, + ) + require.NoError(t, err) + + proposal.Result = types.Enactment + app.CustomGovKeeper.SaveProposal(ctx, proposal) + + app.CustomGovKeeper.AddToEnactmentProposals(ctx, proposal) + + iterator := app.CustomGovKeeper.GetEnactmentProposalsWithFinishedEnactmentEndTimeIterator(ctx, time.Now().Add(25*time.Second)) + requireIteratorCount(t, iterator, 1) + + return addrs + }, + validateScenario: func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context, addrs []sdk.AccAddress) { + iterator := app.CustomGovKeeper.GetEnactmentProposalsWithFinishedEnactmentEndTimeIterator(ctx, time.Now().Add(25*time.Second)) + requireIteratorCount(t, iterator, 0) + + actor, found := app.CustomGovKeeper.GetNetworkActorByAddress(ctx, addrs[0]) + require.True(t, found) + + require.True(t, actor.Permissions.IsWhitelisted(types.PermSetPermissions)) + }, + blockHeightChange: 3, + }, + { + name: "Passed proposal in enactment is applied and removed from enactment list, actor does not exist", + prepareScenario: func(app *simapp.SekaiApp, ctx sdk.Context) []sdk.AccAddress { + addrs := simapp.AddTestAddrsIncremental(app, ctx, 10, sdk.NewInt(100)) + + proposalID := uint64(1234) + proposal, err := types.NewProposal( + proposalID, + "title", + "some desc", + types.NewWhitelistAccountPermissionProposal( + addrs[0], + types.PermSetPermissions, + ), + time.Now(), + time.Now().Add(10*time.Second), + time.Now().Add(20*time.Second), + ctx.BlockHeight()+2, + ctx.BlockHeight()+3, + ) + require.NoError(t, err) + + proposal.Result = types.Enactment + app.CustomGovKeeper.SaveProposal(ctx, proposal) + + app.CustomGovKeeper.AddToEnactmentProposals(ctx, proposal) + + iterator := app.CustomGovKeeper.GetEnactmentProposalsWithFinishedEnactmentEndTimeIterator(ctx, time.Now().Add(25*time.Second)) + requireIteratorCount(t, iterator, 1) + + return addrs + }, + validateScenario: func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context, addrs []sdk.AccAddress) { + iterator := app.CustomGovKeeper.GetEnactmentProposalsWithFinishedEnactmentEndTimeIterator(ctx, time.Now().Add(25*time.Second)) + requireIteratorCount(t, iterator, 0) + + actor, found := app.CustomGovKeeper.GetNetworkActorByAddress(ctx, addrs[0]) + require.True(t, found) + + require.True(t, actor.Permissions.IsWhitelisted(types.PermSetPermissions)) + }, + blockHeightChange: 3, + }, + { + name: "Passed proposal in enactment is applied and removed from enactment list: Upsert Data Registry", + prepareScenario: func(app *simapp.SekaiApp, ctx sdk.Context) []sdk.AccAddress { + addrs := simapp.AddTestAddrsIncremental(app, ctx, 10, sdk.NewInt(100)) + + actor := types.NewDefaultActor(addrs[0]) + app.CustomGovKeeper.SaveNetworkActor(ctx, actor) + + proposalID := uint64(1234) + proposal, err := types.NewProposal( + proposalID, + "title", + "some desc", + types.NewUpsertDataRegistryProposal( + "theKey", + "theHash", + "theReference", + "theEncoding", + 1234, + ), + time.Now(), + time.Now().Add(10*time.Second), + time.Now().Add(20*time.Second), + ctx.BlockHeight()+2, + ctx.BlockHeight()+3, + ) + require.NoError(t, err) + + proposal.Result = types.Enactment + app.CustomGovKeeper.SaveProposal(ctx, proposal) + + app.CustomGovKeeper.AddToEnactmentProposals(ctx, proposal) + + iterator := app.CustomGovKeeper.GetEnactmentProposalsWithFinishedEnactmentEndTimeIterator(ctx, time.Now().Add(25*time.Second)) + requireIteratorCount(t, iterator, 1) + + return addrs + }, + validateScenario: func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context, addrs []sdk.AccAddress) { + iterator := app.CustomGovKeeper.GetEnactmentProposalsWithFinishedEnactmentEndTimeIterator(ctx, time.Now().Add(25*time.Second)) + requireIteratorCount(t, iterator, 0) + + entry, found := app.CustomGovKeeper.GetDataRegistryEntry(ctx, "theKey") + require.True(t, found) + + require.Equal(t, "theHash", entry.Hash) + require.Equal(t, "theEncoding", entry.Encoding) + require.Equal(t, "theReference", entry.Reference) + require.Equal(t, uint64(1234), entry.Size_) + }, + blockHeightChange: 3, + }, + { + name: "Passed proposal in enactment is applied and removed from enactment list: Set Network Property", + prepareScenario: func(app *simapp.SekaiApp, ctx sdk.Context) []sdk.AccAddress { + addrs := simapp.AddTestAddrsIncremental(app, ctx, 10, sdk.NewInt(100)) + + actor := types.NewDefaultActor(addrs[0]) + app.CustomGovKeeper.SaveNetworkActor(ctx, actor) + + proposalID := uint64(1234) + proposal, err := types.NewProposal( + proposalID, + "title", + "some desc", + types.NewSetNetworkPropertyProposal( + types.MinTxFee, + types.NetworkPropertyValue{Value: 300}, + ), + time.Now(), + time.Now().Add(10*time.Second), + time.Now().Add(20*time.Second), + ctx.BlockHeight()+2, + ctx.BlockHeight()+3, + ) + require.NoError(t, err) + + proposal.Result = types.Enactment + app.CustomGovKeeper.SaveProposal(ctx, proposal) + + app.CustomGovKeeper.AddToEnactmentProposals(ctx, proposal) + + iterator := app.CustomGovKeeper.GetEnactmentProposalsWithFinishedEnactmentEndTimeIterator(ctx, time.Now().Add(25*time.Second)) + requireIteratorCount(t, iterator, 1) + + return addrs + }, + validateScenario: func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context, addrs []sdk.AccAddress) { + iterator := app.CustomGovKeeper.GetEnactmentProposalsWithFinishedEnactmentEndTimeIterator(ctx, time.Now().Add(25*time.Second)) + requireIteratorCount(t, iterator, 0) + + minTxFee, err := app.CustomGovKeeper.GetNetworkProperty(ctx, types.MinTxFee) + require.NoError(t, err) + + require.Equal(t, uint64(300), minTxFee.Value) + }, + blockHeightChange: 3, + }, + { + name: "Passed proposal in enactment is applied and removed from enactment list: Set Token Alias", + prepareScenario: func(app *simapp.SekaiApp, ctx sdk.Context) []sdk.AccAddress { + addrs := simapp.AddTestAddrsIncremental(app, ctx, 10, sdk.NewInt(100)) + + actor := types.NewDefaultActor(addrs[0]) + app.CustomGovKeeper.SaveNetworkActor(ctx, actor) + + proposalID := uint64(1234) + proposal, err := types.NewProposal( + proposalID, + "title", + "some desc", + tokenstypes.NewUpsertTokenAliasProposal( + "EUR", + "Euro", + "http://www.google.es", + 12, + []string{ + "eur", + "€", + }, + false, + ), + time.Now(), + time.Now().Add(10*time.Second), + time.Now().Add(20*time.Second), + ctx.BlockHeight()+2, + ctx.BlockHeight()+3, + ) + require.NoError(t, err) + + proposal.Result = types.Enactment + app.CustomGovKeeper.SaveProposal(ctx, proposal) + + app.CustomGovKeeper.AddToEnactmentProposals(ctx, proposal) + + iterator := app.CustomGovKeeper.GetEnactmentProposalsWithFinishedEnactmentEndTimeIterator(ctx, time.Now().Add(25*time.Second)) + requireIteratorCount(t, iterator, 1) + + return addrs + }, + validateScenario: func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context, addrs []sdk.AccAddress) { + iterator := app.CustomGovKeeper.GetEnactmentProposalsWithFinishedEnactmentEndTimeIterator(ctx, time.Now().Add(25*time.Second)) + requireIteratorCount(t, iterator, 0) + + token := app.TokensKeeper.GetTokenAlias(ctx, "EUR") + require.Equal(t, "Euro", token.Name) + }, + blockHeightChange: 3, + }, + { + name: "Passed proposal in enactment is applied and removed from enactment list: Set Token Rates", + prepareScenario: func(app *simapp.SekaiApp, ctx sdk.Context) []sdk.AccAddress { + addrs := simapp.AddTestAddrsIncremental(app, ctx, 10, sdk.NewInt(100)) + + actor := types.NewDefaultActor(addrs[0]) + app.CustomGovKeeper.SaveNetworkActor(ctx, actor) + + proposalID := uint64(1234) + proposal, err := types.NewProposal( + proposalID, + "title", + "some desc", + tokenstypes.NewUpsertTokenRatesProposal( + "btc", + sdk.NewDec(1234), + false, + sdk.ZeroDec(), + sdk.ZeroInt(), + false, + false, + ), + time.Now(), + time.Now().Add(10*time.Second), + time.Now().Add(20*time.Second), + ctx.BlockHeight()+2, + ctx.BlockHeight()+3, + ) + require.NoError(t, err) + + proposal.Result = types.Enactment + app.CustomGovKeeper.SaveProposal(ctx, proposal) + + app.CustomGovKeeper.AddToEnactmentProposals(ctx, proposal) + + iterator := app.CustomGovKeeper.GetEnactmentProposalsWithFinishedEnactmentEndTimeIterator(ctx, time.Now().Add(25*time.Second)) + requireIteratorCount(t, iterator, 1) + + return addrs + }, + validateScenario: func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context, addrs []sdk.AccAddress) { + iterator := app.CustomGovKeeper.GetEnactmentProposalsWithFinishedEnactmentEndTimeIterator(ctx, time.Now().Add(25*time.Second)) + requireIteratorCount(t, iterator, 0) + + token := app.TokensKeeper.GetTokenRate(ctx, "btc") + require.Equal(t, sdk.NewDec(1234), token.FeeRate) + require.Equal(t, "btc", token.Denom) + require.Equal(t, false, token.FeePayments) + }, + blockHeightChange: 3, + }, + { + name: "Passed proposal in enactment is applied and removed from enactment list: Unjail Validator", + prepareScenario: func(app *simapp.SekaiApp, ctx sdk.Context) []sdk.AccAddress { + addrs := simapp.AddTestAddrsIncremental(app, ctx, 1, sdk.NewInt(100)) + valAddr := sdk.ValAddress(addrs[0]) + pubkeys := simapp.CreateTestPubKeys(1) + pubKey := pubkeys[0] + + actor := types.NewDefaultActor(addrs[0]) + app.CustomGovKeeper.SaveNetworkActor(ctx, actor) + + val, err := stakingtypes.NewValidator(valAddr, pubKey) + require.NoError(t, err) + app.CustomStakingKeeper.AddValidator(ctx, val) + err = app.CustomStakingKeeper.Jail(ctx, val.ValKey) + require.NoError(t, err) + + proposalID := uint64(1234) + proposal, err := types.NewProposal( + proposalID, + "title", + "some desc", + stakingtypes.NewUnjailValidatorProposal( + addrs[0], + valAddr, + "theProposal", + ), + time.Now(), + time.Now().Add(10*time.Second), + time.Now().Add(20*time.Second), + ctx.BlockHeight()+2, + ctx.BlockHeight()+3, + ) + require.NoError(t, err) + + proposal.Result = types.Enactment + app.CustomGovKeeper.SaveProposal(ctx, proposal) + + app.CustomGovKeeper.AddToEnactmentProposals(ctx, proposal) + + iterator := app.CustomGovKeeper.GetEnactmentProposalsWithFinishedEnactmentEndTimeIterator(ctx, time.Now().Add(25*time.Second)) + requireIteratorCount(t, iterator, 1) + + return addrs + }, + validateScenario: func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context, addrs []sdk.AccAddress) { + iterator := app.CustomGovKeeper.GetEnactmentProposalsWithFinishedEnactmentEndTimeIterator(ctx, time.Now().Add(25*time.Second)) + requireIteratorCount(t, iterator, 0) + + validator, err := app.CustomStakingKeeper.GetValidator(ctx, sdk.ValAddress(addrs[0])) + require.NoError(t, err) + + require.False(t, validator.IsJailed()) + }, + blockHeightChange: 3, + }, + { + name: "Passed proposal in enactment is applied and removed from enactment list: Create Role", + prepareScenario: func(app *simapp.SekaiApp, ctx sdk.Context) []sdk.AccAddress { + addrs := simapp.AddTestAddrsIncremental(app, ctx, 1, sdk.NewInt(100)) + + actor := types.NewDefaultActor(addrs[0]) + app.CustomGovKeeper.SaveNetworkActor(ctx, actor) + + proposalID := uint64(1234) + proposal, err := types.NewProposal( + proposalID, + "title", + "some desc", + types.NewCreateRoleProposal( + "role1000", + "role1000 description", + []types.PermValue{ + types.PermClaimValidator, + }, + []types.PermValue{ + types.PermChangeTxFee, + }, + ), + time.Now(), + time.Now().Add(10*time.Second), + time.Now().Add(20*time.Second), + ctx.BlockHeight()+2, + ctx.BlockHeight()+3, + ) + require.NoError(t, err) + + proposal.Result = types.Enactment + app.CustomGovKeeper.SaveProposal(ctx, proposal) + + app.CustomGovKeeper.AddToEnactmentProposals(ctx, proposal) + + iterator := app.CustomGovKeeper.GetEnactmentProposalsWithFinishedEnactmentEndTimeIterator(ctx, time.Now().Add(25*time.Second)) + requireIteratorCount(t, iterator, 1) + + _, err = app.CustomGovKeeper.GetRoleBySid(ctx, "role1000") + require.Error(t, err) + + return addrs + }, + validateScenario: func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context, addrs []sdk.AccAddress) { + iterator := app.CustomGovKeeper.GetEnactmentProposalsWithFinishedEnactmentEndTimeIterator(ctx, time.Now().Add(25*time.Second)) + requireIteratorCount(t, iterator, 0) + + role, err := app.CustomGovKeeper.GetRoleBySid(ctx, "role1000") + require.NoError(t, err) + perms, found := app.CustomGovKeeper.GetPermissionsForRole(ctx, uint64(role.Id)) + require.True(t, found) + require.True(t, perms.IsWhitelisted(types.PermClaimValidator)) + require.True(t, perms.IsBlacklisted(types.PermChangeTxFee)) + }, + blockHeightChange: 3, + }, + } + + for _, tt := range tests { + tt := tt + t.Run(tt.name, func(t *testing.T) { + app := simapp.Setup(false) + ctx := app.NewContext(false, tmproto.Header{}) + ctx = ctx.WithBlockTime(time.Now()) + + addrs := tt.prepareScenario(app, ctx) + + ctx = ctx.WithBlockTime(time.Now().Add(time.Second * 25)) + ctx = ctx.WithBlockHeight(ctx.BlockHeight() + tt.blockHeightChange) + + gov.EndBlocker(ctx, app.CustomGovKeeper) + + tt.validateScenario(t, app, ctx, addrs) + }) + } +} + +func requireIteratorCount(t *testing.T, iterator sdk.Iterator, expectedCount int) { + c := 0 + for ; iterator.Valid(); iterator.Next() { + c++ + } + + require.Equal(t, expectedCount, c) +} diff --git a/x/gov/client/cli/cli_identity_registrar_test.go b/x/gov/client/cli/cli_identity_registrar_test.go index 9dd2dfba3..4baa62df0 100644 --- a/x/gov/client/cli/cli_identity_registrar_test.go +++ b/x/gov/client/cli/cli_identity_registrar_test.go @@ -1,202 +1,202 @@ -package cli_test - -import ( - "fmt" - - "github.com/KiraCore/sekai/x/gov/client/cli" - "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/cosmos/cosmos-sdk/testutil" - clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" - sdk "github.com/cosmos/cosmos-sdk/types" -) - -func (s IntegrationTestSuite) TestTxRegisterIdentityRecords() { - val := s.network.Validators[0] - cmd := cli.GetTxRegisterIdentityRecords() - - infosFile := testutil.WriteToNewTempFile(s.T(), ` - { - "key1": "value1", - "key2": "value2" - } - `) - - clientCtx := val.ClientCtx.WithOutputFormat("json") - out, err := clitestutil.ExecTestCLICmd( - clientCtx, - cmd, - []string{ - fmt.Sprintf("--%s=%s", cli.FlagInfosFile, infosFile.Name()), - fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), - fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), - }, - ) - s.Require().NoError(err) - - err = s.network.WaitForNextBlock() - s.Require().NoError(err) - fmt.Println("out", out) -} - -func (s IntegrationTestSuite) TestTxEditIdentityRecord() { - val := s.network.Validators[0] - cmd := cli.GetTxDeleteIdentityRecords() - - clientCtx := val.ClientCtx.WithOutputFormat("json") - out, err := clitestutil.ExecTestCLICmd( - clientCtx, - cmd, - []string{ - fmt.Sprintf("--%s=%s", cli.FlagKeys, "key1,key2"), - fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), - fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), - }, - ) - s.Require().NoError(err) - - err = s.network.WaitForNextBlock() - s.Require().NoError(err) - fmt.Println("out", out) -} - -func (s IntegrationTestSuite) TestTxRequestIdentityRecordsVerify() { - val := s.network.Validators[0] - cmd := cli.GetTxRequestIdentityRecordsVerify() - - clientCtx := val.ClientCtx.WithOutputFormat("json") - out, err := clitestutil.ExecTestCLICmd( - clientCtx, - cmd, - []string{ - fmt.Sprintf("--%s=%s", cli.FlagVerifier, val.Address.String()), - fmt.Sprintf("--%s=%s", cli.FlagRecordIds, "1"), - fmt.Sprintf("--%s=%s", cli.FlagTip, "10stake"), - fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), - fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), - }, - ) - s.Require().NoError(err) - - err = s.network.WaitForNextBlock() - s.Require().NoError(err) - fmt.Println("out", out) -} - -func (s IntegrationTestSuite) TestTxHandleIdentityRecordsVerifyRequest() { - val := s.network.Validators[0] - cmd := cli.GetTxHandleIdentityRecordsVerifyRequest() - - clientCtx := val.ClientCtx.WithOutputFormat("json") - out, err := clitestutil.ExecTestCLICmd( - clientCtx, - cmd, - []string{ - "1", - fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), - fmt.Sprintf("--%s=true", cli.FlagApprove), - fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), - }, - ) - s.Require().NoError(err) - - err = s.network.WaitForNextBlock() - s.Require().NoError(err) - fmt.Println("out", out) -} - -func (s IntegrationTestSuite) TestTxCancelIdentityRecordsVerifyRequest() { - val := s.network.Validators[0] - cmd := cli.GetTxCancelIdentityRecordsVerifyRequest() - - clientCtx := val.ClientCtx.WithOutputFormat("json") - out, err := clitestutil.ExecTestCLICmd( - clientCtx, - cmd, - []string{ - "1", - fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), - fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), - }, - ) - s.Require().NoError(err) - - err = s.network.WaitForNextBlock() - s.Require().NoError(err) - fmt.Println("out", out) -} - -func (s IntegrationTestSuite) TestCmdQueryIdentityRecord() { - val := s.network.Validators[0] - clientCtx := val.ClientCtx - cmd := cli.GetCmdQueryIdentityRecord() - _, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ - fmt.Sprintf("%d", 1), - }) - s.Require().NoError(err) -} - -func (s IntegrationTestSuite) TestCmdQueryIdentityRecordByAddress() { - val := s.network.Validators[0] - clientCtx := val.ClientCtx - cmd := cli.GetCmdQueryIdentityRecordByAddress() - _, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ - fmt.Sprintf("%s", val.Address.String()), - }) - s.Require().NoError(err) -} - -func (s IntegrationTestSuite) TestCmdQueryAllIdentityRecords() { - val := s.network.Validators[0] - clientCtx := val.ClientCtx - cmd := cli.GetCmdQueryAllIdentityRecords() - _, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{}) - s.Require().NoError(err) -} - -func (s IntegrationTestSuite) TestCmdQueryIdentityRecordVerifyRequest() { - val := s.network.Validators[0] - clientCtx := val.ClientCtx - cmd := cli.GetCmdQueryIdentityRecordVerifyRequest() - _, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ - fmt.Sprintf("%d", 1), - }) - s.Require().NoError(err) -} - -func (s IntegrationTestSuite) TestCmdQueryIdentityRecordVerifyRequestsByRequester() { - val := s.network.Validators[0] - clientCtx := val.ClientCtx - cmd := cli.GetCmdQueryIdentityRecordVerifyRequestsByRequester() - _, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ - fmt.Sprintf("%s", val.Address.String()), - }) - s.Require().NoError(err) -} - -func (s IntegrationTestSuite) TestCmdQueryIdentityRecordVerifyRequestsByApprover() { - val := s.network.Validators[0] - clientCtx := val.ClientCtx - cmd := cli.GetCmdQueryIdentityRecordVerifyRequestsByApprover() - _, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ - fmt.Sprintf("%s", val.Address.String()), - }) - s.Require().NoError(err) -} - -func (s IntegrationTestSuite) TestCmdQueryAllIdentityRecordVerifyRequests() { - val := s.network.Validators[0] - clientCtx := val.ClientCtx - cmd := cli.GetCmdQueryAllIdentityRecordVerifyRequests() - _, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{}) - s.Require().NoError(err) -} +package cli_test + +import ( + "fmt" + + "github.com/KiraCore/sekai/x/gov/client/cli" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/testutil" + clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func (s IntegrationTestSuite) TestTxRegisterIdentityRecords() { + val := s.network.Validators[0] + cmd := cli.GetTxRegisterIdentityRecords() + + infosFile := testutil.WriteToNewTempFile(s.T(), ` + { + "key1": "value1", + "key2": "value2" + } + `) + + clientCtx := val.ClientCtx.WithOutputFormat("json") + out, err := clitestutil.ExecTestCLICmd( + clientCtx, + cmd, + []string{ + fmt.Sprintf("--%s=%s", cli.FlagInfosFile, infosFile.Name()), + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), + }, + ) + s.Require().NoError(err) + + err = s.network.WaitForNextBlock() + s.Require().NoError(err) + fmt.Println("out", out) +} + +func (s IntegrationTestSuite) TestTxEditIdentityRecord() { + val := s.network.Validators[0] + cmd := cli.GetTxDeleteIdentityRecords() + + clientCtx := val.ClientCtx.WithOutputFormat("json") + out, err := clitestutil.ExecTestCLICmd( + clientCtx, + cmd, + []string{ + fmt.Sprintf("--%s=%s", cli.FlagKeys, "key1,key2"), + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), + }, + ) + s.Require().NoError(err) + + err = s.network.WaitForNextBlock() + s.Require().NoError(err) + fmt.Println("out", out) +} + +func (s IntegrationTestSuite) TestTxRequestIdentityRecordsVerify() { + val := s.network.Validators[0] + cmd := cli.GetTxRequestIdentityRecordsVerify() + + clientCtx := val.ClientCtx.WithOutputFormat("json") + out, err := clitestutil.ExecTestCLICmd( + clientCtx, + cmd, + []string{ + fmt.Sprintf("--%s=%s", cli.FlagVerifier, val.Address.String()), + fmt.Sprintf("--%s=%s", cli.FlagRecordIds, "1"), + fmt.Sprintf("--%s=%s", cli.FlagTip, "10stake"), + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), + }, + ) + s.Require().NoError(err) + + err = s.network.WaitForNextBlock() + s.Require().NoError(err) + fmt.Println("out", out) +} + +func (s IntegrationTestSuite) TestTxHandleIdentityRecordsVerifyRequest() { + val := s.network.Validators[0] + cmd := cli.GetTxHandleIdentityRecordsVerifyRequest() + + clientCtx := val.ClientCtx.WithOutputFormat("json") + out, err := clitestutil.ExecTestCLICmd( + clientCtx, + cmd, + []string{ + "1", + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), + fmt.Sprintf("--%s=true", cli.FlagApprove), + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), + }, + ) + s.Require().NoError(err) + + err = s.network.WaitForNextBlock() + s.Require().NoError(err) + fmt.Println("out", out) +} + +func (s IntegrationTestSuite) TestTxCancelIdentityRecordsVerifyRequest() { + val := s.network.Validators[0] + cmd := cli.GetTxCancelIdentityRecordsVerifyRequest() + + clientCtx := val.ClientCtx.WithOutputFormat("json") + out, err := clitestutil.ExecTestCLICmd( + clientCtx, + cmd, + []string{ + "1", + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), + }, + ) + s.Require().NoError(err) + + err = s.network.WaitForNextBlock() + s.Require().NoError(err) + fmt.Println("out", out) +} + +func (s IntegrationTestSuite) TestCmdQueryIdentityRecord() { + val := s.network.Validators[0] + clientCtx := val.ClientCtx + cmd := cli.GetCmdQueryIdentityRecord() + _, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ + fmt.Sprintf("%d", 1), + }) + s.Require().NoError(err) +} + +func (s IntegrationTestSuite) TestCmdQueryIdentityRecordByAddress() { + val := s.network.Validators[0] + clientCtx := val.ClientCtx + cmd := cli.GetCmdQueryIdentityRecordByAddress() + _, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ + fmt.Sprintf("%s", val.Address.String()), + }) + s.Require().NoError(err) +} + +func (s IntegrationTestSuite) TestCmdQueryAllIdentityRecords() { + val := s.network.Validators[0] + clientCtx := val.ClientCtx + cmd := cli.GetCmdQueryAllIdentityRecords() + _, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{}) + s.Require().NoError(err) +} + +func (s IntegrationTestSuite) TestCmdQueryIdentityRecordVerifyRequest() { + val := s.network.Validators[0] + clientCtx := val.ClientCtx + cmd := cli.GetCmdQueryIdentityRecordVerifyRequest() + _, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ + fmt.Sprintf("%d", 1), + }) + s.Require().NoError(err) +} + +func (s IntegrationTestSuite) TestCmdQueryIdentityRecordVerifyRequestsByRequester() { + val := s.network.Validators[0] + clientCtx := val.ClientCtx + cmd := cli.GetCmdQueryIdentityRecordVerifyRequestsByRequester() + _, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ + fmt.Sprintf("%s", val.Address.String()), + }) + s.Require().NoError(err) +} + +func (s IntegrationTestSuite) TestCmdQueryIdentityRecordVerifyRequestsByApprover() { + val := s.network.Validators[0] + clientCtx := val.ClientCtx + cmd := cli.GetCmdQueryIdentityRecordVerifyRequestsByApprover() + _, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ + fmt.Sprintf("%s", val.Address.String()), + }) + s.Require().NoError(err) +} + +func (s IntegrationTestSuite) TestCmdQueryAllIdentityRecordVerifyRequests() { + val := s.network.Validators[0] + clientCtx := val.ClientCtx + cmd := cli.GetCmdQueryAllIdentityRecordVerifyRequests() + _, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{}) + s.Require().NoError(err) +} diff --git a/x/gov/client/cli/cli_permission_test.go b/x/gov/client/cli/cli_permission_test.go index afd21d7be..9f2bff38d 100644 --- a/x/gov/client/cli/cli_permission_test.go +++ b/x/gov/client/cli/cli_permission_test.go @@ -1,130 +1,130 @@ -package cli_test - -import ( - "fmt" - "strings" - - "github.com/KiraCore/sekai/x/gov/client/cli" - "github.com/KiraCore/sekai/x/gov/types" - stakingcli "github.com/KiraCore/sekai/x/staking/client/cli" - "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/cosmos/cosmos-sdk/crypto/hd" - "github.com/cosmos/cosmos-sdk/crypto/keyring" - clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" - sdk "github.com/cosmos/cosmos-sdk/types" -) - -func (s IntegrationTestSuite) TestGetTxSetWhitelistPermissions() { - val := s.network.Validators[0] - cmd := cli.GetTxSetWhitelistPermissions() - - // We create some random address where we will give perms. - addr, err := sdk.AccAddressFromBech32("kira15ky9du8a2wlstz6fpx3p4mqpjyrm5cgqzp4f3d") - s.Require().NoError(err) - - clientCtx := val.ClientCtx.WithOutputFormat("json") - out, err := clitestutil.ExecTestCLICmd( - clientCtx, - cmd, - []string{ - fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), - fmt.Sprintf("--%s=%s", stakingcli.FlagAddr, addr.String()), - fmt.Sprintf("--%s=%s", cli.FlagPermission, "1"), - fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), - }, - ) - s.Require().NoError(err) - - err = s.network.WaitForNextBlock() - s.Require().NoError(err) - - // We check if the user has the permissions - cmd = cli.GetCmdQueryPermissions() - - out, err = clitestutil.ExecTestCLICmd( - clientCtx, - cmd, - []string{ - addr.String(), - }, - ) - s.Require().NoError(err) - - var perms types.Permissions - clientCtx.JSONCodec.MustUnmarshalJSON(out.Bytes(), &perms) - - // Validator 1 has permission to Add Permissions. - s.Require().True(perms.IsWhitelisted(types.PermSetPermissions)) - s.Require().False(perms.IsWhitelisted(types.PermClaimValidator)) -} - -func (s IntegrationTestSuite) TestGetTxSetBlacklistPermissions() { - val := s.network.Validators[0] - - // We create some random address where we will give perms. - addr, err := sdk.AccAddressFromBech32("kira1alzyfq40zjsveat87jlg8jxetwqmr0a29sgd0f") - s.Require().NoError(err) - - clientCtx := val.ClientCtx.WithOutputFormat("json") - - out, err := clitestutil.ExecTestCLICmd( - clientCtx, - cli.GetTxSetBlacklistPermissions(), - []string{ - fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), - fmt.Sprintf("--%s=%s", stakingcli.FlagAddr, addr.String()), - fmt.Sprintf("--%s=%s", cli.FlagPermission, "1"), - fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), - }, - ) - s.Require().NoError(err) - s.T().Logf("error %s", out.String()) - - err = s.network.WaitForNextBlock() - s.Require().NoError(err) - - // We check if the user has the permissions - cmd := cli.GetCmdQueryPermissions() - out, err = clitestutil.ExecTestCLICmd( - clientCtx, - cmd, - []string{ - addr.String(), - }, - ) - s.Require().NoError(err) - - var perms types.Permissions - clientCtx.JSONCodec.MustUnmarshalJSON(out.Bytes(), &perms) - - // Validator 1 has permission to Add Permissions. - s.Require().True(perms.IsBlacklisted(types.PermSetPermissions)) - s.Require().False(perms.IsBlacklisted(types.PermClaimValidator)) -} - -func (s IntegrationTestSuite) TestGetTxSetWhitelistPermissions_WithUserThatDoesNotHaveSetPermissions() { - val := s.network.Validators[0] - - // We create some random address where we will give perms. - newAccount, _, err := val.ClientCtx.Keyring.NewMnemonic("test", keyring.English, sdk.FullFundraiserPath, keyring.DefaultBIP39Passphrase, hd.Secp256k1) - s.Require().NoError(err) - s.SendValue(val.ClientCtx, val.Address, newAccount.GetAddress(), sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))) - - // Now we try to set permissions with a user that does not have. - cmd := cli.GetTxSetWhitelistPermissions() - clientCtx := val.ClientCtx - out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ - fmt.Sprintf("--%s=%s", flags.FlagFrom, newAccount.GetAddress().String()), - fmt.Sprintf("--%s=%s", stakingcli.FlagAddr, val.Address.String()), - fmt.Sprintf("--%s=%s", cli.FlagPermission, "1"), - fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), - }) - s.Require().NoError(err) - strings.Contains(out.String(), "SetPermissions: not enough permissions") -} +package cli_test + +import ( + "fmt" + "strings" + + "github.com/KiraCore/sekai/x/gov/client/cli" + "github.com/KiraCore/sekai/x/gov/types" + stakingcli "github.com/KiraCore/sekai/x/staking/client/cli" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/crypto/hd" + "github.com/cosmos/cosmos-sdk/crypto/keyring" + clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func (s IntegrationTestSuite) TestGetTxSetWhitelistPermissions() { + val := s.network.Validators[0] + cmd := cli.GetTxSetWhitelistPermissions() + + // We create some random address where we will give perms. + addr, err := sdk.AccAddressFromBech32("kira15ky9du8a2wlstz6fpx3p4mqpjyrm5cgqzp4f3d") + s.Require().NoError(err) + + clientCtx := val.ClientCtx.WithOutputFormat("json") + out, err := clitestutil.ExecTestCLICmd( + clientCtx, + cmd, + []string{ + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), + fmt.Sprintf("--%s=%s", stakingcli.FlagAddr, addr.String()), + fmt.Sprintf("--%s=%s", cli.FlagPermission, "1"), + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), + }, + ) + s.Require().NoError(err) + + err = s.network.WaitForNextBlock() + s.Require().NoError(err) + + // We check if the user has the permissions + cmd = cli.GetCmdQueryPermissions() + + out, err = clitestutil.ExecTestCLICmd( + clientCtx, + cmd, + []string{ + addr.String(), + }, + ) + s.Require().NoError(err) + + var perms types.Permissions + clientCtx.JSONCodec.MustUnmarshalJSON(out.Bytes(), &perms) + + // Validator 1 has permission to Add Permissions. + s.Require().True(perms.IsWhitelisted(types.PermSetPermissions)) + s.Require().False(perms.IsWhitelisted(types.PermClaimValidator)) +} + +func (s IntegrationTestSuite) TestGetTxSetBlacklistPermissions() { + val := s.network.Validators[0] + + // We create some random address where we will give perms. + addr, err := sdk.AccAddressFromBech32("kira1alzyfq40zjsveat87jlg8jxetwqmr0a29sgd0f") + s.Require().NoError(err) + + clientCtx := val.ClientCtx.WithOutputFormat("json") + + out, err := clitestutil.ExecTestCLICmd( + clientCtx, + cli.GetTxSetBlacklistPermissions(), + []string{ + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), + fmt.Sprintf("--%s=%s", stakingcli.FlagAddr, addr.String()), + fmt.Sprintf("--%s=%s", cli.FlagPermission, "1"), + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), + }, + ) + s.Require().NoError(err) + s.T().Logf("error %s", out.String()) + + err = s.network.WaitForNextBlock() + s.Require().NoError(err) + + // We check if the user has the permissions + cmd := cli.GetCmdQueryPermissions() + out, err = clitestutil.ExecTestCLICmd( + clientCtx, + cmd, + []string{ + addr.String(), + }, + ) + s.Require().NoError(err) + + var perms types.Permissions + clientCtx.JSONCodec.MustUnmarshalJSON(out.Bytes(), &perms) + + // Validator 1 has permission to Add Permissions. + s.Require().True(perms.IsBlacklisted(types.PermSetPermissions)) + s.Require().False(perms.IsBlacklisted(types.PermClaimValidator)) +} + +func (s IntegrationTestSuite) TestGetTxSetWhitelistPermissions_WithUserThatDoesNotHaveSetPermissions() { + val := s.network.Validators[0] + + // We create some random address where we will give perms. + newAccount, _, err := val.ClientCtx.Keyring.NewMnemonic("test", keyring.English, sdk.FullFundraiserPath, keyring.DefaultBIP39Passphrase, hd.Secp256k1) + s.Require().NoError(err) + s.SendValue(val.ClientCtx, val.Address, newAccount.GetAddress(), sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))) + + // Now we try to set permissions with a user that does not have. + cmd := cli.GetTxSetWhitelistPermissions() + clientCtx := val.ClientCtx + out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ + fmt.Sprintf("--%s=%s", flags.FlagFrom, newAccount.GetAddress().String()), + fmt.Sprintf("--%s=%s", stakingcli.FlagAddr, val.Address.String()), + fmt.Sprintf("--%s=%s", cli.FlagPermission, "1"), + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), + }) + s.Require().NoError(err) + strings.Contains(out.String(), "SetPermissions: not enough permissions") +} diff --git a/x/gov/client/cli/cli_proposal_test.go b/x/gov/client/cli/cli_proposal_test.go index 8fc1429b6..e88425f9d 100644 --- a/x/gov/client/cli/cli_proposal_test.go +++ b/x/gov/client/cli/cli_proposal_test.go @@ -1,149 +1,149 @@ -package cli_test - -import ( - "fmt" - - "github.com/KiraCore/sekai/x/gov/client/cli" - "github.com/KiraCore/sekai/x/gov/types" - stakingcli "github.com/KiraCore/sekai/x/staking/client/cli" - "github.com/cosmos/cosmos-sdk/client/flags" - clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" - sdk "github.com/cosmos/cosmos-sdk/types" -) - -func (s IntegrationTestSuite) TestCreateProposalAssignPermission() { - // Query permissions for role Validator - val := s.network.Validators[0] - - // We create some random address where we will give perms. - addr, err := sdk.AccAddressFromBech32("kira1alzyfq40zjsveet87jlg8jxetwqmr0a2x50lqq") - s.Require().NoError(err) - - cmd := cli.GetTxProposalAssignRoleToAccount() - clientCtx := val.ClientCtx - _, err = clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ - fmt.Sprintf("%d", types.PermClaimValidator), - fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), - fmt.Sprintf("--%s=%s", stakingcli.FlagAddr, addr.String()), - fmt.Sprintf("--%s=%s", cli.FlagTitle, "title"), - fmt.Sprintf("--%s=%s", cli.FlagDescription, "some desc"), - fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), - }) - s.Require().NoError(err) - - cmd = cli.GetTxVoteProposal() - _, err = clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ - fmt.Sprintf("%d", 1), // Proposal ID - fmt.Sprintf("%d", types.OptionYes), - fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), - fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), - }) - s.Require().NoError(err) -} - -func (s IntegrationTestSuite) TestCreateProposalUpsertDataRegistry() { - // Query permissions for role Validator - val := s.network.Validators[0] - - cmd := cli.GetTxProposalUpsertDataRegistry() - clientCtx := val.ClientCtx - out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ - fmt.Sprintf("%s", "theKey"), - fmt.Sprintf("%s", "theHash"), - fmt.Sprintf("%s", "theReference"), - fmt.Sprintf("%s", "theEncoding"), - fmt.Sprintf("%d", 12345), - fmt.Sprintf("--%s=%s", cli.FlagTitle, "title"), - fmt.Sprintf("--%s=%s", cli.FlagDescription, "some desc"), - fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), - fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), - }) - s.Require().NoError(err) - fmt.Printf("%s", out.String()) - - // Vote Proposal - cmd = cli.GetTxVoteProposal() - out, err = clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ - fmt.Sprintf("%d", 1), // Proposal ID - fmt.Sprintf("%d", types.OptionYes), - fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), - fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), - }) - s.Require().NoError(err) - fmt.Printf("%s", out.String()) -} - -func (s IntegrationTestSuite) TestCreateProposalSetNetworkProperty() { - // Query permissions for role Validator - val := s.network.Validators[0] - - cmd := cli.GetTxProposalSetNetworkProperty() - clientCtx := val.ClientCtx - out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ - fmt.Sprintf("%s", "MIN_TX_FEE"), - fmt.Sprintf("%d", 12345), - fmt.Sprintf("--%s=%s", cli.FlagTitle, "title"), - fmt.Sprintf("--%s=%s", cli.FlagDescription, "some desc"), - fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), - fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), - }) - s.Require().NoError(err) - fmt.Printf("%s", out.String()) - - // Vote Proposal - cmd = cli.GetTxVoteProposal() - out, err = clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ - fmt.Sprintf("%d", 1), // Proposal ID - fmt.Sprintf("%d", types.OptionYes), - fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), - fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), - }) - s.Require().NoError(err) - fmt.Printf("%s", out.String()) -} - -func (s IntegrationTestSuite) TestCreateProposalCreateRole() { - // Query permissions for role Validator - val := s.network.Validators[0] - - cmd := cli.GetTxProposalCreateRole() - clientCtx := val.ClientCtx - out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ - fmt.Sprintf("newRole"), - fmt.Sprintf("newRole"), - fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), - fmt.Sprintf("--%s=%s", cli.FlagTitle, "title"), - fmt.Sprintf("--%s=%s", cli.FlagDescription, "some desc"), - fmt.Sprintf("--%s=%s", cli.FlagWhitelistPerms, "1,2,3"), - fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), - }) - s.Require().NoError(err) - fmt.Printf("%s", out.String()) - - // Vote Proposal - cmd = cli.GetTxVoteProposal() - out, err = clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ - fmt.Sprintf("%d", 1), // Proposal ID - fmt.Sprintf("%d", types.OptionYes), - fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), - fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), - }) - s.Require().NoError(err) - fmt.Printf("%s", out.String()) -} +package cli_test + +import ( + "fmt" + + "github.com/KiraCore/sekai/x/gov/client/cli" + "github.com/KiraCore/sekai/x/gov/types" + stakingcli "github.com/KiraCore/sekai/x/staking/client/cli" + "github.com/cosmos/cosmos-sdk/client/flags" + clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func (s IntegrationTestSuite) TestCreateProposalAssignPermission() { + // Query permissions for role Validator + val := s.network.Validators[0] + + // We create some random address where we will give perms. + addr, err := sdk.AccAddressFromBech32("kira1alzyfq40zjsveet87jlg8jxetwqmr0a2x50lqq") + s.Require().NoError(err) + + cmd := cli.GetTxProposalAssignRoleToAccount() + clientCtx := val.ClientCtx + _, err = clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ + fmt.Sprintf("%d", types.PermClaimValidator), + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), + fmt.Sprintf("--%s=%s", stakingcli.FlagAddr, addr.String()), + fmt.Sprintf("--%s=%s", cli.FlagTitle, "title"), + fmt.Sprintf("--%s=%s", cli.FlagDescription, "some desc"), + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), + }) + s.Require().NoError(err) + + cmd = cli.GetTxVoteProposal() + _, err = clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ + fmt.Sprintf("%d", 1), // Proposal ID + fmt.Sprintf("%d", types.OptionYes), + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), + }) + s.Require().NoError(err) +} + +func (s IntegrationTestSuite) TestCreateProposalUpsertDataRegistry() { + // Query permissions for role Validator + val := s.network.Validators[0] + + cmd := cli.GetTxProposalUpsertDataRegistry() + clientCtx := val.ClientCtx + out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ + fmt.Sprintf("%s", "theKey"), + fmt.Sprintf("%s", "theHash"), + fmt.Sprintf("%s", "theReference"), + fmt.Sprintf("%s", "theEncoding"), + fmt.Sprintf("%d", 12345), + fmt.Sprintf("--%s=%s", cli.FlagTitle, "title"), + fmt.Sprintf("--%s=%s", cli.FlagDescription, "some desc"), + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), + }) + s.Require().NoError(err) + fmt.Printf("%s", out.String()) + + // Vote Proposal + cmd = cli.GetTxVoteProposal() + out, err = clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ + fmt.Sprintf("%d", 1), // Proposal ID + fmt.Sprintf("%d", types.OptionYes), + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), + }) + s.Require().NoError(err) + fmt.Printf("%s", out.String()) +} + +func (s IntegrationTestSuite) TestCreateProposalSetNetworkProperty() { + // Query permissions for role Validator + val := s.network.Validators[0] + + cmd := cli.GetTxProposalSetNetworkProperty() + clientCtx := val.ClientCtx + out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ + fmt.Sprintf("%s", "MIN_TX_FEE"), + fmt.Sprintf("%d", 12345), + fmt.Sprintf("--%s=%s", cli.FlagTitle, "title"), + fmt.Sprintf("--%s=%s", cli.FlagDescription, "some desc"), + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), + }) + s.Require().NoError(err) + fmt.Printf("%s", out.String()) + + // Vote Proposal + cmd = cli.GetTxVoteProposal() + out, err = clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ + fmt.Sprintf("%d", 1), // Proposal ID + fmt.Sprintf("%d", types.OptionYes), + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), + }) + s.Require().NoError(err) + fmt.Printf("%s", out.String()) +} + +func (s IntegrationTestSuite) TestCreateProposalCreateRole() { + // Query permissions for role Validator + val := s.network.Validators[0] + + cmd := cli.GetTxProposalCreateRole() + clientCtx := val.ClientCtx + out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ + fmt.Sprintf("newRole"), + fmt.Sprintf("newRole"), + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), + fmt.Sprintf("--%s=%s", cli.FlagTitle, "title"), + fmt.Sprintf("--%s=%s", cli.FlagDescription, "some desc"), + fmt.Sprintf("--%s=%s", cli.FlagWhitelistPerms, "1,2,3"), + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), + }) + s.Require().NoError(err) + fmt.Printf("%s", out.String()) + + // Vote Proposal + cmd = cli.GetTxVoteProposal() + out, err = clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ + fmt.Sprintf("%d", 1), // Proposal ID + fmt.Sprintf("%d", types.OptionYes), + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), + }) + s.Require().NoError(err) + fmt.Printf("%s", out.String()) +} diff --git a/x/gov/client/cli/cli_role_test.go b/x/gov/client/cli/cli_role_test.go index 474208191..a4c55dbf7 100644 --- a/x/gov/client/cli/cli_role_test.go +++ b/x/gov/client/cli/cli_role_test.go @@ -1,250 +1,250 @@ -package cli_test - -import ( - "fmt" - "strings" - - "github.com/KiraCore/sekai/x/gov/client/cli" - "github.com/KiraCore/sekai/x/gov/types" - stakingcli "github.com/KiraCore/sekai/x/staking/client/cli" - "github.com/cosmos/cosmos-sdk/client/flags" - clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" - sdk "github.com/cosmos/cosmos-sdk/types" -) - -func (s IntegrationTestSuite) TestWhitelistRolePermission() { - // Query permissions for role Validator - val := s.network.Validators[0] - clientCtx := val.ClientCtx - - cmd := cli.GetCmdQueryRole() - out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ - "2", // RoleInTest - }) - s.Require().NoError(err) - - var roleQuery types.RoleQuery - val.ClientCtx.JSONCodec.MustUnmarshalJSON(out.Bytes(), &roleQuery) - s.Require().False(roleQuery.Permissions.IsWhitelisted(types.PermSetPermissions)) - - // Send Tx To Whitelist permission - cmd = cli.GetTxWhitelistRolePermission() - _, err = clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ - "2", // Role created in test - "1", // PermSetPermission - fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), - fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), - }) - s.Require().NoError(err) - - // Query again to check if it has the new permission - cmd = cli.GetCmdQueryRole() - out, err = clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ - "2", // RoleCreatedInTest - }) - s.Require().NoError(err) - - var newRoleQuery types.RoleQuery - val.ClientCtx.JSONCodec.MustUnmarshalJSON(out.Bytes(), &newRoleQuery) - s.Require().True(newRoleQuery.Permissions.IsWhitelisted(types.PermSetPermissions)) -} - -func (s IntegrationTestSuite) TestBlacklistRolePermission() { - // Query permissions for role Validator - val := s.network.Validators[0] - clientCtx := val.ClientCtx - - cmd := cli.GetCmdQueryRole() - out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ - "2", // RoleValidator - }) - s.Require().NoError(err) - - var roleQuery types.RoleQuery - val.ClientCtx.JSONCodec.MustUnmarshalJSON(out.Bytes(), &roleQuery) - s.Require().True(roleQuery.Permissions.IsWhitelisted(types.PermClaimValidator)) - s.Require().False(roleQuery.Permissions.IsBlacklisted(types.PermClaimCouncilor)) - - // Send Tx To Blacklist permission - cmd = cli.GetTxBlacklistRolePermission() - out, err = clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ - "2", // RoleValidator - "3", // PermClaimCouncilor - fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), - fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), - }) - s.Require().NoError(err) - - // Query again to check if it has the new permission - err = s.network.WaitForNextBlock() - s.Require().NoError(err) - - cmd = cli.GetCmdQueryRole() - out, err = clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ - "2", // RoleValidator - }) - s.Require().NoError(err) - - var newRoleQuery types.RoleQuery - val.ClientCtx.JSONCodec.MustUnmarshalJSON(out.Bytes(), &newRoleQuery) - s.Require().True(newRoleQuery.Permissions.IsWhitelisted(types.PermClaimValidator)) - s.Require().True(newRoleQuery.Permissions.IsBlacklisted(types.PermClaimCouncilor)) -} - -func (s IntegrationTestSuite) TestRemoveWhitelistRolePermission() { - // Query permissions for role Validator - val := s.network.Validators[0] - clientCtx := val.ClientCtx - - cmd := cli.GetCmdQueryRole() - out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ - "2", // RoleInTest - }) - s.Require().NoError(err) - - var roleQuery types.RoleQuery - val.ClientCtx.JSONCodec.MustUnmarshalJSON(out.Bytes(), &roleQuery) - s.Require().True(roleQuery.Permissions.IsWhitelisted(types.PermClaimValidator)) - - // Send Tx To Blacklist permission - cmd = cli.GetTxRemoveWhitelistRolePermission() - out, err = clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ - "2", // RoleValidator - "2", // PermClaimValidator - fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), - fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), - }) - s.Require().NoError(err) - - // Query again to check if it has the new permission - err = s.network.WaitForNextBlock() - s.Require().NoError(err) - - cmd = cli.GetCmdQueryRole() - out, err = clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ - "2", // RoleInTest - }) - s.Require().NoError(err) - - var newRoleQuery types.RoleQuery - val.ClientCtx.JSONCodec.MustUnmarshalJSON(out.Bytes(), &newRoleQuery) - s.Require().False(newRoleQuery.Permissions.IsWhitelisted(types.PermClaimValidator)) -} - -func (s IntegrationTestSuite) TestRemoveBlacklistRolePermission() { - // Query permissions for role RoleInTest - val := s.network.Validators[0] - clientCtx := val.ClientCtx - - cmd := cli.GetCmdQueryRole() - _, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ - "sudo", - }) - s.Require().NoError(err) - - // Send Tx To Remove Blacklist Permissions - cmd = cli.GetTxRemoveBlacklistRolePermission() - _, err = clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ - "sudo", // RoleValidator - "3", // PermClaimCouncilor - fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), - fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), - }) - s.Require().NoError(err) - - // Query again to check if it has the new permission - err = s.network.WaitForNextBlock() - s.Require().NoError(err) -} - -func (s IntegrationTestSuite) TestCreateRole() { - // Query permissions for role Non existing role yet - val := s.network.Validators[0] - clientCtx := val.ClientCtx - - cmd := cli.GetCmdQueryRole() - _, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ - "myRole", // RoleInTest - }) - s.Require().Error(err) - strings.Contains(err.Error(), types.ErrRoleDoesNotExist.Error()) - - // Add role - cmd = cli.GetTxCreateRole() - _, err = clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ - "myRole", "myRole", // RoleValidator - fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), - fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), - }) - s.Require().NoError(err) - - err = s.network.WaitForNextBlock() - s.Require().NoError(err) - - // Query again the role - cmd = cli.GetCmdQueryRole() - _, err = clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ - "myRole", // RoleInTest - }) - s.Require().NoError(err) -} - -func (s IntegrationTestSuite) TestAssignRoles_AndRemoveRoles() { - val := s.network.Validators[0] - clientCtx := val.ClientCtx - - addr, err := sdk.AccAddressFromBech32("kira15ky9du8a2wlstz6fpx3p4mqpjyrm5cgqzp4f3d") - s.Require().NoError(err) - - cmd := cli.GetTxAssignRole() - _, err = clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ - "2", // Role created in test - fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), - fmt.Sprintf("--%s=%s", stakingcli.FlagAddr, addr), - fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), - }) - s.Require().NoError(err) - - roles := GetRolesByAddress(s.T(), s.network, addr) - s.Require().Equal([]uint64{uint64(types.RoleValidator)}, roles) - - err = s.network.WaitForNextBlock() - s.Require().NoError(err) - - cmd = cli.GetTxRemoveRole() - _, err = clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ - "2", // Role created in test - fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), - fmt.Sprintf("--%s=%s", stakingcli.FlagAddr, addr), - fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), - }) - s.Require().NoError(err) - - err = s.network.WaitForNextBlock() - s.Require().NoError(err) - - roles = GetRolesByAddress(s.T(), s.network, addr) - s.Require().Equal([]uint64{}, roles) -} - -func (s IntegrationTestSuite) TestGetRolesByAddress() { - val := s.network.Validators[0] - - roles := GetRolesByAddress(s.T(), s.network, val.Address) - - s.Require().Equal([]uint64{uint64(types.RoleSudo)}, roles) -} +package cli_test + +import ( + "fmt" + "strings" + + "github.com/KiraCore/sekai/x/gov/client/cli" + "github.com/KiraCore/sekai/x/gov/types" + stakingcli "github.com/KiraCore/sekai/x/staking/client/cli" + "github.com/cosmos/cosmos-sdk/client/flags" + clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func (s IntegrationTestSuite) TestWhitelistRolePermission() { + // Query permissions for role Validator + val := s.network.Validators[0] + clientCtx := val.ClientCtx + + cmd := cli.GetCmdQueryRole() + out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ + "2", // RoleInTest + }) + s.Require().NoError(err) + + var roleQuery types.RoleQuery + val.ClientCtx.JSONCodec.MustUnmarshalJSON(out.Bytes(), &roleQuery) + s.Require().False(roleQuery.Permissions.IsWhitelisted(types.PermSetPermissions)) + + // Send Tx To Whitelist permission + cmd = cli.GetTxWhitelistRolePermission() + _, err = clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ + "2", // Role created in test + "1", // PermSetPermission + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), + }) + s.Require().NoError(err) + + // Query again to check if it has the new permission + cmd = cli.GetCmdQueryRole() + out, err = clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ + "2", // RoleCreatedInTest + }) + s.Require().NoError(err) + + var newRoleQuery types.RoleQuery + val.ClientCtx.JSONCodec.MustUnmarshalJSON(out.Bytes(), &newRoleQuery) + s.Require().True(newRoleQuery.Permissions.IsWhitelisted(types.PermSetPermissions)) +} + +func (s IntegrationTestSuite) TestBlacklistRolePermission() { + // Query permissions for role Validator + val := s.network.Validators[0] + clientCtx := val.ClientCtx + + cmd := cli.GetCmdQueryRole() + out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ + "2", // RoleValidator + }) + s.Require().NoError(err) + + var roleQuery types.RoleQuery + val.ClientCtx.JSONCodec.MustUnmarshalJSON(out.Bytes(), &roleQuery) + s.Require().True(roleQuery.Permissions.IsWhitelisted(types.PermClaimValidator)) + s.Require().False(roleQuery.Permissions.IsBlacklisted(types.PermClaimCouncilor)) + + // Send Tx To Blacklist permission + cmd = cli.GetTxBlacklistRolePermission() + out, err = clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ + "2", // RoleValidator + "3", // PermClaimCouncilor + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), + }) + s.Require().NoError(err) + + // Query again to check if it has the new permission + err = s.network.WaitForNextBlock() + s.Require().NoError(err) + + cmd = cli.GetCmdQueryRole() + out, err = clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ + "2", // RoleValidator + }) + s.Require().NoError(err) + + var newRoleQuery types.RoleQuery + val.ClientCtx.JSONCodec.MustUnmarshalJSON(out.Bytes(), &newRoleQuery) + s.Require().True(newRoleQuery.Permissions.IsWhitelisted(types.PermClaimValidator)) + s.Require().True(newRoleQuery.Permissions.IsBlacklisted(types.PermClaimCouncilor)) +} + +func (s IntegrationTestSuite) TestRemoveWhitelistRolePermission() { + // Query permissions for role Validator + val := s.network.Validators[0] + clientCtx := val.ClientCtx + + cmd := cli.GetCmdQueryRole() + out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ + "2", // RoleInTest + }) + s.Require().NoError(err) + + var roleQuery types.RoleQuery + val.ClientCtx.JSONCodec.MustUnmarshalJSON(out.Bytes(), &roleQuery) + s.Require().True(roleQuery.Permissions.IsWhitelisted(types.PermClaimValidator)) + + // Send Tx To Blacklist permission + cmd = cli.GetTxRemoveWhitelistRolePermission() + out, err = clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ + "2", // RoleValidator + "2", // PermClaimValidator + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), + }) + s.Require().NoError(err) + + // Query again to check if it has the new permission + err = s.network.WaitForNextBlock() + s.Require().NoError(err) + + cmd = cli.GetCmdQueryRole() + out, err = clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ + "2", // RoleInTest + }) + s.Require().NoError(err) + + var newRoleQuery types.RoleQuery + val.ClientCtx.JSONCodec.MustUnmarshalJSON(out.Bytes(), &newRoleQuery) + s.Require().False(newRoleQuery.Permissions.IsWhitelisted(types.PermClaimValidator)) +} + +func (s IntegrationTestSuite) TestRemoveBlacklistRolePermission() { + // Query permissions for role RoleInTest + val := s.network.Validators[0] + clientCtx := val.ClientCtx + + cmd := cli.GetCmdQueryRole() + _, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ + "sudo", + }) + s.Require().NoError(err) + + // Send Tx To Remove Blacklist Permissions + cmd = cli.GetTxRemoveBlacklistRolePermission() + _, err = clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ + "sudo", // RoleValidator + "3", // PermClaimCouncilor + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), + }) + s.Require().NoError(err) + + // Query again to check if it has the new permission + err = s.network.WaitForNextBlock() + s.Require().NoError(err) +} + +func (s IntegrationTestSuite) TestCreateRole() { + // Query permissions for role Non existing role yet + val := s.network.Validators[0] + clientCtx := val.ClientCtx + + cmd := cli.GetCmdQueryRole() + _, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ + "myRole", // RoleInTest + }) + s.Require().Error(err) + strings.Contains(err.Error(), types.ErrRoleDoesNotExist.Error()) + + // Add role + cmd = cli.GetTxCreateRole() + _, err = clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ + "myRole", "myRole", // RoleValidator + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), + }) + s.Require().NoError(err) + + err = s.network.WaitForNextBlock() + s.Require().NoError(err) + + // Query again the role + cmd = cli.GetCmdQueryRole() + _, err = clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ + "myRole", // RoleInTest + }) + s.Require().NoError(err) +} + +func (s IntegrationTestSuite) TestAssignRoles_AndRemoveRoles() { + val := s.network.Validators[0] + clientCtx := val.ClientCtx + + addr, err := sdk.AccAddressFromBech32("kira15ky9du8a2wlstz6fpx3p4mqpjyrm5cgqzp4f3d") + s.Require().NoError(err) + + cmd := cli.GetTxAssignRole() + _, err = clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ + "2", // Role created in test + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), + fmt.Sprintf("--%s=%s", stakingcli.FlagAddr, addr), + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), + }) + s.Require().NoError(err) + + roles := GetRolesByAddress(s.T(), s.network, addr) + s.Require().Equal([]uint64{uint64(types.RoleValidator)}, roles) + + err = s.network.WaitForNextBlock() + s.Require().NoError(err) + + cmd = cli.GetTxRemoveRole() + _, err = clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ + "2", // Role created in test + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), + fmt.Sprintf("--%s=%s", stakingcli.FlagAddr, addr), + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), + }) + s.Require().NoError(err) + + err = s.network.WaitForNextBlock() + s.Require().NoError(err) + + roles = GetRolesByAddress(s.T(), s.network, addr) + s.Require().Equal([]uint64{}, roles) +} + +func (s IntegrationTestSuite) TestGetRolesByAddress() { + val := s.network.Validators[0] + + roles := GetRolesByAddress(s.T(), s.network, val.Address) + + s.Require().Equal([]uint64{uint64(types.RoleSudo)}, roles) +} diff --git a/x/gov/client/cli/cli_test.go b/x/gov/client/cli/cli_test.go index ad8371146..a2301923c 100644 --- a/x/gov/client/cli/cli_test.go +++ b/x/gov/client/cli/cli_test.go @@ -1,178 +1,178 @@ -package cli_test - -import ( - "testing" - - "github.com/KiraCore/sekai/app" - simapp "github.com/KiraCore/sekai/app" - "github.com/KiraCore/sekai/testutil/network" - "github.com/KiraCore/sekai/x/gov/types" - "github.com/cosmos/cosmos-sdk/baseapp" - servertypes "github.com/cosmos/cosmos-sdk/server/types" - storetypes "github.com/cosmos/cosmos-sdk/store/types" - "github.com/stretchr/testify/suite" - dbm "github.com/tendermint/tm-db" -) - -type IntegrationTestSuite struct { - suite.Suite - - cfg network.Config - network *network.Network -} - -func (s *IntegrationTestSuite) SetupSuite() { - app.SetConfig() - s.T().Log("setting up integration test suite") - - cfg := network.DefaultConfig() - encCfg := app.MakeEncodingConfig() - cfg.Codec = encCfg.Marshaler - cfg.TxConfig = encCfg.TxConfig - - cfg.NumValidators = 1 - - // customize proposal end time and enactment time - govGen := types.DefaultGenesis() - // govGen.NetworkProperties.ProposalEndTime = 1 - // govGen.NetworkProperties.ProposalEnactmentTime = 2 - govGenRaw := encCfg.Marshaler.MustMarshalJSON(govGen) - - genesis := app.ModuleBasics.DefaultGenesis(encCfg.Marshaler) - genesis[types.ModuleName] = govGenRaw - cfg.GenesisState = genesis - - cfg.AppConstructor = func(val network.Validator) servertypes.Application { - return app.NewInitApp( - val.Ctx.Logger, dbm.NewMemDB(), nil, true, make(map[int64]bool), val.Ctx.Config.RootDir, 0, - simapp.MakeEncodingConfig(), - simapp.EmptyAppOptions{}, - baseapp.SetPruning(storetypes.NewPruningOptionsFromString(val.AppConfig.Pruning)), - baseapp.SetMinGasPrices(val.AppConfig.MinGasPrices), - ) - } - - s.cfg = cfg - s.network = network.New(s.T(), cfg) - - _, err := s.network.WaitForHeight(1) - s.Require().NoError(err) -} - -// func (s IntegrationTestSuite) TestClaimCouncilor_HappyPath() { -// val := s.network.Validators[0] -// clientCtx := val.ClientCtx - -// s.SetCouncilor(val.Address) - -// err := s.network.WaitForNextBlock() -// s.Require().NoError(err) - -// // Query command -// // Mandatory flags -// cmd := cli.GetCmdQueryCouncilRegistry() - -// out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{""}) -// s.Require().Error(err) - -// // From address -// out.Reset() - -// cmd = cli.GetCmdQueryCouncilRegistry() - -// out, err = clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ -// fmt.Sprintf("--%s=%s", cli.FlagAddress, val.Address.String()), -// }) -// s.Require().NoError(err) - -// var councilorByAddress types.Councilor -// err = val.ClientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), &councilorByAddress) -// s.Require().NoError(err) -// s.Require().Equal(val.Moniker, councilorByAddress.Moniker) -// s.Require().Equal(val.Address, councilorByAddress.Address) - -// // From Moniker -// cmd = cli.GetCmdQueryCouncilRegistry() -// out, err = clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ -// fmt.Sprintf("--%s=%s", cli.FlagMoniker, val.Moniker), -// }) -// s.Require().NoError(err) - -// var councilorByMoniker types.Councilor -// err = val.ClientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), &councilorByMoniker) -// s.Require().NoError(err) -// s.Require().Equal(val.Moniker, councilorByMoniker.Moniker) -// s.Require().Equal(val.Address, councilorByMoniker.Address) -// } - -// func (s IntegrationTestSuite) TestProposalAndVoteSetPoorNetworkMessages_HappyPath() { -// val := s.network.Validators[0] - -// // create proposal for setting poor network msgs -// result := s.SetPoorNetworkMessages("AAA,BBB") -// s.Require().Contains(result.RawLog, "SetPoorNetworkMessages") - -// // query for proposals -// s.QueryProposals() - -// // set permission to vote on proposal -// s.WhitelistPermission(val.Address, "19") // 19 is permission for vote on poor network message set proposal - -// // vote on the proposal -// s.VoteWithValidator0(1, types.OptionYes) - -// // check votes -// s.QueryProposalVotes(1) - -// // check proposal status until gov process it -// s.network.WaitForNextBlock() - -// // query poor network messages -// s.QueryPoorNetworkMessages() -// } - -// func (s IntegrationTestSuite) TestProposalAndVotePoorNetworkMaxBankSend_HappyPath() { -// val := s.network.Validators[0] - -// // set min validators to 2 -// s.SetNetworkProperties(1, 10000, 2) - -// // try setting network property by governance to allow more amount sending -// s.SetNetworkPropertyProposal("POOR_NETWORK_MAX_BANK_SEND", 100000000) - -// // vote on the proposal -// s.VoteWithValidator0(1, types.OptionYes) - -// // check votes -// s.QueryProposalVotes(1) - -// // check proposal status until gov process it -// s.network.WaitForNextBlock() - -// // try sending after modification of poor network bank send param -// s.SendValue(val.ClientCtx, val.Address, val.Address, sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100000000))) -// } - -// func (s IntegrationTestSuite) TestPoorNetworkRestrictions_HappyPath() { -// val := s.network.Validators[0] - -// // whitelist permission for modifying network properties -// s.WhitelistPermission(val.Address, "7") - -// // test poor network messages after modifying min_validators section -// s.SetNetworkProperties(1, 10000, 2) - -// // set permission for upsert token rate -// s.WhitelistPermission(val.Address, "8") - -// // try running upser token rate which is not allowed on poor network -// result := s.UpsertRate("mykex", "1.5", true) -// s.Require().Contains(result.RawLog, "invalid transaction type on poor network") - -// // try sending more than allowed amount via bank send -// s.SendValue(val.ClientCtx, val.Address, val.Address, sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100000000))) -// } - -func TestIntegrationTestSuite(t *testing.T) { - suite.Run(t, new(IntegrationTestSuite)) -} +package cli_test + +import ( + "testing" + + "github.com/KiraCore/sekai/app" + simapp "github.com/KiraCore/sekai/app" + "github.com/KiraCore/sekai/testutil/network" + "github.com/KiraCore/sekai/x/gov/types" + "github.com/cosmos/cosmos-sdk/baseapp" + servertypes "github.com/cosmos/cosmos-sdk/server/types" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + "github.com/stretchr/testify/suite" + dbm "github.com/tendermint/tm-db" +) + +type IntegrationTestSuite struct { + suite.Suite + + cfg network.Config + network *network.Network +} + +func (s *IntegrationTestSuite) SetupSuite() { + app.SetConfig() + s.T().Log("setting up integration test suite") + + cfg := network.DefaultConfig() + encCfg := app.MakeEncodingConfig() + cfg.Codec = encCfg.Marshaler + cfg.TxConfig = encCfg.TxConfig + + cfg.NumValidators = 1 + + // customize proposal end time and enactment time + govGen := types.DefaultGenesis() + // govGen.NetworkProperties.ProposalEndTime = 1 + // govGen.NetworkProperties.ProposalEnactmentTime = 2 + govGenRaw := encCfg.Marshaler.MustMarshalJSON(govGen) + + genesis := app.ModuleBasics.DefaultGenesis(encCfg.Marshaler) + genesis[types.ModuleName] = govGenRaw + cfg.GenesisState = genesis + + cfg.AppConstructor = func(val network.Validator) servertypes.Application { + return app.NewInitApp( + val.Ctx.Logger, dbm.NewMemDB(), nil, true, make(map[int64]bool), val.Ctx.Config.RootDir, 0, + simapp.MakeEncodingConfig(), + simapp.EmptyAppOptions{}, + baseapp.SetPruning(storetypes.NewPruningOptionsFromString(val.AppConfig.Pruning)), + baseapp.SetMinGasPrices(val.AppConfig.MinGasPrices), + ) + } + + s.cfg = cfg + s.network = network.New(s.T(), cfg) + + _, err := s.network.WaitForHeight(1) + s.Require().NoError(err) +} + +// func (s IntegrationTestSuite) TestClaimCouncilor_HappyPath() { +// val := s.network.Validators[0] +// clientCtx := val.ClientCtx + +// s.SetCouncilor(val.Address) + +// err := s.network.WaitForNextBlock() +// s.Require().NoError(err) + +// // Query command +// // Mandatory flags +// cmd := cli.GetCmdQueryCouncilRegistry() + +// out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{""}) +// s.Require().Error(err) + +// // From address +// out.Reset() + +// cmd = cli.GetCmdQueryCouncilRegistry() + +// out, err = clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ +// fmt.Sprintf("--%s=%s", cli.FlagAddress, val.Address.String()), +// }) +// s.Require().NoError(err) + +// var councilorByAddress types.Councilor +// err = val.ClientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), &councilorByAddress) +// s.Require().NoError(err) +// s.Require().Equal(val.Moniker, councilorByAddress.Moniker) +// s.Require().Equal(val.Address, councilorByAddress.Address) + +// // From Moniker +// cmd = cli.GetCmdQueryCouncilRegistry() +// out, err = clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ +// fmt.Sprintf("--%s=%s", cli.FlagMoniker, val.Moniker), +// }) +// s.Require().NoError(err) + +// var councilorByMoniker types.Councilor +// err = val.ClientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), &councilorByMoniker) +// s.Require().NoError(err) +// s.Require().Equal(val.Moniker, councilorByMoniker.Moniker) +// s.Require().Equal(val.Address, councilorByMoniker.Address) +// } + +// func (s IntegrationTestSuite) TestProposalAndVoteSetPoorNetworkMessages_HappyPath() { +// val := s.network.Validators[0] + +// // create proposal for setting poor network msgs +// result := s.SetPoorNetworkMessages("AAA,BBB") +// s.Require().Contains(result.RawLog, "SetPoorNetworkMessages") + +// // query for proposals +// s.QueryProposals() + +// // set permission to vote on proposal +// s.WhitelistPermission(val.Address, "19") // 19 is permission for vote on poor network message set proposal + +// // vote on the proposal +// s.VoteWithValidator0(1, types.OptionYes) + +// // check votes +// s.QueryProposalVotes(1) + +// // check proposal status until gov process it +// s.network.WaitForNextBlock() + +// // query poor network messages +// s.QueryPoorNetworkMessages() +// } + +// func (s IntegrationTestSuite) TestProposalAndVotePoorNetworkMaxBankSend_HappyPath() { +// val := s.network.Validators[0] + +// // set min validators to 2 +// s.SetNetworkProperties(1, 10000, 2) + +// // try setting network property by governance to allow more amount sending +// s.SetNetworkPropertyProposal("POOR_NETWORK_MAX_BANK_SEND", 100000000) + +// // vote on the proposal +// s.VoteWithValidator0(1, types.OptionYes) + +// // check votes +// s.QueryProposalVotes(1) + +// // check proposal status until gov process it +// s.network.WaitForNextBlock() + +// // try sending after modification of poor network bank send param +// s.SendValue(val.ClientCtx, val.Address, val.Address, sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100000000))) +// } + +// func (s IntegrationTestSuite) TestPoorNetworkRestrictions_HappyPath() { +// val := s.network.Validators[0] + +// // whitelist permission for modifying network properties +// s.WhitelistPermission(val.Address, "7") + +// // test poor network messages after modifying min_validators section +// s.SetNetworkProperties(1, 10000, 2) + +// // set permission for upsert token rate +// s.WhitelistPermission(val.Address, "8") + +// // try running upser token rate which is not allowed on poor network +// result := s.UpsertRate("mykex", "1.5", true) +// s.Require().Contains(result.RawLog, "invalid transaction type on poor network") + +// // try sending more than allowed amount via bank send +// s.SendValue(val.ClientCtx, val.Address, val.Address, sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100000000))) +// } + +func TestIntegrationTestSuite(t *testing.T) { + suite.Run(t, new(IntegrationTestSuite)) +} diff --git a/x/gov/client/cli/query.go b/x/gov/client/cli/query.go index fda04b678..81461682b 100644 --- a/x/gov/client/cli/query.go +++ b/x/gov/client/cli/query.go @@ -38,6 +38,8 @@ func NewQueryCmd() *cobra.Command { GetCmdQueryAllRoles(), GetCmdQueryRolesByAddress(), GetCmdQueryProposals(), + GetCmdQueryPolls(), + GetCmdQueryPollVotes(), GetCmdQueryCouncilRegistry(), GetCmdQueryProposal(), GetCmdQueryVote(), @@ -391,6 +393,68 @@ $ %s query gov proposals --voter cosmos1skjwj5whet0lpe65qaq4rpq03hjxlwd9nf39lk return cmd } +// GetCmdQueryPolls implements a query polls command. Command to Get a +// poll ids. +func GetCmdQueryPolls() *cobra.Command { + cmd := &cobra.Command{ + Use: "polls [address]", + Short: "Get polls by address", + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + accAddr, err := sdk.AccAddressFromBech32(args[0]) + + if err != nil { + return errors.Wrap(err, "invalid account address") + } + + params := &types.QueryPollsListByAddress{Creator: accAddr} + queryClient := types.NewQueryClient(clientCtx) + res, err := queryClient.PollsListByAddress(context.Background(), params) + + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +// GetCmdQueryPollVotes implements a query poll votes command. Command to Get a +// poll votes by id. +func GetCmdQueryPollVotes() *cobra.Command { + cmd := &cobra.Command{ + Use: "poll-votes [ID]", + Short: "Get poll votes by id", + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + id, err := strconv.Atoi(args[0]) + + if err != nil { + return errors.Wrap(err, "invalid poll id") + } + + params := &types.QueryPollsVotesByPollId{PollId: uint64(id)} + queryClient := types.NewQueryClient(clientCtx) + res, err := queryClient.PollsVotesByPollId(context.Background(), params) + + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + // GetCmdQueryProposal implements the query proposal command. func GetCmdQueryProposal() *cobra.Command { cmd := &cobra.Command{ @@ -1140,7 +1204,7 @@ $ %[1]s query gov councilors clientCtx := client.GetClientContextFromCmd(cmd) queryClient := types.NewQueryClient(clientCtx) - res, err := queryClient.QueryCouncilors( + res, err := queryClient.Councilors( context.Background(), &types.QueryCouncilors{}, ) @@ -1177,7 +1241,7 @@ $ %[1]s query gov non-councilors clientCtx := client.GetClientContextFromCmd(cmd) queryClient := types.NewQueryClient(clientCtx) - res, err := queryClient.QueryNonCouncilors( + res, err := queryClient.NonCouncilors( context.Background(), &types.QueryNonCouncilors{}, ) @@ -1219,7 +1283,7 @@ $ %[1]s query gov whitelisted-permission-addresses [perm] return err } - res, err := queryClient.QueryAddressesByWhitelistedPermission( + res, err := queryClient.AddressesByWhitelistedPermission( context.Background(), &types.QueryAddressesByWhitelistedPermission{ Permission: uint32(perm), @@ -1263,7 +1327,7 @@ $ %[1]s query gov blacklisted-permission-addresses [perm] return err } - res, err := queryClient.QueryAddressesByBlacklistedPermission( + res, err := queryClient.AddressesByBlacklistedPermission( context.Background(), &types.QueryAddressesByBlacklistedPermission{ Permission: uint32(perm), @@ -1307,7 +1371,7 @@ $ %[1]s query gov whitelisted-role-addresses [role] return err } - res, err := queryClient.QueryAddressesByWhitelistedRole( + res, err := queryClient.AddressesByWhitelistedRole( context.Background(), &types.QueryAddressesByWhitelistedRole{ Role: uint32(role), diff --git a/x/gov/client/cli/tx.go b/x/gov/client/cli/tx.go index e2c1e49dc..2c246e15b 100644 --- a/x/gov/client/cli/tx.go +++ b/x/gov/client/cli/tx.go @@ -48,6 +48,15 @@ const ( FlagSocial = "social" FlagContact = "contact" FlagAvatar = "avatar" + FlagPollRoles = "poll-roles" + FlagPollOptions = "poll-options" + FlagPollCount = "poll-count" + FlagPollType = "poll-type" + FlagPollChoices = "poll-choices" + FlagPollDuration = "poll-duration" + FlagPollReference = "poll-reference" + FlagPollChecksum = "poll-checksum" + FlagCustomPollValue = "poll-custom-value" ) // NewTxCmd returns a root CLI command handler for all x/bank transaction commands. @@ -63,6 +72,7 @@ func NewTxCmd() *cobra.Command { txCmd.AddCommand( NewTxCouncilorCmds(), NewTxProposalCmds(), + NewTxPollCmds(), NewTxRoleCmds(), NewTxPermissionCmds(), NewTxSetNetworkProperties(), @@ -77,6 +87,22 @@ func NewTxCmd() *cobra.Command { return txCmd } +// NewTxPollCmds returns the subcommands of poll related commands. +func NewTxPollCmds() *cobra.Command { + pollCmd := &cobra.Command{ + Use: "poll", + Short: "Governance poll management subcommands", + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + pollCmd.AddCommand(GetTxPollCreate()) + pollCmd.AddCommand(GetTxVotePoll()) + + return pollCmd +} + // NewTxProposalCmds returns the subcommands of proposal related commands. func NewTxProposalCmds() *cobra.Command { proposalCmd := &cobra.Command{ @@ -2022,6 +2048,156 @@ func GetTxCancelIdentityRecordsVerifyRequest() *cobra.Command { return cmd } +func GetTxPollCreate() *cobra.Command { + cmd := &cobra.Command{ + Use: "create", + Short: "Create a poll.", + Args: cobra.ExactArgs(0), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + title, err := cmd.Flags().GetString(FlagTitle) + if err != nil { + return fmt.Errorf("invalid title: %w", err) + } + + description, err := cmd.Flags().GetString(FlagDescription) + if err != nil { + return fmt.Errorf("invalid description: %w", err) + } + + reference, err := cmd.Flags().GetString(FlagPollReference) + if err != nil { + return fmt.Errorf("invalid reference: %w", err) + } + + checksum, err := cmd.Flags().GetString(FlagPollChecksum) + if err != nil { + return fmt.Errorf("invalid checksum: %w", err) + } + + options, err := cmd.Flags().GetStringSlice(FlagPollOptions) + if err != nil { + return fmt.Errorf("invalid options: %w", err) + } + + var filteredOptions []string + for _, v := range options { + filteredOptions = append(filteredOptions, strings.ToLower(strings.TrimSpace(v))) + } + + roles, err := cmd.Flags().GetStringSlice(FlagPollRoles) + if err != nil { + return fmt.Errorf("invalid roles: %w", err) + } + + valueCount, err := cmd.Flags().GetUint64(FlagPollCount) + if err != nil { + return fmt.Errorf("invalid count: %w", err) + } + + valueType, err := cmd.Flags().GetString(FlagPollType) + if err != nil { + return fmt.Errorf("invalid type: %w", err) + } + + possibleChoices, err := cmd.Flags().GetUint64(FlagPollChoices) + if err != nil { + return fmt.Errorf("invalid choices: %w", err) + } + + duration, err := cmd.Flags().GetString(FlagPollDuration) + if err != nil { + return fmt.Errorf("invalid duration: %w", err) + } + + msg := types.NewMsgPollCreate( + clientCtx.FromAddress, + title, + description, + reference, + checksum, + filteredOptions, + roles, + valueCount, + valueType, + possibleChoices, + duration, + ) + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + cmd.Flags().String(FlagTitle, "", "The title of the poll.") + cmd.MarkFlagRequired(FlagTitle) + cmd.Flags().String(FlagDescription, "", "The description of the poll, it can be an url, some text, etc.") + cmd.MarkFlagRequired(FlagDescription) + cmd.Flags().String(FlagPollReference, "", "IPFS CID or URL reference to file describing poll and voting options in depth.") + cmd.Flags().String(FlagPollChecksum, "", "Reference checksum.") + cmd.Flags().StringSlice(FlagPollOptions, []string{}, "The options value in the format variant1,variant2.") + cmd.MarkFlagRequired(FlagPollOptions) + cmd.Flags().StringSlice(FlagPollRoles, []string{}, "List of roles that are allowed to take part in the poll vote in the format role1,role2.") + cmd.MarkFlagRequired(FlagPollRoles) + cmd.Flags().Uint64(FlagPollCount, 128, "Maximum number of voting options that poll can have.") + cmd.Flags().String(FlagPollType, "", "Type of the options, all user supplied or predefined options must match its type.") + cmd.MarkFlagRequired(FlagPollType) + cmd.Flags().Uint64(FlagPollChoices, 1, "Should define maximum number of choices that voter can select.") + cmd.Flags().String(FlagPollDuration, "", "The duration of the poll.") + cmd.MarkFlagRequired(FlagPollDuration) + cmd.MarkFlagRequired(flags.FlagFrom) + + return cmd +} + +func GetTxVotePoll() *cobra.Command { + cmd := &cobra.Command{ + Use: "vote [poll-id] [poll-option] ", + Short: "Vote a poll.", + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + pollID, err := strconv.Atoi(args[0]) + if err != nil { + return fmt.Errorf("invalid poll ID: %w", err) + } + + optionID, err := strconv.Atoi(args[1]) + if err != nil { + return fmt.Errorf("invalid option ID: %w", err) + } + + value, err := cmd.Flags().GetString(FlagCustomPollValue) + if err != nil { + return fmt.Errorf("invalid custom value: %w", err) + } + + msg := types.NewMsgVotePoll( + uint64(pollID), + clientCtx.FromAddress, + types.PollVoteOption(optionID), + value, + ) + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + cmd.Flags().String(FlagCustomPollValue, "", "The custom poll value.") + cmd.MarkFlagRequired(flags.FlagFrom) + + return cmd +} + func parseIdInfoJSON(fs *pflag.FlagSet) ([]types.IdentityInfoEntry, error) { var err error infos := make(map[string]string) @@ -2155,3 +2331,13 @@ func convertAsPermValues(values []int32) []types.PermValue { return v } + +// convertAsPermValues convert array of int32 to PermValue array. +func convertAsOptionValues(values []int32) []types.PollVoteOption { + var v []types.PollVoteOption + for _, option := range values { + v = append(v, types.PollVoteOption(option)) + } + + return v +} diff --git a/x/gov/client/cli/util_test.go b/x/gov/client/cli/util_test.go index fc83d4a9e..ee74725ee 100644 --- a/x/gov/client/cli/util_test.go +++ b/x/gov/client/cli/util_test.go @@ -1,230 +1,230 @@ -package cli_test - -import ( - "fmt" - "strconv" - "testing" - - "github.com/KiraCore/sekai/testutil/network" - "github.com/KiraCore/sekai/x/gov/client/cli" - "github.com/KiraCore/sekai/x/gov/types" - customstakingcli "github.com/KiraCore/sekai/x/staking/client/cli" - tokenscli "github.com/KiraCore/sekai/x/tokens/client/cli" - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/client/flags" - clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" - sdk "github.com/cosmos/cosmos-sdk/types" - bankcli "github.com/cosmos/cosmos-sdk/x/bank/client/cli" - "github.com/stretchr/testify/require" -) - -// GetRolesByAddress calls the CLI command GetCmdQueryRolesByAddress and returns the roles. -func GetRolesByAddress(t *testing.T, network *network.Network, address sdk.AccAddress) []uint64 { - val := network.Validators[0] - clientCtx := val.ClientCtx - cmd := cli.GetCmdQueryRolesByAddress() - out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ - address.String(), - }) - require.NoError(t, err) - - var roles types.RolesByAddressResponse - err = val.ClientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), &roles) - require.NoError(t, err) - - return roles.RoleIds -} - -// SetCouncilor calls CLI to set address in the Councilor Registry. The Validator 1 is the caller. -func (s IntegrationTestSuite) SetCouncilor(address sdk.Address) { - val := s.network.Validators[0] - clientCtx := val.ClientCtx - - cmd := cli.GetTxClaimCouncilorSeatCmd() - _, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ - fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), - fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), - fmt.Sprintf("--%s=%s", cli.FlagAddress, address.String()), - fmt.Sprintf("--%s=%s", cli.FlagMoniker, val.Moniker), - }) - s.Require().NoError(err) - - err = s.network.WaitForNextBlock() - s.Require().NoError(err) -} - -// SendValue sends Coins from A to B using CLI. -func (s IntegrationTestSuite) SendValue(cCtx client.Context, from sdk.AccAddress, to sdk.AccAddress, coin sdk.Coin) { - cmd := bankcli.NewSendTxCmd() - _, err := clitestutil.ExecTestCLICmd(cCtx, cmd, []string{ - from.String(), - to.String(), - coin.String(), - fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), - }) - s.Require().NoError(err) - - err = s.network.WaitForNextBlock() - s.Require().NoError(err) -} - -func (s IntegrationTestSuite) WhitelistPermission(address sdk.AccAddress, perm string) { - val := s.network.Validators[0] - clientCtx := val.ClientCtx - cmd := cli.GetTxSetWhitelistPermissions() - out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ - fmt.Sprintf("--%s=%s", customstakingcli.FlagAddr, address.String()), - fmt.Sprintf("--%s=%s", cli.FlagPermission, perm), - fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), - fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), - }) - s.Require().NoError(err) - fmt.Println("IntegrationTestSuite::WhitelistPermission", out.String()) -} - -func (s IntegrationTestSuite) VoteWithValidator0(proposalID uint64, voteOption types.VoteOption) { - val := s.network.Validators[0] - clientCtx := val.ClientCtx - cmd := cli.GetTxVoteProposal() - out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ - fmt.Sprintf("%d", proposalID), - fmt.Sprintf("%d", voteOption), - fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), - fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), - }) - s.Require().NoError(err) - var result sdk.TxResponse - s.Require().NoError(val.ClientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), &result)) - s.Require().NotNil(result.Height) -} - -func (s IntegrationTestSuite) QueryProposals() { - val := s.network.Validators[0] - clientCtx := val.ClientCtx - cmd := cli.GetCmdQueryProposals() - output, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{}) - s.Require().NoError(err, string(output.Bytes())) -} - -func (s IntegrationTestSuite) QueryProposalVotes(proposalID uint64) { - val := s.network.Validators[0] - clientCtx := val.ClientCtx - cmd := cli.GetCmdQueryVotes() - _, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ - fmt.Sprintf("%d", proposalID), - }) - s.Require().NoError(err) -} - -func (s IntegrationTestSuite) QueryPoorNetworkMessages() { - val := s.network.Validators[0] - clientCtx := val.ClientCtx - cmd := cli.GetCmdQueryPoorNetworkMessages() - _, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{}) - s.Require().NoError(err) -} - -func (s IntegrationTestSuite) SetPoorNetworkMessages(messages string) sdk.TxResponse { - val := s.network.Validators[0] - clientCtx := val.ClientCtx - cmd := cli.GetTxProposalSetPoorNetworkMessages() - out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ - messages, - fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), - fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", cli.FlagTitle, "title"), - fmt.Sprintf("--%s=%s", cli.FlagDescription, "some desc"), - fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), - }) - s.Require().NoError(err) - - err = s.network.WaitForNextBlock() - s.Require().NoError(err) - - var result sdk.TxResponse - s.Require().NoError(val.ClientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), &result)) - s.Require().NotNil(result.Height) - return result -} - -func (s IntegrationTestSuite) SetNetworkProperties(minTxFee, maxTxFee, minValidators uint64) { - val := s.network.Validators[0] - clientCtx := val.ClientCtx - cmd := cli.NewTxSetNetworkProperties() - out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ - fmt.Sprintf("--%s=%d", cli.FlagMinTxFee, minTxFee), - fmt.Sprintf("--%s=%d", cli.FlagMaxTxFee, maxTxFee), - fmt.Sprintf("--%s=%d", cli.FlagMinValidators, minValidators), - fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), - fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), - }) - s.Require().NoError(err) - - err = s.network.WaitForNextBlock() - s.Require().NoError(err) - - var result sdk.TxResponse - s.Require().NoError(val.ClientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), &result)) - s.Require().NotNil(result.Height) - s.Require().Contains(result.RawLog, "MsgSetNetworkProperties") -} - -func (s IntegrationTestSuite) SetNetworkPropertyProposal(property string, value uint64) { - val := s.network.Validators[0] - clientCtx := val.ClientCtx - cmd := cli.GetTxProposalSetNetworkProperty() - out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ - property, - fmt.Sprintf("%d", value), - fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), - fmt.Sprintf("--%s=%s", cli.FlagTitle, "title"), - fmt.Sprintf("--%s=%s", cli.FlagDescription, "some desc"), - fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), - }) - s.Require().NoError(err) - - err = s.network.WaitForNextBlock() - s.Require().NoError(err) - - var result sdk.TxResponse - s.Require().NoError(val.ClientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), &result)) - s.Require().NotNil(result.Height) - s.Require().Contains(result.RawLog, "SetNetworkProperty") -} - -func (s IntegrationTestSuite) UpsertRate(denom string, rate string, flagFeePayments bool) sdk.TxResponse { - val := s.network.Validators[0] - clientCtx := val.ClientCtx - cmd := tokenscli.GetTxUpsertTokenRateCmd() - out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ - fmt.Sprintf("--%s=%s", tokenscli.FlagDenom, denom), - fmt.Sprintf("--%s=%s", tokenscli.FlagRate, rate), - fmt.Sprintf("--%s=%s", tokenscli.FlagFeePayments, strconv.FormatBool(flagFeePayments)), - fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), - fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), - }) - s.Require().NoError(err) - - err = s.network.WaitForNextBlock() - s.Require().NoError(err) - - var result sdk.TxResponse - s.Require().NoError(val.ClientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), &result)) - s.Require().NotNil(result.Height) - return result -} +package cli_test + +import ( + "fmt" + "strconv" + "testing" + + "github.com/KiraCore/sekai/testutil/network" + "github.com/KiraCore/sekai/x/gov/client/cli" + "github.com/KiraCore/sekai/x/gov/types" + customstakingcli "github.com/KiraCore/sekai/x/staking/client/cli" + tokenscli "github.com/KiraCore/sekai/x/tokens/client/cli" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" + sdk "github.com/cosmos/cosmos-sdk/types" + bankcli "github.com/cosmos/cosmos-sdk/x/bank/client/cli" + "github.com/stretchr/testify/require" +) + +// GetRolesByAddress calls the CLI command GetCmdQueryRolesByAddress and returns the roles. +func GetRolesByAddress(t *testing.T, network *network.Network, address sdk.AccAddress) []uint64 { + val := network.Validators[0] + clientCtx := val.ClientCtx + cmd := cli.GetCmdQueryRolesByAddress() + out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ + address.String(), + }) + require.NoError(t, err) + + var roles types.RolesByAddressResponse + err = val.ClientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), &roles) + require.NoError(t, err) + + return roles.RoleIds +} + +// SetCouncilor calls CLI to set address in the Councilor Registry. The Validator 1 is the caller. +func (s IntegrationTestSuite) SetCouncilor(address sdk.Address) { + val := s.network.Validators[0] + clientCtx := val.ClientCtx + + cmd := cli.GetTxClaimCouncilorSeatCmd() + _, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), + fmt.Sprintf("--%s=%s", cli.FlagAddress, address.String()), + fmt.Sprintf("--%s=%s", cli.FlagMoniker, val.Moniker), + }) + s.Require().NoError(err) + + err = s.network.WaitForNextBlock() + s.Require().NoError(err) +} + +// SendValue sends Coins from A to B using CLI. +func (s IntegrationTestSuite) SendValue(cCtx client.Context, from sdk.AccAddress, to sdk.AccAddress, coin sdk.Coin) { + cmd := bankcli.NewSendTxCmd() + _, err := clitestutil.ExecTestCLICmd(cCtx, cmd, []string{ + from.String(), + to.String(), + coin.String(), + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), + }) + s.Require().NoError(err) + + err = s.network.WaitForNextBlock() + s.Require().NoError(err) +} + +func (s IntegrationTestSuite) WhitelistPermission(address sdk.AccAddress, perm string) { + val := s.network.Validators[0] + clientCtx := val.ClientCtx + cmd := cli.GetTxSetWhitelistPermissions() + out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ + fmt.Sprintf("--%s=%s", customstakingcli.FlagAddr, address.String()), + fmt.Sprintf("--%s=%s", cli.FlagPermission, perm), + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), + }) + s.Require().NoError(err) + fmt.Println("IntegrationTestSuite::WhitelistPermission", out.String()) +} + +func (s IntegrationTestSuite) VoteWithValidator0(proposalID uint64, voteOption types.VoteOption) { + val := s.network.Validators[0] + clientCtx := val.ClientCtx + cmd := cli.GetTxVoteProposal() + out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ + fmt.Sprintf("%d", proposalID), + fmt.Sprintf("%d", voteOption), + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), + }) + s.Require().NoError(err) + var result sdk.TxResponse + s.Require().NoError(val.ClientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), &result)) + s.Require().NotNil(result.Height) +} + +func (s IntegrationTestSuite) QueryProposals() { + val := s.network.Validators[0] + clientCtx := val.ClientCtx + cmd := cli.GetCmdQueryProposals() + output, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{}) + s.Require().NoError(err, string(output.Bytes())) +} + +func (s IntegrationTestSuite) QueryProposalVotes(proposalID uint64) { + val := s.network.Validators[0] + clientCtx := val.ClientCtx + cmd := cli.GetCmdQueryVotes() + _, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ + fmt.Sprintf("%d", proposalID), + }) + s.Require().NoError(err) +} + +func (s IntegrationTestSuite) QueryPoorNetworkMessages() { + val := s.network.Validators[0] + clientCtx := val.ClientCtx + cmd := cli.GetCmdQueryPoorNetworkMessages() + _, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{}) + s.Require().NoError(err) +} + +func (s IntegrationTestSuite) SetPoorNetworkMessages(messages string) sdk.TxResponse { + val := s.network.Validators[0] + clientCtx := val.ClientCtx + cmd := cli.GetTxProposalSetPoorNetworkMessages() + out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ + messages, + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", cli.FlagTitle, "title"), + fmt.Sprintf("--%s=%s", cli.FlagDescription, "some desc"), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), + }) + s.Require().NoError(err) + + err = s.network.WaitForNextBlock() + s.Require().NoError(err) + + var result sdk.TxResponse + s.Require().NoError(val.ClientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), &result)) + s.Require().NotNil(result.Height) + return result +} + +func (s IntegrationTestSuite) SetNetworkProperties(minTxFee, maxTxFee, minValidators uint64) { + val := s.network.Validators[0] + clientCtx := val.ClientCtx + cmd := cli.NewTxSetNetworkProperties() + out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ + fmt.Sprintf("--%s=%d", cli.FlagMinTxFee, minTxFee), + fmt.Sprintf("--%s=%d", cli.FlagMaxTxFee, maxTxFee), + fmt.Sprintf("--%s=%d", cli.FlagMinValidators, minValidators), + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), + }) + s.Require().NoError(err) + + err = s.network.WaitForNextBlock() + s.Require().NoError(err) + + var result sdk.TxResponse + s.Require().NoError(val.ClientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), &result)) + s.Require().NotNil(result.Height) + s.Require().Contains(result.RawLog, "MsgSetNetworkProperties") +} + +func (s IntegrationTestSuite) SetNetworkPropertyProposal(property string, value uint64) { + val := s.network.Validators[0] + clientCtx := val.ClientCtx + cmd := cli.GetTxProposalSetNetworkProperty() + out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ + property, + fmt.Sprintf("%d", value), + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), + fmt.Sprintf("--%s=%s", cli.FlagTitle, "title"), + fmt.Sprintf("--%s=%s", cli.FlagDescription, "some desc"), + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), + }) + s.Require().NoError(err) + + err = s.network.WaitForNextBlock() + s.Require().NoError(err) + + var result sdk.TxResponse + s.Require().NoError(val.ClientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), &result)) + s.Require().NotNil(result.Height) + s.Require().Contains(result.RawLog, "SetNetworkProperty") +} + +func (s IntegrationTestSuite) UpsertRate(denom string, rate string, flagFeePayments bool) sdk.TxResponse { + val := s.network.Validators[0] + clientCtx := val.ClientCtx + cmd := tokenscli.GetTxUpsertTokenRateCmd() + out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{ + fmt.Sprintf("--%s=%s", tokenscli.FlagDenom, denom), + fmt.Sprintf("--%s=%s", tokenscli.FlagRate, rate), + fmt.Sprintf("--%s=%s", tokenscli.FlagFeePayments, strconv.FormatBool(flagFeePayments)), + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), + }) + s.Require().NoError(err) + + err = s.network.WaitForNextBlock() + s.Require().NoError(err) + + var result sdk.TxResponse + s.Require().NoError(val.ClientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), &result)) + s.Require().NotNil(result.Height) + return result +} diff --git a/x/gov/genesis.go b/x/gov/genesis.go index 6199c84af..4c662867c 100644 --- a/x/gov/genesis.go +++ b/x/gov/genesis.go @@ -1,137 +1,137 @@ -package gov - -import ( - "bytes" - - "github.com/KiraCore/sekai/x/gov/keeper" - "github.com/KiraCore/sekai/x/gov/types" - sdk "github.com/cosmos/cosmos-sdk/types" -) - -func InitGenesis( - ctx sdk.Context, - k keeper.Keeper, - genesisState types.GenesisState, -) error { - k.SetNextRoleId(ctx, genesisState.NextRoleId) - for _, actor := range genesisState.NetworkActors { - k.SaveNetworkActor(ctx, *actor) - for _, role := range actor.Roles { - k.AssignRoleToActor(ctx, *actor, role) - } - for _, perm := range actor.Permissions.Whitelist { - k.SetWhitelistAddressPermKey(ctx, *actor, types.PermValue(perm)) - } - // TODO when we add keeper function for managing blacklist mapping, we can just enable this - // for _, perm := range actor.Permissions.Blacklist { - // k.RemoveWhitelistPermission(ctx, *actor, types.PermValue(perm)) - // } - } - - for _, role := range genesisState.Roles { - k.SetRole(ctx, role) - } - - for roleId, perm := range genesisState.RolePermissions { - for _, white := range perm.Whitelist { - k.WhitelistRolePermission(ctx, roleId, types.PermValue(white)) - } - // TODO when we add keeper function for managing blacklist mapping, we can just enable this - // for _, black := range perm.Blacklist { - // err := k.BlacklistRolePermission(ctx, roleId, types.PermValue(black)) - // if err != nil { - // // TODO: this is fine with current upgrade but from next time, it should panic - // fmt.Println("There was an error blacklisting role permission", err) - // // panic(err) - // } - // } - } - - k.SetNextProposalID(ctx, genesisState.StartingProposalId) - err := k.SetNetworkProperties(ctx, genesisState.NetworkProperties) - if err != nil { - panic(err) - } - - for _, fee := range genesisState.ExecutionFees { - k.SetExecutionFee(ctx, fee) - } - - k.SavePoorNetworkMessages(ctx, genesisState.PoorNetworkMessages) - - for _, proposal := range genesisState.Proposals { - k.SaveProposal(ctx, proposal) - } - - for _, vote := range genesisState.Votes { - k.SaveVote(ctx, vote) - } - - for key, entry := range genesisState.DataRegistry { - if entry == nil { - continue - } - k.UpsertDataRegistryEntry(ctx, key, *entry) - } - - for _, record := range genesisState.IdentityRecords { - k.SetIdentityRecord(ctx, record) - } - for _, request := range genesisState.IdRecordsVerifyRequests { - k.SetIdentityRecordsVerifyRequest(ctx, request) - } - - k.SetLastIdentityRecordId(ctx, genesisState.LastIdentityRecordId) - k.SetLastIdRecordVerifyRequestId(ctx, genesisState.LastIdRecordVerifyRequestId) - - for typeofProposal, duration := range genesisState.ProposalDurations { - err := k.SetProposalDuration(ctx, typeofProposal, duration) - if err != nil { - return nil - } - } - - return nil -} - -// ExportGenesis writes the current store values -// to a genesis file, which can be imported again -// with InitGenesis -func ExportGenesis(ctx sdk.Context, k keeper.Keeper) (data *types.GenesisState) { - rolesIterator := k.IterateRoles(ctx) - defer rolesIterator.Close() - rolePermissions := make(map[uint64]*types.Permissions) - for ; rolesIterator.Valid(); rolesIterator.Next() { - role := sdk.BigEndianToUint64(bytes.TrimPrefix(rolesIterator.Key(), keeper.RolePermissionRegistry)) - perms := k.GetPermissionsFromIterator(rolesIterator) - rolePermissions[role] = &perms - } - - networkActorsIterator := k.GetNetworkActorsIterator(ctx) - defer networkActorsIterator.Close() - networkActors := []*types.NetworkActor{} - for ; networkActorsIterator.Valid(); networkActorsIterator.Next() { - networkActors = append(networkActors, k.GetNetworkActorFromIterator(networkActorsIterator)) - } - - proposals, _ := k.GetProposals(ctx) - - return &types.GenesisState{ - StartingProposalId: k.GetNextProposalID(ctx), - NextRoleId: k.GetNextRoleId(ctx), - Roles: k.GetAllRoles(ctx), - RolePermissions: rolePermissions, - NetworkActors: networkActors, - NetworkProperties: k.GetNetworkProperties(ctx), - ExecutionFees: k.GetExecutionFees(ctx), - PoorNetworkMessages: k.GetPoorNetworkMessages(ctx), - Proposals: proposals, - Votes: k.GetVotes(ctx), - DataRegistry: k.AllDataRegistry(ctx), - IdentityRecords: k.GetAllIdentityRecords(ctx), - LastIdentityRecordId: k.GetLastIdentityRecordId(ctx), - IdRecordsVerifyRequests: k.GetAllIdRecordsVerifyRequests(ctx), - LastIdRecordVerifyRequestId: k.GetLastIdRecordVerifyRequestId(ctx), - ProposalDurations: k.GetAllProposalDurations(ctx), - } -} +package gov + +import ( + "bytes" + + "github.com/KiraCore/sekai/x/gov/keeper" + "github.com/KiraCore/sekai/x/gov/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func InitGenesis( + ctx sdk.Context, + k keeper.Keeper, + genesisState types.GenesisState, +) error { + k.SetNextRoleId(ctx, genesisState.NextRoleId) + for _, actor := range genesisState.NetworkActors { + k.SaveNetworkActor(ctx, *actor) + for _, role := range actor.Roles { + k.AssignRoleToActor(ctx, *actor, role) + } + for _, perm := range actor.Permissions.Whitelist { + k.SetWhitelistAddressPermKey(ctx, *actor, types.PermValue(perm)) + } + // TODO when we add keeper function for managing blacklist mapping, we can just enable this + // for _, perm := range actor.Permissions.Blacklist { + // k.RemoveWhitelistPermission(ctx, *actor, types.PermValue(perm)) + // } + } + + for _, role := range genesisState.Roles { + k.SetRole(ctx, role) + } + + for roleId, perm := range genesisState.RolePermissions { + for _, white := range perm.Whitelist { + k.WhitelistRolePermission(ctx, roleId, types.PermValue(white)) + } + // TODO when we add keeper function for managing blacklist mapping, we can just enable this + // for _, black := range perm.Blacklist { + // err := k.BlacklistRolePermission(ctx, roleId, types.PermValue(black)) + // if err != nil { + // // TODO: this is fine with current upgrade but from next time, it should panic + // fmt.Println("There was an error blacklisting role permission", err) + // // panic(err) + // } + // } + } + + k.SetNextProposalID(ctx, genesisState.StartingProposalId) + err := k.SetNetworkProperties(ctx, genesisState.NetworkProperties) + if err != nil { + panic(err) + } + + for _, fee := range genesisState.ExecutionFees { + k.SetExecutionFee(ctx, fee) + } + + k.SavePoorNetworkMessages(ctx, genesisState.PoorNetworkMessages) + + for _, proposal := range genesisState.Proposals { + k.SaveProposal(ctx, proposal) + } + + for _, vote := range genesisState.Votes { + k.SaveVote(ctx, vote) + } + + for key, entry := range genesisState.DataRegistry { + if entry == nil { + continue + } + k.UpsertDataRegistryEntry(ctx, key, *entry) + } + + for _, record := range genesisState.IdentityRecords { + k.SetIdentityRecord(ctx, record) + } + for _, request := range genesisState.IdRecordsVerifyRequests { + k.SetIdentityRecordsVerifyRequest(ctx, request) + } + + k.SetLastIdentityRecordId(ctx, genesisState.LastIdentityRecordId) + k.SetLastIdRecordVerifyRequestId(ctx, genesisState.LastIdRecordVerifyRequestId) + + for typeofProposal, duration := range genesisState.ProposalDurations { + err := k.SetProposalDuration(ctx, typeofProposal, duration) + if err != nil { + return nil + } + } + + return nil +} + +// ExportGenesis writes the current store values +// to a genesis file, which can be imported again +// with InitGenesis +func ExportGenesis(ctx sdk.Context, k keeper.Keeper) (data *types.GenesisState) { + rolesIterator := k.IterateRoles(ctx) + defer rolesIterator.Close() + rolePermissions := make(map[uint64]*types.Permissions) + for ; rolesIterator.Valid(); rolesIterator.Next() { + role := sdk.BigEndianToUint64(bytes.TrimPrefix(rolesIterator.Key(), keeper.RolePermissionRegistry)) + perms := k.GetPermissionsFromIterator(rolesIterator) + rolePermissions[role] = &perms + } + + networkActorsIterator := k.GetNetworkActorsIterator(ctx) + defer networkActorsIterator.Close() + networkActors := []*types.NetworkActor{} + for ; networkActorsIterator.Valid(); networkActorsIterator.Next() { + networkActors = append(networkActors, k.GetNetworkActorFromIterator(networkActorsIterator)) + } + + proposals, _ := k.GetProposals(ctx) + + return &types.GenesisState{ + StartingProposalId: k.GetNextProposalID(ctx), + NextRoleId: k.GetNextRoleId(ctx), + Roles: k.GetAllRoles(ctx), + RolePermissions: rolePermissions, + NetworkActors: networkActors, + NetworkProperties: k.GetNetworkProperties(ctx), + ExecutionFees: k.GetExecutionFees(ctx), + PoorNetworkMessages: k.GetPoorNetworkMessages(ctx), + Proposals: proposals, + Votes: k.GetVotes(ctx), + DataRegistry: k.AllDataRegistry(ctx), + IdentityRecords: k.GetAllIdentityRecords(ctx), + LastIdentityRecordId: k.GetLastIdentityRecordId(ctx), + IdRecordsVerifyRequests: k.GetAllIdRecordsVerifyRequests(ctx), + LastIdRecordVerifyRequestId: k.GetLastIdRecordVerifyRequestId(ctx), + ProposalDurations: k.GetAllProposalDurations(ctx), + } +} diff --git a/x/gov/genesis_test.go b/x/gov/genesis_test.go index 3c66694e4..c159726ae 100644 --- a/x/gov/genesis_test.go +++ b/x/gov/genesis_test.go @@ -110,7 +110,8 @@ func TestSimappExportGenesis(t *testing.T) { 62, 63, 64, - 65 + 65, + 66 ] }, "2": { @@ -159,7 +160,28 @@ func TestSimappExportGenesis(t *testing.T) { "min_collective_bond": "100000", "min_collective_bonding_time": "86400", "max_collective_outputs": "10", - "min_collective_claim_period": "14400" + "min_collective_claim_period": "14400", + "validator_recovery_bond": "300000", + "max_annual_inflation": "0.350000000000000000", + "max_proposal_title_size": "128", + "max_proposal_description_size": "1024", + "max_proposal_poll_option_size": "64", + "max_proposal_poll_option_count": "128", + "max_proposal_reference_size": "512", + "max_proposal_checksum_size": "128", + "min_dapp_bond": "1000000", + "max_dapp_bond": "10000000", + "dapp_liquidation_threshold": "0", + "dapp_liquidation_period": "0", + "dapp_bond_duration": "604800", + "dapp_verifier_bond": "0.001000000000000000", + "dapp_auto_denounce_time": "60", + "dapp_mischance_rank_decrease_amount": "1", + "dapp_max_mischance": "10", + "dapp_inactive_rank_decrease_percent": "10", + "dapp_pool_slippage_default": "0.100000000000000000", + "minting_ft_fee": "100000000000000", + "minting_nft_fee": "100000000000000" }, "execution_fees": [ { @@ -313,40 +335,59 @@ func TestExportInitGenesis(t *testing.T) { }, StartingProposalId: 1, NetworkProperties: &types.NetworkProperties{ - MinTxFee: 100, - MaxTxFee: 1000000, - VoteQuorum: 33, - MinimumProposalEndTime: 300, // 300 seconds / 5 mins - ProposalEnactmentTime: 300, // 300 seconds / 5 mins - MinProposalEndBlocks: 2, - MinProposalEnactmentBlocks: 1, - MischanceRankDecreaseAmount: 1, - MaxMischance: 1, - InactiveRankDecreasePercent: sdk.NewDecWithPrec(2, 2), - MinValidators: 1, - PoorNetworkMaxBankSend: 1, - EnableForeignFeePayments: true, - MinIdentityApprovalTip: 200, - UniqueIdentityKeys: "moniker,username", - UbiHardcap: 6000_000, - ValidatorsFeeShare: sdk.NewDecWithPrec(50, 2), // 50% - InflationRate: sdk.NewDecWithPrec(18, 2), // 18% - InflationPeriod: 31557600, // 1 year - UnstakingPeriod: 2629800, // 1 month - MaxDelegators: 100, - MinDelegationPushout: 10, - SlashingPeriod: 3600, - MaxJailedPercentage: sdk.NewDecWithPrec(25, 2), - MaxSlashingPercentage: sdk.NewDecWithPrec(1, 2), - MinCustodyReward: 200, - MaxCustodyBufferSize: 10, - MaxCustodyTxSize: 8192, - AbstentionRankDecreaseAmount: 1, - MaxAbstention: 2, - MinCollectiveBond: 100_000, // in KEX - MinCollectiveBondingTime: 86400, // in seconds - MaxCollectiveOutputs: 10, - MinCollectiveClaimPeriod: 14400, // 4hrs + MinTxFee: 100, + MaxTxFee: 1000000, + VoteQuorum: 33, + MinimumProposalEndTime: 300, // 300 seconds / 5 mins + ProposalEnactmentTime: 300, // 300 seconds / 5 mins + MinProposalEndBlocks: 2, + MinProposalEnactmentBlocks: 1, + MischanceRankDecreaseAmount: 1, + MaxMischance: 1, + InactiveRankDecreasePercent: sdk.NewDecWithPrec(2, 2), + MinValidators: 1, + PoorNetworkMaxBankSend: 1, + EnableForeignFeePayments: true, + MinIdentityApprovalTip: 200, + UniqueIdentityKeys: "moniker,username", + UbiHardcap: 6000_000, + ValidatorsFeeShare: sdk.NewDecWithPrec(50, 2), // 50% + InflationRate: sdk.NewDecWithPrec(18, 2), // 18% + InflationPeriod: 31557600, // 1 year + UnstakingPeriod: 2629800, // 1 month + MaxDelegators: 100, + MinDelegationPushout: 10, + SlashingPeriod: 3600, + MaxJailedPercentage: sdk.NewDecWithPrec(25, 2), + MaxSlashingPercentage: sdk.NewDecWithPrec(1, 2), + MinCustodyReward: 200, + MaxCustodyBufferSize: 10, + MaxCustodyTxSize: 8192, + AbstentionRankDecreaseAmount: 1, + MaxAbstention: 2, + MinCollectiveBond: 100_000, // in KEX + MinCollectiveBondingTime: 86400, // in seconds + MaxCollectiveOutputs: 10, + MinCollectiveClaimPeriod: 14400, // 4hrs + ValidatorRecoveryBond: 300000, // 300k KEX + MaxAnnualInflation: sdk.NewDecWithPrec(35, 2), // 35% + MaxProposalTitleSize: 128, + MaxProposalDescriptionSize: 1024, + MaxProposalPollOptionSize: 64, + MaxProposalPollOptionCount: 128, + MaxProposalReferenceSize: 512, + MaxProposalChecksumSize: 128, + MinDappBond: 1000000, + MaxDappBond: 10000000, + DappBondDuration: 604800, + DappVerifierBond: sdk.NewDecWithPrec(1, 3), //0.1% + DappAutoDenounceTime: 60, // 60s + DappMischanceRankDecreaseAmount: 1, + DappMaxMischance: 10, + DappInactiveRankDecreasePercent: 10, + DappPoolSlippageDefault: sdk.NewDecWithPrec(1, 1), // 10% + MintingFtFee: 100_000_000_000_000, + MintingNftFee: 100_000_000_000_000, }, ExecutionFees: []types.ExecutionFee{ { @@ -439,7 +480,28 @@ func TestExportInitGenesis(t *testing.T) { "min_collective_bond": "100000", "min_collective_bonding_time": "86400", "max_collective_outputs": "10", - "min_collective_claim_period": "14400" + "min_collective_claim_period": "14400", + "validator_recovery_bond": "300000", + "max_annual_inflation": "0.350000000000000000", + "max_proposal_title_size": "128", + "max_proposal_description_size": "1024", + "max_proposal_poll_option_size": "64", + "max_proposal_poll_option_count": "128", + "max_proposal_reference_size": "512", + "max_proposal_checksum_size": "128", + "min_dapp_bond": "1000000", + "max_dapp_bond": "10000000", + "dapp_liquidation_threshold": "0", + "dapp_liquidation_period": "0", + "dapp_bond_duration": "604800", + "dapp_verifier_bond": "0.001000000000000000", + "dapp_auto_denounce_time": "60", + "dapp_mischance_rank_decrease_amount": "1", + "dapp_max_mischance": "10", + "dapp_inactive_rank_decrease_percent": "10", + "dapp_pool_slippage_default": "0.100000000000000000", + "minting_ft_fee": "100000000000000", + "minting_nft_fee": "100000000000000" }, "execution_fees": [ { diff --git a/x/gov/handler.go b/x/gov/handler.go index db1df97cc..21eb5ac70 100644 --- a/x/gov/handler.go +++ b/x/gov/handler.go @@ -1,95 +1,103 @@ -package gov - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/errors" - - "github.com/KiraCore/sekai/x/gov/keeper" - "github.com/KiraCore/sekai/x/gov/types" -) - -func NewHandler(ck keeper.Keeper) sdk.Handler { - msgServer := keeper.NewMsgServerImpl(ck) - - return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { - ctx = ctx.WithEventManager(sdk.NewEventManager()) - - switch msg := msg.(type) { - case *types.MsgSetNetworkProperties: - res, err := msgServer.SetNetworkProperties(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - case *types.MsgSetExecutionFee: - res, err := msgServer.SetExecutionFee(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - - // Permission Related - case *types.MsgWhitelistPermissions: - res, err := msgServer.WhitelistPermissions(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - case *types.MsgRemoveWhitelistedPermissions: - res, err := msgServer.RemoveWhitelistedPermissions(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - case *types.MsgBlacklistPermissions: - res, err := msgServer.BlacklistPermissions(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - case *types.MsgRemoveBlacklistedPermissions: - res, err := msgServer.RemoveBlacklistedPermissions(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - - // Councilor Related - case *types.MsgClaimCouncilor: - res, err := msgServer.ClaimCouncilor(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - - // Role Related - case *types.MsgWhitelistRolePermission: - res, err := msgServer.WhitelistRolePermission(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - case *types.MsgBlacklistRolePermission: - res, err := msgServer.BlacklistRolePermission(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - case *types.MsgRemoveWhitelistRolePermission: - res, err := msgServer.RemoveWhitelistRolePermission(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - case *types.MsgRemoveBlacklistRolePermission: - res, err := msgServer.RemoveBlacklistRolePermission(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - case *types.MsgCreateRole: - res, err := msgServer.CreateRole(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - case *types.MsgAssignRole: - res, err := msgServer.AssignRole(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - case *types.MsgRemoveRole: - res, err := msgServer.RemoveRole(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - - // Proposal related - case *types.MsgSubmitProposal: - res, err := msgServer.SubmitProposal(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - case *types.MsgVoteProposal: - res, err := msgServer.VoteProposal(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - - // identity registrar related - case *types.MsgRegisterIdentityRecords: - res, err := msgServer.RegisterIdentityRecords(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - case *types.MsgDeleteIdentityRecords: - res, err := msgServer.DeleteIdentityRecords(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - case *types.MsgRequestIdentityRecordsVerify: - res, err := msgServer.RequestIdentityRecordsVerify(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - case *types.MsgHandleIdentityRecordsVerifyRequest: - res, err := msgServer.HandleIdentityRecordsVerifyRequest(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - case *types.MsgCancelIdentityRecordsVerifyRequest: - res, err := msgServer.CancelIdentityRecordsVerifyRequest(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - default: - return nil, errors.Wrapf(errors.ErrUnknownRequest, "unrecognized %s message type: %T", types.ModuleName, msg) - } - } -} +package gov + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/errors" + + "github.com/KiraCore/sekai/x/gov/keeper" + "github.com/KiraCore/sekai/x/gov/types" +) + +func NewHandler(ck keeper.Keeper) sdk.Handler { + msgServer := keeper.NewMsgServerImpl(ck) + + return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { + ctx = ctx.WithEventManager(sdk.NewEventManager()) + + switch msg := msg.(type) { + case *types.MsgSetNetworkProperties: + res, err := msgServer.SetNetworkProperties(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + case *types.MsgSetExecutionFee: + res, err := msgServer.SetExecutionFee(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + + // Permission Related + case *types.MsgWhitelistPermissions: + res, err := msgServer.WhitelistPermissions(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + case *types.MsgRemoveWhitelistedPermissions: + res, err := msgServer.RemoveWhitelistedPermissions(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + case *types.MsgBlacklistPermissions: + res, err := msgServer.BlacklistPermissions(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + case *types.MsgRemoveBlacklistedPermissions: + res, err := msgServer.RemoveBlacklistedPermissions(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + + // Councilor Related + case *types.MsgClaimCouncilor: + res, err := msgServer.ClaimCouncilor(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + + // Role Related + case *types.MsgWhitelistRolePermission: + res, err := msgServer.WhitelistRolePermission(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + case *types.MsgBlacklistRolePermission: + res, err := msgServer.BlacklistRolePermission(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + case *types.MsgRemoveWhitelistRolePermission: + res, err := msgServer.RemoveWhitelistRolePermission(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + case *types.MsgRemoveBlacklistRolePermission: + res, err := msgServer.RemoveBlacklistRolePermission(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + case *types.MsgCreateRole: + res, err := msgServer.CreateRole(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + case *types.MsgAssignRole: + res, err := msgServer.AssignRole(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + case *types.MsgRemoveRole: + res, err := msgServer.RemoveRole(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + + // Proposal related + case *types.MsgSubmitProposal: + res, err := msgServer.SubmitProposal(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + case *types.MsgVoteProposal: + res, err := msgServer.VoteProposal(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + + // Poll Proposal related + case *types.MsgPollCreate: + res, err := msgServer.PollCreate(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + case *types.MsgPollVote: + res, err := msgServer.PollVote(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + + // identity registrar related + case *types.MsgRegisterIdentityRecords: + res, err := msgServer.RegisterIdentityRecords(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + case *types.MsgDeleteIdentityRecords: + res, err := msgServer.DeleteIdentityRecords(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + case *types.MsgRequestIdentityRecordsVerify: + res, err := msgServer.RequestIdentityRecordsVerify(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + case *types.MsgHandleIdentityRecordsVerifyRequest: + res, err := msgServer.HandleIdentityRecordsVerifyRequest(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + case *types.MsgCancelIdentityRecordsVerifyRequest: + res, err := msgServer.CancelIdentityRecordsVerifyRequest(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + default: + return nil, errors.Wrapf(errors.ErrUnknownRequest, "unrecognized %s message type: %T", types.ModuleName, msg) + } + } +} diff --git a/x/gov/handler_test.go b/x/gov/handler_test.go index 24ddae204..a98c78086 100644 --- a/x/gov/handler_test.go +++ b/x/gov/handler_test.go @@ -1,1959 +1,1960 @@ -package gov_test - -import ( - "fmt" - "os" - "testing" - "time" - - "github.com/KiraCore/sekai/app" - simapp "github.com/KiraCore/sekai/app" - kiratypes "github.com/KiraCore/sekai/types" - "github.com/KiraCore/sekai/x/gov" - "github.com/KiraCore/sekai/x/gov/types" - tokenstypes "github.com/KiraCore/sekai/x/tokens/types" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/gogo/protobuf/proto" - "github.com/stretchr/testify/require" - tmproto "github.com/tendermint/tendermint/proto/tendermint/types" -) - -func TestMain(m *testing.M) { - app.SetConfig() - os.Exit(m.Run()) -} - -// When a network actor has not been saved before, it creates one with default params -// and sets the permissions. -func TestHandler_MsgWhitelistPermissions_ActorDoesNotExist(t *testing.T) { - proposerAddr, err := sdk.AccAddressFromBech32("kira1alzyfq40zjsveat87jlg8jxetwqmr0a29sgd0f") - require.NoError(t, err) - - addr, err := sdk.AccAddressFromBech32("kira15ky9du8a2wlstz6fpx3p4mqpjyrm5cgqzp4f3d") - require.NoError(t, err) - - tests := []struct { - name string - msg sdk.Msg - checkWhitelisted bool - }{ - { - "Msg Whitelist Permissions", - &types.MsgWhitelistPermissions{ - Proposer: proposerAddr, - Address: addr, - Permission: uint32(types.PermClaimValidator), - }, - true, - }, - { - "Msg Blacklist Permissions", - &types.MsgBlacklistPermissions{ - Proposer: proposerAddr, - Address: addr, - Permission: uint32(types.PermClaimValidator), - }, - false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - app := simapp.Setup(false) - ctx := app.NewContext(false, tmproto.Header{}) - - err := setPermissionToAddr(t, app, ctx, proposerAddr, types.PermSetPermissions) - require.NoError(t, err) - - handler := gov.NewHandler(app.CustomGovKeeper) - _, err = handler(ctx, tt.msg) - require.NoError(t, err) - - actor, found := app.CustomGovKeeper.GetNetworkActorByAddress(ctx, addr) - require.True(t, found) - - if tt.checkWhitelisted { - require.True(t, actor.Permissions.IsWhitelisted(types.PermClaimValidator)) - } else { - require.True(t, actor.Permissions.IsBlacklisted(types.PermClaimValidator)) - } - }) - } -} - -// When a network actor has already permissions it just appends the permission. -func TestNewHandler_SetPermissions_ActorWithPerms(t *testing.T) { - addr, err := sdk.AccAddressFromBech32("kira15ky9du8a2wlstz6fpx3p4mqpjyrm5cgqzp4f3d") - require.NoError(t, err) - - proposerAddr, err := sdk.AccAddressFromBech32("kira1alzyfq40zjsveat87jlg8jxetwqmr0a29sgd0f") - require.NoError(t, err) - - tests := []struct { - name string - msg sdk.Msg - checkWhitelisted bool - }{ - { - name: "actor with Whitelist Permissions", - msg: &types.MsgWhitelistPermissions{ - Proposer: proposerAddr, - Address: addr, - Permission: uint32(types.PermClaimValidator), - }, - checkWhitelisted: true, - }, - { - name: "actor with Blacklist Permissions", - msg: &types.MsgBlacklistPermissions{ - Proposer: proposerAddr, - Address: addr, - Permission: uint32(types.PermClaimValidator), - }, - checkWhitelisted: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - app := simapp.Setup(false) - ctx := app.NewContext(false, tmproto.Header{}) - - err := setPermissionToAddr(t, app, ctx, proposerAddr, types.PermSetPermissions) - require.NoError(t, err) - - // Add some perms before to the actor. - actor := types.NewDefaultActor(addr) - if tt.checkWhitelisted { - err = actor.Permissions.AddToWhitelist(types.PermSetPermissions) - } else { - err = actor.Permissions.AddToBlacklist(types.PermSetPermissions) - } - require.NoError(t, err) - - app.CustomGovKeeper.SaveNetworkActor(ctx, actor) - - // Call the handler to add some permissions. - handler := gov.NewHandler(app.CustomGovKeeper) - _, err = handler(ctx, tt.msg) - require.NoError(t, err) - - actor, found := app.CustomGovKeeper.GetNetworkActorByAddress(ctx, addr) - require.True(t, found) - - if tt.checkWhitelisted { - require.True(t, actor.Permissions.IsWhitelisted(types.PermClaimValidator)) - require.True(t, actor.Permissions.IsWhitelisted(types.PermSetPermissions)) // This permission was already set before callid add permission. - } else { - require.True(t, actor.Permissions.IsBlacklisted(types.PermClaimValidator)) - require.True(t, actor.Permissions.IsBlacklisted(types.PermSetPermissions)) // This permission was already set before callid add permission. - } - }) - } -} - -func TestNewHandler_SetPermissionsWithoutSetPermissions(t *testing.T) { - addr, err := sdk.AccAddressFromBech32("kira15ky9du8a2wlstz6fpx3p4mqpjyrm5cgqzp4f3d") - require.NoError(t, err) - - proposerAddr, err := sdk.AccAddressFromBech32("kira1alzyfq40zjsveat87jlg8jxetwqmr0a29sgd0f") - require.NoError(t, err) - - tests := []struct { - name string - msg sdk.Msg - }{ - { - name: "MsgWhitelist", - msg: &types.MsgWhitelistPermissions{ - Proposer: proposerAddr, - Address: addr, - Permission: uint32(types.PermClaimValidator), - }, - }, - { - name: "MsgBlacklist", - msg: &types.MsgBlacklistPermissions{ - Proposer: proposerAddr, - Address: addr, - Permission: uint32(types.PermClaimValidator), - }, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - app := simapp.Setup(false) - ctx := app.NewContext(false, tmproto.Header{}) - - handler := gov.NewHandler(app.CustomGovKeeper) - _, err = handler(ctx, tt.msg) - require.EqualError(t, err, "PermSetPermissions || (ClaimValidatorPermission && ClaimValidatorPermMsg): not enough permissions") - }) - } -} - -func TestNewHandler_SetPermissions_ProposerHasRoleSudo(t *testing.T) { - addr, err := sdk.AccAddressFromBech32("kira15ky9du8a2wlstz6fpx3p4mqpjyrm5cgqzp4f3d") - require.NoError(t, err) - - proposerAddr, err := sdk.AccAddressFromBech32("kira1alzyfq40zjsveat87jlg8jxetwqmr0a29sgd0f") - require.NoError(t, err) - - tests := []struct { - name string - msg sdk.Msg - checkWhitelist bool - }{ - { - name: "MsgWhitelist", - msg: &types.MsgWhitelistPermissions{ - Proposer: proposerAddr, - Address: addr, - Permission: uint32(types.PermClaimValidator), - }, - checkWhitelist: true, - }, - { - name: "MsgBlacklist", - msg: &types.MsgBlacklistPermissions{ - Proposer: proposerAddr, - Address: addr, - Permission: uint32(types.PermClaimValidator), - }, - checkWhitelist: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - app := simapp.Setup(false) - ctx := app.NewContext(false, tmproto.Header{}) - - // First we set Role Sudo to proposer Actor - proposerActor := types.NewDefaultActor(proposerAddr) - proposerActor.SetRole(types.RoleSudo) - require.NoError(t, err) - app.CustomGovKeeper.SaveNetworkActor(ctx, proposerActor) - - handler := gov.NewHandler(app.CustomGovKeeper) - _, err = handler(ctx, tt.msg) - require.NoError(t, err) - - actor, found := app.CustomGovKeeper.GetNetworkActorByAddress(ctx, addr) - require.True(t, found) - - if tt.checkWhitelist { - require.True(t, actor.Permissions.IsWhitelisted(types.PermClaimValidator)) - } else { - require.True(t, actor.Permissions.IsBlacklisted(types.PermClaimValidator)) - } - }) - } -} - -func TestNewHandler_SetNetworkProperties(t *testing.T) { - changeFeeAddr, err := sdk.AccAddressFromBech32("kira15ky9du8a2wlstz6fpx3p4mqpjyrm5cgqzp4f3d") - require.NoError(t, err) - - sudoAddr, err := sdk.AccAddressFromBech32("kira1alzyfq40zjsveat87jlg8jxetwqmr0a29sgd0f") - require.NoError(t, err) - - tests := []struct { - name string - msg sdk.Msg - desiredErr string - }{ - { - name: "Success run with ChangeTxFee permission", - msg: &types.MsgSetNetworkProperties{ - NetworkProperties: &types.NetworkProperties{ - MinTxFee: 100, - MaxTxFee: 1000, - }, - Proposer: changeFeeAddr, - }, - desiredErr: "", - }, - { - name: "Failure run without ChangeTxFee permission", - msg: &types.MsgSetNetworkProperties{ - NetworkProperties: &types.NetworkProperties{ - MinTxFee: 100, - MaxTxFee: 1000, - }, - Proposer: sudoAddr, - }, - desiredErr: "not enough permissions", - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - app := simapp.Setup(false) - ctx := app.NewContext(false, tmproto.Header{}) - // First we set Role Sudo to proposer Actor - proposerActor := types.NewDefaultActor(sudoAddr) - proposerActor.SetRole(types.RoleSudo) - app.CustomGovKeeper.SaveNetworkActor(ctx, proposerActor) - - handler := gov.NewHandler(app.CustomGovKeeper) - - // set change fee permission to addr - _, err = handler(ctx, &types.MsgWhitelistPermissions{ - Proposer: sudoAddr, - Address: changeFeeAddr, - Permission: uint32(types.PermChangeTxFee), - }) - require.NoError(t, err) - - _, err = handler(ctx, tt.msg) - if tt.desiredErr == "" { - require.NoError(t, err) - } else { - require.Error(t, err) - require.Contains(t, err.Error(), tt.desiredErr) - } - }) - } -} - -func TestNewHandler_SetExecutionFee(t *testing.T) { - execFeeSetAddr, err := sdk.AccAddressFromBech32("kira15ky9du8a2wlstz6fpx3p4mqpjyrm5cgqzp4f3d") - require.NoError(t, err) - - sudoAddr, err := sdk.AccAddressFromBech32("kira1alzyfq40zjsveat87jlg8jxetwqmr0a29sgd0f") - require.NoError(t, err) - - tests := []struct { - name string - msg types.MsgSetExecutionFee - desiredErr string - }{ - { - name: "Success run with ChangeTxFee permission", - msg: types.MsgSetExecutionFee{ - TransactionType: "network-properties", - ExecutionFee: 10000, - FailureFee: 1000, - Timeout: 1, - DefaultParameters: 2, - Proposer: execFeeSetAddr, - }, - desiredErr: "", - }, - { - name: "Success run without ChangeTxFee permission", - msg: types.MsgSetExecutionFee{ - TransactionType: "network-properties-2", - ExecutionFee: 10000, - FailureFee: 1000, - Timeout: 1, - DefaultParameters: 2, - Proposer: sudoAddr, - }, - desiredErr: "PermChangeTxFee: not enough permissions", - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - app := simapp.Setup(false) - ctx := app.NewContext(false, tmproto.Header{}) - // First we set Role Sudo to proposer Actor - proposerActor := types.NewDefaultActor(sudoAddr) - proposerActor.SetRole(types.RoleSudo) - require.NoError(t, err) - app.CustomGovKeeper.SaveNetworkActor(ctx, proposerActor) - - handler := gov.NewHandler(app.CustomGovKeeper) - - // set change fee permission to addr - _, err = handler(ctx, &types.MsgWhitelistPermissions{ - Proposer: sudoAddr, - Address: execFeeSetAddr, - Permission: uint32(types.PermChangeTxFee), - }) - require.NoError(t, err) - - _, err = handler(ctx, &tt.msg) - if tt.desiredErr == "" { - require.NoError(t, err) - execFee := app.CustomGovKeeper.GetExecutionFee(ctx, tt.msg.TransactionType) - require.Equal(t, tt.msg.TransactionType, execFee.TransactionType) - require.Equal(t, tt.msg.ExecutionFee, execFee.ExecutionFee) - require.Equal(t, tt.msg.FailureFee, execFee.FailureFee) - require.Equal(t, tt.msg.Timeout, execFee.Timeout) - require.Equal(t, tt.msg.DefaultParameters, execFee.DefaultParameters) - } else { - require.Error(t, err) - require.Contains(t, err.Error(), tt.desiredErr) - } - }) - } -} - -func TestHandler_ClaimCouncilor_Fails(t *testing.T) { - addr, err := sdk.AccAddressFromBech32("kira15ky9du8a2wlstz6fpx3p4mqpjyrm5cgqzp4f3d") - require.NoError(t, err) - - tests := []struct { - name string - msg sdk.Msg - expectedErr error - }{ - { - name: "not enough permissions", - msg: &types.MsgClaimCouncilor{ - Moniker: "", - Address: addr, - }, - expectedErr: fmt.Errorf("PermClaimCouncilor: not enough permissions"), - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - app := simapp.Setup(false) - ctx := app.NewContext(false, tmproto.Header{}) - - handler := gov.NewHandler(app.CustomGovKeeper) - _, err := handler(ctx, tt.msg) - require.EqualError(t, err, tt.expectedErr.Error()) - }) - } -} - -func TestHandler_ClaimCouncilor_HappyPath(t *testing.T) { - addr, err := sdk.AccAddressFromBech32("kira15ky9du8a2wlstz6fpx3p4mqpjyrm5cgqzp4f3d") - require.NoError(t, err) - - tests := []struct { - name string - msg *types.MsgClaimCouncilor - }{ - { - name: "all correct", - msg: &types.MsgClaimCouncilor{ - Address: addr, - }, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - app := simapp.Setup(false) - ctx := app.NewContext(false, tmproto.Header{}) - - err = setPermissionToAddr(t, app, ctx, addr, types.PermClaimCouncilor) - require.NoError(t, err) - - handler := gov.NewHandler(app.CustomGovKeeper) - _, err := handler(ctx, tt.msg) - require.NoError(t, err) - - expectedCouncilor := types.NewCouncilor( - tt.msg.Address, - types.CouncilorActive, - ) - - councilor, found := app.CustomGovKeeper.GetCouncilor(ctx, addr) - require.True(t, found) - - require.Equal(t, expectedCouncilor, councilor) - }) - } -} - -func TestHandler_WhitelistRolePermissions_Errors(t *testing.T) { - addr, err := sdk.AccAddressFromBech32("kira15ky9du8a2wlstz6fpx3p4mqpjyrm5cgqzp4f3d") - require.NoError(t, err) - - tests := []struct { - name string - msg *types.MsgWhitelistRolePermission - preparePerms func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) - expectedErr error - }{ - { - name: "address without SetPermissions perm", - msg: types.NewMsgWhitelistRolePermission( - addr, - fmt.Sprintf("%d", types.RoleValidator), - uint32(types.PermSetPermissions), - ), - preparePerms: func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) { - return - }, - expectedErr: fmt.Errorf("%s: not enough permissions", types.PermUpsertRole.String()), - }, - { - name: "role does not exist", - msg: types.NewMsgWhitelistRolePermission( - addr, - "10000", - 1, - ), - preparePerms: func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) { - err2 := setPermissionToAddr(t, app, ctx, addr, types.PermUpsertRole) - require.NoError(t, err2) - }, - expectedErr: fmt.Errorf("role does not exist"), - }, - { - name: "permission is blacklisted", - msg: types.NewMsgWhitelistRolePermission( - addr, - fmt.Sprintf("%d", types.RoleValidator), - uint32(types.PermSetPermissions), - ), - preparePerms: func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) { - err2 := setPermissionToAddr(t, app, ctx, addr, types.PermUpsertRole) - require.NoError(t, err2) - - _, found := app.CustomGovKeeper.GetPermissionsForRole(ctx, types.RoleValidator) - require.True(t, found) - - err2 = app.CustomGovKeeper.BlacklistRolePermission(ctx, types.RoleValidator, types.PermSetPermissions) - require.NoError(t, err2) - }, - expectedErr: fmt.Errorf("permission is blacklisted"), - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - app := simapp.Setup(false) - ctx := app.NewContext(false, tmproto.Header{}) - - tt.preparePerms(t, app, ctx) - - handler := gov.NewHandler(app.CustomGovKeeper) - _, err := handler(ctx, tt.msg) - require.EqualError(t, err, tt.expectedErr.Error()) - }) - } -} - -func TestHandler_WhitelistRolePermissions(t *testing.T) { - addr, err := sdk.AccAddressFromBech32("kira15ky9du8a2wlstz6fpx3p4mqpjyrm5cgqzp4f3d") - require.NoError(t, err) - - app := simapp.Setup(false) - ctx := app.NewContext(false, tmproto.Header{}) - - err = setPermissionToAddr(t, app, ctx, addr, types.PermUpsertRole) - require.NoError(t, err) - - perms, found := app.CustomGovKeeper.GetPermissionsForRole(ctx, types.RoleValidator) - require.True(t, found) - require.False(t, perms.IsWhitelisted(types.PermSetPermissions)) - - msg := types.NewMsgWhitelistRolePermission( - addr, - fmt.Sprintf("%d", types.RoleValidator), - uint32(types.PermSetPermissions), - ) - - handler := gov.NewHandler(app.CustomGovKeeper) - _, err = handler(ctx, msg) - require.NoError(t, err) - - perms, found = app.CustomGovKeeper.GetPermissionsForRole(ctx, types.RoleValidator) - require.True(t, found) - require.True(t, perms.IsWhitelisted(types.PermSetPermissions)) -} - -func TestHandler_BlacklistRolePermissions_Errors(t *testing.T) { - addr, err := sdk.AccAddressFromBech32("kira15ky9du8a2wlstz6fpx3p4mqpjyrm5cgqzp4f3d") - require.NoError(t, err) - - tests := []struct { - name string - msg *types.MsgBlacklistRolePermission - preparePerms func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) - expectedErr error - }{ - { - name: "address without SetPermissions perm", - msg: types.NewMsgBlacklistRolePermission( - addr, - fmt.Sprintf("%d", types.RoleValidator), - uint32(types.PermSetPermissions), - ), - preparePerms: func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) {}, - expectedErr: fmt.Errorf("%s: not enough permissions", types.PermUpsertRole.String()), - }, - { - name: "role does not exist", - msg: types.NewMsgBlacklistRolePermission( - addr, - "10000", - 1, - ), - preparePerms: func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) { - err2 := setPermissionToAddr(t, app, ctx, addr, types.PermUpsertRole) - require.NoError(t, err2) - }, - expectedErr: fmt.Errorf("role does not exist"), - }, - { - name: "permission is whitelisted", - msg: types.NewMsgBlacklistRolePermission( - addr, - fmt.Sprintf("%d", types.RoleValidator), - uint32(types.PermSetPermissions), - ), - preparePerms: func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) { - err2 := setPermissionToAddr(t, app, ctx, addr, types.PermUpsertRole) - require.NoError(t, err2) - - _, found := app.CustomGovKeeper.GetPermissionsForRole(ctx, types.RoleValidator) - require.True(t, found) - - err2 = app.CustomGovKeeper.WhitelistRolePermission(ctx, types.RoleValidator, types.PermSetPermissions) - require.NoError(t, err2) - }, - expectedErr: fmt.Errorf("permission is whitelisted"), - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - app := simapp.Setup(false) - ctx := app.NewContext(false, tmproto.Header{}) - - tt.preparePerms(t, app, ctx) - - handler := gov.NewHandler(app.CustomGovKeeper) - _, err := handler(ctx, tt.msg) - require.EqualError(t, err, tt.expectedErr.Error()) - }) - } -} - -func TestHandler_BlacklistRolePermissions(t *testing.T) { - addr, err := sdk.AccAddressFromBech32("kira15ky9du8a2wlstz6fpx3p4mqpjyrm5cgqzp4f3d") - require.NoError(t, err) - - app := simapp.Setup(false) - ctx := app.NewContext(false, tmproto.Header{}) - - err = setPermissionToAddr(t, app, ctx, addr, types.PermUpsertRole) - require.NoError(t, err) - - perms, found := app.CustomGovKeeper.GetPermissionsForRole(ctx, types.RoleValidator) - require.True(t, found) - require.False(t, perms.IsBlacklisted(types.PermSetPermissions)) - - msg := types.NewMsgBlacklistRolePermission( - addr, - fmt.Sprintf("%d", types.RoleValidator), - uint32(types.PermSetPermissions), - ) - - handler := gov.NewHandler(app.CustomGovKeeper) - _, err = handler(ctx, msg) - require.NoError(t, err) - - perms, found = app.CustomGovKeeper.GetPermissionsForRole(ctx, types.RoleValidator) - require.True(t, found) - require.True(t, perms.IsBlacklisted(types.PermSetPermissions)) -} - -func TestHandler_RemoveWhitelistRolePermissions_Errors(t *testing.T) { - addr, err := sdk.AccAddressFromBech32("kira15ky9du8a2wlstz6fpx3p4mqpjyrm5cgqzp4f3d") - require.NoError(t, err) - - tests := []struct { - name string - msg *types.MsgRemoveWhitelistRolePermission - preparePerms func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) - expectedErr error - }{ - { - name: "address without SetPermissions perm", - msg: types.NewMsgRemoveWhitelistRolePermission( - addr, - fmt.Sprintf("%d", types.RoleValidator), - uint32(types.PermSetPermissions), - ), - preparePerms: func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) {}, - expectedErr: fmt.Errorf("%s: not enough permissions", types.PermUpsertRole.String()), - }, - { - name: "role does not exist", - msg: types.NewMsgRemoveWhitelistRolePermission( - addr, - "10000", - 1, - ), - preparePerms: func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) { - err2 := setPermissionToAddr(t, app, ctx, addr, types.PermUpsertRole) - require.NoError(t, err2) - }, - expectedErr: fmt.Errorf("role does not exist"), - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - app := simapp.Setup(false) - ctx := app.NewContext(false, tmproto.Header{}) - - tt.preparePerms(t, app, ctx) - - handler := gov.NewHandler(app.CustomGovKeeper) - _, err := handler(ctx, tt.msg) - require.EqualError(t, err, tt.expectedErr.Error()) - }) - } -} - -func TestHandler_RemoveWhitelistRolePermissions(t *testing.T) { - addr, err := sdk.AccAddressFromBech32("kira15ky9du8a2wlstz6fpx3p4mqpjyrm5cgqzp4f3d") - require.NoError(t, err) - - app := simapp.Setup(false) - ctx := app.NewContext(false, tmproto.Header{}) - - err = setPermissionToAddr(t, app, ctx, addr, types.PermUpsertRole) - require.NoError(t, err) - - perms, found := app.CustomGovKeeper.GetPermissionsForRole(ctx, types.RoleValidator) - require.True(t, found) - require.True(t, perms.IsWhitelisted(types.PermClaimValidator)) - - msg := types.NewMsgRemoveWhitelistRolePermission( - addr, - fmt.Sprintf("%d", types.RoleValidator), - uint32(types.PermClaimValidator), - ) - - handler := gov.NewHandler(app.CustomGovKeeper) - _, err = handler(ctx, msg) - require.NoError(t, err) - - perms, found = app.CustomGovKeeper.GetPermissionsForRole(ctx, types.RoleValidator) - require.True(t, found) - require.False(t, perms.IsWhitelisted(types.PermClaimValidator)) -} - -func TestHandler_RemoveBlacklistRolePermissions_Errors(t *testing.T) { - addr, err := sdk.AccAddressFromBech32("kira15ky9du8a2wlstz6fpx3p4mqpjyrm5cgqzp4f3d") - require.NoError(t, err) - - tests := []struct { - name string - msg *types.MsgRemoveBlacklistRolePermission - preparePerms func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) - expectedErr error - }{ - { - name: "address without SetPermissions perm", - msg: types.NewMsgRemoveBlacklistRolePermission( - addr, - fmt.Sprintf("%d", types.RoleValidator), - uint32(types.PermSetPermissions), - ), - preparePerms: func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) {}, - expectedErr: fmt.Errorf("%s: not enough permissions", types.PermUpsertRole.String()), - }, - { - name: "role does not exist", - msg: types.NewMsgRemoveBlacklistRolePermission( - addr, - "10000", - 1, - ), - preparePerms: func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) { - err2 := setPermissionToAddr(t, app, ctx, addr, types.PermUpsertRole) - require.NoError(t, err2) - }, - expectedErr: fmt.Errorf("role does not exist"), - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - app := simapp.Setup(false) - ctx := app.NewContext(false, tmproto.Header{}) - - tt.preparePerms(t, app, ctx) - - handler := gov.NewHandler(app.CustomGovKeeper) - _, err := handler(ctx, tt.msg) - require.EqualError(t, err, tt.expectedErr.Error()) - }) - } -} - -func TestHandler_RemoveBlacklistRolePermissions(t *testing.T) { - addr, err := sdk.AccAddressFromBech32("kira15ky9du8a2wlstz6fpx3p4mqpjyrm5cgqzp4f3d") - require.NoError(t, err) - - app := simapp.Setup(false) - ctx := app.NewContext(false, tmproto.Header{}) - - err = setPermissionToAddr(t, app, ctx, addr, types.PermUpsertRole) - require.NoError(t, err) - - _, found := app.CustomGovKeeper.GetPermissionsForRole(ctx, types.RoleValidator) - require.True(t, found) - - // Set some blacklist value - err = app.CustomGovKeeper.BlacklistRolePermission(ctx, types.RoleValidator, types.PermClaimCouncilor) - require.NoError(t, err) - - // Check if it is blacklisted. - perms, found := app.CustomGovKeeper.GetPermissionsForRole(ctx, types.RoleValidator) - require.True(t, found) - require.True(t, perms.IsBlacklisted(types.PermClaimCouncilor)) - - msg := types.NewMsgRemoveBlacklistRolePermission( - addr, - fmt.Sprintf("%d", types.RoleValidator), - uint32(types.PermClaimCouncilor), - ) - - handler := gov.NewHandler(app.CustomGovKeeper) - _, err = handler(ctx, msg) - require.NoError(t, err) - - perms, found = app.CustomGovKeeper.GetPermissionsForRole(ctx, types.RoleValidator) - require.True(t, found) - require.False(t, perms.IsBlacklisted(types.PermClaimCouncilor)) -} - -func TestHandler_CreateRole_Errors(t *testing.T) { - addr, err := sdk.AccAddressFromBech32("kira15ky9du8a2wlstz6fpx3p4mqpjyrm5cgqzp4f3d") - require.NoError(t, err) - - tests := []struct { - name string - msg *types.MsgCreateRole - preparePerms func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) - expectedErr error - }{ - { - "fails when no perms", - types.NewMsgCreateRole( - addr, - "role10", - "role10desc", - ), - func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) {}, - fmt.Errorf("PermUpsertRole: not enough permissions"), - }, - { - "fails when role already exists", - types.NewMsgCreateRole( - addr, - "role1234", - "role1234desc", - ), - func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) { - err2 := setPermissionToAddr(t, app, ctx, addr, types.PermUpsertRole) - require.NoError(t, err2) - app.CustomGovKeeper.CreateRole(ctx, "role1234", "role1234desc") - }, - fmt.Errorf("role already exist"), - }, - } - - for _, tt := range tests { - app := simapp.Setup(false) - ctx := app.NewContext(false, tmproto.Header{}) - - tt.preparePerms(t, app, ctx) - - handler := gov.NewHandler(app.CustomGovKeeper) - _, err := handler(ctx, tt.msg) - require.EqualError(t, err, tt.expectedErr.Error()) - } -} - -func TestHandler_CreateRole(t *testing.T) { - addr, err := sdk.AccAddressFromBech32("kira15ky9du8a2wlstz6fpx3p4mqpjyrm5cgqzp4f3d") - require.NoError(t, err) - - app := simapp.Setup(false) - ctx := app.NewContext(false, tmproto.Header{}) - - err = setPermissionToAddr(t, app, ctx, addr, types.PermUpsertRole) - require.NoError(t, err) - - _, found := app.CustomGovKeeper.GetPermissionsForRole(ctx, 1234) - require.False(t, found) - - handler := gov.NewHandler(app.CustomGovKeeper) - _, err = handler(ctx, types.NewMsgCreateRole( - addr, - "role1234", - "role1234desc", - )) - require.NoError(t, err) - - _, err = app.CustomGovKeeper.GetRoleBySid(ctx, "role1234") - require.NoError(t, err) -} - -func TestHandler_AssignRole_Errors(t *testing.T) { - proposerAddr, err := sdk.AccAddressFromBech32("kira1alzyfq40zjsveat87jlg8jxetwqmr0a29sgd0f") - require.NoError(t, err) - - addr, err := sdk.AccAddressFromBech32("kira15ky9du8a2wlstz6fpx3p4mqpjyrm5cgqzp4f3d") - require.NoError(t, err) - - tests := []struct { - name string - msg *types.MsgAssignRole - preparePerms func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) - expectedErr error - }{ - { - "fails when no perms", - types.NewMsgAssignRole( - proposerAddr, addr, 3, - ), - func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) {}, - fmt.Errorf("%s: not enough permissions", types.PermUpsertRole.String()), - }, - { - "fails when role does not exist", - types.NewMsgAssignRole( - proposerAddr, addr, 3, - ), - func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) { - err2 := setPermissionToAddr(t, app, ctx, proposerAddr, types.PermUpsertRole) - require.NoError(t, err2) - }, - types.ErrRoleDoesNotExist, - }, - { - "role already assigned", - types.NewMsgAssignRole( - proposerAddr, addr, 3, - ), - func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) { - err2 := setPermissionToAddr(t, app, ctx, proposerAddr, types.PermUpsertRole) - require.NoError(t, err2) - - app.CustomGovKeeper.SetRole(ctx, types.Role{ - Id: 3, - Sid: "3", - Description: "3", - }) - err2 = app.CustomGovKeeper.WhitelistRolePermission(ctx, 3, types.PermClaimValidator) - require.NoError(t, err2) - - networkActor := types.NewDefaultActor(addr) - app.CustomGovKeeper.AssignRoleToActor(ctx, networkActor, 3) - }, - types.ErrRoleAlreadyAssigned, - }, - } - - for _, tt := range tests { - app := simapp.Setup(false) - ctx := app.NewContext(false, tmproto.Header{}) - - tt.preparePerms(t, app, ctx) - - handler := gov.NewHandler(app.CustomGovKeeper) - _, err := handler(ctx, tt.msg) - require.EqualError(t, err, tt.expectedErr.Error()) - } -} - -func TestHandler_AssignRole(t *testing.T) { - proposerAddr, err := sdk.AccAddressFromBech32("kira1alzyfq40zjsveat87jlg8jxetwqmr0a29sgd0f") - require.NoError(t, err) - - addr, err := sdk.AccAddressFromBech32("kira15ky9du8a2wlstz6fpx3p4mqpjyrm5cgqzp4f3d") - require.NoError(t, err) - - app := simapp.Setup(false) - ctx := app.NewContext(false, tmproto.Header{}) - - // Set permissions to proposer. - err = setPermissionToAddr(t, app, ctx, proposerAddr, types.PermUpsertRole) - require.NoError(t, err) - - // Create role - app.CustomGovKeeper.SetRole(ctx, types.Role{ - Id: 3, - Sid: "3", - Description: "3", - }) - err = app.CustomGovKeeper.WhitelistRolePermission(ctx, 3, types.PermSetPermissions) - require.NoError(t, err) - - msg := types.NewMsgAssignRole(proposerAddr, addr, 3) - - handler := gov.NewHandler(app.CustomGovKeeper) - _, err = handler(ctx, msg) - require.NoError(t, err) - - actor, found := app.CustomGovKeeper.GetNetworkActorByAddress(ctx, addr) - require.True(t, found) - - require.True(t, actor.HasRole(3)) -} - -func TestHandler_RemoveRole_Errors(t *testing.T) { - proposerAddr, err := sdk.AccAddressFromBech32("kira1alzyfq40zjsveat87jlg8jxetwqmr0a29sgd0f") - require.NoError(t, err) - - addr, err := sdk.AccAddressFromBech32("kira15ky9du8a2wlstz6fpx3p4mqpjyrm5cgqzp4f3d") - require.NoError(t, err) - - tests := []struct { - name string - msg *types.MsgRemoveRole - preparePerms func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) - expectedErr error - }{ - { - "fails when no perms", - types.NewMsgRemoveRole( - proposerAddr, addr, 3, - ), - func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) {}, - fmt.Errorf("%s: not enough permissions", types.PermUpsertRole.String()), - }, - { - "fails when role does not exist", - types.NewMsgRemoveRole( - proposerAddr, addr, 3, - ), - func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) { - err2 := setPermissionToAddr(t, app, ctx, proposerAddr, types.PermUpsertRole) - require.NoError(t, err2) - }, - types.ErrRoleDoesNotExist, - }, - { - "role not assigned", - types.NewMsgRemoveRole( - proposerAddr, addr, 3, - ), - func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) { - err2 := setPermissionToAddr(t, app, ctx, proposerAddr, types.PermUpsertRole) - require.NoError(t, err2) - - app.CustomGovKeeper.SetRole(ctx, types.Role{ - Id: 3, - Sid: "3", - Description: "3", - }) - err2 = app.CustomGovKeeper.WhitelistRolePermission(ctx, 3, types.PermClaimValidator) - require.NoError(t, err2) - networkActor := types.NewDefaultActor(addr) - app.CustomGovKeeper.SaveNetworkActor(ctx, networkActor) - }, - types.ErrRoleNotAssigned, - }, - } - - for _, tt := range tests { - app := simapp.Setup(false) - ctx := app.NewContext(false, tmproto.Header{}) - - tt.preparePerms(t, app, ctx) - - handler := gov.NewHandler(app.CustomGovKeeper) - _, err := handler(ctx, tt.msg) - require.EqualError(t, err, tt.expectedErr.Error()) - } -} - -func TestHandler_RemoveRoles(t *testing.T) { - proposerAddr, err := sdk.AccAddressFromBech32("kira1alzyfq40zjsveat87jlg8jxetwqmr0a29sgd0f") - require.NoError(t, err) - - addr, err := sdk.AccAddressFromBech32("kira15ky9du8a2wlstz6fpx3p4mqpjyrm5cgqzp4f3d") - require.NoError(t, err) - - app := simapp.Setup(false) - ctx := app.NewContext(false, tmproto.Header{}) - - // Set permissions to proposer. - err = setPermissionToAddr(t, app, ctx, proposerAddr, types.PermUpsertRole) - require.NoError(t, err) - - // Set new role and set permission to actor. - app.CustomGovKeeper.SetRole(ctx, types.Role{ - Id: 3, - Sid: "3", - Description: "3", - }) - err = app.CustomGovKeeper.WhitelistRolePermission(ctx, 3, types.PermSetPermissions) - require.NoError(t, err) - - actor := types.NewDefaultActor(addr) - app.CustomGovKeeper.AssignRoleToActor(ctx, actor, 3) - - actor, found := app.CustomGovKeeper.GetNetworkActorByAddress(ctx, addr) - require.True(t, found) - require.True(t, actor.HasRole(3)) - - msg := types.NewMsgRemoveRole(proposerAddr, addr, 3) - handler := gov.NewHandler(app.CustomGovKeeper) - _, err = handler(ctx, msg) - require.NoError(t, err) - - actor, found = app.CustomGovKeeper.GetNetworkActorByAddress(ctx, addr) - require.True(t, found) - - require.False(t, actor.HasRole(3)) -} - -func TestHandler_CreateProposalAssignPermission_Errors(t *testing.T) { - proposerAddr, err := sdk.AccAddressFromBech32("kira1alzyfq40zjsveat87jlg8jxetwqmr0a29sgd0f") - require.NoError(t, err) - - addr, err := sdk.AccAddressFromBech32("kira15ky9du8a2wlstz6fpx3p4mqpjyrm5cgqzp4f3d") - require.NoError(t, err) - - tests := []struct { - name string - content types.Content - preparePerms func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) - expectedErr error - }{ - { - "Proposer does not have Perm", - types.NewWhitelistAccountPermissionProposal( - addr, types.PermClaimValidator, - ), - func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) {}, - errors.Wrap(types.ErrNotEnoughPermissions, types.PermWhitelistAccountPermissionProposal.String()), - }, - { - "address already has that permission", - types.NewWhitelistAccountPermissionProposal( - addr, types.PermClaimValidator, - ), - func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) { - proposerActor := types.NewDefaultActor(proposerAddr) - err2 := app.CustomGovKeeper.AddWhitelistPermission(ctx, proposerActor, types.PermWhitelistAccountPermissionProposal) - require.NoError(t, err2) - - actor := types.NewDefaultActor(addr) - err2 = app.CustomGovKeeper.AddWhitelistPermission(ctx, actor, types.PermClaimValidator) - require.NoError(t, err2) - }, - fmt.Errorf("permission already whitelisted: error adding to whitelist"), - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - app := simapp.Setup(false) - ctx := app.NewContext(false, tmproto.Header{}) - - tt.preparePerms(t, app, ctx) - - handler := gov.NewHandler(app.CustomGovKeeper) - msg, err := types.NewMsgSubmitProposal(proposerAddr, "title", "some desc", tt.content) - require.NoError(t, err) - _, err = handler(ctx, msg) - require.EqualError(t, err, tt.expectedErr.Error()) - }) - } -} - -func TestHandler_ProposalAssignPermission(t *testing.T) { - proposerAddr, err := sdk.AccAddressFromBech32("kira1alzyfq40zjsveat87jlg8jxetwqmr0a29sgd0f") - require.NoError(t, err) - - addr, err := sdk.AccAddressFromBech32("kira15ky9du8a2wlstz6fpx3p4mqpjyrm5cgqzp4f3d") - require.NoError(t, err) - - app := simapp.Setup(false) - ctx := app.NewContext(false, tmproto.Header{ - Time: time.Now(), - }) - - // Set proposer Permissions - proposerActor := types.NewDefaultActor(proposerAddr) - err2 := app.CustomGovKeeper.AddWhitelistPermission(ctx, proposerActor, types.PermWhitelistAccountPermissionProposal) - require.NoError(t, err2) - - properties := app.CustomGovKeeper.GetNetworkProperties(ctx) - properties.MinimumProposalEndTime = 600 // Seconds, 10 mins - app.CustomGovKeeper.SetNetworkProperties(ctx, properties) - - handler := gov.NewHandler(app.CustomGovKeeper) - proposal := types.NewWhitelistAccountPermissionProposal(addr, types.PermValue(1)) - msg, err := types.NewMsgSubmitProposal(proposerAddr, "title", "some desc", proposal) - require.NoError(t, err) - res, err := handler( - ctx, - msg, - ) - require.NoError(t, err) - - expData, _ := proto.Marshal(&types.MsgSubmitProposalResponse{ProposalID: 1}) - require.Equal(t, expData, res.Data) - - savedProposal, found := app.CustomGovKeeper.GetProposal(ctx, 1) - require.True(t, found) - - expectedSavedProposal, err := types.NewProposal( - 1, - "title", - "some desc", - types.NewWhitelistAccountPermissionProposal( - addr, - types.PermValue(1), - ), - ctx.BlockTime(), - ctx.BlockTime().Add(time.Second*time.Duration(properties.MinimumProposalEndTime)), - ctx.BlockTime().Add((time.Second*time.Duration(properties.MinimumProposalEndTime))+(time.Second*time.Duration(properties.ProposalEnactmentTime))), - ctx.BlockHeight()+2, - ctx.BlockHeight()+3, - ) - require.NoError(t, err) - require.Equal(t, expectedSavedProposal, savedProposal) - - // Next proposal ID is increased. - id := app.CustomGovKeeper.GetNextProposalID(ctx) - require.Equal(t, uint64(2), id) - - // Is not on finished active proposals. - iterator := app.CustomGovKeeper.GetActiveProposalsWithFinishedVotingEndTimeIterator(ctx, ctx.BlockTime()) - require.False(t, iterator.Valid()) - - ctx = ctx.WithBlockTime(ctx.BlockTime().Add(time.Minute * 10)) - iterator = app.CustomGovKeeper.GetActiveProposalsWithFinishedVotingEndTimeIterator(ctx, ctx.BlockTime()) - require.True(t, iterator.Valid()) -} - -func TestHandler_CreateProposalUpsertDataRegistry_Errors(t *testing.T) { - proposerAddr, err := sdk.AccAddressFromBech32("kira1alzyfq40zjsveat87jlg8jxetwqmr0a29sgd0f") - require.NoError(t, err) - - tests := []struct { - name string - content types.Content - preparePerms func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) - expectedErr error - }{ - { - "Proposer does not have Perm", - types.NewUpsertDataRegistryProposal( - "theKey", - "theHash", - "theReference", - "theEncoding", - 1234, - ), - func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) {}, - errors.Wrap(types.ErrNotEnoughPermissions, types.PermCreateUpsertDataRegistryProposal.String()), - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - app := simapp.Setup(false) - ctx := app.NewContext(false, tmproto.Header{}) - - tt.preparePerms(t, app, ctx) - - handler := gov.NewHandler(app.CustomGovKeeper) - msg, err := types.NewMsgSubmitProposal(proposerAddr, "title", "some desc", tt.content) - require.NoError(t, err) - _, err = handler(ctx, msg) - require.EqualError(t, err, tt.expectedErr.Error()) - }) - } -} - -func TestHandler_ProposalUpsertDataRegistry(t *testing.T) { - proposerAddr, err := sdk.AccAddressFromBech32("kira1alzyfq40zjsveat87jlg8jxetwqmr0a29sgd0f") - require.NoError(t, err) - - app := simapp.Setup(false) - ctx := app.NewContext(false, tmproto.Header{ - Time: time.Now(), - }) - - // Set proposer Permissions - proposerActor := types.NewDefaultActor(proposerAddr) - err2 := app.CustomGovKeeper.AddWhitelistPermission(ctx, proposerActor, types.PermCreateUpsertDataRegistryProposal) - require.NoError(t, err2) - - properties := app.CustomGovKeeper.GetNetworkProperties(ctx) - properties.MinimumProposalEndTime = 10 - app.CustomGovKeeper.SetNetworkProperties(ctx, properties) - - handler := gov.NewHandler(app.CustomGovKeeper) - proposal := types.NewUpsertDataRegistryProposal( - "theKey", - "theHash", - "theReference", - "theEncoding", - 1234, - ) - msg, err := types.NewMsgSubmitProposal(proposerAddr, "title", "some desc", proposal) - require.NoError(t, err) - res, err := handler( - ctx, msg, - ) - require.NoError(t, err) - - expData, _ := proto.Marshal(&types.MsgSubmitProposalResponse{ProposalID: 1}) - require.Equal(t, expData, res.Data) - - savedProposal, found := app.CustomGovKeeper.GetProposal(ctx, 1) - require.True(t, found) - - expectedSavedProposal, err := types.NewProposal( - 1, - "title", - "some desc", - types.NewUpsertDataRegistryProposal( - "theKey", - "theHash", - "theReference", - "theEncoding", - 1234, - ), - ctx.BlockTime(), - ctx.BlockTime().Add(time.Second*time.Duration(properties.MinimumProposalEndTime)), - ctx.BlockTime().Add(time.Second*time.Duration(properties.ProposalEnactmentTime)+time.Second*time.Duration(properties.MinimumProposalEndTime)), - ctx.BlockHeight()+2, - ctx.BlockHeight()+3, - ) - require.NoError(t, err) - require.Equal(t, expectedSavedProposal, savedProposal) - - // Next proposal ID is increased. - id := app.CustomGovKeeper.GetNextProposalID(ctx) - require.Equal(t, uint64(2), id) - - // Is not on finished active proposals. - iterator := app.CustomGovKeeper.GetActiveProposalsWithFinishedVotingEndTimeIterator(ctx, ctx.BlockTime()) - require.False(t, iterator.Valid()) - - ctx = ctx.WithBlockTime(ctx.BlockTime().Add(time.Minute * 10)) - iterator = app.CustomGovKeeper.GetActiveProposalsWithFinishedVotingEndTimeIterator(ctx, ctx.BlockTime()) - require.True(t, iterator.Valid()) -} - -func TestHandler_VoteProposal_Errors(t *testing.T) { - voterAddr, err := sdk.AccAddressFromBech32("kira15ky9du8a2wlstz6fpx3p4mqpjyrm5cgqzp4f3d") - require.NoError(t, err) - - tests := []struct { - name string - msg *types.MsgVoteProposal - preparePerms func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) - expectedErr error - }{ - { - "voting time has finished", - types.NewMsgVoteProposal( - 1, voterAddr, types.OptionAbstain, sdk.ZeroDec(), - ), - func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) { - actor := types.NewNetworkActor( - voterAddr, - []uint64{}, - types.Active, - []types.VoteOption{}, - types.NewPermissions(nil, nil), - 1, - ) - app.CustomGovKeeper.SaveNetworkActor(ctx, actor) - - err = app.CustomGovKeeper.AddWhitelistPermission(ctx, actor, types.PermVoteWhitelistAccountPermissionProposal) - require.NoError(t, err) - - // Create proposal - proposal, err := types.NewProposal( - 1, - "title", - "some desc", - types.NewWhitelistAccountPermissionProposal( - voterAddr, - types.PermClaimCouncilor, - ), - ctx.BlockTime(), - ctx.BlockTime().Add(time.Second*9), - ctx.BlockTime().Add(time.Second*20), - ctx.BlockHeight()+2, - ctx.BlockHeight()+3, - ) - - require.NoError(t, err) - app.CustomGovKeeper.SaveProposal(ctx, proposal) - }, - types.ErrVotingTimeEnded, - }, - { - "Voter does not have permission to vote this proposal: Assign Permission", - types.NewMsgVoteProposal( - 1, voterAddr, types.OptionAbstain, sdk.ZeroDec(), - ), - func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) { - actor := types.NewNetworkActor( - voterAddr, - []uint64{}, - types.Active, - []types.VoteOption{}, - types.NewPermissions(nil, nil), - 1, - ) - app.CustomGovKeeper.SaveNetworkActor(ctx, actor) - - // Create proposal - proposal, err := types.NewProposal( - 1, - "title", - "some desc", - types.NewWhitelistAccountPermissionProposal( - voterAddr, - types.PermClaimCouncilor, - ), - ctx.BlockTime(), - ctx.BlockTime().Add(time.Second*20), - ctx.BlockTime().Add(time.Second*30), - ctx.BlockHeight()+2, - ctx.BlockHeight()+3, - ) - require.NoError(t, err) - app.CustomGovKeeper.SaveProposal(ctx, proposal) - }, - fmt.Errorf("%s: not enough permissions", types.PermVoteWhitelistAccountPermissionProposal.String()), - }, - { - "Voter does not have permission to vote this proposal: Change Data Registry", - types.NewMsgVoteProposal( - 1, voterAddr, types.OptionAbstain, sdk.ZeroDec(), - ), - func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) { - actor := types.NewNetworkActor( - voterAddr, - []uint64{}, - types.Active, - []types.VoteOption{}, - types.NewPermissions(nil, nil), - 1, - ) - app.CustomGovKeeper.SaveNetworkActor(ctx, actor) - - // Create proposal - proposal, err := types.NewProposal( - 1, - "title", - "some desc", - types.NewUpsertDataRegistryProposal( - "theKey", - "theHash", - "theReference", - "theEncoding", - 1234, - ), - ctx.BlockTime(), - ctx.BlockTime().Add(time.Second*20), - ctx.BlockTime().Add(time.Second*30), - ctx.BlockHeight()+2, - ctx.BlockHeight()+3, - ) - require.NoError(t, err) - app.CustomGovKeeper.SaveProposal(ctx, proposal) - }, - fmt.Errorf("%s: not enough permissions", types.PermVoteUpsertDataRegistryProposal.String()), - }, - { - "Proposal does not exist", - types.NewMsgVoteProposal( - 1, voterAddr, types.OptionAbstain, sdk.ZeroDec(), - ), - func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) { - actor := types.NewNetworkActor( - voterAddr, - []uint64{}, - types.Active, - []types.VoteOption{}, - types.NewPermissions(nil, nil), - 1, - ) - app.CustomGovKeeper.SaveNetworkActor(ctx, actor) - err2 := app.CustomGovKeeper.AddWhitelistPermission(ctx, actor, types.PermVoteWhitelistAccountPermissionProposal) - require.NoError(t, err2) - }, - types.ErrProposalDoesNotExist, - }, - { - "Voter is not active", - types.NewMsgVoteProposal( - 1, voterAddr, types.OptionAbstain, sdk.ZeroDec(), - ), - func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) { - actor := types.NewDefaultActor(voterAddr) - actor.Deactivate() - app.CustomGovKeeper.SaveNetworkActor(ctx, actor) - err2 := app.CustomGovKeeper.AddWhitelistPermission(ctx, actor, types.PermVoteWhitelistAccountPermissionProposal) - require.NoError(t, err2) - }, - types.ErrActorIsNotActive, - }, - { - "Voter does not have permission to vote this proposal: Change Network Property", - types.NewMsgVoteProposal( - 1, voterAddr, types.OptionAbstain, sdk.ZeroDec(), - ), - func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) { - actor := types.NewNetworkActor( - voterAddr, - []uint64{}, - types.Active, - []types.VoteOption{}, - types.NewPermissions(nil, nil), - 1, - ) - app.CustomGovKeeper.SaveNetworkActor(ctx, actor) - - // Create proposal - proposal, err := types.NewProposal( - 1, - "title", - "some desc", - types.NewSetNetworkPropertyProposal( - types.MinTxFee, - types.NetworkPropertyValue{Value: 1234}, - ), - ctx.BlockTime(), - ctx.BlockTime().Add(time.Second*20), - ctx.BlockTime().Add(time.Second*30), - ctx.BlockHeight()+2, - ctx.BlockHeight()+3, - ) - require.NoError(t, err) - app.CustomGovKeeper.SaveProposal(ctx, proposal) - }, - fmt.Errorf("%s: not enough permissions", types.PermVoteSetNetworkPropertyProposal.String()), - }, - { - "Voter does not have permission to vote this proposal: UpsertTokenAlias", - types.NewMsgVoteProposal( - 1, voterAddr, types.OptionAbstain, sdk.ZeroDec(), - ), - func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) { - actor := types.NewNetworkActor( - voterAddr, - []uint64{}, - types.Active, - []types.VoteOption{}, - types.NewPermissions(nil, nil), - 1, - ) - app.CustomGovKeeper.SaveNetworkActor(ctx, actor) - - // Create proposal - proposal, err := types.NewProposal( - 1, - "title", - "some desc", - tokenstypes.NewUpsertTokenAliasProposal( - "eur", - "Euro", - "theIcon", - 12, - []string{}, - ), - ctx.BlockTime(), - ctx.BlockTime().Add(time.Second*20), - ctx.BlockTime().Add(time.Second*30), - ctx.BlockHeight()+2, - ctx.BlockHeight()+3, - ) - require.NoError(t, err) - app.CustomGovKeeper.SaveProposal(ctx, proposal) - }, - fmt.Errorf("%s: not enough permissions", types.PermVoteUpsertTokenAliasProposal.String()), - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - app := simapp.Setup(false) - ctx := app.NewContext(false, tmproto.Header{}).WithBlockTime(time.Now()) - - tt.preparePerms(t, app, ctx) - - // Add some BlockTime. - ctx = ctx.WithBlockTime(ctx.BlockTime().Add(time.Second * 10)) - - handler := gov.NewHandler(app.CustomGovKeeper) - _, err := handler(ctx, tt.msg) - require.EqualError(t, err, tt.expectedErr.Error()) - }) - } -} - -func TestHandler_VoteProposal(t *testing.T) { - voterAddr, err := sdk.AccAddressFromBech32("kira15ky9du8a2wlstz6fpx3p4mqpjyrm5cgqzp4f3d") - require.NoError(t, err) - - app := simapp.Setup(false) - ctx := app.NewContext(false, tmproto.Header{}) - - // Create Voter as active actor. - actor := types.NewNetworkActor( - voterAddr, - []uint64{}, - types.Active, - []types.VoteOption{}, - types.NewPermissions(nil, nil), - 1, - ) - app.CustomGovKeeper.SaveNetworkActor(ctx, actor) - err2 := app.CustomGovKeeper.AddWhitelistPermission(ctx, actor, types.PermVoteWhitelistAccountPermissionProposal) - require.NoError(t, err2) - - // Create proposal - proposal, err := types.NewProposal( - 1, - "title", - "some desc", - types.NewWhitelistAccountPermissionProposal( - voterAddr, - types.PermClaimCouncilor, - ), - ctx.BlockTime(), - ctx.BlockTime().Add(time.Second*1), - ctx.BlockTime().Add(time.Second*10), - ctx.BlockHeight()+2, - ctx.BlockHeight()+3, - ) - require.NoError(t, err) - app.CustomGovKeeper.SaveProposal(ctx, proposal) - - msg := types.NewMsgVoteProposal(proposal.ProposalId, voterAddr, types.OptionAbstain, sdk.ZeroDec()) - handler := gov.NewHandler(app.CustomGovKeeper) - _, err = handler(ctx, msg) - require.NoError(t, err) - - vote, found := app.CustomGovKeeper.GetVote(ctx, proposal.ProposalId, voterAddr) - require.True(t, found) - require.Equal(t, types.NewVote(proposal.ProposalId, voterAddr, types.OptionAbstain, sdk.ZeroDec()), vote) -} - -func setPermissionToAddr(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context, addr sdk.AccAddress, perm types.PermValue) error { - proposerActor := types.NewDefaultActor(addr) - err := app.CustomGovKeeper.AddWhitelistPermission(ctx, proposerActor, perm) - require.NoError(t, err) - - return nil -} - -func TestHandler_CreateProposalSetNetworkProperty_Errors(t *testing.T) { - proposerAddr, err := sdk.AccAddressFromBech32("kira1alzyfq40zjsveat87jlg8jxetwqmr0a29sgd0f") - require.NoError(t, err) - - tests := []struct { - name string - content types.Content - preparePerms func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) - expectedErr error - }{ - { - "Proposer does not have Perm", - types.NewSetNetworkPropertyProposal( - types.MaxTxFee, - types.NetworkPropertyValue{Value: 100000}, - ), - func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) {}, - errors.Wrap(types.ErrNotEnoughPermissions, types.PermCreateSetNetworkPropertyProposal.String()), - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - app := simapp.Setup(false) - ctx := app.NewContext(false, tmproto.Header{}) - - tt.preparePerms(t, app, ctx) - - handler := gov.NewHandler(app.CustomGovKeeper) - msg, err := types.NewMsgSubmitProposal(proposerAddr, "title", "some desc", tt.content) - require.NoError(t, err) - _, err = handler(ctx, msg) - require.EqualError(t, err, tt.expectedErr.Error()) - }) - } -} - -func TestHandler_ProposalSetNetworkProperty(t *testing.T) { - proposerAddr, err := sdk.AccAddressFromBech32("kira1alzyfq40zjsveat87jlg8jxetwqmr0a29sgd0f") - require.NoError(t, err) - - app := simapp.Setup(false) - ctx := app.NewContext(false, tmproto.Header{ - Time: time.Now(), - }) - - // Set proposer Permissions - proposerActor := types.NewDefaultActor(proposerAddr) - err2 := app.CustomGovKeeper.AddWhitelistPermission(ctx, proposerActor, types.PermCreateSetNetworkPropertyProposal) - require.NoError(t, err2) - - properties := app.CustomGovKeeper.GetNetworkProperties(ctx) - properties.MinimumProposalEndTime = 10 - app.CustomGovKeeper.SetNetworkProperties(ctx, properties) - - handler := gov.NewHandler(app.CustomGovKeeper) - proposal := types.NewSetNetworkPropertyProposal( - types.MinTxFee, - types.NetworkPropertyValue{Value: 1234}, - ) - msg, err := types.NewMsgSubmitProposal(proposerAddr, "title", "some desc", proposal) - require.NoError(t, err) - res, err := handler( - ctx, - msg, - ) - require.NoError(t, err) - - expData, _ := proto.Marshal(&types.MsgSubmitProposalResponse{ProposalID: 1}) - require.Equal(t, expData, res.Data) - - savedProposal, found := app.CustomGovKeeper.GetProposal(ctx, 1) - require.True(t, found) - - expectedSavedProposal, err := types.NewProposal( - 1, - "title", - "some desc", - types.NewSetNetworkPropertyProposal( - types.MinTxFee, - types.NetworkPropertyValue{Value: 1234}, - ), - ctx.BlockTime(), - ctx.BlockTime().Add(time.Second*time.Duration(properties.MinimumProposalEndTime)), - ctx.BlockTime().Add(time.Second*time.Duration(properties.ProposalEnactmentTime)+time.Second*time.Duration(properties.MinimumProposalEndTime)), - ctx.BlockHeight()+2, - ctx.BlockHeight()+3, - ) - require.NoError(t, err) - require.Equal(t, expectedSavedProposal, savedProposal) - - // Next proposal ID is increased. - id := app.CustomGovKeeper.GetNextProposalID(ctx) - require.Equal(t, uint64(2), id) - - // Is not on finished active proposals. - iterator := app.CustomGovKeeper.GetActiveProposalsWithFinishedVotingEndTimeIterator(ctx, ctx.BlockTime()) - require.False(t, iterator.Valid()) - - ctx = ctx.WithBlockTime(ctx.BlockTime().Add(time.Minute * 10)) - iterator = app.CustomGovKeeper.GetActiveProposalsWithFinishedVotingEndTimeIterator(ctx, ctx.BlockTime()) - require.True(t, iterator.Valid()) -} - -func TestHandler_CreateProposalCreateRole_Errors(t *testing.T) { - proposerAddr, err := sdk.AccAddressFromBech32("kira1alzyfq40zjsveat87jlg8jxetwqmr0a29sgd0f") - require.NoError(t, err) - - tests := []struct { - name string - content types.Content - preparePerms func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) - expectedErr error - }{ - { - "Proposer does not have Perm", - types.NewCreateRoleProposal( - "role1", - "role1 description", - []types.PermValue{}, - []types.PermValue{types.PermClaimValidator}, - ), - func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) {}, - errors.Wrap(types.ErrNotEnoughPermissions, types.PermCreateRoleProposal.String()), - }, - { - "role already exist", - types.NewCreateRoleProposal( - "role1", - "role1 description", - []types.PermValue{types.PermClaimCouncilor}, - []types.PermValue{}, - ), - func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) { - proposerActor := types.NewDefaultActor(proposerAddr) - err := app.CustomGovKeeper.AddWhitelistPermission( - ctx, - proposerActor, - types.PermCreateRoleProposal, - ) - require.NoError(t, err) - - app.CustomGovKeeper.SetRole(ctx, types.Role{ - Id: 1, - Sid: "role1", - Description: "role1 description", - }) - }, - types.ErrRoleExist, - }, - { - "permissions are empty", - types.NewCreateRoleProposal( - "role1000", - "role1000 description", - []types.PermValue{}, - []types.PermValue{}, - ), - func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) { - proposerActor := types.NewDefaultActor(proposerAddr) - err := app.CustomGovKeeper.AddWhitelistPermission( - ctx, - proposerActor, - types.PermCreateRoleProposal, - ) - require.NoError(t, err) - }, - types.ErrEmptyPermissions, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - app := simapp.Setup(false) - ctx := app.NewContext(false, tmproto.Header{}) - - tt.preparePerms(t, app, ctx) - - handler := gov.NewHandler(app.CustomGovKeeper) - msg, err := types.NewMsgSubmitProposal(proposerAddr, "title", "some desc", tt.content) - require.NoError(t, err) - _, err = handler(ctx, msg) - require.EqualError(t, err, tt.expectedErr.Error()) - }) - } -} - -func TestHandler_ProposalCreateRole(t *testing.T) { - proposerAddr, err := sdk.AccAddressFromBech32("kira1alzyfq40zjsveat87jlg8jxetwqmr0a29sgd0f") - require.NoError(t, err) - - app := simapp.Setup(false) - ctx := app.NewContext(false, tmproto.Header{ - Time: time.Now(), - }) - - // Set proposer Permissions - proposerActor := types.NewDefaultActor(proposerAddr) - err2 := app.CustomGovKeeper.AddWhitelistPermission(ctx, proposerActor, types.PermCreateRoleProposal) - require.NoError(t, err2) - - properties := app.CustomGovKeeper.GetNetworkProperties(ctx) - properties.MinimumProposalEndTime = 10 - app.CustomGovKeeper.SetNetworkProperties(ctx, properties) - - handler := gov.NewHandler(app.CustomGovKeeper) - proposal := types.NewCreateRoleProposal( - "role1000", - "role1000 description", - []types.PermValue{ - types.PermClaimValidator, - }, - []types.PermValue{ - types.PermChangeTxFee, - }, - ) - msg, err := types.NewMsgSubmitProposal(proposerAddr, "title", "some desc", proposal) - require.NoError(t, err) - res, err := handler( - ctx, - msg, - ) - require.NoError(t, err) - - expData, _ := proto.Marshal(&types.MsgSubmitProposalResponse{ProposalID: 1}) - require.Equal(t, expData, res.Data) - - savedProposal, found := app.CustomGovKeeper.GetProposal(ctx, 1) - require.True(t, found) - - expectedSavedProposal, err := types.NewProposal( - 1, - "title", - "some desc", - types.NewCreateRoleProposal( - "role1000", - "role1000 description", - []types.PermValue{ - types.PermClaimValidator, - }, - []types.PermValue{ - types.PermChangeTxFee, - }, - ), - ctx.BlockTime(), - ctx.BlockTime().Add(time.Second*time.Duration(properties.MinimumProposalEndTime)), - ctx.BlockTime().Add(time.Second*time.Duration(properties.ProposalEnactmentTime)+time.Second*time.Duration(properties.MinimumProposalEndTime)), - ctx.BlockHeight()+2, - ctx.BlockHeight()+3, - ) - require.NoError(t, err) - require.Equal(t, expectedSavedProposal, savedProposal) - - // Next proposal ID is increased. - id := app.CustomGovKeeper.GetNextProposalID(ctx) - require.Equal(t, uint64(2), id) - - // Is not on finished active proposals. - iterator := app.CustomGovKeeper.GetActiveProposalsWithFinishedVotingEndTimeIterator(ctx, ctx.BlockTime()) - require.False(t, iterator.Valid()) - - ctx = ctx.WithBlockTime(ctx.BlockTime().Add(time.Minute * 10)) - iterator = app.CustomGovKeeper.GetActiveProposalsWithFinishedVotingEndTimeIterator(ctx, ctx.BlockTime()) - require.True(t, iterator.Valid()) -} - -func TestHandler_SetProposalDurationsProposal(t *testing.T) { - app := simapp.Setup(false) - ctx := app.NewContext(false, tmproto.Header{ - Time: time.Now(), - }) - - proposal := types.NewSetProposalDurationsProposal( - []string{kiratypes.CreateRoleProposalType, kiratypes.SetNetworkPropertyProposalType}, - []uint64{1200, 2400}, // 20 min, 40min - ) - - router := app.CustomGovKeeper.GetProposalRouter() - err := router.ApplyProposal(ctx, 1, proposal, sdk.ZeroDec()) - require.NoError(t, err) - - duration := app.CustomGovKeeper.GetProposalDuration(ctx, kiratypes.CreateRoleProposalType) - require.Equal(t, duration, uint64(1200)) - - duration = app.CustomGovKeeper.GetProposalDuration(ctx, kiratypes.SetNetworkPropertyProposalType) - require.Equal(t, duration, uint64(2400)) -} +package gov_test + +import ( + "fmt" + "os" + "testing" + "time" + + "github.com/KiraCore/sekai/app" + simapp "github.com/KiraCore/sekai/app" + kiratypes "github.com/KiraCore/sekai/types" + "github.com/KiraCore/sekai/x/gov" + "github.com/KiraCore/sekai/x/gov/types" + tokenstypes "github.com/KiraCore/sekai/x/tokens/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/gogo/protobuf/proto" + "github.com/stretchr/testify/require" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" +) + +func TestMain(m *testing.M) { + app.SetConfig() + os.Exit(m.Run()) +} + +// When a network actor has not been saved before, it creates one with default params +// and sets the permissions. +func TestHandler_MsgWhitelistPermissions_ActorDoesNotExist(t *testing.T) { + proposerAddr, err := sdk.AccAddressFromBech32("kira1alzyfq40zjsveat87jlg8jxetwqmr0a29sgd0f") + require.NoError(t, err) + + addr, err := sdk.AccAddressFromBech32("kira15ky9du8a2wlstz6fpx3p4mqpjyrm5cgqzp4f3d") + require.NoError(t, err) + + tests := []struct { + name string + msg sdk.Msg + checkWhitelisted bool + }{ + { + "Msg Whitelist Permissions", + &types.MsgWhitelistPermissions{ + Proposer: proposerAddr, + Address: addr, + Permission: uint32(types.PermClaimValidator), + }, + true, + }, + { + "Msg Blacklist Permissions", + &types.MsgBlacklistPermissions{ + Proposer: proposerAddr, + Address: addr, + Permission: uint32(types.PermClaimValidator), + }, + false, + }, + } + + for _, tt := range tests { + tt := tt + t.Run(tt.name, func(t *testing.T) { + app := simapp.Setup(false) + ctx := app.NewContext(false, tmproto.Header{}) + + err := setPermissionToAddr(t, app, ctx, proposerAddr, types.PermSetPermissions) + require.NoError(t, err) + + handler := gov.NewHandler(app.CustomGovKeeper) + _, err = handler(ctx, tt.msg) + require.NoError(t, err) + + actor, found := app.CustomGovKeeper.GetNetworkActorByAddress(ctx, addr) + require.True(t, found) + + if tt.checkWhitelisted { + require.True(t, actor.Permissions.IsWhitelisted(types.PermClaimValidator)) + } else { + require.True(t, actor.Permissions.IsBlacklisted(types.PermClaimValidator)) + } + }) + } +} + +// When a network actor has already permissions it just appends the permission. +func TestNewHandler_SetPermissions_ActorWithPerms(t *testing.T) { + addr, err := sdk.AccAddressFromBech32("kira15ky9du8a2wlstz6fpx3p4mqpjyrm5cgqzp4f3d") + require.NoError(t, err) + + proposerAddr, err := sdk.AccAddressFromBech32("kira1alzyfq40zjsveat87jlg8jxetwqmr0a29sgd0f") + require.NoError(t, err) + + tests := []struct { + name string + msg sdk.Msg + checkWhitelisted bool + }{ + { + name: "actor with Whitelist Permissions", + msg: &types.MsgWhitelistPermissions{ + Proposer: proposerAddr, + Address: addr, + Permission: uint32(types.PermClaimValidator), + }, + checkWhitelisted: true, + }, + { + name: "actor with Blacklist Permissions", + msg: &types.MsgBlacklistPermissions{ + Proposer: proposerAddr, + Address: addr, + Permission: uint32(types.PermClaimValidator), + }, + checkWhitelisted: false, + }, + } + + for _, tt := range tests { + tt := tt + t.Run(tt.name, func(t *testing.T) { + app := simapp.Setup(false) + ctx := app.NewContext(false, tmproto.Header{}) + + err := setPermissionToAddr(t, app, ctx, proposerAddr, types.PermSetPermissions) + require.NoError(t, err) + + // Add some perms before to the actor. + actor := types.NewDefaultActor(addr) + if tt.checkWhitelisted { + err = actor.Permissions.AddToWhitelist(types.PermSetPermissions) + } else { + err = actor.Permissions.AddToBlacklist(types.PermSetPermissions) + } + require.NoError(t, err) + + app.CustomGovKeeper.SaveNetworkActor(ctx, actor) + + // Call the handler to add some permissions. + handler := gov.NewHandler(app.CustomGovKeeper) + _, err = handler(ctx, tt.msg) + require.NoError(t, err) + + actor, found := app.CustomGovKeeper.GetNetworkActorByAddress(ctx, addr) + require.True(t, found) + + if tt.checkWhitelisted { + require.True(t, actor.Permissions.IsWhitelisted(types.PermClaimValidator)) + require.True(t, actor.Permissions.IsWhitelisted(types.PermSetPermissions)) // This permission was already set before callid add permission. + } else { + require.True(t, actor.Permissions.IsBlacklisted(types.PermClaimValidator)) + require.True(t, actor.Permissions.IsBlacklisted(types.PermSetPermissions)) // This permission was already set before callid add permission. + } + }) + } +} + +func TestNewHandler_SetPermissionsWithoutSetPermissions(t *testing.T) { + addr, err := sdk.AccAddressFromBech32("kira15ky9du8a2wlstz6fpx3p4mqpjyrm5cgqzp4f3d") + require.NoError(t, err) + + proposerAddr, err := sdk.AccAddressFromBech32("kira1alzyfq40zjsveat87jlg8jxetwqmr0a29sgd0f") + require.NoError(t, err) + + tests := []struct { + name string + msg sdk.Msg + }{ + { + name: "MsgWhitelist", + msg: &types.MsgWhitelistPermissions{ + Proposer: proposerAddr, + Address: addr, + Permission: uint32(types.PermClaimValidator), + }, + }, + { + name: "MsgBlacklist", + msg: &types.MsgBlacklistPermissions{ + Proposer: proposerAddr, + Address: addr, + Permission: uint32(types.PermClaimValidator), + }, + }, + } + + for _, tt := range tests { + tt := tt + t.Run(tt.name, func(t *testing.T) { + app := simapp.Setup(false) + ctx := app.NewContext(false, tmproto.Header{}) + + handler := gov.NewHandler(app.CustomGovKeeper) + _, err = handler(ctx, tt.msg) + require.EqualError(t, err, "PermSetPermissions || (ClaimValidatorPermission && ClaimValidatorPermMsg): not enough permissions") + }) + } +} + +func TestNewHandler_SetPermissions_ProposerHasRoleSudo(t *testing.T) { + addr, err := sdk.AccAddressFromBech32("kira15ky9du8a2wlstz6fpx3p4mqpjyrm5cgqzp4f3d") + require.NoError(t, err) + + proposerAddr, err := sdk.AccAddressFromBech32("kira1alzyfq40zjsveat87jlg8jxetwqmr0a29sgd0f") + require.NoError(t, err) + + tests := []struct { + name string + msg sdk.Msg + checkWhitelist bool + }{ + { + name: "MsgWhitelist", + msg: &types.MsgWhitelistPermissions{ + Proposer: proposerAddr, + Address: addr, + Permission: uint32(types.PermClaimValidator), + }, + checkWhitelist: true, + }, + { + name: "MsgBlacklist", + msg: &types.MsgBlacklistPermissions{ + Proposer: proposerAddr, + Address: addr, + Permission: uint32(types.PermClaimValidator), + }, + checkWhitelist: false, + }, + } + + for _, tt := range tests { + tt := tt + t.Run(tt.name, func(t *testing.T) { + app := simapp.Setup(false) + ctx := app.NewContext(false, tmproto.Header{}) + + // First we set Role Sudo to proposer Actor + proposerActor := types.NewDefaultActor(proposerAddr) + proposerActor.SetRole(types.RoleSudo) + require.NoError(t, err) + app.CustomGovKeeper.SaveNetworkActor(ctx, proposerActor) + + handler := gov.NewHandler(app.CustomGovKeeper) + _, err = handler(ctx, tt.msg) + require.NoError(t, err) + + actor, found := app.CustomGovKeeper.GetNetworkActorByAddress(ctx, addr) + require.True(t, found) + + if tt.checkWhitelist { + require.True(t, actor.Permissions.IsWhitelisted(types.PermClaimValidator)) + } else { + require.True(t, actor.Permissions.IsBlacklisted(types.PermClaimValidator)) + } + }) + } +} + +func TestNewHandler_SetNetworkProperties(t *testing.T) { + changeFeeAddr, err := sdk.AccAddressFromBech32("kira15ky9du8a2wlstz6fpx3p4mqpjyrm5cgqzp4f3d") + require.NoError(t, err) + + sudoAddr, err := sdk.AccAddressFromBech32("kira1alzyfq40zjsveat87jlg8jxetwqmr0a29sgd0f") + require.NoError(t, err) + + tests := []struct { + name string + msg sdk.Msg + desiredErr string + }{ + { + name: "Success run with ChangeTxFee permission", + msg: &types.MsgSetNetworkProperties{ + NetworkProperties: &types.NetworkProperties{ + MinTxFee: 100, + MaxTxFee: 1000, + }, + Proposer: changeFeeAddr, + }, + desiredErr: "", + }, + { + name: "Failure run without ChangeTxFee permission", + msg: &types.MsgSetNetworkProperties{ + NetworkProperties: &types.NetworkProperties{ + MinTxFee: 100, + MaxTxFee: 1000, + }, + Proposer: sudoAddr, + }, + desiredErr: "not enough permissions", + }, + } + + for _, tt := range tests { + tt := tt + t.Run(tt.name, func(t *testing.T) { + app := simapp.Setup(false) + ctx := app.NewContext(false, tmproto.Header{}) + // First we set Role Sudo to proposer Actor + proposerActor := types.NewDefaultActor(sudoAddr) + proposerActor.SetRole(types.RoleSudo) + app.CustomGovKeeper.SaveNetworkActor(ctx, proposerActor) + + handler := gov.NewHandler(app.CustomGovKeeper) + + // set change fee permission to addr + _, err = handler(ctx, &types.MsgWhitelistPermissions{ + Proposer: sudoAddr, + Address: changeFeeAddr, + Permission: uint32(types.PermChangeTxFee), + }) + require.NoError(t, err) + + _, err = handler(ctx, tt.msg) + if tt.desiredErr == "" { + require.NoError(t, err) + } else { + require.Error(t, err) + require.Contains(t, err.Error(), tt.desiredErr) + } + }) + } +} + +func TestNewHandler_SetExecutionFee(t *testing.T) { + execFeeSetAddr, err := sdk.AccAddressFromBech32("kira15ky9du8a2wlstz6fpx3p4mqpjyrm5cgqzp4f3d") + require.NoError(t, err) + + sudoAddr, err := sdk.AccAddressFromBech32("kira1alzyfq40zjsveat87jlg8jxetwqmr0a29sgd0f") + require.NoError(t, err) + + tests := []struct { + name string + msg types.MsgSetExecutionFee + desiredErr string + }{ + { + name: "Success run with ChangeTxFee permission", + msg: types.MsgSetExecutionFee{ + TransactionType: "network-properties", + ExecutionFee: 10000, + FailureFee: 1000, + Timeout: 1, + DefaultParameters: 2, + Proposer: execFeeSetAddr, + }, + desiredErr: "", + }, + { + name: "Success run without ChangeTxFee permission", + msg: types.MsgSetExecutionFee{ + TransactionType: "network-properties-2", + ExecutionFee: 10000, + FailureFee: 1000, + Timeout: 1, + DefaultParameters: 2, + Proposer: sudoAddr, + }, + desiredErr: "PermChangeTxFee: not enough permissions", + }, + } + + for _, tt := range tests { + tt := tt + t.Run(tt.name, func(t *testing.T) { + app := simapp.Setup(false) + ctx := app.NewContext(false, tmproto.Header{}) + // First we set Role Sudo to proposer Actor + proposerActor := types.NewDefaultActor(sudoAddr) + proposerActor.SetRole(types.RoleSudo) + require.NoError(t, err) + app.CustomGovKeeper.SaveNetworkActor(ctx, proposerActor) + + handler := gov.NewHandler(app.CustomGovKeeper) + + // set change fee permission to addr + _, err = handler(ctx, &types.MsgWhitelistPermissions{ + Proposer: sudoAddr, + Address: execFeeSetAddr, + Permission: uint32(types.PermChangeTxFee), + }) + require.NoError(t, err) + + _, err = handler(ctx, &tt.msg) + if tt.desiredErr == "" { + require.NoError(t, err) + execFee := app.CustomGovKeeper.GetExecutionFee(ctx, tt.msg.TransactionType) + require.Equal(t, tt.msg.TransactionType, execFee.TransactionType) + require.Equal(t, tt.msg.ExecutionFee, execFee.ExecutionFee) + require.Equal(t, tt.msg.FailureFee, execFee.FailureFee) + require.Equal(t, tt.msg.Timeout, execFee.Timeout) + require.Equal(t, tt.msg.DefaultParameters, execFee.DefaultParameters) + } else { + require.Error(t, err) + require.Contains(t, err.Error(), tt.desiredErr) + } + }) + } +} + +func TestHandler_ClaimCouncilor_Fails(t *testing.T) { + addr, err := sdk.AccAddressFromBech32("kira15ky9du8a2wlstz6fpx3p4mqpjyrm5cgqzp4f3d") + require.NoError(t, err) + + tests := []struct { + name string + msg sdk.Msg + expectedErr error + }{ + { + name: "not enough permissions", + msg: &types.MsgClaimCouncilor{ + Moniker: "", + Address: addr, + }, + expectedErr: fmt.Errorf("PermClaimCouncilor: not enough permissions"), + }, + } + + for _, tt := range tests { + tt := tt + t.Run(tt.name, func(t *testing.T) { + app := simapp.Setup(false) + ctx := app.NewContext(false, tmproto.Header{}) + + handler := gov.NewHandler(app.CustomGovKeeper) + _, err := handler(ctx, tt.msg) + require.EqualError(t, err, tt.expectedErr.Error()) + }) + } +} + +func TestHandler_ClaimCouncilor_HappyPath(t *testing.T) { + addr, err := sdk.AccAddressFromBech32("kira15ky9du8a2wlstz6fpx3p4mqpjyrm5cgqzp4f3d") + require.NoError(t, err) + + tests := []struct { + name string + msg *types.MsgClaimCouncilor + }{ + { + name: "all correct", + msg: &types.MsgClaimCouncilor{ + Address: addr, + }, + }, + } + + for _, tt := range tests { + tt := tt + t.Run(tt.name, func(t *testing.T) { + app := simapp.Setup(false) + ctx := app.NewContext(false, tmproto.Header{}) + + err = setPermissionToAddr(t, app, ctx, addr, types.PermClaimCouncilor) + require.NoError(t, err) + + handler := gov.NewHandler(app.CustomGovKeeper) + _, err := handler(ctx, tt.msg) + require.NoError(t, err) + + expectedCouncilor := types.NewCouncilor( + tt.msg.Address, + types.CouncilorActive, + ) + + councilor, found := app.CustomGovKeeper.GetCouncilor(ctx, addr) + require.True(t, found) + + require.Equal(t, expectedCouncilor, councilor) + }) + } +} + +func TestHandler_WhitelistRolePermissions_Errors(t *testing.T) { + addr, err := sdk.AccAddressFromBech32("kira15ky9du8a2wlstz6fpx3p4mqpjyrm5cgqzp4f3d") + require.NoError(t, err) + + tests := []struct { + name string + msg *types.MsgWhitelistRolePermission + preparePerms func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) + expectedErr error + }{ + { + name: "address without SetPermissions perm", + msg: types.NewMsgWhitelistRolePermission( + addr, + fmt.Sprintf("%d", types.RoleValidator), + uint32(types.PermSetPermissions), + ), + preparePerms: func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) { + return + }, + expectedErr: fmt.Errorf("%s: not enough permissions", types.PermUpsertRole.String()), + }, + { + name: "role does not exist", + msg: types.NewMsgWhitelistRolePermission( + addr, + "10000", + 1, + ), + preparePerms: func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) { + err2 := setPermissionToAddr(t, app, ctx, addr, types.PermUpsertRole) + require.NoError(t, err2) + }, + expectedErr: fmt.Errorf("role does not exist"), + }, + { + name: "permission is blacklisted", + msg: types.NewMsgWhitelistRolePermission( + addr, + fmt.Sprintf("%d", types.RoleValidator), + uint32(types.PermSetPermissions), + ), + preparePerms: func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) { + err2 := setPermissionToAddr(t, app, ctx, addr, types.PermUpsertRole) + require.NoError(t, err2) + + _, found := app.CustomGovKeeper.GetPermissionsForRole(ctx, types.RoleValidator) + require.True(t, found) + + err2 = app.CustomGovKeeper.BlacklistRolePermission(ctx, types.RoleValidator, types.PermSetPermissions) + require.NoError(t, err2) + }, + expectedErr: fmt.Errorf("permission is blacklisted"), + }, + } + + for _, tt := range tests { + tt := tt + t.Run(tt.name, func(t *testing.T) { + app := simapp.Setup(false) + ctx := app.NewContext(false, tmproto.Header{}) + + tt.preparePerms(t, app, ctx) + + handler := gov.NewHandler(app.CustomGovKeeper) + _, err := handler(ctx, tt.msg) + require.EqualError(t, err, tt.expectedErr.Error()) + }) + } +} + +func TestHandler_WhitelistRolePermissions(t *testing.T) { + addr, err := sdk.AccAddressFromBech32("kira15ky9du8a2wlstz6fpx3p4mqpjyrm5cgqzp4f3d") + require.NoError(t, err) + + app := simapp.Setup(false) + ctx := app.NewContext(false, tmproto.Header{}) + + err = setPermissionToAddr(t, app, ctx, addr, types.PermUpsertRole) + require.NoError(t, err) + + perms, found := app.CustomGovKeeper.GetPermissionsForRole(ctx, types.RoleValidator) + require.True(t, found) + require.False(t, perms.IsWhitelisted(types.PermSetPermissions)) + + msg := types.NewMsgWhitelistRolePermission( + addr, + fmt.Sprintf("%d", types.RoleValidator), + uint32(types.PermSetPermissions), + ) + + handler := gov.NewHandler(app.CustomGovKeeper) + _, err = handler(ctx, msg) + require.NoError(t, err) + + perms, found = app.CustomGovKeeper.GetPermissionsForRole(ctx, types.RoleValidator) + require.True(t, found) + require.True(t, perms.IsWhitelisted(types.PermSetPermissions)) +} + +func TestHandler_BlacklistRolePermissions_Errors(t *testing.T) { + addr, err := sdk.AccAddressFromBech32("kira15ky9du8a2wlstz6fpx3p4mqpjyrm5cgqzp4f3d") + require.NoError(t, err) + + tests := []struct { + name string + msg *types.MsgBlacklistRolePermission + preparePerms func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) + expectedErr error + }{ + { + name: "address without SetPermissions perm", + msg: types.NewMsgBlacklistRolePermission( + addr, + fmt.Sprintf("%d", types.RoleValidator), + uint32(types.PermSetPermissions), + ), + preparePerms: func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) {}, + expectedErr: fmt.Errorf("%s: not enough permissions", types.PermUpsertRole.String()), + }, + { + name: "role does not exist", + msg: types.NewMsgBlacklistRolePermission( + addr, + "10000", + 1, + ), + preparePerms: func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) { + err2 := setPermissionToAddr(t, app, ctx, addr, types.PermUpsertRole) + require.NoError(t, err2) + }, + expectedErr: fmt.Errorf("role does not exist"), + }, + { + name: "permission is whitelisted", + msg: types.NewMsgBlacklistRolePermission( + addr, + fmt.Sprintf("%d", types.RoleValidator), + uint32(types.PermSetPermissions), + ), + preparePerms: func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) { + err2 := setPermissionToAddr(t, app, ctx, addr, types.PermUpsertRole) + require.NoError(t, err2) + + _, found := app.CustomGovKeeper.GetPermissionsForRole(ctx, types.RoleValidator) + require.True(t, found) + + err2 = app.CustomGovKeeper.WhitelistRolePermission(ctx, types.RoleValidator, types.PermSetPermissions) + require.NoError(t, err2) + }, + expectedErr: fmt.Errorf("permission is whitelisted"), + }, + } + + for _, tt := range tests { + tt := tt + t.Run(tt.name, func(t *testing.T) { + app := simapp.Setup(false) + ctx := app.NewContext(false, tmproto.Header{}) + + tt.preparePerms(t, app, ctx) + + handler := gov.NewHandler(app.CustomGovKeeper) + _, err := handler(ctx, tt.msg) + require.EqualError(t, err, tt.expectedErr.Error()) + }) + } +} + +func TestHandler_BlacklistRolePermissions(t *testing.T) { + addr, err := sdk.AccAddressFromBech32("kira15ky9du8a2wlstz6fpx3p4mqpjyrm5cgqzp4f3d") + require.NoError(t, err) + + app := simapp.Setup(false) + ctx := app.NewContext(false, tmproto.Header{}) + + err = setPermissionToAddr(t, app, ctx, addr, types.PermUpsertRole) + require.NoError(t, err) + + perms, found := app.CustomGovKeeper.GetPermissionsForRole(ctx, types.RoleValidator) + require.True(t, found) + require.False(t, perms.IsBlacklisted(types.PermSetPermissions)) + + msg := types.NewMsgBlacklistRolePermission( + addr, + fmt.Sprintf("%d", types.RoleValidator), + uint32(types.PermSetPermissions), + ) + + handler := gov.NewHandler(app.CustomGovKeeper) + _, err = handler(ctx, msg) + require.NoError(t, err) + + perms, found = app.CustomGovKeeper.GetPermissionsForRole(ctx, types.RoleValidator) + require.True(t, found) + require.True(t, perms.IsBlacklisted(types.PermSetPermissions)) +} + +func TestHandler_RemoveWhitelistRolePermissions_Errors(t *testing.T) { + addr, err := sdk.AccAddressFromBech32("kira15ky9du8a2wlstz6fpx3p4mqpjyrm5cgqzp4f3d") + require.NoError(t, err) + + tests := []struct { + name string + msg *types.MsgRemoveWhitelistRolePermission + preparePerms func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) + expectedErr error + }{ + { + name: "address without SetPermissions perm", + msg: types.NewMsgRemoveWhitelistRolePermission( + addr, + fmt.Sprintf("%d", types.RoleValidator), + uint32(types.PermSetPermissions), + ), + preparePerms: func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) {}, + expectedErr: fmt.Errorf("%s: not enough permissions", types.PermUpsertRole.String()), + }, + { + name: "role does not exist", + msg: types.NewMsgRemoveWhitelistRolePermission( + addr, + "10000", + 1, + ), + preparePerms: func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) { + err2 := setPermissionToAddr(t, app, ctx, addr, types.PermUpsertRole) + require.NoError(t, err2) + }, + expectedErr: fmt.Errorf("role does not exist"), + }, + } + + for _, tt := range tests { + tt := tt + t.Run(tt.name, func(t *testing.T) { + app := simapp.Setup(false) + ctx := app.NewContext(false, tmproto.Header{}) + + tt.preparePerms(t, app, ctx) + + handler := gov.NewHandler(app.CustomGovKeeper) + _, err := handler(ctx, tt.msg) + require.EqualError(t, err, tt.expectedErr.Error()) + }) + } +} + +func TestHandler_RemoveWhitelistRolePermissions(t *testing.T) { + addr, err := sdk.AccAddressFromBech32("kira15ky9du8a2wlstz6fpx3p4mqpjyrm5cgqzp4f3d") + require.NoError(t, err) + + app := simapp.Setup(false) + ctx := app.NewContext(false, tmproto.Header{}) + + err = setPermissionToAddr(t, app, ctx, addr, types.PermUpsertRole) + require.NoError(t, err) + + perms, found := app.CustomGovKeeper.GetPermissionsForRole(ctx, types.RoleValidator) + require.True(t, found) + require.True(t, perms.IsWhitelisted(types.PermClaimValidator)) + + msg := types.NewMsgRemoveWhitelistRolePermission( + addr, + fmt.Sprintf("%d", types.RoleValidator), + uint32(types.PermClaimValidator), + ) + + handler := gov.NewHandler(app.CustomGovKeeper) + _, err = handler(ctx, msg) + require.NoError(t, err) + + perms, found = app.CustomGovKeeper.GetPermissionsForRole(ctx, types.RoleValidator) + require.True(t, found) + require.False(t, perms.IsWhitelisted(types.PermClaimValidator)) +} + +func TestHandler_RemoveBlacklistRolePermissions_Errors(t *testing.T) { + addr, err := sdk.AccAddressFromBech32("kira15ky9du8a2wlstz6fpx3p4mqpjyrm5cgqzp4f3d") + require.NoError(t, err) + + tests := []struct { + name string + msg *types.MsgRemoveBlacklistRolePermission + preparePerms func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) + expectedErr error + }{ + { + name: "address without SetPermissions perm", + msg: types.NewMsgRemoveBlacklistRolePermission( + addr, + fmt.Sprintf("%d", types.RoleValidator), + uint32(types.PermSetPermissions), + ), + preparePerms: func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) {}, + expectedErr: fmt.Errorf("%s: not enough permissions", types.PermUpsertRole.String()), + }, + { + name: "role does not exist", + msg: types.NewMsgRemoveBlacklistRolePermission( + addr, + "10000", + 1, + ), + preparePerms: func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) { + err2 := setPermissionToAddr(t, app, ctx, addr, types.PermUpsertRole) + require.NoError(t, err2) + }, + expectedErr: fmt.Errorf("role does not exist"), + }, + } + + for _, tt := range tests { + tt := tt + t.Run(tt.name, func(t *testing.T) { + app := simapp.Setup(false) + ctx := app.NewContext(false, tmproto.Header{}) + + tt.preparePerms(t, app, ctx) + + handler := gov.NewHandler(app.CustomGovKeeper) + _, err := handler(ctx, tt.msg) + require.EqualError(t, err, tt.expectedErr.Error()) + }) + } +} + +func TestHandler_RemoveBlacklistRolePermissions(t *testing.T) { + addr, err := sdk.AccAddressFromBech32("kira15ky9du8a2wlstz6fpx3p4mqpjyrm5cgqzp4f3d") + require.NoError(t, err) + + app := simapp.Setup(false) + ctx := app.NewContext(false, tmproto.Header{}) + + err = setPermissionToAddr(t, app, ctx, addr, types.PermUpsertRole) + require.NoError(t, err) + + _, found := app.CustomGovKeeper.GetPermissionsForRole(ctx, types.RoleValidator) + require.True(t, found) + + // Set some blacklist value + err = app.CustomGovKeeper.BlacklistRolePermission(ctx, types.RoleValidator, types.PermClaimCouncilor) + require.NoError(t, err) + + // Check if it is blacklisted. + perms, found := app.CustomGovKeeper.GetPermissionsForRole(ctx, types.RoleValidator) + require.True(t, found) + require.True(t, perms.IsBlacklisted(types.PermClaimCouncilor)) + + msg := types.NewMsgRemoveBlacklistRolePermission( + addr, + fmt.Sprintf("%d", types.RoleValidator), + uint32(types.PermClaimCouncilor), + ) + + handler := gov.NewHandler(app.CustomGovKeeper) + _, err = handler(ctx, msg) + require.NoError(t, err) + + perms, found = app.CustomGovKeeper.GetPermissionsForRole(ctx, types.RoleValidator) + require.True(t, found) + require.False(t, perms.IsBlacklisted(types.PermClaimCouncilor)) +} + +func TestHandler_CreateRole_Errors(t *testing.T) { + addr, err := sdk.AccAddressFromBech32("kira15ky9du8a2wlstz6fpx3p4mqpjyrm5cgqzp4f3d") + require.NoError(t, err) + + tests := []struct { + name string + msg *types.MsgCreateRole + preparePerms func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) + expectedErr error + }{ + { + "fails when no perms", + types.NewMsgCreateRole( + addr, + "role10", + "role10desc", + ), + func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) {}, + fmt.Errorf("PermUpsertRole: not enough permissions"), + }, + { + "fails when role already exists", + types.NewMsgCreateRole( + addr, + "role1234", + "role1234desc", + ), + func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) { + err2 := setPermissionToAddr(t, app, ctx, addr, types.PermUpsertRole) + require.NoError(t, err2) + app.CustomGovKeeper.CreateRole(ctx, "role1234", "role1234desc") + }, + fmt.Errorf("role already exist"), + }, + } + + for _, tt := range tests { + app := simapp.Setup(false) + ctx := app.NewContext(false, tmproto.Header{}) + + tt.preparePerms(t, app, ctx) + + handler := gov.NewHandler(app.CustomGovKeeper) + _, err := handler(ctx, tt.msg) + require.EqualError(t, err, tt.expectedErr.Error()) + } +} + +func TestHandler_CreateRole(t *testing.T) { + addr, err := sdk.AccAddressFromBech32("kira15ky9du8a2wlstz6fpx3p4mqpjyrm5cgqzp4f3d") + require.NoError(t, err) + + app := simapp.Setup(false) + ctx := app.NewContext(false, tmproto.Header{}) + + err = setPermissionToAddr(t, app, ctx, addr, types.PermUpsertRole) + require.NoError(t, err) + + _, found := app.CustomGovKeeper.GetPermissionsForRole(ctx, 1234) + require.False(t, found) + + handler := gov.NewHandler(app.CustomGovKeeper) + _, err = handler(ctx, types.NewMsgCreateRole( + addr, + "role1234", + "role1234desc", + )) + require.NoError(t, err) + + _, err = app.CustomGovKeeper.GetRoleBySid(ctx, "role1234") + require.NoError(t, err) +} + +func TestHandler_AssignRole_Errors(t *testing.T) { + proposerAddr, err := sdk.AccAddressFromBech32("kira1alzyfq40zjsveat87jlg8jxetwqmr0a29sgd0f") + require.NoError(t, err) + + addr, err := sdk.AccAddressFromBech32("kira15ky9du8a2wlstz6fpx3p4mqpjyrm5cgqzp4f3d") + require.NoError(t, err) + + tests := []struct { + name string + msg *types.MsgAssignRole + preparePerms func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) + expectedErr error + }{ + { + "fails when no perms", + types.NewMsgAssignRole( + proposerAddr, addr, 3, + ), + func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) {}, + fmt.Errorf("%s: not enough permissions", types.PermUpsertRole.String()), + }, + { + "fails when role does not exist", + types.NewMsgAssignRole( + proposerAddr, addr, 3, + ), + func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) { + err2 := setPermissionToAddr(t, app, ctx, proposerAddr, types.PermUpsertRole) + require.NoError(t, err2) + }, + types.ErrRoleDoesNotExist, + }, + { + "role already assigned", + types.NewMsgAssignRole( + proposerAddr, addr, 3, + ), + func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) { + err2 := setPermissionToAddr(t, app, ctx, proposerAddr, types.PermUpsertRole) + require.NoError(t, err2) + + app.CustomGovKeeper.SetRole(ctx, types.Role{ + Id: 3, + Sid: "3", + Description: "3", + }) + err2 = app.CustomGovKeeper.WhitelistRolePermission(ctx, 3, types.PermClaimValidator) + require.NoError(t, err2) + + networkActor := types.NewDefaultActor(addr) + app.CustomGovKeeper.AssignRoleToActor(ctx, networkActor, 3) + }, + types.ErrRoleAlreadyAssigned, + }, + } + + for _, tt := range tests { + app := simapp.Setup(false) + ctx := app.NewContext(false, tmproto.Header{}) + + tt.preparePerms(t, app, ctx) + + handler := gov.NewHandler(app.CustomGovKeeper) + _, err := handler(ctx, tt.msg) + require.EqualError(t, err, tt.expectedErr.Error()) + } +} + +func TestHandler_AssignRole(t *testing.T) { + proposerAddr, err := sdk.AccAddressFromBech32("kira1alzyfq40zjsveat87jlg8jxetwqmr0a29sgd0f") + require.NoError(t, err) + + addr, err := sdk.AccAddressFromBech32("kira15ky9du8a2wlstz6fpx3p4mqpjyrm5cgqzp4f3d") + require.NoError(t, err) + + app := simapp.Setup(false) + ctx := app.NewContext(false, tmproto.Header{}) + + // Set permissions to proposer. + err = setPermissionToAddr(t, app, ctx, proposerAddr, types.PermUpsertRole) + require.NoError(t, err) + + // Create role + app.CustomGovKeeper.SetRole(ctx, types.Role{ + Id: 3, + Sid: "3", + Description: "3", + }) + err = app.CustomGovKeeper.WhitelistRolePermission(ctx, 3, types.PermSetPermissions) + require.NoError(t, err) + + msg := types.NewMsgAssignRole(proposerAddr, addr, 3) + + handler := gov.NewHandler(app.CustomGovKeeper) + _, err = handler(ctx, msg) + require.NoError(t, err) + + actor, found := app.CustomGovKeeper.GetNetworkActorByAddress(ctx, addr) + require.True(t, found) + + require.True(t, actor.HasRole(3)) +} + +func TestHandler_RemoveRole_Errors(t *testing.T) { + proposerAddr, err := sdk.AccAddressFromBech32("kira1alzyfq40zjsveat87jlg8jxetwqmr0a29sgd0f") + require.NoError(t, err) + + addr, err := sdk.AccAddressFromBech32("kira15ky9du8a2wlstz6fpx3p4mqpjyrm5cgqzp4f3d") + require.NoError(t, err) + + tests := []struct { + name string + msg *types.MsgRemoveRole + preparePerms func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) + expectedErr error + }{ + { + "fails when no perms", + types.NewMsgRemoveRole( + proposerAddr, addr, 3, + ), + func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) {}, + fmt.Errorf("%s: not enough permissions", types.PermUpsertRole.String()), + }, + { + "fails when role does not exist", + types.NewMsgRemoveRole( + proposerAddr, addr, 3, + ), + func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) { + err2 := setPermissionToAddr(t, app, ctx, proposerAddr, types.PermUpsertRole) + require.NoError(t, err2) + }, + types.ErrRoleDoesNotExist, + }, + { + "role not assigned", + types.NewMsgRemoveRole( + proposerAddr, addr, 3, + ), + func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) { + err2 := setPermissionToAddr(t, app, ctx, proposerAddr, types.PermUpsertRole) + require.NoError(t, err2) + + app.CustomGovKeeper.SetRole(ctx, types.Role{ + Id: 3, + Sid: "3", + Description: "3", + }) + err2 = app.CustomGovKeeper.WhitelistRolePermission(ctx, 3, types.PermClaimValidator) + require.NoError(t, err2) + networkActor := types.NewDefaultActor(addr) + app.CustomGovKeeper.SaveNetworkActor(ctx, networkActor) + }, + types.ErrRoleNotAssigned, + }, + } + + for _, tt := range tests { + app := simapp.Setup(false) + ctx := app.NewContext(false, tmproto.Header{}) + + tt.preparePerms(t, app, ctx) + + handler := gov.NewHandler(app.CustomGovKeeper) + _, err := handler(ctx, tt.msg) + require.EqualError(t, err, tt.expectedErr.Error()) + } +} + +func TestHandler_RemoveRoles(t *testing.T) { + proposerAddr, err := sdk.AccAddressFromBech32("kira1alzyfq40zjsveat87jlg8jxetwqmr0a29sgd0f") + require.NoError(t, err) + + addr, err := sdk.AccAddressFromBech32("kira15ky9du8a2wlstz6fpx3p4mqpjyrm5cgqzp4f3d") + require.NoError(t, err) + + app := simapp.Setup(false) + ctx := app.NewContext(false, tmproto.Header{}) + + // Set permissions to proposer. + err = setPermissionToAddr(t, app, ctx, proposerAddr, types.PermUpsertRole) + require.NoError(t, err) + + // Set new role and set permission to actor. + app.CustomGovKeeper.SetRole(ctx, types.Role{ + Id: 3, + Sid: "3", + Description: "3", + }) + err = app.CustomGovKeeper.WhitelistRolePermission(ctx, 3, types.PermSetPermissions) + require.NoError(t, err) + + actor := types.NewDefaultActor(addr) + app.CustomGovKeeper.AssignRoleToActor(ctx, actor, 3) + + actor, found := app.CustomGovKeeper.GetNetworkActorByAddress(ctx, addr) + require.True(t, found) + require.True(t, actor.HasRole(3)) + + msg := types.NewMsgRemoveRole(proposerAddr, addr, 3) + handler := gov.NewHandler(app.CustomGovKeeper) + _, err = handler(ctx, msg) + require.NoError(t, err) + + actor, found = app.CustomGovKeeper.GetNetworkActorByAddress(ctx, addr) + require.True(t, found) + + require.False(t, actor.HasRole(3)) +} + +func TestHandler_CreateProposalAssignPermission_Errors(t *testing.T) { + proposerAddr, err := sdk.AccAddressFromBech32("kira1alzyfq40zjsveat87jlg8jxetwqmr0a29sgd0f") + require.NoError(t, err) + + addr, err := sdk.AccAddressFromBech32("kira15ky9du8a2wlstz6fpx3p4mqpjyrm5cgqzp4f3d") + require.NoError(t, err) + + tests := []struct { + name string + content types.Content + preparePerms func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) + expectedErr error + }{ + { + "Proposer does not have Perm", + types.NewWhitelistAccountPermissionProposal( + addr, types.PermClaimValidator, + ), + func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) {}, + errors.Wrap(types.ErrNotEnoughPermissions, types.PermWhitelistAccountPermissionProposal.String()), + }, + { + "address already has that permission", + types.NewWhitelistAccountPermissionProposal( + addr, types.PermClaimValidator, + ), + func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) { + proposerActor := types.NewDefaultActor(proposerAddr) + err2 := app.CustomGovKeeper.AddWhitelistPermission(ctx, proposerActor, types.PermWhitelistAccountPermissionProposal) + require.NoError(t, err2) + + actor := types.NewDefaultActor(addr) + err2 = app.CustomGovKeeper.AddWhitelistPermission(ctx, actor, types.PermClaimValidator) + require.NoError(t, err2) + }, + fmt.Errorf("permission already whitelisted: error adding to whitelist"), + }, + } + + for _, tt := range tests { + tt := tt + t.Run(tt.name, func(t *testing.T) { + app := simapp.Setup(false) + ctx := app.NewContext(false, tmproto.Header{}) + + tt.preparePerms(t, app, ctx) + + handler := gov.NewHandler(app.CustomGovKeeper) + msg, err := types.NewMsgSubmitProposal(proposerAddr, "title", "some desc", tt.content) + require.NoError(t, err) + _, err = handler(ctx, msg) + require.EqualError(t, err, tt.expectedErr.Error()) + }) + } +} + +func TestHandler_ProposalAssignPermission(t *testing.T) { + proposerAddr, err := sdk.AccAddressFromBech32("kira1alzyfq40zjsveat87jlg8jxetwqmr0a29sgd0f") + require.NoError(t, err) + + addr, err := sdk.AccAddressFromBech32("kira15ky9du8a2wlstz6fpx3p4mqpjyrm5cgqzp4f3d") + require.NoError(t, err) + + app := simapp.Setup(false) + ctx := app.NewContext(false, tmproto.Header{ + Time: time.Now(), + }) + + // Set proposer Permissions + proposerActor := types.NewDefaultActor(proposerAddr) + err2 := app.CustomGovKeeper.AddWhitelistPermission(ctx, proposerActor, types.PermWhitelistAccountPermissionProposal) + require.NoError(t, err2) + + properties := app.CustomGovKeeper.GetNetworkProperties(ctx) + properties.MinimumProposalEndTime = 600 // Seconds, 10 mins + app.CustomGovKeeper.SetNetworkProperties(ctx, properties) + + handler := gov.NewHandler(app.CustomGovKeeper) + proposal := types.NewWhitelistAccountPermissionProposal(addr, types.PermValue(1)) + msg, err := types.NewMsgSubmitProposal(proposerAddr, "title", "some desc", proposal) + require.NoError(t, err) + res, err := handler( + ctx, + msg, + ) + require.NoError(t, err) + + expData, _ := proto.Marshal(&types.MsgSubmitProposalResponse{ProposalID: 1}) + require.Equal(t, expData, res.Data) + + savedProposal, found := app.CustomGovKeeper.GetProposal(ctx, 1) + require.True(t, found) + + expectedSavedProposal, err := types.NewProposal( + 1, + "title", + "some desc", + types.NewWhitelistAccountPermissionProposal( + addr, + types.PermValue(1), + ), + ctx.BlockTime(), + ctx.BlockTime().Add(time.Second*time.Duration(properties.MinimumProposalEndTime)), + ctx.BlockTime().Add((time.Second*time.Duration(properties.MinimumProposalEndTime))+(time.Second*time.Duration(properties.ProposalEnactmentTime))), + ctx.BlockHeight()+2, + ctx.BlockHeight()+3, + ) + require.NoError(t, err) + require.Equal(t, expectedSavedProposal, savedProposal) + + // Next proposal ID is increased. + id := app.CustomGovKeeper.GetNextProposalID(ctx) + require.Equal(t, uint64(2), id) + + // Is not on finished active proposals. + iterator := app.CustomGovKeeper.GetActiveProposalsWithFinishedVotingEndTimeIterator(ctx, ctx.BlockTime()) + require.False(t, iterator.Valid()) + + ctx = ctx.WithBlockTime(ctx.BlockTime().Add(time.Minute * 10)) + iterator = app.CustomGovKeeper.GetActiveProposalsWithFinishedVotingEndTimeIterator(ctx, ctx.BlockTime()) + require.True(t, iterator.Valid()) +} + +func TestHandler_CreateProposalUpsertDataRegistry_Errors(t *testing.T) { + proposerAddr, err := sdk.AccAddressFromBech32("kira1alzyfq40zjsveat87jlg8jxetwqmr0a29sgd0f") + require.NoError(t, err) + + tests := []struct { + name string + content types.Content + preparePerms func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) + expectedErr error + }{ + { + "Proposer does not have Perm", + types.NewUpsertDataRegistryProposal( + "theKey", + "theHash", + "theReference", + "theEncoding", + 1234, + ), + func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) {}, + errors.Wrap(types.ErrNotEnoughPermissions, types.PermCreateUpsertDataRegistryProposal.String()), + }, + } + + for _, tt := range tests { + tt := tt + t.Run(tt.name, func(t *testing.T) { + app := simapp.Setup(false) + ctx := app.NewContext(false, tmproto.Header{}) + + tt.preparePerms(t, app, ctx) + + handler := gov.NewHandler(app.CustomGovKeeper) + msg, err := types.NewMsgSubmitProposal(proposerAddr, "title", "some desc", tt.content) + require.NoError(t, err) + _, err = handler(ctx, msg) + require.EqualError(t, err, tt.expectedErr.Error()) + }) + } +} + +func TestHandler_ProposalUpsertDataRegistry(t *testing.T) { + proposerAddr, err := sdk.AccAddressFromBech32("kira1alzyfq40zjsveat87jlg8jxetwqmr0a29sgd0f") + require.NoError(t, err) + + app := simapp.Setup(false) + ctx := app.NewContext(false, tmproto.Header{ + Time: time.Now(), + }) + + // Set proposer Permissions + proposerActor := types.NewDefaultActor(proposerAddr) + err2 := app.CustomGovKeeper.AddWhitelistPermission(ctx, proposerActor, types.PermCreateUpsertDataRegistryProposal) + require.NoError(t, err2) + + properties := app.CustomGovKeeper.GetNetworkProperties(ctx) + properties.MinimumProposalEndTime = 10 + app.CustomGovKeeper.SetNetworkProperties(ctx, properties) + + handler := gov.NewHandler(app.CustomGovKeeper) + proposal := types.NewUpsertDataRegistryProposal( + "theKey", + "theHash", + "theReference", + "theEncoding", + 1234, + ) + msg, err := types.NewMsgSubmitProposal(proposerAddr, "title", "some desc", proposal) + require.NoError(t, err) + res, err := handler( + ctx, msg, + ) + require.NoError(t, err) + + expData, _ := proto.Marshal(&types.MsgSubmitProposalResponse{ProposalID: 1}) + require.Equal(t, expData, res.Data) + + savedProposal, found := app.CustomGovKeeper.GetProposal(ctx, 1) + require.True(t, found) + + expectedSavedProposal, err := types.NewProposal( + 1, + "title", + "some desc", + types.NewUpsertDataRegistryProposal( + "theKey", + "theHash", + "theReference", + "theEncoding", + 1234, + ), + ctx.BlockTime(), + ctx.BlockTime().Add(time.Second*time.Duration(properties.MinimumProposalEndTime)), + ctx.BlockTime().Add(time.Second*time.Duration(properties.ProposalEnactmentTime)+time.Second*time.Duration(properties.MinimumProposalEndTime)), + ctx.BlockHeight()+2, + ctx.BlockHeight()+3, + ) + require.NoError(t, err) + require.Equal(t, expectedSavedProposal, savedProposal) + + // Next proposal ID is increased. + id := app.CustomGovKeeper.GetNextProposalID(ctx) + require.Equal(t, uint64(2), id) + + // Is not on finished active proposals. + iterator := app.CustomGovKeeper.GetActiveProposalsWithFinishedVotingEndTimeIterator(ctx, ctx.BlockTime()) + require.False(t, iterator.Valid()) + + ctx = ctx.WithBlockTime(ctx.BlockTime().Add(time.Minute * 10)) + iterator = app.CustomGovKeeper.GetActiveProposalsWithFinishedVotingEndTimeIterator(ctx, ctx.BlockTime()) + require.True(t, iterator.Valid()) +} + +func TestHandler_VoteProposal_Errors(t *testing.T) { + voterAddr, err := sdk.AccAddressFromBech32("kira15ky9du8a2wlstz6fpx3p4mqpjyrm5cgqzp4f3d") + require.NoError(t, err) + + tests := []struct { + name string + msg *types.MsgVoteProposal + preparePerms func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) + expectedErr error + }{ + { + "voting time has finished", + types.NewMsgVoteProposal( + 1, voterAddr, types.OptionAbstain, sdk.ZeroDec(), + ), + func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) { + actor := types.NewNetworkActor( + voterAddr, + []uint64{}, + types.Active, + []types.VoteOption{}, + types.NewPermissions(nil, nil), + 1, + ) + app.CustomGovKeeper.SaveNetworkActor(ctx, actor) + + err = app.CustomGovKeeper.AddWhitelistPermission(ctx, actor, types.PermVoteWhitelistAccountPermissionProposal) + require.NoError(t, err) + + // Create proposal + proposal, err := types.NewProposal( + 1, + "title", + "some desc", + types.NewWhitelistAccountPermissionProposal( + voterAddr, + types.PermClaimCouncilor, + ), + ctx.BlockTime(), + ctx.BlockTime().Add(time.Second*9), + ctx.BlockTime().Add(time.Second*20), + ctx.BlockHeight()+2, + ctx.BlockHeight()+3, + ) + + require.NoError(t, err) + app.CustomGovKeeper.SaveProposal(ctx, proposal) + }, + types.ErrVotingTimeEnded, + }, + { + "Voter does not have permission to vote this proposal: Assign Permission", + types.NewMsgVoteProposal( + 1, voterAddr, types.OptionAbstain, sdk.ZeroDec(), + ), + func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) { + actor := types.NewNetworkActor( + voterAddr, + []uint64{}, + types.Active, + []types.VoteOption{}, + types.NewPermissions(nil, nil), + 1, + ) + app.CustomGovKeeper.SaveNetworkActor(ctx, actor) + + // Create proposal + proposal, err := types.NewProposal( + 1, + "title", + "some desc", + types.NewWhitelistAccountPermissionProposal( + voterAddr, + types.PermClaimCouncilor, + ), + ctx.BlockTime(), + ctx.BlockTime().Add(time.Second*20), + ctx.BlockTime().Add(time.Second*30), + ctx.BlockHeight()+2, + ctx.BlockHeight()+3, + ) + require.NoError(t, err) + app.CustomGovKeeper.SaveProposal(ctx, proposal) + }, + fmt.Errorf("%s: not enough permissions", types.PermVoteWhitelistAccountPermissionProposal.String()), + }, + { + "Voter does not have permission to vote this proposal: Change Data Registry", + types.NewMsgVoteProposal( + 1, voterAddr, types.OptionAbstain, sdk.ZeroDec(), + ), + func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) { + actor := types.NewNetworkActor( + voterAddr, + []uint64{}, + types.Active, + []types.VoteOption{}, + types.NewPermissions(nil, nil), + 1, + ) + app.CustomGovKeeper.SaveNetworkActor(ctx, actor) + + // Create proposal + proposal, err := types.NewProposal( + 1, + "title", + "some desc", + types.NewUpsertDataRegistryProposal( + "theKey", + "theHash", + "theReference", + "theEncoding", + 1234, + ), + ctx.BlockTime(), + ctx.BlockTime().Add(time.Second*20), + ctx.BlockTime().Add(time.Second*30), + ctx.BlockHeight()+2, + ctx.BlockHeight()+3, + ) + require.NoError(t, err) + app.CustomGovKeeper.SaveProposal(ctx, proposal) + }, + fmt.Errorf("%s: not enough permissions", types.PermVoteUpsertDataRegistryProposal.String()), + }, + { + "Proposal does not exist", + types.NewMsgVoteProposal( + 1, voterAddr, types.OptionAbstain, sdk.ZeroDec(), + ), + func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) { + actor := types.NewNetworkActor( + voterAddr, + []uint64{}, + types.Active, + []types.VoteOption{}, + types.NewPermissions(nil, nil), + 1, + ) + app.CustomGovKeeper.SaveNetworkActor(ctx, actor) + err2 := app.CustomGovKeeper.AddWhitelistPermission(ctx, actor, types.PermVoteWhitelistAccountPermissionProposal) + require.NoError(t, err2) + }, + types.ErrProposalDoesNotExist, + }, + { + "Voter is not active", + types.NewMsgVoteProposal( + 1, voterAddr, types.OptionAbstain, sdk.ZeroDec(), + ), + func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) { + actor := types.NewDefaultActor(voterAddr) + actor.Deactivate() + app.CustomGovKeeper.SaveNetworkActor(ctx, actor) + err2 := app.CustomGovKeeper.AddWhitelistPermission(ctx, actor, types.PermVoteWhitelistAccountPermissionProposal) + require.NoError(t, err2) + }, + types.ErrActorIsNotActive, + }, + { + "Voter does not have permission to vote this proposal: Change Network Property", + types.NewMsgVoteProposal( + 1, voterAddr, types.OptionAbstain, sdk.ZeroDec(), + ), + func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) { + actor := types.NewNetworkActor( + voterAddr, + []uint64{}, + types.Active, + []types.VoteOption{}, + types.NewPermissions(nil, nil), + 1, + ) + app.CustomGovKeeper.SaveNetworkActor(ctx, actor) + + // Create proposal + proposal, err := types.NewProposal( + 1, + "title", + "some desc", + types.NewSetNetworkPropertyProposal( + types.MinTxFee, + types.NetworkPropertyValue{Value: 1234}, + ), + ctx.BlockTime(), + ctx.BlockTime().Add(time.Second*20), + ctx.BlockTime().Add(time.Second*30), + ctx.BlockHeight()+2, + ctx.BlockHeight()+3, + ) + require.NoError(t, err) + app.CustomGovKeeper.SaveProposal(ctx, proposal) + }, + fmt.Errorf("%s: not enough permissions", types.PermVoteSetNetworkPropertyProposal.String()), + }, + { + "Voter does not have permission to vote this proposal: UpsertTokenAlias", + types.NewMsgVoteProposal( + 1, voterAddr, types.OptionAbstain, sdk.ZeroDec(), + ), + func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) { + actor := types.NewNetworkActor( + voterAddr, + []uint64{}, + types.Active, + []types.VoteOption{}, + types.NewPermissions(nil, nil), + 1, + ) + app.CustomGovKeeper.SaveNetworkActor(ctx, actor) + + // Create proposal + proposal, err := types.NewProposal( + 1, + "title", + "some desc", + tokenstypes.NewUpsertTokenAliasProposal( + "eur", + "Euro", + "theIcon", + 12, + []string{}, + false, + ), + ctx.BlockTime(), + ctx.BlockTime().Add(time.Second*20), + ctx.BlockTime().Add(time.Second*30), + ctx.BlockHeight()+2, + ctx.BlockHeight()+3, + ) + require.NoError(t, err) + app.CustomGovKeeper.SaveProposal(ctx, proposal) + }, + fmt.Errorf("%s: not enough permissions", types.PermVoteUpsertTokenAliasProposal.String()), + }, + } + + for _, tt := range tests { + tt := tt + t.Run(tt.name, func(t *testing.T) { + app := simapp.Setup(false) + ctx := app.NewContext(false, tmproto.Header{}).WithBlockTime(time.Now()) + + tt.preparePerms(t, app, ctx) + + // Add some BlockTime. + ctx = ctx.WithBlockTime(ctx.BlockTime().Add(time.Second * 10)) + + handler := gov.NewHandler(app.CustomGovKeeper) + _, err := handler(ctx, tt.msg) + require.EqualError(t, err, tt.expectedErr.Error()) + }) + } +} + +func TestHandler_VoteProposal(t *testing.T) { + voterAddr, err := sdk.AccAddressFromBech32("kira15ky9du8a2wlstz6fpx3p4mqpjyrm5cgqzp4f3d") + require.NoError(t, err) + + app := simapp.Setup(false) + ctx := app.NewContext(false, tmproto.Header{}) + + // Create Voter as active actor. + actor := types.NewNetworkActor( + voterAddr, + []uint64{}, + types.Active, + []types.VoteOption{}, + types.NewPermissions(nil, nil), + 1, + ) + app.CustomGovKeeper.SaveNetworkActor(ctx, actor) + err2 := app.CustomGovKeeper.AddWhitelistPermission(ctx, actor, types.PermVoteWhitelistAccountPermissionProposal) + require.NoError(t, err2) + + // Create proposal + proposal, err := types.NewProposal( + 1, + "title", + "some desc", + types.NewWhitelistAccountPermissionProposal( + voterAddr, + types.PermClaimCouncilor, + ), + ctx.BlockTime(), + ctx.BlockTime().Add(time.Second*1), + ctx.BlockTime().Add(time.Second*10), + ctx.BlockHeight()+2, + ctx.BlockHeight()+3, + ) + require.NoError(t, err) + app.CustomGovKeeper.SaveProposal(ctx, proposal) + + msg := types.NewMsgVoteProposal(proposal.ProposalId, voterAddr, types.OptionAbstain, sdk.ZeroDec()) + handler := gov.NewHandler(app.CustomGovKeeper) + _, err = handler(ctx, msg) + require.NoError(t, err) + + vote, found := app.CustomGovKeeper.GetVote(ctx, proposal.ProposalId, voterAddr) + require.True(t, found) + require.Equal(t, types.NewVote(proposal.ProposalId, voterAddr, types.OptionAbstain, sdk.ZeroDec()), vote) +} + +func setPermissionToAddr(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context, addr sdk.AccAddress, perm types.PermValue) error { + proposerActor := types.NewDefaultActor(addr) + err := app.CustomGovKeeper.AddWhitelistPermission(ctx, proposerActor, perm) + require.NoError(t, err) + + return nil +} + +func TestHandler_CreateProposalSetNetworkProperty_Errors(t *testing.T) { + proposerAddr, err := sdk.AccAddressFromBech32("kira1alzyfq40zjsveat87jlg8jxetwqmr0a29sgd0f") + require.NoError(t, err) + + tests := []struct { + name string + content types.Content + preparePerms func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) + expectedErr error + }{ + { + "Proposer does not have Perm", + types.NewSetNetworkPropertyProposal( + types.MaxTxFee, + types.NetworkPropertyValue{Value: 100000}, + ), + func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) {}, + errors.Wrap(types.ErrNotEnoughPermissions, types.PermCreateSetNetworkPropertyProposal.String()), + }, + } + + for _, tt := range tests { + tt := tt + t.Run(tt.name, func(t *testing.T) { + app := simapp.Setup(false) + ctx := app.NewContext(false, tmproto.Header{}) + + tt.preparePerms(t, app, ctx) + + handler := gov.NewHandler(app.CustomGovKeeper) + msg, err := types.NewMsgSubmitProposal(proposerAddr, "title", "some desc", tt.content) + require.NoError(t, err) + _, err = handler(ctx, msg) + require.EqualError(t, err, tt.expectedErr.Error()) + }) + } +} + +func TestHandler_ProposalSetNetworkProperty(t *testing.T) { + proposerAddr, err := sdk.AccAddressFromBech32("kira1alzyfq40zjsveat87jlg8jxetwqmr0a29sgd0f") + require.NoError(t, err) + + app := simapp.Setup(false) + ctx := app.NewContext(false, tmproto.Header{ + Time: time.Now(), + }) + + // Set proposer Permissions + proposerActor := types.NewDefaultActor(proposerAddr) + err2 := app.CustomGovKeeper.AddWhitelistPermission(ctx, proposerActor, types.PermCreateSetNetworkPropertyProposal) + require.NoError(t, err2) + + properties := app.CustomGovKeeper.GetNetworkProperties(ctx) + properties.MinimumProposalEndTime = 10 + app.CustomGovKeeper.SetNetworkProperties(ctx, properties) + + handler := gov.NewHandler(app.CustomGovKeeper) + proposal := types.NewSetNetworkPropertyProposal( + types.MinTxFee, + types.NetworkPropertyValue{Value: 1234}, + ) + msg, err := types.NewMsgSubmitProposal(proposerAddr, "title", "some desc", proposal) + require.NoError(t, err) + res, err := handler( + ctx, + msg, + ) + require.NoError(t, err) + + expData, _ := proto.Marshal(&types.MsgSubmitProposalResponse{ProposalID: 1}) + require.Equal(t, expData, res.Data) + + savedProposal, found := app.CustomGovKeeper.GetProposal(ctx, 1) + require.True(t, found) + + expectedSavedProposal, err := types.NewProposal( + 1, + "title", + "some desc", + types.NewSetNetworkPropertyProposal( + types.MinTxFee, + types.NetworkPropertyValue{Value: 1234}, + ), + ctx.BlockTime(), + ctx.BlockTime().Add(time.Second*time.Duration(properties.MinimumProposalEndTime)), + ctx.BlockTime().Add(time.Second*time.Duration(properties.ProposalEnactmentTime)+time.Second*time.Duration(properties.MinimumProposalEndTime)), + ctx.BlockHeight()+2, + ctx.BlockHeight()+3, + ) + require.NoError(t, err) + require.Equal(t, expectedSavedProposal, savedProposal) + + // Next proposal ID is increased. + id := app.CustomGovKeeper.GetNextProposalID(ctx) + require.Equal(t, uint64(2), id) + + // Is not on finished active proposals. + iterator := app.CustomGovKeeper.GetActiveProposalsWithFinishedVotingEndTimeIterator(ctx, ctx.BlockTime()) + require.False(t, iterator.Valid()) + + ctx = ctx.WithBlockTime(ctx.BlockTime().Add(time.Minute * 10)) + iterator = app.CustomGovKeeper.GetActiveProposalsWithFinishedVotingEndTimeIterator(ctx, ctx.BlockTime()) + require.True(t, iterator.Valid()) +} + +func TestHandler_CreateProposalCreateRole_Errors(t *testing.T) { + proposerAddr, err := sdk.AccAddressFromBech32("kira1alzyfq40zjsveat87jlg8jxetwqmr0a29sgd0f") + require.NoError(t, err) + + tests := []struct { + name string + content types.Content + preparePerms func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) + expectedErr error + }{ + { + "Proposer does not have Perm", + types.NewCreateRoleProposal( + "role1", + "role1 description", + []types.PermValue{}, + []types.PermValue{types.PermClaimValidator}, + ), + func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) {}, + errors.Wrap(types.ErrNotEnoughPermissions, types.PermCreateRoleProposal.String()), + }, + { + "role already exist", + types.NewCreateRoleProposal( + "role1", + "role1 description", + []types.PermValue{types.PermClaimCouncilor}, + []types.PermValue{}, + ), + func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) { + proposerActor := types.NewDefaultActor(proposerAddr) + err := app.CustomGovKeeper.AddWhitelistPermission( + ctx, + proposerActor, + types.PermCreateRoleProposal, + ) + require.NoError(t, err) + + app.CustomGovKeeper.SetRole(ctx, types.Role{ + Id: 1, + Sid: "role1", + Description: "role1 description", + }) + }, + types.ErrRoleExist, + }, + { + "permissions are empty", + types.NewCreateRoleProposal( + "role1000", + "role1000 description", + []types.PermValue{}, + []types.PermValue{}, + ), + func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) { + proposerActor := types.NewDefaultActor(proposerAddr) + err := app.CustomGovKeeper.AddWhitelistPermission( + ctx, + proposerActor, + types.PermCreateRoleProposal, + ) + require.NoError(t, err) + }, + types.ErrEmptyPermissions, + }, + } + + for _, tt := range tests { + tt := tt + t.Run(tt.name, func(t *testing.T) { + app := simapp.Setup(false) + ctx := app.NewContext(false, tmproto.Header{}) + + tt.preparePerms(t, app, ctx) + + handler := gov.NewHandler(app.CustomGovKeeper) + msg, err := types.NewMsgSubmitProposal(proposerAddr, "title", "some desc", tt.content) + require.NoError(t, err) + _, err = handler(ctx, msg) + require.EqualError(t, err, tt.expectedErr.Error()) + }) + } +} + +func TestHandler_ProposalCreateRole(t *testing.T) { + proposerAddr, err := sdk.AccAddressFromBech32("kira1alzyfq40zjsveat87jlg8jxetwqmr0a29sgd0f") + require.NoError(t, err) + + app := simapp.Setup(false) + ctx := app.NewContext(false, tmproto.Header{ + Time: time.Now(), + }) + + // Set proposer Permissions + proposerActor := types.NewDefaultActor(proposerAddr) + err2 := app.CustomGovKeeper.AddWhitelistPermission(ctx, proposerActor, types.PermCreateRoleProposal) + require.NoError(t, err2) + + properties := app.CustomGovKeeper.GetNetworkProperties(ctx) + properties.MinimumProposalEndTime = 10 + app.CustomGovKeeper.SetNetworkProperties(ctx, properties) + + handler := gov.NewHandler(app.CustomGovKeeper) + proposal := types.NewCreateRoleProposal( + "role1000", + "role1000 description", + []types.PermValue{ + types.PermClaimValidator, + }, + []types.PermValue{ + types.PermChangeTxFee, + }, + ) + msg, err := types.NewMsgSubmitProposal(proposerAddr, "title", "some desc", proposal) + require.NoError(t, err) + res, err := handler( + ctx, + msg, + ) + require.NoError(t, err) + + expData, _ := proto.Marshal(&types.MsgSubmitProposalResponse{ProposalID: 1}) + require.Equal(t, expData, res.Data) + + savedProposal, found := app.CustomGovKeeper.GetProposal(ctx, 1) + require.True(t, found) + + expectedSavedProposal, err := types.NewProposal( + 1, + "title", + "some desc", + types.NewCreateRoleProposal( + "role1000", + "role1000 description", + []types.PermValue{ + types.PermClaimValidator, + }, + []types.PermValue{ + types.PermChangeTxFee, + }, + ), + ctx.BlockTime(), + ctx.BlockTime().Add(time.Second*time.Duration(properties.MinimumProposalEndTime)), + ctx.BlockTime().Add(time.Second*time.Duration(properties.ProposalEnactmentTime)+time.Second*time.Duration(properties.MinimumProposalEndTime)), + ctx.BlockHeight()+2, + ctx.BlockHeight()+3, + ) + require.NoError(t, err) + require.Equal(t, expectedSavedProposal, savedProposal) + + // Next proposal ID is increased. + id := app.CustomGovKeeper.GetNextProposalID(ctx) + require.Equal(t, uint64(2), id) + + // Is not on finished active proposals. + iterator := app.CustomGovKeeper.GetActiveProposalsWithFinishedVotingEndTimeIterator(ctx, ctx.BlockTime()) + require.False(t, iterator.Valid()) + + ctx = ctx.WithBlockTime(ctx.BlockTime().Add(time.Minute * 10)) + iterator = app.CustomGovKeeper.GetActiveProposalsWithFinishedVotingEndTimeIterator(ctx, ctx.BlockTime()) + require.True(t, iterator.Valid()) +} + +func TestHandler_SetProposalDurationsProposal(t *testing.T) { + app := simapp.Setup(false) + ctx := app.NewContext(false, tmproto.Header{ + Time: time.Now(), + }) + + proposal := types.NewSetProposalDurationsProposal( + []string{kiratypes.CreateRoleProposalType, kiratypes.SetNetworkPropertyProposalType}, + []uint64{1200, 2400}, // 20 min, 40min + ) + + router := app.CustomGovKeeper.GetProposalRouter() + err := router.ApplyProposal(ctx, 1, proposal, sdk.ZeroDec()) + require.NoError(t, err) + + duration := app.CustomGovKeeper.GetProposalDuration(ctx, kiratypes.CreateRoleProposalType) + require.Equal(t, duration, uint64(1200)) + + duration = app.CustomGovKeeper.GetProposalDuration(ctx, kiratypes.SetNetworkPropertyProposalType) + require.Equal(t, duration, uint64(2400)) +} diff --git a/x/gov/keeper/councilor.go b/x/gov/keeper/councilor.go index b8701a7ca..1dff49309 100644 --- a/x/gov/keeper/councilor.go +++ b/x/gov/keeper/councilor.go @@ -1,130 +1,136 @@ -package keeper - -import ( - "github.com/cosmos/cosmos-sdk/store/prefix" - sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/KiraCore/sekai/x/gov/types" -) - -var ( - CouncilorsKey = []byte{0x21} // Councilors key prefix. - CouncilorsByMonikerKey = []byte{0x22} // Councilors by moniker prefix. -) - -func GetCouncilorKey(address sdk.AccAddress) []byte { - return append(CouncilorsKey, address.Bytes()...) -} - -func (k Keeper) SaveCouncilor(ctx sdk.Context, councilor types.Councilor) { - prefixStore := prefix.NewStore(ctx.KVStore(k.storeKey), CouncilorIdentityRegistryPrefix) - - bz := k.cdc.MustMarshal(&councilor) - - councilorKey := GetCouncilorKey(councilor.Address) - - prefixStore.Set(councilorKey, bz) -} - -func (k Keeper) GetCouncilor(ctx sdk.Context, address sdk.AccAddress) (types.Councilor, bool) { - return k.getCouncilorByKey(ctx, GetCouncilorKey(address)) -} - -func (k Keeper) GetCouncilorByMoniker(ctx sdk.Context, moniker string) (types.Councilor, bool) { - addresses := k.GetAddressesByIdRecordKey(ctx, "moniker", moniker) - - if len(addresses) != 1 { - return types.Councilor{}, false - } - - return k.GetCouncilor(ctx, addresses[0]) -} - -func (k Keeper) getCouncilorByKey(ctx sdk.Context, key []byte) (types.Councilor, bool) { - prefixStore := prefix.NewStore(ctx.KVStore(k.storeKey), CouncilorIdentityRegistryPrefix) - - bz := prefixStore.Get(key) - if bz == nil { - return types.Councilor{}, false - } - - var councilor types.Councilor - k.cdc.MustUnmarshal(bz, &councilor) - return councilor, true -} - -func (k Keeper) GetAllCouncilors(ctx sdk.Context) []types.Councilor { - prefixStore := prefix.NewStore(ctx.KVStore(k.storeKey), CouncilorIdentityRegistryPrefix) - - iterator := prefixStore.Iterator(nil, nil) - defer iterator.Close() - - councilors := []types.Councilor{} - for ; iterator.Valid(); iterator.Next() { - var councilor types.Councilor - k.cdc.MustUnmarshal(iterator.Value(), &councilor) - councilors = append(councilors, councilor) - } - - return councilors -} - -func (k Keeper) OnCouncilorAct(ctx sdk.Context, addr sdk.AccAddress) { - councilor, found := k.GetCouncilor(ctx, addr) - if !found { - return - } - if councilor.Status == types.CouncilorActive { - councilor.AbstentionCounter = 0 - councilor.Rank++ - k.SaveCouncilor(ctx, councilor) - } -} - -func (k Keeper) OnCouncilorAbsent(ctx sdk.Context, addr sdk.AccAddress) { - councilor, found := k.GetCouncilor(ctx, addr) - if !found { - return - } - if councilor.Status == types.CouncilorActive { - properties := k.GetNetworkProperties(ctx) - // increase `abstention counter` by `1` - councilor.AbstentionCounter++ - // decrease rank by `abstention_rank_decrease_amount` - if councilor.Rank > int64(properties.AbstentionRankDecreaseAmount) { - councilor.Rank -= int64(properties.AbstentionRankDecreaseAmount) - } else { - councilor.Rank = 0 - } - - // Counselor **consecutively** did NOT voted on the proposal he had permission to vote more than `max_abstention` number of times while having `active` status - // - change status to `inactive` - // - set `rank` to `0` - if councilor.AbstentionCounter >= int64(properties.MaxAbstention) { - councilor.Status = types.CouncilorInactive - councilor.Rank = 0 - } - - k.SaveCouncilor(ctx, councilor) - } -} - -func (k Keeper) OnCouncilorJail(ctx sdk.Context, addr sdk.AccAddress) { - councilor, found := k.GetCouncilor(ctx, addr) - if !found { - return - } - councilor.Status = types.CouncilorJailed - councilor.Rank = 0 - k.SaveCouncilor(ctx, councilor) -} - -func (k Keeper) ResetWholeCouncilorRank(ctx sdk.Context) { - councilors := k.GetAllCouncilors(ctx) - for _, councilor := range councilors { - councilor.Status = types.CouncilorActive - councilor.Rank = 0 - councilor.AbstentionCounter = 0 - k.SaveCouncilor(ctx, councilor) - } -} +package keeper + +import ( + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/KiraCore/sekai/x/gov/types" +) + +var ( + CouncilorsKey = []byte{0x21} // Councilors key prefix. + CouncilorsByMonikerKey = []byte{0x22} // Councilors by moniker prefix. +) + +func GetCouncilorKey(address sdk.AccAddress) []byte { + return append(CouncilorsKey, address.Bytes()...) +} + +func (k Keeper) SaveCouncilor(ctx sdk.Context, councilor types.Councilor) { + prefixStore := prefix.NewStore(ctx.KVStore(k.storeKey), CouncilorIdentityRegistryPrefix) + + bz := k.cdc.MustMarshal(&councilor) + + councilorKey := GetCouncilorKey(councilor.Address) + + prefixStore.Set(councilorKey, bz) +} + +func (k Keeper) DeleteCouncilor(ctx sdk.Context, councilor types.Councilor) { + prefixStore := prefix.NewStore(ctx.KVStore(k.storeKey), CouncilorIdentityRegistryPrefix) + councilorKey := GetCouncilorKey(councilor.Address) + prefixStore.Delete(councilorKey) +} + +func (k Keeper) GetCouncilor(ctx sdk.Context, address sdk.AccAddress) (types.Councilor, bool) { + return k.getCouncilorByKey(ctx, GetCouncilorKey(address)) +} + +func (k Keeper) GetCouncilorByMoniker(ctx sdk.Context, moniker string) (types.Councilor, bool) { + addresses := k.GetAddressesByIdRecordKey(ctx, "moniker", moniker) + + if len(addresses) != 1 { + return types.Councilor{}, false + } + + return k.GetCouncilor(ctx, addresses[0]) +} + +func (k Keeper) getCouncilorByKey(ctx sdk.Context, key []byte) (types.Councilor, bool) { + prefixStore := prefix.NewStore(ctx.KVStore(k.storeKey), CouncilorIdentityRegistryPrefix) + + bz := prefixStore.Get(key) + if bz == nil { + return types.Councilor{}, false + } + + var councilor types.Councilor + k.cdc.MustUnmarshal(bz, &councilor) + return councilor, true +} + +func (k Keeper) GetAllCouncilors(ctx sdk.Context) []types.Councilor { + prefixStore := prefix.NewStore(ctx.KVStore(k.storeKey), CouncilorIdentityRegistryPrefix) + + iterator := prefixStore.Iterator(nil, nil) + defer iterator.Close() + + councilors := []types.Councilor{} + for ; iterator.Valid(); iterator.Next() { + var councilor types.Councilor + k.cdc.MustUnmarshal(iterator.Value(), &councilor) + councilors = append(councilors, councilor) + } + + return councilors +} + +func (k Keeper) OnCouncilorAct(ctx sdk.Context, addr sdk.AccAddress) { + councilor, found := k.GetCouncilor(ctx, addr) + if !found { + return + } + if councilor.Status == types.CouncilorActive { + councilor.AbstentionCounter = 0 + councilor.Rank++ + k.SaveCouncilor(ctx, councilor) + } +} + +func (k Keeper) OnCouncilorAbsent(ctx sdk.Context, addr sdk.AccAddress) { + councilor, found := k.GetCouncilor(ctx, addr) + if !found { + return + } + if councilor.Status == types.CouncilorActive { + properties := k.GetNetworkProperties(ctx) + // increase `abstention counter` by `1` + councilor.AbstentionCounter++ + // decrease rank by `abstention_rank_decrease_amount` + if councilor.Rank > int64(properties.AbstentionRankDecreaseAmount) { + councilor.Rank -= int64(properties.AbstentionRankDecreaseAmount) + } else { + councilor.Rank = 0 + } + + // Counselor **consecutively** did NOT voted on the proposal he had permission to vote more than `max_abstention` number of times while having `active` status + // - change status to `inactive` + // - set `rank` to `0` + if councilor.AbstentionCounter >= int64(properties.MaxAbstention) { + councilor.Status = types.CouncilorInactive + councilor.Rank = 0 + } + + k.SaveCouncilor(ctx, councilor) + } +} + +func (k Keeper) OnCouncilorJail(ctx sdk.Context, addr sdk.AccAddress) { + councilor, found := k.GetCouncilor(ctx, addr) + if !found { + return + } + councilor.Status = types.CouncilorJailed + councilor.Rank = 0 + k.SaveCouncilor(ctx, councilor) +} + +func (k Keeper) ResetWholeCouncilorRank(ctx sdk.Context) { + councilors := k.GetAllCouncilors(ctx) + for _, councilor := range councilors { + councilor.Status = types.CouncilorActive + councilor.Rank = 0 + councilor.AbstentionCounter = 0 + k.SaveCouncilor(ctx, councilor) + } +} diff --git a/x/gov/keeper/councilor_test.go b/x/gov/keeper/councilor_test.go index c800b70a0..ff3e0337d 100644 --- a/x/gov/keeper/councilor_test.go +++ b/x/gov/keeper/councilor_test.go @@ -1,200 +1,200 @@ -package keeper_test - -import ( - "testing" - - simapp "github.com/KiraCore/sekai/app" - "github.com/KiraCore/sekai/x/gov/types" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/require" - tmproto "github.com/tendermint/tendermint/proto/tendermint/types" -) - -func TestKeeper_SaveCouncilor(t *testing.T) { - app := simapp.Setup(false) - ctx := app.NewContext(false, tmproto.Header{}) - - addrs := simapp.AddTestAddrsIncremental(app, ctx, 1, sdk.TokensFromConsensusPower(10, sdk.DefaultPowerReduction)) - addr := addrs[0] - - councilor := types.NewCouncilor( - addr, - types.CouncilorActive, - ) - - app.CustomGovKeeper.SaveCouncilor(ctx, councilor) - - savedCouncilor, found := app.CustomGovKeeper.GetCouncilor(ctx, councilor.Address) - require.True(t, found) - require.Equal(t, councilor, savedCouncilor) -} - -func TestKeeper_TryCouncilorMonikerOrUsernameUpdate(t *testing.T) { - app := simapp.Setup(false) - ctx := app.NewContext(false, tmproto.Header{}) - - addrs := simapp.AddTestAddrsIncremental(app, ctx, 1, sdk.TokensFromConsensusPower(10, sdk.DefaultPowerReduction)) - addr := addrs[0] - - councilor := types.NewCouncilor( - addr, - types.CouncilorActive, - ) - - app.CustomGovKeeper.SaveCouncilor(ctx, councilor) - - savedCouncilor, found := app.CustomGovKeeper.GetCouncilor(ctx, councilor.Address) - require.True(t, found) - require.Equal(t, councilor, savedCouncilor) - - err := app.CustomGovKeeper.RegisterIdentityRecords(ctx, addr, []types.IdentityInfoEntry{ - {Key: "moniker", Info: "moniker1"}, - }) - require.NoError(t, err) - err = app.CustomGovKeeper.RegisterIdentityRecords(ctx, addr, []types.IdentityInfoEntry{ - {Key: "moniker", Info: "xxxx"}, - }) - require.Error(t, err) - - err = app.CustomGovKeeper.RegisterIdentityRecords(ctx, addr, []types.IdentityInfoEntry{ - {Key: "username", Info: "username1"}, - }) - require.NoError(t, err) - err = app.CustomGovKeeper.RegisterIdentityRecords(ctx, addr, []types.IdentityInfoEntry{ - {Key: "username", Info: "xxxx"}, - }) - require.Error(t, err) - - err = app.CustomGovKeeper.RegisterIdentityRecords(ctx, addr, []types.IdentityInfoEntry{ - {Key: "avatar", Info: "avatar1"}, - }) - require.NoError(t, err) - err = app.CustomGovKeeper.RegisterIdentityRecords(ctx, addr, []types.IdentityInfoEntry{ - {Key: "avatar", Info: "xxxx"}, - }) - require.NoError(t, err) -} - -func TestKeeper_OnCouncilorAct(t *testing.T) { - app := simapp.Setup(false) - ctx := app.NewContext(false, tmproto.Header{}) - - addrs := simapp.AddTestAddrsIncremental(app, ctx, 1, sdk.TokensFromConsensusPower(10, sdk.DefaultPowerReduction)) - addr := addrs[0] - - councilor := types.Councilor{ - Address: addr, - Status: types.CouncilorActive, - Rank: 1, - AbstentionCounter: 1, - } - - app.CustomGovKeeper.SaveCouncilor(ctx, councilor) - - savedCouncilor, found := app.CustomGovKeeper.GetCouncilor(ctx, councilor.Address) - require.True(t, found) - require.Equal(t, councilor, savedCouncilor) - - app.CustomGovKeeper.OnCouncilorAct(ctx, addr) - savedCouncilor, found = app.CustomGovKeeper.GetCouncilor(ctx, councilor.Address) - require.True(t, found) - require.Equal(t, types.Councilor{ - Address: addr, - Status: types.CouncilorActive, - Rank: 2, - AbstentionCounter: 0, - }, savedCouncilor) -} - -func TestKeeper_OnCouncilorAbsent(t *testing.T) { - app := simapp.Setup(false) - ctx := app.NewContext(false, tmproto.Header{}) - - addrs := simapp.AddTestAddrsIncremental(app, ctx, 1, sdk.TokensFromConsensusPower(10, sdk.DefaultPowerReduction)) - addr := addrs[0] - - councilor := types.Councilor{ - Address: addr, - Status: types.CouncilorActive, - Rank: 1, - AbstentionCounter: 1, - } - - app.CustomGovKeeper.SaveCouncilor(ctx, councilor) - - savedCouncilor, found := app.CustomGovKeeper.GetCouncilor(ctx, councilor.Address) - require.True(t, found) - require.Equal(t, councilor, savedCouncilor) - - app.CustomGovKeeper.OnCouncilorAbsent(ctx, addr) - savedCouncilor, found = app.CustomGovKeeper.GetCouncilor(ctx, councilor.Address) - require.True(t, found) - require.Equal(t, types.Councilor{ - Address: addr, - Status: types.CouncilorInactive, - Rank: 0, - AbstentionCounter: 2, - }, savedCouncilor) -} - -func TestKeeper_OnCouncilorJail(t *testing.T) { - app := simapp.Setup(false) - ctx := app.NewContext(false, tmproto.Header{}) - - addrs := simapp.AddTestAddrsIncremental(app, ctx, 1, sdk.TokensFromConsensusPower(10, sdk.DefaultPowerReduction)) - addr := addrs[0] - - councilor := types.Councilor{ - Address: addr, - Status: types.CouncilorActive, - Rank: 1, - AbstentionCounter: 1, - } - - app.CustomGovKeeper.SaveCouncilor(ctx, councilor) - - savedCouncilor, found := app.CustomGovKeeper.GetCouncilor(ctx, councilor.Address) - require.True(t, found) - require.Equal(t, councilor, savedCouncilor) - - app.CustomGovKeeper.OnCouncilorJail(ctx, addr) - savedCouncilor, found = app.CustomGovKeeper.GetCouncilor(ctx, councilor.Address) - require.True(t, found) - require.Equal(t, types.Councilor{ - Address: addr, - Status: types.CouncilorJailed, - Rank: 0, - AbstentionCounter: 1, - }, savedCouncilor) -} - -func TestKeeper_ResetWholeCouncilorRank(t *testing.T) { - app := simapp.Setup(false) - ctx := app.NewContext(false, tmproto.Header{}) - - addrs := simapp.AddTestAddrsIncremental(app, ctx, 1, sdk.TokensFromConsensusPower(10, sdk.DefaultPowerReduction)) - addr := addrs[0] - - councilor := types.Councilor{ - Address: addr, - Status: types.CouncilorActive, - Rank: 1, - AbstentionCounter: 1, - } - - app.CustomGovKeeper.SaveCouncilor(ctx, councilor) - - savedCouncilor, found := app.CustomGovKeeper.GetCouncilor(ctx, councilor.Address) - require.True(t, found) - require.Equal(t, councilor, savedCouncilor) - - app.CustomGovKeeper.ResetWholeCouncilorRank(ctx) - savedCouncilor, found = app.CustomGovKeeper.GetCouncilor(ctx, councilor.Address) - require.True(t, found) - require.Equal(t, types.Councilor{ - Address: addr, - Status: types.CouncilorActive, - Rank: 0, - AbstentionCounter: 0, - }, savedCouncilor) -} +package keeper_test + +import ( + "testing" + + simapp "github.com/KiraCore/sekai/app" + "github.com/KiraCore/sekai/x/gov/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" +) + +func TestKeeper_SaveCouncilor(t *testing.T) { + app := simapp.Setup(false) + ctx := app.NewContext(false, tmproto.Header{}) + + addrs := simapp.AddTestAddrsIncremental(app, ctx, 1, sdk.TokensFromConsensusPower(10, sdk.DefaultPowerReduction)) + addr := addrs[0] + + councilor := types.NewCouncilor( + addr, + types.CouncilorActive, + ) + + app.CustomGovKeeper.SaveCouncilor(ctx, councilor) + + savedCouncilor, found := app.CustomGovKeeper.GetCouncilor(ctx, councilor.Address) + require.True(t, found) + require.Equal(t, councilor, savedCouncilor) +} + +func TestKeeper_TryCouncilorMonikerOrUsernameUpdate(t *testing.T) { + app := simapp.Setup(false) + ctx := app.NewContext(false, tmproto.Header{}) + + addrs := simapp.AddTestAddrsIncremental(app, ctx, 1, sdk.TokensFromConsensusPower(10, sdk.DefaultPowerReduction)) + addr := addrs[0] + + councilor := types.NewCouncilor( + addr, + types.CouncilorActive, + ) + + app.CustomGovKeeper.SaveCouncilor(ctx, councilor) + + savedCouncilor, found := app.CustomGovKeeper.GetCouncilor(ctx, councilor.Address) + require.True(t, found) + require.Equal(t, councilor, savedCouncilor) + + err := app.CustomGovKeeper.RegisterIdentityRecords(ctx, addr, []types.IdentityInfoEntry{ + {Key: "moniker", Info: "moniker1"}, + }) + require.NoError(t, err) + err = app.CustomGovKeeper.RegisterIdentityRecords(ctx, addr, []types.IdentityInfoEntry{ + {Key: "moniker", Info: "xxxx"}, + }) + require.Error(t, err) + + err = app.CustomGovKeeper.RegisterIdentityRecords(ctx, addr, []types.IdentityInfoEntry{ + {Key: "username", Info: "username1"}, + }) + require.NoError(t, err) + err = app.CustomGovKeeper.RegisterIdentityRecords(ctx, addr, []types.IdentityInfoEntry{ + {Key: "username", Info: "xxxx"}, + }) + require.Error(t, err) + + err = app.CustomGovKeeper.RegisterIdentityRecords(ctx, addr, []types.IdentityInfoEntry{ + {Key: "avatar", Info: "avatar1"}, + }) + require.NoError(t, err) + err = app.CustomGovKeeper.RegisterIdentityRecords(ctx, addr, []types.IdentityInfoEntry{ + {Key: "avatar", Info: "xxxx"}, + }) + require.NoError(t, err) +} + +func TestKeeper_OnCouncilorAct(t *testing.T) { + app := simapp.Setup(false) + ctx := app.NewContext(false, tmproto.Header{}) + + addrs := simapp.AddTestAddrsIncremental(app, ctx, 1, sdk.TokensFromConsensusPower(10, sdk.DefaultPowerReduction)) + addr := addrs[0] + + councilor := types.Councilor{ + Address: addr, + Status: types.CouncilorActive, + Rank: 1, + AbstentionCounter: 1, + } + + app.CustomGovKeeper.SaveCouncilor(ctx, councilor) + + savedCouncilor, found := app.CustomGovKeeper.GetCouncilor(ctx, councilor.Address) + require.True(t, found) + require.Equal(t, councilor, savedCouncilor) + + app.CustomGovKeeper.OnCouncilorAct(ctx, addr) + savedCouncilor, found = app.CustomGovKeeper.GetCouncilor(ctx, councilor.Address) + require.True(t, found) + require.Equal(t, types.Councilor{ + Address: addr, + Status: types.CouncilorActive, + Rank: 2, + AbstentionCounter: 0, + }, savedCouncilor) +} + +func TestKeeper_OnCouncilorAbsent(t *testing.T) { + app := simapp.Setup(false) + ctx := app.NewContext(false, tmproto.Header{}) + + addrs := simapp.AddTestAddrsIncremental(app, ctx, 1, sdk.TokensFromConsensusPower(10, sdk.DefaultPowerReduction)) + addr := addrs[0] + + councilor := types.Councilor{ + Address: addr, + Status: types.CouncilorActive, + Rank: 1, + AbstentionCounter: 1, + } + + app.CustomGovKeeper.SaveCouncilor(ctx, councilor) + + savedCouncilor, found := app.CustomGovKeeper.GetCouncilor(ctx, councilor.Address) + require.True(t, found) + require.Equal(t, councilor, savedCouncilor) + + app.CustomGovKeeper.OnCouncilorAbsent(ctx, addr) + savedCouncilor, found = app.CustomGovKeeper.GetCouncilor(ctx, councilor.Address) + require.True(t, found) + require.Equal(t, types.Councilor{ + Address: addr, + Status: types.CouncilorInactive, + Rank: 0, + AbstentionCounter: 2, + }, savedCouncilor) +} + +func TestKeeper_OnCouncilorJail(t *testing.T) { + app := simapp.Setup(false) + ctx := app.NewContext(false, tmproto.Header{}) + + addrs := simapp.AddTestAddrsIncremental(app, ctx, 1, sdk.TokensFromConsensusPower(10, sdk.DefaultPowerReduction)) + addr := addrs[0] + + councilor := types.Councilor{ + Address: addr, + Status: types.CouncilorActive, + Rank: 1, + AbstentionCounter: 1, + } + + app.CustomGovKeeper.SaveCouncilor(ctx, councilor) + + savedCouncilor, found := app.CustomGovKeeper.GetCouncilor(ctx, councilor.Address) + require.True(t, found) + require.Equal(t, councilor, savedCouncilor) + + app.CustomGovKeeper.OnCouncilorJail(ctx, addr) + savedCouncilor, found = app.CustomGovKeeper.GetCouncilor(ctx, councilor.Address) + require.True(t, found) + require.Equal(t, types.Councilor{ + Address: addr, + Status: types.CouncilorJailed, + Rank: 0, + AbstentionCounter: 1, + }, savedCouncilor) +} + +func TestKeeper_ResetWholeCouncilorRank(t *testing.T) { + app := simapp.Setup(false) + ctx := app.NewContext(false, tmproto.Header{}) + + addrs := simapp.AddTestAddrsIncremental(app, ctx, 1, sdk.TokensFromConsensusPower(10, sdk.DefaultPowerReduction)) + addr := addrs[0] + + councilor := types.Councilor{ + Address: addr, + Status: types.CouncilorActive, + Rank: 1, + AbstentionCounter: 1, + } + + app.CustomGovKeeper.SaveCouncilor(ctx, councilor) + + savedCouncilor, found := app.CustomGovKeeper.GetCouncilor(ctx, councilor.Address) + require.True(t, found) + require.Equal(t, councilor, savedCouncilor) + + app.CustomGovKeeper.ResetWholeCouncilorRank(ctx) + savedCouncilor, found = app.CustomGovKeeper.GetCouncilor(ctx, councilor.Address) + require.True(t, found) + require.Equal(t, types.Councilor{ + Address: addr, + Status: types.CouncilorActive, + Rank: 0, + AbstentionCounter: 0, + }, savedCouncilor) +} diff --git a/x/gov/keeper/data_registry.go b/x/gov/keeper/data_registry.go index f8b3b8ded..652393c88 100644 --- a/x/gov/keeper/data_registry.go +++ b/x/gov/keeper/data_registry.go @@ -1,72 +1,72 @@ -package keeper - -import ( - "strings" - - "github.com/KiraCore/sekai/x/gov/types" - "github.com/cosmos/cosmos-sdk/store/prefix" - sdk "github.com/cosmos/cosmos-sdk/types" -) - -// UpsertDataRegistryEntry insert/updates a data registry entry. -func (k Keeper) UpsertDataRegistryEntry(ctx sdk.Context, key string, entry types.DataRegistryEntry) { - prefixStore := prefix.NewStore(ctx.KVStore(k.storeKey), DataRegistryPrefix) - - bz := k.cdc.MustMarshal(&entry) - prefixStore.Set([]byte(key), bz) -} - -// GetDataRegistryEntry returns the Entry of the registry by key. -func (k Keeper) GetDataRegistryEntry(ctx sdk.Context, key string) (types.DataRegistryEntry, bool) { - prefixStore := prefix.NewStore(ctx.KVStore(k.storeKey), DataRegistryPrefix) - - bz := prefixStore.Get([]byte(key)) - if bz == nil { - return types.DataRegistryEntry{}, false - } - - var na types.DataRegistryEntry - k.cdc.MustUnmarshal(bz, &na) - - return na, true -} - -// ListDataRegistryEntryKeys returns all keys of data registry -func (k Keeper) ListDataRegistryEntryKeys(ctx sdk.Context) []string { - var keys []string - - // get iterator for token aliases - store := ctx.KVStore(k.storeKey) - iterator := sdk.KVStorePrefixIterator(store, DataRegistryPrefix) - defer iterator.Close() - - for ; iterator.Valid(); iterator.Next() { - key := strings.TrimPrefix(string(iterator.Key()), string(DataRegistryPrefix)) - keys = append(keys, key) - } - - return keys -} - -// AllDataRegistry returns all of data registry -func (k Keeper) AllDataRegistry(ctx sdk.Context) map[string]*types.DataRegistryEntry { - var dataRegistry map[string]*types.DataRegistryEntry - - keys := k.ListDataRegistryEntryKeys(ctx) - - // get iterator for token aliases - store := ctx.KVStore(k.storeKey) - iterator := sdk.KVStorePrefixIterator(store, DataRegistryPrefix) - defer iterator.Close() - - for _, key := range keys { - entry, ok := k.GetDataRegistryEntry(ctx, key) - if ok { - dataRegistry[key] = &entry - } else { - dataRegistry[key] = nil - } - } - - return dataRegistry -} +package keeper + +import ( + "strings" + + "github.com/KiraCore/sekai/x/gov/types" + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// UpsertDataRegistryEntry insert/updates a data registry entry. +func (k Keeper) UpsertDataRegistryEntry(ctx sdk.Context, key string, entry types.DataRegistryEntry) { + prefixStore := prefix.NewStore(ctx.KVStore(k.storeKey), DataRegistryPrefix) + + bz := k.cdc.MustMarshal(&entry) + prefixStore.Set([]byte(key), bz) +} + +// GetDataRegistryEntry returns the Entry of the registry by key. +func (k Keeper) GetDataRegistryEntry(ctx sdk.Context, key string) (types.DataRegistryEntry, bool) { + prefixStore := prefix.NewStore(ctx.KVStore(k.storeKey), DataRegistryPrefix) + + bz := prefixStore.Get([]byte(key)) + if bz == nil { + return types.DataRegistryEntry{}, false + } + + var na types.DataRegistryEntry + k.cdc.MustUnmarshal(bz, &na) + + return na, true +} + +// ListDataRegistryEntryKeys returns all keys of data registry +func (k Keeper) ListDataRegistryEntryKeys(ctx sdk.Context) []string { + var keys []string + + // get iterator for token aliases + store := ctx.KVStore(k.storeKey) + iterator := sdk.KVStorePrefixIterator(store, DataRegistryPrefix) + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + key := strings.TrimPrefix(string(iterator.Key()), string(DataRegistryPrefix)) + keys = append(keys, key) + } + + return keys +} + +// AllDataRegistry returns all of data registry +func (k Keeper) AllDataRegistry(ctx sdk.Context) map[string]*types.DataRegistryEntry { + var dataRegistry map[string]*types.DataRegistryEntry + + keys := k.ListDataRegistryEntryKeys(ctx) + + // get iterator for token aliases + store := ctx.KVStore(k.storeKey) + iterator := sdk.KVStorePrefixIterator(store, DataRegistryPrefix) + defer iterator.Close() + + for _, key := range keys { + entry, ok := k.GetDataRegistryEntry(ctx, key) + if ok { + dataRegistry[key] = &entry + } else { + dataRegistry[key] = nil + } + } + + return dataRegistry +} diff --git a/x/gov/keeper/data_registry_test.go b/x/gov/keeper/data_registry_test.go index 8d34aac74..40a3bcd23 100644 --- a/x/gov/keeper/data_registry_test.go +++ b/x/gov/keeper/data_registry_test.go @@ -1,33 +1,33 @@ -package keeper_test - -import ( - "testing" - - "github.com/stretchr/testify/require" - - simapp "github.com/KiraCore/sekai/app" - "github.com/KiraCore/sekai/x/gov/types" - tmproto "github.com/tendermint/tendermint/proto/tendermint/types" -) - -func TestKeeper_UpsertDataRegistryEntry(t *testing.T) { - app := simapp.Setup(false) - ctx := app.NewContext(false, tmproto.Header{}) - - entry := types.NewDataRegistryEntry( - "someHAsh", - "someURL", - "someEncoding", - 1234, - ) - - app.CustomGovKeeper.UpsertDataRegistryEntry(ctx, "CodeOfConduct", entry) - - savedDataRegistry, found := app.CustomGovKeeper.GetDataRegistryEntry(ctx, "CodeOfConduct") - require.True(t, found) - - require.Equal(t, entry, savedDataRegistry) - - _, found = app.CustomGovKeeper.GetDataRegistryEntry(ctx, "NonExistingKey") - require.False(t, found) -} +package keeper_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + + simapp "github.com/KiraCore/sekai/app" + "github.com/KiraCore/sekai/x/gov/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" +) + +func TestKeeper_UpsertDataRegistryEntry(t *testing.T) { + app := simapp.Setup(false) + ctx := app.NewContext(false, tmproto.Header{}) + + entry := types.NewDataRegistryEntry( + "someHAsh", + "someURL", + "someEncoding", + 1234, + ) + + app.CustomGovKeeper.UpsertDataRegistryEntry(ctx, "CodeOfConduct", entry) + + savedDataRegistry, found := app.CustomGovKeeper.GetDataRegistryEntry(ctx, "CodeOfConduct") + require.True(t, found) + + require.Equal(t, entry, savedDataRegistry) + + _, found = app.CustomGovKeeper.GetDataRegistryEntry(ctx, "NonExistingKey") + require.False(t, found) +} diff --git a/x/gov/keeper/grpc_query.go b/x/gov/keeper/grpc_query.go index f8ced6efe..7d52af087 100644 --- a/x/gov/keeper/grpc_query.go +++ b/x/gov/keeper/grpc_query.go @@ -18,6 +18,15 @@ import ( var _ types.QueryServer = Keeper{} +func (k Keeper) PollsVotesByPollId(goCtx context.Context, request *types.QueryPollsVotesByPollId) (*types.QueryPollsVotesByPollIdResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + votes := k.GetPollVotes(ctx, request.PollId) + + return &types.QueryPollsVotesByPollIdResponse{ + Votes: votes, + }, nil +} + // AllRoles return all roles registered func (k Keeper) AllRoles(goCtx context.Context, request *types.AllRolesRequest) (*types.AllRolesResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) @@ -38,6 +47,20 @@ func (k Keeper) AllRoles(goCtx context.Context, request *types.AllRolesRequest) }, nil } +// PollsListByAddress return polls associated to an address +func (k Keeper) PollsListByAddress(goCtx context.Context, request *types.QueryPollsListByAddress) (*types.QueryPollsListByAddressResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + polls, err := k.GetPollsByAddress(ctx, request.Creator) + + if err != nil { + return nil, err + } + + return &types.QueryPollsListByAddressResponse{ + Polls: polls, + }, nil +} + // RolesByAddress return roles associated to an address func (k Keeper) RolesByAddress(goCtx context.Context, request *types.RolesByAddressRequest) (*types.RolesByAddressResponse, error) { addr, err := sdk.AccAddressFromBech32(request.Addr) @@ -676,9 +699,9 @@ func (k Keeper) ProposalDuration(goCtx context.Context, req *types.QueryProposal }, nil } -// QueryCouncilors - all councilors (waiting or not), including their corresponding statuses, +// Councilors - all councilors (waiting or not), including their corresponding statuses, // ranks & abstenation counters - add sub-query to search by specific KIRA address -func (k Keeper) QueryCouncilors(goCtx context.Context, req *types.QueryCouncilors) (*types.QueryCouncilorsResponse, error) { +func (k Keeper) Councilors(goCtx context.Context, req *types.QueryCouncilors) (*types.QueryCouncilorsResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) if req.Address == "" { @@ -700,8 +723,8 @@ func (k Keeper) QueryCouncilors(goCtx context.Context, req *types.QueryCouncilor }, nil } -// QueryNonCouncilors - list all governance members that are NOT Councilors -func (k Keeper) QueryNonCouncilors(goCtx context.Context, req *types.QueryNonCouncilors) (*types.QueryNonCouncilorsResponse, error) { +// NonCouncilors - list all governance members that are NOT Councilors +func (k Keeper) NonCouncilors(goCtx context.Context, req *types.QueryNonCouncilors) (*types.QueryNonCouncilorsResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) networkActorsIterator := k.GetNetworkActorsIterator(ctx) @@ -721,8 +744,8 @@ func (k Keeper) QueryNonCouncilors(goCtx context.Context, req *types.QueryNonCou }, nil } -// QueryAddressesByWhitelistedPermission - list all KIRA addresses by a specific whitelisted permission (address does NOT have to be a Councilor) -func (k Keeper) QueryAddressesByWhitelistedPermission(goCtx context.Context, req *types.QueryAddressesByWhitelistedPermission) (*types.QueryAddressesByWhitelistedPermissionResponse, error) { +// AddressesByWhitelistedPermission - list all KIRA addresses by a specific whitelisted permission (address does NOT have to be a Councilor) +func (k Keeper) AddressesByWhitelistedPermission(goCtx context.Context, req *types.QueryAddressesByWhitelistedPermission) (*types.QueryAddressesByWhitelistedPermissionResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) actors := k.GetNetworkActorsByAbsoluteWhitelistPermission(ctx, types.PermValue(req.Permission)) @@ -735,8 +758,8 @@ func (k Keeper) QueryAddressesByWhitelistedPermission(goCtx context.Context, req }, nil } -// QueryAddressesByBlacklistedPermission - list all KIRA addresses by a specific whitelisted permission (address does NOT have to be a Councilor) -func (k Keeper) QueryAddressesByBlacklistedPermission(goCtx context.Context, req *types.QueryAddressesByBlacklistedPermission) (*types.QueryAddressesByBlacklistedPermissionResponse, error) { +// AddressesByBlacklistedPermission - list all KIRA addresses by a specific whitelisted permission (address does NOT have to be a Councilor) +func (k Keeper) AddressesByBlacklistedPermission(goCtx context.Context, req *types.QueryAddressesByBlacklistedPermission) (*types.QueryAddressesByBlacklistedPermissionResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) networkActorsIterator := k.GetNetworkActorsIterator(ctx) @@ -755,14 +778,14 @@ func (k Keeper) QueryAddressesByBlacklistedPermission(goCtx context.Context, req }, nil } -// QueryAddressesByWhitelistedRole - list all kira addresses by a specific whitelisted role (address does NOT have to be a Councilor) -func (k Keeper) QueryAddressesByWhitelistedRole(goCtx context.Context, req *types.QueryAddressesByWhitelistedRole) (*types.QueryAddressesByWhitelistedRoleResponse, error) { +// AddressesByWhitelistedRole - list all kira addresses by a specific whitelisted role (address does NOT have to be a Councilor) +func (k Keeper) AddressesByWhitelistedRole(goCtx context.Context, req *types.QueryAddressesByWhitelistedRole) (*types.QueryAddressesByWhitelistedRoleResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) addrs := []string{} actorIter := k.GetNetworkActorsByRole(ctx, uint64(req.Role)) for ; actorIter.Valid(); actorIter.Next() { - actor := k.getNetworkActorOrFail(ctx, actorIter.Value()) + actor := k.GetNetworkActorOrFail(ctx, actorIter.Value()) addrs = append(addrs, actor.Address.String()) } diff --git a/x/gov/keeper/grpc_query_test.go b/x/gov/keeper/grpc_query_test.go index cdb3a1527..e41fa96e5 100644 --- a/x/gov/keeper/grpc_query_test.go +++ b/x/gov/keeper/grpc_query_test.go @@ -1,261 +1,261 @@ -package keeper_test - -import ( - "testing" - "time" - - stakingtypes "github.com/KiraCore/sekai/x/staking/types" - - "github.com/stretchr/testify/require" - - sdk "github.com/cosmos/cosmos-sdk/types" - tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - - simapp "github.com/KiraCore/sekai/app" - "github.com/KiraCore/sekai/x/gov/types" -) - -func TestQuerier_PermissionsByAddress(t *testing.T) { - app := simapp.Setup(false) - ctx := app.NewContext(false, tmproto.Header{}) - - addrs := simapp.AddTestAddrsIncremental(app, ctx, 2, sdk.TokensFromConsensusPower(10, sdk.DefaultPowerReduction)) - addr1 := addrs[0] - addr2 := addrs[1] - - permissions := types.NewPermissions( - []types.PermValue{ - types.PermClaimValidator, - }, - nil, - ) - - networkActor := types.NewNetworkActor( - addr1, - []uint64{}, - 1, - nil, - permissions, - 123, - ) - - app.CustomGovKeeper.SaveNetworkActor(ctx, networkActor) - - querier := app.CustomGovKeeper - resp, err := querier.PermissionsByAddress(sdk.WrapSDKContext(ctx), &types.PermissionsByAddressRequest{Addr: addr1.String()}) - require.NoError(t, err) - - require.Equal(t, permissions, resp.Permissions) - - // Get permissions by address that is not saved. - _, err = querier.PermissionsByAddress(sdk.WrapSDKContext(ctx), &types.PermissionsByAddressRequest{Addr: addr2.String()}) - require.EqualError(t, err, stakingtypes.ErrNetworkActorNotFound.Error()) -} - -func TestQuerier_RolesByAddress(t *testing.T) { - app := simapp.Setup(false) - ctx := app.NewContext(false, tmproto.Header{}) - - addrs := simapp.AddTestAddrsIncremental(app, ctx, 2, sdk.TokensFromConsensusPower(10, sdk.DefaultPowerReduction)) - addr1 := addrs[0] - addr2 := addrs[1] - - networkActor := types.NewNetworkActor( - addr1, - []uint64{ - 1, 2, 3, - }, - 1, - nil, - types.NewPermissions( - []types.PermValue{ - types.PermClaimValidator, - }, - nil, - ), - 123, - ) - - app.CustomGovKeeper.SaveNetworkActor(ctx, networkActor) - - querier := app.CustomGovKeeper - - resp, err := querier.RolesByAddress(sdk.WrapSDKContext(ctx), &types.RolesByAddressRequest{Addr: addr1.String()}) - require.NoError(t, err) - - require.Equal(t, - []uint64{0x1, 0x2, 0x3}, - resp.RoleIds, - ) - - // Get roles for actor that does not exist - _, err = querier.RolesByAddress(sdk.WrapSDKContext(ctx), &types.RolesByAddressRequest{Addr: addr2.String()}) - require.EqualError(t, err, "network actor not found") -} - -func TestQuerier_Proposal(t *testing.T) { - app := simapp.Setup(false) - ctx := app.NewContext(false, tmproto.Header{}) - - addrs := simapp.AddTestAddrsIncremental(app, ctx, 2, sdk.TokensFromConsensusPower(10, sdk.DefaultPowerReduction)) - - proposalID := uint64(1234) - proposal, err := types.NewProposal( - proposalID, - "title", - "some desc", - types.NewWhitelistAccountPermissionProposal( - addrs[0], - types.PermSetPermissions, - ), - time.Now(), - time.Now().Add(10*time.Second), - time.Now().Add(20*time.Second), - ctx.BlockHeight()+2, - ctx.BlockHeight()+3, - ) - require.NoError(t, err) - - app.CustomGovKeeper.SaveProposal(ctx, proposal) - - app.CustomGovKeeper.SaveVote(ctx, types.Vote{ - ProposalId: proposalID, - Voter: addrs[0], - Option: types.OptionNo, - }) - - querier := app.CustomGovKeeper - - resp, err := querier.Proposal( - sdk.WrapSDKContext(ctx), - &types.QueryProposalRequest{ProposalId: proposalID}, - ) - require.NoError(t, err) - require.Equal(t, proposalID, resp.Proposal.ProposalId) - require.Len(t, resp.Votes, 1) - require.Equal(t, proposal.Description, resp.Proposal.Description) -} - -func TestQuerier_CouncilorByAddress(t *testing.T) { - app := simapp.Setup(false) - ctx := app.NewContext(false, tmproto.Header{}) - - addrs := simapp.AddTestAddrsIncremental(app, ctx, 2, sdk.TokensFromConsensusPower(10, sdk.DefaultPowerReduction)) - addr1 := addrs[0] - addr2 := addrs[1] - - councilor := types.NewCouncilor( - addr1, - types.CouncilorActive, - ) - - app.CustomGovKeeper.SaveCouncilor(ctx, councilor) - - querier := app.CustomGovKeeper - - resp, err := querier.CouncilorByAddress( - sdk.WrapSDKContext(ctx), - &types.CouncilorByAddressRequest{Addr: addr1.String()}, - ) - require.NoError(t, err) - require.Equal(t, councilor, resp.Councilor) - - // Non existing Councilor - resp, err = querier.CouncilorByAddress( - sdk.WrapSDKContext(ctx), - &types.CouncilorByAddressRequest{Addr: addr2.String()}, - ) - require.Error(t, types.ErrCouncilorNotFound) -} - -func TestQuerier_CouncilorQueries(t *testing.T) { - app := simapp.Setup(false) - ctx := app.NewContext(false, tmproto.Header{}) - - addrs := simapp.AddTestAddrsIncremental(app, ctx, 2, sdk.TokensFromConsensusPower(10, sdk.DefaultPowerReduction)) - addr1 := addrs[0] - addr2 := addrs[1] - - councilor := types.NewCouncilor( - addr1, - types.CouncilorActive, - ) - - app.CustomGovKeeper.SaveCouncilor(ctx, councilor) - - networkActor := types.NewNetworkActor( - addr2, - []uint64{types.RoleSudo}, - 1, - nil, - types.NewPermissions( - []types.PermValue{ - types.PermClaimValidator, - }, - []types.PermValue{ - types.PermClaimCouncilor, - }, - ), - 123, - ) - app.CustomGovKeeper.SaveNetworkActor(ctx, networkActor) - for _, perm := range networkActor.Permissions.Whitelist { - app.CustomGovKeeper.SetWhitelistAddressPermKey(ctx, networkActor, types.PermValue(perm)) - } - for _, role := range networkActor.Roles { - app.CustomGovKeeper.AssignRoleToActor(ctx, networkActor, role) - } - - querier := app.CustomGovKeeper - - // specific councilor - resp, err := querier.QueryCouncilors( - sdk.WrapSDKContext(ctx), - &types.QueryCouncilors{Address: addr1.String()}, - ) - require.NoError(t, err) - require.Len(t, resp.Councilors, 1) - require.Equal(t, councilor, resp.Councilors[0]) - - // all councilors - resp, err = querier.QueryCouncilors( - sdk.WrapSDKContext(ctx), - &types.QueryCouncilors{}, - ) - require.NoError(t, err) - require.Len(t, resp.Councilors, 1) - require.Equal(t, councilor, resp.Councilors[0]) - - // non-councilors - nresp, err := querier.QueryNonCouncilors( - sdk.WrapSDKContext(ctx), - &types.QueryNonCouncilors{}, - ) - require.NoError(t, err) - require.Len(t, nresp.NonCouncilors, 1) - require.Equal(t, networkActor, nresp.NonCouncilors[0]) - - wresp, err := querier.QueryAddressesByWhitelistedPermission( - sdk.WrapSDKContext(ctx), - &types.QueryAddressesByWhitelistedPermission{Permission: uint32(types.PermClaimValidator)}, - ) - require.NoError(t, err) - require.Len(t, wresp.Addresses, 1) - require.Equal(t, addr2.String(), wresp.Addresses[0]) - - bresp, err := querier.QueryAddressesByBlacklistedPermission( - sdk.WrapSDKContext(ctx), - &types.QueryAddressesByBlacklistedPermission{Permission: uint32(types.PermClaimCouncilor)}, - ) - require.NoError(t, err) - require.Len(t, bresp.Addresses, 1) - require.Equal(t, addr2.String(), bresp.Addresses[0]) - - rresp, err := querier.QueryAddressesByWhitelistedRole( - sdk.WrapSDKContext(ctx), - &types.QueryAddressesByWhitelistedRole{Role: uint32(types.RoleSudo)}, - ) - require.NoError(t, err) - require.Len(t, rresp.Addresses, 1) - require.Equal(t, addr2.String(), rresp.Addresses[0]) -} +package keeper_test + +import ( + "testing" + "time" + + stakingtypes "github.com/KiraCore/sekai/x/staking/types" + + "github.com/stretchr/testify/require" + + sdk "github.com/cosmos/cosmos-sdk/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + + simapp "github.com/KiraCore/sekai/app" + "github.com/KiraCore/sekai/x/gov/types" +) + +func TestQuerier_PermissionsByAddress(t *testing.T) { + app := simapp.Setup(false) + ctx := app.NewContext(false, tmproto.Header{}) + + addrs := simapp.AddTestAddrsIncremental(app, ctx, 2, sdk.TokensFromConsensusPower(10, sdk.DefaultPowerReduction)) + addr1 := addrs[0] + addr2 := addrs[1] + + permissions := types.NewPermissions( + []types.PermValue{ + types.PermClaimValidator, + }, + nil, + ) + + networkActor := types.NewNetworkActor( + addr1, + []uint64{}, + 1, + nil, + permissions, + 123, + ) + + app.CustomGovKeeper.SaveNetworkActor(ctx, networkActor) + + querier := app.CustomGovKeeper + resp, err := querier.PermissionsByAddress(sdk.WrapSDKContext(ctx), &types.PermissionsByAddressRequest{Addr: addr1.String()}) + require.NoError(t, err) + + require.Equal(t, permissions, resp.Permissions) + + // Get permissions by address that is not saved. + _, err = querier.PermissionsByAddress(sdk.WrapSDKContext(ctx), &types.PermissionsByAddressRequest{Addr: addr2.String()}) + require.EqualError(t, err, stakingtypes.ErrNetworkActorNotFound.Error()) +} + +func TestQuerier_RolesByAddress(t *testing.T) { + app := simapp.Setup(false) + ctx := app.NewContext(false, tmproto.Header{}) + + addrs := simapp.AddTestAddrsIncremental(app, ctx, 2, sdk.TokensFromConsensusPower(10, sdk.DefaultPowerReduction)) + addr1 := addrs[0] + addr2 := addrs[1] + + networkActor := types.NewNetworkActor( + addr1, + []uint64{ + 1, 2, 3, + }, + 1, + nil, + types.NewPermissions( + []types.PermValue{ + types.PermClaimValidator, + }, + nil, + ), + 123, + ) + + app.CustomGovKeeper.SaveNetworkActor(ctx, networkActor) + + querier := app.CustomGovKeeper + + resp, err := querier.RolesByAddress(sdk.WrapSDKContext(ctx), &types.RolesByAddressRequest{Addr: addr1.String()}) + require.NoError(t, err) + + require.Equal(t, + []uint64{0x1, 0x2, 0x3}, + resp.RoleIds, + ) + + // Get roles for actor that does not exist + _, err = querier.RolesByAddress(sdk.WrapSDKContext(ctx), &types.RolesByAddressRequest{Addr: addr2.String()}) + require.EqualError(t, err, "network actor not found") +} + +func TestQuerier_Proposal(t *testing.T) { + app := simapp.Setup(false) + ctx := app.NewContext(false, tmproto.Header{}) + + addrs := simapp.AddTestAddrsIncremental(app, ctx, 2, sdk.TokensFromConsensusPower(10, sdk.DefaultPowerReduction)) + + proposalID := uint64(1234) + proposal, err := types.NewProposal( + proposalID, + "title", + "some desc", + types.NewWhitelistAccountPermissionProposal( + addrs[0], + types.PermSetPermissions, + ), + time.Now(), + time.Now().Add(10*time.Second), + time.Now().Add(20*time.Second), + ctx.BlockHeight()+2, + ctx.BlockHeight()+3, + ) + require.NoError(t, err) + + app.CustomGovKeeper.SaveProposal(ctx, proposal) + + app.CustomGovKeeper.SaveVote(ctx, types.Vote{ + ProposalId: proposalID, + Voter: addrs[0], + Option: types.OptionNo, + }) + + querier := app.CustomGovKeeper + + resp, err := querier.Proposal( + sdk.WrapSDKContext(ctx), + &types.QueryProposalRequest{ProposalId: proposalID}, + ) + require.NoError(t, err) + require.Equal(t, proposalID, resp.Proposal.ProposalId) + require.Len(t, resp.Votes, 1) + require.Equal(t, proposal.Description, resp.Proposal.Description) +} + +func TestQuerier_CouncilorByAddress(t *testing.T) { + app := simapp.Setup(false) + ctx := app.NewContext(false, tmproto.Header{}) + + addrs := simapp.AddTestAddrsIncremental(app, ctx, 2, sdk.TokensFromConsensusPower(10, sdk.DefaultPowerReduction)) + addr1 := addrs[0] + addr2 := addrs[1] + + councilor := types.NewCouncilor( + addr1, + types.CouncilorActive, + ) + + app.CustomGovKeeper.SaveCouncilor(ctx, councilor) + + querier := app.CustomGovKeeper + + resp, err := querier.CouncilorByAddress( + sdk.WrapSDKContext(ctx), + &types.CouncilorByAddressRequest{Addr: addr1.String()}, + ) + require.NoError(t, err) + require.Equal(t, councilor, resp.Councilor) + + // Non existing Councilor + resp, err = querier.CouncilorByAddress( + sdk.WrapSDKContext(ctx), + &types.CouncilorByAddressRequest{Addr: addr2.String()}, + ) + require.Error(t, types.ErrCouncilorNotFound) +} + +func TestQuerier_CouncilorQueries(t *testing.T) { + app := simapp.Setup(false) + ctx := app.NewContext(false, tmproto.Header{}) + + addrs := simapp.AddTestAddrsIncremental(app, ctx, 2, sdk.TokensFromConsensusPower(10, sdk.DefaultPowerReduction)) + addr1 := addrs[0] + addr2 := addrs[1] + + councilor := types.NewCouncilor( + addr1, + types.CouncilorActive, + ) + + app.CustomGovKeeper.SaveCouncilor(ctx, councilor) + + networkActor := types.NewNetworkActor( + addr2, + []uint64{types.RoleSudo}, + 1, + nil, + types.NewPermissions( + []types.PermValue{ + types.PermClaimValidator, + }, + []types.PermValue{ + types.PermClaimCouncilor, + }, + ), + 123, + ) + app.CustomGovKeeper.SaveNetworkActor(ctx, networkActor) + for _, perm := range networkActor.Permissions.Whitelist { + app.CustomGovKeeper.SetWhitelistAddressPermKey(ctx, networkActor, types.PermValue(perm)) + } + for _, role := range networkActor.Roles { + app.CustomGovKeeper.AssignRoleToActor(ctx, networkActor, role) + } + + querier := app.CustomGovKeeper + + // specific councilor + resp, err := querier.Councilors( + sdk.WrapSDKContext(ctx), + &types.QueryCouncilors{Address: addr1.String()}, + ) + require.NoError(t, err) + require.Len(t, resp.Councilors, 1) + require.Equal(t, councilor, resp.Councilors[0]) + + // all councilors + resp, err = querier.Councilors( + sdk.WrapSDKContext(ctx), + &types.QueryCouncilors{}, + ) + require.NoError(t, err) + require.Len(t, resp.Councilors, 1) + require.Equal(t, councilor, resp.Councilors[0]) + + // non-councilors + nresp, err := querier.NonCouncilors( + sdk.WrapSDKContext(ctx), + &types.QueryNonCouncilors{}, + ) + require.NoError(t, err) + require.Len(t, nresp.NonCouncilors, 1) + require.Equal(t, networkActor, nresp.NonCouncilors[0]) + + wresp, err := querier.AddressesByWhitelistedPermission( + sdk.WrapSDKContext(ctx), + &types.QueryAddressesByWhitelistedPermission{Permission: uint32(types.PermClaimValidator)}, + ) + require.NoError(t, err) + require.Len(t, wresp.Addresses, 1) + require.Equal(t, addr2.String(), wresp.Addresses[0]) + + bresp, err := querier.AddressesByBlacklistedPermission( + sdk.WrapSDKContext(ctx), + &types.QueryAddressesByBlacklistedPermission{Permission: uint32(types.PermClaimCouncilor)}, + ) + require.NoError(t, err) + require.Len(t, bresp.Addresses, 1) + require.Equal(t, addr2.String(), bresp.Addresses[0]) + + rresp, err := querier.AddressesByWhitelistedRole( + sdk.WrapSDKContext(ctx), + &types.QueryAddressesByWhitelistedRole{Role: uint32(types.RoleSudo)}, + ) + require.NoError(t, err) + require.Len(t, rresp.Addresses, 1) + require.Equal(t, addr2.String(), rresp.Addresses[0]) +} diff --git a/x/gov/keeper/identity_registrar.go b/x/gov/keeper/identity_registrar.go index 33da8736d..15c41ebe8 100644 --- a/x/gov/keeper/identity_registrar.go +++ b/x/gov/keeper/identity_registrar.go @@ -1,550 +1,550 @@ -package keeper - -import ( - "bytes" - "errors" - "fmt" - "regexp" - "strings" - "time" - - "github.com/KiraCore/sekai/x/gov/types" - stakingtypes "github.com/KiraCore/sekai/x/staking/types" - "github.com/cosmos/cosmos-sdk/store/prefix" - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" -) - -func ValidateIdentityRecordKey(key string) bool { - regex := regexp.MustCompile(`^[a-zA-Z][_0-9a-zA-Z]*$`) - return regex.MatchString(key) -} - -func FormalizeIdentityRecordKey(key string) string { - return strings.ToLower(key) -} - -func CheckIfWithinStringArray(key string, keys []string) bool { - for _, k := range keys { - if k == key { - return true - } - } - return false -} - -func CheckIfWithinAddressArray(addr sdk.AccAddress, array []sdk.AccAddress) bool { - for _, itemAddr := range array { - if bytes.Equal(addr, itemAddr) { - return true - } - } - return false -} - -func (k Keeper) GetLastIdentityRecordId(ctx sdk.Context) uint64 { - store := ctx.KVStore(k.storeKey) - - bz := store.Get(types.KeyLastIdentityRecordId) - if bz == nil { - return 0 - } - - return sdk.BigEndianToUint64(bz) -} - -func (k Keeper) SetLastIdentityRecordId(ctx sdk.Context, id uint64) { - store := ctx.KVStore(k.storeKey) - store.Set(types.KeyLastIdentityRecordId, sdk.Uint64ToBigEndian(id)) -} - -func (k Keeper) GetLastIdRecordVerifyRequestId(ctx sdk.Context) uint64 { - store := ctx.KVStore(k.storeKey) - - bz := store.Get(types.KeyLastIdRecordVerifyRequestId) - if bz == nil { - return 0 - } - - return sdk.BigEndianToUint64(bz) -} - -func (k Keeper) SetLastIdRecordVerifyRequestId(ctx sdk.Context, id uint64) { - store := ctx.KVStore(k.storeKey) - store.Set(types.KeyLastIdRecordVerifyRequestId, sdk.Uint64ToBigEndian(id)) -} - -// SetIdentityRecord defines a method to set identity record -func (k Keeper) SetIdentityRecord(ctx sdk.Context, record types.IdentityRecord) { - // validate key - if !ValidateIdentityRecordKey(record.Key) { - panic("identity record key is invalid") - } - properties := k.GetNetworkProperties(ctx) - uniqueKeys := strings.Split(properties.UniqueIdentityKeys, ",") - if CheckIfWithinStringArray(record.Key, uniqueKeys) { - addrs := k.GetAddressesByIdRecordKey(ctx, record.Key, record.Value) - if len(addrs) == 1 && addrs[0].String() == record.Address { - - } else if len(addrs) > 0 { - panic(fmt.Sprintf("the key %s, value %s is already registered by %s", record.Key, record.Value, addrs[0].String())) - } - } - // set the key to non case-sensitive - record.Key = FormalizeIdentityRecordKey(record.Key) - - prefixStore := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefixIdentityRecord) - bz := k.cdc.MustMarshal(&record) - prefixStore.Set(sdk.Uint64ToBigEndian(record.Id), bz) - - // connect address + key to id - store := ctx.KVStore(k.storeKey) - addrPrefixStore := prefix.NewStore(store, types.IdentityRecordByAddressPrefix(record.Address)) - addrPrefixStore.Set([]byte(record.Key), sdk.Uint64ToBigEndian(record.Id)) -} - -func (k Keeper) GetIdentityRecordById(ctx sdk.Context, recordId uint64) *types.IdentityRecord { - record := types.IdentityRecord{} - - prefixStore := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefixIdentityRecord) - bz := prefixStore.Get(sdk.Uint64ToBigEndian(recordId)) - if bz == nil { - return nil - } - k.cdc.MustUnmarshal(bz, &record) - return &record -} - -// Get identity record id by address and key -func (k Keeper) GetIdentityRecordIdByAddressKey(ctx sdk.Context, address sdk.AccAddress, key string) uint64 { - // validate key - if !ValidateIdentityRecordKey(key) { - return 0 - } - // set the key to non case-sensitive - key = FormalizeIdentityRecordKey(key) - - store := ctx.KVStore(k.storeKey) - prefixStore := prefix.NewStore(store, types.IdentityRecordByAddressPrefix(address.String())) - recordIdBytes := prefixStore.Get([]byte(key)) - if recordIdBytes == nil { - return 0 - } - return sdk.BigEndianToUint64(recordIdBytes) -} - -// DeleteIdentityRecord defines a method to delete identity record by id -func (k Keeper) DeleteIdentityRecordById(ctx sdk.Context, recordId uint64) { - record := k.GetIdentityRecordById(ctx, recordId) - if record == nil { - return - } - recordKey := sdk.Uint64ToBigEndian(recordId) - prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefixIdentityRecord).Delete(recordKey) - prefix.NewStore(ctx.KVStore(k.storeKey), types.IdentityRecordByAddressPrefix(record.Address)).Delete(sdk.Uint64ToBigEndian(recordId)) -} - -// RegisterIdentityRecord defines a method to register identity records for an address -func (k Keeper) RegisterIdentityRecords(ctx sdk.Context, address sdk.AccAddress, infos []types.IdentityInfoEntry) error { - // validate key and set the key to non case-sensitive - properties := k.GetNetworkProperties(ctx) - uniqueKeys := strings.Split(properties.UniqueIdentityKeys, ",") - for i, info := range infos { - if !ValidateIdentityRecordKey(info.Key) { - return sdkerrors.Wrap(types.ErrInvalidIdentityRecordKey, fmt.Sprintf("invalid key exists: key=%s", info.Key)) - } - infos[i].Key = FormalizeIdentityRecordKey(info.Key) - - if infos[i].Key == "moniker" && len(infos[i].Info) > 32 { - return stakingtypes.ErrInvalidMonikerLength - } - if infos[i].Key == "username" && len(infos[i].Info) > 32 { - return stakingtypes.ErrInvalidUsernameLength - } - - // check when the user is councilor - _, found := k.GetCouncilor(ctx, address) - if found { - monikerRecordId := k.GetIdentityRecordIdByAddressKey(ctx, address, "moniker") - usernameRecordId := k.GetIdentityRecordIdByAddressKey(ctx, address, "username") - moniker := k.GetIdentityRecordById(ctx, monikerRecordId) - username := k.GetIdentityRecordById(ctx, usernameRecordId) - if infos[i].Key == "moniker" && moniker != nil && infos[i].Info != moniker.Value { - return types.ErrCouncilorMonikerNotAllowedToBeChanged - } - if infos[i].Key == "username" && username != nil && infos[i].Info != username.Value { - return types.ErrCouncilorUsernameNotAllowedToBeChanged - } - } - - if CheckIfWithinStringArray(infos[i].Key, uniqueKeys) { - addrs := k.GetAddressesByIdRecordKey(ctx, infos[i].Key, infos[i].Info) - if len(addrs) == 1 && bytes.Equal(addrs[0], address) { - - } else if len(addrs) > 0 { - return sdkerrors.Wrap(types.ErrKeyShouldBeUnique, fmt.Sprintf("the key %s, value %s is already registered by %s", infos[i].Key, infos[i].Info, addrs[0].String())) - } - } - } - - for _, info := range infos { - // use existing record id if it already exists - recordId := k.GetIdentityRecordIdByAddressKey(ctx, address, info.Key) - if recordId == 0 { - recordId = k.GetLastIdentityRecordId(ctx) + 1 - k.SetLastIdentityRecordId(ctx, recordId) - } - // create or update identity record - k.SetIdentityRecord(ctx, types.IdentityRecord{ - Id: recordId, - Address: address.String(), - Key: info.Key, - Value: info.Info, - Date: ctx.BlockTime(), - Verifiers: []string{}, - }) - } - return nil -} - -// DeleteIdentityRecords defines a method to delete identity records owned by an address -func (k Keeper) DeleteIdentityRecords(ctx sdk.Context, address sdk.AccAddress, keys []string) error { - // validate key and set the key to non case-sensitive - for i, key := range keys { - if !ValidateIdentityRecordKey(key) { - return sdkerrors.Wrap(types.ErrInvalidIdentityRecordKey, fmt.Sprintf("invalid key exists: key=%s", key)) - } - keys[i] = FormalizeIdentityRecordKey(key) - - // we prevent deleting moniker field of a validator - if key == "moniker" { - return sdkerrors.Wrap(types.ErrMonikerDeletionNotAllowed, fmt.Sprintf("moniker field is not allowed to delete")) - } - } - - store := ctx.KVStore(k.storeKey) - prefix := types.IdentityRecordByAddressPrefix(address.String()) - iterator := sdk.KVStorePrefixIterator(store, prefix) - defer iterator.Close() - - keyMap := make(map[string]bool) - for _, key := range keys { - keyMap[key] = true - } - recordIds := []uint64{} - for ; iterator.Valid(); iterator.Next() { - key := bytes.TrimPrefix(iterator.Key(), prefix) - if len(keys) == 0 || keyMap[string(key)] { - // if no specific keys are provided remove all - // invalid keys are ignored - recordIds = append(recordIds, sdk.BigEndianToUint64(iterator.Value())) - store.Delete(iterator.Key()) - } - } - - for _, recordId := range recordIds { - prevRecord := k.GetIdentityRecordById(ctx, recordId) - if prevRecord == nil { - return sdkerrors.Wrap(types.ErrInvalidIdentityRecordId, fmt.Sprintf("identity record with specified id does NOT exist: id=%d", recordId)) - } - - k.DeleteIdentityRecordById(ctx, recordId) - } - - return nil -} - -// GetAllIdentityRecords query all identity records -func (k Keeper) GetAllIdentityRecords(ctx sdk.Context) []types.IdentityRecord { - records := []types.IdentityRecord{} - store := ctx.KVStore(k.storeKey) - iterator := sdk.KVStorePrefixIterator(store, types.KeyPrefixIdentityRecord) - defer iterator.Close() - - for ; iterator.Valid(); iterator.Next() { - record := types.IdentityRecord{} - k.cdc.MustUnmarshal(iterator.Value(), &record) - records = append(records, record) - } - - return records -} - -// GetIdRecordsByAddressAndKeys query identity record by address and keys -func (k Keeper) GetIdRecordsByAddressAndKeys(ctx sdk.Context, address sdk.AccAddress, keys []string) ([]types.IdentityRecord, error) { - // validate key and set the key to non case-sensitive - for i, key := range keys { - if !ValidateIdentityRecordKey(key) { - return []types.IdentityRecord{}, sdkerrors.Wrap(types.ErrInvalidIdentityRecordKey, fmt.Sprintf("invalid key exists: key=%s", key)) - } - keys[i] = FormalizeIdentityRecordKey(key) - } - - if len(keys) == 0 { - return k.GetIdRecordsByAddress(ctx, address), nil - } - - store := ctx.KVStore(k.storeKey) - prefixStore := prefix.NewStore(store, types.IdentityRecordByAddressPrefix(address.String())) - - records := []types.IdentityRecord{} - for _, key := range keys { - bz := prefixStore.Get([]byte(key)) - recordId := sdk.BigEndianToUint64(bz) - record := k.GetIdentityRecordById(ctx, recordId) - if record == nil { - return records, sdkerrors.Wrap(types.ErrInvalidIdentityRecordId, fmt.Sprintf("identity record with specified id does NOT exist: id=%d", recordId)) - } - records = append(records, *record) - } - return records, nil -} - -func (k Keeper) GetAddressesByIdRecordKey(ctx sdk.Context, key, value string) []sdk.AccAddress { - addrs := []sdk.AccAddress{} - for _, record := range k.GetAllIdentityRecords(ctx) { - if record.Key == key && record.Value == value { - addr, err := sdk.AccAddressFromBech32(record.Address) - if err != nil { - panic(err) - } - addrs = append(addrs, addr) - } - } - return addrs -} - -// GetIdRecordsByAddress query identity record by address -func (k Keeper) GetIdRecordsByAddress(ctx sdk.Context, address sdk.AccAddress) []types.IdentityRecord { - store := ctx.KVStore(k.storeKey) - prefix := types.IdentityRecordByAddressPrefix(address.String()) - iterator := sdk.KVStorePrefixIterator(store, prefix) - defer iterator.Close() - - records := []types.IdentityRecord{} - for ; iterator.Valid(); iterator.Next() { - recordId := sdk.BigEndianToUint64(iterator.Value()) - record := k.GetIdentityRecordById(ctx, recordId) - if record == nil { - panic(fmt.Sprintf("invalid recordId exists: recordId = %d, key=%s, value=%s", recordId, string(iterator.Key()), string(iterator.Value()))) - } - records = append(records, *record) - } - return records -} - -// SetIdentityRecordsVerifyRequest saves identity verify request into the store -func (k Keeper) SetIdentityRecordsVerifyRequest(ctx sdk.Context, request types.IdentityRecordsVerify) { - requestId := request.Id - bz := k.cdc.MustMarshal(&request) - prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefixIdRecordVerifyRequest).Set(sdk.Uint64ToBigEndian(requestId), bz) - prefix.NewStore( - ctx.KVStore(k.storeKey), - types.IdRecordVerifyRequestByRequesterPrefix(request.Address), - ).Set(sdk.Uint64ToBigEndian(requestId), sdk.Uint64ToBigEndian(requestId)) - prefix.NewStore( - ctx.KVStore(k.storeKey), - types.IdRecordVerifyRequestByApproverPrefix(request.Verifier), - ).Set(sdk.Uint64ToBigEndian(requestId), sdk.Uint64ToBigEndian(requestId)) -} - -// RequestIdentityRecordsVerify defines a method to request verify request from specific verifier -func (k Keeper) RequestIdentityRecordsVerify(ctx sdk.Context, address, verifier sdk.AccAddress, recordIds []uint64, tip sdk.Coin) (uint64, error) { - requestId := k.GetLastIdRecordVerifyRequestId(ctx) + 1 - - lastRecordEditDate := time.Time{} - for _, recordId := range recordIds { - record := k.GetIdentityRecordById(ctx, recordId) - if record == nil { - return requestId, sdkerrors.Wrap(types.ErrInvalidIdentityRecordId, fmt.Sprintf("identity record with specified id does NOT exist: id=%d", recordId)) - } - if lastRecordEditDate.Before(record.Date) { - lastRecordEditDate = record.Date - } - } - - request := types.IdentityRecordsVerify{ - Id: requestId, - Address: address.String(), - Verifier: verifier.String(), - RecordIds: recordIds, - Tip: tip, - LastRecordEditDate: lastRecordEditDate, - } - - minApprovalTip := k.GetNetworkProperties(ctx).MinIdentityApprovalTip - if sdk.NewInt(int64(minApprovalTip)).GT(tip.Amount) { - return requestId, sdkerrors.Wrap(types.ErrInvalidApprovalTip, fmt.Sprintf("approval tip is lower than minimum tip configured by the network")) - } - - k.SetIdentityRecordsVerifyRequest(ctx, request) - k.SetLastIdRecordVerifyRequestId(ctx, requestId) - - if !tip.Amount.IsZero() { - if err := k.bk.SendCoinsFromAccountToModule(ctx, address, types.ModuleName, sdk.Coins{tip}); err != nil { - return 0, err - } - } - return requestId, nil -} - -// GetIdRecordsVerifyRequest defines a method to get an identity records verify request by id -func (k Keeper) GetIdRecordsVerifyRequest(ctx sdk.Context, requestId uint64) *types.IdentityRecordsVerify { - request := types.IdentityRecordsVerify{} - - prefixStore := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefixIdRecordVerifyRequest) - bz := prefixStore.Get(sdk.Uint64ToBigEndian(requestId)) - if bz == nil { - return nil - } - k.cdc.MustUnmarshal(bz, &request) - return &request -} - -// DeleteIdRecordsVerifyRequest defines a method to get an identity records verify request by id -func (k Keeper) DeleteIdRecordsVerifyRequest(ctx sdk.Context, requestId uint64) { - request := k.GetIdRecordsVerifyRequest(ctx, requestId) - if request == nil { - return - } - prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefixIdRecordVerifyRequest).Delete(sdk.Uint64ToBigEndian(requestId)) - prefix.NewStore( - ctx.KVStore(k.storeKey), - types.IdRecordVerifyRequestByRequesterPrefix(request.Address), - ).Delete(sdk.Uint64ToBigEndian(requestId)) - prefix.NewStore( - ctx.KVStore(k.storeKey), - types.IdRecordVerifyRequestByApproverPrefix(request.Verifier), - ).Delete(sdk.Uint64ToBigEndian(requestId)) -} - -// ApproveIdentityRecords defines a method to accept or reject verification request -func (k Keeper) HandleIdentityRecordsVerifyRequest(ctx sdk.Context, verifier sdk.AccAddress, requestId uint64, approve bool) error { - request := k.GetIdRecordsVerifyRequest(ctx, requestId) - if request == nil { - return sdkerrors.Wrap(types.ErrInvalidVerifyRequestId, fmt.Sprintf("specified identity record verify request does NOT exist: id=%d", requestId)) - } - if verifier.String() != request.Verifier { - return errors.New("verifier does not match with requested") - } - - // send the balance regardless approve or reject - if !request.Tip.Amount.IsZero() { - if err := k.bk.SendCoinsFromModuleToAccount(ctx, types.ModuleName, verifier, sdk.Coins{request.Tip}); err != nil { - return err - } - } - - // automatically reject if last record edit date is incorrect - for _, recordId := range request.RecordIds { - record := k.GetIdentityRecordById(ctx, recordId) - if record == nil { - return sdkerrors.Wrap(types.ErrInvalidIdentityRecordId, fmt.Sprintf("identity record with specified id does NOT exist: id=%d", recordId)) - } - - if record.Date.After(request.LastRecordEditDate) { - approve = false - break - } - } - - if approve == false { - k.DeleteIdRecordsVerifyRequest(ctx, requestId) - return nil - } - - for _, recordId := range request.RecordIds { - record := k.GetIdentityRecordById(ctx, recordId) - if record == nil { - return sdkerrors.Wrap(types.ErrInvalidIdentityRecordId, fmt.Sprintf("identity record with specified id does NOT exist: id=%d", recordId)) - } - - // if already exist, skip - if CheckIfWithinStringArray(verifier.String(), record.Verifiers) { - continue - } - record.Verifiers = append(record.Verifiers, verifier.String()) - k.SetIdentityRecord(ctx, *record) - } - - k.DeleteIdRecordsVerifyRequest(ctx, requestId) - return nil -} - -// CancelIdentityRecordsVerifyRequest defines a method to cancel verification request -func (k Keeper) CancelIdentityRecordsVerifyRequest(ctx sdk.Context, executor sdk.AccAddress, requestId uint64) error { - request := k.GetIdRecordsVerifyRequest(ctx, requestId) - if request == nil { - return sdkerrors.Wrap(types.ErrInvalidVerifyRequestId, fmt.Sprintf("specified identity record verify request does NOT exist: id=%d", requestId)) - } - if executor.String() != request.Address { - return errors.New("executor is not identity record creator") - } - - if !request.Tip.Amount.IsZero() { - requester, err := sdk.AccAddressFromBech32(request.Address) - if err != nil { - return err - } - if err := k.bk.SendCoinsFromModuleToAccount(ctx, types.ModuleName, requester, sdk.Coins{request.Tip}); err != nil { - return err - } - } - - k.DeleteIdRecordsVerifyRequest(ctx, requestId) - return nil -} - -// GetIdRecordsVerifyRequestsByRequester query identity record verify requests by requester -func (k Keeper) GetIdRecordsVerifyRequestsByRequester(ctx sdk.Context, requester sdk.AccAddress) []types.IdentityRecordsVerify { - requests := []types.IdentityRecordsVerify{} - store := ctx.KVStore(k.storeKey) - iterator := sdk.KVStorePrefixIterator(store, types.IdRecordVerifyRequestByRequesterPrefix(requester.String())) - defer iterator.Close() - - for ; iterator.Valid(); iterator.Next() { - requestId := sdk.BigEndianToUint64(iterator.Value()) - request := k.GetIdRecordsVerifyRequest(ctx, requestId) - if request == nil { - panic(fmt.Errorf("invalid id available on requests: %d", requestId)) - } - requests = append(requests, *request) - } - - return requests -} - -// GetIdRecordsVerifyRequestsByApprover query identity records verify requests by approver -func (k Keeper) GetIdRecordsVerifyRequestsByApprover(ctx sdk.Context, requester sdk.AccAddress) []types.IdentityRecordsVerify { - requests := []types.IdentityRecordsVerify{} - store := ctx.KVStore(k.storeKey) - iterator := sdk.KVStorePrefixIterator(store, types.IdRecordVerifyRequestByApproverPrefix(requester.String())) - defer iterator.Close() - - for ; iterator.Valid(); iterator.Next() { - requestId := sdk.BigEndianToUint64(iterator.Value()) - request := k.GetIdRecordsVerifyRequest(ctx, requestId) - if request == nil { - panic(fmt.Errorf("invalid id available on requests: %d", requestId)) - } - requests = append(requests, *request) - } - - return requests -} - -// GetAllIdRecordsVerifyRequests query all identity records verify requests -func (k Keeper) GetAllIdRecordsVerifyRequests(ctx sdk.Context) []types.IdentityRecordsVerify { - requests := []types.IdentityRecordsVerify{} - store := ctx.KVStore(k.storeKey) - iterator := sdk.KVStorePrefixIterator(store, types.KeyPrefixIdRecordVerifyRequest) - defer iterator.Close() - - for ; iterator.Valid(); iterator.Next() { - request := types.IdentityRecordsVerify{} - k.cdc.MustUnmarshal(iterator.Value(), &request) - requests = append(requests, request) - } - - return requests -} +package keeper + +import ( + "bytes" + "errors" + "fmt" + "regexp" + "strings" + "time" + + "github.com/KiraCore/sekai/x/gov/types" + stakingtypes "github.com/KiraCore/sekai/x/staking/types" + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +func ValidateIdentityRecordKey(key string) bool { + regex := regexp.MustCompile(`^[a-zA-Z][_0-9a-zA-Z]*$`) + return regex.MatchString(key) +} + +func FormalizeIdentityRecordKey(key string) string { + return strings.ToLower(key) +} + +func CheckIfWithinStringArray(key string, keys []string) bool { + for _, k := range keys { + if k == key { + return true + } + } + return false +} + +func CheckIfWithinAddressArray(addr sdk.AccAddress, array []sdk.AccAddress) bool { + for _, itemAddr := range array { + if bytes.Equal(addr, itemAddr) { + return true + } + } + return false +} + +func (k Keeper) GetLastIdentityRecordId(ctx sdk.Context) uint64 { + store := ctx.KVStore(k.storeKey) + + bz := store.Get(types.KeyLastIdentityRecordId) + if bz == nil { + return 0 + } + + return sdk.BigEndianToUint64(bz) +} + +func (k Keeper) SetLastIdentityRecordId(ctx sdk.Context, id uint64) { + store := ctx.KVStore(k.storeKey) + store.Set(types.KeyLastIdentityRecordId, sdk.Uint64ToBigEndian(id)) +} + +func (k Keeper) GetLastIdRecordVerifyRequestId(ctx sdk.Context) uint64 { + store := ctx.KVStore(k.storeKey) + + bz := store.Get(types.KeyLastIdRecordVerifyRequestId) + if bz == nil { + return 0 + } + + return sdk.BigEndianToUint64(bz) +} + +func (k Keeper) SetLastIdRecordVerifyRequestId(ctx sdk.Context, id uint64) { + store := ctx.KVStore(k.storeKey) + store.Set(types.KeyLastIdRecordVerifyRequestId, sdk.Uint64ToBigEndian(id)) +} + +// SetIdentityRecord defines a method to set identity record +func (k Keeper) SetIdentityRecord(ctx sdk.Context, record types.IdentityRecord) { + // validate key + if !ValidateIdentityRecordKey(record.Key) { + panic("identity record key is invalid") + } + properties := k.GetNetworkProperties(ctx) + uniqueKeys := strings.Split(properties.UniqueIdentityKeys, ",") + if CheckIfWithinStringArray(record.Key, uniqueKeys) { + addrs := k.GetAddressesByIdRecordKey(ctx, record.Key, record.Value) + if len(addrs) == 1 && addrs[0].String() == record.Address { + + } else if len(addrs) > 0 { + panic(fmt.Sprintf("the key %s, value %s is already registered by %s", record.Key, record.Value, addrs[0].String())) + } + } + // set the key to non case-sensitive + record.Key = FormalizeIdentityRecordKey(record.Key) + + prefixStore := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefixIdentityRecord) + bz := k.cdc.MustMarshal(&record) + prefixStore.Set(sdk.Uint64ToBigEndian(record.Id), bz) + + // connect address + key to id + store := ctx.KVStore(k.storeKey) + addrPrefixStore := prefix.NewStore(store, types.IdentityRecordByAddressPrefix(record.Address)) + addrPrefixStore.Set([]byte(record.Key), sdk.Uint64ToBigEndian(record.Id)) +} + +func (k Keeper) GetIdentityRecordById(ctx sdk.Context, recordId uint64) *types.IdentityRecord { + record := types.IdentityRecord{} + + prefixStore := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefixIdentityRecord) + bz := prefixStore.Get(sdk.Uint64ToBigEndian(recordId)) + if bz == nil { + return nil + } + k.cdc.MustUnmarshal(bz, &record) + return &record +} + +// Get identity record id by address and key +func (k Keeper) GetIdentityRecordIdByAddressKey(ctx sdk.Context, address sdk.AccAddress, key string) uint64 { + // validate key + if !ValidateIdentityRecordKey(key) { + return 0 + } + // set the key to non case-sensitive + key = FormalizeIdentityRecordKey(key) + + store := ctx.KVStore(k.storeKey) + prefixStore := prefix.NewStore(store, types.IdentityRecordByAddressPrefix(address.String())) + recordIdBytes := prefixStore.Get([]byte(key)) + if recordIdBytes == nil { + return 0 + } + return sdk.BigEndianToUint64(recordIdBytes) +} + +// DeleteIdentityRecord defines a method to delete identity record by id +func (k Keeper) DeleteIdentityRecordById(ctx sdk.Context, recordId uint64) { + record := k.GetIdentityRecordById(ctx, recordId) + if record == nil { + return + } + recordKey := sdk.Uint64ToBigEndian(recordId) + prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefixIdentityRecord).Delete(recordKey) + prefix.NewStore(ctx.KVStore(k.storeKey), types.IdentityRecordByAddressPrefix(record.Address)).Delete(sdk.Uint64ToBigEndian(recordId)) +} + +// RegisterIdentityRecord defines a method to register identity records for an address +func (k Keeper) RegisterIdentityRecords(ctx sdk.Context, address sdk.AccAddress, infos []types.IdentityInfoEntry) error { + // validate key and set the key to non case-sensitive + properties := k.GetNetworkProperties(ctx) + uniqueKeys := strings.Split(properties.UniqueIdentityKeys, ",") + for i, info := range infos { + if !ValidateIdentityRecordKey(info.Key) { + return sdkerrors.Wrap(types.ErrInvalidIdentityRecordKey, fmt.Sprintf("invalid key exists: key=%s", info.Key)) + } + infos[i].Key = FormalizeIdentityRecordKey(info.Key) + + if infos[i].Key == "moniker" && len(infos[i].Info) > 32 { + return stakingtypes.ErrInvalidMonikerLength + } + if infos[i].Key == "username" && len(infos[i].Info) > 32 { + return stakingtypes.ErrInvalidUsernameLength + } + + // check when the user is councilor + _, found := k.GetCouncilor(ctx, address) + if found { + monikerRecordId := k.GetIdentityRecordIdByAddressKey(ctx, address, "moniker") + usernameRecordId := k.GetIdentityRecordIdByAddressKey(ctx, address, "username") + moniker := k.GetIdentityRecordById(ctx, monikerRecordId) + username := k.GetIdentityRecordById(ctx, usernameRecordId) + if infos[i].Key == "moniker" && moniker != nil && infos[i].Info != moniker.Value { + return types.ErrCouncilorMonikerNotAllowedToBeChanged + } + if infos[i].Key == "username" && username != nil && infos[i].Info != username.Value { + return types.ErrCouncilorUsernameNotAllowedToBeChanged + } + } + + if CheckIfWithinStringArray(infos[i].Key, uniqueKeys) { + addrs := k.GetAddressesByIdRecordKey(ctx, infos[i].Key, infos[i].Info) + if len(addrs) == 1 && bytes.Equal(addrs[0], address) { + + } else if len(addrs) > 0 { + return sdkerrors.Wrap(types.ErrKeyShouldBeUnique, fmt.Sprintf("the key %s, value %s is already registered by %s", infos[i].Key, infos[i].Info, addrs[0].String())) + } + } + } + + for _, info := range infos { + // use existing record id if it already exists + recordId := k.GetIdentityRecordIdByAddressKey(ctx, address, info.Key) + if recordId == 0 { + recordId = k.GetLastIdentityRecordId(ctx) + 1 + k.SetLastIdentityRecordId(ctx, recordId) + } + // create or update identity record + k.SetIdentityRecord(ctx, types.IdentityRecord{ + Id: recordId, + Address: address.String(), + Key: info.Key, + Value: info.Info, + Date: ctx.BlockTime(), + Verifiers: []string{}, + }) + } + return nil +} + +// DeleteIdentityRecords defines a method to delete identity records owned by an address +func (k Keeper) DeleteIdentityRecords(ctx sdk.Context, address sdk.AccAddress, keys []string) error { + // validate key and set the key to non case-sensitive + for i, key := range keys { + if !ValidateIdentityRecordKey(key) { + return sdkerrors.Wrap(types.ErrInvalidIdentityRecordKey, fmt.Sprintf("invalid key exists: key=%s", key)) + } + keys[i] = FormalizeIdentityRecordKey(key) + + // we prevent deleting moniker field of a validator + if key == "moniker" { + return sdkerrors.Wrap(types.ErrMonikerDeletionNotAllowed, fmt.Sprintf("moniker field is not allowed to delete")) + } + } + + store := ctx.KVStore(k.storeKey) + prefix := types.IdentityRecordByAddressPrefix(address.String()) + iterator := sdk.KVStorePrefixIterator(store, prefix) + defer iterator.Close() + + keyMap := make(map[string]bool) + for _, key := range keys { + keyMap[key] = true + } + recordIds := []uint64{} + for ; iterator.Valid(); iterator.Next() { + key := bytes.TrimPrefix(iterator.Key(), prefix) + if len(keys) == 0 || keyMap[string(key)] { + // if no specific keys are provided remove all + // invalid keys are ignored + recordIds = append(recordIds, sdk.BigEndianToUint64(iterator.Value())) + store.Delete(iterator.Key()) + } + } + + for _, recordId := range recordIds { + prevRecord := k.GetIdentityRecordById(ctx, recordId) + if prevRecord == nil { + return sdkerrors.Wrap(types.ErrInvalidIdentityRecordId, fmt.Sprintf("identity record with specified id does NOT exist: id=%d", recordId)) + } + + k.DeleteIdentityRecordById(ctx, recordId) + } + + return nil +} + +// GetAllIdentityRecords query all identity records +func (k Keeper) GetAllIdentityRecords(ctx sdk.Context) []types.IdentityRecord { + records := []types.IdentityRecord{} + store := ctx.KVStore(k.storeKey) + iterator := sdk.KVStorePrefixIterator(store, types.KeyPrefixIdentityRecord) + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + record := types.IdentityRecord{} + k.cdc.MustUnmarshal(iterator.Value(), &record) + records = append(records, record) + } + + return records +} + +// GetIdRecordsByAddressAndKeys query identity record by address and keys +func (k Keeper) GetIdRecordsByAddressAndKeys(ctx sdk.Context, address sdk.AccAddress, keys []string) ([]types.IdentityRecord, error) { + // validate key and set the key to non case-sensitive + for i, key := range keys { + if !ValidateIdentityRecordKey(key) { + return []types.IdentityRecord{}, sdkerrors.Wrap(types.ErrInvalidIdentityRecordKey, fmt.Sprintf("invalid key exists: key=%s", key)) + } + keys[i] = FormalizeIdentityRecordKey(key) + } + + if len(keys) == 0 { + return k.GetIdRecordsByAddress(ctx, address), nil + } + + store := ctx.KVStore(k.storeKey) + prefixStore := prefix.NewStore(store, types.IdentityRecordByAddressPrefix(address.String())) + + records := []types.IdentityRecord{} + for _, key := range keys { + bz := prefixStore.Get([]byte(key)) + recordId := sdk.BigEndianToUint64(bz) + record := k.GetIdentityRecordById(ctx, recordId) + if record == nil { + return records, sdkerrors.Wrap(types.ErrInvalidIdentityRecordId, fmt.Sprintf("identity record with specified id does NOT exist: id=%d", recordId)) + } + records = append(records, *record) + } + return records, nil +} + +func (k Keeper) GetAddressesByIdRecordKey(ctx sdk.Context, key, value string) []sdk.AccAddress { + addrs := []sdk.AccAddress{} + for _, record := range k.GetAllIdentityRecords(ctx) { + if record.Key == key && record.Value == value { + addr, err := sdk.AccAddressFromBech32(record.Address) + if err != nil { + panic(err) + } + addrs = append(addrs, addr) + } + } + return addrs +} + +// GetIdRecordsByAddress query identity record by address +func (k Keeper) GetIdRecordsByAddress(ctx sdk.Context, address sdk.AccAddress) []types.IdentityRecord { + store := ctx.KVStore(k.storeKey) + prefix := types.IdentityRecordByAddressPrefix(address.String()) + iterator := sdk.KVStorePrefixIterator(store, prefix) + defer iterator.Close() + + records := []types.IdentityRecord{} + for ; iterator.Valid(); iterator.Next() { + recordId := sdk.BigEndianToUint64(iterator.Value()) + record := k.GetIdentityRecordById(ctx, recordId) + if record == nil { + panic(fmt.Sprintf("invalid recordId exists: recordId = %d, key=%s, value=%s", recordId, string(iterator.Key()), string(iterator.Value()))) + } + records = append(records, *record) + } + return records +} + +// SetIdentityRecordsVerifyRequest saves identity verify request into the store +func (k Keeper) SetIdentityRecordsVerifyRequest(ctx sdk.Context, request types.IdentityRecordsVerify) { + requestId := request.Id + bz := k.cdc.MustMarshal(&request) + prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefixIdRecordVerifyRequest).Set(sdk.Uint64ToBigEndian(requestId), bz) + prefix.NewStore( + ctx.KVStore(k.storeKey), + types.IdRecordVerifyRequestByRequesterPrefix(request.Address), + ).Set(sdk.Uint64ToBigEndian(requestId), sdk.Uint64ToBigEndian(requestId)) + prefix.NewStore( + ctx.KVStore(k.storeKey), + types.IdRecordVerifyRequestByApproverPrefix(request.Verifier), + ).Set(sdk.Uint64ToBigEndian(requestId), sdk.Uint64ToBigEndian(requestId)) +} + +// RequestIdentityRecordsVerify defines a method to request verify request from specific verifier +func (k Keeper) RequestIdentityRecordsVerify(ctx sdk.Context, address, verifier sdk.AccAddress, recordIds []uint64, tip sdk.Coin) (uint64, error) { + requestId := k.GetLastIdRecordVerifyRequestId(ctx) + 1 + + lastRecordEditDate := time.Time{} + for _, recordId := range recordIds { + record := k.GetIdentityRecordById(ctx, recordId) + if record == nil { + return requestId, sdkerrors.Wrap(types.ErrInvalidIdentityRecordId, fmt.Sprintf("identity record with specified id does NOT exist: id=%d", recordId)) + } + if lastRecordEditDate.Before(record.Date) { + lastRecordEditDate = record.Date + } + } + + request := types.IdentityRecordsVerify{ + Id: requestId, + Address: address.String(), + Verifier: verifier.String(), + RecordIds: recordIds, + Tip: tip, + LastRecordEditDate: lastRecordEditDate, + } + + minApprovalTip := k.GetNetworkProperties(ctx).MinIdentityApprovalTip + if sdk.NewInt(int64(minApprovalTip)).GT(tip.Amount) { + return requestId, sdkerrors.Wrap(types.ErrInvalidApprovalTip, fmt.Sprintf("approval tip is lower than minimum tip configured by the network")) + } + + k.SetIdentityRecordsVerifyRequest(ctx, request) + k.SetLastIdRecordVerifyRequestId(ctx, requestId) + + if !tip.Amount.IsZero() { + if err := k.bk.SendCoinsFromAccountToModule(ctx, address, types.ModuleName, sdk.Coins{tip}); err != nil { + return 0, err + } + } + return requestId, nil +} + +// GetIdRecordsVerifyRequest defines a method to get an identity records verify request by id +func (k Keeper) GetIdRecordsVerifyRequest(ctx sdk.Context, requestId uint64) *types.IdentityRecordsVerify { + request := types.IdentityRecordsVerify{} + + prefixStore := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefixIdRecordVerifyRequest) + bz := prefixStore.Get(sdk.Uint64ToBigEndian(requestId)) + if bz == nil { + return nil + } + k.cdc.MustUnmarshal(bz, &request) + return &request +} + +// DeleteIdRecordsVerifyRequest defines a method to get an identity records verify request by id +func (k Keeper) DeleteIdRecordsVerifyRequest(ctx sdk.Context, requestId uint64) { + request := k.GetIdRecordsVerifyRequest(ctx, requestId) + if request == nil { + return + } + prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefixIdRecordVerifyRequest).Delete(sdk.Uint64ToBigEndian(requestId)) + prefix.NewStore( + ctx.KVStore(k.storeKey), + types.IdRecordVerifyRequestByRequesterPrefix(request.Address), + ).Delete(sdk.Uint64ToBigEndian(requestId)) + prefix.NewStore( + ctx.KVStore(k.storeKey), + types.IdRecordVerifyRequestByApproverPrefix(request.Verifier), + ).Delete(sdk.Uint64ToBigEndian(requestId)) +} + +// ApproveIdentityRecords defines a method to accept or reject verification request +func (k Keeper) HandleIdentityRecordsVerifyRequest(ctx sdk.Context, verifier sdk.AccAddress, requestId uint64, approve bool) error { + request := k.GetIdRecordsVerifyRequest(ctx, requestId) + if request == nil { + return sdkerrors.Wrap(types.ErrInvalidVerifyRequestId, fmt.Sprintf("specified identity record verify request does NOT exist: id=%d", requestId)) + } + if verifier.String() != request.Verifier { + return errors.New("verifier does not match with requested") + } + + // send the balance regardless approve or reject + if !request.Tip.Amount.IsZero() { + if err := k.bk.SendCoinsFromModuleToAccount(ctx, types.ModuleName, verifier, sdk.Coins{request.Tip}); err != nil { + return err + } + } + + // automatically reject if last record edit date is incorrect + for _, recordId := range request.RecordIds { + record := k.GetIdentityRecordById(ctx, recordId) + if record == nil { + return sdkerrors.Wrap(types.ErrInvalidIdentityRecordId, fmt.Sprintf("identity record with specified id does NOT exist: id=%d", recordId)) + } + + if record.Date.After(request.LastRecordEditDate) { + approve = false + break + } + } + + if approve == false { + k.DeleteIdRecordsVerifyRequest(ctx, requestId) + return nil + } + + for _, recordId := range request.RecordIds { + record := k.GetIdentityRecordById(ctx, recordId) + if record == nil { + return sdkerrors.Wrap(types.ErrInvalidIdentityRecordId, fmt.Sprintf("identity record with specified id does NOT exist: id=%d", recordId)) + } + + // if already exist, skip + if CheckIfWithinStringArray(verifier.String(), record.Verifiers) { + continue + } + record.Verifiers = append(record.Verifiers, verifier.String()) + k.SetIdentityRecord(ctx, *record) + } + + k.DeleteIdRecordsVerifyRequest(ctx, requestId) + return nil +} + +// CancelIdentityRecordsVerifyRequest defines a method to cancel verification request +func (k Keeper) CancelIdentityRecordsVerifyRequest(ctx sdk.Context, executor sdk.AccAddress, requestId uint64) error { + request := k.GetIdRecordsVerifyRequest(ctx, requestId) + if request == nil { + return sdkerrors.Wrap(types.ErrInvalidVerifyRequestId, fmt.Sprintf("specified identity record verify request does NOT exist: id=%d", requestId)) + } + if executor.String() != request.Address { + return errors.New("executor is not identity record creator") + } + + if !request.Tip.Amount.IsZero() { + requester, err := sdk.AccAddressFromBech32(request.Address) + if err != nil { + return err + } + if err := k.bk.SendCoinsFromModuleToAccount(ctx, types.ModuleName, requester, sdk.Coins{request.Tip}); err != nil { + return err + } + } + + k.DeleteIdRecordsVerifyRequest(ctx, requestId) + return nil +} + +// GetIdRecordsVerifyRequestsByRequester query identity record verify requests by requester +func (k Keeper) GetIdRecordsVerifyRequestsByRequester(ctx sdk.Context, requester sdk.AccAddress) []types.IdentityRecordsVerify { + requests := []types.IdentityRecordsVerify{} + store := ctx.KVStore(k.storeKey) + iterator := sdk.KVStorePrefixIterator(store, types.IdRecordVerifyRequestByRequesterPrefix(requester.String())) + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + requestId := sdk.BigEndianToUint64(iterator.Value()) + request := k.GetIdRecordsVerifyRequest(ctx, requestId) + if request == nil { + panic(fmt.Errorf("invalid id available on requests: %d", requestId)) + } + requests = append(requests, *request) + } + + return requests +} + +// GetIdRecordsVerifyRequestsByApprover query identity records verify requests by approver +func (k Keeper) GetIdRecordsVerifyRequestsByApprover(ctx sdk.Context, requester sdk.AccAddress) []types.IdentityRecordsVerify { + requests := []types.IdentityRecordsVerify{} + store := ctx.KVStore(k.storeKey) + iterator := sdk.KVStorePrefixIterator(store, types.IdRecordVerifyRequestByApproverPrefix(requester.String())) + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + requestId := sdk.BigEndianToUint64(iterator.Value()) + request := k.GetIdRecordsVerifyRequest(ctx, requestId) + if request == nil { + panic(fmt.Errorf("invalid id available on requests: %d", requestId)) + } + requests = append(requests, *request) + } + + return requests +} + +// GetAllIdRecordsVerifyRequests query all identity records verify requests +func (k Keeper) GetAllIdRecordsVerifyRequests(ctx sdk.Context) []types.IdentityRecordsVerify { + requests := []types.IdentityRecordsVerify{} + store := ctx.KVStore(k.storeKey) + iterator := sdk.KVStorePrefixIterator(store, types.KeyPrefixIdRecordVerifyRequest) + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + request := types.IdentityRecordsVerify{} + k.cdc.MustUnmarshal(iterator.Value(), &request) + requests = append(requests, request) + } + + return requests +} diff --git a/x/gov/keeper/identity_registrar_test.go b/x/gov/keeper/identity_registrar_test.go index a772b69f5..253ec7a73 100644 --- a/x/gov/keeper/identity_registrar_test.go +++ b/x/gov/keeper/identity_registrar_test.go @@ -1,596 +1,596 @@ -package keeper_test - -import ( - "strings" - "testing" - "time" - - simapp "github.com/KiraCore/sekai/app" - "github.com/KiraCore/sekai/x/gov/keeper" - "github.com/KiraCore/sekai/x/gov/types" - sdk "github.com/cosmos/cosmos-sdk/types" - minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" - "github.com/stretchr/testify/require" - tmproto "github.com/tendermint/tendermint/proto/tendermint/types" -) - -func TestKeeper_ValidateIdentityRecordKey(t *testing.T) { - require.False(t, keeper.ValidateIdentityRecordKey("_abc")) - require.False(t, keeper.ValidateIdentityRecordKey("1abc")) - require.True(t, keeper.ValidateIdentityRecordKey("ab_a")) - require.True(t, keeper.ValidateIdentityRecordKey("ab_1a")) - require.True(t, keeper.ValidateIdentityRecordKey("aa_Aa")) -} - -func TestKeeper_CheckIfWithinAddressArray(t *testing.T) { - addr1 := sdk.AccAddress("foo1________________") - addr2 := sdk.AccAddress("foo2________________") - addr3 := sdk.AccAddress("foo3________________") - addr4 := sdk.AccAddress("foo4________________") - - array := []sdk.AccAddress{addr1, addr2, addr3} - - require.True(t, keeper.CheckIfWithinAddressArray(addr1, array)) - require.True(t, keeper.CheckIfWithinAddressArray(addr2, array)) - require.True(t, keeper.CheckIfWithinAddressArray(addr3, array)) - require.False(t, keeper.CheckIfWithinAddressArray(addr4, array)) -} - -func TestKeeper_LastIdentityRecordId(t *testing.T) { - app := simapp.Setup(false) - ctx := app.NewContext(false, tmproto.Header{}) - - lastRecordId := app.CustomGovKeeper.GetLastIdentityRecordId(ctx) - require.Equal(t, lastRecordId, uint64(0)) - - app.CustomGovKeeper.SetLastIdentityRecordId(ctx, 5) - - lastRecordId = app.CustomGovKeeper.GetLastIdentityRecordId(ctx) - require.Equal(t, lastRecordId, uint64(5)) -} - -func TestKeeper_LastIdRecordVerifyRequestId(t *testing.T) { - app := simapp.Setup(false) - ctx := app.NewContext(false, tmproto.Header{}) - - lastRecordId := app.CustomGovKeeper.GetLastIdRecordVerifyRequestId(ctx) - require.Equal(t, lastRecordId, uint64(0)) - - app.CustomGovKeeper.SetLastIdRecordVerifyRequestId(ctx, 5) - - lastRecordId = app.CustomGovKeeper.GetLastIdRecordVerifyRequestId(ctx) - require.Equal(t, lastRecordId, uint64(5)) -} - -func TestKeeper_IdentityRecordBasicFlow(t *testing.T) { - app := simapp.Setup(false) - ctx := app.NewContext(false, tmproto.Header{}) - - // try to get non existent record - record := app.CustomGovKeeper.GetIdentityRecordById(ctx, 1) - require.Nil(t, record) - - // create a new record and check if set correctly - addr1 := sdk.AccAddress("foo1________________") - addr2 := sdk.AccAddress("foo2________________") - addr3 := sdk.AccAddress("foo3________________") - newRecord := types.IdentityRecord{ - Id: 1, - Address: addr1.String(), - Key: "key", - Value: "value", - Date: time.Now().UTC(), - Verifiers: []string{addr2.String(), addr3.String()}, - } - app.CustomGovKeeper.SetIdentityRecord(ctx, newRecord) - record = app.CustomGovKeeper.GetIdentityRecordById(ctx, 1) - require.NotNil(t, record) - require.Equal(t, *record, newRecord) - - // check no panics - app.CustomGovKeeper.DeleteIdentityRecordById(ctx, 0) - - // remove existing id and check - app.CustomGovKeeper.DeleteIdentityRecordById(ctx, 1) - record = app.CustomGovKeeper.GetIdentityRecordById(ctx, 1) - require.Nil(t, record) - - // check automatic conversion to lowercase - uppercaseRecord := types.IdentityRecord{ - Id: 2, - Address: addr1.String(), - Key: "MyKey", - Value: "value", - Date: time.Now().UTC(), - Verifiers: []string{addr2.String(), addr3.String()}, - } - app.CustomGovKeeper.SetIdentityRecord(ctx, uppercaseRecord) - record = app.CustomGovKeeper.GetIdentityRecordById(ctx, 2) - require.NotNil(t, record) - require.Equal(t, record.Key, "mykey") - - // try to get via uppercase key - recordId := app.CustomGovKeeper.GetIdentityRecordIdByAddressKey(ctx, addr1, "MYKEY") - require.Equal(t, recordId, uint64(2)) - - // try to get by key - recordId = app.CustomGovKeeper.GetIdentityRecordIdByAddressKey(ctx, addr1, "_key") - require.Equal(t, recordId, uint64(0)) - - // check invalid key set - invalidRecord := types.IdentityRecord{ - Id: 1, - Address: addr1.String(), - Key: "_key", - Value: "value", - Date: time.Now().UTC(), - Verifiers: []string{addr2.String(), addr3.String()}, - } - require.Panics(t, func() { - app.CustomGovKeeper.SetIdentityRecord(ctx, invalidRecord) - }) -} - -func TestKeeper_IdentityRecordAddEditRemove(t *testing.T) { - app := simapp.Setup(false) - ctx := app.NewContext(false, tmproto.Header{}) - - // create a new record and check if set correctly - addr1 := sdk.AccAddress("foo1________________") - addr2 := sdk.AccAddress("foo2________________") - addr3 := sdk.AccAddress("foo3________________") - infos := make(map[string]string) - infos["key"] = "value" - now := time.Now().UTC() - ctx = ctx.WithBlockTime(now) - err := app.CustomGovKeeper.RegisterIdentityRecords(ctx, addr1, types.WrapInfos(infos)) - require.NoError(t, err) - - record := app.CustomGovKeeper.GetIdentityRecordById(ctx, 1) - require.NotNil(t, record) - expectedRecord := types.IdentityRecord{ - Id: 1, - Address: addr1.String(), - Key: "key", - Value: "value", - Date: now, - } - require.Equal(t, *record, expectedRecord) - - err = app.CustomGovKeeper.RegisterIdentityRecords(ctx, addr2, types.WrapInfos(infos)) - require.NoError(t, err) - - records := app.CustomGovKeeper.GetAllIdentityRecords(ctx) - require.Len(t, records, 2) - records = app.CustomGovKeeper.GetIdRecordsByAddress(ctx, addr1) - require.NotNil(t, records) - records = app.CustomGovKeeper.GetIdRecordsByAddress(ctx, addr2) - require.NotNil(t, records) - - // remove existing id and check - app.CustomGovKeeper.DeleteIdentityRecords(ctx, addr2, []string{}) - records = app.CustomGovKeeper.GetIdRecordsByAddress(ctx, addr2) - require.Len(t, records, 0) - records = app.CustomGovKeeper.GetIdRecordsByAddress(ctx, addr1) - require.Len(t, records, 1) - records = app.CustomGovKeeper.GetAllIdentityRecords(ctx) - require.Len(t, records, 1) - - infos["key1"] = "value1" - now = now.Add(time.Second) - ctx = ctx.WithBlockTime(now) - - // try deleting one key - err = app.CustomGovKeeper.DeleteIdentityRecords(ctx, addr3, []string{"key1"}) - require.NoError(t, err) - - // set verifier of identity record - app.CustomGovKeeper.RegisterIdentityRecords(ctx, addr1, types.WrapInfos(infos)) - - err = app.CustomGovKeeper.RegisterIdentityRecords(ctx, addr1, types.WrapInfos(infos)) - require.NoError(t, err) - record = app.CustomGovKeeper.GetIdentityRecordById(ctx, 1) - require.NotNil(t, record) - require.Equal(t, *record, types.IdentityRecord{ - Id: 1, - Address: addr1.String(), - Key: "key", - Value: "value", - Date: now, - }) - records = app.CustomGovKeeper.GetAllIdentityRecords(ctx) - require.Len(t, records, 2) - records = app.CustomGovKeeper.GetIdRecordsByAddress(ctx, addr1) - require.NotNil(t, record) - records = app.CustomGovKeeper.GetIdRecordsByAddress(ctx, addr2) - require.Len(t, records, 0) - - // check identity records by address - records = app.CustomGovKeeper.GetIdRecordsByAddress(ctx, addr1) - require.Len(t, records, 2) - - // check identity records by address and keys - records, err = app.CustomGovKeeper.GetIdRecordsByAddressAndKeys(ctx, addr1, []string{}) - require.NoError(t, err) - require.Len(t, records, 2) - - records, err = app.CustomGovKeeper.GetIdRecordsByAddressAndKeys(ctx, addr1, []string{"key"}) - require.NoError(t, err) - require.Len(t, records, 1) - - records, err = app.CustomGovKeeper.GetIdRecordsByAddressAndKeys(ctx, addr1, []string{"invalidkey"}) - require.Error(t, err) -} - -func TestKeeper_TryLongMonikerField(t *testing.T) { - app := simapp.Setup(false) - ctx := app.NewContext(false, tmproto.Header{}) - - // create a new record and check if set correctly - addr1 := sdk.AccAddress("foo1________________") - infos := make(map[string]string) - infos["moniker"] = strings.Repeat("A", 33) - now := time.Now().UTC() - ctx = ctx.WithBlockTime(now) - err := app.CustomGovKeeper.RegisterIdentityRecords(ctx, addr1, types.WrapInfos(infos)) - require.Error(t, err) -} - -func TestKeeper_TrySameMonikerField(t *testing.T) { - app := simapp.Setup(false) - ctx := app.NewContext(false, tmproto.Header{}) - - // create a new record and check if set correctly - addr1 := sdk.AccAddress("foo1________________") - addr2 := sdk.AccAddress("foo2________________") - infos := make(map[string]string) - infos["moniker"] = "AAA" - now := time.Now().UTC() - ctx = ctx.WithBlockTime(now) - err := app.CustomGovKeeper.RegisterIdentityRecords(ctx, addr1, types.WrapInfos(infos)) - require.NoError(t, err) - err = app.CustomGovKeeper.RegisterIdentityRecords(ctx, addr1, types.WrapInfos(infos)) - require.NoError(t, err) - err = app.CustomGovKeeper.RegisterIdentityRecords(ctx, addr2, types.WrapInfos(infos)) - require.Error(t, err) - infos["moniker"] = "AAA2" - err = app.CustomGovKeeper.RegisterIdentityRecords(ctx, addr2, types.WrapInfos(infos)) - require.NoError(t, err) -} - -func TestKeeper_TryUniqueIdentityKeysSet(t *testing.T) { - app := simapp.Setup(false) - ctx := app.NewContext(false, tmproto.Header{}) - - // create a new record and check if set correctly - now := time.Now().UTC() - ctx = ctx.WithBlockTime(now) - err := app.CustomGovKeeper.SetNetworkProperty(ctx, types.UniqueIdentityKeys, types.NetworkPropertyValue{StrValue: "moniker,email"}) - require.NoError(t, err) - networkProperties := app.CustomGovKeeper.GetNetworkProperties(ctx) - require.NotNil(t, networkProperties) - - require.Equal(t, networkProperties.UniqueIdentityKeys, "moniker,email") -} - -// func TestKeeper_IdentityKeysManagement(t *testing.T) { -// app := simapp.Setup(false) -// ctx := app.NewContext(false, tmproto.Header{}) - -// // create a new record and check if set correctly -// addr1 := sdk.AccAddress("foo1________________") -// infos := make(map[string]string) -// infos["MyKey"] = "MyValue" -// infos["Nike"] = "MyNike" -// now := time.Now().UTC() -// ctx = ctx.WithBlockTime(now) -// err := app.CustomGovKeeper.RegisterIdentityRecords(ctx, addr1, types.WrapInfos(infos)) -// require.NoError(t, err) - -// record := app.CustomGovKeeper.GetIdentityRecordById(ctx, 1) -// require.NotNil(t, record) -// expectedRecord := types.IdentityRecord{ -// Id: 1, -// Address: addr1.String(), -// Key: "mykey", -// Value: "MyValue", -// Date: now, -// } -// require.Equal(t, *record, expectedRecord) - -// record = app.CustomGovKeeper.GetIdentityRecordById(ctx, 2) -// require.NotNil(t, record) -// expectedRecord = types.IdentityRecord{ -// Id: 2, -// Address: addr1.String(), -// Key: "nike", -// Value: "MyNike", -// Date: now, -// } -// require.Equal(t, *record, expectedRecord) - -// // check invalid key involved registration -// infos["1Nike"] = "MyNike" -// err = app.CustomGovKeeper.RegisterIdentityRecords(ctx, addr1, types.WrapInfos(infos)) -// require.Error(t, err) - -// records, err := app.CustomGovKeeper.GetIdRecordsByAddressAndKeys(ctx, addr1, []string{"MyKey", "nike"}) -// require.NoError(t, err) -// require.Len(t, records, 2) - -// records, err = app.CustomGovKeeper.GetIdRecordsByAddressAndKeys(ctx, addr1, []string{"MyKey", "nike", "A"}) -// require.Error(t, err) - -// records, err = app.CustomGovKeeper.GetIdRecordsByAddressAndKeys(ctx, addr1, []string{"MyKey", "nike", "_"}) -// require.Error(t, err) - -// // get address from identity record key value -// addrs := app.CustomGovKeeper.GetAddressesByIdRecordKey(ctx, "mykey", "MyValue") -// require.Len(t, addrs, 1) - -// addrs = app.CustomGovKeeper.GetAddressesByIdRecordKey(ctx, "mykey", "MyValue2") -// require.Len(t, addrs, 0) - -// // delete by uppercase key and check if deleted correctly -// err = app.CustomGovKeeper.DeleteIdentityRecords(ctx, addr1, []string{"myKey"}) -// require.NoError(t, err) - -// records, err = app.CustomGovKeeper.GetIdRecordsByAddressAndKeys(ctx, addr1, []string{"MyKey"}) -// require.Error(t, err) - -// // test for moniker field deletion is not enabled -// err = app.CustomGovKeeper.RegisterIdentityRecords(ctx, addr1, []types.IdentityInfoEntry{ -// { -// Key: "moniker", -// Info: "node0", -// }, -// }) -// require.NoError(t, err) -// err = app.CustomGovKeeper.DeleteIdentityRecords(ctx, addr1, []string{"moniker"}) -// require.Error(t, err) -// } - -func TestKeeper_IdentityRecordApproveFlow(t *testing.T) { - app := simapp.Setup(false) - ctx := app.NewContext(false, tmproto.Header{}) - - // create a new record and check if set correctly - addr1 := sdk.AccAddress("foo1________________") - addr2 := sdk.AccAddress("foo2________________") - addr3 := sdk.AccAddress("foo3________________") - addr4 := sdk.AccAddress("foo4________________") - initCoins := sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 10000)} - app.BankKeeper.MintCoins(ctx, minttypes.ModuleName, initCoins) - app.BankKeeper.MintCoins(ctx, minttypes.ModuleName, initCoins) - app.BankKeeper.MintCoins(ctx, minttypes.ModuleName, initCoins) - app.BankKeeper.SendCoinsFromModuleToAccount(ctx, minttypes.ModuleName, addr1, initCoins) - app.BankKeeper.SendCoinsFromModuleToAccount(ctx, minttypes.ModuleName, addr2, initCoins) - app.BankKeeper.SendCoinsFromModuleToAccount(ctx, minttypes.ModuleName, addr3, initCoins) - - infos := make(map[string]string) - infos["key"] = "value" - now := time.Now().UTC() - ctx = ctx.WithBlockTime(now) - err := app.CustomGovKeeper.RegisterIdentityRecords(ctx, addr1, types.WrapInfos(infos)) - require.NoError(t, err) - - record := app.CustomGovKeeper.GetIdentityRecordById(ctx, 1) - require.NotNil(t, record) - expectedRecord := types.IdentityRecord{ - Id: 1, - Address: addr1.String(), - Key: "key", - Value: "value", - Date: now, - } - require.Equal(t, *record, expectedRecord) - - err = app.CustomGovKeeper.RegisterIdentityRecords(ctx, addr2, types.WrapInfos(infos)) - require.NoError(t, err) - - // bigger tip than balance - ctxCache, _ := ctx.CacheContext() - reqId, err := app.CustomGovKeeper.RequestIdentityRecordsVerify(ctxCache, addr1, addr3, []uint64{1}, sdk.NewInt64Coin(sdk.DefaultBondDenom, 1000000000)) - require.Equal(t, reqId, uint64(0)) - require.Error(t, err) - - // test smaller tip than minimum tip - ctxCache, _ = ctx.CacheContext() - reqId, err = app.CustomGovKeeper.RequestIdentityRecordsVerify(ctxCache, addr1, addr3, []uint64{1}, sdk.NewInt64Coin(sdk.DefaultBondDenom, 199)) - require.Error(t, err) - require.Equal(t, reqId, uint64(1)) - - // request id record 1 to addr3 by addr1 - reqId, err = app.CustomGovKeeper.RequestIdentityRecordsVerify(ctx, addr1, addr3, []uint64{1}, sdk.NewInt64Coin(sdk.DefaultBondDenom, 200)) - require.Equal(t, reqId, uint64(1)) - require.NoError(t, err) - request := app.CustomGovKeeper.GetIdRecordsVerifyRequest(ctx, 1) - require.NotNil(t, request) - require.Equal(t, *request, types.IdentityRecordsVerify{ - Id: 1, - Address: addr1.String(), - Verifier: addr3.String(), - RecordIds: []uint64{1}, - Tip: sdk.NewInt64Coin(sdk.DefaultBondDenom, 200), - LastRecordEditDate: now, - }) - coins := app.BankKeeper.GetAllBalances(ctx, addr1) - require.Equal(t, coins, sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 9800)}) - coins = app.BankKeeper.GetAllBalances(ctx, app.AccountKeeper.GetModuleAddress(types.ModuleName)) - require.Equal(t, coins, sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 200)}) - err = app.CustomGovKeeper.HandleIdentityRecordsVerifyRequest(ctx, addr3, 1, true) - require.NoError(t, err) - coins = app.BankKeeper.GetAllBalances(ctx, addr3) - require.Equal(t, coins, sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 10200)}) - coins = app.BankKeeper.GetAllBalances(ctx, app.AccountKeeper.GetModuleAddress(types.ModuleName)) - require.Equal(t, coins, sdk.Coins{}) - record = app.CustomGovKeeper.GetIdentityRecordById(ctx, 1) - require.NotNil(t, record) - require.Equal(t, *record, types.IdentityRecord{ - Id: 1, - Address: addr1.String(), - Key: "key", - Value: "value", - Date: now, - Verifiers: []string{addr3.String()}, - }) - request = app.CustomGovKeeper.GetIdRecordsVerifyRequest(ctx, 1) - require.Nil(t, request) - - // request id record 1 to addr3 by addr1 again - reqId, err = app.CustomGovKeeper.RequestIdentityRecordsVerify(ctx, addr1, addr3, []uint64{1}, sdk.NewInt64Coin(sdk.DefaultBondDenom, 200)) - require.Equal(t, reqId, uint64(2)) - require.NoError(t, err) - coins = app.BankKeeper.GetAllBalances(ctx, addr1) - require.Equal(t, coins, sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 9600)}) - err = app.CustomGovKeeper.HandleIdentityRecordsVerifyRequest(ctx, addr3, 2, true) - require.NoError(t, err) - coins = app.BankKeeper.GetAllBalances(ctx, addr3) - require.Equal(t, coins, sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 10400)}) - record = app.CustomGovKeeper.GetIdentityRecordById(ctx, 1) - require.NotNil(t, record) - require.Equal(t, *record, types.IdentityRecord{ - Id: 1, - Address: addr1.String(), - Key: "key", - Value: "value", - Date: now, - Verifiers: []string{addr3.String()}, - }) - - // request id record 1 and 2 to addr3 by addr1 again - reqId, err = app.CustomGovKeeper.RequestIdentityRecordsVerify(ctx, addr1, addr3, []uint64{1, 2}, sdk.NewInt64Coin(sdk.DefaultBondDenom, 200)) - require.Equal(t, reqId, uint64(3)) - require.NoError(t, err) - coins = app.BankKeeper.GetAllBalances(ctx, addr1) - require.Equal(t, coins, sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 9400)}) - err = app.CustomGovKeeper.HandleIdentityRecordsVerifyRequest(ctx, addr3, 3, true) - require.NoError(t, err) - coins = app.BankKeeper.GetAllBalances(ctx, addr3) - require.Equal(t, coins, sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 10600)}) - record = app.CustomGovKeeper.GetIdentityRecordById(ctx, 1) - require.NotNil(t, record) - require.Equal(t, *record, types.IdentityRecord{ - Id: 1, - Address: addr1.String(), - Key: "key", - Value: "value", - Date: now, - Verifiers: []string{addr3.String()}, - }) - record = app.CustomGovKeeper.GetIdentityRecordById(ctx, 2) - require.NotNil(t, record) - require.Equal(t, *record, types.IdentityRecord{ - Id: 2, - Address: addr2.String(), - Key: "key", - Value: "value", - Date: now, - Verifiers: []string{addr3.String()}, - }) - - // request id record 2 to addr3 by addr2 - reqId, err = app.CustomGovKeeper.RequestIdentityRecordsVerify(ctx, addr2, addr3, []uint64{2}, sdk.NewInt64Coin(sdk.DefaultBondDenom, 200)) - require.Equal(t, reqId, uint64(4)) - require.NoError(t, err) - err = app.CustomGovKeeper.HandleIdentityRecordsVerifyRequest(ctx, addr3, 4, true) - require.NoError(t, err) - record = app.CustomGovKeeper.GetIdentityRecordById(ctx, 2) - require.NotNil(t, record) - require.Equal(t, *record, types.IdentityRecord{ - Id: 2, - Address: addr2.String(), - Key: "key", - Value: "value", - Date: now, - Verifiers: []string{addr3.String()}, - }) - - // request non-exist identity record - ctxCache, _ = ctx.CacheContext() - reqId, err = app.CustomGovKeeper.RequestIdentityRecordsVerify(ctxCache, addr2, addr3, []uint64{5}, sdk.NewInt64Coin(sdk.DefaultBondDenom, 200)) - require.Equal(t, reqId, uint64(5)) - require.Error(t, err) - - // approve with non-approver - reqId, err = app.CustomGovKeeper.RequestIdentityRecordsVerify(ctx, addr1, addr3, []uint64{1}, sdk.NewInt64Coin(sdk.DefaultBondDenom, 200)) - require.Equal(t, reqId, uint64(5)) - require.NoError(t, err) - ctxCache, _ = ctx.CacheContext() - err = app.CustomGovKeeper.HandleIdentityRecordsVerifyRequest(ctxCache, addr2, 5, true) - require.Error(t, err) - - // approve not existing request id - ctxCache, _ = ctx.CacheContext() - err = app.CustomGovKeeper.HandleIdentityRecordsVerifyRequest(ctxCache, addr2, 0xFFFFF, true) - require.Error(t, err) - - // try edit and check if verification records all gone - infos["key1"] = "value1" - err = app.CustomGovKeeper.DeleteIdentityRecords(ctx, addr1, []string{"key", "key1"}) - require.NoError(t, err) - record = app.CustomGovKeeper.GetIdentityRecordById(ctx, 1) - require.Nil(t, record) - - // check get queries - requests := app.CustomGovKeeper.GetIdRecordsVerifyRequestsByRequester(ctx, addr1) - require.Len(t, requests, 1) - requests = app.CustomGovKeeper.GetIdRecordsVerifyRequestsByApprover(ctx, addr1) - require.Len(t, requests, 0) - requests = app.CustomGovKeeper.GetAllIdRecordsVerifyRequests(ctx) - require.Len(t, requests, 1) - - // remove all and query again - app.CustomGovKeeper.DeleteIdRecordsVerifyRequest(ctx, 5) - requests = app.CustomGovKeeper.GetAllIdRecordsVerifyRequests(ctx) - require.Len(t, requests, 0) - - // try to cancel request and check coin moves correctly - reqId, err = app.CustomGovKeeper.RequestIdentityRecordsVerify(ctx, addr2, addr3, []uint64{2}, sdk.NewInt64Coin(sdk.DefaultBondDenom, 200)) - require.Equal(t, reqId, uint64(6)) - require.NoError(t, err) - coins = app.BankKeeper.GetAllBalances(ctx, addr2) - require.Equal(t, coins, sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 9600)}) - cacheCtx, _ := ctx.CacheContext() - err = app.CustomGovKeeper.CancelIdentityRecordsVerifyRequest(cacheCtx, addr3, 6) - require.Error(t, err) - err = app.CustomGovKeeper.CancelIdentityRecordsVerifyRequest(ctx, addr2, 6) - require.NoError(t, err) - request = app.CustomGovKeeper.GetIdRecordsVerifyRequest(ctx, 6) - require.Nil(t, request) - coins = app.BankKeeper.GetAllBalances(ctx, addr2) - require.Equal(t, coins, sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 9800)}) - - // try deleting request after request creation - reqId, err = app.CustomGovKeeper.RequestIdentityRecordsVerify(ctx, addr2, addr3, []uint64{2}, sdk.NewInt64Coin(sdk.DefaultBondDenom, 200)) - require.Equal(t, reqId, uint64(7)) - app.CustomGovKeeper.DeleteIdRecordsVerifyRequest(ctx, 7) - request = app.CustomGovKeeper.GetIdRecordsVerifyRequest(ctx, 7) - require.Nil(t, request) - requests = app.CustomGovKeeper.GetIdRecordsVerifyRequestsByRequester(ctx, addr2) - require.Len(t, requests, 0) - requests = app.CustomGovKeeper.GetIdRecordsVerifyRequestsByApprover(ctx, addr3) - require.Len(t, requests, 0) - - // check automatic reject if record is edited after raising verification request - reqId, err = app.CustomGovKeeper.RequestIdentityRecordsVerify(ctx, addr2, addr4, []uint64{2}, sdk.NewInt64Coin(sdk.DefaultBondDenom, 200)) - require.Equal(t, reqId, uint64(8)) - ctx = ctx.WithBlockTime(now.Add(time.Second)) - app.CustomGovKeeper.RegisterIdentityRecords(ctx, addr2, types.WrapInfos(infos)) - ctx, _ = ctx.CacheContext() - err = app.CustomGovKeeper.HandleIdentityRecordsVerifyRequest(ctx, addr4, 8, true) - require.NoError(t, err) - record = app.CustomGovKeeper.GetIdentityRecordById(ctx, 2) - require.NotNil(t, record) - require.False(t, keeper.CheckIfWithinStringArray(addr4.String(), record.Verifiers)) - coins = app.BankKeeper.GetAllBalances(ctx, addr4) - require.Equal(t, coins, sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 200)}) - - // try deleting id record after request creation - reqId, err = app.CustomGovKeeper.RequestIdentityRecordsVerify(ctx, addr2, addr3, []uint64{2}, sdk.NewInt64Coin(sdk.DefaultBondDenom, 200)) - require.Equal(t, reqId, uint64(9)) - app.CustomGovKeeper.DeleteIdentityRecords(ctx, addr2, []string{}) - cacheCtx, _ = ctx.CacheContext() - err = app.CustomGovKeeper.HandleIdentityRecordsVerifyRequest(cacheCtx, addr3, 9, true) - require.Error(t, err) -} +package keeper_test + +import ( + "strings" + "testing" + "time" + + simapp "github.com/KiraCore/sekai/app" + "github.com/KiraCore/sekai/x/gov/keeper" + "github.com/KiraCore/sekai/x/gov/types" + sdk "github.com/cosmos/cosmos-sdk/types" + minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" + "github.com/stretchr/testify/require" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" +) + +func TestKeeper_ValidateIdentityRecordKey(t *testing.T) { + require.False(t, keeper.ValidateIdentityRecordKey("_abc")) + require.False(t, keeper.ValidateIdentityRecordKey("1abc")) + require.True(t, keeper.ValidateIdentityRecordKey("ab_a")) + require.True(t, keeper.ValidateIdentityRecordKey("ab_1a")) + require.True(t, keeper.ValidateIdentityRecordKey("aa_Aa")) +} + +func TestKeeper_CheckIfWithinAddressArray(t *testing.T) { + addr1 := sdk.AccAddress("foo1________________") + addr2 := sdk.AccAddress("foo2________________") + addr3 := sdk.AccAddress("foo3________________") + addr4 := sdk.AccAddress("foo4________________") + + array := []sdk.AccAddress{addr1, addr2, addr3} + + require.True(t, keeper.CheckIfWithinAddressArray(addr1, array)) + require.True(t, keeper.CheckIfWithinAddressArray(addr2, array)) + require.True(t, keeper.CheckIfWithinAddressArray(addr3, array)) + require.False(t, keeper.CheckIfWithinAddressArray(addr4, array)) +} + +func TestKeeper_LastIdentityRecordId(t *testing.T) { + app := simapp.Setup(false) + ctx := app.NewContext(false, tmproto.Header{}) + + lastRecordId := app.CustomGovKeeper.GetLastIdentityRecordId(ctx) + require.Equal(t, lastRecordId, uint64(0)) + + app.CustomGovKeeper.SetLastIdentityRecordId(ctx, 5) + + lastRecordId = app.CustomGovKeeper.GetLastIdentityRecordId(ctx) + require.Equal(t, lastRecordId, uint64(5)) +} + +func TestKeeper_LastIdRecordVerifyRequestId(t *testing.T) { + app := simapp.Setup(false) + ctx := app.NewContext(false, tmproto.Header{}) + + lastRecordId := app.CustomGovKeeper.GetLastIdRecordVerifyRequestId(ctx) + require.Equal(t, lastRecordId, uint64(0)) + + app.CustomGovKeeper.SetLastIdRecordVerifyRequestId(ctx, 5) + + lastRecordId = app.CustomGovKeeper.GetLastIdRecordVerifyRequestId(ctx) + require.Equal(t, lastRecordId, uint64(5)) +} + +func TestKeeper_IdentityRecordBasicFlow(t *testing.T) { + app := simapp.Setup(false) + ctx := app.NewContext(false, tmproto.Header{}) + + // try to get non existent record + record := app.CustomGovKeeper.GetIdentityRecordById(ctx, 1) + require.Nil(t, record) + + // create a new record and check if set correctly + addr1 := sdk.AccAddress("foo1________________") + addr2 := sdk.AccAddress("foo2________________") + addr3 := sdk.AccAddress("foo3________________") + newRecord := types.IdentityRecord{ + Id: 1, + Address: addr1.String(), + Key: "key", + Value: "value", + Date: time.Now().UTC(), + Verifiers: []string{addr2.String(), addr3.String()}, + } + app.CustomGovKeeper.SetIdentityRecord(ctx, newRecord) + record = app.CustomGovKeeper.GetIdentityRecordById(ctx, 1) + require.NotNil(t, record) + require.Equal(t, *record, newRecord) + + // check no panics + app.CustomGovKeeper.DeleteIdentityRecordById(ctx, 0) + + // remove existing id and check + app.CustomGovKeeper.DeleteIdentityRecordById(ctx, 1) + record = app.CustomGovKeeper.GetIdentityRecordById(ctx, 1) + require.Nil(t, record) + + // check automatic conversion to lowercase + uppercaseRecord := types.IdentityRecord{ + Id: 2, + Address: addr1.String(), + Key: "MyKey", + Value: "value", + Date: time.Now().UTC(), + Verifiers: []string{addr2.String(), addr3.String()}, + } + app.CustomGovKeeper.SetIdentityRecord(ctx, uppercaseRecord) + record = app.CustomGovKeeper.GetIdentityRecordById(ctx, 2) + require.NotNil(t, record) + require.Equal(t, record.Key, "mykey") + + // try to get via uppercase key + recordId := app.CustomGovKeeper.GetIdentityRecordIdByAddressKey(ctx, addr1, "MYKEY") + require.Equal(t, recordId, uint64(2)) + + // try to get by key + recordId = app.CustomGovKeeper.GetIdentityRecordIdByAddressKey(ctx, addr1, "_key") + require.Equal(t, recordId, uint64(0)) + + // check invalid key set + invalidRecord := types.IdentityRecord{ + Id: 1, + Address: addr1.String(), + Key: "_key", + Value: "value", + Date: time.Now().UTC(), + Verifiers: []string{addr2.String(), addr3.String()}, + } + require.Panics(t, func() { + app.CustomGovKeeper.SetIdentityRecord(ctx, invalidRecord) + }) +} + +func TestKeeper_IdentityRecordAddEditRemove(t *testing.T) { + app := simapp.Setup(false) + ctx := app.NewContext(false, tmproto.Header{}) + + // create a new record and check if set correctly + addr1 := sdk.AccAddress("foo1________________") + addr2 := sdk.AccAddress("foo2________________") + addr3 := sdk.AccAddress("foo3________________") + infos := make(map[string]string) + infos["key"] = "value" + now := time.Now().UTC() + ctx = ctx.WithBlockTime(now) + err := app.CustomGovKeeper.RegisterIdentityRecords(ctx, addr1, types.WrapInfos(infos)) + require.NoError(t, err) + + record := app.CustomGovKeeper.GetIdentityRecordById(ctx, 1) + require.NotNil(t, record) + expectedRecord := types.IdentityRecord{ + Id: 1, + Address: addr1.String(), + Key: "key", + Value: "value", + Date: now, + } + require.Equal(t, *record, expectedRecord) + + err = app.CustomGovKeeper.RegisterIdentityRecords(ctx, addr2, types.WrapInfos(infos)) + require.NoError(t, err) + + records := app.CustomGovKeeper.GetAllIdentityRecords(ctx) + require.Len(t, records, 2) + records = app.CustomGovKeeper.GetIdRecordsByAddress(ctx, addr1) + require.NotNil(t, records) + records = app.CustomGovKeeper.GetIdRecordsByAddress(ctx, addr2) + require.NotNil(t, records) + + // remove existing id and check + app.CustomGovKeeper.DeleteIdentityRecords(ctx, addr2, []string{}) + records = app.CustomGovKeeper.GetIdRecordsByAddress(ctx, addr2) + require.Len(t, records, 0) + records = app.CustomGovKeeper.GetIdRecordsByAddress(ctx, addr1) + require.Len(t, records, 1) + records = app.CustomGovKeeper.GetAllIdentityRecords(ctx) + require.Len(t, records, 1) + + infos["key1"] = "value1" + now = now.Add(time.Second) + ctx = ctx.WithBlockTime(now) + + // try deleting one key + err = app.CustomGovKeeper.DeleteIdentityRecords(ctx, addr3, []string{"key1"}) + require.NoError(t, err) + + // set verifier of identity record + app.CustomGovKeeper.RegisterIdentityRecords(ctx, addr1, types.WrapInfos(infos)) + + err = app.CustomGovKeeper.RegisterIdentityRecords(ctx, addr1, types.WrapInfos(infos)) + require.NoError(t, err) + record = app.CustomGovKeeper.GetIdentityRecordById(ctx, 1) + require.NotNil(t, record) + require.Equal(t, *record, types.IdentityRecord{ + Id: 1, + Address: addr1.String(), + Key: "key", + Value: "value", + Date: now, + }) + records = app.CustomGovKeeper.GetAllIdentityRecords(ctx) + require.Len(t, records, 2) + records = app.CustomGovKeeper.GetIdRecordsByAddress(ctx, addr1) + require.NotNil(t, record) + records = app.CustomGovKeeper.GetIdRecordsByAddress(ctx, addr2) + require.Len(t, records, 0) + + // check identity records by address + records = app.CustomGovKeeper.GetIdRecordsByAddress(ctx, addr1) + require.Len(t, records, 2) + + // check identity records by address and keys + records, err = app.CustomGovKeeper.GetIdRecordsByAddressAndKeys(ctx, addr1, []string{}) + require.NoError(t, err) + require.Len(t, records, 2) + + records, err = app.CustomGovKeeper.GetIdRecordsByAddressAndKeys(ctx, addr1, []string{"key"}) + require.NoError(t, err) + require.Len(t, records, 1) + + records, err = app.CustomGovKeeper.GetIdRecordsByAddressAndKeys(ctx, addr1, []string{"invalidkey"}) + require.Error(t, err) +} + +func TestKeeper_TryLongMonikerField(t *testing.T) { + app := simapp.Setup(false) + ctx := app.NewContext(false, tmproto.Header{}) + + // create a new record and check if set correctly + addr1 := sdk.AccAddress("foo1________________") + infos := make(map[string]string) + infos["moniker"] = strings.Repeat("A", 33) + now := time.Now().UTC() + ctx = ctx.WithBlockTime(now) + err := app.CustomGovKeeper.RegisterIdentityRecords(ctx, addr1, types.WrapInfos(infos)) + require.Error(t, err) +} + +func TestKeeper_TrySameMonikerField(t *testing.T) { + app := simapp.Setup(false) + ctx := app.NewContext(false, tmproto.Header{}) + + // create a new record and check if set correctly + addr1 := sdk.AccAddress("foo1________________") + addr2 := sdk.AccAddress("foo2________________") + infos := make(map[string]string) + infos["moniker"] = "AAA" + now := time.Now().UTC() + ctx = ctx.WithBlockTime(now) + err := app.CustomGovKeeper.RegisterIdentityRecords(ctx, addr1, types.WrapInfos(infos)) + require.NoError(t, err) + err = app.CustomGovKeeper.RegisterIdentityRecords(ctx, addr1, types.WrapInfos(infos)) + require.NoError(t, err) + err = app.CustomGovKeeper.RegisterIdentityRecords(ctx, addr2, types.WrapInfos(infos)) + require.Error(t, err) + infos["moniker"] = "AAA2" + err = app.CustomGovKeeper.RegisterIdentityRecords(ctx, addr2, types.WrapInfos(infos)) + require.NoError(t, err) +} + +func TestKeeper_TryUniqueIdentityKeysSet(t *testing.T) { + app := simapp.Setup(false) + ctx := app.NewContext(false, tmproto.Header{}) + + // create a new record and check if set correctly + now := time.Now().UTC() + ctx = ctx.WithBlockTime(now) + err := app.CustomGovKeeper.SetNetworkProperty(ctx, types.UniqueIdentityKeys, types.NetworkPropertyValue{StrValue: "moniker,email"}) + require.NoError(t, err) + networkProperties := app.CustomGovKeeper.GetNetworkProperties(ctx) + require.NotNil(t, networkProperties) + + require.Equal(t, networkProperties.UniqueIdentityKeys, "moniker,email") +} + +// func TestKeeper_IdentityKeysManagement(t *testing.T) { +// app := simapp.Setup(false) +// ctx := app.NewContext(false, tmproto.Header{}) + +// // create a new record and check if set correctly +// addr1 := sdk.AccAddress("foo1________________") +// infos := make(map[string]string) +// infos["MyKey"] = "MyValue" +// infos["Nike"] = "MyNike" +// now := time.Now().UTC() +// ctx = ctx.WithBlockTime(now) +// err := app.CustomGovKeeper.RegisterIdentityRecords(ctx, addr1, types.WrapInfos(infos)) +// require.NoError(t, err) + +// record := app.CustomGovKeeper.GetIdentityRecordById(ctx, 1) +// require.NotNil(t, record) +// expectedRecord := types.IdentityRecord{ +// Id: 1, +// Address: addr1.String(), +// Key: "mykey", +// Value: "MyValue", +// Date: now, +// } +// require.Equal(t, *record, expectedRecord) + +// record = app.CustomGovKeeper.GetIdentityRecordById(ctx, 2) +// require.NotNil(t, record) +// expectedRecord = types.IdentityRecord{ +// Id: 2, +// Address: addr1.String(), +// Key: "nike", +// Value: "MyNike", +// Date: now, +// } +// require.Equal(t, *record, expectedRecord) + +// // check invalid key involved registration +// infos["1Nike"] = "MyNike" +// err = app.CustomGovKeeper.RegisterIdentityRecords(ctx, addr1, types.WrapInfos(infos)) +// require.Error(t, err) + +// records, err := app.CustomGovKeeper.GetIdRecordsByAddressAndKeys(ctx, addr1, []string{"MyKey", "nike"}) +// require.NoError(t, err) +// require.Len(t, records, 2) + +// records, err = app.CustomGovKeeper.GetIdRecordsByAddressAndKeys(ctx, addr1, []string{"MyKey", "nike", "A"}) +// require.Error(t, err) + +// records, err = app.CustomGovKeeper.GetIdRecordsByAddressAndKeys(ctx, addr1, []string{"MyKey", "nike", "_"}) +// require.Error(t, err) + +// // get address from identity record key value +// addrs := app.CustomGovKeeper.GetAddressesByIdRecordKey(ctx, "mykey", "MyValue") +// require.Len(t, addrs, 1) + +// addrs = app.CustomGovKeeper.GetAddressesByIdRecordKey(ctx, "mykey", "MyValue2") +// require.Len(t, addrs, 0) + +// // delete by uppercase key and check if deleted correctly +// err = app.CustomGovKeeper.DeleteIdentityRecords(ctx, addr1, []string{"myKey"}) +// require.NoError(t, err) + +// records, err = app.CustomGovKeeper.GetIdRecordsByAddressAndKeys(ctx, addr1, []string{"MyKey"}) +// require.Error(t, err) + +// // test for moniker field deletion is not enabled +// err = app.CustomGovKeeper.RegisterIdentityRecords(ctx, addr1, []types.IdentityInfoEntry{ +// { +// Key: "moniker", +// Info: "node0", +// }, +// }) +// require.NoError(t, err) +// err = app.CustomGovKeeper.DeleteIdentityRecords(ctx, addr1, []string{"moniker"}) +// require.Error(t, err) +// } + +func TestKeeper_IdentityRecordApproveFlow(t *testing.T) { + app := simapp.Setup(false) + ctx := app.NewContext(false, tmproto.Header{}) + + // create a new record and check if set correctly + addr1 := sdk.AccAddress("foo1________________") + addr2 := sdk.AccAddress("foo2________________") + addr3 := sdk.AccAddress("foo3________________") + addr4 := sdk.AccAddress("foo4________________") + initCoins := sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 10000)} + app.BankKeeper.MintCoins(ctx, minttypes.ModuleName, initCoins) + app.BankKeeper.MintCoins(ctx, minttypes.ModuleName, initCoins) + app.BankKeeper.MintCoins(ctx, minttypes.ModuleName, initCoins) + app.BankKeeper.SendCoinsFromModuleToAccount(ctx, minttypes.ModuleName, addr1, initCoins) + app.BankKeeper.SendCoinsFromModuleToAccount(ctx, minttypes.ModuleName, addr2, initCoins) + app.BankKeeper.SendCoinsFromModuleToAccount(ctx, minttypes.ModuleName, addr3, initCoins) + + infos := make(map[string]string) + infos["key"] = "value" + now := time.Now().UTC() + ctx = ctx.WithBlockTime(now) + err := app.CustomGovKeeper.RegisterIdentityRecords(ctx, addr1, types.WrapInfos(infos)) + require.NoError(t, err) + + record := app.CustomGovKeeper.GetIdentityRecordById(ctx, 1) + require.NotNil(t, record) + expectedRecord := types.IdentityRecord{ + Id: 1, + Address: addr1.String(), + Key: "key", + Value: "value", + Date: now, + } + require.Equal(t, *record, expectedRecord) + + err = app.CustomGovKeeper.RegisterIdentityRecords(ctx, addr2, types.WrapInfos(infos)) + require.NoError(t, err) + + // bigger tip than balance + ctxCache, _ := ctx.CacheContext() + reqId, err := app.CustomGovKeeper.RequestIdentityRecordsVerify(ctxCache, addr1, addr3, []uint64{1}, sdk.NewInt64Coin(sdk.DefaultBondDenom, 1000000000)) + require.Equal(t, reqId, uint64(0)) + require.Error(t, err) + + // test smaller tip than minimum tip + ctxCache, _ = ctx.CacheContext() + reqId, err = app.CustomGovKeeper.RequestIdentityRecordsVerify(ctxCache, addr1, addr3, []uint64{1}, sdk.NewInt64Coin(sdk.DefaultBondDenom, 199)) + require.Error(t, err) + require.Equal(t, reqId, uint64(1)) + + // request id record 1 to addr3 by addr1 + reqId, err = app.CustomGovKeeper.RequestIdentityRecordsVerify(ctx, addr1, addr3, []uint64{1}, sdk.NewInt64Coin(sdk.DefaultBondDenom, 200)) + require.Equal(t, reqId, uint64(1)) + require.NoError(t, err) + request := app.CustomGovKeeper.GetIdRecordsVerifyRequest(ctx, 1) + require.NotNil(t, request) + require.Equal(t, *request, types.IdentityRecordsVerify{ + Id: 1, + Address: addr1.String(), + Verifier: addr3.String(), + RecordIds: []uint64{1}, + Tip: sdk.NewInt64Coin(sdk.DefaultBondDenom, 200), + LastRecordEditDate: now, + }) + coins := app.BankKeeper.GetAllBalances(ctx, addr1) + require.Equal(t, coins, sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 9800)}) + coins = app.BankKeeper.GetAllBalances(ctx, app.AccountKeeper.GetModuleAddress(types.ModuleName)) + require.Equal(t, coins, sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 200)}) + err = app.CustomGovKeeper.HandleIdentityRecordsVerifyRequest(ctx, addr3, 1, true) + require.NoError(t, err) + coins = app.BankKeeper.GetAllBalances(ctx, addr3) + require.Equal(t, coins, sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 10200)}) + coins = app.BankKeeper.GetAllBalances(ctx, app.AccountKeeper.GetModuleAddress(types.ModuleName)) + require.Equal(t, coins, sdk.Coins{}) + record = app.CustomGovKeeper.GetIdentityRecordById(ctx, 1) + require.NotNil(t, record) + require.Equal(t, *record, types.IdentityRecord{ + Id: 1, + Address: addr1.String(), + Key: "key", + Value: "value", + Date: now, + Verifiers: []string{addr3.String()}, + }) + request = app.CustomGovKeeper.GetIdRecordsVerifyRequest(ctx, 1) + require.Nil(t, request) + + // request id record 1 to addr3 by addr1 again + reqId, err = app.CustomGovKeeper.RequestIdentityRecordsVerify(ctx, addr1, addr3, []uint64{1}, sdk.NewInt64Coin(sdk.DefaultBondDenom, 200)) + require.Equal(t, reqId, uint64(2)) + require.NoError(t, err) + coins = app.BankKeeper.GetAllBalances(ctx, addr1) + require.Equal(t, coins, sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 9600)}) + err = app.CustomGovKeeper.HandleIdentityRecordsVerifyRequest(ctx, addr3, 2, true) + require.NoError(t, err) + coins = app.BankKeeper.GetAllBalances(ctx, addr3) + require.Equal(t, coins, sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 10400)}) + record = app.CustomGovKeeper.GetIdentityRecordById(ctx, 1) + require.NotNil(t, record) + require.Equal(t, *record, types.IdentityRecord{ + Id: 1, + Address: addr1.String(), + Key: "key", + Value: "value", + Date: now, + Verifiers: []string{addr3.String()}, + }) + + // request id record 1 and 2 to addr3 by addr1 again + reqId, err = app.CustomGovKeeper.RequestIdentityRecordsVerify(ctx, addr1, addr3, []uint64{1, 2}, sdk.NewInt64Coin(sdk.DefaultBondDenom, 200)) + require.Equal(t, reqId, uint64(3)) + require.NoError(t, err) + coins = app.BankKeeper.GetAllBalances(ctx, addr1) + require.Equal(t, coins, sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 9400)}) + err = app.CustomGovKeeper.HandleIdentityRecordsVerifyRequest(ctx, addr3, 3, true) + require.NoError(t, err) + coins = app.BankKeeper.GetAllBalances(ctx, addr3) + require.Equal(t, coins, sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 10600)}) + record = app.CustomGovKeeper.GetIdentityRecordById(ctx, 1) + require.NotNil(t, record) + require.Equal(t, *record, types.IdentityRecord{ + Id: 1, + Address: addr1.String(), + Key: "key", + Value: "value", + Date: now, + Verifiers: []string{addr3.String()}, + }) + record = app.CustomGovKeeper.GetIdentityRecordById(ctx, 2) + require.NotNil(t, record) + require.Equal(t, *record, types.IdentityRecord{ + Id: 2, + Address: addr2.String(), + Key: "key", + Value: "value", + Date: now, + Verifiers: []string{addr3.String()}, + }) + + // request id record 2 to addr3 by addr2 + reqId, err = app.CustomGovKeeper.RequestIdentityRecordsVerify(ctx, addr2, addr3, []uint64{2}, sdk.NewInt64Coin(sdk.DefaultBondDenom, 200)) + require.Equal(t, reqId, uint64(4)) + require.NoError(t, err) + err = app.CustomGovKeeper.HandleIdentityRecordsVerifyRequest(ctx, addr3, 4, true) + require.NoError(t, err) + record = app.CustomGovKeeper.GetIdentityRecordById(ctx, 2) + require.NotNil(t, record) + require.Equal(t, *record, types.IdentityRecord{ + Id: 2, + Address: addr2.String(), + Key: "key", + Value: "value", + Date: now, + Verifiers: []string{addr3.String()}, + }) + + // request non-exist identity record + ctxCache, _ = ctx.CacheContext() + reqId, err = app.CustomGovKeeper.RequestIdentityRecordsVerify(ctxCache, addr2, addr3, []uint64{5}, sdk.NewInt64Coin(sdk.DefaultBondDenom, 200)) + require.Equal(t, reqId, uint64(5)) + require.Error(t, err) + + // approve with non-approver + reqId, err = app.CustomGovKeeper.RequestIdentityRecordsVerify(ctx, addr1, addr3, []uint64{1}, sdk.NewInt64Coin(sdk.DefaultBondDenom, 200)) + require.Equal(t, reqId, uint64(5)) + require.NoError(t, err) + ctxCache, _ = ctx.CacheContext() + err = app.CustomGovKeeper.HandleIdentityRecordsVerifyRequest(ctxCache, addr2, 5, true) + require.Error(t, err) + + // approve not existing request id + ctxCache, _ = ctx.CacheContext() + err = app.CustomGovKeeper.HandleIdentityRecordsVerifyRequest(ctxCache, addr2, 0xFFFFF, true) + require.Error(t, err) + + // try edit and check if verification records all gone + infos["key1"] = "value1" + err = app.CustomGovKeeper.DeleteIdentityRecords(ctx, addr1, []string{"key", "key1"}) + require.NoError(t, err) + record = app.CustomGovKeeper.GetIdentityRecordById(ctx, 1) + require.Nil(t, record) + + // check get queries + requests := app.CustomGovKeeper.GetIdRecordsVerifyRequestsByRequester(ctx, addr1) + require.Len(t, requests, 1) + requests = app.CustomGovKeeper.GetIdRecordsVerifyRequestsByApprover(ctx, addr1) + require.Len(t, requests, 0) + requests = app.CustomGovKeeper.GetAllIdRecordsVerifyRequests(ctx) + require.Len(t, requests, 1) + + // remove all and query again + app.CustomGovKeeper.DeleteIdRecordsVerifyRequest(ctx, 5) + requests = app.CustomGovKeeper.GetAllIdRecordsVerifyRequests(ctx) + require.Len(t, requests, 0) + + // try to cancel request and check coin moves correctly + reqId, err = app.CustomGovKeeper.RequestIdentityRecordsVerify(ctx, addr2, addr3, []uint64{2}, sdk.NewInt64Coin(sdk.DefaultBondDenom, 200)) + require.Equal(t, reqId, uint64(6)) + require.NoError(t, err) + coins = app.BankKeeper.GetAllBalances(ctx, addr2) + require.Equal(t, coins, sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 9600)}) + cacheCtx, _ := ctx.CacheContext() + err = app.CustomGovKeeper.CancelIdentityRecordsVerifyRequest(cacheCtx, addr3, 6) + require.Error(t, err) + err = app.CustomGovKeeper.CancelIdentityRecordsVerifyRequest(ctx, addr2, 6) + require.NoError(t, err) + request = app.CustomGovKeeper.GetIdRecordsVerifyRequest(ctx, 6) + require.Nil(t, request) + coins = app.BankKeeper.GetAllBalances(ctx, addr2) + require.Equal(t, coins, sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 9800)}) + + // try deleting request after request creation + reqId, err = app.CustomGovKeeper.RequestIdentityRecordsVerify(ctx, addr2, addr3, []uint64{2}, sdk.NewInt64Coin(sdk.DefaultBondDenom, 200)) + require.Equal(t, reqId, uint64(7)) + app.CustomGovKeeper.DeleteIdRecordsVerifyRequest(ctx, 7) + request = app.CustomGovKeeper.GetIdRecordsVerifyRequest(ctx, 7) + require.Nil(t, request) + requests = app.CustomGovKeeper.GetIdRecordsVerifyRequestsByRequester(ctx, addr2) + require.Len(t, requests, 0) + requests = app.CustomGovKeeper.GetIdRecordsVerifyRequestsByApprover(ctx, addr3) + require.Len(t, requests, 0) + + // check automatic reject if record is edited after raising verification request + reqId, err = app.CustomGovKeeper.RequestIdentityRecordsVerify(ctx, addr2, addr4, []uint64{2}, sdk.NewInt64Coin(sdk.DefaultBondDenom, 200)) + require.Equal(t, reqId, uint64(8)) + ctx = ctx.WithBlockTime(now.Add(time.Second)) + app.CustomGovKeeper.RegisterIdentityRecords(ctx, addr2, types.WrapInfos(infos)) + ctx, _ = ctx.CacheContext() + err = app.CustomGovKeeper.HandleIdentityRecordsVerifyRequest(ctx, addr4, 8, true) + require.NoError(t, err) + record = app.CustomGovKeeper.GetIdentityRecordById(ctx, 2) + require.NotNil(t, record) + require.False(t, keeper.CheckIfWithinStringArray(addr4.String(), record.Verifiers)) + coins = app.BankKeeper.GetAllBalances(ctx, addr4) + require.Equal(t, coins, sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 200)}) + + // try deleting id record after request creation + reqId, err = app.CustomGovKeeper.RequestIdentityRecordsVerify(ctx, addr2, addr3, []uint64{2}, sdk.NewInt64Coin(sdk.DefaultBondDenom, 200)) + require.Equal(t, reqId, uint64(9)) + app.CustomGovKeeper.DeleteIdentityRecords(ctx, addr2, []string{}) + cacheCtx, _ = ctx.CacheContext() + err = app.CustomGovKeeper.HandleIdentityRecordsVerifyRequest(cacheCtx, addr3, 9, true) + require.Error(t, err) +} diff --git a/x/gov/keeper/keeper.go b/x/gov/keeper/keeper.go index 9630e9d8c..31893b5b5 100644 --- a/x/gov/keeper/keeper.go +++ b/x/gov/keeper/keeper.go @@ -225,6 +225,33 @@ func (k Keeper) GetNetworkProperty(ctx sdk.Context, property types.NetworkProper return types.NetworkPropertyValue{Value: properties.MaxCollectiveOutputs}, nil case types.MinCollectiveClaimPeriod: return types.NetworkPropertyValue{Value: properties.MinCollectiveClaimPeriod}, nil + case types.ValidatorRecoveryBond: + return types.NetworkPropertyValue{Value: properties.ValidatorRecoveryBond}, nil + case types.MaxAnnualInflation: + return types.NetworkPropertyValue{StrValue: properties.MaxAnnualInflation.String()}, nil + case types.MinDappBond: + return types.NetworkPropertyValue{Value: properties.MinDappBond}, nil + case types.MaxDappBond: + return types.NetworkPropertyValue{Value: properties.MaxDappBond}, nil + case types.DappBondDuration: + return types.NetworkPropertyValue{Value: properties.DappBondDuration}, nil + case types.DappVerifierBond: + return types.NetworkPropertyValue{StrValue: properties.DappVerifierBond.String()}, nil + case types.DappAutoDenounceTime: + return types.NetworkPropertyValue{Value: properties.DappAutoDenounceTime}, nil + case types.DappMischanceRankDecreaseAmount: + return types.NetworkPropertyValue{Value: properties.DappMischanceRankDecreaseAmount}, nil + case types.DappMaxMischance: + return types.NetworkPropertyValue{Value: properties.DappMaxMischance}, nil + case types.DappInactiveRankDecreasePercent: + return types.NetworkPropertyValue{Value: properties.DappInactiveRankDecreasePercent}, nil + case types.DappPoolSlippageDefault: + return types.NetworkPropertyValue{StrValue: properties.DappPoolSlippageDefault.String()}, nil + case types.MintingFtFee: + return types.NetworkPropertyValue{Value: properties.MintingFtFee}, nil + case types.MintingNftFee: + return types.NetworkPropertyValue{Value: properties.MintingNftFee}, nil + default: return types.NetworkPropertyValue{}, errors.New("trying to fetch network property that does not exist") } @@ -333,6 +360,45 @@ func (k Keeper) SetNetworkProperty(ctx sdk.Context, property types.NetworkProper properties.MaxCollectiveOutputs = value.Value case types.MinCollectiveClaimPeriod: properties.MinCollectiveClaimPeriod = value.Value + case types.ValidatorRecoveryBond: + properties.ValidatorRecoveryBond = value.Value + case types.MaxAnnualInflation: + decValue, err := sdk.NewDecFromStr(value.StrValue) + if err != nil { + return err + } + properties.MaxAnnualInflation = decValue + case types.MinDappBond: + properties.MinDappBond = value.Value + case types.MaxDappBond: + properties.MaxDappBond = value.Value + case types.DappBondDuration: + properties.DappBondDuration = value.Value + case types.DappVerifierBond: + decValue, err := sdk.NewDecFromStr(value.StrValue) + if err != nil { + return err + } + properties.DappVerifierBond = decValue + case types.DappAutoDenounceTime: + properties.DappAutoDenounceTime = value.Value + case types.DappMischanceRankDecreaseAmount: + properties.DappMischanceRankDecreaseAmount = value.Value + case types.DappMaxMischance: + properties.DappMaxMischance = value.Value + case types.DappInactiveRankDecreasePercent: + properties.DappInactiveRankDecreasePercent = value.Value + case types.DappPoolSlippageDefault: + decValue, err := sdk.NewDecFromStr(value.StrValue) + if err != nil { + return err + } + properties.DappPoolSlippageDefault = decValue + case types.MintingFtFee: + properties.MintingFtFee = value.Value + case types.MintingNftFee: + properties.MintingNftFee = value.Value + default: return errors.New("trying to set network property that does not exist") } diff --git a/x/gov/keeper/keeper_test.go b/x/gov/keeper/keeper_test.go index e28f44638..4cc196d2a 100644 --- a/x/gov/keeper/keeper_test.go +++ b/x/gov/keeper/keeper_test.go @@ -1,28 +1,28 @@ -package keeper_test - -import ( - "testing" - - "github.com/stretchr/testify/require" - - simapp "github.com/KiraCore/sekai/app" - "github.com/KiraCore/sekai/x/gov/types" - tmproto "github.com/tendermint/tendermint/proto/tendermint/types" -) - -func TestKeeper_SetNetworkProperty(t *testing.T) { - app := simapp.Setup(false) - ctx := app.NewContext(false, tmproto.Header{}) - - app.CustomGovKeeper.SetNetworkProperties(ctx, &types.NetworkProperties{ - MinTxFee: 100, - MaxTxFee: 50000, - }) - - err := app.CustomGovKeeper.SetNetworkProperty(ctx, types.MinTxFee, types.NetworkPropertyValue{Value: 300}) - require.Nil(t, err) - - savedMinTxFee, err := app.CustomGovKeeper.GetNetworkProperty(ctx, types.MinTxFee) - require.Nil(t, err) - require.Equal(t, uint64(300), savedMinTxFee.Value) -} +package keeper_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + + simapp "github.com/KiraCore/sekai/app" + "github.com/KiraCore/sekai/x/gov/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" +) + +func TestKeeper_SetNetworkProperty(t *testing.T) { + app := simapp.Setup(false) + ctx := app.NewContext(false, tmproto.Header{}) + + app.CustomGovKeeper.SetNetworkProperties(ctx, &types.NetworkProperties{ + MinTxFee: 100, + MaxTxFee: 50000, + }) + + err := app.CustomGovKeeper.SetNetworkProperty(ctx, types.MinTxFee, types.NetworkPropertyValue{Value: 300}) + require.Nil(t, err) + + savedMinTxFee, err := app.CustomGovKeeper.GetNetworkProperty(ctx, types.MinTxFee) + require.Nil(t, err) + require.Equal(t, uint64(300), savedMinTxFee.Value) +} diff --git a/x/gov/keeper/keys.go b/x/gov/keeper/keys.go index 87f1a48a9..eb65b5890 100644 --- a/x/gov/keeper/keys.go +++ b/x/gov/keeper/keys.go @@ -1,42 +1,46 @@ -package keeper - -// Keys for Gov store. -// 0x00 : The next proposalID. -// 0x01 : The Proposal -// 0x02 : The vote -// 0x03 : ActiveProposalID -// 0x04 : ProposalID Holds all the proposals that are in process of enactment. -// -// 0x10 : The role permissions. -// -// 0x20 : Councilor. -// -// 0x30 : NetworkActor. -// 0x31 : NetworkActorAddress. This is used to get all the actors that have a specific whitelist. -// 0x32 : NetworkActorAddress. This is used to get all the actors that have a specific role. -// 0x33 : RoleID_Bytes. This is used to get all the actors that have a specific role. -// -// 0x40 : DataRegistryEntry -var ( - NextProposalIDPrefix = []byte{0x00} - ProposalsPrefix = []byte{0x01} - VotesPrefix = []byte{0x02} - ActiveProposalsPrefix = []byte{0x03} - EnactmentProposalsPrefix = []byte{0x04} - - RolePermissionRegistry = []byte{0x10} - RoleIdToInfo = []byte{0x11} - RoleSidToIdRegistry = []byte{0x12} - CouncilorIdentityRegistryPrefix = []byte{0x20} - - NetworkActorsPrefix = []byte{0x30} - WhitelistActorPrefix = []byte{0x31} - RoleActorPrefix = []byte{0x32} - WhitelistRolePrefix = []byte{0x33} - - DataRegistryPrefix = []byte{0x40} - - PoorNetworkMessagesPrefix = []byte{0x41} - - NextRolePrefix = []byte{0x50} -) +package keeper + +// Keys for Gov store. +// 0x00 : The next proposalID. +// 0x01 : The Proposal +// 0x02 : The vote +// 0x03 : ActiveProposalID +// 0x04 : ProposalID Holds all the proposals that are in process of enactment. +// +// 0x10 : The role permissions. +// +// 0x20 : Councilor. +// +// 0x30 : NetworkActor. +// 0x31 : NetworkActorAddress. This is used to get all the actors that have a specific whitelist. +// 0x32 : NetworkActorAddress. This is used to get all the actors that have a specific role. +// 0x33 : RoleID_Bytes. This is used to get all the actors that have a specific role. +// +// 0x40 : DataRegistryEntry +var ( + NextProposalIDPrefix = []byte{0x00} + ProposalsPrefix = []byte{0x01} + VotesPrefix = []byte{0x02} + ActiveProposalsPrefix = []byte{0x03} + EnactmentProposalsPrefix = []byte{0x04} + PollPrefix = []byte{0x05} + NextPollIDPrefix = []byte{0x06} + PollVotesPrefix = []byte{0x07} + ActivePollPrefix = []byte{0x08} + + RolePermissionRegistry = []byte{0x10} + RoleIdToInfo = []byte{0x11} + RoleSidToIdRegistry = []byte{0x12} + CouncilorIdentityRegistryPrefix = []byte{0x20} + + NetworkActorsPrefix = []byte{0x30} + WhitelistActorPrefix = []byte{0x31} + RoleActorPrefix = []byte{0x32} + WhitelistRolePrefix = []byte{0x33} + + DataRegistryPrefix = []byte{0x40} + + PoorNetworkMessagesPrefix = []byte{0x41} + + NextRolePrefix = []byte{0x50} +) diff --git a/x/gov/keeper/msg_server.go b/x/gov/keeper/msg_server.go index 3e3893d98..295ea59f3 100644 --- a/x/gov/keeper/msg_server.go +++ b/x/gov/keeper/msg_server.go @@ -3,11 +3,15 @@ package keeper import ( "context" "fmt" + "sort" + "strconv" + "time" "github.com/KiraCore/sekai/x/gov/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/errors" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "golang.org/x/exp/utf8string" ) type msgServer struct { @@ -135,6 +139,136 @@ func (k msgServer) VoteProposal( return &types.MsgVoteProposalResponse{}, nil } +func (k msgServer) PollCreate(goCtx context.Context, msg *types.MsgPollCreate) (*types.MsgPollCreateResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + blockTime := ctx.BlockTime() + properties := k.keeper.GetNetworkProperties(ctx) + allowedTypes := []string{"string", "uint", "int", "float", "bool"} + + isAllowed := CheckIfAllowedPermission(ctx, k.keeper, msg.Creator, types.PermCreatePollProposal) + if !isAllowed { + return nil, errors.Wrap(types.ErrNotEnoughPermissions, types.PermCreatePollProposal.String()) + } + + if len(msg.Title) > int(properties.MaxProposalTitleSize) { + return nil, types.ErrProposalTitleSizeExceeds + } + + if len(msg.Description) > int(properties.MaxProposalDescriptionSize) { + return nil, types.ErrProposalDescriptionSizeExceeds + } + + if len(msg.Reference) > int(properties.MaxProposalReferenceSize) { + return nil, types.ErrProposalTitleSizeExceeds + } + + if len(msg.Checksum) > int(properties.MaxProposalChecksumSize) { + return nil, types.ErrProposalTitleSizeExceeds + } + + if len(msg.PollValues) > int(properties.MaxProposalPollOptionCount) { + return nil, types.ErrProposalOptionCountExceeds + } + + duration, err := time.ParseDuration(msg.Duration) + if err != nil || blockTime.Add(duration).Before(blockTime) { + return nil, fmt.Errorf("invalid duration: %w", err) + } + + for _, v := range msg.PollValues { + if len(v) > int(properties.MaxProposalPollOptionSize) { + return nil, types.ErrProposalOptionSizeExceeds + } + + if !utf8string.NewString(v).IsASCII() { + return nil, types.ErrProposalOptionOnlyAscii + } + } + + for _, v := range msg.Roles { + _, err := k.keeper.GetRoleBySid(ctx, v) + if err != nil { + return nil, errors.Wrap(types.ErrRoleDoesNotExist, v) + } + } + + sort.Strings(allowedTypes) + i := sort.SearchStrings(allowedTypes, msg.ValueType) + + if i == len(allowedTypes) && allowedTypes[i] != msg.ValueType { + return nil, types.ErrProposalTypeNotAllowed + } + + pollID, err := k.keeper.PollCreate(ctx, msg) + + if err != nil { + return nil, err + } + + return &types.MsgPollCreateResponse{ + PollID: pollID, + }, nil +} + +func (k msgServer) PollVote(goCtx context.Context, msg *types.MsgPollVote) (*types.MsgPollVoteResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + actor, found := k.keeper.GetNetworkActorByAddress(ctx, msg.Voter) + if !found || !actor.IsActive() { + return nil, types.ErrActorIsNotActive + } + + poll, pErr := k.keeper.GetPoll(ctx, msg.PollId) + if pErr != nil { + return nil, pErr + } + + if poll.VotingEndTime.Before(time.Now()) { + return nil, types.ErrVotingTimeEnded + } + + roles := intersection(poll.Roles, actor.Roles) + + if len(roles) == 0 { + return nil, types.ErrNotEnoughPermissions + } + + switch poll.Options.Type { + case "uint": + _, err := strconv.ParseUint(msg.Value, 10, 64) + if err != nil { + return nil, errors.Wrap(types.ErrPollWrongValue, "Can not be converted to the unsigned integer") + } + case "int": + _, err := strconv.ParseInt(msg.Value, 10, 64) + if err != nil { + return nil, errors.Wrap(types.ErrPollWrongValue, "Can not be converted to the integer") + } + case "bool": + _, err := strconv.ParseBool(msg.Value) + if err != nil { + return nil, errors.Wrap(types.ErrPollWrongValue, "Can not be converted to the boolean") + } + case "float": + _, err := strconv.ParseFloat(msg.Value, 64) + if err != nil { + return nil, errors.Wrap(types.ErrPollWrongValue, "Can not be converted to the float") + } + } + + if msg.Option == types.PollOptionCustom && poll.Options.Count <= uint64(len(poll.Options.Values)) && !inSlice(poll.Options.Values, msg.Value) { + return nil, errors.Wrap(types.ErrPollWrongValue, "Maximum custom values exceeded") + } + + if msg.Option == types.PollOptionCustom && poll.Options.Count > uint64(len(poll.Options.Values)) && !inSlice(poll.Options.Values, msg.Value) { + poll.Options.Values = append(poll.Options.Values, msg.Value) + k.keeper.SavePoll(ctx, poll) + } + + err := k.keeper.PollVote(ctx, msg) + return &types.MsgPollVoteResponse{}, err +} + // RegisterIdentityRecords defines a method to create identity record func (k msgServer) RegisterIdentityRecords(goCtx context.Context, msg *types.MsgRegisterIdentityRecords) (*types.MsgRegisterIdentityRecordsResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) @@ -737,3 +871,28 @@ func (k msgServer) CouncilorActivate( return &types.MsgCouncilorActivateResponse{}, nil } + +func intersection(first, second []uint64) []uint64 { + out := []uint64{} + bucket := map[uint64]bool{} + + for _, i := range first { + for _, j := range second { + if i == j && !bucket[i] { + out = append(out, i) + bucket[i] = true + } + } + } + + return out +} + +func inSlice(sl []string, name string) bool { + for _, value := range sl { + if value == name { + return true + } + } + return false +} diff --git a/x/gov/keeper/msg_server_test.go b/x/gov/keeper/msg_server_test.go index 8500ac046..1cf566d10 100644 --- a/x/gov/keeper/msg_server_test.go +++ b/x/gov/keeper/msg_server_test.go @@ -1,229 +1,229 @@ -package keeper_test - -import ( - "testing" - - simapp "github.com/KiraCore/sekai/app" - "github.com/KiraCore/sekai/x/gov/keeper" - "github.com/KiraCore/sekai/x/gov/types" - "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/require" - tmproto "github.com/tendermint/tendermint/proto/tendermint/types" -) - -func TestMsgServerClaimCouncilor(t *testing.T) { - app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, tmproto.Header{}) - - addr := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address().Bytes()) - - // try claim with not allowed user - msgServer := keeper.NewMsgServerImpl(app.CustomGovKeeper) - _, err := msgServer.ClaimCouncilor(sdk.WrapSDKContext(ctx), types.NewMsgClaimCouncilor( - addr, "moniker", "username", "description", "social", "contact", "avatar", - )) - require.Error(t, err) - - // try claim with allowed user - actor := types.NewDefaultActor(addr) - err = app.CustomGovKeeper.AddWhitelistPermission(ctx, actor, types.PermClaimCouncilor) - require.NoError(t, err) - _, err = msgServer.ClaimCouncilor(sdk.WrapSDKContext(ctx), types.NewMsgClaimCouncilor( - addr, "moniker", "username", "description", "social", "contact", "avatar", - )) - require.NoError(t, err) - - // check councilor created - councilor, found := app.CustomGovKeeper.GetCouncilor(ctx, addr) - require.True(t, found) - require.Equal(t, councilor, types.Councilor{ - Address: addr, - Status: types.CouncilorActive, - Rank: 0, - AbstentionCounter: 0, - }) - - // check moniker, username, description, social, contact, avatar registered correctly - recordId := app.CustomGovKeeper.GetIdentityRecordIdByAddressKey(ctx, addr, "moniker") - record := app.CustomGovKeeper.GetIdentityRecordById(ctx, recordId) - require.Equal(t, record.Key, "moniker") - require.Equal(t, record.Value, "moniker") - - recordId = app.CustomGovKeeper.GetIdentityRecordIdByAddressKey(ctx, addr, "username") - record = app.CustomGovKeeper.GetIdentityRecordById(ctx, recordId) - require.Equal(t, record.Key, "username") - require.Equal(t, record.Value, "username") - - recordId = app.CustomGovKeeper.GetIdentityRecordIdByAddressKey(ctx, addr, "description") - record = app.CustomGovKeeper.GetIdentityRecordById(ctx, recordId) - require.Equal(t, record.Key, "description") - require.Equal(t, record.Value, "description") - - recordId = app.CustomGovKeeper.GetIdentityRecordIdByAddressKey(ctx, addr, "social") - record = app.CustomGovKeeper.GetIdentityRecordById(ctx, recordId) - require.Equal(t, record.Key, "social") - require.Equal(t, record.Value, "social") - - recordId = app.CustomGovKeeper.GetIdentityRecordIdByAddressKey(ctx, addr, "contact") - record = app.CustomGovKeeper.GetIdentityRecordById(ctx, recordId) - require.Equal(t, record.Key, "contact") - require.Equal(t, record.Value, "contact") - - recordId = app.CustomGovKeeper.GetIdentityRecordIdByAddressKey(ctx, addr, "avatar") - record = app.CustomGovKeeper.GetIdentityRecordById(ctx, recordId) - require.Equal(t, record.Key, "avatar") - require.Equal(t, record.Value, "avatar") -} - -func TestMsgServerCouncilorPause(t *testing.T) { - app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, tmproto.Header{}) - - addr := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address().Bytes()) - - // try pause with not available councilor - msgServer := keeper.NewMsgServerImpl(app.CustomGovKeeper) - _, err := msgServer.CouncilorPause(sdk.WrapSDKContext(ctx), types.NewMsgCouncilorPause( - addr, - )) - require.Error(t, err) - - // test jailed councilor pause - app.CustomGovKeeper.SaveCouncilor(ctx, types.Councilor{ - Address: addr, - Status: types.CouncilorJailed, - Rank: 0, - AbstentionCounter: 0, - }) - _, err = msgServer.CouncilorPause(sdk.WrapSDKContext(ctx), types.NewMsgCouncilorPause( - addr, - )) - require.Error(t, err) - - // test inactive councilor - app.CustomGovKeeper.SaveCouncilor(ctx, types.Councilor{ - Address: addr, - Status: types.CouncilorInactive, - Rank: 0, - AbstentionCounter: 0, - }) - _, err = msgServer.CouncilorPause(sdk.WrapSDKContext(ctx), types.NewMsgCouncilorPause( - addr, - )) - require.Error(t, err) - - // test paused councilor pause - app.CustomGovKeeper.SaveCouncilor(ctx, types.Councilor{ - Address: addr, - Status: types.CouncilorPaused, - Rank: 0, - AbstentionCounter: 0, - }) - _, err = msgServer.CouncilorPause(sdk.WrapSDKContext(ctx), types.NewMsgCouncilorPause( - addr, - )) - require.Error(t, err) - - // active councilor pause - app.CustomGovKeeper.SaveCouncilor(ctx, types.Councilor{ - Address: addr, - Status: types.CouncilorActive, - Rank: 0, - AbstentionCounter: 0, - }) - _, err = msgServer.CouncilorPause(sdk.WrapSDKContext(ctx), types.NewMsgCouncilorPause( - addr, - )) - require.NoError(t, err) - councilor, found := app.CustomGovKeeper.GetCouncilor(ctx, addr) - require.True(t, found) - require.Equal(t, councilor.Status, types.CouncilorPaused) -} - -func TestMsgServerCouncilorUnpause(t *testing.T) { - app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, tmproto.Header{}) - - addr := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address().Bytes()) - - // try unpause with not available councilor - msgServer := keeper.NewMsgServerImpl(app.CustomGovKeeper) - _, err := msgServer.CouncilorUnpause(sdk.WrapSDKContext(ctx), types.NewMsgCouncilorUnpause( - addr, - )) - require.Error(t, err) - - // test active councilor unpause - app.CustomGovKeeper.SaveCouncilor(ctx, types.Councilor{ - Address: addr, - Status: types.CouncilorActive, - Rank: 0, - AbstentionCounter: 0, - }) - _, err = msgServer.CouncilorUnpause(sdk.WrapSDKContext(ctx), types.NewMsgCouncilorUnpause( - addr, - )) - require.Error(t, err) - - // test paused councilor pause - app.CustomGovKeeper.SaveCouncilor(ctx, types.Councilor{ - Address: addr, - Status: types.CouncilorPaused, - Rank: 0, - AbstentionCounter: 0, - }) - _, err = msgServer.CouncilorUnpause(sdk.WrapSDKContext(ctx), types.NewMsgCouncilorUnpause( - addr, - )) - require.NoError(t, err) - - councilor, found := app.CustomGovKeeper.GetCouncilor(ctx, addr) - require.True(t, found) - require.Equal(t, councilor.Status, types.CouncilorActive) -} - -func TestMsgServerCouncilorActivate(t *testing.T) { - app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, tmproto.Header{}) - - addr := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address().Bytes()) - - // try activate with not available councilor - msgServer := keeper.NewMsgServerImpl(app.CustomGovKeeper) - _, err := msgServer.CouncilorActivate(sdk.WrapSDKContext(ctx), types.NewMsgCouncilorActivate( - addr, - )) - require.Error(t, err) - - // test active councilor activate - app.CustomGovKeeper.SaveCouncilor(ctx, types.Councilor{ - Address: addr, - Status: types.CouncilorActive, - Rank: 0, - AbstentionCounter: 100, - }) - _, err = msgServer.CouncilorActivate(sdk.WrapSDKContext(ctx), types.NewMsgCouncilorActivate( - addr, - )) - require.Error(t, err) - - // test inactive councilor activate - app.CustomGovKeeper.SaveCouncilor(ctx, types.Councilor{ - Address: addr, - Status: types.CouncilorInactive, - Rank: 0, - AbstentionCounter: 100, - }) - _, err = msgServer.CouncilorActivate(sdk.WrapSDKContext(ctx), types.NewMsgCouncilorActivate( - addr, - )) - require.NoError(t, err) - - councilor, found := app.CustomGovKeeper.GetCouncilor(ctx, addr) - require.True(t, found) - // check status change - require.Equal(t, councilor.Status, types.CouncilorActive) - // check absention counter change - require.Equal(t, councilor.AbstentionCounter, int64(0)) -} +package keeper_test + +import ( + "testing" + + simapp "github.com/KiraCore/sekai/app" + "github.com/KiraCore/sekai/x/gov/keeper" + "github.com/KiraCore/sekai/x/gov/types" + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" +) + +func TestMsgServerClaimCouncilor(t *testing.T) { + app := simapp.Setup(false) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) + + addr := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address().Bytes()) + + // try claim with not allowed user + msgServer := keeper.NewMsgServerImpl(app.CustomGovKeeper) + _, err := msgServer.ClaimCouncilor(sdk.WrapSDKContext(ctx), types.NewMsgClaimCouncilor( + addr, "moniker", "username", "description", "social", "contact", "avatar", + )) + require.Error(t, err) + + // try claim with allowed user + actor := types.NewDefaultActor(addr) + err = app.CustomGovKeeper.AddWhitelistPermission(ctx, actor, types.PermClaimCouncilor) + require.NoError(t, err) + _, err = msgServer.ClaimCouncilor(sdk.WrapSDKContext(ctx), types.NewMsgClaimCouncilor( + addr, "moniker", "username", "description", "social", "contact", "avatar", + )) + require.NoError(t, err) + + // check councilor created + councilor, found := app.CustomGovKeeper.GetCouncilor(ctx, addr) + require.True(t, found) + require.Equal(t, councilor, types.Councilor{ + Address: addr, + Status: types.CouncilorActive, + Rank: 0, + AbstentionCounter: 0, + }) + + // check moniker, username, description, social, contact, avatar registered correctly + recordId := app.CustomGovKeeper.GetIdentityRecordIdByAddressKey(ctx, addr, "moniker") + record := app.CustomGovKeeper.GetIdentityRecordById(ctx, recordId) + require.Equal(t, record.Key, "moniker") + require.Equal(t, record.Value, "moniker") + + recordId = app.CustomGovKeeper.GetIdentityRecordIdByAddressKey(ctx, addr, "username") + record = app.CustomGovKeeper.GetIdentityRecordById(ctx, recordId) + require.Equal(t, record.Key, "username") + require.Equal(t, record.Value, "username") + + recordId = app.CustomGovKeeper.GetIdentityRecordIdByAddressKey(ctx, addr, "description") + record = app.CustomGovKeeper.GetIdentityRecordById(ctx, recordId) + require.Equal(t, record.Key, "description") + require.Equal(t, record.Value, "description") + + recordId = app.CustomGovKeeper.GetIdentityRecordIdByAddressKey(ctx, addr, "social") + record = app.CustomGovKeeper.GetIdentityRecordById(ctx, recordId) + require.Equal(t, record.Key, "social") + require.Equal(t, record.Value, "social") + + recordId = app.CustomGovKeeper.GetIdentityRecordIdByAddressKey(ctx, addr, "contact") + record = app.CustomGovKeeper.GetIdentityRecordById(ctx, recordId) + require.Equal(t, record.Key, "contact") + require.Equal(t, record.Value, "contact") + + recordId = app.CustomGovKeeper.GetIdentityRecordIdByAddressKey(ctx, addr, "avatar") + record = app.CustomGovKeeper.GetIdentityRecordById(ctx, recordId) + require.Equal(t, record.Key, "avatar") + require.Equal(t, record.Value, "avatar") +} + +func TestMsgServerCouncilorPause(t *testing.T) { + app := simapp.Setup(false) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) + + addr := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address().Bytes()) + + // try pause with not available councilor + msgServer := keeper.NewMsgServerImpl(app.CustomGovKeeper) + _, err := msgServer.CouncilorPause(sdk.WrapSDKContext(ctx), types.NewMsgCouncilorPause( + addr, + )) + require.Error(t, err) + + // test jailed councilor pause + app.CustomGovKeeper.SaveCouncilor(ctx, types.Councilor{ + Address: addr, + Status: types.CouncilorJailed, + Rank: 0, + AbstentionCounter: 0, + }) + _, err = msgServer.CouncilorPause(sdk.WrapSDKContext(ctx), types.NewMsgCouncilorPause( + addr, + )) + require.Error(t, err) + + // test inactive councilor + app.CustomGovKeeper.SaveCouncilor(ctx, types.Councilor{ + Address: addr, + Status: types.CouncilorInactive, + Rank: 0, + AbstentionCounter: 0, + }) + _, err = msgServer.CouncilorPause(sdk.WrapSDKContext(ctx), types.NewMsgCouncilorPause( + addr, + )) + require.Error(t, err) + + // test paused councilor pause + app.CustomGovKeeper.SaveCouncilor(ctx, types.Councilor{ + Address: addr, + Status: types.CouncilorPaused, + Rank: 0, + AbstentionCounter: 0, + }) + _, err = msgServer.CouncilorPause(sdk.WrapSDKContext(ctx), types.NewMsgCouncilorPause( + addr, + )) + require.Error(t, err) + + // active councilor pause + app.CustomGovKeeper.SaveCouncilor(ctx, types.Councilor{ + Address: addr, + Status: types.CouncilorActive, + Rank: 0, + AbstentionCounter: 0, + }) + _, err = msgServer.CouncilorPause(sdk.WrapSDKContext(ctx), types.NewMsgCouncilorPause( + addr, + )) + require.NoError(t, err) + councilor, found := app.CustomGovKeeper.GetCouncilor(ctx, addr) + require.True(t, found) + require.Equal(t, councilor.Status, types.CouncilorPaused) +} + +func TestMsgServerCouncilorUnpause(t *testing.T) { + app := simapp.Setup(false) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) + + addr := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address().Bytes()) + + // try unpause with not available councilor + msgServer := keeper.NewMsgServerImpl(app.CustomGovKeeper) + _, err := msgServer.CouncilorUnpause(sdk.WrapSDKContext(ctx), types.NewMsgCouncilorUnpause( + addr, + )) + require.Error(t, err) + + // test active councilor unpause + app.CustomGovKeeper.SaveCouncilor(ctx, types.Councilor{ + Address: addr, + Status: types.CouncilorActive, + Rank: 0, + AbstentionCounter: 0, + }) + _, err = msgServer.CouncilorUnpause(sdk.WrapSDKContext(ctx), types.NewMsgCouncilorUnpause( + addr, + )) + require.Error(t, err) + + // test paused councilor pause + app.CustomGovKeeper.SaveCouncilor(ctx, types.Councilor{ + Address: addr, + Status: types.CouncilorPaused, + Rank: 0, + AbstentionCounter: 0, + }) + _, err = msgServer.CouncilorUnpause(sdk.WrapSDKContext(ctx), types.NewMsgCouncilorUnpause( + addr, + )) + require.NoError(t, err) + + councilor, found := app.CustomGovKeeper.GetCouncilor(ctx, addr) + require.True(t, found) + require.Equal(t, councilor.Status, types.CouncilorActive) +} + +func TestMsgServerCouncilorActivate(t *testing.T) { + app := simapp.Setup(false) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) + + addr := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address().Bytes()) + + // try activate with not available councilor + msgServer := keeper.NewMsgServerImpl(app.CustomGovKeeper) + _, err := msgServer.CouncilorActivate(sdk.WrapSDKContext(ctx), types.NewMsgCouncilorActivate( + addr, + )) + require.Error(t, err) + + // test active councilor activate + app.CustomGovKeeper.SaveCouncilor(ctx, types.Councilor{ + Address: addr, + Status: types.CouncilorActive, + Rank: 0, + AbstentionCounter: 100, + }) + _, err = msgServer.CouncilorActivate(sdk.WrapSDKContext(ctx), types.NewMsgCouncilorActivate( + addr, + )) + require.Error(t, err) + + // test inactive councilor activate + app.CustomGovKeeper.SaveCouncilor(ctx, types.Councilor{ + Address: addr, + Status: types.CouncilorInactive, + Rank: 0, + AbstentionCounter: 100, + }) + _, err = msgServer.CouncilorActivate(sdk.WrapSDKContext(ctx), types.NewMsgCouncilorActivate( + addr, + )) + require.NoError(t, err) + + councilor, found := app.CustomGovKeeper.GetCouncilor(ctx, addr) + require.True(t, found) + // check status change + require.Equal(t, councilor.Status, types.CouncilorActive) + // check absention counter change + require.Equal(t, councilor.AbstentionCounter, int64(0)) +} diff --git a/x/gov/keeper/network_actor.go b/x/gov/keeper/network_actor.go index a1bf5f820..b29996856 100644 --- a/x/gov/keeper/network_actor.go +++ b/x/gov/keeper/network_actor.go @@ -13,6 +13,11 @@ func (k Keeper) SaveNetworkActor(ctx sdk.Context, actor types.NetworkActor) { prefixStore.Set(actor.Address.Bytes(), bz) } +func (k Keeper) DeleteNetworkActor(ctx sdk.Context, actor types.NetworkActor) { + prefixStore := prefix.NewStore(ctx.KVStore(k.storeKey), NetworkActorsPrefix) + prefixStore.Delete(actor.Address.Bytes()) +} + func (k Keeper) GetNetworkActorByAddress(ctx sdk.Context, address sdk.AccAddress) (types.NetworkActor, bool) { prefixStore := prefix.NewStore(ctx.KVStore(k.storeKey), NetworkActorsPrefix) @@ -44,6 +49,11 @@ func (k Keeper) SetWhitelistAddressPermKey(ctx sdk.Context, actor types.NetworkA store.Set(WhitelistAddressPermKey(actor.Address, perm), actor.Address.Bytes()) } +func (k Keeper) DeleteWhitelistAddressPermKey(ctx sdk.Context, actor types.NetworkActor, perm types.PermValue) { + store := ctx.KVStore(k.storeKey) + store.Delete(WhitelistAddressPermKey(actor.Address, perm)) +} + // AddWhitelistPermission whitelist a permission to an address. It saves the actor after it. func (k Keeper) AddWhitelistPermission(ctx sdk.Context, actor types.NetworkActor, perm types.PermValue) error { err := actor.Permissions.AddToWhitelist(perm) @@ -83,10 +93,7 @@ func (k Keeper) RemoveWhitelistedPermission(ctx sdk.Context, actor types.Network } k.SaveNetworkActor(ctx, actor) - - store := ctx.KVStore(k.storeKey) - store.Delete(WhitelistAddressPermKey(actor.Address, perm)) - + k.DeleteWhitelistAddressPermKey(ctx, actor, perm) return nil } @@ -196,7 +203,7 @@ func (k Keeper) GetNetworkActorsByAbsoluteWhitelistPermission(ctx sdk.Context, p for ; iterator.Valid(); iterator.Next() { if _, ok := duplicateMap[sdk.AccAddress(iterator.Value()).String()]; !ok { duplicateMap[sdk.AccAddress(iterator.Value()).String()] = true - actors = append(actors, k.getNetworkActorOrFail(ctx, iterator.Value())) + actors = append(actors, k.GetNetworkActorOrFail(ctx, iterator.Value())) } } @@ -209,7 +216,7 @@ func (k Keeper) GetNetworkActorsByAbsoluteWhitelistPermission(ctx sdk.Context, p for ; actorIter.Valid(); actorIter.Next() { if _, ok := duplicateMap[sdk.AccAddress(actorIter.Value()).String()]; !ok { duplicateMap[sdk.AccAddress(actorIter.Value()).String()] = true - actors = append(actors, k.getNetworkActorOrFail(ctx, actorIter.Value())) + actors = append(actors, k.GetNetworkActorOrFail(ctx, actorIter.Value())) } } } @@ -217,7 +224,7 @@ func (k Keeper) GetNetworkActorsByAbsoluteWhitelistPermission(ctx sdk.Context, p return actors } -func (k Keeper) getNetworkActorOrFail(ctx sdk.Context, addr sdk.AccAddress) types.NetworkActor { +func (k Keeper) GetNetworkActorOrFail(ctx sdk.Context, addr sdk.AccAddress) types.NetworkActor { actor, found := k.GetNetworkActorByAddress(ctx, addr) if !found { panic("expected network actor not found") diff --git a/x/gov/keeper/network_actor_test.go b/x/gov/keeper/network_actor_test.go index f2aca9d1f..d222318e5 100644 --- a/x/gov/keeper/network_actor_test.go +++ b/x/gov/keeper/network_actor_test.go @@ -1,410 +1,410 @@ -package keeper_test - -import ( - "testing" - - simapp "github.com/KiraCore/sekai/app" - "github.com/KiraCore/sekai/x/gov/types" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/require" - tmproto "github.com/tendermint/tendermint/proto/tendermint/types" -) - -func TestNewKeeper_SaveNetworkActor(t *testing.T) { - app := simapp.Setup(false) - ctx := app.NewContext(false, tmproto.Header{}) - - addrs := simapp.AddTestAddrsIncremental(app, ctx, 1, sdk.TokensFromConsensusPower(10, sdk.DefaultPowerReduction)) - addr := addrs[0] - - networkActor := types.NetworkActor{ - Address: addr, - } - - app.CustomGovKeeper.SaveNetworkActor(ctx, networkActor) - - savedActor, found := app.CustomGovKeeper.GetNetworkActorByAddress(ctx, networkActor.Address) - require.True(t, found) - - require.Equal(t, networkActor, savedActor) -} - -func TestKeeper_GetNetworkActorByAddress_FailsIfItDoesNotExist(t *testing.T) { - app := simapp.Setup(false) - ctx := app.NewContext(false, tmproto.Header{}) - - addrs := simapp.AddTestAddrsIncremental(app, ctx, 1, sdk.TokensFromConsensusPower(10, sdk.DefaultPowerReduction)) - addr := addrs[0] - - _, found := app.CustomGovKeeper.GetNetworkActorByAddress(ctx, addr) - require.False(t, found) -} - -func TestKeeper_AssignRoleToAddress(t *testing.T) { - app := simapp.Setup(false) - ctx := app.NewContext(false, tmproto.Header{}) - - addrs := simapp.AddTestAddrsIncremental(app, ctx, 1, sdk.TokensFromConsensusPower(10, sdk.DefaultPowerReduction)) - addr := addrs[0] - - actor := types.NewDefaultActor(addr) - app.CustomGovKeeper.AssignRoleToActor(ctx, actor, types.RoleSudo) - - savedActor, found := app.CustomGovKeeper.GetNetworkActorByAddress(ctx, addr) - require.True(t, found) - require.True(t, savedActor.HasRole(types.RoleSudo)) -} - -func TestKeeper_AddPermissionToNetworkActor(t *testing.T) { - app := simapp.Setup(false) - ctx := app.NewContext(false, tmproto.Header{}) - - addrs := simapp.AddTestAddrsIncremental(app, ctx, 1, sdk.TokensFromConsensusPower(10, sdk.DefaultPowerReduction)) - addr := addrs[0] - - networkActor := types.NewNetworkActor( - addr, - nil, - 1, - nil, - types.NewPermissions(nil, nil), - 1, - ) - - app.CustomGovKeeper.SaveNetworkActor(ctx, networkActor) - - // We check he does not have permissions - savedNetworkActor, found := app.CustomGovKeeper.GetNetworkActorByAddress(ctx, addr) - require.True(t, found) - require.False(t, savedNetworkActor.Permissions.IsWhitelisted(types.PermSetPermissions)) - - // We add permissions and we save it again. - err := app.CustomGovKeeper.AddWhitelistPermission(ctx, savedNetworkActor, types.PermSetPermissions) - require.NoError(t, err) - - // And we check that now it has permissions - savedNetworkActor, found = app.CustomGovKeeper.GetNetworkActorByAddress(ctx, addr) - require.True(t, found) - require.True(t, savedNetworkActor.Permissions.IsWhitelisted(types.PermSetPermissions)) - - _, found = app.CustomGovKeeper.GetCouncilor(ctx, addr) - require.False(t, found) - - // check gov claim permission - err = app.CustomGovKeeper.AddWhitelistPermission(ctx, savedNetworkActor, types.PermClaimCouncilor) - require.NoError(t, err) - savedNetworkActor, found = app.CustomGovKeeper.GetNetworkActorByAddress(ctx, addr) - require.True(t, found) - require.True(t, savedNetworkActor.Permissions.IsWhitelisted(types.PermClaimCouncilor)) - - councilor, found := app.CustomGovKeeper.GetCouncilor(ctx, addr) - require.True(t, found) - require.Equal(t, councilor.Status, types.CouncilorWaiting) -} - -func TestKeeper_RemoveWhitelistPermission(t *testing.T) { - app := simapp.Setup(false) - ctx := app.NewContext(false, tmproto.Header{}) - - addrs := simapp.AddTestAddrsIncremental(app, ctx, 2, sdk.TokensFromConsensusPower(10, sdk.DefaultPowerReduction)) - - err := whitelistPermToMultipleAddrs(app, ctx, addrs, types.PermSetPermissions) - require.NoError(t, err) - - iterator := app.CustomGovKeeper.GetNetworkActorsByWhitelistedPermission(ctx, types.PermSetPermissions) - requireIteratorCount(t, iterator, 2) - assertAddrsHaveWhitelistedPerm(t, app, ctx, addrs, types.PermSetPermissions) - - actor, found := app.CustomGovKeeper.GetNetworkActorByAddress(ctx, addrs[0]) - require.True(t, found) - err = app.CustomGovKeeper.RemoveWhitelistedPermission(ctx, actor, types.PermSetPermissions) - require.NoError(t, err) - - iterator = app.CustomGovKeeper.GetNetworkActorsByWhitelistedPermission(ctx, types.PermSetPermissions) - requireIteratorCount(t, iterator, 1) - - assertAddrsDontHaveWhitelistedPerm(t, app, ctx, []sdk.AccAddress{addrs[0]}, types.PermSetPermissions) - assertAddrsHaveWhitelistedPerm(t, app, ctx, []sdk.AccAddress{addrs[1]}, types.PermSetPermissions) -} - -func TestAssignRoleToAccount(t *testing.T) { - app := simapp.Setup(false) - ctx := app.NewContext(false, tmproto.Header{}) - - addrs := simapp.AddTestAddrsIncremental(app, ctx, 1, sdk.TokensFromConsensusPower(10, sdk.DefaultPowerReduction)) - addr := addrs[0] - - networkActor := types.NewNetworkActor( - addr, - nil, - 1, - nil, - types.NewPermissions(nil, nil), - 1, - ) - - app.CustomGovKeeper.SaveNetworkActor(ctx, networkActor) - - // check sudo role assign - err := app.CustomGovKeeper.AssignRoleToAccount(ctx, addr, types.RoleSudo) - require.NoError(t, err) - savedNetworkActor, found := app.CustomGovKeeper.GetNetworkActorByAddress(ctx, addr) - require.True(t, found) - require.True(t, savedNetworkActor.HasRole(types.RoleSudo)) - - councilor, found := app.CustomGovKeeper.GetCouncilor(ctx, addr) - require.True(t, found) - require.Equal(t, councilor.Status, types.CouncilorWaiting) -} - -func TestKeeper_GetActorsByRole(t *testing.T) { - app := simapp.Setup(false) - ctx := app.NewContext(false, tmproto.Header{}) - - addrs := simapp.AddTestAddrsIncremental(app, ctx, 2, sdk.TokensFromConsensusPower(10, sdk.DefaultPowerReduction)) - - addRoleToMultipleAddrs(app, ctx, addrs, types.RoleSudo) - - iterator := app.CustomGovKeeper.GetNetworkActorsByRole(ctx, types.RoleSudo) - requireIteratorCount(t, iterator, 2) - - assertAddrsHaveRole(t, app, ctx, addrs, types.RoleSudo) -} - -func TestKeeper_RemoveRole(t *testing.T) { - app := simapp.Setup(false) - ctx := app.NewContext(false, tmproto.Header{}) - - addrs := simapp.AddTestAddrsIncremental(app, ctx, 2, sdk.TokensFromConsensusPower(10, sdk.DefaultPowerReduction)) - - addRoleToMultipleAddrs(app, ctx, addrs, types.RoleSudo) - - iterator := app.CustomGovKeeper.GetNetworkActorsByRole(ctx, types.RoleSudo) - requireIteratorCount(t, iterator, 2) - - assertAddrsHaveRole(t, app, ctx, addrs, types.RoleSudo) - - actor, found := app.CustomGovKeeper.GetNetworkActorByAddress(ctx, addrs[0]) - require.True(t, found) - require.True(t, actor.HasRole(types.RoleSudo)) - - app.CustomGovKeeper.RemoveRoleFromActor(ctx, actor, types.RoleSudo) - - actor, found = app.CustomGovKeeper.GetNetworkActorByAddress(ctx, addrs[0]) - require.True(t, found) - require.False(t, actor.HasRole(types.RoleSudo)) - - iterator = app.CustomGovKeeper.GetNetworkActorsByRole(ctx, types.RoleSudo) - requireIteratorCount(t, iterator, 1) - -} - -func TestKeeper_GetActorsByWhitelistedPerm(t *testing.T) { - app := simapp.Setup(false) - ctx := app.NewContext(false, tmproto.Header{}) - - addrs := simapp.AddTestAddrsIncremental(app, ctx, 2, sdk.TokensFromConsensusPower(10, sdk.DefaultPowerReduction)) - - err := whitelistPermToMultipleAddrs(app, ctx, addrs, types.PermSetPermissions) - require.NoError(t, err) - - iterator := app.CustomGovKeeper.GetNetworkActorsByWhitelistedPermission(ctx, types.PermSetPermissions) - requireIteratorCount(t, iterator, 2) - - assertAddrsHaveWhitelistedPerm(t, app, ctx, addrs, types.PermSetPermissions) -} - -func TestKeeper_GetNetworkActorsByAbsoluteWhitelistPermission(t *testing.T) { - tests := []struct { - name string - prepareApp func(app *simapp.SekaiApp, ctx sdk.Context) []types.NetworkActor - }{ - { - name: "some addresses whitelisted", - prepareApp: func(app *simapp.SekaiApp, ctx sdk.Context) []types.NetworkActor { - addrs := simapp.AddTestAddrsIncremental(app, ctx, 2, sdk.TokensFromConsensusPower(10, sdk.DefaultPowerReduction)) - - err := whitelistPermToMultipleAddrs(app, ctx, addrs, types.PermSetPermissions) - require.NoError(t, err) - - expectedActors := []types.NetworkActor{ - types.NewDefaultActor(addrs[0]), - types.NewDefaultActor(addrs[1]), - } - - return expectedActors - }, - }, - { - name: "some addresses whitelisted by role", - prepareApp: func(app *simapp.SekaiApp, ctx sdk.Context) []types.NetworkActor { - addrs := simapp.AddTestAddrsIncremental(app, ctx, 2, sdk.TokensFromConsensusPower(10, sdk.DefaultPowerReduction)) - - // Create role - app.CustomGovKeeper.SetRole(ctx, types.Role{ - Id: 12345, - Sid: "12345", - Description: "12345", - }) - err := app.CustomGovKeeper.WhitelistRolePermission(ctx, 12345, types.PermSetPermissions) - require.NoError(t, err) - - for _, addr := range addrs { - actor := types.NewDefaultActor(addr) - app.CustomGovKeeper.AssignRoleToActor(ctx, actor, 12345) - } - - expectedActors := []types.NetworkActor{ - types.NewDefaultActor(addrs[0]), - types.NewDefaultActor(addrs[1]), - } - - return expectedActors - }, - }, - { - name: "whitelisted address whitelisted by role and personal permission (case 1)", - prepareApp: func(app *simapp.SekaiApp, ctx sdk.Context) []types.NetworkActor { - addrs := simapp.AddTestAddrsIncremental(app, ctx, 2, sdk.TokensFromConsensusPower(10, sdk.DefaultPowerReduction)) - - // Create role - app.CustomGovKeeper.SetRole(ctx, types.Role{ - Id: 12345, - Sid: "12345", - Description: "12345", - }) - err := app.CustomGovKeeper.WhitelistRolePermission(ctx, 12345, types.PermSetPermissions) - require.NoError(t, err) - - // We whitelist all by the role. - for _, addr := range addrs { - actor := types.NewDefaultActor(addr) - app.CustomGovKeeper.AssignRoleToActor(ctx, actor, 12345) - } - - err = app.CustomGovKeeper.AddWhitelistPermission(ctx, types.NewDefaultActor(addrs[0]), types.PermSetPermissions) - require.NoError(t, err) - - expectedActors := []types.NetworkActor{ - types.NewDefaultActor(addrs[0]), - types.NewDefaultActor(addrs[1]), - } - - return expectedActors - }, - }, - { - name: "whitelisted address whitelisted by role and personal permission (case 2)", - prepareApp: func(app *simapp.SekaiApp, ctx sdk.Context) []types.NetworkActor { - addrs := simapp.AddTestAddrsIncremental(app, ctx, 2, sdk.TokensFromConsensusPower(10, sdk.DefaultPowerReduction)) - - // Create role - app.CustomGovKeeper.SetRole(ctx, types.Role{ - Id: 12345, - Sid: "12345", - Description: "12345", - }) - err := app.CustomGovKeeper.WhitelistRolePermission(ctx, 12345, types.PermSetPermissions) - require.NoError(t, err) - - // We assign role to first actor. - actor := types.NewDefaultActor(addrs[0]) - app.CustomGovKeeper.AssignRoleToActor(ctx, actor, 12345) - - err = whitelistPermToMultipleAddrs(app, ctx, addrs, types.PermSetPermissions) - require.NoError(t, err) - - expectedActors := []types.NetworkActor{ - types.NewDefaultActor(addrs[0]), - types.NewDefaultActor(addrs[1]), - } - - return expectedActors - }, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - app := simapp.Setup(false) - ctx := app.NewContext(false, tmproto.Header{}) - - expectecActors := tt.prepareApp(app, ctx) - savedPerms := app.CustomGovKeeper.GetNetworkActorsByAbsoluteWhitelistPermission(ctx, types.PermSetPermissions) - - require.Equal(t, len(expectecActors), len(savedPerms)) - for i, actor := range expectecActors { - require.Equal(t, actor.Address, savedPerms[i].Address) - } - }) - } -} - -func addRoleToMultipleAddrs(app *simapp.SekaiApp, ctx sdk.Context, addrs []sdk.AccAddress, role uint64) { - for _, addr := range addrs { - app.CustomGovKeeper.AssignRoleToActor(ctx, types.NewDefaultActor(addr), role) - } -} - -func whitelistPermToMultipleAddrs(app *simapp.SekaiApp, ctx sdk.Context, addrs []sdk.AccAddress, permissions types.PermValue) error { - for _, addr := range addrs { - err := app.CustomGovKeeper.AddWhitelistPermission(ctx, types.NewDefaultActor(addr), permissions) - if err != nil { - return err - } - } - - return nil -} - -func requireIteratorCount(t *testing.T, iterator sdk.Iterator, expectedCount int) { - c := 0 - for ; iterator.Valid(); iterator.Next() { - c++ - } - - require.Equal(t, expectedCount, c) -} - -func assertAddrsHaveWhitelistedPerm( - t *testing.T, - app *simapp.SekaiApp, - ctx sdk.Context, - addrs []sdk.AccAddress, - perm types.PermValue, -) { - for _, addr := range addrs { - actor, found := app.CustomGovKeeper.GetNetworkActorByAddress(ctx, addr) - require.True(t, found) - require.True(t, actor.Permissions.IsWhitelisted(perm)) - } -} - -func assertAddrsHaveRole( - t *testing.T, - app *simapp.SekaiApp, - ctx sdk.Context, - addrs []sdk.AccAddress, - role uint64, -) { - for _, addr := range addrs { - actor, found := app.CustomGovKeeper.GetNetworkActorByAddress(ctx, addr) - require.True(t, found) - require.True(t, actor.HasRole(role)) - } -} - -func assertAddrsDontHaveWhitelistedPerm( - t *testing.T, - app *simapp.SekaiApp, - ctx sdk.Context, - addrs []sdk.AccAddress, - perm types.PermValue, -) { - for _, addr := range addrs { - actor, found := app.CustomGovKeeper.GetNetworkActorByAddress(ctx, addr) - require.True(t, found) - require.False(t, actor.Permissions.IsWhitelisted(perm)) - } -} +package keeper_test + +import ( + "testing" + + simapp "github.com/KiraCore/sekai/app" + "github.com/KiraCore/sekai/x/gov/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" +) + +func TestNewKeeper_SaveNetworkActor(t *testing.T) { + app := simapp.Setup(false) + ctx := app.NewContext(false, tmproto.Header{}) + + addrs := simapp.AddTestAddrsIncremental(app, ctx, 1, sdk.TokensFromConsensusPower(10, sdk.DefaultPowerReduction)) + addr := addrs[0] + + networkActor := types.NetworkActor{ + Address: addr, + } + + app.CustomGovKeeper.SaveNetworkActor(ctx, networkActor) + + savedActor, found := app.CustomGovKeeper.GetNetworkActorByAddress(ctx, networkActor.Address) + require.True(t, found) + + require.Equal(t, networkActor, savedActor) +} + +func TestKeeper_GetNetworkActorByAddress_FailsIfItDoesNotExist(t *testing.T) { + app := simapp.Setup(false) + ctx := app.NewContext(false, tmproto.Header{}) + + addrs := simapp.AddTestAddrsIncremental(app, ctx, 1, sdk.TokensFromConsensusPower(10, sdk.DefaultPowerReduction)) + addr := addrs[0] + + _, found := app.CustomGovKeeper.GetNetworkActorByAddress(ctx, addr) + require.False(t, found) +} + +func TestKeeper_AssignRoleToAddress(t *testing.T) { + app := simapp.Setup(false) + ctx := app.NewContext(false, tmproto.Header{}) + + addrs := simapp.AddTestAddrsIncremental(app, ctx, 1, sdk.TokensFromConsensusPower(10, sdk.DefaultPowerReduction)) + addr := addrs[0] + + actor := types.NewDefaultActor(addr) + app.CustomGovKeeper.AssignRoleToActor(ctx, actor, types.RoleSudo) + + savedActor, found := app.CustomGovKeeper.GetNetworkActorByAddress(ctx, addr) + require.True(t, found) + require.True(t, savedActor.HasRole(types.RoleSudo)) +} + +func TestKeeper_AddPermissionToNetworkActor(t *testing.T) { + app := simapp.Setup(false) + ctx := app.NewContext(false, tmproto.Header{}) + + addrs := simapp.AddTestAddrsIncremental(app, ctx, 1, sdk.TokensFromConsensusPower(10, sdk.DefaultPowerReduction)) + addr := addrs[0] + + networkActor := types.NewNetworkActor( + addr, + nil, + 1, + nil, + types.NewPermissions(nil, nil), + 1, + ) + + app.CustomGovKeeper.SaveNetworkActor(ctx, networkActor) + + // We check he does not have permissions + savedNetworkActor, found := app.CustomGovKeeper.GetNetworkActorByAddress(ctx, addr) + require.True(t, found) + require.False(t, savedNetworkActor.Permissions.IsWhitelisted(types.PermSetPermissions)) + + // We add permissions and we save it again. + err := app.CustomGovKeeper.AddWhitelistPermission(ctx, savedNetworkActor, types.PermSetPermissions) + require.NoError(t, err) + + // And we check that now it has permissions + savedNetworkActor, found = app.CustomGovKeeper.GetNetworkActorByAddress(ctx, addr) + require.True(t, found) + require.True(t, savedNetworkActor.Permissions.IsWhitelisted(types.PermSetPermissions)) + + _, found = app.CustomGovKeeper.GetCouncilor(ctx, addr) + require.False(t, found) + + // check gov claim permission + err = app.CustomGovKeeper.AddWhitelistPermission(ctx, savedNetworkActor, types.PermClaimCouncilor) + require.NoError(t, err) + savedNetworkActor, found = app.CustomGovKeeper.GetNetworkActorByAddress(ctx, addr) + require.True(t, found) + require.True(t, savedNetworkActor.Permissions.IsWhitelisted(types.PermClaimCouncilor)) + + councilor, found := app.CustomGovKeeper.GetCouncilor(ctx, addr) + require.True(t, found) + require.Equal(t, councilor.Status, types.CouncilorWaiting) +} + +func TestKeeper_RemoveWhitelistPermission(t *testing.T) { + app := simapp.Setup(false) + ctx := app.NewContext(false, tmproto.Header{}) + + addrs := simapp.AddTestAddrsIncremental(app, ctx, 2, sdk.TokensFromConsensusPower(10, sdk.DefaultPowerReduction)) + + err := whitelistPermToMultipleAddrs(app, ctx, addrs, types.PermSetPermissions) + require.NoError(t, err) + + iterator := app.CustomGovKeeper.GetNetworkActorsByWhitelistedPermission(ctx, types.PermSetPermissions) + requireIteratorCount(t, iterator, 2) + assertAddrsHaveWhitelistedPerm(t, app, ctx, addrs, types.PermSetPermissions) + + actor, found := app.CustomGovKeeper.GetNetworkActorByAddress(ctx, addrs[0]) + require.True(t, found) + err = app.CustomGovKeeper.RemoveWhitelistedPermission(ctx, actor, types.PermSetPermissions) + require.NoError(t, err) + + iterator = app.CustomGovKeeper.GetNetworkActorsByWhitelistedPermission(ctx, types.PermSetPermissions) + requireIteratorCount(t, iterator, 1) + + assertAddrsDontHaveWhitelistedPerm(t, app, ctx, []sdk.AccAddress{addrs[0]}, types.PermSetPermissions) + assertAddrsHaveWhitelistedPerm(t, app, ctx, []sdk.AccAddress{addrs[1]}, types.PermSetPermissions) +} + +func TestAssignRoleToAccount(t *testing.T) { + app := simapp.Setup(false) + ctx := app.NewContext(false, tmproto.Header{}) + + addrs := simapp.AddTestAddrsIncremental(app, ctx, 1, sdk.TokensFromConsensusPower(10, sdk.DefaultPowerReduction)) + addr := addrs[0] + + networkActor := types.NewNetworkActor( + addr, + nil, + 1, + nil, + types.NewPermissions(nil, nil), + 1, + ) + + app.CustomGovKeeper.SaveNetworkActor(ctx, networkActor) + + // check sudo role assign + err := app.CustomGovKeeper.AssignRoleToAccount(ctx, addr, types.RoleSudo) + require.NoError(t, err) + savedNetworkActor, found := app.CustomGovKeeper.GetNetworkActorByAddress(ctx, addr) + require.True(t, found) + require.True(t, savedNetworkActor.HasRole(types.RoleSudo)) + + councilor, found := app.CustomGovKeeper.GetCouncilor(ctx, addr) + require.True(t, found) + require.Equal(t, councilor.Status, types.CouncilorWaiting) +} + +func TestKeeper_GetActorsByRole(t *testing.T) { + app := simapp.Setup(false) + ctx := app.NewContext(false, tmproto.Header{}) + + addrs := simapp.AddTestAddrsIncremental(app, ctx, 2, sdk.TokensFromConsensusPower(10, sdk.DefaultPowerReduction)) + + addRoleToMultipleAddrs(app, ctx, addrs, types.RoleSudo) + + iterator := app.CustomGovKeeper.GetNetworkActorsByRole(ctx, types.RoleSudo) + requireIteratorCount(t, iterator, 2) + + assertAddrsHaveRole(t, app, ctx, addrs, types.RoleSudo) +} + +func TestKeeper_RemoveRole(t *testing.T) { + app := simapp.Setup(false) + ctx := app.NewContext(false, tmproto.Header{}) + + addrs := simapp.AddTestAddrsIncremental(app, ctx, 2, sdk.TokensFromConsensusPower(10, sdk.DefaultPowerReduction)) + + addRoleToMultipleAddrs(app, ctx, addrs, types.RoleSudo) + + iterator := app.CustomGovKeeper.GetNetworkActorsByRole(ctx, types.RoleSudo) + requireIteratorCount(t, iterator, 2) + + assertAddrsHaveRole(t, app, ctx, addrs, types.RoleSudo) + + actor, found := app.CustomGovKeeper.GetNetworkActorByAddress(ctx, addrs[0]) + require.True(t, found) + require.True(t, actor.HasRole(types.RoleSudo)) + + app.CustomGovKeeper.RemoveRoleFromActor(ctx, actor, types.RoleSudo) + + actor, found = app.CustomGovKeeper.GetNetworkActorByAddress(ctx, addrs[0]) + require.True(t, found) + require.False(t, actor.HasRole(types.RoleSudo)) + + iterator = app.CustomGovKeeper.GetNetworkActorsByRole(ctx, types.RoleSudo) + requireIteratorCount(t, iterator, 1) + +} + +func TestKeeper_GetActorsByWhitelistedPerm(t *testing.T) { + app := simapp.Setup(false) + ctx := app.NewContext(false, tmproto.Header{}) + + addrs := simapp.AddTestAddrsIncremental(app, ctx, 2, sdk.TokensFromConsensusPower(10, sdk.DefaultPowerReduction)) + + err := whitelistPermToMultipleAddrs(app, ctx, addrs, types.PermSetPermissions) + require.NoError(t, err) + + iterator := app.CustomGovKeeper.GetNetworkActorsByWhitelistedPermission(ctx, types.PermSetPermissions) + requireIteratorCount(t, iterator, 2) + + assertAddrsHaveWhitelistedPerm(t, app, ctx, addrs, types.PermSetPermissions) +} + +func TestKeeper_GetNetworkActorsByAbsoluteWhitelistPermission(t *testing.T) { + tests := []struct { + name string + prepareApp func(app *simapp.SekaiApp, ctx sdk.Context) []types.NetworkActor + }{ + { + name: "some addresses whitelisted", + prepareApp: func(app *simapp.SekaiApp, ctx sdk.Context) []types.NetworkActor { + addrs := simapp.AddTestAddrsIncremental(app, ctx, 2, sdk.TokensFromConsensusPower(10, sdk.DefaultPowerReduction)) + + err := whitelistPermToMultipleAddrs(app, ctx, addrs, types.PermSetPermissions) + require.NoError(t, err) + + expectedActors := []types.NetworkActor{ + types.NewDefaultActor(addrs[0]), + types.NewDefaultActor(addrs[1]), + } + + return expectedActors + }, + }, + { + name: "some addresses whitelisted by role", + prepareApp: func(app *simapp.SekaiApp, ctx sdk.Context) []types.NetworkActor { + addrs := simapp.AddTestAddrsIncremental(app, ctx, 2, sdk.TokensFromConsensusPower(10, sdk.DefaultPowerReduction)) + + // Create role + app.CustomGovKeeper.SetRole(ctx, types.Role{ + Id: 12345, + Sid: "12345", + Description: "12345", + }) + err := app.CustomGovKeeper.WhitelistRolePermission(ctx, 12345, types.PermSetPermissions) + require.NoError(t, err) + + for _, addr := range addrs { + actor := types.NewDefaultActor(addr) + app.CustomGovKeeper.AssignRoleToActor(ctx, actor, 12345) + } + + expectedActors := []types.NetworkActor{ + types.NewDefaultActor(addrs[0]), + types.NewDefaultActor(addrs[1]), + } + + return expectedActors + }, + }, + { + name: "whitelisted address whitelisted by role and personal permission (case 1)", + prepareApp: func(app *simapp.SekaiApp, ctx sdk.Context) []types.NetworkActor { + addrs := simapp.AddTestAddrsIncremental(app, ctx, 2, sdk.TokensFromConsensusPower(10, sdk.DefaultPowerReduction)) + + // Create role + app.CustomGovKeeper.SetRole(ctx, types.Role{ + Id: 12345, + Sid: "12345", + Description: "12345", + }) + err := app.CustomGovKeeper.WhitelistRolePermission(ctx, 12345, types.PermSetPermissions) + require.NoError(t, err) + + // We whitelist all by the role. + for _, addr := range addrs { + actor := types.NewDefaultActor(addr) + app.CustomGovKeeper.AssignRoleToActor(ctx, actor, 12345) + } + + err = app.CustomGovKeeper.AddWhitelistPermission(ctx, types.NewDefaultActor(addrs[0]), types.PermSetPermissions) + require.NoError(t, err) + + expectedActors := []types.NetworkActor{ + types.NewDefaultActor(addrs[0]), + types.NewDefaultActor(addrs[1]), + } + + return expectedActors + }, + }, + { + name: "whitelisted address whitelisted by role and personal permission (case 2)", + prepareApp: func(app *simapp.SekaiApp, ctx sdk.Context) []types.NetworkActor { + addrs := simapp.AddTestAddrsIncremental(app, ctx, 2, sdk.TokensFromConsensusPower(10, sdk.DefaultPowerReduction)) + + // Create role + app.CustomGovKeeper.SetRole(ctx, types.Role{ + Id: 12345, + Sid: "12345", + Description: "12345", + }) + err := app.CustomGovKeeper.WhitelistRolePermission(ctx, 12345, types.PermSetPermissions) + require.NoError(t, err) + + // We assign role to first actor. + actor := types.NewDefaultActor(addrs[0]) + app.CustomGovKeeper.AssignRoleToActor(ctx, actor, 12345) + + err = whitelistPermToMultipleAddrs(app, ctx, addrs, types.PermSetPermissions) + require.NoError(t, err) + + expectedActors := []types.NetworkActor{ + types.NewDefaultActor(addrs[0]), + types.NewDefaultActor(addrs[1]), + } + + return expectedActors + }, + }, + } + + for _, tt := range tests { + tt := tt + t.Run(tt.name, func(t *testing.T) { + app := simapp.Setup(false) + ctx := app.NewContext(false, tmproto.Header{}) + + expectecActors := tt.prepareApp(app, ctx) + savedPerms := app.CustomGovKeeper.GetNetworkActorsByAbsoluteWhitelistPermission(ctx, types.PermSetPermissions) + + require.Equal(t, len(expectecActors), len(savedPerms)) + for i, actor := range expectecActors { + require.Equal(t, actor.Address, savedPerms[i].Address) + } + }) + } +} + +func addRoleToMultipleAddrs(app *simapp.SekaiApp, ctx sdk.Context, addrs []sdk.AccAddress, role uint64) { + for _, addr := range addrs { + app.CustomGovKeeper.AssignRoleToActor(ctx, types.NewDefaultActor(addr), role) + } +} + +func whitelistPermToMultipleAddrs(app *simapp.SekaiApp, ctx sdk.Context, addrs []sdk.AccAddress, permissions types.PermValue) error { + for _, addr := range addrs { + err := app.CustomGovKeeper.AddWhitelistPermission(ctx, types.NewDefaultActor(addr), permissions) + if err != nil { + return err + } + } + + return nil +} + +func requireIteratorCount(t *testing.T, iterator sdk.Iterator, expectedCount int) { + c := 0 + for ; iterator.Valid(); iterator.Next() { + c++ + } + + require.Equal(t, expectedCount, c) +} + +func assertAddrsHaveWhitelistedPerm( + t *testing.T, + app *simapp.SekaiApp, + ctx sdk.Context, + addrs []sdk.AccAddress, + perm types.PermValue, +) { + for _, addr := range addrs { + actor, found := app.CustomGovKeeper.GetNetworkActorByAddress(ctx, addr) + require.True(t, found) + require.True(t, actor.Permissions.IsWhitelisted(perm)) + } +} + +func assertAddrsHaveRole( + t *testing.T, + app *simapp.SekaiApp, + ctx sdk.Context, + addrs []sdk.AccAddress, + role uint64, +) { + for _, addr := range addrs { + actor, found := app.CustomGovKeeper.GetNetworkActorByAddress(ctx, addr) + require.True(t, found) + require.True(t, actor.HasRole(role)) + } +} + +func assertAddrsDontHaveWhitelistedPerm( + t *testing.T, + app *simapp.SekaiApp, + ctx sdk.Context, + addrs []sdk.AccAddress, + perm types.PermValue, +) { + for _, addr := range addrs { + actor, found := app.CustomGovKeeper.GetNetworkActorByAddress(ctx, addr) + require.True(t, found) + require.False(t, actor.Permissions.IsWhitelisted(perm)) + } +} diff --git a/x/gov/keeper/permission_registry.go b/x/gov/keeper/permission_registry.go index 45ba2b6a4..20a489b24 100644 --- a/x/gov/keeper/permission_registry.go +++ b/x/gov/keeper/permission_registry.go @@ -1,246 +1,246 @@ -package keeper - -import ( - "strconv" - - "github.com/KiraCore/sekai/x/gov/types" - "github.com/cosmos/cosmos-sdk/store/prefix" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/gogo/protobuf/proto" -) - -func (k Keeper) GetNextRoleId(ctx sdk.Context) uint64 { - store := ctx.KVStore(k.storeKey) - bz := store.Get(NextRolePrefix) - if bz == nil { - return 1 - } - return sdk.BigEndianToUint64(bz) -} - -func (k Keeper) SetNextRoleId(ctx sdk.Context, nextRoleId uint64) { - store := ctx.KVStore(k.storeKey) - store.Set(NextRolePrefix, sdk.Uint64ToBigEndian(nextRoleId)) -} - -func (k Keeper) SetRole(ctx sdk.Context, role types.Role) { - bz, err := proto.Marshal(&role) - if err != nil { - panic(err) - } - prefixStore := prefix.NewStore(ctx.KVStore(k.storeKey), RoleIdToInfo) - prefixStore.Set(roleToBytes(uint64(role.Id)), bz) - - prefixStore = prefix.NewStore(ctx.KVStore(k.storeKey), RoleSidToIdRegistry) - prefixStore.Set([]byte(role.Sid), sdk.Uint64ToBigEndian(uint64(role.Id))) - - // set empty permissions - perms := types.NewPermissions(nil, nil) - k.savePermissionsForRole(ctx, uint64(role.Id), perms) -} - -func (k Keeper) GetRole(ctx sdk.Context, roleId uint64) (types.Role, error) { - prefixStore := prefix.NewStore(ctx.KVStore(k.storeKey), RoleIdToInfo) - bz := prefixStore.Get(roleToBytes(uint64(roleId))) - if bz == nil { - return types.Role{}, types.ErrRoleDoesNotExist - } - role := types.Role{} - err := proto.Unmarshal(bz, &role) - return role, err -} - -func (k Keeper) GetRoleBySid(ctx sdk.Context, sId string) (types.Role, error) { - prefixStore := prefix.NewStore(ctx.KVStore(k.storeKey), RoleSidToIdRegistry) - bz := prefixStore.Get([]byte(sId)) - if bz == nil { - return types.Role{}, types.ErrRoleDoesNotExist - } - return k.GetRole(ctx, sdk.BigEndianToUint64(bz)) -} - -func (k Keeper) CreateRole(ctx sdk.Context, sid, description string) uint64 { - newRoleId := k.GetNextRoleId(ctx) - k.SetRole(ctx, types.Role{ - Id: uint32(newRoleId), - Sid: sid, - Description: description, - }) - k.SetNextRoleId(ctx, newRoleId+1) - return newRoleId -} - -// savePermissionsForRole adds permissions to role in the permission Registry. -func (k Keeper) savePermissionsForRole(ctx sdk.Context, role uint64, permissions *types.Permissions) { - prefixStore := prefix.NewStore(ctx.KVStore(k.storeKey), RolePermissionRegistry) - prefixStore.Set(roleToBytes(role), k.cdc.MustMarshal(permissions)) -} - -func (k Keeper) GetAllRoles(ctx sdk.Context) []types.Role { - prefixStore := prefix.NewStore(ctx.KVStore(k.storeKey), RoleIdToInfo) - iterator := sdk.KVStorePrefixIterator(prefixStore, nil) - defer iterator.Close() - - roles := []types.Role{} - for ; iterator.Valid(); iterator.Next() { - role := types.Role{} - err := proto.Unmarshal(iterator.Value(), &role) - if err != nil { - panic(err) - } - roles = append(roles, role) - } - return roles -} - -// GetPermissionsForRole returns the permissions assigned to the specific role. -func (k Keeper) GetPermissionsForRole(ctx sdk.Context, role uint64) (types.Permissions, bool) { - prefixStore := prefix.NewStore(ctx.KVStore(k.storeKey), RolePermissionRegistry) - bz := prefixStore.Get(roleToBytes(role)) - if bz == nil { - return types.Permissions{}, false - } - - var perm types.Permissions - k.cdc.MustUnmarshal(bz, &perm) - - return perm, true -} - -func (k Keeper) GetRoleIdFromIdentifierString(ctx sdk.Context, identifier string) (uint64, error) { - if roleId, err := strconv.Atoi(identifier); err == nil { - return uint64(roleId), nil - } - role, err := k.GetRoleBySid(ctx, identifier) // sid - if err != nil { - return 0, err - } - return uint64(role.Id), nil -} - -func (k Keeper) SetWhiltelistPermRoleKey(ctx sdk.Context, role uint64, perm types.PermValue) { - store := ctx.KVStore(k.storeKey) - store.Set(prefixWhitelistRole(perm, role), roleToBytes(role)) -} - -func (k Keeper) WhitelistRolePermission(ctx sdk.Context, role uint64, perm types.PermValue) error { - store := ctx.KVStore(k.storeKey) - - prefixStore := prefix.NewStore(store, RolePermissionRegistry) - bz := prefixStore.Get(roleToBytes(role)) - if bz == nil { - return types.ErrRoleDoesNotExist - } - - var perms types.Permissions - k.cdc.MustUnmarshal(bz, &perms) - - err := perms.AddToWhitelist(perm) - if err != nil { - return err - } - - k.savePermissionsForRole(ctx, role, &perms) - k.SetWhiltelistPermRoleKey(ctx, role, perm) - - return nil -} - -func (k Keeper) BlacklistRolePermission(ctx sdk.Context, role uint64, perm types.PermValue) error { - store := ctx.KVStore(k.storeKey) - - prefixStore := prefix.NewStore(store, RolePermissionRegistry) - bz := prefixStore.Get(roleToBytes(role)) - if bz == nil { - return types.ErrRoleDoesNotExist - } - - var perms types.Permissions - k.cdc.MustUnmarshal(bz, &perms) - - err := perms.AddToBlacklist(perm) - if err != nil { - return err - } - - k.savePermissionsForRole(ctx, role, &perms) - - return nil -} - -func (k Keeper) RemoveWhitelistRolePermission(ctx sdk.Context, role uint64, perm types.PermValue) error { - store := ctx.KVStore(k.storeKey) - - prefixStore := prefix.NewStore(store, RolePermissionRegistry) - bz := prefixStore.Get(roleToBytes(role)) - if bz == nil { - return types.ErrRoleDoesNotExist - } - - var perms types.Permissions - k.cdc.MustUnmarshal(bz, &perms) - - err := perms.RemoveFromWhitelist(perm) - if err != nil { - return err - } - - k.savePermissionsForRole(ctx, role, &perms) - store.Delete(prefixWhitelistRole(perm, role)) - - return nil -} - -func (k Keeper) RemoveBlacklistRolePermission(ctx sdk.Context, role uint64, perm types.PermValue) error { - store := ctx.KVStore(k.storeKey) - prefixStore := prefix.NewStore(store, RolePermissionRegistry) - - bz := prefixStore.Get(roleToBytes(role)) - if bz == nil { - return types.ErrRoleDoesNotExist - } - - var perms types.Permissions - k.cdc.MustUnmarshal(bz, &perms) - - err := perms.RemoveFromBlacklist(perm) - if err != nil { - return err - } - - k.savePermissionsForRole(ctx, role, &perms) - - return nil -} - -func (k Keeper) IterateRoles(ctx sdk.Context) sdk.Iterator { - return sdk.KVStorePrefixIterator(ctx.KVStore(k.storeKey), RolePermissionRegistry) -} - -func (k Keeper) GetPermissionsFromIterator(iterator sdk.Iterator) types.Permissions { - bz := iterator.Value() - if bz == nil { - return types.Permissions{} - } - - var perms types.Permissions - k.cdc.MustUnmarshal(bz, &perms) - return perms -} - -func (k Keeper) GetRolesByWhitelistedPerm(ctx sdk.Context, perm types.PermValue) sdk.Iterator { - store := ctx.KVStore(k.storeKey) - return sdk.KVStorePrefixIterator(store, prefixWhitelist(perm)) -} - -func (k Keeper) CheckIfAllowedPermission(ctx sdk.Context, addr sdk.AccAddress, permValue types.PermValue) bool { - return CheckIfAllowedPermission(ctx, k, addr, permValue) -} - -func prefixWhitelist(perm types.PermValue) []byte { - return append(WhitelistRolePrefix, permToBytes(perm)...) -} - -func prefixWhitelistRole(perm types.PermValue, role uint64) []byte { - return append(prefixWhitelist(perm), roleToBytes(role)...) -} +package keeper + +import ( + "strconv" + + "github.com/KiraCore/sekai/x/gov/types" + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/gogo/protobuf/proto" +) + +func (k Keeper) GetNextRoleId(ctx sdk.Context) uint64 { + store := ctx.KVStore(k.storeKey) + bz := store.Get(NextRolePrefix) + if bz == nil { + return 1 + } + return sdk.BigEndianToUint64(bz) +} + +func (k Keeper) SetNextRoleId(ctx sdk.Context, nextRoleId uint64) { + store := ctx.KVStore(k.storeKey) + store.Set(NextRolePrefix, sdk.Uint64ToBigEndian(nextRoleId)) +} + +func (k Keeper) SetRole(ctx sdk.Context, role types.Role) { + bz, err := proto.Marshal(&role) + if err != nil { + panic(err) + } + prefixStore := prefix.NewStore(ctx.KVStore(k.storeKey), RoleIdToInfo) + prefixStore.Set(roleToBytes(uint64(role.Id)), bz) + + prefixStore = prefix.NewStore(ctx.KVStore(k.storeKey), RoleSidToIdRegistry) + prefixStore.Set([]byte(role.Sid), sdk.Uint64ToBigEndian(uint64(role.Id))) + + // set empty permissions + perms := types.NewPermissions(nil, nil) + k.savePermissionsForRole(ctx, uint64(role.Id), perms) +} + +func (k Keeper) GetRole(ctx sdk.Context, roleId uint64) (types.Role, error) { + prefixStore := prefix.NewStore(ctx.KVStore(k.storeKey), RoleIdToInfo) + bz := prefixStore.Get(roleToBytes(uint64(roleId))) + if bz == nil { + return types.Role{}, types.ErrRoleDoesNotExist + } + role := types.Role{} + err := proto.Unmarshal(bz, &role) + return role, err +} + +func (k Keeper) GetRoleBySid(ctx sdk.Context, sId string) (types.Role, error) { + prefixStore := prefix.NewStore(ctx.KVStore(k.storeKey), RoleSidToIdRegistry) + bz := prefixStore.Get([]byte(sId)) + if bz == nil { + return types.Role{}, types.ErrRoleDoesNotExist + } + return k.GetRole(ctx, sdk.BigEndianToUint64(bz)) +} + +func (k Keeper) CreateRole(ctx sdk.Context, sid, description string) uint64 { + newRoleId := k.GetNextRoleId(ctx) + k.SetRole(ctx, types.Role{ + Id: uint32(newRoleId), + Sid: sid, + Description: description, + }) + k.SetNextRoleId(ctx, newRoleId+1) + return newRoleId +} + +// savePermissionsForRole adds permissions to role in the permission Registry. +func (k Keeper) savePermissionsForRole(ctx sdk.Context, role uint64, permissions *types.Permissions) { + prefixStore := prefix.NewStore(ctx.KVStore(k.storeKey), RolePermissionRegistry) + prefixStore.Set(roleToBytes(role), k.cdc.MustMarshal(permissions)) +} + +func (k Keeper) GetAllRoles(ctx sdk.Context) []types.Role { + prefixStore := prefix.NewStore(ctx.KVStore(k.storeKey), RoleIdToInfo) + iterator := sdk.KVStorePrefixIterator(prefixStore, nil) + defer iterator.Close() + + roles := []types.Role{} + for ; iterator.Valid(); iterator.Next() { + role := types.Role{} + err := proto.Unmarshal(iterator.Value(), &role) + if err != nil { + panic(err) + } + roles = append(roles, role) + } + return roles +} + +// GetPermissionsForRole returns the permissions assigned to the specific role. +func (k Keeper) GetPermissionsForRole(ctx sdk.Context, role uint64) (types.Permissions, bool) { + prefixStore := prefix.NewStore(ctx.KVStore(k.storeKey), RolePermissionRegistry) + bz := prefixStore.Get(roleToBytes(role)) + if bz == nil { + return types.Permissions{}, false + } + + var perm types.Permissions + k.cdc.MustUnmarshal(bz, &perm) + + return perm, true +} + +func (k Keeper) GetRoleIdFromIdentifierString(ctx sdk.Context, identifier string) (uint64, error) { + if roleId, err := strconv.Atoi(identifier); err == nil { + return uint64(roleId), nil + } + role, err := k.GetRoleBySid(ctx, identifier) // sid + if err != nil { + return 0, err + } + return uint64(role.Id), nil +} + +func (k Keeper) SetWhiltelistPermRoleKey(ctx sdk.Context, role uint64, perm types.PermValue) { + store := ctx.KVStore(k.storeKey) + store.Set(prefixWhitelistRole(perm, role), roleToBytes(role)) +} + +func (k Keeper) WhitelistRolePermission(ctx sdk.Context, role uint64, perm types.PermValue) error { + store := ctx.KVStore(k.storeKey) + + prefixStore := prefix.NewStore(store, RolePermissionRegistry) + bz := prefixStore.Get(roleToBytes(role)) + if bz == nil { + return types.ErrRoleDoesNotExist + } + + var perms types.Permissions + k.cdc.MustUnmarshal(bz, &perms) + + err := perms.AddToWhitelist(perm) + if err != nil { + return err + } + + k.savePermissionsForRole(ctx, role, &perms) + k.SetWhiltelistPermRoleKey(ctx, role, perm) + + return nil +} + +func (k Keeper) BlacklistRolePermission(ctx sdk.Context, role uint64, perm types.PermValue) error { + store := ctx.KVStore(k.storeKey) + + prefixStore := prefix.NewStore(store, RolePermissionRegistry) + bz := prefixStore.Get(roleToBytes(role)) + if bz == nil { + return types.ErrRoleDoesNotExist + } + + var perms types.Permissions + k.cdc.MustUnmarshal(bz, &perms) + + err := perms.AddToBlacklist(perm) + if err != nil { + return err + } + + k.savePermissionsForRole(ctx, role, &perms) + + return nil +} + +func (k Keeper) RemoveWhitelistRolePermission(ctx sdk.Context, role uint64, perm types.PermValue) error { + store := ctx.KVStore(k.storeKey) + + prefixStore := prefix.NewStore(store, RolePermissionRegistry) + bz := prefixStore.Get(roleToBytes(role)) + if bz == nil { + return types.ErrRoleDoesNotExist + } + + var perms types.Permissions + k.cdc.MustUnmarshal(bz, &perms) + + err := perms.RemoveFromWhitelist(perm) + if err != nil { + return err + } + + k.savePermissionsForRole(ctx, role, &perms) + store.Delete(prefixWhitelistRole(perm, role)) + + return nil +} + +func (k Keeper) RemoveBlacklistRolePermission(ctx sdk.Context, role uint64, perm types.PermValue) error { + store := ctx.KVStore(k.storeKey) + prefixStore := prefix.NewStore(store, RolePermissionRegistry) + + bz := prefixStore.Get(roleToBytes(role)) + if bz == nil { + return types.ErrRoleDoesNotExist + } + + var perms types.Permissions + k.cdc.MustUnmarshal(bz, &perms) + + err := perms.RemoveFromBlacklist(perm) + if err != nil { + return err + } + + k.savePermissionsForRole(ctx, role, &perms) + + return nil +} + +func (k Keeper) IterateRoles(ctx sdk.Context) sdk.Iterator { + return sdk.KVStorePrefixIterator(ctx.KVStore(k.storeKey), RolePermissionRegistry) +} + +func (k Keeper) GetPermissionsFromIterator(iterator sdk.Iterator) types.Permissions { + bz := iterator.Value() + if bz == nil { + return types.Permissions{} + } + + var perms types.Permissions + k.cdc.MustUnmarshal(bz, &perms) + return perms +} + +func (k Keeper) GetRolesByWhitelistedPerm(ctx sdk.Context, perm types.PermValue) sdk.Iterator { + store := ctx.KVStore(k.storeKey) + return sdk.KVStorePrefixIterator(store, prefixWhitelist(perm)) +} + +func (k Keeper) CheckIfAllowedPermission(ctx sdk.Context, addr sdk.AccAddress, permValue types.PermValue) bool { + return CheckIfAllowedPermission(ctx, k, addr, permValue) +} + +func prefixWhitelist(perm types.PermValue) []byte { + return append(WhitelistRolePrefix, permToBytes(perm)...) +} + +func prefixWhitelistRole(perm types.PermValue, role uint64) []byte { + return append(prefixWhitelist(perm), roleToBytes(role)...) +} diff --git a/x/gov/keeper/permission_registry_test.go b/x/gov/keeper/permission_registry_test.go index 38964d3ee..39fdde08a 100644 --- a/x/gov/keeper/permission_registry_test.go +++ b/x/gov/keeper/permission_registry_test.go @@ -1,139 +1,139 @@ -package keeper_test - -import ( - "testing" - - simapp "github.com/KiraCore/sekai/app" - "github.com/KiraCore/sekai/x/gov/types" - "github.com/stretchr/testify/require" - tmproto "github.com/tendermint/tendermint/proto/tendermint/types" -) - -func TestKeeper_CreateRoleAndWhitelistPerm(t *testing.T) { - app := simapp.Setup(false) - ctx := app.NewContext(false, tmproto.Header{}) - - app.CustomGovKeeper.SetRole(ctx, types.Role{ - Id: uint32(types.RoleSudo), - Sid: "RoleSudo", - Description: "RoleSudo", - }) - - err := app.CustomGovKeeper.WhitelistRolePermission(ctx, types.RoleSudo, types.PermClaimValidator) - require.NoError(t, err) - - savedPerms, found := app.CustomGovKeeper.GetPermissionsForRole(ctx, types.RoleSudo) - require.True(t, found) - require.True(t, savedPerms.IsWhitelisted(types.PermClaimValidator)) -} - -func TestKeeper_HasGenesisDefaultRoles(t *testing.T) { - app := simapp.Setup(false) - ctx := app.NewContext(false, tmproto.Header{}) - - roleSudo, found := app.CustomGovKeeper.GetPermissionsForRole(ctx, types.RoleSudo) - require.True(t, found) - require.True(t, roleSudo.IsWhitelisted(types.PermSetPermissions)) - - roleValidator, found := app.CustomGovKeeper.GetPermissionsForRole(ctx, types.RoleValidator) - require.True(t, found) - require.True(t, roleValidator.IsWhitelisted(types.PermClaimValidator)) - - iterator := app.CustomGovKeeper.GetRolesByWhitelistedPerm(ctx, types.PermClaimValidator) - requireIteratorCount(t, iterator, 2) -} - -func TestKeeper_WhitelistRolePermission(t *testing.T) { - app := simapp.Setup(false) - ctx := app.NewContext(false, tmproto.Header{}) - - perms, found := app.CustomGovKeeper.GetPermissionsForRole(ctx, types.RoleSudo) - require.True(t, found) - require.False(t, perms.IsWhitelisted(types.PermChangeTxFee)) - - err := app.CustomGovKeeper.WhitelistRolePermission(ctx, types.RoleSudo, types.PermChangeTxFee) - require.NoError(t, err) - - perms, found = app.CustomGovKeeper.GetPermissionsForRole(ctx, types.RoleSudo) - require.True(t, found) - require.True(t, perms.IsWhitelisted(types.PermChangeTxFee)) - - iterator := app.CustomGovKeeper.GetRolesByWhitelistedPerm(ctx, types.PermChangeTxFee) - requireIteratorCount(t, iterator, 1) -} - -func TestKeeper_RemoveWhitelistRolePermission(t *testing.T) { - app := simapp.Setup(false) - ctx := app.NewContext(false, tmproto.Header{}) - - perms, found := app.CustomGovKeeper.GetPermissionsForRole(ctx, types.RoleSudo) - require.True(t, found) - require.False(t, perms.IsWhitelisted(types.PermChangeTxFee)) - - err := app.CustomGovKeeper.WhitelistRolePermission(ctx, types.RoleSudo, types.PermChangeTxFee) - require.NoError(t, err) - - perms, found = app.CustomGovKeeper.GetPermissionsForRole(ctx, types.RoleSudo) - require.True(t, found) - require.True(t, perms.IsWhitelisted(types.PermChangeTxFee)) - - iterator := app.CustomGovKeeper.GetRolesByWhitelistedPerm(ctx, types.PermChangeTxFee) - requireIteratorCount(t, iterator, 1) - - err = app.CustomGovKeeper.RemoveWhitelistRolePermission(ctx, types.RoleSudo, types.PermChangeTxFee) - require.NoError(t, err) - - perms, found = app.CustomGovKeeper.GetPermissionsForRole(ctx, types.RoleSudo) - require.True(t, found) - require.False(t, perms.IsWhitelisted(types.PermChangeTxFee)) - - iterator = app.CustomGovKeeper.GetRolesByWhitelistedPerm(ctx, types.PermChangeTxFee) - requireIteratorCount(t, iterator, 0) -} - -func TestKeeper_BlacklistRolePermission(t *testing.T) { - app := simapp.Setup(false) - ctx := app.NewContext(false, tmproto.Header{}) - - perms, found := app.CustomGovKeeper.GetPermissionsForRole(ctx, types.RoleSudo) - require.True(t, found) - require.False(t, perms.IsBlacklisted(types.PermChangeTxFee)) - - err := app.CustomGovKeeper.BlacklistRolePermission(ctx, types.RoleSudo, types.PermChangeTxFee) - require.NoError(t, err) - - perms, found = app.CustomGovKeeper.GetPermissionsForRole(ctx, types.RoleSudo) - require.True(t, found) - require.True(t, perms.IsBlacklisted(types.PermChangeTxFee)) -} - -func TestKeeper_RemoveBlacklistRolePermission(t *testing.T) { - app := simapp.Setup(false) - ctx := app.NewContext(false, tmproto.Header{}) - - perms, found := app.CustomGovKeeper.GetPermissionsForRole(ctx, types.RoleSudo) - require.True(t, found) - require.False(t, perms.IsBlacklisted(types.PermChangeTxFee)) - - err := app.CustomGovKeeper.BlacklistRolePermission(ctx, types.RoleSudo, types.PermChangeTxFee) - require.NoError(t, err) - - perms, found = app.CustomGovKeeper.GetPermissionsForRole(ctx, types.RoleSudo) - require.True(t, found) - require.True(t, perms.IsBlacklisted(types.PermChangeTxFee)) - - err = app.CustomGovKeeper.RemoveBlacklistRolePermission(ctx, types.RoleSudo, types.PermChangeTxFee) - require.NoError(t, err) - - perms, found = app.CustomGovKeeper.GetPermissionsForRole(ctx, types.RoleSudo) - require.True(t, found) - require.False(t, perms.IsBlacklisted(types.PermChangeTxFee)) -} - -func TestKeeper_GetPermissionsForRole_ReturnsNilWhenDoesNotExist(t *testing.T) { - app := simapp.Setup(false) - ctx := app.NewContext(false, tmproto.Header{}) - - _, found := app.CustomGovKeeper.GetPermissionsForRole(ctx, 12345) - require.False(t, found) -} +package keeper_test + +import ( + "testing" + + simapp "github.com/KiraCore/sekai/app" + "github.com/KiraCore/sekai/x/gov/types" + "github.com/stretchr/testify/require" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" +) + +func TestKeeper_CreateRoleAndWhitelistPerm(t *testing.T) { + app := simapp.Setup(false) + ctx := app.NewContext(false, tmproto.Header{}) + + app.CustomGovKeeper.SetRole(ctx, types.Role{ + Id: uint32(types.RoleSudo), + Sid: "RoleSudo", + Description: "RoleSudo", + }) + + err := app.CustomGovKeeper.WhitelistRolePermission(ctx, types.RoleSudo, types.PermClaimValidator) + require.NoError(t, err) + + savedPerms, found := app.CustomGovKeeper.GetPermissionsForRole(ctx, types.RoleSudo) + require.True(t, found) + require.True(t, savedPerms.IsWhitelisted(types.PermClaimValidator)) +} + +func TestKeeper_HasGenesisDefaultRoles(t *testing.T) { + app := simapp.Setup(false) + ctx := app.NewContext(false, tmproto.Header{}) + + roleSudo, found := app.CustomGovKeeper.GetPermissionsForRole(ctx, types.RoleSudo) + require.True(t, found) + require.True(t, roleSudo.IsWhitelisted(types.PermSetPermissions)) + + roleValidator, found := app.CustomGovKeeper.GetPermissionsForRole(ctx, types.RoleValidator) + require.True(t, found) + require.True(t, roleValidator.IsWhitelisted(types.PermClaimValidator)) + + iterator := app.CustomGovKeeper.GetRolesByWhitelistedPerm(ctx, types.PermClaimValidator) + requireIteratorCount(t, iterator, 2) +} + +func TestKeeper_WhitelistRolePermission(t *testing.T) { + app := simapp.Setup(false) + ctx := app.NewContext(false, tmproto.Header{}) + + perms, found := app.CustomGovKeeper.GetPermissionsForRole(ctx, types.RoleSudo) + require.True(t, found) + require.False(t, perms.IsWhitelisted(types.PermChangeTxFee)) + + err := app.CustomGovKeeper.WhitelistRolePermission(ctx, types.RoleSudo, types.PermChangeTxFee) + require.NoError(t, err) + + perms, found = app.CustomGovKeeper.GetPermissionsForRole(ctx, types.RoleSudo) + require.True(t, found) + require.True(t, perms.IsWhitelisted(types.PermChangeTxFee)) + + iterator := app.CustomGovKeeper.GetRolesByWhitelistedPerm(ctx, types.PermChangeTxFee) + requireIteratorCount(t, iterator, 1) +} + +func TestKeeper_RemoveWhitelistRolePermission(t *testing.T) { + app := simapp.Setup(false) + ctx := app.NewContext(false, tmproto.Header{}) + + perms, found := app.CustomGovKeeper.GetPermissionsForRole(ctx, types.RoleSudo) + require.True(t, found) + require.False(t, perms.IsWhitelisted(types.PermChangeTxFee)) + + err := app.CustomGovKeeper.WhitelistRolePermission(ctx, types.RoleSudo, types.PermChangeTxFee) + require.NoError(t, err) + + perms, found = app.CustomGovKeeper.GetPermissionsForRole(ctx, types.RoleSudo) + require.True(t, found) + require.True(t, perms.IsWhitelisted(types.PermChangeTxFee)) + + iterator := app.CustomGovKeeper.GetRolesByWhitelistedPerm(ctx, types.PermChangeTxFee) + requireIteratorCount(t, iterator, 1) + + err = app.CustomGovKeeper.RemoveWhitelistRolePermission(ctx, types.RoleSudo, types.PermChangeTxFee) + require.NoError(t, err) + + perms, found = app.CustomGovKeeper.GetPermissionsForRole(ctx, types.RoleSudo) + require.True(t, found) + require.False(t, perms.IsWhitelisted(types.PermChangeTxFee)) + + iterator = app.CustomGovKeeper.GetRolesByWhitelistedPerm(ctx, types.PermChangeTxFee) + requireIteratorCount(t, iterator, 0) +} + +func TestKeeper_BlacklistRolePermission(t *testing.T) { + app := simapp.Setup(false) + ctx := app.NewContext(false, tmproto.Header{}) + + perms, found := app.CustomGovKeeper.GetPermissionsForRole(ctx, types.RoleSudo) + require.True(t, found) + require.False(t, perms.IsBlacklisted(types.PermChangeTxFee)) + + err := app.CustomGovKeeper.BlacklistRolePermission(ctx, types.RoleSudo, types.PermChangeTxFee) + require.NoError(t, err) + + perms, found = app.CustomGovKeeper.GetPermissionsForRole(ctx, types.RoleSudo) + require.True(t, found) + require.True(t, perms.IsBlacklisted(types.PermChangeTxFee)) +} + +func TestKeeper_RemoveBlacklistRolePermission(t *testing.T) { + app := simapp.Setup(false) + ctx := app.NewContext(false, tmproto.Header{}) + + perms, found := app.CustomGovKeeper.GetPermissionsForRole(ctx, types.RoleSudo) + require.True(t, found) + require.False(t, perms.IsBlacklisted(types.PermChangeTxFee)) + + err := app.CustomGovKeeper.BlacklistRolePermission(ctx, types.RoleSudo, types.PermChangeTxFee) + require.NoError(t, err) + + perms, found = app.CustomGovKeeper.GetPermissionsForRole(ctx, types.RoleSudo) + require.True(t, found) + require.True(t, perms.IsBlacklisted(types.PermChangeTxFee)) + + err = app.CustomGovKeeper.RemoveBlacklistRolePermission(ctx, types.RoleSudo, types.PermChangeTxFee) + require.NoError(t, err) + + perms, found = app.CustomGovKeeper.GetPermissionsForRole(ctx, types.RoleSudo) + require.True(t, found) + require.False(t, perms.IsBlacklisted(types.PermChangeTxFee)) +} + +func TestKeeper_GetPermissionsForRole_ReturnsNilWhenDoesNotExist(t *testing.T) { + app := simapp.Setup(false) + ctx := app.NewContext(false, tmproto.Header{}) + + _, found := app.CustomGovKeeper.GetPermissionsForRole(ctx, 12345) + require.False(t, found) +} diff --git a/x/gov/keeper/poll.go b/x/gov/keeper/poll.go new file mode 100644 index 000000000..c4643a70d --- /dev/null +++ b/x/gov/keeper/poll.go @@ -0,0 +1,198 @@ +package keeper + +import ( + "encoding/binary" + "fmt" + "github.com/KiraCore/sekai/x/gov/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "time" +) + +func (k Keeper) GetNextPollIDAndIncrement(ctx sdk.Context) uint64 { + pollID := k.GetNextPollID(ctx) + k.SetNextPollID(ctx, pollID+1) + return pollID +} + +func (k Keeper) GetNextPollID(ctx sdk.Context) uint64 { + store := ctx.KVStore(k.storeKey) + + bz := store.Get(NextPollIDPrefix) + if bz == nil { + return 1 + } + + pollID := sdk.BigEndianToUint64(bz) + return pollID +} + +func (k Keeper) SetNextPollID(ctx sdk.Context, pollID uint64) { + store := ctx.KVStore(k.storeKey) + store.Set(NextPollIDPrefix, sdk.Uint64ToBigEndian(pollID)) +} + +func (k Keeper) PollCreate(ctx sdk.Context, msg *types.MsgPollCreate) (uint64, error) { + var roles []uint64 + pollID := k.GetNextPollIDAndIncrement(ctx) + options := new(types.PollOptions) + + options.Type = msg.ValueType + options.Count = msg.ValueCount + options.Choices = msg.PossibleChoices + + duration, err := time.ParseDuration(msg.Duration) + if err != nil { + return pollID, fmt.Errorf("invalid duration: %w", err) + } + + for _, v := range msg.PollValues { + options.Values = append(options.Values, v) + } + + for _, sid := range msg.Roles { + role, _ := k.GetRoleBySid(ctx, sid) + roles = append(roles, uint64(role.Id)) + } + + poll, err := types.NewPoll( + pollID, + msg.Creator, + msg.Title, + msg.Description, + msg.Reference, + msg.Checksum, + roles, + options, + time.Now().Add(duration), + ) + + if err != nil { + return pollID, err + } + + k.SavePoll(ctx, poll) + k.AddAddressPoll(ctx, poll) + k.AddToActivePolls(ctx, poll) + + return pollID, nil +} + +func (k Keeper) SavePoll(ctx sdk.Context, poll types.Poll) { + store := ctx.KVStore(k.storeKey) + key := append(PollPrefix, sdk.Uint64ToBigEndian(poll.PollId)...) + store.Set(key, k.cdc.MustMarshal(&poll)) +} + +func (k Keeper) AddAddressPoll(ctx sdk.Context, poll types.Poll) { + store := ctx.KVStore(k.storeKey) + addressKey := append(PollPrefix, poll.Creator.Bytes()...) + key := append(addressKey, sdk.Uint64ToBigEndian(poll.PollId)...) + store.Set(key, sdk.Uint64ToBigEndian(poll.PollId)) +} + +func (k Keeper) AddToActivePolls(ctx sdk.Context, poll types.Poll) { + store := ctx.KVStore(k.storeKey) + key := append(PollsByTimeKey(poll.VotingEndTime), sdk.Uint64ToBigEndian(poll.PollId)...) + store.Set(key, sdk.Uint64ToBigEndian(poll.PollId)) +} + +func (k Keeper) RemoveActivePoll(ctx sdk.Context, poll types.Poll) { + store := ctx.KVStore(k.storeKey) + key := append(PollsByTimeKey(poll.VotingEndTime), sdk.Uint64ToBigEndian(poll.PollId)...) + store.Delete(key) +} + +func (k Keeper) PollVote(ctx sdk.Context, msg *types.MsgPollVote) error { + vote := types.PollVote{ + Voter: msg.Voter, + PollId: msg.PollId, + Option: msg.Option, + CustomValue: msg.Value, + } + + store := ctx.KVStore(k.storeKey) + bz := k.cdc.MustMarshal(&vote) + store.Set(PollVoteKey(vote.PollId, vote.Voter), bz) + + return nil +} + +func (k Keeper) GetPoll(ctx sdk.Context, pollID uint64) (types.Poll, error) { + store := ctx.KVStore(k.storeKey) + bz := store.Get(append(PollPrefix, sdk.Uint64ToBigEndian(pollID)...)) + + if bz == nil { + return types.Poll{}, types.ErrPollsNotFount + } + + var poll types.Poll + k.cdc.MustUnmarshal(bz, &poll) + + return poll, nil +} + +func (k Keeper) GetPollsIdsByAddress(ctx sdk.Context, address sdk.AccAddress) []uint64 { + var ids []uint64 + store := ctx.KVStore(k.storeKey) + addressKey := append(PollPrefix, address.Bytes()...) + iterator := sdk.KVStorePrefixIterator(store, addressKey) + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + id := binary.BigEndian.Uint64(iterator.Value()) + ids = append(ids, id) + } + + return ids +} + +func (k Keeper) GetPollsByAddress(ctx sdk.Context, address sdk.AccAddress) ([]types.Poll, error) { + ids := k.GetPollsIdsByAddress(ctx, address) + var polls []types.Poll + + for _, v := range ids { + poll, err := k.GetPoll(ctx, v) + if err != nil { + return nil, err + } + polls = append(polls, poll) + } + + return polls, nil +} + +func (k Keeper) GetPollVotes(ctx sdk.Context, pollID uint64) types.PollVotes { + var votes types.PollVotes + + iterator := k.GetPollVotesIterator(ctx, pollID) + defer iterator.Close() + for ; iterator.Valid(); iterator.Next() { + var vote types.PollVote + k.cdc.MustUnmarshal(iterator.Value(), &vote) + votes = append(votes, vote) + } + + return votes +} + +func (k Keeper) GetPollVotesIterator(ctx sdk.Context, pollID uint64) sdk.Iterator { + store := ctx.KVStore(k.storeKey) + return sdk.KVStorePrefixIterator(store, PollVotesKey(pollID)) +} + +func (k Keeper) GetPollsWithFinishedVotingEndTimeIterator(ctx sdk.Context, endTime time.Time) sdk.Iterator { + store := ctx.KVStore(k.storeKey) + return store.Iterator(ActivePollPrefix, sdk.PrefixEndBytes(PollsByTimeKey(endTime))) +} + +func PollsByTimeKey(endTime time.Time) []byte { + return append(ActivePollPrefix, sdk.FormatTimeBytes(endTime)...) +} + +func PollVotesKey(pollId uint64) []byte { + return append(PollVotesPrefix, sdk.Uint64ToBigEndian(pollId)...) +} + +func PollVoteKey(pollId uint64, address sdk.AccAddress) []byte { + return append(PollVotesKey(pollId), address.Bytes()...) +} diff --git a/x/gov/keeper/poor_network_msgs.go b/x/gov/keeper/poor_network_msgs.go index 80b123097..78b668292 100644 --- a/x/gov/keeper/poor_network_msgs.go +++ b/x/gov/keeper/poor_network_msgs.go @@ -1,28 +1,28 @@ -package keeper - -import ( - "github.com/KiraCore/sekai/x/gov/types" - sdk "github.com/cosmos/cosmos-sdk/types" -) - -// SavePoorNetworkMessages store poor network messages by gov or by genesis -func (k Keeper) SavePoorNetworkMessages(ctx sdk.Context, allows *types.AllowedMessages) { - store := ctx.KVStore(k.storeKey) - bz := k.cdc.MustMarshal(allows) - store.Set(PoorNetworkMessagesPrefix, bz) -} - -// GetPoorNetworkMessages returns poor network messages stored inside keeper -func (k Keeper) GetPoorNetworkMessages(ctx sdk.Context) *types.AllowedMessages { - var am types.AllowedMessages - store := ctx.KVStore(k.storeKey) - - bz := store.Get(PoorNetworkMessagesPrefix) - if bz == nil { - return &am - } - - k.cdc.MustUnmarshal(bz, &am) - - return &am -} +package keeper + +import ( + "github.com/KiraCore/sekai/x/gov/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// SavePoorNetworkMessages store poor network messages by gov or by genesis +func (k Keeper) SavePoorNetworkMessages(ctx sdk.Context, allows *types.AllowedMessages) { + store := ctx.KVStore(k.storeKey) + bz := k.cdc.MustMarshal(allows) + store.Set(PoorNetworkMessagesPrefix, bz) +} + +// GetPoorNetworkMessages returns poor network messages stored inside keeper +func (k Keeper) GetPoorNetworkMessages(ctx sdk.Context) *types.AllowedMessages { + var am types.AllowedMessages + store := ctx.KVStore(k.storeKey) + + bz := store.Get(PoorNetworkMessagesPrefix) + if bz == nil { + return &am + } + + k.cdc.MustUnmarshal(bz, &am) + + return &am +} diff --git a/x/gov/keeper/proposal.go b/x/gov/keeper/proposal.go index 7a4b6941e..33bb6ae5c 100644 --- a/x/gov/keeper/proposal.go +++ b/x/gov/keeper/proposal.go @@ -1,242 +1,247 @@ -package keeper - -import ( - "time" - - sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/KiraCore/sekai/x/gov/types" -) - -func (k Keeper) GetNextProposalIDAndIncrement(ctx sdk.Context) uint64 { - proposalID := k.GetNextProposalID(ctx) - k.SetNextProposalID(ctx, proposalID+1) - return proposalID -} - -func (k Keeper) GetNextProposalID(ctx sdk.Context) uint64 { - store := ctx.KVStore(k.storeKey) - - bz := store.Get(NextProposalIDPrefix) - if bz == nil { - return 1 - } - - proposalID := BytesToProposalID(bz) - return proposalID -} - -func (k Keeper) SetNextProposalID(ctx sdk.Context, proposalID uint64) { - store := ctx.KVStore(k.storeKey) - store.Set(NextProposalIDPrefix, ProposalIDToBytes(proposalID)) -} - -func (k Keeper) CreateAndSaveProposalWithContent(ctx sdk.Context, title, description string, content types.Content) (uint64, error) { - blockTime := ctx.BlockTime() - proposalID := k.GetNextProposalIDAndIncrement(ctx) - - properties := k.GetNetworkProperties(ctx) - - // dynamic proposal end time based on proposal type - proposalEndTime := k.GetProposalDuration(ctx, content.ProposalType()) - if proposalEndTime < properties.MinimumProposalEndTime { - proposalEndTime = properties.MinimumProposalEndTime - } - - proposalEnactmentTime := properties.ProposalEnactmentTime - - if content.VotePermission() == types.PermZero { - router := k.GetProposalRouter() - proposalEndTime = router.VotePeriodDynamicProposal(ctx, content) - proposalEnactmentTime = router.EnactmentPeriodDynamicProposal(ctx, content) - } - - proposal, err := types.NewProposal( - proposalID, - title, - description, - content, - blockTime, - blockTime.Add(time.Second*time.Duration(proposalEndTime)), - blockTime.Add(time.Second*time.Duration(proposalEndTime)+ - time.Second*time.Duration(proposalEnactmentTime), - ), - ctx.BlockHeight()+int64(properties.MinProposalEndBlocks), - ctx.BlockHeight()+int64(properties.MinProposalEndBlocks+properties.MinProposalEnactmentBlocks), - ) - - if err != nil { - return proposalID, err - } - - k.SaveProposal(ctx, proposal) - k.AddToActiveProposals(ctx, proposal) - - return proposalID, nil -} - -func (k Keeper) SaveProposal(ctx sdk.Context, proposal types.Proposal) { - store := ctx.KVStore(k.storeKey) - - bz := k.cdc.MustMarshal(&proposal) - store.Set(GetProposalKey(proposal.ProposalId), bz) -} - -func (k Keeper) GetProposal(ctx sdk.Context, proposalID uint64) (types.Proposal, bool) { - store := ctx.KVStore(k.storeKey) - - bz := store.Get(GetProposalKey(proposalID)) - if bz == nil { - return types.Proposal{}, false - } - - var prop types.Proposal - k.cdc.MustUnmarshal(bz, &prop) - - return prop, true -} - -func (k Keeper) GetProposals(ctx sdk.Context) ([]types.Proposal, error) { - proposals := []types.Proposal{} - iterator := sdk.KVStorePrefixIterator(ctx.KVStore(k.storeKey), ProposalsPrefix) - defer iterator.Close() - - for ; iterator.Valid(); iterator.Next() { - var proposal types.Proposal - bz := iterator.Value() - k.cdc.MustUnmarshal(bz, &proposal) - proposals = append(proposals, proposal) - } - - return proposals, nil -} - -func (k Keeper) SaveVote(ctx sdk.Context, vote types.Vote) { - store := ctx.KVStore(k.storeKey) - bz := k.cdc.MustMarshal(&vote) - store.Set(VoteKey(vote.ProposalId, vote.Voter), bz) -} - -func (k Keeper) GetVote(ctx sdk.Context, proposalID uint64, address sdk.AccAddress) (types.Vote, bool) { - store := ctx.KVStore(k.storeKey) - - bz := store.Get(VoteKey(proposalID, address)) - if bz == nil { - return types.Vote{}, false - } - - var vote types.Vote - k.cdc.MustUnmarshal(bz, &vote) - - return vote, true -} - -func (k Keeper) GetVotes(ctx sdk.Context) []types.Vote { - votes := []types.Vote{} - iterator := sdk.KVStorePrefixIterator(ctx.KVStore(k.storeKey), VotesPrefix) - defer iterator.Close() - - for ; iterator.Valid(); iterator.Next() { - var vote types.Vote - bz := iterator.Value() - k.cdc.MustUnmarshal(bz, &vote) - votes = append(votes, vote) - } - - return votes -} - -func (k Keeper) GetProposalVotesIterator(ctx sdk.Context, proposalID uint64) sdk.Iterator { - store := ctx.KVStore(k.storeKey) - return sdk.KVStorePrefixIterator(store, VotesKey(proposalID)) -} - -func (k Keeper) GetProposalVotes(ctx sdk.Context, proposalID uint64) types.Votes { - var votes types.Votes - - iterator := k.GetProposalVotesIterator(ctx, proposalID) - defer iterator.Close() - for ; iterator.Valid(); iterator.Next() { - var vote types.Vote - k.cdc.MustUnmarshal(iterator.Value(), &vote) - votes = append(votes, vote) - } - - return votes -} - -func (k Keeper) GetAverageVotesSlash(ctx sdk.Context, proposalID uint64) sdk.Dec { - votes := k.GetProposalVotes(ctx, proposalID) - totalSlash := sdk.ZeroDec() - totalCount := int64(0) - for _, vote := range votes { - if vote.Option == types.OptionYes { - totalSlash = totalSlash.Add(vote.Slash) - totalCount++ - } - } - if totalCount == 0 { - return sdk.ZeroDec() - } - return totalSlash.QuoInt64(totalCount) -} - -func (k Keeper) AddToActiveProposals(ctx sdk.Context, proposal types.Proposal) { - store := ctx.KVStore(k.storeKey) - store.Set(ActiveProposalKey(proposal), ProposalIDToBytes(proposal.ProposalId)) -} - -func (k Keeper) RemoveActiveProposal(ctx sdk.Context, proposal types.Proposal) { - store := ctx.KVStore(k.storeKey) - store.Delete(ActiveProposalKey(proposal)) -} - -func (k Keeper) AddToEnactmentProposals(ctx sdk.Context, proposal types.Proposal) { - store := ctx.KVStore(k.storeKey) - store.Set(EnactmentProposalKey(proposal), ProposalIDToBytes(proposal.ProposalId)) -} - -func (k Keeper) RemoveEnactmentProposal(ctx sdk.Context, proposal types.Proposal) { - store := ctx.KVStore(k.storeKey) - store.Delete(EnactmentProposalKey(proposal)) -} - -// GetActiveProposalsWithFinishedVotingEndTimeIterator returns the proposals that have endtime finished. -func (k Keeper) GetActiveProposalsWithFinishedVotingEndTimeIterator(ctx sdk.Context, endTime time.Time) sdk.Iterator { - store := ctx.KVStore(k.storeKey) - return store.Iterator(ActiveProposalsPrefix, sdk.PrefixEndBytes(ActiveProposalByTimeKey(endTime))) -} - -// GetEnactmentProposalsWithFinishedEnactmentEndTimeIterator returns the proposals that have finished the enactment time. -func (k Keeper) GetEnactmentProposalsWithFinishedEnactmentEndTimeIterator(ctx sdk.Context, endTime time.Time) sdk.Iterator { - store := ctx.KVStore(k.storeKey) - return store.Iterator(EnactmentProposalsPrefix, sdk.PrefixEndBytes(EnactmentProposalByTimeKey(endTime))) -} - -func ActiveProposalByTimeKey(endTime time.Time) []byte { - return append(ActiveProposalsPrefix, sdk.FormatTimeBytes(endTime)...) -} - -func EnactmentProposalByTimeKey(endTime time.Time) []byte { - return append(EnactmentProposalsPrefix, sdk.FormatTimeBytes(endTime)...) -} - -func ActiveProposalKey(prop types.Proposal) []byte { - return append(ActiveProposalByTimeKey(prop.VotingEndTime), ProposalIDToBytes(prop.ProposalId)...) -} - -func EnactmentProposalKey(prop types.Proposal) []byte { - return append(EnactmentProposalByTimeKey(prop.EnactmentEndTime), ProposalIDToBytes(prop.ProposalId)...) -} - -func VotesKey(proposalID uint64) []byte { - return append(VotesPrefix, ProposalIDToBytes(proposalID)...) -} - -func VoteKey(proposalId uint64, address sdk.AccAddress) []byte { - return append(VotesKey(proposalId), address.Bytes()...) -} - -func GetProposalKey(proposalID uint64) []byte { - return append(ProposalsPrefix, ProposalIDToBytes(proposalID)...) -} +package keeper + +import ( + "time" + + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/KiraCore/sekai/x/gov/types" +) + +func (k Keeper) GetNextProposalIDAndIncrement(ctx sdk.Context) uint64 { + proposalID := k.GetNextProposalID(ctx) + k.SetNextProposalID(ctx, proposalID+1) + return proposalID +} + +func (k Keeper) GetNextProposalID(ctx sdk.Context) uint64 { + store := ctx.KVStore(k.storeKey) + + bz := store.Get(NextProposalIDPrefix) + if bz == nil { + return 1 + } + + proposalID := BytesToProposalID(bz) + return proposalID +} + +func (k Keeper) SetNextProposalID(ctx sdk.Context, proposalID uint64) { + store := ctx.KVStore(k.storeKey) + store.Set(NextProposalIDPrefix, ProposalIDToBytes(proposalID)) +} + +func (k Keeper) CreateAndSaveProposalWithContent(ctx sdk.Context, title, description string, content types.Content) (uint64, error) { + blockTime := ctx.BlockTime() + proposalID := k.GetNextProposalIDAndIncrement(ctx) + + properties := k.GetNetworkProperties(ctx) + + // dynamic proposal end time based on proposal type + proposalEndTime := k.GetProposalDuration(ctx, content.ProposalType()) + if proposalEndTime < properties.MinimumProposalEndTime { + proposalEndTime = properties.MinimumProposalEndTime + } + + proposalEnactmentTime := properties.ProposalEnactmentTime + + if content.VotePermission() == types.PermZero { + router := k.GetProposalRouter() + proposalEndTime = router.VotePeriodDynamicProposal(ctx, content) + proposalEnactmentTime = router.EnactmentPeriodDynamicProposal(ctx, content) + } + + proposal, err := types.NewProposal( + proposalID, + title, + description, + content, + blockTime, + blockTime.Add(time.Second*time.Duration(proposalEndTime)), + blockTime.Add(time.Second*time.Duration(proposalEndTime)+ + time.Second*time.Duration(proposalEnactmentTime), + ), + ctx.BlockHeight()+int64(properties.MinProposalEndBlocks), + ctx.BlockHeight()+int64(properties.MinProposalEndBlocks+properties.MinProposalEnactmentBlocks), + ) + + if err != nil { + return proposalID, err + } + + k.SaveProposal(ctx, proposal) + k.AddToActiveProposals(ctx, proposal) + + return proposalID, nil +} + +func (k Keeper) SaveProposal(ctx sdk.Context, proposal types.Proposal) { + store := ctx.KVStore(k.storeKey) + + bz := k.cdc.MustMarshal(&proposal) + store.Set(GetProposalKey(proposal.ProposalId), bz) +} + +func (k Keeper) GetProposal(ctx sdk.Context, proposalID uint64) (types.Proposal, bool) { + store := ctx.KVStore(k.storeKey) + + bz := store.Get(GetProposalKey(proposalID)) + if bz == nil { + return types.Proposal{}, false + } + + var prop types.Proposal + k.cdc.MustUnmarshal(bz, &prop) + + return prop, true +} + +func (k Keeper) GetProposals(ctx sdk.Context) ([]types.Proposal, error) { + proposals := []types.Proposal{} + iterator := sdk.KVStorePrefixIterator(ctx.KVStore(k.storeKey), ProposalsPrefix) + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + var proposal types.Proposal + bz := iterator.Value() + k.cdc.MustUnmarshal(bz, &proposal) + proposals = append(proposals, proposal) + } + + return proposals, nil +} + +func (k Keeper) SaveVote(ctx sdk.Context, vote types.Vote) { + store := ctx.KVStore(k.storeKey) + bz := k.cdc.MustMarshal(&vote) + store.Set(VoteKey(vote.ProposalId, vote.Voter), bz) +} + +func (k Keeper) DeleteVote(ctx sdk.Context, vote types.Vote) { + store := ctx.KVStore(k.storeKey) + store.Delete(VoteKey(vote.ProposalId, vote.Voter)) +} + +func (k Keeper) GetVote(ctx sdk.Context, proposalID uint64, address sdk.AccAddress) (types.Vote, bool) { + store := ctx.KVStore(k.storeKey) + + bz := store.Get(VoteKey(proposalID, address)) + if bz == nil { + return types.Vote{}, false + } + + var vote types.Vote + k.cdc.MustUnmarshal(bz, &vote) + + return vote, true +} + +func (k Keeper) GetVotes(ctx sdk.Context) []types.Vote { + votes := []types.Vote{} + iterator := sdk.KVStorePrefixIterator(ctx.KVStore(k.storeKey), VotesPrefix) + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + var vote types.Vote + bz := iterator.Value() + k.cdc.MustUnmarshal(bz, &vote) + votes = append(votes, vote) + } + + return votes +} + +func (k Keeper) GetProposalVotesIterator(ctx sdk.Context, proposalID uint64) sdk.Iterator { + store := ctx.KVStore(k.storeKey) + return sdk.KVStorePrefixIterator(store, VotesKey(proposalID)) +} + +func (k Keeper) GetProposalVotes(ctx sdk.Context, proposalID uint64) types.Votes { + var votes types.Votes + + iterator := k.GetProposalVotesIterator(ctx, proposalID) + defer iterator.Close() + for ; iterator.Valid(); iterator.Next() { + var vote types.Vote + k.cdc.MustUnmarshal(iterator.Value(), &vote) + votes = append(votes, vote) + } + + return votes +} + +func (k Keeper) GetAverageVotesSlash(ctx sdk.Context, proposalID uint64) sdk.Dec { + votes := k.GetProposalVotes(ctx, proposalID) + totalSlash := sdk.ZeroDec() + totalCount := int64(0) + for _, vote := range votes { + if vote.Option == types.OptionYes { + totalSlash = totalSlash.Add(vote.Slash) + totalCount++ + } + } + if totalCount == 0 { + return sdk.ZeroDec() + } + return totalSlash.QuoInt64(totalCount) +} + +func (k Keeper) AddToActiveProposals(ctx sdk.Context, proposal types.Proposal) { + store := ctx.KVStore(k.storeKey) + store.Set(ActiveProposalKey(proposal), ProposalIDToBytes(proposal.ProposalId)) +} + +func (k Keeper) RemoveActiveProposal(ctx sdk.Context, proposal types.Proposal) { + store := ctx.KVStore(k.storeKey) + store.Delete(ActiveProposalKey(proposal)) +} + +func (k Keeper) AddToEnactmentProposals(ctx sdk.Context, proposal types.Proposal) { + store := ctx.KVStore(k.storeKey) + store.Set(EnactmentProposalKey(proposal), ProposalIDToBytes(proposal.ProposalId)) +} + +func (k Keeper) RemoveEnactmentProposal(ctx sdk.Context, proposal types.Proposal) { + store := ctx.KVStore(k.storeKey) + store.Delete(EnactmentProposalKey(proposal)) +} + +// GetActiveProposalsWithFinishedVotingEndTimeIterator returns the proposals that have endtime finished. +func (k Keeper) GetActiveProposalsWithFinishedVotingEndTimeIterator(ctx sdk.Context, endTime time.Time) sdk.Iterator { + store := ctx.KVStore(k.storeKey) + return store.Iterator(ActiveProposalsPrefix, sdk.PrefixEndBytes(ActiveProposalByTimeKey(endTime))) +} + +// GetEnactmentProposalsWithFinishedEnactmentEndTimeIterator returns the proposals that have finished the enactment time. +func (k Keeper) GetEnactmentProposalsWithFinishedEnactmentEndTimeIterator(ctx sdk.Context, endTime time.Time) sdk.Iterator { + store := ctx.KVStore(k.storeKey) + return store.Iterator(EnactmentProposalsPrefix, sdk.PrefixEndBytes(EnactmentProposalByTimeKey(endTime))) +} + +func ActiveProposalByTimeKey(endTime time.Time) []byte { + return append(ActiveProposalsPrefix, sdk.FormatTimeBytes(endTime)...) +} + +func EnactmentProposalByTimeKey(endTime time.Time) []byte { + return append(EnactmentProposalsPrefix, sdk.FormatTimeBytes(endTime)...) +} + +func ActiveProposalKey(prop types.Proposal) []byte { + return append(ActiveProposalByTimeKey(prop.VotingEndTime), ProposalIDToBytes(prop.ProposalId)...) +} + +func EnactmentProposalKey(prop types.Proposal) []byte { + return append(EnactmentProposalByTimeKey(prop.EnactmentEndTime), ProposalIDToBytes(prop.ProposalId)...) +} + +func VotesKey(proposalID uint64) []byte { + return append(VotesPrefix, ProposalIDToBytes(proposalID)...) +} + +func VoteKey(proposalId uint64, address sdk.AccAddress) []byte { + return append(VotesKey(proposalId), address.Bytes()...) +} + +func GetProposalKey(proposalID uint64) []byte { + return append(ProposalsPrefix, ProposalIDToBytes(proposalID)...) +} diff --git a/x/gov/keeper/proposal_duration.go b/x/gov/keeper/proposal_duration.go index d9accecd5..16dd7678c 100644 --- a/x/gov/keeper/proposal_duration.go +++ b/x/gov/keeper/proposal_duration.go @@ -1,44 +1,44 @@ -package keeper - -import ( - "fmt" - - "github.com/KiraCore/sekai/x/gov/types" - "github.com/cosmos/cosmos-sdk/store/prefix" - sdk "github.com/cosmos/cosmos-sdk/types" -) - -func (k Keeper) SetProposalDuration(ctx sdk.Context, proposalType string, duration uint64) error { - // duration should be longer than minimum proposal duration - properties := k.GetNetworkProperties(ctx) - if duration < properties.MinimumProposalEndTime { - return fmt.Errorf("duration should be longer than minimum proposal duration") - } - - store := ctx.KVStore(k.storeKey) - prefixStore := prefix.NewStore(store, types.KeyPrefixProposalDuration) - prefixStore.Set([]byte(proposalType), sdk.Uint64ToBigEndian(duration)) - return nil -} - -func (k Keeper) GetProposalDuration(ctx sdk.Context, proposalType string) uint64 { - store := ctx.KVStore(k.storeKey) - prefixStore := prefix.NewStore(store, types.KeyPrefixProposalDuration) - bz := prefixStore.Get([]byte(proposalType)) - if bz == nil { - return 0 - } - return sdk.BigEndianToUint64(bz) -} - -func (k Keeper) GetAllProposalDurations(ctx sdk.Context) map[string]uint64 { - proposalDurations := make(map[string]uint64) - store := ctx.KVStore(k.storeKey) - prefixStore := prefix.NewStore(store, types.KeyPrefixProposalDuration) - iterator := prefixStore.Iterator(nil, nil) - defer iterator.Close() - for ; iterator.Valid(); iterator.Next() { - proposalDurations[string(iterator.Key())] = sdk.BigEndianToUint64(iterator.Value()) - } - return proposalDurations -} +package keeper + +import ( + "fmt" + + "github.com/KiraCore/sekai/x/gov/types" + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func (k Keeper) SetProposalDuration(ctx sdk.Context, proposalType string, duration uint64) error { + // duration should be longer than minimum proposal duration + properties := k.GetNetworkProperties(ctx) + if duration < properties.MinimumProposalEndTime { + return fmt.Errorf("duration should be longer than minimum proposal duration") + } + + store := ctx.KVStore(k.storeKey) + prefixStore := prefix.NewStore(store, types.KeyPrefixProposalDuration) + prefixStore.Set([]byte(proposalType), sdk.Uint64ToBigEndian(duration)) + return nil +} + +func (k Keeper) GetProposalDuration(ctx sdk.Context, proposalType string) uint64 { + store := ctx.KVStore(k.storeKey) + prefixStore := prefix.NewStore(store, types.KeyPrefixProposalDuration) + bz := prefixStore.Get([]byte(proposalType)) + if bz == nil { + return 0 + } + return sdk.BigEndianToUint64(bz) +} + +func (k Keeper) GetAllProposalDurations(ctx sdk.Context) map[string]uint64 { + proposalDurations := make(map[string]uint64) + store := ctx.KVStore(k.storeKey) + prefixStore := prefix.NewStore(store, types.KeyPrefixProposalDuration) + iterator := prefixStore.Iterator(nil, nil) + defer iterator.Close() + for ; iterator.Valid(); iterator.Next() { + proposalDurations[string(iterator.Key())] = sdk.BigEndianToUint64(iterator.Value()) + } + return proposalDurations +} diff --git a/x/gov/keeper/proposal_duration_test.go b/x/gov/keeper/proposal_duration_test.go index 2087e6728..70e1a390e 100644 --- a/x/gov/keeper/proposal_duration_test.go +++ b/x/gov/keeper/proposal_duration_test.go @@ -1,37 +1,37 @@ -package keeper_test - -import ( - "testing" - - simapp "github.com/KiraCore/sekai/app" - kiratypes "github.com/KiraCore/sekai/types" - "github.com/stretchr/testify/require" - tmproto "github.com/tendermint/tendermint/proto/tendermint/types" -) - -func TestProposalDurationSetGet(t *testing.T) { - app := simapp.Setup(false) - ctx := app.NewContext(false, tmproto.Header{}) - - // get not specifically define type - duration := app.CustomGovKeeper.GetProposalDuration(ctx, kiratypes.SetProposalDurationsProposalType) - require.Equal(t, duration, uint64(0)) - - // try to set correct value - err := app.CustomGovKeeper.SetProposalDuration(ctx, kiratypes.SetProposalDurationsProposalType, 2400) - require.NoError(t, err) - - duration = app.CustomGovKeeper.GetProposalDuration(ctx, kiratypes.SetProposalDurationsProposalType) - require.Equal(t, duration, uint64(2400)) - - // try setting again with lower than minimum value - err = app.CustomGovKeeper.SetProposalDuration(ctx, kiratypes.SetProposalDurationsProposalType, 1) - require.Error(t, err) - - duration = app.CustomGovKeeper.GetProposalDuration(ctx, kiratypes.SetProposalDurationsProposalType) - require.Equal(t, duration, uint64(2400)) - - // check get all functionality - allDurations := app.CustomGovKeeper.GetAllProposalDurations(ctx) - require.Equal(t, len(allDurations), 1) -} +package keeper_test + +import ( + "testing" + + simapp "github.com/KiraCore/sekai/app" + kiratypes "github.com/KiraCore/sekai/types" + "github.com/stretchr/testify/require" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" +) + +func TestProposalDurationSetGet(t *testing.T) { + app := simapp.Setup(false) + ctx := app.NewContext(false, tmproto.Header{}) + + // get not specifically define type + duration := app.CustomGovKeeper.GetProposalDuration(ctx, kiratypes.SetProposalDurationsProposalType) + require.Equal(t, duration, uint64(0)) + + // try to set correct value + err := app.CustomGovKeeper.SetProposalDuration(ctx, kiratypes.SetProposalDurationsProposalType, 2400) + require.NoError(t, err) + + duration = app.CustomGovKeeper.GetProposalDuration(ctx, kiratypes.SetProposalDurationsProposalType) + require.Equal(t, duration, uint64(2400)) + + // try setting again with lower than minimum value + err = app.CustomGovKeeper.SetProposalDuration(ctx, kiratypes.SetProposalDurationsProposalType, 1) + require.Error(t, err) + + duration = app.CustomGovKeeper.GetProposalDuration(ctx, kiratypes.SetProposalDurationsProposalType) + require.Equal(t, duration, uint64(2400)) + + // check get all functionality + allDurations := app.CustomGovKeeper.GetAllProposalDurations(ctx) + require.Equal(t, len(allDurations), 1) +} diff --git a/x/gov/keeper/proposal_test.go b/x/gov/keeper/proposal_test.go index bf6b7622d..6be2f9042 100644 --- a/x/gov/keeper/proposal_test.go +++ b/x/gov/keeper/proposal_test.go @@ -1,366 +1,366 @@ -package keeper_test - -import ( - "testing" - "time" - - simapp "github.com/KiraCore/sekai/app" - kiratypes "github.com/KiraCore/sekai/types" - "github.com/KiraCore/sekai/x/gov/types" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/require" - tmproto "github.com/tendermint/tendermint/proto/tendermint/types" -) - -func TestDefaultProposalIdAtDefaultGenesis(t *testing.T) { - app := simapp.Setup(false) - ctx := app.NewContext(false, tmproto.Header{}) - - proposalID := app.CustomGovKeeper.GetNextProposalID(ctx) - require.Equal(t, uint64(1), proposalID) -} - -func TestKeeper_EncodingContentType(t *testing.T) { - app := simapp.Setup(false) - ctx := app.NewContext(false, tmproto.Header{}) - - addrs := simapp.AddTestAddrsIncremental(app, ctx, 1, sdk.TokensFromConsensusPower(10, sdk.DefaultPowerReduction)) - addr := addrs[0] - - proposal1, err := types.NewProposal( - 1, - "title", - "some desc", - types.NewWhitelistAccountPermissionProposal( - addr, - types.PermSetPermissions, - ), - time.Now(), - time.Now().Add(1*time.Second), - time.Now().Add(10*time.Second), - ctx.BlockHeight()+2, - ctx.BlockHeight()+3, - ) - require.NoError(t, err) - - app.CustomGovKeeper.SaveProposal(ctx, proposal1) - - saveProposal, found := app.CustomGovKeeper.GetProposal(ctx, proposal1.ProposalId) - require.True(t, found) - - require.Equal(t, proposal1.GetContent(), saveProposal.GetContent()) - - content, ok := saveProposal.GetContent().(*types.WhitelistAccountPermissionProposal) - require.True(t, ok) - require.Equal(t, addr, content.Address) - require.Equal(t, types.PermSetPermissions, content.Permission) -} - -func TestKeeper_GetProposals(t *testing.T) { - app := simapp.Setup(false) - ctx := app.NewContext(false, tmproto.Header{}) - - addrs := simapp.AddTestAddrsIncremental(app, ctx, 1, sdk.TokensFromConsensusPower(10, sdk.DefaultPowerReduction)) - addr := addrs[0] - - proposal1, err := types.NewProposal( - 1, - "title", - "some desc", - types.NewWhitelistAccountPermissionProposal( - addr, - types.PermSetPermissions, - ), - time.Now(), - time.Now().Add(1*time.Second), - time.Now().Add(10*time.Second), - ctx.BlockHeight()+2, - ctx.BlockHeight()+3, - ) - require.NoError(t, err) - - app.CustomGovKeeper.SaveProposal(ctx, proposal1) - - proposals, err := app.CustomGovKeeper.GetProposals(ctx) - require.NoError(t, err) - require.Len(t, proposals, 1) - - proposal2, err := types.NewProposal( - 2, - "title", - "some desc", - types.NewWhitelistAccountPermissionProposal( - addr, - types.PermSetPermissions, - ), - time.Now(), - time.Now().Add(1*time.Second), - time.Now().Add(10*time.Second), - ctx.BlockHeight()+2, - ctx.BlockHeight()+3, - ) - app.CustomGovKeeper.SaveProposal(ctx, proposal2) - proposals, err = app.CustomGovKeeper.GetProposals(ctx) - require.NoError(t, err) - require.Len(t, proposals, 2) - require.Equal(t, proposals[1].ProposalId, proposal2.ProposalId) - require.Equal(t, proposals[1].Content, proposal2.Content) - require.Equal(t, proposals[1].Result, proposal2.Result) - require.Equal(t, proposals[1].SubmitTime.UTC().String(), proposal2.SubmitTime.UTC().String()) - require.Equal(t, proposals[1].VotingEndTime.UTC().String(), proposal2.VotingEndTime.UTC().String()) - require.Equal(t, proposals[1].EnactmentEndTime.UTC().String(), proposal2.EnactmentEndTime.UTC().String()) -} - -func TestSaveProposalReturnsTheProposalID_AndIncreasesLast(t *testing.T) { - app := simapp.Setup(false) - ctx := app.NewContext(false, tmproto.Header{}) - - proposalID := app.CustomGovKeeper.GetNextProposalIDAndIncrement(ctx) - require.Equal(t, uint64(1), proposalID) - - addrs := simapp.AddTestAddrsIncremental(app, ctx, 1, sdk.TokensFromConsensusPower(10, sdk.DefaultPowerReduction)) - addr := addrs[0] - - proposal, err := types.NewProposal( - proposalID, - "title", - "some desc", - types.NewWhitelistAccountPermissionProposal( - addr, - types.PermClaimValidator, - ), - ctx.BlockTime(), - ctx.BlockTime().Add(10*time.Minute), - ctx.BlockTime().Add(20*time.Minute), - ctx.BlockHeight()+2, - ctx.BlockHeight()+3, - ) - require.NoError(t, err) - app.CustomGovKeeper.SaveProposal(ctx, proposal) - - // nextProposalID should be 2 - proposalID = app.CustomGovKeeper.GetNextProposalID(ctx) - require.Equal(t, uint64(2), proposalID) - - // Get proposal - savedProposal, found := app.CustomGovKeeper.GetProposal(ctx, proposal.ProposalId) - require.True(t, found) - require.Equal(t, proposal, savedProposal) -} - -func TestKeeper_SaveVote(t *testing.T) { - app := simapp.Setup(false) - ctx := app.NewContext(false, tmproto.Header{}) - - addrs := simapp.AddTestAddrsIncremental(app, ctx, 1, sdk.TokensFromConsensusPower(10, sdk.DefaultPowerReduction)) - addr := addrs[0] - - // Vote not saved yet - _, found := app.CustomGovKeeper.GetVote(ctx, 1, addr) - require.False(t, found) - - vote := types.NewVote(1, addr, types.OptionAbstain, sdk.ZeroDec()) - - app.CustomGovKeeper.SaveVote(ctx, vote) - - savedVote, found := app.CustomGovKeeper.GetVote(ctx, 1, addr) - require.True(t, found) - require.Equal(t, vote, savedVote) -} - -func TestKeeper_AddProposalToActiveQueue(t *testing.T) { - app := simapp.Setup(false) - ctx := app.NewContext(false, tmproto.Header{}) - - addrs := simapp.AddTestAddrsIncremental(app, ctx, 1, sdk.TokensFromConsensusPower(10, sdk.DefaultPowerReduction)) - addr := addrs[0] - - baseEndTime := time.Now() - for _, i := range []uint64{1, 2, 3} { - endTime := baseEndTime.Add(time.Second * time.Duration(i)) - - proposal, err := types.NewProposal( - i, - "title", - "some desc", - types.NewWhitelistAccountPermissionProposal( - addr, - types.PermSetPermissions, - ), - baseEndTime, - endTime, - endTime, - ctx.BlockHeight()+2, - ctx.BlockHeight()+3, - ) - require.NoError(t, err) - - app.CustomGovKeeper.SaveProposal(ctx, proposal) - app.CustomGovKeeper.AddToActiveProposals(ctx, proposal) - } - - // We only get until endtime of the second proposal. - iterator := app.CustomGovKeeper.GetActiveProposalsWithFinishedVotingEndTimeIterator(ctx, baseEndTime.Add(2*time.Second)) - defer iterator.Close() - requireIteratorCount(t, iterator, 2) - - // We remove one ActiveProposal, the first - proposal, found := app.CustomGovKeeper.GetProposal(ctx, 1) - require.True(t, found) - app.CustomGovKeeper.RemoveActiveProposal(ctx, proposal) - - // We then only get 1 proposal. - iterator = app.CustomGovKeeper.GetActiveProposalsWithFinishedVotingEndTimeIterator(ctx, baseEndTime.Add(2*time.Second)) - defer iterator.Close() - requireIteratorCount(t, iterator, 1) -} - -func TestKeeper_AddProposalToEnactmentQueue(t *testing.T) { - app := simapp.Setup(false) - ctx := app.NewContext(false, tmproto.Header{}) - - addrs := simapp.AddTestAddrsIncremental(app, ctx, 1, sdk.TokensFromConsensusPower(10, sdk.DefaultPowerReduction)) - addr := addrs[0] - - baseEndTime := time.Now() - for _, i := range []uint64{1, 2, 3} { - enactmentEndTime := baseEndTime.Add(time.Duration(i) * time.Second) - proposal, err := types.NewProposal( - i, - "title", - "some desc", - types.NewWhitelistAccountPermissionProposal( - addr, - types.PermSetPermissions, - ), - baseEndTime, - baseEndTime, - enactmentEndTime, - ctx.BlockHeight()+2, - ctx.BlockHeight()+3, - ) - require.NoError(t, err) - - app.CustomGovKeeper.SaveProposal(ctx, proposal) - app.CustomGovKeeper.AddToEnactmentProposals(ctx, proposal) - } - - // We only get until endtime of the second proposal. - iterator := app.CustomGovKeeper.GetEnactmentProposalsWithFinishedEnactmentEndTimeIterator(ctx, baseEndTime.Add(2*time.Second)) - defer iterator.Close() - requireIteratorCount(t, iterator, 2) - - // We remove one Proposal from the Enactment list, the first - proposal, found := app.CustomGovKeeper.GetProposal(ctx, 1) - require.True(t, found) - app.CustomGovKeeper.RemoveEnactmentProposal(ctx, proposal) - - // We then only get 1 proposal. - iterator = app.CustomGovKeeper.GetEnactmentProposalsWithFinishedEnactmentEndTimeIterator(ctx, baseEndTime.Add(2*time.Second)) - defer iterator.Close() - requireIteratorCount(t, iterator, 1) -} - -func TestKeeper_GetProposalVotesIterator(t *testing.T) { - app := simapp.Setup(false) - ctx := app.NewContext(false, tmproto.Header{}) - - addrs := simapp.AddTestAddrsIncremental(app, ctx, 2, sdk.TokensFromConsensusPower(10, sdk.DefaultPowerReduction)) - addr1 := addrs[0] - addr2 := addrs[1] - - proposal1, err := types.NewProposal( - 1, - "title", - "some desc", - types.NewWhitelistAccountPermissionProposal( - addr1, - types.PermSetPermissions, - ), - time.Now(), - time.Now().Add(1*time.Second), - time.Now().Add(10*time.Second), - ctx.BlockHeight()+2, - ctx.BlockHeight()+3, - ) - require.NoError(t, err) - - proposal2, err := types.NewProposal( - 2, - "title", - "some desc", - types.NewWhitelistAccountPermissionProposal( - addr2, - types.PermClaimCouncilor, - ), - time.Now(), - time.Now().Add(1*time.Second), - time.Now().Add(10*time.Second), - ctx.BlockHeight()+2, - ctx.BlockHeight()+3, - ) - require.NoError(t, err) - - app.CustomGovKeeper.SaveProposal(ctx, proposal1) - app.CustomGovKeeper.SaveProposal(ctx, proposal2) - - // 1st proposal has 2 votes - vote1 := types.NewVote(proposal1.ProposalId, addr1, types.OptionYes, sdk.ZeroDec()) - vote2 := types.NewVote(proposal1.ProposalId, addr2, types.OptionYes, sdk.ZeroDec()) - app.CustomGovKeeper.SaveVote(ctx, vote1) - app.CustomGovKeeper.SaveVote(ctx, vote2) - - // 2nd proposal has 1 vote - v1 := types.NewVote(proposal2.ProposalId, addr1, types.OptionYes, sdk.ZeroDec()) - app.CustomGovKeeper.SaveVote(ctx, v1) - - // We iterate the 1st proposal - iterator := app.CustomGovKeeper.GetProposalVotesIterator(ctx, proposal1.ProposalId) - require.True(t, iterator.Valid()) - totalVotes := 0 - for ; iterator.Valid(); iterator.Next() { - totalVotes++ - } - require.Equal(t, 2, totalVotes) - - // We iterate the 2nd proposal - iterator = app.CustomGovKeeper.GetProposalVotesIterator(ctx, proposal2.ProposalId) - require.True(t, iterator.Valid()) - totalVotes = 0 - for ; iterator.Valid(); iterator.Next() { - totalVotes++ - } - require.Equal(t, 1, totalVotes) -} - -func TestKeeper_ProposalDuration(t *testing.T) { - app := simapp.Setup(false) - ctx := app.NewContext(false, tmproto.Header{}) - ctx = ctx.WithBlockTime(time.Now()) - - properties := app.CustomGovKeeper.GetNetworkProperties(ctx) - - // test WhitelistAccountPermissionProposal - proposalID, err := app.CustomGovKeeper.CreateAndSaveProposalWithContent(ctx, "title", "description", &types.WhitelistAccountPermissionProposal{}) - require.NoError(t, err) - - proposal, found := app.CustomGovKeeper.GetProposal(ctx, proposalID) - require.True(t, found) - - require.Equal(t, proposal.VotingEndTime.Unix(), ctx.BlockTime().Unix()+int64(properties.MinimumProposalEndTime)) - - // test SetNetworkPropertyProposal - proposalID, err = app.CustomGovKeeper.CreateAndSaveProposalWithContent(ctx, "title", "description", &types.SetNetworkPropertyProposal{}) - require.NoError(t, err) - proposal, found = app.CustomGovKeeper.GetProposal(ctx, proposalID) - require.True(t, found) - require.Equal(t, proposal.VotingEndTime.Unix(), ctx.BlockTime().Unix()+int64(properties.MinimumProposalEndTime)) - - // check longer duration proposal - app.CustomGovKeeper.SetProposalDuration(ctx, kiratypes.SetProposalDurationsProposalType, 2400) - proposalID, err = app.CustomGovKeeper.CreateAndSaveProposalWithContent(ctx, "title", "description", &types.SetProposalDurationsProposal{}) - require.NoError(t, err) - proposal, found = app.CustomGovKeeper.GetProposal(ctx, proposalID) - require.True(t, found) - require.Equal(t, proposal.VotingEndTime.Unix(), ctx.BlockTime().Unix()+2400) -} +package keeper_test + +import ( + "testing" + "time" + + simapp "github.com/KiraCore/sekai/app" + kiratypes "github.com/KiraCore/sekai/types" + "github.com/KiraCore/sekai/x/gov/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" +) + +func TestDefaultProposalIdAtDefaultGenesis(t *testing.T) { + app := simapp.Setup(false) + ctx := app.NewContext(false, tmproto.Header{}) + + proposalID := app.CustomGovKeeper.GetNextProposalID(ctx) + require.Equal(t, uint64(1), proposalID) +} + +func TestKeeper_EncodingContentType(t *testing.T) { + app := simapp.Setup(false) + ctx := app.NewContext(false, tmproto.Header{}) + + addrs := simapp.AddTestAddrsIncremental(app, ctx, 1, sdk.TokensFromConsensusPower(10, sdk.DefaultPowerReduction)) + addr := addrs[0] + + proposal1, err := types.NewProposal( + 1, + "title", + "some desc", + types.NewWhitelistAccountPermissionProposal( + addr, + types.PermSetPermissions, + ), + time.Now(), + time.Now().Add(1*time.Second), + time.Now().Add(10*time.Second), + ctx.BlockHeight()+2, + ctx.BlockHeight()+3, + ) + require.NoError(t, err) + + app.CustomGovKeeper.SaveProposal(ctx, proposal1) + + saveProposal, found := app.CustomGovKeeper.GetProposal(ctx, proposal1.ProposalId) + require.True(t, found) + + require.Equal(t, proposal1.GetContent(), saveProposal.GetContent()) + + content, ok := saveProposal.GetContent().(*types.WhitelistAccountPermissionProposal) + require.True(t, ok) + require.Equal(t, addr, content.Address) + require.Equal(t, types.PermSetPermissions, content.Permission) +} + +func TestKeeper_GetProposals(t *testing.T) { + app := simapp.Setup(false) + ctx := app.NewContext(false, tmproto.Header{}) + + addrs := simapp.AddTestAddrsIncremental(app, ctx, 1, sdk.TokensFromConsensusPower(10, sdk.DefaultPowerReduction)) + addr := addrs[0] + + proposal1, err := types.NewProposal( + 1, + "title", + "some desc", + types.NewWhitelistAccountPermissionProposal( + addr, + types.PermSetPermissions, + ), + time.Now(), + time.Now().Add(1*time.Second), + time.Now().Add(10*time.Second), + ctx.BlockHeight()+2, + ctx.BlockHeight()+3, + ) + require.NoError(t, err) + + app.CustomGovKeeper.SaveProposal(ctx, proposal1) + + proposals, err := app.CustomGovKeeper.GetProposals(ctx) + require.NoError(t, err) + require.Len(t, proposals, 1) + + proposal2, err := types.NewProposal( + 2, + "title", + "some desc", + types.NewWhitelistAccountPermissionProposal( + addr, + types.PermSetPermissions, + ), + time.Now(), + time.Now().Add(1*time.Second), + time.Now().Add(10*time.Second), + ctx.BlockHeight()+2, + ctx.BlockHeight()+3, + ) + app.CustomGovKeeper.SaveProposal(ctx, proposal2) + proposals, err = app.CustomGovKeeper.GetProposals(ctx) + require.NoError(t, err) + require.Len(t, proposals, 2) + require.Equal(t, proposals[1].ProposalId, proposal2.ProposalId) + require.Equal(t, proposals[1].Content, proposal2.Content) + require.Equal(t, proposals[1].Result, proposal2.Result) + require.Equal(t, proposals[1].SubmitTime.UTC().String(), proposal2.SubmitTime.UTC().String()) + require.Equal(t, proposals[1].VotingEndTime.UTC().String(), proposal2.VotingEndTime.UTC().String()) + require.Equal(t, proposals[1].EnactmentEndTime.UTC().String(), proposal2.EnactmentEndTime.UTC().String()) +} + +func TestSaveProposalReturnsTheProposalID_AndIncreasesLast(t *testing.T) { + app := simapp.Setup(false) + ctx := app.NewContext(false, tmproto.Header{}) + + proposalID := app.CustomGovKeeper.GetNextProposalIDAndIncrement(ctx) + require.Equal(t, uint64(1), proposalID) + + addrs := simapp.AddTestAddrsIncremental(app, ctx, 1, sdk.TokensFromConsensusPower(10, sdk.DefaultPowerReduction)) + addr := addrs[0] + + proposal, err := types.NewProposal( + proposalID, + "title", + "some desc", + types.NewWhitelistAccountPermissionProposal( + addr, + types.PermClaimValidator, + ), + ctx.BlockTime(), + ctx.BlockTime().Add(10*time.Minute), + ctx.BlockTime().Add(20*time.Minute), + ctx.BlockHeight()+2, + ctx.BlockHeight()+3, + ) + require.NoError(t, err) + app.CustomGovKeeper.SaveProposal(ctx, proposal) + + // nextProposalID should be 2 + proposalID = app.CustomGovKeeper.GetNextProposalID(ctx) + require.Equal(t, uint64(2), proposalID) + + // Get proposal + savedProposal, found := app.CustomGovKeeper.GetProposal(ctx, proposal.ProposalId) + require.True(t, found) + require.Equal(t, proposal, savedProposal) +} + +func TestKeeper_SaveVote(t *testing.T) { + app := simapp.Setup(false) + ctx := app.NewContext(false, tmproto.Header{}) + + addrs := simapp.AddTestAddrsIncremental(app, ctx, 1, sdk.TokensFromConsensusPower(10, sdk.DefaultPowerReduction)) + addr := addrs[0] + + // Vote not saved yet + _, found := app.CustomGovKeeper.GetVote(ctx, 1, addr) + require.False(t, found) + + vote := types.NewVote(1, addr, types.OptionAbstain, sdk.ZeroDec()) + + app.CustomGovKeeper.SaveVote(ctx, vote) + + savedVote, found := app.CustomGovKeeper.GetVote(ctx, 1, addr) + require.True(t, found) + require.Equal(t, vote, savedVote) +} + +func TestKeeper_AddProposalToActiveQueue(t *testing.T) { + app := simapp.Setup(false) + ctx := app.NewContext(false, tmproto.Header{}) + + addrs := simapp.AddTestAddrsIncremental(app, ctx, 1, sdk.TokensFromConsensusPower(10, sdk.DefaultPowerReduction)) + addr := addrs[0] + + baseEndTime := time.Now() + for _, i := range []uint64{1, 2, 3} { + endTime := baseEndTime.Add(time.Second * time.Duration(i)) + + proposal, err := types.NewProposal( + i, + "title", + "some desc", + types.NewWhitelistAccountPermissionProposal( + addr, + types.PermSetPermissions, + ), + baseEndTime, + endTime, + endTime, + ctx.BlockHeight()+2, + ctx.BlockHeight()+3, + ) + require.NoError(t, err) + + app.CustomGovKeeper.SaveProposal(ctx, proposal) + app.CustomGovKeeper.AddToActiveProposals(ctx, proposal) + } + + // We only get until endtime of the second proposal. + iterator := app.CustomGovKeeper.GetActiveProposalsWithFinishedVotingEndTimeIterator(ctx, baseEndTime.Add(2*time.Second)) + defer iterator.Close() + requireIteratorCount(t, iterator, 2) + + // We remove one ActiveProposal, the first + proposal, found := app.CustomGovKeeper.GetProposal(ctx, 1) + require.True(t, found) + app.CustomGovKeeper.RemoveActiveProposal(ctx, proposal) + + // We then only get 1 proposal. + iterator = app.CustomGovKeeper.GetActiveProposalsWithFinishedVotingEndTimeIterator(ctx, baseEndTime.Add(2*time.Second)) + defer iterator.Close() + requireIteratorCount(t, iterator, 1) +} + +func TestKeeper_AddProposalToEnactmentQueue(t *testing.T) { + app := simapp.Setup(false) + ctx := app.NewContext(false, tmproto.Header{}) + + addrs := simapp.AddTestAddrsIncremental(app, ctx, 1, sdk.TokensFromConsensusPower(10, sdk.DefaultPowerReduction)) + addr := addrs[0] + + baseEndTime := time.Now() + for _, i := range []uint64{1, 2, 3} { + enactmentEndTime := baseEndTime.Add(time.Duration(i) * time.Second) + proposal, err := types.NewProposal( + i, + "title", + "some desc", + types.NewWhitelistAccountPermissionProposal( + addr, + types.PermSetPermissions, + ), + baseEndTime, + baseEndTime, + enactmentEndTime, + ctx.BlockHeight()+2, + ctx.BlockHeight()+3, + ) + require.NoError(t, err) + + app.CustomGovKeeper.SaveProposal(ctx, proposal) + app.CustomGovKeeper.AddToEnactmentProposals(ctx, proposal) + } + + // We only get until endtime of the second proposal. + iterator := app.CustomGovKeeper.GetEnactmentProposalsWithFinishedEnactmentEndTimeIterator(ctx, baseEndTime.Add(2*time.Second)) + defer iterator.Close() + requireIteratorCount(t, iterator, 2) + + // We remove one Proposal from the Enactment list, the first + proposal, found := app.CustomGovKeeper.GetProposal(ctx, 1) + require.True(t, found) + app.CustomGovKeeper.RemoveEnactmentProposal(ctx, proposal) + + // We then only get 1 proposal. + iterator = app.CustomGovKeeper.GetEnactmentProposalsWithFinishedEnactmentEndTimeIterator(ctx, baseEndTime.Add(2*time.Second)) + defer iterator.Close() + requireIteratorCount(t, iterator, 1) +} + +func TestKeeper_GetProposalVotesIterator(t *testing.T) { + app := simapp.Setup(false) + ctx := app.NewContext(false, tmproto.Header{}) + + addrs := simapp.AddTestAddrsIncremental(app, ctx, 2, sdk.TokensFromConsensusPower(10, sdk.DefaultPowerReduction)) + addr1 := addrs[0] + addr2 := addrs[1] + + proposal1, err := types.NewProposal( + 1, + "title", + "some desc", + types.NewWhitelistAccountPermissionProposal( + addr1, + types.PermSetPermissions, + ), + time.Now(), + time.Now().Add(1*time.Second), + time.Now().Add(10*time.Second), + ctx.BlockHeight()+2, + ctx.BlockHeight()+3, + ) + require.NoError(t, err) + + proposal2, err := types.NewProposal( + 2, + "title", + "some desc", + types.NewWhitelistAccountPermissionProposal( + addr2, + types.PermClaimCouncilor, + ), + time.Now(), + time.Now().Add(1*time.Second), + time.Now().Add(10*time.Second), + ctx.BlockHeight()+2, + ctx.BlockHeight()+3, + ) + require.NoError(t, err) + + app.CustomGovKeeper.SaveProposal(ctx, proposal1) + app.CustomGovKeeper.SaveProposal(ctx, proposal2) + + // 1st proposal has 2 votes + vote1 := types.NewVote(proposal1.ProposalId, addr1, types.OptionYes, sdk.ZeroDec()) + vote2 := types.NewVote(proposal1.ProposalId, addr2, types.OptionYes, sdk.ZeroDec()) + app.CustomGovKeeper.SaveVote(ctx, vote1) + app.CustomGovKeeper.SaveVote(ctx, vote2) + + // 2nd proposal has 1 vote + v1 := types.NewVote(proposal2.ProposalId, addr1, types.OptionYes, sdk.ZeroDec()) + app.CustomGovKeeper.SaveVote(ctx, v1) + + // We iterate the 1st proposal + iterator := app.CustomGovKeeper.GetProposalVotesIterator(ctx, proposal1.ProposalId) + require.True(t, iterator.Valid()) + totalVotes := 0 + for ; iterator.Valid(); iterator.Next() { + totalVotes++ + } + require.Equal(t, 2, totalVotes) + + // We iterate the 2nd proposal + iterator = app.CustomGovKeeper.GetProposalVotesIterator(ctx, proposal2.ProposalId) + require.True(t, iterator.Valid()) + totalVotes = 0 + for ; iterator.Valid(); iterator.Next() { + totalVotes++ + } + require.Equal(t, 1, totalVotes) +} + +func TestKeeper_ProposalDuration(t *testing.T) { + app := simapp.Setup(false) + ctx := app.NewContext(false, tmproto.Header{}) + ctx = ctx.WithBlockTime(time.Now()) + + properties := app.CustomGovKeeper.GetNetworkProperties(ctx) + + // test WhitelistAccountPermissionProposal + proposalID, err := app.CustomGovKeeper.CreateAndSaveProposalWithContent(ctx, "title", "description", &types.WhitelistAccountPermissionProposal{}) + require.NoError(t, err) + + proposal, found := app.CustomGovKeeper.GetProposal(ctx, proposalID) + require.True(t, found) + + require.Equal(t, proposal.VotingEndTime.Unix(), ctx.BlockTime().Unix()+int64(properties.MinimumProposalEndTime)) + + // test SetNetworkPropertyProposal + proposalID, err = app.CustomGovKeeper.CreateAndSaveProposalWithContent(ctx, "title", "description", &types.SetNetworkPropertyProposal{}) + require.NoError(t, err) + proposal, found = app.CustomGovKeeper.GetProposal(ctx, proposalID) + require.True(t, found) + require.Equal(t, proposal.VotingEndTime.Unix(), ctx.BlockTime().Unix()+int64(properties.MinimumProposalEndTime)) + + // check longer duration proposal + app.CustomGovKeeper.SetProposalDuration(ctx, kiratypes.SetProposalDurationsProposalType, 2400) + proposalID, err = app.CustomGovKeeper.CreateAndSaveProposalWithContent(ctx, "title", "description", &types.SetProposalDurationsProposal{}) + require.NoError(t, err) + proposal, found = app.CustomGovKeeper.GetProposal(ctx, proposalID) + require.True(t, found) + require.Equal(t, proposal.VotingEndTime.Unix(), ctx.BlockTime().Unix()+2400) +} diff --git a/x/gov/keeper/util.go b/x/gov/keeper/util.go index 6df5ce29b..0556c949e 100644 --- a/x/gov/keeper/util.go +++ b/x/gov/keeper/util.go @@ -1,95 +1,95 @@ -package keeper - -import ( - "regexp" - - "github.com/KiraCore/sekai/x/gov/types" - sdk "github.com/cosmos/cosmos-sdk/types" -) - -// CheckIfAllowedPermission -func CheckIfAllowedPermission(ctx sdk.Context, keeper Keeper, addr sdk.AccAddress, permValue types.PermValue) bool { - actor, found := keeper.GetNetworkActorByAddress(ctx, addr) - if !found { - return false - } - - // Get All Roles for actor - roles := getRolePermissions(ctx, keeper, actor) - - permMap := map[uint32]bool{} - - // Add whitelist perms into list - // First roles - for _, rolePerm := range roles { - for _, rp := range rolePerm.Whitelist { - permMap[rp] = true - } - } - - // Second individual roles - for _, ap := range actor.Permissions.Whitelist { - permMap[ap] = true - } - - // Remove All Blacklisted perms - for _, rolePerm := range roles { - for _, rp := range rolePerm.Blacklist { - permMap[rp] = false - } - } - - // Remove personal Permissions - for _, pp := range actor.Permissions.Blacklist { - permMap[pp] = false - } - - isAllowed, ok := permMap[uint32(permValue)] - if !ok { - return false - } - - return isAllowed -} - -func getRolePermissions(ctx sdk.Context, keeper Keeper, actor types.NetworkActor) map[uint64]*types.Permissions { - roles := map[uint64]*types.Permissions{} - for _, role := range actor.Roles { - rolePerms, found := keeper.GetPermissionsForRole(ctx, role) - if found { - roles[role] = &rolePerms - } - } - - return roles -} - -// ProposalIDToBytes returns the byte representation of the proposalID -func ProposalIDToBytes(proposalID uint64) []byte { - proposalIDBz := sdk.Uint64ToBigEndian(proposalID) - return proposalIDBz -} - -// BytesToProposalID returns proposalID in uint64 format from a byte array -func BytesToProposalID(bz []byte) uint64 { - return sdk.BigEndianToUint64(bz) -} - -func BoolToInt(v bool) uint64 { - if v { - return 1 - } - return 0 -} - -func IntToBool(v uint64) bool { - if v != 0 { - return true - } - return false -} - -func ValidateRoleSidKey(key string) bool { - regex := regexp.MustCompile(`^[a-zA-Z][_0-9a-zA-Z]*$`) - return regex.MatchString(key) -} +package keeper + +import ( + "regexp" + + "github.com/KiraCore/sekai/x/gov/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// CheckIfAllowedPermission +func CheckIfAllowedPermission(ctx sdk.Context, keeper Keeper, addr sdk.AccAddress, permValue types.PermValue) bool { + actor, found := keeper.GetNetworkActorByAddress(ctx, addr) + if !found { + return false + } + + // Get All Roles for actor + roles := getRolePermissions(ctx, keeper, actor) + + permMap := map[uint32]bool{} + + // Add whitelist perms into list + // First roles + for _, rolePerm := range roles { + for _, rp := range rolePerm.Whitelist { + permMap[rp] = true + } + } + + // Second individual roles + for _, ap := range actor.Permissions.Whitelist { + permMap[ap] = true + } + + // Remove All Blacklisted perms + for _, rolePerm := range roles { + for _, rp := range rolePerm.Blacklist { + permMap[rp] = false + } + } + + // Remove personal Permissions + for _, pp := range actor.Permissions.Blacklist { + permMap[pp] = false + } + + isAllowed, ok := permMap[uint32(permValue)] + if !ok { + return false + } + + return isAllowed +} + +func getRolePermissions(ctx sdk.Context, keeper Keeper, actor types.NetworkActor) map[uint64]*types.Permissions { + roles := map[uint64]*types.Permissions{} + for _, role := range actor.Roles { + rolePerms, found := keeper.GetPermissionsForRole(ctx, role) + if found { + roles[role] = &rolePerms + } + } + + return roles +} + +// ProposalIDToBytes returns the byte representation of the proposalID +func ProposalIDToBytes(proposalID uint64) []byte { + proposalIDBz := sdk.Uint64ToBigEndian(proposalID) + return proposalIDBz +} + +// BytesToProposalID returns proposalID in uint64 format from a byte array +func BytesToProposalID(bz []byte) uint64 { + return sdk.BigEndianToUint64(bz) +} + +func BoolToInt(v bool) uint64 { + if v { + return 1 + } + return 0 +} + +func IntToBool(v uint64) bool { + if v != 0 { + return true + } + return false +} + +func ValidateRoleSidKey(key string) bool { + regex := regexp.MustCompile(`^[a-zA-Z][_0-9a-zA-Z]*$`) + return regex.MatchString(key) +} diff --git a/x/gov/keeper/util_test.go b/x/gov/keeper/util_test.go index a063ea8a9..8656bbd0d 100644 --- a/x/gov/keeper/util_test.go +++ b/x/gov/keeper/util_test.go @@ -1,112 +1,112 @@ -package keeper_test - -import ( - "os" - "testing" - - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/require" - tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - - "github.com/KiraCore/sekai/app" - simapp "github.com/KiraCore/sekai/app" - "github.com/KiraCore/sekai/x/gov/keeper" - "github.com/KiraCore/sekai/x/gov/types" -) - -func TestMain(m *testing.M) { - app.SetConfig() - os.Exit(m.Run()) -} - -func TestCheckIfAllowedPermission(t *testing.T) { - addr, err := sdk.AccAddressFromBech32("kira15ky9du8a2wlstz6fpx3p4mqpjyrm5cgqzp4f3d") - require.NoError(t, err) - - tests := []struct { - name string - prepareScenario func(ctx sdk.Context, keeper keeper.Keeper) - isAllowed bool - }{ - { - name: "actor not present", - prepareScenario: func(ctx sdk.Context, keeper keeper.Keeper) { - return - }, - isAllowed: false, - }, - { - name: "actor has permission individually blacklisted", - prepareScenario: func(ctx sdk.Context, keeper keeper.Keeper) { - actor := types.NewDefaultActor(addr) - require.NoError(t, actor.Permissions.AddToBlacklist(types.PermClaimValidator)) - keeper.SaveNetworkActor(ctx, actor) - }, - isAllowed: false, - }, - { - name: "actor has permission blacklisted in role", - prepareScenario: func(ctx sdk.Context, keeper keeper.Keeper) { - roleWithBlacklistedValue := uint64(123) - keeper.SetRole(ctx, types.Role{ - Id: uint32(roleWithBlacklistedValue), - Sid: "123", - Description: "123", - }) - err2 := keeper.BlacklistRolePermission(ctx, roleWithBlacklistedValue, types.PermClaimValidator) - require.NoError(t, err2) - - actor := types.NewDefaultActor(addr) - keeper.AssignRoleToActor(ctx, actor, roleWithBlacklistedValue) - }, - isAllowed: false, - }, - { - name: "actor has permission whitelisted in role", - prepareScenario: func(ctx sdk.Context, keeper keeper.Keeper) { - roleWithWhitelistedValue := uint64(123) - keeper.SetRole(ctx, types.Role{ - Id: uint32(roleWithWhitelistedValue), - Sid: "123", - Description: "123", - }) - - err2 := keeper.WhitelistRolePermission(ctx, roleWithWhitelistedValue, types.PermClaimValidator) - require.NoError(t, err2) - - actor := types.NewDefaultActor(addr) - keeper.AssignRoleToActor(ctx, actor, roleWithWhitelistedValue) - }, - isAllowed: true, - }, - { - name: "actor has permission whitelisted individually", - prepareScenario: func(ctx sdk.Context, keeper keeper.Keeper) { - actor := types.NewDefaultActor(addr) - require.NoError(t, keeper.AddWhitelistPermission(ctx, actor, types.PermClaimValidator)) - }, - isAllowed: true, - }, - { - name: "actor not whitelisted or blacklisted", - prepareScenario: func(ctx sdk.Context, keeper keeper.Keeper) { - actor := types.NewDefaultActor(addr) - keeper.SaveNetworkActor(ctx, actor) - }, - isAllowed: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - app := simapp.Setup(false) - ctx := app.NewContext(false, tmproto.Header{}) - - tt.prepareScenario(ctx, app.CustomGovKeeper) - - allowed := keeper.CheckIfAllowedPermission(ctx, app.CustomGovKeeper, addr, types.PermClaimValidator) - require.Equal(t, tt.isAllowed, allowed) - }) - } -} +package keeper_test + +import ( + "os" + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + + "github.com/KiraCore/sekai/app" + simapp "github.com/KiraCore/sekai/app" + "github.com/KiraCore/sekai/x/gov/keeper" + "github.com/KiraCore/sekai/x/gov/types" +) + +func TestMain(m *testing.M) { + app.SetConfig() + os.Exit(m.Run()) +} + +func TestCheckIfAllowedPermission(t *testing.T) { + addr, err := sdk.AccAddressFromBech32("kira15ky9du8a2wlstz6fpx3p4mqpjyrm5cgqzp4f3d") + require.NoError(t, err) + + tests := []struct { + name string + prepareScenario func(ctx sdk.Context, keeper keeper.Keeper) + isAllowed bool + }{ + { + name: "actor not present", + prepareScenario: func(ctx sdk.Context, keeper keeper.Keeper) { + return + }, + isAllowed: false, + }, + { + name: "actor has permission individually blacklisted", + prepareScenario: func(ctx sdk.Context, keeper keeper.Keeper) { + actor := types.NewDefaultActor(addr) + require.NoError(t, actor.Permissions.AddToBlacklist(types.PermClaimValidator)) + keeper.SaveNetworkActor(ctx, actor) + }, + isAllowed: false, + }, + { + name: "actor has permission blacklisted in role", + prepareScenario: func(ctx sdk.Context, keeper keeper.Keeper) { + roleWithBlacklistedValue := uint64(123) + keeper.SetRole(ctx, types.Role{ + Id: uint32(roleWithBlacklistedValue), + Sid: "123", + Description: "123", + }) + err2 := keeper.BlacklistRolePermission(ctx, roleWithBlacklistedValue, types.PermClaimValidator) + require.NoError(t, err2) + + actor := types.NewDefaultActor(addr) + keeper.AssignRoleToActor(ctx, actor, roleWithBlacklistedValue) + }, + isAllowed: false, + }, + { + name: "actor has permission whitelisted in role", + prepareScenario: func(ctx sdk.Context, keeper keeper.Keeper) { + roleWithWhitelistedValue := uint64(123) + keeper.SetRole(ctx, types.Role{ + Id: uint32(roleWithWhitelistedValue), + Sid: "123", + Description: "123", + }) + + err2 := keeper.WhitelistRolePermission(ctx, roleWithWhitelistedValue, types.PermClaimValidator) + require.NoError(t, err2) + + actor := types.NewDefaultActor(addr) + keeper.AssignRoleToActor(ctx, actor, roleWithWhitelistedValue) + }, + isAllowed: true, + }, + { + name: "actor has permission whitelisted individually", + prepareScenario: func(ctx sdk.Context, keeper keeper.Keeper) { + actor := types.NewDefaultActor(addr) + require.NoError(t, keeper.AddWhitelistPermission(ctx, actor, types.PermClaimValidator)) + }, + isAllowed: true, + }, + { + name: "actor not whitelisted or blacklisted", + prepareScenario: func(ctx sdk.Context, keeper keeper.Keeper) { + actor := types.NewDefaultActor(addr) + keeper.SaveNetworkActor(ctx, actor) + }, + isAllowed: false, + }, + } + + for _, tt := range tests { + tt := tt + t.Run(tt.name, func(t *testing.T) { + app := simapp.Setup(false) + ctx := app.NewContext(false, tmproto.Header{}) + + tt.prepareScenario(ctx, app.CustomGovKeeper) + + allowed := keeper.CheckIfAllowedPermission(ctx, app.CustomGovKeeper, addr, types.PermClaimValidator) + require.Equal(t, tt.isAllowed, allowed) + }) + } +} diff --git a/x/gov/legacy/v01228/genesis.pb.go b/x/gov/legacy/v01228/genesis.pb.go index 5fd4e57bc..141629523 100644 --- a/x/gov/legacy/v01228/genesis.pb.go +++ b/x/gov/legacy/v01228/genesis.pb.go @@ -1,1234 +1,1234 @@ -package types - -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: kira/gov/genesis.proto - -import ( - fmt "fmt" - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/gogo/protobuf/proto" - io "io" - math "math" - math_bits "math/bits" - - govtypes "github.com/KiraCore/sekai/x/gov/types" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -type GenesisStateV01228 struct { - // starting_proposal_id is the ID of the starting proposal. - StartingProposalId uint64 `protobuf:"varint,1,opt,name=starting_proposal_id,json=startingProposalId,proto3" json:"starting_proposal_id,omitempty"` - // permissions is the roles that are active from genesis. - Permissions map[uint64]*govtypes.Permissions `protobuf:"bytes,2,rep,name=permissions,proto3" json:"permissions,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - // NetworkActors are the actors that are saved from genesis. - NetworkActors []*govtypes.NetworkActor `protobuf:"bytes,3,rep,name=network_actors,json=networkActors,proto3" json:"network_actors,omitempty"` - NetworkProperties *NetworkPropertiesV0228 `protobuf:"bytes,4,opt,name=network_properties,json=networkProperties,proto3" json:"network_properties,omitempty"` - ExecutionFees []govtypes.ExecutionFee `protobuf:"bytes,5,rep,name=execution_fees,json=executionFees,proto3" json:"execution_fees,omitempty"` - PoorNetworkMessages *govtypes.AllowedMessages `protobuf:"bytes,6,opt,name=poor_network_messages,json=poorNetworkMessages,proto3" json:"poor_network_messages,omitempty"` - Proposals []govtypes.Proposal `protobuf:"bytes,7,rep,name=proposals,proto3" json:"proposals"` - Votes []govtypes.Vote `protobuf:"bytes,8,rep,name=votes,proto3" json:"votes"` - DataRegistry map[string]*govtypes.DataRegistryEntry `protobuf:"bytes,9,rep,name=data_registry,json=dataRegistry,proto3" json:"data_registry,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - IdentityRecords []govtypes.IdentityRecord `protobuf:"bytes,10,rep,name=identity_records,json=identityRecords,proto3" json:"identity_records"` - LastIdentityRecordId uint64 `protobuf:"varint,11,opt,name=last_identity_record_id,json=lastIdentityRecordId,proto3" json:"last_identity_record_id,omitempty"` - IdRecordsVerifyRequests []govtypes.IdentityRecordsVerify `protobuf:"bytes,12,rep,name=id_records_verify_requests,json=idRecordsVerifyRequests,proto3" json:"id_records_verify_requests"` - LastIdRecordVerifyRequestId uint64 `protobuf:"varint,13,opt,name=last_id_record_verify_request_id,json=lastIdRecordVerifyRequestId,proto3" json:"last_id_record_verify_request_id,omitempty"` -} - -func (m *GenesisStateV01228) Reset() { *m = GenesisStateV01228{} } -func (m *GenesisStateV01228) String() string { return proto.CompactTextString(m) } -func (*GenesisStateV01228) ProtoMessage() {} -func (*GenesisStateV01228) Descriptor() ([]byte, []int) { - return fileDescriptor_042721fb65a4ea2d, []int{0} -} -func (m *GenesisStateV01228) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *GenesisStateV01228) 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 *GenesisStateV01228) XXX_Merge(src proto.Message) { - xxx_messageInfo_GenesisState.Merge(m, src) -} -func (m *GenesisStateV01228) XXX_Size() int { - return m.Size() -} -func (m *GenesisStateV01228) XXX_DiscardUnknown() { - xxx_messageInfo_GenesisState.DiscardUnknown(m) -} - -var xxx_messageInfo_GenesisState proto.InternalMessageInfo - -func (m *GenesisStateV01228) GetStartingProposalId() uint64 { - if m != nil { - return m.StartingProposalId - } - return 0 -} - -func (m *GenesisStateV01228) GetPermissions() map[uint64]*govtypes.Permissions { - if m != nil { - return m.Permissions - } - return nil -} - -func (m *GenesisStateV01228) GetNetworkActors() []*govtypes.NetworkActor { - if m != nil { - return m.NetworkActors - } - return nil -} - -func (m *GenesisStateV01228) GetNetworkProperties() *NetworkPropertiesV0228 { - if m != nil { - return m.NetworkProperties - } - return nil -} - -func (m *GenesisStateV01228) GetExecutionFees() []govtypes.ExecutionFee { - if m != nil { - return m.ExecutionFees - } - return nil -} - -func (m *GenesisStateV01228) GetPoorNetworkMessages() *govtypes.AllowedMessages { - if m != nil { - return m.PoorNetworkMessages - } - return nil -} - -func (m *GenesisStateV01228) GetProposals() []govtypes.Proposal { - if m != nil { - return m.Proposals - } - return nil -} - -func (m *GenesisStateV01228) GetVotes() []govtypes.Vote { - if m != nil { - return m.Votes - } - return nil -} - -func (m *GenesisStateV01228) GetDataRegistry() map[string]*govtypes.DataRegistryEntry { - if m != nil { - return m.DataRegistry - } - return nil -} - -func (m *GenesisStateV01228) GetIdentityRecords() []govtypes.IdentityRecord { - if m != nil { - return m.IdentityRecords - } - return nil -} - -func (m *GenesisStateV01228) GetLastIdentityRecordId() uint64 { - if m != nil { - return m.LastIdentityRecordId - } - return 0 -} - -func (m *GenesisStateV01228) GetIdRecordsVerifyRequests() []govtypes.IdentityRecordsVerify { - if m != nil { - return m.IdRecordsVerifyRequests - } - return nil -} - -func (m *GenesisStateV01228) GetLastIdRecordVerifyRequestId() uint64 { - if m != nil { - return m.LastIdRecordVerifyRequestId - } - return 0 -} - -func init() { - proto.RegisterType((*GenesisStateV01228)(nil), "kira.gov.GenesisStateV01228") -} - -func init() { proto.RegisterFile("kira/gov/genesis.proto", fileDescriptor_042721fb65a4ea2d) } - -var fileDescriptor_042721fb65a4ea2d = []byte{ - // 666 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x54, 0x5d, 0x4f, 0x13, 0x41, - 0x14, 0xed, 0xf2, 0x25, 0x4c, 0x29, 0xc2, 0x50, 0x60, 0x2c, 0xa6, 0x54, 0x13, 0x63, 0xa3, 0x49, - 0xab, 0x18, 0x8d, 0x31, 0x31, 0x06, 0x14, 0x4d, 0x35, 0x18, 0xb2, 0x46, 0x1e, 0x8c, 0xc9, 0x66, - 0xe8, 0x5e, 0xd6, 0x49, 0xcb, 0xce, 0x3a, 0x33, 0x2d, 0xf4, 0x5f, 0xf8, 0x77, 0xfc, 0x07, 0x3c, - 0xf2, 0xe8, 0x93, 0x31, 0xf4, 0x8f, 0x98, 0x9d, 0x9d, 0xd9, 0x8f, 0x36, 0xbc, 0xed, 0x9e, 0x73, - 0xee, 0xd9, 0x33, 0xf7, 0xde, 0x59, 0xb4, 0xd9, 0x63, 0x82, 0xb6, 0x03, 0x3e, 0x6c, 0x07, 0x10, - 0x82, 0x64, 0xb2, 0x15, 0x09, 0xae, 0x38, 0x5e, 0x8c, 0xf1, 0x56, 0xc0, 0x87, 0xb5, 0x6a, 0xc0, - 0x03, 0xae, 0xc1, 0x76, 0xfc, 0x94, 0xf0, 0xb5, 0x6a, 0x5a, 0x47, 0xbb, 0x8a, 0x0b, 0x83, 0xae, - 0xa7, 0xa8, 0xe0, 0x7d, 0x30, 0xe0, 0x56, 0x0a, 0x46, 0x82, 0x47, 0x5c, 0xd2, 0xbe, 0x21, 0xee, - 0xa6, 0x84, 0x4f, 0x15, 0xf5, 0x04, 0x04, 0x4c, 0x2a, 0x31, 0x9a, 0x62, 0xe1, 0x02, 0xba, 0x03, - 0xc5, 0x78, 0xe8, 0x9d, 0x82, 0x35, 0xbd, 0x97, 0xb2, 0x21,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0x7d, 0x45, 0xab, 0x93, 0x37, 0x03, 0xaf, 0xa2, 0xd9, - 0x1e, 0x8c, 0xcc, 0xc5, 0x8b, 0x1f, 0xf1, 0x63, 0x34, 0x3f, 0xa4, 0xfd, 0x01, 0x90, 0x19, 0xbd, - 0x44, 0x1b, 0xb9, 0x0d, 0xc8, 0x8a, 0xdd, 0x44, 0xf3, 0x6a, 0xe6, 0xa5, 0x53, 0xfb, 0x8e, 0xd6, - 0xa6, 0xc6, 0x94, 0xf7, 0x5d, 0x4a, 0x7c, 0x9f, 0x16, 0x7d, 0x73, 0x57, 0x65, 0x7a, 0xc8, 0x99, - 0xfb, 0xfe, 0x9b, 0xcb, 0xeb, 0xba, 0x73, 0x75, 0x5d, 0x77, 0xfe, 0x5d, 0xd7, 0x9d, 0x5f, 0xe3, - 0x7a, 0xe9, 0x6a, 0x5c, 0x2f, 0xfd, 0x19, 0xd7, 0x4b, 0xdf, 0x1e, 0x04, 0x4c, 0xfd, 0x18, 0x9c, - 0xb4, 0xba, 0xfc, 0xac, 0xfd, 0x89, 0x09, 0xfa, 0x96, 0x0b, 0x68, 0x4b, 0xe8, 0x51, 0xd6, 0xbe, - 0xd0, 0xff, 0x23, 0x35, 0x8a, 0x40, 0x9e, 0x2c, 0xe8, 0x7f, 0xd0, 0xb3, 0xff, 0x01, 0x00, 0x00, - 0xff, 0xff, 0x03, 0x6d, 0xd7, 0x16, 0xa4, 0x05, 0x00, 0x00, -} - -func (m *GenesisStateV01228) 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 *GenesisStateV01228) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *GenesisStateV01228) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.LastIdRecordVerifyRequestId != 0 { - i = encodeVarintGenesis(dAtA, i, uint64(m.LastIdRecordVerifyRequestId)) - i-- - dAtA[i] = 0x68 - } - if len(m.IdRecordsVerifyRequests) > 0 { - for iNdEx := len(m.IdRecordsVerifyRequests) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.IdRecordsVerifyRequests[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x62 - } - } - if m.LastIdentityRecordId != 0 { - i = encodeVarintGenesis(dAtA, i, uint64(m.LastIdentityRecordId)) - i-- - dAtA[i] = 0x58 - } - if len(m.IdentityRecords) > 0 { - for iNdEx := len(m.IdentityRecords) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.IdentityRecords[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x52 - } - } - if len(m.DataRegistry) > 0 { - for k := range m.DataRegistry { - v := m.DataRegistry[k] - baseI := i - if v != nil { - { - size, err := v.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - i -= len(k) - copy(dAtA[i:], k) - i = encodeVarintGenesis(dAtA, i, uint64(len(k))) - i-- - dAtA[i] = 0xa - i = encodeVarintGenesis(dAtA, i, uint64(baseI-i)) - i-- - dAtA[i] = 0x4a - } - } - if len(m.Votes) > 0 { - for iNdEx := len(m.Votes) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Votes[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x42 - } - } - if len(m.Proposals) > 0 { - for iNdEx := len(m.Proposals) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Proposals[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x3a - } - } - if m.PoorNetworkMessages != nil { - { - size, err := m.PoorNetworkMessages.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x32 - } - if len(m.ExecutionFees) > 0 { - for iNdEx := len(m.ExecutionFees) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.ExecutionFees[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x2a - } - } - if m.NetworkProperties != nil { - { - size, err := m.NetworkProperties.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - } - if len(m.NetworkActors) > 0 { - for iNdEx := len(m.NetworkActors) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.NetworkActors[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - } - } - if len(m.Permissions) > 0 { - for k := range m.Permissions { - v := m.Permissions[k] - baseI := i - if v != nil { - { - size, err := v.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - i = encodeVarintGenesis(dAtA, i, uint64(k)) - i-- - dAtA[i] = 0x8 - i = encodeVarintGenesis(dAtA, i, uint64(baseI-i)) - i-- - dAtA[i] = 0x12 - } - } - if m.StartingProposalId != 0 { - i = encodeVarintGenesis(dAtA, i, uint64(m.StartingProposalId)) - i-- - dAtA[i] = 0x8 - } - 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 *GenesisStateV01228) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.StartingProposalId != 0 { - n += 1 + sovGenesis(uint64(m.StartingProposalId)) - } - if len(m.Permissions) > 0 { - for k, v := range m.Permissions { - _ = k - _ = v - l = 0 - if v != nil { - l = v.Size() - l += 1 + sovGenesis(uint64(l)) - } - mapEntrySize := 1 + sovGenesis(uint64(k)) + l - n += mapEntrySize + 1 + sovGenesis(uint64(mapEntrySize)) - } - } - if len(m.NetworkActors) > 0 { - for _, e := range m.NetworkActors { - l = e.Size() - n += 1 + l + sovGenesis(uint64(l)) - } - } - if m.NetworkProperties != nil { - l = m.NetworkProperties.Size() - n += 1 + l + sovGenesis(uint64(l)) - } - if len(m.ExecutionFees) > 0 { - for _, e := range m.ExecutionFees { - l = e.Size() - n += 1 + l + sovGenesis(uint64(l)) - } - } - if m.PoorNetworkMessages != nil { - l = m.PoorNetworkMessages.Size() - n += 1 + l + sovGenesis(uint64(l)) - } - if len(m.Proposals) > 0 { - for _, e := range m.Proposals { - l = e.Size() - n += 1 + l + sovGenesis(uint64(l)) - } - } - if len(m.Votes) > 0 { - for _, e := range m.Votes { - l = e.Size() - n += 1 + l + sovGenesis(uint64(l)) - } - } - if len(m.DataRegistry) > 0 { - for k, v := range m.DataRegistry { - _ = k - _ = v - l = 0 - if v != nil { - l = v.Size() - l += 1 + sovGenesis(uint64(l)) - } - mapEntrySize := 1 + len(k) + sovGenesis(uint64(len(k))) + l - n += mapEntrySize + 1 + sovGenesis(uint64(mapEntrySize)) - } - } - if len(m.IdentityRecords) > 0 { - for _, e := range m.IdentityRecords { - l = e.Size() - n += 1 + l + sovGenesis(uint64(l)) - } - } - if m.LastIdentityRecordId != 0 { - n += 1 + sovGenesis(uint64(m.LastIdentityRecordId)) - } - if len(m.IdRecordsVerifyRequests) > 0 { - for _, e := range m.IdRecordsVerifyRequests { - l = e.Size() - n += 1 + l + sovGenesis(uint64(l)) - } - } - if m.LastIdRecordVerifyRequestId != 0 { - n += 1 + sovGenesis(uint64(m.LastIdRecordVerifyRequestId)) - } - 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 *GenesisStateV01228) 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 != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field StartingProposalId", wireType) - } - m.StartingProposalId = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.StartingProposalId |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Permissions", 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.Permissions == nil { - m.Permissions = make(map[uint64]*govtypes.Permissions) - } - var mapkey uint64 - var mapvalue *govtypes.Permissions - for iNdEx < postIndex { - entryPreIndex := 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) - if fieldNum == 1 { - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - mapkey |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - } else if fieldNum == 2 { - var mapmsglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - mapmsglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if mapmsglen < 0 { - return ErrInvalidLengthGenesis - } - postmsgIndex := iNdEx + mapmsglen - if postmsgIndex < 0 { - return ErrInvalidLengthGenesis - } - if postmsgIndex > l { - return io.ErrUnexpectedEOF - } - mapvalue = &govtypes.Permissions{} - if err := mapvalue.Unmarshal(dAtA[iNdEx:postmsgIndex]); err != nil { - return err - } - iNdEx = postmsgIndex - } else { - iNdEx = entryPreIndex - skippy, err := skipGenesis(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthGenesis - } - if (iNdEx + skippy) > postIndex { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - m.Permissions[mapkey] = mapvalue - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field NetworkActors", 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.NetworkActors = append(m.NetworkActors, &govtypes.NetworkActor{}) - if err := m.NetworkActors[len(m.NetworkActors)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field NetworkProperties", 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.NetworkProperties == nil { - m.NetworkProperties = &NetworkPropertiesV0228{} - } - if err := m.NetworkProperties.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ExecutionFees", 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.ExecutionFees = append(m.ExecutionFees, govtypes.ExecutionFee{}) - if err := m.ExecutionFees[len(m.ExecutionFees)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 6: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PoorNetworkMessages", 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.PoorNetworkMessages == nil { - m.PoorNetworkMessages = &govtypes.AllowedMessages{} - } - if err := m.PoorNetworkMessages.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 7: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Proposals", 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.Proposals = append(m.Proposals, govtypes.Proposal{}) - if err := m.Proposals[len(m.Proposals)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 8: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Votes", 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.Votes = append(m.Votes, govtypes.Vote{}) - if err := m.Votes[len(m.Votes)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 9: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DataRegistry", 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.DataRegistry == nil { - m.DataRegistry = make(map[string]*govtypes.DataRegistryEntry) - } - var mapkey string - var mapvalue *govtypes.DataRegistryEntry - for iNdEx < postIndex { - entryPreIndex := 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) - if fieldNum == 1 { - var stringLenmapkey uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLenmapkey |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLenmapkey := int(stringLenmapkey) - if intStringLenmapkey < 0 { - return ErrInvalidLengthGenesis - } - postStringIndexmapkey := iNdEx + intStringLenmapkey - if postStringIndexmapkey < 0 { - return ErrInvalidLengthGenesis - } - if postStringIndexmapkey > l { - return io.ErrUnexpectedEOF - } - mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) - iNdEx = postStringIndexmapkey - } else if fieldNum == 2 { - var mapmsglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - mapmsglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if mapmsglen < 0 { - return ErrInvalidLengthGenesis - } - postmsgIndex := iNdEx + mapmsglen - if postmsgIndex < 0 { - return ErrInvalidLengthGenesis - } - if postmsgIndex > l { - return io.ErrUnexpectedEOF - } - mapvalue = &govtypes.DataRegistryEntry{} - if err := mapvalue.Unmarshal(dAtA[iNdEx:postmsgIndex]); err != nil { - return err - } - iNdEx = postmsgIndex - } else { - iNdEx = entryPreIndex - skippy, err := skipGenesis(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthGenesis - } - if (iNdEx + skippy) > postIndex { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - m.DataRegistry[mapkey] = mapvalue - iNdEx = postIndex - case 10: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field IdentityRecords", 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.IdentityRecords = append(m.IdentityRecords, govtypes.IdentityRecord{}) - if err := m.IdentityRecords[len(m.IdentityRecords)-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 LastIdentityRecordId", wireType) - } - m.LastIdentityRecordId = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.LastIdentityRecordId |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 12: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field IdRecordsVerifyRequests", 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.IdRecordsVerifyRequests = append(m.IdRecordsVerifyRequests, govtypes.IdentityRecordsVerify{}) - if err := m.IdRecordsVerifyRequests[len(m.IdRecordsVerifyRequests)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 13: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field LastIdRecordVerifyRequestId", wireType) - } - m.LastIdRecordVerifyRequestId = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.LastIdRecordVerifyRequestId |= 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 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") -) +package types + +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: kira/gov/genesis.proto + +import ( + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" + + govtypes "github.com/KiraCore/sekai/x/gov/types" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type GenesisStateV01228 struct { + // starting_proposal_id is the ID of the starting proposal. + StartingProposalId uint64 `protobuf:"varint,1,opt,name=starting_proposal_id,json=startingProposalId,proto3" json:"starting_proposal_id,omitempty"` + // permissions is the roles that are active from genesis. + Permissions map[uint64]*govtypes.Permissions `protobuf:"bytes,2,rep,name=permissions,proto3" json:"permissions,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + // NetworkActors are the actors that are saved from genesis. + NetworkActors []*govtypes.NetworkActor `protobuf:"bytes,3,rep,name=network_actors,json=networkActors,proto3" json:"network_actors,omitempty"` + NetworkProperties *NetworkPropertiesV0228 `protobuf:"bytes,4,opt,name=network_properties,json=networkProperties,proto3" json:"network_properties,omitempty"` + ExecutionFees []govtypes.ExecutionFee `protobuf:"bytes,5,rep,name=execution_fees,json=executionFees,proto3" json:"execution_fees,omitempty"` + PoorNetworkMessages *govtypes.AllowedMessages `protobuf:"bytes,6,opt,name=poor_network_messages,json=poorNetworkMessages,proto3" json:"poor_network_messages,omitempty"` + Proposals []govtypes.Proposal `protobuf:"bytes,7,rep,name=proposals,proto3" json:"proposals"` + Votes []govtypes.Vote `protobuf:"bytes,8,rep,name=votes,proto3" json:"votes"` + DataRegistry map[string]*govtypes.DataRegistryEntry `protobuf:"bytes,9,rep,name=data_registry,json=dataRegistry,proto3" json:"data_registry,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + IdentityRecords []govtypes.IdentityRecord `protobuf:"bytes,10,rep,name=identity_records,json=identityRecords,proto3" json:"identity_records"` + LastIdentityRecordId uint64 `protobuf:"varint,11,opt,name=last_identity_record_id,json=lastIdentityRecordId,proto3" json:"last_identity_record_id,omitempty"` + IdRecordsVerifyRequests []govtypes.IdentityRecordsVerify `protobuf:"bytes,12,rep,name=id_records_verify_requests,json=idRecordsVerifyRequests,proto3" json:"id_records_verify_requests"` + LastIdRecordVerifyRequestId uint64 `protobuf:"varint,13,opt,name=last_id_record_verify_request_id,json=lastIdRecordVerifyRequestId,proto3" json:"last_id_record_verify_request_id,omitempty"` +} + +func (m *GenesisStateV01228) Reset() { *m = GenesisStateV01228{} } +func (m *GenesisStateV01228) String() string { return proto.CompactTextString(m) } +func (*GenesisStateV01228) ProtoMessage() {} +func (*GenesisStateV01228) Descriptor() ([]byte, []int) { + return fileDescriptor_042721fb65a4ea2d, []int{0} +} +func (m *GenesisStateV01228) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GenesisStateV01228) 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 *GenesisStateV01228) XXX_Merge(src proto.Message) { + xxx_messageInfo_GenesisState.Merge(m, src) +} +func (m *GenesisStateV01228) XXX_Size() int { + return m.Size() +} +func (m *GenesisStateV01228) XXX_DiscardUnknown() { + xxx_messageInfo_GenesisState.DiscardUnknown(m) +} + +var xxx_messageInfo_GenesisState proto.InternalMessageInfo + +func (m *GenesisStateV01228) GetStartingProposalId() uint64 { + if m != nil { + return m.StartingProposalId + } + return 0 +} + +func (m *GenesisStateV01228) GetPermissions() map[uint64]*govtypes.Permissions { + if m != nil { + return m.Permissions + } + return nil +} + +func (m *GenesisStateV01228) GetNetworkActors() []*govtypes.NetworkActor { + if m != nil { + return m.NetworkActors + } + return nil +} + +func (m *GenesisStateV01228) GetNetworkProperties() *NetworkPropertiesV0228 { + if m != nil { + return m.NetworkProperties + } + return nil +} + +func (m *GenesisStateV01228) GetExecutionFees() []govtypes.ExecutionFee { + if m != nil { + return m.ExecutionFees + } + return nil +} + +func (m *GenesisStateV01228) GetPoorNetworkMessages() *govtypes.AllowedMessages { + if m != nil { + return m.PoorNetworkMessages + } + return nil +} + +func (m *GenesisStateV01228) GetProposals() []govtypes.Proposal { + if m != nil { + return m.Proposals + } + return nil +} + +func (m *GenesisStateV01228) GetVotes() []govtypes.Vote { + if m != nil { + return m.Votes + } + return nil +} + +func (m *GenesisStateV01228) GetDataRegistry() map[string]*govtypes.DataRegistryEntry { + if m != nil { + return m.DataRegistry + } + return nil +} + +func (m *GenesisStateV01228) GetIdentityRecords() []govtypes.IdentityRecord { + if m != nil { + return m.IdentityRecords + } + return nil +} + +func (m *GenesisStateV01228) GetLastIdentityRecordId() uint64 { + if m != nil { + return m.LastIdentityRecordId + } + return 0 +} + +func (m *GenesisStateV01228) GetIdRecordsVerifyRequests() []govtypes.IdentityRecordsVerify { + if m != nil { + return m.IdRecordsVerifyRequests + } + return nil +} + +func (m *GenesisStateV01228) GetLastIdRecordVerifyRequestId() uint64 { + if m != nil { + return m.LastIdRecordVerifyRequestId + } + return 0 +} + +func init() { + proto.RegisterType((*GenesisStateV01228)(nil), "kira.gov.GenesisStateV01228") +} + +func init() { proto.RegisterFile("kira/gov/genesis.proto", fileDescriptor_042721fb65a4ea2d) } + +var fileDescriptor_042721fb65a4ea2d = []byte{ + // 666 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x54, 0x5d, 0x4f, 0x13, 0x41, + 0x14, 0xed, 0xf2, 0x25, 0x4c, 0x29, 0xc2, 0x50, 0x60, 0x2c, 0xa6, 0x54, 0x13, 0x63, 0xa3, 0x49, + 0xab, 0x18, 0x8d, 0x31, 0x31, 0x06, 0x14, 0x4d, 0x35, 0x18, 0xb2, 0x46, 0x1e, 0x8c, 0xc9, 0x66, + 0xe8, 0x5e, 0xd6, 0x49, 0xcb, 0xce, 0x3a, 0x33, 0x2d, 0xf4, 0x5f, 0xf8, 0x77, 0xfc, 0x07, 0x3c, + 0xf2, 0xe8, 0x93, 0x31, 0xf4, 0x8f, 0x98, 0x9d, 0x9d, 0xd9, 0x8f, 0x36, 0xbc, 0xed, 0x9e, 0x73, + 0xee, 0xd9, 0x33, 0xf7, 0xde, 0x59, 0xb4, 0xd9, 0x63, 0x82, 0xb6, 0x03, 0x3e, 0x6c, 0x07, 0x10, + 0x82, 0x64, 0xb2, 0x15, 0x09, 0xae, 0x38, 0x5e, 0x8c, 0xf1, 0x56, 0xc0, 0x87, 0xb5, 0x6a, 0xc0, + 0x03, 0xae, 0xc1, 0x76, 0xfc, 0x94, 0xf0, 0xb5, 0x6a, 0x5a, 0x47, 0xbb, 0x8a, 0x0b, 0x83, 0xae, + 0xa7, 0xa8, 0xe0, 0x7d, 0x30, 0xe0, 0x56, 0x0a, 0x46, 0x82, 0x47, 0x5c, 0xd2, 0xbe, 0x21, 0xee, + 0xa6, 0x84, 0x4f, 0x15, 0xf5, 0x04, 0x04, 0x4c, 0x2a, 0x31, 0x9a, 0x62, 0xe1, 0x02, 0xba, 0x03, + 0xc5, 0x78, 0xe8, 0x9d, 0x82, 0x35, 0xbd, 0x97, 0xb2, 0x21, 0xa8, 0x73, 0x2e, 0x7a, 0x5e, 0x6c, + 0x0e, 0x42, 0x31, 0x30, 0x47, 0xa8, 0xed, 0x64, 0x11, 0xfb, 0x7d, 0x7e, 0x0e, 0xbe, 0x77, 0x06, + 0x52, 0xd2, 0x20, 0x15, 0x64, 0x1e, 0xcc, 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, 0xc8, 0x8a, 0xdd, 0x44, 0xf3, 0x6a, 0xe6, 0xa5, 0x53, 0xfb, 0x8e, 0xd6, + 0xa6, 0xc6, 0x94, 0xf7, 0x5d, 0x4a, 0x7c, 0x9f, 0x16, 0x7d, 0x73, 0x57, 0x65, 0x7a, 0xc8, 0x99, + 0xfb, 0xfe, 0x9b, 0xcb, 0xeb, 0xba, 0x73, 0x75, 0x5d, 0x77, 0xfe, 0x5d, 0xd7, 0x9d, 0x5f, 0xe3, + 0x7a, 0xe9, 0x6a, 0x5c, 0x2f, 0xfd, 0x19, 0xd7, 0x4b, 0xdf, 0x1e, 0x04, 0x4c, 0xfd, 0x18, 0x9c, + 0xb4, 0xba, 0xfc, 0xac, 0xfd, 0x89, 0x09, 0xfa, 0x96, 0x0b, 0x68, 0x4b, 0xe8, 0x51, 0xd6, 0xbe, + 0xd0, 0xff, 0x23, 0x35, 0x8a, 0x40, 0x9e, 0x2c, 0xe8, 0x7f, 0xd0, 0xb3, 0xff, 0x01, 0x00, 0x00, + 0xff, 0xff, 0x03, 0x6d, 0xd7, 0x16, 0xa4, 0x05, 0x00, 0x00, +} + +func (m *GenesisStateV01228) 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 *GenesisStateV01228) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GenesisStateV01228) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.LastIdRecordVerifyRequestId != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.LastIdRecordVerifyRequestId)) + i-- + dAtA[i] = 0x68 + } + if len(m.IdRecordsVerifyRequests) > 0 { + for iNdEx := len(m.IdRecordsVerifyRequests) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.IdRecordsVerifyRequests[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x62 + } + } + if m.LastIdentityRecordId != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.LastIdentityRecordId)) + i-- + dAtA[i] = 0x58 + } + if len(m.IdentityRecords) > 0 { + for iNdEx := len(m.IdentityRecords) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.IdentityRecords[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x52 + } + } + if len(m.DataRegistry) > 0 { + for k := range m.DataRegistry { + v := m.DataRegistry[k] + baseI := i + if v != nil { + { + size, err := v.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + i -= len(k) + copy(dAtA[i:], k) + i = encodeVarintGenesis(dAtA, i, uint64(len(k))) + i-- + dAtA[i] = 0xa + i = encodeVarintGenesis(dAtA, i, uint64(baseI-i)) + i-- + dAtA[i] = 0x4a + } + } + if len(m.Votes) > 0 { + for iNdEx := len(m.Votes) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Votes[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x42 + } + } + if len(m.Proposals) > 0 { + for iNdEx := len(m.Proposals) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Proposals[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x3a + } + } + if m.PoorNetworkMessages != nil { + { + size, err := m.PoorNetworkMessages.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 + } + if len(m.ExecutionFees) > 0 { + for iNdEx := len(m.ExecutionFees) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.ExecutionFees[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + } + } + if m.NetworkProperties != nil { + { + size, err := m.NetworkProperties.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + if len(m.NetworkActors) > 0 { + for iNdEx := len(m.NetworkActors) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.NetworkActors[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + if len(m.Permissions) > 0 { + for k := range m.Permissions { + v := m.Permissions[k] + baseI := i + if v != nil { + { + size, err := v.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + i = encodeVarintGenesis(dAtA, i, uint64(k)) + i-- + dAtA[i] = 0x8 + i = encodeVarintGenesis(dAtA, i, uint64(baseI-i)) + i-- + dAtA[i] = 0x12 + } + } + if m.StartingProposalId != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.StartingProposalId)) + i-- + dAtA[i] = 0x8 + } + 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 *GenesisStateV01228) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.StartingProposalId != 0 { + n += 1 + sovGenesis(uint64(m.StartingProposalId)) + } + if len(m.Permissions) > 0 { + for k, v := range m.Permissions { + _ = k + _ = v + l = 0 + if v != nil { + l = v.Size() + l += 1 + sovGenesis(uint64(l)) + } + mapEntrySize := 1 + sovGenesis(uint64(k)) + l + n += mapEntrySize + 1 + sovGenesis(uint64(mapEntrySize)) + } + } + if len(m.NetworkActors) > 0 { + for _, e := range m.NetworkActors { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if m.NetworkProperties != nil { + l = m.NetworkProperties.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + if len(m.ExecutionFees) > 0 { + for _, e := range m.ExecutionFees { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if m.PoorNetworkMessages != nil { + l = m.PoorNetworkMessages.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + if len(m.Proposals) > 0 { + for _, e := range m.Proposals { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.Votes) > 0 { + for _, e := range m.Votes { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.DataRegistry) > 0 { + for k, v := range m.DataRegistry { + _ = k + _ = v + l = 0 + if v != nil { + l = v.Size() + l += 1 + sovGenesis(uint64(l)) + } + mapEntrySize := 1 + len(k) + sovGenesis(uint64(len(k))) + l + n += mapEntrySize + 1 + sovGenesis(uint64(mapEntrySize)) + } + } + if len(m.IdentityRecords) > 0 { + for _, e := range m.IdentityRecords { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if m.LastIdentityRecordId != 0 { + n += 1 + sovGenesis(uint64(m.LastIdentityRecordId)) + } + if len(m.IdRecordsVerifyRequests) > 0 { + for _, e := range m.IdRecordsVerifyRequests { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if m.LastIdRecordVerifyRequestId != 0 { + n += 1 + sovGenesis(uint64(m.LastIdRecordVerifyRequestId)) + } + 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 *GenesisStateV01228) 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 != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field StartingProposalId", wireType) + } + m.StartingProposalId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.StartingProposalId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Permissions", 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.Permissions == nil { + m.Permissions = make(map[uint64]*govtypes.Permissions) + } + var mapkey uint64 + var mapvalue *govtypes.Permissions + for iNdEx < postIndex { + entryPreIndex := 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) + if fieldNum == 1 { + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + mapkey |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + } else if fieldNum == 2 { + var mapmsglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + mapmsglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if mapmsglen < 0 { + return ErrInvalidLengthGenesis + } + postmsgIndex := iNdEx + mapmsglen + if postmsgIndex < 0 { + return ErrInvalidLengthGenesis + } + if postmsgIndex > l { + return io.ErrUnexpectedEOF + } + mapvalue = &govtypes.Permissions{} + if err := mapvalue.Unmarshal(dAtA[iNdEx:postmsgIndex]); err != nil { + return err + } + iNdEx = postmsgIndex + } else { + iNdEx = entryPreIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > postIndex { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + m.Permissions[mapkey] = mapvalue + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NetworkActors", 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.NetworkActors = append(m.NetworkActors, &govtypes.NetworkActor{}) + if err := m.NetworkActors[len(m.NetworkActors)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NetworkProperties", 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.NetworkProperties == nil { + m.NetworkProperties = &NetworkPropertiesV0228{} + } + if err := m.NetworkProperties.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ExecutionFees", 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.ExecutionFees = append(m.ExecutionFees, govtypes.ExecutionFee{}) + if err := m.ExecutionFees[len(m.ExecutionFees)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PoorNetworkMessages", 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.PoorNetworkMessages == nil { + m.PoorNetworkMessages = &govtypes.AllowedMessages{} + } + if err := m.PoorNetworkMessages.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Proposals", 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.Proposals = append(m.Proposals, govtypes.Proposal{}) + if err := m.Proposals[len(m.Proposals)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Votes", 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.Votes = append(m.Votes, govtypes.Vote{}) + if err := m.Votes[len(m.Votes)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 9: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DataRegistry", 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.DataRegistry == nil { + m.DataRegistry = make(map[string]*govtypes.DataRegistryEntry) + } + var mapkey string + var mapvalue *govtypes.DataRegistryEntry + for iNdEx < postIndex { + entryPreIndex := 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) + if fieldNum == 1 { + var stringLenmapkey uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapkey |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapkey := int(stringLenmapkey) + if intStringLenmapkey < 0 { + return ErrInvalidLengthGenesis + } + postStringIndexmapkey := iNdEx + intStringLenmapkey + if postStringIndexmapkey < 0 { + return ErrInvalidLengthGenesis + } + if postStringIndexmapkey > l { + return io.ErrUnexpectedEOF + } + mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) + iNdEx = postStringIndexmapkey + } else if fieldNum == 2 { + var mapmsglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + mapmsglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if mapmsglen < 0 { + return ErrInvalidLengthGenesis + } + postmsgIndex := iNdEx + mapmsglen + if postmsgIndex < 0 { + return ErrInvalidLengthGenesis + } + if postmsgIndex > l { + return io.ErrUnexpectedEOF + } + mapvalue = &govtypes.DataRegistryEntry{} + if err := mapvalue.Unmarshal(dAtA[iNdEx:postmsgIndex]); err != nil { + return err + } + iNdEx = postmsgIndex + } else { + iNdEx = entryPreIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > postIndex { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + m.DataRegistry[mapkey] = mapvalue + iNdEx = postIndex + case 10: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field IdentityRecords", 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.IdentityRecords = append(m.IdentityRecords, govtypes.IdentityRecord{}) + if err := m.IdentityRecords[len(m.IdentityRecords)-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 LastIdentityRecordId", wireType) + } + m.LastIdentityRecordId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.LastIdentityRecordId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 12: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field IdRecordsVerifyRequests", 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.IdRecordsVerifyRequests = append(m.IdRecordsVerifyRequests, govtypes.IdentityRecordsVerify{}) + if err := m.IdRecordsVerifyRequests[len(m.IdRecordsVerifyRequests)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 13: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field LastIdRecordVerifyRequestId", wireType) + } + m.LastIdRecordVerifyRequestId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.LastIdRecordVerifyRequestId |= 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 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/gov/legacy/v01228/network_properties.pb.go b/x/gov/legacy/v01228/network_properties.pb.go index 65541eb8d..4eb4852dd 100644 --- a/x/gov/legacy/v01228/network_properties.pb.go +++ b/x/gov/legacy/v01228/network_properties.pb.go @@ -1,1037 +1,1037 @@ -package types - -import ( - fmt "fmt" - io "io" - math "math" - math_bits "math/bits" - - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/gogo/protobuf/proto" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -type NetworkPropertiesV0228 struct { - MinTxFee uint64 `protobuf:"varint,1,opt,name=min_tx_fee,json=minTxFee,proto3" json:"min_tx_fee,omitempty"` - MaxTxFee uint64 `protobuf:"varint,2,opt,name=max_tx_fee,json=maxTxFee,proto3" json:"max_tx_fee,omitempty"` - VoteQuorum uint64 `protobuf:"varint,3,opt,name=vote_quorum,json=voteQuorum,proto3" json:"vote_quorum,omitempty"` - ProposalEndTime uint64 `protobuf:"varint,4,opt,name=proposal_end_time,json=proposalEndTime,proto3" json:"proposal_end_time,omitempty"` - ProposalEnactmentTime uint64 `protobuf:"varint,5,opt,name=proposal_enactment_time,json=proposalEnactmentTime,proto3" json:"proposal_enactment_time,omitempty"` - MinProposalEndBlocks uint64 `protobuf:"varint,6,opt,name=min_proposal_end_blocks,json=minProposalEndBlocks,proto3" json:"min_proposal_end_blocks,omitempty"` - MinProposalEnactmentBlocks uint64 `protobuf:"varint,7,opt,name=min_proposal_enactment_blocks,json=minProposalEnactmentBlocks,proto3" json:"min_proposal_enactment_blocks,omitempty"` - EnableForeignFeePayments bool `protobuf:"varint,8,opt,name=enable_foreign_fee_payments,json=enableForeignFeePayments,proto3" json:"enable_foreign_fee_payments,omitempty"` - MischanceRankDecreaseAmount uint64 `protobuf:"varint,9,opt,name=mischance_rank_decrease_amount,json=mischanceRankDecreaseAmount,proto3" json:"mischance_rank_decrease_amount,omitempty"` - MaxMischance uint64 `protobuf:"varint,10,opt,name=max_mischance,json=maxMischance,proto3" json:"max_mischance,omitempty"` - MischanceConfidence uint64 `protobuf:"varint,11,opt,name=mischance_confidence,json=mischanceConfidence,proto3" json:"mischance_confidence,omitempty"` - InactiveRankDecreasePercent uint64 `protobuf:"varint,12,opt,name=inactive_rank_decrease_percent,json=inactiveRankDecreasePercent,proto3" json:"inactive_rank_decrease_percent,omitempty"` - MinValidators uint64 `protobuf:"varint,13,opt,name=min_validators,json=minValidators,proto3" json:"min_validators,omitempty"` - PoorNetworkMaxBankSend uint64 `protobuf:"varint,14,opt,name=poor_network_max_bank_send,json=poorNetworkMaxBankSend,proto3" json:"poor_network_max_bank_send,omitempty"` - JailMaxTime uint64 `protobuf:"varint,15,opt,name=jail_max_time,json=jailMaxTime,proto3" json:"jail_max_time,omitempty"` - EnableTokenWhitelist bool `protobuf:"varint,16,opt,name=enable_token_whitelist,json=enableTokenWhitelist,proto3" json:"enable_token_whitelist,omitempty"` - EnableTokenBlacklist bool `protobuf:"varint,17,opt,name=enable_token_blacklist,json=enableTokenBlacklist,proto3" json:"enable_token_blacklist,omitempty"` - MinIdentityApprovalTip uint64 `protobuf:"varint,18,opt,name=min_identity_approval_tip,json=minIdentityApprovalTip,proto3" json:"min_identity_approval_tip,omitempty"` - UniqueIdentityKeys string `protobuf:"bytes,19,opt,name=unique_identity_keys,json=uniqueIdentityKeys,proto3" json:"unique_identity_keys,omitempty"` -} - -func (m *NetworkPropertiesV0228) Reset() { *m = NetworkPropertiesV0228{} } -func (m *NetworkPropertiesV0228) String() string { return proto.CompactTextString(m) } -func (*NetworkPropertiesV0228) ProtoMessage() {} -func (*NetworkPropertiesV0228) Descriptor() ([]byte, []int) { - return fileDescriptor_98011a6048e5dde3, []int{2} -} -func (m *NetworkPropertiesV0228) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *NetworkPropertiesV0228) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_NetworkProperties.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 *NetworkPropertiesV0228) XXX_Merge(src proto.Message) { - xxx_messageInfo_NetworkProperties.Merge(m, src) -} -func (m *NetworkPropertiesV0228) XXX_Size() int { - return m.Size() -} -func (m *NetworkPropertiesV0228) XXX_DiscardUnknown() { - xxx_messageInfo_NetworkProperties.DiscardUnknown(m) -} - -var xxx_messageInfo_NetworkProperties proto.InternalMessageInfo - -func (m *NetworkPropertiesV0228) GetMinTxFee() uint64 { - if m != nil { - return m.MinTxFee - } - return 0 -} - -func (m *NetworkPropertiesV0228) GetMaxTxFee() uint64 { - if m != nil { - return m.MaxTxFee - } - return 0 -} - -func (m *NetworkPropertiesV0228) GetVoteQuorum() uint64 { - if m != nil { - return m.VoteQuorum - } - return 0 -} - -func (m *NetworkPropertiesV0228) GetProposalEndTime() uint64 { - if m != nil { - return m.ProposalEndTime - } - return 0 -} - -func (m *NetworkPropertiesV0228) GetProposalEnactmentTime() uint64 { - if m != nil { - return m.ProposalEnactmentTime - } - return 0 -} - -func (m *NetworkPropertiesV0228) GetMinProposalEndBlocks() uint64 { - if m != nil { - return m.MinProposalEndBlocks - } - return 0 -} - -func (m *NetworkPropertiesV0228) GetMinProposalEnactmentBlocks() uint64 { - if m != nil { - return m.MinProposalEnactmentBlocks - } - return 0 -} - -func (m *NetworkPropertiesV0228) GetEnableForeignFeePayments() bool { - if m != nil { - return m.EnableForeignFeePayments - } - return false -} - -func (m *NetworkPropertiesV0228) GetMischanceRankDecreaseAmount() uint64 { - if m != nil { - return m.MischanceRankDecreaseAmount - } - return 0 -} - -func (m *NetworkPropertiesV0228) GetMaxMischance() uint64 { - if m != nil { - return m.MaxMischance - } - return 0 -} - -func (m *NetworkPropertiesV0228) GetMischanceConfidence() uint64 { - if m != nil { - return m.MischanceConfidence - } - return 0 -} - -func (m *NetworkPropertiesV0228) GetInactiveRankDecreasePercent() uint64 { - if m != nil { - return m.InactiveRankDecreasePercent - } - return 0 -} - -func (m *NetworkPropertiesV0228) GetMinValidators() uint64 { - if m != nil { - return m.MinValidators - } - return 0 -} - -func (m *NetworkPropertiesV0228) GetPoorNetworkMaxBankSend() uint64 { - if m != nil { - return m.PoorNetworkMaxBankSend - } - return 0 -} - -func (m *NetworkPropertiesV0228) GetJailMaxTime() uint64 { - if m != nil { - return m.JailMaxTime - } - return 0 -} - -func (m *NetworkPropertiesV0228) GetEnableTokenWhitelist() bool { - if m != nil { - return m.EnableTokenWhitelist - } - return false -} - -func (m *NetworkPropertiesV0228) GetEnableTokenBlacklist() bool { - if m != nil { - return m.EnableTokenBlacklist - } - return false -} - -func (m *NetworkPropertiesV0228) GetMinIdentityApprovalTip() uint64 { - if m != nil { - return m.MinIdentityApprovalTip - } - return 0 -} - -func (m *NetworkPropertiesV0228) GetUniqueIdentityKeys() string { - if m != nil { - return m.UniqueIdentityKeys - } - return "" -} - -func init() { - proto.RegisterType((*NetworkPropertiesV0228)(nil), "kira.gov.NetworkPropertiesV0228") -} - -func init() { proto.RegisterFile("kira/gov/network_properties.proto", fileDescriptor_98011a6048e5dde3) } - -var fileDescriptor_98011a6048e5dde3 = []byte{ - // 1202 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x56, 0xcb, 0x6e, 0xdb, 0x46, - 0x17, 0xb6, 0x12, 0x27, 0x96, 0xc7, 0x96, 0x4d, 0xd3, 0x8a, 0xcd, 0xd0, 0xf9, 0x65, 0xfe, 0x2e, - 0x02, 0x04, 0x01, 0x62, 0x35, 0xbd, 0x01, 0x0d, 0x50, 0x14, 0x94, 0x3c, 0x6e, 0x18, 0x89, 0x97, - 0x50, 0xb4, 0x92, 0x74, 0x33, 0x18, 0x4b, 0x13, 0x65, 0x2a, 0x91, 0x54, 0x48, 0x4a, 0x91, 0xdf, - 0xa0, 0xe0, 0xaa, 0x2f, 0x40, 0xa0, 0x40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0xa5, 0xef, 0xef, 0x5f, 0x7a, 0x4b, 0x34, 0x68, 0x80, - 0xeb, 0x7e, 0x40, 0xaa, 0x21, 0xe9, 0x63, 0x5a, 0x9d, 0xf0, 0x37, 0x12, 0x7f, 0x4e, 0x9c, 0xde, - 0xe6, 0xef, 0x9e, 0xcf, 0xff, 0x0b, 0x00, 0x00, 0xff, 0xff, 0x47, 0x3a, 0x99, 0xc8, 0x3c, 0x09, - 0x00, 0x00, -} - -func (m *NetworkPropertiesV0228) 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 *NetworkPropertiesV0228) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *NetworkPropertiesV0228) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.UniqueIdentityKeys) > 0 { - i -= len(m.UniqueIdentityKeys) - copy(dAtA[i:], m.UniqueIdentityKeys) - i = encodeVarintNetworkProperties(dAtA, i, uint64(len(m.UniqueIdentityKeys))) - i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0x9a - } - if m.MinIdentityApprovalTip != 0 { - i = encodeVarintNetworkProperties(dAtA, i, uint64(m.MinIdentityApprovalTip)) - i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0x90 - } - if m.EnableTokenBlacklist { - i-- - if m.EnableTokenBlacklist { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0x88 - } - if m.EnableTokenWhitelist { - i-- - if m.EnableTokenWhitelist { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0x80 - } - if m.JailMaxTime != 0 { - i = encodeVarintNetworkProperties(dAtA, i, uint64(m.JailMaxTime)) - i-- - dAtA[i] = 0x78 - } - if m.PoorNetworkMaxBankSend != 0 { - i = encodeVarintNetworkProperties(dAtA, i, uint64(m.PoorNetworkMaxBankSend)) - i-- - dAtA[i] = 0x70 - } - if m.MinValidators != 0 { - i = encodeVarintNetworkProperties(dAtA, i, uint64(m.MinValidators)) - i-- - dAtA[i] = 0x68 - } - if m.InactiveRankDecreasePercent != 0 { - i = encodeVarintNetworkProperties(dAtA, i, uint64(m.InactiveRankDecreasePercent)) - i-- - dAtA[i] = 0x60 - } - if m.MischanceConfidence != 0 { - i = encodeVarintNetworkProperties(dAtA, i, uint64(m.MischanceConfidence)) - i-- - dAtA[i] = 0x58 - } - if m.MaxMischance != 0 { - i = encodeVarintNetworkProperties(dAtA, i, uint64(m.MaxMischance)) - i-- - dAtA[i] = 0x50 - } - if m.MischanceRankDecreaseAmount != 0 { - i = encodeVarintNetworkProperties(dAtA, i, uint64(m.MischanceRankDecreaseAmount)) - i-- - dAtA[i] = 0x48 - } - if m.EnableForeignFeePayments { - i-- - if m.EnableForeignFeePayments { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x40 - } - if m.MinProposalEnactmentBlocks != 0 { - i = encodeVarintNetworkProperties(dAtA, i, uint64(m.MinProposalEnactmentBlocks)) - i-- - dAtA[i] = 0x38 - } - if m.MinProposalEndBlocks != 0 { - i = encodeVarintNetworkProperties(dAtA, i, uint64(m.MinProposalEndBlocks)) - i-- - dAtA[i] = 0x30 - } - if m.ProposalEnactmentTime != 0 { - i = encodeVarintNetworkProperties(dAtA, i, uint64(m.ProposalEnactmentTime)) - i-- - dAtA[i] = 0x28 - } - if m.ProposalEndTime != 0 { - i = encodeVarintNetworkProperties(dAtA, i, uint64(m.ProposalEndTime)) - i-- - dAtA[i] = 0x20 - } - if m.VoteQuorum != 0 { - i = encodeVarintNetworkProperties(dAtA, i, uint64(m.VoteQuorum)) - i-- - dAtA[i] = 0x18 - } - if m.MaxTxFee != 0 { - i = encodeVarintNetworkProperties(dAtA, i, uint64(m.MaxTxFee)) - i-- - dAtA[i] = 0x10 - } - if m.MinTxFee != 0 { - i = encodeVarintNetworkProperties(dAtA, i, uint64(m.MinTxFee)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func encodeVarintNetworkProperties(dAtA []byte, offset int, v uint64) int { - offset -= sovNetworkProperties(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} - -func (m *NetworkPropertiesV0228) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.MinTxFee != 0 { - n += 1 + sovNetworkProperties(uint64(m.MinTxFee)) - } - if m.MaxTxFee != 0 { - n += 1 + sovNetworkProperties(uint64(m.MaxTxFee)) - } - if m.VoteQuorum != 0 { - n += 1 + sovNetworkProperties(uint64(m.VoteQuorum)) - } - if m.ProposalEndTime != 0 { - n += 1 + sovNetworkProperties(uint64(m.ProposalEndTime)) - } - if m.ProposalEnactmentTime != 0 { - n += 1 + sovNetworkProperties(uint64(m.ProposalEnactmentTime)) - } - if m.MinProposalEndBlocks != 0 { - n += 1 + sovNetworkProperties(uint64(m.MinProposalEndBlocks)) - } - if m.MinProposalEnactmentBlocks != 0 { - n += 1 + sovNetworkProperties(uint64(m.MinProposalEnactmentBlocks)) - } - if m.EnableForeignFeePayments { - n += 2 - } - if m.MischanceRankDecreaseAmount != 0 { - n += 1 + sovNetworkProperties(uint64(m.MischanceRankDecreaseAmount)) - } - if m.MaxMischance != 0 { - n += 1 + sovNetworkProperties(uint64(m.MaxMischance)) - } - if m.MischanceConfidence != 0 { - n += 1 + sovNetworkProperties(uint64(m.MischanceConfidence)) - } - if m.InactiveRankDecreasePercent != 0 { - n += 1 + sovNetworkProperties(uint64(m.InactiveRankDecreasePercent)) - } - if m.MinValidators != 0 { - n += 1 + sovNetworkProperties(uint64(m.MinValidators)) - } - if m.PoorNetworkMaxBankSend != 0 { - n += 1 + sovNetworkProperties(uint64(m.PoorNetworkMaxBankSend)) - } - if m.JailMaxTime != 0 { - n += 1 + sovNetworkProperties(uint64(m.JailMaxTime)) - } - if m.EnableTokenWhitelist { - n += 3 - } - if m.EnableTokenBlacklist { - n += 3 - } - if m.MinIdentityApprovalTip != 0 { - n += 2 + sovNetworkProperties(uint64(m.MinIdentityApprovalTip)) - } - l = len(m.UniqueIdentityKeys) - if l > 0 { - n += 2 + l + sovNetworkProperties(uint64(l)) - } - return n -} - -func sovNetworkProperties(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozNetworkProperties(x uint64) (n int) { - return sovNetworkProperties(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} - -func (m *NetworkPropertiesV0228) 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 ErrIntOverflowNetworkProperties - } - 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: NetworkProperties: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: NetworkProperties: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MinTxFee", wireType) - } - m.MinTxFee = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowNetworkProperties - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MinTxFee |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MaxTxFee", wireType) - } - m.MaxTxFee = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowNetworkProperties - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MaxTxFee |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field VoteQuorum", wireType) - } - m.VoteQuorum = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowNetworkProperties - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.VoteQuorum |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field ProposalEndTime", wireType) - } - m.ProposalEndTime = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowNetworkProperties - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.ProposalEndTime |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 5: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field ProposalEnactmentTime", wireType) - } - m.ProposalEnactmentTime = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowNetworkProperties - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.ProposalEnactmentTime |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 6: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MinProposalEndBlocks", wireType) - } - m.MinProposalEndBlocks = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowNetworkProperties - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MinProposalEndBlocks |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 7: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MinProposalEnactmentBlocks", wireType) - } - m.MinProposalEnactmentBlocks = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowNetworkProperties - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MinProposalEnactmentBlocks |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 8: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field EnableForeignFeePayments", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowNetworkProperties - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.EnableForeignFeePayments = bool(v != 0) - case 9: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MischanceRankDecreaseAmount", wireType) - } - m.MischanceRankDecreaseAmount = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowNetworkProperties - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MischanceRankDecreaseAmount |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 10: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MaxMischance", wireType) - } - m.MaxMischance = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowNetworkProperties - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MaxMischance |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 11: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MischanceConfidence", wireType) - } - m.MischanceConfidence = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowNetworkProperties - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MischanceConfidence |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 12: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field InactiveRankDecreasePercent", wireType) - } - m.InactiveRankDecreasePercent = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowNetworkProperties - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.InactiveRankDecreasePercent |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 13: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MinValidators", wireType) - } - m.MinValidators = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowNetworkProperties - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MinValidators |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 14: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field PoorNetworkMaxBankSend", wireType) - } - m.PoorNetworkMaxBankSend = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowNetworkProperties - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.PoorNetworkMaxBankSend |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 15: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field JailMaxTime", wireType) - } - m.JailMaxTime = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowNetworkProperties - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.JailMaxTime |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 16: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field EnableTokenWhitelist", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowNetworkProperties - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.EnableTokenWhitelist = bool(v != 0) - case 17: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field EnableTokenBlacklist", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowNetworkProperties - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.EnableTokenBlacklist = bool(v != 0) - case 18: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MinIdentityApprovalTip", wireType) - } - m.MinIdentityApprovalTip = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowNetworkProperties - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MinIdentityApprovalTip |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 19: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field UniqueIdentityKeys", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowNetworkProperties - } - 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 ErrInvalidLengthNetworkProperties - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthNetworkProperties - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.UniqueIdentityKeys = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipNetworkProperties(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthNetworkProperties - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipNetworkProperties(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, ErrIntOverflowNetworkProperties - } - 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, ErrIntOverflowNetworkProperties - } - 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, ErrIntOverflowNetworkProperties - } - 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, ErrInvalidLengthNetworkProperties - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupNetworkProperties - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthNetworkProperties - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthNetworkProperties = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowNetworkProperties = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupNetworkProperties = fmt.Errorf("proto: unexpected end of group") -) +package types + +import ( + fmt "fmt" + io "io" + math "math" + math_bits "math/bits" + + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type NetworkPropertiesV0228 struct { + MinTxFee uint64 `protobuf:"varint,1,opt,name=min_tx_fee,json=minTxFee,proto3" json:"min_tx_fee,omitempty"` + MaxTxFee uint64 `protobuf:"varint,2,opt,name=max_tx_fee,json=maxTxFee,proto3" json:"max_tx_fee,omitempty"` + VoteQuorum uint64 `protobuf:"varint,3,opt,name=vote_quorum,json=voteQuorum,proto3" json:"vote_quorum,omitempty"` + ProposalEndTime uint64 `protobuf:"varint,4,opt,name=proposal_end_time,json=proposalEndTime,proto3" json:"proposal_end_time,omitempty"` + ProposalEnactmentTime uint64 `protobuf:"varint,5,opt,name=proposal_enactment_time,json=proposalEnactmentTime,proto3" json:"proposal_enactment_time,omitempty"` + MinProposalEndBlocks uint64 `protobuf:"varint,6,opt,name=min_proposal_end_blocks,json=minProposalEndBlocks,proto3" json:"min_proposal_end_blocks,omitempty"` + MinProposalEnactmentBlocks uint64 `protobuf:"varint,7,opt,name=min_proposal_enactment_blocks,json=minProposalEnactmentBlocks,proto3" json:"min_proposal_enactment_blocks,omitempty"` + EnableForeignFeePayments bool `protobuf:"varint,8,opt,name=enable_foreign_fee_payments,json=enableForeignFeePayments,proto3" json:"enable_foreign_fee_payments,omitempty"` + MischanceRankDecreaseAmount uint64 `protobuf:"varint,9,opt,name=mischance_rank_decrease_amount,json=mischanceRankDecreaseAmount,proto3" json:"mischance_rank_decrease_amount,omitempty"` + MaxMischance uint64 `protobuf:"varint,10,opt,name=max_mischance,json=maxMischance,proto3" json:"max_mischance,omitempty"` + MischanceConfidence uint64 `protobuf:"varint,11,opt,name=mischance_confidence,json=mischanceConfidence,proto3" json:"mischance_confidence,omitempty"` + InactiveRankDecreasePercent uint64 `protobuf:"varint,12,opt,name=inactive_rank_decrease_percent,json=inactiveRankDecreasePercent,proto3" json:"inactive_rank_decrease_percent,omitempty"` + MinValidators uint64 `protobuf:"varint,13,opt,name=min_validators,json=minValidators,proto3" json:"min_validators,omitempty"` + PoorNetworkMaxBankSend uint64 `protobuf:"varint,14,opt,name=poor_network_max_bank_send,json=poorNetworkMaxBankSend,proto3" json:"poor_network_max_bank_send,omitempty"` + JailMaxTime uint64 `protobuf:"varint,15,opt,name=jail_max_time,json=jailMaxTime,proto3" json:"jail_max_time,omitempty"` + EnableTokenWhitelist bool `protobuf:"varint,16,opt,name=enable_token_whitelist,json=enableTokenWhitelist,proto3" json:"enable_token_whitelist,omitempty"` + EnableTokenBlacklist bool `protobuf:"varint,17,opt,name=enable_token_blacklist,json=enableTokenBlacklist,proto3" json:"enable_token_blacklist,omitempty"` + MinIdentityApprovalTip uint64 `protobuf:"varint,18,opt,name=min_identity_approval_tip,json=minIdentityApprovalTip,proto3" json:"min_identity_approval_tip,omitempty"` + UniqueIdentityKeys string `protobuf:"bytes,19,opt,name=unique_identity_keys,json=uniqueIdentityKeys,proto3" json:"unique_identity_keys,omitempty"` +} + +func (m *NetworkPropertiesV0228) Reset() { *m = NetworkPropertiesV0228{} } +func (m *NetworkPropertiesV0228) String() string { return proto.CompactTextString(m) } +func (*NetworkPropertiesV0228) ProtoMessage() {} +func (*NetworkPropertiesV0228) Descriptor() ([]byte, []int) { + return fileDescriptor_98011a6048e5dde3, []int{2} +} +func (m *NetworkPropertiesV0228) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *NetworkPropertiesV0228) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_NetworkProperties.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 *NetworkPropertiesV0228) XXX_Merge(src proto.Message) { + xxx_messageInfo_NetworkProperties.Merge(m, src) +} +func (m *NetworkPropertiesV0228) XXX_Size() int { + return m.Size() +} +func (m *NetworkPropertiesV0228) XXX_DiscardUnknown() { + xxx_messageInfo_NetworkProperties.DiscardUnknown(m) +} + +var xxx_messageInfo_NetworkProperties proto.InternalMessageInfo + +func (m *NetworkPropertiesV0228) GetMinTxFee() uint64 { + if m != nil { + return m.MinTxFee + } + return 0 +} + +func (m *NetworkPropertiesV0228) GetMaxTxFee() uint64 { + if m != nil { + return m.MaxTxFee + } + return 0 +} + +func (m *NetworkPropertiesV0228) GetVoteQuorum() uint64 { + if m != nil { + return m.VoteQuorum + } + return 0 +} + +func (m *NetworkPropertiesV0228) GetProposalEndTime() uint64 { + if m != nil { + return m.ProposalEndTime + } + return 0 +} + +func (m *NetworkPropertiesV0228) GetProposalEnactmentTime() uint64 { + if m != nil { + return m.ProposalEnactmentTime + } + return 0 +} + +func (m *NetworkPropertiesV0228) GetMinProposalEndBlocks() uint64 { + if m != nil { + return m.MinProposalEndBlocks + } + return 0 +} + +func (m *NetworkPropertiesV0228) GetMinProposalEnactmentBlocks() uint64 { + if m != nil { + return m.MinProposalEnactmentBlocks + } + return 0 +} + +func (m *NetworkPropertiesV0228) GetEnableForeignFeePayments() bool { + if m != nil { + return m.EnableForeignFeePayments + } + return false +} + +func (m *NetworkPropertiesV0228) GetMischanceRankDecreaseAmount() uint64 { + if m != nil { + return m.MischanceRankDecreaseAmount + } + return 0 +} + +func (m *NetworkPropertiesV0228) GetMaxMischance() uint64 { + if m != nil { + return m.MaxMischance + } + return 0 +} + +func (m *NetworkPropertiesV0228) GetMischanceConfidence() uint64 { + if m != nil { + return m.MischanceConfidence + } + return 0 +} + +func (m *NetworkPropertiesV0228) GetInactiveRankDecreasePercent() uint64 { + if m != nil { + return m.InactiveRankDecreasePercent + } + return 0 +} + +func (m *NetworkPropertiesV0228) GetMinValidators() uint64 { + if m != nil { + return m.MinValidators + } + return 0 +} + +func (m *NetworkPropertiesV0228) GetPoorNetworkMaxBankSend() uint64 { + if m != nil { + return m.PoorNetworkMaxBankSend + } + return 0 +} + +func (m *NetworkPropertiesV0228) GetJailMaxTime() uint64 { + if m != nil { + return m.JailMaxTime + } + return 0 +} + +func (m *NetworkPropertiesV0228) GetEnableTokenWhitelist() bool { + if m != nil { + return m.EnableTokenWhitelist + } + return false +} + +func (m *NetworkPropertiesV0228) GetEnableTokenBlacklist() bool { + if m != nil { + return m.EnableTokenBlacklist + } + return false +} + +func (m *NetworkPropertiesV0228) GetMinIdentityApprovalTip() uint64 { + if m != nil { + return m.MinIdentityApprovalTip + } + return 0 +} + +func (m *NetworkPropertiesV0228) GetUniqueIdentityKeys() string { + if m != nil { + return m.UniqueIdentityKeys + } + return "" +} + +func init() { + proto.RegisterType((*NetworkPropertiesV0228)(nil), "kira.gov.NetworkPropertiesV0228") +} + +func init() { proto.RegisterFile("kira/gov/network_properties.proto", fileDescriptor_98011a6048e5dde3) } + +var fileDescriptor_98011a6048e5dde3 = []byte{ + // 1202 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x56, 0xcb, 0x6e, 0xdb, 0x46, + 0x17, 0xb6, 0x12, 0x27, 0x96, 0xc7, 0x96, 0x4d, 0xd3, 0x8a, 0xcd, 0xd0, 0xf9, 0x65, 0xfe, 0x2e, + 0x02, 0x04, 0x01, 0x62, 0x35, 0xbd, 0x01, 0x0d, 0x50, 0x14, 0x94, 0x3c, 0x6e, 0x18, 0x89, 0x97, + 0x50, 0xb4, 0x92, 0x74, 0x33, 0x18, 0x4b, 0x13, 0x65, 0x2a, 0x91, 0x54, 0x48, 0x4a, 0x91, 0xdf, + 0xa0, 0xe0, 0xaa, 0x2f, 0x40, 0xa0, 0x40, 0x5f, 0xa1, 0x0f, 0xd1, 0x5d, 0x03, 0x74, 0xd3, 0x55, + 0x51, 0xc4, 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, 0xaa, 0x21, 0xe9, 0x63, 0x5a, 0x9d, 0xf0, 0x37, 0x12, 0x7f, 0x4e, 0x9c, 0xde, + 0xe6, 0xef, 0x9e, 0xcf, 0xff, 0x0b, 0x00, 0x00, 0xff, 0xff, 0x47, 0x3a, 0x99, 0xc8, 0x3c, 0x09, + 0x00, 0x00, +} + +func (m *NetworkPropertiesV0228) 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 *NetworkPropertiesV0228) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *NetworkPropertiesV0228) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.UniqueIdentityKeys) > 0 { + i -= len(m.UniqueIdentityKeys) + copy(dAtA[i:], m.UniqueIdentityKeys) + i = encodeVarintNetworkProperties(dAtA, i, uint64(len(m.UniqueIdentityKeys))) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x9a + } + if m.MinIdentityApprovalTip != 0 { + i = encodeVarintNetworkProperties(dAtA, i, uint64(m.MinIdentityApprovalTip)) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x90 + } + if m.EnableTokenBlacklist { + i-- + if m.EnableTokenBlacklist { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x88 + } + if m.EnableTokenWhitelist { + i-- + if m.EnableTokenWhitelist { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x80 + } + if m.JailMaxTime != 0 { + i = encodeVarintNetworkProperties(dAtA, i, uint64(m.JailMaxTime)) + i-- + dAtA[i] = 0x78 + } + if m.PoorNetworkMaxBankSend != 0 { + i = encodeVarintNetworkProperties(dAtA, i, uint64(m.PoorNetworkMaxBankSend)) + i-- + dAtA[i] = 0x70 + } + if m.MinValidators != 0 { + i = encodeVarintNetworkProperties(dAtA, i, uint64(m.MinValidators)) + i-- + dAtA[i] = 0x68 + } + if m.InactiveRankDecreasePercent != 0 { + i = encodeVarintNetworkProperties(dAtA, i, uint64(m.InactiveRankDecreasePercent)) + i-- + dAtA[i] = 0x60 + } + if m.MischanceConfidence != 0 { + i = encodeVarintNetworkProperties(dAtA, i, uint64(m.MischanceConfidence)) + i-- + dAtA[i] = 0x58 + } + if m.MaxMischance != 0 { + i = encodeVarintNetworkProperties(dAtA, i, uint64(m.MaxMischance)) + i-- + dAtA[i] = 0x50 + } + if m.MischanceRankDecreaseAmount != 0 { + i = encodeVarintNetworkProperties(dAtA, i, uint64(m.MischanceRankDecreaseAmount)) + i-- + dAtA[i] = 0x48 + } + if m.EnableForeignFeePayments { + i-- + if m.EnableForeignFeePayments { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x40 + } + if m.MinProposalEnactmentBlocks != 0 { + i = encodeVarintNetworkProperties(dAtA, i, uint64(m.MinProposalEnactmentBlocks)) + i-- + dAtA[i] = 0x38 + } + if m.MinProposalEndBlocks != 0 { + i = encodeVarintNetworkProperties(dAtA, i, uint64(m.MinProposalEndBlocks)) + i-- + dAtA[i] = 0x30 + } + if m.ProposalEnactmentTime != 0 { + i = encodeVarintNetworkProperties(dAtA, i, uint64(m.ProposalEnactmentTime)) + i-- + dAtA[i] = 0x28 + } + if m.ProposalEndTime != 0 { + i = encodeVarintNetworkProperties(dAtA, i, uint64(m.ProposalEndTime)) + i-- + dAtA[i] = 0x20 + } + if m.VoteQuorum != 0 { + i = encodeVarintNetworkProperties(dAtA, i, uint64(m.VoteQuorum)) + i-- + dAtA[i] = 0x18 + } + if m.MaxTxFee != 0 { + i = encodeVarintNetworkProperties(dAtA, i, uint64(m.MaxTxFee)) + i-- + dAtA[i] = 0x10 + } + if m.MinTxFee != 0 { + i = encodeVarintNetworkProperties(dAtA, i, uint64(m.MinTxFee)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintNetworkProperties(dAtA []byte, offset int, v uint64) int { + offset -= sovNetworkProperties(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} + +func (m *NetworkPropertiesV0228) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.MinTxFee != 0 { + n += 1 + sovNetworkProperties(uint64(m.MinTxFee)) + } + if m.MaxTxFee != 0 { + n += 1 + sovNetworkProperties(uint64(m.MaxTxFee)) + } + if m.VoteQuorum != 0 { + n += 1 + sovNetworkProperties(uint64(m.VoteQuorum)) + } + if m.ProposalEndTime != 0 { + n += 1 + sovNetworkProperties(uint64(m.ProposalEndTime)) + } + if m.ProposalEnactmentTime != 0 { + n += 1 + sovNetworkProperties(uint64(m.ProposalEnactmentTime)) + } + if m.MinProposalEndBlocks != 0 { + n += 1 + sovNetworkProperties(uint64(m.MinProposalEndBlocks)) + } + if m.MinProposalEnactmentBlocks != 0 { + n += 1 + sovNetworkProperties(uint64(m.MinProposalEnactmentBlocks)) + } + if m.EnableForeignFeePayments { + n += 2 + } + if m.MischanceRankDecreaseAmount != 0 { + n += 1 + sovNetworkProperties(uint64(m.MischanceRankDecreaseAmount)) + } + if m.MaxMischance != 0 { + n += 1 + sovNetworkProperties(uint64(m.MaxMischance)) + } + if m.MischanceConfidence != 0 { + n += 1 + sovNetworkProperties(uint64(m.MischanceConfidence)) + } + if m.InactiveRankDecreasePercent != 0 { + n += 1 + sovNetworkProperties(uint64(m.InactiveRankDecreasePercent)) + } + if m.MinValidators != 0 { + n += 1 + sovNetworkProperties(uint64(m.MinValidators)) + } + if m.PoorNetworkMaxBankSend != 0 { + n += 1 + sovNetworkProperties(uint64(m.PoorNetworkMaxBankSend)) + } + if m.JailMaxTime != 0 { + n += 1 + sovNetworkProperties(uint64(m.JailMaxTime)) + } + if m.EnableTokenWhitelist { + n += 3 + } + if m.EnableTokenBlacklist { + n += 3 + } + if m.MinIdentityApprovalTip != 0 { + n += 2 + sovNetworkProperties(uint64(m.MinIdentityApprovalTip)) + } + l = len(m.UniqueIdentityKeys) + if l > 0 { + n += 2 + l + sovNetworkProperties(uint64(l)) + } + return n +} + +func sovNetworkProperties(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozNetworkProperties(x uint64) (n int) { + return sovNetworkProperties(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} + +func (m *NetworkPropertiesV0228) 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 ErrIntOverflowNetworkProperties + } + 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: NetworkProperties: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: NetworkProperties: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MinTxFee", wireType) + } + m.MinTxFee = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNetworkProperties + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MinTxFee |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MaxTxFee", wireType) + } + m.MaxTxFee = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNetworkProperties + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MaxTxFee |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field VoteQuorum", wireType) + } + m.VoteQuorum = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNetworkProperties + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.VoteQuorum |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ProposalEndTime", wireType) + } + m.ProposalEndTime = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNetworkProperties + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ProposalEndTime |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ProposalEnactmentTime", wireType) + } + m.ProposalEnactmentTime = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNetworkProperties + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ProposalEnactmentTime |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MinProposalEndBlocks", wireType) + } + m.MinProposalEndBlocks = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNetworkProperties + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MinProposalEndBlocks |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 7: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MinProposalEnactmentBlocks", wireType) + } + m.MinProposalEnactmentBlocks = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNetworkProperties + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MinProposalEnactmentBlocks |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 8: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field EnableForeignFeePayments", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNetworkProperties + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.EnableForeignFeePayments = bool(v != 0) + case 9: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MischanceRankDecreaseAmount", wireType) + } + m.MischanceRankDecreaseAmount = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNetworkProperties + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MischanceRankDecreaseAmount |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 10: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MaxMischance", wireType) + } + m.MaxMischance = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNetworkProperties + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MaxMischance |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 11: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MischanceConfidence", wireType) + } + m.MischanceConfidence = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNetworkProperties + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MischanceConfidence |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 12: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field InactiveRankDecreasePercent", wireType) + } + m.InactiveRankDecreasePercent = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNetworkProperties + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.InactiveRankDecreasePercent |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 13: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MinValidators", wireType) + } + m.MinValidators = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNetworkProperties + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MinValidators |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 14: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PoorNetworkMaxBankSend", wireType) + } + m.PoorNetworkMaxBankSend = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNetworkProperties + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PoorNetworkMaxBankSend |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 15: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field JailMaxTime", wireType) + } + m.JailMaxTime = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNetworkProperties + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.JailMaxTime |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 16: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field EnableTokenWhitelist", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNetworkProperties + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.EnableTokenWhitelist = bool(v != 0) + case 17: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field EnableTokenBlacklist", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNetworkProperties + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.EnableTokenBlacklist = bool(v != 0) + case 18: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MinIdentityApprovalTip", wireType) + } + m.MinIdentityApprovalTip = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNetworkProperties + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MinIdentityApprovalTip |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 19: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field UniqueIdentityKeys", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNetworkProperties + } + 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 ErrInvalidLengthNetworkProperties + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthNetworkProperties + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.UniqueIdentityKeys = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipNetworkProperties(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthNetworkProperties + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipNetworkProperties(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, ErrIntOverflowNetworkProperties + } + 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, ErrIntOverflowNetworkProperties + } + 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, ErrIntOverflowNetworkProperties + } + 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, ErrInvalidLengthNetworkProperties + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupNetworkProperties + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthNetworkProperties + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthNetworkProperties = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowNetworkProperties = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupNetworkProperties = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/gov/proposal_handler.go b/x/gov/proposal_handler.go index 85f8106e4..6c38827d6 100644 --- a/x/gov/proposal_handler.go +++ b/x/gov/proposal_handler.go @@ -1,454 +1,454 @@ -package gov - -import ( - "fmt" - - kiratypes "github.com/KiraCore/sekai/types" - "github.com/KiraCore/sekai/x/gov/keeper" - "github.com/KiraCore/sekai/x/gov/types" - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/pkg/errors" -) - -type ApplyWhitelistAccountPermissionProposalHandler struct { - keeper keeper.Keeper -} - -func NewApplyWhitelistAccountPermissionProposalHandler(keeper keeper.Keeper) *ApplyWhitelistAccountPermissionProposalHandler { - return &ApplyWhitelistAccountPermissionProposalHandler{keeper: keeper} -} - -func (a ApplyWhitelistAccountPermissionProposalHandler) ProposalType() string { - return kiratypes.WhitelistAccountPermissionProposalType -} - -func (a ApplyWhitelistAccountPermissionProposalHandler) Apply(ctx sdk.Context, proposalID uint64, proposal types.Content, slash sdk.Dec) error { - p := proposal.(*types.WhitelistAccountPermissionProposal) - - actor, found := a.keeper.GetNetworkActorByAddress(ctx, p.Address) - if found { - if actor.Permissions.IsWhitelisted(types.PermValue(p.Permission)) { - return sdkerrors.Wrap(types.ErrWhitelisting, "permission already whitelisted") - } - } else { - actor = types.NewDefaultActor(p.Address) - } - - return a.keeper.AddWhitelistPermission(ctx, actor, types.PermValue(p.Permission)) -} - -type ApplyBlacklistAccountPermissionProposalHandler struct { - keeper keeper.Keeper -} - -func NewApplyBlacklistAccountPermissionProposalHandler(keeper keeper.Keeper) *ApplyBlacklistAccountPermissionProposalHandler { - return &ApplyBlacklistAccountPermissionProposalHandler{keeper: keeper} -} - -func (a ApplyBlacklistAccountPermissionProposalHandler) ProposalType() string { - return kiratypes.BlacklistAccountPermissionProposalType -} - -func (a ApplyBlacklistAccountPermissionProposalHandler) Apply(ctx sdk.Context, proposalID uint64, proposal types.Content, slash sdk.Dec) error { - p := proposal.(*types.BlacklistAccountPermissionProposal) - - actor, found := a.keeper.GetNetworkActorByAddress(ctx, p.Address) - if found { - if actor.Permissions.IsBlacklisted(types.PermValue(p.Permission)) { - return sdkerrors.Wrap(types.ErrWhitelisting, "permission already blacklisted") - } - } else { - actor = types.NewDefaultActor(p.Address) - } - - return a.keeper.AddBlacklistPermission(ctx, actor, types.PermValue(p.Permission)) -} - -type ApplyRemoveWhitelistedAccountPermissionProposalHandler struct { - keeper keeper.Keeper -} - -func NewApplyRemoveWhitelistedAccountPermissionProposalHandler(keeper keeper.Keeper) *ApplyRemoveWhitelistedAccountPermissionProposalHandler { - return &ApplyRemoveWhitelistedAccountPermissionProposalHandler{keeper: keeper} -} - -func (a ApplyRemoveWhitelistedAccountPermissionProposalHandler) ProposalType() string { - return kiratypes.RemoveWhitelistedAccountPermissionProposalType -} - -func (a ApplyRemoveWhitelistedAccountPermissionProposalHandler) Apply(ctx sdk.Context, proposalID uint64, proposal types.Content, slash sdk.Dec) error { - p := proposal.(*types.RemoveWhitelistedAccountPermissionProposal) - - actor, found := a.keeper.GetNetworkActorByAddress(ctx, p.Address) - if found { - if !actor.Permissions.IsWhitelisted(types.PermValue(p.Permission)) { - return sdkerrors.Wrap(types.ErrWhitelisting, "whitelisted permission does not exist") - } - } else { - actor = types.NewDefaultActor(p.Address) - } - - return a.keeper.RemoveWhitelistedPermission(ctx, actor, types.PermValue(p.Permission)) -} - -type ApplyRemoveBlacklistedAccountPermissionProposalHandler struct { - keeper keeper.Keeper -} - -func NewApplyRemoveBlacklistedAccountPermissionProposalHandler(keeper keeper.Keeper) *ApplyRemoveBlacklistedAccountPermissionProposalHandler { - return &ApplyRemoveBlacklistedAccountPermissionProposalHandler{keeper: keeper} -} - -func (a ApplyRemoveBlacklistedAccountPermissionProposalHandler) ProposalType() string { - return kiratypes.RemoveBlacklistedAccountPermissionProposalType -} - -func (a ApplyRemoveBlacklistedAccountPermissionProposalHandler) Apply(ctx sdk.Context, proposalID uint64, proposal types.Content, slash sdk.Dec) error { - p := proposal.(*types.RemoveBlacklistedAccountPermissionProposal) - - actor, found := a.keeper.GetNetworkActorByAddress(ctx, p.Address) - fmt.Println("actor", actor) - if found { - if !actor.Permissions.IsBlacklisted(types.PermValue(p.Permission)) { - return sdkerrors.Wrap(types.ErrWhitelisting, "blacklisted permission does not exist") - } - } else { - actor = types.NewDefaultActor(p.Address) - } - - fmt.Println("RemoveBlacklistedPermission", p.Permission) - return a.keeper.RemoveBlacklistedPermission(ctx, actor, types.PermValue(p.Permission)) -} - -type ApplyAssignRoleToAccountProposalHandler struct { - keeper keeper.Keeper -} - -func NewApplyAssignRoleToAccountProposalHandler(keeper keeper.Keeper) *ApplyAssignRoleToAccountProposalHandler { - return &ApplyAssignRoleToAccountProposalHandler{keeper: keeper} -} - -func (a ApplyAssignRoleToAccountProposalHandler) ProposalType() string { - return kiratypes.AssignRoleToAccountProposalType -} - -func (a ApplyAssignRoleToAccountProposalHandler) Apply(ctx sdk.Context, proposalID uint64, proposal types.Content, slash sdk.Dec) error { - p := proposal.(*types.AssignRoleToAccountProposal) - - roleId, err := a.keeper.GetRoleIdFromIdentifierString(ctx, p.RoleIdentifier) - if err != nil { - return err - } - - return a.keeper.AssignRoleToAccount(ctx, p.Address, roleId) -} - -type ApplyUnassignRoleFromAccountProposalHandler struct { - keeper keeper.Keeper -} - -func NewApplyUnassignRoleFromAccountProposalHandler(keeper keeper.Keeper) *ApplyUnassignRoleFromAccountProposalHandler { - return &ApplyUnassignRoleFromAccountProposalHandler{keeper: keeper} -} - -func (a ApplyUnassignRoleFromAccountProposalHandler) ProposalType() string { - return kiratypes.UnassignRoleFromAccountProposalType -} - -func (a ApplyUnassignRoleFromAccountProposalHandler) Apply(ctx sdk.Context, proposalID uint64, proposal types.Content, slash sdk.Dec) error { - p := proposal.(*types.UnassignRoleFromAccountProposal) - - roleId, err := a.keeper.GetRoleIdFromIdentifierString(ctx, p.RoleIdentifier) - if err != nil { - return err - } - - return a.keeper.UnassignRoleFromAccount(ctx, p.Address, roleId) -} - -type ApplySetNetworkPropertyProposalHandler struct { - keeper keeper.Keeper -} - -func NewApplySetNetworkPropertyProposalHandler(keeper keeper.Keeper) *ApplySetNetworkPropertyProposalHandler { - return &ApplySetNetworkPropertyProposalHandler{keeper: keeper} -} - -func (a ApplySetNetworkPropertyProposalHandler) ProposalType() string { - return kiratypes.SetNetworkPropertyProposalType -} - -func (a ApplySetNetworkPropertyProposalHandler) Apply(ctx sdk.Context, proposalID uint64, proposal types.Content, slash sdk.Dec) error { - p := proposal.(*types.SetNetworkPropertyProposal) - - property, err := a.keeper.GetNetworkProperty(ctx, p.NetworkProperty) - if err != nil { - return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, err.Error()) - } - if property == p.Value { - return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "network property already set as proposed value") - } - - return a.keeper.SetNetworkProperty(ctx, p.NetworkProperty, p.Value) -} - -type ApplyUpsertDataRegistryProposalHandler struct { - keeper keeper.Keeper -} - -func NewApplyUpsertDataRegistryProposalHandler(keeper keeper.Keeper) *ApplyUpsertDataRegistryProposalHandler { - return &ApplyUpsertDataRegistryProposalHandler{keeper: keeper} -} - -func (a ApplyUpsertDataRegistryProposalHandler) ProposalType() string { - return kiratypes.UpsertDataRegistryProposalType -} - -func (a ApplyUpsertDataRegistryProposalHandler) Apply(ctx sdk.Context, proposalID uint64, proposal types.Content, slash sdk.Dec) error { - p := proposal.(*types.UpsertDataRegistryProposal) - entry := types.NewDataRegistryEntry(p.Hash, p.Reference, p.Encoding, p.Size_) - a.keeper.UpsertDataRegistryEntry(ctx, p.Key, entry) - return nil -} - -type ApplySetPoorNetworkMessagesProposalHandler struct { - keeper keeper.Keeper -} - -func NewApplySetPoorNetworkMessagesProposalHandler(keeper keeper.Keeper) *ApplySetPoorNetworkMessagesProposalHandler { - return &ApplySetPoorNetworkMessagesProposalHandler{keeper: keeper} -} - -func (a ApplySetPoorNetworkMessagesProposalHandler) ProposalType() string { - return kiratypes.SetPoorNetworkMessagesProposalType -} - -func (a ApplySetPoorNetworkMessagesProposalHandler) Apply(ctx sdk.Context, proposalID uint64, proposal types.Content, slash sdk.Dec) error { - p := proposal.(*types.SetPoorNetworkMessagesProposal) - msgs := types.AllowedMessages{Messages: p.Messages} - a.keeper.SavePoorNetworkMessages(ctx, &msgs) - return nil -} - -type CreateRoleProposalHandler struct { - keeper keeper.Keeper -} - -func NewApplyCreateRoleProposalHandler(keeper keeper.Keeper) *CreateRoleProposalHandler { - return &CreateRoleProposalHandler{keeper: keeper} -} - -func (c CreateRoleProposalHandler) ProposalType() string { - return kiratypes.CreateRoleProposalType -} - -func (c CreateRoleProposalHandler) Apply(ctx sdk.Context, proposalID uint64, proposal types.Content, slash sdk.Dec) error { - p := proposal.(*types.CreateRoleProposal) - - // check sid is good variable naming form - if !keeper.ValidateRoleSidKey(p.RoleSid) { - return errors.Wrap(types.ErrInvalidRoleSid, fmt.Sprintf("invalid role sid configuration: sid=%s", p.RoleSid)) - } - - _, err := c.keeper.GetRoleBySid(ctx, p.RoleSid) - if err == nil { - return types.ErrRoleExist - } - - roleId := c.keeper.CreateRole(ctx, p.RoleSid, p.RoleDescription) - - for _, w := range p.WhitelistedPermissions { - err := c.keeper.WhitelistRolePermission(ctx, roleId, w) - if err != nil { - return err - } - } - - for _, b := range p.BlacklistedPermissions { - err := c.keeper.BlacklistRolePermission(ctx, roleId, b) - if err != nil { - return err - } - } - return nil -} - -type ApplyRemoveRoleProposalHandler struct { - keeper keeper.Keeper -} - -func NewApplyRemoveRoleProposalHandler(keeper keeper.Keeper) *ApplyRemoveRoleProposalHandler { - return &ApplyRemoveRoleProposalHandler{keeper: keeper} -} - -func (c ApplyRemoveRoleProposalHandler) ProposalType() string { - return kiratypes.RemoveRoleProposalType -} - -func (c ApplyRemoveRoleProposalHandler) Apply(ctx sdk.Context, proposalID uint64, proposal types.Content, slash sdk.Dec) error { - p := proposal.(*types.RemoveRoleProposal) - _ = p - return fmt.Errorf("remove role proposal is not implemented!") -} - -type ApplyWhitelistRolePermissionProposalHandler struct { - keeper keeper.Keeper -} - -func NewApplyWhitelistRolePermissionProposalHandler(keeper keeper.Keeper) *ApplyWhitelistRolePermissionProposalHandler { - return &ApplyWhitelistRolePermissionProposalHandler{keeper: keeper} -} - -func (c ApplyWhitelistRolePermissionProposalHandler) ProposalType() string { - return kiratypes.WhitelistRolePermissionProposalType -} - -func (c ApplyWhitelistRolePermissionProposalHandler) Apply(ctx sdk.Context, proposalID uint64, proposal types.Content, slash sdk.Dec) error { - p := proposal.(*types.WhitelistRolePermissionProposal) - - roleId, err := c.keeper.GetRoleIdFromIdentifierString(ctx, p.RoleIdentifier) - if err != nil { - return err - } - - return c.keeper.WhitelistRolePermission(ctx, roleId, p.Permission) -} - -type ApplyBlacklistRolePermissionProposalHandler struct { - keeper keeper.Keeper -} - -func NewApplyBlacklistRolePermissionProposalHandler(keeper keeper.Keeper) *ApplyBlacklistRolePermissionProposalHandler { - return &ApplyBlacklistRolePermissionProposalHandler{keeper: keeper} -} - -func (c ApplyBlacklistRolePermissionProposalHandler) ProposalType() string { - return kiratypes.BlacklistRolePermissionProposalType -} - -func (c ApplyBlacklistRolePermissionProposalHandler) Apply(ctx sdk.Context, proposalID uint64, proposal types.Content, slash sdk.Dec) error { - p := proposal.(*types.BlacklistRolePermissionProposal) - - roleId, err := c.keeper.GetRoleIdFromIdentifierString(ctx, p.RoleIdentifier) - if err != nil { - return err - } - - return c.keeper.BlacklistRolePermission(ctx, roleId, p.Permission) -} - -type ApplyRemoveWhitelistedRolePermissionProposalHandler struct { - keeper keeper.Keeper -} - -func NewApplyRemoveWhitelistedRolePermissionProposalHandler(keeper keeper.Keeper) *ApplyRemoveWhitelistedRolePermissionProposalHandler { - return &ApplyRemoveWhitelistedRolePermissionProposalHandler{keeper: keeper} -} - -func (c ApplyRemoveWhitelistedRolePermissionProposalHandler) ProposalType() string { - return kiratypes.RemoveWhitelistedRolePermissionProposalType -} - -func (c ApplyRemoveWhitelistedRolePermissionProposalHandler) Apply(ctx sdk.Context, proposalID uint64, proposal types.Content, slash sdk.Dec) error { - p := proposal.(*types.RemoveWhitelistedRolePermissionProposal) - - roleId, err := c.keeper.GetRoleIdFromIdentifierString(ctx, p.RoleSid) - if err != nil { - return err - } - - return c.keeper.RemoveWhitelistRolePermission(ctx, roleId, p.Permission) -} - -type ApplyRemoveBlacklistedRolePermissionProposalHandler struct { - keeper keeper.Keeper -} - -func NewApplyRemoveBlacklistedRolePermissionProposalHandler(keeper keeper.Keeper) *ApplyRemoveBlacklistedRolePermissionProposalHandler { - return &ApplyRemoveBlacklistedRolePermissionProposalHandler{keeper: keeper} -} - -func (c ApplyRemoveBlacklistedRolePermissionProposalHandler) ProposalType() string { - return kiratypes.RemoveBlacklistedRolePermissionProposalType -} - -func (c ApplyRemoveBlacklistedRolePermissionProposalHandler) Apply(ctx sdk.Context, proposalID uint64, proposal types.Content, slash sdk.Dec) error { - p := proposal.(*types.RemoveBlacklistedRolePermissionProposal) - - roleId, err := c.keeper.GetRoleIdFromIdentifierString(ctx, p.RoleSid) - if err != nil { - return err - } - - return c.keeper.RemoveBlacklistRolePermission(ctx, roleId, p.Permission) -} - -type SetProposalDurationsProposalHandler struct { - keeper keeper.Keeper -} - -func NewApplySetProposalDurationsProposalHandler(keeper keeper.Keeper) *SetProposalDurationsProposalHandler { - return &SetProposalDurationsProposalHandler{keeper: keeper} -} - -func (c SetProposalDurationsProposalHandler) ProposalType() string { - return kiratypes.SetProposalDurationsProposalType -} - -func (c SetProposalDurationsProposalHandler) Apply(ctx sdk.Context, proposalID uint64, proposal types.Content, slash sdk.Dec) error { - p := proposal.(*types.SetProposalDurationsProposal) - for i, pt := range p.TypeofProposals { - err := c.keeper.SetProposalDuration(ctx, pt, p.ProposalDurations[i]) - if err != nil { - return nil - } - } - return nil -} - -type ApplyResetWholeCouncilorRankProposalHandler struct { - keeper keeper.Keeper -} - -func NewApplyResetWholeCouncilorRankProposalHandler(keeper keeper.Keeper) *ApplyResetWholeCouncilorRankProposalHandler { - return &ApplyResetWholeCouncilorRankProposalHandler{ - keeper: keeper, - } -} - -func (a ApplyResetWholeCouncilorRankProposalHandler) ProposalType() string { - return kiratypes.ProposalTypeResetWholeCouncilorRank -} - -func (a ApplyResetWholeCouncilorRankProposalHandler) Apply(ctx sdk.Context, proposalID uint64, proposal types.Content, slash sdk.Dec) error { - _ = proposal.(*types.ProposalResetWholeCouncilorRank) - a.keeper.ResetWholeCouncilorRank(ctx) - return nil -} - -type ApplyJailCouncilorProposalHandler struct { - keeper keeper.Keeper -} - -func NewApplyJailCouncilorProposalHandler(keeper keeper.Keeper) *ApplyJailCouncilorProposalHandler { - return &ApplyJailCouncilorProposalHandler{ - keeper: keeper, - } -} - -func (a ApplyJailCouncilorProposalHandler) ProposalType() string { - return kiratypes.ProposalTypeJailCouncilor -} - -func (a ApplyJailCouncilorProposalHandler) Apply(ctx sdk.Context, proposalID uint64, proposal types.Content, slash sdk.Dec) error { - p := proposal.(*types.ProposalJailCouncilor) - for _, councilor := range p.Councilors { - addr, err := sdk.AccAddressFromBech32(councilor) - if err != nil { - return err - } - a.keeper.OnCouncilorJail(ctx, addr) - } - return nil -} +package gov + +import ( + "fmt" + + kiratypes "github.com/KiraCore/sekai/types" + "github.com/KiraCore/sekai/x/gov/keeper" + "github.com/KiraCore/sekai/x/gov/types" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/pkg/errors" +) + +type ApplyWhitelistAccountPermissionProposalHandler struct { + keeper keeper.Keeper +} + +func NewApplyWhitelistAccountPermissionProposalHandler(keeper keeper.Keeper) *ApplyWhitelistAccountPermissionProposalHandler { + return &ApplyWhitelistAccountPermissionProposalHandler{keeper: keeper} +} + +func (a ApplyWhitelistAccountPermissionProposalHandler) ProposalType() string { + return kiratypes.WhitelistAccountPermissionProposalType +} + +func (a ApplyWhitelistAccountPermissionProposalHandler) Apply(ctx sdk.Context, proposalID uint64, proposal types.Content, slash sdk.Dec) error { + p := proposal.(*types.WhitelistAccountPermissionProposal) + + actor, found := a.keeper.GetNetworkActorByAddress(ctx, p.Address) + if found { + if actor.Permissions.IsWhitelisted(types.PermValue(p.Permission)) { + return sdkerrors.Wrap(types.ErrWhitelisting, "permission already whitelisted") + } + } else { + actor = types.NewDefaultActor(p.Address) + } + + return a.keeper.AddWhitelistPermission(ctx, actor, types.PermValue(p.Permission)) +} + +type ApplyBlacklistAccountPermissionProposalHandler struct { + keeper keeper.Keeper +} + +func NewApplyBlacklistAccountPermissionProposalHandler(keeper keeper.Keeper) *ApplyBlacklistAccountPermissionProposalHandler { + return &ApplyBlacklistAccountPermissionProposalHandler{keeper: keeper} +} + +func (a ApplyBlacklistAccountPermissionProposalHandler) ProposalType() string { + return kiratypes.BlacklistAccountPermissionProposalType +} + +func (a ApplyBlacklistAccountPermissionProposalHandler) Apply(ctx sdk.Context, proposalID uint64, proposal types.Content, slash sdk.Dec) error { + p := proposal.(*types.BlacklistAccountPermissionProposal) + + actor, found := a.keeper.GetNetworkActorByAddress(ctx, p.Address) + if found { + if actor.Permissions.IsBlacklisted(types.PermValue(p.Permission)) { + return sdkerrors.Wrap(types.ErrWhitelisting, "permission already blacklisted") + } + } else { + actor = types.NewDefaultActor(p.Address) + } + + return a.keeper.AddBlacklistPermission(ctx, actor, types.PermValue(p.Permission)) +} + +type ApplyRemoveWhitelistedAccountPermissionProposalHandler struct { + keeper keeper.Keeper +} + +func NewApplyRemoveWhitelistedAccountPermissionProposalHandler(keeper keeper.Keeper) *ApplyRemoveWhitelistedAccountPermissionProposalHandler { + return &ApplyRemoveWhitelistedAccountPermissionProposalHandler{keeper: keeper} +} + +func (a ApplyRemoveWhitelistedAccountPermissionProposalHandler) ProposalType() string { + return kiratypes.RemoveWhitelistedAccountPermissionProposalType +} + +func (a ApplyRemoveWhitelistedAccountPermissionProposalHandler) Apply(ctx sdk.Context, proposalID uint64, proposal types.Content, slash sdk.Dec) error { + p := proposal.(*types.RemoveWhitelistedAccountPermissionProposal) + + actor, found := a.keeper.GetNetworkActorByAddress(ctx, p.Address) + if found { + if !actor.Permissions.IsWhitelisted(types.PermValue(p.Permission)) { + return sdkerrors.Wrap(types.ErrWhitelisting, "whitelisted permission does not exist") + } + } else { + actor = types.NewDefaultActor(p.Address) + } + + return a.keeper.RemoveWhitelistedPermission(ctx, actor, types.PermValue(p.Permission)) +} + +type ApplyRemoveBlacklistedAccountPermissionProposalHandler struct { + keeper keeper.Keeper +} + +func NewApplyRemoveBlacklistedAccountPermissionProposalHandler(keeper keeper.Keeper) *ApplyRemoveBlacklistedAccountPermissionProposalHandler { + return &ApplyRemoveBlacklistedAccountPermissionProposalHandler{keeper: keeper} +} + +func (a ApplyRemoveBlacklistedAccountPermissionProposalHandler) ProposalType() string { + return kiratypes.RemoveBlacklistedAccountPermissionProposalType +} + +func (a ApplyRemoveBlacklistedAccountPermissionProposalHandler) Apply(ctx sdk.Context, proposalID uint64, proposal types.Content, slash sdk.Dec) error { + p := proposal.(*types.RemoveBlacklistedAccountPermissionProposal) + + actor, found := a.keeper.GetNetworkActorByAddress(ctx, p.Address) + fmt.Println("actor", actor) + if found { + if !actor.Permissions.IsBlacklisted(types.PermValue(p.Permission)) { + return sdkerrors.Wrap(types.ErrWhitelisting, "blacklisted permission does not exist") + } + } else { + actor = types.NewDefaultActor(p.Address) + } + + fmt.Println("RemoveBlacklistedPermission", p.Permission) + return a.keeper.RemoveBlacklistedPermission(ctx, actor, types.PermValue(p.Permission)) +} + +type ApplyAssignRoleToAccountProposalHandler struct { + keeper keeper.Keeper +} + +func NewApplyAssignRoleToAccountProposalHandler(keeper keeper.Keeper) *ApplyAssignRoleToAccountProposalHandler { + return &ApplyAssignRoleToAccountProposalHandler{keeper: keeper} +} + +func (a ApplyAssignRoleToAccountProposalHandler) ProposalType() string { + return kiratypes.AssignRoleToAccountProposalType +} + +func (a ApplyAssignRoleToAccountProposalHandler) Apply(ctx sdk.Context, proposalID uint64, proposal types.Content, slash sdk.Dec) error { + p := proposal.(*types.AssignRoleToAccountProposal) + + roleId, err := a.keeper.GetRoleIdFromIdentifierString(ctx, p.RoleIdentifier) + if err != nil { + return err + } + + return a.keeper.AssignRoleToAccount(ctx, p.Address, roleId) +} + +type ApplyUnassignRoleFromAccountProposalHandler struct { + keeper keeper.Keeper +} + +func NewApplyUnassignRoleFromAccountProposalHandler(keeper keeper.Keeper) *ApplyUnassignRoleFromAccountProposalHandler { + return &ApplyUnassignRoleFromAccountProposalHandler{keeper: keeper} +} + +func (a ApplyUnassignRoleFromAccountProposalHandler) ProposalType() string { + return kiratypes.UnassignRoleFromAccountProposalType +} + +func (a ApplyUnassignRoleFromAccountProposalHandler) Apply(ctx sdk.Context, proposalID uint64, proposal types.Content, slash sdk.Dec) error { + p := proposal.(*types.UnassignRoleFromAccountProposal) + + roleId, err := a.keeper.GetRoleIdFromIdentifierString(ctx, p.RoleIdentifier) + if err != nil { + return err + } + + return a.keeper.UnassignRoleFromAccount(ctx, p.Address, roleId) +} + +type ApplySetNetworkPropertyProposalHandler struct { + keeper keeper.Keeper +} + +func NewApplySetNetworkPropertyProposalHandler(keeper keeper.Keeper) *ApplySetNetworkPropertyProposalHandler { + return &ApplySetNetworkPropertyProposalHandler{keeper: keeper} +} + +func (a ApplySetNetworkPropertyProposalHandler) ProposalType() string { + return kiratypes.SetNetworkPropertyProposalType +} + +func (a ApplySetNetworkPropertyProposalHandler) Apply(ctx sdk.Context, proposalID uint64, proposal types.Content, slash sdk.Dec) error { + p := proposal.(*types.SetNetworkPropertyProposal) + + property, err := a.keeper.GetNetworkProperty(ctx, p.NetworkProperty) + if err != nil { + return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, err.Error()) + } + if property == p.Value { + return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "network property already set as proposed value") + } + + return a.keeper.SetNetworkProperty(ctx, p.NetworkProperty, p.Value) +} + +type ApplyUpsertDataRegistryProposalHandler struct { + keeper keeper.Keeper +} + +func NewApplyUpsertDataRegistryProposalHandler(keeper keeper.Keeper) *ApplyUpsertDataRegistryProposalHandler { + return &ApplyUpsertDataRegistryProposalHandler{keeper: keeper} +} + +func (a ApplyUpsertDataRegistryProposalHandler) ProposalType() string { + return kiratypes.UpsertDataRegistryProposalType +} + +func (a ApplyUpsertDataRegistryProposalHandler) Apply(ctx sdk.Context, proposalID uint64, proposal types.Content, slash sdk.Dec) error { + p := proposal.(*types.UpsertDataRegistryProposal) + entry := types.NewDataRegistryEntry(p.Hash, p.Reference, p.Encoding, p.Size_) + a.keeper.UpsertDataRegistryEntry(ctx, p.Key, entry) + return nil +} + +type ApplySetPoorNetworkMessagesProposalHandler struct { + keeper keeper.Keeper +} + +func NewApplySetPoorNetworkMessagesProposalHandler(keeper keeper.Keeper) *ApplySetPoorNetworkMessagesProposalHandler { + return &ApplySetPoorNetworkMessagesProposalHandler{keeper: keeper} +} + +func (a ApplySetPoorNetworkMessagesProposalHandler) ProposalType() string { + return kiratypes.SetPoorNetworkMessagesProposalType +} + +func (a ApplySetPoorNetworkMessagesProposalHandler) Apply(ctx sdk.Context, proposalID uint64, proposal types.Content, slash sdk.Dec) error { + p := proposal.(*types.SetPoorNetworkMessagesProposal) + msgs := types.AllowedMessages{Messages: p.Messages} + a.keeper.SavePoorNetworkMessages(ctx, &msgs) + return nil +} + +type CreateRoleProposalHandler struct { + keeper keeper.Keeper +} + +func NewApplyCreateRoleProposalHandler(keeper keeper.Keeper) *CreateRoleProposalHandler { + return &CreateRoleProposalHandler{keeper: keeper} +} + +func (c CreateRoleProposalHandler) ProposalType() string { + return kiratypes.CreateRoleProposalType +} + +func (c CreateRoleProposalHandler) Apply(ctx sdk.Context, proposalID uint64, proposal types.Content, slash sdk.Dec) error { + p := proposal.(*types.CreateRoleProposal) + + // check sid is good variable naming form + if !keeper.ValidateRoleSidKey(p.RoleSid) { + return errors.Wrap(types.ErrInvalidRoleSid, fmt.Sprintf("invalid role sid configuration: sid=%s", p.RoleSid)) + } + + _, err := c.keeper.GetRoleBySid(ctx, p.RoleSid) + if err == nil { + return types.ErrRoleExist + } + + roleId := c.keeper.CreateRole(ctx, p.RoleSid, p.RoleDescription) + + for _, w := range p.WhitelistedPermissions { + err := c.keeper.WhitelistRolePermission(ctx, roleId, w) + if err != nil { + return err + } + } + + for _, b := range p.BlacklistedPermissions { + err := c.keeper.BlacklistRolePermission(ctx, roleId, b) + if err != nil { + return err + } + } + return nil +} + +type ApplyRemoveRoleProposalHandler struct { + keeper keeper.Keeper +} + +func NewApplyRemoveRoleProposalHandler(keeper keeper.Keeper) *ApplyRemoveRoleProposalHandler { + return &ApplyRemoveRoleProposalHandler{keeper: keeper} +} + +func (c ApplyRemoveRoleProposalHandler) ProposalType() string { + return kiratypes.RemoveRoleProposalType +} + +func (c ApplyRemoveRoleProposalHandler) Apply(ctx sdk.Context, proposalID uint64, proposal types.Content, slash sdk.Dec) error { + p := proposal.(*types.RemoveRoleProposal) + _ = p + return fmt.Errorf("remove role proposal is not implemented!") +} + +type ApplyWhitelistRolePermissionProposalHandler struct { + keeper keeper.Keeper +} + +func NewApplyWhitelistRolePermissionProposalHandler(keeper keeper.Keeper) *ApplyWhitelistRolePermissionProposalHandler { + return &ApplyWhitelistRolePermissionProposalHandler{keeper: keeper} +} + +func (c ApplyWhitelistRolePermissionProposalHandler) ProposalType() string { + return kiratypes.WhitelistRolePermissionProposalType +} + +func (c ApplyWhitelistRolePermissionProposalHandler) Apply(ctx sdk.Context, proposalID uint64, proposal types.Content, slash sdk.Dec) error { + p := proposal.(*types.WhitelistRolePermissionProposal) + + roleId, err := c.keeper.GetRoleIdFromIdentifierString(ctx, p.RoleIdentifier) + if err != nil { + return err + } + + return c.keeper.WhitelistRolePermission(ctx, roleId, p.Permission) +} + +type ApplyBlacklistRolePermissionProposalHandler struct { + keeper keeper.Keeper +} + +func NewApplyBlacklistRolePermissionProposalHandler(keeper keeper.Keeper) *ApplyBlacklistRolePermissionProposalHandler { + return &ApplyBlacklistRolePermissionProposalHandler{keeper: keeper} +} + +func (c ApplyBlacklistRolePermissionProposalHandler) ProposalType() string { + return kiratypes.BlacklistRolePermissionProposalType +} + +func (c ApplyBlacklistRolePermissionProposalHandler) Apply(ctx sdk.Context, proposalID uint64, proposal types.Content, slash sdk.Dec) error { + p := proposal.(*types.BlacklistRolePermissionProposal) + + roleId, err := c.keeper.GetRoleIdFromIdentifierString(ctx, p.RoleIdentifier) + if err != nil { + return err + } + + return c.keeper.BlacklistRolePermission(ctx, roleId, p.Permission) +} + +type ApplyRemoveWhitelistedRolePermissionProposalHandler struct { + keeper keeper.Keeper +} + +func NewApplyRemoveWhitelistedRolePermissionProposalHandler(keeper keeper.Keeper) *ApplyRemoveWhitelistedRolePermissionProposalHandler { + return &ApplyRemoveWhitelistedRolePermissionProposalHandler{keeper: keeper} +} + +func (c ApplyRemoveWhitelistedRolePermissionProposalHandler) ProposalType() string { + return kiratypes.RemoveWhitelistedRolePermissionProposalType +} + +func (c ApplyRemoveWhitelistedRolePermissionProposalHandler) Apply(ctx sdk.Context, proposalID uint64, proposal types.Content, slash sdk.Dec) error { + p := proposal.(*types.RemoveWhitelistedRolePermissionProposal) + + roleId, err := c.keeper.GetRoleIdFromIdentifierString(ctx, p.RoleSid) + if err != nil { + return err + } + + return c.keeper.RemoveWhitelistRolePermission(ctx, roleId, p.Permission) +} + +type ApplyRemoveBlacklistedRolePermissionProposalHandler struct { + keeper keeper.Keeper +} + +func NewApplyRemoveBlacklistedRolePermissionProposalHandler(keeper keeper.Keeper) *ApplyRemoveBlacklistedRolePermissionProposalHandler { + return &ApplyRemoveBlacklistedRolePermissionProposalHandler{keeper: keeper} +} + +func (c ApplyRemoveBlacklistedRolePermissionProposalHandler) ProposalType() string { + return kiratypes.RemoveBlacklistedRolePermissionProposalType +} + +func (c ApplyRemoveBlacklistedRolePermissionProposalHandler) Apply(ctx sdk.Context, proposalID uint64, proposal types.Content, slash sdk.Dec) error { + p := proposal.(*types.RemoveBlacklistedRolePermissionProposal) + + roleId, err := c.keeper.GetRoleIdFromIdentifierString(ctx, p.RoleSid) + if err != nil { + return err + } + + return c.keeper.RemoveBlacklistRolePermission(ctx, roleId, p.Permission) +} + +type SetProposalDurationsProposalHandler struct { + keeper keeper.Keeper +} + +func NewApplySetProposalDurationsProposalHandler(keeper keeper.Keeper) *SetProposalDurationsProposalHandler { + return &SetProposalDurationsProposalHandler{keeper: keeper} +} + +func (c SetProposalDurationsProposalHandler) ProposalType() string { + return kiratypes.SetProposalDurationsProposalType +} + +func (c SetProposalDurationsProposalHandler) Apply(ctx sdk.Context, proposalID uint64, proposal types.Content, slash sdk.Dec) error { + p := proposal.(*types.SetProposalDurationsProposal) + for i, pt := range p.TypeofProposals { + err := c.keeper.SetProposalDuration(ctx, pt, p.ProposalDurations[i]) + if err != nil { + return nil + } + } + return nil +} + +type ApplyResetWholeCouncilorRankProposalHandler struct { + keeper keeper.Keeper +} + +func NewApplyResetWholeCouncilorRankProposalHandler(keeper keeper.Keeper) *ApplyResetWholeCouncilorRankProposalHandler { + return &ApplyResetWholeCouncilorRankProposalHandler{ + keeper: keeper, + } +} + +func (a ApplyResetWholeCouncilorRankProposalHandler) ProposalType() string { + return kiratypes.ProposalTypeResetWholeCouncilorRank +} + +func (a ApplyResetWholeCouncilorRankProposalHandler) Apply(ctx sdk.Context, proposalID uint64, proposal types.Content, slash sdk.Dec) error { + _ = proposal.(*types.ProposalResetWholeCouncilorRank) + a.keeper.ResetWholeCouncilorRank(ctx) + return nil +} + +type ApplyJailCouncilorProposalHandler struct { + keeper keeper.Keeper +} + +func NewApplyJailCouncilorProposalHandler(keeper keeper.Keeper) *ApplyJailCouncilorProposalHandler { + return &ApplyJailCouncilorProposalHandler{ + keeper: keeper, + } +} + +func (a ApplyJailCouncilorProposalHandler) ProposalType() string { + return kiratypes.ProposalTypeJailCouncilor +} + +func (a ApplyJailCouncilorProposalHandler) Apply(ctx sdk.Context, proposalID uint64, proposal types.Content, slash sdk.Dec) error { + p := proposal.(*types.ProposalJailCouncilor) + for _, councilor := range p.Councilors { + addr, err := sdk.AccAddressFromBech32(councilor) + if err != nil { + return err + } + a.keeper.OnCouncilorJail(ctx, addr) + } + return nil +} diff --git a/x/gov/types/actor.go b/x/gov/types/actor.go index 00d588e76..d8d842d7a 100644 --- a/x/gov/types/actor.go +++ b/x/gov/types/actor.go @@ -1,105 +1,105 @@ -package types - -import "github.com/cosmos/cosmos-sdk/types" - -func NewNetworkActor( - addr types.AccAddress, - roleIds []uint64, - status ActorStatus, - votes []VoteOption, - perm *Permissions, - skin uint64, -) NetworkActor { - return NetworkActor{ - Address: addr, - Roles: roleIds, - Status: status, - Votes: votes, - Permissions: perm, - Skin: skin, - } -} - -func (m *NetworkActor) HasRole(role uint64) bool { - for _, r := range m.Roles { - if r == uint64(role) { - return true - } - } - return false -} - -func (m *NetworkActor) SetRole(role uint64) { - if !m.HasRole(role) { - m.Roles = append(m.Roles, uint64(role)) - } -} - -func (m *NetworkActor) RemoveRole(role uint64) { - for i, r := range m.Roles { - if r == role { - m.Roles = append(m.Roles[:i], m.Roles[i+1:]...) - return - } - } -} - -func (m *NetworkActor) IsActive() bool { - return m.Status == Active -} - -func (m *NetworkActor) IsInactive() bool { - return m.Status == Inactive -} - -// Deactivate the actor -func (m *NetworkActor) Deactivate() { - m.Status = Inactive -} - -// CanVote returns if the actor can vote a specific vote option. -func (m *NetworkActor) CanVote(voteOption VoteOption) bool { - for _, v := range m.Votes { - if v == voteOption { - return true - } - } - - return false -} - -// NewDefaultActor returns a default actor with: -// - The provided addr. -// - Roles set to nil -// - Status set to 0 -// - Votes set to nil -// - Empty permissions -// - Skin set to 0 -func NewDefaultActor(addr types.AccAddress) NetworkActor { - return NewNetworkActor( - addr, - nil, - Active, - []VoteOption{ - OptionYes, - OptionNo, - OptionAbstain, - OptionNoWithVeto, - }, - NewPermissions(nil, nil), - 0, - ) -} - -// GetActorsWithVoteWithVeto returns the actors that have permission to vote with Veto from a list of network actors. -func GetActorsWithVoteWithVeto(actors []NetworkActor) []NetworkActor { - var actorsWithVeto []NetworkActor - - for _, actor := range actors { - if actor.CanVote(OptionNoWithVeto) { - actorsWithVeto = append(actorsWithVeto, actor) - } - } - - return actorsWithVeto -} +package types + +import "github.com/cosmos/cosmos-sdk/types" + +func NewNetworkActor( + addr types.AccAddress, + roleIds []uint64, + status ActorStatus, + votes []VoteOption, + perm *Permissions, + skin uint64, +) NetworkActor { + return NetworkActor{ + Address: addr, + Roles: roleIds, + Status: status, + Votes: votes, + Permissions: perm, + Skin: skin, + } +} + +func (m *NetworkActor) HasRole(role uint64) bool { + for _, r := range m.Roles { + if r == uint64(role) { + return true + } + } + return false +} + +func (m *NetworkActor) SetRole(role uint64) { + if !m.HasRole(role) { + m.Roles = append(m.Roles, uint64(role)) + } +} + +func (m *NetworkActor) RemoveRole(role uint64) { + for i, r := range m.Roles { + if r == role { + m.Roles = append(m.Roles[:i], m.Roles[i+1:]...) + return + } + } +} + +func (m *NetworkActor) IsActive() bool { + return m.Status == Active +} + +func (m *NetworkActor) IsInactive() bool { + return m.Status == Inactive +} + +// Deactivate the actor +func (m *NetworkActor) Deactivate() { + m.Status = Inactive +} + +// CanVote returns if the actor can vote a specific vote option. +func (m *NetworkActor) CanVote(voteOption VoteOption) bool { + for _, v := range m.Votes { + if v == voteOption { + return true + } + } + + return false +} + +// NewDefaultActor returns a default actor with: +// - The provided addr. +// - Roles set to nil +// - Status set to 0 +// - Votes set to nil +// - Empty permissions +// - Skin set to 0 +func NewDefaultActor(addr types.AccAddress) NetworkActor { + return NewNetworkActor( + addr, + nil, + Active, + []VoteOption{ + OptionYes, + OptionNo, + OptionAbstain, + OptionNoWithVeto, + }, + NewPermissions(nil, nil), + 0, + ) +} + +// GetActorsWithVoteWithVeto returns the actors that have permission to vote with Veto from a list of network actors. +func GetActorsWithVoteWithVeto(actors []NetworkActor) []NetworkActor { + var actorsWithVeto []NetworkActor + + for _, actor := range actors { + if actor.CanVote(OptionNoWithVeto) { + actorsWithVeto = append(actorsWithVeto, actor) + } + } + + return actorsWithVeto +} diff --git a/x/gov/types/actor_test.go b/x/gov/types/actor_test.go index 3bea70cd9..d80c2e6f3 100644 --- a/x/gov/types/actor_test.go +++ b/x/gov/types/actor_test.go @@ -1,98 +1,98 @@ -package types_test - -import ( - "testing" - - "github.com/KiraCore/sekai/x/gov/types" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/require" -) - -// -// NETWORK ACTOR -// -func TestNewNetworkActor_SetRole(t *testing.T) { - addr, err := sdk.AccAddressFromBech32("kira1q24436yrnettd6v4eu6r4t9gycnnddack4jr5r") - require.NoError(t, err) - - actor := types.NewDefaultActor(addr) - require.False(t, actor.HasRole(types.RoleValidator)) - - actor.SetRole(types.RoleValidator) - - require.True(t, actor.HasRole(types.RoleValidator)) -} - -func TestNewNetworkActor_RemoveRole(t *testing.T) { - addr, err := sdk.AccAddressFromBech32("kira1q24436yrnettd6v4eu6r4t9gycnnddack4jr5r") - require.NoError(t, err) - - actor := types.NewDefaultActor(addr) - actor.SetRole(types.RoleValidator) - actor.SetRole(types.RoleSudo) - require.True(t, actor.HasRole(types.RoleValidator)) - require.True(t, actor.HasRole(types.RoleSudo)) - - actor.RemoveRole(types.RoleSudo) - require.True(t, actor.HasRole(types.RoleValidator)) - require.False(t, actor.HasRole(types.RoleSudo)) -} - -func TestNewNetworkActor_Status(t *testing.T) { - addr, err := sdk.AccAddressFromBech32("kira1q24436yrnettd6v4eu6r4t9gycnnddack4jr5r") - require.NoError(t, err) - - actor := types.NewDefaultActor(addr) - require.Equal(t, types.Active, actor.Status) - - // Active Actor - actor = types.NewNetworkActor( - addr, - []uint64{}, - types.Active, - []types.VoteOption{}, - types.NewPermissions(nil, nil), - 1, - ) - - require.True(t, actor.IsActive()) - actor.Deactivate() - require.False(t, actor.IsActive()) - require.True(t, actor.IsInactive()) -} - -func TestNewDefaultActor_CanVote(t *testing.T) { - actor := types.NewNetworkActor( - sdk.AccAddress{0x0}, - []uint64{}, - types.Active, - []types.VoteOption{types.OptionYes, types.OptionAbstain}, - nil, - 123, - ) - - require.True(t, actor.CanVote(types.OptionYes)) - require.True(t, actor.CanVote(types.OptionAbstain)) - require.False(t, actor.CanVote(types.OptionNo)) - require.False(t, actor.CanVote(types.OptionNoWithVeto)) -} - -func TestGetVetoActorsFromList(t *testing.T) { - actors := []types.NetworkActor{ - types.NewNetworkActor(sdk.AccAddress{0x0}, []uint64{}, types.Active, []types.VoteOption{types.OptionAbstain}, nil, 123), - types.NewNetworkActor(sdk.AccAddress{0x1}, []uint64{}, types.Active, []types.VoteOption{types.OptionAbstain, types.OptionNoWithVeto}, nil, 123), - types.NewNetworkActor(sdk.AccAddress{0x2}, []uint64{}, types.Active, []types.VoteOption{types.OptionAbstain}, nil, 123), - types.NewNetworkActor(sdk.AccAddress{0x3}, []uint64{}, types.Active, []types.VoteOption{types.OptionAbstain}, nil, 123), - types.NewNetworkActor(sdk.AccAddress{0x4}, []uint64{}, types.Active, []types.VoteOption{types.OptionAbstain}, nil, 123), - types.NewNetworkActor(sdk.AccAddress{0x5}, []uint64{}, types.Active, []types.VoteOption{types.OptionAbstain}, nil, 123), - types.NewNetworkActor(sdk.AccAddress{0x6}, []uint64{}, types.Active, []types.VoteOption{types.OptionAbstain}, nil, 123), - types.NewNetworkActor(sdk.AccAddress{0x7}, []uint64{}, types.Active, []types.VoteOption{types.OptionAbstain, types.OptionNoWithVeto}, nil, 123), - types.NewNetworkActor(sdk.AccAddress{0x8}, []uint64{}, types.Active, []types.VoteOption{types.OptionAbstain}, nil, 123), - types.NewNetworkActor(sdk.AccAddress{0x9}, []uint64{}, types.Active, []types.VoteOption{types.OptionAbstain}, nil, 123), - } - - actorsWithVeto := types.GetActorsWithVoteWithVeto(actors) - require.Equal(t, actorsWithVeto[0], actors[1]) - require.Equal(t, actorsWithVeto[1], actors[7]) - require.Len(t, actorsWithVeto, 2) -} +package types_test + +import ( + "testing" + + "github.com/KiraCore/sekai/x/gov/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" +) + +// +// NETWORK ACTOR +// +func TestNewNetworkActor_SetRole(t *testing.T) { + addr, err := sdk.AccAddressFromBech32("kira1q24436yrnettd6v4eu6r4t9gycnnddack4jr5r") + require.NoError(t, err) + + actor := types.NewDefaultActor(addr) + require.False(t, actor.HasRole(types.RoleValidator)) + + actor.SetRole(types.RoleValidator) + + require.True(t, actor.HasRole(types.RoleValidator)) +} + +func TestNewNetworkActor_RemoveRole(t *testing.T) { + addr, err := sdk.AccAddressFromBech32("kira1q24436yrnettd6v4eu6r4t9gycnnddack4jr5r") + require.NoError(t, err) + + actor := types.NewDefaultActor(addr) + actor.SetRole(types.RoleValidator) + actor.SetRole(types.RoleSudo) + require.True(t, actor.HasRole(types.RoleValidator)) + require.True(t, actor.HasRole(types.RoleSudo)) + + actor.RemoveRole(types.RoleSudo) + require.True(t, actor.HasRole(types.RoleValidator)) + require.False(t, actor.HasRole(types.RoleSudo)) +} + +func TestNewNetworkActor_Status(t *testing.T) { + addr, err := sdk.AccAddressFromBech32("kira1q24436yrnettd6v4eu6r4t9gycnnddack4jr5r") + require.NoError(t, err) + + actor := types.NewDefaultActor(addr) + require.Equal(t, types.Active, actor.Status) + + // Active Actor + actor = types.NewNetworkActor( + addr, + []uint64{}, + types.Active, + []types.VoteOption{}, + types.NewPermissions(nil, nil), + 1, + ) + + require.True(t, actor.IsActive()) + actor.Deactivate() + require.False(t, actor.IsActive()) + require.True(t, actor.IsInactive()) +} + +func TestNewDefaultActor_CanVote(t *testing.T) { + actor := types.NewNetworkActor( + sdk.AccAddress{0x0}, + []uint64{}, + types.Active, + []types.VoteOption{types.OptionYes, types.OptionAbstain}, + nil, + 123, + ) + + require.True(t, actor.CanVote(types.OptionYes)) + require.True(t, actor.CanVote(types.OptionAbstain)) + require.False(t, actor.CanVote(types.OptionNo)) + require.False(t, actor.CanVote(types.OptionNoWithVeto)) +} + +func TestGetVetoActorsFromList(t *testing.T) { + actors := []types.NetworkActor{ + types.NewNetworkActor(sdk.AccAddress{0x0}, []uint64{}, types.Active, []types.VoteOption{types.OptionAbstain}, nil, 123), + types.NewNetworkActor(sdk.AccAddress{0x1}, []uint64{}, types.Active, []types.VoteOption{types.OptionAbstain, types.OptionNoWithVeto}, nil, 123), + types.NewNetworkActor(sdk.AccAddress{0x2}, []uint64{}, types.Active, []types.VoteOption{types.OptionAbstain}, nil, 123), + types.NewNetworkActor(sdk.AccAddress{0x3}, []uint64{}, types.Active, []types.VoteOption{types.OptionAbstain}, nil, 123), + types.NewNetworkActor(sdk.AccAddress{0x4}, []uint64{}, types.Active, []types.VoteOption{types.OptionAbstain}, nil, 123), + types.NewNetworkActor(sdk.AccAddress{0x5}, []uint64{}, types.Active, []types.VoteOption{types.OptionAbstain}, nil, 123), + types.NewNetworkActor(sdk.AccAddress{0x6}, []uint64{}, types.Active, []types.VoteOption{types.OptionAbstain}, nil, 123), + types.NewNetworkActor(sdk.AccAddress{0x7}, []uint64{}, types.Active, []types.VoteOption{types.OptionAbstain, types.OptionNoWithVeto}, nil, 123), + types.NewNetworkActor(sdk.AccAddress{0x8}, []uint64{}, types.Active, []types.VoteOption{types.OptionAbstain}, nil, 123), + types.NewNetworkActor(sdk.AccAddress{0x9}, []uint64{}, types.Active, []types.VoteOption{types.OptionAbstain}, nil, 123), + } + + actorsWithVeto := types.GetActorsWithVoteWithVeto(actors) + require.Equal(t, actorsWithVeto[0], actors[1]) + require.Equal(t, actorsWithVeto[1], actors[7]) + require.Len(t, actorsWithVeto, 2) +} diff --git a/x/gov/types/codec.go b/x/gov/types/codec.go index 83b1fe2ef..b98ccdcac 100644 --- a/x/gov/types/codec.go +++ b/x/gov/types/codec.go @@ -1,479 +1,479 @@ -package types - -import ( - functionmeta "github.com/KiraCore/sekai/function_meta" - "github.com/cosmos/cosmos-sdk/codec" - "github.com/cosmos/cosmos-sdk/codec/types" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/msgservice" -) - -// RegisterCodec register codec and metadata -func RegisterCodec(cdc *codec.LegacyAmino) { - cdc.RegisterInterface((*Content)(nil), nil) - - registerPermissionsCodec(cdc) - registerRolesCodec(cdc) - registerCouncilorCodec(cdc) - registerProposalCodec(cdc) - registerIdRecordsCodec(cdc) - - cdc.RegisterConcrete(&MsgSetNetworkProperties{}, "kiraHub/MsgSetNetworkProperties", nil) - functionmeta.AddNewFunction((&MsgSetNetworkProperties{}).Type(), `{ - "description": "MsgSetNetworkProperties defines a message to set network properties with specific permission.", - "parameters": { - "network_properties": { - "type": "", - "description": "network properties to be set.", - "fields": { - "min_tx_fee": { - "type": "uint64", - "description": "minimum transaction fee" - }, - "max_tx_fee": { - "type": "uint64", - "description": "maximum transaction fee" - }, - "vote_quorum": { - "type": "uint64", - "description": "vote quorum" - }, - "proposal_end_time": { - "type": "uint64", - "description": "proposal end time" - }, - "proposal_enactment_time": { - "type": "uint64", - "description": "proposal enactment time" - }, - "enable_foreign_fee_payments": { - "type": "bool", - "description": "flag to show if foreign fee payment is enabled" - } - } - }, - "proposer": { - "type": "address", - "description": "proposer who propose this message." - } - } - }`) - cdc.RegisterConcrete(&MsgSetExecutionFee{}, "kiraHub/MsgSetExecutionFee", nil) - functionmeta.AddNewFunction((&MsgSetExecutionFee{}).Type(), `{ - "description": "MsgSetExecutionFee defines a message to set execution fee with specific permission.", - "parameters": { - "transaction_type": { - "type": "string", - "description": "Type of the transaction that given permission allows to execute" - }, - "execution_fee": { - "type": "uint64", - "description": "How much user should pay for executing this specific function" - }, - "failure_fee": { - "type": "uint64", - "description": "How much user should pay if function fails to execute" - }, - "timeout": { - "type": "uint64", - "description": "After what time function execution should fail" - }, - "default_parameters": { - "type": "bool", - "description": "Default values that the function in question will consume as input parameters before execution" - }, - "proposer": { - "type": "address", - "description": "proposer who propose this message." - } - } - }`) -} - -func registerProposalCodec(cdc *codec.LegacyAmino) { - cdc.RegisterConcrete(&MsgSubmitProposal{}, "kiraHub/MsgSubmitProposal", nil) - functionmeta.AddNewFunction((&MsgSubmitProposal{}).Type(), `{ - "description": "MsgSubmitProposal defines a proposal message to submit a proposal.", - "parameters": { - "proposer": { - "type": "address", - "description": "the proposer of the proposal." - }, - "title": { - "type": "string", - "description": "the title of the proposal." - }, - "description": { - "type": "string", - "description": "the description of the proposal." - }, - "content": { - "type": "object", - "description": "the content of the proposal - different by type of proposal" - } - } - }`) - - cdc.RegisterConcrete(&MsgVoteProposal{}, "kiraHub/MsgVoteProposal", nil) - functionmeta.AddNewFunction((&MsgVoteProposal{}).Type(), `{ - "description": "MsgVoteProposal defines a proposal message to vote on a submitted proposal.", - "parameters": { - "proposal_id": { - "type": "uint64", - "description": "id of proposal to be voted." - }, - "voter": { - "type": "address", - "description": "the address of the voter who vote on the proposal." - }, - "value": { - "type": "enum", - "description": "vote option: [yes, no, veto, abstain]" - } - } - }`) -} - -func registerIdRecordsCodec(cdc *codec.LegacyAmino) { - cdc.RegisterConcrete(&MsgRegisterIdentityRecords{}, "kiraHub/MsgRegisterIdentityRecords", nil) - functionmeta.AddNewFunction((&MsgRegisterIdentityRecords{}).Type(), `{ - "description": "MsgRegisterIdentityRecords defines a proposal message to create a identity record.", - "parameters": { - "address": { - "type": "string", - "description": "the address for the identity record." - }, - "infos": { - "type": "array", - "description": "key/value array for the mappings of the identity record." - } - } - }`) - - cdc.RegisterConcrete(&MsgDeleteIdentityRecords{}, "kiraHub/MsgDeleteIdentityRecords", nil) - functionmeta.AddNewFunction((&MsgDeleteIdentityRecords{}).Type(), `{ - "description": "MsgDeleteIdentityRecords defines a method to delete identity records owned by an address.", - "parameters": { - "address": { - "type": "string", - "description": "the address of requester." - }, - "keys": { - "type": "array", - "description": "the array string that defines identity record key values to be deleted." - } - } - }`) - - cdc.RegisterConcrete(&MsgRequestIdentityRecordsVerify{}, "kiraHub/MsgRequestIdentityRecordsVerify", nil) - functionmeta.AddNewFunction((&MsgRequestIdentityRecordsVerify{}).Type(), `{ - "description": "MsgRequestIdentityRecordsVerify defines a proposal message to request an identity record verification from a specific verifier.", - "parameters": { - "address": { - "type": "string", - "description": "the address of requester." - }, - "verifier": { - "type": "string", - "description": "the address of verifier." - }, - "record_ids": { - "type": "array", - "description": "the id of records to be verified." - }, - "tip": { - "type": "coins", - "description": "the amount of coins to be given up-on accepting the request." - } - } - }`) - - cdc.RegisterConcrete(&MsgHandleIdentityRecordsVerifyRequest{}, "kiraHub/MsgHandleIdentityRecordsVerifyRequest", nil) - functionmeta.AddNewFunction((&MsgHandleIdentityRecordsVerifyRequest{}).Type(), `{ - "description": "MsgHandleIdentityRecordsVerifyRequest defines a proposal message to approve or reject an identity record request.", - "parameters": { - "verifier": { - "type": "string", - "description": "the address of verifier." - }, - "verify_request_id": { - "type": "uint64", - "description": "the id of verification request." - }, - "yes": { - "type": "bool", - "optional": true, - "description": "defines approval or rejecting an identity request (default false)" - } - } - }`) - - cdc.RegisterConcrete(&MsgCancelIdentityRecordsVerifyRequest{}, "kiraHub/MsgCancelIdentityRecordsVerifyRequest", nil) - functionmeta.AddNewFunction((&MsgCancelIdentityRecordsVerifyRequest{}).Type(), `{ - "description": "MsgCancelIdentityRecordsVerifyRequest defines a proposal message to cancel an identity record request.", - "parameters": { - "executor": { - "type": "string", - "description": "the address of requester." - }, - "verify_request_id": { - "type": "uint64", - "description": "the id of verification request." - } - } - }`) -} - -func registerCouncilorCodec(cdc *codec.LegacyAmino) { - cdc.RegisterConcrete(&MsgClaimCouncilor{}, "kiraHub/MsgClaimCouncilor", nil) - functionmeta.AddNewFunction((&MsgClaimCouncilor{}).Type(), `{ - "description": "MsgClaimCouncilor defines a message to claim councilor when the proposer.", - "parameters": { - "moniker": { - "type": "string", - "description": "validator's name or nickname." - }, - "address": { - "type": "string", - "description": "Address to be set as councilor. This address should be proposer address as well." - } - } - }`) -} - -func registerPermissionsCodec(cdc *codec.LegacyAmino) { - cdc.RegisterConcrete(&MsgWhitelistPermissions{}, "kiraHub/MsgWhitelistPermissions", nil) - functionmeta.AddNewFunction((&MsgWhitelistPermissions{}).Type(), `{ - "description": "MsgWhitelistPermissions defines a message to whitelist permission of an address.", - "parameters": { - "proposer": { - "type": "string", - "description": "proposer who propose this message." - }, - "address": { - "type": "string", - "description": "Address to whitelist permission to." - }, - "permission": { - "type": "uint32", - "description": "Permission to be whitelisted." - } - } - }`) - cdc.RegisterConcrete(&MsgBlacklistPermissions{}, "kiraHub/MsgBlacklistPermissions", nil) - functionmeta.AddNewFunction((&MsgBlacklistPermissions{}).Type(), `{ - "description": "MsgBlacklistPermissions defines a message to blacklist permission of an address.", - "parameters": { - "proposer": { - "type": "string", - "description": "proposer who propose this message." - }, - "address": { - "type": "string", - "description": "Address to blacklist permission to." - }, - "permission": { - "type": "uint32", - "description": "Permission to be blacklisted." - } - } - }`) -} - -func registerRolesCodec(cdc *codec.LegacyAmino) { - cdc.RegisterConcrete(&MsgCreateRole{}, "kiraHub/MsgCreateRole", nil) - functionmeta.AddNewFunction((&MsgCreateRole{}).Type(), `{ - "description": "MsgCreateRole defines a message to create a role.", - "parameters": { - "proposer": { - "type": "string", - "description": "proposer who propose this message." - }, - "role": { - "type": "uint32", - "description": "Identifier of this role." - } - } - }`) - cdc.RegisterConcrete(&MsgAssignRole{}, "kiraHub/MsgAssignRole", nil) - functionmeta.AddNewFunction((&MsgAssignRole{}).Type(), `{ - "description": "MsgAssignRole defines a message to assign a role to an address.", - "parameters": { - "proposer": { - "type": "string", - "description": "proposer who propose this message." - }, - "address": { - "type": "string", - "description": "Address to set role to." - }, - "role": { - "type": "uint32", - "description": "role identifier." - } - } - }`) - cdc.RegisterConcrete(&MsgRemoveRole{}, "kiraHub/MsgRemoveRole", nil) - functionmeta.AddNewFunction((&MsgRemoveRole{}).Type(), `{ - "description": "MsgRemoveRole defines a message to remove a role from an address.", - "parameters": { - "proposer": { - "type": "string", - "description": "proposer who propose this message." - }, - "address": { - "type": "string", - "description": "Address to remove role from." - }, - "role": { - "type": "uint32", - "description": "role identifier." - } - } - }`) - - cdc.RegisterConcrete(&MsgWhitelistRolePermission{}, "kiraHub/MsgWhitelistRolePermission", nil) - functionmeta.AddNewFunction((&MsgWhitelistRolePermission{}).Type(), `{ - "description": "MsgWhitelistRolePermission defines a message to whitelist permission for a role.", - "parameters": { - "proposer": { - "type": "string", - "description": "proposer who propose this message." - }, - "role": { - "type": "uint32", - "description": "role identifier." - }, - "permission": { - "type": "uint32", - "description": "Permission to be whitelisted." - } - } - }`) - cdc.RegisterConcrete(&MsgBlacklistRolePermission{}, "kiraHub/MsgBlacklistRolePermission", nil) - functionmeta.AddNewFunction((&MsgBlacklistRolePermission{}).Type(), `{ - "description": "MsgBlacklistRolePermission defines a message to blacklist permission for a role.", - "parameters": { - "proposer": { - "type": "string", - "description": "proposer who propose this message." - }, - "role": { - "type": "uint32", - "description": "role identifier." - }, - "permission": { - "type": "uint32", - "description": "Permission to be blacklisted." - } - } - }`) - cdc.RegisterConcrete(&MsgRemoveWhitelistRolePermission{}, "kiraHub/MsgRemoveWhitelistRolePermission", nil) - functionmeta.AddNewFunction((&MsgRemoveWhitelistRolePermission{}).Type(), `{ - "description": "MsgRemoveWhitelistRolePermission defines a message to remove whitelisted permission for a role.", - "parameters": { - "proposer": { - "type": "string", - "description": "proposer who propose this message." - }, - "role": { - "type": "uint32", - "description": "role identifier." - }, - "permission": { - "type": "uint32", - "description": "Permission to be removed from whitelisted listing." - } - } - }`) - cdc.RegisterConcrete(&MsgRemoveBlacklistRolePermission{}, "kiraHub/MsgRemoveBlacklistRolePermission", nil) - functionmeta.AddNewFunction((&MsgRemoveBlacklistRolePermission{}).Type(), `{ - "description": "MsgRemoveBlacklistRolePermission defines a message to remove blacklisted permission for a role.", - "parameters": { - "proposer": { - "type": "string", - "description": "proposer who propose this message." - }, - "role": { - "type": "uint32", - "description": "role identifier." - }, - "permission": { - "type": "uint32", - "description": "Permission to be removed from blacklisted listing." - } - } - }`) -} - -func RegisterInterfaces(registry types.InterfaceRegistry) { - registry.RegisterImplementations((*sdk.Msg)(nil), - &MsgWhitelistPermissions{}, - &MsgBlacklistPermissions{}, - - &MsgSetNetworkProperties{}, - &MsgSetExecutionFee{}, - - &MsgClaimCouncilor{}, - - &MsgAssignRole{}, - &MsgCreateRole{}, - &MsgRemoveRole{}, - - &MsgWhitelistRolePermission{}, - &MsgBlacklistRolePermission{}, - &MsgRemoveWhitelistRolePermission{}, - &MsgRemoveBlacklistRolePermission{}, - - &MsgSubmitProposal{}, - &MsgVoteProposal{}, - - &MsgRegisterIdentityRecords{}, - &MsgDeleteIdentityRecords{}, - &MsgRequestIdentityRecordsVerify{}, - &MsgHandleIdentityRecordsVerifyRequest{}, - &MsgCancelIdentityRecordsVerifyRequest{}, - ) - - registry.RegisterInterface( - "kira.gov.Content", - (*Content)(nil), - &WhitelistAccountPermissionProposal{}, - &BlacklistAccountPermissionProposal{}, - &RemoveWhitelistedAccountPermissionProposal{}, - &RemoveBlacklistedAccountPermissionProposal{}, - &AssignRoleToAccountProposal{}, - &UnassignRoleFromAccountProposal{}, - &SetNetworkPropertyProposal{}, - &UpsertDataRegistryProposal{}, - &SetPoorNetworkMessagesProposal{}, - &CreateRoleProposal{}, - &RemoveRoleProposal{}, - &WhitelistRolePermissionProposal{}, - &BlacklistRolePermissionProposal{}, - &RemoveWhitelistedRolePermissionProposal{}, - &RemoveBlacklistedRolePermissionProposal{}, - &SetProposalDurationsProposal{}, - &ProposalResetWholeCouncilorRank{}, - &ProposalJailCouncilor{}, - ) - - msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) -} - -var ( - amino = codec.NewLegacyAmino() - - // ModuleCdc references the global x/staking module codec. Note, the codec should - // ONLY be used in certain instances of tests and for JSON encoding as Amino is - // still used for that purpose. - // - // The actual codec used for serialization should be provided to x/staking and - // defined at the application level. - ModuleCdc = codec.NewAminoCodec(amino) -) - -func init() { - RegisterCodec(amino) - amino.Seal() -} +package types + +import ( + functionmeta "github.com/KiraCore/sekai/function_meta" + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/msgservice" +) + +// RegisterCodec register codec and metadata +func RegisterCodec(cdc *codec.LegacyAmino) { + cdc.RegisterInterface((*Content)(nil), nil) + + registerPermissionsCodec(cdc) + registerRolesCodec(cdc) + registerCouncilorCodec(cdc) + registerProposalCodec(cdc) + registerIdRecordsCodec(cdc) + + cdc.RegisterConcrete(&MsgSetNetworkProperties{}, "kiraHub/MsgSetNetworkProperties", nil) + functionmeta.AddNewFunction((&MsgSetNetworkProperties{}).Type(), `{ + "description": "MsgSetNetworkProperties defines a message to set network properties with specific permission.", + "parameters": { + "network_properties": { + "type": "", + "description": "network properties to be set.", + "fields": { + "min_tx_fee": { + "type": "uint64", + "description": "minimum transaction fee" + }, + "max_tx_fee": { + "type": "uint64", + "description": "maximum transaction fee" + }, + "vote_quorum": { + "type": "uint64", + "description": "vote quorum" + }, + "proposal_end_time": { + "type": "uint64", + "description": "proposal end time" + }, + "proposal_enactment_time": { + "type": "uint64", + "description": "proposal enactment time" + }, + "enable_foreign_fee_payments": { + "type": "bool", + "description": "flag to show if foreign fee payment is enabled" + } + } + }, + "proposer": { + "type": "address", + "description": "proposer who propose this message." + } + } + }`) + cdc.RegisterConcrete(&MsgSetExecutionFee{}, "kiraHub/MsgSetExecutionFee", nil) + functionmeta.AddNewFunction((&MsgSetExecutionFee{}).Type(), `{ + "description": "MsgSetExecutionFee defines a message to set execution fee with specific permission.", + "parameters": { + "transaction_type": { + "type": "string", + "description": "Type of the transaction that given permission allows to execute" + }, + "execution_fee": { + "type": "uint64", + "description": "How much user should pay for executing this specific function" + }, + "failure_fee": { + "type": "uint64", + "description": "How much user should pay if function fails to execute" + }, + "timeout": { + "type": "uint64", + "description": "After what time function execution should fail" + }, + "default_parameters": { + "type": "bool", + "description": "Default values that the function in question will consume as input parameters before execution" + }, + "proposer": { + "type": "address", + "description": "proposer who propose this message." + } + } + }`) +} + +func registerProposalCodec(cdc *codec.LegacyAmino) { + cdc.RegisterConcrete(&MsgSubmitProposal{}, "kiraHub/MsgSubmitProposal", nil) + functionmeta.AddNewFunction((&MsgSubmitProposal{}).Type(), `{ + "description": "MsgSubmitProposal defines a proposal message to submit a proposal.", + "parameters": { + "proposer": { + "type": "address", + "description": "the proposer of the proposal." + }, + "title": { + "type": "string", + "description": "the title of the proposal." + }, + "description": { + "type": "string", + "description": "the description of the proposal." + }, + "content": { + "type": "object", + "description": "the content of the proposal - different by type of proposal" + } + } + }`) + + cdc.RegisterConcrete(&MsgVoteProposal{}, "kiraHub/MsgVoteProposal", nil) + functionmeta.AddNewFunction((&MsgVoteProposal{}).Type(), `{ + "description": "MsgVoteProposal defines a proposal message to vote on a submitted proposal.", + "parameters": { + "proposal_id": { + "type": "uint64", + "description": "id of proposal to be voted." + }, + "voter": { + "type": "address", + "description": "the address of the voter who vote on the proposal." + }, + "value": { + "type": "enum", + "description": "vote option: [yes, no, veto, abstain]" + } + } + }`) +} + +func registerIdRecordsCodec(cdc *codec.LegacyAmino) { + cdc.RegisterConcrete(&MsgRegisterIdentityRecords{}, "kiraHub/MsgRegisterIdentityRecords", nil) + functionmeta.AddNewFunction((&MsgRegisterIdentityRecords{}).Type(), `{ + "description": "MsgRegisterIdentityRecords defines a proposal message to create a identity record.", + "parameters": { + "address": { + "type": "string", + "description": "the address for the identity record." + }, + "infos": { + "type": "array", + "description": "key/value array for the mappings of the identity record." + } + } + }`) + + cdc.RegisterConcrete(&MsgDeleteIdentityRecords{}, "kiraHub/MsgDeleteIdentityRecords", nil) + functionmeta.AddNewFunction((&MsgDeleteIdentityRecords{}).Type(), `{ + "description": "MsgDeleteIdentityRecords defines a method to delete identity records owned by an address.", + "parameters": { + "address": { + "type": "string", + "description": "the address of requester." + }, + "keys": { + "type": "array", + "description": "the array string that defines identity record key values to be deleted." + } + } + }`) + + cdc.RegisterConcrete(&MsgRequestIdentityRecordsVerify{}, "kiraHub/MsgRequestIdentityRecordsVerify", nil) + functionmeta.AddNewFunction((&MsgRequestIdentityRecordsVerify{}).Type(), `{ + "description": "MsgRequestIdentityRecordsVerify defines a proposal message to request an identity record verification from a specific verifier.", + "parameters": { + "address": { + "type": "string", + "description": "the address of requester." + }, + "verifier": { + "type": "string", + "description": "the address of verifier." + }, + "record_ids": { + "type": "array", + "description": "the id of records to be verified." + }, + "tip": { + "type": "coins", + "description": "the amount of coins to be given up-on accepting the request." + } + } + }`) + + cdc.RegisterConcrete(&MsgHandleIdentityRecordsVerifyRequest{}, "kiraHub/MsgHandleIdentityRecordsVerifyRequest", nil) + functionmeta.AddNewFunction((&MsgHandleIdentityRecordsVerifyRequest{}).Type(), `{ + "description": "MsgHandleIdentityRecordsVerifyRequest defines a proposal message to approve or reject an identity record request.", + "parameters": { + "verifier": { + "type": "string", + "description": "the address of verifier." + }, + "verify_request_id": { + "type": "uint64", + "description": "the id of verification request." + }, + "yes": { + "type": "bool", + "optional": true, + "description": "defines approval or rejecting an identity request (default false)" + } + } + }`) + + cdc.RegisterConcrete(&MsgCancelIdentityRecordsVerifyRequest{}, "kiraHub/MsgCancelIdentityRecordsVerifyRequest", nil) + functionmeta.AddNewFunction((&MsgCancelIdentityRecordsVerifyRequest{}).Type(), `{ + "description": "MsgCancelIdentityRecordsVerifyRequest defines a proposal message to cancel an identity record request.", + "parameters": { + "executor": { + "type": "string", + "description": "the address of requester." + }, + "verify_request_id": { + "type": "uint64", + "description": "the id of verification request." + } + } + }`) +} + +func registerCouncilorCodec(cdc *codec.LegacyAmino) { + cdc.RegisterConcrete(&MsgClaimCouncilor{}, "kiraHub/MsgClaimCouncilor", nil) + functionmeta.AddNewFunction((&MsgClaimCouncilor{}).Type(), `{ + "description": "MsgClaimCouncilor defines a message to claim councilor when the proposer.", + "parameters": { + "moniker": { + "type": "string", + "description": "validator's name or nickname." + }, + "address": { + "type": "string", + "description": "Address to be set as councilor. This address should be proposer address as well." + } + } + }`) +} + +func registerPermissionsCodec(cdc *codec.LegacyAmino) { + cdc.RegisterConcrete(&MsgWhitelistPermissions{}, "kiraHub/MsgWhitelistPermissions", nil) + functionmeta.AddNewFunction((&MsgWhitelistPermissions{}).Type(), `{ + "description": "MsgWhitelistPermissions defines a message to whitelist permission of an address.", + "parameters": { + "proposer": { + "type": "string", + "description": "proposer who propose this message." + }, + "address": { + "type": "string", + "description": "Address to whitelist permission to." + }, + "permission": { + "type": "uint32", + "description": "Permission to be whitelisted." + } + } + }`) + cdc.RegisterConcrete(&MsgBlacklistPermissions{}, "kiraHub/MsgBlacklistPermissions", nil) + functionmeta.AddNewFunction((&MsgBlacklistPermissions{}).Type(), `{ + "description": "MsgBlacklistPermissions defines a message to blacklist permission of an address.", + "parameters": { + "proposer": { + "type": "string", + "description": "proposer who propose this message." + }, + "address": { + "type": "string", + "description": "Address to blacklist permission to." + }, + "permission": { + "type": "uint32", + "description": "Permission to be blacklisted." + } + } + }`) +} + +func registerRolesCodec(cdc *codec.LegacyAmino) { + cdc.RegisterConcrete(&MsgCreateRole{}, "kiraHub/MsgCreateRole", nil) + functionmeta.AddNewFunction((&MsgCreateRole{}).Type(), `{ + "description": "MsgCreateRole defines a message to create a role.", + "parameters": { + "proposer": { + "type": "string", + "description": "proposer who propose this message." + }, + "role": { + "type": "uint32", + "description": "Identifier of this role." + } + } + }`) + cdc.RegisterConcrete(&MsgAssignRole{}, "kiraHub/MsgAssignRole", nil) + functionmeta.AddNewFunction((&MsgAssignRole{}).Type(), `{ + "description": "MsgAssignRole defines a message to assign a role to an address.", + "parameters": { + "proposer": { + "type": "string", + "description": "proposer who propose this message." + }, + "address": { + "type": "string", + "description": "Address to set role to." + }, + "role": { + "type": "uint32", + "description": "role identifier." + } + } + }`) + cdc.RegisterConcrete(&MsgRemoveRole{}, "kiraHub/MsgRemoveRole", nil) + functionmeta.AddNewFunction((&MsgRemoveRole{}).Type(), `{ + "description": "MsgRemoveRole defines a message to remove a role from an address.", + "parameters": { + "proposer": { + "type": "string", + "description": "proposer who propose this message." + }, + "address": { + "type": "string", + "description": "Address to remove role from." + }, + "role": { + "type": "uint32", + "description": "role identifier." + } + } + }`) + + cdc.RegisterConcrete(&MsgWhitelistRolePermission{}, "kiraHub/MsgWhitelistRolePermission", nil) + functionmeta.AddNewFunction((&MsgWhitelistRolePermission{}).Type(), `{ + "description": "MsgWhitelistRolePermission defines a message to whitelist permission for a role.", + "parameters": { + "proposer": { + "type": "string", + "description": "proposer who propose this message." + }, + "role": { + "type": "uint32", + "description": "role identifier." + }, + "permission": { + "type": "uint32", + "description": "Permission to be whitelisted." + } + } + }`) + cdc.RegisterConcrete(&MsgBlacklistRolePermission{}, "kiraHub/MsgBlacklistRolePermission", nil) + functionmeta.AddNewFunction((&MsgBlacklistRolePermission{}).Type(), `{ + "description": "MsgBlacklistRolePermission defines a message to blacklist permission for a role.", + "parameters": { + "proposer": { + "type": "string", + "description": "proposer who propose this message." + }, + "role": { + "type": "uint32", + "description": "role identifier." + }, + "permission": { + "type": "uint32", + "description": "Permission to be blacklisted." + } + } + }`) + cdc.RegisterConcrete(&MsgRemoveWhitelistRolePermission{}, "kiraHub/MsgRemoveWhitelistRolePermission", nil) + functionmeta.AddNewFunction((&MsgRemoveWhitelistRolePermission{}).Type(), `{ + "description": "MsgRemoveWhitelistRolePermission defines a message to remove whitelisted permission for a role.", + "parameters": { + "proposer": { + "type": "string", + "description": "proposer who propose this message." + }, + "role": { + "type": "uint32", + "description": "role identifier." + }, + "permission": { + "type": "uint32", + "description": "Permission to be removed from whitelisted listing." + } + } + }`) + cdc.RegisterConcrete(&MsgRemoveBlacklistRolePermission{}, "kiraHub/MsgRemoveBlacklistRolePermission", nil) + functionmeta.AddNewFunction((&MsgRemoveBlacklistRolePermission{}).Type(), `{ + "description": "MsgRemoveBlacklistRolePermission defines a message to remove blacklisted permission for a role.", + "parameters": { + "proposer": { + "type": "string", + "description": "proposer who propose this message." + }, + "role": { + "type": "uint32", + "description": "role identifier." + }, + "permission": { + "type": "uint32", + "description": "Permission to be removed from blacklisted listing." + } + } + }`) +} + +func RegisterInterfaces(registry types.InterfaceRegistry) { + registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgWhitelistPermissions{}, + &MsgBlacklistPermissions{}, + + &MsgSetNetworkProperties{}, + &MsgSetExecutionFee{}, + + &MsgClaimCouncilor{}, + + &MsgAssignRole{}, + &MsgCreateRole{}, + &MsgRemoveRole{}, + + &MsgWhitelistRolePermission{}, + &MsgBlacklistRolePermission{}, + &MsgRemoveWhitelistRolePermission{}, + &MsgRemoveBlacklistRolePermission{}, + + &MsgSubmitProposal{}, + &MsgVoteProposal{}, + + &MsgRegisterIdentityRecords{}, + &MsgDeleteIdentityRecords{}, + &MsgRequestIdentityRecordsVerify{}, + &MsgHandleIdentityRecordsVerifyRequest{}, + &MsgCancelIdentityRecordsVerifyRequest{}, + ) + + registry.RegisterInterface( + "kira.gov.Content", + (*Content)(nil), + &WhitelistAccountPermissionProposal{}, + &BlacklistAccountPermissionProposal{}, + &RemoveWhitelistedAccountPermissionProposal{}, + &RemoveBlacklistedAccountPermissionProposal{}, + &AssignRoleToAccountProposal{}, + &UnassignRoleFromAccountProposal{}, + &SetNetworkPropertyProposal{}, + &UpsertDataRegistryProposal{}, + &SetPoorNetworkMessagesProposal{}, + &CreateRoleProposal{}, + &RemoveRoleProposal{}, + &WhitelistRolePermissionProposal{}, + &BlacklistRolePermissionProposal{}, + &RemoveWhitelistedRolePermissionProposal{}, + &RemoveBlacklistedRolePermissionProposal{}, + &SetProposalDurationsProposal{}, + &ProposalResetWholeCouncilorRank{}, + &ProposalJailCouncilor{}, + ) + + msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) +} + +var ( + amino = codec.NewLegacyAmino() + + // ModuleCdc references the global x/staking module codec. Note, the codec should + // ONLY be used in certain instances of tests and for JSON encoding as Amino is + // still used for that purpose. + // + // The actual codec used for serialization should be provided to x/staking and + // defined at the application level. + ModuleCdc = codec.NewAminoCodec(amino) +) + +func init() { + RegisterCodec(amino) + amino.Seal() +} diff --git a/x/gov/types/content.go b/x/gov/types/content.go index 5e8693442..5d4da68b9 100644 --- a/x/gov/types/content.go +++ b/x/gov/types/content.go @@ -1,19 +1,19 @@ -package types - -type Content interface { - // ProposalType is a string that should be unique by proposal content type in order to be able - // to parse and apply once it passes. - ProposalType() string - - // VotePermission returns the PermValue a user needs to have in order to be able to vote the proposal. - VotePermission() PermValue - - // ProposalPermission returns PermValue a user needs to have in order to be able to submit the proposal. - ProposalPermission() PermValue - - // ValidateBasic returns basic validation result for the proposal - ValidateBasic() error - - // ProposalRoute() string - // String() string -} +package types + +type Content interface { + // ProposalType is a string that should be unique by proposal content type in order to be able + // to parse and apply once it passes. + ProposalType() string + + // VotePermission returns the PermValue a user needs to have in order to be able to vote the proposal. + VotePermission() PermValue + + // ProposalPermission returns PermValue a user needs to have in order to be able to submit the proposal. + ProposalPermission() PermValue + + // ValidateBasic returns basic validation result for the proposal + ValidateBasic() error + + // ProposalRoute() string + // String() string +} diff --git a/x/gov/types/councilor.pb.go b/x/gov/types/councilor.pb.go index 82d9c4e16..2b8b4b1bb 100644 --- a/x/gov/types/councilor.pb.go +++ b/x/gov/types/councilor.pb.go @@ -41,19 +41,19 @@ const ( ) var CouncilorStatus_name = map[int32]string{ - 0: "WAITING", - 1: "ACTIVE", - 2: "INACTIVE", - 3: "PAUSED", - 4: "JAILED", + 0: "COUNCILOR_WAITING", + 1: "COUNCILOR_ACTIVE", + 2: "COUNCILOR_INACTIVE", + 3: "COUNCILOR_PAUSED", + 4: "COUNCILOR_JAILED", } var CouncilorStatus_value = map[string]int32{ - "WAITING": 0, - "ACTIVE": 1, - "INACTIVE": 2, - "PAUSED": 3, - "JAILED": 4, + "COUNCILOR_WAITING": 0, + "COUNCILOR_ACTIVE": 1, + "COUNCILOR_INACTIVE": 2, + "COUNCILOR_PAUSED": 3, + "COUNCILOR_JAILED": 4, } func (x CouncilorStatus) String() string { @@ -233,40 +233,40 @@ func init() { func init() { proto.RegisterFile("kira/gov/councilor.proto", fileDescriptor_cac0b13545050495) } var fileDescriptor_cac0b13545050495 = []byte{ - // 514 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x93, 0x41, 0x6f, 0xd3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f, 0x4e, 0xc2, 0xb7, - 0xbd, 0x26, 0xb0, 0xee, 0x4c, 0x67, 0xce, 0x55, 0x0f, 0x9f, 0x28, 0x36, 0xa1, 0xe8, 0x21, 0x6c, - 0x84, 0x87, 0x25, 0xb2, 0x61, 0xdd, 0x9d, 0xce, 0x9c, 0xd6, 0x0a, 0x09, 0x53, 0x5c, 0x40, 0x6d, - 0x68, 0x1c, 0xf9, 0x6f, 0x8e, 0x7b, 0xfb, 0xcd, 0xea, 0x5a, 0x97, 0x23, 0x9c, 0x49, 0x1a, 0xe5, - 0xc0, 0x81, 0x1f, 0xbe, 0xea, 0xed, 0x37, 0x6b, 0x6b, 0xc0, 0x01, 0x66, 0x23, 0x1a, 0x59, 0xb5, - 0xcf, 0xdf, 0xed, 0xca, 0xde, 0xf3, 0x9f, 0x73, 0x1b, 0x9c, 0xcf, 0x6d, 0x70, 0x39, 0xb7, 0xc1, - 0x97, 0x85, 0x5d, 0x39, 0x5f, 0xd8, 0x95, 0x5f, 0x0b, 0xbb, 0xf2, 0xee, 0xd1, 0xb5, 0x61, 0xbc, - 0x64, 0x02, 0x07, 0x5c, 0x50, 0x4f, 0xd2, 0x21, 0x66, 0xde, 0x27, 0xfd, 0x5e, 0xf4, 0x3c, 0x06, - 0x86, 0x7e, 0x0c, 0xcf, 0xfe, 0x05, 0x00, 0x00, 0xff, 0xff, 0x57, 0x99, 0xc7, 0x35, 0x48, 0x03, - 0x00, 0x00, + // 528 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x93, 0x41, 0x6f, 0xd3, 0x3e, + 0x18, 0xc6, 0x9b, 0xb5, 0xff, 0x76, 0xf3, 0x1f, 0x8d, 0xd4, 0x0c, 0x14, 0x72, 0x48, 0xa3, 0x4a, + 0x48, 0x03, 0xd4, 0x44, 0xc0, 0x6d, 0x17, 0x94, 0x65, 0x15, 0xca, 0x18, 0xdd, 0x94, 0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0x3a, 0x22, 0xd9, 0xd5, 0x96, 0x68, 0xd0, 0x29, + 0xe0, 0x35, 0xf3, 0xfe, 0x78, 0x62, 0xd7, 0x17, 0x70, 0x90, 0xa2, 0x1c, 0xbf, 0xe5, 0x7c, 0xe4, + 0x9d, 0x1e, 0xb7, 0xf7, 0xf4, 0xf2, 0x8a, 0xf3, 0x11, 0x1a, 0x0a, 0x12, 0xdd, 0x46, 0xf7, 0xbd, + 0xe0, 0xa0, 0xbd, 0xa7, 0x57, 0x56, 0xd0, 0x7d, 0x44, 0xfb, 0x24, 0x32, 0x2b, 0x9f, 0xbe, 0x59, + 0xa5, 0xdd, 0x97, 0xdf, 0xa7, 0x96, 0x76, 0x39, 0xb5, 0xb4, 0xeb, 0xa9, 0xa5, 0x7d, 0x9e, 0x59, + 0xa5, 0xcb, 0x99, 0x55, 0xfa, 0x31, 0xb3, 0x4a, 0xef, 0x1e, 0xdd, 0x18, 0xdf, 0x6b, 0xca, 0x91, + 0xcf, 0x38, 0x71, 0x05, 0xe9, 0x21, 0xea, 0x7e, 0x54, 0x2f, 0x4c, 0x4d, 0xb0, 0x5b, 0x55, 0xcf, + 0xe7, 0xc5, 0xdf, 0x00, 0x00, 0x00, 0xff, 0xff, 0xae, 0x1c, 0x0f, 0x24, 0x7a, 0x03, 0x00, 0x00, } func (this *MsgClaimCouncilor) Equal(that interface{}) bool { diff --git a/x/gov/types/errors.go b/x/gov/types/errors.go index d76f50b66..17eb570cb 100644 --- a/x/gov/types/errors.go +++ b/x/gov/types/errors.go @@ -55,4 +55,14 @@ var ( ErrInvalidRoleIdentifier = errors.Register(ModuleName, 50, "invalid role identifier") ErrCouncilorMonikerNotAllowedToBeChanged = errors.Register(ModuleName, 51, "councilor moniker is not allowed to be changed") ErrCouncilorUsernameNotAllowedToBeChanged = errors.Register(ModuleName, 52, "councilor username is not allowed to be changed") + ErrProposalTitleSizeExceeds = errors.Register(ModuleName, 53, "proposal title size exceeds") + ErrProposalDescriptionSizeExceeds = errors.Register(ModuleName, 54, "proposal description size exceeds") + ErrProposalReferenceSizeExceeds = errors.Register(ModuleName, 55, "proposal reference size exceeds") + ErrProposalChecksumSizeExceeds = errors.Register(ModuleName, 56, "proposal checksum size exceeds") + ErrProposalOptionCountExceeds = errors.Register(ModuleName, 57, "proposal option count exceeds") + ErrProposalOptionSizeExceeds = errors.Register(ModuleName, 58, "proposal option size exceeds") + ErrProposalTypeNotAllowed = errors.Register(ModuleName, 59, "proposal type not allowed") + ErrProposalOptionOnlyAscii = errors.Register(ModuleName, 60, "only ascii symbols allowed") + ErrPollsNotFount = errors.Register(ModuleName, 61, "empty polls") + ErrPollWrongValue = errors.Register(ModuleName, 62, "wrong poll value") ) diff --git a/x/gov/types/events.go b/x/gov/types/events.go index f113b9650..efbce9780 100644 --- a/x/gov/types/events.go +++ b/x/gov/types/events.go @@ -1,55 +1,55 @@ -package types - -// governance module events -const ( - EventTypeProposalVote = "proposal_vote" - EventTypeSubmitProposal = "submit_proposal" - EventTypeCreateRole = "create_role" - EventTypeAssignRole = "assign_role" - EventTypeRemoveRole = "remove_role" - EventTypeWhitelistPermisison = "whitelist_permission" - EventTypeRemoveWhitelistedPermisison = "remove_whitelisted_permission" - EventTypeBlacklistPermisison = "blacklist_permission" - EventTypeRemoveBlacklistedPermisison = "remove_blacklisted_permission" - EventTypeWhitelistRolePermisison = "whitelist_role_permission" - EventTypeBlacklistRolePermisison = "blacklist_role_permission" - EventTypeRemoveBlacklistRolePermisison = "remove_blacklist_role_permission" - EventTypeRemoveWhitelistRolePermisison = "remove_whitelist_role_permission" - EventTypeSetNetworkProperties = "set_network_properties" - EventTypeSetExecutionFee = "set_execution_fee" - EventTypeClaimCouncilor = "claim_councilor" - EventTypeAddToEnactment = "add_to_enactments" - EventTypeRemoveEnactment = "remove_from_enactments" - - AttributeKeyProposalId = "proposal_id" - AttributeKeyProposalType = "proposal_type" - AttributeKeyProposalContent = "proposal_content" - AttributeKeyVoter = "voter" - AttributeKeyOption = "option" - AttributeKeyProposer = "proposer" - AttributeKeyAddress = "address" - AttributeKeyRoleId = "role_id" - AttributeKeyPermission = "permission" - AttributeKeyProperties = "properties" - AttributeKeyTransactionType = "transaction_type" - AttributeKeyExecutionFee = "execution_fee" - AttributeKeyFailureFee = "failure_fee" - AttributeKeyTimeout = "time_out" - AttributeKeyDefaultParameters = "default_parameters" - AttributeKeyProposalDescription = "description" - - // ---- Cosmos SDK gov native events ---- - // EventTypeProposalDeposit = "proposal_deposit" - // EventTypeInactiveProposal = "inactive_proposal" - // EventTypeActiveProposal = "active_proposal" - - // AttributeKeyProposalResult = "proposal_result" - // AttributeKeyProposalID = "proposal_id" - // AttributeKeyVotingPeriodStart = "voting_period_start" - // AttributeValueCategory = "governance" - // AttributeValueProposalDropped = "proposal_dropped" // didn't meet min deposit - // AttributeValueProposalPassed = "proposal_passed" // met vote quorum - // AttributeValueProposalRejected = "proposal_rejected" // didn't meet vote quorum - // AttributeValueProposalFailed = "proposal_failed" // error on proposal handler - // AttributeKeyProposalType = "proposal_type" -) +package types + +// governance module events +const ( + EventTypeProposalVote = "proposal_vote" + EventTypeSubmitProposal = "submit_proposal" + EventTypeCreateRole = "create_role" + EventTypeAssignRole = "assign_role" + EventTypeRemoveRole = "remove_role" + EventTypeWhitelistPermisison = "whitelist_permission" + EventTypeRemoveWhitelistedPermisison = "remove_whitelisted_permission" + EventTypeBlacklistPermisison = "blacklist_permission" + EventTypeRemoveBlacklistedPermisison = "remove_blacklisted_permission" + EventTypeWhitelistRolePermisison = "whitelist_role_permission" + EventTypeBlacklistRolePermisison = "blacklist_role_permission" + EventTypeRemoveBlacklistRolePermisison = "remove_blacklist_role_permission" + EventTypeRemoveWhitelistRolePermisison = "remove_whitelist_role_permission" + EventTypeSetNetworkProperties = "set_network_properties" + EventTypeSetExecutionFee = "set_execution_fee" + EventTypeClaimCouncilor = "claim_councilor" + EventTypeAddToEnactment = "add_to_enactments" + EventTypeRemoveEnactment = "remove_from_enactments" + + AttributeKeyProposalId = "proposal_id" + AttributeKeyProposalType = "proposal_type" + AttributeKeyProposalContent = "proposal_content" + AttributeKeyVoter = "voter" + AttributeKeyOption = "option" + AttributeKeyProposer = "proposer" + AttributeKeyAddress = "address" + AttributeKeyRoleId = "role_id" + AttributeKeyPermission = "permission" + AttributeKeyProperties = "properties" + AttributeKeyTransactionType = "transaction_type" + AttributeKeyExecutionFee = "execution_fee" + AttributeKeyFailureFee = "failure_fee" + AttributeKeyTimeout = "time_out" + AttributeKeyDefaultParameters = "default_parameters" + AttributeKeyProposalDescription = "description" + + // ---- Cosmos SDK gov native events ---- + // EventTypeProposalDeposit = "proposal_deposit" + // EventTypeInactiveProposal = "inactive_proposal" + // EventTypeActiveProposal = "active_proposal" + + // AttributeKeyProposalResult = "proposal_result" + // AttributeKeyProposalID = "proposal_id" + // AttributeKeyVotingPeriodStart = "voting_period_start" + // AttributeValueCategory = "governance" + // AttributeValueProposalDropped = "proposal_dropped" // didn't meet min deposit + // AttributeValueProposalPassed = "proposal_passed" // met vote quorum + // AttributeValueProposalRejected = "proposal_rejected" // didn't meet vote quorum + // AttributeValueProposalFailed = "proposal_failed" // error on proposal handler + // AttributeKeyProposalType = "proposal_type" +) diff --git a/x/gov/types/expected_keepers.go b/x/gov/types/expected_keepers.go index 5e5ba16c1..98b88a005 100644 --- a/x/gov/types/expected_keepers.go +++ b/x/gov/types/expected_keepers.go @@ -1,11 +1,11 @@ -package types - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" -) - -// BankKeeper defines the expected interface needed to retrieve account balances. -type BankKeeper interface { - SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error - SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error -} +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// BankKeeper defines the expected interface needed to retrieve account balances. +type BankKeeper interface { + SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error + SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error +} diff --git a/x/gov/types/genesis.go b/x/gov/types/genesis.go index 33cab495b..f25b43abd 100644 --- a/x/gov/types/genesis.go +++ b/x/gov/types/genesis.go @@ -88,49 +88,69 @@ func DefaultGenesis() *GenesisState { PermVoteResetWholeCouncilorRankProposal, PermCreateJailCouncilorProposal, PermVoteJailCouncilorProposal, + PermCreatePollProposal, }, nil), uint64(RoleValidator): NewPermissions([]PermValue{PermClaimValidator}, nil), }, StartingProposalId: 1, NetworkProperties: &NetworkProperties{ - MinTxFee: 100, - MaxTxFee: 1000000, - VoteQuorum: 33, - MinimumProposalEndTime: 300, // 300 seconds / 5 mins - ProposalEnactmentTime: 300, // 300 seconds / 5 mins - MinProposalEndBlocks: 2, - MinProposalEnactmentBlocks: 1, - EnableForeignFeePayments: true, - MischanceRankDecreaseAmount: 10, - MischanceConfidence: 10, - MaxMischance: 110, - InactiveRankDecreasePercent: sdk.NewDecWithPrec(50, 2), // 50% - PoorNetworkMaxBankSend: 1000000, // 1M ukex - MinValidators: 1, - UnjailMaxTime: 600, // 600 seconds / 10 mins - EnableTokenWhitelist: false, - EnableTokenBlacklist: true, - MinIdentityApprovalTip: 200, - UniqueIdentityKeys: "moniker,username", - UbiHardcap: 6000_000, - ValidatorsFeeShare: sdk.NewDecWithPrec(50, 2), // 50% - InflationRate: sdk.NewDecWithPrec(18, 2), // 18% - InflationPeriod: 31557600, // 1 year - UnstakingPeriod: 2629800, // 1 month - MaxDelegators: 100, - MinDelegationPushout: 10, - SlashingPeriod: 3600, - MaxJailedPercentage: sdk.NewDecWithPrec(25, 2), - MaxSlashingPercentage: sdk.NewDecWithPrec(1, 2), - MinCustodyReward: 200, - MaxCustodyTxSize: 8192, - MaxCustodyBufferSize: 10, - AbstentionRankDecreaseAmount: 1, - MaxAbstention: 2, - MinCollectiveBond: 100_000, // in KEX - MinCollectiveBondingTime: 86400, // in seconds - MaxCollectiveOutputs: 10, - MinCollectiveClaimPeriod: 14400, // 4hrs + MinTxFee: 100, + MaxTxFee: 1000000, + VoteQuorum: 33, + MinimumProposalEndTime: 300, // 300 seconds / 5 mins + ProposalEnactmentTime: 300, // 300 seconds / 5 mins + MinProposalEndBlocks: 2, + MinProposalEnactmentBlocks: 1, + EnableForeignFeePayments: true, + MischanceRankDecreaseAmount: 10, + MischanceConfidence: 10, + MaxMischance: 110, + InactiveRankDecreasePercent: sdk.NewDecWithPrec(50, 2), // 50% + PoorNetworkMaxBankSend: 1000000, // 1M ukex + MinValidators: 1, + UnjailMaxTime: 600, // 600 seconds / 10 mins + EnableTokenWhitelist: false, + EnableTokenBlacklist: true, + MinIdentityApprovalTip: 200, + UniqueIdentityKeys: "moniker,username", + UbiHardcap: 6000_000, + ValidatorsFeeShare: sdk.NewDecWithPrec(50, 2), // 50% + InflationRate: sdk.NewDecWithPrec(18, 2), // 18% + InflationPeriod: 31557600, // 1 year + UnstakingPeriod: 2629800, // 1 month + MaxDelegators: 100, + MinDelegationPushout: 10, + SlashingPeriod: 3600, + MaxJailedPercentage: sdk.NewDecWithPrec(25, 2), + MaxSlashingPercentage: sdk.NewDecWithPrec(1, 2), + MinCustodyReward: 200, + MaxCustodyTxSize: 8192, + MaxCustodyBufferSize: 10, + AbstentionRankDecreaseAmount: 1, + MaxAbstention: 2, + MinCollectiveBond: 100_000, // in KEX + MinCollectiveBondingTime: 86400, // in seconds + MaxCollectiveOutputs: 10, + MinCollectiveClaimPeriod: 14400, // 4hrs + ValidatorRecoveryBond: 300000, // 300k KEX + MaxAnnualInflation: sdk.NewDecWithPrec(35, 2), // 35%// 300k KEX + MaxProposalTitleSize: 128, + MaxProposalDescriptionSize: 1024, + MaxProposalPollOptionSize: 64, + MaxProposalPollOptionCount: 128, + MaxProposalReferenceSize: 512, + MaxProposalChecksumSize: 128, + MinDappBond: 1000000, + MaxDappBond: 10000000, + DappBondDuration: 604800, + DappVerifierBond: sdk.NewDecWithPrec(1, 3), //0.1% + DappAutoDenounceTime: 60, // 60s + DappMischanceRankDecreaseAmount: 1, + DappMaxMischance: 10, + DappInactiveRankDecreasePercent: 10, + DappPoolSlippageDefault: sdk.NewDecWithPrec(1, 1), // 10% + MintingFtFee: 100_000_000_000_000, + MintingNftFee: 100_000_000_000_000, }, ExecutionFees: []ExecutionFee{ { diff --git a/x/gov/types/identity_registrar.go b/x/gov/types/identity_registrar.go index da1219bfe..09dbd9347 100644 --- a/x/gov/types/identity_registrar.go +++ b/x/gov/types/identity_registrar.go @@ -1,20 +1,20 @@ -package types - -func WrapInfos(infos map[string]string) []IdentityInfoEntry { - wrappedInfos := []IdentityInfoEntry{} - for key, value := range infos { - wrappedInfos = append(wrappedInfos, IdentityInfoEntry{ - Key: key, - Info: value, - }) - } - return wrappedInfos -} - -func UnwrapInfos(wrappedInfos []IdentityInfoEntry) map[string]string { - infos := make(map[string]string) - for _, wi := range wrappedInfos { - infos[wi.Key] = wi.Info - } - return infos -} +package types + +func WrapInfos(infos map[string]string) []IdentityInfoEntry { + wrappedInfos := []IdentityInfoEntry{} + for key, value := range infos { + wrappedInfos = append(wrappedInfos, IdentityInfoEntry{ + Key: key, + Info: value, + }) + } + return wrappedInfos +} + +func UnwrapInfos(wrappedInfos []IdentityInfoEntry) map[string]string { + infos := make(map[string]string) + for _, wi := range wrappedInfos { + infos[wi.Key] = wi.Info + } + return infos +} diff --git a/x/gov/types/identity_registrar_test.go b/x/gov/types/identity_registrar_test.go index 852f7a7e8..c2a221ae5 100644 --- a/x/gov/types/identity_registrar_test.go +++ b/x/gov/types/identity_registrar_test.go @@ -1,41 +1,41 @@ -package types - -import ( - "testing" - "time" - - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/require" -) - -func TestMarshalUnmarshalIdentityRecord(t *testing.T) { - record := IdentityRecord{ - Id: 1, - Address: "", - Key: "", - Value: "", - Date: time.Now(), - Verifiers: []string{""}, - } - - bz, err := record.Marshal() - require.NoError(t, err) - - parsed := IdentityRecord{} - err = parsed.Unmarshal(bz) - require.NoError(t, err) -} - -func TestMarshalUnmarshalMsgRegisterIdentityRecords(t *testing.T) { - record := MsgRegisterIdentityRecords{ - Address: sdk.AccAddress{}, - Infos: WrapInfos(make(map[string]string)), - } - - bz, err := record.Marshal() - require.NoError(t, err) - - parsed := MsgRegisterIdentityRecords{} - err = parsed.Unmarshal(bz) - require.NoError(t, err) -} +package types + +import ( + "testing" + "time" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" +) + +func TestMarshalUnmarshalIdentityRecord(t *testing.T) { + record := IdentityRecord{ + Id: 1, + Address: "", + Key: "", + Value: "", + Date: time.Now(), + Verifiers: []string{""}, + } + + bz, err := record.Marshal() + require.NoError(t, err) + + parsed := IdentityRecord{} + err = parsed.Unmarshal(bz) + require.NoError(t, err) +} + +func TestMarshalUnmarshalMsgRegisterIdentityRecords(t *testing.T) { + record := MsgRegisterIdentityRecords{ + Address: sdk.AccAddress{}, + Infos: WrapInfos(make(map[string]string)), + } + + bz, err := record.Marshal() + require.NoError(t, err) + + parsed := MsgRegisterIdentityRecords{} + err = parsed.Unmarshal(bz) + require.NoError(t, err) +} diff --git a/x/gov/types/keys.go b/x/gov/types/keys.go index 3d80af13e..becc6c899 100644 --- a/x/gov/types/keys.go +++ b/x/gov/types/keys.go @@ -1,43 +1,43 @@ -package types - -// constants -const ( - ModuleName = "customgov" - // RouterKey to be used for routing msgs - RouterKey = ModuleName - // QuerierRoute is the querier route for the staking module - QuerierRoute = ModuleName -) - -// constants -var ( - KeyPrefixNetworkProperties = []byte("network_properties") - KeyPrefixExecutionFee = []byte("execution_fee") - - // identity registrar - KeyLastIdentityRecordId = []byte("last_identity_record_id") - KeyLastIdRecordVerifyRequestId = []byte("last_identity_record_verify_request_id") - KeyPrefixIdentityRecord = []byte("identity_record_prefix") - KeyPrefixIdentityRecordByAddress = []byte("identity_record_by_address_prefix") - KeyPrefixIdRecordVerifyRequest = []byte("identity_record_verify_request_prefix") - KeyPrefixIdRecordVerifyRequestByRequester = []byte("identity_record_verify_request_by_requester_prefix") - KeyPrefixIdRecordVerifyRequestByApprover = []byte("identity_record_verify_request_by_approver_prefix") - KeyPrefixProposalDuration = []byte("proposal_duration") - - // Roles - RoleUndefined uint64 = 0x0 - RoleSudo uint64 = 0x1 - RoleValidator uint64 = 0x2 -) - -func IdentityRecordByAddressPrefix(address string) []byte { - return append(KeyPrefixIdentityRecordByAddress, address...) -} - -func IdRecordVerifyRequestByRequesterPrefix(address string) []byte { - return append(KeyPrefixIdRecordVerifyRequestByRequester, address...) -} - -func IdRecordVerifyRequestByApproverPrefix(address string) []byte { - return append(KeyPrefixIdRecordVerifyRequestByApprover, address...) -} +package types + +// constants +const ( + ModuleName = "customgov" + // RouterKey to be used for routing msgs + RouterKey = ModuleName + // QuerierRoute is the querier route for the staking module + QuerierRoute = ModuleName +) + +// constants +var ( + KeyPrefixNetworkProperties = []byte("network_properties") + KeyPrefixExecutionFee = []byte("execution_fee") + + // identity registrar + KeyLastIdentityRecordId = []byte("last_identity_record_id") + KeyLastIdRecordVerifyRequestId = []byte("last_identity_record_verify_request_id") + KeyPrefixIdentityRecord = []byte("identity_record_prefix") + KeyPrefixIdentityRecordByAddress = []byte("identity_record_by_address_prefix") + KeyPrefixIdRecordVerifyRequest = []byte("identity_record_verify_request_prefix") + KeyPrefixIdRecordVerifyRequestByRequester = []byte("identity_record_verify_request_by_requester_prefix") + KeyPrefixIdRecordVerifyRequestByApprover = []byte("identity_record_verify_request_by_approver_prefix") + KeyPrefixProposalDuration = []byte("proposal_duration") + + // Roles + RoleUndefined uint64 = 0x0 + RoleSudo uint64 = 0x1 + RoleValidator uint64 = 0x2 +) + +func IdentityRecordByAddressPrefix(address string) []byte { + return append(KeyPrefixIdentityRecordByAddress, address...) +} + +func IdRecordVerifyRequestByRequesterPrefix(address string) []byte { + return append(KeyPrefixIdRecordVerifyRequestByRequester, address...) +} + +func IdRecordVerifyRequestByApproverPrefix(address string) []byte { + return append(KeyPrefixIdRecordVerifyRequestByApprover, address...) +} diff --git a/x/gov/types/msg.go b/x/gov/types/msg.go index 144ada3fc..046c791a6 100644 --- a/x/gov/types/msg.go +++ b/x/gov/types/msg.go @@ -1,907 +1,987 @@ -package types - -import ( - "fmt" - - "github.com/KiraCore/sekai/types" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - proto "github.com/gogo/protobuf/proto" - "gopkg.in/yaml.v2" -) - -var ( - // Proposal - _ sdk.Msg = &MsgVoteProposal{} - - // Permissions - _ sdk.Msg = &MsgWhitelistPermissions{} - _ sdk.Msg = &MsgBlacklistPermissions{} - _ sdk.Msg = &MsgSubmitProposal{} - - // Councilor - _ sdk.Msg = &MsgClaimCouncilor{} - - // Roles - _ sdk.Msg = &MsgCreateRole{} - _ sdk.Msg = &MsgAssignRole{} - _ sdk.Msg = &MsgRemoveRole{} - - _ sdk.Msg = &MsgWhitelistRolePermission{} - _ sdk.Msg = &MsgBlacklistRolePermission{} - _ sdk.Msg = &MsgRemoveWhitelistRolePermission{} - _ sdk.Msg = &MsgRemoveBlacklistRolePermission{} -) - -func NewMsgWhitelistPermissions( - proposer, address sdk.AccAddress, - permission uint32, -) *MsgWhitelistPermissions { - return &MsgWhitelistPermissions{ - Proposer: proposer, - Address: address, - Permission: permission, - } -} - -func (m *MsgWhitelistPermissions) Route() string { - return ModuleName -} - -func (m *MsgWhitelistPermissions) Type() string { - return types.MsgTypeWhitelistPermissions -} - -func (m *MsgWhitelistPermissions) ValidateBasic() error { - if m.Proposer.Empty() { - return ErrEmptyProposerAccAddress - } - - if m.Address.Empty() { - return ErrEmptyPermissionsAccAddress - } - - return nil -} - -func (m *MsgWhitelistPermissions) GetSignBytes() []byte { - bz := ModuleCdc.MustMarshalJSON(m) - return sdk.MustSortJSON(bz) -} - -func (m *MsgWhitelistPermissions) GetSigners() []sdk.AccAddress { - return []sdk.AccAddress{ - m.Proposer, - } -} - -func NewMsgRemoveWhitelistedPermissions( - proposer, address sdk.AccAddress, - permission uint32, -) *MsgRemoveWhitelistedPermissions { - return &MsgRemoveWhitelistedPermissions{ - Proposer: proposer, - Address: address, - Permission: permission, - } -} - -func (m *MsgRemoveWhitelistedPermissions) Route() string { - return ModuleName -} - -func (m *MsgRemoveWhitelistedPermissions) Type() string { - return types.MsgTypeBlacklistPermissions -} - -func (m *MsgRemoveWhitelistedPermissions) ValidateBasic() error { - if m.Proposer.Empty() { - return ErrEmptyProposerAccAddress - } - - if m.Address.Empty() { - return ErrEmptyPermissionsAccAddress - } - - return nil -} - -func (m *MsgRemoveWhitelistedPermissions) GetSignBytes() []byte { - bz := ModuleCdc.MustMarshalJSON(m) - return sdk.MustSortJSON(bz) -} - -func (m *MsgRemoveWhitelistedPermissions) GetSigners() []sdk.AccAddress { - return []sdk.AccAddress{ - m.Proposer, - } -} - -func NewMsgBlacklistPermissions( - proposer, address sdk.AccAddress, - permission uint32, -) *MsgBlacklistPermissions { - return &MsgBlacklistPermissions{ - Proposer: proposer, - Address: address, - Permission: permission, - } -} - -func (m *MsgBlacklistPermissions) Route() string { - return ModuleName -} - -func (m *MsgBlacklistPermissions) Type() string { - return types.MsgTypeBlacklistPermissions -} - -func (m *MsgBlacklistPermissions) ValidateBasic() error { - if m.Proposer.Empty() { - return ErrEmptyProposerAccAddress - } - - if m.Address.Empty() { - return ErrEmptyPermissionsAccAddress - } - - return nil -} - -func (m *MsgBlacklistPermissions) GetSignBytes() []byte { - bz := ModuleCdc.MustMarshalJSON(m) - return sdk.MustSortJSON(bz) -} - -func (m *MsgBlacklistPermissions) GetSigners() []sdk.AccAddress { - return []sdk.AccAddress{ - m.Proposer, - } -} - -func NewMsgRemoveBlacklistedPermissions( - proposer, address sdk.AccAddress, - permission uint32, -) *MsgRemoveBlacklistedPermissions { - return &MsgRemoveBlacklistedPermissions{ - Proposer: proposer, - Address: address, - Permission: permission, - } -} - -func (m *MsgRemoveBlacklistedPermissions) Route() string { - return ModuleName -} - -func (m *MsgRemoveBlacklistedPermissions) Type() string { - return types.MsgTypeBlacklistPermissions -} - -func (m *MsgRemoveBlacklistedPermissions) ValidateBasic() error { - if m.Proposer.Empty() { - return ErrEmptyProposerAccAddress - } - - if m.Address.Empty() { - return ErrEmptyPermissionsAccAddress - } - - return nil -} - -func (m *MsgRemoveBlacklistedPermissions) GetSignBytes() []byte { - bz := ModuleCdc.MustMarshalJSON(m) - return sdk.MustSortJSON(bz) -} - -func (m *MsgRemoveBlacklistedPermissions) GetSigners() []sdk.AccAddress { - return []sdk.AccAddress{ - m.Proposer, - } -} - -func NewMsgClaimCouncilor( - address sdk.AccAddress, - moniker string, - username string, - description string, - social string, - contact string, - avatar string, -) *MsgClaimCouncilor { - return &MsgClaimCouncilor{ - Address: address, - Moniker: moniker, - Username: username, - Description: description, - Social: social, - Contact: contact, - Avatar: avatar, - } -} - -func (m *MsgClaimCouncilor) Route() string { - return ModuleName -} - -func (m *MsgClaimCouncilor) Type() string { - return types.MsgTypeClaimCouncilor -} - -func (m *MsgClaimCouncilor) ValidateBasic() error { - if m.Address.Empty() { - return ErrCouncilorEmptyAddress - } - - return nil -} - -func (m *MsgClaimCouncilor) GetSignBytes() []byte { - bz := ModuleCdc.MustMarshalJSON(m) - return sdk.MustSortJSON(bz) -} - -func (m *MsgClaimCouncilor) GetSigners() []sdk.AccAddress { - return []sdk.AccAddress{ - m.Address, - } -} - -func NewMsgCouncilorPause( - address sdk.AccAddress, -) *MsgCouncilorPause { - return &MsgCouncilorPause{ - Sender: address.String(), - } -} - -func (m *MsgCouncilorPause) Route() string { - return ModuleName -} - -func (m *MsgCouncilorPause) Type() string { - return types.MsgTypeClaimCouncilor -} - -func (m *MsgCouncilorPause) ValidateBasic() error { - if m.Sender == "" { - return ErrCouncilorEmptyAddress - } - - return nil -} - -func (m *MsgCouncilorPause) GetSignBytes() []byte { - bz := ModuleCdc.MustMarshalJSON(m) - return sdk.MustSortJSON(bz) -} - -func (m *MsgCouncilorPause) GetSigners() []sdk.AccAddress { - addr, _ := sdk.AccAddressFromBech32(m.Sender) - return []sdk.AccAddress{ - addr, - } -} - -func NewMsgCouncilorUnpause( - address sdk.AccAddress, -) *MsgCouncilorUnpause { - return &MsgCouncilorUnpause{ - Sender: address.String(), - } -} - -func (m *MsgCouncilorUnpause) Route() string { - return ModuleName -} - -func (m *MsgCouncilorUnpause) Type() string { - return types.MsgTypeClaimCouncilor -} - -func (m *MsgCouncilorUnpause) ValidateBasic() error { - if m.Sender == "" { - return ErrCouncilorEmptyAddress - } - - return nil -} - -func (m *MsgCouncilorUnpause) GetSignBytes() []byte { - bz := ModuleCdc.MustMarshalJSON(m) - return sdk.MustSortJSON(bz) -} - -func (m *MsgCouncilorUnpause) GetSigners() []sdk.AccAddress { - addr, _ := sdk.AccAddressFromBech32(m.Sender) - return []sdk.AccAddress{ - addr, - } -} - -func NewMsgCouncilorActivate( - address sdk.AccAddress, -) *MsgCouncilorActivate { - return &MsgCouncilorActivate{ - Sender: address.String(), - } -} - -func (m *MsgCouncilorActivate) Route() string { - return ModuleName -} - -func (m *MsgCouncilorActivate) Type() string { - return types.MsgTypeClaimCouncilor -} - -func (m *MsgCouncilorActivate) ValidateBasic() error { - if m.Sender == "" { - return ErrCouncilorEmptyAddress - } - - return nil -} - -func (m *MsgCouncilorActivate) GetSignBytes() []byte { - bz := ModuleCdc.MustMarshalJSON(m) - return sdk.MustSortJSON(bz) -} - -func (m *MsgCouncilorActivate) GetSigners() []sdk.AccAddress { - addr, _ := sdk.AccAddressFromBech32(m.Sender) - return []sdk.AccAddress{ - addr, - } -} - -func NewMsgWhitelistRolePermission( - proposer sdk.AccAddress, - roleIdentifier string, - permission uint32, -) *MsgWhitelistRolePermission { - return &MsgWhitelistRolePermission{Proposer: proposer, RoleIdentifier: roleIdentifier, Permission: permission} -} - -func (m *MsgWhitelistRolePermission) Route() string { - return ModuleName -} - -func (m *MsgWhitelistRolePermission) Type() string { - return types.MsgTypeWhitelistRolePermission -} - -func (m *MsgWhitelistRolePermission) ValidateBasic() error { - if m.Proposer.Empty() { - return ErrEmptyProposerAccAddress - } - - return nil -} - -func (m *MsgWhitelistRolePermission) GetSignBytes() []byte { - bz := ModuleCdc.MustMarshalJSON(m) - return sdk.MustSortJSON(bz) -} - -func (m *MsgWhitelistRolePermission) GetSigners() []sdk.AccAddress { - return []sdk.AccAddress{ - m.Proposer, - } -} - -func NewMsgBlacklistRolePermission( - proposer sdk.AccAddress, - roleIdentifier string, - permission uint32, -) *MsgBlacklistRolePermission { - return &MsgBlacklistRolePermission{Proposer: proposer, RoleIdentifier: roleIdentifier, Permission: permission} -} - -func (m *MsgBlacklistRolePermission) Route() string { - return ModuleName -} - -func (m *MsgBlacklistRolePermission) Type() string { - return types.MsgTypeBlacklistRolePermission -} - -func (m *MsgBlacklistRolePermission) ValidateBasic() error { - if m.Proposer.Empty() { - return ErrEmptyProposerAccAddress - } - - return nil -} - -func (m *MsgBlacklistRolePermission) GetSignBytes() []byte { - bz := ModuleCdc.MustMarshalJSON(m) - return sdk.MustSortJSON(bz) -} - -func (m *MsgBlacklistRolePermission) GetSigners() []sdk.AccAddress { - return []sdk.AccAddress{ - m.Proposer, - } -} - -func NewMsgRemoveWhitelistRolePermission( - proposer sdk.AccAddress, - roleIdentifier string, - permission uint32, -) *MsgRemoveWhitelistRolePermission { - return &MsgRemoveWhitelistRolePermission{Proposer: proposer, RoleIdentifier: roleIdentifier, Permission: permission} -} - -func (m *MsgRemoveWhitelistRolePermission) Route() string { - return ModuleName -} - -func (m *MsgRemoveWhitelistRolePermission) Type() string { - return types.MsgTypeRemoveWhitelistRolePermission -} - -func (m *MsgRemoveWhitelistRolePermission) ValidateBasic() error { - if m.Proposer.Empty() { - return ErrEmptyProposerAccAddress - } - - return nil -} - -func (m *MsgRemoveWhitelistRolePermission) GetSignBytes() []byte { - bz := ModuleCdc.MustMarshalJSON(m) - return sdk.MustSortJSON(bz) -} - -func (m *MsgRemoveWhitelistRolePermission) GetSigners() []sdk.AccAddress { - return []sdk.AccAddress{ - m.Proposer, - } -} - -func NewMsgRemoveBlacklistRolePermission( - proposer sdk.AccAddress, - roleIdentifier string, - permission uint32, -) *MsgRemoveBlacklistRolePermission { - return &MsgRemoveBlacklistRolePermission{Proposer: proposer, RoleIdentifier: roleIdentifier, Permission: permission} -} - -func (m *MsgRemoveBlacklistRolePermission) Route() string { - return ModuleName -} - -func (m *MsgRemoveBlacklistRolePermission) Type() string { - return types.MsgTypeRemoveBlacklistRolePermission -} - -func (m *MsgRemoveBlacklistRolePermission) ValidateBasic() error { - if m.Proposer.Empty() { - return ErrEmptyProposerAccAddress - } - - return nil -} - -func (m *MsgRemoveBlacklistRolePermission) GetSignBytes() []byte { - bz := ModuleCdc.MustMarshalJSON(m) - return sdk.MustSortJSON(bz) -} - -func (m *MsgRemoveBlacklistRolePermission) GetSigners() []sdk.AccAddress { - return []sdk.AccAddress{ - m.Proposer, - } -} - -func NewMsgCreateRole(proposer sdk.AccAddress, sid, description string) *MsgCreateRole { - return &MsgCreateRole{Proposer: proposer, RoleSid: sid, RoleDescription: description} -} - -func (m *MsgCreateRole) Route() string { - return ModuleName -} - -func (m *MsgCreateRole) Type() string { - return types.MsgTypeCreateRole -} - -func (m *MsgCreateRole) ValidateBasic() error { - if m.Proposer.Empty() { - return ErrEmptyProposerAccAddress - } - - return nil -} - -func (m *MsgCreateRole) GetSignBytes() []byte { - bz := ModuleCdc.MustMarshalJSON(m) - return sdk.MustSortJSON(bz) -} - -func (m *MsgCreateRole) GetSigners() []sdk.AccAddress { - return []sdk.AccAddress{ - m.Proposer, - } -} - -func NewMsgAssignRole(proposer, address sdk.AccAddress, roleId uint32) *MsgAssignRole { - return &MsgAssignRole{Proposer: proposer, Address: address, RoleId: roleId} -} - -func (m *MsgAssignRole) Route() string { - return ModuleName -} - -func (m *MsgAssignRole) Type() string { - return types.MsgTypeAssignRole -} - -func (m *MsgAssignRole) ValidateBasic() error { - if m.Proposer.Empty() { - return ErrEmptyProposerAccAddress - } - - if m.Address.Empty() { - return ErrEmptyPermissionsAccAddress - } - - return nil -} - -func (m *MsgAssignRole) GetSignBytes() []byte { - bz := ModuleCdc.MustMarshalJSON(m) - return sdk.MustSortJSON(bz) -} - -func (m *MsgAssignRole) GetSigners() []sdk.AccAddress { - return []sdk.AccAddress{ - m.Proposer, - } -} - -func NewMsgRemoveRole(proposer, address sdk.AccAddress, roleId uint32) *MsgRemoveRole { - return &MsgRemoveRole{Proposer: proposer, Address: address, RoleId: roleId} -} - -func (m *MsgRemoveRole) Route() string { - return ModuleName -} - -func (m *MsgRemoveRole) Type() string { - return types.MsgTypeRemoveRole -} - -func (m *MsgRemoveRole) ValidateBasic() error { - if m.Proposer.Empty() { - return ErrEmptyProposerAccAddress - } - - if m.Address.Empty() { - return ErrEmptyPermissionsAccAddress - } - - return nil -} - -func (m *MsgRemoveRole) GetSignBytes() []byte { - bz := ModuleCdc.MustMarshalJSON(m) - return sdk.MustSortJSON(bz) -} - -func (m *MsgRemoveRole) GetSigners() []sdk.AccAddress { - return []sdk.AccAddress{ - m.Proposer, - } -} - -func NewMsgVoteProposal(proposalID uint64, voter sdk.AccAddress, option VoteOption, slash sdk.Dec) *MsgVoteProposal { - return &MsgVoteProposal{ - ProposalId: proposalID, - Voter: voter, - Option: option, - Slash: slash, - } -} - -func (m *MsgVoteProposal) Route() string { - return ModuleName -} - -func (m *MsgVoteProposal) Type() string { - return types.MsgTypeVoteProposal -} - -func (m *MsgVoteProposal) ValidateBasic() error { - if m.Voter.Empty() { - return ErrEmptyProposerAccAddress - } - - return nil -} - -func (m *MsgVoteProposal) GetSignBytes() []byte { - bz := ModuleCdc.MustMarshalJSON(m) - return sdk.MustSortJSON(bz) -} - -func (m *MsgVoteProposal) GetSigners() []sdk.AccAddress { - return []sdk.AccAddress{ - m.Voter, - } -} - -func NewMsgRegisterIdentityRecords(address sdk.AccAddress, infos []IdentityInfoEntry) *MsgRegisterIdentityRecords { - return &MsgRegisterIdentityRecords{ - Address: address, - Infos: infos, - } -} - -func (m *MsgRegisterIdentityRecords) Route() string { - return ModuleName -} - -func (m *MsgRegisterIdentityRecords) Type() string { - return types.MsgTypeRegisterIdentityRecords -} - -func (m *MsgRegisterIdentityRecords) ValidateBasic() error { - if m.Address.Empty() { - return ErrEmptyProposerAccAddress - } - if len(m.Infos) == 0 { - return ErrEmptyInfos - } - return nil -} - -func (m *MsgRegisterIdentityRecords) GetSignBytes() []byte { - bz := ModuleCdc.MustMarshalJSON(m) - return sdk.MustSortJSON(bz) -} - -func (m *MsgRegisterIdentityRecords) GetSigners() []sdk.AccAddress { - return []sdk.AccAddress{ - m.Address, - } -} - -func NewMsgDeleteIdentityRecords(address sdk.AccAddress, keys []string) *MsgDeleteIdentityRecords { - return &MsgDeleteIdentityRecords{ - Address: address, - Keys: keys, - } -} - -func (m *MsgDeleteIdentityRecords) Route() string { - return ModuleName -} - -func (m *MsgDeleteIdentityRecords) Type() string { - return types.MsgTypeEditIdentityRecord -} - -func (m *MsgDeleteIdentityRecords) ValidateBasic() error { - if m.Address.Empty() { - return ErrEmptyProposerAccAddress - } - return nil -} - -func (m *MsgDeleteIdentityRecords) GetSignBytes() []byte { - bz := ModuleCdc.MustMarshalJSON(m) - return sdk.MustSortJSON(bz) -} - -func (m *MsgDeleteIdentityRecords) GetSigners() []sdk.AccAddress { - return []sdk.AccAddress{ - m.Address, - } -} - -func NewMsgRequestIdentityRecordsVerify(address, verifier sdk.AccAddress, recordIds []uint64, tip sdk.Coin) *MsgRequestIdentityRecordsVerify { - return &MsgRequestIdentityRecordsVerify{ - Address: address, - Verifier: verifier, - RecordIds: recordIds, - Tip: tip, - } -} - -func (m *MsgRequestIdentityRecordsVerify) Route() string { - return ModuleName -} - -func (m *MsgRequestIdentityRecordsVerify) Type() string { - return types.MsgTypeRequestIdentityRecordsVerify -} - -func (m *MsgRequestIdentityRecordsVerify) ValidateBasic() error { - if m.Address.Empty() { - return ErrEmptyProposerAccAddress - } - if m.Verifier.Empty() { - return ErrEmptyVerifierAccAddress - } - if !m.Tip.IsValid() { - return ErrInvalidTip - } - if len(m.RecordIds) == 0 { - return ErrInvalidRecordIds - } - return nil -} - -func (m *MsgRequestIdentityRecordsVerify) GetSignBytes() []byte { - bz := ModuleCdc.MustMarshalJSON(m) - return sdk.MustSortJSON(bz) -} - -func (m *MsgRequestIdentityRecordsVerify) GetSigners() []sdk.AccAddress { - return []sdk.AccAddress{ - m.Address, - } -} - -func NewMsgHandleIdentityRecordsVerifyRequest(verifier sdk.AccAddress, requestId uint64, isApprove bool) *MsgHandleIdentityRecordsVerifyRequest { - return &MsgHandleIdentityRecordsVerifyRequest{ - Verifier: verifier, - VerifyRequestId: requestId, - Yes: isApprove, - } -} - -func (m *MsgHandleIdentityRecordsVerifyRequest) Route() string { - return ModuleName -} - -func (m *MsgHandleIdentityRecordsVerifyRequest) Type() string { - return types.MsgTypeHandleIdentityRecordsVerifyRequest -} - -func (m *MsgHandleIdentityRecordsVerifyRequest) ValidateBasic() error { - if m.Verifier.Empty() { - return ErrEmptyVerifierAccAddress - } - if m.VerifyRequestId == 0 { - return ErrInvalidVerifyRequestId - } - return nil -} - -func (m *MsgHandleIdentityRecordsVerifyRequest) GetSignBytes() []byte { - bz := ModuleCdc.MustMarshalJSON(m) - return sdk.MustSortJSON(bz) -} - -func (m *MsgHandleIdentityRecordsVerifyRequest) GetSigners() []sdk.AccAddress { - return []sdk.AccAddress{ - m.Verifier, - } -} - -func NewMsgCancelIdentityRecordsVerifyRequest(executor sdk.AccAddress, verifyRequestId uint64) *MsgCancelIdentityRecordsVerifyRequest { - return &MsgCancelIdentityRecordsVerifyRequest{ - Executor: executor, - VerifyRequestId: verifyRequestId, - } -} - -func (m *MsgCancelIdentityRecordsVerifyRequest) Route() string { - return ModuleName -} - -func (m *MsgCancelIdentityRecordsVerifyRequest) Type() string { - return types.MsgTypeCancelIdentityRecordsVerifyRequest -} - -func (m *MsgCancelIdentityRecordsVerifyRequest) ValidateBasic() error { - if m.Executor.Empty() { - return ErrEmptyProposerAccAddress - } - if m.VerifyRequestId == 0 { - return ErrInvalidVerifyRequestId - } - return nil -} - -func (m *MsgCancelIdentityRecordsVerifyRequest) GetSignBytes() []byte { - bz := ModuleCdc.MustMarshalJSON(m) - return sdk.MustSortJSON(bz) -} - -func (m *MsgCancelIdentityRecordsVerifyRequest) GetSigners() []sdk.AccAddress { - return []sdk.AccAddress{ - m.Executor, - } -} - -// NewMsgSubmitProposal creates a new MsgSubmitProposal. -//nolint:interfacer -func NewMsgSubmitProposal(proposer sdk.AccAddress, title, description string, content Content) (*MsgSubmitProposal, error) { - m := &MsgSubmitProposal{ - Proposer: proposer, - Title: title, - Description: description, - } - err := m.SetContent(content) - if err != nil { - return nil, err - } - return m, nil -} - -func (m *MsgSubmitProposal) GetProposer() sdk.AccAddress { - return m.Proposer -} - -func (m *MsgSubmitProposal) GetContent() Content { - content, ok := m.Content.GetCachedValue().(Content) - if !ok { - return nil - } - return content -} - -func (m *MsgSubmitProposal) SetContent(content Content) error { - msg, ok := content.(proto.Message) - if !ok { - return fmt.Errorf("can't proto marshal %T", msg) - } - any, err := codectypes.NewAnyWithValue(msg) - if err != nil { - return err - } - m.Content = any - return nil -} - -// Route implements Msg -func (m MsgSubmitProposal) Route() string { return RouterKey } - -// Type implements Msg -func (m MsgSubmitProposal) Type() string { return types.MsgTypeSubmitProposal } - -// ValidateBasic implements Msg -func (m MsgSubmitProposal) ValidateBasic() error { - if m.Proposer.Empty() { - return sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, m.Proposer.String()) - } - - content := m.GetContent() - if content == nil { - return sdkerrors.Wrap(ErrInvalidProposalContent, "missing content") - } - if err := content.ValidateBasic(); err != nil { - return err - } - - return nil -} - -// GetSignBytes implements Msg -func (m MsgSubmitProposal) GetSignBytes() []byte { - bz := ModuleCdc.MustMarshalJSON(&m) - return sdk.MustSortJSON(bz) -} - -// GetSigners implements Msg -func (m MsgSubmitProposal) GetSigners() []sdk.AccAddress { - return []sdk.AccAddress{m.Proposer} -} - -// String implements the Stringer interface -func (m MsgSubmitProposal) String() string { - out, _ := yaml.Marshal(m) - return string(out) -} - -// UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (m MsgSubmitProposal) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { - var content Content - return unpacker.UnpackAny(m.Content, &content) -} +package types + +import ( + "fmt" + "github.com/KiraCore/sekai/types" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + proto "github.com/gogo/protobuf/proto" + "gopkg.in/yaml.v2" +) + +var ( + // Proposal + _ sdk.Msg = &MsgVoteProposal{} + + // Permissions + _ sdk.Msg = &MsgWhitelistPermissions{} + _ sdk.Msg = &MsgBlacklistPermissions{} + _ sdk.Msg = &MsgSubmitProposal{} + + // Councilor + _ sdk.Msg = &MsgClaimCouncilor{} + + // Roles + _ sdk.Msg = &MsgCreateRole{} + _ sdk.Msg = &MsgAssignRole{} + _ sdk.Msg = &MsgRemoveRole{} + + _ sdk.Msg = &MsgWhitelistRolePermission{} + _ sdk.Msg = &MsgBlacklistRolePermission{} + _ sdk.Msg = &MsgRemoveWhitelistRolePermission{} + _ sdk.Msg = &MsgRemoveBlacklistRolePermission{} +) + +func NewMsgWhitelistPermissions( + proposer, address sdk.AccAddress, + permission uint32, +) *MsgWhitelistPermissions { + return &MsgWhitelistPermissions{ + Proposer: proposer, + Address: address, + Permission: permission, + } +} + +func (m *MsgWhitelistPermissions) Route() string { + return ModuleName +} + +func (m *MsgWhitelistPermissions) Type() string { + return types.MsgTypeWhitelistPermissions +} + +func (m *MsgWhitelistPermissions) ValidateBasic() error { + if m.Proposer.Empty() { + return ErrEmptyProposerAccAddress + } + + if m.Address.Empty() { + return ErrEmptyPermissionsAccAddress + } + + return nil +} + +func (m *MsgWhitelistPermissions) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(m) + return sdk.MustSortJSON(bz) +} + +func (m *MsgWhitelistPermissions) GetSigners() []sdk.AccAddress { + return []sdk.AccAddress{ + m.Proposer, + } +} + +func NewMsgRemoveWhitelistedPermissions( + proposer, address sdk.AccAddress, + permission uint32, +) *MsgRemoveWhitelistedPermissions { + return &MsgRemoveWhitelistedPermissions{ + Proposer: proposer, + Address: address, + Permission: permission, + } +} + +func (m *MsgRemoveWhitelistedPermissions) Route() string { + return ModuleName +} + +func (m *MsgRemoveWhitelistedPermissions) Type() string { + return types.MsgTypeBlacklistPermissions +} + +func (m *MsgRemoveWhitelistedPermissions) ValidateBasic() error { + if m.Proposer.Empty() { + return ErrEmptyProposerAccAddress + } + + if m.Address.Empty() { + return ErrEmptyPermissionsAccAddress + } + + return nil +} + +func (m *MsgRemoveWhitelistedPermissions) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(m) + return sdk.MustSortJSON(bz) +} + +func (m *MsgRemoveWhitelistedPermissions) GetSigners() []sdk.AccAddress { + return []sdk.AccAddress{ + m.Proposer, + } +} + +func NewMsgBlacklistPermissions( + proposer, address sdk.AccAddress, + permission uint32, +) *MsgBlacklistPermissions { + return &MsgBlacklistPermissions{ + Proposer: proposer, + Address: address, + Permission: permission, + } +} + +func (m *MsgBlacklistPermissions) Route() string { + return ModuleName +} + +func (m *MsgBlacklistPermissions) Type() string { + return types.MsgTypeBlacklistPermissions +} + +func (m *MsgBlacklistPermissions) ValidateBasic() error { + if m.Proposer.Empty() { + return ErrEmptyProposerAccAddress + } + + if m.Address.Empty() { + return ErrEmptyPermissionsAccAddress + } + + return nil +} + +func (m *MsgBlacklistPermissions) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(m) + return sdk.MustSortJSON(bz) +} + +func (m *MsgBlacklistPermissions) GetSigners() []sdk.AccAddress { + return []sdk.AccAddress{ + m.Proposer, + } +} + +func NewMsgRemoveBlacklistedPermissions( + proposer, address sdk.AccAddress, + permission uint32, +) *MsgRemoveBlacklistedPermissions { + return &MsgRemoveBlacklistedPermissions{ + Proposer: proposer, + Address: address, + Permission: permission, + } +} + +func (m *MsgRemoveBlacklistedPermissions) Route() string { + return ModuleName +} + +func (m *MsgRemoveBlacklistedPermissions) Type() string { + return types.MsgTypeBlacklistPermissions +} + +func (m *MsgRemoveBlacklistedPermissions) ValidateBasic() error { + if m.Proposer.Empty() { + return ErrEmptyProposerAccAddress + } + + if m.Address.Empty() { + return ErrEmptyPermissionsAccAddress + } + + return nil +} + +func (m *MsgRemoveBlacklistedPermissions) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(m) + return sdk.MustSortJSON(bz) +} + +func (m *MsgRemoveBlacklistedPermissions) GetSigners() []sdk.AccAddress { + return []sdk.AccAddress{ + m.Proposer, + } +} + +func NewMsgClaimCouncilor( + address sdk.AccAddress, + moniker string, + username string, + description string, + social string, + contact string, + avatar string, +) *MsgClaimCouncilor { + return &MsgClaimCouncilor{ + Address: address, + Moniker: moniker, + Username: username, + Description: description, + Social: social, + Contact: contact, + Avatar: avatar, + } +} + +func (m *MsgClaimCouncilor) Route() string { + return ModuleName +} + +func (m *MsgClaimCouncilor) Type() string { + return types.MsgTypeClaimCouncilor +} + +func (m *MsgClaimCouncilor) ValidateBasic() error { + if m.Address.Empty() { + return ErrCouncilorEmptyAddress + } + + return nil +} + +func (m *MsgClaimCouncilor) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(m) + return sdk.MustSortJSON(bz) +} + +func (m *MsgClaimCouncilor) GetSigners() []sdk.AccAddress { + return []sdk.AccAddress{ + m.Address, + } +} + +func NewMsgCouncilorPause( + address sdk.AccAddress, +) *MsgCouncilorPause { + return &MsgCouncilorPause{ + Sender: address.String(), + } +} + +func (m *MsgCouncilorPause) Route() string { + return ModuleName +} + +func (m *MsgCouncilorPause) Type() string { + return types.MsgTypeClaimCouncilor +} + +func (m *MsgCouncilorPause) ValidateBasic() error { + if m.Sender == "" { + return ErrCouncilorEmptyAddress + } + + return nil +} + +func (m *MsgCouncilorPause) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(m) + return sdk.MustSortJSON(bz) +} + +func (m *MsgCouncilorPause) GetSigners() []sdk.AccAddress { + addr, _ := sdk.AccAddressFromBech32(m.Sender) + return []sdk.AccAddress{ + addr, + } +} + +func NewMsgCouncilorUnpause( + address sdk.AccAddress, +) *MsgCouncilorUnpause { + return &MsgCouncilorUnpause{ + Sender: address.String(), + } +} + +func (m *MsgCouncilorUnpause) Route() string { + return ModuleName +} + +func (m *MsgCouncilorUnpause) Type() string { + return types.MsgTypeClaimCouncilor +} + +func (m *MsgCouncilorUnpause) ValidateBasic() error { + if m.Sender == "" { + return ErrCouncilorEmptyAddress + } + + return nil +} + +func (m *MsgCouncilorUnpause) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(m) + return sdk.MustSortJSON(bz) +} + +func (m *MsgCouncilorUnpause) GetSigners() []sdk.AccAddress { + addr, _ := sdk.AccAddressFromBech32(m.Sender) + return []sdk.AccAddress{ + addr, + } +} + +func NewMsgCouncilorActivate( + address sdk.AccAddress, +) *MsgCouncilorActivate { + return &MsgCouncilorActivate{ + Sender: address.String(), + } +} + +func (m *MsgCouncilorActivate) Route() string { + return ModuleName +} + +func (m *MsgCouncilorActivate) Type() string { + return types.MsgTypeClaimCouncilor +} + +func (m *MsgCouncilorActivate) ValidateBasic() error { + if m.Sender == "" { + return ErrCouncilorEmptyAddress + } + + return nil +} + +func (m *MsgCouncilorActivate) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(m) + return sdk.MustSortJSON(bz) +} + +func (m *MsgCouncilorActivate) GetSigners() []sdk.AccAddress { + addr, _ := sdk.AccAddressFromBech32(m.Sender) + return []sdk.AccAddress{ + addr, + } +} + +func NewMsgWhitelistRolePermission( + proposer sdk.AccAddress, + roleIdentifier string, + permission uint32, +) *MsgWhitelistRolePermission { + return &MsgWhitelistRolePermission{Proposer: proposer, RoleIdentifier: roleIdentifier, Permission: permission} +} + +func (m *MsgWhitelistRolePermission) Route() string { + return ModuleName +} + +func (m *MsgWhitelistRolePermission) Type() string { + return types.MsgTypeWhitelistRolePermission +} + +func (m *MsgWhitelistRolePermission) ValidateBasic() error { + if m.Proposer.Empty() { + return ErrEmptyProposerAccAddress + } + + return nil +} + +func (m *MsgWhitelistRolePermission) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(m) + return sdk.MustSortJSON(bz) +} + +func (m *MsgWhitelistRolePermission) GetSigners() []sdk.AccAddress { + return []sdk.AccAddress{ + m.Proposer, + } +} + +func NewMsgBlacklistRolePermission( + proposer sdk.AccAddress, + roleIdentifier string, + permission uint32, +) *MsgBlacklistRolePermission { + return &MsgBlacklistRolePermission{Proposer: proposer, RoleIdentifier: roleIdentifier, Permission: permission} +} + +func (m *MsgBlacklistRolePermission) Route() string { + return ModuleName +} + +func (m *MsgBlacklistRolePermission) Type() string { + return types.MsgTypeBlacklistRolePermission +} + +func (m *MsgBlacklistRolePermission) ValidateBasic() error { + if m.Proposer.Empty() { + return ErrEmptyProposerAccAddress + } + + return nil +} + +func (m *MsgBlacklistRolePermission) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(m) + return sdk.MustSortJSON(bz) +} + +func (m *MsgBlacklistRolePermission) GetSigners() []sdk.AccAddress { + return []sdk.AccAddress{ + m.Proposer, + } +} + +func NewMsgRemoveWhitelistRolePermission( + proposer sdk.AccAddress, + roleIdentifier string, + permission uint32, +) *MsgRemoveWhitelistRolePermission { + return &MsgRemoveWhitelistRolePermission{Proposer: proposer, RoleIdentifier: roleIdentifier, Permission: permission} +} + +func (m *MsgRemoveWhitelistRolePermission) Route() string { + return ModuleName +} + +func (m *MsgRemoveWhitelistRolePermission) Type() string { + return types.MsgTypeRemoveWhitelistRolePermission +} + +func (m *MsgRemoveWhitelistRolePermission) ValidateBasic() error { + if m.Proposer.Empty() { + return ErrEmptyProposerAccAddress + } + + return nil +} + +func (m *MsgRemoveWhitelistRolePermission) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(m) + return sdk.MustSortJSON(bz) +} + +func (m *MsgRemoveWhitelistRolePermission) GetSigners() []sdk.AccAddress { + return []sdk.AccAddress{ + m.Proposer, + } +} + +func NewMsgRemoveBlacklistRolePermission( + proposer sdk.AccAddress, + roleIdentifier string, + permission uint32, +) *MsgRemoveBlacklistRolePermission { + return &MsgRemoveBlacklistRolePermission{Proposer: proposer, RoleIdentifier: roleIdentifier, Permission: permission} +} + +func (m *MsgRemoveBlacklistRolePermission) Route() string { + return ModuleName +} + +func (m *MsgRemoveBlacklistRolePermission) Type() string { + return types.MsgTypeRemoveBlacklistRolePermission +} + +func (m *MsgRemoveBlacklistRolePermission) ValidateBasic() error { + if m.Proposer.Empty() { + return ErrEmptyProposerAccAddress + } + + return nil +} + +func (m *MsgRemoveBlacklistRolePermission) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(m) + return sdk.MustSortJSON(bz) +} + +func (m *MsgRemoveBlacklistRolePermission) GetSigners() []sdk.AccAddress { + return []sdk.AccAddress{ + m.Proposer, + } +} + +func NewMsgCreateRole(proposer sdk.AccAddress, sid, description string) *MsgCreateRole { + return &MsgCreateRole{Proposer: proposer, RoleSid: sid, RoleDescription: description} +} + +func (m *MsgCreateRole) Route() string { + return ModuleName +} + +func (m *MsgCreateRole) Type() string { + return types.MsgTypeCreateRole +} + +func (m *MsgCreateRole) ValidateBasic() error { + if m.Proposer.Empty() { + return ErrEmptyProposerAccAddress + } + + return nil +} + +func (m *MsgCreateRole) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(m) + return sdk.MustSortJSON(bz) +} + +func (m *MsgCreateRole) GetSigners() []sdk.AccAddress { + return []sdk.AccAddress{ + m.Proposer, + } +} + +func NewMsgAssignRole(proposer, address sdk.AccAddress, roleId uint32) *MsgAssignRole { + return &MsgAssignRole{Proposer: proposer, Address: address, RoleId: roleId} +} + +func (m *MsgAssignRole) Route() string { + return ModuleName +} + +func (m *MsgAssignRole) Type() string { + return types.MsgTypeAssignRole +} + +func (m *MsgAssignRole) ValidateBasic() error { + if m.Proposer.Empty() { + return ErrEmptyProposerAccAddress + } + + if m.Address.Empty() { + return ErrEmptyPermissionsAccAddress + } + + return nil +} + +func (m *MsgAssignRole) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(m) + return sdk.MustSortJSON(bz) +} + +func (m *MsgAssignRole) GetSigners() []sdk.AccAddress { + return []sdk.AccAddress{ + m.Proposer, + } +} + +func NewMsgRemoveRole(proposer, address sdk.AccAddress, roleId uint32) *MsgRemoveRole { + return &MsgRemoveRole{Proposer: proposer, Address: address, RoleId: roleId} +} + +func (m *MsgRemoveRole) Route() string { + return ModuleName +} + +func (m *MsgRemoveRole) Type() string { + return types.MsgTypeRemoveRole +} + +func (m *MsgRemoveRole) ValidateBasic() error { + if m.Proposer.Empty() { + return ErrEmptyProposerAccAddress + } + + if m.Address.Empty() { + return ErrEmptyPermissionsAccAddress + } + + return nil +} + +func (m *MsgRemoveRole) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(m) + return sdk.MustSortJSON(bz) +} + +func (m *MsgRemoveRole) GetSigners() []sdk.AccAddress { + return []sdk.AccAddress{ + m.Proposer, + } +} + +func NewMsgVoteProposal(proposalID uint64, voter sdk.AccAddress, option VoteOption, slash sdk.Dec) *MsgVoteProposal { + return &MsgVoteProposal{ + ProposalId: proposalID, + Voter: voter, + Option: option, + Slash: slash, + } +} + +func (m *MsgVoteProposal) Route() string { + return ModuleName +} + +func (m *MsgVoteProposal) Type() string { + return types.MsgTypeVoteProposal +} + +func (m *MsgVoteProposal) ValidateBasic() error { + if m.Voter.Empty() { + return ErrEmptyProposerAccAddress + } + + return nil +} + +func (m *MsgVoteProposal) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(m) + return sdk.MustSortJSON(bz) +} + +func (m *MsgVoteProposal) GetSigners() []sdk.AccAddress { + return []sdk.AccAddress{ + m.Voter, + } +} + +// NewMsgPollCreate creates a new MsgPollCreate. +//nolint:interfacer +func NewMsgPollCreate(creator sdk.AccAddress, title, description string, reference string, checksum string, pollValues []string, roles []string, valueCount uint64, valueType string, possibleChoices uint64, duration string) *MsgPollCreate { + m := &MsgPollCreate{ + Creator: creator, + Title: title, + Description: description, + Reference: reference, + Checksum: checksum, + PollValues: pollValues, + Roles: roles, + ValueCount: valueCount, + ValueType: valueType, + PossibleChoices: possibleChoices, + Duration: duration, + } + + return m +} + +func (m *MsgPollCreate) GetProposer() sdk.AccAddress { + return m.Creator +} + +// Route implements Msg +func (m MsgPollCreate) Route() string { return RouterKey } + +// Type implements Msg +func (m MsgPollCreate) Type() string { return types.MsgTypeCreatePoll } + +// ValidateBasic implements Msg +func (m MsgPollCreate) ValidateBasic() error { + if m.Creator.Empty() { + return sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, m.Creator.String()) + } + + return nil +} + +func (m *MsgPollCreate) GetSigners() []sdk.AccAddress { + return []sdk.AccAddress{ + m.Creator, + } +} + +func NewMsgVotePoll(polllID uint64, voter sdk.AccAddress, option PollVoteOption, value string) *MsgPollVote { + return &MsgPollVote{ + PollId: polllID, + Voter: voter, + Option: option, + Value: value, + } +} + +func (m *MsgPollVote) Route() string { + return ModuleName +} + +func (m *MsgPollVote) Type() string { + return types.MsgTypeVotePoll +} + +func (m *MsgPollVote) ValidateBasic() error { + if m.Voter.Empty() { + return ErrEmptyProposerAccAddress + } + + return nil +} + +func (m *MsgPollVote) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(m) + return sdk.MustSortJSON(bz) +} + +func (m *MsgPollVote) GetSigners() []sdk.AccAddress { + return []sdk.AccAddress{ + m.Voter, + } +} + +func NewMsgRegisterIdentityRecords(address sdk.AccAddress, infos []IdentityInfoEntry) *MsgRegisterIdentityRecords { + return &MsgRegisterIdentityRecords{ + Address: address, + Infos: infos, + } +} + +func (m *MsgRegisterIdentityRecords) Route() string { + return ModuleName +} + +func (m *MsgRegisterIdentityRecords) Type() string { + return types.MsgTypeRegisterIdentityRecords +} + +func (m *MsgRegisterIdentityRecords) ValidateBasic() error { + if m.Address.Empty() { + return ErrEmptyProposerAccAddress + } + if len(m.Infos) == 0 { + return ErrEmptyInfos + } + return nil +} + +func (m *MsgRegisterIdentityRecords) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(m) + return sdk.MustSortJSON(bz) +} + +func (m *MsgRegisterIdentityRecords) GetSigners() []sdk.AccAddress { + return []sdk.AccAddress{ + m.Address, + } +} + +func NewMsgDeleteIdentityRecords(address sdk.AccAddress, keys []string) *MsgDeleteIdentityRecords { + return &MsgDeleteIdentityRecords{ + Address: address, + Keys: keys, + } +} + +func (m *MsgDeleteIdentityRecords) Route() string { + return ModuleName +} + +func (m *MsgDeleteIdentityRecords) Type() string { + return types.MsgTypeEditIdentityRecord +} + +func (m *MsgDeleteIdentityRecords) ValidateBasic() error { + if m.Address.Empty() { + return ErrEmptyProposerAccAddress + } + return nil +} + +func (m *MsgDeleteIdentityRecords) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(m) + return sdk.MustSortJSON(bz) +} + +func (m *MsgDeleteIdentityRecords) GetSigners() []sdk.AccAddress { + return []sdk.AccAddress{ + m.Address, + } +} + +func NewMsgRequestIdentityRecordsVerify(address, verifier sdk.AccAddress, recordIds []uint64, tip sdk.Coin) *MsgRequestIdentityRecordsVerify { + return &MsgRequestIdentityRecordsVerify{ + Address: address, + Verifier: verifier, + RecordIds: recordIds, + Tip: tip, + } +} + +func (m *MsgRequestIdentityRecordsVerify) Route() string { + return ModuleName +} + +func (m *MsgRequestIdentityRecordsVerify) Type() string { + return types.MsgTypeRequestIdentityRecordsVerify +} + +func (m *MsgRequestIdentityRecordsVerify) ValidateBasic() error { + if m.Address.Empty() { + return ErrEmptyProposerAccAddress + } + if m.Verifier.Empty() { + return ErrEmptyVerifierAccAddress + } + if !m.Tip.IsValid() { + return ErrInvalidTip + } + if len(m.RecordIds) == 0 { + return ErrInvalidRecordIds + } + return nil +} + +func (m *MsgRequestIdentityRecordsVerify) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(m) + return sdk.MustSortJSON(bz) +} + +func (m *MsgRequestIdentityRecordsVerify) GetSigners() []sdk.AccAddress { + return []sdk.AccAddress{ + m.Address, + } +} + +func NewMsgHandleIdentityRecordsVerifyRequest(verifier sdk.AccAddress, requestId uint64, isApprove bool) *MsgHandleIdentityRecordsVerifyRequest { + return &MsgHandleIdentityRecordsVerifyRequest{ + Verifier: verifier, + VerifyRequestId: requestId, + Yes: isApprove, + } +} + +func (m *MsgHandleIdentityRecordsVerifyRequest) Route() string { + return ModuleName +} + +func (m *MsgHandleIdentityRecordsVerifyRequest) Type() string { + return types.MsgTypeHandleIdentityRecordsVerifyRequest +} + +func (m *MsgHandleIdentityRecordsVerifyRequest) ValidateBasic() error { + if m.Verifier.Empty() { + return ErrEmptyVerifierAccAddress + } + if m.VerifyRequestId == 0 { + return ErrInvalidVerifyRequestId + } + return nil +} + +func (m *MsgHandleIdentityRecordsVerifyRequest) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(m) + return sdk.MustSortJSON(bz) +} + +func (m *MsgHandleIdentityRecordsVerifyRequest) GetSigners() []sdk.AccAddress { + return []sdk.AccAddress{ + m.Verifier, + } +} + +func NewMsgCancelIdentityRecordsVerifyRequest(executor sdk.AccAddress, verifyRequestId uint64) *MsgCancelIdentityRecordsVerifyRequest { + return &MsgCancelIdentityRecordsVerifyRequest{ + Executor: executor, + VerifyRequestId: verifyRequestId, + } +} + +func (m *MsgCancelIdentityRecordsVerifyRequest) Route() string { + return ModuleName +} + +func (m *MsgCancelIdentityRecordsVerifyRequest) Type() string { + return types.MsgTypeCancelIdentityRecordsVerifyRequest +} + +func (m *MsgCancelIdentityRecordsVerifyRequest) ValidateBasic() error { + if m.Executor.Empty() { + return ErrEmptyProposerAccAddress + } + if m.VerifyRequestId == 0 { + return ErrInvalidVerifyRequestId + } + return nil +} + +func (m *MsgCancelIdentityRecordsVerifyRequest) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(m) + return sdk.MustSortJSON(bz) +} + +func (m *MsgCancelIdentityRecordsVerifyRequest) GetSigners() []sdk.AccAddress { + return []sdk.AccAddress{ + m.Executor, + } +} + +// NewMsgSubmitProposal creates a new MsgSubmitProposal. +//nolint:interfacer +func NewMsgSubmitProposal(proposer sdk.AccAddress, title, description string, content Content) (*MsgSubmitProposal, error) { + m := &MsgSubmitProposal{ + Proposer: proposer, + Title: title, + Description: description, + } + err := m.SetContent(content) + if err != nil { + return nil, err + } + return m, nil +} + +func (m *MsgSubmitProposal) GetProposer() sdk.AccAddress { + return m.Proposer +} + +func (m *MsgSubmitProposal) GetContent() Content { + content, ok := m.Content.GetCachedValue().(Content) + if !ok { + return nil + } + return content +} + +func (m *MsgSubmitProposal) SetContent(content Content) error { + msg, ok := content.(proto.Message) + if !ok { + return fmt.Errorf("can't proto marshal %T", msg) + } + any, err := codectypes.NewAnyWithValue(msg) + if err != nil { + return err + } + m.Content = any + return nil +} + +// Route implements Msg +func (m MsgSubmitProposal) Route() string { return RouterKey } + +// Type implements Msg +func (m MsgSubmitProposal) Type() string { return types.MsgTypeSubmitProposal } + +// ValidateBasic implements Msg +func (m MsgSubmitProposal) ValidateBasic() error { + if m.Proposer.Empty() { + return sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, m.Proposer.String()) + } + + content := m.GetContent() + if content == nil { + return sdkerrors.Wrap(ErrInvalidProposalContent, "missing content") + } + if err := content.ValidateBasic(); err != nil { + return err + } + + return nil +} + +// GetSignBytes implements Msg +func (m MsgSubmitProposal) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(&m) + return sdk.MustSortJSON(bz) +} + +// GetSigners implements Msg +func (m MsgSubmitProposal) GetSigners() []sdk.AccAddress { + return []sdk.AccAddress{m.Proposer} +} + +// String implements the Stringer interface +func (m MsgSubmitProposal) String() string { + out, _ := yaml.Marshal(m) + return string(out) +} + +// UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces +func (m MsgSubmitProposal) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { + var content Content + return unpacker.UnpackAny(m.Content, &content) +} diff --git a/x/gov/types/msg_execution_fee.go b/x/gov/types/msg_execution_fee.go index a7e2e4e46..c9904b82b 100644 --- a/x/gov/types/msg_execution_fee.go +++ b/x/gov/types/msg_execution_fee.go @@ -1,53 +1,53 @@ -package types - -import ( - "github.com/KiraCore/sekai/types" - sdk "github.com/cosmos/cosmos-sdk/types" -) - -var _ sdk.Msg = &MsgSetExecutionFee{} - -func NewMsgSetExecutionFee( - transactionType string, - executionFee uint64, - failureFee uint64, - timeout uint64, - defaultParams uint64, - proposer sdk.AccAddress, -) *MsgSetExecutionFee { - return &MsgSetExecutionFee{ - TransactionType: transactionType, - ExecutionFee: executionFee, - FailureFee: failureFee, - Timeout: timeout, - DefaultParameters: defaultParams, - Proposer: proposer, - } -} - -func (m *MsgSetExecutionFee) Route() string { - return ModuleName -} - -func (m *MsgSetExecutionFee) Type() string { - return types.MsgTypeSetExecutionFee -} - -func (m *MsgSetExecutionFee) ValidateBasic() error { - if m.Proposer.Empty() { - return ErrEmptyProposerAccAddress - } - - return nil -} - -func (m *MsgSetExecutionFee) GetSignBytes() []byte { - bz := ModuleCdc.MustMarshalJSON(m) - return sdk.MustSortJSON(bz) -} - -func (m *MsgSetExecutionFee) GetSigners() []sdk.AccAddress { - return []sdk.AccAddress{ - m.Proposer, - } -} +package types + +import ( + "github.com/KiraCore/sekai/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +var _ sdk.Msg = &MsgSetExecutionFee{} + +func NewMsgSetExecutionFee( + transactionType string, + executionFee uint64, + failureFee uint64, + timeout uint64, + defaultParams uint64, + proposer sdk.AccAddress, +) *MsgSetExecutionFee { + return &MsgSetExecutionFee{ + TransactionType: transactionType, + ExecutionFee: executionFee, + FailureFee: failureFee, + Timeout: timeout, + DefaultParameters: defaultParams, + Proposer: proposer, + } +} + +func (m *MsgSetExecutionFee) Route() string { + return ModuleName +} + +func (m *MsgSetExecutionFee) Type() string { + return types.MsgTypeSetExecutionFee +} + +func (m *MsgSetExecutionFee) ValidateBasic() error { + if m.Proposer.Empty() { + return ErrEmptyProposerAccAddress + } + + return nil +} + +func (m *MsgSetExecutionFee) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(m) + return sdk.MustSortJSON(bz) +} + +func (m *MsgSetExecutionFee) GetSigners() []sdk.AccAddress { + return []sdk.AccAddress{ + m.Proposer, + } +} diff --git a/x/gov/types/msg_test.go b/x/gov/types/msg_test.go index 8bcadabad..201de0ea2 100644 --- a/x/gov/types/msg_test.go +++ b/x/gov/types/msg_test.go @@ -1,96 +1,96 @@ -package types - -import ( - "testing" - - "github.com/stretchr/testify/require" - - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" -) - -func TestMsgWhitelistPermissions_ValidateBasic(t *testing.T) { - tests := []struct { - name string - msg *MsgWhitelistPermissions - expectedErr *sdkerrors.Error - }{ - { - name: "empty proposer addr", - msg: NewMsgWhitelistPermissions( - sdk.AccAddress{}, - sdk.AccAddress("some addr"), - 0, - ), - expectedErr: ErrEmptyProposerAccAddress, - }, - { - name: "empty addr", - msg: NewMsgWhitelistPermissions( - sdk.AccAddress("some addr"), - sdk.AccAddress{}, - 0, - ), - expectedErr: ErrEmptyPermissionsAccAddress, - }, - } - for _, test := range tests { - test := test - - t.Run(test.name, func(t *testing.T) { - require.Equal(t, test.expectedErr, test.msg.ValidateBasic()) - }) - } -} - -func TestMsgRequestIdentityRecordsVerify_ValidateBasic(t *testing.T) { - addr1 := sdk.AccAddress("foo1________________") - addr3 := sdk.AccAddress("foo3________________") - empty := sdk.AccAddress("") - msg := MsgRequestIdentityRecordsVerify{ - Address: addr1, - Verifier: addr3, - RecordIds: []uint64{1}, - Tip: sdk.Coin{}, - } - require.Error(t, msg.ValidateBasic()) - - msg = MsgRequestIdentityRecordsVerify{ - Address: addr1, - Verifier: addr3, - RecordIds: []uint64{1}, - Tip: sdk.NewInt64Coin(sdk.DefaultBondDenom, 0), - } - require.NoError(t, msg.ValidateBasic()) - - msg = MsgRequestIdentityRecordsVerify{ - Address: addr1, - Verifier: addr3, - RecordIds: []uint64{}, - Tip: sdk.NewInt64Coin(sdk.DefaultBondDenom, 10), - } - require.Error(t, msg.ValidateBasic()) - - msg = MsgRequestIdentityRecordsVerify{ - Address: addr1, - Verifier: empty, - RecordIds: []uint64{}, - Tip: sdk.NewInt64Coin(sdk.DefaultBondDenom, 10), - } - require.Error(t, msg.ValidateBasic()) - msg = MsgRequestIdentityRecordsVerify{ - Address: empty, - Verifier: addr1, - RecordIds: []uint64{}, - Tip: sdk.NewInt64Coin(sdk.DefaultBondDenom, 10), - } - require.Error(t, msg.ValidateBasic()) - - msg = MsgRequestIdentityRecordsVerify{ - Address: addr1, - Verifier: addr3, - RecordIds: []uint64{1}, - Tip: sdk.NewInt64Coin(sdk.DefaultBondDenom, 10), - } - require.NoError(t, msg.ValidateBasic()) -} +package types + +import ( + "testing" + + "github.com/stretchr/testify/require" + + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +func TestMsgWhitelistPermissions_ValidateBasic(t *testing.T) { + tests := []struct { + name string + msg *MsgWhitelistPermissions + expectedErr *sdkerrors.Error + }{ + { + name: "empty proposer addr", + msg: NewMsgWhitelistPermissions( + sdk.AccAddress{}, + sdk.AccAddress("some addr"), + 0, + ), + expectedErr: ErrEmptyProposerAccAddress, + }, + { + name: "empty addr", + msg: NewMsgWhitelistPermissions( + sdk.AccAddress("some addr"), + sdk.AccAddress{}, + 0, + ), + expectedErr: ErrEmptyPermissionsAccAddress, + }, + } + for _, test := range tests { + test := test + + t.Run(test.name, func(t *testing.T) { + require.Equal(t, test.expectedErr, test.msg.ValidateBasic()) + }) + } +} + +func TestMsgRequestIdentityRecordsVerify_ValidateBasic(t *testing.T) { + addr1 := sdk.AccAddress("foo1________________") + addr3 := sdk.AccAddress("foo3________________") + empty := sdk.AccAddress("") + msg := MsgRequestIdentityRecordsVerify{ + Address: addr1, + Verifier: addr3, + RecordIds: []uint64{1}, + Tip: sdk.Coin{}, + } + require.Error(t, msg.ValidateBasic()) + + msg = MsgRequestIdentityRecordsVerify{ + Address: addr1, + Verifier: addr3, + RecordIds: []uint64{1}, + Tip: sdk.NewInt64Coin(sdk.DefaultBondDenom, 0), + } + require.NoError(t, msg.ValidateBasic()) + + msg = MsgRequestIdentityRecordsVerify{ + Address: addr1, + Verifier: addr3, + RecordIds: []uint64{}, + Tip: sdk.NewInt64Coin(sdk.DefaultBondDenom, 10), + } + require.Error(t, msg.ValidateBasic()) + + msg = MsgRequestIdentityRecordsVerify{ + Address: addr1, + Verifier: empty, + RecordIds: []uint64{}, + Tip: sdk.NewInt64Coin(sdk.DefaultBondDenom, 10), + } + require.Error(t, msg.ValidateBasic()) + msg = MsgRequestIdentityRecordsVerify{ + Address: empty, + Verifier: addr1, + RecordIds: []uint64{}, + Tip: sdk.NewInt64Coin(sdk.DefaultBondDenom, 10), + } + require.Error(t, msg.ValidateBasic()) + + msg = MsgRequestIdentityRecordsVerify{ + Address: addr1, + Verifier: addr3, + RecordIds: []uint64{1}, + Tip: sdk.NewInt64Coin(sdk.DefaultBondDenom, 10), + } + require.NoError(t, msg.ValidateBasic()) +} diff --git a/x/gov/types/network_properties.go b/x/gov/types/network_properties.go new file mode 100644 index 000000000..275947ff1 --- /dev/null +++ b/x/gov/types/network_properties.go @@ -0,0 +1,200 @@ +package types + +type PropertyInfo struct { + Name string `json:"name"` + Format string `json:"format"` + Description string `json:"description"` +} + +var PropertyMetadata = []PropertyInfo{ + { + Name: "MinTxFee", + Format: "uint64", + Description: "Minimum transaction fee on the network", + }, + { + Name: "MaxTxFee", + Format: "uint64", + Description: "Maximum transaction fee on the network", + }, + { + Name: "VoteQuorum", + Format: "uint64", + Description: "Vote quorum to meet for a proposal to pass.", + }, + { + Name: "MinimumProposalEndTime", + Format: "uint64", + Description: "Minimum proposal voting duration for a proposal should be live for voting.", + }, + { + Name: "ProposalEnactmentTime", + Format: "uint64", + Description: "Proposal enactment time.", + }, + { + Name: "MinProposalEndBlocks", + Format: "uint64", + Description: "Minimum number of blocks a proposal should be live for voting.", + }, + { + Name: "MinProposalEnactmentBlocks", + Format: "uint64", + Description: "Minimum number of blocks a proposal should be in enactment.", + }, + { + Name: "EnableForeignFeePayments", + Format: "bool", + Description: "Flag that describes foreign token (non-KEX) is enabled as fees.", + }, + { + Name: "MischanceRankDecreaseAmount", + Format: "uint64", + Description: "Rank decrease amount when a validator miss a block.", + }, + { + Name: "MaxMischance", + Format: "uint64", + Description: "Maximun number of sequencial miss on blocks before penalties.", + }, + { + Name: "MischanceConfidence", + Format: "uint64", + Description: "Number of missed blocks accepted before increasing misschance.", + }, + { + Name: "InactiveRankDecreasePercent", + Format: "decimal", + Description: "Percentage of rank decrease when a validator node become inactive.", + }, + { + Name: "MinValidators", + Format: "uint64", + Description: "Number of active validators to be an active network.", + }, + { + Name: "PoorNetworkMaxBankSend", + Format: "uint64", + Description: "Maximum number of tokens transferrable on poor network.", + }, + { + Name: "UnjailMaxTime", + Format: "uint64", + Description: "Maximum time a validator can unjail after jail.", + }, + { + Name: "EnableTokenWhitelist", + Format: "bool", + Description: "Flag to let only whitelisted tokens are transferrable", + }, + { + Name: "EnableTokenBlacklist", + Format: "bool", + Description: "Flag to prevent transfer of blacklisted tokens", + }, + { + Name: "MinIdentityApprovalTip", + Format: "uint64", + Description: "Minimum amount of tokens to be given for an identity record approval", + }, + { + Name: "UniqueIdentityKeys", + Format: "string", + Description: "Comma separated list of identity keys that should be unique across all identity keys", + }, + { + Name: "UbiHardcap", + Format: "uint64", + Description: "The maximum amount of tokens that can be allocated for sum of ubi records", + }, + { + Name: "ValidatorsFeeShare", + Format: "decimal", + Description: "The portion of fees to be given to the validator from the block fees", + }, + { + Name: "InflationRate", + Format: "decimal", + Description: "The rate of inflation during the inflation period", + }, + { + Name: "InflationPeriod", + Format: "uint64", + Description: "The duration unit for InflationRate", + }, + { + Name: "UnstakingPeriod", + Format: "uint64", + Description: "The unstaking duration on multistaking module", + }, + { + Name: "MaxDelegators", + Format: "uint64", + Description: "The maximum number of pool delegators for a single pool", + }, + { + Name: "MinDelegationPushout", + Format: "uint64", + Description: "The multiplier to push out a min delegation user when the maximum number of delegators filled in", + }, + { + Name: "SlashingPeriod", + Format: "uint64", + Description: "The period to take colluders on slash proposal", + }, + { + Name: "MaxJailedPercentage", + Format: "decimal", + Description: "The percentage of jails acceptable before slash proposal happens", + }, + { + Name: "MaxSlashingPercentage", + Format: "decimal", + Description: "The maximum slash percentage to for jail", + }, + { + Name: "MinCustodyReward", + Format: "uint64", + Description: "The minimum custody reward", + }, + { + Name: "MaxCustodyBufferSize", + Format: "uint64", + Description: "The minimum custody buffer size", + }, + { + Name: "MaxCustodyTxSize", + Format: "uint64", + Description: "The minimum custody transaction size", + }, + { + Name: "AbstentionRankDecreaseAmount", + Format: "uint64", + Description: "Rank decrease amount when a councilor does not participate in voting", + }, + { + Name: "MaxAbstention", + Format: "uint64", + Description: "The maximum absention count on voting for an active councilor", + }, + { + Name: "MinCollectiveBond", + Format: "uint64", + Description: "The minimum size of collective to be bootstrapped within bonding period", + }, + { + Name: "MinCollectiveBondingTime", + Format: "uint64", + Description: "The time to bootstrap minimum collectives bonds", + }, + { + Name: "MaxCollectiveOutputs", + Format: "uint64", + Description: "The maximum number of outputs a bonding pool could have", + }, + { + Name: "MinCollectiveClaimPeriod", + Format: "uint64", + Description: "The minimum acceptable collective claim period", + }, +} diff --git a/x/gov/types/network_properties.pb.go b/x/gov/types/network_properties.pb.go index 9a297a088..2224200cb 100644 --- a/x/gov/types/network_properties.pb.go +++ b/x/gov/types/network_properties.pb.go @@ -27,44 +27,65 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type NetworkProperty int32 const ( - MinTxFee NetworkProperty = 0 - MaxTxFee NetworkProperty = 1 - VoteQuorum NetworkProperty = 2 - MinimumProposalEndTime NetworkProperty = 3 - ProposalEnactmentTime NetworkProperty = 4 - MinProposalEndBlocks NetworkProperty = 5 - MinProposalEnactmentBlocks NetworkProperty = 6 - EnableForeignFeePayments NetworkProperty = 7 - MischanceRankDecreaseAmount NetworkProperty = 8 - MaxMischance NetworkProperty = 9 - MischanceConfidence NetworkProperty = 10 - InactiveRankDecreasePercent NetworkProperty = 11 - PoorNetworkMaxBankSend NetworkProperty = 12 - MinValidators NetworkProperty = 13 - UnjailMaxTime NetworkProperty = 14 - EnableTokenWhitelist NetworkProperty = 15 - EnableTokenBlacklist NetworkProperty = 16 - MinIdentityApprovalTip NetworkProperty = 17 - UniqueIdentityKeys NetworkProperty = 18 - UbiHardcap NetworkProperty = 19 - ValidatorsFeeShare NetworkProperty = 20 - InflationRate NetworkProperty = 21 - InflationPeriod NetworkProperty = 22 - UnstakingPeriod NetworkProperty = 23 - MaxDelegators NetworkProperty = 24 - MinDelegationPushout NetworkProperty = 25 - SlashingPeriod NetworkProperty = 26 - MaxJailedPercentage NetworkProperty = 27 - MaxSlashingPercentage NetworkProperty = 28 - MinCustodyReward NetworkProperty = 29 - MaxCustodyBufferSize NetworkProperty = 30 - MaxCustodyTxSize NetworkProperty = 31 - AbstentionRankDecreaseAmount NetworkProperty = 32 - MaxAbstention NetworkProperty = 33 - MinCollectiveBond NetworkProperty = 34 - MinCollectiveBondingTime NetworkProperty = 35 - MaxCollectiveOutputs NetworkProperty = 36 - MinCollectiveClaimPeriod NetworkProperty = 37 + MinTxFee NetworkProperty = 0 + MaxTxFee NetworkProperty = 1 + VoteQuorum NetworkProperty = 2 + MinimumProposalEndTime NetworkProperty = 3 + ProposalEnactmentTime NetworkProperty = 4 + MinProposalEndBlocks NetworkProperty = 5 + MinProposalEnactmentBlocks NetworkProperty = 6 + EnableForeignFeePayments NetworkProperty = 7 + MischanceRankDecreaseAmount NetworkProperty = 8 + MaxMischance NetworkProperty = 9 + MischanceConfidence NetworkProperty = 10 + InactiveRankDecreasePercent NetworkProperty = 11 + PoorNetworkMaxBankSend NetworkProperty = 12 + MinValidators NetworkProperty = 13 + UnjailMaxTime NetworkProperty = 14 + EnableTokenWhitelist NetworkProperty = 15 + EnableTokenBlacklist NetworkProperty = 16 + MinIdentityApprovalTip NetworkProperty = 17 + UniqueIdentityKeys NetworkProperty = 18 + UbiHardcap NetworkProperty = 19 + ValidatorsFeeShare NetworkProperty = 20 + InflationRate NetworkProperty = 21 + InflationPeriod NetworkProperty = 22 + UnstakingPeriod NetworkProperty = 23 + MaxDelegators NetworkProperty = 24 + MinDelegationPushout NetworkProperty = 25 + SlashingPeriod NetworkProperty = 26 + MaxJailedPercentage NetworkProperty = 27 + MaxSlashingPercentage NetworkProperty = 28 + MinCustodyReward NetworkProperty = 29 + MaxCustodyBufferSize NetworkProperty = 30 + MaxCustodyTxSize NetworkProperty = 31 + AbstentionRankDecreaseAmount NetworkProperty = 32 + MaxAbstention NetworkProperty = 33 + MinCollectiveBond NetworkProperty = 34 + MinCollectiveBondingTime NetworkProperty = 35 + MaxCollectiveOutputs NetworkProperty = 36 + MinCollectiveClaimPeriod NetworkProperty = 37 + ValidatorRecoveryBond NetworkProperty = 38 + MaxAnnualInflation NetworkProperty = 39 + MaxProposalTitleSize NetworkProperty = 40 + MaxProposalDescriptionSize NetworkProperty = 41 + MaxProposalPollOptionSize NetworkProperty = 42 + MaxProposalPollOptionCount NetworkProperty = 43 + MaxProposalReferenceSize NetworkProperty = 44 + MaxProposalChecksumSize NetworkProperty = 45 + MinDappBond NetworkProperty = 46 + MaxDappBond NetworkProperty = 47 + DappLiquidationThreshold NetworkProperty = 48 + DappLiquidationPeriod NetworkProperty = 49 + DappBondDuration NetworkProperty = 50 + DappVerifierBond NetworkProperty = 51 + DappAutoDenounceTime NetworkProperty = 52 + DappMischanceRankDecreaseAmount NetworkProperty = 53 + DappMaxMischance NetworkProperty = 54 + DappInactiveRankDecreasePercent NetworkProperty = 55 + DappPoolSlippageDefault NetworkProperty = 56 + MintingFtFee NetworkProperty = 57 + MintingNftFee NetworkProperty = 58 ) var NetworkProperty_name = map[int32]string{ @@ -106,47 +127,89 @@ var NetworkProperty_name = map[int32]string{ 35: "MIN_COLLECTIVE_BONDING_TIME", 36: "MAX_COLLECTIVE_OUTPUTS", 37: "MIN_COLLECTIVE_CLAIM_PERIOD", + 38: "VALIDATOR_RECOVERY_BOND", + 39: "MAX_ANNUAL_INFLATION", + 40: "MAX_PROPOSAL_TITLE_SIZE", + 41: "MAX_PROPOSAL_DESCRIPTION_SIZE", + 42: "MAX_PROPOSAL_POLL_OPTION_SIZE", + 43: "MAX_PROPOSAL_POLL_OPTION_COUNT", + 44: "MAX_PROPOSAL_REFERENCE_SIZE", + 45: "MAX_PROPOSAL_CHECKSUM_SIZE", + 46: "MIN_DAPP_BOND", + 47: "MAX_DAPP_BOND", + 48: "DAPP_LIQUIDATION_THRESHOLD", + 49: "DAPP_LIQUIDATION_PERIOD", + 50: "DAPP_BOND_DURATION", + 51: "DAPP_VERIFIER_BOND", + 52: "DAPP_AUTO_DENOUNCE_TIME", + 53: "DAPP_MISCHANCE_RANK_DECREASE_AMOUNT", + 54: "DAPP_MAX_MISCHANCE", + 55: "DAPP_INACTIVE_RANK_DECREASE_PERCENT", + 56: "DAPP_POOL_SLIPPAGE_DEFAULT", + 57: "MINTING_FT_FEE", + 58: "MINTING_NFT_FEE", } var NetworkProperty_value = map[string]int32{ - "MIN_TX_FEE": 0, - "MAX_TX_FEE": 1, - "VOTE_QUORUM": 2, - "MINIMUM_PROPOSAL_END_TIME": 3, - "PROPOSAL_ENACTMENT_TIME": 4, - "MIN_PROPOSAL_END_BLOCKS": 5, - "MIN_PROPOSAL_ENACTMENT_BLOCKS": 6, - "ENABLE_FOREIGN_FEE_PAYMENTS": 7, - "MISCHANCE_RANK_DECREASE_AMOUNT": 8, - "MAX_MISCHANCE": 9, - "MISCHANCE_CONFIDENCE": 10, - "INACTIVE_RANK_DECREASE_PERCENT": 11, - "POOR_NETWORK_MAX_BANK_SEND": 12, - "MIN_VALIDATORS": 13, - "UNJAIL_MAX_TIME": 14, - "ENABLE_TOKEN_WHITELIST": 15, - "ENABLE_TOKEN_BLACKLIST": 16, - "MIN_IDENTITY_APPROVAL_TIP": 17, - "UNIQUE_IDENTITY_KEYS": 18, - "UBI_HARDCAP": 19, - "VALIDATORS_FEE_SHARE": 20, - "INFLATION_RATE": 21, - "INFLATION_PERIOD": 22, - "UNSTAKING_PERIOD": 23, - "MAX_DELEGATORS": 24, - "MIN_DELEGATION_PUSHOUT": 25, - "SLASHING_PERIOD": 26, - "MAX_JAILED_PERCENTAGE": 27, - "MAX_SLASHING_PERCENTAGE": 28, - "MIN_CUSTODY_REWARD": 29, - "MAX_CUSTODY_BUFFER_SIZE": 30, - "MAX_CUSTODY_TX_SIZE": 31, - "ABSTENTION_RANK_DECREASE_AMOUNT": 32, - "MAX_ABSTENTION": 33, - "MIN_COLLECTIVE_BOND": 34, - "MIN_COLLECTIVE_BONDING_TIME": 35, - "MAX_COLLECTIVE_OUTPUTS": 36, - "MIN_COLLECTIVE_CLAIM_PERIOD": 37, + "MIN_TX_FEE": 0, + "MAX_TX_FEE": 1, + "VOTE_QUORUM": 2, + "MINIMUM_PROPOSAL_END_TIME": 3, + "PROPOSAL_ENACTMENT_TIME": 4, + "MIN_PROPOSAL_END_BLOCKS": 5, + "MIN_PROPOSAL_ENACTMENT_BLOCKS": 6, + "ENABLE_FOREIGN_FEE_PAYMENTS": 7, + "MISCHANCE_RANK_DECREASE_AMOUNT": 8, + "MAX_MISCHANCE": 9, + "MISCHANCE_CONFIDENCE": 10, + "INACTIVE_RANK_DECREASE_PERCENT": 11, + "POOR_NETWORK_MAX_BANK_SEND": 12, + "MIN_VALIDATORS": 13, + "UNJAIL_MAX_TIME": 14, + "ENABLE_TOKEN_WHITELIST": 15, + "ENABLE_TOKEN_BLACKLIST": 16, + "MIN_IDENTITY_APPROVAL_TIP": 17, + "UNIQUE_IDENTITY_KEYS": 18, + "UBI_HARDCAP": 19, + "VALIDATORS_FEE_SHARE": 20, + "INFLATION_RATE": 21, + "INFLATION_PERIOD": 22, + "UNSTAKING_PERIOD": 23, + "MAX_DELEGATORS": 24, + "MIN_DELEGATION_PUSHOUT": 25, + "SLASHING_PERIOD": 26, + "MAX_JAILED_PERCENTAGE": 27, + "MAX_SLASHING_PERCENTAGE": 28, + "MIN_CUSTODY_REWARD": 29, + "MAX_CUSTODY_BUFFER_SIZE": 30, + "MAX_CUSTODY_TX_SIZE": 31, + "ABSTENTION_RANK_DECREASE_AMOUNT": 32, + "MAX_ABSTENTION": 33, + "MIN_COLLECTIVE_BOND": 34, + "MIN_COLLECTIVE_BONDING_TIME": 35, + "MAX_COLLECTIVE_OUTPUTS": 36, + "MIN_COLLECTIVE_CLAIM_PERIOD": 37, + "VALIDATOR_RECOVERY_BOND": 38, + "MAX_ANNUAL_INFLATION": 39, + "MAX_PROPOSAL_TITLE_SIZE": 40, + "MAX_PROPOSAL_DESCRIPTION_SIZE": 41, + "MAX_PROPOSAL_POLL_OPTION_SIZE": 42, + "MAX_PROPOSAL_POLL_OPTION_COUNT": 43, + "MAX_PROPOSAL_REFERENCE_SIZE": 44, + "MAX_PROPOSAL_CHECKSUM_SIZE": 45, + "MIN_DAPP_BOND": 46, + "MAX_DAPP_BOND": 47, + "DAPP_LIQUIDATION_THRESHOLD": 48, + "DAPP_LIQUIDATION_PERIOD": 49, + "DAPP_BOND_DURATION": 50, + "DAPP_VERIFIER_BOND": 51, + "DAPP_AUTO_DENOUNCE_TIME": 52, + "DAPP_MISCHANCE_RANK_DECREASE_AMOUNT": 53, + "DAPP_MAX_MISCHANCE": 54, + "DAPP_INACTIVE_RANK_DECREASE_PERCENT": 55, + "DAPP_POOL_SLIPPAGE_DEFAULT": 56, + "MINTING_FT_FEE": 57, + "MINTING_NFT_FEE": 58, } func (x NetworkProperty) String() string { @@ -262,44 +325,65 @@ func (m *NetworkPropertyValue) GetStrValue() string { } type NetworkProperties struct { - MinTxFee uint64 `protobuf:"varint,1,opt,name=min_tx_fee,json=minTxFee,proto3" json:"min_tx_fee,omitempty"` - MaxTxFee uint64 `protobuf:"varint,2,opt,name=max_tx_fee,json=maxTxFee,proto3" json:"max_tx_fee,omitempty"` - VoteQuorum uint64 `protobuf:"varint,3,opt,name=vote_quorum,json=voteQuorum,proto3" json:"vote_quorum,omitempty"` - MinimumProposalEndTime uint64 `protobuf:"varint,4,opt,name=minimum_proposal_end_time,json=minimumProposalEndTime,proto3" json:"minimum_proposal_end_time,omitempty"` - ProposalEnactmentTime uint64 `protobuf:"varint,5,opt,name=proposal_enactment_time,json=proposalEnactmentTime,proto3" json:"proposal_enactment_time,omitempty"` - MinProposalEndBlocks uint64 `protobuf:"varint,6,opt,name=min_proposal_end_blocks,json=minProposalEndBlocks,proto3" json:"min_proposal_end_blocks,omitempty"` - MinProposalEnactmentBlocks uint64 `protobuf:"varint,7,opt,name=min_proposal_enactment_blocks,json=minProposalEnactmentBlocks,proto3" json:"min_proposal_enactment_blocks,omitempty"` - EnableForeignFeePayments bool `protobuf:"varint,8,opt,name=enable_foreign_fee_payments,json=enableForeignFeePayments,proto3" json:"enable_foreign_fee_payments,omitempty"` - MischanceRankDecreaseAmount uint64 `protobuf:"varint,9,opt,name=mischance_rank_decrease_amount,json=mischanceRankDecreaseAmount,proto3" json:"mischance_rank_decrease_amount,omitempty"` - MaxMischance uint64 `protobuf:"varint,10,opt,name=max_mischance,json=maxMischance,proto3" json:"max_mischance,omitempty"` - MischanceConfidence uint64 `protobuf:"varint,11,opt,name=mischance_confidence,json=mischanceConfidence,proto3" json:"mischance_confidence,omitempty"` - InactiveRankDecreasePercent github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,12,opt,name=inactive_rank_decrease_percent,json=inactiveRankDecreasePercent,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"inactive_rank_decrease_percent"` - MinValidators uint64 `protobuf:"varint,13,opt,name=min_validators,json=minValidators,proto3" json:"min_validators,omitempty"` - PoorNetworkMaxBankSend uint64 `protobuf:"varint,14,opt,name=poor_network_max_bank_send,json=poorNetworkMaxBankSend,proto3" json:"poor_network_max_bank_send,omitempty"` - UnjailMaxTime uint64 `protobuf:"varint,15,opt,name=unjail_max_time,json=unjailMaxTime,proto3" json:"unjail_max_time,omitempty"` - EnableTokenWhitelist bool `protobuf:"varint,16,opt,name=enable_token_whitelist,json=enableTokenWhitelist,proto3" json:"enable_token_whitelist,omitempty"` - EnableTokenBlacklist bool `protobuf:"varint,17,opt,name=enable_token_blacklist,json=enableTokenBlacklist,proto3" json:"enable_token_blacklist,omitempty"` - MinIdentityApprovalTip uint64 `protobuf:"varint,18,opt,name=min_identity_approval_tip,json=minIdentityApprovalTip,proto3" json:"min_identity_approval_tip,omitempty"` - UniqueIdentityKeys string `protobuf:"bytes,19,opt,name=unique_identity_keys,json=uniqueIdentityKeys,proto3" json:"unique_identity_keys,omitempty"` - UbiHardcap uint64 `protobuf:"varint,20,opt,name=ubi_hardcap,json=ubiHardcap,proto3" json:"ubi_hardcap,omitempty"` - ValidatorsFeeShare github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,21,opt,name=validators_fee_share,json=validatorsFeeShare,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"validators_fee_share"` - InflationRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,22,opt,name=inflation_rate,json=inflationRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"inflation_rate"` - InflationPeriod uint64 `protobuf:"varint,23,opt,name=inflation_period,json=inflationPeriod,proto3" json:"inflation_period,omitempty"` - UnstakingPeriod uint64 `protobuf:"varint,24,opt,name=unstaking_period,json=unstakingPeriod,proto3" json:"unstaking_period,omitempty"` - MaxDelegators uint64 `protobuf:"varint,25,opt,name=max_delegators,json=maxDelegators,proto3" json:"max_delegators,omitempty"` - MinDelegationPushout uint64 `protobuf:"varint,26,opt,name=min_delegation_pushout,json=minDelegationPushout,proto3" json:"min_delegation_pushout,omitempty"` - SlashingPeriod uint64 `protobuf:"varint,27,opt,name=slashing_period,json=slashingPeriod,proto3" json:"slashing_period,omitempty"` - MaxJailedPercentage github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,28,opt,name=max_jailed_percentage,json=maxJailedPercentage,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"max_jailed_percentage"` - MaxSlashingPercentage github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,29,opt,name=max_slashing_percentage,json=maxSlashingPercentage,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"max_slashing_percentage"` - MinCustodyReward uint64 `protobuf:"varint,30,opt,name=min_custody_reward,json=minCustodyReward,proto3" json:"min_custody_reward,omitempty"` - MaxCustodyBufferSize uint64 `protobuf:"varint,31,opt,name=max_custody_buffer_size,json=maxCustodyBufferSize,proto3" json:"max_custody_buffer_size,omitempty"` - MaxCustodyTxSize uint64 `protobuf:"varint,32,opt,name=max_custody_tx_size,json=maxCustodyTxSize,proto3" json:"max_custody_tx_size,omitempty"` - AbstentionRankDecreaseAmount uint64 `protobuf:"varint,33,opt,name=abstention_rank_decrease_amount,json=abstentionRankDecreaseAmount,proto3" json:"abstention_rank_decrease_amount,omitempty"` - MaxAbstention uint64 `protobuf:"varint,34,opt,name=max_abstention,json=maxAbstention,proto3" json:"max_abstention,omitempty"` - MinCollectiveBond uint64 `protobuf:"varint,35,opt,name=min_collective_bond,json=minCollectiveBond,proto3" json:"min_collective_bond,omitempty"` - MinCollectiveBondingTime uint64 `protobuf:"varint,36,opt,name=min_collective_bonding_time,json=minCollectiveBondingTime,proto3" json:"min_collective_bonding_time,omitempty"` - MaxCollectiveOutputs uint64 `protobuf:"varint,37,opt,name=max_collective_outputs,json=maxCollectiveOutputs,proto3" json:"max_collective_outputs,omitempty"` - MinCollectiveClaimPeriod uint64 `protobuf:"varint,38,opt,name=min_collective_claim_period,json=minCollectiveClaimPeriod,proto3" json:"min_collective_claim_period,omitempty"` + MinTxFee uint64 `protobuf:"varint,1,opt,name=min_tx_fee,json=minTxFee,proto3" json:"min_tx_fee,omitempty"` + MaxTxFee uint64 `protobuf:"varint,2,opt,name=max_tx_fee,json=maxTxFee,proto3" json:"max_tx_fee,omitempty"` + VoteQuorum uint64 `protobuf:"varint,3,opt,name=vote_quorum,json=voteQuorum,proto3" json:"vote_quorum,omitempty"` + MinimumProposalEndTime uint64 `protobuf:"varint,4,opt,name=minimum_proposal_end_time,json=minimumProposalEndTime,proto3" json:"minimum_proposal_end_time,omitempty"` + ProposalEnactmentTime uint64 `protobuf:"varint,5,opt,name=proposal_enactment_time,json=proposalEnactmentTime,proto3" json:"proposal_enactment_time,omitempty"` + MinProposalEndBlocks uint64 `protobuf:"varint,6,opt,name=min_proposal_end_blocks,json=minProposalEndBlocks,proto3" json:"min_proposal_end_blocks,omitempty"` + MinProposalEnactmentBlocks uint64 `protobuf:"varint,7,opt,name=min_proposal_enactment_blocks,json=minProposalEnactmentBlocks,proto3" json:"min_proposal_enactment_blocks,omitempty"` + EnableForeignFeePayments bool `protobuf:"varint,8,opt,name=enable_foreign_fee_payments,json=enableForeignFeePayments,proto3" json:"enable_foreign_fee_payments,omitempty"` + MischanceRankDecreaseAmount uint64 `protobuf:"varint,9,opt,name=mischance_rank_decrease_amount,json=mischanceRankDecreaseAmount,proto3" json:"mischance_rank_decrease_amount,omitempty"` + MaxMischance uint64 `protobuf:"varint,10,opt,name=max_mischance,json=maxMischance,proto3" json:"max_mischance,omitempty"` + MischanceConfidence uint64 `protobuf:"varint,11,opt,name=mischance_confidence,json=mischanceConfidence,proto3" json:"mischance_confidence,omitempty"` + InactiveRankDecreasePercent github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,12,opt,name=inactive_rank_decrease_percent,json=inactiveRankDecreasePercent,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"inactive_rank_decrease_percent"` + MinValidators uint64 `protobuf:"varint,13,opt,name=min_validators,json=minValidators,proto3" json:"min_validators,omitempty"` + PoorNetworkMaxBankSend uint64 `protobuf:"varint,14,opt,name=poor_network_max_bank_send,json=poorNetworkMaxBankSend,proto3" json:"poor_network_max_bank_send,omitempty"` + UnjailMaxTime uint64 `protobuf:"varint,15,opt,name=unjail_max_time,json=unjailMaxTime,proto3" json:"unjail_max_time,omitempty"` + EnableTokenWhitelist bool `protobuf:"varint,16,opt,name=enable_token_whitelist,json=enableTokenWhitelist,proto3" json:"enable_token_whitelist,omitempty"` + EnableTokenBlacklist bool `protobuf:"varint,17,opt,name=enable_token_blacklist,json=enableTokenBlacklist,proto3" json:"enable_token_blacklist,omitempty"` + MinIdentityApprovalTip uint64 `protobuf:"varint,18,opt,name=min_identity_approval_tip,json=minIdentityApprovalTip,proto3" json:"min_identity_approval_tip,omitempty"` + UniqueIdentityKeys string `protobuf:"bytes,19,opt,name=unique_identity_keys,json=uniqueIdentityKeys,proto3" json:"unique_identity_keys,omitempty"` + UbiHardcap uint64 `protobuf:"varint,20,opt,name=ubi_hardcap,json=ubiHardcap,proto3" json:"ubi_hardcap,omitempty"` + ValidatorsFeeShare github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,21,opt,name=validators_fee_share,json=validatorsFeeShare,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"validators_fee_share"` + InflationRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,22,opt,name=inflation_rate,json=inflationRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"inflation_rate"` + InflationPeriod uint64 `protobuf:"varint,23,opt,name=inflation_period,json=inflationPeriod,proto3" json:"inflation_period,omitempty"` + UnstakingPeriod uint64 `protobuf:"varint,24,opt,name=unstaking_period,json=unstakingPeriod,proto3" json:"unstaking_period,omitempty"` + MaxDelegators uint64 `protobuf:"varint,25,opt,name=max_delegators,json=maxDelegators,proto3" json:"max_delegators,omitempty"` + MinDelegationPushout uint64 `protobuf:"varint,26,opt,name=min_delegation_pushout,json=minDelegationPushout,proto3" json:"min_delegation_pushout,omitempty"` + SlashingPeriod uint64 `protobuf:"varint,27,opt,name=slashing_period,json=slashingPeriod,proto3" json:"slashing_period,omitempty"` + MaxJailedPercentage github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,28,opt,name=max_jailed_percentage,json=maxJailedPercentage,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"max_jailed_percentage"` + MaxSlashingPercentage github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,29,opt,name=max_slashing_percentage,json=maxSlashingPercentage,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"max_slashing_percentage"` + MinCustodyReward uint64 `protobuf:"varint,30,opt,name=min_custody_reward,json=minCustodyReward,proto3" json:"min_custody_reward,omitempty"` + MaxCustodyBufferSize uint64 `protobuf:"varint,31,opt,name=max_custody_buffer_size,json=maxCustodyBufferSize,proto3" json:"max_custody_buffer_size,omitempty"` + MaxCustodyTxSize uint64 `protobuf:"varint,32,opt,name=max_custody_tx_size,json=maxCustodyTxSize,proto3" json:"max_custody_tx_size,omitempty"` + AbstentionRankDecreaseAmount uint64 `protobuf:"varint,33,opt,name=abstention_rank_decrease_amount,json=abstentionRankDecreaseAmount,proto3" json:"abstention_rank_decrease_amount,omitempty"` + MaxAbstention uint64 `protobuf:"varint,34,opt,name=max_abstention,json=maxAbstention,proto3" json:"max_abstention,omitempty"` + MinCollectiveBond uint64 `protobuf:"varint,35,opt,name=min_collective_bond,json=minCollectiveBond,proto3" json:"min_collective_bond,omitempty"` + MinCollectiveBondingTime uint64 `protobuf:"varint,36,opt,name=min_collective_bonding_time,json=minCollectiveBondingTime,proto3" json:"min_collective_bonding_time,omitempty"` + MaxCollectiveOutputs uint64 `protobuf:"varint,37,opt,name=max_collective_outputs,json=maxCollectiveOutputs,proto3" json:"max_collective_outputs,omitempty"` + MinCollectiveClaimPeriod uint64 `protobuf:"varint,38,opt,name=min_collective_claim_period,json=minCollectiveClaimPeriod,proto3" json:"min_collective_claim_period,omitempty"` + ValidatorRecoveryBond uint64 `protobuf:"varint,39,opt,name=validator_recovery_bond,json=validatorRecoveryBond,proto3" json:"validator_recovery_bond,omitempty"` + MaxAnnualInflation github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,40,opt,name=max_annual_inflation,json=maxAnnualInflation,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"max_annual_inflation"` + MaxProposalTitleSize uint64 `protobuf:"varint,41,opt,name=max_proposal_title_size,json=maxProposalTitleSize,proto3" json:"max_proposal_title_size,omitempty"` + MaxProposalDescriptionSize uint64 `protobuf:"varint,42,opt,name=max_proposal_description_size,json=maxProposalDescriptionSize,proto3" json:"max_proposal_description_size,omitempty"` + MaxProposalPollOptionSize uint64 `protobuf:"varint,43,opt,name=max_proposal_poll_option_size,json=maxProposalPollOptionSize,proto3" json:"max_proposal_poll_option_size,omitempty"` + MaxProposalPollOptionCount uint64 `protobuf:"varint,44,opt,name=max_proposal_poll_option_count,json=maxProposalPollOptionCount,proto3" json:"max_proposal_poll_option_count,omitempty"` + MaxProposalReferenceSize uint64 `protobuf:"varint,45,opt,name=max_proposal_reference_size,json=maxProposalReferenceSize,proto3" json:"max_proposal_reference_size,omitempty"` + MaxProposalChecksumSize uint64 `protobuf:"varint,46,opt,name=max_proposal_checksum_size,json=maxProposalChecksumSize,proto3" json:"max_proposal_checksum_size,omitempty"` + MinDappBond uint64 `protobuf:"varint,47,opt,name=min_dapp_bond,json=minDappBond,proto3" json:"min_dapp_bond,omitempty"` + MaxDappBond uint64 `protobuf:"varint,48,opt,name=max_dapp_bond,json=maxDappBond,proto3" json:"max_dapp_bond,omitempty"` + DappLiquidationThreshold uint64 `protobuf:"varint,49,opt,name=dapp_liquidation_threshold,json=dappLiquidationThreshold,proto3" json:"dapp_liquidation_threshold,omitempty"` + DappLiquidationPeriod uint64 `protobuf:"varint,50,opt,name=dapp_liquidation_period,json=dappLiquidationPeriod,proto3" json:"dapp_liquidation_period,omitempty"` + DappBondDuration uint64 `protobuf:"varint,51,opt,name=dapp_bond_duration,json=dappBondDuration,proto3" json:"dapp_bond_duration,omitempty"` + DappVerifierBond github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,52,opt,name=dapp_verifier_bond,json=dappVerifierBond,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"dapp_verifier_bond"` + DappAutoDenounceTime uint64 `protobuf:"varint,53,opt,name=dapp_auto_denounce_time,json=dappAutoDenounceTime,proto3" json:"dapp_auto_denounce_time,omitempty"` + DappMischanceRankDecreaseAmount uint64 `protobuf:"varint,54,opt,name=dapp_mischance_rank_decrease_amount,json=dappMischanceRankDecreaseAmount,proto3" json:"dapp_mischance_rank_decrease_amount,omitempty"` + DappMaxMischance uint64 `protobuf:"varint,55,opt,name=dapp_max_mischance,json=dappMaxMischance,proto3" json:"dapp_max_mischance,omitempty"` + DappInactiveRankDecreasePercent uint64 `protobuf:"varint,56,opt,name=dapp_inactive_rank_decrease_percent,json=dappInactiveRankDecreasePercent,proto3" json:"dapp_inactive_rank_decrease_percent,omitempty"` + DappPoolSlippageDefault github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,57,opt,name=dapp_pool_slippage_default,json=dappPoolSlippageDefault,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"dapp_pool_slippage_default"` + MintingFtFee uint64 `protobuf:"varint,58,opt,name=minting_ft_fee,json=mintingFtFee,proto3" json:"minting_ft_fee,omitempty"` + MintingNftFee uint64 `protobuf:"varint,59,opt,name=minting_nft_fee,json=mintingNftFee,proto3" json:"minting_nft_fee,omitempty"` } func (m *NetworkProperties) Reset() { *m = NetworkProperties{} } @@ -566,6 +650,132 @@ func (m *NetworkProperties) GetMinCollectiveClaimPeriod() uint64 { return 0 } +func (m *NetworkProperties) GetValidatorRecoveryBond() uint64 { + if m != nil { + return m.ValidatorRecoveryBond + } + return 0 +} + +func (m *NetworkProperties) GetMaxProposalTitleSize() uint64 { + if m != nil { + return m.MaxProposalTitleSize + } + return 0 +} + +func (m *NetworkProperties) GetMaxProposalDescriptionSize() uint64 { + if m != nil { + return m.MaxProposalDescriptionSize + } + return 0 +} + +func (m *NetworkProperties) GetMaxProposalPollOptionSize() uint64 { + if m != nil { + return m.MaxProposalPollOptionSize + } + return 0 +} + +func (m *NetworkProperties) GetMaxProposalPollOptionCount() uint64 { + if m != nil { + return m.MaxProposalPollOptionCount + } + return 0 +} + +func (m *NetworkProperties) GetMaxProposalReferenceSize() uint64 { + if m != nil { + return m.MaxProposalReferenceSize + } + return 0 +} + +func (m *NetworkProperties) GetMaxProposalChecksumSize() uint64 { + if m != nil { + return m.MaxProposalChecksumSize + } + return 0 +} + +func (m *NetworkProperties) GetMinDappBond() uint64 { + if m != nil { + return m.MinDappBond + } + return 0 +} + +func (m *NetworkProperties) GetMaxDappBond() uint64 { + if m != nil { + return m.MaxDappBond + } + return 0 +} + +func (m *NetworkProperties) GetDappLiquidationThreshold() uint64 { + if m != nil { + return m.DappLiquidationThreshold + } + return 0 +} + +func (m *NetworkProperties) GetDappLiquidationPeriod() uint64 { + if m != nil { + return m.DappLiquidationPeriod + } + return 0 +} + +func (m *NetworkProperties) GetDappBondDuration() uint64 { + if m != nil { + return m.DappBondDuration + } + return 0 +} + +func (m *NetworkProperties) GetDappAutoDenounceTime() uint64 { + if m != nil { + return m.DappAutoDenounceTime + } + return 0 +} + +func (m *NetworkProperties) GetDappMischanceRankDecreaseAmount() uint64 { + if m != nil { + return m.DappMischanceRankDecreaseAmount + } + return 0 +} + +func (m *NetworkProperties) GetDappMaxMischance() uint64 { + if m != nil { + return m.DappMaxMischance + } + return 0 +} + +func (m *NetworkProperties) GetDappInactiveRankDecreasePercent() uint64 { + if m != nil { + return m.DappInactiveRankDecreasePercent + } + return 0 +} + +func (m *NetworkProperties) GetMintingFtFee() uint64 { + if m != nil { + return m.MintingFtFee + } + return 0 +} + +func (m *NetworkProperties) GetMintingNftFee() uint64 { + if m != nil { + return m.MintingNftFee + } + return 0 +} + func init() { proto.RegisterEnum("kira.gov.NetworkProperty", NetworkProperty_name, NetworkProperty_value) proto.RegisterType((*MsgSetNetworkProperties)(nil), "kira.gov.MsgSetNetworkProperties") @@ -576,130 +786,178 @@ func init() { func init() { proto.RegisterFile("kira/gov/network_properties.proto", fileDescriptor_98011a6048e5dde3) } var fileDescriptor_98011a6048e5dde3 = []byte{ - // 1954 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x58, 0xdd, 0x6e, 0xdb, 0xc8, - 0x15, 0xb6, 0xb2, 0x49, 0xd6, 0x99, 0xf8, 0x87, 0xa6, 0x65, 0x9b, 0xa1, 0x1d, 0x99, 0x71, 0xd6, - 0x69, 0x5a, 0x34, 0xf6, 0xee, 0xb6, 0x5d, 0xa0, 0x01, 0x8a, 0x82, 0x92, 0xa8, 0x98, 0xb1, 0xf8, - 0x13, 0xfe, 0x38, 0xc9, 0xde, 0x4c, 0x47, 0xd2, 0x58, 0x66, 0x25, 0x92, 0x5a, 0x92, 0x72, 0xe4, - 0x7d, 0x82, 0x42, 0x17, 0x45, 0x5f, 0x40, 0x40, 0x81, 0xbe, 0x42, 0x1f, 0x62, 0x2f, 0xf7, 0xb2, - 0xe8, 0x45, 0x50, 0x24, 0x37, 0x7d, 0x86, 0xbd, 0x2a, 0x66, 0x86, 0xa4, 0x7e, 0xed, 0x2e, 0x72, - 0x65, 0xf9, 0x9c, 0xef, 0x3b, 0xe7, 0xcc, 0x39, 0x67, 0xe6, 0x1c, 0x10, 0x3c, 0xea, 0x78, 0x11, - 0x3a, 0x6e, 0x87, 0x97, 0xc7, 0x01, 0x4e, 0xde, 0x85, 0x51, 0x07, 0xf6, 0xa2, 0xb0, 0x87, 0xa3, - 0xc4, 0xc3, 0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0x00, + // 2729 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x59, 0xdd, 0x6e, 0xdb, 0x46, + 0xda, 0x8e, 0xdb, 0xb4, 0x75, 0x26, 0x89, 0x4d, 0xd3, 0x72, 0xcc, 0xd0, 0x89, 0xcc, 0x3a, 0x4d, + 0x9a, 0xb6, 0x89, 0x9d, 0xa4, 0x4d, 0xda, 0xa6, 0xdf, 0x87, 0xef, 0xa3, 0x44, 0x2a, 0x66, 0x2d, + 0xfe, 0x84, 0x3f, 0x4e, 0x53, 0x2c, 0x30, 0xa5, 0xa5, 0xb1, 0xcd, 0x15, 0x45, 0xaa, 0x24, 0xe5, + 0xca, 0xbd, 0x82, 0x85, 0x8e, 0xf6, 0x68, 0x0f, 0x16, 0x10, 0xb0, 0xc0, 0xde, 0xc2, 0x5e, 0x44, + 0x0f, 0x7b, 0xb8, 0xd8, 0x83, 0x62, 0xd1, 0x9e, 0xec, 0x35, 0xec, 0xd1, 0x62, 0x7e, 0x48, 0xea, + 0xcf, 0xce, 0xc2, 0x47, 0x71, 0xe6, 0x7d, 0x9e, 0x77, 0xde, 0x79, 0xe7, 0x99, 0xe1, 0x3c, 0x10, + 0x78, 0xbf, 0x13, 0x24, 0xfe, 0xce, 0x51, 0x7c, 0xb2, 0x13, 0xa1, 0xec, 0x87, 0x38, 0xe9, 0xc0, + 0x5e, 0x12, 0xf7, 0x50, 0x92, 0x05, 0x28, 0xdd, 0xee, 0x25, 0x71, 0x16, 0xf3, 0x8b, 0x18, 0xb2, + 0x7d, 0x14, 0x9f, 0x88, 0x95, 0xa3, 0xf8, 0x28, 0x26, 0x83, 0x3b, 0xf8, 0x2f, 0x1a, 0xdf, 0xfa, + 0xdb, 0x02, 0x58, 0xd7, 0xd3, 0x23, 0x07, 0x65, 0x06, 0x4d, 0x61, 0x15, 0x19, 0xf8, 0xaf, 0x01, + 0x3f, 0x9b, 0x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 0x1a, 0x45, 0x4a, 0x1b, 0x00, 0x00, } func (this *NetworkPropertyValue) Equal(that interface{}) bool { @@ -826,6 +1084,168 @@ func (m *NetworkProperties) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.MintingNftFee != 0 { + i = encodeVarintNetworkProperties(dAtA, i, uint64(m.MintingNftFee)) + i-- + dAtA[i] = 0x3 + i-- + dAtA[i] = 0xd8 + } + if m.MintingFtFee != 0 { + i = encodeVarintNetworkProperties(dAtA, i, uint64(m.MintingFtFee)) + i-- + dAtA[i] = 0x3 + i-- + dAtA[i] = 0xd0 + } + { + size := m.DappPoolSlippageDefault.Size() + i -= size + if _, err := m.DappPoolSlippageDefault.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintNetworkProperties(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x3 + i-- + dAtA[i] = 0xca + if m.DappInactiveRankDecreasePercent != 0 { + i = encodeVarintNetworkProperties(dAtA, i, uint64(m.DappInactiveRankDecreasePercent)) + i-- + dAtA[i] = 0x3 + i-- + dAtA[i] = 0xc0 + } + if m.DappMaxMischance != 0 { + i = encodeVarintNetworkProperties(dAtA, i, uint64(m.DappMaxMischance)) + i-- + dAtA[i] = 0x3 + i-- + dAtA[i] = 0xb8 + } + if m.DappMischanceRankDecreaseAmount != 0 { + i = encodeVarintNetworkProperties(dAtA, i, uint64(m.DappMischanceRankDecreaseAmount)) + i-- + dAtA[i] = 0x3 + i-- + dAtA[i] = 0xb0 + } + if m.DappAutoDenounceTime != 0 { + i = encodeVarintNetworkProperties(dAtA, i, uint64(m.DappAutoDenounceTime)) + i-- + dAtA[i] = 0x3 + i-- + dAtA[i] = 0xa8 + } + { + size := m.DappVerifierBond.Size() + i -= size + if _, err := m.DappVerifierBond.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintNetworkProperties(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x3 + i-- + dAtA[i] = 0xa2 + if m.DappBondDuration != 0 { + i = encodeVarintNetworkProperties(dAtA, i, uint64(m.DappBondDuration)) + i-- + dAtA[i] = 0x3 + i-- + dAtA[i] = 0x98 + } + if m.DappLiquidationPeriod != 0 { + i = encodeVarintNetworkProperties(dAtA, i, uint64(m.DappLiquidationPeriod)) + i-- + dAtA[i] = 0x3 + i-- + dAtA[i] = 0x90 + } + if m.DappLiquidationThreshold != 0 { + i = encodeVarintNetworkProperties(dAtA, i, uint64(m.DappLiquidationThreshold)) + i-- + dAtA[i] = 0x3 + i-- + dAtA[i] = 0x88 + } + if m.MaxDappBond != 0 { + i = encodeVarintNetworkProperties(dAtA, i, uint64(m.MaxDappBond)) + i-- + dAtA[i] = 0x3 + i-- + dAtA[i] = 0x80 + } + if m.MinDappBond != 0 { + i = encodeVarintNetworkProperties(dAtA, i, uint64(m.MinDappBond)) + i-- + dAtA[i] = 0x2 + i-- + dAtA[i] = 0xf8 + } + if m.MaxProposalChecksumSize != 0 { + i = encodeVarintNetworkProperties(dAtA, i, uint64(m.MaxProposalChecksumSize)) + i-- + dAtA[i] = 0x2 + i-- + dAtA[i] = 0xf0 + } + if m.MaxProposalReferenceSize != 0 { + i = encodeVarintNetworkProperties(dAtA, i, uint64(m.MaxProposalReferenceSize)) + i-- + dAtA[i] = 0x2 + i-- + dAtA[i] = 0xe8 + } + if m.MaxProposalPollOptionCount != 0 { + i = encodeVarintNetworkProperties(dAtA, i, uint64(m.MaxProposalPollOptionCount)) + i-- + dAtA[i] = 0x2 + i-- + dAtA[i] = 0xe0 + } + if m.MaxProposalPollOptionSize != 0 { + i = encodeVarintNetworkProperties(dAtA, i, uint64(m.MaxProposalPollOptionSize)) + i-- + dAtA[i] = 0x2 + i-- + dAtA[i] = 0xd8 + } + if m.MaxProposalDescriptionSize != 0 { + i = encodeVarintNetworkProperties(dAtA, i, uint64(m.MaxProposalDescriptionSize)) + i-- + dAtA[i] = 0x2 + i-- + dAtA[i] = 0xd0 + } + if m.MaxProposalTitleSize != 0 { + i = encodeVarintNetworkProperties(dAtA, i, uint64(m.MaxProposalTitleSize)) + i-- + dAtA[i] = 0x2 + i-- + dAtA[i] = 0xc8 + } + { + size := m.MaxAnnualInflation.Size() + i -= size + if _, err := m.MaxAnnualInflation.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintNetworkProperties(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2 + i-- + dAtA[i] = 0xc2 + if m.ValidatorRecoveryBond != 0 { + i = encodeVarintNetworkProperties(dAtA, i, uint64(m.ValidatorRecoveryBond)) + i-- + dAtA[i] = 0x2 + i-- + dAtA[i] = 0xb8 + } if m.MinCollectiveClaimPeriod != 0 { i = encodeVarintNetworkProperties(dAtA, i, uint64(m.MinCollectiveClaimPeriod)) i-- @@ -1267,6 +1687,66 @@ func (m *NetworkProperties) Size() (n int) { if m.MinCollectiveClaimPeriod != 0 { n += 2 + sovNetworkProperties(uint64(m.MinCollectiveClaimPeriod)) } + if m.ValidatorRecoveryBond != 0 { + n += 2 + sovNetworkProperties(uint64(m.ValidatorRecoveryBond)) + } + l = m.MaxAnnualInflation.Size() + n += 2 + l + sovNetworkProperties(uint64(l)) + if m.MaxProposalTitleSize != 0 { + n += 2 + sovNetworkProperties(uint64(m.MaxProposalTitleSize)) + } + if m.MaxProposalDescriptionSize != 0 { + n += 2 + sovNetworkProperties(uint64(m.MaxProposalDescriptionSize)) + } + if m.MaxProposalPollOptionSize != 0 { + n += 2 + sovNetworkProperties(uint64(m.MaxProposalPollOptionSize)) + } + if m.MaxProposalPollOptionCount != 0 { + n += 2 + sovNetworkProperties(uint64(m.MaxProposalPollOptionCount)) + } + if m.MaxProposalReferenceSize != 0 { + n += 2 + sovNetworkProperties(uint64(m.MaxProposalReferenceSize)) + } + if m.MaxProposalChecksumSize != 0 { + n += 2 + sovNetworkProperties(uint64(m.MaxProposalChecksumSize)) + } + if m.MinDappBond != 0 { + n += 2 + sovNetworkProperties(uint64(m.MinDappBond)) + } + if m.MaxDappBond != 0 { + n += 2 + sovNetworkProperties(uint64(m.MaxDappBond)) + } + if m.DappLiquidationThreshold != 0 { + n += 2 + sovNetworkProperties(uint64(m.DappLiquidationThreshold)) + } + if m.DappLiquidationPeriod != 0 { + n += 2 + sovNetworkProperties(uint64(m.DappLiquidationPeriod)) + } + if m.DappBondDuration != 0 { + n += 2 + sovNetworkProperties(uint64(m.DappBondDuration)) + } + l = m.DappVerifierBond.Size() + n += 2 + l + sovNetworkProperties(uint64(l)) + if m.DappAutoDenounceTime != 0 { + n += 2 + sovNetworkProperties(uint64(m.DappAutoDenounceTime)) + } + if m.DappMischanceRankDecreaseAmount != 0 { + n += 2 + sovNetworkProperties(uint64(m.DappMischanceRankDecreaseAmount)) + } + if m.DappMaxMischance != 0 { + n += 2 + sovNetworkProperties(uint64(m.DappMaxMischance)) + } + if m.DappInactiveRankDecreasePercent != 0 { + n += 2 + sovNetworkProperties(uint64(m.DappInactiveRankDecreasePercent)) + } + l = m.DappPoolSlippageDefault.Size() + n += 2 + l + sovNetworkProperties(uint64(l)) + if m.MintingFtFee != 0 { + n += 2 + sovNetworkProperties(uint64(m.MintingFtFee)) + } + if m.MintingNftFee != 0 { + n += 2 + sovNetworkProperties(uint64(m.MintingNftFee)) + } return n } @@ -2339,6 +2819,450 @@ func (m *NetworkProperties) Unmarshal(dAtA []byte) error { break } } + case 39: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ValidatorRecoveryBond", wireType) + } + m.ValidatorRecoveryBond = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNetworkProperties + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ValidatorRecoveryBond |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 40: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MaxAnnualInflation", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNetworkProperties + } + 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 ErrInvalidLengthNetworkProperties + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthNetworkProperties + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.MaxAnnualInflation.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 41: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MaxProposalTitleSize", wireType) + } + m.MaxProposalTitleSize = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNetworkProperties + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MaxProposalTitleSize |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 42: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MaxProposalDescriptionSize", wireType) + } + m.MaxProposalDescriptionSize = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNetworkProperties + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MaxProposalDescriptionSize |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 43: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MaxProposalPollOptionSize", wireType) + } + m.MaxProposalPollOptionSize = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNetworkProperties + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MaxProposalPollOptionSize |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 44: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MaxProposalPollOptionCount", wireType) + } + m.MaxProposalPollOptionCount = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNetworkProperties + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MaxProposalPollOptionCount |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 45: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MaxProposalReferenceSize", wireType) + } + m.MaxProposalReferenceSize = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNetworkProperties + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MaxProposalReferenceSize |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 46: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MaxProposalChecksumSize", wireType) + } + m.MaxProposalChecksumSize = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNetworkProperties + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MaxProposalChecksumSize |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 47: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MinDappBond", wireType) + } + m.MinDappBond = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNetworkProperties + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MinDappBond |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 48: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MaxDappBond", wireType) + } + m.MaxDappBond = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNetworkProperties + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MaxDappBond |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 49: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field DappLiquidationThreshold", wireType) + } + m.DappLiquidationThreshold = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNetworkProperties + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.DappLiquidationThreshold |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 50: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field DappLiquidationPeriod", wireType) + } + m.DappLiquidationPeriod = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNetworkProperties + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.DappLiquidationPeriod |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 51: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field DappBondDuration", wireType) + } + m.DappBondDuration = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNetworkProperties + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.DappBondDuration |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 52: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DappVerifierBond", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNetworkProperties + } + 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 ErrInvalidLengthNetworkProperties + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthNetworkProperties + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.DappVerifierBond.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 53: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field DappAutoDenounceTime", wireType) + } + m.DappAutoDenounceTime = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNetworkProperties + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.DappAutoDenounceTime |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 54: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field DappMischanceRankDecreaseAmount", wireType) + } + m.DappMischanceRankDecreaseAmount = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNetworkProperties + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.DappMischanceRankDecreaseAmount |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 55: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field DappMaxMischance", wireType) + } + m.DappMaxMischance = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNetworkProperties + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.DappMaxMischance |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 56: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field DappInactiveRankDecreasePercent", wireType) + } + m.DappInactiveRankDecreasePercent = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNetworkProperties + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.DappInactiveRankDecreasePercent |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 57: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DappPoolSlippageDefault", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNetworkProperties + } + 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 ErrInvalidLengthNetworkProperties + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthNetworkProperties + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.DappPoolSlippageDefault.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 58: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MintingFtFee", wireType) + } + m.MintingFtFee = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNetworkProperties + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MintingFtFee |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 59: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MintingNftFee", wireType) + } + m.MintingNftFee = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNetworkProperties + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MintingNftFee |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipNetworkProperties(dAtA[iNdEx:]) diff --git a/x/gov/types/pagination.pb.go b/x/gov/types/pagination.pb.go index 94a689ce5..c596f5664 100644 --- a/x/gov/types/pagination.pb.go +++ b/x/gov/types/pagination.pb.go @@ -1,646 +1,646 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: kira/gov/pagination.proto - -package types - -import ( - fmt "fmt" - proto "github.com/gogo/protobuf/proto" - io "io" - math "math" - math_bits "math/bits" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -type PageRequest struct { - Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` - Offset uint64 `protobuf:"varint,2,opt,name=offset,proto3" json:"offset,omitempty"` - Limit uint64 `protobuf:"varint,3,opt,name=limit,proto3" json:"limit,omitempty"` - CountTotal bool `protobuf:"varint,4,opt,name=count_total,json=countTotal,proto3" json:"count_total,omitempty"` -} - -func (m *PageRequest) Reset() { *m = PageRequest{} } -func (m *PageRequest) String() string { return proto.CompactTextString(m) } -func (*PageRequest) ProtoMessage() {} -func (*PageRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_454d1e027b6baed6, []int{0} -} -func (m *PageRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *PageRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_PageRequest.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 *PageRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_PageRequest.Merge(m, src) -} -func (m *PageRequest) XXX_Size() int { - return m.Size() -} -func (m *PageRequest) XXX_DiscardUnknown() { - xxx_messageInfo_PageRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_PageRequest proto.InternalMessageInfo - -func (m *PageRequest) GetKey() []byte { - if m != nil { - return m.Key - } - return nil -} - -func (m *PageRequest) GetOffset() uint64 { - if m != nil { - return m.Offset - } - return 0 -} - -func (m *PageRequest) GetLimit() uint64 { - if m != nil { - return m.Limit - } - return 0 -} - -func (m *PageRequest) GetCountTotal() bool { - if m != nil { - return m.CountTotal - } - return false -} - -type PageResponse struct { - NextKey []byte `protobuf:"bytes,1,opt,name=next_key,json=nextKey,proto3" json:"next_key,omitempty"` - Total uint64 `protobuf:"varint,2,opt,name=total,proto3" json:"total,omitempty"` -} - -func (m *PageResponse) Reset() { *m = PageResponse{} } -func (m *PageResponse) String() string { return proto.CompactTextString(m) } -func (*PageResponse) ProtoMessage() {} -func (*PageResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_454d1e027b6baed6, []int{1} -} -func (m *PageResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *PageResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_PageResponse.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 *PageResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_PageResponse.Merge(m, src) -} -func (m *PageResponse) XXX_Size() int { - return m.Size() -} -func (m *PageResponse) XXX_DiscardUnknown() { - xxx_messageInfo_PageResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_PageResponse proto.InternalMessageInfo - -func (m *PageResponse) GetNextKey() []byte { - if m != nil { - return m.NextKey - } - return nil -} - -func (m *PageResponse) GetTotal() uint64 { - if m != nil { - return m.Total - } - return 0 -} - -func init() { - proto.RegisterType((*PageRequest)(nil), "kira.gov.PageRequest") - proto.RegisterType((*PageResponse)(nil), "kira.gov.PageResponse") -} - -func init() { proto.RegisterFile("kira/gov/pagination.proto", fileDescriptor_454d1e027b6baed6) } - -var fileDescriptor_454d1e027b6baed6 = []byte{ - // 253 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x44, 0x90, 0x31, 0x6a, 0xc3, 0x30, - 0x14, 0x86, 0xad, 0x26, 0x4d, 0x8d, 0x92, 0xa1, 0x88, 0x52, 0x9c, 0x45, 0x35, 0x81, 0x82, 0x27, - 0x7b, 0xe8, 0x01, 0x02, 0xed, 0x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xad, 0x5e, 0xb0, 0x86, - 0xcc, 0x42, 0xa9, 0x74, 0x76, 0x1a, 0x66, 0xa0, 0xb6, 0x02, 0xbb, 0x99, 0x0c, 0x13, 0x3c, 0xfd, - 0x05, 0x00, 0x00, 0xff, 0xff, 0x01, 0xfb, 0x59, 0x1d, 0x1f, 0x01, 0x00, 0x00, -} - -func (m *PageRequest) 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 *PageRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *PageRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.CountTotal { - i-- - if m.CountTotal { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x20 - } - if m.Limit != 0 { - i = encodeVarintPagination(dAtA, i, uint64(m.Limit)) - i-- - dAtA[i] = 0x18 - } - if m.Offset != 0 { - i = encodeVarintPagination(dAtA, i, uint64(m.Offset)) - i-- - dAtA[i] = 0x10 - } - if len(m.Key) > 0 { - i -= len(m.Key) - copy(dAtA[i:], m.Key) - i = encodeVarintPagination(dAtA, i, uint64(len(m.Key))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *PageResponse) 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 *PageResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *PageResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Total != 0 { - i = encodeVarintPagination(dAtA, i, uint64(m.Total)) - i-- - dAtA[i] = 0x10 - } - if len(m.NextKey) > 0 { - i -= len(m.NextKey) - copy(dAtA[i:], m.NextKey) - i = encodeVarintPagination(dAtA, i, uint64(len(m.NextKey))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func encodeVarintPagination(dAtA []byte, offset int, v uint64) int { - offset -= sovPagination(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *PageRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Key) - if l > 0 { - n += 1 + l + sovPagination(uint64(l)) - } - if m.Offset != 0 { - n += 1 + sovPagination(uint64(m.Offset)) - } - if m.Limit != 0 { - n += 1 + sovPagination(uint64(m.Limit)) - } - if m.CountTotal { - n += 2 - } - return n -} - -func (m *PageResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.NextKey) - if l > 0 { - n += 1 + l + sovPagination(uint64(l)) - } - if m.Total != 0 { - n += 1 + sovPagination(uint64(m.Total)) - } - return n -} - -func sovPagination(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozPagination(x uint64) (n int) { - return sovPagination(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *PageRequest) 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 ErrIntOverflowPagination - } - 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: PageRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: PageRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - 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 ErrIntOverflowPagination - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthPagination - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthPagination - } - 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 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Offset", wireType) - } - m.Offset = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowPagination - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Offset |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Limit", wireType) - } - m.Limit = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowPagination - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Limit |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field CountTotal", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowPagination - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.CountTotal = bool(v != 0) - default: - iNdEx = preIndex - skippy, err := skipPagination(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthPagination - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthPagination - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *PageResponse) 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 ErrIntOverflowPagination - } - 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: PageResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: PageResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field NextKey", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowPagination - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthPagination - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthPagination - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.NextKey = append(m.NextKey[:0], dAtA[iNdEx:postIndex]...) - if m.NextKey == nil { - m.NextKey = []byte{} - } - iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Total", wireType) - } - m.Total = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowPagination - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Total |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipPagination(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthPagination - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthPagination - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipPagination(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, ErrIntOverflowPagination - } - 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, ErrIntOverflowPagination - } - 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, ErrIntOverflowPagination - } - 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, ErrInvalidLengthPagination - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupPagination - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthPagination - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthPagination = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowPagination = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupPagination = fmt.Errorf("proto: unexpected end of group") -) +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: kira/gov/pagination.proto + +package types + +import ( + fmt "fmt" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type PageRequest struct { + Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + Offset uint64 `protobuf:"varint,2,opt,name=offset,proto3" json:"offset,omitempty"` + Limit uint64 `protobuf:"varint,3,opt,name=limit,proto3" json:"limit,omitempty"` + CountTotal bool `protobuf:"varint,4,opt,name=count_total,json=countTotal,proto3" json:"count_total,omitempty"` +} + +func (m *PageRequest) Reset() { *m = PageRequest{} } +func (m *PageRequest) String() string { return proto.CompactTextString(m) } +func (*PageRequest) ProtoMessage() {} +func (*PageRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_454d1e027b6baed6, []int{0} +} +func (m *PageRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PageRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PageRequest.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 *PageRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_PageRequest.Merge(m, src) +} +func (m *PageRequest) XXX_Size() int { + return m.Size() +} +func (m *PageRequest) XXX_DiscardUnknown() { + xxx_messageInfo_PageRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_PageRequest proto.InternalMessageInfo + +func (m *PageRequest) GetKey() []byte { + if m != nil { + return m.Key + } + return nil +} + +func (m *PageRequest) GetOffset() uint64 { + if m != nil { + return m.Offset + } + return 0 +} + +func (m *PageRequest) GetLimit() uint64 { + if m != nil { + return m.Limit + } + return 0 +} + +func (m *PageRequest) GetCountTotal() bool { + if m != nil { + return m.CountTotal + } + return false +} + +type PageResponse struct { + NextKey []byte `protobuf:"bytes,1,opt,name=next_key,json=nextKey,proto3" json:"next_key,omitempty"` + Total uint64 `protobuf:"varint,2,opt,name=total,proto3" json:"total,omitempty"` +} + +func (m *PageResponse) Reset() { *m = PageResponse{} } +func (m *PageResponse) String() string { return proto.CompactTextString(m) } +func (*PageResponse) ProtoMessage() {} +func (*PageResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_454d1e027b6baed6, []int{1} +} +func (m *PageResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PageResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PageResponse.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 *PageResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_PageResponse.Merge(m, src) +} +func (m *PageResponse) XXX_Size() int { + return m.Size() +} +func (m *PageResponse) XXX_DiscardUnknown() { + xxx_messageInfo_PageResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_PageResponse proto.InternalMessageInfo + +func (m *PageResponse) GetNextKey() []byte { + if m != nil { + return m.NextKey + } + return nil +} + +func (m *PageResponse) GetTotal() uint64 { + if m != nil { + return m.Total + } + return 0 +} + +func init() { + proto.RegisterType((*PageRequest)(nil), "kira.gov.PageRequest") + proto.RegisterType((*PageResponse)(nil), "kira.gov.PageResponse") +} + +func init() { proto.RegisterFile("kira/gov/pagination.proto", fileDescriptor_454d1e027b6baed6) } + +var fileDescriptor_454d1e027b6baed6 = []byte{ + // 253 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 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0x4e, + 0xb2, 0x73, 0x27, 0xd9, 0x6f, 0x27, 0xd9, 0x57, 0x2f, 0x83, 0x73, 0x2f, 0x83, 0x9f, 0x5e, 0x06, + 0xef, 0x8f, 0x85, 0xa6, 0x8f, 0x66, 0x93, 0x6e, 0xf1, 0x90, 0xad, 0x74, 0xad, 0x5e, 0xb0, 0x86, + 0xcc, 0x42, 0xa9, 0x74, 0x76, 0x1a, 0x66, 0xa0, 0xb6, 0x02, 0xbb, 0x99, 0x0c, 0x13, 0x3c, 0xfd, + 0x05, 0x00, 0x00, 0xff, 0xff, 0x01, 0xfb, 0x59, 0x1d, 0x1f, 0x01, 0x00, 0x00, +} + +func (m *PageRequest) 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 *PageRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PageRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.CountTotal { + i-- + if m.CountTotal { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x20 + } + if m.Limit != 0 { + i = encodeVarintPagination(dAtA, i, uint64(m.Limit)) + i-- + dAtA[i] = 0x18 + } + if m.Offset != 0 { + i = encodeVarintPagination(dAtA, i, uint64(m.Offset)) + i-- + dAtA[i] = 0x10 + } + if len(m.Key) > 0 { + i -= len(m.Key) + copy(dAtA[i:], m.Key) + i = encodeVarintPagination(dAtA, i, uint64(len(m.Key))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *PageResponse) 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 *PageResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PageResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Total != 0 { + i = encodeVarintPagination(dAtA, i, uint64(m.Total)) + i-- + dAtA[i] = 0x10 + } + if len(m.NextKey) > 0 { + i -= len(m.NextKey) + copy(dAtA[i:], m.NextKey) + i = encodeVarintPagination(dAtA, i, uint64(len(m.NextKey))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintPagination(dAtA []byte, offset int, v uint64) int { + offset -= sovPagination(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *PageRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Key) + if l > 0 { + n += 1 + l + sovPagination(uint64(l)) + } + if m.Offset != 0 { + n += 1 + sovPagination(uint64(m.Offset)) + } + if m.Limit != 0 { + n += 1 + sovPagination(uint64(m.Limit)) + } + if m.CountTotal { + n += 2 + } + return n +} + +func (m *PageResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.NextKey) + if l > 0 { + n += 1 + l + sovPagination(uint64(l)) + } + if m.Total != 0 { + n += 1 + sovPagination(uint64(m.Total)) + } + return n +} + +func sovPagination(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozPagination(x uint64) (n int) { + return sovPagination(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *PageRequest) 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 ErrIntOverflowPagination + } + 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: PageRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PageRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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 ErrIntOverflowPagination + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthPagination + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthPagination + } + 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 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Offset", wireType) + } + m.Offset = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPagination + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Offset |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Limit", wireType) + } + m.Limit = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPagination + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Limit |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CountTotal", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPagination + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.CountTotal = bool(v != 0) + default: + iNdEx = preIndex + skippy, err := skipPagination(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthPagination + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthPagination + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *PageResponse) 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 ErrIntOverflowPagination + } + 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: PageResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PageResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NextKey", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPagination + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthPagination + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthPagination + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.NextKey = append(m.NextKey[:0], dAtA[iNdEx:postIndex]...) + if m.NextKey == nil { + m.NextKey = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Total", wireType) + } + m.Total = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPagination + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Total |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipPagination(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthPagination + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthPagination + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipPagination(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, ErrIntOverflowPagination + } + 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, ErrIntOverflowPagination + } + 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, ErrIntOverflowPagination + } + 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, ErrInvalidLengthPagination + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupPagination + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthPagination + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthPagination = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowPagination = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupPagination = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/gov/types/permission.go b/x/gov/types/permission.go new file mode 100644 index 000000000..66522de48 --- /dev/null +++ b/x/gov/types/permission.go @@ -0,0 +1,401 @@ +package types + +type PermInfo struct { + Id int32 `json:"id"` + Name string `json:"name"` + Module string `json:"module"` + Description string `json:"description"` +} + +var PermMetadata = []PermInfo{ + { + Id: int32(PermSetPermissions), + Name: "PERMISSION_SET_PERMISSIONS", + Module: "gov", + Description: "the permission that allows to Set Permissions to other actors", + }, + { + Id: int32(PermClaimValidator), + Name: "PERMISSION_CLAIM_VALIDATOR", + Module: "customstaking", + Description: "the permission that allows to Claim a validator Seat", + }, + { + Id: int32(PermClaimCouncilor), + Name: "PERMISSION_CLAIM_COUNCILOR", + Module: "gov", + Description: "the permission that allows to Claim a Councilor Seat", + }, + { + Id: int32(PermWhitelistAccountPermissionProposal), + Name: "PERMISSION_WHITELIST_ACCOUNT_PERMISSION_PROPOSAL", + Module: "gov", + Description: "the permission needed to create proposals for whitelisting an account permission.", + }, + { + Id: int32(PermVoteWhitelistAccountPermissionProposal), + Name: "PERMISSION_VOTE_WHITELIST_ACCOUNT_PERMISSION_PROPOSAL", + Module: "gov", + Description: "the permission that an actor must have in order to vote a proposal to whitelist account permission", + }, + { + Id: int32(PermUpsertTokenAlias), + Name: "PERMISSION_UPSERT_TOKEN_ALIAS", + Module: "tokens", + Description: "the permission to upsert token alias", + }, + { + Id: int32(PermChangeTxFee), + Name: "PERMISSION_CHANGE_TX_FEE", + Module: "tokens", + Description: "Permission to change tx fee", + }, + { + Id: int32(PermUpsertTokenRate), + Name: "PERMISSION_UPSERT_TOKEN_RATE", + Module: "tokens", + Description: "Permission to upsert token rate", + }, + { + Id: int32(PermUpsertRole), + Name: "PERMISSION_UPSERT_ROLE", + Module: "gov", + Description: "Permission to upsert a role", + }, + { + Id: int32(PermCreateUpsertDataRegistryProposal), + Name: "PERMISSION_CREATE_UPSERT_DATA_REGISTRY_PROPOSAL", + Module: "gov", + Description: "makes possible to create a proposal to change the Data Registry", + }, + { + Id: int32(PermVoteUpsertDataRegistryProposal), + Name: "PERMISSION_VOTE_UPSERT_DATA_REGISTRY_PROPOSAL", + Module: "gov", + Description: "makes possible to vote on a proposal to change the Data Registry.", + }, + { + Id: int32(PermCreateSetNetworkPropertyProposal), + Name: "PERMISSION_CREATE_SET_NETWORK_PROPERTY_PROPOSAL", + Module: "gov", + Description: "the permission needed to create proposals for setting network property", + }, + { + Id: int32(PermVoteSetNetworkPropertyProposal), + Name: "PERMISSION_VOTE_SET_NETWORK_PROPERTY_PROPOSAL", + Module: "gov", + Description: "the permission that an actor must have in order to vote a proposal to set network property.", + }, + { + Id: int32(PermCreateUpsertTokenAliasProposal), + Name: "PERMISSION_CREATE_UPSERT_TOKEN_ALIAS_PROPOSAL", + Module: "tokens", + Description: "the permission needed to create proposals for upsert token Alias.", + }, + { + Id: int32(PermVoteUpsertTokenAliasProposal), + Name: "PERMISSION_VOTE_UPSERT_TOKEN_ALIAS_PROPOSAL", + Module: "tokens", + Description: "the permission needed to vote proposals for upsert token.", + }, + { + Id: int32(PermCreateSetPoorNetworkMessagesProposal), + Name: "PERMISSION_CREATE_SET_POOR_NETWORK_MESSAGES", + Module: "tokens", + Description: "the permission needed to create proposals for setting poor network messages.", + }, + { + Id: int32(PermVoteSetPoorNetworkMessagesProposal), + Name: "PERMISSION_VOTE_SET_POOR_NETWORK_MESSAGES_PROPOSAL", + Module: "tokens", + Description: "the permission needed to vote proposals to set poor network messages.", + }, + { + Id: int32(PermCreateUpsertTokenRateProposal), + Name: "PERMISSION_CREATE_UPSERT_TOKEN_RATE_PROPOSAL", + Module: "tokens", + Description: "the permission needed to create proposals for upsert token rate.", + }, + { + Id: int32(PermVoteUpsertTokenRateProposal), + Name: "PERMISSION_VOTE_UPSERT_TOKEN_RATE_PROPOSAL", + Module: "tokens", + Description: "the permission needed to vote proposals for upsert token rate.", + }, + { + Id: int32(PermCreateUnjailValidatorProposal), + Name: "PERMISSION_CREATE_UNJAIL_VALIDATOR_PROPOSAL", + Module: "slashing", + Description: "the permission needed to create a proposal to unjail a validator.", + }, + { + Id: int32(PermVoteUnjailValidatorProposal), + Name: "PERMISSION_VOTE_UNJAIL_VALIDATOR_PROPOSAL", + Module: "slashing", + Description: "the permission needed to vote a proposal to unjail a validator.", + }, + { + Id: int32(PermCreateRoleProposal), + Name: "PERMISSION_CREATE_CREATE_ROLE_PROPOSAL", + Module: "gov", + Description: "the permission needed to create a proposal to create a role.", + }, + { + Id: int32(PermVoteCreateRoleProposal), + Name: "PERMISSION_VOTE_CREATE_ROLE_PROPOSAL", + Module: "gov", + Description: "the permission needed to vote a proposal to create a role.", + }, + { + Id: int32(PermCreateTokensWhiteBlackChangeProposal), + Name: "PERMISSION_CREATE_TOKENS_WHITE_BLACK_CHANGE_PROPOSAL", + Module: "tokens", + Description: "the permission needed to create a proposal to blacklist/whitelisted tokens", + }, + { + Id: int32(PermVoteTokensWhiteBlackChangeProposal), + Name: "PERMISSION_VOTE_TOKENS_WHITE_BLACK_CHANGE_PROPOSAL", + Module: "tokens", + Description: "the permission needed to vote on blacklist/whitelisted tokens proposal", + }, + { + Id: int32(PermCreateResetWholeValidatorRankProposal), + Name: "PERMISSION_CREATE_RESET_WHOLE_VALIDATOR_RANK_PROPOSAL", + Module: "customstaking", + Description: "the permission needed to create a proposal to reset whole validator rank", + }, + { + Id: int32(PermVoteResetWholeValidatorRankProposal), + Name: "PERMISSION_VOTE_RESET_WHOLE_VALIDATOR_RANK_PROPOSAL", + Module: "customstaking", + Description: "the permission needed to vote on reset whole validator rank proposal", + }, + { + Id: int32(PermCreateSoftwareUpgradeProposal), + Name: "PERMISSION_CREATE_SOFTWARE_UPGRADE_PROPOSAL", + Module: "upgrade", + Description: "the permission needed to create a proposal for software upgrade", + }, + { + Id: int32(PermCreateSoftwareUpgradeProposal), + Name: "PermVoteSoftwareUpgradeProposal", + Module: "upgrade", + Description: "the permission needed to vote on software upgrade proposal", + }, + { + Id: int32(PermSetClaimValidatorPermission), + Name: "PERMISSION_SET_CLAIM_VALIDATOR_PERMISSION", + Module: "customstaking", + Description: "the permission that allows to Set ClaimValidatorPermission to other actors.", + }, + { + Id: int32(PermCreateSetProposalDurationProposal), + Name: "PERMISSION_CREATE_SET_PROPOSAL_DURATION_PROPOSAL", + Module: "gov", + Description: "the permission needed to create a proposal to set proposal duration.", + }, + { + Id: int32(PermVoteSetProposalDurationProposal), + Name: "PERMISSION_VOTE_SET_PROPOSAL_DURATION_PROPOSAL", + Module: "gov", + Description: "the permission needed to vote a proposal to set proposal duration.", + }, + { + Id: int32(PermBlacklistAccountPermissionProposal), + Name: "PERMISSION_BLACKLIST_ACCOUNT_PERMISSION_PROPOSAL", + Module: "gov", + Description: "the permission needed to create proposals for blacklisting an account permission.", + }, + { + Id: int32(PermVoteBlacklistAccountPermissionProposal), + Name: "PERMISSION_VOTE_BLACKLIST_ACCOUNT_PERMISSION_PROPOSAL", + Module: "gov", + Description: "the permission that an actor must have in order to vote a proposal to blacklist account permission.", + }, + { + Id: int32(PermRemoveWhitelistedAccountPermissionProposal), + Name: "PERMISSION_REMOVE_WHITELISTED_ACCOUNT_PERMISSION_PROPOSAL", + Module: "gov", + Description: "the permission needed to create proposals for removing whitelisted permission from an account.", + }, + { + Id: int32(PermVoteRemoveWhitelistedAccountPermissionProposal), + Name: "PERMISSION_VOTE_REMOVE_WHITELISTED_ACCOUNT_PERMISSION_PROPOSAL", + Module: "gov", + Description: "the permission that an actor must have in order to vote a proposal to remove a whitelisted account permission.", + }, + { + Id: int32(PermRemoveBlacklistedAccountPermissionProposal), + Name: "PERMISSION_REMOVE_BLACKLISTED_ACCOUNT_PERMISSION_PROPOSAL", + Module: "gov", + Description: "the permission needed to create proposals for removing blacklisted permission from an account.", + }, + { + Id: int32(PermVoteRemoveBlacklistedAccountPermissionProposal), + Name: "PERMISSION_VOTE_REMOVE_BLACKLISTED_ACCOUNT_PERMISSION_PROPOSAL", + Module: "gov", + Description: "the permission that an actor must have in order to vote a proposal to remove a blacklisted account permission.", + }, + { + Id: int32(PermWhitelistRolePermissionProposal), + Name: "PERMISSION_WHITELIST_ROLE_PERMISSION_PROPOSAL", + Module: "gov", + Description: "the permission needed to create proposals for whitelisting an role permission.", + }, + { + Id: int32(PermVoteWhitelistRolePermissionProposal), + Name: "PERMISSION_VOTE_WHITELIST_ROLE_PERMISSION_PROPOSAL", + Module: "gov", + Description: "the permission that an actor must have in order to vote a proposal to whitelist role permission.", + }, + { + Id: int32(PermBlacklistRolePermissionProposal), + Name: "PERMISSION_BLACKLIST_ROLE_PERMISSION_PROPOSAL", + Module: "gov", + Description: "the permission needed to create proposals for blacklisting an role permission.", + }, + { + Id: int32(PermVoteBlacklistRolePermissionProposal), + Name: "PERMISSION_VOTE_BLACKLIST_ROLE_PERMISSION_PROPOSAL", + Module: "gov", + Description: "the permission that an actor must have in order to vote a proposal to blacklist role permission.", + }, + { + Id: int32(PermRemoveWhitelistedRolePermissionProposal), + Name: "PERMISSION_REMOVE_WHITELISTED_ROLE_PERMISSION_PROPOSAL", + Module: "gov", + Description: "the permission needed to create proposals for removing whitelisted permission from a role.", + }, + { + Id: int32(PermVoteRemoveWhitelistedRolePermissionProposal), + Name: "PERMISSION_VOTE_REMOVE_WHITELISTED_ROLE_PERMISSION_PROPOSAL", + Module: "gov", + Description: "the permission that an actor must have in order to vote a proposal to remove a whitelisted role permission.", + }, + { + Id: int32(PermRemoveBlacklistedRolePermissionProposal), + Name: "PERMISSION_REMOVE_BLACKLISTED_ROLE_PERMISSION_PROPOSAL", + Module: "gov", + Description: "the permission needed to create proposals for removing blacklisted permission from a role.", + }, + { + Id: int32(PermVoteRemoveBlacklistedRolePermissionProposal), + Name: "PERMISSION_VOTE_REMOVE_BLACKLISTED_ROLE_PERMISSION_PROPOSAL", + Module: "gov", + Description: "the permission that an actor must have in order to vote a proposal to remove a blacklisted role permission.", + }, + { + Id: int32(PermAssignRoleToAccountProposal), + Name: "PERMISSION_ASSIGN_ROLE_TO_ACCOUNT_PROPOSAL", + Module: "gov", + Description: "the permission needed to create proposals to assign role to an account.", + }, + { + Id: int32(PermVoteAssignRoleToAccountProposal), + Name: "PERMISSION_VOTE_ASSIGN_ROLE_TO_ACCOUNT_PROPOSAL", + Module: "gov", + Description: "the permission that an actor must have in order to vote a proposal to assign role to an account", + }, + { + Id: int32(PermUnassignRoleFromAccountProposal), + Name: "PERMISSION_UNASSIGN_ROLE_FROM_ACCOUNT_PROPOSAL", + Module: "gov", + Description: "the permission needed to create proposals to unassign role from an account", + }, + { + Id: int32(PermVoteUnassignRoleFromAccountProposal), + Name: "PERMISSION_VOTE_UNASSIGN_ROLE_FROM_ACCOUNT_PROPOSAL", + Module: "gov", + Description: "the permission that an actor must have in order to vote a proposal to unassign role from an account", + }, + { + Id: int32(PermRemoveRoleProposal), + Name: "PERMISSION_CREATE_REMOVE_ROLE_PROPOSAL", + Module: "gov", + Description: "the permission needed to create a proposal to remove a role.", + }, + { + Id: int32(PermVoteRemoveRoleProposal), + Name: "PERMISSION_VOTE_REMOVE_ROLE_PROPOSAL", + Module: "gov", + Description: "the permission needed to vote a proposal to remove a role.", + }, + { + Id: int32(PermCreateUpsertUBIProposal), + Name: "PERMISSION_CREATE_UPSERT_UBI_PROPOSAL", + Module: "ubi", + Description: "the permission needed to create proposals to upsert ubi.", + }, + { + Id: int32(PermVoteUpsertUBIProposal), + Name: "PERMISSION_VOTE_UPSERT_UBI_PROPOSAL", + Module: "ubi", + Description: "the permission that an actor must have in order to vote a proposal to upsert ubi", + }, + { + Id: int32(PermCreateRemoveUBIProposal), + Name: "PERMISSION_CREATE_REMOVE_UBI_PROPOSAL", + Module: "ubi", + Description: "the permission needed to create a proposal to remove ubi", + }, + { + Id: int32(PermVoteRemoveUBIProposal), + Name: "PERMISSION_VOTE_REMOVE_UBI_PROPOSAL", + Module: "ubi", + Description: "the permission needed to vote a proposal to remove ubi.", + }, + { + Id: int32(PermCreateSlashValidatorProposal), + Name: "PERMISSION_CREATE_SLASH_VALIDATOR_PROPOSAL", + Module: "slashing", + Description: "the permission needed to create a proposal to slash validator", + }, + { + Id: int32(PermVoteSlashValidatorProposal), + Name: "PERMISSION_VOTE_SLASH_VALIDATOR_PROPOSAL", + Module: "slashing", + Description: "the permission needed to vote a proposal to slash validator", + }, + { + Id: int32(PermCreateBasketProposal), + Name: "PERMISSION_CREATE_BASKET_PROPOSAL", + Module: "basket", + Description: "the permission needed to create a proposal related to basket", + }, + { + Id: int32(PermVoteBasketProposal), + Name: "PERMISSION_VOTE_BASKET_PROPOSAL", + Module: "basket", + Description: "the permission needed to vote a proposal related to basket", + }, + { + Id: int32(PermHandleBasketEmergency), + Name: "PERMISSION_HANDLE_BASKET_EMERGENCY", + Module: "basket", + Description: "the permission needed to handle emergency issues on basket", + }, + { + Id: int32(PermCreateResetWholeCouncilorRankProposal), + Name: "PERMISSION_CREATE_RESET_WHOLE_COUNCILOR_RANK_PROPOSAL", + Module: "gov", + Description: "the permission needed to create a proposal to reset whole councilor rank", + }, + { + Id: int32(PermVoteResetWholeCouncilorRankProposal), + Name: "PERMISSION_VOTE_RESET_WHOLE_COUNCILOR_RANK_PROPOSAL", + Module: "gov", + Description: "the permission needed to vote on reset whole councilor rank proposal", + }, + { + Id: int32(PermCreateJailCouncilorProposal), + Name: "PERMISSION_CREATE_JAIL_COUNCILOR_PROPOSAL", + Module: "gov", + Description: "the permission needed to create a proposal to jail councilors", + }, + { + Id: int32(PermVoteJailCouncilorProposal), + Name: "PERMISSION_VOTE_JAIL_COUNCILOR_PROPOSAL", + Module: "gov", + Description: "the permission needed to vote on jail councilors proposal", + }, +} diff --git a/x/gov/types/permission.pb.go b/x/gov/types/permission.pb.go index 0c6abba9e..9067a9a37 100644 --- a/x/gov/types/permission.pb.go +++ b/x/gov/types/permission.pb.go @@ -168,6 +168,10 @@ const ( PermCreateJailCouncilorProposal PermValue = 64 // PERMISSION_VOTE_JAIL_COUNCILOR_PROPOSAL defines the permission needed to vote on jail councilors proposal PermVoteJailCouncilorProposal PermValue = 65 + // PERMISSION_CREATE_POLL_PROPOSAL defines the permission needed to create a poll proposal. + PermCreatePollProposal PermValue = 66 + // PERMISSION_CREATE_DAPP_PROPOSAL_WITHOUT_BOND defines the permission needed to create a dapp proposal without bond + PermCreateDappProposalWithoutBond PermValue = 67 ) var PermValue_name = map[int32]string{ @@ -237,6 +241,8 @@ var PermValue_name = map[int32]string{ 63: "PERMISSION_VOTE_RESET_WHOLE_COUNCILOR_RANK_PROPOSAL", 64: "PERMISSION_CREATE_JAIL_COUNCILOR_PROPOSAL", 65: "PERMISSION_VOTE_JAIL_COUNCILOR_PROPOSAL", + 66: "PERMISSION_CREATE_POLL_PROPOSAL", + 67: "PERMISSION_CREATE_DAPP_PROPOSAL_WITHOUT_BOND", } var PermValue_value = map[string]int32{ @@ -306,6 +312,8 @@ var PermValue_value = map[string]int32{ "PERMISSION_VOTE_RESET_WHOLE_COUNCILOR_RANK_PROPOSAL": 63, "PERMISSION_CREATE_JAIL_COUNCILOR_PROPOSAL": 64, "PERMISSION_VOTE_JAIL_COUNCILOR_PROPOSAL": 65, + "PERMISSION_CREATE_POLL_PROPOSAL": 66, + "PERMISSION_CREATE_DAPP_PROPOSAL_WITHOUT_BOND": 67, } func (x PermValue) String() string { @@ -323,105 +331,108 @@ func init() { func init() { proto.RegisterFile("kira/gov/permission.proto", fileDescriptor_214168f8815c1062) } var fileDescriptor_214168f8815c1062 = []byte{ - // 1596 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x98, 0xdb, 0x76, 0xd3, 0x46, - 0x17, 0xc7, 0x93, 0xef, 0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 0xec, 0x38, 0x3b, 0x64, 0x01, 0xba, 0x06, 0x56, 0x62, 0xfc, 0x16, 0x82, - 0xaf, 0xc1, 0x59, 0x42, 0x11, 0xe2, 0xdd, 0x16, 0x60, 0x5f, 0x70, 0xd8, 0x90, 0xd7, 0x55, 0x45, - 0x51, 0x03, 0x4f, 0xca, 0xb2, 0xa6, 0x49, 0xdb, 0xb2, 0x96, 0x4a, 0xc1, 0xbb, 0x84, 0xa2, 0x45, - 0xce, 0xe7, 0xaa, 0x65, 0xd9, 0x5d, 0x43, 0xca, 0xd8, 0x71, 0x8c, 0x06, 0x66, 0xf8, 0x97, 0x60, - 0x4d, 0xe4, 0xb5, 0x10, 0xce, 0x82, 0xff, 0x8c, 0x5d, 0x17, 0x5d, 0xc3, 0x07, 0x69, 0xec, 0x83, - 0xbb, 0x43, 0x4c, 0xf7, 0x4a, 0x8b, 0xd1, 0xd3, 0x70, 0x8e, 0x50, 0x34, 0x25, 0xf4, 0xdc, 0xab, - 0xb4, 0x00, 0xac, 0x81, 0xe5, 0x81, 0x96, 0xf3, 0xd8, 0xeb, 0x70, 0x86, 0x50, 0x34, 0x29, 0x70, - 0x9c, 0x83, 0xee, 0x89, 0x0c, 0xaf, 0x55, 0x9e, 0x49, 0xc5, 0x12, 0xbb, 0xb6, 0x19, 0xf5, 0x46, - 0x5f, 0xb0, 0xed, 0x9f, 0x0c, 0xb3, 0x15, 0x5c, 0xe3, 0x01, 0x57, 0x05, 0x4b, 0x7d, 0xc1, 0xc6, - 0x52, 0x3f, 0x8f, 0xc4, 0x1a, 0xc3, 0xdc, 0x02, 0xf3, 0xfd, 0xb1, 0x76, 0xff, 0xf0, 0x6e, 0x1e, - 0x06, 0x1c, 0x83, 0x90, 0x50, 0x34, 0xc6, 0xc2, 0xf4, 0xae, 0xa0, 0x80, 0xb3, 0x03, 0x66, 0xa3, - 0xb1, 0x09, 0x29, 0x37, 0x61, 0x86, 0x50, 0x04, 0x7b, 0x61, 0x09, 0x48, 0xaf,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xe3, 0x8f, 0xe8, 0x4c, 0x20, 0x60, 0x7f, 0xcb, 0xee, 0xdc, 0x4e, 0x0e, - 0xcf, 0x0c, 0xb3, 0x15, 0x70, 0x03, 0x66, 0x05, 0x2c, 0x44, 0x23, 0x8f, 0x23, 0x4a, 0x70, 0x8a, - 0x50, 0x34, 0xd1, 0x8b, 0x56, 0xc8, 0x83, 0x17, 0x7e, 0xfd, 0x3d, 0x33, 0xb2, 0xf9, 0xf4, 0xcf, - 0x0f, 0x99, 0xd1, 0xf7, 0x1f, 0x32, 0xa3, 0x7f, 0x7f, 0xc8, 0x8c, 0xfe, 0xf6, 0x31, 0x33, 0xf2, - 0xfe, 0x63, 0x66, 0xe4, 0xaf, 0x8f, 0x99, 0x91, 0x83, 0xb9, 0x86, 0xe9, 0x1e, 0x9f, 0xbd, 0xcc, - 0x1e, 0x5a, 0x27, 0xb9, 0x5d, 0xd3, 0x36, 0xf2, 0x96, 0x8d, 0x73, 0x0e, 0x6e, 0x1a, 0x66, 0xee, - 0xad, 0xff, 0x43, 0xb9, 0xfb, 0xee, 0x14, 0x3b, 0x2f, 0x2f, 0xfa, 0x3f, 0x82, 0xaf, 0xff, 0x13, - 0x00, 0x00, 0xff, 0xff, 0x93, 0x4b, 0xe3, 0x06, 0x41, 0x17, 0x00, 0x00, + // 1647 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x98, 0xcd, 0x76, 0xd3, 0x46, + 0x14, 0xc7, 0x93, 0x96, 0x52, 0x98, 0x52, 0x50, 0x0d, 0x0d, 0x61, 0x20, 0xce, 0xe4, 0xfb, 0x0b, + 0x6c, 0x48, 0x20, 0x2d, 0xa5, 0x85, 0xca, 0xb6, 0x12, 0x9b, 0xd8, 0x96, 0x8f, 0x24, 0xc7, 0x25, + 0x2d, 0xc7, 0x15, 0xc9, 0xe0, 0xa8, 0x56, 0x3c, 0xae, 0xa4, 0xf0, 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59, 0xbf, 0x46, 0x74, 0x7d, 0xf4, 0xd7, 0x98, 0x02, 0x5f, 0xab, 0xd1, 0x61, 0xa5, 0x51, 0x52, + 0x8a, 0x62, 0x5d, 0x69, 0xe6, 0xc4, 0x6a, 0x81, 0xcb, 0x87, 0xc7, 0xc0, 0x82, 0xda, 0xed, 0x0e, + 0x68, 0x0d, 0xcd, 0x3a, 0x26, 0xa7, 0x56, 0x8e, 0x74, 0x8e, 0xe0, 0xb9, 0xdf, 0xff, 0x4c, 0x4f, + 0xe4, 0x9e, 0xfc, 0xf5, 0x3e, 0x3d, 0xf9, 0xee, 0x7d, 0x7a, 0xf2, 0xdf, 0xf7, 0xe9, 0xc9, 0x3f, + 0x3e, 0xa4, 0x27, 0xde, 0x7d, 0x48, 0x4f, 0xfc, 0xf3, 0x21, 0x3d, 0x71, 0xb0, 0xd4, 0xd2, 0xac, + 0xe3, 0xd3, 0x17, 0x99, 0x43, 0x72, 0x92, 0xdd, 0xd3, 0x0c, 0x35, 0x4f, 0x0c, 0x9c, 0x35, 0x71, + 0x5b, 0xd5, 0xb2, 0x6f, 0xbc, 0x4f, 0xf8, 0xd6, 0xdb, 0x2e, 0x36, 0x5f, 0x9c, 0xf7, 0x3e, 0xcf, + 0x6f, 0xfd, 0x17, 0x00, 0x00, 0xff, 0xff, 0x16, 0xe0, 0x0d, 0x6b, 0xdb, 0x17, 0x00, 0x00, } diff --git a/x/gov/types/poll.go b/x/gov/types/poll.go new file mode 100644 index 000000000..6c625f6b8 --- /dev/null +++ b/x/gov/types/poll.go @@ -0,0 +1,69 @@ +package types + +import ( + "github.com/KiraCore/sekai/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "time" +) + +// NewPoll creates a new poll proposal +func NewPoll(pollID uint64, creator sdk.AccAddress, title string, description string, reference string, checksum string, roles []uint64, options *PollOptions, expire time.Time) (Poll, error) { + return Poll{ + PollId: pollID, + Creator: creator, + Title: title, + Description: description, + Reference: reference, + Checksum: checksum, + Roles: roles, + Options: options, + VotingEndTime: expire, + Result: PollPending, + }, nil +} + +func (m *Poll) Route() string { + return ModuleName +} + +func (m *Poll) Type() string { + return types.MsgTypeCreatePoll +} + +func (m *Poll) ValidateBasic() error { + return nil +} + +func (m *Poll) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(m) + return sdk.MustSortJSON(bz) +} + +func (m *Poll) GetSigners() []sdk.AccAddress { + return []sdk.AccAddress{ + m.Creator, + } +} + +func (m *AddressPolls) Route() string { + return ModuleName +} + +func (m *AddressPolls) Type() string { + return types.MsgTypeAddressPoll +} + +func (m *AddressPolls) ValidateBasic() error { + return nil +} + +func (m *AddressPolls) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(m) + return sdk.MustSortJSON(bz) +} + +func (m *AddressPolls) GetSigners() []sdk.AccAddress { + return []sdk.AccAddress{ + m.Address, + } +} diff --git a/x/gov/types/poll.pb.go b/x/gov/types/poll.pb.go new file mode 100644 index 000000000..b1548f827 --- /dev/null +++ b/x/gov/types/poll.pb.go @@ -0,0 +1,2624 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: kira/gov/poll.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/codec/types" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + github_com_gogo_protobuf_types "github.com/gogo/protobuf/types" + _ "github.com/regen-network/cosmos-proto" + _ "google.golang.org/protobuf/types/known/timestamppb" + io "io" + math "math" + math_bits "math/bits" + time "time" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf +var _ = time.Kitchen + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type PollVoteOption int32 + +const ( + // VOTE_OPTION_UNSPECIFIED defines a no-op vote option. + PollOptionEmpty PollVoteOption = 0 + // VOTE_OPTION_ABSTAIN defines an abstain vote option. + PollOptionAbstain PollVoteOption = 1 + // VOTE_OPTION_NO defines a no vote option. + PollOptionCustom PollVoteOption = 2 + // VOTE_OPTION_NO_WITH_VETO defines a no with veto vote option. + PollOptionNoWithVeto PollVoteOption = 3 +) + +var PollVoteOption_name = map[int32]string{ + 0: "POLL_VOTE_OPTION_UNSPECIFIED", + 1: "POLL_VOTE_OPTION_ABSTAIN", + 2: "POLL_VOTE_OPTION_CUSTOM", + 3: "POLL_VOTE_OPTION_NO_WITH_VETO", +} + +var PollVoteOption_value = map[string]int32{ + "POLL_VOTE_OPTION_UNSPECIFIED": 0, + "POLL_VOTE_OPTION_ABSTAIN": 1, + "POLL_VOTE_OPTION_CUSTOM": 2, + "POLL_VOTE_OPTION_NO_WITH_VETO": 3, +} + +func (x PollVoteOption) String() string { + return proto.EnumName(PollVoteOption_name, int32(x)) +} + +func (PollVoteOption) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_c3fa5d41f67be42c, []int{0} +} + +type PollResult int32 + +const ( + PollUnknown PollResult = 0 + PollPassed PollResult = 1 + PollRejected PollResult = 2 + PollRejectedWithVeto PollResult = 3 + PollPending PollResult = 4 + PollQuorumNotReached PollResult = 5 +) + +var PollResult_name = map[int32]string{ + 0: "POLL_RESULT_UNKNOWN", + 1: "POLL_RESULT_PASSED", + 2: "POLL_RESULT_REJECTED", + 3: "POLL_RESULT_REJECTED_WITH_VETO", + 4: "POLL_PENDING", + 5: "POLL_RESULT_QUORUM_NOT_REACHED", +} + +var PollResult_value = map[string]int32{ + "POLL_RESULT_UNKNOWN": 0, + "POLL_RESULT_PASSED": 1, + "POLL_RESULT_REJECTED": 2, + "POLL_RESULT_REJECTED_WITH_VETO": 3, + "POLL_PENDING": 4, + "POLL_RESULT_QUORUM_NOT_REACHED": 5, +} + +func (x PollResult) String() string { + return proto.EnumName(PollResult_name, int32(x)) +} + +func (PollResult) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_c3fa5d41f67be42c, []int{1} +} + +type PollVote struct { + PollId uint64 `protobuf:"varint,1,opt,name=poll_id,json=pollId,proto3" json:"poll_id,omitempty"` + Voter github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,2,opt,name=voter,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"voter,omitempty"` + Option PollVoteOption `protobuf:"varint,3,opt,name=option,proto3,enum=kira.gov.PollVoteOption" json:"option,omitempty"` + CustomValue string `protobuf:"bytes,5,opt,name=custom_value,json=customValue,proto3" json:"custom_value,omitempty"` +} + +func (m *PollVote) Reset() { *m = PollVote{} } +func (m *PollVote) String() string { return proto.CompactTextString(m) } +func (*PollVote) ProtoMessage() {} +func (*PollVote) Descriptor() ([]byte, []int) { + return fileDescriptor_c3fa5d41f67be42c, []int{0} +} +func (m *PollVote) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PollVote) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PollVote.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 *PollVote) XXX_Merge(src proto.Message) { + xxx_messageInfo_PollVote.Merge(m, src) +} +func (m *PollVote) XXX_Size() int { + return m.Size() +} +func (m *PollVote) XXX_DiscardUnknown() { + xxx_messageInfo_PollVote.DiscardUnknown(m) +} + +var xxx_messageInfo_PollVote proto.InternalMessageInfo + +func (m *PollVote) GetPollId() uint64 { + if m != nil { + return m.PollId + } + return 0 +} + +func (m *PollVote) GetVoter() github_com_cosmos_cosmos_sdk_types.AccAddress { + if m != nil { + return m.Voter + } + return nil +} + +func (m *PollVote) GetOption() PollVoteOption { + if m != nil { + return m.Option + } + return PollOptionEmpty +} + +func (m *PollVote) GetCustomValue() string { + if m != nil { + return m.CustomValue + } + return "" +} + +type PollOptions struct { + Values []string `protobuf:"bytes,1,rep,name=values,proto3" json:"values,omitempty"` + Count uint64 `protobuf:"varint,2,opt,name=count,proto3" json:"count,omitempty"` + Type string `protobuf:"bytes,3,opt,name=type,proto3" json:"type,omitempty"` + Choices uint64 `protobuf:"varint,4,opt,name=choices,proto3" json:"choices,omitempty"` +} + +func (m *PollOptions) Reset() { *m = PollOptions{} } +func (m *PollOptions) String() string { return proto.CompactTextString(m) } +func (*PollOptions) ProtoMessage() {} +func (*PollOptions) Descriptor() ([]byte, []int) { + return fileDescriptor_c3fa5d41f67be42c, []int{1} +} +func (m *PollOptions) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PollOptions) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PollOptions.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 *PollOptions) XXX_Merge(src proto.Message) { + xxx_messageInfo_PollOptions.Merge(m, src) +} +func (m *PollOptions) XXX_Size() int { + return m.Size() +} +func (m *PollOptions) XXX_DiscardUnknown() { + xxx_messageInfo_PollOptions.DiscardUnknown(m) +} + +var xxx_messageInfo_PollOptions proto.InternalMessageInfo + +func (m *PollOptions) GetValues() []string { + if m != nil { + return m.Values + } + return nil +} + +func (m *PollOptions) GetCount() uint64 { + if m != nil { + return m.Count + } + return 0 +} + +func (m *PollOptions) GetType() string { + if m != nil { + return m.Type + } + return "" +} + +func (m *PollOptions) GetChoices() uint64 { + if m != nil { + return m.Choices + } + return 0 +} + +type AddressPolls struct { + Address github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,1,opt,name=address,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"address,omitempty" yaml:"address"` + Ids []uint64 `protobuf:"varint,2,rep,packed,name=ids,proto3" json:"ids,omitempty"` +} + +func (m *AddressPolls) Reset() { *m = AddressPolls{} } +func (m *AddressPolls) String() string { return proto.CompactTextString(m) } +func (*AddressPolls) ProtoMessage() {} +func (*AddressPolls) Descriptor() ([]byte, []int) { + return fileDescriptor_c3fa5d41f67be42c, []int{2} +} +func (m *AddressPolls) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *AddressPolls) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_AddressPolls.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 *AddressPolls) XXX_Merge(src proto.Message) { + xxx_messageInfo_AddressPolls.Merge(m, src) +} +func (m *AddressPolls) XXX_Size() int { + return m.Size() +} +func (m *AddressPolls) XXX_DiscardUnknown() { + xxx_messageInfo_AddressPolls.DiscardUnknown(m) +} + +var xxx_messageInfo_AddressPolls proto.InternalMessageInfo + +func (m *AddressPolls) GetAddress() github_com_cosmos_cosmos_sdk_types.AccAddress { + if m != nil { + return m.Address + } + return nil +} + +func (m *AddressPolls) GetIds() []uint64 { + if m != nil { + return m.Ids + } + return nil +} + +type Poll struct { + PollId uint64 `protobuf:"varint,1,opt,name=poll_id,json=pollId,proto3" json:"poll_id,omitempty"` + Creator github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,2,opt,name=creator,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"creator,omitempty"` + Title string `protobuf:"bytes,3,opt,name=title,proto3" json:"title,omitempty"` + Description string `protobuf:"bytes,4,opt,name=description,proto3" json:"description,omitempty"` + Reference string `protobuf:"bytes,5,opt,name=reference,proto3" json:"reference,omitempty"` + Checksum string `protobuf:"bytes,6,opt,name=checksum,proto3" json:"checksum,omitempty"` + Roles []uint64 `protobuf:"varint,7,rep,packed,name=roles,proto3" json:"roles,omitempty"` + Options *PollOptions `protobuf:"bytes,8,opt,name=options,proto3" json:"options,omitempty"` + VotingEndTime time.Time `protobuf:"bytes,9,opt,name=voting_end_time,json=votingEndTime,proto3,stdtime" json:"voting_end_time" yaml:"voting_end_time"` + Result PollResult `protobuf:"varint,10,opt,name=result,proto3,enum=kira.gov.PollResult" json:"result,omitempty"` +} + +func (m *Poll) Reset() { *m = Poll{} } +func (m *Poll) String() string { return proto.CompactTextString(m) } +func (*Poll) ProtoMessage() {} +func (*Poll) Descriptor() ([]byte, []int) { + return fileDescriptor_c3fa5d41f67be42c, []int{3} +} +func (m *Poll) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Poll) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Poll.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 *Poll) XXX_Merge(src proto.Message) { + xxx_messageInfo_Poll.Merge(m, src) +} +func (m *Poll) XXX_Size() int { + return m.Size() +} +func (m *Poll) XXX_DiscardUnknown() { + xxx_messageInfo_Poll.DiscardUnknown(m) +} + +var xxx_messageInfo_Poll proto.InternalMessageInfo + +type MsgPollVote struct { + PollId uint64 `protobuf:"varint,1,opt,name=poll_id,json=pollId,proto3" json:"poll_id,omitempty"` + Voter github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,2,opt,name=voter,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"voter,omitempty"` + Option PollVoteOption `protobuf:"varint,3,opt,name=option,proto3,enum=kira.gov.PollVoteOption" json:"option,omitempty"` + Value string `protobuf:"bytes,4,opt,name=value,proto3" json:"value,omitempty"` +} + +func (m *MsgPollVote) Reset() { *m = MsgPollVote{} } +func (m *MsgPollVote) String() string { return proto.CompactTextString(m) } +func (*MsgPollVote) ProtoMessage() {} +func (*MsgPollVote) Descriptor() ([]byte, []int) { + return fileDescriptor_c3fa5d41f67be42c, []int{4} +} +func (m *MsgPollVote) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgPollVote) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgPollVote.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 *MsgPollVote) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgPollVote.Merge(m, src) +} +func (m *MsgPollVote) XXX_Size() int { + return m.Size() +} +func (m *MsgPollVote) XXX_DiscardUnknown() { + xxx_messageInfo_MsgPollVote.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgPollVote proto.InternalMessageInfo + +func (m *MsgPollVote) GetPollId() uint64 { + if m != nil { + return m.PollId + } + return 0 +} + +func (m *MsgPollVote) GetVoter() github_com_cosmos_cosmos_sdk_types.AccAddress { + if m != nil { + return m.Voter + } + return nil +} + +func (m *MsgPollVote) GetOption() PollVoteOption { + if m != nil { + return m.Option + } + return PollOptionEmpty +} + +func (m *MsgPollVote) GetValue() string { + if m != nil { + return m.Value + } + return "" +} + +type MsgPollCreate struct { + Creator github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,1,opt,name=creator,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"creator,omitempty"` + Title string `protobuf:"bytes,2,opt,name=title,proto3" json:"title,omitempty"` + Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty"` + Reference string `protobuf:"bytes,4,opt,name=reference,proto3" json:"reference,omitempty"` + Checksum string `protobuf:"bytes,5,opt,name=checksum,proto3" json:"checksum,omitempty"` + Roles []string `protobuf:"bytes,6,rep,name=roles,proto3" json:"roles,omitempty"` + PollValues []string `protobuf:"bytes,7,rep,name=poll_values,json=pollValues,proto3" json:"poll_values,omitempty"` + ValueCount uint64 `protobuf:"varint,8,opt,name=value_count,json=valueCount,proto3" json:"value_count,omitempty"` + ValueType string `protobuf:"bytes,9,opt,name=value_type,json=valueType,proto3" json:"value_type,omitempty"` + PossibleChoices uint64 `protobuf:"varint,10,opt,name=possible_choices,json=possibleChoices,proto3" json:"possible_choices,omitempty"` + Duration string `protobuf:"bytes,11,opt,name=duration,proto3" json:"duration,omitempty"` +} + +func (m *MsgPollCreate) Reset() { *m = MsgPollCreate{} } +func (m *MsgPollCreate) String() string { return proto.CompactTextString(m) } +func (*MsgPollCreate) ProtoMessage() {} +func (*MsgPollCreate) Descriptor() ([]byte, []int) { + return fileDescriptor_c3fa5d41f67be42c, []int{5} +} +func (m *MsgPollCreate) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgPollCreate) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgPollCreate.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 *MsgPollCreate) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgPollCreate.Merge(m, src) +} +func (m *MsgPollCreate) XXX_Size() int { + return m.Size() +} +func (m *MsgPollCreate) XXX_DiscardUnknown() { + xxx_messageInfo_MsgPollCreate.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgPollCreate proto.InternalMessageInfo + +func init() { + proto.RegisterEnum("kira.gov.PollVoteOption", PollVoteOption_name, PollVoteOption_value) + proto.RegisterEnum("kira.gov.PollResult", PollResult_name, PollResult_value) + proto.RegisterType((*PollVote)(nil), "kira.gov.PollVote") + proto.RegisterType((*PollOptions)(nil), "kira.gov.PollOptions") + proto.RegisterType((*AddressPolls)(nil), "kira.gov.AddressPolls") + proto.RegisterType((*Poll)(nil), "kira.gov.Poll") + proto.RegisterType((*MsgPollVote)(nil), "kira.gov.MsgPollVote") + proto.RegisterType((*MsgPollCreate)(nil), "kira.gov.MsgPollCreate") +} + +func init() { proto.RegisterFile("kira/gov/poll.proto", fileDescriptor_c3fa5d41f67be42c) } + +var fileDescriptor_c3fa5d41f67be42c = []byte{ + // 1093 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x56, 0xbb, 0x6f, 0xdb, 0x46, + 0x18, 0x17, 0xf5, 0xb4, 0x4e, 0x8e, 0xcd, 0x9e, 0x95, 0x84, 0x25, 0x12, 0x89, 0x11, 0xd0, 0x42, + 0x35, 0x1a, 0xa9, 0x49, 0xd0, 0x25, 0x2d, 0x50, 0xc8, 0x32, 0x9b, 0xa8, 0xb6, 0x29, 0x85, 0x7a, + 0x18, 0x28, 0x50, 0x10, 0x34, 0x79, 0x96, 0x59, 0x51, 0x3c, 0x81, 0x77, 0x72, 0xea, 0xa9, 0x6b, + 0xa0, 0x29, 0xe8, 0x2e, 0xa0, 0x40, 0xff, 0x80, 0x8e, 0x9d, 0xb3, 0x65, 0xcc, 0xd8, 0xc9, 0x2d, + 0xec, 0xff, 0xc0, 0x63, 0xa7, 0xe2, 0xee, 0xc8, 0xc8, 0x8f, 0x24, 0x45, 0xd1, 0x0e, 0x99, 0xcc, + 0xef, 0xf1, 0xfb, 0x1e, 0xf7, 0xfd, 0xbe, 0x4f, 0x06, 0x6b, 0x23, 0x2f, 0xb4, 0xeb, 0x43, 0x7c, + 0x58, 0x9f, 0x60, 0xdf, 0xaf, 0x4d, 0x42, 0x4c, 0x31, 0x5c, 0x62, 0xca, 0xda, 0x10, 0x1f, 0xaa, + 0xc5, 0x21, 0x1e, 0x62, 0xae, 0xac, 0xb3, 0x2f, 0x61, 0x57, 0xcb, 0x43, 0x8c, 0x87, 0x3e, 0xaa, + 0x73, 0x69, 0x6f, 0xba, 0x5f, 0xa7, 0xde, 0x18, 0x11, 0x6a, 0x8f, 0x27, 0x91, 0xc3, 0x87, 0x97, + 0x1d, 0xec, 0xe0, 0x28, 0x36, 0x39, 0x98, 0x8c, 0x31, 0xb1, 0x44, 0x50, 0x21, 0x44, 0xa6, 0x45, + 0x2d, 0x21, 0xf6, 0x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 0x08, 0x41, 0x9a, 0x15, 0xcb, + 0xeb, 0xc9, 0x9b, 0xfc, 0x1b, 0x2a, 0x20, 0xe7, 0x1c, 0x60, 0xcf, 0x41, 0x44, 0x49, 0x73, 0xdf, + 0x58, 0xac, 0xfc, 0x08, 0x96, 0xa3, 0x8e, 0x58, 0x46, 0x02, 0xbf, 0x03, 0x39, 0x5b, 0xc8, 0xfc, + 0xc5, 0x96, 0x37, 0x9a, 0x67, 0xc7, 0xe5, 0x95, 0x23, 0x7b, 0xec, 0x3f, 0xac, 0x44, 0x86, 0xca, + 0xbf, 0x7f, 0xac, 0x38, 0x26, 0x94, 0x41, 0xca, 0x73, 0x89, 0x92, 0xd4, 0x52, 0xd5, 0xb4, 0xc9, + 0x3e, 0x2b, 0x2f, 0x52, 0x20, 0xcd, 0x52, 0xbf, 0x7d, 0x56, 0x5b, 0x20, 0xe7, 0x84, 0xc8, 0xa6, + 0xf8, 0x3f, 0x4c, 0x2b, 0x8e, 0xc0, 0xde, 0x8c, 0x7a, 0xd4, 0x8f, 0x9f, 0x47, 0x08, 0x50, 0x03, + 0x05, 0x17, 0x11, 0x27, 0xf4, 0xc4, 0x28, 0xd3, 0x62, 0x24, 0xe7, 0x54, 0xf0, 0x16, 0xc8, 0x87, + 0x68, 0x1f, 0x85, 0x28, 0x70, 0xe2, 0x91, 0x2d, 0x14, 0x50, 0x05, 0x4b, 0xce, 0x01, 0x72, 0x46, + 0x64, 0x3a, 0x56, 0xb2, 0xdc, 0xf8, 0x5a, 0x66, 0x19, 0x19, 0xb9, 0x89, 0x92, 0xe3, 0x4d, 0x0b, + 0x01, 0xd6, 0x41, 0x4e, 0xf0, 0x81, 0x28, 0x4b, 0x9a, 0x54, 0x2d, 0xdc, 0xbf, 0x7e, 0x91, 0x38, + 0xd1, 0xec, 0xcd, 0xd8, 0x0b, 0xee, 0x83, 0xd5, 0x43, 0x4c, 0xbd, 0x60, 0x68, 0xa1, 0xc0, 0xb5, + 0xd8, 0xfa, 0x29,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+func (m *PollVote) 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 *PollVote) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PollVote) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.CustomValue) > 0 { + i -= len(m.CustomValue) + copy(dAtA[i:], m.CustomValue) + i = encodeVarintPoll(dAtA, i, uint64(len(m.CustomValue))) + i-- + dAtA[i] = 0x2a + } + if m.Option != 0 { + i = encodeVarintPoll(dAtA, i, uint64(m.Option)) + i-- + dAtA[i] = 0x18 + } + if len(m.Voter) > 0 { + i -= len(m.Voter) + copy(dAtA[i:], m.Voter) + i = encodeVarintPoll(dAtA, i, uint64(len(m.Voter))) + i-- + dAtA[i] = 0x12 + } + if m.PollId != 0 { + i = encodeVarintPoll(dAtA, i, uint64(m.PollId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *PollOptions) 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 *PollOptions) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PollOptions) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Choices != 0 { + i = encodeVarintPoll(dAtA, i, uint64(m.Choices)) + i-- + dAtA[i] = 0x20 + } + if len(m.Type) > 0 { + i -= len(m.Type) + copy(dAtA[i:], m.Type) + i = encodeVarintPoll(dAtA, i, uint64(len(m.Type))) + i-- + dAtA[i] = 0x1a + } + if m.Count != 0 { + i = encodeVarintPoll(dAtA, i, uint64(m.Count)) + i-- + dAtA[i] = 0x10 + } + if len(m.Values) > 0 { + for iNdEx := len(m.Values) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Values[iNdEx]) + copy(dAtA[i:], m.Values[iNdEx]) + i = encodeVarintPoll(dAtA, i, uint64(len(m.Values[iNdEx]))) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *AddressPolls) 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 *AddressPolls) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *AddressPolls) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Ids) > 0 { + dAtA2 := make([]byte, len(m.Ids)*10) + var j1 int + for _, num := range m.Ids { + for num >= 1<<7 { + dAtA2[j1] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j1++ + } + dAtA2[j1] = uint8(num) + j1++ + } + i -= j1 + copy(dAtA[i:], dAtA2[:j1]) + i = encodeVarintPoll(dAtA, i, uint64(j1)) + i-- + dAtA[i] = 0x12 + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintPoll(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *Poll) 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 *Poll) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Poll) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Result != 0 { + i = encodeVarintPoll(dAtA, i, uint64(m.Result)) + i-- + dAtA[i] = 0x50 + } + n3, err3 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.VotingEndTime, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.VotingEndTime):]) + if err3 != nil { + return 0, err3 + } + i -= n3 + i = encodeVarintPoll(dAtA, i, uint64(n3)) + i-- + dAtA[i] = 0x4a + if m.Options != nil { + { + size, err := m.Options.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintPoll(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x42 + } + if len(m.Roles) > 0 { + dAtA6 := make([]byte, len(m.Roles)*10) + var j5 int + for _, num := range m.Roles { + for num >= 1<<7 { + dAtA6[j5] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j5++ + } + dAtA6[j5] = uint8(num) + j5++ + } + i -= j5 + copy(dAtA[i:], dAtA6[:j5]) + i = encodeVarintPoll(dAtA, i, uint64(j5)) + i-- + dAtA[i] = 0x3a + } + if len(m.Checksum) > 0 { + i -= len(m.Checksum) + copy(dAtA[i:], m.Checksum) + i = encodeVarintPoll(dAtA, i, uint64(len(m.Checksum))) + i-- + dAtA[i] = 0x32 + } + if len(m.Reference) > 0 { + i -= len(m.Reference) + copy(dAtA[i:], m.Reference) + i = encodeVarintPoll(dAtA, i, uint64(len(m.Reference))) + i-- + dAtA[i] = 0x2a + } + if len(m.Description) > 0 { + i -= len(m.Description) + copy(dAtA[i:], m.Description) + i = encodeVarintPoll(dAtA, i, uint64(len(m.Description))) + i-- + dAtA[i] = 0x22 + } + if len(m.Title) > 0 { + i -= len(m.Title) + copy(dAtA[i:], m.Title) + i = encodeVarintPoll(dAtA, i, uint64(len(m.Title))) + i-- + dAtA[i] = 0x1a + } + if len(m.Creator) > 0 { + i -= len(m.Creator) + copy(dAtA[i:], m.Creator) + i = encodeVarintPoll(dAtA, i, uint64(len(m.Creator))) + i-- + dAtA[i] = 0x12 + } + if m.PollId != 0 { + i = encodeVarintPoll(dAtA, i, uint64(m.PollId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *MsgPollVote) 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 *MsgPollVote) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgPollVote) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Value) > 0 { + i -= len(m.Value) + copy(dAtA[i:], m.Value) + i = encodeVarintPoll(dAtA, i, uint64(len(m.Value))) + i-- + dAtA[i] = 0x22 + } + if m.Option != 0 { + i = encodeVarintPoll(dAtA, i, uint64(m.Option)) + i-- + dAtA[i] = 0x18 + } + if len(m.Voter) > 0 { + i -= len(m.Voter) + copy(dAtA[i:], m.Voter) + i = encodeVarintPoll(dAtA, i, uint64(len(m.Voter))) + i-- + dAtA[i] = 0x12 + } + if m.PollId != 0 { + i = encodeVarintPoll(dAtA, i, uint64(m.PollId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *MsgPollCreate) 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 *MsgPollCreate) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgPollCreate) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Duration) > 0 { + i -= len(m.Duration) + copy(dAtA[i:], m.Duration) + i = encodeVarintPoll(dAtA, i, uint64(len(m.Duration))) + i-- + dAtA[i] = 0x5a + } + if m.PossibleChoices != 0 { + i = encodeVarintPoll(dAtA, i, uint64(m.PossibleChoices)) + i-- + dAtA[i] = 0x50 + } + if len(m.ValueType) > 0 { + i -= len(m.ValueType) + copy(dAtA[i:], m.ValueType) + i = encodeVarintPoll(dAtA, i, uint64(len(m.ValueType))) + i-- + dAtA[i] = 0x4a + } + if m.ValueCount != 0 { + i = encodeVarintPoll(dAtA, i, uint64(m.ValueCount)) + i-- + dAtA[i] = 0x40 + } + if len(m.PollValues) > 0 { + for iNdEx := len(m.PollValues) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.PollValues[iNdEx]) + copy(dAtA[i:], m.PollValues[iNdEx]) + i = encodeVarintPoll(dAtA, i, uint64(len(m.PollValues[iNdEx]))) + i-- + dAtA[i] = 0x3a + } + } + if len(m.Roles) > 0 { + for iNdEx := len(m.Roles) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Roles[iNdEx]) + copy(dAtA[i:], m.Roles[iNdEx]) + i = encodeVarintPoll(dAtA, i, uint64(len(m.Roles[iNdEx]))) + i-- + dAtA[i] = 0x32 + } + } + if len(m.Checksum) > 0 { + i -= len(m.Checksum) + copy(dAtA[i:], m.Checksum) + i = encodeVarintPoll(dAtA, i, uint64(len(m.Checksum))) + i-- + dAtA[i] = 0x2a + } + if len(m.Reference) > 0 { + i -= len(m.Reference) + copy(dAtA[i:], m.Reference) + i = encodeVarintPoll(dAtA, i, uint64(len(m.Reference))) + i-- + dAtA[i] = 0x22 + } + if len(m.Description) > 0 { + i -= len(m.Description) + copy(dAtA[i:], m.Description) + i = encodeVarintPoll(dAtA, i, uint64(len(m.Description))) + i-- + dAtA[i] = 0x1a + } + if len(m.Title) > 0 { + i -= len(m.Title) + copy(dAtA[i:], m.Title) + i = encodeVarintPoll(dAtA, i, uint64(len(m.Title))) + i-- + dAtA[i] = 0x12 + } + if len(m.Creator) > 0 { + i -= len(m.Creator) + copy(dAtA[i:], m.Creator) + i = encodeVarintPoll(dAtA, i, uint64(len(m.Creator))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintPoll(dAtA []byte, offset int, v uint64) int { + offset -= sovPoll(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *PollVote) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PollId != 0 { + n += 1 + sovPoll(uint64(m.PollId)) + } + l = len(m.Voter) + if l > 0 { + n += 1 + l + sovPoll(uint64(l)) + } + if m.Option != 0 { + n += 1 + sovPoll(uint64(m.Option)) + } + l = len(m.CustomValue) + if l > 0 { + n += 1 + l + sovPoll(uint64(l)) + } + return n +} + +func (m *PollOptions) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Values) > 0 { + for _, s := range m.Values { + l = len(s) + n += 1 + l + sovPoll(uint64(l)) + } + } + if m.Count != 0 { + n += 1 + sovPoll(uint64(m.Count)) + } + l = len(m.Type) + if l > 0 { + n += 1 + l + sovPoll(uint64(l)) + } + if m.Choices != 0 { + n += 1 + sovPoll(uint64(m.Choices)) + } + return n +} + +func (m *AddressPolls) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovPoll(uint64(l)) + } + if len(m.Ids) > 0 { + l = 0 + for _, e := range m.Ids { + l += sovPoll(uint64(e)) + } + n += 1 + sovPoll(uint64(l)) + l + } + return n +} + +func (m *Poll) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PollId != 0 { + n += 1 + sovPoll(uint64(m.PollId)) + } + l = len(m.Creator) + if l > 0 { + n += 1 + l + sovPoll(uint64(l)) + } + l = len(m.Title) + if l > 0 { + n += 1 + l + sovPoll(uint64(l)) + } + l = len(m.Description) + if l > 0 { + n += 1 + l + sovPoll(uint64(l)) + } + l = len(m.Reference) + if l > 0 { + n += 1 + l + sovPoll(uint64(l)) + } + l = len(m.Checksum) + if l > 0 { + n += 1 + l + sovPoll(uint64(l)) + } + if len(m.Roles) > 0 { + l = 0 + for _, e := range m.Roles { + l += sovPoll(uint64(e)) + } + n += 1 + sovPoll(uint64(l)) + l + } + if m.Options != nil { + l = m.Options.Size() + n += 1 + l + sovPoll(uint64(l)) + } + l = github_com_gogo_protobuf_types.SizeOfStdTime(m.VotingEndTime) + n += 1 + l + sovPoll(uint64(l)) + if m.Result != 0 { + n += 1 + sovPoll(uint64(m.Result)) + } + return n +} + +func (m *MsgPollVote) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PollId != 0 { + n += 1 + sovPoll(uint64(m.PollId)) + } + l = len(m.Voter) + if l > 0 { + n += 1 + l + sovPoll(uint64(l)) + } + if m.Option != 0 { + n += 1 + sovPoll(uint64(m.Option)) + } + l = len(m.Value) + if l > 0 { + n += 1 + l + sovPoll(uint64(l)) + } + return n +} + +func (m *MsgPollCreate) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Creator) + if l > 0 { + n += 1 + l + sovPoll(uint64(l)) + } + l = len(m.Title) + if l > 0 { + n += 1 + l + sovPoll(uint64(l)) + } + l = len(m.Description) + if l > 0 { + n += 1 + l + sovPoll(uint64(l)) + } + l = len(m.Reference) + if l > 0 { + n += 1 + l + sovPoll(uint64(l)) + } + l = len(m.Checksum) + if l > 0 { + n += 1 + l + sovPoll(uint64(l)) + } + if len(m.Roles) > 0 { + for _, s := range m.Roles { + l = len(s) + n += 1 + l + sovPoll(uint64(l)) + } + } + if len(m.PollValues) > 0 { + for _, s := range m.PollValues { + l = len(s) + n += 1 + l + sovPoll(uint64(l)) + } + } + if m.ValueCount != 0 { + n += 1 + sovPoll(uint64(m.ValueCount)) + } + l = len(m.ValueType) + if l > 0 { + n += 1 + l + sovPoll(uint64(l)) + } + if m.PossibleChoices != 0 { + n += 1 + sovPoll(uint64(m.PossibleChoices)) + } + l = len(m.Duration) + if l > 0 { + n += 1 + l + sovPoll(uint64(l)) + } + return n +} + +func sovPoll(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozPoll(x uint64) (n int) { + return sovPoll(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *PollVote) 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 ErrIntOverflowPoll + } + 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: PollVote: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PollVote: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PollId", wireType) + } + m.PollId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPoll + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PollId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Voter", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPoll + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthPoll + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthPoll + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Voter = append(m.Voter[:0], dAtA[iNdEx:postIndex]...) + if m.Voter == nil { + m.Voter = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Option", wireType) + } + m.Option = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPoll + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Option |= PollVoteOption(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CustomValue", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPoll + } + 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 ErrInvalidLengthPoll + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPoll + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.CustomValue = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipPoll(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthPoll + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *PollOptions) 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 ErrIntOverflowPoll + } + 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: PollOptions: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PollOptions: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Values", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPoll + } + 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 ErrInvalidLengthPoll + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPoll + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Values = append(m.Values, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Count", wireType) + } + m.Count = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPoll + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Count |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Type", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPoll + } + 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 ErrInvalidLengthPoll + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPoll + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Type = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Choices", wireType) + } + m.Choices = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPoll + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Choices |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipPoll(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthPoll + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *AddressPolls) 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 ErrIntOverflowPoll + } + 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: AddressPolls: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: AddressPolls: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPoll + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthPoll + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthPoll + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = append(m.Address[:0], dAtA[iNdEx:postIndex]...) + if m.Address == nil { + m.Address = []byte{} + } + iNdEx = postIndex + case 2: + if wireType == 0 { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPoll + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Ids = append(m.Ids, v) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPoll + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return ErrInvalidLengthPoll + } + postIndex := iNdEx + packedLen + if postIndex < 0 { + return ErrInvalidLengthPoll + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var elementCount int + var count int + for _, integer := range dAtA[iNdEx:postIndex] { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Ids) == 0 { + m.Ids = make([]uint64, 0, elementCount) + } + for iNdEx < postIndex { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPoll + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Ids = append(m.Ids, v) + } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field Ids", wireType) + } + default: + iNdEx = preIndex + skippy, err := skipPoll(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthPoll + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Poll) 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 ErrIntOverflowPoll + } + 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: Poll: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Poll: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PollId", wireType) + } + m.PollId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPoll + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PollId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPoll + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthPoll + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthPoll + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Creator = append(m.Creator[:0], dAtA[iNdEx:postIndex]...) + if m.Creator == nil { + m.Creator = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Title", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPoll + } + 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 ErrInvalidLengthPoll + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPoll + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Title = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPoll + } + 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 ErrInvalidLengthPoll + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPoll + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Description = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Reference", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPoll + } + 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 ErrInvalidLengthPoll + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPoll + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Reference = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Checksum", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPoll + } + 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 ErrInvalidLengthPoll + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPoll + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Checksum = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 7: + if wireType == 0 { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPoll + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Roles = append(m.Roles, v) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPoll + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return ErrInvalidLengthPoll + } + postIndex := iNdEx + packedLen + if postIndex < 0 { + return ErrInvalidLengthPoll + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var elementCount int + var count int + for _, integer := range dAtA[iNdEx:postIndex] { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Roles) == 0 { + m.Roles = make([]uint64, 0, elementCount) + } + for iNdEx < postIndex { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPoll + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Roles = append(m.Roles, v) + } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field Roles", wireType) + } + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Options", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPoll + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthPoll + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthPoll + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Options == nil { + m.Options = &PollOptions{} + } + if err := m.Options.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 9: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field VotingEndTime", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPoll + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthPoll + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthPoll + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_gogo_protobuf_types.StdTimeUnmarshal(&m.VotingEndTime, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 10: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Result", wireType) + } + m.Result = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPoll + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Result |= PollResult(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipPoll(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthPoll + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgPollVote) 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 ErrIntOverflowPoll + } + 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: MsgPollVote: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgPollVote: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PollId", wireType) + } + m.PollId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPoll + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PollId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Voter", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPoll + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthPoll + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthPoll + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Voter = append(m.Voter[:0], dAtA[iNdEx:postIndex]...) + if m.Voter == nil { + m.Voter = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Option", wireType) + } + m.Option = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPoll + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Option |= PollVoteOption(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPoll + } + 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 ErrInvalidLengthPoll + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPoll + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Value = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipPoll(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthPoll + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgPollCreate) 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 ErrIntOverflowPoll + } + 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: MsgPollCreate: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgPollCreate: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPoll + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthPoll + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthPoll + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Creator = append(m.Creator[:0], dAtA[iNdEx:postIndex]...) + if m.Creator == nil { + m.Creator = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Title", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPoll + } + 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 ErrInvalidLengthPoll + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPoll + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Title = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPoll + } + 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 ErrInvalidLengthPoll + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPoll + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Description = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Reference", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPoll + } + 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 ErrInvalidLengthPoll + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPoll + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Reference = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Checksum", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPoll + } + 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 ErrInvalidLengthPoll + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPoll + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Checksum = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Roles", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPoll + } + 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 ErrInvalidLengthPoll + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPoll + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Roles = append(m.Roles, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PollValues", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPoll + } + 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 ErrInvalidLengthPoll + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPoll + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PollValues = append(m.PollValues, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 8: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ValueCount", wireType) + } + m.ValueCount = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPoll + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ValueCount |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 9: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ValueType", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPoll + } + 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 ErrInvalidLengthPoll + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPoll + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ValueType = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 10: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PossibleChoices", wireType) + } + m.PossibleChoices = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPoll + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PossibleChoices |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 11: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Duration", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPoll + } + 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 ErrInvalidLengthPoll + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPoll + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Duration = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipPoll(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthPoll + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipPoll(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, ErrIntOverflowPoll + } + 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, ErrIntOverflowPoll + } + 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, ErrIntOverflowPoll + } + 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, ErrInvalidLengthPoll + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupPoll + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthPoll + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthPoll = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowPoll = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupPoll = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/gov/types/poll_vote.go b/x/gov/types/poll_vote.go new file mode 100644 index 000000000..32d8e56b2 --- /dev/null +++ b/x/gov/types/poll_vote.go @@ -0,0 +1,57 @@ +package types + +type PollVotes []PollVote + +type CalculatedPollVotes struct { + votes map[PollVoteOption]uint64 + actorsWithVeto uint64 + total uint64 +} + +func CalculatePollVotes(votes PollVotes, actorsWithVeto uint64) CalculatedPollVotes { + votesMap := make(map[PollVoteOption]uint64) + for _, vote := range votes { + votesMap[vote.Option]++ + } + + return CalculatedPollVotes{ + total: uint64(len(votes)), + actorsWithVeto: actorsWithVeto, + votes: votesMap, + } +} + +func (c CalculatedPollVotes) TotalVotes() uint64 { + return c.total +} + +func (c CalculatedPollVotes) AbstainVotes() uint64 { + return c.votes[PollOptionAbstain] +} + +func (c CalculatedPollVotes) VetoVotes() uint64 { + return c.votes[PollOptionNoWithVeto] +} + +func (c CalculatedPollVotes) ProcessResult() PollResult { + if c.actorsWithVeto != 0 { + percentageActorsWithVeto := (float32(c.votes[PollOptionNoWithVeto]) / float32(c.actorsWithVeto)) * 100 + if percentageActorsWithVeto >= 50 { + return PollRejectedWithVeto + } + } + + yesPercentage := (float32(c.votes[PollOptionCustom]) / float32(c.total)) * 100 + if yesPercentage > 50.00 { + return PollPassed + } + + sumOtherThanYes := c.votes[PollOptionAbstain] + c.votes[PollOptionNoWithVeto] + sumPercentage := (float32(sumOtherThanYes) / float32(c.total)) * 100 + + if sumPercentage >= 50 { + return PollRejected + } + + return PollUnknown +} diff --git a/x/gov/types/proposal.go b/x/gov/types/proposal.go index edd4d74ea..be842dc54 100644 --- a/x/gov/types/proposal.go +++ b/x/gov/types/proposal.go @@ -327,7 +327,12 @@ func (m *SetNetworkPropertyProposal) ValidateBasic() error { MinCollectiveBond, MinCollectiveBondingTime, MaxCollectiveOutputs, - MinCollectiveClaimPeriod: + MinCollectiveClaimPeriod, + ValidatorRecoveryBond, + MaxAnnualInflation, + MinDappBond, + MaxDappBond, + DappBondDuration: return nil default: return ErrInvalidNetworkProperty diff --git a/x/gov/types/proposal_test.go b/x/gov/types/proposal_test.go index c2dad9202..55e5030ae 100644 --- a/x/gov/types/proposal_test.go +++ b/x/gov/types/proposal_test.go @@ -1,29 +1,29 @@ -package types - -import ( - "testing" - "time" - - "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/require" -) - -func TestNewProposal_ProposalIsPendingByDefault(t *testing.T) { - proposal, err := NewProposal( - 1234, - "title", - "some desc", - NewWhitelistAccountPermissionProposal( - types.AccAddress{0x12}, - PermSetPermissions, - ), - time.Now(), - time.Now(), - time.Now(), - 2, - 3, - ) - - require.NoError(t, err) - require.Equal(t, Pending, proposal.Result) -} +package types + +import ( + "testing" + "time" + + "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" +) + +func TestNewProposal_ProposalIsPendingByDefault(t *testing.T) { + proposal, err := NewProposal( + 1234, + "title", + "some desc", + NewWhitelistAccountPermissionProposal( + types.AccAddress{0x12}, + PermSetPermissions, + ), + time.Now(), + time.Now(), + time.Now(), + 2, + 3, + ) + + require.NoError(t, err) + require.Equal(t, Pending, proposal.Result) +} diff --git a/x/gov/types/query.pb.go b/x/gov/types/query.pb.go index 5c681c24c..f3bd9c514 100644 --- a/x/gov/types/query.pb.go +++ b/x/gov/types/query.pb.go @@ -32,6 +32,182 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package +type QueryPollsVotesByPollId struct { + PollId uint64 `protobuf:"varint,1,opt,name=poll_id,json=pollId,proto3" json:"poll_id,omitempty"` +} + +func (m *QueryPollsVotesByPollId) Reset() { *m = QueryPollsVotesByPollId{} } +func (m *QueryPollsVotesByPollId) String() string { return proto.CompactTextString(m) } +func (*QueryPollsVotesByPollId) ProtoMessage() {} +func (*QueryPollsVotesByPollId) Descriptor() ([]byte, []int) { + return fileDescriptor_bcca1063f62efc95, []int{0} +} +func (m *QueryPollsVotesByPollId) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryPollsVotesByPollId) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryPollsVotesByPollId.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 *QueryPollsVotesByPollId) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryPollsVotesByPollId.Merge(m, src) +} +func (m *QueryPollsVotesByPollId) XXX_Size() int { + return m.Size() +} +func (m *QueryPollsVotesByPollId) XXX_DiscardUnknown() { + xxx_messageInfo_QueryPollsVotesByPollId.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryPollsVotesByPollId proto.InternalMessageInfo + +func (m *QueryPollsVotesByPollId) GetPollId() uint64 { + if m != nil { + return m.PollId + } + return 0 +} + +type QueryPollsVotesByPollIdResponse struct { + Votes []PollVote `protobuf:"bytes,1,rep,name=votes,proto3" json:"votes"` +} + +func (m *QueryPollsVotesByPollIdResponse) Reset() { *m = QueryPollsVotesByPollIdResponse{} } +func (m *QueryPollsVotesByPollIdResponse) String() string { return proto.CompactTextString(m) } +func (*QueryPollsVotesByPollIdResponse) ProtoMessage() {} +func (*QueryPollsVotesByPollIdResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_bcca1063f62efc95, []int{1} +} +func (m *QueryPollsVotesByPollIdResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryPollsVotesByPollIdResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryPollsVotesByPollIdResponse.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 *QueryPollsVotesByPollIdResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryPollsVotesByPollIdResponse.Merge(m, src) +} +func (m *QueryPollsVotesByPollIdResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryPollsVotesByPollIdResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryPollsVotesByPollIdResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryPollsVotesByPollIdResponse proto.InternalMessageInfo + +func (m *QueryPollsVotesByPollIdResponse) GetVotes() []PollVote { + if m != nil { + return m.Votes + } + return nil +} + +type QueryPollsListByAddress struct { + Creator github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,1,opt,name=creator,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"creator,omitempty" yaml:"creator"` +} + +func (m *QueryPollsListByAddress) Reset() { *m = QueryPollsListByAddress{} } +func (m *QueryPollsListByAddress) String() string { return proto.CompactTextString(m) } +func (*QueryPollsListByAddress) ProtoMessage() {} +func (*QueryPollsListByAddress) Descriptor() ([]byte, []int) { + return fileDescriptor_bcca1063f62efc95, []int{2} +} +func (m *QueryPollsListByAddress) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryPollsListByAddress) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryPollsListByAddress.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 *QueryPollsListByAddress) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryPollsListByAddress.Merge(m, src) +} +func (m *QueryPollsListByAddress) XXX_Size() int { + return m.Size() +} +func (m *QueryPollsListByAddress) XXX_DiscardUnknown() { + xxx_messageInfo_QueryPollsListByAddress.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryPollsListByAddress proto.InternalMessageInfo + +func (m *QueryPollsListByAddress) GetCreator() github_com_cosmos_cosmos_sdk_types.AccAddress { + if m != nil { + return m.Creator + } + return nil +} + +type QueryPollsListByAddressResponse struct { + Polls []Poll `protobuf:"bytes,1,rep,name=polls,proto3" json:"polls"` +} + +func (m *QueryPollsListByAddressResponse) Reset() { *m = QueryPollsListByAddressResponse{} } +func (m *QueryPollsListByAddressResponse) String() string { return proto.CompactTextString(m) } +func (*QueryPollsListByAddressResponse) ProtoMessage() {} +func (*QueryPollsListByAddressResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_bcca1063f62efc95, []int{3} +} +func (m *QueryPollsListByAddressResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryPollsListByAddressResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryPollsListByAddressResponse.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 *QueryPollsListByAddressResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryPollsListByAddressResponse.Merge(m, src) +} +func (m *QueryPollsListByAddressResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryPollsListByAddressResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryPollsListByAddressResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryPollsListByAddressResponse proto.InternalMessageInfo + +func (m *QueryPollsListByAddressResponse) GetPolls() []Poll { + if m != nil { + return m.Polls + } + return nil +} + type NetworkPropertiesRequest struct { } @@ -39,7 +215,7 @@ func (m *NetworkPropertiesRequest) Reset() { *m = NetworkPropertiesReque func (m *NetworkPropertiesRequest) String() string { return proto.CompactTextString(m) } func (*NetworkPropertiesRequest) ProtoMessage() {} func (*NetworkPropertiesRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_bcca1063f62efc95, []int{0} + return fileDescriptor_bcca1063f62efc95, []int{4} } func (m *NetworkPropertiesRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -76,7 +252,7 @@ func (m *NetworkPropertiesResponse) Reset() { *m = NetworkPropertiesResp func (m *NetworkPropertiesResponse) String() string { return proto.CompactTextString(m) } func (*NetworkPropertiesResponse) ProtoMessage() {} func (*NetworkPropertiesResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_bcca1063f62efc95, []int{1} + return fileDescriptor_bcca1063f62efc95, []int{5} } func (m *NetworkPropertiesResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -120,7 +296,7 @@ func (m *PermissionsByAddressRequest) Reset() { *m = PermissionsByAddres func (m *PermissionsByAddressRequest) String() string { return proto.CompactTextString(m) } func (*PermissionsByAddressRequest) ProtoMessage() {} func (*PermissionsByAddressRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_bcca1063f62efc95, []int{2} + return fileDescriptor_bcca1063f62efc95, []int{6} } func (m *PermissionsByAddressRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -164,7 +340,7 @@ func (m *PermissionsResponse) Reset() { *m = PermissionsResponse{} } func (m *PermissionsResponse) String() string { return proto.CompactTextString(m) } func (*PermissionsResponse) ProtoMessage() {} func (*PermissionsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_bcca1063f62efc95, []int{3} + return fileDescriptor_bcca1063f62efc95, []int{7} } func (m *PermissionsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -211,7 +387,7 @@ func (m *RoleQuery) Reset() { *m = RoleQuery{} } func (m *RoleQuery) String() string { return proto.CompactTextString(m) } func (*RoleQuery) ProtoMessage() {} func (*RoleQuery) Descriptor() ([]byte, []int) { - return fileDescriptor_bcca1063f62efc95, []int{4} + return fileDescriptor_bcca1063f62efc95, []int{8} } func (m *RoleQuery) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -275,7 +451,7 @@ func (m *AllRolesRequest) Reset() { *m = AllRolesRequest{} } func (m *AllRolesRequest) String() string { return proto.CompactTextString(m) } func (*AllRolesRequest) ProtoMessage() {} func (*AllRolesRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_bcca1063f62efc95, []int{5} + return fileDescriptor_bcca1063f62efc95, []int{9} } func (m *AllRolesRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -312,7 +488,7 @@ func (m *AllRolesResponse) Reset() { *m = AllRolesResponse{} } func (m *AllRolesResponse) String() string { return proto.CompactTextString(m) } func (*AllRolesResponse) ProtoMessage() {} func (*AllRolesResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_bcca1063f62efc95, []int{6} + return fileDescriptor_bcca1063f62efc95, []int{10} } func (m *AllRolesResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -356,7 +532,7 @@ func (m *RolesByAddressRequest) Reset() { *m = RolesByAddressRequest{} } func (m *RolesByAddressRequest) String() string { return proto.CompactTextString(m) } func (*RolesByAddressRequest) ProtoMessage() {} func (*RolesByAddressRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_bcca1063f62efc95, []int{7} + return fileDescriptor_bcca1063f62efc95, []int{11} } func (m *RolesByAddressRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -400,7 +576,7 @@ func (m *RolesByAddressResponse) Reset() { *m = RolesByAddressResponse{} func (m *RolesByAddressResponse) String() string { return proto.CompactTextString(m) } func (*RolesByAddressResponse) ProtoMessage() {} func (*RolesByAddressResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_bcca1063f62efc95, []int{8} + return fileDescriptor_bcca1063f62efc95, []int{12} } func (m *RolesByAddressResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -444,7 +620,7 @@ func (m *RoleRequest) Reset() { *m = RoleRequest{} } func (m *RoleRequest) String() string { return proto.CompactTextString(m) } func (*RoleRequest) ProtoMessage() {} func (*RoleRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_bcca1063f62efc95, []int{9} + return fileDescriptor_bcca1063f62efc95, []int{13} } func (m *RoleRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -488,7 +664,7 @@ func (m *RoleResponse) Reset() { *m = RoleResponse{} } func (m *RoleResponse) String() string { return proto.CompactTextString(m) } func (*RoleResponse) ProtoMessage() {} func (*RoleResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_bcca1063f62efc95, []int{10} + return fileDescriptor_bcca1063f62efc95, []int{14} } func (m *RoleResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -532,7 +708,7 @@ func (m *ExecutionFeeRequest) Reset() { *m = ExecutionFeeRequest{} } func (m *ExecutionFeeRequest) String() string { return proto.CompactTextString(m) } func (*ExecutionFeeRequest) ProtoMessage() {} func (*ExecutionFeeRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_bcca1063f62efc95, []int{11} + return fileDescriptor_bcca1063f62efc95, []int{15} } func (m *ExecutionFeeRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -576,7 +752,7 @@ func (m *ExecutionFeeResponse) Reset() { *m = ExecutionFeeResponse{} } func (m *ExecutionFeeResponse) String() string { return proto.CompactTextString(m) } func (*ExecutionFeeResponse) ProtoMessage() {} func (*ExecutionFeeResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_bcca1063f62efc95, []int{12} + return fileDescriptor_bcca1063f62efc95, []int{16} } func (m *ExecutionFeeResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -619,7 +795,7 @@ func (m *AllExecutionFeesRequest) Reset() { *m = AllExecutionFeesRequest func (m *AllExecutionFeesRequest) String() string { return proto.CompactTextString(m) } func (*AllExecutionFeesRequest) ProtoMessage() {} func (*AllExecutionFeesRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_bcca1063f62efc95, []int{13} + return fileDescriptor_bcca1063f62efc95, []int{17} } func (m *AllExecutionFeesRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -657,7 +833,7 @@ func (m *AllExecutionFeesResponse) Reset() { *m = AllExecutionFeesRespon func (m *AllExecutionFeesResponse) String() string { return proto.CompactTextString(m) } func (*AllExecutionFeesResponse) ProtoMessage() {} func (*AllExecutionFeesResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_bcca1063f62efc95, []int{14} + return fileDescriptor_bcca1063f62efc95, []int{18} } func (m *AllExecutionFeesResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -707,7 +883,7 @@ func (m *PoorNetworkMessagesRequest) Reset() { *m = PoorNetworkMessagesR func (m *PoorNetworkMessagesRequest) String() string { return proto.CompactTextString(m) } func (*PoorNetworkMessagesRequest) ProtoMessage() {} func (*PoorNetworkMessagesRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_bcca1063f62efc95, []int{15} + return fileDescriptor_bcca1063f62efc95, []int{19} } func (m *PoorNetworkMessagesRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -744,7 +920,7 @@ func (m *PoorNetworkMessagesResponse) Reset() { *m = PoorNetworkMessages func (m *PoorNetworkMessagesResponse) String() string { return proto.CompactTextString(m) } func (*PoorNetworkMessagesResponse) ProtoMessage() {} func (*PoorNetworkMessagesResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_bcca1063f62efc95, []int{16} + return fileDescriptor_bcca1063f62efc95, []int{20} } func (m *PoorNetworkMessagesResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -788,7 +964,7 @@ func (m *CouncilorByAddressRequest) Reset() { *m = CouncilorByAddressReq func (m *CouncilorByAddressRequest) String() string { return proto.CompactTextString(m) } func (*CouncilorByAddressRequest) ProtoMessage() {} func (*CouncilorByAddressRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_bcca1063f62efc95, []int{17} + return fileDescriptor_bcca1063f62efc95, []int{21} } func (m *CouncilorByAddressRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -832,7 +1008,7 @@ func (m *CouncilorByMonikerRequest) Reset() { *m = CouncilorByMonikerReq func (m *CouncilorByMonikerRequest) String() string { return proto.CompactTextString(m) } func (*CouncilorByMonikerRequest) ProtoMessage() {} func (*CouncilorByMonikerRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_bcca1063f62efc95, []int{18} + return fileDescriptor_bcca1063f62efc95, []int{22} } func (m *CouncilorByMonikerRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -876,7 +1052,7 @@ func (m *CouncilorResponse) Reset() { *m = CouncilorResponse{} } func (m *CouncilorResponse) String() string { return proto.CompactTextString(m) } func (*CouncilorResponse) ProtoMessage() {} func (*CouncilorResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_bcca1063f62efc95, []int{19} + return fileDescriptor_bcca1063f62efc95, []int{23} } func (m *CouncilorResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -922,7 +1098,7 @@ func (m *QueryProposalRequest) Reset() { *m = QueryProposalRequest{} } func (m *QueryProposalRequest) String() string { return proto.CompactTextString(m) } func (*QueryProposalRequest) ProtoMessage() {} func (*QueryProposalRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_bcca1063f62efc95, []int{20} + return fileDescriptor_bcca1063f62efc95, []int{24} } func (m *QueryProposalRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -968,7 +1144,7 @@ func (m *QueryProposalResponse) Reset() { *m = QueryProposalResponse{} } func (m *QueryProposalResponse) String() string { return proto.CompactTextString(m) } func (*QueryProposalResponse) ProtoMessage() {} func (*QueryProposalResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_bcca1063f62efc95, []int{21} + return fileDescriptor_bcca1063f62efc95, []int{25} } func (m *QueryProposalResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1022,7 +1198,7 @@ func (m *QueryProposalsRequest) Reset() { *m = QueryProposalsRequest{} } func (m *QueryProposalsRequest) String() string { return proto.CompactTextString(m) } func (*QueryProposalsRequest) ProtoMessage() {} func (*QueryProposalsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_bcca1063f62efc95, []int{22} + return fileDescriptor_bcca1063f62efc95, []int{26} } func (m *QueryProposalsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1062,7 +1238,7 @@ func (m *QueryProposalsResponse) Reset() { *m = QueryProposalsResponse{} func (m *QueryProposalsResponse) String() string { return proto.CompactTextString(m) } func (*QueryProposalsResponse) ProtoMessage() {} func (*QueryProposalsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_bcca1063f62efc95, []int{23} + return fileDescriptor_bcca1063f62efc95, []int{27} } func (m *QueryProposalsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1115,7 +1291,7 @@ func (m *QueryWhitelistedProposalVotersRequest) Reset() { *m = QueryWhit func (m *QueryWhitelistedProposalVotersRequest) String() string { return proto.CompactTextString(m) } func (*QueryWhitelistedProposalVotersRequest) ProtoMessage() {} func (*QueryWhitelistedProposalVotersRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_bcca1063f62efc95, []int{24} + return fileDescriptor_bcca1063f62efc95, []int{28} } func (m *QueryWhitelistedProposalVotersRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1162,7 +1338,7 @@ func (m *QueryWhitelistedProposalVotersResponse) Reset() { func (m *QueryWhitelistedProposalVotersResponse) String() string { return proto.CompactTextString(m) } func (*QueryWhitelistedProposalVotersResponse) ProtoMessage() {} func (*QueryWhitelistedProposalVotersResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_bcca1063f62efc95, []int{25} + return fileDescriptor_bcca1063f62efc95, []int{29} } func (m *QueryWhitelistedProposalVotersResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1206,7 +1382,7 @@ func (m *QueryProposerVotersCountRequest) Reset() { *m = QueryProposerVo func (m *QueryProposerVotersCountRequest) String() string { return proto.CompactTextString(m) } func (*QueryProposerVotersCountRequest) ProtoMessage() {} func (*QueryProposerVotersCountRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_bcca1063f62efc95, []int{26} + return fileDescriptor_bcca1063f62efc95, []int{30} } func (m *QueryProposerVotersCountRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1245,7 +1421,7 @@ func (m *QueryProposerVotersCountResponse) Reset() { *m = QueryProposerV func (m *QueryProposerVotersCountResponse) String() string { return proto.CompactTextString(m) } func (*QueryProposerVotersCountResponse) ProtoMessage() {} func (*QueryProposerVotersCountResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_bcca1063f62efc95, []int{27} + return fileDescriptor_bcca1063f62efc95, []int{31} } func (m *QueryProposerVotersCountResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1300,7 +1476,7 @@ func (m *QueryVoteRequest) Reset() { *m = QueryVoteRequest{} } func (m *QueryVoteRequest) String() string { return proto.CompactTextString(m) } func (*QueryVoteRequest) ProtoMessage() {} func (*QueryVoteRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_bcca1063f62efc95, []int{28} + return fileDescriptor_bcca1063f62efc95, []int{32} } func (m *QueryVoteRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1339,7 +1515,7 @@ func (m *QueryVoteResponse) Reset() { *m = QueryVoteResponse{} } func (m *QueryVoteResponse) String() string { return proto.CompactTextString(m) } func (*QueryVoteResponse) ProtoMessage() {} func (*QueryVoteResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_bcca1063f62efc95, []int{29} + return fileDescriptor_bcca1063f62efc95, []int{33} } func (m *QueryVoteResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1385,7 +1561,7 @@ func (m *QueryVotesRequest) Reset() { *m = QueryVotesRequest{} } func (m *QueryVotesRequest) String() string { return proto.CompactTextString(m) } func (*QueryVotesRequest) ProtoMessage() {} func (*QueryVotesRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_bcca1063f62efc95, []int{30} + return fileDescriptor_bcca1063f62efc95, []int{34} } func (m *QueryVotesRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1431,7 +1607,7 @@ func (m *QueryVotesResponse) Reset() { *m = QueryVotesResponse{} } func (m *QueryVotesResponse) String() string { return proto.CompactTextString(m) } func (*QueryVotesResponse) ProtoMessage() {} func (*QueryVotesResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_bcca1063f62efc95, []int{31} + return fileDescriptor_bcca1063f62efc95, []int{35} } func (m *QueryVotesResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1476,7 +1652,7 @@ func (m *QueryDataReferenceKeysRequest) Reset() { *m = QueryDataReferenc func (m *QueryDataReferenceKeysRequest) String() string { return proto.CompactTextString(m) } func (*QueryDataReferenceKeysRequest) ProtoMessage() {} func (*QueryDataReferenceKeysRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_bcca1063f62efc95, []int{32} + return fileDescriptor_bcca1063f62efc95, []int{36} } func (m *QueryDataReferenceKeysRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1522,7 +1698,7 @@ func (m *QueryDataReferenceKeysResponse) Reset() { *m = QueryDataReferen func (m *QueryDataReferenceKeysResponse) String() string { return proto.CompactTextString(m) } func (*QueryDataReferenceKeysResponse) ProtoMessage() {} func (*QueryDataReferenceKeysResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_bcca1063f62efc95, []int{33} + return fileDescriptor_bcca1063f62efc95, []int{37} } func (m *QueryDataReferenceKeysResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1574,7 +1750,7 @@ func (m *QueryDataReferenceRequest) Reset() { *m = QueryDataReferenceReq func (m *QueryDataReferenceRequest) String() string { return proto.CompactTextString(m) } func (*QueryDataReferenceRequest) ProtoMessage() {} func (*QueryDataReferenceRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_bcca1063f62efc95, []int{34} + return fileDescriptor_bcca1063f62efc95, []int{38} } func (m *QueryDataReferenceRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1619,7 +1795,7 @@ func (m *QueryDataReferenceResponse) Reset() { *m = QueryDataReferenceRe func (m *QueryDataReferenceResponse) String() string { return proto.CompactTextString(m) } func (*QueryDataReferenceResponse) ProtoMessage() {} func (*QueryDataReferenceResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_bcca1063f62efc95, []int{35} + return fileDescriptor_bcca1063f62efc95, []int{39} } func (m *QueryDataReferenceResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1663,7 +1839,7 @@ func (m *QueryIdentityRecordRequest) Reset() { *m = QueryIdentityRecordR func (m *QueryIdentityRecordRequest) String() string { return proto.CompactTextString(m) } func (*QueryIdentityRecordRequest) ProtoMessage() {} func (*QueryIdentityRecordRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_bcca1063f62efc95, []int{36} + return fileDescriptor_bcca1063f62efc95, []int{40} } func (m *QueryIdentityRecordRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1707,7 +1883,7 @@ func (m *QueryIdentityRecordResponse) Reset() { *m = QueryIdentityRecord func (m *QueryIdentityRecordResponse) String() string { return proto.CompactTextString(m) } func (*QueryIdentityRecordResponse) ProtoMessage() {} func (*QueryIdentityRecordResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_bcca1063f62efc95, []int{37} + return fileDescriptor_bcca1063f62efc95, []int{41} } func (m *QueryIdentityRecordResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1752,7 +1928,7 @@ func (m *QueryIdentityRecordsByAddressRequest) Reset() { *m = QueryIdent func (m *QueryIdentityRecordsByAddressRequest) String() string { return proto.CompactTextString(m) } func (*QueryIdentityRecordsByAddressRequest) ProtoMessage() {} func (*QueryIdentityRecordsByAddressRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_bcca1063f62efc95, []int{38} + return fileDescriptor_bcca1063f62efc95, []int{42} } func (m *QueryIdentityRecordsByAddressRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1803,7 +1979,7 @@ func (m *QueryIdentityRecordsByAddressResponse) Reset() { *m = QueryIden func (m *QueryIdentityRecordsByAddressResponse) String() string { return proto.CompactTextString(m) } func (*QueryIdentityRecordsByAddressResponse) ProtoMessage() {} func (*QueryIdentityRecordsByAddressResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_bcca1063f62efc95, []int{39} + return fileDescriptor_bcca1063f62efc95, []int{43} } func (m *QueryIdentityRecordsByAddressResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1847,7 +2023,7 @@ func (m *QueryAllIdentityRecordsRequest) Reset() { *m = QueryAllIdentity func (m *QueryAllIdentityRecordsRequest) String() string { return proto.CompactTextString(m) } func (*QueryAllIdentityRecordsRequest) ProtoMessage() {} func (*QueryAllIdentityRecordsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_bcca1063f62efc95, []int{40} + return fileDescriptor_bcca1063f62efc95, []int{44} } func (m *QueryAllIdentityRecordsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1892,7 +2068,7 @@ func (m *QueryAllIdentityRecordsResponse) Reset() { *m = QueryAllIdentit func (m *QueryAllIdentityRecordsResponse) String() string { return proto.CompactTextString(m) } func (*QueryAllIdentityRecordsResponse) ProtoMessage() {} func (*QueryAllIdentityRecordsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_bcca1063f62efc95, []int{41} + return fileDescriptor_bcca1063f62efc95, []int{45} } func (m *QueryAllIdentityRecordsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1943,7 +2119,7 @@ func (m *QueryIdentityVerifyRecordRequest) Reset() { *m = QueryIdentityV func (m *QueryIdentityVerifyRecordRequest) String() string { return proto.CompactTextString(m) } func (*QueryIdentityVerifyRecordRequest) ProtoMessage() {} func (*QueryIdentityVerifyRecordRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_bcca1063f62efc95, []int{42} + return fileDescriptor_bcca1063f62efc95, []int{46} } func (m *QueryIdentityVerifyRecordRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1987,7 +2163,7 @@ func (m *QueryIdentityVerifyRecordResponse) Reset() { *m = QueryIdentity func (m *QueryIdentityVerifyRecordResponse) String() string { return proto.CompactTextString(m) } func (*QueryIdentityVerifyRecordResponse) ProtoMessage() {} func (*QueryIdentityVerifyRecordResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_bcca1063f62efc95, []int{43} + return fileDescriptor_bcca1063f62efc95, []int{47} } func (m *QueryIdentityVerifyRecordResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2036,7 +2212,7 @@ func (m *QueryIdentityRecordVerifyRequestsByApprover) String() string { } func (*QueryIdentityRecordVerifyRequestsByApprover) ProtoMessage() {} func (*QueryIdentityRecordVerifyRequestsByApprover) Descriptor() ([]byte, []int) { - return fileDescriptor_bcca1063f62efc95, []int{44} + return fileDescriptor_bcca1063f62efc95, []int{48} } func (m *QueryIdentityRecordVerifyRequestsByApprover) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2092,7 +2268,7 @@ func (m *QueryIdentityRecordVerifyRequestsByApproverResponse) String() string { } func (*QueryIdentityRecordVerifyRequestsByApproverResponse) ProtoMessage() {} func (*QueryIdentityRecordVerifyRequestsByApproverResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_bcca1063f62efc95, []int{45} + return fileDescriptor_bcca1063f62efc95, []int{49} } func (m *QueryIdentityRecordVerifyRequestsByApproverResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2148,7 +2324,7 @@ func (m *QueryIdentityRecordVerifyRequestsByRequester) String() string { } func (*QueryIdentityRecordVerifyRequestsByRequester) ProtoMessage() {} func (*QueryIdentityRecordVerifyRequestsByRequester) Descriptor() ([]byte, []int) { - return fileDescriptor_bcca1063f62efc95, []int{46} + return fileDescriptor_bcca1063f62efc95, []int{50} } func (m *QueryIdentityRecordVerifyRequestsByRequester) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2204,7 +2380,7 @@ func (m *QueryIdentityRecordVerifyRequestsByRequesterResponse) String() string { } func (*QueryIdentityRecordVerifyRequestsByRequesterResponse) ProtoMessage() {} func (*QueryIdentityRecordVerifyRequestsByRequesterResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_bcca1063f62efc95, []int{47} + return fileDescriptor_bcca1063f62efc95, []int{51} } func (m *QueryIdentityRecordVerifyRequestsByRequesterResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2255,7 +2431,7 @@ func (m *QueryAllIdentityRecordVerifyRequests) Reset() { *m = QueryAllId func (m *QueryAllIdentityRecordVerifyRequests) String() string { return proto.CompactTextString(m) } func (*QueryAllIdentityRecordVerifyRequests) ProtoMessage() {} func (*QueryAllIdentityRecordVerifyRequests) Descriptor() ([]byte, []int) { - return fileDescriptor_bcca1063f62efc95, []int{48} + return fileDescriptor_bcca1063f62efc95, []int{52} } func (m *QueryAllIdentityRecordVerifyRequests) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2304,7 +2480,7 @@ func (m *QueryAllIdentityRecordVerifyRequestsResponse) String() string { } func (*QueryAllIdentityRecordVerifyRequestsResponse) ProtoMessage() {} func (*QueryAllIdentityRecordVerifyRequestsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_bcca1063f62efc95, []int{49} + return fileDescriptor_bcca1063f62efc95, []int{53} } func (m *QueryAllIdentityRecordVerifyRequestsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2354,7 +2530,7 @@ func (m *QueryAllProposalDurations) Reset() { *m = QueryAllProposalDurat func (m *QueryAllProposalDurations) String() string { return proto.CompactTextString(m) } func (*QueryAllProposalDurations) ProtoMessage() {} func (*QueryAllProposalDurations) Descriptor() ([]byte, []int) { - return fileDescriptor_bcca1063f62efc95, []int{50} + return fileDescriptor_bcca1063f62efc95, []int{54} } func (m *QueryAllProposalDurations) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2391,7 +2567,7 @@ func (m *QueryAllProposalDurationsResponse) Reset() { *m = QueryAllPropo func (m *QueryAllProposalDurationsResponse) String() string { return proto.CompactTextString(m) } func (*QueryAllProposalDurationsResponse) ProtoMessage() {} func (*QueryAllProposalDurationsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_bcca1063f62efc95, []int{51} + return fileDescriptor_bcca1063f62efc95, []int{55} } func (m *QueryAllProposalDurationsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2435,7 +2611,7 @@ func (m *QueryProposalDuration) Reset() { *m = QueryProposalDuration{} } func (m *QueryProposalDuration) String() string { return proto.CompactTextString(m) } func (*QueryProposalDuration) ProtoMessage() {} func (*QueryProposalDuration) Descriptor() ([]byte, []int) { - return fileDescriptor_bcca1063f62efc95, []int{52} + return fileDescriptor_bcca1063f62efc95, []int{56} } func (m *QueryProposalDuration) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2479,7 +2655,7 @@ func (m *QueryProposalDurationResponse) Reset() { *m = QueryProposalDura func (m *QueryProposalDurationResponse) String() string { return proto.CompactTextString(m) } func (*QueryProposalDurationResponse) ProtoMessage() {} func (*QueryProposalDurationResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_bcca1063f62efc95, []int{53} + return fileDescriptor_bcca1063f62efc95, []int{57} } func (m *QueryProposalDurationResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2523,7 +2699,7 @@ func (m *QueryCouncilors) Reset() { *m = QueryCouncilors{} } func (m *QueryCouncilors) String() string { return proto.CompactTextString(m) } func (*QueryCouncilors) ProtoMessage() {} func (*QueryCouncilors) Descriptor() ([]byte, []int) { - return fileDescriptor_bcca1063f62efc95, []int{54} + return fileDescriptor_bcca1063f62efc95, []int{58} } func (m *QueryCouncilors) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2567,7 +2743,7 @@ func (m *QueryCouncilorsResponse) Reset() { *m = QueryCouncilorsResponse func (m *QueryCouncilorsResponse) String() string { return proto.CompactTextString(m) } func (*QueryCouncilorsResponse) ProtoMessage() {} func (*QueryCouncilorsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_bcca1063f62efc95, []int{55} + return fileDescriptor_bcca1063f62efc95, []int{59} } func (m *QueryCouncilorsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2610,7 +2786,7 @@ func (m *QueryNonCouncilors) Reset() { *m = QueryNonCouncilors{} } func (m *QueryNonCouncilors) String() string { return proto.CompactTextString(m) } func (*QueryNonCouncilors) ProtoMessage() {} func (*QueryNonCouncilors) Descriptor() ([]byte, []int) { - return fileDescriptor_bcca1063f62efc95, []int{56} + return fileDescriptor_bcca1063f62efc95, []int{60} } func (m *QueryNonCouncilors) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2647,7 +2823,7 @@ func (m *QueryNonCouncilorsResponse) Reset() { *m = QueryNonCouncilorsRe func (m *QueryNonCouncilorsResponse) String() string { return proto.CompactTextString(m) } func (*QueryNonCouncilorsResponse) ProtoMessage() {} func (*QueryNonCouncilorsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_bcca1063f62efc95, []int{57} + return fileDescriptor_bcca1063f62efc95, []int{61} } func (m *QueryNonCouncilorsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2691,7 +2867,7 @@ func (m *QueryAddressesByWhitelistedPermission) Reset() { *m = QueryAddr func (m *QueryAddressesByWhitelistedPermission) String() string { return proto.CompactTextString(m) } func (*QueryAddressesByWhitelistedPermission) ProtoMessage() {} func (*QueryAddressesByWhitelistedPermission) Descriptor() ([]byte, []int) { - return fileDescriptor_bcca1063f62efc95, []int{58} + return fileDescriptor_bcca1063f62efc95, []int{62} } func (m *QueryAddressesByWhitelistedPermission) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2739,7 +2915,7 @@ func (m *QueryAddressesByWhitelistedPermissionResponse) String() string { } func (*QueryAddressesByWhitelistedPermissionResponse) ProtoMessage() {} func (*QueryAddressesByWhitelistedPermissionResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_bcca1063f62efc95, []int{59} + return fileDescriptor_bcca1063f62efc95, []int{63} } func (m *QueryAddressesByWhitelistedPermissionResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2783,7 +2959,7 @@ func (m *QueryAddressesByBlacklistedPermission) Reset() { *m = QueryAddr func (m *QueryAddressesByBlacklistedPermission) String() string { return proto.CompactTextString(m) } func (*QueryAddressesByBlacklistedPermission) ProtoMessage() {} func (*QueryAddressesByBlacklistedPermission) Descriptor() ([]byte, []int) { - return fileDescriptor_bcca1063f62efc95, []int{60} + return fileDescriptor_bcca1063f62efc95, []int{64} } func (m *QueryAddressesByBlacklistedPermission) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2831,7 +3007,7 @@ func (m *QueryAddressesByBlacklistedPermissionResponse) String() string { } func (*QueryAddressesByBlacklistedPermissionResponse) ProtoMessage() {} func (*QueryAddressesByBlacklistedPermissionResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_bcca1063f62efc95, []int{61} + return fileDescriptor_bcca1063f62efc95, []int{65} } func (m *QueryAddressesByBlacklistedPermissionResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2875,7 +3051,7 @@ func (m *QueryAddressesByWhitelistedRole) Reset() { *m = QueryAddressesB func (m *QueryAddressesByWhitelistedRole) String() string { return proto.CompactTextString(m) } func (*QueryAddressesByWhitelistedRole) ProtoMessage() {} func (*QueryAddressesByWhitelistedRole) Descriptor() ([]byte, []int) { - return fileDescriptor_bcca1063f62efc95, []int{62} + return fileDescriptor_bcca1063f62efc95, []int{66} } func (m *QueryAddressesByWhitelistedRole) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2921,7 +3097,7 @@ func (m *QueryAddressesByWhitelistedRoleResponse) Reset() { func (m *QueryAddressesByWhitelistedRoleResponse) String() string { return proto.CompactTextString(m) } func (*QueryAddressesByWhitelistedRoleResponse) ProtoMessage() {} func (*QueryAddressesByWhitelistedRoleResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_bcca1063f62efc95, []int{63} + return fileDescriptor_bcca1063f62efc95, []int{67} } func (m *QueryAddressesByWhitelistedRoleResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2958,6 +3134,10 @@ func (m *QueryAddressesByWhitelistedRoleResponse) GetAddresses() []string { } func init() { + proto.RegisterType((*QueryPollsVotesByPollId)(nil), "kira.gov.QueryPollsVotesByPollId") + proto.RegisterType((*QueryPollsVotesByPollIdResponse)(nil), "kira.gov.QueryPollsVotesByPollIdResponse") + proto.RegisterType((*QueryPollsListByAddress)(nil), "kira.gov.QueryPollsListByAddress") + proto.RegisterType((*QueryPollsListByAddressResponse)(nil), "kira.gov.QueryPollsListByAddressResponse") proto.RegisterType((*NetworkPropertiesRequest)(nil), "kira.gov.NetworkPropertiesRequest") proto.RegisterType((*NetworkPropertiesResponse)(nil), "kira.gov.NetworkPropertiesResponse") proto.RegisterType((*PermissionsByAddressRequest)(nil), "kira.gov.PermissionsByAddressRequest") @@ -3028,177 +3208,187 @@ func init() { func init() { proto.RegisterFile("kira/gov/query.proto", fileDescriptor_bcca1063f62efc95) } var fileDescriptor_bcca1063f62efc95 = []byte{ - // 2714 bytes of a gzipped FileDescriptorProto + // 2877 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x5a, 0xcb, 0x6f, 0x1b, 0xc7, - 0x19, 0xd7, 0x52, 0xb4, 0x25, 0x7d, 0xb2, 0x64, 0x79, 0x24, 0xcb, 0xd4, 0x4a, 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xb5, 0xad, 0x2a, 0x8e, 0xa9, 0xe0, 0x27, 0xb8, 0xb4, 0x4b, 0x9c, 0x17, 0xb7, 0x30, - 0xef, 0x9d, 0x15, 0xbd, 0x35, 0xec, 0x3e, 0xb6, 0xec, 0xed, 0x62, 0xdd, 0xb6, 0xea, 0xd8, 0x76, - 0x4d, 0xec, 0x30, 0x91, 0x53, 0x42, 0x84, 0x74, 0x59, 0x8e, 0x51, 0x8d, 0xe9, 0x9a, 0x65, 0x5c, - 0x73, 0x4d, 0xb7, 0xc1, 0x01, 0x19, 0x1c, 0xef, 0x58, 0xc5, 0xaa, 0x58, 0xf4, 0x53, 0x27, 0x5f, - 0x1c, 0x52, 0xc5, 0xb2, 0x2a, 0x55, 0xac, 0x1b, 0x75, 0x53, 0x37, 0x6a, 0x35, 0xcb, 0xa5, 0x29, - 0x61, 0xfe, 0x34, 0x15, 0x32, 0x0f, 0x3c, 0x2c, 0x0f, 0x05, 0x94, 0x02, 0x7e, 0xb4, 0x8b, 0x1d, - 0x57, 0xfb, 0x01, 0x4c, 0x48, 0xfa, 0x9c, 0xba, 0x55, 0x73, 0x30, 0xba, 0x09, 0xe0, 0x83, 0xcf, - 0x28, 0x33, 0xca, 0xe2, 0xe0, 0xea, 0x64, 0x9e, 0x8f, 0x4b, 0x3e, 0xae, 0x18, 0x10, 0xd7, 0x2e, - 0xc0, 0xe4, 0x43, 0x6c, 0xef, 0x98, 0x8e, 0x43, 0xa0, 0xac, 0x37, 0xd6, 0xca, 0x65, 0x1b, 0x3b, - 0xdc, 0x31, 0x42, 0x90, 0x36, 0xca, 0x65, 0x9b, 0x5a, 0x1d, 0x28, 0xd0, 0x6f, 0xed, 0x01, 0x8c, - 0x06, 0x54, 0x04, 0x8c, 0xab, 0x30, 0x58, 0xf7, 0x9b, 0x19, 0x8e, 0x93, 0x3e, 0x8e, 0xa0, 0x4e, - 0x50, 0x52, 0x7b, 0xaa, 0xc0, 0x40, 0xc1, 0xaa, 0xe2, 0xef, 0x92, 0x9a, 0x41, 0xc3, 0x90, 0x32, - 0xcb, 0x54, 0x7b, 0xa8, 0x90, 0x32, 0xcb, 0x68, 0x04, 0x7a, 0x1d, 0xb3, 0x9c, 0x49, 0x51, 0x00, - 0xe4, 0x13, 0xcd, 0xc0, 0x60, 0x19, 0x3b, 0x25, 0xdb, 0xac, 0x93, 0xf4, 0x65, 0x7a, 0x69, 0x4f, - 0xb0, 0x29, 0x0a, 0x25, 0xdd, 0x35, 0x94, 0x13, 0x70, 0x7c, 0xad, 0x5a, 0x25, 0x60, 0x44, 0xea, - 0x37, 0x60, 0xc4, 0x6f, 0x62, 0xa1, 0xea, 0x70, 0x84, 0x54, 0x1a, 0x09, 0xb2, 0x77, 0x71, 0x70, - 0x75, 0xd4, 0xb7, 0x2c, 0xe2, 0x58, 0x4f, 0x7f, 0xbe, 0x9f, 0xeb, 0x29, 0x78, 0x72, 0xda, 0x59, - 0x38, 0x49, 0x2d, 0x74, 0x95, 0xdf, 0x55, 0x18, 0x8f, 0x0a, 0x33, 0xbf, 0x19, 0xe8, 0x23, 0xf6, - 0xee, 0x96, 0x3d, 0xcf, 0xe9, 0x02, 0xff, 0xa9, 0xad, 0xc0, 0x20, 0xd1, 0xe1, 0x66, 0xb3, 0x00, - 0x5e, 0x6d, 0x6e, 0x99, 0x98, 0x1b, 0x0f, 0xb4, 0x68, 0x57, 0xe1, 0x98, 0x27, 0xce, 0x0c, 0x2f, - 0x40, 0x9a, 0x58, 0x62, 0x83, 0x26, 0x8b, 0xa7, 0x40, 0x05, 0xb4, 0xd7, 0x61, 0xf4, 0x0e, 0x9f, - 0x4e, 0xdf, 0xc2, 0xc2, 0xdf, 0x12, 0x8c, 0xb8, 0xb6, 0x51, 0x73, 0x8c, 0x12, 0x9d, 0x67, 0x6e, - 0xa3, 0x8e, 0x99, 0xd7, 0xe3, 0x81, 0xf6, 0xb7, 0x1a, 0x75, 0x62, 0x61, 0x2c, 0x6c, 0x81, 0x41, - 0x58, 0x84, 0xde, 0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81, 0xf0, 0x72, 0x35, - 0xf5, 0xd6, 0x2b, 0xa9, 0x89, 0x28, 0xd7, 0x68, 0x94, 0x37, 0xd1, 0xf5, 0xee, 0xa2, 0xe4, 0x4c, - 0xb6, 0xde, 0xe4, 0x5f, 0x2d, 0xf4, 0x99, 0x02, 0xb9, 0x4e, 0xe4, 0x58, 0xbe, 0x53, 0xcd, 0x87, - 0xe5, 0xd5, 0x2b, 0x07, 0x93, 0x17, 0xe1, 0xe4, 0x69, 0x38, 0x8b, 0x68, 0x3e, 0x61, 0xc2, 0x44, - 0x42, 0x42, 0x1f, 0x79, 0x1b, 0x41, 0x8c, 0x7b, 0x89, 0x2d, 0xc1, 0x32, 0xa1, 0xd8, 0x54, 0x69, - 0x47, 0x06, 0xc9, 0xf6, 0x5d, 0x02, 0x2d, 0xce, 0x34, 0x91, 0x15, 0x66, 0x24, 0x46, 0xe1, 0x24, - 0x1d, 0x97, 0xb8, 0x80, 0xba, 0xd0, 0x41, 0x40, 0x00, 0xb9, 0x48, 0x81, 0xac, 0xa0, 0xb3, 0xf1, - 0x53, 0x93, 0x00, 0x11, 0xd8, 0x2f, 0xbd, 0x13, 0xf4, 0xe3, 0x38, 0xbf, 0x33, 0x11, 0x71, 0xe8, - 0x77, 0xa9, 0xb3, 0x89, 0x5d, 0xed, 0x96, 0x36, 0x9f, 0x85, 0xf1, 0xee, 0x52, 0xd8, 0x71, 0x5a, - 0xe8, 0xc7, 0x32, 0x56, 0x07, 0x45, 0x4f, 0x01, 0xa1, 0xde, 0xd8, 0xd6, 0x28, 0xe5, 0x7e, 0xb4, - 0x19, 0x8a, 0x40, 0x45, 0x99, 0xc0, 0xf5, 0x25, 0xc4, 0x05, 0xa1, 0x2f, 0x95, 0x6e, 0x99, 0x9d, - 0xe8, 0x9e, 0xd3, 0x49, 0x41, 0xbd, 0x7a, 0x40, 0x05, 0x81, 0x7a, 0x9d, 0xa2, 0x7e, 0x0d, 0xdd, - 0x08, 0x94, 0x11, 0xd7, 0x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, 0x7b, + 0x89, 0x64, 0x27, 0x81, 0xae, 0xb7, 0x18, 0x24, 0x0f, 0xfd, 0x4c, 0x83, 0x93, 0x8a, 0xc7, 0x18, + 0x74, 0x3e, 0xfa, 0x16, 0x9b, 0xf5, 0x92, 0xa3, 0x5f, 0xe8, 0x23, 0xc5, 0xa1, 0xcc, 0x33, 0x28, + 0x73, 0xa8, 0x14, 0xd9, 0x6e, 0x1c, 0xc7, 0xad, 0x89, 0x41, 0x11, 0xcf, 0x3b, 0x68, 0x07, 0x86, + 0xc5, 0x21, 0x8f, 0x8a, 0x89, 0x82, 0x26, 0xf1, 0x78, 0xa2, 0x97, 0x32, 0xfb, 0xb3, 0x97, 0xbf, + 0xa4, 0xf3, 0x8d, 0xdd, 0x08, 0xef, 0xda, 0x45, 0x9b, 0x30, 0x22, 0x5f, 0x0a, 0x50, 0x96, 0x61, + 0xd5, 0xce, 0xa3, 0x7e, 0x64, 0x50, 0xed, 0x75, 0xe1, 0x4b, 0xc2, 0xef, 0x35, 0x98, 0xce, 0xa4, + 0xdd, 0x91, 0x91, 0x30, 0xde, 0x8f, 0xea, 0xd7, 0xaf, 0x0c, 0xae, 0xc0, 0xd1, 0x5d, 0x64, 0xe8, + 0x66, 0x51, 0x31, 0x44, 0x17, 0x10, 0xe7, 0x89, 0xac, 0x7c, 0x40, 0xe7, 0x46, 0x9a, 0x9c, 0x47, + 0x8b, 0xca, 0xf8, 0x55, 0x1c, 0xbf, 0xbe, 0x34, 0x88, 0x28, 0x87, 0xb5, 0xc0, 0x60, 0x61, 0x34, + 0x9b, 0x4c, 0x1a, 0x71, 0xbd, 0x5a, 0x00, 0x90, 0xd5, 0x43, 0x3e, 0xda, 0x82, 0x3c, 0x35, 0x80, + 0xf4, 0x84, 0xf5, 0x08, 0xdf, 0x1f, 0xdd, 0xb1, 0x52, 0xb4, 0x3d, 0xbe, 0xcc, 0x5c, 0x5d, 0x44, + 0xe7, 0xe3, 0x19, 0x88, 0xc7, 0x6f, 0xec,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x2c, 0x0a, 0x48, 0x96, + 0xe8, 0xc1, 0xaf, 0xb5, 0xbb, 0x95, 0xaf, 0x7f, 0xf2, 0x79, 0x51, 0xfb, 0xf4, 0xf3, 0xa2, 0xf6, + 0xd9, 0xe7, 0x45, 0xed, 0x97, 0x5f, 0x14, 0x0f, 0x7d, 0xfa, 0x45, 0xf1, 0xd0, 0x5f, 0xbf, 0x28, + 0x1e, 0x7a, 0xfd, 0x42, 0xe4, 0x81, 0xe0, 0x45, 0xcb, 0x35, 0xd7, 0x1c, 0x97, 0x18, 0x1e, 0xd9, + 0x34, 0x2d, 0xe3, 0x21, 0x33, 0xcc, 0xde, 0x08, 0xd6, 0x8f, 0xb2, 0x1f, 0x87, 0x3f, 0xf5, 0xef, + 0x00, 0x00, 0x00, 0xff, 0xff, 0x9f, 0x91, 0x07, 0x3b, 0x93, 0x2f, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -3267,17 +3457,20 @@ type QueryClient interface { AllProposalDurations(ctx context.Context, in *QueryAllProposalDurations, opts ...grpc.CallOption) (*QueryAllProposalDurationsResponse, error) // Query single proposal duration ProposalDuration(ctx context.Context, in *QueryProposalDuration, opts ...grpc.CallOption) (*QueryProposalDurationResponse, error) - // QueryCouncilorslist - all councilors (waiting or not), including their corresponding statuses, + // Councilors - all councilors (waiting or not), including their corresponding statuses, // ranks & abstenation counters - add sub-query to search by specific KIRA address - QueryCouncilors(ctx context.Context, in *QueryCouncilors, opts ...grpc.CallOption) (*QueryCouncilorsResponse, error) - // QueryNonCouncilors - list all governance members that are NOT Councilors - QueryNonCouncilors(ctx context.Context, in *QueryNonCouncilors, opts ...grpc.CallOption) (*QueryNonCouncilorsResponse, error) - // QueryAddressesByWhitelistedPermission - list all KIRA addresses by a specific whitelisted permission (address does NOT have to be a Councilor) - QueryAddressesByWhitelistedPermission(ctx context.Context, in *QueryAddressesByWhitelistedPermission, opts ...grpc.CallOption) (*QueryAddressesByWhitelistedPermissionResponse, error) - // QueryAddressesByBlacklistedPermission - list all KIRA addresses by a specific blacklisted permission (address does NOT have to be a Councilor) - QueryAddressesByBlacklistedPermission(ctx context.Context, in *QueryAddressesByBlacklistedPermission, opts ...grpc.CallOption) (*QueryAddressesByBlacklistedPermissionResponse, error) - // QueryAddressesByWhitelistedRole - list all kira addresses by a specific whitelisted role (address does NOT have to be a Councilor) - QueryAddressesByWhitelistedRole(ctx context.Context, in *QueryAddressesByWhitelistedRole, opts ...grpc.CallOption) (*QueryAddressesByWhitelistedRoleResponse, error) + Councilors(ctx context.Context, in *QueryCouncilors, opts ...grpc.CallOption) (*QueryCouncilorsResponse, error) + // NonCouncilors - list all governance members that are NOT Councilors + NonCouncilors(ctx context.Context, in *QueryNonCouncilors, opts ...grpc.CallOption) (*QueryNonCouncilorsResponse, error) + // AddressesByWhitelistedPermission - list all KIRA addresses by a specific whitelisted permission (address does NOT have to be a Councilor) + AddressesByWhitelistedPermission(ctx context.Context, in *QueryAddressesByWhitelistedPermission, opts ...grpc.CallOption) (*QueryAddressesByWhitelistedPermissionResponse, error) + // AddressesByBlacklistedPermission - list all KIRA addresses by a specific blacklisted permission (address does NOT have to be a Councilor) + AddressesByBlacklistedPermission(ctx context.Context, in *QueryAddressesByBlacklistedPermission, opts ...grpc.CallOption) (*QueryAddressesByBlacklistedPermissionResponse, error) + // AddressesByWhitelistedRole - list all kira addresses by a specific whitelisted role (address does NOT have to be a Councilor) + AddressesByWhitelistedRole(ctx context.Context, in *QueryAddressesByWhitelistedRole, opts ...grpc.CallOption) (*QueryAddressesByWhitelistedRoleResponse, error) + //Query list of all polls by address + PollsListByAddress(ctx context.Context, in *QueryPollsListByAddress, opts ...grpc.CallOption) (*QueryPollsListByAddressResponse, error) + PollsVotesByPollId(ctx context.Context, in *QueryPollsVotesByPollId, opts ...grpc.CallOption) (*QueryPollsVotesByPollIdResponse, error) } type queryClient struct { @@ -3531,45 +3724,63 @@ func (c *queryClient) ProposalDuration(ctx context.Context, in *QueryProposalDur return out, nil } -func (c *queryClient) QueryCouncilors(ctx context.Context, in *QueryCouncilors, opts ...grpc.CallOption) (*QueryCouncilorsResponse, error) { +func (c *queryClient) Councilors(ctx context.Context, in *QueryCouncilors, opts ...grpc.CallOption) (*QueryCouncilorsResponse, error) { out := new(QueryCouncilorsResponse) - err := c.cc.Invoke(ctx, "/kira.gov.Query/QueryCouncilors", in, out, opts...) + err := c.cc.Invoke(ctx, "/kira.gov.Query/Councilors", in, out, opts...) if err != nil { return nil, err } return out, nil } -func (c *queryClient) QueryNonCouncilors(ctx context.Context, in *QueryNonCouncilors, opts ...grpc.CallOption) (*QueryNonCouncilorsResponse, error) { +func (c *queryClient) NonCouncilors(ctx context.Context, in *QueryNonCouncilors, opts ...grpc.CallOption) (*QueryNonCouncilorsResponse, error) { out := new(QueryNonCouncilorsResponse) - err := c.cc.Invoke(ctx, "/kira.gov.Query/QueryNonCouncilors", in, out, opts...) + err := c.cc.Invoke(ctx, "/kira.gov.Query/NonCouncilors", in, out, opts...) if err != nil { return nil, err } return out, nil } -func (c *queryClient) QueryAddressesByWhitelistedPermission(ctx context.Context, in *QueryAddressesByWhitelistedPermission, opts ...grpc.CallOption) (*QueryAddressesByWhitelistedPermissionResponse, error) { +func (c *queryClient) AddressesByWhitelistedPermission(ctx context.Context, in *QueryAddressesByWhitelistedPermission, opts ...grpc.CallOption) (*QueryAddressesByWhitelistedPermissionResponse, error) { out := new(QueryAddressesByWhitelistedPermissionResponse) - err := c.cc.Invoke(ctx, "/kira.gov.Query/QueryAddressesByWhitelistedPermission", in, out, opts...) + err := c.cc.Invoke(ctx, "/kira.gov.Query/AddressesByWhitelistedPermission", in, out, opts...) if err != nil { return nil, err } return out, nil } -func (c *queryClient) QueryAddressesByBlacklistedPermission(ctx context.Context, in *QueryAddressesByBlacklistedPermission, opts ...grpc.CallOption) (*QueryAddressesByBlacklistedPermissionResponse, error) { +func (c *queryClient) AddressesByBlacklistedPermission(ctx context.Context, in *QueryAddressesByBlacklistedPermission, opts ...grpc.CallOption) (*QueryAddressesByBlacklistedPermissionResponse, error) { out := new(QueryAddressesByBlacklistedPermissionResponse) - err := c.cc.Invoke(ctx, "/kira.gov.Query/QueryAddressesByBlacklistedPermission", in, out, opts...) + err := c.cc.Invoke(ctx, "/kira.gov.Query/AddressesByBlacklistedPermission", in, out, opts...) if err != nil { return nil, err } return out, nil } -func (c *queryClient) QueryAddressesByWhitelistedRole(ctx context.Context, in *QueryAddressesByWhitelistedRole, opts ...grpc.CallOption) (*QueryAddressesByWhitelistedRoleResponse, error) { +func (c *queryClient) AddressesByWhitelistedRole(ctx context.Context, in *QueryAddressesByWhitelistedRole, opts ...grpc.CallOption) (*QueryAddressesByWhitelistedRoleResponse, error) { out := new(QueryAddressesByWhitelistedRoleResponse) - err := c.cc.Invoke(ctx, "/kira.gov.Query/QueryAddressesByWhitelistedRole", in, out, opts...) + err := c.cc.Invoke(ctx, "/kira.gov.Query/AddressesByWhitelistedRole", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) PollsListByAddress(ctx context.Context, in *QueryPollsListByAddress, opts ...grpc.CallOption) (*QueryPollsListByAddressResponse, error) { + out := new(QueryPollsListByAddressResponse) + err := c.cc.Invoke(ctx, "/kira.gov.Query/PollsListByAddress", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) PollsVotesByPollId(ctx context.Context, in *QueryPollsVotesByPollId, opts ...grpc.CallOption) (*QueryPollsVotesByPollIdResponse, error) { + out := new(QueryPollsVotesByPollIdResponse) + err := c.cc.Invoke(ctx, "/kira.gov.Query/PollsVotesByPollId", in, out, opts...) if err != nil { return nil, err } @@ -3632,17 +3843,20 @@ type QueryServer interface { AllProposalDurations(context.Context, *QueryAllProposalDurations) (*QueryAllProposalDurationsResponse, error) // Query single proposal duration ProposalDuration(context.Context, *QueryProposalDuration) (*QueryProposalDurationResponse, error) - // QueryCouncilorslist - all councilors (waiting or not), including their corresponding statuses, + // Councilors - all councilors (waiting or not), including their corresponding statuses, // ranks & abstenation counters - add sub-query to search by specific KIRA address - QueryCouncilors(context.Context, *QueryCouncilors) (*QueryCouncilorsResponse, error) - // QueryNonCouncilors - list all governance members that are NOT Councilors - QueryNonCouncilors(context.Context, *QueryNonCouncilors) (*QueryNonCouncilorsResponse, error) - // QueryAddressesByWhitelistedPermission - list all KIRA addresses by a specific whitelisted permission (address does NOT have to be a Councilor) - QueryAddressesByWhitelistedPermission(context.Context, *QueryAddressesByWhitelistedPermission) (*QueryAddressesByWhitelistedPermissionResponse, error) - // QueryAddressesByBlacklistedPermission - list all KIRA addresses by a specific blacklisted permission (address does NOT have to be a Councilor) - QueryAddressesByBlacklistedPermission(context.Context, *QueryAddressesByBlacklistedPermission) (*QueryAddressesByBlacklistedPermissionResponse, error) - // QueryAddressesByWhitelistedRole - list all kira addresses by a specific whitelisted role (address does NOT have to be a Councilor) - QueryAddressesByWhitelistedRole(context.Context, *QueryAddressesByWhitelistedRole) (*QueryAddressesByWhitelistedRoleResponse, error) + Councilors(context.Context, *QueryCouncilors) (*QueryCouncilorsResponse, error) + // NonCouncilors - list all governance members that are NOT Councilors + NonCouncilors(context.Context, *QueryNonCouncilors) (*QueryNonCouncilorsResponse, error) + // AddressesByWhitelistedPermission - list all KIRA addresses by a specific whitelisted permission (address does NOT have to be a Councilor) + AddressesByWhitelistedPermission(context.Context, *QueryAddressesByWhitelistedPermission) (*QueryAddressesByWhitelistedPermissionResponse, error) + // AddressesByBlacklistedPermission - list all KIRA addresses by a specific blacklisted permission (address does NOT have to be a Councilor) + AddressesByBlacklistedPermission(context.Context, *QueryAddressesByBlacklistedPermission) (*QueryAddressesByBlacklistedPermissionResponse, error) + // AddressesByWhitelistedRole - list all kira addresses by a specific whitelisted role (address does NOT have to be a Councilor) + AddressesByWhitelistedRole(context.Context, *QueryAddressesByWhitelistedRole) (*QueryAddressesByWhitelistedRoleResponse, error) + //Query list of all polls by address + PollsListByAddress(context.Context, *QueryPollsListByAddress) (*QueryPollsListByAddressResponse, error) + PollsVotesByPollId(context.Context, *QueryPollsVotesByPollId) (*QueryPollsVotesByPollIdResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -3730,20 +3944,26 @@ func (*UnimplementedQueryServer) AllProposalDurations(ctx context.Context, req * func (*UnimplementedQueryServer) ProposalDuration(ctx context.Context, req *QueryProposalDuration) (*QueryProposalDurationResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ProposalDuration not implemented") } -func (*UnimplementedQueryServer) QueryCouncilors(ctx context.Context, req *QueryCouncilors) (*QueryCouncilorsResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method QueryCouncilors not implemented") +func (*UnimplementedQueryServer) Councilors(ctx context.Context, req *QueryCouncilors) (*QueryCouncilorsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Councilors not implemented") +} +func (*UnimplementedQueryServer) NonCouncilors(ctx context.Context, req *QueryNonCouncilors) (*QueryNonCouncilorsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method NonCouncilors not implemented") } -func (*UnimplementedQueryServer) QueryNonCouncilors(ctx context.Context, req *QueryNonCouncilors) (*QueryNonCouncilorsResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method QueryNonCouncilors not implemented") +func (*UnimplementedQueryServer) AddressesByWhitelistedPermission(ctx context.Context, req *QueryAddressesByWhitelistedPermission) (*QueryAddressesByWhitelistedPermissionResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method AddressesByWhitelistedPermission not implemented") } -func (*UnimplementedQueryServer) QueryAddressesByWhitelistedPermission(ctx context.Context, req *QueryAddressesByWhitelistedPermission) (*QueryAddressesByWhitelistedPermissionResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method QueryAddressesByWhitelistedPermission not implemented") +func (*UnimplementedQueryServer) AddressesByBlacklistedPermission(ctx context.Context, req *QueryAddressesByBlacklistedPermission) (*QueryAddressesByBlacklistedPermissionResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method AddressesByBlacklistedPermission not implemented") } -func (*UnimplementedQueryServer) QueryAddressesByBlacklistedPermission(ctx context.Context, req *QueryAddressesByBlacklistedPermission) (*QueryAddressesByBlacklistedPermissionResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method QueryAddressesByBlacklistedPermission not implemented") +func (*UnimplementedQueryServer) AddressesByWhitelistedRole(ctx context.Context, req *QueryAddressesByWhitelistedRole) (*QueryAddressesByWhitelistedRoleResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method AddressesByWhitelistedRole not implemented") } -func (*UnimplementedQueryServer) QueryAddressesByWhitelistedRole(ctx context.Context, req *QueryAddressesByWhitelistedRole) (*QueryAddressesByWhitelistedRoleResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method QueryAddressesByWhitelistedRole not implemented") +func (*UnimplementedQueryServer) PollsListByAddress(ctx context.Context, req *QueryPollsListByAddress) (*QueryPollsListByAddressResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method PollsListByAddress not implemented") +} +func (*UnimplementedQueryServer) PollsVotesByPollId(ctx context.Context, req *QueryPollsVotesByPollId) (*QueryPollsVotesByPollIdResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method PollsVotesByPollId not implemented") } func RegisterQueryServer(s grpc1.Server, srv QueryServer) { @@ -4236,103 +4456,139 @@ func _Query_ProposalDuration_Handler(srv interface{}, ctx context.Context, dec f return interceptor(ctx, in, info, handler) } -func _Query_QueryCouncilors_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Query_Councilors_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(QueryCouncilors) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(QueryServer).QueryCouncilors(ctx, in) + return srv.(QueryServer).Councilors(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/kira.gov.Query/QueryCouncilors", + FullMethod: "/kira.gov.Query/Councilors", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).QueryCouncilors(ctx, req.(*QueryCouncilors)) + return srv.(QueryServer).Councilors(ctx, req.(*QueryCouncilors)) } return interceptor(ctx, in, info, handler) } -func _Query_QueryNonCouncilors_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Query_NonCouncilors_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(QueryNonCouncilors) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(QueryServer).QueryNonCouncilors(ctx, in) + return srv.(QueryServer).NonCouncilors(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/kira.gov.Query/QueryNonCouncilors", + FullMethod: "/kira.gov.Query/NonCouncilors", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).QueryNonCouncilors(ctx, req.(*QueryNonCouncilors)) + return srv.(QueryServer).NonCouncilors(ctx, req.(*QueryNonCouncilors)) } return interceptor(ctx, in, info, handler) } -func _Query_QueryAddressesByWhitelistedPermission_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Query_AddressesByWhitelistedPermission_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(QueryAddressesByWhitelistedPermission) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(QueryServer).QueryAddressesByWhitelistedPermission(ctx, in) + return srv.(QueryServer).AddressesByWhitelistedPermission(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/kira.gov.Query/QueryAddressesByWhitelistedPermission", + FullMethod: "/kira.gov.Query/AddressesByWhitelistedPermission", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).QueryAddressesByWhitelistedPermission(ctx, req.(*QueryAddressesByWhitelistedPermission)) + return srv.(QueryServer).AddressesByWhitelistedPermission(ctx, req.(*QueryAddressesByWhitelistedPermission)) } return interceptor(ctx, in, info, handler) } -func _Query_QueryAddressesByBlacklistedPermission_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Query_AddressesByBlacklistedPermission_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(QueryAddressesByBlacklistedPermission) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(QueryServer).QueryAddressesByBlacklistedPermission(ctx, in) + return srv.(QueryServer).AddressesByBlacklistedPermission(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/kira.gov.Query/QueryAddressesByBlacklistedPermission", + FullMethod: "/kira.gov.Query/AddressesByBlacklistedPermission", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).QueryAddressesByBlacklistedPermission(ctx, req.(*QueryAddressesByBlacklistedPermission)) + return srv.(QueryServer).AddressesByBlacklistedPermission(ctx, req.(*QueryAddressesByBlacklistedPermission)) } return interceptor(ctx, in, info, handler) } -func _Query_QueryAddressesByWhitelistedRole_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Query_AddressesByWhitelistedRole_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(QueryAddressesByWhitelistedRole) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(QueryServer).QueryAddressesByWhitelistedRole(ctx, in) + return srv.(QueryServer).AddressesByWhitelistedRole(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/kira.gov.Query/QueryAddressesByWhitelistedRole", + FullMethod: "/kira.gov.Query/AddressesByWhitelistedRole", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).QueryAddressesByWhitelistedRole(ctx, req.(*QueryAddressesByWhitelistedRole)) + return srv.(QueryServer).AddressesByWhitelistedRole(ctx, req.(*QueryAddressesByWhitelistedRole)) } return interceptor(ctx, in, info, handler) } -var _Query_serviceDesc = grpc.ServiceDesc{ - ServiceName: "kira.gov.Query", - HandlerType: (*QueryServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "PermissionsByAddress", - Handler: _Query_PermissionsByAddress_Handler, +func _Query_PollsListByAddress_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryPollsListByAddress) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).PollsListByAddress(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/kira.gov.Query/PollsListByAddress", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).PollsListByAddress(ctx, req.(*QueryPollsListByAddress)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_PollsVotesByPollId_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryPollsVotesByPollId) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).PollsVotesByPollId(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/kira.gov.Query/PollsVotesByPollId", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).PollsVotesByPollId(ctx, req.(*QueryPollsVotesByPollId)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "kira.gov.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "PermissionsByAddress", + Handler: _Query_PermissionsByAddress_Handler, }, { MethodName: "AllRoles", @@ -4439,30 +4695,170 @@ var _Query_serviceDesc = grpc.ServiceDesc{ Handler: _Query_ProposalDuration_Handler, }, { - MethodName: "QueryCouncilors", - Handler: _Query_QueryCouncilors_Handler, + MethodName: "Councilors", + Handler: _Query_Councilors_Handler, + }, + { + MethodName: "NonCouncilors", + Handler: _Query_NonCouncilors_Handler, + }, + { + MethodName: "AddressesByWhitelistedPermission", + Handler: _Query_AddressesByWhitelistedPermission_Handler, }, { - MethodName: "QueryNonCouncilors", - Handler: _Query_QueryNonCouncilors_Handler, + MethodName: "AddressesByBlacklistedPermission", + Handler: _Query_AddressesByBlacklistedPermission_Handler, }, { - MethodName: "QueryAddressesByWhitelistedPermission", - Handler: _Query_QueryAddressesByWhitelistedPermission_Handler, + MethodName: "AddressesByWhitelistedRole", + Handler: _Query_AddressesByWhitelistedRole_Handler, }, { - MethodName: "QueryAddressesByBlacklistedPermission", - Handler: _Query_QueryAddressesByBlacklistedPermission_Handler, + MethodName: "PollsListByAddress", + Handler: _Query_PollsListByAddress_Handler, }, { - MethodName: "QueryAddressesByWhitelistedRole", - Handler: _Query_QueryAddressesByWhitelistedRole_Handler, + MethodName: "PollsVotesByPollId", + Handler: _Query_PollsVotesByPollId_Handler, }, }, Streams: []grpc.StreamDesc{}, Metadata: "kira/gov/query.proto", } +func (m *QueryPollsVotesByPollId) 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 *QueryPollsVotesByPollId) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryPollsVotesByPollId) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.PollId != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.PollId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *QueryPollsVotesByPollIdResponse) 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 *QueryPollsVotesByPollIdResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryPollsVotesByPollIdResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Votes) > 0 { + for iNdEx := len(m.Votes) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Votes[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 *QueryPollsListByAddress) 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 *QueryPollsListByAddress) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryPollsListByAddress) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Creator) > 0 { + i -= len(m.Creator) + copy(dAtA[i:], m.Creator) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Creator))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryPollsListByAddressResponse) 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 *QueryPollsListByAddressResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryPollsListByAddressResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Polls) > 0 { + for iNdEx := len(m.Polls) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Polls[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 *NetworkPropertiesRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -6673,6 +7069,61 @@ func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } +func (m *QueryPollsVotesByPollId) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PollId != 0 { + n += 1 + sovQuery(uint64(m.PollId)) + } + return n +} + +func (m *QueryPollsVotesByPollIdResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Votes) > 0 { + for _, e := range m.Votes { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + +func (m *QueryPollsListByAddress) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Creator) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryPollsListByAddressResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Polls) > 0 { + for _, e := range m.Polls { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + func (m *NetworkPropertiesRequest) Size() (n int) { if m == nil { return 0 @@ -7579,6 +8030,327 @@ func sovQuery(x uint64) (n int) { func sozQuery(x uint64) (n int) { return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } +func (m *QueryPollsVotesByPollId) 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: QueryPollsVotesByPollId: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryPollsVotesByPollId: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PollId", wireType) + } + m.PollId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PollId |= 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 *QueryPollsVotesByPollIdResponse) 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: QueryPollsVotesByPollIdResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryPollsVotesByPollIdResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Votes", 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.Votes = append(m.Votes, PollVote{}) + if err := m.Votes[len(m.Votes)-1].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 *QueryPollsListByAddress) 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: QueryPollsListByAddress: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryPollsListByAddress: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Creator", 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.Creator = append(m.Creator[:0], dAtA[iNdEx:postIndex]...) + if m.Creator == nil { + m.Creator = []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 *QueryPollsListByAddressResponse) 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: QueryPollsListByAddressResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryPollsListByAddressResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Polls", 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.Polls = append(m.Polls, Poll{}) + if err := m.Polls[len(m.Polls)-1].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 *NetworkPropertiesRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/x/gov/types/query.pb.gw.go b/x/gov/types/query.pb.gw.go index 2f1559a9a..8faa6c136 100644 --- a/x/gov/types/query.pb.gw.go +++ b/x/gov/types/query.pb.gw.go @@ -1277,7 +1277,7 @@ func local_request_Query_ProposalDuration_0(ctx context.Context, marshaler runti } -func request_Query_QueryCouncilors_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { +func request_Query_Councilors_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryCouncilors var metadata runtime.ServerMetadata @@ -1299,12 +1299,12 @@ func request_Query_QueryCouncilors_0(ctx context.Context, marshaler runtime.Mars return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "address", err) } - msg, err := client.QueryCouncilors(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + msg, err := client.Councilors(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_Query_QueryCouncilors_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { +func local_request_Query_Councilors_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryCouncilors var metadata runtime.ServerMetadata @@ -1326,30 +1326,30 @@ func local_request_Query_QueryCouncilors_0(ctx context.Context, marshaler runtim return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "address", err) } - msg, err := server.QueryCouncilors(ctx, &protoReq) + msg, err := server.Councilors(ctx, &protoReq) return msg, metadata, err } -func request_Query_QueryNonCouncilors_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { +func request_Query_NonCouncilors_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryNonCouncilors var metadata runtime.ServerMetadata - msg, err := client.QueryNonCouncilors(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + msg, err := client.NonCouncilors(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_Query_QueryNonCouncilors_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { +func local_request_Query_NonCouncilors_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryNonCouncilors var metadata runtime.ServerMetadata - msg, err := server.QueryNonCouncilors(ctx, &protoReq) + msg, err := server.NonCouncilors(ctx, &protoReq) return msg, metadata, err } -func request_Query_QueryAddressesByWhitelistedPermission_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { +func request_Query_AddressesByWhitelistedPermission_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryAddressesByWhitelistedPermission var metadata runtime.ServerMetadata @@ -1371,12 +1371,12 @@ func request_Query_QueryAddressesByWhitelistedPermission_0(ctx context.Context, return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "permission", err) } - msg, err := client.QueryAddressesByWhitelistedPermission(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + msg, err := client.AddressesByWhitelistedPermission(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_Query_QueryAddressesByWhitelistedPermission_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { +func local_request_Query_AddressesByWhitelistedPermission_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryAddressesByWhitelistedPermission var metadata runtime.ServerMetadata @@ -1398,12 +1398,12 @@ func local_request_Query_QueryAddressesByWhitelistedPermission_0(ctx context.Con return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "permission", err) } - msg, err := server.QueryAddressesByWhitelistedPermission(ctx, &protoReq) + msg, err := server.AddressesByWhitelistedPermission(ctx, &protoReq) return msg, metadata, err } -func request_Query_QueryAddressesByBlacklistedPermission_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { +func request_Query_AddressesByBlacklistedPermission_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryAddressesByBlacklistedPermission var metadata runtime.ServerMetadata @@ -1425,12 +1425,12 @@ func request_Query_QueryAddressesByBlacklistedPermission_0(ctx context.Context, return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "permission", err) } - msg, err := client.QueryAddressesByBlacklistedPermission(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + msg, err := client.AddressesByBlacklistedPermission(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_Query_QueryAddressesByBlacklistedPermission_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { +func local_request_Query_AddressesByBlacklistedPermission_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryAddressesByBlacklistedPermission var metadata runtime.ServerMetadata @@ -1452,12 +1452,12 @@ func local_request_Query_QueryAddressesByBlacklistedPermission_0(ctx context.Con return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "permission", err) } - msg, err := server.QueryAddressesByBlacklistedPermission(ctx, &protoReq) + msg, err := server.AddressesByBlacklistedPermission(ctx, &protoReq) return msg, metadata, err } -func request_Query_QueryAddressesByWhitelistedRole_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { +func request_Query_AddressesByWhitelistedRole_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryAddressesByWhitelistedRole var metadata runtime.ServerMetadata @@ -1479,12 +1479,12 @@ func request_Query_QueryAddressesByWhitelistedRole_0(ctx context.Context, marsha return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "role", err) } - msg, err := client.QueryAddressesByWhitelistedRole(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + msg, err := client.AddressesByWhitelistedRole(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_Query_QueryAddressesByWhitelistedRole_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { +func local_request_Query_AddressesByWhitelistedRole_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryAddressesByWhitelistedRole var metadata runtime.ServerMetadata @@ -1506,7 +1506,115 @@ func local_request_Query_QueryAddressesByWhitelistedRole_0(ctx context.Context, return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "role", err) } - msg, err := server.QueryAddressesByWhitelistedRole(ctx, &protoReq) + msg, err := server.AddressesByWhitelistedRole(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_PollsListByAddress_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryPollsListByAddress + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["creator"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "creator") + } + + protoReq.Creator, err = runtime.Bytes(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "creator", err) + } + + msg, err := client.PollsListByAddress(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_PollsListByAddress_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryPollsListByAddress + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["creator"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "creator") + } + + protoReq.Creator, err = runtime.Bytes(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "creator", err) + } + + msg, err := server.PollsListByAddress(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_PollsVotesByPollId_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryPollsVotesByPollId + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["poll_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "poll_id") + } + + protoReq.PollId, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "poll_id", err) + } + + msg, err := client.PollsVotesByPollId(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_PollsVotesByPollId_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryPollsVotesByPollId + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["poll_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "poll_id") + } + + protoReq.PollId, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "poll_id", err) + } + + msg, err := server.PollsVotesByPollId(ctx, &protoReq) return msg, metadata, err } @@ -2057,7 +2165,47 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) - mux.Handle("GET", pattern_Query_QueryCouncilors_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_Councilors_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.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_Councilors_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Councilors_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_NonCouncilors_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.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_NonCouncilors_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_NonCouncilors_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_AddressesByWhitelistedPermission_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) @@ -2066,18 +2214,18 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Query_QueryCouncilors_0(rctx, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_Query_AddressesByWhitelistedPermission_0(rctx, inboundMarshaler, server, req, pathParams) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - forward_Query_QueryCouncilors_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_AddressesByWhitelistedPermission_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("GET", pattern_Query_QueryNonCouncilors_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_AddressesByBlacklistedPermission_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) @@ -2086,18 +2234,18 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Query_QueryNonCouncilors_0(rctx, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_Query_AddressesByBlacklistedPermission_0(rctx, inboundMarshaler, server, req, pathParams) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - forward_Query_QueryNonCouncilors_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_AddressesByBlacklistedPermission_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("GET", pattern_Query_QueryAddressesByWhitelistedPermission_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_AddressesByWhitelistedRole_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) @@ -2106,18 +2254,18 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Query_QueryAddressesByWhitelistedPermission_0(rctx, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_Query_AddressesByWhitelistedRole_0(rctx, inboundMarshaler, server, req, pathParams) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - forward_Query_QueryAddressesByWhitelistedPermission_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_AddressesByWhitelistedRole_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("GET", pattern_Query_QueryAddressesByBlacklistedPermission_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_PollsListByAddress_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) @@ -2126,18 +2274,18 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Query_QueryAddressesByBlacklistedPermission_0(rctx, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_Query_PollsListByAddress_0(rctx, inboundMarshaler, server, req, pathParams) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - forward_Query_QueryAddressesByBlacklistedPermission_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_PollsListByAddress_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("GET", pattern_Query_QueryAddressesByWhitelistedRole_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_PollsVotesByPollId_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) @@ -2146,14 +2294,14 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Query_QueryAddressesByWhitelistedRole_0(rctx, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_Query_PollsVotesByPollId_0(rctx, inboundMarshaler, server, req, pathParams) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - forward_Query_QueryAddressesByWhitelistedRole_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_PollsVotesByPollId_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -2738,7 +2886,47 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) - mux.Handle("GET", pattern_Query_QueryCouncilors_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_Councilors_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_Councilors_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_Councilors_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_NonCouncilors_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_NonCouncilors_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_NonCouncilors_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_AddressesByWhitelistedPermission_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) @@ -2747,18 +2935,18 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Query_QueryCouncilors_0(rctx, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Query_AddressesByWhitelistedPermission_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_QueryCouncilors_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_AddressesByWhitelistedPermission_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("GET", pattern_Query_QueryNonCouncilors_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_AddressesByBlacklistedPermission_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) @@ -2767,18 +2955,18 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Query_QueryNonCouncilors_0(rctx, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Query_AddressesByBlacklistedPermission_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_QueryNonCouncilors_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_AddressesByBlacklistedPermission_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("GET", pattern_Query_QueryAddressesByWhitelistedPermission_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_AddressesByWhitelistedRole_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) @@ -2787,18 +2975,18 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Query_QueryAddressesByWhitelistedPermission_0(rctx, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Query_AddressesByWhitelistedRole_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_QueryAddressesByWhitelistedPermission_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_AddressesByWhitelistedRole_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("GET", pattern_Query_QueryAddressesByBlacklistedPermission_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_PollsListByAddress_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) @@ -2807,18 +2995,18 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Query_QueryAddressesByBlacklistedPermission_0(rctx, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Query_PollsListByAddress_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_QueryAddressesByBlacklistedPermission_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_PollsListByAddress_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("GET", pattern_Query_QueryAddressesByWhitelistedRole_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_PollsVotesByPollId_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) @@ -2827,14 +3015,14 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Query_QueryAddressesByWhitelistedRole_0(rctx, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Query_PollsVotesByPollId_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_QueryAddressesByWhitelistedRole_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_PollsVotesByPollId_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -2896,15 +3084,19 @@ var ( pattern_Query_ProposalDuration_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"kira", "gov", "proposal_duration", "proposal_type"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_Query_QueryCouncilors_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"kira", "gov", "councilors", "address"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_Councilors_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"kira", "gov", "councilors", "address"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_NonCouncilors_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"kira", "gov", "non_councilors"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_AddressesByWhitelistedPermission_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"kira", "gov", "addresses_by_whitelisted_permission", "permission"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_Query_QueryNonCouncilors_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"kira", "gov", "non_councilors"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_AddressesByBlacklistedPermission_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"kira", "gov", "addresses_by_blacklisted_permission", "permission"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_Query_QueryAddressesByWhitelistedPermission_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"kira", "gov", "addresses_by_whitelisted_permission", "permission"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_AddressesByWhitelistedRole_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"kira", "gov", "addresses_by_whitelisted_role", "role"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_Query_QueryAddressesByBlacklistedPermission_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"kira", "gov", "addresses_by_blacklisted_permission", "permission"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_PollsListByAddress_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"kira", "gov", "proposal_polls", "creator"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_Query_QueryAddressesByWhitelistedRole_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"kira", "gov", "addresses_by_whitelisted_role", "role"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_PollsVotesByPollId_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"kira", "gov", "proposal_poll", "votes", "poll_id"}, "", runtime.AssumeColonVerbOpt(true))) ) var ( @@ -2962,13 +3154,17 @@ var ( forward_Query_ProposalDuration_0 = runtime.ForwardResponseMessage - forward_Query_QueryCouncilors_0 = runtime.ForwardResponseMessage + forward_Query_Councilors_0 = runtime.ForwardResponseMessage + + forward_Query_NonCouncilors_0 = runtime.ForwardResponseMessage + + forward_Query_AddressesByWhitelistedPermission_0 = runtime.ForwardResponseMessage - forward_Query_QueryNonCouncilors_0 = runtime.ForwardResponseMessage + forward_Query_AddressesByBlacklistedPermission_0 = runtime.ForwardResponseMessage - forward_Query_QueryAddressesByWhitelistedPermission_0 = runtime.ForwardResponseMessage + forward_Query_AddressesByWhitelistedRole_0 = runtime.ForwardResponseMessage - forward_Query_QueryAddressesByBlacklistedPermission_0 = runtime.ForwardResponseMessage + forward_Query_PollsListByAddress_0 = runtime.ForwardResponseMessage - forward_Query_QueryAddressesByWhitelistedRole_0 = runtime.ForwardResponseMessage + forward_Query_PollsVotesByPollId_0 = runtime.ForwardResponseMessage ) diff --git a/x/gov/types/quorum.go b/x/gov/types/quorum.go index 47d2e5988..30a9a54df 100644 --- a/x/gov/types/quorum.go +++ b/x/gov/types/quorum.go @@ -1,19 +1,19 @@ -package types - -import ( - "fmt" - "math" -) - -func IsQuorum(percentage, votes, totalVoters uint64) (bool, error) { - if votes > totalVoters { - return false, fmt.Errorf("there is more votes than voters: %d > %d", votes, totalVoters) - } - - if percentage > 100 { - return false, fmt.Errorf("quorum cannot be bigger than 100: %d", percentage) - } - - necessaryApproval := uint64(math.Ceil(float64(totalVoters*percentage) / 100.0)) - return votes >= necessaryApproval, nil -} +package types + +import ( + "fmt" + "math" +) + +func IsQuorum(percentage, votes, totalVoters uint64) (bool, error) { + if votes > totalVoters { + return false, fmt.Errorf("there is more votes than voters: %d > %d", votes, totalVoters) + } + + if percentage > 100 { + return false, fmt.Errorf("quorum cannot be bigger than 100: %d", percentage) + } + + necessaryApproval := uint64(math.Ceil(float64(totalVoters*percentage) / 100.0)) + return votes >= necessaryApproval, nil +} diff --git a/x/gov/types/quorum_test.go b/x/gov/types/quorum_test.go index 56692afa2..1a7d381a4 100644 --- a/x/gov/types/quorum_test.go +++ b/x/gov/types/quorum_test.go @@ -1,71 +1,71 @@ -package types - -import ( - "fmt" - "testing" - - "github.com/stretchr/testify/require" -) - -func TestIsQuorum_Errors(t *testing.T) { - tests := []struct { - name string - percentage, votes, voters uint64 - expectedErr error - }{ - { - name: "more votes than total voters", - percentage: 66, - votes: 11, - voters: 10, - expectedErr: fmt.Errorf("there is more votes than voters: 11 > 10"), - }, - { - name: "invalid quorum", - percentage: 101, - votes: 7, - voters: 10, - expectedErr: fmt.Errorf("quorum cannot be bigger than 100: 101"), - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - _, err := IsQuorum(tt.percentage, tt.votes, tt.voters) - require.EqualError(t, err, tt.expectedErr.Error()) - }) - } -} - -func TestIsQuorum(t *testing.T) { - tests := []struct { - name string - percentage, votes, voters uint64 - reached bool - }{ - { - name: "quorum not reached", - percentage: 66, - votes: 6, - voters: 10, - reached: false, - }, - { - name: "quorum reached", - percentage: 66, - votes: 7, - voters: 10, - reached: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - quorum, err := IsQuorum(tt.percentage, tt.votes, tt.voters) - require.NoError(t, err) - require.Equal(t, tt.reached, quorum) - }) - } -} +package types + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/require" +) + +func TestIsQuorum_Errors(t *testing.T) { + tests := []struct { + name string + percentage, votes, voters uint64 + expectedErr error + }{ + { + name: "more votes than total voters", + percentage: 66, + votes: 11, + voters: 10, + expectedErr: fmt.Errorf("there is more votes than voters: 11 > 10"), + }, + { + name: "invalid quorum", + percentage: 101, + votes: 7, + voters: 10, + expectedErr: fmt.Errorf("quorum cannot be bigger than 100: 101"), + }, + } + + for _, tt := range tests { + tt := tt + t.Run(tt.name, func(t *testing.T) { + _, err := IsQuorum(tt.percentage, tt.votes, tt.voters) + require.EqualError(t, err, tt.expectedErr.Error()) + }) + } +} + +func TestIsQuorum(t *testing.T) { + tests := []struct { + name string + percentage, votes, voters uint64 + reached bool + }{ + { + name: "quorum not reached", + percentage: 66, + votes: 6, + voters: 10, + reached: false, + }, + { + name: "quorum reached", + percentage: 66, + votes: 7, + voters: 10, + reached: true, + }, + } + + for _, tt := range tests { + tt := tt + t.Run(tt.name, func(t *testing.T) { + quorum, err := IsQuorum(tt.percentage, tt.votes, tt.voters) + require.NoError(t, err) + require.Equal(t, tt.reached, quorum) + }) + } +} diff --git a/x/gov/types/router.go b/x/gov/types/router.go index 23c6a5836..1e87c70f8 100644 --- a/x/gov/types/router.go +++ b/x/gov/types/router.go @@ -1,116 +1,116 @@ -package types - -import ( - "fmt" - - sdk "github.com/cosmos/cosmos-sdk/types" -) - -type ProposalRouter struct { - routes map[string]ProposalHandler -} - -func NewProposalRouter(handlers []ProposalHandler) ProposalRouter { - routes := make(map[string]ProposalHandler, len(handlers)) - for _, h := range handlers { - routes[h.ProposalType()] = h - } - - return ProposalRouter{routes: routes} -} - -func (r ProposalRouter) IsAllowedAddressDynamicProposal(ctx sdk.Context, addr sdk.AccAddress, proposal Content) bool { - h, ok := r.routes[proposal.ProposalType()] - if !ok { - panic("invalid proposal type") - } - - dh, ok := h.(DynamicVoterProposalHandler) - if !ok { - return false - } - return dh.IsAllowedAddress(ctx, addr, proposal) -} - -func (r ProposalRouter) AllowedAddressesDynamicProposal(ctx sdk.Context, proposal Content) []string { - h, ok := r.routes[proposal.ProposalType()] - if !ok { - panic("invalid proposal type") - } - - dh, ok := h.(DynamicVoterProposalHandler) - if !ok { - return []string{} - } - return dh.AllowedAddresses(ctx, proposal) -} - -func (r ProposalRouter) QuorumDynamicProposal(ctx sdk.Context, proposal Content) uint64 { - h, ok := r.routes[proposal.ProposalType()] - if !ok { - panic("invalid proposal type") - } - - dh, ok := h.(DynamicVoterProposalHandler) - if !ok { - return 0 - } - return dh.Quorum(ctx, proposal) -} - -func (r ProposalRouter) VotePeriodDynamicProposal(ctx sdk.Context, proposal Content) uint64 { - h, ok := r.routes[proposal.ProposalType()] - if !ok { - panic("invalid proposal type") - } - - dh, ok := h.(DynamicVoterProposalHandler) - if !ok { - return 0 - } - return dh.VotePeriod(ctx, proposal) -} - -func (r ProposalRouter) EnactmentPeriodDynamicProposal(ctx sdk.Context, proposal Content) uint64 { - h, ok := r.routes[proposal.ProposalType()] - if !ok { - panic("invalid proposal type") - } - - dh, ok := h.(DynamicVoterProposalHandler) - if !ok { - return 0 - } - return dh.VoteEnactment(ctx, proposal) -} - -func (r ProposalRouter) ApplyProposal(ctx sdk.Context, proposalID uint64, proposal Content, slash sdk.Dec) error { - h, ok := r.routes[proposal.ProposalType()] - if !ok { - panic("invalid proposal type") - } - - cachedCtx, writeCache := ctx.CacheContext() - err := h.Apply(cachedCtx, proposalID, proposal, slash) - if err == nil { - writeCache() - } else { // not halt the chain for proposal execution - fmt.Println("error applying proposal:", err) - } - return err -} - -type ProposalHandler interface { - ProposalType() string - Apply(ctx sdk.Context, proposalID uint64, proposal Content, slash sdk.Dec) error -} - -type DynamicVoterProposalHandler interface { - ProposalType() string - IsAllowedAddress(ctx sdk.Context, addr sdk.AccAddress, proposal Content) bool - Quorum(ctx sdk.Context, proposal Content) uint64 - VotePeriod(ctx sdk.Context, proposal Content) uint64 - VoteEnactment(ctx sdk.Context, proposal Content) uint64 - AllowedAddresses(ctx sdk.Context, proposal Content) []string - Apply(ctx sdk.Context, proposalID uint64, proposal Content, slash sdk.Dec) error -} +package types + +import ( + "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" +) + +type ProposalRouter struct { + routes map[string]ProposalHandler +} + +func NewProposalRouter(handlers []ProposalHandler) ProposalRouter { + routes := make(map[string]ProposalHandler, len(handlers)) + for _, h := range handlers { + routes[h.ProposalType()] = h + } + + return ProposalRouter{routes: routes} +} + +func (r ProposalRouter) IsAllowedAddressDynamicProposal(ctx sdk.Context, addr sdk.AccAddress, proposal Content) bool { + h, ok := r.routes[proposal.ProposalType()] + if !ok { + panic("invalid proposal type") + } + + dh, ok := h.(DynamicVoterProposalHandler) + if !ok { + return false + } + return dh.IsAllowedAddress(ctx, addr, proposal) +} + +func (r ProposalRouter) AllowedAddressesDynamicProposal(ctx sdk.Context, proposal Content) []string { + h, ok := r.routes[proposal.ProposalType()] + if !ok { + panic("invalid proposal type") + } + + dh, ok := h.(DynamicVoterProposalHandler) + if !ok { + return []string{} + } + return dh.AllowedAddresses(ctx, proposal) +} + +func (r ProposalRouter) QuorumDynamicProposal(ctx sdk.Context, proposal Content) uint64 { + h, ok := r.routes[proposal.ProposalType()] + if !ok { + panic("invalid proposal type") + } + + dh, ok := h.(DynamicVoterProposalHandler) + if !ok { + return 0 + } + return dh.Quorum(ctx, proposal) +} + +func (r ProposalRouter) VotePeriodDynamicProposal(ctx sdk.Context, proposal Content) uint64 { + h, ok := r.routes[proposal.ProposalType()] + if !ok { + panic("invalid proposal type") + } + + dh, ok := h.(DynamicVoterProposalHandler) + if !ok { + return 0 + } + return dh.VotePeriod(ctx, proposal) +} + +func (r ProposalRouter) EnactmentPeriodDynamicProposal(ctx sdk.Context, proposal Content) uint64 { + h, ok := r.routes[proposal.ProposalType()] + if !ok { + panic("invalid proposal type") + } + + dh, ok := h.(DynamicVoterProposalHandler) + if !ok { + return 0 + } + return dh.VoteEnactment(ctx, proposal) +} + +func (r ProposalRouter) ApplyProposal(ctx sdk.Context, proposalID uint64, proposal Content, slash sdk.Dec) error { + h, ok := r.routes[proposal.ProposalType()] + if !ok { + panic("invalid proposal type") + } + + cachedCtx, writeCache := ctx.CacheContext() + err := h.Apply(cachedCtx, proposalID, proposal, slash) + if err == nil { + writeCache() + } else { // not halt the chain for proposal execution + fmt.Println("error applying proposal:", err) + } + return err +} + +type ProposalHandler interface { + ProposalType() string + Apply(ctx sdk.Context, proposalID uint64, proposal Content, slash sdk.Dec) error +} + +type DynamicVoterProposalHandler interface { + ProposalType() string + IsAllowedAddress(ctx sdk.Context, addr sdk.AccAddress, proposal Content) bool + Quorum(ctx sdk.Context, proposal Content) uint64 + VotePeriod(ctx sdk.Context, proposal Content) uint64 + VoteEnactment(ctx sdk.Context, proposal Content) uint64 + AllowedAddresses(ctx sdk.Context, proposal Content) []string + Apply(ctx sdk.Context, proposalID uint64, proposal Content, slash sdk.Dec) error +} diff --git a/x/gov/types/tx.pb.go b/x/gov/types/tx.pb.go index cb669ad6f..dc547113d 100644 --- a/x/gov/types/tx.pb.go +++ b/x/gov/types/tx.pb.go @@ -1100,6 +1100,86 @@ func (m *MsgCouncilorActivateResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgCouncilorActivateResponse proto.InternalMessageInfo +type MsgPollCreateResponse struct { + PollID uint64 `protobuf:"varint,1,opt,name=pollID,proto3" json:"pollID,omitempty"` +} + +func (m *MsgPollCreateResponse) Reset() { *m = MsgPollCreateResponse{} } +func (m *MsgPollCreateResponse) String() string { return proto.CompactTextString(m) } +func (*MsgPollCreateResponse) ProtoMessage() {} +func (*MsgPollCreateResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_4b262b5902d6e313, []int{28} +} +func (m *MsgPollCreateResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgPollCreateResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgPollCreateResponse.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 *MsgPollCreateResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgPollCreateResponse.Merge(m, src) +} +func (m *MsgPollCreateResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgPollCreateResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgPollCreateResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgPollCreateResponse proto.InternalMessageInfo + +func (m *MsgPollCreateResponse) GetPollID() uint64 { + if m != nil { + return m.PollID + } + return 0 +} + +type MsgPollVoteResponse struct { +} + +func (m *MsgPollVoteResponse) Reset() { *m = MsgPollVoteResponse{} } +func (m *MsgPollVoteResponse) String() string { return proto.CompactTextString(m) } +func (*MsgPollVoteResponse) ProtoMessage() {} +func (*MsgPollVoteResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_4b262b5902d6e313, []int{29} +} +func (m *MsgPollVoteResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgPollVoteResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgPollVoteResponse.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 *MsgPollVoteResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgPollVoteResponse.Merge(m, src) +} +func (m *MsgPollVoteResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgPollVoteResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgPollVoteResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgPollVoteResponse proto.InternalMessageInfo + func init() { proto.RegisterType((*MsgSubmitProposal)(nil), "kira.gov.MsgSubmitProposal") proto.RegisterType((*MsgSubmitProposalResponse)(nil), "kira.gov.MsgSubmitProposalResponse") @@ -1129,82 +1209,88 @@ func init() { proto.RegisterType((*MsgCouncilorUnpauseResponse)(nil), "kira.gov.MsgCouncilorUnpauseResponse") proto.RegisterType((*MsgCouncilorActivate)(nil), "kira.gov.MsgCouncilorActivate") proto.RegisterType((*MsgCouncilorActivateResponse)(nil), "kira.gov.MsgCouncilorActivateResponse") + proto.RegisterType((*MsgPollCreateResponse)(nil), "kira.gov.MsgPollCreateResponse") + proto.RegisterType((*MsgPollVoteResponse)(nil), "kira.gov.MsgPollVoteResponse") } func init() { proto.RegisterFile("kira/gov/tx.proto", fileDescriptor_4b262b5902d6e313) } var fileDescriptor_4b262b5902d6e313 = []byte{ - // 1113 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x58, 0x41, 0x6f, 0xd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xf1, 0x27, 0x10, 0x00, 0x00, + // 1173 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x58, 0xcf, 0x6f, 0x1b, 0x45, + 0x14, 0xb6, 0x69, 0x29, 0xc9, 0x6b, 0x05, 0xcd, 0xd4, 0xa9, 0x93, 0x8d, 0x63, 0x3b, 0x4b, 0x5a, + 0xd2, 0x40, 0x6c, 0x1a, 0x0e, 0x48, 0x70, 0x80, 0x24, 0xa5, 0x50, 0x81, 0x51, 0xe4, 0xaa, 0x05, + 0xc1, 0x21, 0xda, 0xec, 0xbe, 0x6c, 0x57, 0x59, 0xef, 0x98, 0x9d, 0x71, 0x9a, 0x48, 0x48, 0x70, + 0x83, 0x13, 0xe2, 0xc8, 0x31, 0x7f, 0x09, 0x67, 0x8e, 0x3d, 0x72, 0xa8, 0x10, 0x4a, 0x2e, 0xfc, + 0x0d, 0x9c, 0xd0, 0xfe, 0x9a, 0xdd, 0x9d, 0x9d, 0x5d, 0x9b, 0x53, 0xbb, 0xef, 0xfb, 0xde, 0x37, + 0xf3, 0x66, 0xde, 0xbc, 0xf7, 0x1c, 0x58, 0x38, 0x76, 0x7c, 0xa3, 0x6f, 0xd3, 0x93, 0x3e, 0x3f, + 0xed, 0x8d, 0x7d, 0xca, 0x29, 0x99, 0x0b, 0x4c, 0x3d, 0x9b, 0x9e, 0x68, 0x0d, 0x9b, 0xda, 0x34, + 0x34, 0xf6, 0x83, 0xff, 0x45, 0xb8, 0xb6, 0x6c, 0x53, 0x6a, 0xbb, 0xd8, 0x0f, 0xbf, 0x0e, 0x27, + 0x47, 0x7d, 0xc3, 0x3b, 0x8b, 0xa1, 0x86, 0x50, 0x33, 0x4c, 0x4e, 0xfd, 0xd8, 0xba, 0x24, 0xac, + 0x26, 0x9d, 0x78, 0xa6, 0xe3, 0x0a, 0xa4, 0x29, 0x90, 0xb1, 0x4f, 0xc7, 0x94, 0x19, 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f7, + 0x06, 0x5c, 0x19, 0x30, 0x9b, 0x0c, 0xe1, 0x75, 0xa9, 0x82, 0xae, 0xf4, 0x92, 0x5e, 0xd4, 0x2b, + 0x14, 0x20, 0xed, 0xcd, 0x0a, 0x50, 0x6c, 0xc5, 0x82, 0x86, 0xaa, 0xf4, 0x90, 0xb5, 0x9c, 0xb3, + 0x8a, 0xa2, 0xdd, 0x9b, 0x4a, 0x11, 0xab, 0x7c, 0x0f, 0xad, 0xaa, 0xea, 0x45, 0xf2, 0x52, 0x55, + 0x54, 0xed, 0xfe, 0xcc, 0xd4, 0x6c, 0x8c, 0xaa, 0x82, 0x28, 0xc5, 0xa8, 0xa2, 0x48, 0x31, 0x56, + 0x95, 0xd5, 0x34, 0x46, 0x75, 0x4d, 0x55, 0xc6, 0xa8, 0xa6, 0x2a, 0x63, 0xac, 0xae, 0xd4, 0x41, + 0x6e, 0xe4, 0xcb, 0xb4, 0x94, 0x1b, 0x79, 0x50, 0xca, 0x0d, 0x75, 0x81, 0x27, 0x5f, 0xc0, 0x8d, + 0x6c, 0x75, 0x27, 0xcb, 0x39, 0xa7, 0x2c, 0xa4, 0xad, 0x95, 0x42, 0x42, 0xed, 0x21, 0x40, 0xda, + 0x10, 0x48, 0x33, 0xbf, 0x01, 0x01, 0x68, 0x9d, 0x12, 0x20, 0xab, 0x93, 0xf6, 0x0f, 0x49, 0x27, + 0x05, 0x24, 0x9d, 0x62, 0xc7, 0x09, 0x74, 0xd2, 0x76, 0x23, 0xe9, 0xa4, 0x80, 0xa4, 0x53, 0x6c, + 0x50, 0x41, 0x76, 0xa9, 0xba, 0x93, 0x94, 0x5d, 0x2a, 0x8a, 0x94, 0x5d, 0x55, 0x3d, 0x8e, 0x3c, + 0x81, 0x37, 0xa4, 0x06, 0x47, 0x5a, 0xb2, 0x77, 0x16, 0xd5, 0xd6, 0xab, 0x50, 0x21, 0x3b, 0x82, + 0x66, 0x49, 0x1f, 0x23, 0xeb, 0xea, 0xe7, 0x9d, 0x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x8b, 0x1f, + 0xc3, 0x5c, 0x32, 0x12, 0x92, 0xc5, 0x02, 0x39, 0x30, 0x6b, 0xab, 0x4a, 0x73, 0xa2, 0xb0, 0xfb, + 0xd1, 0x1f, 0x17, 0xed, 0xfa, 0x8b, 0x8b, 0x76, 0xfd, 0xef, 0x8b, 0x76, 0xfd, 0xd7, 0xcb, 0x76, + 0xed, 0xc5, 0x65, 0xbb, 0xf6, 0xe7, 0x65, 0xbb, 0xf6, 0xcd, 0x9d, 0xcc, 0x8f, 0xed, 0xcf, 0x1d, + 0xdf, 0xd8, 0xa3, 0x3e, 0xf6, 0x19, 0x1e, 0x1b, 0x4e, 0xff, 0x34, 0xfa, 0xab, 0x47, 0xf0, 0x7b, + 0xfb, 0xf0, 0x5a, 0xf8, 0x4b, 0xf8, 0xbd, 0xff, 0x02, 0x00, 0x00, 0xff, 0xff, 0x84, 0xea, 0x92, + 0x45, 0x0e, 0x11, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1267,6 +1353,10 @@ type MsgClient interface { CouncilorUnpause(ctx context.Context, in *MsgCouncilorUnpause, opts ...grpc.CallOption) (*MsgCouncilorUnpauseResponse, error) // CouncilorActivate - signal to the network that Councilor wishes to regain voting ability after unannounced absence CouncilorActivate(ctx context.Context, in *MsgCouncilorActivate, opts ...grpc.CallOption) (*MsgCouncilorActivateResponse, error) + // PollCreate defines a method to create a new poll proposal + PollCreate(ctx context.Context, in *MsgPollCreate, opts ...grpc.CallOption) (*MsgPollCreateResponse, error) + // PollVote defines a method for voting a poll proposal + PollVote(ctx context.Context, in *MsgPollVote, opts ...grpc.CallOption) (*MsgPollVoteResponse, error) } type msgClient struct { @@ -1493,6 +1583,24 @@ func (c *msgClient) CouncilorActivate(ctx context.Context, in *MsgCouncilorActiv return out, nil } +func (c *msgClient) PollCreate(ctx context.Context, in *MsgPollCreate, opts ...grpc.CallOption) (*MsgPollCreateResponse, error) { + out := new(MsgPollCreateResponse) + err := c.cc.Invoke(ctx, "/kira.gov.Msg/PollCreate", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) PollVote(ctx context.Context, in *MsgPollVote, opts ...grpc.CallOption) (*MsgPollVoteResponse, error) { + out := new(MsgPollVoteResponse) + err := c.cc.Invoke(ctx, "/kira.gov.Msg/PollVote", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // MsgServer is the server API for Msg service. type MsgServer interface { // SubmitProposal defines a method to create new proposal given a content. @@ -1543,6 +1651,10 @@ type MsgServer interface { CouncilorUnpause(context.Context, *MsgCouncilorUnpause) (*MsgCouncilorUnpauseResponse, error) // CouncilorActivate - signal to the network that Councilor wishes to regain voting ability after unannounced absence CouncilorActivate(context.Context, *MsgCouncilorActivate) (*MsgCouncilorActivateResponse, error) + // PollCreate defines a method to create a new poll proposal + PollCreate(context.Context, *MsgPollCreate) (*MsgPollCreateResponse, error) + // PollVote defines a method for voting a poll proposal + PollVote(context.Context, *MsgPollVote) (*MsgPollVoteResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. @@ -1621,6 +1733,12 @@ func (*UnimplementedMsgServer) CouncilorUnpause(ctx context.Context, req *MsgCou func (*UnimplementedMsgServer) CouncilorActivate(ctx context.Context, req *MsgCouncilorActivate) (*MsgCouncilorActivateResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method CouncilorActivate not implemented") } +func (*UnimplementedMsgServer) PollCreate(ctx context.Context, req *MsgPollCreate) (*MsgPollCreateResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method PollCreate not implemented") +} +func (*UnimplementedMsgServer) PollVote(ctx context.Context, req *MsgPollVote) (*MsgPollVoteResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method PollVote not implemented") +} func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) @@ -2058,6 +2176,42 @@ func _Msg_CouncilorActivate_Handler(srv interface{}, ctx context.Context, dec fu return interceptor(ctx, in, info, handler) } +func _Msg_PollCreate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgPollCreate) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).PollCreate(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/kira.gov.Msg/PollCreate", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).PollCreate(ctx, req.(*MsgPollCreate)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_PollVote_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgPollVote) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).PollVote(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/kira.gov.Msg/PollVote", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).PollVote(ctx, req.(*MsgPollVote)) + } + return interceptor(ctx, in, info, handler) +} + var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "kira.gov.Msg", HandlerType: (*MsgServer)(nil), @@ -2158,6 +2312,14 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "CouncilorActivate", Handler: _Msg_CouncilorActivate_Handler, }, + { + MethodName: "PollCreate", + Handler: _Msg_PollCreate_Handler, + }, + { + MethodName: "PollVote", + Handler: _Msg_PollVote_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "kira/gov/tx.proto", @@ -2871,6 +3033,57 @@ func (m *MsgCouncilorActivateResponse) MarshalToSizedBuffer(dAtA []byte) (int, e return len(dAtA) - i, nil } +func (m *MsgPollCreateResponse) 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 *MsgPollCreateResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgPollCreateResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.PollID != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.PollID)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *MsgPollVoteResponse) 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 *MsgPollVoteResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgPollVoteResponse) 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 @@ -3168,6 +3381,27 @@ func (m *MsgCouncilorActivateResponse) Size() (n int) { return n } +func (m *MsgPollCreateResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PollID != 0 { + n += 1 + sovTx(uint64(m.PollID)) + } + return n +} + +func (m *MsgPollVoteResponse) 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 } @@ -4842,6 +5076,125 @@ func (m *MsgCouncilorActivateResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgPollCreateResponse) 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: MsgPollCreateResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgPollCreateResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PollID", wireType) + } + m.PollID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PollID |= 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 *MsgPollVoteResponse) 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: MsgPollVoteResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgPollVoteResponse: 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 diff --git a/x/gov/types/types.go b/x/gov/types/types.go index aa7c859d0..7ac9a0114 100644 --- a/x/gov/types/types.go +++ b/x/gov/types/types.go @@ -1,117 +1,117 @@ -package types - -import ( - "fmt" - - "github.com/cosmos/cosmos-sdk/types" -) - -// NewPermissions generates a new permissions struct. -func NewPermissions(whitelist []PermValue, blacklist []PermValue) *Permissions { - var b []uint32 - for _, bv := range blacklist { - b = append(b, uint32(bv)) - } - - var w []uint32 - for _, wv := range whitelist { - w = append(w, uint32(wv)) - } - - return &Permissions{ - Blacklist: b, - Whitelist: w, - } -} - -// IsBlacklisted returns if the perm is blacklisted or not. -func (p *Permissions) IsBlacklisted(perm PermValue) bool { - for _, bPerm := range p.Blacklist { - if bPerm == uint32(perm) { - return true - } - } - - return false -} - -// IsWhitelisted returns if the perm is whitelisted or not. -func (p *Permissions) IsWhitelisted(perm PermValue) bool { - for _, bPerm := range p.Whitelist { - if bPerm == uint32(perm) { - return true - } - } - - return false -} - -// AddToWhitelist adds permission to whitelist. -func (p *Permissions) AddToWhitelist(perm PermValue) error { - if p.IsBlacklisted(perm) { - return fmt.Errorf("permission is blacklisted") - } - - if p.IsWhitelisted(perm) { - return fmt.Errorf("permission is already whitelisted") - } - - p.Whitelist = append(p.Whitelist, uint32(perm)) - return nil -} - -// AddToBlacklist adds permission to blacklist. It fails if the permission is whitelisted. -func (p *Permissions) AddToBlacklist(perm PermValue) error { - if p.IsWhitelisted(perm) { - return fmt.Errorf("permission is whitelisted") - } - - if p.IsBlacklisted(perm) { - return fmt.Errorf("permission is already blacklisted") - } - - p.Blacklist = append(p.Blacklist, uint32(perm)) - return nil -} - -// RemoveFromWhitelist removes permission from whitelist. It fails if permission is not -// whitelisted. -func (m *Permissions) RemoveFromWhitelist(perm PermValue) error { - if !m.IsWhitelisted(perm) { - return fmt.Errorf("permission is not whitelisted") - } - - for i, v := range m.Whitelist { - if v == uint32(perm) { - m.Whitelist = append(m.Whitelist[:i], m.Whitelist[i+1:]...) - return nil - } - } - - return nil -} - -func (m *Permissions) RemoveFromBlacklist(perm PermValue) error { - if !m.IsBlacklisted(perm) { - return fmt.Errorf("permission is not blacklisted") - } - - for i, v := range m.Blacklist { - if v == uint32(perm) { - m.Blacklist = append(m.Blacklist[:i], m.Blacklist[i+1:]...) - return nil - } - } - - return nil -} - -func NewCouncilor( - address types.AccAddress, - status CouncilorStatus, -) Councilor { - return Councilor{ - Address: address, - Status: status, - } -} +package types + +import ( + "fmt" + + "github.com/cosmos/cosmos-sdk/types" +) + +// NewPermissions generates a new permissions struct. +func NewPermissions(whitelist []PermValue, blacklist []PermValue) *Permissions { + var b []uint32 + for _, bv := range blacklist { + b = append(b, uint32(bv)) + } + + var w []uint32 + for _, wv := range whitelist { + w = append(w, uint32(wv)) + } + + return &Permissions{ + Blacklist: b, + Whitelist: w, + } +} + +// IsBlacklisted returns if the perm is blacklisted or not. +func (p *Permissions) IsBlacklisted(perm PermValue) bool { + for _, bPerm := range p.Blacklist { + if bPerm == uint32(perm) { + return true + } + } + + return false +} + +// IsWhitelisted returns if the perm is whitelisted or not. +func (p *Permissions) IsWhitelisted(perm PermValue) bool { + for _, bPerm := range p.Whitelist { + if bPerm == uint32(perm) { + return true + } + } + + return false +} + +// AddToWhitelist adds permission to whitelist. +func (p *Permissions) AddToWhitelist(perm PermValue) error { + if p.IsBlacklisted(perm) { + return fmt.Errorf("permission is blacklisted") + } + + if p.IsWhitelisted(perm) { + return fmt.Errorf("permission is already whitelisted") + } + + p.Whitelist = append(p.Whitelist, uint32(perm)) + return nil +} + +// AddToBlacklist adds permission to blacklist. It fails if the permission is whitelisted. +func (p *Permissions) AddToBlacklist(perm PermValue) error { + if p.IsWhitelisted(perm) { + return fmt.Errorf("permission is whitelisted") + } + + if p.IsBlacklisted(perm) { + return fmt.Errorf("permission is already blacklisted") + } + + p.Blacklist = append(p.Blacklist, uint32(perm)) + return nil +} + +// RemoveFromWhitelist removes permission from whitelist. It fails if permission is not +// whitelisted. +func (m *Permissions) RemoveFromWhitelist(perm PermValue) error { + if !m.IsWhitelisted(perm) { + return fmt.Errorf("permission is not whitelisted") + } + + for i, v := range m.Whitelist { + if v == uint32(perm) { + m.Whitelist = append(m.Whitelist[:i], m.Whitelist[i+1:]...) + return nil + } + } + + return nil +} + +func (m *Permissions) RemoveFromBlacklist(perm PermValue) error { + if !m.IsBlacklisted(perm) { + return fmt.Errorf("permission is not blacklisted") + } + + for i, v := range m.Blacklist { + if v == uint32(perm) { + m.Blacklist = append(m.Blacklist[:i], m.Blacklist[i+1:]...) + return nil + } + } + + return nil +} + +func NewCouncilor( + address types.AccAddress, + status CouncilorStatus, +) Councilor { + return Councilor{ + Address: address, + Status: status, + } +} diff --git a/x/gov/types/types_test.go b/x/gov/types/types_test.go index 89c67d8c3..8980c2bb6 100644 --- a/x/gov/types/types_test.go +++ b/x/gov/types/types_test.go @@ -1,97 +1,97 @@ -package types_test - -import ( - "os" - "testing" - - "github.com/KiraCore/sekai/app" - "github.com/KiraCore/sekai/x/gov/types" - "github.com/stretchr/testify/require" -) - -func TestMain(m *testing.M) { - app.SetConfig() - os.Exit(m.Run()) -} - -func TestPermissions_IsBlacklisted(t *testing.T) { - perms := types.NewPermissions( - []types.PermValue{}, - []types.PermValue{types.PermClaimValidator}, - ) - - require.True(t, perms.IsBlacklisted(types.PermClaimValidator)) - require.False(t, perms.IsBlacklisted(types.PermSetPermissions)) -} - -func TestPermissions_IsWhitelisted(t *testing.T) { - perms := types.NewPermissions([]types.PermValue{types.PermClaimValidator}, nil) - - require.True(t, perms.IsWhitelisted(types.PermClaimValidator)) - require.False(t, perms.IsWhitelisted(types.PermSetPermissions)) -} - -func TestPermissions_AddWhitelist(t *testing.T) { - perms := types.NewPermissions(nil, nil) - - require.False(t, perms.IsWhitelisted(types.PermClaimValidator)) - - err := perms.AddToWhitelist(types.PermSetPermissions) - require.NoError(t, err) - require.True(t, perms.IsWhitelisted(types.PermSetPermissions)) - - // Add to whitelist value blacklisted gives error - err = perms.AddToBlacklist(types.PermClaimValidator) - require.NoError(t, err) - - err = perms.AddToWhitelist(types.PermClaimValidator) - require.EqualError(t, err, "permission is blacklisted") -} - -func TestPermissions_AddBlacklist(t *testing.T) { - perms := types.NewPermissions(nil, nil) - - require.False(t, perms.IsBlacklisted(types.PermSetPermissions)) - err := perms.AddToBlacklist(types.PermSetPermissions) - require.NoError(t, err) - require.True(t, perms.IsBlacklisted(types.PermSetPermissions)) - - // Add to blacklist when is whitelisted gives error - err = perms.AddToWhitelist(types.PermClaimValidator) - require.NoError(t, err) - - err = perms.AddToBlacklist(types.PermClaimValidator) - require.EqualError(t, err, "permission is whitelisted") -} - -func TestPermissions_RemoveFromWhitelist(t *testing.T) { - perms := types.NewPermissions([]types.PermValue{ - types.PermSetPermissions, - }, nil) - - // It fails if permission is not whitelisted. - err := perms.RemoveFromWhitelist(types.PermClaimCouncilor) - require.EqualError(t, err, "permission is not whitelisted") - - err = perms.RemoveFromWhitelist(types.PermSetPermissions) - require.NoError(t, err) - - require.False(t, perms.IsWhitelisted(types.PermSetPermissions)) -} - -func TestPermissions_RemoveFromBlacklist(t *testing.T) { - perms := types.NewPermissions(nil, - []types.PermValue{ - types.PermSetPermissions, - }, - ) - - // It fails if permission is not blacklisted. - err := perms.RemoveFromBlacklist(types.PermClaimCouncilor) - require.EqualError(t, err, "permission is not blacklisted") - - err = perms.RemoveFromBlacklist(types.PermSetPermissions) - require.NoError(t, err) - - require.False(t, perms.IsBlacklisted(types.PermSetPermissions)) -} +package types_test + +import ( + "os" + "testing" + + "github.com/KiraCore/sekai/app" + "github.com/KiraCore/sekai/x/gov/types" + "github.com/stretchr/testify/require" +) + +func TestMain(m *testing.M) { + app.SetConfig() + os.Exit(m.Run()) +} + +func TestPermissions_IsBlacklisted(t *testing.T) { + perms := types.NewPermissions( + []types.PermValue{}, + []types.PermValue{types.PermClaimValidator}, + ) + + require.True(t, perms.IsBlacklisted(types.PermClaimValidator)) + require.False(t, perms.IsBlacklisted(types.PermSetPermissions)) +} + +func TestPermissions_IsWhitelisted(t *testing.T) { + perms := types.NewPermissions([]types.PermValue{types.PermClaimValidator}, nil) + + require.True(t, perms.IsWhitelisted(types.PermClaimValidator)) + require.False(t, perms.IsWhitelisted(types.PermSetPermissions)) +} + +func TestPermissions_AddWhitelist(t *testing.T) { + perms := types.NewPermissions(nil, nil) + + require.False(t, perms.IsWhitelisted(types.PermClaimValidator)) + + err := perms.AddToWhitelist(types.PermSetPermissions) + require.NoError(t, err) + require.True(t, perms.IsWhitelisted(types.PermSetPermissions)) + + // Add to whitelist value blacklisted gives error + err = perms.AddToBlacklist(types.PermClaimValidator) + require.NoError(t, err) + + err = perms.AddToWhitelist(types.PermClaimValidator) + require.EqualError(t, err, "permission is blacklisted") +} + +func TestPermissions_AddBlacklist(t *testing.T) { + perms := types.NewPermissions(nil, nil) + + require.False(t, perms.IsBlacklisted(types.PermSetPermissions)) + err := perms.AddToBlacklist(types.PermSetPermissions) + require.NoError(t, err) + require.True(t, perms.IsBlacklisted(types.PermSetPermissions)) + + // Add to blacklist when is whitelisted gives error + err = perms.AddToWhitelist(types.PermClaimValidator) + require.NoError(t, err) + + err = perms.AddToBlacklist(types.PermClaimValidator) + require.EqualError(t, err, "permission is whitelisted") +} + +func TestPermissions_RemoveFromWhitelist(t *testing.T) { + perms := types.NewPermissions([]types.PermValue{ + types.PermSetPermissions, + }, nil) + + // It fails if permission is not whitelisted. + err := perms.RemoveFromWhitelist(types.PermClaimCouncilor) + require.EqualError(t, err, "permission is not whitelisted") + + err = perms.RemoveFromWhitelist(types.PermSetPermissions) + require.NoError(t, err) + + require.False(t, perms.IsWhitelisted(types.PermSetPermissions)) +} + +func TestPermissions_RemoveFromBlacklist(t *testing.T) { + perms := types.NewPermissions(nil, + []types.PermValue{ + types.PermSetPermissions, + }, + ) + + // It fails if permission is not blacklisted. + err := perms.RemoveFromBlacklist(types.PermClaimCouncilor) + require.EqualError(t, err, "permission is not blacklisted") + + err = perms.RemoveFromBlacklist(types.PermSetPermissions) + require.NoError(t, err) + + require.False(t, perms.IsBlacklisted(types.PermSetPermissions)) +} diff --git a/x/gov/types/vote.go b/x/gov/types/vote.go index 4a831184a..662177a79 100644 --- a/x/gov/types/vote.go +++ b/x/gov/types/vote.go @@ -1,79 +1,79 @@ -package types - -import ( - "github.com/cosmos/cosmos-sdk/types" - sdk "github.com/cosmos/cosmos-sdk/types" -) - -type Votes []Vote - -func NewVote(proposalID uint64, addr types.AccAddress, option VoteOption, slash sdk.Dec) Vote { - return Vote{ - ProposalId: proposalID, - Voter: addr, - Option: option, - Slash: slash, - } -} - -type CalculatedVotes struct { - votes map[VoteOption]uint64 - actorsWithVeto uint64 - total uint64 -} - -func CalculateVotes(votes Votes, actorsWithVeto uint64) CalculatedVotes { - votesMap := make(map[VoteOption]uint64) - for _, vote := range votes { - votesMap[vote.Option]++ - } - - return CalculatedVotes{ - total: uint64(len(votes)), - actorsWithVeto: actorsWithVeto, - votes: votesMap, - } -} - -func (c CalculatedVotes) TotalVotes() uint64 { - return c.total -} - -func (c CalculatedVotes) YesVotes() uint64 { - return c.votes[OptionYes] -} - -func (c CalculatedVotes) NoVotes() uint64 { - return c.votes[OptionNo] -} - -func (c CalculatedVotes) AbstainVotes() uint64 { - return c.votes[OptionAbstain] -} - -func (c CalculatedVotes) VetoVotes() uint64 { - return c.votes[OptionNoWithVeto] -} - -func (c CalculatedVotes) ProcessResult() VoteResult { - if c.actorsWithVeto != 0 { - percentageActorsWithVeto := (float32(c.votes[OptionNoWithVeto]) / float32(c.actorsWithVeto)) * 100 - if percentageActorsWithVeto >= 50 { - return RejectedWithVeto - } - } - - yesPercentage := (float32(c.votes[OptionYes]) / float32(c.total)) * 100 - if yesPercentage > 50.00 { - return Passed - } - - sumOtherThanYes := c.votes[OptionNo] + c.votes[OptionAbstain] + c.votes[OptionNoWithVeto] - sumPercentage := (float32(sumOtherThanYes) / float32(c.total)) * 100 - - if sumPercentage >= 50 { - return Rejected - } - - return Unknown -} +package types + +import ( + "github.com/cosmos/cosmos-sdk/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +type Votes []Vote + +func NewVote(proposalID uint64, addr types.AccAddress, option VoteOption, slash sdk.Dec) Vote { + return Vote{ + ProposalId: proposalID, + Voter: addr, + Option: option, + Slash: slash, + } +} + +type CalculatedVotes struct { + votes map[VoteOption]uint64 + actorsWithVeto uint64 + total uint64 +} + +func CalculateVotes(votes Votes, actorsWithVeto uint64) CalculatedVotes { + votesMap := make(map[VoteOption]uint64) + for _, vote := range votes { + votesMap[vote.Option]++ + } + + return CalculatedVotes{ + total: uint64(len(votes)), + actorsWithVeto: actorsWithVeto, + votes: votesMap, + } +} + +func (c CalculatedVotes) TotalVotes() uint64 { + return c.total +} + +func (c CalculatedVotes) YesVotes() uint64 { + return c.votes[OptionYes] +} + +func (c CalculatedVotes) NoVotes() uint64 { + return c.votes[OptionNo] +} + +func (c CalculatedVotes) AbstainVotes() uint64 { + return c.votes[OptionAbstain] +} + +func (c CalculatedVotes) VetoVotes() uint64 { + return c.votes[OptionNoWithVeto] +} + +func (c CalculatedVotes) ProcessResult() VoteResult { + if c.actorsWithVeto != 0 { + percentageActorsWithVeto := (float32(c.votes[OptionNoWithVeto]) / float32(c.actorsWithVeto)) * 100 + if percentageActorsWithVeto >= 50 { + return RejectedWithVeto + } + } + + yesPercentage := (float32(c.votes[OptionYes]) / float32(c.total)) * 100 + if yesPercentage > 50.00 { + return Passed + } + + sumOtherThanYes := c.votes[OptionNo] + c.votes[OptionAbstain] + c.votes[OptionNoWithVeto] + sumPercentage := (float32(sumOtherThanYes) / float32(c.total)) * 100 + + if sumPercentage >= 50 { + return Rejected + } + + return Unknown +} diff --git a/x/gov/types/vote_test.go b/x/gov/types/vote_test.go index 2c2f009f2..ad3313f0f 100644 --- a/x/gov/types/vote_test.go +++ b/x/gov/types/vote_test.go @@ -1,106 +1,106 @@ -package types - -import ( - "testing" - - "github.com/cosmos/cosmos-sdk/types" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/require" -) - -func TestVotes_Getters(t *testing.T) { - proposalID := uint64(12345) - addr := types.AccAddress("some addr") - - votes := Votes{ - NewVote(proposalID, addr, OptionYes, sdk.ZeroDec()), - NewVote(proposalID, addr, OptionYes, sdk.ZeroDec()), - NewVote(proposalID, addr, OptionYes, sdk.ZeroDec()), - NewVote(proposalID, addr, OptionYes, sdk.ZeroDec()), - NewVote(proposalID, addr, OptionYes, sdk.ZeroDec()), - NewVote(proposalID, addr, OptionNoWithVeto, sdk.ZeroDec()), - NewVote(proposalID, addr, OptionNoWithVeto, sdk.ZeroDec()), - NewVote(proposalID, addr, OptionNoWithVeto, sdk.ZeroDec()), - NewVote(proposalID, addr, OptionAbstain, sdk.ZeroDec()), - NewVote(proposalID, addr, OptionAbstain, sdk.ZeroDec()), - NewVote(proposalID, addr, OptionNo, sdk.ZeroDec()), - } - - calculatedVotes := CalculateVotes(votes, 3) - require.Equal(t, uint64(len(votes)), calculatedVotes.TotalVotes()) - require.Equal(t, uint64(5), calculatedVotes.YesVotes()) - require.Equal(t, uint64(1), calculatedVotes.NoVotes()) - require.Equal(t, uint64(2), calculatedVotes.AbstainVotes()) - require.Equal(t, uint64(3), calculatedVotes.VetoVotes()) -} - -func TestCalculatedVotes_ProcessResult(t *testing.T) { - proposalID := uint64(12345) - addr := types.AccAddress("some addr") - - tests := []struct { - name string - votes Votes - actorsWithVeto uint64 - result VoteResult - }{ - { - name: "more than 50% Yes", - votes: Votes{ - NewVote(proposalID, addr, OptionYes, sdk.ZeroDec()), - NewVote(proposalID, addr, OptionYes, sdk.ZeroDec()), - NewVote(proposalID, addr, OptionYes, sdk.ZeroDec()), - NewVote(proposalID, addr, OptionYes, sdk.ZeroDec()), - NewVote(proposalID, addr, OptionYes, sdk.ZeroDec()), - NewVote(proposalID, addr, OptionYes, sdk.ZeroDec()), - NewVote(proposalID, addr, OptionNoWithVeto, sdk.ZeroDec()), - NewVote(proposalID, addr, OptionNo, sdk.ZeroDec()), - NewVote(proposalID, addr, OptionAbstain, sdk.ZeroDec()), - NewVote(proposalID, addr, OptionAbstain, sdk.ZeroDec()), - }, - actorsWithVeto: 3, - result: Passed, - }, - { - name: "different votes than yes equal or more than 50 : equal 50%", - votes: Votes{ - NewVote(proposalID, addr, OptionYes, sdk.ZeroDec()), - NewVote(proposalID, addr, OptionYes, sdk.ZeroDec()), - NewVote(proposalID, addr, OptionYes, sdk.ZeroDec()), - NewVote(proposalID, addr, OptionYes, sdk.ZeroDec()), - NewVote(proposalID, addr, OptionYes, sdk.ZeroDec()), - NewVote(proposalID, addr, OptionNoWithVeto, sdk.ZeroDec()), - NewVote(proposalID, addr, OptionNo, sdk.ZeroDec()), - NewVote(proposalID, addr, OptionNo, sdk.ZeroDec()), - NewVote(proposalID, addr, OptionAbstain, sdk.ZeroDec()), - NewVote(proposalID, addr, OptionAbstain, sdk.ZeroDec()), - }, - result: Rejected, - }, - { - name: "50% or more of actors with Veto reject by voting No With Veto", - votes: Votes{ - NewVote(proposalID, addr, OptionYes, sdk.ZeroDec()), - NewVote(proposalID, addr, OptionYes, sdk.ZeroDec()), - NewVote(proposalID, addr, OptionYes, sdk.ZeroDec()), - NewVote(proposalID, addr, OptionYes, sdk.ZeroDec()), - NewVote(proposalID, addr, OptionYes, sdk.ZeroDec()), - NewVote(proposalID, addr, OptionNoWithVeto, sdk.ZeroDec()), - NewVote(proposalID, addr, OptionNoWithVeto, sdk.ZeroDec()), - NewVote(proposalID, addr, OptionNo, sdk.ZeroDec()), - NewVote(proposalID, addr, OptionAbstain, sdk.ZeroDec()), - NewVote(proposalID, addr, OptionAbstain, sdk.ZeroDec()), - }, - actorsWithVeto: 3, - result: RejectedWithVeto, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - calc := CalculateVotes(tt.votes, tt.actorsWithVeto) - require.Equal(t, tt.result, calc.ProcessResult()) - }) - } -} +package types + +import ( + "testing" + + "github.com/cosmos/cosmos-sdk/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" +) + +func TestVotes_Getters(t *testing.T) { + proposalID := uint64(12345) + addr := types.AccAddress("some addr") + + votes := Votes{ + NewVote(proposalID, addr, OptionYes, sdk.ZeroDec()), + NewVote(proposalID, addr, OptionYes, sdk.ZeroDec()), + NewVote(proposalID, addr, OptionYes, sdk.ZeroDec()), + NewVote(proposalID, addr, OptionYes, sdk.ZeroDec()), + NewVote(proposalID, addr, OptionYes, sdk.ZeroDec()), + NewVote(proposalID, addr, OptionNoWithVeto, sdk.ZeroDec()), + NewVote(proposalID, addr, OptionNoWithVeto, sdk.ZeroDec()), + NewVote(proposalID, addr, OptionNoWithVeto, sdk.ZeroDec()), + NewVote(proposalID, addr, OptionAbstain, sdk.ZeroDec()), + NewVote(proposalID, addr, OptionAbstain, sdk.ZeroDec()), + NewVote(proposalID, addr, OptionNo, sdk.ZeroDec()), + } + + calculatedVotes := CalculateVotes(votes, 3) + require.Equal(t, uint64(len(votes)), calculatedVotes.TotalVotes()) + require.Equal(t, uint64(5), calculatedVotes.YesVotes()) + require.Equal(t, uint64(1), calculatedVotes.NoVotes()) + require.Equal(t, uint64(2), calculatedVotes.AbstainVotes()) + require.Equal(t, uint64(3), calculatedVotes.VetoVotes()) +} + +func TestCalculatedVotes_ProcessResult(t *testing.T) { + proposalID := uint64(12345) + addr := types.AccAddress("some addr") + + tests := []struct { + name string + votes Votes + actorsWithVeto uint64 + result VoteResult + }{ + { + name: "more than 50% Yes", + votes: Votes{ + NewVote(proposalID, addr, OptionYes, sdk.ZeroDec()), + NewVote(proposalID, addr, OptionYes, sdk.ZeroDec()), + NewVote(proposalID, addr, OptionYes, sdk.ZeroDec()), + NewVote(proposalID, addr, OptionYes, sdk.ZeroDec()), + NewVote(proposalID, addr, OptionYes, sdk.ZeroDec()), + NewVote(proposalID, addr, OptionYes, sdk.ZeroDec()), + NewVote(proposalID, addr, OptionNoWithVeto, sdk.ZeroDec()), + NewVote(proposalID, addr, OptionNo, sdk.ZeroDec()), + NewVote(proposalID, addr, OptionAbstain, sdk.ZeroDec()), + NewVote(proposalID, addr, OptionAbstain, sdk.ZeroDec()), + }, + actorsWithVeto: 3, + result: Passed, + }, + { + name: "different votes than yes equal or more than 50 : equal 50%", + votes: Votes{ + NewVote(proposalID, addr, OptionYes, sdk.ZeroDec()), + NewVote(proposalID, addr, OptionYes, sdk.ZeroDec()), + NewVote(proposalID, addr, OptionYes, sdk.ZeroDec()), + NewVote(proposalID, addr, OptionYes, sdk.ZeroDec()), + NewVote(proposalID, addr, OptionYes, sdk.ZeroDec()), + NewVote(proposalID, addr, OptionNoWithVeto, sdk.ZeroDec()), + NewVote(proposalID, addr, OptionNo, sdk.ZeroDec()), + NewVote(proposalID, addr, OptionNo, sdk.ZeroDec()), + NewVote(proposalID, addr, OptionAbstain, sdk.ZeroDec()), + NewVote(proposalID, addr, OptionAbstain, sdk.ZeroDec()), + }, + result: Rejected, + }, + { + name: "50% or more of actors with Veto reject by voting No With Veto", + votes: Votes{ + NewVote(proposalID, addr, OptionYes, sdk.ZeroDec()), + NewVote(proposalID, addr, OptionYes, sdk.ZeroDec()), + NewVote(proposalID, addr, OptionYes, sdk.ZeroDec()), + NewVote(proposalID, addr, OptionYes, sdk.ZeroDec()), + NewVote(proposalID, addr, OptionYes, sdk.ZeroDec()), + NewVote(proposalID, addr, OptionNoWithVeto, sdk.ZeroDec()), + NewVote(proposalID, addr, OptionNoWithVeto, sdk.ZeroDec()), + NewVote(proposalID, addr, OptionNo, sdk.ZeroDec()), + NewVote(proposalID, addr, OptionAbstain, sdk.ZeroDec()), + NewVote(proposalID, addr, OptionAbstain, sdk.ZeroDec()), + }, + actorsWithVeto: 3, + result: RejectedWithVeto, + }, + } + + for _, tt := range tests { + tt := tt + t.Run(tt.name, func(t *testing.T) { + calc := CalculateVotes(tt.votes, tt.actorsWithVeto) + require.Equal(t, tt.result, calc.ProcessResult()) + }) + } +} diff --git a/x/layer2/client/cli/query.go b/x/layer2/client/cli/query.go new file mode 100644 index 000000000..2011d12eb --- /dev/null +++ b/x/layer2/client/cli/query.go @@ -0,0 +1,122 @@ +package cli + +import ( + "context" + + "github.com/spf13/cobra" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + + "github.com/KiraCore/sekai/x/layer2/types" +) + +// NewQueryCmd returns a root CLI command handler for all x/layer2 transaction commands. +func NewQueryCmd() *cobra.Command { + queryCmd := &cobra.Command{ + Use: types.RouterKey, + Short: "query commands for the layer2 module", + } + queryCmd.AddCommand( + GetCmdQueryExecutionRegistrar(), + GetCmdQueryAllDapps(), + GetCmdQueryTransferDapp(), + GetCmdQueryGlobalTokens(), + ) + + return queryCmd +} + +func GetCmdQueryExecutionRegistrar() *cobra.Command { + cmd := &cobra.Command{ + Use: "execution-registrar [dapp-name]", + Short: "Queries a execution registrar for a dapp", + Args: cobra.MinimumNArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + + queryClient := types.NewQueryClient(clientCtx) + res, err := queryClient.ExecutionRegistrar(context.Background(), &types.QueryExecutionRegistrarRequest{ + Identifier: args[0], + }) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +func GetCmdQueryAllDapps() *cobra.Command { + cmd := &cobra.Command{ + Use: "all-dapps", + Short: "Queries all dapps", + Args: cobra.MinimumNArgs(0), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + + queryClient := types.NewQueryClient(clientCtx) + res, err := queryClient.AllDapps(context.Background(), &types.QueryAllDappsRequest{}) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +func GetCmdQueryTransferDapp() *cobra.Command { + cmd := &cobra.Command{ + Use: "transfer-dapps", + Short: "Queries transfer dapps", + Args: cobra.MinimumNArgs(0), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + + queryClient := types.NewQueryClient(clientCtx) + res, err := queryClient.TransferDapps(context.Background(), &types.QueryTransferDappsRequest{}) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +func GetCmdQueryGlobalTokens() *cobra.Command { + cmd := &cobra.Command{ + Use: "global-tokens", + Short: "Queries global tokens", + Args: cobra.MinimumNArgs(0), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + + queryClient := types.NewQueryClient(clientCtx) + res, err := queryClient.GlobalTokens(context.Background(), &types.QueryGlobalTokensRequest{}) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/layer2/client/cli/tx.go b/x/layer2/client/cli/tx.go new file mode 100644 index 000000000..2fecba206 --- /dev/null +++ b/x/layer2/client/cli/tx.go @@ -0,0 +1,1360 @@ +package cli + +import ( + "fmt" + "strconv" + "strings" + + govtypes "github.com/KiraCore/sekai/x/gov/types" + "github.com/KiraCore/sekai/x/layer2/types" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/spf13/cobra" +) + +const ( + FlagTitle = "title" + FlagDescription = "description" + FlagDappName = "dapp-name" + FlagDappDescription = "dapp-description" + FlagDenom = "denom" + FlagWebsite = "website" + FlagLogo = "logo" + FlagSocial = "social" + FlagDocs = "docs" + FlagControllerRoles = "controller-roles" + FlagControllerAccounts = "controller-accounts" + FlagBinaryInfo = "binary-info" + FlagLpPoolConfig = "lp-pool-config" + FlagIssuranceConfig = "issurance-config" + FlagUpdateTimeMax = "update-time-max" + FlagExecutorsMin = "executors-min" + FlagExecutorsMax = "executors-max" + FlagVerifiersMin = "verifiers-min" + FlagDappStatus = "dapp-status" + FlagBond = "bond" + FlagVoteQuorum = "vote-quorum" + FlagVotePeriod = "vote-period" + FlagVoteEnactment = "vote-enactment" + FlagAddress = "address" + FlagAmount = "amount" +) + +// NewTxCmd returns a root CLI command handler for all x/bank transaction commands. +func NewTxCmd() *cobra.Command { + txCmd := &cobra.Command{ + Use: types.ModuleName, + Short: "Tokens sub commands", + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + txCmd.AddCommand( + GetTxCreateDappProposalCmd(), + GetTxBondDappProposalCmd(), + GetTxReclaimDappBondProposalCmd(), + GetTxJoinDappVerifierWithBondCmd(), + GetTxExitDappCmd(), + GetTxExecuteDappTxCmd(), + GetTxDenounceLeaderTxCmd(), + GetTxTransitionDappCmd(), + GetTxApproveDappTransitionCmd(), + GetTxRejectDappTransitionCmd(), + GetTxProposalJoinDappCmd(), + GetTxProposalUpsertDappCmd(), + GetTxRedeemDappPoolTxCmd(), + GetTxSwapDappPoolTxCmd(), + GetTxConvertDappPoolTxCmd(), + GetTxPauseDappTxCmd(), + GetTxUnPauseDappTxCmd(), + GetTxReactivateDappTxCmd(), + GetTxTransferDappTxCmd(), + GetTxMintCreateFtTxCmd(), + GetTxMintCreateNftTxCmd(), + GetTxMintIssueTxCmd(), + GetTxMintBurnTxCmd(), + ) + + return txCmd +} + +// GetTxCreateDappProposalCmd implement cli command for MsgCreateDappProposal +func GetTxCreateDappProposalCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "create-dapp-proposal", + Short: "Submit a proposal to launch a dapp", + Args: cobra.MinimumNArgs(0), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + name, err := cmd.Flags().GetString(FlagDappName) + if err != nil { + return fmt.Errorf("invalid name: %w", err) + } + denom, err := cmd.Flags().GetString(FlagDenom) + if err != nil { + return fmt.Errorf("invalid denom: %w", err) + } + description, err := cmd.Flags().GetString(FlagDappDescription) + if err != nil { + return fmt.Errorf("invalid description: %w", err) + } + website, err := cmd.Flags().GetString(FlagWebsite) + if err != nil { + return fmt.Errorf("invalid website: %w", err) + } + logo, err := cmd.Flags().GetString(FlagLogo) + if err != nil { + return fmt.Errorf("invalid logo: %w", err) + } + social, err := cmd.Flags().GetString(FlagSocial) + if err != nil { + return fmt.Errorf("invalid social: %w", err) + } + docs, err := cmd.Flags().GetString(FlagDocs) + if err != nil { + return fmt.Errorf("invalid docs: %w", err) + } + bondStr, err := cmd.Flags().GetString(FlagBond) + if err != nil { + return fmt.Errorf("invalid bonds: %w", err) + } + bond, err := sdk.ParseCoinNormalized(bondStr) + if err != nil { + return fmt.Errorf("invalid bonds: %w", err) + } + + voteQuorum, err := cmd.Flags().GetUint64(FlagVoteQuorum) + if err != nil { + return fmt.Errorf("invalid vote quorum: %w", err) + } + votePeriod, err := cmd.Flags().GetUint64(FlagVotePeriod) + if err != nil { + return fmt.Errorf("invalid vote period: %w", err) + } + voteEnactment, err := cmd.Flags().GetUint64(FlagVoteEnactment) + if err != nil { + return fmt.Errorf("invalid vote period: %w", err) + } + + ctrlRolesStr, err := cmd.Flags().GetString(FlagControllerRoles) + if err != nil { + return fmt.Errorf("invalid controller roles: %w", err) + } + ctrlAccountsStr, err := cmd.Flags().GetString(FlagControllerAccounts) + if err != nil { + return fmt.Errorf("invalid controller accounts: %w", err) + } + + ctrlRoles, ctrlAccounts, err := parseRolesAccounts(ctrlRolesStr, ctrlAccountsStr) + if err != nil { + return fmt.Errorf("invalid controller role/accounts: %w", err) + } + + issuranceStr, err := cmd.Flags().GetString(FlagIssuranceConfig) + if err != nil { + return fmt.Errorf("invalid issurance config: %w", err) + } + issurance := types.IssuranceConfig{} + err = clientCtx.Codec.UnmarshalJSON([]byte(issuranceStr), &issurance) + if err != nil { + return fmt.Errorf("invalid issurance config: %w", err) + } + + lpPoolConfigStr, err := cmd.Flags().GetString(FlagLpPoolConfig) + if err != nil { + return fmt.Errorf("invalid lp pool config: %w", err) + } + lpPoolConfig := types.LpPoolConfig{} + err = clientCtx.Codec.UnmarshalJSON([]byte(lpPoolConfigStr), &lpPoolConfig) + if err != nil { + return fmt.Errorf("invalid lp pool config: %w", err) + } + + binaryInfoStr, err := cmd.Flags().GetString(FlagBinaryInfo) + if err != nil { + return fmt.Errorf("invalid binaryInfo: %w", err) + } + binaryInfo := types.BinaryInfo{} + err = clientCtx.Codec.UnmarshalJSON([]byte(binaryInfoStr), &binaryInfo) + if err != nil { + return fmt.Errorf("invalid binaryInfo: %w", err) + } + + statusStr, err := cmd.Flags().GetString(FlagDappStatus) + if err != nil { + return fmt.Errorf("invalid status: %w", err) + } + + updateMaxTime, err := cmd.Flags().GetUint64(FlagUpdateTimeMax) + if err != nil { + return fmt.Errorf("invalid updateMaxTime: %w", err) + } + executorsMin, err := cmd.Flags().GetUint64(FlagExecutorsMin) + if err != nil { + return fmt.Errorf("invalid executorsMin: %w", err) + } + executorsMax, err := cmd.Flags().GetUint64(FlagExecutorsMax) + if err != nil { + return fmt.Errorf("invalid executorsMax: %w", err) + } + verifiersMin, err := cmd.Flags().GetUint64(FlagVerifiersMin) + if err != nil { + return fmt.Errorf("invalid verifiersMin: %w", err) + } + + msg := &types.MsgCreateDappProposal{ + Sender: clientCtx.GetFromAddress().String(), + Bond: bond, + Dapp: types.Dapp{ + Name: name, + Denom: denom, + Description: description, + Website: website, + Logo: logo, + Social: social, + Docs: docs, + Controllers: types.Controllers{ + Whitelist: types.AccountRange{ + Roles: ctrlRoles, + Addresses: ctrlAccounts, + }, + }, + Bin: []types.BinaryInfo{binaryInfo}, + Pool: lpPoolConfig, + Issurance: issurance, + UpdateTimeMax: updateMaxTime, + ExecutorsMin: executorsMin, + ExecutorsMax: executorsMax, + VerifiersMin: verifiersMin, + Status: types.DappStatus(types.SessionStatus_value[statusStr]), + VoteQuorum: voteQuorum, + VotePeriod: votePeriod, + VoteEnactment: voteEnactment, + }, + } + + err = msg.ValidateBasic() + if err != nil { + return err + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + _ = cmd.MarkFlagRequired(flags.FlagFrom) + + cmd.Flags().String(FlagDappName, "", "Dapp name") + cmd.Flags().String(FlagDenom, "", "Dapp denom") + cmd.Flags().String(FlagDappDescription, "", "Dapp description") + cmd.Flags().String(FlagWebsite, "", "Dapp website") + cmd.Flags().String(FlagLogo, "", "Dapp logo") + cmd.Flags().String(FlagSocial, "", "Dapp social") + cmd.Flags().String(FlagDocs, "", "Dapp docs") + cmd.Flags().String(FlagBond, "", "Initial bond deposit for dapp") + cmd.Flags().Uint64(FlagVoteQuorum, 0, "vote quorum of the dapp") + cmd.Flags().Uint64(FlagVotePeriod, 0, "vote period of the dapp") + cmd.Flags().Uint64(FlagVoteEnactment, 0, "vote enactment of the dapp") + cmd.Flags().String(FlagControllerRoles, "", "controller roles on the dapp.") + cmd.Flags().String(FlagControllerAccounts, "", "controller accounts on the dapp.") + cmd.Flags().String(FlagIssuranceConfig, "{}", "dapp issurance config.") + cmd.Flags().String(FlagLpPoolConfig, "{}", "dapp lp config.") + cmd.Flags().String(FlagBinaryInfo, "{}", "dapp binary info.") + cmd.Flags().String(FlagDappStatus, "{}", "dapp status.") + cmd.Flags().Uint64(FlagUpdateTimeMax, 0, "dapp update time max") + cmd.Flags().Uint64(FlagExecutorsMin, 0, "dapp executors min") + cmd.Flags().Uint64(FlagExecutorsMax, 0, "dapp executors max") + cmd.Flags().Uint64(FlagVerifiersMin, 0, "dapp verifiers min") + + return cmd +} + +// GetTxBondDappProposalCmd implement cli command for MsgBondDappProposal +func GetTxBondDappProposalCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "bond-dapp-proposal", + Short: "Bond on dapp proposal", + Args: cobra.MinimumNArgs(0), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + name, err := cmd.Flags().GetString(FlagDappName) + if err != nil { + return fmt.Errorf("invalid name: %w", err) + } + bondStr, err := cmd.Flags().GetString(FlagBond) + if err != nil { + return fmt.Errorf("invalid bonds: %w", err) + } + bond, err := sdk.ParseCoinNormalized(bondStr) + if err != nil { + return fmt.Errorf("invalid bonds: %w", err) + } + + msg := &types.MsgBondDappProposal{ + Sender: clientCtx.GetFromAddress().String(), + DappName: name, + Bond: bond, + } + + err = msg.ValidateBasic() + if err != nil { + return err + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + _ = cmd.MarkFlagRequired(flags.FlagFrom) + + cmd.Flags().String(FlagDappName, "", "Dapp name") + cmd.Flags().String(FlagBond, "", "Initial bond deposit for dapp") + + return cmd +} + +// GetTxReclaimDappBondProposalCmd implement cli command for MsgReclaimDappBondProposal +func GetTxReclaimDappBondProposalCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "reclaim-dapp-proposal", + Short: "Reclaim from dapp proposal", + Args: cobra.MinimumNArgs(0), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + name, err := cmd.Flags().GetString(FlagDappName) + if err != nil { + return fmt.Errorf("invalid name: %w", err) + } + bondStr, err := cmd.Flags().GetString(FlagBond) + if err != nil { + return fmt.Errorf("invalid bonds: %w", err) + } + bond, err := sdk.ParseCoinNormalized(bondStr) + if err != nil { + return fmt.Errorf("invalid bonds: %w", err) + } + + msg := &types.MsgReclaimDappBondProposal{ + Sender: clientCtx.GetFromAddress().String(), + DappName: name, + Bond: bond, + } + + err = msg.ValidateBasic() + if err != nil { + return err + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + _ = cmd.MarkFlagRequired(flags.FlagFrom) + + cmd.Flags().String(FlagDappName, "", "Dapp name") + cmd.Flags().String(FlagBond, "", "Initial bond deposit for dapp") + + return cmd +} + +// GetTxJoinDappVerifierWithBondCmd implement cli command for MsgJoinDappVerifierWithBond +func GetTxJoinDappVerifierWithBondCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "join-dapp-verifier-with-bond [dapp-name] [interx]", + Short: "Join dapp verifier with bond", + Args: cobra.MinimumNArgs(2), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + msg := &types.MsgJoinDappVerifierWithBond{ + Sender: clientCtx.GetFromAddress().String(), + DappName: args[0], + Interx: args[1], + } + + err = msg.ValidateBasic() + if err != nil { + return err + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + _ = cmd.MarkFlagRequired(flags.FlagFrom) + + return cmd +} + +// GetTxExitDappCmd implement cli command for MsgExitDapp +func GetTxExitDappCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "exit-dapp [dapp-name]", + Short: "Send request to exit dapp", + Args: cobra.MinimumNArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + msg := &types.MsgExitDapp{ + Sender: clientCtx.GetFromAddress().String(), + DappName: args[0], + } + + err = msg.ValidateBasic() + if err != nil { + return err + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + _ = cmd.MarkFlagRequired(flags.FlagFrom) + + return cmd +} + +// GetTxExecuteDappTxCmd implement cli command for MsgExecuteDappTx +func GetTxExecuteDappTxCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "execute-dapp-tx [dapp-name] [gateway]", + Short: "Send signal to start dapp execution", + Args: cobra.MinimumNArgs(2), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + msg := &types.MsgExecuteDappTx{ + Sender: clientCtx.GetFromAddress().String(), + DappName: args[0], + Gateway: args[1], + } + + err = msg.ValidateBasic() + if err != nil { + return err + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + _ = cmd.MarkFlagRequired(flags.FlagFrom) + + return cmd +} + +// GetTxDenounceLeaderTxCmd implement cli command for MsgDenounceLeaderTx +func GetTxDenounceLeaderTxCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "denounce-leader [dapp-name] [leader] [denounce-txt] [version]", + Short: "Send leader denounce transaction", + Args: cobra.MinimumNArgs(4), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + msg := &types.MsgDenounceLeaderTx{ + Sender: clientCtx.GetFromAddress().String(), + DappName: args[0], + Leader: args[1], + DenounceText: args[2], + Version: args[3], + } + + err = msg.ValidateBasic() + if err != nil { + return err + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + _ = cmd.MarkFlagRequired(flags.FlagFrom) + + return cmd +} + +// GetTxTransitionDappCmd implement cli command for MsgTransitionDappTx +func GetTxTransitionDappCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "transition-dapp [dapp-name] [status-hash] [version]", + Short: "Send dapp transition message", + Args: cobra.MinimumNArgs(3), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + msg := types.NewMsgTransitionDappTx( + clientCtx.GetFromAddress().String(), args[0], args[1], args[2], []sdk.Msg{}, + ) + err = msg.ValidateBasic() + if err != nil { + return err + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + _ = cmd.MarkFlagRequired(flags.FlagFrom) + + return cmd +} + +// GetTxApproveDappTransitionCmd implement cli command for MsgApproveDappTransitionTx +func GetTxApproveDappTransitionCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "approve-dapp-transition [dapp-name] [version]", + Short: "Send dapp transition approval message", + Args: cobra.MinimumNArgs(2), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + msg := &types.MsgApproveDappTransitionTx{ + Sender: clientCtx.GetFromAddress().String(), + DappName: args[0], + Version: args[1], + } + + err = msg.ValidateBasic() + if err != nil { + return err + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + _ = cmd.MarkFlagRequired(flags.FlagFrom) + + return cmd +} + +// GetTxRejectDappTransitionCmd implement cli command for MsgRejectDappTransitionTx +func GetTxRejectDappTransitionCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "reject-dapp-transition [dapp-name] [version]", + Short: "Send dapp transition reject message", + Args: cobra.MinimumNArgs(2), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + msg := &types.MsgRejectDappTransitionTx{ + Sender: clientCtx.GetFromAddress().String(), + DappName: args[0], + Version: args[1], + } + + err = msg.ValidateBasic() + if err != nil { + return err + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + _ = cmd.MarkFlagRequired(flags.FlagFrom) + + return cmd +} + +// GetTxProposalJoinDappCmd implement cli command for ProposalJoinDapp +func GetTxProposalJoinDappCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "proposal-join-dapp [dapp-name] [is-executor] [is-verifier] [interx]", + Short: "Create a proposal to join dapp", + Args: cobra.ExactArgs(4), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + title, err := cmd.Flags().GetString(FlagTitle) + if err != nil { + return fmt.Errorf("invalid title: %w", err) + } + description, err := cmd.Flags().GetString(FlagDescription) + if err != nil { + return fmt.Errorf("invalid description: %w", err) + } + + executor, err := strconv.ParseBool(args[1]) + if err != nil { + return fmt.Errorf("invalid executor flag: %w", err) + } + + verifier, err := strconv.ParseBool(args[2]) + if err != nil { + return fmt.Errorf("invalid verifier flag: %w", err) + } + + msg, err := govtypes.NewMsgSubmitProposal( + clientCtx.FromAddress, + title, + description, + &types.ProposalJoinDapp{ + Sender: clientCtx.GetFromAddress().String(), + DappName: args[0], + Executor: executor, + Verifier: verifier, + Interx: args[3], + }, + ) + if err != nil { + return err + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + cmd.Flags().String(FlagTitle, "", "The title of the proposal.") + cmd.MarkFlagRequired(FlagTitle) + cmd.Flags().String(FlagDescription, "", "The description of the proposal, it can be a url, some text, etc.") + cmd.MarkFlagRequired(FlagDescription) + + flags.AddTxFlagsToCmd(cmd) + _ = cmd.MarkFlagRequired(flags.FlagFrom) + + return cmd +} + +// GetTxProposalUpsertDappCmd implement cli command for ProposalUpsertDapp +func GetTxProposalUpsertDappCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "proposal-upsert-dapp", + Short: "Create a proposal to upsert dapp", + Args: cobra.ExactArgs(0), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + title, err := cmd.Flags().GetString(FlagTitle) + if err != nil { + return fmt.Errorf("invalid title: %w", err) + } + description, err := cmd.Flags().GetString(FlagDescription) + if err != nil { + return fmt.Errorf("invalid description: %w", err) + } + + name, err := cmd.Flags().GetString(FlagDappName) + if err != nil { + return fmt.Errorf("invalid name: %w", err) + } + denom, err := cmd.Flags().GetString(FlagDenom) + if err != nil { + return fmt.Errorf("invalid denom: %w", err) + } + dappDescription, err := cmd.Flags().GetString(FlagDappDescription) + if err != nil { + return fmt.Errorf("invalid description: %w", err) + } + website, err := cmd.Flags().GetString(FlagWebsite) + if err != nil { + return fmt.Errorf("invalid website: %w", err) + } + logo, err := cmd.Flags().GetString(FlagLogo) + if err != nil { + return fmt.Errorf("invalid logo: %w", err) + } + social, err := cmd.Flags().GetString(FlagSocial) + if err != nil { + return fmt.Errorf("invalid social: %w", err) + } + docs, err := cmd.Flags().GetString(FlagDocs) + if err != nil { + return fmt.Errorf("invalid docs: %w", err) + } + + ctrlRolesStr, err := cmd.Flags().GetString(FlagControllerRoles) + if err != nil { + return fmt.Errorf("invalid controller roles: %w", err) + } + ctrlAccountsStr, err := cmd.Flags().GetString(FlagControllerAccounts) + if err != nil { + return fmt.Errorf("invalid controller accounts: %w", err) + } + + ctrlRoles, ctrlAccounts, err := parseRolesAccounts(ctrlRolesStr, ctrlAccountsStr) + if err != nil { + return fmt.Errorf("invalid controller role/accounts: %w", err) + } + + issuranceStr, err := cmd.Flags().GetString(FlagIssuranceConfig) + if err != nil { + return fmt.Errorf("invalid issurance config: %w", err) + } + issurance := types.IssuranceConfig{} + err = clientCtx.Codec.UnmarshalJSON([]byte(issuranceStr), &issurance) + if err != nil { + return fmt.Errorf("invalid issurance config: %w", err) + } + + lpPoolConfigStr, err := cmd.Flags().GetString(FlagLpPoolConfig) + if err != nil { + return fmt.Errorf("invalid lp pool config: %w", err) + } + lpPoolConfig := types.LpPoolConfig{} + err = clientCtx.Codec.UnmarshalJSON([]byte(lpPoolConfigStr), &lpPoolConfig) + if err != nil { + return fmt.Errorf("invalid lp pool config: %w", err) + } + + binaryInfoStr, err := cmd.Flags().GetString(FlagBinaryInfo) + if err != nil { + return fmt.Errorf("invalid binaryInfo: %w", err) + } + binaryInfo := types.BinaryInfo{} + err = clientCtx.Codec.UnmarshalJSON([]byte(binaryInfoStr), &binaryInfo) + if err != nil { + return fmt.Errorf("invalid binaryInfo: %w", err) + } + + statusStr, err := cmd.Flags().GetString(FlagDappStatus) + if err != nil { + return fmt.Errorf("invalid status: %w", err) + } + + updateMaxTime, err := cmd.Flags().GetUint64(FlagUpdateTimeMax) + if err != nil { + return fmt.Errorf("invalid updateMaxTime: %w", err) + } + executorsMin, err := cmd.Flags().GetUint64(FlagExecutorsMin) + if err != nil { + return fmt.Errorf("invalid executorsMin: %w", err) + } + executorsMax, err := cmd.Flags().GetUint64(FlagExecutorsMax) + if err != nil { + return fmt.Errorf("invalid executorsMax: %w", err) + } + verifiersMin, err := cmd.Flags().GetUint64(FlagVerifiersMin) + if err != nil { + return fmt.Errorf("invalid verifiersMin: %w", err) + } + voteQuorum, err := cmd.Flags().GetUint64(FlagVoteQuorum) + if err != nil { + return fmt.Errorf("invalid vote quorum: %w", err) + } + votePeriod, err := cmd.Flags().GetUint64(FlagVotePeriod) + if err != nil { + return fmt.Errorf("invalid vote period: %w", err) + } + voteEnactment, err := cmd.Flags().GetUint64(FlagVoteEnactment) + if err != nil { + return fmt.Errorf("invalid vote period: %w", err) + } + + msg, err := govtypes.NewMsgSubmitProposal( + clientCtx.FromAddress, + title, + description, + &types.ProposalUpsertDapp{ + Sender: clientCtx.GetFromAddress().String(), + Dapp: types.Dapp{ + Name: name, + Denom: denom, + Description: dappDescription, + Website: website, + Logo: logo, + Social: social, + Docs: docs, + Controllers: types.Controllers{ + Whitelist: types.AccountRange{ + Roles: ctrlRoles, + Addresses: ctrlAccounts, + }, + }, + Bin: []types.BinaryInfo{binaryInfo}, + Pool: lpPoolConfig, + Issurance: issurance, + UpdateTimeMax: updateMaxTime, + ExecutorsMin: executorsMin, + ExecutorsMax: executorsMax, + VerifiersMin: verifiersMin, + Status: types.DappStatus(types.SessionStatus_value[statusStr]), + VoteQuorum: voteQuorum, + VotePeriod: votePeriod, + VoteEnactment: voteEnactment, + }, + }, + ) + if err != nil { + return err + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + cmd.Flags().String(FlagTitle, "", "The title of the proposal.") + cmd.MarkFlagRequired(FlagTitle) + cmd.Flags().String(FlagDescription, "", "The description of the proposal, it can be a url, some text, etc.") + cmd.MarkFlagRequired(FlagDescription) + + cmd.Flags().String(FlagDappName, "", "Dapp name") + cmd.Flags().String(FlagDenom, "", "Dapp denom") + cmd.Flags().String(FlagDappDescription, "", "Dapp description") + cmd.Flags().String(FlagWebsite, "", "Dapp website") + cmd.Flags().String(FlagLogo, "", "Dapp logo") + cmd.Flags().String(FlagSocial, "", "Dapp social") + cmd.Flags().String(FlagDocs, "", "Dapp docs") + cmd.Flags().String(FlagBond, "", "Initial bond deposit for dapp") + cmd.Flags().Uint64(FlagVoteQuorum, 0, "vote quorum of the dapp") + cmd.Flags().Uint64(FlagVotePeriod, 0, "vote period of the dapp") + cmd.Flags().Uint64(FlagVoteEnactment, 0, "vote enactment of the dapp") + cmd.Flags().String(FlagControllerRoles, "", "controller roles on the dapp.") + cmd.Flags().String(FlagControllerAccounts, "", "controller accounts on the dapp.") + cmd.Flags().String(FlagIssuranceConfig, "{}", "dapp issurance config.") + cmd.Flags().String(FlagLpPoolConfig, "{}", "dapp lp config.") + cmd.Flags().String(FlagBinaryInfo, "{}", "dapp binary info.") + cmd.Flags().String(FlagDappStatus, "{}", "dapp status.") + cmd.Flags().Uint64(FlagUpdateTimeMax, 0, "dapp update time max") + cmd.Flags().Uint64(FlagExecutorsMin, 0, "dapp executors min") + cmd.Flags().Uint64(FlagExecutorsMax, 0, "dapp executors max") + cmd.Flags().Uint64(FlagVerifiersMin, 0, "dapp verifiers min") + + flags.AddTxFlagsToCmd(cmd) + _ = cmd.MarkFlagRequired(flags.FlagFrom) + + return cmd +} + +func parseRolesAccounts(rolesStr, accountsStr string) ([]uint64, []string, error) { + roleStrArr := strings.Split(rolesStr, ",") + if rolesStr == "" { + roleStrArr = []string{} + } + roles := []uint64{} + for _, roleStr := range roleStrArr { + role, err := strconv.Atoi(roleStr) + if err != nil { + return []uint64{}, []string{}, fmt.Errorf("invalid role: %w", err) + } + roles = append(roles, uint64(role)) + } + accounts := strings.Split(accountsStr, ",") + if accountsStr == "" { + accounts = []string{} + } + return roles, accounts, nil +} + +// GetTxRedeemDappPoolTxCmd implement cli command for MsgRedeemDappPoolTx +func GetTxRedeemDappPoolTxCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "redeem-dapp-pool [dapp-name] [lp-token] [slippage]", + Short: "Send redeem dapp pool message", + Args: cobra.MinimumNArgs(3), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + coin, err := sdk.ParseCoinNormalized(args[1]) + if err != nil { + return err + } + + slippage, err := sdk.NewDecFromStr(args[2]) + if err != nil { + return err + } + + msg := &types.MsgRedeemDappPoolTx{ + Sender: clientCtx.GetFromAddress().String(), + DappName: args[0], + LpToken: coin, + Slippage: slippage, + } + + err = msg.ValidateBasic() + if err != nil { + return err + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + _ = cmd.MarkFlagRequired(flags.FlagFrom) + + return cmd +} + +// GetTxSwapDappPoolTxCmd implement cli command for MsgSwapDappPoolTx +func GetTxSwapDappPoolTxCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "swap-dapp-pool [dapp-name] [token] [slippage]", + Short: "Send swap dapp pool message", + Args: cobra.MinimumNArgs(3), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + coin, err := sdk.ParseCoinNormalized(args[1]) + if err != nil { + return err + } + + slippage, err := sdk.NewDecFromStr(args[2]) + if err != nil { + return err + } + + msg := &types.MsgSwapDappPoolTx{ + Sender: clientCtx.GetFromAddress().String(), + DappName: args[0], + Token: coin, + Slippage: slippage, + } + + err = msg.ValidateBasic() + if err != nil { + return err + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + _ = cmd.MarkFlagRequired(flags.FlagFrom) + + return cmd +} + +// GetTxConvertDappPoolTxCmd implement cli command for MsgConvertDappPoolTx +func GetTxConvertDappPoolTxCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "convert-dapp-pool [dapp-name] [target-dapp-name] [token] [slippage]", + Short: "Send convert dapp pool message", + Args: cobra.MinimumNArgs(4), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + coin, err := sdk.ParseCoinNormalized(args[2]) + if err != nil { + return err + } + + slippage, err := sdk.NewDecFromStr(args[3]) + if err != nil { + return err + } + + msg := &types.MsgConvertDappPoolTx{ + Sender: clientCtx.GetFromAddress().String(), + DappName: args[0], + TargetDappName: args[1], + LpToken: coin, + Slippage: slippage, + } + + err = msg.ValidateBasic() + if err != nil { + return err + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + _ = cmd.MarkFlagRequired(flags.FlagFrom) + + return cmd +} + +// GetTxPauseDappTxCmd implement cli command for MsgPauseDappTx +func GetTxPauseDappTxCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "pause-dapp [dapp-name]", + Short: "Send pause dapp message", + Args: cobra.MinimumNArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + msg := &types.MsgPauseDappTx{ + Sender: clientCtx.GetFromAddress().String(), + DappName: args[0], + } + + err = msg.ValidateBasic() + if err != nil { + return err + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + _ = cmd.MarkFlagRequired(flags.FlagFrom) + + return cmd +} + +// GetTxUnPauseDappTxCmd implement cli command for MsgUnPauseDappTx +func GetTxUnPauseDappTxCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "unpause-dapp [dapp-name]", + Short: "Send unpause dapp message", + Args: cobra.MinimumNArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + msg := &types.MsgUnPauseDappTx{ + Sender: clientCtx.GetFromAddress().String(), + DappName: args[0], + } + + err = msg.ValidateBasic() + if err != nil { + return err + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + _ = cmd.MarkFlagRequired(flags.FlagFrom) + + return cmd +} + +// GetTxReactivateDappTxCmd implement cli command for MsgReactivateDappTx +func GetTxReactivateDappTxCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "reactivate-dapp [dapp-name]", + Short: "Send reactivate dapp message", + Args: cobra.MinimumNArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + msg := &types.MsgReactivateDappTx{ + Sender: clientCtx.GetFromAddress().String(), + DappName: args[0], + } + + err = msg.ValidateBasic() + if err != nil { + return err + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + _ = cmd.MarkFlagRequired(flags.FlagFrom) + + return cmd +} + +// GetTxTransferDappTxCmd implement cli command for MsgTransferDappTx +func GetTxTransferDappTxCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "transfer-dapp [request-json]", + Short: "Send transfer dapp message", + Args: cobra.MinimumNArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + req := types.XAMRequest{} + err = clientCtx.Codec.UnmarshalJSON([]byte(args[0]), &req) + if err != nil { + return err + } + + msg := &types.MsgTransferDappTx{ + Sender: clientCtx.GetFromAddress().String(), + Requests: []types.XAMRequest{req}, + } + + err = msg.ValidateBasic() + if err != nil { + return err + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + _ = cmd.MarkFlagRequired(flags.FlagFrom) + + return cmd +} + +// GetTxMintCreateFtTxCmd implement cli command for MsgMintCreateFtTx +func GetTxMintCreateFtTxCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "mint-create-ft-tx [denom-suffix] [name] [symbol] [icon] [description] [website] [social] [decimals] [cap] [supply] [fee] [owner]", + Short: "Send create fungible token tx message", + Args: cobra.MinimumNArgs(12), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + decimals, err := strconv.Atoi(args[7]) + if err != nil { + return err + } + + cap, ok := sdk.NewIntFromString(args[8]) + if !ok { + return fmt.Errorf("invalid cap") + } + + supply, ok := sdk.NewIntFromString(args[9]) + if !ok { + return fmt.Errorf("invalid supply") + } + + fee, ok := sdk.NewIntFromString(args[10]) + if !ok { + return fmt.Errorf("invalid fee") + } + + msg := &types.MsgMintCreateFtTx{ + Sender: clientCtx.GetFromAddress().String(), + DenomSuffix: args[0], + Name: args[1], + Symbol: args[2], + Icon: args[3], + Description: args[4], + Website: args[5], + Social: args[6], + Decimals: uint64(decimals), + Cap: cap, + Supply: supply, + Fee: fee, + Owner: args[11], + } + + err = msg.ValidateBasic() + if err != nil { + return err + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + _ = cmd.MarkFlagRequired(flags.FlagFrom) + + return cmd +} + +// GetTxMintCreateNftTxCmd implement cli command for MsgMintCreateNftTx +func GetTxMintCreateNftTxCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "mint-create-nft-tx [denom-suffix] [name] [symbol] [icon] [description] [website] [social] [decimals] [cap] [supply] [fee] [owner] [metadata] [hash]", + Short: "Send create non-fungible token tx message", + Args: cobra.MinimumNArgs(14), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + decimals, err := strconv.Atoi(args[7]) + if err != nil { + return err + } + + cap, ok := sdk.NewIntFromString(args[8]) + if !ok { + return fmt.Errorf("invalid cap") + } + + supply, ok := sdk.NewIntFromString(args[9]) + if !ok { + return fmt.Errorf("invalid supply") + } + + fee, ok := sdk.NewIntFromString(args[10]) + if !ok { + return fmt.Errorf("invalid fee") + } + + msg := &types.MsgMintCreateNftTx{ + Sender: clientCtx.GetFromAddress().String(), + DenomSuffix: args[0], + Name: args[1], + Symbol: args[2], + Icon: args[3], + Description: args[4], + Website: args[5], + Social: args[6], + Decimals: uint64(decimals), + Cap: cap, + Supply: supply, + Fee: fee, + Owner: args[11], + Metadata: args[12], + Hash: args[13], + } + + err = msg.ValidateBasic() + if err != nil { + return err + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + _ = cmd.MarkFlagRequired(flags.FlagFrom) + + return cmd +} + +// GetTxMintIssueTxCmd implement cli command for MsgMintIssueTx +func GetTxMintIssueTxCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "mint-issue-tx [denom] [amount] [receiver]", + Short: "Send mint issue tx message", + Args: cobra.MinimumNArgs(3), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + amount, ok := sdk.NewIntFromString(args[1]) + if !ok { + return fmt.Errorf("invalid amount") + } + + msg := &types.MsgMintIssueTx{ + Sender: clientCtx.GetFromAddress().String(), + Denom: args[0], + Amount: amount, + Receiver: args[2], + } + + err = msg.ValidateBasic() + if err != nil { + return err + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + _ = cmd.MarkFlagRequired(flags.FlagFrom) + + return cmd +} + +// GetTxMintBurnTxCmd implement cli command for MsgMintBurnTx +func GetTxMintBurnTxCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "burn-issue-tx [denom] [amount]", + Short: "Send burn issue tx message", + Args: cobra.MinimumNArgs(2), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + amount, ok := sdk.NewIntFromString(args[1]) + if !ok { + return fmt.Errorf("invalid amount") + } + + msg := &types.MsgMintBurnTx{ + Sender: clientCtx.GetFromAddress().String(), + Denom: args[0], + Amount: amount, + } + + err = msg.ValidateBasic() + if err != nil { + return err + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + _ = cmd.MarkFlagRequired(flags.FlagFrom) + + return cmd +} diff --git a/x/layer2/handler.go b/x/layer2/handler.go new file mode 100644 index 000000000..41b904ec4 --- /dev/null +++ b/x/layer2/handler.go @@ -0,0 +1,89 @@ +package layer2 + +import ( + "github.com/KiraCore/sekai/x/layer2/keeper" + "github.com/KiraCore/sekai/x/layer2/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/errors" +) + +// NewHandler returns new instance of handler +func NewHandler(k keeper.Keeper) sdk.Handler { + msgServer := keeper.NewMsgServerImpl(k) + + return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { + ctx = ctx.WithEventManager(sdk.NewEventManager()) + + switch msg := msg.(type) { + case *types.MsgCreateDappProposal: + res, err := msgServer.CreateDappProposal(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + case *types.MsgBondDappProposal: + res, err := msgServer.BondDappProposal(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + case *types.MsgReclaimDappBondProposal: + res, err := msgServer.ReclaimDappBondProposal(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + case *types.MsgJoinDappVerifierWithBond: + res, err := msgServer.JoinDappVerifierWithBond(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + case *types.MsgExitDapp: + res, err := msgServer.ExitDapp(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + case *types.MsgRedeemDappPoolTx: + res, err := msgServer.RedeemDappPoolTx(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + case *types.MsgSwapDappPoolTx: + res, err := msgServer.SwapDappPoolTx(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + case *types.MsgConvertDappPoolTx: + res, err := msgServer.ConvertDappPoolTx(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + case *types.MsgPauseDappTx: + res, err := msgServer.PauseDappTx(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + case *types.MsgUnPauseDappTx: + res, err := msgServer.UnPauseDappTx(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + case *types.MsgReactivateDappTx: + res, err := msgServer.ReactivateDappTx(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + case *types.MsgExecuteDappTx: + res, err := msgServer.ExecuteDappTx(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + case *types.MsgDenounceLeaderTx: + res, err := msgServer.DenounceLeaderTx(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + case *types.MsgTransitionDappTx: + res, err := msgServer.TransitionDappTx(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + case *types.MsgApproveDappTransitionTx: + res, err := msgServer.ApproveDappTransitionTx(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + case *types.MsgRejectDappTransitionTx: + res, err := msgServer.RejectDappTransitionTx(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + case *types.MsgTransferDappTx: + res, err := msgServer.TransferDappTx(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + case *types.MsgAckTransferDappTx: + res, err := msgServer.AckTransferDappTx(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + case *types.MsgMintCreateFtTx: + res, err := msgServer.MintCreateFtTx(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + case *types.MsgMintCreateNftTx: + res, err := msgServer.MintCreateNftTx(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + case *types.MsgMintIssueTx: + res, err := msgServer.MintIssueTx(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + case *types.MsgMintBurnTx: + res, err := msgServer.MintBurnTx(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + + default: + return nil, errors.Wrapf(errors.ErrUnknownRequest, "unrecognized %s message type: %T", types.ModuleName, msg) + } + } +} diff --git a/x/layer2/keeper/abci.go b/x/layer2/keeper/abci.go new file mode 100644 index 000000000..70dcaff29 --- /dev/null +++ b/x/layer2/keeper/abci.go @@ -0,0 +1,199 @@ +package keeper + +import ( + "fmt" + + "github.com/KiraCore/sekai/x/layer2/types" + spendingtypes "github.com/KiraCore/sekai/x/spending/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func (k Keeper) BeginBlocker(ctx sdk.Context) { + +} + +func (k Keeper) EndBlocker(ctx sdk.Context) { + dapps := k.GetAllDapps(ctx) + properties := k.gk.GetNetworkProperties(ctx) + currTimestamp := uint64(ctx.BlockTime().Unix()) + for _, dapp := range dapps { + if dapp.Status == types.Bootstrap && dapp.CreationTime+properties.DappBondDuration <= currTimestamp { + k.FinishDappBootstrap(ctx, dapp) + } + + if dapp.PremintTime+dapp.Pool.Drip < uint64(ctx.BlockTime().Unix()) && + dapp.Issurance.Postmint.IsPositive() && + dapp.Status == types.Active { + teamReserve := sdk.MustAccAddressFromBech32(dapp.TeamReserve) + dappBondLpToken := dapp.LpToken() + premintCoin := sdk.NewCoin(dappBondLpToken, dapp.Issurance.Premint) + err := k.bk.SendCoinsFromModuleToAccount(ctx, types.ModuleName, teamReserve, sdk.Coins{premintCoin}) + if err != nil { + panic(err) + } + dapp.PostMintPaid = true + k.SetDapp(ctx, dapp) + } + + if dapp.Status == types.Active { + session := k.GetDappSession(ctx, dapp.Name) + // session not started yet during denounce time + if session.NextSession != nil && + session.NextSession.Start+properties.DappAutoDenounceTime <= currTimestamp && + session.NextSession.Status == types.SessionScheduled { + operator := k.GetDappOperator(ctx, dapp.Name, session.NextSession.Leader) + operator.Status = types.OperatorJailed + k.SetDappOperator(ctx, operator) + + // update next session with new info + k.ResetNewSession(ctx, dapp.Name, session.CurrSession.Leader) + } + + // If the KEX collateral in the pool falls below dapp_liquidation_threshold (by default set to 100’000 KEX) + // then the dApp will enter a depreciation phase lasting dapp_liquidation_period (by default set to 2419200, that is ~28d) + // after which the execution will be stopped. + if dapp.LiquidationStart+properties.DappLiquidationPeriod < uint64(ctx.BlockTime().Unix()) { + dapp.Status = types.Halted + k.SetDapp(ctx, dapp) + } + } + } + + // handle bridge xam time outs + for _, xam := range k.GetXAMs(ctx) { + if xam.Req.SourceDapp != 0 && xam.Res.Src == 0 { + account := k.GetBridgeAccount(ctx, xam.Req.SourceDapp) + dapp := k.GetDapp(ctx, account.DappName) + if xam.ReqTime+2*dapp.UpdateTimeMax < uint64(ctx.BlockTime().Unix()) { + xam.Res.Src = 498 + k.SetXAM(ctx, xam) + } + } + + if xam.Req.DestDapp != 0 && xam.Res.Drc == 0 { + account := k.GetBridgeAccount(ctx, xam.Req.DestDapp) + dapp := k.GetDapp(ctx, account.DappName) + if xam.ReqTime+2*dapp.UpdateTimeMax < uint64(ctx.BlockTime().Unix()) { + xam.Res.Drc = 498 + k.SetXAM(ctx, xam) + } + } + } + // - **Deposit** funds from personal account (source application `src == 0`) to destination `dst` application beneficiary `ben` address. + // - Deposit must be accepted by the `dst` application or funds returned back to the user kira account outside of ABR + // - Max time for accepting deposit is `max(2 blocks, 2 * update_time_max)` after which transaction must fail (internal response `irc` code `522`) + // - **Transfer** funds from the source `src` application account `acc` address to another destination `dst` application beneficiary `ben` address + // - Withdrawal from `src` application must be permissionless, the source `src` app does not need to confirm it but can speed it up by setting source response `src` code to `200` + // - Deposit to destination `dst` app must be accepted by the `dst` app with destination app response code `drc` set to `200` or funds **returned through deposit like process** + // - If Deposit fails to `dst` fails then `src` must accept the re-deposit otherwise if re-deposit fails the funds must be returned to the kira account outside of ABR + // - Max time for accepting withdrawal by `src` app must be `max(2 blocks, 2 * update_time_max)` otherwise the withdrawal must automatically succeed + // - Max time for accepting deposit by `dst` app must be `max(2 blocks, 2 * update_time_max)` otherwise the deposit must automatically fail with internal response `irc` code set to `522` + // - If redeposit must be executed the new transaction must be created with new `xid`. Rules for re-deposit are same as for the deposit (if re-deposit fails funds must be returned to kira address outside of ABR) + // - **Withdrawal** funds from the source `src` application account `acc` address to kira address outside the ABR (`dst == 0`) to beneficiary `ben` address + // - Withdrawal from `src` application must be permissionless, the source `src` app does not need to confirm it but can speed it up by setting source response `src` code to `200` + // - Max time for accepting withdrawal by `src` app must be `max(2 blocks, 2 * update_time_max)` otherwise the withdrawal must automatically succeed + +} + +func (k Keeper) FinishDappBootstrap(ctx sdk.Context, dapp types.Dapp) { + properties := k.gk.GetNetworkProperties(ctx) + minDappBond := sdk.NewInt(int64(properties.MinDappBond)).Mul(sdk.NewInt(1000_000)) + if dapp.TotalBond.Amount.LT(minDappBond) { + cacheCtx, write := ctx.CacheContext() + err := k.ExecuteDappRemove(cacheCtx, dapp) + if err == nil { + write() + } + } else { + userBonds := k.GetUserDappBonds(ctx, dapp.Name) + beneficiaries := []spendingtypes.WeightedAccount{} + for _, userBond := range userBonds { + beneficiaries = append(beneficiaries, spendingtypes.WeightedAccount{ + Account: userBond.User, + Weight: userBond.Bond.Amount.Uint64(), + }) + } + + dappBondLpToken := dapp.LpToken() + err := sdk.ValidateDenom(dappBondLpToken) + if err != nil { + return + } + + spendingPoolDeposit := dapp.GetSpendingPoolLpDeposit() + totalSupply := dapp.GetLpTokenSupply() + drip := dapp.Pool.Drip + if drip == 0 { + drip = 1 + } + rate := spendingPoolDeposit.ToDec().Quo(sdk.NewDec(int64(drip))) + err = k.bk.MintCoins(ctx, types.ModuleName, sdk.Coins{sdk.NewCoin(dappBondLpToken, totalSupply)}) + if err != nil { + panic(err) + } + + cacheCtx, write := ctx.CacheContext() + blockTime := uint64(ctx.BlockTime().Unix()) + spendingPoolName := fmt.Sprintf("dp_%s", dapp.Name) + err = k.spk.CreateSpendingPool(cacheCtx, spendingtypes.SpendingPool{ + Name: spendingPoolName, + ClaimStart: blockTime, + ClaimEnd: blockTime + drip, + Rates: sdk.NewDecCoins(sdk.NewDecCoinFromDec(dappBondLpToken, rate)), + VoteQuorum: dapp.VoteQuorum, + VotePeriod: dapp.VotePeriod, + VoteEnactment: dapp.VoteEnactment, + Owners: &spendingtypes.PermInfo{ + OwnerRoles: dapp.Controllers.Whitelist.Roles, + OwnerAccounts: dapp.Controllers.Whitelist.Addresses, + }, + Beneficiaries: &spendingtypes.WeightedPermInfo{ + Accounts: beneficiaries, + }, + Balances: []sdk.Coin{}, + DynamicRate: false, + DynamicRatePeriod: 0, + LastDynamicRateCalcTime: 0, + }) + if err == nil { + write() + } + + cacheCtx, write = ctx.CacheContext() + coin := sdk.NewCoin(dappBondLpToken, spendingPoolDeposit) + err = k.spk.DepositSpendingPoolFromModule(cacheCtx, types.ModuleName, spendingPoolName, sdk.Coins{coin}) + if err == nil { + write() + } + + dapp.Status = types.Halted + dapp.Pool.Deposit = spendingPoolName + dapp.PremintTime = blockTime + k.SetDapp(ctx, dapp) + + // register bridge account for dapp + helper := k.GetBridgeRegistrarHelper(ctx) + k.SetBridgeAccount(ctx, types.BridgeAccount{ + Index: helper.NextUser, + Address: dapp.GetAccount().String(), + DappName: dapp.Name, + Balances: []types.BridgeBalance{}, + }) + helper.NextUser += 1 + k.SetBridgeRegistrarHelper(ctx, helper) + + for _, userBond := range userBonds { + k.DeleteUserDappBond(ctx, dapp.Name, userBond.User) + } + + // send premint amount to team reserve + if dapp.Issurance.Premint.IsPositive() { + teamReserve := sdk.MustAccAddressFromBech32(dapp.TeamReserve) + premintCoin := sdk.NewCoin(dappBondLpToken, dapp.Issurance.Premint) + err = k.bk.SendCoinsFromModuleToAccount(ctx, types.ModuleName, teamReserve, sdk.Coins{premintCoin}) + if err != nil { + panic(err) + } + } + } +} diff --git a/x/layer2/keeper/abci_test.go b/x/layer2/keeper/abci_test.go new file mode 100644 index 000000000..f42c2be8f --- /dev/null +++ b/x/layer2/keeper/abci_test.go @@ -0,0 +1,8 @@ +package keeper_test + +// TODO: add test for EndBlocker +// - finishing bootstrap case on EndBlocker +// - operator jail case on EndBlocker +// - liquidation case on EndBlocker +// - timeout for bridge registrar +// TODO: add test for FinishDappBootstrap diff --git a/x/layer2/keeper/bridge_registrar.go b/x/layer2/keeper/bridge_registrar.go new file mode 100644 index 000000000..f5fe9df2a --- /dev/null +++ b/x/layer2/keeper/bridge_registrar.go @@ -0,0 +1,123 @@ +package keeper + +import ( + "github.com/KiraCore/sekai/x/layer2/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func (k Keeper) SetBridgeRegistrarHelper(ctx sdk.Context, helper types.BridgeRegistrarHelper) { + bz := k.cdc.MustMarshal(&helper) + store := ctx.KVStore(k.storeKey) + store.Set(types.BridgeRegistrarHelperKey, bz) +} + +func (k Keeper) GetBridgeRegistrarHelper(ctx sdk.Context) types.BridgeRegistrarHelper { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.BridgeRegistrarHelperKey) + if bz == nil { + return types.BridgeRegistrarHelper{} + } + + helper := types.BridgeRegistrarHelper{} + k.cdc.MustUnmarshal(bz, &helper) + return helper +} + +func (k Keeper) SetBridgeAccount(ctx sdk.Context, account types.BridgeAccount) { + bz := k.cdc.MustMarshal(&account) + store := ctx.KVStore(k.storeKey) + store.Set(types.BridgeAccountKey(account.Index), bz) +} + +func (k Keeper) GetBridgeAccount(ctx sdk.Context, index uint64) types.BridgeAccount { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.BridgeAccountKey(index)) + if bz == nil { + return types.BridgeAccount{} + } + + account := types.BridgeAccount{} + k.cdc.MustUnmarshal(bz, &account) + return account +} + +func (k Keeper) GetBridgeAccounts(ctx sdk.Context) []types.BridgeAccount { + store := ctx.KVStore(k.storeKey) + + accounts := []types.BridgeAccount{} + it := sdk.KVStorePrefixIterator(store, []byte(types.PrefixBridgeAccountKey)) + defer it.Close() + + for ; it.Valid(); it.Next() { + account := types.BridgeAccount{} + k.cdc.MustUnmarshal(it.Value(), &account) + accounts = append(accounts, account) + } + return accounts +} + +func (k Keeper) SetBridgeToken(ctx sdk.Context, token types.BridgeToken) { + bz := k.cdc.MustMarshal(&token) + store := ctx.KVStore(k.storeKey) + store.Set(types.BridgeTokenKey(token.Index), bz) +} + +func (k Keeper) GetBridgeToken(ctx sdk.Context, index uint64) types.BridgeToken { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.BridgeTokenKey(index)) + if bz == nil { + return types.BridgeToken{} + } + + token := types.BridgeToken{} + k.cdc.MustUnmarshal(bz, &token) + return token +} + +func (k Keeper) GetBridgeTokens(ctx sdk.Context) []types.BridgeToken { + store := ctx.KVStore(k.storeKey) + + tokens := []types.BridgeToken{} + it := sdk.KVStorePrefixIterator(store, []byte(types.PrefixBridgeTokenKey)) + defer it.Close() + + for ; it.Valid(); it.Next() { + token := types.BridgeToken{} + k.cdc.MustUnmarshal(it.Value(), &token) + tokens = append(tokens, token) + } + return tokens +} + +func (k Keeper) SetXAM(ctx sdk.Context, xam types.XAM) { + bz := k.cdc.MustMarshal(&xam) + store := ctx.KVStore(k.storeKey) + store.Set(types.XAMKey(xam.Res.Xid), bz) +} + +func (k Keeper) GetXAM(ctx sdk.Context, xid uint64) types.XAM { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.XAMKey(xid)) + if bz == nil { + return types.XAM{} + } + + xam := types.XAM{} + k.cdc.MustUnmarshal(bz, &xam) + return xam +} + +func (k Keeper) GetXAMs(ctx sdk.Context) []types.XAM { + store := ctx.KVStore(k.storeKey) + + xams := []types.XAM{} + it := sdk.KVStorePrefixIterator(store, []byte(types.PrefixXAMKey)) + defer it.Close() + + for ; it.Valid(); it.Next() { + xam := types.XAM{} + k.cdc.MustUnmarshal(it.Value(), &xam) + xams = append(xams, xam) + } + return xams +} diff --git a/x/layer2/keeper/bridge_registrar_test.go b/x/layer2/keeper/bridge_registrar_test.go new file mode 100644 index 000000000..ed49a2ce4 --- /dev/null +++ b/x/layer2/keeper/bridge_registrar_test.go @@ -0,0 +1,137 @@ +package keeper_test + +import ( + "github.com/KiraCore/sekai/x/layer2/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func (suite *KeeperTestSuite) TestBridgeRegistrarHelperSetGet() { + helper := types.BridgeRegistrarHelper{ + NextUser: 1, + NextXam: 1, + NextToken: 1, + } + suite.app.Layer2Keeper.SetBridgeRegistrarHelper(suite.ctx, helper) + + saved := suite.app.Layer2Keeper.GetBridgeRegistrarHelper(suite.ctx) + suite.Require().Equal(saved, helper) +} + +func (suite *KeeperTestSuite) TestBridgeAccountSetGet() { + infos := []types.BridgeAccount{ + { + Index: 1, + Address: "kira15ky9du8a2wlstz6fpx3p4mqpjyrm5cgqzp4f3d", + DappName: "", + Balances: []types.BridgeBalance(nil), + }, + { + Index: 2, + Address: "kira1alzyfq40zjsveat87jlg8jxetwqmr0a29sgd0f", + DappName: "dapp1", + Balances: []types.BridgeBalance{ + { + BridgeTokenIndex: 1, + Amount: sdk.OneInt(), + }, + }, + }, + } + + for _, info := range infos { + suite.app.Layer2Keeper.SetBridgeAccount(suite.ctx, info) + } + + for _, info := range infos { + c := suite.app.Layer2Keeper.GetBridgeAccount(suite.ctx, info.Index) + suite.Require().Equal(c, info) + } + + accounts := suite.app.Layer2Keeper.GetBridgeAccounts(suite.ctx) + suite.Require().Len(accounts, 2) +} + +func (suite *KeeperTestSuite) TestBridgeTokenSetGet() { + infos := []types.BridgeToken{ + { + Index: 1, + Denom: "btc", + }, + { + Index: 2, + Denom: "eth", + }, + } + + for _, info := range infos { + suite.app.Layer2Keeper.SetBridgeToken(suite.ctx, info) + } + + for _, info := range infos { + c := suite.app.Layer2Keeper.GetBridgeToken(suite.ctx, info.Index) + suite.Require().Equal(c, info) + } + + tokens := suite.app.Layer2Keeper.GetBridgeTokens(suite.ctx) + suite.Require().Len(tokens, 2) +} + +func (suite *KeeperTestSuite) TestXAMSetGet() { + infos := []types.XAM{ + { + Req: types.XAMRequest{ + Amounts: []types.BridgeBalance(nil), + SourceDapp: 1, + SourceAccount: 1, + DestDapp: 2, + DestBeneficiary: 1, + Xam: "", + }, + Res: types.XAMResponse{ + Xid: 1, + Irc: 0, + Src: 0, + Drc: 0, + Irm: 0, + Srm: 0, + Drm: 0, + }, + }, + { + Req: types.XAMRequest{ + Amounts: []types.BridgeBalance{ + { + BridgeTokenIndex: 1, + Amount: sdk.OneInt(), + }, + }, + SourceDapp: 1, + SourceAccount: 1, + DestDapp: 2, + DestBeneficiary: 1, + Xam: "", + }, + Res: types.XAMResponse{ + Xid: 2, + Irc: 0, + Src: 0, + Drc: 0, + Irm: 0, + Srm: 0, + Drm: 0, + }, + }, + } + + for _, info := range infos { + suite.app.Layer2Keeper.SetXAM(suite.ctx, info) + } + + for _, info := range infos { + c := suite.app.Layer2Keeper.GetXAM(suite.ctx, info.Res.Xid) + suite.Require().Equal(c, info) + } + + xams := suite.app.Layer2Keeper.GetXAMs(suite.ctx) + suite.Require().Len(xams, 2) +} diff --git a/x/layer2/keeper/dapp.go b/x/layer2/keeper/dapp.go new file mode 100644 index 000000000..5143e8a6c --- /dev/null +++ b/x/layer2/keeper/dapp.go @@ -0,0 +1,111 @@ +package keeper + +import ( + "github.com/KiraCore/sekai/x/layer2/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func (k Keeper) GetDapp(ctx sdk.Context, name string) types.Dapp { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.DappKey(name)) + if bz == nil { + return types.Dapp{} + } + + dapp := types.Dapp{} + k.cdc.MustUnmarshal(bz, &dapp) + return dapp +} + +func (k Keeper) GetAllDapps(ctx sdk.Context) []types.Dapp { + store := ctx.KVStore(k.storeKey) + + dapps := []types.Dapp{} + it := sdk.KVStorePrefixIterator(store, types.KeyPrefixDapp) + defer it.Close() + + for ; it.Valid(); it.Next() { + dapp := types.Dapp{} + k.cdc.MustUnmarshal(it.Value(), &dapp) + dapps = append(dapps, dapp) + } + return dapps +} + +func (k Keeper) SetDapp(ctx sdk.Context, dapp types.Dapp) { + bz := k.cdc.MustMarshal(&dapp) + store := ctx.KVStore(k.storeKey) + store.Set(types.DappKey(dapp.Name), bz) +} + +func (k Keeper) DeleteDapp(ctx sdk.Context, name string) { + store := ctx.KVStore(k.storeKey) + store.Delete(types.DappKey(name)) +} + +func (k Keeper) SetUserDappBond(ctx sdk.Context, bond types.UserDappBond) { + bz := k.cdc.MustMarshal(&bond) + store := ctx.KVStore(k.storeKey) + store.Set(types.UserDappBondKey(bond.DappName, bond.User), bz) +} + +func (k Keeper) DeleteUserDappBond(ctx sdk.Context, name, address string) { + store := ctx.KVStore(k.storeKey) + store.Delete(types.UserDappBondKey(name, address)) +} + +func (k Keeper) GetUserDappBond(ctx sdk.Context, name string, user string) types.UserDappBond { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.UserDappBondKey(name, user)) + if bz == nil { + return types.UserDappBond{} + } + + bond := types.UserDappBond{} + k.cdc.MustUnmarshal(bz, &bond) + return bond +} + +func (k Keeper) GetUserDappBonds(ctx sdk.Context, name string) []types.UserDappBond { + store := ctx.KVStore(k.storeKey) + + bondlist := []types.UserDappBond{} + it := sdk.KVStorePrefixIterator(store, append([]byte(types.PrefixUserDappBondKey), name...)) + defer it.Close() + + for ; it.Valid(); it.Next() { + bond := types.UserDappBond{} + k.cdc.MustUnmarshal(it.Value(), &bond) + bondlist = append(bondlist, bond) + } + return bondlist +} + +func (k Keeper) GetAllUserDappBonds(ctx sdk.Context) []types.UserDappBond { + store := ctx.KVStore(k.storeKey) + + bondlist := []types.UserDappBond{} + it := sdk.KVStorePrefixIterator(store, []byte(types.PrefixUserDappBondKey)) + defer it.Close() + + for ; it.Valid(); it.Next() { + bond := types.UserDappBond{} + k.cdc.MustUnmarshal(it.Value(), &bond) + bondlist = append(bondlist, bond) + } + return bondlist +} + +func (k Keeper) ExecuteDappRemove(ctx sdk.Context, dapp types.Dapp) error { + for _, userBond := range k.GetUserDappBonds(ctx, dapp.Name) { + // send tokens back to user + addr := sdk.MustAccAddressFromBech32(userBond.User) + err := k.bk.SendCoinsFromModuleToAccount(ctx, types.ModuleName, addr, sdk.Coins{userBond.Bond}) + if err != nil { + return err + } + k.DeleteUserDappBond(ctx, dapp.Name, userBond.User) + } + k.DeleteDapp(ctx, dapp.Name) + return nil +} diff --git a/x/layer2/keeper/dapp_leader_denounce.go b/x/layer2/keeper/dapp_leader_denounce.go new file mode 100644 index 000000000..83289ad4e --- /dev/null +++ b/x/layer2/keeper/dapp_leader_denounce.go @@ -0,0 +1,59 @@ +package keeper + +import ( + "github.com/KiraCore/sekai/x/layer2/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func (k Keeper) SetDappLeaderDenouncement(ctx sdk.Context, denouncement types.DappLeaderDenouncement) { + bz := k.cdc.MustMarshal(&denouncement) + store := ctx.KVStore(k.storeKey) + store.Set(types.DappLeaderDenouncementKey(denouncement.DappName, denouncement.Leader, denouncement.Sender), bz) +} + +func (k Keeper) DeleteDappLeaderDenouncement(ctx sdk.Context, name, denouncement, sender string) { + store := ctx.KVStore(k.storeKey) + store.Delete(types.DappLeaderDenouncementKey(name, denouncement, sender)) +} + +func (k Keeper) GetDappLeaderDenouncement(ctx sdk.Context, name, denouncement, sender string) types.DappLeaderDenouncement { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.DappLeaderDenouncementKey(name, denouncement, sender)) + if bz == nil { + return types.DappLeaderDenouncement{} + } + + denouncementInfo := types.DappLeaderDenouncement{} + k.cdc.MustUnmarshal(bz, &denouncementInfo) + return denouncementInfo +} + +func (k Keeper) GetDappLeaderDenouncements(ctx sdk.Context, name, denouncement string) []types.DappLeaderDenouncement { + store := ctx.KVStore(k.storeKey) + + denouncements := []types.DappLeaderDenouncement{} + it := sdk.KVStorePrefixIterator(store, append(append([]byte(types.PrefixDappLeaderDenouncementKey), name...), denouncement...)) + defer it.Close() + + for ; it.Valid(); it.Next() { + denouncement := types.DappLeaderDenouncement{} + k.cdc.MustUnmarshal(it.Value(), &denouncement) + denouncements = append(denouncements, denouncement) + } + return denouncements +} + +func (k Keeper) GetAllDappLeaderDenouncements(ctx sdk.Context) []types.DappLeaderDenouncement { + store := ctx.KVStore(k.storeKey) + + denouncements := []types.DappLeaderDenouncement{} + it := sdk.KVStorePrefixIterator(store, []byte(types.PrefixDappLeaderDenouncementKey)) + defer it.Close() + + for ; it.Valid(); it.Next() { + denouncement := types.DappLeaderDenouncement{} + k.cdc.MustUnmarshal(it.Value(), &denouncement) + denouncements = append(denouncements, denouncement) + } + return denouncements +} diff --git a/x/layer2/keeper/dapp_leader_denounce_test.go b/x/layer2/keeper/dapp_leader_denounce_test.go new file mode 100644 index 000000000..5d509b78e --- /dev/null +++ b/x/layer2/keeper/dapp_leader_denounce_test.go @@ -0,0 +1,7 @@ +package keeper_test + +// TODO: add test for SetDappLeaderDenouncement +// TODO: add test for DeleteDappLeaderDenouncement +// TODO: add test for GetDappLeaderDenouncement +// TODO: add test for GetDappLeaderDenouncements +// TODO: add test for GetAllDappLeaderDenouncements diff --git a/x/layer2/keeper/dapp_operator.go b/x/layer2/keeper/dapp_operator.go new file mode 100644 index 000000000..70df0ad44 --- /dev/null +++ b/x/layer2/keeper/dapp_operator.go @@ -0,0 +1,157 @@ +package keeper + +import ( + "github.com/KiraCore/sekai/x/layer2/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func (k Keeper) SetDappOperator(ctx sdk.Context, operator types.DappOperator) { + bz := k.cdc.MustMarshal(&operator) + store := ctx.KVStore(k.storeKey) + store.Set(types.DappOperatorKey(operator.DappName, operator.Operator), bz) +} + +func (k Keeper) DeleteDappOperator(ctx sdk.Context, name, address string) { + store := ctx.KVStore(k.storeKey) + store.Delete(types.DappOperatorKey(name, address)) +} + +func (k Keeper) GetDappOperator(ctx sdk.Context, name string, user string) types.DappOperator { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.DappOperatorKey(name, user)) + if bz == nil { + return types.DappOperator{} + } + + operator := types.DappOperator{} + k.cdc.MustUnmarshal(bz, &operator) + return operator +} + +func (k Keeper) GetDappOperators(ctx sdk.Context, name string) []types.DappOperator { + store := ctx.KVStore(k.storeKey) + + operators := []types.DappOperator{} + it := sdk.KVStorePrefixIterator(store, append([]byte(types.PrefixDappOperatorKey), name...)) + defer it.Close() + + for ; it.Valid(); it.Next() { + operator := types.DappOperator{} + k.cdc.MustUnmarshal(it.Value(), &operator) + operators = append(operators, operator) + } + return operators +} + +func (k Keeper) GetDappExecutors(ctx sdk.Context, name string) []types.DappOperator { + operators := k.GetDappOperators(ctx, name) + executors := []types.DappOperator{} + for _, operator := range operators { + if operator.Executor { + executors = append(executors, operator) + } + } + return executors +} + +func (k Keeper) GetDappVerifiers(ctx sdk.Context, name string) []types.DappOperator { + operators := k.GetDappOperators(ctx, name) + verifiers := []types.DappOperator{} + for _, operator := range operators { + if operator.Verifier { + verifiers = append(verifiers, operator) + } + } + return verifiers +} + +func (k Keeper) GetAllDappOperators(ctx sdk.Context) []types.DappOperator { + store := ctx.KVStore(k.storeKey) + + operators := []types.DappOperator{} + it := sdk.KVStorePrefixIterator(store, []byte(types.PrefixDappOperatorKey)) + defer it.Close() + + for ; it.Valid(); it.Next() { + operator := types.DappOperator{} + k.cdc.MustUnmarshal(it.Value(), &operator) + operators = append(operators, operator) + } + return operators +} + +func (k Keeper) ExecuteJoinDappProposal(ctx sdk.Context, p *types.ProposalJoinDapp) error { + dapp := k.GetDapp(ctx, p.DappName) + if dapp.Name == "" { + return types.ErrDappDoesNotExist + } + + if p.Executor { + // ensure executor is a validator + addr, err := sdk.AccAddressFromBech32(p.Sender) + if err != nil { + return err + } + _, err = k.sk.GetValidator(ctx, sdk.ValAddress(addr)) + if err != nil { + return err + } + executors := k.GetDappExecutors(ctx, p.DappName) + if len(executors) >= int(dapp.ExecutorsMax) { + return types.ErrNumberOfOperatorsExceedsExecutorsMax + } + } + + k.SetDappOperator(ctx, types.DappOperator{ + DappName: p.DappName, + Operator: p.Sender, + Executor: p.Executor, + Verifier: p.Verifier, + Interx: p.Interx, + Status: types.OperatorActive, + BondedLpAmount: sdk.ZeroInt(), + }) + + // when executors_min reaches, session is created + executors := k.GetDappExecutors(ctx, p.DappName) + verifiers := k.GetDappVerifiers(ctx, p.DappName) + if len(executors) >= int(dapp.ExecutorsMin) && len(executors) >= 1 && len(verifiers) >= int(dapp.VerifiersMin) { + session := k.GetDappSession(ctx, p.DappName) + if session.DappName == "" { + k.CreateNewSession(ctx, p.DappName, "") + } + } + + return nil +} + +func (k Keeper) HandleSessionParticipation(ctx sdk.Context, operator types.DappOperator, participated bool) { + properties := k.gk.GetNetworkProperties(ctx) + if participated { + // If the dApp operator participates in the production of a dApp session (sends session or verification tx) his + // `rank` and `streak` must be increased by `1` while `mischance` re-set to 0, + + operator.Rank += 1 + operator.Streak += 1 + operator.VerifiedSessions += 1 + operator.Mischance = 0 + k.SetDappOperator(ctx, operator) + } else if operator.Status == types.OperatorActive { + // otherwise in the case of failure to participate the `mischance` counter must be increased by `1`, + // the `streak` re-set to `0` and `rank` decreased by `dAppMischanceRankDecreaseAmount`. + operator.Rank -= int64(properties.DappMischanceRankDecreaseAmount) + if operator.Rank < 0 { + operator.Rank = 0 + } + operator.Streak = 0 + operator.Mischance += 1 + operator.MissedSessions += 1 + + // If the dApp operator does not enable maintenance mode by using the `pause-dapp-tx` and the `mischance` counter + // exceeds `dAppMaxMischance` then his ranks should be slashed by `dAppInactiveRankDecreasePercent`. + if operator.Mischance > int64(properties.DappMaxMischance) { + operator.Rank = operator.Rank * (100 - int64(properties.AbstentionRankDecreaseAmount)) / 100 + } + k.SetDappOperator(ctx, operator) + } +} diff --git a/x/layer2/keeper/dapp_operator_test.go b/x/layer2/keeper/dapp_operator_test.go new file mode 100644 index 000000000..02aed6a93 --- /dev/null +++ b/x/layer2/keeper/dapp_operator_test.go @@ -0,0 +1,78 @@ +package keeper_test + +import ( + "github.com/KiraCore/sekai/x/layer2/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func (suite *KeeperTestSuite) TestDappOperatorSetGetDelete() { + operators := []types.DappOperator{ + { + DappName: "dapp1", + Operator: "kira1q24436yrnettd6v4eu6r4t9gycnnddack4jr5r", + Executor: true, + Verifier: true, + Interx: "kira1q24436yrnettd6v4eu6r4t9gycnnddack4jr5r", + Status: types.OperatorActive, + Rank: 1, + Streak: 1, + BondedLpAmount: sdk.ZeroInt(), + }, + { + DappName: "dapp1", + Operator: "kira1alzyfq40zjsveat87jlg8jxetwqmr0a29sgd0f", + Executor: true, + Verifier: false, + Interx: "kira1alzyfq40zjsveat87jlg8jxetwqmr0a29sgd0f", + Status: types.OperatorActive, + Rank: 1, + Streak: 1, + BondedLpAmount: sdk.OneInt(), + }, + { + DappName: "dapp2", + Operator: "kira1alzyfq40zjsveat87jlg8jxetwqmr0a29sgd0f", + Executor: false, + Verifier: true, + Interx: "kira1alzyfq40zjsveat87jlg8jxetwqmr0a29sgd0f", + Status: types.OperatorActive, + Rank: 1, + Streak: 1, + BondedLpAmount: sdk.OneInt(), + }, + } + + for _, operator := range operators { + suite.app.Layer2Keeper.SetDappOperator(suite.ctx, operator) + } + + for _, operator := range operators { + c := suite.app.Layer2Keeper.GetDappOperator(suite.ctx, operator.DappName, operator.Operator) + suite.Require().Equal(c, operator) + } + + allOperators := suite.app.Layer2Keeper.GetDappOperators(suite.ctx, operators[0].DappName) + suite.Require().Len(allOperators, 2) + + allOperators = suite.app.Layer2Keeper.GetAllDappOperators(suite.ctx) + suite.Require().Len(allOperators, 3) + + allVerifiers := suite.app.Layer2Keeper.GetDappVerifiers(suite.ctx, operators[0].DappName) + suite.Require().Len(allVerifiers, 1) + + allExecutors := suite.app.Layer2Keeper.GetDappExecutors(suite.ctx, operators[0].DappName) + suite.Require().Len(allExecutors, 2) + + suite.app.Layer2Keeper.DeleteDappOperator(suite.ctx, operators[0].DappName, operators[0].Operator) + + allOperators = suite.app.Layer2Keeper.GetDappOperators(suite.ctx, operators[0].DappName) + suite.Require().Len(allOperators, 1) + + operator := suite.app.Layer2Keeper.GetDappOperator(suite.ctx, operators[0].DappName, operators[0].Operator) + suite.Require().Equal(operator.DappName, "") + + allOperators = suite.app.Layer2Keeper.GetAllDappOperators(suite.ctx) + suite.Require().Len(allOperators, 2) +} + +// TODO: add test for ExecuteJoinDappProposal diff --git a/x/layer2/keeper/dapp_session.go b/x/layer2/keeper/dapp_session.go new file mode 100644 index 000000000..265946604 --- /dev/null +++ b/x/layer2/keeper/dapp_session.go @@ -0,0 +1,298 @@ +package keeper + +import ( + "github.com/KiraCore/sekai/x/layer2/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func (k Keeper) SetDappSession(ctx sdk.Context, session types.ExecutionRegistrar) { + bz := k.cdc.MustMarshal(&session) + store := ctx.KVStore(k.storeKey) + store.Set(types.ExecutionRegistrarKey(session.DappName), bz) +} + +func (k Keeper) DeleteDappSession(ctx sdk.Context, name string) { + store := ctx.KVStore(k.storeKey) + store.Delete(types.ExecutionRegistrarKey(name)) +} + +func (k Keeper) GetDappSession(ctx sdk.Context, name string) types.ExecutionRegistrar { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.ExecutionRegistrarKey(name)) + if bz == nil { + return types.ExecutionRegistrar{} + } + + sessionInfo := types.ExecutionRegistrar{} + k.cdc.MustUnmarshal(bz, &sessionInfo) + return sessionInfo +} + +func (k Keeper) GetAllDappSessions(ctx sdk.Context) []types.ExecutionRegistrar { + store := ctx.KVStore(k.storeKey) + + sessions := []types.ExecutionRegistrar{} + it := sdk.KVStorePrefixIterator(store, []byte(types.PrefixDappSessionKey)) + defer it.Close() + + for ; it.Valid(); it.Next() { + session := types.ExecutionRegistrar{} + k.cdc.MustUnmarshal(it.Value(), &session) + sessions = append(sessions, session) + } + return sessions +} + +// Halt the dapp if verifiers and executors number does not meet on ExitDapp and after Jail operation +func (k Keeper) HaltDappIfNoEnoughActiveOperators(ctx sdk.Context, dappName string) bool { + dapp := k.GetDapp(ctx, dappName) + executors := k.GetDappExecutors(ctx, dappName) + verifiers := k.GetDappVerifiers(ctx, dappName) + // active executors + activeExecutors := int(0) + for _, executor := range executors { + if executor.Status == types.OperatorActive { + activeExecutors++ + } + } + activeVerifiers := int(0) + for _, verifier := range verifiers { + if verifier.Status == types.OperatorActive { + activeVerifiers++ + } + } + + if activeExecutors < int(dapp.ExecutorsMin) || activeVerifiers < int(dapp.VerifiersMin) { + dapp.Status = types.Halted + k.SetDapp(ctx, dapp) + return true + } + return false +} + +func (k Keeper) ResetNewSession(ctx sdk.Context, name string, prevLeader string) { + operators := k.GetDappOperators(ctx, name) + for _, operator := range operators { + if operator.Status == types.OperatorExiting { + // If the operator leaving the dApp was a verifier then + // as the result of the exit tx his LP tokens bond should be returned once the record is deleted. + // The bond can only be claimed if and only if the status didn’t change to jailed in the meantime. + if operator.BondedLpAmount.IsPositive() { + dapp := k.GetDapp(ctx, name) + dappLpToken := dapp.LpToken() + lpCoins := sdk.NewCoins(sdk.NewCoin(dappLpToken, operator.BondedLpAmount)) + addr := sdk.MustAccAddressFromBech32(operator.Operator) + err := k.bk.SendCoinsFromModuleToAccount(ctx, types.ModuleName, addr, lpCoins) + if err != nil { + panic(err) + } + } + // remove operators exiting when session ends + k.DeleteDappOperator(ctx, name, operator.Operator) + } + } + + // halt the dapp if operators condition does not meet on session reset + halted := k.HaltDappIfNoEnoughActiveOperators(ctx, name) + if halted { + return + } + + leader := "" + executors := k.GetDappExecutors(ctx, name) + if len(executors) > 0 { + leader = executors[0].Operator + for index, executor := range executors { + if executor.Operator == prevLeader { + leader = executors[(index+1)%len(executors)].Interx + } + } + } + if leader == "" { + operator := k.GetDappOperator(ctx, name, prevLeader) + if operator.Status == types.OperatorActive { + leader = prevLeader + } + } + + session := k.GetDappSession(ctx, name) + session.NextSession = &types.DappSession{ + Leader: leader, + Start: uint64(ctx.BlockTime().Unix()), + StatusHash: "", + Status: types.SessionScheduled, + } + k.SetDappSession(ctx, session) + + // halt the dapp if next session leader is not available + if session.NextSession.Leader == "" { + dapp := k.GetDapp(ctx, name) + dapp.Status = types.Halted + k.SetDapp(ctx, dapp) + } +} + +func (k Keeper) CreateNewSession(ctx sdk.Context, name string, prevLeader string) { + session := k.GetDappSession(ctx, name) + session.PrevSession = session.CurrSession + session.CurrSession = session.NextSession + k.SetDappSession(ctx, session) + + // handle bridge and mint messages + msgServer := NewMsgServerImpl(k) + for _, msg := range session.PrevSession.OnchainMessages { + cacheCtx, write := ctx.CacheContext() + var err error + switch msg := msg.GetCachedValue().(type) { + case *types.MsgTransferDappTx: + _, err = msgServer.TransferDappTx(sdk.WrapSDKContext(cacheCtx), msg) + case *types.MsgAckTransferDappTx: + _, err = msgServer.AckTransferDappTx(sdk.WrapSDKContext(ctx), msg) + case *types.MsgMintCreateFtTx: + _, err = msgServer.MintCreateFtTx(sdk.WrapSDKContext(ctx), msg) + case *types.MsgMintCreateNftTx: + _, err = msgServer.MintCreateNftTx(sdk.WrapSDKContext(ctx), msg) + case *types.MsgMintIssueTx: + _, err = msgServer.MintIssueTx(sdk.WrapSDKContext(ctx), msg) + case *types.MsgMintBurnTx: + _, err = msgServer.MintBurnTx(sdk.WrapSDKContext(ctx), msg) + } + if err == nil { + write() + } + } + k.ResetNewSession(ctx, name, prevLeader) +} + +// **Next Session** + +// A summary of possible “next session” states: +// - `unscheduled` - The session is NOT ready yet to be picked up by another dApp Leader (e.g. previous dApp Session is ongoing) +// - `scheduled`- The session is ready to be picked up by the next dApp Leader +// - `ongoing` - Session was claimed by the dApp Leader and is currently being executed + +// **Current Session** + +// Allow every executor to send a `denounce-leader-tx` (true/false) which at any point in time via majority vote can invalidate +// further changes to the current session +// and will cause the next session to change its status to `scheduled`. + +// It must be possible for the automatic denouncement of the leader to happen if the current session data is not updated within +// `update_time_max` since `sessions.next.data.time` while the executor +// did NOT change his status to `paused` +// If automatic denouement happens then the same as in the case of manual votes of denouement the current session status +// should change to `denounced` while the next session status should be set to `scheduled`. + +// The most important property of the current session is `data`. +// The objective of the leader is to periodically update the `sessions.current.data` property with hashes of the `old` state, +// user `input`, the `new` proposed state, expected changes to account balances, +// and optional `proof` of the correctness of the execution + +// The `transition-dapp-tx` can be submitted ONLY by the leader and can be sent at ANY point in time allowing for finality +// the moment a sufficient number of verifiers or executors accept the changes**. + +// Whenever leader submits the new dApp state transition the `version` MUST be included and match the application version**. +// The transition tx should fail if the dApp `version` is NOT correct, the leader status is NOT active or +// if the `old` state hash does NOT match the `sessions.previous.data.new` hash. + +// There are no limitations to how many times the current session leader can submit `transition-dapp-tx` to replace the content +// of the current session data, however, every time a new dApp state transition is submitted, +// the list of approvals must be wiped, meaning any verifications will be lost. + +// Regardless if the approvals are lost or not the performance counters should maintain their count allowing for a fair +// reward distribution to operators later on. +// Additionally, the dApp leader must send the `transition-dapp-tx` before `update_time_max` elapses, +// otherwise his session will expire, and sending of any further `transition-dapp-tx` should fail, and the +// [sessions.currend.data.final](http://sessions.currend.data.final)` flag should be set to true. +// Finally, the session leader must be able to include a boolean flag in the `transition-dapp-tx` +// indicating if the transition tx is final on his own. +// If the final session flag is set then the leader should NOT be allowed to submit another +// `transition-dapp-tx` to the current session. + +// If the non-final session is approved before the finality flag is set and the session changes state to `approved` +// then the default next session leader should become the current session leader. +// This way the operator can continue execution with all data already available to him and provide fully uninterrupted service +// to the users. +// In order to give verifiers sufficient time to approve non-final sessions we should prohibit the submission of new +// `transition-dapp-tx` by the leader unless no less than `update_time_max/2` seconds elapsed since the last submission. + +// A summary of possible “current session” states: + +// - `accepted` - Session was accepted by verifiers and the new state is irreversible (changes will be applied to the blockchain unless status changes to halted or failed) +// - `ongoing` - Session was claimed by the dApp Leader and is currently being executed +// - `denounced` - The session was rejected by either a manual vote of executors to change the leader or due to the leader becoming jailed. +// - `halted` - The session was halted because it was questioned by one of the verifiers submitting evidence against it. Validators will have to assist unhalting and decide slashing penalty to either validator or fisherman +// - `failed` - The session failed to transition from “current” into “previous session” because internal data submitted by the leader was invalid and could NOT result in the modification of the blockchain state. + +// In the case where the current dApp Session becomes `failed` or `halted` but the new Leader already started execution based on an unverified state then both sessions (current and next) should be rejected by the network and a consecutive dApp Leader MUST start the execution from the dApp State that was persisted as a result of previous Session. If by any chance resources from the previous dApp state are no longer accessible (e.g. IPFS/URL link does not work and no validator has it saved on their execution node) then users can begin recovery of funds in accordance to the latest known settlement of balances within the Execution Registrar. + +// **Previous Session** + +// In order for the already approved “current session” to become a “previous session” the changes proposed in the `data.internal` +// section of the current session properties must be applied to the blockchain state. +// We will differentiate two types of internal data: + +// - Application Data (`appdata`) - A simple key-value pair dictionary, each application should be able to store on-chain +// up to `256` keys with up to `8192` characters each. +// The purpose of `appdata` is to enable applications communicate informations to the users that can be easily accessed +// and can be trusted, this might include location of IPFS gateways preserving dApp state files, +// deposit addresses of bridges, communicates to other applications and more. +// - JSON Structure: + +// ```json +// { "": "", "": "", ... } +// ``` + +// - Key names must be unique and adhere to the same rules as IR keys +// - Values must be a string or set to integer value `0` indicating that the key should be deleted +// - Compression Algorithm: `zip (max compression, level 9)` +// - Format: `base64` +// - Cross-Application Message Data (`xamdata`) - A simple json structure containing changes that must be communicated +// to the blockchain and in particular to the Application Bridge Registrar (ABR). +// The ABR is responsible for maintaining balances of users who deposit tokens to various dApps, +// minting new tokens and sending communicates between dApps & internal modules. +// - JSON Structure: + +// ```json +// { // key-array list defninig changes that must be applied to the Application Bridge Registrar +// "": [ "", "", "", ... ], ... } +// ``` + +// - Compression Algorithm: `zip (max compression, level 9)` +// - Format: `base64` + +// It is NOT guaranteed that even if dApp state was accepted the changes to the blockchain can actually be executed. +// For example application might be requesting to transfer to the user more assets then it actually holds. +// In such cases the State of the “current session” state must change to `failed` and the next session should automatically be wiped +// and set to `scheaduled`. +// The operators must also be explicitly informed what is the exact reason for the failure though `errors` +// property in the current session. +// Any failures should automatically result in the current session leader being denounced, +// meaning that the next session leader should be changed even if session finalization flag was not set in `transition-dapp-tx`. + +// **Reporting Failed Execution** + +// Fisherman (verifiers and executors who are not a leader) must be able to report any potential misbehavior of a leader +// and/or otherwise issues with the application to ensure that funds locked within can remain safe. +// In certain cases the finality gadget might not even exists or be possible to be created while fisherman might want +// to create custom systems monitoring behavior of the application far beyond the code logic itself. +// ANY fisherman must be able to send a `reject-dapp-transition-tx` with a message body (up to `8192` characters) +// containing a dApp name, session id and a reason for halting the application. +// As the result of `reject-dapp-transition-tx` the status of the current session should immediately change to +// `halted` and a `dapp-slash` proposal raised, similar to the way that the validator slashing proposals are created. +// In this case however the validators will need to make following judgements: + +// - should the dApp session be unhalted and state transition accepted (boolean) - true / false +// - if `true` then status of session should change to `ongoing` unless sufficient number of approvals is sent then `accepted` +// - if `false` then status should be set to `failed` and `errors` specify that governance vote decided to reject the session +// - what percentage of the fisherman bond should be slashed (percentage) - from 0 to 1 (100%) +// - slashed dApp LP tokens should be simply deminted (increasing value of other LP token holders positions) +// - if fisherman is slashed the validator can NOT be slashed +// - what percentage of the validator stake should be slashed (percentage) - from 0 to 0.1 (10%) +// - From the amount slashed 1% should be sent to fisherman address as reward and 99% to community pool +// - if validator is slashed the fisherman can NOT be slashed + +// Voting on `dapp-slash` proposal should only be possible by validators **with exception for the dApp leader**. +// If quorum is not reached or result is inconclusive then the default behavior should be no slashing and +// rejection of the dApp session state. If as the result of the proposal the bond of the fisherman was slashed, +// then he should be removed from the fisherman position until sufficient amount is locked by him again. diff --git a/x/layer2/keeper/dapp_session_approval.go b/x/layer2/keeper/dapp_session_approval.go new file mode 100644 index 000000000..df84a52df --- /dev/null +++ b/x/layer2/keeper/dapp_session_approval.go @@ -0,0 +1,59 @@ +package keeper + +import ( + "github.com/KiraCore/sekai/x/layer2/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func (k Keeper) SetDappSessionApproval(ctx sdk.Context, session types.DappSessionApproval) { + bz := k.cdc.MustMarshal(&session) + store := ctx.KVStore(k.storeKey) + store.Set(types.DappSessionApprovalKey(session.DappName, session.Approver), bz) +} + +func (k Keeper) DeleteDappSessionApproval(ctx sdk.Context, name, session string) { + store := ctx.KVStore(k.storeKey) + store.Delete(types.DappSessionApprovalKey(name, session)) +} + +func (k Keeper) GetDappSessionApproval(ctx sdk.Context, name, verifier string) types.DappSessionApproval { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.DappSessionApprovalKey(name, verifier)) + if bz == nil { + return types.DappSessionApproval{} + } + + sessionInfo := types.DappSessionApproval{} + k.cdc.MustUnmarshal(bz, &sessionInfo) + return sessionInfo +} + +func (k Keeper) GetDappSessionApprovals(ctx sdk.Context, name string) []types.DappSessionApproval { + store := ctx.KVStore(k.storeKey) + + sessions := []types.DappSessionApproval{} + it := sdk.KVStorePrefixIterator(store, append([]byte(types.PrefixDappSessionApprovalKey), name...)) + defer it.Close() + + for ; it.Valid(); it.Next() { + session := types.DappSessionApproval{} + k.cdc.MustUnmarshal(it.Value(), &session) + sessions = append(sessions, session) + } + return sessions +} + +func (k Keeper) GetAllDappSessionApprovals(ctx sdk.Context) []types.DappSessionApproval { + store := ctx.KVStore(k.storeKey) + + sessions := []types.DappSessionApproval{} + it := sdk.KVStorePrefixIterator(store, []byte(types.PrefixDappSessionApprovalKey)) + defer it.Close() + + for ; it.Valid(); it.Next() { + session := types.DappSessionApproval{} + k.cdc.MustUnmarshal(it.Value(), &session) + sessions = append(sessions, session) + } + return sessions +} diff --git a/x/layer2/keeper/dapp_session_approval_test.go b/x/layer2/keeper/dapp_session_approval_test.go new file mode 100644 index 000000000..39d313e1e --- /dev/null +++ b/x/layer2/keeper/dapp_session_approval_test.go @@ -0,0 +1,46 @@ +package keeper_test + +import ( + "github.com/KiraCore/sekai/x/layer2/types" +) + +func (suite *KeeperTestSuite) TestDappSessionApprovalSetGetDelete() { + approvals := []types.DappSessionApproval{ + { + Approver: "kira1q24436yrnettd6v4eu6r4t9gycnnddack4jr5r", + DappName: "dapp1", + IsApproved: true, + }, + { + Approver: "kira1q24436yrnettd6v4eu6r4t9gycnnddack4jr5r", + DappName: "dapp2", + IsApproved: false, + }, + } + + for _, approval := range approvals { + suite.app.Layer2Keeper.SetDappSessionApproval(suite.ctx, approval) + } + + for _, approval := range approvals { + c := suite.app.Layer2Keeper.GetDappSessionApproval(suite.ctx, approval.DappName, approval.Approver) + suite.Require().Equal(c, approval) + } + + allApprovals := suite.app.Layer2Keeper.GetDappSessionApprovals(suite.ctx, approvals[0].DappName) + suite.Require().Len(allApprovals, 1) + + allApprovals = suite.app.Layer2Keeper.GetAllDappSessionApprovals(suite.ctx) + suite.Require().Len(allApprovals, 2) + + suite.app.Layer2Keeper.DeleteDappSessionApproval(suite.ctx, approvals[0].DappName, approvals[0].Approver) + + allApprovals = suite.app.Layer2Keeper.GetDappSessionApprovals(suite.ctx, approvals[0].DappName) + suite.Require().Len(allApprovals, 0) + + approval := suite.app.Layer2Keeper.GetDappSessionApproval(suite.ctx, approvals[0].DappName, approvals[0].Approver) + suite.Require().Equal(approval.DappName, "") + + allApprovals = suite.app.Layer2Keeper.GetAllDappSessionApprovals(suite.ctx) + suite.Require().Len(allApprovals, 1) +} diff --git a/x/layer2/keeper/dapp_session_test.go b/x/layer2/keeper/dapp_session_test.go new file mode 100644 index 000000000..011a07715 --- /dev/null +++ b/x/layer2/keeper/dapp_session_test.go @@ -0,0 +1,93 @@ +package keeper_test + +import ( + "github.com/KiraCore/sekai/x/layer2/types" +) + +func (suite *KeeperTestSuite) TestDappSessionSetGetDelete() { + registrars := []types.ExecutionRegistrar{ + { + DappName: "dapp1", + PrevSession: nil, + CurrSession: nil, + NextSession: nil, + }, + { + DappName: "dapp2", + PrevSession: nil, + CurrSession: nil, + NextSession: &types.DappSession{ + Leader: "kira1q24436yrnettd6v4eu6r4t9gycnnddack4jr5r", + Start: 1680141605, + StatusHash: "0c", + Status: types.SessionUnscheduled, + Gateway: "dapp2.com", + }, + }, + { + DappName: "dapp3", + PrevSession: nil, + CurrSession: &types.DappSession{ + Leader: "kira1q24436yrnettd6v4eu6r4t9gycnnddack4jr5r", + Start: 1680141605, + StatusHash: "0c", + Status: types.SessionOngoing, + Gateway: "dapp3.com", + }, + NextSession: &types.DappSession{ + Leader: "kira1q24436yrnettd6v4eu6r4t9gycnnddack4jr5r", + Start: 1680141605, + StatusHash: "0c", + Status: types.SessionUnscheduled, + Gateway: "dapp3.com", + }, + }, + { + DappName: "dapp4", + PrevSession: &types.DappSession{ + Leader: "kira1q24436yrnettd6v4eu6r4t9gycnnddack4jr5r", + Start: 1680141605, + StatusHash: "0c", + Status: types.SessionAccepted, + Gateway: "dapp4.com", + }, + CurrSession: &types.DappSession{ + Leader: "kira1q24436yrnettd6v4eu6r4t9gycnnddack4jr5r", + Start: 1680141605, + StatusHash: "0c", + Status: types.SessionOngoing, + Gateway: "dapp4.com", + }, + NextSession: &types.DappSession{ + Leader: "kira1q24436yrnettd6v4eu6r4t9gycnnddack4jr5r", + Start: 1680141605, + StatusHash: "0c", + Status: types.SessionUnscheduled, + Gateway: "dapp4.com", + }, + }, + } + + for _, registrar := range registrars { + suite.app.Layer2Keeper.SetDappSession(suite.ctx, registrar) + } + + for _, registrar := range registrars { + c := suite.app.Layer2Keeper.GetDappSession(suite.ctx, registrar.DappName) + suite.Require().Equal(c, registrar) + } + + allRegistrars := suite.app.Layer2Keeper.GetAllDappSessions(suite.ctx) + suite.Require().Len(allRegistrars, 4) + + suite.app.Layer2Keeper.DeleteDappSession(suite.ctx, registrars[0].DappName) + + registrar := suite.app.Layer2Keeper.GetDappSession(suite.ctx, registrars[0].DappName) + suite.Require().Equal(registrar.DappName, "") + + allRegistrars = suite.app.Layer2Keeper.GetAllDappSessions(suite.ctx) + suite.Require().Len(allRegistrars, 3) +} + +// TODO: add test for ResetNewSession +// TODO: add test for CreateNewSession diff --git a/x/layer2/keeper/dapp_test.go b/x/layer2/keeper/dapp_test.go new file mode 100644 index 000000000..da47fe736 --- /dev/null +++ b/x/layer2/keeper/dapp_test.go @@ -0,0 +1,166 @@ +package keeper_test + +import ( + "github.com/KiraCore/sekai/x/layer2/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func (suite *KeeperTestSuite) TestDappSetGetDelete() { + dapps := []types.Dapp{ + { + Name: "dapp1", + Denom: "dapp1", + Description: "dapp1 description", + Status: types.Active, + Website: "", + Logo: "", + Social: "", + Docs: "", + Controllers: types.Controllers{ + Whitelist: types.AccountRange{ + Roles: []uint64{1}, + Addresses: []string{"kira1q24436yrnettd6v4eu6r4t9gycnnddack4jr5r"}, + }, + }, + Bin: []types.BinaryInfo{ + { + Name: "dapp1", + Hash: "dapp1", + Source: "dapp1", + Reference: "dapp1", + Type: "dapp1", + }, + }, + Pool: types.LpPoolConfig{ + Ratio: sdk.OneDec(), + Deposit: "", + Drip: 86400, + }, + Issurance: types.IssuranceConfig{ + Deposit: "", + Premint: sdk.OneInt(), + Postmint: sdk.OneInt(), + Time: 1680141605, + }, + VoteQuorum: 30, + VotePeriod: 86400, + VoteEnactment: 3000, + UpdateTimeMax: 60, + ExecutorsMin: 1, + ExecutorsMax: 2, + VerifiersMin: 1, + TotalBond: sdk.NewInt64Coin("ukex", 10000), + CreationTime: 0, + PoolFee: sdk.NewDec(1), + }, + { + Name: "dapp2", + Denom: "dapp2", + Description: "dapp2 description", + Status: types.Active, + Website: "", + Logo: "", + Social: "", + Docs: "", + Controllers: types.Controllers{ + Whitelist: types.AccountRange{ + Roles: []uint64{1}, + Addresses: []string{"kira1q24436yrnettd6v4eu6r4t9gycnnddack4jr5r"}, + }, + }, + Bin: []types.BinaryInfo{ + { + Name: "dapp2", + Hash: "dapp2", + Source: "dapp2", + Reference: "dapp2", + Type: "dapp2", + }, + }, + Pool: types.LpPoolConfig{ + Ratio: sdk.OneDec(), + Deposit: "", + Drip: 86400, + }, + Issurance: types.IssuranceConfig{ + Deposit: "", + Premint: sdk.OneInt(), + Postmint: sdk.OneInt(), + Time: 1680141605, + }, + VoteQuorum: 30, + VotePeriod: 86400, + VoteEnactment: 3000, + UpdateTimeMax: 60, + ExecutorsMin: 1, + ExecutorsMax: 2, + VerifiersMin: 1, + TotalBond: sdk.NewInt64Coin("ukex", 10000), + CreationTime: 0, + PoolFee: sdk.NewDec(1), + }, + } + + for _, dapp := range dapps { + suite.app.Layer2Keeper.SetDapp(suite.ctx, dapp) + } + + for _, dapp := range dapps { + c := suite.app.Layer2Keeper.GetDapp(suite.ctx, dapp.Name) + suite.Require().Equal(c, dapp) + } + + allCollectives := suite.app.Layer2Keeper.GetAllDapps(suite.ctx) + suite.Require().Len(allCollectives, 2) + + suite.app.Layer2Keeper.DeleteDapp(suite.ctx, dapps[0].Name) + + allCollectives = suite.app.Layer2Keeper.GetAllDapps(suite.ctx) + suite.Require().Len(allCollectives, 1) + + dapp := suite.app.Layer2Keeper.GetDapp(suite.ctx, dapps[0].Name) + suite.Require().Equal(dapp.Name, "") +} + +func (suite *KeeperTestSuite) TestUserDappBondSetGetDelete() { + userBonds := []types.UserDappBond{ + { + User: "kira1q24436yrnettd6v4eu6r4t9gycnnddack4jr5r", + DappName: "dapp1", + Bond: sdk.NewInt64Coin("ukex", 1000_000), + }, + { + User: "kira1q24436yrnettd6v4eu6r4t9gycnnddack4jr5r", + DappName: "dapp2", + Bond: sdk.NewInt64Coin("ukex", 1000_000), + }, + } + + for _, userBond := range userBonds { + suite.app.Layer2Keeper.SetUserDappBond(suite.ctx, userBond) + } + + for _, userBond := range userBonds { + c := suite.app.Layer2Keeper.GetUserDappBond(suite.ctx, userBond.DappName, userBond.User) + suite.Require().Equal(c, userBond) + } + + allBonds := suite.app.Layer2Keeper.GetUserDappBonds(suite.ctx, userBonds[0].DappName) + suite.Require().Len(allBonds, 1) + + allBonds = suite.app.Layer2Keeper.GetAllUserDappBonds(suite.ctx) + suite.Require().Len(allBonds, 2) + + suite.app.Layer2Keeper.DeleteUserDappBond(suite.ctx, userBonds[0].DappName, userBonds[0].User) + + allBonds = suite.app.Layer2Keeper.GetUserDappBonds(suite.ctx, userBonds[0].DappName) + suite.Require().Len(allBonds, 0) + + userBond := suite.app.Layer2Keeper.GetUserDappBond(suite.ctx, userBonds[0].DappName, userBonds[0].User) + suite.Require().Equal(userBond.DappName, "") + + allBonds = suite.app.Layer2Keeper.GetAllUserDappBonds(suite.ctx) + suite.Require().Len(allBonds, 1) +} + +// TODO: add test for ExecuteDappRemove diff --git a/x/layer2/keeper/grpc_query.go b/x/layer2/keeper/grpc_query.go new file mode 100644 index 000000000..d9258839c --- /dev/null +++ b/x/layer2/keeper/grpc_query.go @@ -0,0 +1,44 @@ +package keeper + +import ( + "context" + + "github.com/KiraCore/sekai/x/layer2/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +var _ types.QueryServer = Keeper{} + +func (k Keeper) ExecutionRegistrar(goCtx context.Context, request *types.QueryExecutionRegistrarRequest) (*types.QueryExecutionRegistrarResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + dapp := k.GetDapp(ctx, request.Identifier) + registarar := k.GetDappSession(ctx, request.Identifier) + + return &types.QueryExecutionRegistrarResponse{ + Dapp: &dapp, + ExecutionRegistrar: ®istarar, + }, nil +} + +func (k Keeper) AllDapps(goCtx context.Context, request *types.QueryAllDappsRequest) (*types.QueryAllDappsResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + return &types.QueryAllDappsResponse{ + Dapps: k.GetAllDapps(ctx), + }, nil +} + +func (k Keeper) TransferDapps(goCtx context.Context, request *types.QueryTransferDappsRequest) (*types.QueryTransferDappsResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + return &types.QueryTransferDappsResponse{ + XAMs: k.GetXAMs(ctx), + }, nil +} + +func (k Keeper) GlobalTokens(goCtx context.Context, request *types.QueryGlobalTokensRequest) (*types.QueryGlobalTokensResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + return &types.QueryGlobalTokensResponse{ + Tokens: k.GetTokenInfos(ctx), + }, nil +} diff --git a/x/layer2/keeper/keeper.go b/x/layer2/keeper/keeper.go new file mode 100644 index 000000000..40a52549d --- /dev/null +++ b/x/layer2/keeper/keeper.go @@ -0,0 +1,89 @@ +package keeper + +import ( + govkeeper "github.com/KiraCore/sekai/x/gov/keeper" + govtypes "github.com/KiraCore/sekai/x/gov/types" + "github.com/KiraCore/sekai/x/layer2/types" + "github.com/cosmos/cosmos-sdk/codec" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +type Keeper struct { + cdc codec.BinaryCodec + storeKey sdk.StoreKey + bk types.BankKeeper + sk types.StakingKeeper + gk govkeeper.Keeper + spk types.SpendingKeeper +} + +func NewKeeper(storeKey sdk.StoreKey, cdc codec.BinaryCodec, bk types.BankKeeper, sk types.StakingKeeper, gk govkeeper.Keeper, spk types.SpendingKeeper) Keeper { + return Keeper{ + cdc: cdc, + storeKey: storeKey, + bk: bk, + sk: sk, + gk: gk, + spk: spk, + } +} + +// BondDenom returns the denom that is basically used for fee payment +func (k Keeper) BondDenom(ctx sdk.Context) string { + return "ukex" +} + +func (k Keeper) CheckIfAllowedPermission(ctx sdk.Context, addr sdk.AccAddress, permValue govtypes.PermValue) bool { + return govkeeper.CheckIfAllowedPermission(ctx, k.gk, addr, govtypes.PermHandleBasketEmergency) +} + +func (k Keeper) IsAllowedAddress(ctx sdk.Context, address sdk.AccAddress, permInfo types.Controllers) bool { + for _, owner := range permInfo.Whitelist.Addresses { + if owner == address.String() { + return true + } + } + + actor, found := k.gk.GetNetworkActorByAddress(ctx, address) + if !found { + return false + } + + flags := make(map[uint64]bool) + for _, role := range permInfo.Whitelist.Roles { + flags[role] = true + } + + for _, role := range actor.Roles { + if flags[role] { + return true + } + } + return false +} + +func (k Keeper) AllowedAddresses(ctx sdk.Context, permInfo types.Controllers) []string { + addrs := []string{} + flags := make(map[string]bool) + + for _, owner := range permInfo.Whitelist.Addresses { + if flags[owner] == false { + flags[owner] = true + addrs = append(addrs, owner) + } + } + + for _, role := range permInfo.Whitelist.Roles { + actorIter := k.gk.GetNetworkActorsByRole(ctx, role) + + for ; actorIter.Valid(); actorIter.Next() { + addr := sdk.AccAddress(actorIter.Value()).String() + if flags[addr] == false { + flags[addr] = true + addrs = append(addrs, addr) + } + } + } + + return addrs +} diff --git a/x/layer2/keeper/keeper_test.go b/x/layer2/keeper/keeper_test.go new file mode 100644 index 000000000..a34f9156e --- /dev/null +++ b/x/layer2/keeper/keeper_test.go @@ -0,0 +1,43 @@ +package keeper_test + +import ( + "encoding/hex" + "testing" + + simapp "github.com/KiraCore/sekai/app" + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/suite" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" +) + +func newPubKey(pk string) (res cryptotypes.PubKey) { + pkBytes, err := hex.DecodeString(pk) + if err != nil { + panic(err) + } + + pubkey := &ed25519.PubKey{Key: pkBytes} + + return pubkey +} + +type KeeperTestSuite struct { + suite.Suite + + ctx sdk.Context + app *simapp.SekaiApp +} + +func (suite *KeeperTestSuite) SetupTest() { + checkTx := false + app := simapp.Setup(checkTx) + + suite.ctx = app.BaseApp.NewContext(checkTx, tmproto.Header{Height: 1}) + suite.app = app +} + +func TestKeeperTestSuite(t *testing.T) { + suite.Run(t, new(KeeperTestSuite)) +} diff --git a/x/layer2/keeper/lp_swap_redeem_convert.go b/x/layer2/keeper/lp_swap_redeem_convert.go new file mode 100644 index 000000000..f88b896af --- /dev/null +++ b/x/layer2/keeper/lp_swap_redeem_convert.go @@ -0,0 +1,138 @@ +package keeper + +import ( + "github.com/KiraCore/sekai/x/layer2/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func (k Keeper) LpTokenPrice(ctx sdk.Context, dapp types.Dapp) sdk.Dec { + lpToken := dapp.LpToken() + lpSupply := k.bk.GetSupply(ctx, lpToken).Amount + totalBond := dapp.TotalBond.Amount + if lpSupply.IsZero() { + return sdk.ZeroDec() + } + return totalBond.ToDec().Quo(lpSupply.ToDec()) +} + +func (k Keeper) OnCollectFee(ctx sdk.Context, fee sdk.Coins) error { + // TODO: The fixed fee will be applied after the swap from where + // - `50%` of the corresponding tokens must be **burned** (deminted) + // - `25%` given as a reward to liquidity providers + // - `25%` will be split between **ACTIVE** dApp executors, and verifiers (fisherman). + // Additionally, the premint and postmint tokens can be used to incentivize operators before + // dApp starts to generate revenue. + err := k.bk.BurnCoins(ctx, types.ModuleName, fee) + if err != nil { + return err + } + return nil +} + +func (k Keeper) RedeemDappPoolTx(ctx sdk.Context, addr sdk.AccAddress, dapp types.Dapp, poolFee sdk.Dec, lpTokenAmount sdk.Coin) (sdk.Coin, error) { + // totalBond * lpSupply = (totalBond - swapBond) * (lpSupply + swapLpAmount) + lpToken := dapp.LpToken() + if lpToken != lpTokenAmount.Denom { + return sdk.Coin{}, types.ErrInvalidLpToken + } + lpSupply := k.bk.GetSupply(ctx, lpToken).Amount + totalBond := dapp.TotalBond.Amount + swapLpAmount := lpTokenAmount.Amount + totalBondAfterSwap := totalBond.Mul(lpSupply).Quo(lpSupply.Add(swapLpAmount)) + swapBond := totalBond.Sub(totalBondAfterSwap) + + dapp.TotalBond.Amount = totalBondAfterSwap + k.SetDapp(ctx, dapp) + + fee := swapBond.ToDec().Mul(poolFee).RoundInt() + if fee.IsPositive() { + feeCoin := sdk.NewCoin(dapp.TotalBond.Denom, fee) + err := k.OnCollectFee(ctx, sdk.Coins{feeCoin}) + if err != nil { + return sdk.Coin{}, err + } + } + + // send lp tokens to the module account + err := k.bk.SendCoinsFromAccountToModule(ctx, addr, types.ModuleName, sdk.Coins{lpTokenAmount}) + if err != nil { + return sdk.Coin{}, err + } + + // send tokens to user + userReceiveCoin := sdk.NewCoin(dapp.TotalBond.Denom, swapBond.Sub(fee)) + err = k.bk.SendCoinsFromModuleToAccount(ctx, types.ModuleName, addr, sdk.Coins{userReceiveCoin}) + if err != nil { + return sdk.Coin{}, err + } + + properties := k.gk.GetNetworkProperties(ctx) + threshold := sdk.NewInt(int64(properties.DappLiquidationThreshold)).Mul(sdk.NewInt(1000_000)) + if dapp.LiquidationStart == 0 && dapp.TotalBond.Amount.LT(threshold) { + dapp.LiquidationStart = uint64(ctx.BlockTime().Unix()) + k.SetDapp(ctx, dapp) + } + + return userReceiveCoin, nil +} + +func (k Keeper) SwapDappPoolTx(ctx sdk.Context, addr sdk.AccAddress, dapp types.Dapp, poolFee sdk.Dec, swapBond sdk.Coin) (sdk.Coin, error) { + // totalBond * lpSupply = (totalBond + swapBond) * (lpSupply - swapLpAmount) + lpToken := dapp.LpToken() + if swapBond.Denom != k.BondDenom(ctx) { + return sdk.Coin{}, types.ErrInvalidLpToken + } + lpSupply := k.bk.GetSupply(ctx, lpToken).Amount + totalBond := dapp.TotalBond.Amount + swapBondAmount := swapBond.Amount + totalLpAfterSwap := totalBond.Mul(lpSupply).Quo(totalBond.Add(swapBondAmount)) + swapLpAmount := lpSupply.Sub(totalLpAfterSwap) + + dapp.TotalBond.Amount = dapp.TotalBond.Amount.Add(swapBond.Amount) + k.SetDapp(ctx, dapp) + + fee := swapLpAmount.ToDec().Mul(poolFee).RoundInt() + if fee.IsPositive() { + feeCoin := sdk.NewCoin(lpToken, fee) + err := k.OnCollectFee(ctx, sdk.Coins{feeCoin}) + if err != nil { + return sdk.Coin{}, err + } + } + + // send lp tokens to the module account + err := k.bk.SendCoinsFromAccountToModule(ctx, addr, types.ModuleName, sdk.Coins{swapBond}) + if err != nil { + return sdk.Coin{}, err + } + + // send tokens to user + userReceiveCoin := sdk.NewCoin(lpToken, swapLpAmount.Sub(fee)) + err = k.bk.SendCoinsFromModuleToAccount(ctx, types.ModuleName, addr, sdk.Coins{userReceiveCoin}) + if err != nil { + return sdk.Coin{}, err + } + + properties := k.gk.GetNetworkProperties(ctx) + threshold := sdk.NewInt(int64(properties.DappLiquidationThreshold)).Mul(sdk.NewInt(1000_000)) + if dapp.LiquidationStart != 0 && dapp.TotalBond.Amount.GTE(threshold) { + dapp.LiquidationStart = 0 + k.SetDapp(ctx, dapp) + } + + return userReceiveCoin, nil +} + +func (k Keeper) ConvertDappPoolTx( + ctx sdk.Context, + addr sdk.AccAddress, + dapp1 types.Dapp, + dapp2 types.Dapp, + lpToken sdk.Coin, +) (sdk.Coin, error) { + swapBond, err := k.RedeemDappPoolTx(ctx, addr, dapp1, dapp1.PoolFee.Quo(sdk.NewDec(2)), lpToken) + if err != nil { + return sdk.Coin{}, err + } + return k.SwapDappPoolTx(ctx, addr, dapp2, dapp2.PoolFee.Quo(sdk.NewDec(2)), swapBond) +} diff --git a/x/layer2/keeper/lp_swap_redeem_convert_test.go b/x/layer2/keeper/lp_swap_redeem_convert_test.go new file mode 100644 index 000000000..61a84b3cc --- /dev/null +++ b/x/layer2/keeper/lp_swap_redeem_convert_test.go @@ -0,0 +1,284 @@ +package keeper_test + +import ( + "github.com/KiraCore/sekai/x/layer2/types" + sdk "github.com/cosmos/cosmos-sdk/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" + "github.com/tendermint/tendermint/crypto/ed25519" +) + +func (suite *KeeperTestSuite) TestLpTokenPrice() { + dapp := types.Dapp{ + Name: "dapp1", + Denom: "dapp1", + Description: "dapp1 description", + Status: types.Active, + Website: "", + Logo: "", + Social: "", + Docs: "", + Controllers: types.Controllers{ + Whitelist: types.AccountRange{ + Roles: []uint64{1}, + Addresses: []string{"kira1q24436yrnettd6v4eu6r4t9gycnnddack4jr5r"}, + }, + }, + Bin: []types.BinaryInfo{ + { + Name: "dapp1", + Hash: "dapp1", + Source: "dapp1", + Reference: "dapp1", + Type: "dapp1", + }, + }, + Pool: types.LpPoolConfig{ + Ratio: sdk.OneDec(), + Deposit: "", + Drip: 86400, + }, + Issurance: types.IssuranceConfig{ + Deposit: "", + Premint: sdk.OneInt(), + Postmint: sdk.OneInt(), + Time: 1680141605, + }, + VoteQuorum: 30, + VotePeriod: 86400, + VoteEnactment: 3000, + UpdateTimeMax: 60, + ExecutorsMin: 1, + ExecutorsMax: 2, + VerifiersMin: 1, + TotalBond: sdk.NewInt64Coin("ukex", 10000), + CreationTime: 0, + PoolFee: sdk.NewDec(1), + } + + suite.app.Layer2Keeper.SetDapp(suite.ctx, dapp) + + lpToken := dapp.LpToken() + err := suite.app.BankKeeper.MintCoins(suite.ctx, minttypes.ModuleName, sdk.Coins{sdk.NewInt64Coin(lpToken, 10000)}) + suite.Require().NoError(err) + + price := suite.app.Layer2Keeper.LpTokenPrice(suite.ctx, dapp) + suite.Require().Equal(price, sdk.OneDec()) +} + +func (suite *KeeperTestSuite) TestOnCollectFee() { + coins := sdk.Coins{sdk.NewInt64Coin("ukex", 10000)} + err := suite.app.BankKeeper.MintCoins(suite.ctx, types.ModuleName, coins) + suite.Require().NoError(err) + + moduleAddr := authtypes.NewModuleAddress(types.ModuleName) + balances := suite.app.BankKeeper.GetAllBalances(suite.ctx, moduleAddr) + suite.Require().False(balances.Empty()) + + err = suite.app.Layer2Keeper.OnCollectFee(suite.ctx, coins) + suite.Require().NoError(err) + + balances = suite.app.BankKeeper.GetAllBalances(suite.ctx, moduleAddr) + suite.Require().True(balances.Empty()) +} + +func (suite *KeeperTestSuite) TestRedeemDappPoolTx() { + dapp := types.Dapp{ + Name: "dapp1", + Denom: "dapp1", + Description: "dapp1 description", + Status: types.Active, + Website: "", + Logo: "", + Social: "", + Docs: "", + Controllers: types.Controllers{ + Whitelist: types.AccountRange{ + Roles: []uint64{1}, + Addresses: []string{"kira1q24436yrnettd6v4eu6r4t9gycnnddack4jr5r"}, + }, + }, + Bin: []types.BinaryInfo{ + { + Name: "dapp1", + Hash: "dapp1", + Source: "dapp1", + Reference: "dapp1", + Type: "dapp1", + }, + }, + Pool: types.LpPoolConfig{ + Ratio: sdk.OneDec(), + Deposit: "", + Drip: 86400, + }, + Issurance: types.IssuranceConfig{ + Deposit: "", + Premint: sdk.OneInt(), + Postmint: sdk.OneInt(), + Time: 1680141605, + }, + VoteQuorum: 30, + VotePeriod: 86400, + VoteEnactment: 3000, + UpdateTimeMax: 60, + ExecutorsMin: 1, + ExecutorsMax: 2, + VerifiersMin: 1, + TotalBond: sdk.NewInt64Coin("ukex", 10000), + CreationTime: 0, + PoolFee: sdk.NewDec(1), + } + + suite.app.Layer2Keeper.SetDapp(suite.ctx, dapp) + + lpToken := dapp.LpToken() + lpCoins := sdk.Coins{sdk.NewInt64Coin(lpToken, 10000)} + err := suite.app.BankKeeper.MintCoins(suite.ctx, minttypes.ModuleName, lpCoins) + suite.Require().NoError(err) + + addr := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address().Bytes()) + err = suite.app.BankKeeper.SendCoinsFromModuleToAccount(suite.ctx, minttypes.ModuleName, addr, lpCoins) + suite.Require().NoError(err) + + err = suite.app.BankKeeper.MintCoins(suite.ctx, types.ModuleName, sdk.Coins{dapp.TotalBond}) + suite.Require().NoError(err) + + price := suite.app.Layer2Keeper.LpTokenPrice(suite.ctx, dapp) + suite.Require().Equal(price, sdk.OneDec()) + + out, err := suite.app.Layer2Keeper.RedeemDappPoolTx(suite.ctx, addr, dapp, sdk.NewDecWithPrec(1, 1), sdk.NewInt64Coin(lpToken, 1000)) + suite.Require().NoError(err) + suite.Require().Equal(out.String(), "819ukex") + + out, err = suite.app.Layer2Keeper.SwapDappPoolTx(suite.ctx, addr, dapp, sdk.NewDecWithPrec(1, 1), sdk.NewInt64Coin("ukex", 800)) + suite.Require().NoError(err) + suite.Require().Equal(out.String(), "667lp/dapp1") +} + +func (suite *KeeperTestSuite) TestConvertDappPoolTx() { + dapps := []types.Dapp{ + { + Name: "dapp1", + Denom: "dapp1", + Description: "dapp1 description", + Status: types.Active, + Website: "", + Logo: "", + Social: "", + Docs: "", + Controllers: types.Controllers{ + Whitelist: types.AccountRange{ + Roles: []uint64{1}, + Addresses: []string{"kira1q24436yrnettd6v4eu6r4t9gycnnddack4jr5r"}, + }, + }, + Bin: []types.BinaryInfo{ + { + Name: "dapp1", + Hash: "dapp1", + Source: "dapp1", + Reference: "dapp1", + Type: "dapp1", + }, + }, + Pool: types.LpPoolConfig{ + Ratio: sdk.OneDec(), + Deposit: "", + Drip: 86400, + }, + Issurance: types.IssuranceConfig{ + Deposit: "", + Premint: sdk.OneInt(), + Postmint: sdk.OneInt(), + Time: 1680141605, + }, + VoteQuorum: 30, + VotePeriod: 86400, + VoteEnactment: 3000, + UpdateTimeMax: 60, + ExecutorsMin: 1, + ExecutorsMax: 2, + VerifiersMin: 1, + TotalBond: sdk.NewInt64Coin("ukex", 10000), + CreationTime: 0, + PoolFee: sdk.NewDec(1), + }, + { + Name: "dapp2", + Denom: "dapp2", + Description: "dapp2 description", + Status: types.Active, + Website: "", + Logo: "", + Social: "", + Docs: "", + Controllers: types.Controllers{ + Whitelist: types.AccountRange{ + Roles: []uint64{1}, + Addresses: []string{"kira1q24436yrnettd6v4eu6r4t9gycnnddack4jr5r"}, + }, + }, + Bin: []types.BinaryInfo{ + { + Name: "dapp2", + Hash: "dapp2", + Source: "dapp2", + Reference: "dapp2", + Type: "dapp2", + }, + }, + Pool: types.LpPoolConfig{ + Ratio: sdk.OneDec(), + Deposit: "", + Drip: 86400, + }, + Issurance: types.IssuranceConfig{ + Deposit: "", + Premint: sdk.OneInt(), + Postmint: sdk.OneInt(), + Time: 1680141605, + }, + VoteQuorum: 30, + VotePeriod: 86400, + VoteEnactment: 3000, + UpdateTimeMax: 60, + ExecutorsMin: 1, + ExecutorsMax: 2, + VerifiersMin: 1, + TotalBond: sdk.NewInt64Coin("ukex", 10000), + CreationTime: 0, + PoolFee: sdk.NewDec(1), + }, + } + + for _, dapp := range dapps { + suite.app.Layer2Keeper.SetDapp(suite.ctx, dapp) + } + dapp1 := dapps[0] + dapp2 := dapps[1] + + addr := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address().Bytes()) + + lpToken1 := dapp1.LpToken() + lpCoins1 := sdk.Coins{sdk.NewInt64Coin(lpToken1, 10000)} + err := suite.app.BankKeeper.MintCoins(suite.ctx, minttypes.ModuleName, lpCoins1) + suite.Require().NoError(err) + err = suite.app.BankKeeper.SendCoinsFromModuleToAccount(suite.ctx, minttypes.ModuleName, addr, lpCoins1) + suite.Require().NoError(err) + + lpToken2 := dapp2.LpToken() + lpCoins2 := sdk.Coins{sdk.NewInt64Coin(lpToken2, 10000)} + err = suite.app.BankKeeper.MintCoins(suite.ctx, types.ModuleName, lpCoins2) + suite.Require().NoError(err) + + err = suite.app.BankKeeper.MintCoins(suite.ctx, types.ModuleName, sdk.Coins{dapp1.TotalBond}) + suite.Require().NoError(err) + + price := suite.app.Layer2Keeper.LpTokenPrice(suite.ctx, dapp1) + suite.Require().Equal(price, sdk.OneDec()) + + out, err := suite.app.Layer2Keeper.ConvertDappPoolTx(suite.ctx, addr, dapp1, dapp2, sdk.NewInt64Coin(lpToken1, 1000)) + suite.Require().NoError(err) + suite.Require().Equal(out.String(), "218lp/dapp2") +} diff --git a/x/layer2/keeper/msg_server.go b/x/layer2/keeper/msg_server.go new file mode 100644 index 000000000..0f8c734d6 --- /dev/null +++ b/x/layer2/keeper/msg_server.go @@ -0,0 +1,840 @@ +package keeper + +import ( + "context" + + govtypes "github.com/KiraCore/sekai/x/gov/types" + "github.com/KiraCore/sekai/x/layer2/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +type msgServer struct { + keeper Keeper +} + +// NewMsgServerImpl returns an implementation of the bank MsgServer interface +// for the provided Keeper. +func NewMsgServerImpl(keeper Keeper) types.MsgServer { + return &msgServer{ + keeper: keeper, + } +} + +var _ types.MsgServer = msgServer{} + +func (k msgServer) CreateDappProposal(goCtx context.Context, msg *types.MsgCreateDappProposal) (*types.MsgCreateDappProposalResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + properties := k.keeper.gk.GetNetworkProperties(ctx) + addr := sdk.MustAccAddressFromBech32(msg.Sender) + + // permission check PermCreateDappProposalWithoutBond + isAllowed := k.keeper.CheckIfAllowedPermission(ctx, addr, govtypes.PermCreateDappProposalWithoutBond) + if !isAllowed { + minDappBond := properties.MinDappBond + if msg.Bond.Denom != k.keeper.BondDenom(ctx) { + return nil, types.ErrInvalidDappBondDenom + } + // check 1% of properties.MinDappBond + if msg.Bond.Amount.Mul(sdk.NewInt(100)).LT(sdk.NewInt(int64(minDappBond)).Mul(sdk.NewInt(1000_000))) { + return nil, types.ErrLowAmountToCreateDappProposal + } + } + + // send initial bond to module account + if msg.Bond.IsPositive() { + err := k.keeper.bk.SendCoinsFromAccountToModule(ctx, addr, types.ModuleName, sdk.Coins{msg.Bond}) + if err != nil { + return nil, err + } + } + + dapp := k.keeper.GetDapp(ctx, msg.Dapp.Name) + if dapp.Name != "" { + return nil, types.ErrDappAlreadyExists + } + + // create dapp object + msg.Dapp.TotalBond = msg.Bond + msg.Dapp.CreationTime = uint64(ctx.BlockTime().Unix()) + msg.Dapp.Status = types.Bootstrap + k.keeper.SetDapp(ctx, msg.Dapp) + k.keeper.SetUserDappBond(ctx, types.UserDappBond{ + DappName: msg.Dapp.Name, + User: msg.Sender, + Bond: msg.Bond, + }) + + return &types.MsgCreateDappProposalResponse{}, nil +} + +func (k msgServer) BondDappProposal(goCtx context.Context, msg *types.MsgBondDappProposal) (*types.MsgBondDappProposalResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + dapp := k.keeper.GetDapp(ctx, msg.DappName) + if dapp.Name == "" { + return nil, types.ErrDappDoesNotExist + } + + if k.keeper.BondDenom(ctx) != msg.Bond.Denom { + return nil, types.ErrInvalidDappBondDenom + } + + // send initial bond to module account + addr := sdk.MustAccAddressFromBech32(msg.Sender) + err := k.keeper.bk.SendCoinsFromAccountToModule(ctx, addr, types.ModuleName, sdk.Coins{msg.Bond}) + if err != nil { + return nil, err + } + + properties := k.keeper.gk.GetNetworkProperties(ctx) + if dapp.TotalBond.Amount.GTE(sdk.NewInt(int64(properties.MaxDappBond)).Mul(sdk.NewInt(1000_000))) { + return nil, types.ErrMaxDappBondReached + } + + dapp.TotalBond = dapp.TotalBond.Add(msg.Bond) + k.keeper.SetDapp(ctx, dapp) + + userDappBond := k.keeper.GetUserDappBond(ctx, msg.DappName, msg.Sender) + if userDappBond.User != "" { + userDappBond.Bond = userDappBond.Bond.Add(msg.Bond) + } else { + userDappBond = types.UserDappBond{ + User: msg.Sender, + DappName: msg.DappName, + Bond: msg.Bond, + } + } + k.keeper.SetUserDappBond(ctx, userDappBond) + + return &types.MsgBondDappProposalResponse{}, nil +} + +func (k msgServer) ReclaimDappBondProposal(goCtx context.Context, msg *types.MsgReclaimDappBondProposal) (*types.MsgReclaimDappBondProposalResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + userDappBond := k.keeper.GetUserDappBond(ctx, msg.DappName, msg.Sender) + if userDappBond.DappName == "" { + return nil, types.ErrUserDappBondDoesNotExist + } + if userDappBond.Bond.Denom != msg.Bond.Denom { + return nil, types.ErrInvalidDappBondDenom + } + if userDappBond.Bond.Amount.LT(msg.Bond.Amount) { + return nil, types.ErrNotEnoughUserDappBond + } + + userDappBond.Bond.Amount = userDappBond.Bond.Amount.Sub(msg.Bond.Amount) + k.keeper.SetUserDappBond(ctx, userDappBond) + + // send tokens back to user + addr := sdk.MustAccAddressFromBech32(msg.Sender) + err := k.keeper.bk.SendCoinsFromModuleToAccount(ctx, types.ModuleName, addr, sdk.Coins{msg.Bond}) + if err != nil { + return nil, err + } + + return &types.MsgReclaimDappBondProposalResponse{}, nil +} + +func (k msgServer) JoinDappVerifierWithBond(goCtx context.Context, msg *types.MsgJoinDappVerifierWithBond) (*types.MsgJoinDappVerifierWithBondResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + dapp := k.keeper.GetDapp(ctx, msg.DappName) + operator := k.keeper.GetDappOperator(ctx, msg.DappName, msg.Sender) + if operator.DappName != "" && operator.Verifier { + return nil, types.ErrAlreadyADappVerifier + } + + properties := k.keeper.gk.GetNetworkProperties(ctx) + verifierBond := properties.DappVerifierBond + totalSupply := dapp.GetLpTokenSupply() + dappBondLpToken := dapp.LpToken() + lpTokenAmount := totalSupply.ToDec().Mul(verifierBond).RoundInt() + verifierBondCoins := sdk.NewCoins(sdk.NewCoin(dappBondLpToken, lpTokenAmount)) + addr := sdk.MustAccAddressFromBech32(msg.Interx) + if verifierBondCoins.IsAllPositive() { + err := k.keeper.bk.SendCoinsFromAccountToModule(ctx, addr, types.ModuleName, verifierBondCoins) + if err != nil { + return nil, err + } + } + + if operator.DappName == "" { + operator = types.DappOperator{ + DappName: msg.DappName, + Interx: msg.Interx, + Operator: msg.Sender, + Executor: false, + Verifier: true, + Status: types.OperatorActive, + BondedLpAmount: lpTokenAmount, + } + } else { + operator.Verifier = true + operator.BondedLpAmount = lpTokenAmount + } + k.keeper.SetDappOperator(ctx, operator) + return &types.MsgJoinDappVerifierWithBondResponse{}, nil +} + +func (k msgServer) ExitDapp(goCtx context.Context, msg *types.MsgExitDapp) (*types.MsgExitDappResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + operator := k.keeper.GetDappOperator(ctx, msg.DappName, msg.Sender) + if operator.DappName == "" { + return nil, types.ErrNotDappOperator + } + + if operator.Status == types.OperatorJailed { + return nil, types.ErrOperatorJailed + } + if operator.Status == types.OperatorExiting { + return nil, types.ErrOperatorAlreadyExiting + } + + operator.Status = types.OperatorExiting + k.keeper.SetDappOperator(ctx, operator) + + return &types.MsgExitDappResponse{}, nil +} + +func (k msgServer) PauseDappTx(goCtx context.Context, msg *types.MsgPauseDappTx) (*types.MsgPauseDappTxResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + operator := k.keeper.GetDappOperator(ctx, msg.DappName, msg.Sender) + if operator.DappName == "" { + return nil, types.ErrNotDappOperator + } + if operator.Status != types.OperatorActive { + return nil, types.ErrDappOperatorNotActive + } + operator.Status = types.OperatorPaused + k.keeper.SetDappOperator(ctx, operator) + + // TODO: if the validator status changes to paused, inactive or jailed then his executor status for ALL dApps should + // also change to the same paused, inactive or jailed status so that all other executors can be informed that + // a specific node operator is not available and will miss his execution round. + + return &types.MsgPauseDappTxResponse{}, nil +} + +func (k msgServer) UnPauseDappTx(goCtx context.Context, msg *types.MsgUnPauseDappTx) (*types.MsgUnPauseDappTxResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + operator := k.keeper.GetDappOperator(ctx, msg.DappName, msg.Sender) + if operator.DappName == "" { + return nil, types.ErrNotDappOperator + } + if operator.Status != types.OperatorPaused { + return nil, types.ErrDappOperatorNotPaused + } + operator.Status = types.OperatorActive + k.keeper.SetDappOperator(ctx, operator) + + return &types.MsgUnPauseDappTxResponse{}, nil +} + +func (k msgServer) ReactivateDappTx(goCtx context.Context, msg *types.MsgReactivateDappTx) (*types.MsgReactivateDappTxResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + operator := k.keeper.GetDappOperator(ctx, msg.DappName, msg.Sender) + if operator.DappName == "" { + return nil, types.ErrNotDappOperator + } + if operator.Status != types.OperatorInactive { + return nil, types.ErrDappOperatorNotInActive + } + operator.Status = types.OperatorActive + k.keeper.SetDappOperator(ctx, operator) + + return &types.MsgReactivateDappTxResponse{}, nil +} + +func (k msgServer) ExecuteDappTx(goCtx context.Context, msg *types.MsgExecuteDappTx) (*types.MsgExecuteDappTxResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + session := k.keeper.GetDappSession(ctx, msg.DappName) + if session.DappName == "" { + return nil, types.ErrNoDappSessionExists + } + + if session.NextSession.Leader != msg.Sender { + return nil, types.ErrNotDappSessionLeader + } + session.NextSession.Gateway = msg.Gateway + session.NextSession.Status = types.SessionOngoing + + if session.CurrSession == nil { + session.CurrSession = session.NextSession + k.keeper.CreateNewSession(ctx, msg.DappName, session.CurrSession.Leader) + } + + return &types.MsgExecuteDappTxResponse{}, nil +} + +func (k msgServer) TransitionDappTx(goCtx context.Context, msg *types.MsgTransitionDappTx) (*types.MsgTransitionDappTxResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + dapp := k.keeper.GetDapp(ctx, msg.DappName) + if dapp.Name != "" { + return nil, types.ErrDappDoesNotExist + } + + if msg.Version != dapp.Version() { + return nil, types.ErrInvalidDappVersion + } + + session := k.keeper.GetDappSession(ctx, msg.DappName) + if session.DappName == "" { + return nil, types.ErrDappSessionDoesNotExist + } + session.NextSession.StatusHash = msg.StatusHash + session.NextSession.OnchainMessages = msg.OnchainMessages + k.keeper.SetDappSession(ctx, session) + + return &types.MsgTransitionDappTxResponse{}, nil +} + +func (k msgServer) DenounceLeaderTx(goCtx context.Context, msg *types.MsgDenounceLeaderTx) (*types.MsgDenounceLeaderTxResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + operator := k.keeper.GetDappOperator(ctx, msg.DappName, msg.Sender) + if !operator.Verifier { + return nil, types.ErrNotDappVerifier + } + + session := k.keeper.GetDappSession(ctx, msg.DappName) + if session.CurrSession == nil || session.CurrSession.StatusHash == "" { + return nil, types.ErrVerificationNotAllowedOnEmptySession + } + if session.CurrSession.Leader == msg.Sender { + return nil, types.ErrLeaderCannotEvaluateSelfSubmission + } + + dapp := k.keeper.GetDapp(ctx, msg.DappName) + if dapp.Name != "" { + return nil, types.ErrDappDoesNotExist + } + + if msg.Version != dapp.Version() { + return nil, types.ErrInvalidDappVersion + } + + // TODO: update it to be put on session + k.keeper.SetDappLeaderDenouncement(ctx, types.DappLeaderDenouncement{ + DappName: msg.DappName, + Leader: msg.Leader, + Sender: msg.Sender, + Denouncement: msg.DenounceText, + }) + + return &types.MsgDenounceLeaderTxResponse{}, nil +} + +func (k msgServer) ApproveDappTransitionTx(goCtx context.Context, msg *types.MsgApproveDappTransitionTx) (*types.MsgApproveDappTransitionTxResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + dapp := k.keeper.GetDapp(ctx, msg.DappName) + if dapp.Name != "" { + return nil, types.ErrDappDoesNotExist + } + + if msg.Version != dapp.Version() { + return nil, types.ErrInvalidDappVersion + } + + operator := k.keeper.GetDappOperator(ctx, msg.DappName, msg.Sender) + if !operator.Verifier { + return nil, types.ErrNotDappVerifier + } + + session := k.keeper.GetDappSession(ctx, msg.DappName) + if session.CurrSession == nil || session.CurrSession.StatusHash == "" { + return nil, types.ErrVerificationNotAllowedOnEmptySession + } + if session.CurrSession.Leader == msg.Sender { + return nil, types.ErrLeaderCannotEvaluateSelfSubmission + } + k.keeper.SetDappSessionApproval(ctx, types.DappSessionApproval{ + DappName: msg.DappName, + Approver: msg.Sender, + IsApproved: true, + }) + + // TODO: check after full implementation + // The current session status can change to `accepted` if and only if 2/3 of executors who are NOT a leader send + // `approve-dapp-transition-tx` and no verifiers submitted the evidence of faults requesting the application to be halted, + // additionally the total number of approvals must be no less then `verifiers_min`. + // It might happen that the application will only have a single executor, + // meaning that there is always an insufficient number of verifiers to approve the transition. + // In such cases where only one executor of the dApp exists, the approval of **NO LESS THAN** 2/3 of ALL active verifiers is required + // for the session state to change into `accepted` (the `verifiers_min` rule also applies). + + // if more than 2/3 verify, convert to accepted + verifiers := k.keeper.GetDappVerifiers(ctx, msg.DappName) + approvals := k.keeper.GetDappSessionApprovals(ctx, msg.DappName) + if len(verifiers)*2/3 <= len(approvals) { + session.CurrSession.Status = types.SessionAccepted + k.keeper.SetDappSession(ctx, session) + k.keeper.CreateNewSession(ctx, msg.DappName, session.NextSession.Leader) + + isApprover := make(map[string]bool) + for _, approval := range approvals { + isApprover[approval.Approver] = true + } + + // dapp operator rank management + executor := k.keeper.GetDappOperator(ctx, session.DappName, session.CurrSession.Leader) + k.keeper.HandleSessionParticipation(ctx, executor, true) + for _, verifier := range verifiers { + k.keeper.HandleSessionParticipation(ctx, verifier, isApprover[verifier.Operator]) + } + } + + return &types.MsgApproveDappTransitionTxResponse{}, nil +} + +func (k msgServer) RejectDappTransitionTx(goCtx context.Context, msg *types.MsgRejectDappTransitionTx) (*types.MsgRejectDappTransitionTxResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + operator := k.keeper.GetDappOperator(ctx, msg.DappName, msg.Sender) + if !operator.Verifier { + return nil, types.ErrNotDappVerifier + } + + session := k.keeper.GetDappSession(ctx, msg.DappName) + if session.CurrSession.Leader == msg.Sender { + return nil, types.ErrLeaderCannotEvaluateSelfSubmission + } + + dapp := k.keeper.GetDapp(ctx, msg.DappName) + if dapp.Name != "" { + return nil, types.ErrDappDoesNotExist + } + + if msg.Version != dapp.Version() { + return nil, types.ErrInvalidDappVersion + } + + if session.CurrSession == nil || session.CurrSession.StatusHash == "" { + return nil, types.ErrVerificationNotAllowedOnEmptySession + } + + // halt the session + session.CurrSession.Status = types.SessionHalted + k.keeper.SetDappSession(ctx, session) + + k.keeper.SetDappSessionApproval(ctx, types.DappSessionApproval{ + DappName: msg.DappName, + Approver: msg.Sender, + IsApproved: true, + }) + + return &types.MsgRejectDappTransitionTxResponse{}, nil +} + +func (k Keeper) GetCoinsFromBridgeBalance(ctx sdk.Context, balances []types.BridgeBalance) sdk.Coins { + coins := sdk.Coins{} + for _, balance := range balances { + token := k.GetBridgeToken(ctx, balance.BridgeTokenIndex) + if token.Denom == "" { + continue + } + coins = coins.Add(sdk.NewCoin(token.Denom, balance.Amount)) + } + return coins +} + +func AddBridgeBalance(balances []types.BridgeBalance, addition []types.BridgeBalance) []types.BridgeBalance { + indexMap := make(map[uint64]int) + for i, balance := range balances { + indexMap[balance.BridgeTokenIndex] = i + } + + for _, balance := range addition { + i, ok := indexMap[balance.BridgeTokenIndex] + if ok { + balances[i].Amount = balances[i].Amount.Add(balance.Amount) + } else { + balances = append(balances, balance) + } + } + return balances +} + +func SubBridgeBalance(balances []types.BridgeBalance, removal []types.BridgeBalance) ([]types.BridgeBalance, error) { + indexMap := make(map[uint64]int) + for i, balance := range balances { + indexMap[balance.BridgeTokenIndex] = i + } + + for _, balance := range removal { + i, ok := indexMap[balance.BridgeTokenIndex] + if ok { + balances[i].Amount = balances[i].Amount.Sub(balance.Amount) + if balances[i].Amount.IsNegative() { + return balances, types.ErrNegativeBridgeBalance + } + } else { + return balances, types.ErrNegativeBridgeBalance + } + } + return balances, nil +} + +func (k msgServer) TransferDappTx(goCtx context.Context, msg *types.MsgTransferDappTx) (*types.MsgTransferDappTxResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + sender := sdk.MustAccAddressFromBech32(msg.Sender) + helper := k.keeper.GetBridgeRegistrarHelper(ctx) + nextXid := helper.NextXam + for _, xam := range msg.Requests { + coins := k.keeper.GetCoinsFromBridgeBalance(ctx, xam.Amounts) + if !coins.Empty() { + sa := k.keeper.GetBridgeAccount(ctx, xam.SourceAccount) + if xam.SourceDapp == 0 { // direct deposit from user + if sa.Address == "" { + sa.Address = msg.Sender + sa.Index = helper.NextUser + sa.DappName = "" + helper.NextUser += 1 + k.keeper.SetBridgeRegistrarHelper(ctx, helper) + } + if sa.Address != msg.Sender { + return nil, types.ErrInvalidBridgeDepositMessage + } + err := k.keeper.bk.SendCoinsFromAccountToModule(ctx, sender, types.ModuleName, coins) + if err != nil { + return nil, err + } + sa.Balances = AddBridgeBalance(sa.Balances, xam.Amounts) + k.keeper.SetBridgeAccount(ctx, sa) + } else if xam.DestDapp == 0 { // withdrawal to user account + ba := k.keeper.GetBridgeAccount(ctx, xam.DestBeneficiary) + if ba.Address != msg.Sender { + return nil, types.ErrInvalidBridgeWithdrawalMessage + } + err := k.keeper.bk.SendCoinsFromModuleToAccount(ctx, types.ModuleName, sender, coins) + if err != nil { + return nil, err + } + sa.Balances, err = SubBridgeBalance(sa.Balances, xam.Amounts) + if err != nil { + return nil, err + } + k.keeper.SetBridgeAccount(ctx, sa) + } else { + // check accuracy of source in case of dapp + sa := k.keeper.GetBridgeAccount(ctx, xam.SourceAccount) + if sa.Address != msg.Sender { + return nil, types.ErrInvalidBridgeSourceAccount + } + } + } + k.keeper.SetXAM(ctx, types.XAM{ + Req: xam, + Res: types.XAMResponse{ + Xid: nextXid, + Irc: 0, + Src: 0, + Drc: 0, + Irm: 0, + Srm: 0, + Drm: 0, + }, + }) + nextXid += 1 + } + helper.NextXam = nextXid + k.keeper.SetBridgeRegistrarHelper(ctx, helper) + + return &types.MsgTransferDappTxResponse{}, nil +} + +func (k msgServer) AckTransferDappTx(goCtx context.Context, msg *types.MsgAckTransferDappTx) (*types.MsgAckTransferDappTxResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + for _, res := range msg.Responses { + xam := k.keeper.GetXAM(ctx, res.Xid) + if xam.Res.Drc != 0 { // response already set + continue + } + xam.Res = res + k.keeper.SetXAM(ctx, xam) + // handle token transfer when response is okay + if res.Drc == 200 { // status okay + var err error + sa := k.keeper.GetBridgeAccount(ctx, xam.Req.SourceAccount) + sa.Balances, err = SubBridgeBalance(sa.Balances, xam.Req.Amounts) + if err != nil { + return nil, err + } + k.keeper.SetBridgeAccount(ctx, sa) + da := k.keeper.GetBridgeAccount(ctx, xam.Req.DestBeneficiary) + da.Balances = AddBridgeBalance(sa.Balances, xam.Req.Amounts) + if err != nil { + return nil, err + } + k.keeper.SetBridgeAccount(ctx, da) + } + } + + return &types.MsgAckTransferDappTxResponse{}, nil +} + +func (k msgServer) RedeemDappPoolTx(goCtx context.Context, msg *types.MsgRedeemDappPoolTx) (*types.MsgRedeemDappPoolTxResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + addr := sdk.MustAccAddressFromBech32(msg.Sender) + dapp := k.keeper.GetDapp(ctx, msg.DappName) + if dapp.Name != "" { + return nil, types.ErrDappDoesNotExist + } + lpTokenPrice := k.keeper.LpTokenPrice(ctx, dapp) + withoutSlippage := msg.LpToken.Amount.ToDec().Mul(lpTokenPrice) + + receiveCoin, err := k.keeper.RedeemDappPoolTx(ctx, addr, dapp, dapp.PoolFee, msg.LpToken) + if err != nil { + return nil, err + } + + properties := k.keeper.gk.GetNetworkProperties(ctx) + maxSlippage := msg.Slippage + if maxSlippage.IsZero() { + maxSlippage = properties.DappPoolSlippageDefault + } + slippage := sdk.OneDec().Sub(receiveCoin.Amount.ToDec().Quo(withoutSlippage)) + if slippage.GT(maxSlippage) { + return nil, types.ErrOperationExceedsSlippage + } + + return &types.MsgRedeemDappPoolTxResponse{}, nil +} + +func (k msgServer) SwapDappPoolTx(goCtx context.Context, msg *types.MsgSwapDappPoolTx) (*types.MsgSwapDappPoolTxResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + addr := sdk.MustAccAddressFromBech32(msg.Sender) + dapp := k.keeper.GetDapp(ctx, msg.DappName) + if dapp.Name != "" { + return nil, types.ErrDappDoesNotExist + } + + lpTokenPrice := k.keeper.LpTokenPrice(ctx, dapp) + if lpTokenPrice.IsZero() { + return nil, types.ErrOperationExceedsSlippage + } + withoutSlippage := msg.Token.Amount.ToDec().Quo(lpTokenPrice) + + receiveCoin, err := k.keeper.SwapDappPoolTx(ctx, addr, dapp, dapp.PoolFee, msg.Token) + if err != nil { + return nil, err + } + + properties := k.keeper.gk.GetNetworkProperties(ctx) + maxSlippage := msg.Slippage + if maxSlippage.IsZero() { + maxSlippage = properties.DappPoolSlippageDefault + } + slippage := sdk.OneDec().Sub(receiveCoin.Amount.ToDec().Quo(withoutSlippage)) + if slippage.GT(maxSlippage) { + return nil, types.ErrOperationExceedsSlippage + } + + return &types.MsgSwapDappPoolTxResponse{}, nil +} + +func (k msgServer) ConvertDappPoolTx(goCtx context.Context, msg *types.MsgConvertDappPoolTx) (*types.MsgConvertDappPoolTxResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + addr := sdk.MustAccAddressFromBech32(msg.Sender) + dapp1 := k.keeper.GetDapp(ctx, msg.DappName) + if dapp1.Name != "" { + return nil, types.ErrDappDoesNotExist + } + + lpTokenPrice1 := k.keeper.LpTokenPrice(ctx, dapp1) + if lpTokenPrice1.IsZero() { + return nil, types.ErrOperationExceedsSlippage + } + dapp2 := k.keeper.GetDapp(ctx, msg.TargetDappName) + if dapp2.Name != "" { + return nil, types.ErrDappDoesNotExist + } + + lpTokenPrice2 := k.keeper.LpTokenPrice(ctx, dapp2) + if lpTokenPrice2.IsZero() { + return nil, types.ErrOperationExceedsSlippage + } + + withoutSlippage := msg.LpToken.Amount.ToDec().Mul(lpTokenPrice1).Quo(lpTokenPrice2) + + receiveCoin, err := k.keeper.ConvertDappPoolTx(ctx, addr, dapp1, dapp2, msg.LpToken) + if err != nil { + return nil, err + } + + properties := k.keeper.gk.GetNetworkProperties(ctx) + maxSlippage := msg.Slippage + if maxSlippage.IsZero() { + maxSlippage = properties.DappPoolSlippageDefault + } + slippage := sdk.OneDec().Sub(receiveCoin.Amount.ToDec().Quo(withoutSlippage)) + if slippage.GT(maxSlippage) { + return nil, types.ErrOperationExceedsSlippage + } + + return &types.MsgConvertDappPoolTxResponse{}, nil +} + +func (k msgServer) MintCreateFtTx(goCtx context.Context, msg *types.MsgMintCreateFtTx) (*types.MsgMintCreateFtTxResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + properties := k.keeper.gk.GetNetworkProperties(ctx) + fee := sdk.NewInt64Coin(k.keeper.BondDenom(ctx), int64(properties.MintingFtFee)) + sender := sdk.MustAccAddressFromBech32(msg.Sender) + err := k.keeper.bk.SendCoinsFromAccountToModule(ctx, sender, types.ModuleName, sdk.Coins{fee}) + if err != nil { + return nil, err + } + + err = k.keeper.bk.BurnCoins(ctx, types.ModuleName, sdk.Coins{fee}) + if err != nil { + return nil, err + } + + denom := "ku/" + msg.DenomSuffix + + info := k.keeper.GetTokenInfo(ctx, denom) + if info.Denom != "" { + return nil, types.ErrTokenAlreadyRegistered + } + + k.keeper.SetTokenInfo(ctx, types.TokenInfo{ + TokenType: "adr20", + Denom: denom, + Name: msg.Name, + Symbol: msg.Symbol, + Icon: msg.Icon, + Description: msg.Description, + Website: msg.Website, + Social: msg.Social, + Decimals: msg.Decimals, + Cap: msg.Cap, + Supply: msg.Supply, + Holders: msg.Holders, + Fee: msg.Fee, + Owner: msg.Owner, + Metadata: "", + Hash: "", + }) + + return &types.MsgMintCreateFtTxResponse{}, nil +} + +func (k msgServer) MintCreateNftTx(goCtx context.Context, msg *types.MsgMintCreateNftTx) (*types.MsgMintCreateNftTxResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + properties := k.keeper.gk.GetNetworkProperties(ctx) + fee := sdk.NewInt64Coin(k.keeper.BondDenom(ctx), int64(properties.MintingFtFee)) + sender := sdk.MustAccAddressFromBech32(msg.Sender) + err := k.keeper.bk.SendCoinsFromAccountToModule(ctx, sender, types.ModuleName, sdk.Coins{fee}) + if err != nil { + return nil, err + } + + err = k.keeper.bk.BurnCoins(ctx, types.ModuleName, sdk.Coins{fee}) + if err != nil { + return nil, err + } + + denom := "ku/" + msg.DenomSuffix + info := k.keeper.GetTokenInfo(ctx, denom) + if info.Denom != "" { + return nil, types.ErrTokenAlreadyRegistered + } + + k.keeper.SetTokenInfo(ctx, types.TokenInfo{ + TokenType: "adr43", + Denom: denom, + Name: msg.Name, + Symbol: msg.Symbol, + Icon: msg.Icon, + Description: msg.Description, + Website: msg.Website, + Social: msg.Social, + Decimals: msg.Decimals, + Cap: msg.Cap, + Supply: msg.Supply, + Holders: msg.Holders, + Fee: msg.Fee, + Owner: msg.Owner, + Metadata: msg.Metadata, + Hash: msg.Hash, + }) + + return &types.MsgMintCreateNftTxResponse{}, nil +} + +func (k msgServer) MintIssueTx(goCtx context.Context, msg *types.MsgMintIssueTx) (*types.MsgMintIssueTxResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + sender := sdk.MustAccAddressFromBech32(msg.Sender) + tokenInfo := k.keeper.GetTokenInfo(ctx, msg.Denom) + if tokenInfo.Denom == "" { + return nil, types.ErrTokenNotRegistered + } + + if msg.Sender != tokenInfo.Owner { + fee := msg.Amount.Mul(tokenInfo.Fee).Quo(Pow10(tokenInfo.Decimals)) + feeCoins := sdk.Coins{sdk.NewCoin(k.keeper.BondDenom(ctx), fee)} + if fee.IsPositive() { + if tokenInfo.Owner == "" { + err := k.keeper.bk.SendCoinsFromAccountToModule(ctx, sender, types.ModuleName, feeCoins) + if err != nil { + return nil, err + } + } else { + owner := sdk.MustAccAddressFromBech32(tokenInfo.Owner) + err := k.keeper.bk.SendCoins(ctx, sender, owner, feeCoins) + if err != nil { + return nil, err + } + } + } else { + return nil, types.ErrNotAbleToMintCoinsWithoutFee + } + } + + mintCoin := sdk.NewCoin(msg.Denom, msg.Amount) + err := k.keeper.bk.MintCoins(ctx, types.ModuleName, sdk.Coins{mintCoin}) + if err != nil { + return nil, err + } + + err = k.keeper.bk.SendCoinsFromModuleToAccount(ctx, types.ModuleName, sender, sdk.Coins{mintCoin}) + if err != nil { + return nil, err + } + + tokenInfo.Supply = tokenInfo.Supply.Add(msg.Amount) + if tokenInfo.Supply.GT(tokenInfo.Cap) { + return nil, types.ErrCannotExceedTokenCap + } + k.keeper.SetTokenInfo(ctx, tokenInfo) + + return &types.MsgMintIssueTxResponse{}, nil +} + +func (k msgServer) MintBurnTx(goCtx context.Context, msg *types.MsgMintBurnTx) (*types.MsgMintBurnTxResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + sender := sdk.MustAccAddressFromBech32(msg.Sender) + tokenInfo := k.keeper.GetTokenInfo(ctx, msg.Denom) + if tokenInfo.Denom == "" { + return nil, types.ErrTokenNotRegistered + } + + burnCoin := sdk.NewCoin(msg.Denom, msg.Amount) + err := k.keeper.bk.SendCoinsFromAccountToModule(ctx, sender, types.ModuleName, sdk.Coins{burnCoin}) + if err != nil { + return nil, err + } + + err = k.keeper.bk.BurnCoins(ctx, types.ModuleName, sdk.Coins{burnCoin}) + if err != nil { + return nil, err + } + + tokenInfo.Supply = tokenInfo.Supply.Sub(msg.Amount) + k.keeper.SetTokenInfo(ctx, tokenInfo) + + return &types.MsgMintBurnTxResponse{}, nil +} diff --git a/x/layer2/keeper/msg_server_test.go b/x/layer2/keeper/msg_server_test.go new file mode 100644 index 000000000..50ff244d0 --- /dev/null +++ b/x/layer2/keeper/msg_server_test.go @@ -0,0 +1,282 @@ +package keeper_test + +import ( + "github.com/KiraCore/sekai/x/layer2/keeper" + "github.com/KiraCore/sekai/x/layer2/types" + stakingtypes "github.com/KiraCore/sekai/x/staking/types" + "github.com/cosmos/cosmos-sdk/simapp" + sdk "github.com/cosmos/cosmos-sdk/types" + minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" + "github.com/tendermint/tendermint/crypto/ed25519" +) + +func (suite *KeeperTestSuite) TestCreateDappProposal() { + addr1 := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address().Bytes()) + + valAddr := sdk.ValAddress(addr1) + pubkeys := simapp.CreateTestPubKeys(1) + pubKey := pubkeys[0] + val, err := stakingtypes.NewValidator(valAddr, pubKey) + suite.Require().NoError(err) + + val.Status = stakingtypes.Active + suite.app.CustomStakingKeeper.AddValidator(suite.ctx, val) + + coins := sdk.Coins{sdk.NewInt64Coin("ukex", 10000000000)} + err = suite.app.BankKeeper.MintCoins(suite.ctx, minttypes.ModuleName, coins) + suite.Require().NoError(err) + err = suite.app.BankKeeper.SendCoinsFromModuleToAccount(suite.ctx, minttypes.ModuleName, addr1, coins) + suite.Require().NoError(err) + + // create dapp + msgServer := keeper.NewMsgServerImpl(suite.app.Layer2Keeper) + msg := &types.MsgCreateDappProposal{ + Sender: addr1.String(), + Dapp: types.Dapp{ + Name: "dapp1", + Denom: "dapp1", + Description: "dapp1 description", + Status: types.Active, + Website: "", + Logo: "", + Social: "", + Docs: "", + Controllers: types.Controllers{ + Whitelist: types.AccountRange{ + Roles: []uint64{1}, + Addresses: []string{"kira1q24436yrnettd6v4eu6r4t9gycnnddack4jr5r"}, + }, + }, + Bin: []types.BinaryInfo{ + { + Name: "dapp1", + Hash: "dapp1", + Source: "dapp1", + Reference: "dapp1", + Type: "dapp1", + }, + }, + Pool: types.LpPoolConfig{ + Ratio: sdk.OneDec(), + Deposit: "", + Drip: 86400, + }, + Issurance: types.IssuranceConfig{ + Deposit: "", + Premint: sdk.OneInt(), + Postmint: sdk.OneInt(), + Time: 1680141605, + }, + VoteQuorum: 30, + VotePeriod: 86400, + VoteEnactment: 3000, + UpdateTimeMax: 60, + ExecutorsMin: 1, + ExecutorsMax: 2, + VerifiersMin: 1, + TotalBond: sdk.Coin{}, + CreationTime: 0, + }, + Bond: sdk.NewInt64Coin("ukex", 10000000000), + } + + _, err = msgServer.CreateDappProposal(sdk.WrapSDKContext(suite.ctx), msg) + suite.Require().NoError(err) + + // check dapp correctly crteated + dapp := suite.app.Layer2Keeper.GetDapp(suite.ctx, msg.Dapp.Name) + suite.Require().NotEqual(dapp.Name, "") +} + +func (suite *KeeperTestSuite) TestBondDappProposal() { + addr1 := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address().Bytes()) + + valAddr := sdk.ValAddress(addr1) + pubkeys := simapp.CreateTestPubKeys(1) + pubKey := pubkeys[0] + val, err := stakingtypes.NewValidator(valAddr, pubKey) + suite.Require().NoError(err) + + val.Status = stakingtypes.Active + suite.app.CustomStakingKeeper.AddValidator(suite.ctx, val) + + coins := sdk.Coins{sdk.NewInt64Coin("ukex", 20000000000)} + err = suite.app.BankKeeper.MintCoins(suite.ctx, minttypes.ModuleName, coins) + suite.Require().NoError(err) + err = suite.app.BankKeeper.SendCoinsFromModuleToAccount(suite.ctx, minttypes.ModuleName, addr1, coins) + suite.Require().NoError(err) + + // create dapp + msgServer := keeper.NewMsgServerImpl(suite.app.Layer2Keeper) + createMsg := &types.MsgCreateDappProposal{ + Sender: addr1.String(), + Dapp: types.Dapp{ + Name: "dapp1", + Denom: "dapp1", + Description: "dapp1 description", + Status: types.Active, + Website: "", + Logo: "", + Social: "", + Docs: "", + Controllers: types.Controllers{ + Whitelist: types.AccountRange{ + Roles: []uint64{1}, + Addresses: []string{"kira1q24436yrnettd6v4eu6r4t9gycnnddack4jr5r"}, + }, + }, + Bin: []types.BinaryInfo{ + { + Name: "dapp1", + Hash: "dapp1", + Source: "dapp1", + Reference: "dapp1", + Type: "dapp1", + }, + }, + Pool: types.LpPoolConfig{ + Ratio: sdk.OneDec(), + Deposit: "", + Drip: 86400, + }, + Issurance: types.IssuranceConfig{ + Deposit: "", + Premint: sdk.OneInt(), + Postmint: sdk.OneInt(), + Time: 1680141605, + }, + VoteQuorum: 30, + VotePeriod: 86400, + VoteEnactment: 3000, + UpdateTimeMax: 60, + ExecutorsMin: 1, + ExecutorsMax: 2, + VerifiersMin: 1, + TotalBond: sdk.Coin{}, + CreationTime: 0, + }, + Bond: sdk.NewInt64Coin("ukex", 10000000000), + } + + _, err = msgServer.CreateDappProposal(sdk.WrapSDKContext(suite.ctx), createMsg) + suite.Require().NoError(err) + + // bond dapp + bondMsg := &types.MsgBondDappProposal{ + Sender: addr1.String(), + DappName: createMsg.Dapp.Name, + Bond: sdk.NewInt64Coin("ukex", 10000000000), + } + + _, err = msgServer.BondDappProposal(sdk.WrapSDKContext(suite.ctx), bondMsg) + suite.Require().NoError(err) + + userBond := suite.app.Layer2Keeper.GetUserDappBond(suite.ctx, bondMsg.DappName, addr1.String()) + suite.Require().Equal(userBond.Bond.String(), "20000000000ukex") +} + +func (suite *KeeperTestSuite) TestReclaimDappBondProposal() { + addr1 := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address().Bytes()) + + valAddr := sdk.ValAddress(addr1) + pubkeys := simapp.CreateTestPubKeys(1) + pubKey := pubkeys[0] + val, err := stakingtypes.NewValidator(valAddr, pubKey) + suite.Require().NoError(err) + + val.Status = stakingtypes.Active + suite.app.CustomStakingKeeper.AddValidator(suite.ctx, val) + + coins := sdk.Coins{sdk.NewInt64Coin("ukex", 20000000000)} + err = suite.app.BankKeeper.MintCoins(suite.ctx, minttypes.ModuleName, coins) + suite.Require().NoError(err) + err = suite.app.BankKeeper.SendCoinsFromModuleToAccount(suite.ctx, minttypes.ModuleName, addr1, coins) + suite.Require().NoError(err) + + // create dapp + msgServer := keeper.NewMsgServerImpl(suite.app.Layer2Keeper) + createMsg := &types.MsgCreateDappProposal{ + Sender: addr1.String(), + Dapp: types.Dapp{ + Name: "dapp1", + Denom: "dapp1", + Description: "dapp1 description", + Status: types.Active, + Website: "", + Logo: "", + Social: "", + Docs: "", + Controllers: types.Controllers{ + Whitelist: types.AccountRange{ + Roles: []uint64{1}, + Addresses: []string{"kira1q24436yrnettd6v4eu6r4t9gycnnddack4jr5r"}, + }, + }, + Bin: []types.BinaryInfo{ + { + Name: "dapp1", + Hash: "dapp1", + Source: "dapp1", + Reference: "dapp1", + Type: "dapp1", + }, + }, + Pool: types.LpPoolConfig{ + Ratio: sdk.OneDec(), + Deposit: "", + Drip: 86400, + }, + Issurance: types.IssuranceConfig{ + Deposit: "", + Premint: sdk.OneInt(), + Postmint: sdk.OneInt(), + Time: 1680141605, + }, + VoteQuorum: 30, + VotePeriod: 86400, + VoteEnactment: 3000, + UpdateTimeMax: 60, + ExecutorsMin: 1, + ExecutorsMax: 2, + VerifiersMin: 1, + TotalBond: sdk.Coin{}, + CreationTime: 0, + }, + Bond: sdk.NewInt64Coin("ukex", 10000000000), + } + + _, err = msgServer.CreateDappProposal(sdk.WrapSDKContext(suite.ctx), createMsg) + suite.Require().NoError(err) + + // bond dapp + reclaimMsg := &types.MsgReclaimDappBondProposal{ + Sender: addr1.String(), + DappName: createMsg.Dapp.Name, + Bond: sdk.NewInt64Coin("ukex", 10000000), + } + + _, err = msgServer.ReclaimDappBondProposal(sdk.WrapSDKContext(suite.ctx), reclaimMsg) + suite.Require().NoError(err) + + userBond := suite.app.Layer2Keeper.GetUserDappBond(suite.ctx, reclaimMsg.DappName, addr1.String()) + suite.Require().Equal(userBond.Bond.String(), "9990000000ukex") +} + +// TODO: add test for JoinDappVerifierWithBond +// TODO: add test for ExitDapp +// TODO: add test for PauseDappTx +// TODO: add test for UnPauseDappTx +// TODO: add test for ReactivateDappTx +// TODO: add test for ExecuteDappTx +// TODO: add test for TransitionDappTx +// TODO: add test for DenounceLeaderTx +// TODO: add test for ApproveDappTransitionTx +// TODO: add test for RejectDappTransitionTx +// TODO: add test for TransferDappTx +// TODO: add test for RedeemDappPoolTx +// TODO: add test for SwapDappPoolTx +// TODO: add test for ConvertDappPoolTx +// TODO: add test for MintCreateFtTx +// TODO: add test for MintCreateNftTx +// TODO: add test for MintIssueTx +// TODO: add test for MintBurnTx diff --git a/x/layer2/keeper/token_mint.go b/x/layer2/keeper/token_mint.go new file mode 100644 index 000000000..3051fb84d --- /dev/null +++ b/x/layer2/keeper/token_mint.go @@ -0,0 +1,52 @@ +package keeper + +import ( + "github.com/KiraCore/sekai/x/layer2/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func Pow10(decimal uint64) sdk.Int { + res := sdk.OneInt() + for i := 0; i < int(decimal); i++ { + res = res.Mul(sdk.NewInt(10)) + } + return res +} + +func (k Keeper) SetTokenInfo(ctx sdk.Context, info types.TokenInfo) { + bz := k.cdc.MustMarshal(&info) + store := ctx.KVStore(k.storeKey) + store.Set(types.TokenInfoKey(info.Denom), bz) +} + +func (k Keeper) DeleteTokenInfo(ctx sdk.Context, denom string) { + store := ctx.KVStore(k.storeKey) + store.Delete(types.TokenInfoKey(denom)) +} + +func (k Keeper) GetTokenInfo(ctx sdk.Context, denom string) types.TokenInfo { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.TokenInfoKey(denom)) + if bz == nil { + return types.TokenInfo{} + } + + info := types.TokenInfo{} + k.cdc.MustUnmarshal(bz, &info) + return info +} + +func (k Keeper) GetTokenInfos(ctx sdk.Context) []types.TokenInfo { + store := ctx.KVStore(k.storeKey) + + infos := []types.TokenInfo{} + it := sdk.KVStorePrefixIterator(store, types.PrefixTokenInfoKey) + defer it.Close() + + for ; it.Valid(); it.Next() { + info := types.TokenInfo{} + k.cdc.MustUnmarshal(it.Value(), &info) + infos = append(infos, info) + } + return infos +} diff --git a/x/layer2/keeper/token_mint_test.go b/x/layer2/keeper/token_mint_test.go new file mode 100644 index 000000000..c5adccc10 --- /dev/null +++ b/x/layer2/keeper/token_mint_test.go @@ -0,0 +1,70 @@ +package keeper_test + +import ( + "github.com/KiraCore/sekai/x/layer2/keeper" + "github.com/KiraCore/sekai/x/layer2/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func (suite *KeeperTestSuite) TestTokenInfoSetGetDelete() { + infos := []types.TokenInfo{ + { + TokenType: "adr20", + Denom: "ku/bridgebtc", + Name: "Bridge BTC", + Symbol: "BTC", + Icon: "", + Description: "", + Website: "", + Social: "", + Decimals: 8, + Cap: sdk.NewInt(1000_000_000), + Supply: sdk.ZeroInt(), + Holders: 0, + Fee: sdk.ZeroInt(), + Owner: "kira15ky9du8a2wlstz6fpx3p4mqpjyrm5cgqzp4f3d", + }, + { + TokenType: "adr43", + Denom: "ku/punk", + Name: "Bridge PUNK", + Symbol: "PUNK", + Icon: "", + Description: "", + Website: "", + Social: "", + Decimals: 0, + Cap: sdk.NewInt(1000_000_000), + Supply: sdk.ZeroInt(), + Holders: 0, + Fee: sdk.ZeroInt(), + Owner: "kira15ky9du8a2wlstz6fpx3p4mqpjyrm5cgqzp4f3d", + Hash: "", + Metadata: "", + }, + } + + for _, info := range infos { + suite.app.Layer2Keeper.SetTokenInfo(suite.ctx, info) + } + + for _, info := range infos { + c := suite.app.Layer2Keeper.GetTokenInfo(suite.ctx, info.Denom) + suite.Require().Equal(c, info) + } + + allInfos := suite.app.Layer2Keeper.GetTokenInfos(suite.ctx) + suite.Require().Len(allInfos, 2) + + suite.app.Layer2Keeper.DeleteTokenInfo(suite.ctx, infos[0].Denom) + + allInfos = suite.app.Layer2Keeper.GetTokenInfos(suite.ctx) + suite.Require().Len(allInfos, 1) +} + +func (suite *KeeperTestSuite) TestPow10() { + suite.Require().Equal(keeper.Pow10(0), sdk.NewInt(1)) + suite.Require().Equal(keeper.Pow10(1), sdk.NewInt(10)) + suite.Require().Equal(keeper.Pow10(2), sdk.NewInt(100)) + suite.Require().Equal(keeper.Pow10(3), sdk.NewInt(1000)) +} diff --git a/x/layer2/module.go b/x/layer2/module.go new file mode 100644 index 000000000..175e8736b --- /dev/null +++ b/x/layer2/module.go @@ -0,0 +1,144 @@ +package layer2 + +import ( + "context" + "encoding/json" + + "github.com/grpc-ecosystem/grpc-gateway/runtime" + + "github.com/KiraCore/sekai/middleware" + layer2cli "github.com/KiraCore/sekai/x/layer2/client/cli" + layer2keeper "github.com/KiraCore/sekai/x/layer2/keeper" + "github.com/KiraCore/sekai/x/layer2/types" + layer2types "github.com/KiraCore/sekai/x/layer2/types" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/codec" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + "github.com/gorilla/mux" + "github.com/spf13/cobra" + abci "github.com/tendermint/tendermint/abci/types" +) + +var ( + _ module.AppModule = AppModule{} + _ module.AppModuleBasic = AppModuleBasic{} +) + +type AppModuleBasic struct{} + +// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the staking module. +func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { +} + +func (b AppModuleBasic) Name() string { + return layer2types.ModuleName +} + +func (b AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry) { + layer2types.RegisterInterfaces(registry) +} + +func (b AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { + return cdc.MustMarshalJSON(layer2types.DefaultGenesis()) +} + +func (b AppModuleBasic) ValidateGenesis(marshaler codec.JSONCodec, config client.TxEncodingConfig, message json.RawMessage) error { + return nil +} + +func (b AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, router *mux.Router) { +} + +func (b AppModuleBasic) RegisterGRPCRoutes(clientCtx client.Context, serveMux *runtime.ServeMux) { + layer2types.RegisterQueryHandlerClient(context.Background(), serveMux, types.NewQueryClient(clientCtx)) +} + +func (b AppModuleBasic) RegisterLegacyAminoCodec(amino *codec.LegacyAmino) { + layer2types.RegisterCodec(amino) +} + +func (b AppModuleBasic) GetTxCmd() *cobra.Command { + return layer2cli.NewTxCmd() +} + +// GetQueryCmd implement query commands for this module +func (b AppModuleBasic) GetQueryCmd() *cobra.Command { + return layer2cli.NewQueryCmd() +} + +// AppModule for layer2 management +type AppModule struct { + AppModuleBasic + layer2Keeper layer2keeper.Keeper +} + +// RegisterQueryService registers a GRPC query service to respond to the +// module-specific GRPC queries. +func (am AppModule) RegisterServices(cfg module.Configurator) { + layer2types.RegisterMsgServer(cfg.MsgServer(), layer2keeper.NewMsgServerImpl(am.layer2Keeper)) + layer2types.RegisterQueryServer(cfg.QueryServer(), am.layer2Keeper) +} + +func (am AppModule) RegisterInterfaces(registry codectypes.InterfaceRegistry) { + layer2types.RegisterInterfaces(registry) +} + +func (am AppModule) InitGenesis( + ctx sdk.Context, + cdc codec.JSONCodec, + data json.RawMessage, +) []abci.ValidatorUpdate { + var genesisState layer2types.GenesisState + cdc.MustUnmarshalJSON(data, &genesisState) + + return nil +} + +func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { + genesisState := layer2types.GenesisState{} + return cdc.MustMarshalJSON(&genesisState) +} + +// ConsensusVersion implements AppModule/ConsensusVersion. +func (AppModule) ConsensusVersion() uint64 { return 1 } + +func (am AppModule) RegisterInvariants(registry sdk.InvariantRegistry) {} + +func (am AppModule) QuerierRoute() string { + return layer2types.QuerierRoute +} + +// LegacyQuerierHandler returns the staking module sdk.Querier. +func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sdk.Querier { + return nil +} + +func (am AppModule) BeginBlock(clientCtx sdk.Context, req abci.RequestBeginBlock) { + am.layer2Keeper.BeginBlocker(clientCtx) +} + +func (am AppModule) EndBlock(ctx sdk.Context, block abci.RequestEndBlock) []abci.ValidatorUpdate { + am.layer2Keeper.EndBlocker(ctx) + return nil +} + +func (am AppModule) Name() string { + return layer2types.ModuleName +} + +// Route returns the message routing key for the staking module. +func (am AppModule) Route() sdk.Route { + return middleware.NewRoute(layer2types.ModuleName, NewHandler(am.layer2Keeper)) +} + +// NewAppModule returns a new Custom Staking module. +func NewAppModule( + keeper layer2keeper.Keeper, +) AppModule { + return AppModule{ + layer2Keeper: keeper, + } +} diff --git a/x/layer2/proposal_handler.go b/x/layer2/proposal_handler.go new file mode 100644 index 000000000..4ce0f5550 --- /dev/null +++ b/x/layer2/proposal_handler.go @@ -0,0 +1,186 @@ +package layer2 + +import ( + kiratypes "github.com/KiraCore/sekai/types" + govtypes "github.com/KiraCore/sekai/x/gov/types" + "github.com/KiraCore/sekai/x/layer2/keeper" + "github.com/KiraCore/sekai/x/layer2/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +type ApplyJoinDappProposalHandler struct { + keeper keeper.Keeper +} + +func NewApplyJoinDappProposalHandler(keeper keeper.Keeper) *ApplyJoinDappProposalHandler { + return &ApplyJoinDappProposalHandler{ + keeper: keeper, + } +} + +func (a ApplyJoinDappProposalHandler) ProposalType() string { + return kiratypes.ProposalTypeJoinDapp +} + +func (a ApplyJoinDappProposalHandler) IsAllowedAddress(ctx sdk.Context, addr sdk.AccAddress, proposal govtypes.Content) bool { + p := proposal.(*types.ProposalJoinDapp) + + dapp := a.keeper.GetDapp(ctx, p.DappName) + if dapp.Name == "" { + return false + } + + return a.keeper.IsAllowedAddress(ctx, addr, dapp.Controllers) +} + +func (a ApplyJoinDappProposalHandler) AllowedAddresses(ctx sdk.Context, proposal govtypes.Content) []string { + p := proposal.(*types.ProposalJoinDapp) + + dapp := a.keeper.GetDapp(ctx, p.DappName) + if dapp.Name == "" { + return []string{} + } + return a.keeper.AllowedAddresses(ctx, dapp.Controllers) +} + +func (a ApplyJoinDappProposalHandler) Quorum(ctx sdk.Context, proposal govtypes.Content) uint64 { + p := proposal.(*types.ProposalJoinDapp) + + dapp := a.keeper.GetDapp(ctx, p.DappName) + if dapp.Name == "" { + return 0 + } + + return dapp.VoteQuorum +} + +func (a ApplyJoinDappProposalHandler) VotePeriod(ctx sdk.Context, proposal govtypes.Content) uint64 { + p := proposal.(*types.ProposalJoinDapp) + + dapp := a.keeper.GetDapp(ctx, p.DappName) + if dapp.Name == "" { + return 0 + } + + return dapp.VotePeriod +} + +func (a ApplyJoinDappProposalHandler) VoteEnactment(ctx sdk.Context, proposal govtypes.Content) uint64 { + p := proposal.(*types.ProposalJoinDapp) + + dapp := a.keeper.GetDapp(ctx, p.DappName) + if dapp.Name == "" { + return 0 + } + + return dapp.VoteEnactment +} + +func (a ApplyJoinDappProposalHandler) Apply(ctx sdk.Context, proposalID uint64, proposal govtypes.Content, slash sdk.Dec) error { + p := proposal.(*types.ProposalJoinDapp) + + return a.keeper.ExecuteJoinDappProposal(ctx, p) +} + +type ApplyUpsertDappProposalHandler struct { + keeper keeper.Keeper +} + +func NewApplyUpsertDappProposalHandler(keeper keeper.Keeper) *ApplyUpsertDappProposalHandler { + return &ApplyUpsertDappProposalHandler{ + keeper: keeper, + } +} + +func (a ApplyUpsertDappProposalHandler) ProposalType() string { + return kiratypes.ProposalTypeUpsertDapp +} + +func (a ApplyUpsertDappProposalHandler) IsAllowedAddress(ctx sdk.Context, addr sdk.AccAddress, proposal govtypes.Content) bool { + p := proposal.(*types.ProposalUpsertDapp) + + dapp := a.keeper.GetDapp(ctx, p.Dapp.Name) + if dapp.Name == "" { + return false + } + + return a.keeper.IsAllowedAddress(ctx, addr, dapp.Controllers) +} + +func (a ApplyUpsertDappProposalHandler) AllowedAddresses(ctx sdk.Context, proposal govtypes.Content) []string { + p := proposal.(*types.ProposalUpsertDapp) + + dapp := a.keeper.GetDapp(ctx, p.Dapp.Name) + if dapp.Name == "" { + return []string{} + } + + return a.keeper.AllowedAddresses(ctx, dapp.Controllers) +} + +func (a ApplyUpsertDappProposalHandler) Quorum(ctx sdk.Context, proposal govtypes.Content) uint64 { + p := proposal.(*types.ProposalUpsertDapp) + + dapp := a.keeper.GetDapp(ctx, p.Dapp.Name) + if dapp.Name == "" { + return 0 + } + + return dapp.VoteQuorum +} + +func (a ApplyUpsertDappProposalHandler) VotePeriod(ctx sdk.Context, proposal govtypes.Content) uint64 { + p := proposal.(*types.ProposalUpsertDapp) + + dapp := a.keeper.GetDapp(ctx, p.Dapp.Name) + if dapp.Name == "" { + return 0 + } + + return dapp.VotePeriod +} + +func (a ApplyUpsertDappProposalHandler) VoteEnactment(ctx sdk.Context, proposal govtypes.Content) uint64 { + p := proposal.(*types.ProposalUpsertDapp) + + dapp := a.keeper.GetDapp(ctx, p.Dapp.Name) + if dapp.Name == "" { + return 0 + } + + return dapp.VoteEnactment +} + +func (a ApplyUpsertDappProposalHandler) Apply(ctx sdk.Context, proposalID uint64, proposal govtypes.Content, slash sdk.Dec) error { + p := proposal.(*types.ProposalUpsertDapp) + + dapp := a.keeper.GetDapp(ctx, p.Dapp.Name) + if dapp.Name == "" { + return types.ErrDappDoesNotExist + } + + dapp.Name = p.Dapp.Name + dapp.Denom = p.Dapp.Denom + dapp.Description = p.Dapp.Description + dapp.Website = p.Dapp.Website + dapp.Logo = p.Dapp.Logo + dapp.Social = p.Dapp.Social + dapp.Docs = p.Dapp.Docs + dapp.Controllers = p.Dapp.Controllers + dapp.Bin = p.Dapp.Bin + dapp.Pool = p.Dapp.Pool + dapp.Issurance = p.Dapp.Issurance + dapp.UpdateTimeMax = p.Dapp.UpdateTimeMax + dapp.ExecutorsMin = p.Dapp.ExecutorsMin + dapp.ExecutorsMax = p.Dapp.ExecutorsMax + dapp.VerifiersMin = p.Dapp.VerifiersMin + dapp.TotalBond = p.Dapp.TotalBond + dapp.CreationTime = p.Dapp.CreationTime + dapp.Status = p.Dapp.Status + dapp.VoteQuorum = p.Dapp.VoteQuorum + dapp.VotePeriod = p.Dapp.VotePeriod + dapp.VoteEnactment = p.Dapp.VoteEnactment + + a.keeper.SetDapp(ctx, p.Dapp) + return nil +} diff --git a/x/layer2/types/codec.go b/x/layer2/types/codec.go new file mode 100644 index 000000000..2b7a4c128 --- /dev/null +++ b/x/layer2/types/codec.go @@ -0,0 +1,68 @@ +package types + +import ( + govtypes "github.com/KiraCore/sekai/x/gov/types" + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/msgservice" +) + +// RegisterCodec register codec and metadata +func RegisterCodec(cdc *codec.LegacyAmino) { + +} + +// RegisterInterfaces register Msg and structs +func RegisterInterfaces(registry types.InterfaceRegistry) { + registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgCreateDappProposal{}, + &MsgBondDappProposal{}, + &MsgReclaimDappBondProposal{}, + &MsgJoinDappVerifierWithBond{}, + &MsgExitDapp{}, + &MsgRedeemDappPoolTx{}, + &MsgSwapDappPoolTx{}, + &MsgConvertDappPoolTx{}, + &MsgPauseDappTx{}, + &MsgUnPauseDappTx{}, + &MsgReactivateDappTx{}, + &MsgExecuteDappTx{}, + &MsgDenounceLeaderTx{}, + &MsgTransitionDappTx{}, + &MsgApproveDappTransitionTx{}, + &MsgRejectDappTransitionTx{}, + &MsgTransferDappTx{}, + &MsgAckTransferDappTx{}, + &MsgMintCreateFtTx{}, + &MsgMintCreateNftTx{}, + &MsgMintIssueTx{}, + &MsgMintBurnTx{}, + ) + + registry.RegisterInterface( + "kira.gov.Content", + (*govtypes.Content)(nil), + &ProposalJoinDapp{}, + &ProposalUpsertDapp{}, + ) + + msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) +} + +var ( + amino = codec.NewLegacyAmino() + + // ModuleCdc references the global x/staking module codec. Note, the codec should + // ONLY be used in certain instances of tests and for JSON encoding as Amino is + // still used for that purpose. + // + // The actual codec used for serialization should be provided to x/staking and + // defined at the application level. + ModuleCdc = codec.NewAminoCodec(amino) +) + +func init() { + RegisterCodec(amino) + amino.Seal() +} diff --git a/x/layer2/types/errors.go b/x/layer2/types/errors.go new file mode 100644 index 000000000..60dd25d05 --- /dev/null +++ b/x/layer2/types/errors.go @@ -0,0 +1,45 @@ +package types + +import ( + "github.com/cosmos/cosmos-sdk/types/errors" +) + +// layer2 module errors +var ( + ErrInvalidDappBondDenom = errors.Register(ModuleName, 1, "invalid dapp bond denom") + ErrLowAmountToCreateDappProposal = errors.Register(ModuleName, 2, "low amount to create dapp proposal") + ErrDappDoesNotExist = errors.Register(ModuleName, 3, "dapp not found") + ErrDappAlreadyExists = errors.Register(ModuleName, 4, "dapp already exists") + ErrMaxDappBondReached = errors.Register(ModuleName, 5, "max dapp bond reached") + ErrNotEnoughUserDappBond = errors.Register(ModuleName, 6, "not enough user dapp bond") + ErrUserDappBondDoesNotExist = errors.Register(ModuleName, 7, "user dapp bond does not exist") + ErrAlreadyADappVerifier = errors.Register(ModuleName, 8, "already a dapp verifier") + ErrNotDappOperator = errors.Register(ModuleName, 9, "not a dapp operator") + ErrAlreadyADappOperator = errors.Register(ModuleName, 10, "already a dapp operator") + ErrDappNotHalted = errors.Register(ModuleName, 11, "dapp is not halted") + ErrDappNotActive = errors.Register(ModuleName, 12, "dapp is not active") + ErrDappNotPaused = errors.Register(ModuleName, 13, "dapp is not paused") + ErrDappSessionDoesNotExist = errors.Register(ModuleName, 14, "dapp session does not exist") + ErrDappOperatorNotPaused = errors.Register(ModuleName, 15, "dapp operator is not paused") + ErrDappOperatorNotInActive = errors.Register(ModuleName, 16, "dapp operator is not inactive") + ErrDappOperatorNotActive = errors.Register(ModuleName, 17, "dapp operator is not active") + ErrNoDappSessionExists = errors.Register(ModuleName, 18, "dapp session does not exist") + ErrNotDappSessionLeader = errors.Register(ModuleName, 19, "not a dapp session leader") + ErrNumberOfOperatorsExceedsExecutorsMax = errors.Register(ModuleName, 20, "number of operators exceeds executors max") + ErrOperatorJailed = errors.Register(ModuleName, 21, "operator jailed") + ErrOperatorAlreadyExiting = errors.Register(ModuleName, 22, "operator already exiting") + ErrNotDappVerifier = errors.Register(ModuleName, 23, "not a dapp verifier") + ErrLeaderCannotEvaluateSelfSubmission = errors.Register(ModuleName, 24, "leader cannot evaluate self submission") + ErrVerificationNotAllowedOnEmptySession = errors.Register(ModuleName, 25, "verification not allowed on empty session") + ErrInvalidLpToken = errors.Register(ModuleName, 26, "invalid lp token") + ErrOperationExceedsSlippage = errors.Register(ModuleName, 27, "operation exceeds slippage") + ErrTokenNotRegistered = errors.Register(ModuleName, 28, "token not registered") + ErrCannotExceedTokenCap = errors.Register(ModuleName, 29, "cannot exceed token cap") + ErrTokenAlreadyRegistered = errors.Register(ModuleName, 30, "token already registered") + ErrNotAbleToMintCoinsWithoutFee = errors.Register(ModuleName, 31, "not able to mint coins without fee") + ErrInvalidBridgeDepositMessage = errors.Register(ModuleName, 32, "invalid bridge deposit message") + ErrInvalidBridgeWithdrawalMessage = errors.Register(ModuleName, 33, "invalid bridge withdrawal message") + ErrNegativeBridgeBalance = errors.Register(ModuleName, 34, "negative bridge balance") + ErrInvalidBridgeSourceAccount = errors.Register(ModuleName, 35, "invalid bridge source account") + ErrInvalidDappVersion = errors.Register(ModuleName, 36, "invalid dapp version") +) diff --git a/x/layer2/types/expected_keepers.go b/x/layer2/types/expected_keepers.go new file mode 100644 index 000000000..2a8ddc3bd --- /dev/null +++ b/x/layer2/types/expected_keepers.go @@ -0,0 +1,34 @@ +package types + +import ( + govtypes "github.com/KiraCore/sekai/x/gov/types" + spendingtypes "github.com/KiraCore/sekai/x/spending/types" + stakingtypes "github.com/KiraCore/sekai/x/staking/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +type CustomGovKeeper interface { + GetNetworkProperties(ctx sdk.Context) *govtypes.NetworkProperties +} + +type BankKeeper interface { + GetSupply(ctx sdk.Context, denom string) sdk.Coin + GetAllBalances(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins + MintCoins(ctx sdk.Context, moduleName string, amt sdk.Coins) error + BurnCoins(ctx sdk.Context, moduleName string, amt sdk.Coins) error + SendCoins(ctx sdk.Context, fromAddr sdk.AccAddress, toAddr sdk.AccAddress, amt sdk.Coins) error + SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error + SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error + SendCoinsFromModuleToModule(ctx sdk.Context, senderModule, recipientModule string, amt sdk.Coins) error +} + +type StakingKeeper interface { + GetValidatorByConsAddr(ctx sdk.Context, consAddr sdk.ConsAddress) (stakingtypes.Validator, error) + GetValidator(sdk.Context, sdk.ValAddress) (stakingtypes.Validator, error) +} + +type SpendingKeeper interface { + CreateSpendingPool(ctx sdk.Context, pool spendingtypes.SpendingPool) error + GetSpendingPool(ctx sdk.Context, name string) *spendingtypes.SpendingPool + DepositSpendingPoolFromModule(ctx sdk.Context, moduleName, poolName string, amount sdk.Coins) error +} diff --git a/x/layer2/types/genesis.go b/x/layer2/types/genesis.go new file mode 100644 index 000000000..3c68498a2 --- /dev/null +++ b/x/layer2/types/genesis.go @@ -0,0 +1,8 @@ +package types + +// DefaultGenesis returns the default CustomGo genesis state +func DefaultGenesis() *GenesisState { + return &GenesisState{ + Dapps: []Dapp{}, + } +} diff --git a/x/layer2/types/genesis.pb.go b/x/layer2/types/genesis.pb.go new file mode 100644 index 000000000..8359e6a20 --- /dev/null +++ b/x/layer2/types/genesis.pb.go @@ -0,0 +1,386 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: kira/layer2/genesis.proto + +package types + +import ( + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// GenesisState defines the layer2 module's genesis state. +type GenesisState struct { + // dapps registered on the module + Dapps []Dapp `protobuf:"bytes,1,rep,name=dapps,proto3" json:"dapps"` + Bridge BridgeRegistrar `protobuf:"bytes,2,opt,name=bridge,proto3" json:"bridge"` +} + +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_62e80f6b8dc90c5e, []int{0} +} +func (m *GenesisState) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GenesisState.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *GenesisState) XXX_Merge(src proto.Message) { + xxx_messageInfo_GenesisState.Merge(m, src) +} +func (m *GenesisState) XXX_Size() int { + return m.Size() +} +func (m *GenesisState) XXX_DiscardUnknown() { + xxx_messageInfo_GenesisState.DiscardUnknown(m) +} + +var xxx_messageInfo_GenesisState proto.InternalMessageInfo + +func (m *GenesisState) GetDapps() []Dapp { + if m != nil { + return m.Dapps + } + return nil +} + +func (m *GenesisState) GetBridge() BridgeRegistrar { + if m != nil { + return m.Bridge + } + return BridgeRegistrar{} +} + +func init() { + proto.RegisterType((*GenesisState)(nil), "kira.layer2.GenesisState") +} + +func init() { proto.RegisterFile("kira/layer2/genesis.proto", fileDescriptor_62e80f6b8dc90c5e) } + +var fileDescriptor_62e80f6b8dc90c5e = []byte{ + // 230 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xcc, 0xce, 0x2c, 0x4a, + 0xd4, 0xcf, 0x49, 0xac, 0x4c, 0x2d, 0x32, 0xd2, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, + 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x06, 0x49, 0xe9, 0x41, 0xa4, 0xa4, 0x44, 0xd2, 0xf3, + 0xd3, 0xf3, 0xc1, 0xe2, 0xfa, 0x20, 0x16, 0x44, 0x89, 0x94, 0x04, 0xb2, 0x6e, 0x08, 0x05, 0x91, + 0x51, 0xaa, 0xe4, 0xe2, 0x71, 0x87, 0x98, 0x16, 0x5c, 0x92, 0x58, 0x92, 0x2a, 0xa4, 0xcb, 0xc5, + 0x9a, 0x92, 0x58, 0x50, 0x50, 0x2c, 0xc1, 0xa8, 0xc0, 0xac, 0xc1, 0x6d, 0x24, 0xa8, 0x87, 0x64, + 0xb8, 0x9e, 0x4b, 0x62, 0x41, 0x81, 0x13, 0xcb, 0x89, 0x7b, 0xf2, 0x0c, 0x41, 0x10, 0x55, 0x42, + 0x56, 0x5c, 0x6c, 0x49, 0x45, 0x99, 0x29, 0xe9, 0xa9, 0x12, 0x4c, 0x0a, 0x8c, 0x1a, 0xdc, 0x46, + 0x32, 0x28, 0xea, 0x9d, 0xc0, 0x52, 0x41, 0xa9, 0xe9, 0x99, 0xc5, 0x25, 0x45, 0x89, 0x45, 0x50, + 0xad, 0x50, 0x1d, 0x4e, 0x4e, 0x27, 0x1e, 0xc9, 0x31, 0x5e, 0x78, 0x24, 0xc7, 0xf8, 0xe0, 0x91, + 0x1c, 0xe3, 0x84, 0xc7, 0x72, 0x0c, 0x17, 0x1e, 0xcb, 0x31, 0xdc, 0x78, 0x2c, 0xc7, 0x10, 0xa5, + 0x91, 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0xab, 0xef, 0x9d, 0x59, 0x94, 0xe8, + 0x9c, 0x5f, 0x94, 0xaa, 0x5f, 0x9c, 0x9a, 0x9d, 0x98, 0xa9, 0x5f, 0x01, 0xf3, 0x45, 0x49, 0x65, + 0x41, 0x6a, 0x71, 0x12, 0x1b, 0xd8, 0x17, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xcd, + 0xc9, 0xe0, 0x1f, 0x01, 0x00, 0x00, +} + +func (m *GenesisState) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *GenesisState) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Bridge.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.Dapps) > 0 { + for iNdEx := len(m.Dapps) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Dapps[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { + offset -= sovGenesis(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *GenesisState) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Dapps) > 0 { + for _, e := range m.Dapps { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + l = m.Bridge.Size() + n += 1 + l + sovGenesis(uint64(l)) + return n +} + +func sovGenesis(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozGenesis(x uint64) (n int) { + return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *GenesisState) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: GenesisState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Dapps", 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.Dapps = append(m.Dapps, Dapp{}) + if err := m.Dapps[len(m.Dapps)-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 Bridge", 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.Bridge.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/layer2/types/keys.go b/x/layer2/types/keys.go new file mode 100644 index 000000000..3a59a2876 --- /dev/null +++ b/x/layer2/types/keys.go @@ -0,0 +1,74 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// constants +const ( + ModuleName = "layer2" + // RouterKey to be used for routing msgs + RouterKey = ModuleName + // QuerierRoute is the querier route for the layer2 module + QuerierRoute = ModuleName +) + +// constants +var ( + KeyPrefixDapp = []byte("dapp_info") + PrefixUserDappBondKey = []byte("dapp_user_bond") + PrefixDappOperatorCandidateKey = []byte("dapp_operator_candidate_key") + PrefixDappOperatorKey = []byte("dapp_operator_key") + PrefixDappSessionKey = []byte("dapp_session_key") + PrefixDappSessionApprovalKey = []byte("dapp_session_approval_key") + PrefixDappLeaderDenouncementKey = []byte("dapp_leader_denouncement_key") + BridgeRegistrarHelperKey = []byte("bridge_registrar_helper") + PrefixBridgeAccountKey = []byte("bridge_account_key") + PrefixBridgeTokenKey = []byte("bridge_token_key") + PrefixXAMKey = []byte("xam_key") + PrefixTokenInfoKey = []byte("token_info") +) + +func DappKey(name string) []byte { + return append(KeyPrefixDapp, name...) +} + +func UserDappBondKey(dappName string, user string) []byte { + return append(append(PrefixUserDappBondKey, dappName...), user...) +} + +func DappOperatorCandidateKey(dappName string, operator string) []byte { + return append(append(PrefixDappOperatorCandidateKey, dappName...), operator...) +} + +func DappOperatorKey(dappName string, operator string) []byte { + return append(append(PrefixDappOperatorKey, dappName...), operator...) +} + +func ExecutionRegistrarKey(dappName string) []byte { + return append(PrefixDappSessionKey, dappName...) +} + +func DappSessionApprovalKey(dappName string, verifier string) []byte { + return append(append(PrefixDappSessionApprovalKey, dappName...), verifier...) +} + +func DappLeaderDenouncementKey(dappName string, leader string, sender string) []byte { + return append(append(append(PrefixDappLeaderDenouncementKey, dappName...), leader...), sender...) +} + +func BridgeAccountKey(index uint64) []byte { + return append(PrefixBridgeAccountKey, sdk.Uint64ToBigEndian(index)...) +} + +func BridgeTokenKey(index uint64) []byte { + return append(PrefixBridgeTokenKey, sdk.Uint64ToBigEndian(index)...) +} + +func XAMKey(xid uint64) []byte { + return append(PrefixXAMKey, sdk.Uint64ToBigEndian(xid)...) +} + +func TokenInfoKey(denom string) []byte { + return append(PrefixTokenInfoKey, denom...) +} diff --git a/x/layer2/types/layer2.go b/x/layer2/types/layer2.go new file mode 100644 index 000000000..3a72ff658 --- /dev/null +++ b/x/layer2/types/layer2.go @@ -0,0 +1,31 @@ +package types + +import ( + fmt "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func (dapp Dapp) LpToken() string { + return fmt.Sprintf("lp/%s", dapp.Denom) +} +func (dapp Dapp) GetSpendingPoolLpDeposit() sdk.Int { + return dapp.TotalBond.Amount.ToDec().Mul(dapp.Pool.Ratio).RoundInt() +} + +func (dapp Dapp) GetLpTokenSupply() sdk.Int { + spendingPoolDeposit := dapp.GetSpendingPoolLpDeposit() + totalSupply := spendingPoolDeposit.Add(dapp.Issurance.Postmint).Add(dapp.Issurance.Premint) + return totalSupply +} + +func (dapp Dapp) GetAccount() sdk.AccAddress { + return sdk.AccAddress(dapp.Name) +} + +func (dapp Dapp) Version() string { + if len(dapp.Bin) > 0 { + return dapp.Bin[0].Hash + } + return "" +} diff --git a/x/layer2/types/layer2.pb.go b/x/layer2/types/layer2.pb.go new file mode 100644 index 000000000..ad8b08a29 --- /dev/null +++ b/x/layer2/types/layer2.pb.go @@ -0,0 +1,8413 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: kira/layer2/layer2.proto + +package types + +import ( + fmt "fmt" + types "github.com/cosmos/cosmos-sdk/codec/types" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + _ "google.golang.org/protobuf/types/known/timestamppb" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type DappStatus int32 + +const ( + Bootstrap DappStatus = 0 + Active DappStatus = 1 + Paused DappStatus = 2 + Halted DappStatus = 3 +) + +var DappStatus_name = map[int32]string{ + 0: "BOOTSTRAP", + 1: "ACTIVE", + 2: "PAUSED", + 3: "HALTED", +} + +var DappStatus_value = map[string]int32{ + "BOOTSTRAP": 0, + "ACTIVE": 1, + "PAUSED": 2, + "HALTED": 3, +} + +func (x DappStatus) String() string { + return proto.EnumName(DappStatus_name, int32(x)) +} + +func (DappStatus) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_4070283bbe72a11a, []int{0} +} + +type OperatorStatus int32 + +const ( + OperatorActive OperatorStatus = 0 + OperatorPaused OperatorStatus = 1 + OperatorInactive OperatorStatus = 2 + OperatorExiting OperatorStatus = 3 + OperatorJailed OperatorStatus = 4 +) + +var OperatorStatus_name = map[int32]string{ + 0: "OPERATOR_ACTIVE", + 1: "OPERATOR_PAUSED", + 2: "OPERATOR_INACTIVE", + 3: "OPERATOR_EXITING", + 4: "OPERATOR_JAILED", +} + +var OperatorStatus_value = map[string]int32{ + "OPERATOR_ACTIVE": 0, + "OPERATOR_PAUSED": 1, + "OPERATOR_INACTIVE": 2, + "OPERATOR_EXITING": 3, + "OPERATOR_JAILED": 4, +} + +func (x OperatorStatus) String() string { + return proto.EnumName(OperatorStatus_name, int32(x)) +} + +func (OperatorStatus) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_4070283bbe72a11a, []int{1} +} + +type SessionStatus int32 + +const ( + SessionUnscheduled SessionStatus = 0 + SessionScheduled SessionStatus = 1 + SessionOngoing SessionStatus = 2 + SessionAccepted SessionStatus = 3 + SessionDenounced SessionStatus = 4 + SessionHalted SessionStatus = 5 + SessionFailed SessionStatus = 6 +) + +var SessionStatus_name = map[int32]string{ + 0: "SESSION_UNSCHEDULED", + 1: "SESSION_SCHEDULED", + 2: "SESSION_ONGOING", + 3: "SESSION_ACCEPTED", + 4: "SESSION_DENOUNCED", + 5: "SESSION_HALTED", + 6: "SESSION_FAILED", +} + +var SessionStatus_value = map[string]int32{ + "SESSION_UNSCHEDULED": 0, + "SESSION_SCHEDULED": 1, + "SESSION_ONGOING": 2, + "SESSION_ACCEPTED": 3, + "SESSION_DENOUNCED": 4, + "SESSION_HALTED": 5, + "SESSION_FAILED": 6, +} + +func (x SessionStatus) String() string { + return proto.EnumName(SessionStatus_name, int32(x)) +} + +func (SessionStatus) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_4070283bbe72a11a, []int{2} +} + +type AccountRange struct { + Addresses []string `protobuf:"bytes,1,rep,name=addresses,proto3" json:"addresses,omitempty"` + Roles []uint64 `protobuf:"varint,2,rep,packed,name=roles,proto3" json:"roles,omitempty"` +} + +func (m *AccountRange) Reset() { *m = AccountRange{} } +func (m *AccountRange) String() string { return proto.CompactTextString(m) } +func (*AccountRange) ProtoMessage() {} +func (*AccountRange) Descriptor() ([]byte, []int) { + return fileDescriptor_4070283bbe72a11a, []int{0} +} +func (m *AccountRange) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *AccountRange) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_AccountRange.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 *AccountRange) XXX_Merge(src proto.Message) { + xxx_messageInfo_AccountRange.Merge(m, src) +} +func (m *AccountRange) XXX_Size() int { + return m.Size() +} +func (m *AccountRange) XXX_DiscardUnknown() { + xxx_messageInfo_AccountRange.DiscardUnknown(m) +} + +var xxx_messageInfo_AccountRange proto.InternalMessageInfo + +func (m *AccountRange) GetAddresses() []string { + if m != nil { + return m.Addresses + } + return nil +} + +func (m *AccountRange) GetRoles() []uint64 { + if m != nil { + return m.Roles + } + return nil +} + +type Controllers struct { + Whitelist AccountRange `protobuf:"bytes,1,opt,name=whitelist,proto3" json:"whitelist"` + Blacklist AccountRange `protobuf:"bytes,2,opt,name=blacklist,proto3" json:"blacklist"` +} + +func (m *Controllers) Reset() { *m = Controllers{} } +func (m *Controllers) String() string { return proto.CompactTextString(m) } +func (*Controllers) ProtoMessage() {} +func (*Controllers) Descriptor() ([]byte, []int) { + return fileDescriptor_4070283bbe72a11a, []int{1} +} +func (m *Controllers) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Controllers) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Controllers.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 *Controllers) XXX_Merge(src proto.Message) { + xxx_messageInfo_Controllers.Merge(m, src) +} +func (m *Controllers) XXX_Size() int { + return m.Size() +} +func (m *Controllers) XXX_DiscardUnknown() { + xxx_messageInfo_Controllers.DiscardUnknown(m) +} + +var xxx_messageInfo_Controllers proto.InternalMessageInfo + +func (m *Controllers) GetWhitelist() AccountRange { + if m != nil { + return m.Whitelist + } + return AccountRange{} +} + +func (m *Controllers) GetBlacklist() AccountRange { + if m != nil { + return m.Blacklist + } + return AccountRange{} +} + +type BinaryInfo struct { + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Hash string `protobuf:"bytes,2,opt,name=hash,proto3" json:"hash,omitempty"` + Source string `protobuf:"bytes,3,opt,name=source,proto3" json:"source,omitempty"` + Reference string `protobuf:"bytes,4,opt,name=reference,proto3" json:"reference,omitempty"` + Type string `protobuf:"bytes,5,opt,name=type,proto3" json:"type,omitempty"` +} + +func (m *BinaryInfo) Reset() { *m = BinaryInfo{} } +func (m *BinaryInfo) String() string { return proto.CompactTextString(m) } +func (*BinaryInfo) ProtoMessage() {} +func (*BinaryInfo) Descriptor() ([]byte, []int) { + return fileDescriptor_4070283bbe72a11a, []int{2} +} +func (m *BinaryInfo) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *BinaryInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_BinaryInfo.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 *BinaryInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_BinaryInfo.Merge(m, src) +} +func (m *BinaryInfo) XXX_Size() int { + return m.Size() +} +func (m *BinaryInfo) XXX_DiscardUnknown() { + xxx_messageInfo_BinaryInfo.DiscardUnknown(m) +} + +var xxx_messageInfo_BinaryInfo proto.InternalMessageInfo + +func (m *BinaryInfo) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *BinaryInfo) GetHash() string { + if m != nil { + return m.Hash + } + return "" +} + +func (m *BinaryInfo) GetSource() string { + if m != nil { + return m.Source + } + return "" +} + +func (m *BinaryInfo) GetReference() string { + if m != nil { + return m.Reference + } + return "" +} + +func (m *BinaryInfo) GetType() string { + if m != nil { + return m.Type + } + return "" +} + +type LpPoolConfig struct { + Ratio github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,1,opt,name=ratio,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"ratio"` + Deposit string `protobuf:"bytes,2,opt,name=deposit,proto3" json:"deposit,omitempty"` + Drip uint64 `protobuf:"varint,3,opt,name=drip,proto3" json:"drip,omitempty"` +} + +func (m *LpPoolConfig) Reset() { *m = LpPoolConfig{} } +func (m *LpPoolConfig) String() string { return proto.CompactTextString(m) } +func (*LpPoolConfig) ProtoMessage() {} +func (*LpPoolConfig) Descriptor() ([]byte, []int) { + return fileDescriptor_4070283bbe72a11a, []int{3} +} +func (m *LpPoolConfig) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *LpPoolConfig) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_LpPoolConfig.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 *LpPoolConfig) XXX_Merge(src proto.Message) { + xxx_messageInfo_LpPoolConfig.Merge(m, src) +} +func (m *LpPoolConfig) XXX_Size() int { + return m.Size() +} +func (m *LpPoolConfig) XXX_DiscardUnknown() { + xxx_messageInfo_LpPoolConfig.DiscardUnknown(m) +} + +var xxx_messageInfo_LpPoolConfig proto.InternalMessageInfo + +func (m *LpPoolConfig) GetDeposit() string { + if m != nil { + return m.Deposit + } + return "" +} + +func (m *LpPoolConfig) GetDrip() uint64 { + if m != nil { + return m.Drip + } + return 0 +} + +type IssuranceConfig struct { + Deposit string `protobuf:"bytes,1,opt,name=deposit,proto3" json:"deposit,omitempty"` + Premint github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=premint,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"premint"` + Postmint github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=postmint,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"postmint"` + Time uint64 `protobuf:"varint,4,opt,name=time,proto3" json:"time,omitempty"` +} + +func (m *IssuranceConfig) Reset() { *m = IssuranceConfig{} } +func (m *IssuranceConfig) String() string { return proto.CompactTextString(m) } +func (*IssuranceConfig) ProtoMessage() {} +func (*IssuranceConfig) Descriptor() ([]byte, []int) { + return fileDescriptor_4070283bbe72a11a, []int{4} +} +func (m *IssuranceConfig) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *IssuranceConfig) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_IssuranceConfig.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 *IssuranceConfig) XXX_Merge(src proto.Message) { + xxx_messageInfo_IssuranceConfig.Merge(m, src) +} +func (m *IssuranceConfig) XXX_Size() int { + return m.Size() +} +func (m *IssuranceConfig) XXX_DiscardUnknown() { + xxx_messageInfo_IssuranceConfig.DiscardUnknown(m) +} + +var xxx_messageInfo_IssuranceConfig proto.InternalMessageInfo + +func (m *IssuranceConfig) GetDeposit() string { + if m != nil { + return m.Deposit + } + return "" +} + +func (m *IssuranceConfig) GetTime() uint64 { + if m != nil { + return m.Time + } + return 0 +} + +type Dapp struct { + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Denom string `protobuf:"bytes,2,opt,name=denom,proto3" json:"denom,omitempty"` + Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty"` + Website string `protobuf:"bytes,4,opt,name=website,proto3" json:"website,omitempty"` + Logo string `protobuf:"bytes,5,opt,name=logo,proto3" json:"logo,omitempty"` + Social string `protobuf:"bytes,6,opt,name=social,proto3" json:"social,omitempty"` + Docs string `protobuf:"bytes,7,opt,name=docs,proto3" json:"docs,omitempty"` + Controllers Controllers `protobuf:"bytes,8,opt,name=controllers,proto3" json:"controllers"` + Bin []BinaryInfo `protobuf:"bytes,9,rep,name=bin,proto3" json:"bin"` + Pool LpPoolConfig `protobuf:"bytes,10,opt,name=pool,proto3" json:"pool"` + Issurance IssuranceConfig `protobuf:"bytes,11,opt,name=issurance,proto3" json:"issurance"` + UpdateTimeMax uint64 `protobuf:"varint,12,opt,name=update_time_max,json=updateTimeMax,proto3" json:"update_time_max,omitempty"` + ExecutorsMin uint64 `protobuf:"varint,13,opt,name=executors_min,json=executorsMin,proto3" json:"executors_min,omitempty"` + ExecutorsMax uint64 `protobuf:"varint,14,opt,name=executors_max,json=executorsMax,proto3" json:"executors_max,omitempty"` + VerifiersMin uint64 `protobuf:"varint,15,opt,name=verifiers_min,json=verifiersMin,proto3" json:"verifiers_min,omitempty"` + TotalBond github_com_cosmos_cosmos_sdk_types.Coin `protobuf:"bytes,16,opt,name=total_bond,json=totalBond,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Coin" json:"total_bond"` + CreationTime uint64 `protobuf:"varint,17,opt,name=creation_time,json=creationTime,proto3" json:"creation_time,omitempty"` + Status DappStatus `protobuf:"varint,18,opt,name=status,proto3,enum=kira.layer2.DappStatus" json:"status,omitempty"` + VoteQuorum uint64 `protobuf:"varint,19,opt,name=vote_quorum,json=voteQuorum,proto3" json:"vote_quorum,omitempty"` + VotePeriod uint64 `protobuf:"varint,20,opt,name=vote_period,json=votePeriod,proto3" json:"vote_period,omitempty"` + VoteEnactment uint64 `protobuf:"varint,21,opt,name=vote_enactment,json=voteEnactment,proto3" json:"vote_enactment,omitempty"` + LiquidationStart uint64 `protobuf:"varint,22,opt,name=liquidation_start,json=liquidationStart,proto3" json:"liquidation_start,omitempty"` + PoolFee github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,23,opt,name=pool_fee,json=poolFee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"pool_fee"` + TeamReserve string `protobuf:"bytes,24,opt,name=team_reserve,json=teamReserve,proto3" json:"team_reserve,omitempty"` + PremintTime uint64 `protobuf:"varint,25,opt,name=premint_time,json=premintTime,proto3" json:"premint_time,omitempty"` + PostMintPaid bool `protobuf:"varint,26,opt,name=post_mint_paid,json=postMintPaid,proto3" json:"post_mint_paid,omitempty"` +} + +func (m *Dapp) Reset() { *m = Dapp{} } +func (m *Dapp) String() string { return proto.CompactTextString(m) } +func (*Dapp) ProtoMessage() {} +func (*Dapp) Descriptor() ([]byte, []int) { + return fileDescriptor_4070283bbe72a11a, []int{5} +} +func (m *Dapp) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Dapp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Dapp.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 *Dapp) XXX_Merge(src proto.Message) { + xxx_messageInfo_Dapp.Merge(m, src) +} +func (m *Dapp) XXX_Size() int { + return m.Size() +} +func (m *Dapp) XXX_DiscardUnknown() { + xxx_messageInfo_Dapp.DiscardUnknown(m) +} + +var xxx_messageInfo_Dapp proto.InternalMessageInfo + +func (m *Dapp) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *Dapp) GetDenom() string { + if m != nil { + return m.Denom + } + return "" +} + +func (m *Dapp) GetDescription() string { + if m != nil { + return m.Description + } + return "" +} + +func (m *Dapp) GetWebsite() string { + if m != nil { + return m.Website + } + return "" +} + +func (m *Dapp) GetLogo() string { + if m != nil { + return m.Logo + } + return "" +} + +func (m *Dapp) GetSocial() string { + if m != nil { + return m.Social + } + return "" +} + +func (m *Dapp) GetDocs() string { + if m != nil { + return m.Docs + } + return "" +} + +func (m *Dapp) GetControllers() Controllers { + if m != nil { + return m.Controllers + } + return Controllers{} +} + +func (m *Dapp) GetBin() []BinaryInfo { + if m != nil { + return m.Bin + } + return nil +} + +func (m *Dapp) GetPool() LpPoolConfig { + if m != nil { + return m.Pool + } + return LpPoolConfig{} +} + +func (m *Dapp) GetIssurance() IssuranceConfig { + if m != nil { + return m.Issurance + } + return IssuranceConfig{} +} + +func (m *Dapp) GetUpdateTimeMax() uint64 { + if m != nil { + return m.UpdateTimeMax + } + return 0 +} + +func (m *Dapp) GetExecutorsMin() uint64 { + if m != nil { + return m.ExecutorsMin + } + return 0 +} + +func (m *Dapp) GetExecutorsMax() uint64 { + if m != nil { + return m.ExecutorsMax + } + return 0 +} + +func (m *Dapp) GetVerifiersMin() uint64 { + if m != nil { + return m.VerifiersMin + } + return 0 +} + +func (m *Dapp) GetCreationTime() uint64 { + if m != nil { + return m.CreationTime + } + return 0 +} + +func (m *Dapp) GetStatus() DappStatus { + if m != nil { + return m.Status + } + return Bootstrap +} + +func (m *Dapp) GetVoteQuorum() uint64 { + if m != nil { + return m.VoteQuorum + } + return 0 +} + +func (m *Dapp) GetVotePeriod() uint64 { + if m != nil { + return m.VotePeriod + } + return 0 +} + +func (m *Dapp) GetVoteEnactment() uint64 { + if m != nil { + return m.VoteEnactment + } + return 0 +} + +func (m *Dapp) GetLiquidationStart() uint64 { + if m != nil { + return m.LiquidationStart + } + return 0 +} + +func (m *Dapp) GetTeamReserve() string { + if m != nil { + return m.TeamReserve + } + return "" +} + +func (m *Dapp) GetPremintTime() uint64 { + if m != nil { + return m.PremintTime + } + return 0 +} + +func (m *Dapp) GetPostMintPaid() bool { + if m != nil { + return m.PostMintPaid + } + return false +} + +type UserDappBond struct { + User string `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` + DappName string `protobuf:"bytes,2,opt,name=dapp_name,json=dappName,proto3" json:"dapp_name,omitempty"` + Bond github_com_cosmos_cosmos_sdk_types.Coin `protobuf:"bytes,3,opt,name=bond,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Coin" json:"bond"` +} + +func (m *UserDappBond) Reset() { *m = UserDappBond{} } +func (m *UserDappBond) String() string { return proto.CompactTextString(m) } +func (*UserDappBond) ProtoMessage() {} +func (*UserDappBond) Descriptor() ([]byte, []int) { + return fileDescriptor_4070283bbe72a11a, []int{6} +} +func (m *UserDappBond) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *UserDappBond) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_UserDappBond.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 *UserDappBond) XXX_Merge(src proto.Message) { + xxx_messageInfo_UserDappBond.Merge(m, src) +} +func (m *UserDappBond) XXX_Size() int { + return m.Size() +} +func (m *UserDappBond) XXX_DiscardUnknown() { + xxx_messageInfo_UserDappBond.DiscardUnknown(m) +} + +var xxx_messageInfo_UserDappBond proto.InternalMessageInfo + +func (m *UserDappBond) GetUser() string { + if m != nil { + return m.User + } + return "" +} + +func (m *UserDappBond) GetDappName() string { + if m != nil { + return m.DappName + } + return "" +} + +type DappOperator struct { + DappName string `protobuf:"bytes,1,opt,name=dapp_name,json=dappName,proto3" json:"dapp_name,omitempty"` + Operator string `protobuf:"bytes,2,opt,name=operator,proto3" json:"operator,omitempty"` + Executor bool `protobuf:"varint,3,opt,name=executor,proto3" json:"executor,omitempty"` + Verifier bool `protobuf:"varint,4,opt,name=verifier,proto3" json:"verifier,omitempty"` + Interx string `protobuf:"bytes,5,opt,name=interx,proto3" json:"interx,omitempty"` + Status OperatorStatus `protobuf:"varint,6,opt,name=status,proto3,enum=kira.layer2.OperatorStatus" json:"status,omitempty"` + Rank int64 `protobuf:"varint,7,opt,name=rank,proto3" json:"rank,omitempty"` + Streak int64 `protobuf:"varint,8,opt,name=streak,proto3" json:"streak,omitempty"` + Mischance int64 `protobuf:"varint,9,opt,name=mischance,proto3" json:"mischance,omitempty"` + VerifiedSessions int64 `protobuf:"varint,10,opt,name=verified_sessions,json=verifiedSessions,proto3" json:"verified_sessions,omitempty"` + MissedSessions int64 `protobuf:"varint,11,opt,name=missed_sessions,json=missedSessions,proto3" json:"missed_sessions,omitempty"` + BondedLpAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,12,opt,name=bonded_lp_amount,json=bondedLpAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"bonded_lp_amount"` +} + +func (m *DappOperator) Reset() { *m = DappOperator{} } +func (m *DappOperator) String() string { return proto.CompactTextString(m) } +func (*DappOperator) ProtoMessage() {} +func (*DappOperator) Descriptor() ([]byte, []int) { + return fileDescriptor_4070283bbe72a11a, []int{7} +} +func (m *DappOperator) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *DappOperator) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_DappOperator.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 *DappOperator) XXX_Merge(src proto.Message) { + xxx_messageInfo_DappOperator.Merge(m, src) +} +func (m *DappOperator) XXX_Size() int { + return m.Size() +} +func (m *DappOperator) XXX_DiscardUnknown() { + xxx_messageInfo_DappOperator.DiscardUnknown(m) +} + +var xxx_messageInfo_DappOperator proto.InternalMessageInfo + +func (m *DappOperator) GetDappName() string { + if m != nil { + return m.DappName + } + return "" +} + +func (m *DappOperator) GetOperator() string { + if m != nil { + return m.Operator + } + return "" +} + +func (m *DappOperator) GetExecutor() bool { + if m != nil { + return m.Executor + } + return false +} + +func (m *DappOperator) GetVerifier() bool { + if m != nil { + return m.Verifier + } + return false +} + +func (m *DappOperator) GetInterx() string { + if m != nil { + return m.Interx + } + return "" +} + +func (m *DappOperator) GetStatus() OperatorStatus { + if m != nil { + return m.Status + } + return OperatorActive +} + +func (m *DappOperator) GetRank() int64 { + if m != nil { + return m.Rank + } + return 0 +} + +func (m *DappOperator) GetStreak() int64 { + if m != nil { + return m.Streak + } + return 0 +} + +func (m *DappOperator) GetMischance() int64 { + if m != nil { + return m.Mischance + } + return 0 +} + +func (m *DappOperator) GetVerifiedSessions() int64 { + if m != nil { + return m.VerifiedSessions + } + return 0 +} + +func (m *DappOperator) GetMissedSessions() int64 { + if m != nil { + return m.MissedSessions + } + return 0 +} + +type DappLeaderDenouncement struct { + DappName string `protobuf:"bytes,1,opt,name=dapp_name,json=dappName,proto3" json:"dapp_name,omitempty"` + Leader string `protobuf:"bytes,2,opt,name=leader,proto3" json:"leader,omitempty"` + Sender string `protobuf:"bytes,3,opt,name=sender,proto3" json:"sender,omitempty"` + Denouncement string `protobuf:"bytes,4,opt,name=denouncement,proto3" json:"denouncement,omitempty"` +} + +func (m *DappLeaderDenouncement) Reset() { *m = DappLeaderDenouncement{} } +func (m *DappLeaderDenouncement) String() string { return proto.CompactTextString(m) } +func (*DappLeaderDenouncement) ProtoMessage() {} +func (*DappLeaderDenouncement) Descriptor() ([]byte, []int) { + return fileDescriptor_4070283bbe72a11a, []int{8} +} +func (m *DappLeaderDenouncement) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *DappLeaderDenouncement) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_DappLeaderDenouncement.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 *DappLeaderDenouncement) XXX_Merge(src proto.Message) { + xxx_messageInfo_DappLeaderDenouncement.Merge(m, src) +} +func (m *DappLeaderDenouncement) XXX_Size() int { + return m.Size() +} +func (m *DappLeaderDenouncement) XXX_DiscardUnknown() { + xxx_messageInfo_DappLeaderDenouncement.DiscardUnknown(m) +} + +var xxx_messageInfo_DappLeaderDenouncement proto.InternalMessageInfo + +func (m *DappLeaderDenouncement) GetDappName() string { + if m != nil { + return m.DappName + } + return "" +} + +func (m *DappLeaderDenouncement) GetLeader() string { + if m != nil { + return m.Leader + } + return "" +} + +func (m *DappLeaderDenouncement) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +func (m *DappLeaderDenouncement) GetDenouncement() string { + if m != nil { + return m.Denouncement + } + return "" +} + +type DappSession struct { + Leader string `protobuf:"bytes,1,opt,name=leader,proto3" json:"leader,omitempty"` + Start uint64 `protobuf:"varint,2,opt,name=start,proto3" json:"start,omitempty"` + StatusHash string `protobuf:"bytes,3,opt,name=status_hash,json=statusHash,proto3" json:"status_hash,omitempty"` + Status SessionStatus `protobuf:"varint,4,opt,name=status,proto3,enum=kira.layer2.SessionStatus" json:"status,omitempty"` + Gateway string `protobuf:"bytes,5,opt,name=gateway,proto3" json:"gateway,omitempty"` + OnchainMessages []*types.Any `protobuf:"bytes,6,rep,name=onchain_messages,json=onchainMessages,proto3" json:"onchain_messages,omitempty"` +} + +func (m *DappSession) Reset() { *m = DappSession{} } +func (m *DappSession) String() string { return proto.CompactTextString(m) } +func (*DappSession) ProtoMessage() {} +func (*DappSession) Descriptor() ([]byte, []int) { + return fileDescriptor_4070283bbe72a11a, []int{9} +} +func (m *DappSession) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *DappSession) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_DappSession.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 *DappSession) XXX_Merge(src proto.Message) { + xxx_messageInfo_DappSession.Merge(m, src) +} +func (m *DappSession) XXX_Size() int { + return m.Size() +} +func (m *DappSession) XXX_DiscardUnknown() { + xxx_messageInfo_DappSession.DiscardUnknown(m) +} + +var xxx_messageInfo_DappSession proto.InternalMessageInfo + +func (m *DappSession) GetLeader() string { + if m != nil { + return m.Leader + } + return "" +} + +func (m *DappSession) GetStart() uint64 { + if m != nil { + return m.Start + } + return 0 +} + +func (m *DappSession) GetStatusHash() string { + if m != nil { + return m.StatusHash + } + return "" +} + +func (m *DappSession) GetStatus() SessionStatus { + if m != nil { + return m.Status + } + return SessionUnscheduled +} + +func (m *DappSession) GetGateway() string { + if m != nil { + return m.Gateway + } + return "" +} + +func (m *DappSession) GetOnchainMessages() []*types.Any { + if m != nil { + return m.OnchainMessages + } + return nil +} + +type DappSessionApproval struct { + DappName string `protobuf:"bytes,1,opt,name=dapp_name,json=dappName,proto3" json:"dapp_name,omitempty"` + Approver string `protobuf:"bytes,2,opt,name=approver,proto3" json:"approver,omitempty"` + IsApproved bool `protobuf:"varint,3,opt,name=is_approved,json=isApproved,proto3" json:"is_approved,omitempty"` +} + +func (m *DappSessionApproval) Reset() { *m = DappSessionApproval{} } +func (m *DappSessionApproval) String() string { return proto.CompactTextString(m) } +func (*DappSessionApproval) ProtoMessage() {} +func (*DappSessionApproval) Descriptor() ([]byte, []int) { + return fileDescriptor_4070283bbe72a11a, []int{10} +} +func (m *DappSessionApproval) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *DappSessionApproval) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_DappSessionApproval.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 *DappSessionApproval) XXX_Merge(src proto.Message) { + xxx_messageInfo_DappSessionApproval.Merge(m, src) +} +func (m *DappSessionApproval) XXX_Size() int { + return m.Size() +} +func (m *DappSessionApproval) XXX_DiscardUnknown() { + xxx_messageInfo_DappSessionApproval.DiscardUnknown(m) +} + +var xxx_messageInfo_DappSessionApproval proto.InternalMessageInfo + +func (m *DappSessionApproval) GetDappName() string { + if m != nil { + return m.DappName + } + return "" +} + +func (m *DappSessionApproval) GetApprover() string { + if m != nil { + return m.Approver + } + return "" +} + +func (m *DappSessionApproval) GetIsApproved() bool { + if m != nil { + return m.IsApproved + } + return false +} + +type ExecutionRegistrar struct { + DappName string `protobuf:"bytes,1,opt,name=dapp_name,json=dappName,proto3" json:"dapp_name,omitempty"` + PrevSession *DappSession `protobuf:"bytes,2,opt,name=prev_session,json=prevSession,proto3" json:"prev_session,omitempty"` + CurrSession *DappSession `protobuf:"bytes,3,opt,name=curr_session,json=currSession,proto3" json:"curr_session,omitempty"` + NextSession *DappSession `protobuf:"bytes,4,opt,name=next_session,json=nextSession,proto3" json:"next_session,omitempty"` +} + +func (m *ExecutionRegistrar) Reset() { *m = ExecutionRegistrar{} } +func (m *ExecutionRegistrar) String() string { return proto.CompactTextString(m) } +func (*ExecutionRegistrar) ProtoMessage() {} +func (*ExecutionRegistrar) Descriptor() ([]byte, []int) { + return fileDescriptor_4070283bbe72a11a, []int{11} +} +func (m *ExecutionRegistrar) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ExecutionRegistrar) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ExecutionRegistrar.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 *ExecutionRegistrar) XXX_Merge(src proto.Message) { + xxx_messageInfo_ExecutionRegistrar.Merge(m, src) +} +func (m *ExecutionRegistrar) XXX_Size() int { + return m.Size() +} +func (m *ExecutionRegistrar) XXX_DiscardUnknown() { + xxx_messageInfo_ExecutionRegistrar.DiscardUnknown(m) +} + +var xxx_messageInfo_ExecutionRegistrar proto.InternalMessageInfo + +func (m *ExecutionRegistrar) GetDappName() string { + if m != nil { + return m.DappName + } + return "" +} + +func (m *ExecutionRegistrar) GetPrevSession() *DappSession { + if m != nil { + return m.PrevSession + } + return nil +} + +func (m *ExecutionRegistrar) GetCurrSession() *DappSession { + if m != nil { + return m.CurrSession + } + return nil +} + +func (m *ExecutionRegistrar) GetNextSession() *DappSession { + if m != nil { + return m.NextSession + } + return nil +} + +type BridgeRegistrarHelper struct { + NextUser uint64 `protobuf:"varint,1,opt,name=next_user,json=nextUser,proto3" json:"next_user,omitempty"` + NextXam uint64 `protobuf:"varint,2,opt,name=next_xam,json=nextXam,proto3" json:"next_xam,omitempty"` + NextToken uint64 `protobuf:"varint,3,opt,name=next_token,json=nextToken,proto3" json:"next_token,omitempty"` +} + +func (m *BridgeRegistrarHelper) Reset() { *m = BridgeRegistrarHelper{} } +func (m *BridgeRegistrarHelper) String() string { return proto.CompactTextString(m) } +func (*BridgeRegistrarHelper) ProtoMessage() {} +func (*BridgeRegistrarHelper) Descriptor() ([]byte, []int) { + return fileDescriptor_4070283bbe72a11a, []int{12} +} +func (m *BridgeRegistrarHelper) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *BridgeRegistrarHelper) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_BridgeRegistrarHelper.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 *BridgeRegistrarHelper) XXX_Merge(src proto.Message) { + xxx_messageInfo_BridgeRegistrarHelper.Merge(m, src) +} +func (m *BridgeRegistrarHelper) XXX_Size() int { + return m.Size() +} +func (m *BridgeRegistrarHelper) XXX_DiscardUnknown() { + xxx_messageInfo_BridgeRegistrarHelper.DiscardUnknown(m) +} + +var xxx_messageInfo_BridgeRegistrarHelper proto.InternalMessageInfo + +func (m *BridgeRegistrarHelper) GetNextUser() uint64 { + if m != nil { + return m.NextUser + } + return 0 +} + +func (m *BridgeRegistrarHelper) GetNextXam() uint64 { + if m != nil { + return m.NextXam + } + return 0 +} + +func (m *BridgeRegistrarHelper) GetNextToken() uint64 { + if m != nil { + return m.NextToken + } + return 0 +} + +type BridgeRegistrar struct { + Helper *BridgeRegistrarHelper `protobuf:"bytes,1,opt,name=helper,proto3" json:"helper,omitempty"` + Accounts []BridgeAccount `protobuf:"bytes,2,rep,name=accounts,proto3" json:"accounts"` + Tokens []BridgeToken `protobuf:"bytes,3,rep,name=tokens,proto3" json:"tokens"` + Xams []XAM `protobuf:"bytes,4,rep,name=xams,proto3" json:"xams"` +} + +func (m *BridgeRegistrar) Reset() { *m = BridgeRegistrar{} } +func (m *BridgeRegistrar) String() string { return proto.CompactTextString(m) } +func (*BridgeRegistrar) ProtoMessage() {} +func (*BridgeRegistrar) Descriptor() ([]byte, []int) { + return fileDescriptor_4070283bbe72a11a, []int{13} +} +func (m *BridgeRegistrar) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *BridgeRegistrar) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_BridgeRegistrar.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 *BridgeRegistrar) XXX_Merge(src proto.Message) { + xxx_messageInfo_BridgeRegistrar.Merge(m, src) +} +func (m *BridgeRegistrar) XXX_Size() int { + return m.Size() +} +func (m *BridgeRegistrar) XXX_DiscardUnknown() { + xxx_messageInfo_BridgeRegistrar.DiscardUnknown(m) +} + +var xxx_messageInfo_BridgeRegistrar proto.InternalMessageInfo + +func (m *BridgeRegistrar) GetHelper() *BridgeRegistrarHelper { + if m != nil { + return m.Helper + } + return nil +} + +func (m *BridgeRegistrar) GetAccounts() []BridgeAccount { + if m != nil { + return m.Accounts + } + return nil +} + +func (m *BridgeRegistrar) GetTokens() []BridgeToken { + if m != nil { + return m.Tokens + } + return nil +} + +func (m *BridgeRegistrar) GetXams() []XAM { + if m != nil { + return m.Xams + } + return nil +} + +type BridgeBalance struct { + BridgeTokenIndex uint64 `protobuf:"varint,1,opt,name=bridge_token_index,json=bridgeTokenIndex,proto3" json:"bridge_token_index,omitempty"` + Amount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=amount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"amount"` +} + +func (m *BridgeBalance) Reset() { *m = BridgeBalance{} } +func (m *BridgeBalance) String() string { return proto.CompactTextString(m) } +func (*BridgeBalance) ProtoMessage() {} +func (*BridgeBalance) Descriptor() ([]byte, []int) { + return fileDescriptor_4070283bbe72a11a, []int{14} +} +func (m *BridgeBalance) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *BridgeBalance) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_BridgeBalance.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 *BridgeBalance) XXX_Merge(src proto.Message) { + xxx_messageInfo_BridgeBalance.Merge(m, src) +} +func (m *BridgeBalance) XXX_Size() int { + return m.Size() +} +func (m *BridgeBalance) XXX_DiscardUnknown() { + xxx_messageInfo_BridgeBalance.DiscardUnknown(m) +} + +var xxx_messageInfo_BridgeBalance proto.InternalMessageInfo + +func (m *BridgeBalance) GetBridgeTokenIndex() uint64 { + if m != nil { + return m.BridgeTokenIndex + } + return 0 +} + +type BridgeAccount struct { + Index uint64 `protobuf:"varint,1,opt,name=index,proto3" json:"index,omitempty"` + Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"` + DappName string `protobuf:"bytes,3,opt,name=dapp_name,json=dappName,proto3" json:"dapp_name,omitempty"` + Balances []BridgeBalance `protobuf:"bytes,4,rep,name=balances,proto3" json:"balances"` +} + +func (m *BridgeAccount) Reset() { *m = BridgeAccount{} } +func (m *BridgeAccount) String() string { return proto.CompactTextString(m) } +func (*BridgeAccount) ProtoMessage() {} +func (*BridgeAccount) Descriptor() ([]byte, []int) { + return fileDescriptor_4070283bbe72a11a, []int{15} +} +func (m *BridgeAccount) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *BridgeAccount) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_BridgeAccount.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 *BridgeAccount) XXX_Merge(src proto.Message) { + xxx_messageInfo_BridgeAccount.Merge(m, src) +} +func (m *BridgeAccount) XXX_Size() int { + return m.Size() +} +func (m *BridgeAccount) XXX_DiscardUnknown() { + xxx_messageInfo_BridgeAccount.DiscardUnknown(m) +} + +var xxx_messageInfo_BridgeAccount proto.InternalMessageInfo + +func (m *BridgeAccount) GetIndex() uint64 { + if m != nil { + return m.Index + } + return 0 +} + +func (m *BridgeAccount) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +func (m *BridgeAccount) GetDappName() string { + if m != nil { + return m.DappName + } + return "" +} + +func (m *BridgeAccount) GetBalances() []BridgeBalance { + if m != nil { + return m.Balances + } + return nil +} + +type BridgeToken struct { + Index uint64 `protobuf:"varint,1,opt,name=index,proto3" json:"index,omitempty"` + Denom string `protobuf:"bytes,2,opt,name=denom,proto3" json:"denom,omitempty"` +} + +func (m *BridgeToken) Reset() { *m = BridgeToken{} } +func (m *BridgeToken) String() string { return proto.CompactTextString(m) } +func (*BridgeToken) ProtoMessage() {} +func (*BridgeToken) Descriptor() ([]byte, []int) { + return fileDescriptor_4070283bbe72a11a, []int{16} +} +func (m *BridgeToken) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *BridgeToken) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_BridgeToken.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 *BridgeToken) XXX_Merge(src proto.Message) { + xxx_messageInfo_BridgeToken.Merge(m, src) +} +func (m *BridgeToken) XXX_Size() int { + return m.Size() +} +func (m *BridgeToken) XXX_DiscardUnknown() { + xxx_messageInfo_BridgeToken.DiscardUnknown(m) +} + +var xxx_messageInfo_BridgeToken proto.InternalMessageInfo + +func (m *BridgeToken) GetIndex() uint64 { + if m != nil { + return m.Index + } + return 0 +} + +func (m *BridgeToken) GetDenom() string { + if m != nil { + return m.Denom + } + return "" +} + +type XAMRequest struct { + Amounts []BridgeBalance `protobuf:"bytes,1,rep,name=amounts,proto3" json:"amounts"` + SourceDapp uint64 `protobuf:"varint,2,opt,name=source_dapp,json=sourceDapp,proto3" json:"source_dapp,omitempty"` + SourceAccount uint64 `protobuf:"varint,3,opt,name=source_account,json=sourceAccount,proto3" json:"source_account,omitempty"` + DestDapp uint64 `protobuf:"varint,4,opt,name=dest_dapp,json=destDapp,proto3" json:"dest_dapp,omitempty"` + DestBeneficiary uint64 `protobuf:"varint,5,opt,name=dest_beneficiary,json=destBeneficiary,proto3" json:"dest_beneficiary,omitempty"` + Xam string `protobuf:"bytes,6,opt,name=xam,proto3" json:"xam,omitempty"` +} + +func (m *XAMRequest) Reset() { *m = XAMRequest{} } +func (m *XAMRequest) String() string { return proto.CompactTextString(m) } +func (*XAMRequest) ProtoMessage() {} +func (*XAMRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_4070283bbe72a11a, []int{17} +} +func (m *XAMRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *XAMRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_XAMRequest.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 *XAMRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_XAMRequest.Merge(m, src) +} +func (m *XAMRequest) XXX_Size() int { + return m.Size() +} +func (m *XAMRequest) XXX_DiscardUnknown() { + xxx_messageInfo_XAMRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_XAMRequest proto.InternalMessageInfo + +func (m *XAMRequest) GetAmounts() []BridgeBalance { + if m != nil { + return m.Amounts + } + return nil +} + +func (m *XAMRequest) GetSourceDapp() uint64 { + if m != nil { + return m.SourceDapp + } + return 0 +} + +func (m *XAMRequest) GetSourceAccount() uint64 { + if m != nil { + return m.SourceAccount + } + return 0 +} + +func (m *XAMRequest) GetDestDapp() uint64 { + if m != nil { + return m.DestDapp + } + return 0 +} + +func (m *XAMRequest) GetDestBeneficiary() uint64 { + if m != nil { + return m.DestBeneficiary + } + return 0 +} + +func (m *XAMRequest) GetXam() string { + if m != nil { + return m.Xam + } + return "" +} + +type XAMResponse struct { + Xid uint64 `protobuf:"varint,1,opt,name=xid,proto3" json:"xid,omitempty"` + Irc uint64 `protobuf:"varint,2,opt,name=irc,proto3" json:"irc,omitempty"` + Src uint64 `protobuf:"varint,3,opt,name=src,proto3" json:"src,omitempty"` + Drc uint64 `protobuf:"varint,4,opt,name=drc,proto3" json:"drc,omitempty"` + Irm uint64 `protobuf:"varint,5,opt,name=irm,proto3" json:"irm,omitempty"` + Srm uint64 `protobuf:"varint,6,opt,name=srm,proto3" json:"srm,omitempty"` + Drm uint64 `protobuf:"varint,7,opt,name=drm,proto3" json:"drm,omitempty"` +} + +func (m *XAMResponse) Reset() { *m = XAMResponse{} } +func (m *XAMResponse) String() string { return proto.CompactTextString(m) } +func (*XAMResponse) ProtoMessage() {} +func (*XAMResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_4070283bbe72a11a, []int{18} +} +func (m *XAMResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *XAMResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_XAMResponse.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 *XAMResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_XAMResponse.Merge(m, src) +} +func (m *XAMResponse) XXX_Size() int { + return m.Size() +} +func (m *XAMResponse) XXX_DiscardUnknown() { + xxx_messageInfo_XAMResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_XAMResponse proto.InternalMessageInfo + +func (m *XAMResponse) GetXid() uint64 { + if m != nil { + return m.Xid + } + return 0 +} + +func (m *XAMResponse) GetIrc() uint64 { + if m != nil { + return m.Irc + } + return 0 +} + +func (m *XAMResponse) GetSrc() uint64 { + if m != nil { + return m.Src + } + return 0 +} + +func (m *XAMResponse) GetDrc() uint64 { + if m != nil { + return m.Drc + } + return 0 +} + +func (m *XAMResponse) GetIrm() uint64 { + if m != nil { + return m.Irm + } + return 0 +} + +func (m *XAMResponse) GetSrm() uint64 { + if m != nil { + return m.Srm + } + return 0 +} + +func (m *XAMResponse) GetDrm() uint64 { + if m != nil { + return m.Drm + } + return 0 +} + +type XAM struct { + ReqTime uint64 `protobuf:"varint,1,opt,name=req_time,json=reqTime,proto3" json:"req_time,omitempty"` + Req XAMRequest `protobuf:"bytes,2,opt,name=req,proto3" json:"req"` + Res XAMResponse `protobuf:"bytes,3,opt,name=res,proto3" json:"res"` +} + +func (m *XAM) Reset() { *m = XAM{} } +func (m *XAM) String() string { return proto.CompactTextString(m) } +func (*XAM) ProtoMessage() {} +func (*XAM) Descriptor() ([]byte, []int) { + return fileDescriptor_4070283bbe72a11a, []int{19} +} +func (m *XAM) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *XAM) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_XAM.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 *XAM) XXX_Merge(src proto.Message) { + xxx_messageInfo_XAM.Merge(m, src) +} +func (m *XAM) XXX_Size() int { + return m.Size() +} +func (m *XAM) XXX_DiscardUnknown() { + xxx_messageInfo_XAM.DiscardUnknown(m) +} + +var xxx_messageInfo_XAM proto.InternalMessageInfo + +func (m *XAM) GetReqTime() uint64 { + if m != nil { + return m.ReqTime + } + return 0 +} + +func (m *XAM) GetReq() XAMRequest { + if m != nil { + return m.Req + } + return XAMRequest{} +} + +func (m *XAM) GetRes() XAMResponse { + if m != nil { + return m.Res + } + return XAMResponse{} +} + +func init() { + proto.RegisterEnum("kira.layer2.DappStatus", DappStatus_name, DappStatus_value) + proto.RegisterEnum("kira.layer2.OperatorStatus", OperatorStatus_name, OperatorStatus_value) + proto.RegisterEnum("kira.layer2.SessionStatus", SessionStatus_name, SessionStatus_value) + proto.RegisterType((*AccountRange)(nil), "kira.layer2.AccountRange") + proto.RegisterType((*Controllers)(nil), "kira.layer2.Controllers") + proto.RegisterType((*BinaryInfo)(nil), "kira.layer2.BinaryInfo") + proto.RegisterType((*LpPoolConfig)(nil), "kira.layer2.LpPoolConfig") + proto.RegisterType((*IssuranceConfig)(nil), "kira.layer2.IssuranceConfig") + proto.RegisterType((*Dapp)(nil), "kira.layer2.Dapp") + proto.RegisterType((*UserDappBond)(nil), "kira.layer2.UserDappBond") + proto.RegisterType((*DappOperator)(nil), "kira.layer2.DappOperator") + proto.RegisterType((*DappLeaderDenouncement)(nil), "kira.layer2.DappLeaderDenouncement") + proto.RegisterType((*DappSession)(nil), "kira.layer2.DappSession") + proto.RegisterType((*DappSessionApproval)(nil), "kira.layer2.DappSessionApproval") + proto.RegisterType((*ExecutionRegistrar)(nil), "kira.layer2.ExecutionRegistrar") + proto.RegisterType((*BridgeRegistrarHelper)(nil), "kira.layer2.BridgeRegistrarHelper") + proto.RegisterType((*BridgeRegistrar)(nil), "kira.layer2.BridgeRegistrar") + proto.RegisterType((*BridgeBalance)(nil), "kira.layer2.BridgeBalance") + proto.RegisterType((*BridgeAccount)(nil), "kira.layer2.BridgeAccount") + proto.RegisterType((*BridgeToken)(nil), "kira.layer2.BridgeToken") + proto.RegisterType((*XAMRequest)(nil), "kira.layer2.XAMRequest") + proto.RegisterType((*XAMResponse)(nil), "kira.layer2.XAMResponse") + proto.RegisterType((*XAM)(nil), "kira.layer2.XAM") +} + +func init() { proto.RegisterFile("kira/layer2/layer2.proto", fileDescriptor_4070283bbe72a11a) } + +var fileDescriptor_4070283bbe72a11a = []byte{ + // 2178 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x58, 0x4b, 0x6f, 0x1b, 0xc9, + 0xf1, 0xd7, 0x88, 0x94, 0x44, 0x35, 0xf5, 0xa0, 0xdb, 0x5a, 0x7b, 0xcc, 0xdd, 0xbf, 0xcc, 0x3f, + 0x93, 0x5d, 0xcb, 0xde, 0x44, 0x0c, 0x6c, 0x20, 0x40, 0x76, 0x37, 0xc8, 0x52, 0x12, 0xbd, 0xa2, + 0x63, 0x3d, 0x32, 0x92, 0x02, 0x21, 0x17, 0xa2, 0x39, 0xd3, 0xa2, 0x1a, 0x9a, 0x99, 0x1e, 0x75, + 0x0f, 0x65, 0xea, 0x92, 0x43, 0x1e, 0x40, 0xa2, 0x5c, 0x72, 0x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+ 0x90, 0xe5, 0x7e, 0x12, 0xb0, 0x94, 0x77, 0xe0, 0x9c, 0x3a, 0x11, 0x1b, 0xb8, 0x0b, 0x78, 0x6e, + 0x8b, 0x06, 0x3e, 0x14, 0x11, 0xdf, 0x61, 0x03, 0xfa, 0x35, 0xb2, 0xc8, 0x07, 0xdc, 0xef, 0xa7, + 0x52, 0xe9, 0x4e, 0x24, 0x62, 0x77, 0x11, 0x59, 0x0b, 0x39, 0xb8, 0x23, 0xe2, 0x09, 0x12, 0x1b, + 0xb8, 0x4b, 0x93, 0x24, 0x63, 0xe9, 0x82, 0x2b, 0x71, 0x22, 0xb8, 0xb5, 0xb4, 0x6c, 0x48, 0x39, + 0x08, 0x96, 0x76, 0x09, 0x49, 0x65, 0xca, 0xc2, 0x4e, 0x57, 0xc6, 0x81, 0x5b, 0xc1, 0x8c, 0x6c, + 0xd8, 0x8c, 0x7c, 0xf0, 0x06, 0x19, 0xb9, 0x29, 0x45, 0xec, 0xcd, 0xa3, 0x89, 0x0d, 0x19, 0x07, + 0xb0, 0xa8, 0xaf, 0x38, 0x5c, 0xc8, 0x18, 0x37, 0xea, 0xde, 0x32, 0x8b, 0x66, 0x20, 0x6c, 0x93, + 0x36, 0xc8, 0xac, 0x4e, 0x59, 0xda, 0xd7, 0x2e, 0xad, 0x39, 0x6b, 0x4b, 0x13, 0xc7, 0x06, 0xe9, + 0x7b, 0x80, 0xd3, 0x9e, 0xa5, 0xd1, 0xfb, 0xa4, 0x7c, 0x21, 0x53, 0xde, 0x39, 0xef, 0x4b, 0xd5, + 0x8f, 0xdc, 0xdb, 0x68, 0x93, 0x00, 0xf4, 0x03, 0x44, 0x72, 0x42, 0xc2, 0x95, 0x90, 0x81, 0xbb, + 0x32, 0x24, 0xec, 0x23, 0x42, 0xdf, 0x27, 0x4b, 0x48, 0xe0, 0x31, 0xf3, 0xd3, 0x88, 0xc7, 0xa9, + 0xfb, 0x8e, 0x89, 0x3e, 0xa0, 0xad, 0x0c, 0xa4, 0x1f, 0x92, 0x5b, 0xa1, 0x38, 0xef, 0x8b, 0xc0, + 0xec, 0x40, 0xa7, 0x4c, 0xa5, 0xee, 0x1d, 0x64, 0x56, 0x46, 0x26, 0x0e, 0x00, 0xa7, 0x6d, 0xb8, + 0xcb, 0x32, 0xec, 0x9c, 0x70, 0xee, 0xde, 0x7d, 0xab, 0xd2, 0x35, 0x07, 0xfa, 0x4f, 0x39, 0xa7, + 0xff, 0x4f, 0x16, 0x52, 0xce, 0xa2, 0x8e, 0xe2, 0x9a, 0xab, 0x0b, 0xee, 0xba, 0xe6, 0x12, 0x02, + 0xe6, 0x19, 0x08, 0x28, 0xb6, 0x88, 0x98, 0xc0, 0xde, 0x43, 0xaf, 0xca, 0x16, 0xc3, 0xb8, 0x7e, + 0x9d, 0x2c, 0x41, 0x71, 0xe8, 0x20, 0x29, 0x61, 0x22, 0x70, 0xab, 0x35, 0x67, 0xad, 0xe4, 0x2d, + 0x00, 0xba, 0x23, 0xe2, 0x74, 0x9f, 0x89, 0xa0, 0xfe, 0x33, 0x87, 0x2c, 0x1c, 0x69, 0xae, 0x20, + 0xce, 0x78, 0x66, 0x94, 0x14, 0xfb, 0x9a, 0xab, 0xac, 0x54, 0xc0, 0x98, 0xbe, 0x4b, 0xe6, 0x03, + 0x96, 0x24, 0x1d, 0xac, 0x21, 0xa6, 0x5c, 0x94, 0x00, 0xd8, 0x85, 0x3a, 0xb2, 0x49, 0x8a, 0x98, + 0x2e, 0x85, 0xb7, 0x4b, 0x17, 0x54, 0xae, 0xff, 0xb1, 0x40, 0x16, 0xc0, 0x85, 0xbd, 0x84, 0x2b, + 0x96, 0xca, 0x89, 0x25, 0x9d, 0x89, 0x25, 0xab, 0xa4, 0x24, 0x2d, 0x31, 0x73, 0x27, 0x93, 0x61, + 0x2e, 0x4b, 0x7c, 0x74, 0xa9, 0xe4, 0xe5, 0x32, 0xcc, 0x65, 0xf9, 0x8e, 0xb5, 0xab, 0xe4, 0xe5, + 0x32, 0x14, 0x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, 0x6b, 0x59, 0x14, 0x4c, 0x26, 0x8c, 0xd2, 0x9e, 0x9a, + 0x28, 0xce, 0x8e, 0xd1, 0x9e, 0x8e, 0x04, 0x71, 0xe3, 0xe9, 0xef, 0x5f, 0xae, 0x3a, 0x9f, 0xbf, + 0x5c, 0x75, 0xbe, 0x78, 0xb9, 0xea, 0xfc, 0xf5, 0xe5, 0xaa, 0xf3, 0xeb, 0x57, 0xab, 0x53, 0x5f, + 0xbc, 0x5a, 0x9d, 0xfa, 0xf3, 0xab, 0xd5, 0xa9, 0x1f, 0xad, 0x8d, 0x54, 0xf4, 0xef, 0x0b, 0xc5, + 0x36, 0xa5, 0xe2, 0x0d, 0xcd, 0xcf, 0x98, 0x68, 0x0c, 0xb2, 0xff, 0x04, 0xb1, 0xae, 0x77, 0x67, + 0xb1, 0x61, 0x7a, 0xf2, 0xef, 0x00, 0x00, 0x00, 0xff, 0xff, 0x7f, 0xc4, 0x05, 0xf0, 0x2f, 0x14, + 0x00, 0x00, +} + +func (this *AccountRange) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*AccountRange) + if !ok { + that2, ok := that.(AccountRange) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if len(this.Addresses) != len(that1.Addresses) { + return false + } + for i := range this.Addresses { + if this.Addresses[i] != that1.Addresses[i] { + return false + } + } + if len(this.Roles) != len(that1.Roles) { + return false + } + for i := range this.Roles { + if this.Roles[i] != that1.Roles[i] { + return false + } + } + return true +} +func (this *Controllers) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*Controllers) + if !ok { + that2, ok := that.(Controllers) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if !this.Whitelist.Equal(&that1.Whitelist) { + return false + } + if !this.Blacklist.Equal(&that1.Blacklist) { + return false + } + return true +} +func (this *BinaryInfo) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*BinaryInfo) + if !ok { + that2, ok := that.(BinaryInfo) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Name != that1.Name { + return false + } + if this.Hash != that1.Hash { + return false + } + if this.Source != that1.Source { + return false + } + if this.Reference != that1.Reference { + return false + } + if this.Type != that1.Type { + return false + } + return true +} +func (this *LpPoolConfig) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*LpPoolConfig) + if !ok { + that2, ok := that.(LpPoolConfig) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if !this.Ratio.Equal(that1.Ratio) { + return false + } + if this.Deposit != that1.Deposit { + return false + } + if this.Drip != that1.Drip { + return false + } + return true +} +func (this *IssuranceConfig) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*IssuranceConfig) + if !ok { + that2, ok := that.(IssuranceConfig) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Deposit != that1.Deposit { + return false + } + if !this.Premint.Equal(that1.Premint) { + return false + } + if !this.Postmint.Equal(that1.Postmint) { + return false + } + if this.Time != that1.Time { + return false + } + return true +} +func (this *Dapp) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*Dapp) + if !ok { + that2, ok := that.(Dapp) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Name != that1.Name { + return false + } + if this.Denom != that1.Denom { + return false + } + if this.Description != that1.Description { + return false + } + if this.Website != that1.Website { + return false + } + if this.Logo != that1.Logo { + return false + } + if this.Social != that1.Social { + return false + } + if this.Docs != that1.Docs { + return false + } + if !this.Controllers.Equal(&that1.Controllers) { + return false + } + if len(this.Bin) != len(that1.Bin) { + return false + } + for i := range this.Bin { + if !this.Bin[i].Equal(&that1.Bin[i]) { + return false + } + } + if !this.Pool.Equal(&that1.Pool) { + return false + } + if !this.Issurance.Equal(&that1.Issurance) { + return false + } + if this.UpdateTimeMax != that1.UpdateTimeMax { + return false + } + if this.ExecutorsMin != that1.ExecutorsMin { + return false + } + if this.ExecutorsMax != that1.ExecutorsMax { + return false + } + if this.VerifiersMin != that1.VerifiersMin { + return false + } + if !this.TotalBond.Equal(that1.TotalBond) { + return false + } + if this.CreationTime != that1.CreationTime { + return false + } + if this.Status != that1.Status { + return false + } + if this.VoteQuorum != that1.VoteQuorum { + return false + } + if this.VotePeriod != that1.VotePeriod { + return false + } + if this.VoteEnactment != that1.VoteEnactment { + return false + } + if this.LiquidationStart != that1.LiquidationStart { + return false + } + if !this.PoolFee.Equal(that1.PoolFee) { + return false + } + if this.TeamReserve != that1.TeamReserve { + return false + } + if this.PremintTime != that1.PremintTime { + return false + } + if this.PostMintPaid != that1.PostMintPaid { + return false + } + return true +} +func (this *UserDappBond) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*UserDappBond) + if !ok { + that2, ok := that.(UserDappBond) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.User != that1.User { + return false + } + if this.DappName != that1.DappName { + return false + } + if !this.Bond.Equal(that1.Bond) { + return false + } + return true +} +func (this *DappOperator) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*DappOperator) + if !ok { + that2, ok := that.(DappOperator) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.DappName != that1.DappName { + return false + } + if this.Operator != that1.Operator { + return false + } + if this.Executor != that1.Executor { + return false + } + if this.Verifier != that1.Verifier { + return false + } + if this.Interx != that1.Interx { + return false + } + if this.Status != that1.Status { + return false + } + if this.Rank != that1.Rank { + return false + } + if this.Streak != that1.Streak { + return false + } + if this.Mischance != that1.Mischance { + return false + } + if this.VerifiedSessions != that1.VerifiedSessions { + return false + } + if this.MissedSessions != that1.MissedSessions { + return false + } + if !this.BondedLpAmount.Equal(that1.BondedLpAmount) { + return false + } + return true +} +func (this *DappLeaderDenouncement) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*DappLeaderDenouncement) + if !ok { + that2, ok := that.(DappLeaderDenouncement) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.DappName != that1.DappName { + return false + } + if this.Leader != that1.Leader { + return false + } + if this.Sender != that1.Sender { + return false + } + if this.Denouncement != that1.Denouncement { + return false + } + return true +} +func (this *DappSession) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*DappSession) + if !ok { + that2, ok := that.(DappSession) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Leader != that1.Leader { + return false + } + if this.Start != that1.Start { + return false + } + if this.StatusHash != that1.StatusHash { + return false + } + if this.Status != that1.Status { + return false + } + if this.Gateway != that1.Gateway { + return false + } + if len(this.OnchainMessages) != len(that1.OnchainMessages) { + return false + } + for i := range this.OnchainMessages { + if !this.OnchainMessages[i].Equal(that1.OnchainMessages[i]) { + return false + } + } + return true +} +func (this *DappSessionApproval) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*DappSessionApproval) + if !ok { + that2, ok := that.(DappSessionApproval) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.DappName != that1.DappName { + return false + } + if this.Approver != that1.Approver { + return false + } + if this.IsApproved != that1.IsApproved { + return false + } + return true +} +func (this *ExecutionRegistrar) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*ExecutionRegistrar) + if !ok { + that2, ok := that.(ExecutionRegistrar) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.DappName != that1.DappName { + return false + } + if !this.PrevSession.Equal(that1.PrevSession) { + return false + } + if !this.CurrSession.Equal(that1.CurrSession) { + return false + } + if !this.NextSession.Equal(that1.NextSession) { + return false + } + return true +} +func (this *BridgeRegistrarHelper) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*BridgeRegistrarHelper) + if !ok { + that2, ok := that.(BridgeRegistrarHelper) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.NextUser != that1.NextUser { + return false + } + if this.NextXam != that1.NextXam { + return false + } + if this.NextToken != that1.NextToken { + return false + } + return true +} +func (this *BridgeRegistrar) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*BridgeRegistrar) + if !ok { + that2, ok := that.(BridgeRegistrar) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if !this.Helper.Equal(that1.Helper) { + return false + } + if len(this.Accounts) != len(that1.Accounts) { + return false + } + for i := range this.Accounts { + if !this.Accounts[i].Equal(&that1.Accounts[i]) { + return false + } + } + if len(this.Tokens) != len(that1.Tokens) { + return false + } + for i := range this.Tokens { + if !this.Tokens[i].Equal(&that1.Tokens[i]) { + return false + } + } + if len(this.Xams) != len(that1.Xams) { + return false + } + for i := range this.Xams { + if !this.Xams[i].Equal(&that1.Xams[i]) { + return false + } + } + return true +} +func (this *BridgeBalance) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*BridgeBalance) + if !ok { + that2, ok := that.(BridgeBalance) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.BridgeTokenIndex != that1.BridgeTokenIndex { + return false + } + if !this.Amount.Equal(that1.Amount) { + return false + } + return true +} +func (this *BridgeAccount) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*BridgeAccount) + if !ok { + that2, ok := that.(BridgeAccount) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Index != that1.Index { + return false + } + if this.Address != that1.Address { + return false + } + if this.DappName != that1.DappName { + return false + } + if len(this.Balances) != len(that1.Balances) { + return false + } + for i := range this.Balances { + if !this.Balances[i].Equal(&that1.Balances[i]) { + return false + } + } + return true +} +func (this *BridgeToken) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*BridgeToken) + if !ok { + that2, ok := that.(BridgeToken) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Index != that1.Index { + return false + } + if this.Denom != that1.Denom { + return false + } + return true +} +func (this *XAMRequest) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*XAMRequest) + if !ok { + that2, ok := that.(XAMRequest) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if len(this.Amounts) != len(that1.Amounts) { + return false + } + for i := range this.Amounts { + if !this.Amounts[i].Equal(&that1.Amounts[i]) { + return false + } + } + if this.SourceDapp != that1.SourceDapp { + return false + } + if this.SourceAccount != that1.SourceAccount { + return false + } + if this.DestDapp != that1.DestDapp { + return false + } + if this.DestBeneficiary != that1.DestBeneficiary { + return false + } + if this.Xam != that1.Xam { + return false + } + return true +} +func (this *XAMResponse) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*XAMResponse) + if !ok { + that2, ok := that.(XAMResponse) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Xid != that1.Xid { + return false + } + if this.Irc != that1.Irc { + return false + } + if this.Src != that1.Src { + return false + } + if this.Drc != that1.Drc { + return false + } + if this.Irm != that1.Irm { + return false + } + if this.Srm != that1.Srm { + return false + } + if this.Drm != that1.Drm { + return false + } + return true +} +func (this *XAM) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*XAM) + if !ok { + that2, ok := that.(XAM) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.ReqTime != that1.ReqTime { + return false + } + if !this.Req.Equal(&that1.Req) { + return false + } + if !this.Res.Equal(&that1.Res) { + return false + } + return true +} +func (m *AccountRange) 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 *AccountRange) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *AccountRange) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Roles) > 0 { + dAtA2 := make([]byte, len(m.Roles)*10) + var j1 int + for _, num := range m.Roles { + for num >= 1<<7 { + dAtA2[j1] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j1++ + } + dAtA2[j1] = uint8(num) + j1++ + } + i -= j1 + copy(dAtA[i:], dAtA2[:j1]) + i = encodeVarintLayer2(dAtA, i, uint64(j1)) + i-- + dAtA[i] = 0x12 + } + if len(m.Addresses) > 0 { + for iNdEx := len(m.Addresses) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Addresses[iNdEx]) + copy(dAtA[i:], m.Addresses[iNdEx]) + i = encodeVarintLayer2(dAtA, i, uint64(len(m.Addresses[iNdEx]))) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *Controllers) 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 *Controllers) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Controllers) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Blacklist.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintLayer2(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + { + size, err := m.Whitelist.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintLayer2(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *BinaryInfo) 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 *BinaryInfo) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *BinaryInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Type) > 0 { + i -= len(m.Type) + copy(dAtA[i:], m.Type) + i = encodeVarintLayer2(dAtA, i, uint64(len(m.Type))) + i-- + dAtA[i] = 0x2a + } + if len(m.Reference) > 0 { + i -= len(m.Reference) + copy(dAtA[i:], m.Reference) + i = encodeVarintLayer2(dAtA, i, uint64(len(m.Reference))) + i-- + dAtA[i] = 0x22 + } + if len(m.Source) > 0 { + i -= len(m.Source) + copy(dAtA[i:], m.Source) + i = encodeVarintLayer2(dAtA, i, uint64(len(m.Source))) + i-- + dAtA[i] = 0x1a + } + if len(m.Hash) > 0 { + i -= len(m.Hash) + copy(dAtA[i:], m.Hash) + i = encodeVarintLayer2(dAtA, i, uint64(len(m.Hash))) + i-- + dAtA[i] = 0x12 + } + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintLayer2(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *LpPoolConfig) 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 *LpPoolConfig) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *LpPoolConfig) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Drip != 0 { + i = encodeVarintLayer2(dAtA, i, uint64(m.Drip)) + i-- + dAtA[i] = 0x18 + } + if len(m.Deposit) > 0 { + i -= len(m.Deposit) + copy(dAtA[i:], m.Deposit) + i = encodeVarintLayer2(dAtA, i, uint64(len(m.Deposit))) + i-- + dAtA[i] = 0x12 + } + { + size := m.Ratio.Size() + i -= size + if _, err := m.Ratio.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintLayer2(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *IssuranceConfig) 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 *IssuranceConfig) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *IssuranceConfig) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Time != 0 { + i = encodeVarintLayer2(dAtA, i, uint64(m.Time)) + i-- + dAtA[i] = 0x20 + } + { + size := m.Postmint.Size() + i -= size + if _, err := m.Postmint.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintLayer2(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + { + size := m.Premint.Size() + i -= size + if _, err := m.Premint.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintLayer2(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.Deposit) > 0 { + i -= len(m.Deposit) + copy(dAtA[i:], m.Deposit) + i = encodeVarintLayer2(dAtA, i, uint64(len(m.Deposit))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *Dapp) 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 *Dapp) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Dapp) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.PostMintPaid { + i-- + if m.PostMintPaid { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0xd0 + } + if m.PremintTime != 0 { + i = encodeVarintLayer2(dAtA, i, uint64(m.PremintTime)) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0xc8 + } + if len(m.TeamReserve) > 0 { + i -= len(m.TeamReserve) + copy(dAtA[i:], m.TeamReserve) + i = encodeVarintLayer2(dAtA, i, uint64(len(m.TeamReserve))) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0xc2 + } + { + size := m.PoolFee.Size() + i -= size + if _, err := m.PoolFee.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintLayer2(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0xba + if m.LiquidationStart != 0 { + i = encodeVarintLayer2(dAtA, i, uint64(m.LiquidationStart)) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0xb0 + } + if m.VoteEnactment != 0 { + i = encodeVarintLayer2(dAtA, i, uint64(m.VoteEnactment)) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0xa8 + } + if m.VotePeriod != 0 { + i = encodeVarintLayer2(dAtA, i, uint64(m.VotePeriod)) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0xa0 + } + if m.VoteQuorum != 0 { + i = encodeVarintLayer2(dAtA, i, uint64(m.VoteQuorum)) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x98 + } + if m.Status != 0 { + i = encodeVarintLayer2(dAtA, i, uint64(m.Status)) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x90 + } + if m.CreationTime != 0 { + i = encodeVarintLayer2(dAtA, i, uint64(m.CreationTime)) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x88 + } + { + size := m.TotalBond.Size() + i -= size + if _, err := m.TotalBond.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintLayer2(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x82 + if m.VerifiersMin != 0 { + i = encodeVarintLayer2(dAtA, i, uint64(m.VerifiersMin)) + i-- + dAtA[i] = 0x78 + } + if m.ExecutorsMax != 0 { + i = encodeVarintLayer2(dAtA, i, uint64(m.ExecutorsMax)) + i-- + dAtA[i] = 0x70 + } + if m.ExecutorsMin != 0 { + i = encodeVarintLayer2(dAtA, i, uint64(m.ExecutorsMin)) + i-- + dAtA[i] = 0x68 + } + if m.UpdateTimeMax != 0 { + i = encodeVarintLayer2(dAtA, i, uint64(m.UpdateTimeMax)) + i-- + dAtA[i] = 0x60 + } + { + size, err := m.Issurance.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintLayer2(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x5a + { + size, err := m.Pool.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintLayer2(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x52 + if len(m.Bin) > 0 { + for iNdEx := len(m.Bin) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Bin[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintLayer2(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x4a + } + } + { + size, err := m.Controllers.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintLayer2(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x42 + if len(m.Docs) > 0 { + i -= len(m.Docs) + copy(dAtA[i:], m.Docs) + i = encodeVarintLayer2(dAtA, i, uint64(len(m.Docs))) + i-- + dAtA[i] = 0x3a + } + if len(m.Social) > 0 { + i -= len(m.Social) + copy(dAtA[i:], m.Social) + i = encodeVarintLayer2(dAtA, i, uint64(len(m.Social))) + i-- + dAtA[i] = 0x32 + } + if len(m.Logo) > 0 { + i -= len(m.Logo) + copy(dAtA[i:], m.Logo) + i = encodeVarintLayer2(dAtA, i, uint64(len(m.Logo))) + i-- + dAtA[i] = 0x2a + } + if len(m.Website) > 0 { + i -= len(m.Website) + copy(dAtA[i:], m.Website) + i = encodeVarintLayer2(dAtA, i, uint64(len(m.Website))) + i-- + dAtA[i] = 0x22 + } + if len(m.Description) > 0 { + i -= len(m.Description) + copy(dAtA[i:], m.Description) + i = encodeVarintLayer2(dAtA, i, uint64(len(m.Description))) + i-- + dAtA[i] = 0x1a + } + if len(m.Denom) > 0 { + i -= len(m.Denom) + copy(dAtA[i:], m.Denom) + i = encodeVarintLayer2(dAtA, i, uint64(len(m.Denom))) + i-- + dAtA[i] = 0x12 + } + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintLayer2(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *UserDappBond) 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 *UserDappBond) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *UserDappBond) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.Bond.Size() + i -= size + if _, err := m.Bond.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintLayer2(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if len(m.DappName) > 0 { + i -= len(m.DappName) + copy(dAtA[i:], m.DappName) + i = encodeVarintLayer2(dAtA, i, uint64(len(m.DappName))) + i-- + dAtA[i] = 0x12 + } + if len(m.User) > 0 { + i -= len(m.User) + copy(dAtA[i:], m.User) + i = encodeVarintLayer2(dAtA, i, uint64(len(m.User))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *DappOperator) 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 *DappOperator) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *DappOperator) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.BondedLpAmount.Size() + i -= size + if _, err := m.BondedLpAmount.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintLayer2(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x62 + if m.MissedSessions != 0 { + i = encodeVarintLayer2(dAtA, i, uint64(m.MissedSessions)) + i-- + dAtA[i] = 0x58 + } + if m.VerifiedSessions != 0 { + i = encodeVarintLayer2(dAtA, i, uint64(m.VerifiedSessions)) + i-- + dAtA[i] = 0x50 + } + if m.Mischance != 0 { + i = encodeVarintLayer2(dAtA, i, uint64(m.Mischance)) + i-- + dAtA[i] = 0x48 + } + if m.Streak != 0 { + i = encodeVarintLayer2(dAtA, i, uint64(m.Streak)) + i-- + dAtA[i] = 0x40 + } + if m.Rank != 0 { + i = encodeVarintLayer2(dAtA, i, uint64(m.Rank)) + i-- + dAtA[i] = 0x38 + } + if m.Status != 0 { + i = encodeVarintLayer2(dAtA, i, uint64(m.Status)) + i-- + dAtA[i] = 0x30 + } + if len(m.Interx) > 0 { + i -= len(m.Interx) + copy(dAtA[i:], m.Interx) + i = encodeVarintLayer2(dAtA, i, uint64(len(m.Interx))) + i-- + dAtA[i] = 0x2a + } + if m.Verifier { + i-- + if m.Verifier { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x20 + } + if m.Executor { + i-- + if m.Executor { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x18 + } + if len(m.Operator) > 0 { + i -= len(m.Operator) + copy(dAtA[i:], m.Operator) + i = encodeVarintLayer2(dAtA, i, uint64(len(m.Operator))) + i-- + dAtA[i] = 0x12 + } + if len(m.DappName) > 0 { + i -= len(m.DappName) + copy(dAtA[i:], m.DappName) + i = encodeVarintLayer2(dAtA, i, uint64(len(m.DappName))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *DappLeaderDenouncement) 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 *DappLeaderDenouncement) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *DappLeaderDenouncement) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Denouncement) > 0 { + i -= len(m.Denouncement) + copy(dAtA[i:], m.Denouncement) + i = encodeVarintLayer2(dAtA, i, uint64(len(m.Denouncement))) + i-- + dAtA[i] = 0x22 + } + if len(m.Sender) > 0 { + i -= len(m.Sender) + copy(dAtA[i:], m.Sender) + i = encodeVarintLayer2(dAtA, i, uint64(len(m.Sender))) + i-- + dAtA[i] = 0x1a + } + if len(m.Leader) > 0 { + i -= len(m.Leader) + copy(dAtA[i:], m.Leader) + i = encodeVarintLayer2(dAtA, i, uint64(len(m.Leader))) + i-- + dAtA[i] = 0x12 + } + if len(m.DappName) > 0 { + i -= len(m.DappName) + copy(dAtA[i:], m.DappName) + i = encodeVarintLayer2(dAtA, i, uint64(len(m.DappName))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *DappSession) 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 *DappSession) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *DappSession) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.OnchainMessages) > 0 { + for iNdEx := len(m.OnchainMessages) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.OnchainMessages[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintLayer2(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 + } + } + if len(m.Gateway) > 0 { + i -= len(m.Gateway) + copy(dAtA[i:], m.Gateway) + i = encodeVarintLayer2(dAtA, i, uint64(len(m.Gateway))) + i-- + dAtA[i] = 0x2a + } + if m.Status != 0 { + i = encodeVarintLayer2(dAtA, i, uint64(m.Status)) + i-- + dAtA[i] = 0x20 + } + if len(m.StatusHash) > 0 { + i -= len(m.StatusHash) + copy(dAtA[i:], m.StatusHash) + i = encodeVarintLayer2(dAtA, i, uint64(len(m.StatusHash))) + i-- + dAtA[i] = 0x1a + } + if m.Start != 0 { + i = encodeVarintLayer2(dAtA, i, uint64(m.Start)) + i-- + dAtA[i] = 0x10 + } + if len(m.Leader) > 0 { + i -= len(m.Leader) + copy(dAtA[i:], m.Leader) + i = encodeVarintLayer2(dAtA, i, uint64(len(m.Leader))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *DappSessionApproval) 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 *DappSessionApproval) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *DappSessionApproval) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.IsApproved { + i-- + if m.IsApproved { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x18 + } + if len(m.Approver) > 0 { + i -= len(m.Approver) + copy(dAtA[i:], m.Approver) + i = encodeVarintLayer2(dAtA, i, uint64(len(m.Approver))) + i-- + dAtA[i] = 0x12 + } + if len(m.DappName) > 0 { + i -= len(m.DappName) + copy(dAtA[i:], m.DappName) + i = encodeVarintLayer2(dAtA, i, uint64(len(m.DappName))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *ExecutionRegistrar) 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 *ExecutionRegistrar) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ExecutionRegistrar) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.NextSession != nil { + { + size, err := m.NextSession.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintLayer2(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + if m.CurrSession != nil { + { + size, err := m.CurrSession.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintLayer2(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + if m.PrevSession != nil { + { + size, err := m.PrevSession.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintLayer2(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.DappName) > 0 { + i -= len(m.DappName) + copy(dAtA[i:], m.DappName) + i = encodeVarintLayer2(dAtA, i, uint64(len(m.DappName))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *BridgeRegistrarHelper) 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 *BridgeRegistrarHelper) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *BridgeRegistrarHelper) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.NextToken != 0 { + i = encodeVarintLayer2(dAtA, i, uint64(m.NextToken)) + i-- + dAtA[i] = 0x18 + } + if m.NextXam != 0 { + i = encodeVarintLayer2(dAtA, i, uint64(m.NextXam)) + i-- + dAtA[i] = 0x10 + } + if m.NextUser != 0 { + i = encodeVarintLayer2(dAtA, i, uint64(m.NextUser)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *BridgeRegistrar) 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 *BridgeRegistrar) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *BridgeRegistrar) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Xams) > 0 { + for iNdEx := len(m.Xams) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Xams[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintLayer2(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + } + if len(m.Tokens) > 0 { + for iNdEx := len(m.Tokens) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Tokens[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintLayer2(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + if len(m.Accounts) > 0 { + for iNdEx := len(m.Accounts) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Accounts[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintLayer2(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if m.Helper != nil { + { + size, err := m.Helper.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintLayer2(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *BridgeBalance) 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 *BridgeBalance) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *BridgeBalance) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.Amount.Size() + i -= size + if _, err := m.Amount.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintLayer2(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if m.BridgeTokenIndex != 0 { + i = encodeVarintLayer2(dAtA, i, uint64(m.BridgeTokenIndex)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *BridgeAccount) 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 *BridgeAccount) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *BridgeAccount) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Balances) > 0 { + for iNdEx := len(m.Balances) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Balances[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintLayer2(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + } + if len(m.DappName) > 0 { + i -= len(m.DappName) + copy(dAtA[i:], m.DappName) + i = encodeVarintLayer2(dAtA, i, uint64(len(m.DappName))) + i-- + dAtA[i] = 0x1a + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintLayer2(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0x12 + } + if m.Index != 0 { + i = encodeVarintLayer2(dAtA, i, uint64(m.Index)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *BridgeToken) 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 *BridgeToken) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *BridgeToken) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Denom) > 0 { + i -= len(m.Denom) + copy(dAtA[i:], m.Denom) + i = encodeVarintLayer2(dAtA, i, uint64(len(m.Denom))) + i-- + dAtA[i] = 0x12 + } + if m.Index != 0 { + i = encodeVarintLayer2(dAtA, i, uint64(m.Index)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *XAMRequest) 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 *XAMRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *XAMRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Xam) > 0 { + i -= len(m.Xam) + copy(dAtA[i:], m.Xam) + i = encodeVarintLayer2(dAtA, i, uint64(len(m.Xam))) + i-- + dAtA[i] = 0x32 + } + if m.DestBeneficiary != 0 { + i = encodeVarintLayer2(dAtA, i, uint64(m.DestBeneficiary)) + i-- + dAtA[i] = 0x28 + } + if m.DestDapp != 0 { + i = encodeVarintLayer2(dAtA, i, uint64(m.DestDapp)) + i-- + dAtA[i] = 0x20 + } + if m.SourceAccount != 0 { + i = encodeVarintLayer2(dAtA, i, uint64(m.SourceAccount)) + i-- + dAtA[i] = 0x18 + } + if m.SourceDapp != 0 { + i = encodeVarintLayer2(dAtA, i, uint64(m.SourceDapp)) + i-- + dAtA[i] = 0x10 + } + if len(m.Amounts) > 0 { + for iNdEx := len(m.Amounts) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Amounts[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintLayer2(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *XAMResponse) 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 *XAMResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *XAMResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Drm != 0 { + i = encodeVarintLayer2(dAtA, i, uint64(m.Drm)) + i-- + dAtA[i] = 0x38 + } + if m.Srm != 0 { + i = encodeVarintLayer2(dAtA, i, uint64(m.Srm)) + i-- + dAtA[i] = 0x30 + } + if m.Irm != 0 { + i = encodeVarintLayer2(dAtA, i, uint64(m.Irm)) + i-- + dAtA[i] = 0x28 + } + if m.Drc != 0 { + i = encodeVarintLayer2(dAtA, i, uint64(m.Drc)) + i-- + dAtA[i] = 0x20 + } + if m.Src != 0 { + i = encodeVarintLayer2(dAtA, i, uint64(m.Src)) + i-- + dAtA[i] = 0x18 + } + if m.Irc != 0 { + i = encodeVarintLayer2(dAtA, i, uint64(m.Irc)) + i-- + dAtA[i] = 0x10 + } + if m.Xid != 0 { + i = encodeVarintLayer2(dAtA, i, uint64(m.Xid)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *XAM) 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 *XAM) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *XAM) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Res.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintLayer2(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + { + size, err := m.Req.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintLayer2(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if m.ReqTime != 0 { + i = encodeVarintLayer2(dAtA, i, uint64(m.ReqTime)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintLayer2(dAtA []byte, offset int, v uint64) int { + offset -= sovLayer2(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *AccountRange) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Addresses) > 0 { + for _, s := range m.Addresses { + l = len(s) + n += 1 + l + sovLayer2(uint64(l)) + } + } + if len(m.Roles) > 0 { + l = 0 + for _, e := range m.Roles { + l += sovLayer2(uint64(e)) + } + n += 1 + sovLayer2(uint64(l)) + l + } + return n +} + +func (m *Controllers) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Whitelist.Size() + n += 1 + l + sovLayer2(uint64(l)) + l = m.Blacklist.Size() + n += 1 + l + sovLayer2(uint64(l)) + return n +} + +func (m *BinaryInfo) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Name) + if l > 0 { + n += 1 + l + sovLayer2(uint64(l)) + } + l = len(m.Hash) + if l > 0 { + n += 1 + l + sovLayer2(uint64(l)) + } + l = len(m.Source) + if l > 0 { + n += 1 + l + sovLayer2(uint64(l)) + } + l = len(m.Reference) + if l > 0 { + n += 1 + l + sovLayer2(uint64(l)) + } + l = len(m.Type) + if l > 0 { + n += 1 + l + sovLayer2(uint64(l)) + } + return n +} + +func (m *LpPoolConfig) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Ratio.Size() + n += 1 + l + sovLayer2(uint64(l)) + l = len(m.Deposit) + if l > 0 { + n += 1 + l + sovLayer2(uint64(l)) + } + if m.Drip != 0 { + n += 1 + sovLayer2(uint64(m.Drip)) + } + return n +} + +func (m *IssuranceConfig) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Deposit) + if l > 0 { + n += 1 + l + sovLayer2(uint64(l)) + } + l = m.Premint.Size() + n += 1 + l + sovLayer2(uint64(l)) + l = m.Postmint.Size() + n += 1 + l + sovLayer2(uint64(l)) + if m.Time != 0 { + n += 1 + sovLayer2(uint64(m.Time)) + } + return n +} + +func (m *Dapp) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Name) + if l > 0 { + n += 1 + l + sovLayer2(uint64(l)) + } + l = len(m.Denom) + if l > 0 { + n += 1 + l + sovLayer2(uint64(l)) + } + l = len(m.Description) + if l > 0 { + n += 1 + l + sovLayer2(uint64(l)) + } + l = len(m.Website) + if l > 0 { + n += 1 + l + sovLayer2(uint64(l)) + } + l = len(m.Logo) + if l > 0 { + n += 1 + l + sovLayer2(uint64(l)) + } + l = len(m.Social) + if l > 0 { + n += 1 + l + sovLayer2(uint64(l)) + } + l = len(m.Docs) + if l > 0 { + n += 1 + l + sovLayer2(uint64(l)) + } + l = m.Controllers.Size() + n += 1 + l + sovLayer2(uint64(l)) + if len(m.Bin) > 0 { + for _, e := range m.Bin { + l = e.Size() + n += 1 + l + sovLayer2(uint64(l)) + } + } + l = m.Pool.Size() + n += 1 + l + sovLayer2(uint64(l)) + l = m.Issurance.Size() + n += 1 + l + sovLayer2(uint64(l)) + if m.UpdateTimeMax != 0 { + n += 1 + sovLayer2(uint64(m.UpdateTimeMax)) + } + if m.ExecutorsMin != 0 { + n += 1 + sovLayer2(uint64(m.ExecutorsMin)) + } + if m.ExecutorsMax != 0 { + n += 1 + sovLayer2(uint64(m.ExecutorsMax)) + } + if m.VerifiersMin != 0 { + n += 1 + sovLayer2(uint64(m.VerifiersMin)) + } + l = m.TotalBond.Size() + n += 2 + l + sovLayer2(uint64(l)) + if m.CreationTime != 0 { + n += 2 + sovLayer2(uint64(m.CreationTime)) + } + if m.Status != 0 { + n += 2 + sovLayer2(uint64(m.Status)) + } + if m.VoteQuorum != 0 { + n += 2 + sovLayer2(uint64(m.VoteQuorum)) + } + if m.VotePeriod != 0 { + n += 2 + sovLayer2(uint64(m.VotePeriod)) + } + if m.VoteEnactment != 0 { + n += 2 + sovLayer2(uint64(m.VoteEnactment)) + } + if m.LiquidationStart != 0 { + n += 2 + sovLayer2(uint64(m.LiquidationStart)) + } + l = m.PoolFee.Size() + n += 2 + l + sovLayer2(uint64(l)) + l = len(m.TeamReserve) + if l > 0 { + n += 2 + l + sovLayer2(uint64(l)) + } + if m.PremintTime != 0 { + n += 2 + sovLayer2(uint64(m.PremintTime)) + } + if m.PostMintPaid { + n += 3 + } + return n +} + +func (m *UserDappBond) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.User) + if l > 0 { + n += 1 + l + sovLayer2(uint64(l)) + } + l = len(m.DappName) + if l > 0 { + n += 1 + l + sovLayer2(uint64(l)) + } + l = m.Bond.Size() + n += 1 + l + sovLayer2(uint64(l)) + return n +} + +func (m *DappOperator) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.DappName) + if l > 0 { + n += 1 + l + sovLayer2(uint64(l)) + } + l = len(m.Operator) + if l > 0 { + n += 1 + l + sovLayer2(uint64(l)) + } + if m.Executor { + n += 2 + } + if m.Verifier { + n += 2 + } + l = len(m.Interx) + if l > 0 { + n += 1 + l + sovLayer2(uint64(l)) + } + if m.Status != 0 { + n += 1 + sovLayer2(uint64(m.Status)) + } + if m.Rank != 0 { + n += 1 + sovLayer2(uint64(m.Rank)) + } + if m.Streak != 0 { + n += 1 + sovLayer2(uint64(m.Streak)) + } + if m.Mischance != 0 { + n += 1 + sovLayer2(uint64(m.Mischance)) + } + if m.VerifiedSessions != 0 { + n += 1 + sovLayer2(uint64(m.VerifiedSessions)) + } + if m.MissedSessions != 0 { + n += 1 + sovLayer2(uint64(m.MissedSessions)) + } + l = m.BondedLpAmount.Size() + n += 1 + l + sovLayer2(uint64(l)) + return n +} + +func (m *DappLeaderDenouncement) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.DappName) + if l > 0 { + n += 1 + l + sovLayer2(uint64(l)) + } + l = len(m.Leader) + if l > 0 { + n += 1 + l + sovLayer2(uint64(l)) + } + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovLayer2(uint64(l)) + } + l = len(m.Denouncement) + if l > 0 { + n += 1 + l + sovLayer2(uint64(l)) + } + return n +} + +func (m *DappSession) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Leader) + if l > 0 { + n += 1 + l + sovLayer2(uint64(l)) + } + if m.Start != 0 { + n += 1 + sovLayer2(uint64(m.Start)) + } + l = len(m.StatusHash) + if l > 0 { + n += 1 + l + sovLayer2(uint64(l)) + } + if m.Status != 0 { + n += 1 + sovLayer2(uint64(m.Status)) + } + l = len(m.Gateway) + if l > 0 { + n += 1 + l + sovLayer2(uint64(l)) + } + if len(m.OnchainMessages) > 0 { + for _, e := range m.OnchainMessages { + l = e.Size() + n += 1 + l + sovLayer2(uint64(l)) + } + } + return n +} + +func (m *DappSessionApproval) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.DappName) + if l > 0 { + n += 1 + l + sovLayer2(uint64(l)) + } + l = len(m.Approver) + if l > 0 { + n += 1 + l + sovLayer2(uint64(l)) + } + if m.IsApproved { + n += 2 + } + return n +} + +func (m *ExecutionRegistrar) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.DappName) + if l > 0 { + n += 1 + l + sovLayer2(uint64(l)) + } + if m.PrevSession != nil { + l = m.PrevSession.Size() + n += 1 + l + sovLayer2(uint64(l)) + } + if m.CurrSession != nil { + l = m.CurrSession.Size() + n += 1 + l + sovLayer2(uint64(l)) + } + if m.NextSession != nil { + l = m.NextSession.Size() + n += 1 + l + sovLayer2(uint64(l)) + } + return n +} + +func (m *BridgeRegistrarHelper) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.NextUser != 0 { + n += 1 + sovLayer2(uint64(m.NextUser)) + } + if m.NextXam != 0 { + n += 1 + sovLayer2(uint64(m.NextXam)) + } + if m.NextToken != 0 { + n += 1 + sovLayer2(uint64(m.NextToken)) + } + return n +} + +func (m *BridgeRegistrar) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Helper != nil { + l = m.Helper.Size() + n += 1 + l + sovLayer2(uint64(l)) + } + if len(m.Accounts) > 0 { + for _, e := range m.Accounts { + l = e.Size() + n += 1 + l + sovLayer2(uint64(l)) + } + } + if len(m.Tokens) > 0 { + for _, e := range m.Tokens { + l = e.Size() + n += 1 + l + sovLayer2(uint64(l)) + } + } + if len(m.Xams) > 0 { + for _, e := range m.Xams { + l = e.Size() + n += 1 + l + sovLayer2(uint64(l)) + } + } + return n +} + +func (m *BridgeBalance) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.BridgeTokenIndex != 0 { + n += 1 + sovLayer2(uint64(m.BridgeTokenIndex)) + } + l = m.Amount.Size() + n += 1 + l + sovLayer2(uint64(l)) + return n +} + +func (m *BridgeAccount) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Index != 0 { + n += 1 + sovLayer2(uint64(m.Index)) + } + l = len(m.Address) + if l > 0 { + n += 1 + l + sovLayer2(uint64(l)) + } + l = len(m.DappName) + if l > 0 { + n += 1 + l + sovLayer2(uint64(l)) + } + if len(m.Balances) > 0 { + for _, e := range m.Balances { + l = e.Size() + n += 1 + l + sovLayer2(uint64(l)) + } + } + return n +} + +func (m *BridgeToken) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Index != 0 { + n += 1 + sovLayer2(uint64(m.Index)) + } + l = len(m.Denom) + if l > 0 { + n += 1 + l + sovLayer2(uint64(l)) + } + return n +} + +func (m *XAMRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Amounts) > 0 { + for _, e := range m.Amounts { + l = e.Size() + n += 1 + l + sovLayer2(uint64(l)) + } + } + if m.SourceDapp != 0 { + n += 1 + sovLayer2(uint64(m.SourceDapp)) + } + if m.SourceAccount != 0 { + n += 1 + sovLayer2(uint64(m.SourceAccount)) + } + if m.DestDapp != 0 { + n += 1 + sovLayer2(uint64(m.DestDapp)) + } + if m.DestBeneficiary != 0 { + n += 1 + sovLayer2(uint64(m.DestBeneficiary)) + } + l = len(m.Xam) + if l > 0 { + n += 1 + l + sovLayer2(uint64(l)) + } + return n +} + +func (m *XAMResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Xid != 0 { + n += 1 + sovLayer2(uint64(m.Xid)) + } + if m.Irc != 0 { + n += 1 + sovLayer2(uint64(m.Irc)) + } + if m.Src != 0 { + n += 1 + sovLayer2(uint64(m.Src)) + } + if m.Drc != 0 { + n += 1 + sovLayer2(uint64(m.Drc)) + } + if m.Irm != 0 { + n += 1 + sovLayer2(uint64(m.Irm)) + } + if m.Srm != 0 { + n += 1 + sovLayer2(uint64(m.Srm)) + } + if m.Drm != 0 { + n += 1 + sovLayer2(uint64(m.Drm)) + } + return n +} + +func (m *XAM) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ReqTime != 0 { + n += 1 + sovLayer2(uint64(m.ReqTime)) + } + l = m.Req.Size() + n += 1 + l + sovLayer2(uint64(l)) + l = m.Res.Size() + n += 1 + l + sovLayer2(uint64(l)) + return n +} + +func sovLayer2(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozLayer2(x uint64) (n int) { + return sovLayer2(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *AccountRange) 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 ErrIntOverflowLayer2 + } + 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: AccountRange: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: AccountRange: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Addresses", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + 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 ErrInvalidLengthLayer2 + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLayer2 + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Addresses = append(m.Addresses, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 2: + if wireType == 0 { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Roles = append(m.Roles, v) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return ErrInvalidLengthLayer2 + } + postIndex := iNdEx + packedLen + if postIndex < 0 { + return ErrInvalidLengthLayer2 + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var elementCount int + var count int + for _, integer := range dAtA[iNdEx:postIndex] { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Roles) == 0 { + m.Roles = make([]uint64, 0, elementCount) + } + for iNdEx < postIndex { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Roles = append(m.Roles, v) + } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field Roles", wireType) + } + default: + iNdEx = preIndex + skippy, err := skipLayer2(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthLayer2 + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Controllers) 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 ErrIntOverflowLayer2 + } + 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: Controllers: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Controllers: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Whitelist", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthLayer2 + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthLayer2 + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Whitelist.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Blacklist", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthLayer2 + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthLayer2 + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Blacklist.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipLayer2(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthLayer2 + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *BinaryInfo) 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 ErrIntOverflowLayer2 + } + 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: BinaryInfo: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: BinaryInfo: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + 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 ErrInvalidLengthLayer2 + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLayer2 + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Hash", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + 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 ErrInvalidLengthLayer2 + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLayer2 + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Hash = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Source", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + 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 ErrInvalidLengthLayer2 + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLayer2 + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Source = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Reference", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + 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 ErrInvalidLengthLayer2 + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLayer2 + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Reference = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Type", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + 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 ErrInvalidLengthLayer2 + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLayer2 + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Type = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipLayer2(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthLayer2 + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *LpPoolConfig) 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 ErrIntOverflowLayer2 + } + 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: LpPoolConfig: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: LpPoolConfig: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Ratio", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + 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 ErrInvalidLengthLayer2 + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLayer2 + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Ratio.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Deposit", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + 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 ErrInvalidLengthLayer2 + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLayer2 + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Deposit = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Drip", wireType) + } + m.Drip = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Drip |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipLayer2(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthLayer2 + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *IssuranceConfig) 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 ErrIntOverflowLayer2 + } + 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: IssuranceConfig: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: IssuranceConfig: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Deposit", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + 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 ErrInvalidLengthLayer2 + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLayer2 + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Deposit = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Premint", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + 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 ErrInvalidLengthLayer2 + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLayer2 + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Premint.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Postmint", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + 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 ErrInvalidLengthLayer2 + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLayer2 + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Postmint.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Time", wireType) + } + m.Time = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Time |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipLayer2(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthLayer2 + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Dapp) 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 ErrIntOverflowLayer2 + } + 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: Dapp: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Dapp: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + 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 ErrInvalidLengthLayer2 + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLayer2 + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Denom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + 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 ErrInvalidLengthLayer2 + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLayer2 + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Denom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + 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 ErrInvalidLengthLayer2 + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLayer2 + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Description = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Website", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + 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 ErrInvalidLengthLayer2 + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLayer2 + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Website = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Logo", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + 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 ErrInvalidLengthLayer2 + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLayer2 + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Logo = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Social", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + 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 ErrInvalidLengthLayer2 + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLayer2 + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Social = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Docs", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + 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 ErrInvalidLengthLayer2 + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLayer2 + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Docs = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Controllers", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthLayer2 + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthLayer2 + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Controllers.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 9: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Bin", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthLayer2 + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthLayer2 + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Bin = append(m.Bin, BinaryInfo{}) + if err := m.Bin[len(m.Bin)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 10: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pool", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthLayer2 + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthLayer2 + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Pool.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 11: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Issurance", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthLayer2 + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthLayer2 + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Issurance.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 12: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field UpdateTimeMax", wireType) + } + m.UpdateTimeMax = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.UpdateTimeMax |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 13: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ExecutorsMin", wireType) + } + m.ExecutorsMin = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ExecutorsMin |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 14: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ExecutorsMax", wireType) + } + m.ExecutorsMax = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ExecutorsMax |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 15: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field VerifiersMin", wireType) + } + m.VerifiersMin = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.VerifiersMin |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 16: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TotalBond", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + 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 ErrInvalidLengthLayer2 + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLayer2 + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.TotalBond.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 17: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CreationTime", wireType) + } + m.CreationTime = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CreationTime |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 18: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) + } + m.Status = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Status |= DappStatus(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 19: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field VoteQuorum", wireType) + } + m.VoteQuorum = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.VoteQuorum |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 20: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field VotePeriod", wireType) + } + m.VotePeriod = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.VotePeriod |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 21: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field VoteEnactment", wireType) + } + m.VoteEnactment = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.VoteEnactment |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 22: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field LiquidationStart", wireType) + } + m.LiquidationStart = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.LiquidationStart |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 23: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PoolFee", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + 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 ErrInvalidLengthLayer2 + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLayer2 + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.PoolFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 24: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TeamReserve", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + 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 ErrInvalidLengthLayer2 + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLayer2 + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.TeamReserve = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 25: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PremintTime", wireType) + } + m.PremintTime = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PremintTime |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 26: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PostMintPaid", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.PostMintPaid = bool(v != 0) + default: + iNdEx = preIndex + skippy, err := skipLayer2(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthLayer2 + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *UserDappBond) 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 ErrIntOverflowLayer2 + } + 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: UserDappBond: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: UserDappBond: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field User", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + 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 ErrInvalidLengthLayer2 + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLayer2 + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.User = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DappName", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + 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 ErrInvalidLengthLayer2 + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLayer2 + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DappName = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Bond", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + 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 ErrInvalidLengthLayer2 + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLayer2 + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Bond.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipLayer2(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthLayer2 + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *DappOperator) 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 ErrIntOverflowLayer2 + } + 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: DappOperator: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DappOperator: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DappName", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + 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 ErrInvalidLengthLayer2 + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLayer2 + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DappName = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Operator", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + 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 ErrInvalidLengthLayer2 + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLayer2 + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Operator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Executor", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Executor = bool(v != 0) + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Verifier", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Verifier = bool(v != 0) + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Interx", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + 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 ErrInvalidLengthLayer2 + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLayer2 + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Interx = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) + } + m.Status = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Status |= OperatorStatus(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 7: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Rank", wireType) + } + m.Rank = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Rank |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 8: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Streak", wireType) + } + m.Streak = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Streak |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 9: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Mischance", wireType) + } + m.Mischance = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Mischance |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 10: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field VerifiedSessions", wireType) + } + m.VerifiedSessions = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.VerifiedSessions |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 11: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MissedSessions", wireType) + } + m.MissedSessions = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MissedSessions |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 12: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BondedLpAmount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + 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 ErrInvalidLengthLayer2 + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLayer2 + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.BondedLpAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipLayer2(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthLayer2 + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *DappLeaderDenouncement) 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 ErrIntOverflowLayer2 + } + 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: DappLeaderDenouncement: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DappLeaderDenouncement: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DappName", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + 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 ErrInvalidLengthLayer2 + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLayer2 + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DappName = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Leader", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + 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 ErrInvalidLengthLayer2 + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLayer2 + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Leader = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + 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 ErrIntOverflowLayer2 + } + 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 ErrInvalidLengthLayer2 + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLayer2 + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Sender = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Denouncement", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + 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 ErrInvalidLengthLayer2 + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLayer2 + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Denouncement = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipLayer2(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthLayer2 + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *DappSession) 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 ErrIntOverflowLayer2 + } + 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: DappSession: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DappSession: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Leader", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + 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 ErrInvalidLengthLayer2 + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLayer2 + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Leader = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Start", wireType) + } + m.Start = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Start |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StatusHash", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + 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 ErrInvalidLengthLayer2 + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLayer2 + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.StatusHash = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) + } + m.Status = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Status |= SessionStatus(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Gateway", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + 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 ErrInvalidLengthLayer2 + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLayer2 + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Gateway = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OnchainMessages", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthLayer2 + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthLayer2 + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.OnchainMessages = append(m.OnchainMessages, &types.Any{}) + if err := m.OnchainMessages[len(m.OnchainMessages)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipLayer2(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthLayer2 + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *DappSessionApproval) 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 ErrIntOverflowLayer2 + } + 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: DappSessionApproval: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DappSessionApproval: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DappName", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + 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 ErrInvalidLengthLayer2 + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLayer2 + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DappName = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Approver", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + 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 ErrInvalidLengthLayer2 + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLayer2 + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Approver = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field IsApproved", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.IsApproved = bool(v != 0) + default: + iNdEx = preIndex + skippy, err := skipLayer2(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthLayer2 + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ExecutionRegistrar) 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 ErrIntOverflowLayer2 + } + 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: ExecutionRegistrar: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ExecutionRegistrar: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DappName", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + 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 ErrInvalidLengthLayer2 + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLayer2 + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DappName = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PrevSession", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthLayer2 + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthLayer2 + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.PrevSession == nil { + m.PrevSession = &DappSession{} + } + if err := m.PrevSession.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CurrSession", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthLayer2 + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthLayer2 + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.CurrSession == nil { + m.CurrSession = &DappSession{} + } + if err := m.CurrSession.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NextSession", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthLayer2 + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthLayer2 + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.NextSession == nil { + m.NextSession = &DappSession{} + } + if err := m.NextSession.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipLayer2(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthLayer2 + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *BridgeRegistrarHelper) 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 ErrIntOverflowLayer2 + } + 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: BridgeRegistrarHelper: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: BridgeRegistrarHelper: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field NextUser", wireType) + } + m.NextUser = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.NextUser |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field NextXam", wireType) + } + m.NextXam = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.NextXam |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field NextToken", wireType) + } + m.NextToken = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.NextToken |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipLayer2(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthLayer2 + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *BridgeRegistrar) 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 ErrIntOverflowLayer2 + } + 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: BridgeRegistrar: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: BridgeRegistrar: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Helper", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthLayer2 + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthLayer2 + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Helper == nil { + m.Helper = &BridgeRegistrarHelper{} + } + if err := m.Helper.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Accounts", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthLayer2 + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthLayer2 + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Accounts = append(m.Accounts, BridgeAccount{}) + if err := m.Accounts[len(m.Accounts)-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 Tokens", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthLayer2 + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthLayer2 + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Tokens = append(m.Tokens, BridgeToken{}) + if err := m.Tokens[len(m.Tokens)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Xams", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthLayer2 + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthLayer2 + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Xams = append(m.Xams, XAM{}) + if err := m.Xams[len(m.Xams)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipLayer2(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthLayer2 + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *BridgeBalance) 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 ErrIntOverflowLayer2 + } + 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: BridgeBalance: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: BridgeBalance: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field BridgeTokenIndex", wireType) + } + m.BridgeTokenIndex = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.BridgeTokenIndex |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + 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 ErrInvalidLengthLayer2 + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLayer2 + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Amount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipLayer2(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthLayer2 + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *BridgeAccount) 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 ErrIntOverflowLayer2 + } + 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: BridgeAccount: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: BridgeAccount: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Index", wireType) + } + m.Index = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Index |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + 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 ErrInvalidLengthLayer2 + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLayer2 + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DappName", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + 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 ErrInvalidLengthLayer2 + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLayer2 + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DappName = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Balances", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthLayer2 + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthLayer2 + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Balances = append(m.Balances, BridgeBalance{}) + if err := m.Balances[len(m.Balances)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipLayer2(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthLayer2 + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *BridgeToken) 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 ErrIntOverflowLayer2 + } + 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: BridgeToken: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: BridgeToken: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Index", wireType) + } + m.Index = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Index |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Denom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + 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 ErrInvalidLengthLayer2 + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLayer2 + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Denom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipLayer2(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthLayer2 + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *XAMRequest) 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 ErrIntOverflowLayer2 + } + 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: XAMRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: XAMRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Amounts", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthLayer2 + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthLayer2 + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Amounts = append(m.Amounts, BridgeBalance{}) + if err := m.Amounts[len(m.Amounts)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field SourceDapp", wireType) + } + m.SourceDapp = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.SourceDapp |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field SourceAccount", wireType) + } + m.SourceAccount = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.SourceAccount |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field DestDapp", wireType) + } + m.DestDapp = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.DestDapp |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field DestBeneficiary", wireType) + } + m.DestBeneficiary = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.DestBeneficiary |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Xam", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + 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 ErrInvalidLengthLayer2 + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLayer2 + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Xam = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipLayer2(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthLayer2 + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *XAMResponse) 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 ErrIntOverflowLayer2 + } + 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: XAMResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: XAMResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Xid", wireType) + } + m.Xid = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Xid |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Irc", wireType) + } + m.Irc = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Irc |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Src", wireType) + } + m.Src = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Src |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Drc", wireType) + } + m.Drc = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Drc |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Irm", wireType) + } + m.Irm = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Irm |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Srm", wireType) + } + m.Srm = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Srm |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 7: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Drm", wireType) + } + m.Drm = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Drm |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipLayer2(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthLayer2 + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *XAM) 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 ErrIntOverflowLayer2 + } + 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: XAM: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: XAM: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ReqTime", wireType) + } + m.ReqTime = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ReqTime |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Req", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthLayer2 + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthLayer2 + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Req.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Res", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLayer2 + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthLayer2 + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthLayer2 + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Res.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipLayer2(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthLayer2 + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipLayer2(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, ErrIntOverflowLayer2 + } + 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, ErrIntOverflowLayer2 + } + 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, ErrIntOverflowLayer2 + } + 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, ErrInvalidLengthLayer2 + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupLayer2 + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthLayer2 + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthLayer2 = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowLayer2 = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupLayer2 = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/layer2/types/mint.pb.go b/x/layer2/types/mint.pb.go new file mode 100644 index 000000000..5ff4ec43c --- /dev/null +++ b/x/layer2/types/mint.pb.go @@ -0,0 +1,1126 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: kira/layer2/mint.proto + +package types + +import ( + fmt "fmt" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + _ "google.golang.org/protobuf/types/known/timestamppb" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type TokenInfo struct { + TokenType string `protobuf:"bytes,1,opt,name=token_type,json=tokenType,proto3" json:"token_type,omitempty"` + Denom string `protobuf:"bytes,2,opt,name=denom,proto3" json:"denom,omitempty"` + Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"` + Symbol string `protobuf:"bytes,4,opt,name=symbol,proto3" json:"symbol,omitempty"` + Icon string `protobuf:"bytes,5,opt,name=icon,proto3" json:"icon,omitempty"` + Description string `protobuf:"bytes,6,opt,name=description,proto3" json:"description,omitempty"` + Website string `protobuf:"bytes,7,opt,name=website,proto3" json:"website,omitempty"` + Social string `protobuf:"bytes,8,opt,name=social,proto3" json:"social,omitempty"` + Decimals uint64 `protobuf:"varint,9,opt,name=decimals,proto3" json:"decimals,omitempty"` + Cap github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,10,opt,name=cap,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"cap"` + Supply github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,11,opt,name=supply,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"supply"` + Holders uint64 `protobuf:"varint,12,opt,name=holders,proto3" json:"holders,omitempty"` + Fee github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,13,opt,name=fee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"fee"` + Owner string `protobuf:"bytes,14,opt,name=owner,proto3" json:"owner,omitempty"` + Metadata string `protobuf:"bytes,15,opt,name=metadata,proto3" json:"metadata,omitempty"` + Hash string `protobuf:"bytes,16,opt,name=hash,proto3" json:"hash,omitempty"` +} + +func (m *TokenInfo) Reset() { *m = TokenInfo{} } +func (m *TokenInfo) String() string { return proto.CompactTextString(m) } +func (*TokenInfo) ProtoMessage() {} +func (*TokenInfo) Descriptor() ([]byte, []int) { + return fileDescriptor_066d1ba7ae573fa3, []int{0} +} +func (m *TokenInfo) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *TokenInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_TokenInfo.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 *TokenInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_TokenInfo.Merge(m, src) +} +func (m *TokenInfo) XXX_Size() int { + return m.Size() +} +func (m *TokenInfo) XXX_DiscardUnknown() { + xxx_messageInfo_TokenInfo.DiscardUnknown(m) +} + +var xxx_messageInfo_TokenInfo proto.InternalMessageInfo + +func (m *TokenInfo) GetTokenType() string { + if m != nil { + return m.TokenType + } + return "" +} + +func (m *TokenInfo) GetDenom() string { + if m != nil { + return m.Denom + } + return "" +} + +func (m *TokenInfo) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *TokenInfo) GetSymbol() string { + if m != nil { + return m.Symbol + } + return "" +} + +func (m *TokenInfo) GetIcon() string { + if m != nil { + return m.Icon + } + return "" +} + +func (m *TokenInfo) GetDescription() string { + if m != nil { + return m.Description + } + return "" +} + +func (m *TokenInfo) GetWebsite() string { + if m != nil { + return m.Website + } + return "" +} + +func (m *TokenInfo) GetSocial() string { + if m != nil { + return m.Social + } + return "" +} + +func (m *TokenInfo) GetDecimals() uint64 { + if m != nil { + return m.Decimals + } + return 0 +} + +func (m *TokenInfo) GetHolders() uint64 { + if m != nil { + return m.Holders + } + return 0 +} + +func (m *TokenInfo) GetOwner() string { + if m != nil { + return m.Owner + } + return "" +} + +func (m *TokenInfo) GetMetadata() string { + if m != nil { + return m.Metadata + } + return "" +} + +func (m *TokenInfo) GetHash() string { + if m != nil { + return m.Hash + } + return "" +} + +func init() { + proto.RegisterType((*TokenInfo)(nil), "kira.layer2.TokenInfo") +} + +func init() { proto.RegisterFile("kira/layer2/mint.proto", fileDescriptor_066d1ba7ae573fa3) } + +var fileDescriptor_066d1ba7ae573fa3 = []byte{ + // 429 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x92, 0xcf, 0x6a, 0xdb, 0x40, + 0x10, 0xc6, 0xad, 0xc6, 0x71, 0xe2, 0x75, 0xff, 0xb1, 0x84, 0x30, 0x18, 0x2a, 0x9b, 0x1e, 0x8a, + 0x2f, 0xf5, 0x42, 0xfb, 0x02, 0x25, 0x85, 0x40, 0xe8, 0xcd, 0xe4, 0xd4, 0x4b, 0x59, 0x49, 0x63, + 0x79, 0xb1, 0x76, 0x47, 0x68, 0xd7, 0xa4, 0x7a, 0x8b, 0x3e, 0x40, 0x1f, 0xa0, 0x8f, 0x92, 0x63, + 0x8e, 0xa5, 0x87, 0x50, 0xec, 0x17, 0x09, 0x3b, 0xb2, 0x43, 0xce, 0x39, 0x69, 0x7e, 0xdf, 0xcc, + 0x68, 0xbf, 0xdd, 0x19, 0x71, 0xbe, 0x36, 0x8d, 0x56, 0x95, 0x6e, 0xb1, 0xf9, 0xa4, 0xac, 0x71, + 0x61, 0x5e, 0x37, 0x14, 0x48, 0x8e, 0xa2, 0x3e, 0xef, 0xf4, 0xf1, 0x59, 0x49, 0x25, 0xb1, 0xae, + 0x62, 0xd4, 0x95, 0x8c, 0x27, 0x25, 0x51, 0x59, 0xa1, 0x62, 0xca, 0x36, 0x4b, 0x15, 0x8c, 0x45, + 0x1f, 0xb4, 0xad, 0xbb, 0x82, 0xf7, 0xbf, 0xfb, 0x62, 0x78, 0x4d, 0x6b, 0x74, 0x57, 0x6e, 0x49, + 0xf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 0x57, 0xcf, 0xf3, 0xb8, 0x44, 0x9e, 0x15, 0xdd, 0x38, + 0x6c, 0xe0, 0x75, 0x37, 0x2b, 0x86, 0xf8, 0x2e, 0x16, 0x83, 0x2e, 0x74, 0xd0, 0xf0, 0x86, 0x13, + 0x8f, 0x1c, 0x67, 0xb3, 0xd2, 0x7e, 0x05, 0x6f, 0xbb, 0xd9, 0xc4, 0xf8, 0xe2, 0xf2, 0xcf, 0x36, + 0x4d, 0x6e, 0xb7, 0x69, 0x72, 0xb7, 0x4d, 0x93, 0xff, 0xdb, 0x34, 0xf9, 0xb5, 0x4b, 0x7b, 0x77, + 0xbb, 0xb4, 0xf7, 0x77, 0x97, 0xf6, 0xbe, 0xcf, 0x9e, 0x18, 0xfa, 0x66, 0x1a, 0xfd, 0x95, 0x1a, + 0x54, 0x1e, 0xd7, 0xda, 0xa8, 0x9f, 0x87, 0x7d, 0x65, 0x5b, 0xd9, 0x80, 0xb7, 0xed, 0xf3, 0x43, + 0x00, 0x00, 0x00, 0xff, 0xff, 0x04, 0x35, 0x96, 0x68, 0xcb, 0x02, 0x00, 0x00, +} + +func (this *TokenInfo) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*TokenInfo) + if !ok { + that2, ok := that.(TokenInfo) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.TokenType != that1.TokenType { + return false + } + if this.Denom != that1.Denom { + return false + } + if this.Name != that1.Name { + return false + } + if this.Symbol != that1.Symbol { + return false + } + if this.Icon != that1.Icon { + return false + } + if this.Description != that1.Description { + return false + } + if this.Website != that1.Website { + return false + } + if this.Social != that1.Social { + return false + } + if this.Decimals != that1.Decimals { + return false + } + if !this.Cap.Equal(that1.Cap) { + return false + } + if !this.Supply.Equal(that1.Supply) { + return false + } + if this.Holders != that1.Holders { + return false + } + if !this.Fee.Equal(that1.Fee) { + return false + } + if this.Owner != that1.Owner { + return false + } + if this.Metadata != that1.Metadata { + return false + } + if this.Hash != that1.Hash { + return false + } + return true +} +func (m *TokenInfo) 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 *TokenInfo) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TokenInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Hash) > 0 { + i -= len(m.Hash) + copy(dAtA[i:], m.Hash) + i = encodeVarintMint(dAtA, i, uint64(len(m.Hash))) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x82 + } + if len(m.Metadata) > 0 { + i -= len(m.Metadata) + copy(dAtA[i:], m.Metadata) + i = encodeVarintMint(dAtA, i, uint64(len(m.Metadata))) + i-- + dAtA[i] = 0x7a + } + if len(m.Owner) > 0 { + i -= len(m.Owner) + copy(dAtA[i:], m.Owner) + i = encodeVarintMint(dAtA, i, uint64(len(m.Owner))) + i-- + dAtA[i] = 0x72 + } + { + size := m.Fee.Size() + i -= size + if _, err := m.Fee.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintMint(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x6a + if m.Holders != 0 { + i = encodeVarintMint(dAtA, i, uint64(m.Holders)) + i-- + dAtA[i] = 0x60 + } + { + size := m.Supply.Size() + i -= size + if _, err := m.Supply.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintMint(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x5a + { + size := m.Cap.Size() + i -= size + if _, err := m.Cap.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintMint(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x52 + if m.Decimals != 0 { + i = encodeVarintMint(dAtA, i, uint64(m.Decimals)) + i-- + dAtA[i] = 0x48 + } + if len(m.Social) > 0 { + i -= len(m.Social) + copy(dAtA[i:], m.Social) + i = encodeVarintMint(dAtA, i, uint64(len(m.Social))) + i-- + dAtA[i] = 0x42 + } + if len(m.Website) > 0 { + i -= len(m.Website) + copy(dAtA[i:], m.Website) + i = encodeVarintMint(dAtA, i, uint64(len(m.Website))) + i-- + dAtA[i] = 0x3a + } + if len(m.Description) > 0 { + i -= len(m.Description) + copy(dAtA[i:], m.Description) + i = encodeVarintMint(dAtA, i, uint64(len(m.Description))) + i-- + dAtA[i] = 0x32 + } + if len(m.Icon) > 0 { + i -= len(m.Icon) + copy(dAtA[i:], m.Icon) + i = encodeVarintMint(dAtA, i, uint64(len(m.Icon))) + i-- + dAtA[i] = 0x2a + } + if len(m.Symbol) > 0 { + i -= len(m.Symbol) + copy(dAtA[i:], m.Symbol) + i = encodeVarintMint(dAtA, i, uint64(len(m.Symbol))) + i-- + dAtA[i] = 0x22 + } + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintMint(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0x1a + } + if len(m.Denom) > 0 { + i -= len(m.Denom) + copy(dAtA[i:], m.Denom) + i = encodeVarintMint(dAtA, i, uint64(len(m.Denom))) + i-- + dAtA[i] = 0x12 + } + if len(m.TokenType) > 0 { + i -= len(m.TokenType) + copy(dAtA[i:], m.TokenType) + i = encodeVarintMint(dAtA, i, uint64(len(m.TokenType))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintMint(dAtA []byte, offset int, v uint64) int { + offset -= sovMint(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *TokenInfo) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.TokenType) + if l > 0 { + n += 1 + l + sovMint(uint64(l)) + } + l = len(m.Denom) + if l > 0 { + n += 1 + l + sovMint(uint64(l)) + } + l = len(m.Name) + if l > 0 { + n += 1 + l + sovMint(uint64(l)) + } + l = len(m.Symbol) + if l > 0 { + n += 1 + l + sovMint(uint64(l)) + } + l = len(m.Icon) + if l > 0 { + n += 1 + l + sovMint(uint64(l)) + } + l = len(m.Description) + if l > 0 { + n += 1 + l + sovMint(uint64(l)) + } + l = len(m.Website) + if l > 0 { + n += 1 + l + sovMint(uint64(l)) + } + l = len(m.Social) + if l > 0 { + n += 1 + l + sovMint(uint64(l)) + } + if m.Decimals != 0 { + n += 1 + sovMint(uint64(m.Decimals)) + } + l = m.Cap.Size() + n += 1 + l + sovMint(uint64(l)) + l = m.Supply.Size() + n += 1 + l + sovMint(uint64(l)) + if m.Holders != 0 { + n += 1 + sovMint(uint64(m.Holders)) + } + l = m.Fee.Size() + n += 1 + l + sovMint(uint64(l)) + l = len(m.Owner) + if l > 0 { + n += 1 + l + sovMint(uint64(l)) + } + l = len(m.Metadata) + if l > 0 { + n += 1 + l + sovMint(uint64(l)) + } + l = len(m.Hash) + if l > 0 { + n += 2 + l + sovMint(uint64(l)) + } + return n +} + +func sovMint(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozMint(x uint64) (n int) { + return sovMint(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *TokenInfo) 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 ErrIntOverflowMint + } + 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: TokenInfo: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: TokenInfo: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TokenType", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMint + } + 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 ErrInvalidLengthMint + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMint + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.TokenType = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Denom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMint + } + 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 ErrInvalidLengthMint + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMint + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Denom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMint + } + 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 ErrInvalidLengthMint + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMint + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Symbol", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMint + } + 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 ErrInvalidLengthMint + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMint + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Symbol = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Icon", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMint + } + 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 ErrInvalidLengthMint + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMint + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Icon = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMint + } + 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 ErrInvalidLengthMint + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMint + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Description = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Website", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMint + } + 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 ErrInvalidLengthMint + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMint + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Website = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Social", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMint + } + 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 ErrInvalidLengthMint + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMint + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Social = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 9: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Decimals", wireType) + } + m.Decimals = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMint + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Decimals |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 10: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Cap", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMint + } + 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 ErrInvalidLengthMint + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMint + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Cap.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 11: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Supply", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMint + } + 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 ErrInvalidLengthMint + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMint + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Supply.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 12: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Holders", wireType) + } + m.Holders = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMint + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Holders |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 13: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Fee", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMint + } + 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 ErrInvalidLengthMint + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMint + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Fee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 14: + 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 ErrIntOverflowMint + } + 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 ErrInvalidLengthMint + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMint + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Owner = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 15: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMint + } + 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 ErrInvalidLengthMint + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMint + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Metadata = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 16: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Hash", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMint + } + 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 ErrInvalidLengthMint + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMint + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Hash = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipMint(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthMint + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipMint(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, ErrIntOverflowMint + } + 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, ErrIntOverflowMint + } + 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, ErrIntOverflowMint + } + 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, ErrInvalidLengthMint + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupMint + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthMint + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthMint = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowMint = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupMint = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/layer2/types/msgs.go b/x/layer2/types/msgs.go new file mode 100644 index 000000000..d4baf5b10 --- /dev/null +++ b/x/layer2/types/msgs.go @@ -0,0 +1,662 @@ +package types + +import ( + "github.com/KiraCore/sekai/types" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +var _ sdk.Msg = &MsgCreateDappProposal{} + +func (m *MsgCreateDappProposal) Route() string { + return ModuleName +} +func (m *MsgCreateDappProposal) Type() string { + return types.MsgTypeCreateDappProposal +} +func (m *MsgCreateDappProposal) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(m.Sender) + if err != nil { + return err + } + + return nil +} +func (m *MsgCreateDappProposal) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(m) + return sdk.MustSortJSON(bz) +} +func (m *MsgCreateDappProposal) GetSigners() []sdk.AccAddress { + addr, err := sdk.AccAddressFromBech32(m.Sender) + if err != nil { + panic(err) + } + return []sdk.AccAddress{addr} +} + +var _ sdk.Msg = &MsgBondDappProposal{} + +func (m *MsgBondDappProposal) Route() string { + return ModuleName +} +func (m *MsgBondDappProposal) Type() string { + return types.MsgTypeBondDappProposal +} +func (m *MsgBondDappProposal) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(m.Sender) + if err != nil { + return err + } + + return nil +} +func (m *MsgBondDappProposal) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(m) + return sdk.MustSortJSON(bz) +} +func (m *MsgBondDappProposal) GetSigners() []sdk.AccAddress { + addr, err := sdk.AccAddressFromBech32(m.Sender) + if err != nil { + panic(err) + } + return []sdk.AccAddress{addr} +} + +var _ sdk.Msg = &MsgReclaimDappBondProposal{} + +func (m *MsgReclaimDappBondProposal) Route() string { + return ModuleName +} +func (m *MsgReclaimDappBondProposal) Type() string { + return types.MsgTypeReclaimDappBondProposal +} +func (m *MsgReclaimDappBondProposal) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(m.Sender) + if err != nil { + return err + } + + return nil +} +func (m *MsgReclaimDappBondProposal) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(m) + return sdk.MustSortJSON(bz) +} +func (m MsgReclaimDappBondProposal) GetSigners() []sdk.AccAddress { + addr, err := sdk.AccAddressFromBech32(m.Sender) + if err != nil { + panic(err) + } + return []sdk.AccAddress{addr} +} + +var _ sdk.Msg = &MsgJoinDappVerifierWithBond{} + +func (m *MsgJoinDappVerifierWithBond) Route() string { + return ModuleName +} +func (m *MsgJoinDappVerifierWithBond) Type() string { + return types.MsgTypeJoinDappVerifierWithBond +} +func (m *MsgJoinDappVerifierWithBond) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(m.Sender) + if err != nil { + return err + } + + return nil +} +func (m *MsgJoinDappVerifierWithBond) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(m) + return sdk.MustSortJSON(bz) +} +func (m MsgJoinDappVerifierWithBond) GetSigners() []sdk.AccAddress { + addr, err := sdk.AccAddressFromBech32(m.Sender) + if err != nil { + panic(err) + } + return []sdk.AccAddress{addr} +} + +var _ sdk.Msg = &MsgExitDapp{} + +func (m *MsgExitDapp) Route() string { + return ModuleName +} +func (m *MsgExitDapp) Type() string { + return types.MsgTypeExitDapp +} +func (m *MsgExitDapp) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(m.Sender) + if err != nil { + return err + } + + return nil +} +func (m *MsgExitDapp) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(m) + return sdk.MustSortJSON(bz) +} +func (m *MsgExitDapp) GetSigners() []sdk.AccAddress { + addr, err := sdk.AccAddressFromBech32(m.Sender) + if err != nil { + panic(err) + } + return []sdk.AccAddress{addr} +} + +var _ sdk.Msg = &MsgRedeemDappPoolTx{} + +func (m *MsgRedeemDappPoolTx) Route() string { + return ModuleName +} +func (m *MsgRedeemDappPoolTx) Type() string { + return types.MsgTypeRedeemDappPoolTx +} +func (m *MsgRedeemDappPoolTx) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(m.Sender) + if err != nil { + return err + } + + return nil +} +func (m *MsgRedeemDappPoolTx) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(m) + return sdk.MustSortJSON(bz) +} +func (m *MsgRedeemDappPoolTx) GetSigners() []sdk.AccAddress { + addr, err := sdk.AccAddressFromBech32(m.Sender) + if err != nil { + panic(err) + } + return []sdk.AccAddress{addr} +} + +var _ sdk.Msg = &MsgSwapDappPoolTx{} + +func (m *MsgSwapDappPoolTx) Route() string { + return ModuleName +} +func (m *MsgSwapDappPoolTx) Type() string { + return types.MsgTypeSwapDappPoolTx +} +func (m *MsgSwapDappPoolTx) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(m.Sender) + if err != nil { + return err + } + + return nil +} +func (m *MsgSwapDappPoolTx) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(m) + return sdk.MustSortJSON(bz) +} +func (m *MsgSwapDappPoolTx) GetSigners() []sdk.AccAddress { + addr, err := sdk.AccAddressFromBech32(m.Sender) + if err != nil { + panic(err) + } + return []sdk.AccAddress{addr} +} + +var _ sdk.Msg = &MsgConvertDappPoolTx{} + +func (m *MsgConvertDappPoolTx) Route() string { + return ModuleName +} +func (m *MsgConvertDappPoolTx) Type() string { + return types.MsgTypeConvertDappPoolTx +} +func (m *MsgConvertDappPoolTx) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(m.Sender) + if err != nil { + return err + } + + return nil +} +func (m *MsgConvertDappPoolTx) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(m) + return sdk.MustSortJSON(bz) +} +func (m *MsgConvertDappPoolTx) GetSigners() []sdk.AccAddress { + addr, err := sdk.AccAddressFromBech32(m.Sender) + if err != nil { + panic(err) + } + return []sdk.AccAddress{addr} +} + +var _ sdk.Msg = &MsgPauseDappTx{} + +func (m *MsgPauseDappTx) Route() string { + return ModuleName +} +func (m *MsgPauseDappTx) Type() string { + return types.MsgTypePauseDappTx +} +func (m *MsgPauseDappTx) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(m.Sender) + if err != nil { + return err + } + + return nil +} +func (m *MsgPauseDappTx) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(m) + return sdk.MustSortJSON(bz) +} +func (m *MsgPauseDappTx) GetSigners() []sdk.AccAddress { + addr, err := sdk.AccAddressFromBech32(m.Sender) + if err != nil { + panic(err) + } + return []sdk.AccAddress{addr} +} + +var _ sdk.Msg = &MsgUnPauseDappTx{} + +func (m *MsgUnPauseDappTx) Route() string { + return ModuleName +} +func (m *MsgUnPauseDappTx) Type() string { + return types.MsgTypeUnPauseDappTx +} +func (m *MsgUnPauseDappTx) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(m.Sender) + if err != nil { + return err + } + + return nil +} +func (m *MsgUnPauseDappTx) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(m) + return sdk.MustSortJSON(bz) +} +func (m *MsgUnPauseDappTx) GetSigners() []sdk.AccAddress { + addr, err := sdk.AccAddressFromBech32(m.Sender) + if err != nil { + panic(err) + } + return []sdk.AccAddress{addr} +} + +var _ sdk.Msg = &MsgReactivateDappTx{} + +func (m *MsgReactivateDappTx) Route() string { + return ModuleName +} +func (m *MsgReactivateDappTx) Type() string { + return types.MsgTypeReactivateDappTx +} +func (m *MsgReactivateDappTx) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(m.Sender) + if err != nil { + return err + } + + return nil +} +func (m *MsgReactivateDappTx) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(m) + return sdk.MustSortJSON(bz) +} +func (m *MsgReactivateDappTx) GetSigners() []sdk.AccAddress { + addr, err := sdk.AccAddressFromBech32(m.Sender) + if err != nil { + panic(err) + } + return []sdk.AccAddress{addr} +} + +var _ sdk.Msg = &MsgExecuteDappTx{} + +func (m *MsgExecuteDappTx) Route() string { + return ModuleName +} +func (m *MsgExecuteDappTx) Type() string { + return types.MsgTypeExecuteDappTx +} +func (m *MsgExecuteDappTx) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(m.Sender) + if err != nil { + return err + } + + return nil +} +func (m *MsgExecuteDappTx) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(m) + return sdk.MustSortJSON(bz) +} +func (m *MsgExecuteDappTx) GetSigners() []sdk.AccAddress { + addr, err := sdk.AccAddressFromBech32(m.Sender) + if err != nil { + panic(err) + } + return []sdk.AccAddress{addr} +} + +var _ sdk.Msg = &MsgDenounceLeaderTx{} + +func (m *MsgDenounceLeaderTx) Route() string { + return ModuleName +} +func (m *MsgDenounceLeaderTx) Type() string { + return types.MsgTypeDenounceLeaderTx +} +func (m *MsgDenounceLeaderTx) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(m.Sender) + if err != nil { + return err + } + + return nil +} +func (m *MsgDenounceLeaderTx) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(m) + return sdk.MustSortJSON(bz) +} +func (m *MsgDenounceLeaderTx) GetSigners() []sdk.AccAddress { + addr, err := sdk.AccAddressFromBech32(m.Sender) + if err != nil { + panic(err) + } + return []sdk.AccAddress{addr} +} + +var _ sdk.Msg = &MsgTransitionDappTx{} + +func NewMsgTransitionDappTx(sender, dappName, statusHash, version string, onchainMsgs []sdk.Msg) *MsgTransitionDappTx { + msgs := []*codectypes.Any{} + for _, om := range onchainMsgs { + anyMsg, err := PackTxMsgAny(om) + if err != nil { + panic(err) + } + msgs = append(msgs, anyMsg) + } + return &MsgTransitionDappTx{ + Sender: sender, + DappName: dappName, + StatusHash: statusHash, + Version: version, + OnchainMessages: msgs, + } +} + +func (m *MsgTransitionDappTx) Route() string { + return ModuleName +} +func (m *MsgTransitionDappTx) Type() string { + return types.MsgTypeTransitionDappTx +} +func (m *MsgTransitionDappTx) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(m.Sender) + if err != nil { + return err + } + + return nil +} +func (m *MsgTransitionDappTx) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(m) + return sdk.MustSortJSON(bz) +} +func (m *MsgTransitionDappTx) GetSigners() []sdk.AccAddress { + addr, err := sdk.AccAddressFromBech32(m.Sender) + if err != nil { + panic(err) + } + return []sdk.AccAddress{addr} +} + +// UnpackInterfaces implements codectypes.UnpackInterfacesMessage +func (m *MsgTransitionDappTx) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { + var sdkMsg sdk.Msg + + for _, any := range m.OnchainMessages { + err := unpacker.UnpackAny(any, &sdkMsg) + if err != nil { + return err + } + } + return nil +} + +var _ sdk.Msg = &MsgApproveDappTransitionTx{} + +func (m *MsgApproveDappTransitionTx) Route() string { + return ModuleName +} +func (m *MsgApproveDappTransitionTx) Type() string { + return types.MsgTypeApproveDappTransitionTx +} +func (m *MsgApproveDappTransitionTx) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(m.Sender) + if err != nil { + return err + } + + return nil +} +func (m *MsgApproveDappTransitionTx) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(m) + return sdk.MustSortJSON(bz) +} +func (m *MsgApproveDappTransitionTx) GetSigners() []sdk.AccAddress { + addr, err := sdk.AccAddressFromBech32(m.Sender) + if err != nil { + panic(err) + } + return []sdk.AccAddress{addr} +} + +var _ sdk.Msg = &MsgRejectDappTransitionTx{} + +func (m *MsgRejectDappTransitionTx) Route() string { + return ModuleName +} +func (m *MsgRejectDappTransitionTx) Type() string { + return types.MsgTypeRejectDappTransitionTx +} +func (m *MsgRejectDappTransitionTx) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(m.Sender) + if err != nil { + return err + } + + return nil +} +func (m *MsgRejectDappTransitionTx) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(m) + return sdk.MustSortJSON(bz) +} +func (m *MsgRejectDappTransitionTx) GetSigners() []sdk.AccAddress { + addr, err := sdk.AccAddressFromBech32(m.Sender) + if err != nil { + panic(err) + } + return []sdk.AccAddress{addr} +} + +var _ sdk.Msg = &MsgTransferDappTx{} + +func (m *MsgTransferDappTx) Route() string { + return ModuleName +} +func (m *MsgTransferDappTx) Type() string { + return types.MsgTypeTransferDappTx +} +func (m *MsgTransferDappTx) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(m.Sender) + if err != nil { + return err + } + + return nil +} +func (m *MsgTransferDappTx) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(m) + return sdk.MustSortJSON(bz) +} +func (m *MsgTransferDappTx) GetSigners() []sdk.AccAddress { + addr, err := sdk.AccAddressFromBech32(m.Sender) + if err != nil { + panic(err) + } + return []sdk.AccAddress{addr} +} + +var _ sdk.Msg = &MsgAckTransferDappTx{} + +// NewMsgAckTransferDappTx creates a new MsgAckTransferDappTx instance +func NewMsgAckTransferDappTx(sender string, responses []XAMResponse) *MsgAckTransferDappTx { + return &MsgAckTransferDappTx{ + Sender: sender, + Responses: responses, + } +} + +func (m *MsgAckTransferDappTx) Route() string { + return ModuleName +} +func (m *MsgAckTransferDappTx) Type() string { + return types.MsgTypeAckTransferDappTx +} +func (m *MsgAckTransferDappTx) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(m.Sender) + if err != nil { + return err + } + + return nil +} +func (m *MsgAckTransferDappTx) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(m) + return sdk.MustSortJSON(bz) +} +func (m *MsgAckTransferDappTx) GetSigners() []sdk.AccAddress { + addr, err := sdk.AccAddressFromBech32(m.Sender) + if err != nil { + panic(err) + } + return []sdk.AccAddress{addr} +} + +var _ sdk.Msg = &MsgMintCreateFtTx{} + +func (m *MsgMintCreateFtTx) Route() string { + return ModuleName +} +func (m *MsgMintCreateFtTx) Type() string { + return types.MsgTypeMintCreateFtTx +} +func (m *MsgMintCreateFtTx) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(m.Sender) + if err != nil { + return err + } + + return nil +} +func (m *MsgMintCreateFtTx) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(m) + return sdk.MustSortJSON(bz) +} +func (m *MsgMintCreateFtTx) GetSigners() []sdk.AccAddress { + addr, err := sdk.AccAddressFromBech32(m.Sender) + if err != nil { + panic(err) + } + return []sdk.AccAddress{addr} +} + +var _ sdk.Msg = &MsgMintCreateNftTx{} + +func (m *MsgMintCreateNftTx) Route() string { + return ModuleName +} +func (m *MsgMintCreateNftTx) Type() string { + return types.MsgTypeMintCreateNftTx +} +func (m *MsgMintCreateNftTx) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(m.Sender) + if err != nil { + return err + } + + return nil +} +func (m *MsgMintCreateNftTx) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(m) + return sdk.MustSortJSON(bz) +} +func (m *MsgMintCreateNftTx) GetSigners() []sdk.AccAddress { + addr, err := sdk.AccAddressFromBech32(m.Sender) + if err != nil { + panic(err) + } + return []sdk.AccAddress{addr} +} + +var _ sdk.Msg = &MsgMintIssueTx{} + +func (m *MsgMintIssueTx) Route() string { + return ModuleName +} +func (m *MsgMintIssueTx) Type() string { + return types.MsgTypeMintIssueTx +} +func (m *MsgMintIssueTx) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(m.Sender) + if err != nil { + return err + } + + return nil +} +func (m *MsgMintIssueTx) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(m) + return sdk.MustSortJSON(bz) +} +func (m *MsgMintIssueTx) GetSigners() []sdk.AccAddress { + addr, err := sdk.AccAddressFromBech32(m.Sender) + if err != nil { + panic(err) + } + return []sdk.AccAddress{addr} +} + +var _ sdk.Msg = &MsgMintBurnTx{} + +func (m *MsgMintBurnTx) Route() string { + return ModuleName +} +func (m *MsgMintBurnTx) Type() string { + return types.MsgTypeMintBurnTx +} +func (m *MsgMintBurnTx) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(m.Sender) + if err != nil { + return err + } + + return nil +} +func (m *MsgMintBurnTx) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(m) + return sdk.MustSortJSON(bz) +} +func (m *MsgMintBurnTx) GetSigners() []sdk.AccAddress { + addr, err := sdk.AccAddressFromBech32(m.Sender) + if err != nil { + panic(err) + } + return []sdk.AccAddress{addr} +} diff --git a/x/layer2/types/proposal.go b/x/layer2/types/proposal.go new file mode 100644 index 000000000..a656840db --- /dev/null +++ b/x/layer2/types/proposal.go @@ -0,0 +1,40 @@ +package types + +import ( + kiratypes "github.com/KiraCore/sekai/types" + "github.com/KiraCore/sekai/x/gov/types" +) + +func (m *ProposalJoinDapp) ProposalType() string { + return kiratypes.ProposalTypeJoinDapp +} + +func (m *ProposalJoinDapp) ProposalPermission() types.PermValue { + return types.PermZero +} + +func (m *ProposalJoinDapp) VotePermission() types.PermValue { + return types.PermZero +} + +// ValidateBasic returns basic validation +func (m *ProposalJoinDapp) ValidateBasic() error { + return nil +} + +func (m *ProposalUpsertDapp) ProposalType() string { + return kiratypes.ProposalTypeUpsertDapp +} + +func (m *ProposalUpsertDapp) ProposalPermission() types.PermValue { + return types.PermZero +} + +func (m *ProposalUpsertDapp) VotePermission() types.PermValue { + return types.PermZero +} + +// ValidateBasic returns basic validation +func (m *ProposalUpsertDapp) ValidateBasic() error { + return nil +} diff --git a/x/layer2/types/proposal.pb.go b/x/layer2/types/proposal.pb.go new file mode 100644 index 000000000..d05fd56fd --- /dev/null +++ b/x/layer2/types/proposal.pb.go @@ -0,0 +1,780 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: kira/layer2/proposal.proto + +package types + +import ( + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + _ "github.com/regen-network/cosmos-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 + +// Allows joining applications as executor or fisherman. By default all +// executors are also verifiers so it should not be possible to set both +// executor and verifier flags to true at the same time. This tx MUST also allow +// to define or update a globally unique INTERX address that will be tasked with +// operating the application. Tx should also fail if someone already joined +// application and is applying for a different role, in other words all +// operators must be unique for each dApp although different applications can +// have the same operators. +type ProposalJoinDapp struct { + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + DappName string `protobuf:"bytes,2,opt,name=dapp_name,json=dappName,proto3" json:"dapp_name,omitempty"` + Executor bool `protobuf:"varint,3,opt,name=executor,proto3" json:"executor,omitempty"` + Verifier bool `protobuf:"varint,4,opt,name=verifier,proto3" json:"verifier,omitempty"` + Interx string `protobuf:"bytes,5,opt,name=interx,proto3" json:"interx,omitempty"` +} + +func (m *ProposalJoinDapp) Reset() { *m = ProposalJoinDapp{} } +func (m *ProposalJoinDapp) String() string { return proto.CompactTextString(m) } +func (*ProposalJoinDapp) ProtoMessage() {} +func (*ProposalJoinDapp) Descriptor() ([]byte, []int) { + return fileDescriptor_b1582b91a5d65ebd, []int{0} +} +func (m *ProposalJoinDapp) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ProposalJoinDapp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ProposalJoinDapp.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 *ProposalJoinDapp) XXX_Merge(src proto.Message) { + xxx_messageInfo_ProposalJoinDapp.Merge(m, src) +} +func (m *ProposalJoinDapp) XXX_Size() int { + return m.Size() +} +func (m *ProposalJoinDapp) XXX_DiscardUnknown() { + xxx_messageInfo_ProposalJoinDapp.DiscardUnknown(m) +} + +var xxx_messageInfo_ProposalJoinDapp proto.InternalMessageInfo + +func (m *ProposalJoinDapp) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +func (m *ProposalJoinDapp) GetDappName() string { + if m != nil { + return m.DappName + } + return "" +} + +func (m *ProposalJoinDapp) GetExecutor() bool { + if m != nil { + return m.Executor + } + return false +} + +func (m *ProposalJoinDapp) GetVerifier() bool { + if m != nil { + return m.Verifier + } + return false +} + +func (m *ProposalJoinDapp) GetInterx() string { + if m != nil { + return m.Interx + } + return "" +} + +// can only be sent by the dApp controllers, allowing to upgrade binaries, +// controlled and modify all other properties +type ProposalUpsertDapp struct { + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + Dapp Dapp `protobuf:"bytes,2,opt,name=dapp,proto3" json:"dapp"` +} + +func (m *ProposalUpsertDapp) Reset() { *m = ProposalUpsertDapp{} } +func (m *ProposalUpsertDapp) String() string { return proto.CompactTextString(m) } +func (*ProposalUpsertDapp) ProtoMessage() {} +func (*ProposalUpsertDapp) Descriptor() ([]byte, []int) { + return fileDescriptor_b1582b91a5d65ebd, []int{1} +} +func (m *ProposalUpsertDapp) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ProposalUpsertDapp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ProposalUpsertDapp.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 *ProposalUpsertDapp) XXX_Merge(src proto.Message) { + xxx_messageInfo_ProposalUpsertDapp.Merge(m, src) +} +func (m *ProposalUpsertDapp) XXX_Size() int { + return m.Size() +} +func (m *ProposalUpsertDapp) XXX_DiscardUnknown() { + xxx_messageInfo_ProposalUpsertDapp.DiscardUnknown(m) +} + +var xxx_messageInfo_ProposalUpsertDapp proto.InternalMessageInfo + +func (m *ProposalUpsertDapp) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +func (m *ProposalUpsertDapp) GetDapp() Dapp { + if m != nil { + return m.Dapp + } + return Dapp{} +} + +func init() { + proto.RegisterType((*ProposalJoinDapp)(nil), "kira.layer2.ProposalJoinDapp") + proto.RegisterType((*ProposalUpsertDapp)(nil), "kira.layer2.ProposalUpsertDapp") +} + +func init() { proto.RegisterFile("kira/layer2/proposal.proto", fileDescriptor_b1582b91a5d65ebd) } + +var fileDescriptor_b1582b91a5d65ebd = []byte{ + // 326 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x90, 0xb1, 0x4e, 0x02, 0x31, + 0x18, 0xc7, 0xaf, 0x8a, 0x08, 0x65, 0x50, 0x2f, 0xc6, 0x9c, 0x67, 0x72, 0x10, 0x26, 0x12, 0xe3, + 0x5d, 0x82, 0x9b, 0x23, 0x38, 0x69, 0x62, 0x0c, 0x89, 0x83, 0x2e, 0xa4, 0xc0, 0x27, 0x36, 0x70, + 0xfd, 0x9a, 0xb6, 0x18, 0x78, 0x0b, 0x1f, 0xc1, 0xd1, 0x07, 0xf0, 0x21, 0x18, 0x89, 0x93, 0x93, + 0x31, 0xb0, 0xf8, 0x18, 0xa6, 0x57, 0xce, 0x30, 0x39, 0xb5, 0xff, 0xef, 0xf7, 0xb5, 0xff, 0x7f, + 0xfe, 0x34, 0x1c, 0x71, 0xc5, 0x92, 0x31, 0x9b, 0x81, 0x6a, 0x26, 0x52, 0xa1, 0x44, 0xcd, 0xc6, + 0xb1, 0x54, 0x68, 0xd0, 0xaf, 0x58, 0x16, 0x3b, 0x16, 0x1e, 0x0e, 0x71, 0x88, 0xd9, 0x3c, 0xb1, + 0x37, 0xb7, 0x12, 0x1e, 0xf7, 0x51, 0xa7, 0xa8, 0xbb, 0x0e, 0x38, 0xb1, 0x46, 0xc1, 0xe6, 0xcf, + 0xee, 0x70, 0xa4, 0xfe, 0x46, 0xe8, 0xfe, 0xed, 0xda, 0xea, 0x0a, 0xb9, 0xb8, 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0x00, 0x00, +} + +func (this *ProposalJoinDapp) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*ProposalJoinDapp) + if !ok { + that2, ok := that.(ProposalJoinDapp) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Sender != that1.Sender { + return false + } + if this.DappName != that1.DappName { + return false + } + if this.Executor != that1.Executor { + return false + } + if this.Verifier != that1.Verifier { + return false + } + if this.Interx != that1.Interx { + return false + } + return true +} +func (m *ProposalJoinDapp) 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 *ProposalJoinDapp) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ProposalJoinDapp) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Interx) > 0 { + i -= len(m.Interx) + copy(dAtA[i:], m.Interx) + i = encodeVarintProposal(dAtA, i, uint64(len(m.Interx))) + i-- + dAtA[i] = 0x2a + } + if m.Verifier { + i-- + if m.Verifier { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x20 + } + if m.Executor { + i-- + if m.Executor { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x18 + } + if len(m.DappName) > 0 { + i -= len(m.DappName) + copy(dAtA[i:], m.DappName) + i = encodeVarintProposal(dAtA, i, uint64(len(m.DappName))) + i-- + dAtA[i] = 0x12 + } + if len(m.Sender) > 0 { + i -= len(m.Sender) + copy(dAtA[i:], m.Sender) + i = encodeVarintProposal(dAtA, i, uint64(len(m.Sender))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *ProposalUpsertDapp) 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 *ProposalUpsertDapp) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ProposalUpsertDapp) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Dapp.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintProposal(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.Sender) > 0 { + i -= len(m.Sender) + copy(dAtA[i:], m.Sender) + i = encodeVarintProposal(dAtA, i, uint64(len(m.Sender))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintProposal(dAtA []byte, offset int, v uint64) int { + offset -= sovProposal(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *ProposalJoinDapp) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovProposal(uint64(l)) + } + l = len(m.DappName) + if l > 0 { + n += 1 + l + sovProposal(uint64(l)) + } + if m.Executor { + n += 2 + } + if m.Verifier { + n += 2 + } + l = len(m.Interx) + if l > 0 { + n += 1 + l + sovProposal(uint64(l)) + } + return n +} + +func (m *ProposalUpsertDapp) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovProposal(uint64(l)) + } + l = m.Dapp.Size() + n += 1 + l + sovProposal(uint64(l)) + return n +} + +func sovProposal(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozProposal(x uint64) (n int) { + return sovProposal(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *ProposalJoinDapp) 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 ErrIntOverflowProposal + } + 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: ProposalJoinDapp: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ProposalJoinDapp: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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 ErrIntOverflowProposal + } + 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 ErrInvalidLengthProposal + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthProposal + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Sender = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DappName", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProposal + } + 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 ErrInvalidLengthProposal + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthProposal + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DappName = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Executor", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProposal + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Executor = bool(v != 0) + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Verifier", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProposal + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Verifier = bool(v != 0) + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Interx", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProposal + } + 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 ErrInvalidLengthProposal + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthProposal + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Interx = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipProposal(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthProposal + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ProposalUpsertDapp) 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 ErrIntOverflowProposal + } + 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: ProposalUpsertDapp: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ProposalUpsertDapp: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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 ErrIntOverflowProposal + } + 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 ErrInvalidLengthProposal + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthProposal + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Sender = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Dapp", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProposal + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthProposal + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthProposal + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Dapp.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipProposal(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthProposal + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipProposal(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, ErrIntOverflowProposal + } + 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, ErrIntOverflowProposal + } + 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, ErrIntOverflowProposal + } + 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, ErrInvalidLengthProposal + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupProposal + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthProposal + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthProposal = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowProposal = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupProposal = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/layer2/types/query.pb.go b/x/layer2/types/query.pb.go new file mode 100644 index 000000000..d77c12daf --- /dev/null +++ b/x/layer2/types/query.pb.go @@ -0,0 +1,1697 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: kira/layer2/query.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/codec/types" + _ "github.com/cosmos/cosmos-sdk/types/query" + _ "github.com/gogo/protobuf/gogoproto" + grpc1 "github.com/gogo/protobuf/grpc" + proto "github.com/gogo/protobuf/proto" + _ "google.golang.org/genproto/googleapis/api/annotations" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type QueryExecutionRegistrarRequest struct { + Identifier string `protobuf:"bytes,1,opt,name=identifier,proto3" json:"identifier,omitempty"` +} + +func (m *QueryExecutionRegistrarRequest) Reset() { *m = QueryExecutionRegistrarRequest{} } +func (m *QueryExecutionRegistrarRequest) String() string { return proto.CompactTextString(m) } +func (*QueryExecutionRegistrarRequest) ProtoMessage() {} +func (*QueryExecutionRegistrarRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_b9c14366296fd7f4, []int{0} +} +func (m *QueryExecutionRegistrarRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryExecutionRegistrarRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryExecutionRegistrarRequest.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 *QueryExecutionRegistrarRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryExecutionRegistrarRequest.Merge(m, src) +} +func (m *QueryExecutionRegistrarRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryExecutionRegistrarRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryExecutionRegistrarRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryExecutionRegistrarRequest proto.InternalMessageInfo + +func (m *QueryExecutionRegistrarRequest) GetIdentifier() string { + if m != nil { + return m.Identifier + } + return "" +} + +type QueryExecutionRegistrarResponse struct { + Dapp *Dapp `protobuf:"bytes,1,opt,name=dapp,proto3" json:"dapp,omitempty"` + ExecutionRegistrar *ExecutionRegistrar `protobuf:"bytes,2,opt,name=execution_registrar,json=executionRegistrar,proto3" json:"execution_registrar,omitempty"` +} + +func (m *QueryExecutionRegistrarResponse) Reset() { *m = QueryExecutionRegistrarResponse{} } +func (m *QueryExecutionRegistrarResponse) String() string { return proto.CompactTextString(m) } +func (*QueryExecutionRegistrarResponse) ProtoMessage() {} +func (*QueryExecutionRegistrarResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_b9c14366296fd7f4, []int{1} +} +func (m *QueryExecutionRegistrarResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryExecutionRegistrarResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryExecutionRegistrarResponse.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 *QueryExecutionRegistrarResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryExecutionRegistrarResponse.Merge(m, src) +} +func (m *QueryExecutionRegistrarResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryExecutionRegistrarResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryExecutionRegistrarResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryExecutionRegistrarResponse proto.InternalMessageInfo + +func (m *QueryExecutionRegistrarResponse) GetDapp() *Dapp { + if m != nil { + return m.Dapp + } + return nil +} + +func (m *QueryExecutionRegistrarResponse) GetExecutionRegistrar() *ExecutionRegistrar { + if m != nil { + return m.ExecutionRegistrar + } + return nil +} + +type QueryAllDappsRequest struct { +} + +func (m *QueryAllDappsRequest) Reset() { *m = QueryAllDappsRequest{} } +func (m *QueryAllDappsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryAllDappsRequest) ProtoMessage() {} +func (*QueryAllDappsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_b9c14366296fd7f4, []int{2} +} +func (m *QueryAllDappsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryAllDappsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryAllDappsRequest.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 *QueryAllDappsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryAllDappsRequest.Merge(m, src) +} +func (m *QueryAllDappsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryAllDappsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryAllDappsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryAllDappsRequest proto.InternalMessageInfo + +type QueryAllDappsResponse struct { + Dapps []Dapp `protobuf:"bytes,1,rep,name=dapps,proto3" json:"dapps"` +} + +func (m *QueryAllDappsResponse) Reset() { *m = QueryAllDappsResponse{} } +func (m *QueryAllDappsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryAllDappsResponse) ProtoMessage() {} +func (*QueryAllDappsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_b9c14366296fd7f4, []int{3} +} +func (m *QueryAllDappsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryAllDappsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryAllDappsResponse.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 *QueryAllDappsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryAllDappsResponse.Merge(m, src) +} +func (m *QueryAllDappsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryAllDappsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryAllDappsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryAllDappsResponse proto.InternalMessageInfo + +func (m *QueryAllDappsResponse) GetDapps() []Dapp { + if m != nil { + return m.Dapps + } + return nil +} + +type QueryTransferDappsRequest struct { +} + +func (m *QueryTransferDappsRequest) Reset() { *m = QueryTransferDappsRequest{} } +func (m *QueryTransferDappsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryTransferDappsRequest) ProtoMessage() {} +func (*QueryTransferDappsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_b9c14366296fd7f4, []int{4} +} +func (m *QueryTransferDappsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryTransferDappsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryTransferDappsRequest.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 *QueryTransferDappsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryTransferDappsRequest.Merge(m, src) +} +func (m *QueryTransferDappsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryTransferDappsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryTransferDappsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryTransferDappsRequest proto.InternalMessageInfo + +type QueryTransferDappsResponse struct { + XAMs []XAM `protobuf:"bytes,1,rep,name=XAMs,proto3" json:"XAMs"` +} + +func (m *QueryTransferDappsResponse) Reset() { *m = QueryTransferDappsResponse{} } +func (m *QueryTransferDappsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryTransferDappsResponse) ProtoMessage() {} +func (*QueryTransferDappsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_b9c14366296fd7f4, []int{5} +} +func (m *QueryTransferDappsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryTransferDappsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryTransferDappsResponse.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 *QueryTransferDappsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryTransferDappsResponse.Merge(m, src) +} +func (m *QueryTransferDappsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryTransferDappsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryTransferDappsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryTransferDappsResponse proto.InternalMessageInfo + +func (m *QueryTransferDappsResponse) GetXAMs() []XAM { + if m != nil { + return m.XAMs + } + return nil +} + +type QueryGlobalTokensRequest struct { +} + +func (m *QueryGlobalTokensRequest) Reset() { *m = QueryGlobalTokensRequest{} } +func (m *QueryGlobalTokensRequest) String() string { return proto.CompactTextString(m) } +func (*QueryGlobalTokensRequest) ProtoMessage() {} +func (*QueryGlobalTokensRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_b9c14366296fd7f4, []int{6} +} +func (m *QueryGlobalTokensRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGlobalTokensRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGlobalTokensRequest.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 *QueryGlobalTokensRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGlobalTokensRequest.Merge(m, src) +} +func (m *QueryGlobalTokensRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryGlobalTokensRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGlobalTokensRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGlobalTokensRequest proto.InternalMessageInfo + +type QueryGlobalTokensResponse struct { + Tokens []TokenInfo `protobuf:"bytes,1,rep,name=tokens,proto3" json:"tokens"` +} + +func (m *QueryGlobalTokensResponse) Reset() { *m = QueryGlobalTokensResponse{} } +func (m *QueryGlobalTokensResponse) String() string { return proto.CompactTextString(m) } +func (*QueryGlobalTokensResponse) ProtoMessage() {} +func (*QueryGlobalTokensResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_b9c14366296fd7f4, []int{7} +} +func (m *QueryGlobalTokensResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGlobalTokensResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGlobalTokensResponse.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 *QueryGlobalTokensResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGlobalTokensResponse.Merge(m, src) +} +func (m *QueryGlobalTokensResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryGlobalTokensResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGlobalTokensResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGlobalTokensResponse proto.InternalMessageInfo + +func (m *QueryGlobalTokensResponse) GetTokens() []TokenInfo { + if m != nil { + return m.Tokens + } + return nil +} + +func init() { + proto.RegisterType((*QueryExecutionRegistrarRequest)(nil), "kira.layer2.QueryExecutionRegistrarRequest") + proto.RegisterType((*QueryExecutionRegistrarResponse)(nil), "kira.layer2.QueryExecutionRegistrarResponse") + proto.RegisterType((*QueryAllDappsRequest)(nil), "kira.layer2.QueryAllDappsRequest") + proto.RegisterType((*QueryAllDappsResponse)(nil), "kira.layer2.QueryAllDappsResponse") + proto.RegisterType((*QueryTransferDappsRequest)(nil), "kira.layer2.QueryTransferDappsRequest") + proto.RegisterType((*QueryTransferDappsResponse)(nil), "kira.layer2.QueryTransferDappsResponse") + proto.RegisterType((*QueryGlobalTokensRequest)(nil), "kira.layer2.QueryGlobalTokensRequest") + proto.RegisterType((*QueryGlobalTokensResponse)(nil), "kira.layer2.QueryGlobalTokensResponse") +} + +func init() { proto.RegisterFile("kira/layer2/query.proto", fileDescriptor_b9c14366296fd7f4) } + +var fileDescriptor_b9c14366296fd7f4 = []byte{ + // 590 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x54, 0x4f, 0x6f, 0xd3, 0x30, + 0x1c, 0x6d, 0x46, 0x37, 0x81, 0x07, 0x12, 0x98, 0x51, 0xb2, 0x30, 0xa5, 0x23, 0xd2, 0xc6, 0x34, + 0x58, 0xad, 0x15, 0xb8, 0xd3, 0xf2, 0x5f, 0x68, 0x12, 0xab, 0x76, 0x98, 0xb8, 0x54, 0x4e, 0xe7, + 0x06, 0xab, 0xa9, 0x9d, 0xda, 0x2e, 0x5a, 0x85, 0x38, 0x80, 0xf8, 0x00, 0x48, 0xdc, 0xf8, 0x00, + 0x1c, 0xf9, 0x1c, 0x3b, 0x4e, 0xe2, 0xc2, 0x09, 0xa1, 0x96, 0x0f, 0x82, 0xe2, 0xb8, 0x23, 0x59, + 0x42, 0xc7, 0xa9, 0xee, 0xef, 0xbd, 0xdf, 0x7b, 0xcf, 0xfe, 0xfd, 0x14, 0x70, 0xbd, 0x47, 0x05, + 0x46, 0x21, 0x1e, 0x11, 0x51, 0x47, 0x83, 0x21, 0x11, 0xa3, 0x5a, 0x24, 0xb8, 0xe2, 0x70, 0x31, + 0x06, 0x6a, 0x09, 0xe0, 0x6c, 0x76, 0xb8, 0xec, 0x73, 0x89, 0x7c, 0x2c, 0x49, 0xc2, 0x42, 0x6f, + 0xb6, 0x7d, 0xa2, 0xf0, 0x36, 0x8a, 0x70, 0x40, 0x19, 0x56, 0x94, 0xb3, 0xa4, 0xd1, 0x59, 0x0a, + 0x78, 0xc0, 0xf5, 0x11, 0xc5, 0x27, 0x53, 0x5d, 0x0e, 0x38, 0x0f, 0x42, 0x82, 0xf4, 0x3f, 0x7f, + 0xd8, 0x45, 0x98, 0x19, 0x27, 0x67, 0xc5, 0x40, 0x38, 0xa2, 0x08, 0x33, 0xc6, 0x95, 0x56, 0x93, + 0x06, 0xb5, 0xd3, 0x01, 0x93, 0x1f, 0x83, 0x54, 0xd2, 0x48, 0x9f, 0x32, 0x95, 0xd4, 0xbd, 0x07, + 0xc0, 0xdd, 0x8d, 0x23, 0x3e, 0x3e, 0x24, 0x9d, 0x61, 0x2c, 0xd5, 0x22, 0x01, 0x95, 0x4a, 0x60, + 0xd1, 0x22, 0x83, 0x21, 0x91, 0x0a, 0xba, 0x00, 0xd0, 0x03, 0xc2, 0x14, 0xed, 0x52, 0x22, 0x6c, + 0x6b, 0xd5, 0xda, 0xb8, 0xd0, 0x4a, 0x55, 0xbc, 0x2f, 0x16, 0xa8, 0xfe, 0x53, 0x42, 0x46, 0x9c, + 0x49, 0x02, 0xd7, 0x40, 0xf9, 0x00, 0x47, 0x91, 0xee, 0x5e, 0xac, 0x5f, 0xa9, 0xa5, 0x9e, 0xab, + 0xf6, 0x08, 0x47, 0x51, 0x4b, 0xc3, 0xf0, 0x25, 0xb8, 0x4a, 0xa6, 0x22, 0x6d, 0x31, 0x55, 0xb1, + 0xe7, 0x74, 0x57, 0x35, 0xd3, 0x55, 0x60, 0x06, 0x49, 0xae, 0xe6, 0x55, 0xc0, 0x92, 0xce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, 0x8f, 0x16, 0xb8, 0x94, 0x19, 0x2d, 0x5c, 0xcf, 0xab, 0x16, 0x2d, 0x86, + 0x73, 0xeb, 0x4c, 0x9e, 0x89, 0xe0, 0xe9, 0x08, 0x2b, 0xd0, 0xc9, 0x44, 0x50, 0x86, 0xab, 0x73, + 0xc0, 0xf7, 0x16, 0xb8, 0x98, 0x9e, 0x3d, 0x5c, 0xcb, 0xab, 0x17, 0xec, 0x8d, 0xb3, 0x7e, 0x16, + 0x6d, 0x66, 0x86, 0x40, 0x53, 0xdb, 0xc9, 0xc2, 0x34, 0x9b, 0x47, 0x63, 0xd7, 0x3a, 0x1e, 0xbb, + 0xd6, 0xaf, 0xb1, 0x6b, 0x7d, 0x9a, 0xb8, 0xa5, 0xe3, 0x89, 0x5b, 0xfa, 0x31, 0x71, 0x4b, 0xaf, + 0x36, 0x02, 0xaa, 0x5e, 0x0f, 0xfd, 0x5a, 0x87, 0xf7, 0xd1, 0x0b, 0x2a, 0xf0, 0x43, 0x2e, 0x08, + 0x92, 0xa4, 0x87, 0x29, 0x3a, 0x3c, 0xb9, 0xcf, 0x28, 0x22, 0xd2, 0x5f, 0xd0, 0x1f, 0xa4, 0xbb, + 0x7f, 0x02, 0x00, 0x00, 0xff, 0xff, 0xae, 0x94, 0x53, 0xc9, 0x65, 0x05, 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 { + // query info of a specific application by dApp ID or name + ExecutionRegistrar(ctx context.Context, in *QueryExecutionRegistrarRequest, opts ...grpc.CallOption) (*QueryExecutionRegistrarResponse, error) + // list IDs of all execution registrars and allow search by + // executor or verifier kira public key (e.g. list all dApps run by address kiraXXX…YYY) + AllDapps(ctx context.Context, in *QueryAllDappsRequest, opts ...grpc.CallOption) (*QueryAllDappsResponse, error) + // query XAMs’ records by either account address, account index, xid or + // transaction hash in which cross-app transaction was added to the ABR. + TransferDapps(ctx context.Context, in *QueryTransferDappsRequest, opts ...grpc.CallOption) (*QueryTransferDappsResponse, error) + // query list of all token denoms on the network including those created in + // the genesis (ukex, samolean etc..) as well as those in the minting module, + // lp tokens, validator recovery tokens and so on. If the flag with specific + // name is specified provide a detailed information about the token including + // its current circulating supply etc. + GlobalTokens(ctx context.Context, in *QueryGlobalTokensRequest, opts ...grpc.CallOption) (*QueryGlobalTokensResponse, error) +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +func (c *queryClient) ExecutionRegistrar(ctx context.Context, in *QueryExecutionRegistrarRequest, opts ...grpc.CallOption) (*QueryExecutionRegistrarResponse, error) { + out := new(QueryExecutionRegistrarResponse) + err := c.cc.Invoke(ctx, "/kira.layer2.Query/ExecutionRegistrar", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) AllDapps(ctx context.Context, in *QueryAllDappsRequest, opts ...grpc.CallOption) (*QueryAllDappsResponse, error) { + out := new(QueryAllDappsResponse) + err := c.cc.Invoke(ctx, "/kira.layer2.Query/AllDapps", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) TransferDapps(ctx context.Context, in *QueryTransferDappsRequest, opts ...grpc.CallOption) (*QueryTransferDappsResponse, error) { + out := new(QueryTransferDappsResponse) + err := c.cc.Invoke(ctx, "/kira.layer2.Query/TransferDapps", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) GlobalTokens(ctx context.Context, in *QueryGlobalTokensRequest, opts ...grpc.CallOption) (*QueryGlobalTokensResponse, error) { + out := new(QueryGlobalTokensResponse) + err := c.cc.Invoke(ctx, "/kira.layer2.Query/GlobalTokens", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +type QueryServer interface { + // query info of a specific application by dApp ID or name + ExecutionRegistrar(context.Context, *QueryExecutionRegistrarRequest) (*QueryExecutionRegistrarResponse, error) + // list IDs of all execution registrars and allow search by + // executor or verifier kira public key (e.g. list all dApps run by address kiraXXX…YYY) + AllDapps(context.Context, *QueryAllDappsRequest) (*QueryAllDappsResponse, error) + // query XAMs’ records by either account address, account index, xid or + // transaction hash in which cross-app transaction was added to the ABR. + TransferDapps(context.Context, *QueryTransferDappsRequest) (*QueryTransferDappsResponse, error) + // query list of all token denoms on the network including those created in + // the genesis (ukex, samolean etc..) as well as those in the minting module, + // lp tokens, validator recovery tokens and so on. If the flag with specific + // name is specified provide a detailed information about the token including + // its current circulating supply etc. + GlobalTokens(context.Context, *QueryGlobalTokensRequest) (*QueryGlobalTokensResponse, error) +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func (*UnimplementedQueryServer) ExecutionRegistrar(ctx context.Context, req *QueryExecutionRegistrarRequest) (*QueryExecutionRegistrarResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ExecutionRegistrar not implemented") +} +func (*UnimplementedQueryServer) AllDapps(ctx context.Context, req *QueryAllDappsRequest) (*QueryAllDappsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method AllDapps not implemented") +} +func (*UnimplementedQueryServer) TransferDapps(ctx context.Context, req *QueryTransferDappsRequest) (*QueryTransferDappsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method TransferDapps not implemented") +} +func (*UnimplementedQueryServer) GlobalTokens(ctx context.Context, req *QueryGlobalTokensRequest) (*QueryGlobalTokensResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GlobalTokens not implemented") +} + +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) +} + +func _Query_ExecutionRegistrar_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryExecutionRegistrarRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).ExecutionRegistrar(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/kira.layer2.Query/ExecutionRegistrar", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).ExecutionRegistrar(ctx, req.(*QueryExecutionRegistrarRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_AllDapps_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryAllDappsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).AllDapps(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/kira.layer2.Query/AllDapps", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).AllDapps(ctx, req.(*QueryAllDappsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_TransferDapps_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryTransferDappsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).TransferDapps(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/kira.layer2.Query/TransferDapps", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).TransferDapps(ctx, req.(*QueryTransferDappsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_GlobalTokens_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryGlobalTokensRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).GlobalTokens(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/kira.layer2.Query/GlobalTokens", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).GlobalTokens(ctx, req.(*QueryGlobalTokensRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "kira.layer2.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "ExecutionRegistrar", + Handler: _Query_ExecutionRegistrar_Handler, + }, + { + MethodName: "AllDapps", + Handler: _Query_AllDapps_Handler, + }, + { + MethodName: "TransferDapps", + Handler: _Query_TransferDapps_Handler, + }, + { + MethodName: "GlobalTokens", + Handler: _Query_GlobalTokens_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "kira/layer2/query.proto", +} + +func (m *QueryExecutionRegistrarRequest) 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 *QueryExecutionRegistrarRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryExecutionRegistrarRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Identifier) > 0 { + i -= len(m.Identifier) + copy(dAtA[i:], m.Identifier) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Identifier))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryExecutionRegistrarResponse) 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 *QueryExecutionRegistrarResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryExecutionRegistrarResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.ExecutionRegistrar != nil { + { + size, err := m.ExecutionRegistrar.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if m.Dapp != nil { + { + size, err := m.Dapp.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 *QueryAllDappsRequest) 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 *QueryAllDappsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryAllDappsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryAllDappsResponse) 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 *QueryAllDappsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryAllDappsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Dapps) > 0 { + for iNdEx := len(m.Dapps) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Dapps[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 *QueryTransferDappsRequest) 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 *QueryTransferDappsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryTransferDappsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryTransferDappsResponse) 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 *QueryTransferDappsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryTransferDappsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.XAMs) > 0 { + for iNdEx := len(m.XAMs) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.XAMs[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 *QueryGlobalTokensRequest) 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 *QueryGlobalTokensRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGlobalTokensRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryGlobalTokensResponse) 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 *QueryGlobalTokensResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGlobalTokensResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Tokens) > 0 { + for iNdEx := len(m.Tokens) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Tokens[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { + offset -= sovQuery(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *QueryExecutionRegistrarRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Identifier) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryExecutionRegistrarResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Dapp != nil { + l = m.Dapp.Size() + n += 1 + l + sovQuery(uint64(l)) + } + if m.ExecutionRegistrar != nil { + l = m.ExecutionRegistrar.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryAllDappsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryAllDappsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Dapps) > 0 { + for _, e := range m.Dapps { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + +func (m *QueryTransferDappsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryTransferDappsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.XAMs) > 0 { + for _, e := range m.XAMs { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + +func (m *QueryGlobalTokensRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryGlobalTokensResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Tokens) > 0 { + for _, e := range m.Tokens { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + +func sovQuery(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QueryExecutionRegistrarRequest) 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: QueryExecutionRegistrarRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryExecutionRegistrarRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Identifier", 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.Identifier = 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 *QueryExecutionRegistrarResponse) 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: QueryExecutionRegistrarResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryExecutionRegistrarResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Dapp", 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.Dapp == nil { + m.Dapp = &Dapp{} + } + if err := m.Dapp.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ExecutionRegistrar", 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.ExecutionRegistrar == nil { + m.ExecutionRegistrar = &ExecutionRegistrar{} + } + if err := m.ExecutionRegistrar.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 *QueryAllDappsRequest) 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: QueryAllDappsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryAllDappsRequest: 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 *QueryAllDappsResponse) 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: QueryAllDappsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryAllDappsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Dapps", 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.Dapps = append(m.Dapps, Dapp{}) + if err := m.Dapps[len(m.Dapps)-1].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 *QueryTransferDappsRequest) 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: QueryTransferDappsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryTransferDappsRequest: 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 *QueryTransferDappsResponse) 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: QueryTransferDappsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryTransferDappsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field XAMs", 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.XAMs = append(m.XAMs, XAM{}) + if err := m.XAMs[len(m.XAMs)-1].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 *QueryGlobalTokensRequest) 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: QueryGlobalTokensRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGlobalTokensRequest: 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 *QueryGlobalTokensResponse) 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: QueryGlobalTokensResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGlobalTokensResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Tokens", 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.Tokens = append(m.Tokens, TokenInfo{}) + if err := m.Tokens[len(m.Tokens)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipQuery(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthQuery + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupQuery + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthQuery + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthQuery = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowQuery = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/layer2/types/query.pb.gw.go b/x/layer2/types/query.pb.gw.go new file mode 100644 index 000000000..49db40070 --- /dev/null +++ b/x/layer2/types/query.pb.gw.go @@ -0,0 +1,370 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: kira/layer2/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/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 + +func request_Query_ExecutionRegistrar_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryExecutionRegistrarRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["identifier"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "identifier") + } + + protoReq.Identifier, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "identifier", err) + } + + msg, err := client.ExecutionRegistrar(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_ExecutionRegistrar_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryExecutionRegistrarRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["identifier"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "identifier") + } + + protoReq.Identifier, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "identifier", err) + } + + msg, err := server.ExecutionRegistrar(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_AllDapps_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAllDappsRequest + var metadata runtime.ServerMetadata + + msg, err := client.AllDapps(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_AllDapps_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAllDappsRequest + var metadata runtime.ServerMetadata + + msg, err := server.AllDapps(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_TransferDapps_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryTransferDappsRequest + var metadata runtime.ServerMetadata + + msg, err := client.TransferDapps(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_TransferDapps_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryTransferDappsRequest + var metadata runtime.ServerMetadata + + msg, err := server.TransferDapps(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_GlobalTokens_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGlobalTokensRequest + var metadata runtime.ServerMetadata + + msg, err := client.GlobalTokens(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_GlobalTokens_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGlobalTokensRequest + var metadata runtime.ServerMetadata + + msg, err := server.GlobalTokens(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 (such as grpc.SendHeader, etc) to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { + + mux.Handle("GET", pattern_Query_ExecutionRegistrar_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.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_ExecutionRegistrar_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_ExecutionRegistrar_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_AllDapps_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.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_AllDapps_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_AllDapps_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_TransferDapps_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.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_TransferDapps_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_TransferDapps_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_GlobalTokens_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.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_GlobalTokens_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_GlobalTokens_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_ExecutionRegistrar_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_ExecutionRegistrar_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_ExecutionRegistrar_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_AllDapps_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_AllDapps_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_AllDapps_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_TransferDapps_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_TransferDapps_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_TransferDapps_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_GlobalTokens_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_GlobalTokens_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_GlobalTokens_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_Query_ExecutionRegistrar_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"kira", "layer2", "execution_registrar", "identifier"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_AllDapps_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"kira", "layer2", "all_dapps"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_TransferDapps_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"kira", "layer2", "transfer_dapp"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_GlobalTokens_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"kira", "layer2", "global_tokens"}, "", runtime.AssumeColonVerbOpt(true))) +) + +var ( + forward_Query_ExecutionRegistrar_0 = runtime.ForwardResponseMessage + + forward_Query_AllDapps_0 = runtime.ForwardResponseMessage + + forward_Query_TransferDapps_0 = runtime.ForwardResponseMessage + + forward_Query_GlobalTokens_0 = runtime.ForwardResponseMessage +) diff --git a/x/layer2/types/session.go b/x/layer2/types/session.go new file mode 100644 index 000000000..ac8397a34 --- /dev/null +++ b/x/layer2/types/session.go @@ -0,0 +1,32 @@ +package types + +import ( + fmt "fmt" + + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + proto "github.com/gogo/protobuf/proto" +) + +// PackTxMsgAny marshals the sdk.Msg payload to a protobuf Any type +func PackTxMsgAny(sdkMsg sdk.Msg) (*codectypes.Any, error) { + msg, ok := sdkMsg.(proto.Message) + if !ok { + return nil, fmt.Errorf("can't proto marshal %T", sdkMsg) + } + + return codectypes.NewAnyWithValue(msg) +} + +// UnpackInterfaces implements codectypes.UnpackInterfacesMessage +func (session DappSession) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { + var sdkMsg sdk.Msg + + for _, any := range session.OnchainMessages { + err := unpacker.UnpackAny(any, &sdkMsg) + if err != nil { + return err + } + } + return nil +} diff --git a/x/layer2/types/tx.pb.go b/x/layer2/types/tx.pb.go new file mode 100644 index 000000000..c502639ce --- /dev/null +++ b/x/layer2/types/tx.pb.go @@ -0,0 +1,12224 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: kira/layer2/tx.proto + +package types + +import ( + context "context" + fmt "fmt" + types "github.com/cosmos/cosmos-sdk/codec/types" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/gogo/protobuf/gogoproto" + grpc1 "github.com/gogo/protobuf/grpc" + proto "github.com/gogo/protobuf/proto" + _ "github.com/regen-network/cosmos-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 + +// allow to raise dApp launch proposal using a token +// bond or with a dedicated permission (where no starting 1% bond needed). Fail +// proposal if min_dapp_bond is not reached. This proposal does NOT require +// governance approval only sufficient number of bonded tokens. +type MsgCreateDappProposal struct { + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + Dapp Dapp `protobuf:"bytes,2,opt,name=dapp,proto3" json:"dapp"` + Bond github_com_cosmos_cosmos_sdk_types.Coin `protobuf:"bytes,3,opt,name=bond,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Coin" json:"bond"` +} + +func (m *MsgCreateDappProposal) Reset() { *m = MsgCreateDappProposal{} } +func (m *MsgCreateDappProposal) String() string { return proto.CompactTextString(m) } +func (*MsgCreateDappProposal) ProtoMessage() {} +func (*MsgCreateDappProposal) Descriptor() ([]byte, []int) { + return fileDescriptor_c30a928a62b31d6d, []int{0} +} +func (m *MsgCreateDappProposal) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCreateDappProposal) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCreateDappProposal.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 *MsgCreateDappProposal) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCreateDappProposal.Merge(m, src) +} +func (m *MsgCreateDappProposal) XXX_Size() int { + return m.Size() +} +func (m *MsgCreateDappProposal) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCreateDappProposal.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCreateDappProposal proto.InternalMessageInfo + +func (m *MsgCreateDappProposal) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +func (m *MsgCreateDappProposal) GetDapp() Dapp { + if m != nil { + return m.Dapp + } + return Dapp{} +} + +type MsgCreateDappProposalResponse struct { +} + +func (m *MsgCreateDappProposalResponse) Reset() { *m = MsgCreateDappProposalResponse{} } +func (m *MsgCreateDappProposalResponse) String() string { return proto.CompactTextString(m) } +func (*MsgCreateDappProposalResponse) ProtoMessage() {} +func (*MsgCreateDappProposalResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_c30a928a62b31d6d, []int{1} +} +func (m *MsgCreateDappProposalResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCreateDappProposalResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCreateDappProposalResponse.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 *MsgCreateDappProposalResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCreateDappProposalResponse.Merge(m, src) +} +func (m *MsgCreateDappProposalResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgCreateDappProposalResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCreateDappProposalResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCreateDappProposalResponse proto.InternalMessageInfo + +// allow KEX holders to bond extra tokens to dApp +// proposal unless max_dapp_bond is reached in which case fail the tx. +type MsgBondDappProposal struct { + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + DappName string `protobuf:"bytes,2,opt,name=dapp_name,json=dappName,proto3" json:"dapp_name,omitempty"` + Bond github_com_cosmos_cosmos_sdk_types.Coin `protobuf:"bytes,3,opt,name=bond,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Coin" json:"bond"` +} + +func (m *MsgBondDappProposal) Reset() { *m = MsgBondDappProposal{} } +func (m *MsgBondDappProposal) String() string { return proto.CompactTextString(m) } +func (*MsgBondDappProposal) ProtoMessage() {} +func (*MsgBondDappProposal) Descriptor() ([]byte, []int) { + return fileDescriptor_c30a928a62b31d6d, []int{2} +} +func (m *MsgBondDappProposal) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgBondDappProposal) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgBondDappProposal.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 *MsgBondDappProposal) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgBondDappProposal.Merge(m, src) +} +func (m *MsgBondDappProposal) XXX_Size() int { + return m.Size() +} +func (m *MsgBondDappProposal) XXX_DiscardUnknown() { + xxx_messageInfo_MsgBondDappProposal.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgBondDappProposal proto.InternalMessageInfo + +func (m *MsgBondDappProposal) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +func (m *MsgBondDappProposal) GetDappName() string { + if m != nil { + return m.DappName + } + return "" +} + +type MsgBondDappProposalResponse struct { +} + +func (m *MsgBondDappProposalResponse) Reset() { *m = MsgBondDappProposalResponse{} } +func (m *MsgBondDappProposalResponse) String() string { return proto.CompactTextString(m) } +func (*MsgBondDappProposalResponse) ProtoMessage() {} +func (*MsgBondDappProposalResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_c30a928a62b31d6d, []int{3} +} +func (m *MsgBondDappProposalResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgBondDappProposalResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgBondDappProposalResponse.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 *MsgBondDappProposalResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgBondDappProposalResponse.Merge(m, src) +} +func (m *MsgBondDappProposalResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgBondDappProposalResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgBondDappProposalResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgBondDappProposalResponse proto.InternalMessageInfo + +// claim your KEX back from dApp proposal, should +// be possible to execute regardless if the proposal is still ongoing or failed +type MsgReclaimDappBondProposal struct { + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + DappName string `protobuf:"bytes,2,opt,name=dapp_name,json=dappName,proto3" json:"dapp_name,omitempty"` + Bond github_com_cosmos_cosmos_sdk_types.Coin `protobuf:"bytes,3,opt,name=bond,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Coin" json:"bond"` +} + +func (m *MsgReclaimDappBondProposal) Reset() { *m = MsgReclaimDappBondProposal{} } +func (m *MsgReclaimDappBondProposal) String() string { return proto.CompactTextString(m) } +func (*MsgReclaimDappBondProposal) ProtoMessage() {} +func (*MsgReclaimDappBondProposal) Descriptor() ([]byte, []int) { + return fileDescriptor_c30a928a62b31d6d, []int{4} +} +func (m *MsgReclaimDappBondProposal) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgReclaimDappBondProposal) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgReclaimDappBondProposal.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 *MsgReclaimDappBondProposal) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgReclaimDappBondProposal.Merge(m, src) +} +func (m *MsgReclaimDappBondProposal) XXX_Size() int { + return m.Size() +} +func (m *MsgReclaimDappBondProposal) XXX_DiscardUnknown() { + xxx_messageInfo_MsgReclaimDappBondProposal.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgReclaimDappBondProposal proto.InternalMessageInfo + +func (m *MsgReclaimDappBondProposal) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +func (m *MsgReclaimDappBondProposal) GetDappName() string { + if m != nil { + return m.DappName + } + return "" +} + +type MsgReclaimDappBondProposalResponse struct { +} + +func (m *MsgReclaimDappBondProposalResponse) Reset() { *m = MsgReclaimDappBondProposalResponse{} } +func (m *MsgReclaimDappBondProposalResponse) String() string { return proto.CompactTextString(m) } +func (*MsgReclaimDappBondProposalResponse) ProtoMessage() {} +func (*MsgReclaimDappBondProposalResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_c30a928a62b31d6d, []int{5} +} +func (m *MsgReclaimDappBondProposalResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgReclaimDappBondProposalResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgReclaimDappBondProposalResponse.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 *MsgReclaimDappBondProposalResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgReclaimDappBondProposalResponse.Merge(m, src) +} +func (m *MsgReclaimDappBondProposalResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgReclaimDappBondProposalResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgReclaimDappBondProposalResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgReclaimDappBondProposalResponse proto.InternalMessageInfo + +type MsgJoinDappVerifierWithBond struct { + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + DappName string `protobuf:"bytes,2,opt,name=dapp_name,json=dappName,proto3" json:"dapp_name,omitempty"` + Interx string `protobuf:"bytes,3,opt,name=interx,proto3" json:"interx,omitempty"` +} + +func (m *MsgJoinDappVerifierWithBond) Reset() { *m = MsgJoinDappVerifierWithBond{} } +func (m *MsgJoinDappVerifierWithBond) String() string { return proto.CompactTextString(m) } +func (*MsgJoinDappVerifierWithBond) ProtoMessage() {} +func (*MsgJoinDappVerifierWithBond) Descriptor() ([]byte, []int) { + return fileDescriptor_c30a928a62b31d6d, []int{6} +} +func (m *MsgJoinDappVerifierWithBond) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgJoinDappVerifierWithBond) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgJoinDappVerifierWithBond.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 *MsgJoinDappVerifierWithBond) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgJoinDappVerifierWithBond.Merge(m, src) +} +func (m *MsgJoinDappVerifierWithBond) XXX_Size() int { + return m.Size() +} +func (m *MsgJoinDappVerifierWithBond) XXX_DiscardUnknown() { + xxx_messageInfo_MsgJoinDappVerifierWithBond.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgJoinDappVerifierWithBond proto.InternalMessageInfo + +func (m *MsgJoinDappVerifierWithBond) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +func (m *MsgJoinDappVerifierWithBond) GetDappName() string { + if m != nil { + return m.DappName + } + return "" +} + +func (m *MsgJoinDappVerifierWithBond) GetInterx() string { + if m != nil { + return m.Interx + } + return "" +} + +type MsgJoinDappVerifierWithBondResponse struct { +} + +func (m *MsgJoinDappVerifierWithBondResponse) Reset() { *m = MsgJoinDappVerifierWithBondResponse{} } +func (m *MsgJoinDappVerifierWithBondResponse) String() string { return proto.CompactTextString(m) } +func (*MsgJoinDappVerifierWithBondResponse) ProtoMessage() {} +func (*MsgJoinDappVerifierWithBondResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_c30a928a62b31d6d, []int{7} +} +func (m *MsgJoinDappVerifierWithBondResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgJoinDappVerifierWithBondResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgJoinDappVerifierWithBondResponse.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 *MsgJoinDappVerifierWithBondResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgJoinDappVerifierWithBondResponse.Merge(m, src) +} +func (m *MsgJoinDappVerifierWithBondResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgJoinDappVerifierWithBondResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgJoinDappVerifierWithBondResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgJoinDappVerifierWithBondResponse proto.InternalMessageInfo + +// stop being a dApp operator and remove the record in the Execution Registrar. +// Return bonded funds if the operator is a verifier. +type MsgExitDapp struct { + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + DappName string `protobuf:"bytes,2,opt,name=dapp_name,json=dappName,proto3" json:"dapp_name,omitempty"` +} + +func (m *MsgExitDapp) Reset() { *m = MsgExitDapp{} } +func (m *MsgExitDapp) String() string { return proto.CompactTextString(m) } +func (*MsgExitDapp) ProtoMessage() {} +func (*MsgExitDapp) Descriptor() ([]byte, []int) { + return fileDescriptor_c30a928a62b31d6d, []int{8} +} +func (m *MsgExitDapp) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgExitDapp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgExitDapp.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 *MsgExitDapp) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgExitDapp.Merge(m, src) +} +func (m *MsgExitDapp) XXX_Size() int { + return m.Size() +} +func (m *MsgExitDapp) XXX_DiscardUnknown() { + xxx_messageInfo_MsgExitDapp.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgExitDapp proto.InternalMessageInfo + +func (m *MsgExitDapp) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +func (m *MsgExitDapp) GetDappName() string { + if m != nil { + return m.DappName + } + return "" +} + +type MsgExitDappResponse struct { +} + +func (m *MsgExitDappResponse) Reset() { *m = MsgExitDappResponse{} } +func (m *MsgExitDappResponse) String() string { return proto.CompactTextString(m) } +func (*MsgExitDappResponse) ProtoMessage() {} +func (*MsgExitDappResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_c30a928a62b31d6d, []int{9} +} +func (m *MsgExitDappResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgExitDappResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgExitDappResponse.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 *MsgExitDappResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgExitDappResponse.Merge(m, src) +} +func (m *MsgExitDappResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgExitDappResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgExitDappResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgExitDappResponse proto.InternalMessageInfo + +// return lp_ tokens to the pool and redeem KEX or dp_ token +// unless slippage is exceeded then fail the tx. +type MsgRedeemDappPoolTx struct { + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + DappName string `protobuf:"bytes,2,opt,name=dapp_name,json=dappName,proto3" json:"dapp_name,omitempty"` + LpToken github_com_cosmos_cosmos_sdk_types.Coin `protobuf:"bytes,3,opt,name=lp_token,json=lpToken,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Coin" json:"lp_token"` + Slippage github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,4,opt,name=slippage,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"slippage"` +} + +func (m *MsgRedeemDappPoolTx) Reset() { *m = MsgRedeemDappPoolTx{} } +func (m *MsgRedeemDappPoolTx) String() string { return proto.CompactTextString(m) } +func (*MsgRedeemDappPoolTx) ProtoMessage() {} +func (*MsgRedeemDappPoolTx) Descriptor() ([]byte, []int) { + return fileDescriptor_c30a928a62b31d6d, []int{10} +} +func (m *MsgRedeemDappPoolTx) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRedeemDappPoolTx) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRedeemDappPoolTx.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 *MsgRedeemDappPoolTx) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRedeemDappPoolTx.Merge(m, src) +} +func (m *MsgRedeemDappPoolTx) XXX_Size() int { + return m.Size() +} +func (m *MsgRedeemDappPoolTx) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRedeemDappPoolTx.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRedeemDappPoolTx proto.InternalMessageInfo + +func (m *MsgRedeemDappPoolTx) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +func (m *MsgRedeemDappPoolTx) GetDappName() string { + if m != nil { + return m.DappName + } + return "" +} + +type MsgRedeemDappPoolTxResponse struct { +} + +func (m *MsgRedeemDappPoolTxResponse) Reset() { *m = MsgRedeemDappPoolTxResponse{} } +func (m *MsgRedeemDappPoolTxResponse) String() string { return proto.CompactTextString(m) } +func (*MsgRedeemDappPoolTxResponse) ProtoMessage() {} +func (*MsgRedeemDappPoolTxResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_c30a928a62b31d6d, []int{11} +} +func (m *MsgRedeemDappPoolTxResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRedeemDappPoolTxResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRedeemDappPoolTxResponse.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 *MsgRedeemDappPoolTxResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRedeemDappPoolTxResponse.Merge(m, src) +} +func (m *MsgRedeemDappPoolTxResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgRedeemDappPoolTxResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRedeemDappPoolTxResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRedeemDappPoolTxResponse proto.InternalMessageInfo + +// send KEX and receive dp_ or send dp_ and receive KEX unless +// slippage is exceeded then fail the tx. +type MsgSwapDappPoolTx struct { + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + DappName string `protobuf:"bytes,2,opt,name=dapp_name,json=dappName,proto3" json:"dapp_name,omitempty"` + Token github_com_cosmos_cosmos_sdk_types.Coin `protobuf:"bytes,3,opt,name=token,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Coin" json:"token"` + Slippage github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,4,opt,name=slippage,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"slippage"` +} + +func (m *MsgSwapDappPoolTx) Reset() { *m = MsgSwapDappPoolTx{} } +func (m *MsgSwapDappPoolTx) String() string { return proto.CompactTextString(m) } +func (*MsgSwapDappPoolTx) ProtoMessage() {} +func (*MsgSwapDappPoolTx) Descriptor() ([]byte, []int) { + return fileDescriptor_c30a928a62b31d6d, []int{12} +} +func (m *MsgSwapDappPoolTx) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSwapDappPoolTx) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSwapDappPoolTx.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 *MsgSwapDappPoolTx) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSwapDappPoolTx.Merge(m, src) +} +func (m *MsgSwapDappPoolTx) XXX_Size() int { + return m.Size() +} +func (m *MsgSwapDappPoolTx) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSwapDappPoolTx.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSwapDappPoolTx proto.InternalMessageInfo + +func (m *MsgSwapDappPoolTx) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +func (m *MsgSwapDappPoolTx) GetDappName() string { + if m != nil { + return m.DappName + } + return "" +} + +type MsgSwapDappPoolTxResponse struct { +} + +func (m *MsgSwapDappPoolTxResponse) Reset() { *m = MsgSwapDappPoolTxResponse{} } +func (m *MsgSwapDappPoolTxResponse) String() string { return proto.CompactTextString(m) } +func (*MsgSwapDappPoolTxResponse) ProtoMessage() {} +func (*MsgSwapDappPoolTxResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_c30a928a62b31d6d, []int{13} +} +func (m *MsgSwapDappPoolTxResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSwapDappPoolTxResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSwapDappPoolTxResponse.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 *MsgSwapDappPoolTxResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSwapDappPoolTxResponse.Merge(m, src) +} +func (m *MsgSwapDappPoolTxResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgSwapDappPoolTxResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSwapDappPoolTxResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSwapDappPoolTxResponse proto.InternalMessageInfo + +// allow user to convert any dp_ for any other dp_ token unless +// slippage is exceeded then fail the tx. +type MsgConvertDappPoolTx struct { + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + DappName string `protobuf:"bytes,2,opt,name=dapp_name,json=dappName,proto3" json:"dapp_name,omitempty"` + TargetDappName string `protobuf:"bytes,3,opt,name=target_dapp_name,json=targetDappName,proto3" json:"target_dapp_name,omitempty"` + LpToken github_com_cosmos_cosmos_sdk_types.Coin `protobuf:"bytes,4,opt,name=lp_token,json=lpToken,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Coin" json:"lp_token"` + Slippage github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,5,opt,name=slippage,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"slippage"` +} + +func (m *MsgConvertDappPoolTx) Reset() { *m = MsgConvertDappPoolTx{} } +func (m *MsgConvertDappPoolTx) String() string { return proto.CompactTextString(m) } +func (*MsgConvertDappPoolTx) ProtoMessage() {} +func (*MsgConvertDappPoolTx) Descriptor() ([]byte, []int) { + return fileDescriptor_c30a928a62b31d6d, []int{14} +} +func (m *MsgConvertDappPoolTx) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgConvertDappPoolTx) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgConvertDappPoolTx.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 *MsgConvertDappPoolTx) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgConvertDappPoolTx.Merge(m, src) +} +func (m *MsgConvertDappPoolTx) XXX_Size() int { + return m.Size() +} +func (m *MsgConvertDappPoolTx) XXX_DiscardUnknown() { + xxx_messageInfo_MsgConvertDappPoolTx.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgConvertDappPoolTx proto.InternalMessageInfo + +func (m *MsgConvertDappPoolTx) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +func (m *MsgConvertDappPoolTx) GetDappName() string { + if m != nil { + return m.DappName + } + return "" +} + +func (m *MsgConvertDappPoolTx) GetTargetDappName() string { + if m != nil { + return m.TargetDappName + } + return "" +} + +type MsgConvertDappPoolTxResponse struct { +} + +func (m *MsgConvertDappPoolTxResponse) Reset() { *m = MsgConvertDappPoolTxResponse{} } +func (m *MsgConvertDappPoolTxResponse) String() string { return proto.CompactTextString(m) } +func (*MsgConvertDappPoolTxResponse) ProtoMessage() {} +func (*MsgConvertDappPoolTxResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_c30a928a62b31d6d, []int{15} +} +func (m *MsgConvertDappPoolTxResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgConvertDappPoolTxResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgConvertDappPoolTxResponse.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 *MsgConvertDappPoolTxResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgConvertDappPoolTxResponse.Merge(m, src) +} +func (m *MsgConvertDappPoolTxResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgConvertDappPoolTxResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgConvertDappPoolTxResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgConvertDappPoolTxResponse proto.InternalMessageInfo + +// allow executors to change their status to paused. This tx does NOT pause the +// dApp, it only pauses the ability of an executor to continue running the dApp +// in the next session. If the executor is currently running the session then he +// needs to finish it before paused status is applied. +type MsgPauseDappTx struct { + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + DappName string `protobuf:"bytes,2,opt,name=dapp_name,json=dappName,proto3" json:"dapp_name,omitempty"` +} + +func (m *MsgPauseDappTx) Reset() { *m = MsgPauseDappTx{} } +func (m *MsgPauseDappTx) String() string { return proto.CompactTextString(m) } +func (*MsgPauseDappTx) ProtoMessage() {} +func (*MsgPauseDappTx) Descriptor() ([]byte, []int) { + return fileDescriptor_c30a928a62b31d6d, []int{16} +} +func (m *MsgPauseDappTx) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgPauseDappTx) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgPauseDappTx.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 *MsgPauseDappTx) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgPauseDappTx.Merge(m, src) +} +func (m *MsgPauseDappTx) XXX_Size() int { + return m.Size() +} +func (m *MsgPauseDappTx) XXX_DiscardUnknown() { + xxx_messageInfo_MsgPauseDappTx.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgPauseDappTx proto.InternalMessageInfo + +func (m *MsgPauseDappTx) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +func (m *MsgPauseDappTx) GetDappName() string { + if m != nil { + return m.DappName + } + return "" +} + +type MsgPauseDappTxResponse struct { +} + +func (m *MsgPauseDappTxResponse) Reset() { *m = MsgPauseDappTxResponse{} } +func (m *MsgPauseDappTxResponse) String() string { return proto.CompactTextString(m) } +func (*MsgPauseDappTxResponse) ProtoMessage() {} +func (*MsgPauseDappTxResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_c30a928a62b31d6d, []int{17} +} +func (m *MsgPauseDappTxResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgPauseDappTxResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgPauseDappTxResponse.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 *MsgPauseDappTxResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgPauseDappTxResponse.Merge(m, src) +} +func (m *MsgPauseDappTxResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgPauseDappTxResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgPauseDappTxResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgPauseDappTxResponse proto.InternalMessageInfo + +// exit maintenance mode to signal that verifier or executor is ready to operate +// the dApp again. +type MsgUnPauseDappTx struct { + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + DappName string `protobuf:"bytes,2,opt,name=dapp_name,json=dappName,proto3" json:"dapp_name,omitempty"` +} + +func (m *MsgUnPauseDappTx) Reset() { *m = MsgUnPauseDappTx{} } +func (m *MsgUnPauseDappTx) String() string { return proto.CompactTextString(m) } +func (*MsgUnPauseDappTx) ProtoMessage() {} +func (*MsgUnPauseDappTx) Descriptor() ([]byte, []int) { + return fileDescriptor_c30a928a62b31d6d, []int{18} +} +func (m *MsgUnPauseDappTx) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUnPauseDappTx) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUnPauseDappTx.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 *MsgUnPauseDappTx) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUnPauseDappTx.Merge(m, src) +} +func (m *MsgUnPauseDappTx) XXX_Size() int { + return m.Size() +} +func (m *MsgUnPauseDappTx) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUnPauseDappTx.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUnPauseDappTx proto.InternalMessageInfo + +func (m *MsgUnPauseDappTx) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +func (m *MsgUnPauseDappTx) GetDappName() string { + if m != nil { + return m.DappName + } + return "" +} + +type MsgUnPauseDappTxResponse struct { +} + +func (m *MsgUnPauseDappTxResponse) Reset() { *m = MsgUnPauseDappTxResponse{} } +func (m *MsgUnPauseDappTxResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUnPauseDappTxResponse) ProtoMessage() {} +func (*MsgUnPauseDappTxResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_c30a928a62b31d6d, []int{19} +} +func (m *MsgUnPauseDappTxResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUnPauseDappTxResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUnPauseDappTxResponse.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 *MsgUnPauseDappTxResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUnPauseDappTxResponse.Merge(m, src) +} +func (m *MsgUnPauseDappTxResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgUnPauseDappTxResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUnPauseDappTxResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUnPauseDappTxResponse proto.InternalMessageInfo + +// re-activate deactivated dApp operator +type MsgReactivateDappTx struct { + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + DappName string `protobuf:"bytes,2,opt,name=dapp_name,json=dappName,proto3" json:"dapp_name,omitempty"` +} + +func (m *MsgReactivateDappTx) Reset() { *m = MsgReactivateDappTx{} } +func (m *MsgReactivateDappTx) String() string { return proto.CompactTextString(m) } +func (*MsgReactivateDappTx) ProtoMessage() {} +func (*MsgReactivateDappTx) Descriptor() ([]byte, []int) { + return fileDescriptor_c30a928a62b31d6d, []int{20} +} +func (m *MsgReactivateDappTx) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgReactivateDappTx) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgReactivateDappTx.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 *MsgReactivateDappTx) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgReactivateDappTx.Merge(m, src) +} +func (m *MsgReactivateDappTx) XXX_Size() int { + return m.Size() +} +func (m *MsgReactivateDappTx) XXX_DiscardUnknown() { + xxx_messageInfo_MsgReactivateDappTx.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgReactivateDappTx proto.InternalMessageInfo + +func (m *MsgReactivateDappTx) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +func (m *MsgReactivateDappTx) GetDappName() string { + if m != nil { + return m.DappName + } + return "" +} + +type MsgReactivateDappTxResponse struct { +} + +func (m *MsgReactivateDappTxResponse) Reset() { *m = MsgReactivateDappTxResponse{} } +func (m *MsgReactivateDappTxResponse) String() string { return proto.CompactTextString(m) } +func (*MsgReactivateDappTxResponse) ProtoMessage() {} +func (*MsgReactivateDappTxResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_c30a928a62b31d6d, []int{21} +} +func (m *MsgReactivateDappTxResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgReactivateDappTxResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgReactivateDappTxResponse.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 *MsgReactivateDappTxResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgReactivateDappTxResponse.Merge(m, src) +} +func (m *MsgReactivateDappTxResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgReactivateDappTxResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgReactivateDappTxResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgReactivateDappTxResponse proto.InternalMessageInfo + +// allow next session leader to announce or update his IP address and start +// execution. +type MsgExecuteDappTx struct { + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + DappName string `protobuf:"bytes,2,opt,name=dapp_name,json=dappName,proto3" json:"dapp_name,omitempty"` + Gateway string `protobuf:"bytes,3,opt,name=gateway,proto3" json:"gateway,omitempty"` +} + +func (m *MsgExecuteDappTx) Reset() { *m = MsgExecuteDappTx{} } +func (m *MsgExecuteDappTx) String() string { return proto.CompactTextString(m) } +func (*MsgExecuteDappTx) ProtoMessage() {} +func (*MsgExecuteDappTx) Descriptor() ([]byte, []int) { + return fileDescriptor_c30a928a62b31d6d, []int{22} +} +func (m *MsgExecuteDappTx) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgExecuteDappTx) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgExecuteDappTx.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 *MsgExecuteDappTx) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgExecuteDappTx.Merge(m, src) +} +func (m *MsgExecuteDappTx) XXX_Size() int { + return m.Size() +} +func (m *MsgExecuteDappTx) XXX_DiscardUnknown() { + xxx_messageInfo_MsgExecuteDappTx.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgExecuteDappTx proto.InternalMessageInfo + +func (m *MsgExecuteDappTx) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +func (m *MsgExecuteDappTx) GetDappName() string { + if m != nil { + return m.DappName + } + return "" +} + +func (m *MsgExecuteDappTx) GetGateway() string { + if m != nil { + return m.Gateway + } + return "" +} + +type MsgExecuteDappTxResponse struct { +} + +func (m *MsgExecuteDappTxResponse) Reset() { *m = MsgExecuteDappTxResponse{} } +func (m *MsgExecuteDappTxResponse) String() string { return proto.CompactTextString(m) } +func (*MsgExecuteDappTxResponse) ProtoMessage() {} +func (*MsgExecuteDappTxResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_c30a928a62b31d6d, []int{23} +} +func (m *MsgExecuteDappTxResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgExecuteDappTxResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgExecuteDappTxResponse.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 *MsgExecuteDappTxResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgExecuteDappTxResponse.Merge(m, src) +} +func (m *MsgExecuteDappTxResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgExecuteDappTxResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgExecuteDappTxResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgExecuteDappTxResponse proto.InternalMessageInfo + +// allow executors to denounce the current session leader, should take a +// session id as a parameter as well as a true or false flag to allow vote +// change. +type MsgDenounceLeaderTx struct { + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + DappName string `protobuf:"bytes,2,opt,name=dapp_name,json=dappName,proto3" json:"dapp_name,omitempty"` + Leader string `protobuf:"bytes,3,opt,name=leader,proto3" json:"leader,omitempty"` + DenounceText string `protobuf:"bytes,4,opt,name=denounce_text,json=denounceText,proto3" json:"denounce_text,omitempty"` + Version string `protobuf:"bytes,5,opt,name=version,proto3" json:"version,omitempty"` +} + +func (m *MsgDenounceLeaderTx) Reset() { *m = MsgDenounceLeaderTx{} } +func (m *MsgDenounceLeaderTx) String() string { return proto.CompactTextString(m) } +func (*MsgDenounceLeaderTx) ProtoMessage() {} +func (*MsgDenounceLeaderTx) Descriptor() ([]byte, []int) { + return fileDescriptor_c30a928a62b31d6d, []int{24} +} +func (m *MsgDenounceLeaderTx) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgDenounceLeaderTx) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgDenounceLeaderTx.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 *MsgDenounceLeaderTx) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgDenounceLeaderTx.Merge(m, src) +} +func (m *MsgDenounceLeaderTx) XXX_Size() int { + return m.Size() +} +func (m *MsgDenounceLeaderTx) XXX_DiscardUnknown() { + xxx_messageInfo_MsgDenounceLeaderTx.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgDenounceLeaderTx proto.InternalMessageInfo + +func (m *MsgDenounceLeaderTx) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +func (m *MsgDenounceLeaderTx) GetDappName() string { + if m != nil { + return m.DappName + } + return "" +} + +func (m *MsgDenounceLeaderTx) GetLeader() string { + if m != nil { + return m.Leader + } + return "" +} + +func (m *MsgDenounceLeaderTx) GetDenounceText() string { + if m != nil { + return m.DenounceText + } + return "" +} + +func (m *MsgDenounceLeaderTx) GetVersion() string { + if m != nil { + return m.Version + } + return "" +} + +type MsgDenounceLeaderTxResponse struct { +} + +func (m *MsgDenounceLeaderTxResponse) Reset() { *m = MsgDenounceLeaderTxResponse{} } +func (m *MsgDenounceLeaderTxResponse) String() string { return proto.CompactTextString(m) } +func (*MsgDenounceLeaderTxResponse) ProtoMessage() {} +func (*MsgDenounceLeaderTxResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_c30a928a62b31d6d, []int{25} +} +func (m *MsgDenounceLeaderTxResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgDenounceLeaderTxResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgDenounceLeaderTxResponse.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 *MsgDenounceLeaderTxResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgDenounceLeaderTxResponse.Merge(m, src) +} +func (m *MsgDenounceLeaderTxResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgDenounceLeaderTxResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgDenounceLeaderTxResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgDenounceLeaderTxResponse proto.InternalMessageInfo + +// update CURRENT session state (can only be sent by current session leader), +// this tx MUST include dApp version. +type MsgTransitionDappTx struct { + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + DappName string `protobuf:"bytes,2,opt,name=dapp_name,json=dappName,proto3" json:"dapp_name,omitempty"` + StatusHash string `protobuf:"bytes,3,opt,name=status_hash,json=statusHash,proto3" json:"status_hash,omitempty"` + OnchainMessages []*types.Any `protobuf:"bytes,4,rep,name=onchain_messages,json=onchainMessages,proto3" json:"onchain_messages,omitempty"` + Version string `protobuf:"bytes,5,opt,name=version,proto3" json:"version,omitempty"` +} + +func (m *MsgTransitionDappTx) Reset() { *m = MsgTransitionDappTx{} } +func (m *MsgTransitionDappTx) String() string { return proto.CompactTextString(m) } +func (*MsgTransitionDappTx) ProtoMessage() {} +func (*MsgTransitionDappTx) Descriptor() ([]byte, []int) { + return fileDescriptor_c30a928a62b31d6d, []int{26} +} +func (m *MsgTransitionDappTx) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgTransitionDappTx) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgTransitionDappTx.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 *MsgTransitionDappTx) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgTransitionDappTx.Merge(m, src) +} +func (m *MsgTransitionDappTx) XXX_Size() int { + return m.Size() +} +func (m *MsgTransitionDappTx) XXX_DiscardUnknown() { + xxx_messageInfo_MsgTransitionDappTx.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgTransitionDappTx proto.InternalMessageInfo + +func (m *MsgTransitionDappTx) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +func (m *MsgTransitionDappTx) GetDappName() string { + if m != nil { + return m.DappName + } + return "" +} + +func (m *MsgTransitionDappTx) GetStatusHash() string { + if m != nil { + return m.StatusHash + } + return "" +} + +func (m *MsgTransitionDappTx) GetOnchainMessages() []*types.Any { + if m != nil { + return m.OnchainMessages + } + return nil +} + +func (m *MsgTransitionDappTx) GetVersion() string { + if m != nil { + return m.Version + } + return "" +} + +type MsgTransitionDappTxResponse struct { +} + +func (m *MsgTransitionDappTxResponse) Reset() { *m = MsgTransitionDappTxResponse{} } +func (m *MsgTransitionDappTxResponse) String() string { return proto.CompactTextString(m) } +func (*MsgTransitionDappTxResponse) ProtoMessage() {} +func (*MsgTransitionDappTxResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_c30a928a62b31d6d, []int{27} +} +func (m *MsgTransitionDappTxResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgTransitionDappTxResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgTransitionDappTxResponse.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 *MsgTransitionDappTxResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgTransitionDappTxResponse.Merge(m, src) +} +func (m *MsgTransitionDappTxResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgTransitionDappTxResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgTransitionDappTxResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgTransitionDappTxResponse proto.InternalMessageInfo + +// approve CURRENT session state (can only be sent by the verifiers or executors +// who are NOT a leader), this tx MUST include dApp version. +type MsgApproveDappTransitionTx struct { + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + DappName string `protobuf:"bytes,2,opt,name=dapp_name,json=dappName,proto3" json:"dapp_name,omitempty"` + Version string `protobuf:"bytes,3,opt,name=version,proto3" json:"version,omitempty"` +} + +func (m *MsgApproveDappTransitionTx) Reset() { *m = MsgApproveDappTransitionTx{} } +func (m *MsgApproveDappTransitionTx) String() string { return proto.CompactTextString(m) } +func (*MsgApproveDappTransitionTx) ProtoMessage() {} +func (*MsgApproveDappTransitionTx) Descriptor() ([]byte, []int) { + return fileDescriptor_c30a928a62b31d6d, []int{28} +} +func (m *MsgApproveDappTransitionTx) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgApproveDappTransitionTx) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgApproveDappTransitionTx.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 *MsgApproveDappTransitionTx) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgApproveDappTransitionTx.Merge(m, src) +} +func (m *MsgApproveDappTransitionTx) XXX_Size() int { + return m.Size() +} +func (m *MsgApproveDappTransitionTx) XXX_DiscardUnknown() { + xxx_messageInfo_MsgApproveDappTransitionTx.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgApproveDappTransitionTx proto.InternalMessageInfo + +func (m *MsgApproveDappTransitionTx) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +func (m *MsgApproveDappTransitionTx) GetDappName() string { + if m != nil { + return m.DappName + } + return "" +} + +func (m *MsgApproveDappTransitionTx) GetVersion() string { + if m != nil { + return m.Version + } + return "" +} + +type MsgApproveDappTransitionTxResponse struct { +} + +func (m *MsgApproveDappTransitionTxResponse) Reset() { *m = MsgApproveDappTransitionTxResponse{} } +func (m *MsgApproveDappTransitionTxResponse) String() string { return proto.CompactTextString(m) } +func (*MsgApproveDappTransitionTxResponse) ProtoMessage() {} +func (*MsgApproveDappTransitionTxResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_c30a928a62b31d6d, []int{29} +} +func (m *MsgApproveDappTransitionTxResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgApproveDappTransitionTxResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgApproveDappTransitionTxResponse.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 *MsgApproveDappTransitionTxResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgApproveDappTransitionTxResponse.Merge(m, src) +} +func (m *MsgApproveDappTransitionTxResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgApproveDappTransitionTxResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgApproveDappTransitionTxResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgApproveDappTransitionTxResponse proto.InternalMessageInfo + +// reject session transition and immediately set the state of the current +// session to halted, this tx MUST include dApp version and session id. +type MsgRejectDappTransitionTx struct { + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + DappName string `protobuf:"bytes,2,opt,name=dapp_name,json=dappName,proto3" json:"dapp_name,omitempty"` + Version string `protobuf:"bytes,3,opt,name=version,proto3" json:"version,omitempty"` +} + +func (m *MsgRejectDappTransitionTx) Reset() { *m = MsgRejectDappTransitionTx{} } +func (m *MsgRejectDappTransitionTx) String() string { return proto.CompactTextString(m) } +func (*MsgRejectDappTransitionTx) ProtoMessage() {} +func (*MsgRejectDappTransitionTx) Descriptor() ([]byte, []int) { + return fileDescriptor_c30a928a62b31d6d, []int{30} +} +func (m *MsgRejectDappTransitionTx) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRejectDappTransitionTx) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRejectDappTransitionTx.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 *MsgRejectDappTransitionTx) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRejectDappTransitionTx.Merge(m, src) +} +func (m *MsgRejectDappTransitionTx) XXX_Size() int { + return m.Size() +} +func (m *MsgRejectDappTransitionTx) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRejectDappTransitionTx.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRejectDappTransitionTx proto.InternalMessageInfo + +func (m *MsgRejectDappTransitionTx) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +func (m *MsgRejectDappTransitionTx) GetDappName() string { + if m != nil { + return m.DappName + } + return "" +} + +func (m *MsgRejectDappTransitionTx) GetVersion() string { + if m != nil { + return m.Version + } + return "" +} + +type MsgRejectDappTransitionTxResponse struct { +} + +func (m *MsgRejectDappTransitionTxResponse) Reset() { *m = MsgRejectDappTransitionTxResponse{} } +func (m *MsgRejectDappTransitionTxResponse) String() string { return proto.CompactTextString(m) } +func (*MsgRejectDappTransitionTxResponse) ProtoMessage() {} +func (*MsgRejectDappTransitionTxResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_c30a928a62b31d6d, []int{31} +} +func (m *MsgRejectDappTransitionTxResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRejectDappTransitionTxResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRejectDappTransitionTxResponse.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 *MsgRejectDappTransitionTxResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRejectDappTransitionTxResponse.Merge(m, src) +} +func (m *MsgRejectDappTransitionTxResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgRejectDappTransitionTxResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRejectDappTransitionTxResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRejectDappTransitionTxResponse proto.InternalMessageInfo + +// allow user to manually deposit/transfer/withdrawal funds to / from / within +// ABR and communicate with apps by including xam string message. +type MsgTransferDappTx struct { + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + Requests []XAMRequest `protobuf:"bytes,2,rep,name=requests,proto3" json:"requests"` +} + +func (m *MsgTransferDappTx) Reset() { *m = MsgTransferDappTx{} } +func (m *MsgTransferDappTx) String() string { return proto.CompactTextString(m) } +func (*MsgTransferDappTx) ProtoMessage() {} +func (*MsgTransferDappTx) Descriptor() ([]byte, []int) { + return fileDescriptor_c30a928a62b31d6d, []int{32} +} +func (m *MsgTransferDappTx) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgTransferDappTx) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgTransferDappTx.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 *MsgTransferDappTx) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgTransferDappTx.Merge(m, src) +} +func (m *MsgTransferDappTx) XXX_Size() int { + return m.Size() +} +func (m *MsgTransferDappTx) XXX_DiscardUnknown() { + xxx_messageInfo_MsgTransferDappTx.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgTransferDappTx proto.InternalMessageInfo + +func (m *MsgTransferDappTx) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +func (m *MsgTransferDappTx) GetRequests() []XAMRequest { + if m != nil { + return m.Requests + } + return nil +} + +type MsgTransferDappTxResponse struct { +} + +func (m *MsgTransferDappTxResponse) Reset() { *m = MsgTransferDappTxResponse{} } +func (m *MsgTransferDappTxResponse) String() string { return proto.CompactTextString(m) } +func (*MsgTransferDappTxResponse) ProtoMessage() {} +func (*MsgTransferDappTxResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_c30a928a62b31d6d, []int{33} +} +func (m *MsgTransferDappTxResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgTransferDappTxResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgTransferDappTxResponse.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 *MsgTransferDappTxResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgTransferDappTxResponse.Merge(m, src) +} +func (m *MsgTransferDappTxResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgTransferDappTxResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgTransferDappTxResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgTransferDappTxResponse proto.InternalMessageInfo + +// acknowledgement of transfer dapp tx +type MsgAckTransferDappTx struct { + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + Responses []XAMResponse `protobuf:"bytes,2,rep,name=responses,proto3" json:"responses"` +} + +func (m *MsgAckTransferDappTx) Reset() { *m = MsgAckTransferDappTx{} } +func (m *MsgAckTransferDappTx) String() string { return proto.CompactTextString(m) } +func (*MsgAckTransferDappTx) ProtoMessage() {} +func (*MsgAckTransferDappTx) Descriptor() ([]byte, []int) { + return fileDescriptor_c30a928a62b31d6d, []int{34} +} +func (m *MsgAckTransferDappTx) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgAckTransferDappTx) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgAckTransferDappTx.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 *MsgAckTransferDappTx) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgAckTransferDappTx.Merge(m, src) +} +func (m *MsgAckTransferDappTx) XXX_Size() int { + return m.Size() +} +func (m *MsgAckTransferDappTx) XXX_DiscardUnknown() { + xxx_messageInfo_MsgAckTransferDappTx.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgAckTransferDappTx proto.InternalMessageInfo + +func (m *MsgAckTransferDappTx) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +func (m *MsgAckTransferDappTx) GetResponses() []XAMResponse { + if m != nil { + return m.Responses + } + return nil +} + +type MsgAckTransferDappTxResponse struct { +} + +func (m *MsgAckTransferDappTxResponse) Reset() { *m = MsgAckTransferDappTxResponse{} } +func (m *MsgAckTransferDappTxResponse) String() string { return proto.CompactTextString(m) } +func (*MsgAckTransferDappTxResponse) ProtoMessage() {} +func (*MsgAckTransferDappTxResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_c30a928a62b31d6d, []int{35} +} +func (m *MsgAckTransferDappTxResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgAckTransferDappTxResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgAckTransferDappTxResponse.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 *MsgAckTransferDappTxResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgAckTransferDappTxResponse.Merge(m, src) +} +func (m *MsgAckTransferDappTxResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgAckTransferDappTxResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgAckTransferDappTxResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgAckTransferDappTxResponse proto.InternalMessageInfo + +// create new fungible token record in the minting module +type MsgMintCreateFtTx struct { + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + DenomSuffix string `protobuf:"bytes,2,opt,name=denom_suffix,json=denomSuffix,proto3" json:"denom_suffix,omitempty"` + Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"` + Symbol string `protobuf:"bytes,4,opt,name=symbol,proto3" json:"symbol,omitempty"` + Icon string `protobuf:"bytes,5,opt,name=icon,proto3" json:"icon,omitempty"` + Description string `protobuf:"bytes,6,opt,name=description,proto3" json:"description,omitempty"` + Website string `protobuf:"bytes,7,opt,name=website,proto3" json:"website,omitempty"` + Social string `protobuf:"bytes,8,opt,name=social,proto3" json:"social,omitempty"` + Decimals uint64 `protobuf:"varint,9,opt,name=decimals,proto3" json:"decimals,omitempty"` + Cap github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,10,opt,name=cap,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"cap"` + Supply github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,11,opt,name=supply,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"supply"` + Holders uint64 `protobuf:"varint,12,opt,name=holders,proto3" json:"holders,omitempty"` + Fee github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,13,opt,name=fee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"fee"` + Owner string `protobuf:"bytes,14,opt,name=owner,proto3" json:"owner,omitempty"` +} + +func (m *MsgMintCreateFtTx) Reset() { *m = MsgMintCreateFtTx{} } +func (m *MsgMintCreateFtTx) String() string { return proto.CompactTextString(m) } +func (*MsgMintCreateFtTx) ProtoMessage() {} +func (*MsgMintCreateFtTx) Descriptor() ([]byte, []int) { + return fileDescriptor_c30a928a62b31d6d, []int{36} +} +func (m *MsgMintCreateFtTx) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgMintCreateFtTx) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgMintCreateFtTx.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 *MsgMintCreateFtTx) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgMintCreateFtTx.Merge(m, src) +} +func (m *MsgMintCreateFtTx) XXX_Size() int { + return m.Size() +} +func (m *MsgMintCreateFtTx) XXX_DiscardUnknown() { + xxx_messageInfo_MsgMintCreateFtTx.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgMintCreateFtTx proto.InternalMessageInfo + +func (m *MsgMintCreateFtTx) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +func (m *MsgMintCreateFtTx) GetDenomSuffix() string { + if m != nil { + return m.DenomSuffix + } + return "" +} + +func (m *MsgMintCreateFtTx) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *MsgMintCreateFtTx) GetSymbol() string { + if m != nil { + return m.Symbol + } + return "" +} + +func (m *MsgMintCreateFtTx) GetIcon() string { + if m != nil { + return m.Icon + } + return "" +} + +func (m *MsgMintCreateFtTx) GetDescription() string { + if m != nil { + return m.Description + } + return "" +} + +func (m *MsgMintCreateFtTx) GetWebsite() string { + if m != nil { + return m.Website + } + return "" +} + +func (m *MsgMintCreateFtTx) GetSocial() string { + if m != nil { + return m.Social + } + return "" +} + +func (m *MsgMintCreateFtTx) GetDecimals() uint64 { + if m != nil { + return m.Decimals + } + return 0 +} + +func (m *MsgMintCreateFtTx) GetHolders() uint64 { + if m != nil { + return m.Holders + } + return 0 +} + +func (m *MsgMintCreateFtTx) GetOwner() string { + if m != nil { + return m.Owner + } + return "" +} + +type MsgMintCreateFtTxResponse struct { +} + +func (m *MsgMintCreateFtTxResponse) Reset() { *m = MsgMintCreateFtTxResponse{} } +func (m *MsgMintCreateFtTxResponse) String() string { return proto.CompactTextString(m) } +func (*MsgMintCreateFtTxResponse) ProtoMessage() {} +func (*MsgMintCreateFtTxResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_c30a928a62b31d6d, []int{37} +} +func (m *MsgMintCreateFtTxResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgMintCreateFtTxResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgMintCreateFtTxResponse.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 *MsgMintCreateFtTxResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgMintCreateFtTxResponse.Merge(m, src) +} +func (m *MsgMintCreateFtTxResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgMintCreateFtTxResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgMintCreateFtTxResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgMintCreateFtTxResponse proto.InternalMessageInfo + +// create new non-fungible token record in the minting module +type MsgMintCreateNftTx struct { + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + DenomSuffix string `protobuf:"bytes,2,opt,name=denom_suffix,json=denomSuffix,proto3" json:"denom_suffix,omitempty"` + Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"` + Symbol string `protobuf:"bytes,4,opt,name=symbol,proto3" json:"symbol,omitempty"` + Icon string `protobuf:"bytes,5,opt,name=icon,proto3" json:"icon,omitempty"` + Description string `protobuf:"bytes,6,opt,name=description,proto3" json:"description,omitempty"` + Website string `protobuf:"bytes,7,opt,name=website,proto3" json:"website,omitempty"` + Social string `protobuf:"bytes,8,opt,name=social,proto3" json:"social,omitempty"` + Decimals uint64 `protobuf:"varint,9,opt,name=decimals,proto3" json:"decimals,omitempty"` + Cap github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,10,opt,name=cap,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"cap"` + Supply github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,11,opt,name=supply,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"supply"` + Holders uint64 `protobuf:"varint,12,opt,name=holders,proto3" json:"holders,omitempty"` + Fee github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,13,opt,name=fee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"fee"` + Owner string `protobuf:"bytes,14,opt,name=owner,proto3" json:"owner,omitempty"` + Metadata string `protobuf:"bytes,15,opt,name=metadata,proto3" json:"metadata,omitempty"` + Hash string `protobuf:"bytes,16,opt,name=hash,proto3" json:"hash,omitempty"` +} + +func (m *MsgMintCreateNftTx) Reset() { *m = MsgMintCreateNftTx{} } +func (m *MsgMintCreateNftTx) String() string { return proto.CompactTextString(m) } +func (*MsgMintCreateNftTx) ProtoMessage() {} +func (*MsgMintCreateNftTx) Descriptor() ([]byte, []int) { + return fileDescriptor_c30a928a62b31d6d, []int{38} +} +func (m *MsgMintCreateNftTx) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgMintCreateNftTx) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgMintCreateNftTx.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 *MsgMintCreateNftTx) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgMintCreateNftTx.Merge(m, src) +} +func (m *MsgMintCreateNftTx) XXX_Size() int { + return m.Size() +} +func (m *MsgMintCreateNftTx) XXX_DiscardUnknown() { + xxx_messageInfo_MsgMintCreateNftTx.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgMintCreateNftTx proto.InternalMessageInfo + +func (m *MsgMintCreateNftTx) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +func (m *MsgMintCreateNftTx) GetDenomSuffix() string { + if m != nil { + return m.DenomSuffix + } + return "" +} + +func (m *MsgMintCreateNftTx) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *MsgMintCreateNftTx) GetSymbol() string { + if m != nil { + return m.Symbol + } + return "" +} + +func (m *MsgMintCreateNftTx) GetIcon() string { + if m != nil { + return m.Icon + } + return "" +} + +func (m *MsgMintCreateNftTx) GetDescription() string { + if m != nil { + return m.Description + } + return "" +} + +func (m *MsgMintCreateNftTx) GetWebsite() string { + if m != nil { + return m.Website + } + return "" +} + +func (m *MsgMintCreateNftTx) GetSocial() string { + if m != nil { + return m.Social + } + return "" +} + +func (m *MsgMintCreateNftTx) GetDecimals() uint64 { + if m != nil { + return m.Decimals + } + return 0 +} + +func (m *MsgMintCreateNftTx) GetHolders() uint64 { + if m != nil { + return m.Holders + } + return 0 +} + +func (m *MsgMintCreateNftTx) GetOwner() string { + if m != nil { + return m.Owner + } + return "" +} + +func (m *MsgMintCreateNftTx) GetMetadata() string { + if m != nil { + return m.Metadata + } + return "" +} + +func (m *MsgMintCreateNftTx) GetHash() string { + if m != nil { + return m.Hash + } + return "" +} + +type MsgMintCreateNftTxResponse struct { +} + +func (m *MsgMintCreateNftTxResponse) Reset() { *m = MsgMintCreateNftTxResponse{} } +func (m *MsgMintCreateNftTxResponse) String() string { return proto.CompactTextString(m) } +func (*MsgMintCreateNftTxResponse) ProtoMessage() {} +func (*MsgMintCreateNftTxResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_c30a928a62b31d6d, []int{39} +} +func (m *MsgMintCreateNftTxResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgMintCreateNftTxResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgMintCreateNftTxResponse.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 *MsgMintCreateNftTxResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgMintCreateNftTxResponse.Merge(m, src) +} +func (m *MsgMintCreateNftTxResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgMintCreateNftTxResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgMintCreateNftTxResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgMintCreateNftTxResponse proto.InternalMessageInfo + +// allow owner to mint new tokens or anyone if the minting-fee is set to value +// other then 0. +type MsgMintIssueTx struct { + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + Denom string `protobuf:"bytes,2,opt,name=denom,proto3" json:"denom,omitempty"` + Amount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=amount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"amount"` + Receiver string `protobuf:"bytes,4,opt,name=receiver,proto3" json:"receiver,omitempty"` +} + +func (m *MsgMintIssueTx) Reset() { *m = MsgMintIssueTx{} } +func (m *MsgMintIssueTx) String() string { return proto.CompactTextString(m) } +func (*MsgMintIssueTx) ProtoMessage() {} +func (*MsgMintIssueTx) Descriptor() ([]byte, []int) { + return fileDescriptor_c30a928a62b31d6d, []int{40} +} +func (m *MsgMintIssueTx) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgMintIssueTx) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgMintIssueTx.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 *MsgMintIssueTx) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgMintIssueTx.Merge(m, src) +} +func (m *MsgMintIssueTx) XXX_Size() int { + return m.Size() +} +func (m *MsgMintIssueTx) XXX_DiscardUnknown() { + xxx_messageInfo_MsgMintIssueTx.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgMintIssueTx proto.InternalMessageInfo + +func (m *MsgMintIssueTx) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +func (m *MsgMintIssueTx) GetDenom() string { + if m != nil { + return m.Denom + } + return "" +} + +func (m *MsgMintIssueTx) GetReceiver() string { + if m != nil { + return m.Receiver + } + return "" +} + +type MsgMintIssueTxResponse struct { +} + +func (m *MsgMintIssueTxResponse) Reset() { *m = MsgMintIssueTxResponse{} } +func (m *MsgMintIssueTxResponse) String() string { return proto.CompactTextString(m) } +func (*MsgMintIssueTxResponse) ProtoMessage() {} +func (*MsgMintIssueTxResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_c30a928a62b31d6d, []int{41} +} +func (m *MsgMintIssueTxResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgMintIssueTxResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgMintIssueTxResponse.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 *MsgMintIssueTxResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgMintIssueTxResponse.Merge(m, src) +} +func (m *MsgMintIssueTxResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgMintIssueTxResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgMintIssueTxResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgMintIssueTxResponse proto.InternalMessageInfo + +// allow anyone burn the tokens they own +type MsgMintBurnTx struct { + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + Denom string `protobuf:"bytes,2,opt,name=denom,proto3" json:"denom,omitempty"` + Amount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=amount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"amount"` +} + +func (m *MsgMintBurnTx) Reset() { *m = MsgMintBurnTx{} } +func (m *MsgMintBurnTx) String() string { return proto.CompactTextString(m) } +func (*MsgMintBurnTx) ProtoMessage() {} +func (*MsgMintBurnTx) Descriptor() ([]byte, []int) { + return fileDescriptor_c30a928a62b31d6d, []int{42} +} +func (m *MsgMintBurnTx) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgMintBurnTx) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgMintBurnTx.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 *MsgMintBurnTx) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgMintBurnTx.Merge(m, src) +} +func (m *MsgMintBurnTx) XXX_Size() int { + return m.Size() +} +func (m *MsgMintBurnTx) XXX_DiscardUnknown() { + xxx_messageInfo_MsgMintBurnTx.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgMintBurnTx proto.InternalMessageInfo + +func (m *MsgMintBurnTx) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +func (m *MsgMintBurnTx) GetDenom() string { + if m != nil { + return m.Denom + } + return "" +} + +type MsgMintBurnTxResponse struct { +} + +func (m *MsgMintBurnTxResponse) Reset() { *m = MsgMintBurnTxResponse{} } +func (m *MsgMintBurnTxResponse) String() string { return proto.CompactTextString(m) } +func (*MsgMintBurnTxResponse) ProtoMessage() {} +func (*MsgMintBurnTxResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_c30a928a62b31d6d, []int{43} +} +func (m *MsgMintBurnTxResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgMintBurnTxResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgMintBurnTxResponse.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 *MsgMintBurnTxResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgMintBurnTxResponse.Merge(m, src) +} +func (m *MsgMintBurnTxResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgMintBurnTxResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgMintBurnTxResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgMintBurnTxResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*MsgCreateDappProposal)(nil), "kira.layer2.MsgCreateDappProposal") + proto.RegisterType((*MsgCreateDappProposalResponse)(nil), "kira.layer2.MsgCreateDappProposalResponse") + proto.RegisterType((*MsgBondDappProposal)(nil), "kira.layer2.MsgBondDappProposal") + proto.RegisterType((*MsgBondDappProposalResponse)(nil), "kira.layer2.MsgBondDappProposalResponse") + proto.RegisterType((*MsgReclaimDappBondProposal)(nil), "kira.layer2.MsgReclaimDappBondProposal") + proto.RegisterType((*MsgReclaimDappBondProposalResponse)(nil), "kira.layer2.MsgReclaimDappBondProposalResponse") + proto.RegisterType((*MsgJoinDappVerifierWithBond)(nil), "kira.layer2.MsgJoinDappVerifierWithBond") + proto.RegisterType((*MsgJoinDappVerifierWithBondResponse)(nil), "kira.layer2.MsgJoinDappVerifierWithBondResponse") + proto.RegisterType((*MsgExitDapp)(nil), "kira.layer2.MsgExitDapp") + proto.RegisterType((*MsgExitDappResponse)(nil), "kira.layer2.MsgExitDappResponse") + proto.RegisterType((*MsgRedeemDappPoolTx)(nil), "kira.layer2.MsgRedeemDappPoolTx") + proto.RegisterType((*MsgRedeemDappPoolTxResponse)(nil), "kira.layer2.MsgRedeemDappPoolTxResponse") + proto.RegisterType((*MsgSwapDappPoolTx)(nil), "kira.layer2.MsgSwapDappPoolTx") + proto.RegisterType((*MsgSwapDappPoolTxResponse)(nil), "kira.layer2.MsgSwapDappPoolTxResponse") + proto.RegisterType((*MsgConvertDappPoolTx)(nil), "kira.layer2.MsgConvertDappPoolTx") + proto.RegisterType((*MsgConvertDappPoolTxResponse)(nil), "kira.layer2.MsgConvertDappPoolTxResponse") + proto.RegisterType((*MsgPauseDappTx)(nil), "kira.layer2.MsgPauseDappTx") + proto.RegisterType((*MsgPauseDappTxResponse)(nil), "kira.layer2.MsgPauseDappTxResponse") + proto.RegisterType((*MsgUnPauseDappTx)(nil), "kira.layer2.MsgUnPauseDappTx") + proto.RegisterType((*MsgUnPauseDappTxResponse)(nil), "kira.layer2.MsgUnPauseDappTxResponse") + proto.RegisterType((*MsgReactivateDappTx)(nil), "kira.layer2.MsgReactivateDappTx") + proto.RegisterType((*MsgReactivateDappTxResponse)(nil), "kira.layer2.MsgReactivateDappTxResponse") + proto.RegisterType((*MsgExecuteDappTx)(nil), "kira.layer2.MsgExecuteDappTx") + proto.RegisterType((*MsgExecuteDappTxResponse)(nil), "kira.layer2.MsgExecuteDappTxResponse") + proto.RegisterType((*MsgDenounceLeaderTx)(nil), "kira.layer2.MsgDenounceLeaderTx") + proto.RegisterType((*MsgDenounceLeaderTxResponse)(nil), "kira.layer2.MsgDenounceLeaderTxResponse") + proto.RegisterType((*MsgTransitionDappTx)(nil), "kira.layer2.MsgTransitionDappTx") + proto.RegisterType((*MsgTransitionDappTxResponse)(nil), "kira.layer2.MsgTransitionDappTxResponse") + proto.RegisterType((*MsgApproveDappTransitionTx)(nil), "kira.layer2.MsgApproveDappTransitionTx") + proto.RegisterType((*MsgApproveDappTransitionTxResponse)(nil), "kira.layer2.MsgApproveDappTransitionTxResponse") + proto.RegisterType((*MsgRejectDappTransitionTx)(nil), "kira.layer2.MsgRejectDappTransitionTx") + proto.RegisterType((*MsgRejectDappTransitionTxResponse)(nil), "kira.layer2.MsgRejectDappTransitionTxResponse") + proto.RegisterType((*MsgTransferDappTx)(nil), "kira.layer2.MsgTransferDappTx") + proto.RegisterType((*MsgTransferDappTxResponse)(nil), "kira.layer2.MsgTransferDappTxResponse") + proto.RegisterType((*MsgAckTransferDappTx)(nil), "kira.layer2.MsgAckTransferDappTx") + proto.RegisterType((*MsgAckTransferDappTxResponse)(nil), "kira.layer2.MsgAckTransferDappTxResponse") + proto.RegisterType((*MsgMintCreateFtTx)(nil), "kira.layer2.MsgMintCreateFtTx") + proto.RegisterType((*MsgMintCreateFtTxResponse)(nil), "kira.layer2.MsgMintCreateFtTxResponse") + proto.RegisterType((*MsgMintCreateNftTx)(nil), "kira.layer2.MsgMintCreateNftTx") + proto.RegisterType((*MsgMintCreateNftTxResponse)(nil), "kira.layer2.MsgMintCreateNftTxResponse") + proto.RegisterType((*MsgMintIssueTx)(nil), "kira.layer2.MsgMintIssueTx") + proto.RegisterType((*MsgMintIssueTxResponse)(nil), "kira.layer2.MsgMintIssueTxResponse") + proto.RegisterType((*MsgMintBurnTx)(nil), "kira.layer2.MsgMintBurnTx") + proto.RegisterType((*MsgMintBurnTxResponse)(nil), "kira.layer2.MsgMintBurnTxResponse") +} + +func init() { proto.RegisterFile("kira/layer2/tx.proto", fileDescriptor_c30a928a62b31d6d) } + +var fileDescriptor_c30a928a62b31d6d = []byte{ + // 1591 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x59, 0xdd, 0x6f, 0x1b, 0xc5, + 0x16, 0x8f, 0x1b, 0x27, 0x4d, 0x8e, 0x9b, 0x34, 0xdd, 0x9b, 0xa6, 0xdb, 0x4d, 0xe3, 0xb8, 0xce, + 0x6d, 0x9b, 0x7b, 0xaf, 0xae, 0x8d, 0xc2, 0x13, 0x12, 0x12, 0xe4, 0x13, 0x5a, 0xea, 0x52, 0x6d, + 0x53, 0xa8, 0x40, 0xc2, 0x9a, 0xac, 0xc7, 0x9b, 0x6d, 0xd6, 0x3b, 0xcb, 0xce, 0x3a, 0x71, 0xfe, + 0x00, 0x1e, 0x11, 0x3c, 0xf1, 0x5e, 0x9e, 0x90, 0x78, 0xe7, 0x4f, 0x40, 0x7d, 0xec, 0x23, 0x02, + 0xa9, 0x42, 0xe9, 0x7f, 0xc1, 0x13, 0x9a, 0x8f, 0x9d, 0x7a, 0xbf, 0xe2, 0xd4, 0x2e, 0x02, 0x09, + 0x9e, 0xe2, 0x33, 0xe7, 0xeb, 0x77, 0xce, 0x9c, 0x9d, 0x39, 0x67, 0x02, 0xf3, 0x07, 0x4e, 0x80, + 0xea, 0x2e, 0x3a, 0xc6, 0xc1, 0x5a, 0x3d, 0xec, 0xd5, 0xfc, 0x80, 0x84, 0x44, 0x2b, 0xb1, 0xd5, + 0x9a, 0x58, 0x35, 0xe6, 0x6d, 0x62, 0x13, 0xbe, 0x5e, 0x67, 0xbf, 0x84, 0x88, 0x71, 0xd5, 0x26, + 0xc4, 0x76, 0x71, 0x9d, 0x53, 0x7b, 0xdd, 0x76, 0x1d, 0x79, 0xc7, 0x11, 0xcb, 0x22, 0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b8, 0xf7, 0xda, 0xff, 0x94, + 0xc6, 0xdf, 0xa5, 0x34, 0x58, 0x5e, 0x3a, 0x38, 0x44, 0x2d, 0x14, 0x22, 0xfd, 0xa2, 0x38, 0x85, + 0x23, 0x9a, 0xed, 0x0d, 0xbf, 0xfe, 0xe6, 0xc4, 0xde, 0xb0, 0xdf, 0xd5, 0x6b, 0xfc, 0xfa, 0x49, + 0x14, 0x8b, 0xaa, 0xa5, 0x6f, 0x0b, 0xbc, 0xf1, 0x63, 0xec, 0xdb, 0x94, 0x76, 0xf1, 0x29, 0x75, + 0x34, 0x0f, 0x13, 0xbc, 0x66, 0x64, 0x01, 0x09, 0x82, 0x25, 0x12, 0x75, 0x48, 0xd7, 0x0b, 0xe5, + 0x64, 0xf0, 0xca, 0x89, 0x14, 0xda, 0x2c, 0xac, 0x00, 0x5b, 0xd8, 0x39, 0xc4, 0x81, 0x2c, 0x38, + 0x45, 0xcb, 0xae, 0xb2, 0x0f, 0xa3, 0x82, 0xff, 0x45, 0x01, 0x66, 0x24, 0x6b, 0xa3, 0x1b, 0x78, + 0x7f, 0x16, 0xfa, 0xea, 0x15, 0xfe, 0x1e, 0xf3, 0x12, 0x46, 0x04, 0x70, 0xed, 0x87, 0x39, 0x18, + 0x6f, 0x50, 0x5b, 0x6b, 0x81, 0x96, 0xf1, 0x5a, 0x53, 0x8d, 0x5d, 0x17, 0x99, 0xcf, 0x25, 0xc6, + 0x7f, 0x07, 0xcb, 0x44, 0xde, 0xb4, 0xcf, 0x60, 0x2e, 0xf5, 0x9c, 0x52, 0x49, 0xea, 0x27, 0x25, + 0x8c, 0xd5, 0x41, 0x12, 0xca, 0x3e, 0x85, 0x2b, 0x79, 0xaf, 0x1f, 0xb7, 0x92, 0x46, 0x72, 0x04, + 0x8d, 0xfa, 0x19, 0x05, 0x95, 0xd3, 0x43, 0xd0, 0x73, 0x1f, 0x2d, 0x52, 0xd0, 0xf3, 0x24, 0x8d, + 0x37, 0xce, 0x2a, 0xa9, 0xfc, 0xee, 0xc0, 0x94, 0x7a, 0x99, 0xd0, 0x93, 0xda, 0x11, 0xc7, 0xa8, + 0xe4, 0x71, 0xfa, 0x37, 0x25, 0xf5, 0x0a, 0x51, 0x49, 0x27, 0x21, 0x2e, 0x91, 0xde, 0x94, 0xbc, + 0x29, 0x5f, 0x7b, 0x04, 0xb3, 0x89, 0x09, 0xbf, 0x9c, 0xd4, 0x8d, 0xf3, 0x8d, 0x9b, 0xa7, 0xf3, + 0x95, 0x65, 0x04, 0x97, 0xd2, 0x03, 0xf4, 0xf5, 0x54, 0x3d, 0x26, 0x45, 0x8c, 0xff, 0x0c, 0x14, + 0x51, 0x2e, 0x3e, 0x84, 0x52, 0xff, 0x44, 0xb8, 0x98, 0xd4, 0xec, 0x63, 0x1a, 0x2b, 0xa7, 0x30, + 0x95, 0xc1, 0x87, 0x30, 0x13, 0x1f, 0x32, 0x97, 0x92, 0x5a, 0x31, 0xb6, 0x71, 0xe3, 0x54, 0x76, + 0x7c, 0x13, 0x13, 0x63, 0x65, 0xc6, 0x26, 0xc6, 0x25, 0xb2, 0x36, 0x31, 0x7b, 0x9c, 0x64, 0xb0, + 0xe3, 0xb3, 0xe4, 0x52, 0xba, 0xae, 0xfa, 0xd8, 0x69, 0xd8, 0x99, 0x63, 0x22, 0x83, 0x9d, 0x1a, + 0x11, 0x53, 0xb0, 0x93, 0x12, 0x69, 0xd8, 0x79, 0x33, 0x1c, 0xb3, 0x9f, 0x9a, 0xdf, 0x52, 0xf6, + 0x93, 0x12, 0x69, 0xfb, 0x79, 0xb3, 0x13, 0x3b, 0x70, 0xf2, 0x06, 0xa7, 0xd4, 0x81, 0x93, 0x23, + 0x98, 0x3e, 0x70, 0x06, 0x4c, 0x47, 0x9a, 0x0f, 0x0b, 0x39, 0xa3, 0xd1, 0xcd, 0xf4, 0x7e, 0x66, + 0xc9, 0x19, 0xb5, 0xb3, 0xc9, 0xf5, 0x7f, 0xc2, 0x89, 0x99, 0xa3, 0x9c, 0x99, 0x22, 0xc5, 0x4f, + 0x7f, 0xc2, 0xd9, 0x53, 0x04, 0xfb, 0x84, 0xd3, 0x03, 0x4d, 0xea, 0x13, 0x4e, 0x89, 0xa4, 0x3f, + 0xe1, 0xdc, 0x41, 0x85, 0x81, 0x4f, 0x0c, 0x29, 0x29, 0xf0, 0x71, 0x7e, 0x1a, 0x7c, 0x76, 0xa3, + 0xab, 0x7d, 0x0a, 0x17, 0x93, 0x4d, 0xee, 0x72, 0xbe, 0x2a, 0x17, 0x30, 0x6e, 0x0d, 0x10, 0xe8, + 0x3f, 0x79, 0xfa, 0xbb, 0x9e, 0xc5, 0x2c, 0x3d, 0xc9, 0x4c, 0x9f, 0x3c, 0x19, 0xbd, 0x88, 0x76, + 0x17, 0xa0, 0xaf, 0x0f, 0x31, 0xb2, 0x54, 0x04, 0xcf, 0xa8, 0xe6, 0xf3, 0xd4, 0xbc, 0xb8, 0xf3, + 0xdd, 0x49, 0xb9, 0xf0, 0xf4, 0xa4, 0x5c, 0x78, 0x76, 0x52, 0x2e, 0xfc, 0x7a, 0x52, 0x2e, 0x7c, + 0xfd, 0xa2, 0x3c, 0xf6, 0xec, 0x45, 0x79, 0xec, 0xa7, 0x17, 0xe5, 0xb1, 0x4f, 0x56, 0xfb, 0xfa, + 0x93, 0x0f, 0x9c, 0x00, 0x6d, 0x92, 0x00, 0xd7, 0x29, 0x3e, 0x40, 0x4e, 0xbd, 0xa7, 0xfe, 0x41, + 0xc5, 0xba, 0x94, 0xbd, 0x49, 0xfe, 0xaa, 0xf1, 0xe6, 0xef, 0x01, 0x00, 0x00, 0xff, 0xff, 0x78, + 0xfc, 0x9a, 0xb8, 0xbc, 0x1a, 0x00, 0x00, +} + +func (this *MsgCreateDappProposal) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*MsgCreateDappProposal) + if !ok { + that2, ok := that.(MsgCreateDappProposal) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Sender != that1.Sender { + return false + } + if !this.Dapp.Equal(&that1.Dapp) { + return false + } + if !this.Bond.Equal(that1.Bond) { + return false + } + return true +} +func (this *MsgCreateDappProposalResponse) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*MsgCreateDappProposalResponse) + if !ok { + that2, ok := that.(MsgCreateDappProposalResponse) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + return true +} +func (this *MsgBondDappProposal) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*MsgBondDappProposal) + if !ok { + that2, ok := that.(MsgBondDappProposal) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Sender != that1.Sender { + return false + } + if this.DappName != that1.DappName { + return false + } + if !this.Bond.Equal(that1.Bond) { + return false + } + return true +} +func (this *MsgBondDappProposalResponse) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*MsgBondDappProposalResponse) + if !ok { + that2, ok := that.(MsgBondDappProposalResponse) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + return true +} +func (this *MsgReclaimDappBondProposal) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*MsgReclaimDappBondProposal) + if !ok { + that2, ok := that.(MsgReclaimDappBondProposal) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Sender != that1.Sender { + return false + } + if this.DappName != that1.DappName { + return false + } + if !this.Bond.Equal(that1.Bond) { + return false + } + return true +} +func (this *MsgReclaimDappBondProposalResponse) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*MsgReclaimDappBondProposalResponse) + if !ok { + that2, ok := that.(MsgReclaimDappBondProposalResponse) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + return true +} +func (this *MsgJoinDappVerifierWithBond) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*MsgJoinDappVerifierWithBond) + if !ok { + that2, ok := that.(MsgJoinDappVerifierWithBond) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Sender != that1.Sender { + return false + } + if this.DappName != that1.DappName { + return false + } + if this.Interx != that1.Interx { + return false + } + return true +} +func (this *MsgJoinDappVerifierWithBondResponse) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*MsgJoinDappVerifierWithBondResponse) + if !ok { + that2, ok := that.(MsgJoinDappVerifierWithBondResponse) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + return true +} +func (this *MsgExitDapp) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*MsgExitDapp) + if !ok { + that2, ok := that.(MsgExitDapp) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Sender != that1.Sender { + return false + } + if this.DappName != that1.DappName { + return false + } + return true +} +func (this *MsgExitDappResponse) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*MsgExitDappResponse) + if !ok { + that2, ok := that.(MsgExitDappResponse) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + return true +} +func (this *MsgRedeemDappPoolTx) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*MsgRedeemDappPoolTx) + if !ok { + that2, ok := that.(MsgRedeemDappPoolTx) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Sender != that1.Sender { + return false + } + if this.DappName != that1.DappName { + return false + } + if !this.LpToken.Equal(that1.LpToken) { + return false + } + if !this.Slippage.Equal(that1.Slippage) { + return false + } + return true +} +func (this *MsgRedeemDappPoolTxResponse) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*MsgRedeemDappPoolTxResponse) + if !ok { + that2, ok := that.(MsgRedeemDappPoolTxResponse) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + return true +} +func (this *MsgSwapDappPoolTx) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*MsgSwapDappPoolTx) + if !ok { + that2, ok := that.(MsgSwapDappPoolTx) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Sender != that1.Sender { + return false + } + if this.DappName != that1.DappName { + return false + } + if !this.Token.Equal(that1.Token) { + return false + } + if !this.Slippage.Equal(that1.Slippage) { + return false + } + return true +} +func (this *MsgSwapDappPoolTxResponse) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*MsgSwapDappPoolTxResponse) + if !ok { + that2, ok := that.(MsgSwapDappPoolTxResponse) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + return true +} +func (this *MsgConvertDappPoolTx) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*MsgConvertDappPoolTx) + if !ok { + that2, ok := that.(MsgConvertDappPoolTx) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Sender != that1.Sender { + return false + } + if this.DappName != that1.DappName { + return false + } + if this.TargetDappName != that1.TargetDappName { + return false + } + if !this.LpToken.Equal(that1.LpToken) { + return false + } + if !this.Slippage.Equal(that1.Slippage) { + return false + } + return true +} +func (this *MsgConvertDappPoolTxResponse) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*MsgConvertDappPoolTxResponse) + if !ok { + that2, ok := that.(MsgConvertDappPoolTxResponse) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + return true +} +func (this *MsgPauseDappTx) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*MsgPauseDappTx) + if !ok { + that2, ok := that.(MsgPauseDappTx) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Sender != that1.Sender { + return false + } + if this.DappName != that1.DappName { + return false + } + return true +} +func (this *MsgPauseDappTxResponse) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*MsgPauseDappTxResponse) + if !ok { + that2, ok := that.(MsgPauseDappTxResponse) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + return true +} +func (this *MsgUnPauseDappTx) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*MsgUnPauseDappTx) + if !ok { + that2, ok := that.(MsgUnPauseDappTx) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Sender != that1.Sender { + return false + } + if this.DappName != that1.DappName { + return false + } + return true +} +func (this *MsgUnPauseDappTxResponse) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*MsgUnPauseDappTxResponse) + if !ok { + that2, ok := that.(MsgUnPauseDappTxResponse) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + return true +} +func (this *MsgReactivateDappTx) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*MsgReactivateDappTx) + if !ok { + that2, ok := that.(MsgReactivateDappTx) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Sender != that1.Sender { + return false + } + if this.DappName != that1.DappName { + return false + } + return true +} +func (this *MsgReactivateDappTxResponse) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*MsgReactivateDappTxResponse) + if !ok { + that2, ok := that.(MsgReactivateDappTxResponse) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + return true +} +func (this *MsgExecuteDappTx) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*MsgExecuteDappTx) + if !ok { + that2, ok := that.(MsgExecuteDappTx) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Sender != that1.Sender { + return false + } + if this.DappName != that1.DappName { + return false + } + if this.Gateway != that1.Gateway { + return false + } + return true +} +func (this *MsgExecuteDappTxResponse) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*MsgExecuteDappTxResponse) + if !ok { + that2, ok := that.(MsgExecuteDappTxResponse) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + return true +} +func (this *MsgDenounceLeaderTx) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*MsgDenounceLeaderTx) + if !ok { + that2, ok := that.(MsgDenounceLeaderTx) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Sender != that1.Sender { + return false + } + if this.DappName != that1.DappName { + return false + } + if this.Leader != that1.Leader { + return false + } + if this.DenounceText != that1.DenounceText { + return false + } + if this.Version != that1.Version { + return false + } + return true +} +func (this *MsgDenounceLeaderTxResponse) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*MsgDenounceLeaderTxResponse) + if !ok { + that2, ok := that.(MsgDenounceLeaderTxResponse) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + return true +} +func (this *MsgTransitionDappTx) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*MsgTransitionDappTx) + if !ok { + that2, ok := that.(MsgTransitionDappTx) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Sender != that1.Sender { + return false + } + if this.DappName != that1.DappName { + return false + } + if this.StatusHash != that1.StatusHash { + return false + } + if len(this.OnchainMessages) != len(that1.OnchainMessages) { + return false + } + for i := range this.OnchainMessages { + if !this.OnchainMessages[i].Equal(that1.OnchainMessages[i]) { + return false + } + } + if this.Version != that1.Version { + return false + } + return true +} +func (this *MsgTransitionDappTxResponse) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*MsgTransitionDappTxResponse) + if !ok { + that2, ok := that.(MsgTransitionDappTxResponse) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + return true +} +func (this *MsgApproveDappTransitionTx) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*MsgApproveDappTransitionTx) + if !ok { + that2, ok := that.(MsgApproveDappTransitionTx) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Sender != that1.Sender { + return false + } + if this.DappName != that1.DappName { + return false + } + if this.Version != that1.Version { + return false + } + return true +} +func (this *MsgApproveDappTransitionTxResponse) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*MsgApproveDappTransitionTxResponse) + if !ok { + that2, ok := that.(MsgApproveDappTransitionTxResponse) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + return true +} +func (this *MsgRejectDappTransitionTx) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*MsgRejectDappTransitionTx) + if !ok { + that2, ok := that.(MsgRejectDappTransitionTx) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Sender != that1.Sender { + return false + } + if this.DappName != that1.DappName { + return false + } + if this.Version != that1.Version { + return false + } + return true +} +func (this *MsgRejectDappTransitionTxResponse) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*MsgRejectDappTransitionTxResponse) + if !ok { + that2, ok := that.(MsgRejectDappTransitionTxResponse) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + return true +} +func (this *MsgTransferDappTx) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*MsgTransferDappTx) + if !ok { + that2, ok := that.(MsgTransferDappTx) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Sender != that1.Sender { + return false + } + if len(this.Requests) != len(that1.Requests) { + return false + } + for i := range this.Requests { + if !this.Requests[i].Equal(&that1.Requests[i]) { + return false + } + } + return true +} +func (this *MsgTransferDappTxResponse) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*MsgTransferDappTxResponse) + if !ok { + that2, ok := that.(MsgTransferDappTxResponse) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + return true +} +func (this *MsgAckTransferDappTx) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*MsgAckTransferDappTx) + if !ok { + that2, ok := that.(MsgAckTransferDappTx) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Sender != that1.Sender { + return false + } + if len(this.Responses) != len(that1.Responses) { + return false + } + for i := range this.Responses { + if !this.Responses[i].Equal(&that1.Responses[i]) { + return false + } + } + return true +} +func (this *MsgAckTransferDappTxResponse) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*MsgAckTransferDappTxResponse) + if !ok { + that2, ok := that.(MsgAckTransferDappTxResponse) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + return true +} +func (this *MsgMintCreateFtTx) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*MsgMintCreateFtTx) + if !ok { + that2, ok := that.(MsgMintCreateFtTx) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Sender != that1.Sender { + return false + } + if this.DenomSuffix != that1.DenomSuffix { + return false + } + if this.Name != that1.Name { + return false + } + if this.Symbol != that1.Symbol { + return false + } + if this.Icon != that1.Icon { + return false + } + if this.Description != that1.Description { + return false + } + if this.Website != that1.Website { + return false + } + if this.Social != that1.Social { + return false + } + if this.Decimals != that1.Decimals { + return false + } + if !this.Cap.Equal(that1.Cap) { + return false + } + if !this.Supply.Equal(that1.Supply) { + return false + } + if this.Holders != that1.Holders { + return false + } + if !this.Fee.Equal(that1.Fee) { + return false + } + if this.Owner != that1.Owner { + return false + } + return true +} +func (this *MsgMintCreateFtTxResponse) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*MsgMintCreateFtTxResponse) + if !ok { + that2, ok := that.(MsgMintCreateFtTxResponse) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + return true +} +func (this *MsgMintCreateNftTx) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*MsgMintCreateNftTx) + if !ok { + that2, ok := that.(MsgMintCreateNftTx) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Sender != that1.Sender { + return false + } + if this.DenomSuffix != that1.DenomSuffix { + return false + } + if this.Name != that1.Name { + return false + } + if this.Symbol != that1.Symbol { + return false + } + if this.Icon != that1.Icon { + return false + } + if this.Description != that1.Description { + return false + } + if this.Website != that1.Website { + return false + } + if this.Social != that1.Social { + return false + } + if this.Decimals != that1.Decimals { + return false + } + if !this.Cap.Equal(that1.Cap) { + return false + } + if !this.Supply.Equal(that1.Supply) { + return false + } + if this.Holders != that1.Holders { + return false + } + if !this.Fee.Equal(that1.Fee) { + return false + } + if this.Owner != that1.Owner { + return false + } + if this.Metadata != that1.Metadata { + return false + } + if this.Hash != that1.Hash { + return false + } + return true +} +func (this *MsgMintCreateNftTxResponse) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*MsgMintCreateNftTxResponse) + if !ok { + that2, ok := that.(MsgMintCreateNftTxResponse) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + return true +} +func (this *MsgMintIssueTx) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*MsgMintIssueTx) + if !ok { + that2, ok := that.(MsgMintIssueTx) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Sender != that1.Sender { + return false + } + if this.Denom != that1.Denom { + return false + } + if !this.Amount.Equal(that1.Amount) { + return false + } + if this.Receiver != that1.Receiver { + return false + } + return true +} +func (this *MsgMintIssueTxResponse) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*MsgMintIssueTxResponse) + if !ok { + that2, ok := that.(MsgMintIssueTxResponse) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + return true +} +func (this *MsgMintBurnTx) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*MsgMintBurnTx) + if !ok { + that2, ok := that.(MsgMintBurnTx) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Sender != that1.Sender { + return false + } + if this.Denom != that1.Denom { + return false + } + if !this.Amount.Equal(that1.Amount) { + return false + } + return true +} +func (this *MsgMintBurnTxResponse) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*MsgMintBurnTxResponse) + if !ok { + that2, ok := that.(MsgMintBurnTxResponse) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + return true +} + +// 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 { + CreateDappProposal(ctx context.Context, in *MsgCreateDappProposal, opts ...grpc.CallOption) (*MsgCreateDappProposalResponse, error) + BondDappProposal(ctx context.Context, in *MsgBondDappProposal, opts ...grpc.CallOption) (*MsgBondDappProposalResponse, error) + ReclaimDappBondProposal(ctx context.Context, in *MsgReclaimDappBondProposal, opts ...grpc.CallOption) (*MsgReclaimDappBondProposalResponse, error) + JoinDappVerifierWithBond(ctx context.Context, in *MsgJoinDappVerifierWithBond, opts ...grpc.CallOption) (*MsgJoinDappVerifierWithBondResponse, error) + ExitDapp(ctx context.Context, in *MsgExitDapp, opts ...grpc.CallOption) (*MsgExitDappResponse, error) + RedeemDappPoolTx(ctx context.Context, in *MsgRedeemDappPoolTx, opts ...grpc.CallOption) (*MsgRedeemDappPoolTxResponse, error) + SwapDappPoolTx(ctx context.Context, in *MsgSwapDappPoolTx, opts ...grpc.CallOption) (*MsgSwapDappPoolTxResponse, error) + ConvertDappPoolTx(ctx context.Context, in *MsgConvertDappPoolTx, opts ...grpc.CallOption) (*MsgConvertDappPoolTxResponse, error) + PauseDappTx(ctx context.Context, in *MsgPauseDappTx, opts ...grpc.CallOption) (*MsgPauseDappTxResponse, error) + UnPauseDappTx(ctx context.Context, in *MsgUnPauseDappTx, opts ...grpc.CallOption) (*MsgUnPauseDappTxResponse, error) + ReactivateDappTx(ctx context.Context, in *MsgReactivateDappTx, opts ...grpc.CallOption) (*MsgReactivateDappTxResponse, error) + ExecuteDappTx(ctx context.Context, in *MsgExecuteDappTx, opts ...grpc.CallOption) (*MsgExecuteDappTxResponse, error) + DenounceLeaderTx(ctx context.Context, in *MsgDenounceLeaderTx, opts ...grpc.CallOption) (*MsgDenounceLeaderTxResponse, error) + TransitionDappTx(ctx context.Context, in *MsgTransitionDappTx, opts ...grpc.CallOption) (*MsgTransitionDappTxResponse, error) + ApproveDappTransitionTx(ctx context.Context, in *MsgApproveDappTransitionTx, opts ...grpc.CallOption) (*MsgApproveDappTransitionTxResponse, error) + RejectDappTransitionTx(ctx context.Context, in *MsgRejectDappTransitionTx, opts ...grpc.CallOption) (*MsgRejectDappTransitionTxResponse, error) + TransferDappTx(ctx context.Context, in *MsgTransferDappTx, opts ...grpc.CallOption) (*MsgTransferDappTxResponse, error) + AckTransferDappTx(ctx context.Context, in *MsgAckTransferDappTx, opts ...grpc.CallOption) (*MsgAckTransferDappTxResponse, error) + MintCreateFtTx(ctx context.Context, in *MsgMintCreateFtTx, opts ...grpc.CallOption) (*MsgMintCreateFtTxResponse, error) + MintCreateNftTx(ctx context.Context, in *MsgMintCreateNftTx, opts ...grpc.CallOption) (*MsgMintCreateNftTxResponse, error) + MintIssueTx(ctx context.Context, in *MsgMintIssueTx, opts ...grpc.CallOption) (*MsgMintIssueTxResponse, error) + MintBurnTx(ctx context.Context, in *MsgMintBurnTx, opts ...grpc.CallOption) (*MsgMintBurnTxResponse, error) +} + +type msgClient struct { + cc grpc1.ClientConn +} + +func NewMsgClient(cc grpc1.ClientConn) MsgClient { + return &msgClient{cc} +} + +func (c *msgClient) CreateDappProposal(ctx context.Context, in *MsgCreateDappProposal, opts ...grpc.CallOption) (*MsgCreateDappProposalResponse, error) { + out := new(MsgCreateDappProposalResponse) + err := c.cc.Invoke(ctx, "/kira.layer2.Msg/CreateDappProposal", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) BondDappProposal(ctx context.Context, in *MsgBondDappProposal, opts ...grpc.CallOption) (*MsgBondDappProposalResponse, error) { + out := new(MsgBondDappProposalResponse) + err := c.cc.Invoke(ctx, "/kira.layer2.Msg/BondDappProposal", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) ReclaimDappBondProposal(ctx context.Context, in *MsgReclaimDappBondProposal, opts ...grpc.CallOption) (*MsgReclaimDappBondProposalResponse, error) { + out := new(MsgReclaimDappBondProposalResponse) + err := c.cc.Invoke(ctx, "/kira.layer2.Msg/ReclaimDappBondProposal", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) JoinDappVerifierWithBond(ctx context.Context, in *MsgJoinDappVerifierWithBond, opts ...grpc.CallOption) (*MsgJoinDappVerifierWithBondResponse, error) { + out := new(MsgJoinDappVerifierWithBondResponse) + err := c.cc.Invoke(ctx, "/kira.layer2.Msg/JoinDappVerifierWithBond", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) ExitDapp(ctx context.Context, in *MsgExitDapp, opts ...grpc.CallOption) (*MsgExitDappResponse, error) { + out := new(MsgExitDappResponse) + err := c.cc.Invoke(ctx, "/kira.layer2.Msg/ExitDapp", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) RedeemDappPoolTx(ctx context.Context, in *MsgRedeemDappPoolTx, opts ...grpc.CallOption) (*MsgRedeemDappPoolTxResponse, error) { + out := new(MsgRedeemDappPoolTxResponse) + err := c.cc.Invoke(ctx, "/kira.layer2.Msg/RedeemDappPoolTx", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) SwapDappPoolTx(ctx context.Context, in *MsgSwapDappPoolTx, opts ...grpc.CallOption) (*MsgSwapDappPoolTxResponse, error) { + out := new(MsgSwapDappPoolTxResponse) + err := c.cc.Invoke(ctx, "/kira.layer2.Msg/SwapDappPoolTx", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) ConvertDappPoolTx(ctx context.Context, in *MsgConvertDappPoolTx, opts ...grpc.CallOption) (*MsgConvertDappPoolTxResponse, error) { + out := new(MsgConvertDappPoolTxResponse) + err := c.cc.Invoke(ctx, "/kira.layer2.Msg/ConvertDappPoolTx", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) PauseDappTx(ctx context.Context, in *MsgPauseDappTx, opts ...grpc.CallOption) (*MsgPauseDappTxResponse, error) { + out := new(MsgPauseDappTxResponse) + err := c.cc.Invoke(ctx, "/kira.layer2.Msg/PauseDappTx", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) UnPauseDappTx(ctx context.Context, in *MsgUnPauseDappTx, opts ...grpc.CallOption) (*MsgUnPauseDappTxResponse, error) { + out := new(MsgUnPauseDappTxResponse) + err := c.cc.Invoke(ctx, "/kira.layer2.Msg/UnPauseDappTx", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) ReactivateDappTx(ctx context.Context, in *MsgReactivateDappTx, opts ...grpc.CallOption) (*MsgReactivateDappTxResponse, error) { + out := new(MsgReactivateDappTxResponse) + err := c.cc.Invoke(ctx, "/kira.layer2.Msg/ReactivateDappTx", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) ExecuteDappTx(ctx context.Context, in *MsgExecuteDappTx, opts ...grpc.CallOption) (*MsgExecuteDappTxResponse, error) { + out := new(MsgExecuteDappTxResponse) + err := c.cc.Invoke(ctx, "/kira.layer2.Msg/ExecuteDappTx", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) DenounceLeaderTx(ctx context.Context, in *MsgDenounceLeaderTx, opts ...grpc.CallOption) (*MsgDenounceLeaderTxResponse, error) { + out := new(MsgDenounceLeaderTxResponse) + err := c.cc.Invoke(ctx, "/kira.layer2.Msg/DenounceLeaderTx", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) TransitionDappTx(ctx context.Context, in *MsgTransitionDappTx, opts ...grpc.CallOption) (*MsgTransitionDappTxResponse, error) { + out := new(MsgTransitionDappTxResponse) + err := c.cc.Invoke(ctx, "/kira.layer2.Msg/TransitionDappTx", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) ApproveDappTransitionTx(ctx context.Context, in *MsgApproveDappTransitionTx, opts ...grpc.CallOption) (*MsgApproveDappTransitionTxResponse, error) { + out := new(MsgApproveDappTransitionTxResponse) + err := c.cc.Invoke(ctx, "/kira.layer2.Msg/ApproveDappTransitionTx", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) RejectDappTransitionTx(ctx context.Context, in *MsgRejectDappTransitionTx, opts ...grpc.CallOption) (*MsgRejectDappTransitionTxResponse, error) { + out := new(MsgRejectDappTransitionTxResponse) + err := c.cc.Invoke(ctx, "/kira.layer2.Msg/RejectDappTransitionTx", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) TransferDappTx(ctx context.Context, in *MsgTransferDappTx, opts ...grpc.CallOption) (*MsgTransferDappTxResponse, error) { + out := new(MsgTransferDappTxResponse) + err := c.cc.Invoke(ctx, "/kira.layer2.Msg/TransferDappTx", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) AckTransferDappTx(ctx context.Context, in *MsgAckTransferDappTx, opts ...grpc.CallOption) (*MsgAckTransferDappTxResponse, error) { + out := new(MsgAckTransferDappTxResponse) + err := c.cc.Invoke(ctx, "/kira.layer2.Msg/AckTransferDappTx", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) MintCreateFtTx(ctx context.Context, in *MsgMintCreateFtTx, opts ...grpc.CallOption) (*MsgMintCreateFtTxResponse, error) { + out := new(MsgMintCreateFtTxResponse) + err := c.cc.Invoke(ctx, "/kira.layer2.Msg/MintCreateFtTx", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) MintCreateNftTx(ctx context.Context, in *MsgMintCreateNftTx, opts ...grpc.CallOption) (*MsgMintCreateNftTxResponse, error) { + out := new(MsgMintCreateNftTxResponse) + err := c.cc.Invoke(ctx, "/kira.layer2.Msg/MintCreateNftTx", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) MintIssueTx(ctx context.Context, in *MsgMintIssueTx, opts ...grpc.CallOption) (*MsgMintIssueTxResponse, error) { + out := new(MsgMintIssueTxResponse) + err := c.cc.Invoke(ctx, "/kira.layer2.Msg/MintIssueTx", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) MintBurnTx(ctx context.Context, in *MsgMintBurnTx, opts ...grpc.CallOption) (*MsgMintBurnTxResponse, error) { + out := new(MsgMintBurnTxResponse) + err := c.cc.Invoke(ctx, "/kira.layer2.Msg/MintBurnTx", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// MsgServer is the server API for Msg service. +type MsgServer interface { + CreateDappProposal(context.Context, *MsgCreateDappProposal) (*MsgCreateDappProposalResponse, error) + BondDappProposal(context.Context, *MsgBondDappProposal) (*MsgBondDappProposalResponse, error) + ReclaimDappBondProposal(context.Context, *MsgReclaimDappBondProposal) (*MsgReclaimDappBondProposalResponse, error) + JoinDappVerifierWithBond(context.Context, *MsgJoinDappVerifierWithBond) (*MsgJoinDappVerifierWithBondResponse, error) + ExitDapp(context.Context, *MsgExitDapp) (*MsgExitDappResponse, error) + RedeemDappPoolTx(context.Context, *MsgRedeemDappPoolTx) (*MsgRedeemDappPoolTxResponse, error) + SwapDappPoolTx(context.Context, *MsgSwapDappPoolTx) (*MsgSwapDappPoolTxResponse, error) + ConvertDappPoolTx(context.Context, *MsgConvertDappPoolTx) (*MsgConvertDappPoolTxResponse, error) + PauseDappTx(context.Context, *MsgPauseDappTx) (*MsgPauseDappTxResponse, error) + UnPauseDappTx(context.Context, *MsgUnPauseDappTx) (*MsgUnPauseDappTxResponse, error) + ReactivateDappTx(context.Context, *MsgReactivateDappTx) (*MsgReactivateDappTxResponse, error) + ExecuteDappTx(context.Context, *MsgExecuteDappTx) (*MsgExecuteDappTxResponse, error) + DenounceLeaderTx(context.Context, *MsgDenounceLeaderTx) (*MsgDenounceLeaderTxResponse, error) + TransitionDappTx(context.Context, *MsgTransitionDappTx) (*MsgTransitionDappTxResponse, error) + ApproveDappTransitionTx(context.Context, *MsgApproveDappTransitionTx) (*MsgApproveDappTransitionTxResponse, error) + RejectDappTransitionTx(context.Context, *MsgRejectDappTransitionTx) (*MsgRejectDappTransitionTxResponse, error) + TransferDappTx(context.Context, *MsgTransferDappTx) (*MsgTransferDappTxResponse, error) + AckTransferDappTx(context.Context, *MsgAckTransferDappTx) (*MsgAckTransferDappTxResponse, error) + MintCreateFtTx(context.Context, *MsgMintCreateFtTx) (*MsgMintCreateFtTxResponse, error) + MintCreateNftTx(context.Context, *MsgMintCreateNftTx) (*MsgMintCreateNftTxResponse, error) + MintIssueTx(context.Context, *MsgMintIssueTx) (*MsgMintIssueTxResponse, error) + MintBurnTx(context.Context, *MsgMintBurnTx) (*MsgMintBurnTxResponse, error) +} + +// UnimplementedMsgServer can be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { +} + +func (*UnimplementedMsgServer) CreateDappProposal(ctx context.Context, req *MsgCreateDappProposal) (*MsgCreateDappProposalResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CreateDappProposal not implemented") +} +func (*UnimplementedMsgServer) BondDappProposal(ctx context.Context, req *MsgBondDappProposal) (*MsgBondDappProposalResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method BondDappProposal not implemented") +} +func (*UnimplementedMsgServer) ReclaimDappBondProposal(ctx context.Context, req *MsgReclaimDappBondProposal) (*MsgReclaimDappBondProposalResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ReclaimDappBondProposal not implemented") +} +func (*UnimplementedMsgServer) JoinDappVerifierWithBond(ctx context.Context, req *MsgJoinDappVerifierWithBond) (*MsgJoinDappVerifierWithBondResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method JoinDappVerifierWithBond not implemented") +} +func (*UnimplementedMsgServer) ExitDapp(ctx context.Context, req *MsgExitDapp) (*MsgExitDappResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ExitDapp not implemented") +} +func (*UnimplementedMsgServer) RedeemDappPoolTx(ctx context.Context, req *MsgRedeemDappPoolTx) (*MsgRedeemDappPoolTxResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RedeemDappPoolTx not implemented") +} +func (*UnimplementedMsgServer) SwapDappPoolTx(ctx context.Context, req *MsgSwapDappPoolTx) (*MsgSwapDappPoolTxResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SwapDappPoolTx not implemented") +} +func (*UnimplementedMsgServer) ConvertDappPoolTx(ctx context.Context, req *MsgConvertDappPoolTx) (*MsgConvertDappPoolTxResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ConvertDappPoolTx not implemented") +} +func (*UnimplementedMsgServer) PauseDappTx(ctx context.Context, req *MsgPauseDappTx) (*MsgPauseDappTxResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method PauseDappTx not implemented") +} +func (*UnimplementedMsgServer) UnPauseDappTx(ctx context.Context, req *MsgUnPauseDappTx) (*MsgUnPauseDappTxResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UnPauseDappTx not implemented") +} +func (*UnimplementedMsgServer) ReactivateDappTx(ctx context.Context, req *MsgReactivateDappTx) (*MsgReactivateDappTxResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ReactivateDappTx not implemented") +} +func (*UnimplementedMsgServer) ExecuteDappTx(ctx context.Context, req *MsgExecuteDappTx) (*MsgExecuteDappTxResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ExecuteDappTx not implemented") +} +func (*UnimplementedMsgServer) DenounceLeaderTx(ctx context.Context, req *MsgDenounceLeaderTx) (*MsgDenounceLeaderTxResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method DenounceLeaderTx not implemented") +} +func (*UnimplementedMsgServer) TransitionDappTx(ctx context.Context, req *MsgTransitionDappTx) (*MsgTransitionDappTxResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method TransitionDappTx not implemented") +} +func (*UnimplementedMsgServer) ApproveDappTransitionTx(ctx context.Context, req *MsgApproveDappTransitionTx) (*MsgApproveDappTransitionTxResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ApproveDappTransitionTx not implemented") +} +func (*UnimplementedMsgServer) RejectDappTransitionTx(ctx context.Context, req *MsgRejectDappTransitionTx) (*MsgRejectDappTransitionTxResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RejectDappTransitionTx not implemented") +} +func (*UnimplementedMsgServer) TransferDappTx(ctx context.Context, req *MsgTransferDappTx) (*MsgTransferDappTxResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method TransferDappTx not implemented") +} +func (*UnimplementedMsgServer) AckTransferDappTx(ctx context.Context, req *MsgAckTransferDappTx) (*MsgAckTransferDappTxResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method AckTransferDappTx not implemented") +} +func (*UnimplementedMsgServer) MintCreateFtTx(ctx context.Context, req *MsgMintCreateFtTx) (*MsgMintCreateFtTxResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method MintCreateFtTx not implemented") +} +func (*UnimplementedMsgServer) MintCreateNftTx(ctx context.Context, req *MsgMintCreateNftTx) (*MsgMintCreateNftTxResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method MintCreateNftTx not implemented") +} +func (*UnimplementedMsgServer) MintIssueTx(ctx context.Context, req *MsgMintIssueTx) (*MsgMintIssueTxResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method MintIssueTx not implemented") +} +func (*UnimplementedMsgServer) MintBurnTx(ctx context.Context, req *MsgMintBurnTx) (*MsgMintBurnTxResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method MintBurnTx not implemented") +} + +func RegisterMsgServer(s grpc1.Server, srv MsgServer) { + s.RegisterService(&_Msg_serviceDesc, srv) +} + +func _Msg_CreateDappProposal_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgCreateDappProposal) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).CreateDappProposal(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/kira.layer2.Msg/CreateDappProposal", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).CreateDappProposal(ctx, req.(*MsgCreateDappProposal)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_BondDappProposal_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgBondDappProposal) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).BondDappProposal(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/kira.layer2.Msg/BondDappProposal", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).BondDappProposal(ctx, req.(*MsgBondDappProposal)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_ReclaimDappBondProposal_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgReclaimDappBondProposal) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).ReclaimDappBondProposal(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/kira.layer2.Msg/ReclaimDappBondProposal", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).ReclaimDappBondProposal(ctx, req.(*MsgReclaimDappBondProposal)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_JoinDappVerifierWithBond_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgJoinDappVerifierWithBond) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).JoinDappVerifierWithBond(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/kira.layer2.Msg/JoinDappVerifierWithBond", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).JoinDappVerifierWithBond(ctx, req.(*MsgJoinDappVerifierWithBond)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_ExitDapp_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgExitDapp) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).ExitDapp(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/kira.layer2.Msg/ExitDapp", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).ExitDapp(ctx, req.(*MsgExitDapp)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_RedeemDappPoolTx_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgRedeemDappPoolTx) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).RedeemDappPoolTx(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/kira.layer2.Msg/RedeemDappPoolTx", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).RedeemDappPoolTx(ctx, req.(*MsgRedeemDappPoolTx)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_SwapDappPoolTx_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgSwapDappPoolTx) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).SwapDappPoolTx(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/kira.layer2.Msg/SwapDappPoolTx", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).SwapDappPoolTx(ctx, req.(*MsgSwapDappPoolTx)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_ConvertDappPoolTx_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgConvertDappPoolTx) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).ConvertDappPoolTx(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/kira.layer2.Msg/ConvertDappPoolTx", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).ConvertDappPoolTx(ctx, req.(*MsgConvertDappPoolTx)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_PauseDappTx_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgPauseDappTx) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).PauseDappTx(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/kira.layer2.Msg/PauseDappTx", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).PauseDappTx(ctx, req.(*MsgPauseDappTx)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_UnPauseDappTx_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUnPauseDappTx) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).UnPauseDappTx(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/kira.layer2.Msg/UnPauseDappTx", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UnPauseDappTx(ctx, req.(*MsgUnPauseDappTx)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_ReactivateDappTx_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgReactivateDappTx) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).ReactivateDappTx(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/kira.layer2.Msg/ReactivateDappTx", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).ReactivateDappTx(ctx, req.(*MsgReactivateDappTx)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_ExecuteDappTx_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgExecuteDappTx) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).ExecuteDappTx(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/kira.layer2.Msg/ExecuteDappTx", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).ExecuteDappTx(ctx, req.(*MsgExecuteDappTx)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_DenounceLeaderTx_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgDenounceLeaderTx) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).DenounceLeaderTx(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/kira.layer2.Msg/DenounceLeaderTx", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).DenounceLeaderTx(ctx, req.(*MsgDenounceLeaderTx)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_TransitionDappTx_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgTransitionDappTx) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).TransitionDappTx(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/kira.layer2.Msg/TransitionDappTx", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).TransitionDappTx(ctx, req.(*MsgTransitionDappTx)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_ApproveDappTransitionTx_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgApproveDappTransitionTx) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).ApproveDappTransitionTx(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/kira.layer2.Msg/ApproveDappTransitionTx", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).ApproveDappTransitionTx(ctx, req.(*MsgApproveDappTransitionTx)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_RejectDappTransitionTx_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgRejectDappTransitionTx) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).RejectDappTransitionTx(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/kira.layer2.Msg/RejectDappTransitionTx", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).RejectDappTransitionTx(ctx, req.(*MsgRejectDappTransitionTx)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_TransferDappTx_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgTransferDappTx) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).TransferDappTx(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/kira.layer2.Msg/TransferDappTx", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).TransferDappTx(ctx, req.(*MsgTransferDappTx)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_AckTransferDappTx_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgAckTransferDappTx) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).AckTransferDappTx(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/kira.layer2.Msg/AckTransferDappTx", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).AckTransferDappTx(ctx, req.(*MsgAckTransferDappTx)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_MintCreateFtTx_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgMintCreateFtTx) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).MintCreateFtTx(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/kira.layer2.Msg/MintCreateFtTx", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).MintCreateFtTx(ctx, req.(*MsgMintCreateFtTx)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_MintCreateNftTx_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgMintCreateNftTx) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).MintCreateNftTx(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/kira.layer2.Msg/MintCreateNftTx", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).MintCreateNftTx(ctx, req.(*MsgMintCreateNftTx)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_MintIssueTx_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgMintIssueTx) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).MintIssueTx(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/kira.layer2.Msg/MintIssueTx", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).MintIssueTx(ctx, req.(*MsgMintIssueTx)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_MintBurnTx_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgMintBurnTx) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).MintBurnTx(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/kira.layer2.Msg/MintBurnTx", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).MintBurnTx(ctx, req.(*MsgMintBurnTx)) + } + return interceptor(ctx, in, info, handler) +} + +var _Msg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "kira.layer2.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "CreateDappProposal", + Handler: _Msg_CreateDappProposal_Handler, + }, + { + MethodName: "BondDappProposal", + Handler: _Msg_BondDappProposal_Handler, + }, + { + MethodName: "ReclaimDappBondProposal", + Handler: _Msg_ReclaimDappBondProposal_Handler, + }, + { + MethodName: "JoinDappVerifierWithBond", + Handler: _Msg_JoinDappVerifierWithBond_Handler, + }, + { + MethodName: "ExitDapp", + Handler: _Msg_ExitDapp_Handler, + }, + { + MethodName: "RedeemDappPoolTx", + Handler: _Msg_RedeemDappPoolTx_Handler, + }, + { + MethodName: "SwapDappPoolTx", + Handler: _Msg_SwapDappPoolTx_Handler, + }, + { + MethodName: "ConvertDappPoolTx", + Handler: _Msg_ConvertDappPoolTx_Handler, + }, + { + MethodName: "PauseDappTx", + Handler: _Msg_PauseDappTx_Handler, + }, + { + MethodName: "UnPauseDappTx", + Handler: _Msg_UnPauseDappTx_Handler, + }, + { + MethodName: "ReactivateDappTx", + Handler: _Msg_ReactivateDappTx_Handler, + }, + { + MethodName: "ExecuteDappTx", + Handler: _Msg_ExecuteDappTx_Handler, + }, + { + MethodName: "DenounceLeaderTx", + Handler: _Msg_DenounceLeaderTx_Handler, + }, + { + MethodName: "TransitionDappTx", + Handler: _Msg_TransitionDappTx_Handler, + }, + { + MethodName: "ApproveDappTransitionTx", + Handler: _Msg_ApproveDappTransitionTx_Handler, + }, + { + MethodName: "RejectDappTransitionTx", + Handler: _Msg_RejectDappTransitionTx_Handler, + }, + { + MethodName: "TransferDappTx", + Handler: _Msg_TransferDappTx_Handler, + }, + { + MethodName: "AckTransferDappTx", + Handler: _Msg_AckTransferDappTx_Handler, + }, + { + MethodName: "MintCreateFtTx", + Handler: _Msg_MintCreateFtTx_Handler, + }, + { + MethodName: "MintCreateNftTx", + Handler: _Msg_MintCreateNftTx_Handler, + }, + { + MethodName: "MintIssueTx", + Handler: _Msg_MintIssueTx_Handler, + }, + { + MethodName: "MintBurnTx", + Handler: _Msg_MintBurnTx_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "kira/layer2/tx.proto", +} + +func (m *MsgCreateDappProposal) 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 *MsgCreateDappProposal) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCreateDappProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.Bond.Size() + i -= size + if _, err := m.Bond.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + { + size, err := m.Dapp.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + 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] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgCreateDappProposalResponse) 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 *MsgCreateDappProposalResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCreateDappProposalResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgBondDappProposal) 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 *MsgBondDappProposal) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgBondDappProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.Bond.Size() + i -= size + if _, err := m.Bond.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if len(m.DappName) > 0 { + i -= len(m.DappName) + copy(dAtA[i:], m.DappName) + i = encodeVarintTx(dAtA, i, uint64(len(m.DappName))) + i-- + dAtA[i] = 0x12 + } + 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] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgBondDappProposalResponse) 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 *MsgBondDappProposalResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgBondDappProposalResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgReclaimDappBondProposal) 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 *MsgReclaimDappBondProposal) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgReclaimDappBondProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.Bond.Size() + i -= size + if _, err := m.Bond.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if len(m.DappName) > 0 { + i -= len(m.DappName) + copy(dAtA[i:], m.DappName) + i = encodeVarintTx(dAtA, i, uint64(len(m.DappName))) + i-- + dAtA[i] = 0x12 + } + 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] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgReclaimDappBondProposalResponse) 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 *MsgReclaimDappBondProposalResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgReclaimDappBondProposalResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgJoinDappVerifierWithBond) 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 *MsgJoinDappVerifierWithBond) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgJoinDappVerifierWithBond) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Interx) > 0 { + i -= len(m.Interx) + copy(dAtA[i:], m.Interx) + i = encodeVarintTx(dAtA, i, uint64(len(m.Interx))) + i-- + dAtA[i] = 0x1a + } + if len(m.DappName) > 0 { + i -= len(m.DappName) + copy(dAtA[i:], m.DappName) + i = encodeVarintTx(dAtA, i, uint64(len(m.DappName))) + i-- + dAtA[i] = 0x12 + } + 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] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgJoinDappVerifierWithBondResponse) 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 *MsgJoinDappVerifierWithBondResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgJoinDappVerifierWithBondResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgExitDapp) 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 *MsgExitDapp) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgExitDapp) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.DappName) > 0 { + i -= len(m.DappName) + copy(dAtA[i:], m.DappName) + i = encodeVarintTx(dAtA, i, uint64(len(m.DappName))) + i-- + dAtA[i] = 0x12 + } + 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] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgExitDappResponse) 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 *MsgExitDappResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgExitDappResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgRedeemDappPoolTx) 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 *MsgRedeemDappPoolTx) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgRedeemDappPoolTx) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.Slippage.Size() + i -= size + if _, err := m.Slippage.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + { + size := m.LpToken.Size() + i -= size + if _, err := m.LpToken.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if len(m.DappName) > 0 { + i -= len(m.DappName) + copy(dAtA[i:], m.DappName) + i = encodeVarintTx(dAtA, i, uint64(len(m.DappName))) + i-- + dAtA[i] = 0x12 + } + 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] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgRedeemDappPoolTxResponse) 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 *MsgRedeemDappPoolTxResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgRedeemDappPoolTxResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgSwapDappPoolTx) 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 *MsgSwapDappPoolTx) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSwapDappPoolTx) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.Slippage.Size() + i -= size + if _, err := m.Slippage.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + { + size := m.Token.Size() + i -= size + if _, err := m.Token.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if len(m.DappName) > 0 { + i -= len(m.DappName) + copy(dAtA[i:], m.DappName) + i = encodeVarintTx(dAtA, i, uint64(len(m.DappName))) + i-- + dAtA[i] = 0x12 + } + 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] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgSwapDappPoolTxResponse) 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 *MsgSwapDappPoolTxResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSwapDappPoolTxResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgConvertDappPoolTx) 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 *MsgConvertDappPoolTx) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgConvertDappPoolTx) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.Slippage.Size() + i -= size + if _, err := m.Slippage.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + { + size := m.LpToken.Size() + i -= size + if _, err := m.LpToken.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + if len(m.TargetDappName) > 0 { + i -= len(m.TargetDappName) + copy(dAtA[i:], m.TargetDappName) + i = encodeVarintTx(dAtA, i, uint64(len(m.TargetDappName))) + i-- + dAtA[i] = 0x1a + } + if len(m.DappName) > 0 { + i -= len(m.DappName) + copy(dAtA[i:], m.DappName) + i = encodeVarintTx(dAtA, i, uint64(len(m.DappName))) + i-- + dAtA[i] = 0x12 + } + 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] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgConvertDappPoolTxResponse) 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 *MsgConvertDappPoolTxResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgConvertDappPoolTxResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgPauseDappTx) 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 *MsgPauseDappTx) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgPauseDappTx) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.DappName) > 0 { + i -= len(m.DappName) + copy(dAtA[i:], m.DappName) + i = encodeVarintTx(dAtA, i, uint64(len(m.DappName))) + i-- + dAtA[i] = 0x12 + } + 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] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgPauseDappTxResponse) 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 *MsgPauseDappTxResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgPauseDappTxResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgUnPauseDappTx) 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 *MsgUnPauseDappTx) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUnPauseDappTx) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.DappName) > 0 { + i -= len(m.DappName) + copy(dAtA[i:], m.DappName) + i = encodeVarintTx(dAtA, i, uint64(len(m.DappName))) + i-- + dAtA[i] = 0x12 + } + 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] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgUnPauseDappTxResponse) 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 *MsgUnPauseDappTxResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUnPauseDappTxResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgReactivateDappTx) 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 *MsgReactivateDappTx) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgReactivateDappTx) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.DappName) > 0 { + i -= len(m.DappName) + copy(dAtA[i:], m.DappName) + i = encodeVarintTx(dAtA, i, uint64(len(m.DappName))) + i-- + dAtA[i] = 0x12 + } + 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] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgReactivateDappTxResponse) 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 *MsgReactivateDappTxResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgReactivateDappTxResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgExecuteDappTx) 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 *MsgExecuteDappTx) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgExecuteDappTx) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Gateway) > 0 { + i -= len(m.Gateway) + copy(dAtA[i:], m.Gateway) + i = encodeVarintTx(dAtA, i, uint64(len(m.Gateway))) + i-- + dAtA[i] = 0x1a + } + if len(m.DappName) > 0 { + i -= len(m.DappName) + copy(dAtA[i:], m.DappName) + i = encodeVarintTx(dAtA, i, uint64(len(m.DappName))) + i-- + dAtA[i] = 0x12 + } + 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] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgExecuteDappTxResponse) 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 *MsgExecuteDappTxResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgExecuteDappTxResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgDenounceLeaderTx) 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 *MsgDenounceLeaderTx) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgDenounceLeaderTx) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Version) > 0 { + i -= len(m.Version) + copy(dAtA[i:], m.Version) + i = encodeVarintTx(dAtA, i, uint64(len(m.Version))) + i-- + dAtA[i] = 0x2a + } + if len(m.DenounceText) > 0 { + i -= len(m.DenounceText) + copy(dAtA[i:], m.DenounceText) + i = encodeVarintTx(dAtA, i, uint64(len(m.DenounceText))) + i-- + dAtA[i] = 0x22 + } + if len(m.Leader) > 0 { + i -= len(m.Leader) + copy(dAtA[i:], m.Leader) + i = encodeVarintTx(dAtA, i, uint64(len(m.Leader))) + i-- + dAtA[i] = 0x1a + } + if len(m.DappName) > 0 { + i -= len(m.DappName) + copy(dAtA[i:], m.DappName) + i = encodeVarintTx(dAtA, i, uint64(len(m.DappName))) + i-- + dAtA[i] = 0x12 + } + 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] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgDenounceLeaderTxResponse) 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 *MsgDenounceLeaderTxResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgDenounceLeaderTxResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgTransitionDappTx) 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 *MsgTransitionDappTx) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgTransitionDappTx) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Version) > 0 { + i -= len(m.Version) + copy(dAtA[i:], m.Version) + i = encodeVarintTx(dAtA, i, uint64(len(m.Version))) + i-- + dAtA[i] = 0x2a + } + if len(m.OnchainMessages) > 0 { + for iNdEx := len(m.OnchainMessages) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.OnchainMessages[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + } + if len(m.StatusHash) > 0 { + i -= len(m.StatusHash) + copy(dAtA[i:], m.StatusHash) + i = encodeVarintTx(dAtA, i, uint64(len(m.StatusHash))) + i-- + dAtA[i] = 0x1a + } + if len(m.DappName) > 0 { + i -= len(m.DappName) + copy(dAtA[i:], m.DappName) + i = encodeVarintTx(dAtA, i, uint64(len(m.DappName))) + i-- + dAtA[i] = 0x12 + } + 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] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgTransitionDappTxResponse) 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 *MsgTransitionDappTxResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgTransitionDappTxResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgApproveDappTransitionTx) 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 *MsgApproveDappTransitionTx) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgApproveDappTransitionTx) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Version) > 0 { + i -= len(m.Version) + copy(dAtA[i:], m.Version) + i = encodeVarintTx(dAtA, i, uint64(len(m.Version))) + i-- + dAtA[i] = 0x1a + } + if len(m.DappName) > 0 { + i -= len(m.DappName) + copy(dAtA[i:], m.DappName) + i = encodeVarintTx(dAtA, i, uint64(len(m.DappName))) + i-- + dAtA[i] = 0x12 + } + 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] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgApproveDappTransitionTxResponse) 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 *MsgApproveDappTransitionTxResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgApproveDappTransitionTxResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgRejectDappTransitionTx) 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 *MsgRejectDappTransitionTx) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgRejectDappTransitionTx) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Version) > 0 { + i -= len(m.Version) + copy(dAtA[i:], m.Version) + i = encodeVarintTx(dAtA, i, uint64(len(m.Version))) + i-- + dAtA[i] = 0x1a + } + if len(m.DappName) > 0 { + i -= len(m.DappName) + copy(dAtA[i:], m.DappName) + i = encodeVarintTx(dAtA, i, uint64(len(m.DappName))) + i-- + dAtA[i] = 0x12 + } + 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] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgRejectDappTransitionTxResponse) 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 *MsgRejectDappTransitionTxResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgRejectDappTransitionTxResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgTransferDappTx) 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 *MsgTransferDappTx) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgTransferDappTx) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Requests) > 0 { + for iNdEx := len(m.Requests) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Requests[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.Sender) > 0 { + i -= len(m.Sender) + copy(dAtA[i:], m.Sender) + i = encodeVarintTx(dAtA, i, uint64(len(m.Sender))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgTransferDappTxResponse) 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 *MsgTransferDappTxResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgTransferDappTxResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgAckTransferDappTx) 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 *MsgAckTransferDappTx) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgAckTransferDappTx) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Responses) > 0 { + for iNdEx := len(m.Responses) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Responses[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.Sender) > 0 { + i -= len(m.Sender) + copy(dAtA[i:], m.Sender) + i = encodeVarintTx(dAtA, i, uint64(len(m.Sender))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgAckTransferDappTxResponse) 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 *MsgAckTransferDappTxResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgAckTransferDappTxResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgMintCreateFtTx) 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 *MsgMintCreateFtTx) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgMintCreateFtTx) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Owner) > 0 { + i -= len(m.Owner) + copy(dAtA[i:], m.Owner) + i = encodeVarintTx(dAtA, i, uint64(len(m.Owner))) + i-- + dAtA[i] = 0x72 + } + { + size := m.Fee.Size() + i -= size + if _, err := m.Fee.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x6a + if m.Holders != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.Holders)) + i-- + dAtA[i] = 0x60 + } + { + size := m.Supply.Size() + i -= size + if _, err := m.Supply.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x5a + { + size := m.Cap.Size() + i -= size + if _, err := m.Cap.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x52 + if m.Decimals != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.Decimals)) + i-- + dAtA[i] = 0x48 + } + if len(m.Social) > 0 { + i -= len(m.Social) + copy(dAtA[i:], m.Social) + i = encodeVarintTx(dAtA, i, uint64(len(m.Social))) + i-- + dAtA[i] = 0x42 + } + if len(m.Website) > 0 { + i -= len(m.Website) + copy(dAtA[i:], m.Website) + i = encodeVarintTx(dAtA, i, uint64(len(m.Website))) + i-- + dAtA[i] = 0x3a + } + if len(m.Description) > 0 { + i -= len(m.Description) + copy(dAtA[i:], m.Description) + i = encodeVarintTx(dAtA, i, uint64(len(m.Description))) + i-- + dAtA[i] = 0x32 + } + if len(m.Icon) > 0 { + i -= len(m.Icon) + copy(dAtA[i:], m.Icon) + i = encodeVarintTx(dAtA, i, uint64(len(m.Icon))) + i-- + dAtA[i] = 0x2a + } + if len(m.Symbol) > 0 { + i -= len(m.Symbol) + copy(dAtA[i:], m.Symbol) + i = encodeVarintTx(dAtA, i, uint64(len(m.Symbol))) + i-- + dAtA[i] = 0x22 + } + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintTx(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0x1a + } + if len(m.DenomSuffix) > 0 { + i -= len(m.DenomSuffix) + copy(dAtA[i:], m.DenomSuffix) + i = encodeVarintTx(dAtA, i, uint64(len(m.DenomSuffix))) + i-- + dAtA[i] = 0x12 + } + 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] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgMintCreateFtTxResponse) 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 *MsgMintCreateFtTxResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgMintCreateFtTxResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgMintCreateNftTx) 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 *MsgMintCreateNftTx) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgMintCreateNftTx) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Hash) > 0 { + i -= len(m.Hash) + copy(dAtA[i:], m.Hash) + i = encodeVarintTx(dAtA, i, uint64(len(m.Hash))) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x82 + } + if len(m.Metadata) > 0 { + i -= len(m.Metadata) + copy(dAtA[i:], m.Metadata) + i = encodeVarintTx(dAtA, i, uint64(len(m.Metadata))) + i-- + dAtA[i] = 0x7a + } + if len(m.Owner) > 0 { + i -= len(m.Owner) + copy(dAtA[i:], m.Owner) + i = encodeVarintTx(dAtA, i, uint64(len(m.Owner))) + i-- + dAtA[i] = 0x72 + } + { + size := m.Fee.Size() + i -= size + if _, err := m.Fee.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x6a + if m.Holders != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.Holders)) + i-- + dAtA[i] = 0x60 + } + { + size := m.Supply.Size() + i -= size + if _, err := m.Supply.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x5a + { + size := m.Cap.Size() + i -= size + if _, err := m.Cap.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x52 + if m.Decimals != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.Decimals)) + i-- + dAtA[i] = 0x48 + } + if len(m.Social) > 0 { + i -= len(m.Social) + copy(dAtA[i:], m.Social) + i = encodeVarintTx(dAtA, i, uint64(len(m.Social))) + i-- + dAtA[i] = 0x42 + } + if len(m.Website) > 0 { + i -= len(m.Website) + copy(dAtA[i:], m.Website) + i = encodeVarintTx(dAtA, i, uint64(len(m.Website))) + i-- + dAtA[i] = 0x3a + } + if len(m.Description) > 0 { + i -= len(m.Description) + copy(dAtA[i:], m.Description) + i = encodeVarintTx(dAtA, i, uint64(len(m.Description))) + i-- + dAtA[i] = 0x32 + } + if len(m.Icon) > 0 { + i -= len(m.Icon) + copy(dAtA[i:], m.Icon) + i = encodeVarintTx(dAtA, i, uint64(len(m.Icon))) + i-- + dAtA[i] = 0x2a + } + if len(m.Symbol) > 0 { + i -= len(m.Symbol) + copy(dAtA[i:], m.Symbol) + i = encodeVarintTx(dAtA, i, uint64(len(m.Symbol))) + i-- + dAtA[i] = 0x22 + } + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintTx(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0x1a + } + if len(m.DenomSuffix) > 0 { + i -= len(m.DenomSuffix) + copy(dAtA[i:], m.DenomSuffix) + i = encodeVarintTx(dAtA, i, uint64(len(m.DenomSuffix))) + i-- + dAtA[i] = 0x12 + } + 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] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgMintCreateNftTxResponse) 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 *MsgMintCreateNftTxResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgMintCreateNftTxResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgMintIssueTx) 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 *MsgMintIssueTx) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgMintIssueTx) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Receiver) > 0 { + i -= len(m.Receiver) + copy(dAtA[i:], m.Receiver) + i = encodeVarintTx(dAtA, i, uint64(len(m.Receiver))) + i-- + dAtA[i] = 0x22 + } + { + size := m.Amount.Size() + i -= size + if _, err := m.Amount.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if len(m.Denom) > 0 { + i -= len(m.Denom) + copy(dAtA[i:], m.Denom) + i = encodeVarintTx(dAtA, i, uint64(len(m.Denom))) + i-- + dAtA[i] = 0x12 + } + 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] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgMintIssueTxResponse) 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 *MsgMintIssueTxResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgMintIssueTxResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgMintBurnTx) 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 *MsgMintBurnTx) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgMintBurnTx) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.Amount.Size() + i -= size + if _, err := m.Amount.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if len(m.Denom) > 0 { + i -= len(m.Denom) + copy(dAtA[i:], m.Denom) + i = encodeVarintTx(dAtA, i, uint64(len(m.Denom))) + i-- + dAtA[i] = 0x12 + } + 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] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgMintBurnTxResponse) 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 *MsgMintBurnTxResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgMintBurnTxResponse) 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 *MsgCreateDappProposal) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.Dapp.Size() + n += 1 + l + sovTx(uint64(l)) + l = m.Bond.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + +func (m *MsgCreateDappProposalResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgBondDappProposal) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.DappName) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.Bond.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + +func (m *MsgBondDappProposalResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgReclaimDappBondProposal) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.DappName) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.Bond.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + +func (m *MsgReclaimDappBondProposalResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgJoinDappVerifierWithBond) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.DappName) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Interx) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgJoinDappVerifierWithBondResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgExitDapp) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.DappName) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgExitDappResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgRedeemDappPoolTx) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.DappName) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.LpToken.Size() + n += 1 + l + sovTx(uint64(l)) + l = m.Slippage.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + +func (m *MsgRedeemDappPoolTxResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgSwapDappPoolTx) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.DappName) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.Token.Size() + n += 1 + l + sovTx(uint64(l)) + l = m.Slippage.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + +func (m *MsgSwapDappPoolTxResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgConvertDappPoolTx) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.DappName) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.TargetDappName) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.LpToken.Size() + n += 1 + l + sovTx(uint64(l)) + l = m.Slippage.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + +func (m *MsgConvertDappPoolTxResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgPauseDappTx) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.DappName) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgPauseDappTxResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgUnPauseDappTx) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.DappName) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgUnPauseDappTxResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgReactivateDappTx) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.DappName) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgReactivateDappTxResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgExecuteDappTx) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.DappName) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Gateway) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgExecuteDappTxResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgDenounceLeaderTx) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.DappName) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Leader) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.DenounceText) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Version) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgDenounceLeaderTxResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgTransitionDappTx) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.DappName) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.StatusHash) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if len(m.OnchainMessages) > 0 { + for _, e := range m.OnchainMessages { + l = e.Size() + n += 1 + l + sovTx(uint64(l)) + } + } + l = len(m.Version) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgTransitionDappTxResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgApproveDappTransitionTx) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.DappName) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Version) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgApproveDappTransitionTxResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgRejectDappTransitionTx) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.DappName) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Version) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgRejectDappTransitionTxResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgTransferDappTx) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if len(m.Requests) > 0 { + for _, e := range m.Requests { + l = e.Size() + n += 1 + l + sovTx(uint64(l)) + } + } + return n +} + +func (m *MsgTransferDappTxResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgAckTransferDappTx) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if len(m.Responses) > 0 { + for _, e := range m.Responses { + l = e.Size() + n += 1 + l + sovTx(uint64(l)) + } + } + return n +} + +func (m *MsgAckTransferDappTxResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgMintCreateFtTx) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.DenomSuffix) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Name) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Symbol) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Icon) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Description) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Website) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Social) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.Decimals != 0 { + n += 1 + sovTx(uint64(m.Decimals)) + } + l = m.Cap.Size() + n += 1 + l + sovTx(uint64(l)) + l = m.Supply.Size() + n += 1 + l + sovTx(uint64(l)) + if m.Holders != 0 { + n += 1 + sovTx(uint64(m.Holders)) + } + l = m.Fee.Size() + n += 1 + l + sovTx(uint64(l)) + l = len(m.Owner) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgMintCreateFtTxResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgMintCreateNftTx) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.DenomSuffix) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Name) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Symbol) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Icon) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Description) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Website) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Social) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.Decimals != 0 { + n += 1 + sovTx(uint64(m.Decimals)) + } + l = m.Cap.Size() + n += 1 + l + sovTx(uint64(l)) + l = m.Supply.Size() + n += 1 + l + sovTx(uint64(l)) + if m.Holders != 0 { + n += 1 + sovTx(uint64(m.Holders)) + } + l = m.Fee.Size() + n += 1 + l + sovTx(uint64(l)) + l = len(m.Owner) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Metadata) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Hash) + if l > 0 { + n += 2 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgMintCreateNftTxResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgMintIssueTx) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Denom) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.Amount.Size() + n += 1 + l + sovTx(uint64(l)) + l = len(m.Receiver) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgMintIssueTxResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgMintBurnTx) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Denom) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.Amount.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + +func (m *MsgMintBurnTxResponse) 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 *MsgCreateDappProposal) 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: MsgCreateDappProposal: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCreateDappProposal: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Dapp", 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.Dapp.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Bond", 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 + } + if err := m.Bond.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 *MsgCreateDappProposalResponse) 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: MsgCreateDappProposalResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCreateDappProposalResponse: 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 *MsgBondDappProposal) 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: MsgBondDappProposal: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgBondDappProposal: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DappName", 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.DappName = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Bond", 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 + } + if err := m.Bond.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 *MsgBondDappProposalResponse) 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: MsgBondDappProposalResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgBondDappProposalResponse: 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 *MsgReclaimDappBondProposal) 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: MsgReclaimDappBondProposal: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgReclaimDappBondProposal: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DappName", 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.DappName = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Bond", 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 + } + if err := m.Bond.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 *MsgReclaimDappBondProposalResponse) 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: MsgReclaimDappBondProposalResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgReclaimDappBondProposalResponse: 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 *MsgJoinDappVerifierWithBond) 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: MsgJoinDappVerifierWithBond: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgJoinDappVerifierWithBond: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DappName", 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.DappName = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Interx", 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.Interx = 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 *MsgJoinDappVerifierWithBondResponse) 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: MsgJoinDappVerifierWithBondResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgJoinDappVerifierWithBondResponse: 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 *MsgExitDapp) 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: MsgExitDapp: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgExitDapp: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DappName", 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.DappName = 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 *MsgExitDappResponse) 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: MsgExitDappResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgExitDappResponse: 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 *MsgRedeemDappPoolTx) 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: MsgRedeemDappPoolTx: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRedeemDappPoolTx: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DappName", 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.DappName = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field LpToken", 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 + } + if err := m.LpToken.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Slippage", 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 + } + if err := m.Slippage.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 *MsgRedeemDappPoolTxResponse) 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: MsgRedeemDappPoolTxResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRedeemDappPoolTxResponse: 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 *MsgSwapDappPoolTx) 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: MsgSwapDappPoolTx: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSwapDappPoolTx: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DappName", 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.DappName = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Token", 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 + } + if err := m.Token.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Slippage", 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 + } + if err := m.Slippage.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 *MsgSwapDappPoolTxResponse) 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: MsgSwapDappPoolTxResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSwapDappPoolTxResponse: 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 *MsgConvertDappPoolTx) 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: MsgConvertDappPoolTx: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgConvertDappPoolTx: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DappName", 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.DappName = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TargetDappName", 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.TargetDappName = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field LpToken", 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 + } + if err := m.LpToken.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Slippage", 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 + } + if err := m.Slippage.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 *MsgConvertDappPoolTxResponse) 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: MsgConvertDappPoolTxResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgConvertDappPoolTxResponse: 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 *MsgPauseDappTx) 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: MsgPauseDappTx: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgPauseDappTx: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DappName", 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.DappName = 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 *MsgPauseDappTxResponse) 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: MsgPauseDappTxResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgPauseDappTxResponse: 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 *MsgUnPauseDappTx) 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: MsgUnPauseDappTx: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUnPauseDappTx: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DappName", 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.DappName = 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 *MsgUnPauseDappTxResponse) 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: MsgUnPauseDappTxResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUnPauseDappTxResponse: 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 *MsgReactivateDappTx) 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: MsgReactivateDappTx: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgReactivateDappTx: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DappName", 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.DappName = 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 *MsgReactivateDappTxResponse) 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: MsgReactivateDappTxResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgReactivateDappTxResponse: 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 *MsgExecuteDappTx) 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: MsgExecuteDappTx: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgExecuteDappTx: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DappName", 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.DappName = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Gateway", 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.Gateway = 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 *MsgExecuteDappTxResponse) 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: MsgExecuteDappTxResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgExecuteDappTxResponse: 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 *MsgDenounceLeaderTx) 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: MsgDenounceLeaderTx: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgDenounceLeaderTx: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DappName", 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.DappName = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Leader", 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.Leader = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DenounceText", 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.DenounceText = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Version", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Version = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgDenounceLeaderTxResponse) 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: MsgDenounceLeaderTxResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgDenounceLeaderTxResponse: 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 *MsgTransitionDappTx) 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: MsgTransitionDappTx: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgTransitionDappTx: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DappName", 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.DappName = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StatusHash", 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.StatusHash = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OnchainMessages", 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.OnchainMessages = append(m.OnchainMessages, &types.Any{}) + if err := m.OnchainMessages[len(m.OnchainMessages)-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 Version", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Version = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgTransitionDappTxResponse) 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: MsgTransitionDappTxResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgTransitionDappTxResponse: 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 *MsgApproveDappTransitionTx) 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: MsgApproveDappTransitionTx: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgApproveDappTransitionTx: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DappName", 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.DappName = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Version", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Version = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgApproveDappTransitionTxResponse) 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: MsgApproveDappTransitionTxResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgApproveDappTransitionTxResponse: 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 *MsgRejectDappTransitionTx) 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: MsgRejectDappTransitionTx: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRejectDappTransitionTx: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DappName", 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.DappName = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Version", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Version = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgRejectDappTransitionTxResponse) 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: MsgRejectDappTransitionTxResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRejectDappTransitionTxResponse: 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 *MsgTransferDappTx) 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: MsgTransferDappTx: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgTransferDappTx: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Requests", 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.Requests = append(m.Requests, XAMRequest{}) + if err := m.Requests[len(m.Requests)-1].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 *MsgTransferDappTxResponse) 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: MsgTransferDappTxResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgTransferDappTxResponse: 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 *MsgAckTransferDappTx) 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: MsgAckTransferDappTx: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgAckTransferDappTx: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Responses", 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.Responses = append(m.Responses, XAMResponse{}) + if err := m.Responses[len(m.Responses)-1].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 *MsgAckTransferDappTxResponse) 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: MsgAckTransferDappTxResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgAckTransferDappTxResponse: 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 *MsgMintCreateFtTx) 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: MsgMintCreateFtTx: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgMintCreateFtTx: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DenomSuffix", 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.DenomSuffix = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", 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.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Symbol", 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.Symbol = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Icon", 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.Icon = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Description", 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.Description = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Website", 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.Website = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Social", 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.Social = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 9: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Decimals", wireType) + } + m.Decimals = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Decimals |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 10: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Cap", 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 + } + if err := m.Cap.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 11: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Supply", 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 + } + if err := m.Supply.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 12: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Holders", wireType) + } + m.Holders = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Holders |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 13: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Fee", 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 + } + if err := m.Fee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 14: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Owner", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Owner = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + 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 *MsgMintCreateFtTxResponse) 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: MsgMintCreateFtTxResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgMintCreateFtTxResponse: 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 *MsgMintCreateNftTx) 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: MsgMintCreateNftTx: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgMintCreateNftTx: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DenomSuffix", 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.DenomSuffix = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", 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.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Symbol", 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.Symbol = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Icon", 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.Icon = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Description", 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.Description = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Website", 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.Website = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Social", 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.Social = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 9: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Decimals", wireType) + } + m.Decimals = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Decimals |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 10: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Cap", 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 + } + if err := m.Cap.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 11: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Supply", 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 + } + if err := m.Supply.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 12: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Holders", wireType) + } + m.Holders = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Holders |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 13: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Fee", 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 + } + if err := m.Fee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 14: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Owner", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Owner = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 15: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Metadata", 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.Metadata = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 16: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Hash", 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.Hash = 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 *MsgMintCreateNftTxResponse) 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: MsgMintCreateNftTxResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgMintCreateNftTxResponse: 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 *MsgMintIssueTx) 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: MsgMintIssueTx: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgMintIssueTx: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Denom", 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.Denom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", 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 + } + if err := m.Amount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Receiver", 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.Receiver = 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 *MsgMintIssueTxResponse) 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: MsgMintIssueTxResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgMintIssueTxResponse: 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 *MsgMintBurnTx) 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: MsgMintBurnTx: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgMintBurnTx: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Denom", 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.Denom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", 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 + } + if err := m.Amount.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 *MsgMintBurnTxResponse) 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: MsgMintBurnTxResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgMintBurnTxResponse: 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/multistaking/keeper/compound.go b/x/multistaking/keeper/compound.go index 9f2efd904..d90a23061 100644 --- a/x/multistaking/keeper/compound.go +++ b/x/multistaking/keeper/compound.go @@ -37,3 +37,9 @@ func (k Keeper) SetCompoundInfo(ctx sdk.Context, info types.CompoundInfo) { key := append(types.KeyPrefixCompoundInfo, []byte(info.Delegator)...) store.Set(key, k.cdc.MustMarshal(&info)) } + +func (k Keeper) RemoveCompoundInfo(ctx sdk.Context, info types.CompoundInfo) { + store := ctx.KVStore(k.storeKey) + key := append(types.KeyPrefixCompoundInfo, []byte(info.Delegator)...) + store.Delete(key) +} diff --git a/x/multistaking/keeper/pool.go b/x/multistaking/keeper/pool.go index 1d7f0f7f4..8f865f9c6 100644 --- a/x/multistaking/keeper/pool.go +++ b/x/multistaking/keeper/pool.go @@ -57,6 +57,12 @@ func (k Keeper) SetStakingPool(ctx sdk.Context, pool types.StakingPool) { store.Set(key, k.cdc.MustMarshal(&pool)) } +func (k Keeper) RemoveStakingPool(ctx sdk.Context, pool types.StakingPool) { + store := ctx.KVStore(k.storeKey) + key := append([]byte(types.KeyPrefixStakingPool), []byte(pool.Validator)...) + store.Delete(key) +} + func getPoolPrefix(poolID uint64) string { return fmt.Sprintf("v%d/", poolID) } diff --git a/x/recovery/abci.go b/x/recovery/abci.go new file mode 100644 index 000000000..24f552721 --- /dev/null +++ b/x/recovery/abci.go @@ -0,0 +1,14 @@ +package recovery + +import ( + abci "github.com/tendermint/tendermint/abci/types" + + "github.com/KiraCore/sekai/x/recovery/keeper" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// BeginBlocker check for infraction evidence or downtime of validators +// on every begin block +func BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock, k keeper.Keeper) { + +} diff --git a/x/recovery/client/cli/flags.go b/x/recovery/client/cli/flags.go new file mode 100644 index 000000000..7f1e458cd --- /dev/null +++ b/x/recovery/client/cli/flags.go @@ -0,0 +1 @@ +package cli diff --git a/x/recovery/client/cli/query.go b/x/recovery/client/cli/query.go new file mode 100644 index 000000000..5ef98284f --- /dev/null +++ b/x/recovery/client/cli/query.go @@ -0,0 +1,155 @@ +package cli + +import ( + "context" + "strings" + + "github.com/spf13/cobra" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + + "github.com/KiraCore/sekai/x/recovery/types" +) + +// GetQueryCmd returns the cli query commands for this module +func GetQueryCmd() *cobra.Command { + // Group recovery queries under a subcommand + recoveryQueryCmd := &cobra.Command{ + Use: types.ModuleName, + Short: "Querying commands for the recovery module", + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + recoveryQueryCmd.AddCommand( + GetCmdQueryRecoveryRecord(), + GetCmdQueryRecoveryToken(), + GetCmdQueryRRHolderRewards(), + GetCmdQueryRRHolders(), + ) + + return recoveryQueryCmd + +} + +// GetCmdQueryRecoveryRecord implements the command to query a recovery record for an address. +func GetCmdQueryRecoveryRecord() *cobra.Command { + cmd := &cobra.Command{ + Use: "recovery-record [address]", + Short: "Query an account's recovery information", + Long: strings.TrimSpace(`Query an account's recovery information: + +$ query recovery recovery-record kira15nxzg5lrmyu42vuzlztdnlhq9sngerenu520ey +`), + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + + queryClient := types.NewQueryClient(clientCtx) + + params := &types.QueryRecoveryRecordRequest{Address: args[0]} + res, err := queryClient.RecoveryRecord(context.Background(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +// GetCmdQueryRecoveryToken implements the command to query a recovery token for an address. +func GetCmdQueryRecoveryToken() *cobra.Command { + cmd := &cobra.Command{ + Use: "recovery-token [address]", + Short: "Query an account's recovery token information", + Long: strings.TrimSpace(`Query an account's recovery token information: + +$ query recovery recovery-token kira15nxzg5lrmyu42vuzlztdnlhq9sngerenu520ey +`), + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + + queryClient := types.NewQueryClient(clientCtx) + + params := &types.QueryRecoveryTokenRequest{Address: args[0]} + res, err := queryClient.RecoveryToken(context.Background(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +// GetCmdQueryRRHolderRewards implements the command to query rr holder rewards +func GetCmdQueryRRHolderRewards() *cobra.Command { + cmd := &cobra.Command{ + Use: "rr-holder-rewards [address]", + Short: "Query an account's rr holder rewards information", + Long: strings.TrimSpace(`Query an account's rr holder rewards information: + +$ query recovery rr-holder-rewards kira15nxzg5lrmyu42vuzlztdnlhq9sngerenu520ey +`), + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + + queryClient := types.NewQueryClient(clientCtx) + + params := &types.QueryRRHolderRewardsRequest{Address: args[0]} + res, err := queryClient.RRHolderRewards(context.Background(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +// GetCmdQueryRRHolders implements the command to query rr holders +func GetCmdQueryRRHolders() *cobra.Command { + cmd := &cobra.Command{ + Use: "rr-holders [rr_token]", + Short: "Query registered rr holders", + Long: strings.TrimSpace(`Query registered rr holders: + +$ query recovery rr-holders rr/val1 +`), + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + + queryClient := types.NewQueryClient(clientCtx) + + params := &types.QueryRegisteredRRTokenHoldersRequest{RecoveryToken: args[0]} + res, err := queryClient.RegisteredRRTokenHolders(context.Background(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/recovery/client/cli/tx.go b/x/recovery/client/cli/tx.go new file mode 100644 index 000000000..0f1c6ced4 --- /dev/null +++ b/x/recovery/client/cli/tx.go @@ -0,0 +1,282 @@ +package cli + +import ( + "crypto/sha256" + "encoding/hex" + "fmt" + + "github.com/KiraCore/sekai/x/recovery/types" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/spf13/cobra" +) + +// NewTxCmd returns a root CLI command handler for all x/recovery transaction commands. +func NewTxCmd() *cobra.Command { + recoveryTxCmd := &cobra.Command{ + Use: types.ModuleName, + Short: "Recovery transaction subcommands", + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + recoveryTxCmd.AddCommand( + NewRegisterRecoverySecretTxCmd(), + NewRotateRecoveryAddressTxCmd(), + NewIssueRecoveryTokensTxCmd(), + NewBurnRecoveryTokensTxCmd(), + NewGenerateRecoverySecretCmd(), + NewRegisterRRTokenHolderTxCmd(), + NewClaimRRTokenHolderRewardsTxCmd(), + NewRotateValidatorByHalfRRTokenHolderTxCmd(), + ) + return recoveryTxCmd +} + +// NewRegisterRecoverySecretTxCmd defines MsgRegisterRecoverySecret tx +func NewRegisterRecoverySecretTxCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "register-recovery-secret [challenge] [nonce] [proof]", + Args: cobra.ExactArgs(3), + Short: "Register recovery secret", + Long: `Register recovery secret: + +$ tx recovery register-recovery-secret [challenge] [nonce] [proof] --from mykey +`, + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + msg := types.NewMsgRegisterRecoverySecret(clientCtx.GetFromAddress().String(), args[0], args[1], args[2]) + if err := msg.ValidateBasic(); err != nil { + return err + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + +// NewRotateRecoveryAddressTxCmd defines MsgRotateRecoveryAddress tx +func NewRotateRecoveryAddressTxCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "rotate-recovery-address [recovery] [proof]", + Args: cobra.ExactArgs(2), + Short: "Rotate an address to recovery address", + Long: `Rotate an address to recovery address: + +$ tx recovery rotate-recovery-address [recovery] [proof] --from validator --chain-id=testing --keyring-backend=test --fees=100ukex --home=$HOME/.sekaid --yes +`, + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + msg := types.NewMsgRotateRecoveryAddress(clientCtx.GetFromAddress().String(), clientCtx.GetFromAddress().String(), args[0], args[1]) + if err := msg.ValidateBasic(); err != nil { + return err + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + +// NewIssueRecoveryTokensTxCmd defines MsgIssueRecoveryTokens tx +func NewIssueRecoveryTokensTxCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "issue-recovery-tokens", + Args: cobra.NoArgs, + Short: "Issue recovery tokens", + Long: `Issue recovery tokens: + +$ tx recovery issue-recovery-tokens --from mykey +`, + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + msg := types.NewMsgIssueRecoveryTokens(clientCtx.GetFromAddress().String()) + if err := msg.ValidateBasic(); err != nil { + return err + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + +// NewBurnRecoveryTokensTxCmd defines MsgBurnRecoveryTokens tx +func NewBurnRecoveryTokensTxCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "burn-recovery-tokens [coin]", + Args: cobra.ExactArgs(1), + Short: "Burn recovery tokens", + Long: `Burn recovery tokens: + +$ tx recovery burn-recovery-tokens [coin] --from mykey +`, + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + coin, err := sdk.ParseCoinNormalized(args[0]) + if err != nil { + return err + } + + msg := types.NewMsgBurnRecoveryTokens(clientCtx.GetFromAddress(), coin) + if err := msg.ValidateBasic(); err != nil { + return err + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + +// NewGenerateRecoverySecretCmd generates recovery secret +func NewGenerateRecoverySecretCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "generate-recovery-secret [key]", + Args: cobra.ExactArgs(1), + Short: "Generate recovery secret", + Long: `Generate recovery secret: + +$ tx recovery generate-recovery-secret 10a0fbe01030000122300000000000 +`, + RunE: func(cmd *cobra.Command, args []string) error { + privKey, err := hex.DecodeString(args[0]) + if err != nil { + return err + } + + proof := sha256.Sum256(privKey) + challenge := sha256.Sum256(proof[:]) + + fmt.Println("nonce", "00") + fmt.Println("proof", hex.EncodeToString(proof[:])) + fmt.Println("challenge", hex.EncodeToString(challenge[:])) + + return nil + }, + } + + return cmd +} + +// NewRegisterRRTokenHolderTxCmd defines Ms tx +func NewRegisterRRTokenHolderTxCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "register-rrtoken-holder", + Args: cobra.NoArgs, + Short: "Register RR token holder", + Long: `Register RR token holder: + +$ tx recovery register-rrtoken-holder --from mykey +`, + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + msg := types.NewMsgRegisterRRTokenHolder(clientCtx.GetFromAddress()) + if err := msg.ValidateBasic(); err != nil { + return err + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + +// NewClaimRRTokenHolderRewardsTxCmd defines Ms tx +func NewClaimRRTokenHolderRewardsTxCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "claim-rrtoken-rewards", + Args: cobra.NoArgs, + Short: "Claim RR token holder rewards", + Long: `Claim RR token holder rewards: + +$ tx recovery claim-rrtoken-rewards --from mykey +`, + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + msg := types.NewMsgClaimRRHolderRewards(clientCtx.GetFromAddress()) + if err := msg.ValidateBasic(); err != nil { + return err + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + +// NewRotateValidatorByHalfRRTokenHolderTxCmd defines MsgRotateValidatorByHalfRRTokenHolderTxCmd tx +func NewRotateValidatorByHalfRRTokenHolderTxCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "rotate-validator-by-half-rr-holder [address] [recovery]", + Args: cobra.ExactArgs(2), + Short: "Rotate a validator with half rr holder", + Long: `Rotate a validator with half rr holder: + +$ tx recovery rotate-validator-by-half-rr-holder [address] [recovery] --from validator --chain-id=testing --keyring-backend=test --fees=100ukex --home=$HOME/.sekaid --yes +`, + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + msg := types.NewMsgRotateValidatorByHalfRRTokenHolder(clientCtx.GetFromAddress().String(), args[0], args[1]) + if err := msg.ValidateBasic(); err != nil { + return err + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} diff --git a/x/recovery/genesis.go b/x/recovery/genesis.go new file mode 100644 index 000000000..51939c0e2 --- /dev/null +++ b/x/recovery/genesis.go @@ -0,0 +1,39 @@ +package recovery + +import ( + "github.com/KiraCore/sekai/x/recovery/keeper" + "github.com/KiraCore/sekai/x/recovery/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// InitGenesis initialize default parameters +// and the keeper's address to pubkey map +func InitGenesis(ctx sdk.Context, keeper keeper.Keeper, stakingKeeper types.StakingKeeper, data *types.GenesisState) { + for _, record := range data.RecoveryRecords { + keeper.SetRecoveryRecord(ctx, record) + } + + for _, token := range data.RecoveryTokens { + keeper.SetRecoveryToken(ctx, token) + } + + for _, rewards := range data.Rewards { + holder := sdk.MustAccAddressFromBech32(rewards.Holder) + keeper.SetRRTokenHolderRewards(ctx, holder, rewards.Rewards) + } + + for _, rotation := range data.Rotations { + keeper.SetRotationHistory(ctx, rotation) + } +} + +// ExportGenesis writes the current store values +// to a genesis file, which can be imported again +// with InitGenesis +func ExportGenesis(ctx sdk.Context, keeper keeper.Keeper) (data *types.GenesisState) { + records := keeper.GetAllRecoveryRecords(ctx) + tokens := keeper.GetAllRecoveryTokens(ctx) + rewards := keeper.GetAllRRHolderRewards(ctx) + rotations := keeper.GetAllRotationHistory(ctx) + return types.NewGenesisState(records, tokens, rewards, rotations) +} diff --git a/x/recovery/handler.go b/x/recovery/handler.go new file mode 100644 index 000000000..0077d4f92 --- /dev/null +++ b/x/recovery/handler.go @@ -0,0 +1,43 @@ +package recovery + +import ( + "github.com/KiraCore/sekai/x/recovery/keeper" + "github.com/KiraCore/sekai/x/recovery/types" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +// NewHandler creates an sdk.Handler for all the recovery type messages +func NewHandler(k keeper.Keeper) sdk.Handler { + return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { + ctx = ctx.WithEventManager(sdk.NewEventManager()) + + msgServer := keeper.NewMsgServerImpl(k) + + switch msg := msg.(type) { + case *types.MsgRegisterRecoverySecret: + res, err := msgServer.RegisterRecoverySecret(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + case *types.MsgRotateRecoveryAddress: + res, err := msgServer.RotateRecoveryAddress(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + case *types.MsgIssueRecoveryTokens: + res, err := msgServer.IssueRecoveryTokens(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + case *types.MsgBurnRecoveryTokens: + res, err := msgServer.BurnRecoveryTokens(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + case *types.MsgRegisterRRTokenHolder: + res, err := msgServer.RegisterRRTokenHolder(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + case *types.MsgClaimRRHolderRewards: + res, err := msgServer.ClaimRRHolderRewards(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + case *types.MsgRotateValidatorByHalfRRTokenHolder: + res, err := msgServer.RotateValidatorByHalfRRTokenHolder(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + default: + return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized %s message type: %T", types.ModuleName, msg) + } + } +} diff --git a/x/recovery/keeper/grpc_query.go b/x/recovery/keeper/grpc_query.go new file mode 100644 index 000000000..2684dc2fd --- /dev/null +++ b/x/recovery/keeper/grpc_query.go @@ -0,0 +1,64 @@ +package keeper + +import ( + "context" + + "github.com/KiraCore/sekai/x/recovery/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +var _ types.QueryServer = Keeper{} + +// given KIRA public address as parameter return data from the recovery registrar +func (k Keeper) RecoveryRecord(c context.Context, req *types.QueryRecoveryRecordRequest) (*types.QueryRecoveryRecordResponse, error) { + if req == nil { + return nil, status.Errorf(codes.InvalidArgument, "empty request") + } + + ctx := sdk.UnwrapSDKContext(c) + record, err := k.GetRecoveryRecord(ctx, req.Address) + if err != nil { + return nil, err + } + return &types.QueryRecoveryRecordResponse{Record: record}, nil +} + +func (k Keeper) RecoveryToken(c context.Context, req *types.QueryRecoveryTokenRequest) (*types.QueryRecoveryTokenResponse, error) { + if req == nil { + return nil, status.Errorf(codes.InvalidArgument, "empty request") + } + + ctx := sdk.UnwrapSDKContext(c) + token, err := k.GetRecoveryToken(ctx, req.Address) + if err != nil { + return nil, err + } + return &types.QueryRecoveryTokenResponse{Token: token}, nil +} + +func (k Keeper) RRHolderRewards(c context.Context, req *types.QueryRRHolderRewardsRequest) (*types.QueryRRHolderRewardsResponse, error) { + if req == nil { + return nil, status.Errorf(codes.InvalidArgument, "empty request") + } + + ctx := sdk.UnwrapSDKContext(c) + addr := sdk.MustAccAddressFromBech32(req.Address) + coins := k.GetRRTokenHolderRewards(ctx, addr) + return &types.QueryRRHolderRewardsResponse{Rewards: coins}, nil +} + +func (k Keeper) RegisteredRRTokenHolders(c context.Context, req *types.QueryRegisteredRRTokenHoldersRequest) (*types.QueryRegisteredRRTokenHoldersResponse, error) { + if req == nil { + return nil, status.Errorf(codes.InvalidArgument, "empty request") + } + + ctx := sdk.UnwrapSDKContext(c) + holders := k.GetRRTokenHolders(ctx, req.RecoveryToken) + holderRes := []string{} + for _, holder := range holders { + holderRes = append(holderRes, holder.String()) + } + return &types.QueryRegisteredRRTokenHoldersResponse{Holders: holderRes}, nil +} diff --git a/x/recovery/keeper/keeper.go b/x/recovery/keeper/keeper.go new file mode 100644 index 000000000..ab4506bdd --- /dev/null +++ b/x/recovery/keeper/keeper.go @@ -0,0 +1,56 @@ +package keeper + +import ( + "fmt" + + "github.com/tendermint/tendermint/libs/log" + + "github.com/KiraCore/sekai/x/recovery/types" + "github.com/cosmos/cosmos-sdk/codec" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// Keeper of the recovery store +type Keeper struct { + storeKey sdk.StoreKey + cdc codec.BinaryCodec + ak types.AccountKeeper + bk types.BankKeeper + sk types.StakingKeeper + gk types.GovKeeper + msk types.MultiStakingKeeper + ck types.CollectivesKeeper + spk types.SpendingKeeper + custodyk types.CustodyKeeper +} + +// NewKeeper creates a recovery keeper +func NewKeeper(cdc codec.BinaryCodec, key sdk.StoreKey, + ak types.AccountKeeper, + bk types.BankKeeper, + sk types.StakingKeeper, + gk types.GovKeeper, + msk types.MultiStakingKeeper, + ck types.CollectivesKeeper, + spk types.SpendingKeeper, + custodyk types.CustodyKeeper, +) Keeper { + + return Keeper{ + storeKey: key, + cdc: cdc, + ak: ak, + bk: bk, + sk: sk, + gk: gk, + msk: msk, + ck: ck, + spk: spk, + custodyk: custodyk, + } +} + +// Logger returns a module-specific logger. +func (k Keeper) Logger(ctx sdk.Context) log.Logger { + return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) +} diff --git a/x/recovery/keeper/keeper_test.go b/x/recovery/keeper/keeper_test.go new file mode 100644 index 000000000..a9df068bd --- /dev/null +++ b/x/recovery/keeper/keeper_test.go @@ -0,0 +1,29 @@ +package keeper_test + +import ( + "testing" + + simapp "github.com/KiraCore/sekai/app" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/suite" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" +) + +type KeeperTestSuite struct { + suite.Suite + + ctx sdk.Context + app *simapp.SekaiApp +} + +func (suite *KeeperTestSuite) SetupTest() { + checkTx := false + app := simapp.Setup(checkTx) + + suite.ctx = app.BaseApp.NewContext(checkTx, tmproto.Header{Height: 1}) + suite.app = app +} + +func TestKeeperTestSuite(t *testing.T) { + suite.Run(t, new(KeeperTestSuite)) +} diff --git a/x/recovery/keeper/msg_server.go b/x/recovery/keeper/msg_server.go new file mode 100644 index 000000000..506c7cb01 --- /dev/null +++ b/x/recovery/keeper/msg_server.go @@ -0,0 +1,650 @@ +package keeper + +import ( + "context" + "crypto/sha256" + "encoding/hex" + "fmt" + "strings" + + custodytypes "github.com/KiraCore/sekai/x/custody/types" + govtypes "github.com/KiraCore/sekai/x/gov/types" + "github.com/KiraCore/sekai/x/recovery/types" + slashingtypes "github.com/KiraCore/sekai/x/slashing/types" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +type msgServer struct { + Keeper +} + +// NewMsgServerImpl returns an implementation of the recovery MsgServer interface +// for the provided Keeper. +func NewMsgServerImpl(keeper Keeper) types.MsgServer { + return &msgServer{Keeper: keeper} +} + +var _ types.MsgServer = msgServer{} + +var RecoveryFee = sdk.Coins{sdk.NewInt64Coin("ukex", 1000_000_000)} + +// allow ANY user to register or modify existing recovery secret & verify if the nonce is correct +func (k msgServer) RegisterRecoverySecret(goCtx context.Context, msg *types.MsgRegisterRecoverySecret) (*types.MsgRegisterRecoverySecretResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + // check if validator recovery token exists + _, err := k.GetRecoveryToken(ctx, msg.Address) + if err == nil { + return nil, types.ErrAddressHasValidatorRecoveryToken + } + + // check previous recovery and check proof if already exists + oldRecord, err := k.Keeper.GetRecoveryRecord(ctx, msg.Address) + if err == nil { // recovery record already exists + bz, err := hex.DecodeString(msg.Proof) + if err != nil { + return nil, err + } + hash := sha256.Sum256(bz) + if hex.EncodeToString(hash[:]) != oldRecord.Challenge { + return nil, types.ErrInvalidProof + } + } + + k.Keeper.SetRecoveryRecord(ctx, types.RecoveryRecord{ + Address: msg.Address, + Challenge: msg.Challenge, + Nonce: msg.Nonce, + }) + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName), + sdk.NewAttribute(sdk.AttributeKeySender, msg.Address), + ), + ) + + return &types.MsgRegisterRecoverySecretResponse{}, nil +} + +func (k msgServer) RotateValidatorByHalfRRTokenHolder(goCtx context.Context, msg *types.MsgRotateValidatorByHalfRRTokenHolder) (*types.MsgRotateValidatorByHalfRRTokenHolderResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + // check if validator recovery token exists + recoveryToken, err := k.GetRecoveryToken(ctx, msg.Address) + if err != nil { + return nil, types.ErrRecoveryTokenDoesNotExist + } + + // check rr token amount + rrHolder := sdk.MustAccAddressFromBech32(msg.RrHolder) + balances := k.bk.GetAllBalances(ctx, rrHolder) + rrAmount := balances.AmountOf(recoveryToken.Token) + supply := k.bk.GetSupply(ctx, recoveryToken.Token) + if rrAmount.Mul(sdk.NewInt(2)).LT(supply.Amount) { + return nil, types.ErrNotEnoughRRTokenAmountForRotation + } + + rotation := k.GetRotationHistory(ctx, msg.Recovery) + if rotation.Rotated != "" { + return nil, types.ErrTargetAddressAlreadyHasRotationHistory + } + + // set rotation history + k.SetRotationHistory(ctx, types.Rotation{ + Address: msg.Address, + Rotated: msg.Recovery, + }) + + addr := sdk.MustAccAddressFromBech32(msg.Address) + rotatedAddr := sdk.MustAccAddressFromBech32(msg.Recovery) + + // - recovery module + k.DeleteRecoveryToken(ctx, recoveryToken) + recoveryToken.Address = msg.Recovery + k.SetRecoveryToken(ctx, recoveryToken) + + // - multistaking + info := k.msk.GetCompoundInfoByAddress(ctx, msg.Address) + k.msk.RemoveCompoundInfo(ctx, info) + info.Delegator = msg.Recovery + k.msk.SetCompoundInfo(ctx, info) + + pools := k.msk.GetAllStakingPools(ctx) + for _, pool := range pools { + isDelegator := k.msk.IsPoolDelegator(ctx, pool.Id, addr) + if isDelegator { + k.msk.RemovePoolDelegator(ctx, pool.Id, addr) + k.msk.SetPoolDelegator(ctx, pool.Id, rotatedAddr) + } + } + + rewards := k.msk.GetDelegatorRewards(ctx, addr) + if !rewards.IsZero() { + k.msk.RemoveDelegatorRewards(ctx, addr) + k.msk.SetDelegatorRewards(ctx, rotatedAddr, rewards) + } + + stpool, found := k.msk.GetStakingPoolByValidator(ctx, sdk.ValAddress(addr).String()) + if found { + k.msk.RemoveStakingPool(ctx, stpool) + stpool.Validator = sdk.ValAddress(rotatedAddr).String() + k.msk.SetStakingPool(ctx, stpool) + } + + // - staking + validator, err := k.sk.GetValidator(ctx, sdk.ValAddress(addr)) + if err == nil { + k.sk.RemoveValidator(ctx, validator) + validator.ValKey = sdk.ValAddress(rotatedAddr) + k.sk.AddValidator(ctx, validator) + } + + // - gov:councilor + councilor, found := k.gk.GetCouncilor(ctx, addr) + if found { + k.gk.DeleteCouncilor(ctx, councilor) + councilor.Address = rotatedAddr + k.gk.SaveCouncilor(ctx, councilor) + } + + // - gov:identity_records + records := k.gk.GetIdRecordsByAddress(ctx, addr) + for _, record := range records { + k.gk.DeleteIdentityRecordById(ctx, record.Id) + record.Address = msg.Recovery + k.gk.SetIdentityRecord(ctx, record) + } + + requests := k.gk.GetIdRecordsVerifyRequestsByRequester(ctx, addr) + for _, req := range requests { + k.gk.DeleteIdRecordsVerifyRequest(ctx, req.Id) + req.Address = msg.Recovery + k.gk.SetIdentityRecordsVerifyRequest(ctx, req) + } + + requests = k.gk.GetIdRecordsVerifyRequestsByApprover(ctx, addr) + for _, req := range requests { + k.gk.DeleteIdRecordsVerifyRequest(ctx, req.Id) + req.Verifier = msg.Recovery + k.gk.SetIdentityRecordsVerifyRequest(ctx, req) + } + + // - gov:network_actor + actor, found := k.gk.GetNetworkActorByAddress(ctx, addr) + if found { + k.gk.DeleteNetworkActor(ctx, actor) + for _, role := range actor.Roles { + k.gk.RemoveRoleFromActor(ctx, actor, role) + } + for _, perm := range actor.Permissions.Whitelist { + k.gk.DeleteWhitelistAddressPermKey(ctx, actor, govtypes.PermValue(perm)) + } + + actor.Address = rotatedAddr + k.gk.SaveNetworkActor(ctx, actor) + for _, role := range actor.Roles { + k.gk.AssignRoleToActor(ctx, actor, role) + } + for _, perm := range actor.Permissions.Whitelist { + k.gk.SetWhitelistAddressPermKey(ctx, actor, govtypes.PermValue(perm)) + } + } + + // - gov:proposals + proposals, err := k.gk.GetProposals(ctx) + if err != nil { + return nil, err + } + + for _, p := range proposals { + content, ok := p.GetContent().(*slashingtypes.ProposalSlashValidator) + if ok { + if content.Offender == sdk.ValAddress(addr).String() { + content.Offender = sdk.ValAddress(rotatedAddr).String() + any, err := codectypes.NewAnyWithValue(msg) + if err != nil { + return nil, err + } + + p.Content = any + k.gk.SaveProposal(ctx, p) + } + } + } + + // - gov:votes + for _, p := range proposals { + vote, found := k.gk.GetVote(ctx, p.ProposalId, addr) + if found { + k.gk.DeleteVote(ctx, vote) + vote.Voter = rotatedAddr + k.gk.SaveVote(ctx, vote) + } + } + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName), + sdk.NewAttribute(sdk.AttributeKeySender, msg.Address), + ), + ) + + return &types.MsgRotateValidatorByHalfRRTokenHolderResponse{}, nil +} + +// allow ANY KIRA address that knows the recovery secret or has a sufficient number of RR tokens to rotate the address +func (k msgServer) RotateRecoveryAddress(goCtx context.Context, msg *types.MsgRotateRecoveryAddress) (*types.MsgRotateRecoveryAddressResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + // check if validator recovery token exists + _, err := k.GetRecoveryToken(ctx, msg.Address) + if err == nil { + return nil, types.ErrAddressHasValidatorRecoveryToken + } + + // Pay 1000 KEX + feePayer := sdk.MustAccAddressFromBech32(msg.FeePayer) + err = k.bk.SendCoinsFromAccountToModule(ctx, feePayer, types.ModuleName, RecoveryFee) + if err != nil { + return nil, err + } + + record, err := k.Keeper.GetRecoveryRecord(ctx, msg.Address) + if err != nil { + return nil, err + } + + bz, err := hex.DecodeString(msg.Proof) + if err != nil { + return nil, err + } + hash := sha256.Sum256(bz) + if hex.EncodeToString(hash[:]) != record.Challenge { + return nil, types.ErrInvalidProof + } + + addr := sdk.MustAccAddressFromBech32(msg.Address) + rotatedAddr := sdk.MustAccAddressFromBech32(msg.Recovery) + + rotation := k.GetRotationHistory(ctx, msg.Recovery) + if rotation.Rotated != "" { + return nil, types.ErrTargetAddressAlreadyHasRotationHistory + } + + // set rotation history + k.SetRotationHistory(ctx, types.Rotation{ + Address: msg.Address, + Rotated: msg.Recovery, + }) + + // - account module + acc := k.ak.GetAccount(ctx, addr) + if acc == nil { + return nil, types.ErrAccountDoesNotExists + } + rotatedAcc := k.ak.GetAccount(ctx, rotatedAddr) + if rotatedAcc != nil { + return nil, types.ErrRotatedAccountAlreadyExists + } + + // - bank module + balances := k.bk.GetAllBalances(ctx, addr) + if balances.IsAllPositive() { + err = k.bk.SendCoins(ctx, addr, rotatedAddr, balances) + if err != nil { + return nil, err + } + } + + // - collectives module + contributers := k.ck.GetAllCollectiveContributers(ctx) + for _, cc := range contributers { + if cc.Address == msg.Address { + k.ck.DeleteCollectiveContributer(ctx, cc.Name, cc.Address) + cc.Address = msg.Recovery + k.ck.SetCollectiveContributer(ctx, cc) + } + } + + // - gov:councilor + councilor, found := k.gk.GetCouncilor(ctx, addr) + if found { + k.gk.DeleteCouncilor(ctx, councilor) + councilor.Address = rotatedAddr + k.gk.SaveCouncilor(ctx, councilor) + } + + // - gov:identity_records + records := k.gk.GetIdRecordsByAddress(ctx, addr) + for _, record := range records { + k.gk.DeleteIdentityRecordById(ctx, record.Id) + record.Address = msg.Recovery + k.gk.SetIdentityRecord(ctx, record) + } + + requests := k.gk.GetIdRecordsVerifyRequestsByRequester(ctx, addr) + for _, req := range requests { + k.gk.DeleteIdRecordsVerifyRequest(ctx, req.Id) + req.Address = msg.Recovery + k.gk.SetIdentityRecordsVerifyRequest(ctx, req) + } + + requests = k.gk.GetIdRecordsVerifyRequestsByApprover(ctx, addr) + for _, req := range requests { + k.gk.DeleteIdRecordsVerifyRequest(ctx, req.Id) + req.Verifier = msg.Recovery + k.gk.SetIdentityRecordsVerifyRequest(ctx, req) + } + + // - gov:network_actor + actor, found := k.gk.GetNetworkActorByAddress(ctx, addr) + if found { + k.gk.DeleteNetworkActor(ctx, actor) + for _, role := range actor.Roles { + k.gk.RemoveRoleFromActor(ctx, actor, role) + } + for _, perm := range actor.Permissions.Whitelist { + k.gk.DeleteWhitelistAddressPermKey(ctx, actor, govtypes.PermValue(perm)) + } + + actor.Address = rotatedAddr + k.gk.SaveNetworkActor(ctx, actor) + for _, role := range actor.Roles { + k.gk.AssignRoleToActor(ctx, actor, role) + } + for _, perm := range actor.Permissions.Whitelist { + k.gk.SetWhitelistAddressPermKey(ctx, actor, govtypes.PermValue(perm)) + } + } + + // - gov:proposals + proposals, err := k.gk.GetProposals(ctx) + if err != nil { + return nil, err + } + + for _, p := range proposals { + content, ok := p.GetContent().(*slashingtypes.ProposalSlashValidator) + if ok { + if content.Offender == sdk.ValAddress(addr).String() { + content.Offender = sdk.ValAddress(rotatedAddr).String() + any, err := codectypes.NewAnyWithValue(msg) + if err != nil { + return nil, err + } + + p.Content = any + k.gk.SaveProposal(ctx, p) + } + } + } + + // - gov:votes + for _, p := range proposals { + vote, found := k.gk.GetVote(ctx, p.ProposalId, addr) + if found { + k.gk.DeleteVote(ctx, vote) + vote.Voter = rotatedAddr + k.gk.SaveVote(ctx, vote) + } + } + + // - multistaking + info := k.msk.GetCompoundInfoByAddress(ctx, msg.Address) + k.msk.RemoveCompoundInfo(ctx, info) + info.Delegator = msg.Recovery + k.msk.SetCompoundInfo(ctx, info) + + pools := k.msk.GetAllStakingPools(ctx) + for _, pool := range pools { + isDelegator := k.msk.IsPoolDelegator(ctx, pool.Id, addr) + if isDelegator { + k.msk.RemovePoolDelegator(ctx, pool.Id, addr) + k.msk.SetPoolDelegator(ctx, pool.Id, rotatedAddr) + } + } + + rewards := k.msk.GetDelegatorRewards(ctx, addr) + if !rewards.IsZero() { + k.msk.RemoveDelegatorRewards(ctx, addr) + k.msk.SetDelegatorRewards(ctx, rotatedAddr, rewards) + } + + stpool, found := k.msk.GetStakingPoolByValidator(ctx, sdk.ValAddress(addr).String()) + if found { + k.msk.RemoveStakingPool(ctx, stpool) + stpool.Validator = sdk.ValAddress(rotatedAddr).String() + k.msk.SetStakingPool(ctx, stpool) + } + + // - spending + sppools := k.spk.GetAllSpendingPools(ctx) + for _, pool := range sppools { + info := k.spk.GetClaimInfo(ctx, pool.Name, addr) + if info != nil { + k.spk.RemoveClaimInfo(ctx, *info) + info.Account = msg.Recovery + k.spk.SetClaimInfo(ctx, *info) + } + } + + // - staking + validator, err := k.sk.GetValidator(ctx, sdk.ValAddress(addr)) + if err == nil { + k.sk.RemoveValidator(ctx, validator) + validator.ValKey = sdk.ValAddress(rotatedAddr) + k.sk.AddValidator(ctx, validator) + } + + // - custody + settings := k.custodyk.GetCustodyInfoByAddress(ctx, addr) + if settings != nil { + k.custodyk.DisableCustodyRecord(ctx, addr) + k.custodyk.SetCustodyRecord(ctx, custodytypes.CustodyRecord{ + Address: rotatedAddr, + CustodySettings: settings, + }) + } + + custodians := k.custodyk.GetCustodyCustodiansByAddress(ctx, addr) + if custodians != nil { + k.custodyk.DropCustodyCustodiansByAddress(ctx, addr) + k.custodyk.AddToCustodyCustodians(ctx, custodytypes.CustodyCustodiansRecord{ + Address: rotatedAddr, + CustodyCustodians: custodians, + }) + } + + whitelist := k.custodyk.GetCustodyWhiteListByAddress(ctx, addr) + if whitelist != nil { + k.custodyk.DropCustodyWhiteListByAddress(ctx, addr) + k.custodyk.AddToCustodyWhiteList(ctx, custodytypes.CustodyWhiteListRecord{ + Address: rotatedAddr, + CustodyWhiteList: whitelist, + }) + } + + limits := k.custodyk.GetCustodyLimitsByAddress(ctx, addr) + if limits != nil { + k.custodyk.DropCustodyLimitsByAddress(ctx, addr) + k.custodyk.AddToCustodyLimits(ctx, custodytypes.CustodyLimitRecord{ + Address: rotatedAddr, + CustodyLimits: limits, + }) + } + + limitsStatus := k.custodyk.GetCustodyLimitsStatusByAddress(ctx, addr) + if limitsStatus != nil { + k.custodyk.DropCustodyLimitsStatus(ctx, addr) + k.custodyk.AddToCustodyLimitsStatus(ctx, custodytypes.CustodyLimitStatusRecord{ + Address: rotatedAddr, + CustodyStatuses: limitsStatus, + }) + } + + txPool := k.custodyk.GetCustodyPoolByAddress(ctx, addr) + if txPool != nil { + k.custodyk.DropCustodyPool(ctx, addr) + k.custodyk.AddToCustodyPool(ctx, custodytypes.CustodyPool{ + Address: rotatedAddr, + Transactions: txPool, + }) + } + + // nothing to do with following modules + // - basket + // - distributor + // - evidence + // - slashing + // - tokens + // - ubi + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName), + sdk.NewAttribute(sdk.AttributeKeySender, msg.Address), + ), + ) + + return &types.MsgRotateRecoveryAddressResponse{}, nil +} + +// mint `rr/` tokens and deposit them to the validator account. +// This function will require putting up a bond in the amount of `validator_recovery_bond` otherwise should fail +func (k msgServer) IssueRecoveryTokens(goCtx context.Context, msg *types.MsgIssueRecoveryTokens) (*types.MsgIssueRecoveryTokensResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + addr := sdk.MustAccAddressFromBech32(msg.Address) + + // check if validator and previously not issued token + _, err := k.Keeper.GetRecoveryToken(ctx, msg.Address) + if err == nil { + return nil, types.ErrRecoveryTokenAlreadyExists + } + + // KEX token spend + properties := k.gk.GetNetworkProperties(ctx) + amount := sdk.NewInt(int64(properties.ValidatorRecoveryBond)).Mul(sdk.NewInt(1000_000)) + coins := sdk.NewCoins(sdk.NewCoin("ukex", amount)) + err = k.bk.SendCoinsFromAccountToModule(ctx, addr, types.ModuleName, coins) + if err != nil { + return nil, err + } + + records, err := k.gk.GetIdRecordsByAddressAndKeys(ctx, addr, []string{"moniker"}) + if err != nil { + return nil, err + } + if len(records) != 1 { + return nil, types.ErrInvalidMoniker + } + + denom := fmt.Sprintf("rr/%s", strings.ToLower(records[0].Value)) + + // issue 10'000'000 tokens + recoveryTokenAmount := sdk.NewInt(10_000_000).Mul(sdk.NewInt(1000_000)) + recoveryCoins := sdk.NewCoins(sdk.NewCoin(denom, recoveryTokenAmount)) + err = k.bk.MintCoins(ctx, types.ModuleName, recoveryCoins) + if err != nil { + return nil, err + } + + err = k.bk.SendCoinsFromModuleToAccount(ctx, types.ModuleName, addr, recoveryCoins) + if err != nil { + return nil, err + } + + k.Keeper.SetRecoveryToken(ctx, types.RecoveryToken{ + Address: msg.Address, + Token: denom, + RrSupply: recoveryTokenAmount, + UnderlyingTokens: coins, + }) + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName), + sdk.NewAttribute(sdk.AttributeKeySender, msg.Address), + ), + ) + + return &types.MsgIssueRecoveryTokensResponse{}, nil +} + +// burn tokens and redeem underlying tokens +func (k msgServer) BurnRecoveryTokens(goCtx context.Context, msg *types.MsgBurnRecoveryTokens) (*types.MsgBurnRecoveryTokensResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + addr := sdk.MustAccAddressFromBech32(msg.Address) + recoveryToken, err := k.GetRecoveryTokenByDenom(ctx, msg.RrCoin.Denom) + if err != nil { + return nil, err + } + + redeemAmount := sdk.Coins{} + for _, coin := range recoveryToken.UnderlyingTokens { + amount := coin.Amount.Mul(msg.RrCoin.Amount).Quo(recoveryToken.RrSupply) + if amount.IsPositive() { + redeemAmount = redeemAmount.Add(sdk.NewCoin(coin.Denom, amount)) + } + } + + if !redeemAmount.IsZero() { + err = k.bk.SendCoinsFromModuleToAccount(ctx, types.ModuleName, addr, redeemAmount) + if err != nil { + return nil, err + } + } + + err = k.bk.SendCoinsFromAccountToModule(ctx, addr, types.ModuleName, sdk.NewCoins(msg.RrCoin)) + if err != nil { + return nil, err + } + + err = k.bk.BurnCoins(ctx, types.ModuleName, sdk.NewCoins(msg.RrCoin)) + if err != nil { + return nil, err + } + + recoveryToken.RrSupply = recoveryToken.RrSupply.Sub(msg.RrCoin.Amount) + recoveryToken.UnderlyingTokens = sdk.Coins(recoveryToken.UnderlyingTokens).Sub(redeemAmount) + + if recoveryToken.RrSupply.IsZero() { + k.Keeper.DeleteRecoveryToken(ctx, recoveryToken) + } else { + k.Keeper.SetRecoveryToken(ctx, recoveryToken) + } + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName), + sdk.NewAttribute(sdk.AttributeKeySender, msg.Address), + ), + ) + return &types.MsgBurnRecoveryTokensResponse{}, nil +} + +// claim RR token holder rewards +func (k msgServer) ClaimRRHolderRewards(goCtx context.Context, msg *types.MsgClaimRRHolderRewards) (*types.MsgClaimRRHolderRewardsResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + addr := sdk.MustAccAddressFromBech32(msg.Sender) + k.ClaimRewards(ctx, addr) + return &types.MsgClaimRRHolderRewardsResponse{}, nil +} + +// register RR token holder +func (k msgServer) RegisterRRTokenHolder(goCtx context.Context, msg *types.MsgRegisterRRTokenHolder) (*types.MsgRegisterRRTokenHolderResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + addr := sdk.MustAccAddressFromBech32(msg.Holder) + k.Keeper.RegisterRRTokenHolder(ctx, addr) + return &types.MsgRegisterRRTokenHolderResponse{}, nil +} diff --git a/x/recovery/keeper/msg_server_test.go b/x/recovery/keeper/msg_server_test.go new file mode 100644 index 000000000..d171b7156 --- /dev/null +++ b/x/recovery/keeper/msg_server_test.go @@ -0,0 +1,405 @@ +package keeper_test + +import ( + "crypto/sha256" + "encoding/hex" + "time" + + "github.com/KiraCore/sekai/app" + collectivestypes "github.com/KiraCore/sekai/x/collectives/types" + custodytypes "github.com/KiraCore/sekai/x/custody/types" + govtypes "github.com/KiraCore/sekai/x/gov/types" + "github.com/KiraCore/sekai/x/recovery/keeper" + "github.com/KiraCore/sekai/x/recovery/types" + stakingtypes "github.com/KiraCore/sekai/x/staking/types" + "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" + "github.com/cosmos/cosmos-sdk/simapp" + sdk "github.com/cosmos/cosmos-sdk/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" + "github.com/tendermint/tendermint/crypto/ed25519" +) + +func init() { + app.SetConfig() +} + +func (suite *KeeperTestSuite) TestRegisterRecoverySecret() { + addr1 := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address().Bytes()) + + // create recovery record + msgServer := keeper.NewMsgServerImpl(suite.app.RecoveryKeeper) + msg := types.NewMsgRegisterRecoverySecret( + addr1.String(), "123456", "111111", "", + ) + + _, err := msgServer.RegisterRecoverySecret(sdk.WrapSDKContext(suite.ctx), msg) + suite.Require().NoError(err) + + // check recovery correctly crteated + record, err := suite.app.RecoveryKeeper.GetRecoveryRecord(suite.ctx, addr1.String()) + suite.Require().NoError(err) + suite.Require().Equal(record, types.RecoveryRecord{ + Address: addr1.String(), + Challenge: "123456", + Nonce: "111111", + }) + + // try another execution without proof + _, err = msgServer.RegisterRecoverySecret(sdk.WrapSDKContext(suite.ctx), msg) + suite.Require().Error(err) +} + +func (suite *KeeperTestSuite) TestRotateRecoveryAddress() { + pubkey1 := secp256k1.GenPrivKey().PubKey() + pubkey2 := secp256k1.GenPrivKey().PubKey() + addr1 := sdk.AccAddress(pubkey1.Address()) + addr2 := sdk.AccAddress(pubkey2.Address()) + + acc1 := authtypes.NewBaseAccount(addr1, pubkey1, 0, 0) + suite.app.AccountKeeper.SetAccount(suite.ctx, acc1) + + // bank module setup + coins := sdk.Coins{sdk.NewInt64Coin("ukex", 1000_000)} + err := suite.app.BankKeeper.MintCoins(suite.ctx, minttypes.ModuleName, coins) + suite.Require().NoError(err) + err = suite.app.BankKeeper.SendCoinsFromModuleToAccount(suite.ctx, minttypes.ModuleName, addr1, coins) + suite.Require().NoError(err) + + err = suite.app.BankKeeper.MintCoins(suite.ctx, minttypes.ModuleName, keeper.RecoveryFee) + suite.Require().NoError(err) + err = suite.app.BankKeeper.SendCoinsFromModuleToAccount(suite.ctx, minttypes.ModuleName, addr1, keeper.RecoveryFee) + suite.Require().NoError(err) + + // collectives module setup + contributer := collectivestypes.CollectiveContributor{ + Address: addr1.String(), + Name: "collective1", + Bonds: []sdk.Coin{sdk.NewInt64Coin("ukex", 1000_000)}, + Locking: 1000, + Donation: sdk.NewDecWithPrec(1, 1), // 10% + DonationLock: true, + } + suite.app.CollectivesKeeper.SetCollectiveContributer(suite.ctx, contributer) + + // gov module setup + councilor := govtypes.NewCouncilor( + addr1, + govtypes.CouncilorActive, + ) + suite.app.CustomGovKeeper.SaveCouncilor(suite.ctx, councilor) + + // multistaking module + suite.app.MultiStakingKeeper.SetDelegatorRewards(suite.ctx, addr1, coins) + + // staking module + valAddr := sdk.ValAddress(addr1) + pubkeys := simapp.CreateTestPubKeys(1) + pubKey := pubkeys[0] + val, err := stakingtypes.NewValidator(valAddr, pubKey) + suite.Require().NoError(err) + val.Status = stakingtypes.Active + suite.app.CustomStakingKeeper.AddValidator(suite.ctx, val) + + // custody settings + settings := custodytypes.CustodySettings{ + CustodyEnabled: true, + CustodyMode: 1, + UsePassword: true, + UseWhiteList: true, + UseLimits: true, + Key: "key", + } + suite.app.CustodyKeeper.SetCustodyRecord(suite.ctx, custodytypes.CustodyRecord{ + Address: addr1, + CustodySettings: &settings, + }) + + // recovery record set + privKey, err := hex.DecodeString("10a0fbe01030000122300000000000") + suite.Require().NoError(err) + proof := sha256.Sum256(privKey) + challenge := sha256.Sum256(proof[:]) + + suite.app.RecoveryKeeper.SetRecoveryRecord(suite.ctx, types.RecoveryRecord{ + Address: addr1.String(), + Challenge: hex.EncodeToString(challenge[:]), + Nonce: "111111", + }) + + // invalid proof + msg := types.NewMsgRotateRecoveryAddress( + addr1.String(), addr1.String(), addr2.String(), "", + ) + + msgServer := keeper.NewMsgServerImpl(suite.app.RecoveryKeeper) + cacheCtx, _ := suite.ctx.CacheContext() + _, err = msgServer.RotateRecoveryAddress(sdk.WrapSDKContext(cacheCtx), msg) + suite.Require().Error(err) + + // valid proof + msg.Proof = hex.EncodeToString(proof[:]) + _, err = msgServer.RotateRecoveryAddress(sdk.WrapSDKContext(suite.ctx), msg) + suite.Require().NoError(err) + + // check bank module transfer + addr1Coins := suite.app.BankKeeper.GetAllBalances(suite.ctx, addr1) + suite.Require().Equal(addr1Coins, sdk.Coins{}) + addr2Coins := suite.app.BankKeeper.GetAllBalances(suite.ctx, addr2) + suite.Require().Equal(addr2Coins, coins) + + // check collective contributer recovery + addr1Contributer := suite.app.CollectivesKeeper.GetCollectiveContributer(suite.ctx, "collective1", addr1.String()) + suite.Require().Equal(addr1Contributer, collectivestypes.CollectiveContributor{}) + addr2Contributer := suite.app.CollectivesKeeper.GetCollectiveContributer(suite.ctx, "collective1", addr2.String()) + suite.Require().Equal(addr2Contributer.Address, addr2.String()) + suite.Require().Equal(addr2Contributer.Bonds, contributer.Bonds) + + // check gov: councilor recovery + _, found := suite.app.CustomGovKeeper.GetCouncilor(suite.ctx, addr1) + suite.Require().False(found) + addr2Councilor, found := suite.app.CustomGovKeeper.GetCouncilor(suite.ctx, addr2) + suite.Require().True(found) + suite.Require().Equal(addr2Councilor.Status, councilor.Status) + + // TODO: check gov: identity records recovery + // TODO: check gov: identity records verification requests recovery + // TODO: check gov: network actor recovery + // TODO: check gov: votes recovery + + // check multistaking delegator rewards recovery + addr1Rewards := suite.app.MultiStakingKeeper.GetDelegatorRewards(suite.ctx, addr1) + suite.Require().Equal(addr1Rewards, sdk.Coins{}) + addr2Rewards := suite.app.MultiStakingKeeper.GetDelegatorRewards(suite.ctx, addr2) + suite.Require().Equal(addr2Rewards, coins) + + // TODO: check multistaking is delegator recovery + // TODO: check multistaking validator address recovery + // TODO: check spending pool claim info recovery + + // check validator address recovery + _, err = suite.app.CustomStakingKeeper.GetValidator(suite.ctx, sdk.ValAddress(addr1)) + suite.Require().Error(err) + val2, err := suite.app.CustomStakingKeeper.GetValidator(suite.ctx, sdk.ValAddress(addr2)) + suite.Require().NoError(err) + suite.Require().Equal(val2.Status, val.Status) + + // check custody settings recovery + addr1Custody := suite.app.CustodyKeeper.GetCustodyInfoByAddress(suite.ctx, addr1) + suite.Require().Nil(addr1Custody) + addr2Custody := suite.app.CustodyKeeper.GetCustodyInfoByAddress(suite.ctx, addr2) + suite.Require().NotNil(addr2Custody) + suite.Require().Equal(*addr2Custody, settings) + + // check rotation history is correctly set after rotation + rotation := suite.app.RecoveryKeeper.GetRotationHistory(suite.ctx, addr1.String()) + suite.Require().Equal(rotation, types.Rotation{ + Address: addr1.String(), + Rotated: addr2.String(), + }) + + // rotation to already rotated address to fail + _, err = msgServer.RotateRecoveryAddress(sdk.WrapSDKContext(suite.ctx), msg) + suite.Require().Error(err) +} + +func (suite *KeeperTestSuite) TestIssueRecoveryTokens() { + addr1 := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address().Bytes()) + valAddr := sdk.ValAddress(addr1) + pubkeys := simapp.CreateTestPubKeys(1) + pubKey := pubkeys[0] + val, err := stakingtypes.NewValidator(valAddr, pubKey) + suite.Require().NoError(err) + + suite.app.CustomStakingKeeper.AddValidator(suite.ctx, val) + suite.app.CustomGovKeeper.SetIdentityRecord(suite.ctx, govtypes.IdentityRecord{ + Id: 1, + Address: addr1.String(), + Key: "moniker", + Value: "val1", + Date: time.Now(), + Verifiers: []string{}, + }) + + coins := sdk.Coins{sdk.NewInt64Coin("ukex", 300000000000)} + err = suite.app.BankKeeper.MintCoins(suite.ctx, minttypes.ModuleName, coins) + suite.Require().NoError(err) + err = suite.app.BankKeeper.SendCoinsFromModuleToAccount(suite.ctx, minttypes.ModuleName, addr1, coins) + suite.Require().NoError(err) + + // create recovery token + msgServer := keeper.NewMsgServerImpl(suite.app.RecoveryKeeper) + msg := types.NewMsgIssueRecoveryTokens( + addr1.String(), + ) + + _, err = msgServer.IssueRecoveryTokens(sdk.WrapSDKContext(suite.ctx), msg) + suite.Require().NoError(err) + + // check recovery correctly crteated + recoveryToken, err := suite.app.RecoveryKeeper.GetRecoveryToken(suite.ctx, addr1.String()) + suite.Require().NoError(err) + suite.Require().Equal(recoveryToken, types.RecoveryToken{ + Address: addr1.String(), + Token: "rr/val1", + RrSupply: sdk.NewInt(10000000000000), + UnderlyingTokens: coins, + }) +} + +func (suite *KeeperTestSuite) TestBurnRecoveryTokens() { + addr1 := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address().Bytes()) + valAddr := sdk.ValAddress(addr1) + pubkeys := simapp.CreateTestPubKeys(1) + pubKey := pubkeys[0] + val, err := stakingtypes.NewValidator(valAddr, pubKey) + suite.Require().NoError(err) + + suite.app.CustomStakingKeeper.AddValidator(suite.ctx, val) + suite.app.CustomGovKeeper.SetIdentityRecord(suite.ctx, govtypes.IdentityRecord{ + Id: 1, + Address: addr1.String(), + Key: "moniker", + Value: "val1", + Date: time.Now(), + Verifiers: []string{}, + }) + + coins := sdk.Coins{sdk.NewInt64Coin("ukex", 300000000000)} + err = suite.app.BankKeeper.MintCoins(suite.ctx, minttypes.ModuleName, coins) + suite.Require().NoError(err) + err = suite.app.BankKeeper.SendCoinsFromModuleToAccount(suite.ctx, minttypes.ModuleName, addr1, coins) + suite.Require().NoError(err) + + // create recovery token + msgServer := keeper.NewMsgServerImpl(suite.app.RecoveryKeeper) + issueMsg := types.NewMsgIssueRecoveryTokens( + addr1.String(), + ) + + _, err = msgServer.IssueRecoveryTokens(sdk.WrapSDKContext(suite.ctx), issueMsg) + suite.Require().NoError(err) + + burnMsg := types.NewMsgBurnRecoveryTokens( + addr1, sdk.NewInt64Coin("rr/val1", 10000000000), + ) + _, err = msgServer.BurnRecoveryTokens(sdk.WrapSDKContext(suite.ctx), burnMsg) + suite.Require().NoError(err) + + // check recovery correctly created + recoveryToken, err := suite.app.RecoveryKeeper.GetRecoveryToken(suite.ctx, addr1.String()) + suite.Require().NoError(err) + suite.Require().Equal(recoveryToken, types.RecoveryToken{ + Address: addr1.String(), + Token: "rr/val1", + RrSupply: sdk.NewInt(9990000000000), + UnderlyingTokens: sdk.Coins{sdk.NewInt64Coin("ukex", 299700000000)}, + }) +} + +func (suite *KeeperTestSuite) TestClaimRRHolderRewards() { + addr1 := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address().Bytes()) + valAddr := sdk.ValAddress(addr1) + pubkeys := simapp.CreateTestPubKeys(1) + pubKey := pubkeys[0] + val, err := stakingtypes.NewValidator(valAddr, pubKey) + suite.Require().NoError(err) + + suite.app.CustomStakingKeeper.AddValidator(suite.ctx, val) + suite.app.CustomGovKeeper.SetIdentityRecord(suite.ctx, govtypes.IdentityRecord{ + Id: 1, + Address: addr1.String(), + Key: "moniker", + Value: "val1", + Date: time.Now(), + Verifiers: []string{}, + }) + + coins := sdk.Coins{sdk.NewInt64Coin("ukex", 300000000000)} + err = suite.app.BankKeeper.MintCoins(suite.ctx, minttypes.ModuleName, coins) + suite.Require().NoError(err) + err = suite.app.BankKeeper.SendCoinsFromModuleToAccount(suite.ctx, minttypes.ModuleName, addr1, coins) + suite.Require().NoError(err) + + // create recovery token + msgServer := keeper.NewMsgServerImpl(suite.app.RecoveryKeeper) + issueMsg := types.NewMsgIssueRecoveryTokens( + addr1.String(), + ) + + _, err = msgServer.IssueRecoveryTokens(sdk.WrapSDKContext(suite.ctx), issueMsg) + suite.Require().NoError(err) + + registerMsg := types.NewMsgRegisterRRTokenHolder( + addr1, + ) + _, err = msgServer.RegisterRRTokenHolder(sdk.WrapSDKContext(suite.ctx), registerMsg) + suite.Require().NoError(err) + + rewardCoins := sdk.Coins{sdk.NewInt64Coin("ukex", 1000000)} + err = suite.app.BankKeeper.MintCoins(suite.ctx, types.ModuleName, rewardCoins) + suite.Require().NoError(err) + + err = suite.app.RecoveryKeeper.IncreaseRecoveryTokenUnderlying(suite.ctx, addr1, rewardCoins) + suite.Require().NoError(err) + + claimMsg := types.NewMsgClaimRRHolderRewards( + addr1, + ) + _, err = msgServer.ClaimRRHolderRewards(sdk.WrapSDKContext(suite.ctx), claimMsg) + suite.Require().NoError(err) + + // check reward already claimed + balance := suite.app.BankKeeper.GetBalance(suite.ctx, addr1, "ukex") + suite.Require().Equal(balance.String(), rewardCoins.String()) +} + +func (suite *KeeperTestSuite) TestRotateValidatorByHalfRRTokenHolder() { + addr1 := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address().Bytes()) + addr2 := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address().Bytes()) + valAddr := sdk.ValAddress(addr1) + pubkeys := simapp.CreateTestPubKeys(1) + pubKey := pubkeys[0] + val, err := stakingtypes.NewValidator(valAddr, pubKey) + suite.Require().NoError(err) + + suite.app.CustomStakingKeeper.AddValidator(suite.ctx, val) + suite.app.CustomGovKeeper.SetIdentityRecord(suite.ctx, govtypes.IdentityRecord{ + Id: 1, + Address: addr1.String(), + Key: "moniker", + Value: "val1", + Date: time.Now(), + Verifiers: []string{}, + }) + + coins := sdk.Coins{sdk.NewInt64Coin("ukex", 300000000000)} + err = suite.app.BankKeeper.MintCoins(suite.ctx, minttypes.ModuleName, coins) + suite.Require().NoError(err) + err = suite.app.BankKeeper.SendCoinsFromModuleToAccount(suite.ctx, minttypes.ModuleName, addr1, coins) + suite.Require().NoError(err) + + // create recovery token + msgServer := keeper.NewMsgServerImpl(suite.app.RecoveryKeeper) + issueMsg := types.NewMsgIssueRecoveryTokens( + addr1.String(), + ) + + _, err = msgServer.IssueRecoveryTokens(sdk.WrapSDKContext(suite.ctx), issueMsg) + suite.Require().NoError(err) + + rotateMsg := types.NewMsgRotateValidatorByHalfRRTokenHolder( + addr1.String(), + addr1.String(), + addr2.String(), + ) + _, err = msgServer.RotateValidatorByHalfRRTokenHolder(sdk.WrapSDKContext(suite.ctx), rotateMsg) + suite.Require().NoError(err) + + // check rotation history is correctly set after rotation + rotation := suite.app.RecoveryKeeper.GetRotationHistory(suite.ctx, addr1.String()) + suite.Require().Equal(rotation, types.Rotation{ + Address: addr1.String(), + Rotated: addr2.String(), + }) +} diff --git a/x/recovery/keeper/recovery.go b/x/recovery/keeper/recovery.go new file mode 100644 index 000000000..0a0861a56 --- /dev/null +++ b/x/recovery/keeper/recovery.go @@ -0,0 +1,139 @@ +package keeper + +import ( + "github.com/KiraCore/sekai/x/recovery/types" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +func (k Keeper) GetRecoveryRecord(ctx sdk.Context, address string) (types.RecoveryRecord, error) { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.RecoveryRecordKey(address)) + if bz == nil { + return types.RecoveryRecord{}, sdkerrors.Wrapf(types.ErrRecoveryRecordDoesNotExist, "RecoveryRecord: %s does not exist", address) + } + record := types.RecoveryRecord{} + k.cdc.MustUnmarshal(bz, &record) + return record, nil +} + +func (k Keeper) GetRecoveryAddressFromChallenge(ctx sdk.Context, challenge string) string { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.RecoveryChallengeKey(challenge)) + if bz == nil { + return "" + } + return string(bz) +} + +func (k Keeper) SetRecoveryRecord(ctx sdk.Context, record types.RecoveryRecord) { + bz := k.cdc.MustMarshal(&record) + store := ctx.KVStore(k.storeKey) + store.Set(types.RecoveryRecordKey(record.Address), bz) + store.Set(types.RecoveryChallengeKey(record.Challenge), []byte(record.Address)) +} + +func (k Keeper) DeleteRecoveryRecord(ctx sdk.Context, record types.RecoveryRecord) { + store := ctx.KVStore(k.storeKey) + store.Delete(types.RecoveryRecordKey(record.Address)) + store.Delete(types.RecoveryChallengeKey(record.Challenge)) +} + +func (k Keeper) GetAllRecoveryRecords(ctx sdk.Context) []types.RecoveryRecord { + store := ctx.KVStore(k.storeKey) + + records := []types.RecoveryRecord{} + it := sdk.KVStorePrefixIterator(store, types.RecoveryRecordKeyPrefix) + defer it.Close() + + for ; it.Valid(); it.Next() { + record := types.RecoveryRecord{} + k.cdc.MustUnmarshal(it.Value(), &record) + records = append(records, record) + } + return records +} + +func (k Keeper) GetRecoveryToken(ctx sdk.Context, address string) (types.RecoveryToken, error) { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.RecoveryTokenKey(address)) + if bz == nil { + return types.RecoveryToken{}, sdkerrors.Wrapf(types.ErrRecoveryTokenDoesNotExist, "RecoveryToken: %s does not exist", address) + } + recovery := types.RecoveryToken{} + k.cdc.MustUnmarshal(bz, &recovery) + return recovery, nil +} + +func (k Keeper) GetRecoveryTokenByDenom(ctx sdk.Context, denom string) (types.RecoveryToken, error) { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.RecoveryTokenByDenomKey(denom)) + if bz == nil { + return types.RecoveryToken{}, sdkerrors.Wrapf(types.ErrRecoveryTokenDoesNotExist, "RecoveryTokenByDenom: %s does not exist", denom) + } + address := string(bz) + return k.GetRecoveryToken(ctx, address) +} + +func (k Keeper) SetRecoveryToken(ctx sdk.Context, recovery types.RecoveryToken) { + bz := k.cdc.MustMarshal(&recovery) + store := ctx.KVStore(k.storeKey) + store.Set(types.RecoveryTokenKey(recovery.Address), bz) + store.Set(types.RecoveryTokenByDenomKey(recovery.Token), []byte(recovery.Address)) +} + +func (k Keeper) DeleteRecoveryToken(ctx sdk.Context, recovery types.RecoveryToken) { + store := ctx.KVStore(k.storeKey) + store.Delete(types.RecoveryTokenKey(recovery.Address)) + store.Delete(types.RecoveryTokenByDenomKey(recovery.Token)) +} + +func calcPortion(coins sdk.Coins, portion sdk.Int, supply sdk.Int) sdk.Coins { + portionCoins := sdk.Coins{} + for _, coin := range coins { + portionCoin := sdk.NewCoin(coin.Denom, coin.Amount.Mul(portion).Quo(supply)) + portionCoins = portionCoins.Add(portionCoin) + } + return portionCoins +} + +func (k Keeper) IncreaseRecoveryTokenUnderlying(ctx sdk.Context, addr sdk.AccAddress, amount sdk.Coins) error { + recoveryToken, err := k.GetRecoveryToken(ctx, addr.String()) + if err != nil { + return err + } + + k.UnregisterNotEnoughAmountHolder(ctx, recoveryToken.Token) + + supply := k.bk.GetSupply(ctx, recoveryToken.Token).Amount + + holders := k.GetRRTokenHolders(ctx, recoveryToken.Token) + totalAllocation := sdk.NewCoins() + for _, holder := range holders { + balances := k.bk.GetAllBalances(ctx, holder) + balance := balances.AmountOf(recoveryToken.Token) + allocation := calcPortion(amount, balance, supply) + totalAllocation = totalAllocation.Add(allocation...) + k.IncreaseRRTokenHolderRewards(ctx, holder, allocation) + } + + unallocated := amount.Sub(totalAllocation) + recoveryToken.UnderlyingTokens = sdk.Coins(recoveryToken.UnderlyingTokens).Add(unallocated...) + k.SetRecoveryToken(ctx, recoveryToken) + return nil +} + +func (k Keeper) GetAllRecoveryTokens(ctx sdk.Context) []types.RecoveryToken { + store := ctx.KVStore(k.storeKey) + + recoveries := []types.RecoveryToken{} + it := sdk.KVStorePrefixIterator(store, types.RecoveryTokenKeyPrefix) + defer it.Close() + + for ; it.Valid(); it.Next() { + recovery := types.RecoveryToken{} + k.cdc.MustUnmarshal(it.Value(), &recovery) + recoveries = append(recoveries, recovery) + } + return recoveries +} diff --git a/x/recovery/keeper/recovery_test.go b/x/recovery/keeper/recovery_test.go new file mode 100644 index 000000000..88412bb27 --- /dev/null +++ b/x/recovery/keeper/recovery_test.go @@ -0,0 +1,101 @@ +package keeper_test + +import ( + "github.com/KiraCore/sekai/x/recovery/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/tendermint/tendermint/crypto/ed25519" +) + +func (suite *KeeperTestSuite) TestRecoveryRecordSetGetDelete() { + addr1 := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address().Bytes()) + addr2 := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address().Bytes()) + records := []types.RecoveryRecord{ + { + Address: addr1.String(), + Challenge: "12345678", + Nonce: "001100110022", + }, + { + Address: addr2.String(), + Challenge: "87654321", + Nonce: "001100110022", + }, + } + + for _, record := range records { + suite.app.RecoveryKeeper.SetRecoveryRecord(suite.ctx, record) + } + + for _, record := range records { + r, err := suite.app.RecoveryKeeper.GetRecoveryRecord(suite.ctx, record.Address) + suite.Require().NoError(err) + suite.Require().Equal(r, record) + } + + allRecords := suite.app.RecoveryKeeper.GetAllRecoveryRecords(suite.ctx) + suite.Require().Len(allRecords, 2) + + addr := suite.app.RecoveryKeeper.GetRecoveryAddressFromChallenge(suite.ctx, records[0].Challenge) + suite.Require().Equal(addr, records[0].Address) + + suite.app.RecoveryKeeper.DeleteRecoveryRecord(suite.ctx, records[0]) + + allRecords = suite.app.RecoveryKeeper.GetAllRecoveryRecords(suite.ctx) + suite.Require().Len(allRecords, 1) + + _, err := suite.app.RecoveryKeeper.GetRecoveryRecord(suite.ctx, records[0].Address) + suite.Require().Error(err) +} + +func (suite *KeeperTestSuite) TestRecoveryTokenSetGetDelete() { + addr1 := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address().Bytes()) + addr2 := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address().Bytes()) + records := []types.RecoveryToken{ + { + Address: addr1.String(), + Token: "rr_moniker1", + RrSupply: sdk.NewInt(10000), + UnderlyingTokens: sdk.NewCoins(sdk.NewInt64Coin("ukex", 1000000)), + }, + { + Address: addr2.String(), + Token: "rr_moniker2", + RrSupply: sdk.NewInt(20000), + UnderlyingTokens: sdk.NewCoins(sdk.NewInt64Coin("ukex", 2000000)), + }, + } + + for _, record := range records { + suite.app.RecoveryKeeper.SetRecoveryToken(suite.ctx, record) + } + + for _, record := range records { + r, err := suite.app.RecoveryKeeper.GetRecoveryToken(suite.ctx, record.Address) + suite.Require().NoError(err) + suite.Require().Equal(r, record) + } + + allRecords := suite.app.RecoveryKeeper.GetAllRecoveryTokens(suite.ctx) + suite.Require().Len(allRecords, 2) + + recoveryToken, err := suite.app.RecoveryKeeper.GetRecoveryTokenByDenom(suite.ctx, records[0].Token) + suite.Require().NoError(err) + suite.Require().Equal(recoveryToken, records[0]) + + err = suite.app.RecoveryKeeper.IncreaseRecoveryTokenUnderlying(suite.ctx, addr1, sdk.NewCoins(sdk.NewInt64Coin("reward", 10000))) + suite.Require().NoError(err) + recoveryToken, err = suite.app.RecoveryKeeper.GetRecoveryToken(suite.ctx, records[0].Address) + suite.Require().NoError(err) + suite.Require().Equal(sdk.Coins(recoveryToken.UnderlyingTokens).String(), "10000reward,1000000ukex") + + suite.app.RecoveryKeeper.DeleteRecoveryToken(suite.ctx, records[0]) + + allRecords = suite.app.RecoveryKeeper.GetAllRecoveryTokens(suite.ctx) + suite.Require().Len(allRecords, 1) + + _, err = suite.app.RecoveryKeeper.GetRecoveryToken(suite.ctx, records[0].Address) + suite.Require().Error(err) + + _, err = suite.app.RecoveryKeeper.GetRecoveryTokenByDenom(suite.ctx, records[0].Token) + suite.Require().Error(err) +} diff --git a/x/recovery/keeper/rewards.go b/x/recovery/keeper/rewards.go new file mode 100644 index 000000000..7ed213b4b --- /dev/null +++ b/x/recovery/keeper/rewards.go @@ -0,0 +1,140 @@ +package keeper + +import ( + "github.com/KiraCore/sekai/x/recovery/types" + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +var MinHoldAmount = sdk.NewInt(1000_000) + +func (k Keeper) SetRRTokenHolder(ctx sdk.Context, rrToken string, delegator sdk.AccAddress) { + store := ctx.KVStore(k.storeKey) + key := append(append(types.KeyPrefixRRTokenHolder, rrToken...), delegator...) + store.Set(key, delegator) +} + +func (k Keeper) RemoveRRTokenHolder(ctx sdk.Context, rrToken string, delegator sdk.AccAddress) { + store := ctx.KVStore(k.storeKey) + key := append(append(types.KeyPrefixRRTokenHolder, rrToken...), delegator...) + store.Delete(key) +} + +func (k Keeper) IsRRTokenHolder(ctx sdk.Context, rrToken string, delegator sdk.AccAddress) bool { + store := ctx.KVStore(k.storeKey) + key := append(append(types.KeyPrefixRRTokenHolder, rrToken...), delegator...) + bz := store.Get(key) + return bz != nil +} + +func (k Keeper) GetRRTokenHolders(ctx sdk.Context, rrToken string) []sdk.AccAddress { + prefixStore := prefix.NewStore(ctx.KVStore(k.storeKey), append(types.KeyPrefixRRTokenHolder, rrToken...)) + + iterator := prefixStore.Iterator(nil, nil) + defer iterator.Close() + + delegators := []sdk.AccAddress{} + for ; iterator.Valid(); iterator.Next() { + delegators = append(delegators, sdk.AccAddress(iterator.Value())) + } + return delegators +} + +func (k Keeper) SetRRTokenHolderRewards(ctx sdk.Context, holder sdk.AccAddress, rewards sdk.Coins) { + store := ctx.KVStore(k.storeKey) + key := append(types.KeyPrefixRewards, holder...) + store.Set(key, []byte(rewards.String())) +} + +func (k Keeper) IncreaseRRTokenHolderRewards(ctx sdk.Context, holder sdk.AccAddress, amounts sdk.Coins) { + rewards := k.GetRRTokenHolderRewards(ctx, holder) + rewards = rewards.Add(amounts...) + + k.SetRRTokenHolderRewards(ctx, holder, rewards) +} + +func (k Keeper) RemoveRRTokenHolderRewards(ctx sdk.Context, holder sdk.AccAddress) { + store := ctx.KVStore(k.storeKey) + key := append(types.KeyPrefixRewards, holder...) + store.Delete(key) +} + +func (k Keeper) GetRRTokenHolderRewards(ctx sdk.Context, holder sdk.AccAddress) sdk.Coins { + store := ctx.KVStore(k.storeKey) + key := append(types.KeyPrefixRewards, holder...) + bz := store.Get(key) + if bz == nil { + return sdk.Coins{} + } + + coinStr := string(bz) + coins, err := sdk.ParseCoinsNormalized(coinStr) + if err != nil { + panic(err) + } + + return coins +} + +func (k Keeper) GetAllRRHolderRewards(ctx sdk.Context) []types.Rewards { + rewards := []types.Rewards{} + + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefixRewards) + iterator := sdk.KVStorePrefixIterator(store, nil) + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + rewardsCoins, err := sdk.ParseCoinsNormalized(string(iterator.Value())) + if err != nil { + panic(err) + } + rewards = append(rewards, types.Rewards{ + Holder: sdk.AccAddress(iterator.Key()).String(), + Rewards: rewardsCoins, + }) + } + return rewards +} + +func (k Keeper) RegisterRRTokenHolder(ctx sdk.Context, delegator sdk.AccAddress) { + balances := k.bk.GetAllBalances(ctx, delegator) + + recoveryTokens := k.GetAllRecoveryTokens(ctx) + for _, recoveryToken := range recoveryTokens { + if k.IsRRTokenHolder(ctx, recoveryToken.Token, delegator) { + continue + } + + balance := balances.AmountOf(recoveryToken.Token) + if balance.GTE(MinHoldAmount) { + k.SetRRTokenHolder(ctx, recoveryToken.Token, delegator) + break + } + } +} + +func (k Keeper) UnregisterNotEnoughAmountHolder(ctx sdk.Context, rrToken string) { + holders := k.GetRRTokenHolders(ctx, rrToken) + + for _, holder := range holders { + toBeRemoved := true + balances := k.bk.GetAllBalances(ctx, holder) + if balances.AmountOf(rrToken).GTE(MinHoldAmount) { + toBeRemoved = false + } + if toBeRemoved { + k.RemoveRRTokenHolder(ctx, rrToken, holder) + } + } +} + +func (k Keeper) ClaimRewards(ctx sdk.Context, delegator sdk.AccAddress) sdk.Coins { + rewards := k.GetRRTokenHolderRewards(ctx, delegator) + err := k.bk.SendCoinsFromModuleToAccount(ctx, types.ModuleName, delegator, rewards) + if err != nil { + panic(err) + } + + k.RemoveRRTokenHolderRewards(ctx, delegator) + return rewards +} diff --git a/x/recovery/keeper/rewards_test.go b/x/recovery/keeper/rewards_test.go new file mode 100644 index 000000000..ed0054b92 --- /dev/null +++ b/x/recovery/keeper/rewards_test.go @@ -0,0 +1,80 @@ +package keeper_test + +import ( + "github.com/KiraCore/sekai/x/multistaking/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/tendermint/tendermint/crypto/ed25519" +) + +func (suite *KeeperTestSuite) TestRRTokenHolderSetGetDelete() { + addr1 := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address().Bytes()) + addr2 := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address().Bytes()) + addr3 := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address().Bytes()) + holders := []sdk.AccAddress{ + addr1, + addr2, + addr3, + } + + for _, holder := range holders { + suite.app.RecoveryKeeper.SetRRTokenHolder(suite.ctx, "rr/val1", holder) + } + + for _, holder := range holders { + isHolder := suite.app.RecoveryKeeper.IsRRTokenHolder(suite.ctx, "rr/val1", holder) + suite.Require().True(isHolder) + } + + allHolders := suite.app.RecoveryKeeper.GetRRTokenHolders(suite.ctx, "rr/val1") + suite.Require().Len(allHolders, 3) + + suite.app.RecoveryKeeper.RemoveRRTokenHolder(suite.ctx, "rr/val1", holders[0]) + + allHolders = suite.app.RecoveryKeeper.GetRRTokenHolders(suite.ctx, "rr/val1") + suite.Require().Len(allHolders, 2) +} + +func (suite *KeeperTestSuite) TestRRTokenHolderRewardsSetGetDelete() { + addr1 := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address().Bytes()) + addr2 := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address().Bytes()) + addr3 := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address().Bytes()) + rewards := []types.Rewards{ + { + Delegator: addr1.String(), + Rewards: sdk.NewCoins(sdk.NewInt64Coin("token1", 1000)), + }, + { + Delegator: addr2.String(), + Rewards: sdk.NewCoins(sdk.NewInt64Coin("token2", 1000)), + }, + { + Delegator: addr3.String(), + Rewards: sdk.NewCoins(sdk.NewInt64Coin("token3", 1000)), + }, + } + + for _, reward := range rewards { + holder := sdk.MustAccAddressFromBech32(reward.Delegator) + suite.app.RecoveryKeeper.SetRRTokenHolderRewards(suite.ctx, holder, reward.Rewards) + } + + for _, reward := range rewards { + holder := sdk.MustAccAddressFromBech32(reward.Delegator) + coins := suite.app.RecoveryKeeper.GetRRTokenHolderRewards(suite.ctx, holder) + suite.Require().Equal(coins.String(), sdk.Coins(reward.Rewards).String()) + } + + allRewards := suite.app.RecoveryKeeper.GetAllRRHolderRewards(suite.ctx) + suite.Require().Len(allRewards, 3) + + suite.app.RecoveryKeeper.RemoveRRTokenHolderRewards(suite.ctx, addr1) + + allRewards = suite.app.RecoveryKeeper.GetAllRRHolderRewards(suite.ctx) + suite.Require().Len(allRewards, 2) + + suite.app.RecoveryKeeper.IncreaseRRTokenHolderRewards(suite.ctx, addr1, sdk.NewCoins(sdk.NewInt64Coin("token2", 1000))) + allRewards = suite.app.RecoveryKeeper.GetAllRRHolderRewards(suite.ctx) + suite.Require().Len(allRewards, 3) +} + +// TODO: add test for UnregisterNotEnoughAmountHolder diff --git a/x/recovery/keeper/rotation.go b/x/recovery/keeper/rotation.go new file mode 100644 index 000000000..6576ae244 --- /dev/null +++ b/x/recovery/keeper/rotation.go @@ -0,0 +1,44 @@ +package keeper + +import ( + "github.com/KiraCore/sekai/x/recovery/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func (k Keeper) SetRotationHistory(ctx sdk.Context, rotation types.Rotation) { + bz := k.cdc.MustMarshal(&rotation) + store := ctx.KVStore(k.storeKey) + store.Set(types.RotationHistoryKey(rotation.Address), bz) +} + +func (k Keeper) DeleteRotationHistory(ctx sdk.Context, rotation types.Rotation) { + store := ctx.KVStore(k.storeKey) + store.Delete(types.RotationHistoryKey(rotation.Address)) +} + +func (k Keeper) GetRotationHistory(ctx sdk.Context, address string) types.Rotation { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.RotationHistoryKey(address)) + if bz == nil { + return types.Rotation{} + } + + rotation := types.Rotation{} + k.cdc.MustUnmarshal(bz, &rotation) + return rotation +} + +func (k Keeper) GetAllRotationHistory(ctx sdk.Context) []types.Rotation { + store := ctx.KVStore(k.storeKey) + + rotations := []types.Rotation{} + it := sdk.KVStorePrefixIterator(store, types.RotationHistoryKeyPrefix) + defer it.Close() + + for ; it.Valid(); it.Next() { + rotation := types.Rotation{} + k.cdc.MustUnmarshal(it.Value(), &rotation) + rotations = append(rotations, rotation) + } + return rotations +} diff --git a/x/recovery/keeper/rotation_test.go b/x/recovery/keeper/rotation_test.go new file mode 100644 index 000000000..97ea34648 --- /dev/null +++ b/x/recovery/keeper/rotation_test.go @@ -0,0 +1,40 @@ +package keeper_test + +import ( + "github.com/KiraCore/sekai/x/recovery/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/tendermint/tendermint/crypto/ed25519" +) + +func (suite *KeeperTestSuite) TestRotationHistorySetGetDelete() { + addr1 := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address().Bytes()) + addr2 := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address().Bytes()) + addr3 := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address().Bytes()) + records := []types.Rotation{ + { + Address: addr1.String(), + Rotated: addr2.String(), + }, + { + Address: addr2.String(), + Rotated: addr3.String(), + }, + } + + for _, record := range records { + suite.app.RecoveryKeeper.SetRotationHistory(suite.ctx, record) + } + + for _, record := range records { + r := suite.app.RecoveryKeeper.GetRotationHistory(suite.ctx, record.Address) + suite.Require().Equal(r, record) + } + + allRecords := suite.app.RecoveryKeeper.GetAllRotationHistory(suite.ctx) + suite.Require().Len(allRecords, 2) + + suite.app.RecoveryKeeper.DeleteRotationHistory(suite.ctx, records[0]) + + allRecords = suite.app.RecoveryKeeper.GetAllRotationHistory(suite.ctx) + suite.Require().Len(allRecords, 1) +} diff --git a/x/recovery/module.go b/x/recovery/module.go new file mode 100644 index 000000000..36f658804 --- /dev/null +++ b/x/recovery/module.go @@ -0,0 +1,198 @@ +package recovery + +import ( + "context" + "encoding/json" + "fmt" + "math/rand" + + "github.com/grpc-ecosystem/grpc-gateway/runtime" + + "github.com/gorilla/mux" + "github.com/spf13/cobra" + + abci "github.com/tendermint/tendermint/abci/types" + + "github.com/KiraCore/sekai/x/recovery/client/cli" + "github.com/KiraCore/sekai/x/recovery/keeper" + "github.com/KiraCore/sekai/x/recovery/types" + stakingkeeper "github.com/KiraCore/sekai/x/staking/keeper" + "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" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" +) + +var ( + _ module.AppModule = AppModule{} + _ module.AppModuleBasic = AppModuleBasic{} +) + +// AppModuleBasic defines the basic application module used by the recovery module. +type AppModuleBasic struct { + cdc codec.Codec +} + +var _ module.AppModuleBasic = AppModuleBasic{} + +// Name returns the recovery module's name. +func (AppModuleBasic) Name() string { + return types.ModuleName +} + +// RegisterLegacyAminoCodec registers the recovery module's types for the given codec. +func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + types.RegisterLegacyAminoCodec(cdc) +} + +// RegisterInterfaces registers the module's interface types +func (b AppModuleBasic) RegisterInterfaces(registry cdctypes.InterfaceRegistry) { + types.RegisterInterfaces(registry) +} + +// DefaultGenesis returns default genesis state as raw bytes for the recovery +// module. +func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { + return cdc.MustMarshalJSON(types.DefaultGenesisState()) +} + +// ValidateGenesis performs genesis state validation for the recovery module. +func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, bz json.RawMessage) error { + var data types.GenesisState + if err := cdc.UnmarshalJSON(bz, &data); err != nil { + return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err) + } + + return types.ValidateGenesis(data) +} + +// RegisterRESTRoutes registers the REST routes for the recovery module. +func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router) { +} + +// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the slashig module. +func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { +} + +func (AppModuleBasic) RegisterGRPCRoutes(clientCtx client.Context, serveMux *runtime.ServeMux) { + types.RegisterQueryHandlerClient(context.Background(), serveMux, types.NewQueryClient(clientCtx)) +} + +// GetTxCmd returns the root tx command for the recovery module. +func (AppModuleBasic) GetTxCmd() *cobra.Command { + return cli.NewTxCmd() +} + +// GetQueryCmd returns no root query command for the recovery module. +func (AppModuleBasic) GetQueryCmd() *cobra.Command { + return cli.GetQueryCmd() +} + +//____________________________________________________________________________ + +// AppModule implements an application module for the recovery module. +type AppModule struct { + AppModuleBasic + + keeper keeper.Keeper + accountKeeper types.AccountKeeper + stakingKeeper stakingkeeper.Keeper +} + +// NewAppModule creates a new AppModule object +func NewAppModule(cdc codec.Codec, keeper keeper.Keeper, ak types.AccountKeeper, sk stakingkeeper.Keeper) AppModule { + return AppModule{ + AppModuleBasic: AppModuleBasic{cdc: cdc}, + keeper: keeper, + accountKeeper: ak, + stakingKeeper: sk, + } +} + +// Name returns the recovery module's name. +func (AppModule) Name() string { + return types.ModuleName +} + +// RegisterInvariants registers the recovery module invariants. +func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} + +// Route returns the message routing key for the recovery module. +func (am AppModule) Route() sdk.Route { + return sdk.NewRoute(types.RouterKey, NewHandler(am.keeper)) +} + +// QuerierRoute returns the recovery module's querier route name. +func (AppModule) QuerierRoute() string { + return types.QuerierRoute +} + +// LegacyQuerierHandler returns the recovery module sdk.Querier. +func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sdk.Querier { + return nil +} + +// RegisterServices registers module services. +func (am AppModule) RegisterServices(cfg module.Configurator) { + types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) + types.RegisterQueryServer(cfg.QueryServer(), am.keeper) +} + +// InitGenesis performs genesis initialization for the recovery module. It returns +// no validator updates. +func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate { + var genesisState types.GenesisState + cdc.MustUnmarshalJSON(data, &genesisState) + InitGenesis(ctx, am.keeper, am.stakingKeeper, &genesisState) + return []abci.ValidatorUpdate{} +} + +// ExportGenesis returns the exported genesis state as raw bytes for the recovery +// module. +func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { + gs := ExportGenesis(ctx, am.keeper) + return cdc.MustMarshalJSON(gs) +} + +// ConsensusVersion implements AppModule/ConsensusVersion. +func (AppModule) ConsensusVersion() uint64 { return 1 } + +// BeginBlock returns the begin blocker for the recovery module. +func (am AppModule) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock) { + BeginBlocker(ctx, req, am.keeper) +} + +// EndBlock returns the end blocker for the recovery module. It returns no validator +// updates. +func (AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { + return []abci.ValidatorUpdate{} +} + +//____________________________________________________________________________ + +// AppModuleSimulation functions + +// GenerateGenesisState creates a randomized GenState of the recovery module. +func (AppModule) GenerateGenesisState(simState *module.SimulationState) { +} + +// ProposalContents doesn't return any content functions for governance proposals. +func (AppModule) ProposalContents(simState module.SimulationState) []simtypes.WeightedProposalContent { + return nil +} + +// RandomizedParams creates randomized recovery param changes for the simulator. +func (AppModule) RandomizedParams(r *rand.Rand) []simtypes.ParamChange { + return []simtypes.ParamChange{} +} + +// RegisterStoreDecoder registers a decoder for recovery module's types +func (am AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) { +} + +// WeightedOperations returns the all the recovery module operations with their respective weights. +func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation { + return []simtypes.WeightedOperation{} +} diff --git a/x/recovery/types/codec.go b/x/recovery/types/codec.go new file mode 100644 index 000000000..baf933f91 --- /dev/null +++ b/x/recovery/types/codec.go @@ -0,0 +1,51 @@ +package types + +import ( + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/codec/types" + cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/msgservice" +) + +// RegisterLegacyAminoCodec registers concrete types on LegacyAmino codec +func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + cdc.RegisterConcrete(&MsgRegisterRecoverySecret{}, "cosmos-sdk/MsgRegisterRecoverySecret", nil) + cdc.RegisterConcrete(&MsgRotateRecoveryAddress{}, "cosmos-sdk/MsgRotateRecoveryAddress", nil) + cdc.RegisterConcrete(&MsgIssueRecoveryTokens{}, "cosmos-sdk/MsgIssueRecoveryTokens", nil) + cdc.RegisterConcrete(&MsgBurnRecoveryTokens{}, "cosmos-sdk/MsgBurnRecoveryTokens", nil) + cdc.RegisterConcrete(&MsgClaimRRHolderRewards{}, "cosmos-sdk/MsgClaimRRHolderRewards", nil) + cdc.RegisterConcrete(&MsgRegisterRRTokenHolder{}, "cosmos-sdk/MsgRegisterRRTokenHolder", nil) +} + +// RegisterInterfaces register interfaces on registry +func RegisterInterfaces(registry types.InterfaceRegistry) { + registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgRegisterRecoverySecret{}, + &MsgRotateRecoveryAddress{}, + &MsgIssueRecoveryTokens{}, + &MsgBurnRecoveryTokens{}, + &MsgClaimRRHolderRewards{}, + &MsgRegisterRRTokenHolder{}, + ) + + msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) +} + +var ( + amino = codec.NewLegacyAmino() + + // ModuleCdc references the global x/recovery module codec. Note, the codec + // should ONLY be used in certain instances of tests and for JSON encoding as Amino + // is still used for that purpose. + // + // The actual codec used for serialization should be provided to x/recovery and + // defined at the application level. + ModuleCdc = codec.NewAminoCodec(amino) +) + +func init() { + RegisterLegacyAminoCodec(amino) + cryptocodec.RegisterCrypto(amino) + amino.Seal() +} diff --git a/x/recovery/types/errors.go b/x/recovery/types/errors.go new file mode 100644 index 000000000..0778c1839 --- /dev/null +++ b/x/recovery/types/errors.go @@ -0,0 +1,20 @@ +package types + +import ( + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +// x/recovery module sentinel errors +var ( + ErrInvalidAccAddress = sdkerrors.Register(ModuleName, 2, "invalid account address") + ErrRecoveryRecordDoesNotExist = sdkerrors.Register(ModuleName, 3, "recovery record does not exist") + ErrRecoveryTokenDoesNotExist = sdkerrors.Register(ModuleName, 4, "recovery token does not exist") + ErrInvalidProof = sdkerrors.Register(ModuleName, 5, "invalid proof") + ErrRotatedAccountAlreadyExists = sdkerrors.Register(ModuleName, 6, "rotated account already exists") + ErrAccountDoesNotExists = sdkerrors.Register(ModuleName, 7, "account does not exist") + ErrInvalidMoniker = sdkerrors.Register(ModuleName, 8, "invalid moniker") + ErrRecoveryTokenAlreadyExists = sdkerrors.Register(ModuleName, 9, "recovery token already exists") + ErrAddressHasValidatorRecoveryToken = sdkerrors.Register(ModuleName, 10, "address already has validator recovery token") + ErrNotEnoughRRTokenAmountForRotation = sdkerrors.Register(ModuleName, 11, "not enough rr token amount for rotation") + ErrTargetAddressAlreadyHasRotationHistory = sdkerrors.Register(ModuleName, 12, "target address already has rotation history") +) diff --git a/x/recovery/types/events.go b/x/recovery/types/events.go new file mode 100644 index 000000000..8d0fa1603 --- /dev/null +++ b/x/recovery/types/events.go @@ -0,0 +1,2 @@ +//noalias +package types diff --git a/x/recovery/types/expected_keepers.go b/x/recovery/types/expected_keepers.go new file mode 100644 index 000000000..984a342d0 --- /dev/null +++ b/x/recovery/types/expected_keepers.go @@ -0,0 +1,171 @@ +package types + +import ( + collectivestypes "github.com/KiraCore/sekai/x/collectives/types" + custodytypes "github.com/KiraCore/sekai/x/custody/types" + govtypes "github.com/KiraCore/sekai/x/gov/types" + multistakingtypes "github.com/KiraCore/sekai/x/multistaking/types" + spendingtypes "github.com/KiraCore/sekai/x/spending/types" + stakingtypes "github.com/KiraCore/sekai/x/staking/types" + sdk "github.com/cosmos/cosmos-sdk/types" + auth "github.com/cosmos/cosmos-sdk/x/auth/types" + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" +) + +// AccountKeeper expected account keeper +type AccountKeeper interface { + GetAccount(ctx sdk.Context, addr sdk.AccAddress) auth.AccountI + SetAccount(ctx sdk.Context, acc auth.AccountI) + IterateAccounts(ctx sdk.Context, process func(auth.AccountI) (stop bool)) +} + +type BankKeeper interface { + GetAllBalances(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins + GetSupply(ctx sdk.Context, denom string) sdk.Coin + SendCoins(ctx sdk.Context, fromAddr sdk.AccAddress, toAddr sdk.AccAddress, amt sdk.Coins) error + MintCoins(ctx sdk.Context, moduleName string, amt sdk.Coins) error + BurnCoins(ctx sdk.Context, moduleName string, amt sdk.Coins) error + SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error + SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error + SendCoinsFromModuleToModule(ctx sdk.Context, senderModule, recipientModule string, amt sdk.Coins) error +} + +// ParamSubspace defines the expected Subspace interfacace +type ParamSubspace interface { + HasKeyTable() bool + WithKeyTable(table paramtypes.KeyTable) paramtypes.Subspace + Get(ctx sdk.Context, key []byte, ptr interface{}) + GetParamSet(ctx sdk.Context, ps paramtypes.ParamSet) + SetParamSet(ctx sdk.Context, ps paramtypes.ParamSet) +} + +// StakingKeeper expected staking keeper +type StakingKeeper interface { + // iterate through validators by operator address, execute func for each validator + IterateValidators(sdk.Context, + func(index int64, validator *stakingtypes.Validator) (stop bool)) + + GetValidator(sdk.Context, sdk.ValAddress) (stakingtypes.Validator, error) // get a particular validator by operator address + GetValidatorByConsAddr(sdk.Context, sdk.ConsAddress) (stakingtypes.Validator, error) // get a particular validator by consensus address + GetValidatorSet(ctx sdk.Context) []stakingtypes.Validator // get all validator set + AddValidator(ctx sdk.Context, validator stakingtypes.Validator) + RemoveValidator(ctx sdk.Context, validator stakingtypes.Validator) + + // activate/inactivate the validator and delegators of the validator, specifying offence height, offence power, and slash fraction + Inactivate(sdk.Context, sdk.ValAddress) error // inactivate a validator + Activate(sdk.Context, sdk.ValAddress) error // activate a validator + Jail(sdk.Context, sdk.ValAddress) error // jail a validator + ResetWholeValidatorRank(sdk.Context) // reset whole validator rank + + // pause/unpause the validator and delegators of the validator, specifying offence height, offence power, and slash fraction + Pause(sdk.Context, sdk.ValAddress) error // pause a validator + Unpause(sdk.Context, sdk.ValAddress) error // unpause a validator + + HandleValidatorSignature(sdk.Context, sdk.ValAddress, bool, int64) error + + // MaxValidators returns the maximum amount of joined validators + MaxValidators(sdk.Context) uint32 + + GetIdRecordsByAddress(sdk.Context, sdk.AccAddress) []govtypes.IdentityRecord +} + +// StakingHooks event hooks for staking validator object (noalias) +type StakingHooks interface { + AfterValidatorCreated(ctx sdk.Context, valAddr sdk.ValAddress) // Must be called when a validator is created + AfterValidatorRemoved(ctx sdk.Context, consAddr sdk.ConsAddress, valAddr sdk.ValAddress) // Must be called when a validator is deleted + AfterValidatorJoined(ctx sdk.Context, consAddr sdk.ConsAddress, valAddr sdk.ValAddress) // Must be called when a validator is joined +} + +// GovKeeper expected governance keeper +type GovKeeper interface { + GetNetworkProperties(ctx sdk.Context) *govtypes.NetworkProperties + + SaveCouncilor(ctx sdk.Context, councilor govtypes.Councilor) + DeleteCouncilor(ctx sdk.Context, councilor govtypes.Councilor) + GetCouncilor(ctx sdk.Context, address sdk.AccAddress) (govtypes.Councilor, bool) + + GetIdRecordsByAddress(ctx sdk.Context, address sdk.AccAddress) []govtypes.IdentityRecord + SetIdentityRecord(ctx sdk.Context, record govtypes.IdentityRecord) + DeleteIdentityRecordById(ctx sdk.Context, recordId uint64) + + GetIdentityRecordIdByAddressKey(ctx sdk.Context, address sdk.AccAddress, key string) uint64 + GetIdentityRecordById(ctx sdk.Context, recordId uint64) *govtypes.IdentityRecord + GetIdRecordsByAddressAndKeys(ctx sdk.Context, address sdk.AccAddress, keys []string) ([]govtypes.IdentityRecord, error) + + SetIdentityRecordsVerifyRequest(ctx sdk.Context, request govtypes.IdentityRecordsVerify) + DeleteIdRecordsVerifyRequest(ctx sdk.Context, requestId uint64) + GetIdRecordsVerifyRequestsByRequester(ctx sdk.Context, requester sdk.AccAddress) []govtypes.IdentityRecordsVerify + GetIdRecordsVerifyRequestsByApprover(ctx sdk.Context, requester sdk.AccAddress) []govtypes.IdentityRecordsVerify + + SaveNetworkActor(ctx sdk.Context, actor govtypes.NetworkActor) + DeleteNetworkActor(ctx sdk.Context, actor govtypes.NetworkActor) + GetNetworkActorByAddress(ctx sdk.Context, address sdk.AccAddress) (govtypes.NetworkActor, bool) + SetWhitelistAddressPermKey(ctx sdk.Context, actor govtypes.NetworkActor, perm govtypes.PermValue) + RemoveRoleFromActor(ctx sdk.Context, actor govtypes.NetworkActor, role uint64) + AssignRoleToActor(ctx sdk.Context, actor govtypes.NetworkActor, role uint64) + DeleteWhitelistAddressPermKey(ctx sdk.Context, actor govtypes.NetworkActor, perm govtypes.PermValue) + + SaveVote(ctx sdk.Context, vote govtypes.Vote) + DeleteVote(ctx sdk.Context, vote govtypes.Vote) + GetVote(ctx sdk.Context, proposalID uint64, address sdk.AccAddress) (govtypes.Vote, bool) + GetProposals(ctx sdk.Context) ([]govtypes.Proposal, error) + SaveProposal(ctx sdk.Context, proposal govtypes.Proposal) +} + +type MultiStakingKeeper interface { + GetCompoundInfoByAddress(ctx sdk.Context, addr string) multistakingtypes.CompoundInfo + SetCompoundInfo(ctx sdk.Context, info multistakingtypes.CompoundInfo) + RemoveCompoundInfo(ctx sdk.Context, info multistakingtypes.CompoundInfo) + + SetPoolDelegator(ctx sdk.Context, poolId uint64, delegator sdk.AccAddress) + RemovePoolDelegator(ctx sdk.Context, poolId uint64, delegator sdk.AccAddress) + IsPoolDelegator(ctx sdk.Context, poolId uint64, delegator sdk.AccAddress) bool + + SetDelegatorRewards(ctx sdk.Context, delegator sdk.AccAddress, rewards sdk.Coins) + RemoveDelegatorRewards(ctx sdk.Context, delegator sdk.AccAddress) + GetDelegatorRewards(ctx sdk.Context, delegator sdk.AccAddress) sdk.Coins + + GetAllStakingPools(ctx sdk.Context) []multistakingtypes.StakingPool + GetStakingPoolByValidator(ctx sdk.Context, validator string) (pool multistakingtypes.StakingPool, found bool) + SetStakingPool(ctx sdk.Context, pool multistakingtypes.StakingPool) + RemoveStakingPool(ctx sdk.Context, pool multistakingtypes.StakingPool) +} + +type CollectivesKeeper interface { + SetCollectiveContributer(ctx sdk.Context, cc collectivestypes.CollectiveContributor) + DeleteCollectiveContributer(ctx sdk.Context, name, address string) + GetAllCollectiveContributers(ctx sdk.Context) []collectivestypes.CollectiveContributor +} + +type SpendingKeeper interface { + GetAllSpendingPools(ctx sdk.Context) []spendingtypes.SpendingPool + SetClaimInfo(ctx sdk.Context, claimInfo spendingtypes.ClaimInfo) + RemoveClaimInfo(ctx sdk.Context, claimInfo spendingtypes.ClaimInfo) + GetClaimInfo(ctx sdk.Context, poolName string, address sdk.AccAddress) *spendingtypes.ClaimInfo +} + +type CustodyKeeper interface { + GetCustodyInfoByAddress(ctx sdk.Context, address sdk.AccAddress) *custodytypes.CustodySettings + SetCustodyRecord(ctx sdk.Context, record custodytypes.CustodyRecord) + DisableCustodyRecord(ctx sdk.Context, address sdk.AccAddress) + + GetCustodyCustodiansByAddress(ctx sdk.Context, address sdk.AccAddress) *custodytypes.CustodyCustodianList + AddToCustodyCustodians(ctx sdk.Context, record custodytypes.CustodyCustodiansRecord) + DropCustodyCustodiansByAddress(ctx sdk.Context, address sdk.AccAddress) + + GetCustodyWhiteListByAddress(ctx sdk.Context, address sdk.AccAddress) *custodytypes.CustodyWhiteList + AddToCustodyWhiteList(ctx sdk.Context, record custodytypes.CustodyWhiteListRecord) + DropCustodyWhiteListByAddress(ctx sdk.Context, address sdk.AccAddress) + + GetCustodyLimitsByAddress(ctx sdk.Context, address sdk.AccAddress) *custodytypes.CustodyLimits + AddToCustodyLimits(ctx sdk.Context, record custodytypes.CustodyLimitRecord) + DropCustodyLimitsByAddress(ctx sdk.Context, address sdk.AccAddress) + + GetCustodyLimitsStatusByAddress(ctx sdk.Context, address sdk.AccAddress) *custodytypes.CustodyStatuses + AddToCustodyLimitsStatus(ctx sdk.Context, record custodytypes.CustodyLimitStatusRecord) + DropCustodyLimitsStatus(ctx sdk.Context, addr sdk.AccAddress) + + AddToCustodyPool(ctx sdk.Context, record custodytypes.CustodyPool) + GetCustodyPoolByAddress(ctx sdk.Context, address sdk.AccAddress) *custodytypes.TransactionPool + DropCustodyPool(ctx sdk.Context, addr sdk.AccAddress) +} diff --git a/x/recovery/types/genesis.go b/x/recovery/types/genesis.go new file mode 100644 index 000000000..29c0fcbb6 --- /dev/null +++ b/x/recovery/types/genesis.go @@ -0,0 +1,31 @@ +package types + +// NewGenesisState creates a new GenesisState object +func NewGenesisState( + recoveryRecords []RecoveryRecord, + recoveryTokens []RecoveryToken, + rewards []Rewards, + rotations []Rotation, +) *GenesisState { + return &GenesisState{ + RecoveryRecords: recoveryRecords, + RecoveryTokens: recoveryTokens, + Rewards: rewards, + Rotations: rotations, + } +} + +// DefaultGenesisState - default GenesisState used by Cosmos Hub +func DefaultGenesisState() *GenesisState { + return &GenesisState{ + RecoveryRecords: []RecoveryRecord{}, + RecoveryTokens: []RecoveryToken{}, + Rewards: []Rewards{}, + } +} + +// ValidateGenesis validates the recovery genesis parameters +func ValidateGenesis(data GenesisState) error { + + return nil +} diff --git a/x/recovery/types/genesis.pb.go b/x/recovery/types/genesis.pb.go new file mode 100644 index 000000000..3719076cb --- /dev/null +++ b/x/recovery/types/genesis.pb.go @@ -0,0 +1,523 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: kira/recovery/genesis.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/codec/types" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// GenesisState defines the recovery module's genesis state. +type GenesisState struct { + RecoveryRecords []RecoveryRecord `protobuf:"bytes,1,rep,name=recovery_records,json=recoveryRecords,proto3" json:"recovery_records"` + RecoveryTokens []RecoveryToken `protobuf:"bytes,2,rep,name=recovery_tokens,json=recoveryTokens,proto3" json:"recovery_tokens"` + Rewards []Rewards `protobuf:"bytes,3,rep,name=rewards,proto3" json:"rewards"` + Rotations []Rotation `protobuf:"bytes,4,rep,name=rotations,proto3" json:"rotations"` +} + +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_e8b68a38c0eea823, []int{0} +} +func (m *GenesisState) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GenesisState.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *GenesisState) XXX_Merge(src proto.Message) { + xxx_messageInfo_GenesisState.Merge(m, src) +} +func (m *GenesisState) XXX_Size() int { + return m.Size() +} +func (m *GenesisState) XXX_DiscardUnknown() { + xxx_messageInfo_GenesisState.DiscardUnknown(m) +} + +var xxx_messageInfo_GenesisState proto.InternalMessageInfo + +func (m *GenesisState) GetRecoveryRecords() []RecoveryRecord { + if m != nil { + return m.RecoveryRecords + } + return nil +} + +func (m *GenesisState) GetRecoveryTokens() []RecoveryToken { + if m != nil { + return m.RecoveryTokens + } + return nil +} + +func (m *GenesisState) GetRewards() []Rewards { + if m != nil { + return m.Rewards + } + return nil +} + +func (m *GenesisState) GetRotations() []Rotation { + if m != nil { + return m.Rotations + } + return nil +} + +func init() { + proto.RegisterType((*GenesisState)(nil), "kira.recovery.GenesisState") +} + +func init() { proto.RegisterFile("kira/recovery/genesis.proto", fileDescriptor_e8b68a38c0eea823) } + +var fileDescriptor_e8b68a38c0eea823 = []byte{ + // 302 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xce, 0xce, 0x2c, 0x4a, + 0xd4, 0x2f, 0x4a, 0x4d, 0xce, 0x2f, 0x4b, 0x2d, 0xaa, 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, + 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x05, 0x49, 0xea, 0xc1, 0x24, 0xa5, 0x44, + 0xd2, 0xf3, 0xd3, 0xf3, 0xc1, 0x32, 0xfa, 0x20, 0x16, 0x44, 0x91, 0x94, 0x64, 0x7a, 0x7e, 0x7e, + 0x7a, 0x4e, 0xaa, 0x3e, 0x98, 0x97, 0x54, 0x9a, 0xa6, 0x9f, 0x98, 0x57, 0x09, 0x95, 0x92, 0x41, + 0x35, 0x1c, 0xc6, 0x80, 0xc8, 0x2a, 0x2d, 0x60, 0xe2, 0xe2, 0x71, 0x87, 0xd8, 0x17, 0x5c, 0x92, + 0x58, 0x92, 0x2a, 0xe4, 0xc7, 0x25, 0x00, 0x53, 0x12, 0x0f, 0x62, 0x14, 0xa5, 0x14, 0x4b, 0x30, + 0x2a, 0x30, 0x6b, 0x70, 0x1b, 0xc9, 0xea, 0xa1, 0xb8, 0x44, 0x2f, 0x08, 0xca, 0x08, 0x02, 0xab, + 0x72, 0x62, 0x39, 0x71, 0x4f, 0x9e, 0x21, 0x88, 0xbf, 0x08, 0x45, 0xb4, 0x58, 0xc8, 0x9b, 0x0b, + 0x2e, 0x14, 0x5f, 0x92, 0x9f, 0x9d, 0x9a, 0x57, 0x2c, 0xc1, 0x04, 0x36, 0x4e, 0x06, 0x87, 0x71, + 0x21, 0x20, 0x45, 0x50, 0xd3, 0xf8, 0x8a, 0x90, 0x05, 0x8b, 0x85, 0xcc, 0xb8, 0xd8, 0x8b, 0x52, + 0xcb, 0x13, 0x41, 0x6e, 0x62, 0x06, 0x1b, 0x22, 0x86, 0x61, 0x08, 0x58, 0x16, 0xaa, 0x1d, 0xa6, + 0x58, 0xc8, 0x9a, 0x8b, 0xb3, 0x28, 0xbf, 0x24, 0xb1, 0x24, 0x33, 0x3f, 0xaf, 0x58, 0x82, 0x05, + 0xac, 0x53, 0x1c, 0x5d, 0x27, 0x54, 0x1e, 0xaa, 0x15, 0xa1, 0xde, 0xc9, 0xe5, 0xc4, 0x23, 0x39, + 0xc6, 0x0b, 0x8f, 0xe4, 0x18, 0x1f, 0x3c, 0x92, 0x63, 0x9c, 0xf0, 0x58, 0x8e, 0xe1, 0xc2, 0x63, + 0x39, 0x86, 0x1b, 0x8f, 0xe5, 0x18, 0xa2, 0xb4, 0xd2, 0x33, 0x4b, 0x32, 0x4a, 0x93, 0xf4, 0x92, + 0xf3, 0x73, 0xf5, 0xbd, 0x33, 0x8b, 0x12, 0x9d, 0xf3, 0x8b, 0x52, 0xf5, 0x8b, 0x53, 0xb3, 0x13, + 0x33, 0xf5, 0x2b, 0x10, 0x21, 0x5e, 0x52, 0x59, 0x90, 0x5a, 0x9c, 0xc4, 0x06, 0x0e, 0x6f, 0x63, + 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x4f, 0x3b, 0x93, 0xa9, 0xec, 0x01, 0x00, 0x00, +} + +func (m *GenesisState) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *GenesisState) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Rotations) > 0 { + for iNdEx := len(m.Rotations) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Rotations[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.Rewards) > 0 { + for iNdEx := len(m.Rewards) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Rewards[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + if len(m.RecoveryTokens) > 0 { + for iNdEx := len(m.RecoveryTokens) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.RecoveryTokens[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if len(m.RecoveryRecords) > 0 { + for iNdEx := len(m.RecoveryRecords) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.RecoveryRecords[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { + offset -= sovGenesis(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *GenesisState) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.RecoveryRecords) > 0 { + for _, e := range m.RecoveryRecords { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.RecoveryTokens) > 0 { + for _, e := range m.RecoveryTokens { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.Rewards) > 0 { + for _, e := range m.Rewards { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.Rotations) > 0 { + for _, e := range m.Rotations { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + return n +} + +func sovGenesis(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozGenesis(x uint64) (n int) { + return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *GenesisState) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: GenesisState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RecoveryRecords", 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.RecoveryRecords = append(m.RecoveryRecords, RecoveryRecord{}) + if err := m.RecoveryRecords[len(m.RecoveryRecords)-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 RecoveryTokens", 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.RecoveryTokens = append(m.RecoveryTokens, RecoveryToken{}) + if err := m.RecoveryTokens[len(m.RecoveryTokens)-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 Rewards", 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.Rewards = append(m.Rewards, Rewards{}) + if err := m.Rewards[len(m.Rewards)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Rotations", 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.Rotations = append(m.Rotations, Rotation{}) + if err := m.Rotations[len(m.Rotations)-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/recovery/types/keys.go b/x/recovery/types/keys.go new file mode 100644 index 000000000..05e029c54 --- /dev/null +++ b/x/recovery/types/keys.go @@ -0,0 +1,45 @@ +package types + +const ( + // ModuleName is the name of the module + ModuleName = "recovery" + + // StoreKey is the store key string for recovery + StoreKey = ModuleName + + // RouterKey is the message route for recovery + RouterKey = ModuleName + + // QuerierRoute is the querier route for recovery + QuerierRoute = ModuleName +) + +var ( + RecoveryChallengeKeyPrefix = []byte{0x01} // Prefix for recovery challenge + RecoveryRecordKeyPrefix = []byte{0x02} // Prefix for recovery record + RecoveryTokenByDenomKeyPrefix = []byte{0x03} // Prefix for recovery token by denom + RecoveryTokenKeyPrefix = []byte{0x04} // Prefix for recovery token + RotationHistoryKeyPrefix = []byte{0x05} // Prefix for rotation history + KeyPrefixRewards = []byte{0x06} + KeyPrefixRRTokenHolder = []byte{0x07} +) + +func RecoveryChallengeKey(challenge string) []byte { + return append(RecoveryChallengeKeyPrefix, challenge...) +} + +func RecoveryRecordKey(address string) []byte { + return append(RecoveryRecordKeyPrefix, address...) +} + +func RecoveryTokenKey(address string) []byte { + return append(RecoveryTokenKeyPrefix, address...) +} + +func RecoveryTokenByDenomKey(denom string) []byte { + return append(RecoveryTokenByDenomKeyPrefix, denom...) +} + +func RotationHistoryKey(address string) []byte { + return append(RotationHistoryKeyPrefix, address...) +} diff --git a/x/recovery/types/msg.go b/x/recovery/types/msg.go new file mode 100644 index 000000000..17e731ec3 --- /dev/null +++ b/x/recovery/types/msg.go @@ -0,0 +1,275 @@ +package types + +import ( + "github.com/KiraCore/sekai/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// verify interface at compile time +var _ sdk.Msg = &MsgRegisterRecoverySecret{} + +// NewMsgRegisterRecoverySecret creates a new MsgRegisterRecoverySecret instance +//nolint:interfacer +func NewMsgRegisterRecoverySecret(addr, challenge, nonce, proof string) *MsgRegisterRecoverySecret { + return &MsgRegisterRecoverySecret{ + Address: addr, + Challenge: challenge, + Nonce: nonce, + Proof: proof, + } +} + +func (msg MsgRegisterRecoverySecret) Route() string { return RouterKey } +func (msg MsgRegisterRecoverySecret) Type() string { return types.MsgTypeRegisterRecoverySecret } +func (msg MsgRegisterRecoverySecret) GetSigners() []sdk.AccAddress { + addr, err := sdk.AccAddressFromBech32(msg.Address) + if err != nil { + panic(err) + } + return []sdk.AccAddress{addr.Bytes()} +} + +// GetSignBytes gets the bytes for the message signer to sign on +func (msg MsgRegisterRecoverySecret) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(&msg) + return sdk.MustSortJSON(bz) +} + +// ValidateBasic validity check for the AnteHandler +func (msg MsgRegisterRecoverySecret) ValidateBasic() error { + if msg.Address == "" { + return ErrInvalidAccAddress + } + + return nil +} + +// verify interface at compile time +var _ sdk.Msg = &MsgRotateRecoveryAddress{} + +// NewMsgRotateRecoveryAddress creates a new MsgRotateRecoveryAddress instance +//nolint:interfacer +func NewMsgRotateRecoveryAddress(feePayer, addr, recovery, proof string) *MsgRotateRecoveryAddress { + return &MsgRotateRecoveryAddress{ + FeePayer: feePayer, + Address: addr, + Recovery: recovery, + Proof: proof, + } +} + +func (msg MsgRotateRecoveryAddress) Route() string { return RouterKey } +func (msg MsgRotateRecoveryAddress) Type() string { return types.MsgTypeRotateRecoveryAddress } +func (msg MsgRotateRecoveryAddress) GetSigners() []sdk.AccAddress { + feePayer, err := sdk.AccAddressFromBech32(msg.FeePayer) + if err != nil { + panic(err) + } + addr, err := sdk.AccAddressFromBech32(msg.Address) + if err != nil { + panic(err) + } + + if msg.Address == msg.FeePayer { + return []sdk.AccAddress{addr.Bytes()} + } + return []sdk.AccAddress{feePayer.Bytes(), addr.Bytes()} +} + +// GetSignBytes gets the bytes for the message signer to sign on +func (msg MsgRotateRecoveryAddress) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(&msg) + return sdk.MustSortJSON(bz) +} + +// ValidateBasic validity check for the AnteHandler +func (msg MsgRotateRecoveryAddress) ValidateBasic() error { + if msg.Address == "" { + return ErrInvalidAccAddress + } + + return nil +} + +// verify interface at compile time +var _ sdk.Msg = &MsgIssueRecoveryTokens{} + +// NewMsgIssueRecoveryTokens creates a new MsgIssueRecoveryTokens instance +//nolint:interfacer +func NewMsgIssueRecoveryTokens(addr string) *MsgIssueRecoveryTokens { + return &MsgIssueRecoveryTokens{ + Address: addr, + } +} + +func (msg MsgIssueRecoveryTokens) Route() string { return RouterKey } +func (msg MsgIssueRecoveryTokens) Type() string { return types.MsgTypeIssueRecoveryTokens } +func (msg MsgIssueRecoveryTokens) GetSigners() []sdk.AccAddress { + addr, err := sdk.AccAddressFromBech32(msg.Address) + if err != nil { + panic(err) + } + return []sdk.AccAddress{addr.Bytes()} +} + +// GetSignBytes gets the bytes for the message signer to sign on +func (msg MsgIssueRecoveryTokens) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(&msg) + return sdk.MustSortJSON(bz) +} + +// ValidateBasic validity check for the AnteHandler +func (msg MsgIssueRecoveryTokens) ValidateBasic() error { + if msg.Address == "" { + return ErrInvalidAccAddress + } + + return nil +} + +// verify interface at compile time +var _ sdk.Msg = &MsgBurnRecoveryTokens{} + +// NewMsgBurnRecoveryTokens creates a new MsgBurnRecoveryTokens instance +func NewMsgBurnRecoveryTokens(sender sdk.AccAddress, rrCoin sdk.Coin) *MsgBurnRecoveryTokens { + return &MsgBurnRecoveryTokens{ + Address: sender.String(), + RrCoin: rrCoin, + } +} + +func (msg MsgBurnRecoveryTokens) Route() string { return RouterKey } +func (msg MsgBurnRecoveryTokens) Type() string { return types.MsgTypeBurnRecoveryTokens } +func (msg MsgBurnRecoveryTokens) GetSigners() []sdk.AccAddress { + addr, err := sdk.AccAddressFromBech32(msg.Address) + if err != nil { + panic(err) + } + return []sdk.AccAddress{addr} +} + +// GetSignBytes gets the bytes for the message signer to sign on +func (msg MsgBurnRecoveryTokens) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(&msg) + return sdk.MustSortJSON(bz) +} + +// ValidateBasic validity check for the AnteHandler +func (msg MsgBurnRecoveryTokens) ValidateBasic() error { + if msg.Address == "" { + return ErrInvalidAccAddress + } + + return nil +} + +// verify interface at compile time +var _ sdk.Msg = &MsgRegisterRRTokenHolder{} + +// NewMsgRegisterRRTokenHolder creates a new MsgRegisterRRTokenHolder instance +func NewMsgRegisterRRTokenHolder(sender sdk.AccAddress) *MsgRegisterRRTokenHolder { + return &MsgRegisterRRTokenHolder{ + Holder: sender.String(), + } +} + +func (msg MsgRegisterRRTokenHolder) Route() string { return RouterKey } +func (msg MsgRegisterRRTokenHolder) Type() string { return types.MsgTypeRegisterRRTokenHolder } +func (msg MsgRegisterRRTokenHolder) GetSigners() []sdk.AccAddress { + addr, err := sdk.AccAddressFromBech32(msg.Holder) + if err != nil { + panic(err) + } + return []sdk.AccAddress{addr} +} + +// GetSignBytes gets the bytes for the message signer to sign on +func (msg MsgRegisterRRTokenHolder) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(&msg) + return sdk.MustSortJSON(bz) +} + +// ValidateBasic validity check for the AnteHandler +func (msg MsgRegisterRRTokenHolder) ValidateBasic() error { + if msg.Holder == "" { + return ErrInvalidAccAddress + } + + return nil +} + +// verify interface at compile time +var _ sdk.Msg = &MsgClaimRRHolderRewards{} + +// NewMsgClaimRRHolderRewards creates a new MsgClaimRRHolderRewards instance +func NewMsgClaimRRHolderRewards(sender sdk.AccAddress) *MsgClaimRRHolderRewards { + return &MsgClaimRRHolderRewards{ + Sender: sender.String(), + } +} + +func (msg MsgClaimRRHolderRewards) Route() string { return RouterKey } +func (msg MsgClaimRRHolderRewards) Type() string { return types.MsgTypeClaimRRHolderRewards } +func (msg MsgClaimRRHolderRewards) GetSigners() []sdk.AccAddress { + addr, err := sdk.AccAddressFromBech32(msg.Sender) + if err != nil { + panic(err) + } + return []sdk.AccAddress{addr} +} + +// GetSignBytes gets the bytes for the message signer to sign on +func (msg MsgClaimRRHolderRewards) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(&msg) + return sdk.MustSortJSON(bz) +} + +// ValidateBasic validity check for the AnteHandler +func (msg MsgClaimRRHolderRewards) ValidateBasic() error { + if msg.Sender == "" { + return ErrInvalidAccAddress + } + + return nil +} + +// verify interface at compile time +var _ sdk.Msg = &MsgRotateValidatorByHalfRRTokenHolder{} + +// NewMsgRotateValidatorByHalfRRTokenHolder creates a new MsgRotateValidatorByHalfRRTokenHolder instance +//nolint:interfacer +func NewMsgRotateValidatorByHalfRRTokenHolder(rrHolder, addr, recovery string) *MsgRotateValidatorByHalfRRTokenHolder { + return &MsgRotateValidatorByHalfRRTokenHolder{ + RrHolder: rrHolder, + Address: addr, + Recovery: recovery, + } +} + +func (msg MsgRotateValidatorByHalfRRTokenHolder) Route() string { return RouterKey } +func (msg MsgRotateValidatorByHalfRRTokenHolder) Type() string { + return types.MsgTypeRotateValidatorByHalfRRTokenHolder +} +func (msg MsgRotateValidatorByHalfRRTokenHolder) GetSigners() []sdk.AccAddress { + rrHolder, err := sdk.AccAddressFromBech32(msg.RrHolder) + if err != nil { + panic(err) + } + + return []sdk.AccAddress{rrHolder.Bytes()} +} + +// GetSignBytes gets the bytes for the message signer to sign on +func (msg MsgRotateValidatorByHalfRRTokenHolder) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(&msg) + return sdk.MustSortJSON(bz) +} + +// ValidateBasic validity check for the AnteHandler +func (msg MsgRotateValidatorByHalfRRTokenHolder) ValidateBasic() error { + if msg.Address == "" { + return ErrInvalidAccAddress + } + + return nil +} diff --git a/x/recovery/types/query.pb.go b/x/recovery/types/query.pb.go new file mode 100644 index 000000000..d3b1a4240 --- /dev/null +++ b/x/recovery/types/query.pb.go @@ -0,0 +1,1746 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: kira/recovery/query.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/codec/types" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/cosmos/cosmos-sdk/types/query" + _ "github.com/gogo/protobuf/gogoproto" + grpc1 "github.com/gogo/protobuf/grpc" + proto "github.com/gogo/protobuf/proto" + _ "google.golang.org/genproto/googleapis/api/annotations" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type QueryRecoveryRecordRequest struct { + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` +} + +func (m *QueryRecoveryRecordRequest) Reset() { *m = QueryRecoveryRecordRequest{} } +func (m *QueryRecoveryRecordRequest) String() string { return proto.CompactTextString(m) } +func (*QueryRecoveryRecordRequest) ProtoMessage() {} +func (*QueryRecoveryRecordRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_1ccd2ab45d9acb75, []int{0} +} +func (m *QueryRecoveryRecordRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryRecoveryRecordRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryRecoveryRecordRequest.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 *QueryRecoveryRecordRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryRecoveryRecordRequest.Merge(m, src) +} +func (m *QueryRecoveryRecordRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryRecoveryRecordRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryRecoveryRecordRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryRecoveryRecordRequest proto.InternalMessageInfo + +func (m *QueryRecoveryRecordRequest) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +type QueryRecoveryRecordResponse struct { + Record RecoveryRecord `protobuf:"bytes,1,opt,name=record,proto3" json:"record"` +} + +func (m *QueryRecoveryRecordResponse) Reset() { *m = QueryRecoveryRecordResponse{} } +func (m *QueryRecoveryRecordResponse) String() string { return proto.CompactTextString(m) } +func (*QueryRecoveryRecordResponse) ProtoMessage() {} +func (*QueryRecoveryRecordResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_1ccd2ab45d9acb75, []int{1} +} +func (m *QueryRecoveryRecordResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryRecoveryRecordResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryRecoveryRecordResponse.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 *QueryRecoveryRecordResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryRecoveryRecordResponse.Merge(m, src) +} +func (m *QueryRecoveryRecordResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryRecoveryRecordResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryRecoveryRecordResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryRecoveryRecordResponse proto.InternalMessageInfo + +func (m *QueryRecoveryRecordResponse) GetRecord() RecoveryRecord { + if m != nil { + return m.Record + } + return RecoveryRecord{} +} + +type QueryRecoveryTokenRequest struct { + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` +} + +func (m *QueryRecoveryTokenRequest) Reset() { *m = QueryRecoveryTokenRequest{} } +func (m *QueryRecoveryTokenRequest) String() string { return proto.CompactTextString(m) } +func (*QueryRecoveryTokenRequest) ProtoMessage() {} +func (*QueryRecoveryTokenRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_1ccd2ab45d9acb75, []int{2} +} +func (m *QueryRecoveryTokenRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryRecoveryTokenRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryRecoveryTokenRequest.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 *QueryRecoveryTokenRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryRecoveryTokenRequest.Merge(m, src) +} +func (m *QueryRecoveryTokenRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryRecoveryTokenRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryRecoveryTokenRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryRecoveryTokenRequest proto.InternalMessageInfo + +func (m *QueryRecoveryTokenRequest) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +type QueryRecoveryTokenResponse struct { + Token RecoveryToken `protobuf:"bytes,1,opt,name=token,proto3" json:"token"` +} + +func (m *QueryRecoveryTokenResponse) Reset() { *m = QueryRecoveryTokenResponse{} } +func (m *QueryRecoveryTokenResponse) String() string { return proto.CompactTextString(m) } +func (*QueryRecoveryTokenResponse) ProtoMessage() {} +func (*QueryRecoveryTokenResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_1ccd2ab45d9acb75, []int{3} +} +func (m *QueryRecoveryTokenResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryRecoveryTokenResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryRecoveryTokenResponse.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 *QueryRecoveryTokenResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryRecoveryTokenResponse.Merge(m, src) +} +func (m *QueryRecoveryTokenResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryRecoveryTokenResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryRecoveryTokenResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryRecoveryTokenResponse proto.InternalMessageInfo + +func (m *QueryRecoveryTokenResponse) GetToken() RecoveryToken { + if m != nil { + return m.Token + } + return RecoveryToken{} +} + +type QueryRRHolderRewardsRequest struct { + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` +} + +func (m *QueryRRHolderRewardsRequest) Reset() { *m = QueryRRHolderRewardsRequest{} } +func (m *QueryRRHolderRewardsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryRRHolderRewardsRequest) ProtoMessage() {} +func (*QueryRRHolderRewardsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_1ccd2ab45d9acb75, []int{4} +} +func (m *QueryRRHolderRewardsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryRRHolderRewardsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryRRHolderRewardsRequest.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 *QueryRRHolderRewardsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryRRHolderRewardsRequest.Merge(m, src) +} +func (m *QueryRRHolderRewardsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryRRHolderRewardsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryRRHolderRewardsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryRRHolderRewardsRequest proto.InternalMessageInfo + +func (m *QueryRRHolderRewardsRequest) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +type QueryRRHolderRewardsResponse struct { + Rewards []github_com_cosmos_cosmos_sdk_types.Coin `protobuf:"bytes,1,rep,name=rewards,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Coin" json:"rewards"` +} + +func (m *QueryRRHolderRewardsResponse) Reset() { *m = QueryRRHolderRewardsResponse{} } +func (m *QueryRRHolderRewardsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryRRHolderRewardsResponse) ProtoMessage() {} +func (*QueryRRHolderRewardsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_1ccd2ab45d9acb75, []int{5} +} +func (m *QueryRRHolderRewardsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryRRHolderRewardsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryRRHolderRewardsResponse.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 *QueryRRHolderRewardsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryRRHolderRewardsResponse.Merge(m, src) +} +func (m *QueryRRHolderRewardsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryRRHolderRewardsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryRRHolderRewardsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryRRHolderRewardsResponse proto.InternalMessageInfo + +type QueryRegisteredRRTokenHoldersRequest struct { + RecoveryToken string `protobuf:"bytes,1,opt,name=recovery_token,json=recoveryToken,proto3" json:"recovery_token,omitempty"` +} + +func (m *QueryRegisteredRRTokenHoldersRequest) Reset() { *m = QueryRegisteredRRTokenHoldersRequest{} } +func (m *QueryRegisteredRRTokenHoldersRequest) String() string { return proto.CompactTextString(m) } +func (*QueryRegisteredRRTokenHoldersRequest) ProtoMessage() {} +func (*QueryRegisteredRRTokenHoldersRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_1ccd2ab45d9acb75, []int{6} +} +func (m *QueryRegisteredRRTokenHoldersRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryRegisteredRRTokenHoldersRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryRegisteredRRTokenHoldersRequest.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 *QueryRegisteredRRTokenHoldersRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryRegisteredRRTokenHoldersRequest.Merge(m, src) +} +func (m *QueryRegisteredRRTokenHoldersRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryRegisteredRRTokenHoldersRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryRegisteredRRTokenHoldersRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryRegisteredRRTokenHoldersRequest proto.InternalMessageInfo + +func (m *QueryRegisteredRRTokenHoldersRequest) GetRecoveryToken() string { + if m != nil { + return m.RecoveryToken + } + return "" +} + +type QueryRegisteredRRTokenHoldersResponse struct { + Holders []string `protobuf:"bytes,1,rep,name=holders,proto3" json:"holders,omitempty"` +} + +func (m *QueryRegisteredRRTokenHoldersResponse) Reset() { *m = QueryRegisteredRRTokenHoldersResponse{} } +func (m *QueryRegisteredRRTokenHoldersResponse) String() string { return proto.CompactTextString(m) } +func (*QueryRegisteredRRTokenHoldersResponse) ProtoMessage() {} +func (*QueryRegisteredRRTokenHoldersResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_1ccd2ab45d9acb75, []int{7} +} +func (m *QueryRegisteredRRTokenHoldersResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryRegisteredRRTokenHoldersResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryRegisteredRRTokenHoldersResponse.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 *QueryRegisteredRRTokenHoldersResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryRegisteredRRTokenHoldersResponse.Merge(m, src) +} +func (m *QueryRegisteredRRTokenHoldersResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryRegisteredRRTokenHoldersResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryRegisteredRRTokenHoldersResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryRegisteredRRTokenHoldersResponse proto.InternalMessageInfo + +func (m *QueryRegisteredRRTokenHoldersResponse) GetHolders() []string { + if m != nil { + return m.Holders + } + return nil +} + +func init() { + proto.RegisterType((*QueryRecoveryRecordRequest)(nil), "kira.recovery.QueryRecoveryRecordRequest") + proto.RegisterType((*QueryRecoveryRecordResponse)(nil), "kira.recovery.QueryRecoveryRecordResponse") + proto.RegisterType((*QueryRecoveryTokenRequest)(nil), "kira.recovery.QueryRecoveryTokenRequest") + proto.RegisterType((*QueryRecoveryTokenResponse)(nil), "kira.recovery.QueryRecoveryTokenResponse") + proto.RegisterType((*QueryRRHolderRewardsRequest)(nil), "kira.recovery.QueryRRHolderRewardsRequest") + proto.RegisterType((*QueryRRHolderRewardsResponse)(nil), "kira.recovery.QueryRRHolderRewardsResponse") + proto.RegisterType((*QueryRegisteredRRTokenHoldersRequest)(nil), "kira.recovery.QueryRegisteredRRTokenHoldersRequest") + proto.RegisterType((*QueryRegisteredRRTokenHoldersResponse)(nil), "kira.recovery.QueryRegisteredRRTokenHoldersResponse") +} + +func init() { proto.RegisterFile("kira/recovery/query.proto", fileDescriptor_1ccd2ab45d9acb75) } + +var fileDescriptor_1ccd2ab45d9acb75 = []byte{ + // 606 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x94, 0x4f, 0x6f, 0xd3, 0x3e, + 0x1c, 0xc6, 0x9b, 0xdf, 0x8f, 0xae, 0xaa, 0x51, 0x87, 0x64, 0x71, 0x68, 0x43, 0xc9, 0xa6, 0x88, + 0x89, 0xae, 0x88, 0x98, 0x76, 0x40, 0x87, 0x90, 0xf8, 0xd3, 0x21, 0x04, 0x42, 0x1c, 0xb0, 0x10, + 0x87, 0x5d, 0x26, 0xb7, 0x31, 0x99, 0xd5, 0x2d, 0xee, 0xec, 0x74, 0x50, 0x4d, 0xbb, 0xf0, 0x0a, + 0x90, 0x38, 0x73, 0xe0, 0xcc, 0x1b, 0x19, 0x07, 0xa4, 0x49, 0x5c, 0x10, 0x87, 0x09, 0xb5, 0xbc, + 0x10, 0x14, 0xdb, 0xd9, 0x9a, 0xaa, 0x5d, 0xcb, 0x29, 0xf6, 0xd7, 0x7e, 0xec, 0xcf, 0x63, 0x3f, + 0x0e, 0x28, 0x75, 0x98, 0x20, 0x48, 0xd0, 0x36, 0xdf, 0xa7, 0xa2, 0x8f, 0xf6, 0x7a, 0x54, 0xf4, + 0xbd, 0xae, 0xe0, 0x11, 0x87, 0x85, 0x78, 0xc8, 0x4b, 0x86, 0xec, 0x6a, 0x9b, 0xcb, 0x5d, 0x2e, + 0x51, 0x8b, 0x48, 0xaa, 0xe7, 0xa1, 0xfd, 0x5a, 0x8b, 0x46, 0xa4, 0x86, 0xba, 0x24, 0x60, 0x21, + 0x89, 0x18, 0x0f, 0xb5, 0xd4, 0xbe, 0x1c, 0xf0, 0x80, 0xab, 0x26, 0x8a, 0x5b, 0xa6, 0x5a, 0x0a, + 0x38, 0x0f, 0x76, 0x28, 0x52, 0xbd, 0x56, 0xef, 0x2d, 0x22, 0xa1, 0xd9, 0xc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c, 0x74, 0xd1, 0x41, 0xba, 0x7e, 0xd8, + 0x7c, 0x72, 0x34, 0x70, 0xac, 0xe3, 0x81, 0x63, 0xfd, 0x1e, 0x38, 0xd6, 0xc7, 0xa1, 0x93, 0x39, + 0x1e, 0x3a, 0x99, 0x9f, 0x43, 0x27, 0xb3, 0x59, 0x1d, 0x79, 0xa9, 0x2f, 0x98, 0x20, 0x1b, 0x5c, + 0x50, 0x24, 0x69, 0x87, 0x30, 0xf4, 0xfe, 0x6c, 0x3f, 0xf5, 0x62, 0x5b, 0x0b, 0xea, 0x8f, 0xbb, + 0xf6, 0x37, 0x00, 0x00, 0xff, 0xff, 0xc5, 0x12, 0x30, 0x24, 0x36, 0x06, 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 { + // given KIRA public address as parameter return data from the recovery registrar + RecoveryRecord(ctx context.Context, in *QueryRecoveryRecordRequest, opts ...grpc.CallOption) (*QueryRecoveryRecordResponse, error) + RecoveryToken(ctx context.Context, in *QueryRecoveryTokenRequest, opts ...grpc.CallOption) (*QueryRecoveryTokenResponse, error) + RRHolderRewards(ctx context.Context, in *QueryRRHolderRewardsRequest, opts ...grpc.CallOption) (*QueryRRHolderRewardsResponse, error) + RegisteredRRTokenHolders(ctx context.Context, in *QueryRegisteredRRTokenHoldersRequest, opts ...grpc.CallOption) (*QueryRegisteredRRTokenHoldersResponse, error) +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +func (c *queryClient) RecoveryRecord(ctx context.Context, in *QueryRecoveryRecordRequest, opts ...grpc.CallOption) (*QueryRecoveryRecordResponse, error) { + out := new(QueryRecoveryRecordResponse) + err := c.cc.Invoke(ctx, "/kira.recovery.Query/RecoveryRecord", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) RecoveryToken(ctx context.Context, in *QueryRecoveryTokenRequest, opts ...grpc.CallOption) (*QueryRecoveryTokenResponse, error) { + out := new(QueryRecoveryTokenResponse) + err := c.cc.Invoke(ctx, "/kira.recovery.Query/RecoveryToken", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) RRHolderRewards(ctx context.Context, in *QueryRRHolderRewardsRequest, opts ...grpc.CallOption) (*QueryRRHolderRewardsResponse, error) { + out := new(QueryRRHolderRewardsResponse) + err := c.cc.Invoke(ctx, "/kira.recovery.Query/RRHolderRewards", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) RegisteredRRTokenHolders(ctx context.Context, in *QueryRegisteredRRTokenHoldersRequest, opts ...grpc.CallOption) (*QueryRegisteredRRTokenHoldersResponse, error) { + out := new(QueryRegisteredRRTokenHoldersResponse) + err := c.cc.Invoke(ctx, "/kira.recovery.Query/RegisteredRRTokenHolders", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +type QueryServer interface { + // given KIRA public address as parameter return data from the recovery registrar + RecoveryRecord(context.Context, *QueryRecoveryRecordRequest) (*QueryRecoveryRecordResponse, error) + RecoveryToken(context.Context, *QueryRecoveryTokenRequest) (*QueryRecoveryTokenResponse, error) + RRHolderRewards(context.Context, *QueryRRHolderRewardsRequest) (*QueryRRHolderRewardsResponse, error) + RegisteredRRTokenHolders(context.Context, *QueryRegisteredRRTokenHoldersRequest) (*QueryRegisteredRRTokenHoldersResponse, error) +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func (*UnimplementedQueryServer) RecoveryRecord(ctx context.Context, req *QueryRecoveryRecordRequest) (*QueryRecoveryRecordResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RecoveryRecord not implemented") +} +func (*UnimplementedQueryServer) RecoveryToken(ctx context.Context, req *QueryRecoveryTokenRequest) (*QueryRecoveryTokenResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RecoveryToken not implemented") +} +func (*UnimplementedQueryServer) RRHolderRewards(ctx context.Context, req *QueryRRHolderRewardsRequest) (*QueryRRHolderRewardsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RRHolderRewards not implemented") +} +func (*UnimplementedQueryServer) RegisteredRRTokenHolders(ctx context.Context, req *QueryRegisteredRRTokenHoldersRequest) (*QueryRegisteredRRTokenHoldersResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RegisteredRRTokenHolders not implemented") +} + +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) +} + +func _Query_RecoveryRecord_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryRecoveryRecordRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).RecoveryRecord(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/kira.recovery.Query/RecoveryRecord", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).RecoveryRecord(ctx, req.(*QueryRecoveryRecordRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_RecoveryToken_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryRecoveryTokenRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).RecoveryToken(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/kira.recovery.Query/RecoveryToken", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).RecoveryToken(ctx, req.(*QueryRecoveryTokenRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_RRHolderRewards_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryRRHolderRewardsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).RRHolderRewards(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/kira.recovery.Query/RRHolderRewards", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).RRHolderRewards(ctx, req.(*QueryRRHolderRewardsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_RegisteredRRTokenHolders_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryRegisteredRRTokenHoldersRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).RegisteredRRTokenHolders(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/kira.recovery.Query/RegisteredRRTokenHolders", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).RegisteredRRTokenHolders(ctx, req.(*QueryRegisteredRRTokenHoldersRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "kira.recovery.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "RecoveryRecord", + Handler: _Query_RecoveryRecord_Handler, + }, + { + MethodName: "RecoveryToken", + Handler: _Query_RecoveryToken_Handler, + }, + { + MethodName: "RRHolderRewards", + Handler: _Query_RRHolderRewards_Handler, + }, + { + MethodName: "RegisteredRRTokenHolders", + Handler: _Query_RegisteredRRTokenHolders_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "kira/recovery/query.proto", +} + +func (m *QueryRecoveryRecordRequest) 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 *QueryRecoveryRecordRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryRecoveryRecordRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryRecoveryRecordResponse) 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 *QueryRecoveryRecordResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryRecoveryRecordResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Record.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 *QueryRecoveryTokenRequest) 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 *QueryRecoveryTokenRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryRecoveryTokenRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryRecoveryTokenResponse) 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 *QueryRecoveryTokenResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryRecoveryTokenResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Token.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 *QueryRRHolderRewardsRequest) 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 *QueryRRHolderRewardsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryRRHolderRewardsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryRRHolderRewardsResponse) 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 *QueryRRHolderRewardsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryRRHolderRewardsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Rewards) > 0 { + for iNdEx := len(m.Rewards) - 1; iNdEx >= 0; iNdEx-- { + { + size := m.Rewards[iNdEx].Size() + i -= size + if _, err := m.Rewards[iNdEx].MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *QueryRegisteredRRTokenHoldersRequest) 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 *QueryRegisteredRRTokenHoldersRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryRegisteredRRTokenHoldersRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.RecoveryToken) > 0 { + i -= len(m.RecoveryToken) + copy(dAtA[i:], m.RecoveryToken) + i = encodeVarintQuery(dAtA, i, uint64(len(m.RecoveryToken))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryRegisteredRRTokenHoldersResponse) 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 *QueryRegisteredRRTokenHoldersResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryRegisteredRRTokenHoldersResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Holders) > 0 { + for iNdEx := len(m.Holders) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Holders[iNdEx]) + copy(dAtA[i:], m.Holders[iNdEx]) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Holders[iNdEx]))) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { + offset -= sovQuery(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *QueryRecoveryRecordRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryRecoveryRecordResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Record.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryRecoveryTokenRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryRecoveryTokenResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Token.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryRRHolderRewardsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryRRHolderRewardsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Rewards) > 0 { + for _, e := range m.Rewards { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + +func (m *QueryRegisteredRRTokenHoldersRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.RecoveryToken) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryRegisteredRRTokenHoldersResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Holders) > 0 { + for _, s := range m.Holders { + l = len(s) + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + +func sovQuery(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QueryRecoveryRecordRequest) 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: QueryRecoveryRecordRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryRecoveryRecordRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", 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.Address = 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 *QueryRecoveryRecordResponse) 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: QueryRecoveryRecordResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryRecoveryRecordResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Record", 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.Record.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 *QueryRecoveryTokenRequest) 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: QueryRecoveryTokenRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryRecoveryTokenRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", 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.Address = 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 *QueryRecoveryTokenResponse) 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: QueryRecoveryTokenResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryRecoveryTokenResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Token", 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.Token.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 *QueryRRHolderRewardsRequest) 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: QueryRRHolderRewardsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryRRHolderRewardsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", 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.Address = 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 *QueryRRHolderRewardsResponse) 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: QueryRRHolderRewardsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryRRHolderRewardsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Rewards", 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 + } + var v github_com_cosmos_cosmos_sdk_types.Coin + m.Rewards = append(m.Rewards, v) + if err := m.Rewards[len(m.Rewards)-1].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 *QueryRegisteredRRTokenHoldersRequest) 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: QueryRegisteredRRTokenHoldersRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryRegisteredRRTokenHoldersRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RecoveryToken", 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.RecoveryToken = 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 *QueryRegisteredRRTokenHoldersResponse) 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: QueryRegisteredRRTokenHoldersResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryRegisteredRRTokenHoldersResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Holders", 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.Holders = append(m.Holders, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipQuery(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthQuery + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupQuery + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthQuery + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthQuery = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowQuery = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/recovery/types/query.pb.gw.go b/x/recovery/types/query.pb.gw.go new file mode 100644 index 000000000..e398c7938 --- /dev/null +++ b/x/recovery/types/query.pb.gw.go @@ -0,0 +1,478 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: kira/recovery/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/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 + +func request_Query_RecoveryRecord_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryRecoveryRecordRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["address"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "address") + } + + protoReq.Address, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "address", err) + } + + msg, err := client.RecoveryRecord(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_RecoveryRecord_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryRecoveryRecordRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["address"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "address") + } + + protoReq.Address, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "address", err) + } + + msg, err := server.RecoveryRecord(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_RecoveryToken_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryRecoveryTokenRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["address"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "address") + } + + protoReq.Address, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "address", err) + } + + msg, err := client.RecoveryToken(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_RecoveryToken_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryRecoveryTokenRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["address"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "address") + } + + protoReq.Address, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "address", err) + } + + msg, err := server.RecoveryToken(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_RRHolderRewards_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryRRHolderRewardsRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["address"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "address") + } + + protoReq.Address, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "address", err) + } + + msg, err := client.RRHolderRewards(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_RRHolderRewards_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryRRHolderRewardsRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["address"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "address") + } + + protoReq.Address, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "address", err) + } + + msg, err := server.RRHolderRewards(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_RegisteredRRTokenHolders_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryRegisteredRRTokenHoldersRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["recovery_token"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "recovery_token") + } + + protoReq.RecoveryToken, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "recovery_token", err) + } + + msg, err := client.RegisteredRRTokenHolders(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_RegisteredRRTokenHolders_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryRegisteredRRTokenHoldersRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["recovery_token"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "recovery_token") + } + + protoReq.RecoveryToken, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "recovery_token", err) + } + + msg, err := server.RegisteredRRTokenHolders(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 (such as grpc.SendHeader, etc) to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { + + mux.Handle("GET", pattern_Query_RecoveryRecord_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.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_RecoveryRecord_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_RecoveryRecord_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_RecoveryToken_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.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_RecoveryToken_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_RecoveryToken_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_RRHolderRewards_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.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_RRHolderRewards_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_RRHolderRewards_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_RegisteredRRTokenHolders_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.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_RegisteredRRTokenHolders_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_RegisteredRRTokenHolders_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_RecoveryRecord_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_RecoveryRecord_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_RecoveryRecord_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_RecoveryToken_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_RecoveryToken_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_RecoveryToken_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_RRHolderRewards_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_RRHolderRewards_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_RRHolderRewards_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_RegisteredRRTokenHolders_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_RegisteredRRTokenHolders_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_RegisteredRRTokenHolders_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_Query_RecoveryRecord_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"kira", "recovery", "v1beta1", "recovery_record", "address"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_RecoveryToken_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"kira", "recovery", "v1beta1", "recovery_token", "address"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_RRHolderRewards_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"kira", "recovery", "v1beta1", "recovery_token_rewards", "address"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_RegisteredRRTokenHolders_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"kira", "recovery", "v1beta1", "recovery_token_holders", "recovery_token"}, "", runtime.AssumeColonVerbOpt(true))) +) + +var ( + forward_Query_RecoveryRecord_0 = runtime.ForwardResponseMessage + + forward_Query_RecoveryToken_0 = runtime.ForwardResponseMessage + + forward_Query_RRHolderRewards_0 = runtime.ForwardResponseMessage + + forward_Query_RegisteredRRTokenHolders_0 = runtime.ForwardResponseMessage +) diff --git a/x/recovery/types/recovery.pb.go b/x/recovery/types/recovery.pb.go new file mode 100644 index 000000000..a8154c13a --- /dev/null +++ b/x/recovery/types/recovery.pb.go @@ -0,0 +1,1334 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: kira/recovery/recovery.proto + +package types + +import ( + fmt "fmt" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + _ "google.golang.org/protobuf/types/known/timestamppb" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type RecoveryRecord struct { + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + Challenge string `protobuf:"bytes,2,opt,name=challenge,proto3" json:"challenge,omitempty"` + Nonce string `protobuf:"bytes,3,opt,name=nonce,proto3" json:"nonce,omitempty"` +} + +func (m *RecoveryRecord) Reset() { *m = RecoveryRecord{} } +func (m *RecoveryRecord) String() string { return proto.CompactTextString(m) } +func (*RecoveryRecord) ProtoMessage() {} +func (*RecoveryRecord) Descriptor() ([]byte, []int) { + return fileDescriptor_c2745d5958530d7f, []int{0} +} +func (m *RecoveryRecord) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *RecoveryRecord) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_RecoveryRecord.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 *RecoveryRecord) XXX_Merge(src proto.Message) { + xxx_messageInfo_RecoveryRecord.Merge(m, src) +} +func (m *RecoveryRecord) XXX_Size() int { + return m.Size() +} +func (m *RecoveryRecord) XXX_DiscardUnknown() { + xxx_messageInfo_RecoveryRecord.DiscardUnknown(m) +} + +var xxx_messageInfo_RecoveryRecord proto.InternalMessageInfo + +func (m *RecoveryRecord) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +func (m *RecoveryRecord) GetChallenge() string { + if m != nil { + return m.Challenge + } + return "" +} + +func (m *RecoveryRecord) GetNonce() string { + if m != nil { + return m.Nonce + } + return "" +} + +type RecoveryToken struct { + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + Token string `protobuf:"bytes,2,opt,name=token,proto3" json:"token,omitempty"` + RrSupply github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=rr_supply,json=rrSupply,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"rr_supply"` + UnderlyingTokens []github_com_cosmos_cosmos_sdk_types.Coin `protobuf:"bytes,4,rep,name=underlying_tokens,json=underlyingTokens,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Coin" json:"underlying_tokens"` +} + +func (m *RecoveryToken) Reset() { *m = RecoveryToken{} } +func (m *RecoveryToken) String() string { return proto.CompactTextString(m) } +func (*RecoveryToken) ProtoMessage() {} +func (*RecoveryToken) Descriptor() ([]byte, []int) { + return fileDescriptor_c2745d5958530d7f, []int{1} +} +func (m *RecoveryToken) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *RecoveryToken) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_RecoveryToken.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 *RecoveryToken) XXX_Merge(src proto.Message) { + xxx_messageInfo_RecoveryToken.Merge(m, src) +} +func (m *RecoveryToken) XXX_Size() int { + return m.Size() +} +func (m *RecoveryToken) XXX_DiscardUnknown() { + xxx_messageInfo_RecoveryToken.DiscardUnknown(m) +} + +var xxx_messageInfo_RecoveryToken proto.InternalMessageInfo + +func (m *RecoveryToken) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +func (m *RecoveryToken) GetToken() string { + if m != nil { + return m.Token + } + return "" +} + +type Rotation struct { + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + Rotated string `protobuf:"bytes,2,opt,name=rotated,proto3" json:"rotated,omitempty"` +} + +func (m *Rotation) Reset() { *m = Rotation{} } +func (m *Rotation) String() string { return proto.CompactTextString(m) } +func (*Rotation) ProtoMessage() {} +func (*Rotation) Descriptor() ([]byte, []int) { + return fileDescriptor_c2745d5958530d7f, []int{2} +} +func (m *Rotation) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Rotation) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Rotation.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 *Rotation) XXX_Merge(src proto.Message) { + xxx_messageInfo_Rotation.Merge(m, src) +} +func (m *Rotation) XXX_Size() int { + return m.Size() +} +func (m *Rotation) XXX_DiscardUnknown() { + xxx_messageInfo_Rotation.DiscardUnknown(m) +} + +var xxx_messageInfo_Rotation proto.InternalMessageInfo + +func (m *Rotation) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +func (m *Rotation) GetRotated() string { + if m != nil { + return m.Rotated + } + return "" +} + +type Rewards struct { + Holder string `protobuf:"bytes,1,opt,name=holder,proto3" json:"holder,omitempty"` + Rewards []github_com_cosmos_cosmos_sdk_types.Coin `protobuf:"bytes,2,rep,name=rewards,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Coin" json:"rewards"` +} + +func (m *Rewards) Reset() { *m = Rewards{} } +func (m *Rewards) String() string { return proto.CompactTextString(m) } +func (*Rewards) ProtoMessage() {} +func (*Rewards) Descriptor() ([]byte, []int) { + return fileDescriptor_c2745d5958530d7f, []int{3} +} +func (m *Rewards) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Rewards) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Rewards.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 *Rewards) XXX_Merge(src proto.Message) { + xxx_messageInfo_Rewards.Merge(m, src) +} +func (m *Rewards) XXX_Size() int { + return m.Size() +} +func (m *Rewards) XXX_DiscardUnknown() { + xxx_messageInfo_Rewards.DiscardUnknown(m) +} + +var xxx_messageInfo_Rewards proto.InternalMessageInfo + +func (m *Rewards) GetHolder() string { + if m != nil { + return m.Holder + } + return "" +} + +func init() { + proto.RegisterType((*RecoveryRecord)(nil), "kira.recovery.RecoveryRecord") + proto.RegisterType((*RecoveryToken)(nil), "kira.recovery.RecoveryToken") + proto.RegisterType((*Rotation)(nil), "kira.recovery.Rotation") + proto.RegisterType((*Rewards)(nil), "kira.recovery.Rewards") +} + +func init() { proto.RegisterFile("kira/recovery/recovery.proto", fileDescriptor_c2745d5958530d7f) } + +var fileDescriptor_c2745d5958530d7f = []byte{ + // 398 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x92, 0xc1, 0x6e, 0xd4, 0x30, + 0x10, 0x86, 0x37, 0x2d, 0xed, 0x76, 0x2d, 0x15, 0x81, 0xb5, 0x42, 0x51, 0x55, 0x65, 0xab, 0x3d, + 0x40, 0x85, 0x44, 0x7c, 0xe0, 0xce, 0x61, 0x7b, 0xa1, 0xea, 0x2d, 0x70, 0x42, 0x88, 0xca, 0x1b, + 0x0f, 0x59, 0x2b, 0x89, 0x27, 0x1a, 0x3b, 0x40, 0xde, 0x82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0x9a, + 0x0a, 0x6c, 0x7c, 0x69, 0x5c, 0x72, 0x44, 0xf4, 0xc6, 0xd7, 0xf3, 0xf7, 0xec, 0x71, 0x6d, 0x14, + 0x50, 0xd1, 0x68, 0x93, 0x5d, 0xfb, 0x06, 0x36, 0x7c, 0x70, 0xb6, 0x7f, 0x3e, 0x5b, 0x89, 0x01, + 0xfa, 0xec, 0x1f, 0xa0, 0x17, 0xa8, 0x4d, 0xf2, 0x68, 0x47, 0xf2, 0x93, 0xd9, 0xe5, 0x2b, 0x76, + 0x94, 0xa0, 0x93, 0x4e, 0xe3, 0x7d, 0x63, 0x86, 0x6c, 0x4a, 0x5d, 0x0a, 0xd4, 0x30, 0xe8, 0x28, + 0x97, 0x05, 0x9b, 0x26, 0xf0, 0x59, 0x92, 0xb2, 0xfc, 0x09, 0x3b, 0xdc, 0x60, 0xa1, 0x80, 0x86, + 0xea, 0x41, 0xf1, 0x4b, 0x36, 0xa5, 0x3e, 0x12, 0xee, 0xfd, 0xdf, 0xb7, 0xc7, 0xfa, 0xd5, 0xeb, + 0x6f, 0x6d, 0x14, 0xdc, 0xb4, 0x51, 0x70, 0xdb, 0x46, 0xc1, 0xcf, 0x36, 0x0a, 0xbe, 0x6e, 0xa3, + 0xc9, 0xed, 0x36, 0x9a, 0x7c, 0xdf, 0x46, 0x93, 0x77, 0xcf, 0xff, 0xe2, 0x5d, 0x69, 0x92, 0x17, + 0x48, 0x20, 0x2c, 0xe4, 0x52, 0x8b, 0x2f, 0xbb, 0x9d, 0xf4, 0xdc, 0xf5, 0xa1, 0xdf, 0xa5, 0x97, + 0xbf, 0x03, 0x00, 0x00, 0xff, 0xff, 0xc7, 0x27, 0xcd, 0xb2, 0xb1, 0x02, 0x00, 0x00, +} + +func (this *RecoveryRecord) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*RecoveryRecord) + if !ok { + that2, ok := that.(RecoveryRecord) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Address != that1.Address { + return false + } + if this.Challenge != that1.Challenge { + return false + } + if this.Nonce != that1.Nonce { + return false + } + return true +} +func (this *RecoveryToken) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*RecoveryToken) + if !ok { + that2, ok := that.(RecoveryToken) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Address != that1.Address { + return false + } + if this.Token != that1.Token { + return false + } + if !this.RrSupply.Equal(that1.RrSupply) { + return false + } + if len(this.UnderlyingTokens) != len(that1.UnderlyingTokens) { + return false + } + for i := range this.UnderlyingTokens { + if !this.UnderlyingTokens[i].Equal(that1.UnderlyingTokens[i]) { + return false + } + } + return true +} +func (this *Rotation) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*Rotation) + if !ok { + that2, ok := that.(Rotation) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Address != that1.Address { + return false + } + if this.Rotated != that1.Rotated { + return false + } + return true +} +func (this *Rewards) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*Rewards) + if !ok { + that2, ok := that.(Rewards) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Holder != that1.Holder { + return false + } + if len(this.Rewards) != len(that1.Rewards) { + return false + } + for i := range this.Rewards { + if !this.Rewards[i].Equal(that1.Rewards[i]) { + return false + } + } + return true +} +func (m *RecoveryRecord) 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 *RecoveryRecord) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *RecoveryRecord) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Nonce) > 0 { + i -= len(m.Nonce) + copy(dAtA[i:], m.Nonce) + i = encodeVarintRecovery(dAtA, i, uint64(len(m.Nonce))) + i-- + dAtA[i] = 0x1a + } + if len(m.Challenge) > 0 { + i -= len(m.Challenge) + copy(dAtA[i:], m.Challenge) + i = encodeVarintRecovery(dAtA, i, uint64(len(m.Challenge))) + i-- + dAtA[i] = 0x12 + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintRecovery(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *RecoveryToken) 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 *RecoveryToken) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *RecoveryToken) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.UnderlyingTokens) > 0 { + for iNdEx := len(m.UnderlyingTokens) - 1; iNdEx >= 0; iNdEx-- { + { + size := m.UnderlyingTokens[iNdEx].Size() + i -= size + if _, err := m.UnderlyingTokens[iNdEx].MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintRecovery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + } + { + size := m.RrSupply.Size() + i -= size + if _, err := m.RrSupply.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintRecovery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if len(m.Token) > 0 { + i -= len(m.Token) + copy(dAtA[i:], m.Token) + i = encodeVarintRecovery(dAtA, i, uint64(len(m.Token))) + i-- + dAtA[i] = 0x12 + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintRecovery(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *Rotation) 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 *Rotation) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Rotation) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Rotated) > 0 { + i -= len(m.Rotated) + copy(dAtA[i:], m.Rotated) + i = encodeVarintRecovery(dAtA, i, uint64(len(m.Rotated))) + i-- + dAtA[i] = 0x12 + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintRecovery(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *Rewards) 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 *Rewards) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Rewards) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Rewards) > 0 { + for iNdEx := len(m.Rewards) - 1; iNdEx >= 0; iNdEx-- { + { + size := m.Rewards[iNdEx].Size() + i -= size + if _, err := m.Rewards[iNdEx].MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintRecovery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if len(m.Holder) > 0 { + i -= len(m.Holder) + copy(dAtA[i:], m.Holder) + i = encodeVarintRecovery(dAtA, i, uint64(len(m.Holder))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintRecovery(dAtA []byte, offset int, v uint64) int { + offset -= sovRecovery(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *RecoveryRecord) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovRecovery(uint64(l)) + } + l = len(m.Challenge) + if l > 0 { + n += 1 + l + sovRecovery(uint64(l)) + } + l = len(m.Nonce) + if l > 0 { + n += 1 + l + sovRecovery(uint64(l)) + } + return n +} + +func (m *RecoveryToken) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovRecovery(uint64(l)) + } + l = len(m.Token) + if l > 0 { + n += 1 + l + sovRecovery(uint64(l)) + } + l = m.RrSupply.Size() + n += 1 + l + sovRecovery(uint64(l)) + if len(m.UnderlyingTokens) > 0 { + for _, e := range m.UnderlyingTokens { + l = e.Size() + n += 1 + l + sovRecovery(uint64(l)) + } + } + return n +} + +func (m *Rotation) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovRecovery(uint64(l)) + } + l = len(m.Rotated) + if l > 0 { + n += 1 + l + sovRecovery(uint64(l)) + } + return n +} + +func (m *Rewards) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Holder) + if l > 0 { + n += 1 + l + sovRecovery(uint64(l)) + } + if len(m.Rewards) > 0 { + for _, e := range m.Rewards { + l = e.Size() + n += 1 + l + sovRecovery(uint64(l)) + } + } + return n +} + +func sovRecovery(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozRecovery(x uint64) (n int) { + return sovRecovery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *RecoveryRecord) 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 ErrIntOverflowRecovery + } + 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: RecoveryRecord: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: RecoveryRecord: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRecovery + } + 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 ErrInvalidLengthRecovery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthRecovery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Challenge", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRecovery + } + 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 ErrInvalidLengthRecovery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthRecovery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Challenge = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Nonce", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRecovery + } + 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 ErrInvalidLengthRecovery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthRecovery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Nonce = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipRecovery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthRecovery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *RecoveryToken) 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 ErrIntOverflowRecovery + } + 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: RecoveryToken: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: RecoveryToken: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRecovery + } + 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 ErrInvalidLengthRecovery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthRecovery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Token", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRecovery + } + 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 ErrInvalidLengthRecovery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthRecovery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Token = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RrSupply", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRecovery + } + 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 ErrInvalidLengthRecovery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthRecovery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.RrSupply.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field UnderlyingTokens", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRecovery + } + 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 ErrInvalidLengthRecovery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthRecovery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var v github_com_cosmos_cosmos_sdk_types.Coin + m.UnderlyingTokens = append(m.UnderlyingTokens, v) + if err := m.UnderlyingTokens[len(m.UnderlyingTokens)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipRecovery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthRecovery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Rotation) 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 ErrIntOverflowRecovery + } + 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: Rotation: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Rotation: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRecovery + } + 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 ErrInvalidLengthRecovery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthRecovery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Rotated", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRecovery + } + 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 ErrInvalidLengthRecovery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthRecovery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Rotated = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipRecovery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthRecovery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Rewards) 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 ErrIntOverflowRecovery + } + 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: Rewards: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Rewards: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Holder", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRecovery + } + 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 ErrInvalidLengthRecovery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthRecovery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Holder = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Rewards", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRecovery + } + 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 ErrInvalidLengthRecovery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthRecovery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var v github_com_cosmos_cosmos_sdk_types.Coin + m.Rewards = append(m.Rewards, v) + if err := m.Rewards[len(m.Rewards)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipRecovery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthRecovery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipRecovery(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, ErrIntOverflowRecovery + } + 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, ErrIntOverflowRecovery + } + 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, ErrIntOverflowRecovery + } + 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, ErrInvalidLengthRecovery + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupRecovery + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthRecovery + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthRecovery = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowRecovery = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupRecovery = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/recovery/types/tx.pb.go b/x/recovery/types/tx.pb.go new file mode 100644 index 000000000..205f6f9dc --- /dev/null +++ b/x/recovery/types/tx.pb.go @@ -0,0 +1,3291 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: kira/recovery/tx.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/codec/types" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/gogo/protobuf/gogoproto" + grpc1 "github.com/gogo/protobuf/grpc" + proto "github.com/gogo/protobuf/proto" + _ "github.com/regen-network/cosmos-proto" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type MsgRegisterRecoverySecret struct { + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + Challenge string `protobuf:"bytes,2,opt,name=challenge,proto3" json:"challenge,omitempty"` + Nonce string `protobuf:"bytes,3,opt,name=nonce,proto3" json:"nonce,omitempty"` + Proof string `protobuf:"bytes,4,opt,name=proof,proto3" json:"proof,omitempty"` +} + +func (m *MsgRegisterRecoverySecret) Reset() { *m = MsgRegisterRecoverySecret{} } +func (m *MsgRegisterRecoverySecret) String() string { return proto.CompactTextString(m) } +func (*MsgRegisterRecoverySecret) ProtoMessage() {} +func (*MsgRegisterRecoverySecret) Descriptor() ([]byte, []int) { + return fileDescriptor_8b5bb529d56b66ae, []int{0} +} +func (m *MsgRegisterRecoverySecret) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRegisterRecoverySecret) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRegisterRecoverySecret.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 *MsgRegisterRecoverySecret) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRegisterRecoverySecret.Merge(m, src) +} +func (m *MsgRegisterRecoverySecret) XXX_Size() int { + return m.Size() +} +func (m *MsgRegisterRecoverySecret) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRegisterRecoverySecret.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRegisterRecoverySecret proto.InternalMessageInfo + +func (m *MsgRegisterRecoverySecret) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +func (m *MsgRegisterRecoverySecret) GetChallenge() string { + if m != nil { + return m.Challenge + } + return "" +} + +func (m *MsgRegisterRecoverySecret) GetNonce() string { + if m != nil { + return m.Nonce + } + return "" +} + +func (m *MsgRegisterRecoverySecret) GetProof() string { + if m != nil { + return m.Proof + } + return "" +} + +type MsgRegisterRecoverySecretResponse struct { +} + +func (m *MsgRegisterRecoverySecretResponse) Reset() { *m = MsgRegisterRecoverySecretResponse{} } +func (m *MsgRegisterRecoverySecretResponse) String() string { return proto.CompactTextString(m) } +func (*MsgRegisterRecoverySecretResponse) ProtoMessage() {} +func (*MsgRegisterRecoverySecretResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_8b5bb529d56b66ae, []int{1} +} +func (m *MsgRegisterRecoverySecretResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRegisterRecoverySecretResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRegisterRecoverySecretResponse.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 *MsgRegisterRecoverySecretResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRegisterRecoverySecretResponse.Merge(m, src) +} +func (m *MsgRegisterRecoverySecretResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgRegisterRecoverySecretResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRegisterRecoverySecretResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRegisterRecoverySecretResponse proto.InternalMessageInfo + +type MsgRotateRecoveryAddress struct { + FeePayer string `protobuf:"bytes,1,opt,name=fee_payer,json=feePayer,proto3" json:"fee_payer,omitempty"` + Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"` + Recovery string `protobuf:"bytes,3,opt,name=recovery,proto3" json:"recovery,omitempty"` + Proof string `protobuf:"bytes,4,opt,name=proof,proto3" json:"proof,omitempty"` +} + +func (m *MsgRotateRecoveryAddress) Reset() { *m = MsgRotateRecoveryAddress{} } +func (m *MsgRotateRecoveryAddress) String() string { return proto.CompactTextString(m) } +func (*MsgRotateRecoveryAddress) ProtoMessage() {} +func (*MsgRotateRecoveryAddress) Descriptor() ([]byte, []int) { + return fileDescriptor_8b5bb529d56b66ae, []int{2} +} +func (m *MsgRotateRecoveryAddress) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRotateRecoveryAddress) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRotateRecoveryAddress.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 *MsgRotateRecoveryAddress) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRotateRecoveryAddress.Merge(m, src) +} +func (m *MsgRotateRecoveryAddress) XXX_Size() int { + return m.Size() +} +func (m *MsgRotateRecoveryAddress) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRotateRecoveryAddress.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRotateRecoveryAddress proto.InternalMessageInfo + +func (m *MsgRotateRecoveryAddress) GetFeePayer() string { + if m != nil { + return m.FeePayer + } + return "" +} + +func (m *MsgRotateRecoveryAddress) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +func (m *MsgRotateRecoveryAddress) GetRecovery() string { + if m != nil { + return m.Recovery + } + return "" +} + +func (m *MsgRotateRecoveryAddress) GetProof() string { + if m != nil { + return m.Proof + } + return "" +} + +type MsgRotateRecoveryAddressResponse struct { +} + +func (m *MsgRotateRecoveryAddressResponse) Reset() { *m = MsgRotateRecoveryAddressResponse{} } +func (m *MsgRotateRecoveryAddressResponse) String() string { return proto.CompactTextString(m) } +func (*MsgRotateRecoveryAddressResponse) ProtoMessage() {} +func (*MsgRotateRecoveryAddressResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_8b5bb529d56b66ae, []int{3} +} +func (m *MsgRotateRecoveryAddressResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRotateRecoveryAddressResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRotateRecoveryAddressResponse.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 *MsgRotateRecoveryAddressResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRotateRecoveryAddressResponse.Merge(m, src) +} +func (m *MsgRotateRecoveryAddressResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgRotateRecoveryAddressResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRotateRecoveryAddressResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRotateRecoveryAddressResponse proto.InternalMessageInfo + +type MsgIssueRecoveryTokens struct { + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` +} + +func (m *MsgIssueRecoveryTokens) Reset() { *m = MsgIssueRecoveryTokens{} } +func (m *MsgIssueRecoveryTokens) String() string { return proto.CompactTextString(m) } +func (*MsgIssueRecoveryTokens) ProtoMessage() {} +func (*MsgIssueRecoveryTokens) Descriptor() ([]byte, []int) { + return fileDescriptor_8b5bb529d56b66ae, []int{4} +} +func (m *MsgIssueRecoveryTokens) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgIssueRecoveryTokens) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgIssueRecoveryTokens.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 *MsgIssueRecoveryTokens) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgIssueRecoveryTokens.Merge(m, src) +} +func (m *MsgIssueRecoveryTokens) XXX_Size() int { + return m.Size() +} +func (m *MsgIssueRecoveryTokens) XXX_DiscardUnknown() { + xxx_messageInfo_MsgIssueRecoveryTokens.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgIssueRecoveryTokens proto.InternalMessageInfo + +func (m *MsgIssueRecoveryTokens) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +type MsgIssueRecoveryTokensResponse struct { +} + +func (m *MsgIssueRecoveryTokensResponse) Reset() { *m = MsgIssueRecoveryTokensResponse{} } +func (m *MsgIssueRecoveryTokensResponse) String() string { return proto.CompactTextString(m) } +func (*MsgIssueRecoveryTokensResponse) ProtoMessage() {} +func (*MsgIssueRecoveryTokensResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_8b5bb529d56b66ae, []int{5} +} +func (m *MsgIssueRecoveryTokensResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgIssueRecoveryTokensResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgIssueRecoveryTokensResponse.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 *MsgIssueRecoveryTokensResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgIssueRecoveryTokensResponse.Merge(m, src) +} +func (m *MsgIssueRecoveryTokensResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgIssueRecoveryTokensResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgIssueRecoveryTokensResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgIssueRecoveryTokensResponse proto.InternalMessageInfo + +type MsgBurnRecoveryTokens struct { + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + RrCoin github_com_cosmos_cosmos_sdk_types.Coin `protobuf:"bytes,2,opt,name=rr_coin,json=rrCoin,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Coin" json:"rr_coin"` +} + +func (m *MsgBurnRecoveryTokens) Reset() { *m = MsgBurnRecoveryTokens{} } +func (m *MsgBurnRecoveryTokens) String() string { return proto.CompactTextString(m) } +func (*MsgBurnRecoveryTokens) ProtoMessage() {} +func (*MsgBurnRecoveryTokens) Descriptor() ([]byte, []int) { + return fileDescriptor_8b5bb529d56b66ae, []int{6} +} +func (m *MsgBurnRecoveryTokens) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgBurnRecoveryTokens) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgBurnRecoveryTokens.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 *MsgBurnRecoveryTokens) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgBurnRecoveryTokens.Merge(m, src) +} +func (m *MsgBurnRecoveryTokens) XXX_Size() int { + return m.Size() +} +func (m *MsgBurnRecoveryTokens) XXX_DiscardUnknown() { + xxx_messageInfo_MsgBurnRecoveryTokens.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgBurnRecoveryTokens proto.InternalMessageInfo + +func (m *MsgBurnRecoveryTokens) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +type MsgBurnRecoveryTokensResponse struct { +} + +func (m *MsgBurnRecoveryTokensResponse) Reset() { *m = MsgBurnRecoveryTokensResponse{} } +func (m *MsgBurnRecoveryTokensResponse) String() string { return proto.CompactTextString(m) } +func (*MsgBurnRecoveryTokensResponse) ProtoMessage() {} +func (*MsgBurnRecoveryTokensResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_8b5bb529d56b66ae, []int{7} +} +func (m *MsgBurnRecoveryTokensResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgBurnRecoveryTokensResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgBurnRecoveryTokensResponse.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 *MsgBurnRecoveryTokensResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgBurnRecoveryTokensResponse.Merge(m, src) +} +func (m *MsgBurnRecoveryTokensResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgBurnRecoveryTokensResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgBurnRecoveryTokensResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgBurnRecoveryTokensResponse proto.InternalMessageInfo + +type MsgClaimRRHolderRewards struct { + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` +} + +func (m *MsgClaimRRHolderRewards) Reset() { *m = MsgClaimRRHolderRewards{} } +func (m *MsgClaimRRHolderRewards) String() string { return proto.CompactTextString(m) } +func (*MsgClaimRRHolderRewards) ProtoMessage() {} +func (*MsgClaimRRHolderRewards) Descriptor() ([]byte, []int) { + return fileDescriptor_8b5bb529d56b66ae, []int{8} +} +func (m *MsgClaimRRHolderRewards) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgClaimRRHolderRewards) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgClaimRRHolderRewards.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 *MsgClaimRRHolderRewards) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgClaimRRHolderRewards.Merge(m, src) +} +func (m *MsgClaimRRHolderRewards) XXX_Size() int { + return m.Size() +} +func (m *MsgClaimRRHolderRewards) XXX_DiscardUnknown() { + xxx_messageInfo_MsgClaimRRHolderRewards.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgClaimRRHolderRewards proto.InternalMessageInfo + +type MsgClaimRRHolderRewardsResponse struct { +} + +func (m *MsgClaimRRHolderRewardsResponse) Reset() { *m = MsgClaimRRHolderRewardsResponse{} } +func (m *MsgClaimRRHolderRewardsResponse) String() string { return proto.CompactTextString(m) } +func (*MsgClaimRRHolderRewardsResponse) ProtoMessage() {} +func (*MsgClaimRRHolderRewardsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_8b5bb529d56b66ae, []int{9} +} +func (m *MsgClaimRRHolderRewardsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgClaimRRHolderRewardsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgClaimRRHolderRewardsResponse.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 *MsgClaimRRHolderRewardsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgClaimRRHolderRewardsResponse.Merge(m, src) +} +func (m *MsgClaimRRHolderRewardsResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgClaimRRHolderRewardsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgClaimRRHolderRewardsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgClaimRRHolderRewardsResponse proto.InternalMessageInfo + +type MsgRegisterRRTokenHolder struct { + Holder string `protobuf:"bytes,1,opt,name=holder,proto3" json:"holder,omitempty"` +} + +func (m *MsgRegisterRRTokenHolder) Reset() { *m = MsgRegisterRRTokenHolder{} } +func (m *MsgRegisterRRTokenHolder) String() string { return proto.CompactTextString(m) } +func (*MsgRegisterRRTokenHolder) ProtoMessage() {} +func (*MsgRegisterRRTokenHolder) Descriptor() ([]byte, []int) { + return fileDescriptor_8b5bb529d56b66ae, []int{10} +} +func (m *MsgRegisterRRTokenHolder) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRegisterRRTokenHolder) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRegisterRRTokenHolder.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 *MsgRegisterRRTokenHolder) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRegisterRRTokenHolder.Merge(m, src) +} +func (m *MsgRegisterRRTokenHolder) XXX_Size() int { + return m.Size() +} +func (m *MsgRegisterRRTokenHolder) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRegisterRRTokenHolder.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRegisterRRTokenHolder proto.InternalMessageInfo + +func (m *MsgRegisterRRTokenHolder) GetHolder() string { + if m != nil { + return m.Holder + } + return "" +} + +type MsgRegisterRRTokenHolderResponse struct { +} + +func (m *MsgRegisterRRTokenHolderResponse) Reset() { *m = MsgRegisterRRTokenHolderResponse{} } +func (m *MsgRegisterRRTokenHolderResponse) String() string { return proto.CompactTextString(m) } +func (*MsgRegisterRRTokenHolderResponse) ProtoMessage() {} +func (*MsgRegisterRRTokenHolderResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_8b5bb529d56b66ae, []int{11} +} +func (m *MsgRegisterRRTokenHolderResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRegisterRRTokenHolderResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRegisterRRTokenHolderResponse.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 *MsgRegisterRRTokenHolderResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRegisterRRTokenHolderResponse.Merge(m, src) +} +func (m *MsgRegisterRRTokenHolderResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgRegisterRRTokenHolderResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRegisterRRTokenHolderResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRegisterRRTokenHolderResponse proto.InternalMessageInfo + +type MsgRotateValidatorByHalfRRTokenHolder struct { + RrHolder string `protobuf:"bytes,1,opt,name=rr_holder,json=rrHolder,proto3" json:"rr_holder,omitempty"` + Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"` + Recovery string `protobuf:"bytes,3,opt,name=recovery,proto3" json:"recovery,omitempty"` +} + +func (m *MsgRotateValidatorByHalfRRTokenHolder) Reset() { *m = MsgRotateValidatorByHalfRRTokenHolder{} } +func (m *MsgRotateValidatorByHalfRRTokenHolder) String() string { return proto.CompactTextString(m) } +func (*MsgRotateValidatorByHalfRRTokenHolder) ProtoMessage() {} +func (*MsgRotateValidatorByHalfRRTokenHolder) Descriptor() ([]byte, []int) { + return fileDescriptor_8b5bb529d56b66ae, []int{12} +} +func (m *MsgRotateValidatorByHalfRRTokenHolder) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRotateValidatorByHalfRRTokenHolder) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRotateValidatorByHalfRRTokenHolder.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 *MsgRotateValidatorByHalfRRTokenHolder) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRotateValidatorByHalfRRTokenHolder.Merge(m, src) +} +func (m *MsgRotateValidatorByHalfRRTokenHolder) XXX_Size() int { + return m.Size() +} +func (m *MsgRotateValidatorByHalfRRTokenHolder) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRotateValidatorByHalfRRTokenHolder.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRotateValidatorByHalfRRTokenHolder proto.InternalMessageInfo + +func (m *MsgRotateValidatorByHalfRRTokenHolder) GetRrHolder() string { + if m != nil { + return m.RrHolder + } + return "" +} + +func (m *MsgRotateValidatorByHalfRRTokenHolder) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +func (m *MsgRotateValidatorByHalfRRTokenHolder) GetRecovery() string { + if m != nil { + return m.Recovery + } + return "" +} + +type MsgRotateValidatorByHalfRRTokenHolderResponse struct { +} + +func (m *MsgRotateValidatorByHalfRRTokenHolderResponse) Reset() { + *m = MsgRotateValidatorByHalfRRTokenHolderResponse{} +} +func (m *MsgRotateValidatorByHalfRRTokenHolderResponse) String() string { + return proto.CompactTextString(m) +} +func (*MsgRotateValidatorByHalfRRTokenHolderResponse) ProtoMessage() {} +func (*MsgRotateValidatorByHalfRRTokenHolderResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_8b5bb529d56b66ae, []int{13} +} +func (m *MsgRotateValidatorByHalfRRTokenHolderResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRotateValidatorByHalfRRTokenHolderResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRotateValidatorByHalfRRTokenHolderResponse.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 *MsgRotateValidatorByHalfRRTokenHolderResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRotateValidatorByHalfRRTokenHolderResponse.Merge(m, src) +} +func (m *MsgRotateValidatorByHalfRRTokenHolderResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgRotateValidatorByHalfRRTokenHolderResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRotateValidatorByHalfRRTokenHolderResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRotateValidatorByHalfRRTokenHolderResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*MsgRegisterRecoverySecret)(nil), "kira.recovery.MsgRegisterRecoverySecret") + proto.RegisterType((*MsgRegisterRecoverySecretResponse)(nil), "kira.recovery.MsgRegisterRecoverySecretResponse") + proto.RegisterType((*MsgRotateRecoveryAddress)(nil), "kira.recovery.MsgRotateRecoveryAddress") + proto.RegisterType((*MsgRotateRecoveryAddressResponse)(nil), "kira.recovery.MsgRotateRecoveryAddressResponse") + proto.RegisterType((*MsgIssueRecoveryTokens)(nil), "kira.recovery.MsgIssueRecoveryTokens") + proto.RegisterType((*MsgIssueRecoveryTokensResponse)(nil), "kira.recovery.MsgIssueRecoveryTokensResponse") + proto.RegisterType((*MsgBurnRecoveryTokens)(nil), "kira.recovery.MsgBurnRecoveryTokens") + proto.RegisterType((*MsgBurnRecoveryTokensResponse)(nil), "kira.recovery.MsgBurnRecoveryTokensResponse") + proto.RegisterType((*MsgClaimRRHolderRewards)(nil), "kira.recovery.MsgClaimRRHolderRewards") + proto.RegisterType((*MsgClaimRRHolderRewardsResponse)(nil), "kira.recovery.MsgClaimRRHolderRewardsResponse") + proto.RegisterType((*MsgRegisterRRTokenHolder)(nil), "kira.recovery.MsgRegisterRRTokenHolder") + proto.RegisterType((*MsgRegisterRRTokenHolderResponse)(nil), "kira.recovery.MsgRegisterRRTokenHolderResponse") + proto.RegisterType((*MsgRotateValidatorByHalfRRTokenHolder)(nil), "kira.recovery.MsgRotateValidatorByHalfRRTokenHolder") + proto.RegisterType((*MsgRotateValidatorByHalfRRTokenHolderResponse)(nil), "kira.recovery.MsgRotateValidatorByHalfRRTokenHolderResponse") +} + +func init() { proto.RegisterFile("kira/recovery/tx.proto", fileDescriptor_8b5bb529d56b66ae) } + +var fileDescriptor_8b5bb529d56b66ae = []byte{ + // 671 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x55, 0xbf, 0x6f, 0xd3, 0x4e, + 0x14, 0x8f, 0xdb, 0xef, 0x37, 0x4d, 0x9e, 0xc4, 0x62, 0xda, 0xe0, 0xba, 0xc5, 0x69, 0x0d, 0xa5, + 0x15, 0xa2, 0x36, 0x2a, 0x4c, 0xc0, 0x42, 0xba, 0x04, 0xa1, 0x48, 0xc8, 0x20, 0x06, 0x96, 0xe8, + 0x6a, 0xbf, 0x38, 0x56, 0x5c, 0x5f, 0xb8, 0x73, 0xa0, 0x81, 0x81, 0x81, 0x85, 0x91, 0x91, 0xb1, + 0x23, 0xff, 0x07, 0x4b, 0xc7, 0x8e, 0x88, 0xa1, 0x42, 0xe9, 0xc2, 0x9f, 0x81, 0xfc, 0x93, 0x44, + 0x39, 0x47, 0x56, 0x27, 0xdf, 0xbb, 0xf7, 0x79, 0xef, 0xf3, 0xb9, 0x7b, 0xef, 0x9d, 0xa1, 0x31, + 0xf0, 0x18, 0x31, 0x19, 0xda, 0xf4, 0x1d, 0xb2, 0xb1, 0x19, 0x9e, 0x18, 0x43, 0x46, 0x43, 0x2a, + 0x5f, 0x8b, 0xf6, 0x8d, 0x6c, 0x5f, 0x5d, 0x75, 0xa9, 0x4b, 0x63, 0x8f, 0x19, 0xad, 0x12, 0x90, + 0xba, 0xee, 0x52, 0xea, 0xfa, 0x68, 0xc6, 0xd6, 0xd1, 0xa8, 0x67, 0x92, 0x60, 0x9c, 0xb9, 0x6c, + 0xca, 0x8f, 0x29, 0xef, 0x26, 0x31, 0x89, 0x91, 0xba, 0x36, 0x67, 0x29, 0xb3, 0x45, 0xe2, 0xd5, + 0x3f, 0xc1, 0x7a, 0x87, 0xbb, 0x16, 0xba,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x86, 0x4d, 0x8f, + 0xd3, 0x46, 0x49, 0x3f, 0xfb, 0xdc, 0x19, 0x98, 0xe1, 0x78, 0x88, 0xdc, 0x38, 0xa4, 0x5e, 0x60, + 0x55, 0x19, 0x8b, 0xbe, 0x7a, 0x13, 0x6e, 0x0a, 0xc9, 0x73, 0x75, 0x8f, 0xe1, 0x46, 0x87, 0xbb, + 0x87, 0x3e, 0xf1, 0x8e, 0x2d, 0xab, 0x4d, 0x7d, 0x27, 0xaa, 0xe3, 0x7b, 0xc2, 0x1c, 0x2e, 0x37, + 0xa0, 0xca, 0x31, 0x70, 0xf2, 0xc2, 0xa4, 0xd6, 0xa3, 0xda, 0x97, 0xd3, 0x66, 0xe5, 0xcf, 0x69, + 0xb3, 0xa2, 0x6f, 0x43, 0xb3, 0x20, 0x78, 0xea, 0x4e, 0x95, 0xe9, 0x16, 0xb1, 0x62, 0xfa, 0x04, + 0x1a, 0x11, 0xf4, 0xe3, 0x55, 0x46, 0x90, 0x58, 0x59, 0xad, 0x44, 0x31, 0x79, 0xde, 0x0f, 0xb0, + 0x93, 0xd7, 0xf3, 0x35, 0xf1, 0x3d, 0x87, 0x84, 0x94, 0xb5, 0xc6, 0x6d, 0xe2, 0xf7, 0x66, 0x49, + 0x36, 0xa0, 0xce, 0x58, 0x77, 0x86, 0xa7, 0xc6, 0x58, 0xea, 0xbc, 0x52, 0x87, 0xe9, 0x26, 0xec, + 0x97, 0xe2, 0xce, 0xc4, 0x1e, 0xfc, 0xa8, 0xc2, 0x72, 0x87, 0xbb, 0x72, 0x08, 0x8d, 0x82, 0x69, + 0xdd, 0x33, 0x66, 0x1e, 0x11, 0xa3, 0x70, 0xac, 0xd4, 0xfb, 0x65, 0x91, 0x19, 0xbb, 0xfc, 0x16, + 0xd6, 0xc4, 0xc3, 0xb7, 0x2b, 0x48, 0x25, 0x02, 0xaa, 0x66, 0x49, 0x60, 0x4e, 0x39, 0x80, 0xeb, + 0xa2, 0x31, 0xda, 0x99, 0xcf, 0x23, 0x80, 0xa9, 0xfb, 0xa5, 0x60, 0x39, 0x59, 0x1f, 0x64, 0xc1, + 0x74, 0xdd, 0x9e, 0x4f, 0x32, 0x8f, 0x52, 0xef, 0x95, 0x41, 0xe5, 0x4c, 0x01, 0xac, 0x0a, 0x27, + 0xe5, 0xce, 0x7c, 0x16, 0x11, 0x4e, 0x35, 0xca, 0xe1, 0x66, 0x2a, 0x27, 0x9c, 0x9c, 0xdd, 0x05, + 0x4d, 0x30, 0x0d, 0x14, 0x56, 0x6e, 0xd1, 0x5c, 0xc9, 0xdf, 0x24, 0xd0, 0x4b, 0x4c, 0xd5, 0xc3, + 0xa2, 0x8e, 0x58, 0x14, 0xa5, 0x3e, 0xb9, 0x4a, 0x54, 0x26, 0xad, 0xd5, 0xfe, 0x3e, 0xd1, 0xa4, + 0xb3, 0x89, 0x26, 0x9d, 0x4f, 0x34, 0xe9, 0xf7, 0x44, 0x93, 0xbe, 0x5e, 0x6a, 0x95, 0xf3, 0x4b, + 0xad, 0xf2, 0xf3, 0x52, 0xab, 0xbc, 0xb9, 0x3b, 0xf5, 0x34, 0x3e, 0xf7, 0x18, 0x39, 0xa4, 0x0c, + 0x4d, 0x8e, 0x03, 0xe2, 0x99, 0x27, 0x53, 0x3f, 0xed, 0xe8, 0x89, 0x3c, 0xaa, 0xc6, 0xff, 0xcf, + 0x07, 0x7f, 0x03, 0x00, 0x00, 0xff, 0xff, 0xc6, 0x5a, 0x7b, 0x37, 0xd2, 0x07, 0x00, 0x00, +} + +func (this *MsgRegisterRecoverySecret) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*MsgRegisterRecoverySecret) + if !ok { + that2, ok := that.(MsgRegisterRecoverySecret) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Address != that1.Address { + return false + } + if this.Challenge != that1.Challenge { + return false + } + if this.Nonce != that1.Nonce { + return false + } + if this.Proof != that1.Proof { + return false + } + return true +} +func (this *MsgRegisterRecoverySecretResponse) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*MsgRegisterRecoverySecretResponse) + if !ok { + that2, ok := that.(MsgRegisterRecoverySecretResponse) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + return true +} +func (this *MsgRotateRecoveryAddress) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*MsgRotateRecoveryAddress) + if !ok { + that2, ok := that.(MsgRotateRecoveryAddress) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.FeePayer != that1.FeePayer { + return false + } + if this.Address != that1.Address { + return false + } + if this.Recovery != that1.Recovery { + return false + } + if this.Proof != that1.Proof { + return false + } + return true +} +func (this *MsgRotateRecoveryAddressResponse) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*MsgRotateRecoveryAddressResponse) + if !ok { + that2, ok := that.(MsgRotateRecoveryAddressResponse) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + return true +} +func (this *MsgIssueRecoveryTokens) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*MsgIssueRecoveryTokens) + if !ok { + that2, ok := that.(MsgIssueRecoveryTokens) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Address != that1.Address { + return false + } + return true +} +func (this *MsgIssueRecoveryTokensResponse) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*MsgIssueRecoveryTokensResponse) + if !ok { + that2, ok := that.(MsgIssueRecoveryTokensResponse) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + return true +} +func (this *MsgBurnRecoveryTokens) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*MsgBurnRecoveryTokens) + if !ok { + that2, ok := that.(MsgBurnRecoveryTokens) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Address != that1.Address { + return false + } + if !this.RrCoin.Equal(that1.RrCoin) { + return false + } + return true +} +func (this *MsgBurnRecoveryTokensResponse) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*MsgBurnRecoveryTokensResponse) + if !ok { + that2, ok := that.(MsgBurnRecoveryTokensResponse) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + return true +} +func (this *MsgClaimRRHolderRewardsResponse) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*MsgClaimRRHolderRewardsResponse) + if !ok { + that2, ok := that.(MsgClaimRRHolderRewardsResponse) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + return true +} +func (this *MsgRegisterRRTokenHolder) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*MsgRegisterRRTokenHolder) + if !ok { + that2, ok := that.(MsgRegisterRRTokenHolder) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Holder != that1.Holder { + return false + } + return true +} +func (this *MsgRegisterRRTokenHolderResponse) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*MsgRegisterRRTokenHolderResponse) + if !ok { + that2, ok := that.(MsgRegisterRRTokenHolderResponse) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + return true +} +func (this *MsgRotateValidatorByHalfRRTokenHolder) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*MsgRotateValidatorByHalfRRTokenHolder) + if !ok { + that2, ok := that.(MsgRotateValidatorByHalfRRTokenHolder) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.RrHolder != that1.RrHolder { + return false + } + if this.Address != that1.Address { + return false + } + if this.Recovery != that1.Recovery { + return false + } + return true +} +func (this *MsgRotateValidatorByHalfRRTokenHolderResponse) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*MsgRotateValidatorByHalfRRTokenHolderResponse) + if !ok { + that2, ok := that.(MsgRotateValidatorByHalfRRTokenHolderResponse) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + return true +} + +// 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 { + // allow ANY user to register or modify existing recovery secret & verify if the nonce is correct + RegisterRecoverySecret(ctx context.Context, in *MsgRegisterRecoverySecret, opts ...grpc.CallOption) (*MsgRegisterRecoverySecretResponse, error) + // allow ANY KIRA address that knows the recovery secret to rotate the address + RotateRecoveryAddress(ctx context.Context, in *MsgRotateRecoveryAddress, opts ...grpc.CallOption) (*MsgRotateRecoveryAddressResponse, error) + // mint `rr_` tokens and deposit them to the validator account. + // This function will require putting up a bond in the amount of `validator_recovery_bond` otherwise should fail + IssueRecoveryTokens(ctx context.Context, in *MsgIssueRecoveryTokens, opts ...grpc.CallOption) (*MsgIssueRecoveryTokensResponse, error) + // burn tokens and redeem KEX + BurnRecoveryTokens(ctx context.Context, in *MsgBurnRecoveryTokens, opts ...grpc.CallOption) (*MsgBurnRecoveryTokensResponse, error) + // claim rewards + ClaimRRHolderRewards(ctx context.Context, in *MsgClaimRRHolderRewards, opts ...grpc.CallOption) (*MsgClaimRRHolderRewardsResponse, error) + // register RR token holder + RegisterRRTokenHolder(ctx context.Context, in *MsgRegisterRRTokenHolder, opts ...grpc.CallOption) (*MsgRegisterRRTokenHolderResponse, error) + // allow ANY KIRA address has a sufficient number of RR tokens to rotate the address + RotateValidatorByHalfRRTokenHolder(ctx context.Context, in *MsgRotateValidatorByHalfRRTokenHolder, opts ...grpc.CallOption) (*MsgRotateValidatorByHalfRRTokenHolderResponse, error) +} + +type msgClient struct { + cc grpc1.ClientConn +} + +func NewMsgClient(cc grpc1.ClientConn) MsgClient { + return &msgClient{cc} +} + +func (c *msgClient) RegisterRecoverySecret(ctx context.Context, in *MsgRegisterRecoverySecret, opts ...grpc.CallOption) (*MsgRegisterRecoverySecretResponse, error) { + out := new(MsgRegisterRecoverySecretResponse) + err := c.cc.Invoke(ctx, "/kira.recovery.Msg/RegisterRecoverySecret", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) RotateRecoveryAddress(ctx context.Context, in *MsgRotateRecoveryAddress, opts ...grpc.CallOption) (*MsgRotateRecoveryAddressResponse, error) { + out := new(MsgRotateRecoveryAddressResponse) + err := c.cc.Invoke(ctx, "/kira.recovery.Msg/RotateRecoveryAddress", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) IssueRecoveryTokens(ctx context.Context, in *MsgIssueRecoveryTokens, opts ...grpc.CallOption) (*MsgIssueRecoveryTokensResponse, error) { + out := new(MsgIssueRecoveryTokensResponse) + err := c.cc.Invoke(ctx, "/kira.recovery.Msg/IssueRecoveryTokens", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) BurnRecoveryTokens(ctx context.Context, in *MsgBurnRecoveryTokens, opts ...grpc.CallOption) (*MsgBurnRecoveryTokensResponse, error) { + out := new(MsgBurnRecoveryTokensResponse) + err := c.cc.Invoke(ctx, "/kira.recovery.Msg/BurnRecoveryTokens", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) ClaimRRHolderRewards(ctx context.Context, in *MsgClaimRRHolderRewards, opts ...grpc.CallOption) (*MsgClaimRRHolderRewardsResponse, error) { + out := new(MsgClaimRRHolderRewardsResponse) + err := c.cc.Invoke(ctx, "/kira.recovery.Msg/ClaimRRHolderRewards", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) RegisterRRTokenHolder(ctx context.Context, in *MsgRegisterRRTokenHolder, opts ...grpc.CallOption) (*MsgRegisterRRTokenHolderResponse, error) { + out := new(MsgRegisterRRTokenHolderResponse) + err := c.cc.Invoke(ctx, "/kira.recovery.Msg/RegisterRRTokenHolder", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) RotateValidatorByHalfRRTokenHolder(ctx context.Context, in *MsgRotateValidatorByHalfRRTokenHolder, opts ...grpc.CallOption) (*MsgRotateValidatorByHalfRRTokenHolderResponse, error) { + out := new(MsgRotateValidatorByHalfRRTokenHolderResponse) + err := c.cc.Invoke(ctx, "/kira.recovery.Msg/RotateValidatorByHalfRRTokenHolder", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// MsgServer is the server API for Msg service. +type MsgServer interface { + // allow ANY user to register or modify existing recovery secret & verify if the nonce is correct + RegisterRecoverySecret(context.Context, *MsgRegisterRecoverySecret) (*MsgRegisterRecoverySecretResponse, error) + // allow ANY KIRA address that knows the recovery secret to rotate the address + RotateRecoveryAddress(context.Context, *MsgRotateRecoveryAddress) (*MsgRotateRecoveryAddressResponse, error) + // mint `rr_` tokens and deposit them to the validator account. + // This function will require putting up a bond in the amount of `validator_recovery_bond` otherwise should fail + IssueRecoveryTokens(context.Context, *MsgIssueRecoveryTokens) (*MsgIssueRecoveryTokensResponse, error) + // burn tokens and redeem KEX + BurnRecoveryTokens(context.Context, *MsgBurnRecoveryTokens) (*MsgBurnRecoveryTokensResponse, error) + // claim rewards + ClaimRRHolderRewards(context.Context, *MsgClaimRRHolderRewards) (*MsgClaimRRHolderRewardsResponse, error) + // register RR token holder + RegisterRRTokenHolder(context.Context, *MsgRegisterRRTokenHolder) (*MsgRegisterRRTokenHolderResponse, error) + // allow ANY KIRA address has a sufficient number of RR tokens to rotate the address + RotateValidatorByHalfRRTokenHolder(context.Context, *MsgRotateValidatorByHalfRRTokenHolder) (*MsgRotateValidatorByHalfRRTokenHolderResponse, error) +} + +// UnimplementedMsgServer can be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { +} + +func (*UnimplementedMsgServer) RegisterRecoverySecret(ctx context.Context, req *MsgRegisterRecoverySecret) (*MsgRegisterRecoverySecretResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RegisterRecoverySecret not implemented") +} +func (*UnimplementedMsgServer) RotateRecoveryAddress(ctx context.Context, req *MsgRotateRecoveryAddress) (*MsgRotateRecoveryAddressResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RotateRecoveryAddress not implemented") +} +func (*UnimplementedMsgServer) IssueRecoveryTokens(ctx context.Context, req *MsgIssueRecoveryTokens) (*MsgIssueRecoveryTokensResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method IssueRecoveryTokens not implemented") +} +func (*UnimplementedMsgServer) BurnRecoveryTokens(ctx context.Context, req *MsgBurnRecoveryTokens) (*MsgBurnRecoveryTokensResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method BurnRecoveryTokens not implemented") +} +func (*UnimplementedMsgServer) ClaimRRHolderRewards(ctx context.Context, req *MsgClaimRRHolderRewards) (*MsgClaimRRHolderRewardsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ClaimRRHolderRewards not implemented") +} +func (*UnimplementedMsgServer) RegisterRRTokenHolder(ctx context.Context, req *MsgRegisterRRTokenHolder) (*MsgRegisterRRTokenHolderResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RegisterRRTokenHolder not implemented") +} +func (*UnimplementedMsgServer) RotateValidatorByHalfRRTokenHolder(ctx context.Context, req *MsgRotateValidatorByHalfRRTokenHolder) (*MsgRotateValidatorByHalfRRTokenHolderResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RotateValidatorByHalfRRTokenHolder not implemented") +} + +func RegisterMsgServer(s grpc1.Server, srv MsgServer) { + s.RegisterService(&_Msg_serviceDesc, srv) +} + +func _Msg_RegisterRecoverySecret_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgRegisterRecoverySecret) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).RegisterRecoverySecret(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/kira.recovery.Msg/RegisterRecoverySecret", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).RegisterRecoverySecret(ctx, req.(*MsgRegisterRecoverySecret)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_RotateRecoveryAddress_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgRotateRecoveryAddress) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).RotateRecoveryAddress(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/kira.recovery.Msg/RotateRecoveryAddress", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).RotateRecoveryAddress(ctx, req.(*MsgRotateRecoveryAddress)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_IssueRecoveryTokens_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgIssueRecoveryTokens) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).IssueRecoveryTokens(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/kira.recovery.Msg/IssueRecoveryTokens", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).IssueRecoveryTokens(ctx, req.(*MsgIssueRecoveryTokens)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_BurnRecoveryTokens_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgBurnRecoveryTokens) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).BurnRecoveryTokens(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/kira.recovery.Msg/BurnRecoveryTokens", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).BurnRecoveryTokens(ctx, req.(*MsgBurnRecoveryTokens)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_ClaimRRHolderRewards_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgClaimRRHolderRewards) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).ClaimRRHolderRewards(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/kira.recovery.Msg/ClaimRRHolderRewards", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).ClaimRRHolderRewards(ctx, req.(*MsgClaimRRHolderRewards)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_RegisterRRTokenHolder_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgRegisterRRTokenHolder) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).RegisterRRTokenHolder(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/kira.recovery.Msg/RegisterRRTokenHolder", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).RegisterRRTokenHolder(ctx, req.(*MsgRegisterRRTokenHolder)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_RotateValidatorByHalfRRTokenHolder_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgRotateValidatorByHalfRRTokenHolder) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).RotateValidatorByHalfRRTokenHolder(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/kira.recovery.Msg/RotateValidatorByHalfRRTokenHolder", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).RotateValidatorByHalfRRTokenHolder(ctx, req.(*MsgRotateValidatorByHalfRRTokenHolder)) + } + return interceptor(ctx, in, info, handler) +} + +var _Msg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "kira.recovery.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "RegisterRecoverySecret", + Handler: _Msg_RegisterRecoverySecret_Handler, + }, + { + MethodName: "RotateRecoveryAddress", + Handler: _Msg_RotateRecoveryAddress_Handler, + }, + { + MethodName: "IssueRecoveryTokens", + Handler: _Msg_IssueRecoveryTokens_Handler, + }, + { + MethodName: "BurnRecoveryTokens", + Handler: _Msg_BurnRecoveryTokens_Handler, + }, + { + MethodName: "ClaimRRHolderRewards", + Handler: _Msg_ClaimRRHolderRewards_Handler, + }, + { + MethodName: "RegisterRRTokenHolder", + Handler: _Msg_RegisterRRTokenHolder_Handler, + }, + { + MethodName: "RotateValidatorByHalfRRTokenHolder", + Handler: _Msg_RotateValidatorByHalfRRTokenHolder_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "kira/recovery/tx.proto", +} + +func (m *MsgRegisterRecoverySecret) 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 *MsgRegisterRecoverySecret) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgRegisterRecoverySecret) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Proof) > 0 { + i -= len(m.Proof) + copy(dAtA[i:], m.Proof) + i = encodeVarintTx(dAtA, i, uint64(len(m.Proof))) + i-- + dAtA[i] = 0x22 + } + if len(m.Nonce) > 0 { + i -= len(m.Nonce) + copy(dAtA[i:], m.Nonce) + i = encodeVarintTx(dAtA, i, uint64(len(m.Nonce))) + i-- + dAtA[i] = 0x1a + } + if len(m.Challenge) > 0 { + i -= len(m.Challenge) + copy(dAtA[i:], m.Challenge) + i = encodeVarintTx(dAtA, i, uint64(len(m.Challenge))) + i-- + dAtA[i] = 0x12 + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintTx(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgRegisterRecoverySecretResponse) 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 *MsgRegisterRecoverySecretResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgRegisterRecoverySecretResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgRotateRecoveryAddress) 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 *MsgRotateRecoveryAddress) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgRotateRecoveryAddress) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Proof) > 0 { + i -= len(m.Proof) + copy(dAtA[i:], m.Proof) + i = encodeVarintTx(dAtA, i, uint64(len(m.Proof))) + i-- + dAtA[i] = 0x22 + } + if len(m.Recovery) > 0 { + i -= len(m.Recovery) + copy(dAtA[i:], m.Recovery) + i = encodeVarintTx(dAtA, i, uint64(len(m.Recovery))) + i-- + dAtA[i] = 0x1a + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintTx(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0x12 + } + if len(m.FeePayer) > 0 { + i -= len(m.FeePayer) + copy(dAtA[i:], m.FeePayer) + i = encodeVarintTx(dAtA, i, uint64(len(m.FeePayer))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgRotateRecoveryAddressResponse) 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 *MsgRotateRecoveryAddressResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgRotateRecoveryAddressResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgIssueRecoveryTokens) 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 *MsgIssueRecoveryTokens) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgIssueRecoveryTokens) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintTx(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgIssueRecoveryTokensResponse) 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 *MsgIssueRecoveryTokensResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgIssueRecoveryTokensResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgBurnRecoveryTokens) 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 *MsgBurnRecoveryTokens) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgBurnRecoveryTokens) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.RrCoin.Size() + i -= size + if _, err := m.RrCoin.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintTx(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgBurnRecoveryTokensResponse) 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 *MsgBurnRecoveryTokensResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgBurnRecoveryTokensResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgClaimRRHolderRewards) 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 *MsgClaimRRHolderRewards) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgClaimRRHolderRewards) 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] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgClaimRRHolderRewardsResponse) 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 *MsgClaimRRHolderRewardsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgClaimRRHolderRewardsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgRegisterRRTokenHolder) 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 *MsgRegisterRRTokenHolder) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgRegisterRRTokenHolder) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Holder) > 0 { + i -= len(m.Holder) + copy(dAtA[i:], m.Holder) + i = encodeVarintTx(dAtA, i, uint64(len(m.Holder))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgRegisterRRTokenHolderResponse) 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 *MsgRegisterRRTokenHolderResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgRegisterRRTokenHolderResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgRotateValidatorByHalfRRTokenHolder) 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 *MsgRotateValidatorByHalfRRTokenHolder) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgRotateValidatorByHalfRRTokenHolder) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Recovery) > 0 { + i -= len(m.Recovery) + copy(dAtA[i:], m.Recovery) + i = encodeVarintTx(dAtA, i, uint64(len(m.Recovery))) + i-- + dAtA[i] = 0x1a + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintTx(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0x12 + } + if len(m.RrHolder) > 0 { + i -= len(m.RrHolder) + copy(dAtA[i:], m.RrHolder) + i = encodeVarintTx(dAtA, i, uint64(len(m.RrHolder))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgRotateValidatorByHalfRRTokenHolderResponse) 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 *MsgRotateValidatorByHalfRRTokenHolderResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgRotateValidatorByHalfRRTokenHolderResponse) 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 *MsgRegisterRecoverySecret) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Challenge) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Nonce) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Proof) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgRegisterRecoverySecretResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgRotateRecoveryAddress) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.FeePayer) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Address) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Recovery) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Proof) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgRotateRecoveryAddressResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgIssueRecoveryTokens) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgIssueRecoveryTokensResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgBurnRecoveryTokens) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.RrCoin.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + +func (m *MsgBurnRecoveryTokensResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgClaimRRHolderRewards) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgClaimRRHolderRewardsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgRegisterRRTokenHolder) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Holder) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgRegisterRRTokenHolderResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgRotateValidatorByHalfRRTokenHolder) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.RrHolder) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Address) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Recovery) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgRotateValidatorByHalfRRTokenHolderResponse) 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 *MsgRegisterRecoverySecret) 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: MsgRegisterRecoverySecret: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRegisterRecoverySecret: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", 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.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Challenge", 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.Challenge = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Nonce", 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.Nonce = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Proof", 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.Proof = 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 *MsgRegisterRecoverySecretResponse) 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: MsgRegisterRecoverySecretResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRegisterRecoverySecretResponse: 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 *MsgRotateRecoveryAddress) 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: MsgRotateRecoveryAddress: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRotateRecoveryAddress: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FeePayer", 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.FeePayer = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", 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.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Recovery", 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.Recovery = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Proof", 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.Proof = 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 *MsgRotateRecoveryAddressResponse) 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: MsgRotateRecoveryAddressResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRotateRecoveryAddressResponse: 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 *MsgIssueRecoveryTokens) 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: MsgIssueRecoveryTokens: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgIssueRecoveryTokens: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", 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.Address = 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 *MsgIssueRecoveryTokensResponse) 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: MsgIssueRecoveryTokensResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgIssueRecoveryTokensResponse: 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 *MsgBurnRecoveryTokens) 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: MsgBurnRecoveryTokens: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgBurnRecoveryTokens: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", 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.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RrCoin", 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 + } + if err := m.RrCoin.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 *MsgBurnRecoveryTokensResponse) 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: MsgBurnRecoveryTokensResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgBurnRecoveryTokensResponse: 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 *MsgClaimRRHolderRewards) 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: MsgClaimRRHolderRewards: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgClaimRRHolderRewards: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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 *MsgClaimRRHolderRewardsResponse) 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: MsgClaimRRHolderRewardsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgClaimRRHolderRewardsResponse: 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 *MsgRegisterRRTokenHolder) 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: MsgRegisterRRTokenHolder: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRegisterRRTokenHolder: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Holder", 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.Holder = 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 *MsgRegisterRRTokenHolderResponse) 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: MsgRegisterRRTokenHolderResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRegisterRRTokenHolderResponse: 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 *MsgRotateValidatorByHalfRRTokenHolder) 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: MsgRotateValidatorByHalfRRTokenHolder: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRotateValidatorByHalfRRTokenHolder: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RrHolder", 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.RrHolder = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", 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.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Recovery", 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.Recovery = 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 *MsgRotateValidatorByHalfRRTokenHolderResponse) 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: MsgRotateValidatorByHalfRRTokenHolderResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRotateValidatorByHalfRRTokenHolderResponse: 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/spending/client/cli/flags.go b/x/spending/client/cli/flags.go index 1dd8b20d5..2147a8aa0 100644 --- a/x/spending/client/cli/flags.go +++ b/x/spending/client/cli/flags.go @@ -17,6 +17,7 @@ const ( FlagAmount = "amount" FlagDynamicRate = "dynamic-rate" FlagDynamicRatePeriod = "dynamic-rate-period" + FlagClaimExpiry = "claim-expiry" FlagTitle = "title" FlagDescription = "description" diff --git a/x/spending/client/cli/tx.go b/x/spending/client/cli/tx.go index c0675a684..a0eded186 100644 --- a/x/spending/client/cli/tx.go +++ b/x/spending/client/cli/tx.go @@ -152,6 +152,7 @@ func GetTxCreateSpendingPoolCmd() *cobra.Command { cmd.Flags().String(FlagName, "", "The name of the spending pool.") cmd.Flags().Int32(FlagClaimStart, 0, "The claim start timestamp of the spending pool.") cmd.Flags().Int32(FlagClaimEnd, 0, "The claim end timestamp of the spending pool.") + cmd.Flags().Uint64(FlagClaimExpiry, 43200, "claim expiry time when the users' rewards cut.") cmd.Flags().String(FlagRates, "", "reward rates of the spending pool.") cmd.Flags().Int32(FlagVoteQuorum, 0, "vote quorum of the spending pool.") cmd.Flags().Int32(FlagVotePeriod, 0, "vote period of the spending pool.") diff --git a/x/spending/keeper/msg_server.go b/x/spending/keeper/msg_server.go index d268e82dd..4df0fc874 100644 --- a/x/spending/keeper/msg_server.go +++ b/x/spending/keeper/msg_server.go @@ -43,6 +43,7 @@ func (k msgServer) CreateSpendingPool( Name: msg.Name, ClaimStart: msg.ClaimStart, ClaimEnd: msg.ClaimEnd, + ClaimExpiry: msg.ClaimExpiry, Rates: msg.Rates, VoteQuorum: msg.VoteQuorum, VotePeriod: msg.VotePeriod, diff --git a/x/spending/keeper/spending_pool.go b/x/spending/keeper/spending_pool.go index abeb1bc74..3eb2ade47 100644 --- a/x/spending/keeper/spending_pool.go +++ b/x/spending/keeper/spending_pool.go @@ -58,6 +58,11 @@ func (k Keeper) SetClaimInfo(ctx sdk.Context, claimInfo types.ClaimInfo) { store.Set(types.ClaimInfoKey(claimInfo.PoolName, claimInfo.Account), bz) } +func (k Keeper) RemoveClaimInfo(ctx sdk.Context, claimInfo types.ClaimInfo) { + store := ctx.KVStore(k.storeKey) + store.Delete(types.ClaimInfoKey(claimInfo.PoolName, claimInfo.Account)) +} + func (k Keeper) GetClaimInfo(ctx sdk.Context, poolName string, address sdk.AccAddress) *types.ClaimInfo { store := ctx.KVStore(k.storeKey) bz := store.Get(types.ClaimInfoKey(poolName, address.String())) @@ -133,9 +138,19 @@ func (k Keeper) ClaimSpendingPool(ctx sdk.Context, poolName string, sender sdk.A return types.ErrNoMoreRewardsToClaim } + if pool.DynamicRate { // dynamic rate case + if claimStart < int64(pool.LastDynamicRateCalcTime) { + claimStart = int64(pool.LastDynamicRateCalcTime) + } + } + rewards := sdk.Coins{} for _, rate := range pool.Rates { - amount := rate.Amount.Mul(sdk.NewDec((claimEnd - int64(claimStart)) * int64(weight))).RoundInt() + duration := claimEnd - claimStart + if duration > int64(pool.ClaimExpiry) { + duration = int64(pool.ClaimExpiry) + } + amount := rate.Amount.Mul(sdk.NewDec(duration * int64(weight))).RoundInt() rewards = rewards.Add(sdk.NewCoin(rate.Denom, amount)) } diff --git a/x/spending/types/pool.pb.go b/x/spending/types/pool.pb.go index c4c24c69a..2a0308a90 100644 --- a/x/spending/types/pool.pb.go +++ b/x/spending/types/pool.pb.go @@ -296,24 +296,25 @@ func (m *WeightedPermInfo) GetAccounts() []WeightedAccount { type SpendingPool struct { Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` // claim-start & claim-end - defines the exact time period (Unix timestamps) between which tokens can be claimed from the pool, allowing for a precise funds distribution. - ClaimStart uint64 `protobuf:"varint,2,opt,name=claim_start,json=claimStart,proto3" json:"claim_start,omitempty"` - ClaimEnd uint64 `protobuf:"varint,3,opt,name=claim_end,json=claimEnd,proto3" json:"claim_end,omitempty"` + ClaimStart uint64 `protobuf:"varint,2,opt,name=claim_start,json=claimStart,proto3" json:"claim_start,omitempty"` + ClaimEnd uint64 `protobuf:"varint,3,opt,name=claim_end,json=claimEnd,proto3" json:"claim_end,omitempty"` + ClaimExpiry uint64 `protobuf:"varint,4,opt,name=claim_expiry,json=claimExpiry,proto3" json:"claim_expiry,omitempty"` // rate of distribution in the smallest token denomination per 1 second (this value can be a float number, smaller than actual denomination) - Rates []github_com_cosmos_cosmos_sdk_types.DecCoin `protobuf:"bytes,4,rep,name=rates,proto3,customtype=github.com/cosmos/cosmos-sdk/types.DecCoin" json:"rates" yaml:"rates"` + Rates []github_com_cosmos_cosmos_sdk_types.DecCoin `protobuf:"bytes,5,rep,name=rates,proto3,customtype=github.com/cosmos/cosmos-sdk/types.DecCoin" json:"rates" yaml:"rates"` // pool specific % of owner accounts that must vote YES or NO for any of the pool proposals to be valid. - VoteQuorum uint64 `protobuf:"varint,5,opt,name=vote_quorum,json=voteQuorum,proto3" json:"vote_quorum,omitempty"` + VoteQuorum uint64 `protobuf:"varint,6,opt,name=vote_quorum,json=voteQuorum,proto3" json:"vote_quorum,omitempty"` // period of time in seconds that any of the pool proposals must last before passing or being rejected - VotePeriod uint64 `protobuf:"varint,6,opt,name=vote_period,json=votePeriod,proto3" json:"vote_period,omitempty"` + VotePeriod uint64 `protobuf:"varint,7,opt,name=vote_period,json=votePeriod,proto3" json:"vote_period,omitempty"` // period of time that must pass before any of the pool proposal is enacted - VoteEnactment uint64 `protobuf:"varint,7,opt,name=vote_enactment,json=voteEnactment,proto3" json:"vote_enactment,omitempty"` + VoteEnactment uint64 `protobuf:"varint,8,opt,name=vote_enactment,json=voteEnactment,proto3" json:"vote_enactment,omitempty"` // defines a list of accounts/roles controlling the spending pool via “governance-like” proposals - Owners *PermInfo `protobuf:"bytes,8,opt,name=owners,proto3" json:"owners,omitempty"` + Owners *PermInfo `protobuf:"bytes,9,opt,name=owners,proto3" json:"owners,omitempty"` // defines set of accounts/roles to which funds can be distributed - Beneficiaries *WeightedPermInfo `protobuf:"bytes,9,opt,name=beneficiaries,proto3" json:"beneficiaries,omitempty"` - Balances []github_com_cosmos_cosmos_sdk_types.Coin `protobuf:"bytes,10,rep,name=balances,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Coin" json:"balances"` - DynamicRate bool `protobuf:"varint,11,opt,name=dynamic_rate,json=dynamicRate,proto3" json:"dynamic_rate,omitempty"` - DynamicRatePeriod uint64 `protobuf:"varint,12,opt,name=dynamic_rate_period,json=dynamicRatePeriod,proto3" json:"dynamic_rate_period,omitempty"` - LastDynamicRateCalcTime uint64 `protobuf:"varint,13,opt,name=last_dynamic_rate_calc_time,json=lastDynamicRateCalcTime,proto3" json:"last_dynamic_rate_calc_time,omitempty"` + Beneficiaries *WeightedPermInfo `protobuf:"bytes,10,opt,name=beneficiaries,proto3" json:"beneficiaries,omitempty"` + Balances []github_com_cosmos_cosmos_sdk_types.Coin `protobuf:"bytes,11,rep,name=balances,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Coin" json:"balances"` + DynamicRate bool `protobuf:"varint,12,opt,name=dynamic_rate,json=dynamicRate,proto3" json:"dynamic_rate,omitempty"` + DynamicRatePeriod uint64 `protobuf:"varint,13,opt,name=dynamic_rate_period,json=dynamicRatePeriod,proto3" json:"dynamic_rate_period,omitempty"` + LastDynamicRateCalcTime uint64 `protobuf:"varint,14,opt,name=last_dynamic_rate_calc_time,json=lastDynamicRateCalcTime,proto3" json:"last_dynamic_rate_calc_time,omitempty"` } func (m *SpendingPool) Reset() { *m = SpendingPool{} } @@ -370,6 +371,13 @@ func (m *SpendingPool) GetClaimEnd() uint64 { return 0 } +func (m *SpendingPool) GetClaimExpiry() uint64 { + if m != nil { + return m.ClaimExpiry + } + return 0 +} + func (m *SpendingPool) GetVoteQuorum() uint64 { if m != nil { return m.VoteQuorum @@ -438,50 +446,51 @@ func init() { func init() { proto.RegisterFile("kira/spending/pool.proto", fileDescriptor_6027931ab19c9a21) } var fileDescriptor_6027931ab19c9a21 = []byte{ - // 687 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x54, 0xcd, 0x6a, 0x1b, 0x3d, - 0x14, 0xf5, 0x24, 0x13, 0xc7, 0x96, 0xed, 0xef, 0x47, 0xdf, 0x47, 0x23, 0x12, 0x6a, 0xbb, 0x86, - 0x52, 0x53, 0xe8, 0x0c, 0xa4, 0x8b, 0x42, 0xe8, 0x22, 0xb5, 0x93, 0x45, 0x08, 0x94, 0x74, 0x52, - 0x68, 0xe8, 0x66, 0x90, 0x67, 0x94, 0x89, 0xc8, 0x8c, 0xe4, 0x8e, 0xe4, 0xa6, 0x79, 0x8b, 0x42, - 0x5f, 0xa0, 0x8f, 0x93, 0x65, 0x96, 0xa5, 0x8b, 0x50, 0x92, 0x4d, 0xd7, 0xdd, 0x75, 0x57, 0x74, - 0x47, 0xe3, 0x9f, 0x42, 0x42, 0x57, 0xd6, 0x1c, 0x9d, 0x73, 0x74, 0xef, 0xb9, 0xb2, 0x10, 0x39, - 0xe5, 0x39, 0xf5, 0xd5, 0x98, 0x89, 0x98, 0x8b, 0xc4, 0x1f, 0x4b, 0x99, 0x7a, 0xe3, 0x5c, 0x6a, - 0x89, 0x5b, 0x66, 0xc7, 0x2b, 0x77, 0xd6, 0x3b, 0x89, 0x94, 0x49, 0xca, 0x7c, 0xd8, 0x1c, 0x4d, - 0x8e, 0x7d, 0xcd, 0x33, 0xa6, 0x34, 0xcd, 0xc6, 0x05, 0x7f, 0xfd, 0xff, 0x44, 0x26, 0x12, 0x96, - 0xbe, 0x59, 0x15, 0x68, 0x8f, 0xa2, 0xfa, 0x30, 0xa5, 0x3c, 0xdb, 0x13, 0xc7, 0x12, 0x13, 0xb4, - 0x4a, 0xa3, 0x48, 0x4e, 0x84, 0x26, 0x4e, 0xd7, 0xe9, 0xd7, 0x83, 0xf2, 0x13, 0x6f, 0xa0, 0xba, - 0x39, 0x3a, 0x14, 0x34, 0x63, 0x64, 0x09, 0xf6, 0x6a, 0x06, 0x78, 0x49, 0x33, 0x86, 0xef, 0x23, - 0x94, 0x52, 0xa5, 0xc3, 0xc8, 0x18, 0x91, 0xe5, 0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x17, 0x34, 0xe3, 0x51, 0x68, 0xe2, 0x23, 0x8d, 0xae, 0xd3, 0xaf, - 0x05, 0x0d, 0x8b, 0x05, 0x54, 0x33, 0xec, 0xa1, 0xff, 0xe6, 0x29, 0x65, 0x6e, 0x4d, 0xc8, 0xe4, - 0xdf, 0x39, 0xa6, 0x8d, 0xef, 0x39, 0xda, 0x80, 0x7f, 0xf6, 0x82, 0x28, 0xa2, 0x69, 0x14, 0x9a, - 0xd7, 0x85, 0xb4, 0x40, 0xb7, 0x66, 0x28, 0x3b, 0x33, 0xed, 0x90, 0xa6, 0xd1, 0x6b, 0x9e, 0xb1, - 0xc1, 0xce, 0xc5, 0x75, 0xdb, 0xb9, 0xbc, 0x6e, 0x3b, 0xdf, 0xae, 0xdb, 0xce, 0xc7, 0x9b, 0x76, - 0xe5, 0xf2, 0xa6, 0x5d, 0xf9, 0x72, 0xd3, 0xae, 0xbc, 0x9d, 0xbf, 0x1b, 0xfb, 0x3c, 0xa7, 0x43, - 0x99, 0x33, 0x5f, 0xb1, 0x53, 0xca, 0xfd, 0x0f, 0xb3, 0xc7, 0x0e, 0xba, 0x1c, 0x55, 0xe1, 0xa1, - 0x7a, 0xfa, 0x2b, 0x00, 0x00, 0xff, 0xff, 0x0e, 0x39, 0x1e, 0x23, 0x0a, 0x05, 0x00, 0x00, + // 703 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x54, 0x4d, 0x6b, 0x1b, 0x3b, + 0x14, 0xf5, 0x24, 0x63, 0xc7, 0x96, 0xed, 0xbc, 0xf7, 0xf4, 0x1e, 0x2f, 0x22, 0xa1, 0xb6, 0x6b, + 0x28, 0x35, 0x85, 0x7a, 0x20, 0x5d, 0x14, 0x42, 0x17, 0xa9, 0x1d, 0x2f, 0x42, 0xa0, 0xa4, 0x93, + 0x42, 0x43, 0x37, 0x46, 0x1e, 0x2b, 0x13, 0x91, 0x19, 0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0xbe, 0xd5, 0xc1, 0x93, 0x7f, + 0x16, 0x98, 0xd6, 0xbe, 0x17, 0x68, 0x0b, 0xfe, 0xfc, 0x4b, 0x4d, 0x01, 0x8d, 0x82, 0xa1, 0x79, + 0x80, 0xc8, 0x3a, 0xf4, 0x6d, 0x18, 0xca, 0xde, 0xbc, 0xb7, 0x4f, 0xa3, 0xe0, 0x0d, 0x8f, 0x59, + 0x6f, 0xef, 0xf2, 0xa6, 0xe1, 0x5c, 0xdd, 0x34, 0x9c, 0xef, 0x37, 0x0d, 0xe7, 0xe3, 0x6d, 0xa3, + 0x70, 0x75, 0xdb, 0x28, 0x7c, 0xbd, 0x6d, 0x14, 0xde, 0x2d, 0xde, 0x8d, 0x03, 0x9e, 0xd2, 0xbe, + 0x4c, 0x99, 0xa7, 0xd8, 0x19, 0xe5, 0xde, 0xc5, 0xfc, 0x3d, 0x84, 0x53, 0x8e, 0x4a, 0xf0, 0x96, + 0x3d, 0xfb, 0x15, 0x00, 0x00, 0xff, 0xff, 0xd4, 0x60, 0xba, 0x37, 0x2d, 0x05, 0x00, 0x00, } func (this *PermInfo) Equal(that interface{}) bool { @@ -846,12 +855,12 @@ func (m *SpendingPool) MarshalToSizedBuffer(dAtA []byte) (int, error) { if m.LastDynamicRateCalcTime != 0 { i = encodeVarintPool(dAtA, i, uint64(m.LastDynamicRateCalcTime)) i-- - dAtA[i] = 0x68 + dAtA[i] = 0x70 } if m.DynamicRatePeriod != 0 { i = encodeVarintPool(dAtA, i, uint64(m.DynamicRatePeriod)) i-- - dAtA[i] = 0x60 + dAtA[i] = 0x68 } if m.DynamicRate { i-- @@ -861,7 +870,7 @@ func (m *SpendingPool) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0 } i-- - dAtA[i] = 0x58 + dAtA[i] = 0x60 } if len(m.Balances) > 0 { for iNdEx := len(m.Balances) - 1; iNdEx >= 0; iNdEx-- { @@ -874,7 +883,7 @@ func (m *SpendingPool) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintPool(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x52 + dAtA[i] = 0x5a } } if m.Beneficiaries != nil { @@ -887,7 +896,7 @@ func (m *SpendingPool) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintPool(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x4a + dAtA[i] = 0x52 } if m.Owners != nil { { @@ -899,22 +908,22 @@ func (m *SpendingPool) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintPool(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x42 + dAtA[i] = 0x4a } if m.VoteEnactment != 0 { i = encodeVarintPool(dAtA, i, uint64(m.VoteEnactment)) i-- - dAtA[i] = 0x38 + dAtA[i] = 0x40 } if m.VotePeriod != 0 { i = encodeVarintPool(dAtA, i, uint64(m.VotePeriod)) i-- - dAtA[i] = 0x30 + dAtA[i] = 0x38 } if m.VoteQuorum != 0 { i = encodeVarintPool(dAtA, i, uint64(m.VoteQuorum)) i-- - dAtA[i] = 0x28 + dAtA[i] = 0x30 } if len(m.Rates) > 0 { for iNdEx := len(m.Rates) - 1; iNdEx >= 0; iNdEx-- { @@ -927,9 +936,14 @@ func (m *SpendingPool) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintPool(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x22 + dAtA[i] = 0x2a } } + if m.ClaimExpiry != 0 { + i = encodeVarintPool(dAtA, i, uint64(m.ClaimExpiry)) + i-- + dAtA[i] = 0x20 + } if m.ClaimEnd != 0 { i = encodeVarintPool(dAtA, i, uint64(m.ClaimEnd)) i-- @@ -1071,6 +1085,9 @@ func (m *SpendingPool) Size() (n int) { if m.ClaimEnd != 0 { n += 1 + sovPool(uint64(m.ClaimEnd)) } + if m.ClaimExpiry != 0 { + n += 1 + sovPool(uint64(m.ClaimExpiry)) + } if len(m.Rates) > 0 { for _, e := range m.Rates { l = e.Size() @@ -1816,6 +1833,25 @@ func (m *SpendingPool) Unmarshal(dAtA []byte) error { } } case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ClaimExpiry", wireType) + } + m.ClaimExpiry = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ClaimExpiry |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Rates", wireType) } @@ -1851,7 +1887,7 @@ func (m *SpendingPool) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 5: + case 6: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field VoteQuorum", wireType) } @@ -1870,7 +1906,7 @@ func (m *SpendingPool) Unmarshal(dAtA []byte) error { break } } - case 6: + case 7: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field VotePeriod", wireType) } @@ -1889,7 +1925,7 @@ func (m *SpendingPool) Unmarshal(dAtA []byte) error { break } } - case 7: + case 8: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field VoteEnactment", wireType) } @@ -1908,7 +1944,7 @@ func (m *SpendingPool) Unmarshal(dAtA []byte) error { break } } - case 8: + case 9: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Owners", wireType) } @@ -1944,7 +1980,7 @@ func (m *SpendingPool) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 9: + case 10: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Beneficiaries", wireType) } @@ -1980,7 +2016,7 @@ func (m *SpendingPool) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 10: + case 11: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Balances", wireType) } @@ -2016,7 +2052,7 @@ func (m *SpendingPool) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 11: + case 12: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field DynamicRate", wireType) } @@ -2036,7 +2072,7 @@ func (m *SpendingPool) Unmarshal(dAtA []byte) error { } } m.DynamicRate = bool(v != 0) - case 12: + case 13: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field DynamicRatePeriod", wireType) } @@ -2055,7 +2091,7 @@ func (m *SpendingPool) Unmarshal(dAtA []byte) error { break } } - case 13: + case 14: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field LastDynamicRateCalcTime", wireType) } diff --git a/x/spending/types/tx.pb.go b/x/spending/types/tx.pb.go index 17dd7a428..ce85d00f9 100644 --- a/x/spending/types/tx.pb.go +++ b/x/spending/types/tx.pb.go @@ -33,23 +33,24 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type MsgCreateSpendingPool struct { Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` // claim-start & claim-end - defines the exact time period (Unix timestamps) between which tokens can be claimed from the pool, allowing for a precise funds distribution. - ClaimStart uint64 `protobuf:"varint,2,opt,name=claim_start,json=claimStart,proto3" json:"claim_start,omitempty"` - ClaimEnd uint64 `protobuf:"varint,3,opt,name=claim_end,json=claimEnd,proto3" json:"claim_end,omitempty"` + ClaimStart uint64 `protobuf:"varint,2,opt,name=claim_start,json=claimStart,proto3" json:"claim_start,omitempty"` + ClaimEnd uint64 `protobuf:"varint,3,opt,name=claim_end,json=claimEnd,proto3" json:"claim_end,omitempty"` + ClaimExpiry uint64 `protobuf:"varint,4,opt,name=claim_expiry,json=claimExpiry,proto3" json:"claim_expiry,omitempty"` // rate of distribution in the smallest token denomination per 1 second (this value can be a float number, smaller than actual denomination) - Rates []github_com_cosmos_cosmos_sdk_types.DecCoin `protobuf:"bytes,4,rep,name=rates,proto3,customtype=github.com/cosmos/cosmos-sdk/types.DecCoin" json:"rates" yaml:"rates"` + Rates []github_com_cosmos_cosmos_sdk_types.DecCoin `protobuf:"bytes,5,rep,name=rates,proto3,customtype=github.com/cosmos/cosmos-sdk/types.DecCoin" json:"rates" yaml:"rates"` // pool specific % of owner accounts that must vote YES or NO for any of the pool proposals to be valid. - VoteQuorum uint64 `protobuf:"varint,5,opt,name=vote_quorum,json=voteQuorum,proto3" json:"vote_quorum,omitempty"` + VoteQuorum uint64 `protobuf:"varint,6,opt,name=vote_quorum,json=voteQuorum,proto3" json:"vote_quorum,omitempty"` // period of time in seconds that any of the pool proposals must last before passing or being rejected - VotePeriod uint64 `protobuf:"varint,6,opt,name=vote_period,json=votePeriod,proto3" json:"vote_period,omitempty"` + VotePeriod uint64 `protobuf:"varint,7,opt,name=vote_period,json=votePeriod,proto3" json:"vote_period,omitempty"` // period of time that must pass before any of the pool proposal is enacted - VoteEnactment uint64 `protobuf:"varint,7,opt,name=vote_enactment,json=voteEnactment,proto3" json:"vote_enactment,omitempty"` + VoteEnactment uint64 `protobuf:"varint,8,opt,name=vote_enactment,json=voteEnactment,proto3" json:"vote_enactment,omitempty"` // defines a list of accounts/roles controlling the spending pool via “governance-like” proposals - Owners PermInfo `protobuf:"bytes,8,opt,name=owners,proto3" json:"owners"` + Owners PermInfo `protobuf:"bytes,9,opt,name=owners,proto3" json:"owners"` // defines set of accounts/roles to which funds can be distributed - Beneficiaries WeightedPermInfo `protobuf:"bytes,9,opt,name=beneficiaries,proto3" json:"beneficiaries"` - Sender string `protobuf:"bytes,10,opt,name=sender,proto3" json:"sender,omitempty"` - DynamicRate bool `protobuf:"varint,11,opt,name=dynamic_rate,json=dynamicRate,proto3" json:"dynamic_rate,omitempty"` - DynamicRatePeriod uint64 `protobuf:"varint,12,opt,name=dynamic_rate_period,json=dynamicRatePeriod,proto3" json:"dynamic_rate_period,omitempty"` + Beneficiaries WeightedPermInfo `protobuf:"bytes,10,opt,name=beneficiaries,proto3" json:"beneficiaries"` + Sender string `protobuf:"bytes,11,opt,name=sender,proto3" json:"sender,omitempty"` + DynamicRate bool `protobuf:"varint,12,opt,name=dynamic_rate,json=dynamicRate,proto3" json:"dynamic_rate,omitempty"` + DynamicRatePeriod uint64 `protobuf:"varint,13,opt,name=dynamic_rate_period,json=dynamicRatePeriod,proto3" json:"dynamic_rate_period,omitempty"` } func (m *MsgCreateSpendingPool) Reset() { *m = MsgCreateSpendingPool{} } @@ -106,6 +107,13 @@ func (m *MsgCreateSpendingPool) GetClaimEnd() uint64 { return 0 } +func (m *MsgCreateSpendingPool) GetClaimExpiry() uint64 { + if m != nil { + return m.ClaimExpiry + } + return 0 +} + func (m *MsgCreateSpendingPool) GetVoteQuorum() uint64 { if m != nil { return m.VoteQuorum @@ -481,51 +489,52 @@ func init() { func init() { proto.RegisterFile("kira/spending/tx.proto", fileDescriptor_edfb840607cf4f3d) } var fileDescriptor_edfb840607cf4f3d = []byte{ - // 695 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x95, 0xcf, 0x6e, 0xd3, 0x4a, - 0x14, 0xc6, 0xe3, 0x26, 0xcd, 0x4d, 0x26, 0xed, 0x95, 0x3a, 0xed, 0xed, 0xb5, 0x52, 0xb0, 0x83, - 0xa1, 0x22, 0x2a, 0x6d, 0x2c, 0x8a, 0x58, 0xc0, 0x32, 0x6d, 0x85, 0x50, 0x15, 0x54, 0xdc, 0x05, - 0x7f, 0x36, 0xd1, 0x24, 0x3e, 0x75, 0x47, 0x89, 0x67, 0x8c, 0x67, 0x02, 0xcd, 0x53, 0xc0, 0x8a, - 0x0d, 0x2f, 0xd4, 0x65, 0x37, 0x48, 0x88, 0x45, 0x85, 0xda, 0x37, 0xe0, 0x09, 0xd0, 0x4c, 0x9c, - 0x34, 0x49, 0x2d, 0x35, 0xc0, 0x2a, 0xf6, 0x37, 0xbf, 0x73, 0xe6, 0xcc, 0x39, 0xdf, 0xc4, 0x68, - 0xb5, 0x43, 0x63, 0xe2, 0x8a, 0x08, 0x98, 0x4f, 0x59, 0xe0, 0xca, 0x93, 0x5a, 0x14, 0x73, 0xc9, - 0xf1,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34, 0x26, 0x3b, 0x3c, 0x06, 0x57, 0x40, 0x87, 0x50, 0xf7, 0x64, 0xec, - 0x83, 0xa3, 0xae, 0x50, 0x2b, 0xaf, 0x3f, 0x0a, 0x8f, 0x7e, 0x05, 0x00, 0x00, 0xff, 0xff, 0x92, - 0xe6, 0x41, 0xf5, 0x8e, 0x06, 0x00, 0x00, + // 711 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x55, 0xcd, 0x4e, 0xdb, 0x4a, + 0x14, 0x8e, 0x49, 0xc8, 0x4d, 0x26, 0xe4, 0x4a, 0x18, 0x2e, 0xd7, 0x0a, 0xf7, 0xda, 0xb9, 0xbe, + 0x45, 0x8d, 0x28, 0xc4, 0x2a, 0x55, 0x17, 0xed, 0x32, 0x80, 0xaa, 0x0a, 0xa5, 0xa2, 0x66, 0xd1, + 0x9f, 0x4d, 0x34, 0x89, 0x0f, 0x66, 0x94, 0x78, 0xc6, 0x9d, 0x99, 0xb4, 0xe4, 0x29, 0xda, 0x55, + 0x1f, 0xa7, 0x6b, 0x96, 0x6c, 0x2a, 0x55, 0x5d, 0xa0, 0x0a, 0xde, 0xa0, 0x4f, 0x50, 0xcd, 0xc4, + 0x09, 0x49, 0xb0, 0x44, 0xda, 0xae, 0x6c, 0x7f, 0xe7, 0x3b, 0xdf, 0x39, 0x73, 0xce, 0x67, 0x1b, + 0xad, 0x75, 0x09, 0xc7, 0x9e, 0x88, 0x81, 0x06, 0x84, 0x86, 0x9e, 0x3c, 0xad, 0xc7, 0x9c, 0x49, + 0x66, 0x96, 0x15, 0x5e, 0x1f, 0xe1, 0x95, 0xd5, 0x90, 0x85, 0x4c, 0x47, 0x3c, 0x75, 0x37, 0x24, + 0x55, 0x9c, 0x90, 0xb1, 0xb0, 0x07, 0x9e, 0x7e, 0x6a, 0xf7, 0x8f, 0x3d, 0x49, 0x22, 0x10, 0x12, + 0x47, 0x71, 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 0x5e, 0xff, 0x37, 0x1e, 0xfc, 0x08, 0x00, 0x00, 0xff, 0xff, 0x7d, + 0x9c, 0x15, 0x04, 0xb1, 0x06, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -759,7 +768,7 @@ func (m *MsgCreateSpendingPool) MarshalToSizedBuffer(dAtA []byte) (int, error) { if m.DynamicRatePeriod != 0 { i = encodeVarintTx(dAtA, i, uint64(m.DynamicRatePeriod)) i-- - dAtA[i] = 0x60 + dAtA[i] = 0x68 } if m.DynamicRate { i-- @@ -769,14 +778,14 @@ func (m *MsgCreateSpendingPool) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0 } i-- - dAtA[i] = 0x58 + dAtA[i] = 0x60 } 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] = 0x52 + dAtA[i] = 0x5a } { size, err := m.Beneficiaries.MarshalToSizedBuffer(dAtA[:i]) @@ -787,7 +796,7 @@ func (m *MsgCreateSpendingPool) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintTx(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x4a + dAtA[i] = 0x52 { size, err := m.Owners.MarshalToSizedBuffer(dAtA[:i]) if err != nil { @@ -797,21 +806,21 @@ func (m *MsgCreateSpendingPool) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintTx(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x42 + dAtA[i] = 0x4a if m.VoteEnactment != 0 { i = encodeVarintTx(dAtA, i, uint64(m.VoteEnactment)) i-- - dAtA[i] = 0x38 + dAtA[i] = 0x40 } if m.VotePeriod != 0 { i = encodeVarintTx(dAtA, i, uint64(m.VotePeriod)) i-- - dAtA[i] = 0x30 + dAtA[i] = 0x38 } if m.VoteQuorum != 0 { i = encodeVarintTx(dAtA, i, uint64(m.VoteQuorum)) i-- - dAtA[i] = 0x28 + dAtA[i] = 0x30 } if len(m.Rates) > 0 { for iNdEx := len(m.Rates) - 1; iNdEx >= 0; iNdEx-- { @@ -824,9 +833,14 @@ func (m *MsgCreateSpendingPool) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintTx(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x22 + dAtA[i] = 0x2a } } + if m.ClaimExpiry != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.ClaimExpiry)) + i-- + dAtA[i] = 0x20 + } if m.ClaimEnd != 0 { i = encodeVarintTx(dAtA, i, uint64(m.ClaimEnd)) i-- @@ -1091,6 +1105,9 @@ func (m *MsgCreateSpendingPool) Size() (n int) { if m.ClaimEnd != 0 { n += 1 + sovTx(uint64(m.ClaimEnd)) } + if m.ClaimExpiry != 0 { + n += 1 + sovTx(uint64(m.ClaimExpiry)) + } if len(m.Rates) > 0 { for _, e := range m.Rates { l = e.Size() @@ -1322,6 +1339,25 @@ func (m *MsgCreateSpendingPool) Unmarshal(dAtA []byte) error { } } case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ClaimExpiry", wireType) + } + m.ClaimExpiry = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ClaimExpiry |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Rates", wireType) } @@ -1357,7 +1393,7 @@ func (m *MsgCreateSpendingPool) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 5: + case 6: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field VoteQuorum", wireType) } @@ -1376,7 +1412,7 @@ func (m *MsgCreateSpendingPool) Unmarshal(dAtA []byte) error { break } } - case 6: + case 7: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field VotePeriod", wireType) } @@ -1395,7 +1431,7 @@ func (m *MsgCreateSpendingPool) Unmarshal(dAtA []byte) error { break } } - case 7: + case 8: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field VoteEnactment", wireType) } @@ -1414,7 +1450,7 @@ func (m *MsgCreateSpendingPool) Unmarshal(dAtA []byte) error { break } } - case 8: + case 9: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Owners", wireType) } @@ -1447,7 +1483,7 @@ func (m *MsgCreateSpendingPool) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 9: + case 10: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Beneficiaries", wireType) } @@ -1480,7 +1516,7 @@ func (m *MsgCreateSpendingPool) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 10: + case 11: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType) } @@ -1512,7 +1548,7 @@ func (m *MsgCreateSpendingPool) Unmarshal(dAtA []byte) error { } m.Sender = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 11: + case 12: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field DynamicRate", wireType) } @@ -1532,7 +1568,7 @@ func (m *MsgCreateSpendingPool) Unmarshal(dAtA []byte) error { } } m.DynamicRate = bool(v != 0) - case 12: + case 13: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field DynamicRatePeriod", wireType) } diff --git a/x/staking/keeper/keeper.go b/x/staking/keeper/keeper.go index 360f9231a..3f117712e 100644 --- a/x/staking/keeper/keeper.go +++ b/x/staking/keeper/keeper.go @@ -46,6 +46,12 @@ func (k Keeper) AddValidator(ctx sdk.Context, validator types.Validator) { k.AddValidatorByConsAddr(ctx, validator) } +func (k Keeper) RemoveValidator(ctx sdk.Context, validator types.Validator) { + store := ctx.KVStore(k.storeKey) + store.Delete(GetValidatorKey(validator.ValKey)) + k.RemoveValidatorByConsAddr(ctx, validator) +} + // validator index func (k Keeper) AddValidatorByConsAddr(ctx sdk.Context, validator types.Validator) { consPk := validator.GetConsAddr() @@ -54,6 +60,12 @@ func (k Keeper) AddValidatorByConsAddr(ctx sdk.Context, validator types.Validato store.Set(GetValidatorByConsAddrKey(consPk), validator.ValKey) } +func (k Keeper) RemoveValidatorByConsAddr(ctx sdk.Context, validator types.Validator) { + consPk := validator.GetConsAddr() + store := ctx.KVStore(k.storeKey) + store.Delete(GetValidatorByConsAddrKey(consPk)) +} + func (k Keeper) AddPendingValidator(ctx sdk.Context, validator types.Validator) { store := ctx.KVStore(k.storeKey) bz := k.cdc.MustMarshal(&validator) diff --git a/x/tokens/client/cli/tx.go b/x/tokens/client/cli/tx.go index 731740152..491db913d 100644 --- a/x/tokens/client/cli/tx.go +++ b/x/tokens/client/cli/tx.go @@ -31,6 +31,7 @@ const ( FlagTokens = "tokens" FlagTitle = "title" FlagDescription = "description" + FlagInvalidated = "invalidated" ) // NewTxCmd returns a root CLI command handler for all x/bank transaction commands. @@ -94,6 +95,11 @@ func GetTxUpsertTokenAliasCmd() *cobra.Command { } } + isInvalidated, err := cmd.Flags().GetBool(FlagInvalidated) + if err != nil { + return fmt.Errorf("invalid invalidated flag: %w", err) + } + msg := types.NewMsgUpsertTokenAlias( clientCtx.FromAddress, symbol, @@ -101,6 +107,7 @@ func GetTxUpsertTokenAliasCmd() *cobra.Command { icon, decimals, denoms, + isInvalidated, ) err = msg.ValidateBasic() @@ -117,6 +124,7 @@ func GetTxUpsertTokenAliasCmd() *cobra.Command { cmd.Flags().String(FlagIcon, "", "Graphical Symbol (url link to graphics)") cmd.Flags().Uint32(FlagDecimals, 6, "Integer number of max decimals") cmd.Flags().String(FlagDenoms, "ukex,mkex", "An array of token denoms to be aliased") + cmd.Flags().Bool(FlagInvalidated, false, "Flag to show token alias is invalidated or not") flags.AddTxFlagsToCmd(cmd) _ = cmd.MarkFlagRequired(flags.FlagFrom) @@ -157,6 +165,11 @@ func GetTxProposalUpsertTokenAliasCmd() *cobra.Command { return fmt.Errorf("invalid denoms: %w", err) } + isInvalidated, err := cmd.Flags().GetBool(FlagInvalidated) + if err != nil { + return fmt.Errorf("invalid invalidated flag: %w", err) + } + title, err := cmd.Flags().GetString(FlagTitle) if err != nil { return fmt.Errorf("invalid title: %w", err) @@ -177,6 +190,7 @@ func GetTxProposalUpsertTokenAliasCmd() *cobra.Command { icon, decimals, strings.Split(denoms, ","), + isInvalidated, ), ) if err != nil { @@ -197,6 +211,7 @@ func GetTxProposalUpsertTokenAliasCmd() *cobra.Command { cmd.MarkFlagRequired(FlagDecimals) cmd.Flags().String(FlagDenoms, "ukex,mkex", "An array of token denoms to be aliased") cmd.MarkFlagRequired(FlagDenoms) + cmd.Flags().Bool(FlagInvalidated, false, "Flag to show token alias is invalidated or not") cmd.Flags().String(FlagTitle, "", "The title of the proposal.") cmd.MarkFlagRequired(FlagTitle) @@ -275,6 +290,11 @@ func GetTxProposalUpsertTokenRatesCmd() *cobra.Command { return fmt.Errorf("invalid stake min: %s", stakeMinStr) } + isInvalidated, err := cmd.Flags().GetBool(FlagInvalidated) + if err != nil { + return fmt.Errorf("invalid invalidated flag: %w", err) + } + msg, err := govtypes.NewMsgSubmitProposal( clientCtx.FromAddress, title, @@ -286,6 +306,7 @@ func GetTxProposalUpsertTokenRatesCmd() *cobra.Command { stakeCap, stakeMin, stakeToken, + isInvalidated, ), ) if err != nil { @@ -314,6 +335,7 @@ func GetTxProposalUpsertTokenRatesCmd() *cobra.Command { cmd.Flags().String(FlagStakeCap, "0.1", "rewards to be allocated for the token.") cmd.Flags().String(FlagStakeMin, "1", "min amount to stake at a time.") cmd.Flags().Bool(FlagStakeToken, false, "flag of if staking token or not.") + cmd.Flags().Bool(FlagInvalidated, false, "Flag to show token rate is invalidated or not") flags.AddTxFlagsToCmd(cmd) _ = cmd.MarkFlagRequired(flags.FlagFrom) @@ -377,6 +399,11 @@ func GetTxUpsertTokenRateCmd() *cobra.Command { return fmt.Errorf("invalid stake min: %s", stakeMinStr) } + isInvalidated, err := cmd.Flags().GetBool(FlagInvalidated) + if err != nil { + return fmt.Errorf("invalid invalidated flag: %w", err) + } + msg := types.NewMsgUpsertTokenRate( clientCtx.FromAddress, denom, @@ -385,6 +412,7 @@ func GetTxUpsertTokenRateCmd() *cobra.Command { stakeCap, stakeMin, stakeToken, + isInvalidated, ) err = msg.ValidateBasic() @@ -405,6 +433,7 @@ func GetTxUpsertTokenRateCmd() *cobra.Command { cmd.Flags().String(FlagStakeCap, "0.1", "rewards to be allocated for the token.") cmd.Flags().String(FlagStakeMin, "1", "min amount to stake at a time.") cmd.Flags().Bool(FlagStakeToken, false, "flag of if staking token or not.") + cmd.Flags().Bool(FlagInvalidated, false, "Flag to show token rate is invalidated or not") flags.AddTxFlagsToCmd(cmd) _ = cmd.MarkFlagRequired(flags.FlagFrom) diff --git a/x/tokens/handler_test.go b/x/tokens/handler_test.go index 9a0addb07..b6e637b4c 100644 --- a/x/tokens/handler_test.go +++ b/x/tokens/handler_test.go @@ -73,6 +73,7 @@ func TestNewHandler_MsgUpsertTokenAlias(t *testing.T) { "icon", 6, []string{"finney"}, + false, ), nil }, }, @@ -86,6 +87,7 @@ func TestNewHandler_MsgUpsertTokenAlias(t *testing.T) { "icon", 6, []string{"finney"}, + false, ), nil }, handlerErr: "PERMISSION_UPSERT_TOKEN_ALIAS: not enough permissions", @@ -143,6 +145,7 @@ func TestNewHandler_MsgUpsertTokenRate(t *testing.T) { sdk.ZeroDec(), sdk.ZeroInt(), false, + false, ), nil }, }, @@ -156,6 +159,7 @@ func TestNewHandler_MsgUpsertTokenRate(t *testing.T) { sdk.ZeroDec(), sdk.ZeroInt(), false, + false, ), nil }, handlerErr: "PERMISSION_UPSERT_TOKEN_RATE: not enough permissions", @@ -170,6 +174,7 @@ func TestNewHandler_MsgUpsertTokenRate(t *testing.T) { sdk.ZeroDec(), sdk.ZeroInt(), false, + false, ), nil }, handlerErr: "rate should be positive", @@ -186,6 +191,7 @@ func TestNewHandler_MsgUpsertTokenRate(t *testing.T) { sdk.ZeroDec(), sdk.ZeroInt(), false, + false, ), nil }, handlerErr: "bond denom rate is read-only", @@ -232,6 +238,7 @@ func TestHandler_CreateProposalUpsertTokenAliases_Errors(t *testing.T) { "http://theicon.com", 18, []string{}, + false, ), func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) {}, errors.Wrap(types.ErrNotEnoughPermissions, types.PermCreateUpsertTokenAliasProposal.String()), @@ -282,6 +289,7 @@ func TestHandler_CreateProposalUpsertTokenAliases(t *testing.T) { []string{ "atom", }, + false, ) msg, err := govtypes.NewMsgSubmitProposal(proposerAddr, "title", "some desc", proposal) require.NoError(t, err) @@ -308,6 +316,7 @@ func TestHandler_CreateProposalUpsertTokenAliases(t *testing.T) { []string{ "atom", }, + false, ), ctx.BlockTime(), ctx.BlockTime().Add(time.Second*time.Duration(properties.MinimumProposalEndTime)), @@ -352,6 +361,7 @@ func TestHandler_CreateProposalUpsertTokenRates_Errors(t *testing.T) { sdk.ZeroDec(), sdk.ZeroInt(), false, + false, ), func(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context) {}, errors.Wrap(types.ErrNotEnoughPermissions, types.PermCreateUpsertTokenRateProposal.String()), @@ -401,6 +411,7 @@ func TestHandler_CreateProposalUpsertTokenRates(t *testing.T) { sdk.ZeroDec(), sdk.ZeroInt(), false, + false, ) msg, err := govtypes.NewMsgSubmitProposal(proposerAddr, "title", "some desc", proposal) require.NoError(t, err) @@ -426,6 +437,7 @@ func TestHandler_CreateProposalUpsertTokenRates(t *testing.T) { sdk.ZeroDec(), sdk.ZeroInt(), false, + false, ), ctx.BlockTime(), ctx.BlockTime().Add(time.Second*time.Duration(properties.MinimumProposalEndTime)), diff --git a/x/tokens/keeper/msg_server.go b/x/tokens/keeper/msg_server.go index e779f38af..2264a7486 100644 --- a/x/tokens/keeper/msg_server.go +++ b/x/tokens/keeper/msg_server.go @@ -46,6 +46,7 @@ func (k msgServer) UpsertTokenAlias( msg.Icon, msg.Decimals, msg.Denoms, + msg.Invalidated, )) ctx.EventManager().EmitEvent( sdk.NewEvent( @@ -81,6 +82,7 @@ func (k msgServer) UpsertTokenRate(goCtx context.Context, msg *types.MsgUpsertTo msg.StakeCap, msg.StakeMin, msg.StakeToken, + msg.Invalidated, )) if err != nil { diff --git a/x/tokens/proposal_handler.go b/x/tokens/proposal_handler.go index 5562f5739..196a8e82c 100644 --- a/x/tokens/proposal_handler.go +++ b/x/tokens/proposal_handler.go @@ -25,7 +25,7 @@ func (a ApplyUpsertTokenAliasProposalHandler) ProposalType() string { func (a ApplyUpsertTokenAliasProposalHandler) Apply(ctx sdk.Context, proposalID uint64, proposal types.Content, slash sdk.Dec) error { p := proposal.(*tokenstypes.ProposalUpsertTokenAlias) - tokenAlians := tokenstypes.NewTokenAlias(p.Symbol, p.Name, p.Icon, p.Decimals, p.Denoms) + tokenAlians := tokenstypes.NewTokenAlias(p.Symbol, p.Name, p.Icon, p.Decimals, p.Denoms, p.Invalidated) return a.keeper.UpsertTokenAlias(ctx, *tokenAlians) } @@ -44,7 +44,7 @@ func (a ApplyUpsertTokenRatesProposalHandler) ProposalType() string { func (a ApplyUpsertTokenRatesProposalHandler) Apply(ctx sdk.Context, proposalID uint64, proposal types.Content, slash sdk.Dec) error { p := proposal.(*tokenstypes.ProposalUpsertTokenRates) - tokenAlians := tokenstypes.NewTokenRate(p.Denom, p.Rate, p.FeePayments, p.StakeCap, p.StakeMin, p.StakeToken) + tokenAlians := tokenstypes.NewTokenRate(p.Denom, p.Rate, p.FeePayments, p.StakeCap, p.StakeMin, p.StakeToken, p.Invalidated) return a.keeper.UpsertTokenRate(ctx, *tokenAlians) } diff --git a/x/tokens/types/alias.pb.go b/x/tokens/types/alias.pb.go index b24d53a92..058633523 100644 --- a/x/tokens/types/alias.pb.go +++ b/x/tokens/types/alias.pb.go @@ -25,11 +25,12 @@ var _ = math.Inf const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type TokenAlias struct { - Symbol string `protobuf:"bytes,1,opt,name=symbol,proto3" json:"symbol,omitempty"` - Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` - Icon string `protobuf:"bytes,3,opt,name=icon,proto3" json:"icon,omitempty"` - Decimals uint32 `protobuf:"varint,4,opt,name=decimals,proto3" json:"decimals,omitempty"` - Denoms []string `protobuf:"bytes,5,rep,name=denoms,proto3" json:"denoms,omitempty"` + Symbol string `protobuf:"bytes,1,opt,name=symbol,proto3" json:"symbol,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + Icon string `protobuf:"bytes,3,opt,name=icon,proto3" json:"icon,omitempty"` + Decimals uint32 `protobuf:"varint,4,opt,name=decimals,proto3" json:"decimals,omitempty"` + Denoms []string `protobuf:"bytes,5,rep,name=denoms,proto3" json:"denoms,omitempty"` + Invalidated bool `protobuf:"varint,6,opt,name=invalidated,proto3" json:"invalidated,omitempty"` } func (m *TokenAlias) Reset() { *m = TokenAlias{} } @@ -100,13 +101,21 @@ func (m *TokenAlias) GetDenoms() []string { return nil } +func (m *TokenAlias) GetInvalidated() bool { + if m != nil { + return m.Invalidated + } + return false +} + type MsgUpsertTokenAlias struct { - Symbol string `protobuf:"bytes,1,opt,name=symbol,proto3" json:"symbol,omitempty"` - Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` - Icon string `protobuf:"bytes,3,opt,name=icon,proto3" json:"icon,omitempty"` - Decimals uint32 `protobuf:"varint,4,opt,name=decimals,proto3" json:"decimals,omitempty"` - Denoms []string `protobuf:"bytes,5,rep,name=denoms,proto3" json:"denoms,omitempty"` - Proposer github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,6,opt,name=proposer,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"proposer,omitempty" yaml:"proposer"` + Symbol string `protobuf:"bytes,1,opt,name=symbol,proto3" json:"symbol,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + Icon string `protobuf:"bytes,3,opt,name=icon,proto3" json:"icon,omitempty"` + Decimals uint32 `protobuf:"varint,4,opt,name=decimals,proto3" json:"decimals,omitempty"` + Denoms []string `protobuf:"bytes,5,rep,name=denoms,proto3" json:"denoms,omitempty"` + Invalidated bool `protobuf:"varint,6,opt,name=invalidated,proto3" json:"invalidated,omitempty"` + Proposer github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,7,opt,name=proposer,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"proposer,omitempty" yaml:"proposer"` } func (m *MsgUpsertTokenAlias) Reset() { *m = MsgUpsertTokenAlias{} } @@ -177,6 +186,13 @@ func (m *MsgUpsertTokenAlias) GetDenoms() []string { return nil } +func (m *MsgUpsertTokenAlias) GetInvalidated() bool { + if m != nil { + return m.Invalidated + } + return false +} + func (m *MsgUpsertTokenAlias) GetProposer() github_com_cosmos_cosmos_sdk_types.AccAddress { if m != nil { return m.Proposer @@ -192,27 +208,28 @@ func init() { func init() { proto.RegisterFile("kira/tokens/alias.proto", fileDescriptor_e5f7b26b3e48e5a6) } var fileDescriptor_e5f7b26b3e48e5a6 = []byte{ - // 309 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x91, 0xbf, 0x4e, 0xfb, 0x30, - 0x10, 0xc7, 0xeb, 0x5f, 0xfb, 0xab, 0x8a, 0x01, 0x21, 0x05, 0x04, 0x51, 0x07, 0x37, 0xca, 0x94, - 0xa5, 0xf1, 0xc0, 0xc6, 0xd6, 0xc2, 0x86, 0x58, 0x2a, 0x58, 0x98, 0x70, 0x1d, 0x2b, 0x58, 0x89, - 0x73, 0x91, 0x2f, 0x48, 0x74, 0xe3, 0x11, 0x78, 0x2c, 0xc6, 0x8e, 0x4c, 0x15, 0x6a, 0x46, 0x36, - 0x46, 0x26, 0xe4, 0xa4, 0xad, 0x78, 0x03, 0x26, 0x7f, 0xff, 0x9c, 0x3f, 0x3a, 0xe9, 0xe8, 0x59, - 0xa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xb5, 0x66, 0x9d, 0x65, 0xcd, 0x3a, 0xef, 0x35, 0xeb, 0xdc, - 0x47, 0xbf, 0x90, 0xd7, 0xda, 0x8a, 0x4b, 0xb0, 0x8a, 0xa3, 0xca, 0x84, 0xe6, 0xcf, 0xdb, 0xeb, - 0x36, 0xe0, 0x79, 0xbf, 0xb9, 0xdd, 0xf9, 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x02, 0x38, 0xf5, - 0x56, 0xf9, 0x01, 0x00, 0x00, + // 330 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x92, 0xbd, 0x4e, 0xeb, 0x30, + 0x14, 0xc7, 0xeb, 0xb6, 0xb7, 0xb7, 0xd7, 0xbd, 0x08, 0x29, 0x20, 0x88, 0x3a, 0xa4, 0x51, 0xa6, + 0x2c, 0x8d, 0x07, 0x36, 0xb6, 0x16, 0x36, 0xc4, 0x12, 0xc1, 0xc2, 0x84, 0x1b, 0x5b, 0xc1, 0x4a, + 0x9c, 0x13, 0xf9, 0x04, 0x44, 0x1f, 0x02, 0x89, 0x67, 0xe0, 0x69, 0x18, 0x3b, 0x32, 0x55, 0xa8, + 0x7d, 0x03, 0x46, 0x26, 0xe4, 0xa4, 0xad, 0xfa, 0x08, 0x4c, 0xfe, 0x7f, 0x1c, 0xff, 0x64, 0xc9, + 0x87, 0x9e, 0x66, 0xca, 0x70, 0x56, 0x41, 0x26, 0x0b, 0x64, 0x3c, 0x57, 0x1c, 0xa3, 0xd2, 0x40, + 0x05, 0xce, 0xc0, 0x16, 0x51, 0x53, 0x0c, 0x8f, 0x53, 0x48, 0xa1, 0xce, 0x99, 0x55, 0xcd, 0x48, + 0xf0, 0x46, 0x28, 0xbd, 0xb1, 0x03, 0x13, 0x7b, 0xcf, 0x39, 0xa1, 0x3d, 0x9c, 0xeb, 0x19, 0xe4, + 0x2e, 0xf1, 0x49, 0xf8, 0x2f,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xff, 0xec, 0x27, 0x00, 0x00, + 0xff, 0xff, 0x6f, 0x5b, 0xa6, 0x08, 0x3d, 0x02, 0x00, 0x00, } func (m *TokenAlias) Marshal() (dAtA []byte, err error) { @@ -235,6 +252,16 @@ func (m *TokenAlias) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.Invalidated { + i-- + if m.Invalidated { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x30 + } if len(m.Denoms) > 0 { for iNdEx := len(m.Denoms) - 1; iNdEx >= 0; iNdEx-- { i -= len(m.Denoms[iNdEx]) @@ -298,7 +325,17 @@ func (m *MsgUpsertTokenAlias) MarshalToSizedBuffer(dAtA []byte) (int, error) { copy(dAtA[i:], m.Proposer) i = encodeVarintAlias(dAtA, i, uint64(len(m.Proposer))) i-- - dAtA[i] = 0x32 + dAtA[i] = 0x3a + } + if m.Invalidated { + i-- + if m.Invalidated { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x30 } if len(m.Denoms) > 0 { for iNdEx := len(m.Denoms) - 1; iNdEx >= 0; iNdEx-- { @@ -376,6 +413,9 @@ func (m *TokenAlias) Size() (n int) { n += 1 + l + sovAlias(uint64(l)) } } + if m.Invalidated { + n += 2 + } return n } @@ -406,6 +446,9 @@ func (m *MsgUpsertTokenAlias) Size() (n int) { n += 1 + l + sovAlias(uint64(l)) } } + if m.Invalidated { + n += 2 + } l = len(m.Proposer) if l > 0 { n += 1 + l + sovAlias(uint64(l)) @@ -595,6 +638,26 @@ func (m *TokenAlias) Unmarshal(dAtA []byte) error { } m.Denoms = append(m.Denoms, string(dAtA[iNdEx:postIndex])) iNdEx = postIndex + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Invalidated", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAlias + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Invalidated = bool(v != 0) default: iNdEx = preIndex skippy, err := skipAlias(dAtA[iNdEx:]) @@ -793,6 +856,26 @@ func (m *MsgUpsertTokenAlias) Unmarshal(dAtA []byte) error { m.Denoms = append(m.Denoms, string(dAtA[iNdEx:postIndex])) iNdEx = postIndex case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Invalidated", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAlias + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Invalidated = bool(v != 0) + case 7: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Proposer", wireType) } diff --git a/x/tokens/types/genesis.go b/x/tokens/types/genesis.go index 674c726a6..dc56e1a7e 100644 --- a/x/tokens/types/genesis.go +++ b/x/tokens/types/genesis.go @@ -8,13 +8,13 @@ import ( func DefaultGenesis() *GenesisState { return &GenesisState{ Aliases: []*TokenAlias{ - NewTokenAlias("KEX", "Kira", "", 6, []string{"ukex", "mkex"}), + NewTokenAlias("KEX", "Kira", "", 6, []string{"ukex", "mkex"}, false), }, Rates: []*TokenRate{ - NewTokenRate("ukex", sdk.NewDec(1), true, sdk.NewDecWithPrec(50, 2), sdk.OneInt(), true), // 1 - NewTokenRate("ubtc", sdk.NewDec(10), true, sdk.NewDecWithPrec(25, 2), sdk.OneInt(), true), // 10 - NewTokenRate("xeth", sdk.NewDecWithPrec(1, 1), true, sdk.NewDecWithPrec(10, 2), sdk.OneInt(), false), // 0.1 - NewTokenRate("frozen", sdk.NewDecWithPrec(1, 1), true, sdk.ZeroDec(), sdk.OneInt(), false), // 0.1 + NewTokenRate("ukex", sdk.NewDec(1), true, sdk.NewDecWithPrec(50, 2), sdk.OneInt(), true, false), // 1 + NewTokenRate("ubtc", sdk.NewDec(10), true, sdk.NewDecWithPrec(25, 2), sdk.OneInt(), true, false), // 10 + NewTokenRate("xeth", sdk.NewDecWithPrec(1, 1), true, sdk.NewDecWithPrec(10, 2), sdk.OneInt(), false, false), // 0.1 + NewTokenRate("frozen", sdk.NewDecWithPrec(1, 1), true, sdk.ZeroDec(), sdk.OneInt(), false, false), // 0.1 }, TokenBlackWhites: &TokensWhiteBlack{ Whitelisted: []string{"ukex"}, diff --git a/x/tokens/types/msg_alias.go b/x/tokens/types/msg_alias.go index b618bc5c1..267f615f7 100644 --- a/x/tokens/types/msg_alias.go +++ b/x/tokens/types/msg_alias.go @@ -17,14 +17,16 @@ func NewMsgUpsertTokenAlias( icon string, decimals uint32, denoms []string, + invalidated bool, ) *MsgUpsertTokenAlias { return &MsgUpsertTokenAlias{ - Proposer: proposer, - Symbol: symbol, - Name: name, - Icon: icon, - Decimals: decimals, - Denoms: denoms, + Proposer: proposer, + Symbol: symbol, + Name: name, + Icon: icon, + Decimals: decimals, + Denoms: denoms, + Invalidated: invalidated, } } diff --git a/x/tokens/types/msg_rate.go b/x/tokens/types/msg_rate.go index fdafe40a5..cb43103c4 100644 --- a/x/tokens/types/msg_rate.go +++ b/x/tokens/types/msg_rate.go @@ -20,6 +20,7 @@ func NewMsgUpsertTokenRate( stakeCap sdk.Dec, stakeMin sdk.Int, stakeToken bool, + invalidated bool, ) *MsgUpsertTokenRate { return &MsgUpsertTokenRate{ Proposer: proposer, @@ -29,6 +30,7 @@ func NewMsgUpsertTokenRate( StakeCap: stakeCap, StakeMin: stakeMin, StakeToken: stakeToken, + Invalidated: invalidated, } } diff --git a/x/tokens/types/proposal.go b/x/tokens/types/proposal.go index 72d0b3ae0..82a7ebef6 100644 --- a/x/tokens/types/proposal.go +++ b/x/tokens/types/proposal.go @@ -20,13 +20,15 @@ func NewUpsertTokenAliasProposal( icon string, decimals uint32, denoms []string, + isInvalidated bool, ) *ProposalUpsertTokenAlias { return &ProposalUpsertTokenAlias{ - Symbol: symbol, - Name: name, - Icon: icon, - Decimals: decimals, - Denoms: denoms, + Symbol: symbol, + Name: name, + Icon: icon, + Decimals: decimals, + Denoms: denoms, + Invalidated: isInvalidated, } } @@ -54,6 +56,7 @@ func NewUpsertTokenRatesProposal( stakeCap sdk.Dec, stakeMin sdk.Int, stakeToken bool, + isInvalidated bool, ) *ProposalUpsertTokenRates { return &ProposalUpsertTokenRates{ Denom: denom, @@ -62,6 +65,7 @@ func NewUpsertTokenRatesProposal( StakeCap: stakeCap, StakeMin: stakeMin, StakeToken: stakeToken, + Invalidated: isInvalidated, } } diff --git a/x/tokens/types/proposal.pb.go b/x/tokens/types/proposal.pb.go index 575b83c09..9c60282e4 100644 --- a/x/tokens/types/proposal.pb.go +++ b/x/tokens/types/proposal.pb.go @@ -26,11 +26,12 @@ var _ = math.Inf const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type ProposalUpsertTokenAlias struct { - Symbol string `protobuf:"bytes,1,opt,name=symbol,proto3" json:"symbol,omitempty"` - Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` - Icon string `protobuf:"bytes,3,opt,name=icon,proto3" json:"icon,omitempty"` - Decimals uint32 `protobuf:"varint,4,opt,name=decimals,proto3" json:"decimals,omitempty"` - Denoms []string `protobuf:"bytes,5,rep,name=denoms,proto3" json:"denoms,omitempty"` + Symbol string `protobuf:"bytes,1,opt,name=symbol,proto3" json:"symbol,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + Icon string `protobuf:"bytes,3,opt,name=icon,proto3" json:"icon,omitempty"` + Decimals uint32 `protobuf:"varint,4,opt,name=decimals,proto3" json:"decimals,omitempty"` + Denoms []string `protobuf:"bytes,5,rep,name=denoms,proto3" json:"denoms,omitempty"` + Invalidated bool `protobuf:"varint,6,opt,name=invalidated,proto3" json:"invalidated,omitempty"` } func (m *ProposalUpsertTokenAlias) Reset() { *m = ProposalUpsertTokenAlias{} } @@ -101,6 +102,13 @@ func (m *ProposalUpsertTokenAlias) GetDenoms() []string { return nil } +func (m *ProposalUpsertTokenAlias) GetInvalidated() bool { + if m != nil { + return m.Invalidated + } + return false +} + type ProposalUpsertTokenRates struct { Denom string `protobuf:"bytes,1,opt,name=denom,proto3" json:"denom,omitempty"` Rate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=rate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"rate" yaml:"rate"` @@ -108,6 +116,7 @@ type ProposalUpsertTokenRates struct { StakeCap github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,4,opt,name=stake_cap,json=stakeCap,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"stake_cap" yaml:"stake_cap"` StakeMin github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,5,opt,name=stake_min,json=stakeMin,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"stake_min" yaml:"stake_min"` StakeToken bool `protobuf:"varint,6,opt,name=stake_token,json=stakeToken,proto3" json:"stake_token,omitempty"` + Invalidated bool `protobuf:"varint,7,opt,name=invalidated,proto3" json:"invalidated,omitempty"` } func (m *ProposalUpsertTokenRates) Reset() { *m = ProposalUpsertTokenRates{} } @@ -164,6 +173,13 @@ func (m *ProposalUpsertTokenRates) GetStakeToken() bool { return false } +func (m *ProposalUpsertTokenRates) GetInvalidated() bool { + if m != nil { + return m.Invalidated + } + return false +} + func init() { proto.RegisterType((*ProposalUpsertTokenAlias)(nil), "kira.tokens.ProposalUpsertTokenAlias") proto.RegisterType((*ProposalUpsertTokenRates)(nil), "kira.tokens.ProposalUpsertTokenRates") @@ -172,35 +188,36 @@ func init() { func init() { proto.RegisterFile("kira/tokens/proposal.proto", fileDescriptor_68008d794328e180) } var fileDescriptor_68008d794328e180 = []byte{ - // 436 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x52, 0x3d, 0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 0xbb, 0x08, 0x5d, 0xec, 0x22, 0xf4, 0x63, - 0x17, 0xa1, 0x0f, 0xfb, 0xa8, 0x73, 0xb1, 0x8f, 0x3a, 0xdf, 0xf6, 0x51, 0xe7, 0xcd, 0xec, 0xaf, - 0x44, 0xcf, 0x79, 0xcd, 0x16, 0xaa, 0x86, 0xd4, 0x40, 0xc9, 0x78, 0xfa, 0xfe, 0xf2, 0x92, 0x7d, - 0xae, 0xd5, 0xc0, 0x5f, 0xe2, 0xa3, 0xdf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x0f, 0x73, 0x30, 0xa7, - 0xe5, 0x02, 0x00, 0x00, + // 460 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x53, 0xbf, 0x8f, 0xd3, 0x30, + 0x14, 0xae, 0xe9, 0x8f, 0x6b, 0x1d, 0x10, 0xc8, 0x3a, 0xa1, 0xd0, 0x21, 0x09, 0x19, 0x50, 0x97, + 0x6b, 0x06, 0xb6, 0x93, 0x18, 0x48, 0x59, 0x10, 0x42, 0x3a, 0x22, 0x58, 0x58, 0x2a, 0x37, 0x79, + 0x57, 0xac, 0xc4, 0x76, 0x14, 0x1b, 0x44, 0xfe, 0x0b, 0xfe, 0x04, 0xfe, 0x08, 0x46, 0x16, 0xb6, + 0x1b, 0x4f, 0x4c, 0x88, 0xa1, 0x42, 0xed, 0xc2, 0xcc, 0x5f, 0x80, 0x62, 0xfb, 0x8e, 0xd3, 0x09, + 0xe9, 0xd4, 0x29, 0xef, 0xfb, 0x5e, 0xf4, 0x7d, 0x7e, 0xdf, 0xb3, 0xf1, 0xb4, 0x64, 0x0d, 0x4d, + 0xb4, 0x2c, 0x41, 0xa8, 0xa4, 0x6e, 0x64, 0x2d, 0x15, 0xad, 0xe6, 0x75, 0x23, 0xb5, 0x24, 0x5e, + 0xd7, 0x9b, 0xdb, 0xde, 0xf4, 0x70, 0x2d, 0xd7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xff, 0xd9, 0x84, + 0x5e, 0x4b, 0x79, 0x75, 0x1c, 0x77, 0x1a, 0x71, 0x66, 0xa4, 0xc8, 0x43, 0x7c, 0xfb, 0x14, 0x60, + 0x59, 0xd3, 0x96, 0x83, 0xd0, 0xca, 0x04, 0x31, 0xce, 0xbc, 0x53, 0x80, 0x13, 0x47, 0x91, 0x25, + 0x9e, 0x28, 0x4d, 0x4b, 0x58, 0xe6, 0xb4, 0x36, 0x81, 0x4c, 0xd2, 0x74, 0x6f, 0xeb, 0x7b, 0xd6, + 0xfa, 0x52, 0x28, 0xce, 0xc6, 0xa6, 0x5e, 0xd0, 0xfa, 0x9f, 0x01, 0x67, 0xc2, 0x1f, 0xee, 0x6d, + 0xf0, 0x5c, 0xe8, 0xeb, 0x06, 0x9c, 0x89, 0x0b, 0x83, 0x97, 0x4c, 0x90, 0x10, 0x7b, 0x96, 0x37, + 0xf7, 0xcd, 0x6d, 0x07, 0x1b, 0xca, 0x64, 0x7e, 0x7d, 0x7d, 0x07, 0x37, 0xaf, 0x2f, 0x4d, 0xcf, + 0xb6, 0x01, 0x3a, 0xdf, 0x06, 0xe8, 0xd7, 0x36, 0x40, 0x9f, 0x76, 0x41, 0xef, 0x7c, 0x17, 0xf4, + 0x7e, 0xec, 0x82, 0xde, 0xdb, 0xd9, 0x95, 0x33, 0xbf, 0x60, 0x0d, 0x5d, 0xc8, 0x06, 0x12, 0x05, + 0x25, 0x65, 0xc9, 0xc7, 0x8b, 0xd7, 0x60, 0x4e, 0xbe, 0x1a, 0x99, 0xdb, 0xfc, 0xf8, 0x6f, 0x00, + 0x00, 0x00, 0xff, 0xff, 0x1a, 0x32, 0x11, 0xd8, 0x29, 0x03, 0x00, 0x00, } func (this *ProposalUpsertTokenAlias) Equal(that interface{}) bool { @@ -242,6 +259,9 @@ func (this *ProposalUpsertTokenAlias) Equal(that interface{}) bool { return false } } + if this.Invalidated != that1.Invalidated { + return false + } return true } func (this *ProposalUpsertTokenRates) Equal(that interface{}) bool { @@ -281,6 +301,9 @@ func (this *ProposalUpsertTokenRates) Equal(that interface{}) bool { if this.StakeToken != that1.StakeToken { return false } + if this.Invalidated != that1.Invalidated { + return false + } return true } func (m *ProposalUpsertTokenAlias) Marshal() (dAtA []byte, err error) { @@ -303,6 +326,16 @@ func (m *ProposalUpsertTokenAlias) MarshalToSizedBuffer(dAtA []byte) (int, error _ = i var l int _ = l + if m.Invalidated { + i-- + if m.Invalidated { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x30 + } if len(m.Denoms) > 0 { for iNdEx := len(m.Denoms) - 1; iNdEx >= 0; iNdEx-- { i -= len(m.Denoms[iNdEx]) @@ -361,6 +394,16 @@ func (m *ProposalUpsertTokenRates) MarshalToSizedBuffer(dAtA []byte) (int, error _ = i var l int _ = l + if m.Invalidated { + i-- + if m.Invalidated { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x38 + } if m.StakeToken { i-- if m.StakeToken { @@ -459,6 +502,9 @@ func (m *ProposalUpsertTokenAlias) Size() (n int) { n += 1 + l + sovProposal(uint64(l)) } } + if m.Invalidated { + n += 2 + } return n } @@ -484,6 +530,9 @@ func (m *ProposalUpsertTokenRates) Size() (n int) { if m.StakeToken { n += 2 } + if m.Invalidated { + n += 2 + } return n } @@ -669,6 +718,26 @@ func (m *ProposalUpsertTokenAlias) Unmarshal(dAtA []byte) error { } m.Denoms = append(m.Denoms, string(dAtA[iNdEx:postIndex])) iNdEx = postIndex + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Invalidated", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProposal + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Invalidated = bool(v != 0) default: iNdEx = preIndex skippy, err := skipProposal(dAtA[iNdEx:]) @@ -893,6 +962,26 @@ func (m *ProposalUpsertTokenRates) Unmarshal(dAtA []byte) error { } } m.StakeToken = bool(v != 0) + case 7: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Invalidated", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProposal + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Invalidated = bool(v != 0) default: iNdEx = preIndex skippy, err := skipProposal(dAtA[iNdEx:]) diff --git a/x/tokens/types/rate.pb.go b/x/tokens/types/rate.pb.go index 5f5811324..4bda61ead 100644 --- a/x/tokens/types/rate.pb.go +++ b/x/tokens/types/rate.pb.go @@ -31,6 +31,7 @@ type TokenRate struct { StakeCap github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,4,opt,name=stake_cap,json=stakeCap,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"stake_cap" yaml:"stake_cap"` StakeMin github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,5,opt,name=stake_min,json=stakeMin,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"stake_min" yaml:"stake_min"` StakeToken bool `protobuf:"varint,6,opt,name=stake_token,json=stakeToken,proto3" json:"stake_token,omitempty"` + Invalidated bool `protobuf:"varint,7,opt,name=invalidated,proto3" json:"invalidated,omitempty"` } func (m *TokenRate) Reset() { *m = TokenRate{} } @@ -87,6 +88,13 @@ func (m *TokenRate) GetStakeToken() bool { return false } +func (m *TokenRate) GetInvalidated() bool { + if m != nil { + return m.Invalidated + } + return false +} + type MsgUpsertTokenRate struct { Denom string `protobuf:"bytes,1,opt,name=denom,proto3" json:"denom,omitempty"` Rate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=rate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"rate" yaml:"rate"` @@ -94,7 +102,8 @@ type MsgUpsertTokenRate struct { StakeCap github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,4,opt,name=stake_cap,json=stakeCap,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"stake_cap" yaml:"stake_cap"` StakeMin github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,5,opt,name=stake_min,json=stakeMin,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"stake_min" yaml:"stake_min"` StakeToken bool `protobuf:"varint,6,opt,name=stake_token,json=stakeToken,proto3" json:"stake_token,omitempty"` - Proposer github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,7,opt,name=proposer,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"proposer,omitempty" yaml:"proposer"` + Invalidated bool `protobuf:"varint,7,opt,name=invalidated,proto3" json:"invalidated,omitempty"` + Proposer github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,8,opt,name=proposer,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"proposer,omitempty" yaml:"proposer"` } func (m *MsgUpsertTokenRate) Reset() { *m = MsgUpsertTokenRate{} } @@ -151,6 +160,13 @@ func (m *MsgUpsertTokenRate) GetStakeToken() bool { return false } +func (m *MsgUpsertTokenRate) GetInvalidated() bool { + if m != nil { + return m.Invalidated + } + return false +} + func (m *MsgUpsertTokenRate) GetProposer() github_com_cosmos_cosmos_sdk_types.AccAddress { if m != nil { return m.Proposer @@ -166,33 +182,34 @@ func init() { func init() { proto.RegisterFile("kira/tokens/rate.proto", fileDescriptor_d415c64b17c96dda) } var fileDescriptor_d415c64b17c96dda = []byte{ - // 410 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x93, 0x4f, 0x8b, 0x9b, 0x40, - 0x18, 0xc6, 0xb5, 0xf9, 0x67, 0xc6, 0x40, 0x8b, 0x84, 0x22, 0x3d, 0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x39, 0xba, 0xaf, 0x6f, 0x03, 0x00, 0x00, - 0xff, 0xff, 0xcf, 0x5b, 0xaa, 0x8d, 0xf7, 0x03, 0x00, 0x00, + // 430 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x94, 0xb1, 0x6e, 0xd4, 0x30, + 0x18, 0xc7, 0x2f, 0xf4, 0xda, 0xe6, 0x9c, 0x4a, 0x20, 0xab, 0x42, 0x16, 0x43, 0x72, 0x64, 0x40, + 0x59, 0x9a, 0x0c, 0x6c, 0x48, 0x0c, 0x97, 0x76, 0x41, 0xa8, 0x12, 0x44, 0xb0, 0x20, 0xa4, 0xc3, + 0x4d, 0xbe, 0x0b, 0x56, 0x1a, 0xdb, 0xb2, 0x0d, 0xe2, 0x9e, 0x80, 0x95, 0xb7, 0xe0, 0x55, 0x3a, + 0x76, 0x44, 0x0c, 0x11, 0xba, 0x7b, 0x03, 0x46, 0x26, 0x14, 0xbb, 0x69, 0x4f, 0x2c, 0xf4, 0xf6, + 0x4e, 0x71, 0x7e, 0xb6, 0xfe, 0xff, 0xef, 0xfb, 0xfe, 0x89, 0xd1, 0xc3, 0x86, 0x29, 0x9a, 0x19, + 0xd1, 0x00, 0xd7, 0x99, 0xa2, 0x06, 0x52, 0xa9, 0x84, 0x11, 0x38, 0xe8, 0x79, 0xea, 0xf8, 0xa3, + 0xc3, 0x5a, 0xd4, 0xc2, 0xf2, 0xac, 0x5f, 0xb9, 0x23, 0xf1, 0xf7, 0x1d, 0x34, 0x79, 0xd3, 0x1f, + 0x28, 0xa8, 0x01, 0x7c, 0x88, 0x76, 0x2b, 0xe0, 0xa2, 0x25, 0xde, 0xd4, 0x4b, 0x26, 0x85, 0x7b, + 0xc1, 0xef, 0x91, 0xbf, 0x00, 0x98, 0xf7, 0xc2, 0xe4, 0x5e, 0xbf, 0x91, 0xcf, 0x2e, 0xba, 0x68, + 0xf4, 0xb3, 0x8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f, 0xf5, 0x92, 0x83, 0xfc, 0xe4, 0xe6, 0xfb, 0x1f, 0x76, + 0xe2, 0x3f, 0x5d, 0x74, 0x74, 0x8b, 0x8a, 0x67, 0x65, 0x39, 0xab, 0x2a, 0x05, 0x5a, 0x17, 0xd7, + 0xaa, 0x79, 0x7e, 0xb1, 0x0a, 0xbd, 0xcb, 0x55, 0xe8, 0xfd, 0x5a, 0x85, 0xde, 0xb7, 0x75, 0x38, + 0xba, 0x5c, 0x87, 0xa3, 0x1f, 0xeb, 0x70, 0xf4, 0x2e, 0xd9, 0x90, 0x7c, 0xc9, 0x14, 0x3d, 0x16, + 0x0a, 0x32, 0x0d, 0x0d, 0x65, 0xd9, 0x97, 0xe1, 0x7e, 0xb0, 0xc2, 0x67, 0x7b, 0xf6, 0xf7, 0x7f, + 0xfa, 0x37, 0x00, 0x00, 0xff, 0xff, 0xf6, 0xd1, 0xe1, 0x89, 0x3b, 0x04, 0x00, 0x00, } func (m *TokenRate) Marshal() (dAtA []byte, err error) { @@ -215,6 +232,16 @@ func (m *TokenRate) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.Invalidated { + i-- + if m.Invalidated { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x38 + } if m.StakeToken { i-- if m.StakeToken { @@ -300,7 +327,17 @@ func (m *MsgUpsertTokenRate) MarshalToSizedBuffer(dAtA []byte) (int, error) { copy(dAtA[i:], m.Proposer) i = encodeVarintRate(dAtA, i, uint64(len(m.Proposer))) i-- - dAtA[i] = 0x3a + dAtA[i] = 0x42 + } + if m.Invalidated { + i-- + if m.Invalidated { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x38 } if m.StakeToken { i-- @@ -395,6 +432,9 @@ func (m *TokenRate) Size() (n int) { if m.StakeToken { n += 2 } + if m.Invalidated { + n += 2 + } return n } @@ -420,6 +460,9 @@ func (m *MsgUpsertTokenRate) Size() (n int) { if m.StakeToken { n += 2 } + if m.Invalidated { + n += 2 + } l = len(m.Proposer) if l > 0 { n += 1 + l + sovRate(uint64(l)) @@ -636,6 +679,26 @@ func (m *TokenRate) Unmarshal(dAtA []byte) error { } } m.StakeToken = bool(v != 0) + case 7: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Invalidated", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRate + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Invalidated = bool(v != 0) default: iNdEx = preIndex skippy, err := skipRate(dAtA[iNdEx:]) @@ -861,6 +924,26 @@ func (m *MsgUpsertTokenRate) Unmarshal(dAtA []byte) error { } m.StakeToken = bool(v != 0) case 7: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Invalidated", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRate + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Invalidated = bool(v != 0) + case 8: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Proposer", wireType) } diff --git a/x/tokens/types/types.go b/x/tokens/types/types.go index 14e53f689..299b31e5a 100644 --- a/x/tokens/types/types.go +++ b/x/tokens/types/types.go @@ -11,13 +11,15 @@ func NewTokenAlias( icon string, decimals uint32, denoms []string, + invalidated bool, ) *TokenAlias { return &TokenAlias{ - Symbol: symbol, - Name: name, - Icon: icon, - Decimals: decimals, - Denoms: denoms, + Symbol: symbol, + Name: name, + Icon: icon, + Decimals: decimals, + Denoms: denoms, + Invalidated: invalidated, } } @@ -29,6 +31,7 @@ func NewTokenRate( stakeCap sdk.Dec, stakeMin sdk.Int, stakeToken bool, + invalidated bool, ) *TokenRate { return &TokenRate{ Denom: denom, @@ -37,5 +40,6 @@ func NewTokenRate( StakeCap: stakeCap, StakeMin: stakeMin, StakeToken: stakeToken, + Invalidated: invalidated, } } diff --git a/x/ubi/keeper/keeper.go b/x/ubi/keeper/keeper.go index 839ea645e..4f9954d32 100644 --- a/x/ubi/keeper/keeper.go +++ b/x/ubi/keeper/keeper.go @@ -12,15 +12,17 @@ type Keeper struct { storeKey sdk.StoreKey bk types.BankKeeper sk types.SpendingKeeper + dk types.DistrKeeper } // NewKeeper returns instance of a keeper -func NewKeeper(storeKey sdk.StoreKey, cdc codec.BinaryCodec, bk types.BankKeeper, sk types.SpendingKeeper) Keeper { +func NewKeeper(storeKey sdk.StoreKey, cdc codec.BinaryCodec, bk types.BankKeeper, sk types.SpendingKeeper, dk types.DistrKeeper) Keeper { return Keeper{ cdc: cdc, storeKey: storeKey, bk: bk, sk: sk, + dk: dk, } } diff --git a/x/ubi/keeper/ubi.go b/x/ubi/keeper/ubi.go index f90653c5d..5a1d62d4d 100644 --- a/x/ubi/keeper/ubi.go +++ b/x/ubi/keeper/ubi.go @@ -61,6 +61,9 @@ func (k Keeper) DeleteUBIRecord(ctx sdk.Context, name string) error { } func (k Keeper) ProcessUBIRecord(ctx sdk.Context, record types.UBIRecord) error { + if !k.dk.InflationPossible(ctx) { + return nil + } currUnixTimestamp := uint64(ctx.BlockTime().Unix()) record.DistributionLast = currUnixTimestamp k.SetUBIRecord(ctx, record) diff --git a/x/ubi/types/expected_keepers.go b/x/ubi/types/expected_keepers.go index abdc24001..33fd3edb7 100644 --- a/x/ubi/types/expected_keepers.go +++ b/x/ubi/types/expected_keepers.go @@ -26,3 +26,7 @@ type SpendingKeeper interface { GetSpendingPool(ctx sdk.Context, name string) *spendingtypes.SpendingPool DepositSpendingPoolFromModule(ctx sdk.Context, moduleName, poolName string, amounts sdk.Coins) error } + +type DistrKeeper interface { + InflationPossible(ctx sdk.Context) bool +}