From 0651828413b360df8b3153561ed841c3ac532a6d Mon Sep 17 00:00:00 2001 From: Raphael Date: Wed, 8 Nov 2023 10:57:47 +0100 Subject: [PATCH] feat: implement funders module (#141) Co-authored-by: mbreithecker --- CHANGELOG.md | 4 + Makefile | 3 +- app/app.go | 35 + app/keepers.go | 2 + app/modules.go | 4 + app/upgrades/v1_4/store.go | 3 +- app/upgrades/v1_4/upgrade.go | 162 +- app/upgrades/v1_4/v1_3_types/getters_pool.go | 29 + app/upgrades/v1_4/v1_3_types/pool.pb.go | 2120 ++++++++++ config.yml | 86 +- docs/config.json | 3 + docs/swagger.yml | 1655 +++++++- go.mod | 24 +- go.sum | 43 +- proto/Dockerfile | 17 + proto/buf.gen.yaml | 2 +- proto/generate.sh | 2 +- proto/kyve/funders/v1beta1/events.proto | 84 + proto/kyve/funders/v1beta1/funders.proto | 48 + proto/kyve/funders/v1beta1/genesis.proto | 21 + proto/kyve/funders/v1beta1/params.proto | 17 + proto/kyve/funders/v1beta1/query.proto | 26 + proto/kyve/funders/v1beta1/tx.proto | 101 + proto/kyve/pool/v1beta1/events.proto | 37 +- proto/kyve/pool/v1beta1/pool.proto | 26 +- proto/kyve/pool/v1beta1/tx.proto | 35 +- proto/kyve/query/v1beta1/funders.proto | 173 + proto/kyve/query/v1beta1/params.proto | 5 +- proto/kyve/query/v1beta1/query.proto | 4 +- testutil/integration/checks.go | 136 +- testutil/integration/transactions.go | 10 + testutil/keeper/funders.go | 56 + tools/tools.go | 1 - x/bundles/abci.go | 17 +- x/bundles/keeper/abci_protocol_split_test.go | 164 +- x/bundles/keeper/keeper.go | 3 + .../keeper_suite_dropped_bundles_test.go | 51 +- .../keeper_suite_funding_bundles_test.go | 280 +- .../keeper_suite_inflation_splitting_test.go | 310 +- .../keeper_suite_invalid_bundles_test.go | 67 +- x/bundles/keeper/keeper_suite_points_test.go | 44 +- .../keeper/keeper_suite_stakers_leave_test.go | 55 +- .../keeper/keeper_suite_valid_bundles_test.go | 112 +- .../keeper_suite_zero_delegation_test.go | 81 +- x/bundles/keeper/logic_bundles_test.go | 418 +- ...ic_end_block_handle_upload_timeout_test.go | 90 +- x/bundles/keeper/logic_round_robin_test.go | 47 +- .../msg_server_claim_uploader_role_test.go | 103 +- .../msg_server_skip_uploader_role_test.go | 43 +- .../msg_server_submit_bundle_proposal.go | 4 +- .../msg_server_submit_bundle_proposal_test.go | 43 +- .../msg_server_vote_bundle_proposal_test.go | 45 +- x/bundles/spec/04_begin_block.md | 2 +- x/bundles/types/errors.go | 1 - x/bundles/types/expected_keepers.go | 5 +- x/delegation/keeper/keeper_suite_test.go | 58 +- .../keeper/msg_server_delegate_test.go | 18 +- .../keeper/msg_server_redelegate_test.go | 29 +- .../keeper/msg_server_undelegate_test.go | 28 +- .../msg_server_withdraw_rewards_test.go | 16 +- x/funders/client/cli/flags.go | 25 + x/funders/client/cli/query.go | 31 + x/funders/client/cli/query_params.go | 36 + x/funders/client/cli/tx.go | 30 + x/funders/client/cli/tx_create_funder.go | 47 + .../client/cli/tx_defund_pool.go | 12 +- .../client/cli/tx_fund_pool.go | 21 +- x/funders/client/cli/tx_update_funder.go | 46 + x/funders/genesis.go | 33 + x/funders/keeper/getters_funder.go | 92 + x/funders/keeper/getters_funding.go | 153 + x/funders/keeper/getters_funding_state.go | 63 + x/funders/keeper/getters_params.go | 26 + x/funders/keeper/keeper.go | 61 + x/funders/keeper/keeper_test.go | 16 + x/funders/keeper/logic_funders.go | 163 + x/funders/keeper/logic_funders_test.go | 306 ++ x/funders/keeper/msg_server.go | 17 + x/funders/keeper/msg_server_create_funder.go | 43 + .../keeper/msg_server_create_funder_test.go | 110 + x/funders/keeper/msg_server_defund_pool.go | 65 + .../keeper/msg_server_defund_pool_test.go | 214 + x/funders/keeper/msg_server_fund_pool.go | 90 + x/funders/keeper/msg_server_fund_pool_test.go | 432 ++ x/funders/keeper/msg_server_update_funder.go | 42 + .../keeper/msg_server_update_funder_test.go | 99 + x/funders/keeper/msg_server_update_params.go | 35 + .../keeper/msg_server_update_params_test.go | 409 ++ x/funders/keeper/query.go | 7 + x/funders/keeper/query_params.go | 19 + x/funders/module.go | 151 + x/funders/types/codec.go | 23 + x/funders/types/errors.go | 18 + x/funders/types/events.pb.go | 1994 ++++++++++ x/funders/types/expected_keepers.go | 15 + x/funders/types/funders.go | 49 + x/funders/types/funders.pb.go | 1124 ++++++ x/funders/types/funders_test.go | 139 + x/funders/types/genesis.go | 46 + x/funders/types/genesis.pb.go | 519 +++ x/funders/types/keys.go | 70 + x/funders/types/message_create_funder.go | 42 + .../types/message_defund_pool.go | 31 +- .../types/message_fund_pool.go | 24 +- x/funders/types/message_update_funder.go | 42 + x/funders/types/msgs.go | 35 + x/funders/types/params.go | 49 + x/funders/types/params.pb.go | 380 ++ x/funders/types/query.pb.go | 536 +++ x/funders/types/query.pb.gw.go | 153 + x/funders/types/tx.pb.go | 2623 ++++++++++++ x/funders/types/types.go | 1 + x/funders/types/types_test.go | 16 + x/pool/client/cli/tx.go | 3 - x/pool/keeper/keeper.go | 11 +- x/pool/keeper/keeper_utils_test.go | 20 + ...gic_end_block_handle_pool_upgrades_test.go | 32 +- x/pool/keeper/logic_funders.go | 64 - x/pool/keeper/logic_funders_test.go | 314 -- .../msg_server_cancel_runtime_upgrade_test.go | 27 +- x/pool/keeper/msg_server_create_pool.go | 47 +- x/pool/keeper/msg_server_create_pool_test.go | 248 +- x/pool/keeper/msg_server_defund_pool.go | 55 - x/pool/keeper/msg_server_defund_pool_test.go | 149 - x/pool/keeper/msg_server_disable_pool_test.go | 103 +- x/pool/keeper/msg_server_enable_pool_test.go | 8 +- x/pool/keeper/msg_server_fund_pool.go | 71 - x/pool/keeper/msg_server_fund_pool_test.go | 278 -- ...sg_server_schedule_runtime_upgrade_test.go | 45 +- x/pool/keeper/msg_server_update_pool.go | 28 +- x/pool/keeper/msg_server_update_pool_test.go | 140 +- x/pool/spec/02_state.md | 10 +- x/pool/spec/06_events.md | 8 +- x/pool/types/codec.go | 7 +- x/pool/types/errors.go | 9 +- x/pool/types/events.pb.go | 793 +--- x/pool/types/expected_keepers.go | 10 +- x/pool/types/genesis.go | 7 +- x/pool/types/keys.go | 4 - x/pool/types/msgs.go | 30 +- x/pool/types/pool.go | 71 - x/pool/types/pool.pb.go | 462 +-- x/pool/types/tx.pb.go | 1001 +---- x/query/client/cli/query.go | 7 +- x/query/client/cli/query_funders.go | 86 + x/query/client/cli/query_fundings.go | 82 + x/query/keeper/grpc_account_assets.go | 6 +- x/query/keeper/grpc_account_funded.go | 35 +- .../keeper/grpc_account_redelegation_test.go | 29 +- x/query/keeper/grpc_params.go | 10 +- x/query/keeper/grpc_query.go | 1 + x/query/keeper/grpc_query_can_propose_test.go | 28 +- .../keeper/grpc_query_can_validate_test.go | 22 +- x/query/keeper/grpc_query_can_vote_test.go | 28 +- x/query/keeper/grpc_query_funders.go | 107 + x/query/keeper/grpc_query_fundings.go | 57 + x/query/keeper/helper.go | 23 +- x/query/keeper/keeper.go | 5 + x/query/module.go | 2 + x/query/types/funders.pb.go | 3517 +++++++++++++++++ x/query/types/funders.pb.gw.go | 528 +++ x/query/types/params.pb.go | 123 +- x/query/types/query.pb.go | 123 +- x/stakers/keeper/exported_functions_test.go | 23 +- ...sg_server_claim_commission_rewards_test.go | 86 +- x/stakers/keeper/msg_server_join_pool_test.go | 87 +- .../keeper/msg_server_leave_pool_test.go | 33 +- x/team/keeper/logic_team_test.go | 5 - 168 files changed, 21984 insertions(+), 5055 deletions(-) create mode 100644 app/upgrades/v1_4/v1_3_types/getters_pool.go create mode 100644 app/upgrades/v1_4/v1_3_types/pool.pb.go create mode 100644 proto/kyve/funders/v1beta1/events.proto create mode 100644 proto/kyve/funders/v1beta1/funders.proto create mode 100644 proto/kyve/funders/v1beta1/genesis.proto create mode 100644 proto/kyve/funders/v1beta1/params.proto create mode 100644 proto/kyve/funders/v1beta1/query.proto create mode 100644 proto/kyve/funders/v1beta1/tx.proto create mode 100644 proto/kyve/query/v1beta1/funders.proto create mode 100644 testutil/keeper/funders.go create mode 100644 x/funders/client/cli/flags.go create mode 100644 x/funders/client/cli/query.go create mode 100644 x/funders/client/cli/query_params.go create mode 100644 x/funders/client/cli/tx.go create mode 100644 x/funders/client/cli/tx_create_funder.go rename x/{pool => funders}/client/cli/tx_defund_pool.go (83%) rename x/{pool => funders}/client/cli/tx_fund_pool.go (65%) create mode 100644 x/funders/client/cli/tx_update_funder.go create mode 100644 x/funders/genesis.go create mode 100644 x/funders/keeper/getters_funder.go create mode 100644 x/funders/keeper/getters_funding.go create mode 100644 x/funders/keeper/getters_funding_state.go create mode 100644 x/funders/keeper/getters_params.go create mode 100644 x/funders/keeper/keeper.go create mode 100644 x/funders/keeper/keeper_test.go create mode 100644 x/funders/keeper/logic_funders.go create mode 100644 x/funders/keeper/logic_funders_test.go create mode 100644 x/funders/keeper/msg_server.go create mode 100644 x/funders/keeper/msg_server_create_funder.go create mode 100644 x/funders/keeper/msg_server_create_funder_test.go create mode 100644 x/funders/keeper/msg_server_defund_pool.go create mode 100644 x/funders/keeper/msg_server_defund_pool_test.go create mode 100644 x/funders/keeper/msg_server_fund_pool.go create mode 100644 x/funders/keeper/msg_server_fund_pool_test.go create mode 100644 x/funders/keeper/msg_server_update_funder.go create mode 100644 x/funders/keeper/msg_server_update_funder_test.go create mode 100644 x/funders/keeper/msg_server_update_params.go create mode 100644 x/funders/keeper/msg_server_update_params_test.go create mode 100644 x/funders/keeper/query.go create mode 100644 x/funders/keeper/query_params.go create mode 100644 x/funders/module.go create mode 100644 x/funders/types/codec.go create mode 100644 x/funders/types/errors.go create mode 100644 x/funders/types/events.pb.go create mode 100644 x/funders/types/expected_keepers.go create mode 100644 x/funders/types/funders.go create mode 100644 x/funders/types/funders.pb.go create mode 100644 x/funders/types/funders_test.go create mode 100644 x/funders/types/genesis.go create mode 100644 x/funders/types/genesis.pb.go create mode 100644 x/funders/types/keys.go create mode 100644 x/funders/types/message_create_funder.go rename x/{pool => funders}/types/message_defund_pool.go (61%) rename x/{pool => funders}/types/message_fund_pool.go (73%) create mode 100644 x/funders/types/message_update_funder.go create mode 100644 x/funders/types/msgs.go create mode 100644 x/funders/types/params.go create mode 100644 x/funders/types/params.pb.go create mode 100644 x/funders/types/query.pb.go create mode 100644 x/funders/types/query.pb.gw.go create mode 100644 x/funders/types/tx.pb.go create mode 100644 x/funders/types/types.go create mode 100644 x/funders/types/types_test.go delete mode 100644 x/pool/keeper/logic_funders.go delete mode 100644 x/pool/keeper/logic_funders_test.go delete mode 100644 x/pool/keeper/msg_server_defund_pool.go delete mode 100644 x/pool/keeper/msg_server_defund_pool_test.go delete mode 100644 x/pool/keeper/msg_server_fund_pool.go delete mode 100644 x/pool/keeper/msg_server_fund_pool_test.go create mode 100644 x/query/client/cli/query_funders.go create mode 100644 x/query/client/cli/query_fundings.go create mode 100644 x/query/keeper/grpc_query_funders.go create mode 100644 x/query/keeper/grpc_query_fundings.go create mode 100644 x/query/types/funders.pb.go create mode 100644 x/query/types/funders.pb.gw.go diff --git a/CHANGELOG.md b/CHANGELOG.md index a281a0f2..df220eda 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,10 @@ An '!' indicates a state machine breaking change. ## [Unreleased] +### Features + +- ! (`x/funders`) [#141](https://github.com/KYVENetwork/chain/pull/141) Implementation of the new [funders concept](https://commonwealth.im/kyve/discussion/13420-enhancing-kyves-funders-concept). + ### Improvements - ! (`x/bundles`) [#142](https://github.com/KYVENetwork/chain/pull/142) Halt the pool if a single validator has more than 50% voting power. diff --git a/Makefile b/Makefile index 50784932..6f1f8824 100644 --- a/Makefile +++ b/Makefile @@ -171,7 +171,8 @@ proto-lint: proto-setup: @echo "🤖 Setting up protobuf environment..." - @docker build --rm --tag kyve-proto:latest --file proto/Dockerfile . + @docker build --rm --tag kyve-proto:latest --file proto/Dockerfile \ + --build-arg USER_ID=$$(id -u) --build-arg USER_GID=$$(id -g) . @echo "✅ Setup protobuf environment!" ############################################################################### diff --git a/app/app.go b/app/app.go index 9f31b949..0ed558bb 100644 --- a/app/app.go +++ b/app/app.go @@ -162,6 +162,10 @@ import ( "github.com/cosmos/cosmos-sdk/x/upgrade" upgradeKeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper" upgradeTypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" + // Funders + "github.com/KYVENetwork/chain/x/funders" + fundersKeeper "github.com/KYVENetwork/chain/x/funders/keeper" + fundersTypes "github.com/KYVENetwork/chain/x/funders/types" ) const ( @@ -293,6 +297,7 @@ func NewKYVEApp( queryTypes.StoreKey, stakersTypes.StoreKey, teamTypes.StoreKey, + fundersTypes.StoreKey, ) tkeys := sdk.NewTransientStoreKeys(paramsTypes.TStoreKey) memKeys := sdk.NewMemoryStoreKeys( @@ -425,6 +430,12 @@ func NewKYVEApp( app.AccountKeeper, ) + app.FeeGrantKeeper = feeGrantKeeper.NewKeeper( + appCodec, + keys[feeGrantTypes.StoreKey], + app.AccountKeeper, + ) + app.GroupKeeper = groupKeeper.NewKeeper( keys[groupTypes.StoreKey], appCodec, @@ -504,8 +515,22 @@ func NewKYVEApp( app.StakersKeeper, ) + app.FundersKeeper = *fundersKeeper.NewKeeper( + appCodec, + keys[fundersTypes.StoreKey], + memKeys[fundersTypes.MemStoreKey], + + authTypes.NewModuleAddress(govTypes.ModuleName).String(), + + app.AccountKeeper, + app.BankKeeper, + app.PoolKeeper, + app.UpgradeKeeper, + ) + stakersKeeper.SetDelegationKeeper(&app.StakersKeeper, app.DelegationKeeper) poolKeeper.SetStakersKeeper(&app.PoolKeeper, app.StakersKeeper) + poolKeeper.SetFundersKeeper(&app.PoolKeeper, app.FundersKeeper) app.BundlesKeeper = *bundlesKeeper.NewKeeper( appCodec, @@ -520,6 +545,7 @@ func NewKYVEApp( app.PoolKeeper, app.StakersKeeper, app.DelegationKeeper, + app.FundersKeeper, ) app.IBCKeeper = ibcKeeper.NewKeeper( @@ -633,6 +659,7 @@ func NewKYVEApp( app.GlobalKeeper, *app.GovKeeper, app.TeamKeeper, + app.FundersKeeper, ) // this line is used by starport scaffolding # stargate/app/keeperDefinition @@ -709,6 +736,7 @@ func NewKYVEApp( query.NewAppModule(appCodec, app.QueryKeeper, app.AccountKeeper, app.BankKeeper), stakers.NewAppModule(appCodec, app.StakersKeeper, app.AccountKeeper, app.BankKeeper), team.NewAppModule(appCodec, app.BankKeeper, app.MintKeeper, app.TeamKeeper, *app.UpgradeKeeper), + funders.NewAppModule(appCodec, app.FundersKeeper, app.AccountKeeper, app.BankKeeper), ) // During begin block slashing happens after distr.BeginBlocker so that @@ -750,6 +778,7 @@ func NewKYVEApp( delegationTypes.ModuleName, queryTypes.ModuleName, globalTypes.ModuleName, + fundersTypes.ModuleName, ) app.mm.SetOrderEndBlockers( @@ -784,6 +813,7 @@ func NewKYVEApp( queryTypes.ModuleName, globalTypes.ModuleName, teamTypes.ModuleName, + fundersTypes.ModuleName, ) // NOTE: The genutils module must occur after staking so that pools are @@ -823,6 +853,7 @@ func NewKYVEApp( queryTypes.ModuleName, globalTypes.ModuleName, teamTypes.ModuleName, + fundersTypes.ModuleName, ) // Uncomment if you want to set a custom migration order here. @@ -880,6 +911,10 @@ func NewKYVEApp( *app.GovKeeper, *app.IBCKeeper, app.ParamsKeeper, + app.PoolKeeper, + app.FundersKeeper, + app.BankKeeper, + app.AccountKeeper, ), ) diff --git a/app/keepers.go b/app/keepers.go index 3959e0bb..e265ce64 100644 --- a/app/keepers.go +++ b/app/keepers.go @@ -1,6 +1,7 @@ package app import ( + fundersKeeper "github.com/KYVENetwork/chain/x/funders/keeper" "github.com/cosmos/cosmos-sdk/codec" storeTypes "github.com/cosmos/cosmos-sdk/store/types" @@ -112,6 +113,7 @@ type Keepers struct { QueryKeeper queryKeeper.Keeper StakersKeeper stakersKeeper.Keeper TeamKeeper teamKeeper.Keeper + FundersKeeper fundersKeeper.Keeper // ----- Scoped Keepers ----- // make scoped keepers public for test purposes diff --git a/app/modules.go b/app/modules.go index a94366f3..cfcf3019 100644 --- a/app/modules.go +++ b/app/modules.go @@ -1,6 +1,8 @@ package app import ( + "github.com/KYVENetwork/chain/x/funders" + fundersTypes "github.com/KYVENetwork/chain/x/funders/types" "github.com/cosmos/cosmos-sdk/types/module" // Auth @@ -129,6 +131,7 @@ var appModuleBasics = []module.AppModuleBasic{ query.AppModuleBasic{}, stakers.AppModuleBasic{}, team.AppModuleBasic{}, + funders.AppModuleBasic{}, } // moduleAccountPermissions ... @@ -152,6 +155,7 @@ var moduleAccountPermissions = map[string][]string{ poolTypes.ModuleName: nil, stakersTypes.ModuleName: nil, teamTypes.ModuleName: nil, + fundersTypes.ModuleName: nil, } // BlockedModuleAccountAddrs returns all the app's blocked module account addresses. diff --git a/app/upgrades/v1_4/store.go b/app/upgrades/v1_4/store.go index 95ef9d11..5f5f52ca 100644 --- a/app/upgrades/v1_4/store.go +++ b/app/upgrades/v1_4/store.go @@ -1,6 +1,7 @@ package v1_4 import ( + funderstypes "github.com/KYVENetwork/chain/x/funders/types" "github.com/cosmos/cosmos-sdk/baseapp" storeTypes "github.com/cosmos/cosmos-sdk/store/types" @@ -16,7 +17,7 @@ import ( func CreateStoreLoader(upgradeHeight int64) baseapp.StoreLoader { storeUpgrades := storeTypes.StoreUpgrades{ Added: []string{ - consensusTypes.StoreKey, crisisTypes.StoreKey, + consensusTypes.StoreKey, crisisTypes.StoreKey, funderstypes.StoreKey, }, } diff --git a/app/upgrades/v1_4/upgrade.go b/app/upgrades/v1_4/upgrade.go index 78d3bdbd..9ae077c2 100644 --- a/app/upgrades/v1_4/upgrade.go +++ b/app/upgrades/v1_4/upgrade.go @@ -1,11 +1,22 @@ package v1_4 import ( + "errors" + + "github.com/KYVENetwork/chain/app/upgrades/v1_4/v1_3_types" + "github.com/KYVENetwork/chain/util" + fundersKeeper "github.com/KYVENetwork/chain/x/funders/keeper" + fundersTypes "github.com/KYVENetwork/chain/x/funders/types" + globalTypes "github.com/KYVENetwork/chain/x/global/types" + poolKeeper "github.com/KYVENetwork/chain/x/pool/keeper" + poolTypes "github.com/KYVENetwork/chain/x/pool/types" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" + authKeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" authTypes "github.com/cosmos/cosmos-sdk/x/auth/types" + bankKeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" bankTypes "github.com/cosmos/cosmos-sdk/x/bank/types" crisisTypes "github.com/cosmos/cosmos-sdk/x/crisis/types" distributionTypes "github.com/cosmos/cosmos-sdk/x/distribution/types" @@ -17,18 +28,12 @@ import ( "github.com/cosmos/ibc-go/v7/modules/core/exported" ibcTmMigrations "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint/migrations" - // Consensus - consensusKeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper" - // Global globalKeeper "github.com/KYVENetwork/chain/x/global/keeper" - // Governance + consensusKeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper" govKeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper" - // IBC Core ibcKeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper" - // Params paramsKeeper "github.com/cosmos/cosmos-sdk/x/params/keeper" - // Upgrade upgradeTypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" ) @@ -43,6 +48,10 @@ func CreateUpgradeHandler( govKeeper govKeeper.Keeper, ibcKeeper ibcKeeper.Keeper, paramsKeeper paramsKeeper.Keeper, + poolKeeper poolKeeper.Keeper, + fundersKeeper fundersKeeper.Keeper, + bankKeeper bankKeeper.Keeper, + accountKeeper authKeeper.AccountKeeper, ) upgradeTypes.UpgradeHandler { return func(ctx sdk.Context, _ upgradeTypes.Plan, vm module.VersionMap) (module.VersionMap, error) { logger := ctx.Logger().With("upgrade", UpgradeName) @@ -103,6 +112,20 @@ func CreateUpgradeHandler( return vm, err } + // Migrate funders. + err = migrateFundersAndPools(ctx, cdc, poolKeeper, fundersKeeper, bankKeeper, accountKeeper) + if err != nil { + return vm, err + } + + // Set min gas for funder creation in global module + globalParams := globalKeeper.GetParams(ctx) + globalParams.GasAdjustments = append(globalParams.GasAdjustments, globalTypes.GasAdjustment{ + Type: "/kyve.funders.v1beta1.MsgCreateFunder", + Amount: 50_000_000, + }) + globalKeeper.SetParams(ctx, globalParams) + return vm, nil } } @@ -121,3 +144,128 @@ func migrateInitialDepositRatio( return govKeeper.SetParams(ctx, params) } + +type FundingMigration struct { + PoolId uint64 + Amount uint64 +} + +type FunderMigration struct { + Address string + Fundings []FundingMigration +} + +// migrateFunders migrates funders from x/pool to x/funders and creates funding states for pools. +func migrateFundersAndPools( + ctx sdk.Context, + cdc codec.BinaryCodec, + poolKeeper poolKeeper.Keeper, + fundersKeeper fundersKeeper.Keeper, + bankKeeper bankKeeper.Keeper, + accountKeeper authKeeper.AccountKeeper, +) error { + pools, err := v1_3_types.GetAllPools(ctx, poolKeeper, cdc) + if err != nil { + return err + } + + toBeCreatedFunders := make(map[string]*FunderMigration) + amountToBeTransferred := uint64(0) + + // Get all funders and their funding from pools. + for _, oldPool := range pools { + checkTotalFunds := uint64(0) + for _, funder := range oldPool.Funders { + if funder.Amount > 0 { + _, ok := toBeCreatedFunders[funder.Address] + if ok { + toBeCreatedFunders[funder.Address].Fundings = append(toBeCreatedFunders[funder.Address].Fundings, FundingMigration{PoolId: oldPool.Id, Amount: funder.Amount}) + } else { + toBeCreatedFunders[funder.Address] = &FunderMigration{ + Address: funder.Address, + Fundings: []FundingMigration{{PoolId: oldPool.Id, Amount: funder.Amount}}, + } + } + checkTotalFunds += funder.Amount + } + } + if checkTotalFunds != oldPool.TotalFunds { + return errors.New("total funds is not equal to the sum of all funders amount") + } + amountToBeTransferred += oldPool.TotalFunds + + // Create funding state for pool. + fundersKeeper.SetFundingState(ctx, &fundersTypes.FundingState{ + PoolId: oldPool.Id, + ActiveFunderAddresses: []string{}, + }) + + poolKeeper.SetPool(ctx, poolTypes.Pool{ + Id: oldPool.Id, + Name: oldPool.Name, + Runtime: oldPool.Runtime, + Logo: oldPool.Logo, + Config: oldPool.Config, + StartKey: oldPool.StartKey, + CurrentKey: oldPool.CurrentKey, + CurrentSummary: oldPool.CurrentSummary, + CurrentIndex: oldPool.CurrentIndex, + TotalBundles: oldPool.TotalBundles, + UploadInterval: oldPool.UploadInterval, + InflationShareWeight: oldPool.OperatingCost, + MinDelegation: oldPool.MinDelegation, + MaxBundleSize: oldPool.MaxBundleSize, + Disabled: oldPool.Disabled, + Protocol: &poolTypes.Protocol{ + Version: oldPool.Protocol.Version, + Binaries: oldPool.Protocol.Binaries, + LastUpgrade: oldPool.Protocol.LastUpgrade, + }, + UpgradePlan: &poolTypes.UpgradePlan{ + Version: oldPool.UpgradePlan.Version, + Binaries: oldPool.UpgradePlan.Binaries, + ScheduledAt: oldPool.UpgradePlan.ScheduledAt, + Duration: oldPool.UpgradePlan.Duration, + }, + CurrentStorageProviderId: oldPool.CurrentStorageProviderId, + CurrentCompressionId: oldPool.CurrentCompressionId, + }) + } + + // Create new funders and fundings. + for _, funder := range toBeCreatedFunders { + fundersKeeper.SetFunder(ctx, &fundersTypes.Funder{ + Address: funder.Address, + Moniker: funder.Address, + Identity: "", + Website: "", + Contact: "", + Description: "", + }) + for _, funding := range funder.Fundings { + fundersKeeper.SetFunding(ctx, &fundersTypes.Funding{ + FunderAddress: funder.Address, + PoolId: funding.PoolId, + Amount: funding.Amount, + AmountPerBundle: fundersTypes.DefaultMinFundingAmountPerBundle, + // Previous funders will not be considered, as there is no way to calculate this on chain. + // Although almost all funding was only provided by the Foundation itself. + TotalFunded: 0, + }) + } + } + + // Check if pool module balance is equal to the sum of all pools total funds. + poolModule := accountKeeper.GetModuleAddress(poolTypes.ModuleName) + balance := bankKeeper.GetBalance(ctx, poolModule, globalTypes.Denom) + if balance.Amount.Uint64() != amountToBeTransferred { + return errors.New("pool module balance is not equal to the sum of all pools total funds") + } + + // Transfer funds from pools to funders. + if err := util.TransferFromModuleToModule(bankKeeper, ctx, poolTypes.ModuleName, fundersTypes.ModuleName, amountToBeTransferred); err != nil { + return err + } + + return nil +} diff --git a/app/upgrades/v1_4/v1_3_types/getters_pool.go b/app/upgrades/v1_4/v1_3_types/getters_pool.go new file mode 100644 index 00000000..80d31ff7 --- /dev/null +++ b/app/upgrades/v1_4/v1_3_types/getters_pool.go @@ -0,0 +1,29 @@ +package v1_3_types + +import ( + poolKeeper "github.com/KYVENetwork/chain/x/pool/keeper" + "github.com/KYVENetwork/chain/x/pool/types" + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// GetAllPools returns all pools +func GetAllPools(ctx sdk.Context, poolKeeper poolKeeper.Keeper, cdc codec.BinaryCodec) (list []Pool, err error) { + store := prefix.NewStore(ctx.KVStore(poolKeeper.StoreKey()), types.PoolKey) + iterator := sdk.KVStorePrefixIterator(store, []byte{}) + + //goland:noinspection GoUnhandledErrorResult + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + var val Pool + err = cdc.Unmarshal(iterator.Value(), &val) + if err != nil { + return + } + list = append(list, val) + } + + return +} diff --git a/app/upgrades/v1_4/v1_3_types/pool.pb.go b/app/upgrades/v1_4/v1_3_types/pool.pb.go new file mode 100644 index 00000000..f2a5536f --- /dev/null +++ b/app/upgrades/v1_4/v1_3_types/pool.pb.go @@ -0,0 +1,2120 @@ +package v1_3_types + +import ( + "fmt" + "io" +) + +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: kyve/pool/v1beta1/pool.proto + +import ( + math "math" + math_bits "math/bits" + + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" +) + +// Reference imports to suppress errors if they are not otherwise used. +var ( + _ = proto.Marshal + _ = fmt.Errorf + _ = 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 + +// PoolStatus ... +type PoolStatus int32 + +const ( + // POOL_STATUS_UNSPECIFIED ... + POOL_STATUS_UNSPECIFIED PoolStatus = 0 + // POOL_STATUS_ACTIVE ... + POOL_STATUS_ACTIVE PoolStatus = 1 + // POOL_STATUS_DISABLED ... + POOL_STATUS_DISABLED PoolStatus = 2 + // POOL_STATUS_NO_FUNDS ... + POOL_STATUS_NO_FUNDS PoolStatus = 3 + // POOL_STATUS_NOT_ENOUGH_DELEGATION ... + POOL_STATUS_NOT_ENOUGH_DELEGATION PoolStatus = 4 + // POOL_STATUS_UPGRADING ... + POOL_STATUS_UPGRADING PoolStatus = 5 +) + +var PoolStatus_name = map[int32]string{ + 0: "POOL_STATUS_UNSPECIFIED", + 1: "POOL_STATUS_ACTIVE", + 2: "POOL_STATUS_DISABLED", + 3: "POOL_STATUS_NO_FUNDS", + 4: "POOL_STATUS_NOT_ENOUGH_DELEGATION", + 5: "POOL_STATUS_UPGRADING", +} + +var PoolStatus_value = map[string]int32{ + "POOL_STATUS_UNSPECIFIED": 0, + "POOL_STATUS_ACTIVE": 1, + "POOL_STATUS_DISABLED": 2, + "POOL_STATUS_NO_FUNDS": 3, + "POOL_STATUS_NOT_ENOUGH_DELEGATION": 4, + "POOL_STATUS_UPGRADING": 5, +} + +func (x PoolStatus) String() string { + return proto.EnumName(PoolStatus_name, int32(x)) +} + +func (PoolStatus) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_40c1730f47ff2ef8, []int{0} +} + +// Protocol holds all info about the current pool version and the +// available binaries for participating as a validator in a pool +type Protocol struct { + // version holds the current software version tag of the pool binaries + Version string `protobuf:"bytes,1,opt,name=version,proto3" json:"version,omitempty"` + // binaries is a stringified json object which holds binaries in the + // current version for multiple platforms and architectures + Binaries string `protobuf:"bytes,2,opt,name=binaries,proto3" json:"binaries,omitempty"` + // last_upgrade is the unix time the pool was upgraded the last time + LastUpgrade uint64 `protobuf:"varint,3,opt,name=last_upgrade,json=lastUpgrade,proto3" json:"last_upgrade,omitempty"` +} + +func (m *Protocol) Reset() { *m = Protocol{} } +func (m *Protocol) String() string { return proto.CompactTextString(m) } +func (*Protocol) ProtoMessage() {} +func (*Protocol) Descriptor() ([]byte, []int) { + return fileDescriptor_40c1730f47ff2ef8, []int{0} +} + +func (m *Protocol) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} + +func (m *Protocol) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Protocol.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 *Protocol) XXX_Merge(src proto.Message) { + xxx_messageInfo_Protocol.Merge(m, src) +} + +func (m *Protocol) XXX_Size() int { + return m.Size() +} + +func (m *Protocol) XXX_DiscardUnknown() { + xxx_messageInfo_Protocol.DiscardUnknown(m) +} + +var xxx_messageInfo_Protocol proto.InternalMessageInfo + +func (m *Protocol) GetVersion() string { + if m != nil { + return m.Version + } + return "" +} + +func (m *Protocol) GetBinaries() string { + if m != nil { + return m.Binaries + } + return "" +} + +func (m *Protocol) GetLastUpgrade() uint64 { + if m != nil { + return m.LastUpgrade + } + return 0 +} + +// Upgrade holds all info when a pool has a scheduled upgrade +type UpgradePlan struct { + // version is the new software version tag of the upgrade + Version string `protobuf:"bytes,1,opt,name=version,proto3" json:"version,omitempty"` + // binaries is the new stringified json object which holds binaries in the + // upgrade version for multiple platforms and architectures + Binaries string `protobuf:"bytes,2,opt,name=binaries,proto3" json:"binaries,omitempty"` + // scheduled_at is the unix time the upgrade is supposed to be done + ScheduledAt uint64 `protobuf:"varint,3,opt,name=scheduled_at,json=scheduledAt,proto3" json:"scheduled_at,omitempty"` + // duration is the time in seconds how long the pool should halt + // during the upgrade to give all validators a chance of switching + // to the new binaries + Duration uint64 `protobuf:"varint,4,opt,name=duration,proto3" json:"duration,omitempty"` +} + +func (m *UpgradePlan) Reset() { *m = UpgradePlan{} } +func (m *UpgradePlan) String() string { return proto.CompactTextString(m) } +func (*UpgradePlan) ProtoMessage() {} +func (*UpgradePlan) Descriptor() ([]byte, []int) { + return fileDescriptor_40c1730f47ff2ef8, []int{1} +} + +func (m *UpgradePlan) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} + +func (m *UpgradePlan) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_UpgradePlan.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 *UpgradePlan) XXX_Merge(src proto.Message) { + xxx_messageInfo_UpgradePlan.Merge(m, src) +} + +func (m *UpgradePlan) XXX_Size() int { + return m.Size() +} + +func (m *UpgradePlan) XXX_DiscardUnknown() { + xxx_messageInfo_UpgradePlan.DiscardUnknown(m) +} + +var xxx_messageInfo_UpgradePlan proto.InternalMessageInfo + +func (m *UpgradePlan) GetVersion() string { + if m != nil { + return m.Version + } + return "" +} + +func (m *UpgradePlan) GetBinaries() string { + if m != nil { + return m.Binaries + } + return "" +} + +func (m *UpgradePlan) GetScheduledAt() uint64 { + if m != nil { + return m.ScheduledAt + } + return 0 +} + +func (m *UpgradePlan) GetDuration() uint64 { + if m != nil { + return m.Duration + } + return 0 +} + +// Funder is the object which holds info about a single pool funder +type Funder struct { + // address is the address of the funder + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + // amount is the current amount of funds in ukyve the funder has + // still funded the pool with + Amount uint64 `protobuf:"varint,2,opt,name=amount,proto3" json:"amount,omitempty"` +} + +func (m *Funder) Reset() { *m = Funder{} } +func (m *Funder) String() string { return proto.CompactTextString(m) } +func (*Funder) ProtoMessage() {} +func (*Funder) Descriptor() ([]byte, []int) { + return fileDescriptor_40c1730f47ff2ef8, []int{2} +} + +func (m *Funder) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} + +func (m *Funder) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Funder.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 *Funder) XXX_Merge(src proto.Message) { + xxx_messageInfo_Funder.Merge(m, src) +} + +func (m *Funder) XXX_Size() int { + return m.Size() +} + +func (m *Funder) XXX_DiscardUnknown() { + xxx_messageInfo_Funder.DiscardUnknown(m) +} + +var xxx_messageInfo_Funder proto.InternalMessageInfo + +func (m *Funder) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +func (m *Funder) GetAmount() uint64 { + if m != nil { + return m.Amount + } + return 0 +} + +// Pool ... +type Pool struct { + // id - unique identifier of the pool, can not be changed + Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + // name is a human readable name for the pool + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + // runtime specified which protocol and which version needs is required + Runtime string `protobuf:"bytes,3,opt,name=runtime,proto3" json:"runtime,omitempty"` + // logo is a link to an image file + Logo string `protobuf:"bytes,4,opt,name=logo,proto3" json:"logo,omitempty"` + // config is either a JSON encoded string or a link to an external storage provider. + // This is up to the implementation of the protocol node. + Config string `protobuf:"bytes,5,opt,name=config,proto3" json:"config,omitempty"` + // start_key ... + StartKey string `protobuf:"bytes,6,opt,name=start_key,json=startKey,proto3" json:"start_key,omitempty"` + // current_key ... + CurrentKey string `protobuf:"bytes,7,opt,name=current_key,json=currentKey,proto3" json:"current_key,omitempty"` + // current_summary ... + CurrentSummary string `protobuf:"bytes,8,opt,name=current_summary,json=currentSummary,proto3" json:"current_summary,omitempty"` + // current_index ... + CurrentIndex uint64 `protobuf:"varint,9,opt,name=current_index,json=currentIndex,proto3" json:"current_index,omitempty"` + // total_bundles is the number of total finalized bundles + TotalBundles uint64 `protobuf:"varint,10,opt,name=total_bundles,json=totalBundles,proto3" json:"total_bundles,omitempty"` + // upload_interval ... + UploadInterval uint64 `protobuf:"varint,11,opt,name=upload_interval,json=uploadInterval,proto3" json:"upload_interval,omitempty"` + // operating_cost ... + OperatingCost uint64 `protobuf:"varint,12,opt,name=operating_cost,json=operatingCost,proto3" json:"operating_cost,omitempty"` + // min_delegation ... + MinDelegation uint64 `protobuf:"varint,13,opt,name=min_delegation,json=minDelegation,proto3" json:"min_delegation,omitempty"` + // max_bundle_size ... + MaxBundleSize uint64 `protobuf:"varint,14,opt,name=max_bundle_size,json=maxBundleSize,proto3" json:"max_bundle_size,omitempty"` + // disabled is true when the pool is disabled. + // Can only be done via governance. + Disabled bool `protobuf:"varint,15,opt,name=disabled,proto3" json:"disabled,omitempty"` + // funders ... + Funders []*Funder `protobuf:"bytes,16,rep,name=funders,proto3" json:"funders,omitempty"` + // total_funds ... + TotalFunds uint64 `protobuf:"varint,17,opt,name=total_funds,json=totalFunds,proto3" json:"total_funds,omitempty"` + // protocol ... + Protocol *Protocol `protobuf:"bytes,18,opt,name=protocol,proto3" json:"protocol,omitempty"` + // upgrade_plan ... + UpgradePlan *UpgradePlan `protobuf:"bytes,19,opt,name=upgrade_plan,json=upgradePlan,proto3" json:"upgrade_plan,omitempty"` + // storage_provider_id ... + CurrentStorageProviderId uint32 `protobuf:"varint,20,opt,name=current_storage_provider_id,json=currentStorageProviderId,proto3" json:"current_storage_provider_id,omitempty"` + // compression_id ... + CurrentCompressionId uint32 `protobuf:"varint,21,opt,name=current_compression_id,json=currentCompressionId,proto3" json:"current_compression_id,omitempty"` +} + +func (m *Pool) Reset() { *m = Pool{} } +func (m *Pool) String() string { return proto.CompactTextString(m) } +func (*Pool) ProtoMessage() {} +func (*Pool) Descriptor() ([]byte, []int) { + return fileDescriptor_40c1730f47ff2ef8, []int{3} +} + +func (m *Pool) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} + +func (m *Pool) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Pool.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 *Pool) XXX_Merge(src proto.Message) { + xxx_messageInfo_Pool.Merge(m, src) +} + +func (m *Pool) XXX_Size() int { + return m.Size() +} + +func (m *Pool) XXX_DiscardUnknown() { + xxx_messageInfo_Pool.DiscardUnknown(m) +} + +var xxx_messageInfo_Pool proto.InternalMessageInfo + +func (m *Pool) GetId() uint64 { + if m != nil { + return m.Id + } + return 0 +} + +func (m *Pool) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *Pool) GetRuntime() string { + if m != nil { + return m.Runtime + } + return "" +} + +func (m *Pool) GetLogo() string { + if m != nil { + return m.Logo + } + return "" +} + +func (m *Pool) GetConfig() string { + if m != nil { + return m.Config + } + return "" +} + +func (m *Pool) GetStartKey() string { + if m != nil { + return m.StartKey + } + return "" +} + +func (m *Pool) GetCurrentKey() string { + if m != nil { + return m.CurrentKey + } + return "" +} + +func (m *Pool) GetCurrentSummary() string { + if m != nil { + return m.CurrentSummary + } + return "" +} + +func (m *Pool) GetCurrentIndex() uint64 { + if m != nil { + return m.CurrentIndex + } + return 0 +} + +func (m *Pool) GetTotalBundles() uint64 { + if m != nil { + return m.TotalBundles + } + return 0 +} + +func (m *Pool) GetUploadInterval() uint64 { + if m != nil { + return m.UploadInterval + } + return 0 +} + +func (m *Pool) GetOperatingCost() uint64 { + if m != nil { + return m.OperatingCost + } + return 0 +} + +func (m *Pool) GetMinDelegation() uint64 { + if m != nil { + return m.MinDelegation + } + return 0 +} + +func (m *Pool) GetMaxBundleSize() uint64 { + if m != nil { + return m.MaxBundleSize + } + return 0 +} + +func (m *Pool) GetDisabled() bool { + if m != nil { + return m.Disabled + } + return false +} + +func (m *Pool) GetFunders() []*Funder { + if m != nil { + return m.Funders + } + return nil +} + +func (m *Pool) GetTotalFunds() uint64 { + if m != nil { + return m.TotalFunds + } + return 0 +} + +func (m *Pool) GetProtocol() *Protocol { + if m != nil { + return m.Protocol + } + return nil +} + +func (m *Pool) GetUpgradePlan() *UpgradePlan { + if m != nil { + return m.UpgradePlan + } + return nil +} + +func (m *Pool) GetCurrentStorageProviderId() uint32 { + if m != nil { + return m.CurrentStorageProviderId + } + return 0 +} + +func (m *Pool) GetCurrentCompressionId() uint32 { + if m != nil { + return m.CurrentCompressionId + } + return 0 +} + +func init() { + // proto.RegisterEnum("kyve.pool.v1beta1.PoolStatus", PoolStatus_name, PoolStatus_value) + // proto.RegisterType((*Protocol)(nil), "kyve.pool.v1beta1.Protocol") + // proto.RegisterType((*UpgradePlan)(nil), "kyve.pool.v1beta1.UpgradePlan") + // proto.RegisterType((*Funder)(nil), "kyve.pool.v1beta1.Funder") + // proto.RegisterType((*Pool)(nil), "kyve.pool.v1beta1.Pool") +} + +func init() { proto.RegisterFile("kyve/pool/v1beta1/pool.proto", fileDescriptor_40c1730f47ff2ef8) } + +var fileDescriptor_40c1730f47ff2ef8 = []byte{ + // 818 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x94, 0x41, 0x6f, 0xdb, 0x36, + 0x14, 0xc7, 0xad, 0xc4, 0x75, 0x6c, 0x3a, 0x71, 0x5c, 0x2e, 0xcd, 0xd8, 0x64, 0xf0, 0xdc, 0x0c, + 0xdd, 0xbc, 0x1d, 0x6c, 0xb4, 0x1d, 0x30, 0x60, 0xc0, 0x0e, 0x8e, 0xed, 0x64, 0x42, 0x03, 0xdb, + 0x90, 0xed, 0x02, 0xdb, 0x45, 0xa0, 0x45, 0x56, 0x21, 0x22, 0x91, 0x02, 0x49, 0x79, 0x71, 0x8f, + 0x3b, 0xed, 0xb8, 0xef, 0xd0, 0xcf, 0xb1, 0xfb, 0x8e, 0x3d, 0xee, 0x38, 0x24, 0x5f, 0x64, 0x20, + 0x25, 0x79, 0xee, 0xd6, 0x53, 0x6f, 0x7c, 0xbf, 0xff, 0xff, 0xe9, 0x3d, 0xf3, 0xf1, 0x19, 0x7c, + 0x76, 0xb3, 0x5e, 0xd1, 0x5e, 0x22, 0x44, 0xd4, 0x5b, 0x3d, 0x5b, 0x52, 0x8d, 0x9f, 0xd9, 0xa0, + 0x9b, 0x48, 0xa1, 0x05, 0x7c, 0x68, 0xd4, 0xae, 0x05, 0xb9, 0x7a, 0x72, 0x14, 0x8a, 0x50, 0x58, + 0xb5, 0x67, 0x4e, 0x99, 0xf1, 0x2c, 0x00, 0xd5, 0xa9, 0x39, 0x04, 0x22, 0x82, 0x08, 0xec, 0xad, + 0xa8, 0x54, 0x4c, 0x70, 0xe4, 0xb4, 0x9d, 0x4e, 0xcd, 0x2b, 0x42, 0x78, 0x02, 0xaa, 0x4b, 0xc6, + 0xb1, 0x64, 0x54, 0xa1, 0x1d, 0x2b, 0x6d, 0x62, 0xf8, 0x04, 0xec, 0x47, 0x58, 0x69, 0x3f, 0x4d, + 0x42, 0x89, 0x09, 0x45, 0xbb, 0x6d, 0xa7, 0x53, 0xf6, 0xea, 0x86, 0x2d, 0x32, 0x74, 0xf6, 0xab, + 0x03, 0xea, 0xf9, 0x79, 0x1a, 0x61, 0xfe, 0xf1, 0x85, 0x54, 0x70, 0x4d, 0x49, 0x1a, 0x51, 0xe2, + 0x63, 0x5d, 0x14, 0xda, 0xb0, 0xbe, 0x36, 0xe9, 0x24, 0x95, 0x58, 0x9b, 0x2f, 0x97, 0xad, 0xbc, + 0x89, 0xcf, 0xbe, 0x07, 0x95, 0x8b, 0x94, 0x13, 0x2a, 0x4d, 0x79, 0x4c, 0x88, 0xa4, 0x4a, 0x15, + 0xe5, 0xf3, 0x10, 0x1e, 0x83, 0x0a, 0x8e, 0x45, 0xca, 0xb5, 0x2d, 0x5e, 0xf6, 0xf2, 0xe8, 0xec, + 0x6d, 0x05, 0x94, 0xa7, 0x42, 0x44, 0xb0, 0x01, 0x76, 0x18, 0xb1, 0x59, 0x65, 0x6f, 0x87, 0x11, + 0x08, 0x41, 0x99, 0xe3, 0x98, 0xe6, 0xbd, 0xda, 0xb3, 0xf9, 0xbc, 0x4c, 0xb9, 0x66, 0x71, 0x76, + 0x17, 0x35, 0xaf, 0x08, 0x8d, 0x3b, 0x12, 0xa1, 0xb0, 0xad, 0xd5, 0x3c, 0x7b, 0x36, 0x25, 0x03, + 0xc1, 0x5f, 0xb3, 0x10, 0x3d, 0xb0, 0x34, 0x8f, 0xe0, 0x29, 0xa8, 0x29, 0x8d, 0xa5, 0xf6, 0x6f, + 0xe8, 0x1a, 0x55, 0xb2, 0xab, 0xb0, 0xe0, 0x25, 0x5d, 0xc3, 0xcf, 0x41, 0x3d, 0x48, 0xa5, 0xa4, + 0x3c, 0x93, 0xf7, 0xac, 0x0c, 0x72, 0x64, 0x0c, 0x5f, 0x81, 0xc3, 0xc2, 0xa0, 0xd2, 0x38, 0xc6, + 0x72, 0x8d, 0xaa, 0xd6, 0xd4, 0xc8, 0xf1, 0x2c, 0xa3, 0xf0, 0x0b, 0x70, 0x50, 0x18, 0x19, 0x27, + 0xf4, 0x16, 0xd5, 0xec, 0x6f, 0xdb, 0xcf, 0xa1, 0x6b, 0x98, 0x31, 0x69, 0xa1, 0x71, 0xe4, 0x2f, + 0x53, 0x4e, 0x22, 0xaa, 0x10, 0xc8, 0x4c, 0x16, 0x9e, 0x67, 0xcc, 0x94, 0x4c, 0x93, 0x48, 0x60, + 0xe2, 0x33, 0xae, 0xa9, 0x5c, 0xe1, 0x08, 0xd5, 0xad, 0xad, 0x91, 0x61, 0x37, 0xa7, 0xf0, 0x29, + 0x68, 0x88, 0x84, 0x9a, 0xa9, 0xf0, 0xd0, 0x0f, 0x84, 0xd2, 0x68, 0xdf, 0xfa, 0x0e, 0x36, 0x74, + 0x20, 0x94, 0x36, 0xb6, 0x98, 0x71, 0x9f, 0xd0, 0x88, 0x86, 0xd9, 0x44, 0x0f, 0x32, 0x5b, 0xcc, + 0xf8, 0x70, 0x03, 0xe1, 0x97, 0xe0, 0x30, 0xc6, 0xb7, 0x79, 0x67, 0xbe, 0x62, 0x6f, 0x28, 0x6a, + 0xe4, 0x3e, 0x7c, 0x9b, 0xf5, 0x36, 0x63, 0x6f, 0xa8, 0x7d, 0x1a, 0x4c, 0xe1, 0x65, 0x44, 0x09, + 0x3a, 0x6c, 0x3b, 0x9d, 0xaa, 0xb7, 0x89, 0xe1, 0x0b, 0xb0, 0xf7, 0xda, 0x3e, 0x0d, 0x85, 0x9a, + 0xed, 0xdd, 0x4e, 0xfd, 0xf9, 0xe3, 0xee, 0xff, 0xf6, 0xa7, 0x9b, 0x3d, 0x1e, 0xaf, 0x70, 0x9a, + 0x19, 0x64, 0x97, 0x62, 0x80, 0x42, 0x0f, 0x6d, 0x51, 0x60, 0x91, 0xb1, 0x2a, 0xf8, 0x1d, 0xa8, + 0x26, 0xf9, 0x6a, 0x21, 0xd8, 0x76, 0x3a, 0xf5, 0xe7, 0xa7, 0x1f, 0xf8, 0x6c, 0xb1, 0x7d, 0xde, + 0xc6, 0x0c, 0xfb, 0x60, 0x3f, 0x5f, 0x26, 0x3f, 0x89, 0x30, 0x47, 0x9f, 0xd8, 0xe4, 0xd6, 0x07, + 0x92, 0xb7, 0x96, 0xca, 0xab, 0xa7, 0x5b, 0x1b, 0xf6, 0x03, 0x38, 0xdd, 0xcc, 0x5f, 0x0b, 0x89, + 0x43, 0xea, 0x27, 0x52, 0xac, 0x18, 0xa1, 0xd2, 0x67, 0x04, 0x1d, 0xb5, 0x9d, 0xce, 0x81, 0x87, + 0x8a, 0xb7, 0x90, 0x39, 0xa6, 0xb9, 0xc1, 0x25, 0xf0, 0x5b, 0x70, 0x5c, 0xa4, 0x07, 0x22, 0x4e, + 0xcc, 0x6e, 0x30, 0xc1, 0x4d, 0xe6, 0x23, 0x9b, 0x79, 0x94, 0xab, 0x83, 0x7f, 0x45, 0x97, 0x7c, + 0xf3, 0x87, 0x03, 0x80, 0xd9, 0x92, 0x99, 0xc6, 0x3a, 0x55, 0xf0, 0x14, 0x7c, 0x3a, 0x9d, 0x4c, + 0xae, 0xfc, 0xd9, 0xbc, 0x3f, 0x5f, 0xcc, 0xfc, 0xc5, 0x78, 0x36, 0x1d, 0x0d, 0xdc, 0x0b, 0x77, + 0x34, 0x6c, 0x96, 0xe0, 0x31, 0x80, 0xdb, 0x62, 0x7f, 0x30, 0x77, 0x5f, 0x8d, 0x9a, 0x0e, 0x44, + 0xe0, 0x68, 0x9b, 0x0f, 0xdd, 0x59, 0xff, 0xfc, 0x6a, 0x34, 0x6c, 0xee, 0xfc, 0x57, 0x19, 0x4f, + 0xfc, 0x8b, 0xc5, 0x78, 0x38, 0x6b, 0xee, 0xc2, 0xa7, 0xe0, 0xc9, 0xfb, 0xca, 0xdc, 0x1f, 0x8d, + 0x27, 0x8b, 0xcb, 0x1f, 0xfd, 0xe1, 0xe8, 0x6a, 0x74, 0xd9, 0x9f, 0xbb, 0x93, 0x71, 0xb3, 0x0c, + 0x1f, 0x83, 0x47, 0xef, 0xf5, 0x33, 0xbd, 0xf4, 0xfa, 0x43, 0x77, 0x7c, 0xd9, 0x7c, 0x70, 0x52, + 0xfe, 0xed, 0x6d, 0xab, 0x74, 0x3e, 0xf8, 0xf3, 0xae, 0xe5, 0xbc, 0xbb, 0x6b, 0x39, 0x7f, 0xdf, + 0xb5, 0x9c, 0xdf, 0xef, 0x5b, 0xa5, 0x77, 0xf7, 0xad, 0xd2, 0x5f, 0xf7, 0xad, 0xd2, 0xcf, 0x5f, + 0x87, 0x4c, 0x5f, 0xa7, 0xcb, 0x6e, 0x20, 0xe2, 0xde, 0xcb, 0x9f, 0x5e, 0x8d, 0xc6, 0x54, 0xff, + 0x22, 0xe4, 0x4d, 0x2f, 0xb8, 0xc6, 0x8c, 0xf7, 0x6e, 0xb3, 0xbf, 0x61, 0xbd, 0x4e, 0xa8, 0x5a, + 0x56, 0xec, 0x18, 0x5f, 0xfc, 0x13, 0x00, 0x00, 0xff, 0xff, 0xec, 0x2d, 0x4a, 0x94, 0xa0, 0x05, + 0x00, 0x00, +} + +func (m *Protocol) 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 *Protocol) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Protocol) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.LastUpgrade != 0 { + i = encodeVarintPool(dAtA, i, uint64(m.LastUpgrade)) + i-- + dAtA[i] = 0x18 + } + if len(m.Binaries) > 0 { + i -= len(m.Binaries) + copy(dAtA[i:], m.Binaries) + i = encodeVarintPool(dAtA, i, uint64(len(m.Binaries))) + i-- + dAtA[i] = 0x12 + } + if len(m.Version) > 0 { + i -= len(m.Version) + copy(dAtA[i:], m.Version) + i = encodeVarintPool(dAtA, i, uint64(len(m.Version))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *UpgradePlan) 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 *UpgradePlan) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *UpgradePlan) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Duration != 0 { + i = encodeVarintPool(dAtA, i, uint64(m.Duration)) + i-- + dAtA[i] = 0x20 + } + if m.ScheduledAt != 0 { + i = encodeVarintPool(dAtA, i, uint64(m.ScheduledAt)) + i-- + dAtA[i] = 0x18 + } + if len(m.Binaries) > 0 { + i -= len(m.Binaries) + copy(dAtA[i:], m.Binaries) + i = encodeVarintPool(dAtA, i, uint64(len(m.Binaries))) + i-- + dAtA[i] = 0x12 + } + if len(m.Version) > 0 { + i -= len(m.Version) + copy(dAtA[i:], m.Version) + i = encodeVarintPool(dAtA, i, uint64(len(m.Version))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *Funder) 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 *Funder) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Funder) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Amount != 0 { + i = encodeVarintPool(dAtA, i, uint64(m.Amount)) + i-- + dAtA[i] = 0x10 + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintPool(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *Pool) 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 *Pool) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Pool) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.CurrentCompressionId != 0 { + i = encodeVarintPool(dAtA, i, uint64(m.CurrentCompressionId)) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0xa8 + } + if m.CurrentStorageProviderId != 0 { + i = encodeVarintPool(dAtA, i, uint64(m.CurrentStorageProviderId)) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0xa0 + } + if m.UpgradePlan != nil { + { + size, err := m.UpgradePlan.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintPool(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x9a + } + if m.Protocol != nil { + { + size, err := m.Protocol.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintPool(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x92 + } + if m.TotalFunds != 0 { + i = encodeVarintPool(dAtA, i, uint64(m.TotalFunds)) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x88 + } + if len(m.Funders) > 0 { + for iNdEx := len(m.Funders) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Funders[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintPool(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x82 + } + } + if m.Disabled { + i-- + if m.Disabled { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x78 + } + if m.MaxBundleSize != 0 { + i = encodeVarintPool(dAtA, i, uint64(m.MaxBundleSize)) + i-- + dAtA[i] = 0x70 + } + if m.MinDelegation != 0 { + i = encodeVarintPool(dAtA, i, uint64(m.MinDelegation)) + i-- + dAtA[i] = 0x68 + } + if m.OperatingCost != 0 { + i = encodeVarintPool(dAtA, i, uint64(m.OperatingCost)) + i-- + dAtA[i] = 0x60 + } + if m.UploadInterval != 0 { + i = encodeVarintPool(dAtA, i, uint64(m.UploadInterval)) + i-- + dAtA[i] = 0x58 + } + if m.TotalBundles != 0 { + i = encodeVarintPool(dAtA, i, uint64(m.TotalBundles)) + i-- + dAtA[i] = 0x50 + } + if m.CurrentIndex != 0 { + i = encodeVarintPool(dAtA, i, uint64(m.CurrentIndex)) + i-- + dAtA[i] = 0x48 + } + if len(m.CurrentSummary) > 0 { + i -= len(m.CurrentSummary) + copy(dAtA[i:], m.CurrentSummary) + i = encodeVarintPool(dAtA, i, uint64(len(m.CurrentSummary))) + i-- + dAtA[i] = 0x42 + } + if len(m.CurrentKey) > 0 { + i -= len(m.CurrentKey) + copy(dAtA[i:], m.CurrentKey) + i = encodeVarintPool(dAtA, i, uint64(len(m.CurrentKey))) + i-- + dAtA[i] = 0x3a + } + if len(m.StartKey) > 0 { + i -= len(m.StartKey) + copy(dAtA[i:], m.StartKey) + i = encodeVarintPool(dAtA, i, uint64(len(m.StartKey))) + i-- + dAtA[i] = 0x32 + } + if len(m.Config) > 0 { + i -= len(m.Config) + copy(dAtA[i:], m.Config) + i = encodeVarintPool(dAtA, i, uint64(len(m.Config))) + i-- + dAtA[i] = 0x2a + } + if len(m.Logo) > 0 { + i -= len(m.Logo) + copy(dAtA[i:], m.Logo) + i = encodeVarintPool(dAtA, i, uint64(len(m.Logo))) + i-- + dAtA[i] = 0x22 + } + if len(m.Runtime) > 0 { + i -= len(m.Runtime) + copy(dAtA[i:], m.Runtime) + i = encodeVarintPool(dAtA, i, uint64(len(m.Runtime))) + i-- + dAtA[i] = 0x1a + } + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintPool(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0x12 + } + if m.Id != 0 { + i = encodeVarintPool(dAtA, i, uint64(m.Id)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintPool(dAtA []byte, offset int, v uint64) int { + offset -= sovPool(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} + +func (m *Protocol) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Version) + if l > 0 { + n += 1 + l + sovPool(uint64(l)) + } + l = len(m.Binaries) + if l > 0 { + n += 1 + l + sovPool(uint64(l)) + } + if m.LastUpgrade != 0 { + n += 1 + sovPool(uint64(m.LastUpgrade)) + } + return n +} + +func (m *UpgradePlan) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Version) + if l > 0 { + n += 1 + l + sovPool(uint64(l)) + } + l = len(m.Binaries) + if l > 0 { + n += 1 + l + sovPool(uint64(l)) + } + if m.ScheduledAt != 0 { + n += 1 + sovPool(uint64(m.ScheduledAt)) + } + if m.Duration != 0 { + n += 1 + sovPool(uint64(m.Duration)) + } + return n +} + +func (m *Funder) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovPool(uint64(l)) + } + if m.Amount != 0 { + n += 1 + sovPool(uint64(m.Amount)) + } + return n +} + +func (m *Pool) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Id != 0 { + n += 1 + sovPool(uint64(m.Id)) + } + l = len(m.Name) + if l > 0 { + n += 1 + l + sovPool(uint64(l)) + } + l = len(m.Runtime) + if l > 0 { + n += 1 + l + sovPool(uint64(l)) + } + l = len(m.Logo) + if l > 0 { + n += 1 + l + sovPool(uint64(l)) + } + l = len(m.Config) + if l > 0 { + n += 1 + l + sovPool(uint64(l)) + } + l = len(m.StartKey) + if l > 0 { + n += 1 + l + sovPool(uint64(l)) + } + l = len(m.CurrentKey) + if l > 0 { + n += 1 + l + sovPool(uint64(l)) + } + l = len(m.CurrentSummary) + if l > 0 { + n += 1 + l + sovPool(uint64(l)) + } + if m.CurrentIndex != 0 { + n += 1 + sovPool(uint64(m.CurrentIndex)) + } + if m.TotalBundles != 0 { + n += 1 + sovPool(uint64(m.TotalBundles)) + } + if m.UploadInterval != 0 { + n += 1 + sovPool(uint64(m.UploadInterval)) + } + if m.OperatingCost != 0 { + n += 1 + sovPool(uint64(m.OperatingCost)) + } + if m.MinDelegation != 0 { + n += 1 + sovPool(uint64(m.MinDelegation)) + } + if m.MaxBundleSize != 0 { + n += 1 + sovPool(uint64(m.MaxBundleSize)) + } + if m.Disabled { + n += 2 + } + if len(m.Funders) > 0 { + for _, e := range m.Funders { + l = e.Size() + n += 2 + l + sovPool(uint64(l)) + } + } + if m.TotalFunds != 0 { + n += 2 + sovPool(uint64(m.TotalFunds)) + } + if m.Protocol != nil { + l = m.Protocol.Size() + n += 2 + l + sovPool(uint64(l)) + } + if m.UpgradePlan != nil { + l = m.UpgradePlan.Size() + n += 2 + l + sovPool(uint64(l)) + } + if m.CurrentStorageProviderId != 0 { + n += 2 + sovPool(uint64(m.CurrentStorageProviderId)) + } + if m.CurrentCompressionId != 0 { + n += 2 + sovPool(uint64(m.CurrentCompressionId)) + } + return n +} + +func sovPool(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} + +func sozPool(x uint64) (n int) { + return sovPool(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} + +func (m *Protocol) 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 ErrIntOverflowPool + } + 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: Protocol: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Protocol: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Version", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthPool + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPool + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Version = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Binaries", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthPool + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPool + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Binaries = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field LastUpgrade", wireType) + } + m.LastUpgrade = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.LastUpgrade |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipPool(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthPool + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} + +func (m *UpgradePlan) 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 ErrIntOverflowPool + } + 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: UpgradePlan: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: UpgradePlan: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Version", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthPool + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPool + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Version = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Binaries", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthPool + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPool + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Binaries = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ScheduledAt", wireType) + } + m.ScheduledAt = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ScheduledAt |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Duration", wireType) + } + m.Duration = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Duration |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipPool(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthPool + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} + +func (m *Funder) 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 ErrIntOverflowPool + } + 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: Funder: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Funder: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthPool + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPool + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + m.Amount = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Amount |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipPool(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthPool + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} + +func (m *Pool) 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 ErrIntOverflowPool + } + 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: Pool: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Pool: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) + } + m.Id = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Id |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthPool + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPool + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Runtime", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthPool + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPool + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Runtime = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Logo", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthPool + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPool + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Logo = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Config", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthPool + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPool + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Config = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StartKey", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthPool + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPool + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.StartKey = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CurrentKey", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthPool + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPool + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.CurrentKey = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CurrentSummary", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthPool + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPool + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.CurrentSummary = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 9: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CurrentIndex", wireType) + } + m.CurrentIndex = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CurrentIndex |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 10: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field TotalBundles", wireType) + } + m.TotalBundles = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.TotalBundles |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 11: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field UploadInterval", wireType) + } + m.UploadInterval = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.UploadInterval |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 12: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field OperatingCost", wireType) + } + m.OperatingCost = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.OperatingCost |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 13: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MinDelegation", wireType) + } + m.MinDelegation = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MinDelegation |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 14: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MaxBundleSize", wireType) + } + m.MaxBundleSize = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MaxBundleSize |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 15: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Disabled", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Disabled = bool(v != 0) + case 16: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Funders", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthPool + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthPool + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Funders = append(m.Funders, &Funder{}) + if err := m.Funders[len(m.Funders)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 17: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field TotalFunds", wireType) + } + m.TotalFunds = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.TotalFunds |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 18: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Protocol", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthPool + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthPool + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Protocol == nil { + m.Protocol = &Protocol{} + } + if err := m.Protocol.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 19: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field UpgradePlan", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthPool + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthPool + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.UpgradePlan == nil { + m.UpgradePlan = &UpgradePlan{} + } + if err := m.UpgradePlan.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 20: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CurrentStorageProviderId", wireType) + } + m.CurrentStorageProviderId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CurrentStorageProviderId |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 21: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CurrentCompressionId", wireType) + } + m.CurrentCompressionId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CurrentCompressionId |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipPool(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthPool + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} + +func skipPool(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, ErrIntOverflowPool + } + 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, ErrIntOverflowPool + } + 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, ErrIntOverflowPool + } + 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, ErrInvalidLengthPool + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupPool + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthPool + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthPool = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowPool = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupPool = fmt.Errorf("proto: unexpected end of group") +) diff --git a/config.yml b/config.yml index a2ef69a8..c523cf25 100644 --- a/config.yml +++ b/config.yml @@ -31,17 +31,17 @@ accounts: - 1000000000000000tkyve mnemonic: open home share route party lake room solution quantum pact model avocado humor dilemma review desert turtle total humor produce rate keen eagle fee -# - name: team -# coins: -# - 165000000000000tkyve -# address: kyve1e29j95xmsw3zmvtrk4st8e89z5n72v7nf70ma4 + # - name: team + # coins: + # - 165000000000000tkyve + # address: kyve1e29j95xmsw3zmvtrk4st8e89z5n72v7nf70ma4 - name: foundation coins: # for fees - 1000000tkyve mnemonic: evidence taxi material cabin annual phrase practice unhappy safe jealous section drink illness panther bread aim mouse dolphin deliver ready doll finger search cheap -# address: kyve1fd4qu868n7arav8vteghcppxxa0p2vna5f5ep8 + # address: kyve1fd4qu868n7arav8vteghcppxxa0p2vna5f5ep8 - name: foundation_inflation coins: # for fees @@ -66,6 +66,10 @@ genesis: coins: - denom: "tkyve" amount: "165000000000000000" + - address: "kyve1vg5325u5mat0y44g73n8t8z2le26fsa4n947f5" # funders module (funding from Alice) + coins: + - denom: "tkyve" + amount: "1001234" delegation: params: unbonding_delegation_time: 10 @@ -130,7 +134,7 @@ genesis: pool: params: protocol_inflation_share: "0.04" - pool_count: "1" + pool_count: "2" pool_list: - config: "{\"network\":\"kyve-1\",\"rpc\":\"https://rpc-eu-1.kyve.network\"}" current_compression_id: "1" @@ -138,18 +142,42 @@ genesis: current_key: "" current_storage_provider_id: "1" current_summary: "" - funders: [] id: "0" logo: "" max_bundle_size: "100" min_delegation: "100000000000" name: "KYVE // Mainnet" - operating_cost: "2500000000" + inflation_share_weight: "2500000000" + disabled: false + runtime: '@kyvejs/tendermint-bsync' + start_key: "1" + total_bundles: "0" + upload_interval: "60" + protocol: + version: "1.0.0" + binaries: "{\"kyve-linux-arm64\":\"https://github.com/KYVENetwork/kyvejs/releases/download/%40kyvejs%2Ftendermint-bsync%401.0.0/kyve-linux-arm64.zip\",\"kyve-linux-x64\":\"https://github.com/KYVENetwork/kyvejs/releases/download/%40kyvejs%2Ftendermint-bsync%401.0.0/kyve-linux-x64.zip\",\"kyve-macos-x64\":\"https://github.com/KYVENetwork/kyvejs/releases/download/%40kyvejs%2Ftendermint-bsync%401.0.0/kyve-macos-x64.zip\"}" + last_upgrade: "0" + upgrade_plan: + version: "" + binaries: "" + scheduled_at: "0" + duration: "0" + - config: "{\"network\":\"kyve-1\",\"rpc\":\"https://rpc-eu-1.kyve.network\"}" + current_compression_id: "1" + current_index: "0" + current_key: "" + current_storage_provider_id: "1" + current_summary: "" + id: "1" + logo: "" + max_bundle_size: "100" + min_delegation: "100000000000" + name: "KYVE // Blub" + inflation_share_weight: "2500000000" disabled: false runtime: '@kyvejs/tendermint-bsync' start_key: "1" total_bundles: "0" - total_funds: "0" upload_interval: "60" protocol: version: "1.0.0" @@ -166,6 +194,44 @@ genesis: staking: params: bond_denom: tkyve + funders: + params: + min_funding_amount: 1000000000 + min_funding_amount_per_bundle: 10000000 + funder_list: + - address: "kyve1jq304cthpx0lwhpqzrdjrcza559ukyy3zsl2vd" + contact: "https://twitter.com/kyvenetwork" + moniker: "Alice" + description: "Alice is the first funder of the KYVE network." + website: "https://kyve.network" + identity: "0657A086E5201562" + - address: "kyve1ze3ncmkvat3t2mcj9e3uy8uktat4fq2vltcnat" + contact: "https://twitter.com/kyvenetwork" + moniker: "Otto" + description: "Another funder of the KYVE network." + website: "https://ot.to" + identity: "0657A086E5201562" + funding_list: + - pool_id: 0 + funder_address: "kyve1jq304cthpx0lwhpqzrdjrcza559ukyy3zsl2vd" + amount: 5000000000000 + amount_per_bundle: 230000000 + total_funded: 2200400000000 + - pool_id: 0 + funder_address: "kyve1ze3ncmkvat3t2mcj9e3uy8uktat4fq2vltcnat" + amount: 200000000000 + amount_per_bundle: 20000000 + total_funded: 64500000000 + - pool_id: 1 + funder_address: "kyve1ze3ncmkvat3t2mcj9e3uy8uktat4fq2vltcnat" + amount: 100000000000 + amount_per_bundle: 10000000 + total_funded: 23000000000 + funding_state_list: + - pool_id: 0 + active_funder_addresses: ["kyve1jq304cthpx0lwhpqzrdjrcza559ukyy3zsl2vd", "kyve1ze3ncmkvat3t2mcj9e3uy8uktat4fq2vltcnat"] + - pool_id: 1 + active_funder_addresses: ["kyve1ze3ncmkvat3t2mcj9e3uy8uktat4fq2vltcnat"] chain_id: kyve-local validators: - name: alice @@ -173,4 +239,4 @@ validators: config: consensus: timeout_commit: "2s" - timeout_propose: "2s" + timeout_propose: "2s" \ No newline at end of file diff --git a/docs/config.json b/docs/config.json index 3ef0f89d..40381d27 100644 --- a/docs/config.json +++ b/docs/config.json @@ -66,6 +66,9 @@ { "url": "./tmp-swagger-gen/kyve/query/v1beta1/stakers.swagger.json" }, + { + "url": "./tmp-swagger-gen/kyve/query/v1beta1/funders.swagger.json" + }, { "url": "./tmp-swagger-gen/kyve/stakers/v1beta1/query.swagger.json", "operationIds": { diff --git a/docs/swagger.yml b/docs/swagger.yml index f175be1e..1e81aabf 100644 --- a/docs/swagger.yml +++ b/docs/swagger.yml @@ -346,7 +346,10 @@ paths: protobuf release, and it is not used for type URLs beginning with - type.googleapis.com. + type.googleapis.com. As of May 2023, there are no widely + used type server + + implementations and no plans to implement one. Schemes other than `http`, `https` (or the empty scheme) @@ -396,7 +399,7 @@ paths: foo = any.unpack(Foo.getDefaultInstance()); } - Example 3: Pack and unpack a message in Python. + Example 3: Pack and unpack a message in Python. foo = Foo(...) any = Any() @@ -406,7 +409,7 @@ paths: any.Unpack(foo) ... - Example 4: Pack and unpack a message in Go + Example 4: Pack and unpack a message in Go foo := &pb.Foo{...} any, err := anypb.New(foo) @@ -436,6 +439,7 @@ paths: JSON + ==== The JSON representation of an `Any` value uses the regular @@ -647,12 +651,12 @@ paths: logo: type: string title: logo of the pool - operating_cost: + inflation_share_weight: type: string format: uint64 title: >- - operating_cost is the base payout for each - bundle reward + inflation_share_weight is the base payout + for each bundle reward upload_interval: type: string format: uint64 @@ -824,7 +828,10 @@ paths: protobuf release, and it is not used for type URLs beginning with - type.googleapis.com. + type.googleapis.com. As of May 2023, there are no widely + used type server + + implementations and no plans to implement one. Schemes other than `http`, `https` (or the empty scheme) @@ -874,7 +881,7 @@ paths: foo = any.unpack(Foo.getDefaultInstance()); } - Example 3: Pack and unpack a message in Python. + Example 3: Pack and unpack a message in Python. foo = Foo(...) any = Any() @@ -884,7 +891,7 @@ paths: any.Unpack(foo) ... - Example 4: Pack and unpack a message in Go + Example 4: Pack and unpack a message in Go foo := &pb.Foo{...} any, err := anypb.New(foo) @@ -914,6 +921,7 @@ paths: JSON + ==== The JSON representation of an `Any` value uses the regular @@ -1052,12 +1060,12 @@ paths: logo: type: string title: logo of the pool - operating_cost: + inflation_share_weight: type: string format: uint64 title: >- - operating_cost is the base payout for each bundle - reward + inflation_share_weight is the base payout for each + bundle reward upload_interval: type: string format: uint64 @@ -1164,7 +1172,10 @@ paths: protobuf release, and it is not used for type URLs beginning with - type.googleapis.com. + type.googleapis.com. As of May 2023, there are no widely + used type server + + implementations and no plans to implement one. Schemes other than `http`, `https` (or the empty scheme) @@ -1214,7 +1225,7 @@ paths: foo = any.unpack(Foo.getDefaultInstance()); } - Example 3: Pack and unpack a message in Python. + Example 3: Pack and unpack a message in Python. foo = Foo(...) any = Any() @@ -1224,7 +1235,7 @@ paths: any.Unpack(foo) ... - Example 4: Pack and unpack a message in Go + Example 4: Pack and unpack a message in Go foo := &pb.Foo{...} any, err := anypb.New(foo) @@ -1254,6 +1265,7 @@ paths: JSON + ==== The JSON representation of an `Any` value uses the regular @@ -1398,7 +1410,10 @@ paths: protobuf release, and it is not used for type URLs beginning with - type.googleapis.com. + type.googleapis.com. As of May 2023, there are no widely + used type server + + implementations and no plans to implement one. Schemes other than `http`, `https` (or the empty scheme) @@ -1448,7 +1463,7 @@ paths: foo = any.unpack(Foo.getDefaultInstance()); } - Example 3: Pack and unpack a message in Python. + Example 3: Pack and unpack a message in Python. foo = Foo(...) any = Any() @@ -1458,7 +1473,7 @@ paths: any.Unpack(foo) ... - Example 4: Pack and unpack a message in Go + Example 4: Pack and unpack a message in Go foo := &pb.Foo{...} any, err := anypb.New(foo) @@ -1488,6 +1503,7 @@ paths: JSON + ==== The JSON representation of an `Any` value uses the regular @@ -1619,7 +1635,10 @@ paths: protobuf release, and it is not used for type URLs beginning with - type.googleapis.com. + type.googleapis.com. As of May 2023, there are no widely + used type server + + implementations and no plans to implement one. Schemes other than `http`, `https` (or the empty scheme) @@ -1669,7 +1688,7 @@ paths: foo = any.unpack(Foo.getDefaultInstance()); } - Example 3: Pack and unpack a message in Python. + Example 3: Pack and unpack a message in Python. foo = Foo(...) any = Any() @@ -1679,7 +1698,7 @@ paths: any.Unpack(foo) ... - Example 4: Pack and unpack a message in Go + Example 4: Pack and unpack a message in Go foo := &pb.Foo{...} any, err := anypb.New(foo) @@ -1709,6 +1728,7 @@ paths: JSON + ==== The JSON representation of an `Any` value uses the regular @@ -1857,7 +1877,10 @@ paths: protobuf release, and it is not used for type URLs beginning with - type.googleapis.com. + type.googleapis.com. As of May 2023, there are no widely + used type server + + implementations and no plans to implement one. Schemes other than `http`, `https` (or the empty scheme) @@ -1907,7 +1930,7 @@ paths: foo = any.unpack(Foo.getDefaultInstance()); } - Example 3: Pack and unpack a message in Python. + Example 3: Pack and unpack a message in Python. foo = Foo(...) any = Any() @@ -1917,7 +1940,7 @@ paths: any.Unpack(foo) ... - Example 4: Pack and unpack a message in Go + Example 4: Pack and unpack a message in Go foo := &pb.Foo{...} any, err := anypb.New(foo) @@ -1947,6 +1970,7 @@ paths: JSON + ==== The JSON representation of an `Any` value uses the regular @@ -2084,7 +2108,10 @@ paths: protobuf release, and it is not used for type URLs beginning with - type.googleapis.com. + type.googleapis.com. As of May 2023, there are no widely + used type server + + implementations and no plans to implement one. Schemes other than `http`, `https` (or the empty scheme) @@ -2134,7 +2161,7 @@ paths: foo = any.unpack(Foo.getDefaultInstance()); } - Example 3: Pack and unpack a message in Python. + Example 3: Pack and unpack a message in Python. foo = Foo(...) any = Any() @@ -2144,7 +2171,7 @@ paths: any.Unpack(foo) ... - Example 4: Pack and unpack a message in Go + Example 4: Pack and unpack a message in Go foo := &pb.Foo{...} any, err := anypb.New(foo) @@ -2174,6 +2201,7 @@ paths: JSON + ==== The JSON representation of an `Any` value uses the regular @@ -2331,7 +2359,10 @@ paths: protobuf release, and it is not used for type URLs beginning with - type.googleapis.com. + type.googleapis.com. As of May 2023, there are no widely + used type server + + implementations and no plans to implement one. Schemes other than `http`, `https` (or the empty scheme) @@ -2381,7 +2412,7 @@ paths: foo = any.unpack(Foo.getDefaultInstance()); } - Example 3: Pack and unpack a message in Python. + Example 3: Pack and unpack a message in Python. foo = Foo(...) any = Any() @@ -2391,7 +2422,7 @@ paths: any.Unpack(foo) ... - Example 4: Pack and unpack a message in Go + Example 4: Pack and unpack a message in Go foo := &pb.Foo{...} any, err := anypb.New(foo) @@ -2421,6 +2452,7 @@ paths: JSON + ==== The JSON representation of an `Any` value uses the regular @@ -2672,7 +2704,10 @@ paths: protobuf release, and it is not used for type URLs beginning with - type.googleapis.com. + type.googleapis.com. As of May 2023, there are no widely + used type server + + implementations and no plans to implement one. Schemes other than `http`, `https` (or the empty scheme) @@ -2722,7 +2757,7 @@ paths: foo = any.unpack(Foo.getDefaultInstance()); } - Example 3: Pack and unpack a message in Python. + Example 3: Pack and unpack a message in Python. foo = Foo(...) any = Any() @@ -2732,7 +2767,7 @@ paths: any.Unpack(foo) ... - Example 4: Pack and unpack a message in Go + Example 4: Pack and unpack a message in Go foo := &pb.Foo{...} any, err := anypb.New(foo) @@ -2762,6 +2797,7 @@ paths: JSON + ==== The JSON representation of an `Any` value uses the regular @@ -3047,7 +3083,10 @@ paths: protobuf release, and it is not used for type URLs beginning with - type.googleapis.com. + type.googleapis.com. As of May 2023, there are no widely + used type server + + implementations and no plans to implement one. Schemes other than `http`, `https` (or the empty scheme) @@ -3097,7 +3136,7 @@ paths: foo = any.unpack(Foo.getDefaultInstance()); } - Example 3: Pack and unpack a message in Python. + Example 3: Pack and unpack a message in Python. foo = Foo(...) any = Any() @@ -3107,7 +3146,7 @@ paths: any.Unpack(foo) ... - Example 4: Pack and unpack a message in Go + Example 4: Pack and unpack a message in Go foo := &pb.Foo{...} any, err := anypb.New(foo) @@ -3137,6 +3176,7 @@ paths: JSON + ==== The JSON representation of an `Any` value uses the regular @@ -3289,7 +3329,10 @@ paths: protobuf release, and it is not used for type URLs beginning with - type.googleapis.com. + type.googleapis.com. As of May 2023, there are no widely + used type server + + implementations and no plans to implement one. Schemes other than `http`, `https` (or the empty scheme) @@ -3339,7 +3382,7 @@ paths: foo = any.unpack(Foo.getDefaultInstance()); } - Example 3: Pack and unpack a message in Python. + Example 3: Pack and unpack a message in Python. foo = Foo(...) any = Any() @@ -3349,7 +3392,7 @@ paths: any.Unpack(foo) ... - Example 4: Pack and unpack a message in Go + Example 4: Pack and unpack a message in Go foo := &pb.Foo{...} any, err := anypb.New(foo) @@ -3379,6 +3422,7 @@ paths: JSON + ==== The JSON representation of an `Any` value uses the regular @@ -3559,7 +3603,10 @@ paths: protobuf release, and it is not used for type URLs beginning with - type.googleapis.com. + type.googleapis.com. As of May 2023, there are no widely + used type server + + implementations and no plans to implement one. Schemes other than `http`, `https` (or the empty scheme) @@ -3609,7 +3656,7 @@ paths: foo = any.unpack(Foo.getDefaultInstance()); } - Example 3: Pack and unpack a message in Python. + Example 3: Pack and unpack a message in Python. foo = Foo(...) any = Any() @@ -3619,7 +3666,7 @@ paths: any.Unpack(foo) ... - Example 4: Pack and unpack a message in Go + Example 4: Pack and unpack a message in Go foo := &pb.Foo{...} any, err := anypb.New(foo) @@ -3649,6 +3696,7 @@ paths: JSON + ==== The JSON representation of an `Any` value uses the regular @@ -3915,12 +3963,12 @@ paths: logo: type: string title: logo of the pool - operating_cost: + inflation_share_weight: type: string format: uint64 title: >- - operating_cost is the base payout for each - bundle reward + inflation_share_weight is the base payout + for each bundle reward upload_interval: type: string format: uint64 @@ -4104,7 +4152,10 @@ paths: protobuf release, and it is not used for type URLs beginning with - type.googleapis.com. + type.googleapis.com. As of May 2023, there are no widely + used type server + + implementations and no plans to implement one. Schemes other than `http`, `https` (or the empty scheme) @@ -4154,7 +4205,7 @@ paths: foo = any.unpack(Foo.getDefaultInstance()); } - Example 3: Pack and unpack a message in Python. + Example 3: Pack and unpack a message in Python. foo = Foo(...) any = Any() @@ -4164,7 +4215,7 @@ paths: any.Unpack(foo) ... - Example 4: Pack and unpack a message in Go + Example 4: Pack and unpack a message in Go foo := &pb.Foo{...} any, err := anypb.New(foo) @@ -4194,6 +4245,7 @@ paths: JSON + ==== The JSON representation of an `Any` value uses the regular @@ -4509,6 +4561,29 @@ paths: pool_inflation_payout_rate: type: string description: pool_inflation_payout_rate ... + funders_params: + description: funders_params ... + type: object + properties: + min_funding_amount: + type: string + format: uint64 + description: Minimum amount of tokens that can be funded. + min_funding_amount_per_bundle: + type: string + format: uint64 + description: Minimum amount of tokens that can be funded per bundle. + min_funding_multiple: + type: string + format: uint64 + description: >- + Minimum ratio between the funded amount and the + amount_per_bundle. + + In other words this param ensures, that a funder provides + at least funding for + + `min_funding_multiple` bundles. description: QueryParamsResponse ... default: description: An unexpected error response. @@ -4578,7 +4653,10 @@ paths: protobuf release, and it is not used for type URLs beginning with - type.googleapis.com. + type.googleapis.com. As of May 2023, there are no widely + used type server + + implementations and no plans to implement one. Schemes other than `http`, `https` (or the empty scheme) @@ -4628,7 +4706,7 @@ paths: foo = any.unpack(Foo.getDefaultInstance()); } - Example 3: Pack and unpack a message in Python. + Example 3: Pack and unpack a message in Python. foo = Foo(...) any = Any() @@ -4638,7 +4716,7 @@ paths: any.Unpack(foo) ... - Example 4: Pack and unpack a message in Go + Example 4: Pack and unpack a message in Go foo := &pb.Foo{...} any, err := anypb.New(foo) @@ -4668,6 +4746,7 @@ paths: JSON + ==== The JSON representation of an `Any` value uses the regular @@ -4771,10 +4850,10 @@ paths: type: string format: uint64 description: upload_interval ... - operating_cost: + inflation_share_weight: type: string format: uint64 - description: operating_cost ... + description: inflation_share_weight ... min_delegation: type: string format: uint64 @@ -4788,30 +4867,6 @@ paths: description: |- disabled is true when the pool is disabled. Can only be done via governance. - funders: - type: array - items: - type: object - properties: - address: - type: string - title: address is the address of the funder - amount: - type: string - format: uint64 - title: >- - amount is the current amount of funds in ukyve - the funder has - - still funded the pool with - title: >- - Funder is the object which holds info about a single - pool funder - description: funders ... - total_funds: - type: string - format: uint64 - description: total_funds ... protocol: description: protocol ... type: object @@ -5082,7 +5137,10 @@ paths: protobuf release, and it is not used for type URLs beginning with - type.googleapis.com. + type.googleapis.com. As of May 2023, there are no widely + used type server + + implementations and no plans to implement one. Schemes other than `http`, `https` (or the empty scheme) @@ -5132,7 +5190,7 @@ paths: foo = any.unpack(Foo.getDefaultInstance()); } - Example 3: Pack and unpack a message in Python. + Example 3: Pack and unpack a message in Python. foo = Foo(...) any = Any() @@ -5142,7 +5200,7 @@ paths: any.Unpack(foo) ... - Example 4: Pack and unpack a message in Go + Example 4: Pack and unpack a message in Go foo := &pb.Foo{...} any, err := anypb.New(foo) @@ -5172,6 +5230,7 @@ paths: JSON + ==== The JSON representation of an `Any` value uses the regular @@ -5288,10 +5347,10 @@ paths: type: string format: uint64 description: upload_interval ... - operating_cost: + inflation_share_weight: type: string format: uint64 - description: operating_cost ... + description: inflation_share_weight ... min_delegation: type: string format: uint64 @@ -5305,30 +5364,6 @@ paths: description: |- disabled is true when the pool is disabled. Can only be done via governance. - funders: - type: array - items: - type: object - properties: - address: - type: string - title: address is the address of the funder - amount: - type: string - format: uint64 - title: >- - amount is the current amount of funds in ukyve - the funder has - - still funded the pool with - title: >- - Funder is the object which holds info about a - single pool funder - description: funders ... - total_funds: - type: string - format: uint64 - description: total_funds ... protocol: description: protocol ... type: object @@ -5620,7 +5655,10 @@ paths: protobuf release, and it is not used for type URLs beginning with - type.googleapis.com. + type.googleapis.com. As of May 2023, there are no widely + used type server + + implementations and no plans to implement one. Schemes other than `http`, `https` (or the empty scheme) @@ -5670,7 +5708,7 @@ paths: foo = any.unpack(Foo.getDefaultInstance()); } - Example 3: Pack and unpack a message in Python. + Example 3: Pack and unpack a message in Python. foo = Foo(...) any = Any() @@ -5680,7 +5718,7 @@ paths: any.Unpack(foo) ... - Example 4: Pack and unpack a message in Go + Example 4: Pack and unpack a message in Go foo := &pb.Foo{...} any, err := anypb.New(foo) @@ -5710,6 +5748,7 @@ paths: JSON + ==== The JSON representation of an `Any` value uses the regular @@ -5963,12 +6002,12 @@ paths: logo: type: string title: logo of the pool - operating_cost: + inflation_share_weight: type: string format: uint64 title: >- - operating_cost is the base payout for each - bundle reward + inflation_share_weight is the base payout for + each bundle reward upload_interval: type: string format: uint64 @@ -6118,7 +6157,10 @@ paths: protobuf release, and it is not used for type URLs beginning with - type.googleapis.com. + type.googleapis.com. As of May 2023, there are no widely + used type server + + implementations and no plans to implement one. Schemes other than `http`, `https` (or the empty scheme) @@ -6168,7 +6210,7 @@ paths: foo = any.unpack(Foo.getDefaultInstance()); } - Example 3: Pack and unpack a message in Python. + Example 3: Pack and unpack a message in Python. foo = Foo(...) any = Any() @@ -6178,7 +6220,7 @@ paths: any.Unpack(foo) ... - Example 4: Pack and unpack a message in Go + Example 4: Pack and unpack a message in Go foo := &pb.Foo{...} any, err := anypb.New(foo) @@ -6208,6 +6250,7 @@ paths: JSON + ==== The JSON representation of an `Any` value uses the regular @@ -6393,12 +6436,12 @@ paths: logo: type: string title: logo of the pool - operating_cost: + inflation_share_weight: type: string format: uint64 title: >- - operating_cost is the base payout for each - bundle reward + inflation_share_weight is the base payout for + each bundle reward upload_interval: type: string format: uint64 @@ -6568,7 +6611,10 @@ paths: protobuf release, and it is not used for type URLs beginning with - type.googleapis.com. + type.googleapis.com. As of May 2023, there are no widely + used type server + + implementations and no plans to implement one. Schemes other than `http`, `https` (or the empty scheme) @@ -6618,7 +6664,7 @@ paths: foo = any.unpack(Foo.getDefaultInstance()); } - Example 3: Pack and unpack a message in Python. + Example 3: Pack and unpack a message in Python. foo = Foo(...) any = Any() @@ -6628,7 +6674,7 @@ paths: any.Unpack(foo) ... - Example 4: Pack and unpack a message in Go + Example 4: Pack and unpack a message in Go foo := &pb.Foo{...} any, err := anypb.New(foo) @@ -6658,6 +6704,7 @@ paths: JSON + ==== The JSON representation of an `Any` value uses the regular @@ -6933,12 +6980,12 @@ paths: logo: type: string title: logo of the pool - operating_cost: + inflation_share_weight: type: string format: uint64 title: >- - operating_cost is the base payout for each - bundle reward + inflation_share_weight is the base payout + for each bundle reward upload_interval: type: string format: uint64 @@ -7128,7 +7175,10 @@ paths: protobuf release, and it is not used for type URLs beginning with - type.googleapis.com. + type.googleapis.com. As of May 2023, there are no widely + used type server + + implementations and no plans to implement one. Schemes other than `http`, `https` (or the empty scheme) @@ -7178,7 +7228,7 @@ paths: foo = any.unpack(Foo.getDefaultInstance()); } - Example 3: Pack and unpack a message in Python. + Example 3: Pack and unpack a message in Python. foo = Foo(...) any = Any() @@ -7188,7 +7238,7 @@ paths: any.Unpack(foo) ... - Example 4: Pack and unpack a message in Go + Example 4: Pack and unpack a message in Go foo := &pb.Foo{...} any, err := anypb.New(foo) @@ -7218,6 +7268,7 @@ paths: JSON + ==== The JSON representation of an `Any` value uses the regular @@ -7408,12 +7459,12 @@ paths: logo: type: string title: logo of the pool - operating_cost: + inflation_share_weight: type: string format: uint64 title: >- - operating_cost is the base payout for each - bundle reward + inflation_share_weight is the base payout for + each bundle reward upload_interval: type: string format: uint64 @@ -7581,7 +7632,10 @@ paths: protobuf release, and it is not used for type URLs beginning with - type.googleapis.com. + type.googleapis.com. As of May 2023, there are no widely + used type server + + implementations and no plans to implement one. Schemes other than `http`, `https` (or the empty scheme) @@ -7631,7 +7685,7 @@ paths: foo = any.unpack(Foo.getDefaultInstance()); } - Example 3: Pack and unpack a message in Python. + Example 3: Pack and unpack a message in Python. foo = Foo(...) any = Any() @@ -7641,7 +7695,7 @@ paths: any.Unpack(foo) ... - Example 4: Pack and unpack a message in Go + Example 4: Pack and unpack a message in Go foo := &pb.Foo{...} any, err := anypb.New(foo) @@ -7671,6 +7725,7 @@ paths: JSON + ==== The JSON representation of an `Any` value uses the regular @@ -7766,6 +7821,1340 @@ paths: type: boolean tags: - QueryStakers + /kyve/query/v1beta1/funder/{address}: + get: + summary: Funder queries a funder by address. + operationId: Funder + responses: + '200': + description: A successful response. + schema: + type: object + properties: + funder: + description: funder ... + type: object + properties: + address: + type: string + description: address ... + moniker: + type: string + description: moniker ... + identity: + type: string + title: identity is the 64 bit keybase.io identity string + website: + type: string + description: website ... + contact: + type: string + description: contact ... + description: + type: string + description: description ... + stats: + description: statistics about all the fundings of the funder. + type: object + properties: + total_used_funds: + type: string + format: uint64 + description: >- + total_used_funds are the total funds that have been + distributed by the funder. + total_allocated_funds: + type: string + format: uint64 + description: >- + total_allocated_funds are the total funds that have + been allocated by the funder. They can either get + distributed or refunded. + total_amount_per_bundle: + type: string + format: uint64 + description: >- + total_amount_per_bundle is the total amount per bundle + of all fundings of the funder. + pools_funded: + type: array + items: + type: string + format: uint64 + description: >- + pools_funded are the ids of the pools that have been + funded by the funder. + fundings: + type: array + items: + type: object + properties: + funder_address: + type: string + title: funder_address + pool_id: + type: string + format: uint64 + description: pool_id ... + amount: + type: string + format: uint64 + description: amount ... + amount_per_bundle: + type: string + format: uint64 + description: amount_per_bundle ... + total_funded: + type: string + format: uint64 + description: total_funded ... + description: Funding ... + description: fundings ... + description: >- + QueryFunderResponse is the response type for the Query/Funder RPC + method. + default: + description: An unexpected error response. + schema: + type: object + properties: + error: + type: string + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + type_url: + type: string + description: >- + A URL/resource name that uniquely identifies the type of + the serialized + + protocol buffer message. This string must contain at + least + + one "/" character. The last segment of the URL's path + must represent + + the fully qualified name of the type (as in + + `path/google.protobuf.Duration`). The name should be in + a canonical form + + (e.g., leading "." is not accepted). + + + In practice, teams usually precompile into the binary + all types that they + + expect it to use in the context of Any. However, for + URLs which use the + + scheme `http`, `https`, or no scheme, one can optionally + set up a type + + server that maps type URLs to message definitions as + follows: + + + * If no scheme is provided, `https` is assumed. + + * An HTTP GET on the URL must yield a + [google.protobuf.Type][] + value in binary format, or produce an error. + * Applications are allowed to cache lookup results based + on the + URL, or have them precompiled into a binary to avoid any + lookup. Therefore, binary compatibility needs to be preserved + on changes to types. (Use versioned type names to manage + breaking changes.) + + Note: this functionality is not currently available in + the official + + protobuf release, and it is not used for type URLs + beginning with + + type.googleapis.com. As of May 2023, there are no widely + used type server + + implementations and no plans to implement one. + + + Schemes other than `http`, `https` (or the empty scheme) + might be + + used with implementation specific semantics. + value: + type: string + format: byte + description: >- + Must be a valid serialized protocol buffer of the above + specified type. + description: >- + `Any` contains an arbitrary serialized protocol buffer + message along with a + + URL that describes the type of the serialized message. + + + Protobuf library provides support to pack/unpack Any values + in the form + + of utility functions or additional generated methods of the + Any type. + + + Example 1: Pack and unpack a message in C++. + + Foo foo = ...; + Any any; + any.PackFrom(foo); + ... + if (any.UnpackTo(&foo)) { + ... + } + + Example 2: Pack and unpack a message in Java. + + Foo foo = ...; + Any any = Any.pack(foo); + ... + if (any.is(Foo.class)) { + foo = any.unpack(Foo.class); + } + // or ... + if (any.isSameTypeAs(Foo.getDefaultInstance())) { + foo = any.unpack(Foo.getDefaultInstance()); + } + + Example 3: Pack and unpack a message in Python. + + foo = Foo(...) + any = Any() + any.Pack(foo) + ... + if any.Is(Foo.DESCRIPTOR): + any.Unpack(foo) + ... + + Example 4: Pack and unpack a message in Go + + foo := &pb.Foo{...} + any, err := anypb.New(foo) + if err != nil { + ... + } + ... + foo := &pb.Foo{} + if err := any.UnmarshalTo(foo); err != nil { + ... + } + + The pack methods provided by protobuf library will by + default use + + 'type.googleapis.com/full.type.name' as the type URL and the + unpack + + methods only use the fully qualified type name after the + last '/' + + in the type URL, for example "foo.bar.com/x/y.z" will yield + type + + name "y.z". + + + JSON + + ==== + + The JSON representation of an `Any` value uses the regular + + representation of the deserialized, embedded message, with + an + + additional field `@type` which contains the type URL. + Example: + + package google.profile; + message Person { + string first_name = 1; + string last_name = 2; + } + + { + "@type": "type.googleapis.com/google.profile.Person", + "firstName": , + "lastName": + } + + If the embedded message type is well-known and has a custom + JSON + + representation, that representation will be embedded adding + a field + + `value` which holds the custom JSON in addition to the + `@type` + + field. Example (for message [google.protobuf.Duration][]): + + { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.212s" + } + parameters: + - name: address + description: address ... + in: path + required: true + type: string + - name: status + description: |- + status ... + + - FUNDING_STATUS_UNSPECIFIED: FundingStatusUnspecified ... + - FUNDING_STATUS_ACTIVE: FundingStatusActive status is set when the funding is active. + - FUNDING_STATUS_INACTIVE: FundingStatusInactive status is set when the funding has been used up or refunded. + in: query + required: false + type: string + enum: + - FUNDING_STATUS_UNSPECIFIED + - FUNDING_STATUS_ACTIVE + - FUNDING_STATUS_INACTIVE + default: FUNDING_STATUS_UNSPECIFIED + tags: + - QueryFunders + /kyve/query/v1beta1/funders: + get: + summary: Funders queries all funders. + operationId: Funders + responses: + '200': + description: A successful response. + schema: + type: object + properties: + 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 + funders: + type: array + items: + type: object + properties: + address: + type: string + description: address ... + moniker: + type: string + description: moniker ... + identity: + type: string + title: identity is the 64 bit keybase.io identity string + website: + type: string + description: website ... + contact: + type: string + description: contact ... + description: + type: string + description: description ... + stats: + description: statistics about all the fundings of the funder. + type: object + properties: + total_used_funds: + type: string + format: uint64 + description: >- + total_used_funds are the total funds that have been + distributed by the funder. + total_allocated_funds: + type: string + format: uint64 + description: >- + total_allocated_funds are the total funds that have + been allocated by the funder. They can either get + distributed or refunded. + total_amount_per_bundle: + type: string + format: uint64 + description: >- + total_amount_per_bundle is the total amount per + bundle of all fundings of the funder. + pools_funded: + type: array + items: + type: string + format: uint64 + description: >- + pools_funded are the ids of the pools that have been + funded by the funder. + description: Funder ... + description: funders ... + description: >- + QueryFundersResponse is the response type for the Query/Funders + RPC method. + default: + description: An unexpected error response. + schema: + type: object + properties: + error: + type: string + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + type_url: + type: string + description: >- + A URL/resource name that uniquely identifies the type of + the serialized + + protocol buffer message. This string must contain at + least + + one "/" character. The last segment of the URL's path + must represent + + the fully qualified name of the type (as in + + `path/google.protobuf.Duration`). The name should be in + a canonical form + + (e.g., leading "." is not accepted). + + + In practice, teams usually precompile into the binary + all types that they + + expect it to use in the context of Any. However, for + URLs which use the + + scheme `http`, `https`, or no scheme, one can optionally + set up a type + + server that maps type URLs to message definitions as + follows: + + + * If no scheme is provided, `https` is assumed. + + * An HTTP GET on the URL must yield a + [google.protobuf.Type][] + value in binary format, or produce an error. + * Applications are allowed to cache lookup results based + on the + URL, or have them precompiled into a binary to avoid any + lookup. Therefore, binary compatibility needs to be preserved + on changes to types. (Use versioned type names to manage + breaking changes.) + + Note: this functionality is not currently available in + the official + + protobuf release, and it is not used for type URLs + beginning with + + type.googleapis.com. As of May 2023, there are no widely + used type server + + implementations and no plans to implement one. + + + Schemes other than `http`, `https` (or the empty scheme) + might be + + used with implementation specific semantics. + value: + type: string + format: byte + description: >- + Must be a valid serialized protocol buffer of the above + specified type. + description: >- + `Any` contains an arbitrary serialized protocol buffer + message along with a + + URL that describes the type of the serialized message. + + + Protobuf library provides support to pack/unpack Any values + in the form + + of utility functions or additional generated methods of the + Any type. + + + Example 1: Pack and unpack a message in C++. + + Foo foo = ...; + Any any; + any.PackFrom(foo); + ... + if (any.UnpackTo(&foo)) { + ... + } + + Example 2: Pack and unpack a message in Java. + + Foo foo = ...; + Any any = Any.pack(foo); + ... + if (any.is(Foo.class)) { + foo = any.unpack(Foo.class); + } + // or ... + if (any.isSameTypeAs(Foo.getDefaultInstance())) { + foo = any.unpack(Foo.getDefaultInstance()); + } + + Example 3: Pack and unpack a message in Python. + + foo = Foo(...) + any = Any() + any.Pack(foo) + ... + if any.Is(Foo.DESCRIPTOR): + any.Unpack(foo) + ... + + Example 4: Pack and unpack a message in Go + + foo := &pb.Foo{...} + any, err := anypb.New(foo) + if err != nil { + ... + } + ... + foo := &pb.Foo{} + if err := any.UnmarshalTo(foo); err != nil { + ... + } + + The pack methods provided by protobuf library will by + default use + + 'type.googleapis.com/full.type.name' as the type URL and the + unpack + + methods only use the fully qualified type name after the + last '/' + + in the type URL, for example "foo.bar.com/x/y.z" will yield + type + + name "y.z". + + + JSON + + ==== + + The JSON representation of an `Any` value uses the regular + + representation of the deserialized, embedded message, with + an + + additional field `@type` which contains the type URL. + Example: + + package google.profile; + message Person { + string first_name = 1; + string last_name = 2; + } + + { + "@type": "type.googleapis.com/google.profile.Person", + "firstName": , + "lastName": + } + + If the embedded message type is well-known and has a custom + JSON + + representation, that representation will be embedded adding + a field + + `value` which holds the custom JSON in addition to the + `@type` + + field. Example (for message [google.protobuf.Duration][]): + + { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.212s" + } + parameters: + - 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 + - name: search + description: search ... + in: query + required: false + type: string + tags: + - QueryFunders + /kyve/query/v1beta1/fundings_by_funder/{address}: + get: + summary: FundingsByFunder queries all fundings of a funder by address. + operationId: FundingsByFunder + responses: + '200': + description: A successful response. + schema: + type: object + properties: + 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 + fundings: + type: array + items: + type: object + properties: + funder_address: + type: string + title: funder_address + pool_id: + type: string + format: uint64 + description: pool_id ... + amount: + type: string + format: uint64 + description: amount ... + amount_per_bundle: + type: string + format: uint64 + description: amount_per_bundle ... + total_funded: + type: string + format: uint64 + description: total_funded ... + description: Funding ... + description: fundings ... + description: >- + QueryFundingsByFunderResponse is the response type for the + Query/FundingsByFunder RPC method. + default: + description: An unexpected error response. + schema: + type: object + properties: + error: + type: string + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + type_url: + type: string + description: >- + A URL/resource name that uniquely identifies the type of + the serialized + + protocol buffer message. This string must contain at + least + + one "/" character. The last segment of the URL's path + must represent + + the fully qualified name of the type (as in + + `path/google.protobuf.Duration`). The name should be in + a canonical form + + (e.g., leading "." is not accepted). + + + In practice, teams usually precompile into the binary + all types that they + + expect it to use in the context of Any. However, for + URLs which use the + + scheme `http`, `https`, or no scheme, one can optionally + set up a type + + server that maps type URLs to message definitions as + follows: + + + * If no scheme is provided, `https` is assumed. + + * An HTTP GET on the URL must yield a + [google.protobuf.Type][] + value in binary format, or produce an error. + * Applications are allowed to cache lookup results based + on the + URL, or have them precompiled into a binary to avoid any + lookup. Therefore, binary compatibility needs to be preserved + on changes to types. (Use versioned type names to manage + breaking changes.) + + Note: this functionality is not currently available in + the official + + protobuf release, and it is not used for type URLs + beginning with + + type.googleapis.com. As of May 2023, there are no widely + used type server + + implementations and no plans to implement one. + + + Schemes other than `http`, `https` (or the empty scheme) + might be + + used with implementation specific semantics. + value: + type: string + format: byte + description: >- + Must be a valid serialized protocol buffer of the above + specified type. + description: >- + `Any` contains an arbitrary serialized protocol buffer + message along with a + + URL that describes the type of the serialized message. + + + Protobuf library provides support to pack/unpack Any values + in the form + + of utility functions or additional generated methods of the + Any type. + + + Example 1: Pack and unpack a message in C++. + + Foo foo = ...; + Any any; + any.PackFrom(foo); + ... + if (any.UnpackTo(&foo)) { + ... + } + + Example 2: Pack and unpack a message in Java. + + Foo foo = ...; + Any any = Any.pack(foo); + ... + if (any.is(Foo.class)) { + foo = any.unpack(Foo.class); + } + // or ... + if (any.isSameTypeAs(Foo.getDefaultInstance())) { + foo = any.unpack(Foo.getDefaultInstance()); + } + + Example 3: Pack and unpack a message in Python. + + foo = Foo(...) + any = Any() + any.Pack(foo) + ... + if any.Is(Foo.DESCRIPTOR): + any.Unpack(foo) + ... + + Example 4: Pack and unpack a message in Go + + foo := &pb.Foo{...} + any, err := anypb.New(foo) + if err != nil { + ... + } + ... + foo := &pb.Foo{} + if err := any.UnmarshalTo(foo); err != nil { + ... + } + + The pack methods provided by protobuf library will by + default use + + 'type.googleapis.com/full.type.name' as the type URL and the + unpack + + methods only use the fully qualified type name after the + last '/' + + in the type URL, for example "foo.bar.com/x/y.z" will yield + type + + name "y.z". + + + JSON + + ==== + + The JSON representation of an `Any` value uses the regular + + representation of the deserialized, embedded message, with + an + + additional field `@type` which contains the type URL. + Example: + + package google.profile; + message Person { + string first_name = 1; + string last_name = 2; + } + + { + "@type": "type.googleapis.com/google.profile.Person", + "firstName": , + "lastName": + } + + If the embedded message type is well-known and has a custom + JSON + + representation, that representation will be embedded adding + a field + + `value` which holds the custom JSON in addition to the + `@type` + + field. Example (for message [google.protobuf.Duration][]): + + { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.212s" + } + parameters: + - name: address + description: address ... + in: path + required: true + type: string + - 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 + - name: status + description: |- + status ... + + - FUNDING_STATUS_UNSPECIFIED: FundingStatusUnspecified ... + - FUNDING_STATUS_ACTIVE: FundingStatusActive status is set when the funding is active. + - FUNDING_STATUS_INACTIVE: FundingStatusInactive status is set when the funding has been used up or refunded. + in: query + required: false + type: string + enum: + - FUNDING_STATUS_UNSPECIFIED + - FUNDING_STATUS_ACTIVE + - FUNDING_STATUS_INACTIVE + default: FUNDING_STATUS_UNSPECIFIED + tags: + - QueryFunders + /kyve/query/v1beta1/fundings_by_pool/{pool_id}: + get: + summary: FundingsByPool queries all fundings of a pool by id. + operationId: FundingsByPool + responses: + '200': + description: A successful response. + schema: + type: object + properties: + 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 + fundings: + type: array + items: + type: object + properties: + funder_address: + type: string + title: funder_address + pool_id: + type: string + format: uint64 + description: pool_id ... + amount: + type: string + format: uint64 + description: amount ... + amount_per_bundle: + type: string + format: uint64 + description: amount_per_bundle ... + total_funded: + type: string + format: uint64 + description: total_funded ... + description: Funding ... + description: fundings ... + description: >- + QueryFundingsByPoolResponse is the response type for the + Query/FundingsByPool RPC method. + default: + description: An unexpected error response. + schema: + type: object + properties: + error: + type: string + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + type_url: + type: string + description: >- + A URL/resource name that uniquely identifies the type of + the serialized + + protocol buffer message. This string must contain at + least + + one "/" character. The last segment of the URL's path + must represent + + the fully qualified name of the type (as in + + `path/google.protobuf.Duration`). The name should be in + a canonical form + + (e.g., leading "." is not accepted). + + + In practice, teams usually precompile into the binary + all types that they + + expect it to use in the context of Any. However, for + URLs which use the + + scheme `http`, `https`, or no scheme, one can optionally + set up a type + + server that maps type URLs to message definitions as + follows: + + + * If no scheme is provided, `https` is assumed. + + * An HTTP GET on the URL must yield a + [google.protobuf.Type][] + value in binary format, or produce an error. + * Applications are allowed to cache lookup results based + on the + URL, or have them precompiled into a binary to avoid any + lookup. Therefore, binary compatibility needs to be preserved + on changes to types. (Use versioned type names to manage + breaking changes.) + + Note: this functionality is not currently available in + the official + + protobuf release, and it is not used for type URLs + beginning with + + type.googleapis.com. As of May 2023, there are no widely + used type server + + implementations and no plans to implement one. + + + Schemes other than `http`, `https` (or the empty scheme) + might be + + used with implementation specific semantics. + value: + type: string + format: byte + description: >- + Must be a valid serialized protocol buffer of the above + specified type. + description: >- + `Any` contains an arbitrary serialized protocol buffer + message along with a + + URL that describes the type of the serialized message. + + + Protobuf library provides support to pack/unpack Any values + in the form + + of utility functions or additional generated methods of the + Any type. + + + Example 1: Pack and unpack a message in C++. + + Foo foo = ...; + Any any; + any.PackFrom(foo); + ... + if (any.UnpackTo(&foo)) { + ... + } + + Example 2: Pack and unpack a message in Java. + + Foo foo = ...; + Any any = Any.pack(foo); + ... + if (any.is(Foo.class)) { + foo = any.unpack(Foo.class); + } + // or ... + if (any.isSameTypeAs(Foo.getDefaultInstance())) { + foo = any.unpack(Foo.getDefaultInstance()); + } + + Example 3: Pack and unpack a message in Python. + + foo = Foo(...) + any = Any() + any.Pack(foo) + ... + if any.Is(Foo.DESCRIPTOR): + any.Unpack(foo) + ... + + Example 4: Pack and unpack a message in Go + + foo := &pb.Foo{...} + any, err := anypb.New(foo) + if err != nil { + ... + } + ... + foo := &pb.Foo{} + if err := any.UnmarshalTo(foo); err != nil { + ... + } + + The pack methods provided by protobuf library will by + default use + + 'type.googleapis.com/full.type.name' as the type URL and the + unpack + + methods only use the fully qualified type name after the + last '/' + + in the type URL, for example "foo.bar.com/x/y.z" will yield + type + + name "y.z". + + + JSON + + ==== + + The JSON representation of an `Any` value uses the regular + + representation of the deserialized, embedded message, with + an + + additional field `@type` which contains the type URL. + Example: + + package google.profile; + message Person { + string first_name = 1; + string last_name = 2; + } + + { + "@type": "type.googleapis.com/google.profile.Person", + "firstName": , + "lastName": + } + + If the embedded message type is well-known and has a custom + JSON + + representation, that representation will be embedded adding + a field + + `value` which holds the custom JSON in addition to the + `@type` + + field. Example (for message [google.protobuf.Duration][]): + + { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.212s" + } + parameters: + - name: pool_id + description: pool_id ... + in: path + required: true + 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 + - name: status + description: |- + status ... + + - FUNDING_STATUS_UNSPECIFIED: FundingStatusUnspecified ... + - FUNDING_STATUS_ACTIVE: FundingStatusActive status is set when the funding is active. + - FUNDING_STATUS_INACTIVE: FundingStatusInactive status is set when the funding has been used up or refunded. + in: query + required: false + type: string + enum: + - FUNDING_STATUS_UNSPECIFIED + - FUNDING_STATUS_ACTIVE + - FUNDING_STATUS_INACTIVE + default: FUNDING_STATUS_UNSPECIFIED + tags: + - QueryFunders /kyve/stakers/v1beta1/params: get: summary: Parameters queries the parameters of the module. diff --git a/go.mod b/go.mod index f0f08bbf..7070c493 100644 --- a/go.mod +++ b/go.mod @@ -15,10 +15,11 @@ require ( github.com/golang/protobuf v1.5.3 github.com/golangci/golangci-lint v1.52.2 github.com/grpc-ecosystem/grpc-gateway v1.16.0 - github.com/onsi/ginkgo/v2 v2.8.0 - github.com/onsi/gomega v1.26.0 + github.com/onsi/ginkgo/v2 v2.12.1 + github.com/onsi/gomega v1.27.10 github.com/spf13/cast v1.5.1 github.com/spf13/cobra v1.7.0 + github.com/spf13/pflag v1.0.5 github.com/spf13/viper v1.16.0 github.com/strangelove-ventures/packet-forward-middleware/v7 v7.0.0-20230523193151-73dea436e53f github.com/stretchr/testify v1.8.4 @@ -113,7 +114,8 @@ require ( github.com/go-kit/kit v0.12.0 // indirect github.com/go-kit/log v0.2.1 // indirect github.com/go-logfmt/logfmt v0.6.0 // indirect - github.com/go-logr/logr v1.2.3 // indirect + github.com/go-logr/logr v1.2.4 // indirect + github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect github.com/go-toolsmith/astcast v1.1.0 // indirect github.com/go-toolsmith/astcopy v1.1.0 // indirect github.com/go-toolsmith/astequal v1.1.0 // indirect @@ -143,6 +145,7 @@ require ( github.com/google/btree v1.1.2 // indirect github.com/google/go-cmp v0.5.9 // indirect github.com/google/orderedcode v0.0.1 // indirect + github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 // indirect github.com/google/s2a-go v0.1.4 // indirect github.com/google/uuid v1.3.0 // indirect github.com/googleapis/enterprise-certificate-proxy v0.2.3 // indirect @@ -257,7 +260,6 @@ require ( github.com/sourcegraph/go-diff v0.7.0 // indirect github.com/spf13/afero v1.9.5 // indirect github.com/spf13/jwalterweatherman v1.1.0 // indirect - github.com/spf13/pflag v1.0.5 // indirect github.com/ssgreg/nlreturn/v2 v2.2.1 // indirect github.com/stbenjam/no-sprintf-host-port v0.1.1 // indirect github.com/stretchr/objx v0.5.0 // indirect @@ -287,17 +289,17 @@ require ( go.uber.org/goleak v1.1.12 // indirect go.uber.org/multierr v1.8.0 // indirect go.uber.org/zap v1.24.0 // indirect - golang.org/x/crypto v0.11.0 // indirect + golang.org/x/crypto v0.12.0 // indirect golang.org/x/exp v0.0.0-20230711153332-06a737ee72cb // indirect golang.org/x/exp/typeparams v0.0.0-20230224173230-c95f2b4c22f2 // indirect - golang.org/x/mod v0.11.0 // indirect - golang.org/x/net v0.12.0 // indirect + golang.org/x/mod v0.12.0 // indirect + golang.org/x/net v0.14.0 // indirect golang.org/x/oauth2 v0.8.0 // indirect - golang.org/x/sync v0.2.0 // indirect - golang.org/x/sys v0.11.0 // indirect - golang.org/x/term v0.10.0 // indirect + golang.org/x/sync v0.3.0 // indirect + golang.org/x/sys v0.12.0 // indirect + golang.org/x/term v0.11.0 // indirect golang.org/x/text v0.12.0 // indirect - golang.org/x/tools v0.8.0 // indirect + golang.org/x/tools v0.12.0 // indirect golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect google.golang.org/api v0.126.0 // indirect google.golang.org/appengine v1.6.7 // indirect diff --git a/go.sum b/go.sum index 5418ef47..a35cff07 100644 --- a/go.sum +++ b/go.sum @@ -586,8 +586,8 @@ github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= github.com/go-logfmt/logfmt v0.6.0 h1:wGYYu3uicYdqXVgoYbvnkrPVXkuLM1p1ifugDMEdRi4= github.com/go-logfmt/logfmt v0.6.0/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= -github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0= -github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ= +github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-ole/go-ole v1.2.1/go.mod h1:7FAglXiTm7HKlQRDeOQ6ZNUHidzCWXuZWq/1dTyBNF8= github.com/go-openapi/jsonpointer v0.19.5/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= @@ -602,6 +602,8 @@ github.com/go-sourcemap/sourcemap v2.1.3+incompatible/go.mod h1:F8jJfvm2KbVjc5Nq github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= +github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= +github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls= github.com/go-toolsmith/astcast v1.1.0 h1:+JN9xZV1A+Re+95pgnMgDboWNVnIMMQXwfBwLRPgSC8= github.com/go-toolsmith/astcast v1.1.0/go.mod h1:qdcuFWeGGS2xX5bLM/c3U9lewg7+Zu4mr+xPwZIB4ZU= github.com/go-toolsmith/astcopy v1.1.0 h1:YGwBN0WM+ekI/6SS6+52zLDEf8Yvp3n2seZITCUBt5s= @@ -754,6 +756,7 @@ github.com/google/pprof v0.0.0-20210122040257-d980be63207e/go.mod h1:kpwsk12EmLe github.com/google/pprof v0.0.0-20210226084205-cbba55b83ad5/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20210601050228-01bbb1931b22/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20210609004039-a478d1d731e9/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 h1:K6RDEckDVWvDI9JAJYCmNdQXq6neHJOYx3V6jnqNEec= github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/s2a-go v0.1.4 h1:1kZ/sQM3srePvKs3tXAvQzo66XfcReoqFpIpIccE7Oc= @@ -1126,14 +1129,14 @@ github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+W github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= github.com/onsi/ginkgo v1.16.4 h1:29JGrr5oVBm5ulCWet69zQkzWipVXIol6ygQUe/EzNc= -github.com/onsi/ginkgo/v2 v2.8.0 h1:pAM+oBNPrpXRs+E/8spkeGx9QgekbRVyr74EUvRVOUI= -github.com/onsi/ginkgo/v2 v2.8.0/go.mod h1:6JsQiECmxCa3V5st74AL/AmsV482EDdVrGaVW6z3oYU= +github.com/onsi/ginkgo/v2 v2.12.1 h1:uHNEO1RP2SpuZApSkel9nEh1/Mu+hmQe7Q+Pepg5OYA= +github.com/onsi/ginkgo/v2 v2.12.1/go.mod h1:TE309ZR8s5FsKKpuB1YAQYBzCaAfUgatB/xlT/ETL/o= github.com/onsi/gomega v1.4.1/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= -github.com/onsi/gomega v1.26.0 h1:03cDLK28U6hWvCAns6NeydX3zIm4SF3ci69ulidS32Q= -github.com/onsi/gomega v1.26.0/go.mod h1:r+zV744Re+DiYCIPRlYOTxn0YkOLcAnW8k1xXdMPGhM= +github.com/onsi/gomega v1.27.10 h1:naR28SdDFlqrG6kScpT8VWpu1xWY5nJRCF3XaYyBjhI= +github.com/onsi/gomega v1.27.10/go.mod h1:RsS8tutOdbdgzbPtzzATp12yT7kM5I5aElG3evPbQ0M= github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/image-spec v1.1.0-rc2 h1:2zx/Stx4Wc5pIPDvIxHXvXtQFW/7XWJGmnM7r3wg034= @@ -1505,8 +1508,8 @@ golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20220314234659-1baeb1ce4c0b/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw= -golang.org/x/crypto v0.11.0 h1:6Ewdq3tDic1mg5xRO4milcWCfMVQhI4NkqWWvqejpuA= -golang.org/x/crypto v0.11.0/go.mod h1:xgJhtzW8F9jGdVFWZESrid1U1bjeNy4zgy5cRr/CIio= +golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk= +golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw= golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -1559,8 +1562,8 @@ golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91 golang.org/x/mod v0.6.0/go.mod h1:4mET923SAdbXp2ki8ey+zGs1SLqsuM2Y0uvdZR/fUNI= golang.org/x/mod v0.7.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/mod v0.11.0 h1:bUO06HqtnRcc/7l71XBe4WcqTZ+3AH1J59zWDDwLKgU= -golang.org/x/mod v0.11.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc= +golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -1632,8 +1635,8 @@ golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= golang.org/x/net v0.3.0/go.mod h1:MBQ8lrhLObU/6UmLb4fmbmk5OcyYmqtbGd/9yIeKjEE= golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/net v0.12.0 h1:cfawfvKITfUsFCeJIHJrbSxpeu/E81khclypR0GVT50= -golang.org/x/net v0.12.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA= +golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14= +golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -1676,8 +1679,8 @@ golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220929204114-8fcdb60fdcc0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.2.0 h1:PUR+T4wwASmuSTYdKjYHI5TD22Wy5ogLU5qZCOLxBrI= -golang.org/x/sync v0.2.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E= +golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -1795,8 +1798,8 @@ golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM= -golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o= +golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= @@ -1805,8 +1808,8 @@ golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= golang.org/x/term v0.3.0/go.mod h1:q750SLmJuPmVoN1blW3UFBPREJfb1KmY3vwxfr+nFDA= golang.org/x/term v0.4.0/go.mod h1:9P2UbLfCdcvo3p/nzKvsmas4TnlujnuoV9hGgYzW1lQ= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= -golang.org/x/term v0.10.0 h1:3R7pNqamzBraeqj/Tj8qt1aQ2HpmlC+Cx/qL/7hn4/c= -golang.org/x/term v0.10.0/go.mod h1:lpqdcUyK/oCiQxvxVrppt5ggO2KCZ5QblwqPnfZ6d5o= +golang.org/x/term v0.11.0 h1:F9tnn/DA/Im8nCwm+fX+1/eBwi4qFjRT++MhtVC4ZX0= +golang.org/x/term v0.11.0/go.mod h1:zC9APTIj3jG3FdV/Ons+XE1riIZXG4aZ4GTHiPZJPIU= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -1911,8 +1914,8 @@ golang.org/x/tools v0.3.0/go.mod h1:/rWhSS2+zyEVwoJf8YAX6L2f0ntZ7Kn/mGgAWcipA5k= golang.org/x/tools v0.4.0/go.mod h1:UE5sM2OK9E/d67R0ANs2xJizIymRP5gJU295PvKXxjQ= golang.org/x/tools v0.5.0/go.mod h1:N+Kgy78s5I24c24dU8OfWNEotWjutIs8SnJvn5IDq+k= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= -golang.org/x/tools v0.8.0 h1:vSDcovVPld282ceKgDimkRSC8kpaH1dgyc9UMzlt84Y= -golang.org/x/tools v0.8.0/go.mod h1:JxBZ99ISMI5ViVkT1tr6tdNmXeTrcpVSD3vZ1RsRdN4= +golang.org/x/tools v0.12.0 h1:YW6HUoUmYBpwSgyaGaZq1fHjrBjX1rlpZ54T6mu2kss= +golang.org/x/tools v0.12.0/go.mod h1:Sc0INKfu04TlqNoRA1hgpFZbhYXHPr4V5DzpSBTPqQM= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/proto/Dockerfile b/proto/Dockerfile index ea2150dc..8176c1b2 100644 --- a/proto/Dockerfile +++ b/proto/Dockerfile @@ -18,3 +18,20 @@ RUN git clone https://github.com/cosmos/gogoproto.git; \ RUN npm install -g swagger-combine COPY --from=BUILDER /usr/local/bin /usr/local/bin + +# Inject user id and group id to avoid permission issues when running as a root user +ARG USER_ID=1000 +ARG USER_GID=1000 + +# Create group if it doesn't exist +RUN if ! getent group $USER_GID; then \ + addgroup -g $USER_GID mygroup; \ +fi + +# Create user if it doesn't exist +RUN if ! getent passwd $USER_ID; then \ + adduser -D -u $USER_ID -G $(getent group $USER_GID | cut -d: -f1) myuser; \ +fi + +# Change to user +USER $USER_ID diff --git a/proto/buf.gen.yaml b/proto/buf.gen.yaml index 90dcc2a7..d57a306f 100644 --- a/proto/buf.gen.yaml +++ b/proto/buf.gen.yaml @@ -9,4 +9,4 @@ plugins: - name: swagger out: ../tmp-swagger-gen opt: - - simple_operation_ids=true + - simple_operation_ids=true \ No newline at end of file diff --git a/proto/generate.sh b/proto/generate.sh index 27a7fa57..fe4889f5 100644 --- a/proto/generate.sh +++ b/proto/generate.sh @@ -6,4 +6,4 @@ cp -r github.com/KYVENetwork/chain/* ./ rm -rf github.com swagger-combine ./docs/config.json -o ./docs/swagger.yml -rm -rf tmp-swagger-gen +rm -rf tmp-swagger-gen \ No newline at end of file diff --git a/proto/kyve/funders/v1beta1/events.proto b/proto/kyve/funders/v1beta1/events.proto new file mode 100644 index 00000000..a41f62d6 --- /dev/null +++ b/proto/kyve/funders/v1beta1/events.proto @@ -0,0 +1,84 @@ +syntax = "proto3"; + +package kyve.funders.v1beta1; + +import "gogoproto/gogo.proto"; +import "kyve/funders/v1beta1/params.proto"; + +option go_package = "github.com/KYVENetwork/chain/x/funders/types"; + +// EventUpdateParams is an event emitted when the module parameters are updated. +// emitted_by: MsgUpdateParams +message EventUpdateParams { + // old_params is the module's old parameters. + Params old_params = 1 [(gogoproto.nullable) = false]; + // new_params is the module's new parameters. + Params new_params = 2 [(gogoproto.nullable) = false]; + // payload is the parameter updates that were performed. + string payload = 3; +} + +// EventCreateFunder is an event emitted when a funder is created. +// emitted_by: MsgCreateFunder +message EventCreateFunder { + // address is the account address of the funder. + string address = 1; + // moniker ... + string moniker = 2; + // identity is the 64 bit keybase.io identity string + string identity = 3; + // website ... + string website = 4; + // contact ... + string contact = 5; + // description are some additional notes the funder finds important + string description = 6; +} + +// EventUpdateFunder is an event emitted when a funder is created. +// emitted_by: MsgCreateFunder +message EventUpdateFunder { + // address is the account address of the funder. + string address = 1; + // moniker ... + string moniker = 2; + // identity is the 64 bit keybase.io identity string + string identity = 3; + // website ... + string website = 4; + // contact ... + string contact = 5; + // description are some additional notes the funder finds important + string description = 6; +} + +// EventFundPool is an event emitted when a pool is funded. +// emitted_by: MsgFundPool +message EventFundPool { + // pool_id is the unique ID of the pool. + uint64 pool_id = 1; + // address is the account address of the pool funder. + string address = 2; + // amount is the amount in ukyve the funder has funded + uint64 amount = 3; + // amount_per_bundle is the amount in ukyve the funder has funded per bundle + uint64 amount_per_bundle = 4; +} + +// EventDefundPool is an event emitted when a pool is defunded. +// emitted_by: MsgDefundPool +message EventDefundPool { + // pool_id is the unique ID of the pool. + uint64 pool_id = 1; + // address is the account address of the pool funder. + string address = 2; + // amount is the amount in ukyve the funder has defunded + uint64 amount = 3; +} + +// EventPoolOutOfFunds is an event emitted when a pool has run out of funds +// emitted_by: MsgSubmitBundleProposal +message EventPoolOutOfFunds { + // pool_id is the unique ID of the pool. + uint64 pool_id = 1; +} diff --git a/proto/kyve/funders/v1beta1/funders.proto b/proto/kyve/funders/v1beta1/funders.proto new file mode 100644 index 00000000..13867c80 --- /dev/null +++ b/proto/kyve/funders/v1beta1/funders.proto @@ -0,0 +1,48 @@ +syntax = "proto3"; + +package kyve.funders.v1beta1; + +//import "gogoproto/gogo.proto"; + +option go_package = "github.com/KYVENetwork/chain/x/funders/types"; + +// Funder is the object which holds info about a single pool funder +message Funder { + // address ... + string address = 1; + // moniker ... + string moniker = 2; + // identity is the 64 bit keybase.io identity string + string identity = 3; + // website ... + string website = 4; + // contact ... + string contact = 5; + // description are some additional notes the funder finds important + string description = 6; +} + +// Funding is the object which holds info about the current funding +// funder_address and pool_id (m2m) are unique together which means that +// a funder can only fund each pool once and a pool can only be funded +// by each funder once. However, a funder can update the amount of funds. +message Funding { + // funder_id is the id of the funder + string funder_address = 1; + // pool_id is the id of the pool this funding is for + uint64 pool_id = 2; + // amount is the amount of funds in ukyve the funder has left + uint64 amount = 3; + // amount_per_bundle is the amount of funds in ukyve the funder pays per bundle + uint64 amount_per_bundle = 4; + // total_funded is the total amount of funds in ukyve the funder has funded + uint64 total_funded = 5; +} + +// FundingState is the object which holds info about the funding state of a pool +message FundingState { + // pool_id is the id of the pool this funding is for + uint64 pool_id = 1; + // active_funder_addresses is the list of all active fundings + repeated string active_funder_addresses = 2; +} diff --git a/proto/kyve/funders/v1beta1/genesis.proto b/proto/kyve/funders/v1beta1/genesis.proto new file mode 100644 index 00000000..f0686f39 --- /dev/null +++ b/proto/kyve/funders/v1beta1/genesis.proto @@ -0,0 +1,21 @@ +syntax = "proto3"; + +package kyve.funders.v1beta1; + +import "gogoproto/gogo.proto"; +import "kyve/funders/v1beta1/funders.proto"; +import "kyve/funders/v1beta1/params.proto"; + +option go_package = "github.com/KYVENetwork/chain/x/funders/types"; + +// GenesisState defines the funders module's genesis state. +message GenesisState { + // params defines all the parameters of the module. + Params params = 1 [(gogoproto.nullable) = false]; + // funder_list ... + repeated kyve.funders.v1beta1.Funder funder_list = 2 [(gogoproto.nullable) = false]; + // funding_list ... + repeated kyve.funders.v1beta1.Funding funding_list = 3 [(gogoproto.nullable) = false]; + // funding_state ... + repeated kyve.funders.v1beta1.FundingState funding_state_list = 4 [(gogoproto.nullable) = false]; +} diff --git a/proto/kyve/funders/v1beta1/params.proto b/proto/kyve/funders/v1beta1/params.proto new file mode 100644 index 00000000..df0acccc --- /dev/null +++ b/proto/kyve/funders/v1beta1/params.proto @@ -0,0 +1,17 @@ +syntax = "proto3"; + +package kyve.funders.v1beta1; + +option go_package = "github.com/KYVENetwork/chain/x/funders/types"; + +// Params defines the funders module parameters. +message Params { + // Minimum amount of tokens that can be funded. + uint64 min_funding_amount = 1; + // Minimum amount of tokens that can be funded per bundle. + uint64 min_funding_amount_per_bundle = 2; + // Minimum ratio between the funded amount and the amount_per_bundle. + // In other words this param ensures, that a funder provides at least funding for + // `min_funding_multiple` bundles. + uint64 min_funding_multiple = 3; +} diff --git a/proto/kyve/funders/v1beta1/query.proto b/proto/kyve/funders/v1beta1/query.proto new file mode 100644 index 00000000..58d13403 --- /dev/null +++ b/proto/kyve/funders/v1beta1/query.proto @@ -0,0 +1,26 @@ +syntax = "proto3"; + +package kyve.funders.v1beta1; + +import "gogoproto/gogo.proto"; +import "google/api/annotations.proto"; +import "kyve/funders/v1beta1/params.proto"; + +option go_package = "github.com/KYVENetwork/chain/x/funders/types"; + +// Query defines the gRPC querier service. +service Query { + // Parameters queries the parameters of the module. + rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { + option (google.api.http).get = "/kyve/funders/v1beta1/params"; + } +} + +// 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]; +} diff --git a/proto/kyve/funders/v1beta1/tx.proto b/proto/kyve/funders/v1beta1/tx.proto new file mode 100644 index 00000000..98baf0a9 --- /dev/null +++ b/proto/kyve/funders/v1beta1/tx.proto @@ -0,0 +1,101 @@ +syntax = "proto3"; + +package kyve.funders.v1beta1; + +import "cosmos_proto/cosmos.proto"; + +option go_package = "github.com/KYVENetwork/chain/x/funders/types"; + +// Msg defines the Msg service. +service Msg { + // CreateFunder ... + rpc CreateFunder(MsgCreateFunder) returns (MsgCreateFunderResponse); + // UpdateFunder ... + rpc UpdateFunder(MsgUpdateFunder) returns (MsgUpdateFunderResponse); + // FundPool ... + rpc FundPool(MsgFundPool) returns (MsgFundPoolResponse); + // DefundPool ... + rpc DefundPool(MsgDefundPool) returns (MsgDefundPoolResponse); + + // UpdateParams defines a governance operation for updating the x/delegation module + // parameters. The authority is hard-coded to the x/gov module account. + rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse); +} + +// MsgCreateFunder defines a SDK message for creating a funder. +message MsgCreateFunder { + // creator ... + string creator = 1; + // moniker + string moniker = 2; + // identity is the 64 bit keybase.io identity string + string identity = 3; + // website + string website = 4; + // contact + string contact = 5; + // description are some additional notes the funder finds important + string description = 6; +} + +// MsgCreateFunderResponse defines the Msg/CreateFunder response type. +message MsgCreateFunderResponse {} + +// MsgUpdateFunder defines a SDK message for updating a funder. +message MsgUpdateFunder { + // creator ... + string creator = 1; + // moniker + string moniker = 2; + // identity is the 64 bit keybase.io identity string + string identity = 3; + // website + string website = 4; + // contact + string contact = 5; + // description are some additional notes the funder finds important + string description = 6; +} + +// MsgUpdateFunderResponse defines the Msg/UpdateFunder response type. +message MsgUpdateFunderResponse {} + +// MsgFundPool defines a SDK message for funding a pool. +message MsgFundPool { + // creator ... + string creator = 1; + // id ... + uint64 pool_id = 2; + // amount is the total amount available for distribution + uint64 amount = 3; + // amount_per_bundle defines the amount of tokens that are distributed per submitted bundle + uint64 amount_per_bundle = 4; +} + +// MsgFundPoolResponse defines the Msg/DefundPool response type. +message MsgFundPoolResponse {} + +// MsgDefundPool defines a SDK message for defunding a pool. +message MsgDefundPool { + // creator ... + string creator = 1; + // id ... + uint64 pool_id = 2; + // amount ... + uint64 amount = 3; +} + +// MsgDefundPoolResponse defines the Msg/DefundPool response type. +message MsgDefundPoolResponse {} + +// MsgUpdateParams defines a SDK message for updating the module parameters. +message MsgUpdateParams { + // authority is the address of the governance account. + string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + + // payload defines the x/delegation parameters to update. + string payload = 2; +} + +// MsgUpdateParamsResponse defines the Msg/UpdateParams response type. +message MsgUpdateParamsResponse {} diff --git a/proto/kyve/pool/v1beta1/events.proto b/proto/kyve/pool/v1beta1/events.proto index 2e23ad92..2c0d83fc 100644 --- a/proto/kyve/pool/v1beta1/events.proto +++ b/proto/kyve/pool/v1beta1/events.proto @@ -38,9 +38,9 @@ message EventCreatePool { // upload_interval is the interval the pool should validate // bundles with uint64 upload_interval = 7; - // operating_cost is the fixed cost which gets paid out + // inflation_share_weight is the fixed cost which gets paid out // to every successful uploader - uint64 operating_cost = 8; + uint64 inflation_share_weight = 8; // min_delegation is the minimum amount of $KYVE the pool has // to have in order to produce bundles uint64 min_delegation = 9; @@ -121,9 +121,9 @@ message EventPoolUpdated { // upload_interval is the interval the pool should validate // bundles with uint64 upload_interval = 7; - // operating_cost is the fixed cost which gets paid out + // inflation_share_weight is the fixed cost which gets paid out // to every successful uploader - uint64 operating_cost = 8; + uint64 inflation_share_weight = 8; // min_delegation is the minimum amount of $KYVE the pool has // to have in order to produce bundles uint64 min_delegation = 9; @@ -138,28 +138,6 @@ message EventPoolUpdated { uint32 compression_id = 12; } -// EventFundPool is an event emitted when a pool is funded. -// emitted_by: MsgFundPool -message EventFundPool { - // pool_id is the unique ID of the pool. - uint64 pool_id = 1; - // address is the account address of the pool funder. - string address = 2; - // amount is the amount in ukyve the funder has funded - uint64 amount = 3; -} - -// EventDefundPool is an event emitted when a pool is defunded. -// emitted_by: MsgDefundPool -message EventDefundPool { - // pool_id is the unique ID of the pool. - uint64 pool_id = 1; - // address is the account address of the pool funder. - string address = 2; - // amount is the amount in ukyve the funder has defunded - uint64 amount = 3; -} - // EventDefundPool is an event emitted when a pool is defunded. // emitted_by: MsgSubmitBundleProposal message EventPoolFundsSlashed { @@ -170,10 +148,3 @@ message EventPoolFundsSlashed { // amount is the amount in ukyve the validator has lost due to the slash uint64 amount = 3; } - -// EventPoolOutOfFunds is an event emitted when a pool has run out of funds -// emitted_by: MsgSubmitBundleProposal -message EventPoolOutOfFunds { - // pool_id is the unique ID of the pool. - uint64 pool_id = 1; -} diff --git a/proto/kyve/pool/v1beta1/pool.proto b/proto/kyve/pool/v1beta1/pool.proto index ac286ec3..c82e9305 100644 --- a/proto/kyve/pool/v1beta1/pool.proto +++ b/proto/kyve/pool/v1beta1/pool.proto @@ -61,15 +61,6 @@ message UpgradePlan { uint64 duration = 4; } -// Funder is the object which holds info about a single pool funder -message Funder { - // address is the address of the funder - string address = 1; - // amount is the current amount of funds in ukyve the funder has - // still funded the pool with - uint64 amount = 2; -} - // Pool ... message Pool { // id - unique identifier of the pool, can not be changed @@ -98,8 +89,8 @@ message Pool { // upload_interval ... uint64 upload_interval = 11; - // operating_cost ... - uint64 operating_cost = 12; + // inflation_share_weight ... + uint64 inflation_share_weight = 12; // min_delegation ... uint64 min_delegation = 13; // max_bundle_size ... @@ -109,18 +100,13 @@ message Pool { // Can only be done via governance. bool disabled = 15; - // funders ... - repeated Funder funders = 16; - // total_funds ... - uint64 total_funds = 17; - // protocol ... - Protocol protocol = 18; + Protocol protocol = 16; // upgrade_plan ... - UpgradePlan upgrade_plan = 19; + UpgradePlan upgrade_plan = 17; // storage_provider_id ... - uint32 current_storage_provider_id = 20; + uint32 current_storage_provider_id = 18; // compression_id ... - uint32 current_compression_id = 21; + uint32 current_compression_id = 19; } diff --git a/proto/kyve/pool/v1beta1/tx.proto b/proto/kyve/pool/v1beta1/tx.proto index c7efa075..808618a3 100644 --- a/proto/kyve/pool/v1beta1/tx.proto +++ b/proto/kyve/pool/v1beta1/tx.proto @@ -8,11 +8,6 @@ option go_package = "github.com/KYVENetwork/chain/x/pool/types"; // Msg defines the Msg service. service Msg { - // FundPool ... - rpc FundPool(MsgFundPool) returns (MsgFundPoolResponse); - // DefundPool ... - rpc DefundPool(MsgDefundPool) returns (MsgDefundPoolResponse); - // CreatePool defines a governance operation for creating a new pool. // The authority is hard-coded to the x/gov module account. rpc CreatePool(MsgCreatePool) returns (MsgCreatePoolResponse); @@ -36,32 +31,6 @@ service Msg { rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse); } -// MsgFundPool defines a SDK message for funding a pool. -message MsgFundPool { - // creator ... - string creator = 1; - // id ... - uint64 id = 2; - // amount ... - uint64 amount = 3; -} - -// MsgFundPoolResponse defines the Msg/DefundPool response type. -message MsgFundPoolResponse {} - -// MsgDefundPool defines a SDK message for defunding a pool. -message MsgDefundPool { - // creator ... - string creator = 1; - // id ... - uint64 id = 2; - // amount ... - uint64 amount = 3; -} - -// MsgDefundPoolResponse defines the Msg/DefundPool response type. -message MsgDefundPoolResponse {} - // MsgCreatePool defines a SDK message for creating a new pool. message MsgCreatePool { // authority is the address of the governance account. @@ -78,8 +47,8 @@ message MsgCreatePool { string start_key = 6; // upload_interval ... uint64 upload_interval = 7; - // operating_cost ... - uint64 operating_cost = 8; + // inflation_share_weight ... + uint64 inflation_share_weight = 8; // min_delegation ... uint64 min_delegation = 9; // max_bundle_size ... diff --git a/proto/kyve/query/v1beta1/funders.proto b/proto/kyve/query/v1beta1/funders.proto new file mode 100644 index 00000000..54bd18c3 --- /dev/null +++ b/proto/kyve/query/v1beta1/funders.proto @@ -0,0 +1,173 @@ +syntax = "proto3"; + +package kyve.query.v1beta1; + +import "cosmos/base/query/v1beta1/pagination.proto"; +import "gogoproto/gogo.proto"; +import "google/api/annotations.proto"; + +option go_package = "github.com/KYVENetwork/chain/x/query/types"; + +// QueryFunders ... +service QueryFunders { + // Funders queries all funders. + rpc Funders(QueryFundersRequest) returns (QueryFundersResponse) { + option (google.api.http).get = "/kyve/query/v1beta1/funders"; + } + // Funder queries a funder by address. + rpc Funder(QueryFunderRequest) returns (QueryFunderResponse) { + option (google.api.http).get = "/kyve/query/v1beta1/funder/{address}"; + } + // FundingsByFunder queries all fundings of a funder by address. + rpc FundingsByFunder(QueryFundingsByFunderRequest) returns (QueryFundingsByFunderResponse) { + option (google.api.http).get = "/kyve/query/v1beta1/fundings_by_funder/{address}"; + } + // FundingsByPool queries all fundings of a pool by id. + rpc FundingsByPool(QueryFundingsByPoolRequest) returns (QueryFundingsByPoolResponse) { + option (google.api.http).get = "/kyve/query/v1beta1/fundings_by_pool/{pool_id}"; + } +} + +// =============== +// Common messages +// =============== + +// Funder ... +message Funder { + // address ... + string address = 1; + // moniker ... + string moniker = 2; + // identity is the 64 bit keybase.io identity string + string identity = 3; + // website ... + string website = 4; + // contact ... + string contact = 5; + // description ... + string description = 6; + // statistics about all the fundings of the funder. + FundingStats stats = 7; +} + +// FundingStats ... +message FundingStats { + // total_used_funds are the total funds that have been distributed by the funder. + uint64 total_used_funds = 1; + // total_allocated_funds are the total funds that have been allocated by the funder. They can either get distributed or refunded. + uint64 total_allocated_funds = 2; + // total_amount_per_bundle is the total amount per bundle of all fundings of the funder. + uint64 total_amount_per_bundle = 3; + // pools_funded are the ids of the pools that have been funded by the funder. + repeated uint64 pools_funded = 4; +} + +// Funding ... +message Funding { + // funder_address + string funder_address = 1; + // pool_id ... + uint64 pool_id = 2; + // amount ... + uint64 amount = 3; + // amount_per_bundle ... + uint64 amount_per_bundle = 4; + // total_funded ... + uint64 total_funded = 5; +} + +// FundingStatus ... +enum FundingStatus { + option (gogoproto.goproto_enum_prefix) = false; + + // FundingStatusUnspecified ... + FUNDING_STATUS_UNSPECIFIED = 0; + // FundingStatusActive status is set when the funding is active. + FUNDING_STATUS_ACTIVE = 1; + // FundingStatusInactive status is set when the funding has been used up or refunded. + FUNDING_STATUS_INACTIVE = 2; +} + +// ======== +// /funders +// ======== + +// QueryFundersRequest is the request type for the Query/Funders RPC method. +message QueryFundersRequest { + // pagination defines an optional pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 1; + // search ... + string search = 2; +} + +// QueryFundersResponse is the response type for the Query/Funders RPC method. +message QueryFundersResponse { + // pagination defines the pagination in the response. + cosmos.base.query.v1beta1.PageResponse pagination = 1; + // funders ... + repeated Funder funders = 2 [(gogoproto.nullable) = false]; +} + +// ============ +// /funder/{id} +// ============ + +// QueryFunderRequest is the request type for the Query/Funder RPC method. +message QueryFunderRequest { + // address ... + string address = 1; + // status ... + FundingStatus status = 3; +} + +// QueryFunderResponse is the response type for the Query/Funder RPC method. +message QueryFunderResponse { + // funder ... + Funder funder = 1; + // fundings ... + repeated Funding fundings = 2 [(gogoproto.nullable) = false]; +} + +// ======================== +// /fundings_by_funder/{id} +// ======================== + +// QueryFundingsByFunderRequest is the request type for the Query/FundingsByFunder RPC method. +message QueryFundingsByFunderRequest { + // pagination defines an optional pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 1; + // address ... + string address = 2; + // status ... + FundingStatus status = 3; +} + +// QueryFundingsByFunderResponse is the response type for the Query/FundingsByFunder RPC method. +message QueryFundingsByFunderResponse { + // pagination defines the pagination in the response. + cosmos.base.query.v1beta1.PageResponse pagination = 1; + // fundings ... + repeated Funding fundings = 2 [(gogoproto.nullable) = false]; +} + +// ====================== +// /fundings_by_pool/{id} +// ====================== + +// QueryFundingsByPoolRequest is the request type for the Query/FundingsByPool RPC method. +message QueryFundingsByPoolRequest { + // pagination defines an optional pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 1; + // pool_id ... + uint64 pool_id = 2; + // status ... + FundingStatus status = 3; +} + +// QueryFundingsByPoolResponse is the response type for the Query/FundingsByPool RPC method. +message QueryFundingsByPoolResponse { + // pagination defines the pagination in the response. + cosmos.base.query.v1beta1.PageResponse pagination = 1; + // fundings ... + repeated Funding fundings = 2 [(gogoproto.nullable) = false]; +} diff --git a/proto/kyve/query/v1beta1/params.proto b/proto/kyve/query/v1beta1/params.proto index 7d9381fe..799ae5b5 100644 --- a/proto/kyve/query/v1beta1/params.proto +++ b/proto/kyve/query/v1beta1/params.proto @@ -6,13 +6,14 @@ import "cosmos/gov/v1/gov.proto"; import "google/api/annotations.proto"; import "kyve/bundles/v1beta1/params.proto"; import "kyve/delegation/v1beta1/params.proto"; +import "kyve/funders/v1beta1/params.proto"; import "kyve/global/v1beta1/global.proto"; import "kyve/pool/v1beta1/params.proto"; import "kyve/stakers/v1beta1/params.proto"; option go_package = "github.com/KYVENetwork/chain/x/query/types"; -// QueryPool ... +// QueryParams ... service QueryParams { // Pools queries for all pools. rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { @@ -41,4 +42,6 @@ message QueryParamsResponse { kyve.stakers.v1beta1.Params stakers_params = 5; // pool_params ... kyve.pool.v1beta1.Params pool_params = 6; + // funders_params ... + kyve.funders.v1beta1.Params funders_params = 7; } diff --git a/proto/kyve/query/v1beta1/query.proto b/proto/kyve/query/v1beta1/query.proto index b8033a71..cc150e36 100644 --- a/proto/kyve/query/v1beta1/query.proto +++ b/proto/kyve/query/v1beta1/query.proto @@ -38,8 +38,8 @@ message BasicPool { // logo of the pool string logo = 4; - // operating_cost is the base payout for each bundle reward - uint64 operating_cost = 5; + // inflation_share_weight is the base payout for each bundle reward + uint64 inflation_share_weight = 5; // upload_interval is the interval bundles get created uint64 upload_interval = 6; diff --git a/testutil/integration/checks.go b/testutil/integration/checks.go index 446fcf29..373970b3 100644 --- a/testutil/integration/checks.go +++ b/testutil/integration/checks.go @@ -3,6 +3,9 @@ package integration import ( "time" + "github.com/KYVENetwork/chain/x/funders" + funderstypes "github.com/KYVENetwork/chain/x/funders/types" + "github.com/KYVENetwork/chain/x/bundles" bundlesTypes "github.com/KYVENetwork/chain/x/bundles/types" "github.com/KYVENetwork/chain/x/delegation" @@ -16,17 +19,20 @@ import ( "github.com/cosmos/cosmos-sdk/types/query" . "github.com/onsi/gomega" - pooltypes "github.com/KYVENetwork/chain/x/pool/types" sdk "github.com/cosmos/cosmos-sdk/types" ) func (suite *KeeperTestSuite) PerformValidityChecks() { // verify pool module - suite.VerifyPoolModuleAssetsIntegrity() - suite.VerifyPoolTotalFunds() + suite.VerifyPoolModuleFundingStates() suite.VerifyPoolQueries() suite.VerifyPoolGenesisImportExport() + // verify funders module + suite.VerifyFundersGenesisImportExport() + suite.VerifyFundersModuleIntegrity() + suite.VerifyFundersModuleAssetsIntegrity() + // verify stakers module suite.VerifyStakersGenesisImportExport() suite.VerifyStakersModuleAssetsIntegrity() @@ -52,33 +58,11 @@ func (suite *KeeperTestSuite) PerformValidityChecks() { // pool module checks // ================== -func (suite *KeeperTestSuite) VerifyPoolModuleAssetsIntegrity() { - expectedBalance := uint64(0) - actualBalance := uint64(0) - - for _, pool := range suite.App().PoolKeeper.GetAllPools(suite.Ctx()) { - // pool funds should be in pool module - for _, funder := range pool.Funders { - expectedBalance += funder.Amount - } - } - - moduleAcc := suite.App().AccountKeeper.GetModuleAccount(suite.Ctx(), pooltypes.ModuleName).GetAddress() - actualBalance = suite.App().BankKeeper.GetBalance(suite.Ctx(), moduleAcc, globalTypes.Denom).Amount.Uint64() - - Expect(actualBalance).To(Equal(expectedBalance)) -} - -func (suite *KeeperTestSuite) VerifyPoolTotalFunds() { - for _, pool := range suite.App().PoolKeeper.GetAllPools(suite.Ctx()) { - expectedBalance := uint64(0) - actualBalance := pool.TotalFunds - - for _, funder := range pool.Funders { - expectedBalance += funder.Amount - } - - Expect(actualBalance).To(Equal(expectedBalance)) +func (suite *KeeperTestSuite) VerifyPoolModuleFundingStates() { + // every pool must have a funding state + for _, p := range suite.App().PoolKeeper.GetAllPools(suite.Ctx()) { + found := suite.App().FundersKeeper.DoesFundingStateExist(suite.Ctx(), p.Id) + Expect(found).To(BeTrue()) } } @@ -438,6 +422,92 @@ func (suite *KeeperTestSuite) VerifyTeamGenesisImportExport() { team.InitGenesis(suite.Ctx(), suite.App().TeamKeeper, *genState) } +// ======================== +// funders module checks +// ======================== + +func (suite *KeeperTestSuite) VerifyFundersGenesisImportExport() { + genState := funders.ExportGenesis(suite.Ctx(), suite.App().FundersKeeper) + + // Delete all entries in Funders Store + store := suite.Ctx().KVStore(suite.App().FundersKeeper.StoreKey()) + suite.deleteStore(store) + + err := genState.Validate() + Expect(err).To(BeNil()) + funders.InitGenesis(suite.Ctx(), suite.App().FundersKeeper, *genState) +} + +func (suite *KeeperTestSuite) VerifyFundersModuleIntegrity() { + funderAddresses := make(map[string]bool) + for _, funder := range suite.App().FundersKeeper.GetAllFunders(suite.Ctx()) { + funderAddresses[funder.Address] = true + } + + allActiveFundings := make(map[string]bool) + for _, funding := range suite.App().FundersKeeper.GetAllFundings(suite.Ctx()) { + // check if funding has a valid funder + _, found := funderAddresses[funding.FunderAddress] + Expect(found).To(BeTrue()) + + // check if funding is active + if funding.Amount > 0 { + key := string(funderstypes.FundingKeyByFunder(funding.FunderAddress, funding.PoolId)) + allActiveFundings[key] = true + } + + // check if pool exists + _, found = suite.App().PoolKeeper.GetPool(suite.Ctx(), funding.PoolId) + Expect(found).To(BeTrue()) + } + + for _, fundingState := range suite.App().FundersKeeper.GetAllFundingStates(suite.Ctx()) { + fsActiveAddresses := make(map[string]bool) + for _, funderAddress := range fundingState.ActiveFunderAddresses { + // check if funding has a valid funder + key := funderstypes.FundingKeyByFunder(funderAddress, fundingState.PoolId) + _, found := allActiveFundings[string(key)] + Expect(found).To(BeTrue()) + + // check if funder is not already in the list + Expect(fsActiveAddresses[funderAddress]).To(BeFalse()) + fsActiveAddresses[funderAddress] = true + } + + // check if the amount of active fundings is equal to the amount of active funder addresses + activeFundings := suite.App().FundersKeeper.GetActiveFundings(suite.Ctx(), fundingState) + Expect(activeFundings).To(HaveLen(len(fundingState.ActiveFunderAddresses))) + + // be lower or equal to max funders + Expect(len(fundingState.ActiveFunderAddresses)).To(BeNumerically("<=", funderstypes.MaxFunders)) + } +} + +func (suite *KeeperTestSuite) VerifyFundersModuleAssetsIntegrity() { + expectedBalance := uint64(0) + for _, funding := range suite.App().FundersKeeper.GetAllFundings(suite.Ctx()) { + expectedBalance += funding.Amount + } + + expectedFundingStateTotalAmount := uint64(0) + for _, fundingState := range suite.App().FundersKeeper.GetAllFundingStates(suite.Ctx()) { + activeFundings := suite.App().FundersKeeper.GetActiveFundings(suite.Ctx(), fundingState) + totalAmount := uint64(0) + for _, activeFunding := range activeFundings { + totalAmount += activeFunding.Amount + } + totalActiveFunding := suite.App().FundersKeeper.GetTotalActiveFunding(suite.ctx, fundingState.PoolId) + Expect(totalAmount).To(Equal(totalActiveFunding)) + expectedFundingStateTotalAmount += totalAmount + } + + // total amount of fundings should be equal to the amount of the funders module account + moduleAcc := suite.App().AccountKeeper.GetModuleAccount(suite.Ctx(), funderstypes.ModuleName).GetAddress() + actualBalance := suite.App().BankKeeper.GetBalance(suite.Ctx(), moduleAcc, globalTypes.Denom).Amount.Uint64() + Expect(actualBalance).To(Equal(expectedBalance)) + Expect(actualBalance).To(Equal(expectedFundingStateTotalAmount)) +} + // ======================== // helpers // ======================== @@ -492,10 +562,14 @@ func (suite *KeeperTestSuite) verifyFullStaker(fullStaker querytypes.FullStaker, Expect(found).To(BeTrue()) Expect(poolMembership.Pool.Id).To(Equal(pool.Id)) Expect(poolMembership.Pool.Logo).To(Equal(pool.Logo)) - Expect(poolMembership.Pool.TotalFunds).To(Equal(pool.TotalFunds)) + + fundingState, found := suite.App().FundersKeeper.GetFundingState(suite.Ctx(), poolMembership.Pool.Id) + Expect(found).To(BeTrue()) + Expect(poolMembership.Pool.TotalFunds).To(Equal(suite.App().FundersKeeper.GetTotalActiveFunding(suite.Ctx(), fundingState.PoolId))) Expect(poolMembership.Pool.Name).To(Equal(pool.Name)) Expect(poolMembership.Pool.Runtime).To(Equal(pool.Runtime)) Expect(poolMembership.Pool.Status).To(Equal(suite.App().QueryKeeper.GetPoolStatus(suite.Ctx(), &pool))) + Expect(poolMembership.Pool.Status).To(Equal(suite.App().QueryKeeper.GetPoolStatus(suite.Ctx(), &pool))) } // Reverse check the pool memberships diff --git a/testutil/integration/transactions.go b/testutil/integration/transactions.go index 3dce58be..cf09b998 100644 --- a/testutil/integration/transactions.go +++ b/testutil/integration/transactions.go @@ -92,3 +92,13 @@ func (suite *KeeperTestSuite) RunTxTeamError(msg sdk.Msg) { _, err := suite.RunTx(msg) Expect(err).To(HaveOccurred()) } + +func (suite *KeeperTestSuite) RunTxFundersSuccess(msg sdk.Msg) { + _, err := suite.RunTx(msg) + Expect(err).NotTo(HaveOccurred()) +} + +func (suite *KeeperTestSuite) RunTxFundersError(msg sdk.Msg) { + _, err := suite.RunTx(msg) + Expect(err).To(HaveOccurred()) +} diff --git a/testutil/keeper/funders.go b/testutil/keeper/funders.go new file mode 100644 index 00000000..9a511ee6 --- /dev/null +++ b/testutil/keeper/funders.go @@ -0,0 +1,56 @@ +package keeper + +import ( + "testing" + + "github.com/KYVENetwork/chain/x/funders/keeper" + "github.com/KYVENetwork/chain/x/funders/types" + tmdb "github.com/cometbft/cometbft-db" + "github.com/cometbft/cometbft/libs/log" + tmproto "github.com/cometbft/cometbft/proto/tendermint/types" + "github.com/cosmos/cosmos-sdk/codec" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/store" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + typesparams "github.com/cosmos/cosmos-sdk/x/params/types" + "github.com/stretchr/testify/require" +) + +func FundersKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) { + storeKey := sdk.NewKVStoreKey(types.StoreKey) + memStoreKey := storetypes.NewMemoryStoreKey(types.MemStoreKey) + + db := tmdb.NewMemDB() + stateStore := store.NewCommitMultiStore(db) + stateStore.MountStoreWithDB(storeKey, storetypes.StoreTypeIAVL, db) + stateStore.MountStoreWithDB(memStoreKey, storetypes.StoreTypeMemory, nil) + require.NoError(t, stateStore.LoadLatestVersion()) + + registry := codectypes.NewInterfaceRegistry() + cdc := codec.NewProtoCodec(registry) + + paramsSubspace := typesparams.NewSubspace(cdc, + types.Amino, + storeKey, + memStoreKey, + "FundersParams", + ) + k := keeper.NewKeeper( + cdc, + storeKey, + memStoreKey, + "authority", + nil, + nil, + nil, + nil, + ) + _ = paramsSubspace + ctx := sdk.NewContext(stateStore, tmproto.Header{}, false, log.NewNopLogger()) + + // Initialize params + k.SetParams(ctx, types.DefaultParams()) + + return k, ctx +} diff --git a/tools/tools.go b/tools/tools.go index 4e24981a..26ec7364 100644 --- a/tools/tools.go +++ b/tools/tools.go @@ -1,5 +1,4 @@ //go:build tools -// +build tools // This file uses the recommended method for tracking developer tools in a Go module. // diff --git a/x/bundles/abci.go b/x/bundles/abci.go index 245607a1..b6fc9ebe 100644 --- a/x/bundles/abci.go +++ b/x/bundles/abci.go @@ -39,26 +39,29 @@ func SplitInflation(ctx sdk.Context, k bundlesKeeper.Keeper, bk bankKeeper.Keepe // track actual distributed block provision for protocol distributed := uint64(0) - // calculate total operating cost of pools to get each pool's reward share - totalOperatingCost := uint64(0) + // calculate total inflation share weight of pools to get each pool's reward share + totalInflationShareWeight := uint64(0) for _, pool := range pk.GetAllPools(ctx) { // only include active pools if err := k.AssertPoolCanRun(ctx, pool.Id); err == nil { - totalOperatingCost += pool.OperatingCost + totalInflationShareWeight += pool.InflationShareWeight } } - // if the total operating cost is zero all rewards go the chain - if totalOperatingCost == 0 { + // if the total inflation share weight is zero all rewards go the chain + if totalInflationShareWeight == 0 { return } for _, pool := range pk.GetAllPools(ctx) { // only include active pools if err := k.AssertPoolCanRun(ctx, pool.Id); err == nil { - // calculate pool share based of operating cost - amount := uint64(sdk.NewDec(int64(pool.OperatingCost)).Quo(sdk.NewDec(int64(totalOperatingCost))).Mul(sdk.NewDec(protocolBlockProvision)).TruncateInt64()) + // calculate pool share based of inflation share weight + amount := uint64(sdk.NewDec(int64(pool.InflationShareWeight)). + Quo(sdk.NewDec(int64(totalInflationShareWeight))). + Mul(sdk.NewDec(protocolBlockProvision)). + TruncateInt64()) // transfer funds to pool account if err := util.TransferFromModuleToAddress(bk, ctx, authTypes.FeeCollectorName, pool.GetPoolAccount().String(), amount); err != nil { diff --git a/x/bundles/keeper/abci_protocol_split_test.go b/x/bundles/keeper/abci_protocol_split_test.go index 4ee4ba3e..bac5b8cb 100644 --- a/x/bundles/keeper/abci_protocol_split_test.go +++ b/x/bundles/keeper/abci_protocol_split_test.go @@ -3,7 +3,7 @@ package keeper_test import ( i "github.com/KYVENetwork/chain/testutil/integration" globalTypes "github.com/KYVENetwork/chain/x/global/types" - poolTypes "github.com/KYVENetwork/chain/x/pool/types" + pooltypes "github.com/KYVENetwork/chain/x/pool/types" stakertypes "github.com/KYVENetwork/chain/x/stakers/types" sdk "github.com/cosmos/cosmos-sdk/types" . "github.com/onsi/ginkgo/v2" @@ -16,37 +16,42 @@ TEST CASES - abci.go * inactive pool should not receive inflation funds * active pool should receive inflation funds -* pool should split inflation funds depending on operating cost -* pools with zero operating cost should receive nothing -* every pool has zero operating cost +* pool should split inflation funds depending on inflation share weight +* pools with zero inflation share weight should receive nothing +* every pool has zero inflation share weight */ var _ = Describe("abci.go", Ordered, func() { s := i.NewCleanChain() + gov := s.App().GovKeeper.GetGovernanceAccount(s.Ctx()).GetAddress().String() BeforeEach(func() { s = i.NewCleanChain() - s.App().PoolKeeper.SetParams(s.Ctx(), poolTypes.Params{ + s.App().PoolKeeper.SetParams(s.Ctx(), pooltypes.Params{ ProtocolInflationShare: sdk.MustNewDecFromStr("0.1"), PoolInflationPayoutRate: sdk.MustNewDecFromStr("0.1"), }) - s.App().PoolKeeper.AppendPool(s.Ctx(), poolTypes.Pool{ - Name: "PoolTest", - MaxBundleSize: 100, - StartKey: "0", - UploadInterval: 60, - MinDelegation: 100 * i.KYVE, - OperatingCost: 1_000_000, - Protocol: &poolTypes.Protocol{ - Version: "0.0.0", - Binaries: "{}", - LastUpgrade: uint64(s.Ctx().BlockTime().Unix()), - }, - UpgradePlan: &poolTypes.UpgradePlan{}, - }) + // create clean pool for every test case + msg := &pooltypes.MsgCreatePool{ + Authority: gov, + Name: "PoolTest", + Runtime: "@kyve/test", + Logo: "ar://Tewyv2P5VEG8EJ6AUQORdqNTectY9hlOrWPK8wwo-aU", + Config: "ar://DgdB-2hLrxjhyEEbCML__dgZN5_uS7T6Z5XDkaFh3P0", + StartKey: "0", + UploadInterval: 60, + InflationShareWeight: 1_000_000, + MinDelegation: 100 * i.KYVE, + MaxBundleSize: 100, + Version: "0.0.0", + Binaries: "{}", + StorageProviderId: 2, + CompressionId: 1, + } + s.RunTxPoolSuccess(msg) }) AfterEach(func() { @@ -108,22 +113,25 @@ var _ = Describe("abci.go", Ordered, func() { } }) - It("pool should split inflation funds depending on operating cost", func() { + It("pool should split inflation funds depending on inflation share weight", func() { // ARRANGE - s.App().PoolKeeper.AppendPool(s.Ctx(), poolTypes.Pool{ - Name: "PoolTest2", - MaxBundleSize: 100, - StartKey: "0", - UploadInterval: 60, - MinDelegation: 100 * i.KYVE, - OperatingCost: 2_000_000, - Protocol: &poolTypes.Protocol{ - Version: "0.0.0", - Binaries: "{}", - LastUpgrade: uint64(s.Ctx().BlockTime().Unix()), - }, - UpgradePlan: &poolTypes.UpgradePlan{}, - }) + msg := &pooltypes.MsgCreatePool{ + Authority: gov, + Name: "PoolTest", + Runtime: "@kyve/test", + Logo: "ar://Tewyv2P5VEG8EJ6AUQORdqNTectY9hlOrWPK8wwo-aU", + Config: "ar://DgdB-2hLrxjhyEEbCML__dgZN5_uS7T6Z5XDkaFh3P0", + StartKey: "0", + UploadInterval: 60, + InflationShareWeight: 2_000_000, + MinDelegation: 100 * i.KYVE, + MaxBundleSize: 100, + Version: "0.0.0", + Binaries: "{}", + StorageProviderId: 2, + CompressionId: 1, + } + s.RunTxPoolSuccess(msg) s.RunTxStakersSuccess(&stakertypes.MsgCreateStaker{ Creator: i.STAKER_0, @@ -169,25 +177,28 @@ var _ = Describe("abci.go", Ordered, func() { b2 := uint64(s.App().BankKeeper.GetBalance(s.Ctx(), pool2.GetPoolAccount(), globalTypes.Denom).Amount.Int64()) // ASSERT - Expect(b1 * 2).To(BeNumerically("~", b2, 1)) + Expect(b1 * 2).To(BeNumerically("~", b2-10, b2+10)) }) - It("pools with zero operating cost should receive nothing", func() { + It("pools with zero inflation share weight should receive nothing", func() { // ARRANGE - s.App().PoolKeeper.AppendPool(s.Ctx(), poolTypes.Pool{ - Name: "PoolTest2", - MaxBundleSize: 100, - StartKey: "0", - UploadInterval: 60, - MinDelegation: 100 * i.KYVE, - OperatingCost: 0, - Protocol: &poolTypes.Protocol{ - Version: "0.0.0", - Binaries: "{}", - LastUpgrade: uint64(s.Ctx().BlockTime().Unix()), - }, - UpgradePlan: &poolTypes.UpgradePlan{}, - }) + msg := &pooltypes.MsgCreatePool{ + Authority: gov, + Name: "PoolTest", + Runtime: "@kyve/test", + Logo: "ar://Tewyv2P5VEG8EJ6AUQORdqNTectY9hlOrWPK8wwo-aU", + Config: "ar://DgdB-2hLrxjhyEEbCML__dgZN5_uS7T6Z5XDkaFh3P0", + StartKey: "0", + UploadInterval: 60, + InflationShareWeight: 0, + MinDelegation: 100 * i.KYVE, + MaxBundleSize: 100, + Version: "0.0.0", + Binaries: "{}", + StorageProviderId: 2, + CompressionId: 1, + } + s.RunTxPoolSuccess(msg) s.RunTxStakersSuccess(&stakertypes.MsgCreateStaker{ Creator: i.STAKER_0, @@ -225,41 +236,34 @@ var _ = Describe("abci.go", Ordered, func() { Expect(b2).To(BeZero()) }) - It("every pool has zero operating cost", func() { + It("every pool has zero inflation share weight", func() { // ARRANGE - s.App().PoolKeeper.SetPool(s.Ctx(), poolTypes.Pool{ - Id: 0, - Name: "PoolTest", - MaxBundleSize: 100, - StartKey: "0", - UploadInterval: 60, - OperatingCost: 0, - Protocol: &poolTypes.Protocol{ - Version: "0.0.0", - Binaries: "{}", - LastUpgrade: uint64(s.Ctx().BlockTime().Unix()), - }, - UpgradePlan: &poolTypes.UpgradePlan{}, - }) - - s.App().PoolKeeper.AppendPool(s.Ctx(), poolTypes.Pool{ - Name: "PoolTest2", - MaxBundleSize: 100, - StartKey: "0", - UploadInterval: 60, - OperatingCost: 0, - Protocol: &poolTypes.Protocol{ - Version: "0.0.0", - Binaries: "{}", - LastUpgrade: uint64(s.Ctx().BlockTime().Unix()), - }, - UpgradePlan: &poolTypes.UpgradePlan{}, - }) + pool1, _ := s.App().PoolKeeper.GetPool(s.Ctx(), 0) + pool1.InflationShareWeight = 0 + s.App().PoolKeeper.SetPool(s.Ctx(), pool1) + + msg := &pooltypes.MsgCreatePool{ + Authority: gov, + Name: "PoolTest", + Runtime: "@kyve/test", + Logo: "ar://Tewyv2P5VEG8EJ6AUQORdqNTectY9hlOrWPK8wwo-aU", + Config: "ar://DgdB-2hLrxjhyEEbCML__dgZN5_uS7T6Z5XDkaFh3P0", + StartKey: "0", + UploadInterval: 60, + InflationShareWeight: 0, + MinDelegation: 100 * i.KYVE, + MaxBundleSize: 100, + Version: "0.0.0", + Binaries: "{}", + StorageProviderId: 2, + CompressionId: 1, + } + s.RunTxPoolSuccess(msg) // ACT s.Commit() - pool1, _ := s.App().PoolKeeper.GetPool(s.Ctx(), 0) + pool1, _ = s.App().PoolKeeper.GetPool(s.Ctx(), 0) b1 := uint64(s.App().BankKeeper.GetBalance(s.Ctx(), pool1.GetPoolAccount(), globalTypes.Denom).Amount.Int64()) pool2, _ := s.App().PoolKeeper.GetPool(s.Ctx(), 1) diff --git a/x/bundles/keeper/keeper.go b/x/bundles/keeper/keeper.go index 35811cd4..24be1fd2 100644 --- a/x/bundles/keeper/keeper.go +++ b/x/bundles/keeper/keeper.go @@ -25,6 +25,7 @@ type ( poolKeeper types.PoolKeeper stakerKeeper types.StakerKeeper delegationKeeper types.DelegationKeeper + fundersKeeper types.FundersKeeper } ) @@ -41,6 +42,7 @@ func NewKeeper( poolKeeper types.PoolKeeper, stakerKeeper types.StakerKeeper, delegationKeeper types.DelegationKeeper, + fundersKeeper types.FundersKeeper, ) *Keeper { return &Keeper{ cdc: cdc, @@ -55,6 +57,7 @@ func NewKeeper( poolKeeper: poolKeeper, stakerKeeper: stakerKeeper, delegationKeeper: delegationKeeper, + fundersKeeper: fundersKeeper, } } diff --git a/x/bundles/keeper/keeper_suite_dropped_bundles_test.go b/x/bundles/keeper/keeper_suite_dropped_bundles_test.go index bc548eb3..1bf9aab6 100644 --- a/x/bundles/keeper/keeper_suite_dropped_bundles_test.go +++ b/x/bundles/keeper/keeper_suite_dropped_bundles_test.go @@ -1,6 +1,7 @@ package keeper_test import ( + funderstypes "github.com/KYVENetwork/chain/x/funders/types" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" @@ -32,24 +33,35 @@ var _ = Describe("dropped bundles", Ordered, func() { s = i.NewCleanChain() // create clean pool for every test case - s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{ - Name: "PoolTest", - MaxBundleSize: 100, - StartKey: "0", - UploadInterval: 60, - OperatingCost: 10_000, - Protocol: &pooltypes.Protocol{ - Version: "0.0.0", - Binaries: "{}", - LastUpgrade: uint64(s.Ctx().BlockTime().Unix()), - }, - UpgradePlan: &pooltypes.UpgradePlan{}, + gov := s.App().GovKeeper.GetGovernanceAccount(s.Ctx()).GetAddress().String() + msg := &pooltypes.MsgCreatePool{ + Authority: gov, + Name: "PoolTest", + Runtime: "@kyve/test", + Logo: "ar://Tewyv2P5VEG8EJ6AUQORdqNTectY9hlOrWPK8wwo-aU", + Config: "ar://DgdB-2hLrxjhyEEbCML__dgZN5_uS7T6Z5XDkaFh3P0", + StartKey: "0", + UploadInterval: 60, + InflationShareWeight: 10_000, + MinDelegation: 100 * i.KYVE, + MaxBundleSize: 100, + Version: "0.0.0", + Binaries: "{}", + StorageProviderId: 2, + CompressionId: 1, + } + s.RunTxPoolSuccess(msg) + + s.RunTxFundersSuccess(&funderstypes.MsgCreateFunder{ + Creator: i.ALICE, + Moniker: "Alice", }) - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ - Creator: i.ALICE, - Id: 0, - Amount: 100 * i.KYVE, + s.RunTxPoolSuccess(&funderstypes.MsgFundPool{ + Creator: i.ALICE, + PoolId: 0, + Amount: 100 * i.KYVE, + AmountPerBundle: 1 * i.KYVE, }) s.RunTxStakersSuccess(&stakertypes.MsgCreateStaker{ @@ -188,7 +200,10 @@ var _ = Describe("dropped bundles", Ordered, func() { // check pool funds pool, _ = s.App().PoolKeeper.GetPool(s.Ctx(), 0) - Expect(pool.Funders).To(HaveLen(1)) - Expect(pool.GetFunderAmount(i.ALICE)).To(Equal(100 * i.KYVE)) + fundingState, _ := s.App().FundersKeeper.GetFundingState(s.Ctx(), 0) + + // assert total pool funds + Expect(s.App().FundersKeeper.GetTotalActiveFunding(s.Ctx(), fundingState.PoolId)).To(Equal(100 * i.KYVE)) + Expect(fundingState.ActiveFunderAddresses).To(HaveLen(1)) }) }) diff --git a/x/bundles/keeper/keeper_suite_funding_bundles_test.go b/x/bundles/keeper/keeper_suite_funding_bundles_test.go index ad16c345..841a17f1 100644 --- a/x/bundles/keeper/keeper_suite_funding_bundles_test.go +++ b/x/bundles/keeper/keeper_suite_funding_bundles_test.go @@ -3,9 +3,9 @@ package keeper_test import ( i "github.com/KYVENetwork/chain/testutil/integration" bundletypes "github.com/KYVENetwork/chain/x/bundles/types" + funderstypes "github.com/KYVENetwork/chain/x/funders/types" pooltypes "github.com/KYVENetwork/chain/x/pool/types" stakertypes "github.com/KYVENetwork/chain/x/stakers/types" - sdk "github.com/cosmos/cosmos-sdk/types" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -18,7 +18,7 @@ TEST CASES - funding bundles * Produce a valid bundle with multiple funders and same funding amounts * Produce a valid bundle with multiple funders and different funding amounts * Produce a valid bundle with multiple funders and different funding amounts where not everyone can afford the funds -* Produce a valid bundle although the only funder can not pay for the bundle reward +* Produce a valid bundle although the only funder can not pay for the full bundle reward * Produce a valid bundle although multiple funders with same amount can not pay for the bundle reward * Produce a valid bundle although multiple funders with different amount can not pay for the bundle reward * Produce a valid bundle although there are no funders at all @@ -35,19 +35,38 @@ var _ = Describe("funding bundles", Ordered, func() { // init new clean chain s = i.NewCleanChain() + params := s.App().FundersKeeper.GetParams(s.Ctx()) + params.MinFundingMultiple = 0 + s.App().FundersKeeper.SetParams(s.Ctx(), params) + // create clean pool for every test case - s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{ - Name: "PoolTest", - MaxBundleSize: 100, - StartKey: "0", - UploadInterval: 60, - OperatingCost: 10_000, - Protocol: &pooltypes.Protocol{ - Version: "0.0.0", - Binaries: "{}", - LastUpgrade: uint64(s.Ctx().BlockTime().Unix()), - }, - UpgradePlan: &pooltypes.UpgradePlan{}, + gov := s.App().GovKeeper.GetGovernanceAccount(s.Ctx()).GetAddress().String() + msg := &pooltypes.MsgCreatePool{ + Authority: gov, + Name: "PoolTest", + Runtime: "@kyve/test", + Logo: "ar://Tewyv2P5VEG8EJ6AUQORdqNTectY9hlOrWPK8wwo-aU", + Config: "ar://DgdB-2hLrxjhyEEbCML__dgZN5_uS7T6Z5XDkaFh3P0", + StartKey: "0", + UploadInterval: 60, + InflationShareWeight: 10_000, + MinDelegation: 100 * i.KYVE, + MaxBundleSize: 100, + Version: "0.0.0", + Binaries: "{}", + StorageProviderId: 2, + CompressionId: 1, + } + s.RunTxPoolSuccess(msg) + + // create funders + s.RunTxFundersSuccess(&funderstypes.MsgCreateFunder{ + Creator: i.ALICE, + Moniker: "Alice", + }) + s.RunTxFundersSuccess(&funderstypes.MsgCreateFunder{ + Creator: i.BOB, + Moniker: "Bob", }) s.RunTxStakersSuccess(&stakertypes.MsgCreateStaker{ @@ -85,10 +104,11 @@ var _ = Describe("funding bundles", Ordered, func() { It("Produce a valid bundle with only one funder", func() { // ARRANGE - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ - Creator: i.ALICE, - Id: 0, - Amount: 100 * i.KYVE, + s.RunTxFundersSuccess(&funderstypes.MsgFundPool{ + Creator: i.ALICE, + PoolId: 0, + Amount: 100 * i.KYVE, + AmountPerBundle: 10 * i.KYVE, }) s.CommitAfterSeconds(60) @@ -139,14 +159,17 @@ var _ = Describe("funding bundles", Ordered, func() { Expect(pool.TotalBundles).To(Equal(uint64(1))) Expect(pool.CurrentKey).To(Equal("99")) - totalReward := pool.OperatingCost + fundingState, _ := s.App().FundersKeeper.GetFundingState(s.Ctx(), 0) // assert total pool funds - Expect(pool.TotalFunds).To(Equal(100*i.KYVE - totalReward)) - Expect(pool.Funders).To(HaveLen(1)) + Expect(s.App().FundersKeeper.GetTotalActiveFunding(s.Ctx(), fundingState.PoolId)).To(Equal(90 * i.KYVE)) + Expect(fundingState.ActiveFunderAddresses).To(HaveLen(1)) + + funding, _ := s.App().FundersKeeper.GetFunding(s.Ctx(), i.ALICE, 0) // assert individual funds - Expect(pool.GetFunderAmount(i.ALICE)).To(Equal(100*i.KYVE - totalReward)) + Expect(funding.Amount).To(Equal(90 * i.KYVE)) + Expect(funding.TotalFunded).To(Equal(10 * i.KYVE)) // assert individual balances balanceAlice := s.GetBalanceFromAddress(i.ALICE) @@ -155,16 +178,18 @@ var _ = Describe("funding bundles", Ordered, func() { It("Produce a valid bundle with multiple funders and same funding amounts", func() { // ARRANGE - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ - Creator: i.ALICE, - Id: 0, - Amount: 100 * i.KYVE, + s.RunTxFundersSuccess(&funderstypes.MsgFundPool{ + Creator: i.ALICE, + PoolId: 0, + Amount: 100 * i.KYVE, + AmountPerBundle: 10 * i.KYVE, }) - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ - Creator: i.BOB, - Id: 0, - Amount: 100 * i.KYVE, + s.RunTxFundersSuccess(&funderstypes.MsgFundPool{ + Creator: i.BOB, + PoolId: 0, + Amount: 100 * i.KYVE, + AmountPerBundle: 10 * i.KYVE, }) s.CommitAfterSeconds(60) @@ -215,18 +240,20 @@ var _ = Describe("funding bundles", Ordered, func() { Expect(pool.TotalBundles).To(Equal(uint64(1))) Expect(pool.CurrentKey).To(Equal("99")) - totalReward := pool.OperatingCost + fundingState, _ := s.App().FundersKeeper.GetFundingState(s.Ctx(), 0) // assert total pool funds - Expect(pool.TotalFunds).To(Equal(200*i.KYVE - totalReward)) - Expect(pool.Funders).To(HaveLen(2)) + Expect(s.App().FundersKeeper.GetTotalActiveFunding(s.Ctx(), fundingState.PoolId)).To(Equal(180 * i.KYVE)) + Expect(fundingState.ActiveFunderAddresses).To(HaveLen(2)) - // assert individual funds - fundersCharge := uint64(sdk.NewDec(int64(totalReward)).Quo(sdk.NewDec(2)).TruncateInt64()) - - Expect(pool.GetFunderAmount(i.ALICE)).To(Equal(100*i.KYVE - fundersCharge)) + fundingAlice, _ := s.App().FundersKeeper.GetFunding(s.Ctx(), i.ALICE, 0) + fundingBob, _ := s.App().FundersKeeper.GetFunding(s.Ctx(), i.BOB, 0) - Expect(pool.GetFunderAmount(i.BOB)).To(Equal(100*i.KYVE - fundersCharge)) + // assert individual funds + Expect(fundingAlice.Amount).To(Equal(90 * i.KYVE)) + Expect(fundingAlice.TotalFunded).To(Equal(10 * i.KYVE)) + Expect(fundingBob.Amount).To(Equal(90 * i.KYVE)) + Expect(fundingBob.TotalFunded).To(Equal(10 * i.KYVE)) // assert individual balances balanceAlice := s.GetBalanceFromAddress(i.ALICE) @@ -238,16 +265,18 @@ var _ = Describe("funding bundles", Ordered, func() { It("Produce a valid bundle with multiple funders and different funding amounts", func() { // ARRANGE - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ - Creator: i.ALICE, - Id: 0, - Amount: 150 * i.KYVE, + s.RunTxFundersSuccess(&funderstypes.MsgFundPool{ + Creator: i.ALICE, + PoolId: 0, + Amount: 150 * i.KYVE, + AmountPerBundle: 15 * i.KYVE, }) - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ - Creator: i.BOB, - Id: 0, - Amount: 50 * i.KYVE, + s.RunTxFundersSuccess(&funderstypes.MsgFundPool{ + Creator: i.BOB, + PoolId: 0, + Amount: 50 * i.KYVE, + AmountPerBundle: 5 * i.KYVE, }) s.CommitAfterSeconds(60) @@ -298,18 +327,20 @@ var _ = Describe("funding bundles", Ordered, func() { Expect(pool.TotalBundles).To(Equal(uint64(1))) Expect(pool.CurrentKey).To(Equal("99")) - totalReward := pool.OperatingCost + fundingState, _ := s.App().FundersKeeper.GetFundingState(s.Ctx(), 0) // assert total pool funds - Expect(pool.TotalFunds).To(Equal(200*i.KYVE - totalReward)) - Expect(pool.Funders).To(HaveLen(2)) + Expect(s.App().FundersKeeper.GetTotalActiveFunding(s.Ctx(), fundingState.PoolId)).To(Equal(180 * i.KYVE)) + Expect(fundingState.ActiveFunderAddresses).To(HaveLen(2)) - // assert individual funds - fundersCharge := uint64(sdk.NewDec(int64(totalReward)).Quo(sdk.NewDec(2)).TruncateInt64()) + fundingAlice, _ := s.App().FundersKeeper.GetFunding(s.Ctx(), i.ALICE, 0) + fundingBob, _ := s.App().FundersKeeper.GetFunding(s.Ctx(), i.BOB, 0) - Expect(pool.GetFunderAmount(i.ALICE)).To(Equal(150*i.KYVE - fundersCharge)) - - Expect(pool.GetFunderAmount(i.BOB)).To(Equal(50*i.KYVE - fundersCharge)) + // assert individual funds + Expect(fundingAlice.Amount).To(Equal(135 * i.KYVE)) + Expect(fundingAlice.TotalFunded).To(Equal(15 * i.KYVE)) + Expect(fundingBob.Amount).To(Equal(45 * i.KYVE)) + Expect(fundingBob.TotalFunded).To(Equal(5 * i.KYVE)) // assert individual balances balanceAlice := s.GetBalanceFromAddress(i.ALICE) @@ -319,18 +350,20 @@ var _ = Describe("funding bundles", Ordered, func() { Expect(balanceBob).To(Equal(initialBalanceBob - 50*i.KYVE)) }) - It("Produce a valid bundle with multiple funders and different funding amounts where not everyone can afford the funds", func() { + It("Produce a valid bundle with multiple funders and different funding amounts where not everyone can afford the full funds", func() { // ARRANGE - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ - Creator: i.ALICE, - Id: 0, - Amount: 10, + s.RunTxFundersSuccess(&funderstypes.MsgFundPool{ + Creator: i.ALICE, + PoolId: 0, + Amount: 10 * i.KYVE, + AmountPerBundle: 50 * i.KYVE, }) - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ - Creator: i.BOB, - Id: 0, - Amount: 100 * i.KYVE, + s.RunTxFundersSuccess(&funderstypes.MsgFundPool{ + Creator: i.BOB, + PoolId: 0, + Amount: 100 * i.KYVE, + AmountPerBundle: 50 * i.KYVE, }) s.CommitAfterSeconds(60) @@ -381,28 +414,37 @@ var _ = Describe("funding bundles", Ordered, func() { Expect(pool.TotalBundles).To(Equal(uint64(1))) Expect(pool.CurrentKey).To(Equal("99")) - totalReward := pool.OperatingCost + fundingState, _ := s.App().FundersKeeper.GetFundingState(s.Ctx(), 0) // assert total pool funds - Expect(pool.TotalFunds).To(Equal(100*i.KYVE - (totalReward / 2))) - Expect(pool.Funders).To(HaveLen(1)) + Expect(s.App().FundersKeeper.GetTotalActiveFunding(s.Ctx(), fundingState.PoolId)).To(Equal(50 * i.KYVE)) + Expect(fundingState.ActiveFunderAddresses).To(HaveLen(1)) + Expect(fundingState.ActiveFunderAddresses[0]).To(Equal(i.BOB)) - Expect(pool.GetFunderAmount(i.BOB)).To(Equal(100*i.KYVE - (totalReward / 2))) + fundingAlice, _ := s.App().FundersKeeper.GetFunding(s.Ctx(), i.ALICE, 0) + fundingBob, _ := s.App().FundersKeeper.GetFunding(s.Ctx(), i.BOB, 0) + + // assert individual funds + Expect(fundingAlice.Amount).To(Equal(0 * i.KYVE)) + Expect(fundingAlice.TotalFunded).To(Equal(10 * i.KYVE)) + Expect(fundingBob.Amount).To(Equal(50 * i.KYVE)) + Expect(fundingBob.TotalFunded).To(Equal(50 * i.KYVE)) // assert individual balances balanceAlice := s.GetBalanceFromAddress(i.ALICE) - Expect(balanceAlice).To(Equal(initialBalanceAlice - 10)) + Expect(balanceAlice).To(Equal(initialBalanceAlice - 10*i.KYVE)) balanceBob := s.GetBalanceFromAddress(i.BOB) Expect(balanceBob).To(Equal(initialBalanceBob - 100*i.KYVE)) }) - It("Produce a valid bundle although the only funder can not pay for the bundle reward", func() { + It("Produce a valid bundle although the only funder can not pay for the full bundle reward", func() { // ARRANGE - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ - Creator: i.ALICE, - Id: 0, - Amount: 10, + s.RunTxFundersSuccess(&funderstypes.MsgFundPool{ + Creator: i.ALICE, + PoolId: 0, + Amount: 10 * i.KYVE, + AmountPerBundle: 20 * i.KYVE, }) s.CommitAfterSeconds(60) @@ -453,27 +495,37 @@ var _ = Describe("funding bundles", Ordered, func() { Expect(pool.TotalBundles).To(Equal(uint64(1))) Expect(pool.CurrentKey).To(Equal("99")) + fundingState, _ := s.App().FundersKeeper.GetFundingState(s.Ctx(), 0) + // assert total pool funds - Expect(pool.TotalFunds).To(BeZero()) - Expect(pool.Funders).To(BeEmpty()) + Expect(s.App().FundersKeeper.GetTotalActiveFunding(s.Ctx(), fundingState.PoolId)).To(Equal(0 * i.KYVE)) + Expect(fundingState.ActiveFunderAddresses).To(HaveLen(0)) + + fundingAlice, _ := s.App().FundersKeeper.GetFunding(s.Ctx(), i.ALICE, 0) + + // assert individual funds + Expect(fundingAlice.Amount).To(Equal(0 * i.KYVE)) + Expect(fundingAlice.TotalFunded).To(Equal(10 * i.KYVE)) // assert individual balances balanceAlice := s.GetBalanceFromAddress(i.ALICE) - Expect(balanceAlice).To(Equal(initialBalanceAlice - 10)) + Expect(balanceAlice).To(Equal(initialBalanceAlice - 10*i.KYVE)) }) It("Produce a valid bundle although multiple funders with same amount can not pay for the bundle reward", func() { // ARRANGE - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ - Creator: i.ALICE, - Id: 0, - Amount: 10, + s.RunTxFundersSuccess(&funderstypes.MsgFundPool{ + Creator: i.ALICE, + PoolId: 0, + Amount: 10 * i.KYVE, + AmountPerBundle: 20 * i.KYVE, }) - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ - Creator: i.BOB, - Id: 0, - Amount: 10, + s.RunTxFundersSuccess(&funderstypes.MsgFundPool{ + Creator: i.BOB, + PoolId: 0, + Amount: 10 * i.KYVE, + AmountPerBundle: 20 * i.KYVE, }) s.CommitAfterSeconds(60) @@ -525,29 +577,34 @@ var _ = Describe("funding bundles", Ordered, func() { Expect(pool.CurrentKey).To(Equal("99")) // assert total pool funds - Expect(pool.TotalFunds).To(BeZero()) - Expect(pool.Funders).To(BeEmpty()) + fundingState, _ := s.App().FundersKeeper.GetFundingState(s.Ctx(), 0) + + // assert total pool funds + Expect(s.App().FundersKeeper.GetTotalActiveFunding(s.Ctx(), fundingState.PoolId)).To(Equal(uint64(0))) + Expect(fundingState.ActiveFunderAddresses).To(HaveLen(0)) // assert individual balances balanceAlice := s.GetBalanceFromAddress(i.ALICE) - Expect(balanceAlice).To(Equal(initialBalanceAlice - 10)) + Expect(balanceAlice).To(Equal(initialBalanceAlice - 10*i.KYVE)) balanceBob := s.GetBalanceFromAddress(i.BOB) - Expect(balanceBob).To(Equal(initialBalanceBob - 10)) + Expect(balanceBob).To(Equal(initialBalanceBob - 10*i.KYVE)) }) It("Produce a dropped bundle because multiple funders with different amount can not pay for the bundle reward", func() { // ARRANGE - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ - Creator: i.ALICE, - Id: 0, - Amount: 10, + s.RunTxFundersSuccess(&funderstypes.MsgFundPool{ + Creator: i.ALICE, + PoolId: 0, + Amount: 10 * i.KYVE, + AmountPerBundle: 10 * i.KYVE, }) - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ - Creator: i.BOB, - Id: 0, - Amount: 20, + s.RunTxFundersSuccess(&funderstypes.MsgFundPool{ + Creator: i.BOB, + PoolId: 0, + Amount: 20 * i.KYVE, + AmountPerBundle: 20 * i.KYVE, }) s.CommitAfterSeconds(60) @@ -598,16 +655,21 @@ var _ = Describe("funding bundles", Ordered, func() { Expect(pool.TotalBundles).To(Equal(uint64(1))) Expect(pool.CurrentKey).To(Equal("99")) + fundingState, _ := s.App().FundersKeeper.GetFundingState(s.Ctx(), 0) + // assert total pool funds - Expect(pool.TotalFunds).To(BeZero()) - Expect(pool.Funders).To(BeEmpty()) + Expect(s.App().FundersKeeper.GetTotalActiveFunding(s.Ctx(), fundingState.PoolId)).To(Equal(0 * i.KYVE)) + Expect(fundingState.ActiveFunderAddresses).To(HaveLen(0)) + + fundingAlice, _ := s.App().FundersKeeper.GetFunding(s.Ctx(), i.ALICE, 0) + + // assert individual funds + Expect(fundingAlice.Amount).To(Equal(0 * i.KYVE)) + Expect(fundingAlice.TotalFunded).To(Equal(10 * i.KYVE)) // assert individual balances balanceAlice := s.GetBalanceFromAddress(i.ALICE) - Expect(balanceAlice).To(Equal(initialBalanceAlice - 10)) - - balanceBob := s.GetBalanceFromAddress(i.BOB) - Expect(balanceBob).To(Equal(initialBalanceBob - 20)) + Expect(balanceAlice).To(Equal(initialBalanceAlice - 10*i.KYVE)) }) It("Produce a valid bundle although there are no funders at all", func() { @@ -636,11 +698,11 @@ var _ = Describe("funding bundles", Ordered, func() { Vote: 1, }) - pool, _ := s.App().PoolKeeper.GetPool(s.Ctx(), 0) + fundingState, _ := s.App().FundersKeeper.GetFundingState(s.Ctx(), 0) // assert total pool funds - Expect(pool.TotalFunds).To(BeZero()) - Expect(pool.Funders).To(BeEmpty()) + Expect(s.App().FundersKeeper.GetTotalActiveFunding(s.Ctx(), fundingState.PoolId)).To(Equal(0 * i.KYVE)) + Expect(fundingState.ActiveFunderAddresses).To(HaveLen(0)) s.CommitAfterSeconds(60) @@ -660,14 +722,16 @@ var _ = Describe("funding bundles", Ordered, func() { }) // ASSERT - pool, _ = s.App().PoolKeeper.GetPool(s.Ctx(), 0) + pool, _ := s.App().PoolKeeper.GetPool(s.Ctx(), 0) // assert if bundle go finalized Expect(pool.TotalBundles).To(Equal(uint64(1))) Expect(pool.CurrentKey).To(Equal("99")) + fundingState, _ = s.App().FundersKeeper.GetFundingState(s.Ctx(), 0) + // assert total pool funds - Expect(pool.TotalFunds).To(BeZero()) - Expect(pool.Funders).To(BeEmpty()) + Expect(s.App().FundersKeeper.GetTotalActiveFunding(s.Ctx(), fundingState.PoolId)).To(Equal(0 * i.KYVE)) + Expect(fundingState.ActiveFunderAddresses).To(HaveLen(0)) }) }) diff --git a/x/bundles/keeper/keeper_suite_inflation_splitting_test.go b/x/bundles/keeper/keeper_suite_inflation_splitting_test.go index 877d1e16..7958fc25 100644 --- a/x/bundles/keeper/keeper_suite_inflation_splitting_test.go +++ b/x/bundles/keeper/keeper_suite_inflation_splitting_test.go @@ -3,6 +3,7 @@ package keeper_test import ( i "github.com/KYVENetwork/chain/testutil/integration" bundletypes "github.com/KYVENetwork/chain/x/bundles/types" + funderstypes "github.com/KYVENetwork/chain/x/funders/types" pooltypes "github.com/KYVENetwork/chain/x/pool/types" stakertypes "github.com/KYVENetwork/chain/x/stakers/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -40,18 +41,39 @@ var _ = Describe("inflation splitting", Ordered, func() { s = i.NewCleanChain() // create clean pool for every test case - s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{ - Name: "PoolTest", - MaxBundleSize: 100, - StartKey: "0", - UploadInterval: 60, - OperatingCost: 10_000, - Protocol: &pooltypes.Protocol{ - Version: "0.0.0", - Binaries: "{}", - LastUpgrade: uint64(s.Ctx().BlockTime().Unix()), - }, - UpgradePlan: &pooltypes.UpgradePlan{}, + gov := s.App().GovKeeper.GetGovernanceAccount(s.Ctx()).GetAddress().String() + msg := &pooltypes.MsgCreatePool{ + Authority: gov, + Name: "PoolTest", + Runtime: "@kyve/test", + Logo: "ar://Tewyv2P5VEG8EJ6AUQORdqNTectY9hlOrWPK8wwo-aU", + Config: "ar://DgdB-2hLrxjhyEEbCML__dgZN5_uS7T6Z5XDkaFh3P0", + StartKey: "0", + UploadInterval: 60, + InflationShareWeight: 10_000, + MinDelegation: 100 * i.KYVE, + MaxBundleSize: 100, + Version: "0.0.0", + Binaries: "{}", + StorageProviderId: 2, + CompressionId: 1, + } + s.RunTxPoolSuccess(msg) + + params := s.App().FundersKeeper.GetParams(s.Ctx()) + params.MinFundingAmountPerBundle = 1_000 + params.MinFundingAmount = 100 + params.MinFundingMultiple = 0 + s.App().FundersKeeper.SetParams(s.Ctx(), params) + + // create funders + s.RunTxFundersSuccess(&funderstypes.MsgCreateFunder{ + Creator: i.ALICE, + Moniker: "Alice", + }) + s.RunTxFundersSuccess(&funderstypes.MsgCreateFunder{ + Creator: i.BOB, + Moniker: "Bob", }) s.RunTxStakersSuccess(&stakertypes.MsgCreateStaker{ @@ -162,9 +184,11 @@ var _ = Describe("inflation splitting", Ordered, func() { // assert uploader self delegation rewards Expect(s.App().DelegationKeeper.GetOutstandingRewards(s.Ctx(), i.STAKER_0, i.STAKER_0)).To(BeZero()) + fundingState, _ := s.App().FundersKeeper.GetFundingState(s.Ctx(), 0) + // assert total pool funds - Expect(pool.TotalFunds).To(BeZero()) - Expect(pool.Funders).To(BeEmpty()) + Expect(s.App().FundersKeeper.GetTotalActiveFunding(s.Ctx(), fundingState.PoolId)).To(BeZero()) + Expect(fundingState.ActiveFunderAddresses).To(BeEmpty()) }) It("Produce a valid bundle with no funders and 10% inflation splitting", func() { @@ -253,9 +277,11 @@ var _ = Describe("inflation splitting", Ordered, func() { // assert uploader self delegation rewards Expect(s.App().DelegationKeeper.GetOutstandingRewards(s.Ctx(), i.STAKER_0, i.STAKER_0)).To(Equal(uploaderDelegationReward)) + fundingState, _ := s.App().FundersKeeper.GetFundingState(s.Ctx(), 0) + // assert total pool funds - Expect(pool.TotalFunds).To(BeZero()) - Expect(pool.Funders).To(BeEmpty()) + Expect(s.App().FundersKeeper.GetTotalActiveFunding(s.Ctx(), fundingState.PoolId)).To(BeZero()) + Expect(fundingState.ActiveFunderAddresses).To(BeEmpty()) }) It("Produce a valid bundle with no funders and 100% inflation splitting", func() { @@ -344,9 +370,11 @@ var _ = Describe("inflation splitting", Ordered, func() { // assert uploader self delegation rewards Expect(s.App().DelegationKeeper.GetOutstandingRewards(s.Ctx(), i.STAKER_0, i.STAKER_0)).To(Equal(uploaderDelegationReward)) + fundingState, _ := s.App().FundersKeeper.GetFundingState(s.Ctx(), 0) + // assert total pool funds - Expect(pool.TotalFunds).To(BeZero()) - Expect(pool.Funders).To(BeEmpty()) + Expect(s.App().FundersKeeper.GetTotalActiveFunding(s.Ctx(), fundingState.PoolId)).To(BeZero()) + Expect(fundingState.ActiveFunderAddresses).To(BeEmpty()) }) It("Produce a valid bundle with sufficient funders and 0% inflation splitting", func() { @@ -361,16 +389,18 @@ var _ = Describe("inflation splitting", Ordered, func() { s.Commit() } - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ - Creator: i.ALICE, - Id: 0, - Amount: 100 * i.KYVE, + s.RunTxFundersSuccess(&funderstypes.MsgFundPool{ + Creator: i.ALICE, + PoolId: 0, + Amount: 100 * i.KYVE, + AmountPerBundle: 5_000, }) - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ - Creator: i.BOB, - Id: 0, - Amount: 100 * i.KYVE, + s.RunTxFundersSuccess(&funderstypes.MsgFundPool{ + Creator: i.BOB, + PoolId: 0, + Amount: 100 * i.KYVE, + AmountPerBundle: 5_000, }) s.RunTxBundlesSuccess(&bundletypes.MsgSubmitBundleProposal{ @@ -429,9 +459,9 @@ var _ = Describe("inflation splitting", Ordered, func() { // assert bundle reward uploader, _ := s.App().StakersKeeper.GetStaker(s.Ctx(), i.STAKER_0) - // the total payout is the operating cost because the funding is sufficient + // the total payout is the inflation share weight because the funding is sufficient // and there is no additional inflation - totalPayout := pool.OperatingCost + totalPayout := pool.InflationShareWeight networkFee := s.App().BundlesKeeper.GetNetworkFee(s.Ctx()) treasuryReward := uint64(sdk.NewDec(int64(totalPayout)).Mul(networkFee).TruncateInt64()) @@ -446,9 +476,11 @@ var _ = Describe("inflation splitting", Ordered, func() { // assert uploader self delegation rewards Expect(s.App().DelegationKeeper.GetOutstandingRewards(s.Ctx(), i.STAKER_0, i.STAKER_0)).To(Equal(uploaderDelegationReward)) + fundingState, _ := s.App().FundersKeeper.GetFundingState(s.Ctx(), 0) + // assert total pool funds - Expect(pool.TotalFunds).To(Equal(200*i.KYVE - totalPayout)) - Expect(pool.Funders).To(HaveLen(2)) + Expect(s.App().FundersKeeper.GetTotalActiveFunding(s.Ctx(), fundingState.PoolId)).To(Equal(200*i.KYVE - 10_000)) + Expect(fundingState.ActiveFunderAddresses).To(HaveLen(2)) }) It("Produce a valid bundle with sufficient funders and 10% inflation splitting", func() { @@ -463,16 +495,18 @@ var _ = Describe("inflation splitting", Ordered, func() { s.Commit() } - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ - Creator: i.ALICE, - Id: 0, - Amount: 100 * i.KYVE, + s.RunTxFundersSuccess(&funderstypes.MsgFundPool{ + Creator: i.ALICE, + PoolId: 0, + Amount: 100 * i.KYVE, + AmountPerBundle: 5_000, }) - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ - Creator: i.BOB, - Id: 0, - Amount: 100 * i.KYVE, + s.RunTxFundersSuccess(&funderstypes.MsgFundPool{ + Creator: i.BOB, + PoolId: 0, + Amount: 100 * i.KYVE, + AmountPerBundle: 5_000, }) s.RunTxBundlesSuccess(&bundletypes.MsgSubmitBundleProposal{ @@ -533,8 +567,8 @@ var _ = Describe("inflation splitting", Ordered, func() { // assert bundle reward uploader, _ := s.App().StakersKeeper.GetStaker(s.Ctx(), i.STAKER_0) - // the total payout is the operating cost plus the inflation payout - totalPayout := pool.OperatingCost + payout + // the total payout is the inflation share weight plus the inflation payout + totalPayout := pool.InflationShareWeight + payout networkFee := s.App().BundlesKeeper.GetNetworkFee(s.Ctx()) treasuryReward := uint64(sdk.NewDec(int64(totalPayout)).Mul(networkFee).TruncateInt64()) @@ -549,9 +583,11 @@ var _ = Describe("inflation splitting", Ordered, func() { // assert uploader self delegation rewards Expect(s.App().DelegationKeeper.GetOutstandingRewards(s.Ctx(), i.STAKER_0, i.STAKER_0)).To(Equal(uploaderDelegationReward)) + fundingState, _ := s.App().FundersKeeper.GetFundingState(s.Ctx(), 0) + // assert total pool funds - Expect(pool.TotalFunds).To(Equal(200*i.KYVE - pool.OperatingCost)) - Expect(pool.Funders).To(HaveLen(2)) + Expect(s.App().FundersKeeper.GetTotalActiveFunding(s.Ctx(), fundingState.PoolId)).To(Equal(200*i.KYVE - 10_000)) + Expect(fundingState.ActiveFunderAddresses).To(HaveLen(2)) }) It("Produce a valid bundle with sufficient funders and 100% inflation splitting", func() { @@ -566,16 +602,18 @@ var _ = Describe("inflation splitting", Ordered, func() { s.Commit() } - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ - Creator: i.ALICE, - Id: 0, - Amount: 100 * i.KYVE, + s.RunTxFundersSuccess(&funderstypes.MsgFundPool{ + Creator: i.ALICE, + PoolId: 0, + Amount: 100 * i.KYVE, + AmountPerBundle: 5_000, }) - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ - Creator: i.BOB, - Id: 0, - Amount: 100 * i.KYVE, + s.RunTxFundersSuccess(&funderstypes.MsgFundPool{ + Creator: i.BOB, + PoolId: 0, + Amount: 100 * i.KYVE, + AmountPerBundle: 5_000, }) s.RunTxBundlesSuccess(&bundletypes.MsgSubmitBundleProposal{ @@ -636,8 +674,8 @@ var _ = Describe("inflation splitting", Ordered, func() { // assert bundle reward uploader, _ := s.App().StakersKeeper.GetStaker(s.Ctx(), i.STAKER_0) - // the total payout is the operating cost plus the inflation payout - totalPayout := pool.OperatingCost + payout + // the total payout is the inflation share weight plus the inflation payout + totalPayout := pool.InflationShareWeight + payout networkFee := s.App().BundlesKeeper.GetNetworkFee(s.Ctx()) treasuryReward := uint64(sdk.NewDec(int64(totalPayout)).Mul(networkFee).TruncateInt64()) @@ -652,9 +690,11 @@ var _ = Describe("inflation splitting", Ordered, func() { // assert uploader self delegation rewards Expect(s.App().DelegationKeeper.GetOutstandingRewards(s.Ctx(), i.STAKER_0, i.STAKER_0)).To(Equal(uploaderDelegationReward)) + fundingState, _ := s.App().FundersKeeper.GetFundingState(s.Ctx(), 0) + // assert total pool funds - Expect(pool.TotalFunds).To(Equal(200*i.KYVE - pool.OperatingCost)) - Expect(pool.Funders).To(HaveLen(2)) + Expect(s.App().FundersKeeper.GetTotalActiveFunding(s.Ctx(), fundingState.PoolId)).To(Equal(200*i.KYVE - 10_000)) + Expect(fundingState.ActiveFunderAddresses).To(HaveLen(2)) }) It("Produce a valid bundle with insufficient funders and 0% inflation splitting", func() { @@ -669,16 +709,18 @@ var _ = Describe("inflation splitting", Ordered, func() { s.Commit() } - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ - Creator: i.ALICE, - Id: 0, - Amount: 100, + s.RunTxFundersSuccess(&funderstypes.MsgFundPool{ + Creator: i.ALICE, + PoolId: 0, + Amount: 100, + AmountPerBundle: 5_000, }) - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ - Creator: i.BOB, - Id: 0, - Amount: 200, + s.RunTxFundersSuccess(&funderstypes.MsgFundPool{ + Creator: i.BOB, + PoolId: 0, + Amount: 200, + AmountPerBundle: 5_000, }) s.RunTxBundlesSuccess(&bundletypes.MsgSubmitBundleProposal{ @@ -753,12 +795,14 @@ var _ = Describe("inflation splitting", Ordered, func() { // assert uploader self delegation rewards Expect(s.App().DelegationKeeper.GetOutstandingRewards(s.Ctx(), i.STAKER_0, i.STAKER_0)).To(Equal(uploaderDelegationReward)) + fundingState, _ := s.App().FundersKeeper.GetFundingState(s.Ctx(), 0) + // assert total pool funds - Expect(pool.TotalFunds).To(BeZero()) - Expect(pool.Funders).To(BeEmpty()) + Expect(s.App().FundersKeeper.GetTotalActiveFunding(s.Ctx(), fundingState.PoolId)).To(BeZero()) + Expect(fundingState.ActiveFunderAddresses).To(BeEmpty()) }) - It("Produce a valid bundle with insufficient funders and 10% inflation splitting", func() { + It("Produce a valid bundle with insufficient funders and 30% inflation splitting", func() { // ARRANGE s.App().PoolKeeper.SetParams(s.Ctx(), pooltypes.Params{ ProtocolInflationShare: sdk.MustNewDecFromStr("0.1"), @@ -770,16 +814,18 @@ var _ = Describe("inflation splitting", Ordered, func() { s.Commit() } - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ - Creator: i.ALICE, - Id: 0, - Amount: 100, + s.RunTxFundersSuccess(&funderstypes.MsgFundPool{ + Creator: i.ALICE, + PoolId: 0, + Amount: 100, + AmountPerBundle: 5_000, }) - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ - Creator: i.BOB, - Id: 0, - Amount: 200, + s.RunTxFundersSuccess(&funderstypes.MsgFundPool{ + Creator: i.BOB, + PoolId: 0, + Amount: 200, + AmountPerBundle: 5_000, }) s.RunTxBundlesSuccess(&bundletypes.MsgSubmitBundleProposal{ @@ -840,7 +886,7 @@ var _ = Describe("inflation splitting", Ordered, func() { // assert bundle reward uploader, _ := s.App().StakersKeeper.GetStaker(s.Ctx(), i.STAKER_0) - // the total payout is the operating cost plus the inflation payout + // the total payout is the inflation share weight plus the inflation payout totalPayout := 300 + payout networkFee := s.App().BundlesKeeper.GetNetworkFee(s.Ctx()) @@ -856,9 +902,11 @@ var _ = Describe("inflation splitting", Ordered, func() { // assert uploader self delegation rewards Expect(s.App().DelegationKeeper.GetOutstandingRewards(s.Ctx(), i.STAKER_0, i.STAKER_0)).To(Equal(uploaderDelegationReward)) + fundingState, _ := s.App().FundersKeeper.GetFundingState(s.Ctx(), 0) + // assert total pool funds - Expect(pool.TotalFunds).To(BeZero()) - Expect(pool.Funders).To(BeEmpty()) + Expect(s.App().FundersKeeper.GetTotalActiveFunding(s.Ctx(), fundingState.PoolId)).To(BeZero()) + Expect(fundingState.ActiveFunderAddresses).To(BeEmpty()) }) It("Produce a valid bundle with insufficient funders and 10% inflation splitting", func() { @@ -873,16 +921,18 @@ var _ = Describe("inflation splitting", Ordered, func() { s.Commit() } - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ - Creator: i.ALICE, - Id: 0, - Amount: 100, + s.RunTxFundersSuccess(&funderstypes.MsgFundPool{ + Creator: i.ALICE, + PoolId: 0, + Amount: 100, + AmountPerBundle: 5_000, }) - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ - Creator: i.BOB, - Id: 0, - Amount: 200, + s.RunTxFundersSuccess(&funderstypes.MsgFundPool{ + Creator: i.BOB, + PoolId: 0, + Amount: 200, + AmountPerBundle: 5_000, }) s.RunTxBundlesSuccess(&bundletypes.MsgSubmitBundleProposal{ @@ -943,7 +993,7 @@ var _ = Describe("inflation splitting", Ordered, func() { // assert bundle reward uploader, _ := s.App().StakersKeeper.GetStaker(s.Ctx(), i.STAKER_0) - // the total payout is the operating cost plus the inflation payout + // the total payout is the inflation share weight plus the inflation payout totalPayout := 300 + payout networkFee := s.App().BundlesKeeper.GetNetworkFee(s.Ctx()) @@ -959,9 +1009,11 @@ var _ = Describe("inflation splitting", Ordered, func() { // assert uploader self delegation rewards Expect(s.App().DelegationKeeper.GetOutstandingRewards(s.Ctx(), i.STAKER_0, i.STAKER_0)).To(Equal(uploaderDelegationReward)) + fundingState, _ := s.App().FundersKeeper.GetFundingState(s.Ctx(), 0) + // assert total pool funds - Expect(pool.TotalFunds).To(BeZero()) - Expect(pool.Funders).To(BeEmpty()) + Expect(s.App().FundersKeeper.GetTotalActiveFunding(s.Ctx(), fundingState.PoolId)).To(BeZero()) + Expect(fundingState.ActiveFunderAddresses).To(BeEmpty()) }) It("Produce a valid bundle with some insufficient funders and 0% inflation splitting", func() { @@ -976,16 +1028,18 @@ var _ = Describe("inflation splitting", Ordered, func() { s.Commit() } - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ - Creator: i.ALICE, - Id: 0, - Amount: 100 * i.KYVE, + s.RunTxFundersSuccess(&funderstypes.MsgFundPool{ + Creator: i.ALICE, + PoolId: 0, + Amount: 100 * i.KYVE, + AmountPerBundle: 5_000, }) - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ - Creator: i.BOB, - Id: 0, - Amount: 200, + s.RunTxFundersSuccess(&funderstypes.MsgFundPool{ + Creator: i.BOB, + PoolId: 0, + Amount: 200, + AmountPerBundle: 5_000, }) s.RunTxBundlesSuccess(&bundletypes.MsgSubmitBundleProposal{ @@ -1045,7 +1099,7 @@ var _ = Describe("inflation splitting", Ordered, func() { uploader, _ := s.App().StakersKeeper.GetStaker(s.Ctx(), i.STAKER_0) // the total payout is the total funds - totalPayout := (pool.OperatingCost / 2) + 200 + totalPayout := (pool.InflationShareWeight / 2) + 200 networkFee := s.App().BundlesKeeper.GetNetworkFee(s.Ctx()) treasuryReward := uint64(sdk.NewDec(int64(totalPayout)).Mul(networkFee).TruncateInt64()) @@ -1060,12 +1114,14 @@ var _ = Describe("inflation splitting", Ordered, func() { // assert uploader self delegation rewards Expect(s.App().DelegationKeeper.GetOutstandingRewards(s.Ctx(), i.STAKER_0, i.STAKER_0)).To(Equal(uploaderDelegationReward)) + fundingState, _ := s.App().FundersKeeper.GetFundingState(s.Ctx(), 0) + // assert total pool funds - Expect(pool.TotalFunds).To(Equal(100*i.KYVE - (pool.OperatingCost / 2))) - Expect(pool.Funders).To(HaveLen(1)) + Expect(s.App().FundersKeeper.GetTotalActiveFunding(s.Ctx(), fundingState.PoolId)).To(Equal(100*i.KYVE - 5_000)) + Expect(fundingState.ActiveFunderAddresses).To(HaveLen(1)) }) - It("Produce a valid bundle with some insufficient funders and 10% inflation splitting", func() { + It("Produce a valid bundle with some insufficient funders and 30% inflation splitting", func() { // ARRANGE s.App().PoolKeeper.SetParams(s.Ctx(), pooltypes.Params{ ProtocolInflationShare: sdk.MustNewDecFromStr("0.1"), @@ -1077,16 +1133,18 @@ var _ = Describe("inflation splitting", Ordered, func() { s.Commit() } - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ - Creator: i.ALICE, - Id: 0, - Amount: 100 * i.KYVE, + s.RunTxFundersSuccess(&funderstypes.MsgFundPool{ + Creator: i.ALICE, + PoolId: 0, + Amount: 100 * i.KYVE, + AmountPerBundle: 5_000, }) - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ - Creator: i.BOB, - Id: 0, - Amount: 200, + s.RunTxFundersSuccess(&funderstypes.MsgFundPool{ + Creator: i.BOB, + PoolId: 0, + Amount: 200, + AmountPerBundle: 5_000, }) s.RunTxBundlesSuccess(&bundletypes.MsgSubmitBundleProposal{ @@ -1147,8 +1205,8 @@ var _ = Describe("inflation splitting", Ordered, func() { // assert bundle reward uploader, _ := s.App().StakersKeeper.GetStaker(s.Ctx(), i.STAKER_0) - // the total payout is the operating cost plus the inflation payout - totalPayout := (pool.OperatingCost / 2) + 200 + payout + // the total payout is the inflation share weight plus the inflation payout + totalPayout := (pool.InflationShareWeight / 2) + 200 + payout networkFee := s.App().BundlesKeeper.GetNetworkFee(s.Ctx()) treasuryReward := uint64(sdk.NewDec(int64(totalPayout)).Mul(networkFee).TruncateInt64()) @@ -1163,9 +1221,11 @@ var _ = Describe("inflation splitting", Ordered, func() { // assert uploader self delegation rewards Expect(s.App().DelegationKeeper.GetOutstandingRewards(s.Ctx(), i.STAKER_0, i.STAKER_0)).To(Equal(uploaderDelegationReward)) + fundingState, _ := s.App().FundersKeeper.GetFundingState(s.Ctx(), 0) + // assert total pool funds - Expect(pool.TotalFunds).To(Equal(100*i.KYVE - (pool.OperatingCost / 2))) - Expect(pool.Funders).To(HaveLen(1)) + Expect(s.App().FundersKeeper.GetTotalActiveFunding(s.Ctx(), fundingState.PoolId)).To(Equal(100*i.KYVE - 5_000)) + Expect(fundingState.ActiveFunderAddresses).To(HaveLen(1)) }) It("Produce a valid bundle with some insufficient funders and 10% inflation splitting", func() { @@ -1180,16 +1240,18 @@ var _ = Describe("inflation splitting", Ordered, func() { s.Commit() } - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ - Creator: i.ALICE, - Id: 0, - Amount: 100 * i.KYVE, + s.RunTxFundersSuccess(&funderstypes.MsgFundPool{ + Creator: i.ALICE, + PoolId: 0, + Amount: 100 * i.KYVE, + AmountPerBundle: 5_000, }) - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ - Creator: i.BOB, - Id: 0, - Amount: 200, + s.RunTxFundersSuccess(&funderstypes.MsgFundPool{ + Creator: i.BOB, + PoolId: 0, + Amount: 200, + AmountPerBundle: 5_000, }) s.RunTxBundlesSuccess(&bundletypes.MsgSubmitBundleProposal{ @@ -1250,8 +1312,8 @@ var _ = Describe("inflation splitting", Ordered, func() { // assert bundle reward uploader, _ := s.App().StakersKeeper.GetStaker(s.Ctx(), i.STAKER_0) - // the total payout is the operating cost plus the inflation payout - totalPayout := (pool.OperatingCost / 2) + 200 + payout + // the total payout is the inflation share weight plus the inflation payout + totalPayout := (pool.InflationShareWeight / 2) + 200 + payout networkFee := s.App().BundlesKeeper.GetNetworkFee(s.Ctx()) treasuryReward := uint64(sdk.NewDec(int64(totalPayout)).Mul(networkFee).TruncateInt64()) @@ -1266,8 +1328,10 @@ var _ = Describe("inflation splitting", Ordered, func() { // assert uploader self delegation rewards Expect(s.App().DelegationKeeper.GetOutstandingRewards(s.Ctx(), i.STAKER_0, i.STAKER_0)).To(Equal(uploaderDelegationReward)) + fundingState, _ := s.App().FundersKeeper.GetFundingState(s.Ctx(), 0) + // assert total pool funds - Expect(pool.TotalFunds).To(Equal(100*i.KYVE - (pool.OperatingCost / 2))) - Expect(pool.Funders).To(HaveLen(1)) + Expect(s.App().FundersKeeper.GetTotalActiveFunding(s.Ctx(), fundingState.PoolId)).To(Equal(100*i.KYVE - 5_000)) + Expect(fundingState.ActiveFunderAddresses).To(HaveLen(1)) }) }) diff --git a/x/bundles/keeper/keeper_suite_invalid_bundles_test.go b/x/bundles/keeper/keeper_suite_invalid_bundles_test.go index ab3f20e5..c15c7240 100644 --- a/x/bundles/keeper/keeper_suite_invalid_bundles_test.go +++ b/x/bundles/keeper/keeper_suite_invalid_bundles_test.go @@ -7,6 +7,7 @@ import ( i "github.com/KYVENetwork/chain/testutil/integration" bundletypes "github.com/KYVENetwork/chain/x/bundles/types" + funderstypes "github.com/KYVENetwork/chain/x/funders/types" pooltypes "github.com/KYVENetwork/chain/x/pool/types" stakertypes "github.com/KYVENetwork/chain/x/stakers/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -39,24 +40,35 @@ var _ = Describe("invalid bundles", Ordered, func() { s = i.NewCleanChain() // create clean pool for every test case - s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{ - Name: "PoolTest", - MaxBundleSize: 100, - StartKey: "0", - UploadInterval: 60, - OperatingCost: 10_000, - Protocol: &pooltypes.Protocol{ - Version: "0.0.0", - Binaries: "{}", - LastUpgrade: uint64(s.Ctx().BlockTime().Unix()), - }, - UpgradePlan: &pooltypes.UpgradePlan{}, - }) - - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ + gov := s.App().GovKeeper.GetGovernanceAccount(s.Ctx()).GetAddress().String() + msg := &pooltypes.MsgCreatePool{ + Authority: gov, + Name: "PoolTest", + Runtime: "@kyve/test", + Logo: "ar://Tewyv2P5VEG8EJ6AUQORdqNTectY9hlOrWPK8wwo-aU", + Config: "ar://DgdB-2hLrxjhyEEbCML__dgZN5_uS7T6Z5XDkaFh3P0", + StartKey: "0", + UploadInterval: 60, + InflationShareWeight: 10_000, + MinDelegation: 100 * i.KYVE, + MaxBundleSize: 100, + Version: "0.0.0", + Binaries: "{}", + StorageProviderId: 2, + CompressionId: 1, + } + s.RunTxPoolSuccess(msg) + + s.RunTxFundersSuccess(&funderstypes.MsgCreateFunder{ Creator: i.ALICE, - Id: 0, - Amount: 100 * i.KYVE, + Moniker: "Alice", + }) + + s.RunTxFundersSuccess(&funderstypes.MsgFundPool{ + Creator: i.ALICE, + PoolId: 0, + Amount: 100 * i.KYVE, + AmountPerBundle: 1 * i.KYVE, }) s.RunTxStakersSuccess(&stakertypes.MsgCreateStaker{ @@ -245,10 +257,11 @@ var _ = Describe("invalid bundles", Ordered, func() { Expect(s.App().DelegationKeeper.GetOutstandingRewards(s.Ctx(), i.STAKER_2, i.STAKER_2)).To(BeZero()) // check pool funds - pool, _ = s.App().PoolKeeper.GetPool(s.Ctx(), 0) + fundingState, _ := s.App().FundersKeeper.GetFundingState(s.Ctx(), 0) - Expect(pool.Funders).To(HaveLen(1)) - Expect(pool.GetFunderAmount(i.ALICE)).To(Equal(100 * i.KYVE)) + // assert total pool funds + Expect(s.App().FundersKeeper.GetTotalActiveFunding(s.Ctx(), fundingState.PoolId)).To(Equal(100 * i.KYVE)) + Expect(fundingState.ActiveFunderAddresses).To(HaveLen(1)) }) It("Produce an invalid bundle with multiple validators and foreign delegations", func() { @@ -415,10 +428,11 @@ var _ = Describe("invalid bundles", Ordered, func() { Expect(s.App().DelegationKeeper.GetOutstandingRewards(s.Ctx(), i.STAKER_1, i.BOB)).To(BeZero()) // check pool funds - pool, _ = s.App().PoolKeeper.GetPool(s.Ctx(), 0) + fundingState, _ := s.App().FundersKeeper.GetFundingState(s.Ctx(), 0) - Expect(pool.Funders).To(HaveLen(1)) - Expect(pool.GetFunderAmount(i.ALICE)).To(Equal(100 * i.KYVE)) + // assert total pool funds + Expect(s.App().FundersKeeper.GetTotalActiveFunding(s.Ctx(), fundingState.PoolId)).To(Equal(100 * i.KYVE)) + Expect(fundingState.ActiveFunderAddresses).To(HaveLen(1)) }) It("Produce an invalid bundle with multiple validators although some voted valid", func() { @@ -632,9 +646,10 @@ var _ = Describe("invalid bundles", Ordered, func() { Expect(s.App().DelegationKeeper.GetOutstandingRewards(s.Ctx(), i.STAKER_3, i.DAVID)).To(BeZero()) // check pool funds - pool, _ = s.App().PoolKeeper.GetPool(s.Ctx(), 0) + fundingState, _ := s.App().FundersKeeper.GetFundingState(s.Ctx(), 0) - Expect(pool.Funders).To(HaveLen(1)) - Expect(pool.GetFunderAmount(i.ALICE)).To(Equal(100 * i.KYVE)) + // assert total pool funds + Expect(s.App().FundersKeeper.GetTotalActiveFunding(s.Ctx(), fundingState.PoolId)).To(Equal(100 * i.KYVE)) + Expect(fundingState.ActiveFunderAddresses).To(HaveLen(1)) }) }) diff --git a/x/bundles/keeper/keeper_suite_points_test.go b/x/bundles/keeper/keeper_suite_points_test.go index 4251501b..810670e4 100644 --- a/x/bundles/keeper/keeper_suite_points_test.go +++ b/x/bundles/keeper/keeper_suite_points_test.go @@ -3,6 +3,7 @@ package keeper_test import ( i "github.com/KYVENetwork/chain/testutil/integration" bundletypes "github.com/KYVENetwork/chain/x/bundles/types" + funderstypes "github.com/KYVENetwork/chain/x/funders/types" pooltypes "github.com/KYVENetwork/chain/x/pool/types" stakertypes "github.com/KYVENetwork/chain/x/stakers/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -33,24 +34,35 @@ var _ = Describe("points", Ordered, func() { s = i.NewCleanChain() // create clean pool for every test case - s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{ - Name: "PoolTest", - MaxBundleSize: 100, - StartKey: "0", - UploadInterval: 60, - OperatingCost: 10_000, - Protocol: &pooltypes.Protocol{ - Version: "0.0.0", - Binaries: "{}", - LastUpgrade: uint64(s.Ctx().BlockTime().Unix()), - }, - UpgradePlan: &pooltypes.UpgradePlan{}, - }) + gov := s.App().GovKeeper.GetGovernanceAccount(s.Ctx()).GetAddress().String() + msg := &pooltypes.MsgCreatePool{ + Authority: gov, + Name: "PoolTest", + Runtime: "@kyve/test", + Logo: "ar://Tewyv2P5VEG8EJ6AUQORdqNTectY9hlOrWPK8wwo-aU", + Config: "ar://DgdB-2hLrxjhyEEbCML__dgZN5_uS7T6Z5XDkaFh3P0", + StartKey: "0", + UploadInterval: 60, + InflationShareWeight: 10_000, + MinDelegation: 100 * i.KYVE, + MaxBundleSize: 100, + Version: "0.0.0", + Binaries: "{}", + StorageProviderId: 2, + CompressionId: 1, + } + s.RunTxPoolSuccess(msg) - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ + s.RunTxFundersSuccess(&funderstypes.MsgCreateFunder{ Creator: i.ALICE, - Id: 0, - Amount: 100 * i.KYVE, + Moniker: "Alice", + }) + + s.RunTxFundersSuccess(&funderstypes.MsgFundPool{ + Creator: i.ALICE, + PoolId: 0, + Amount: 100 * i.KYVE, + AmountPerBundle: 1 * i.KYVE, }) s.RunTxStakersSuccess(&stakertypes.MsgCreateStaker{ diff --git a/x/bundles/keeper/keeper_suite_stakers_leave_test.go b/x/bundles/keeper/keeper_suite_stakers_leave_test.go index 5a8af7ca..130920c9 100644 --- a/x/bundles/keeper/keeper_suite_stakers_leave_test.go +++ b/x/bundles/keeper/keeper_suite_stakers_leave_test.go @@ -3,6 +3,7 @@ package keeper_test import ( i "github.com/KYVENetwork/chain/testutil/integration" bundletypes "github.com/KYVENetwork/chain/x/bundles/types" + funderstypes "github.com/KYVENetwork/chain/x/funders/types" pooltypes "github.com/KYVENetwork/chain/x/pool/types" stakertypes "github.com/KYVENetwork/chain/x/stakers/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -40,24 +41,40 @@ var _ = Describe("stakers leave", Ordered, func() { s = i.NewCleanChain() // create clean pool for every test case - s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{ - Name: "PoolTest", - MaxBundleSize: 100, - StartKey: "0", - UploadInterval: 60, - OperatingCost: 10_000, - Protocol: &pooltypes.Protocol{ - Version: "0.0.0", - Binaries: "{}", - LastUpgrade: uint64(s.Ctx().BlockTime().Unix()), - }, - UpgradePlan: &pooltypes.UpgradePlan{}, - }) - - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ + gov := s.App().GovKeeper.GetGovernanceAccount(s.Ctx()).GetAddress().String() + msg := &pooltypes.MsgCreatePool{ + Authority: gov, + Name: "PoolTest", + Runtime: "@kyve/test", + Logo: "ar://Tewyv2P5VEG8EJ6AUQORdqNTectY9hlOrWPK8wwo-aU", + Config: "ar://DgdB-2hLrxjhyEEbCML__dgZN5_uS7T6Z5XDkaFh3P0", + StartKey: "0", + UploadInterval: 60, + InflationShareWeight: 10_000, + MinDelegation: 0 * i.KYVE, + MaxBundleSize: 100, + Version: "0.0.0", + Binaries: "{}", + StorageProviderId: 2, + CompressionId: 1, + } + s.RunTxPoolSuccess(msg) + + // create funders + s.RunTxFundersSuccess(&funderstypes.MsgCreateFunder{ Creator: i.ALICE, - Id: 0, - Amount: 100 * i.KYVE, + Moniker: "Alice", + }) + + params := s.App().FundersKeeper.GetParams(s.Ctx()) + params.MinFundingAmountPerBundle = 10_000 + s.App().FundersKeeper.SetParams(s.Ctx(), params) + + s.RunTxFundersSuccess(&funderstypes.MsgFundPool{ + Creator: i.ALICE, + PoolId: 0, + Amount: 100 * i.KYVE, + AmountPerBundle: 10_000, }) s.RunTxStakersSuccess(&stakertypes.MsgCreateStaker{ @@ -232,9 +249,9 @@ var _ = Describe("stakers leave", Ordered, func() { // calculate uploader rewards networkFee := s.App().BundlesKeeper.GetNetworkFee(s.Ctx()) - treasuryReward := uint64(sdk.NewDec(int64(pool.OperatingCost)).Mul(networkFee).TruncateInt64()) + treasuryReward := uint64(sdk.NewDec(int64(pool.InflationShareWeight)).Mul(networkFee).TruncateInt64()) storageReward := uint64(s.App().BundlesKeeper.GetStorageCost(s.Ctx()).MulInt64(100).TruncateInt64()) - totalUploaderReward := pool.OperatingCost - treasuryReward - storageReward + totalUploaderReward := pool.InflationShareWeight - treasuryReward - storageReward uploaderPayoutReward := uint64(sdk.NewDec(int64(totalUploaderReward)).Mul(uploader.Commission).TruncateInt64()) uploaderDelegationReward := totalUploaderReward - uploaderPayoutReward diff --git a/x/bundles/keeper/keeper_suite_valid_bundles_test.go b/x/bundles/keeper/keeper_suite_valid_bundles_test.go index 0d7000ae..d4517d80 100644 --- a/x/bundles/keeper/keeper_suite_valid_bundles_test.go +++ b/x/bundles/keeper/keeper_suite_valid_bundles_test.go @@ -1,6 +1,7 @@ package keeper_test import ( + fundersTypes "github.com/KYVENetwork/chain/x/funders/types" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" @@ -36,29 +37,45 @@ var _ = Describe("valid bundles", Ordered, func() { initialBalanceStaker2 := s.GetBalanceFromAddress(i.STAKER_2) initialBalanceValaddress2 := s.GetBalanceFromAddress(i.VALADDRESS_2_A) + amountPerBundle := uint64(10_000) + BeforeEach(func() { // init new clean chain s = i.NewCleanChain() // create clean pool for every test case - s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{ - Name: "PoolTest", - MaxBundleSize: 100, - StartKey: "0", - UploadInterval: 60, - OperatingCost: 10_000, - Protocol: &pooltypes.Protocol{ - Version: "0.0.0", - Binaries: "{}", - LastUpgrade: uint64(s.Ctx().BlockTime().Unix()), - }, - UpgradePlan: &pooltypes.UpgradePlan{}, - }) - - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ + gov := s.App().GovKeeper.GetGovernanceAccount(s.Ctx()).GetAddress().String() + msg := &pooltypes.MsgCreatePool{ + Authority: gov, + Name: "PoolTest", + Runtime: "@kyve/test", + Logo: "ar://Tewyv2P5VEG8EJ6AUQORdqNTectY9hlOrWPK8wwo-aU", + Config: "ar://DgdB-2hLrxjhyEEbCML__dgZN5_uS7T6Z5XDkaFh3P0", + StartKey: "0", + UploadInterval: 60, + InflationShareWeight: 10_000, + MinDelegation: 0 * i.KYVE, + MaxBundleSize: 100, + Version: "0.0.0", + Binaries: "{}", + StorageProviderId: 2, + CompressionId: 1, + } + s.RunTxPoolSuccess(msg) + + // create funders + s.RunTxFundersSuccess(&fundersTypes.MsgCreateFunder{ Creator: i.ALICE, - Id: 0, - Amount: 100 * i.KYVE, + Moniker: "Alice", + }) + + params := s.App().FundersKeeper.GetParams(s.Ctx()) + params.MinFundingAmountPerBundle = amountPerBundle + s.App().FundersKeeper.SetParams(s.Ctx(), params) + s.RunTxPoolSuccess(&fundersTypes.MsgFundPool{ + Creator: i.ALICE, + Amount: 100 * i.KYVE, + AmountPerBundle: amountPerBundle, }) s.RunTxStakersSuccess(&stakertypes.MsgCreateStaker{ @@ -215,9 +232,9 @@ var _ = Describe("valid bundles", Ordered, func() { // calculate uploader rewards // calculate uploader rewards networkFee := s.App().BundlesKeeper.GetNetworkFee(s.Ctx()) - treasuryReward := uint64(sdk.NewDec(int64(pool.OperatingCost)).Mul(networkFee).TruncateInt64()) + treasuryReward := uint64(sdk.NewDec(int64(pool.InflationShareWeight)).Mul(networkFee).TruncateInt64()) storageReward := uint64(s.App().BundlesKeeper.GetStorageCost(s.Ctx()).MulInt64(100).TruncateInt64()) - totalUploaderReward := pool.OperatingCost - treasuryReward - storageReward + totalUploaderReward := pool.InflationShareWeight - treasuryReward - storageReward uploaderPayoutReward := uint64(sdk.NewDec(int64(totalUploaderReward)).Mul(uploader.Commission).TruncateInt64()) uploaderDelegationReward := totalUploaderReward - uploaderPayoutReward @@ -229,11 +246,11 @@ var _ = Describe("valid bundles", Ordered, func() { // assert uploader self delegation rewards Expect(s.App().DelegationKeeper.GetOutstandingRewards(s.Ctx(), i.STAKER_0, i.STAKER_0)).To(Equal(uploaderDelegationReward)) - // check pool funds - pool, _ = s.App().PoolKeeper.GetPool(s.Ctx(), 0) + fundingState, _ := s.App().FundersKeeper.GetFundingState(s.Ctx(), 0) - Expect(pool.Funders).To(HaveLen(1)) - Expect(pool.GetFunderAmount(i.ALICE)).To(Equal(100*i.KYVE - pool.OperatingCost)) + // assert total pool funds + Expect(s.App().FundersKeeper.GetTotalActiveFunding(s.Ctx(), fundingState.PoolId)).To(Equal(100*i.KYVE - 1*amountPerBundle)) + Expect(fundingState.ActiveFunderAddresses).To(HaveLen(1)) }) It("Produce a valid bundle with multiple validators and foreign delegations", func() { @@ -360,9 +377,9 @@ var _ = Describe("valid bundles", Ordered, func() { // calculate uploader rewards networkFee := s.App().BundlesKeeper.GetNetworkFee(s.Ctx()) - treasuryReward := uint64(sdk.NewDec(int64(pool.OperatingCost)).Mul(networkFee).TruncateInt64()) + treasuryReward := uint64(sdk.NewDec(int64(pool.InflationShareWeight)).Mul(networkFee).TruncateInt64()) storageReward := uint64(s.App().BundlesKeeper.GetStorageCost(s.Ctx()).MulInt64(100).TruncateInt64()) - totalUploaderReward := pool.OperatingCost - treasuryReward - storageReward + totalUploaderReward := pool.InflationShareWeight - treasuryReward - storageReward uploaderPayoutReward := uint64(sdk.NewDec(int64(totalUploaderReward)).Mul(uploader.Commission).TruncateInt64()) totalDelegationReward := totalUploaderReward - uploaderPayoutReward @@ -390,11 +407,11 @@ var _ = Describe("valid bundles", Ordered, func() { // assert uploader self delegation rewards Expect(s.App().DelegationKeeper.GetOutstandingRewards(s.Ctx(), i.STAKER_0, i.STAKER_0)).To(Equal(uploaderDelegationReward)) - // check pool funds - pool, _ = s.App().PoolKeeper.GetPool(s.Ctx(), 0) + fundingState, _ := s.App().FundersKeeper.GetFundingState(s.Ctx(), 0) - Expect(pool.Funders).To(HaveLen(1)) - Expect(pool.GetFunderAmount(i.ALICE)).To(Equal(100*i.KYVE - pool.OperatingCost)) + // assert total pool funds + Expect(s.App().FundersKeeper.GetTotalActiveFunding(s.Ctx(), fundingState.PoolId)).To(Equal(100*i.KYVE - 1*amountPerBundle)) + Expect(fundingState.ActiveFunderAddresses).To(HaveLen(1)) }) It("Produce a valid bundle with multiple validators and foreign delegation although some did not vote at all", func() { @@ -538,9 +555,9 @@ var _ = Describe("valid bundles", Ordered, func() { // calculate uploader rewards networkFee := s.App().BundlesKeeper.GetNetworkFee(s.Ctx()) - treasuryReward := uint64(sdk.NewDec(int64(pool.OperatingCost)).Mul(networkFee).TruncateInt64()) + treasuryReward := uint64(sdk.NewDec(int64(pool.InflationShareWeight)).Mul(networkFee).TruncateInt64()) storageReward := uint64(s.App().BundlesKeeper.GetStorageCost(s.Ctx()).MulInt64(100).TruncateInt64()) - totalUploaderReward := pool.OperatingCost - treasuryReward - storageReward + totalUploaderReward := pool.InflationShareWeight - treasuryReward - storageReward uploaderPayoutReward := uint64(sdk.NewDec(int64(totalUploaderReward)).Mul(uploader.Commission).TruncateInt64()) totalDelegationReward := totalUploaderReward - uploaderPayoutReward @@ -561,11 +578,11 @@ var _ = Describe("valid bundles", Ordered, func() { // check voter rewards Expect(s.App().DelegationKeeper.GetOutstandingRewards(s.Ctx(), i.STAKER_2, i.CHARLIE)).To(BeZero()) - // check pool funds - pool, _ = s.App().PoolKeeper.GetPool(s.Ctx(), 0) + fundingState, _ := s.App().FundersKeeper.GetFundingState(s.Ctx(), 0) - Expect(pool.Funders).To(HaveLen(1)) - Expect(pool.GetFunderAmount(i.ALICE)).To(Equal(100*i.KYVE - pool.OperatingCost)) + // assert total pool funds + Expect(s.App().FundersKeeper.GetTotalActiveFunding(s.Ctx(), fundingState.PoolId)).To(Equal(100*i.KYVE - 1*amountPerBundle)) + Expect(fundingState.ActiveFunderAddresses).To(HaveLen(1)) }) It("Produce a valid bundle with multiple validators and foreign delegation although some voted abstain", func() { @@ -715,12 +732,11 @@ var _ = Describe("valid bundles", Ordered, func() { balanceVoter := s.GetBalanceFromAddress(valaccountVoter.Staker) Expect(balanceVoter).To(Equal(initialBalanceStaker1)) - // calculate uploader rewards // calculate uploader rewards networkFee := s.App().BundlesKeeper.GetNetworkFee(s.Ctx()) - treasuryReward := uint64(sdk.NewDec(int64(pool.OperatingCost)).Mul(networkFee).TruncateInt64()) + treasuryReward := uint64(sdk.NewDec(int64(pool.InflationShareWeight)).Mul(networkFee).TruncateInt64()) storageReward := uint64(s.App().BundlesKeeper.GetStorageCost(s.Ctx()).MulInt64(100).TruncateInt64()) - totalUploaderReward := pool.OperatingCost - treasuryReward - storageReward + totalUploaderReward := pool.InflationShareWeight - treasuryReward - storageReward uploaderPayoutReward := uint64(sdk.NewDec(int64(totalUploaderReward)).Mul(uploader.Commission).TruncateInt64()) totalDelegationReward := totalUploaderReward - uploaderPayoutReward @@ -741,11 +757,11 @@ var _ = Describe("valid bundles", Ordered, func() { // check voter rewards Expect(s.App().DelegationKeeper.GetOutstandingRewards(s.Ctx(), i.STAKER_2, i.CHARLIE)).To(BeZero()) - // check pool funds - pool, _ = s.App().PoolKeeper.GetPool(s.Ctx(), 0) + fundingState, _ := s.App().FundersKeeper.GetFundingState(s.Ctx(), 0) - Expect(pool.Funders).To(HaveLen(1)) - Expect(pool.GetFunderAmount(i.ALICE)).To(Equal(100*i.KYVE - pool.OperatingCost)) + // assert total pool funds + Expect(s.App().FundersKeeper.GetTotalActiveFunding(s.Ctx(), fundingState.PoolId)).To(Equal(100*i.KYVE - 1*amountPerBundle)) + Expect(fundingState.ActiveFunderAddresses).To(HaveLen(1)) }) It("Produce a valid bundle with multiple validators and foreign delegation although some voted invalid", func() { @@ -907,9 +923,9 @@ var _ = Describe("valid bundles", Ordered, func() { // calculate uploader rewards networkFee := s.App().BundlesKeeper.GetNetworkFee(s.Ctx()) - treasuryReward := uint64(sdk.NewDec(int64(pool.OperatingCost)).Mul(networkFee).TruncateInt64()) + treasuryReward := uint64(sdk.NewDec(int64(pool.InflationShareWeight)).Mul(networkFee).TruncateInt64()) storageReward := uint64(s.App().BundlesKeeper.GetStorageCost(s.Ctx()).MulInt64(100).TruncateInt64()) - totalUploaderReward := pool.OperatingCost - treasuryReward - storageReward + totalUploaderReward := pool.InflationShareWeight - treasuryReward - storageReward uploaderPayoutReward := uint64(sdk.NewDec(int64(totalUploaderReward)).Mul(uploader.Commission).TruncateInt64()) totalDelegationReward := totalUploaderReward - uploaderPayoutReward @@ -930,10 +946,10 @@ var _ = Describe("valid bundles", Ordered, func() { // check voter rewards Expect(s.App().DelegationKeeper.GetOutstandingRewards(s.Ctx(), i.STAKER_2, i.CHARLIE)).To(BeZero()) - // check pool funds - pool, _ = s.App().PoolKeeper.GetPool(s.Ctx(), 0) + fundingState, _ := s.App().FundersKeeper.GetFundingState(s.Ctx(), 0) - Expect(pool.Funders).To(HaveLen(1)) - Expect(pool.GetFunderAmount(i.ALICE)).To(Equal(100*i.KYVE - pool.OperatingCost)) + // assert total pool funds + Expect(s.App().FundersKeeper.GetTotalActiveFunding(s.Ctx(), fundingState.PoolId)).To(Equal(100*i.KYVE - 1*amountPerBundle)) + Expect(fundingState.ActiveFunderAddresses).To(HaveLen(1)) }) }) diff --git a/x/bundles/keeper/keeper_suite_zero_delegation_test.go b/x/bundles/keeper/keeper_suite_zero_delegation_test.go index 92068a9d..8b2f7956 100644 --- a/x/bundles/keeper/keeper_suite_zero_delegation_test.go +++ b/x/bundles/keeper/keeper_suite_zero_delegation_test.go @@ -3,6 +3,7 @@ package keeper_test import ( i "github.com/KYVENetwork/chain/testutil/integration" bundletypes "github.com/KYVENetwork/chain/x/bundles/types" + funderstypes "github.com/KYVENetwork/chain/x/funders/types" pooltypes "github.com/KYVENetwork/chain/x/pool/types" stakertypes "github.com/KYVENetwork/chain/x/stakers/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -35,29 +36,47 @@ var _ = Describe("zero delegation", Ordered, func() { // initialBalanceStaker2 := s.GetBalanceFromAddress(i.STAKER_2) // initialBalanceValaddress2 := s.GetBalanceFromAddress(i.VALADDRESS_2_A) + amountPerBundle := uint64(10_000) + BeforeEach(func() { // init new clean chain s = i.NewCleanChain() // create clean pool for every test case - s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{ - Name: "PoolTest", - MaxBundleSize: 100, - StartKey: "0", - UploadInterval: 60, - OperatingCost: 10_000, - Protocol: &pooltypes.Protocol{ - Version: "0.0.0", - Binaries: "{}", - LastUpgrade: uint64(s.Ctx().BlockTime().Unix()), - }, - UpgradePlan: &pooltypes.UpgradePlan{}, - }) - - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ + gov := s.App().GovKeeper.GetGovernanceAccount(s.Ctx()).GetAddress().String() + msg := &pooltypes.MsgCreatePool{ + Authority: gov, + Name: "PoolTest", + Runtime: "@kyve/test", + Logo: "ar://Tewyv2P5VEG8EJ6AUQORdqNTectY9hlOrWPK8wwo-aU", + Config: "ar://DgdB-2hLrxjhyEEbCML__dgZN5_uS7T6Z5XDkaFh3P0", + StartKey: "0", + UploadInterval: 60, + InflationShareWeight: 10_000, + MinDelegation: 0 * i.KYVE, + MaxBundleSize: 100, + Version: "0.0.0", + Binaries: "{}", + StorageProviderId: 2, + CompressionId: 1, + } + s.RunTxPoolSuccess(msg) + + params := s.App().FundersKeeper.GetParams(s.Ctx()) + params.MinFundingAmountPerBundle = amountPerBundle + s.App().FundersKeeper.SetParams(s.Ctx(), params) + + // create funders + s.RunTxFundersSuccess(&funderstypes.MsgCreateFunder{ Creator: i.ALICE, - Id: 0, - Amount: 100 * i.KYVE, + Moniker: "Alice", + }) + + s.RunTxPoolSuccess(&funderstypes.MsgFundPool{ + Creator: i.ALICE, + PoolId: 0, + Amount: 100 * i.KYVE, + AmountPerBundle: amountPerBundle, }) s.CommitAfterSeconds(60) @@ -446,9 +465,9 @@ var _ = Describe("zero delegation", Ordered, func() { // calculate uploader rewards networkFee := s.App().BundlesKeeper.GetNetworkFee(s.Ctx()) - treasuryReward := uint64(sdk.NewDec(int64(pool.OperatingCost)).Mul(networkFee).TruncateInt64()) + treasuryReward := uint64(sdk.NewDec(int64(pool.InflationShareWeight)).Mul(networkFee).TruncateInt64()) storageReward := uint64(s.App().BundlesKeeper.GetStorageCost(s.Ctx()).MulInt64(100).TruncateInt64()) - totalUploaderReward := pool.OperatingCost - treasuryReward - storageReward + totalUploaderReward := pool.InflationShareWeight - treasuryReward - storageReward uploader, _ := s.App().StakersKeeper.GetStaker(s.Ctx(), i.STAKER_0) @@ -459,11 +478,11 @@ var _ = Describe("zero delegation", Ordered, func() { // assert uploader self delegation rewards Expect(s.App().DelegationKeeper.GetOutstandingRewards(s.Ctx(), i.STAKER_0, i.STAKER_0)).To(BeZero()) - // check pool funds - pool, _ = s.App().PoolKeeper.GetPool(s.Ctx(), 0) + fundingState, _ := s.App().FundersKeeper.GetFundingState(s.Ctx(), 0) - Expect(pool.Funders).To(HaveLen(1)) - Expect(pool.GetFunderAmount(i.ALICE)).To(Equal(100*i.KYVE - pool.OperatingCost)) + // assert total pool funds + Expect(s.App().FundersKeeper.GetTotalActiveFunding(s.Ctx(), fundingState.PoolId)).To(Equal(100*i.KYVE - 1*amountPerBundle)) + Expect(fundingState.ActiveFunderAddresses).To(HaveLen(1)) }) It("Staker receives upload slash with zero delegation", func() { @@ -631,11 +650,11 @@ var _ = Describe("zero delegation", Ordered, func() { Expect(balanceVoter).To(Equal(initialBalanceStaker1)) Expect(s.App().DelegationKeeper.GetOutstandingRewards(s.Ctx(), i.STAKER_1, i.STAKER_1)).To(BeZero()) - // check pool funds - pool, _ = s.App().PoolKeeper.GetPool(s.Ctx(), 0) + fundingState, _ := s.App().FundersKeeper.GetFundingState(s.Ctx(), 0) - Expect(pool.Funders).To(HaveLen(1)) - Expect(pool.GetFunderAmount(i.ALICE)).To(Equal(100 * i.KYVE)) + // assert total pool funds + Expect(s.App().FundersKeeper.GetTotalActiveFunding(s.Ctx(), fundingState.PoolId)).To(Equal(100 * i.KYVE)) + Expect(fundingState.ActiveFunderAddresses).To(HaveLen(1)) }) It("Staker receives timeout slash because votes were missed", func() { @@ -889,10 +908,10 @@ var _ = Describe("zero delegation", Ordered, func() { Expect(balanceVoter).To(Equal(initialBalanceStaker1)) Expect(s.App().DelegationKeeper.GetOutstandingRewards(s.Ctx(), i.STAKER_1, i.STAKER_1)).To(BeZero()) - // check pool funds - pool, _ = s.App().PoolKeeper.GetPool(s.Ctx(), 0) + fundingState, _ := s.App().FundersKeeper.GetFundingState(s.Ctx(), 0) - Expect(pool.Funders).To(HaveLen(1)) - Expect(pool.GetFunderAmount(i.ALICE)).To(Equal(100 * i.KYVE)) + // assert total pool funds + Expect(s.App().FundersKeeper.GetTotalActiveFunding(s.Ctx(), fundingState.PoolId)).To(Equal(100 * i.KYVE)) + Expect(fundingState.ActiveFunderAddresses).To(HaveLen(1)) }) }) diff --git a/x/bundles/keeper/logic_bundles_test.go b/x/bundles/keeper/logic_bundles_test.go index 4eb58182..ad8c585a 100644 --- a/x/bundles/keeper/logic_bundles_test.go +++ b/x/bundles/keeper/logic_bundles_test.go @@ -4,6 +4,7 @@ import ( "cosmossdk.io/errors" i "github.com/KYVENetwork/chain/testutil/integration" bundlesTypes "github.com/KYVENetwork/chain/x/bundles/types" + funderstypes "github.com/KYVENetwork/chain/x/funders/types" pooltypes "github.com/KYVENetwork/chain/x/pool/types" stakertypes "github.com/KYVENetwork/chain/x/stakers/types" . "github.com/onsi/ginkgo/v2" @@ -17,7 +18,6 @@ TEST CASES - logic_bundles.go * Assert pool can run while pool is upgrading * Assert pool can run while pool is disabled * Assert pool can run while min delegation is not reached -* Assert pool can run while voting power of one node is too high * Assert pool can run * Assert pool can run while pool has no funds @@ -38,10 +38,42 @@ TEST CASES - logic_bundles.go var _ = Describe("logic_bundles.go", Ordered, func() { s := i.NewCleanChain() + gov := s.App().GovKeeper.GetGovernanceAccount(s.Ctx()).GetAddress().String() BeforeEach(func() { // init new clean chain s = i.NewCleanChain() + + // create clean pool for every test case + msg := &pooltypes.MsgCreatePool{ + Authority: gov, + Name: "PoolTest", + Runtime: "@kyve/test", + Logo: "ar://Tewyv2P5VEG8EJ6AUQORdqNTectY9hlOrWPK8wwo-aU", + Config: "ar://DgdB-2hLrxjhyEEbCML__dgZN5_uS7T6Z5XDkaFh3P0", + StartKey: "0", + UploadInterval: 60, + InflationShareWeight: 2 * i.KYVE, + MinDelegation: 100 * i.KYVE, + MaxBundleSize: 100, + Version: "0.0.0", + Binaries: "{}", + StorageProviderId: 2, + CompressionId: 1, + } + s.RunTxPoolSuccess(msg) + + s.RunTxFundersSuccess(&funderstypes.MsgCreateFunder{ + Creator: i.ALICE, + Moniker: "Alice", + }) + + s.RunTxPoolSuccess(&funderstypes.MsgFundPool{ + Creator: i.ALICE, + PoolId: 0, + Amount: 100 * i.KYVE, + AmountPerBundle: 1 * i.KYVE, + }) }) AfterEach(func() { @@ -52,30 +84,14 @@ var _ = Describe("logic_bundles.go", Ordered, func() { It("Assert pool can run while pool is upgrading", func() { // ASSERT - s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{ - Name: "PoolTest", - UploadInterval: 60, - OperatingCost: 2 * i.KYVE, - MinDelegation: 100 * i.KYVE, - MaxBundleSize: 100, - Protocol: &pooltypes.Protocol{ - Version: "0.0.0", - Binaries: "{}", - LastUpgrade: uint64(s.Ctx().BlockTime().Unix()), - }, - UpgradePlan: &pooltypes.UpgradePlan{ - Version: "1.0.0", - Binaries: "{}", - ScheduledAt: uint64(s.Ctx().BlockTime().Unix()), - Duration: 60, - }, - }) - - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ - Creator: i.ALICE, - Id: 0, - Amount: 100 * i.KYVE, - }) + pool, _ := s.App().PoolKeeper.GetPool(s.Ctx(), 0) + pool.UpgradePlan = &pooltypes.UpgradePlan{ + Version: "1.0.0", + Binaries: "{}", + ScheduledAt: uint64(s.Ctx().BlockTime().Unix()), + Duration: 60, + } + s.App().PoolKeeper.SetPool(s.Ctx(), pool) s.RunTxStakersSuccess(&stakertypes.MsgCreateStaker{ Creator: i.STAKER_0, @@ -110,26 +126,6 @@ var _ = Describe("logic_bundles.go", Ordered, func() { It("Assert pool can run while pool is disabled", func() { // ASSERT - s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{ - Name: "PoolTest", - UploadInterval: 60, - OperatingCost: 2 * i.KYVE, - MinDelegation: 100 * i.KYVE, - MaxBundleSize: 100, - Protocol: &pooltypes.Protocol{ - Version: "0.0.0", - Binaries: "{}", - LastUpgrade: uint64(s.Ctx().BlockTime().Unix()), - }, - UpgradePlan: &pooltypes.UpgradePlan{}, - }) - - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ - Creator: i.ALICE, - Id: 0, - Amount: 100 * i.KYVE, - }) - s.RunTxStakersSuccess(&stakertypes.MsgCreateStaker{ Creator: i.STAKER_0, Amount: 100 * i.KYVE, @@ -168,26 +164,6 @@ var _ = Describe("logic_bundles.go", Ordered, func() { It("Assert pool can run while min delegation is not reached", func() { // ASSERT - s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{ - Name: "PoolTest", - UploadInterval: 60, - OperatingCost: 2 * i.KYVE, - MinDelegation: 100 * i.KYVE, - MaxBundleSize: 100, - Protocol: &pooltypes.Protocol{ - Version: "0.0.0", - Binaries: "{}", - LastUpgrade: uint64(s.Ctx().BlockTime().Unix()), - }, - UpgradePlan: &pooltypes.UpgradePlan{}, - }) - - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ - Creator: i.ALICE, - Id: 0, - Amount: 100 * i.KYVE, - }) - s.RunTxStakersSuccess(&stakertypes.MsgCreateStaker{ Creator: i.STAKER_0, Amount: 20 * i.KYVE, @@ -221,25 +197,24 @@ var _ = Describe("logic_bundles.go", Ordered, func() { It("Assert pool can run while voting power of one node is too high", func() { // ASSERT - s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{ - Name: "PoolTest", - UploadInterval: 60, - OperatingCost: 2 * i.KYVE, - MinDelegation: 100 * i.KYVE, - MaxBundleSize: 100, - Protocol: &pooltypes.Protocol{ - Version: "0.0.0", - Binaries: "{}", - LastUpgrade: uint64(s.Ctx().BlockTime().Unix()), - }, - UpgradePlan: &pooltypes.UpgradePlan{}, - }) - - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ - Creator: i.ALICE, - Id: 0, - Amount: 100 * i.KYVE, - }) + gov := s.App().GovKeeper.GetGovernanceAccount(s.Ctx()).GetAddress().String() + msg := &pooltypes.MsgCreatePool{ + Authority: gov, + Name: "PoolTest", + Runtime: "@kyve/test", + Logo: "ar://Tewyv2P5VEG8EJ6AUQORdqNTectY9hlOrWPK8wwo-aU", + Config: "ar://DgdB-2hLrxjhyEEbCML__dgZN5_uS7T6Z5XDkaFh3P0", + StartKey: "0", + UploadInterval: 60, + InflationShareWeight: 10_000, + MinDelegation: 100 * i.KYVE, + MaxBundleSize: 100, + Version: "0.0.0", + Binaries: "{}", + StorageProviderId: 2, + CompressionId: 1, + } + s.RunTxPoolSuccess(msg) s.RunTxStakersSuccess(&stakertypes.MsgCreateStaker{ Creator: i.STAKER_0, @@ -274,26 +249,6 @@ var _ = Describe("logic_bundles.go", Ordered, func() { It("Assert pool can run", func() { // ASSERT - s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{ - Name: "PoolTest", - UploadInterval: 60, - OperatingCost: 2 * i.KYVE, - MinDelegation: 100 * i.KYVE, - MaxBundleSize: 100, - Protocol: &pooltypes.Protocol{ - Version: "0.0.0", - Binaries: "{}", - LastUpgrade: uint64(s.Ctx().BlockTime().Unix()), - }, - UpgradePlan: &pooltypes.UpgradePlan{}, - }) - - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ - Creator: i.ALICE, - Id: 0, - Amount: 100 * i.KYVE, - }) - s.RunTxStakersSuccess(&stakertypes.MsgCreateStaker{ Creator: i.STAKER_0, Amount: 50 * i.KYVE, @@ -327,19 +282,23 @@ var _ = Describe("logic_bundles.go", Ordered, func() { It("Assert pool can run while pool has no funds", func() { // ASSERT - s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{ - Name: "PoolTest", - UploadInterval: 60, - OperatingCost: 2 * i.KYVE, - MinDelegation: 100 * i.KYVE, - MaxBundleSize: 100, - Protocol: &pooltypes.Protocol{ - Version: "0.0.0", - Binaries: "{}", - LastUpgrade: uint64(s.Ctx().BlockTime().Unix()), - }, - UpgradePlan: &pooltypes.UpgradePlan{}, - }) + msg := &pooltypes.MsgCreatePool{ + Authority: gov, + Name: "PoolTest", + Runtime: "@kyve/test", + Logo: "ar://Tewyv2P5VEG8EJ6AUQORdqNTectY9hlOrWPK8wwo-aU", + Config: "ar://DgdB-2hLrxjhyEEbCML__dgZN5_uS7T6Z5XDkaFh3P0", + StartKey: "0", + UploadInterval: 60, + InflationShareWeight: 2 * i.KYVE, + MinDelegation: 100, + MaxBundleSize: 100, + Version: "0.0.0", + Binaries: "{}", + StorageProviderId: 2, + CompressionId: 1, + } + s.RunTxPoolSuccess(msg) s.RunTxStakersSuccess(&stakertypes.MsgCreateStaker{ Creator: i.STAKER_0, @@ -376,26 +335,6 @@ var _ = Describe("logic_bundles.go", Ordered, func() { It("Assert can vote if sender is no staker", func() { // ASSERT - s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{ - Name: "PoolTest", - UploadInterval: 60, - OperatingCost: 2 * i.KYVE, - MinDelegation: 100 * i.KYVE, - MaxBundleSize: 100, - Protocol: &pooltypes.Protocol{ - Version: "0.0.0", - Binaries: "{}", - LastUpgrade: uint64(s.Ctx().BlockTime().Unix()), - }, - UpgradePlan: &pooltypes.UpgradePlan{}, - }) - - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ - Creator: i.ALICE, - Id: 0, - Amount: 100 * i.KYVE, - }) - s.RunTxStakersSuccess(&stakertypes.MsgCreateStaker{ Creator: i.STAKER_0, Amount: 100 * i.KYVE, @@ -458,26 +397,6 @@ var _ = Describe("logic_bundles.go", Ordered, func() { It("Assert can vote if bundle is dropped", func() { // ASSERT - s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{ - Name: "PoolTest", - UploadInterval: 60, - OperatingCost: 2 * i.KYVE, - MinDelegation: 100 * i.KYVE, - MaxBundleSize: 100, - Protocol: &pooltypes.Protocol{ - Version: "0.0.0", - Binaries: "{}", - LastUpgrade: uint64(s.Ctx().BlockTime().Unix()), - }, - UpgradePlan: &pooltypes.UpgradePlan{}, - }) - - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ - Creator: i.ALICE, - Id: 0, - Amount: 100 * i.KYVE, - }) - s.RunTxStakersSuccess(&stakertypes.MsgCreateStaker{ Creator: i.STAKER_0, Amount: 100 * i.KYVE, @@ -537,26 +456,6 @@ var _ = Describe("logic_bundles.go", Ordered, func() { It("Assert can vote if storage id does not match", func() { // ASSERT - s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{ - Name: "PoolTest", - UploadInterval: 60, - OperatingCost: 2 * i.KYVE, - MinDelegation: 100 * i.KYVE, - MaxBundleSize: 100, - Protocol: &pooltypes.Protocol{ - Version: "0.0.0", - Binaries: "{}", - LastUpgrade: uint64(s.Ctx().BlockTime().Unix()), - }, - UpgradePlan: &pooltypes.UpgradePlan{}, - }) - - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ - Creator: i.ALICE, - Id: 0, - Amount: 100 * i.KYVE, - }) - s.RunTxStakersSuccess(&stakertypes.MsgCreateStaker{ Creator: i.STAKER_0, Amount: 100 * i.KYVE, @@ -614,26 +513,6 @@ var _ = Describe("logic_bundles.go", Ordered, func() { It("Assert can vote if sender has already voted valid", func() { // ASSERT - s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{ - Name: "PoolTest", - UploadInterval: 60, - OperatingCost: 2 * i.KYVE, - MinDelegation: 100 * i.KYVE, - MaxBundleSize: 100, - Protocol: &pooltypes.Protocol{ - Version: "0.0.0", - Binaries: "{}", - LastUpgrade: uint64(s.Ctx().BlockTime().Unix()), - }, - UpgradePlan: &pooltypes.UpgradePlan{}, - }) - - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ - Creator: i.ALICE, - Id: 0, - Amount: 100 * i.KYVE, - }) - s.RunTxStakersSuccess(&stakertypes.MsgCreateStaker{ Creator: i.STAKER_0, Amount: 100 * i.KYVE, @@ -699,26 +578,6 @@ var _ = Describe("logic_bundles.go", Ordered, func() { It("Assert can vote if sender has already voted invalid", func() { // ASSERT - s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{ - Name: "PoolTest", - UploadInterval: 60, - OperatingCost: 2 * i.KYVE, - MinDelegation: 100 * i.KYVE, - MaxBundleSize: 100, - Protocol: &pooltypes.Protocol{ - Version: "0.0.0", - Binaries: "{}", - LastUpgrade: uint64(s.Ctx().BlockTime().Unix()), - }, - UpgradePlan: &pooltypes.UpgradePlan{}, - }) - - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ - Creator: i.ALICE, - Id: 0, - Amount: 100 * i.KYVE, - }) - s.RunTxStakersSuccess(&stakertypes.MsgCreateStaker{ Creator: i.STAKER_0, Amount: 100 * i.KYVE, @@ -784,26 +643,6 @@ var _ = Describe("logic_bundles.go", Ordered, func() { It("Assert can vote", func() { // ASSERT - s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{ - Name: "PoolTest", - UploadInterval: 60, - OperatingCost: 2 * i.KYVE, - MinDelegation: 100 * i.KYVE, - MaxBundleSize: 100, - Protocol: &pooltypes.Protocol{ - Version: "0.0.0", - Binaries: "{}", - LastUpgrade: uint64(s.Ctx().BlockTime().Unix()), - }, - UpgradePlan: &pooltypes.UpgradePlan{}, - }) - - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ - Creator: i.ALICE, - Id: 0, - Amount: 100 * i.KYVE, - }) - s.RunTxStakersSuccess(&stakertypes.MsgCreateStaker{ Creator: i.STAKER_0, Amount: 100 * i.KYVE, @@ -863,26 +702,6 @@ var _ = Describe("logic_bundles.go", Ordered, func() { It("Assert can propose if sender is no staker", func() { // ASSERT - s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{ - Name: "PoolTest", - UploadInterval: 60, - OperatingCost: 2 * i.KYVE, - MinDelegation: 100 * i.KYVE, - MaxBundleSize: 100, - Protocol: &pooltypes.Protocol{ - Version: "0.0.0", - Binaries: "{}", - LastUpgrade: uint64(s.Ctx().BlockTime().Unix()), - }, - UpgradePlan: &pooltypes.UpgradePlan{}, - }) - - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ - Creator: i.ALICE, - Id: 0, - Amount: 100 * i.KYVE, - }) - s.RunTxStakersSuccess(&stakertypes.MsgCreateStaker{ Creator: i.STAKER_0, Amount: 100 * i.KYVE, @@ -924,26 +743,6 @@ var _ = Describe("logic_bundles.go", Ordered, func() { It("Assert can propose if sender is not next uploader", func() { // ASSERT - s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{ - Name: "PoolTest", - UploadInterval: 60, - OperatingCost: 2 * i.KYVE, - MinDelegation: 100 * i.KYVE, - MaxBundleSize: 100, - Protocol: &pooltypes.Protocol{ - Version: "0.0.0", - Binaries: "{}", - LastUpgrade: uint64(s.Ctx().BlockTime().Unix()), - }, - UpgradePlan: &pooltypes.UpgradePlan{}, - }) - - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ - Creator: i.ALICE, - Id: 0, - Amount: 100 * i.KYVE, - }) - s.RunTxStakersSuccess(&stakertypes.MsgCreateStaker{ Creator: i.STAKER_0, Amount: 100 * i.KYVE, @@ -985,26 +784,6 @@ var _ = Describe("logic_bundles.go", Ordered, func() { It("Assert can propose if upload interval has not passed", func() { // ASSERT - s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{ - Name: "PoolTest", - UploadInterval: 60, - OperatingCost: 2 * i.KYVE, - MinDelegation: 100 * i.KYVE, - MaxBundleSize: 100, - Protocol: &pooltypes.Protocol{ - Version: "0.0.0", - Binaries: "{}", - LastUpgrade: uint64(s.Ctx().BlockTime().Unix()), - }, - UpgradePlan: &pooltypes.UpgradePlan{}, - }) - - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ - Creator: i.ALICE, - Id: 0, - Amount: 100 * i.KYVE, - }) - s.RunTxStakersSuccess(&stakertypes.MsgCreateStaker{ Creator: i.STAKER_0, Amount: 100 * i.KYVE, @@ -1049,26 +828,6 @@ var _ = Describe("logic_bundles.go", Ordered, func() { It("Assert can propose if index does not match", func() { // ASSERT - s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{ - Name: "PoolTest", - UploadInterval: 60, - OperatingCost: 2 * i.KYVE, - MinDelegation: 100 * i.KYVE, - MaxBundleSize: 100, - Protocol: &pooltypes.Protocol{ - Version: "0.0.0", - Binaries: "{}", - LastUpgrade: uint64(s.Ctx().BlockTime().Unix()), - }, - UpgradePlan: &pooltypes.UpgradePlan{}, - }) - - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ - Creator: i.ALICE, - Id: 0, - Amount: 100 * i.KYVE, - }) - s.RunTxStakersSuccess(&stakertypes.MsgCreateStaker{ Creator: i.STAKER_0, Amount: 100 * i.KYVE, @@ -1105,34 +864,11 @@ var _ = Describe("logic_bundles.go", Ordered, func() { err := s.App().BundlesKeeper.AssertCanPropose(s.Ctx(), 0, i.STAKER_0, i.VALADDRESS_0_A, 1000) // ASSERT - pool, _ := s.App().PoolKeeper.GetPool(s.Ctx(), 0) - bundleProposal, _ := s.App().BundlesKeeper.GetBundleProposal(s.Ctx(), 0) - - Expect(err.Error()).To(Equal(errors.Wrapf(bundlesTypes.ErrFromIndex, "expected %v received %v", pool.CurrentIndex+bundleProposal.BundleSize, 1000).Error())) + Expect(err).To(HaveOccurred()) }) It("Assert can propose", func() { // ASSERT - s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{ - Name: "PoolTest", - UploadInterval: 60, - OperatingCost: 2 * i.KYVE, - MinDelegation: 100 * i.KYVE, - MaxBundleSize: 100, - Protocol: &pooltypes.Protocol{ - Version: "0.0.0", - Binaries: "{}", - LastUpgrade: uint64(s.Ctx().BlockTime().Unix()), - }, - UpgradePlan: &pooltypes.UpgradePlan{}, - }) - - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ - Creator: i.ALICE, - Id: 0, - Amount: 100 * i.KYVE, - }) - s.RunTxStakersSuccess(&stakertypes.MsgCreateStaker{ Creator: i.STAKER_0, Amount: 100 * i.KYVE, diff --git a/x/bundles/keeper/logic_end_block_handle_upload_timeout_test.go b/x/bundles/keeper/logic_end_block_handle_upload_timeout_test.go index b024e258..383ebc09 100644 --- a/x/bundles/keeper/logic_end_block_handle_upload_timeout_test.go +++ b/x/bundles/keeper/logic_end_block_handle_upload_timeout_test.go @@ -4,6 +4,7 @@ import ( i "github.com/KYVENetwork/chain/testutil/integration" bundletypes "github.com/KYVENetwork/chain/x/bundles/types" delegationtypes "github.com/KYVENetwork/chain/x/delegation/types" + funderstypes "github.com/KYVENetwork/chain/x/funders/types" pooltypes "github.com/KYVENetwork/chain/x/pool/types" stakertypes "github.com/KYVENetwork/chain/x/stakers/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -45,25 +46,35 @@ var _ = Describe("logic_end_block_handle_upload_timeout.go", Ordered, func() { s = i.NewCleanChain() // create clean pool for every test case - s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{ - Name: "PoolTest", - MaxBundleSize: 100, - StartKey: "0", - MinDelegation: 100 * i.KYVE, - UploadInterval: 60, - OperatingCost: 10_000, - Protocol: &pooltypes.Protocol{ - Version: "0.0.0", - Binaries: "{}", - LastUpgrade: uint64(s.Ctx().BlockTime().Unix()), - }, - UpgradePlan: &pooltypes.UpgradePlan{}, - }) + gov := s.App().GovKeeper.GetGovernanceAccount(s.Ctx()).GetAddress().String() + msg := &pooltypes.MsgCreatePool{ + Authority: gov, + Name: "PoolTest", + Runtime: "@kyve/test", + Logo: "ar://Tewyv2P5VEG8EJ6AUQORdqNTectY9hlOrWPK8wwo-aU", + Config: "ar://DgdB-2hLrxjhyEEbCML__dgZN5_uS7T6Z5XDkaFh3P0", + StartKey: "0", + UploadInterval: 60, + InflationShareWeight: 10_000, + MinDelegation: 100 * i.KYVE, + MaxBundleSize: 100, + Version: "0.0.0", + Binaries: "{}", + StorageProviderId: 2, + CompressionId: 1, + } + s.RunTxPoolSuccess(msg) - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ + s.RunTxFundersSuccess(&funderstypes.MsgCreateFunder{ Creator: i.ALICE, - Id: 0, - Amount: 100 * i.KYVE, + Moniker: "Alice", + }) + + s.RunTxFundersSuccess(&funderstypes.MsgFundPool{ + Creator: i.ALICE, + PoolId: 0, + Amount: 100 * i.KYVE, + AmountPerBundle: 1 * i.KYVE, }) s.RunTxStakersSuccess(&stakertypes.MsgCreateStaker{ @@ -101,9 +112,9 @@ var _ = Describe("logic_end_block_handle_upload_timeout.go", Ordered, func() { PoolId: 0, }) - s.RunTxPoolSuccess(&pooltypes.MsgDefundPool{ + s.RunTxPoolSuccess(&funderstypes.MsgDefundPool{ Creator: i.ALICE, - Id: 0, + PoolId: 0, Amount: 100 * i.KYVE, }) @@ -1000,25 +1011,30 @@ var _ = Describe("logic_end_block_handle_upload_timeout.go", Ordered, func() { It("Staker with already max points is next uploader of bundle proposal in a second pool and upload timeout passes", func() { // ARRANGE - s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{ - Name: "PoolTest2", - MaxBundleSize: 100, - StartKey: "0", - MinDelegation: 100 * i.KYVE, - UploadInterval: 60, - OperatingCost: 10_000, - Protocol: &pooltypes.Protocol{ - Version: "0.0.0", - Binaries: "{}", - LastUpgrade: uint64(s.Ctx().BlockTime().Unix()), - }, - UpgradePlan: &pooltypes.UpgradePlan{}, - }) + gov := s.App().GovKeeper.GetGovernanceAccount(s.Ctx()).GetAddress().String() + msg := &pooltypes.MsgCreatePool{ + Authority: gov, + Name: "PoolTest", + Runtime: "@kyve/test", + Logo: "ar://Tewyv2P5VEG8EJ6AUQORdqNTectY9hlOrWPK8wwo-aU", + Config: "ar://DgdB-2hLrxjhyEEbCML__dgZN5_uS7T6Z5XDkaFh3P0", + StartKey: "0", + UploadInterval: 60, + InflationShareWeight: 10_000, + MinDelegation: 100 * i.KYVE, + MaxBundleSize: 100, + Version: "0.0.0", + Binaries: "{}", + StorageProviderId: 2, + CompressionId: 1, + } + s.RunTxPoolSuccess(msg) - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ - Creator: i.ALICE, - Id: 1, - Amount: 100 * i.KYVE, + s.RunTxPoolSuccess(&funderstypes.MsgFundPool{ + Creator: i.ALICE, + PoolId: 1, + Amount: 100 * i.KYVE, + AmountPerBundle: 1 * i.KYVE, }) s.RunTxStakersSuccess(&stakertypes.MsgJoinPool{ diff --git a/x/bundles/keeper/logic_round_robin_test.go b/x/bundles/keeper/logic_round_robin_test.go index 8e9f95a6..c207b6cb 100644 --- a/x/bundles/keeper/logic_round_robin_test.go +++ b/x/bundles/keeper/logic_round_robin_test.go @@ -63,24 +63,35 @@ var _ = Describe("logic_round_robin.go", Ordered, func() { return i.DUMMY[k] < i.DUMMY[j] }) - s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{ - Name: "PoolTest", - UploadInterval: 60, - OperatingCost: 2 * i.KYVE, - MinDelegation: 1_000_000 * i.KYVE, - MaxBundleSize: 100, - Protocol: &pooltypes.Protocol{ - Version: "0.0.0", - Binaries: "{}", - LastUpgrade: uint64(s.Ctx().BlockTime().Unix()), - }, - UpgradePlan: &pooltypes.UpgradePlan{ - Version: "1.0.0", - Binaries: "{}", - ScheduledAt: uint64(s.Ctx().BlockTime().Unix()), - Duration: 60, - }, - }) + // create clean pool for every test case + gov := s.App().GovKeeper.GetGovernanceAccount(s.Ctx()).GetAddress().String() + msg := &pooltypes.MsgCreatePool{ + Authority: gov, + Name: "PoolTest", + Runtime: "@kyve/test", + Logo: "ar://Tewyv2P5VEG8EJ6AUQORdqNTectY9hlOrWPK8wwo-aU", + Config: "ar://DgdB-2hLrxjhyEEbCML__dgZN5_uS7T6Z5XDkaFh3P0", + StartKey: "0", + UploadInterval: 60, + InflationShareWeight: 2 * i.KYVE, + MinDelegation: 1_000_000 * i.KYVE, + MaxBundleSize: 100, + Version: "0.0.0", + Binaries: "{}", + StorageProviderId: 2, + CompressionId: 1, + } + s.RunTxPoolSuccess(msg) + + pool, _ := s.App().PoolKeeper.GetPool(s.Ctx(), 0) + pool.Protocol.LastUpgrade = uint64(s.Ctx().BlockTime().Unix()) + pool.UpgradePlan = &pooltypes.UpgradePlan{ + Version: "1.0.0", + Binaries: "{}", + ScheduledAt: uint64(s.Ctx().BlockTime().Unix()), + Duration: 60, + } + s.App().PoolKeeper.SetPool(s.Ctx(), pool) }) AfterEach(func() { diff --git a/x/bundles/keeper/msg_server_claim_uploader_role_test.go b/x/bundles/keeper/msg_server_claim_uploader_role_test.go index ea2f9d08..7e7f1a53 100644 --- a/x/bundles/keeper/msg_server_claim_uploader_role_test.go +++ b/x/bundles/keeper/msg_server_claim_uploader_role_test.go @@ -1,6 +1,7 @@ package keeper_test import ( + funderstypes "github.com/KYVENetwork/chain/x/funders/types" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" @@ -24,20 +25,35 @@ TEST CASES - msg_server_claim_uploader_role.go var _ = Describe("msg_server_claim_uploader_role.go", Ordered, func() { s := i.NewCleanChain() + gov := s.App().GovKeeper.GetGovernanceAccount(s.Ctx()).GetAddress().String() BeforeEach(func() { // init new clean chain s = i.NewCleanChain() // create clean pool for every test case - s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{ - Name: "PoolTest", - Protocol: &pooltypes.Protocol{ - Version: "0.0.0", - Binaries: "{}", - LastUpgrade: uint64(s.Ctx().BlockTime().Unix()), - }, - UpgradePlan: &pooltypes.UpgradePlan{}, + msg := &pooltypes.MsgCreatePool{ + Authority: gov, + Name: "PoolTest", + Runtime: "@kyve/test", + Logo: "ar://Tewyv2P5VEG8EJ6AUQORdqNTectY9hlOrWPK8wwo-aU", + Config: "ar://DgdB-2hLrxjhyEEbCML__dgZN5_uS7T6Z5XDkaFh3P0", + StartKey: "0", + UploadInterval: 60, + InflationShareWeight: 10_000, + MinDelegation: 100 * i.KYVE, + MaxBundleSize: 100, + Version: "0.0.0", + Binaries: "{}", + StorageProviderId: 2, + CompressionId: 1, + } + s.RunTxPoolSuccess(msg) + + // create funders + s.RunTxFundersSuccess(&funderstypes.MsgCreateFunder{ + Creator: i.ALICE, + Moniker: "Alice", }) s.RunTxStakersSuccess(&stakertypes.MsgCreateStaker{ @@ -84,10 +100,11 @@ var _ = Describe("msg_server_claim_uploader_role.go", Ordered, func() { It("Try to claim uploader role without being a staker", func() { // ARRANGE - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ - Creator: i.ALICE, - Id: 0, - Amount: 100 * i.KYVE, + s.RunTxPoolSuccess(&funderstypes.MsgFundPool{ + Creator: i.ALICE, + PoolId: 0, + Amount: 100 * i.KYVE, + AmountPerBundle: 1 * i.KYVE, }) // ACT @@ -104,10 +121,11 @@ var _ = Describe("msg_server_claim_uploader_role.go", Ordered, func() { It("Try to claim uploader role if the next uploader is not set yet", func() { // ARRANGE - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ - Creator: i.ALICE, - Id: 0, - Amount: 100 * i.KYVE, + s.RunTxPoolSuccess(&funderstypes.MsgFundPool{ + Creator: i.ALICE, + PoolId: 0, + Amount: 100 * i.KYVE, + AmountPerBundle: 1 * i.KYVE, }) // ACT @@ -139,10 +157,11 @@ var _ = Describe("msg_server_claim_uploader_role.go", Ordered, func() { It("Try to claim uploader role with non existing valaccount", func() { // ARRANGE - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ - Creator: i.ALICE, - Id: 0, - Amount: 100 * i.KYVE, + s.RunTxPoolSuccess(&funderstypes.MsgFundPool{ + Creator: i.ALICE, + PoolId: 0, + Amount: 100 * i.KYVE, + AmountPerBundle: 1 * i.KYVE, }) // ACT @@ -159,21 +178,30 @@ var _ = Describe("msg_server_claim_uploader_role.go", Ordered, func() { It("Try to claim uploader role with valaccount that belongs to another pool", func() { // ARRANGE - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ - Creator: i.ALICE, - Id: 0, - Amount: 100 * i.KYVE, + s.RunTxPoolSuccess(&funderstypes.MsgFundPool{ + Creator: i.ALICE, + PoolId: 0, + Amount: 100 * i.KYVE, + AmountPerBundle: 1 * i.KYVE, }) - s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{ - Name: "PoolTest2", - Protocol: &pooltypes.Protocol{ - Version: "0.0.0", - Binaries: "{}", - LastUpgrade: uint64(s.Ctx().BlockTime().Unix()), - }, - UpgradePlan: &pooltypes.UpgradePlan{}, - }) + msg := &pooltypes.MsgCreatePool{ + Authority: gov, + Name: "PoolTest", + Runtime: "@kyve/test", + Logo: "ar://Tewyv2P5VEG8EJ6AUQORdqNTectY9hlOrWPK8wwo-aU", + Config: "ar://DgdB-2hLrxjhyEEbCML__dgZN5_uS7T6Z5XDkaFh3P0", + StartKey: "0", + UploadInterval: 60, + InflationShareWeight: 10_000, + MinDelegation: 100 * i.KYVE, + MaxBundleSize: 100, + Version: "0.0.0", + Binaries: "{}", + StorageProviderId: 2, + CompressionId: 1, + } + s.RunTxPoolSuccess(msg) s.RunTxStakersSuccess(&stakertypes.MsgJoinPool{ Creator: i.STAKER_0, @@ -195,10 +223,11 @@ var _ = Describe("msg_server_claim_uploader_role.go", Ordered, func() { It("Try to claim uploader role if someone else is already next uploader", func() { // ARRANGE - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ - Creator: i.ALICE, - Id: 0, - Amount: 100 * i.KYVE, + s.RunTxPoolSuccess(&funderstypes.MsgFundPool{ + Creator: i.ALICE, + PoolId: 0, + Amount: 100 * i.KYVE, + AmountPerBundle: 1 * i.KYVE, }) s.RunTxBundlesSuccess(&bundletypes.MsgClaimUploaderRole{ diff --git a/x/bundles/keeper/msg_server_skip_uploader_role_test.go b/x/bundles/keeper/msg_server_skip_uploader_role_test.go index 1a01a3f4..8f7de1f3 100644 --- a/x/bundles/keeper/msg_server_skip_uploader_role_test.go +++ b/x/bundles/keeper/msg_server_skip_uploader_role_test.go @@ -3,6 +3,7 @@ package keeper_test import ( i "github.com/KYVENetwork/chain/testutil/integration" bundletypes "github.com/KYVENetwork/chain/x/bundles/types" + funderstypes "github.com/KYVENetwork/chain/x/funders/types" pooltypes "github.com/KYVENetwork/chain/x/pool/types" stakertypes "github.com/KYVENetwork/chain/x/stakers/types" . "github.com/onsi/ginkgo/v2" @@ -27,23 +28,35 @@ var _ = Describe("msg_server_skip_uploader_role.go", Ordered, func() { s = i.NewCleanChain() // create clean pool for every test case - s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{ - Name: "PoolTest", - MaxBundleSize: 100, - StartKey: "0", - UploadInterval: 60, - OperatingCost: 10_000, - Protocol: &pooltypes.Protocol{ - Version: "0.0.0", - Binaries: "{}", - LastUpgrade: uint64(s.Ctx().BlockTime().Unix()), - }, - UpgradePlan: &pooltypes.UpgradePlan{}, + gov := s.App().GovKeeper.GetGovernanceAccount(s.Ctx()).GetAddress().String() + msg := &pooltypes.MsgCreatePool{ + Authority: gov, + Name: "PoolTest", + Runtime: "@kyve/test", + Logo: "ar://Tewyv2P5VEG8EJ6AUQORdqNTectY9hlOrWPK8wwo-aU", + Config: "ar://DgdB-2hLrxjhyEEbCML__dgZN5_uS7T6Z5XDkaFh3P0", + StartKey: "0", + UploadInterval: 60, + InflationShareWeight: 10_000, + MinDelegation: 0 * i.KYVE, + MaxBundleSize: 100, + Version: "0.0.0", + Binaries: "{}", + StorageProviderId: 2, + CompressionId: 1, + } + s.RunTxPoolSuccess(msg) + + //// create funders + s.RunTxFundersSuccess(&funderstypes.MsgCreateFunder{ + Creator: i.ALICE, + Moniker: "Alice", }) - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ - Creator: i.ALICE, - Amount: 100 * i.KYVE, + s.RunTxPoolSuccess(&funderstypes.MsgFundPool{ + Creator: i.ALICE, + Amount: 100 * i.KYVE, + AmountPerBundle: 1 * i.KYVE, }) s.RunTxStakersSuccess(&stakertypes.MsgCreateStaker{ diff --git a/x/bundles/keeper/msg_server_submit_bundle_proposal.go b/x/bundles/keeper/msg_server_submit_bundle_proposal.go index 4d95de09..2185b45e 100644 --- a/x/bundles/keeper/msg_server_submit_bundle_proposal.go +++ b/x/bundles/keeper/msg_server_submit_bundle_proposal.go @@ -66,8 +66,8 @@ func (k msgServer) SubmitBundleProposal(goCtx context.Context, msg *types.MsgSub pool, _ := k.poolKeeper.GetPool(ctx, msg.PoolId) - // charge the operating cost from funders - fundersPayout, err := k.poolKeeper.ChargeFundersOfPool(ctx, msg.PoolId, pool.OperatingCost) + // charge the funders of the pool + fundersPayout, err := k.fundersKeeper.ChargeFundersOfPool(ctx, msg.PoolId) if err != nil { return &types.MsgSubmitBundleProposalResponse{}, err } diff --git a/x/bundles/keeper/msg_server_submit_bundle_proposal_test.go b/x/bundles/keeper/msg_server_submit_bundle_proposal_test.go index 32e3fcae..0f523fba 100644 --- a/x/bundles/keeper/msg_server_submit_bundle_proposal_test.go +++ b/x/bundles/keeper/msg_server_submit_bundle_proposal_test.go @@ -1,6 +1,7 @@ package keeper_test import ( + funderstypes "github.com/KYVENetwork/chain/x/funders/types" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" @@ -35,23 +36,35 @@ var _ = Describe("msg_server_submit_bundle_proposal.go", Ordered, func() { s = i.NewCleanChain() // create clean pool for every test case - s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{ - Name: "PoolTest", - MaxBundleSize: 100, - StartKey: "0", - UploadInterval: 60, - OperatingCost: 10_000, - Protocol: &pooltypes.Protocol{ - Version: "0.0.0", - Binaries: "{}", - LastUpgrade: uint64(s.Ctx().BlockTime().Unix()), - }, - UpgradePlan: &pooltypes.UpgradePlan{}, + gov := s.App().GovKeeper.GetGovernanceAccount(s.Ctx()).GetAddress().String() + msg := &pooltypes.MsgCreatePool{ + Authority: gov, + Name: "PoolTest", + Runtime: "@kyve/test", + Logo: "ar://Tewyv2P5VEG8EJ6AUQORdqNTectY9hlOrWPK8wwo-aU", + Config: "ar://DgdB-2hLrxjhyEEbCML__dgZN5_uS7T6Z5XDkaFh3P0", + StartKey: "0", + UploadInterval: 60, + InflationShareWeight: 10_000, + MinDelegation: 0 * i.KYVE, + MaxBundleSize: 100, + Version: "0.0.0", + Binaries: "{}", + StorageProviderId: 2, + CompressionId: 1, + } + s.RunTxPoolSuccess(msg) + + //// create funders + s.RunTxFundersSuccess(&funderstypes.MsgCreateFunder{ + Creator: i.STAKER_0, + Moniker: "Staker 0", }) - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ - Creator: i.STAKER_0, - Amount: 100 * i.KYVE, + s.RunTxPoolSuccess(&funderstypes.MsgFundPool{ + Creator: i.STAKER_0, + Amount: 100 * i.KYVE, + AmountPerBundle: 1 * i.KYVE, }) s.RunTxStakersSuccess(&stakertypes.MsgCreateStaker{ diff --git a/x/bundles/keeper/msg_server_vote_bundle_proposal_test.go b/x/bundles/keeper/msg_server_vote_bundle_proposal_test.go index 9db0c936..87f7a1ae 100644 --- a/x/bundles/keeper/msg_server_vote_bundle_proposal_test.go +++ b/x/bundles/keeper/msg_server_vote_bundle_proposal_test.go @@ -1,6 +1,7 @@ package keeper_test import ( + funderstypes "github.com/KYVENetwork/chain/x/funders/types" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" @@ -30,20 +31,38 @@ var _ = Describe("msg_server_vote_bundle_proposal.go", Ordered, func() { s = i.NewCleanChain() // create clean pool for every test case - s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{ - Name: "PoolTest", - MaxBundleSize: 100, - Protocol: &pooltypes.Protocol{ - Version: "0.0.0", - Binaries: "{}", - LastUpgrade: uint64(s.Ctx().BlockTime().Unix()), - }, - UpgradePlan: &pooltypes.UpgradePlan{}, - }) - - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ + gov := s.App().GovKeeper.GetGovernanceAccount(s.Ctx()).GetAddress().String() + msg := &pooltypes.MsgCreatePool{ + Authority: gov, + Name: "PoolTest", + Runtime: "@kyve/test", + Logo: "ar://Tewyv2P5VEG8EJ6AUQORdqNTectY9hlOrWPK8wwo-aU", + Config: "ar://DgdB-2hLrxjhyEEbCML__dgZN5_uS7T6Z5XDkaFh3P0", + StartKey: "0", + UploadInterval: 60, + InflationShareWeight: 10_000, + MinDelegation: 0 * i.KYVE, + MaxBundleSize: 100, + Version: "0.0.0", + Binaries: "{}", + StorageProviderId: 2, + CompressionId: 1, + } + s.RunTxPoolSuccess(msg) + pool, _ := s.App().PoolKeeper.GetPool(s.Ctx(), 0) + pool.UploadInterval = 0 + s.App().PoolKeeper.SetPool(s.Ctx(), pool) + + //// create funders + s.RunTxFundersSuccess(&funderstypes.MsgCreateFunder{ Creator: i.ALICE, - Amount: 100 * i.KYVE, + Moniker: "Alice", + }) + + s.RunTxPoolSuccess(&funderstypes.MsgFundPool{ + Creator: i.ALICE, + Amount: 100 * i.KYVE, + AmountPerBundle: 1 * i.KYVE, }) s.RunTxStakersSuccess(&stakertypes.MsgCreateStaker{ diff --git a/x/bundles/spec/04_begin_block.md b/x/bundles/spec/04_begin_block.md index cb7d4c17..7f0e8cb9 100644 --- a/x/bundles/spec/04_begin_block.md +++ b/x/bundles/spec/04_begin_block.md @@ -6,4 +6,4 @@ order: 4 BeginBlock is used to distribute the inflation split to the pools. All active pools are eligible for the inflation split. The distribution -between the pools are determined by the operating cost of each pool. +between the pools are determined by the inflation share weight of each pool. diff --git a/x/bundles/types/errors.go b/x/bundles/types/errors.go index b6530677..9a30d74a 100644 --- a/x/bundles/types/errors.go +++ b/x/bundles/types/errors.go @@ -18,7 +18,6 @@ var ( ErrPoolDisabled = errors.Register(ModuleName, 1121, "pool is disabled") ErrPoolCurrentlyUpgrading = errors.Register(ModuleName, 1122, "pool currently upgrading") ErrMinDelegationNotReached = errors.Register(ModuleName, 1200, "min delegation not reached") - ErrPoolOutOfFunds = errors.Register(ModuleName, 1201, "pool is out of funds") ErrBundleDropped = errors.Register(ModuleName, 1202, "bundle proposal is dropped") ErrAlreadyVotedValid = errors.Register(ModuleName, 1204, "already voted valid on bundle proposal") ErrAlreadyVotedInvalid = errors.Register(ModuleName, 1205, "already voted invalid on bundle proposal") diff --git a/x/bundles/types/expected_keepers.go b/x/bundles/types/expected_keepers.go index b6102fa2..ed267f77 100644 --- a/x/bundles/types/expected_keepers.go +++ b/x/bundles/types/expected_keepers.go @@ -36,7 +36,6 @@ type PoolKeeper interface { IncrementBundleInformation(ctx sdk.Context, poolId uint64, currentHeight uint64, currentKey string, currentValue string) GetAllPools(ctx sdk.Context) (list []pooltypes.Pool) - ChargeFundersOfPool(ctx sdk.Context, poolId uint64, amount uint64) (payout uint64, err error) ChargeInflationPool(ctx sdk.Context, poolId uint64) (payout uint64, err error) } @@ -62,3 +61,7 @@ type DelegationKeeper interface { PayoutRewards(ctx sdk.Context, staker string, amount uint64, payerModuleName string) error SlashDelegators(ctx sdk.Context, poolId uint64, staker string, slashType delegationTypes.SlashType) } + +type FundersKeeper interface { + ChargeFundersOfPool(ctx sdk.Context, poolId uint64) (payout uint64, err error) +} diff --git a/x/delegation/keeper/keeper_suite_test.go b/x/delegation/keeper/keeper_suite_test.go index 160587f1..392e2468 100644 --- a/x/delegation/keeper/keeper_suite_test.go +++ b/x/delegation/keeper/keeper_suite_test.go @@ -4,6 +4,8 @@ import ( "fmt" "testing" + funderstypes "github.com/KYVENetwork/chain/x/funders/types" + i "github.com/KYVENetwork/chain/testutil/integration" "github.com/KYVENetwork/chain/x/delegation/types" pooltypes "github.com/KYVENetwork/chain/x/pool/types" @@ -18,7 +20,17 @@ func TestDelegationKeeper(t *testing.T) { } func PayoutRewards(s *i.KeeperTestSuite, staker string, amount uint64) { - payout, err := s.App().PoolKeeper.ChargeFundersOfPool(s.Ctx(), 0, amount) + fundingState, found := s.App().FundersKeeper.GetFundingState(s.Ctx(), 0) + Expect(found).To(BeTrue()) + + // divide amount by number of active fundings so that total payout is equal to amount + activeFundings := s.App().FundersKeeper.GetActiveFundings(s.Ctx(), fundingState) + for _, funding := range activeFundings { + funding.AmountPerBundle = amount / uint64(len(activeFundings)) + s.App().FundersKeeper.SetFunding(s.Ctx(), &funding) + } + + payout, err := s.App().FundersKeeper.ChargeFundersOfPool(s.Ctx(), 0) Expect(err).To(BeNil()) err = s.App().DelegationKeeper.PayoutRewards(s.Ctx(), staker, amount, pooltypes.ModuleName) Expect(err).NotTo(HaveOccurred()) @@ -26,30 +38,44 @@ func PayoutRewards(s *i.KeeperTestSuite, staker string, amount uint64) { } func CreateFundedPool(s *i.KeeperTestSuite) { - s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{ - Name: "PoolTest", - Protocol: &pooltypes.Protocol{ - Version: "0.0.0", - Binaries: "{}", - LastUpgrade: uint64(s.Ctx().BlockTime().Unix()), - }, - UpgradePlan: &pooltypes.UpgradePlan{}, - }) + gov := s.App().GovKeeper.GetGovernanceAccount(s.Ctx()).GetAddress().String() + msg := &pooltypes.MsgCreatePool{ + Authority: gov, + Name: "PoolTest", + Runtime: "@kyve/test", + Logo: "ar://Tewyv2P5VEG8EJ6AUQORdqNTectY9hlOrWPK8wwo-aU", + Config: "ar://DgdB-2hLrxjhyEEbCML__dgZN5_uS7T6Z5XDkaFh3P0", + StartKey: "0", + UploadInterval: 60, + InflationShareWeight: 10_000, + MinDelegation: 100 * i.KYVE, + MaxBundleSize: 100, + Version: "0.0.0", + Binaries: "{}", + StorageProviderId: 2, + CompressionId: 1, + } + s.RunTxPoolSuccess(msg) s.CommitAfterSeconds(7) - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ + s.RunTxFundersSuccess(&funderstypes.MsgCreateFunder{ Creator: i.ALICE, - Id: 0, - Amount: 100 * i.KYVE, + Moniker: "Alice", + }) + + s.RunTxPoolSuccess(&funderstypes.MsgFundPool{ + Creator: i.ALICE, + PoolId: 0, + Amount: 100 * i.KYVE, + AmountPerBundle: 1 * i.KYVE, }) s.CommitAfterSeconds(7) - pool, poolFound := s.App().PoolKeeper.GetPool(s.Ctx(), 0) + fundingState, _ := s.App().FundersKeeper.GetFundingState(s.Ctx(), 0) - Expect(poolFound).To(BeTrue()) - Expect(pool.TotalFunds).To(Equal(100 * i.KYVE)) + Expect(s.App().FundersKeeper.GetTotalActiveFunding(s.Ctx(), fundingState.PoolId)).To(Equal(100 * i.KYVE)) } func CheckAndContinueChainForOneMonth(s *i.KeeperTestSuite) { diff --git a/x/delegation/keeper/msg_server_delegate_test.go b/x/delegation/keeper/msg_server_delegate_test.go index 991df2a9..c5880469 100644 --- a/x/delegation/keeper/msg_server_delegate_test.go +++ b/x/delegation/keeper/msg_server_delegate_test.go @@ -1,12 +1,12 @@ package keeper_test import ( + funderstypes "github.com/KYVENetwork/chain/x/funders/types" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" i "github.com/KYVENetwork/chain/testutil/integration" "github.com/KYVENetwork/chain/x/delegation/types" - pooltypes "github.com/KYVENetwork/chain/x/pool/types" stakerstypes "github.com/KYVENetwork/chain/x/stakers/types" ) @@ -156,9 +156,9 @@ var _ = Describe("msg_server_delegate.go", Ordered, func() { Amount: 209 * i.KYVE, }) - poolModuleBalance := s.GetBalanceFromModule(pooltypes.ModuleName) + fundersModuleBalance := s.GetBalanceFromModule(funderstypes.ModuleName) - Expect(poolModuleBalance).To(Equal(100 * i.KYVE)) + Expect(fundersModuleBalance).To(Equal(100 * i.KYVE)) Expect(s.App().DelegationKeeper.GetOutstandingRewards(s.Ctx(), i.ALICE, i.DUMMY[0])).To(BeZero()) Expect(s.App().DelegationKeeper.GetOutstandingRewards(s.Ctx(), i.ALICE, i.DUMMY[1])).To(BeZero()) @@ -186,8 +186,8 @@ var _ = Describe("msg_server_delegate.go", Ordered, func() { Expect(s.App().DelegationKeeper.GetOutstandingRewards(s.Ctx(), i.ALICE, i.DUMMY[0])).To(Equal(uint64(0))) Expect(s.App().DelegationKeeper.GetOutstandingRewards(s.Ctx(), i.ALICE, i.DUMMY[1])).To(Equal(uint64(5_110_024_449))) - Expect(s.GetBalanceFromAddress(i.DUMMY[0])).To(Equal(uint64(900*i.KYVE + 2_444_987_775))) - Expect(s.GetBalanceFromModule(pooltypes.ModuleName)).To(Equal(90 * i.KYVE)) + Expect(s.GetBalanceFromAddress(i.DUMMY[0])).To(Equal(900*i.KYVE + 2_444_987_775)) + Expect(s.GetBalanceFromModule(funderstypes.ModuleName)).To(Equal(90 * i.KYVE)) Expect(s.GetBalanceFromModule(types.ModuleName)).To(Equal((200+409)*i.KYVE + uint64(2_444_987_775+5_110_024_449+1))) }) @@ -205,9 +205,9 @@ var _ = Describe("msg_server_delegate.go", Ordered, func() { Amount: 200 * i.KYVE, }) - poolModuleBalance := s.GetBalanceFromModule(pooltypes.ModuleName) + fundersModuleBalance := s.GetBalanceFromModule(funderstypes.ModuleName) - Expect(poolModuleBalance).To(Equal(100 * i.KYVE)) + Expect(fundersModuleBalance).To(Equal(100 * i.KYVE)) Expect(s.App().DelegationKeeper.GetOutstandingRewards(s.Ctx(), i.ALICE, i.DUMMY[0])).To(BeZero()) Expect(s.App().DelegationKeeper.GetOutstandingRewards(s.Ctx(), i.ALICE, i.DUMMY[1])).To(BeZero()) @@ -238,8 +238,8 @@ var _ = Describe("msg_server_delegate.go", Ordered, func() { Expect(s.App().DelegationKeeper.GetOutstandingRewards(s.Ctx(), i.ALICE, i.DUMMY[0])).To(Equal(uint64(0))) Expect(s.App().DelegationKeeper.GetOutstandingRewards(s.Ctx(), i.ALICE, i.DUMMY[1])).To(Equal(uint64(5_000_000_000))) - Expect(s.GetBalanceFromAddress(i.DUMMY[0])).To(Equal(uint64(900*i.KYVE + 2_500_000_000))) - Expect(s.GetBalanceFromModule(pooltypes.ModuleName)).To(Equal(90 * i.KYVE)) + Expect(s.GetBalanceFromAddress(i.DUMMY[0])).To(Equal(900*i.KYVE + 2_500_000_000)) + Expect(s.GetBalanceFromModule(funderstypes.ModuleName)).To(Equal(90 * i.KYVE)) Expect(s.GetBalanceFromModule(types.ModuleName)).To(Equal(600*i.KYVE + 7_500_000_000)) }) diff --git a/x/delegation/keeper/msg_server_redelegate_test.go b/x/delegation/keeper/msg_server_redelegate_test.go index 4a0d2997..f8c49d51 100644 --- a/x/delegation/keeper/msg_server_redelegate_test.go +++ b/x/delegation/keeper/msg_server_redelegate_test.go @@ -34,17 +34,24 @@ var _ = Describe("Delegation - Redelegation", Ordered, func() { CreateFundedPool(s) - s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{ - Name: "EnabledPool", - MinDelegation: 1_000 * i.KYVE, - Protocol: &pooltypes.Protocol{ - Version: "0.0.0", - Binaries: "{}", - LastUpgrade: uint64(s.Ctx().BlockTime().Unix()), - }, - Disabled: false, - UpgradePlan: &pooltypes.UpgradePlan{}, - }) + gov := s.App().GovKeeper.GetGovernanceAccount(s.Ctx()).GetAddress().String() + msg := &pooltypes.MsgCreatePool{ + Authority: gov, + Name: "PoolTest", + Runtime: "@kyve/test", + Logo: "ar://Tewyv2P5VEG8EJ6AUQORdqNTectY9hlOrWPK8wwo-aU", + Config: "ar://DgdB-2hLrxjhyEEbCML__dgZN5_uS7T6Z5XDkaFh3P0", + StartKey: "0", + UploadInterval: 60, + InflationShareWeight: 10_000, + MinDelegation: 1_000 * i.KYVE, + MaxBundleSize: 100, + Version: "0.0.0", + Binaries: "{}", + StorageProviderId: 2, + CompressionId: 1, + } + s.RunTxPoolSuccess(msg) s.RunTxStakersSuccess(&stakerstypes.MsgCreateStaker{ Creator: i.ALICE, diff --git a/x/delegation/keeper/msg_server_undelegate_test.go b/x/delegation/keeper/msg_server_undelegate_test.go index a91d99b9..ddff84a6 100644 --- a/x/delegation/keeper/msg_server_undelegate_test.go +++ b/x/delegation/keeper/msg_server_undelegate_test.go @@ -49,16 +49,24 @@ var _ = Describe("msg_server_undelegate.go", Ordered, func() { Amount: bobSelfDelegation, }) - s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{ - Name: "DisabledPool", - Protocol: &pooltypes.Protocol{ - Version: "0.0.0", - Binaries: "{}", - LastUpgrade: uint64(s.Ctx().BlockTime().Unix()), - }, - Disabled: true, - UpgradePlan: &pooltypes.UpgradePlan{}, - }) + gov := s.App().GovKeeper.GetGovernanceAccount(s.Ctx()).GetAddress().String() + msg := &pooltypes.MsgCreatePool{ + Authority: gov, + Name: "PoolTest", + Runtime: "@kyve/test", + Logo: "ar://Tewyv2P5VEG8EJ6AUQORdqNTectY9hlOrWPK8wwo-aU", + Config: "ar://DgdB-2hLrxjhyEEbCML__dgZN5_uS7T6Z5XDkaFh3P0", + StartKey: "0", + UploadInterval: 60, + InflationShareWeight: 10_000, + MinDelegation: 100 * i.KYVE, + MaxBundleSize: 100, + Version: "0.0.0", + Binaries: "{}", + StorageProviderId: 2, + CompressionId: 1, + } + s.RunTxPoolSuccess(msg) s.RunTxStakersSuccess(&stakerstypes.MsgJoinPool{ Creator: i.BOB, diff --git a/x/delegation/keeper/msg_server_withdraw_rewards_test.go b/x/delegation/keeper/msg_server_withdraw_rewards_test.go index 357ad1b5..d4717773 100644 --- a/x/delegation/keeper/msg_server_withdraw_rewards_test.go +++ b/x/delegation/keeper/msg_server_withdraw_rewards_test.go @@ -1,6 +1,7 @@ package keeper_test import ( + funderstypes "github.com/KYVENetwork/chain/x/funders/types" pooltypes "github.com/KYVENetwork/chain/x/pool/types" stakerstypes "github.com/KYVENetwork/chain/x/stakers/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -82,7 +83,7 @@ var _ = Describe("msg_server_withdraw_rewards.go", Ordered, func() { Expect(s.App().DelegationKeeper.GetDelegationAmount(s.Ctx(), i.ALICE)).To(Equal(aliceSelfDelegation + 30*i.KYVE)) delegationModuleBalanceBefore := s.GetBalanceFromModule(types.ModuleName) - poolModuleBalanceBefore := s.GetBalanceFromModule(pooltypes.ModuleName) + fundersModuleBalanceBefore := s.GetBalanceFromModule(funderstypes.ModuleName) s.PerformValidityChecks() // ACT @@ -94,10 +95,10 @@ var _ = Describe("msg_server_withdraw_rewards.go", Ordered, func() { // ASSERT delegationModuleBalanceAfter := s.GetBalanceFromModule(types.ModuleName) - poolModuleBalanceAfter := s.GetBalanceFromModule(pooltypes.ModuleName) + fundersModuleBalanceAfter := s.GetBalanceFromModule(funderstypes.ModuleName) Expect(delegationModuleBalanceAfter).To(Equal(delegationModuleBalanceBefore + 20*i.KYVE)) - Expect(poolModuleBalanceAfter).To(Equal(poolModuleBalanceBefore - 20*i.KYVE)) + Expect(fundersModuleBalanceAfter).To(Equal(fundersModuleBalanceBefore - 20*i.KYVE)) Expect(s.App().DelegationKeeper.GetOutstandingRewards(s.Ctx(), i.ALICE, i.DUMMY[0])).To(Equal(uint64(6666666666))) Expect(s.App().DelegationKeeper.GetOutstandingRewards(s.Ctx(), i.ALICE, i.DUMMY[1])).To(Equal(uint64(6666666666))) @@ -154,10 +155,11 @@ var _ = Describe("msg_server_withdraw_rewards.go", Ordered, func() { // ARRANGE // fund pool module - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ - Creator: i.ALICE, - Id: 0, - Amount: 100 * i.KYVE, + s.RunTxFundersSuccess(&funderstypes.MsgFundPool{ + Creator: i.ALICE, + PoolId: 0, + Amount: 100 * i.KYVE, + AmountPerBundle: 1 * i.KYVE, }) // ACT diff --git a/x/funders/client/cli/flags.go b/x/funders/client/cli/flags.go new file mode 100644 index 00000000..e9258eb7 --- /dev/null +++ b/x/funders/client/cli/flags.go @@ -0,0 +1,25 @@ +package cli + +import ( + flag "github.com/spf13/pflag" +) + +const ( + FlagMoniker = "moniker" + FlagIdentity = "identity" + FlagWebsite = "website" + FlagContact = "contact" + FlagDescription = "description" +) + +func flagSetFunderCreate() *flag.FlagSet { + fs := flag.NewFlagSet("", flag.ContinueOnError) + + fs.String(FlagMoniker, "", "The funder's name") + fs.String(FlagIdentity, "", "The optional identity signature (ex. UPort or Keybase)") + fs.String(FlagWebsite, "", "The funder's (optional) website") + fs.String(FlagContact, "", "The funder's (optional) security contact email") + fs.String(FlagDescription, "", "The funder's (optional) description") + + return fs +} diff --git a/x/funders/client/cli/query.go b/x/funders/client/cli/query.go new file mode 100644 index 00000000..6378890d --- /dev/null +++ b/x/funders/client/cli/query.go @@ -0,0 +1,31 @@ +package cli + +import ( + "fmt" + // "strings" + + "github.com/spf13/cobra" + + "github.com/cosmos/cosmos-sdk/client" + // "github.com/cosmos/cosmos-sdk/client/flags" + // sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/KYVENetwork/chain/x/funders/types" +) + +// GetQueryCmd returns the cli query commands for this module +func GetQueryCmd(queryRoute string) *cobra.Command { + // Group funders queries under a subcommand + cmd := &cobra.Command{ + Use: types.ModuleName, + Short: fmt.Sprintf("Querying commands for the %s module", types.ModuleName), + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + cmd.AddCommand(CmdQueryParams()) + // this line is used by starport scaffolding # 1 + + return cmd +} diff --git a/x/funders/client/cli/query_params.go b/x/funders/client/cli/query_params.go new file mode 100644 index 00000000..782568e8 --- /dev/null +++ b/x/funders/client/cli/query_params.go @@ -0,0 +1,36 @@ +package cli + +import ( + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/spf13/cobra" + + "github.com/KYVENetwork/chain/x/funders/types" +) + +func CmdQueryParams() *cobra.Command { + cmd := &cobra.Command{ + Use: "params", + Short: "shows the parameters of the module", + Args: cobra.NoArgs, + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + res, err := queryClient.Params(cmd.Context(), &types.QueryParamsRequest{}) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/funders/client/cli/tx.go b/x/funders/client/cli/tx.go new file mode 100644 index 00000000..b98cb825 --- /dev/null +++ b/x/funders/client/cli/tx.go @@ -0,0 +1,30 @@ +package cli + +import ( + "fmt" + + "github.com/spf13/cobra" + + "github.com/cosmos/cosmos-sdk/client" + // "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/KYVENetwork/chain/x/funders/types" +) + +// GetTxCmd returns the transaction commands for this module +func GetTxCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: types.ModuleName, + Short: fmt.Sprintf("%s transactions subcommands", types.ModuleName), + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + cmd.AddCommand(CmdCreateFunder()) + cmd.AddCommand(CmdUpdateFunder()) + cmd.AddCommand(CmdFundPool()) + cmd.AddCommand(CmdDefundPool()) + // this line is used by starport scaffolding # 1 + + return cmd +} diff --git a/x/funders/client/cli/tx_create_funder.go b/x/funders/client/cli/tx_create_funder.go new file mode 100644 index 00000000..e7bb4c72 --- /dev/null +++ b/x/funders/client/cli/tx_create_funder.go @@ -0,0 +1,47 @@ +package cli + +import ( + "github.com/KYVENetwork/chain/x/funders/types" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" + "github.com/spf13/cobra" +) + +func CmdCreateFunder() *cobra.Command { + cmd := &cobra.Command{ + Use: "create-funder [moniker]", + Short: "Broadcast message create-funder", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) (err error) { + argMoniker := args[0] + identity, _ := cmd.Flags().GetString(FlagIdentity) + website, _ := cmd.Flags().GetString(FlagWebsite) + contact, _ := cmd.Flags().GetString(FlagContact) + description, _ := cmd.Flags().GetString(FlagDescription) + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + msg := &types.MsgCreateFunder{ + Creator: clientCtx.GetFromAddress().String(), + Moniker: argMoniker, + Identity: identity, + Website: website, + Contact: contact, + Description: description, + } + if err := msg.ValidateBasic(); err != nil { + return err + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + cmd.Flags().AddFlagSet(flagSetFunderCreate()) + flags.AddTxFlagsToCmd(cmd) + + return cmd +} diff --git a/x/pool/client/cli/tx_defund_pool.go b/x/funders/client/cli/tx_defund_pool.go similarity index 83% rename from x/pool/client/cli/tx_defund_pool.go rename to x/funders/client/cli/tx_defund_pool.go index 8bf60be8..3c41183f 100644 --- a/x/pool/client/cli/tx_defund_pool.go +++ b/x/funders/client/cli/tx_defund_pool.go @@ -1,7 +1,7 @@ package cli import ( - "github.com/KYVENetwork/chain/x/pool/types" + "github.com/KYVENetwork/chain/x/funders/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/tx" @@ -29,11 +29,11 @@ func CmdDefundPool() *cobra.Command { return err } - msg := types.NewMsgDefundPool( - clientCtx.GetFromAddress().String(), - argId, - argAmount, - ) + msg := &types.MsgDefundPool{ + Creator: clientCtx.GetFromAddress().String(), + PoolId: argId, + Amount: argAmount, + } if err := msg.ValidateBasic(); err != nil { return err } diff --git a/x/pool/client/cli/tx_fund_pool.go b/x/funders/client/cli/tx_fund_pool.go similarity index 65% rename from x/pool/client/cli/tx_fund_pool.go rename to x/funders/client/cli/tx_fund_pool.go index aef09fbb..bdfce2dd 100644 --- a/x/pool/client/cli/tx_fund_pool.go +++ b/x/funders/client/cli/tx_fund_pool.go @@ -1,7 +1,7 @@ package cli import ( - "github.com/KYVENetwork/chain/x/pool/types" + "github.com/KYVENetwork/chain/x/funders/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/tx" @@ -11,9 +11,9 @@ import ( func CmdFundPool() *cobra.Command { cmd := &cobra.Command{ - Use: "fund-pool [id] [amount]", + Use: "fund-pool [id] [amount] [amount_per_bundle]", Short: "Broadcast message fund-pool", - Args: cobra.ExactArgs(2), + Args: cobra.ExactArgs(3), RunE: func(cmd *cobra.Command, args []string) (err error) { argId, err := cast.ToUint64E(args[0]) if err != nil { @@ -23,17 +23,22 @@ func CmdFundPool() *cobra.Command { if err != nil { return err } + argAmountPerBundle, err := cast.ToUint64E(args[2]) + if err != nil { + return err + } clientCtx, err := client.GetClientTxContext(cmd) if err != nil { return err } - msg := types.NewMsgFundPool( - clientCtx.GetFromAddress().String(), - argId, - argAmount, - ) + msg := &types.MsgFundPool{ + Creator: clientCtx.GetFromAddress().String(), + PoolId: argId, + Amount: argAmount, + AmountPerBundle: argAmountPerBundle, + } if err := msg.ValidateBasic(); err != nil { return err } diff --git a/x/funders/client/cli/tx_update_funder.go b/x/funders/client/cli/tx_update_funder.go new file mode 100644 index 00000000..17666c62 --- /dev/null +++ b/x/funders/client/cli/tx_update_funder.go @@ -0,0 +1,46 @@ +package cli + +import ( + "github.com/KYVENetwork/chain/x/funders/types" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" + "github.com/spf13/cobra" +) + +func CmdUpdateFunder() *cobra.Command { + cmd := &cobra.Command{ + Use: "update-funder", + Short: "Broadcast message create-funder", + RunE: func(cmd *cobra.Command, args []string) (err error) { + moniker, _ := cmd.Flags().GetString(FlagMoniker) + identity, _ := cmd.Flags().GetString(FlagIdentity) + website, _ := cmd.Flags().GetString(FlagWebsite) + contact, _ := cmd.Flags().GetString(FlagContact) + description, _ := cmd.Flags().GetString(FlagDescription) + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + msg := &types.MsgUpdateFunder{ + Creator: clientCtx.GetFromAddress().String(), + Moniker: moniker, + Identity: identity, + Website: website, + Contact: contact, + Description: description, + } + if err := msg.ValidateBasic(); err != nil { + return err + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + cmd.Flags().AddFlagSet(flagSetFunderCreate()) + flags.AddTxFlagsToCmd(cmd) + + return cmd +} diff --git a/x/funders/genesis.go b/x/funders/genesis.go new file mode 100644 index 00000000..ea4dffd8 --- /dev/null +++ b/x/funders/genesis.go @@ -0,0 +1,33 @@ +package funders + +import ( + "github.com/KYVENetwork/chain/x/funders/keeper" + "github.com/KYVENetwork/chain/x/funders/types" + sdk "github.com/cosmos/cosmos-sdk/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) + for _, entry := range genState.FunderList { + k.SetFunder(ctx, &entry) + } + for _, entry := range genState.FundingList { + k.SetFunding(ctx, &entry) + } + for _, entry := range genState.FundingStateList { + k.SetFundingState(ctx, &entry) + } +} + +// 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) + genesis.FunderList = k.GetAllFunders(ctx) + genesis.FundingList = k.GetAllFundings(ctx) + genesis.FundingStateList = k.GetAllFundingStates(ctx) + // this line is used by starport scaffolding # genesis/module/export + return genesis +} diff --git a/x/funders/keeper/getters_funder.go b/x/funders/keeper/getters_funder.go new file mode 100644 index 00000000..b049066f --- /dev/null +++ b/x/funders/keeper/getters_funder.go @@ -0,0 +1,92 @@ +package keeper + +import ( + "strings" + + "github.com/KYVENetwork/chain/x/funders/types" + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/query" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +// DoesFunderExist checks if the funding exists +func (k Keeper) DoesFunderExist(ctx sdk.Context, funderAddress string) bool { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.FunderKeyPrefix) + return store.Has(types.FunderKey(funderAddress)) +} + +// GetFunder returns the funder +func (k Keeper) GetFunder(ctx sdk.Context, funderAddress string) (funder types.Funder, found bool) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.FunderKeyPrefix) + + b := store.Get(types.FunderKey( + funderAddress, + )) + if b == nil { + return funder, false + } + + k.cdc.MustUnmarshal(b, &funder) + return funder, true +} + +// GetAllFunders returns all funders +func (k Keeper) GetAllFunders(ctx sdk.Context) (funders []types.Funder) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.FunderKeyPrefix) + iterator := sdk.KVStorePrefixIterator(store, []byte{}) + + //goland:noinspection GoUnhandledErrorResult + defer iterator.Close() + for ; iterator.Valid(); iterator.Next() { + var val types.Funder + k.cdc.MustUnmarshal(iterator.Value(), &val) + funders = append(funders, val) + } + + return funders +} + +// SetFunder sets a specific funder in the store from its index +func (k Keeper) SetFunder(ctx sdk.Context, funder *types.Funder) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.FunderKeyPrefix) + b := k.cdc.MustMarshal(funder) + store.Set(types.FunderKey( + funder.Address, + ), b) +} + +// GetPaginatedFundersQuery performs a full search on all funders with the given parameters. +func (k Keeper) GetPaginatedFundersQuery( + ctx sdk.Context, + pagination *query.PageRequest, + search string, +) ([]types.Funder, *query.PageResponse, error) { + var funders []types.Funder + + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.FunderKeyPrefix) + + pageRes, err := query.FilteredPaginate(store, pagination, func(key []byte, value []byte, accumulate bool) (bool, error) { + var funder types.Funder + if err := k.cdc.Unmarshal(value, &funder); err != nil { + return false, err + } + + // filter search + if !strings.Contains(strings.ToLower(funder.Moniker), strings.ToLower(search)) { + return false, nil + } + + if accumulate { + funders = append(funders, funder) + } + + return true, nil + }) + if err != nil { + return nil, nil, status.Error(codes.Internal, err.Error()) + } + + return funders, pageRes, nil +} diff --git a/x/funders/keeper/getters_funding.go b/x/funders/keeper/getters_funding.go new file mode 100644 index 00000000..2ed77e1d --- /dev/null +++ b/x/funders/keeper/getters_funding.go @@ -0,0 +1,153 @@ +package keeper + +import ( + "github.com/KYVENetwork/chain/x/funders/types" + queryTypes "github.com/KYVENetwork/chain/x/query/types" + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/query" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +// DoesFundingExist checks if the funding exists +func (k Keeper) DoesFundingExist(ctx sdk.Context, funderAddress string, poolId uint64) bool { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.FundingKeyPrefixByFunder) + return store.Has(types.FundingKeyByFunder(funderAddress, poolId)) +} + +// GetFunding returns the funding +func (k Keeper) GetFunding(ctx sdk.Context, funderAddress string, poolId uint64) (funding types.Funding, found bool) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.FundingKeyPrefixByFunder) + + b := store.Get(types.FundingKeyByFunder( + funderAddress, + poolId, + )) + if b == nil { + return funding, false + } + + k.cdc.MustUnmarshal(b, &funding) + return funding, true +} + +// GetFundingsOfFunder returns all fundings of a funder +func (k Keeper) GetFundingsOfFunder(ctx sdk.Context, funderAddress string) (fundings []types.Funding) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.FundingKeyPrefixByFunder) + + iterator := sdk.KVStorePrefixIterator(store, types.FundingKeyByFunderIter(funderAddress)) + //goland:noinspection GoUnhandledErrorResult + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + var funding types.Funding + k.cdc.MustUnmarshal(iterator.Value(), &funding) + fundings = append(fundings, funding) + } + return fundings +} + +// GetFundingsOfPool returns all fundings of a pool +func (k Keeper) GetFundingsOfPool(ctx sdk.Context, poolId uint64) (fundings []types.Funding) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.FundingKeyPrefixByPool) + + iterator := sdk.KVStorePrefixIterator(store, types.FundingKeyByPoolIter(poolId)) + //goland:noinspection GoUnhandledErrorResult + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + var funding types.Funding + k.cdc.MustUnmarshal(iterator.Value(), &funding) + fundings = append(fundings, funding) + } + return fundings +} + +// GetAllFundings returns all fundings +func (k Keeper) GetAllFundings(ctx sdk.Context) (fundings []types.Funding) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.FundingKeyPrefixByFunder) + iterator := sdk.KVStorePrefixIterator(store, []byte{}) + + //goland:noinspection GoUnhandledErrorResult + defer iterator.Close() + for ; iterator.Valid(); iterator.Next() { + var val types.Funding + k.cdc.MustUnmarshal(iterator.Value(), &val) + fundings = append(fundings, val) + } + + return fundings +} + +// SetFunding sets a specific funding in the store from its index +func (k Keeper) SetFunding(ctx sdk.Context, funding *types.Funding) { + b := k.cdc.MustMarshal(funding) + + storeByFunder := prefix.NewStore(ctx.KVStore(k.storeKey), types.FundingKeyPrefixByFunder) + storeByFunder.Set(types.FundingKeyByFunder( + funding.FunderAddress, + funding.PoolId, + ), b) + + storeByPool := prefix.NewStore(ctx.KVStore(k.storeKey), types.FundingKeyPrefixByPool) + storeByPool.Set(types.FundingKeyByPool( + funding.FunderAddress, + funding.PoolId, + ), b) +} + +// GetPaginatedFundingQuery performs a full search on all fundings with the given parameters. +// Requires either funderAddress or poolId to be provided. +func (k Keeper) GetPaginatedFundingQuery( + ctx sdk.Context, + pagination *query.PageRequest, + funderAddress *string, + poolId *uint64, + fundingStatus queryTypes.FundingStatus, +) ([]types.Funding, *query.PageResponse, error) { + if funderAddress == nil && poolId == nil { + return nil, nil, status.Error(codes.InvalidArgument, "either funderAddress or poolId must be provided") + } + keyPrefix := types.FundingKeyPrefixByFunder + if funderAddress == nil { + keyPrefix = types.FundingKeyPrefixByPool + } + + var fundings []types.Funding + store := prefix.NewStore(ctx.KVStore(k.storeKey), keyPrefix) + + pageRes, err := query.FilteredPaginate(store, pagination, func(key []byte, value []byte, accumulate bool) (bool, error) { + var funding types.Funding + if err := k.cdc.Unmarshal(value, &funding); err != nil { + return false, err + } + + if funderAddress != nil && *funderAddress != funding.FunderAddress { + return false, nil + } + + if poolId != nil && *poolId != funding.PoolId { + return false, nil + } + + if fundingStatus == queryTypes.FUNDING_STATUS_ACTIVE && funding.IsInactive() { + return false, nil + } + + if fundingStatus == queryTypes.FUNDING_STATUS_INACTIVE && funding.IsActive() { + return false, nil + } + + if accumulate { + fundings = append(fundings, funding) + } + + return true, nil + }) + if err != nil { + return nil, nil, status.Error(codes.Internal, err.Error()) + } + + return fundings, pageRes, nil +} diff --git a/x/funders/keeper/getters_funding_state.go b/x/funders/keeper/getters_funding_state.go new file mode 100644 index 00000000..04770741 --- /dev/null +++ b/x/funders/keeper/getters_funding_state.go @@ -0,0 +1,63 @@ +package keeper + +import ( + "github.com/KYVENetwork/chain/x/funders/types" + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// DoesFundingStateExist checks if the FundingState exists +func (k Keeper) DoesFundingStateExist(ctx sdk.Context, poolId uint64) bool { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.FundingStateKeyPrefix) + return store.Has(types.FundingStateKey(poolId)) +} + +// GetFundingState returns the FundingState +func (k Keeper) GetFundingState(ctx sdk.Context, poolId uint64) (fundingState types.FundingState, found bool) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.FundingStateKeyPrefix) + + b := store.Get(types.FundingStateKey( + poolId, + )) + if b == nil { + return fundingState, false + } + + k.cdc.MustUnmarshal(b, &fundingState) + return fundingState, true +} + +// GetAllFundingStates returns all FundingStates +func (k Keeper) GetAllFundingStates(ctx sdk.Context) (fundingStates []types.FundingState) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.FundingStateKeyPrefix) + iterator := sdk.KVStorePrefixIterator(store, []byte{}) + + //goland:noinspection GoUnhandledErrorResult + defer iterator.Close() + for ; iterator.Valid(); iterator.Next() { + var val types.FundingState + k.cdc.MustUnmarshal(iterator.Value(), &val) + fundingStates = append(fundingStates, val) + } + + return fundingStates +} + +// SetFundingState sets a specific FundingState in the store from its index +func (k Keeper) SetFundingState(ctx sdk.Context, fundingState *types.FundingState) { + b := k.cdc.MustMarshal(fundingState) + storeByFunder := prefix.NewStore(ctx.KVStore(k.storeKey), types.FundingStateKeyPrefix) + storeByFunder.Set(types.FundingStateKey( + fundingState.PoolId, + ), b) +} + +func (k Keeper) GetActiveFundings(ctx sdk.Context, fundingState types.FundingState) (fundings []types.Funding) { + for _, funder := range fundingState.ActiveFunderAddresses { + funding, found := k.GetFunding(ctx, funder, fundingState.PoolId) + if found { + fundings = append(fundings, funding) + } // else should never happen or we have a corrupted state + } + return fundings +} diff --git a/x/funders/keeper/getters_params.go b/x/funders/keeper/getters_params.go new file mode 100644 index 00000000..5d95604c --- /dev/null +++ b/x/funders/keeper/getters_params.go @@ -0,0 +1,26 @@ +package keeper + +import ( + "github.com/KYVENetwork/chain/x/funders/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// GetParams get all parameters as types.Params +func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) { + store := ctx.KVStore(k.storeKey) + + bz := store.Get(types.ParamsKey) + if bz == nil { + return params + } + + k.cdc.MustUnmarshal(bz, ¶ms) + return params +} + +// SetParams set the params +func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { + store := ctx.KVStore(k.storeKey) + bz := k.cdc.MustMarshal(¶ms) + store.Set(types.ParamsKey, bz) +} diff --git a/x/funders/keeper/keeper.go b/x/funders/keeper/keeper.go new file mode 100644 index 00000000..e188b999 --- /dev/null +++ b/x/funders/keeper/keeper.go @@ -0,0 +1,61 @@ +package keeper + +import ( + "fmt" + + "github.com/KYVENetwork/chain/util" + "github.com/KYVENetwork/chain/x/funders/types" + "github.com/cometbft/cometbft/libs/log" + "github.com/cosmos/cosmos-sdk/codec" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +type ( + Keeper struct { + cdc codec.BinaryCodec + storeKey storetypes.StoreKey + memKey storetypes.StoreKey + + authority string + + accountKeeper types.AccountKeeper + bankKeeper util.BankKeeper + poolKeeper types.PoolKeeper + upgradeKeeper util.UpgradeKeeper + } +) + +func NewKeeper( + cdc codec.BinaryCodec, + storeKey, + memKey storetypes.StoreKey, + + authority string, + + accountKeeper types.AccountKeeper, + bankKeeper util.BankKeeper, + poolKeeper types.PoolKeeper, + upgradeKeeper util.UpgradeKeeper, +) *Keeper { + return &Keeper{ + cdc: cdc, + storeKey: storeKey, + memKey: memKey, + + authority: authority, + + accountKeeper: accountKeeper, + bankKeeper: bankKeeper, + poolKeeper: poolKeeper, + upgradeKeeper: upgradeKeeper, + } +} + +func (k Keeper) Logger(ctx sdk.Context) log.Logger { + return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) +} + +func (k Keeper) StoreKey() storetypes.StoreKey { + return k.storeKey +} diff --git a/x/funders/keeper/keeper_test.go b/x/funders/keeper/keeper_test.go new file mode 100644 index 00000000..6dee1b57 --- /dev/null +++ b/x/funders/keeper/keeper_test.go @@ -0,0 +1,16 @@ +package keeper_test + +import ( + "fmt" + "testing" + + "github.com/KYVENetwork/chain/x/team/types" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" +) + +func TestTeamKeeper(t *testing.T) { + RegisterFailHandler(Fail) + RunSpecs(t, fmt.Sprintf("x/%s Keeper Test Suite", types.ModuleName)) +} diff --git a/x/funders/keeper/logic_funders.go b/x/funders/keeper/logic_funders.go new file mode 100644 index 00000000..25d3ea44 --- /dev/null +++ b/x/funders/keeper/logic_funders.go @@ -0,0 +1,163 @@ +package keeper + +import ( + "fmt" + + "cosmossdk.io/errors" + + "github.com/KYVENetwork/chain/util" + "github.com/KYVENetwork/chain/x/funders/types" + pooltypes "github.com/KYVENetwork/chain/x/pool/types" + sdk "github.com/cosmos/cosmos-sdk/types" + errorsTypes "github.com/cosmos/cosmos-sdk/types/errors" +) + +func (k Keeper) CreateFundingState(ctx sdk.Context, poolId uint64) { + fundingState := types.FundingState{ + PoolId: poolId, + ActiveFunderAddresses: []string{}, + } + k.SetFundingState(ctx, &fundingState) +} + +func (k Keeper) GetTotalActiveFunding(ctx sdk.Context, poolId uint64) (amount uint64) { + state, found := k.GetFundingState(ctx, poolId) + if !found { + return 0 + } + for _, address := range state.ActiveFunderAddresses { + funding, _ := k.GetFunding(ctx, address, poolId) + amount += funding.Amount + } + return amount +} + +// ChargeFundersOfPool charges all funders of a pool with their amount_per_bundle +// If the amount is lower than the amount_per_bundle, +// the max amount is charged and the funder is removed from the active funders list. +// The amount is transferred from the funders to the pool module account where it can be paid out. +// If there are no more active funders, an event is emitted. +func (k Keeper) ChargeFundersOfPool(ctx sdk.Context, poolId uint64) (payout uint64, err error) { + // Get funding state for pool + fundingState, found := k.GetFundingState(ctx, poolId) + if !found { + return 0, errors.Wrapf(errorsTypes.ErrNotFound, types.ErrFundingStateDoesNotExist.Error(), poolId) + } + + // If there are no active fundings we immediately return + activeFundings := k.GetActiveFundings(ctx, fundingState) + if len(activeFundings) == 0 { + return 0, nil + } + + // This is the amount every funding will be charged + for _, funding := range activeFundings { + payout += funding.ChargeOneBundle() + if funding.Amount == 0 { + fundingState.SetInactive(&funding) + } + k.SetFunding(ctx, &funding) + } + + // Save funding state + k.SetFundingState(ctx, &fundingState) + + // Emit a pool out of funds event if there are no more active funders + if len(fundingState.ActiveFunderAddresses) == 0 { + _ = ctx.EventManager().EmitTypedEvent(&types.EventPoolOutOfFunds{ + PoolId: poolId, + }) + } + + // Move funds to pool module account + if payout > 0 { + err = util.TransferFromModuleToModule(k.bankKeeper, ctx, types.ModuleName, pooltypes.ModuleName, payout) + if err != nil { + return 0, err + } + } + + return payout, nil +} + +// GetLowestFunding returns the funding with the lowest amount +// Precondition: len(fundings) > 0 +func (k Keeper) GetLowestFunding(fundings []types.Funding) (lowestFunding *types.Funding, err error) { + if len(fundings) == 0 { + return nil, fmt.Errorf("no active fundings") + } + + lowestFundingIndex := 0 + for i := range fundings { + if fundings[i].Amount < fundings[lowestFundingIndex].Amount { + lowestFundingIndex = i + } + } + return &fundings[lowestFundingIndex], nil +} + +// ensureParamsCompatibility checks compatibility of the provided funding with the pool params. +// i.e. +// - minimum funding per bundle +// - minimum funding amount +// - minimum funding multiple +func (k Keeper) ensureParamsCompatibility(ctx sdk.Context, funding types.Funding) error { + params := k.GetParams(ctx) + if funding.AmountPerBundle < params.MinFundingAmountPerBundle { + return errors.Wrapf(errorsTypes.ErrInvalidRequest, types.ErrAmountPerBundleTooLow.Error(), params.MinFundingAmountPerBundle) + } + if funding.Amount < params.MinFundingAmount { + return errors.Wrapf(errorsTypes.ErrInvalidRequest, types.ErrMinFundingAmount.Error(), params.MinFundingAmount) + } + if funding.AmountPerBundle*params.MinFundingMultiple > funding.Amount { + return errors.Wrapf(errorsTypes.ErrInvalidRequest, types.ErrMinFundingMultiple.Error(), funding.AmountPerBundle, params.MinFundingAmount, funding.Amount) + } + return nil +} + +// ensureFreeSlot makes sure that a funder can add funding to a given pool. +// If this is not possible an appropriate error is returned. +// A pool has a fixed amount of funding-slots. If there are still free slots +// a funder can just join (even with the smallest funding possible). +// If all slots are taken, it checks if the new funding has more funds +// than the current lowest funding in that pool. +// If so, the lowest funding gets removed from the pool, so that the +// new funding can be added. +// CONTRACT: no KV Writing on newFunding and fundingState +func (k Keeper) ensureFreeSlot(ctx sdk.Context, newFunding *types.Funding, fundingState *types.FundingState) error { + activeFundings := k.GetActiveFundings(ctx, *fundingState) + // check if slots are still available + if len(activeFundings) < types.MaxFunders { + return nil + } + + lowestFunding, _ := k.GetLowestFunding(activeFundings) + + if lowestFunding.FunderAddress == newFunding.FunderAddress { + // Funder already has a funding slot + return nil + } + + // Check if lowest funding is lower than new funding based on amount (amount per bundle is ignored) + if newFunding.Amount < lowestFunding.Amount { + return errors.Wrapf(errorsTypes.ErrLogic, types.ErrFundsTooLow.Error(), lowestFunding.Amount) + } + + // Defund lowest funder + if err := util.TransferFromModuleToAddress(k.bankKeeper, ctx, types.ModuleName, lowestFunding.FunderAddress, lowestFunding.Amount); err != nil { + return err + } + + subtracted := lowestFunding.SubtractAmount(lowestFunding.Amount) + fundingState.SetInactive(lowestFunding) + k.SetFunding(ctx, lowestFunding) + + // Emit a defund event. + _ = ctx.EventManager().EmitTypedEvent(&types.EventDefundPool{ + PoolId: fundingState.PoolId, + Address: lowestFunding.FunderAddress, + Amount: subtracted, + }) + + return nil +} diff --git a/x/funders/keeper/logic_funders_test.go b/x/funders/keeper/logic_funders_test.go new file mode 100644 index 00000000..adbd7d48 --- /dev/null +++ b/x/funders/keeper/logic_funders_test.go @@ -0,0 +1,306 @@ +package keeper_test + +import ( + i "github.com/KYVENetwork/chain/testutil/integration" + funderstypes "github.com/KYVENetwork/chain/x/funders/types" + globaltypes "github.com/KYVENetwork/chain/x/global/types" + pooltypes "github.com/KYVENetwork/chain/x/pool/types" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" +) + +/* + +TEST CASES - logic_funders.go + +* Charge funders once +* Charge funders until one funder runs out of funds +* Charge funders until all funders run out of funds +* Charge funder with less funds than amount_per_bundle +* Charge without fundings +* Check if the lowest funding is returned correctly + +*/ + +var _ = Describe("logic_funders.go", Ordered, func() { + s := i.NewCleanChain() + fundersModuleAcc := s.App().AccountKeeper.GetModuleAccount(s.Ctx(), funderstypes.ModuleName).GetAddress() + poolModuleAcc := s.App().AccountKeeper.GetModuleAccount(s.Ctx(), pooltypes.ModuleName).GetAddress() + + BeforeEach(func() { + s = i.NewCleanChain() + + // create clean pool for every test case + gov := s.App().GovKeeper.GetGovernanceAccount(s.Ctx()).GetAddress().String() + msg := &pooltypes.MsgCreatePool{ + Authority: gov, + Name: "PoolTest", + Runtime: "@kyve/test", + Logo: "ar://Tewyv2P5VEG8EJ6AUQORdqNTectY9hlOrWPK8wwo-aU", + Config: "ar://DgdB-2hLrxjhyEEbCML__dgZN5_uS7T6Z5XDkaFh3P0", + StartKey: "0", + UploadInterval: 60, + InflationShareWeight: 10_000, + MinDelegation: 100 * i.KYVE, + MaxBundleSize: 100, + Version: "0.0.0", + Binaries: "{}", + StorageProviderId: 2, + CompressionId: 1, + } + s.RunTxPoolSuccess(msg) + + params := s.App().FundersKeeper.GetParams(s.Ctx()) + params.MinFundingMultiple = 5 + s.App().FundersKeeper.SetParams(s.Ctx(), params) + + // create funder + s.RunTxFundersSuccess(&funderstypes.MsgCreateFunder{ + Creator: i.ALICE, + Moniker: "Alice", + }) + s.RunTxFundersSuccess(&funderstypes.MsgCreateFunder{ + Creator: i.BOB, + Moniker: "Bob", + }) + + // fund pool + s.RunTxPoolSuccess(&funderstypes.MsgFundPool{ + Creator: i.ALICE, + PoolId: 0, + Amount: 100 * i.KYVE, + AmountPerBundle: 1 * i.KYVE, + }) + s.RunTxPoolSuccess(&funderstypes.MsgFundPool{ + Creator: i.BOB, + PoolId: 0, + Amount: 50 * i.KYVE, + AmountPerBundle: 10 * i.KYVE, + }) + + fundersBalance := s.App().BankKeeper.GetBalance(s.Ctx(), fundersModuleAcc, globaltypes.Denom).Amount.Uint64() + Expect(fundersBalance).To(Equal(150 * i.KYVE)) + }) + + AfterEach(func() { + s.PerformValidityChecks() + }) + + It("Charge funders once", func() { + // ACT + payout, err := s.App().FundersKeeper.ChargeFundersOfPool(s.Ctx(), 0) + Expect(err).NotTo(HaveOccurred()) + + // ASSERT + Expect(payout).To(Equal(11 * i.KYVE)) + + fundingAlice, foundAlice := s.App().FundersKeeper.GetFunding(s.Ctx(), i.ALICE, 0) + Expect(foundAlice).To(BeTrue()) + Expect(fundingAlice.Amount).To(Equal(99 * i.KYVE)) + Expect(fundingAlice.TotalFunded).To(Equal(1 * i.KYVE)) + + fundingBob, foundBob := s.App().FundersKeeper.GetFunding(s.Ctx(), i.BOB, 0) + Expect(foundBob).To(BeTrue()) + Expect(fundingBob.Amount).To(Equal(40 * i.KYVE)) + Expect(fundingBob.TotalFunded).To(Equal(10 * i.KYVE)) + + fundingState, _ := s.App().FundersKeeper.GetFundingState(s.Ctx(), 0) + Expect(fundingState.ActiveFunderAddresses).To(HaveLen(2)) + Expect(fundingState.ActiveFunderAddresses[0]).To(Equal(i.ALICE)) + Expect(fundingState.ActiveFunderAddresses[1]).To(Equal(i.BOB)) + + fundersBalance := s.App().BankKeeper.GetBalance(s.Ctx(), fundersModuleAcc, globaltypes.Denom).Amount.Uint64() + poolBalance := s.App().BankKeeper.GetBalance(s.Ctx(), poolModuleAcc, globaltypes.Denom).Amount.Uint64() + Expect(fundersBalance).To(Equal(139 * i.KYVE)) + Expect(poolBalance).To(Equal(11 * i.KYVE)) + }) + + It("Charge funders until one funder runs out of funds", func() { + // ACT + for range [5]struct{}{} { + payout, err := s.App().FundersKeeper.ChargeFundersOfPool(s.Ctx(), 0) + Expect(err).NotTo(HaveOccurred()) + Expect(payout).To(Equal(11 * i.KYVE)) + } + + // ASSERT + fundingState, _ := s.App().FundersKeeper.GetFundingState(s.Ctx(), 0) + Expect(fundingState.ActiveFunderAddresses).To(HaveLen(1)) + Expect(fundingState.ActiveFunderAddresses[0]).To(Equal(i.ALICE)) + + fundingAlice, foundAlice := s.App().FundersKeeper.GetFunding(s.Ctx(), i.ALICE, 0) + Expect(foundAlice).To(BeTrue()) + Expect(fundingAlice.Amount).To(Equal(95 * i.KYVE)) + Expect(fundingAlice.TotalFunded).To(Equal(5 * i.KYVE)) + + fundingBob, foundBob := s.App().FundersKeeper.GetFunding(s.Ctx(), i.BOB, 0) + Expect(foundBob).To(BeTrue()) + Expect(fundingBob.Amount).To(Equal(0 * i.KYVE)) + Expect(fundingBob.TotalFunded).To(Equal(50 * i.KYVE)) + + fundersBalance := s.App().BankKeeper.GetBalance(s.Ctx(), fundersModuleAcc, globaltypes.Denom).Amount.Uint64() + poolBalance := s.App().BankKeeper.GetBalance(s.Ctx(), poolModuleAcc, globaltypes.Denom).Amount.Uint64() + Expect(fundersBalance).To(Equal(95 * i.KYVE)) + Expect(poolBalance).To(Equal(55 * i.KYVE)) + }) + + It("Charge funders until all funders run out of funds", func() { + // ARRANGE + funding, _ := s.App().FundersKeeper.GetFunding(s.Ctx(), i.ALICE, 0) + funding.AmountPerBundle = 10 * i.KYVE + s.App().FundersKeeper.SetFunding(s.Ctx(), &funding) + + // ACT / ASSERT + for range [5]struct{}{} { + fundingState, _ := s.App().FundersKeeper.GetFundingState(s.Ctx(), 0) + Expect(fundingState.ActiveFunderAddresses).To(HaveLen(2)) + + payout, err := s.App().FundersKeeper.ChargeFundersOfPool(s.Ctx(), 0) + Expect(err).NotTo(HaveOccurred()) + Expect(payout).To(Equal(20 * i.KYVE)) + } + fundingState, _ := s.App().FundersKeeper.GetFundingState(s.Ctx(), 0) + Expect(fundingState.ActiveFunderAddresses).To(HaveLen(1)) + Expect(fundingState.ActiveFunderAddresses[0]).To(Equal(i.ALICE)) + + fundingAlice, foundAlice := s.App().FundersKeeper.GetFunding(s.Ctx(), i.ALICE, 0) + Expect(foundAlice).To(BeTrue()) + Expect(fundingAlice.Amount).To(Equal(50 * i.KYVE)) + Expect(fundingAlice.TotalFunded).To(Equal(50 * i.KYVE)) + + fundingBob, foundBob := s.App().FundersKeeper.GetFunding(s.Ctx(), i.BOB, 0) + Expect(foundBob).To(BeTrue()) + Expect(fundingBob.Amount).To(Equal(0 * i.KYVE)) + Expect(fundingBob.TotalFunded).To(Equal(50 * i.KYVE)) + + for range [5]struct{}{} { + fundingState, _ := s.App().FundersKeeper.GetFundingState(s.Ctx(), 0) + Expect(fundingState.ActiveFunderAddresses).To(HaveLen(1)) + + payout, err := s.App().FundersKeeper.ChargeFundersOfPool(s.Ctx(), 0) + Expect(err).NotTo(HaveOccurred()) + Expect(payout).To(Equal(10 * i.KYVE)) + } + fundingState, _ = s.App().FundersKeeper.GetFundingState(s.Ctx(), 0) + Expect(fundingState.ActiveFunderAddresses).To(HaveLen(0)) + + fundingAlice, foundAlice = s.App().FundersKeeper.GetFunding(s.Ctx(), i.ALICE, 0) + Expect(foundAlice).To(BeTrue()) + Expect(fundingAlice.Amount).To(Equal(0 * i.KYVE)) + Expect(fundingAlice.TotalFunded).To(Equal(100 * i.KYVE)) + + fundingBob, foundBob = s.App().FundersKeeper.GetFunding(s.Ctx(), i.BOB, 0) + Expect(foundBob).To(BeTrue()) + Expect(fundingBob.Amount).To(Equal(0 * i.KYVE)) + Expect(fundingBob.TotalFunded).To(Equal(50 * i.KYVE)) + + payout, err := s.App().FundersKeeper.ChargeFundersOfPool(s.Ctx(), 0) + Expect(err).NotTo(HaveOccurred()) + Expect(payout).To(Equal(0 * i.KYVE)) + + fundingState, _ = s.App().FundersKeeper.GetFundingState(s.Ctx(), 0) + Expect(fundingState.ActiveFunderAddresses).To(HaveLen(0)) + + fundersBalance := s.App().BankKeeper.GetBalance(s.Ctx(), fundersModuleAcc, globaltypes.Denom).Amount.Uint64() + poolBalance := s.App().BankKeeper.GetBalance(s.Ctx(), poolModuleAcc, globaltypes.Denom).Amount.Uint64() + Expect(fundersBalance).To(Equal(0 * i.KYVE)) + Expect(poolBalance).To(Equal(150 * i.KYVE)) + }) + + It("Charge funder with less funds than amount_per_bundle", func() { + // ARRANGE + funding, _ := s.App().FundersKeeper.GetFunding(s.Ctx(), i.ALICE, 0) + funding.AmountPerBundle = 105 * i.KYVE + s.App().FundersKeeper.SetFunding(s.Ctx(), &funding) + + // ACT + payout, err := s.App().FundersKeeper.ChargeFundersOfPool(s.Ctx(), 0) + Expect(err).NotTo(HaveOccurred()) + Expect(payout).To(Equal(110 * i.KYVE)) + + // ASSERT + fundingState, _ := s.App().FundersKeeper.GetFundingState(s.Ctx(), 0) + Expect(fundingState.ActiveFunderAddresses).To(HaveLen(1)) + Expect(fundingState.ActiveFunderAddresses[0]).To(Equal(i.BOB)) + + fundingAlice, foundAlice := s.App().FundersKeeper.GetFunding(s.Ctx(), i.ALICE, 0) + Expect(foundAlice).To(BeTrue()) + Expect(fundingAlice.Amount).To(Equal(0 * i.KYVE)) + Expect(fundingAlice.TotalFunded).To(Equal(100 * i.KYVE)) + + fundingBob, foundBob := s.App().FundersKeeper.GetFunding(s.Ctx(), i.BOB, 0) + Expect(foundBob).To(BeTrue()) + Expect(fundingBob.Amount).To(Equal(40 * i.KYVE)) + Expect(fundingBob.TotalFunded).To(Equal(10 * i.KYVE)) + + fundersBalance := s.App().BankKeeper.GetBalance(s.Ctx(), fundersModuleAcc, globaltypes.Denom).Amount.Uint64() + poolBalance := s.App().BankKeeper.GetBalance(s.Ctx(), poolModuleAcc, globaltypes.Denom).Amount.Uint64() + Expect(fundersBalance).To(Equal(40 * i.KYVE)) + Expect(poolBalance).To(Equal(110 * i.KYVE)) + }) + + It("Charge without fundings", func() { + // ARRANGE + s.RunTxFundersSuccess(&funderstypes.MsgDefundPool{ + Creator: i.ALICE, + PoolId: 0, + Amount: 100 * i.KYVE, + }) + s.RunTxFundersSuccess(&funderstypes.MsgDefundPool{ + Creator: i.BOB, + PoolId: 0, + Amount: 50 * i.KYVE, + }) + + // ACT + payout, err := s.App().FundersKeeper.ChargeFundersOfPool(s.Ctx(), 0) + + // ASSERT + fundingState, _ := s.App().FundersKeeper.GetFundingState(s.Ctx(), 0) + Expect(fundingState.ActiveFunderAddresses).To(HaveLen(0)) + + fundingAlice, foundAlice := s.App().FundersKeeper.GetFunding(s.Ctx(), i.ALICE, 0) + Expect(foundAlice).To(BeTrue()) + Expect(fundingAlice.Amount).To(Equal(0 * i.KYVE)) + Expect(fundingAlice.TotalFunded).To(Equal(0 * i.KYVE)) + + fundingBob, foundBob := s.App().FundersKeeper.GetFunding(s.Ctx(), i.BOB, 0) + Expect(foundBob).To(BeTrue()) + Expect(fundingBob.Amount).To(Equal(0 * i.KYVE)) + Expect(fundingBob.TotalFunded).To(Equal(0 * i.KYVE)) + + Expect(err).NotTo(HaveOccurred()) + Expect(payout).To(Equal(0 * i.KYVE)) + fundersBalance := s.App().BankKeeper.GetBalance(s.Ctx(), fundersModuleAcc, globaltypes.Denom).Amount.Uint64() + poolBalance := s.App().BankKeeper.GetBalance(s.Ctx(), poolModuleAcc, globaltypes.Denom).Amount.Uint64() + Expect(fundersBalance).To(Equal(0 * i.KYVE)) + Expect(poolBalance).To(Equal(0 * i.KYVE)) + }) + + It("Check if the lowest funding is returned correctly", func() { + fundings := []funderstypes.Funding{ + { + FunderAddress: i.DUMMY[0], + PoolId: 0, + Amount: 1000 * i.KYVE, + AmountPerBundle: 1 * i.KYVE, + }, + { + FunderAddress: i.DUMMY[1], + PoolId: 0, + Amount: 900 * i.KYVE, + AmountPerBundle: 1 * i.KYVE, + }, + { + FunderAddress: i.DUMMY[2], + PoolId: 0, + Amount: 1100 * i.KYVE, + AmountPerBundle: 1 * i.KYVE, + }, + } + + getLowestFunding, err := s.App().FundersKeeper.GetLowestFunding(fundings) + Expect(err).NotTo(HaveOccurred()) + Expect(getLowestFunding.Amount).To(Equal(900 * i.KYVE)) + }) +}) diff --git a/x/funders/keeper/msg_server.go b/x/funders/keeper/msg_server.go new file mode 100644 index 00000000..66990305 --- /dev/null +++ b/x/funders/keeper/msg_server.go @@ -0,0 +1,17 @@ +package keeper + +import ( + "github.com/KYVENetwork/chain/x/funders/types" +) + +type msgServer struct { + Keeper +} + +// NewMsgServerImpl returns an implementation of the MsgServer interface +// for the provided Keeper. +func NewMsgServerImpl(keeper Keeper) types.MsgServer { + return &msgServer{Keeper: keeper} +} + +var _ types.MsgServer = msgServer{} diff --git a/x/funders/keeper/msg_server_create_funder.go b/x/funders/keeper/msg_server_create_funder.go new file mode 100644 index 00000000..b29417ce --- /dev/null +++ b/x/funders/keeper/msg_server_create_funder.go @@ -0,0 +1,43 @@ +package keeper + +import ( + "context" + + "cosmossdk.io/errors" + "github.com/KYVENetwork/chain/x/funders/types" + sdk "github.com/cosmos/cosmos-sdk/types" + errorsTypes "github.com/cosmos/cosmos-sdk/types/errors" +) + +// CreateFunder creates a new funder object and stores it in the store. +// If the funder already exists, an error is returned. +func (k msgServer) CreateFunder(goCtx context.Context, msg *types.MsgCreateFunder) (*types.MsgCreateFunderResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + // Check if funder already exists + if k.DoesFunderExist(ctx, msg.Creator) { + return nil, errors.Wrapf(errorsTypes.ErrInvalidRequest, types.ErrFunderAlreadyExists.Error(), msg.Creator) + } + + // Create new funder + k.SetFunder(ctx, &types.Funder{ + Address: msg.Creator, + Moniker: msg.Moniker, + Identity: msg.Identity, + Website: msg.Website, + Contact: msg.Contact, + Description: msg.Description, + }) + + // Emit a create funder event + _ = ctx.EventManager().EmitTypedEvent(&types.EventCreateFunder{ + Address: msg.Creator, + Moniker: msg.Moniker, + Identity: msg.Identity, + Website: msg.Website, + Contact: msg.Contact, + Description: msg.Description, + }) + + return &types.MsgCreateFunderResponse{}, nil +} diff --git a/x/funders/keeper/msg_server_create_funder_test.go b/x/funders/keeper/msg_server_create_funder_test.go new file mode 100644 index 00000000..597725de --- /dev/null +++ b/x/funders/keeper/msg_server_create_funder_test.go @@ -0,0 +1,110 @@ +package keeper_test + +import ( + "github.com/KYVENetwork/chain/x/funders/types" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + + i "github.com/KYVENetwork/chain/testutil/integration" +) + +/* + +TEST CASES - msg_server_create_funder.go + +* Try to create a funder with empty values +* Create a funder with empty values except moniker +* Create a funder with all values set +* Try to create a funder that already exists +* Create two funders +*/ + +var _ = Describe("msg_server_create_funder.go", Ordered, func() { + s := i.NewCleanChain() + + BeforeEach(func() { + // init new clean chain + s = i.NewCleanChain() + }) + + AfterEach(func() { + s.PerformValidityChecks() + }) + + It("Try to create a funder with empty values", func() { + // ASSERT + s.RunTxFundersError(&types.MsgCreateFunder{ + Creator: i.ALICE, + }) + }) + + It("Create a funder with empty values except moniker", func() { + // ACT + s.RunTxFundersSuccess(&types.MsgCreateFunder{ + Creator: i.ALICE, + Moniker: "moniker", + }) + + // ASSERT + funder, found := s.App().FundersKeeper.GetFunder(s.Ctx(), i.ALICE) + Expect(found).To(BeTrue()) + Expect(funder.Address).To(Equal(i.ALICE)) + Expect(funder.Moniker).To(Equal("moniker")) + Expect(funder.Identity).To(BeEmpty()) + Expect(funder.Website).To(BeEmpty()) + Expect(funder.Contact).To(BeEmpty()) + Expect(funder.Description).To(BeEmpty()) + }) + + It("Create a funder with all values set", func() { + // ACT + moniker, identity, website, contact, description := "moniker", "identity", "website", "contact", "description" + s.RunTxFundersSuccess(&types.MsgCreateFunder{ + Creator: i.ALICE, + Moniker: moniker, + Identity: identity, + Website: website, + Contact: contact, + Description: description, + }) + + // ASSERT + funder, found := s.App().FundersKeeper.GetFunder(s.Ctx(), i.ALICE) + Expect(found).To(BeTrue()) + Expect(funder.Address).To(Equal(i.ALICE)) + Expect(funder.Moniker).To(Equal(moniker)) + Expect(funder.Identity).To(Equal(identity)) + Expect(funder.Website).To(Equal(website)) + Expect(funder.Contact).To(Equal(contact)) + Expect(funder.Description).To(Equal(description)) + }) + + It("Try to create a funder that already exists", func() { + // ARRANGE + s.RunTxFundersSuccess(&types.MsgCreateFunder{ + Creator: i.ALICE, + Moniker: "moniker 1", + }) + + // ACT + _, err := s.RunTx(&types.MsgCreateFunder{ + Creator: i.ALICE, + Moniker: "moniker 2", + }) + Expect(err.Error()).To(Equal("funder with address kyve1jq304cthpx0lwhpqzrdjrcza559ukyy3zsl2vd already exists: invalid request")) + }) + + It("Create two funders", func() { + // ARRANGE + s.RunTxFundersSuccess(&types.MsgCreateFunder{ + Creator: i.ALICE, + Moniker: "moniker 1", + }) + + // ACT + s.RunTxFundersSuccess(&types.MsgCreateFunder{ + Creator: i.BOB, + Moniker: "moniker 2", + }) + }) +}) diff --git a/x/funders/keeper/msg_server_defund_pool.go b/x/funders/keeper/msg_server_defund_pool.go new file mode 100644 index 00000000..1ad2c10c --- /dev/null +++ b/x/funders/keeper/msg_server_defund_pool.go @@ -0,0 +1,65 @@ +package keeper + +import ( + "context" + "fmt" + + "github.com/KYVENetwork/chain/x/funders/types" + + "cosmossdk.io/errors" + "github.com/KYVENetwork/chain/util" + sdk "github.com/cosmos/cosmos-sdk/types" + errorsTypes "github.com/cosmos/cosmos-sdk/types/errors" +) + +// DefundPool handles the logic to defund a pool. +// If the user is a funder, it will subtract the provided amount +// and send the tokens back. If there are no more funds left, the funding will get inactive. +func (k msgServer) DefundPool(goCtx context.Context, msg *types.MsgDefundPool) (*types.MsgDefundPoolResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + // Funding has to exist + funding, found := k.GetFunding(ctx, msg.Creator, msg.PoolId) + if !found { + return nil, errors.Wrapf(errorsTypes.ErrNotFound, types.ErrFundingDoesNotExist.Error(), msg.PoolId, msg.Creator) + } + + if funding.Amount == 0 { + return nil, errors.Wrapf(errorsTypes.ErrInvalidRequest, types.ErrFundingIsUsedUp.Error(), msg.PoolId, msg.Creator) + } + + // FundingState has to exist + fundingState, found := k.GetFundingState(ctx, msg.PoolId) + if !found { + util.PanicHalt(k.upgradeKeeper, ctx, fmt.Sprintf("FundingState for pool %d does not exist", msg.PoolId)) + } + + // Subtract amount from funding + amount := funding.SubtractAmount(msg.Amount) + if funding.Amount == 0 { + fundingState.SetInactive(&funding) + } else { + // If funding is not fully revoked, check if updated funding is still compatible with params. + if err := k.ensureParamsCompatibility(ctx, funding); err != nil { + return nil, err + } + } + + // Transfer tokens from this module to sender. + if err := util.TransferFromModuleToAddress(k.bankKeeper, ctx, types.ModuleName, msg.Creator, amount); err != nil { + return nil, err + } + + // Save funding and funding state + k.SetFunding(ctx, &funding) + k.SetFundingState(ctx, &fundingState) + + // Emit a defund event. + _ = ctx.EventManager().EmitTypedEvent(&types.EventDefundPool{ + PoolId: msg.PoolId, + Address: msg.Creator, + Amount: amount, + }) + + return &types.MsgDefundPoolResponse{}, nil +} diff --git a/x/funders/keeper/msg_server_defund_pool_test.go b/x/funders/keeper/msg_server_defund_pool_test.go new file mode 100644 index 00000000..4d738442 --- /dev/null +++ b/x/funders/keeper/msg_server_defund_pool_test.go @@ -0,0 +1,214 @@ +package keeper_test + +import ( + i "github.com/KYVENetwork/chain/testutil/integration" + "github.com/KYVENetwork/chain/x/funders/types" + pooltypes "github.com/KYVENetwork/chain/x/pool/types" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" +) + +/* + +TEST CASES - msg_server_defund_pool.go + +* Defund 50 KYVE from a funder who has previously funded 100 KYVE +* Defund more than actually funded +* Defund full funding amount from a funder who has previously funded 100 KYVE +* Defund as highest funder 75 KYVE in order to be the lowest funder afterward +* Try to defund nonexistent fundings +* Try to defund a funding twice +* Try to defund below minimum funding params (but not full defund) + +*/ + +var _ = Describe("msg_server_defund_pool.go", Ordered, func() { + s := i.NewCleanChain() + + initialBalance := s.GetBalanceFromAddress(i.ALICE) + + BeforeEach(func() { + // init new clean chain + s = i.NewCleanChain() + + // create clean pool for every test case + gov := s.App().GovKeeper.GetGovernanceAccount(s.Ctx()).GetAddress().String() + msg := &pooltypes.MsgCreatePool{ + Authority: gov, + Name: "PoolTest", + Runtime: "@kyve/test", + Logo: "ar://Tewyv2P5VEG8EJ6AUQORdqNTectY9hlOrWPK8wwo-aU", + Config: "ar://DgdB-2hLrxjhyEEbCML__dgZN5_uS7T6Z5XDkaFh3P0", + StartKey: "0", + UploadInterval: 60, + InflationShareWeight: 10_000, + MinDelegation: 100 * i.KYVE, + MaxBundleSize: 100, + Version: "0.0.0", + Binaries: "{}", + StorageProviderId: 2, + CompressionId: 1, + } + s.RunTxPoolSuccess(msg) + + // create funder + s.RunTxFundersSuccess(&types.MsgCreateFunder{ + Creator: i.ALICE, + Moniker: "moniker", + }) + + // fund pool + s.RunTxFundersSuccess(&types.MsgFundPool{ + Creator: i.ALICE, + PoolId: 0, + Amount: 100 * i.KYVE, + AmountPerBundle: 1 * i.KYVE, + }) + }) + + AfterEach(func() { + s.PerformValidityChecks() + }) + + It("Defund 50 KYVE from a funder who has previously funded 100 KYVE", func() { + // ACT + s.RunTxFundersSuccess(&types.MsgDefundPool{ + Creator: i.ALICE, + PoolId: 0, + Amount: 50 * i.KYVE, + }) + + // ASSERT + balanceAfter := s.GetBalanceFromAddress(i.ALICE) + + Expect(initialBalance - balanceAfter).To(Equal(50 * i.KYVE)) + + funding, _ := s.App().FundersKeeper.GetFunding(s.Ctx(), i.ALICE, 0) + Expect(funding.Amount).To(Equal(50 * i.KYVE)) + Expect(funding.AmountPerBundle).To(Equal(1 * i.KYVE)) + Expect(funding.TotalFunded).To(Equal(0 * i.KYVE)) + + fundingState, _ := s.App().FundersKeeper.GetFundingState(s.Ctx(), 0) + Expect(len(fundingState.ActiveFunderAddresses)).To(Equal(1)) + Expect(fundingState.ActiveFunderAddresses[0]).To(Equal(i.ALICE)) + }) + + It("Defund more than actually funded", func() { + // ACT + s.RunTxFundersSuccess(&types.MsgDefundPool{ + Creator: i.ALICE, + PoolId: 0, + Amount: 101 * i.KYVE, + }) + + // ASSERT + balanceAfter := s.GetBalanceFromAddress(i.ALICE) + Expect(initialBalance - balanceAfter).To(BeZero()) + + funding, _ := s.App().FundersKeeper.GetFunding(s.Ctx(), i.ALICE, 0) + Expect(funding.Amount).To(Equal(0 * i.KYVE)) + Expect(funding.AmountPerBundle).To(Equal(1 * i.KYVE)) + Expect(funding.TotalFunded).To(Equal(0 * i.KYVE)) + + fundingState, _ := s.App().FundersKeeper.GetFundingState(s.Ctx(), 0) + Expect(len(fundingState.ActiveFunderAddresses)).To(Equal(0)) + }) + + It("Defund full funding amount from a funder who has previously funded 100 KYVE", func() { + // ACT + s.RunTxFundersSuccess(&types.MsgDefundPool{ + Creator: i.ALICE, + PoolId: 0, + Amount: 100 * i.KYVE, + }) + + // ASSERT + balanceAfter := s.GetBalanceFromAddress(i.ALICE) + Expect(initialBalance - balanceAfter).To(BeZero()) + + funding, _ := s.App().FundersKeeper.GetFunding(s.Ctx(), i.ALICE, 0) + Expect(funding.Amount).To(Equal(0 * i.KYVE)) + Expect(funding.AmountPerBundle).To(Equal(1 * i.KYVE)) + Expect(funding.TotalFunded).To(Equal(0 * i.KYVE)) + + fundingState, _ := s.App().FundersKeeper.GetFundingState(s.Ctx(), 0) + Expect(len(fundingState.ActiveFunderAddresses)).To(Equal(0)) + }) + + It("Defund as highest funder 75 KYVE in order to be the lowest funder afterwards", func() { + // ARRANGE + s.RunTxFundersSuccess(&types.MsgCreateFunder{ + Creator: i.BOB, + Moniker: "moniker", + }) + s.RunTxFundersSuccess(&types.MsgFundPool{ + Creator: i.BOB, + PoolId: 0, + Amount: 50 * i.KYVE, + AmountPerBundle: 1 * i.KYVE, + }) + + fundingState, _ := s.App().FundersKeeper.GetFundingState(s.Ctx(), 0) + activeFundings := s.App().FundersKeeper.GetActiveFundings(s.Ctx(), fundingState) + lowestFunding, err := s.App().FundersKeeper.GetLowestFunding(activeFundings) + Expect(err).To(BeNil()) + Expect(lowestFunding.FunderAddress).To(Equal(i.BOB)) + + // ACT + s.RunTxFundersSuccess(&types.MsgDefundPool{ + Creator: i.ALICE, + PoolId: 0, + Amount: 75 * i.KYVE, + }) + + // ASSERT + fundingState, _ = s.App().FundersKeeper.GetFundingState(s.Ctx(), 0) + activeFundings = s.App().FundersKeeper.GetActiveFundings(s.Ctx(), fundingState) + lowestFunding, err = s.App().FundersKeeper.GetLowestFunding(activeFundings) + Expect(err).To(BeNil()) + Expect(lowestFunding.FunderAddress).To(Equal(i.ALICE)) + }) + + It("Try to defund nonexistent fundings", func() { + // ASSERT + s.RunTxFundersError(&types.MsgDefundPool{ + Creator: i.ALICE, + PoolId: 1, + Amount: 1 * i.KYVE, + }) + + s.RunTxFundersError(&types.MsgDefundPool{ + Creator: i.BOB, + PoolId: 0, + Amount: 1 * i.KYVE, + }) + }) + + It("Try to defund a funding twice", func() { + // ACT + s.RunTxFundersSuccess(&types.MsgDefundPool{ + Creator: i.ALICE, + PoolId: 0, + Amount: 100 * i.KYVE, + }) + + // ASSERT + s.RunTxFundersError(&types.MsgDefundPool{ + Creator: i.ALICE, + PoolId: 0, + Amount: 100 * i.KYVE, + }) + }) + + It("Try to defund below minimum funding params (but not full defund)", func() { + // ACT + _, err := s.RunTx(&types.MsgDefundPool{ + Creator: i.ALICE, + PoolId: 0, + Amount: 100*i.KYVE - types.DefaultMinFundingAmount/2, + }) + + // ASSERT + Expect(err.Error()).To(Equal("minimum funding amount of 1000000000kyve not reached: invalid request")) + }) +}) diff --git a/x/funders/keeper/msg_server_fund_pool.go b/x/funders/keeper/msg_server_fund_pool.go new file mode 100644 index 00000000..8fd3cbcb --- /dev/null +++ b/x/funders/keeper/msg_server_fund_pool.go @@ -0,0 +1,90 @@ +package keeper + +import ( + "context" + + "cosmossdk.io/errors" + "github.com/KYVENetwork/chain/util" + "github.com/KYVENetwork/chain/x/funders/types" + sdk "github.com/cosmos/cosmos-sdk/types" + errorsTypes "github.com/cosmos/cosmos-sdk/types/errors" +) + +// FundPool handles the logic to fund a pool. +// A funder is added to the active funders list with the specified amount +// If the funders list is full, it checks if the funder wants to fund +// more than the current lowest funder. If so, the current lowest funder +// will get their tokens back and removed form the active funders list. +func (k msgServer) FundPool(goCtx context.Context, msg *types.MsgFundPool) (*types.MsgFundPoolResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + // Funder has to exist + if !k.DoesFunderExist(ctx, msg.Creator) { + return nil, errors.Wrapf(errorsTypes.ErrNotFound, types.ErrFunderDoesNotExist.Error(), msg.Creator) + } + + // Pool has to exist + if err := k.poolKeeper.AssertPoolExists(ctx, msg.PoolId); err != nil { + return nil, err + } + + // Get funding state for pool + fundingState, found := k.GetFundingState(ctx, msg.PoolId) + if !found { + return nil, errors.Wrapf(errorsTypes.ErrNotFound, types.ErrFundingStateDoesNotExist.Error(), msg.PoolId) + } + + // Check if funding already exists + funding, found := k.GetFunding(ctx, msg.Creator, msg.PoolId) + if found { + // If so, update funding amount + funding.AddAmount(msg.Amount) + // If the amount per bundle is set, update it + if msg.AmountPerBundle > 0 { + funding.AmountPerBundle = msg.AmountPerBundle + } + } else { + // If not, create new funding + funding = types.Funding{ + FunderAddress: msg.Creator, + PoolId: msg.PoolId, + Amount: msg.Amount, + AmountPerBundle: msg.AmountPerBundle, + TotalFunded: 0, + } + } + + // Check if updated (or new) funding is compatible with module params + if err := k.ensureParamsCompatibility(ctx, funding); err != nil { + return nil, err + } + + // Kicks out lowest funder if all slots are taken and new funder is about to fund more. + // Otherwise, an error is thrown + // funding and fundingState are not written to the KV-Store. Everything else is handled safely. + if err := k.ensureFreeSlot(ctx, &funding, &fundingState); err != nil { + return nil, err + } + + // All checks passed, transfer funds from funder to module + if err := util.TransferFromAddressToModule(k.bankKeeper, ctx, msg.Creator, types.ModuleName, msg.Amount); err != nil { + return nil, err + } + + // Funding must be active + fundingState.SetActive(&funding) + + // Save funding and funding state + k.SetFunding(ctx, &funding) + k.SetFundingState(ctx, &fundingState) + + // Emit a fund event. + _ = ctx.EventManager().EmitTypedEvent(&types.EventFundPool{ + PoolId: msg.PoolId, + Address: msg.Creator, + Amount: msg.Amount, + AmountPerBundle: msg.AmountPerBundle, + }) + + return &types.MsgFundPoolResponse{}, nil +} diff --git a/x/funders/keeper/msg_server_fund_pool_test.go b/x/funders/keeper/msg_server_fund_pool_test.go new file mode 100644 index 00000000..a6a251b8 --- /dev/null +++ b/x/funders/keeper/msg_server_fund_pool_test.go @@ -0,0 +1,432 @@ +package keeper_test + +import ( + i "github.com/KYVENetwork/chain/testutil/integration" + funderstypes "github.com/KYVENetwork/chain/x/funders/types" + pooltypes "github.com/KYVENetwork/chain/x/pool/types" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" +) + +/* + +TEST CASES - msg_server_fund_pool.go + +* Fund a pool with 100 $KYVE +* Fund additional 50 $KYVE to an existing funding with 100 $KYVE +* Try to fund more $KYVE than available in balance +* Fund with a new funder less $KYVE than the existing one +* Fund with a new funder more $KYVE than the existing one +* Try to fund with a non-existent funder +* Try to fund less $KYVE than the lowest funder with full funding slots +* Fund more $KYVE than the lowest funder with full funding slots +* Refund a funding as the lowest funder +* Try to fund a non-existent pool +* Try to fund below the minimum amount +* Try to fund below the minimum amount per bundle +* Try to fund without fulfilling min_funding_multiple + +*/ + +var _ = Describe("msg_server_fund_pool.go", Ordered, func() { + s := i.NewCleanChain() + + initialBalance := s.GetBalanceFromAddress(i.ALICE) + + BeforeEach(func() { + // init new clean chain + s = i.NewCleanChain() + + // create clean pool for every test case + gov := s.App().GovKeeper.GetGovernanceAccount(s.Ctx()).GetAddress().String() + msg := &pooltypes.MsgCreatePool{ + Authority: gov, + Name: "PoolTest", + Runtime: "@kyve/test", + Logo: "ar://Tewyv2P5VEG8EJ6AUQORdqNTectY9hlOrWPK8wwo-aU", + Config: "ar://DgdB-2hLrxjhyEEbCML__dgZN5_uS7T6Z5XDkaFh3P0", + StartKey: "0", + UploadInterval: 60, + InflationShareWeight: 10_000, + MinDelegation: 100 * i.KYVE, + MaxBundleSize: 100, + Version: "0.0.0", + Binaries: "{}", + StorageProviderId: 2, + CompressionId: 1, + } + s.RunTxPoolSuccess(msg) + + // create funder + s.RunTxFundersSuccess(&funderstypes.MsgCreateFunder{ + Creator: i.ALICE, + Moniker: "Alice", + }) + s.RunTxFundersSuccess(&funderstypes.MsgCreateFunder{ + Creator: i.BOB, + Moniker: "Bob", + }) + }) + + AfterEach(func() { + s.PerformValidityChecks() + }) + + It("Fund a pool with 100 $KYVE", func() { + // ACT + s.RunTxFundersSuccess(&funderstypes.MsgFundPool{ + Creator: i.ALICE, + PoolId: 0, + Amount: 100 * i.KYVE, + AmountPerBundle: 1 * i.KYVE, + }) + + // ASSERT + balanceAfter := s.GetBalanceFromAddress(i.ALICE) + + Expect(initialBalance - balanceAfter).To(Equal(100 * i.KYVE)) + + funding, _ := s.App().FundersKeeper.GetFunding(s.Ctx(), i.ALICE, 0) + Expect(funding.FunderAddress).To(Equal(i.ALICE)) + Expect(funding.PoolId).To(Equal(uint64(0))) + Expect(funding.Amount).To(Equal(100 * i.KYVE)) + Expect(funding.AmountPerBundle).To(Equal(1 * i.KYVE)) + Expect(funding.TotalFunded).To(Equal(0 * i.KYVE)) + + fundingState, _ := s.App().FundersKeeper.GetFundingState(s.Ctx(), 0) + Expect(fundingState.PoolId).To(Equal(uint64(0))) + Expect(len(fundingState.ActiveFunderAddresses)).To(Equal(1)) + Expect(fundingState.ActiveFunderAddresses[0]).To(Equal(i.ALICE)) + }) + + It("Fund additional 50 $KYVE to an existing funding with 100 $KYVE", func() { + // ARRANGE + s.RunTxFundersSuccess(&funderstypes.MsgFundPool{ + Creator: i.ALICE, + PoolId: 0, + Amount: 100 * i.KYVE, + AmountPerBundle: 1 * i.KYVE, + }) + + // ACT + s.RunTxFundersSuccess(&funderstypes.MsgFundPool{ + Creator: i.ALICE, + PoolId: 0, + Amount: 50 * i.KYVE, + }) + + // ASSERT + balanceAfter := s.GetBalanceFromAddress(i.ALICE) + + Expect(initialBalance - balanceAfter).To(Equal(150 * i.KYVE)) + + funding, _ := s.App().FundersKeeper.GetFunding(s.Ctx(), i.ALICE, 0) + Expect(funding.FunderAddress).To(Equal(i.ALICE)) + Expect(funding.PoolId).To(Equal(uint64(0))) + Expect(funding.Amount).To(Equal(150 * i.KYVE)) + Expect(funding.AmountPerBundle).To(Equal(1 * i.KYVE)) + Expect(funding.TotalFunded).To(Equal(0 * i.KYVE)) + + fundingState, _ := s.App().FundersKeeper.GetFundingState(s.Ctx(), 0) + Expect(fundingState.PoolId).To(Equal(uint64(0))) + Expect(len(fundingState.ActiveFunderAddresses)).To(Equal(1)) + Expect(fundingState.ActiveFunderAddresses[0]).To(Equal(i.ALICE)) + + activeFundings := s.App().FundersKeeper.GetActiveFundings(s.Ctx(), fundingState) + lowestFunding, err := s.App().FundersKeeper.GetLowestFunding(activeFundings) + Expect(err).To(BeNil()) + Expect(lowestFunding.FunderAddress).To(Equal(i.ALICE)) + }) + + It("Try to fund more $KYVE than available in balance", func() { + // ACT + currentBalance := s.GetBalanceFromAddress(i.ALICE) + + s.RunTxFundersError(&funderstypes.MsgFundPool{ + Creator: i.ALICE, + PoolId: 0, + Amount: currentBalance + 1, + AmountPerBundle: 1 * i.KYVE, + }) + + // ASSERT + balanceAfter := s.GetBalanceFromAddress(i.ALICE) + Expect(initialBalance - balanceAfter).To(BeZero()) + + _, found := s.App().FundersKeeper.GetFunding(s.Ctx(), i.ALICE, 0) + Expect(found).To(BeFalse()) + + fundingState, _ := s.App().FundersKeeper.GetFundingState(s.Ctx(), 0) + Expect(fundingState.PoolId).To(Equal(uint64(0))) + Expect(len(fundingState.ActiveFunderAddresses)).To(Equal(0)) + }) + + It("Fund with a new funder less $KYVE than the existing one", func() { + // ARRANGE + s.RunTxFundersSuccess(&funderstypes.MsgFundPool{ + Creator: i.ALICE, + PoolId: 0, + Amount: 100 * i.KYVE, + AmountPerBundle: 1 * i.KYVE, + }) + + // ACT + s.RunTxFundersSuccess(&funderstypes.MsgFundPool{ + Creator: i.BOB, + PoolId: 0, + Amount: 50 * i.KYVE, + AmountPerBundle: 1 * i.KYVE, + }) + + // ASSERT + balanceAfter := s.GetBalanceFromAddress(i.BOB) + Expect(initialBalance - balanceAfter).To(Equal(50 * i.KYVE)) + + funding, _ := s.App().FundersKeeper.GetFunding(s.Ctx(), i.BOB, 0) + Expect(funding.Amount).To(Equal(50 * i.KYVE)) + Expect(funding.AmountPerBundle).To(Equal(1 * i.KYVE)) + Expect(funding.TotalFunded).To(Equal(0 * i.KYVE)) + + fundingState, _ := s.App().FundersKeeper.GetFundingState(s.Ctx(), 0) + Expect(fundingState.PoolId).To(Equal(uint64(0))) + Expect(len(fundingState.ActiveFunderAddresses)).To(Equal(2)) + + activeFundings := s.App().FundersKeeper.GetActiveFundings(s.Ctx(), fundingState) + lowestFunding, err := s.App().FundersKeeper.GetLowestFunding(activeFundings) + Expect(err).To(BeNil()) + Expect(lowestFunding.FunderAddress).To(Equal(i.BOB)) + }) + + It("Fund with a new funder more $KYVE than the existing one", func() { + // ARRANGE + s.RunTxFundersSuccess(&funderstypes.MsgFundPool{ + Creator: i.ALICE, + PoolId: 0, + Amount: 100 * i.KYVE, + AmountPerBundle: 1 * i.KYVE, + }) + + // ACT + s.RunTxFundersSuccess(&funderstypes.MsgFundPool{ + Creator: i.BOB, + PoolId: 0, + Amount: 200 * i.KYVE, + AmountPerBundle: 1 * i.KYVE, + }) + + // ASSERT + balanceAfter := s.GetBalanceFromAddress(i.BOB) + Expect(initialBalance - balanceAfter).To(Equal(200 * i.KYVE)) + + funding, _ := s.App().FundersKeeper.GetFunding(s.Ctx(), i.BOB, 0) + Expect(funding.Amount).To(Equal(200 * i.KYVE)) + Expect(funding.AmountPerBundle).To(Equal(1 * i.KYVE)) + Expect(funding.TotalFunded).To(Equal(0 * i.KYVE)) + + fundingState, _ := s.App().FundersKeeper.GetFundingState(s.Ctx(), 0) + Expect(fundingState.PoolId).To(Equal(uint64(0))) + Expect(len(fundingState.ActiveFunderAddresses)).To(Equal(2)) + + activeFundings := s.App().FundersKeeper.GetActiveFundings(s.Ctx(), fundingState) + lowestFunding, err := s.App().FundersKeeper.GetLowestFunding(activeFundings) + Expect(err).To(BeNil()) + Expect(lowestFunding.FunderAddress).To(Equal(i.ALICE)) + }) + + It("Try to fund with a non-existent funder", func() { + // ASSERT + s.RunTxFundersError(&funderstypes.MsgFundPool{ + Creator: i.CHARLIE, + PoolId: 0, + Amount: 100 * i.KYVE, + AmountPerBundle: 1 * i.KYVE, + }) + }) + + It("Try to fund less $KYVE than the lowest funder with full funding slots", func() { + // ARRANGE + s.RunTxFundersSuccess(&funderstypes.MsgFundPool{ + Creator: i.ALICE, + PoolId: 0, + Amount: 100 * i.KYVE, + AmountPerBundle: 1 * i.KYVE, + }) + + for a := 0; a < funderstypes.MaxFunders-1; a++ { + s.RunTxFundersSuccess(&funderstypes.MsgCreateFunder{ + Creator: i.DUMMY[a], + Moniker: i.DUMMY[a], + }) + // fill remaining funding slots + s.RunTxFundersSuccess(&funderstypes.MsgFundPool{ + Creator: i.DUMMY[a], + PoolId: 0, + Amount: 1000 * i.KYVE, + AmountPerBundle: 1 * i.KYVE, + }) + } + + fundingState, _ := s.App().FundersKeeper.GetFundingState(s.Ctx(), 0) + Expect(len(fundingState.ActiveFunderAddresses)).To(Equal(funderstypes.MaxFunders)) + + balanceAfter := s.GetBalanceFromAddress(i.ALICE) + Expect(initialBalance - balanceAfter).To(Equal(100 * i.KYVE)) + + // ACT + s.RunTxFundersError(&funderstypes.MsgFundPool{ + Creator: i.BOB, + PoolId: 0, + Amount: 50 * i.KYVE, + AmountPerBundle: 1 * i.KYVE, + }) + + // ASSERT + fundingState, _ = s.App().FundersKeeper.GetFundingState(s.Ctx(), 0) + Expect(len(fundingState.ActiveFunderAddresses)).To(Equal(funderstypes.MaxFunders)) + + activeFundings := s.App().FundersKeeper.GetActiveFundings(s.Ctx(), fundingState) + Expect(activeFundings).To(HaveLen(50)) + lowestFunding, err := s.App().FundersKeeper.GetLowestFunding(activeFundings) + Expect(err).To(BeNil()) + Expect(lowestFunding.FunderAddress).To(Equal(i.ALICE)) + }) + + It("Fund more $KYVE than the lowest funder with full funding slots", func() { + // ARRANGE + initialBalanceBob := s.GetBalanceFromAddress(i.BOB) + s.RunTxFundersSuccess(&funderstypes.MsgFundPool{ + Creator: i.ALICE, + PoolId: 0, + Amount: 100 * i.KYVE, + AmountPerBundle: 1 * i.KYVE, + }) + + for a := 0; a < funderstypes.MaxFunders-1; a++ { + s.RunTxFundersSuccess(&funderstypes.MsgCreateFunder{ + Creator: i.DUMMY[a], + Moniker: i.DUMMY[a], + }) + // fill remaining funding slots + s.RunTxFundersSuccess(&funderstypes.MsgFundPool{ + Creator: i.DUMMY[a], + PoolId: 0, + Amount: 1000 * i.KYVE, + AmountPerBundle: 1 * i.KYVE, + }) + } + balanceAfter := s.GetBalanceFromAddress(i.ALICE) + Expect(initialBalance - balanceAfter).To(Equal(100 * i.KYVE)) + + // ACT + s.RunTxFundersSuccess(&funderstypes.MsgFundPool{ + Creator: i.BOB, + PoolId: 0, + Amount: 200 * i.KYVE, + AmountPerBundle: 1 * i.KYVE, + }) + x := s.GetBalanceFromAddress(i.BOB) + Expect(initialBalanceBob - x).To(Equal(200 * i.KYVE)) + // ASSERT + fundingState, _ := s.App().FundersKeeper.GetFundingState(s.Ctx(), 0) + Expect(len(fundingState.ActiveFunderAddresses)).To(Equal(funderstypes.MaxFunders)) + + activeFundings := s.App().FundersKeeper.GetActiveFundings(s.Ctx(), fundingState) + Expect(activeFundings).To(HaveLen(50)) + lowestFunding, err := s.App().FundersKeeper.GetLowestFunding(activeFundings) + Expect(err).To(BeNil()) + Expect(lowestFunding.FunderAddress).To(Equal(i.BOB)) + + balanceEnd := s.GetBalanceFromAddress(i.ALICE) + Expect(initialBalance - balanceEnd).To(BeZero()) + + balanceAfterBob := s.GetBalanceFromAddress(i.BOB) + Expect(initialBalanceBob - balanceAfterBob).To(Equal(200 * i.KYVE)) + }) + + It("Refund a funding as the lowest funder", func() { + // ARRANGE + s.RunTxFundersSuccess(&funderstypes.MsgFundPool{ + Creator: i.ALICE, + PoolId: 0, + Amount: 100 * i.KYVE, + AmountPerBundle: 1 * i.KYVE, + }) + + for a := 0; a < funderstypes.MaxFunders-1; a++ { + s.RunTxFundersSuccess(&funderstypes.MsgCreateFunder{ + Creator: i.DUMMY[a], + Moniker: i.DUMMY[a], + }) + // fill remaining funding slots + s.RunTxFundersSuccess(&funderstypes.MsgFundPool{ + Creator: i.DUMMY[a], + PoolId: 0, + Amount: 1000 * i.KYVE, + AmountPerBundle: 1 * i.KYVE, + }) + } + + fundingState, _ := s.App().FundersKeeper.GetFundingState(s.Ctx(), 0) + activeFundings := s.App().FundersKeeper.GetActiveFundings(s.Ctx(), fundingState) + Expect(activeFundings).To(HaveLen(50)) + lowestFunding, err := s.App().FundersKeeper.GetLowestFunding(activeFundings) + Expect(err).To(BeNil()) + Expect(lowestFunding.FunderAddress).To(Equal(i.ALICE)) + + // ACT + s.RunTxFundersSuccess(&funderstypes.MsgFundPool{ + Creator: i.ALICE, + PoolId: 0, + Amount: 50 * i.KYVE, + AmountPerBundle: 1 * i.KYVE, + }) + + // ASSERT + fundingState, _ = s.App().FundersKeeper.GetFundingState(s.Ctx(), 0) + Expect(len(fundingState.ActiveFunderAddresses)).To(Equal(funderstypes.MaxFunders)) + + balanceEnd := s.GetBalanceFromAddress(i.ALICE) + Expect(initialBalance - balanceEnd).To(Equal(150 * i.KYVE)) + }) + + It("Try to fund a non-existent pool", func() { + // ASSERT + s.RunTxFundersError(&funderstypes.MsgFundPool{ + Creator: i.ALICE, + PoolId: 1, + Amount: 100 * i.KYVE, + AmountPerBundle: 1 * i.KYVE, + }) + }) + + It("Try to fund below the minimum amount", func() { + // ASSERT + s.RunTxFundersError(&funderstypes.MsgFundPool{ + Creator: i.ALICE, + PoolId: 0, + Amount: 1, + AmountPerBundle: 1 * i.KYVE, + }) + }) + + It("Try to fund below the minimum amount per bundle", func() { + // ASSERT + s.RunTxFundersError(&funderstypes.MsgFundPool{ + Creator: i.ALICE, + PoolId: 0, + Amount: 100 * i.KYVE, + AmountPerBundle: 1, + }) + }) + + It("Try to fund without fulfilling min_funding_multiple", func() { + // ASSERT + _, err := s.RunTx(&funderstypes.MsgFundPool{ + Creator: i.ALICE, + PoolId: 0, + Amount: 2 * i.KYVE, + AmountPerBundle: 1 * i.KYVE, + }) + Expect(err.Error()).To(Equal("per_bundle_amount (1000000000kyve) times min_funding_multiple (1000000000) is smaller than funded_amount (2000000000kyve): invalid request")) + }) +}) diff --git a/x/funders/keeper/msg_server_update_funder.go b/x/funders/keeper/msg_server_update_funder.go new file mode 100644 index 00000000..b609f768 --- /dev/null +++ b/x/funders/keeper/msg_server_update_funder.go @@ -0,0 +1,42 @@ +package keeper + +import ( + "context" + + "cosmossdk.io/errors" + "github.com/KYVENetwork/chain/x/funders/types" + sdk "github.com/cosmos/cosmos-sdk/types" + errorsTypes "github.com/cosmos/cosmos-sdk/types/errors" +) + +// UpdateFunder allows a funder to change basic metadata like moniker, address, logo, etc. +func (k msgServer) UpdateFunder(goCtx context.Context, msg *types.MsgUpdateFunder) (*types.MsgUpdateFunderResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + // Error if funder does not exist + if !k.DoesFunderExist(ctx, msg.Creator) { + return nil, errors.Wrap(errorsTypes.ErrNotFound, types.ErrFunderDoesNotExist.Error()) + } + + // Update funder + k.SetFunder(ctx, &types.Funder{ + Address: msg.Creator, + Moniker: msg.Moniker, + Identity: msg.Identity, + Website: msg.Website, + Contact: msg.Contact, + Description: msg.Description, + }) + + // Emit a update funder event + _ = ctx.EventManager().EmitTypedEvent(&types.EventUpdateFunder{ + Address: msg.Creator, + Moniker: msg.Moniker, + Identity: msg.Identity, + Website: msg.Website, + Contact: msg.Contact, + Description: msg.Description, + }) + + return &types.MsgUpdateFunderResponse{}, nil +} diff --git a/x/funders/keeper/msg_server_update_funder_test.go b/x/funders/keeper/msg_server_update_funder_test.go new file mode 100644 index 00000000..fd810a54 --- /dev/null +++ b/x/funders/keeper/msg_server_update_funder_test.go @@ -0,0 +1,99 @@ +package keeper_test + +import ( + "github.com/KYVENetwork/chain/x/funders/types" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + + i "github.com/KYVENetwork/chain/testutil/integration" +) + +/* + +TEST CASES - msg_server_update_funder.go + +* Try to update a funder that does not exist +* Try to update a funder with empty moniker +* Update a funder with empty values except moniker +* Update a funder with all values set +*/ + +var _ = Describe("msg_server_update_funder.go", Ordered, func() { + s := i.NewCleanChain() + + BeforeEach(func() { + // init new clean chain + s = i.NewCleanChain() + + moniker, identity, website, contact, description := "AliceMoniker", "identity", "website", "contact", "description" + s.RunTxFundersSuccess(&types.MsgCreateFunder{ + Creator: i.ALICE, + Moniker: moniker, + Identity: identity, + Website: website, + Contact: contact, + Description: description, + }) + }) + + AfterEach(func() { + s.PerformValidityChecks() + }) + + It("Try to update a funder that does not exist", func() { + // ASSERT + s.RunTxFundersError(&types.MsgUpdateFunder{ + Creator: i.BOB, + Moniker: "moniker", + }) + }) + + It("Try to update a funder with empty moniker", func() { + // ASSERT + s.RunTxFundersError(&types.MsgUpdateFunder{ + Creator: i.BOB, + Moniker: "", + }) + }) + + It("Update a funder with empty values except moniker", func() { + // ACT + s.RunTxFundersSuccess(&types.MsgUpdateFunder{ + Creator: i.ALICE, + Moniker: "moniker", + }) + + // ASSERT + funder, found := s.App().FundersKeeper.GetFunder(s.Ctx(), i.ALICE) + Expect(found).To(BeTrue()) + Expect(funder.Address).To(Equal(i.ALICE)) + Expect(funder.Moniker).To(Equal("moniker")) + Expect(funder.Identity).To(BeEmpty()) + Expect(funder.Website).To(BeEmpty()) + Expect(funder.Contact).To(BeEmpty()) + Expect(funder.Description).To(BeEmpty()) + }) + + It("Update a funder with all values set", func() { + // ACT + moniker, identity, website, contact, description := "moniker", "identity", "website", "contact", "description" + s.RunTxFundersSuccess(&types.MsgUpdateFunder{ + Creator: i.ALICE, + Moniker: moniker, + Identity: identity, + Website: website, + Contact: contact, + Description: description, + }) + + // ASSERT + funder, found := s.App().FundersKeeper.GetFunder(s.Ctx(), i.ALICE) + Expect(found).To(BeTrue()) + Expect(funder.Address).To(Equal(i.ALICE)) + Expect(funder.Moniker).To(Equal(moniker)) + Expect(funder.Identity).To(Equal(identity)) + Expect(funder.Website).To(Equal(website)) + Expect(funder.Contact).To(Equal(contact)) + Expect(funder.Description).To(Equal(description)) + }) +}) diff --git a/x/funders/keeper/msg_server_update_params.go b/x/funders/keeper/msg_server_update_params.go new file mode 100644 index 00000000..0872cc62 --- /dev/null +++ b/x/funders/keeper/msg_server_update_params.go @@ -0,0 +1,35 @@ +package keeper + +import ( + "context" + "encoding/json" + + "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + + // Delegation + "github.com/KYVENetwork/chain/x/funders/types" + // Gov + govTypes "github.com/cosmos/cosmos-sdk/x/gov/types" +) + +func (k msgServer) UpdateParams(goCtx context.Context, msg *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) { + if k.authority != msg.Authority { + return nil, errors.Wrapf(govTypes.ErrInvalidSigner, "invalid authority; expected %s, got %s", k.authority, msg.Authority) + } + + ctx := sdk.UnwrapSDKContext(goCtx) + oldParams := k.GetParams(ctx) + + newParams := oldParams + _ = json.Unmarshal([]byte(msg.Payload), &newParams) + k.SetParams(ctx, newParams) + + _ = ctx.EventManager().EmitTypedEvent(&types.EventUpdateParams{ + OldParams: oldParams, + NewParams: newParams, + Payload: msg.Payload, + }) + + return &types.MsgUpdateParamsResponse{}, nil +} diff --git a/x/funders/keeper/msg_server_update_params_test.go b/x/funders/keeper/msg_server_update_params_test.go new file mode 100644 index 00000000..c60aaccc --- /dev/null +++ b/x/funders/keeper/msg_server_update_params_test.go @@ -0,0 +1,409 @@ +package keeper_test + +import ( + i "github.com/KYVENetwork/chain/testutil/integration" + sdk "github.com/cosmos/cosmos-sdk/types" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + + // Delegation + "github.com/KYVENetwork/chain/x/funders/types" + // Gov + govV1Types "github.com/cosmos/cosmos-sdk/x/gov/types/v1" +) + +/* + +TEST CASES - msg_server_update_params.go + +* Check default params +* Invalid authority (transaction) +* Invalid authority (proposal) +* Update every param at once +* Update no param +* Update with invalid formatted payload + +* Update min-funding-amount +* Update min-funding-amount with invalid value + +* Update min-funding-amount-per-bundle +* Update min-funding-amount-per-bundle with invalid value + +* Update min-funding-multiple +* Update min-funding-multiple with invalid value + +*/ + +var _ = Describe("msg_server_update_params.go", Ordered, func() { + s := i.NewCleanChain() + + gov := s.App().GovKeeper.GetGovernanceAccount(s.Ctx()).GetAddress().String() + + minDeposit := s.App().GovKeeper.GetParams(s.Ctx()).MinDeposit + votingPeriod := s.App().GovKeeper.GetParams(s.Ctx()).VotingPeriod + + delegations := s.App().StakingKeeper.GetAllDelegations(s.Ctx()) + voter := sdk.MustAccAddressFromBech32(delegations[0].DelegatorAddress) + + BeforeEach(func() { + s = i.NewCleanChain() + + delegations := s.App().StakingKeeper.GetAllDelegations(s.Ctx()) + voter = sdk.MustAccAddressFromBech32(delegations[0].DelegatorAddress) + }) + + AfterEach(func() { + s.PerformValidityChecks() + }) + + It("Check default params", func() { + // ASSERT + params := s.App().FundersKeeper.GetParams(s.Ctx()) + + Expect(params.MinFundingAmount).To(Equal(types.DefaultMinFundingAmount)) + Expect(params.MinFundingAmountPerBundle).To(Equal(types.DefaultMinFundingAmountPerBundle)) + Expect(params.MinFundingMultiple).To(Equal(types.DefaultMinFundingMultiple)) + }) + + It("Invalid authority (transaction)", func() { + // ARRANGE + msg := &types.MsgUpdateParams{ + Authority: i.DUMMY[0], + Payload: "{}", + } + + // ACT + _, err := s.RunTx(msg) + + // ASSERT + Expect(err).To(HaveOccurred()) + }) + + It("Invalid authority (proposal)", func() { + // ARRANGE + msg := &types.MsgUpdateParams{ + Authority: i.DUMMY[0], + Payload: "{}", + } + + proposal, _ := govV1Types.NewMsgSubmitProposal( + []sdk.Msg{msg}, minDeposit, i.DUMMY[0], "", "title", "summary", + ) + + // ACT + _, err := s.RunTx(proposal) + + // ASSERT + Expect(err).To(HaveOccurred()) + }) + + It("Update every param at once", func() { + // ARRANGE + payload := `{ + "min_funding_amount": 2000000000, + "min_funding_amount_per_bundle": 500000, + "min_funding_multiple": 25 + }` + + msg := &types.MsgUpdateParams{ + Authority: gov, + Payload: payload, + } + + proposal, _ := govV1Types.NewMsgSubmitProposal( + []sdk.Msg{msg}, minDeposit, i.DUMMY[0], "", "title", "summary", + ) + + vote := govV1Types.NewMsgVote( + voter, 1, govV1Types.VoteOption_VOTE_OPTION_YES, "", + ) + + // ACT + _, submitErr := s.RunTx(proposal) + _, voteErr := s.RunTx(vote) + + s.CommitAfter(*votingPeriod) + s.Commit() + + // ASSERT + updatedParams := s.App().FundersKeeper.GetParams(s.Ctx()) + + Expect(submitErr).NotTo(HaveOccurred()) + Expect(voteErr).NotTo(HaveOccurred()) + + Expect(updatedParams.MinFundingAmount).To(Equal(uint64(2_000_000_000))) + Expect(updatedParams.MinFundingAmountPerBundle).To(Equal(uint64(500_000))) + Expect(updatedParams.MinFundingMultiple).To(Equal(uint64(25))) + }) + + It("Update no param", func() { + // ARRANGE + payload := `{}` + + msg := &types.MsgUpdateParams{ + Authority: gov, + Payload: payload, + } + + proposal, _ := govV1Types.NewMsgSubmitProposal( + []sdk.Msg{msg}, minDeposit, i.DUMMY[0], "", "title", "summary", + ) + + vote := govV1Types.NewMsgVote( + voter, 1, govV1Types.VoteOption_VOTE_OPTION_YES, "", + ) + + // ACT + _, submitErr := s.RunTx(proposal) + _, voteErr := s.RunTx(vote) + + s.CommitAfter(*votingPeriod) + s.Commit() + + // ASSERT + updatedParams := s.App().FundersKeeper.GetParams(s.Ctx()) + + Expect(submitErr).NotTo(HaveOccurred()) + Expect(voteErr).NotTo(HaveOccurred()) + + Expect(updatedParams.MinFundingAmount).To(Equal(types.DefaultMinFundingAmount)) + Expect(updatedParams.MinFundingAmountPerBundle).To(Equal(types.DefaultMinFundingAmountPerBundle)) + Expect(updatedParams.MinFundingMultiple).To(Equal(types.DefaultMinFundingMultiple)) + }) + + It("Update with invalid formatted payload", func() { + // ARRANGE + payload := `{ + "min_funding_amount": abc, + }` + + msg := &types.MsgUpdateParams{ + Authority: gov, + Payload: payload, + } + + proposal, _ := govV1Types.NewMsgSubmitProposal( + []sdk.Msg{msg}, minDeposit, i.DUMMY[0], "", "title", "summary", + ) + + // ACT + _, submitErr := s.RunTx(proposal) + + s.CommitAfter(*votingPeriod) + s.Commit() + + // ASSERT + updatedParams := s.App().FundersKeeper.GetParams(s.Ctx()) + + Expect(submitErr).To(HaveOccurred()) + + Expect(updatedParams.MinFundingAmount).To(Equal(types.DefaultMinFundingAmount)) + Expect(updatedParams.MinFundingAmountPerBundle).To(Equal(types.DefaultMinFundingAmountPerBundle)) + Expect(updatedParams.MinFundingMultiple).To(Equal(types.DefaultMinFundingMultiple)) + }) + + It("Update min-funding-amount", func() { + // ARRANGE + payload := `{ + "min_funding_amount": 100000000 + }` + + msg := &types.MsgUpdateParams{ + Authority: gov, + Payload: payload, + } + + proposal, _ := govV1Types.NewMsgSubmitProposal( + []sdk.Msg{msg}, minDeposit, i.DUMMY[0], "", "title", "summary", + ) + + vote := govV1Types.NewMsgVote( + voter, 1, govV1Types.VoteOption_VOTE_OPTION_YES, "", + ) + + // ACT + _, submitErr := s.RunTx(proposal) + _, voteErr := s.RunTx(vote) + + s.CommitAfter(*votingPeriod) + s.Commit() + + // ASSERT + updatedParams := s.App().FundersKeeper.GetParams(s.Ctx()) + + Expect(submitErr).NotTo(HaveOccurred()) + Expect(voteErr).NotTo(HaveOccurred()) + + Expect(updatedParams.MinFundingAmount).To(Equal(uint64(100_000_000))) + Expect(updatedParams.MinFundingAmountPerBundle).To(Equal(types.DefaultMinFundingAmountPerBundle)) + Expect(updatedParams.MinFundingMultiple).To(Equal(types.DefaultMinFundingMultiple)) + }) + + It("Update min-funding-amount with invalid value", func() { + // ARRANGE + payload := `{ + "min_funding_amount": "invalid" + }` + + msg := &types.MsgUpdateParams{ + Authority: gov, + Payload: payload, + } + + proposal, _ := govV1Types.NewMsgSubmitProposal( + []sdk.Msg{msg}, minDeposit, i.DUMMY[0], "", "title", "summary", + ) + + // ACT + _, submitErr := s.RunTx(proposal) + + s.CommitAfter(*votingPeriod) + s.Commit() + + // ASSERT + updatedParams := s.App().FundersKeeper.GetParams(s.Ctx()) + + Expect(submitErr).To(HaveOccurred()) + + Expect(updatedParams.MinFundingAmount).To(Equal(types.DefaultMinFundingAmount)) + Expect(updatedParams.MinFundingAmountPerBundle).To(Equal(types.DefaultMinFundingAmountPerBundle)) + Expect(updatedParams.MinFundingMultiple).To(Equal(types.DefaultMinFundingMultiple)) + }) + + It("min-funding-amount-per-bundle", func() { + // ARRANGE + payload := `{ + "min_funding_amount_per_bundle": 300000 + }` + + msg := &types.MsgUpdateParams{ + Authority: gov, + Payload: payload, + } + + proposal, _ := govV1Types.NewMsgSubmitProposal( + []sdk.Msg{msg}, minDeposit, i.DUMMY[0], "", "title", "summary", + ) + + vote := govV1Types.NewMsgVote( + voter, 1, govV1Types.VoteOption_VOTE_OPTION_YES, "", + ) + + // ACT + _, submitErr := s.RunTx(proposal) + _, voteErr := s.RunTx(vote) + + s.CommitAfter(*votingPeriod) + s.Commit() + + // ASSERT + updatedParams := s.App().FundersKeeper.GetParams(s.Ctx()) + + Expect(submitErr).NotTo(HaveOccurred()) + Expect(voteErr).NotTo(HaveOccurred()) + + Expect(updatedParams.MinFundingAmount).To(Equal(types.DefaultMinFundingAmount)) + Expect(updatedParams.MinFundingAmountPerBundle).To(Equal(uint64(300000))) + Expect(updatedParams.MinFundingMultiple).To(Equal(types.DefaultMinFundingMultiple)) + }) + + It("Update min-funding-amount-per-bundle", func() { + // ARRANGE + payload := `{ + "min_funding_amount_per_bundle": "invalid" + }` + + msg := &types.MsgUpdateParams{ + Authority: gov, + Payload: payload, + } + + proposal, _ := govV1Types.NewMsgSubmitProposal( + []sdk.Msg{msg}, minDeposit, i.DUMMY[0], "", "title", "summary", + ) + + // ACT + _, submitErr := s.RunTx(proposal) + + s.CommitAfter(*votingPeriod) + s.Commit() + + // ASSERT + updatedParams := s.App().FundersKeeper.GetParams(s.Ctx()) + + Expect(submitErr).To(HaveOccurred()) + + Expect(updatedParams.MinFundingAmount).To(Equal(types.DefaultMinFundingAmount)) + Expect(updatedParams.MinFundingAmountPerBundle).To(Equal(types.DefaultMinFundingAmountPerBundle)) + Expect(updatedParams.MinFundingMultiple).To(Equal(types.DefaultMinFundingMultiple)) + }) + + It("Update min-funding-multiple", func() { + // ARRANGE + payload := `{ + "min_funding_multiple": 9 + }` + + msg := &types.MsgUpdateParams{ + Authority: gov, + Payload: payload, + } + + proposal, _ := govV1Types.NewMsgSubmitProposal( + []sdk.Msg{msg}, minDeposit, i.DUMMY[0], "", "title", "summary", + ) + + vote := govV1Types.NewMsgVote( + voter, 1, govV1Types.VoteOption_VOTE_OPTION_YES, "", + ) + + // ACT + _, submitErr := s.RunTx(proposal) + _, voteErr := s.RunTx(vote) + + s.CommitAfter(*votingPeriod) + s.Commit() + + // ASSERT + updatedParams := s.App().FundersKeeper.GetParams(s.Ctx()) + + Expect(submitErr).NotTo(HaveOccurred()) + Expect(voteErr).NotTo(HaveOccurred()) + + Expect(updatedParams.MinFundingAmount).To(Equal(types.DefaultMinFundingAmount)) + Expect(updatedParams.MinFundingAmountPerBundle).To(Equal(types.DefaultMinFundingAmountPerBundle)) + Expect(updatedParams.MinFundingMultiple).To(Equal(uint64(9))) + }) + + It("Update min-funding-multiple with invalid value", func() { + // ARRANGE + payload := `{ + "min_funding_multiple": -1 + }` + + msg := &types.MsgUpdateParams{ + Authority: gov, + Payload: payload, + } + + proposal, _ := govV1Types.NewMsgSubmitProposal( + []sdk.Msg{msg}, minDeposit, i.DUMMY[0], "", "title", "summary", + ) + + // ACT + _, submitErr := s.RunTx(proposal) + + s.CommitAfter(*votingPeriod) + s.Commit() + + // ASSERT + updatedParams := s.App().FundersKeeper.GetParams(s.Ctx()) + + Expect(submitErr).To(HaveOccurred()) + + Expect(updatedParams.MinFundingAmount).To(Equal(types.DefaultMinFundingAmount)) + Expect(updatedParams.MinFundingAmountPerBundle).To(Equal(types.DefaultMinFundingAmountPerBundle)) + Expect(updatedParams.MinFundingMultiple).To(Equal(types.DefaultMinFundingMultiple)) + }) +}) diff --git a/x/funders/keeper/query.go b/x/funders/keeper/query.go new file mode 100644 index 00000000..e031fbbe --- /dev/null +++ b/x/funders/keeper/query.go @@ -0,0 +1,7 @@ +package keeper + +import ( + "github.com/KYVENetwork/chain/x/funders/types" +) + +var _ types.QueryServer = Keeper{} diff --git a/x/funders/keeper/query_params.go b/x/funders/keeper/query_params.go new file mode 100644 index 00000000..3a937d2d --- /dev/null +++ b/x/funders/keeper/query_params.go @@ -0,0 +1,19 @@ +package keeper + +import ( + "context" + + "github.com/KYVENetwork/chain/x/funders/types" + sdk "github.com/cosmos/cosmos-sdk/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/funders/module.go b/x/funders/module.go new file mode 100644 index 00000000..87f5b484 --- /dev/null +++ b/x/funders/module.go @@ -0,0 +1,151 @@ +package funders + +import ( + "context" + "encoding/json" + "fmt" + + "github.com/KYVENetwork/chain/util" + + // this line is used by starport scaffolding # 1 + + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/spf13/cobra" + + abci "github.com/cometbft/cometbft/abci/types" + + "github.com/KYVENetwork/chain/x/funders/client/cli" + "github.com/KYVENetwork/chain/x/funders/keeper" + "github.com/KYVENetwork/chain/x/funders/types" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/codec" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" +) + +var ( + _ module.AppModule = AppModule{} + _ module.AppModuleBasic = AppModuleBasic{} +) + +// ---------------------------------------------------------------------------- +// AppModuleBasic +// ---------------------------------------------------------------------------- + +// AppModuleBasic implements the AppModuleBasic interface that defines the independent methods a Cosmos SDK module needs to implement. +type AppModuleBasic struct { + cdc codec.BinaryCodec +} + +func NewAppModuleBasic(cdc codec.BinaryCodec) AppModuleBasic { + return AppModuleBasic{cdc: cdc} +} + +// Name returns the name of the module as a string +func (AppModuleBasic) Name() string { + return types.ModuleName +} + +// RegisterLegacyAminoCodec registers the amino codec for the module, which is used to marshal and unmarshal structs to/from []byte in order to persist them in the module's KVStore +func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + types.RegisterCodec(cdc) +} + +// RegisterInterfaces registers a module's interface types and their concrete implementations as proto.Message +func (a AppModuleBasic) RegisterInterfaces(reg cdctypes.InterfaceRegistry) { + types.RegisterInterfaces(reg) +} + +// DefaultGenesis returns a default GenesisState for the module, marshalled to json.RawMessage. The default GenesisState need to be defined by the module developer and is primarily used for testing +func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { + return cdc.MustMarshalJSON(types.DefaultGenesis()) +} + +// ValidateGenesis used to validate the GenesisState, given in its json.RawMessage form +func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, bz json.RawMessage) error { + var genState types.GenesisState + if err := cdc.UnmarshalJSON(bz, &genState); err != nil { + return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err) + } + return genState.Validate() +} + +// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module +func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { + _ = types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) +} + +// GetTxCmd returns the root Tx command for the module. The subcommands of this root command are used by end-users to generate new transactions containing messages defined in the module +func (a AppModuleBasic) GetTxCmd() *cobra.Command { + return cli.GetTxCmd() +} + +// GetQueryCmd returns the root query command for the module. The subcommands of this root command are used by end-users to generate new queries to the subset of the state defined by the module +func (AppModuleBasic) GetQueryCmd() *cobra.Command { + return cli.GetQueryCmd(types.StoreKey) +} + +// ---------------------------------------------------------------------------- +// AppModule +// ---------------------------------------------------------------------------- + +// AppModule implements the AppModule interface that defines the inter-dependent methods that modules need to implement +type AppModule struct { + AppModuleBasic + + keeper keeper.Keeper + accountKeeper util.AccountKeeper + bankKeeper util.BankKeeper +} + +func NewAppModule( + cdc codec.Codec, + keeper keeper.Keeper, + accountKeeper util.AccountKeeper, + bankKeeper util.BankKeeper, +) AppModule { + return AppModule{ + AppModuleBasic: NewAppModuleBasic(cdc), + keeper: keeper, + accountKeeper: accountKeeper, + bankKeeper: bankKeeper, + } +} + +// RegisterServices registers a gRPC query service to respond to the module-specific gRPC queries +func (am AppModule) RegisterServices(cfg module.Configurator) { + types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) + types.RegisterQueryServer(cfg.QueryServer(), am.keeper) +} + +// RegisterInvariants registers the invariants of the module. If an invariant deviates from its predicted value, the InvariantRegistry triggers appropriate logic (most often the chain will be halted) +func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} + +// InitGenesis performs the module's genesis initialization. It returns no validator updates. +func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, gs json.RawMessage) []abci.ValidatorUpdate { + var genState types.GenesisState + // Initialize global index to index in genesis state + cdc.MustUnmarshalJSON(gs, &genState) + + InitGenesis(ctx, am.keeper, genState) + + return []abci.ValidatorUpdate{} +} + +// ExportGenesis returns the module's exported genesis state as raw JSON bytes. +func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { + genState := ExportGenesis(ctx, am.keeper) + return cdc.MustMarshalJSON(genState) +} + +// ConsensusVersion is a sequence number for state-breaking change of the module. It should be incremented on each consensus-breaking change introduced by the module. To avoid wrong/empty versions, the initial version should be set to 1 +func (AppModule) ConsensusVersion() uint64 { return 1 } + +// BeginBlock contains the logic that is automatically triggered at the beginning of each block +func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {} + +// EndBlock contains the logic that is automatically triggered at the end of each block +func (am AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { + return []abci.ValidatorUpdate{} +} diff --git a/x/funders/types/codec.go b/x/funders/types/codec.go new file mode 100644 index 00000000..844157a8 --- /dev/null +++ b/x/funders/types/codec.go @@ -0,0 +1,23 @@ +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 + "github.com/cosmos/cosmos-sdk/types/msgservice" +) + +func RegisterCodec(cdc *codec.LegacyAmino) { + // this line is used by starport scaffolding # 2 +} + +func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { + // this line is used by starport scaffolding # 3 + + msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) +} + +var ( + Amino = codec.NewLegacyAmino() + ModuleCdc = codec.NewProtoCodec(cdctypes.NewInterfaceRegistry()) +) diff --git a/x/funders/types/errors.go b/x/funders/types/errors.go new file mode 100644 index 00000000..d37bfe95 --- /dev/null +++ b/x/funders/types/errors.go @@ -0,0 +1,18 @@ +package types + +import ( + "cosmossdk.io/errors" +) + +// x/funders module sentinel errors +var ( + ErrFunderAlreadyExists = errors.Register(ModuleName, 1100, "funder with address %v already exists") + ErrFunderDoesNotExist = errors.Register(ModuleName, 1101, "funder with address %v does not exist") + ErrFundsTooLow = errors.Register(ModuleName, 1102, "minimum funding amount of %vkyve not reached") + ErrAmountPerBundleTooLow = errors.Register(ModuleName, 1103, "minimum amount per bundle of %vkyve not reached") + ErrMinFundingAmount = errors.Register(ModuleName, 1104, "minimum funding amount of %vkyve not reached") + ErrFundingDoesNotExist = errors.Register(ModuleName, 1105, "funding for pool %v and funder %v does not exist") + ErrFundingIsUsedUp = errors.Register(ModuleName, 1106, "funding for pool %v and funder %v is used up") + ErrFundingStateDoesNotExist = errors.Register(ModuleName, 1107, "funding state for pool %v does not exist") + ErrMinFundingMultiple = errors.Register(ModuleName, 1108, "per_bundle_amount (%dkyve) times min_funding_multiple (%d) is smaller than funded_amount (%vkyve)") +) diff --git a/x/funders/types/events.pb.go b/x/funders/types/events.pb.go new file mode 100644 index 00000000..d88c886d --- /dev/null +++ b/x/funders/types/events.pb.go @@ -0,0 +1,1994 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: kyve/funders/v1beta1/events.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// EventUpdateParams is an event emitted when the module parameters are updated. +// emitted_by: MsgUpdateParams +type EventUpdateParams struct { + // old_params is the module's old parameters. + OldParams Params `protobuf:"bytes,1,opt,name=old_params,json=oldParams,proto3" json:"old_params"` + // new_params is the module's new parameters. + NewParams Params `protobuf:"bytes,2,opt,name=new_params,json=newParams,proto3" json:"new_params"` + // payload is the parameter updates that were performed. + Payload string `protobuf:"bytes,3,opt,name=payload,proto3" json:"payload,omitempty"` +} + +func (m *EventUpdateParams) Reset() { *m = EventUpdateParams{} } +func (m *EventUpdateParams) String() string { return proto.CompactTextString(m) } +func (*EventUpdateParams) ProtoMessage() {} +func (*EventUpdateParams) Descriptor() ([]byte, []int) { + return fileDescriptor_1cf957abd56bbcb0, []int{0} +} +func (m *EventUpdateParams) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EventUpdateParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EventUpdateParams.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 *EventUpdateParams) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventUpdateParams.Merge(m, src) +} +func (m *EventUpdateParams) XXX_Size() int { + return m.Size() +} +func (m *EventUpdateParams) XXX_DiscardUnknown() { + xxx_messageInfo_EventUpdateParams.DiscardUnknown(m) +} + +var xxx_messageInfo_EventUpdateParams proto.InternalMessageInfo + +func (m *EventUpdateParams) GetOldParams() Params { + if m != nil { + return m.OldParams + } + return Params{} +} + +func (m *EventUpdateParams) GetNewParams() Params { + if m != nil { + return m.NewParams + } + return Params{} +} + +func (m *EventUpdateParams) GetPayload() string { + if m != nil { + return m.Payload + } + return "" +} + +// EventCreateFunder is an event emitted when a funder is created. +// emitted_by: MsgCreateFunder +type EventCreateFunder struct { + // address is the account address of the funder. + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + // moniker ... + Moniker string `protobuf:"bytes,2,opt,name=moniker,proto3" json:"moniker,omitempty"` + // identity is the 64 bit keybase.io identity string + Identity string `protobuf:"bytes,3,opt,name=identity,proto3" json:"identity,omitempty"` + // website ... + Website string `protobuf:"bytes,4,opt,name=website,proto3" json:"website,omitempty"` + // contact ... + Contact string `protobuf:"bytes,5,opt,name=contact,proto3" json:"contact,omitempty"` + // description are some additional notes the funder finds important + Description string `protobuf:"bytes,6,opt,name=description,proto3" json:"description,omitempty"` +} + +func (m *EventCreateFunder) Reset() { *m = EventCreateFunder{} } +func (m *EventCreateFunder) String() string { return proto.CompactTextString(m) } +func (*EventCreateFunder) ProtoMessage() {} +func (*EventCreateFunder) Descriptor() ([]byte, []int) { + return fileDescriptor_1cf957abd56bbcb0, []int{1} +} +func (m *EventCreateFunder) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EventCreateFunder) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EventCreateFunder.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 *EventCreateFunder) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventCreateFunder.Merge(m, src) +} +func (m *EventCreateFunder) XXX_Size() int { + return m.Size() +} +func (m *EventCreateFunder) XXX_DiscardUnknown() { + xxx_messageInfo_EventCreateFunder.DiscardUnknown(m) +} + +var xxx_messageInfo_EventCreateFunder proto.InternalMessageInfo + +func (m *EventCreateFunder) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +func (m *EventCreateFunder) GetMoniker() string { + if m != nil { + return m.Moniker + } + return "" +} + +func (m *EventCreateFunder) GetIdentity() string { + if m != nil { + return m.Identity + } + return "" +} + +func (m *EventCreateFunder) GetWebsite() string { + if m != nil { + return m.Website + } + return "" +} + +func (m *EventCreateFunder) GetContact() string { + if m != nil { + return m.Contact + } + return "" +} + +func (m *EventCreateFunder) GetDescription() string { + if m != nil { + return m.Description + } + return "" +} + +// EventUpdateFunder is an event emitted when a funder is created. +// emitted_by: MsgCreateFunder +type EventUpdateFunder struct { + // address is the account address of the funder. + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + // moniker ... + Moniker string `protobuf:"bytes,2,opt,name=moniker,proto3" json:"moniker,omitempty"` + // identity is the 64 bit keybase.io identity string + Identity string `protobuf:"bytes,3,opt,name=identity,proto3" json:"identity,omitempty"` + // website ... + Website string `protobuf:"bytes,4,opt,name=website,proto3" json:"website,omitempty"` + // contact ... + Contact string `protobuf:"bytes,5,opt,name=contact,proto3" json:"contact,omitempty"` + // description are some additional notes the funder finds important + Description string `protobuf:"bytes,6,opt,name=description,proto3" json:"description,omitempty"` +} + +func (m *EventUpdateFunder) Reset() { *m = EventUpdateFunder{} } +func (m *EventUpdateFunder) String() string { return proto.CompactTextString(m) } +func (*EventUpdateFunder) ProtoMessage() {} +func (*EventUpdateFunder) Descriptor() ([]byte, []int) { + return fileDescriptor_1cf957abd56bbcb0, []int{2} +} +func (m *EventUpdateFunder) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EventUpdateFunder) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EventUpdateFunder.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 *EventUpdateFunder) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventUpdateFunder.Merge(m, src) +} +func (m *EventUpdateFunder) XXX_Size() int { + return m.Size() +} +func (m *EventUpdateFunder) XXX_DiscardUnknown() { + xxx_messageInfo_EventUpdateFunder.DiscardUnknown(m) +} + +var xxx_messageInfo_EventUpdateFunder proto.InternalMessageInfo + +func (m *EventUpdateFunder) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +func (m *EventUpdateFunder) GetMoniker() string { + if m != nil { + return m.Moniker + } + return "" +} + +func (m *EventUpdateFunder) GetIdentity() string { + if m != nil { + return m.Identity + } + return "" +} + +func (m *EventUpdateFunder) GetWebsite() string { + if m != nil { + return m.Website + } + return "" +} + +func (m *EventUpdateFunder) GetContact() string { + if m != nil { + return m.Contact + } + return "" +} + +func (m *EventUpdateFunder) GetDescription() string { + if m != nil { + return m.Description + } + return "" +} + +// EventFundPool is an event emitted when a pool is funded. +// emitted_by: MsgFundPool +type EventFundPool struct { + // pool_id is the unique ID of the pool. + PoolId uint64 `protobuf:"varint,1,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty"` + // address is the account address of the pool funder. + Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"` + // amount is the amount in ukyve the funder has funded + Amount uint64 `protobuf:"varint,3,opt,name=amount,proto3" json:"amount,omitempty"` + // amount_per_bundle is the amount in ukyve the funder has funded per bundle + AmountPerBundle uint64 `protobuf:"varint,4,opt,name=amount_per_bundle,json=amountPerBundle,proto3" json:"amount_per_bundle,omitempty"` +} + +func (m *EventFundPool) Reset() { *m = EventFundPool{} } +func (m *EventFundPool) String() string { return proto.CompactTextString(m) } +func (*EventFundPool) ProtoMessage() {} +func (*EventFundPool) Descriptor() ([]byte, []int) { + return fileDescriptor_1cf957abd56bbcb0, []int{3} +} +func (m *EventFundPool) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EventFundPool) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EventFundPool.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 *EventFundPool) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventFundPool.Merge(m, src) +} +func (m *EventFundPool) XXX_Size() int { + return m.Size() +} +func (m *EventFundPool) XXX_DiscardUnknown() { + xxx_messageInfo_EventFundPool.DiscardUnknown(m) +} + +var xxx_messageInfo_EventFundPool proto.InternalMessageInfo + +func (m *EventFundPool) GetPoolId() uint64 { + if m != nil { + return m.PoolId + } + return 0 +} + +func (m *EventFundPool) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +func (m *EventFundPool) GetAmount() uint64 { + if m != nil { + return m.Amount + } + return 0 +} + +func (m *EventFundPool) GetAmountPerBundle() uint64 { + if m != nil { + return m.AmountPerBundle + } + return 0 +} + +// EventDefundPool is an event emitted when a pool is defunded. +// emitted_by: MsgDefundPool +type EventDefundPool struct { + // pool_id is the unique ID of the pool. + PoolId uint64 `protobuf:"varint,1,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty"` + // address is the account address of the pool funder. + Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"` + // amount is the amount in ukyve the funder has defunded + Amount uint64 `protobuf:"varint,3,opt,name=amount,proto3" json:"amount,omitempty"` +} + +func (m *EventDefundPool) Reset() { *m = EventDefundPool{} } +func (m *EventDefundPool) String() string { return proto.CompactTextString(m) } +func (*EventDefundPool) ProtoMessage() {} +func (*EventDefundPool) Descriptor() ([]byte, []int) { + return fileDescriptor_1cf957abd56bbcb0, []int{4} +} +func (m *EventDefundPool) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EventDefundPool) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EventDefundPool.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 *EventDefundPool) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventDefundPool.Merge(m, src) +} +func (m *EventDefundPool) XXX_Size() int { + return m.Size() +} +func (m *EventDefundPool) XXX_DiscardUnknown() { + xxx_messageInfo_EventDefundPool.DiscardUnknown(m) +} + +var xxx_messageInfo_EventDefundPool proto.InternalMessageInfo + +func (m *EventDefundPool) GetPoolId() uint64 { + if m != nil { + return m.PoolId + } + return 0 +} + +func (m *EventDefundPool) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +func (m *EventDefundPool) GetAmount() uint64 { + if m != nil { + return m.Amount + } + return 0 +} + +// EventPoolOutOfFunds is an event emitted when a pool has run out of funds +// emitted_by: MsgSubmitBundleProposal +type EventPoolOutOfFunds struct { + // pool_id is the unique ID of the pool. + PoolId uint64 `protobuf:"varint,1,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty"` +} + +func (m *EventPoolOutOfFunds) Reset() { *m = EventPoolOutOfFunds{} } +func (m *EventPoolOutOfFunds) String() string { return proto.CompactTextString(m) } +func (*EventPoolOutOfFunds) ProtoMessage() {} +func (*EventPoolOutOfFunds) Descriptor() ([]byte, []int) { + return fileDescriptor_1cf957abd56bbcb0, []int{5} +} +func (m *EventPoolOutOfFunds) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EventPoolOutOfFunds) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EventPoolOutOfFunds.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 *EventPoolOutOfFunds) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventPoolOutOfFunds.Merge(m, src) +} +func (m *EventPoolOutOfFunds) XXX_Size() int { + return m.Size() +} +func (m *EventPoolOutOfFunds) XXX_DiscardUnknown() { + xxx_messageInfo_EventPoolOutOfFunds.DiscardUnknown(m) +} + +var xxx_messageInfo_EventPoolOutOfFunds proto.InternalMessageInfo + +func (m *EventPoolOutOfFunds) GetPoolId() uint64 { + if m != nil { + return m.PoolId + } + return 0 +} + +func init() { + proto.RegisterType((*EventUpdateParams)(nil), "kyve.funders.v1beta1.EventUpdateParams") + proto.RegisterType((*EventCreateFunder)(nil), "kyve.funders.v1beta1.EventCreateFunder") + proto.RegisterType((*EventUpdateFunder)(nil), "kyve.funders.v1beta1.EventUpdateFunder") + proto.RegisterType((*EventFundPool)(nil), "kyve.funders.v1beta1.EventFundPool") + proto.RegisterType((*EventDefundPool)(nil), "kyve.funders.v1beta1.EventDefundPool") + proto.RegisterType((*EventPoolOutOfFunds)(nil), "kyve.funders.v1beta1.EventPoolOutOfFunds") +} + +func init() { proto.RegisterFile("kyve/funders/v1beta1/events.proto", fileDescriptor_1cf957abd56bbcb0) } + +var fileDescriptor_1cf957abd56bbcb0 = []byte{ + // 460 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x93, 0x4f, 0x6b, 0xd4, 0x40, + 0x18, 0xc6, 0x37, 0x35, 0x6e, 0xdd, 0x29, 0x52, 0x1a, 0x8b, 0x86, 0x45, 0xe2, 0xba, 0xa7, 0x22, + 0x92, 0x50, 0xfd, 0x04, 0xae, 0xb6, 0x20, 0x82, 0x5d, 0x02, 0x0a, 0x8a, 0xb0, 0x4c, 0x32, 0xef, + 0x6e, 0x87, 0xcd, 0xce, 0x1b, 0x26, 0x93, 0x5d, 0xf3, 0x05, 0x3c, 0xfb, 0x5d, 0x3c, 0xf9, 0x0d, + 0x7a, 0xec, 0xd1, 0x93, 0xc8, 0xee, 0x17, 0x91, 0xf9, 0x93, 0xb6, 0x42, 0x05, 0x0f, 0x5e, 0x7a, + 0xcb, 0x33, 0xcf, 0x33, 0xcf, 0xfb, 0x7b, 0x03, 0x43, 0x1e, 0xcf, 0x9b, 0x25, 0x24, 0xd3, 0x5a, + 0x30, 0x90, 0x55, 0xb2, 0x3c, 0xcc, 0x40, 0xd1, 0xc3, 0x04, 0x96, 0x20, 0x54, 0x15, 0x97, 0x12, + 0x15, 0x06, 0xfb, 0x3a, 0x12, 0xbb, 0x48, 0xec, 0x22, 0xfd, 0xfd, 0x19, 0xce, 0xd0, 0x04, 0x12, + 0xfd, 0x65, 0xb3, 0xfd, 0xeb, 0xeb, 0x4a, 0x2a, 0xe9, 0xc2, 0xd5, 0x0d, 0xbf, 0x79, 0x64, 0xef, + 0x48, 0xf7, 0xbf, 0x2b, 0x19, 0x55, 0x30, 0x36, 0x5e, 0xf0, 0x82, 0x10, 0x2c, 0xd8, 0xc4, 0x26, + 0x43, 0x6f, 0xe0, 0x1d, 0xec, 0x3c, 0x7b, 0x18, 0x5f, 0x37, 0x39, 0xb6, 0x37, 0x46, 0xfe, 0xd9, + 0xcf, 0x47, 0x9d, 0xb4, 0x87, 0x05, 0xbb, 0xac, 0x10, 0xb0, 0x6a, 0x2b, 0xb6, 0xfe, 0xbd, 0x42, + 0xc0, 0xca, 0x55, 0x84, 0x64, 0xbb, 0xa4, 0x4d, 0x81, 0x94, 0x85, 0xb7, 0x06, 0xde, 0x41, 0x2f, + 0x6d, 0xe5, 0xf0, 0x7b, 0x4b, 0xfd, 0x52, 0x02, 0x55, 0x70, 0x6c, 0x0a, 0x75, 0x9e, 0x32, 0x26, + 0xa1, 0xb2, 0xc8, 0xbd, 0xb4, 0x95, 0xda, 0x59, 0xa0, 0xe0, 0x73, 0x90, 0x86, 0xa4, 0x97, 0xb6, + 0x32, 0xe8, 0x93, 0x3b, 0x9c, 0x81, 0x50, 0x5c, 0x35, 0x6e, 0xc8, 0x85, 0xd6, 0xb7, 0x56, 0x90, + 0x55, 0x5c, 0x41, 0xe8, 0xdb, 0x5b, 0x4e, 0x6a, 0x27, 0x47, 0xa1, 0x68, 0xae, 0xc2, 0xdb, 0xd6, + 0x71, 0x32, 0x18, 0x90, 0x1d, 0x06, 0x55, 0x2e, 0x79, 0xa9, 0x38, 0x8a, 0xb0, 0x6b, 0xdc, 0xab, + 0x47, 0x97, 0xec, 0xf6, 0x8f, 0xdf, 0x28, 0xf6, 0x2f, 0x1e, 0xb9, 0x6b, 0xd8, 0x35, 0xf5, 0x18, + 0xb1, 0x08, 0x1e, 0x90, 0xed, 0x12, 0xb1, 0x98, 0x70, 0x66, 0xb8, 0xfd, 0xb4, 0xab, 0xe5, 0x6b, + 0x76, 0x75, 0xa1, 0xad, 0x3f, 0x17, 0xba, 0x4f, 0xba, 0x74, 0x81, 0xb5, 0x50, 0x06, 0xda, 0x4f, + 0x9d, 0x0a, 0x9e, 0x90, 0x3d, 0xfb, 0x35, 0x29, 0x41, 0x4e, 0xb2, 0x5a, 0xb0, 0xc2, 0xc2, 0xfb, + 0xe9, 0xae, 0x35, 0xc6, 0x20, 0x47, 0xe6, 0x78, 0xf8, 0x89, 0xec, 0x1a, 0x8e, 0x57, 0x30, 0xfd, + 0xff, 0x24, 0xc3, 0x98, 0xdc, 0x33, 0xed, 0xba, 0xf7, 0xa4, 0x56, 0x27, 0x53, 0xbd, 0x6e, 0xf5, + 0xd7, 0x09, 0xa3, 0xe3, 0xb3, 0x75, 0xe4, 0x9d, 0xaf, 0x23, 0xef, 0xd7, 0x3a, 0xf2, 0xbe, 0x6e, + 0xa2, 0xce, 0xf9, 0x26, 0xea, 0xfc, 0xd8, 0x44, 0x9d, 0x8f, 0x4f, 0x67, 0x5c, 0x9d, 0xd6, 0x59, + 0x9c, 0xe3, 0x22, 0x79, 0xf3, 0xe1, 0xfd, 0xd1, 0x5b, 0x50, 0x2b, 0x94, 0xf3, 0x24, 0x3f, 0xa5, + 0x5c, 0x24, 0x9f, 0x2f, 0xde, 0xa6, 0x6a, 0x4a, 0xa8, 0xb2, 0xae, 0x79, 0x93, 0xcf, 0x7f, 0x07, + 0x00, 0x00, 0xff, 0xff, 0xfe, 0x83, 0x31, 0xec, 0x07, 0x04, 0x00, 0x00, +} + +func (m *EventUpdateParams) 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 *EventUpdateParams) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventUpdateParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Payload) > 0 { + i -= len(m.Payload) + copy(dAtA[i:], m.Payload) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Payload))) + i-- + dAtA[i] = 0x1a + } + { + size, err := m.NewParams.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintEvents(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + { + size, err := m.OldParams.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintEvents(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *EventCreateFunder) 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 *EventCreateFunder) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventCreateFunder) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Description) > 0 { + i -= len(m.Description) + copy(dAtA[i:], m.Description) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Description))) + i-- + dAtA[i] = 0x32 + } + if len(m.Contact) > 0 { + i -= len(m.Contact) + copy(dAtA[i:], m.Contact) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Contact))) + i-- + dAtA[i] = 0x2a + } + if len(m.Website) > 0 { + i -= len(m.Website) + copy(dAtA[i:], m.Website) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Website))) + i-- + dAtA[i] = 0x22 + } + if len(m.Identity) > 0 { + i -= len(m.Identity) + copy(dAtA[i:], m.Identity) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Identity))) + i-- + dAtA[i] = 0x1a + } + if len(m.Moniker) > 0 { + i -= len(m.Moniker) + copy(dAtA[i:], m.Moniker) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Moniker))) + i-- + dAtA[i] = 0x12 + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *EventUpdateFunder) 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 *EventUpdateFunder) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventUpdateFunder) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Description) > 0 { + i -= len(m.Description) + copy(dAtA[i:], m.Description) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Description))) + i-- + dAtA[i] = 0x32 + } + if len(m.Contact) > 0 { + i -= len(m.Contact) + copy(dAtA[i:], m.Contact) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Contact))) + i-- + dAtA[i] = 0x2a + } + if len(m.Website) > 0 { + i -= len(m.Website) + copy(dAtA[i:], m.Website) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Website))) + i-- + dAtA[i] = 0x22 + } + if len(m.Identity) > 0 { + i -= len(m.Identity) + copy(dAtA[i:], m.Identity) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Identity))) + i-- + dAtA[i] = 0x1a + } + if len(m.Moniker) > 0 { + i -= len(m.Moniker) + copy(dAtA[i:], m.Moniker) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Moniker))) + i-- + dAtA[i] = 0x12 + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *EventFundPool) 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 *EventFundPool) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventFundPool) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.AmountPerBundle != 0 { + i = encodeVarintEvents(dAtA, i, uint64(m.AmountPerBundle)) + i-- + dAtA[i] = 0x20 + } + if m.Amount != 0 { + i = encodeVarintEvents(dAtA, i, uint64(m.Amount)) + i-- + dAtA[i] = 0x18 + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0x12 + } + if m.PoolId != 0 { + i = encodeVarintEvents(dAtA, i, uint64(m.PoolId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *EventDefundPool) 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 *EventDefundPool) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventDefundPool) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Amount != 0 { + i = encodeVarintEvents(dAtA, i, uint64(m.Amount)) + i-- + dAtA[i] = 0x18 + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0x12 + } + if m.PoolId != 0 { + i = encodeVarintEvents(dAtA, i, uint64(m.PoolId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *EventPoolOutOfFunds) 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 *EventPoolOutOfFunds) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventPoolOutOfFunds) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.PoolId != 0 { + i = encodeVarintEvents(dAtA, i, uint64(m.PoolId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintEvents(dAtA []byte, offset int, v uint64) int { + offset -= sovEvents(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *EventUpdateParams) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.OldParams.Size() + n += 1 + l + sovEvents(uint64(l)) + l = m.NewParams.Size() + n += 1 + l + sovEvents(uint64(l)) + l = len(m.Payload) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + return n +} + +func (m *EventCreateFunder) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.Moniker) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.Identity) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.Website) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.Contact) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.Description) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + return n +} + +func (m *EventUpdateFunder) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.Moniker) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.Identity) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.Website) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.Contact) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.Description) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + return n +} + +func (m *EventFundPool) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PoolId != 0 { + n += 1 + sovEvents(uint64(m.PoolId)) + } + l = len(m.Address) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + if m.Amount != 0 { + n += 1 + sovEvents(uint64(m.Amount)) + } + if m.AmountPerBundle != 0 { + n += 1 + sovEvents(uint64(m.AmountPerBundle)) + } + return n +} + +func (m *EventDefundPool) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PoolId != 0 { + n += 1 + sovEvents(uint64(m.PoolId)) + } + l = len(m.Address) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + if m.Amount != 0 { + n += 1 + sovEvents(uint64(m.Amount)) + } + return n +} + +func (m *EventPoolOutOfFunds) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PoolId != 0 { + n += 1 + sovEvents(uint64(m.PoolId)) + } + return n +} + +func sovEvents(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozEvents(x uint64) (n int) { + return sovEvents(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *EventUpdateParams) 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 ErrIntOverflowEvents + } + 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: EventUpdateParams: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventUpdateParams: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OldParams", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthEvents + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.OldParams.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NewParams", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthEvents + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.NewParams.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Payload", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Payload = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipEvents(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvents + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *EventCreateFunder) 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 ErrIntOverflowEvents + } + 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: EventCreateFunder: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventCreateFunder: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Moniker", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Moniker = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Identity", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Identity = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Website", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Website = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Contact", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Contact = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Description = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipEvents(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvents + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *EventUpdateFunder) 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 ErrIntOverflowEvents + } + 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: EventUpdateFunder: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventUpdateFunder: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Moniker", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Moniker = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Identity", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Identity = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Website", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Website = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Contact", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Contact = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Description = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipEvents(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvents + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *EventFundPool) 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 ErrIntOverflowEvents + } + 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: EventFundPool: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventFundPool: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PoolId", wireType) + } + m.PoolId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PoolId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + m.Amount = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Amount |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field AmountPerBundle", wireType) + } + m.AmountPerBundle = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.AmountPerBundle |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipEvents(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvents + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *EventDefundPool) 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 ErrIntOverflowEvents + } + 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: EventDefundPool: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventDefundPool: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PoolId", wireType) + } + m.PoolId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PoolId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + m.Amount = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Amount |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipEvents(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvents + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *EventPoolOutOfFunds) 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 ErrIntOverflowEvents + } + 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: EventPoolOutOfFunds: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventPoolOutOfFunds: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PoolId", wireType) + } + m.PoolId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PoolId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipEvents(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvents + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipEvents(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, ErrIntOverflowEvents + } + 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, ErrIntOverflowEvents + } + 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, ErrIntOverflowEvents + } + 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, ErrInvalidLengthEvents + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupEvents + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthEvents + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthEvents = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowEvents = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupEvents = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/funders/types/expected_keepers.go b/x/funders/types/expected_keepers.go new file mode 100644 index 00000000..e4dacee0 --- /dev/null +++ b/x/funders/types/expected_keepers.go @@ -0,0 +1,15 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/auth/types" +) + +type AccountKeeper interface { + GetAccount(ctx sdk.Context, addr sdk.AccAddress) types.AccountI + SetAccount(ctx sdk.Context, acc types.AccountI) +} + +type PoolKeeper interface { + AssertPoolExists(ctx sdk.Context, poolId uint64) error +} diff --git a/x/funders/types/funders.go b/x/funders/types/funders.go new file mode 100644 index 00000000..906e258c --- /dev/null +++ b/x/funders/types/funders.go @@ -0,0 +1,49 @@ +package types + +func (f *Funding) AddAmount(amount uint64) { + f.Amount += amount +} + +func (f *Funding) SubtractAmount(amount uint64) (subtracted uint64) { + subtracted = amount + if f.Amount < amount { + subtracted = f.Amount + } + f.Amount -= subtracted + return subtracted +} + +func (f *Funding) ChargeOneBundle() (amount uint64) { + amount = f.SubtractAmount(f.AmountPerBundle) + f.TotalFunded += amount + return amount +} + +func (f *Funding) IsActive() (isActive bool) { + return f.Amount > 0 +} + +func (f *Funding) IsInactive() (isInactive bool) { + return !f.IsActive() +} + +// SetInactive removes a funding from active fundings +func (fs *FundingState) SetInactive(funding *Funding) { + for i, funderAddress := range fs.ActiveFunderAddresses { + if funderAddress == funding.FunderAddress { + fs.ActiveFunderAddresses[i] = fs.ActiveFunderAddresses[len(fs.ActiveFunderAddresses)-1] + fs.ActiveFunderAddresses = fs.ActiveFunderAddresses[:len(fs.ActiveFunderAddresses)-1] + break + } + } +} + +// SetActive adds a funding to active fundings +func (fs *FundingState) SetActive(funding *Funding) { + for _, funderAddress := range fs.ActiveFunderAddresses { + if funderAddress == funding.FunderAddress { + return + } + } + fs.ActiveFunderAddresses = append(fs.ActiveFunderAddresses, funding.FunderAddress) +} diff --git a/x/funders/types/funders.pb.go b/x/funders/types/funders.pb.go new file mode 100644 index 00000000..1748443e --- /dev/null +++ b/x/funders/types/funders.pb.go @@ -0,0 +1,1124 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: kyve/funders/v1beta1/funders.proto + +package types + +import ( + fmt "fmt" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// Funder is the object which holds info about a single pool funder +type Funder struct { + // address ... + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + // moniker ... + Moniker string `protobuf:"bytes,2,opt,name=moniker,proto3" json:"moniker,omitempty"` + // identity is the 64 bit keybase.io identity string + Identity string `protobuf:"bytes,3,opt,name=identity,proto3" json:"identity,omitempty"` + // website ... + Website string `protobuf:"bytes,4,opt,name=website,proto3" json:"website,omitempty"` + // contact ... + Contact string `protobuf:"bytes,5,opt,name=contact,proto3" json:"contact,omitempty"` + // description are some additional notes the funder finds important + Description string `protobuf:"bytes,6,opt,name=description,proto3" json:"description,omitempty"` +} + +func (m *Funder) Reset() { *m = Funder{} } +func (m *Funder) String() string { return proto.CompactTextString(m) } +func (*Funder) ProtoMessage() {} +func (*Funder) Descriptor() ([]byte, []int) { + return fileDescriptor_252d80f89b0fa299, []int{0} +} +func (m *Funder) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Funder) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Funder.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 *Funder) XXX_Merge(src proto.Message) { + xxx_messageInfo_Funder.Merge(m, src) +} +func (m *Funder) XXX_Size() int { + return m.Size() +} +func (m *Funder) XXX_DiscardUnknown() { + xxx_messageInfo_Funder.DiscardUnknown(m) +} + +var xxx_messageInfo_Funder proto.InternalMessageInfo + +func (m *Funder) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +func (m *Funder) GetMoniker() string { + if m != nil { + return m.Moniker + } + return "" +} + +func (m *Funder) GetIdentity() string { + if m != nil { + return m.Identity + } + return "" +} + +func (m *Funder) GetWebsite() string { + if m != nil { + return m.Website + } + return "" +} + +func (m *Funder) GetContact() string { + if m != nil { + return m.Contact + } + return "" +} + +func (m *Funder) GetDescription() string { + if m != nil { + return m.Description + } + return "" +} + +// Funding is the object which holds info about the current funding +// funder_address and pool_id (m2m) are unique together which means that +// a funder can only fund each pool once and a pool can only be funded +// by each funder once. However, a funder can update the amount of funds. +type Funding struct { + // funder_id is the id of the funder + FunderAddress string `protobuf:"bytes,1,opt,name=funder_address,json=funderAddress,proto3" json:"funder_address,omitempty"` + // pool_id is the id of the pool this funding is for + PoolId uint64 `protobuf:"varint,2,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty"` + // amount is the amount of funds in ukyve the funder has left + Amount uint64 `protobuf:"varint,3,opt,name=amount,proto3" json:"amount,omitempty"` + // amount_per_bundle is the amount of funds in ukyve the funder pays per bundle + AmountPerBundle uint64 `protobuf:"varint,4,opt,name=amount_per_bundle,json=amountPerBundle,proto3" json:"amount_per_bundle,omitempty"` + // total_funded is the total amount of funds in ukyve the funder has funded + TotalFunded uint64 `protobuf:"varint,5,opt,name=total_funded,json=totalFunded,proto3" json:"total_funded,omitempty"` +} + +func (m *Funding) Reset() { *m = Funding{} } +func (m *Funding) String() string { return proto.CompactTextString(m) } +func (*Funding) ProtoMessage() {} +func (*Funding) Descriptor() ([]byte, []int) { + return fileDescriptor_252d80f89b0fa299, []int{1} +} +func (m *Funding) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Funding) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Funding.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 *Funding) XXX_Merge(src proto.Message) { + xxx_messageInfo_Funding.Merge(m, src) +} +func (m *Funding) XXX_Size() int { + return m.Size() +} +func (m *Funding) XXX_DiscardUnknown() { + xxx_messageInfo_Funding.DiscardUnknown(m) +} + +var xxx_messageInfo_Funding proto.InternalMessageInfo + +func (m *Funding) GetFunderAddress() string { + if m != nil { + return m.FunderAddress + } + return "" +} + +func (m *Funding) GetPoolId() uint64 { + if m != nil { + return m.PoolId + } + return 0 +} + +func (m *Funding) GetAmount() uint64 { + if m != nil { + return m.Amount + } + return 0 +} + +func (m *Funding) GetAmountPerBundle() uint64 { + if m != nil { + return m.AmountPerBundle + } + return 0 +} + +func (m *Funding) GetTotalFunded() uint64 { + if m != nil { + return m.TotalFunded + } + return 0 +} + +// FundingState is the object which holds info about the funding state of a pool +type FundingState struct { + // pool_id is the id of the pool this funding is for + PoolId uint64 `protobuf:"varint,1,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty"` + // active_funder_addresses is the list of all active fundings + ActiveFunderAddresses []string `protobuf:"bytes,2,rep,name=active_funder_addresses,json=activeFunderAddresses,proto3" json:"active_funder_addresses,omitempty"` +} + +func (m *FundingState) Reset() { *m = FundingState{} } +func (m *FundingState) String() string { return proto.CompactTextString(m) } +func (*FundingState) ProtoMessage() {} +func (*FundingState) Descriptor() ([]byte, []int) { + return fileDescriptor_252d80f89b0fa299, []int{2} +} +func (m *FundingState) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *FundingState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_FundingState.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 *FundingState) XXX_Merge(src proto.Message) { + xxx_messageInfo_FundingState.Merge(m, src) +} +func (m *FundingState) XXX_Size() int { + return m.Size() +} +func (m *FundingState) XXX_DiscardUnknown() { + xxx_messageInfo_FundingState.DiscardUnknown(m) +} + +var xxx_messageInfo_FundingState proto.InternalMessageInfo + +func (m *FundingState) GetPoolId() uint64 { + if m != nil { + return m.PoolId + } + return 0 +} + +func (m *FundingState) GetActiveFunderAddresses() []string { + if m != nil { + return m.ActiveFunderAddresses + } + return nil +} + +func init() { + proto.RegisterType((*Funder)(nil), "kyve.funders.v1beta1.Funder") + proto.RegisterType((*Funding)(nil), "kyve.funders.v1beta1.Funding") + proto.RegisterType((*FundingState)(nil), "kyve.funders.v1beta1.FundingState") +} + +func init() { + proto.RegisterFile("kyve/funders/v1beta1/funders.proto", fileDescriptor_252d80f89b0fa299) +} + +var fileDescriptor_252d80f89b0fa299 = []byte{ + // 386 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x54, 0x92, 0xd1, 0x8a, 0xd3, 0x40, + 0x14, 0x86, 0x3b, 0xbb, 0x31, 0x75, 0x67, 0x57, 0xc5, 0x41, 0xdd, 0xc1, 0x8b, 0x50, 0x03, 0xc2, + 0x22, 0xd2, 0xb0, 0x08, 0xde, 0x5b, 0xb0, 0x20, 0x82, 0x48, 0x04, 0x41, 0x6f, 0xc2, 0x24, 0x73, + 0x6c, 0x87, 0xb6, 0x33, 0x61, 0xe6, 0xa4, 0xb5, 0x6f, 0xe1, 0x93, 0x88, 0x8f, 0xe1, 0x65, 0x2f, + 0xbd, 0x94, 0xf6, 0x45, 0x96, 0xcc, 0xa4, 0xa5, 0xbd, 0xcb, 0xff, 0xff, 0xe7, 0x90, 0xef, 0x1f, + 0x0e, 0x4d, 0x67, 0xeb, 0x25, 0x64, 0x3f, 0x1a, 0x2d, 0xc1, 0xba, 0x6c, 0x79, 0x5b, 0x02, 0x8a, + 0xdb, 0xbd, 0x1e, 0xd6, 0xd6, 0xa0, 0x61, 0x4f, 0xda, 0x99, 0xe1, 0xde, 0xeb, 0x66, 0xd2, 0xdf, + 0x84, 0xc6, 0x63, 0xef, 0x31, 0x4e, 0xfb, 0x42, 0x4a, 0x0b, 0xce, 0x71, 0x32, 0x20, 0x37, 0x17, + 0xf9, 0x5e, 0xb6, 0xc9, 0xc2, 0x68, 0x35, 0x03, 0xcb, 0xcf, 0x42, 0xd2, 0x49, 0xf6, 0x9c, 0xde, + 0x57, 0x12, 0x34, 0x2a, 0x5c, 0xf3, 0x73, 0x1f, 0x1d, 0x74, 0xbb, 0xb5, 0x82, 0xd2, 0x29, 0x04, + 0x1e, 0x85, 0xad, 0x4e, 0xb6, 0x49, 0x65, 0x34, 0x8a, 0x0a, 0xf9, 0xbd, 0x90, 0x74, 0x92, 0x0d, + 0xe8, 0xa5, 0x04, 0x57, 0x59, 0x55, 0xa3, 0x32, 0x9a, 0xc7, 0x3e, 0x3d, 0xb6, 0xd2, 0x3f, 0x84, + 0xf6, 0x5b, 0x60, 0xa5, 0x27, 0xec, 0x25, 0x7d, 0x18, 0xfa, 0x14, 0xa7, 0xe0, 0x0f, 0x82, 0xfb, + 0xae, 0xc3, 0xbf, 0xa6, 0xfd, 0xda, 0x98, 0x79, 0xa1, 0xa4, 0xc7, 0x8f, 0xf2, 0xb8, 0x95, 0x1f, + 0x24, 0x7b, 0x46, 0x63, 0xb1, 0x30, 0x8d, 0x46, 0xcf, 0x1e, 0xe5, 0x9d, 0x62, 0xaf, 0xe8, 0xe3, + 0xf0, 0x55, 0xd4, 0x60, 0x8b, 0xb2, 0xd1, 0x72, 0x1e, 0x3a, 0x44, 0xf9, 0xa3, 0x10, 0x7c, 0x06, + 0x3b, 0xf2, 0x36, 0x7b, 0x41, 0xaf, 0xd0, 0xa0, 0x98, 0x17, 0xfe, 0x9f, 0xd2, 0x17, 0x8a, 0xf2, + 0x4b, 0xef, 0xf9, 0x87, 0x95, 0x69, 0x41, 0xaf, 0x3a, 0xe2, 0x2f, 0x28, 0x10, 0x8e, 0x79, 0xc8, + 0x09, 0xcf, 0x5b, 0x7a, 0x2d, 0x2a, 0x54, 0x4b, 0x28, 0x4e, 0x6b, 0x81, 0xe3, 0x67, 0x83, 0xf3, + 0x9b, 0x8b, 0xfc, 0x69, 0x88, 0xc7, 0xc7, 0xf5, 0xc0, 0x8d, 0xc6, 0x7f, 0xb7, 0x09, 0xd9, 0x6c, + 0x13, 0xf2, 0x7f, 0x9b, 0x90, 0x5f, 0xbb, 0xa4, 0xb7, 0xd9, 0x25, 0xbd, 0x7f, 0xbb, 0xa4, 0xf7, + 0xfd, 0xf5, 0x44, 0xe1, 0xb4, 0x29, 0x87, 0x95, 0x59, 0x64, 0x1f, 0xbf, 0x7d, 0x7d, 0xff, 0x09, + 0x70, 0x65, 0xec, 0x2c, 0xab, 0xa6, 0x42, 0xe9, 0xec, 0xe7, 0xe1, 0x64, 0x70, 0x5d, 0x83, 0x2b, + 0x63, 0x7f, 0x29, 0x6f, 0xee, 0x02, 0x00, 0x00, 0xff, 0xff, 0xf6, 0x1c, 0xef, 0x4f, 0x4f, 0x02, + 0x00, 0x00, +} + +func (m *Funder) 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 *Funder) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Funder) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Description) > 0 { + i -= len(m.Description) + copy(dAtA[i:], m.Description) + i = encodeVarintFunders(dAtA, i, uint64(len(m.Description))) + i-- + dAtA[i] = 0x32 + } + if len(m.Contact) > 0 { + i -= len(m.Contact) + copy(dAtA[i:], m.Contact) + i = encodeVarintFunders(dAtA, i, uint64(len(m.Contact))) + i-- + dAtA[i] = 0x2a + } + if len(m.Website) > 0 { + i -= len(m.Website) + copy(dAtA[i:], m.Website) + i = encodeVarintFunders(dAtA, i, uint64(len(m.Website))) + i-- + dAtA[i] = 0x22 + } + if len(m.Identity) > 0 { + i -= len(m.Identity) + copy(dAtA[i:], m.Identity) + i = encodeVarintFunders(dAtA, i, uint64(len(m.Identity))) + i-- + dAtA[i] = 0x1a + } + if len(m.Moniker) > 0 { + i -= len(m.Moniker) + copy(dAtA[i:], m.Moniker) + i = encodeVarintFunders(dAtA, i, uint64(len(m.Moniker))) + i-- + dAtA[i] = 0x12 + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintFunders(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *Funding) 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 *Funding) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Funding) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.TotalFunded != 0 { + i = encodeVarintFunders(dAtA, i, uint64(m.TotalFunded)) + i-- + dAtA[i] = 0x28 + } + if m.AmountPerBundle != 0 { + i = encodeVarintFunders(dAtA, i, uint64(m.AmountPerBundle)) + i-- + dAtA[i] = 0x20 + } + if m.Amount != 0 { + i = encodeVarintFunders(dAtA, i, uint64(m.Amount)) + i-- + dAtA[i] = 0x18 + } + if m.PoolId != 0 { + i = encodeVarintFunders(dAtA, i, uint64(m.PoolId)) + i-- + dAtA[i] = 0x10 + } + if len(m.FunderAddress) > 0 { + i -= len(m.FunderAddress) + copy(dAtA[i:], m.FunderAddress) + i = encodeVarintFunders(dAtA, i, uint64(len(m.FunderAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *FundingState) 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 *FundingState) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *FundingState) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ActiveFunderAddresses) > 0 { + for iNdEx := len(m.ActiveFunderAddresses) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.ActiveFunderAddresses[iNdEx]) + copy(dAtA[i:], m.ActiveFunderAddresses[iNdEx]) + i = encodeVarintFunders(dAtA, i, uint64(len(m.ActiveFunderAddresses[iNdEx]))) + i-- + dAtA[i] = 0x12 + } + } + if m.PoolId != 0 { + i = encodeVarintFunders(dAtA, i, uint64(m.PoolId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintFunders(dAtA []byte, offset int, v uint64) int { + offset -= sovFunders(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Funder) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovFunders(uint64(l)) + } + l = len(m.Moniker) + if l > 0 { + n += 1 + l + sovFunders(uint64(l)) + } + l = len(m.Identity) + if l > 0 { + n += 1 + l + sovFunders(uint64(l)) + } + l = len(m.Website) + if l > 0 { + n += 1 + l + sovFunders(uint64(l)) + } + l = len(m.Contact) + if l > 0 { + n += 1 + l + sovFunders(uint64(l)) + } + l = len(m.Description) + if l > 0 { + n += 1 + l + sovFunders(uint64(l)) + } + return n +} + +func (m *Funding) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.FunderAddress) + if l > 0 { + n += 1 + l + sovFunders(uint64(l)) + } + if m.PoolId != 0 { + n += 1 + sovFunders(uint64(m.PoolId)) + } + if m.Amount != 0 { + n += 1 + sovFunders(uint64(m.Amount)) + } + if m.AmountPerBundle != 0 { + n += 1 + sovFunders(uint64(m.AmountPerBundle)) + } + if m.TotalFunded != 0 { + n += 1 + sovFunders(uint64(m.TotalFunded)) + } + return n +} + +func (m *FundingState) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PoolId != 0 { + n += 1 + sovFunders(uint64(m.PoolId)) + } + if len(m.ActiveFunderAddresses) > 0 { + for _, s := range m.ActiveFunderAddresses { + l = len(s) + n += 1 + l + sovFunders(uint64(l)) + } + } + return n +} + +func sovFunders(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozFunders(x uint64) (n int) { + return sovFunders(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Funder) 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 ErrIntOverflowFunders + } + 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: Funder: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Funder: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFunders + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthFunders + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthFunders + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Moniker", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFunders + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthFunders + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthFunders + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Moniker = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Identity", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFunders + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthFunders + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthFunders + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Identity = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Website", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFunders + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthFunders + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthFunders + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Website = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Contact", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFunders + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthFunders + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthFunders + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Contact = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFunders + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthFunders + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthFunders + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Description = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipFunders(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthFunders + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Funding) 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 ErrIntOverflowFunders + } + 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: Funding: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Funding: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FunderAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFunders + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthFunders + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthFunders + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.FunderAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PoolId", wireType) + } + m.PoolId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFunders + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PoolId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + m.Amount = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFunders + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Amount |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field AmountPerBundle", wireType) + } + m.AmountPerBundle = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFunders + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.AmountPerBundle |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field TotalFunded", wireType) + } + m.TotalFunded = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFunders + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.TotalFunded |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipFunders(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthFunders + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *FundingState) 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 ErrIntOverflowFunders + } + 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: FundingState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: FundingState: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PoolId", wireType) + } + m.PoolId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFunders + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PoolId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ActiveFunderAddresses", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFunders + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthFunders + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthFunders + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ActiveFunderAddresses = append(m.ActiveFunderAddresses, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipFunders(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthFunders + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipFunders(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, ErrIntOverflowFunders + } + 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, ErrIntOverflowFunders + } + 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, ErrIntOverflowFunders + } + 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, ErrInvalidLengthFunders + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupFunders + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthFunders + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthFunders = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowFunders = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupFunders = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/funders/types/funders_test.go b/x/funders/types/funders_test.go new file mode 100644 index 00000000..47763b61 --- /dev/null +++ b/x/funders/types/funders_test.go @@ -0,0 +1,139 @@ +package types_test + +import ( + i "github.com/KYVENetwork/chain/testutil/integration" + "github.com/KYVENetwork/chain/x/funders/types" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" +) + +/* + +TEST CASES - funders.go + +* Funding.AddAmount +* Funding.SubtractAmount +* Funding.SubtractAmount - subtract more than available +* Funding.ChargeOneBundle +* Funding.ChargeOneBundle - charge more than available +* FundintState.SetActive +* FundintState.SetActive - add same funder twice +* FundintState.SetInactive +* FundintState.SetInactive - with multiple funders + +*/ + +var _ = Describe("logic_funders.go", Ordered, func() { + funding := types.Funding{} + fundingState := types.FundingState{} + + BeforeEach(func() { + funding = types.Funding{ + FunderAddress: i.ALICE, + PoolId: 0, + Amount: 100 * i.KYVE, + AmountPerBundle: 1 * i.KYVE, + TotalFunded: 0, + } + fundingState = types.FundingState{ + PoolId: 0, + ActiveFunderAddresses: []string{i.ALICE, i.BOB}, + } + }) + + It("Funding.AddAmount", func() { + // ACT + funding.AddAmount(100 * i.KYVE) + + // ASSERT + Expect(funding.Amount).To(Equal(200 * i.KYVE)) + Expect(funding.TotalFunded).To(Equal(uint64(0))) + }) + + It("Funding.SubtractAmount", func() { + // ACT + funding.SubtractAmount(50 * i.KYVE) + + // ASSERT + Expect(funding.Amount).To(Equal(50 * i.KYVE)) + Expect(funding.TotalFunded).To(Equal(uint64(0))) + }) + + It("Funding.SubtractAmount - subtract more than available", func() { + // ACT + subtracted := funding.SubtractAmount(200 * i.KYVE) + + // ASSERT + Expect(subtracted).To(Equal(100 * i.KYVE)) + Expect(funding.Amount).To(Equal(uint64(0))) + }) + + It("Funding.ChargeOneBundle", func() { + // ACT + amount := funding.ChargeOneBundle() + + // ASSERT + Expect(amount).To(Equal(1 * i.KYVE)) + Expect(funding.Amount).To(Equal(99 * i.KYVE)) + Expect(funding.TotalFunded).To(Equal(1 * i.KYVE)) + }) + + It("Funding.ChargeOneBundle - charge more than available", func() { + // ARRANGE + funding.Amount = 1 * i.KYVE / 2 + + // ACT + amount := funding.ChargeOneBundle() + + // ASSERT + Expect(amount).To(Equal(1 * i.KYVE / 2)) + Expect(funding.Amount).To(Equal(uint64(0))) + Expect(funding.TotalFunded).To(Equal(1 * i.KYVE / 2)) + }) + + It("FundintState.SetActive", func() { + // ARRANGE + fundingState.ActiveFunderAddresses = []string{} + + // ACT + fundingState.SetActive(&funding) + + // ASSERT + Expect(fundingState.ActiveFunderAddresses).To(HaveLen(1)) + Expect(fundingState.ActiveFunderAddresses[0]).To(Equal(i.ALICE)) + }) + + It("FundintState.SetActive - add same funder twice", func() { + // ACT + Expect(fundingState.ActiveFunderAddresses).To(HaveLen(2)) + Expect(fundingState.ActiveFunderAddresses[0]).To(Equal(i.ALICE)) + + fundingState.SetActive(&funding) + + // ASSERT + Expect(fundingState.ActiveFunderAddresses).To(HaveLen(2)) + Expect(fundingState.ActiveFunderAddresses[0]).To(Equal(i.ALICE)) + }) + + It("FundintState.SetInactive", func() { + // ACT + Expect(fundingState.ActiveFunderAddresses[0]).To(Equal(i.ALICE)) + fundingState.SetInactive(&funding) + + // ASSERT + Expect(fundingState.ActiveFunderAddresses).To(HaveLen(1)) + }) + + It("FundintState.SetInactive - with multiple funders", func() { + // ARRANGE + fundingState.ActiveFunderAddresses = []string{i.ALICE, i.BOB, i.CHARLIE} + + // ACT + fundingState.SetInactive(&funding) + + // ASSERT + Expect(fundingState.ActiveFunderAddresses).To(HaveLen(2)) + Expect(fundingState.ActiveFunderAddresses[0]).To(Equal(i.CHARLIE)) + Expect(fundingState.ActiveFunderAddresses[1]).To(Equal(i.BOB)) + }) +}) diff --git a/x/funders/types/genesis.go b/x/funders/types/genesis.go new file mode 100644 index 00000000..9529939d --- /dev/null +++ b/x/funders/types/genesis.go @@ -0,0 +1,46 @@ +package types + +import "fmt" + +// DefaultGenesis returns the default genesis state +func DefaultGenesis() *GenesisState { + return &GenesisState{ + // this line is used by starport scaffolding # genesis/types/default + Params: DefaultParams(), + } +} + +// Validate performs basic genesis state validation returning an error upon any +// failure. +func (gs GenesisState) Validate() error { + // this line is used by starport scaffolding # genesis/types/validate + fundersIndexMap := make(map[string]struct{}) + for _, funder := range gs.FunderList { + index := FunderKey(funder.Address) + if _, ok := fundersIndexMap[string(index)]; ok { + return fmt.Errorf("duplicated funder id for %v", funder) + } + } + + fundingByFunderIndexMap := make(map[string]struct{}) + fundingByPoolIndexMap := make(map[string]struct{}) + for _, funding := range gs.FundingList { + byFunderIndex := FundingKeyByFunder(funding.FunderAddress, funding.PoolId) + if _, ok := fundingByFunderIndexMap[string(byFunderIndex)]; ok { + return fmt.Errorf("duplicated funding id for %v", funding) + } + byPoolIndex := FundingKeyByPool(funding.FunderAddress, funding.PoolId) + if _, ok := fundingByPoolIndexMap[string(byPoolIndex)]; ok { + return fmt.Errorf("duplicated funding id for %v", funding) + } + } + + fundingStateIndexMap := make(map[string]struct{}) + for _, fundingState := range gs.FundingStateList { + index := FundingStateKey(fundingState.PoolId) + if _, ok := fundingStateIndexMap[string(index)]; ok { + return fmt.Errorf("duplicated funding state id for %v", fundingState) + } + } + return gs.Params.Validate() +} diff --git a/x/funders/types/genesis.pb.go b/x/funders/types/genesis.pb.go new file mode 100644 index 00000000..5d60f0b6 --- /dev/null +++ b/x/funders/types/genesis.pb.go @@ -0,0 +1,519 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: kyve/funders/v1beta1/genesis.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// GenesisState defines the funders module's genesis state. +type GenesisState struct { + // params defines all the parameters of the module. + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` + // funder_list ... + FunderList []Funder `protobuf:"bytes,2,rep,name=funder_list,json=funderList,proto3" json:"funder_list"` + // funding_list ... + FundingList []Funding `protobuf:"bytes,3,rep,name=funding_list,json=fundingList,proto3" json:"funding_list"` + // funding_state ... + FundingStateList []FundingState `protobuf:"bytes,4,rep,name=funding_state_list,json=fundingStateList,proto3" json:"funding_state_list"` +} + +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_d339226ca8e2c929, []int{0} +} +func (m *GenesisState) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GenesisState.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *GenesisState) XXX_Merge(src proto.Message) { + xxx_messageInfo_GenesisState.Merge(m, src) +} +func (m *GenesisState) XXX_Size() int { + return m.Size() +} +func (m *GenesisState) XXX_DiscardUnknown() { + xxx_messageInfo_GenesisState.DiscardUnknown(m) +} + +var xxx_messageInfo_GenesisState proto.InternalMessageInfo + +func (m *GenesisState) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +func (m *GenesisState) GetFunderList() []Funder { + if m != nil { + return m.FunderList + } + return nil +} + +func (m *GenesisState) GetFundingList() []Funding { + if m != nil { + return m.FundingList + } + return nil +} + +func (m *GenesisState) GetFundingStateList() []FundingState { + if m != nil { + return m.FundingStateList + } + return nil +} + +func init() { + proto.RegisterType((*GenesisState)(nil), "kyve.funders.v1beta1.GenesisState") +} + +func init() { + proto.RegisterFile("kyve/funders/v1beta1/genesis.proto", fileDescriptor_d339226ca8e2c929) +} + +var fileDescriptor_d339226ca8e2c929 = []byte{ + // 301 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0xca, 0xae, 0x2c, 0x4b, + 0xd5, 0x4f, 0x2b, 0xcd, 0x4b, 0x49, 0x2d, 0x2a, 0xd6, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, 0x34, + 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, + 0x01, 0xa9, 0xd1, 0x83, 0xaa, 0xd1, 0x83, 0xaa, 0x91, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0x2b, + 0xd0, 0x07, 0xb1, 0x20, 0x6a, 0xa5, 0xb0, 0x9b, 0x07, 0xd3, 0x0b, 0x51, 0xa3, 0x88, 0x55, 0x4d, + 0x41, 0x62, 0x51, 0x62, 0x2e, 0x54, 0x89, 0xd2, 0x7a, 0x26, 0x2e, 0x1e, 0x77, 0x88, 0x23, 0x82, + 0x4b, 0x12, 0x4b, 0x52, 0x85, 0xac, 0xb8, 0xd8, 0x20, 0x0a, 0x24, 0x18, 0x15, 0x18, 0x35, 0xb8, + 0x8d, 0x64, 0xf4, 0xb0, 0x39, 0x4a, 0x2f, 0x00, 0xac, 0xc6, 0x89, 0xe5, 0xc4, 0x3d, 0x79, 0x86, + 0x20, 0xa8, 0x0e, 0x21, 0x67, 0x2e, 0x6e, 0x88, 0xba, 0xf8, 0x9c, 0xcc, 0xe2, 0x12, 0x09, 0x26, + 0x05, 0x66, 0xdc, 0x06, 0xb8, 0x81, 0xf9, 0x50, 0x03, 0xb8, 0x20, 0xb2, 0x3e, 0x99, 0xc5, 0x25, + 0x42, 0x6e, 0x5c, 0x3c, 0x20, 0x5e, 0x66, 0x5e, 0x3a, 0xc4, 0x14, 0x66, 0xb0, 0x29, 0xb2, 0xb8, + 0x4d, 0xc9, 0xcc, 0x4b, 0x87, 0x1a, 0xc3, 0x0d, 0xd5, 0x08, 0x36, 0x27, 0x8c, 0x4b, 0x08, 0x66, + 0x4e, 0x31, 0xc8, 0x67, 0x10, 0xd3, 0x58, 0xc0, 0xa6, 0x29, 0xe1, 0x35, 0x0d, 0x1c, 0x10, 0x50, + 0x23, 0x05, 0xd2, 0x90, 0xc4, 0x40, 0xe6, 0x3a, 0xb9, 0x9d, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, + 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3, + 0xb1, 0x1c, 0x43, 0x94, 0x4e, 0x7a, 0x66, 0x49, 0x46, 0x69, 0x92, 0x5e, 0x72, 0x7e, 0xae, 0xbe, + 0x77, 0x64, 0x98, 0xab, 0x5f, 0x6a, 0x49, 0x79, 0x7e, 0x51, 0xb6, 0x7e, 0x72, 0x46, 0x62, 0x66, + 0x9e, 0x7e, 0x05, 0x3c, 0x22, 0x4a, 0x2a, 0x0b, 0x52, 0x8b, 0x93, 0xd8, 0xc0, 0x11, 0x60, 0x0c, + 0x08, 0x00, 0x00, 0xff, 0xff, 0x69, 0x25, 0xe7, 0xb6, 0x19, 0x02, 0x00, 0x00, +} + +func (m *GenesisState) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *GenesisState) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.FundingStateList) > 0 { + for iNdEx := len(m.FundingStateList) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.FundingStateList[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + } + if len(m.FundingList) > 0 { + for iNdEx := len(m.FundingList) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.FundingList[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + if len(m.FunderList) > 0 { + for iNdEx := len(m.FunderList) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.FunderList[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { + offset -= sovGenesis(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *GenesisState) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovGenesis(uint64(l)) + if len(m.FunderList) > 0 { + for _, e := range m.FunderList { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.FundingList) > 0 { + for _, e := range m.FundingList { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.FundingStateList) > 0 { + for _, e := range m.FundingStateList { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + return n +} + +func sovGenesis(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozGenesis(x uint64) (n int) { + return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *GenesisState) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: GenesisState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FunderList", 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.FunderList = append(m.FunderList, Funder{}) + if err := m.FunderList[len(m.FunderList)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FundingList", 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.FundingList = append(m.FundingList, Funding{}) + if err := m.FundingList[len(m.FundingList)-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 FundingStateList", 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.FundingStateList = append(m.FundingStateList, FundingState{}) + if err := m.FundingStateList[len(m.FundingStateList)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipGenesis(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthGenesis + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupGenesis + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthGenesis + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthGenesis = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowGenesis = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupGenesis = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/funders/types/keys.go b/x/funders/types/keys.go new file mode 100644 index 00000000..24b69fc9 --- /dev/null +++ b/x/funders/types/keys.go @@ -0,0 +1,70 @@ +package types + +import "github.com/KYVENetwork/chain/util" + +const ( + // ModuleName defines the module name + ModuleName = "funders" + + // StoreKey defines the primary module store key + StoreKey = ModuleName + + // RouterKey defines the module's message routing key + RouterKey = ModuleName + + // MemStoreKey defines the in-memory store key + MemStoreKey = "mem_funders" +) + +const ( + // MaxFunders which are allowed per pool + MaxFunders = 50 +) + +var ( + // ParamsKey is the prefix for all module params defined in params.proto + ParamsKey = []byte{0x00} + + // FunderKeyPrefix is indexed by the funder address + // and contains all funders regardless of the pool + // key -> FunderKeyPrefix | + FunderKeyPrefix = []byte{1} + + // FundingKeyPrefixByFunder stores funding for each funder and pool by funder + // FundingKeyPrefixByFunder | | + FundingKeyPrefixByFunder = []byte{2, 0} + + // FundingKeyPrefixByPool stores funding for each funder and pool by pool + // FundingKeyPrefixByPool | | + FundingKeyPrefixByPool = []byte{2, 1} + + // FundingStateKeyPrefix stores funding state for each pool + // FundingStateKeyPrefix | | + FundingStateKeyPrefix = []byte{3, 0} +) + +func FunderKey(funderAddress string) []byte { + return util.GetByteKey(funderAddress) +} + +func FundingKeyByFunder(funderAddress string, poolId uint64) []byte { + return util.GetByteKey(funderAddress, poolId) +} + +func FundingKeyByPool(funderAddress string, poolId uint64) []byte { + return util.GetByteKey(poolId, funderAddress) +} + +// FundingKeyByFunderIter is used to query all fundings for a funder +func FundingKeyByFunderIter(funderAddress string) []byte { + return util.GetByteKey(funderAddress) +} + +// FundingKeyByPoolIter is used to query all fundings for a pool +func FundingKeyByPoolIter(poolId uint64) []byte { + return util.GetByteKey(poolId) +} + +func FundingStateKey(poolId uint64) []byte { + return util.GetByteKey(poolId) +} diff --git a/x/funders/types/message_create_funder.go b/x/funders/types/message_create_funder.go new file mode 100644 index 00000000..da23795f --- /dev/null +++ b/x/funders/types/message_create_funder.go @@ -0,0 +1,42 @@ +package types + +import ( + "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + errorsTypes "github.com/cosmos/cosmos-sdk/types/errors" +) + +var _ sdk.Msg = &MsgCreateFunder{} + +func (msg *MsgCreateFunder) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +func (msg *MsgCreateFunder) GetSigners() []sdk.AccAddress { + creator, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + panic(err) + } + + return []sdk.AccAddress{creator} +} + +func (msg *MsgCreateFunder) Route() string { + return RouterKey +} + +func (msg *MsgCreateFunder) Type() string { + return "kyve/funders/MsgCreateFunder" +} + +func (msg *MsgCreateFunder) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(msg.Creator); err != nil { + return errors.Wrapf(errorsTypes.ErrInvalidAddress, "invalid creator address: %s", err) + } + if msg.Moniker == "" { + return errors.Wrapf(errorsTypes.ErrInvalidRequest, "moniker cannot be empty") + } + + return nil +} diff --git a/x/pool/types/message_defund_pool.go b/x/funders/types/message_defund_pool.go similarity index 61% rename from x/pool/types/message_defund_pool.go rename to x/funders/types/message_defund_pool.go index ba6a2b63..85329811 100644 --- a/x/pool/types/message_defund_pool.go +++ b/x/funders/types/message_defund_pool.go @@ -2,23 +2,12 @@ package types import ( "cosmossdk.io/errors" + "github.com/KYVENetwork/chain/util" sdk "github.com/cosmos/cosmos-sdk/types" errorsTypes "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx" ) -var ( - _ legacytx.LegacyMsg = &MsgDefundPool{} - _ sdk.Msg = &MsgDefundPool{} -) - -func NewMsgDefundPool(creator string, id uint64, amount uint64) *MsgDefundPool { - return &MsgDefundPool{ - Creator: creator, - Id: id, - Amount: amount, - } -} +var _ sdk.Msg = &MsgDefundPool{} func (msg *MsgDefundPool) GetSignBytes() []byte { bz := ModuleCdc.MustMarshalJSON(msg) @@ -39,13 +28,21 @@ func (msg *MsgDefundPool) Route() string { } func (msg *MsgDefundPool) Type() string { - return "kyve/pool/MsgDefundPool" + return "kyve/funders/MsgDefundPool" } func (msg *MsgDefundPool) ValidateBasic() error { - _, err := sdk.AccAddressFromBech32(msg.Creator) - if err != nil { - return errors.Wrapf(errorsTypes.ErrInvalidAddress, "invalid creator address (%s)", err) + if _, err := sdk.AccAddressFromBech32(msg.Creator); err != nil { + return errors.Wrapf(errorsTypes.ErrInvalidAddress, "invalid creator address: %s", err) } + + if util.ValidateNumber(msg.PoolId) != nil { + return errors.Wrapf(errorsTypes.ErrInvalidRequest, "invalid pool id") + } + + if util.ValidatePositiveNumber(msg.Amount) != nil { + return errors.Wrapf(errorsTypes.ErrInvalidRequest, "invalid amount") + } + return nil } diff --git a/x/pool/types/message_fund_pool.go b/x/funders/types/message_fund_pool.go similarity index 73% rename from x/pool/types/message_fund_pool.go rename to x/funders/types/message_fund_pool.go index 61c716f8..44efdafe 100644 --- a/x/pool/types/message_fund_pool.go +++ b/x/funders/types/message_fund_pool.go @@ -5,21 +5,9 @@ import ( "github.com/KYVENetwork/chain/util" sdk "github.com/cosmos/cosmos-sdk/types" errorsTypes "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx" ) -var ( - _ legacytx.LegacyMsg = &MsgFundPool{} - _ sdk.Msg = &MsgFundPool{} -) - -func NewMsgFundPool(creator string, id uint64, amount uint64) *MsgFundPool { - return &MsgFundPool{ - Creator: creator, - Id: id, - Amount: amount, - } -} +var _ sdk.Msg = &MsgFundPool{} func (msg *MsgFundPool) GetSignBytes() []byte { bz := ModuleCdc.MustMarshalJSON(msg) @@ -40,7 +28,7 @@ func (msg *MsgFundPool) Route() string { } func (msg *MsgFundPool) Type() string { - return "kyve/pool/MsgFundPool" + return "kyve/funders/MsgFundPool" } func (msg *MsgFundPool) ValidateBasic() error { @@ -48,9 +36,17 @@ func (msg *MsgFundPool) ValidateBasic() error { return errors.Wrapf(errorsTypes.ErrInvalidAddress, "invalid creator address: %s", err) } + if util.ValidateNumber(msg.PoolId) != nil { + return errors.Wrapf(errorsTypes.ErrInvalidRequest, "invalid pool id") + } + if util.ValidateNumber(msg.Amount) != nil { return errors.Wrapf(errorsTypes.ErrInvalidRequest, "invalid amount") } + if util.ValidateNumber(msg.AmountPerBundle) != nil { + return errors.Wrapf(errorsTypes.ErrInvalidRequest, "invalid amount per bundle") + } + return nil } diff --git a/x/funders/types/message_update_funder.go b/x/funders/types/message_update_funder.go new file mode 100644 index 00000000..3b35b403 --- /dev/null +++ b/x/funders/types/message_update_funder.go @@ -0,0 +1,42 @@ +package types + +import ( + "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + errorsTypes "github.com/cosmos/cosmos-sdk/types/errors" +) + +var _ sdk.Msg = &MsgUpdateFunder{} + +func (msg *MsgUpdateFunder) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +func (msg *MsgUpdateFunder) GetSigners() []sdk.AccAddress { + creator, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + panic(err) + } + + return []sdk.AccAddress{creator} +} + +func (msg *MsgUpdateFunder) Route() string { + return RouterKey +} + +func (msg *MsgUpdateFunder) Type() string { + return "kyve/funders/MsgUpdateFunder" +} + +func (msg *MsgUpdateFunder) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(msg.Creator); err != nil { + return errors.Wrapf(errorsTypes.ErrInvalidAddress, "invalid creator address: %s", err) + } + if msg.Moniker == "" { + return errors.Wrapf(errorsTypes.ErrInvalidRequest, "moniker cannot be empty") + } + + return nil +} diff --git a/x/funders/types/msgs.go b/x/funders/types/msgs.go new file mode 100644 index 00000000..e568d11e --- /dev/null +++ b/x/funders/types/msgs.go @@ -0,0 +1,35 @@ +package types + +import ( + "encoding/json" + + "cosmossdk.io/errors" + + sdk "github.com/cosmos/cosmos-sdk/types" +) + +var _ sdk.Msg = &MsgUpdateParams{} + +// GetSigners returns the expected signers for a MsgUpdateParams message. +func (msg *MsgUpdateParams) GetSigners() []sdk.AccAddress { + addr, _ := sdk.AccAddressFromBech32(msg.Authority) + return []sdk.AccAddress{addr} +} + +// ValidateBasic does a sanity check on the provided data. +func (msg *MsgUpdateParams) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(msg.Authority); err != nil { + return errors.Wrap(err, "invalid authority address") + } + + params := DefaultParams() + if err := json.Unmarshal([]byte(msg.Payload), ¶ms); err != nil { + return err + } + + if err := params.Validate(); err != nil { + return err + } + + return nil +} diff --git a/x/funders/types/params.go b/x/funders/types/params.go new file mode 100644 index 00000000..c87c8599 --- /dev/null +++ b/x/funders/types/params.go @@ -0,0 +1,49 @@ +package types + +import ( + "github.com/KYVENetwork/chain/util" +) + +const ( + // DefaultMinFundingAmount 1000 Kyve + DefaultMinFundingAmount = uint64(1_000_000_000) + // DefaultMinFundingAmountPerBundle 0.1 Kyve + DefaultMinFundingAmountPerBundle = uint64(100_000) + // DefaultMinFundingMultiple 20 + DefaultMinFundingMultiple = uint64(20) +) + +// NewParams creates a new Params instance +func NewParams(minFundingAmount uint64, minFundingAmountPerBundle uint64, minFundingMultiple uint64) Params { + return Params{ + MinFundingAmount: minFundingAmount, + MinFundingAmountPerBundle: minFundingAmountPerBundle, + MinFundingMultiple: minFundingMultiple, + } +} + +// DefaultParams returns a default set of parameters +func DefaultParams() Params { + return NewParams( + DefaultMinFundingAmount, + DefaultMinFundingAmountPerBundle, + DefaultMinFundingMultiple, + ) +} + +// Validate validates the set of params +func (p *Params) Validate() error { + if err := util.ValidateNumber(p.MinFundingAmount); err != nil { + return err + } + + if err := util.ValidateNumber(p.MinFundingAmountPerBundle); err != nil { + return err + } + + if err := util.ValidateNumber(p.MinFundingAmountPerBundle); err != nil { + return err + } + + return nil +} diff --git a/x/funders/types/params.pb.go b/x/funders/types/params.pb.go new file mode 100644 index 00000000..adf8da11 --- /dev/null +++ b/x/funders/types/params.pb.go @@ -0,0 +1,380 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: kyve/funders/v1beta1/params.proto + +package types + +import ( + fmt "fmt" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// Params defines the funders module parameters. +type Params struct { + // Minimum amount of tokens that can be funded. + MinFundingAmount uint64 `protobuf:"varint,1,opt,name=min_funding_amount,json=minFundingAmount,proto3" json:"min_funding_amount,omitempty"` + // Minimum amount of tokens that can be funded per bundle. + MinFundingAmountPerBundle uint64 `protobuf:"varint,2,opt,name=min_funding_amount_per_bundle,json=minFundingAmountPerBundle,proto3" json:"min_funding_amount_per_bundle,omitempty"` + // Minimum ratio between the funded amount and the amount_per_bundle. + // In other words this param ensures, that a funder provides at least funding for + // `min_funding_multiple` bundles. + MinFundingMultiple uint64 `protobuf:"varint,3,opt,name=min_funding_multiple,json=minFundingMultiple,proto3" json:"min_funding_multiple,omitempty"` +} + +func (m *Params) Reset() { *m = Params{} } +func (m *Params) String() string { return proto.CompactTextString(m) } +func (*Params) ProtoMessage() {} +func (*Params) Descriptor() ([]byte, []int) { + return fileDescriptor_906a9a55094dc984, []int{0} +} +func (m *Params) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Params.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Params) XXX_Merge(src proto.Message) { + xxx_messageInfo_Params.Merge(m, src) +} +func (m *Params) XXX_Size() int { + return m.Size() +} +func (m *Params) XXX_DiscardUnknown() { + xxx_messageInfo_Params.DiscardUnknown(m) +} + +var xxx_messageInfo_Params proto.InternalMessageInfo + +func (m *Params) GetMinFundingAmount() uint64 { + if m != nil { + return m.MinFundingAmount + } + return 0 +} + +func (m *Params) GetMinFundingAmountPerBundle() uint64 { + if m != nil { + return m.MinFundingAmountPerBundle + } + return 0 +} + +func (m *Params) GetMinFundingMultiple() uint64 { + if m != nil { + return m.MinFundingMultiple + } + return 0 +} + +func init() { + proto.RegisterType((*Params)(nil), "kyve.funders.v1beta1.Params") +} + +func init() { proto.RegisterFile("kyve/funders/v1beta1/params.proto", fileDescriptor_906a9a55094dc984) } + +var fileDescriptor_906a9a55094dc984 = []byte{ + // 241 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0xcc, 0xae, 0x2c, 0x4b, + 0xd5, 0x4f, 0x2b, 0xcd, 0x4b, 0x49, 0x2d, 0x2a, 0xd6, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, 0x34, + 0xd4, 0x2f, 0x48, 0x2c, 0x4a, 0xcc, 0x2d, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x01, + 0x29, 0xd1, 0x83, 0x2a, 0xd1, 0x83, 0x2a, 0x51, 0x5a, 0xc5, 0xc8, 0xc5, 0x16, 0x00, 0x56, 0x26, + 0xa4, 0xc3, 0x25, 0x94, 0x9b, 0x99, 0x17, 0x0f, 0x52, 0x91, 0x99, 0x97, 0x1e, 0x9f, 0x98, 0x9b, + 0x5f, 0x9a, 0x57, 0x22, 0xc1, 0xa8, 0xc0, 0xa8, 0xc1, 0x12, 0x24, 0x90, 0x9b, 0x99, 0xe7, 0x06, + 0x91, 0x70, 0x04, 0x8b, 0x0b, 0x39, 0x70, 0xc9, 0x62, 0xaa, 0x8e, 0x2f, 0x48, 0x2d, 0x8a, 0x4f, + 0x2a, 0xcd, 0x4b, 0xc9, 0x49, 0x95, 0x60, 0x02, 0x6b, 0x94, 0x44, 0xd7, 0x18, 0x90, 0x5a, 0xe4, + 0x04, 0x56, 0x20, 0x64, 0xc0, 0x25, 0x82, 0x6c, 0x42, 0x6e, 0x69, 0x4e, 0x49, 0x66, 0x41, 0x4e, + 0xaa, 0x04, 0x33, 0x58, 0xa3, 0x10, 0x42, 0xa3, 0x2f, 0x54, 0xc6, 0xc9, 0xed, 0xc4, 0x23, 0x39, + 0xc6, 0x0b, 0x8f, 0xe4, 0x18, 0x1f, 0x3c, 0x92, 0x63, 0x9c, 0xf0, 0x58, 0x8e, 0xe1, 0xc2, 0x63, + 0x39, 0x86, 0x1b, 0x8f, 0xe5, 0x18, 0xa2, 0x74, 0xd2, 0x33, 0x4b, 0x32, 0x4a, 0x93, 0xf4, 0x92, + 0xf3, 0x73, 0xf5, 0xbd, 0x23, 0xc3, 0x5c, 0xfd, 0x52, 0x4b, 0xca, 0xf3, 0x8b, 0xb2, 0xf5, 0x93, + 0x33, 0x12, 0x33, 0xf3, 0xf4, 0x2b, 0xe0, 0x21, 0x53, 0x52, 0x59, 0x90, 0x5a, 0x9c, 0xc4, 0x06, + 0x0e, 0x11, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x66, 0xb6, 0xfa, 0xe0, 0x36, 0x01, 0x00, + 0x00, +} + +func (m *Params) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Params) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.MinFundingMultiple != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.MinFundingMultiple)) + i-- + dAtA[i] = 0x18 + } + if m.MinFundingAmountPerBundle != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.MinFundingAmountPerBundle)) + i-- + dAtA[i] = 0x10 + } + if m.MinFundingAmount != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.MinFundingAmount)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintParams(dAtA []byte, offset int, v uint64) int { + offset -= sovParams(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Params) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.MinFundingAmount != 0 { + n += 1 + sovParams(uint64(m.MinFundingAmount)) + } + if m.MinFundingAmountPerBundle != 0 { + n += 1 + sovParams(uint64(m.MinFundingAmountPerBundle)) + } + if m.MinFundingMultiple != 0 { + n += 1 + sovParams(uint64(m.MinFundingMultiple)) + } + return n +} + +func sovParams(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozParams(x uint64) (n int) { + return sovParams(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Params) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Params: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MinFundingAmount", wireType) + } + m.MinFundingAmount = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MinFundingAmount |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MinFundingAmountPerBundle", wireType) + } + m.MinFundingAmountPerBundle = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MinFundingAmountPerBundle |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MinFundingMultiple", wireType) + } + m.MinFundingMultiple = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MinFundingMultiple |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipParams(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthParams + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipParams(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowParams + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowParams + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowParams + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthParams + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupParams + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthParams + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthParams = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowParams = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupParams = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/funders/types/query.pb.go b/x/funders/types/query.pb.go new file mode 100644 index 00000000..83ed0025 --- /dev/null +++ b/x/funders/types/query.pb.go @@ -0,0 +1,536 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: kyve/funders/v1beta1/query.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + _ "google.golang.org/genproto/googleapis/api/annotations" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// QueryParamsRequest is request type for the Query/Params RPC method. +type QueryParamsRequest struct { +} + +func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} } +func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryParamsRequest) ProtoMessage() {} +func (*QueryParamsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_6f21e7f51590fda7, []int{0} +} +func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryParamsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryParamsRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryParamsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsRequest.Merge(m, src) +} +func (m *QueryParamsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryParamsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryParamsRequest proto.InternalMessageInfo + +// QueryParamsResponse is response type for the Query/Params RPC method. +type QueryParamsResponse struct { + // params holds all the parameters of this module. + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` +} + +func (m *QueryParamsResponse) Reset() { *m = QueryParamsResponse{} } +func (m *QueryParamsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryParamsResponse) ProtoMessage() {} +func (*QueryParamsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_6f21e7f51590fda7, []int{1} +} +func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryParamsResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsResponse.Merge(m, src) +} +func (m *QueryParamsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryParamsResponse proto.InternalMessageInfo + +func (m *QueryParamsResponse) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +func init() { + proto.RegisterType((*QueryParamsRequest)(nil), "kyve.funders.v1beta1.QueryParamsRequest") + proto.RegisterType((*QueryParamsResponse)(nil), "kyve.funders.v1beta1.QueryParamsResponse") +} + +func init() { proto.RegisterFile("kyve/funders/v1beta1/query.proto", fileDescriptor_6f21e7f51590fda7) } + +var fileDescriptor_6f21e7f51590fda7 = []byte{ + // 289 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0xc8, 0xae, 0x2c, 0x4b, + 0xd5, 0x4f, 0x2b, 0xcd, 0x4b, 0x49, 0x2d, 0x2a, 0xd6, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, 0x34, + 0xd4, 0x2f, 0x2c, 0x4d, 0x2d, 0xaa, 0xd4, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x01, 0xa9, + 0xd0, 0x83, 0xaa, 0xd0, 0x83, 0xaa, 0x90, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0x2b, 0xd0, 0x07, + 0xb1, 0x20, 0x6a, 0xa5, 0x64, 0xd2, 0xf3, 0xf3, 0xd3, 0x73, 0x52, 0xf5, 0x13, 0x0b, 0x32, 0xf5, + 0x13, 0xf3, 0xf2, 0xf2, 0x4b, 0x12, 0x4b, 0x32, 0xf3, 0xf3, 0x8a, 0xa1, 0xb2, 0x8a, 0x58, 0xed, + 0x2a, 0x48, 0x2c, 0x4a, 0xcc, 0x85, 0x2a, 0x51, 0x12, 0xe1, 0x12, 0x0a, 0x04, 0xd9, 0x1d, 0x00, + 0x16, 0x0c, 0x4a, 0x2d, 0x2c, 0x4d, 0x2d, 0x2e, 0x51, 0x0a, 0xe4, 0x12, 0x46, 0x11, 0x2d, 0x2e, + 0xc8, 0xcf, 0x2b, 0x4e, 0x15, 0xb2, 0xe2, 0x62, 0x83, 0x68, 0x96, 0x60, 0x54, 0x60, 0xd4, 0xe0, + 0x36, 0x92, 0xd1, 0xc3, 0xe6, 0x54, 0x3d, 0x88, 0x2e, 0x27, 0x96, 0x13, 0xf7, 0xe4, 0x19, 0x82, + 0xa0, 0x3a, 0x8c, 0x7a, 0x19, 0xb9, 0x58, 0xc1, 0x66, 0x0a, 0x35, 0x33, 0x72, 0xb1, 0x41, 0x94, + 0x08, 0x69, 0x60, 0x37, 0x00, 0xd3, 0x45, 0x52, 0x9a, 0x44, 0xa8, 0x84, 0xb8, 0x52, 0x49, 0xa5, + 0xe9, 0xf2, 0x93, 0xc9, 0x4c, 0x72, 0x42, 0x32, 0xfa, 0x78, 0xbc, 0xef, 0xe4, 0x76, 0xe2, 0x91, + 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, 0xc9, 0x31, 0x4e, 0x78, 0x2c, 0xc7, 0x70, 0xe1, + 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, 0x0c, 0x51, 0x3a, 0xe9, 0x99, 0x25, 0x19, 0xa5, 0x49, 0x7a, + 0xc9, 0xf9, 0xb9, 0xfa, 0xde, 0x91, 0x61, 0xae, 0x7e, 0xa9, 0x25, 0xe5, 0xf9, 0x45, 0xd9, 0xfa, + 0xc9, 0x19, 0x89, 0x99, 0x79, 0xfa, 0x15, 0x70, 0x03, 0x4b, 0x2a, 0x0b, 0x52, 0x8b, 0x93, 0xd8, + 0xc0, 0xe1, 0x68, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0x17, 0x4e, 0xe8, 0x7b, 0xd8, 0x01, 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) +} + +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, "/kyve.funders.v1beta1.Query/Params", 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) +} + +// 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 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: "/kyve.funders.v1beta1.Query/Params", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "kyve.funders.v1beta1.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Params", + Handler: _Query_Params_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "kyve/funders/v1beta1/query.proto", +} + +func (m *QueryParamsRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryParamsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryParamsResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func 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 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 skipQuery(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthQuery + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupQuery + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthQuery + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthQuery = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowQuery = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/funders/types/query.pb.gw.go b/x/funders/types/query.pb.gw.go new file mode 100644 index 00000000..ac6feae2 --- /dev/null +++ b/x/funders/types/query.pb.gw.go @@ -0,0 +1,153 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: kyve/funders/v1beta1/query.proto + +/* +Package types is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package types + +import ( + "context" + "io" + "net/http" + + "github.com/golang/protobuf/descriptor" + "github.com/golang/protobuf/proto" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/grpc-ecosystem/grpc-gateway/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" +) + +// Suppress "imported and not used" errors +var _ codes.Code +var _ io.Reader +var _ status.Status +var _ = runtime.String +var _ = utilities.NewDoubleArray +var _ = descriptor.ForMessage +var _ = metadata.Join + +func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsRequest + var metadata runtime.ServerMetadata + + msg, err := client.Params(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsRequest + var metadata runtime.ServerMetadata + + msg, err := server.Params(ctx, &protoReq) + return msg, metadata, err + +} + +// RegisterQueryHandlerServer registers the http handlers for service Query to "mux". +// UnaryRPC :call QueryServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { + + mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_Params_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.Dial(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterQueryHandler(ctx, mux, conn) +} + +// RegisterQueryHandler registers the http handlers for service Query to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn)) +} + +// RegisterQueryHandlerClient registers the http handlers for service Query +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "QueryClient" to call the correct interceptors. +func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { + + mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_Params_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"kyve", "funders", "v1beta1", "params"}, "", runtime.AssumeColonVerbOpt(true))) +) + +var ( + forward_Query_Params_0 = runtime.ForwardResponseMessage +) diff --git a/x/funders/types/tx.pb.go b/x/funders/types/tx.pb.go new file mode 100644 index 00000000..93061955 --- /dev/null +++ b/x/funders/types/tx.pb.go @@ -0,0 +1,2623 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: kyve/funders/v1beta1/tx.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// MsgCreateFunder defines a SDK message for creating a funder. +type MsgCreateFunder struct { + // creator ... + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + // moniker + Moniker string `protobuf:"bytes,2,opt,name=moniker,proto3" json:"moniker,omitempty"` + // identity is the 64 bit keybase.io identity string + Identity string `protobuf:"bytes,3,opt,name=identity,proto3" json:"identity,omitempty"` + // website + Website string `protobuf:"bytes,4,opt,name=website,proto3" json:"website,omitempty"` + // contact + Contact string `protobuf:"bytes,5,opt,name=contact,proto3" json:"contact,omitempty"` + // description are some additional notes the funder finds important + Description string `protobuf:"bytes,6,opt,name=description,proto3" json:"description,omitempty"` +} + +func (m *MsgCreateFunder) Reset() { *m = MsgCreateFunder{} } +func (m *MsgCreateFunder) String() string { return proto.CompactTextString(m) } +func (*MsgCreateFunder) ProtoMessage() {} +func (*MsgCreateFunder) Descriptor() ([]byte, []int) { + return fileDescriptor_5145d80c2db97f3d, []int{0} +} +func (m *MsgCreateFunder) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCreateFunder) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCreateFunder.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 *MsgCreateFunder) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCreateFunder.Merge(m, src) +} +func (m *MsgCreateFunder) XXX_Size() int { + return m.Size() +} +func (m *MsgCreateFunder) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCreateFunder.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCreateFunder proto.InternalMessageInfo + +func (m *MsgCreateFunder) GetCreator() string { + if m != nil { + return m.Creator + } + return "" +} + +func (m *MsgCreateFunder) GetMoniker() string { + if m != nil { + return m.Moniker + } + return "" +} + +func (m *MsgCreateFunder) GetIdentity() string { + if m != nil { + return m.Identity + } + return "" +} + +func (m *MsgCreateFunder) GetWebsite() string { + if m != nil { + return m.Website + } + return "" +} + +func (m *MsgCreateFunder) GetContact() string { + if m != nil { + return m.Contact + } + return "" +} + +func (m *MsgCreateFunder) GetDescription() string { + if m != nil { + return m.Description + } + return "" +} + +// MsgCreateFunderResponse defines the Msg/CreateFunder response type. +type MsgCreateFunderResponse struct { +} + +func (m *MsgCreateFunderResponse) Reset() { *m = MsgCreateFunderResponse{} } +func (m *MsgCreateFunderResponse) String() string { return proto.CompactTextString(m) } +func (*MsgCreateFunderResponse) ProtoMessage() {} +func (*MsgCreateFunderResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_5145d80c2db97f3d, []int{1} +} +func (m *MsgCreateFunderResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCreateFunderResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCreateFunderResponse.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 *MsgCreateFunderResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCreateFunderResponse.Merge(m, src) +} +func (m *MsgCreateFunderResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgCreateFunderResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCreateFunderResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCreateFunderResponse proto.InternalMessageInfo + +// MsgUpdateFunder defines a SDK message for updating a funder. +type MsgUpdateFunder struct { + // creator ... + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + // moniker + Moniker string `protobuf:"bytes,2,opt,name=moniker,proto3" json:"moniker,omitempty"` + // identity is the 64 bit keybase.io identity string + Identity string `protobuf:"bytes,3,opt,name=identity,proto3" json:"identity,omitempty"` + // website + Website string `protobuf:"bytes,4,opt,name=website,proto3" json:"website,omitempty"` + // contact + Contact string `protobuf:"bytes,5,opt,name=contact,proto3" json:"contact,omitempty"` + // description are some additional notes the funder finds important + Description string `protobuf:"bytes,6,opt,name=description,proto3" json:"description,omitempty"` +} + +func (m *MsgUpdateFunder) Reset() { *m = MsgUpdateFunder{} } +func (m *MsgUpdateFunder) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateFunder) ProtoMessage() {} +func (*MsgUpdateFunder) Descriptor() ([]byte, []int) { + return fileDescriptor_5145d80c2db97f3d, []int{2} +} +func (m *MsgUpdateFunder) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateFunder) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateFunder.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 *MsgUpdateFunder) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateFunder.Merge(m, src) +} +func (m *MsgUpdateFunder) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateFunder) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateFunder.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateFunder proto.InternalMessageInfo + +func (m *MsgUpdateFunder) GetCreator() string { + if m != nil { + return m.Creator + } + return "" +} + +func (m *MsgUpdateFunder) GetMoniker() string { + if m != nil { + return m.Moniker + } + return "" +} + +func (m *MsgUpdateFunder) GetIdentity() string { + if m != nil { + return m.Identity + } + return "" +} + +func (m *MsgUpdateFunder) GetWebsite() string { + if m != nil { + return m.Website + } + return "" +} + +func (m *MsgUpdateFunder) GetContact() string { + if m != nil { + return m.Contact + } + return "" +} + +func (m *MsgUpdateFunder) GetDescription() string { + if m != nil { + return m.Description + } + return "" +} + +// MsgUpdateFunderResponse defines the Msg/UpdateFunder response type. +type MsgUpdateFunderResponse struct { +} + +func (m *MsgUpdateFunderResponse) Reset() { *m = MsgUpdateFunderResponse{} } +func (m *MsgUpdateFunderResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateFunderResponse) ProtoMessage() {} +func (*MsgUpdateFunderResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_5145d80c2db97f3d, []int{3} +} +func (m *MsgUpdateFunderResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateFunderResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateFunderResponse.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 *MsgUpdateFunderResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateFunderResponse.Merge(m, src) +} +func (m *MsgUpdateFunderResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateFunderResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateFunderResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateFunderResponse proto.InternalMessageInfo + +// MsgFundPool defines a SDK message for funding a pool. +type MsgFundPool struct { + // creator ... + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + // id ... + PoolId uint64 `protobuf:"varint,2,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty"` + // amount is the total amount available for distribution + Amount uint64 `protobuf:"varint,3,opt,name=amount,proto3" json:"amount,omitempty"` + // amount_per_bundle defines the amount of tokens that are distributed per submitted bundle + AmountPerBundle uint64 `protobuf:"varint,4,opt,name=amount_per_bundle,json=amountPerBundle,proto3" json:"amount_per_bundle,omitempty"` +} + +func (m *MsgFundPool) Reset() { *m = MsgFundPool{} } +func (m *MsgFundPool) String() string { return proto.CompactTextString(m) } +func (*MsgFundPool) ProtoMessage() {} +func (*MsgFundPool) Descriptor() ([]byte, []int) { + return fileDescriptor_5145d80c2db97f3d, []int{4} +} +func (m *MsgFundPool) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgFundPool) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgFundPool.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 *MsgFundPool) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgFundPool.Merge(m, src) +} +func (m *MsgFundPool) XXX_Size() int { + return m.Size() +} +func (m *MsgFundPool) XXX_DiscardUnknown() { + xxx_messageInfo_MsgFundPool.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgFundPool proto.InternalMessageInfo + +func (m *MsgFundPool) GetCreator() string { + if m != nil { + return m.Creator + } + return "" +} + +func (m *MsgFundPool) GetPoolId() uint64 { + if m != nil { + return m.PoolId + } + return 0 +} + +func (m *MsgFundPool) GetAmount() uint64 { + if m != nil { + return m.Amount + } + return 0 +} + +func (m *MsgFundPool) GetAmountPerBundle() uint64 { + if m != nil { + return m.AmountPerBundle + } + return 0 +} + +// MsgFundPoolResponse defines the Msg/DefundPool response type. +type MsgFundPoolResponse struct { +} + +func (m *MsgFundPoolResponse) Reset() { *m = MsgFundPoolResponse{} } +func (m *MsgFundPoolResponse) String() string { return proto.CompactTextString(m) } +func (*MsgFundPoolResponse) ProtoMessage() {} +func (*MsgFundPoolResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_5145d80c2db97f3d, []int{5} +} +func (m *MsgFundPoolResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgFundPoolResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgFundPoolResponse.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 *MsgFundPoolResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgFundPoolResponse.Merge(m, src) +} +func (m *MsgFundPoolResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgFundPoolResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgFundPoolResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgFundPoolResponse proto.InternalMessageInfo + +// MsgDefundPool defines a SDK message for defunding a pool. +type MsgDefundPool struct { + // creator ... + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + // id ... + PoolId uint64 `protobuf:"varint,2,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty"` + // amount ... + Amount uint64 `protobuf:"varint,3,opt,name=amount,proto3" json:"amount,omitempty"` +} + +func (m *MsgDefundPool) Reset() { *m = MsgDefundPool{} } +func (m *MsgDefundPool) String() string { return proto.CompactTextString(m) } +func (*MsgDefundPool) ProtoMessage() {} +func (*MsgDefundPool) Descriptor() ([]byte, []int) { + return fileDescriptor_5145d80c2db97f3d, []int{6} +} +func (m *MsgDefundPool) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgDefundPool) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgDefundPool.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 *MsgDefundPool) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgDefundPool.Merge(m, src) +} +func (m *MsgDefundPool) XXX_Size() int { + return m.Size() +} +func (m *MsgDefundPool) XXX_DiscardUnknown() { + xxx_messageInfo_MsgDefundPool.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgDefundPool proto.InternalMessageInfo + +func (m *MsgDefundPool) GetCreator() string { + if m != nil { + return m.Creator + } + return "" +} + +func (m *MsgDefundPool) GetPoolId() uint64 { + if m != nil { + return m.PoolId + } + return 0 +} + +func (m *MsgDefundPool) GetAmount() uint64 { + if m != nil { + return m.Amount + } + return 0 +} + +// MsgDefundPoolResponse defines the Msg/DefundPool response type. +type MsgDefundPoolResponse struct { +} + +func (m *MsgDefundPoolResponse) Reset() { *m = MsgDefundPoolResponse{} } +func (m *MsgDefundPoolResponse) String() string { return proto.CompactTextString(m) } +func (*MsgDefundPoolResponse) ProtoMessage() {} +func (*MsgDefundPoolResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_5145d80c2db97f3d, []int{7} +} +func (m *MsgDefundPoolResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgDefundPoolResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgDefundPoolResponse.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 *MsgDefundPoolResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgDefundPoolResponse.Merge(m, src) +} +func (m *MsgDefundPoolResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgDefundPoolResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgDefundPoolResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgDefundPoolResponse proto.InternalMessageInfo + +// MsgUpdateParams defines a SDK message for updating the module parameters. +type MsgUpdateParams struct { + // authority is the address of the governance account. + Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` + // payload defines the x/delegation parameters to update. + Payload string `protobuf:"bytes,2,opt,name=payload,proto3" json:"payload,omitempty"` +} + +func (m *MsgUpdateParams) Reset() { *m = MsgUpdateParams{} } +func (m *MsgUpdateParams) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateParams) ProtoMessage() {} +func (*MsgUpdateParams) Descriptor() ([]byte, []int) { + return fileDescriptor_5145d80c2db97f3d, []int{8} +} +func (m *MsgUpdateParams) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateParams.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgUpdateParams) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateParams.Merge(m, src) +} +func (m *MsgUpdateParams) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateParams) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateParams.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateParams proto.InternalMessageInfo + +func (m *MsgUpdateParams) GetAuthority() string { + if m != nil { + return m.Authority + } + return "" +} + +func (m *MsgUpdateParams) GetPayload() string { + if m != nil { + return m.Payload + } + return "" +} + +// MsgUpdateParamsResponse defines the Msg/UpdateParams response type. +type MsgUpdateParamsResponse struct { +} + +func (m *MsgUpdateParamsResponse) Reset() { *m = MsgUpdateParamsResponse{} } +func (m *MsgUpdateParamsResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateParamsResponse) ProtoMessage() {} +func (*MsgUpdateParamsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_5145d80c2db97f3d, []int{9} +} +func (m *MsgUpdateParamsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateParamsResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgUpdateParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateParamsResponse.Merge(m, src) +} +func (m *MsgUpdateParamsResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateParamsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateParamsResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*MsgCreateFunder)(nil), "kyve.funders.v1beta1.MsgCreateFunder") + proto.RegisterType((*MsgCreateFunderResponse)(nil), "kyve.funders.v1beta1.MsgCreateFunderResponse") + proto.RegisterType((*MsgUpdateFunder)(nil), "kyve.funders.v1beta1.MsgUpdateFunder") + proto.RegisterType((*MsgUpdateFunderResponse)(nil), "kyve.funders.v1beta1.MsgUpdateFunderResponse") + proto.RegisterType((*MsgFundPool)(nil), "kyve.funders.v1beta1.MsgFundPool") + proto.RegisterType((*MsgFundPoolResponse)(nil), "kyve.funders.v1beta1.MsgFundPoolResponse") + proto.RegisterType((*MsgDefundPool)(nil), "kyve.funders.v1beta1.MsgDefundPool") + proto.RegisterType((*MsgDefundPoolResponse)(nil), "kyve.funders.v1beta1.MsgDefundPoolResponse") + proto.RegisterType((*MsgUpdateParams)(nil), "kyve.funders.v1beta1.MsgUpdateParams") + proto.RegisterType((*MsgUpdateParamsResponse)(nil), "kyve.funders.v1beta1.MsgUpdateParamsResponse") +} + +func init() { proto.RegisterFile("kyve/funders/v1beta1/tx.proto", fileDescriptor_5145d80c2db97f3d) } + +var fileDescriptor_5145d80c2db97f3d = []byte{ + // 547 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x54, 0xdd, 0x6e, 0xd3, 0x30, + 0x18, 0x6d, 0x68, 0xe9, 0x36, 0x0f, 0x34, 0x11, 0x36, 0x9a, 0x55, 0x22, 0x1a, 0x45, 0x48, 0xfc, + 0x2d, 0xd1, 0x40, 0xe2, 0x9e, 0x02, 0x93, 0x10, 0x2a, 0xaa, 0x82, 0x40, 0xb0, 0x0b, 0x2a, 0x27, + 0xf6, 0x52, 0xab, 0x8d, 0x1d, 0xd9, 0xce, 0xb6, 0xde, 0xf3, 0x00, 0x3c, 0x0c, 0x12, 0xaf, 0xc0, + 0xe5, 0xc4, 0x15, 0x97, 0xa8, 0x7d, 0x02, 0xde, 0x00, 0xc5, 0x4e, 0xb2, 0x64, 0xac, 0xeb, 0x2e, + 0xb8, 0xd9, 0x5d, 0x8e, 0xcf, 0xf9, 0x72, 0xbe, 0xcf, 0xdf, 0x49, 0xc0, 0xed, 0xd1, 0xe4, 0x00, + 0xbb, 0xfb, 0x09, 0x45, 0x98, 0x0b, 0xf7, 0x60, 0xc7, 0xc7, 0x12, 0xee, 0xb8, 0xf2, 0xc8, 0x89, + 0x39, 0x93, 0xcc, 0x5c, 0x4f, 0x69, 0x27, 0xa3, 0x9d, 0x8c, 0x6e, 0x6f, 0x06, 0x4c, 0x44, 0x4c, + 0x0c, 0x94, 0xc6, 0xd5, 0x40, 0x17, 0x74, 0xbe, 0x1b, 0x60, 0xad, 0x27, 0xc2, 0x17, 0x1c, 0x43, + 0x89, 0x77, 0x55, 0x9d, 0x69, 0x81, 0xa5, 0x20, 0xc5, 0x8c, 0x5b, 0xc6, 0x96, 0x71, 0x7f, 0xc5, + 0xcb, 0x61, 0xca, 0x44, 0x8c, 0x92, 0x11, 0xe6, 0xd6, 0x15, 0xcd, 0x64, 0xd0, 0x6c, 0x83, 0x65, + 0x82, 0x30, 0x95, 0x44, 0x4e, 0xac, 0xba, 0xa2, 0x0a, 0x9c, 0x56, 0x1d, 0x62, 0x5f, 0x10, 0x89, + 0xad, 0x86, 0xae, 0xca, 0xa0, 0x72, 0x62, 0x54, 0xc2, 0x40, 0x5a, 0x57, 0x33, 0x27, 0x0d, 0xcd, + 0x2d, 0xb0, 0x8a, 0xb0, 0x08, 0x38, 0x89, 0x25, 0x61, 0xd4, 0x6a, 0x2a, 0xb6, 0x7c, 0xd4, 0xd9, + 0x04, 0xad, 0x53, 0x8d, 0x7b, 0x58, 0xc4, 0x8c, 0x0a, 0x9c, 0x0f, 0xf5, 0x3e, 0x46, 0x97, 0x73, + 0xa8, 0x72, 0xe3, 0xc5, 0x50, 0x5f, 0x0c, 0xb0, 0xda, 0x13, 0x61, 0x7a, 0xda, 0x67, 0x6c, 0x7c, + 0xce, 0x40, 0x2d, 0xb0, 0x14, 0x33, 0x36, 0x1e, 0x10, 0xa4, 0x06, 0x6a, 0x78, 0xcd, 0x14, 0xbe, + 0x46, 0xe6, 0x2d, 0xd0, 0x84, 0x11, 0x4b, 0xa8, 0x54, 0xd3, 0x34, 0xbc, 0x0c, 0x99, 0x0f, 0xc1, + 0x0d, 0xfd, 0x34, 0x88, 0x31, 0x1f, 0xf8, 0x09, 0x45, 0x63, 0x3d, 0x55, 0xc3, 0x5b, 0xd3, 0x44, + 0x1f, 0xf3, 0xae, 0x3a, 0xee, 0x6c, 0x80, 0x9b, 0xa5, 0x2e, 0x8a, 0xee, 0xf6, 0xc0, 0xf5, 0x9e, + 0x08, 0x5f, 0xe2, 0xfd, 0xff, 0xdf, 0x5e, 0xa7, 0x05, 0x36, 0x2a, 0xef, 0x2e, 0x4c, 0x83, 0xd2, + 0x9a, 0xfb, 0x90, 0xc3, 0x48, 0x98, 0xcf, 0xc0, 0x0a, 0x4c, 0xe4, 0x90, 0xf1, 0x74, 0x67, 0xca, + 0xb8, 0x6b, 0xfd, 0xfc, 0xb6, 0xbd, 0x9e, 0x85, 0xfe, 0x39, 0x42, 0x1c, 0x0b, 0xf1, 0x4e, 0x72, + 0x42, 0x43, 0xef, 0x44, 0x9a, 0xb6, 0x1b, 0xc3, 0xc9, 0x98, 0x41, 0x94, 0x87, 0x20, 0x83, 0x95, + 0x95, 0x68, 0x93, 0xdc, 0xff, 0xc9, 0x9f, 0x3a, 0xa8, 0xf7, 0x44, 0x68, 0x22, 0x70, 0xad, 0xf2, + 0x01, 0xdd, 0x73, 0xce, 0xfa, 0x0c, 0x9d, 0x53, 0x71, 0x6d, 0x6f, 0x5f, 0x48, 0x96, 0xbb, 0xa5, + 0x2e, 0x95, 0x44, 0xcf, 0x77, 0x29, 0xcb, 0xce, 0x71, 0x39, 0x2b, 0x66, 0xe6, 0x47, 0xb0, 0x5c, + 0x44, 0xec, 0xce, 0xdc, 0xd2, 0x5c, 0xd2, 0x7e, 0xb0, 0x50, 0x52, 0xbc, 0xf9, 0x33, 0x00, 0xa5, + 0x7c, 0xdc, 0x9d, 0x5b, 0x78, 0x22, 0x6a, 0x3f, 0xba, 0x80, 0xe8, 0xdf, 0xfb, 0xc9, 0xa2, 0xb0, + 0xe8, 0x7e, 0xb4, 0x6c, 0xe1, 0xfd, 0x54, 0x77, 0xde, 0xdd, 0xfd, 0x31, 0xb5, 0x8d, 0xe3, 0xa9, + 0x6d, 0xfc, 0x9e, 0xda, 0xc6, 0xd7, 0x99, 0x5d, 0x3b, 0x9e, 0xd9, 0xb5, 0x5f, 0x33, 0xbb, 0xb6, + 0xf7, 0x38, 0x24, 0x72, 0x98, 0xf8, 0x4e, 0xc0, 0x22, 0xf7, 0xcd, 0xa7, 0x0f, 0xaf, 0xde, 0x62, + 0x79, 0xc8, 0xf8, 0xc8, 0x0d, 0x86, 0x90, 0x50, 0xf7, 0xa8, 0xf8, 0x69, 0xcb, 0x49, 0x8c, 0x85, + 0xdf, 0x54, 0xff, 0xdf, 0xa7, 0x7f, 0x03, 0x00, 0x00, 0xff, 0xff, 0x1d, 0xaa, 0xbb, 0x16, 0xd1, + 0x05, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// MsgClient is the client API for Msg service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type MsgClient interface { + // CreateFunder ... + CreateFunder(ctx context.Context, in *MsgCreateFunder, opts ...grpc.CallOption) (*MsgCreateFunderResponse, error) + // UpdateFunder ... + UpdateFunder(ctx context.Context, in *MsgUpdateFunder, opts ...grpc.CallOption) (*MsgUpdateFunderResponse, error) + // FundPool ... + FundPool(ctx context.Context, in *MsgFundPool, opts ...grpc.CallOption) (*MsgFundPoolResponse, error) + // DefundPool ... + DefundPool(ctx context.Context, in *MsgDefundPool, opts ...grpc.CallOption) (*MsgDefundPoolResponse, error) + // UpdateParams defines a governance operation for updating the x/delegation module + // parameters. The authority is hard-coded to the x/gov module account. + UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) +} + +type msgClient struct { + cc grpc1.ClientConn +} + +func NewMsgClient(cc grpc1.ClientConn) MsgClient { + return &msgClient{cc} +} + +func (c *msgClient) CreateFunder(ctx context.Context, in *MsgCreateFunder, opts ...grpc.CallOption) (*MsgCreateFunderResponse, error) { + out := new(MsgCreateFunderResponse) + err := c.cc.Invoke(ctx, "/kyve.funders.v1beta1.Msg/CreateFunder", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) UpdateFunder(ctx context.Context, in *MsgUpdateFunder, opts ...grpc.CallOption) (*MsgUpdateFunderResponse, error) { + out := new(MsgUpdateFunderResponse) + err := c.cc.Invoke(ctx, "/kyve.funders.v1beta1.Msg/UpdateFunder", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) FundPool(ctx context.Context, in *MsgFundPool, opts ...grpc.CallOption) (*MsgFundPoolResponse, error) { + out := new(MsgFundPoolResponse) + err := c.cc.Invoke(ctx, "/kyve.funders.v1beta1.Msg/FundPool", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) DefundPool(ctx context.Context, in *MsgDefundPool, opts ...grpc.CallOption) (*MsgDefundPoolResponse, error) { + out := new(MsgDefundPoolResponse) + err := c.cc.Invoke(ctx, "/kyve.funders.v1beta1.Msg/DefundPool", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) { + out := new(MsgUpdateParamsResponse) + err := c.cc.Invoke(ctx, "/kyve.funders.v1beta1.Msg/UpdateParams", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// MsgServer is the server API for Msg service. +type MsgServer interface { + // CreateFunder ... + CreateFunder(context.Context, *MsgCreateFunder) (*MsgCreateFunderResponse, error) + // UpdateFunder ... + UpdateFunder(context.Context, *MsgUpdateFunder) (*MsgUpdateFunderResponse, error) + // FundPool ... + FundPool(context.Context, *MsgFundPool) (*MsgFundPoolResponse, error) + // DefundPool ... + DefundPool(context.Context, *MsgDefundPool) (*MsgDefundPoolResponse, error) + // UpdateParams defines a governance operation for updating the x/delegation module + // parameters. The authority is hard-coded to the x/gov module account. + UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error) +} + +// UnimplementedMsgServer can be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { +} + +func (*UnimplementedMsgServer) CreateFunder(ctx context.Context, req *MsgCreateFunder) (*MsgCreateFunderResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CreateFunder not implemented") +} +func (*UnimplementedMsgServer) UpdateFunder(ctx context.Context, req *MsgUpdateFunder) (*MsgUpdateFunderResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateFunder not implemented") +} +func (*UnimplementedMsgServer) FundPool(ctx context.Context, req *MsgFundPool) (*MsgFundPoolResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method FundPool not implemented") +} +func (*UnimplementedMsgServer) DefundPool(ctx context.Context, req *MsgDefundPool) (*MsgDefundPoolResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method DefundPool not implemented") +} +func (*UnimplementedMsgServer) UpdateParams(ctx context.Context, req *MsgUpdateParams) (*MsgUpdateParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateParams not implemented") +} + +func RegisterMsgServer(s grpc1.Server, srv MsgServer) { + s.RegisterService(&_Msg_serviceDesc, srv) +} + +func _Msg_CreateFunder_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgCreateFunder) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).CreateFunder(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/kyve.funders.v1beta1.Msg/CreateFunder", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).CreateFunder(ctx, req.(*MsgCreateFunder)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_UpdateFunder_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpdateFunder) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).UpdateFunder(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/kyve.funders.v1beta1.Msg/UpdateFunder", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UpdateFunder(ctx, req.(*MsgUpdateFunder)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_FundPool_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgFundPool) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).FundPool(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/kyve.funders.v1beta1.Msg/FundPool", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).FundPool(ctx, req.(*MsgFundPool)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_DefundPool_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgDefundPool) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).DefundPool(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/kyve.funders.v1beta1.Msg/DefundPool", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).DefundPool(ctx, req.(*MsgDefundPool)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_UpdateParams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpdateParams) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).UpdateParams(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/kyve.funders.v1beta1.Msg/UpdateParams", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UpdateParams(ctx, req.(*MsgUpdateParams)) + } + return interceptor(ctx, in, info, handler) +} + +var _Msg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "kyve.funders.v1beta1.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "CreateFunder", + Handler: _Msg_CreateFunder_Handler, + }, + { + MethodName: "UpdateFunder", + Handler: _Msg_UpdateFunder_Handler, + }, + { + MethodName: "FundPool", + Handler: _Msg_FundPool_Handler, + }, + { + MethodName: "DefundPool", + Handler: _Msg_DefundPool_Handler, + }, + { + MethodName: "UpdateParams", + Handler: _Msg_UpdateParams_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "kyve/funders/v1beta1/tx.proto", +} + +func (m *MsgCreateFunder) 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 *MsgCreateFunder) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCreateFunder) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Description) > 0 { + i -= len(m.Description) + copy(dAtA[i:], m.Description) + i = encodeVarintTx(dAtA, i, uint64(len(m.Description))) + i-- + dAtA[i] = 0x32 + } + if len(m.Contact) > 0 { + i -= len(m.Contact) + copy(dAtA[i:], m.Contact) + i = encodeVarintTx(dAtA, i, uint64(len(m.Contact))) + i-- + dAtA[i] = 0x2a + } + if len(m.Website) > 0 { + i -= len(m.Website) + copy(dAtA[i:], m.Website) + i = encodeVarintTx(dAtA, i, uint64(len(m.Website))) + i-- + dAtA[i] = 0x22 + } + if len(m.Identity) > 0 { + i -= len(m.Identity) + copy(dAtA[i:], m.Identity) + i = encodeVarintTx(dAtA, i, uint64(len(m.Identity))) + i-- + dAtA[i] = 0x1a + } + if len(m.Moniker) > 0 { + i -= len(m.Moniker) + copy(dAtA[i:], m.Moniker) + i = encodeVarintTx(dAtA, i, uint64(len(m.Moniker))) + i-- + dAtA[i] = 0x12 + } + if len(m.Creator) > 0 { + i -= len(m.Creator) + copy(dAtA[i:], m.Creator) + i = encodeVarintTx(dAtA, i, uint64(len(m.Creator))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgCreateFunderResponse) 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 *MsgCreateFunderResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCreateFunderResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgUpdateFunder) 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 *MsgUpdateFunder) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateFunder) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Description) > 0 { + i -= len(m.Description) + copy(dAtA[i:], m.Description) + i = encodeVarintTx(dAtA, i, uint64(len(m.Description))) + i-- + dAtA[i] = 0x32 + } + if len(m.Contact) > 0 { + i -= len(m.Contact) + copy(dAtA[i:], m.Contact) + i = encodeVarintTx(dAtA, i, uint64(len(m.Contact))) + i-- + dAtA[i] = 0x2a + } + if len(m.Website) > 0 { + i -= len(m.Website) + copy(dAtA[i:], m.Website) + i = encodeVarintTx(dAtA, i, uint64(len(m.Website))) + i-- + dAtA[i] = 0x22 + } + if len(m.Identity) > 0 { + i -= len(m.Identity) + copy(dAtA[i:], m.Identity) + i = encodeVarintTx(dAtA, i, uint64(len(m.Identity))) + i-- + dAtA[i] = 0x1a + } + if len(m.Moniker) > 0 { + i -= len(m.Moniker) + copy(dAtA[i:], m.Moniker) + i = encodeVarintTx(dAtA, i, uint64(len(m.Moniker))) + i-- + dAtA[i] = 0x12 + } + if len(m.Creator) > 0 { + i -= len(m.Creator) + copy(dAtA[i:], m.Creator) + i = encodeVarintTx(dAtA, i, uint64(len(m.Creator))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgUpdateFunderResponse) 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 *MsgUpdateFunderResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateFunderResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgFundPool) 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 *MsgFundPool) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgFundPool) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.AmountPerBundle != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.AmountPerBundle)) + i-- + dAtA[i] = 0x20 + } + if m.Amount != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.Amount)) + i-- + dAtA[i] = 0x18 + } + if m.PoolId != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.PoolId)) + i-- + dAtA[i] = 0x10 + } + if len(m.Creator) > 0 { + i -= len(m.Creator) + copy(dAtA[i:], m.Creator) + i = encodeVarintTx(dAtA, i, uint64(len(m.Creator))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgFundPoolResponse) 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 *MsgFundPoolResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgFundPoolResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgDefundPool) 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 *MsgDefundPool) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgDefundPool) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Amount != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.Amount)) + i-- + dAtA[i] = 0x18 + } + if m.PoolId != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.PoolId)) + i-- + dAtA[i] = 0x10 + } + if len(m.Creator) > 0 { + i -= len(m.Creator) + copy(dAtA[i:], m.Creator) + i = encodeVarintTx(dAtA, i, uint64(len(m.Creator))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgDefundPoolResponse) 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 *MsgDefundPoolResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgDefundPoolResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgUpdateParams) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgUpdateParams) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Payload) > 0 { + i -= len(m.Payload) + copy(dAtA[i:], m.Payload) + i = encodeVarintTx(dAtA, i, uint64(len(m.Payload))) + i-- + dAtA[i] = 0x12 + } + if len(m.Authority) > 0 { + i -= len(m.Authority) + copy(dAtA[i:], m.Authority) + i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgUpdateParamsResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgUpdateParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func encodeVarintTx(dAtA []byte, offset int, v uint64) int { + offset -= sovTx(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *MsgCreateFunder) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Creator) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Moniker) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Identity) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Website) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Contact) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Description) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgCreateFunderResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgUpdateFunder) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Creator) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Moniker) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Identity) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Website) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Contact) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Description) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgUpdateFunderResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgFundPool) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Creator) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.PoolId != 0 { + n += 1 + sovTx(uint64(m.PoolId)) + } + if m.Amount != 0 { + n += 1 + sovTx(uint64(m.Amount)) + } + if m.AmountPerBundle != 0 { + n += 1 + sovTx(uint64(m.AmountPerBundle)) + } + return n +} + +func (m *MsgFundPoolResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgDefundPool) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Creator) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.PoolId != 0 { + n += 1 + sovTx(uint64(m.PoolId)) + } + if m.Amount != 0 { + n += 1 + sovTx(uint64(m.Amount)) + } + return n +} + +func (m *MsgDefundPoolResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgUpdateParams) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Authority) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Payload) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgUpdateParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func sovTx(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozTx(x uint64) (n int) { + return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *MsgCreateFunder) 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: MsgCreateFunder: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCreateFunder: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType) + } + var 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.Creator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Moniker", 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.Moniker = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Identity", 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.Identity = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Website", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Website = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Contact", 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.Contact = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Description = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + 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 *MsgCreateFunderResponse) 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: MsgCreateFunderResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCreateFunderResponse: 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 *MsgUpdateFunder) 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: MsgUpdateFunder: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateFunder: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType) + } + var 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.Creator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Moniker", 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.Moniker = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Identity", 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.Identity = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Website", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Website = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Contact", 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.Contact = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Description = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + 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 *MsgUpdateFunderResponse) 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: MsgUpdateFunderResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateFunderResponse: 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 *MsgFundPool) 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: MsgFundPool: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgFundPool: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType) + } + var 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.Creator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PoolId", wireType) + } + m.PoolId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PoolId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + m.Amount = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Amount |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field AmountPerBundle", wireType) + } + m.AmountPerBundle = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.AmountPerBundle |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgFundPoolResponse) 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: MsgFundPoolResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgFundPoolResponse: 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 *MsgDefundPool) 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: MsgDefundPool: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgDefundPool: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType) + } + var 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.Creator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PoolId", wireType) + } + m.PoolId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PoolId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + m.Amount = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Amount |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgDefundPoolResponse) 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: MsgDefundPoolResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgDefundPoolResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUpdateParams) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgUpdateParams: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateParams: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Authority", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Authority = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Payload", 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.Payload = 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 *MsgUpdateParamsResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgUpdateParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipTx(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthTx + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupTx + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthTx + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthTx = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowTx = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupTx = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/funders/types/types.go b/x/funders/types/types.go new file mode 100644 index 00000000..ab1254f4 --- /dev/null +++ b/x/funders/types/types.go @@ -0,0 +1 @@ +package types diff --git a/x/funders/types/types_test.go b/x/funders/types/types_test.go new file mode 100644 index 00000000..28251e21 --- /dev/null +++ b/x/funders/types/types_test.go @@ -0,0 +1,16 @@ +package types_test + +import ( + "fmt" + "testing" + + "github.com/KYVENetwork/chain/x/team/types" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" +) + +func TestTeamKeeper(t *testing.T) { + RegisterFailHandler(Fail) + RunSpecs(t, fmt.Sprintf("x/%s Types Test Suite", types.ModuleName)) +} diff --git a/x/pool/client/cli/tx.go b/x/pool/client/cli/tx.go index bc7c3b03..a6298b9c 100644 --- a/x/pool/client/cli/tx.go +++ b/x/pool/client/cli/tx.go @@ -18,8 +18,5 @@ func GetTxCmd() *cobra.Command { RunE: client.ValidateCmd, } - cmd.AddCommand(CmdFundPool()) - cmd.AddCommand(CmdDefundPool()) - return cmd } diff --git a/x/pool/keeper/keeper.go b/x/pool/keeper/keeper.go index bf73b53f..64c15511 100644 --- a/x/pool/keeper/keeper.go +++ b/x/pool/keeper/keeper.go @@ -8,8 +8,6 @@ import ( storeTypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" - // Auth - authKeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" authTypes "github.com/cosmos/cosmos-sdk/x/auth/types" // Bank bankKeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" @@ -32,12 +30,13 @@ type ( authority string stakersKeeper types.StakersKeeper - accountKeeper authKeeper.AccountKeeper + accountKeeper types.AccountKeeper bankKeeper bankKeeper.Keeper distrkeeper distributionKeeper.Keeper mintKeeper mintKeeper.Keeper upgradeKeeper types.UpgradeKeeper teamKeeper teamKeeper.Keeper + fundersKeeper types.FundersKeeper } ) @@ -48,7 +47,7 @@ func NewKeeper( authority string, - accountKeeper authKeeper.AccountKeeper, + accountKeeper types.AccountKeeper, bankKeeper bankKeeper.Keeper, distrKeeper distributionKeeper.Keeper, mintKeeper mintKeeper.Keeper, @@ -94,6 +93,10 @@ func SetStakersKeeper(k *Keeper, stakersKeeper types.StakersKeeper) { k.stakersKeeper = stakersKeeper } +func SetFundersKeeper(k *Keeper, fundersKeeper types.FundersKeeper) { + k.fundersKeeper = fundersKeeper +} + func (k Keeper) Logger(ctx sdk.Context) log.Logger { return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) } diff --git a/x/pool/keeper/keeper_utils_test.go b/x/pool/keeper/keeper_utils_test.go index f13f8866..49142dc4 100644 --- a/x/pool/keeper/keeper_utils_test.go +++ b/x/pool/keeper/keeper_utils_test.go @@ -2,6 +2,7 @@ package keeper_test import ( i "github.com/KYVENetwork/chain/testutil/integration" + "github.com/KYVENetwork/chain/x/pool/types" sdk "github.com/cosmos/cosmos-sdk/types" govV1Types "github.com/cosmos/cosmos-sdk/x/gov/types/v1" ) @@ -23,3 +24,22 @@ func BuildGovernanceTxs(s *i.KeeperTestSuite, msgs []sdk.Msg) (govV1Types.MsgSub return *proposal, *vote } + +func createPoolWithEmptyValues(s *i.KeeperTestSuite) { + gov := s.App().GovKeeper.GetGovernanceAccount(s.Ctx()).GetAddress().String() + msg := &types.MsgCreatePool{ + Authority: gov, + UploadInterval: 60, + MaxBundleSize: 100, + Binaries: "{}", + } + s.RunTxPoolSuccess(msg) + + poolId := s.App().PoolKeeper.GetPoolCount(s.Ctx()) - 1 + pool, _ := s.App().PoolKeeper.GetPool(s.Ctx(), poolId) + pool.UploadInterval = 0 + pool.MaxBundleSize = 0 + pool.Protocol = &types.Protocol{} + pool.UpgradePlan = &types.UpgradePlan{} + s.App().PoolKeeper.SetPool(s.Ctx(), pool) +} diff --git a/x/pool/keeper/logic_end_block_handle_pool_upgrades_test.go b/x/pool/keeper/logic_end_block_handle_pool_upgrades_test.go index 416361ce..4d05d370 100644 --- a/x/pool/keeper/logic_end_block_handle_pool_upgrades_test.go +++ b/x/pool/keeper/logic_end_block_handle_pool_upgrades_test.go @@ -28,20 +28,24 @@ var _ = Describe("logic_end_block_handle_pool_upgrades.go", Ordered, func() { s = i.NewCleanChain() // create clean pool for every test case - s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{ - Name: "PoolTest", - MaxBundleSize: 100, - StartKey: "0", - MinDelegation: 100 * i.KYVE, - UploadInterval: 60, - OperatingCost: 10_000, - Protocol: &pooltypes.Protocol{ - Version: "0.0.0", - Binaries: "{}", - LastUpgrade: uint64(s.Ctx().BlockTime().Unix()), - }, - UpgradePlan: &pooltypes.UpgradePlan{}, - }) + gov := s.App().GovKeeper.GetGovernanceAccount(s.Ctx()).GetAddress().String() + msg := &pooltypes.MsgCreatePool{ + Authority: gov, + Name: "PoolTest", + Runtime: "@kyve/test", + Logo: "ar://Tewyv2P5VEG8EJ6AUQORdqNTectY9hlOrWPK8wwo-aU", + Config: "ar://DgdB-2hLrxjhyEEbCML__dgZN5_uS7T6Z5XDkaFh3P0", + StartKey: "0", + UploadInterval: 60, + InflationShareWeight: 10_000, + MinDelegation: 100 * i.KYVE, + MaxBundleSize: 100, + Version: "0.0.0", + Binaries: "{}", + StorageProviderId: 2, + CompressionId: 1, + } + s.RunTxPoolSuccess(msg) }) AfterEach(func() { diff --git a/x/pool/keeper/logic_funders.go b/x/pool/keeper/logic_funders.go deleted file mode 100644 index d5ad55d1..00000000 --- a/x/pool/keeper/logic_funders.go +++ /dev/null @@ -1,64 +0,0 @@ -package keeper - -import ( - poolTypes "github.com/KYVENetwork/chain/x/pool/types" - sdk "github.com/cosmos/cosmos-sdk/types" -) - -// ChargeFundersOfPool equally splits the amount between all funders and removes -// the appropriate amount from each funder. -// All funders who can't afford the amount, are kicked out. -// Their remaining amount is transferred to the Treasury. -// This method does not transfer any funds. The bundles-module -// is responsible for transferring the rewards out of the module. -func (k Keeper) ChargeFundersOfPool(ctx sdk.Context, poolId uint64, amount uint64) (payout uint64, err error) { - pool, poolErr := k.GetPoolWithError(ctx, poolId) - if poolErr != nil { - return 0, poolErr - } - - // if pool has no funders we immediately return - if len(pool.Funders) == 0 { - return payout, err - } - - // This is the amount every funder will be charged - amountPerFunder := amount / uint64(len(pool.Funders)) - - // Due to discrete division there will be a reminder which can not be split - // equally among all funders. This amount is charged to the lowest funder - amountRemainder := amount - amountPerFunder*uint64(len(pool.Funders)) - - funders := pool.Funders - - for _, funder := range funders { - if funder.Amount < amountPerFunder { - pool.RemoveFunder(funder.Address) - payout += funder.Amount - } else { - pool.SubtractAmountFromFunder(funder.Address, amountPerFunder) - payout += amountPerFunder - } - } - - lowestFunder := pool.GetLowestFunder() - - if lowestFunder.Address != "" { - if lowestFunder.Amount < amountRemainder { - pool.RemoveFunder(lowestFunder.Address) - payout += lowestFunder.Amount - } else { - pool.SubtractAmountFromFunder(lowestFunder.Address, amountRemainder) - payout += amountRemainder - } - } - - if len(pool.Funders) == 0 { - _ = ctx.EventManager().EmitTypedEvent(&poolTypes.EventPoolOutOfFunds{ - PoolId: pool.Id, - }) - } - - k.SetPool(ctx, pool) - return payout, nil -} diff --git a/x/pool/keeper/logic_funders_test.go b/x/pool/keeper/logic_funders_test.go deleted file mode 100644 index ebb83291..00000000 --- a/x/pool/keeper/logic_funders_test.go +++ /dev/null @@ -1,314 +0,0 @@ -package keeper_test - -import ( - i "github.com/KYVENetwork/chain/testutil/integration" - "github.com/KYVENetwork/chain/util" - pooltypes "github.com/KYVENetwork/chain/x/pool/types" - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" -) - -/* - -TEST CASES - logic_funders.go - -* Add funders; check total sum -* Add multiple funders; check total sum -* Remove funder -* Remove funder by defunding everything -* Charge Funders with equal amounts -* Charge Funders test remainder -* Charge exactly the lowest funder amount -* Kick out multiple lowest funders -* Charge more than pool has funds -* Charge pool which has no funds at all - -*/ - -func chargeFunders(s *i.KeeperTestSuite, amount uint64) (payout uint64, err error) { - payout, err = s.App().PoolKeeper.ChargeFundersOfPool(s.Ctx(), 0, amount) - if err != nil { - return 0, err - } - - if err := util.TransferFromModuleToAddress(s.App().BankKeeper, s.Ctx(), pooltypes.ModuleName, i.BURNER, payout); err != nil { - return 0, err - } - - return payout, err -} - -func fundersCheck(pool *pooltypes.Pool) { - poolFunds := uint64(0) - funders := make(map[string]bool) - for _, funder := range pool.Funders { - Expect(funders[funder.Address]).To(BeFalse()) - funders[funder.Address] = true - poolFunds += funder.Amount - } - Expect(pool.TotalFunds).To(Equal(poolFunds)) -} - -var _ = Describe("logic_funders.go", Ordered, func() { - s := i.NewCleanChain() - var pool *pooltypes.Pool - - BeforeEach(func() { - s = i.NewCleanChain() - pool = &pooltypes.Pool{ - Name: "PoolTest", - MaxBundleSize: 100, - StartKey: "0", - MinDelegation: 100 * i.KYVE, - UploadInterval: 60, - OperatingCost: 10_000, - UpgradePlan: &pooltypes.UpgradePlan{}, - } - - s.App().PoolKeeper.AppendPool(s.Ctx(), *pool) - }) - - AfterEach(func() { - fundersCheck(pool) - s.PerformValidityChecks() - }) - - It("Add funders; check total sum", func() { - // ACT - pool.AddAmountToFunder(i.ALICE, 1000) - pool.AddAmountToFunder(i.ALICE, 2000) - pool.AddAmountToFunder(i.ALICE, 0) - pool.AddAmountToFunder(i.BOB, 0) - pool.AddAmountToFunder(i.ALICE, 10) - - // ASSERT - Expect(pool.TotalFunds).To(Equal(uint64(3010))) - Expect(pool.Funders).To(HaveLen(1)) - }) - - It("Add multiple funders; check total sum", func() { - // ACT - pool.AddAmountToFunder(i.ALICE, 1000) - pool.AddAmountToFunder(i.ALICE, 2000) - pool.AddAmountToFunder(i.ALICE, 0) - pool.AddAmountToFunder(i.BOB, 1000) - pool.AddAmountToFunder(i.ALICE, 10) - - // ASSERT - Expect(pool.TotalFunds).To(Equal(uint64(4010))) - Expect(pool.Funders).To(HaveLen(2)) - }) - - It("Remove funder", func() { - // ARRANGE - pool.AddAmountToFunder(i.ALICE, 1000) - pool.AddAmountToFunder(i.ALICE, 2000) - pool.AddAmountToFunder(i.ALICE, 0) - pool.AddAmountToFunder(i.BOB, 0) - pool.AddAmountToFunder(i.ALICE, 10) - pool.AddAmountToFunder(i.CHARLIE, 500) - - Expect(pool.TotalFunds).To(Equal(uint64(3510))) - - // ACT - // Alice: 3010 - // Charlie: 500 - pool.RemoveFunder(i.CHARLIE) - - // ASSERT - Expect(pool.TotalFunds).To(Equal(uint64(3010))) - Expect(pool.Funders).To(HaveLen(1)) - }) - - It("Remove funder by defunding everything", func() { - // ARRANGE - pool.AddAmountToFunder(i.ALICE, 1000) - pool.AddAmountToFunder(i.ALICE, 2000) - pool.AddAmountToFunder(i.ALICE, 0) - pool.AddAmountToFunder(i.BOB, 0) - pool.AddAmountToFunder(i.ALICE, 10) - pool.AddAmountToFunder(i.CHARLIE, 500) - - // ACT - // Alice: 3010 - // Charlie: 500 - pool.SubtractAmountFromFunder(i.ALICE, 3010) - - // ASSERT - Expect(pool.TotalFunds).To(Equal(uint64(500))) - Expect(pool.Funders).To(HaveLen(1)) - }) - - It("Charge Funders with equal amounts", func() { - // ARRANGE - for k := 0; k < 50; k++ { - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ - Creator: i.DUMMY[k], - Id: 0, - Amount: 100 * i.KYVE, - }) - } - pool, poolFound := s.App().PoolKeeper.GetPool(s.Ctx(), 0) - Expect(poolFound).To(BeTrue()) - Expect(pool.TotalFunds).To(Equal(50 * 100 * i.KYVE)) - - // ACT - payout, err := chargeFunders(s, 50*10*i.KYVE) - - // ASSERT - Expect(err).NotTo(HaveOccurred()) - Expect(payout).To(Equal(50 * 10 * i.KYVE)) - - pool, _ = s.App().PoolKeeper.GetPool(s.Ctx(), 0) - Expect(pool.TotalFunds).To(Equal(50 * 90 * i.KYVE)) - - for _, funder := range pool.Funders { - Expect(funder.Amount).To(Equal(90 * i.KYVE)) - } - }) - - It("Charge Funders test remainder", func() { - // ARRANGE - for k := 0; k < 50; k++ { - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ - Creator: i.DUMMY[k], - Id: 0, - Amount: 100 * i.KYVE, - }) - } - pool, poolFound := s.App().PoolKeeper.GetPool(s.Ctx(), 0) - Expect(poolFound).To(BeTrue()) - Expect(pool.TotalFunds).To(Equal(50 * 100 * i.KYVE)) - - // ACT - // Charge 10 $KYVE + 49tkyve - // the 49 tkyve will be charged to the lowest funder - payout, err := chargeFunders(s, 50*10*i.KYVE+49) - - // ASSERT - Expect(err).NotTo(HaveOccurred()) - Expect(payout).To(Equal(50*10*i.KYVE + 49)) - - pool, _ = s.App().PoolKeeper.GetPool(s.Ctx(), 0) - - for _, funder := range pool.Funders { - if pool.GetLowestFunder().Address == funder.Address { - Expect(funder.Amount).To(Equal(90*i.KYVE - 49)) - } else { - Expect(funder.Amount).To(Equal(90 * i.KYVE)) - } - } - }) - - It("Charge exactly lowest funder amount", func() { - // ARRANGE - for k := 0; k < 40; k++ { - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ - Creator: i.DUMMY[k], - Id: 0, - Amount: 100 * i.KYVE, - }) - } - for k := 0; k < 10; k++ { - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ - Creator: i.DUMMY[40+k], - Id: 0, - Amount: 200 * i.KYVE, - }) - } - pool, poolFound := s.App().PoolKeeper.GetPool(s.Ctx(), 0) - Expect(poolFound).To(BeTrue()) - Expect(pool.TotalFunds).To(Equal((100*40 + 200*10) * i.KYVE)) - - // ACT - payout, err := chargeFunders(s, 50*100*i.KYVE) - - // ASSERT - Expect(err).NotTo(HaveOccurred()) - Expect(payout).To(Equal(50 * 100 * i.KYVE)) - - pool, _ = s.App().PoolKeeper.GetPool(s.Ctx(), 0) - Expect(pool.Funders).To(HaveLen(10)) - }) - - It("Kick out multiple lowest funders", func() { - // Arrange - for k := 0; k < 40; k++ { - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ - Creator: i.DUMMY[k], - Id: 0, - Amount: 50 * i.KYVE, - }) - } - for k := 0; k < 10; k++ { - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ - Creator: i.DUMMY[40+k], - Id: 0, - Amount: 1000 * i.KYVE, - }) - } - pool, poolFound := s.App().PoolKeeper.GetPool(s.Ctx(), 0) - Expect(poolFound).To(BeTrue()) - Expect(pool.TotalFunds).To(Equal((50*40 + 1000*10) * i.KYVE)) - - // 40 * 50 = 2000 - // 10 * 1000 = 10000 - // Charge 5000 - - // Act - payout, err := chargeFunders(s, 5000*i.KYVE) - - // Assert - Expect(err).NotTo(HaveOccurred()) - Expect(payout).To(Equal(3000 * i.KYVE)) - - pool, _ = s.App().PoolKeeper.GetPool(s.Ctx(), 0) - Expect(pool.Funders).To(HaveLen(10)) - - for _, funder := range pool.Funders { - Expect(funder.Amount).To(Equal(900 * i.KYVE)) - } - }) - - It("Charge more than pool has funds", func() { - // ARRANGE - for k := 0; k < 50; k++ { - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ - Creator: i.DUMMY[k], - Id: 0, - Amount: 50 * i.KYVE, - }) - } - pool, poolFound := s.App().PoolKeeper.GetPool(s.Ctx(), 0) - Expect(poolFound).To(BeTrue()) - Expect(pool.TotalFunds).To(Equal((50 * 50) * i.KYVE)) - - // ACT - payout, err := chargeFunders(s, 5000*i.KYVE) - - // ASSERT - Expect(err).NotTo(HaveOccurred()) - Expect(payout).To(Equal(2500 * i.KYVE)) - - pool, _ = s.App().PoolKeeper.GetPool(s.Ctx(), 0) - Expect(pool.Funders).To(HaveLen(0)) - }) - - It("Charge pool which has no funds at all", func() { - // ARRANGE - pool, poolFound := s.App().PoolKeeper.GetPool(s.Ctx(), 0) - Expect(poolFound).To(BeTrue()) - Expect(pool.TotalFunds).To(BeZero()) - - // ACT - payout, err := chargeFunders(s, 5000*i.KYVE) - - // ASSERT - Expect(err).NotTo(HaveOccurred()) - Expect(payout).To(BeZero()) - - pool, _ = s.App().PoolKeeper.GetPool(s.Ctx(), 0) - Expect(pool.Funders).To(HaveLen(0)) - Expect(pool.TotalFunds).To(BeZero()) - }) -}) diff --git a/x/pool/keeper/msg_server_cancel_runtime_upgrade_test.go b/x/pool/keeper/msg_server_cancel_runtime_upgrade_test.go index 2924ccfe..731dde43 100644 --- a/x/pool/keeper/msg_server_cancel_runtime_upgrade_test.go +++ b/x/pool/keeper/msg_server_cancel_runtime_upgrade_test.go @@ -30,18 +30,23 @@ var _ = Describe("msg_server_cancel_runtime_upgrade.go", Ordered, func() { gov := s.App().GovKeeper.GetGovernanceAccount(s.Ctx()).GetAddress().String() votingPeriod := s.App().GovKeeper.GetParams(s.Ctx()).VotingPeriod + var currentTime uint64 + BeforeEach(func() { s = i.NewCleanChain() - s.App().PoolKeeper.AppendPool(s.Ctx(), types.Pool{ - Runtime: "@kyve/test", - Protocol: &types.Protocol{ - Version: "0.0.0", - Binaries: "{\"linux\":\"test\"}", - LastUpgrade: 0, - }, - UpgradePlan: &types.UpgradePlan{}, - }) + createPoolWithEmptyValues(s) + pool, _ := s.App().PoolKeeper.GetPool(s.Ctx(), 0) + pool.UpgradePlan = &types.UpgradePlan{} + pool.Protocol = &types.Protocol{ + Version: "0.0.0", + Binaries: "{\"linux\":\"test\"}", + LastUpgrade: 0, + } + pool.Runtime = "@kyve/test" + s.App().PoolKeeper.SetPool(s.Ctx(), pool) + + currentTime = uint64(time.Now().Unix()) }) AfterEach(func() { @@ -86,7 +91,7 @@ var _ = Describe("msg_server_cancel_runtime_upgrade.go", Ordered, func() { Version: "1.0.0", Binaries: "{}", Duration: 60, - ScheduledAt: uint64(time.Now().Unix()) + 7*24*3600, + ScheduledAt: currentTime + 7*24*3600, } p, v := BuildGovernanceTxs(s, []sdk.Msg{msg}) @@ -138,7 +143,7 @@ var _ = Describe("msg_server_cancel_runtime_upgrade.go", Ordered, func() { Version: "1.0.0", Binaries: "{}", Duration: 60, - ScheduledAt: uint64(time.Now().Unix()), + ScheduledAt: currentTime, } p, v := BuildGovernanceTxs(s, []sdk.Msg{msg}) diff --git a/x/pool/keeper/msg_server_create_pool.go b/x/pool/keeper/msg_server_create_pool.go index f69d29c8..2aaa5ee4 100644 --- a/x/pool/keeper/msg_server_create_pool.go +++ b/x/pool/keeper/msg_server_create_pool.go @@ -27,15 +27,15 @@ func (k msgServer) CreatePool(goCtx context.Context, req *types.MsgCreatePool) ( ctx := sdk.UnwrapSDKContext(goCtx) id := k.AppendPool(ctx, types.Pool{ - Name: req.Name, - Runtime: req.Runtime, - Logo: req.Logo, - Config: req.Config, - StartKey: req.StartKey, - UploadInterval: req.UploadInterval, - OperatingCost: req.OperatingCost, - MinDelegation: req.MinDelegation, - MaxBundleSize: req.MaxBundleSize, + Name: req.Name, + Runtime: req.Runtime, + Logo: req.Logo, + Config: req.Config, + StartKey: req.StartKey, + UploadInterval: req.UploadInterval, + InflationShareWeight: req.InflationShareWeight, + MinDelegation: req.MinDelegation, + MaxBundleSize: req.MaxBundleSize, Protocol: &types.Protocol{ Version: req.Version, Binaries: req.Binaries, @@ -47,22 +47,23 @@ func (k msgServer) CreatePool(goCtx context.Context, req *types.MsgCreatePool) ( }) k.EnsurePoolAccount(ctx, id) + k.fundersKeeper.CreateFundingState(ctx, id) _ = ctx.EventManager().EmitTypedEvent(&types.EventCreatePool{ - Id: k.GetPoolCount(ctx) - 1, - Name: req.Name, - Runtime: req.Runtime, - Logo: req.Logo, - Config: req.Config, - StartKey: req.StartKey, - UploadInterval: req.UploadInterval, - OperatingCost: req.OperatingCost, - MinDelegation: req.MinDelegation, - MaxBundleSize: req.MaxBundleSize, - Version: req.Version, - Binaries: req.Binaries, - StorageProviderId: req.StorageProviderId, - CompressionId: req.CompressionId, + Id: k.GetPoolCount(ctx) - 1, + Name: req.Name, + Runtime: req.Runtime, + Logo: req.Logo, + Config: req.Config, + StartKey: req.StartKey, + UploadInterval: req.UploadInterval, + InflationShareWeight: req.InflationShareWeight, + MinDelegation: req.MinDelegation, + MaxBundleSize: req.MaxBundleSize, + Version: req.Version, + Binaries: req.Binaries, + StorageProviderId: req.StorageProviderId, + CompressionId: req.CompressionId, }) return &types.MsgCreatePoolResponse{}, nil diff --git a/x/pool/keeper/msg_server_create_pool_test.go b/x/pool/keeper/msg_server_create_pool_test.go index ae9230aa..22a4a0b1 100644 --- a/x/pool/keeper/msg_server_create_pool_test.go +++ b/x/pool/keeper/msg_server_create_pool_test.go @@ -2,6 +2,7 @@ package keeper_test import ( i "github.com/KYVENetwork/chain/testutil/integration" + funderstypes "github.com/KYVENetwork/chain/x/funders/types" sdk "github.com/cosmos/cosmos-sdk/types" govV1Types "github.com/cosmos/cosmos-sdk/x/gov/types/v1" . "github.com/onsi/ginkgo/v2" @@ -40,20 +41,20 @@ var _ = Describe("msg_server_create_pool.go", Ordered, func() { It("Invalid authority (transaction)", func() { // ARRANGE msg := &types.MsgCreatePool{ - Authority: i.DUMMY[0], - Name: "TestPool", - Runtime: "@kyve/test", - Logo: "ar://Tewyv2P5VEG8EJ6AUQORdqNTectY9hlOrWPK8wwo-aU", - Config: "ar://DgdB-2hLrxjhyEEbCML__dgZN5_uS7T6Z5XDkaFh3P0", - StartKey: "0", - UploadInterval: 60, - OperatingCost: 10000, - MinDelegation: 100 * i.KYVE, - MaxBundleSize: 100, - Version: "0.0.0", - Binaries: "{}", - StorageProviderId: 2, - CompressionId: 1, + Authority: i.DUMMY[0], + Name: "TestPool", + Runtime: "@kyve/test", + Logo: "ar://Tewyv2P5VEG8EJ6AUQORdqNTectY9hlOrWPK8wwo-aU", + Config: "ar://DgdB-2hLrxjhyEEbCML__dgZN5_uS7T6Z5XDkaFh3P0", + StartKey: "0", + UploadInterval: 60, + InflationShareWeight: 10000, + MinDelegation: 100 * i.KYVE, + MaxBundleSize: 100, + Version: "0.0.0", + Binaries: "{}", + StorageProviderId: 2, + CompressionId: 1, } // ACT @@ -66,20 +67,20 @@ var _ = Describe("msg_server_create_pool.go", Ordered, func() { It("Invalid authority (proposal)", func() { // ARRANGE msg := &types.MsgCreatePool{ - Authority: i.DUMMY[0], - Name: "TestPool", - Runtime: "@kyve/test", - Logo: "ar://Tewyv2P5VEG8EJ6AUQORdqNTectY9hlOrWPK8wwo-aU", - Config: "ar://DgdB-2hLrxjhyEEbCML__dgZN5_uS7T6Z5XDkaFh3P0", - StartKey: "0", - UploadInterval: 60, - OperatingCost: 10000, - MinDelegation: 100 * i.KYVE, - MaxBundleSize: 100, - Version: "0.0.0", - Binaries: "{}", - StorageProviderId: 2, - CompressionId: 1, + Authority: i.DUMMY[0], + Name: "TestPool", + Runtime: "@kyve/test", + Logo: "ar://Tewyv2P5VEG8EJ6AUQORdqNTectY9hlOrWPK8wwo-aU", + Config: "ar://DgdB-2hLrxjhyEEbCML__dgZN5_uS7T6Z5XDkaFh3P0", + StartKey: "0", + UploadInterval: 60, + InflationShareWeight: 10000, + MinDelegation: 100 * i.KYVE, + MaxBundleSize: 100, + Version: "0.0.0", + Binaries: "{}", + StorageProviderId: 2, + CompressionId: 1, } proposal, _ := BuildGovernanceTxs(s, []sdk.Msg{msg}) @@ -94,20 +95,20 @@ var _ = Describe("msg_server_create_pool.go", Ordered, func() { It("Create first pool", func() { // ARRANGE msg := &types.MsgCreatePool{ - Authority: gov, - Name: "TestPool", - Runtime: "@kyve/test", - Logo: "ar://Tewyv2P5VEG8EJ6AUQORdqNTectY9hlOrWPK8wwo-aU", - Config: "ar://DgdB-2hLrxjhyEEbCML__dgZN5_uS7T6Z5XDkaFh3P0", - StartKey: "0", - UploadInterval: 60, - OperatingCost: 10000, - MinDelegation: 100 * i.KYVE, - MaxBundleSize: 100, - Version: "0.0.0", - Binaries: "{}", - StorageProviderId: 2, - CompressionId: 1, + Authority: gov, + Name: "TestPool", + Runtime: "@kyve/test", + Logo: "ar://Tewyv2P5VEG8EJ6AUQORdqNTectY9hlOrWPK8wwo-aU", + Config: "ar://DgdB-2hLrxjhyEEbCML__dgZN5_uS7T6Z5XDkaFh3P0", + StartKey: "0", + UploadInterval: 60, + InflationShareWeight: 10000, + MinDelegation: 100 * i.KYVE, + MaxBundleSize: 100, + Version: "0.0.0", + Binaries: "{}", + StorageProviderId: 2, + CompressionId: 1, } p, v := BuildGovernanceTxs(s, []sdk.Msg{msg}) @@ -129,23 +130,21 @@ var _ = Describe("msg_server_create_pool.go", Ordered, func() { pool, _ := s.App().PoolKeeper.GetPool(s.Ctx(), 0) Expect(pool).To(Equal(types.Pool{ - Id: 0, - Name: "TestPool", - Runtime: "@kyve/test", - Logo: "ar://Tewyv2P5VEG8EJ6AUQORdqNTectY9hlOrWPK8wwo-aU", - Config: "ar://DgdB-2hLrxjhyEEbCML__dgZN5_uS7T6Z5XDkaFh3P0", - StartKey: "0", - CurrentKey: "", - CurrentSummary: "", - CurrentIndex: 0, - TotalBundles: 0, - UploadInterval: 60, - OperatingCost: 10000, - MinDelegation: 100 * i.KYVE, - MaxBundleSize: 100, - Disabled: false, - Funders: nil, - TotalFunds: 0, + Id: 0, + Name: "TestPool", + Runtime: "@kyve/test", + Logo: "ar://Tewyv2P5VEG8EJ6AUQORdqNTectY9hlOrWPK8wwo-aU", + Config: "ar://DgdB-2hLrxjhyEEbCML__dgZN5_uS7T6Z5XDkaFh3P0", + StartKey: "0", + CurrentKey: "", + CurrentSummary: "", + CurrentIndex: 0, + TotalBundles: 0, + UploadInterval: 60, + InflationShareWeight: 10000, + MinDelegation: 100 * i.KYVE, + MaxBundleSize: 100, + Disabled: false, Protocol: &types.Protocol{ Version: "0.0.0", Binaries: "{}", @@ -160,25 +159,31 @@ var _ = Describe("msg_server_create_pool.go", Ordered, func() { CurrentStorageProviderId: 2, CurrentCompressionId: 1, })) + + fundingState, _ := s.App().FundersKeeper.GetFundingState(s.Ctx(), 0) + Expect(fundingState).To(Equal(funderstypes.FundingState{ + PoolId: 0, + ActiveFunderAddresses: nil, + })) }) It("Create another pool", func() { // ARRANGE msg := &types.MsgCreatePool{ - Authority: gov, - Name: "TestPool", - Runtime: "@kyve/test", - Logo: "ar://Tewyv2P5VEG8EJ6AUQORdqNTectY9hlOrWPK8wwo-aU", - Config: "ar://DgdB-2hLrxjhyEEbCML__dgZN5_uS7T6Z5XDkaFh3P0", - StartKey: "0", - UploadInterval: 60, - OperatingCost: 10000, - MinDelegation: 100 * i.KYVE, - MaxBundleSize: 100, - Version: "0.0.0", - Binaries: "{}", - StorageProviderId: 2, - CompressionId: 1, + Authority: gov, + Name: "TestPool", + Runtime: "@kyve/test", + Logo: "ar://Tewyv2P5VEG8EJ6AUQORdqNTectY9hlOrWPK8wwo-aU", + Config: "ar://DgdB-2hLrxjhyEEbCML__dgZN5_uS7T6Z5XDkaFh3P0", + StartKey: "0", + UploadInterval: 60, + InflationShareWeight: 10000, + MinDelegation: 100 * i.KYVE, + MaxBundleSize: 100, + Version: "0.0.0", + Binaries: "{}", + StorageProviderId: 2, + CompressionId: 1, } p, v := BuildGovernanceTxs(s, []sdk.Msg{msg}) @@ -198,20 +203,20 @@ var _ = Describe("msg_server_create_pool.go", Ordered, func() { // ACT msg = &types.MsgCreatePool{ - Authority: gov, - Name: "TestPool2", - Runtime: "@kyve/test", - Logo: "ar://Tewyv2P5VEG8EJ6AUQORdqNTectY9hlOrWPK8wwo-aU", - Config: "ar://DgdB-2hLrxjhyEEbCML__dgZN5_uS7T6Z5XDkaFh3P0", - StartKey: "0", - UploadInterval: 60, - OperatingCost: 10000, - MinDelegation: 100 * i.KYVE, - MaxBundleSize: 100, - Version: "0.0.0", - Binaries: "{}", - StorageProviderId: 2, - CompressionId: 1, + Authority: gov, + Name: "TestPool2", + Runtime: "@kyve/test", + Logo: "ar://Tewyv2P5VEG8EJ6AUQORdqNTectY9hlOrWPK8wwo-aU", + Config: "ar://DgdB-2hLrxjhyEEbCML__dgZN5_uS7T6Z5XDkaFh3P0", + StartKey: "0", + UploadInterval: 60, + InflationShareWeight: 10000, + MinDelegation: 100 * i.KYVE, + MaxBundleSize: 100, + Version: "0.0.0", + Binaries: "{}", + StorageProviderId: 2, + CompressionId: 1, } p, v = BuildGovernanceTxs(s, []sdk.Msg{msg}) @@ -232,23 +237,21 @@ var _ = Describe("msg_server_create_pool.go", Ordered, func() { pool, _ := s.App().PoolKeeper.GetPool(s.Ctx(), 1) Expect(pool).To(Equal(types.Pool{ - Id: 1, - Name: "TestPool2", - Runtime: "@kyve/test", - Logo: "ar://Tewyv2P5VEG8EJ6AUQORdqNTectY9hlOrWPK8wwo-aU", - Config: "ar://DgdB-2hLrxjhyEEbCML__dgZN5_uS7T6Z5XDkaFh3P0", - StartKey: "0", - CurrentKey: "", - CurrentSummary: "", - CurrentIndex: 0, - TotalBundles: 0, - UploadInterval: 60, - OperatingCost: 10000, - MinDelegation: 100 * i.KYVE, - MaxBundleSize: 100, - Disabled: false, - Funders: nil, - TotalFunds: 0, + Id: 1, + Name: "TestPool2", + Runtime: "@kyve/test", + Logo: "ar://Tewyv2P5VEG8EJ6AUQORdqNTectY9hlOrWPK8wwo-aU", + Config: "ar://DgdB-2hLrxjhyEEbCML__dgZN5_uS7T6Z5XDkaFh3P0", + StartKey: "0", + CurrentKey: "", + CurrentSummary: "", + CurrentIndex: 0, + TotalBundles: 0, + UploadInterval: 60, + InflationShareWeight: 10000, + MinDelegation: 100 * i.KYVE, + MaxBundleSize: 100, + Disabled: false, Protocol: &types.Protocol{ Version: "0.0.0", Binaries: "{}", @@ -263,25 +266,31 @@ var _ = Describe("msg_server_create_pool.go", Ordered, func() { CurrentStorageProviderId: 2, CurrentCompressionId: 1, })) + + fundingState, _ := s.App().FundersKeeper.GetFundingState(s.Ctx(), 1) + Expect(fundingState).To(Equal(funderstypes.FundingState{ + PoolId: 1, + ActiveFunderAddresses: nil, + })) }) It("Create pool with invalid binaries", func() { // ARRANGE msg := &types.MsgCreatePool{ - Authority: gov, - Name: "TestPool", - Runtime: "@kyve/test", - Logo: "ar://Tewyv2P5VEG8EJ6AUQORdqNTectY9hlOrWPK8wwo-aU", - Config: "ar://DgdB-2hLrxjhyEEbCML__dgZN5_uS7T6Z5XDkaFh3P0", - StartKey: "0", - UploadInterval: 60, - OperatingCost: 10000, - MinDelegation: 100 * i.KYVE, - MaxBundleSize: 100, - Version: "0.0.0", - Binaries: "{", - StorageProviderId: 2, - CompressionId: 1, + Authority: gov, + Name: "TestPool", + Runtime: "@kyve/test", + Logo: "ar://Tewyv2P5VEG8EJ6AUQORdqNTectY9hlOrWPK8wwo-aU", + Config: "ar://DgdB-2hLrxjhyEEbCML__dgZN5_uS7T6Z5XDkaFh3P0", + StartKey: "0", + UploadInterval: 60, + InflationShareWeight: 10000, + MinDelegation: 100 * i.KYVE, + MaxBundleSize: 100, + Version: "0.0.0", + Binaries: "{", + StorageProviderId: 2, + CompressionId: 1, } p, v := BuildGovernanceTxs(s, []sdk.Msg{msg}) @@ -303,5 +312,8 @@ var _ = Describe("msg_server_create_pool.go", Ordered, func() { _, found := s.App().PoolKeeper.GetPool(s.Ctx(), 0) Expect(found).To(BeFalse()) + + _, found = s.App().FundersKeeper.GetFundingState(s.Ctx(), 0) + Expect(found).To(BeFalse()) }) }) diff --git a/x/pool/keeper/msg_server_defund_pool.go b/x/pool/keeper/msg_server_defund_pool.go deleted file mode 100644 index 14dcc8c5..00000000 --- a/x/pool/keeper/msg_server_defund_pool.go +++ /dev/null @@ -1,55 +0,0 @@ -package keeper - -import ( - "context" - - "cosmossdk.io/errors" - "github.com/KYVENetwork/chain/util" - "github.com/KYVENetwork/chain/x/pool/types" - sdk "github.com/cosmos/cosmos-sdk/types" - errorsTypes "github.com/cosmos/cosmos-sdk/types/errors" -) - -// DefundPool handles the logic to defund a pool. -// If the user is a funder, it will subtract the provided amount -// and send the tokens back. If the amount equals the current funding amount -// the funder is removed completely. -func (k msgServer) DefundPool(goCtx context.Context, msg *types.MsgDefundPool) (*types.MsgDefundPoolResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - pool, found := k.GetPool(ctx, msg.Id) - - // Pool has to exist - if !found { - return nil, errors.Wrapf(errorsTypes.ErrNotFound, types.ErrPoolNotFound.Error(), msg.Id) - } - - // Sender needs to be a funder in the pool - funderAmount := pool.GetFunderAmount(msg.Creator) - if funderAmount == 0 { - return nil, errorsTypes.ErrNotFound - } - - // Check if the sender is trying to defund more than they have funded. - if msg.Amount > funderAmount { - return nil, errors.Wrapf(errorsTypes.ErrLogic, types.ErrDefundTooHigh.Error(), msg.Creator) - } - - // Update state variables (or completely remove if fully defunding). - pool.SubtractAmountFromFunder(msg.Creator, msg.Amount) - - // Transfer tokens from this module to sender. - if err := util.TransferFromModuleToAddress(k.bankKeeper, ctx, types.ModuleName, msg.Creator, msg.Amount); err != nil { - return nil, err - } - - // Emit a defund event. - _ = ctx.EventManager().EmitTypedEvent(&types.EventDefundPool{ - PoolId: msg.Id, - Address: msg.Creator, - Amount: msg.Amount, - }) - - k.SetPool(ctx, pool) - - return &types.MsgDefundPoolResponse{}, nil -} diff --git a/x/pool/keeper/msg_server_defund_pool_test.go b/x/pool/keeper/msg_server_defund_pool_test.go deleted file mode 100644 index e5b3aff8..00000000 --- a/x/pool/keeper/msg_server_defund_pool_test.go +++ /dev/null @@ -1,149 +0,0 @@ -package keeper_test - -import ( - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - - i "github.com/KYVENetwork/chain/testutil/integration" - pooltypes "github.com/KYVENetwork/chain/x/pool/types" -) - -/* - -TEST CASES - msg_server_defund_pool.go - -* Defund 50 KYVE from a funder who has previously funded 100 KYVE -* Try to defund more than actually funded -* Defund full funding amount from a funder who has previously funded 100 KYVE -* Defund as highest funder 75 KYVE in order to be the lowest funder afterwards - -*/ - -var _ = Describe("msg_server_defund_pool.go", Ordered, func() { - s := i.NewCleanChain() - - initialBalance := s.GetBalanceFromAddress(i.ALICE) - - BeforeEach(func() { - // init new clean chain - s = i.NewCleanChain() - - // create clean pool for every test case - s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{ - Name: "PoolTest", - Protocol: &pooltypes.Protocol{ - Version: "0.0.0", - Binaries: "{}", - LastUpgrade: uint64(s.Ctx().BlockTime().Unix()), - }, - UpgradePlan: &pooltypes.UpgradePlan{}, - }) - - // fund pool - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ - Creator: i.ALICE, - Id: 0, - Amount: 100 * i.KYVE, - }) - }) - - AfterEach(func() { - s.PerformValidityChecks() - }) - - It("Defund 50 KYVE from a funder who has previously funded 100 KYVE", func() { - // ACT - s.RunTxPoolSuccess(&pooltypes.MsgDefundPool{ - Creator: i.ALICE, - Id: 0, - Amount: 50 * i.KYVE, - }) - - // ASSERT - balanceAfter := s.GetBalanceFromAddress(i.ALICE) - - pool, _ := s.App().PoolKeeper.GetPool(s.Ctx(), 0) - - Expect(initialBalance - balanceAfter).To(Equal(50 * i.KYVE)) - - Expect(pool.Funders).To(HaveLen(1)) - Expect(pool.TotalFunds).To(Equal(50 * i.KYVE)) - - Expect(pool.GetFunderAmount(i.ALICE)).To(Equal(50 * i.KYVE)) - - Expect(pool.GetLowestFunder().Address).To(Equal(i.ALICE)) - Expect(pool.GetLowestFunder().Amount).To(Equal(50 * i.KYVE)) - }) - - It("Try to defund more than actually funded", func() { - // ACT - s.RunTxPoolError(&pooltypes.MsgDefundPool{ - Creator: i.ALICE, - Id: 0, - Amount: 101 * i.KYVE, - }) - - // ASSERT - balanceAfter := s.GetBalanceFromAddress(i.ALICE) - - pool, _ := s.App().PoolKeeper.GetPool(s.Ctx(), 0) - - Expect(initialBalance - balanceAfter).To(Equal(100 * i.KYVE)) - - Expect(pool.Funders).To(HaveLen(1)) - Expect(pool.TotalFunds).To(Equal(100 * i.KYVE)) - - Expect(pool.GetFunderAmount(i.ALICE)).To(Equal(100 * i.KYVE)) - - Expect(pool.GetLowestFunder().Address).To(Equal(i.ALICE)) - Expect(pool.GetLowestFunder().Amount).To(Equal(100 * i.KYVE)) - }) - - It("Defund full funding amount from a funder who has previously funded 100 KYVE", func() { - // ACT - s.RunTxPoolSuccess(&pooltypes.MsgDefundPool{ - Creator: i.ALICE, - Id: 0, - Amount: 100 * i.KYVE, - }) - - // ASSERT - balanceAfter := s.GetBalanceFromAddress(i.ALICE) - - pool, _ := s.App().PoolKeeper.GetPool(s.Ctx(), 0) - - Expect(initialBalance - balanceAfter).To(BeZero()) - - Expect(pool.Funders).To(BeEmpty()) - Expect(pool.TotalFunds).To(BeZero()) - - Expect(pool.GetFunderAmount(i.ALICE)).To(Equal(uint64(0))) - - Expect(pool.GetLowestFunder()).To(Equal(pooltypes.Funder{})) - }) - - It("Defund as highest funder 75 KYVE in order to be the lowest funder afterwards", func() { - // ARRANGE - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ - Creator: i.BOB, - Id: 0, - Amount: 50 * i.KYVE, - }) - - pool, _ := s.App().PoolKeeper.GetPool(s.Ctx(), 0) - Expect(pool.GetLowestFunder().Address).To(Equal(i.BOB)) - Expect(pool.GetLowestFunder().Amount).To(Equal(50 * i.KYVE)) - - // ACT - s.RunTxPoolSuccess(&pooltypes.MsgDefundPool{ - Creator: i.ALICE, - Id: 0, - Amount: 75 * i.KYVE, - }) - - // ASSERT - pool, _ = s.App().PoolKeeper.GetPool(s.Ctx(), 0) - Expect(pool.GetLowestFunder().Address).To(Equal(i.ALICE)) - Expect(pool.GetLowestFunder().Amount).To(Equal(25 * i.KYVE)) - }) -}) diff --git a/x/pool/keeper/msg_server_disable_pool_test.go b/x/pool/keeper/msg_server_disable_pool_test.go index 1ad74def..602d311b 100644 --- a/x/pool/keeper/msg_server_disable_pool_test.go +++ b/x/pool/keeper/msg_server_disable_pool_test.go @@ -3,6 +3,7 @@ package keeper_test import ( i "github.com/KYVENetwork/chain/testutil/integration" bundletypes "github.com/KYVENetwork/chain/x/bundles/types" + funderstypes "github.com/KYVENetwork/chain/x/funders/types" globalTypes "github.com/KYVENetwork/chain/x/global/types" stakertypes "github.com/KYVENetwork/chain/x/stakers/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -38,49 +39,64 @@ var _ = Describe("msg_server_disable_pool.go", Ordered, func() { gov := s.App().GovKeeper.GetGovernanceAccount(s.Ctx()).GetAddress().String() votingPeriod := s.App().GovKeeper.GetParams(s.Ctx()).VotingPeriod + fundingAmount := 100 * i.KYVE BeforeEach(func() { s = i.NewCleanChain() - // create clean pool for every test case - s.App().PoolKeeper.AppendPool(s.Ctx(), types.Pool{ - Name: "PoolTest", - MaxBundleSize: 100, - StartKey: "0", - UploadInterval: 60, - OperatingCost: 10_000, - Protocol: &types.Protocol{ - Version: "0.0.0", - Binaries: "{}", - LastUpgrade: uint64(s.Ctx().BlockTime().Unix()), - }, - UpgradePlan: &types.UpgradePlan{}, - }) + msg := &types.MsgCreatePool{ + Authority: gov, + Name: "PoolTest", + Runtime: "@kyve/test", + Logo: "ar://Tewyv2P5VEG8EJ6AUQORdqNTectY9hlOrWPK8wwo-aU", + Config: "ar://DgdB-2hLrxjhyEEbCML__dgZN5_uS7T6Z5XDkaFh3P0", + StartKey: "0", + UploadInterval: 60, + InflationShareWeight: 10_000, + MinDelegation: 100 * i.KYVE, + MaxBundleSize: 100, + Version: "0.0.0", + Binaries: "{}", + StorageProviderId: 2, + CompressionId: 1, + } + s.RunTxPoolSuccess(msg) - s.RunTxPoolSuccess(&types.MsgFundPool{ + s.RunTxPoolSuccess(&funderstypes.MsgCreateFunder{ Creator: i.ALICE, - Id: 0, - Amount: 100 * i.KYVE, + Moniker: "Alice", }) - s.App().PoolKeeper.AppendPool(s.Ctx(), types.Pool{ - Name: "PoolTest2", - MaxBundleSize: 100, - StartKey: "0", - UploadInterval: 60, - OperatingCost: 10_000, - Protocol: &types.Protocol{ - Version: "0.0.0", - Binaries: "{}", - LastUpgrade: uint64(s.Ctx().BlockTime().Unix()), - }, - UpgradePlan: &types.UpgradePlan{}, + s.RunTxPoolSuccess(&funderstypes.MsgFundPool{ + Creator: i.ALICE, + PoolId: 0, + Amount: fundingAmount, + AmountPerBundle: 1 * i.KYVE, }) - s.RunTxPoolSuccess(&types.MsgFundPool{ - Creator: i.ALICE, - Id: 1, - Amount: 100 * i.KYVE, + msg = &types.MsgCreatePool{ + Authority: gov, + Name: "PoolTest2", + Runtime: "@kyve/test", + Logo: "ar://Tewyv2P5VEG8EJ6AUQORdqNTectY9hlOrWPK8wwo-aU", + Config: "ar://DgdB-2hLrxjhyEEbCML__dgZN5_uS7T6Z5XDkaFh3P0", + StartKey: "0", + UploadInterval: 60, + InflationShareWeight: 10_000, + MinDelegation: 100 * i.KYVE, + MaxBundleSize: 100, + Version: "0.0.0", + Binaries: "{}", + StorageProviderId: 2, + CompressionId: 1, + } + s.RunTxPoolSuccess(msg) + + s.RunTxPoolSuccess(&funderstypes.MsgFundPool{ + Creator: i.ALICE, + PoolId: 1, + Amount: fundingAmount, + AmountPerBundle: 1 * i.KYVE, }) }) @@ -164,6 +180,10 @@ var _ = Describe("msg_server_disable_pool.go", Ordered, func() { p, v := BuildGovernanceTxs(s, []sdk.Msg{msg}) + fundersModuleAddr := s.App().AccountKeeper.GetModuleAddress(funderstypes.ModuleName) + balanceBefore := s.App().BankKeeper.GetBalance(s.Ctx(), fundersModuleAddr, globalTypes.Denom).Amount.Uint64() + Expect(balanceBefore).To(BeNumerically(">", uint64(0))) + // ACT _, submitErr := s.RunTx(&p) _, voteErr := s.RunTx(&v) @@ -184,9 +204,9 @@ var _ = Describe("msg_server_disable_pool.go", Ordered, func() { bundleProposal, _ := s.App().BundlesKeeper.GetBundleProposal(s.Ctx(), 0) Expect(bundleProposal.StorageId).To(BeEmpty()) - // assert empty pool balance - b := s.App().BankKeeper.GetBalance(s.Ctx(), pool.GetPoolAccount(), globalTypes.Denom).Amount.Uint64() - Expect(b).To(BeZero()) + // assert same funding balance + balance := s.App().BankKeeper.GetBalance(s.Ctx(), fundersModuleAddr, globalTypes.Denom).Amount.Uint64() + Expect(balance).To(Equal(balanceBefore)) }) It("Disable pool which is active and has a balance", func() { @@ -202,8 +222,9 @@ var _ = Describe("msg_server_disable_pool.go", Ordered, func() { s.Commit() } - b := s.App().BankKeeper.GetBalance(s.Ctx(), pool.GetPoolAccount(), globalTypes.Denom).Amount.Uint64() - Expect(b).To(BeNumerically(">", uint64(0))) + fundersModuleAddr := s.App().AccountKeeper.GetModuleAddress(funderstypes.ModuleName) + balanceBefore := s.App().BankKeeper.GetBalance(s.Ctx(), fundersModuleAddr, globalTypes.Denom).Amount.Uint64() + Expect(balanceBefore).To(BeNumerically(">", uint64(0))) msg := &types.MsgDisablePool{ Authority: gov, @@ -232,9 +253,9 @@ var _ = Describe("msg_server_disable_pool.go", Ordered, func() { bundleProposal, _ := s.App().BundlesKeeper.GetBundleProposal(s.Ctx(), 0) Expect(bundleProposal.StorageId).To(BeEmpty()) - // assert empty pool balance - b = s.App().BankKeeper.GetBalance(s.Ctx(), pool.GetPoolAccount(), globalTypes.Denom).Amount.Uint64() - Expect(b).To(BeZero()) + // assert same funding balance + balance := s.App().BankKeeper.GetBalance(s.Ctx(), fundersModuleAddr, globalTypes.Denom).Amount.Uint64() + Expect(balance).To(Equal(balanceBefore)) }) It("Disable pool which is active", func() { diff --git a/x/pool/keeper/msg_server_enable_pool_test.go b/x/pool/keeper/msg_server_enable_pool_test.go index 27dffc78..87730fa7 100644 --- a/x/pool/keeper/msg_server_enable_pool_test.go +++ b/x/pool/keeper/msg_server_enable_pool_test.go @@ -35,12 +35,8 @@ var _ = Describe("msg_server_enable_pool.go", Ordered, func() { BeforeEach(func() { s = i.NewCleanChain() - s.App().PoolKeeper.AppendPool(s.Ctx(), types.Pool{ - UpgradePlan: &types.UpgradePlan{}, - }) - s.App().PoolKeeper.AppendPool(s.Ctx(), types.Pool{ - UpgradePlan: &types.UpgradePlan{}, - }) + createPoolWithEmptyValues(s) + createPoolWithEmptyValues(s) }) AfterEach(func() { diff --git a/x/pool/keeper/msg_server_fund_pool.go b/x/pool/keeper/msg_server_fund_pool.go deleted file mode 100644 index b6f5f099..00000000 --- a/x/pool/keeper/msg_server_fund_pool.go +++ /dev/null @@ -1,71 +0,0 @@ -package keeper - -import ( - "context" - - "cosmossdk.io/errors" - "github.com/KYVENetwork/chain/util" - "github.com/KYVENetwork/chain/x/pool/types" - sdk "github.com/cosmos/cosmos-sdk/types" - errorsTypes "github.com/cosmos/cosmos-sdk/types/errors" -) - -// FundPool handles the logic to fund a pool. -// A funder is added to the funders list with the specified amount -// If the funders list is full, it checks if the funder wants to fund -// more than the current lowest funder. If so, the current lowest funder -// will get their tokens back and removed form the funders list. -func (k msgServer) FundPool(goCtx context.Context, msg *types.MsgFundPool) (*types.MsgFundPoolResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - pool, poolFound := k.GetPool(ctx, msg.Id) - - if !poolFound { - return nil, errors.Wrapf(errorsTypes.ErrNotFound, types.ErrPoolNotFound.Error(), msg.Id) - } - - // Check if funder already exists - // If sender is not a funder, check if a free funding slot is still available - if pool.GetFunderAmount(msg.Creator) == 0 { - // If funder does not exist, check if limit is already exceeded. - if len(pool.Funders) >= types.MaxFunders { - // If so, check if funder wants to fund more than current lowest funder. - lowestFunder := pool.GetLowestFunder() - if msg.Amount > lowestFunder.Amount { - // Unstake lowest Funder - err := util.TransferFromModuleToAddress(k.bankKeeper, ctx, types.ModuleName, lowestFunder.Address, lowestFunder.Amount) - if err != nil { - return nil, err - } - - // Emit a defund event. - _ = ctx.EventManager().EmitTypedEvent(&types.EventDefundPool{ - PoolId: msg.Id, - Address: lowestFunder.Address, - Amount: lowestFunder.Amount, - }) - - // Remove from pool - pool.RemoveFunder(lowestFunder.Address) - } else { - return nil, errors.Wrapf(errorsTypes.ErrLogic, types.ErrFundsTooLow.Error(), lowestFunder.Amount) - } - } - } - - // User is allowed to fund - pool.AddAmountToFunder(msg.Creator, msg.Amount) - - if err := util.TransferFromAddressToModule(k.bankKeeper, ctx, msg.Creator, types.ModuleName, msg.Amount); err != nil { - return nil, err - } - - _ = ctx.EventManager().EmitTypedEvent(&types.EventFundPool{ - PoolId: msg.Id, - Address: msg.Creator, - Amount: msg.Amount, - }) - - k.SetPool(ctx, pool) - - return &types.MsgFundPoolResponse{}, nil -} diff --git a/x/pool/keeper/msg_server_fund_pool_test.go b/x/pool/keeper/msg_server_fund_pool_test.go deleted file mode 100644 index 8dc9c6ba..00000000 --- a/x/pool/keeper/msg_server_fund_pool_test.go +++ /dev/null @@ -1,278 +0,0 @@ -package keeper_test - -import ( - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - - i "github.com/KYVENetwork/chain/testutil/integration" - pooltypes "github.com/KYVENetwork/chain/x/pool/types" -) - -/* - -TEST CASES - msg_server_fund_pool.go - -* Create funder by funding a pool with 100 $KYVE -* Fund additional 50 $KYVE to an existing funder with 100 $KYVE -* Try to fund more $KYVE than available in balance -* Fund with a new funder less $KYVE than the existing one -* Fund with a new funder more $KYVE than the existing one -* Try to fund less $KYVE than the lowest funder with full funding slots -* Try to fund more $KYVE than the lowest funder with full funding slots - -*/ - -var _ = Describe("msg_server_fund_pool.go", Ordered, func() { - s := i.NewCleanChain() - - initialBalance := s.GetBalanceFromAddress(i.ALICE) - - BeforeEach(func() { - // init new clean chain - s = i.NewCleanChain() - - // create clean pool for every test case - s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{ - Name: "PoolTest", - Protocol: &pooltypes.Protocol{ - Version: "0.0.0", - Binaries: "{}", - LastUpgrade: uint64(s.Ctx().BlockTime().Unix()), - }, - UpgradePlan: &pooltypes.UpgradePlan{}, - }) - }) - - AfterEach(func() { - s.PerformValidityChecks() - }) - - It("Create funder by funding a pool with 100 $KYVE", func() { - // ACT - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ - Creator: i.ALICE, - Id: 0, - Amount: 100 * i.KYVE, - }) - - // ASSERT - balanceAfter := s.GetBalanceFromAddress(i.ALICE) - - pool, _ := s.App().PoolKeeper.GetPool(s.Ctx(), 0) - - Expect(initialBalance - balanceAfter).To(Equal(100 * i.KYVE)) - - Expect(pool.Funders).To(HaveLen(1)) - Expect(pool.TotalFunds).To(Equal(100 * i.KYVE)) - - funderAmount := pool.GetFunderAmount(i.ALICE) - - Expect(funderAmount).To(Equal(100 * i.KYVE)) - Expect(pool.GetLowestFunder().Address).To(Equal(i.ALICE)) - Expect(pool.GetLowestFunder().Amount).To(Equal(100 * i.KYVE)) - }) - - It("Fund additional 50 $KYVE to an existing funder with 100 $KYVE", func() { - // ARRANGE - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ - Creator: i.ALICE, - Id: 0, - Amount: 100 * i.KYVE, - }) - - // ACT - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ - Creator: i.ALICE, - Id: 0, - Amount: 50 * i.KYVE, - }) - - // ASSERT - balanceAfter := s.GetBalanceFromAddress(i.ALICE) - - pool, _ := s.App().PoolKeeper.GetPool(s.Ctx(), 0) - - Expect(initialBalance - balanceAfter).To(Equal(150 * i.KYVE)) - - Expect(pool.Funders).To(HaveLen(1)) - Expect(pool.TotalFunds).To(Equal(150 * i.KYVE)) - - funderAmount := pool.GetFunderAmount(i.ALICE) - - Expect(funderAmount).To(Equal(150 * i.KYVE)) - Expect(pool.GetLowestFunder().Address).To(Equal(i.ALICE)) - Expect(pool.GetLowestFunder().Amount).To(Equal(150 * i.KYVE)) - }) - - It("Try to fund more $KYVE than available in balance", func() { - // ACT - currentBalance := s.GetBalanceFromAddress(i.ALICE) - - s.RunTxPoolError(&pooltypes.MsgFundPool{ - Creator: i.ALICE, - Id: 0, - Amount: currentBalance + 1, - }) - - // ASSERT - balanceAfter := s.GetBalanceFromAddress(i.ALICE) - - pool, _ := s.App().PoolKeeper.GetPool(s.Ctx(), 0) - - Expect(initialBalance - balanceAfter).To(BeZero()) - - Expect(pool.Funders).To(BeEmpty()) - Expect(pool.TotalFunds).To(BeZero()) - - Expect(pool.GetFunderAmount(i.ALICE)).To(Equal(0 * i.KYVE)) - Expect(pool.GetLowestFunder().Address).To(Equal("")) - Expect(pool.GetLowestFunder().Amount).To(Equal(0 * i.KYVE)) - }) - - It("Fund with a new funder less $KYVE than the existing one", func() { - // ARRANGE - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ - Creator: i.ALICE, - Id: 0, - Amount: 100 * i.KYVE, - }) - - // ACT - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ - Creator: i.BOB, - Id: 0, - Amount: 50 * i.KYVE, - }) - - // ASSERT - balanceAfter := s.GetBalanceFromAddress(i.BOB) - - pool, _ := s.App().PoolKeeper.GetPool(s.Ctx(), 0) - - Expect(initialBalance - balanceAfter).To(Equal(50 * i.KYVE)) - - Expect(pool.Funders).To(HaveLen(2)) - Expect(pool.TotalFunds).To(Equal(150 * i.KYVE)) - - funderAmount := pool.GetFunderAmount(i.BOB) - - Expect(funderAmount).To(Equal(50 * i.KYVE)) - Expect(pool.GetLowestFunder().Address).To(Equal(i.BOB)) - Expect(pool.GetLowestFunder().Amount).To(Equal(50 * i.KYVE)) - }) - - It("Fund with a new funder more $KYVE than the existing one", func() { - // ARRANGE - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ - Creator: i.ALICE, - Id: 0, - Amount: 100 * i.KYVE, - }) - - // ACT - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ - Creator: i.BOB, - Id: 0, - Amount: 200 * i.KYVE, - }) - - // ASSERT - balanceAfter := s.GetBalanceFromAddress(i.BOB) - - pool, _ := s.App().PoolKeeper.GetPool(s.Ctx(), 0) - - Expect(initialBalance - balanceAfter).To(Equal(200 * i.KYVE)) - - Expect(pool.Funders).To(HaveLen(2)) - Expect(pool.TotalFunds).To(Equal(300 * i.KYVE)) - - funderAmount := pool.GetFunderAmount(i.BOB) - Expect(funderAmount).To(Equal(200 * i.KYVE)) - - Expect(pool.GetLowestFunder().Address).To(Equal(i.ALICE)) - Expect(pool.GetLowestFunder().Amount).To(Equal(100 * i.KYVE)) - }) - - It("Try to fund less $KYVE than the lowest funder with full funding slots", func() { - // ARRANGE - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ - Creator: i.ALICE, - Id: 0, - Amount: 100 * i.KYVE, - }) - - for a := 0; a < 49; a++ { - // fill remaining funding slots - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ - Creator: i.DUMMY[a], - Id: 0, - Amount: 1000 * i.KYVE, - }) - } - - pool, _ := s.App().PoolKeeper.GetPool(s.Ctx(), 0) - - Expect(pool.Funders).To(HaveLen(50)) - Expect(pool.TotalFunds).To(Equal(49_100 * i.KYVE)) - - Expect(pool.GetLowestFunder().Address).To(Equal(i.ALICE)) - Expect(pool.GetLowestFunder().Amount).To(Equal(100 * i.KYVE)) - - balanceAfter := s.GetBalanceFromAddress(i.ALICE) - - Expect(initialBalance - balanceAfter).To(Equal(100 * i.KYVE)) - - // ACT - s.RunTxPoolError(&pooltypes.MsgFundPool{ - Creator: i.DUMMY[49], - Id: 0, - Amount: 50 * i.KYVE, - }) - - // ASSERT - Expect(pool.Funders).To(HaveLen(50)) - Expect(pool.TotalFunds).To(Equal(49_100 * i.KYVE)) - - Expect(pool.GetFunderAmount(i.DUMMY[49])).To(BeZero()) - Expect(pool.GetLowestFunder().Address).To(Equal(i.ALICE)) - Expect(pool.GetLowestFunder().Amount).To(Equal(100 * i.KYVE)) - }) - - It("Fund more $KYVE than the lowest funder with full funding slots", func() { - // ARRANGE - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ - Creator: i.ALICE, - Id: 0, - Amount: 100 * i.KYVE, - }) - - for a := 0; a < 49; a++ { - // fill remaining funding slots - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ - Creator: i.DUMMY[a], - Id: 0, - Amount: 1000 * i.KYVE, - }) - } - - // ACT - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ - Creator: i.DUMMY[49], - Id: 0, - Amount: 200 * i.KYVE, - }) - - // ASSERT - pool, _ := s.App().PoolKeeper.GetPool(s.Ctx(), 0) - - Expect(pool.Funders).To(HaveLen(50)) - Expect(pool.TotalFunds).To(Equal(49_200 * i.KYVE)) - - Expect(pool.GetFunderAmount(i.DUMMY[49])).To(Equal(200 * i.KYVE)) - Expect(pool.GetLowestFunder().Address).To(Equal(i.DUMMY[49])) - Expect(pool.GetLowestFunder().Amount).To(Equal(200 * i.KYVE)) - - balanceAfter := s.GetBalanceFromAddress(i.ALICE) - Expect(initialBalance - balanceAfter).To(BeZero()) - }) -}) diff --git a/x/pool/keeper/msg_server_schedule_runtime_upgrade_test.go b/x/pool/keeper/msg_server_schedule_runtime_upgrade_test.go index 32caece2..a6ff6619 100644 --- a/x/pool/keeper/msg_server_schedule_runtime_upgrade_test.go +++ b/x/pool/keeper/msg_server_schedule_runtime_upgrade_test.go @@ -33,18 +33,23 @@ var _ = Describe("msg_server_schedule_runtime_upgrade.go", Ordered, func() { gov := s.App().GovKeeper.GetGovernanceAccount(s.Ctx()).GetAddress().String() votingPeriod := s.App().GovKeeper.GetParams(s.Ctx()).VotingPeriod + var currentTime uint64 + BeforeEach(func() { s = i.NewCleanChain() - s.App().PoolKeeper.AppendPool(s.Ctx(), types.Pool{ - Runtime: "@kyve/test", - Protocol: &types.Protocol{ - Version: "0.0.0", - Binaries: "{\"linux\":\"test\"}", - LastUpgrade: 0, - }, - UpgradePlan: &types.UpgradePlan{}, - }) + createPoolWithEmptyValues(s) + pool, _ := s.App().PoolKeeper.GetPool(s.Ctx(), 0) + pool.UpgradePlan = &types.UpgradePlan{} + pool.Protocol = &types.Protocol{ + Version: "0.0.0", + Binaries: "{\"linux\":\"test\"}", + LastUpgrade: 0, + } + pool.Runtime = "@kyve/test" + s.App().PoolKeeper.SetPool(s.Ctx(), pool) + + currentTime = uint64(time.Now().Unix()) }) AfterEach(func() { @@ -57,7 +62,7 @@ var _ = Describe("msg_server_schedule_runtime_upgrade.go", Ordered, func() { Authority: i.DUMMY[0], Runtime: "@kyve/test", Version: "1.0.0", - ScheduledAt: uint64(time.Now().Unix()), + ScheduledAt: currentTime, } // ACT @@ -75,7 +80,7 @@ var _ = Describe("msg_server_schedule_runtime_upgrade.go", Ordered, func() { Version: "1.0.0", Binaries: "{}", Duration: 60, - ScheduledAt: uint64(time.Now().Unix()), + ScheduledAt: currentTime, } proposal, _ := BuildGovernanceTxs(s, []sdk.Msg{msg}) @@ -95,7 +100,7 @@ var _ = Describe("msg_server_schedule_runtime_upgrade.go", Ordered, func() { Version: "", Binaries: "{}", Duration: 60, - ScheduledAt: uint64(time.Now().Unix()), + ScheduledAt: currentTime, } p, v := BuildGovernanceTxs(s, []sdk.Msg{msg}) @@ -124,7 +129,7 @@ var _ = Describe("msg_server_schedule_runtime_upgrade.go", Ordered, func() { Version: "1.0.0", Binaries: "", Duration: 60, - ScheduledAt: uint64(time.Now().Unix()), + ScheduledAt: currentTime, } p, v := BuildGovernanceTxs(s, []sdk.Msg{msg}) @@ -153,7 +158,7 @@ var _ = Describe("msg_server_schedule_runtime_upgrade.go", Ordered, func() { Version: "1.0.0", Binaries: "{}", Duration: 60, - ScheduledAt: uint64(time.Now().Unix()) - 7*24*3600, + ScheduledAt: currentTime - 7*24*3600, } p, v := BuildGovernanceTxs(s, []sdk.Msg{msg}) @@ -190,7 +195,7 @@ var _ = Describe("msg_server_schedule_runtime_upgrade.go", Ordered, func() { Version: "1.0.0", Binaries: "{}", Duration: 60, - ScheduledAt: uint64(time.Now().Unix()) + 7*24*3600, + ScheduledAt: currentTime + 7*24*3600, } p, v := BuildGovernanceTxs(s, []sdk.Msg{msg}) @@ -214,7 +219,7 @@ var _ = Describe("msg_server_schedule_runtime_upgrade.go", Ordered, func() { Expect(pool.UpgradePlan).To(Equal(&types.UpgradePlan{ Version: "1.0.0", Binaries: "{}", - ScheduledAt: uint64(time.Now().Unix()) + 7*24*3600, + ScheduledAt: currentTime + 7*24*3600, Duration: 60, })) }) @@ -227,7 +232,7 @@ var _ = Describe("msg_server_schedule_runtime_upgrade.go", Ordered, func() { Version: "1.0.0", Binaries: "{}", Duration: 60, - ScheduledAt: uint64(time.Now().Unix()) + 7*24*3600, + ScheduledAt: currentTime + 7*24*3600, } p, v := BuildGovernanceTxs(s, []sdk.Msg{msg}) @@ -250,7 +255,7 @@ var _ = Describe("msg_server_schedule_runtime_upgrade.go", Ordered, func() { Expect(pool.UpgradePlan).To(Equal(&types.UpgradePlan{ Version: "1.0.0", Binaries: "{}", - ScheduledAt: uint64(time.Now().Unix()) + 7*24*3600, + ScheduledAt: currentTime + 7*24*3600, Duration: 60, })) @@ -261,7 +266,7 @@ var _ = Describe("msg_server_schedule_runtime_upgrade.go", Ordered, func() { Version: "2.0.0", Binaries: "{}", Duration: 60, - ScheduledAt: uint64(time.Now().Unix()) + 7*24*3600, + ScheduledAt: currentTime + 7*24*3600, } p, v = BuildGovernanceTxs(s, []sdk.Msg{msg}) @@ -284,7 +289,7 @@ var _ = Describe("msg_server_schedule_runtime_upgrade.go", Ordered, func() { Expect(pool.UpgradePlan).To(Equal(&types.UpgradePlan{ Version: "1.0.0", Binaries: "{}", - ScheduledAt: uint64(time.Now().Unix()) + 7*24*3600, + ScheduledAt: currentTime + 7*24*3600, Duration: 60, })) }) diff --git a/x/pool/keeper/msg_server_update_pool.go b/x/pool/keeper/msg_server_update_pool.go index f8378a13..41f452f1 100644 --- a/x/pool/keeper/msg_server_update_pool.go +++ b/x/pool/keeper/msg_server_update_pool.go @@ -44,8 +44,8 @@ func (k msgServer) UpdatePool(goCtx context.Context, req *types.MsgUpdatePool) ( if update.UploadInterval != nil { pool.UploadInterval = *update.UploadInterval } - if update.OperatingCost != nil { - pool.OperatingCost = *update.OperatingCost + if update.InflationShareWeight != nil { + pool.InflationShareWeight = *update.InflationShareWeight } if update.MinDelegation != nil { pool.MinDelegation = *update.MinDelegation @@ -63,18 +63,18 @@ func (k msgServer) UpdatePool(goCtx context.Context, req *types.MsgUpdatePool) ( k.SetPool(ctx, pool) _ = ctx.EventManager().EmitTypedEvent(&types.EventPoolUpdated{ - Id: pool.Id, - RawUpdateString: req.Payload, - Name: pool.Name, - Runtime: pool.Runtime, - Logo: pool.Logo, - Config: pool.Config, - UploadInterval: pool.UploadInterval, - OperatingCost: pool.OperatingCost, - MinDelegation: pool.MinDelegation, - MaxBundleSize: pool.MaxBundleSize, - StorageProviderId: pool.CurrentStorageProviderId, - CompressionId: pool.CurrentCompressionId, + Id: pool.Id, + RawUpdateString: req.Payload, + Name: pool.Name, + Runtime: pool.Runtime, + Logo: pool.Logo, + Config: pool.Config, + UploadInterval: pool.UploadInterval, + InflationShareWeight: pool.InflationShareWeight, + MinDelegation: pool.MinDelegation, + MaxBundleSize: pool.MaxBundleSize, + StorageProviderId: pool.CurrentStorageProviderId, + CompressionId: pool.CurrentCompressionId, }) return &types.MsgUpdatePoolResponse{}, nil diff --git a/x/pool/keeper/msg_server_update_pool_test.go b/x/pool/keeper/msg_server_update_pool_test.go index 8468e995..4c370a15 100644 --- a/x/pool/keeper/msg_server_update_pool_test.go +++ b/x/pool/keeper/msg_server_update_pool_test.go @@ -33,20 +33,7 @@ var _ = Describe("msg_server_update_pool.go", Ordered, func() { BeforeEach(func() { s = i.NewCleanChain() - s.App().PoolKeeper.AppendPool(s.Ctx(), types.Pool{ - Name: "", - Runtime: "", - Logo: "", - Config: "", - UploadInterval: 0, - OperatingCost: 0, - MinDelegation: 0, - MaxBundleSize: 0, - CurrentStorageProviderId: 0, - CurrentCompressionId: 0, - Protocol: &types.Protocol{}, - UpgradePlan: &types.UpgradePlan{}, - }) + createPoolWithEmptyValues(s) }) AfterEach(func() { @@ -58,7 +45,7 @@ var _ = Describe("msg_server_update_pool.go", Ordered, func() { msg := &types.MsgUpdatePool{ Authority: i.DUMMY[0], Id: 0, - Payload: "{\"Name\":\"TestPool\",\"Runtime\":\"@kyve/test\",\"Logo\":\"ar://Tewyv2P5VEG8EJ6AUQORdqNTectY9hlOrWPK8wwo-aU\",\"Config\":\"ar://DgdB-2hLrxjhyEEbCML__dgZN5_uS7T6Z5XDkaFh3P0\",\"StartKey\":\"0\",\"UploadInterval\":60,\"OperatingCost\":10000,\"MinDelegation\":\"100000000000\",\"MaxBundleSize\":100,\"Version\":\"0.0.0\",\"Binaries\":\"{}\",\"StorageProviderId\":2,\"CompressionId\":1}", + Payload: "{\"Name\":\"TestPool\",\"Runtime\":\"@kyve/test\",\"Logo\":\"ar://Tewyv2P5VEG8EJ6AUQORdqNTectY9hlOrWPK8wwo-aU\",\"Config\":\"ar://DgdB-2hLrxjhyEEbCML__dgZN5_uS7T6Z5XDkaFh3P0\",\"StartKey\":\"0\",\"UploadInterval\":60,\"InflationShareWeight\":10000,\"MinDelegation\":\"100000000000\",\"MaxBundleSize\":100,\"Version\":\"0.0.0\",\"Binaries\":\"{}\",\"StorageProviderId\":2,\"CompressionId\":1}", } // ACT @@ -73,7 +60,7 @@ var _ = Describe("msg_server_update_pool.go", Ordered, func() { msg := &types.MsgUpdatePool{ Authority: i.DUMMY[0], Id: 0, - Payload: "{\"Name\":\"TestPool\",\"Runtime\":\"@kyve/test\",\"Logo\":\"ar://Tewyv2P5VEG8EJ6AUQORdqNTectY9hlOrWPK8wwo-aU\",\"Config\":\"ar://DgdB-2hLrxjhyEEbCML__dgZN5_uS7T6Z5XDkaFh3P0\",\"StartKey\":\"0\",\"UploadInterval\":60,\"OperatingCost\":10000,\"MinDelegation\":\"100000000000\",\"MaxBundleSize\":100,\"Version\":\"0.0.0\",\"Binaries\":\"{}\",\"StorageProviderId\":2,\"CompressionId\":1}", + Payload: "{\"Name\":\"TestPool\",\"Runtime\":\"@kyve/test\",\"Logo\":\"ar://Tewyv2P5VEG8EJ6AUQORdqNTectY9hlOrWPK8wwo-aU\",\"Config\":\"ar://DgdB-2hLrxjhyEEbCML__dgZN5_uS7T6Z5XDkaFh3P0\",\"StartKey\":\"0\",\"UploadInterval\":60,\"InflationShareWeight\":10000,\"MinDelegation\":\"100000000000\",\"MaxBundleSize\":100,\"Version\":\"0.0.0\",\"Binaries\":\"{}\",\"StorageProviderId\":2,\"CompressionId\":1}", } proposal, _ := BuildGovernanceTxs(s, []sdk.Msg{msg}) @@ -90,7 +77,7 @@ var _ = Describe("msg_server_update_pool.go", Ordered, func() { msg := &types.MsgUpdatePool{ Authority: gov, Id: 0, - Payload: "{\"Name\":\"TestPool\",\"Runtime\":\"@kyve/test\",\"Logo\":\"ar://Tewyv2P5VEG8EJ6AUQORdqNTectY9hlOrWPK8wwo-aU\",\"Config\":\"ar://DgdB-2hLrxjhyEEbCML__dgZN5_uS7T6Z5XDkaFh3P0\",\"StartKey\":\"0\",\"UploadInterval\":60,\"OperatingCost\":10000,\"MinDelegation\":100000000000,\"MaxBundleSize\":100,\"Version\":\"0.0.0\",\"Binaries\":\"{}\",\"StorageProviderId\":2,\"CompressionId\":1}", + Payload: "{\"Name\":\"TestPool\",\"Runtime\":\"@kyve/test\",\"Logo\":\"ar://Tewyv2P5VEG8EJ6AUQORdqNTectY9hlOrWPK8wwo-aU\",\"Config\":\"ar://DgdB-2hLrxjhyEEbCML__dgZN5_uS7T6Z5XDkaFh3P0\",\"StartKey\":\"0\",\"UploadInterval\":60,\"InflationShareWeight\":10000,\"MinDelegation\":100000000000,\"MaxBundleSize\":100,\"Version\":\"0.0.0\",\"Binaries\":\"{}\",\"StorageProviderId\":2,\"CompressionId\":1}", } p, v := BuildGovernanceTxs(s, []sdk.Msg{msg}) @@ -112,23 +99,21 @@ var _ = Describe("msg_server_update_pool.go", Ordered, func() { pool, _ := s.App().PoolKeeper.GetPool(s.Ctx(), 0) Expect(pool).To(Equal(types.Pool{ - Id: 0, - Name: "TestPool", - Runtime: "@kyve/test", - Logo: "ar://Tewyv2P5VEG8EJ6AUQORdqNTectY9hlOrWPK8wwo-aU", - Config: "ar://DgdB-2hLrxjhyEEbCML__dgZN5_uS7T6Z5XDkaFh3P0", - StartKey: "", - CurrentKey: "", - CurrentSummary: "", - CurrentIndex: 0, - TotalBundles: 0, - UploadInterval: 60, - OperatingCost: 10000, - MinDelegation: 100 * i.KYVE, - MaxBundleSize: 100, - Disabled: false, - Funders: nil, - TotalFunds: 0, + Id: 0, + Name: "TestPool", + Runtime: "@kyve/test", + Logo: "ar://Tewyv2P5VEG8EJ6AUQORdqNTectY9hlOrWPK8wwo-aU", + Config: "ar://DgdB-2hLrxjhyEEbCML__dgZN5_uS7T6Z5XDkaFh3P0", + StartKey: "", + CurrentKey: "", + CurrentSummary: "", + CurrentIndex: 0, + TotalBundles: 0, + UploadInterval: 60, + InflationShareWeight: 10000, + MinDelegation: 100 * i.KYVE, + MaxBundleSize: 100, + Disabled: false, Protocol: &types.Protocol{ Version: "", Binaries: "", @@ -172,23 +157,21 @@ var _ = Describe("msg_server_update_pool.go", Ordered, func() { pool, _ := s.App().PoolKeeper.GetPool(s.Ctx(), 0) Expect(pool).To(Equal(types.Pool{ - Id: 0, - Name: "TestPool", - Runtime: "@kyve/test", - Logo: "", - Config: "", - StartKey: "", - CurrentKey: "", - CurrentSummary: "", - CurrentIndex: 0, - TotalBundles: 0, - UploadInterval: 0, - OperatingCost: 0, - MinDelegation: 0, - MaxBundleSize: 0, - Disabled: false, - Funders: nil, - TotalFunds: 0, + Id: 0, + Name: "TestPool", + Runtime: "@kyve/test", + Logo: "", + Config: "", + StartKey: "", + CurrentKey: "", + CurrentSummary: "", + CurrentIndex: 0, + TotalBundles: 0, + UploadInterval: 0, + InflationShareWeight: 0, + MinDelegation: 0, + MaxBundleSize: 0, + Disabled: false, Protocol: &types.Protocol{ Version: "", Binaries: "", @@ -207,26 +190,13 @@ var _ = Describe("msg_server_update_pool.go", Ordered, func() { It("Update another pool", func() { // ARRANGE - s.App().PoolKeeper.AppendPool(s.Ctx(), types.Pool{ - Name: "", - Runtime: "", - Logo: "", - Config: "", - UploadInterval: 0, - OperatingCost: 0, - MinDelegation: 0, - MaxBundleSize: 0, - CurrentStorageProviderId: 0, - CurrentCompressionId: 0, - Protocol: &types.Protocol{}, - UpgradePlan: &types.UpgradePlan{}, - }) + createPoolWithEmptyValues(s) // ACT msg := &types.MsgUpdatePool{ Authority: gov, Id: 1, - Payload: "{\"Name\":\"TestPool2\",\"Runtime\":\"@kyve/test\",\"Logo\":\"ar://Tewyv2P5VEG8EJ6AUQORdqNTectY9hlOrWPK8wwo-aU\",\"Config\":\"ar://DgdB-2hLrxjhyEEbCML__dgZN5_uS7T6Z5XDkaFh3P0\",\"StartKey\":\"0\",\"UploadInterval\":60,\"OperatingCost\":10000,\"MinDelegation\":100000000000,\"MaxBundleSize\":100,\"Version\":\"0.0.0\",\"Binaries\":\"{}\",\"StorageProviderId\":2,\"CompressionId\":1}", + Payload: "{\"Name\":\"TestPool2\",\"Runtime\":\"@kyve/test\",\"Logo\":\"ar://Tewyv2P5VEG8EJ6AUQORdqNTectY9hlOrWPK8wwo-aU\",\"Config\":\"ar://DgdB-2hLrxjhyEEbCML__dgZN5_uS7T6Z5XDkaFh3P0\",\"StartKey\":\"0\",\"UploadInterval\":60,\"InflationShareWeight\":10000,\"MinDelegation\":100000000000,\"MaxBundleSize\":100,\"Version\":\"0.0.0\",\"Binaries\":\"{}\",\"StorageProviderId\":2,\"CompressionId\":1}", } p, v := BuildGovernanceTxs(s, []sdk.Msg{msg}) @@ -247,23 +217,21 @@ var _ = Describe("msg_server_update_pool.go", Ordered, func() { pool, _ := s.App().PoolKeeper.GetPool(s.Ctx(), 1) Expect(pool).To(Equal(types.Pool{ - Id: 1, - Name: "TestPool2", - Runtime: "@kyve/test", - Logo: "ar://Tewyv2P5VEG8EJ6AUQORdqNTectY9hlOrWPK8wwo-aU", - Config: "ar://DgdB-2hLrxjhyEEbCML__dgZN5_uS7T6Z5XDkaFh3P0", - StartKey: "", - CurrentKey: "", - CurrentSummary: "", - CurrentIndex: 0, - TotalBundles: 0, - UploadInterval: 60, - OperatingCost: 10000, - MinDelegation: 100 * i.KYVE, - MaxBundleSize: 100, - Disabled: false, - Funders: nil, - TotalFunds: 0, + Id: 1, + Name: "TestPool2", + Runtime: "@kyve/test", + Logo: "ar://Tewyv2P5VEG8EJ6AUQORdqNTectY9hlOrWPK8wwo-aU", + Config: "ar://DgdB-2hLrxjhyEEbCML__dgZN5_uS7T6Z5XDkaFh3P0", + StartKey: "", + CurrentKey: "", + CurrentSummary: "", + CurrentIndex: 0, + TotalBundles: 0, + UploadInterval: 60, + InflationShareWeight: 10000, + MinDelegation: 100 * i.KYVE, + MaxBundleSize: 100, + Disabled: false, Protocol: &types.Protocol{ Version: "", Binaries: "", @@ -285,7 +253,7 @@ var _ = Describe("msg_server_update_pool.go", Ordered, func() { msg := &types.MsgUpdatePool{ Authority: gov, Id: 1, - Payload: "invalid_json_payload\",\"Runtime\":\"@kyve/test\",\"Logo\":\"ar://Tewyv2P5VEG8EJ6AUQORdqNTectY9hlOrWPK8wwo-aU\",\"Config\":\"ar://DgdB-2hLrxjhyEEbCML__dgZN5_uS7T6Z5XDkaFh3P0\",\"StartKey\":\"0\",\"UploadInterval\":60,\"OperatingCost\":10000,\"MinDelegation\":100000000000,\"MaxBundleSize\":100,\"Version\":\"0.0.0\",\"Binaries\":\"{}\",\"StorageProviderId\":2,\"CompressionId\":1}", + Payload: "invalid_json_payload\",\"Runtime\":\"@kyve/test\",\"Logo\":\"ar://Tewyv2P5VEG8EJ6AUQORdqNTectY9hlOrWPK8wwo-aU\",\"Config\":\"ar://DgdB-2hLrxjhyEEbCML__dgZN5_uS7T6Z5XDkaFh3P0\",\"StartKey\":\"0\",\"UploadInterval\":60,\"InflationShareWeight\":10000,\"MinDelegation\":100000000000,\"MaxBundleSize\":100,\"Version\":\"0.0.0\",\"Binaries\":\"{}\",\"StorageProviderId\":2,\"CompressionId\":1}", } p, _ := BuildGovernanceTxs(s, []sdk.Msg{msg}) @@ -322,12 +290,12 @@ var _ = Describe("msg_server_update_pool.go", Ordered, func() { Expect(pool.Name).To(BeEmpty()) }) - It("Update pool with invalid OperatingCost", func() { + It("Update pool with invalid InflationShareWeight", func() { // ARRANGE msg := &types.MsgUpdatePool{ Authority: gov, Id: 1, - Payload: "{\"OperatingCost\": -1}", + Payload: "{\"InflationShareWeight\": -1}", } p, _ := BuildGovernanceTxs(s, []sdk.Msg{msg}) diff --git a/x/pool/spec/02_state.md b/x/pool/spec/02_state.md index 17c51672..c8b582b8 100644 --- a/x/pool/spec/02_state.md +++ b/x/pool/spec/02_state.md @@ -103,8 +103,8 @@ message Pool { // upload_interval ... uint64 upload_interval = 11; - // operating_cost ... - uint64 operating_cost = 12; + // inflation_share_weight ... + uint64 inflation_share_weight = 12; // min_delegation ... uint64 min_delegation = 13; // max_bundle_size ... @@ -113,10 +113,8 @@ message Pool { // disabled ... bool disabled = 15; - // funders ... - repeated Funder funders = 16; - // total_funds ... - uint64 total_funds = 17; + // old funders and total_funds fields + reserved 16, 17; // protocol ... Protocol protocol = 18; diff --git a/x/pool/spec/06_events.md b/x/pool/spec/06_events.md index 6ec5be6d..c26c3c51 100644 --- a/x/pool/spec/06_events.md +++ b/x/pool/spec/06_events.md @@ -114,9 +114,9 @@ message EventCreatePool { // upload_interval is the interval the pool should validate // bundles with uint64 upload_interval = 7; - // operating_cost is the fixed cost which gets paid out + // inflation_share_weight is the fixed cost which gets paid out // to every successful uploader - uint64 operating_cost = 8; + uint64 inflation_share_weight = 8; // min_delegation is the minimum amount of $KYVE the pool has // to have in order to produce bundles uint64 min_delegation = 9; @@ -256,9 +256,9 @@ message EventPoolUpdated { // upload_interval is the interval the pool should validate // bundles with uint64 upload_interval = 7; - // operating_cost is the fixed cost which gets paid out + // inflation_share_weight is the fixed cost which gets paid out // to every successful uploader - uint64 operating_cost = 8; + uint64 inflation_share_weight = 8; // min_delegation is the minimum amount of $KYVE the pool has // to have in order to produce bundles uint64 min_delegation = 9; diff --git a/x/pool/types/codec.go b/x/pool/types/codec.go index b6f742a4..1bb09ac4 100644 --- a/x/pool/types/codec.go +++ b/x/pool/types/codec.go @@ -7,15 +7,10 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { - cdc.RegisterConcrete(&MsgFundPool{}, "kyve/pool/MsgFundPool", nil) - cdc.RegisterConcrete(&MsgDefundPool{}, "kyve/pool/MsgDefundPool", nil) +func RegisterLegacyAminoCodec(_ *codec.LegacyAmino) { } func RegisterInterfaces(registry codecTypes.InterfaceRegistry) { - registry.RegisterImplementations((*sdk.Msg)(nil), &MsgFundPool{}) - registry.RegisterImplementations((*sdk.Msg)(nil), &MsgDefundPool{}) - registry.RegisterImplementations((*sdk.Msg)(nil), &MsgCreatePool{}) registry.RegisterImplementations((*sdk.Msg)(nil), &MsgUpdatePool{}) registry.RegisterImplementations((*sdk.Msg)(nil), &MsgDisablePool{}) diff --git a/x/pool/types/errors.go b/x/pool/types/errors.go index 991c858d..6f2ebc64 100644 --- a/x/pool/types/errors.go +++ b/x/pool/types/errors.go @@ -4,12 +4,9 @@ import ( "cosmossdk.io/errors" ) -var ErrPoolNotFound = errors.Register(ModuleName, 1100, "pool with id %v does not exist") - // funding errors var ( - ErrFundsTooLow = errors.Register(ModuleName, 1101, "minimum funding amount of %vkyve not reached") - ErrDefundTooHigh = errors.Register(ModuleName, 1102, "maximum defunding amount of %vkyve surpassed") - ErrInvalidJson = errors.Register(ModuleName, 1103, "invalid json object: %v") - ErrInvalidArgs = errors.Register(ModuleName, 1104, "invalid args") + ErrPoolNotFound = errors.Register(ModuleName, 1100, "pool with id %v does not exist") + ErrInvalidJson = errors.Register(ModuleName, 1101, "invalid json object: %v") + ErrInvalidArgs = errors.Register(ModuleName, 1102, "invalid args") ) diff --git a/x/pool/types/events.pb.go b/x/pool/types/events.pb.go index e2718420..35d7e1a4 100644 --- a/x/pool/types/events.pb.go +++ b/x/pool/types/events.pb.go @@ -108,9 +108,9 @@ type EventCreatePool struct { // upload_interval is the interval the pool should validate // bundles with UploadInterval uint64 `protobuf:"varint,7,opt,name=upload_interval,json=uploadInterval,proto3" json:"upload_interval,omitempty"` - // operating_cost is the fixed cost which gets paid out + // inflation_share_weight is the fixed cost which gets paid out // to every successful uploader - OperatingCost uint64 `protobuf:"varint,8,opt,name=operating_cost,json=operatingCost,proto3" json:"operating_cost,omitempty"` + InflationShareWeight uint64 `protobuf:"varint,8,opt,name=inflation_share_weight,json=inflationShareWeight,proto3" json:"inflation_share_weight,omitempty"` // min_delegation is the minimum amount of $KYVE the pool has // to have in order to produce bundles MinDelegation uint64 `protobuf:"varint,9,opt,name=min_delegation,json=minDelegation,proto3" json:"min_delegation,omitempty"` @@ -211,9 +211,9 @@ func (m *EventCreatePool) GetUploadInterval() uint64 { return 0 } -func (m *EventCreatePool) GetOperatingCost() uint64 { +func (m *EventCreatePool) GetInflationShareWeight() uint64 { if m != nil { - return m.OperatingCost + return m.InflationShareWeight } return 0 } @@ -524,9 +524,9 @@ type EventPoolUpdated struct { // upload_interval is the interval the pool should validate // bundles with UploadInterval uint64 `protobuf:"varint,7,opt,name=upload_interval,json=uploadInterval,proto3" json:"upload_interval,omitempty"` - // operating_cost is the fixed cost which gets paid out + // inflation_share_weight is the fixed cost which gets paid out // to every successful uploader - OperatingCost uint64 `protobuf:"varint,8,opt,name=operating_cost,json=operatingCost,proto3" json:"operating_cost,omitempty"` + InflationShareWeight uint64 `protobuf:"varint,8,opt,name=inflation_share_weight,json=inflationShareWeight,proto3" json:"inflation_share_weight,omitempty"` // min_delegation is the minimum amount of $KYVE the pool has // to have in order to produce bundles MinDelegation uint64 `protobuf:"varint,9,opt,name=min_delegation,json=minDelegation,proto3" json:"min_delegation,omitempty"` @@ -623,9 +623,9 @@ func (m *EventPoolUpdated) GetUploadInterval() uint64 { return 0 } -func (m *EventPoolUpdated) GetOperatingCost() uint64 { +func (m *EventPoolUpdated) GetInflationShareWeight() uint64 { if m != nil { - return m.OperatingCost + return m.InflationShareWeight } return 0 } @@ -658,136 +658,6 @@ func (m *EventPoolUpdated) GetCompressionId() uint32 { return 0 } -// EventFundPool is an event emitted when a pool is funded. -// emitted_by: MsgFundPool -type EventFundPool struct { - // pool_id is the unique ID of the pool. - PoolId uint64 `protobuf:"varint,1,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty"` - // address is the account address of the pool funder. - Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"` - // amount is the amount in ukyve the funder has funded - Amount uint64 `protobuf:"varint,3,opt,name=amount,proto3" json:"amount,omitempty"` -} - -func (m *EventFundPool) Reset() { *m = EventFundPool{} } -func (m *EventFundPool) String() string { return proto.CompactTextString(m) } -func (*EventFundPool) ProtoMessage() {} -func (*EventFundPool) Descriptor() ([]byte, []int) { - return fileDescriptor_c1828a100d789238, []int{7} -} -func (m *EventFundPool) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *EventFundPool) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_EventFundPool.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 *EventFundPool) XXX_Merge(src proto.Message) { - xxx_messageInfo_EventFundPool.Merge(m, src) -} -func (m *EventFundPool) XXX_Size() int { - return m.Size() -} -func (m *EventFundPool) XXX_DiscardUnknown() { - xxx_messageInfo_EventFundPool.DiscardUnknown(m) -} - -var xxx_messageInfo_EventFundPool proto.InternalMessageInfo - -func (m *EventFundPool) GetPoolId() uint64 { - if m != nil { - return m.PoolId - } - return 0 -} - -func (m *EventFundPool) GetAddress() string { - if m != nil { - return m.Address - } - return "" -} - -func (m *EventFundPool) GetAmount() uint64 { - if m != nil { - return m.Amount - } - return 0 -} - -// EventDefundPool is an event emitted when a pool is defunded. -// emitted_by: MsgDefundPool -type EventDefundPool struct { - // pool_id is the unique ID of the pool. - PoolId uint64 `protobuf:"varint,1,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty"` - // address is the account address of the pool funder. - Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"` - // amount is the amount in ukyve the funder has defunded - Amount uint64 `protobuf:"varint,3,opt,name=amount,proto3" json:"amount,omitempty"` -} - -func (m *EventDefundPool) Reset() { *m = EventDefundPool{} } -func (m *EventDefundPool) String() string { return proto.CompactTextString(m) } -func (*EventDefundPool) ProtoMessage() {} -func (*EventDefundPool) Descriptor() ([]byte, []int) { - return fileDescriptor_c1828a100d789238, []int{8} -} -func (m *EventDefundPool) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *EventDefundPool) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_EventDefundPool.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 *EventDefundPool) XXX_Merge(src proto.Message) { - xxx_messageInfo_EventDefundPool.Merge(m, src) -} -func (m *EventDefundPool) XXX_Size() int { - return m.Size() -} -func (m *EventDefundPool) XXX_DiscardUnknown() { - xxx_messageInfo_EventDefundPool.DiscardUnknown(m) -} - -var xxx_messageInfo_EventDefundPool proto.InternalMessageInfo - -func (m *EventDefundPool) GetPoolId() uint64 { - if m != nil { - return m.PoolId - } - return 0 -} - -func (m *EventDefundPool) GetAddress() string { - if m != nil { - return m.Address - } - return "" -} - -func (m *EventDefundPool) GetAmount() uint64 { - if m != nil { - return m.Amount - } - return 0 -} - // EventDefundPool is an event emitted when a pool is defunded. // emitted_by: MsgSubmitBundleProposal type EventPoolFundsSlashed struct { @@ -803,7 +673,7 @@ func (m *EventPoolFundsSlashed) Reset() { *m = EventPoolFundsSlashed{} } func (m *EventPoolFundsSlashed) String() string { return proto.CompactTextString(m) } func (*EventPoolFundsSlashed) ProtoMessage() {} func (*EventPoolFundsSlashed) Descriptor() ([]byte, []int) { - return fileDescriptor_c1828a100d789238, []int{9} + return fileDescriptor_c1828a100d789238, []int{7} } func (m *EventPoolFundsSlashed) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -853,53 +723,6 @@ func (m *EventPoolFundsSlashed) GetAmount() uint64 { return 0 } -// EventPoolOutOfFunds is an event emitted when a pool has run out of funds -// emitted_by: MsgSubmitBundleProposal -type EventPoolOutOfFunds struct { - // pool_id is the unique ID of the pool. - PoolId uint64 `protobuf:"varint,1,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty"` -} - -func (m *EventPoolOutOfFunds) Reset() { *m = EventPoolOutOfFunds{} } -func (m *EventPoolOutOfFunds) String() string { return proto.CompactTextString(m) } -func (*EventPoolOutOfFunds) ProtoMessage() {} -func (*EventPoolOutOfFunds) Descriptor() ([]byte, []int) { - return fileDescriptor_c1828a100d789238, []int{10} -} -func (m *EventPoolOutOfFunds) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *EventPoolOutOfFunds) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_EventPoolOutOfFunds.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 *EventPoolOutOfFunds) XXX_Merge(src proto.Message) { - xxx_messageInfo_EventPoolOutOfFunds.Merge(m, src) -} -func (m *EventPoolOutOfFunds) XXX_Size() int { - return m.Size() -} -func (m *EventPoolOutOfFunds) XXX_DiscardUnknown() { - xxx_messageInfo_EventPoolOutOfFunds.DiscardUnknown(m) -} - -var xxx_messageInfo_EventPoolOutOfFunds proto.InternalMessageInfo - -func (m *EventPoolOutOfFunds) GetPoolId() uint64 { - if m != nil { - return m.PoolId - } - return 0 -} - func init() { proto.RegisterType((*EventUpdateParams)(nil), "kyve.pool.v1beta1.EventUpdateParams") proto.RegisterType((*EventCreatePool)(nil), "kyve.pool.v1beta1.EventCreatePool") @@ -908,66 +731,61 @@ func init() { proto.RegisterType((*EventRuntimeUpgradeScheduled)(nil), "kyve.pool.v1beta1.EventRuntimeUpgradeScheduled") proto.RegisterType((*EventRuntimeUpgradeCancelled)(nil), "kyve.pool.v1beta1.EventRuntimeUpgradeCancelled") proto.RegisterType((*EventPoolUpdated)(nil), "kyve.pool.v1beta1.EventPoolUpdated") - proto.RegisterType((*EventFundPool)(nil), "kyve.pool.v1beta1.EventFundPool") - proto.RegisterType((*EventDefundPool)(nil), "kyve.pool.v1beta1.EventDefundPool") proto.RegisterType((*EventPoolFundsSlashed)(nil), "kyve.pool.v1beta1.EventPoolFundsSlashed") - proto.RegisterType((*EventPoolOutOfFunds)(nil), "kyve.pool.v1beta1.EventPoolOutOfFunds") } func init() { proto.RegisterFile("kyve/pool/v1beta1/events.proto", fileDescriptor_c1828a100d789238) } var fileDescriptor_c1828a100d789238 = []byte{ - // 792 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x55, 0xcd, 0x6e, 0xeb, 0x44, - 0x14, 0x8e, 0x93, 0x34, 0x6d, 0x26, 0x4d, 0x42, 0x7c, 0xf9, 0x31, 0x05, 0x85, 0x10, 0x74, 0xa1, - 0xb0, 0x70, 0x74, 0x61, 0x8f, 0x44, 0xd3, 0x22, 0x45, 0x57, 0xe2, 0x5e, 0x25, 0xba, 0x48, 0x54, - 0x48, 0xd6, 0xc4, 0x73, 0xe2, 0x8c, 0x6a, 0xcf, 0x58, 0x33, 0xe3, 0xa4, 0xe9, 0x53, 0xf0, 0x04, - 0xbc, 0x01, 0x6f, 0xc1, 0xa2, 0xcb, 0x2e, 0x58, 0xb0, 0x42, 0xa8, 0x7d, 0x11, 0x34, 0xe3, 0x1f, - 0x92, 0xd6, 0x45, 0x5d, 0x80, 0xc4, 0xce, 0xe7, 0x9c, 0xef, 0xfc, 0xcc, 0xf9, 0xce, 0x97, 0xa0, - 0xfe, 0xc5, 0x66, 0x05, 0xa3, 0x98, 0xf3, 0x70, 0xb4, 0x7a, 0x31, 0x07, 0x85, 0x5f, 0x8c, 0x60, - 0x05, 0x4c, 0x49, 0x37, 0x16, 0x5c, 0x71, 0xbb, 0xa7, 0xe3, 0xae, 0x8e, 0xbb, 0x59, 0xfc, 0xe8, - 0xed, 0x80, 0x07, 0xdc, 0x44, 0x47, 0xfa, 0x2b, 0x05, 0x1e, 0x95, 0x14, 0x8a, 0xb1, 0xc0, 0x51, - 0x56, 0x68, 0xf8, 0x8b, 0x85, 0x7a, 0x67, 0xba, 0xf2, 0x9b, 0x98, 0x60, 0x05, 0xaf, 0x4d, 0xcc, - 0xfe, 0x1a, 0x21, 0x1e, 0x12, 0x2f, 0x45, 0x3a, 0xd6, 0xc0, 0x3a, 0x6e, 0x7d, 0xf9, 0xbe, 0xfb, - 0xa0, 0xa7, 0x9b, 0xc2, 0x4f, 0xea, 0xd7, 0x7f, 0x7c, 0x54, 0x99, 0x36, 0x79, 0x48, 0xfe, 0xce, - 0x67, 0xb0, 0xce, 0xf3, 0xab, 0x4f, 0xcc, 0x67, 0xb0, 0xce, 0xf2, 0x1d, 0xb4, 0x1f, 0xe3, 0x4d, - 0xc8, 0x31, 0x71, 0x6a, 0x03, 0xeb, 0xb8, 0x39, 0xcd, 0xcd, 0xe1, 0xaf, 0x35, 0xd4, 0x35, 0xf3, - 0x8e, 0x05, 0xe8, 0x79, 0x39, 0x0f, 0xed, 0x0e, 0xaa, 0x52, 0x62, 0xa6, 0xac, 0x4f, 0xab, 0x94, - 0xd8, 0x36, 0xaa, 0x33, 0x1c, 0x81, 0xe9, 0xdb, 0x9c, 0x9a, 0x6f, 0x5d, 0x51, 0x24, 0x4c, 0xd1, - 0x08, 0xf2, 0x8a, 0x99, 0xa9, 0xd1, 0x21, 0x0f, 0xb8, 0x53, 0x4f, 0xd1, 0xfa, 0xdb, 0x7e, 0x17, - 0x35, 0x7c, 0xce, 0x16, 0x34, 0x70, 0xf6, 0x8c, 0x37, 0xb3, 0xec, 0x0f, 0x50, 0x53, 0x2a, 0x2c, - 0x94, 0x77, 0x01, 0x1b, 0xa7, 0x61, 0x42, 0x07, 0xc6, 0xf1, 0x12, 0x36, 0xf6, 0x67, 0xa8, 0x9b, - 0xc4, 0x7a, 0x48, 0x8f, 0x32, 0x05, 0x62, 0x85, 0x43, 0x67, 0xdf, 0xcc, 0xd4, 0x49, 0xdd, 0x93, - 0xcc, 0x6b, 0x3f, 0x47, 0x1d, 0x1e, 0x83, 0xc0, 0x8a, 0xb2, 0xc0, 0xf3, 0xb9, 0x54, 0xce, 0x81, - 0xc1, 0xb5, 0x0b, 0xef, 0x98, 0x4b, 0xa5, 0x61, 0x11, 0x65, 0x1e, 0x81, 0x10, 0x02, 0xac, 0x28, - 0x67, 0x4e, 0x33, 0x85, 0x45, 0x94, 0x9d, 0x16, 0x4e, 0xfb, 0x53, 0xd4, 0x8d, 0xf0, 0xa5, 0x37, - 0x4f, 0x18, 0x09, 0xc1, 0x93, 0xf4, 0x0a, 0x1c, 0x94, 0xe1, 0xf0, 0xe5, 0x89, 0xf1, 0xce, 0xe8, - 0x95, 0xd9, 0xc0, 0x0a, 0x84, 0xd4, 0x75, 0x5a, 0xe9, 0x06, 0x32, 0xd3, 0x3e, 0x42, 0x07, 0x73, - 0xca, 0xb0, 0xa0, 0x20, 0x9d, 0xc3, 0xf4, 0x51, 0xb9, 0x6d, 0xbb, 0xe8, 0x99, 0x54, 0x5c, 0xe0, - 0x00, 0xbc, 0x58, 0xf0, 0x15, 0x25, 0x20, 0x3c, 0x4a, 0x9c, 0xf6, 0xc0, 0x3a, 0x6e, 0x4f, 0x7b, - 0x59, 0xe8, 0x75, 0x16, 0x99, 0x10, 0x3d, 0xb4, 0xcf, 0xa3, 0x58, 0x80, 0xd4, 0xa5, 0x35, 0xb4, - 0x63, 0xa0, 0xed, 0x2d, 0xef, 0x84, 0x0c, 0x87, 0xe8, 0x2d, 0xc3, 0xa2, 0xe6, 0xef, 0x8c, 0xe1, - 0x79, 0x08, 0xe4, 0x3e, 0x8d, 0xc3, 0x4f, 0xb2, 0xcb, 0xd4, 0x98, 0x53, 0x2a, 0xcb, 0x41, 0xbf, - 0x59, 0xe8, 0x43, 0x83, 0x9a, 0xa6, 0x74, 0xbe, 0x89, 0x03, 0x81, 0x09, 0xcc, 0xfc, 0x25, 0x90, - 0x44, 0x27, 0x6c, 0x11, 0x6f, 0xed, 0x12, 0xbf, 0xb5, 0x90, 0xea, 0xee, 0x42, 0x3e, 0x46, 0x87, - 0x32, 0x2f, 0xe0, 0x61, 0x65, 0x2e, 0xa6, 0x3e, 0x6d, 0x15, 0xbe, 0x6f, 0x94, 0xde, 0x19, 0x49, - 0x44, 0x4a, 0x4b, 0xdd, 0x84, 0x0b, 0x7b, 0x67, 0x9f, 0x7b, 0xf7, 0xf6, 0xf9, 0x1c, 0x75, 0xf0, - 0x62, 0x01, 0xbe, 0x02, 0xe2, 0x69, 0x29, 0x48, 0xa7, 0x31, 0xa8, 0x69, 0xb2, 0x72, 0xaf, 0x7e, - 0xad, 0x1c, 0x7a, 0xa5, 0xaf, 0x1a, 0x63, 0xe6, 0x43, 0xf8, 0xcf, 0xaf, 0x7a, 0xd8, 0xa0, 0x5a, - 0xd6, 0xe0, 0xe7, 0xda, 0x16, 0x03, 0xa9, 0xf6, 0x1f, 0x2c, 0xd7, 0xfe, 0x02, 0xf5, 0x04, 0x5e, - 0x7b, 0x89, 0x09, 0x7b, 0x52, 0x09, 0xca, 0x82, 0x6c, 0x57, 0x5d, 0x81, 0xd7, 0x69, 0xda, 0xcc, - 0xb8, 0x0b, 0xd1, 0xd5, 0xca, 0x45, 0x57, 0x2f, 0x17, 0xdd, 0x5e, 0xa9, 0xe8, 0x1a, 0x3b, 0xa2, - 0xfb, 0x9f, 0xeb, 0xea, 0x11, 0x85, 0xb4, 0x9e, 0xae, 0x90, 0xc3, 0x32, 0x85, 0x9c, 0xa3, 0xb6, - 0xe1, 0xe7, 0xdb, 0x84, 0x19, 0xca, 0xec, 0xf7, 0xd0, 0xbe, 0xe6, 0xd3, 0x2b, 0x18, 0x6a, 0x68, - 0x73, 0x62, 0x6e, 0x01, 0x13, 0xa2, 0x33, 0xf3, 0x3b, 0xce, 0x4c, 0xbd, 0x51, 0x1c, 0xf1, 0x84, - 0xe5, 0x17, 0x9c, 0x59, 0xc3, 0x1f, 0xb3, 0xdf, 0xd0, 0x53, 0x58, 0xfc, 0x07, 0xd5, 0xe7, 0xe8, - 0x9d, 0xe2, 0xb2, 0xf4, 0xf4, 0x72, 0x16, 0x62, 0xb9, 0x04, 0xf2, 0x6f, 0xf6, 0x70, 0xd1, 0xb3, - 0xa2, 0xc7, 0xab, 0x44, 0xbd, 0x5a, 0x98, 0x46, 0x8f, 0x76, 0x38, 0x19, 0x5f, 0xdf, 0xf6, 0xad, - 0x9b, 0xdb, 0xbe, 0xf5, 0xe7, 0x6d, 0xdf, 0xfa, 0xe9, 0xae, 0x5f, 0xb9, 0xb9, 0xeb, 0x57, 0x7e, - 0xbf, 0xeb, 0x57, 0xce, 0x3f, 0x0f, 0xa8, 0x5a, 0x26, 0x73, 0xd7, 0xe7, 0xd1, 0xe8, 0xe5, 0x0f, - 0xdf, 0x9f, 0x7d, 0x07, 0x6a, 0xcd, 0xc5, 0xc5, 0xc8, 0x5f, 0x62, 0xca, 0x46, 0x97, 0xe9, 0x5f, - 0xa7, 0xda, 0xc4, 0x20, 0xe7, 0x0d, 0xf3, 0x97, 0xf9, 0xd5, 0x5f, 0x01, 0x00, 0x00, 0xff, 0xff, - 0xc1, 0xd7, 0x44, 0xf8, 0x9d, 0x07, 0x00, 0x00, + // 763 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x55, 0xcf, 0x6e, 0x33, 0x35, + 0x10, 0xcf, 0x26, 0x69, 0xda, 0x38, 0x4d, 0x42, 0x96, 0x52, 0x96, 0x82, 0x42, 0x08, 0x2a, 0x14, + 0x0e, 0x89, 0x0a, 0x9c, 0x91, 0xe8, 0x1f, 0xa4, 0xa8, 0x12, 0xaa, 0x12, 0x15, 0x04, 0x17, 0xcb, + 0x89, 0x27, 0x1b, 0xab, 0xbb, 0xf6, 0xca, 0xf6, 0x26, 0x4d, 0x9f, 0x82, 0x17, 0xe9, 0x7b, 0xf4, + 0x58, 0x09, 0x0e, 0x9c, 0x10, 0x6a, 0x5f, 0x04, 0xd9, 0xbb, 0x9b, 0x2f, 0x69, 0xf7, 0xfb, 0xd4, + 0xeb, 0x77, 0xf3, 0xcc, 0xef, 0x37, 0xe3, 0xf1, 0xcc, 0xfc, 0x76, 0x51, 0xfb, 0x7a, 0x39, 0x87, + 0x7e, 0x24, 0x44, 0xd0, 0x9f, 0x1f, 0x8f, 0x41, 0x93, 0xe3, 0x3e, 0xcc, 0x81, 0x6b, 0xd5, 0x8b, + 0xa4, 0xd0, 0xc2, 0x6d, 0x19, 0xbc, 0x67, 0xf0, 0x5e, 0x8a, 0x1f, 0xec, 0xf9, 0xc2, 0x17, 0x16, + 0xed, 0x9b, 0x53, 0x42, 0x3c, 0xc8, 0x49, 0x14, 0x11, 0x49, 0xc2, 0x34, 0x51, 0xf7, 0xce, 0x41, + 0xad, 0x73, 0x93, 0xf9, 0x2a, 0xa2, 0x44, 0xc3, 0xa5, 0xc5, 0xdc, 0x1f, 0x11, 0x12, 0x01, 0xc5, + 0x09, 0xd3, 0x73, 0x3a, 0xce, 0x51, 0xed, 0xbb, 0x4f, 0x7a, 0x2f, 0xee, 0xec, 0x25, 0xf4, 0x93, + 0xf2, 0xfd, 0xbf, 0x9f, 0x17, 0x86, 0x55, 0x11, 0xd0, 0x37, 0xf1, 0x1c, 0x16, 0x59, 0x7c, 0xf1, + 0x95, 0xf1, 0x1c, 0x16, 0x69, 0xbc, 0x87, 0xb6, 0x23, 0xb2, 0x0c, 0x04, 0xa1, 0x5e, 0xa9, 0xe3, + 0x1c, 0x55, 0x87, 0x99, 0xd9, 0xfd, 0xab, 0x84, 0x9a, 0xb6, 0xde, 0x53, 0x09, 0xa6, 0x5e, 0x21, + 0x02, 0xb7, 0x81, 0x8a, 0x8c, 0xda, 0x2a, 0xcb, 0xc3, 0x22, 0xa3, 0xae, 0x8b, 0xca, 0x9c, 0x84, + 0x60, 0xef, 0xad, 0x0e, 0xed, 0xd9, 0x64, 0x94, 0x31, 0xd7, 0x2c, 0x84, 0x2c, 0x63, 0x6a, 0x1a, + 0x76, 0x20, 0x7c, 0xe1, 0x95, 0x13, 0xb6, 0x39, 0xbb, 0xfb, 0xa8, 0x32, 0x11, 0x7c, 0xca, 0x7c, + 0x6f, 0xcb, 0x7a, 0x53, 0xcb, 0xfd, 0x14, 0x55, 0x95, 0x26, 0x52, 0xe3, 0x6b, 0x58, 0x7a, 0x15, + 0x0b, 0xed, 0x58, 0xc7, 0x05, 0x2c, 0xdd, 0xaf, 0x51, 0x33, 0x8e, 0x4c, 0x91, 0x98, 0x71, 0x0d, + 0x72, 0x4e, 0x02, 0x6f, 0xdb, 0xd6, 0xd4, 0x48, 0xdc, 0x83, 0xd4, 0xeb, 0xfe, 0x80, 0xf6, 0x19, + 0x9f, 0x06, 0x44, 0x33, 0xc1, 0xb1, 0x9a, 0x11, 0x09, 0x78, 0x01, 0xcc, 0x9f, 0x69, 0x6f, 0xc7, + 0xf2, 0xf7, 0x56, 0xe8, 0xc8, 0x80, 0xbf, 0x59, 0xcc, 0x3d, 0x44, 0x8d, 0x90, 0x71, 0x4c, 0x21, + 0x00, 0xdf, 0x82, 0x5e, 0xd5, 0xb2, 0xeb, 0x21, 0xe3, 0x67, 0x2b, 0xa7, 0xfb, 0x15, 0x6a, 0x86, + 0xe4, 0x06, 0x8f, 0x63, 0x4e, 0x03, 0xc0, 0x8a, 0xdd, 0x82, 0x87, 0x52, 0x1e, 0xb9, 0x39, 0xb1, + 0xde, 0x11, 0xbb, 0xb5, 0x0d, 0x99, 0x83, 0x54, 0x26, 0x4f, 0x2d, 0x69, 0x48, 0x6a, 0xba, 0x07, + 0x68, 0x67, 0xcc, 0x38, 0x91, 0x0c, 0x94, 0xb7, 0x9b, 0xbc, 0x31, 0xb3, 0xdd, 0x1e, 0xfa, 0x50, + 0x69, 0x21, 0x89, 0x0f, 0x38, 0x92, 0x62, 0xce, 0x28, 0x48, 0xcc, 0xa8, 0x57, 0xef, 0x38, 0x47, + 0xf5, 0x61, 0x2b, 0x85, 0x2e, 0x53, 0x64, 0x40, 0x4d, 0xd1, 0x13, 0x11, 0x46, 0x12, 0x94, 0x49, + 0x6d, 0xa8, 0x0d, 0x4b, 0xad, 0xaf, 0x79, 0x07, 0xb4, 0xdb, 0x45, 0x1f, 0xd8, 0xa1, 0x9a, 0x71, + 0x9e, 0x73, 0x32, 0x0e, 0x80, 0x3e, 0x9f, 0x6a, 0xf7, 0xcb, 0x74, 0x51, 0x0d, 0xe7, 0x8c, 0xa9, + 0x7c, 0xd2, 0xdf, 0x0e, 0xfa, 0xcc, 0xb2, 0x86, 0xc9, 0x74, 0xaf, 0x22, 0x5f, 0x12, 0x0a, 0xa3, + 0xc9, 0x0c, 0x68, 0x6c, 0x02, 0xd6, 0xf6, 0xc0, 0xd9, 0xdc, 0x83, 0xb5, 0x86, 0x14, 0x37, 0x1b, + 0xf2, 0x05, 0xda, 0x55, 0x59, 0x02, 0x4c, 0xb4, 0x5d, 0xa0, 0xf2, 0xb0, 0xb6, 0xf2, 0xfd, 0xa4, + 0x4d, 0xcf, 0x68, 0x2c, 0x93, 0xb1, 0x94, 0x2d, 0xbc, 0xb2, 0x37, 0xfa, 0xb9, 0xf5, 0xac, 0x9f, + 0x87, 0xa8, 0x41, 0xa6, 0x53, 0x98, 0x68, 0xa0, 0xd8, 0x28, 0x43, 0x79, 0x95, 0x4e, 0xc9, 0x0c, + 0x2b, 0xf3, 0x9a, 0xd7, 0xaa, 0x2e, 0xce, 0x7d, 0xd5, 0x29, 0xe1, 0x13, 0x08, 0xde, 0xfd, 0xaa, + 0x97, 0x17, 0x14, 0xf3, 0x2e, 0xb8, 0x2b, 0xad, 0x4d, 0x20, 0xf9, 0x14, 0xbc, 0x68, 0xae, 0xfb, + 0x2d, 0x6a, 0x49, 0xb2, 0xc0, 0xb1, 0x85, 0xb1, 0xd2, 0x92, 0x71, 0x3f, 0xed, 0x55, 0x53, 0x92, + 0x45, 0x12, 0x36, 0xb2, 0xee, 0x95, 0x06, 0x4b, 0xf9, 0x1a, 0x2c, 0xe7, 0x6b, 0x70, 0x2b, 0x57, + 0x83, 0x95, 0x0d, 0x0d, 0xbe, 0x5f, 0x32, 0x7b, 0x8b, 0x60, 0x6a, 0xaf, 0x17, 0xcc, 0x6e, 0x9e, + 0x60, 0xc6, 0xe8, 0xa3, 0xd5, 0xb8, 0x7e, 0x8e, 0x39, 0x55, 0xa3, 0x80, 0xa8, 0x19, 0x50, 0xf7, + 0x63, 0xb4, 0x6d, 0xc6, 0x8c, 0x57, 0x83, 0xab, 0x18, 0x73, 0x60, 0x57, 0x84, 0x50, 0x6a, 0x32, + 0x64, 0xeb, 0x9d, 0x9a, 0xa6, 0xd1, 0x24, 0x14, 0x31, 0xcf, 0x16, 0x3b, 0xb5, 0x4e, 0x4e, 0xef, + 0x1f, 0xdb, 0xce, 0xc3, 0x63, 0xdb, 0xf9, 0xef, 0xb1, 0xed, 0xfc, 0xf9, 0xd4, 0x2e, 0x3c, 0x3c, + 0xb5, 0x0b, 0xff, 0x3c, 0xb5, 0x0b, 0x7f, 0x7c, 0xe3, 0x33, 0x3d, 0x8b, 0xc7, 0xbd, 0x89, 0x08, + 0xfb, 0x17, 0xbf, 0xff, 0x7a, 0xfe, 0x0b, 0xe8, 0x85, 0x90, 0xd7, 0xfd, 0xc9, 0x8c, 0x30, 0xde, + 0xbf, 0x49, 0x7e, 0x37, 0x7a, 0x19, 0x81, 0x1a, 0x57, 0xec, 0x6f, 0xe6, 0xfb, 0xff, 0x03, 0x00, + 0x00, 0xff, 0xff, 0x99, 0xc5, 0x91, 0xec, 0xd1, 0x06, 0x00, 0x00, } func (m *EventUpdateParams) Marshal() (dAtA []byte, err error) { @@ -1074,8 +892,8 @@ func (m *EventCreatePool) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x48 } - if m.OperatingCost != 0 { - i = encodeVarintEvents(dAtA, i, uint64(m.OperatingCost)) + if m.InflationShareWeight != 0 { + i = encodeVarintEvents(dAtA, i, uint64(m.InflationShareWeight)) i-- dAtA[i] = 0x40 } @@ -1343,8 +1161,8 @@ func (m *EventPoolUpdated) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x48 } - if m.OperatingCost != 0 { - i = encodeVarintEvents(dAtA, i, uint64(m.OperatingCost)) + if m.InflationShareWeight != 0 { + i = encodeVarintEvents(dAtA, i, uint64(m.InflationShareWeight)) i-- dAtA[i] = 0x40 } @@ -1396,86 +1214,6 @@ func (m *EventPoolUpdated) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *EventFundPool) 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 *EventFundPool) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *EventFundPool) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Amount != 0 { - i = encodeVarintEvents(dAtA, i, uint64(m.Amount)) - i-- - dAtA[i] = 0x18 - } - if len(m.Address) > 0 { - i -= len(m.Address) - copy(dAtA[i:], m.Address) - i = encodeVarintEvents(dAtA, i, uint64(len(m.Address))) - i-- - dAtA[i] = 0x12 - } - if m.PoolId != 0 { - i = encodeVarintEvents(dAtA, i, uint64(m.PoolId)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *EventDefundPool) 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 *EventDefundPool) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *EventDefundPool) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Amount != 0 { - i = encodeVarintEvents(dAtA, i, uint64(m.Amount)) - i-- - dAtA[i] = 0x18 - } - if len(m.Address) > 0 { - i -= len(m.Address) - copy(dAtA[i:], m.Address) - i = encodeVarintEvents(dAtA, i, uint64(len(m.Address))) - i-- - dAtA[i] = 0x12 - } - if m.PoolId != 0 { - i = encodeVarintEvents(dAtA, i, uint64(m.PoolId)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - func (m *EventPoolFundsSlashed) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1516,34 +1254,6 @@ func (m *EventPoolFundsSlashed) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *EventPoolOutOfFunds) 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 *EventPoolOutOfFunds) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *EventPoolOutOfFunds) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.PoolId != 0 { - i = encodeVarintEvents(dAtA, i, uint64(m.PoolId)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - func encodeVarintEvents(dAtA []byte, offset int, v uint64) int { offset -= sovEvents(v) base := offset @@ -1604,8 +1314,8 @@ func (m *EventCreatePool) Size() (n int) { if m.UploadInterval != 0 { n += 1 + sovEvents(uint64(m.UploadInterval)) } - if m.OperatingCost != 0 { - n += 1 + sovEvents(uint64(m.OperatingCost)) + if m.InflationShareWeight != 0 { + n += 1 + sovEvents(uint64(m.InflationShareWeight)) } if m.MinDelegation != 0 { n += 1 + sovEvents(uint64(m.MinDelegation)) @@ -1740,8 +1450,8 @@ func (m *EventPoolUpdated) Size() (n int) { if m.UploadInterval != 0 { n += 1 + sovEvents(uint64(m.UploadInterval)) } - if m.OperatingCost != 0 { - n += 1 + sovEvents(uint64(m.OperatingCost)) + if m.InflationShareWeight != 0 { + n += 1 + sovEvents(uint64(m.InflationShareWeight)) } if m.MinDelegation != 0 { n += 1 + sovEvents(uint64(m.MinDelegation)) @@ -1758,44 +1468,6 @@ func (m *EventPoolUpdated) Size() (n int) { return n } -func (m *EventFundPool) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.PoolId != 0 { - n += 1 + sovEvents(uint64(m.PoolId)) - } - l = len(m.Address) - if l > 0 { - n += 1 + l + sovEvents(uint64(l)) - } - if m.Amount != 0 { - n += 1 + sovEvents(uint64(m.Amount)) - } - return n -} - -func (m *EventDefundPool) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.PoolId != 0 { - n += 1 + sovEvents(uint64(m.PoolId)) - } - l = len(m.Address) - if l > 0 { - n += 1 + l + sovEvents(uint64(l)) - } - if m.Amount != 0 { - n += 1 + sovEvents(uint64(m.Amount)) - } - return n -} - func (m *EventPoolFundsSlashed) Size() (n int) { if m == nil { return 0 @@ -1815,18 +1487,6 @@ func (m *EventPoolFundsSlashed) Size() (n int) { return n } -func (m *EventPoolOutOfFunds) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.PoolId != 0 { - n += 1 + sovEvents(uint64(m.PoolId)) - } - return n -} - func sovEvents(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -2210,9 +1870,9 @@ func (m *EventCreatePool) Unmarshal(dAtA []byte) error { } case 8: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field OperatingCost", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field InflationShareWeight", wireType) } - m.OperatingCost = 0 + m.InflationShareWeight = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowEvents @@ -2222,7 +1882,7 @@ func (m *EventCreatePool) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.OperatingCost |= uint64(b&0x7F) << shift + m.InflationShareWeight |= uint64(b&0x7F) << shift if b < 0x80 { break } @@ -3173,9 +2833,9 @@ func (m *EventPoolUpdated) Unmarshal(dAtA []byte) error { } case 8: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field OperatingCost", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field InflationShareWeight", wireType) } - m.OperatingCost = 0 + m.InflationShareWeight = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowEvents @@ -3185,7 +2845,7 @@ func (m *EventPoolUpdated) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.OperatingCost |= uint64(b&0x7F) << shift + m.InflationShareWeight |= uint64(b&0x7F) << shift if b < 0x80 { break } @@ -3287,246 +2947,6 @@ func (m *EventPoolUpdated) Unmarshal(dAtA []byte) error { } return nil } -func (m *EventFundPool) 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 ErrIntOverflowEvents - } - 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: EventFundPool: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: EventFundPool: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field PoolId", wireType) - } - m.PoolId = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEvents - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.PoolId |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEvents - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthEvents - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthEvents - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Address = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) - } - m.Amount = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEvents - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Amount |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipEvents(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthEvents - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *EventDefundPool) 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 ErrIntOverflowEvents - } - 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: EventDefundPool: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: EventDefundPool: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field PoolId", wireType) - } - m.PoolId = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEvents - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.PoolId |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEvents - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthEvents - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthEvents - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Address = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) - } - m.Amount = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEvents - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Amount |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipEvents(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthEvents - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} func (m *EventPoolFundsSlashed) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -3647,75 +3067,6 @@ func (m *EventPoolFundsSlashed) Unmarshal(dAtA []byte) error { } return nil } -func (m *EventPoolOutOfFunds) 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 ErrIntOverflowEvents - } - 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: EventPoolOutOfFunds: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: EventPoolOutOfFunds: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field PoolId", wireType) - } - m.PoolId = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEvents - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.PoolId |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipEvents(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthEvents - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} func skipEvents(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/pool/types/expected_keepers.go b/x/pool/types/expected_keepers.go index 3c5ee050..d193dde2 100644 --- a/x/pool/types/expected_keepers.go +++ b/x/pool/types/expected_keepers.go @@ -2,10 +2,14 @@ package types import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/auth/types" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" ) -type AccountKeeper interface{} +type AccountKeeper interface { + GetAccount(ctx sdk.Context, addr sdk.AccAddress) types.AccountI + SetAccount(ctx sdk.Context, acc types.AccountI) +} type UpgradeKeeper interface { ScheduleUpgrade(ctx sdk.Context, plan upgradetypes.Plan) error @@ -15,3 +19,7 @@ type StakersKeeper interface { LeavePool(ctx sdk.Context, staker string, poolId uint64) GetAllStakerAddressesOfPool(ctx sdk.Context, poolId uint64) (stakers []string) } + +type FundersKeeper interface { + CreateFundingState(ctx sdk.Context, poolId uint64) +} diff --git a/x/pool/types/genesis.go b/x/pool/types/genesis.go index dff80bf7..096e5892 100644 --- a/x/pool/types/genesis.go +++ b/x/pool/types/genesis.go @@ -1,6 +1,8 @@ package types -import "fmt" +import ( + "fmt" +) // DefaultGenesis returns the default Capability genesis state func DefaultGenesis() *GenesisState { @@ -24,9 +26,6 @@ func (gs GenesisState) Validate() error { if elem.Id >= gs.PoolCount { return fmt.Errorf("pool id higher than pool count %v", elem) } - if len(elem.Funders) > MaxFunders { - return fmt.Errorf("more funders than allowed %v", elem) - } } return gs.Params.Validate() diff --git a/x/pool/types/keys.go b/x/pool/types/keys.go index 715bf985..4d44cd86 100644 --- a/x/pool/types/keys.go +++ b/x/pool/types/keys.go @@ -18,10 +18,6 @@ const ( MemStoreKey = "mem_pool" ) -const ( - MaxFunders = 50 // maximum amount of funders which are allowed -) - var ( // ParamsKey is the prefix for all module params defined in params.proto ParamsKey = []byte{0} diff --git a/x/pool/types/msgs.go b/x/pool/types/msgs.go index 7d6072aa..3996bc6e 100644 --- a/x/pool/types/msgs.go +++ b/x/pool/types/msgs.go @@ -36,8 +36,8 @@ func (msg *MsgCreatePool) ValidateBasic() error { return errors.Wrapf(errorsTypes.ErrInvalidRequest, "invalid upload interval") } - if err := util.ValidateNumber(msg.OperatingCost); err != nil { - return errors.Wrapf(errorsTypes.ErrInvalidRequest, "invalid operating cost") + if err := util.ValidateNumber(msg.InflationShareWeight); err != nil { + return errors.Wrapf(errorsTypes.ErrInvalidRequest, "invalid inflation share weight") } if err := util.ValidateNumber(msg.MinDelegation); err != nil { @@ -59,16 +59,16 @@ func (msg *MsgUpdatePool) GetSigners() []sdk.AccAddress { // PoolUpdate ... type PoolUpdate struct { - Name *string - Runtime *string - Logo *string - Config *string - UploadInterval *uint64 - OperatingCost *uint64 - MinDelegation *uint64 - MaxBundleSize *uint64 - StorageProviderId *uint32 - CompressionId *uint32 + Name *string + Runtime *string + Logo *string + Config *string + UploadInterval *uint64 + InflationShareWeight *uint64 + MinDelegation *uint64 + MaxBundleSize *uint64 + StorageProviderId *uint32 + CompressionId *uint32 } // ValidateBasic does a sanity check on the provided data. @@ -88,9 +88,9 @@ func (msg *MsgUpdatePool) ValidateBasic() error { } } - if payload.OperatingCost != nil { - if err := util.ValidateNumber(*payload.OperatingCost); err != nil { - return errors.Wrapf(errorsTypes.ErrInvalidRequest, "invalid operating cost") + if payload.InflationShareWeight != nil { + if err := util.ValidateNumber(*payload.InflationShareWeight); err != nil { + return errors.Wrapf(errorsTypes.ErrInvalidRequest, "invalid inflation share weight") } } diff --git a/x/pool/types/pool.go b/x/pool/types/pool.go index b9e46dbe..4354326a 100644 --- a/x/pool/types/pool.go +++ b/x/pool/types/pool.go @@ -2,84 +2,13 @@ package types import ( "fmt" - "math" sdk "github.com/cosmos/cosmos-sdk/types" authTypes "github.com/cosmos/cosmos-sdk/x/auth/types" ) -// Handles the funders of a pool. Functions safely add and remove funds to funders. -// If amount drops to zero the funder is automatically removed from the list. - -// AddAmountToFunder adds the given amount to an existing funder. -// If the funder does not exist, a new funder is inserted. -func (m *Pool) AddAmountToFunder(funderAddress string, amount uint64) { - for _, v := range m.Funders { - if v.Address == funderAddress { - m.TotalFunds += amount - v.Amount += amount - return - } - } - if amount > 0 { - // Funder was not found, insert new funder - m.Funders = append(m.Funders, &Funder{ - Address: funderAddress, - Amount: amount, - }) - m.TotalFunds += amount - } -} - -// SubtractAmountFromFunder subtracts the given amount form an existing funder -// If the amount is grater or equal to the funders amount, the funder is removed. -func (m *Pool) SubtractAmountFromFunder(funderAddress string, amount uint64) { - for i := range m.Funders { - if m.Funders[i].Address == funderAddress { - if m.Funders[i].Amount > amount { - m.TotalFunds -= amount - m.Funders[i].Amount -= amount - } else { - m.TotalFunds -= m.Funders[i].Amount - - // Remove funder - m.Funders[i] = m.Funders[len(m.Funders)-1] - m.Funders = m.Funders[:len(m.Funders)-1] - } - return - } - } -} - -func (m *Pool) RemoveFunder(funderAddress string) { - m.SubtractAmountFromFunder(funderAddress, math.MaxUint64) -} - -func (m *Pool) GetFunderAmount(address string) uint64 { - for _, v := range m.Funders { - if v.Address == address { - return v.Amount - } - } - return 0 -} - func (m *Pool) GetPoolAccount() sdk.AccAddress { name := fmt.Sprintf("%s/%d", ModuleName, m.Id) return authTypes.NewModuleAddress(name) } - -func (m *Pool) GetLowestFunder() Funder { - if len(m.Funders) == 0 { - return Funder{} - } - - lowestFunder := m.Funders[0] - for _, v := range m.Funders { - if v.Amount < lowestFunder.Amount { - lowestFunder = v - } - } - return *lowestFunder -} diff --git a/x/pool/types/pool.pb.go b/x/pool/types/pool.pb.go index 11ccca00..a02bd2e7 100644 --- a/x/pool/types/pool.pb.go +++ b/x/pool/types/pool.pb.go @@ -221,62 +221,6 @@ func (m *UpgradePlan) GetDuration() uint64 { return 0 } -// Funder is the object which holds info about a single pool funder -type Funder struct { - // address is the address of the funder - Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` - // amount is the current amount of funds in ukyve the funder has - // still funded the pool with - Amount uint64 `protobuf:"varint,2,opt,name=amount,proto3" json:"amount,omitempty"` -} - -func (m *Funder) Reset() { *m = Funder{} } -func (m *Funder) String() string { return proto.CompactTextString(m) } -func (*Funder) ProtoMessage() {} -func (*Funder) Descriptor() ([]byte, []int) { - return fileDescriptor_40c1730f47ff2ef8, []int{2} -} -func (m *Funder) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Funder) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Funder.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 *Funder) XXX_Merge(src proto.Message) { - xxx_messageInfo_Funder.Merge(m, src) -} -func (m *Funder) XXX_Size() int { - return m.Size() -} -func (m *Funder) XXX_DiscardUnknown() { - xxx_messageInfo_Funder.DiscardUnknown(m) -} - -var xxx_messageInfo_Funder proto.InternalMessageInfo - -func (m *Funder) GetAddress() string { - if m != nil { - return m.Address - } - return "" -} - -func (m *Funder) GetAmount() uint64 { - if m != nil { - return m.Amount - } - return 0 -} - // Pool ... type Pool struct { // id - unique identifier of the pool, can not be changed @@ -302,8 +246,8 @@ type Pool struct { TotalBundles uint64 `protobuf:"varint,10,opt,name=total_bundles,json=totalBundles,proto3" json:"total_bundles,omitempty"` // upload_interval ... UploadInterval uint64 `protobuf:"varint,11,opt,name=upload_interval,json=uploadInterval,proto3" json:"upload_interval,omitempty"` - // operating_cost ... - OperatingCost uint64 `protobuf:"varint,12,opt,name=operating_cost,json=operatingCost,proto3" json:"operating_cost,omitempty"` + // inflation_share_weight ... + InflationShareWeight uint64 `protobuf:"varint,12,opt,name=inflation_share_weight,json=inflationShareWeight,proto3" json:"inflation_share_weight,omitempty"` // min_delegation ... MinDelegation uint64 `protobuf:"varint,13,opt,name=min_delegation,json=minDelegation,proto3" json:"min_delegation,omitempty"` // max_bundle_size ... @@ -311,25 +255,21 @@ type Pool struct { // disabled is true when the pool is disabled. // Can only be done via governance. Disabled bool `protobuf:"varint,15,opt,name=disabled,proto3" json:"disabled,omitempty"` - // funders ... - Funders []*Funder `protobuf:"bytes,16,rep,name=funders,proto3" json:"funders,omitempty"` - // total_funds ... - TotalFunds uint64 `protobuf:"varint,17,opt,name=total_funds,json=totalFunds,proto3" json:"total_funds,omitempty"` // protocol ... - Protocol *Protocol `protobuf:"bytes,18,opt,name=protocol,proto3" json:"protocol,omitempty"` + Protocol *Protocol `protobuf:"bytes,16,opt,name=protocol,proto3" json:"protocol,omitempty"` // upgrade_plan ... - UpgradePlan *UpgradePlan `protobuf:"bytes,19,opt,name=upgrade_plan,json=upgradePlan,proto3" json:"upgrade_plan,omitempty"` + UpgradePlan *UpgradePlan `protobuf:"bytes,17,opt,name=upgrade_plan,json=upgradePlan,proto3" json:"upgrade_plan,omitempty"` // storage_provider_id ... - CurrentStorageProviderId uint32 `protobuf:"varint,20,opt,name=current_storage_provider_id,json=currentStorageProviderId,proto3" json:"current_storage_provider_id,omitempty"` + CurrentStorageProviderId uint32 `protobuf:"varint,18,opt,name=current_storage_provider_id,json=currentStorageProviderId,proto3" json:"current_storage_provider_id,omitempty"` // compression_id ... - CurrentCompressionId uint32 `protobuf:"varint,21,opt,name=current_compression_id,json=currentCompressionId,proto3" json:"current_compression_id,omitempty"` + CurrentCompressionId uint32 `protobuf:"varint,19,opt,name=current_compression_id,json=currentCompressionId,proto3" json:"current_compression_id,omitempty"` } func (m *Pool) Reset() { *m = Pool{} } func (m *Pool) String() string { return proto.CompactTextString(m) } func (*Pool) ProtoMessage() {} func (*Pool) Descriptor() ([]byte, []int) { - return fileDescriptor_40c1730f47ff2ef8, []int{3} + return fileDescriptor_40c1730f47ff2ef8, []int{2} } func (m *Pool) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -435,9 +375,9 @@ func (m *Pool) GetUploadInterval() uint64 { return 0 } -func (m *Pool) GetOperatingCost() uint64 { +func (m *Pool) GetInflationShareWeight() uint64 { if m != nil { - return m.OperatingCost + return m.InflationShareWeight } return 0 } @@ -463,20 +403,6 @@ func (m *Pool) GetDisabled() bool { return false } -func (m *Pool) GetFunders() []*Funder { - if m != nil { - return m.Funders - } - return nil -} - -func (m *Pool) GetTotalFunds() uint64 { - if m != nil { - return m.TotalFunds - } - return 0 -} - func (m *Pool) GetProtocol() *Protocol { if m != nil { return m.Protocol @@ -509,67 +435,62 @@ func init() { proto.RegisterEnum("kyve.pool.v1beta1.PoolStatus", PoolStatus_name, PoolStatus_value) proto.RegisterType((*Protocol)(nil), "kyve.pool.v1beta1.Protocol") proto.RegisterType((*UpgradePlan)(nil), "kyve.pool.v1beta1.UpgradePlan") - proto.RegisterType((*Funder)(nil), "kyve.pool.v1beta1.Funder") proto.RegisterType((*Pool)(nil), "kyve.pool.v1beta1.Pool") } func init() { proto.RegisterFile("kyve/pool/v1beta1/pool.proto", fileDescriptor_40c1730f47ff2ef8) } var fileDescriptor_40c1730f47ff2ef8 = []byte{ - // 840 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x94, 0x41, 0x6f, 0x22, 0x37, - 0x14, 0xc7, 0x99, 0x84, 0x25, 0x60, 0x12, 0xc2, 0xba, 0xd9, 0xd4, 0x9b, 0x54, 0x94, 0x4d, 0xb5, - 0x2d, 0xed, 0x01, 0xb4, 0xbb, 0x95, 0x2a, 0x55, 0xea, 0x81, 0x00, 0x21, 0xa3, 0x8d, 0x00, 0x0d, - 0x90, 0xaa, 0xbd, 0x58, 0x06, 0x7b, 0x27, 0x56, 0x66, 0xec, 0xd1, 0xd8, 0x43, 0xc3, 0x1e, 0x7b, - 0xea, 0xb1, 0xdf, 0x61, 0xbf, 0x4c, 0x8f, 0x7b, 0xec, 0xb1, 0x4a, 0xfa, 0x41, 0x2a, 0x7b, 0x66, - 0x68, 0x76, 0x9b, 0x53, 0x6f, 0x7e, 0xbf, 0xff, 0xff, 0xf9, 0x3d, 0xe6, 0xf9, 0x01, 0x3e, 0xbb, - 0x5e, 0xaf, 0x58, 0x27, 0x92, 0x32, 0xe8, 0xac, 0x5e, 0x2c, 0x98, 0x26, 0x2f, 0x6c, 0xd0, 0x8e, - 0x62, 0xa9, 0x25, 0x7c, 0x6c, 0xd4, 0xb6, 0x05, 0x99, 0x7a, 0x74, 0xe0, 0x4b, 0x5f, 0x5a, 0xb5, - 0x63, 0x4e, 0xa9, 0xf1, 0x64, 0x09, 0xca, 0x13, 0x73, 0x58, 0xca, 0x00, 0x22, 0xb0, 0xb3, 0x62, - 0xb1, 0xe2, 0x52, 0x20, 0xa7, 0xe9, 0xb4, 0x2a, 0x5e, 0x1e, 0xc2, 0x23, 0x50, 0x5e, 0x70, 0x41, - 0x62, 0xce, 0x14, 0xda, 0xb2, 0xd2, 0x26, 0x86, 0xcf, 0xc0, 0x6e, 0x40, 0x94, 0xc6, 0x49, 0xe4, - 0xc7, 0x84, 0x32, 0xb4, 0xdd, 0x74, 0x5a, 0x45, 0xaf, 0x6a, 0xd8, 0x3c, 0x45, 0x27, 0xbf, 0x3a, - 0xa0, 0x9a, 0x9d, 0x27, 0x01, 0x11, 0xff, 0xbf, 0x90, 0x5a, 0x5e, 0x31, 0x9a, 0x04, 0x8c, 0x62, - 0xa2, 0xf3, 0x42, 0x1b, 0xd6, 0xd5, 0x26, 0x9d, 0x26, 0x31, 0xd1, 0xe6, 0xe6, 0xa2, 0x95, 0x37, - 0xf1, 0xc9, 0xf7, 0xa0, 0x74, 0x96, 0x08, 0xca, 0x62, 0x53, 0x9e, 0x50, 0x1a, 0x33, 0xa5, 0xf2, - 0xf2, 0x59, 0x08, 0x0f, 0x41, 0x89, 0x84, 0x32, 0x11, 0xda, 0x16, 0x2f, 0x7a, 0x59, 0x74, 0xf2, - 0xae, 0x04, 0x8a, 0x13, 0x29, 0x03, 0x58, 0x03, 0x5b, 0x9c, 0xda, 0xac, 0xa2, 0xb7, 0xc5, 0x29, - 0x84, 0xa0, 0x28, 0x48, 0xc8, 0xb2, 0x5e, 0xed, 0xd9, 0x5c, 0x1f, 0x27, 0x42, 0xf3, 0x30, 0xfd, - 0x16, 0x15, 0x2f, 0x0f, 0x8d, 0x3b, 0x90, 0xbe, 0xb4, 0xad, 0x55, 0x3c, 0x7b, 0x36, 0x25, 0x97, - 0x52, 0xbc, 0xe1, 0x3e, 0x7a, 0x64, 0x69, 0x16, 0xc1, 0x63, 0x50, 0x51, 0x9a, 0xc4, 0x1a, 0x5f, - 0xb3, 0x35, 0x2a, 0xa5, 0x9f, 0xc2, 0x82, 0xd7, 0x6c, 0x0d, 0x3f, 0x07, 0xd5, 0x65, 0x12, 0xc7, - 0x4c, 0xa4, 0xf2, 0x8e, 0x95, 0x41, 0x86, 0x8c, 0xe1, 0x2b, 0xb0, 0x9f, 0x1b, 0x54, 0x12, 0x86, - 0x24, 0x5e, 0xa3, 0xb2, 0x35, 0xd5, 0x32, 0x3c, 0x4d, 0x29, 0xfc, 0x02, 0xec, 0xe5, 0x46, 0x2e, - 0x28, 0xbb, 0x41, 0x15, 0xfb, 0xdb, 0x76, 0x33, 0xe8, 0x1a, 0x66, 0x4c, 0x5a, 0x6a, 0x12, 0xe0, - 0x45, 0x22, 0x68, 0xc0, 0x14, 0x02, 0xa9, 0xc9, 0xc2, 0xd3, 0x94, 0x99, 0x92, 0x49, 0x14, 0x48, - 0x42, 0x31, 0x17, 0x9a, 0xc5, 0x2b, 0x12, 0xa0, 0xaa, 0xb5, 0xd5, 0x52, 0xec, 0x66, 0x14, 0x3e, - 0x07, 0x35, 0x19, 0x31, 0x33, 0x15, 0xe1, 0xe3, 0xa5, 0x54, 0x1a, 0xed, 0x5a, 0xdf, 0xde, 0x86, - 0xf6, 0xa4, 0xd2, 0xc6, 0x16, 0x72, 0x81, 0x29, 0x0b, 0x98, 0x9f, 0x4e, 0x74, 0x2f, 0xb5, 0x85, - 0x5c, 0xf4, 0x37, 0x10, 0x7e, 0x09, 0xf6, 0x43, 0x72, 0x93, 0x75, 0x86, 0x15, 0x7f, 0xcb, 0x50, - 0x2d, 0xf3, 0x91, 0x9b, 0xb4, 0xb7, 0x29, 0x7f, 0xcb, 0xec, 0xd3, 0xe0, 0x8a, 0x2c, 0x02, 0x46, - 0xd1, 0x7e, 0xd3, 0x69, 0x95, 0xbd, 0x4d, 0x0c, 0x5f, 0x81, 0x9d, 0x37, 0xf6, 0x69, 0x28, 0x54, - 0x6f, 0x6e, 0xb7, 0xaa, 0x2f, 0x9f, 0xb6, 0xff, 0xb3, 0x3f, 0xed, 0xf4, 0xf1, 0x78, 0xb9, 0xd3, - 0xcc, 0x20, 0xfd, 0x28, 0x06, 0x28, 0xf4, 0xd8, 0x16, 0x05, 0x16, 0x19, 0xab, 0x82, 0xdf, 0x81, - 0x72, 0x94, 0xad, 0x16, 0x82, 0x4d, 0xa7, 0x55, 0x7d, 0x79, 0xfc, 0xc0, 0xb5, 0xf9, 0xf6, 0x79, - 0x1b, 0x33, 0xec, 0x82, 0xdd, 0x6c, 0x99, 0x70, 0x14, 0x10, 0x81, 0x3e, 0xb1, 0xc9, 0x8d, 0x07, - 0x92, 0xef, 0x2d, 0x95, 0x57, 0x4d, 0xee, 0x6d, 0xd8, 0x0f, 0xe0, 0x78, 0x33, 0x7f, 0x2d, 0x63, - 0xe2, 0x33, 0x1c, 0xc5, 0x72, 0xc5, 0x29, 0x8b, 0x31, 0xa7, 0xe8, 0xa0, 0xe9, 0xb4, 0xf6, 0x3c, - 0x94, 0xbf, 0x85, 0xd4, 0x31, 0xc9, 0x0c, 0x2e, 0x85, 0xdf, 0x82, 0xc3, 0x3c, 0x7d, 0x29, 0xc3, - 0xc8, 0xec, 0x06, 0x97, 0xc2, 0x64, 0x3e, 0xb1, 0x99, 0x07, 0x99, 0xda, 0xfb, 0x57, 0x74, 0xe9, - 0x37, 0x7f, 0x3b, 0x00, 0x98, 0x2d, 0x99, 0x6a, 0xa2, 0x13, 0x05, 0x8f, 0xc1, 0xa7, 0x93, 0xf1, - 0xf8, 0x02, 0x4f, 0x67, 0xdd, 0xd9, 0x7c, 0x8a, 0xe7, 0xa3, 0xe9, 0x64, 0xd0, 0x73, 0xcf, 0xdc, - 0x41, 0xbf, 0x5e, 0x80, 0x87, 0x00, 0xde, 0x17, 0xbb, 0xbd, 0x99, 0x7b, 0x39, 0xa8, 0x3b, 0x10, - 0x81, 0x83, 0xfb, 0xbc, 0xef, 0x4e, 0xbb, 0xa7, 0x17, 0x83, 0x7e, 0x7d, 0xeb, 0x63, 0x65, 0x34, - 0xc6, 0x67, 0xf3, 0x51, 0x7f, 0x5a, 0xdf, 0x86, 0xcf, 0xc1, 0xb3, 0x0f, 0x95, 0x19, 0x1e, 0x8c, - 0xc6, 0xf3, 0xe1, 0x39, 0xee, 0x0f, 0x2e, 0x06, 0xc3, 0xee, 0xcc, 0x1d, 0x8f, 0xea, 0x45, 0xf8, - 0x14, 0x3c, 0xf9, 0xa0, 0x9f, 0xc9, 0xd0, 0xeb, 0xf6, 0xdd, 0xd1, 0xb0, 0xfe, 0xe8, 0xe3, 0x1b, - 0x2e, 0xc7, 0x33, 0x77, 0x34, 0xc4, 0x93, 0xf1, 0x8f, 0x03, 0x0f, 0xcf, 0xc6, 0x63, 0x7c, 0xee, - 0x0e, 0xcf, 0xeb, 0xa5, 0xa3, 0xe2, 0x6f, 0xef, 0x1a, 0x85, 0xd3, 0xde, 0x1f, 0xb7, 0x0d, 0xe7, - 0xfd, 0x6d, 0xc3, 0xf9, 0xeb, 0xb6, 0xe1, 0xfc, 0x7e, 0xd7, 0x28, 0xbc, 0xbf, 0x6b, 0x14, 0xfe, - 0xbc, 0x6b, 0x14, 0x7e, 0xfe, 0xda, 0xe7, 0xfa, 0x2a, 0x59, 0xb4, 0x97, 0x32, 0xec, 0xbc, 0xfe, - 0xe9, 0x72, 0x30, 0x62, 0xfa, 0x17, 0x19, 0x5f, 0x77, 0x96, 0x57, 0x84, 0x8b, 0xce, 0x4d, 0xfa, - 0x6f, 0xad, 0xd7, 0x11, 0x53, 0x8b, 0x92, 0x9d, 0xf6, 0xab, 0x7f, 0x02, 0x00, 0x00, 0xff, 0xff, - 0x80, 0x23, 0xd9, 0x4f, 0xc7, 0x05, 0x00, 0x00, + // 784 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x94, 0xcf, 0x73, 0xe3, 0x34, + 0x14, 0xc7, 0xe3, 0x6e, 0xda, 0x4d, 0x94, 0x36, 0xcd, 0x8a, 0x52, 0x44, 0xcb, 0x84, 0x6c, 0x99, + 0x85, 0xc0, 0x21, 0x99, 0x05, 0x66, 0x38, 0x71, 0x48, 0x1b, 0x6f, 0xea, 0xd9, 0x4e, 0x9c, 0xb1, + 0x93, 0xee, 0xc0, 0x45, 0xa3, 0xd8, 0x5a, 0x47, 0x53, 0xdb, 0xf2, 0xc8, 0x72, 0xb6, 0xd9, 0x23, + 0x27, 0x8e, 0xfc, 0x0f, 0xfc, 0x33, 0x1c, 0xf7, 0xc8, 0x81, 0x03, 0xd3, 0xf2, 0x87, 0x30, 0x92, + 0x7f, 0x90, 0x2d, 0x9c, 0xb8, 0xbd, 0xf7, 0xf9, 0x7e, 0x9f, 0x9e, 0x94, 0xf7, 0x1c, 0xf0, 0xc9, + 0xcd, 0x66, 0x4d, 0x87, 0x09, 0xe7, 0xe1, 0x70, 0xfd, 0x7c, 0x49, 0x25, 0x79, 0xae, 0x93, 0x41, + 0x22, 0xb8, 0xe4, 0xf0, 0x89, 0x52, 0x07, 0x1a, 0x14, 0xea, 0xc9, 0x51, 0xc0, 0x03, 0xae, 0xd5, + 0xa1, 0x8a, 0x72, 0xe3, 0x99, 0x07, 0x1a, 0x33, 0x15, 0x78, 0x3c, 0x84, 0x08, 0x3c, 0x5e, 0x53, + 0x91, 0x32, 0x1e, 0x23, 0xa3, 0x67, 0xf4, 0x9b, 0x4e, 0x99, 0xc2, 0x13, 0xd0, 0x58, 0xb2, 0x98, + 0x08, 0x46, 0x53, 0xb4, 0xa3, 0xa5, 0x2a, 0x87, 0x4f, 0xc1, 0x7e, 0x48, 0x52, 0x89, 0xb3, 0x24, + 0x10, 0xc4, 0xa7, 0xe8, 0x51, 0xcf, 0xe8, 0xd7, 0x9d, 0x96, 0x62, 0x8b, 0x1c, 0x9d, 0xfd, 0x64, + 0x80, 0x56, 0x11, 0xcf, 0x42, 0x12, 0xff, 0xff, 0x46, 0xa9, 0xb7, 0xa2, 0x7e, 0x16, 0x52, 0x1f, + 0x13, 0x59, 0x36, 0xaa, 0xd8, 0x48, 0xaa, 0x72, 0x3f, 0x13, 0x44, 0xaa, 0x93, 0xeb, 0x5a, 0xae, + 0xf2, 0xb3, 0x3f, 0x76, 0x41, 0x7d, 0xc6, 0x79, 0x08, 0xdb, 0x60, 0x87, 0xf9, 0xba, 0x71, 0xdd, + 0xd9, 0x61, 0x3e, 0x84, 0xa0, 0x1e, 0x93, 0x88, 0x16, 0xfd, 0x74, 0xac, 0x6e, 0x28, 0xb2, 0x58, + 0xb2, 0x28, 0x7f, 0x4f, 0xd3, 0x29, 0x53, 0xe5, 0x0e, 0x79, 0xc0, 0xf5, 0xf1, 0x4d, 0x47, 0xc7, + 0xf0, 0x18, 0xec, 0x79, 0x3c, 0x7e, 0xcd, 0x02, 0xb4, 0xab, 0x69, 0x91, 0xc1, 0x53, 0xd0, 0x4c, + 0x25, 0x11, 0x12, 0xdf, 0xd0, 0x0d, 0xda, 0xcb, 0x9f, 0xa3, 0xc1, 0x4b, 0xba, 0x81, 0x9f, 0x82, + 0x96, 0x97, 0x09, 0x41, 0xe3, 0x5c, 0x7e, 0xac, 0x65, 0x50, 0x20, 0x65, 0xf8, 0x02, 0x1c, 0x96, + 0x86, 0x34, 0x8b, 0x22, 0x22, 0x36, 0xa8, 0xa1, 0x4d, 0xed, 0x02, 0xbb, 0x39, 0x85, 0x9f, 0x81, + 0x83, 0xd2, 0xc8, 0x62, 0x9f, 0xde, 0xa2, 0xa6, 0x7e, 0xdb, 0x7e, 0x01, 0x2d, 0xc5, 0x94, 0x49, + 0x72, 0x49, 0x42, 0xbc, 0xcc, 0x62, 0x3f, 0xa4, 0x29, 0x02, 0xb9, 0x49, 0xc3, 0xf3, 0x9c, 0xa9, + 0x96, 0x59, 0x12, 0x72, 0xe2, 0x63, 0x16, 0x4b, 0x2a, 0xd6, 0x24, 0x44, 0x2d, 0x6d, 0x6b, 0xe7, + 0xd8, 0x2a, 0x28, 0xfc, 0x16, 0x1c, 0xb3, 0xf8, 0x75, 0xa8, 0x7f, 0x59, 0x9c, 0xae, 0x88, 0xa0, + 0xf8, 0x0d, 0x65, 0xc1, 0x4a, 0xa2, 0x7d, 0xed, 0x3f, 0xaa, 0x54, 0x57, 0x89, 0xaf, 0xb4, 0x06, + 0x9f, 0x81, 0x76, 0xc4, 0x62, 0xec, 0xd3, 0x90, 0x06, 0xf9, 0x90, 0x0e, 0xb4, 0xfb, 0x20, 0x62, + 0xf1, 0xb8, 0x82, 0xf0, 0x73, 0x70, 0x18, 0x91, 0xdb, 0xe2, 0xa2, 0x38, 0x65, 0x6f, 0x29, 0x6a, + 0x17, 0x3e, 0x72, 0x9b, 0x5f, 0xd5, 0x65, 0x6f, 0xa9, 0x9e, 0x36, 0x4b, 0xc9, 0x32, 0xa4, 0x3e, + 0x3a, 0xec, 0x19, 0xfd, 0x86, 0x53, 0xe5, 0xf0, 0x3b, 0xd0, 0x48, 0x8a, 0xbd, 0x46, 0x9d, 0x9e, + 0xd1, 0x6f, 0x7d, 0x7d, 0x3a, 0xf8, 0xd7, 0x37, 0x31, 0x28, 0x57, 0xdf, 0xa9, 0xcc, 0x70, 0x04, + 0xf6, 0x8b, 0x4d, 0xc6, 0x49, 0x48, 0x62, 0xf4, 0x44, 0x17, 0x77, 0xff, 0xa3, 0x78, 0x6b, 0xa3, + 0x9d, 0x56, 0xb6, 0xb5, 0xde, 0xdf, 0x83, 0xd3, 0x6a, 0x70, 0x92, 0x0b, 0x12, 0x50, 0x9c, 0x08, + 0xbe, 0x66, 0x3e, 0x15, 0x98, 0xf9, 0x08, 0xf6, 0x8c, 0xfe, 0x81, 0x83, 0xca, 0x21, 0xe6, 0x8e, + 0x59, 0x61, 0xb0, 0x7c, 0xf5, 0xdb, 0x96, 0xe5, 0x1e, 0x8f, 0x12, 0x41, 0x53, 0xf5, 0x69, 0xa8, + 0xca, 0x0f, 0x74, 0xe5, 0x51, 0xa1, 0x5e, 0xfc, 0x23, 0x5a, 0xfe, 0x57, 0x7f, 0x19, 0x00, 0xa8, + 0xf5, 0x76, 0x25, 0x91, 0x59, 0x0a, 0x4f, 0xc1, 0x47, 0x33, 0xdb, 0xbe, 0xc2, 0xee, 0x7c, 0x34, + 0x5f, 0xb8, 0x78, 0x31, 0x75, 0x67, 0xe6, 0x85, 0xf5, 0xc2, 0x32, 0xc7, 0x9d, 0x1a, 0x3c, 0x06, + 0x70, 0x5b, 0x1c, 0x5d, 0xcc, 0xad, 0x6b, 0xb3, 0x63, 0x40, 0x04, 0x8e, 0xb6, 0xf9, 0xd8, 0x72, + 0x47, 0xe7, 0x57, 0xe6, 0xb8, 0xb3, 0xf3, 0x50, 0x99, 0xda, 0xf8, 0xc5, 0x62, 0x3a, 0x76, 0x3b, + 0x8f, 0xe0, 0x33, 0xf0, 0xf4, 0x7d, 0x65, 0x8e, 0xcd, 0xa9, 0xbd, 0x98, 0x5c, 0xe2, 0xb1, 0x79, + 0x65, 0x4e, 0x46, 0x73, 0xcb, 0x9e, 0x76, 0xea, 0xf0, 0x63, 0xf0, 0xe1, 0x7b, 0xf7, 0x99, 0x4d, + 0x9c, 0xd1, 0xd8, 0x9a, 0x4e, 0x3a, 0xbb, 0x0f, 0x4f, 0xb8, 0xb6, 0xe7, 0xd6, 0x74, 0x82, 0x67, + 0xf6, 0x2b, 0xd3, 0xc1, 0x73, 0xdb, 0xc6, 0x97, 0xd6, 0xe4, 0xb2, 0xb3, 0x77, 0x52, 0xff, 0xf9, + 0xd7, 0x6e, 0xed, 0xfc, 0xe2, 0xb7, 0xbb, 0xae, 0xf1, 0xee, 0xae, 0x6b, 0xfc, 0x79, 0xd7, 0x35, + 0x7e, 0xb9, 0xef, 0xd6, 0xde, 0xdd, 0x77, 0x6b, 0xbf, 0xdf, 0x77, 0x6b, 0x3f, 0x7e, 0x19, 0x30, + 0xb9, 0xca, 0x96, 0x03, 0x8f, 0x47, 0xc3, 0x97, 0x3f, 0x5c, 0x9b, 0x53, 0x2a, 0xdf, 0x70, 0x71, + 0x33, 0xf4, 0x56, 0x84, 0xc5, 0xc3, 0xdb, 0xfc, 0xaf, 0x52, 0x6e, 0x12, 0x9a, 0x2e, 0xf7, 0xf4, + 0xb4, 0xbf, 0xf9, 0x3b, 0x00, 0x00, 0xff, 0xff, 0x76, 0xe7, 0x4a, 0x49, 0x44, 0x05, 0x00, 0x00, } func (m *Protocol) Marshal() (dAtA []byte, err error) { @@ -661,41 +582,6 @@ func (m *UpgradePlan) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *Funder) 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 *Funder) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Funder) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Amount != 0 { - i = encodeVarintPool(dAtA, i, uint64(m.Amount)) - i-- - dAtA[i] = 0x10 - } - if len(m.Address) > 0 { - i -= len(m.Address) - copy(dAtA[i:], m.Address) - i = encodeVarintPool(dAtA, i, uint64(len(m.Address))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - func (m *Pool) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -721,14 +607,14 @@ func (m *Pool) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x1 i-- - dAtA[i] = 0xa8 + dAtA[i] = 0x98 } if m.CurrentStorageProviderId != 0 { i = encodeVarintPool(dAtA, i, uint64(m.CurrentStorageProviderId)) i-- dAtA[i] = 0x1 i-- - dAtA[i] = 0xa0 + dAtA[i] = 0x90 } if m.UpgradePlan != nil { { @@ -742,7 +628,7 @@ func (m *Pool) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x1 i-- - dAtA[i] = 0x9a + dAtA[i] = 0x8a } if m.Protocol != nil { { @@ -756,30 +642,7 @@ func (m *Pool) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x1 i-- - dAtA[i] = 0x92 - } - if m.TotalFunds != 0 { - i = encodeVarintPool(dAtA, i, uint64(m.TotalFunds)) - i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0x88 - } - if len(m.Funders) > 0 { - for iNdEx := len(m.Funders) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Funders[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintPool(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0x82 - } + dAtA[i] = 0x82 } if m.Disabled { i-- @@ -801,8 +664,8 @@ func (m *Pool) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x68 } - if m.OperatingCost != 0 { - i = encodeVarintPool(dAtA, i, uint64(m.OperatingCost)) + if m.InflationShareWeight != 0 { + i = encodeVarintPool(dAtA, i, uint64(m.InflationShareWeight)) i-- dAtA[i] = 0x60 } @@ -932,22 +795,6 @@ func (m *UpgradePlan) Size() (n int) { return n } -func (m *Funder) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Address) - if l > 0 { - n += 1 + l + sovPool(uint64(l)) - } - if m.Amount != 0 { - n += 1 + sovPool(uint64(m.Amount)) - } - return n -} - func (m *Pool) Size() (n int) { if m == nil { return 0 @@ -994,8 +841,8 @@ func (m *Pool) Size() (n int) { if m.UploadInterval != 0 { n += 1 + sovPool(uint64(m.UploadInterval)) } - if m.OperatingCost != 0 { - n += 1 + sovPool(uint64(m.OperatingCost)) + if m.InflationShareWeight != 0 { + n += 1 + sovPool(uint64(m.InflationShareWeight)) } if m.MinDelegation != 0 { n += 1 + sovPool(uint64(m.MinDelegation)) @@ -1006,15 +853,6 @@ func (m *Pool) Size() (n int) { if m.Disabled { n += 2 } - if len(m.Funders) > 0 { - for _, e := range m.Funders { - l = e.Size() - n += 2 + l + sovPool(uint64(l)) - } - } - if m.TotalFunds != 0 { - n += 2 + sovPool(uint64(m.TotalFunds)) - } if m.Protocol != nil { l = m.Protocol.Size() n += 2 + l + sovPool(uint64(l)) @@ -1323,107 +1161,6 @@ func (m *UpgradePlan) Unmarshal(dAtA []byte) error { } return nil } -func (m *Funder) 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 ErrIntOverflowPool - } - 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: Funder: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Funder: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowPool - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthPool - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthPool - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Address = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) - } - m.Amount = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowPool - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Amount |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipPool(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthPool - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} func (m *Pool) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -1755,9 +1492,9 @@ func (m *Pool) Unmarshal(dAtA []byte) error { } case 12: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field OperatingCost", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field InflationShareWeight", wireType) } - m.OperatingCost = 0 + m.InflationShareWeight = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowPool @@ -1767,7 +1504,7 @@ func (m *Pool) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.OperatingCost |= uint64(b&0x7F) << shift + m.InflationShareWeight |= uint64(b&0x7F) << shift if b < 0x80 { break } @@ -1831,59 +1568,6 @@ func (m *Pool) Unmarshal(dAtA []byte) error { } m.Disabled = bool(v != 0) case 16: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Funders", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowPool - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthPool - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthPool - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Funders = append(m.Funders, &Funder{}) - if err := m.Funders[len(m.Funders)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 17: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field TotalFunds", wireType) - } - m.TotalFunds = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowPool - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.TotalFunds |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 18: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Protocol", wireType) } @@ -1919,7 +1603,7 @@ func (m *Pool) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 19: + case 17: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field UpgradePlan", wireType) } @@ -1955,7 +1639,7 @@ func (m *Pool) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 20: + case 18: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field CurrentStorageProviderId", wireType) } @@ -1974,7 +1658,7 @@ func (m *Pool) Unmarshal(dAtA []byte) error { break } } - case 21: + case 19: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field CurrentCompressionId", wireType) } diff --git a/x/pool/types/tx.pb.go b/x/pool/types/tx.pb.go index 9b045244..755a5a78 100644 --- a/x/pool/types/tx.pb.go +++ b/x/pool/types/tx.pb.go @@ -28,208 +28,6 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// MsgFundPool defines a SDK message for funding a pool. -type MsgFundPool struct { - // creator ... - Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` - // id ... - Id uint64 `protobuf:"varint,2,opt,name=id,proto3" json:"id,omitempty"` - // amount ... - Amount uint64 `protobuf:"varint,3,opt,name=amount,proto3" json:"amount,omitempty"` -} - -func (m *MsgFundPool) Reset() { *m = MsgFundPool{} } -func (m *MsgFundPool) String() string { return proto.CompactTextString(m) } -func (*MsgFundPool) ProtoMessage() {} -func (*MsgFundPool) Descriptor() ([]byte, []int) { - return fileDescriptor_20ddefdf83388ddc, []int{0} -} -func (m *MsgFundPool) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgFundPool) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgFundPool.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 *MsgFundPool) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgFundPool.Merge(m, src) -} -func (m *MsgFundPool) XXX_Size() int { - return m.Size() -} -func (m *MsgFundPool) XXX_DiscardUnknown() { - xxx_messageInfo_MsgFundPool.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgFundPool proto.InternalMessageInfo - -func (m *MsgFundPool) GetCreator() string { - if m != nil { - return m.Creator - } - return "" -} - -func (m *MsgFundPool) GetId() uint64 { - if m != nil { - return m.Id - } - return 0 -} - -func (m *MsgFundPool) GetAmount() uint64 { - if m != nil { - return m.Amount - } - return 0 -} - -// MsgFundPoolResponse defines the Msg/DefundPool response type. -type MsgFundPoolResponse struct { -} - -func (m *MsgFundPoolResponse) Reset() { *m = MsgFundPoolResponse{} } -func (m *MsgFundPoolResponse) String() string { return proto.CompactTextString(m) } -func (*MsgFundPoolResponse) ProtoMessage() {} -func (*MsgFundPoolResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_20ddefdf83388ddc, []int{1} -} -func (m *MsgFundPoolResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgFundPoolResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgFundPoolResponse.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 *MsgFundPoolResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgFundPoolResponse.Merge(m, src) -} -func (m *MsgFundPoolResponse) XXX_Size() int { - return m.Size() -} -func (m *MsgFundPoolResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgFundPoolResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgFundPoolResponse proto.InternalMessageInfo - -// MsgDefundPool defines a SDK message for defunding a pool. -type MsgDefundPool struct { - // creator ... - Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` - // id ... - Id uint64 `protobuf:"varint,2,opt,name=id,proto3" json:"id,omitempty"` - // amount ... - Amount uint64 `protobuf:"varint,3,opt,name=amount,proto3" json:"amount,omitempty"` -} - -func (m *MsgDefundPool) Reset() { *m = MsgDefundPool{} } -func (m *MsgDefundPool) String() string { return proto.CompactTextString(m) } -func (*MsgDefundPool) ProtoMessage() {} -func (*MsgDefundPool) Descriptor() ([]byte, []int) { - return fileDescriptor_20ddefdf83388ddc, []int{2} -} -func (m *MsgDefundPool) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgDefundPool) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgDefundPool.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 *MsgDefundPool) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgDefundPool.Merge(m, src) -} -func (m *MsgDefundPool) XXX_Size() int { - return m.Size() -} -func (m *MsgDefundPool) XXX_DiscardUnknown() { - xxx_messageInfo_MsgDefundPool.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgDefundPool proto.InternalMessageInfo - -func (m *MsgDefundPool) GetCreator() string { - if m != nil { - return m.Creator - } - return "" -} - -func (m *MsgDefundPool) GetId() uint64 { - if m != nil { - return m.Id - } - return 0 -} - -func (m *MsgDefundPool) GetAmount() uint64 { - if m != nil { - return m.Amount - } - return 0 -} - -// MsgDefundPoolResponse defines the Msg/DefundPool response type. -type MsgDefundPoolResponse struct { -} - -func (m *MsgDefundPoolResponse) Reset() { *m = MsgDefundPoolResponse{} } -func (m *MsgDefundPoolResponse) String() string { return proto.CompactTextString(m) } -func (*MsgDefundPoolResponse) ProtoMessage() {} -func (*MsgDefundPoolResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_20ddefdf83388ddc, []int{3} -} -func (m *MsgDefundPoolResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgDefundPoolResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgDefundPoolResponse.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 *MsgDefundPoolResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgDefundPoolResponse.Merge(m, src) -} -func (m *MsgDefundPoolResponse) XXX_Size() int { - return m.Size() -} -func (m *MsgDefundPoolResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgDefundPoolResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgDefundPoolResponse proto.InternalMessageInfo - // MsgCreatePool defines a SDK message for creating a new pool. type MsgCreatePool struct { // authority is the address of the governance account. @@ -246,8 +44,8 @@ type MsgCreatePool struct { StartKey string `protobuf:"bytes,6,opt,name=start_key,json=startKey,proto3" json:"start_key,omitempty"` // upload_interval ... UploadInterval uint64 `protobuf:"varint,7,opt,name=upload_interval,json=uploadInterval,proto3" json:"upload_interval,omitempty"` - // operating_cost ... - OperatingCost uint64 `protobuf:"varint,8,opt,name=operating_cost,json=operatingCost,proto3" json:"operating_cost,omitempty"` + // inflation_share_weight ... + InflationShareWeight uint64 `protobuf:"varint,8,opt,name=inflation_share_weight,json=inflationShareWeight,proto3" json:"inflation_share_weight,omitempty"` // min_delegation ... MinDelegation uint64 `protobuf:"varint,9,opt,name=min_delegation,json=minDelegation,proto3" json:"min_delegation,omitempty"` // max_bundle_size ... @@ -266,7 +64,7 @@ func (m *MsgCreatePool) Reset() { *m = MsgCreatePool{} } func (m *MsgCreatePool) String() string { return proto.CompactTextString(m) } func (*MsgCreatePool) ProtoMessage() {} func (*MsgCreatePool) Descriptor() ([]byte, []int) { - return fileDescriptor_20ddefdf83388ddc, []int{4} + return fileDescriptor_20ddefdf83388ddc, []int{0} } func (m *MsgCreatePool) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -344,9 +142,9 @@ func (m *MsgCreatePool) GetUploadInterval() uint64 { return 0 } -func (m *MsgCreatePool) GetOperatingCost() uint64 { +func (m *MsgCreatePool) GetInflationShareWeight() uint64 { if m != nil { - return m.OperatingCost + return m.InflationShareWeight } return 0 } @@ -401,7 +199,7 @@ func (m *MsgCreatePoolResponse) Reset() { *m = MsgCreatePoolResponse{} } func (m *MsgCreatePoolResponse) String() string { return proto.CompactTextString(m) } func (*MsgCreatePoolResponse) ProtoMessage() {} func (*MsgCreatePoolResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_20ddefdf83388ddc, []int{5} + return fileDescriptor_20ddefdf83388ddc, []int{1} } func (m *MsgCreatePoolResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -444,7 +242,7 @@ func (m *MsgUpdatePool) Reset() { *m = MsgUpdatePool{} } func (m *MsgUpdatePool) String() string { return proto.CompactTextString(m) } func (*MsgUpdatePool) ProtoMessage() {} func (*MsgUpdatePool) Descriptor() ([]byte, []int) { - return fileDescriptor_20ddefdf83388ddc, []int{6} + return fileDescriptor_20ddefdf83388ddc, []int{2} } func (m *MsgUpdatePool) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -502,7 +300,7 @@ func (m *MsgUpdatePoolResponse) Reset() { *m = MsgUpdatePoolResponse{} } func (m *MsgUpdatePoolResponse) String() string { return proto.CompactTextString(m) } func (*MsgUpdatePoolResponse) ProtoMessage() {} func (*MsgUpdatePoolResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_20ddefdf83388ddc, []int{7} + return fileDescriptor_20ddefdf83388ddc, []int{3} } func (m *MsgUpdatePoolResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -543,7 +341,7 @@ func (m *MsgDisablePool) Reset() { *m = MsgDisablePool{} } func (m *MsgDisablePool) String() string { return proto.CompactTextString(m) } func (*MsgDisablePool) ProtoMessage() {} func (*MsgDisablePool) Descriptor() ([]byte, []int) { - return fileDescriptor_20ddefdf83388ddc, []int{8} + return fileDescriptor_20ddefdf83388ddc, []int{4} } func (m *MsgDisablePool) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -594,7 +392,7 @@ func (m *MsgDisablePoolResponse) Reset() { *m = MsgDisablePoolResponse{} func (m *MsgDisablePoolResponse) String() string { return proto.CompactTextString(m) } func (*MsgDisablePoolResponse) ProtoMessage() {} func (*MsgDisablePoolResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_20ddefdf83388ddc, []int{9} + return fileDescriptor_20ddefdf83388ddc, []int{5} } func (m *MsgDisablePoolResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -635,7 +433,7 @@ func (m *MsgEnablePool) Reset() { *m = MsgEnablePool{} } func (m *MsgEnablePool) String() string { return proto.CompactTextString(m) } func (*MsgEnablePool) ProtoMessage() {} func (*MsgEnablePool) Descriptor() ([]byte, []int) { - return fileDescriptor_20ddefdf83388ddc, []int{10} + return fileDescriptor_20ddefdf83388ddc, []int{6} } func (m *MsgEnablePool) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -686,7 +484,7 @@ func (m *MsgEnablePoolResponse) Reset() { *m = MsgEnablePoolResponse{} } func (m *MsgEnablePoolResponse) String() string { return proto.CompactTextString(m) } func (*MsgEnablePoolResponse) ProtoMessage() {} func (*MsgEnablePoolResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_20ddefdf83388ddc, []int{11} + return fileDescriptor_20ddefdf83388ddc, []int{7} } func (m *MsgEnablePoolResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -735,7 +533,7 @@ func (m *MsgScheduleRuntimeUpgrade) Reset() { *m = MsgScheduleRuntimeUpg func (m *MsgScheduleRuntimeUpgrade) String() string { return proto.CompactTextString(m) } func (*MsgScheduleRuntimeUpgrade) ProtoMessage() {} func (*MsgScheduleRuntimeUpgrade) Descriptor() ([]byte, []int) { - return fileDescriptor_20ddefdf83388ddc, []int{12} + return fileDescriptor_20ddefdf83388ddc, []int{8} } func (m *MsgScheduleRuntimeUpgrade) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -814,7 +612,7 @@ func (m *MsgScheduleRuntimeUpgradeResponse) Reset() { *m = MsgScheduleRu func (m *MsgScheduleRuntimeUpgradeResponse) String() string { return proto.CompactTextString(m) } func (*MsgScheduleRuntimeUpgradeResponse) ProtoMessage() {} func (*MsgScheduleRuntimeUpgradeResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_20ddefdf83388ddc, []int{13} + return fileDescriptor_20ddefdf83388ddc, []int{9} } func (m *MsgScheduleRuntimeUpgradeResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -855,7 +653,7 @@ func (m *MsgCancelRuntimeUpgrade) Reset() { *m = MsgCancelRuntimeUpgrade func (m *MsgCancelRuntimeUpgrade) String() string { return proto.CompactTextString(m) } func (*MsgCancelRuntimeUpgrade) ProtoMessage() {} func (*MsgCancelRuntimeUpgrade) Descriptor() ([]byte, []int) { - return fileDescriptor_20ddefdf83388ddc, []int{14} + return fileDescriptor_20ddefdf83388ddc, []int{10} } func (m *MsgCancelRuntimeUpgrade) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -906,7 +704,7 @@ func (m *MsgCancelRuntimeUpgradeResponse) Reset() { *m = MsgCancelRuntim func (m *MsgCancelRuntimeUpgradeResponse) String() string { return proto.CompactTextString(m) } func (*MsgCancelRuntimeUpgradeResponse) ProtoMessage() {} func (*MsgCancelRuntimeUpgradeResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_20ddefdf83388ddc, []int{15} + return fileDescriptor_20ddefdf83388ddc, []int{11} } func (m *MsgCancelRuntimeUpgradeResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -947,7 +745,7 @@ func (m *MsgUpdateParams) Reset() { *m = MsgUpdateParams{} } func (m *MsgUpdateParams) String() string { return proto.CompactTextString(m) } func (*MsgUpdateParams) ProtoMessage() {} func (*MsgUpdateParams) Descriptor() ([]byte, []int) { - return fileDescriptor_20ddefdf83388ddc, []int{16} + return fileDescriptor_20ddefdf83388ddc, []int{12} } func (m *MsgUpdateParams) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -998,7 +796,7 @@ func (m *MsgUpdateParamsResponse) Reset() { *m = MsgUpdateParamsResponse func (m *MsgUpdateParamsResponse) String() string { return proto.CompactTextString(m) } func (*MsgUpdateParamsResponse) ProtoMessage() {} func (*MsgUpdateParamsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_20ddefdf83388ddc, []int{17} + return fileDescriptor_20ddefdf83388ddc, []int{13} } func (m *MsgUpdateParamsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1028,10 +826,6 @@ func (m *MsgUpdateParamsResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgUpdateParamsResponse proto.InternalMessageInfo func init() { - proto.RegisterType((*MsgFundPool)(nil), "kyve.pool.v1beta1.MsgFundPool") - proto.RegisterType((*MsgFundPoolResponse)(nil), "kyve.pool.v1beta1.MsgFundPoolResponse") - proto.RegisterType((*MsgDefundPool)(nil), "kyve.pool.v1beta1.MsgDefundPool") - proto.RegisterType((*MsgDefundPoolResponse)(nil), "kyve.pool.v1beta1.MsgDefundPoolResponse") proto.RegisterType((*MsgCreatePool)(nil), "kyve.pool.v1beta1.MsgCreatePool") proto.RegisterType((*MsgCreatePoolResponse)(nil), "kyve.pool.v1beta1.MsgCreatePoolResponse") proto.RegisterType((*MsgUpdatePool)(nil), "kyve.pool.v1beta1.MsgUpdatePool") @@ -1051,63 +845,58 @@ func init() { func init() { proto.RegisterFile("kyve/pool/v1beta1/tx.proto", fileDescriptor_20ddefdf83388ddc) } var fileDescriptor_20ddefdf83388ddc = []byte{ - // 881 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x56, 0xd1, 0x6e, 0x1b, 0x45, - 0x14, 0x8d, 0x9d, 0xd4, 0x89, 0x6f, 0x62, 0x47, 0xdd, 0xb6, 0xe9, 0x64, 0x91, 0x4c, 0x62, 0x44, - 0x49, 0x2b, 0xb0, 0xd5, 0x82, 0x78, 0x6f, 0xd2, 0x22, 0x45, 0x55, 0xa0, 0x6c, 0x54, 0x28, 0x20, - 0xb1, 0x1a, 0xef, 0x4c, 0x37, 0xa3, 0xec, 0xce, 0x2c, 0x33, 0xb3, 0x26, 0xae, 0xf8, 0x08, 0x3e, - 0x86, 0x8f, 0xe0, 0xb1, 0xe2, 0x89, 0x47, 0x94, 0xbc, 0xf1, 0xcc, 0x07, 0xa0, 0x99, 0x5d, 0xef, - 0xae, 0xb1, 0xb7, 0x01, 0x9a, 0xbe, 0xf9, 0xde, 0x7b, 0x7c, 0xce, 0x9d, 0x99, 0x33, 0x77, 0x16, - 0xdc, 0xd3, 0xc9, 0x98, 0x0e, 0x13, 0x21, 0xa2, 0xe1, 0xf8, 0xfe, 0x88, 0x6a, 0x7c, 0x7f, 0xa8, - 0xcf, 0x06, 0x89, 0x14, 0x5a, 0x38, 0xd7, 0x4d, 0x6d, 0x60, 0x6a, 0x83, 0xbc, 0xe6, 0x6e, 0x07, - 0x42, 0xc5, 0x42, 0xf9, 0x16, 0x30, 0xcc, 0x82, 0x0c, 0xdd, 0xff, 0x02, 0xd6, 0x8f, 0x54, 0xf8, - 0x59, 0xca, 0xc9, 0x53, 0x21, 0x22, 0x07, 0xc1, 0x6a, 0x20, 0x29, 0xd6, 0x42, 0xa2, 0xc6, 0x4e, - 0x63, 0xaf, 0xed, 0x4d, 0x43, 0xa7, 0x0b, 0x4d, 0x46, 0x50, 0x73, 0xa7, 0xb1, 0xb7, 0xe2, 0x35, - 0x19, 0x71, 0xb6, 0xa0, 0x85, 0x63, 0x91, 0x72, 0x8d, 0x96, 0x6d, 0x2e, 0x8f, 0xfa, 0xb7, 0xe0, - 0x46, 0x85, 0xd0, 0xa3, 0x2a, 0x11, 0x5c, 0xd1, 0xfe, 0x97, 0xd0, 0x39, 0x52, 0xe1, 0x23, 0xfa, - 0xe2, 0xea, 0x94, 0x6e, 0xc3, 0xad, 0x19, 0xca, 0x42, 0xeb, 0xcf, 0x65, 0x2b, 0x76, 0x60, 0xf8, - 0xa8, 0x15, 0xfb, 0x14, 0xda, 0x38, 0xd5, 0x27, 0x42, 0x32, 0x3d, 0xc9, 0xe4, 0xf6, 0xd1, 0x6f, - 0xbf, 0x7c, 0x74, 0x33, 0xdf, 0x8a, 0x87, 0x84, 0x48, 0xaa, 0xd4, 0xb1, 0x96, 0x8c, 0x87, 0x5e, - 0x09, 0x75, 0x1c, 0x58, 0xe1, 0x38, 0xa6, 0xb6, 0x99, 0xb6, 0x67, 0x7f, 0x9b, 0xc6, 0x65, 0xca, - 0x35, 0x8b, 0xa9, 0xed, 0xa7, 0xed, 0x4d, 0x43, 0x83, 0x8e, 0x44, 0x28, 0xd0, 0x4a, 0x86, 0x36, - 0xbf, 0x4d, 0xf3, 0x81, 0xe0, 0x2f, 0x58, 0x88, 0xae, 0xd9, 0x6c, 0x1e, 0x39, 0xef, 0x40, 0x5b, - 0x69, 0x2c, 0xb5, 0x7f, 0x4a, 0x27, 0xa8, 0x65, 0x4b, 0x6b, 0x36, 0xf1, 0x84, 0x4e, 0x9c, 0x0f, - 0x60, 0x33, 0x4d, 0x22, 0x81, 0x89, 0xcf, 0xb8, 0xa6, 0x72, 0x8c, 0x23, 0xb4, 0x6a, 0x97, 0xde, - 0xcd, 0xd2, 0x87, 0x79, 0xd6, 0x79, 0x1f, 0xba, 0x22, 0xa1, 0x12, 0x6b, 0xc6, 0x43, 0x3f, 0x10, - 0x4a, 0xa3, 0x35, 0x8b, 0xeb, 0x14, 0xd9, 0x03, 0xa1, 0xb4, 0x81, 0xc5, 0x8c, 0xfb, 0x84, 0x46, - 0x34, 0xc4, 0x9a, 0x09, 0x8e, 0xda, 0x19, 0x2c, 0x66, 0xfc, 0x51, 0x91, 0x74, 0xee, 0xc0, 0x66, - 0x8c, 0xcf, 0xfc, 0x51, 0xca, 0x49, 0x44, 0x7d, 0xc5, 0x5e, 0x52, 0x04, 0x39, 0x0e, 0x9f, 0xed, - 0xdb, 0xec, 0x31, 0x7b, 0x69, 0x77, 0x60, 0x4c, 0xa5, 0x32, 0x3c, 0xeb, 0xd9, 0x0e, 0xe4, 0xa1, - 0xe3, 0xc2, 0xda, 0x88, 0x71, 0x2c, 0x19, 0x55, 0x68, 0x23, 0x5b, 0xd4, 0x34, 0x76, 0x06, 0x70, - 0x43, 0x69, 0x21, 0x71, 0x48, 0x8d, 0x0f, 0xc7, 0x8c, 0x50, 0xe9, 0x33, 0x82, 0x3a, 0x3b, 0x8d, - 0xbd, 0x8e, 0x77, 0x3d, 0x2f, 0x3d, 0xcd, 0x2b, 0x87, 0xc4, 0x34, 0x1d, 0x88, 0x38, 0x31, 0x07, - 0xc3, 0x04, 0x37, 0xd0, 0xae, 0x85, 0x76, 0x2a, 0xd9, 0x43, 0x92, 0xbb, 0xa0, 0x3c, 0xeb, 0xc2, - 0x05, 0x3f, 0x58, 0x13, 0x3c, 0x4b, 0xc8, 0x9b, 0x9a, 0xe0, 0x9f, 0x7e, 0x44, 0xb0, 0x9a, 0xe0, - 0x89, 0x39, 0x87, 0xa9, 0x01, 0xf2, 0x30, 0xef, 0xa5, 0x94, 0x2c, 0x7a, 0x79, 0x0e, 0x5d, 0x63, - 0x55, 0xa6, 0xf0, 0x28, 0xba, 0xd2, 0x66, 0xfa, 0x08, 0xb6, 0x66, 0x99, 0x0b, 0xcd, 0xaf, 0xed, - 0xfa, 0x1f, 0xf3, 0x2b, 0x97, 0xcc, 0x56, 0x59, 0x12, 0x17, 0x8a, 0xe7, 0x0d, 0xd8, 0x3e, 0x52, - 0xe1, 0x71, 0x70, 0x42, 0x49, 0x1a, 0x51, 0x2f, 0xbb, 0x16, 0xcf, 0x92, 0x50, 0x62, 0x42, 0xff, - 0xb7, 0x7c, 0xe5, 0xbe, 0x35, 0x67, 0xef, 0x5b, 0xc5, 0x87, 0xcb, 0xb3, 0x3e, 0xdc, 0x85, 0x0d, - 0x95, 0x77, 0x41, 0x7c, 0xac, 0xed, 0x8d, 0x5c, 0xf1, 0xd6, 0x8b, 0xdc, 0x43, 0x6d, 0xac, 0x4a, - 0x52, 0x99, 0xdd, 0x86, 0x6b, 0xb6, 0x5c, 0xc4, 0x33, 0x36, 0x6e, 0xcd, 0xda, 0xb8, 0xff, 0x1e, - 0xec, 0xd6, 0xae, 0xb1, 0xd8, 0x89, 0x53, 0xb8, 0x6d, 0x4c, 0x89, 0x79, 0x40, 0xa3, 0xb7, 0xbd, - 0x0d, 0xfd, 0x5d, 0x78, 0xb7, 0x46, 0xac, 0xe8, 0x27, 0x80, 0xcd, 0xd2, 0x98, 0x58, 0xe2, 0x58, - 0xbd, 0x49, 0x1f, 0x53, 0xf7, 0x37, 0x67, 0xdd, 0xbf, 0x6d, 0x17, 0x5d, 0x15, 0x99, 0xea, 0x3f, - 0xf8, 0xab, 0x05, 0xcb, 0x47, 0x2a, 0x74, 0x3c, 0x58, 0x2b, 0x9e, 0x9a, 0xde, 0x60, 0xee, 0xa1, - 0x1a, 0x54, 0x5e, 0x0e, 0xf7, 0xce, 0xeb, 0xeb, 0x53, 0x6e, 0xe7, 0x39, 0x40, 0xe5, 0x59, 0xd9, - 0x59, 0xfc, 0xaf, 0x12, 0xe1, 0xee, 0x5d, 0x86, 0xa8, 0x32, 0x57, 0xde, 0x90, 0x1a, 0xe6, 0x12, - 0x51, 0xc7, 0x3c, 0x3f, 0x9b, 0x0c, 0x73, 0x65, 0x30, 0xd5, 0x30, 0x97, 0x88, 0x3a, 0xe6, 0xf9, - 0x49, 0xe3, 0x7c, 0x07, 0xeb, 0xd5, 0x31, 0xb3, 0x5b, 0xb3, 0xd8, 0x12, 0xe2, 0xde, 0xbd, 0x14, - 0x52, 0x6d, 0xbb, 0x32, 0x4f, 0x6a, 0xda, 0x2e, 0x11, 0x75, 0x6d, 0xcf, 0x8f, 0x0e, 0xe7, 0x27, - 0xd8, 0xaa, 0x19, 0x1b, 0x1f, 0x2e, 0xe6, 0x58, 0x8c, 0x76, 0x3f, 0xf9, 0x2f, 0xe8, 0x42, 0x7d, - 0x0c, 0x37, 0x17, 0xde, 0xd5, 0x7b, 0x35, 0x07, 0xba, 0x00, 0xeb, 0x3e, 0xf8, 0xf7, 0xd8, 0x42, - 0xf7, 0x7b, 0xd8, 0x98, 0xb9, 0x93, 0xfd, 0xd7, 0x1e, 0xb3, 0xc5, 0xb8, 0xf7, 0x2e, 0xc7, 0x4c, - 0xf9, 0xf7, 0x0f, 0x7e, 0x3d, 0xef, 0x35, 0x5e, 0x9d, 0xf7, 0x1a, 0x7f, 0x9c, 0xf7, 0x1a, 0x3f, - 0x5f, 0xf4, 0x96, 0x5e, 0x5d, 0xf4, 0x96, 0x7e, 0xbf, 0xe8, 0x2d, 0x7d, 0x7b, 0x37, 0x64, 0xfa, - 0x24, 0x1d, 0x0d, 0x02, 0x11, 0x0f, 0x9f, 0x7c, 0xf3, 0xd5, 0xe3, 0xcf, 0xa9, 0xfe, 0x51, 0xc8, - 0xd3, 0x61, 0x70, 0x82, 0x19, 0x1f, 0x9e, 0x65, 0x9f, 0x96, 0x7a, 0x92, 0x50, 0x35, 0x6a, 0xd9, - 0x0f, 0xc5, 0x8f, 0xff, 0x0e, 0x00, 0x00, 0xff, 0xff, 0x68, 0x62, 0xc8, 0xb4, 0x74, 0x0a, 0x00, - 0x00, + // 807 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x56, 0xd1, 0x8e, 0xdb, 0x44, + 0x14, 0x5d, 0x67, 0xb3, 0xe9, 0x66, 0x76, 0x93, 0x55, 0x87, 0x25, 0x9d, 0x35, 0x52, 0x48, 0x82, + 0x80, 0xb4, 0x82, 0x44, 0x2d, 0x15, 0xef, 0xdd, 0xb6, 0x0f, 0xab, 0x2a, 0xa8, 0x72, 0x54, 0x5a, + 0x40, 0xc2, 0x9a, 0x78, 0xa6, 0xce, 0x28, 0xb6, 0xc7, 0xcc, 0x4c, 0xd2, 0xa4, 0xe2, 0x23, 0xf8, + 0x18, 0xbe, 0x01, 0xf1, 0x58, 0xf1, 0xc4, 0x23, 0xca, 0x7e, 0x05, 0x6f, 0x68, 0xc6, 0x8e, 0x63, + 0x6b, 0x63, 0x16, 0x68, 0x79, 0xf3, 0xbd, 0xf7, 0xf8, 0x9e, 0x7b, 0x67, 0xce, 0xb1, 0x0c, 0xec, + 0xd9, 0x6a, 0x41, 0x87, 0x31, 0xe7, 0xc1, 0x70, 0x71, 0x77, 0x42, 0x15, 0xbe, 0x3b, 0x54, 0xcb, + 0x41, 0x2c, 0xb8, 0xe2, 0xf0, 0xa6, 0xae, 0x0d, 0x74, 0x6d, 0x90, 0xd6, 0xec, 0x33, 0x8f, 0xcb, + 0x90, 0x4b, 0xd7, 0x00, 0x86, 0x49, 0x90, 0xa0, 0x7b, 0x7f, 0xee, 0x83, 0xc6, 0x48, 0xfa, 0x0f, + 0x05, 0xc5, 0x8a, 0x3e, 0xe5, 0x3c, 0x80, 0x5f, 0x82, 0x3a, 0x9e, 0xab, 0x29, 0x17, 0x4c, 0xad, + 0x90, 0xd5, 0xb1, 0xfa, 0xf5, 0x73, 0xf4, 0xdb, 0xcf, 0x9f, 0x9f, 0xa6, 0xaf, 0x3d, 0x20, 0x44, + 0x50, 0x29, 0xc7, 0x4a, 0xb0, 0xc8, 0x77, 0xb6, 0x50, 0x08, 0x41, 0x35, 0xc2, 0x21, 0x45, 0x15, + 0xfd, 0x8a, 0x63, 0x9e, 0x21, 0x02, 0x37, 0xc4, 0x3c, 0x52, 0x2c, 0xa4, 0x68, 0xdf, 0xa4, 0x37, + 0xa1, 0x46, 0x07, 0xdc, 0xe7, 0xa8, 0x9a, 0xa0, 0xf5, 0x33, 0x6c, 0x81, 0x9a, 0xc7, 0xa3, 0x97, + 0xcc, 0x47, 0x07, 0x26, 0x9b, 0x46, 0xf0, 0x03, 0x50, 0x97, 0x0a, 0x0b, 0xe5, 0xce, 0xe8, 0x0a, + 0xd5, 0x4c, 0xe9, 0xd0, 0x24, 0x9e, 0xd0, 0x15, 0xfc, 0x14, 0x9c, 0xcc, 0xe3, 0x80, 0x63, 0xe2, + 0xb2, 0x48, 0x51, 0xb1, 0xc0, 0x01, 0xba, 0xd1, 0xb1, 0xfa, 0x55, 0xa7, 0x99, 0xa4, 0x2f, 0xd2, + 0x2c, 0xbc, 0x0f, 0x5a, 0x2c, 0x7a, 0x19, 0x60, 0xc5, 0x78, 0xe4, 0xca, 0x29, 0x16, 0xd4, 0x7d, + 0x45, 0x99, 0x3f, 0x55, 0xe8, 0xd0, 0xe0, 0x4f, 0xb3, 0xea, 0x58, 0x17, 0x9f, 0x9b, 0x1a, 0xfc, + 0x18, 0x34, 0x43, 0x16, 0xb9, 0x84, 0x06, 0xd4, 0x37, 0x45, 0x54, 0x37, 0xe8, 0x46, 0xc8, 0xa2, + 0x47, 0x59, 0x12, 0x7e, 0x02, 0x4e, 0x42, 0xbc, 0x74, 0x27, 0xf3, 0x88, 0x04, 0xd4, 0x95, 0xec, + 0x35, 0x45, 0x20, 0xc5, 0xe1, 0xe5, 0xb9, 0xc9, 0x8e, 0xd9, 0x6b, 0x73, 0x20, 0x0b, 0x2a, 0xa4, + 0xee, 0x73, 0x94, 0x1c, 0x48, 0x1a, 0x42, 0x1b, 0x1c, 0x4e, 0x58, 0x84, 0x05, 0xa3, 0x12, 0x1d, + 0x27, 0x3b, 0x6e, 0x62, 0x38, 0x00, 0xef, 0x49, 0xc5, 0x05, 0xf6, 0xa9, 0xbe, 0xc2, 0x05, 0x23, + 0x54, 0xb8, 0x8c, 0xa0, 0x46, 0xc7, 0xea, 0x37, 0x9c, 0x9b, 0x69, 0xe9, 0x69, 0x5a, 0xb9, 0x20, + 0x7a, 0x68, 0x8f, 0x87, 0xb1, 0xbe, 0x27, 0xbd, 0x2c, 0x23, 0xa8, 0x69, 0xa0, 0x8d, 0x5c, 0xf6, + 0x82, 0xf4, 0x6e, 0x81, 0xf7, 0x0b, 0x57, 0xef, 0x50, 0x19, 0xf3, 0x48, 0xd2, 0xde, 0x0f, 0x46, + 0x13, 0xcf, 0x62, 0xf2, 0xb6, 0x9a, 0x68, 0x82, 0x0a, 0x23, 0x46, 0x11, 0x55, 0xa7, 0xc2, 0x88, + 0x5e, 0x3f, 0xc6, 0x2b, 0x7d, 0x2d, 0x1b, 0x3d, 0xa4, 0x61, 0x3a, 0xcb, 0x96, 0x32, 0x9b, 0xe5, + 0x05, 0x68, 0x8e, 0xa4, 0xff, 0x88, 0x49, 0x3c, 0x09, 0xde, 0xe9, 0x30, 0x3d, 0x04, 0x5a, 0xc5, + 0xce, 0x19, 0xe7, 0x73, 0xb3, 0xff, 0xe3, 0xe8, 0x9d, 0x53, 0x26, 0x5b, 0x6e, 0x1b, 0x67, 0x8c, + 0x6b, 0x0b, 0x9c, 0x8d, 0xa4, 0x3f, 0xf6, 0xa6, 0x94, 0xcc, 0x03, 0xea, 0x24, 0x2e, 0x79, 0x16, + 0xfb, 0x02, 0x13, 0xfa, 0x9f, 0xe9, 0x73, 0xf6, 0xab, 0x14, 0xed, 0x97, 0xd3, 0xe1, 0x7e, 0x51, + 0x87, 0x5d, 0x70, 0x2c, 0xd3, 0x29, 0x88, 0x8b, 0x95, 0x31, 0x68, 0xd5, 0x39, 0xca, 0x72, 0x0f, + 0x94, 0x96, 0x2a, 0x99, 0x8b, 0xc4, 0x0d, 0x07, 0xa6, 0x9c, 0xc5, 0x05, 0x19, 0xd7, 0x8a, 0x32, + 0xee, 0x7d, 0x04, 0xba, 0xa5, 0x3b, 0x66, 0x27, 0x31, 0x03, 0xb7, 0xb4, 0x28, 0x71, 0xe4, 0xd1, + 0xe0, 0xff, 0x3e, 0x86, 0x5e, 0x17, 0x7c, 0x58, 0x42, 0x96, 0xcd, 0xe3, 0x81, 0x93, 0xad, 0x30, + 0xb1, 0xc0, 0xa1, 0x7c, 0x9b, 0x39, 0x36, 0xea, 0xaf, 0x14, 0xd5, 0x7f, 0x66, 0x96, 0xce, 0x93, + 0x6c, 0xf8, 0xef, 0xfd, 0x72, 0x00, 0xf6, 0x47, 0xd2, 0x87, 0x2f, 0x00, 0xc8, 0x7d, 0xa4, 0x3b, + 0x83, 0x2b, 0x5f, 0xf9, 0x41, 0xc1, 0xcb, 0x76, 0xff, 0x3a, 0xc4, 0x86, 0x41, 0x77, 0xce, 0x59, + 0xbd, 0xa4, 0xf3, 0x16, 0x51, 0xd6, 0xf9, 0xaa, 0x77, 0xe1, 0x77, 0xe0, 0x28, 0x6f, 0xdc, 0xee, + 0xee, 0x17, 0x73, 0x10, 0xfb, 0xf6, 0xb5, 0x90, 0xfc, 0xd8, 0x39, 0x87, 0x96, 0x8c, 0xbd, 0x45, + 0x94, 0x8d, 0x7d, 0xd5, 0x8c, 0xf0, 0x47, 0xd0, 0x2a, 0x31, 0xe2, 0x67, 0xbb, 0x7b, 0xec, 0x46, + 0xdb, 0xf7, 0xff, 0x0d, 0x3a, 0x63, 0x5f, 0x80, 0xd3, 0x9d, 0xea, 0xbf, 0x53, 0x72, 0xa1, 0x3b, + 0xb0, 0xf6, 0xbd, 0x7f, 0x8e, 0xcd, 0x78, 0xbf, 0x07, 0xc7, 0x05, 0x95, 0xf7, 0xfe, 0xf6, 0x9a, + 0x0d, 0xc6, 0xbe, 0x73, 0x3d, 0x66, 0xd3, 0xff, 0xfc, 0xe1, 0xaf, 0xeb, 0xb6, 0xf5, 0x66, 0xdd, + 0xb6, 0xfe, 0x58, 0xb7, 0xad, 0x9f, 0x2e, 0xdb, 0x7b, 0x6f, 0x2e, 0xdb, 0x7b, 0xbf, 0x5f, 0xb6, + 0xf7, 0xbe, 0xbd, 0xed, 0x33, 0x35, 0x9d, 0x4f, 0x06, 0x1e, 0x0f, 0x87, 0x4f, 0xbe, 0xf9, 0xfa, + 0xf1, 0x57, 0x54, 0xbd, 0xe2, 0x62, 0x36, 0xf4, 0xa6, 0x98, 0x45, 0xc3, 0x65, 0xf2, 0x9f, 0xa3, + 0x56, 0x31, 0x95, 0x93, 0x9a, 0xf9, 0x6b, 0xf9, 0xe2, 0xaf, 0x00, 0x00, 0x00, 0xff, 0xff, 0xa3, + 0x07, 0x08, 0x64, 0x01, 0x09, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1122,10 +911,6 @@ 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 { - // FundPool ... - FundPool(ctx context.Context, in *MsgFundPool, opts ...grpc.CallOption) (*MsgFundPoolResponse, error) - // DefundPool ... - DefundPool(ctx context.Context, in *MsgDefundPool, opts ...grpc.CallOption) (*MsgDefundPoolResponse, error) // CreatePool defines a governance operation for creating a new pool. // The authority is hard-coded to the x/gov module account. CreatePool(ctx context.Context, in *MsgCreatePool, opts ...grpc.CallOption) (*MsgCreatePoolResponse, error) @@ -1157,24 +942,6 @@ func NewMsgClient(cc grpc1.ClientConn) MsgClient { return &msgClient{cc} } -func (c *msgClient) FundPool(ctx context.Context, in *MsgFundPool, opts ...grpc.CallOption) (*MsgFundPoolResponse, error) { - out := new(MsgFundPoolResponse) - err := c.cc.Invoke(ctx, "/kyve.pool.v1beta1.Msg/FundPool", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *msgClient) DefundPool(ctx context.Context, in *MsgDefundPool, opts ...grpc.CallOption) (*MsgDefundPoolResponse, error) { - out := new(MsgDefundPoolResponse) - err := c.cc.Invoke(ctx, "/kyve.pool.v1beta1.Msg/DefundPool", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - func (c *msgClient) CreatePool(ctx context.Context, in *MsgCreatePool, opts ...grpc.CallOption) (*MsgCreatePoolResponse, error) { out := new(MsgCreatePoolResponse) err := c.cc.Invoke(ctx, "/kyve.pool.v1beta1.Msg/CreatePool", in, out, opts...) @@ -1240,10 +1007,6 @@ func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts // MsgServer is the server API for Msg service. type MsgServer interface { - // FundPool ... - FundPool(context.Context, *MsgFundPool) (*MsgFundPoolResponse, error) - // DefundPool ... - DefundPool(context.Context, *MsgDefundPool) (*MsgDefundPoolResponse, error) // CreatePool defines a governance operation for creating a new pool. // The authority is hard-coded to the x/gov module account. CreatePool(context.Context, *MsgCreatePool) (*MsgCreatePoolResponse, error) @@ -1271,12 +1034,6 @@ type MsgServer interface { type UnimplementedMsgServer struct { } -func (*UnimplementedMsgServer) FundPool(ctx context.Context, req *MsgFundPool) (*MsgFundPoolResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method FundPool not implemented") -} -func (*UnimplementedMsgServer) DefundPool(ctx context.Context, req *MsgDefundPool) (*MsgDefundPoolResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method DefundPool not implemented") -} func (*UnimplementedMsgServer) CreatePool(ctx context.Context, req *MsgCreatePool) (*MsgCreatePoolResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method CreatePool not implemented") } @@ -1303,42 +1060,6 @@ func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) } -func _Msg_FundPool_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgFundPool) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).FundPool(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/kyve.pool.v1beta1.Msg/FundPool", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).FundPool(ctx, req.(*MsgFundPool)) - } - return interceptor(ctx, in, info, handler) -} - -func _Msg_DefundPool_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgDefundPool) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).DefundPool(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/kyve.pool.v1beta1.Msg/DefundPool", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).DefundPool(ctx, req.(*MsgDefundPool)) - } - return interceptor(ctx, in, info, handler) -} - func _Msg_CreatePool_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(MsgCreatePool) if err := dec(in); err != nil { @@ -1469,14 +1190,6 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "kyve.pool.v1beta1.Msg", HandlerType: (*MsgServer)(nil), Methods: []grpc.MethodDesc{ - { - MethodName: "FundPool", - Handler: _Msg_FundPool_Handler, - }, - { - MethodName: "DefundPool", - Handler: _Msg_DefundPool_Handler, - }, { MethodName: "CreatePool", Handler: _Msg_CreatePool_Handler, @@ -1510,7 +1223,7 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ Metadata: "kyve/pool/v1beta1/tx.proto", } -func (m *MsgFundPool) Marshal() (dAtA []byte, err error) { +func (m *MsgCreatePool) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1520,165 +1233,39 @@ func (m *MsgFundPool) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgFundPool) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgCreatePool) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgFundPool) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgCreatePool) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if m.Amount != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.Amount)) + if m.CompressionId != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.CompressionId)) i-- - dAtA[i] = 0x18 + dAtA[i] = 0x70 } - if m.Id != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.Id)) + if m.StorageProviderId != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.StorageProviderId)) i-- - dAtA[i] = 0x10 + dAtA[i] = 0x68 } - if len(m.Creator) > 0 { - i -= len(m.Creator) - copy(dAtA[i:], m.Creator) - i = encodeVarintTx(dAtA, i, uint64(len(m.Creator))) + if len(m.Binaries) > 0 { + i -= len(m.Binaries) + copy(dAtA[i:], m.Binaries) + i = encodeVarintTx(dAtA, i, uint64(len(m.Binaries))) i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MsgFundPoolResponse) 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 *MsgFundPoolResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgFundPoolResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func (m *MsgDefundPool) 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[i] = 0x62 } - return dAtA[:n], nil -} - -func (m *MsgDefundPool) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgDefundPool) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Amount != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.Amount)) + if len(m.Version) > 0 { + i -= len(m.Version) + copy(dAtA[i:], m.Version) + i = encodeVarintTx(dAtA, i, uint64(len(m.Version))) i-- - dAtA[i] = 0x18 - } - if m.Id != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.Id)) - i-- - dAtA[i] = 0x10 - } - if len(m.Creator) > 0 { - i -= len(m.Creator) - copy(dAtA[i:], m.Creator) - i = encodeVarintTx(dAtA, i, uint64(len(m.Creator))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MsgDefundPoolResponse) 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 *MsgDefundPoolResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgDefundPoolResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func (m *MsgCreatePool) 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 *MsgCreatePool) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgCreatePool) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.CompressionId != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.CompressionId)) - i-- - dAtA[i] = 0x70 - } - if m.StorageProviderId != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.StorageProviderId)) - i-- - dAtA[i] = 0x68 - } - if len(m.Binaries) > 0 { - i -= len(m.Binaries) - copy(dAtA[i:], m.Binaries) - i = encodeVarintTx(dAtA, i, uint64(len(m.Binaries))) - i-- - dAtA[i] = 0x62 - } - if len(m.Version) > 0 { - i -= len(m.Version) - copy(dAtA[i:], m.Version) - i = encodeVarintTx(dAtA, i, uint64(len(m.Version))) - i-- - dAtA[i] = 0x5a + dAtA[i] = 0x5a } if m.MaxBundleSize != 0 { i = encodeVarintTx(dAtA, i, uint64(m.MaxBundleSize)) @@ -1690,8 +1277,8 @@ func (m *MsgCreatePool) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x48 } - if m.OperatingCost != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.OperatingCost)) + if m.InflationShareWeight != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.InflationShareWeight)) i-- dAtA[i] = 0x40 } @@ -2164,62 +1751,6 @@ func encodeVarintTx(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } -func (m *MsgFundPool) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Creator) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - if m.Id != 0 { - n += 1 + sovTx(uint64(m.Id)) - } - if m.Amount != 0 { - n += 1 + sovTx(uint64(m.Amount)) - } - return n -} - -func (m *MsgFundPoolResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func (m *MsgDefundPool) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Creator) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - if m.Id != 0 { - n += 1 + sovTx(uint64(m.Id)) - } - if m.Amount != 0 { - n += 1 + sovTx(uint64(m.Amount)) - } - return n -} - -func (m *MsgDefundPoolResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - func (m *MsgCreatePool) Size() (n int) { if m == nil { return 0 @@ -2253,8 +1784,8 @@ func (m *MsgCreatePool) Size() (n int) { if m.UploadInterval != 0 { n += 1 + sovTx(uint64(m.UploadInterval)) } - if m.OperatingCost != 0 { - n += 1 + sovTx(uint64(m.OperatingCost)) + if m.InflationShareWeight != 0 { + n += 1 + sovTx(uint64(m.InflationShareWeight)) } if m.MinDelegation != 0 { n += 1 + sovTx(uint64(m.MinDelegation)) @@ -2465,346 +1996,6 @@ func sovTx(x uint64) (n int) { func sozTx(x uint64) (n int) { return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } -func (m *MsgFundPool) 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: MsgFundPool: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgFundPool: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType) - } - var 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.Creator = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) - } - m.Id = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Id |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) - } - m.Amount = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Amount |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgFundPoolResponse) 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: MsgFundPoolResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgFundPoolResponse: 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 *MsgDefundPool) 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: MsgDefundPool: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgDefundPool: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType) - } - var 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.Creator = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) - } - m.Id = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Id |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) - } - m.Amount = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Amount |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgDefundPoolResponse) 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: MsgDefundPoolResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgDefundPoolResponse: 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 *MsgCreatePool) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -3047,9 +2238,9 @@ func (m *MsgCreatePool) Unmarshal(dAtA []byte) error { } case 8: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field OperatingCost", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field InflationShareWeight", wireType) } - m.OperatingCost = 0 + m.InflationShareWeight = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -3059,7 +2250,7 @@ func (m *MsgCreatePool) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.OperatingCost |= uint64(b&0x7F) << shift + m.InflationShareWeight |= uint64(b&0x7F) << shift if b < 0x80 { break } diff --git a/x/query/client/cli/query.go b/x/query/client/cli/query.go index e88a40c4..2598a301 100644 --- a/x/query/client/cli/query.go +++ b/x/query/client/cli/query.go @@ -39,7 +39,7 @@ func GetQueryCmd(queryRoute string) *cobra.Command { cmd.AddCommand(CmdListStakers()) cmd.AddCommand(CmdListStakersByPool()) - // DELEGATION + // Delegation cmd.AddCommand(CmdDelegator()) cmd.AddCommand(CmdStakersByPoolAndDelegator()) cmd.AddCommand(CmdDelegatorsByPoolAndStaker()) @@ -52,5 +52,10 @@ func GetQueryCmd(queryRoute string) *cobra.Command { cmd.AddCommand(CmdCurrentVoteStatus()) cmd.AddCommand(CmdCanValidate()) + // Funders + cmd.AddCommand(CmdShowFunder()) + cmd.AddCommand(CmdListFunders()) + cmd.AddCommand(CmdListFundings()) + return cmd } diff --git a/x/query/client/cli/query_funders.go b/x/query/client/cli/query_funders.go new file mode 100644 index 00000000..a6cb9a3d --- /dev/null +++ b/x/query/client/cli/query_funders.go @@ -0,0 +1,86 @@ +package cli + +import ( + "context" + + "github.com/KYVENetwork/chain/x/query/types" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/spf13/cobra" +) + +func CmdListFunders() *cobra.Command { + cmd := &cobra.Command{ + Use: "funders", + Short: "list all funders", + Args: cobra.MaximumNArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + reqSearch := "" + if len(args) >= 1 { + reqSearch = args[0] + } + + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + pageReq, err := client.ReadPageRequest(cmd.Flags()) + if err != nil { + return err + } + + queryClient := types.NewQueryFundersClient(clientCtx) + + params := &types.QueryFundersRequest{ + Pagination: pageReq, + Search: reqSearch, + } + + res, err := queryClient.Funders(context.Background(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddPaginationFlagsToCmd(cmd, cmd.Use) + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +func CmdShowFunder() *cobra.Command { + cmd := &cobra.Command{ + Use: "funder [address]", + Short: "shows a funder", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + reqAddress := args[0] + + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryFundersClient(clientCtx) + + params := &types.QueryFunderRequest{ + Address: reqAddress, + } + + res, err := queryClient.Funder(context.Background(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/query/client/cli/query_fundings.go b/x/query/client/cli/query_fundings.go new file mode 100644 index 00000000..9d3a5b06 --- /dev/null +++ b/x/query/client/cli/query_fundings.go @@ -0,0 +1,82 @@ +package cli + +import ( + "context" + "strconv" + + "github.com/KYVENetwork/chain/x/query/types" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/types/query" + "github.com/spf13/cobra" +) + +func byFunder( + clientCtx client.Context, + queryClient types.QueryFundersClient, + pageReq *query.PageRequest, + address string, +) error { + params := &types.QueryFundingsByFunderRequest{ + Pagination: pageReq, + Address: address, + } + + res, err := queryClient.FundingsByFunder(context.Background(), params) + if err != nil { + return err + } + return clientCtx.PrintProto(res) +} + +func byPool( + clientCtx client.Context, + queryClient types.QueryFundersClient, + pageReq *query.PageRequest, + poolId uint64, +) error { + params := &types.QueryFundingsByPoolRequest{ + Pagination: pageReq, + PoolId: poolId, + } + + res, err := queryClient.FundingsByPool(context.Background(), params) + if err != nil { + return err + } + return clientCtx.PrintProto(res) +} + +func CmdListFundings() *cobra.Command { + cmd := &cobra.Command{ + Use: "fundings [address | pool-id]", + Short: "list all fundings of a user or a pool", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + reqAddressOrPool := args[0] + + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + pageReq, err := client.ReadPageRequest(cmd.Flags()) + if err != nil { + return err + } + + queryClient := types.NewQueryFundersClient(clientCtx) + + poolId, err := strconv.ParseUint(reqAddressOrPool, 10, 64) + if err != nil { + return byFunder(clientCtx, queryClient, pageReq, reqAddressOrPool) + } + return byPool(clientCtx, queryClient, pageReq, poolId) + }, + } + + flags.AddPaginationFlagsToCmd(cmd, cmd.Use) + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/query/keeper/grpc_account_assets.go b/x/query/keeper/grpc_account_assets.go index b5c30b45..bb62d192 100644 --- a/x/query/keeper/grpc_account_assets.go +++ b/x/query/keeper/grpc_account_assets.go @@ -73,9 +73,9 @@ func (k Keeper) AccountAssets(goCtx context.Context, req *types.QueryAccountAsse // ProtocolFunding // =============== - // Iterate all pools and look if the user is funding - for _, pool := range k.poolKeeper.GetAllPools(ctx) { - response.ProtocolFunding += pool.GetFunderAmount(req.Address) + // Iterate all fundings of the user to get total funding amount + for _, funding := range k.fundersKeeper.GetFundingsOfFunder(ctx, req.Address) { + response.ProtocolFunding += funding.Amount } return &response, nil diff --git a/x/query/keeper/grpc_account_funded.go b/x/query/keeper/grpc_account_funded.go index 73d48bee..de0dc6e9 100644 --- a/x/query/keeper/grpc_account_funded.go +++ b/x/query/keeper/grpc_account_funded.go @@ -17,25 +17,26 @@ func (k Keeper) AccountFundedList(goCtx context.Context, req *types.QueryAccount ctx := sdk.UnwrapSDKContext(goCtx) var funded []types.Funded - pools := k.poolKeeper.GetAllPools(ctx) - - for i := range pools { - pool := pools[i] - amount := pool.GetFunderAmount(req.Address) - - if amount > 0 { + fundings := k.fundersKeeper.GetFundingsOfFunder(ctx, req.Address) + + for _, funding := range fundings { + if funding.Amount > 0 { + pool, found := k.poolKeeper.GetPool(ctx, funding.PoolId) + if !found { + return nil, status.Error(codes.Internal, "pool not found") + } funded = append(funded, types.Funded{ - Amount: amount, + Amount: funding.Amount, Pool: &types.BasicPool{ - Id: pool.Id, - Name: pool.Name, - Runtime: pool.Runtime, - Logo: pool.Logo, - OperatingCost: pool.OperatingCost, - UploadInterval: pool.UploadInterval, - TotalFunds: pool.TotalFunds, - TotalDelegation: k.delegationKeeper.GetDelegationOfPool(ctx, pool.Id), - Status: k.GetPoolStatus(ctx, &pool), + Id: funding.PoolId, + Name: pool.Name, + Runtime: pool.Runtime, + Logo: pool.Logo, + InflationShareWeight: pool.InflationShareWeight, + UploadInterval: pool.UploadInterval, + TotalFunds: k.fundersKeeper.GetTotalActiveFunding(ctx, pool.Id), + TotalDelegation: k.delegationKeeper.GetDelegationOfPool(ctx, pool.Id), + Status: k.GetPoolStatus(ctx, &pool), }, }) } diff --git a/x/query/keeper/grpc_account_redelegation_test.go b/x/query/keeper/grpc_account_redelegation_test.go index 4799af4f..ca370996 100644 --- a/x/query/keeper/grpc_account_redelegation_test.go +++ b/x/query/keeper/grpc_account_redelegation_test.go @@ -28,14 +28,22 @@ var _ = Describe("grpc_account_redelegation.go", Ordered, func() { BeforeEach(func() { s = i.NewCleanChain() - s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{ - Name: "T", + // create 2 pools + gov := s.App().GovKeeper.GetGovernanceAccount(s.Ctx()).GetAddress().String() + msg := &pooltypes.MsgCreatePool{ + Authority: gov, MinDelegation: 200 * i.KYVE, UploadInterval: 60, MaxBundleSize: 100, - Protocol: &pooltypes.Protocol{}, - UpgradePlan: &pooltypes.UpgradePlan{}, - }) + Binaries: "{}", + } + s.RunTxPoolSuccess(msg) + s.RunTxPoolSuccess(msg) + + // disable second pool + pool, _ := s.App().PoolKeeper.GetPool(s.Ctx(), 1) + pool.Disabled = true + s.App().PoolKeeper.SetPool(s.Ctx(), pool) s.RunTxStakersSuccess(&stakertypes.MsgCreateStaker{ Creator: i.STAKER_0, @@ -47,17 +55,6 @@ var _ = Describe("grpc_account_redelegation.go", Ordered, func() { Amount: 100 * i.KYVE, }) - s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{ - Name: "DisabledPool", - Protocol: &pooltypes.Protocol{ - Version: "0.0.0", - Binaries: "{}", - LastUpgrade: uint64(s.Ctx().BlockTime().Unix()), - }, - Disabled: true, - UpgradePlan: &pooltypes.UpgradePlan{}, - }) - s.RunTxStakersSuccess(&stakertypes.MsgJoinPool{ Creator: i.STAKER_1, PoolId: 0, diff --git a/x/query/keeper/grpc_params.go b/x/query/keeper/grpc_params.go index 00a20994..5816707a 100644 --- a/x/query/keeper/grpc_params.go +++ b/x/query/keeper/grpc_params.go @@ -20,6 +20,14 @@ func (k Keeper) Params(goCtx context.Context, req *types.QueryParamsRequest) (*t globalParams := k.globalKeeper.GetParams(ctx) govParams := k.govKeeper.GetParams(ctx) sp := k.stakerKeeper.GetParams(ctx) + fp := k.fundersKeeper.GetParams(ctx) - return &types.QueryParamsResponse{BundlesParams: &bp, DelegationParams: &dp, GlobalParams: &globalParams, GovParams: &govParams, StakersParams: &sp}, nil + return &types.QueryParamsResponse{ + BundlesParams: &bp, + DelegationParams: &dp, + GlobalParams: &globalParams, + GovParams: &govParams, + StakersParams: &sp, + FundersParams: &fp, + }, nil } diff --git a/x/query/keeper/grpc_query.go b/x/query/keeper/grpc_query.go index efa8a9d1..a7441bb7 100644 --- a/x/query/keeper/grpc_query.go +++ b/x/query/keeper/grpc_query.go @@ -11,4 +11,5 @@ var ( _ types.QueryDelegationServer = Keeper{} _ types.QueryBundlesServer = Keeper{} _ types.QueryParamsServer = Keeper{} + _ types.QueryFundersServer = Keeper{} ) diff --git a/x/query/keeper/grpc_query_can_propose_test.go b/x/query/keeper/grpc_query_can_propose_test.go index 0082a047..37f10999 100644 --- a/x/query/keeper/grpc_query_can_propose_test.go +++ b/x/query/keeper/grpc_query_can_propose_test.go @@ -5,6 +5,7 @@ import ( i "github.com/KYVENetwork/chain/testutil/integration" bundletypes "github.com/KYVENetwork/chain/x/bundles/types" delegationtypes "github.com/KYVENetwork/chain/x/delegation/types" + funderstypes "github.com/KYVENetwork/chain/x/funders/types" pooltypes "github.com/KYVENetwork/chain/x/pool/types" querytypes "github.com/KYVENetwork/chain/x/query/types" stakertypes "github.com/KYVENetwork/chain/x/stakers/types" @@ -38,19 +39,26 @@ var _ = Describe("grpc_query_can_propose.go", Ordered, func() { BeforeEach(func() { s = i.NewCleanChain() - s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{ - Name: "PoolTest", + gov := s.App().GovKeeper.GetGovernanceAccount(s.Ctx()).GetAddress().String() + msg := &pooltypes.MsgCreatePool{ + Authority: gov, MinDelegation: 200 * i.KYVE, UploadInterval: 60, MaxBundleSize: 100, - Protocol: &pooltypes.Protocol{}, - UpgradePlan: &pooltypes.UpgradePlan{}, - }) + Binaries: "{}", + } + s.RunTxPoolSuccess(msg) - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ + s.RunTxFundersSuccess(&funderstypes.MsgCreateFunder{ Creator: i.ALICE, - Id: 0, - Amount: 100 * i.KYVE, + Moniker: "Alice", + }) + + s.RunTxFundersSuccess(&funderstypes.MsgFundPool{ + Creator: i.ALICE, + PoolId: 0, + Amount: 100 * i.KYVE, + AmountPerBundle: 1 * i.KYVE, }) s.RunTxStakersSuccess(&stakertypes.MsgCreateStaker{ @@ -518,9 +526,9 @@ var _ = Describe("grpc_query_can_propose.go", Ordered, func() { It("Call can propose on an active pool without funds as the next uploader with valid args", func() { // ARRANGE - s.RunTxPoolSuccess(&pooltypes.MsgDefundPool{ + s.RunTxPoolSuccess(&funderstypes.MsgDefundPool{ Creator: i.ALICE, - Id: 0, + PoolId: 0, Amount: 100 * i.KYVE, }) diff --git a/x/query/keeper/grpc_query_can_validate_test.go b/x/query/keeper/grpc_query_can_validate_test.go index 4a7ae15e..f40bf4e5 100644 --- a/x/query/keeper/grpc_query_can_validate_test.go +++ b/x/query/keeper/grpc_query_can_validate_test.go @@ -29,14 +29,17 @@ var _ = Describe("grpc_query_can_validate.go", Ordered, func() { BeforeEach(func() { s = i.NewCleanChain() - s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{ - Name: "PoolTest", + // create 2 pools + gov := s.App().GovKeeper.GetGovernanceAccount(s.Ctx()).GetAddress().String() + msg := &pooltypes.MsgCreatePool{ + Authority: gov, MinDelegation: 200 * i.KYVE, UploadInterval: 60, MaxBundleSize: 100, - Protocol: &pooltypes.Protocol{}, - UpgradePlan: &pooltypes.UpgradePlan{}, - }) + Binaries: "{}", + } + s.RunTxPoolSuccess(msg) + s.RunTxPoolSuccess(msg) s.RunTxStakersSuccess(&stakertypes.MsgCreateStaker{ Creator: i.STAKER_0, @@ -50,15 +53,6 @@ var _ = Describe("grpc_query_can_validate.go", Ordered, func() { Amount: 0, }) - s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{ - Name: "Test Pool2", - MinDelegation: 200 * i.KYVE, - UploadInterval: 60, - MaxBundleSize: 100, - Protocol: &pooltypes.Protocol{}, - UpgradePlan: &pooltypes.UpgradePlan{}, - }) - s.RunTxStakersSuccess(&stakertypes.MsgCreateStaker{ Creator: i.STAKER_1, Amount: 100 * i.KYVE, diff --git a/x/query/keeper/grpc_query_can_vote_test.go b/x/query/keeper/grpc_query_can_vote_test.go index a6e90f72..26a99844 100644 --- a/x/query/keeper/grpc_query_can_vote_test.go +++ b/x/query/keeper/grpc_query_can_vote_test.go @@ -5,6 +5,7 @@ import ( i "github.com/KYVENetwork/chain/testutil/integration" bundletypes "github.com/KYVENetwork/chain/x/bundles/types" delegationtypes "github.com/KYVENetwork/chain/x/delegation/types" + funderstypes "github.com/KYVENetwork/chain/x/funders/types" pooltypes "github.com/KYVENetwork/chain/x/pool/types" querytypes "github.com/KYVENetwork/chain/x/query/types" stakertypes "github.com/KYVENetwork/chain/x/stakers/types" @@ -39,19 +40,26 @@ var _ = Describe("grpc_query_can_vote.go", Ordered, func() { BeforeEach(func() { s = i.NewCleanChain() - s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{ - Name: "PoolTest", + gov := s.App().GovKeeper.GetGovernanceAccount(s.Ctx()).GetAddress().String() + msg := &pooltypes.MsgCreatePool{ + Authority: gov, MinDelegation: 200 * i.KYVE, UploadInterval: 60, MaxBundleSize: 100, - Protocol: &pooltypes.Protocol{}, - UpgradePlan: &pooltypes.UpgradePlan{}, - }) + Binaries: "{}", + } + s.RunTxPoolSuccess(msg) - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ + s.RunTxFundersSuccess(&funderstypes.MsgCreateFunder{ Creator: i.ALICE, - Id: 0, - Amount: 100 * i.KYVE, + Moniker: "Alice", + }) + + s.RunTxPoolSuccess(&funderstypes.MsgFundPool{ + Creator: i.ALICE, + PoolId: 0, + Amount: 100 * i.KYVE, + AmountPerBundle: 1 * i.KYVE, }) s.RunTxStakersSuccess(&stakertypes.MsgCreateStaker{ @@ -467,9 +475,9 @@ var _ = Describe("grpc_query_can_vote.go", Ordered, func() { It("Call can vote on an active pool with no funds and a data bundle with valid args", func() { // ARRANGE - s.RunTxPoolSuccess(&pooltypes.MsgDefundPool{ + s.RunTxPoolSuccess(&funderstypes.MsgDefundPool{ Creator: i.ALICE, - Id: 0, + PoolId: 0, Amount: 100 * i.KYVE, }) diff --git a/x/query/keeper/grpc_query_funders.go b/x/query/keeper/grpc_query_funders.go new file mode 100644 index 00000000..167660a2 --- /dev/null +++ b/x/query/keeper/grpc_query_funders.go @@ -0,0 +1,107 @@ +package keeper + +import ( + "context" + + fundersTypes "github.com/KYVENetwork/chain/x/funders/types" + + sdk "github.com/cosmos/cosmos-sdk/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + "github.com/KYVENetwork/chain/x/query/types" +) + +func (k Keeper) Funders(c context.Context, req *types.QueryFundersRequest) (*types.QueryFundersResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + ctx := sdk.UnwrapSDKContext(c) + + funders, pageRes, err := k.fundersKeeper.GetPaginatedFundersQuery(ctx, req.Pagination, req.Search) + if err != nil { + return nil, err + } + + data := make([]types.Funder, 0) + for _, funder := range funders { + fundings := k.fundersKeeper.GetFundingsOfFunder(ctx, funder.Address) + data = append(data, k.parseFunder(&funder, fundings)) + } + + return &types.QueryFundersResponse{Funders: data, Pagination: pageRes}, nil +} + +func (k Keeper) Funder(c context.Context, req *types.QueryFunderRequest) (*types.QueryFunderResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + ctx := sdk.UnwrapSDKContext(c) + + funder, found := k.fundersKeeper.GetFunder(ctx, req.Address) + if !found { + return nil, status.Error(codes.NotFound, "funder not found") + } + + allFundings := k.fundersKeeper.GetFundingsOfFunder(ctx, funder.Address) + fundings := k.filterFundingsOnStatus(allFundings, req.Status) + + funderData := k.parseFunder(&funder, allFundings) + fundingsData := k.parseFundings(fundings) + + return &types.QueryFunderResponse{ + Funder: &funderData, + Fundings: fundingsData, + }, nil +} + +func (k Keeper) filterFundingsOnStatus(fundings []fundersTypes.Funding, fundingStatus types.FundingStatus) []fundersTypes.Funding { + if fundingStatus == types.FUNDING_STATUS_UNSPECIFIED { + return fundings + } + + filtered := make([]fundersTypes.Funding, 0) + for _, funding := range fundings { + if fundingStatus == types.FUNDING_STATUS_ACTIVE && funding.Amount > 0 { + filtered = append(filtered, funding) + } + if fundingStatus == types.FUNDING_STATUS_INACTIVE && funding.Amount == 0 { + filtered = append(filtered, funding) + } + } + return filtered +} + +func (k Keeper) parseFunder(funder *fundersTypes.Funder, fundings []fundersTypes.Funding) types.Funder { + totalUsedFunds := uint64(0) + totalAllocatedFunds := uint64(0) + totalAmountPerBundle := uint64(0) + poolsFunded := make([]uint64, 0) + + for _, funding := range fundings { + // Only count active fundings for totalAmountPerBundle + if funding.IsActive() { + totalAmountPerBundle += funding.AmountPerBundle + } + + totalUsedFunds += funding.TotalFunded + totalAllocatedFunds += funding.Amount + + poolsFunded = append(poolsFunded, funding.PoolId) + } + + return types.Funder{ + Address: funder.Address, + Moniker: funder.Moniker, + Identity: funder.Identity, + Website: funder.Website, + Contact: funder.Contact, + Description: funder.Description, + Stats: &types.FundingStats{ + TotalUsedFunds: totalUsedFunds, + TotalAllocatedFunds: totalAllocatedFunds, + TotalAmountPerBundle: totalAmountPerBundle, + PoolsFunded: poolsFunded, + }, + } +} diff --git a/x/query/keeper/grpc_query_fundings.go b/x/query/keeper/grpc_query_fundings.go new file mode 100644 index 00000000..71d13468 --- /dev/null +++ b/x/query/keeper/grpc_query_fundings.go @@ -0,0 +1,57 @@ +package keeper + +import ( + "context" + + fundersTypes "github.com/KYVENetwork/chain/x/funders/types" + "github.com/KYVENetwork/chain/x/query/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +func (k Keeper) FundingsByFunder(c context.Context, req *types.QueryFundingsByFunderRequest) (*types.QueryFundingsByFunderResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + ctx := sdk.UnwrapSDKContext(c) + + fundings, pageRes, err := k.fundersKeeper.GetPaginatedFundingQuery(ctx, req.Pagination, &req.Address, nil, req.Status) + if err != nil { + return nil, err + } + + data := k.parseFundings(fundings) + + return &types.QueryFundingsByFunderResponse{Fundings: data, Pagination: pageRes}, nil +} + +func (k Keeper) FundingsByPool(c context.Context, req *types.QueryFundingsByPoolRequest) (*types.QueryFundingsByPoolResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + ctx := sdk.UnwrapSDKContext(c) + + fundings, pageRes, err := k.fundersKeeper.GetPaginatedFundingQuery(ctx, req.Pagination, nil, &req.PoolId, req.Status) + if err != nil { + return nil, err + } + + data := k.parseFundings(fundings) + + return &types.QueryFundingsByPoolResponse{Fundings: data, Pagination: pageRes}, nil +} + +func (k Keeper) parseFundings(fundings []fundersTypes.Funding) []types.Funding { + fundingsData := make([]types.Funding, 0) + for _, funding := range fundings { + fundingsData = append(fundingsData, types.Funding{ + FunderAddress: funding.FunderAddress, + PoolId: funding.PoolId, + Amount: funding.Amount, + AmountPerBundle: funding.AmountPerBundle, + TotalFunded: funding.TotalFunded, + }) + } + return fundingsData +} diff --git a/x/query/keeper/helper.go b/x/query/keeper/helper.go index 7c95af28..8847f21e 100644 --- a/x/query/keeper/helper.go +++ b/x/query/keeper/helper.go @@ -44,15 +44,15 @@ func (k Keeper) GetFullStaker(ctx sdk.Context, stakerAddress string) *types.Full poolMemberships = append( poolMemberships, &types.PoolMembership{ Pool: &types.BasicPool{ - Id: pool.Id, - Name: pool.Name, - Runtime: pool.Runtime, - Logo: pool.Logo, - OperatingCost: pool.OperatingCost, - UploadInterval: pool.UploadInterval, - TotalFunds: pool.TotalFunds, - TotalDelegation: k.delegationKeeper.GetDelegationOfPool(ctx, pool.Id), - Status: k.GetPoolStatus(ctx, &pool), + Id: pool.Id, + Name: pool.Name, + Runtime: pool.Runtime, + Logo: pool.Logo, + InflationShareWeight: pool.InflationShareWeight, + UploadInterval: pool.UploadInterval, + TotalFunds: k.fundersKeeper.GetTotalActiveFunding(ctx, pool.Id), + TotalDelegation: k.delegationKeeper.GetDelegationOfPool(ctx, pool.Id), + Status: k.GetPoolStatus(ctx, &pool), }, Points: valaccount.Points, IsLeaving: valaccount.IsLeaving, @@ -87,6 +87,7 @@ func (k Keeper) GetPoolStatus(ctx sdk.Context, pool *pooltypes.Pool) pooltypes.P var poolStatus pooltypes.PoolStatus + poolStatus = pooltypes.POOL_STATUS_ACTIVE if pool.UpgradePlan.ScheduledAt > 0 && uint64(ctx.BlockTime().Unix()) >= pool.UpgradePlan.ScheduledAt { poolStatus = pooltypes.POOL_STATUS_UPGRADING } else if pool.Disabled { @@ -95,10 +96,8 @@ func (k Keeper) GetPoolStatus(ctx sdk.Context, pool *pooltypes.Pool) pooltypes.P poolStatus = pooltypes.POOL_STATUS_NOT_ENOUGH_DELEGATION } else if highestDelegation*2 > totalDelegation { poolStatus = pooltypes.POOL_STATUS_VOTING_POWER_TOO_HIGH - } else if pool.TotalFunds == 0 { + } else if k.fundersKeeper.GetTotalActiveFunding(ctx, pool.Id) == 0 { poolStatus = pooltypes.POOL_STATUS_NO_FUNDS - } else { - poolStatus = pooltypes.POOL_STATUS_ACTIVE } return poolStatus diff --git a/x/query/keeper/keeper.go b/x/query/keeper/keeper.go index 570911f4..09a794ba 100644 --- a/x/query/keeper/keeper.go +++ b/x/query/keeper/keeper.go @@ -3,6 +3,8 @@ package keeper import ( "fmt" + fundersKeeper "github.com/KYVENetwork/chain/x/funders/keeper" + globalKeeper "github.com/KYVENetwork/chain/x/global/keeper" teamKeeper "github.com/KYVENetwork/chain/x/team/keeper" govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper" @@ -41,6 +43,7 @@ type ( globalKeeper globalKeeper.Keeper govKeeper govkeeper.Keeper teamKeeper teamKeeper.Keeper + fundersKeeper fundersKeeper.Keeper } ) @@ -60,6 +63,7 @@ func NewKeeper( globalKeeper globalKeeper.Keeper, govKeeper govkeeper.Keeper, teamKeeper teamKeeper.Keeper, + fundersKeeper fundersKeeper.Keeper, ) *Keeper { return &Keeper{ cdc: cdc, @@ -77,6 +81,7 @@ func NewKeeper( globalKeeper: globalKeeper, govKeeper: govKeeper, teamKeeper: teamKeeper, + fundersKeeper: fundersKeeper, } } diff --git a/x/query/module.go b/x/query/module.go index 6997f108..1846e55e 100644 --- a/x/query/module.go +++ b/x/query/module.go @@ -67,6 +67,7 @@ func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *r _ = types.RegisterQueryDelegationHandlerClient(context.Background(), mux, types.NewQueryDelegationClient(clientCtx)) _ = types.RegisterQueryBundlesHandlerClient(context.Background(), mux, types.NewQueryBundlesClient(clientCtx)) _ = types.RegisterQueryParamsHandlerClient(context.Background(), mux, types.NewQueryParamsClient(clientCtx)) + _ = types.RegisterQueryFundersHandlerClient(context.Background(), mux, types.NewQueryFundersClient(clientCtx)) } // GetTxCmd returns the root Tx command for the module. The subcommands of this root command are used by end-users to generate new transactions containing messages defined in the module @@ -117,6 +118,7 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { types.RegisterQueryDelegationServer(cfg.QueryServer(), am.keeper) types.RegisterQueryBundlesServer(cfg.QueryServer(), am.keeper) types.RegisterQueryParamsServer(cfg.QueryServer(), am.keeper) + types.RegisterQueryFundersServer(cfg.QueryServer(), am.keeper) } // RegisterInvariants registers the invariants of the module. If an invariant deviates from its predicted value, the InvariantRegistry triggers appropriate logic (most often the chain will be halted) diff --git a/x/query/types/funders.pb.go b/x/query/types/funders.pb.go new file mode 100644 index 00000000..8b8da549 --- /dev/null +++ b/x/query/types/funders.pb.go @@ -0,0 +1,3517 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: kyve/query/v1beta1/funders.proto + +package types + +import ( + context "context" + fmt "fmt" + query "github.com/cosmos/cosmos-sdk/types/query" + _ "github.com/cosmos/gogoproto/gogoproto" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + _ "google.golang.org/genproto/googleapis/api/annotations" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// FundingStatus ... +type FundingStatus int32 + +const ( + // FundingStatusUnspecified ... + FUNDING_STATUS_UNSPECIFIED FundingStatus = 0 + // FundingStatusActive status is set when the funding is active. + FUNDING_STATUS_ACTIVE FundingStatus = 1 + // FundingStatusInactive status is set when the funding has been used up or refunded. + FUNDING_STATUS_INACTIVE FundingStatus = 2 +) + +var FundingStatus_name = map[int32]string{ + 0: "FUNDING_STATUS_UNSPECIFIED", + 1: "FUNDING_STATUS_ACTIVE", + 2: "FUNDING_STATUS_INACTIVE", +} + +var FundingStatus_value = map[string]int32{ + "FUNDING_STATUS_UNSPECIFIED": 0, + "FUNDING_STATUS_ACTIVE": 1, + "FUNDING_STATUS_INACTIVE": 2, +} + +func (x FundingStatus) String() string { + return proto.EnumName(FundingStatus_name, int32(x)) +} + +func (FundingStatus) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_a182f068d9f0dba9, []int{0} +} + +// Funder ... +type Funder struct { + // address ... + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + // moniker ... + Moniker string `protobuf:"bytes,2,opt,name=moniker,proto3" json:"moniker,omitempty"` + // identity is the 64 bit keybase.io identity string + Identity string `protobuf:"bytes,3,opt,name=identity,proto3" json:"identity,omitempty"` + // website ... + Website string `protobuf:"bytes,4,opt,name=website,proto3" json:"website,omitempty"` + // contact ... + Contact string `protobuf:"bytes,5,opt,name=contact,proto3" json:"contact,omitempty"` + // description ... + Description string `protobuf:"bytes,6,opt,name=description,proto3" json:"description,omitempty"` + // statistics about all the fundings of the funder. + Stats *FundingStats `protobuf:"bytes,7,opt,name=stats,proto3" json:"stats,omitempty"` +} + +func (m *Funder) Reset() { *m = Funder{} } +func (m *Funder) String() string { return proto.CompactTextString(m) } +func (*Funder) ProtoMessage() {} +func (*Funder) Descriptor() ([]byte, []int) { + return fileDescriptor_a182f068d9f0dba9, []int{0} +} +func (m *Funder) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Funder) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Funder.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 *Funder) XXX_Merge(src proto.Message) { + xxx_messageInfo_Funder.Merge(m, src) +} +func (m *Funder) XXX_Size() int { + return m.Size() +} +func (m *Funder) XXX_DiscardUnknown() { + xxx_messageInfo_Funder.DiscardUnknown(m) +} + +var xxx_messageInfo_Funder proto.InternalMessageInfo + +func (m *Funder) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +func (m *Funder) GetMoniker() string { + if m != nil { + return m.Moniker + } + return "" +} + +func (m *Funder) GetIdentity() string { + if m != nil { + return m.Identity + } + return "" +} + +func (m *Funder) GetWebsite() string { + if m != nil { + return m.Website + } + return "" +} + +func (m *Funder) GetContact() string { + if m != nil { + return m.Contact + } + return "" +} + +func (m *Funder) GetDescription() string { + if m != nil { + return m.Description + } + return "" +} + +func (m *Funder) GetStats() *FundingStats { + if m != nil { + return m.Stats + } + return nil +} + +// FundingStats ... +type FundingStats struct { + // total_used_funds are the total funds that have been distributed by the funder. + TotalUsedFunds uint64 `protobuf:"varint,1,opt,name=total_used_funds,json=totalUsedFunds,proto3" json:"total_used_funds,omitempty"` + // total_allocated_funds are the total funds that have been allocated by the funder. They can either get distributed or refunded. + TotalAllocatedFunds uint64 `protobuf:"varint,2,opt,name=total_allocated_funds,json=totalAllocatedFunds,proto3" json:"total_allocated_funds,omitempty"` + // total_amount_per_bundle is the total amount per bundle of all fundings of the funder. + TotalAmountPerBundle uint64 `protobuf:"varint,3,opt,name=total_amount_per_bundle,json=totalAmountPerBundle,proto3" json:"total_amount_per_bundle,omitempty"` + // pools_funded are the ids of the pools that have been funded by the funder. + PoolsFunded []uint64 `protobuf:"varint,4,rep,packed,name=pools_funded,json=poolsFunded,proto3" json:"pools_funded,omitempty"` +} + +func (m *FundingStats) Reset() { *m = FundingStats{} } +func (m *FundingStats) String() string { return proto.CompactTextString(m) } +func (*FundingStats) ProtoMessage() {} +func (*FundingStats) Descriptor() ([]byte, []int) { + return fileDescriptor_a182f068d9f0dba9, []int{1} +} +func (m *FundingStats) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *FundingStats) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_FundingStats.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 *FundingStats) XXX_Merge(src proto.Message) { + xxx_messageInfo_FundingStats.Merge(m, src) +} +func (m *FundingStats) XXX_Size() int { + return m.Size() +} +func (m *FundingStats) XXX_DiscardUnknown() { + xxx_messageInfo_FundingStats.DiscardUnknown(m) +} + +var xxx_messageInfo_FundingStats proto.InternalMessageInfo + +func (m *FundingStats) GetTotalUsedFunds() uint64 { + if m != nil { + return m.TotalUsedFunds + } + return 0 +} + +func (m *FundingStats) GetTotalAllocatedFunds() uint64 { + if m != nil { + return m.TotalAllocatedFunds + } + return 0 +} + +func (m *FundingStats) GetTotalAmountPerBundle() uint64 { + if m != nil { + return m.TotalAmountPerBundle + } + return 0 +} + +func (m *FundingStats) GetPoolsFunded() []uint64 { + if m != nil { + return m.PoolsFunded + } + return nil +} + +// Funding ... +type Funding struct { + // funder_address + FunderAddress string `protobuf:"bytes,1,opt,name=funder_address,json=funderAddress,proto3" json:"funder_address,omitempty"` + // pool_id ... + PoolId uint64 `protobuf:"varint,2,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty"` + // amount ... + Amount uint64 `protobuf:"varint,3,opt,name=amount,proto3" json:"amount,omitempty"` + // amount_per_bundle ... + AmountPerBundle uint64 `protobuf:"varint,4,opt,name=amount_per_bundle,json=amountPerBundle,proto3" json:"amount_per_bundle,omitempty"` + // total_funded ... + TotalFunded uint64 `protobuf:"varint,5,opt,name=total_funded,json=totalFunded,proto3" json:"total_funded,omitempty"` +} + +func (m *Funding) Reset() { *m = Funding{} } +func (m *Funding) String() string { return proto.CompactTextString(m) } +func (*Funding) ProtoMessage() {} +func (*Funding) Descriptor() ([]byte, []int) { + return fileDescriptor_a182f068d9f0dba9, []int{2} +} +func (m *Funding) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Funding) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Funding.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 *Funding) XXX_Merge(src proto.Message) { + xxx_messageInfo_Funding.Merge(m, src) +} +func (m *Funding) XXX_Size() int { + return m.Size() +} +func (m *Funding) XXX_DiscardUnknown() { + xxx_messageInfo_Funding.DiscardUnknown(m) +} + +var xxx_messageInfo_Funding proto.InternalMessageInfo + +func (m *Funding) GetFunderAddress() string { + if m != nil { + return m.FunderAddress + } + return "" +} + +func (m *Funding) GetPoolId() uint64 { + if m != nil { + return m.PoolId + } + return 0 +} + +func (m *Funding) GetAmount() uint64 { + if m != nil { + return m.Amount + } + return 0 +} + +func (m *Funding) GetAmountPerBundle() uint64 { + if m != nil { + return m.AmountPerBundle + } + return 0 +} + +func (m *Funding) GetTotalFunded() uint64 { + if m != nil { + return m.TotalFunded + } + return 0 +} + +// QueryFundersRequest is the request type for the Query/Funders RPC method. +type QueryFundersRequest struct { + // pagination defines an optional pagination for the request. + Pagination *query.PageRequest `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination,omitempty"` + // search ... + Search string `protobuf:"bytes,2,opt,name=search,proto3" json:"search,omitempty"` +} + +func (m *QueryFundersRequest) Reset() { *m = QueryFundersRequest{} } +func (m *QueryFundersRequest) String() string { return proto.CompactTextString(m) } +func (*QueryFundersRequest) ProtoMessage() {} +func (*QueryFundersRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_a182f068d9f0dba9, []int{3} +} +func (m *QueryFundersRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryFundersRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryFundersRequest.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 *QueryFundersRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryFundersRequest.Merge(m, src) +} +func (m *QueryFundersRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryFundersRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryFundersRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryFundersRequest proto.InternalMessageInfo + +func (m *QueryFundersRequest) GetPagination() *query.PageRequest { + if m != nil { + return m.Pagination + } + return nil +} + +func (m *QueryFundersRequest) GetSearch() string { + if m != nil { + return m.Search + } + return "" +} + +// QueryFundersResponse is the response type for the Query/Funders RPC method. +type QueryFundersResponse struct { + // pagination defines the pagination in the response. + Pagination *query.PageResponse `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination,omitempty"` + // funders ... + Funders []Funder `protobuf:"bytes,2,rep,name=funders,proto3" json:"funders"` +} + +func (m *QueryFundersResponse) Reset() { *m = QueryFundersResponse{} } +func (m *QueryFundersResponse) String() string { return proto.CompactTextString(m) } +func (*QueryFundersResponse) ProtoMessage() {} +func (*QueryFundersResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_a182f068d9f0dba9, []int{4} +} +func (m *QueryFundersResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryFundersResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryFundersResponse.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 *QueryFundersResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryFundersResponse.Merge(m, src) +} +func (m *QueryFundersResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryFundersResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryFundersResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryFundersResponse proto.InternalMessageInfo + +func (m *QueryFundersResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination + } + return nil +} + +func (m *QueryFundersResponse) GetFunders() []Funder { + if m != nil { + return m.Funders + } + return nil +} + +// QueryFunderRequest is the request type for the Query/Funder RPC method. +type QueryFunderRequest struct { + // address ... + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + // status ... + Status FundingStatus `protobuf:"varint,3,opt,name=status,proto3,enum=kyve.query.v1beta1.FundingStatus" json:"status,omitempty"` +} + +func (m *QueryFunderRequest) Reset() { *m = QueryFunderRequest{} } +func (m *QueryFunderRequest) String() string { return proto.CompactTextString(m) } +func (*QueryFunderRequest) ProtoMessage() {} +func (*QueryFunderRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_a182f068d9f0dba9, []int{5} +} +func (m *QueryFunderRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryFunderRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryFunderRequest.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 *QueryFunderRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryFunderRequest.Merge(m, src) +} +func (m *QueryFunderRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryFunderRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryFunderRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryFunderRequest proto.InternalMessageInfo + +func (m *QueryFunderRequest) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +func (m *QueryFunderRequest) GetStatus() FundingStatus { + if m != nil { + return m.Status + } + return FUNDING_STATUS_UNSPECIFIED +} + +// QueryFunderResponse is the response type for the Query/Funder RPC method. +type QueryFunderResponse struct { + // funder ... + Funder *Funder `protobuf:"bytes,1,opt,name=funder,proto3" json:"funder,omitempty"` + // fundings ... + Fundings []Funding `protobuf:"bytes,2,rep,name=fundings,proto3" json:"fundings"` +} + +func (m *QueryFunderResponse) Reset() { *m = QueryFunderResponse{} } +func (m *QueryFunderResponse) String() string { return proto.CompactTextString(m) } +func (*QueryFunderResponse) ProtoMessage() {} +func (*QueryFunderResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_a182f068d9f0dba9, []int{6} +} +func (m *QueryFunderResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryFunderResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryFunderResponse.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 *QueryFunderResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryFunderResponse.Merge(m, src) +} +func (m *QueryFunderResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryFunderResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryFunderResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryFunderResponse proto.InternalMessageInfo + +func (m *QueryFunderResponse) GetFunder() *Funder { + if m != nil { + return m.Funder + } + return nil +} + +func (m *QueryFunderResponse) GetFundings() []Funding { + if m != nil { + return m.Fundings + } + return nil +} + +// QueryFundingsByFunderRequest is the request type for the Query/FundingsByFunder RPC method. +type QueryFundingsByFunderRequest struct { + // pagination defines an optional pagination for the request. + Pagination *query.PageRequest `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination,omitempty"` + // address ... + Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"` + // status ... + Status FundingStatus `protobuf:"varint,3,opt,name=status,proto3,enum=kyve.query.v1beta1.FundingStatus" json:"status,omitempty"` +} + +func (m *QueryFundingsByFunderRequest) Reset() { *m = QueryFundingsByFunderRequest{} } +func (m *QueryFundingsByFunderRequest) String() string { return proto.CompactTextString(m) } +func (*QueryFundingsByFunderRequest) ProtoMessage() {} +func (*QueryFundingsByFunderRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_a182f068d9f0dba9, []int{7} +} +func (m *QueryFundingsByFunderRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryFundingsByFunderRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryFundingsByFunderRequest.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 *QueryFundingsByFunderRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryFundingsByFunderRequest.Merge(m, src) +} +func (m *QueryFundingsByFunderRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryFundingsByFunderRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryFundingsByFunderRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryFundingsByFunderRequest proto.InternalMessageInfo + +func (m *QueryFundingsByFunderRequest) GetPagination() *query.PageRequest { + if m != nil { + return m.Pagination + } + return nil +} + +func (m *QueryFundingsByFunderRequest) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +func (m *QueryFundingsByFunderRequest) GetStatus() FundingStatus { + if m != nil { + return m.Status + } + return FUNDING_STATUS_UNSPECIFIED +} + +// QueryFundingsByFunderResponse is the response type for the Query/FundingsByFunder RPC method. +type QueryFundingsByFunderResponse struct { + // pagination defines the pagination in the response. + Pagination *query.PageResponse `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination,omitempty"` + // fundings ... + Fundings []Funding `protobuf:"bytes,2,rep,name=fundings,proto3" json:"fundings"` +} + +func (m *QueryFundingsByFunderResponse) Reset() { *m = QueryFundingsByFunderResponse{} } +func (m *QueryFundingsByFunderResponse) String() string { return proto.CompactTextString(m) } +func (*QueryFundingsByFunderResponse) ProtoMessage() {} +func (*QueryFundingsByFunderResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_a182f068d9f0dba9, []int{8} +} +func (m *QueryFundingsByFunderResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryFundingsByFunderResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryFundingsByFunderResponse.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 *QueryFundingsByFunderResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryFundingsByFunderResponse.Merge(m, src) +} +func (m *QueryFundingsByFunderResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryFundingsByFunderResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryFundingsByFunderResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryFundingsByFunderResponse proto.InternalMessageInfo + +func (m *QueryFundingsByFunderResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination + } + return nil +} + +func (m *QueryFundingsByFunderResponse) GetFundings() []Funding { + if m != nil { + return m.Fundings + } + return nil +} + +// QueryFundingsByPoolRequest is the request type for the Query/FundingsByPool RPC method. +type QueryFundingsByPoolRequest struct { + // pagination defines an optional pagination for the request. + Pagination *query.PageRequest `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination,omitempty"` + // pool_id ... + PoolId uint64 `protobuf:"varint,2,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty"` + // status ... + Status FundingStatus `protobuf:"varint,3,opt,name=status,proto3,enum=kyve.query.v1beta1.FundingStatus" json:"status,omitempty"` +} + +func (m *QueryFundingsByPoolRequest) Reset() { *m = QueryFundingsByPoolRequest{} } +func (m *QueryFundingsByPoolRequest) String() string { return proto.CompactTextString(m) } +func (*QueryFundingsByPoolRequest) ProtoMessage() {} +func (*QueryFundingsByPoolRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_a182f068d9f0dba9, []int{9} +} +func (m *QueryFundingsByPoolRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryFundingsByPoolRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryFundingsByPoolRequest.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 *QueryFundingsByPoolRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryFundingsByPoolRequest.Merge(m, src) +} +func (m *QueryFundingsByPoolRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryFundingsByPoolRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryFundingsByPoolRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryFundingsByPoolRequest proto.InternalMessageInfo + +func (m *QueryFundingsByPoolRequest) GetPagination() *query.PageRequest { + if m != nil { + return m.Pagination + } + return nil +} + +func (m *QueryFundingsByPoolRequest) GetPoolId() uint64 { + if m != nil { + return m.PoolId + } + return 0 +} + +func (m *QueryFundingsByPoolRequest) GetStatus() FundingStatus { + if m != nil { + return m.Status + } + return FUNDING_STATUS_UNSPECIFIED +} + +// QueryFundingsByPoolResponse is the response type for the Query/FundingsByPool RPC method. +type QueryFundingsByPoolResponse struct { + // pagination defines the pagination in the response. + Pagination *query.PageResponse `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination,omitempty"` + // fundings ... + Fundings []Funding `protobuf:"bytes,2,rep,name=fundings,proto3" json:"fundings"` +} + +func (m *QueryFundingsByPoolResponse) Reset() { *m = QueryFundingsByPoolResponse{} } +func (m *QueryFundingsByPoolResponse) String() string { return proto.CompactTextString(m) } +func (*QueryFundingsByPoolResponse) ProtoMessage() {} +func (*QueryFundingsByPoolResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_a182f068d9f0dba9, []int{10} +} +func (m *QueryFundingsByPoolResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryFundingsByPoolResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryFundingsByPoolResponse.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 *QueryFundingsByPoolResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryFundingsByPoolResponse.Merge(m, src) +} +func (m *QueryFundingsByPoolResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryFundingsByPoolResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryFundingsByPoolResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryFundingsByPoolResponse proto.InternalMessageInfo + +func (m *QueryFundingsByPoolResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination + } + return nil +} + +func (m *QueryFundingsByPoolResponse) GetFundings() []Funding { + if m != nil { + return m.Fundings + } + return nil +} + +func init() { + proto.RegisterEnum("kyve.query.v1beta1.FundingStatus", FundingStatus_name, FundingStatus_value) + proto.RegisterType((*Funder)(nil), "kyve.query.v1beta1.Funder") + proto.RegisterType((*FundingStats)(nil), "kyve.query.v1beta1.FundingStats") + proto.RegisterType((*Funding)(nil), "kyve.query.v1beta1.Funding") + proto.RegisterType((*QueryFundersRequest)(nil), "kyve.query.v1beta1.QueryFundersRequest") + proto.RegisterType((*QueryFundersResponse)(nil), "kyve.query.v1beta1.QueryFundersResponse") + proto.RegisterType((*QueryFunderRequest)(nil), "kyve.query.v1beta1.QueryFunderRequest") + proto.RegisterType((*QueryFunderResponse)(nil), "kyve.query.v1beta1.QueryFunderResponse") + proto.RegisterType((*QueryFundingsByFunderRequest)(nil), "kyve.query.v1beta1.QueryFundingsByFunderRequest") + proto.RegisterType((*QueryFundingsByFunderResponse)(nil), "kyve.query.v1beta1.QueryFundingsByFunderResponse") + proto.RegisterType((*QueryFundingsByPoolRequest)(nil), "kyve.query.v1beta1.QueryFundingsByPoolRequest") + proto.RegisterType((*QueryFundingsByPoolResponse)(nil), "kyve.query.v1beta1.QueryFundingsByPoolResponse") +} + +func init() { proto.RegisterFile("kyve/query/v1beta1/funders.proto", fileDescriptor_a182f068d9f0dba9) } + +var fileDescriptor_a182f068d9f0dba9 = []byte{ + // 952 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x96, 0xcf, 0x6f, 0x1b, 0x45, + 0x14, 0xc7, 0x3d, 0xce, 0xc6, 0x2e, 0xcf, 0x69, 0x08, 0xd3, 0x94, 0x2c, 0x9b, 0xd6, 0xb8, 0x06, + 0x12, 0x2b, 0x42, 0xbb, 0x89, 0x11, 0x15, 0x20, 0x71, 0x48, 0x9a, 0xa4, 0xb2, 0x90, 0xac, 0xb0, + 0x49, 0x2a, 0xc1, 0x65, 0xb5, 0xf6, 0x4e, 0x9d, 0x55, 0xec, 0x9d, 0xed, 0xce, 0x6c, 0x8b, 0x55, + 0xf5, 0x00, 0x17, 0x7a, 0x44, 0xe2, 0xc8, 0x11, 0x21, 0xc4, 0x0d, 0x6e, 0x48, 0xdc, 0x51, 0x8f, + 0x95, 0xb8, 0x70, 0x42, 0x28, 0x41, 0xfc, 0x15, 0x1c, 0xd0, 0xfc, 0xb0, 0x6b, 0x3b, 0x76, 0x5c, + 0xd4, 0x1c, 0xb8, 0xed, 0xbc, 0xf7, 0xbe, 0x7e, 0x9f, 0xf7, 0x63, 0xd6, 0x0b, 0xa5, 0xe3, 0xee, + 0x7d, 0xe2, 0xdc, 0x4b, 0x49, 0xd2, 0x75, 0xee, 0x6f, 0x34, 0x08, 0xf7, 0x37, 0x9c, 0xbb, 0x69, + 0x14, 0x90, 0x84, 0xd9, 0x71, 0x42, 0x39, 0xc5, 0x58, 0x44, 0xd8, 0x32, 0xc2, 0xd6, 0x11, 0xd6, + 0x5a, 0x93, 0xb2, 0x0e, 0x65, 0x4e, 0xc3, 0x67, 0xa3, 0xe2, 0xd8, 0x6f, 0x85, 0x91, 0xcf, 0x43, + 0x1a, 0x29, 0xbd, 0xb5, 0xd8, 0xa2, 0x2d, 0x2a, 0x1f, 0x1d, 0xf1, 0xa4, 0xad, 0xd7, 0x5a, 0x94, + 0xb6, 0xda, 0xc4, 0xf1, 0xe3, 0xd0, 0xf1, 0xa3, 0x88, 0x72, 0x29, 0xd1, 0x39, 0xcb, 0x7f, 0x23, + 0xc8, 0xed, 0x4a, 0x0a, 0x6c, 0x42, 0xde, 0x0f, 0x82, 0x84, 0x30, 0x66, 0xa2, 0x12, 0xaa, 0xbc, + 0xe4, 0xf6, 0x8e, 0xc2, 0xd3, 0xa1, 0x51, 0x78, 0x4c, 0x12, 0x33, 0xab, 0x3c, 0xfa, 0x88, 0x2d, + 0xb8, 0x14, 0x06, 0x24, 0xe2, 0x21, 0xef, 0x9a, 0x33, 0xd2, 0xd5, 0x3f, 0x0b, 0xd5, 0x03, 0xd2, + 0x60, 0x21, 0x27, 0xa6, 0xa1, 0x54, 0xfa, 0x28, 0x3c, 0x4d, 0x1a, 0x71, 0xbf, 0xc9, 0xcd, 0x59, + 0xe5, 0xd1, 0x47, 0x5c, 0x82, 0x42, 0x40, 0x58, 0x33, 0x09, 0x63, 0x01, 0x69, 0xe6, 0xa4, 0x77, + 0xd0, 0x84, 0x6f, 0xc2, 0x2c, 0xe3, 0x3e, 0x67, 0x66, 0xbe, 0x84, 0x2a, 0x85, 0x6a, 0xc9, 0x3e, + 0xdb, 0x34, 0x5b, 0x14, 0x14, 0x46, 0xad, 0x7d, 0x11, 0xe7, 0xaa, 0xf0, 0xf2, 0xaf, 0x08, 0xe6, + 0x06, 0xed, 0xb8, 0x02, 0x0b, 0x9c, 0x72, 0xbf, 0xed, 0xa5, 0x8c, 0x04, 0x9e, 0x98, 0x84, 0xaa, + 0xdb, 0x70, 0xe7, 0xa5, 0xfd, 0x90, 0x91, 0x40, 0x08, 0x18, 0xae, 0xc2, 0x55, 0x15, 0xe9, 0xb7, + 0xdb, 0xb4, 0xe9, 0xf3, 0x7e, 0x78, 0x56, 0x86, 0x5f, 0x91, 0xce, 0xcd, 0x9e, 0x4f, 0x69, 0xde, + 0x85, 0x25, 0xad, 0xe9, 0xd0, 0x34, 0xe2, 0x5e, 0x4c, 0x12, 0xaf, 0x91, 0x46, 0x41, 0x9b, 0xc8, + 0x3e, 0x19, 0xee, 0xa2, 0x52, 0x49, 0xef, 0x1e, 0x49, 0xb6, 0xa4, 0x0f, 0xdf, 0x80, 0xb9, 0x98, + 0xd2, 0x36, 0x93, 0x09, 0x48, 0x60, 0x1a, 0xa5, 0x99, 0x8a, 0xe1, 0x16, 0xa4, 0x4d, 0x8e, 0x29, + 0x28, 0xff, 0x88, 0x20, 0xaf, 0x0b, 0xc1, 0x6f, 0xc1, 0xbc, 0x5a, 0x21, 0x6f, 0x78, 0x72, 0x97, + 0x95, 0x75, 0x53, 0xcf, 0x6f, 0x09, 0xf2, 0xe2, 0x17, 0xbc, 0x30, 0xd0, 0xc8, 0x39, 0x71, 0xac, + 0x05, 0xf8, 0x55, 0xc8, 0x29, 0x3e, 0x0d, 0xa5, 0x4f, 0x78, 0x0d, 0x5e, 0x39, 0xcb, 0x6d, 0xc8, + 0x90, 0x97, 0xfd, 0xb3, 0xc8, 0xaa, 0x52, 0x8d, 0x3c, 0x2b, 0xc3, 0x0a, 0xd2, 0xa6, 0x91, 0x53, + 0xb8, 0xf2, 0xb1, 0x18, 0x90, 0x5a, 0x34, 0xe6, 0x92, 0x7b, 0x29, 0x61, 0x1c, 0xef, 0x02, 0x3c, + 0xdb, 0x61, 0x49, 0x5e, 0xa8, 0xae, 0xd8, 0x6a, 0xe1, 0x6d, 0xb1, 0xf0, 0x23, 0x63, 0xdd, 0xf3, + 0x5b, 0x44, 0x6b, 0xdd, 0x01, 0xa5, 0xa8, 0x82, 0x11, 0x3f, 0x69, 0x1e, 0xe9, 0xed, 0xd4, 0xa7, + 0xf2, 0x37, 0x08, 0x16, 0x87, 0xf3, 0xb2, 0x98, 0x46, 0x8c, 0xe0, 0xdb, 0x63, 0x12, 0xaf, 0x4e, + 0x4d, 0xac, 0xc4, 0x43, 0x99, 0x3f, 0x80, 0xbc, 0xbe, 0xc2, 0x66, 0xb6, 0x34, 0x53, 0x29, 0x54, + 0xad, 0x49, 0xeb, 0x48, 0x92, 0x2d, 0xe3, 0xc9, 0x1f, 0xaf, 0x67, 0xdc, 0x9e, 0xa0, 0x1c, 0x02, + 0x1e, 0x80, 0xeb, 0xf5, 0x64, 0xf2, 0x25, 0x7c, 0x1f, 0x72, 0x62, 0x93, 0x53, 0x26, 0x67, 0x35, + 0x5f, 0xbd, 0x31, 0x65, 0xf3, 0x53, 0xe6, 0x6a, 0x41, 0xf9, 0x31, 0x1a, 0x1a, 0x40, 0xbf, 0x0f, + 0x55, 0xc8, 0x29, 0x1a, 0xdd, 0x83, 0x73, 0xe8, 0x5d, 0x1d, 0x89, 0x3f, 0x84, 0x4b, 0x77, 0x55, + 0x92, 0x5e, 0xcd, 0xcb, 0xe7, 0x80, 0xe8, 0xa2, 0xfb, 0x92, 0xf2, 0x2f, 0x08, 0xae, 0xf5, 0x51, + 0x84, 0x65, 0x6b, 0xa4, 0x01, 0x17, 0xb5, 0x14, 0x03, 0x8d, 0xcc, 0x5e, 0x58, 0x23, 0xbf, 0x47, + 0x70, 0x7d, 0x02, 0xfd, 0x45, 0xaf, 0xd6, 0x0b, 0xf6, 0xf9, 0x67, 0x04, 0xd6, 0x08, 0xe9, 0x1e, + 0xa5, 0xed, 0x8b, 0xee, 0xf2, 0xc4, 0x37, 0xcb, 0x0b, 0x34, 0xf9, 0x3b, 0x04, 0xcb, 0x63, 0xd1, + 0xff, 0x5f, 0x2d, 0x5e, 0xeb, 0xc0, 0xe5, 0xa1, 0x02, 0x70, 0x11, 0xac, 0xdd, 0xc3, 0xfa, 0x76, + 0xad, 0x7e, 0xdb, 0xdb, 0x3f, 0xd8, 0x3c, 0x38, 0xdc, 0xf7, 0x0e, 0xeb, 0xfb, 0x7b, 0x3b, 0xb7, + 0x6a, 0xbb, 0xb5, 0x9d, 0xed, 0x85, 0x0c, 0x7e, 0x0d, 0xae, 0x8e, 0xf8, 0x37, 0x6f, 0x1d, 0xd4, + 0xee, 0xec, 0x2c, 0x20, 0xbc, 0x0c, 0x4b, 0x23, 0xae, 0x5a, 0x5d, 0x3b, 0xb3, 0x96, 0xf1, 0xf8, + 0xdb, 0x62, 0xa6, 0xfa, 0x8f, 0x01, 0x73, 0x83, 0x6f, 0x33, 0xfc, 0xb9, 0xfe, 0x23, 0x10, 0xcf, + 0xab, 0xe3, 0xc0, 0xc7, 0xbc, 0x73, 0xad, 0xca, 0xf4, 0x40, 0xd5, 0xa9, 0xf2, 0x1b, 0x5f, 0xfc, + 0xf6, 0xd7, 0xd7, 0xd9, 0xeb, 0x78, 0xd9, 0x99, 0xfc, 0xe1, 0x82, 0xbf, 0x7c, 0xf6, 0xf9, 0xb0, + 0x32, 0xe5, 0x97, 0x7b, 0x04, 0xab, 0x53, 0xe3, 0x34, 0xc0, 0xdb, 0x12, 0x60, 0x05, 0xbf, 0x39, + 0x19, 0xc0, 0x79, 0xa8, 0x2f, 0xf5, 0x23, 0xfc, 0x13, 0x82, 0x85, 0xd1, 0x5b, 0x89, 0xd7, 0xcf, + 0xcd, 0x35, 0xe6, 0xf5, 0x63, 0x6d, 0xfc, 0x07, 0x85, 0xe6, 0x7c, 0x4f, 0x72, 0x56, 0xf1, 0xfa, + 0x24, 0x4e, 0xa1, 0xf2, 0x1a, 0x5d, 0xef, 0x0c, 0xf3, 0x0f, 0x08, 0xe6, 0x87, 0x97, 0x1c, 0xdb, + 0xcf, 0x91, 0x7f, 0xe0, 0x22, 0x5b, 0xce, 0x73, 0xc7, 0x6b, 0xda, 0x9b, 0x92, 0x76, 0x1d, 0xdb, + 0xd3, 0x68, 0xc5, 0x45, 0x76, 0x1e, 0xea, 0xdb, 0xfd, 0x68, 0x6b, 0xfb, 0xc9, 0x49, 0x11, 0x3d, + 0x3d, 0x29, 0xa2, 0x3f, 0x4f, 0x8a, 0xe8, 0xab, 0xd3, 0x62, 0xe6, 0xe9, 0x69, 0x31, 0xf3, 0xfb, + 0x69, 0x31, 0xf3, 0xe9, 0x5a, 0x2b, 0xe4, 0x47, 0x69, 0xc3, 0x6e, 0xd2, 0x8e, 0xf3, 0xd1, 0x27, + 0x77, 0x76, 0xea, 0x84, 0x3f, 0xa0, 0xc9, 0xb1, 0xd3, 0x3c, 0xf2, 0xc3, 0xc8, 0xf9, 0x4c, 0xa7, + 0xe0, 0xdd, 0x98, 0xb0, 0x46, 0x4e, 0x7e, 0x75, 0xbe, 0xf3, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, + 0x7e, 0x45, 0x8a, 0xda, 0x0d, 0x0b, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// QueryFundersClient is the client API for QueryFunders service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type QueryFundersClient interface { + // Funders queries all funders. + Funders(ctx context.Context, in *QueryFundersRequest, opts ...grpc.CallOption) (*QueryFundersResponse, error) + // Funder queries a funder by address. + Funder(ctx context.Context, in *QueryFunderRequest, opts ...grpc.CallOption) (*QueryFunderResponse, error) + // FundingsByFunder queries all fundings of a funder by address. + FundingsByFunder(ctx context.Context, in *QueryFundingsByFunderRequest, opts ...grpc.CallOption) (*QueryFundingsByFunderResponse, error) + // FundingsByPool queries all fundings of a pool by id. + FundingsByPool(ctx context.Context, in *QueryFundingsByPoolRequest, opts ...grpc.CallOption) (*QueryFundingsByPoolResponse, error) +} + +type queryFundersClient struct { + cc grpc1.ClientConn +} + +func NewQueryFundersClient(cc grpc1.ClientConn) QueryFundersClient { + return &queryFundersClient{cc} +} + +func (c *queryFundersClient) Funders(ctx context.Context, in *QueryFundersRequest, opts ...grpc.CallOption) (*QueryFundersResponse, error) { + out := new(QueryFundersResponse) + err := c.cc.Invoke(ctx, "/kyve.query.v1beta1.QueryFunders/Funders", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryFundersClient) Funder(ctx context.Context, in *QueryFunderRequest, opts ...grpc.CallOption) (*QueryFunderResponse, error) { + out := new(QueryFunderResponse) + err := c.cc.Invoke(ctx, "/kyve.query.v1beta1.QueryFunders/Funder", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryFundersClient) FundingsByFunder(ctx context.Context, in *QueryFundingsByFunderRequest, opts ...grpc.CallOption) (*QueryFundingsByFunderResponse, error) { + out := new(QueryFundingsByFunderResponse) + err := c.cc.Invoke(ctx, "/kyve.query.v1beta1.QueryFunders/FundingsByFunder", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryFundersClient) FundingsByPool(ctx context.Context, in *QueryFundingsByPoolRequest, opts ...grpc.CallOption) (*QueryFundingsByPoolResponse, error) { + out := new(QueryFundingsByPoolResponse) + err := c.cc.Invoke(ctx, "/kyve.query.v1beta1.QueryFunders/FundingsByPool", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryFundersServer is the server API for QueryFunders service. +type QueryFundersServer interface { + // Funders queries all funders. + Funders(context.Context, *QueryFundersRequest) (*QueryFundersResponse, error) + // Funder queries a funder by address. + Funder(context.Context, *QueryFunderRequest) (*QueryFunderResponse, error) + // FundingsByFunder queries all fundings of a funder by address. + FundingsByFunder(context.Context, *QueryFundingsByFunderRequest) (*QueryFundingsByFunderResponse, error) + // FundingsByPool queries all fundings of a pool by id. + FundingsByPool(context.Context, *QueryFundingsByPoolRequest) (*QueryFundingsByPoolResponse, error) +} + +// UnimplementedQueryFundersServer can be embedded to have forward compatible implementations. +type UnimplementedQueryFundersServer struct { +} + +func (*UnimplementedQueryFundersServer) Funders(ctx context.Context, req *QueryFundersRequest) (*QueryFundersResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Funders not implemented") +} +func (*UnimplementedQueryFundersServer) Funder(ctx context.Context, req *QueryFunderRequest) (*QueryFunderResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Funder not implemented") +} +func (*UnimplementedQueryFundersServer) FundingsByFunder(ctx context.Context, req *QueryFundingsByFunderRequest) (*QueryFundingsByFunderResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method FundingsByFunder not implemented") +} +func (*UnimplementedQueryFundersServer) FundingsByPool(ctx context.Context, req *QueryFundingsByPoolRequest) (*QueryFundingsByPoolResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method FundingsByPool not implemented") +} + +func RegisterQueryFundersServer(s grpc1.Server, srv QueryFundersServer) { + s.RegisterService(&_QueryFunders_serviceDesc, srv) +} + +func _QueryFunders_Funders_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryFundersRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryFundersServer).Funders(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/kyve.query.v1beta1.QueryFunders/Funders", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryFundersServer).Funders(ctx, req.(*QueryFundersRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _QueryFunders_Funder_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryFunderRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryFundersServer).Funder(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/kyve.query.v1beta1.QueryFunders/Funder", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryFundersServer).Funder(ctx, req.(*QueryFunderRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _QueryFunders_FundingsByFunder_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryFundingsByFunderRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryFundersServer).FundingsByFunder(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/kyve.query.v1beta1.QueryFunders/FundingsByFunder", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryFundersServer).FundingsByFunder(ctx, req.(*QueryFundingsByFunderRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _QueryFunders_FundingsByPool_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryFundingsByPoolRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryFundersServer).FundingsByPool(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/kyve.query.v1beta1.QueryFunders/FundingsByPool", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryFundersServer).FundingsByPool(ctx, req.(*QueryFundingsByPoolRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _QueryFunders_serviceDesc = grpc.ServiceDesc{ + ServiceName: "kyve.query.v1beta1.QueryFunders", + HandlerType: (*QueryFundersServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Funders", + Handler: _QueryFunders_Funders_Handler, + }, + { + MethodName: "Funder", + Handler: _QueryFunders_Funder_Handler, + }, + { + MethodName: "FundingsByFunder", + Handler: _QueryFunders_FundingsByFunder_Handler, + }, + { + MethodName: "FundingsByPool", + Handler: _QueryFunders_FundingsByPool_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "kyve/query/v1beta1/funders.proto", +} + +func (m *Funder) 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 *Funder) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Funder) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Stats != nil { + { + size, err := m.Stats.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintFunders(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x3a + } + if len(m.Description) > 0 { + i -= len(m.Description) + copy(dAtA[i:], m.Description) + i = encodeVarintFunders(dAtA, i, uint64(len(m.Description))) + i-- + dAtA[i] = 0x32 + } + if len(m.Contact) > 0 { + i -= len(m.Contact) + copy(dAtA[i:], m.Contact) + i = encodeVarintFunders(dAtA, i, uint64(len(m.Contact))) + i-- + dAtA[i] = 0x2a + } + if len(m.Website) > 0 { + i -= len(m.Website) + copy(dAtA[i:], m.Website) + i = encodeVarintFunders(dAtA, i, uint64(len(m.Website))) + i-- + dAtA[i] = 0x22 + } + if len(m.Identity) > 0 { + i -= len(m.Identity) + copy(dAtA[i:], m.Identity) + i = encodeVarintFunders(dAtA, i, uint64(len(m.Identity))) + i-- + dAtA[i] = 0x1a + } + if len(m.Moniker) > 0 { + i -= len(m.Moniker) + copy(dAtA[i:], m.Moniker) + i = encodeVarintFunders(dAtA, i, uint64(len(m.Moniker))) + i-- + dAtA[i] = 0x12 + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintFunders(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *FundingStats) 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 *FundingStats) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *FundingStats) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.PoolsFunded) > 0 { + dAtA3 := make([]byte, len(m.PoolsFunded)*10) + var j2 int + for _, num := range m.PoolsFunded { + for num >= 1<<7 { + dAtA3[j2] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j2++ + } + dAtA3[j2] = uint8(num) + j2++ + } + i -= j2 + copy(dAtA[i:], dAtA3[:j2]) + i = encodeVarintFunders(dAtA, i, uint64(j2)) + i-- + dAtA[i] = 0x22 + } + if m.TotalAmountPerBundle != 0 { + i = encodeVarintFunders(dAtA, i, uint64(m.TotalAmountPerBundle)) + i-- + dAtA[i] = 0x18 + } + if m.TotalAllocatedFunds != 0 { + i = encodeVarintFunders(dAtA, i, uint64(m.TotalAllocatedFunds)) + i-- + dAtA[i] = 0x10 + } + if m.TotalUsedFunds != 0 { + i = encodeVarintFunders(dAtA, i, uint64(m.TotalUsedFunds)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *Funding) 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 *Funding) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Funding) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.TotalFunded != 0 { + i = encodeVarintFunders(dAtA, i, uint64(m.TotalFunded)) + i-- + dAtA[i] = 0x28 + } + if m.AmountPerBundle != 0 { + i = encodeVarintFunders(dAtA, i, uint64(m.AmountPerBundle)) + i-- + dAtA[i] = 0x20 + } + if m.Amount != 0 { + i = encodeVarintFunders(dAtA, i, uint64(m.Amount)) + i-- + dAtA[i] = 0x18 + } + if m.PoolId != 0 { + i = encodeVarintFunders(dAtA, i, uint64(m.PoolId)) + i-- + dAtA[i] = 0x10 + } + if len(m.FunderAddress) > 0 { + i -= len(m.FunderAddress) + copy(dAtA[i:], m.FunderAddress) + i = encodeVarintFunders(dAtA, i, uint64(len(m.FunderAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryFundersRequest) 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 *QueryFundersRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryFundersRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Search) > 0 { + i -= len(m.Search) + copy(dAtA[i:], m.Search) + i = encodeVarintFunders(dAtA, i, uint64(len(m.Search))) + i-- + dAtA[i] = 0x12 + } + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintFunders(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryFundersResponse) 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 *QueryFundersResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryFundersResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Funders) > 0 { + for iNdEx := len(m.Funders) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Funders[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintFunders(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintFunders(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryFunderRequest) 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 *QueryFunderRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryFunderRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Status != 0 { + i = encodeVarintFunders(dAtA, i, uint64(m.Status)) + i-- + dAtA[i] = 0x18 + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintFunders(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryFunderResponse) 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 *QueryFunderResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryFunderResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Fundings) > 0 { + for iNdEx := len(m.Fundings) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Fundings[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintFunders(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if m.Funder != nil { + { + size, err := m.Funder.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintFunders(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryFundingsByFunderRequest) 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 *QueryFundingsByFunderRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryFundingsByFunderRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Status != 0 { + i = encodeVarintFunders(dAtA, i, uint64(m.Status)) + i-- + dAtA[i] = 0x18 + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintFunders(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0x12 + } + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintFunders(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryFundingsByFunderResponse) 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 *QueryFundingsByFunderResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryFundingsByFunderResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Fundings) > 0 { + for iNdEx := len(m.Fundings) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Fundings[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintFunders(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintFunders(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryFundingsByPoolRequest) 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 *QueryFundingsByPoolRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryFundingsByPoolRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Status != 0 { + i = encodeVarintFunders(dAtA, i, uint64(m.Status)) + i-- + dAtA[i] = 0x18 + } + if m.PoolId != 0 { + i = encodeVarintFunders(dAtA, i, uint64(m.PoolId)) + i-- + dAtA[i] = 0x10 + } + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintFunders(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryFundingsByPoolResponse) 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 *QueryFundingsByPoolResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryFundingsByPoolResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Fundings) > 0 { + for iNdEx := len(m.Fundings) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Fundings[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintFunders(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintFunders(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintFunders(dAtA []byte, offset int, v uint64) int { + offset -= sovFunders(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Funder) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovFunders(uint64(l)) + } + l = len(m.Moniker) + if l > 0 { + n += 1 + l + sovFunders(uint64(l)) + } + l = len(m.Identity) + if l > 0 { + n += 1 + l + sovFunders(uint64(l)) + } + l = len(m.Website) + if l > 0 { + n += 1 + l + sovFunders(uint64(l)) + } + l = len(m.Contact) + if l > 0 { + n += 1 + l + sovFunders(uint64(l)) + } + l = len(m.Description) + if l > 0 { + n += 1 + l + sovFunders(uint64(l)) + } + if m.Stats != nil { + l = m.Stats.Size() + n += 1 + l + sovFunders(uint64(l)) + } + return n +} + +func (m *FundingStats) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.TotalUsedFunds != 0 { + n += 1 + sovFunders(uint64(m.TotalUsedFunds)) + } + if m.TotalAllocatedFunds != 0 { + n += 1 + sovFunders(uint64(m.TotalAllocatedFunds)) + } + if m.TotalAmountPerBundle != 0 { + n += 1 + sovFunders(uint64(m.TotalAmountPerBundle)) + } + if len(m.PoolsFunded) > 0 { + l = 0 + for _, e := range m.PoolsFunded { + l += sovFunders(uint64(e)) + } + n += 1 + sovFunders(uint64(l)) + l + } + return n +} + +func (m *Funding) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.FunderAddress) + if l > 0 { + n += 1 + l + sovFunders(uint64(l)) + } + if m.PoolId != 0 { + n += 1 + sovFunders(uint64(m.PoolId)) + } + if m.Amount != 0 { + n += 1 + sovFunders(uint64(m.Amount)) + } + if m.AmountPerBundle != 0 { + n += 1 + sovFunders(uint64(m.AmountPerBundle)) + } + if m.TotalFunded != 0 { + n += 1 + sovFunders(uint64(m.TotalFunded)) + } + return n +} + +func (m *QueryFundersRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovFunders(uint64(l)) + } + l = len(m.Search) + if l > 0 { + n += 1 + l + sovFunders(uint64(l)) + } + return n +} + +func (m *QueryFundersResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovFunders(uint64(l)) + } + if len(m.Funders) > 0 { + for _, e := range m.Funders { + l = e.Size() + n += 1 + l + sovFunders(uint64(l)) + } + } + return n +} + +func (m *QueryFunderRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovFunders(uint64(l)) + } + if m.Status != 0 { + n += 1 + sovFunders(uint64(m.Status)) + } + return n +} + +func (m *QueryFunderResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Funder != nil { + l = m.Funder.Size() + n += 1 + l + sovFunders(uint64(l)) + } + if len(m.Fundings) > 0 { + for _, e := range m.Fundings { + l = e.Size() + n += 1 + l + sovFunders(uint64(l)) + } + } + return n +} + +func (m *QueryFundingsByFunderRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovFunders(uint64(l)) + } + l = len(m.Address) + if l > 0 { + n += 1 + l + sovFunders(uint64(l)) + } + if m.Status != 0 { + n += 1 + sovFunders(uint64(m.Status)) + } + return n +} + +func (m *QueryFundingsByFunderResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovFunders(uint64(l)) + } + if len(m.Fundings) > 0 { + for _, e := range m.Fundings { + l = e.Size() + n += 1 + l + sovFunders(uint64(l)) + } + } + return n +} + +func (m *QueryFundingsByPoolRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovFunders(uint64(l)) + } + if m.PoolId != 0 { + n += 1 + sovFunders(uint64(m.PoolId)) + } + if m.Status != 0 { + n += 1 + sovFunders(uint64(m.Status)) + } + return n +} + +func (m *QueryFundingsByPoolResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovFunders(uint64(l)) + } + if len(m.Fundings) > 0 { + for _, e := range m.Fundings { + l = e.Size() + n += 1 + l + sovFunders(uint64(l)) + } + } + return n +} + +func sovFunders(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozFunders(x uint64) (n int) { + return sovFunders(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Funder) 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 ErrIntOverflowFunders + } + 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: Funder: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Funder: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFunders + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthFunders + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthFunders + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Moniker", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFunders + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthFunders + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthFunders + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Moniker = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Identity", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFunders + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthFunders + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthFunders + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Identity = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Website", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFunders + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthFunders + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthFunders + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Website = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Contact", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFunders + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthFunders + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthFunders + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Contact = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFunders + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthFunders + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthFunders + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Description = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Stats", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFunders + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthFunders + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthFunders + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Stats == nil { + m.Stats = &FundingStats{} + } + if err := m.Stats.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipFunders(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthFunders + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *FundingStats) 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 ErrIntOverflowFunders + } + 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: FundingStats: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: FundingStats: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field TotalUsedFunds", wireType) + } + m.TotalUsedFunds = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFunders + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.TotalUsedFunds |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field TotalAllocatedFunds", wireType) + } + m.TotalAllocatedFunds = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFunders + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.TotalAllocatedFunds |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field TotalAmountPerBundle", wireType) + } + m.TotalAmountPerBundle = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFunders + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.TotalAmountPerBundle |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType == 0 { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFunders + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.PoolsFunded = append(m.PoolsFunded, v) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFunders + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return ErrInvalidLengthFunders + } + postIndex := iNdEx + packedLen + if postIndex < 0 { + return ErrInvalidLengthFunders + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var elementCount int + var count int + for _, integer := range dAtA[iNdEx:postIndex] { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.PoolsFunded) == 0 { + m.PoolsFunded = make([]uint64, 0, elementCount) + } + for iNdEx < postIndex { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFunders + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.PoolsFunded = append(m.PoolsFunded, v) + } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field PoolsFunded", wireType) + } + default: + iNdEx = preIndex + skippy, err := skipFunders(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthFunders + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Funding) 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 ErrIntOverflowFunders + } + 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: Funding: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Funding: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FunderAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFunders + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthFunders + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthFunders + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.FunderAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PoolId", wireType) + } + m.PoolId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFunders + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PoolId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + m.Amount = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFunders + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Amount |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field AmountPerBundle", wireType) + } + m.AmountPerBundle = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFunders + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.AmountPerBundle |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field TotalFunded", wireType) + } + m.TotalFunded = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFunders + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.TotalFunded |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipFunders(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthFunders + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryFundersRequest) 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 ErrIntOverflowFunders + } + 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: QueryFundersRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryFundersRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFunders + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthFunders + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthFunders + } + 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 + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Search", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFunders + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthFunders + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthFunders + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Search = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipFunders(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthFunders + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryFundersResponse) 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 ErrIntOverflowFunders + } + 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: QueryFundersResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryFundersResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFunders + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthFunders + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthFunders + } + 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 + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Funders", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFunders + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthFunders + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthFunders + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Funders = append(m.Funders, Funder{}) + if err := m.Funders[len(m.Funders)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipFunders(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthFunders + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryFunderRequest) 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 ErrIntOverflowFunders + } + 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: QueryFunderRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryFunderRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFunders + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthFunders + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthFunders + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) + } + m.Status = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFunders + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Status |= FundingStatus(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipFunders(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthFunders + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryFunderResponse) 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 ErrIntOverflowFunders + } + 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: QueryFunderResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryFunderResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Funder", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFunders + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthFunders + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthFunders + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Funder == nil { + m.Funder = &Funder{} + } + if err := m.Funder.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Fundings", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFunders + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthFunders + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthFunders + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Fundings = append(m.Fundings, Funding{}) + if err := m.Fundings[len(m.Fundings)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipFunders(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthFunders + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryFundingsByFunderRequest) 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 ErrIntOverflowFunders + } + 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: QueryFundingsByFunderRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryFundingsByFunderRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFunders + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthFunders + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthFunders + } + 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 + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFunders + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthFunders + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthFunders + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) + } + m.Status = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFunders + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Status |= FundingStatus(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipFunders(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthFunders + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryFundingsByFunderResponse) 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 ErrIntOverflowFunders + } + 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: QueryFundingsByFunderResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryFundingsByFunderResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFunders + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthFunders + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthFunders + } + 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 + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Fundings", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFunders + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthFunders + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthFunders + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Fundings = append(m.Fundings, Funding{}) + if err := m.Fundings[len(m.Fundings)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipFunders(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthFunders + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryFundingsByPoolRequest) 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 ErrIntOverflowFunders + } + 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: QueryFundingsByPoolRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryFundingsByPoolRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFunders + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthFunders + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthFunders + } + 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 + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PoolId", wireType) + } + m.PoolId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFunders + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PoolId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) + } + m.Status = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFunders + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Status |= FundingStatus(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipFunders(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthFunders + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryFundingsByPoolResponse) 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 ErrIntOverflowFunders + } + 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: QueryFundingsByPoolResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryFundingsByPoolResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFunders + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthFunders + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthFunders + } + 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 + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Fundings", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFunders + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthFunders + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthFunders + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Fundings = append(m.Fundings, Funding{}) + if err := m.Fundings[len(m.Fundings)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipFunders(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthFunders + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipFunders(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, ErrIntOverflowFunders + } + 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, ErrIntOverflowFunders + } + 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, ErrIntOverflowFunders + } + 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, ErrInvalidLengthFunders + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupFunders + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthFunders + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthFunders = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowFunders = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupFunders = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/query/types/funders.pb.gw.go b/x/query/types/funders.pb.gw.go new file mode 100644 index 00000000..b9d4697e --- /dev/null +++ b/x/query/types/funders.pb.gw.go @@ -0,0 +1,528 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: kyve/query/v1beta1/funders.proto + +/* +Package types is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package types + +import ( + "context" + "io" + "net/http" + + "github.com/golang/protobuf/descriptor" + "github.com/golang/protobuf/proto" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/grpc-ecosystem/grpc-gateway/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" +) + +// Suppress "imported and not used" errors +var _ codes.Code +var _ io.Reader +var _ status.Status +var _ = runtime.String +var _ = utilities.NewDoubleArray +var _ = descriptor.ForMessage +var _ = metadata.Join + +var ( + filter_QueryFunders_Funders_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_QueryFunders_Funders_0(ctx context.Context, marshaler runtime.Marshaler, client QueryFundersClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryFundersRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_QueryFunders_Funders_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.Funders(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_QueryFunders_Funders_0(ctx context.Context, marshaler runtime.Marshaler, server QueryFundersServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryFundersRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_QueryFunders_Funders_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.Funders(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_QueryFunders_Funder_0 = &utilities.DoubleArray{Encoding: map[string]int{"address": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} +) + +func request_QueryFunders_Funder_0(ctx context.Context, marshaler runtime.Marshaler, client QueryFundersClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryFunderRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["address"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "address") + } + + protoReq.Address, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "address", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_QueryFunders_Funder_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.Funder(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_QueryFunders_Funder_0(ctx context.Context, marshaler runtime.Marshaler, server QueryFundersServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryFunderRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["address"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "address") + } + + protoReq.Address, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "address", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_QueryFunders_Funder_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.Funder(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_QueryFunders_FundingsByFunder_0 = &utilities.DoubleArray{Encoding: map[string]int{"address": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} +) + +func request_QueryFunders_FundingsByFunder_0(ctx context.Context, marshaler runtime.Marshaler, client QueryFundersClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryFundingsByFunderRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["address"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "address") + } + + protoReq.Address, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "address", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_QueryFunders_FundingsByFunder_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.FundingsByFunder(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_QueryFunders_FundingsByFunder_0(ctx context.Context, marshaler runtime.Marshaler, server QueryFundersServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryFundingsByFunderRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["address"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "address") + } + + protoReq.Address, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "address", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_QueryFunders_FundingsByFunder_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.FundingsByFunder(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_QueryFunders_FundingsByPool_0 = &utilities.DoubleArray{Encoding: map[string]int{"pool_id": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} +) + +func request_QueryFunders_FundingsByPool_0(ctx context.Context, marshaler runtime.Marshaler, client QueryFundersClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryFundingsByPoolRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["pool_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "pool_id") + } + + protoReq.PoolId, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "pool_id", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_QueryFunders_FundingsByPool_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.FundingsByPool(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_QueryFunders_FundingsByPool_0(ctx context.Context, marshaler runtime.Marshaler, server QueryFundersServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryFundingsByPoolRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["pool_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "pool_id") + } + + protoReq.PoolId, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "pool_id", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_QueryFunders_FundingsByPool_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.FundingsByPool(ctx, &protoReq) + return msg, metadata, err + +} + +// RegisterQueryFundersHandlerServer registers the http handlers for service QueryFunders to "mux". +// UnaryRPC :call QueryFundersServer 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 RegisterQueryFundersHandlerFromEndpoint instead. +func RegisterQueryFundersHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryFundersServer) error { + + mux.Handle("GET", pattern_QueryFunders_Funders_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_QueryFunders_Funders_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_QueryFunders_Funders_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_QueryFunders_Funder_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_QueryFunders_Funder_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_QueryFunders_Funder_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_QueryFunders_FundingsByFunder_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_QueryFunders_FundingsByFunder_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_QueryFunders_FundingsByFunder_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_QueryFunders_FundingsByPool_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_QueryFunders_FundingsByPool_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_QueryFunders_FundingsByPool_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +// RegisterQueryFundersHandlerFromEndpoint is same as RegisterQueryFundersHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterQueryFundersHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.Dial(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterQueryFundersHandler(ctx, mux, conn) +} + +// RegisterQueryFundersHandler registers the http handlers for service QueryFunders to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterQueryFundersHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterQueryFundersHandlerClient(ctx, mux, NewQueryFundersClient(conn)) +} + +// RegisterQueryFundersHandlerClient registers the http handlers for service QueryFunders +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryFundersClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryFundersClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "QueryFundersClient" to call the correct interceptors. +func RegisterQueryFundersHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryFundersClient) error { + + mux.Handle("GET", pattern_QueryFunders_Funders_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_QueryFunders_Funders_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_QueryFunders_Funders_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_QueryFunders_Funder_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_QueryFunders_Funder_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_QueryFunders_Funder_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_QueryFunders_FundingsByFunder_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_QueryFunders_FundingsByFunder_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_QueryFunders_FundingsByFunder_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_QueryFunders_FundingsByPool_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_QueryFunders_FundingsByPool_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_QueryFunders_FundingsByPool_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_QueryFunders_Funders_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"kyve", "query", "v1beta1", "funders"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_QueryFunders_Funder_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"kyve", "query", "v1beta1", "funder", "address"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_QueryFunders_FundingsByFunder_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"kyve", "query", "v1beta1", "fundings_by_funder", "address"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_QueryFunders_FundingsByPool_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"kyve", "query", "v1beta1", "fundings_by_pool", "pool_id"}, "", runtime.AssumeColonVerbOpt(true))) +) + +var ( + forward_QueryFunders_Funders_0 = runtime.ForwardResponseMessage + + forward_QueryFunders_Funder_0 = runtime.ForwardResponseMessage + + forward_QueryFunders_FundingsByFunder_0 = runtime.ForwardResponseMessage + + forward_QueryFunders_FundingsByPool_0 = runtime.ForwardResponseMessage +) diff --git a/x/query/types/params.pb.go b/x/query/types/params.pb.go index 43458762..2760847e 100644 --- a/x/query/types/params.pb.go +++ b/x/query/types/params.pb.go @@ -8,6 +8,7 @@ import ( fmt "fmt" types "github.com/KYVENetwork/chain/x/bundles/types" types1 "github.com/KYVENetwork/chain/x/delegation/types" + types5 "github.com/KYVENetwork/chain/x/funders/types" types2 "github.com/KYVENetwork/chain/x/global/types" types4 "github.com/KYVENetwork/chain/x/pool/types" types3 "github.com/KYVENetwork/chain/x/stakers/types" @@ -85,6 +86,8 @@ type QueryParamsResponse struct { StakersParams *types3.Params `protobuf:"bytes,5,opt,name=stakers_params,json=stakersParams,proto3" json:"stakers_params,omitempty"` // pool_params ... PoolParams *types4.Params `protobuf:"bytes,6,opt,name=pool_params,json=poolParams,proto3" json:"pool_params,omitempty"` + // funders_params ... + FundersParams *types5.Params `protobuf:"bytes,7,opt,name=funders_params,json=fundersParams,proto3" json:"funders_params,omitempty"` } func (m *QueryParamsResponse) Reset() { *m = QueryParamsResponse{} } @@ -162,6 +165,13 @@ func (m *QueryParamsResponse) GetPoolParams() *types4.Params { return nil } +func (m *QueryParamsResponse) GetFundersParams() *types5.Params { + if m != nil { + return m.FundersParams + } + return nil +} + func init() { proto.RegisterType((*QueryParamsRequest)(nil), "kyve.query.v1beta1.QueryParamsRequest") proto.RegisterType((*QueryParamsResponse)(nil), "kyve.query.v1beta1.QueryParamsResponse") @@ -170,36 +180,37 @@ func init() { func init() { proto.RegisterFile("kyve/query/v1beta1/params.proto", fileDescriptor_b5269c0a69f1d3d4) } var fileDescriptor_b5269c0a69f1d3d4 = []byte{ - // 453 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x93, 0xb1, 0xae, 0xd3, 0x30, - 0x14, 0x86, 0x9b, 0x7b, 0xa1, 0x12, 0x2e, 0xb7, 0x82, 0x00, 0x02, 0x42, 0x95, 0x96, 0x08, 0x01, - 0x62, 0xb0, 0xd5, 0xc2, 0xc4, 0x84, 0x28, 0x4c, 0x20, 0x04, 0x0c, 0x48, 0xb0, 0x20, 0xa7, 0xb5, - 0xdc, 0xa8, 0x69, 0x4e, 0x1a, 0x3b, 0x81, 0x0e, 0x2c, 0xcc, 0x0c, 0x48, 0x3c, 0x01, 0x6f, 0xc3, - 0x58, 0x89, 0x85, 0x11, 0xb5, 0x3c, 0x08, 0x8a, 0x7d, 0xd2, 0x96, 0x36, 0xe8, 0x4e, 0x8d, 0xcf, - 0xf9, 0xff, 0xcf, 0xf6, 0x7f, 0x5c, 0xd2, 0x9d, 0x2e, 0x0a, 0xc1, 0xe6, 0xb9, 0xc8, 0x16, 0xac, - 0xe8, 0x87, 0x42, 0xf3, 0x3e, 0x4b, 0x79, 0xc6, 0x67, 0x8a, 0xa6, 0x19, 0x68, 0x70, 0xdd, 0x52, - 0x40, 0x8d, 0x80, 0xa2, 0xc0, 0xbb, 0x3a, 0x02, 0x35, 0x03, 0xc5, 0x24, 0x14, 0xac, 0xe8, 0x97, - 0x3f, 0x56, 0xec, 0x75, 0x24, 0x80, 0x8c, 0x05, 0xe3, 0x69, 0xc4, 0x78, 0x92, 0x80, 0xe6, 0x3a, - 0x82, 0x04, 0x51, 0xde, 0x4d, 0xb3, 0x57, 0x98, 0x27, 0xe3, 0x58, 0xa8, 0xda, 0xdd, 0xbc, 0x5b, - 0x46, 0x32, 0x16, 0xb1, 0x90, 0xc6, 0x5a, 0xaf, 0xea, 0x19, 0x95, 0x8c, 0x21, 0xe4, 0xf1, 0x46, - 0x61, 0x97, 0xa8, 0xf0, 0x8d, 0x22, 0x05, 0x88, 0xeb, 0x09, 0xf6, 0x28, 0x4a, 0xf3, 0xa9, 0xc8, - 0xea, 0x8f, 0x12, 0x5c, 0x26, 0xee, 0xab, 0xf2, 0xd6, 0x2f, 0x4d, 0xf1, 0xb5, 0x98, 0xe7, 0x42, - 0xe9, 0xe0, 0xfb, 0x31, 0xb9, 0xf4, 0x4f, 0x59, 0xa5, 0x90, 0x28, 0xe1, 0x0e, 0x49, 0x1b, 0x2f, - 0xf6, 0xde, 0x52, 0xae, 0x39, 0x3d, 0xe7, 0x6e, 0x6b, 0xd0, 0xa1, 0x26, 0x3f, 0xec, 0x55, 0x09, - 0x52, 0x74, 0x9f, 0x60, 0xdd, 0x2e, 0xdd, 0xe7, 0xe4, 0xe2, 0xf6, 0xea, 0x15, 0xe7, 0xc8, 0x70, - 0xba, 0x96, 0xb3, 0x6d, 0xef, 0xa3, 0x2e, 0x6c, 0x5b, 0x48, 0x7b, 0x44, 0x4e, 0x6c, 0x26, 0x15, - 0xe9, 0xd8, 0x90, 0x6e, 0x58, 0x12, 0xc6, 0xb5, 0x47, 0x39, 0x6f, 0xcb, 0x48, 0x78, 0x40, 0x88, - 0x84, 0xa2, 0xb2, 0x9f, 0x31, 0xf6, 0x2b, 0xd4, 0x0e, 0x9f, 0x96, 0x53, 0x2f, 0x36, 0xc6, 0x73, - 0x12, 0x0a, 0x74, 0x0d, 0x49, 0x1b, 0x83, 0xad, 0x9c, 0x67, 0x77, 0xa3, 0xc0, 0xde, 0x41, 0x14, - 0x58, 0x47, 0xc8, 0x43, 0xd2, 0x2a, 0xa7, 0x57, 0x11, 0x9a, 0x86, 0x70, 0xdd, 0x12, 0xca, 0xc6, - 0xbe, 0x9d, 0x94, 0x45, 0xfb, 0x3d, 0xf8, 0xe2, 0x90, 0xd6, 0xce, 0x8c, 0xdc, 0x4f, 0xa4, 0x89, - 0x5f, 0xb7, 0xe9, 0xe1, 0x6b, 0xa6, 0x87, 0x53, 0xf6, 0xee, 0x9c, 0xaa, 0xb3, 0x63, 0x0f, 0x82, - 0xcf, 0x3f, 0xff, 0x7c, 0x3b, 0xea, 0xb8, 0x1e, 0xfb, 0xef, 0xff, 0xe8, 0xf1, 0x93, 0x1f, 0x2b, - 0xdf, 0x59, 0xae, 0x7c, 0xe7, 0xf7, 0xca, 0x77, 0xbe, 0xae, 0xfd, 0xc6, 0x72, 0xed, 0x37, 0x7e, - 0xad, 0xfd, 0xc6, 0xbb, 0x7b, 0x32, 0xd2, 0x93, 0x3c, 0xa4, 0x23, 0x98, 0xb1, 0x67, 0x6f, 0xdf, - 0x3c, 0x7d, 0x21, 0xf4, 0x07, 0xc8, 0xa6, 0x6c, 0x34, 0xe1, 0x51, 0xc2, 0x3e, 0x22, 0x4e, 0x2f, - 0x52, 0xa1, 0xc2, 0xa6, 0x79, 0x95, 0xf7, 0xff, 0x06, 0x00, 0x00, 0xff, 0xff, 0x81, 0x22, 0x17, - 0x0f, 0xb1, 0x03, 0x00, 0x00, + // 473 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x93, 0xb1, 0x8f, 0xd3, 0x30, + 0x14, 0xc6, 0x9b, 0x3b, 0x28, 0xc2, 0xe5, 0x4e, 0x10, 0x40, 0x40, 0xa8, 0x72, 0x47, 0x84, 0x00, + 0x31, 0xd8, 0xea, 0xc1, 0xc4, 0x84, 0x38, 0x98, 0x40, 0x08, 0x18, 0x90, 0x60, 0x41, 0x4e, 0x6b, + 0xdc, 0xa8, 0x69, 0x5e, 0x1a, 0x3b, 0x81, 0x0e, 0x2c, 0xcc, 0x0c, 0x48, 0xfc, 0x53, 0x8c, 0x95, + 0x58, 0x18, 0x51, 0x8b, 0xf8, 0x3b, 0x50, 0xec, 0x97, 0xa6, 0x34, 0x2d, 0x37, 0xb5, 0x7e, 0xef, + 0xfb, 0x7e, 0xcf, 0xf9, 0xf2, 0x42, 0x0e, 0x46, 0xd3, 0x42, 0xb0, 0x49, 0x2e, 0xb2, 0x29, 0x2b, + 0x7a, 0xa1, 0xd0, 0xbc, 0xc7, 0x52, 0x9e, 0xf1, 0xb1, 0xa2, 0x69, 0x06, 0x1a, 0x5c, 0xb7, 0x14, + 0x50, 0x23, 0xa0, 0x28, 0xf0, 0xae, 0xf4, 0x41, 0x8d, 0x41, 0x31, 0x09, 0x05, 0x2b, 0x7a, 0xe5, + 0x8f, 0x15, 0x7b, 0x5d, 0x09, 0x20, 0x63, 0xc1, 0x78, 0x1a, 0x31, 0x9e, 0x24, 0xa0, 0xb9, 0x8e, + 0x20, 0x41, 0x94, 0x77, 0xc3, 0xcc, 0x0a, 0xf3, 0x64, 0x10, 0x0b, 0xb5, 0x71, 0x9a, 0x77, 0xd3, + 0x48, 0x06, 0x22, 0x16, 0xd2, 0x58, 0x37, 0xab, 0x2c, 0xe8, 0x7d, 0x9e, 0x0c, 0x44, 0xb6, 0x05, + 0x74, 0x68, 0x24, 0x32, 0x86, 0x90, 0xc7, 0x4b, 0x85, 0x3d, 0xa2, 0xc2, 0x37, 0x8a, 0x14, 0x20, + 0xfe, 0xdf, 0x10, 0xa5, 0xf9, 0x68, 0xdb, 0x90, 0xe0, 0x12, 0x71, 0x5f, 0x96, 0xc1, 0xbc, 0x30, + 0xc5, 0x57, 0x62, 0x92, 0x0b, 0xa5, 0x83, 0x3f, 0xbb, 0xe4, 0xe2, 0x3f, 0x65, 0x95, 0x42, 0xa2, + 0x84, 0x7b, 0x4c, 0xf6, 0xf1, 0xd9, 0xdf, 0x59, 0xca, 0x55, 0xe7, 0xd0, 0xb9, 0xd3, 0x39, 0xea, + 0x52, 0x13, 0x31, 0xf6, 0xaa, 0x90, 0x29, 0xba, 0xf7, 0xb0, 0x6e, 0x8f, 0xee, 0x33, 0x72, 0xa1, + 0x4e, 0xa7, 0xe2, 0xec, 0x18, 0xce, 0x81, 0xe5, 0xd4, 0xed, 0x75, 0xd4, 0xf9, 0xba, 0x85, 0xb4, + 0x87, 0x64, 0xcf, 0x66, 0x52, 0x91, 0x76, 0x0d, 0xe9, 0xba, 0x25, 0x61, 0x5c, 0x6b, 0x94, 0x73, + 0xb6, 0x8c, 0x84, 0xfb, 0x84, 0x48, 0x28, 0x2a, 0xfb, 0x29, 0x63, 0xbf, 0x4c, 0xed, 0x7e, 0xd0, + 0x72, 0x31, 0x8a, 0xa5, 0xf1, 0xac, 0x84, 0x02, 0x5d, 0xc7, 0x64, 0x1f, 0x83, 0xad, 0x9c, 0xa7, + 0x57, 0xa3, 0xc0, 0x5e, 0x23, 0x0a, 0xac, 0x23, 0xe4, 0x01, 0xe9, 0x94, 0x6f, 0xaf, 0x22, 0xb4, + 0x0d, 0xe1, 0x9a, 0x25, 0x94, 0x8d, 0x75, 0x3b, 0x29, 0x8b, 0xf5, 0x05, 0x70, 0x7d, 0x2a, 0xfb, + 0x99, 0xd5, 0x0b, 0x60, 0xaf, 0x71, 0x01, 0xac, 0xdb, 0xe3, 0xd1, 0x17, 0x87, 0x74, 0x56, 0x5e, + 0xb4, 0xfb, 0x89, 0xb4, 0xf1, 0xdf, 0x2d, 0xda, 0xfc, 0x6a, 0x68, 0x73, 0x55, 0xbc, 0xdb, 0x27, + 0xea, 0xec, 0xee, 0x04, 0xc1, 0xe7, 0x1f, 0xbf, 0xbf, 0xed, 0x74, 0x5d, 0x8f, 0x6d, 0xfd, 0x5e, + 0x1f, 0x3d, 0xfe, 0x3e, 0xf7, 0x9d, 0xd9, 0xdc, 0x77, 0x7e, 0xcd, 0x7d, 0xe7, 0xeb, 0xc2, 0x6f, + 0xcd, 0x16, 0x7e, 0xeb, 0xe7, 0xc2, 0x6f, 0xbd, 0xbd, 0x2b, 0x23, 0x3d, 0xcc, 0x43, 0xda, 0x87, + 0x31, 0x7b, 0xfa, 0xe6, 0xf5, 0x93, 0xe7, 0x42, 0x7f, 0x80, 0x6c, 0xc4, 0xfa, 0x43, 0x1e, 0x25, + 0xec, 0x23, 0xe2, 0xf4, 0x34, 0x15, 0x2a, 0x6c, 0x9b, 0xd5, 0xbe, 0xf7, 0x37, 0x00, 0x00, 0xff, + 0xff, 0xcf, 0xec, 0x60, 0xa4, 0x19, 0x04, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -327,6 +338,18 @@ func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.FundersParams != nil { + { + size, err := m.FundersParams.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x3a + } if m.PoolParams != nil { { size, err := m.PoolParams.MarshalToSizedBuffer(dAtA[:i]) @@ -452,6 +475,10 @@ func (m *QueryParamsResponse) Size() (n int) { l = m.PoolParams.Size() n += 1 + l + sovParams(uint64(l)) } + if m.FundersParams != nil { + l = m.FundersParams.Size() + n += 1 + l + sovParams(uint64(l)) + } return n } @@ -756,6 +783,42 @@ func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FundersParams", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.FundersParams == nil { + m.FundersParams = &types5.Params{} + } + if err := m.FundersParams.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipParams(dAtA[iNdEx:]) diff --git a/x/query/types/query.pb.go b/x/query/types/query.pb.go index 24b741e6..1ebb132a 100644 --- a/x/query/types/query.pb.go +++ b/x/query/types/query.pb.go @@ -37,8 +37,8 @@ type BasicPool struct { Runtime string `protobuf:"bytes,3,opt,name=runtime,proto3" json:"runtime,omitempty"` // logo of the pool Logo string `protobuf:"bytes,4,opt,name=logo,proto3" json:"logo,omitempty"` - // operating_cost is the base payout for each bundle reward - OperatingCost uint64 `protobuf:"varint,5,opt,name=operating_cost,json=operatingCost,proto3" json:"operating_cost,omitempty"` + // inflation_share_weight is the base payout for each bundle reward + InflationShareWeight uint64 `protobuf:"varint,5,opt,name=inflation_share_weight,json=inflationShareWeight,proto3" json:"inflation_share_weight,omitempty"` // upload_interval is the interval bundles get created UploadInterval uint64 `protobuf:"varint,6,opt,name=upload_interval,json=uploadInterval,proto3" json:"upload_interval,omitempty"` // total_funds of the pool. If the pool runs @@ -112,9 +112,9 @@ func (m *BasicPool) GetLogo() string { return "" } -func (m *BasicPool) GetOperatingCost() uint64 { +func (m *BasicPool) GetInflationShareWeight() uint64 { if m != nil { - return m.OperatingCost + return m.InflationShareWeight } return 0 } @@ -520,56 +520,57 @@ func init() { func init() { proto.RegisterFile("kyve/query/v1beta1/query.proto", fileDescriptor_6b41255feae93a15) } var fileDescriptor_6b41255feae93a15 = []byte{ - // 782 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x94, 0x41, 0x8f, 0xe3, 0x34, - 0x14, 0xc7, 0x9b, 0xb6, 0xd3, 0x6d, 0x5f, 0xd9, 0x16, 0x2c, 0x60, 0xb3, 0x23, 0x36, 0x33, 0x2a, - 0x82, 0x9d, 0x45, 0xda, 0x54, 0x33, 0x08, 0x09, 0x71, 0xe0, 0x30, 0xed, 0xae, 0x84, 0x60, 0x57, - 0xc8, 0x08, 0x24, 0xb8, 0x44, 0x6e, 0xe2, 0x4d, 0xad, 0x26, 0x76, 0xb0, 0x9d, 0x0e, 0xfd, 0x0c, - 0x70, 0xe0, 0xa3, 0x70, 0xe0, 0x43, 0xec, 0x71, 0x8e, 0xc0, 0x61, 0x84, 0x66, 0xbe, 0x08, 0xb2, - 0x9d, 0x64, 0xda, 0xa1, 0xdc, 0x38, 0x25, 0xef, 0xff, 0xfe, 0x79, 0xb1, 0x7f, 0xef, 0xd9, 0x10, - 0xac, 0x36, 0x6b, 0x3a, 0xfd, 0xb1, 0xa4, 0x72, 0x33, 0x5d, 0x9f, 0x2e, 0xa8, 0x26, 0xa7, 0x2e, - 0x0a, 0x0b, 0x29, 0xb4, 0x40, 0xc8, 0xe4, 0x43, 0xa7, 0x54, 0xf9, 0xc3, 0xb7, 0x53, 0x91, 0x0a, - 0x9b, 0x9e, 0x9a, 0x37, 0xe7, 0x3c, 0x7c, 0xcf, 0x56, 0x2a, 0x84, 0xc8, 0x9a, 0x42, 0x26, 0x70, - 0xd9, 0xc9, 0x6f, 0x6d, 0x18, 0x9c, 0x13, 0xc5, 0xe2, 0xaf, 0x85, 0xc8, 0xd0, 0x08, 0xda, 0x2c, - 0xf1, 0xbd, 0x63, 0xef, 0xa4, 0x8b, 0xdb, 0x2c, 0x41, 0x08, 0xba, 0x9c, 0xe4, 0xd4, 0x6f, 0x1f, - 0x7b, 0x27, 0x03, 0x6c, 0xdf, 0x91, 0x0f, 0xf7, 0x64, 0xc9, 0x35, 0xcb, 0xa9, 0xdf, 0xb1, 0x72, - 0x1d, 0x1a, 0x77, 0x26, 0x52, 0xe1, 0x77, 0x9d, 0xdb, 0xbc, 0xa3, 0x0f, 0x60, 0x24, 0x0a, 0x2a, - 0x89, 0x66, 0x3c, 0x8d, 0x62, 0xa1, 0xb4, 0x7f, 0x60, 0xab, 0xdf, 0x6f, 0xd4, 0x99, 0x50, 0x1a, - 0x3d, 0x86, 0x71, 0x59, 0x64, 0x82, 0x24, 0x11, 0xe3, 0x9a, 0xca, 0x35, 0xc9, 0xfc, 0x9e, 0xf5, - 0x8d, 0x9c, 0xfc, 0x45, 0xa5, 0xa2, 0x23, 0x18, 0x6a, 0xa1, 0x49, 0x16, 0xbd, 0x2a, 0x79, 0xa2, - 0xfc, 0x7b, 0xd6, 0x04, 0x56, 0x7a, 0x6e, 0x14, 0xf4, 0x04, 0xde, 0x74, 0x86, 0x84, 0x66, 0x34, - 0x25, 0x9a, 0x09, 0xee, 0xf7, 0xad, 0x6b, 0x6c, 0xf5, 0x79, 0x23, 0xa3, 0x4f, 0xa0, 0xa7, 0x34, - 0xd1, 0xa5, 0xf2, 0x07, 0xc7, 0xde, 0xc9, 0xe8, 0xec, 0x51, 0x68, 0xa1, 0x5a, 0x3a, 0x15, 0xaa, - 0xd0, 0x60, 0xf9, 0xc6, 0x9a, 0x70, 0x65, 0x9e, 0xfc, 0xd9, 0x06, 0x78, 0x5e, 0x66, 0x46, 0x5e, - 0x51, 0x69, 0x78, 0x90, 0x24, 0x91, 0x54, 0x29, 0x0b, 0x6e, 0x80, 0xeb, 0x10, 0x7d, 0x0e, 0xfd, - 0x9c, 0x6a, 0x92, 0x10, 0x4d, 0x2c, 0xc1, 0xe1, 0xd9, 0x24, 0xfc, 0x77, 0xdb, 0x42, 0x57, 0xe7, - 0x45, 0xe5, 0xc4, 0xcd, 0x37, 0x06, 0x8a, 0xa2, 0xd9, 0xab, 0xed, 0x9d, 0x74, 0x1c, 0x14, 0x23, - 0x6f, 0x6d, 0xe4, 0x33, 0x78, 0x78, 0xc7, 0x18, 0x95, 0x7c, 0x21, 0x78, 0xc2, 0x78, 0x6a, 0xbb, - 0xd1, 0xc5, 0x0f, 0x76, 0x3f, 0xf9, 0xb6, 0x4e, 0xef, 0xe5, 0x75, 0xb0, 0x9f, 0xd7, 0x63, 0x18, - 0x57, 0x26, 0x21, 0xa3, 0x58, 0x94, 0x5c, 0xd7, 0x4d, 0x6a, 0xe4, 0x99, 0x51, 0xd1, 0xa7, 0x70, - 0x60, 0x20, 0x9a, 0xf6, 0x74, 0xfe, 0x6b, 0xd7, 0x06, 0xec, 0x0b, 0x9a, 0x2f, 0xa8, 0x54, 0x4b, - 0x56, 0x60, 0xf7, 0xc1, 0xe4, 0xe7, 0x0e, 0x8c, 0x76, 0x79, 0xa0, 0x97, 0x00, 0xb1, 0xc8, 0x73, - 0xa6, 0x94, 0x59, 0x9a, 0x45, 0x7c, 0x1e, 0xbe, 0xbe, 0x3a, 0x6a, 0xfd, 0x75, 0x75, 0xf4, 0x61, - 0xca, 0xf4, 0xb2, 0x5c, 0x84, 0xb1, 0xc8, 0xa7, 0xb1, 0x50, 0xb9, 0x50, 0xd5, 0xe3, 0xa9, 0x4a, - 0x56, 0x53, 0xbd, 0x29, 0xa8, 0x0a, 0xe7, 0x34, 0xc6, 0x5b, 0x15, 0x4c, 0xbf, 0x72, 0xc1, 0xd9, - 0x8a, 0xca, 0x6a, 0xac, 0xeb, 0xd0, 0x64, 0x2e, 0xe8, 0x42, 0x31, 0xdd, 0x4c, 0x76, 0x15, 0xa2, - 0x43, 0xe8, 0xb3, 0x84, 0x72, 0xcd, 0xf4, 0xa6, 0x9a, 0xee, 0x26, 0x36, 0x00, 0x15, 0x8d, 0x4b, - 0xc9, 0xf4, 0x26, 0x8a, 0x05, 0xd7, 0x24, 0x76, 0x33, 0x3e, 0xc0, 0xe3, 0x5a, 0x9f, 0x39, 0xd9, - 0xfc, 0x20, 0xa1, 0x9a, 0xb0, 0x4c, 0x59, 0x70, 0x03, 0x5c, 0x87, 0x88, 0xc2, 0xc3, 0x82, 0xda, - 0x86, 0x44, 0xb7, 0x4b, 0x8d, 0xe2, 0x25, 0xe1, 0x29, 0xb5, 0x43, 0x3e, 0x3c, 0x7b, 0xb2, 0x8f, - 0xe2, 0xac, 0x31, 0xcf, 0xac, 0xf7, 0x19, 0xd7, 0x72, 0x83, 0x1f, 0x54, 0xb5, 0xee, 0x66, 0xd1, - 0x53, 0x40, 0x5b, 0xe5, 0x25, 0xbd, 0x20, 0x32, 0x51, 0xd5, 0xf1, 0x78, 0xeb, 0x36, 0x83, 0x5d, - 0x62, 0xf2, 0x8b, 0x07, 0xef, 0xec, 0xfd, 0xc3, 0xff, 0xde, 0x94, 0xf7, 0xe1, 0x7e, 0x2c, 0xa9, - 0x1b, 0xdd, 0x84, 0x68, 0x77, 0xe3, 0x74, 0xf0, 0x1b, 0xb5, 0x38, 0x27, 0x9a, 0x4e, 0x7e, 0xf7, - 0x60, 0xb4, 0x3b, 0x36, 0xe8, 0x14, 0xba, 0x66, 0x70, 0xec, 0x0a, 0x86, 0xf5, 0x01, 0xde, 0x45, - 0xd4, 0xdc, 0x6e, 0xd8, 0x5a, 0xd1, 0xbb, 0xd0, 0x2b, 0x04, 0xe3, 0x5a, 0xd9, 0x7f, 0x74, 0x71, - 0x15, 0xa1, 0x47, 0x00, 0x4c, 0x45, 0x19, 0x25, 0x6b, 0x73, 0x6a, 0xcc, 0x00, 0xf4, 0xf1, 0x80, - 0xa9, 0xaf, 0x9c, 0x80, 0x02, 0x80, 0x35, 0xc9, 0xea, 0x93, 0xee, 0x86, 0x60, 0x4b, 0x31, 0xbd, - 0x5d, 0x90, 0x8c, 0xf0, 0x98, 0x56, 0xc7, 0xa7, 0x0e, 0xcf, 0xe7, 0xaf, 0xaf, 0x03, 0xef, 0xf2, - 0x3a, 0xf0, 0xfe, 0xbe, 0x0e, 0xbc, 0x5f, 0x6f, 0x82, 0xd6, 0xe5, 0x4d, 0xd0, 0xfa, 0xe3, 0x26, - 0x68, 0xfd, 0xf0, 0xd1, 0x16, 0xa9, 0x2f, 0xbf, 0xff, 0xee, 0xd9, 0x4b, 0xaa, 0x2f, 0x84, 0x5c, - 0x4d, 0xe3, 0x25, 0x61, 0x7c, 0xfa, 0x53, 0x75, 0xfd, 0x5b, 0x62, 0x8b, 0x9e, 0xbd, 0xaf, 0x3f, - 0xfe, 0x27, 0x00, 0x00, 0xff, 0xff, 0x50, 0x8f, 0x9d, 0x37, 0x19, 0x06, 0x00, 0x00, + // 790 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x55, 0x41, 0x6f, 0x1b, 0x45, + 0x14, 0xce, 0xda, 0x4e, 0x1a, 0xbf, 0x80, 0x03, 0xa3, 0xd2, 0x6e, 0x23, 0xba, 0x89, 0x8c, 0x44, + 0x53, 0xa4, 0xae, 0x95, 0x00, 0x12, 0xe2, 0xc0, 0x21, 0x49, 0x2b, 0x21, 0x68, 0x85, 0xa6, 0x02, + 0x04, 0x97, 0xd5, 0x78, 0xf7, 0x65, 0x3d, 0xf2, 0xee, 0x8c, 0x99, 0x99, 0xb5, 0xf1, 0x6f, 0x80, + 0x03, 0x3f, 0x86, 0x3b, 0xd7, 0x1e, 0x7b, 0x04, 0x0e, 0x15, 0x4a, 0xfe, 0x08, 0x9a, 0x99, 0xdd, + 0xad, 0x1d, 0xcc, 0xad, 0x27, 0xef, 0xfb, 0xbe, 0x6f, 0xde, 0xcc, 0x7c, 0xef, 0xbd, 0x31, 0x44, + 0xd3, 0xe5, 0x1c, 0x47, 0x3f, 0x55, 0xa8, 0x96, 0xa3, 0xf9, 0xc9, 0x18, 0x0d, 0x3b, 0xf1, 0x51, + 0x3c, 0x53, 0xd2, 0x48, 0x42, 0x2c, 0x1f, 0x7b, 0xa4, 0xe6, 0x0f, 0x6e, 0xe7, 0x32, 0x97, 0x8e, + 0x1e, 0xd9, 0x2f, 0xaf, 0x3c, 0x78, 0xdf, 0x65, 0x9a, 0x49, 0x59, 0xb4, 0x89, 0x6c, 0xe0, 0xd9, + 0xe1, 0x1f, 0x1d, 0xe8, 0x9f, 0x31, 0xcd, 0xd3, 0x6f, 0xa4, 0x2c, 0xc8, 0x00, 0x3a, 0x3c, 0x0b, + 0x83, 0xa3, 0xe0, 0xb8, 0x47, 0x3b, 0x3c, 0x23, 0x04, 0x7a, 0x82, 0x95, 0x18, 0x76, 0x8e, 0x82, + 0xe3, 0x3e, 0x75, 0xdf, 0x24, 0x84, 0x5b, 0xaa, 0x12, 0x86, 0x97, 0x18, 0x76, 0x1d, 0xdc, 0x84, + 0x56, 0x5d, 0xc8, 0x5c, 0x86, 0x3d, 0xaf, 0xb6, 0xdf, 0xe4, 0x13, 0xb8, 0xc3, 0xc5, 0x65, 0xc1, + 0x0c, 0x97, 0x22, 0xd1, 0x13, 0xa6, 0x30, 0x59, 0x20, 0xcf, 0x27, 0x26, 0xdc, 0x76, 0xbb, 0xdc, + 0x6e, 0xd9, 0xe7, 0x96, 0xfc, 0xde, 0x71, 0xe4, 0x01, 0xec, 0x57, 0xb3, 0x42, 0xb2, 0x2c, 0xe1, + 0xc2, 0xa0, 0x9a, 0xb3, 0x22, 0xdc, 0x71, 0xf2, 0x81, 0x87, 0xbf, 0xac, 0x51, 0x72, 0x08, 0x7b, + 0x46, 0x1a, 0x56, 0x24, 0x97, 0x95, 0xc8, 0x74, 0x78, 0xcb, 0x89, 0xc0, 0x41, 0x4f, 0x2c, 0x42, + 0x1e, 0xc2, 0x3b, 0x5e, 0x90, 0x61, 0x81, 0xb9, 0xdb, 0x28, 0xdc, 0x75, 0xaa, 0x7d, 0x87, 0x5f, + 0xb4, 0x30, 0xf9, 0x14, 0x76, 0xb4, 0x61, 0xa6, 0xd2, 0x61, 0xff, 0x28, 0x38, 0x1e, 0x9c, 0xde, + 0x8f, 0x9d, 0xc7, 0xce, 0xac, 0xda, 0xb9, 0xd8, 0xba, 0xf4, 0xdc, 0x89, 0x68, 0x2d, 0x1e, 0xfe, + 0xd5, 0x01, 0x78, 0x52, 0x15, 0x16, 0x9e, 0xa2, 0xb2, 0xf6, 0xb0, 0x2c, 0x53, 0xa8, 0xb5, 0xf3, + 0xb1, 0x4f, 0x9b, 0x90, 0x7c, 0x01, 0xbb, 0x25, 0x1a, 0x96, 0x31, 0xc3, 0x9c, 0xa1, 0x7b, 0xa7, + 0xc3, 0xf8, 0xbf, 0x55, 0x8c, 0x7d, 0x9e, 0xa7, 0xb5, 0x92, 0xb6, 0x6b, 0xac, 0x29, 0x1a, 0x8b, + 0xcb, 0xd5, 0x9b, 0x74, 0xbd, 0x29, 0x16, 0x5e, 0xb9, 0xc8, 0xe7, 0x70, 0xef, 0x86, 0x30, 0xa9, + 0xc4, 0x58, 0x8a, 0x8c, 0x8b, 0xdc, 0x15, 0xa7, 0x47, 0xef, 0xae, 0x2f, 0xf9, 0xb6, 0xa1, 0x37, + 0xfa, 0xb5, 0xbd, 0xd9, 0xaf, 0x07, 0xb0, 0x5f, 0x8b, 0xa4, 0x4a, 0x52, 0x59, 0x09, 0xd3, 0x14, + 0xa9, 0x85, 0xcf, 0x2d, 0x4a, 0x3e, 0x83, 0x6d, 0x6b, 0xa2, 0x2d, 0x4f, 0xf7, 0xff, 0x6e, 0x6d, + 0x8d, 0x7d, 0x8a, 0xe5, 0x18, 0x95, 0x9e, 0xf0, 0x19, 0xf5, 0x0b, 0x86, 0xbf, 0x74, 0x61, 0xb0, + 0xee, 0x07, 0x79, 0x06, 0x90, 0xca, 0xb2, 0xe4, 0x5a, 0xdb, 0xa3, 0x39, 0x8b, 0xcf, 0xe2, 0x17, + 0xaf, 0x0e, 0xb7, 0xfe, 0x7e, 0x75, 0xf8, 0x61, 0xce, 0xcd, 0xa4, 0x1a, 0xc7, 0xa9, 0x2c, 0x47, + 0xa9, 0xd4, 0xa5, 0xd4, 0xf5, 0xcf, 0x23, 0x9d, 0x4d, 0x47, 0x66, 0x39, 0x43, 0x1d, 0x5f, 0x60, + 0x4a, 0x57, 0x32, 0xd8, 0x7a, 0x95, 0x52, 0xf0, 0x29, 0xaa, 0xba, 0xcb, 0x9b, 0xd0, 0x32, 0x0b, + 0x1c, 0x6b, 0x6e, 0xda, 0x46, 0xaf, 0x43, 0x72, 0x00, 0xbb, 0x3c, 0x43, 0x61, 0xb8, 0x59, 0xd6, + 0xcd, 0xde, 0xc6, 0xd6, 0x40, 0x8d, 0x69, 0xa5, 0xb8, 0x59, 0x26, 0xa9, 0x14, 0x86, 0xa5, 0xbe, + 0xd5, 0xfb, 0x74, 0xbf, 0xc1, 0xcf, 0x3d, 0x6c, 0x37, 0xc8, 0xd0, 0x30, 0x5e, 0x68, 0x67, 0x5c, + 0x9f, 0x36, 0x21, 0x41, 0xb8, 0x37, 0x43, 0x57, 0x90, 0xe4, 0xf5, 0x51, 0x93, 0x74, 0xc2, 0x44, + 0x8e, 0xae, 0xc9, 0xf7, 0x4e, 0x1f, 0x6e, 0x72, 0xf1, 0xbc, 0x15, 0x9f, 0x3b, 0xed, 0x63, 0x61, + 0xd4, 0x92, 0xde, 0xad, 0x73, 0xdd, 0x64, 0xc9, 0x23, 0x20, 0x2b, 0xe9, 0x15, 0x2e, 0x98, 0xca, + 0x74, 0x3d, 0x1e, 0xef, 0xbe, 0x66, 0xa8, 0x27, 0x86, 0xbf, 0x06, 0xf0, 0xde, 0xc6, 0x1d, 0xde, + 0x78, 0x51, 0x3e, 0x80, 0xb7, 0x53, 0x85, 0xbe, 0x75, 0x33, 0x66, 0xfc, 0x03, 0xd4, 0xa5, 0x6f, + 0x35, 0xe0, 0x05, 0x33, 0x38, 0xfc, 0x3d, 0x80, 0xc1, 0x7a, 0xdb, 0x90, 0x13, 0xe8, 0xd9, 0xc6, + 0x71, 0x27, 0xd8, 0x6b, 0x06, 0x78, 0xdd, 0xa2, 0xf6, 0xb1, 0xa3, 0x4e, 0x4a, 0xee, 0xc0, 0xce, + 0x4c, 0x72, 0x61, 0xb4, 0xdb, 0xa3, 0x47, 0xeb, 0x88, 0xdc, 0x07, 0xe0, 0x3a, 0x29, 0x90, 0xcd, + 0xed, 0xd4, 0xd8, 0x06, 0xd8, 0xa5, 0x7d, 0xae, 0xbf, 0xf6, 0x00, 0x89, 0x00, 0xe6, 0xac, 0x68, + 0x26, 0xdd, 0x37, 0xc1, 0x0a, 0x62, 0x6b, 0x3b, 0x66, 0x05, 0x13, 0x29, 0xd6, 0xe3, 0xd3, 0x84, + 0x67, 0x17, 0x2f, 0xae, 0xa2, 0xe0, 0xe5, 0x55, 0x14, 0xfc, 0x73, 0x15, 0x05, 0xbf, 0x5d, 0x47, + 0x5b, 0x2f, 0xaf, 0xa3, 0xad, 0x3f, 0xaf, 0xa3, 0xad, 0x1f, 0x3f, 0x5a, 0x71, 0xea, 0xab, 0x1f, + 0xbe, 0x7b, 0xfc, 0x0c, 0xcd, 0x42, 0xaa, 0xe9, 0x28, 0x9d, 0x30, 0x2e, 0x46, 0x3f, 0xd7, 0xff, + 0x06, 0xce, 0xb1, 0xf1, 0x8e, 0x7b, 0xbe, 0x3f, 0xfe, 0x37, 0x00, 0x00, 0xff, 0xff, 0x52, 0x8f, + 0x3f, 0x0f, 0x28, 0x06, 0x00, 0x00, } func (m *BasicPool) Marshal() (dAtA []byte, err error) { @@ -612,8 +613,8 @@ func (m *BasicPool) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x30 } - if m.OperatingCost != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.OperatingCost)) + if m.InflationShareWeight != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.InflationShareWeight)) i-- dAtA[i] = 0x28 } @@ -939,8 +940,8 @@ func (m *BasicPool) Size() (n int) { if l > 0 { n += 1 + l + sovQuery(uint64(l)) } - if m.OperatingCost != 0 { - n += 1 + sovQuery(uint64(m.OperatingCost)) + if m.InflationShareWeight != 0 { + n += 1 + sovQuery(uint64(m.InflationShareWeight)) } if m.UploadInterval != 0 { n += 1 + sovQuery(uint64(m.UploadInterval)) @@ -1222,9 +1223,9 @@ func (m *BasicPool) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 5: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field OperatingCost", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field InflationShareWeight", wireType) } - m.OperatingCost = 0 + m.InflationShareWeight = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -1234,7 +1235,7 @@ func (m *BasicPool) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.OperatingCost |= uint64(b&0x7F) << shift + m.InflationShareWeight |= uint64(b&0x7F) << shift if b < 0x80 { break } diff --git a/x/stakers/keeper/exported_functions_test.go b/x/stakers/keeper/exported_functions_test.go index 3bb9fa44..bb37ab92 100644 --- a/x/stakers/keeper/exported_functions_test.go +++ b/x/stakers/keeper/exported_functions_test.go @@ -3,6 +3,8 @@ package keeper_test import ( "strconv" + pooltypes "github.com/KYVENetwork/chain/x/pool/types" + kyveApp "github.com/KYVENetwork/chain/app" i "github.com/KYVENetwork/chain/testutil/integration" sdk "github.com/cosmos/cosmos-sdk/types" @@ -14,8 +16,7 @@ import ( delegationTypes "github.com/KYVENetwork/chain/x/delegation/types" // Gov govTypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1" - // Pool - poolTypes "github.com/KYVENetwork/chain/x/pool/types" + // Stakers stakersTypes "github.com/KYVENetwork/chain/x/stakers/types" ) @@ -37,7 +38,6 @@ var _ = Describe("Protocol Governance Voting", Ordered, func() { parsedAliceAddr := sdk.MustAccAddressFromBech32(i.ALICE) parsedBobAddr := sdk.MustAccAddressFromBech32(i.BOB) - // TODO(postAudit,@john): Think about randomly generating these values. validatorAmount := 500 * i.KYVE delegatorAmount := 250 * i.KYVE @@ -56,15 +56,14 @@ var _ = Describe("Protocol Governance Voting", Ordered, func() { _ = s.RunTxSuccess(createTx) // Create and join a pool. - s.App().PoolKeeper.AppendPool(s.Ctx(), poolTypes.Pool{ - Name: "Cosmos Hub", - Protocol: &poolTypes.Protocol{ - Version: "0.0.0", - Binaries: "{}", - LastUpgrade: uint64(s.Ctx().BlockTime().Unix()), - }, - UpgradePlan: &poolTypes.UpgradePlan{}, - }) + gov := s.App().GovKeeper.GetGovernanceAccount(s.Ctx()).GetAddress().String() + msg := &pooltypes.MsgCreatePool{ + Authority: gov, + UploadInterval: 60, + MaxBundleSize: 100, + Binaries: "{}", + } + s.RunTxPoolSuccess(msg) joinTx := &stakersTypes.MsgJoinPool{ Creator: i.ALICE, diff --git a/x/stakers/keeper/msg_server_claim_commission_rewards_test.go b/x/stakers/keeper/msg_server_claim_commission_rewards_test.go index 902a933c..c2fb1ef6 100644 --- a/x/stakers/keeper/msg_server_claim_commission_rewards_test.go +++ b/x/stakers/keeper/msg_server_claim_commission_rewards_test.go @@ -3,6 +3,7 @@ package keeper_test import ( i "github.com/KYVENetwork/chain/testutil/integration" bundletypes "github.com/KYVENetwork/chain/x/bundles/types" + funderstypes "github.com/KYVENetwork/chain/x/funders/types" pooltypes "github.com/KYVENetwork/chain/x/pool/types" stakertypes "github.com/KYVENetwork/chain/x/stakers/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -34,19 +35,24 @@ var _ = Describe("msg_server_claim_commission_rewards.go", Ordered, func() { s = i.NewCleanChain() // create clean pool for every test case - s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{ - Name: "PoolTest", - MaxBundleSize: 100, - StartKey: "0", - UploadInterval: 60, - OperatingCost: 10_000, - Protocol: &pooltypes.Protocol{ - Version: "0.0.0", - Binaries: "{}", - LastUpgrade: uint64(s.Ctx().BlockTime().Unix()), - }, - UpgradePlan: &pooltypes.UpgradePlan{}, - }) + gov := s.App().GovKeeper.GetGovernanceAccount(s.Ctx()).GetAddress().String() + msg := &pooltypes.MsgCreatePool{ + Authority: gov, + Name: "PoolTest", + Runtime: "@kyve/test", + Logo: "ar://Tewyv2P5VEG8EJ6AUQORdqNTectY9hlOrWPK8wwo-aU", + Config: "ar://DgdB-2hLrxjhyEEbCML__dgZN5_uS7T6Z5XDkaFh3P0", + StartKey: "0", + UploadInterval: 60, + InflationShareWeight: 10_000, + MinDelegation: 100 * i.KYVE, + MaxBundleSize: 100, + Version: "0.0.0", + Binaries: "{}", + StorageProviderId: 2, + CompressionId: 1, + } + s.RunTxPoolSuccess(msg) s.RunTxStakersSuccess(&stakertypes.MsgCreateStaker{ Creator: i.STAKER_0, @@ -78,11 +84,21 @@ var _ = Describe("msg_server_claim_commission_rewards.go", Ordered, func() { initialBalanceStaker0 = s.GetBalanceFromAddress(i.STAKER_0) - // create a valid bundle so that uploader earns commission rewards - s.RunTxPoolSuccess(&pooltypes.MsgFundPool{ + s.RunTxFundersSuccess(&funderstypes.MsgCreateFunder{ Creator: i.ALICE, - Id: 0, - Amount: 100 * i.KYVE, + Moniker: "Alice", + }) + + params := s.App().FundersKeeper.GetParams(s.Ctx()) + params.MinFundingAmountPerBundle = 10_000 + s.App().FundersKeeper.SetParams(s.Ctx(), params) + + // create a valid bundle so that uploader earns commission rewards + s.RunTxFundersSuccess(&funderstypes.MsgFundPool{ + Creator: i.ALICE, + PoolId: 0, + Amount: 100 * i.KYVE, + AmountPerBundle: 10_000, }) s.CommitAfterSeconds(60) @@ -147,9 +163,9 @@ var _ = Describe("msg_server_claim_commission_rewards.go", Ordered, func() { balanceUploader := s.GetBalanceFromAddress(i.STAKER_0) networkFee := s.App().BundlesKeeper.GetNetworkFee(s.Ctx()) - treasuryReward := uint64(sdk.NewDec(int64(pool.OperatingCost)).Mul(networkFee).TruncateInt64()) + treasuryReward := uint64(sdk.NewDec(int64(pool.InflationShareWeight)).Mul(networkFee).TruncateInt64()) storageReward := uint64(s.App().BundlesKeeper.GetStorageCost(s.Ctx()).MulInt64(100).TruncateInt64()) - totalUploaderReward := pool.OperatingCost - treasuryReward - storageReward + totalUploaderReward := pool.InflationShareWeight - treasuryReward - storageReward uploaderPayoutReward := uint64(sdk.NewDec(int64(totalUploaderReward)).Mul(uploader.Commission).TruncateInt64()) totalDelegationReward := totalUploaderReward - uploaderPayoutReward @@ -162,11 +178,11 @@ var _ = Describe("msg_server_claim_commission_rewards.go", Ordered, func() { // assert commission rewards Expect(uploader.CommissionRewards).To(Equal(uploaderPayoutReward + storageReward)) - // check pool funds - pool, _ = s.App().PoolKeeper.GetPool(s.Ctx(), 0) + fundingState, _ := s.App().FundersKeeper.GetFundingState(s.Ctx(), 0) - Expect(pool.Funders).To(HaveLen(1)) - Expect(pool.GetFunderAmount(i.ALICE)).To(Equal(100*i.KYVE - pool.OperatingCost)) + // assert total pool funds + Expect(s.App().FundersKeeper.GetTotalActiveFunding(s.Ctx(), fundingState.PoolId)).To(Equal(100*i.KYVE - 10_000)) + Expect(fundingState.ActiveFunderAddresses).To(HaveLen(1)) }) It("Claim with non-staker account", func() { @@ -184,9 +200,9 @@ var _ = Describe("msg_server_claim_commission_rewards.go", Ordered, func() { pool, _ := s.App().PoolKeeper.GetPool(s.Ctx(), 0) networkFee := s.App().BundlesKeeper.GetNetworkFee(s.Ctx()) - treasuryReward := uint64(sdk.NewDec(int64(pool.OperatingCost)).Mul(networkFee).TruncateInt64()) + treasuryReward := uint64(sdk.NewDec(int64(pool.InflationShareWeight)).Mul(networkFee).TruncateInt64()) storageReward := uint64(s.App().BundlesKeeper.GetStorageCost(s.Ctx()).MulInt64(100).TruncateInt64()) - totalUploaderReward := pool.OperatingCost - treasuryReward - storageReward + totalUploaderReward := pool.InflationShareWeight - treasuryReward - storageReward uploaderPayoutReward := uint64(sdk.NewDec(int64(totalUploaderReward)).Mul(uploader.Commission).TruncateInt64()) @@ -212,9 +228,9 @@ var _ = Describe("msg_server_claim_commission_rewards.go", Ordered, func() { pool, _ := s.App().PoolKeeper.GetPool(s.Ctx(), 0) networkFee := s.App().BundlesKeeper.GetNetworkFee(s.Ctx()) - treasuryReward := uint64(sdk.NewDec(int64(pool.OperatingCost)).Mul(networkFee).TruncateInt64()) + treasuryReward := uint64(sdk.NewDec(int64(pool.InflationShareWeight)).Mul(networkFee).TruncateInt64()) storageReward := uint64(s.App().BundlesKeeper.GetStorageCost(s.Ctx()).MulInt64(100).TruncateInt64()) - totalUploaderReward := pool.OperatingCost - treasuryReward - storageReward + totalUploaderReward := pool.InflationShareWeight - treasuryReward - storageReward uploaderPayoutReward := uint64(sdk.NewDec(int64(totalUploaderReward)).Mul(uploader.Commission).TruncateInt64()) @@ -236,9 +252,9 @@ var _ = Describe("msg_server_claim_commission_rewards.go", Ordered, func() { pool, _ := s.App().PoolKeeper.GetPool(s.Ctx(), 0) networkFee := s.App().BundlesKeeper.GetNetworkFee(s.Ctx()) - treasuryReward := uint64(sdk.NewDec(int64(pool.OperatingCost)).Mul(networkFee).TruncateInt64()) + treasuryReward := uint64(sdk.NewDec(int64(pool.InflationShareWeight)).Mul(networkFee).TruncateInt64()) storageReward := uint64(s.App().BundlesKeeper.GetStorageCost(s.Ctx()).MulInt64(100).TruncateInt64()) - totalUploaderReward := pool.OperatingCost - treasuryReward - storageReward + totalUploaderReward := pool.InflationShareWeight - treasuryReward - storageReward uploaderPayoutReward := uint64(sdk.NewDec(int64(totalUploaderReward)).Mul(uploader.Commission).TruncateInt64()) @@ -262,9 +278,9 @@ var _ = Describe("msg_server_claim_commission_rewards.go", Ordered, func() { pool, _ := s.App().PoolKeeper.GetPool(s.Ctx(), 0) networkFee := s.App().BundlesKeeper.GetNetworkFee(s.Ctx()) - treasuryReward := uint64(sdk.NewDec(int64(pool.OperatingCost)).Mul(networkFee).TruncateInt64()) + treasuryReward := uint64(sdk.NewDec(int64(pool.InflationShareWeight)).Mul(networkFee).TruncateInt64()) storageReward := uint64(s.App().BundlesKeeper.GetStorageCost(s.Ctx()).MulInt64(100).TruncateInt64()) - totalUploaderReward := pool.OperatingCost - treasuryReward - storageReward + totalUploaderReward := pool.InflationShareWeight - treasuryReward - storageReward uploaderPayoutReward := uint64(sdk.NewDec(int64(totalUploaderReward)).Mul(uploader.Commission).TruncateInt64()) @@ -288,9 +304,9 @@ var _ = Describe("msg_server_claim_commission_rewards.go", Ordered, func() { pool, _ := s.App().PoolKeeper.GetPool(s.Ctx(), 0) networkFee := s.App().BundlesKeeper.GetNetworkFee(s.Ctx()) - treasuryReward := uint64(sdk.NewDec(int64(pool.OperatingCost)).Mul(networkFee).TruncateInt64()) + treasuryReward := uint64(sdk.NewDec(int64(pool.InflationShareWeight)).Mul(networkFee).TruncateInt64()) storageReward := uint64(s.App().BundlesKeeper.GetStorageCost(s.Ctx()).MulInt64(100).TruncateInt64()) - totalUploaderReward := pool.OperatingCost - treasuryReward - storageReward + totalUploaderReward := pool.InflationShareWeight - treasuryReward - storageReward uploaderPayoutReward := uint64(sdk.NewDec(int64(totalUploaderReward)).Mul(uploader.Commission).TruncateInt64()) @@ -360,9 +376,9 @@ var _ = Describe("msg_server_claim_commission_rewards.go", Ordered, func() { pool, _ = s.App().PoolKeeper.GetPool(s.Ctx(), 0) networkFee = s.App().BundlesKeeper.GetNetworkFee(s.Ctx()) - treasuryReward = uint64(sdk.NewDec(int64(pool.OperatingCost)).Mul(networkFee).TruncateInt64()) + treasuryReward = uint64(sdk.NewDec(int64(pool.InflationShareWeight)).Mul(networkFee).TruncateInt64()) storageReward = uint64(s.App().BundlesKeeper.GetStorageCost(s.Ctx()).MulInt64(100).TruncateInt64()) - totalUploaderReward = pool.OperatingCost - treasuryReward - storageReward + totalUploaderReward = pool.InflationShareWeight - treasuryReward - storageReward uploaderPayoutReward = uint64(sdk.NewDec(int64(totalUploaderReward)).Mul(uploader.Commission).TruncateInt64()) diff --git a/x/stakers/keeper/msg_server_join_pool_test.go b/x/stakers/keeper/msg_server_join_pool_test.go index cf7f3ec5..6277d38f 100644 --- a/x/stakers/keeper/msg_server_join_pool_test.go +++ b/x/stakers/keeper/msg_server_join_pool_test.go @@ -46,20 +46,20 @@ var _ = Describe("msg_server_join_pool.go", Ordered, func() { initialBalanceStaker1 := uint64(0) initialBalanceValaddress1 := uint64(0) + gov := s.App().GovKeeper.GetGovernanceAccount(s.Ctx()).GetAddress().String() + BeforeEach(func() { // init new clean chain s = i.NewCleanChain() // create pool - s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{ - Name: "PoolTest", - Protocol: &pooltypes.Protocol{ - Version: "0.0.0", - Binaries: "{}", - LastUpgrade: uint64(s.Ctx().BlockTime().Unix()), - }, - UpgradePlan: &pooltypes.UpgradePlan{}, - }) + msg := &pooltypes.MsgCreatePool{ + Authority: gov, + UploadInterval: 60, + MaxBundleSize: 100, + Binaries: "{}", + } + s.RunTxPoolSuccess(msg) // create staker s.RunTxStakersSuccess(&stakerstypes.MsgCreateStaker{ @@ -174,16 +174,17 @@ var _ = Describe("msg_server_join_pool.go", Ordered, func() { It("Join disabled pool", func() { // ARRANGE - s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{ - Name: "DisabledPool", - Protocol: &pooltypes.Protocol{ - Version: "0.0.0", - Binaries: "{}", - LastUpgrade: uint64(s.Ctx().BlockTime().Unix()), - }, - UpgradePlan: &pooltypes.UpgradePlan{}, - Disabled: true, - }) + msg := &pooltypes.MsgCreatePool{ + Authority: gov, + UploadInterval: 60, + MaxBundleSize: 100, + Binaries: "{}", + } + s.RunTxPoolSuccess(msg) + + pool, _ := s.App().PoolKeeper.GetPool(s.Ctx(), 1) + pool.Disabled = true + s.App().PoolKeeper.SetPool(s.Ctx(), pool) // ACT _, err := s.RunTx(&stakerstypes.MsgJoinPool{ @@ -392,15 +393,13 @@ var _ = Describe("msg_server_join_pool.go", Ordered, func() { Amount: 100 * i.KYVE, }) - s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{ - Name: "Test Pool2", - Protocol: &pooltypes.Protocol{ - Version: "0.0.0", - Binaries: "{}", - LastUpgrade: uint64(s.Ctx().BlockTime().Unix()), - }, - UpgradePlan: &pooltypes.UpgradePlan{}, - }) + msg := &pooltypes.MsgCreatePool{ + Authority: gov, + UploadInterval: 60, + MaxBundleSize: 100, + Binaries: "{}", + } + s.RunTxPoolSuccess(msg) // ACT s.RunTxStakersError(&stakerstypes.MsgJoinPool{ @@ -417,15 +416,13 @@ var _ = Describe("msg_server_join_pool.go", Ordered, func() { It("Try to join pool with a valaddress that is already used by another staker", func() { // ARRANGE - s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{ - Name: "Test Pool2", - Protocol: &pooltypes.Protocol{ - Version: "0.0.0", - Binaries: "{}", - LastUpgrade: uint64(s.Ctx().BlockTime().Unix()), - }, - UpgradePlan: &pooltypes.UpgradePlan{}, - }) + msg := &pooltypes.MsgCreatePool{ + Authority: gov, + UploadInterval: 60, + MaxBundleSize: 100, + Binaries: "{}", + } + s.RunTxPoolSuccess(msg) s.RunTxStakersSuccess(&stakerstypes.MsgCreateStaker{ Creator: i.STAKER_1, @@ -488,15 +485,13 @@ var _ = Describe("msg_server_join_pool.go", Ordered, func() { Amount: 100 * i.KYVE, }) - s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{ - Name: "Test Pool2", - Protocol: &pooltypes.Protocol{ - Version: "0.0.0", - Binaries: "{}", - LastUpgrade: uint64(s.Ctx().BlockTime().Unix()), - }, - UpgradePlan: &pooltypes.UpgradePlan{}, - }) + msg := &pooltypes.MsgCreatePool{ + Authority: gov, + UploadInterval: 60, + MaxBundleSize: 100, + Binaries: "{}", + } + s.RunTxPoolSuccess(msg) // ACT s.RunTxStakersSuccess(&stakerstypes.MsgJoinPool{ diff --git a/x/stakers/keeper/msg_server_leave_pool_test.go b/x/stakers/keeper/msg_server_leave_pool_test.go index 9df61b6e..347bc6d1 100644 --- a/x/stakers/keeper/msg_server_leave_pool_test.go +++ b/x/stakers/keeper/msg_server_leave_pool_test.go @@ -23,21 +23,20 @@ TEST CASES - msg_server_leave_pool.go var _ = Describe("msg_server_leave_pool.go", Ordered, func() { s := i.NewCleanChain() + gov := s.App().GovKeeper.GetGovernanceAccount(s.Ctx()).GetAddress().String() BeforeEach(func() { // init new clean chain s = i.NewCleanChain() // create pool - s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{ - Name: "PoolTest", - Protocol: &pooltypes.Protocol{ - Version: "0.0.0", - Binaries: "{}", - LastUpgrade: uint64(s.Ctx().BlockTime().Unix()), - }, - UpgradePlan: &pooltypes.UpgradePlan{}, - }) + msg := &pooltypes.MsgCreatePool{ + Authority: gov, + UploadInterval: 60, + MaxBundleSize: 100, + Binaries: "{}", + } + s.RunTxPoolSuccess(msg) // create staker s.RunTxStakersSuccess(&stakerstypes.MsgCreateStaker{ @@ -208,15 +207,13 @@ var _ = Describe("msg_server_leave_pool.go", Ordered, func() { It("Leave one of multiple pools a staker has previously joined", func() { // ARRANGE - s.App().PoolKeeper.AppendPool(s.Ctx(), pooltypes.Pool{ - Name: "PoolTest", - Protocol: &pooltypes.Protocol{ - Version: "0.0.0", - Binaries: "{}", - LastUpgrade: uint64(s.Ctx().BlockTime().Unix()), - }, - UpgradePlan: &pooltypes.UpgradePlan{}, - }) + msg := &pooltypes.MsgCreatePool{ + Authority: gov, + UploadInterval: 60, + MaxBundleSize: 100, + Binaries: "{}", + } + s.RunTxPoolSuccess(msg) s.RunTxStakersSuccess(&stakerstypes.MsgJoinPool{ Creator: i.STAKER_0, diff --git a/x/team/keeper/logic_team_test.go b/x/team/keeper/logic_team_test.go index 5554d862..7af1eef4 100644 --- a/x/team/keeper/logic_team_test.go +++ b/x/team/keeper/logic_team_test.go @@ -395,8 +395,3 @@ var _ = Describe("logic_team_test.go", Ordered, func() { Expect(uint64(0)).To(Equal(statusJCU.RemainingUnvestedAmount)) }) }) - -//func debugPrintStatus(status *types.VestingStatus) { -// fmt.Printf("TotalVestedAmount: %d\nTotalUnlocked: %d\nCurrentClaimable: %d\nLocked: %d\nRemainingUnvested: %d\n", -// status.TotalVestedAmount, status.TotalUnlockedAmount, status.CurrentClaimableAmount, status.LockedVestedAmount, status.RemainingUnvestedAmount) -//}