From 1245e699db0ccbd5488ed1396d1339b51b763cdb Mon Sep 17 00:00:00 2001 From: kenta-elys <130330089+kenta-elys@users.noreply.github.com> Date: Tue, 9 May 2023 16:52:01 +0200 Subject: [PATCH] Feat/incentive gas distribute (#72) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * add: scaffold incentive * add: declare incentive params -LP &Stake * add: implement hook interface functions in incentive module * add: implement staking hook interface functions in incentive module * add: add commitmentKeeper as incentive newkeeper param, declare keeper functions for staking hooks * add: calls appropriate keeper functions ffrom hook functions * fix: add one more param in calling newkeeper of testutil-incentive.go * fix: remove exception handling for checking block height in hook functions in order to be succeed in unit test * feat: add commitment hook and integrated into incentive module * feat: calculated eden & eden boost uncomitted token amount * fix: add parms config for incentive module * fix: refactoring proto define of incentive param * fix: remove wrongly merged code - double incentive keeper initiate * fix: rebuild protobuf * fix: correct data type of incentive params in config.yml and add an exception handling in staking hook ignore 0 block height * Commitment Module Denom Checks (#55) * check denom for commit enabled * commitEnabled config * withdraw check * eden-boost assetprofile entry * fix assetprofile enty decimals * fix: addcurrent epoch in incentive param and refactoring code baseaccording to the comments * fix: update getproperincentive param function and handle current epoch number * fix: add eden boost APR and use it in eden boost calculation * fix: change function to calculate delegation amount per delegator * feat: add a map to record elys staker and delegators * feat: add a data map to record elys standard staking * feat: calculate commission to validator and give it * feat: update the corresponding commistment to give each validator commissions * fix: get rid of manual map for recording elys stake info in incentive module * fix: get rid of manual map to record elys stake, currently havng issue with loading params * feat: add protos from distribution module * feat: add query for getting validator outstanding rewards * feat: add query validator commission * feat: add query for getting validator slashes * feat: add query for getting delegation rewards * feat: dd delegation total rewards * feat: add a query for getting validators of a delegator * feat: add community pool query * feat: add query for getting delegator withdraw address * feat: add a tx to set withdraw address in incentive module * feat: add a tx to withdaraw validator commission * feat: add a tx for withdrawing delegator reward * feat: finished toten allocation * feat: finish implementation of queryies and txs * feat: handle staking hook * feat: add place holder for converting Elys to USDC * fix: remove referene to standard distribution module and fix export.go with distribution keeper * feat: fix genesis paraams of incentive module in config.yml * fix: update initi genesis and export genesis functions * fix: fix issue with incentive module genesis initialization and unit testing * fix: update incentive param initialization to fix unit testing issue * fix: 🐛 duplicate maccperms --------- Co-authored-by: Austin Haines Co-authored-by: Cosmic Vagabond <121588426+cosmic-vagabond@users.noreply.github.com> --- app/app.go | 41 +- app/export.go | 20 +- config.yml | 6 + docs/static/openapi.yml | 817 +++++ go.mod | 2 +- proto/elys/incentive/distribution.proto | 137 + proto/elys/incentive/genesis.proto | 133 +- proto/elys/incentive/incentive.proto | 8 +- proto/elys/incentive/params.proto | 11 +- proto/elys/incentive/query.proto | 165 +- proto/elys/incentive/tx.proto | 38 +- testutil/keeper/incentive.go | 3 + x/commitment/keeper/keeper.go | 62 +- x/commitment/types/events.go | 2 +- x/incentive/abci.go | 38 + x/incentive/client/cli/queries.go | 307 ++ x/incentive/client/cli/query.go | 8 + x/incentive/client/cli/query_params.go | 34 - x/incentive/client/cli/tx.go | 3 + x/incentive/client/cli/txs.go | 98 + x/incentive/genesis.go | 23 - x/incentive/genesis_test.go | 29 - x/incentive/keeper/alias_functions.go | 22 + x/incentive/keeper/allocation.go | 145 + x/incentive/keeper/delegation.go | 213 ++ x/incentive/keeper/fee_pool.go | 30 + x/incentive/keeper/genesis.go | 186 ++ x/incentive/keeper/hooks_staking.go | 69 +- x/incentive/keeper/keeper.go | 193 +- x/incentive/keeper/msg_servers.go | 110 + x/incentive/keeper/params.go | 17 +- x/incentive/keeper/queries.go | 238 ++ x/incentive/keeper/query_params.go | 19 - x/incentive/keeper/store.go | 385 +++ x/incentive/keeper/validator.go | 107 + x/incentive/module.go | 5 +- x/incentive/module_simulation.go | 35 +- x/incentive/types/codec.go | 14 +- x/incentive/types/delegator.go | 14 + x/incentive/types/distribution.pb.go | 3025 +++++++++++++++++++ x/incentive/types/errors.go | 13 +- x/incentive/types/events.go | 16 + x/incentive/types/expected_keepers.go | 32 +- x/incentive/types/feel_pool.go | 24 + x/incentive/types/genesis.go | 38 +- x/incentive/types/genesis.pb.go | 2355 ++++++++++++++- x/incentive/types/genesis_test.go | 8 - x/incentive/types/incentive.pb.go | 62 +- x/incentive/types/keys.go | 201 ++ x/incentive/types/messages.go | 125 + x/incentive/types/messages_test.go | 102 + x/incentive/types/params.go | 60 +- x/incentive/types/params.pb.go | 123 +- x/incentive/types/query.go | 39 + x/incentive/types/query.pb.go | 3648 ++++++++++++++++++++++- x/incentive/types/query.pb.gw.go | 818 ++++- x/incentive/types/tx.pb.go | 1365 ++++++++- x/incentive/types/validator.go | 48 + 58 files changed, 15400 insertions(+), 489 deletions(-) create mode 100644 proto/elys/incentive/distribution.proto create mode 100644 x/incentive/abci.go create mode 100644 x/incentive/client/cli/queries.go delete mode 100644 x/incentive/client/cli/query_params.go create mode 100644 x/incentive/client/cli/txs.go delete mode 100644 x/incentive/genesis.go delete mode 100644 x/incentive/genesis_test.go create mode 100644 x/incentive/keeper/alias_functions.go create mode 100644 x/incentive/keeper/allocation.go create mode 100644 x/incentive/keeper/delegation.go create mode 100644 x/incentive/keeper/fee_pool.go create mode 100644 x/incentive/keeper/genesis.go create mode 100644 x/incentive/keeper/msg_servers.go create mode 100644 x/incentive/keeper/queries.go delete mode 100644 x/incentive/keeper/query_params.go create mode 100644 x/incentive/keeper/store.go create mode 100644 x/incentive/keeper/validator.go create mode 100644 x/incentive/types/delegator.go create mode 100644 x/incentive/types/distribution.pb.go create mode 100644 x/incentive/types/events.go create mode 100644 x/incentive/types/feel_pool.go create mode 100644 x/incentive/types/messages.go create mode 100644 x/incentive/types/messages_test.go create mode 100644 x/incentive/types/query.go create mode 100644 x/incentive/types/validator.go diff --git a/app/app.go b/app/app.go index 2318a59e9..3ce8635ec 100644 --- a/app/app.go +++ b/app/app.go @@ -40,10 +40,6 @@ import ( "github.com/cosmos/cosmos-sdk/x/crisis" crisiskeeper "github.com/cosmos/cosmos-sdk/x/crisis/keeper" crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types" - distr "github.com/cosmos/cosmos-sdk/x/distribution" - distrclient "github.com/cosmos/cosmos-sdk/x/distribution/client" - distrkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper" - distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" "github.com/cosmos/cosmos-sdk/x/evidence" evidencekeeper "github.com/cosmos/cosmos-sdk/x/evidence/keeper" evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types" @@ -151,7 +147,7 @@ func getGovProposalHandlers() []govclient.ProposalHandler { govProposalHandlers = append(govProposalHandlers, paramsclient.ProposalHandler, - distrclient.ProposalHandler, + // distrclient.ProposalHandler, upgradeclient.LegacyProposalHandler, upgradeclient.LegacyCancelProposalHandler, ibcclientclient.UpdateClientProposalHandler, @@ -177,7 +173,6 @@ var ( capability.AppModuleBasic{}, staking.AppModuleBasic{}, mint.AppModuleBasic{}, - distr.AppModuleBasic{}, gov.NewAppModuleBasic(getGovProposalHandlers()), params.AppModuleBasic{}, crisis.AppModuleBasic{}, @@ -204,7 +199,6 @@ var ( // module account permissions maccPerms = map[string][]string{ authtypes.FeeCollectorName: nil, - distrtypes.ModuleName: nil, icatypes.ModuleName: nil, minttypes.ModuleName: {authtypes.Minter}, stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking}, @@ -212,8 +206,8 @@ var ( govtypes.ModuleName: {authtypes.Burner}, ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner}, commitmentmoduletypes.ModuleName: {authtypes.Minter, authtypes.Burner}, - incentivemoduletypes.ModuleName: {authtypes.Minter, authtypes.Burner}, burnermoduletypes.ModuleName: {authtypes.Burner}, + incentivemoduletypes.ModuleName: nil, // this line is used by starport scaffolding # stargate/app/maccPerms } ) @@ -257,7 +251,6 @@ type ElysApp struct { StakingKeeper stakingkeeper.Keeper SlashingKeeper slashingkeeper.Keeper MintKeeper mintkeeper.Keeper - DistrKeeper distrkeeper.Keeper GovKeeper govkeeper.Keeper CrisisKeeper crisiskeeper.Keeper UpgradeKeeper upgradekeeper.Keeper @@ -329,7 +322,7 @@ func NewElysApp( keys := sdk.NewKVStoreKeys( authtypes.StoreKey, authz.ModuleName, banktypes.StoreKey, stakingtypes.StoreKey, - minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey, govtypes.StoreKey, + minttypes.StoreKey, slashingtypes.StoreKey, govtypes.StoreKey, paramstypes.StoreKey, ibchost.StoreKey, upgradetypes.StoreKey, feegrant.StoreKey, evidencetypes.StoreKey, ibctransfertypes.StoreKey, icahosttypes.StoreKey, capabilitytypes.StoreKey, group.StoreKey, icacontrollertypes.StoreKey, @@ -424,16 +417,6 @@ func NewElysApp( authtypes.FeeCollectorName, ) - app.DistrKeeper = distrkeeper.NewKeeper( - appCodec, - keys[distrtypes.StoreKey], - app.GetSubspace(distrtypes.ModuleName), - app.AccountKeeper, - app.BankKeeper, - &app.StakingKeeper, - authtypes.FeeCollectorName, - ) - app.SlashingKeeper = slashingkeeper.NewKeeper( appCodec, keys[slashingtypes.StoreKey], @@ -551,7 +534,7 @@ func NewElysApp( govRouter. AddRoute(govtypes.RouterKey, govv1beta1.ProposalHandler). AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.ParamsKeeper)). - AddRoute(distrtypes.RouterKey, distr.NewCommunityPoolSpendProposalHandler(app.DistrKeeper)). + // AddRoute(distrtypes.RouterKey, distr.NewCommunityPoolSpendProposalHandler(app.DistrKeeper)). AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(app.UpgradeKeeper)). AddRoute(ibcclienttypes.RouterKey, ibcclient.NewClientProposalHandler(app.IBCKeeper.ClientKeeper)). AddRoute(oracletypes.RouterKey, oraclemodule.NewAssetInfoProposalHandler(&app.OracleKeeper)) @@ -595,6 +578,9 @@ func NewElysApp( app.GetSubspace(incentivemoduletypes.ModuleName), commitmentKeeper, app.StakingKeeper, + app.AccountKeeper, + app.BankKeeper, + authtypes.FeeCollectorName, ) incentiveModule := incentivemodule.NewAppModule(appCodec, app.IncentiveKeeper) @@ -661,7 +647,6 @@ func NewElysApp( app.StakingKeeper.SetHooks( stakingtypes.NewMultiStakingHooks( // insert staking hooks receivers here - app.DistrKeeper.Hooks(), app.SlashingKeeper.Hooks(), app.IncentiveKeeper.StakingHooks(), ), @@ -709,7 +694,6 @@ func NewElysApp( gov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper), mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper, minttypes.DefaultInflationCalculationFn), slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper), - distr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper), staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper), upgrade.NewAppModule(app.UpgradeKeeper), evidence.NewAppModule(app.EvidenceKeeper), @@ -739,7 +723,7 @@ func NewElysApp( // Note: epochs' begin should be "real" start of epochs, we keep epochs beginblock at the beginning epochsmoduletypes.ModuleName, minttypes.ModuleName, - distrtypes.ModuleName, + incentivemoduletypes.ModuleName, slashingtypes.ModuleName, evidencetypes.ModuleName, stakingtypes.ModuleName, @@ -761,7 +745,6 @@ func NewElysApp( oracletypes.ModuleName, commitmentmoduletypes.ModuleName, tokenomicsmoduletypes.ModuleName, - incentivemoduletypes.ModuleName, burnermoduletypes.ModuleName, // this line is used by starport scaffolding # stargate/app/beginBlockers ) @@ -778,7 +761,7 @@ func NewElysApp( capabilitytypes.ModuleName, authtypes.ModuleName, banktypes.ModuleName, - distrtypes.ModuleName, + incentivemoduletypes.ModuleName, slashingtypes.ModuleName, minttypes.ModuleName, genutiltypes.ModuleName, @@ -794,7 +777,6 @@ func NewElysApp( oracletypes.ModuleName, commitmentmoduletypes.ModuleName, tokenomicsmoduletypes.ModuleName, - incentivemoduletypes.ModuleName, burnermoduletypes.ModuleName, // this line is used by starport scaffolding # stargate/app/endBlockers ) @@ -808,7 +790,7 @@ func NewElysApp( capabilitytypes.ModuleName, authtypes.ModuleName, banktypes.ModuleName, - distrtypes.ModuleName, + incentivemoduletypes.ModuleName, stakingtypes.ModuleName, slashingtypes.ModuleName, govtypes.ModuleName, @@ -831,7 +813,6 @@ func NewElysApp( oracletypes.ModuleName, commitmentmoduletypes.ModuleName, tokenomicsmoduletypes.ModuleName, - incentivemoduletypes.ModuleName, burnermoduletypes.ModuleName, // this line is used by starport scaffolding # stargate/app/initGenesis ) @@ -855,7 +836,6 @@ func NewElysApp( gov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper), mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper, minttypes.DefaultInflationCalculationFn), staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper), - distr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper), slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper), params.NewAppModule(app.ParamsKeeper), groupmodule.NewAppModule(appCodec, app.GroupKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry), @@ -1068,7 +1048,6 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino paramsKeeper.Subspace(banktypes.ModuleName) paramsKeeper.Subspace(stakingtypes.ModuleName) paramsKeeper.Subspace(minttypes.ModuleName) - paramsKeeper.Subspace(distrtypes.ModuleName) paramsKeeper.Subspace(slashingtypes.ModuleName) paramsKeeper.Subspace(govtypes.ModuleName).WithKeyTable(govv1.ParamKeyTable()) paramsKeeper.Subspace(crisistypes.ModuleName) diff --git a/app/export.go b/app/export.go index eeacb17c3..1a28d44bd 100644 --- a/app/export.go +++ b/app/export.go @@ -74,7 +74,7 @@ func (app *ElysApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs [ // withdraw all validator commission app.StakingKeeper.IterateValidators(ctx, func(_ int64, val stakingtypes.ValidatorI) (stop bool) { - _, err := app.DistrKeeper.WithdrawValidatorCommission(ctx, val.GetOperator()) + _, err := app.IncentiveKeeper.WithdrawValidatorCommission(ctx, val.GetOperator()) if err != nil { panic(err) } @@ -84,17 +84,17 @@ func (app *ElysApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs [ // withdraw all delegator rewards dels := app.StakingKeeper.GetAllDelegations(ctx) for _, delegation := range dels { - _, err := app.DistrKeeper.WithdrawDelegationRewards(ctx, delegation.GetDelegatorAddr(), delegation.GetValidatorAddr()) + _, err := app.IncentiveKeeper.WithdrawDelegationRewards(ctx, delegation.GetDelegatorAddr(), delegation.GetValidatorAddr()) if err != nil { panic(err) } } // clear validator slash events - app.DistrKeeper.DeleteAllValidatorSlashEvents(ctx) + app.IncentiveKeeper.DeleteAllValidatorSlashEvents(ctx) // clear validator historical rewards - app.DistrKeeper.DeleteAllValidatorHistoricalRewards(ctx) + app.IncentiveKeeper.DeleteAllValidatorHistoricalRewards(ctx) // set context height to zero height := ctx.BlockHeight() @@ -103,12 +103,12 @@ func (app *ElysApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs [ // reinitialize all validators app.StakingKeeper.IterateValidators(ctx, func(_ int64, val stakingtypes.ValidatorI) (stop bool) { // donate any unwithdrawn outstanding reward fraction tokens to the community pool - scraps := app.DistrKeeper.GetValidatorOutstandingRewardsCoins(ctx, val.GetOperator()) - feePool := app.DistrKeeper.GetFeePool(ctx) + scraps := app.IncentiveKeeper.GetValidatorOutstandingRewardsCoins(ctx, val.GetOperator()) + feePool := app.IncentiveKeeper.GetFeePool(ctx) feePool.CommunityPool = feePool.CommunityPool.Add(scraps...) - app.DistrKeeper.SetFeePool(ctx, feePool) + app.IncentiveKeeper.SetFeePool(ctx, feePool) - err := app.DistrKeeper.Hooks().AfterValidatorCreated(ctx, val.GetOperator()) + err := app.IncentiveKeeper.StakingHooks().AfterValidatorCreated(ctx, val.GetOperator()) if err != nil { panic(err) } @@ -117,11 +117,11 @@ func (app *ElysApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs [ // reinitialize all delegations for _, del := range dels { - err := app.DistrKeeper.Hooks().BeforeDelegationCreated(ctx, del.GetDelegatorAddr(), del.GetValidatorAddr()) + err := app.IncentiveKeeper.StakingHooks().BeforeDelegationCreated(ctx, del.GetDelegatorAddr(), del.GetValidatorAddr()) if err != nil { panic(err) } - err = app.DistrKeeper.Hooks().AfterDelegationModified(ctx, del.GetDelegatorAddr(), del.GetValidatorAddr()) + err = app.IncentiveKeeper.StakingHooks().AfterDelegationModified(ctx, del.GetDelegatorAddr(), del.GetValidatorAddr()) if err != nil { panic(err) } diff --git a/config.yml b/config.yml index 40a1b2a81..8f9a3cf72 100644 --- a/config.yml +++ b/config.yml @@ -212,6 +212,12 @@ genesis: num_epochs: "365" current_epoch: "0" eden_boost_apr: "100" + community_tax: "0.02" + withdraw_addr_enabled: true + fee_pool: + community_pool: + - amount: "0" + denom: uelys tokenomics: airdropList: - intent: AtomStakers diff --git a/docs/static/openapi.yml b/docs/static/openapi.yml index f9c78fdd4..d05d84438 100644 --- a/docs/static/openapi.yml +++ b/docs/static/openapi.yml @@ -33395,6 +33395,276 @@ paths: type: boolean tags: - Query + /elys-network/elys/incentive/community_pool: + get: + summary: Queries a list of CommunityPool items. + operationId: ElysnetworkElysIncentiveCommunityPool + responses: + '200': + description: A successful response. + schema: + type: object + properties: + pool: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + DecCoin defines a token with a denomination and a decimal + amount. + + + NOTE: The amount field is an Dec which implements the custom + method + + signatures required by gogoproto. + description: pool defines community pool's coins. + default: + description: An unexpected error response. + schema: + type: object + properties: + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + '@type': + type: string + additionalProperties: {} + tags: + - Query + /elys-network/elys/incentive/delegators/{delegator_address}/rewards: + get: + summary: |- + DelegationTotalRewards queries the total rewards accrued by a each + validator. + operationId: ElysnetworkElysIncentiveDelegationTotalRewards + responses: + '200': + description: A successful response. + schema: + type: object + properties: + rewards: + type: array + items: + type: object + properties: + validator_address: + type: string + reward: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + DecCoin defines a token with a denomination and a + decimal amount. + + + NOTE: The amount field is an Dec which implements the + custom method + + signatures required by gogoproto. + description: "DelegationDelegatorReward represents the properties\r\nof a delegator's delegation reward." + description: rewards defines all the rewards accrued by a delegator. + total: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + DecCoin defines a token with a denomination and a decimal + amount. + + + NOTE: The amount field is an Dec which implements the custom + method + + signatures required by gogoproto. + description: total defines the sum of all the rewards. + default: + description: An unexpected error response. + schema: + type: object + properties: + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + '@type': + type: string + additionalProperties: {} + parameters: + - name: delegator_address + in: path + required: true + type: string + tags: + - Query + /elys-network/elys/incentive/delegators/{delegator_address}/rewards/{validator_address}: + get: + summary: DelegationRewards queries the total rewards accrued by a delegation. + operationId: ElysnetworkElysIncentiveDelegationRewards + responses: + '200': + description: A successful response. + schema: + type: object + properties: + rewards: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + DecCoin defines a token with a denomination and a decimal + amount. + + + NOTE: The amount field is an Dec which implements the custom + method + + signatures required by gogoproto. + description: rewards defines the rewards accrued by a delegation. + default: + description: An unexpected error response. + schema: + type: object + properties: + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + '@type': + type: string + additionalProperties: {} + parameters: + - name: delegator_address + in: path + required: true + type: string + - name: validator_address + in: path + required: true + type: string + tags: + - Query + /elys-network/elys/incentive/delegators/{delegator_address}/validators: + get: + summary: DelegatorValidators queries the validators of a delegator. + operationId: ElysnetworkElysIncentiveDelegatorValidators + responses: + '200': + description: A successful response. + schema: + type: object + properties: + validators: + type: array + items: + type: string + description: >- + validators defines the validators a delegator is delegating + for. + default: + description: An unexpected error response. + schema: + type: object + properties: + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + '@type': + type: string + additionalProperties: {} + parameters: + - name: delegator_address + in: path + required: true + type: string + tags: + - Query + /elys-network/elys/incentive/delegators/{delegator_address}/withdraw_address: + get: + summary: Queries a list of DelegatorWithdrawAddress items. + operationId: ElysnetworkElysIncentiveDelegatorWithdrawAddress + responses: + '200': + description: A successful response. + schema: + type: object + properties: + withdraw_address: + type: string + description: withdraw_address defines the delegator address to query for. + default: + description: An unexpected error response. + schema: + type: object + properties: + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + '@type': + type: string + additionalProperties: {} + parameters: + - name: delegator_address + in: path + required: true + type: string + tags: + - Query /elys-network/elys/incentive/params: get: summary: Parameters queries the parameters of the module. @@ -33461,6 +33731,10 @@ paths: type: string format: int64 title: Incentive Info + community_tax: + type: string + withdraw_addr_enabled: + type: boolean description: >- QueryParamsResponse is response type for the Query/Params RPC method. @@ -33484,6 +33758,259 @@ paths: additionalProperties: {} tags: - Query + /elys-network/elys/incentive/validators/{validator_address}/commission: + get: + summary: ValidatorCommission queries accumulated commission for a validator. + operationId: ElysnetworkElysIncentiveValidatorCommission + responses: + '200': + description: A successful response. + schema: + type: object + properties: + commission: + description: commission defines the commision the validator received. + type: object + properties: + commission: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + DecCoin defines a token with a denomination and a + decimal amount. + + + NOTE: The amount field is an Dec which implements the + custom method + + signatures required by gogoproto. + default: + description: An unexpected error response. + schema: + type: object + properties: + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + '@type': + type: string + additionalProperties: {} + parameters: + - name: validator_address + in: path + required: true + type: string + tags: + - Query + /elys-network/elys/incentive/validators/{validator_address}/outstanding_rewards: + get: + summary: ValidatorOutstandingRewards queries rewards of a validator address. + operationId: ElysnetworkElysIncentiveValidatorOutstandingRewards + responses: + '200': + description: A successful response. + schema: + type: object + properties: + rewards: + type: object + properties: + rewards: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + DecCoin defines a token with a denomination and a + decimal amount. + + + NOTE: The amount field is an Dec which implements the + custom method + + signatures required by gogoproto. + description: "ValidatorOutstandingRewards represents outstanding (un-withdrawn) rewards\r\nfor a validator inexpensive to track, allows simple sanity checks." + default: + description: An unexpected error response. + schema: + type: object + properties: + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + '@type': + type: string + additionalProperties: {} + parameters: + - name: validator_address + in: path + required: true + type: string + tags: + - Query + /elys-network/elys/incentive/validators/{validator_address}/slashes: + get: + summary: ValidatorSlashes queries slash events of a validator. + operationId: ElysnetworkElysIncentiveValidatorSlashes + responses: + '200': + description: A successful response. + schema: + type: object + properties: + slashes: + type: array + items: + type: object + properties: + validator_period: + type: string + format: uint64 + fraction: + type: string + description: "ValidatorSlashEvent represents a validator slash event.\r\nHeight is implicit within the store key.\r\nThis is needed to calculate appropriate amount of staking tokens\r\nfor delegations which are withdrawn after a slash has occurred." + description: slashes defines the slashes the validator received. + pagination: + description: pagination defines the pagination in the response. + type: object + properties: + next_key: + type: string + format: byte + description: |- + next_key is the key to be passed to PageRequest.key to + query the next page most efficiently. It will be empty if + there are no more results. + total: + type: string + format: uint64 + title: >- + total is total number of results available if + PageRequest.count_total + + was set, its value is undefined otherwise + default: + description: An unexpected error response. + schema: + type: object + properties: + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + '@type': + type: string + additionalProperties: {} + parameters: + - name: validator_address + description: validator_address defines the validator address to query for. + in: path + required: true + type: string + - name: starting_height + description: >- + starting_height defines the optional starting height to query the + slashes. + in: query + required: false + type: string + format: uint64 + - name: ending_height + description: >- + starting_height defines the optional ending height to query the + slashes. + in: query + required: false + type: string + format: uint64 + - name: pagination.key + description: |- + key is a value returned in PageResponse.next_key to begin + querying the next page most efficiently. Only one of offset or key + should be set. + in: query + required: false + type: string + format: byte + - name: pagination.offset + description: >- + offset is a numeric offset that can be used when key is unavailable. + + It is less efficient than using key. Only one of offset or key + should + + be set. + in: query + required: false + type: string + format: uint64 + - name: pagination.limit + description: >- + limit is the total number of results to be returned in the result + page. + + If left empty it will default to a value to be set by each app. + in: query + required: false + type: string + format: uint64 + - name: pagination.count_total + description: >- + count_total is set to true to indicate that the result set should + include + + a count of the total number of items available for pagination in + UIs. + + count_total is only respected when offset is used. It is ignored + when key + + is set. + in: query + required: false + type: boolean + - name: pagination.reverse + description: >- + reverse is set to true if results are to be returned in the + descending order. + + + Since: cosmos-sdk 0.43 + in: query + required: false + type: boolean + tags: + - Query /elys-network/elys/liquidityprovider/params: get: summary: Parameters queries the parameters of the module. @@ -69408,6 +69935,26 @@ definitions: description: |- QueryEpochsInfoResponse is the response type for the Query/EpochInfos RPC method. + elysnetwork.elys.incentive.DelegationDelegatorReward: + type: object + properties: + validator_address: + type: string + reward: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: |- + DecCoin defines a token with a denomination and a decimal amount. + + NOTE: The amount field is an Dec which implements the custom method + signatures required by gogoproto. + description: "DelegationDelegatorReward represents the properties\r\nof a delegator's delegation reward." elysnetwork.elys.incentive.IncentiveInfo: type: object properties: @@ -69432,6 +69979,44 @@ definitions: type: string format: int64 title: Incentive Info + elysnetwork.elys.incentive.MsgSetWithdrawAddressResponse: + type: object + elysnetwork.elys.incentive.MsgWithdrawDelegatorRewardResponse: + type: object + properties: + amount: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: |- + Coin defines a token with a denomination and an amount. + + NOTE: The amount field is an Int which implements the custom method + signatures required by gogoproto. + title: 'Since: cosmos-sdk 0.46' + elysnetwork.elys.incentive.MsgWithdrawValidatorCommissionResponse: + type: object + properties: + amount: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: |- + Coin defines a token with a denomination and an amount. + + NOTE: The amount field is an Int which implements the custom method + signatures required by gogoproto. + title: 'Since: cosmos-sdk 0.46' elysnetwork.elys.incentive.Params: type: object properties: @@ -69487,7 +70072,106 @@ definitions: type: string format: int64 title: Incentive Info + community_tax: + type: string + withdraw_addr_enabled: + type: boolean description: Params defines the parameters for the module. + elysnetwork.elys.incentive.QueryCommunityPoolResponse: + type: object + properties: + pool: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: |- + DecCoin defines a token with a denomination and a decimal amount. + + NOTE: The amount field is an Dec which implements the custom method + signatures required by gogoproto. + description: pool defines community pool's coins. + elysnetwork.elys.incentive.QueryDelegationRewardsResponse: + type: object + properties: + rewards: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: |- + DecCoin defines a token with a denomination and a decimal amount. + + NOTE: The amount field is an Dec which implements the custom method + signatures required by gogoproto. + description: rewards defines the rewards accrued by a delegation. + elysnetwork.elys.incentive.QueryDelegationTotalRewardsResponse: + type: object + properties: + rewards: + type: array + items: + type: object + properties: + validator_address: + type: string + reward: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + DecCoin defines a token with a denomination and a decimal + amount. + + + NOTE: The amount field is an Dec which implements the custom + method + + signatures required by gogoproto. + description: "DelegationDelegatorReward represents the properties\r\nof a delegator's delegation reward." + description: rewards defines all the rewards accrued by a delegator. + total: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: |- + DecCoin defines a token with a denomination and a decimal amount. + + NOTE: The amount field is an Dec which implements the custom method + signatures required by gogoproto. + description: total defines the sum of all the rewards. + elysnetwork.elys.incentive.QueryDelegatorValidatorsResponse: + type: object + properties: + validators: + type: array + items: + type: string + description: validators defines the validators a delegator is delegating for. + elysnetwork.elys.incentive.QueryDelegatorWithdrawAddressResponse: + type: object + properties: + withdraw_address: + type: string + description: withdraw_address defines the delegator address to query for. elysnetwork.elys.incentive.QueryParamsResponse: type: object properties: @@ -69547,7 +70231,140 @@ definitions: type: string format: int64 title: Incentive Info + community_tax: + type: string + withdraw_addr_enabled: + type: boolean description: QueryParamsResponse is response type for the Query/Params RPC method. + elysnetwork.elys.incentive.QueryValidatorCommissionResponse: + type: object + properties: + commission: + description: commission defines the commision the validator received. + type: object + properties: + commission: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + DecCoin defines a token with a denomination and a decimal + amount. + + + NOTE: The amount field is an Dec which implements the custom + method + + signatures required by gogoproto. + elysnetwork.elys.incentive.QueryValidatorOutstandingRewardsResponse: + type: object + properties: + rewards: + type: object + properties: + rewards: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + DecCoin defines a token with a denomination and a decimal + amount. + + + NOTE: The amount field is an Dec which implements the custom + method + + signatures required by gogoproto. + description: "ValidatorOutstandingRewards represents outstanding (un-withdrawn) rewards\r\nfor a validator inexpensive to track, allows simple sanity checks." + elysnetwork.elys.incentive.QueryValidatorSlashesResponse: + type: object + properties: + slashes: + type: array + items: + type: object + properties: + validator_period: + type: string + format: uint64 + fraction: + type: string + description: "ValidatorSlashEvent represents a validator slash event.\r\nHeight is implicit within the store key.\r\nThis is needed to calculate appropriate amount of staking tokens\r\nfor delegations which are withdrawn after a slash has occurred." + description: slashes defines the slashes the validator received. + pagination: + description: pagination defines the pagination in the response. + type: object + properties: + next_key: + type: string + format: byte + description: |- + next_key is the key to be passed to PageRequest.key to + query the next page most efficiently. It will be empty if + there are no more results. + total: + type: string + format: uint64 + title: >- + total is total number of results available if + PageRequest.count_total + + was set, its value is undefined otherwise + elysnetwork.elys.incentive.ValidatorAccumulatedCommission: + type: object + properties: + commission: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: |- + DecCoin defines a token with a denomination and a decimal amount. + + NOTE: The amount field is an Dec which implements the custom method + signatures required by gogoproto. + description: "ValidatorAccumulatedCommission represents accumulated commission\r\nfor a validator kept as a running counter, can be withdrawn at any time." + elysnetwork.elys.incentive.ValidatorOutstandingRewards: + type: object + properties: + rewards: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: |- + DecCoin defines a token with a denomination and a decimal amount. + + NOTE: The amount field is an Dec which implements the custom method + signatures required by gogoproto. + description: "ValidatorOutstandingRewards represents outstanding (un-withdrawn) rewards\r\nfor a validator inexpensive to track, allows simple sanity checks." + elysnetwork.elys.incentive.ValidatorSlashEvent: + type: object + properties: + validator_period: + type: string + format: uint64 + fraction: + type: string + description: "ValidatorSlashEvent represents a validator slash event.\r\nHeight is implicit within the store key.\r\nThis is needed to calculate appropriate amount of staking tokens\r\nfor delegations which are withdrawn after a slash has occurred." elysnetwork.elys.liquidityprovider.Params: type: object description: Params defines the parameters for the module. diff --git a/go.mod b/go.mod index 76df90ea3..108c73732 100644 --- a/go.mod +++ b/go.mod @@ -45,7 +45,7 @@ require ( github.com/99designs/keyring v1.2.1 // indirect github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d // indirect github.com/Workiva/go-datastructures v1.0.53 // indirect - github.com/armon/go-metrics v0.4.1 // indirect + github.com/armon/go-metrics v0.4.1 github.com/aws/aws-sdk-go v1.44.122 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect diff --git a/proto/elys/incentive/distribution.proto b/proto/elys/incentive/distribution.proto new file mode 100644 index 000000000..b91054e9f --- /dev/null +++ b/proto/elys/incentive/distribution.proto @@ -0,0 +1,137 @@ +syntax = "proto3"; +package elysnetwork.elys.incentive; + +option go_package = "github.com/elys-network/elys/x/incentive/types"; +option (gogoproto.equal_all) = true; + +import "gogoproto/gogo.proto"; +import "cosmos/base/v1beta1/coin.proto"; + +// ValidatorHistoricalRewards represents historical rewards for a validator. +// Height is implicit within the store key. +// Cumulative reward ratio is the sum from the zeroeth period +// until this period of rewards / tokens, per the spec. +// The reference count indicates the number of objects +// which might need to reference this historical entry at any point. +// ReferenceCount = +// number of outstanding delegations which ended the associated period (and +// might need to read that record) +// + number of slashes which ended the associated period (and might need to +// read that record) +// + one per validator for the zeroeth period, set on initialization +message ValidatorHistoricalRewards { + repeated cosmos.base.v1beta1.DecCoin cumulative_reward_ratio = 1 [ + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins", + (gogoproto.nullable) = false + ]; + + uint32 reference_count = 2; +} + +// ValidatorCurrentRewards represents current rewards and current +// period for a validator kept as a running counter and incremented +// each block as long as the validator's tokens remain constant. +message ValidatorCurrentRewards { + repeated cosmos.base.v1beta1.DecCoin rewards = 1 [ + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins", + (gogoproto.nullable) = false + ]; + uint64 period = 2; +} + +// ValidatorAccumulatedCommission represents accumulated commission +// for a validator kept as a running counter, can be withdrawn at any time. +message ValidatorAccumulatedCommission { + repeated cosmos.base.v1beta1.DecCoin commission = 1 [ + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins", + (gogoproto.nullable) = false + ]; +} + +// ValidatorOutstandingRewards represents outstanding (un-withdrawn) rewards +// for a validator inexpensive to track, allows simple sanity checks. +message ValidatorOutstandingRewards { + repeated cosmos.base.v1beta1.DecCoin rewards = 1 [ + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins", + (gogoproto.nullable) = false + ]; +} + +// ValidatorSlashEvent represents a validator slash event. +// Height is implicit within the store key. +// This is needed to calculate appropriate amount of staking tokens +// for delegations which are withdrawn after a slash has occurred. +message ValidatorSlashEvent { + uint64 validator_period = 1; + string fraction = 2 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; +} + +// ValidatorSlashEvents is a collection of ValidatorSlashEvent messages. +message ValidatorSlashEvents { + repeated ValidatorSlashEvent validator_slash_events = 1 [(gogoproto.nullable) = false]; +} + +// FeePool is the global fee pool for distribution. +message FeePool { + repeated cosmos.base.v1beta1.DecCoin community_pool = 1 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins" + ]; +} + +// CommunityPoolSpendProposal details a proposal for use of community funds, +// together with how many coins are proposed to be spent, and to which +// recipient account. +message CommunityPoolSpendProposal { + option (gogoproto.goproto_getters) = false; + + string title = 1; + string description = 2; + string recipient = 3; + repeated cosmos.base.v1beta1.Coin amount = 4 + [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; +} + +// DelegatorStartingInfo represents the starting info for a delegator reward +// period. It tracks the previous validator period, the delegation's amount of +// staking token, and the creation height (to check later on if any slashes have +// occurred). NOTE: Even though validators are slashed to whole staking tokens, +// the delegators within the validator may be left with less than a full token, +// thus sdk.Dec is used. +message DelegatorStartingInfo { + uint64 previous_period = 1; + string stake = 2 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + uint64 height = 3 + [(gogoproto.jsontag) = "creation_height" ]; +} + +// DelegationDelegatorReward represents the properties +// of a delegator's delegation reward. +message DelegationDelegatorReward { + option (gogoproto.goproto_getters) = false; + + string validator_address = 1; + + repeated cosmos.base.v1beta1.DecCoin reward = 2 [ + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins", + (gogoproto.nullable) = false + ]; +} + +// CommunityPoolSpendProposalWithDeposit defines a CommunityPoolSpendProposal +// with a deposit +message CommunityPoolSpendProposalWithDeposit { + option (gogoproto.goproto_getters) = false; + + string title = 1; + string description = 2; + string recipient = 3; + string amount = 4; + string deposit = 5; +} diff --git a/proto/elys/incentive/genesis.proto b/proto/elys/incentive/genesis.proto index 0a74f2792..9bf2dd50b 100644 --- a/proto/elys/incentive/genesis.proto +++ b/proto/elys/incentive/genesis.proto @@ -1,12 +1,143 @@ syntax = "proto3"; + package elysnetwork.elys.incentive; import "gogoproto/gogo.proto"; import "elys/incentive/params.proto"; +import "elys/incentive/distribution.proto"; +import "cosmos/base/v1beta1/coin.proto"; option go_package = "github.com/elys-network/elys/x/incentive/types"; + +// DelegatorWithdrawInfo is the address for where distributions rewards are +// withdrawn to by default this struct is only used at genesis to feed in +// default withdraw addresses. +message DelegatorWithdrawInfo { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // delegator_address is the address of the delegator. + string delegator_address = 1; + + // withdraw_address is the address to withdraw the delegation rewards to. + string withdraw_address = 2; +} + +// ValidatorOutstandingRewardsRecord is used for import/export via genesis json. +message ValidatorOutstandingRewardsRecord { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // validator_address is the address of the validator. + string validator_address = 1; + + // outstanding_rewards represents the oustanding rewards of a validator. + repeated cosmos.base.v1beta1.DecCoin outstanding_rewards = 2 + [(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins", (gogoproto.nullable) = false]; +} + +// ValidatorAccumulatedCommissionRecord is used for import / export via genesis +// json. +message ValidatorAccumulatedCommissionRecord { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // validator_address is the address of the validator. + string validator_address = 1; + + // accumulated is the accumulated commission of a validator. + ValidatorAccumulatedCommission accumulated = 2 [(gogoproto.nullable) = false]; +} + + // ValidatorHistoricalRewardsRecord is used for import / export via genesis + // json. +message ValidatorHistoricalRewardsRecord { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // validator_address is the address of the validator. + string validator_address = 1; + + // period defines the period the historical rewards apply to. + uint64 period = 2; + + // rewards defines the historical rewards of a validator. + ValidatorHistoricalRewards rewards = 3 [(gogoproto.nullable) = false]; +} + + // ValidatorCurrentRewardsRecord is used for import / export via genesis json. +message ValidatorCurrentRewardsRecord { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // validator_address is the address of the validator. + string validator_address = 1; + + // rewards defines the current rewards of a validator. + ValidatorCurrentRewards rewards = 2 [(gogoproto.nullable) = false]; +} + + // DelegatorStartingInfoRecord used for import / export via genesis json. +message DelegatorStartingInfoRecord { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // delegator_address is the address of the delegator. + string delegator_address = 1; + + // validator_address is the address of the validator. + string validator_address = 2; + + // starting_info defines the starting info of a delegator. + DelegatorStartingInfo starting_info = 3 [(gogoproto.nullable) = false]; +} + +// ValidatorSlashEventRecord is used for import / export via genesis json. +message ValidatorSlashEventRecord { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // validator_address is the address of the validator. + string validator_address = 1; + // height defines the block height at which the slash event occured. + uint64 height = 2; + // period is the period of the slash event. + uint64 period = 3; + // validator_slash_event describes the slash event. + ValidatorSlashEvent validator_slash_event = 4 [(gogoproto.nullable) = false]; + } + + // GenesisState defines the incentive module's genesis state. message GenesisState { - Params params = 1 [(gogoproto.nullable) = false]; + Params params = 1 [(gogoproto.nullable) = false]; + + // fee_pool defines the fee pool at genesis. + FeePool fee_pool = 2 [(gogoproto.nullable) = false]; + + // fee_pool defines the delegator withdraw infos at genesis. + repeated DelegatorWithdrawInfo delegator_withdraw_infos = 3 [(gogoproto.nullable) = false]; + + // fee_pool defines the previous proposer at genesis. + string previous_proposer = 4; + + // fee_pool defines the outstanding rewards of all validators at genesis. + repeated ValidatorOutstandingRewardsRecord outstanding_rewards = 5 [(gogoproto.nullable) = false]; + + // fee_pool defines the accumulated commisions of all validators at genesis. + repeated ValidatorAccumulatedCommissionRecord validator_accumulated_commissions = 6 [(gogoproto.nullable) = false]; + + // fee_pool defines the historical rewards of all validators at genesis. + repeated ValidatorHistoricalRewardsRecord validator_historical_rewards = 7 [(gogoproto.nullable) = false]; + + // fee_pool defines the current rewards of all validators at genesis. + repeated ValidatorCurrentRewardsRecord validator_current_rewards = 8 [(gogoproto.nullable) = false]; + + // fee_pool defines the delegator starting infos at genesis. + repeated DelegatorStartingInfoRecord delegator_starting_infos = 9 [(gogoproto.nullable) = false]; + + // fee_pool defines the validator slash events at genesis. + repeated ValidatorSlashEventRecord validator_slash_events = 10 [(gogoproto.nullable) = false]; } + diff --git a/proto/elys/incentive/incentive.proto b/proto/elys/incentive/incentive.proto index 3a84553e0..3e1cc6807 100644 --- a/proto/elys/incentive/incentive.proto +++ b/proto/elys/incentive/incentive.proto @@ -11,12 +11,12 @@ message IncentiveInfo { string amount = 1 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"amount\""]; // epoch identifier - string epoch_identifier = 2; + string epoch_identifier = 2 [(gogoproto.moretags) = "yaml:\"epoch_identifier\""]; // start_time of the distribution google.protobuf.Timestamp start_time = 3 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"start_time\""]; // distribution duration - int64 num_epochs = 4; - int64 current_epoch = 5; - int64 eden_boost_apr = 6; + int64 num_epochs = 4 [(gogoproto.moretags) = "yaml:\"num_epochs\""]; + int64 current_epoch = 5 [(gogoproto.moretags) = "yaml:\"current_epoch\""]; + int64 eden_boost_apr = 6 [(gogoproto.moretags) = "yaml:\"eden_boost_apr\""]; } \ No newline at end of file diff --git a/proto/elys/incentive/params.proto b/proto/elys/incentive/params.proto index 31b179797..6538ec918 100644 --- a/proto/elys/incentive/params.proto +++ b/proto/elys/incentive/params.proto @@ -9,6 +9,13 @@ option go_package = "github.com/elys-network/elys/x/incentive/types"; // Params defines the parameters for the module. message Params { option (gogoproto.goproto_stringer) = false; - repeated IncentiveInfo lp_incentives = 1 [(gogoproto.nullable) = false]; - repeated IncentiveInfo stake_incentives = 2 [(gogoproto.nullable) = false]; + repeated IncentiveInfo lp_incentives = 1 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"lp_incentives\""]; + repeated IncentiveInfo stake_incentives = 2 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"stake_incentives\""]; + + string community_tax = 3 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + + bool withdraw_addr_enabled = 4; } diff --git a/proto/elys/incentive/query.proto b/proto/elys/incentive/query.proto index 4749d498b..90b469493 100644 --- a/proto/elys/incentive/query.proto +++ b/proto/elys/incentive/query.proto @@ -1,26 +1,183 @@ syntax = "proto3"; + package elysnetwork.elys.incentive; +import "elys/incentive/params.proto"; +import "elys/incentive/distribution.proto"; import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; +import "cosmos/base/v1beta1/coin.proto"; import "cosmos/base/query/v1beta1/pagination.proto"; -import "elys/incentive/params.proto"; option go_package = "github.com/elys-network/elys/x/incentive/types"; // Query defines the gRPC querier service. service Query { + // Parameters queries the parameters of the module. - rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { + rpc Params (QueryParamsRequest) returns (QueryParamsResponse) { option (google.api.http).get = "/elys-network/elys/incentive/params"; + + } + + // ValidatorOutstandingRewards queries rewards of a validator address. + rpc ValidatorOutstandingRewards (QueryValidatorOutstandingRewardsRequest) returns (QueryValidatorOutstandingRewardsResponse) { + option (google.api.http).get = "/elys-network/elys/incentive/validators/{validator_address}/outstanding_rewards"; + + } + + // ValidatorCommission queries accumulated commission for a validator. + rpc ValidatorCommission (QueryValidatorCommissionRequest) returns (QueryValidatorCommissionResponse) { + option (google.api.http).get = "/elys-network/elys/incentive/validators/{validator_address}/commission"; + + } + + // ValidatorSlashes queries slash events of a validator. + rpc ValidatorSlashes (QueryValidatorSlashesRequest) returns (QueryValidatorSlashesResponse) { + option (google.api.http).get = "/elys-network/elys/incentive/validators/{validator_address}/slashes"; + + } + + // DelegationRewards queries the total rewards accrued by a delegation. + rpc DelegationRewards (QueryDelegationRewardsRequest) returns (QueryDelegationRewardsResponse) { + option (google.api.http).get = "/elys-network/elys/incentive/delegators/{delegator_address}/rewards/{validator_address}"; + + } + + // DelegationTotalRewards queries the total rewards accrued by a each + // validator. + rpc DelegationTotalRewards (QueryDelegationTotalRewardsRequest) returns (QueryDelegationTotalRewardsResponse) { + option (google.api.http).get = "/elys-network/elys/incentive/delegators/{delegator_address}/rewards"; + + } + + // DelegatorValidators queries the validators of a delegator. + rpc DelegatorValidators (QueryDelegatorValidatorsRequest) returns (QueryDelegatorValidatorsResponse) { + option (google.api.http).get = "/elys-network/elys/incentive/delegators/{delegator_address}/validators"; + + } + + // Queries a list of CommunityPool items. + rpc CommunityPool (QueryCommunityPoolRequest) returns (QueryCommunityPoolResponse) { + option (google.api.http).get = "/elys-network/elys/incentive/community_pool"; + + } + + // Queries a list of DelegatorWithdrawAddress items. + rpc DelegatorWithdrawAddress (QueryDelegatorWithdrawAddressRequest) returns (QueryDelegatorWithdrawAddressResponse) { + option (google.api.http).get = "/elys-network/elys/incentive/delegators/{delegator_address}/withdraw_address"; + } } - // QueryParamsRequest is request type for the Query/Params RPC method. message QueryParamsRequest {} // QueryParamsResponse is response type for the Query/Params RPC method. message QueryParamsResponse { + // params holds all the parameters of this module. Params params = 1 [(gogoproto.nullable) = false]; -} \ No newline at end of file +} + +message QueryValidatorOutstandingRewardsRequest { + string validator_address = 1; +} + +message QueryValidatorOutstandingRewardsResponse { + ValidatorOutstandingRewards rewards = 1 [(gogoproto.nullable) = false]; +} + +message QueryValidatorCommissionRequest { + string validator_address = 1; +} + +message QueryValidatorCommissionResponse { + + // commission defines the commision the validator received. + ValidatorAccumulatedCommission commission = 1 [(gogoproto.nullable) = false]; +} + +message QueryValidatorSlashesRequest { + option (gogoproto.goproto_getters) = false; + + // validator_address defines the validator address to query for. + string validator_address = 1; + + // starting_height defines the optional starting height to query the slashes. + uint64 starting_height = 2; + + // starting_height defines the optional ending height to query the slashes. + uint64 ending_height = 3; + + // pagination defines an optional pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 4; +} + +message QueryValidatorSlashesResponse { + + // slashes defines the slashes the validator received. + repeated ValidatorSlashEvent slashes = 1 [(gogoproto.nullable) = false]; + + // pagination defines the pagination in the response. + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + +message QueryDelegationRewardsRequest { + option (gogoproto.goproto_getters) = false; + string delegator_address = 1; + string validator_address = 2; +} + +message QueryDelegationRewardsResponse { + + // rewards defines the rewards accrued by a delegation. + repeated cosmos.base.v1beta1.DecCoin rewards = 1 [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins"]; +} + +message QueryDelegationTotalRewardsRequest { + option (gogoproto.goproto_getters) = false; + string delegator_address = 1; +} + +message QueryDelegationTotalRewardsResponse { + + // rewards defines all the rewards accrued by a delegator. + repeated DelegationDelegatorReward rewards = 1 [(gogoproto.nullable) = false]; + + // total defines the sum of all the rewards. + repeated cosmos.base.v1beta1.DecCoin total = 2 [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins"]; +} + +message QueryDelegatorValidatorsRequest { + option (gogoproto.goproto_getters) = false; + string delegator_address = 1; +} + +message QueryDelegatorValidatorsResponse { + option (gogoproto.goproto_getters) = false; + + // validators defines the validators a delegator is delegating for. + repeated string validators = 1; +} + +message QueryCommunityPoolRequest {} + +message QueryCommunityPoolResponse { + + // pool defines community pool's coins. + repeated cosmos.base.v1beta1.DecCoin pool = 1 [(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins", (gogoproto.nullable) = false]; +} + +message QueryDelegatorWithdrawAddressRequest { + option (gogoproto.goproto_getters) = false; + + string delegator_address = 1; +} + +message QueryDelegatorWithdrawAddressResponse { + option (gogoproto.goproto_getters) = false; + + // withdraw_address defines the delegator address to query for. + string withdraw_address = 1; +} + diff --git a/proto/elys/incentive/tx.proto b/proto/elys/incentive/tx.proto index 0b7bc5766..d2421d12a 100644 --- a/proto/elys/incentive/tx.proto +++ b/proto/elys/incentive/tx.proto @@ -1,7 +1,43 @@ syntax = "proto3"; + package elysnetwork.elys.incentive; +import "cosmos/base/v1beta1/coin.proto"; +import "gogoproto/gogo.proto"; + option go_package = "github.com/elys-network/elys/x/incentive/types"; // Msg defines the Msg service. -service Msg {} \ No newline at end of file +service Msg { + rpc SetWithdrawAddress (MsgSetWithdrawAddress ) returns (MsgSetWithdrawAddressResponse ); + rpc WithdrawValidatorCommission (MsgWithdrawValidatorCommission) returns (MsgWithdrawValidatorCommissionResponse); + rpc WithdrawDelegatorReward (MsgWithdrawDelegatorReward ) returns (MsgWithdrawDelegatorRewardResponse ); +} +message MsgSetWithdrawAddress { + string delegator_address = 1; + string withdraw_address = 2; +} + +message MsgSetWithdrawAddressResponse {} + +message MsgWithdrawValidatorCommission { + string validator_address = 1; +} + +message MsgWithdrawValidatorCommissionResponse { + // Since: cosmos-sdk 0.46 + repeated cosmos.base.v1beta1.Coin amount = 1 + [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; +} + +message MsgWithdrawDelegatorReward { + string delegator_address = 1; + string validator_address = 2; +} + +message MsgWithdrawDelegatorRewardResponse { + // Since: cosmos-sdk 0.46 + repeated cosmos.base.v1beta1.Coin amount = 1 + [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; +} + diff --git a/testutil/keeper/incentive.go b/testutil/keeper/incentive.go index 26eda8725..9042d2d50 100644 --- a/testutil/keeper/incentive.go +++ b/testutil/keeper/incentive.go @@ -43,6 +43,9 @@ func IncentiveKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) { paramsSubspace, nil, nil, + nil, + nil, + "", ) ctx := sdk.NewContext(stateStore, tmproto.Header{}, false, log.NewNopLogger()) diff --git a/x/commitment/keeper/keeper.go b/x/commitment/keeper/keeper.go index 64ead897e..54f640397 100644 --- a/x/commitment/keeper/keeper.go +++ b/x/commitment/keeper/keeper.go @@ -16,7 +16,7 @@ import ( // Interface declearation type CommitmentKeeperI interface { // Initiate commitment according to standard staking - StandardStakingToken(sdk.Context, string, string) error + StandardStakingToken(sdk.Context, string, string, string) error // Iterate all commitments IterateCommitments(sdk.Context, func(types.Commitments) (stop bool)) @@ -92,22 +92,30 @@ func (k *Keeper) SetHooks(eh types.CommitmentHooks) *Keeper { // Process standard staking elys token // Create a commitment entity -func (k Keeper) StandardStakingToken(ctx sdk.Context, creator string, denom string) error { - _, err := sdk.AccAddressFromBech32(creator) +func (k Keeper) StandardStakingToken(ctx sdk.Context, delegator string, validator string, denom string) error { + _, err := sdk.AccAddressFromBech32(delegator) if err != nil { return sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, "unable to convert address from bech32") } - // Get the Commitments for the creator - commitments, found := k.GetCommitments(ctx, creator) + _, err = sdk.AccAddressFromBech32(validator) + if err != nil { + return sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, "unable to convert address from bech32") + } + + /***********************************************************/ + ////////////////// Delegator entity ////////////////////////// + /***********************************************************/ + // Get the Commitments for the delegator + commitments, found := k.GetCommitments(ctx, delegator) if !found { commitments = types.Commitments{ - Creator: creator, + Creator: delegator, CommittedTokens: []*types.CommittedTokens{}, UncommittedTokens: []*types.UncommittedTokens{}, } } - // Get the uncommitted tokens for the creator + // Get the uncommitted tokens for the delegator uncommittedToken, _ := commitments.GetUncommittedTokensForDenom(denom) if !found { uncommittedTokens := commitments.GetUncommittedTokens() @@ -122,14 +130,50 @@ func (k Keeper) StandardStakingToken(ctx sdk.Context, creator string, denom stri // Update the commitments k.SetCommitments(ctx, commitments) + // Emit blockchain event + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventTypeCommitmentChanged, + sdk.NewAttribute(types.AttributeCreator, delegator), + sdk.NewAttribute(types.AttributeAmount, sdk.ZeroInt().String()), + sdk.NewAttribute(types.AttributeDenom, denom), + ), + ) + + /***************************************************************/ + ////////////////////// Validator entity ///////////////////////// + // Get the Commitments for the validator + commitments, found = k.GetCommitments(ctx, validator) + if !found { + commitments = types.Commitments{ + Creator: validator, + CommittedTokens: []*types.CommittedTokens{}, + UncommittedTokens: []*types.UncommittedTokens{}, + } + } + // Get the uncommitted tokens for the validator + uncommittedToken, _ = commitments.GetUncommittedTokensForDenom(denom) + if !found { + uncommittedTokens := commitments.GetUncommittedTokens() + uncommittedToken = &types.UncommittedTokens{ + Denom: denom, + Amount: sdk.ZeroInt(), + } + uncommittedTokens = append(uncommittedTokens, uncommittedToken) + commitments.UncommittedTokens = uncommittedTokens + } + + // Update the commitments + k.SetCommitments(ctx, commitments) + // Emit Hook commitment changed - k.AfterCommitmentChange(ctx, creator, sdk.NewCoin(denom, sdk.ZeroInt())) + k.AfterCommitmentChange(ctx, delegator, sdk.NewCoin(denom, sdk.ZeroInt())) // Emit blockchain event ctx.EventManager().EmitEvent( sdk.NewEvent( types.EventTypeCommitmentChanged, - sdk.NewAttribute(types.AttributeCreator, creator), + sdk.NewAttribute(types.AttributeCreator, validator), sdk.NewAttribute(types.AttributeAmount, sdk.ZeroInt().String()), sdk.NewAttribute(types.AttributeDenom, denom), ), diff --git a/x/commitment/types/events.go b/x/commitment/types/events.go index ec7421c96..f3d10a70c 100644 --- a/x/commitment/types/events.go +++ b/x/commitment/types/events.go @@ -2,7 +2,7 @@ package types // epochs events const ( - EventTypeCommitmentChanged = "commitment_changed" + EventTypeCommitmentChanged = "commitment_changed" AttributeCreator = "creator" AttributeAmount = "token_amount" diff --git a/x/incentive/abci.go b/x/incentive/abci.go new file mode 100644 index 000000000..8f66ed644 --- /dev/null +++ b/x/incentive/abci.go @@ -0,0 +1,38 @@ +package incentive + +import ( + "time" + + abci "github.com/tendermint/tendermint/abci/types" + + "github.com/cosmos/cosmos-sdk/telemetry" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/elys-network/elys/x/incentive/keeper" + "github.com/elys-network/elys/x/incentive/types" +) + +// BeginBlocker sets the proposer for determining distribution during endblock +// and distribute rewards for the previous block +func BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock, k keeper.Keeper) { + defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyBeginBlocker) + + // determine the total power signing the block + var previousTotalPower, sumPreviousPrecommitPower int64 + for _, voteInfo := range req.LastCommitInfo.GetVotes() { + previousTotalPower += voteInfo.Validator.Power + if voteInfo.SignedLastBlock { + sumPreviousPrecommitPower += voteInfo.Validator.Power + } + } + + // TODO this is Tendermint-dependent + // ref https://github.com/cosmos/cosmos-sdk/issues/3095 + if ctx.BlockHeight() > 1 { + previousProposer := k.GetPreviousProposerConsAddr(ctx) + k.AllocateTokens(ctx, sumPreviousPrecommitPower, previousTotalPower, previousProposer, req.LastCommitInfo.GetVotes()) + } + + // record the proposer for when we payout on the next block + consAddr := sdk.ConsAddress(req.Header.ProposerAddress) + k.SetPreviousProposerConsAddr(ctx, consAddr) +} diff --git a/x/incentive/client/cli/queries.go b/x/incentive/client/cli/queries.go new file mode 100644 index 000000000..d5f60b7c9 --- /dev/null +++ b/x/incentive/client/cli/queries.go @@ -0,0 +1,307 @@ +package cli + +import ( + "context" + "strconv" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/elys-network/elys/x/incentive/types" + "github.com/spf13/cobra" +) + +var _ = strconv.Itoa(0) + +func CmdCommunityPool() *cobra.Command { + cmd := &cobra.Command{ + Use: "community-pool", + Short: "Query community-pool", + Args: cobra.ExactArgs(0), + RunE: func(cmd *cobra.Command, args []string) (err error) { + + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + params := &types.QueryCommunityPoolRequest{} + + res, err := queryClient.CommunityPool(cmd.Context(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +func CmdDelegationRewards() *cobra.Command { + cmd := &cobra.Command{ + Use: "delegation-rewards [delegator-address] [validator-address]", + Short: "Query delegation-rewards", + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) (err error) { + reqDelegatorAddress := args[0] + reqValidatorAddress := args[1] + + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + params := &types.QueryDelegationRewardsRequest{ + + DelegatorAddress: reqDelegatorAddress, + ValidatorAddress: reqValidatorAddress, + } + + res, err := queryClient.DelegationRewards(cmd.Context(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +func CmdDelegationTotalRewards() *cobra.Command { + cmd := &cobra.Command{ + Use: "delegation-total-rewards [delegator-address]", + Short: "Query delegation-total-rewards", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) (err error) { + reqDelegatorAddress := args[0] + + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + params := &types.QueryDelegationTotalRewardsRequest{ + + DelegatorAddress: reqDelegatorAddress, + } + + res, err := queryClient.DelegationTotalRewards(cmd.Context(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +func CmdDelegatorValidators() *cobra.Command { + cmd := &cobra.Command{ + Use: "delegator-validators [delegator-address]", + Short: "Query delegator-validators", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) (err error) { + reqDelegatorAddress := args[0] + + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + params := &types.QueryDelegatorValidatorsRequest{ + + DelegatorAddress: reqDelegatorAddress, + } + + res, err := queryClient.DelegatorValidators(cmd.Context(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +func CmdDelegatorWithdrawAddress() *cobra.Command { + cmd := &cobra.Command{ + Use: "delegator-withdraw-address [delegator-address]", + Short: "Query delegator-withdraw-address", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) (err error) { + reqDelegatorAddress := args[0] + + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + params := &types.QueryDelegatorWithdrawAddressRequest{ + + DelegatorAddress: reqDelegatorAddress, + } + + res, err := queryClient.DelegatorWithdrawAddress(cmd.Context(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +func CmdQueryParams() *cobra.Command { + cmd := &cobra.Command{ + Use: "params", + Short: "shows the parameters of the module", + Args: cobra.NoArgs, + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + + queryClient := types.NewQueryClient(clientCtx) + + res, err := queryClient.Params(context.Background(), &types.QueryParamsRequest{}) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +func CmdValidatorCommission() *cobra.Command { + cmd := &cobra.Command{ + Use: "validator-commission [validator-address]", + Short: "Query validator-commission", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) (err error) { + reqValidatorAddress := args[0] + + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + params := &types.QueryValidatorCommissionRequest{ + + ValidatorAddress: reqValidatorAddress, + } + + res, err := queryClient.ValidatorCommission(cmd.Context(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +func CmdValidatorOutstandingRewards() *cobra.Command { + cmd := &cobra.Command{ + Use: "validator-outstanding-rewards [validator-address]", + Short: "Query validator-outstanding-rewards", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) (err error) { + reqValidatorAddress := args[0] + + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + params := &types.QueryValidatorOutstandingRewardsRequest{ + + ValidatorAddress: reqValidatorAddress, + } + + res, err := queryClient.ValidatorOutstandingRewards(cmd.Context(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +func CmdValidatorSlashes() *cobra.Command { + cmd := &cobra.Command{ + Use: "validator-slashes [validator-address]", + Short: "Query validator-slashes", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) (err error) { + reqValidatorAddress := args[0] + + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + params := &types.QueryValidatorSlashesRequest{ + + ValidatorAddress: reqValidatorAddress, + } + + res, err := queryClient.ValidatorSlashes(cmd.Context(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/incentive/client/cli/query.go b/x/incentive/client/cli/query.go index 0cdb251ef..3821247e8 100644 --- a/x/incentive/client/cli/query.go +++ b/x/incentive/client/cli/query.go @@ -25,6 +25,14 @@ func GetQueryCmd(queryRoute string) *cobra.Command { } cmd.AddCommand(CmdQueryParams()) + cmd.AddCommand(CmdValidatorOutstandingRewards()) + cmd.AddCommand(CmdValidatorCommission()) + cmd.AddCommand(CmdValidatorSlashes()) + cmd.AddCommand(CmdDelegationRewards()) + cmd.AddCommand(CmdDelegationTotalRewards()) + cmd.AddCommand(CmdDelegatorValidators()) + cmd.AddCommand(CmdCommunityPool()) + cmd.AddCommand(CmdDelegatorWithdrawAddress()) // this line is used by starport scaffolding # 1 return cmd diff --git a/x/incentive/client/cli/query_params.go b/x/incentive/client/cli/query_params.go deleted file mode 100644 index d124b92db..000000000 --- a/x/incentive/client/cli/query_params.go +++ /dev/null @@ -1,34 +0,0 @@ -package cli - -import ( - "context" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/elys-network/elys/x/incentive/types" - "github.com/spf13/cobra" -) - -func CmdQueryParams() *cobra.Command { - cmd := &cobra.Command{ - Use: "params", - Short: "shows the parameters of the module", - Args: cobra.NoArgs, - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx := client.GetClientContextFromCmd(cmd) - - queryClient := types.NewQueryClient(clientCtx) - - res, err := queryClient.Params(context.Background(), &types.QueryParamsRequest{}) - if err != nil { - return err - } - - return clientCtx.PrintProto(res) - }, - } - - flags.AddQueryFlagsToCmd(cmd) - - return cmd -} diff --git a/x/incentive/client/cli/tx.go b/x/incentive/client/cli/tx.go index b06fcb1dc..bffb52df6 100644 --- a/x/incentive/client/cli/tx.go +++ b/x/incentive/client/cli/tx.go @@ -30,6 +30,9 @@ func GetTxCmd() *cobra.Command { RunE: client.ValidateCmd, } + cmd.AddCommand(CmdSetWithdrawAddress()) + cmd.AddCommand(CmdWithdrawValidatorCommission()) + cmd.AddCommand(CmdWithdrawDelegatorReward()) // this line is used by starport scaffolding # 1 return cmd diff --git a/x/incentive/client/cli/txs.go b/x/incentive/client/cli/txs.go new file mode 100644 index 000000000..18932bbfb --- /dev/null +++ b/x/incentive/client/cli/txs.go @@ -0,0 +1,98 @@ +package cli + +import ( + "strconv" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" + "github.com/elys-network/elys/x/incentive/types" + "github.com/spf13/cobra" +) + +var _ = strconv.Itoa(0) + +func CmdSetWithdrawAddress() *cobra.Command { + cmd := &cobra.Command{ + Use: "set-withdraw-address [delegator-address] [withdraw-address]", + Short: "Broadcast message set-withdraw-address", + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) (err error) { + argWithdrawAddress := args[0] + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + msg := types.NewMsgSetWithdrawAddress( + clientCtx.GetFromAddress().String(), + argWithdrawAddress, + ) + if err := msg.ValidateBasic(); err != nil { + return err + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + +func CmdWithdrawDelegatorReward() *cobra.Command { + cmd := &cobra.Command{ + Use: "withdraw-delegator-reward [validator-address]", + Short: "Broadcast message withdraw-delegator-reward", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) (err error) { + argValidatorAddress := args[0] + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + msg := types.NewMsgWithdrawDelegatorReward( + clientCtx.GetFromAddress().String(), + argValidatorAddress, + ) + if err := msg.ValidateBasic(); err != nil { + return err + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + +func CmdWithdrawValidatorCommission() *cobra.Command { + cmd := &cobra.Command{ + Use: "withdraw-validator-commission", + Short: "Broadcast message withdraw-validator-commission", + Args: cobra.ExactArgs(0), + RunE: func(cmd *cobra.Command, args []string) (err error) { + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + msg := types.NewMsgWithdrawValidatorCommission( + clientCtx.GetFromAddress().String(), + ) + if err := msg.ValidateBasic(); err != nil { + return err + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} diff --git a/x/incentive/genesis.go b/x/incentive/genesis.go deleted file mode 100644 index 588247220..000000000 --- a/x/incentive/genesis.go +++ /dev/null @@ -1,23 +0,0 @@ -package incentive - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/elys-network/elys/x/incentive/keeper" - "github.com/elys-network/elys/x/incentive/types" -) - -// InitGenesis initializes the module's state from a provided genesis state. -func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) { - // this line is used by starport scaffolding # genesis/module/init - k.SetParams(ctx, genState.Params) -} - -// ExportGenesis returns the module's exported genesis -func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { - genesis := types.DefaultGenesis() - genesis.Params = k.GetParams(ctx) - - // this line is used by starport scaffolding # genesis/module/export - - return genesis -} diff --git a/x/incentive/genesis_test.go b/x/incentive/genesis_test.go deleted file mode 100644 index cc27a9f52..000000000 --- a/x/incentive/genesis_test.go +++ /dev/null @@ -1,29 +0,0 @@ -package incentive_test - -import ( - "testing" - - keepertest "github.com/elys-network/elys/testutil/keeper" - "github.com/elys-network/elys/testutil/nullify" - "github.com/elys-network/elys/x/incentive" - "github.com/elys-network/elys/x/incentive/types" - "github.com/stretchr/testify/require" -) - -func TestGenesis(t *testing.T) { - genesisState := types.GenesisState{ - Params: types.DefaultParams(), - - // this line is used by starport scaffolding # genesis/test/state - } - - k, ctx := keepertest.IncentiveKeeper(t) - incentive.InitGenesis(ctx, *k, genesisState) - got := incentive.ExportGenesis(ctx, *k) - require.NotNil(t, got) - - nullify.Fill(&genesisState) - nullify.Fill(got) - - // this line is used by starport scaffolding # genesis/test/assert -} diff --git a/x/incentive/keeper/alias_functions.go b/x/incentive/keeper/alias_functions.go new file mode 100644 index 000000000..1fa7cc790 --- /dev/null +++ b/x/incentive/keeper/alias_functions.go @@ -0,0 +1,22 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + "github.com/elys-network/elys/x/incentive/types" +) + +// get outstanding rewards +func (k Keeper) GetValidatorOutstandingRewardsCoins(ctx sdk.Context, val sdk.ValAddress) sdk.DecCoins { + return k.GetValidatorOutstandingRewards(ctx, val).Rewards +} + +// get the community coins +func (k Keeper) GetFeePoolCommunityCoins(ctx sdk.Context) sdk.DecCoins { + return k.GetFeePool(ctx).CommunityPool +} + +// GetDistributionAccount returns the distribution ModuleAccount +func (k Keeper) GetDistributionAccount(ctx sdk.Context) authtypes.ModuleAccountI { + return k.authKeeper.GetModuleAccount(ctx, types.ModuleName) +} diff --git a/x/incentive/keeper/allocation.go b/x/incentive/keeper/allocation.go new file mode 100644 index 000000000..3c39baa9a --- /dev/null +++ b/x/incentive/keeper/allocation.go @@ -0,0 +1,145 @@ +package keeper + +import ( + "fmt" + + abci "github.com/tendermint/tendermint/abci/types" + + sdk "github.com/cosmos/cosmos-sdk/types" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + "github.com/elys-network/elys/x/incentive/types" +) + +// AllocateTokens handles distribution of the collected fees +// bondedVotes is a list of (validator address, validator voted on last block flag) for all +// validators in the bonded set. +func (k Keeper) AllocateTokens( + ctx sdk.Context, sumPreviousPrecommitPower, totalPreviousPower int64, + previousProposer sdk.ConsAddress, bondedVotes []abci.VoteInfo, +) { + logger := k.Logger(ctx) + + // 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) + feeCollector := k.authKeeper.GetModuleAccount(ctx, k.feeCollectorName) + feesCollectedInt := k.bankKeeper.GetAllBalances(ctx, feeCollector.GetAddress()) + feesCollected := sdk.NewDecCoinsFromCoins(feesCollectedInt...) + + // transfer collected fees to the distribution module account + err := k.bankKeeper.SendCoinsFromModuleToModule(ctx, k.feeCollectorName, types.ModuleName, feesCollectedInt) + if err != nil { + panic(err) + } + + // temporary workaround to keep CanWithdrawInvariant happy + // general discussions here: https://github.com/cosmos/cosmos-sdk/issues/2906#issuecomment-441867634 + feePool := k.GetFeePool(ctx) + if totalPreviousPower == 0 { + feePool.CommunityPool = feePool.CommunityPool.Add(feesCollected...) + k.SetFeePool(ctx, feePool) + return + } + + // calculate fraction votes + previousFractionVotes := sdk.NewDec(sumPreviousPrecommitPower).Quo(sdk.NewDec(totalPreviousPower)) + + // calculate previous proposer reward + baseProposerReward := sdk.ZeroDec() + bonusProposerReward := sdk.ZeroDec() + proposerMultiplier := baseProposerReward.Add(bonusProposerReward.MulTruncate(previousFractionVotes)) + proposerReward := feesCollected.MulDecTruncate(proposerMultiplier) + + // pay previous proposer + remaining := feesCollected + proposerValidator := k.stk.ValidatorByConsAddr(ctx, previousProposer) + + if proposerValidator != nil { + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventTypeProposerReward, + sdk.NewAttribute(sdk.AttributeKeyAmount, proposerReward.String()), + sdk.NewAttribute(types.AttributeKeyValidator, proposerValidator.GetOperator().String()), + ), + ) + + k.AllocateTokensToValidator(ctx, proposerValidator, proposerReward) + remaining = remaining.Sub(proposerReward) + } else { + // previous proposer can be unknown if say, the unbonding period is 1 block, so + // e.g. a validator undelegates at block X, it's removed entirely by + // block X+1's endblock, then X+2 we need to refer to the previous + // proposer for X+1, but we've forgotten about them. + logger.Error(fmt.Sprintf( + "WARNING: Attempt to allocate proposer rewards to unknown proposer %s. "+ + "This should happen only if the proposer unbonded completely within a single block, "+ + "which generally should not happen except in exceptional circumstances (or fuzz testing). "+ + "We recommend you investigate immediately.", + previousProposer.String())) + } + + // calculate fraction allocated to validators + communityTax := k.GetCommunityTax(ctx) + voteMultiplier := sdk.OneDec().Sub(proposerMultiplier).Sub(communityTax) + feeMultiplier := feesCollected.MulDecTruncate(voteMultiplier) + + // allocate tokens proportionally to voting power + // + // TODO: Consider parallelizing later + // + // Ref: https://github.com/cosmos/cosmos-sdk/pull/3099#discussion_r246276376 + for _, vote := range bondedVotes { + validator := k.stk.ValidatorByConsAddr(ctx, vote.Validator.Address) + + // TODO: Consider micro-slashing for missing votes. + // + // Ref: https://github.com/cosmos/cosmos-sdk/issues/2525#issuecomment-430838701 + powerFraction := sdk.NewDec(vote.Validator.Power).QuoTruncate(sdk.NewDec(totalPreviousPower)) + reward := feeMultiplier.MulDecTruncate(powerFraction) + + k.AllocateTokensToValidator(ctx, validator, reward) + remaining = remaining.Sub(reward) + } + + // allocate community funding + feePool.CommunityPool = feePool.CommunityPool.Add(remaining...) + k.SetFeePool(ctx, feePool) +} + +// AllocateTokensToValidator allocate tokens to a particular validator, +// splitting according to commission. +func (k Keeper) AllocateTokensToValidator(ctx sdk.Context, val stakingtypes.ValidatorI, tokens sdk.DecCoins) { + // split tokens between validator and delegators according to commission + commission := tokens.MulDec(val.GetCommission()) + shared := tokens.Sub(commission) + + // update current commission + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventTypeCommission, + sdk.NewAttribute(sdk.AttributeKeyAmount, commission.String()), + sdk.NewAttribute(types.AttributeKeyValidator, val.GetOperator().String()), + ), + ) + currentCommission := k.GetValidatorAccumulatedCommission(ctx, val.GetOperator()) + currentCommission.Commission = currentCommission.Commission.Add(commission...) + k.SetValidatorAccumulatedCommission(ctx, val.GetOperator(), currentCommission) + + // update current rewards + currentRewards := k.GetValidatorCurrentRewards(ctx, val.GetOperator()) + currentRewards.Rewards = currentRewards.Rewards.Add(shared...) + k.SetValidatorCurrentRewards(ctx, val.GetOperator(), currentRewards) + + // update outstanding rewards + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventTypeRewards, + sdk.NewAttribute(sdk.AttributeKeyAmount, tokens.String()), + sdk.NewAttribute(types.AttributeKeyValidator, val.GetOperator().String()), + ), + ) + + outstanding := k.GetValidatorOutstandingRewards(ctx, val.GetOperator()) + outstanding.Rewards = outstanding.Rewards.Add(tokens...) + k.SetValidatorOutstandingRewards(ctx, val.GetOperator(), outstanding) +} diff --git a/x/incentive/keeper/delegation.go b/x/incentive/keeper/delegation.go new file mode 100644 index 000000000..6fe572c6f --- /dev/null +++ b/x/incentive/keeper/delegation.go @@ -0,0 +1,213 @@ +package keeper + +import ( + "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + "github.com/elys-network/elys/x/incentive/types" +) + +// initialize starting info for a new delegation +func (k Keeper) initializeDelegation(ctx sdk.Context, val sdk.ValAddress, del sdk.AccAddress) { + // period has already been incremented - we want to store the period ended by this delegation action + previousPeriod := k.GetValidatorCurrentRewards(ctx, val).Period - 1 + + // increment reference count for the period we're going to track + k.incrementReferenceCount(ctx, val, previousPeriod) + + validator := k.stk.Validator(ctx, val) + delegation := k.stk.Delegation(ctx, del, val) + + // calculate delegation stake in tokens + // we don't store directly, so multiply delegation shares * (tokens per share) + // note: necessary to truncate so we don't allow withdrawing more rewards than owed + stake := validator.TokensFromSharesTruncated(delegation.GetShares()) + k.SetDelegatorStartingInfo(ctx, val, del, types.NewDelegatorStartingInfo(previousPeriod, stake, uint64(ctx.BlockHeight()))) +} + +// calculate the rewards accrued by a delegation between two periods +func (k Keeper) calculateDelegationRewardsBetween(ctx sdk.Context, val stakingtypes.ValidatorI, + startingPeriod, endingPeriod uint64, stake sdk.Dec, +) (rewards sdk.DecCoins) { + // sanity check + if startingPeriod > endingPeriod { + panic("startingPeriod cannot be greater than endingPeriod") + } + + // sanity check + if stake.IsNegative() { + panic("stake should not be negative") + } + + // return staking * (ending - starting) + starting := k.GetValidatorHistoricalRewards(ctx, val.GetOperator(), startingPeriod) + ending := k.GetValidatorHistoricalRewards(ctx, val.GetOperator(), endingPeriod) + difference := ending.CumulativeRewardRatio.Sub(starting.CumulativeRewardRatio) + if difference.IsAnyNegative() { + panic("negative rewards should not be possible") + } + // note: necessary to truncate so we don't allow withdrawing more rewards than owed + rewards = difference.MulDecTruncate(stake) + return +} + +// calculate the total rewards accrued by a delegation +func (k Keeper) CalculateDelegationRewards(ctx sdk.Context, val stakingtypes.ValidatorI, del stakingtypes.DelegationI, endingPeriod uint64) (rewards sdk.DecCoins) { + // fetch starting info for delegation + startingInfo := k.GetDelegatorStartingInfo(ctx, del.GetValidatorAddr(), del.GetDelegatorAddr()) + + if startingInfo.Height == uint64(ctx.BlockHeight()) { + // started this height, no rewards yet + return + } + + startingPeriod := startingInfo.PreviousPeriod + stake := startingInfo.Stake + + // Iterate through slashes and withdraw with calculated staking for + // distribution periods. These period offsets are dependent on *when* slashes + // happen - namely, in BeginBlock, after rewards are allocated... + // Slashes which happened in the first block would have been before this + // delegation existed, UNLESS they were slashes of a redelegation to this + // validator which was itself slashed (from a fault committed by the + // redelegation source validator) earlier in the same BeginBlock. + startingHeight := startingInfo.Height + // Slashes this block happened after reward allocation, but we have to account + // for them for the stake sanity check below. + endingHeight := uint64(ctx.BlockHeight()) + if endingHeight > startingHeight { + k.IterateValidatorSlashEventsBetween(ctx, del.GetValidatorAddr(), startingHeight, endingHeight, + func(height uint64, event types.ValidatorSlashEvent) (stop bool) { + endingPeriod := event.ValidatorPeriod + if endingPeriod > startingPeriod { + rewards = rewards.Add(k.calculateDelegationRewardsBetween(ctx, val, startingPeriod, endingPeriod, stake)...) + + // Note: It is necessary to truncate so we don't allow withdrawing + // more rewards than owed. + stake = stake.MulTruncate(sdk.OneDec().Sub(event.Fraction)) + startingPeriod = endingPeriod + } + return false + }, + ) + } + + // A total stake sanity check; Recalculated final stake should be less than or + // equal to current stake here. We cannot use Equals because stake is truncated + // when multiplied by slash fractions (see above). We could only use equals if + // we had arbitrary-precision rationals. + currentStake := val.TokensFromShares(del.GetShares()) + + if stake.GT(currentStake) { + // AccountI for rounding inconsistencies between: + // + // currentStake: calculated as in staking with a single computation + // stake: calculated as an accumulation of stake + // calculations across validator's distribution periods + // + // These inconsistencies are due to differing order of operations which + // will inevitably have different accumulated rounding and may lead to + // the smallest decimal place being one greater in stake than + // currentStake. When we calculated slashing by period, even if we + // round down for each slash fraction, it's possible due to how much is + // being rounded that we slash less when slashing by period instead of + // for when we slash without periods. In other words, the single slash, + // and the slashing by period could both be rounding down but the + // slashing by period is simply rounding down less, thus making stake > + // currentStake + // + // A small amount of this error is tolerated and corrected for, + // however any greater amount should be considered a breach in expected + // behaviour. + marginOfErr := sdk.SmallestDec().MulInt64(3) + if stake.LTE(currentStake.Add(marginOfErr)) { + stake = currentStake + } else { + panic(fmt.Sprintf("calculated final stake for delegator %s greater than current stake"+ + "\n\tfinal stake:\t%s"+ + "\n\tcurrent stake:\t%s", + del.GetDelegatorAddr(), stake, currentStake)) + } + } + + // calculate rewards for final period + rewards = rewards.Add(k.calculateDelegationRewardsBetween(ctx, val, startingPeriod, endingPeriod, stake)...) + return rewards +} + +func (k Keeper) withdrawDelegationRewards(ctx sdk.Context, val stakingtypes.ValidatorI, del stakingtypes.DelegationI) (sdk.Coins, error) { + // check existence of delegator starting info + if !k.HasDelegatorStartingInfo(ctx, del.GetValidatorAddr(), del.GetDelegatorAddr()) { + return nil, types.ErrEmptyDelegationDistInfo + } + + // end current period and calculate rewards + endingPeriod := k.IncrementValidatorPeriod(ctx, val) + rewardsRaw := k.CalculateDelegationRewards(ctx, val, del, endingPeriod) + outstanding := k.GetValidatorOutstandingRewardsCoins(ctx, del.GetValidatorAddr()) + + // defensive edge case may happen on the very final digits + // of the decCoins due to operation order of the distribution mechanism. + rewards := rewardsRaw.Intersect(outstanding) + if !rewards.IsEqual(rewardsRaw) { + logger := k.Logger(ctx) + logger.Info( + "rounding error withdrawing rewards from validator", + "delegator", del.GetDelegatorAddr().String(), + "validator", val.GetOperator().String(), + "got", rewards.String(), + "expected", rewardsRaw.String(), + ) + } + + // truncate reward dec coins, return remainder to community pool + finalRewards, remainder := rewards.TruncateDecimal() + + // add coins to user account + if !finalRewards.IsZero() { + withdrawAddr := k.GetDelegatorWithdrawAddr(ctx, del.GetDelegatorAddr()) + // Convert Elys to USDC and send + err := k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, withdrawAddr, finalRewards) + if err != nil { + return nil, err + } + } + + // update the outstanding rewards and the community pool only if the + // transaction was successful + k.SetValidatorOutstandingRewards(ctx, del.GetValidatorAddr(), types.ValidatorOutstandingRewards{Rewards: outstanding.Sub(rewards)}) + feePool := k.GetFeePool(ctx) + feePool.CommunityPool = feePool.CommunityPool.Add(remainder...) + k.SetFeePool(ctx, feePool) + + // decrement reference count of starting period + startingInfo := k.GetDelegatorStartingInfo(ctx, del.GetValidatorAddr(), del.GetDelegatorAddr()) + startingPeriod := startingInfo.PreviousPeriod + k.decrementReferenceCount(ctx, del.GetValidatorAddr(), startingPeriod) + + // remove delegator starting info + k.DeleteDelegatorStartingInfo(ctx, del.GetValidatorAddr(), del.GetDelegatorAddr()) + + emittedRewards := finalRewards + if finalRewards.IsZero() { + baseDenom, _ := sdk.GetBaseDenom() + if baseDenom == "" { + baseDenom = sdk.DefaultBondDenom + } + + // Note, we do not call the NewCoins constructor as we do not want the zero + // coin removed. + emittedRewards = sdk.Coins{sdk.NewCoin(baseDenom, sdk.ZeroInt())} + } + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventTypeWithdrawRewards, + sdk.NewAttribute(sdk.AttributeKeyAmount, emittedRewards.String()), + sdk.NewAttribute(types.AttributeKeyValidator, val.GetOperator().String()), + ), + ) + + return finalRewards, nil +} diff --git a/x/incentive/keeper/fee_pool.go b/x/incentive/keeper/fee_pool.go new file mode 100644 index 000000000..a60475013 --- /dev/null +++ b/x/incentive/keeper/fee_pool.go @@ -0,0 +1,30 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/distribution/types" +) + +// DistributeFromFeePool distributes funds from the distribution module account to +// a receiver address while updating the community pool +func (k Keeper) DistributeFromFeePool(ctx sdk.Context, amount sdk.Coins, receiveAddr sdk.AccAddress) error { + feePool := k.GetFeePool(ctx) + + // NOTE the community pool isn't a module account, however its coins + // are held in the distribution module account. Thus the community pool + // must be reduced separately from the SendCoinsFromModuleToAccount call + newPool, negative := feePool.CommunityPool.SafeSub(sdk.NewDecCoinsFromCoins(amount...)) + if negative { + return types.ErrBadDistribution + } + + feePool.CommunityPool = newPool + + err := k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, receiveAddr, amount) + if err != nil { + return err + } + + k.SetFeePool(ctx, feePool) + return nil +} diff --git a/x/incentive/keeper/genesis.go b/x/incentive/keeper/genesis.go new file mode 100644 index 000000000..6741d3839 --- /dev/null +++ b/x/incentive/keeper/genesis.go @@ -0,0 +1,186 @@ +package keeper + +import ( + "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/elys-network/elys/x/incentive/types" +) + +// InitGenesis initializes the module's state from a provided genesis state. +func (k Keeper) InitGenesis(ctx sdk.Context, data types.GenesisState) { + var moduleHoldings sdk.DecCoins + + // this line is used by starport scaffolding # genesis/module/init + k.SetFeePool(ctx, data.FeePool) + k.SetParams(ctx, data.Params) + + for _, dwi := range data.DelegatorWithdrawInfos { + delegatorAddress := sdk.MustAccAddressFromBech32(dwi.DelegatorAddress) + withdrawAddress := sdk.MustAccAddressFromBech32(dwi.WithdrawAddress) + k.SetDelegatorWithdrawAddr(ctx, delegatorAddress, withdrawAddress) + } + + var previousProposer sdk.ConsAddress + if data.PreviousProposer != "" { + var err error + previousProposer, err = sdk.ConsAddressFromBech32(data.PreviousProposer) + if err != nil { + panic(err) + } + } + + k.SetPreviousProposerConsAddr(ctx, previousProposer) + + for _, rew := range data.OutstandingRewards { + valAddr, err := sdk.ValAddressFromBech32(rew.ValidatorAddress) + if err != nil { + panic(err) + } + k.SetValidatorOutstandingRewards(ctx, valAddr, types.ValidatorOutstandingRewards{Rewards: rew.OutstandingRewards}) + moduleHoldings = moduleHoldings.Add(rew.OutstandingRewards...) + } + for _, acc := range data.ValidatorAccumulatedCommissions { + valAddr, err := sdk.ValAddressFromBech32(acc.ValidatorAddress) + if err != nil { + panic(err) + } + k.SetValidatorAccumulatedCommission(ctx, valAddr, acc.Accumulated) + } + for _, his := range data.ValidatorHistoricalRewards { + valAddr, err := sdk.ValAddressFromBech32(his.ValidatorAddress) + if err != nil { + panic(err) + } + k.SetValidatorHistoricalRewards(ctx, valAddr, his.Period, his.Rewards) + } + for _, cur := range data.ValidatorCurrentRewards { + valAddr, err := sdk.ValAddressFromBech32(cur.ValidatorAddress) + if err != nil { + panic(err) + } + k.SetValidatorCurrentRewards(ctx, valAddr, cur.Rewards) + } + for _, del := range data.DelegatorStartingInfos { + valAddr, err := sdk.ValAddressFromBech32(del.ValidatorAddress) + if err != nil { + panic(err) + } + delegatorAddress := sdk.MustAccAddressFromBech32(del.DelegatorAddress) + + k.SetDelegatorStartingInfo(ctx, valAddr, delegatorAddress, del.StartingInfo) + } + for _, evt := range data.ValidatorSlashEvents { + valAddr, err := sdk.ValAddressFromBech32(evt.ValidatorAddress) + if err != nil { + panic(err) + } + k.SetValidatorSlashEvent(ctx, valAddr, evt.Height, evt.Period, evt.ValidatorSlashEvent) + } + + moduleHoldings = moduleHoldings.Add(data.FeePool.CommunityPool...) + moduleHoldingsInt, _ := moduleHoldings.TruncateDecimal() + + // check if the module account exists + moduleAcc := k.GetDistributionAccount(ctx) + if moduleAcc == nil { + panic(fmt.Sprintf("%s module account has not been set", types.ModuleName)) + } + + balances := k.bankKeeper.GetAllBalances(ctx, moduleAcc.GetAddress()) + if balances.IsZero() { + k.authKeeper.SetModuleAccount(ctx, moduleAcc) + } + if !balances.IsEqual(moduleHoldingsInt) { + panic(fmt.Sprintf("distribution module balance does not match the module holdings: %s <-> %s", balances, moduleHoldingsInt)) + } +} + +// ExportGenesis returns the module's exported genesis +func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { + feePool := k.GetFeePool(ctx) + params := k.GetParams(ctx) + + dwi := make([]types.DelegatorWithdrawInfo, 0) + k.IterateDelegatorWithdrawAddrs(ctx, func(del sdk.AccAddress, addr sdk.AccAddress) (stop bool) { + dwi = append(dwi, types.DelegatorWithdrawInfo{ + DelegatorAddress: del.String(), + WithdrawAddress: addr.String(), + }) + return false + }) + + pp := k.GetPreviousProposerConsAddr(ctx) + outstanding := make([]types.ValidatorOutstandingRewardsRecord, 0) + + k.IterateValidatorOutstandingRewards(ctx, + func(addr sdk.ValAddress, rewards types.ValidatorOutstandingRewards) (stop bool) { + outstanding = append(outstanding, types.ValidatorOutstandingRewardsRecord{ + ValidatorAddress: addr.String(), + OutstandingRewards: rewards.Rewards, + }) + return false + }, + ) + + acc := make([]types.ValidatorAccumulatedCommissionRecord, 0) + k.IterateValidatorAccumulatedCommissions(ctx, + func(addr sdk.ValAddress, commission types.ValidatorAccumulatedCommission) (stop bool) { + acc = append(acc, types.ValidatorAccumulatedCommissionRecord{ + ValidatorAddress: addr.String(), + Accumulated: commission, + }) + return false + }, + ) + + his := make([]types.ValidatorHistoricalRewardsRecord, 0) + k.IterateValidatorHistoricalRewards(ctx, + func(val sdk.ValAddress, period uint64, rewards types.ValidatorHistoricalRewards) (stop bool) { + his = append(his, types.ValidatorHistoricalRewardsRecord{ + ValidatorAddress: val.String(), + Period: period, + Rewards: rewards, + }) + return false + }, + ) + + cur := make([]types.ValidatorCurrentRewardsRecord, 0) + k.IterateValidatorCurrentRewards(ctx, + func(val sdk.ValAddress, rewards types.ValidatorCurrentRewards) (stop bool) { + cur = append(cur, types.ValidatorCurrentRewardsRecord{ + ValidatorAddress: val.String(), + Rewards: rewards, + }) + return false + }, + ) + + dels := make([]types.DelegatorStartingInfoRecord, 0) + k.IterateDelegatorStartingInfos(ctx, + func(val sdk.ValAddress, del sdk.AccAddress, info types.DelegatorStartingInfo) (stop bool) { + dels = append(dels, types.DelegatorStartingInfoRecord{ + ValidatorAddress: val.String(), + DelegatorAddress: del.String(), + StartingInfo: info, + }) + return false + }, + ) + + slashes := make([]types.ValidatorSlashEventRecord, 0) + k.IterateValidatorSlashEvents(ctx, + func(val sdk.ValAddress, height uint64, event types.ValidatorSlashEvent) (stop bool) { + slashes = append(slashes, types.ValidatorSlashEventRecord{ + ValidatorAddress: val.String(), + Height: height, + Period: event.ValidatorPeriod, + ValidatorSlashEvent: event, + }) + return false + }, + ) + + return types.NewGenesisState(params, feePool, dwi, pp, outstanding, acc, his, cur, dels, slashes) +} diff --git a/x/incentive/keeper/hooks_staking.go b/x/incentive/keeper/hooks_staking.go index 0d77b2b16..178a22007 100644 --- a/x/incentive/keeper/hooks_staking.go +++ b/x/incentive/keeper/hooks_staking.go @@ -13,7 +13,9 @@ func (k Keeper) BeforeDelegationCreated(ctx sdk.Context, delAddr sdk.AccAddress, return nil } - k.cmk.StandardStakingToken(ctx, delAddr.String(), types.Eden) + // Create an entity in commitment module + k.cmk.StandardStakingToken(ctx, delAddr.String(), valAddr.String(), types.Eden) + return nil } @@ -49,6 +51,8 @@ func (k Keeper) StakingHooks() StakingHooks { // staking StakingHooks // Must be called when a validator is created func (h StakingHooks) AfterValidatorCreated(ctx sdk.Context, valAddr sdk.ValAddress) error { + val := h.k.stk.Validator(ctx, valAddr) + h.k.initializeValidator(ctx, val) return nil } @@ -59,6 +63,56 @@ func (h StakingHooks) BeforeValidatorModified(ctx sdk.Context, valAddr sdk.ValAd // Must be called when a validator is deleted func (h StakingHooks) AfterValidatorRemoved(ctx sdk.Context, consAddr sdk.ConsAddress, valAddr sdk.ValAddress) error { + // fetch outstanding + outstanding := h.k.GetValidatorOutstandingRewardsCoins(ctx, valAddr) + + // force-withdraw commission + commission := h.k.GetValidatorAccumulatedCommission(ctx, valAddr).Commission + if !commission.IsZero() { + // subtract from outstanding + outstanding = outstanding.Sub(commission) + + // split into integral & remainder + coins, remainder := commission.TruncateDecimal() + + // remainder to community pool + feePool := h.k.GetFeePool(ctx) + feePool.CommunityPool = feePool.CommunityPool.Add(remainder...) + h.k.SetFeePool(ctx, feePool) + + // add to validator account + if !coins.IsZero() { + accAddr := sdk.AccAddress(valAddr) + withdrawAddr := h.k.GetDelegatorWithdrawAddr(ctx, accAddr) + // Convert Elys to USDC and send + if err := h.k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, withdrawAddr, coins); err != nil { + return err + } + } + } + + // Add outstanding to community pool + // The validator is removed only after it has no more delegations. + // This operation sends only the remaining dust to the community pool. + feePool := h.k.GetFeePool(ctx) + feePool.CommunityPool = feePool.CommunityPool.Add(outstanding...) + h.k.SetFeePool(ctx, feePool) + + // delete outstanding + h.k.DeleteValidatorOutstandingRewards(ctx, valAddr) + + // remove commission record + h.k.DeleteValidatorAccumulatedCommission(ctx, valAddr) + + // clear slashes + h.k.DeleteValidatorSlashEvents(ctx, valAddr) + + // clear historical rewards + h.k.DeleteValidatorHistoricalRewards(ctx, valAddr) + + // clear current rewards + h.k.DeleteValidatorCurrentRewards(ctx, valAddr) + return nil } @@ -74,11 +128,20 @@ func (h StakingHooks) AfterValidatorBeginUnbonding(ctx sdk.Context, consAddr sdk // Must be called when a delegation is created func (h StakingHooks) BeforeDelegationCreated(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) error { + val := h.k.stk.Validator(ctx, valAddr) + _ = h.k.IncrementValidatorPeriod(ctx, val) return h.k.BeforeDelegationCreated(ctx, delAddr, valAddr) } // Must be called when a delegation's shares are modified func (h StakingHooks) BeforeDelegationSharesModified(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) error { + val := h.k.stk.Validator(ctx, valAddr) + del := h.k.stk.Delegation(ctx, delAddr, valAddr) + + if _, err := h.k.withdrawDelegationRewards(ctx, val, del); err != nil { + return err + } + return h.k.BeforeDelegationSharesModified(ctx, delAddr, valAddr) } @@ -88,9 +151,13 @@ func (h StakingHooks) BeforeDelegationRemoved(ctx sdk.Context, delAddr sdk.AccAd } func (h StakingHooks) AfterDelegationModified(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) error { + h.k.initializeDelegation(ctx, valAddr, delAddr) + return h.k.AfterDelegationModified(ctx, delAddr, valAddr) } func (h StakingHooks) BeforeValidatorSlashed(ctx sdk.Context, valAddr sdk.ValAddress, fraction sdk.Dec) error { + h.k.updateValidatorSlashFraction(ctx, valAddr, fraction) + return nil } diff --git a/x/incentive/keeper/keeper.go b/x/incentive/keeper/keeper.go index c241ce9d6..6fdfe1ac0 100644 --- a/x/incentive/keeper/keeper.go +++ b/x/incentive/keeper/keeper.go @@ -10,6 +10,8 @@ import ( paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" "github.com/tendermint/tendermint/libs/log" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + stypes "github.com/cosmos/cosmos-sdk/x/staking/types" ctypes "github.com/elys-network/elys/x/commitment/types" etypes "github.com/elys-network/elys/x/epochs/types" "github.com/elys-network/elys/x/incentive/types" @@ -24,6 +26,10 @@ type ( cmk types.CommitmentKeeper stk types.StakingKeeper tci *types.TotalCommitmentInfo + authKeeper types.AccountKeeper + bankKeeper types.BankKeeper + + feeCollectorName string // name of the FeeCollector ModuleAccount } ) @@ -34,6 +40,9 @@ func NewKeeper( ps paramtypes.Subspace, ck types.CommitmentKeeper, sk types.StakingKeeper, + ak types.AccountKeeper, + bk types.BankKeeper, + feeCollectorName string, ) *Keeper { // set KeyTable if it has not already been set if !ps.HasKeyTable() { @@ -41,13 +50,16 @@ func NewKeeper( } return &Keeper{ - cdc: cdc, - storeKey: storeKey, - memKey: memKey, - paramstore: ps, - cmk: ck, - stk: sk, - tci: &types.TotalCommitmentInfo{}, + cdc: cdc, + storeKey: storeKey, + memKey: memKey, + paramstore: ps, + cmk: ck, + stk: sk, + tci: &types.TotalCommitmentInfo{}, + feeCollectorName: feeCollectorName, + authKeeper: ak, + bankKeeper: bk, } } @@ -175,6 +187,12 @@ func (k Keeper) UpdateUncommittedTokens(ctx sdk.Context, epochIdentifier string, // Calculate new uncommitted Eden tokens for LP, staker, and Eden token holders newUncommittedEdenTokens := k.CalculateNewUncommittedEdenTokens(ctx, delegatedAmt, commitments, edenAmountPerEpoch) + // Give commission to validators + totalCommissionGiven := k.GiveCommissionToValidators(ctx, creator, delegatedAmt, newUncommittedEdenTokens) + + // Minus the given amount and increase with the remains only + newUncommittedEdenTokens = newUncommittedEdenTokens.Sub(totalCommissionGiven) + // Calculate new uncommitted Eden-Boost tokens for staker and Eden token holders newUncommittedEdenBoostTokens := k.CalculateNewUncommittedEdenBoostTokens(ctx, delegatedAmt, commitments, epochIdentifier, edenBoostAPR) @@ -224,7 +242,7 @@ func (k Keeper) CalculateNewUncommittedEdenBoostTokens(ctx sdk.Context, delegate // Get eden commitments edenCommitted := commitments.GetCommittedAmountForDenom(types.Eden) - // Gompute eden reward based on above and param factors for each + // Compute eden reward based on above and param factors for each totalEden := delegatedAmt.Add(edenCommitted) // Calculate edenBoostAPR % APR for eden boost @@ -271,3 +289,162 @@ func (k Keeper) UpdateEdenBoostTokens(commitments *ctypes.Commitments, new_uncom uncommittedEdenBoost.Amount = uncommittedEdenBoost.Amount.Add(new_uncommitted_eden_boost_tokens) } } + +// Increase uncommitted token amount for the corresponding validator +func (k Keeper) UpdateEdenTokensForValidator(ctx sdk.Context, validator string, new_uncommitted_eden_tokens sdk.Int) { + commitments, bfound := k.cmk.GetCommitments(ctx, validator) + if !bfound { + return + } + + // Get record for uncommitted eden + uncommittedEden, found := commitments.GetUncommittedTokensForDenom(types.Eden) + if !found { + uncommittedTokens := commitments.GetUncommittedTokens() + uncommittedTokens = append(uncommittedTokens, &ctypes.UncommittedTokens{ + Denom: types.Eden, + Amount: new_uncommitted_eden_tokens, + }) + commitments.UncommittedTokens = uncommittedTokens + } else { + uncommittedEden.Amount = uncommittedEden.Amount.Add(new_uncommitted_eden_tokens) + } + + // Update commmitment + k.cmk.SetCommitments(ctx, commitments) +} + +// Give commissions to validators +func (k Keeper) GiveCommissionToValidators(ctx sdk.Context, delegator string, totalDelegationAmt sdk.Int, newUncommittedAmt sdk.Int) sdk.Int { + delAdr, err := sdk.AccAddressFromBech32(delegator) + if err != nil { + return sdk.ZeroInt() + } + + // Total Eden given + totalGiven := sdk.ZeroInt() + + // Iterate all delegated validators + k.stk.IterateDelegations(ctx, delAdr, func(index int64, del stypes.DelegationI) (stop bool) { + valAddr := del.GetValidatorAddr() + // Get validator + val := k.stk.Validator(ctx, valAddr) + // Get commission rate + comm_rate := val.GetCommission() + // Get delegator share + shares := del.GetShares() + // Get token amount delegated + delegatedAmt := val.TokensFromSharesTruncated(shares) + + // to give = delegated amount / total delegation * newly minted eden * commission rate / 100 + commission := delegatedAmt.QuoInt(totalDelegationAmt).MulInt(newUncommittedAmt).Mul(comm_rate).QuoInt(sdk.NewInt(100)) + // Sum total commission given + totalGiven = totalGiven.Add(commission.TruncateInt()) + + // increase uncomitted token amount of validator's commitment + k.UpdateEdenTokensForValidator(ctx, valAddr.String(), commission.TruncateInt()) + + return false + }) + + return totalGiven +} + +// SetWithdrawAddr sets a new address that will receive the rewards upon withdrawal +func (k Keeper) SetWithdrawAddr(ctx sdk.Context, delegatorAddr sdk.AccAddress, withdrawAddr sdk.AccAddress) error { + if k.bankKeeper.BlockedAddr(withdrawAddr) { + return sdkerrors.Wrapf(sdkerrors.ErrUnauthorized, "%s is not allowed to receive external funds", withdrawAddr) + } + + if !k.GetWithdrawAddrEnabled(ctx) { + return types.ErrSetWithdrawAddrDisabled + } + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventTypeSetWithdrawAddress, + sdk.NewAttribute(types.AttributeKeyWithdrawAddress, withdrawAddr.String()), + ), + ) + + k.SetDelegatorWithdrawAddr(ctx, delegatorAddr, withdrawAddr) + return nil +} + +// withdraw rewards from a delegation +func (k Keeper) WithdrawDelegationRewards(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) (sdk.Coins, error) { + val := k.stk.Validator(ctx, valAddr) + if val == nil { + return nil, types.ErrNoValidatorDistInfo + } + + del := k.stk.Delegation(ctx, delAddr, valAddr) + if del == nil { + return nil, types.ErrEmptyDelegationDistInfo + } + + // withdraw rewards + rewards, err := k.withdrawDelegationRewards(ctx, val, del) + if err != nil { + return nil, err + } + + if rewards.IsZero() { + baseDenom, _ := sdk.GetBaseDenom() + rewards = sdk.Coins{sdk.Coin{ + Denom: baseDenom, + Amount: sdk.ZeroInt(), + }} + } + + // reinitialize the delegation + k.initializeDelegation(ctx, valAddr, delAddr) + return rewards, nil +} + +// withdraw validator commission +func (k Keeper) WithdrawValidatorCommission(ctx sdk.Context, valAddr sdk.ValAddress) (sdk.Coins, error) { + // fetch validator accumulated commission + accumCommission := k.GetValidatorAccumulatedCommission(ctx, valAddr) + if accumCommission.Commission.IsZero() { + return nil, types.ErrNoValidatorCommission + } + + commission, remainder := accumCommission.Commission.TruncateDecimal() + k.SetValidatorAccumulatedCommission(ctx, valAddr, types.ValidatorAccumulatedCommission{Commission: remainder}) // leave remainder to withdraw later + + // update outstanding + outstanding := k.GetValidatorOutstandingRewards(ctx, valAddr).Rewards + k.SetValidatorOutstandingRewards(ctx, valAddr, types.ValidatorOutstandingRewards{Rewards: outstanding.Sub(sdk.NewDecCoinsFromCoins(commission...))}) + + if !commission.IsZero() { + accAddr := sdk.AccAddress(valAddr) + withdrawAddr := k.GetDelegatorWithdrawAddr(ctx, accAddr) + // Convert Elys to USDC and send + err := k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, withdrawAddr, commission) + if err != nil { + return nil, err + } + } + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventTypeWithdrawCommission, + sdk.NewAttribute(sdk.AttributeKeyAmount, commission.String()), + ), + ) + + return commission, nil +} + +// GetTotalRewards returns the total amount of fee distribution rewards held in the store +func (k Keeper) GetTotalRewards(ctx sdk.Context) (totalRewards sdk.DecCoins) { + k.IterateValidatorOutstandingRewards(ctx, + func(_ sdk.ValAddress, rewards types.ValidatorOutstandingRewards) (stop bool) { + totalRewards = totalRewards.Add(rewards.Rewards...) + return false + }, + ) + + return totalRewards +} diff --git a/x/incentive/keeper/msg_servers.go b/x/incentive/keeper/msg_servers.go new file mode 100644 index 000000000..e9fd42448 --- /dev/null +++ b/x/incentive/keeper/msg_servers.go @@ -0,0 +1,110 @@ +package keeper + +import ( + "context" + + "github.com/armon/go-metrics" + "github.com/cosmos/cosmos-sdk/telemetry" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/elys-network/elys/x/incentive/types" +) + +func (k msgServer) SetWithdrawAddress(goCtx context.Context, msg *types.MsgSetWithdrawAddress) (*types.MsgSetWithdrawAddressResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + delegatorAddress, err := sdk.AccAddressFromBech32(msg.DelegatorAddress) + if err != nil { + return nil, err + } + withdrawAddress, err := sdk.AccAddressFromBech32(msg.WithdrawAddress) + if err != nil { + return nil, err + } + err = k.SetWithdrawAddr(ctx, delegatorAddress, withdrawAddress) + if err != nil { + return nil, err + } + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + sdk.NewAttribute(sdk.AttributeKeySender, msg.DelegatorAddress), + ), + ) + + return &types.MsgSetWithdrawAddressResponse{}, nil +} + +func (k msgServer) WithdrawDelegatorReward(goCtx context.Context, msg *types.MsgWithdrawDelegatorReward) (*types.MsgWithdrawDelegatorRewardResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + valAddr, err := sdk.ValAddressFromBech32(msg.ValidatorAddress) + if err != nil { + return nil, err + } + delegatorAddress, err := sdk.AccAddressFromBech32(msg.DelegatorAddress) + if err != nil { + return nil, err + } + amount, err := k.WithdrawDelegationRewards(ctx, delegatorAddress, valAddr) + if err != nil { + return nil, err + } + + defer func() { + for _, a := range amount { + if a.Amount.IsInt64() { + telemetry.SetGaugeWithLabels( + []string{"tx", "msg", "withdraw_reward"}, + float32(a.Amount.Int64()), + []metrics.Label{telemetry.NewLabel("denom", a.Denom)}, + ) + } + } + }() + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + sdk.NewAttribute(sdk.AttributeKeySender, msg.DelegatorAddress), + ), + ) + return &types.MsgWithdrawDelegatorRewardResponse{Amount: amount}, nil +} + +func (k msgServer) WithdrawValidatorCommission(goCtx context.Context, msg *types.MsgWithdrawValidatorCommission) (*types.MsgWithdrawValidatorCommissionResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + valAddr, err := sdk.ValAddressFromBech32(msg.ValidatorAddress) + if err != nil { + return nil, err + } + amount, err := k.Keeper.WithdrawValidatorCommission(ctx, valAddr) + if err != nil { + return nil, err + } + + defer func() { + for _, a := range amount { + if a.Amount.IsInt64() { + telemetry.SetGaugeWithLabels( + []string{"tx", "msg", "withdraw_commission"}, + float32(a.Amount.Int64()), + []metrics.Label{telemetry.NewLabel("denom", a.Denom)}, + ) + } + } + }() + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + sdk.NewAttribute(sdk.AttributeKeySender, msg.ValidatorAddress), + ), + ) + + return &types.MsgWithdrawValidatorCommissionResponse{Amount: amount}, nil +} diff --git a/x/incentive/keeper/params.go b/x/incentive/keeper/params.go index 631611e7b..91aad7067 100644 --- a/x/incentive/keeper/params.go +++ b/x/incentive/keeper/params.go @@ -7,10 +7,25 @@ import ( // GetParams get all parameters as types.Params func (k Keeper) GetParams(ctx sdk.Context) types.Params { - return types.NewParams() + var params types.Params + k.paramstore.GetParamSet(ctx, ¶ms) + return params } // SetParams set the params func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { k.paramstore.SetParamSet(ctx, ¶ms) } + +// GetCommunityTax returns the current distribution community tax. +func (k Keeper) GetCommunityTax(ctx sdk.Context) (percent sdk.Dec) { + k.paramstore.Get(ctx, types.ParamStoreKeyCommunityTax, &percent) + return percent +} + +// GetWithdrawAddrEnabled returns the current distribution withdraw address +// enabled parameter. +func (k Keeper) GetWithdrawAddrEnabled(ctx sdk.Context) (enabled bool) { + k.paramstore.Get(ctx, types.ParamStoreKeyWithdrawAddrEnabled, &enabled) + return enabled +} diff --git a/x/incentive/keeper/queries.go b/x/incentive/keeper/queries.go new file mode 100644 index 000000000..bbf689d13 --- /dev/null +++ b/x/incentive/keeper/queries.go @@ -0,0 +1,238 @@ +package keeper + +import ( + "context" + + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/cosmos/cosmos-sdk/types/query" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + "github.com/elys-network/elys/x/incentive/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +func (k Keeper) CommunityPool(goCtx context.Context, req *types.QueryCommunityPoolRequest) (*types.QueryCommunityPoolResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + pool := k.GetFeePoolCommunityCoins(ctx) + + return &types.QueryCommunityPoolResponse{Pool: pool}, nil +} + +func (k Keeper) DelegationRewards(goCtx context.Context, req *types.QueryDelegationRewardsRequest) (*types.QueryDelegationRewardsResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + if req.DelegatorAddress == "" { + return nil, status.Error(codes.InvalidArgument, "empty delegator address") + } + + if req.ValidatorAddress == "" { + return nil, status.Error(codes.InvalidArgument, "empty validator address") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + + valAdr, err := sdk.ValAddressFromBech32(req.ValidatorAddress) + if err != nil { + return nil, err + } + + val := k.stk.Validator(ctx, valAdr) + if val == nil { + return nil, sdkerrors.Wrap(types.ErrNoValidatorExists, req.ValidatorAddress) + } + + delAdr, err := sdk.AccAddressFromBech32(req.DelegatorAddress) + if err != nil { + return nil, err + } + del := k.stk.Delegation(ctx, delAdr, valAdr) + if del == nil { + return nil, types.ErrNoDelegationExists + } + + endingPeriod := k.IncrementValidatorPeriod(ctx, val) + rewards := k.CalculateDelegationRewards(ctx, val, del, endingPeriod) + + return &types.QueryDelegationRewardsResponse{Rewards: rewards}, nil +} + +func (k Keeper) DelegationTotalRewards(goCtx context.Context, req *types.QueryDelegationTotalRewardsRequest) (*types.QueryDelegationTotalRewardsResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + if req.DelegatorAddress == "" { + return nil, status.Error(codes.InvalidArgument, "empty delegator address") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + + total := sdk.DecCoins{} + var delRewards []types.DelegationDelegatorReward + + delAdr, err := sdk.AccAddressFromBech32(req.DelegatorAddress) + if err != nil { + return nil, err + } + + k.stk.IterateDelegations( + ctx, delAdr, + func(_ int64, del stakingtypes.DelegationI) (stop bool) { + valAddr := del.GetValidatorAddr() + val := k.stk.Validator(ctx, valAddr) + endingPeriod := k.IncrementValidatorPeriod(ctx, val) + delReward := k.CalculateDelegationRewards(ctx, val, del, endingPeriod) + + delRewards = append(delRewards, types.NewDelegationDelegatorReward(valAddr, delReward)) + total = total.Add(delReward...) + return false + }, + ) + + return &types.QueryDelegationTotalRewardsResponse{Rewards: delRewards, Total: total}, nil +} + +func (k Keeper) DelegatorValidators(goCtx context.Context, req *types.QueryDelegatorValidatorsRequest) (*types.QueryDelegatorValidatorsResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + if req.DelegatorAddress == "" { + return nil, status.Error(codes.InvalidArgument, "empty delegator address") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + delAdr, err := sdk.AccAddressFromBech32(req.DelegatorAddress) + if err != nil { + return nil, err + } + var validators []string + + k.stk.IterateDelegations( + ctx, delAdr, + func(_ int64, del stakingtypes.DelegationI) (stop bool) { + validators = append(validators, del.GetValidatorAddr().String()) + return false + }, + ) + + return &types.QueryDelegatorValidatorsResponse{Validators: validators}, nil +} + +func (k Keeper) DelegatorWithdrawAddress(goCtx context.Context, req *types.QueryDelegatorWithdrawAddressRequest) (*types.QueryDelegatorWithdrawAddressResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + if req.DelegatorAddress == "" { + return nil, status.Error(codes.InvalidArgument, "empty delegator address") + } + delAdr, err := sdk.AccAddressFromBech32(req.DelegatorAddress) + if err != nil { + return nil, err + } + + ctx := sdk.UnwrapSDKContext(goCtx) + withdrawAddr := k.GetDelegatorWithdrawAddr(ctx, delAdr) + + return &types.QueryDelegatorWithdrawAddressResponse{WithdrawAddress: withdrawAddr.String()}, nil +} + +func (k Keeper) Params(goCtx context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + ctx := sdk.UnwrapSDKContext(goCtx) + + return &types.QueryParamsResponse{Params: k.GetParams(ctx)}, nil +} + +func (k Keeper) ValidatorCommission(goCtx context.Context, req *types.QueryValidatorCommissionRequest) (*types.QueryValidatorCommissionResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + if req.ValidatorAddress == "" { + return nil, status.Error(codes.InvalidArgument, "empty validator address") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + + valAdr, err := sdk.ValAddressFromBech32(req.ValidatorAddress) + if err != nil { + return nil, err + } + commission := k.GetValidatorAccumulatedCommission(ctx, valAdr) + + return &types.QueryValidatorCommissionResponse{Commission: commission}, nil +} + +func (k Keeper) ValidatorOutstandingRewards(goCtx context.Context, req *types.QueryValidatorOutstandingRewardsRequest) (*types.QueryValidatorOutstandingRewardsResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + if req.ValidatorAddress == "" { + return nil, status.Error(codes.InvalidArgument, "empty validator address") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + + valAdr, err := sdk.ValAddressFromBech32(req.ValidatorAddress) + if err != nil { + return nil, err + } + rewards := k.GetValidatorOutstandingRewards(ctx, valAdr) + + return &types.QueryValidatorOutstandingRewardsResponse{Rewards: rewards}, nil +} + +func (k Keeper) ValidatorSlashes(goCtx context.Context, req *types.QueryValidatorSlashesRequest) (*types.QueryValidatorSlashesResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + if req.ValidatorAddress == "" { + return nil, status.Error(codes.InvalidArgument, "empty validator address") + } + + if req.EndingHeight < req.StartingHeight { + return nil, status.Errorf(codes.InvalidArgument, "starting height greater than ending height (%d > %d)", req.StartingHeight, req.EndingHeight) + } + + ctx := sdk.UnwrapSDKContext(goCtx) + store := ctx.KVStore(k.storeKey) + valAddr, err := sdk.ValAddressFromBech32(req.ValidatorAddress) + if err != nil { + return nil, status.Errorf(codes.InvalidArgument, "invalid validator address") + } + slashesStore := prefix.NewStore(store, types.GetValidatorSlashEventPrefix(valAddr)) + + events, pageRes, err := query.GenericFilteredPaginate(k.cdc, slashesStore, req.Pagination, func(key []byte, result *types.ValidatorSlashEvent) (*types.ValidatorSlashEvent, error) { + if result.ValidatorPeriod < req.StartingHeight || result.ValidatorPeriod > req.EndingHeight { + return nil, nil + } + + return result, nil + }, func() *types.ValidatorSlashEvent { + return &types.ValidatorSlashEvent{} + }) + if err != nil { + return nil, err + } + + slashes := []types.ValidatorSlashEvent{} + for _, event := range events { + slashes = append(slashes, *event) + } + + return &types.QueryValidatorSlashesResponse{Slashes: slashes, Pagination: pageRes}, nil +} diff --git a/x/incentive/keeper/query_params.go b/x/incentive/keeper/query_params.go deleted file mode 100644 index 8daf94d67..000000000 --- a/x/incentive/keeper/query_params.go +++ /dev/null @@ -1,19 +0,0 @@ -package keeper - -import ( - "context" - - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/elys-network/elys/x/incentive/types" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" -) - -func (k Keeper) Params(goCtx context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "invalid request") - } - ctx := sdk.UnwrapSDKContext(goCtx) - - return &types.QueryParamsResponse{Params: k.GetParams(ctx)}, nil -} diff --git a/x/incentive/keeper/store.go b/x/incentive/keeper/store.go new file mode 100644 index 000000000..64404a0ef --- /dev/null +++ b/x/incentive/keeper/store.go @@ -0,0 +1,385 @@ +package keeper + +import ( + gogotypes "github.com/gogo/protobuf/types" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/elys-network/elys/x/incentive/types" +) + +// get the delegator withdraw address, defaulting to the delegator address +func (k Keeper) GetDelegatorWithdrawAddr(ctx sdk.Context, delAddr sdk.AccAddress) sdk.AccAddress { + store := ctx.KVStore(k.storeKey) + b := store.Get(types.GetDelegatorWithdrawAddrKey(delAddr)) + if b == nil { + return delAddr + } + return sdk.AccAddress(b) +} + +// set the delegator withdraw address +func (k Keeper) SetDelegatorWithdrawAddr(ctx sdk.Context, delAddr, withdrawAddr sdk.AccAddress) { + store := ctx.KVStore(k.storeKey) + store.Set(types.GetDelegatorWithdrawAddrKey(delAddr), withdrawAddr.Bytes()) +} + +// delete a delegator withdraw addr +func (k Keeper) DeleteDelegatorWithdrawAddr(ctx sdk.Context, delAddr, withdrawAddr sdk.AccAddress) { + store := ctx.KVStore(k.storeKey) + store.Delete(types.GetDelegatorWithdrawAddrKey(delAddr)) +} + +// iterate over delegator withdraw addrs +func (k Keeper) IterateDelegatorWithdrawAddrs(ctx sdk.Context, handler func(del sdk.AccAddress, addr sdk.AccAddress) (stop bool)) { + store := ctx.KVStore(k.storeKey) + iter := sdk.KVStorePrefixIterator(store, types.DelegatorWithdrawAddrPrefix) + defer iter.Close() + for ; iter.Valid(); iter.Next() { + addr := sdk.AccAddress(iter.Value()) + del := types.GetDelegatorWithdrawInfoAddress(iter.Key()) + if handler(del, addr) { + break + } + } +} + +// get the global fee pool distribution info +func (k Keeper) GetFeePool(ctx sdk.Context) (feePool types.FeePool) { + store := ctx.KVStore(k.storeKey) + b := store.Get(types.FeePoolKey) + if b == nil { + panic("Stored fee pool should not have been nil") + } + k.cdc.MustUnmarshal(b, &feePool) + return +} + +// set the global fee pool distribution info +func (k Keeper) SetFeePool(ctx sdk.Context, feePool types.FeePool) { + store := ctx.KVStore(k.storeKey) + b := k.cdc.MustMarshal(&feePool) + store.Set(types.FeePoolKey, b) +} + +// GetPreviousProposerConsAddr returns the proposer consensus address for the +// current block. +func (k Keeper) GetPreviousProposerConsAddr(ctx sdk.Context) sdk.ConsAddress { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.ProposerKey) + if bz == nil { + panic("previous proposer not set") + } + + addrValue := gogotypes.BytesValue{} + k.cdc.MustUnmarshal(bz, &addrValue) + return addrValue.GetValue() +} + +// set the proposer public key for this block +func (k Keeper) SetPreviousProposerConsAddr(ctx sdk.Context, consAddr sdk.ConsAddress) { + store := ctx.KVStore(k.storeKey) + bz := k.cdc.MustMarshal(&gogotypes.BytesValue{Value: consAddr}) + store.Set(types.ProposerKey, bz) +} + +// get the starting info associated with a delegator +func (k Keeper) GetDelegatorStartingInfo(ctx sdk.Context, val sdk.ValAddress, del sdk.AccAddress) (period types.DelegatorStartingInfo) { + store := ctx.KVStore(k.storeKey) + b := store.Get(types.GetDelegatorStartingInfoKey(val, del)) + k.cdc.MustUnmarshal(b, &period) + return +} + +// set the starting info associated with a delegator +func (k Keeper) SetDelegatorStartingInfo(ctx sdk.Context, val sdk.ValAddress, del sdk.AccAddress, period types.DelegatorStartingInfo) { + store := ctx.KVStore(k.storeKey) + b := k.cdc.MustMarshal(&period) + store.Set(types.GetDelegatorStartingInfoKey(val, del), b) +} + +// check existence of the starting info associated with a delegator +func (k Keeper) HasDelegatorStartingInfo(ctx sdk.Context, val sdk.ValAddress, del sdk.AccAddress) bool { + store := ctx.KVStore(k.storeKey) + return store.Has(types.GetDelegatorStartingInfoKey(val, del)) +} + +// delete the starting info associated with a delegator +func (k Keeper) DeleteDelegatorStartingInfo(ctx sdk.Context, val sdk.ValAddress, del sdk.AccAddress) { + store := ctx.KVStore(k.storeKey) + store.Delete(types.GetDelegatorStartingInfoKey(val, del)) +} + +// iterate over delegator starting infos +func (k Keeper) IterateDelegatorStartingInfos(ctx sdk.Context, handler func(val sdk.ValAddress, del sdk.AccAddress, info types.DelegatorStartingInfo) (stop bool)) { + store := ctx.KVStore(k.storeKey) + iter := sdk.KVStorePrefixIterator(store, types.DelegatorStartingInfoPrefix) + defer iter.Close() + for ; iter.Valid(); iter.Next() { + var info types.DelegatorStartingInfo + k.cdc.MustUnmarshal(iter.Value(), &info) + val, del := types.GetDelegatorStartingInfoAddresses(iter.Key()) + if handler(val, del, info) { + break + } + } +} + +// get historical rewards for a particular period +func (k Keeper) GetValidatorHistoricalRewards(ctx sdk.Context, val sdk.ValAddress, period uint64) (rewards types.ValidatorHistoricalRewards) { + store := ctx.KVStore(k.storeKey) + b := store.Get(types.GetValidatorHistoricalRewardsKey(val, period)) + k.cdc.MustUnmarshal(b, &rewards) + return +} + +// set historical rewards for a particular period +func (k Keeper) SetValidatorHistoricalRewards(ctx sdk.Context, val sdk.ValAddress, period uint64, rewards types.ValidatorHistoricalRewards) { + store := ctx.KVStore(k.storeKey) + b := k.cdc.MustMarshal(&rewards) + store.Set(types.GetValidatorHistoricalRewardsKey(val, period), b) +} + +// iterate over historical rewards +func (k Keeper) IterateValidatorHistoricalRewards(ctx sdk.Context, handler func(val sdk.ValAddress, period uint64, rewards types.ValidatorHistoricalRewards) (stop bool)) { + store := ctx.KVStore(k.storeKey) + iter := sdk.KVStorePrefixIterator(store, types.ValidatorHistoricalRewardsPrefix) + defer iter.Close() + for ; iter.Valid(); iter.Next() { + var rewards types.ValidatorHistoricalRewards + k.cdc.MustUnmarshal(iter.Value(), &rewards) + addr, period := types.GetValidatorHistoricalRewardsAddressPeriod(iter.Key()) + if handler(addr, period, rewards) { + break + } + } +} + +// delete a historical reward +func (k Keeper) DeleteValidatorHistoricalReward(ctx sdk.Context, val sdk.ValAddress, period uint64) { + store := ctx.KVStore(k.storeKey) + store.Delete(types.GetValidatorHistoricalRewardsKey(val, period)) +} + +// delete historical rewards for a validator +func (k Keeper) DeleteValidatorHistoricalRewards(ctx sdk.Context, val sdk.ValAddress) { + store := ctx.KVStore(k.storeKey) + iter := sdk.KVStorePrefixIterator(store, types.GetValidatorHistoricalRewardsPrefix(val)) + defer iter.Close() + for ; iter.Valid(); iter.Next() { + store.Delete(iter.Key()) + } +} + +// delete all historical rewards +func (k Keeper) DeleteAllValidatorHistoricalRewards(ctx sdk.Context) { + store := ctx.KVStore(k.storeKey) + iter := sdk.KVStorePrefixIterator(store, types.ValidatorHistoricalRewardsPrefix) + defer iter.Close() + for ; iter.Valid(); iter.Next() { + store.Delete(iter.Key()) + } +} + +// historical reference count (used for testcases) +func (k Keeper) GetValidatorHistoricalReferenceCount(ctx sdk.Context) (count uint64) { + store := ctx.KVStore(k.storeKey) + iter := sdk.KVStorePrefixIterator(store, types.ValidatorHistoricalRewardsPrefix) + defer iter.Close() + for ; iter.Valid(); iter.Next() { + var rewards types.ValidatorHistoricalRewards + k.cdc.MustUnmarshal(iter.Value(), &rewards) + count += uint64(rewards.ReferenceCount) + } + return +} + +// get current rewards for a validator +func (k Keeper) GetValidatorCurrentRewards(ctx sdk.Context, val sdk.ValAddress) (rewards types.ValidatorCurrentRewards) { + store := ctx.KVStore(k.storeKey) + b := store.Get(types.GetValidatorCurrentRewardsKey(val)) + k.cdc.MustUnmarshal(b, &rewards) + return +} + +// set current rewards for a validator +func (k Keeper) SetValidatorCurrentRewards(ctx sdk.Context, val sdk.ValAddress, rewards types.ValidatorCurrentRewards) { + store := ctx.KVStore(k.storeKey) + b := k.cdc.MustMarshal(&rewards) + store.Set(types.GetValidatorCurrentRewardsKey(val), b) +} + +// delete current rewards for a validator +func (k Keeper) DeleteValidatorCurrentRewards(ctx sdk.Context, val sdk.ValAddress) { + store := ctx.KVStore(k.storeKey) + store.Delete(types.GetValidatorCurrentRewardsKey(val)) +} + +// iterate over current rewards +func (k Keeper) IterateValidatorCurrentRewards(ctx sdk.Context, handler func(val sdk.ValAddress, rewards types.ValidatorCurrentRewards) (stop bool)) { + store := ctx.KVStore(k.storeKey) + iter := sdk.KVStorePrefixIterator(store, types.ValidatorCurrentRewardsPrefix) + defer iter.Close() + for ; iter.Valid(); iter.Next() { + var rewards types.ValidatorCurrentRewards + k.cdc.MustUnmarshal(iter.Value(), &rewards) + addr := types.GetValidatorCurrentRewardsAddress(iter.Key()) + if handler(addr, rewards) { + break + } + } +} + +// get accumulated commission for a validator +func (k Keeper) GetValidatorAccumulatedCommission(ctx sdk.Context, val sdk.ValAddress) (commission types.ValidatorAccumulatedCommission) { + store := ctx.KVStore(k.storeKey) + b := store.Get(types.GetValidatorAccumulatedCommissionKey(val)) + if b == nil { + return types.ValidatorAccumulatedCommission{} + } + k.cdc.MustUnmarshal(b, &commission) + return +} + +// set accumulated commission for a validator +func (k Keeper) SetValidatorAccumulatedCommission(ctx sdk.Context, val sdk.ValAddress, commission types.ValidatorAccumulatedCommission) { + var bz []byte + + store := ctx.KVStore(k.storeKey) + if commission.Commission.IsZero() { + bz = k.cdc.MustMarshal(&types.ValidatorAccumulatedCommission{}) + } else { + bz = k.cdc.MustMarshal(&commission) + } + + store.Set(types.GetValidatorAccumulatedCommissionKey(val), bz) +} + +// delete accumulated commission for a validator +func (k Keeper) DeleteValidatorAccumulatedCommission(ctx sdk.Context, val sdk.ValAddress) { + store := ctx.KVStore(k.storeKey) + store.Delete(types.GetValidatorAccumulatedCommissionKey(val)) +} + +// iterate over accumulated commissions +func (k Keeper) IterateValidatorAccumulatedCommissions(ctx sdk.Context, handler func(val sdk.ValAddress, commission types.ValidatorAccumulatedCommission) (stop bool)) { + store := ctx.KVStore(k.storeKey) + iter := sdk.KVStorePrefixIterator(store, types.ValidatorAccumulatedCommissionPrefix) + defer iter.Close() + for ; iter.Valid(); iter.Next() { + var commission types.ValidatorAccumulatedCommission + k.cdc.MustUnmarshal(iter.Value(), &commission) + addr := types.GetValidatorAccumulatedCommissionAddress(iter.Key()) + if handler(addr, commission) { + break + } + } +} + +// get validator outstanding rewards +func (k Keeper) GetValidatorOutstandingRewards(ctx sdk.Context, val sdk.ValAddress) (rewards types.ValidatorOutstandingRewards) { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.GetValidatorOutstandingRewardsKey(val)) + k.cdc.MustUnmarshal(bz, &rewards) + return +} + +// set validator outstanding rewards +func (k Keeper) SetValidatorOutstandingRewards(ctx sdk.Context, val sdk.ValAddress, rewards types.ValidatorOutstandingRewards) { + store := ctx.KVStore(k.storeKey) + b := k.cdc.MustMarshal(&rewards) + store.Set(types.GetValidatorOutstandingRewardsKey(val), b) +} + +// delete validator outstanding rewards +func (k Keeper) DeleteValidatorOutstandingRewards(ctx sdk.Context, val sdk.ValAddress) { + store := ctx.KVStore(k.storeKey) + store.Delete(types.GetValidatorOutstandingRewardsKey(val)) +} + +// iterate validator outstanding rewards +func (k Keeper) IterateValidatorOutstandingRewards(ctx sdk.Context, handler func(val sdk.ValAddress, rewards types.ValidatorOutstandingRewards) (stop bool)) { + store := ctx.KVStore(k.storeKey) + iter := sdk.KVStorePrefixIterator(store, types.ValidatorOutstandingRewardsPrefix) + defer iter.Close() + for ; iter.Valid(); iter.Next() { + rewards := types.ValidatorOutstandingRewards{} + k.cdc.MustUnmarshal(iter.Value(), &rewards) + addr := types.GetValidatorOutstandingRewardsAddress(iter.Key()) + if handler(addr, rewards) { + break + } + } +} + +// get slash event for height +func (k Keeper) GetValidatorSlashEvent(ctx sdk.Context, val sdk.ValAddress, height, period uint64) (event types.ValidatorSlashEvent, found bool) { + store := ctx.KVStore(k.storeKey) + b := store.Get(types.GetValidatorSlashEventKey(val, height, period)) + if b == nil { + return types.ValidatorSlashEvent{}, false + } + k.cdc.MustUnmarshal(b, &event) + return event, true +} + +// set slash event for height +func (k Keeper) SetValidatorSlashEvent(ctx sdk.Context, val sdk.ValAddress, height, period uint64, event types.ValidatorSlashEvent) { + store := ctx.KVStore(k.storeKey) + b := k.cdc.MustMarshal(&event) + store.Set(types.GetValidatorSlashEventKey(val, height, period), b) +} + +// iterate over slash events between heights, inclusive +func (k Keeper) IterateValidatorSlashEventsBetween(ctx sdk.Context, val sdk.ValAddress, startingHeight uint64, endingHeight uint64, + handler func(height uint64, event types.ValidatorSlashEvent) (stop bool), +) { + store := ctx.KVStore(k.storeKey) + iter := store.Iterator( + types.GetValidatorSlashEventKeyPrefix(val, startingHeight), + types.GetValidatorSlashEventKeyPrefix(val, endingHeight+1), + ) + defer iter.Close() + for ; iter.Valid(); iter.Next() { + var event types.ValidatorSlashEvent + k.cdc.MustUnmarshal(iter.Value(), &event) + _, height := types.GetValidatorSlashEventAddressHeight(iter.Key()) + if handler(height, event) { + break + } + } +} + +// iterate over all slash events +func (k Keeper) IterateValidatorSlashEvents(ctx sdk.Context, handler func(val sdk.ValAddress, height uint64, event types.ValidatorSlashEvent) (stop bool)) { + store := ctx.KVStore(k.storeKey) + iter := sdk.KVStorePrefixIterator(store, types.ValidatorSlashEventPrefix) + defer iter.Close() + for ; iter.Valid(); iter.Next() { + var event types.ValidatorSlashEvent + k.cdc.MustUnmarshal(iter.Value(), &event) + val, height := types.GetValidatorSlashEventAddressHeight(iter.Key()) + if handler(val, height, event) { + break + } + } +} + +// delete slash events for a particular validator +func (k Keeper) DeleteValidatorSlashEvents(ctx sdk.Context, val sdk.ValAddress) { + store := ctx.KVStore(k.storeKey) + iter := sdk.KVStorePrefixIterator(store, types.GetValidatorSlashEventPrefix(val)) + defer iter.Close() + for ; iter.Valid(); iter.Next() { + store.Delete(iter.Key()) + } +} + +// delete all slash events +func (k Keeper) DeleteAllValidatorSlashEvents(ctx sdk.Context) { + store := ctx.KVStore(k.storeKey) + iter := sdk.KVStorePrefixIterator(store, types.ValidatorSlashEventPrefix) + defer iter.Close() + for ; iter.Valid(); iter.Next() { + store.Delete(iter.Key()) + } +} diff --git a/x/incentive/keeper/validator.go b/x/incentive/keeper/validator.go new file mode 100644 index 000000000..d8d2bc39f --- /dev/null +++ b/x/incentive/keeper/validator.go @@ -0,0 +1,107 @@ +package keeper + +import ( + "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" + + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + "github.com/elys-network/elys/x/incentive/types" +) + +// initialize rewards for a new validator +func (k Keeper) initializeValidator(ctx sdk.Context, val stakingtypes.ValidatorI) { + // set initial historical rewards (period 0) with reference count of 1 + k.SetValidatorHistoricalRewards(ctx, val.GetOperator(), 0, types.NewValidatorHistoricalRewards(sdk.DecCoins{}, 1)) + + // set current rewards (starting at period 1) + k.SetValidatorCurrentRewards(ctx, val.GetOperator(), types.NewValidatorCurrentRewards(sdk.DecCoins{}, 1)) + + // set accumulated commission + k.SetValidatorAccumulatedCommission(ctx, val.GetOperator(), types.InitialValidatorAccumulatedCommission()) + + // set outstanding rewards + k.SetValidatorOutstandingRewards(ctx, val.GetOperator(), types.ValidatorOutstandingRewards{Rewards: sdk.DecCoins{}}) +} + +// increment validator period, returning the period just ended +func (k Keeper) IncrementValidatorPeriod(ctx sdk.Context, val stakingtypes.ValidatorI) uint64 { + // fetch current rewards + rewards := k.GetValidatorCurrentRewards(ctx, val.GetOperator()) + + // calculate current ratio + var current sdk.DecCoins + if val.GetTokens().IsZero() { + + // can't calculate ratio for zero-token validators + // ergo we instead add to the community pool + feePool := k.GetFeePool(ctx) + outstanding := k.GetValidatorOutstandingRewards(ctx, val.GetOperator()) + feePool.CommunityPool = feePool.CommunityPool.Add(rewards.Rewards...) + outstanding.Rewards = outstanding.GetRewards().Sub(rewards.Rewards) + k.SetFeePool(ctx, feePool) + k.SetValidatorOutstandingRewards(ctx, val.GetOperator(), outstanding) + + current = sdk.DecCoins{} + } else { + // note: necessary to truncate so we don't allow withdrawing more rewards than owed + current = rewards.Rewards.QuoDecTruncate(sdk.NewDecFromInt(val.GetTokens())) + } + + // fetch historical rewards for last period + historical := k.GetValidatorHistoricalRewards(ctx, val.GetOperator(), rewards.Period-1).CumulativeRewardRatio + + // decrement reference count + k.decrementReferenceCount(ctx, val.GetOperator(), rewards.Period-1) + + // set new historical rewards with reference count of 1 + k.SetValidatorHistoricalRewards(ctx, val.GetOperator(), rewards.Period, types.NewValidatorHistoricalRewards(historical.Add(current...), 1)) + + // set current rewards, incrementing period by 1 + k.SetValidatorCurrentRewards(ctx, val.GetOperator(), types.NewValidatorCurrentRewards(sdk.DecCoins{}, rewards.Period+1)) + + return rewards.Period +} + +// increment the reference count for a historical rewards value +func (k Keeper) incrementReferenceCount(ctx sdk.Context, valAddr sdk.ValAddress, period uint64) { + historical := k.GetValidatorHistoricalRewards(ctx, valAddr, period) + if historical.ReferenceCount > 2 { + panic("reference count should never exceed 2") + } + historical.ReferenceCount++ + k.SetValidatorHistoricalRewards(ctx, valAddr, period, historical) +} + +// decrement the reference count for a historical rewards value, and delete if zero references remain +func (k Keeper) decrementReferenceCount(ctx sdk.Context, valAddr sdk.ValAddress, period uint64) { + historical := k.GetValidatorHistoricalRewards(ctx, valAddr, period) + if historical.ReferenceCount == 0 { + panic("cannot set negative reference count") + } + historical.ReferenceCount-- + if historical.ReferenceCount == 0 { + k.DeleteValidatorHistoricalReward(ctx, valAddr, period) + } else { + k.SetValidatorHistoricalRewards(ctx, valAddr, period, historical) + } +} + +func (k Keeper) updateValidatorSlashFraction(ctx sdk.Context, valAddr sdk.ValAddress, fraction sdk.Dec) { + if fraction.GT(sdk.OneDec()) || fraction.IsNegative() { + panic(fmt.Sprintf("fraction must be >=0 and <=1, current fraction: %v", fraction)) + } + + val := k.stk.Validator(ctx, valAddr) + + // increment current period + newPeriod := k.IncrementValidatorPeriod(ctx, val) + + // increment reference count on period we need to track + k.incrementReferenceCount(ctx, valAddr, newPeriod) + + slashEvent := types.NewValidatorSlashEvent(newPeriod, fraction) + height := uint64(ctx.BlockHeight()) + + k.SetValidatorSlashEvent(ctx, valAddr, height, newPeriod, slashEvent) +} diff --git a/x/incentive/module.go b/x/incentive/module.go index 41d9366ff..45f9fcc52 100644 --- a/x/incentive/module.go +++ b/x/incentive/module.go @@ -130,15 +130,14 @@ func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, gs json.Ra var genState types.GenesisState // Initialize global index to index in genesis state cdc.MustUnmarshalJSON(gs, &genState) - - InitGenesis(ctx, am.keeper, genState) + am.keeper.InitGenesis(ctx, genState) return []abci.ValidatorUpdate{} } // ExportGenesis returns the module's exported genesis state as raw JSON bytes. func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { - genState := ExportGenesis(ctx, am.keeper) + genState := am.keeper.ExportGenesis(ctx) return cdc.MustMarshalJSON(genState) } diff --git a/x/incentive/module_simulation.go b/x/incentive/module_simulation.go index 78b81736a..989c1a875 100644 --- a/x/incentive/module_simulation.go +++ b/x/incentive/module_simulation.go @@ -24,7 +24,19 @@ var ( ) const ( -// this line is used by starport scaffolding # simapp/module/const + opWeightMsgSetWithdrawAddress = "op_weight_msg_set_withdraw_address" + // TODO: Determine the simulation weight value + defaultWeightMsgSetWithdrawAddress int = 100 + + opWeightMsgWithdrawValidatorCommission = "op_weight_msg_withdraw_validator_commission" + // TODO: Determine the simulation weight value + defaultWeightMsgWithdrawValidatorCommission int = 100 + + opWeightMsgWithdrawDelegatorReward = "op_weight_msg_withdraw_delegator_reward" + // TODO: Determine the simulation weight value + defaultWeightMsgWithdrawDelegatorReward int = 100 + + // this line is used by starport scaffolding # simapp/module/const ) // GenerateGenesisState creates a randomized GenState of the module @@ -58,6 +70,27 @@ func (am AppModule) RegisterStoreDecoder(_ sdk.StoreDecoderRegistry) {} func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation { operations := make([]simtypes.WeightedOperation, 0) + var weightMsgSetWithdrawAddress int + simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgSetWithdrawAddress, &weightMsgSetWithdrawAddress, nil, + func(_ *rand.Rand) { + weightMsgSetWithdrawAddress = defaultWeightMsgSetWithdrawAddress + }, + ) + + var weightMsgWithdrawValidatorCommission int + simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgWithdrawValidatorCommission, &weightMsgWithdrawValidatorCommission, nil, + func(_ *rand.Rand) { + weightMsgWithdrawValidatorCommission = defaultWeightMsgWithdrawValidatorCommission + }, + ) + + var weightMsgWithdrawDelegatorReward int + simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgWithdrawDelegatorReward, &weightMsgWithdrawDelegatorReward, nil, + func(_ *rand.Rand) { + weightMsgWithdrawDelegatorReward = defaultWeightMsgWithdrawDelegatorReward + }, + ) + // this line is used by starport scaffolding # simapp/module/operation return operations diff --git a/x/incentive/types/codec.go b/x/incentive/types/codec.go index 844157a87..e96a613f7 100644 --- a/x/incentive/types/codec.go +++ b/x/incentive/types/codec.go @@ -3,15 +3,27 @@ package types import ( "github.com/cosmos/cosmos-sdk/codec" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" - // this line is used by starport scaffolding # 1 + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" ) func RegisterCodec(cdc *codec.LegacyAmino) { + cdc.RegisterConcrete(&MsgSetWithdrawAddress{}, "incentive/SetWithdrawAddress", nil) + cdc.RegisterConcrete(&MsgWithdrawValidatorCommission{}, "incentive/WithdrawValidatorCommission", nil) + cdc.RegisterConcrete(&MsgWithdrawDelegatorReward{}, "incentive/WithdrawDelegatorReward", nil) // this line is used by starport scaffolding # 2 } func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { + registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgSetWithdrawAddress{}, + ) + registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgWithdrawValidatorCommission{}, + ) + registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgWithdrawDelegatorReward{}, + ) // this line is used by starport scaffolding # 3 msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) diff --git a/x/incentive/types/delegator.go b/x/incentive/types/delegator.go new file mode 100644 index 000000000..850878660 --- /dev/null +++ b/x/incentive/types/delegator.go @@ -0,0 +1,14 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// create a new DelegatorStartingInfo +func NewDelegatorStartingInfo(previousPeriod uint64, stake sdk.Dec, height uint64) DelegatorStartingInfo { + return DelegatorStartingInfo{ + PreviousPeriod: previousPeriod, + Stake: stake, + Height: height, + } +} diff --git a/x/incentive/types/distribution.pb.go b/x/incentive/types/distribution.pb.go new file mode 100644 index 000000000..7140bbe15 --- /dev/null +++ b/x/incentive/types/distribution.pb.go @@ -0,0 +1,3025 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: elys/incentive/distribution.proto + +package types + +import ( + fmt "fmt" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/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 + +// ValidatorHistoricalRewards represents historical rewards for a validator. +// Height is implicit within the store key. +// Cumulative reward ratio is the sum from the zeroeth period +// until this period of rewards / tokens, per the spec. +// The reference count indicates the number of objects +// which might need to reference this historical entry at any point. +// ReferenceCount = +// +// number of outstanding delegations which ended the associated period (and +// might need to read that record) +// + number of slashes which ended the associated period (and might need to +// read that record) +// + one per validator for the zeroeth period, set on initialization +type ValidatorHistoricalRewards struct { + CumulativeRewardRatio github_com_cosmos_cosmos_sdk_types.DecCoins `protobuf:"bytes,1,rep,name=cumulative_reward_ratio,json=cumulativeRewardRatio,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.DecCoins" json:"cumulative_reward_ratio"` + ReferenceCount uint32 `protobuf:"varint,2,opt,name=reference_count,json=referenceCount,proto3" json:"reference_count,omitempty"` +} + +func (m *ValidatorHistoricalRewards) Reset() { *m = ValidatorHistoricalRewards{} } +func (m *ValidatorHistoricalRewards) String() string { return proto.CompactTextString(m) } +func (*ValidatorHistoricalRewards) ProtoMessage() {} +func (*ValidatorHistoricalRewards) Descriptor() ([]byte, []int) { + return fileDescriptor_4fd7627d4268669e, []int{0} +} +func (m *ValidatorHistoricalRewards) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ValidatorHistoricalRewards) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ValidatorHistoricalRewards.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 *ValidatorHistoricalRewards) XXX_Merge(src proto.Message) { + xxx_messageInfo_ValidatorHistoricalRewards.Merge(m, src) +} +func (m *ValidatorHistoricalRewards) XXX_Size() int { + return m.Size() +} +func (m *ValidatorHistoricalRewards) XXX_DiscardUnknown() { + xxx_messageInfo_ValidatorHistoricalRewards.DiscardUnknown(m) +} + +var xxx_messageInfo_ValidatorHistoricalRewards proto.InternalMessageInfo + +func (m *ValidatorHistoricalRewards) GetCumulativeRewardRatio() github_com_cosmos_cosmos_sdk_types.DecCoins { + if m != nil { + return m.CumulativeRewardRatio + } + return nil +} + +func (m *ValidatorHistoricalRewards) GetReferenceCount() uint32 { + if m != nil { + return m.ReferenceCount + } + return 0 +} + +// ValidatorCurrentRewards represents current rewards and current +// period for a validator kept as a running counter and incremented +// each block as long as the validator's tokens remain constant. +type ValidatorCurrentRewards struct { + Rewards github_com_cosmos_cosmos_sdk_types.DecCoins `protobuf:"bytes,1,rep,name=rewards,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.DecCoins" json:"rewards"` + Period uint64 `protobuf:"varint,2,opt,name=period,proto3" json:"period,omitempty"` +} + +func (m *ValidatorCurrentRewards) Reset() { *m = ValidatorCurrentRewards{} } +func (m *ValidatorCurrentRewards) String() string { return proto.CompactTextString(m) } +func (*ValidatorCurrentRewards) ProtoMessage() {} +func (*ValidatorCurrentRewards) Descriptor() ([]byte, []int) { + return fileDescriptor_4fd7627d4268669e, []int{1} +} +func (m *ValidatorCurrentRewards) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ValidatorCurrentRewards) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ValidatorCurrentRewards.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 *ValidatorCurrentRewards) XXX_Merge(src proto.Message) { + xxx_messageInfo_ValidatorCurrentRewards.Merge(m, src) +} +func (m *ValidatorCurrentRewards) XXX_Size() int { + return m.Size() +} +func (m *ValidatorCurrentRewards) XXX_DiscardUnknown() { + xxx_messageInfo_ValidatorCurrentRewards.DiscardUnknown(m) +} + +var xxx_messageInfo_ValidatorCurrentRewards proto.InternalMessageInfo + +func (m *ValidatorCurrentRewards) GetRewards() github_com_cosmos_cosmos_sdk_types.DecCoins { + if m != nil { + return m.Rewards + } + return nil +} + +func (m *ValidatorCurrentRewards) GetPeriod() uint64 { + if m != nil { + return m.Period + } + return 0 +} + +// ValidatorAccumulatedCommission represents accumulated commission +// for a validator kept as a running counter, can be withdrawn at any time. +type ValidatorAccumulatedCommission struct { + Commission github_com_cosmos_cosmos_sdk_types.DecCoins `protobuf:"bytes,1,rep,name=commission,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.DecCoins" json:"commission"` +} + +func (m *ValidatorAccumulatedCommission) Reset() { *m = ValidatorAccumulatedCommission{} } +func (m *ValidatorAccumulatedCommission) String() string { return proto.CompactTextString(m) } +func (*ValidatorAccumulatedCommission) ProtoMessage() {} +func (*ValidatorAccumulatedCommission) Descriptor() ([]byte, []int) { + return fileDescriptor_4fd7627d4268669e, []int{2} +} +func (m *ValidatorAccumulatedCommission) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ValidatorAccumulatedCommission) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ValidatorAccumulatedCommission.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 *ValidatorAccumulatedCommission) XXX_Merge(src proto.Message) { + xxx_messageInfo_ValidatorAccumulatedCommission.Merge(m, src) +} +func (m *ValidatorAccumulatedCommission) XXX_Size() int { + return m.Size() +} +func (m *ValidatorAccumulatedCommission) XXX_DiscardUnknown() { + xxx_messageInfo_ValidatorAccumulatedCommission.DiscardUnknown(m) +} + +var xxx_messageInfo_ValidatorAccumulatedCommission proto.InternalMessageInfo + +func (m *ValidatorAccumulatedCommission) GetCommission() github_com_cosmos_cosmos_sdk_types.DecCoins { + if m != nil { + return m.Commission + } + return nil +} + +// ValidatorOutstandingRewards represents outstanding (un-withdrawn) rewards +// for a validator inexpensive to track, allows simple sanity checks. +type ValidatorOutstandingRewards struct { + Rewards github_com_cosmos_cosmos_sdk_types.DecCoins `protobuf:"bytes,1,rep,name=rewards,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.DecCoins" json:"rewards"` +} + +func (m *ValidatorOutstandingRewards) Reset() { *m = ValidatorOutstandingRewards{} } +func (m *ValidatorOutstandingRewards) String() string { return proto.CompactTextString(m) } +func (*ValidatorOutstandingRewards) ProtoMessage() {} +func (*ValidatorOutstandingRewards) Descriptor() ([]byte, []int) { + return fileDescriptor_4fd7627d4268669e, []int{3} +} +func (m *ValidatorOutstandingRewards) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ValidatorOutstandingRewards) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ValidatorOutstandingRewards.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 *ValidatorOutstandingRewards) XXX_Merge(src proto.Message) { + xxx_messageInfo_ValidatorOutstandingRewards.Merge(m, src) +} +func (m *ValidatorOutstandingRewards) XXX_Size() int { + return m.Size() +} +func (m *ValidatorOutstandingRewards) XXX_DiscardUnknown() { + xxx_messageInfo_ValidatorOutstandingRewards.DiscardUnknown(m) +} + +var xxx_messageInfo_ValidatorOutstandingRewards proto.InternalMessageInfo + +func (m *ValidatorOutstandingRewards) GetRewards() github_com_cosmos_cosmos_sdk_types.DecCoins { + if m != nil { + return m.Rewards + } + return nil +} + +// ValidatorSlashEvent represents a validator slash event. +// Height is implicit within the store key. +// This is needed to calculate appropriate amount of staking tokens +// for delegations which are withdrawn after a slash has occurred. +type ValidatorSlashEvent struct { + ValidatorPeriod uint64 `protobuf:"varint,1,opt,name=validator_period,json=validatorPeriod,proto3" json:"validator_period,omitempty"` + Fraction github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=fraction,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"fraction"` +} + +func (m *ValidatorSlashEvent) Reset() { *m = ValidatorSlashEvent{} } +func (m *ValidatorSlashEvent) String() string { return proto.CompactTextString(m) } +func (*ValidatorSlashEvent) ProtoMessage() {} +func (*ValidatorSlashEvent) Descriptor() ([]byte, []int) { + return fileDescriptor_4fd7627d4268669e, []int{4} +} +func (m *ValidatorSlashEvent) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ValidatorSlashEvent) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ValidatorSlashEvent.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 *ValidatorSlashEvent) XXX_Merge(src proto.Message) { + xxx_messageInfo_ValidatorSlashEvent.Merge(m, src) +} +func (m *ValidatorSlashEvent) XXX_Size() int { + return m.Size() +} +func (m *ValidatorSlashEvent) XXX_DiscardUnknown() { + xxx_messageInfo_ValidatorSlashEvent.DiscardUnknown(m) +} + +var xxx_messageInfo_ValidatorSlashEvent proto.InternalMessageInfo + +func (m *ValidatorSlashEvent) GetValidatorPeriod() uint64 { + if m != nil { + return m.ValidatorPeriod + } + return 0 +} + +// ValidatorSlashEvents is a collection of ValidatorSlashEvent messages. +type ValidatorSlashEvents struct { + ValidatorSlashEvents []ValidatorSlashEvent `protobuf:"bytes,1,rep,name=validator_slash_events,json=validatorSlashEvents,proto3" json:"validator_slash_events"` +} + +func (m *ValidatorSlashEvents) Reset() { *m = ValidatorSlashEvents{} } +func (m *ValidatorSlashEvents) String() string { return proto.CompactTextString(m) } +func (*ValidatorSlashEvents) ProtoMessage() {} +func (*ValidatorSlashEvents) Descriptor() ([]byte, []int) { + return fileDescriptor_4fd7627d4268669e, []int{5} +} +func (m *ValidatorSlashEvents) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ValidatorSlashEvents) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ValidatorSlashEvents.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 *ValidatorSlashEvents) XXX_Merge(src proto.Message) { + xxx_messageInfo_ValidatorSlashEvents.Merge(m, src) +} +func (m *ValidatorSlashEvents) XXX_Size() int { + return m.Size() +} +func (m *ValidatorSlashEvents) XXX_DiscardUnknown() { + xxx_messageInfo_ValidatorSlashEvents.DiscardUnknown(m) +} + +var xxx_messageInfo_ValidatorSlashEvents proto.InternalMessageInfo + +func (m *ValidatorSlashEvents) GetValidatorSlashEvents() []ValidatorSlashEvent { + if m != nil { + return m.ValidatorSlashEvents + } + return nil +} + +// FeePool is the global fee pool for distribution. +type FeePool struct { + CommunityPool github_com_cosmos_cosmos_sdk_types.DecCoins `protobuf:"bytes,1,rep,name=community_pool,json=communityPool,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.DecCoins" json:"community_pool"` +} + +func (m *FeePool) Reset() { *m = FeePool{} } +func (m *FeePool) String() string { return proto.CompactTextString(m) } +func (*FeePool) ProtoMessage() {} +func (*FeePool) Descriptor() ([]byte, []int) { + return fileDescriptor_4fd7627d4268669e, []int{6} +} +func (m *FeePool) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *FeePool) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_FeePool.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 *FeePool) XXX_Merge(src proto.Message) { + xxx_messageInfo_FeePool.Merge(m, src) +} +func (m *FeePool) XXX_Size() int { + return m.Size() +} +func (m *FeePool) XXX_DiscardUnknown() { + xxx_messageInfo_FeePool.DiscardUnknown(m) +} + +var xxx_messageInfo_FeePool proto.InternalMessageInfo + +func (m *FeePool) GetCommunityPool() github_com_cosmos_cosmos_sdk_types.DecCoins { + if m != nil { + return m.CommunityPool + } + return nil +} + +// CommunityPoolSpendProposal details a proposal for use of community funds, +// together with how many coins are proposed to be spent, and to which +// recipient account. +type CommunityPoolSpendProposal struct { + Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"` + Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` + Recipient string `protobuf:"bytes,3,opt,name=recipient,proto3" json:"recipient,omitempty"` + Amount github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,4,rep,name=amount,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"amount"` +} + +func (m *CommunityPoolSpendProposal) Reset() { *m = CommunityPoolSpendProposal{} } +func (m *CommunityPoolSpendProposal) String() string { return proto.CompactTextString(m) } +func (*CommunityPoolSpendProposal) ProtoMessage() {} +func (*CommunityPoolSpendProposal) Descriptor() ([]byte, []int) { + return fileDescriptor_4fd7627d4268669e, []int{7} +} +func (m *CommunityPoolSpendProposal) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *CommunityPoolSpendProposal) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_CommunityPoolSpendProposal.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 *CommunityPoolSpendProposal) XXX_Merge(src proto.Message) { + xxx_messageInfo_CommunityPoolSpendProposal.Merge(m, src) +} +func (m *CommunityPoolSpendProposal) XXX_Size() int { + return m.Size() +} +func (m *CommunityPoolSpendProposal) XXX_DiscardUnknown() { + xxx_messageInfo_CommunityPoolSpendProposal.DiscardUnknown(m) +} + +var xxx_messageInfo_CommunityPoolSpendProposal proto.InternalMessageInfo + +// DelegatorStartingInfo represents the starting info for a delegator reward +// period. It tracks the previous validator period, the delegation's amount of +// staking token, and the creation height (to check later on if any slashes have +// occurred). NOTE: Even though validators are slashed to whole staking tokens, +// the delegators within the validator may be left with less than a full token, +// thus sdk.Dec is used. +type DelegatorStartingInfo struct { + PreviousPeriod uint64 `protobuf:"varint,1,opt,name=previous_period,json=previousPeriod,proto3" json:"previous_period,omitempty"` + Stake github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=stake,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"stake"` + Height uint64 `protobuf:"varint,3,opt,name=height,proto3" json:"creation_height"` +} + +func (m *DelegatorStartingInfo) Reset() { *m = DelegatorStartingInfo{} } +func (m *DelegatorStartingInfo) String() string { return proto.CompactTextString(m) } +func (*DelegatorStartingInfo) ProtoMessage() {} +func (*DelegatorStartingInfo) Descriptor() ([]byte, []int) { + return fileDescriptor_4fd7627d4268669e, []int{8} +} +func (m *DelegatorStartingInfo) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *DelegatorStartingInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_DelegatorStartingInfo.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 *DelegatorStartingInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_DelegatorStartingInfo.Merge(m, src) +} +func (m *DelegatorStartingInfo) XXX_Size() int { + return m.Size() +} +func (m *DelegatorStartingInfo) XXX_DiscardUnknown() { + xxx_messageInfo_DelegatorStartingInfo.DiscardUnknown(m) +} + +var xxx_messageInfo_DelegatorStartingInfo proto.InternalMessageInfo + +func (m *DelegatorStartingInfo) GetPreviousPeriod() uint64 { + if m != nil { + return m.PreviousPeriod + } + return 0 +} + +func (m *DelegatorStartingInfo) GetHeight() uint64 { + if m != nil { + return m.Height + } + return 0 +} + +// DelegationDelegatorReward represents the properties +// of a delegator's delegation reward. +type DelegationDelegatorReward struct { + ValidatorAddress string `protobuf:"bytes,1,opt,name=validator_address,json=validatorAddress,proto3" json:"validator_address,omitempty"` + Reward github_com_cosmos_cosmos_sdk_types.DecCoins `protobuf:"bytes,2,rep,name=reward,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.DecCoins" json:"reward"` +} + +func (m *DelegationDelegatorReward) Reset() { *m = DelegationDelegatorReward{} } +func (m *DelegationDelegatorReward) String() string { return proto.CompactTextString(m) } +func (*DelegationDelegatorReward) ProtoMessage() {} +func (*DelegationDelegatorReward) Descriptor() ([]byte, []int) { + return fileDescriptor_4fd7627d4268669e, []int{9} +} +func (m *DelegationDelegatorReward) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *DelegationDelegatorReward) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_DelegationDelegatorReward.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 *DelegationDelegatorReward) XXX_Merge(src proto.Message) { + xxx_messageInfo_DelegationDelegatorReward.Merge(m, src) +} +func (m *DelegationDelegatorReward) XXX_Size() int { + return m.Size() +} +func (m *DelegationDelegatorReward) XXX_DiscardUnknown() { + xxx_messageInfo_DelegationDelegatorReward.DiscardUnknown(m) +} + +var xxx_messageInfo_DelegationDelegatorReward proto.InternalMessageInfo + +// CommunityPoolSpendProposalWithDeposit defines a CommunityPoolSpendProposal +// with a deposit +type CommunityPoolSpendProposalWithDeposit struct { + Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"` + Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` + Recipient string `protobuf:"bytes,3,opt,name=recipient,proto3" json:"recipient,omitempty"` + Amount string `protobuf:"bytes,4,opt,name=amount,proto3" json:"amount,omitempty"` + Deposit string `protobuf:"bytes,5,opt,name=deposit,proto3" json:"deposit,omitempty"` +} + +func (m *CommunityPoolSpendProposalWithDeposit) Reset() { *m = CommunityPoolSpendProposalWithDeposit{} } +func (m *CommunityPoolSpendProposalWithDeposit) String() string { return proto.CompactTextString(m) } +func (*CommunityPoolSpendProposalWithDeposit) ProtoMessage() {} +func (*CommunityPoolSpendProposalWithDeposit) Descriptor() ([]byte, []int) { + return fileDescriptor_4fd7627d4268669e, []int{10} +} +func (m *CommunityPoolSpendProposalWithDeposit) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *CommunityPoolSpendProposalWithDeposit) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_CommunityPoolSpendProposalWithDeposit.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 *CommunityPoolSpendProposalWithDeposit) XXX_Merge(src proto.Message) { + xxx_messageInfo_CommunityPoolSpendProposalWithDeposit.Merge(m, src) +} +func (m *CommunityPoolSpendProposalWithDeposit) XXX_Size() int { + return m.Size() +} +func (m *CommunityPoolSpendProposalWithDeposit) XXX_DiscardUnknown() { + xxx_messageInfo_CommunityPoolSpendProposalWithDeposit.DiscardUnknown(m) +} + +var xxx_messageInfo_CommunityPoolSpendProposalWithDeposit proto.InternalMessageInfo + +func init() { + proto.RegisterType((*ValidatorHistoricalRewards)(nil), "elysnetwork.elys.incentive.ValidatorHistoricalRewards") + proto.RegisterType((*ValidatorCurrentRewards)(nil), "elysnetwork.elys.incentive.ValidatorCurrentRewards") + proto.RegisterType((*ValidatorAccumulatedCommission)(nil), "elysnetwork.elys.incentive.ValidatorAccumulatedCommission") + proto.RegisterType((*ValidatorOutstandingRewards)(nil), "elysnetwork.elys.incentive.ValidatorOutstandingRewards") + proto.RegisterType((*ValidatorSlashEvent)(nil), "elysnetwork.elys.incentive.ValidatorSlashEvent") + proto.RegisterType((*ValidatorSlashEvents)(nil), "elysnetwork.elys.incentive.ValidatorSlashEvents") + proto.RegisterType((*FeePool)(nil), "elysnetwork.elys.incentive.FeePool") + proto.RegisterType((*CommunityPoolSpendProposal)(nil), "elysnetwork.elys.incentive.CommunityPoolSpendProposal") + proto.RegisterType((*DelegatorStartingInfo)(nil), "elysnetwork.elys.incentive.DelegatorStartingInfo") + proto.RegisterType((*DelegationDelegatorReward)(nil), "elysnetwork.elys.incentive.DelegationDelegatorReward") + proto.RegisterType((*CommunityPoolSpendProposalWithDeposit)(nil), "elysnetwork.elys.incentive.CommunityPoolSpendProposalWithDeposit") +} + +func init() { proto.RegisterFile("elys/incentive/distribution.proto", fileDescriptor_4fd7627d4268669e) } + +var fileDescriptor_4fd7627d4268669e = []byte{ + // 790 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x55, 0x41, 0x6f, 0x23, 0x35, + 0x14, 0x8e, 0x77, 0xd3, 0x94, 0x7a, 0xb5, 0x2d, 0x78, 0xb3, 0xdd, 0x6c, 0x58, 0x4d, 0xca, 0x48, + 0x40, 0x51, 0xb5, 0x33, 0x2c, 0x7b, 0xe3, 0xb6, 0x49, 0x40, 0x80, 0x90, 0xa8, 0x66, 0x25, 0x90, + 0xb8, 0x44, 0x8e, 0xe7, 0x35, 0xb1, 0x32, 0xb1, 0x07, 0xdb, 0x93, 0xdd, 0x9e, 0xb9, 0x00, 0xe2, + 0x80, 0xc4, 0x1d, 0x71, 0x44, 0x5c, 0x11, 0x07, 0xfe, 0x41, 0x8f, 0xe5, 0x86, 0x90, 0x28, 0x28, + 0xbd, 0xf1, 0x2b, 0x90, 0x3d, 0xce, 0x24, 0x48, 0xa9, 0x54, 0x21, 0x45, 0x9c, 0x92, 0xf7, 0x3d, + 0xdb, 0xdf, 0xf7, 0x3e, 0xbf, 0xe7, 0xc1, 0xaf, 0x40, 0x76, 0xaa, 0x63, 0x2e, 0x18, 0x08, 0xc3, + 0x67, 0x10, 0xa7, 0x5c, 0x1b, 0xc5, 0x87, 0x85, 0xe1, 0x52, 0x44, 0xb9, 0x92, 0x46, 0x92, 0xb6, + 0x5d, 0x22, 0xc0, 0x3c, 0x93, 0x6a, 0x12, 0xd9, 0xff, 0x51, 0xb5, 0xbc, 0xdd, 0x1c, 0xc9, 0x91, + 0x74, 0xcb, 0x62, 0xfb, 0xaf, 0xdc, 0xd1, 0x0e, 0x98, 0xd4, 0x53, 0xa9, 0xe3, 0x21, 0xd5, 0x10, + 0xcf, 0x1e, 0x0d, 0xc1, 0xd0, 0x47, 0x31, 0x93, 0xdc, 0x9f, 0x18, 0xfe, 0x8a, 0x70, 0xfb, 0x63, + 0x9a, 0xf1, 0x94, 0x1a, 0xa9, 0xde, 0xe3, 0xda, 0x48, 0xc5, 0x19, 0xcd, 0x12, 0x78, 0x46, 0x55, + 0xaa, 0xc9, 0x97, 0x08, 0xdf, 0x63, 0xc5, 0xb4, 0xc8, 0xa8, 0xe5, 0x18, 0x28, 0x07, 0x0f, 0x14, + 0x35, 0x5c, 0xb6, 0xd0, 0xc1, 0xcd, 0xc3, 0x5b, 0x6f, 0x3d, 0x88, 0x4a, 0x86, 0xc8, 0x32, 0x44, + 0x9e, 0x21, 0xea, 0x03, 0xeb, 0x49, 0x2e, 0xba, 0x8f, 0xcf, 0x2e, 0x3a, 0xb5, 0x1f, 0xff, 0xec, + 0x1c, 0x8d, 0xb8, 0x19, 0x17, 0xc3, 0x88, 0xc9, 0x69, 0xec, 0x15, 0x95, 0x3f, 0x0f, 0x75, 0x3a, + 0x89, 0xcd, 0x69, 0x0e, 0x7a, 0xb1, 0x47, 0x27, 0x77, 0x97, 0x8c, 0xa5, 0x8e, 0xc4, 0xf2, 0x91, + 0xd7, 0xf1, 0x9e, 0x82, 0x13, 0x50, 0x20, 0x18, 0x0c, 0x98, 0x2c, 0x84, 0x69, 0xdd, 0x38, 0x40, + 0x87, 0xb7, 0x93, 0xdd, 0x0a, 0xee, 0x59, 0x34, 0xfc, 0x0e, 0xe1, 0x7b, 0x55, 0x4d, 0xbd, 0x42, + 0x29, 0x10, 0x66, 0x51, 0xd0, 0x04, 0x6f, 0x97, 0x45, 0xe8, 0xcd, 0xe9, 0x5f, 0x30, 0x90, 0x7d, + 0xdc, 0xc8, 0x41, 0x71, 0x99, 0x3a, 0xa1, 0xf5, 0xc4, 0x47, 0xe1, 0xb7, 0x08, 0x07, 0x95, 0xc0, + 0x27, 0xcc, 0x97, 0x0b, 0x69, 0x4f, 0x4e, 0xa7, 0x5c, 0x6b, 0x2e, 0x05, 0xf9, 0x0c, 0x63, 0x56, + 0x45, 0x9b, 0x93, 0xba, 0x42, 0x12, 0x7e, 0x85, 0xf0, 0xcb, 0x95, 0xaa, 0x8f, 0x0a, 0xa3, 0x0d, + 0x15, 0x29, 0x17, 0xa3, 0xff, 0xc3, 0xba, 0xf0, 0x6b, 0x84, 0xef, 0x54, 0x62, 0x9e, 0x66, 0x54, + 0x8f, 0xdf, 0x99, 0x81, 0x30, 0xe4, 0x0d, 0xfc, 0xe2, 0x6c, 0x01, 0x0f, 0xbc, 0xb9, 0xc8, 0x99, + 0xbb, 0x57, 0xe1, 0xc7, 0x0e, 0x26, 0x1f, 0xe0, 0x17, 0x4e, 0x14, 0x65, 0x76, 0x7c, 0x9c, 0xff, + 0x3b, 0xdd, 0xc8, 0x4a, 0xfa, 0xfd, 0xa2, 0xf3, 0xda, 0xf5, 0x24, 0x25, 0xd5, 0xfe, 0xf0, 0x73, + 0x84, 0x9b, 0x6b, 0xe4, 0x58, 0x53, 0xf6, 0x97, 0x7a, 0xb4, 0x4d, 0x0c, 0xc0, 0x65, 0xbc, 0x47, + 0x71, 0x74, 0xf5, 0xc8, 0x46, 0x6b, 0x4e, 0xec, 0xd6, 0xad, 0xc6, 0xa4, 0x39, 0x5b, 0x43, 0x66, + 0x55, 0x6c, 0xbf, 0x0b, 0x70, 0x2c, 0x65, 0x46, 0x9e, 0xe3, 0x5d, 0x7b, 0x77, 0x85, 0xe0, 0xe6, + 0x74, 0x90, 0x4b, 0x99, 0x6d, 0xee, 0x52, 0x6e, 0x57, 0x44, 0x96, 0x39, 0xfc, 0x03, 0xe1, 0x76, + 0x6f, 0x15, 0x79, 0x9a, 0x83, 0x48, 0x8f, 0x95, 0xcc, 0xa5, 0xa6, 0x19, 0x69, 0xe2, 0x2d, 0xc3, + 0x4d, 0x06, 0xee, 0x5a, 0x76, 0x92, 0x32, 0x20, 0x07, 0xf8, 0x56, 0x0a, 0x9a, 0x29, 0x9e, 0x2f, + 0xef, 0x23, 0x59, 0x85, 0xc8, 0x03, 0xbc, 0xa3, 0x80, 0xf1, 0x9c, 0x83, 0x30, 0xad, 0x9b, 0x2e, + 0xbf, 0x04, 0x08, 0xc3, 0x0d, 0x3a, 0x75, 0x33, 0x5f, 0x77, 0x65, 0xde, 0x5f, 0x5b, 0xa6, 0xab, + 0xf1, 0x4d, 0x5f, 0xe3, 0xe1, 0x35, 0x6a, 0x2c, 0x0b, 0xf4, 0x47, 0xbf, 0x5d, 0xff, 0xe2, 0xfb, + 0x4e, 0x2d, 0xfc, 0x09, 0xe1, 0xbb, 0x7d, 0xc8, 0x60, 0xe4, 0xec, 0x37, 0x54, 0x19, 0x2e, 0x46, + 0xef, 0x8b, 0x13, 0xf7, 0x02, 0xe5, 0x0a, 0x66, 0x5c, 0x16, 0xfa, 0xdf, 0xbd, 0xb7, 0xbb, 0x80, + 0x7d, 0xeb, 0xf5, 0xf1, 0x96, 0x36, 0x74, 0x02, 0xff, 0xb1, 0xef, 0xca, 0xcd, 0xe4, 0x08, 0x37, + 0xc6, 0xc0, 0x47, 0xe3, 0xd2, 0x8e, 0x7a, 0xf7, 0xce, 0xdf, 0x17, 0x9d, 0x3d, 0xa6, 0xc0, 0xbe, + 0x86, 0x62, 0x50, 0xa6, 0x12, 0xbf, 0x24, 0xfc, 0x05, 0xe1, 0xfb, 0x5e, 0x35, 0x97, 0xa2, 0xd2, + 0x5f, 0x0e, 0x2f, 0x39, 0xc2, 0x2f, 0x2d, 0xdb, 0x94, 0xa6, 0xa9, 0x02, 0xad, 0xfd, 0x05, 0x2d, + 0xe7, 0xe9, 0x49, 0x89, 0x13, 0x8e, 0x1b, 0xe5, 0x18, 0xb6, 0x6e, 0x6c, 0xaa, 0xa5, 0x3c, 0x81, + 0x77, 0xfc, 0x67, 0x84, 0x5f, 0xbd, 0xba, 0xa3, 0x3e, 0xe1, 0x66, 0xdc, 0x87, 0x5c, 0x6a, 0x6e, + 0x36, 0xd4, 0x5c, 0xfb, 0x2b, 0xcd, 0x65, 0x53, 0x3e, 0x22, 0x2d, 0xbc, 0x9d, 0x96, 0xc4, 0xad, + 0x2d, 0x97, 0x58, 0x84, 0xa5, 0xee, 0xee, 0x87, 0x3f, 0xcc, 0x03, 0x74, 0x36, 0x0f, 0xd0, 0xf9, + 0x3c, 0x40, 0x7f, 0xcd, 0x03, 0xf4, 0xcd, 0x65, 0x50, 0x3b, 0xbf, 0x0c, 0x6a, 0xbf, 0x5d, 0x06, + 0xb5, 0x4f, 0xa3, 0x15, 0x43, 0xec, 0xe0, 0x3f, 0xf4, 0xaf, 0x80, 0x0b, 0xe2, 0xe7, 0x2b, 0x5f, + 0x7a, 0x67, 0xce, 0xb0, 0xe1, 0xbe, 0xc8, 0x8f, 0xff, 0x09, 0x00, 0x00, 0xff, 0xff, 0xd0, 0xf1, + 0x07, 0x89, 0x08, 0x08, 0x00, 0x00, +} + +func (this *ValidatorHistoricalRewards) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*ValidatorHistoricalRewards) + if !ok { + that2, ok := that.(ValidatorHistoricalRewards) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if len(this.CumulativeRewardRatio) != len(that1.CumulativeRewardRatio) { + return false + } + for i := range this.CumulativeRewardRatio { + if !this.CumulativeRewardRatio[i].Equal(&that1.CumulativeRewardRatio[i]) { + return false + } + } + if this.ReferenceCount != that1.ReferenceCount { + return false + } + return true +} +func (this *ValidatorCurrentRewards) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*ValidatorCurrentRewards) + if !ok { + that2, ok := that.(ValidatorCurrentRewards) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + 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 + } + } + if this.Period != that1.Period { + return false + } + return true +} +func (this *ValidatorAccumulatedCommission) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*ValidatorAccumulatedCommission) + if !ok { + that2, ok := that.(ValidatorAccumulatedCommission) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if len(this.Commission) != len(that1.Commission) { + return false + } + for i := range this.Commission { + if !this.Commission[i].Equal(&that1.Commission[i]) { + return false + } + } + return true +} +func (this *ValidatorOutstandingRewards) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*ValidatorOutstandingRewards) + if !ok { + that2, ok := that.(ValidatorOutstandingRewards) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + 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 (this *ValidatorSlashEvent) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*ValidatorSlashEvent) + if !ok { + that2, ok := that.(ValidatorSlashEvent) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.ValidatorPeriod != that1.ValidatorPeriod { + return false + } + if !this.Fraction.Equal(that1.Fraction) { + return false + } + return true +} +func (this *ValidatorSlashEvents) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*ValidatorSlashEvents) + if !ok { + that2, ok := that.(ValidatorSlashEvents) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if len(this.ValidatorSlashEvents) != len(that1.ValidatorSlashEvents) { + return false + } + for i := range this.ValidatorSlashEvents { + if !this.ValidatorSlashEvents[i].Equal(&that1.ValidatorSlashEvents[i]) { + return false + } + } + return true +} +func (this *FeePool) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*FeePool) + if !ok { + that2, ok := that.(FeePool) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if len(this.CommunityPool) != len(that1.CommunityPool) { + return false + } + for i := range this.CommunityPool { + if !this.CommunityPool[i].Equal(&that1.CommunityPool[i]) { + return false + } + } + return true +} +func (this *CommunityPoolSpendProposal) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*CommunityPoolSpendProposal) + if !ok { + that2, ok := that.(CommunityPoolSpendProposal) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Title != that1.Title { + return false + } + if this.Description != that1.Description { + return false + } + if this.Recipient != that1.Recipient { + return false + } + if len(this.Amount) != len(that1.Amount) { + return false + } + for i := range this.Amount { + if !this.Amount[i].Equal(&that1.Amount[i]) { + return false + } + } + return true +} +func (this *DelegatorStartingInfo) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*DelegatorStartingInfo) + if !ok { + that2, ok := that.(DelegatorStartingInfo) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.PreviousPeriod != that1.PreviousPeriod { + return false + } + if !this.Stake.Equal(that1.Stake) { + return false + } + if this.Height != that1.Height { + return false + } + return true +} +func (this *DelegationDelegatorReward) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*DelegationDelegatorReward) + if !ok { + that2, ok := that.(DelegationDelegatorReward) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.ValidatorAddress != that1.ValidatorAddress { + return false + } + if len(this.Reward) != len(that1.Reward) { + return false + } + for i := range this.Reward { + if !this.Reward[i].Equal(&that1.Reward[i]) { + return false + } + } + return true +} +func (this *CommunityPoolSpendProposalWithDeposit) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*CommunityPoolSpendProposalWithDeposit) + if !ok { + that2, ok := that.(CommunityPoolSpendProposalWithDeposit) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Title != that1.Title { + return false + } + if this.Description != that1.Description { + return false + } + if this.Recipient != that1.Recipient { + return false + } + if this.Amount != that1.Amount { + return false + } + if this.Deposit != that1.Deposit { + return false + } + return true +} +func (m *ValidatorHistoricalRewards) 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 *ValidatorHistoricalRewards) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ValidatorHistoricalRewards) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.ReferenceCount != 0 { + i = encodeVarintDistribution(dAtA, i, uint64(m.ReferenceCount)) + i-- + dAtA[i] = 0x10 + } + if len(m.CumulativeRewardRatio) > 0 { + for iNdEx := len(m.CumulativeRewardRatio) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.CumulativeRewardRatio[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintDistribution(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *ValidatorCurrentRewards) 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 *ValidatorCurrentRewards) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ValidatorCurrentRewards) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Period != 0 { + i = encodeVarintDistribution(dAtA, i, uint64(m.Period)) + i-- + dAtA[i] = 0x10 + } + 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 = encodeVarintDistribution(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *ValidatorAccumulatedCommission) 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 *ValidatorAccumulatedCommission) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ValidatorAccumulatedCommission) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Commission) > 0 { + for iNdEx := len(m.Commission) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Commission[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintDistribution(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *ValidatorOutstandingRewards) 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 *ValidatorOutstandingRewards) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ValidatorOutstandingRewards) 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, err := m.Rewards[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintDistribution(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *ValidatorSlashEvent) 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 *ValidatorSlashEvent) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ValidatorSlashEvent) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.Fraction.Size() + i -= size + if _, err := m.Fraction.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintDistribution(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if m.ValidatorPeriod != 0 { + i = encodeVarintDistribution(dAtA, i, uint64(m.ValidatorPeriod)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *ValidatorSlashEvents) 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 *ValidatorSlashEvents) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ValidatorSlashEvents) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ValidatorSlashEvents) > 0 { + for iNdEx := len(m.ValidatorSlashEvents) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.ValidatorSlashEvents[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintDistribution(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *FeePool) 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 *FeePool) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *FeePool) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.CommunityPool) > 0 { + for iNdEx := len(m.CommunityPool) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.CommunityPool[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintDistribution(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *CommunityPoolSpendProposal) 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 *CommunityPoolSpendProposal) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *CommunityPoolSpendProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Amount) > 0 { + for iNdEx := len(m.Amount) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Amount[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintDistribution(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + } + if len(m.Recipient) > 0 { + i -= len(m.Recipient) + copy(dAtA[i:], m.Recipient) + i = encodeVarintDistribution(dAtA, i, uint64(len(m.Recipient))) + i-- + dAtA[i] = 0x1a + } + if len(m.Description) > 0 { + i -= len(m.Description) + copy(dAtA[i:], m.Description) + i = encodeVarintDistribution(dAtA, i, uint64(len(m.Description))) + i-- + dAtA[i] = 0x12 + } + if len(m.Title) > 0 { + i -= len(m.Title) + copy(dAtA[i:], m.Title) + i = encodeVarintDistribution(dAtA, i, uint64(len(m.Title))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *DelegatorStartingInfo) 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 *DelegatorStartingInfo) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *DelegatorStartingInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Height != 0 { + i = encodeVarintDistribution(dAtA, i, uint64(m.Height)) + i-- + dAtA[i] = 0x18 + } + { + size := m.Stake.Size() + i -= size + if _, err := m.Stake.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintDistribution(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if m.PreviousPeriod != 0 { + i = encodeVarintDistribution(dAtA, i, uint64(m.PreviousPeriod)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *DelegationDelegatorReward) 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 *DelegationDelegatorReward) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *DelegationDelegatorReward) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Reward) > 0 { + for iNdEx := len(m.Reward) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Reward[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintDistribution(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if len(m.ValidatorAddress) > 0 { + i -= len(m.ValidatorAddress) + copy(dAtA[i:], m.ValidatorAddress) + i = encodeVarintDistribution(dAtA, i, uint64(len(m.ValidatorAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *CommunityPoolSpendProposalWithDeposit) 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 *CommunityPoolSpendProposalWithDeposit) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *CommunityPoolSpendProposalWithDeposit) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Deposit) > 0 { + i -= len(m.Deposit) + copy(dAtA[i:], m.Deposit) + i = encodeVarintDistribution(dAtA, i, uint64(len(m.Deposit))) + i-- + dAtA[i] = 0x2a + } + if len(m.Amount) > 0 { + i -= len(m.Amount) + copy(dAtA[i:], m.Amount) + i = encodeVarintDistribution(dAtA, i, uint64(len(m.Amount))) + i-- + dAtA[i] = 0x22 + } + if len(m.Recipient) > 0 { + i -= len(m.Recipient) + copy(dAtA[i:], m.Recipient) + i = encodeVarintDistribution(dAtA, i, uint64(len(m.Recipient))) + i-- + dAtA[i] = 0x1a + } + if len(m.Description) > 0 { + i -= len(m.Description) + copy(dAtA[i:], m.Description) + i = encodeVarintDistribution(dAtA, i, uint64(len(m.Description))) + i-- + dAtA[i] = 0x12 + } + if len(m.Title) > 0 { + i -= len(m.Title) + copy(dAtA[i:], m.Title) + i = encodeVarintDistribution(dAtA, i, uint64(len(m.Title))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintDistribution(dAtA []byte, offset int, v uint64) int { + offset -= sovDistribution(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *ValidatorHistoricalRewards) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.CumulativeRewardRatio) > 0 { + for _, e := range m.CumulativeRewardRatio { + l = e.Size() + n += 1 + l + sovDistribution(uint64(l)) + } + } + if m.ReferenceCount != 0 { + n += 1 + sovDistribution(uint64(m.ReferenceCount)) + } + return n +} + +func (m *ValidatorCurrentRewards) 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 + sovDistribution(uint64(l)) + } + } + if m.Period != 0 { + n += 1 + sovDistribution(uint64(m.Period)) + } + return n +} + +func (m *ValidatorAccumulatedCommission) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Commission) > 0 { + for _, e := range m.Commission { + l = e.Size() + n += 1 + l + sovDistribution(uint64(l)) + } + } + return n +} + +func (m *ValidatorOutstandingRewards) 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 + sovDistribution(uint64(l)) + } + } + return n +} + +func (m *ValidatorSlashEvent) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ValidatorPeriod != 0 { + n += 1 + sovDistribution(uint64(m.ValidatorPeriod)) + } + l = m.Fraction.Size() + n += 1 + l + sovDistribution(uint64(l)) + return n +} + +func (m *ValidatorSlashEvents) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.ValidatorSlashEvents) > 0 { + for _, e := range m.ValidatorSlashEvents { + l = e.Size() + n += 1 + l + sovDistribution(uint64(l)) + } + } + return n +} + +func (m *FeePool) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.CommunityPool) > 0 { + for _, e := range m.CommunityPool { + l = e.Size() + n += 1 + l + sovDistribution(uint64(l)) + } + } + return n +} + +func (m *CommunityPoolSpendProposal) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Title) + if l > 0 { + n += 1 + l + sovDistribution(uint64(l)) + } + l = len(m.Description) + if l > 0 { + n += 1 + l + sovDistribution(uint64(l)) + } + l = len(m.Recipient) + if l > 0 { + n += 1 + l + sovDistribution(uint64(l)) + } + if len(m.Amount) > 0 { + for _, e := range m.Amount { + l = e.Size() + n += 1 + l + sovDistribution(uint64(l)) + } + } + return n +} + +func (m *DelegatorStartingInfo) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PreviousPeriod != 0 { + n += 1 + sovDistribution(uint64(m.PreviousPeriod)) + } + l = m.Stake.Size() + n += 1 + l + sovDistribution(uint64(l)) + if m.Height != 0 { + n += 1 + sovDistribution(uint64(m.Height)) + } + return n +} + +func (m *DelegationDelegatorReward) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ValidatorAddress) + if l > 0 { + n += 1 + l + sovDistribution(uint64(l)) + } + if len(m.Reward) > 0 { + for _, e := range m.Reward { + l = e.Size() + n += 1 + l + sovDistribution(uint64(l)) + } + } + return n +} + +func (m *CommunityPoolSpendProposalWithDeposit) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Title) + if l > 0 { + n += 1 + l + sovDistribution(uint64(l)) + } + l = len(m.Description) + if l > 0 { + n += 1 + l + sovDistribution(uint64(l)) + } + l = len(m.Recipient) + if l > 0 { + n += 1 + l + sovDistribution(uint64(l)) + } + l = len(m.Amount) + if l > 0 { + n += 1 + l + sovDistribution(uint64(l)) + } + l = len(m.Deposit) + if l > 0 { + n += 1 + l + sovDistribution(uint64(l)) + } + return n +} + +func sovDistribution(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozDistribution(x uint64) (n int) { + return sovDistribution(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *ValidatorHistoricalRewards) 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 ErrIntOverflowDistribution + } + 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: ValidatorHistoricalRewards: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ValidatorHistoricalRewards: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CumulativeRewardRatio", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDistribution + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthDistribution + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthDistribution + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.CumulativeRewardRatio = append(m.CumulativeRewardRatio, types.DecCoin{}) + if err := m.CumulativeRewardRatio[len(m.CumulativeRewardRatio)-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 ReferenceCount", wireType) + } + m.ReferenceCount = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDistribution + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ReferenceCount |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipDistribution(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthDistribution + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ValidatorCurrentRewards) 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 ErrIntOverflowDistribution + } + 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: ValidatorCurrentRewards: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ValidatorCurrentRewards: 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 msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDistribution + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthDistribution + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthDistribution + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Rewards = append(m.Rewards, types.DecCoin{}) + if err := m.Rewards[len(m.Rewards)-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 Period", wireType) + } + m.Period = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDistribution + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Period |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipDistribution(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthDistribution + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ValidatorAccumulatedCommission) 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 ErrIntOverflowDistribution + } + 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: ValidatorAccumulatedCommission: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ValidatorAccumulatedCommission: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Commission", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDistribution + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthDistribution + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthDistribution + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Commission = append(m.Commission, types.DecCoin{}) + if err := m.Commission[len(m.Commission)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipDistribution(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthDistribution + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ValidatorOutstandingRewards) 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 ErrIntOverflowDistribution + } + 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: ValidatorOutstandingRewards: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ValidatorOutstandingRewards: 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 msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDistribution + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthDistribution + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthDistribution + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Rewards = append(m.Rewards, types.DecCoin{}) + if err := m.Rewards[len(m.Rewards)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipDistribution(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthDistribution + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ValidatorSlashEvent) 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 ErrIntOverflowDistribution + } + 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: ValidatorSlashEvent: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ValidatorSlashEvent: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ValidatorPeriod", wireType) + } + m.ValidatorPeriod = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDistribution + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ValidatorPeriod |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Fraction", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDistribution + } + 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 ErrInvalidLengthDistribution + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthDistribution + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Fraction.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipDistribution(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthDistribution + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ValidatorSlashEvents) 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 ErrIntOverflowDistribution + } + 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: ValidatorSlashEvents: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ValidatorSlashEvents: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ValidatorSlashEvents", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDistribution + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthDistribution + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthDistribution + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ValidatorSlashEvents = append(m.ValidatorSlashEvents, ValidatorSlashEvent{}) + if err := m.ValidatorSlashEvents[len(m.ValidatorSlashEvents)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipDistribution(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthDistribution + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *FeePool) 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 ErrIntOverflowDistribution + } + 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: FeePool: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: FeePool: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CommunityPool", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDistribution + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthDistribution + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthDistribution + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.CommunityPool = append(m.CommunityPool, types.DecCoin{}) + if err := m.CommunityPool[len(m.CommunityPool)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipDistribution(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthDistribution + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *CommunityPoolSpendProposal) 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 ErrIntOverflowDistribution + } + 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: CommunityPoolSpendProposal: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: CommunityPoolSpendProposal: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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 ErrIntOverflowDistribution + } + 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 ErrInvalidLengthDistribution + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthDistribution + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Title = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + 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 ErrIntOverflowDistribution + } + 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 ErrInvalidLengthDistribution + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthDistribution + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Description = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Recipient", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDistribution + } + 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 ErrInvalidLengthDistribution + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthDistribution + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Recipient = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDistribution + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthDistribution + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthDistribution + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Amount = append(m.Amount, types.Coin{}) + if err := m.Amount[len(m.Amount)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipDistribution(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthDistribution + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *DelegatorStartingInfo) 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 ErrIntOverflowDistribution + } + 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: DelegatorStartingInfo: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DelegatorStartingInfo: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PreviousPeriod", wireType) + } + m.PreviousPeriod = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDistribution + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PreviousPeriod |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Stake", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDistribution + } + 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 ErrInvalidLengthDistribution + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthDistribution + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Stake.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) + } + m.Height = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDistribution + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Height |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipDistribution(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthDistribution + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *DelegationDelegatorReward) 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 ErrIntOverflowDistribution + } + 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: DelegationDelegatorReward: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DelegationDelegatorReward: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ValidatorAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDistribution + } + 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 ErrInvalidLengthDistribution + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthDistribution + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ValidatorAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Reward", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDistribution + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthDistribution + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthDistribution + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Reward = append(m.Reward, types.DecCoin{}) + if err := m.Reward[len(m.Reward)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipDistribution(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthDistribution + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *CommunityPoolSpendProposalWithDeposit) 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 ErrIntOverflowDistribution + } + 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: CommunityPoolSpendProposalWithDeposit: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: CommunityPoolSpendProposalWithDeposit: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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 ErrIntOverflowDistribution + } + 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 ErrInvalidLengthDistribution + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthDistribution + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Title = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + 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 ErrIntOverflowDistribution + } + 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 ErrInvalidLengthDistribution + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthDistribution + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Description = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Recipient", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDistribution + } + 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 ErrInvalidLengthDistribution + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthDistribution + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Recipient = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + 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 ErrIntOverflowDistribution + } + 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 ErrInvalidLengthDistribution + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthDistribution + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Amount = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + 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 ErrIntOverflowDistribution + } + 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 ErrInvalidLengthDistribution + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthDistribution + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Deposit = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipDistribution(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthDistribution + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipDistribution(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, ErrIntOverflowDistribution + } + 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, ErrIntOverflowDistribution + } + 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, ErrIntOverflowDistribution + } + 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, ErrInvalidLengthDistribution + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupDistribution + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthDistribution + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthDistribution = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowDistribution = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupDistribution = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/incentive/types/errors.go b/x/incentive/types/errors.go index 579a0e825..43d96d928 100644 --- a/x/incentive/types/errors.go +++ b/x/incentive/types/errors.go @@ -8,5 +8,16 @@ import ( // x/incentive module sentinel errors var ( - ErrSample = sdkerrors.Register(ModuleName, 1100, "sample error") + ErrEmptyDelegatorAddr = sdkerrors.Register(ModuleName, 2, "delegator address is empty") + ErrEmptyWithdrawAddr = sdkerrors.Register(ModuleName, 3, "withdraw address is empty") + ErrEmptyValidatorAddr = sdkerrors.Register(ModuleName, 4, "validator address is empty") + ErrEmptyDelegationDistInfo = sdkerrors.Register(ModuleName, 5, "no delegation distribution info") + ErrNoValidatorDistInfo = sdkerrors.Register(ModuleName, 6, "no validator distribution info") + ErrNoValidatorCommission = sdkerrors.Register(ModuleName, 7, "no validator commission to withdraw") + ErrSetWithdrawAddrDisabled = sdkerrors.Register(ModuleName, 8, "set withdraw address disabled") + ErrBadDistribution = sdkerrors.Register(ModuleName, 9, "community pool does not have sufficient coins to distribute") + ErrInvalidProposalAmount = sdkerrors.Register(ModuleName, 10, "invalid community pool spend proposal amount") + ErrEmptyProposalRecipient = sdkerrors.Register(ModuleName, 11, "invalid community pool spend proposal recipient") + ErrNoValidatorExists = sdkerrors.Register(ModuleName, 12, "validator does not exist") + ErrNoDelegationExists = sdkerrors.Register(ModuleName, 13, "delegation does not exist") ) diff --git a/x/incentive/types/events.go b/x/incentive/types/events.go new file mode 100644 index 000000000..ce4c0ef62 --- /dev/null +++ b/x/incentive/types/events.go @@ -0,0 +1,16 @@ +package types + +// distribution module event types +const ( + EventTypeSetWithdrawAddress = "set_withdraw_address" + EventTypeRewards = "rewards" + EventTypeCommission = "commission" + EventTypeWithdrawRewards = "withdraw_rewards" + EventTypeWithdrawCommission = "withdraw_commission" + EventTypeProposerReward = "proposer_reward" + + AttributeKeyWithdrawAddress = "withdraw_address" + AttributeKeyValidator = "validator" + + AttributeValueCategory = ModuleName +) diff --git a/x/incentive/types/expected_keepers.go b/x/incentive/types/expected_keepers.go index 912471d19..5b3bd6ac2 100644 --- a/x/incentive/types/expected_keepers.go +++ b/x/incentive/types/expected_keepers.go @@ -2,6 +2,7 @@ package types import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/auth/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" ctypes "github.com/elys-network/elys/x/commitment/types" ) @@ -11,7 +12,7 @@ type CommitmentKeeper interface { // Iterate all commitment IterateCommitments(sdk.Context, func(ctypes.Commitments) (stop bool)) // Initiate commitment according to standard staking - StandardStakingToken(sdk.Context, string, string) error + StandardStakingToken(sdk.Context, string, string, string) error // Update commitment SetCommitments(sdk.Context, ctypes.Commitments) // Get commitment @@ -28,4 +29,33 @@ type StakingKeeper interface { Validator(sdk.Context, sdk.ValAddress) stakingtypes.ValidatorI // GetDelegatorDelegations returns a given amount of all the delegations from a delegator. GetDelegatorDelegations(ctx sdk.Context, delegator sdk.AccAddress, maxRetrieve uint16) (delegations []stakingtypes.Delegation) + // get a particular validator by consensus address + ValidatorByConsAddr(sdk.Context, sdk.ConsAddress) stakingtypes.ValidatorI + // Delegation allows for getting a particular delegation for a given validator + // and delegator outside the scope of the staking module. + Delegation(sdk.Context, sdk.AccAddress, sdk.ValAddress) stakingtypes.DelegationI +} + +// AccountKeeper defines the expected account keeper used for simulations (noalias) +type AccountKeeper interface { + GetAccount(ctx sdk.Context, addr sdk.AccAddress) types.AccountI + + GetModuleAddress(name string) sdk.AccAddress + GetModuleAccount(ctx sdk.Context, name string) types.ModuleAccountI + + // TODO remove with genesis 2-phases refactor https://github.com/cosmos/cosmos-sdk/issues/2862 + SetModuleAccount(sdk.Context, types.ModuleAccountI) +} + +// BankKeeper defines the expected interface needed to retrieve account balances. +type BankKeeper interface { + GetAllBalances(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins + + SpendableCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins + + SendCoinsFromModuleToModule(ctx sdk.Context, senderModule string, recipientModule string, 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 + + BlockedAddr(addr sdk.AccAddress) bool } diff --git a/x/incentive/types/feel_pool.go b/x/incentive/types/feel_pool.go new file mode 100644 index 000000000..645afd401 --- /dev/null +++ b/x/incentive/types/feel_pool.go @@ -0,0 +1,24 @@ +package types + +import ( + "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// zero fee pool +func InitialFeePool() FeePool { + return FeePool{ + CommunityPool: sdk.DecCoins{}, + } +} + +// ValidateGenesis validates the fee pool for a genesis state +func (f FeePool) ValidateGenesis() error { + if f.CommunityPool.IsAnyNegative() { + return fmt.Errorf("negative CommunityPool in distribution fee pool, is %v", + f.CommunityPool) + } + + return nil +} diff --git a/x/incentive/types/genesis.go b/x/incentive/types/genesis.go index 0af9b4416..17aa46f03 100644 --- a/x/incentive/types/genesis.go +++ b/x/incentive/types/genesis.go @@ -1,17 +1,46 @@ package types import ( -// this line is used by starport scaffolding # genesis/types/import + sdk "github.com/cosmos/cosmos-sdk/types" ) // DefaultIndex is the default global index const DefaultIndex uint64 = 1 +//nolint:interfacer +func NewGenesisState( + params Params, fp FeePool, dwis []DelegatorWithdrawInfo, pp sdk.ConsAddress, r []ValidatorOutstandingRewardsRecord, + acc []ValidatorAccumulatedCommissionRecord, historical []ValidatorHistoricalRewardsRecord, + cur []ValidatorCurrentRewardsRecord, dels []DelegatorStartingInfoRecord, slashes []ValidatorSlashEventRecord, +) *GenesisState { + return &GenesisState{ + Params: params, + FeePool: fp, + DelegatorWithdrawInfos: dwis, + PreviousProposer: pp.String(), + OutstandingRewards: r, + ValidatorAccumulatedCommissions: acc, + ValidatorHistoricalRewards: historical, + ValidatorCurrentRewards: cur, + DelegatorStartingInfos: dels, + ValidatorSlashEvents: slashes, + } +} + // DefaultGenesis returns the default genesis state func DefaultGenesis() *GenesisState { return &GenesisState{ // this line is used by starport scaffolding # genesis/types/default - Params: DefaultParams(), + Params: DefaultParams(), + FeePool: InitialFeePool(), + DelegatorWithdrawInfos: []DelegatorWithdrawInfo{}, + PreviousProposer: "", + OutstandingRewards: []ValidatorOutstandingRewardsRecord{}, + ValidatorAccumulatedCommissions: []ValidatorAccumulatedCommissionRecord{}, + ValidatorHistoricalRewards: []ValidatorHistoricalRewardsRecord{}, + ValidatorCurrentRewards: []ValidatorCurrentRewardsRecord{}, + DelegatorStartingInfos: []DelegatorStartingInfoRecord{}, + ValidatorSlashEvents: []ValidatorSlashEventRecord{}, } } @@ -19,6 +48,9 @@ func DefaultGenesis() *GenesisState { // failure. func (gs GenesisState) Validate() error { // this line is used by starport scaffolding # genesis/types/validate + if err := gs.Params.ValidateBasic(); err != nil { + return err + } - return gs.Params.Validate() + return gs.FeePool.ValidateGenesis() } diff --git a/x/incentive/types/genesis.pb.go b/x/incentive/types/genesis.pb.go index b6e1d0d1d..29ce9fa1b 100644 --- a/x/incentive/types/genesis.pb.go +++ b/x/incentive/types/genesis.pb.go @@ -5,6 +5,8 @@ package types import ( fmt "fmt" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + types "github.com/cosmos/cosmos-sdk/types" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" io "io" @@ -23,16 +25,333 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package +// DelegatorWithdrawInfo is the address for where distributions rewards are +// withdrawn to by default this struct is only used at genesis to feed in +// default withdraw addresses. +type DelegatorWithdrawInfo struct { + // delegator_address is the address of the delegator. + DelegatorAddress string `protobuf:"bytes,1,opt,name=delegator_address,json=delegatorAddress,proto3" json:"delegator_address,omitempty"` + // withdraw_address is the address to withdraw the delegation rewards to. + WithdrawAddress string `protobuf:"bytes,2,opt,name=withdraw_address,json=withdrawAddress,proto3" json:"withdraw_address,omitempty"` +} + +func (m *DelegatorWithdrawInfo) Reset() { *m = DelegatorWithdrawInfo{} } +func (m *DelegatorWithdrawInfo) String() string { return proto.CompactTextString(m) } +func (*DelegatorWithdrawInfo) ProtoMessage() {} +func (*DelegatorWithdrawInfo) Descriptor() ([]byte, []int) { + return fileDescriptor_83b8e7899b41b162, []int{0} +} +func (m *DelegatorWithdrawInfo) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *DelegatorWithdrawInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_DelegatorWithdrawInfo.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 *DelegatorWithdrawInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_DelegatorWithdrawInfo.Merge(m, src) +} +func (m *DelegatorWithdrawInfo) XXX_Size() int { + return m.Size() +} +func (m *DelegatorWithdrawInfo) XXX_DiscardUnknown() { + xxx_messageInfo_DelegatorWithdrawInfo.DiscardUnknown(m) +} + +var xxx_messageInfo_DelegatorWithdrawInfo proto.InternalMessageInfo + +// ValidatorOutstandingRewardsRecord is used for import/export via genesis json. +type ValidatorOutstandingRewardsRecord struct { + // validator_address is the address of the validator. + ValidatorAddress string `protobuf:"bytes,1,opt,name=validator_address,json=validatorAddress,proto3" json:"validator_address,omitempty"` + // outstanding_rewards represents the oustanding rewards of a validator. + OutstandingRewards github_com_cosmos_cosmos_sdk_types.DecCoins `protobuf:"bytes,2,rep,name=outstanding_rewards,json=outstandingRewards,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.DecCoins" json:"outstanding_rewards"` +} + +func (m *ValidatorOutstandingRewardsRecord) Reset() { *m = ValidatorOutstandingRewardsRecord{} } +func (m *ValidatorOutstandingRewardsRecord) String() string { return proto.CompactTextString(m) } +func (*ValidatorOutstandingRewardsRecord) ProtoMessage() {} +func (*ValidatorOutstandingRewardsRecord) Descriptor() ([]byte, []int) { + return fileDescriptor_83b8e7899b41b162, []int{1} +} +func (m *ValidatorOutstandingRewardsRecord) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ValidatorOutstandingRewardsRecord) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ValidatorOutstandingRewardsRecord.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 *ValidatorOutstandingRewardsRecord) XXX_Merge(src proto.Message) { + xxx_messageInfo_ValidatorOutstandingRewardsRecord.Merge(m, src) +} +func (m *ValidatorOutstandingRewardsRecord) XXX_Size() int { + return m.Size() +} +func (m *ValidatorOutstandingRewardsRecord) XXX_DiscardUnknown() { + xxx_messageInfo_ValidatorOutstandingRewardsRecord.DiscardUnknown(m) +} + +var xxx_messageInfo_ValidatorOutstandingRewardsRecord proto.InternalMessageInfo + +// ValidatorAccumulatedCommissionRecord is used for import / export via genesis +// json. +type ValidatorAccumulatedCommissionRecord struct { + // validator_address is the address of the validator. + ValidatorAddress string `protobuf:"bytes,1,opt,name=validator_address,json=validatorAddress,proto3" json:"validator_address,omitempty"` + // accumulated is the accumulated commission of a validator. + Accumulated ValidatorAccumulatedCommission `protobuf:"bytes,2,opt,name=accumulated,proto3" json:"accumulated"` +} + +func (m *ValidatorAccumulatedCommissionRecord) Reset() { *m = ValidatorAccumulatedCommissionRecord{} } +func (m *ValidatorAccumulatedCommissionRecord) String() string { return proto.CompactTextString(m) } +func (*ValidatorAccumulatedCommissionRecord) ProtoMessage() {} +func (*ValidatorAccumulatedCommissionRecord) Descriptor() ([]byte, []int) { + return fileDescriptor_83b8e7899b41b162, []int{2} +} +func (m *ValidatorAccumulatedCommissionRecord) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ValidatorAccumulatedCommissionRecord) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ValidatorAccumulatedCommissionRecord.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 *ValidatorAccumulatedCommissionRecord) XXX_Merge(src proto.Message) { + xxx_messageInfo_ValidatorAccumulatedCommissionRecord.Merge(m, src) +} +func (m *ValidatorAccumulatedCommissionRecord) XXX_Size() int { + return m.Size() +} +func (m *ValidatorAccumulatedCommissionRecord) XXX_DiscardUnknown() { + xxx_messageInfo_ValidatorAccumulatedCommissionRecord.DiscardUnknown(m) +} + +var xxx_messageInfo_ValidatorAccumulatedCommissionRecord proto.InternalMessageInfo + +// ValidatorHistoricalRewardsRecord is used for import / export via genesis +// json. +type ValidatorHistoricalRewardsRecord struct { + // validator_address is the address of the validator. + ValidatorAddress string `protobuf:"bytes,1,opt,name=validator_address,json=validatorAddress,proto3" json:"validator_address,omitempty"` + // period defines the period the historical rewards apply to. + Period uint64 `protobuf:"varint,2,opt,name=period,proto3" json:"period,omitempty"` + // rewards defines the historical rewards of a validator. + Rewards ValidatorHistoricalRewards `protobuf:"bytes,3,opt,name=rewards,proto3" json:"rewards"` +} + +func (m *ValidatorHistoricalRewardsRecord) Reset() { *m = ValidatorHistoricalRewardsRecord{} } +func (m *ValidatorHistoricalRewardsRecord) String() string { return proto.CompactTextString(m) } +func (*ValidatorHistoricalRewardsRecord) ProtoMessage() {} +func (*ValidatorHistoricalRewardsRecord) Descriptor() ([]byte, []int) { + return fileDescriptor_83b8e7899b41b162, []int{3} +} +func (m *ValidatorHistoricalRewardsRecord) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ValidatorHistoricalRewardsRecord) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ValidatorHistoricalRewardsRecord.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 *ValidatorHistoricalRewardsRecord) XXX_Merge(src proto.Message) { + xxx_messageInfo_ValidatorHistoricalRewardsRecord.Merge(m, src) +} +func (m *ValidatorHistoricalRewardsRecord) XXX_Size() int { + return m.Size() +} +func (m *ValidatorHistoricalRewardsRecord) XXX_DiscardUnknown() { + xxx_messageInfo_ValidatorHistoricalRewardsRecord.DiscardUnknown(m) +} + +var xxx_messageInfo_ValidatorHistoricalRewardsRecord proto.InternalMessageInfo + +// ValidatorCurrentRewardsRecord is used for import / export via genesis json. +type ValidatorCurrentRewardsRecord struct { + // validator_address is the address of the validator. + ValidatorAddress string `protobuf:"bytes,1,opt,name=validator_address,json=validatorAddress,proto3" json:"validator_address,omitempty"` + // rewards defines the current rewards of a validator. + Rewards ValidatorCurrentRewards `protobuf:"bytes,2,opt,name=rewards,proto3" json:"rewards"` +} + +func (m *ValidatorCurrentRewardsRecord) Reset() { *m = ValidatorCurrentRewardsRecord{} } +func (m *ValidatorCurrentRewardsRecord) String() string { return proto.CompactTextString(m) } +func (*ValidatorCurrentRewardsRecord) ProtoMessage() {} +func (*ValidatorCurrentRewardsRecord) Descriptor() ([]byte, []int) { + return fileDescriptor_83b8e7899b41b162, []int{4} +} +func (m *ValidatorCurrentRewardsRecord) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ValidatorCurrentRewardsRecord) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ValidatorCurrentRewardsRecord.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 *ValidatorCurrentRewardsRecord) XXX_Merge(src proto.Message) { + xxx_messageInfo_ValidatorCurrentRewardsRecord.Merge(m, src) +} +func (m *ValidatorCurrentRewardsRecord) XXX_Size() int { + return m.Size() +} +func (m *ValidatorCurrentRewardsRecord) XXX_DiscardUnknown() { + xxx_messageInfo_ValidatorCurrentRewardsRecord.DiscardUnknown(m) +} + +var xxx_messageInfo_ValidatorCurrentRewardsRecord proto.InternalMessageInfo + +// DelegatorStartingInfoRecord used for import / export via genesis json. +type DelegatorStartingInfoRecord struct { + // delegator_address is the address of the delegator. + DelegatorAddress string `protobuf:"bytes,1,opt,name=delegator_address,json=delegatorAddress,proto3" json:"delegator_address,omitempty"` + // validator_address is the address of the validator. + ValidatorAddress string `protobuf:"bytes,2,opt,name=validator_address,json=validatorAddress,proto3" json:"validator_address,omitempty"` + // starting_info defines the starting info of a delegator. + StartingInfo DelegatorStartingInfo `protobuf:"bytes,3,opt,name=starting_info,json=startingInfo,proto3" json:"starting_info"` +} + +func (m *DelegatorStartingInfoRecord) Reset() { *m = DelegatorStartingInfoRecord{} } +func (m *DelegatorStartingInfoRecord) String() string { return proto.CompactTextString(m) } +func (*DelegatorStartingInfoRecord) ProtoMessage() {} +func (*DelegatorStartingInfoRecord) Descriptor() ([]byte, []int) { + return fileDescriptor_83b8e7899b41b162, []int{5} +} +func (m *DelegatorStartingInfoRecord) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *DelegatorStartingInfoRecord) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_DelegatorStartingInfoRecord.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 *DelegatorStartingInfoRecord) XXX_Merge(src proto.Message) { + xxx_messageInfo_DelegatorStartingInfoRecord.Merge(m, src) +} +func (m *DelegatorStartingInfoRecord) XXX_Size() int { + return m.Size() +} +func (m *DelegatorStartingInfoRecord) XXX_DiscardUnknown() { + xxx_messageInfo_DelegatorStartingInfoRecord.DiscardUnknown(m) +} + +var xxx_messageInfo_DelegatorStartingInfoRecord proto.InternalMessageInfo + +// ValidatorSlashEventRecord is used for import / export via genesis json. +type ValidatorSlashEventRecord struct { + // validator_address is the address of the validator. + ValidatorAddress string `protobuf:"bytes,1,opt,name=validator_address,json=validatorAddress,proto3" json:"validator_address,omitempty"` + // height defines the block height at which the slash event occured. + Height uint64 `protobuf:"varint,2,opt,name=height,proto3" json:"height,omitempty"` + // period is the period of the slash event. + Period uint64 `protobuf:"varint,3,opt,name=period,proto3" json:"period,omitempty"` + // validator_slash_event describes the slash event. + ValidatorSlashEvent ValidatorSlashEvent `protobuf:"bytes,4,opt,name=validator_slash_event,json=validatorSlashEvent,proto3" json:"validator_slash_event"` +} + +func (m *ValidatorSlashEventRecord) Reset() { *m = ValidatorSlashEventRecord{} } +func (m *ValidatorSlashEventRecord) String() string { return proto.CompactTextString(m) } +func (*ValidatorSlashEventRecord) ProtoMessage() {} +func (*ValidatorSlashEventRecord) Descriptor() ([]byte, []int) { + return fileDescriptor_83b8e7899b41b162, []int{6} +} +func (m *ValidatorSlashEventRecord) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ValidatorSlashEventRecord) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ValidatorSlashEventRecord.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 *ValidatorSlashEventRecord) XXX_Merge(src proto.Message) { + xxx_messageInfo_ValidatorSlashEventRecord.Merge(m, src) +} +func (m *ValidatorSlashEventRecord) XXX_Size() int { + return m.Size() +} +func (m *ValidatorSlashEventRecord) XXX_DiscardUnknown() { + xxx_messageInfo_ValidatorSlashEventRecord.DiscardUnknown(m) +} + +var xxx_messageInfo_ValidatorSlashEventRecord proto.InternalMessageInfo + // GenesisState defines the incentive module's genesis state. type GenesisState struct { Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` + // fee_pool defines the fee pool at genesis. + FeePool FeePool `protobuf:"bytes,2,opt,name=fee_pool,json=feePool,proto3" json:"fee_pool"` + // fee_pool defines the delegator withdraw infos at genesis. + DelegatorWithdrawInfos []DelegatorWithdrawInfo `protobuf:"bytes,3,rep,name=delegator_withdraw_infos,json=delegatorWithdrawInfos,proto3" json:"delegator_withdraw_infos"` + // fee_pool defines the previous proposer at genesis. + PreviousProposer string `protobuf:"bytes,4,opt,name=previous_proposer,json=previousProposer,proto3" json:"previous_proposer,omitempty"` + // fee_pool defines the outstanding rewards of all validators at genesis. + OutstandingRewards []ValidatorOutstandingRewardsRecord `protobuf:"bytes,5,rep,name=outstanding_rewards,json=outstandingRewards,proto3" json:"outstanding_rewards"` + // fee_pool defines the accumulated commisions of all validators at genesis. + ValidatorAccumulatedCommissions []ValidatorAccumulatedCommissionRecord `protobuf:"bytes,6,rep,name=validator_accumulated_commissions,json=validatorAccumulatedCommissions,proto3" json:"validator_accumulated_commissions"` + // fee_pool defines the historical rewards of all validators at genesis. + ValidatorHistoricalRewards []ValidatorHistoricalRewardsRecord `protobuf:"bytes,7,rep,name=validator_historical_rewards,json=validatorHistoricalRewards,proto3" json:"validator_historical_rewards"` + // fee_pool defines the current rewards of all validators at genesis. + ValidatorCurrentRewards []ValidatorCurrentRewardsRecord `protobuf:"bytes,8,rep,name=validator_current_rewards,json=validatorCurrentRewards,proto3" json:"validator_current_rewards"` + // fee_pool defines the delegator starting infos at genesis. + DelegatorStartingInfos []DelegatorStartingInfoRecord `protobuf:"bytes,9,rep,name=delegator_starting_infos,json=delegatorStartingInfos,proto3" json:"delegator_starting_infos"` + // fee_pool defines the validator slash events at genesis. + ValidatorSlashEvents []ValidatorSlashEventRecord `protobuf:"bytes,10,rep,name=validator_slash_events,json=validatorSlashEvents,proto3" json:"validator_slash_events"` } 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_83b8e7899b41b162, []int{0} + return fileDescriptor_83b8e7899b41b162, []int{7} } func (m *GenesisState) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -68,30 +387,143 @@ func (m *GenesisState) GetParams() Params { return Params{} } +func (m *GenesisState) GetFeePool() FeePool { + if m != nil { + return m.FeePool + } + return FeePool{} +} + +func (m *GenesisState) GetDelegatorWithdrawInfos() []DelegatorWithdrawInfo { + if m != nil { + return m.DelegatorWithdrawInfos + } + return nil +} + +func (m *GenesisState) GetPreviousProposer() string { + if m != nil { + return m.PreviousProposer + } + return "" +} + +func (m *GenesisState) GetOutstandingRewards() []ValidatorOutstandingRewardsRecord { + if m != nil { + return m.OutstandingRewards + } + return nil +} + +func (m *GenesisState) GetValidatorAccumulatedCommissions() []ValidatorAccumulatedCommissionRecord { + if m != nil { + return m.ValidatorAccumulatedCommissions + } + return nil +} + +func (m *GenesisState) GetValidatorHistoricalRewards() []ValidatorHistoricalRewardsRecord { + if m != nil { + return m.ValidatorHistoricalRewards + } + return nil +} + +func (m *GenesisState) GetValidatorCurrentRewards() []ValidatorCurrentRewardsRecord { + if m != nil { + return m.ValidatorCurrentRewards + } + return nil +} + +func (m *GenesisState) GetDelegatorStartingInfos() []DelegatorStartingInfoRecord { + if m != nil { + return m.DelegatorStartingInfos + } + return nil +} + +func (m *GenesisState) GetValidatorSlashEvents() []ValidatorSlashEventRecord { + if m != nil { + return m.ValidatorSlashEvents + } + return nil +} + func init() { + proto.RegisterType((*DelegatorWithdrawInfo)(nil), "elysnetwork.elys.incentive.DelegatorWithdrawInfo") + proto.RegisterType((*ValidatorOutstandingRewardsRecord)(nil), "elysnetwork.elys.incentive.ValidatorOutstandingRewardsRecord") + proto.RegisterType((*ValidatorAccumulatedCommissionRecord)(nil), "elysnetwork.elys.incentive.ValidatorAccumulatedCommissionRecord") + proto.RegisterType((*ValidatorHistoricalRewardsRecord)(nil), "elysnetwork.elys.incentive.ValidatorHistoricalRewardsRecord") + proto.RegisterType((*ValidatorCurrentRewardsRecord)(nil), "elysnetwork.elys.incentive.ValidatorCurrentRewardsRecord") + proto.RegisterType((*DelegatorStartingInfoRecord)(nil), "elysnetwork.elys.incentive.DelegatorStartingInfoRecord") + proto.RegisterType((*ValidatorSlashEventRecord)(nil), "elysnetwork.elys.incentive.ValidatorSlashEventRecord") proto.RegisterType((*GenesisState)(nil), "elysnetwork.elys.incentive.GenesisState") } func init() { proto.RegisterFile("elys/incentive/genesis.proto", fileDescriptor_83b8e7899b41b162) } var fileDescriptor_83b8e7899b41b162 = []byte{ - // 200 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x49, 0xcd, 0xa9, 0x2c, - 0xd6, 0xcf, 0xcc, 0x4b, 0x4e, 0xcd, 0x2b, 0xc9, 0x2c, 0x4b, 0xd5, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, - 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x92, 0x02, 0xc9, 0xe6, 0xa5, 0x96, 0x94, - 0xe7, 0x17, 0x65, 0xeb, 0x81, 0xd8, 0x7a, 0x70, 0x95, 0x52, 0x22, 0xe9, 0xf9, 0xe9, 0xf9, 0x60, - 0x65, 0xfa, 0x20, 0x16, 0x44, 0x87, 0x94, 0x34, 0x9a, 0x79, 0x05, 0x89, 0x45, 0x89, 0xb9, 0x50, - 0xe3, 0x94, 0x02, 0xb8, 0x78, 0xdc, 0x21, 0xe6, 0x07, 0x97, 0x24, 0x96, 0xa4, 0x0a, 0x39, 0x70, - 0xb1, 0x41, 0xe4, 0x25, 0x18, 0x15, 0x18, 0x35, 0xb8, 0x8d, 0x94, 0xf4, 0x70, 0xdb, 0xa7, 0x17, - 0x00, 0x56, 0xe9, 0xc4, 0x72, 0xe2, 0x9e, 0x3c, 0x43, 0x10, 0x54, 0x9f, 0x93, 0xc7, 0x89, 0x47, - 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0xc3, 0x85, - 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0xe9, 0xa5, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, - 0x25, 0xe7, 0xe7, 0xea, 0x83, 0x4c, 0xd2, 0x85, 0x1a, 0x0b, 0xe6, 0xe8, 0x57, 0x20, 0x39, 0xb1, - 0xa4, 0xb2, 0x20, 0xb5, 0x38, 0x89, 0x0d, 0xec, 0x44, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, - 0x61, 0x43, 0xb9, 0x25, 0x11, 0x01, 0x00, 0x00, + // 886 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x56, 0xcd, 0x4e, 0xeb, 0x46, + 0x14, 0x8e, 0x09, 0x0d, 0x61, 0x42, 0x55, 0x6a, 0x7e, 0x1a, 0x02, 0x4d, 0x80, 0x76, 0x41, 0x85, + 0xb0, 0x05, 0xa8, 0xad, 0x8a, 0x5a, 0x89, 0xbf, 0xb6, 0x74, 0x55, 0x94, 0x48, 0x54, 0xaa, 0x2a, + 0x45, 0x13, 0x7b, 0xe2, 0x8c, 0x70, 0x3c, 0x66, 0x66, 0xe2, 0x14, 0x75, 0x57, 0x75, 0xd1, 0x65, + 0xd5, 0x27, 0x60, 0xdd, 0xae, 0xfa, 0x08, 0xdd, 0x71, 0x77, 0x2c, 0xef, 0xea, 0x72, 0x05, 0x9b, + 0xbb, 0xb9, 0xef, 0x70, 0xe5, 0xf1, 0xf8, 0x0f, 0x9c, 0x28, 0x84, 0x55, 0x32, 0x73, 0xce, 0x9c, + 0xf3, 0x7d, 0xe7, 0x9c, 0xf9, 0x3c, 0x60, 0x05, 0xd9, 0x97, 0x4c, 0xc7, 0x8e, 0x81, 0x1c, 0x8e, + 0x3d, 0xa4, 0x5b, 0xc8, 0x41, 0x0c, 0x33, 0xcd, 0xa5, 0x84, 0x13, 0xb5, 0xe2, 0x5b, 0x1d, 0xc4, + 0xfb, 0x84, 0x9e, 0x6b, 0xfe, 0x7f, 0x2d, 0xf2, 0xac, 0xcc, 0x5b, 0xc4, 0x22, 0xc2, 0x4d, 0xf7, + 0xff, 0x05, 0x27, 0x2a, 0xcb, 0x0f, 0xe2, 0xb9, 0x90, 0xc2, 0xae, 0x0c, 0x57, 0x59, 0x7b, 0x60, + 0x34, 0x31, 0xe3, 0x14, 0xb7, 0x7a, 0x1c, 0x13, 0x47, 0xba, 0x54, 0x0d, 0xc2, 0xba, 0x84, 0xe9, + 0x2d, 0xc8, 0x90, 0xee, 0x6d, 0xb7, 0x10, 0x87, 0xdb, 0xba, 0x41, 0xb0, 0xb4, 0xaf, 0x5f, 0x82, + 0x85, 0x63, 0x64, 0x23, 0x0b, 0x72, 0x42, 0x7f, 0xc2, 0xbc, 0x63, 0x52, 0xd8, 0xff, 0xc1, 0x69, + 0x13, 0x75, 0x13, 0x7c, 0x68, 0x86, 0x86, 0x26, 0x34, 0x4d, 0x8a, 0x18, 0x2b, 0x2b, 0xab, 0xca, + 0xc6, 0x74, 0x7d, 0x36, 0x32, 0x1c, 0x04, 0xfb, 0xea, 0x67, 0x60, 0xb6, 0x2f, 0x0f, 0x47, 0xbe, + 0x13, 0xc2, 0xf7, 0x83, 0x70, 0x5f, 0xba, 0xee, 0x15, 0xff, 0xbc, 0xaa, 0xe5, 0xde, 0x5c, 0xd5, + 0x72, 0xeb, 0xb7, 0x0a, 0x58, 0x3b, 0x83, 0x36, 0x36, 0xfd, 0x48, 0x3f, 0xf6, 0x38, 0xe3, 0xd0, + 0x31, 0xb1, 0x63, 0xd5, 0x51, 0x1f, 0x52, 0x93, 0xd5, 0x91, 0x41, 0xa8, 0xe9, 0xe3, 0xf0, 0x42, + 0xa7, 0x87, 0x38, 0x22, 0x43, 0x88, 0xe3, 0x77, 0x05, 0xcc, 0x91, 0x38, 0x52, 0x93, 0x06, 0xa1, + 0xca, 0x13, 0xab, 0xf9, 0x8d, 0xd2, 0xce, 0x8a, 0x16, 0x14, 0x43, 0xf3, 0x8b, 0xa1, 0xc9, 0x62, + 0x68, 0xc7, 0xc8, 0x38, 0x22, 0xd8, 0x39, 0xdc, 0xbd, 0x7e, 0x55, 0xcb, 0xfd, 0x73, 0x5b, 0xdb, + 0xb4, 0x30, 0xef, 0xf4, 0x5a, 0x9a, 0x41, 0xba, 0xba, 0x2c, 0x5e, 0xf0, 0xb3, 0xc5, 0xcc, 0x73, + 0x9d, 0x5f, 0xba, 0x88, 0x85, 0x67, 0x58, 0x5d, 0x25, 0x8f, 0x70, 0x27, 0x18, 0xfe, 0xaf, 0x80, + 0x4f, 0x23, 0x86, 0x07, 0x86, 0xd1, 0xeb, 0xf6, 0x6c, 0xc8, 0x91, 0x79, 0x44, 0xba, 0x5d, 0xcc, + 0x18, 0x26, 0xce, 0x38, 0x24, 0x5b, 0xa0, 0x04, 0xe3, 0x58, 0xa2, 0xce, 0xa5, 0x9d, 0x3d, 0x6d, + 0xf0, 0x68, 0x69, 0xc3, 0x31, 0x1c, 0x4e, 0xfa, 0xcc, 0xeb, 0xc9, 0xa0, 0x09, 0x0e, 0x2f, 0x14, + 0xb0, 0x1a, 0x9d, 0x3f, 0xc1, 0x8c, 0x13, 0x8a, 0x0d, 0x68, 0x3f, 0xa3, 0x49, 0x8b, 0xa0, 0xe0, + 0x22, 0x8a, 0x49, 0x00, 0x7d, 0xb2, 0x2e, 0x57, 0xea, 0x19, 0x98, 0x0a, 0xfb, 0x95, 0x17, 0x9c, + 0xbe, 0x18, 0x89, 0xd3, 0x23, 0x4c, 0x92, 0x4f, 0x18, 0x2c, 0xc1, 0xe5, 0x5f, 0x05, 0x7c, 0x1c, + 0x9d, 0x3b, 0xea, 0x51, 0x8a, 0x1c, 0xfe, 0x0c, 0x22, 0x8d, 0x18, 0x70, 0xd0, 0x84, 0xdd, 0x91, + 0x00, 0xa7, 0x13, 0x0f, 0x46, 0x7b, 0xab, 0x80, 0xe5, 0xe8, 0x6e, 0x36, 0x38, 0xa4, 0x1c, 0x3b, + 0x96, 0x7f, 0x37, 0x63, 0xac, 0xa3, 0xdf, 0xd0, 0x4c, 0x62, 0x13, 0x03, 0x88, 0xfd, 0x02, 0xde, + 0x67, 0x32, 0x5f, 0x13, 0x3b, 0x6d, 0x22, 0xfb, 0xb1, 0x3d, 0x8c, 0x5e, 0x26, 0x52, 0x49, 0x6e, + 0x86, 0x25, 0xf6, 0x12, 0x0c, 0xdf, 0x2a, 0x60, 0x29, 0x2a, 0x4b, 0xc3, 0x86, 0xac, 0xf3, 0xad, + 0x27, 0x2a, 0x33, 0xd6, 0x50, 0x75, 0x10, 0xb6, 0x3a, 0x3c, 0x1c, 0xaa, 0x60, 0x95, 0x18, 0xb6, + 0x7c, 0x6a, 0xd8, 0x30, 0x58, 0x88, 0x83, 0x33, 0x3f, 0x75, 0x13, 0xf9, 0xb9, 0xcb, 0x93, 0x82, + 0xaa, 0x3e, 0x52, 0x27, 0x63, 0xc8, 0x92, 0xe8, 0x9c, 0xf7, 0xd8, 0x94, 0xe0, 0xfb, 0x5f, 0x11, + 0xcc, 0x7c, 0x1f, 0x7c, 0x10, 0x1a, 0x1c, 0x72, 0xa4, 0xee, 0x83, 0x42, 0x20, 0xe8, 0x82, 0x57, + 0x69, 0x67, 0x7d, 0x58, 0xda, 0x53, 0xe1, 0x29, 0x33, 0xc9, 0x73, 0xea, 0x31, 0x28, 0xb6, 0x11, + 0x6a, 0xba, 0x84, 0xd8, 0x72, 0x08, 0x3f, 0x19, 0x16, 0xe3, 0x3b, 0x84, 0x4e, 0x09, 0xb1, 0xc3, + 0xa1, 0x6b, 0x07, 0x4b, 0xf5, 0x02, 0x94, 0xe3, 0x51, 0x8a, 0x94, 0xdc, 0x6f, 0xbd, 0x7f, 0x17, + 0xf3, 0x23, 0xf7, 0x3e, 0xf9, 0x05, 0x91, 0x39, 0x16, 0xcd, 0x2c, 0xa3, 0x18, 0x48, 0x97, 0x22, + 0x0f, 0x93, 0x1e, 0x6b, 0xba, 0x94, 0xb8, 0x84, 0x21, 0x2a, 0x8a, 0x3f, 0x5d, 0x9f, 0x0d, 0x0d, + 0xa7, 0x72, 0x5f, 0xe5, 0xd9, 0xb2, 0xfe, 0x9e, 0x80, 0xf6, 0xcd, 0x48, 0xbd, 0x1a, 0xf4, 0x81, + 0x91, 0x30, 0x33, 0x84, 0x5c, 0xfd, 0x5b, 0x01, 0x6b, 0x89, 0x09, 0x8c, 0xe5, 0xb1, 0x69, 0x44, + 0xe2, 0xc9, 0xca, 0x05, 0x01, 0x62, 0x7f, 0x7c, 0xfd, 0x4d, 0xe1, 0xa8, 0x79, 0x43, 0x7d, 0x99, + 0xfa, 0x87, 0x02, 0x56, 0x62, 0x50, 0x9d, 0x48, 0xfc, 0xa2, 0xa2, 0x4c, 0x09, 0x3c, 0x5f, 0x8f, + 0xa7, 0x9d, 0x29, 0x2c, 0x15, 0x6f, 0xa0, 0x9f, 0xfa, 0x1b, 0x58, 0x8a, 0x51, 0x18, 0x81, 0xa2, + 0x45, 0x10, 0x8a, 0x02, 0xc2, 0x57, 0x63, 0xa8, 0x61, 0x2a, 0xff, 0x47, 0x5e, 0xb6, 0x93, 0xda, + 0x4f, 0x8e, 0x6b, 0x4a, 0xa9, 0x58, 0x79, 0x5a, 0xe4, 0xfe, 0xf2, 0xc9, 0x52, 0x95, 0xca, 0x1c, + 0x0f, 0x6d, 0xd2, 0x85, 0xa9, 0x17, 0x60, 0x31, 0x53, 0x35, 0x58, 0x19, 0x88, 0xb4, 0x9f, 0x3f, + 0x51, 0x36, 0x52, 0x49, 0xe7, 0x33, 0xc4, 0x83, 0x1d, 0x9e, 0x5c, 0xdf, 0x55, 0x95, 0x9b, 0xbb, + 0xaa, 0xf2, 0xfa, 0xae, 0xaa, 0xfc, 0x75, 0x5f, 0xcd, 0xdd, 0xdc, 0x57, 0x73, 0x2f, 0xef, 0xab, + 0xb9, 0x9f, 0xb5, 0xc4, 0x43, 0xc5, 0x4f, 0xb5, 0x25, 0xf3, 0x8a, 0x85, 0xfe, 0x6b, 0xe2, 0x5d, + 0x28, 0x1e, 0x2d, 0xad, 0x82, 0x78, 0xf1, 0xed, 0xbe, 0x0b, 0x00, 0x00, 0xff, 0xff, 0xea, 0x57, + 0x1e, 0xe7, 0xa3, 0x0a, 0x00, 0x00, } -func (m *GenesisState) Marshal() (dAtA []byte, err error) { +func (m *DelegatorWithdrawInfo) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -101,59 +533,1543 @@ func (m *GenesisState) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *GenesisState) MarshalTo(dAtA []byte) (int, error) { +func (m *DelegatorWithdrawInfo) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *DelegatorWithdrawInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - { - size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) + if len(m.WithdrawAddress) > 0 { + i -= len(m.WithdrawAddress) + copy(dAtA[i:], m.WithdrawAddress) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.WithdrawAddress))) + i-- + dAtA[i] = 0x12 + } + if len(m.DelegatorAddress) > 0 { + i -= len(m.DelegatorAddress) + copy(dAtA[i:], m.DelegatorAddress) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.DelegatorAddress))) + i-- + dAtA[i] = 0xa } - 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++ +func (m *ValidatorOutstandingRewardsRecord) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } - dAtA[offset] = uint8(v) - return base + return dAtA[:n], nil } -func (m *GenesisState) Size() (n int) { - if m == nil { - return 0 - } + +func (m *ValidatorOutstandingRewardsRecord) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ValidatorOutstandingRewardsRecord) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - l = m.Params.Size() - n += 1 + l + sovGenesis(uint64(l)) - return n + if len(m.OutstandingRewards) > 0 { + for iNdEx := len(m.OutstandingRewards) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.OutstandingRewards[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.ValidatorAddress) > 0 { + i -= len(m.ValidatorAddress) + copy(dAtA[i:], m.ValidatorAddress) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.ValidatorAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil } -func sovGenesis(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 +func (m *ValidatorAccumulatedCommissionRecord) 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 sozGenesis(x uint64) (n int) { - return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63)))) + +func (m *ValidatorAccumulatedCommissionRecord) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *GenesisState) Unmarshal(dAtA []byte) error { - l := len(dAtA) + +func (m *ValidatorAccumulatedCommissionRecord) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Accumulated.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.ValidatorAddress) > 0 { + i -= len(m.ValidatorAddress) + copy(dAtA[i:], m.ValidatorAddress) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.ValidatorAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *ValidatorHistoricalRewardsRecord) 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 *ValidatorHistoricalRewardsRecord) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ValidatorHistoricalRewardsRecord) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Rewards.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if m.Period != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.Period)) + i-- + dAtA[i] = 0x10 + } + if len(m.ValidatorAddress) > 0 { + i -= len(m.ValidatorAddress) + copy(dAtA[i:], m.ValidatorAddress) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.ValidatorAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *ValidatorCurrentRewardsRecord) 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 *ValidatorCurrentRewardsRecord) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ValidatorCurrentRewardsRecord) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Rewards.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.ValidatorAddress) > 0 { + i -= len(m.ValidatorAddress) + copy(dAtA[i:], m.ValidatorAddress) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.ValidatorAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *DelegatorStartingInfoRecord) 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 *DelegatorStartingInfoRecord) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *DelegatorStartingInfoRecord) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.StartingInfo.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if len(m.ValidatorAddress) > 0 { + i -= len(m.ValidatorAddress) + copy(dAtA[i:], m.ValidatorAddress) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.ValidatorAddress))) + i-- + dAtA[i] = 0x12 + } + if len(m.DelegatorAddress) > 0 { + i -= len(m.DelegatorAddress) + copy(dAtA[i:], m.DelegatorAddress) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.DelegatorAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *ValidatorSlashEventRecord) 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 *ValidatorSlashEventRecord) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ValidatorSlashEventRecord) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.ValidatorSlashEvent.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + if m.Period != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.Period)) + i-- + dAtA[i] = 0x18 + } + if m.Height != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.Height)) + i-- + dAtA[i] = 0x10 + } + if len(m.ValidatorAddress) > 0 { + i -= len(m.ValidatorAddress) + copy(dAtA[i:], m.ValidatorAddress) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.ValidatorAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *GenesisState) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *GenesisState) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ValidatorSlashEvents) > 0 { + for iNdEx := len(m.ValidatorSlashEvents) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.ValidatorSlashEvents[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.DelegatorStartingInfos) > 0 { + for iNdEx := len(m.DelegatorStartingInfos) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.DelegatorStartingInfos[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x4a + } + } + if len(m.ValidatorCurrentRewards) > 0 { + for iNdEx := len(m.ValidatorCurrentRewards) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.ValidatorCurrentRewards[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.ValidatorHistoricalRewards) > 0 { + for iNdEx := len(m.ValidatorHistoricalRewards) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.ValidatorHistoricalRewards[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x3a + } + } + if len(m.ValidatorAccumulatedCommissions) > 0 { + for iNdEx := len(m.ValidatorAccumulatedCommissions) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.ValidatorAccumulatedCommissions[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 + } + } + if len(m.OutstandingRewards) > 0 { + for iNdEx := len(m.OutstandingRewards) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.OutstandingRewards[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + } + } + if len(m.PreviousProposer) > 0 { + i -= len(m.PreviousProposer) + copy(dAtA[i:], m.PreviousProposer) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.PreviousProposer))) + i-- + dAtA[i] = 0x22 + } + if len(m.DelegatorWithdrawInfos) > 0 { + for iNdEx := len(m.DelegatorWithdrawInfos) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.DelegatorWithdrawInfos[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + { + size, err := m.FeePool.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { + offset -= sovGenesis(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *DelegatorWithdrawInfo) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.DelegatorAddress) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + l = len(m.WithdrawAddress) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + return n +} + +func (m *ValidatorOutstandingRewardsRecord) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ValidatorAddress) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + if len(m.OutstandingRewards) > 0 { + for _, e := range m.OutstandingRewards { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + return n +} + +func (m *ValidatorAccumulatedCommissionRecord) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ValidatorAddress) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + l = m.Accumulated.Size() + n += 1 + l + sovGenesis(uint64(l)) + return n +} + +func (m *ValidatorHistoricalRewardsRecord) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ValidatorAddress) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + if m.Period != 0 { + n += 1 + sovGenesis(uint64(m.Period)) + } + l = m.Rewards.Size() + n += 1 + l + sovGenesis(uint64(l)) + return n +} + +func (m *ValidatorCurrentRewardsRecord) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ValidatorAddress) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + l = m.Rewards.Size() + n += 1 + l + sovGenesis(uint64(l)) + return n +} + +func (m *DelegatorStartingInfoRecord) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.DelegatorAddress) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + l = len(m.ValidatorAddress) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + l = m.StartingInfo.Size() + n += 1 + l + sovGenesis(uint64(l)) + return n +} + +func (m *ValidatorSlashEventRecord) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ValidatorAddress) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + if m.Height != 0 { + n += 1 + sovGenesis(uint64(m.Height)) + } + if m.Period != 0 { + n += 1 + sovGenesis(uint64(m.Period)) + } + l = m.ValidatorSlashEvent.Size() + n += 1 + l + sovGenesis(uint64(l)) + return n +} + +func (m *GenesisState) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovGenesis(uint64(l)) + l = m.FeePool.Size() + n += 1 + l + sovGenesis(uint64(l)) + if len(m.DelegatorWithdrawInfos) > 0 { + for _, e := range m.DelegatorWithdrawInfos { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + l = len(m.PreviousProposer) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + if len(m.OutstandingRewards) > 0 { + for _, e := range m.OutstandingRewards { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.ValidatorAccumulatedCommissions) > 0 { + for _, e := range m.ValidatorAccumulatedCommissions { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.ValidatorHistoricalRewards) > 0 { + for _, e := range m.ValidatorHistoricalRewards { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.ValidatorCurrentRewards) > 0 { + for _, e := range m.ValidatorCurrentRewards { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.DelegatorStartingInfos) > 0 { + for _, e := range m.DelegatorStartingInfos { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.ValidatorSlashEvents) > 0 { + for _, e := range m.ValidatorSlashEvents { + 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 *DelegatorWithdrawInfo) 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: DelegatorWithdrawInfo: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DelegatorWithdrawInfo: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DelegatorAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DelegatorAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field WithdrawAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.WithdrawAddress = string(dAtA[iNdEx:postIndex]) + 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 *ValidatorOutstandingRewardsRecord) 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: ValidatorOutstandingRewardsRecord: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ValidatorOutstandingRewardsRecord: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ValidatorAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ValidatorAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OutstandingRewards", 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.OutstandingRewards = append(m.OutstandingRewards, types.DecCoin{}) + if err := m.OutstandingRewards[len(m.OutstandingRewards)-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 (m *ValidatorAccumulatedCommissionRecord) 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: ValidatorAccumulatedCommissionRecord: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ValidatorAccumulatedCommissionRecord: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ValidatorAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ValidatorAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Accumulated", 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.Accumulated.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 *ValidatorHistoricalRewardsRecord) 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: ValidatorHistoricalRewardsRecord: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ValidatorHistoricalRewardsRecord: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ValidatorAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ValidatorAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Period", wireType) + } + m.Period = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Period |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + 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 + } + if err := m.Rewards.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 *ValidatorCurrentRewardsRecord) 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: ValidatorCurrentRewardsRecord: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ValidatorCurrentRewardsRecord: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ValidatorAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ValidatorAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + 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 + } + if err := m.Rewards.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 *DelegatorStartingInfoRecord) 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: DelegatorStartingInfoRecord: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DelegatorStartingInfoRecord: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DelegatorAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DelegatorAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ValidatorAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ValidatorAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StartingInfo", 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.StartingInfo.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 *ValidatorSlashEventRecord) 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: ValidatorSlashEventRecord: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ValidatorSlashEventRecord: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ValidatorAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ValidatorAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) + } + m.Height = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Height |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Period", wireType) + } + m.Period = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Period |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ValidatorSlashEvent", 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.ValidatorSlashEvent.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 for iNdEx < l { preIndex := iNdEx @@ -162,28 +2078,94 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { if shift >= 64 { return ErrIntOverflowGenesis } - if iNdEx >= l { + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: GenesisState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FeePool", 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 } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break + if err := m.FeePool.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err } - } - 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: + iNdEx = postIndex + case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field DelegatorWithdrawInfos", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -210,7 +2192,244 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.DelegatorWithdrawInfos = append(m.DelegatorWithdrawInfos, DelegatorWithdrawInfo{}) + if err := m.DelegatorWithdrawInfos[len(m.DelegatorWithdrawInfos)-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 PreviousProposer", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PreviousProposer = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OutstandingRewards", 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.OutstandingRewards = append(m.OutstandingRewards, ValidatorOutstandingRewardsRecord{}) + if err := m.OutstandingRewards[len(m.OutstandingRewards)-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 ValidatorAccumulatedCommissions", 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.ValidatorAccumulatedCommissions = append(m.ValidatorAccumulatedCommissions, ValidatorAccumulatedCommissionRecord{}) + if err := m.ValidatorAccumulatedCommissions[len(m.ValidatorAccumulatedCommissions)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ValidatorHistoricalRewards", 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.ValidatorHistoricalRewards = append(m.ValidatorHistoricalRewards, ValidatorHistoricalRewardsRecord{}) + if err := m.ValidatorHistoricalRewards[len(m.ValidatorHistoricalRewards)-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 ValidatorCurrentRewards", 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.ValidatorCurrentRewards = append(m.ValidatorCurrentRewards, ValidatorCurrentRewardsRecord{}) + if err := m.ValidatorCurrentRewards[len(m.ValidatorCurrentRewards)-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 DelegatorStartingInfos", 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.DelegatorStartingInfos = append(m.DelegatorStartingInfos, DelegatorStartingInfoRecord{}) + if err := m.DelegatorStartingInfos[len(m.DelegatorStartingInfos)-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 ValidatorSlashEvents", 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.ValidatorSlashEvents = append(m.ValidatorSlashEvents, ValidatorSlashEventRecord{}) + if err := m.ValidatorSlashEvents[len(m.ValidatorSlashEvents)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex diff --git a/x/incentive/types/genesis_test.go b/x/incentive/types/genesis_test.go index c399eaada..99eb1db6b 100644 --- a/x/incentive/types/genesis_test.go +++ b/x/incentive/types/genesis_test.go @@ -18,14 +18,6 @@ func TestGenesisState_Validate(t *testing.T) { genState: types.DefaultGenesis(), valid: true, }, - { - desc: "valid genesis state", - genState: &types.GenesisState{ - - // this line is used by starport scaffolding # types/genesis/validField - }, - valid: true, - }, // this line is used by starport scaffolding # types/genesis/testcase } { t.Run(tc.desc, func(t *testing.T) { diff --git a/x/incentive/types/incentive.pb.go b/x/incentive/types/incentive.pb.go index 17c763fcc..d683f3183 100644 --- a/x/incentive/types/incentive.pb.go +++ b/x/incentive/types/incentive.pb.go @@ -33,13 +33,13 @@ type IncentiveInfo struct { // reward amount Amount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=amount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"amount" yaml:"amount"` // epoch identifier - EpochIdentifier string `protobuf:"bytes,2,opt,name=epoch_identifier,json=epochIdentifier,proto3" json:"epoch_identifier,omitempty"` + EpochIdentifier string `protobuf:"bytes,2,opt,name=epoch_identifier,json=epochIdentifier,proto3" json:"epoch_identifier,omitempty" yaml:"epoch_identifier"` // start_time of the distribution StartTime time.Time `protobuf:"bytes,3,opt,name=start_time,json=startTime,proto3,stdtime" json:"start_time" yaml:"start_time"` // distribution duration - NumEpochs int64 `protobuf:"varint,4,opt,name=num_epochs,json=numEpochs,proto3" json:"num_epochs,omitempty"` - CurrentEpoch int64 `protobuf:"varint,5,opt,name=current_epoch,json=currentEpoch,proto3" json:"current_epoch,omitempty"` - EdenBoostApr int64 `protobuf:"varint,6,opt,name=eden_boost_apr,json=edenBoostApr,proto3" json:"eden_boost_apr,omitempty"` + NumEpochs int64 `protobuf:"varint,4,opt,name=num_epochs,json=numEpochs,proto3" json:"num_epochs,omitempty" yaml:"num_epochs"` + CurrentEpoch int64 `protobuf:"varint,5,opt,name=current_epoch,json=currentEpoch,proto3" json:"current_epoch,omitempty" yaml:"current_epoch"` + EdenBoostApr int64 `protobuf:"varint,6,opt,name=eden_boost_apr,json=edenBoostApr,proto3" json:"eden_boost_apr,omitempty" yaml:"eden_boost_apr"` } func (m *IncentiveInfo) Reset() { *m = IncentiveInfo{} } @@ -117,32 +117,34 @@ func init() { func init() { proto.RegisterFile("elys/incentive/incentive.proto", fileDescriptor_ed0e67c7f36f3313) } var fileDescriptor_ed0e67c7f36f3313 = []byte{ - // 390 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x92, 0xcd, 0x8a, 0xdb, 0x30, - 0x14, 0x85, 0xad, 0xa4, 0x0d, 0x44, 0x6d, 0xfa, 0x63, 0xba, 0x30, 0x86, 0xd8, 0xc1, 0x2d, 0x25, - 0x5d, 0x44, 0x86, 0x76, 0xd7, 0x4d, 0xa9, 0xa1, 0x50, 0x6f, 0x4d, 0xa1, 0xc3, 0x6c, 0x8c, 0xed, - 0x28, 0x8e, 0x49, 0x24, 0x19, 0x49, 0x9e, 0x99, 0xbc, 0x45, 0x1e, 0x2b, 0xcb, 0xec, 0x66, 0x98, - 0x85, 0x67, 0x48, 0xde, 0x20, 0x4f, 0x30, 0x48, 0x76, 0x7e, 0x56, 0xbe, 0x3a, 0xfe, 0x74, 0x8f, - 0x8e, 0xae, 0xa0, 0x83, 0x97, 0x2b, 0xe1, 0x17, 0x34, 0xc3, 0x54, 0x16, 0x37, 0xf8, 0x5c, 0xa1, - 0x92, 0x33, 0xc9, 0x4c, 0x5b, 0xfd, 0xa7, 0x58, 0xde, 0x32, 0xbe, 0x40, 0xaa, 0x46, 0x27, 0xc2, - 0xfe, 0x94, 0xb3, 0x9c, 0x69, 0xcc, 0x57, 0x55, 0xb3, 0xc3, 0x76, 0x73, 0xc6, 0xf2, 0x25, 0xf6, - 0xf5, 0x2a, 0xad, 0x66, 0xbe, 0x2c, 0x08, 0x16, 0x32, 0x21, 0x65, 0x03, 0x78, 0xf7, 0x1d, 0x38, - 0x08, 0x8f, 0x4d, 0x42, 0x3a, 0x63, 0xe6, 0x7f, 0xd8, 0x4b, 0x08, 0xab, 0xa8, 0xb4, 0xc0, 0x08, - 0x8c, 0xfb, 0xc1, 0xaf, 0x4d, 0xed, 0x1a, 0x8f, 0xb5, 0xfb, 0x35, 0x2f, 0xe4, 0xbc, 0x4a, 0x51, - 0xc6, 0x88, 0x9f, 0x31, 0x41, 0x98, 0x68, 0x3f, 0x13, 0x31, 0x5d, 0xf8, 0x72, 0x55, 0x62, 0x81, - 0x42, 0x2a, 0x0f, 0xb5, 0x3b, 0x58, 0x25, 0x64, 0xf9, 0xd3, 0x6b, 0xba, 0x78, 0x51, 0xdb, 0xce, - 0xfc, 0x06, 0x3f, 0xe0, 0x92, 0x65, 0xf3, 0xb8, 0x98, 0x2a, 0xbb, 0x59, 0x81, 0xb9, 0xd5, 0x51, - 0x16, 0xd1, 0x7b, 0xad, 0x87, 0x27, 0xd9, 0xbc, 0x82, 0x50, 0xc8, 0x84, 0xcb, 0x58, 0x1d, 0xd7, - 0xea, 0x8e, 0xc0, 0xf8, 0xcd, 0x77, 0x1b, 0x35, 0x59, 0xd0, 0x31, 0x0b, 0xfa, 0x77, 0xcc, 0x12, - 0x0c, 0xd5, 0x19, 0x0f, 0xb5, 0xfb, 0xb1, 0x71, 0x3e, 0xef, 0xf5, 0xd6, 0x4f, 0x2e, 0x88, 0xfa, - 0x5a, 0x50, 0xb8, 0x39, 0x84, 0x90, 0x56, 0x24, 0xd6, 0x86, 0xc2, 0x7a, 0x35, 0x02, 0xe3, 0x6e, - 0xd4, 0xa7, 0x15, 0xf9, 0xa3, 0x05, 0xf3, 0x33, 0x1c, 0x64, 0x15, 0xe7, 0x98, 0xca, 0x06, 0xb1, - 0x5e, 0x6b, 0xe2, 0x6d, 0x2b, 0x6a, 0xca, 0xfc, 0x02, 0xdf, 0xe1, 0x29, 0xa6, 0x71, 0xca, 0x98, - 0x90, 0x71, 0x52, 0x72, 0xab, 0xd7, 0x50, 0x4a, 0x0d, 0x94, 0xf8, 0xbb, 0xe4, 0xc1, 0xdf, 0xcd, - 0xce, 0x01, 0xdb, 0x9d, 0x03, 0x9e, 0x77, 0x0e, 0x58, 0xef, 0x1d, 0x63, 0xbb, 0x77, 0x8c, 0x87, - 0xbd, 0x63, 0x5c, 0xa3, 0x8b, 0x9b, 0x54, 0x53, 0x9c, 0xb4, 0x23, 0xd5, 0x0b, 0xff, 0xee, 0xe2, - 0x01, 0xe8, 0x5b, 0x4d, 0x7b, 0x3a, 0xf1, 0x8f, 0x97, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x19, - 0xfb, 0xa6, 0x1f, 0x02, 0x00, 0x00, + // 427 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x52, 0xcd, 0x8e, 0xd3, 0x30, + 0x10, 0xae, 0x29, 0x54, 0xaa, 0xd9, 0xf2, 0x13, 0xed, 0x8a, 0x50, 0x44, 0x5c, 0xf9, 0x80, 0x7a, + 0x59, 0x47, 0x02, 0x4e, 0x48, 0x68, 0x45, 0x24, 0x10, 0xbd, 0x46, 0x48, 0x20, 0x2e, 0x51, 0x92, + 0xba, 0xd9, 0x68, 0x6b, 0x3b, 0xb2, 0x1d, 0xa0, 0x6f, 0xb1, 0x8f, 0xc4, 0x71, 0x8f, 0x7b, 0x44, + 0x1c, 0x02, 0x6a, 0xdf, 0x20, 0x4f, 0x80, 0x6c, 0xa7, 0x9b, 0x2d, 0x27, 0xcf, 0xcc, 0xf7, 0x7d, + 0x33, 0xfa, 0x3c, 0x03, 0x03, 0xba, 0xde, 0xa8, 0xb0, 0xe4, 0x39, 0xe5, 0xba, 0xfc, 0x46, 0xfb, + 0x88, 0x54, 0x52, 0x68, 0xe1, 0x4d, 0x0d, 0xce, 0xa9, 0xfe, 0x2e, 0xe4, 0x05, 0x31, 0x31, 0xb9, + 0x61, 0x4c, 0x8f, 0x0b, 0x51, 0x08, 0x4b, 0x0b, 0x4d, 0xe4, 0x14, 0x53, 0x54, 0x08, 0x51, 0xac, + 0x69, 0x68, 0xb3, 0xac, 0x5e, 0x85, 0xba, 0x64, 0x54, 0xe9, 0x94, 0x55, 0x8e, 0x80, 0x7f, 0x0e, + 0xe1, 0x64, 0xb1, 0x6f, 0xb2, 0xe0, 0x2b, 0xe1, 0x7d, 0x86, 0xa3, 0x94, 0x89, 0x9a, 0x6b, 0x1f, + 0xcc, 0xc0, 0x7c, 0x1c, 0x9d, 0x5d, 0x35, 0x68, 0xf0, 0xbb, 0x41, 0x2f, 0x8a, 0x52, 0x9f, 0xd7, + 0x19, 0xc9, 0x05, 0x0b, 0x73, 0xa1, 0x98, 0x50, 0xdd, 0x73, 0xaa, 0x96, 0x17, 0xa1, 0xde, 0x54, + 0x54, 0x91, 0x05, 0xd7, 0x6d, 0x83, 0x26, 0x9b, 0x94, 0xad, 0xdf, 0x60, 0xd7, 0x05, 0xc7, 0x5d, + 0x3b, 0xef, 0x03, 0x7c, 0x44, 0x2b, 0x91, 0x9f, 0x27, 0xe5, 0xd2, 0x8c, 0x5b, 0x95, 0x54, 0xfa, + 0x77, 0xec, 0x88, 0x67, 0x6d, 0x83, 0x9e, 0x38, 0xd1, 0xff, 0x0c, 0x1c, 0x3f, 0xb4, 0xa5, 0xc5, + 0x4d, 0xc5, 0xfb, 0x02, 0xa1, 0xd2, 0xa9, 0xd4, 0x89, 0xf1, 0xe2, 0x0f, 0x67, 0x60, 0x7e, 0xff, + 0xe5, 0x94, 0x38, 0xa3, 0x64, 0x6f, 0x94, 0x7c, 0xda, 0x1b, 0x8d, 0x9e, 0x1b, 0x03, 0x6d, 0x83, + 0x1e, 0xbb, 0x09, 0xbd, 0x16, 0x5f, 0xfe, 0x41, 0x20, 0x1e, 0xdb, 0x82, 0xa1, 0x7b, 0xaf, 0x21, + 0xe4, 0x35, 0x4b, 0xec, 0x40, 0xe5, 0xdf, 0x9d, 0x81, 0xf9, 0x30, 0x3a, 0xe9, 0x95, 0x3d, 0x86, + 0xe3, 0x31, 0xaf, 0xd9, 0x7b, 0x1b, 0x7b, 0x6f, 0xe1, 0x24, 0xaf, 0xa5, 0xa4, 0x5c, 0x3b, 0xd4, + 0xbf, 0x67, 0x85, 0x7e, 0xdb, 0xa0, 0x63, 0x27, 0x3c, 0x80, 0x71, 0x7c, 0xd4, 0xe5, 0x56, 0xef, + 0x9d, 0xc1, 0x07, 0x74, 0x49, 0x79, 0x92, 0x09, 0xa1, 0x74, 0x92, 0x56, 0xd2, 0x1f, 0x59, 0xfd, + 0xd3, 0xb6, 0x41, 0x27, 0xdd, 0xa7, 0x1c, 0xe0, 0x38, 0x3e, 0x32, 0x85, 0xc8, 0xe4, 0xef, 0x2a, + 0x19, 0x7d, 0xbc, 0xda, 0x06, 0xe0, 0x7a, 0x1b, 0x80, 0xbf, 0xdb, 0x00, 0x5c, 0xee, 0x82, 0xc1, + 0xf5, 0x2e, 0x18, 0xfc, 0xda, 0x05, 0x83, 0xaf, 0xe4, 0xd6, 0xca, 0xcc, 0xb9, 0x9c, 0x76, 0xb7, + 0x63, 0x93, 0xf0, 0xc7, 0xad, 0x4b, 0xb3, 0xeb, 0xcb, 0x46, 0xf6, 0xf7, 0x5e, 0xfd, 0x0b, 0x00, + 0x00, 0xff, 0xff, 0x6a, 0xa4, 0x6c, 0x88, 0x88, 0x02, 0x00, 0x00, } func (m *IncentiveInfo) Marshal() (dAtA []byte, err error) { diff --git a/x/incentive/types/keys.go b/x/incentive/types/keys.go index f6017cf5b..671f90de4 100644 --- a/x/incentive/types/keys.go +++ b/x/incentive/types/keys.go @@ -1,5 +1,13 @@ package types +import ( + "encoding/binary" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/address" + "github.com/cosmos/cosmos-sdk/types/kv" +) + const ( // ModuleName defines the module name ModuleName = "incentive" @@ -35,3 +43,196 @@ const ( func KeyPrefix(p string) []byte { return []byte(p) } + + +// Keys for distribution store +// Items are stored with the following key: values +// +// - 0x00: FeePol +// +// - 0x01: sdk.ConsAddress +// +// - 0x02: ValidatorOutstandingRewards +// +// - 0x03: sdk.AccAddress +// +// - 0x04: DelegatorStartingInfo +// +// - 0x05: ValidatorHistoricalRewards +// +// - 0x06: ValidatorCurrentRewards +// +// - 0x07: ValidatorCurrentCommission +// +// - 0x08: ValidatorSlashEvent +var ( + FeePoolKey = []byte{0x00} // key for global distribution state + ProposerKey = []byte{0x01} // key for the proposer operator address + ValidatorOutstandingRewardsPrefix = []byte{0x02} // key for outstanding rewards + + DelegatorWithdrawAddrPrefix = []byte{0x03} // key for delegator withdraw address + DelegatorStartingInfoPrefix = []byte{0x04} // key for delegator starting info + ValidatorHistoricalRewardsPrefix = []byte{0x05} // key for historical validators rewards / stake + ValidatorCurrentRewardsPrefix = []byte{0x06} // key for current validator rewards + ValidatorAccumulatedCommissionPrefix = []byte{0x07} // key for accumulated validator commission + ValidatorSlashEventPrefix = []byte{0x08} // key for validator slash fraction +) + +// GetValidatorOutstandingRewardsAddress creates an address from a validator's outstanding rewards key. +func GetValidatorOutstandingRewardsAddress(key []byte) (valAddr sdk.ValAddress) { + // key is in the format: + // 0x02 + + // Remove prefix and address length. + kv.AssertKeyAtLeastLength(key, 3) + addr := key[2:] + kv.AssertKeyLength(addr, int(key[1])) + + return sdk.ValAddress(addr) +} + +// GetDelegatorWithdrawInfoAddress creates an address from a delegator's withdraw info key. +func GetDelegatorWithdrawInfoAddress(key []byte) (delAddr sdk.AccAddress) { + // key is in the format: + // 0x03 + + // Remove prefix and address length. + kv.AssertKeyAtLeastLength(key, 3) + addr := key[2:] + kv.AssertKeyLength(addr, int(key[1])) + + return sdk.AccAddress(addr) +} + +// GetDelegatorStartingInfoAddresses creates the addresses from a delegator starting info key. +func GetDelegatorStartingInfoAddresses(key []byte) (valAddr sdk.ValAddress, delAddr sdk.AccAddress) { + // key is in the format: + // 0x04 + kv.AssertKeyAtLeastLength(key, 2) + valAddrLen := int(key[1]) + kv.AssertKeyAtLeastLength(key, 3+valAddrLen) + valAddr = sdk.ValAddress(key[2 : 2+valAddrLen]) + delAddrLen := int(key[2+valAddrLen]) + kv.AssertKeyAtLeastLength(key, 4+valAddrLen) + delAddr = sdk.AccAddress(key[3+valAddrLen:]) + kv.AssertKeyLength(delAddr.Bytes(), delAddrLen) + + return +} + +// GetValidatorHistoricalRewardsAddressPeriod creates the address & period from a validator's historical rewards key. +func GetValidatorHistoricalRewardsAddressPeriod(key []byte) (valAddr sdk.ValAddress, period uint64) { + // key is in the format: + // 0x05 + kv.AssertKeyAtLeastLength(key, 2) + valAddrLen := int(key[1]) + kv.AssertKeyAtLeastLength(key, 3+valAddrLen) + valAddr = sdk.ValAddress(key[2 : 2+valAddrLen]) + b := key[2+valAddrLen:] + kv.AssertKeyLength(b, 8) + period = binary.LittleEndian.Uint64(b) + return +} + +// GetValidatorCurrentRewardsAddress creates the address from a validator's current rewards key. +func GetValidatorCurrentRewardsAddress(key []byte) (valAddr sdk.ValAddress) { + // key is in the format: + // 0x06: ValidatorCurrentRewards + + // Remove prefix and address length. + kv.AssertKeyAtLeastLength(key, 3) + addr := key[2:] + kv.AssertKeyLength(addr, int(key[1])) + + return sdk.ValAddress(addr) +} + +// GetValidatorAccumulatedCommissionAddress creates the address from a validator's accumulated commission key. +func GetValidatorAccumulatedCommissionAddress(key []byte) (valAddr sdk.ValAddress) { + // key is in the format: + // 0x07: ValidatorCurrentRewards + + // Remove prefix and address length. + kv.AssertKeyAtLeastLength(key, 3) + addr := key[2:] + kv.AssertKeyLength(addr, int(key[1])) + + return sdk.ValAddress(addr) +} + +// GetValidatorSlashEventAddressHeight creates the height from a validator's slash event key. +func GetValidatorSlashEventAddressHeight(key []byte) (valAddr sdk.ValAddress, height uint64) { + // key is in the format: + // 0x08: ValidatorSlashEvent + kv.AssertKeyAtLeastLength(key, 2) + valAddrLen := int(key[1]) + kv.AssertKeyAtLeastLength(key, 3+valAddrLen) + valAddr = key[2 : 2+valAddrLen] + startB := 2 + valAddrLen + kv.AssertKeyAtLeastLength(key, startB+9) + b := key[startB : startB+8] // the next 8 bytes represent the height + height = binary.BigEndian.Uint64(b) + return +} + +// GetValidatorOutstandingRewardsKey creates the outstanding rewards key for a validator. +func GetValidatorOutstandingRewardsKey(valAddr sdk.ValAddress) []byte { + return append(ValidatorOutstandingRewardsPrefix, address.MustLengthPrefix(valAddr.Bytes())...) +} + +// GetDelegatorWithdrawAddrKey creates the key for a delegator's withdraw addr. +func GetDelegatorWithdrawAddrKey(delAddr sdk.AccAddress) []byte { + return append(DelegatorWithdrawAddrPrefix, address.MustLengthPrefix(delAddr.Bytes())...) +} + +// GetDelegatorStartingInfoKey creates the key for a delegator's starting info. +func GetDelegatorStartingInfoKey(v sdk.ValAddress, d sdk.AccAddress) []byte { + return append(append(DelegatorStartingInfoPrefix, address.MustLengthPrefix(v.Bytes())...), address.MustLengthPrefix(d.Bytes())...) +} + +// GetValidatorHistoricalRewardsPrefix creates the prefix key for a validator's historical rewards. +func GetValidatorHistoricalRewardsPrefix(v sdk.ValAddress) []byte { + return append(ValidatorHistoricalRewardsPrefix, address.MustLengthPrefix(v.Bytes())...) +} + +// GetValidatorHistoricalRewardsKey creates the key for a validator's historical rewards. +func GetValidatorHistoricalRewardsKey(v sdk.ValAddress, k uint64) []byte { + b := make([]byte, 8) + binary.LittleEndian.PutUint64(b, k) + return append(append(ValidatorHistoricalRewardsPrefix, address.MustLengthPrefix(v.Bytes())...), b...) +} + +// GetValidatorCurrentRewardsKey creates the key for a validator's current rewards. +func GetValidatorCurrentRewardsKey(v sdk.ValAddress) []byte { + return append(ValidatorCurrentRewardsPrefix, address.MustLengthPrefix(v.Bytes())...) +} + +// GetValidatorAccumulatedCommissionKey creates the key for a validator's current commission. +func GetValidatorAccumulatedCommissionKey(v sdk.ValAddress) []byte { + return append(ValidatorAccumulatedCommissionPrefix, address.MustLengthPrefix(v.Bytes())...) +} + +// GetValidatorSlashEventPrefix creates the prefix key for a validator's slash fractions. +func GetValidatorSlashEventPrefix(v sdk.ValAddress) []byte { + return append(ValidatorSlashEventPrefix, address.MustLengthPrefix(v.Bytes())...) +} + +// GetValidatorSlashEventKeyPrefix creates the prefix key for a validator's slash fraction (ValidatorSlashEventPrefix + height). +func GetValidatorSlashEventKeyPrefix(v sdk.ValAddress, height uint64) []byte { + heightBz := make([]byte, 8) + binary.BigEndian.PutUint64(heightBz, height) + + return append( + ValidatorSlashEventPrefix, + append(address.MustLengthPrefix(v.Bytes()), heightBz...)..., + ) +} + +// GetValidatorSlashEventKey creates the key for a validator's slash fraction. +func GetValidatorSlashEventKey(v sdk.ValAddress, height, period uint64) []byte { + periodBz := make([]byte, 8) + binary.BigEndian.PutUint64(periodBz, period) + prefix := GetValidatorSlashEventKeyPrefix(v, height) + + return append(prefix, periodBz...) +} diff --git a/x/incentive/types/messages.go b/x/incentive/types/messages.go new file mode 100644 index 000000000..889d79433 --- /dev/null +++ b/x/incentive/types/messages.go @@ -0,0 +1,125 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +const TypeMsgSetWithdrawAddress = "set_withdraw_address" + +var _ sdk.Msg = &MsgSetWithdrawAddress{} + +func NewMsgSetWithdrawAddress(delegatorAddress string, withdrawAddress string) *MsgSetWithdrawAddress { + return &MsgSetWithdrawAddress{ + DelegatorAddress: delegatorAddress, + WithdrawAddress: withdrawAddress, + } +} + +func (msg *MsgSetWithdrawAddress) Route() string { + return RouterKey +} + +func (msg *MsgSetWithdrawAddress) Type() string { + return TypeMsgSetWithdrawAddress +} + +func (msg *MsgSetWithdrawAddress) GetSigners() []sdk.AccAddress { + creator, err := sdk.AccAddressFromBech32(msg.DelegatorAddress) + if err != nil { + panic(err) + } + return []sdk.AccAddress{creator} +} + +func (msg *MsgSetWithdrawAddress) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +func (msg *MsgSetWithdrawAddress) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.DelegatorAddress) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) + } + return nil +} + +const TypeMsgWithdrawDelegatorReward = "withdraw_delegator_reward" + +var _ sdk.Msg = &MsgWithdrawDelegatorReward{} + +func NewMsgWithdrawDelegatorReward(creator string, validatorAddress string) *MsgWithdrawDelegatorReward { + return &MsgWithdrawDelegatorReward{ + DelegatorAddress: creator, + ValidatorAddress: validatorAddress, + } +} + +func (msg *MsgWithdrawDelegatorReward) Route() string { + return RouterKey +} + +func (msg *MsgWithdrawDelegatorReward) Type() string { + return TypeMsgWithdrawDelegatorReward +} + +func (msg *MsgWithdrawDelegatorReward) GetSigners() []sdk.AccAddress { + creator, err := sdk.AccAddressFromBech32(msg.DelegatorAddress) + if err != nil { + panic(err) + } + return []sdk.AccAddress{creator} +} + +func (msg *MsgWithdrawDelegatorReward) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +func (msg *MsgWithdrawDelegatorReward) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.DelegatorAddress) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) + } + return nil +} + +const TypeMsgWithdrawValidatorCommission = "withdraw_validator_commission" + +var _ sdk.Msg = &MsgWithdrawValidatorCommission{} + +func NewMsgWithdrawValidatorCommission(creator string) *MsgWithdrawValidatorCommission { + return &MsgWithdrawValidatorCommission{ + ValidatorAddress: creator, + } +} + +func (msg *MsgWithdrawValidatorCommission) Route() string { + return RouterKey +} + +func (msg *MsgWithdrawValidatorCommission) Type() string { + return TypeMsgWithdrawValidatorCommission +} + +func (msg *MsgWithdrawValidatorCommission) GetSigners() []sdk.AccAddress { + creator, err := sdk.AccAddressFromBech32(msg.ValidatorAddress) + if err != nil { + panic(err) + } + return []sdk.AccAddress{creator} +} + +func (msg *MsgWithdrawValidatorCommission) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +func (msg *MsgWithdrawValidatorCommission) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.ValidatorAddress) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) + } + return nil +} diff --git a/x/incentive/types/messages_test.go b/x/incentive/types/messages_test.go new file mode 100644 index 000000000..d3810db5c --- /dev/null +++ b/x/incentive/types/messages_test.go @@ -0,0 +1,102 @@ +package types + +import ( + "testing" + + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/elys-network/elys/testutil/sample" + "github.com/stretchr/testify/require" +) + +func TestMsgSetWithdrawAddress_ValidateBasic(t *testing.T) { + tests := []struct { + name string + msg MsgSetWithdrawAddress + err error + }{ + { + name: "invalid address", + msg: MsgSetWithdrawAddress{ + DelegatorAddress: "invalid_address", + }, + err: sdkerrors.ErrInvalidAddress, + }, { + name: "valid address", + msg: MsgSetWithdrawAddress{ + DelegatorAddress: sample.AccAddress(), + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.msg.ValidateBasic() + if tt.err != nil { + require.ErrorIs(t, err, tt.err) + return + } + require.NoError(t, err) + }) + } +} + +func TestMsgWithdrawValidatorCommission_ValidateBasic(t *testing.T) { + tests := []struct { + name string + msg MsgWithdrawValidatorCommission + err error + }{ + { + name: "invalid address", + msg: MsgWithdrawValidatorCommission{ + ValidatorAddress: "invalid_address", + }, + err: sdkerrors.ErrInvalidAddress, + }, { + name: "valid address", + msg: MsgWithdrawValidatorCommission{ + ValidatorAddress: sample.AccAddress(), + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.msg.ValidateBasic() + if tt.err != nil { + require.ErrorIs(t, err, tt.err) + return + } + require.NoError(t, err) + }) + } +} + +func TestMsgWithdrawDelegatorReward_ValidateBasic(t *testing.T) { + tests := []struct { + name string + msg MsgWithdrawDelegatorReward + err error + }{ + { + name: "invalid address", + msg: MsgWithdrawDelegatorReward{ + DelegatorAddress: "invalid_address", + }, + err: sdkerrors.ErrInvalidAddress, + }, { + name: "valid address", + msg: MsgWithdrawDelegatorReward{ + DelegatorAddress: sample.AccAddress(), + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.msg.ValidateBasic() + if tt.err != nil { + require.ErrorIs(t, err, tt.err) + return + } + require.NoError(t, err) + }) + } +} diff --git a/x/incentive/types/params.go b/x/incentive/types/params.go index 357196ad6..a0c3f47f8 100644 --- a/x/incentive/types/params.go +++ b/x/incentive/types/params.go @@ -1,12 +1,21 @@ package types import ( + fmt "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" "gopkg.in/yaml.v2" ) var _ paramtypes.ParamSet = (*Params)(nil) +// Parameter keys +var ( + ParamStoreKeyCommunityTax = []byte("communitytax") + ParamStoreKeyWithdrawAddrEnabled = []byte("withdrawaddrenabled") +) + // ParamKeyTable the param key table for launch module func ParamKeyTable() paramtypes.KeyTable { return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) @@ -14,7 +23,12 @@ func ParamKeyTable() paramtypes.KeyTable { // NewParams creates a new Params instance func NewParams() Params { - return Params{} + return Params{ + LpIncentives: []IncentiveInfo(nil), + StakeIncentives: []IncentiveInfo(nil), + CommunityTax: sdk.NewDecWithPrec(2, 2), // 2% + WithdrawAddrEnabled: true, + } } // DefaultParams returns a default set of parameters @@ -24,7 +38,10 @@ func DefaultParams() Params { // ParamSetPairs get the params.ParamSet func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { - return paramtypes.ParamSetPairs{} + return paramtypes.ParamSetPairs{ + paramtypes.NewParamSetPair(ParamStoreKeyCommunityTax, &p.CommunityTax, validateCommunityTax), + paramtypes.NewParamSetPair(ParamStoreKeyWithdrawAddrEnabled, &p.WithdrawAddrEnabled, validateWithdrawAddrEnabled), + } } // Validate validates the set of params @@ -37,3 +54,42 @@ func (p Params) String() string { out, _ := yaml.Marshal(p) return string(out) } + +// ValidateBasic performs basic validation on distribution parameters. +func (p Params) ValidateBasic() error { + if p.CommunityTax.IsNegative() || p.CommunityTax.GT(sdk.OneDec()) { + return fmt.Errorf( + "community tax should be non-negative and less than one: %s", p.CommunityTax, + ) + } + + return nil +} + +func validateCommunityTax(i interface{}) error { + v, ok := i.(sdk.Dec) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + + if v.IsNil() { + return fmt.Errorf("community tax must be not nil") + } + if v.IsNegative() { + return fmt.Errorf("community tax must be positive: %s", v) + } + if v.GT(sdk.OneDec()) { + return fmt.Errorf("community tax too large: %s", v) + } + + return nil +} + +func validateWithdrawAddrEnabled(i interface{}) error { + _, ok := i.(bool) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + + return nil +} diff --git a/x/incentive/types/params.pb.go b/x/incentive/types/params.pb.go index 402652ee5..ff1393aab 100644 --- a/x/incentive/types/params.pb.go +++ b/x/incentive/types/params.pb.go @@ -5,6 +5,7 @@ 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" io "io" @@ -25,8 +26,10 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Params defines the parameters for the module. type Params struct { - LpIncentives []IncentiveInfo `protobuf:"bytes,1,rep,name=lp_incentives,json=lpIncentives,proto3" json:"lp_incentives"` - StakeIncentives []IncentiveInfo `protobuf:"bytes,2,rep,name=stake_incentives,json=stakeIncentives,proto3" json:"stake_incentives"` + LpIncentives []IncentiveInfo `protobuf:"bytes,1,rep,name=lp_incentives,json=lpIncentives,proto3" json:"lp_incentives" yaml:"lp_incentives"` + StakeIncentives []IncentiveInfo `protobuf:"bytes,2,rep,name=stake_incentives,json=stakeIncentives,proto3" json:"stake_incentives" yaml:"stake_incentives"` + CommunityTax github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=community_tax,json=communityTax,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"community_tax"` + WithdrawAddrEnabled bool `protobuf:"varint,4,opt,name=withdraw_addr_enabled,json=withdrawAddrEnabled,proto3" json:"withdraw_addr_enabled,omitempty"` } func (m *Params) Reset() { *m = Params{} } @@ -75,6 +78,13 @@ func (m *Params) GetStakeIncentives() []IncentiveInfo { return nil } +func (m *Params) GetWithdrawAddrEnabled() bool { + if m != nil { + return m.WithdrawAddrEnabled + } + return false +} + func init() { proto.RegisterType((*Params)(nil), "elysnetwork.elys.incentive.Params") } @@ -82,22 +92,30 @@ func init() { func init() { proto.RegisterFile("elys/incentive/params.proto", fileDescriptor_3bca0267cb466fec) } var fileDescriptor_3bca0267cb466fec = []byte{ - // 229 bytes of a gzipped FileDescriptorProto + // 354 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4e, 0xcd, 0xa9, 0x2c, 0xd6, 0xcf, 0xcc, 0x4b, 0x4e, 0xcd, 0x2b, 0xc9, 0x2c, 0x4b, 0xd5, 0x2f, 0x48, 0x2c, 0x4a, 0xcc, 0x2d, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x92, 0x02, 0x49, 0xe6, 0xa5, 0x96, 0x94, 0xe7, 0x17, 0x65, 0xeb, 0x81, 0xd8, 0x7a, 0x70, 0x85, 0x52, 0x22, 0xe9, 0xf9, 0xe9, 0xf9, 0x60, 0x65, - 0xfa, 0x20, 0x16, 0x44, 0x87, 0x94, 0x1c, 0x9a, 0x71, 0x70, 0x16, 0x44, 0x5e, 0xe9, 0x00, 0x23, - 0x17, 0x5b, 0x00, 0xd8, 0x0a, 0xa1, 0x10, 0x2e, 0xde, 0x9c, 0x82, 0x78, 0xb8, 0x82, 0x62, 0x09, + 0xfa, 0x20, 0x16, 0x44, 0x87, 0x94, 0x1c, 0x9a, 0x71, 0x70, 0x16, 0x44, 0x5e, 0xe9, 0x0f, 0x13, + 0x17, 0x5b, 0x00, 0xd8, 0x0a, 0xa1, 0x1c, 0x2e, 0xde, 0x9c, 0x82, 0x78, 0xb8, 0x82, 0x62, 0x09, 0x46, 0x05, 0x66, 0x0d, 0x6e, 0x23, 0x4d, 0x3d, 0xdc, 0x96, 0xea, 0x79, 0xc2, 0x58, 0x9e, 0x79, - 0x69, 0xf9, 0x4e, 0x2c, 0x27, 0xee, 0xc9, 0x33, 0x04, 0xf1, 0xe4, 0x14, 0xc0, 0x85, 0x8b, 0x85, - 0xa2, 0xb8, 0x04, 0x8a, 0x4b, 0x12, 0xb3, 0x53, 0x91, 0x0d, 0x66, 0x22, 0xcf, 0x60, 0x7e, 0xb0, - 0x41, 0x08, 0xb3, 0xad, 0x58, 0x66, 0x2c, 0x90, 0x67, 0x70, 0xf2, 0x38, 0xf1, 0x48, 0x8e, 0xf1, - 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4, 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, - 0xe1, 0xc6, 0x63, 0x39, 0x86, 0x28, 0xbd, 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, - 0x5c, 0x7d, 0x90, 0xf9, 0xba, 0x50, 0xcb, 0xc0, 0x1c, 0xfd, 0x0a, 0xa4, 0x60, 0x29, 0xa9, 0x2c, - 0x48, 0x2d, 0x4e, 0x62, 0x03, 0x87, 0x89, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x81, 0x68, 0xe0, - 0xdd, 0x84, 0x01, 0x00, 0x00, + 0x69, 0xf9, 0x4e, 0x32, 0x27, 0xee, 0xc9, 0x33, 0x7c, 0xba, 0x27, 0x2f, 0x52, 0x99, 0x98, 0x9b, + 0x63, 0xa5, 0x84, 0x62, 0x9a, 0x52, 0x10, 0x4f, 0x4e, 0x01, 0x5c, 0x79, 0xb1, 0x50, 0x29, 0x97, + 0x40, 0x71, 0x49, 0x62, 0x76, 0x2a, 0xb2, 0x85, 0x4c, 0xa4, 0x5a, 0x28, 0x0f, 0xb5, 0x50, 0x1c, + 0x62, 0x21, 0xba, 0x81, 0x4a, 0x41, 0xfc, 0x60, 0x21, 0x24, 0x6b, 0x83, 0xb9, 0x78, 0x93, 0xf3, + 0x73, 0x73, 0x4b, 0xf3, 0x32, 0x4b, 0x2a, 0xe3, 0x4b, 0x12, 0x2b, 0x24, 0x98, 0x15, 0x18, 0x35, + 0x38, 0x9d, 0xf4, 0x40, 0x06, 0xdd, 0xba, 0x27, 0xaf, 0x96, 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, + 0x97, 0x9c, 0x9f, 0xab, 0x9f, 0x9c, 0x5f, 0x9c, 0x9b, 0x5f, 0x0c, 0xa5, 0x74, 0x8b, 0x53, 0xb2, + 0xf5, 0x4b, 0x2a, 0x0b, 0x52, 0x8b, 0xf5, 0x5c, 0x52, 0x93, 0x83, 0x78, 0xe0, 0x86, 0x84, 0x24, + 0x56, 0x08, 0x19, 0x71, 0x89, 0x96, 0x67, 0x96, 0x64, 0xa4, 0x14, 0x25, 0x96, 0xc7, 0x27, 0xa6, + 0xa4, 0x14, 0xc5, 0xa7, 0xe6, 0x25, 0x26, 0xe5, 0xa4, 0xa6, 0x48, 0xb0, 0x28, 0x30, 0x6a, 0x70, + 0x04, 0x09, 0xc3, 0x24, 0x1d, 0x53, 0x52, 0x8a, 0x5c, 0x21, 0x52, 0x56, 0x2c, 0x33, 0x16, 0xc8, + 0x33, 0x38, 0x79, 0x9c, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, + 0x13, 0x1e, 0xcb, 0x31, 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3, 0xb1, 0x1c, 0x43, 0x94, 0x1e, 0x92, + 0x4b, 0x40, 0x61, 0xa0, 0x0b, 0x0d, 0x10, 0x30, 0x47, 0xbf, 0x02, 0x29, 0x4a, 0xc1, 0xae, 0x4a, + 0x62, 0x03, 0xc7, 0xa7, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x9e, 0x58, 0x46, 0x29, 0x40, 0x02, + 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -120,6 +138,26 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.WithdrawAddrEnabled { + i-- + if m.WithdrawAddrEnabled { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x20 + } + { + size := m.CommunityTax.Size() + i -= size + if _, err := m.CommunityTax.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a if len(m.StakeIncentives) > 0 { for iNdEx := len(m.StakeIncentives) - 1; iNdEx >= 0; iNdEx-- { { @@ -180,6 +218,11 @@ func (m *Params) Size() (n int) { n += 1 + l + sovParams(uint64(l)) } } + l = m.CommunityTax.Size() + n += 1 + l + sovParams(uint64(l)) + if m.WithdrawAddrEnabled { + n += 2 + } return n } @@ -286,6 +329,60 @@ func (m *Params) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CommunityTax", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.CommunityTax.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field WithdrawAddrEnabled", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.WithdrawAddrEnabled = bool(v != 0) default: iNdEx = preIndex skippy, err := skipParams(dAtA[iNdEx:]) diff --git a/x/incentive/types/query.go b/x/incentive/types/query.go new file mode 100644 index 000000000..38f6c0a35 --- /dev/null +++ b/x/incentive/types/query.go @@ -0,0 +1,39 @@ +package types + +import ( + "fmt" + "strings" + + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// QueryDelegatorTotalRewardsResponse defines the properties of +// QueryDelegatorTotalRewards query's response. +type QueryDelegatorTotalRewardsResponse struct { + Rewards []DelegationDelegatorReward `json:"rewards" yaml:"rewards"` + Total sdk.DecCoins `json:"total" yaml:"total"` +} + +// NewQueryDelegatorTotalRewardsResponse constructs a QueryDelegatorTotalRewardsResponse +func NewQueryDelegatorTotalRewardsResponse(rewards []DelegationDelegatorReward, total sdk.DecCoins) QueryDelegatorTotalRewardsResponse { + return QueryDelegatorTotalRewardsResponse{Rewards: rewards, Total: total} +} + +func (res QueryDelegatorTotalRewardsResponse) String() string { + out := "Delegator Total Rewards:\n" + out += " Rewards:" + for _, reward := range res.Rewards { + out += fmt.Sprintf(` + ValidatorAddress: %s + Reward: %s`, reward.ValidatorAddress, reward.Reward) + } + out += fmt.Sprintf("\n Total: %s\n", res.Total) + return strings.TrimSpace(out) +} + +// NewDelegationDelegatorReward constructs a DelegationDelegatorReward. +// +//nolint:interfacer +func NewDelegationDelegatorReward(valAddr sdk.ValAddress, reward sdk.DecCoins) DelegationDelegatorReward { + return DelegationDelegatorReward{ValidatorAddress: valAddr.String(), Reward: reward} +} diff --git a/x/incentive/types/query.pb.go b/x/incentive/types/query.pb.go index 389e04171..1f966ea9b 100644 --- a/x/incentive/types/query.pb.go +++ b/x/incentive/types/query.pb.go @@ -6,7 +6,9 @@ package types import ( context "context" fmt "fmt" - _ "github.com/cosmos/cosmos-sdk/types/query" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + types "github.com/cosmos/cosmos-sdk/types" + query "github.com/cosmos/cosmos-sdk/types/query" _ "github.com/gogo/protobuf/gogoproto" grpc1 "github.com/gogo/protobuf/grpc" proto "github.com/gogo/protobuf/proto" @@ -113,213 +115,3368 @@ func (m *QueryParamsResponse) GetParams() Params { return Params{} } -func init() { - proto.RegisterType((*QueryParamsRequest)(nil), "elysnetwork.elys.incentive.QueryParamsRequest") - proto.RegisterType((*QueryParamsResponse)(nil), "elysnetwork.elys.incentive.QueryParamsResponse") +type QueryValidatorOutstandingRewardsRequest struct { + ValidatorAddress string `protobuf:"bytes,1,opt,name=validator_address,json=validatorAddress,proto3" json:"validator_address,omitempty"` } -func init() { proto.RegisterFile("elys/incentive/query.proto", fileDescriptor_29b04b3fcad26af2) } - -var fileDescriptor_29b04b3fcad26af2 = []byte{ - // 307 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x90, 0xcf, 0x4a, 0x03, 0x31, - 0x10, 0x87, 0x37, 0xa2, 0x3d, 0xc4, 0x5b, 0xec, 0x41, 0x56, 0x89, 0xb2, 0x22, 0x88, 0x62, 0x42, - 0xeb, 0x0b, 0x48, 0x4f, 0x1e, 0xb5, 0x17, 0xc1, 0x5b, 0xb6, 0x84, 0x18, 0x6c, 0x33, 0xe9, 0x26, - 0xad, 0xf6, 0xea, 0x13, 0x08, 0x82, 0x67, 0x1f, 0xa7, 0xc7, 0x82, 0x17, 0x4f, 0x22, 0x5d, 0x1f, - 0x44, 0x36, 0x1b, 0xc4, 0x3f, 0x55, 0xbc, 0x0d, 0x33, 0xdf, 0xf7, 0xcb, 0x64, 0x70, 0x2a, 0xfb, - 0x13, 0xc7, 0xb5, 0xe9, 0x49, 0xe3, 0xf5, 0x58, 0xf2, 0xe1, 0x48, 0x16, 0x13, 0x66, 0x0b, 0xf0, - 0x40, 0xc2, 0xcc, 0x48, 0x7f, 0x0d, 0xc5, 0x15, 0xab, 0x6a, 0xf6, 0xc1, 0xa5, 0x4d, 0x05, 0x0a, - 0x02, 0xc6, 0xab, 0xaa, 0x36, 0xd2, 0x4d, 0x05, 0xa0, 0xfa, 0x92, 0x0b, 0xab, 0xb9, 0x30, 0x06, - 0xbc, 0xf0, 0x1a, 0x8c, 0x8b, 0xd3, 0xfd, 0x1e, 0xb8, 0x01, 0x38, 0x9e, 0x0b, 0x17, 0x1f, 0xe2, - 0xe3, 0x56, 0x2e, 0xbd, 0x68, 0x71, 0x2b, 0x94, 0x36, 0x01, 0x8e, 0xec, 0xc6, 0xb7, 0xbd, 0xac, - 0x28, 0xc4, 0x20, 0x06, 0x65, 0x4d, 0x4c, 0xce, 0x2a, 0xfd, 0x34, 0x34, 0xbb, 0x72, 0x38, 0x92, - 0xce, 0x67, 0xe7, 0x78, 0xed, 0x4b, 0xd7, 0x59, 0x30, 0x4e, 0x92, 0x63, 0xdc, 0xa8, 0xe5, 0x75, - 0xb4, 0x8d, 0xf6, 0x56, 0xdb, 0x19, 0xfb, 0xfd, 0x5b, 0xac, 0x76, 0x3b, 0xcb, 0xd3, 0x97, 0xad, - 0xa4, 0x1b, 0xbd, 0xf6, 0x23, 0xc2, 0x2b, 0x21, 0x99, 0x3c, 0x20, 0xdc, 0xa8, 0x11, 0xc2, 0xfe, - 0x8a, 0xf9, 0xb9, 0x5d, 0xca, 0xff, 0xcd, 0xd7, 0x7b, 0x67, 0x07, 0xb7, 0x4f, 0x6f, 0xf7, 0x4b, - 0xbb, 0x64, 0x87, 0x57, 0xf0, 0x61, 0x34, 0xf9, 0xc2, 0xbb, 0x74, 0x4e, 0xa6, 0x73, 0x8a, 0x66, - 0x73, 0x8a, 0x5e, 0xe7, 0x14, 0xdd, 0x95, 0x34, 0x99, 0x95, 0x34, 0x79, 0x2e, 0x69, 0x72, 0xc1, - 0x94, 0xf6, 0x97, 0xa3, 0x9c, 0xf5, 0x60, 0xb0, 0x20, 0xe8, 0xe6, 0x53, 0x94, 0x9f, 0x58, 0xe9, - 0xf2, 0x46, 0x38, 0xf1, 0xd1, 0x7b, 0x00, 0x00, 0x00, 0xff, 0xff, 0xf7, 0x8f, 0x31, 0x35, 0x19, - 0x02, 0x00, 0x00, +func (m *QueryValidatorOutstandingRewardsRequest) Reset() { + *m = QueryValidatorOutstandingRewardsRequest{} +} +func (m *QueryValidatorOutstandingRewardsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryValidatorOutstandingRewardsRequest) ProtoMessage() {} +func (*QueryValidatorOutstandingRewardsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_29b04b3fcad26af2, []int{2} +} +func (m *QueryValidatorOutstandingRewardsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryValidatorOutstandingRewardsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryValidatorOutstandingRewardsRequest.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 *QueryValidatorOutstandingRewardsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryValidatorOutstandingRewardsRequest.Merge(m, src) +} +func (m *QueryValidatorOutstandingRewardsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryValidatorOutstandingRewardsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryValidatorOutstandingRewardsRequest.DiscardUnknown(m) } -// 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 +var xxx_messageInfo_QueryValidatorOutstandingRewardsRequest proto.InternalMessageInfo -// QueryClient is the client API for Query service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type QueryClient interface { - // Parameters queries the parameters of the module. - Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) +func (m *QueryValidatorOutstandingRewardsRequest) GetValidatorAddress() string { + if m != nil { + return m.ValidatorAddress + } + return "" } -type queryClient struct { - cc grpc1.ClientConn +type QueryValidatorOutstandingRewardsResponse struct { + Rewards ValidatorOutstandingRewards `protobuf:"bytes,1,opt,name=rewards,proto3" json:"rewards"` } -func NewQueryClient(cc grpc1.ClientConn) QueryClient { - return &queryClient{cc} +func (m *QueryValidatorOutstandingRewardsResponse) Reset() { + *m = QueryValidatorOutstandingRewardsResponse{} +} +func (m *QueryValidatorOutstandingRewardsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryValidatorOutstandingRewardsResponse) ProtoMessage() {} +func (*QueryValidatorOutstandingRewardsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_29b04b3fcad26af2, []int{3} +} +func (m *QueryValidatorOutstandingRewardsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryValidatorOutstandingRewardsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryValidatorOutstandingRewardsResponse.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 *QueryValidatorOutstandingRewardsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryValidatorOutstandingRewardsResponse.Merge(m, src) +} +func (m *QueryValidatorOutstandingRewardsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryValidatorOutstandingRewardsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryValidatorOutstandingRewardsResponse.DiscardUnknown(m) } -func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) { - out := new(QueryParamsResponse) - err := c.cc.Invoke(ctx, "/elysnetwork.elys.incentive.Query/Params", in, out, opts...) - if err != nil { - return nil, err +var xxx_messageInfo_QueryValidatorOutstandingRewardsResponse proto.InternalMessageInfo + +func (m *QueryValidatorOutstandingRewardsResponse) GetRewards() ValidatorOutstandingRewards { + if m != nil { + return m.Rewards } - return out, nil + return ValidatorOutstandingRewards{} } -// QueryServer is the server API for Query service. -type QueryServer interface { - // Parameters queries the parameters of the module. - Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) +type QueryValidatorCommissionRequest struct { + ValidatorAddress string `protobuf:"bytes,1,opt,name=validator_address,json=validatorAddress,proto3" json:"validator_address,omitempty"` } -// UnimplementedQueryServer can be embedded to have forward compatible implementations. -type UnimplementedQueryServer struct { +func (m *QueryValidatorCommissionRequest) Reset() { *m = QueryValidatorCommissionRequest{} } +func (m *QueryValidatorCommissionRequest) String() string { return proto.CompactTextString(m) } +func (*QueryValidatorCommissionRequest) ProtoMessage() {} +func (*QueryValidatorCommissionRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_29b04b3fcad26af2, []int{4} +} +func (m *QueryValidatorCommissionRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryValidatorCommissionRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryValidatorCommissionRequest.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 *QueryValidatorCommissionRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryValidatorCommissionRequest.Merge(m, src) +} +func (m *QueryValidatorCommissionRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryValidatorCommissionRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryValidatorCommissionRequest.DiscardUnknown(m) } -func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") +var xxx_messageInfo_QueryValidatorCommissionRequest proto.InternalMessageInfo + +func (m *QueryValidatorCommissionRequest) GetValidatorAddress() string { + if m != nil { + return m.ValidatorAddress + } + return "" } -func RegisterQueryServer(s grpc1.Server, srv QueryServer) { - s.RegisterService(&_Query_serviceDesc, srv) +type QueryValidatorCommissionResponse struct { + // commission defines the commision the validator received. + Commission ValidatorAccumulatedCommission `protobuf:"bytes,1,opt,name=commission,proto3" json:"commission"` } -func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryParamsRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).Params(ctx, in) +func (m *QueryValidatorCommissionResponse) Reset() { *m = QueryValidatorCommissionResponse{} } +func (m *QueryValidatorCommissionResponse) String() string { return proto.CompactTextString(m) } +func (*QueryValidatorCommissionResponse) ProtoMessage() {} +func (*QueryValidatorCommissionResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_29b04b3fcad26af2, []int{5} +} +func (m *QueryValidatorCommissionResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryValidatorCommissionResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryValidatorCommissionResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/elysnetwork.elys.incentive.Query/Params", +} +func (m *QueryValidatorCommissionResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryValidatorCommissionResponse.Merge(m, src) +} +func (m *QueryValidatorCommissionResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryValidatorCommissionResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryValidatorCommissionResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryValidatorCommissionResponse proto.InternalMessageInfo + +func (m *QueryValidatorCommissionResponse) GetCommission() ValidatorAccumulatedCommission { + if m != nil { + return m.Commission } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest)) + return ValidatorAccumulatedCommission{} +} + +type QueryValidatorSlashesRequest struct { + // validator_address defines the validator address to query for. + ValidatorAddress string `protobuf:"bytes,1,opt,name=validator_address,json=validatorAddress,proto3" json:"validator_address,omitempty"` + // starting_height defines the optional starting height to query the slashes. + StartingHeight uint64 `protobuf:"varint,2,opt,name=starting_height,json=startingHeight,proto3" json:"starting_height,omitempty"` + // starting_height defines the optional ending height to query the slashes. + EndingHeight uint64 `protobuf:"varint,3,opt,name=ending_height,json=endingHeight,proto3" json:"ending_height,omitempty"` + // pagination defines an optional pagination for the request. + Pagination *query.PageRequest `protobuf:"bytes,4,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryValidatorSlashesRequest) Reset() { *m = QueryValidatorSlashesRequest{} } +func (m *QueryValidatorSlashesRequest) String() string { return proto.CompactTextString(m) } +func (*QueryValidatorSlashesRequest) ProtoMessage() {} +func (*QueryValidatorSlashesRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_29b04b3fcad26af2, []int{6} +} +func (m *QueryValidatorSlashesRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryValidatorSlashesRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryValidatorSlashesRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil } - return interceptor(ctx, in, info, handler) +} +func (m *QueryValidatorSlashesRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryValidatorSlashesRequest.Merge(m, src) +} +func (m *QueryValidatorSlashesRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryValidatorSlashesRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryValidatorSlashesRequest.DiscardUnknown(m) } -var _Query_serviceDesc = grpc.ServiceDesc{ - ServiceName: "elysnetwork.elys.incentive.Query", - HandlerType: (*QueryServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Params", - Handler: _Query_Params_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "elys/incentive/query.proto", +var xxx_messageInfo_QueryValidatorSlashesRequest proto.InternalMessageInfo + +type QueryValidatorSlashesResponse struct { + // slashes defines the slashes the validator received. + Slashes []ValidatorSlashEvent `protobuf:"bytes,1,rep,name=slashes,proto3" json:"slashes"` + // pagination defines the pagination in the response. + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` } -func (m *QueryParamsRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err +func (m *QueryValidatorSlashesResponse) Reset() { *m = QueryValidatorSlashesResponse{} } +func (m *QueryValidatorSlashesResponse) String() string { return proto.CompactTextString(m) } +func (*QueryValidatorSlashesResponse) ProtoMessage() {} +func (*QueryValidatorSlashesResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_29b04b3fcad26af2, []int{7} +} +func (m *QueryValidatorSlashesResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryValidatorSlashesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryValidatorSlashesResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil } - return dAtA[:n], nil +} +func (m *QueryValidatorSlashesResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryValidatorSlashesResponse.Merge(m, src) +} +func (m *QueryValidatorSlashesResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryValidatorSlashesResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryValidatorSlashesResponse.DiscardUnknown(m) } -func (m *QueryParamsRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +var xxx_messageInfo_QueryValidatorSlashesResponse proto.InternalMessageInfo + +func (m *QueryValidatorSlashesResponse) GetSlashes() []ValidatorSlashEvent { + if m != nil { + return m.Slashes + } + return nil } -func (m *QueryParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil +func (m *QueryValidatorSlashesResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination + } + return nil } -func (m *QueryParamsResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err +type QueryDelegationRewardsRequest struct { + DelegatorAddress string `protobuf:"bytes,1,opt,name=delegator_address,json=delegatorAddress,proto3" json:"delegator_address,omitempty"` + ValidatorAddress string `protobuf:"bytes,2,opt,name=validator_address,json=validatorAddress,proto3" json:"validator_address,omitempty"` +} + +func (m *QueryDelegationRewardsRequest) Reset() { *m = QueryDelegationRewardsRequest{} } +func (m *QueryDelegationRewardsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryDelegationRewardsRequest) ProtoMessage() {} +func (*QueryDelegationRewardsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_29b04b3fcad26af2, []int{8} +} +func (m *QueryDelegationRewardsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryDelegationRewardsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryDelegationRewardsRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil } - return dAtA[:n], nil +} +func (m *QueryDelegationRewardsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryDelegationRewardsRequest.Merge(m, src) +} +func (m *QueryDelegationRewardsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryDelegationRewardsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryDelegationRewardsRequest.DiscardUnknown(m) } -func (m *QueryParamsResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +var xxx_messageInfo_QueryDelegationRewardsRequest proto.InternalMessageInfo + +type QueryDelegationRewardsResponse struct { + // rewards defines the rewards accrued by a delegation. + Rewards github_com_cosmos_cosmos_sdk_types.DecCoins `protobuf:"bytes,1,rep,name=rewards,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.DecCoins" json:"rewards"` } -func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) +func (m *QueryDelegationRewardsResponse) Reset() { *m = QueryDelegationRewardsResponse{} } +func (m *QueryDelegationRewardsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryDelegationRewardsResponse) ProtoMessage() {} +func (*QueryDelegationRewardsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_29b04b3fcad26af2, []int{9} +} +func (m *QueryDelegationRewardsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryDelegationRewardsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryDelegationRewardsResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) if err != nil { - return 0, err + return nil, err } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) + return b[:n], nil } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil } +func (m *QueryDelegationRewardsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryDelegationRewardsResponse.Merge(m, src) +} +func (m *QueryDelegationRewardsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryDelegationRewardsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryDelegationRewardsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryDelegationRewardsResponse proto.InternalMessageInfo + +func (m *QueryDelegationRewardsResponse) GetRewards() github_com_cosmos_cosmos_sdk_types.DecCoins { + if m != nil { + return m.Rewards + } + return nil +} + +type QueryDelegationTotalRewardsRequest struct { + DelegatorAddress string `protobuf:"bytes,1,opt,name=delegator_address,json=delegatorAddress,proto3" json:"delegator_address,omitempty"` +} + +func (m *QueryDelegationTotalRewardsRequest) Reset() { *m = QueryDelegationTotalRewardsRequest{} } +func (m *QueryDelegationTotalRewardsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryDelegationTotalRewardsRequest) ProtoMessage() {} +func (*QueryDelegationTotalRewardsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_29b04b3fcad26af2, []int{10} +} +func (m *QueryDelegationTotalRewardsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryDelegationTotalRewardsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryDelegationTotalRewardsRequest.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 *QueryDelegationTotalRewardsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryDelegationTotalRewardsRequest.Merge(m, src) +} +func (m *QueryDelegationTotalRewardsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryDelegationTotalRewardsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryDelegationTotalRewardsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryDelegationTotalRewardsRequest proto.InternalMessageInfo + +type QueryDelegationTotalRewardsResponse struct { + // rewards defines all the rewards accrued by a delegator. + Rewards []DelegationDelegatorReward `protobuf:"bytes,1,rep,name=rewards,proto3" json:"rewards"` + // total defines the sum of all the rewards. + Total github_com_cosmos_cosmos_sdk_types.DecCoins `protobuf:"bytes,2,rep,name=total,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.DecCoins" json:"total"` +} + +func (m *QueryDelegationTotalRewardsResponse) Reset() { *m = QueryDelegationTotalRewardsResponse{} } +func (m *QueryDelegationTotalRewardsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryDelegationTotalRewardsResponse) ProtoMessage() {} +func (*QueryDelegationTotalRewardsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_29b04b3fcad26af2, []int{11} +} +func (m *QueryDelegationTotalRewardsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryDelegationTotalRewardsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryDelegationTotalRewardsResponse.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 *QueryDelegationTotalRewardsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryDelegationTotalRewardsResponse.Merge(m, src) +} +func (m *QueryDelegationTotalRewardsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryDelegationTotalRewardsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryDelegationTotalRewardsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryDelegationTotalRewardsResponse proto.InternalMessageInfo + +func (m *QueryDelegationTotalRewardsResponse) GetRewards() []DelegationDelegatorReward { + if m != nil { + return m.Rewards + } + return nil +} + +func (m *QueryDelegationTotalRewardsResponse) GetTotal() github_com_cosmos_cosmos_sdk_types.DecCoins { + if m != nil { + return m.Total + } + return nil +} + +type QueryDelegatorValidatorsRequest struct { + DelegatorAddress string `protobuf:"bytes,1,opt,name=delegator_address,json=delegatorAddress,proto3" json:"delegator_address,omitempty"` +} + +func (m *QueryDelegatorValidatorsRequest) Reset() { *m = QueryDelegatorValidatorsRequest{} } +func (m *QueryDelegatorValidatorsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryDelegatorValidatorsRequest) ProtoMessage() {} +func (*QueryDelegatorValidatorsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_29b04b3fcad26af2, []int{12} +} +func (m *QueryDelegatorValidatorsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryDelegatorValidatorsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryDelegatorValidatorsRequest.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 *QueryDelegatorValidatorsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryDelegatorValidatorsRequest.Merge(m, src) +} +func (m *QueryDelegatorValidatorsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryDelegatorValidatorsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryDelegatorValidatorsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryDelegatorValidatorsRequest proto.InternalMessageInfo + +type QueryDelegatorValidatorsResponse struct { + // validators defines the validators a delegator is delegating for. + Validators []string `protobuf:"bytes,1,rep,name=validators,proto3" json:"validators,omitempty"` +} + +func (m *QueryDelegatorValidatorsResponse) Reset() { *m = QueryDelegatorValidatorsResponse{} } +func (m *QueryDelegatorValidatorsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryDelegatorValidatorsResponse) ProtoMessage() {} +func (*QueryDelegatorValidatorsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_29b04b3fcad26af2, []int{13} +} +func (m *QueryDelegatorValidatorsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryDelegatorValidatorsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryDelegatorValidatorsResponse.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 *QueryDelegatorValidatorsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryDelegatorValidatorsResponse.Merge(m, src) +} +func (m *QueryDelegatorValidatorsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryDelegatorValidatorsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryDelegatorValidatorsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryDelegatorValidatorsResponse proto.InternalMessageInfo + +type QueryCommunityPoolRequest struct { +} + +func (m *QueryCommunityPoolRequest) Reset() { *m = QueryCommunityPoolRequest{} } +func (m *QueryCommunityPoolRequest) String() string { return proto.CompactTextString(m) } +func (*QueryCommunityPoolRequest) ProtoMessage() {} +func (*QueryCommunityPoolRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_29b04b3fcad26af2, []int{14} +} +func (m *QueryCommunityPoolRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryCommunityPoolRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryCommunityPoolRequest.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 *QueryCommunityPoolRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryCommunityPoolRequest.Merge(m, src) +} +func (m *QueryCommunityPoolRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryCommunityPoolRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryCommunityPoolRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryCommunityPoolRequest proto.InternalMessageInfo + +type QueryCommunityPoolResponse struct { + // pool defines community pool's coins. + Pool github_com_cosmos_cosmos_sdk_types.DecCoins `protobuf:"bytes,1,rep,name=pool,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.DecCoins" json:"pool"` +} + +func (m *QueryCommunityPoolResponse) Reset() { *m = QueryCommunityPoolResponse{} } +func (m *QueryCommunityPoolResponse) String() string { return proto.CompactTextString(m) } +func (*QueryCommunityPoolResponse) ProtoMessage() {} +func (*QueryCommunityPoolResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_29b04b3fcad26af2, []int{15} +} +func (m *QueryCommunityPoolResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryCommunityPoolResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryCommunityPoolResponse.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 *QueryCommunityPoolResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryCommunityPoolResponse.Merge(m, src) +} +func (m *QueryCommunityPoolResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryCommunityPoolResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryCommunityPoolResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryCommunityPoolResponse proto.InternalMessageInfo + +func (m *QueryCommunityPoolResponse) GetPool() github_com_cosmos_cosmos_sdk_types.DecCoins { + if m != nil { + return m.Pool + } + return nil +} + +type QueryDelegatorWithdrawAddressRequest struct { + DelegatorAddress string `protobuf:"bytes,1,opt,name=delegator_address,json=delegatorAddress,proto3" json:"delegator_address,omitempty"` +} + +func (m *QueryDelegatorWithdrawAddressRequest) Reset() { *m = QueryDelegatorWithdrawAddressRequest{} } +func (m *QueryDelegatorWithdrawAddressRequest) String() string { return proto.CompactTextString(m) } +func (*QueryDelegatorWithdrawAddressRequest) ProtoMessage() {} +func (*QueryDelegatorWithdrawAddressRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_29b04b3fcad26af2, []int{16} +} +func (m *QueryDelegatorWithdrawAddressRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryDelegatorWithdrawAddressRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryDelegatorWithdrawAddressRequest.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 *QueryDelegatorWithdrawAddressRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryDelegatorWithdrawAddressRequest.Merge(m, src) +} +func (m *QueryDelegatorWithdrawAddressRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryDelegatorWithdrawAddressRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryDelegatorWithdrawAddressRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryDelegatorWithdrawAddressRequest proto.InternalMessageInfo + +type QueryDelegatorWithdrawAddressResponse struct { + // withdraw_address defines the delegator address to query for. + WithdrawAddress string `protobuf:"bytes,1,opt,name=withdraw_address,json=withdrawAddress,proto3" json:"withdraw_address,omitempty"` +} + +func (m *QueryDelegatorWithdrawAddressResponse) Reset() { *m = QueryDelegatorWithdrawAddressResponse{} } +func (m *QueryDelegatorWithdrawAddressResponse) String() string { return proto.CompactTextString(m) } +func (*QueryDelegatorWithdrawAddressResponse) ProtoMessage() {} +func (*QueryDelegatorWithdrawAddressResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_29b04b3fcad26af2, []int{17} +} +func (m *QueryDelegatorWithdrawAddressResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryDelegatorWithdrawAddressResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryDelegatorWithdrawAddressResponse.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 *QueryDelegatorWithdrawAddressResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryDelegatorWithdrawAddressResponse.Merge(m, src) +} +func (m *QueryDelegatorWithdrawAddressResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryDelegatorWithdrawAddressResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryDelegatorWithdrawAddressResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryDelegatorWithdrawAddressResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*QueryParamsRequest)(nil), "elysnetwork.elys.incentive.QueryParamsRequest") + proto.RegisterType((*QueryParamsResponse)(nil), "elysnetwork.elys.incentive.QueryParamsResponse") + proto.RegisterType((*QueryValidatorOutstandingRewardsRequest)(nil), "elysnetwork.elys.incentive.QueryValidatorOutstandingRewardsRequest") + proto.RegisterType((*QueryValidatorOutstandingRewardsResponse)(nil), "elysnetwork.elys.incentive.QueryValidatorOutstandingRewardsResponse") + proto.RegisterType((*QueryValidatorCommissionRequest)(nil), "elysnetwork.elys.incentive.QueryValidatorCommissionRequest") + proto.RegisterType((*QueryValidatorCommissionResponse)(nil), "elysnetwork.elys.incentive.QueryValidatorCommissionResponse") + proto.RegisterType((*QueryValidatorSlashesRequest)(nil), "elysnetwork.elys.incentive.QueryValidatorSlashesRequest") + proto.RegisterType((*QueryValidatorSlashesResponse)(nil), "elysnetwork.elys.incentive.QueryValidatorSlashesResponse") + proto.RegisterType((*QueryDelegationRewardsRequest)(nil), "elysnetwork.elys.incentive.QueryDelegationRewardsRequest") + proto.RegisterType((*QueryDelegationRewardsResponse)(nil), "elysnetwork.elys.incentive.QueryDelegationRewardsResponse") + proto.RegisterType((*QueryDelegationTotalRewardsRequest)(nil), "elysnetwork.elys.incentive.QueryDelegationTotalRewardsRequest") + proto.RegisterType((*QueryDelegationTotalRewardsResponse)(nil), "elysnetwork.elys.incentive.QueryDelegationTotalRewardsResponse") + proto.RegisterType((*QueryDelegatorValidatorsRequest)(nil), "elysnetwork.elys.incentive.QueryDelegatorValidatorsRequest") + proto.RegisterType((*QueryDelegatorValidatorsResponse)(nil), "elysnetwork.elys.incentive.QueryDelegatorValidatorsResponse") + proto.RegisterType((*QueryCommunityPoolRequest)(nil), "elysnetwork.elys.incentive.QueryCommunityPoolRequest") + proto.RegisterType((*QueryCommunityPoolResponse)(nil), "elysnetwork.elys.incentive.QueryCommunityPoolResponse") + proto.RegisterType((*QueryDelegatorWithdrawAddressRequest)(nil), "elysnetwork.elys.incentive.QueryDelegatorWithdrawAddressRequest") + proto.RegisterType((*QueryDelegatorWithdrawAddressResponse)(nil), "elysnetwork.elys.incentive.QueryDelegatorWithdrawAddressResponse") +} + +func init() { proto.RegisterFile("elys/incentive/query.proto", fileDescriptor_29b04b3fcad26af2) } + +var fileDescriptor_29b04b3fcad26af2 = []byte{ + // 1117 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x98, 0xcd, 0x6f, 0x1b, 0xc5, + 0x1b, 0xc7, 0x3d, 0xae, 0x9b, 0xaa, 0x4f, 0x7f, 0xfd, 0x25, 0x9d, 0x56, 0xc8, 0x6c, 0x82, 0x13, + 0x36, 0x94, 0x04, 0xa2, 0xec, 0xaa, 0x89, 0xca, 0x4b, 0x40, 0xd0, 0xbc, 0xb4, 0x44, 0x02, 0x25, + 0xa9, 0x09, 0x35, 0xe5, 0x62, 0xc6, 0xde, 0xd1, 0x7a, 0x15, 0x7b, 0xc7, 0xdd, 0x19, 0xc7, 0x44, + 0x55, 0x85, 0xa0, 0x1c, 0xb8, 0x20, 0x21, 0x21, 0x71, 0xe6, 0xcc, 0x95, 0x13, 0xff, 0x00, 0xea, + 0xb1, 0x12, 0x1c, 0x38, 0x41, 0x95, 0xf0, 0x72, 0xe0, 0xcc, 0x1d, 0xed, 0xec, 0xac, 0x5f, 0xd7, + 0xeb, 0x8d, 0xad, 0x9e, 0xbc, 0x7a, 0x66, 0x9e, 0xef, 0x3c, 0x9f, 0x67, 0xe6, 0x99, 0x67, 0x64, + 0xd0, 0x68, 0xf5, 0x88, 0x9b, 0x8e, 0x5b, 0xa6, 0xae, 0x70, 0x0e, 0xa9, 0x79, 0xaf, 0x41, 0xbd, + 0x23, 0xa3, 0xee, 0x31, 0xc1, 0xb0, 0x1c, 0x73, 0xa9, 0x68, 0x32, 0xef, 0xc0, 0xf0, 0xbf, 0x8d, + 0xd6, 0x3c, 0x6d, 0xba, 0xc7, 0xaf, 0x4e, 0x3c, 0x52, 0xe3, 0x81, 0xa3, 0xf6, 0x7c, 0xcf, 0xa0, + 0xe5, 0x70, 0xe1, 0x39, 0xa5, 0x86, 0x70, 0x98, 0xab, 0xa6, 0x5c, 0xb1, 0x99, 0xcd, 0xe4, 0xa7, + 0xe9, 0x7f, 0x29, 0xeb, 0x8c, 0xcd, 0x98, 0x5d, 0xa5, 0x26, 0xa9, 0x3b, 0x26, 0x71, 0x5d, 0x26, + 0x88, 0xef, 0x12, 0xca, 0xe6, 0xca, 0x8c, 0xd7, 0x18, 0x37, 0x4b, 0x84, 0x53, 0xf3, 0xf0, 0x5a, + 0x89, 0x0a, 0x72, 0xcd, 0x2c, 0x33, 0x27, 0xd4, 0x7c, 0xb9, 0x73, 0x5c, 0x82, 0xb4, 0x66, 0xd5, + 0x89, 0xed, 0xb8, 0xa4, 0xbd, 0xbe, 0x7e, 0x05, 0xf0, 0x6d, 0x7f, 0xc6, 0x9e, 0x8c, 0x3b, 0x4f, + 0xef, 0x35, 0x28, 0x17, 0x7a, 0x01, 0x2e, 0x77, 0x59, 0x79, 0x9d, 0xb9, 0x9c, 0xe2, 0x1b, 0x30, + 0x11, 0xf0, 0x65, 0xd1, 0x1c, 0x5a, 0xbc, 0xb0, 0xa2, 0x1b, 0x83, 0x33, 0x63, 0x04, 0xbe, 0x1b, + 0x99, 0x47, 0xbf, 0xcd, 0xa6, 0xf2, 0xca, 0x4f, 0xbf, 0x03, 0x0b, 0x52, 0xf8, 0x0e, 0xa9, 0x3a, + 0x16, 0x11, 0xcc, 0xdb, 0x6d, 0x08, 0x2e, 0x88, 0x6b, 0x39, 0xae, 0x9d, 0xa7, 0x4d, 0xe2, 0x59, + 0x61, 0x0c, 0x78, 0x09, 0x2e, 0x1d, 0x86, 0xb3, 0x8a, 0xc4, 0xb2, 0x3c, 0xca, 0x83, 0x75, 0xcf, + 0xe7, 0xa7, 0x5a, 0x03, 0xeb, 0x81, 0x5d, 0x7f, 0x88, 0x60, 0x71, 0xb8, 0xb0, 0xc2, 0x28, 0xc0, + 0x39, 0x2f, 0x30, 0x29, 0x8e, 0x57, 0xe3, 0x38, 0x62, 0x14, 0x15, 0x5c, 0xa8, 0xa6, 0xef, 0xc0, + 0x6c, 0x77, 0x10, 0x9b, 0xac, 0x56, 0x73, 0x38, 0x77, 0x98, 0x3b, 0x12, 0xd5, 0x17, 0x08, 0xe6, + 0x06, 0x0b, 0x2a, 0x9a, 0x8f, 0x01, 0xca, 0x2d, 0xab, 0x02, 0x5a, 0x4b, 0x04, 0xb4, 0x5e, 0x2e, + 0x37, 0x6a, 0x8d, 0x2a, 0x11, 0xd4, 0x6a, 0xeb, 0x2a, 0xa6, 0x0e, 0x4d, 0xfd, 0x6f, 0x04, 0x33, + 0xdd, 0x61, 0xbc, 0x5f, 0x25, 0xbc, 0x42, 0x47, 0xda, 0x2a, 0xbc, 0x00, 0x93, 0x5c, 0x10, 0x4f, + 0x38, 0xae, 0x5d, 0xac, 0x50, 0xc7, 0xae, 0x88, 0x6c, 0x7a, 0x0e, 0x2d, 0x66, 0xf2, 0xff, 0x0f, + 0xcd, 0xdb, 0xd2, 0x8a, 0xe7, 0xe1, 0x22, 0x95, 0xd9, 0x0e, 0xa7, 0x9d, 0x91, 0xd3, 0xfe, 0x17, + 0x18, 0xd5, 0xa4, 0x5b, 0x00, 0xed, 0x33, 0x9d, 0xcd, 0x48, 0xfa, 0x17, 0x8d, 0xa0, 0x00, 0x0c, + 0xbf, 0x00, 0x8c, 0xa0, 0x92, 0x55, 0x01, 0x18, 0x7b, 0xc4, 0xa6, 0x2a, 0xec, 0x7c, 0x87, 0xe7, + 0x5a, 0xe6, 0xcb, 0xef, 0x66, 0x53, 0xfa, 0x8f, 0x08, 0x9e, 0x1b, 0x40, 0xaa, 0xb2, 0xbd, 0x0b, + 0xe7, 0x78, 0x60, 0xca, 0xa2, 0xb9, 0x33, 0x8b, 0x17, 0x56, 0xcc, 0x44, 0xa9, 0x96, 0x32, 0x37, + 0x0f, 0xa9, 0x2b, 0xc2, 0x33, 0xa3, 0x54, 0xf0, 0x3b, 0x5d, 0x00, 0x69, 0x09, 0xb0, 0x30, 0x14, + 0x20, 0x88, 0xa6, 0x93, 0x40, 0xff, 0x54, 0x85, 0xbe, 0x45, 0xab, 0xd4, 0x96, 0xa6, 0xfe, 0x82, + 0xb2, 0x82, 0xb1, 0xfe, 0x5d, 0x6a, 0x0d, 0x84, 0xbb, 0x14, 0xb9, 0xa5, 0xe9, 0xe8, 0x2d, 0x55, + 0xc9, 0xfb, 0x0a, 0x41, 0x6e, 0x50, 0x04, 0x2a, 0x7b, 0x07, 0x9d, 0x95, 0xe7, 0x67, 0x6f, 0xa6, + 0x8b, 0x34, 0x64, 0xdc, 0xa2, 0xe5, 0x4d, 0xe6, 0xb8, 0x1b, 0xab, 0x7e, 0xaa, 0xbe, 0xff, 0x7d, + 0x76, 0xc9, 0x76, 0x44, 0xa5, 0x51, 0x32, 0xca, 0xac, 0x66, 0xaa, 0xbb, 0x2d, 0xf8, 0x59, 0xe6, + 0xd6, 0x81, 0x29, 0x8e, 0xea, 0x94, 0x87, 0x3e, 0xbc, 0x5d, 0x8d, 0x05, 0xd0, 0x7b, 0xc2, 0xd9, + 0x67, 0x82, 0x54, 0xc7, 0xc8, 0x8a, 0x02, 0xfd, 0x13, 0xc1, 0x7c, 0xac, 0xb2, 0xa2, 0xfd, 0xa0, + 0x97, 0xf6, 0x7a, 0xdc, 0x59, 0x69, 0x8b, 0x6d, 0x85, 0xcb, 0x06, 0x82, 0x3d, 0xb7, 0x0c, 0xb6, + 0xe1, 0xac, 0xf0, 0x97, 0xcb, 0xa6, 0x9f, 0x56, 0x0a, 0x03, 0x7d, 0x7d, 0x5f, 0x5d, 0x67, 0xad, + 0x78, 0x5a, 0xc7, 0x79, 0x9c, 0xec, 0x6d, 0xab, 0x3b, 0x2d, 0x52, 0x55, 0x65, 0x2e, 0x07, 0xd0, + 0x3a, 0x64, 0x41, 0xf2, 0xce, 0xe7, 0x3b, 0x2c, 0x4a, 0x69, 0x1a, 0x9e, 0x95, 0x4a, 0xfe, 0xe5, + 0xd5, 0x70, 0x1d, 0x71, 0xb4, 0xc7, 0x58, 0x35, 0x6c, 0x61, 0x0f, 0x11, 0x68, 0x51, 0xa3, 0x6a, + 0x05, 0x0a, 0x99, 0x3a, 0x63, 0xd5, 0xa7, 0x77, 0x0c, 0xa5, 0xbc, 0x7e, 0x17, 0x5e, 0xe8, 0x86, + 0x2d, 0x38, 0xa2, 0x62, 0x79, 0xa4, 0xa9, 0x72, 0x32, 0x46, 0x1e, 0x3f, 0x84, 0xab, 0x43, 0xa4, + 0x15, 0xea, 0x4b, 0x30, 0xd5, 0x54, 0x43, 0x3d, 0xd2, 0x93, 0xcd, 0x6e, 0x97, 0x40, 0x79, 0xe5, + 0xa7, 0x49, 0x38, 0x2b, 0xa5, 0xf1, 0xb7, 0x08, 0x26, 0x82, 0x3e, 0x8e, 0x8d, 0xb8, 0xb3, 0xdb, + 0xff, 0x84, 0xd0, 0xcc, 0xc4, 0xf3, 0x83, 0x30, 0xf5, 0xa5, 0xcf, 0x7f, 0xfe, 0xe3, 0x9b, 0xf4, + 0x55, 0x3c, 0x6f, 0xfa, 0x93, 0x97, 0x95, 0xa7, 0x19, 0xf9, 0xbe, 0xc2, 0x9f, 0xa5, 0x61, 0x3a, + 0xa6, 0x31, 0xe3, 0xcd, 0xa1, 0xab, 0x0f, 0x7f, 0x81, 0x68, 0x5b, 0xe3, 0x89, 0x28, 0xae, 0x82, + 0xe4, 0xba, 0x8d, 0x77, 0x63, 0xb9, 0xda, 0x87, 0xdb, 0xbc, 0xdf, 0x77, 0xf1, 0x3e, 0x30, 0x59, + 0x5b, 0xbf, 0x18, 0xde, 0x03, 0x4f, 0x10, 0x5c, 0x8e, 0x78, 0x18, 0xe0, 0x37, 0x92, 0x87, 0xdd, + 0xf7, 0x3e, 0xd1, 0xde, 0x1c, 0xcd, 0x59, 0xb1, 0xee, 0x48, 0xd6, 0x6d, 0x7c, 0x6b, 0x1c, 0xd6, + 0xf6, 0xcb, 0x03, 0xff, 0x82, 0x60, 0xaa, 0xb7, 0x15, 0xe3, 0xd7, 0x92, 0x87, 0xd8, 0xfd, 0x4e, + 0xd1, 0x5e, 0x1f, 0xc1, 0x53, 0x91, 0xbd, 0x2b, 0xc9, 0x6e, 0xe2, 0xcd, 0x71, 0xc8, 0xc2, 0x9e, + 0xff, 0x0f, 0x82, 0x4b, 0x7d, 0x4d, 0x12, 0x0f, 0x8f, 0x6e, 0x50, 0x6b, 0xd7, 0xd6, 0x46, 0x71, + 0x55, 0x64, 0x45, 0x49, 0x76, 0x17, 0x17, 0x62, 0xc9, 0x5a, 0x97, 0x10, 0x37, 0xef, 0xf7, 0xdd, + 0x54, 0x0f, 0x4c, 0x75, 0x26, 0xa3, 0xa8, 0xf1, 0x5f, 0x08, 0x9e, 0x89, 0xee, 0x94, 0xf8, 0xad, + 0x53, 0xc4, 0x1d, 0xd1, 0xbc, 0xb5, 0xb7, 0x47, 0xf6, 0x3f, 0xd5, 0xb6, 0x26, 0x83, 0x97, 0x05, + 0x19, 0xd1, 0xd5, 0x12, 0x14, 0xe4, 0xe0, 0x0e, 0x9b, 0xa0, 0x20, 0x63, 0x1a, 0x69, 0xc2, 0x82, + 0x1c, 0xc2, 0xd7, 0x3e, 0xd5, 0xf8, 0x07, 0x04, 0x17, 0xbb, 0x1a, 0x2a, 0xbe, 0x3e, 0x34, 0xbe, + 0xa8, 0xf6, 0xac, 0xbd, 0x72, 0x5a, 0x37, 0x05, 0xb4, 0x2a, 0x81, 0x96, 0xf1, 0x52, 0x2c, 0x50, + 0x39, 0xf4, 0x2d, 0xfa, 0x5d, 0x18, 0xff, 0x8b, 0x20, 0x3b, 0xa8, 0x4d, 0xe2, 0x1b, 0xc9, 0x13, + 0x1c, 0xdd, 0xbc, 0xb5, 0xf5, 0x31, 0x14, 0x14, 0xd6, 0xbe, 0xc4, 0xda, 0xc1, 0xef, 0x8d, 0xb3, + 0x4f, 0xbd, 0x5d, 0x7e, 0x63, 0xfb, 0xd1, 0x71, 0x0e, 0x3d, 0x3e, 0xce, 0xa1, 0x27, 0xc7, 0x39, + 0xf4, 0xf5, 0x49, 0x2e, 0xf5, 0xf8, 0x24, 0x97, 0xfa, 0xf5, 0x24, 0x97, 0xfa, 0xc8, 0xe8, 0x78, + 0xca, 0xf4, 0xaf, 0xf8, 0x49, 0xc7, 0x9a, 0xf2, 0x59, 0x53, 0x9a, 0x90, 0xff, 0x16, 0xac, 0xfe, + 0x17, 0x00, 0x00, 0xff, 0xff, 0xa9, 0x2a, 0x46, 0xe2, 0x27, 0x11, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// QueryClient is the client API for Query service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type QueryClient interface { + // Parameters queries the parameters of the module. + Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) + // ValidatorOutstandingRewards queries rewards of a validator address. + ValidatorOutstandingRewards(ctx context.Context, in *QueryValidatorOutstandingRewardsRequest, opts ...grpc.CallOption) (*QueryValidatorOutstandingRewardsResponse, error) + // ValidatorCommission queries accumulated commission for a validator. + ValidatorCommission(ctx context.Context, in *QueryValidatorCommissionRequest, opts ...grpc.CallOption) (*QueryValidatorCommissionResponse, error) + // ValidatorSlashes queries slash events of a validator. + ValidatorSlashes(ctx context.Context, in *QueryValidatorSlashesRequest, opts ...grpc.CallOption) (*QueryValidatorSlashesResponse, error) + // DelegationRewards queries the total rewards accrued by a delegation. + DelegationRewards(ctx context.Context, in *QueryDelegationRewardsRequest, opts ...grpc.CallOption) (*QueryDelegationRewardsResponse, error) + // DelegationTotalRewards queries the total rewards accrued by a each + // validator. + DelegationTotalRewards(ctx context.Context, in *QueryDelegationTotalRewardsRequest, opts ...grpc.CallOption) (*QueryDelegationTotalRewardsResponse, error) + // DelegatorValidators queries the validators of a delegator. + DelegatorValidators(ctx context.Context, in *QueryDelegatorValidatorsRequest, opts ...grpc.CallOption) (*QueryDelegatorValidatorsResponse, error) + // Queries a list of CommunityPool items. + CommunityPool(ctx context.Context, in *QueryCommunityPoolRequest, opts ...grpc.CallOption) (*QueryCommunityPoolResponse, error) + // Queries a list of DelegatorWithdrawAddress items. + DelegatorWithdrawAddress(ctx context.Context, in *QueryDelegatorWithdrawAddressRequest, opts ...grpc.CallOption) (*QueryDelegatorWithdrawAddressResponse, error) +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) { + out := new(QueryParamsResponse) + err := c.cc.Invoke(ctx, "/elysnetwork.elys.incentive.Query/Params", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) ValidatorOutstandingRewards(ctx context.Context, in *QueryValidatorOutstandingRewardsRequest, opts ...grpc.CallOption) (*QueryValidatorOutstandingRewardsResponse, error) { + out := new(QueryValidatorOutstandingRewardsResponse) + err := c.cc.Invoke(ctx, "/elysnetwork.elys.incentive.Query/ValidatorOutstandingRewards", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) ValidatorCommission(ctx context.Context, in *QueryValidatorCommissionRequest, opts ...grpc.CallOption) (*QueryValidatorCommissionResponse, error) { + out := new(QueryValidatorCommissionResponse) + err := c.cc.Invoke(ctx, "/elysnetwork.elys.incentive.Query/ValidatorCommission", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) ValidatorSlashes(ctx context.Context, in *QueryValidatorSlashesRequest, opts ...grpc.CallOption) (*QueryValidatorSlashesResponse, error) { + out := new(QueryValidatorSlashesResponse) + err := c.cc.Invoke(ctx, "/elysnetwork.elys.incentive.Query/ValidatorSlashes", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) DelegationRewards(ctx context.Context, in *QueryDelegationRewardsRequest, opts ...grpc.CallOption) (*QueryDelegationRewardsResponse, error) { + out := new(QueryDelegationRewardsResponse) + err := c.cc.Invoke(ctx, "/elysnetwork.elys.incentive.Query/DelegationRewards", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) DelegationTotalRewards(ctx context.Context, in *QueryDelegationTotalRewardsRequest, opts ...grpc.CallOption) (*QueryDelegationTotalRewardsResponse, error) { + out := new(QueryDelegationTotalRewardsResponse) + err := c.cc.Invoke(ctx, "/elysnetwork.elys.incentive.Query/DelegationTotalRewards", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) DelegatorValidators(ctx context.Context, in *QueryDelegatorValidatorsRequest, opts ...grpc.CallOption) (*QueryDelegatorValidatorsResponse, error) { + out := new(QueryDelegatorValidatorsResponse) + err := c.cc.Invoke(ctx, "/elysnetwork.elys.incentive.Query/DelegatorValidators", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) CommunityPool(ctx context.Context, in *QueryCommunityPoolRequest, opts ...grpc.CallOption) (*QueryCommunityPoolResponse, error) { + out := new(QueryCommunityPoolResponse) + err := c.cc.Invoke(ctx, "/elysnetwork.elys.incentive.Query/CommunityPool", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) DelegatorWithdrawAddress(ctx context.Context, in *QueryDelegatorWithdrawAddressRequest, opts ...grpc.CallOption) (*QueryDelegatorWithdrawAddressResponse, error) { + out := new(QueryDelegatorWithdrawAddressResponse) + err := c.cc.Invoke(ctx, "/elysnetwork.elys.incentive.Query/DelegatorWithdrawAddress", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +type QueryServer interface { + // Parameters queries the parameters of the module. + Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) + // ValidatorOutstandingRewards queries rewards of a validator address. + ValidatorOutstandingRewards(context.Context, *QueryValidatorOutstandingRewardsRequest) (*QueryValidatorOutstandingRewardsResponse, error) + // ValidatorCommission queries accumulated commission for a validator. + ValidatorCommission(context.Context, *QueryValidatorCommissionRequest) (*QueryValidatorCommissionResponse, error) + // ValidatorSlashes queries slash events of a validator. + ValidatorSlashes(context.Context, *QueryValidatorSlashesRequest) (*QueryValidatorSlashesResponse, error) + // DelegationRewards queries the total rewards accrued by a delegation. + DelegationRewards(context.Context, *QueryDelegationRewardsRequest) (*QueryDelegationRewardsResponse, error) + // DelegationTotalRewards queries the total rewards accrued by a each + // validator. + DelegationTotalRewards(context.Context, *QueryDelegationTotalRewardsRequest) (*QueryDelegationTotalRewardsResponse, error) + // DelegatorValidators queries the validators of a delegator. + DelegatorValidators(context.Context, *QueryDelegatorValidatorsRequest) (*QueryDelegatorValidatorsResponse, error) + // Queries a list of CommunityPool items. + CommunityPool(context.Context, *QueryCommunityPoolRequest) (*QueryCommunityPoolResponse, error) + // Queries a list of DelegatorWithdrawAddress items. + DelegatorWithdrawAddress(context.Context, *QueryDelegatorWithdrawAddressRequest) (*QueryDelegatorWithdrawAddressResponse, error) +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") +} +func (*UnimplementedQueryServer) ValidatorOutstandingRewards(ctx context.Context, req *QueryValidatorOutstandingRewardsRequest) (*QueryValidatorOutstandingRewardsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ValidatorOutstandingRewards not implemented") +} +func (*UnimplementedQueryServer) ValidatorCommission(ctx context.Context, req *QueryValidatorCommissionRequest) (*QueryValidatorCommissionResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ValidatorCommission not implemented") +} +func (*UnimplementedQueryServer) ValidatorSlashes(ctx context.Context, req *QueryValidatorSlashesRequest) (*QueryValidatorSlashesResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ValidatorSlashes not implemented") +} +func (*UnimplementedQueryServer) DelegationRewards(ctx context.Context, req *QueryDelegationRewardsRequest) (*QueryDelegationRewardsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method DelegationRewards not implemented") +} +func (*UnimplementedQueryServer) DelegationTotalRewards(ctx context.Context, req *QueryDelegationTotalRewardsRequest) (*QueryDelegationTotalRewardsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method DelegationTotalRewards not implemented") +} +func (*UnimplementedQueryServer) DelegatorValidators(ctx context.Context, req *QueryDelegatorValidatorsRequest) (*QueryDelegatorValidatorsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method DelegatorValidators not implemented") +} +func (*UnimplementedQueryServer) CommunityPool(ctx context.Context, req *QueryCommunityPoolRequest) (*QueryCommunityPoolResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CommunityPool not implemented") +} +func (*UnimplementedQueryServer) DelegatorWithdrawAddress(ctx context.Context, req *QueryDelegatorWithdrawAddressRequest) (*QueryDelegatorWithdrawAddressResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method DelegatorWithdrawAddress not implemented") +} + +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) +} + +func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryParamsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Params(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/elysnetwork.elys.incentive.Query/Params", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_ValidatorOutstandingRewards_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryValidatorOutstandingRewardsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).ValidatorOutstandingRewards(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/elysnetwork.elys.incentive.Query/ValidatorOutstandingRewards", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).ValidatorOutstandingRewards(ctx, req.(*QueryValidatorOutstandingRewardsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_ValidatorCommission_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryValidatorCommissionRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).ValidatorCommission(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/elysnetwork.elys.incentive.Query/ValidatorCommission", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).ValidatorCommission(ctx, req.(*QueryValidatorCommissionRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_ValidatorSlashes_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryValidatorSlashesRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).ValidatorSlashes(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/elysnetwork.elys.incentive.Query/ValidatorSlashes", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).ValidatorSlashes(ctx, req.(*QueryValidatorSlashesRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_DelegationRewards_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryDelegationRewardsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).DelegationRewards(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/elysnetwork.elys.incentive.Query/DelegationRewards", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).DelegationRewards(ctx, req.(*QueryDelegationRewardsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_DelegationTotalRewards_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryDelegationTotalRewardsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).DelegationTotalRewards(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/elysnetwork.elys.incentive.Query/DelegationTotalRewards", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).DelegationTotalRewards(ctx, req.(*QueryDelegationTotalRewardsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_DelegatorValidators_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryDelegatorValidatorsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).DelegatorValidators(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/elysnetwork.elys.incentive.Query/DelegatorValidators", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).DelegatorValidators(ctx, req.(*QueryDelegatorValidatorsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_CommunityPool_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryCommunityPoolRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).CommunityPool(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/elysnetwork.elys.incentive.Query/CommunityPool", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).CommunityPool(ctx, req.(*QueryCommunityPoolRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_DelegatorWithdrawAddress_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryDelegatorWithdrawAddressRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).DelegatorWithdrawAddress(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/elysnetwork.elys.incentive.Query/DelegatorWithdrawAddress", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).DelegatorWithdrawAddress(ctx, req.(*QueryDelegatorWithdrawAddressRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "elysnetwork.elys.incentive.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Params", + Handler: _Query_Params_Handler, + }, + { + MethodName: "ValidatorOutstandingRewards", + Handler: _Query_ValidatorOutstandingRewards_Handler, + }, + { + MethodName: "ValidatorCommission", + Handler: _Query_ValidatorCommission_Handler, + }, + { + MethodName: "ValidatorSlashes", + Handler: _Query_ValidatorSlashes_Handler, + }, + { + MethodName: "DelegationRewards", + Handler: _Query_DelegationRewards_Handler, + }, + { + MethodName: "DelegationTotalRewards", + Handler: _Query_DelegationTotalRewards_Handler, + }, + { + MethodName: "DelegatorValidators", + Handler: _Query_DelegatorValidators_Handler, + }, + { + MethodName: "CommunityPool", + Handler: _Query_CommunityPool_Handler, + }, + { + MethodName: "DelegatorWithdrawAddress", + Handler: _Query_DelegatorWithdrawAddress_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "elys/incentive/query.proto", +} + +func (m *QueryParamsRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryParamsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryParamsResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *QueryValidatorOutstandingRewardsRequest) 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 *QueryValidatorOutstandingRewardsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryValidatorOutstandingRewardsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ValidatorAddress) > 0 { + i -= len(m.ValidatorAddress) + copy(dAtA[i:], m.ValidatorAddress) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ValidatorAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryValidatorOutstandingRewardsResponse) 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 *QueryValidatorOutstandingRewardsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryValidatorOutstandingRewardsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Rewards.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 *QueryValidatorCommissionRequest) 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 *QueryValidatorCommissionRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryValidatorCommissionRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ValidatorAddress) > 0 { + i -= len(m.ValidatorAddress) + copy(dAtA[i:], m.ValidatorAddress) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ValidatorAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryValidatorCommissionResponse) 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 *QueryValidatorCommissionResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryValidatorCommissionResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Commission.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 *QueryValidatorSlashesRequest) 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 *QueryValidatorSlashesRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryValidatorSlashesRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + if m.EndingHeight != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.EndingHeight)) + i-- + dAtA[i] = 0x18 + } + if m.StartingHeight != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.StartingHeight)) + i-- + dAtA[i] = 0x10 + } + if len(m.ValidatorAddress) > 0 { + i -= len(m.ValidatorAddress) + copy(dAtA[i:], m.ValidatorAddress) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ValidatorAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryValidatorSlashesResponse) 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 *QueryValidatorSlashesResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryValidatorSlashesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Slashes) > 0 { + for iNdEx := len(m.Slashes) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Slashes[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 *QueryDelegationRewardsRequest) 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 *QueryDelegationRewardsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryDelegationRewardsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ValidatorAddress) > 0 { + i -= len(m.ValidatorAddress) + copy(dAtA[i:], m.ValidatorAddress) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ValidatorAddress))) + i-- + dAtA[i] = 0x12 + } + if len(m.DelegatorAddress) > 0 { + i -= len(m.DelegatorAddress) + copy(dAtA[i:], m.DelegatorAddress) + i = encodeVarintQuery(dAtA, i, uint64(len(m.DelegatorAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryDelegationRewardsResponse) 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 *QueryDelegationRewardsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryDelegationRewardsResponse) 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, err := m.Rewards[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 *QueryDelegationTotalRewardsRequest) 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 *QueryDelegationTotalRewardsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryDelegationTotalRewardsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.DelegatorAddress) > 0 { + i -= len(m.DelegatorAddress) + copy(dAtA[i:], m.DelegatorAddress) + i = encodeVarintQuery(dAtA, i, uint64(len(m.DelegatorAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryDelegationTotalRewardsResponse) 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 *QueryDelegationTotalRewardsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryDelegationTotalRewardsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Total) > 0 { + for iNdEx := len(m.Total) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Total[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + 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 = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *QueryDelegatorValidatorsRequest) 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 *QueryDelegatorValidatorsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryDelegatorValidatorsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.DelegatorAddress) > 0 { + i -= len(m.DelegatorAddress) + copy(dAtA[i:], m.DelegatorAddress) + i = encodeVarintQuery(dAtA, i, uint64(len(m.DelegatorAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryDelegatorValidatorsResponse) 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 *QueryDelegatorValidatorsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryDelegatorValidatorsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Validators) > 0 { + for iNdEx := len(m.Validators) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Validators[iNdEx]) + copy(dAtA[i:], m.Validators[iNdEx]) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Validators[iNdEx]))) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *QueryCommunityPoolRequest) 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 *QueryCommunityPoolRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryCommunityPoolRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryCommunityPoolResponse) 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 *QueryCommunityPoolResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryCommunityPoolResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Pool) > 0 { + for iNdEx := len(m.Pool) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Pool[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 *QueryDelegatorWithdrawAddressRequest) 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 *QueryDelegatorWithdrawAddressRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryDelegatorWithdrawAddressRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.DelegatorAddress) > 0 { + i -= len(m.DelegatorAddress) + copy(dAtA[i:], m.DelegatorAddress) + i = encodeVarintQuery(dAtA, i, uint64(len(m.DelegatorAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryDelegatorWithdrawAddressResponse) 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 *QueryDelegatorWithdrawAddressResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryDelegatorWithdrawAddressResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.WithdrawAddress) > 0 { + i -= len(m.WithdrawAddress) + copy(dAtA[i:], m.WithdrawAddress) + i = encodeVarintQuery(dAtA, i, uint64(len(m.WithdrawAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { + offset -= sovQuery(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *QueryParamsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryValidatorOutstandingRewardsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ValidatorAddress) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryValidatorOutstandingRewardsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Rewards.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryValidatorCommissionRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ValidatorAddress) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryValidatorCommissionResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Commission.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryValidatorSlashesRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ValidatorAddress) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.StartingHeight != 0 { + n += 1 + sovQuery(uint64(m.StartingHeight)) + } + if m.EndingHeight != 0 { + n += 1 + sovQuery(uint64(m.EndingHeight)) + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryValidatorSlashesResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Slashes) > 0 { + for _, e := range m.Slashes { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryDelegationRewardsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.DelegatorAddress) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.ValidatorAddress) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryDelegationRewardsResponse) 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 *QueryDelegationTotalRewardsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.DelegatorAddress) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryDelegationTotalRewardsResponse) 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)) + } + } + if len(m.Total) > 0 { + for _, e := range m.Total { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + +func (m *QueryDelegatorValidatorsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.DelegatorAddress) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryDelegatorValidatorsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Validators) > 0 { + for _, s := range m.Validators { + l = len(s) + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + +func (m *QueryCommunityPoolRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryCommunityPoolResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Pool) > 0 { + for _, e := range m.Pool { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + +func (m *QueryDelegatorWithdrawAddressRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.DelegatorAddress) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryDelegatorWithdrawAddressResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.WithdrawAddress) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func sovQuery(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QueryParamsRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryParamsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryValidatorOutstandingRewardsRequest) 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: QueryValidatorOutstandingRewardsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryValidatorOutstandingRewardsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ValidatorAddress", 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.ValidatorAddress = 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 *QueryValidatorOutstandingRewardsResponse) 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: QueryValidatorOutstandingRewardsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryValidatorOutstandingRewardsResponse: 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 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.Rewards.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 *QueryValidatorCommissionRequest) 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: QueryValidatorCommissionRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryValidatorCommissionRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ValidatorAddress", 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.ValidatorAddress = 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 *QueryValidatorCommissionResponse) 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: QueryValidatorCommissionResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryValidatorCommissionResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Commission", 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.Commission.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 *QueryValidatorSlashesRequest) 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: QueryValidatorSlashesRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryValidatorSlashesRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ValidatorAddress", 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.ValidatorAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field StartingHeight", wireType) + } + m.StartingHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.StartingHeight |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field EndingHeight", wireType) + } + m.EndingHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.EndingHeight |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryValidatorSlashesResponse) 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: QueryValidatorSlashesResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryValidatorSlashesResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Slashes", 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.Slashes = append(m.Slashes, ValidatorSlashEvent{}) + if err := m.Slashes[len(m.Slashes)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryDelegationRewardsRequest) 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: QueryDelegationRewardsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryDelegationRewardsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DelegatorAddress", 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.DelegatorAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ValidatorAddress", 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.ValidatorAddress = 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 *QueryDelegationRewardsResponse) 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: QueryDelegationRewardsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryDelegationRewardsResponse: 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 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.Rewards = append(m.Rewards, types.DecCoin{}) + 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 *QueryDelegationTotalRewardsRequest) 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: QueryDelegationTotalRewardsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryDelegationTotalRewardsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DelegatorAddress", 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.DelegatorAddress = 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 *QueryDelegationTotalRewardsResponse) 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: QueryDelegationTotalRewardsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryDelegationTotalRewardsResponse: 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 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.Rewards = append(m.Rewards, DelegationDelegatorReward{}) + if err := m.Rewards[len(m.Rewards)-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 Total", 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.Total = append(m.Total, types.DecCoin{}) + if err := m.Total[len(m.Total)-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 *QueryDelegatorValidatorsRequest) 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: QueryDelegatorValidatorsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryDelegatorValidatorsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DelegatorAddress", 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.DelegatorAddress = 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 + } + } -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++ + if iNdEx > l { + return io.ErrUnexpectedEOF } - dAtA[offset] = uint8(v) - return base + return nil } -func (m *QueryParamsRequest) Size() (n int) { - if m == nil { - return 0 +func (m *QueryDelegatorValidatorsResponse) 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: QueryDelegatorValidatorsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryDelegatorValidatorsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Validators", 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.Validators = append(m.Validators, 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 + } } - var l int - _ = l - return n -} -func (m *QueryParamsResponse) Size() (n int) { - if m == nil { - return 0 + if iNdEx > l { + return io.ErrUnexpectedEOF } - var l int - _ = l - l = m.Params.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)))) + return nil } -func (m *QueryParamsRequest) Unmarshal(dAtA []byte) error { +func (m *QueryCommunityPoolRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -342,10 +3499,10 @@ func (m *QueryParamsRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryParamsRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryCommunityPoolRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryCommunityPoolRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { default: @@ -369,7 +3526,7 @@ func (m *QueryParamsRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { +func (m *QueryCommunityPoolResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -392,15 +3549,15 @@ func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryParamsResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryCommunityPoolResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryCommunityPoolResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Pool", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -427,9 +3584,174 @@ func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.Pool = append(m.Pool, types.DecCoin{}) + if err := m.Pool[len(m.Pool)-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 *QueryDelegatorWithdrawAddressRequest) 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: QueryDelegatorWithdrawAddressRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryDelegatorWithdrawAddressRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DelegatorAddress", 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.DelegatorAddress = 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 *QueryDelegatorWithdrawAddressResponse) 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: QueryDelegatorWithdrawAddressResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryDelegatorWithdrawAddressResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field WithdrawAddress", 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.WithdrawAddress = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex diff --git a/x/incentive/types/query.pb.gw.go b/x/incentive/types/query.pb.gw.go index 1d7532fb5..f05e49ed6 100644 --- a/x/incentive/types/query.pb.gw.go +++ b/x/incentive/types/query.pb.gw.go @@ -51,13 +51,518 @@ func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshal } +func request_Query_ValidatorOutstandingRewards_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryValidatorOutstandingRewardsRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["validator_address"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "validator_address") + } + + protoReq.ValidatorAddress, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "validator_address", err) + } + + msg, err := client.ValidatorOutstandingRewards(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_ValidatorOutstandingRewards_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryValidatorOutstandingRewardsRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["validator_address"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "validator_address") + } + + protoReq.ValidatorAddress, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "validator_address", err) + } + + msg, err := server.ValidatorOutstandingRewards(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_ValidatorCommission_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryValidatorCommissionRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["validator_address"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "validator_address") + } + + protoReq.ValidatorAddress, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "validator_address", err) + } + + msg, err := client.ValidatorCommission(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_ValidatorCommission_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryValidatorCommissionRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["validator_address"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "validator_address") + } + + protoReq.ValidatorAddress, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "validator_address", err) + } + + msg, err := server.ValidatorCommission(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_ValidatorSlashes_0 = &utilities.DoubleArray{Encoding: map[string]int{"validator_address": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} +) + +func request_Query_ValidatorSlashes_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryValidatorSlashesRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["validator_address"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "validator_address") + } + + protoReq.ValidatorAddress, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "validator_address", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_ValidatorSlashes_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.ValidatorSlashes(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_ValidatorSlashes_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryValidatorSlashesRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["validator_address"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "validator_address") + } + + protoReq.ValidatorAddress, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "validator_address", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_ValidatorSlashes_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.ValidatorSlashes(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_DelegationRewards_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryDelegationRewardsRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["delegator_address"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "delegator_address") + } + + protoReq.DelegatorAddress, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "delegator_address", err) + } + + val, ok = pathParams["validator_address"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "validator_address") + } + + protoReq.ValidatorAddress, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "validator_address", err) + } + + msg, err := client.DelegationRewards(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_DelegationRewards_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryDelegationRewardsRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["delegator_address"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "delegator_address") + } + + protoReq.DelegatorAddress, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "delegator_address", err) + } + + val, ok = pathParams["validator_address"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "validator_address") + } + + protoReq.ValidatorAddress, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "validator_address", err) + } + + msg, err := server.DelegationRewards(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_DelegationTotalRewards_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryDelegationTotalRewardsRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["delegator_address"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "delegator_address") + } + + protoReq.DelegatorAddress, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "delegator_address", err) + } + + msg, err := client.DelegationTotalRewards(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_DelegationTotalRewards_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryDelegationTotalRewardsRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["delegator_address"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "delegator_address") + } + + protoReq.DelegatorAddress, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "delegator_address", err) + } + + msg, err := server.DelegationTotalRewards(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_DelegatorValidators_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryDelegatorValidatorsRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["delegator_address"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "delegator_address") + } + + protoReq.DelegatorAddress, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "delegator_address", err) + } + + msg, err := client.DelegatorValidators(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_DelegatorValidators_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryDelegatorValidatorsRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["delegator_address"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "delegator_address") + } + + protoReq.DelegatorAddress, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "delegator_address", err) + } + + msg, err := server.DelegatorValidators(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_CommunityPool_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryCommunityPoolRequest + var metadata runtime.ServerMetadata + + msg, err := client.CommunityPool(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_CommunityPool_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryCommunityPoolRequest + var metadata runtime.ServerMetadata + + msg, err := server.CommunityPool(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_DelegatorWithdrawAddress_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryDelegatorWithdrawAddressRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["delegator_address"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "delegator_address") + } + + protoReq.DelegatorAddress, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "delegator_address", err) + } + + msg, err := client.DelegatorWithdrawAddress(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_DelegatorWithdrawAddress_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryDelegatorWithdrawAddressRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["delegator_address"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "delegator_address") + } + + protoReq.DelegatorAddress, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "delegator_address", err) + } + + msg, err := server.DelegatorWithdrawAddress(ctx, &protoReq) + return msg, metadata, err + +} + // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. // Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { - mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_Params_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_ValidatorOutstandingRewards_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_ValidatorOutstandingRewards_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_ValidatorOutstandingRewards_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_ValidatorCommission_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_ValidatorCommission_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_ValidatorCommission_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_ValidatorSlashes_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream @@ -68,7 +573,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Query_Params_0(rctx, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_Query_ValidatorSlashes_0(rctx, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { @@ -76,7 +581,122 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } - forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_ValidatorSlashes_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_DelegationRewards_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_DelegationRewards_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_DelegationRewards_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_DelegationTotalRewards_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_DelegationTotalRewards_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_DelegationTotalRewards_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_DelegatorValidators_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_DelegatorValidators_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_DelegatorValidators_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_CommunityPool_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_CommunityPool_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_CommunityPool_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_DelegatorWithdrawAddress_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_DelegatorWithdrawAddress_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_DelegatorWithdrawAddress_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -141,13 +761,205 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_ValidatorOutstandingRewards_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_ValidatorOutstandingRewards_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_ValidatorOutstandingRewards_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_ValidatorCommission_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_ValidatorCommission_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_ValidatorCommission_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_ValidatorSlashes_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_ValidatorSlashes_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_ValidatorSlashes_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_DelegationRewards_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_DelegationRewards_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_DelegationRewards_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_DelegationTotalRewards_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_DelegationTotalRewards_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_DelegationTotalRewards_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_DelegatorValidators_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_DelegatorValidators_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_DelegatorValidators_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_CommunityPool_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_CommunityPool_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_CommunityPool_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_DelegatorWithdrawAddress_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_DelegatorWithdrawAddress_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_DelegatorWithdrawAddress_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } var ( pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"elys-network", "elys", "incentive", "params"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_ValidatorOutstandingRewards_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5}, []string{"elys-network", "elys", "incentive", "validators", "validator_address", "outstanding_rewards"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_ValidatorCommission_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5}, []string{"elys-network", "elys", "incentive", "validators", "validator_address", "commission"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_ValidatorSlashes_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5}, []string{"elys-network", "elys", "incentive", "validators", "validator_address", "slashes"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_DelegationRewards_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5, 1, 0, 4, 1, 5, 6}, []string{"elys-network", "elys", "incentive", "delegators", "delegator_address", "rewards", "validator_address"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_DelegationTotalRewards_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5}, []string{"elys-network", "elys", "incentive", "delegators", "delegator_address", "rewards"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_DelegatorValidators_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5}, []string{"elys-network", "elys", "incentive", "delegators", "delegator_address", "validators"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_CommunityPool_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"elys-network", "elys", "incentive", "community_pool"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_DelegatorWithdrawAddress_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5}, []string{"elys-network", "elys", "incentive", "delegators", "delegator_address", "withdraw_address"}, "", runtime.AssumeColonVerbOpt(true))) ) var ( forward_Query_Params_0 = runtime.ForwardResponseMessage + + forward_Query_ValidatorOutstandingRewards_0 = runtime.ForwardResponseMessage + + forward_Query_ValidatorCommission_0 = runtime.ForwardResponseMessage + + forward_Query_ValidatorSlashes_0 = runtime.ForwardResponseMessage + + forward_Query_DelegationRewards_0 = runtime.ForwardResponseMessage + + forward_Query_DelegationTotalRewards_0 = runtime.ForwardResponseMessage + + forward_Query_DelegatorValidators_0 = runtime.ForwardResponseMessage + + forward_Query_CommunityPool_0 = runtime.ForwardResponseMessage + + forward_Query_DelegatorWithdrawAddress_0 = runtime.ForwardResponseMessage ) diff --git a/x/incentive/types/tx.pb.go b/x/incentive/types/tx.pb.go index 93695c89b..d62713f3d 100644 --- a/x/incentive/types/tx.pb.go +++ b/x/incentive/types/tx.pb.go @@ -6,10 +6,17 @@ package types import ( context "context" fmt "fmt" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/gogo/protobuf/gogoproto" grpc1 "github.com/gogo/protobuf/grpc" proto "github.com/gogo/protobuf/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. @@ -23,19 +30,324 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package +type MsgSetWithdrawAddress struct { + DelegatorAddress string `protobuf:"bytes,1,opt,name=delegator_address,json=delegatorAddress,proto3" json:"delegator_address,omitempty"` + WithdrawAddress string `protobuf:"bytes,2,opt,name=withdraw_address,json=withdrawAddress,proto3" json:"withdraw_address,omitempty"` +} + +func (m *MsgSetWithdrawAddress) Reset() { *m = MsgSetWithdrawAddress{} } +func (m *MsgSetWithdrawAddress) String() string { return proto.CompactTextString(m) } +func (*MsgSetWithdrawAddress) ProtoMessage() {} +func (*MsgSetWithdrawAddress) Descriptor() ([]byte, []int) { + return fileDescriptor_59dc3bedfb1cce84, []int{0} +} +func (m *MsgSetWithdrawAddress) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSetWithdrawAddress) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSetWithdrawAddress.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 *MsgSetWithdrawAddress) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSetWithdrawAddress.Merge(m, src) +} +func (m *MsgSetWithdrawAddress) XXX_Size() int { + return m.Size() +} +func (m *MsgSetWithdrawAddress) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSetWithdrawAddress.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSetWithdrawAddress proto.InternalMessageInfo + +func (m *MsgSetWithdrawAddress) GetDelegatorAddress() string { + if m != nil { + return m.DelegatorAddress + } + return "" +} + +func (m *MsgSetWithdrawAddress) GetWithdrawAddress() string { + if m != nil { + return m.WithdrawAddress + } + return "" +} + +type MsgSetWithdrawAddressResponse struct { +} + +func (m *MsgSetWithdrawAddressResponse) Reset() { *m = MsgSetWithdrawAddressResponse{} } +func (m *MsgSetWithdrawAddressResponse) String() string { return proto.CompactTextString(m) } +func (*MsgSetWithdrawAddressResponse) ProtoMessage() {} +func (*MsgSetWithdrawAddressResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_59dc3bedfb1cce84, []int{1} +} +func (m *MsgSetWithdrawAddressResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSetWithdrawAddressResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSetWithdrawAddressResponse.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 *MsgSetWithdrawAddressResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSetWithdrawAddressResponse.Merge(m, src) +} +func (m *MsgSetWithdrawAddressResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgSetWithdrawAddressResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSetWithdrawAddressResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSetWithdrawAddressResponse proto.InternalMessageInfo + +type MsgWithdrawValidatorCommission struct { + ValidatorAddress string `protobuf:"bytes,1,opt,name=validator_address,json=validatorAddress,proto3" json:"validator_address,omitempty"` +} + +func (m *MsgWithdrawValidatorCommission) Reset() { *m = MsgWithdrawValidatorCommission{} } +func (m *MsgWithdrawValidatorCommission) String() string { return proto.CompactTextString(m) } +func (*MsgWithdrawValidatorCommission) ProtoMessage() {} +func (*MsgWithdrawValidatorCommission) Descriptor() ([]byte, []int) { + return fileDescriptor_59dc3bedfb1cce84, []int{2} +} +func (m *MsgWithdrawValidatorCommission) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgWithdrawValidatorCommission) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgWithdrawValidatorCommission.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 *MsgWithdrawValidatorCommission) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgWithdrawValidatorCommission.Merge(m, src) +} +func (m *MsgWithdrawValidatorCommission) XXX_Size() int { + return m.Size() +} +func (m *MsgWithdrawValidatorCommission) XXX_DiscardUnknown() { + xxx_messageInfo_MsgWithdrawValidatorCommission.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgWithdrawValidatorCommission proto.InternalMessageInfo + +func (m *MsgWithdrawValidatorCommission) GetValidatorAddress() string { + if m != nil { + return m.ValidatorAddress + } + return "" +} + +type MsgWithdrawValidatorCommissionResponse struct { + // Since: cosmos-sdk 0.46 + Amount github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,1,rep,name=amount,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"amount"` +} + +func (m *MsgWithdrawValidatorCommissionResponse) Reset() { + *m = MsgWithdrawValidatorCommissionResponse{} +} +func (m *MsgWithdrawValidatorCommissionResponse) String() string { return proto.CompactTextString(m) } +func (*MsgWithdrawValidatorCommissionResponse) ProtoMessage() {} +func (*MsgWithdrawValidatorCommissionResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_59dc3bedfb1cce84, []int{3} +} +func (m *MsgWithdrawValidatorCommissionResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgWithdrawValidatorCommissionResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgWithdrawValidatorCommissionResponse.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 *MsgWithdrawValidatorCommissionResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgWithdrawValidatorCommissionResponse.Merge(m, src) +} +func (m *MsgWithdrawValidatorCommissionResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgWithdrawValidatorCommissionResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgWithdrawValidatorCommissionResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgWithdrawValidatorCommissionResponse proto.InternalMessageInfo + +func (m *MsgWithdrawValidatorCommissionResponse) GetAmount() github_com_cosmos_cosmos_sdk_types.Coins { + if m != nil { + return m.Amount + } + return nil +} + +type MsgWithdrawDelegatorReward struct { + DelegatorAddress string `protobuf:"bytes,1,opt,name=delegator_address,json=delegatorAddress,proto3" json:"delegator_address,omitempty"` + ValidatorAddress string `protobuf:"bytes,2,opt,name=validator_address,json=validatorAddress,proto3" json:"validator_address,omitempty"` +} + +func (m *MsgWithdrawDelegatorReward) Reset() { *m = MsgWithdrawDelegatorReward{} } +func (m *MsgWithdrawDelegatorReward) String() string { return proto.CompactTextString(m) } +func (*MsgWithdrawDelegatorReward) ProtoMessage() {} +func (*MsgWithdrawDelegatorReward) Descriptor() ([]byte, []int) { + return fileDescriptor_59dc3bedfb1cce84, []int{4} +} +func (m *MsgWithdrawDelegatorReward) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgWithdrawDelegatorReward) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgWithdrawDelegatorReward.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 *MsgWithdrawDelegatorReward) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgWithdrawDelegatorReward.Merge(m, src) +} +func (m *MsgWithdrawDelegatorReward) XXX_Size() int { + return m.Size() +} +func (m *MsgWithdrawDelegatorReward) XXX_DiscardUnknown() { + xxx_messageInfo_MsgWithdrawDelegatorReward.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgWithdrawDelegatorReward proto.InternalMessageInfo + +func (m *MsgWithdrawDelegatorReward) GetDelegatorAddress() string { + if m != nil { + return m.DelegatorAddress + } + return "" +} + +func (m *MsgWithdrawDelegatorReward) GetValidatorAddress() string { + if m != nil { + return m.ValidatorAddress + } + return "" +} + +type MsgWithdrawDelegatorRewardResponse struct { + // Since: cosmos-sdk 0.46 + Amount github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,1,rep,name=amount,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"amount"` +} + +func (m *MsgWithdrawDelegatorRewardResponse) Reset() { *m = MsgWithdrawDelegatorRewardResponse{} } +func (m *MsgWithdrawDelegatorRewardResponse) String() string { return proto.CompactTextString(m) } +func (*MsgWithdrawDelegatorRewardResponse) ProtoMessage() {} +func (*MsgWithdrawDelegatorRewardResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_59dc3bedfb1cce84, []int{5} +} +func (m *MsgWithdrawDelegatorRewardResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgWithdrawDelegatorRewardResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgWithdrawDelegatorRewardResponse.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 *MsgWithdrawDelegatorRewardResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgWithdrawDelegatorRewardResponse.Merge(m, src) +} +func (m *MsgWithdrawDelegatorRewardResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgWithdrawDelegatorRewardResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgWithdrawDelegatorRewardResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgWithdrawDelegatorRewardResponse proto.InternalMessageInfo + +func (m *MsgWithdrawDelegatorRewardResponse) GetAmount() github_com_cosmos_cosmos_sdk_types.Coins { + if m != nil { + return m.Amount + } + return nil +} + +func init() { + proto.RegisterType((*MsgSetWithdrawAddress)(nil), "elysnetwork.elys.incentive.MsgSetWithdrawAddress") + proto.RegisterType((*MsgSetWithdrawAddressResponse)(nil), "elysnetwork.elys.incentive.MsgSetWithdrawAddressResponse") + proto.RegisterType((*MsgWithdrawValidatorCommission)(nil), "elysnetwork.elys.incentive.MsgWithdrawValidatorCommission") + proto.RegisterType((*MsgWithdrawValidatorCommissionResponse)(nil), "elysnetwork.elys.incentive.MsgWithdrawValidatorCommissionResponse") + proto.RegisterType((*MsgWithdrawDelegatorReward)(nil), "elysnetwork.elys.incentive.MsgWithdrawDelegatorReward") + proto.RegisterType((*MsgWithdrawDelegatorRewardResponse)(nil), "elysnetwork.elys.incentive.MsgWithdrawDelegatorRewardResponse") +} + func init() { proto.RegisterFile("elys/incentive/tx.proto", fileDescriptor_59dc3bedfb1cce84) } var fileDescriptor_59dc3bedfb1cce84 = []byte{ - // 133 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x4f, 0xcd, 0xa9, 0x2c, - 0xd6, 0xcf, 0xcc, 0x4b, 0x4e, 0xcd, 0x2b, 0xc9, 0x2c, 0x4b, 0xd5, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, - 0xca, 0x2f, 0xc9, 0x17, 0x92, 0x02, 0x49, 0xe4, 0xa5, 0x96, 0x94, 0xe7, 0x17, 0x65, 0xeb, 0x81, - 0xd8, 0x7a, 0x70, 0x45, 0x46, 0xac, 0x5c, 0xcc, 0xbe, 0xc5, 0xe9, 0x4e, 0x1e, 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, 0x97, 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, - 0x9c, 0x9f, 0xab, 0x0f, 0xd2, 0xab, 0x0b, 0x35, 0x08, 0xcc, 0xd1, 0xaf, 0x40, 0xb6, 0xaf, 0xb2, - 0x20, 0xb5, 0x38, 0x89, 0x0d, 0x6c, 0xa7, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x8a, 0x72, 0x87, - 0x7a, 0x8e, 0x00, 0x00, 0x00, + // 462 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x54, 0xcf, 0x6b, 0x13, 0x41, + 0x14, 0xce, 0x34, 0x50, 0x70, 0x3c, 0x58, 0x17, 0xa5, 0x75, 0xc5, 0x49, 0xd9, 0x83, 0x44, 0xa4, + 0x33, 0xa6, 0x82, 0xa0, 0x07, 0xc1, 0xd4, 0x83, 0x97, 0x5c, 0x22, 0x28, 0x78, 0x91, 0xc9, 0xee, + 0xb0, 0x1d, 0x9a, 0x9d, 0x17, 0xf6, 0x4d, 0xb3, 0xed, 0xd5, 0x9b, 0x07, 0x41, 0xff, 0x00, 0xff, + 0x01, 0xff, 0x08, 0xcf, 0x3d, 0xf6, 0xe8, 0x49, 0x25, 0xf9, 0x47, 0x64, 0xf6, 0x17, 0xb1, 0x64, + 0xa3, 0xcd, 0xa1, 0xa7, 0xbc, 0xbc, 0xf7, 0xbe, 0xef, 0x7b, 0xfb, 0xf1, 0x31, 0x74, 0x5b, 0x8d, + 0x4f, 0x51, 0x68, 0x13, 0x2a, 0x63, 0xf5, 0x54, 0x09, 0x7b, 0xc2, 0x27, 0x29, 0x58, 0xf0, 0x7c, + 0x37, 0x30, 0xca, 0x66, 0x90, 0x1e, 0x71, 0x57, 0xf3, 0x7a, 0xc9, 0x67, 0x21, 0x60, 0x02, 0x28, + 0x46, 0x12, 0x95, 0x98, 0xf6, 0x46, 0xca, 0xca, 0x9e, 0x08, 0x41, 0x9b, 0x02, 0xeb, 0xdf, 0x8a, + 0x21, 0x86, 0xbc, 0x14, 0xae, 0x2a, 0xba, 0x01, 0xd0, 0xdb, 0x03, 0x8c, 0x5f, 0x2b, 0xfb, 0x56, + 0xdb, 0xc3, 0x28, 0x95, 0xd9, 0x8b, 0x28, 0x4a, 0x15, 0xa2, 0xf7, 0x90, 0xde, 0x8c, 0xd4, 0x58, + 0xc5, 0xd2, 0x42, 0xfa, 0x5e, 0x16, 0xcd, 0x1d, 0xb2, 0x4b, 0xba, 0xd7, 0x86, 0x5b, 0xf5, 0xa0, + 0x5a, 0x7e, 0x40, 0xb7, 0xb2, 0x12, 0x5f, 0xef, 0x6e, 0xe4, 0xbb, 0x37, 0xb2, 0xbf, 0x79, 0x83, + 0x0e, 0xbd, 0xb7, 0x54, 0x70, 0xa8, 0x70, 0x02, 0x06, 0x55, 0x30, 0xa0, 0x6c, 0x80, 0x71, 0x35, + 0x7d, 0x23, 0xc7, 0x3a, 0x72, 0x52, 0x07, 0x90, 0x24, 0x1a, 0x51, 0x83, 0x71, 0xa7, 0x4d, 0xab, + 0xf6, 0xc5, 0xd3, 0xea, 0x41, 0xa5, 0xf7, 0x89, 0xd0, 0xfb, 0xab, 0xf9, 0x2a, 0x65, 0x2f, 0xa4, + 0x9b, 0x32, 0x81, 0x63, 0x63, 0x77, 0xc8, 0x6e, 0xbb, 0x7b, 0x7d, 0xff, 0x0e, 0x2f, 0x2c, 0xe5, + 0xce, 0x52, 0x5e, 0x5a, 0xca, 0x0f, 0x40, 0x9b, 0xfe, 0xa3, 0xb3, 0x9f, 0x9d, 0xd6, 0xb7, 0x5f, + 0x9d, 0x6e, 0xac, 0xed, 0xe1, 0xf1, 0x88, 0x87, 0x90, 0x88, 0xd2, 0xff, 0xe2, 0x67, 0x0f, 0xa3, + 0x23, 0x61, 0x4f, 0x27, 0x0a, 0x73, 0x00, 0x0e, 0x4b, 0xea, 0x60, 0x4a, 0xfd, 0x85, 0x73, 0x5e, + 0x56, 0x4e, 0x0e, 0x55, 0x26, 0xd3, 0xe8, 0x72, 0xae, 0x2f, 0xf5, 0x61, 0xa3, 0xc1, 0x87, 0x8f, + 0x84, 0x06, 0xcd, 0xc2, 0x57, 0xea, 0xc1, 0xfe, 0xf7, 0x36, 0x6d, 0x0f, 0x30, 0xf6, 0x3e, 0x10, + 0xea, 0x2d, 0x89, 0x5e, 0x8f, 0x37, 0xc7, 0x9c, 0x2f, 0x0d, 0x8f, 0xff, 0xf4, 0xd2, 0x90, 0xfa, + 0x8b, 0xbf, 0x12, 0x7a, 0x77, 0x55, 0xda, 0x9e, 0xfd, 0x83, 0x7a, 0x05, 0xd6, 0xef, 0xaf, 0x8f, + 0xad, 0xef, 0xfb, 0x42, 0xe8, 0x76, 0x53, 0x5c, 0x9e, 0xfc, 0x27, 0xff, 0x05, 0x9c, 0xff, 0x7c, + 0x3d, 0x5c, 0x75, 0x53, 0xff, 0xd5, 0xd9, 0x8c, 0x91, 0xf3, 0x19, 0x23, 0xbf, 0x67, 0x8c, 0x7c, + 0x9e, 0xb3, 0xd6, 0xf9, 0x9c, 0xb5, 0x7e, 0xcc, 0x59, 0xeb, 0x1d, 0x5f, 0x08, 0x83, 0xe3, 0xdd, + 0x2b, 0x45, 0xf2, 0x3f, 0xe2, 0x64, 0xf1, 0x51, 0x73, 0xc1, 0x18, 0x6d, 0xe6, 0xcf, 0xd0, 0xe3, + 0x3f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xa0, 0xb7, 0xfb, 0x9d, 0xf3, 0x04, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -50,6 +362,9 @@ const _ = grpc.SupportPackageIsVersion4 // // 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 { + SetWithdrawAddress(ctx context.Context, in *MsgSetWithdrawAddress, opts ...grpc.CallOption) (*MsgSetWithdrawAddressResponse, error) + WithdrawValidatorCommission(ctx context.Context, in *MsgWithdrawValidatorCommission, opts ...grpc.CallOption) (*MsgWithdrawValidatorCommissionResponse, error) + WithdrawDelegatorReward(ctx context.Context, in *MsgWithdrawDelegatorReward, opts ...grpc.CallOption) (*MsgWithdrawDelegatorRewardResponse, error) } type msgClient struct { @@ -60,22 +375,1046 @@ func NewMsgClient(cc grpc1.ClientConn) MsgClient { return &msgClient{cc} } +func (c *msgClient) SetWithdrawAddress(ctx context.Context, in *MsgSetWithdrawAddress, opts ...grpc.CallOption) (*MsgSetWithdrawAddressResponse, error) { + out := new(MsgSetWithdrawAddressResponse) + err := c.cc.Invoke(ctx, "/elysnetwork.elys.incentive.Msg/SetWithdrawAddress", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) WithdrawValidatorCommission(ctx context.Context, in *MsgWithdrawValidatorCommission, opts ...grpc.CallOption) (*MsgWithdrawValidatorCommissionResponse, error) { + out := new(MsgWithdrawValidatorCommissionResponse) + err := c.cc.Invoke(ctx, "/elysnetwork.elys.incentive.Msg/WithdrawValidatorCommission", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) WithdrawDelegatorReward(ctx context.Context, in *MsgWithdrawDelegatorReward, opts ...grpc.CallOption) (*MsgWithdrawDelegatorRewardResponse, error) { + out := new(MsgWithdrawDelegatorRewardResponse) + err := c.cc.Invoke(ctx, "/elysnetwork.elys.incentive.Msg/WithdrawDelegatorReward", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // MsgServer is the server API for Msg service. type MsgServer interface { + SetWithdrawAddress(context.Context, *MsgSetWithdrawAddress) (*MsgSetWithdrawAddressResponse, error) + WithdrawValidatorCommission(context.Context, *MsgWithdrawValidatorCommission) (*MsgWithdrawValidatorCommissionResponse, error) + WithdrawDelegatorReward(context.Context, *MsgWithdrawDelegatorReward) (*MsgWithdrawDelegatorRewardResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. type UnimplementedMsgServer struct { } +func (*UnimplementedMsgServer) SetWithdrawAddress(ctx context.Context, req *MsgSetWithdrawAddress) (*MsgSetWithdrawAddressResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SetWithdrawAddress not implemented") +} +func (*UnimplementedMsgServer) WithdrawValidatorCommission(ctx context.Context, req *MsgWithdrawValidatorCommission) (*MsgWithdrawValidatorCommissionResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method WithdrawValidatorCommission not implemented") +} +func (*UnimplementedMsgServer) WithdrawDelegatorReward(ctx context.Context, req *MsgWithdrawDelegatorReward) (*MsgWithdrawDelegatorRewardResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method WithdrawDelegatorReward not implemented") +} + func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) } +func _Msg_SetWithdrawAddress_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgSetWithdrawAddress) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).SetWithdrawAddress(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/elysnetwork.elys.incentive.Msg/SetWithdrawAddress", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).SetWithdrawAddress(ctx, req.(*MsgSetWithdrawAddress)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_WithdrawValidatorCommission_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgWithdrawValidatorCommission) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).WithdrawValidatorCommission(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/elysnetwork.elys.incentive.Msg/WithdrawValidatorCommission", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).WithdrawValidatorCommission(ctx, req.(*MsgWithdrawValidatorCommission)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_WithdrawDelegatorReward_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgWithdrawDelegatorReward) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).WithdrawDelegatorReward(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/elysnetwork.elys.incentive.Msg/WithdrawDelegatorReward", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).WithdrawDelegatorReward(ctx, req.(*MsgWithdrawDelegatorReward)) + } + return interceptor(ctx, in, info, handler) +} + var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "elysnetwork.elys.incentive.Msg", HandlerType: (*MsgServer)(nil), - Methods: []grpc.MethodDesc{}, - Streams: []grpc.StreamDesc{}, - Metadata: "elys/incentive/tx.proto", + Methods: []grpc.MethodDesc{ + { + MethodName: "SetWithdrawAddress", + Handler: _Msg_SetWithdrawAddress_Handler, + }, + { + MethodName: "WithdrawValidatorCommission", + Handler: _Msg_WithdrawValidatorCommission_Handler, + }, + { + MethodName: "WithdrawDelegatorReward", + Handler: _Msg_WithdrawDelegatorReward_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "elys/incentive/tx.proto", +} + +func (m *MsgSetWithdrawAddress) 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 *MsgSetWithdrawAddress) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSetWithdrawAddress) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.WithdrawAddress) > 0 { + i -= len(m.WithdrawAddress) + copy(dAtA[i:], m.WithdrawAddress) + i = encodeVarintTx(dAtA, i, uint64(len(m.WithdrawAddress))) + i-- + dAtA[i] = 0x12 + } + if len(m.DelegatorAddress) > 0 { + i -= len(m.DelegatorAddress) + copy(dAtA[i:], m.DelegatorAddress) + i = encodeVarintTx(dAtA, i, uint64(len(m.DelegatorAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgSetWithdrawAddressResponse) 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 *MsgSetWithdrawAddressResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSetWithdrawAddressResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgWithdrawValidatorCommission) 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 *MsgWithdrawValidatorCommission) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgWithdrawValidatorCommission) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ValidatorAddress) > 0 { + i -= len(m.ValidatorAddress) + copy(dAtA[i:], m.ValidatorAddress) + i = encodeVarintTx(dAtA, i, uint64(len(m.ValidatorAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgWithdrawValidatorCommissionResponse) 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 *MsgWithdrawValidatorCommissionResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgWithdrawValidatorCommissionResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Amount) > 0 { + for iNdEx := len(m.Amount) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Amount[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *MsgWithdrawDelegatorReward) 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 *MsgWithdrawDelegatorReward) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgWithdrawDelegatorReward) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ValidatorAddress) > 0 { + i -= len(m.ValidatorAddress) + copy(dAtA[i:], m.ValidatorAddress) + i = encodeVarintTx(dAtA, i, uint64(len(m.ValidatorAddress))) + i-- + dAtA[i] = 0x12 + } + if len(m.DelegatorAddress) > 0 { + i -= len(m.DelegatorAddress) + copy(dAtA[i:], m.DelegatorAddress) + i = encodeVarintTx(dAtA, i, uint64(len(m.DelegatorAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgWithdrawDelegatorRewardResponse) 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 *MsgWithdrawDelegatorRewardResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgWithdrawDelegatorRewardResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Amount) > 0 { + for iNdEx := len(m.Amount) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Amount[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func 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 *MsgSetWithdrawAddress) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.DelegatorAddress) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.WithdrawAddress) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgSetWithdrawAddressResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgWithdrawValidatorCommission) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ValidatorAddress) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgWithdrawValidatorCommissionResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Amount) > 0 { + for _, e := range m.Amount { + l = e.Size() + n += 1 + l + sovTx(uint64(l)) + } + } + return n +} + +func (m *MsgWithdrawDelegatorReward) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.DelegatorAddress) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.ValidatorAddress) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n } + +func (m *MsgWithdrawDelegatorRewardResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Amount) > 0 { + for _, e := range m.Amount { + l = e.Size() + n += 1 + l + sovTx(uint64(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 *MsgSetWithdrawAddress) 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: MsgSetWithdrawAddress: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSetWithdrawAddress: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DelegatorAddress", 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.DelegatorAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field WithdrawAddress", 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.WithdrawAddress = 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 *MsgSetWithdrawAddressResponse) 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: MsgSetWithdrawAddressResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSetWithdrawAddressResponse: 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 *MsgWithdrawValidatorCommission) 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: MsgWithdrawValidatorCommission: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgWithdrawValidatorCommission: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ValidatorAddress", 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.ValidatorAddress = 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 *MsgWithdrawValidatorCommissionResponse) 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: MsgWithdrawValidatorCommissionResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgWithdrawValidatorCommissionResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", 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.Amount = append(m.Amount, types.Coin{}) + if err := m.Amount[len(m.Amount)-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 *MsgWithdrawDelegatorReward) 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: MsgWithdrawDelegatorReward: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgWithdrawDelegatorReward: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DelegatorAddress", 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.DelegatorAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ValidatorAddress", 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.ValidatorAddress = 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 *MsgWithdrawDelegatorRewardResponse) 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: MsgWithdrawDelegatorRewardResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgWithdrawDelegatorRewardResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", 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.Amount = append(m.Amount, types.Coin{}) + if err := m.Amount[len(m.Amount)-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 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/incentive/types/validator.go b/x/incentive/types/validator.go new file mode 100644 index 000000000..a141eef83 --- /dev/null +++ b/x/incentive/types/validator.go @@ -0,0 +1,48 @@ +package types + +import ( + "fmt" + "strings" + + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// create a new ValidatorHistoricalRewards +func NewValidatorHistoricalRewards(cumulativeRewardRatio sdk.DecCoins, referenceCount uint32) ValidatorHistoricalRewards { + return ValidatorHistoricalRewards{ + CumulativeRewardRatio: cumulativeRewardRatio, + ReferenceCount: referenceCount, + } +} + +// create a new ValidatorCurrentRewards +func NewValidatorCurrentRewards(rewards sdk.DecCoins, period uint64) ValidatorCurrentRewards { + return ValidatorCurrentRewards{ + Rewards: rewards, + Period: period, + } +} + +// return the initial accumulated commission (zero) +func InitialValidatorAccumulatedCommission() ValidatorAccumulatedCommission { + return ValidatorAccumulatedCommission{} +} + +// create a new ValidatorSlashEvent +func NewValidatorSlashEvent(validatorPeriod uint64, fraction sdk.Dec) ValidatorSlashEvent { + return ValidatorSlashEvent{ + ValidatorPeriod: validatorPeriod, + Fraction: fraction, + } +} + +func (vs ValidatorSlashEvents) GetString() string { + out := "Validator Slash Events:\n" + for i, sl := range vs.ValidatorSlashEvents { + out += fmt.Sprintf(` Slash %d: + Period: %d + Fraction: %s +`, i, sl.ValidatorPeriod, sl.Fraction) + } + return strings.TrimSpace(out) +}