From 89ef563f28220a7cd3ce6353e5cbe861200df256 Mon Sep 17 00:00:00 2001 From: Doan Phi Hung Date: Wed, 18 Dec 2024 17:19:28 +0700 Subject: [PATCH] feat: farming --- app/app.go | 22 + docs/static/openapi.yml | 2291 ++++++++--- proto/titan/farming/distribution_info.proto | 12 + proto/titan/farming/event.proto | 57 + proto/titan/farming/farm.proto | 29 + proto/titan/farming/genesis.proto | 21 + proto/titan/farming/params.proto | 11 + proto/titan/farming/query.proto | 139 + proto/titan/farming/reward.proto | 20 + proto/titan/farming/staking_info.proto | 20 + proto/titan/farming/tx.proto | 79 + scripts/mockgen.sh | 1 + testutil/keeper/farming.go | 57 + testutil/sample/sample.go | 4 - x/farming/abci.go | 85 + x/farming/client/cli/query.go | 38 + .../client/cli/query_distribution_info.go | 38 + .../cli/query_distribution_info_test.go | 67 + x/farming/client/cli/query_farm.go | 79 + x/farming/client/cli/query_farm_test.go | 173 + x/farming/client/cli/query_params.go | 36 + x/farming/client/cli/query_reward.go | 79 + x/farming/client/cli/query_reward_test.go | 164 + x/farming/client/cli/query_staking_info.go | 87 + .../client/cli/query_staking_info_test.go | 171 + x/farming/client/cli/tx.go | 40 + x/farming/client/cli/tx_add_reward.go | 65 + x/farming/client/cli/tx_harvest.go | 39 + x/farming/client/cli/tx_stake.go | 46 + x/farming/client/cli/tx_unstake.go | 46 + x/farming/genesis.go | 47 + x/farming/genesis_test.go | 76 + x/farming/keeper/distribution_info.go | 27 + x/farming/keeper/distribution_info_test.go | 30 + x/farming/keeper/farm.go | 53 + x/farming/keeper/farm_test.go | 65 + x/farming/keeper/keeper.go | 48 + x/farming/keeper/msg_server.go | 17 + x/farming/keeper/msg_server_add_reward.go | 57 + .../keeper/msg_server_add_reward_test.go | 55 + x/farming/keeper/msg_server_harvest.go | 34 + x/farming/keeper/msg_server_harvest_test.go | 46 + x/farming/keeper/msg_server_stake.go | 41 + x/farming/keeper/msg_server_stake_test.go | 41 + x/farming/keeper/msg_server_test.go | 34 + x/farming/keeper/msg_server_unstake.go | 42 + x/farming/keeper/msg_server_unstake_test.go | 88 + x/farming/keeper/params.go | 16 + x/farming/keeper/params_test.go | 18 + x/farming/keeper/query.go | 7 + x/farming/keeper/query_distribution_info.go | 24 + .../keeper/query_distribution_info_test.go | 50 + x/farming/keeper/query_farm.go | 57 + x/farming/keeper/query_farm_test.go | 131 + x/farming/keeper/query_params.go | 19 + x/farming/keeper/query_params_test.go | 21 + x/farming/keeper/query_reward.go | 57 + x/farming/keeper/query_reward_test.go | 131 + x/farming/keeper/query_staking_info.go | 60 + x/farming/keeper/query_staking_info_test.go | 134 + x/farming/keeper/reward.go | 69 + x/farming/keeper/reward_test.go | 65 + x/farming/keeper/staking_info.go | 72 + x/farming/keeper/staking_info_test.go | 70 + x/farming/module.go | 153 + x/farming/module_simulation.go | 168 + x/farming/simulation/add_reward.go | 26 + x/farming/simulation/harvest.go | 26 + x/farming/simulation/helpers.go | 15 + x/farming/simulation/stake.go | 26 + x/farming/simulation/unstake.go | 26 + x/farming/testutil/expected_keepers_mocks.go | 115 + x/farming/types/codec.go | 39 + x/farming/types/distribution_info.pb.go | 327 ++ x/farming/types/errors.go | 29 + x/farming/types/event.pb.go | 1257 ++++++ x/farming/types/expected_keepers.go | 20 + x/farming/types/farm.pb.go | 738 ++++ x/farming/types/genesis.go | 93 + x/farming/types/genesis.pb.go | 576 +++ x/farming/types/genesis_test.go | 118 + x/farming/types/key_distribution_info.go | 6 + x/farming/types/key_farm.go | 21 + x/farming/types/key_reward.go | 21 + x/farming/types/key_staking_info.go | 21 + x/farming/types/keys.go | 19 + x/farming/types/message_add_reward.go | 68 + x/farming/types/message_add_reward_test.go | 103 + x/farming/types/message_harvest.go | 46 + x/farming/types/message_harvest_test.go | 41 + x/farming/types/message_stake.go | 52 + x/farming/types/message_stake_test.go | 52 + x/farming/types/message_unstake.go | 52 + x/farming/types/message_unstake_test.go | 51 + x/farming/types/params.go | 39 + x/farming/types/params.pb.go | 264 ++ x/farming/types/query.pb.go | 3533 +++++++++++++++++ x/farming/types/query.pb.gw.go | 828 ++++ x/farming/types/reward.pb.go | 392 ++ x/farming/types/staking_info.pb.go | 426 ++ x/farming/types/tx.pb.go | 1882 +++++++++ x/farming/types/types.go | 1 + 102 files changed, 17040 insertions(+), 448 deletions(-) create mode 100644 proto/titan/farming/distribution_info.proto create mode 100644 proto/titan/farming/event.proto create mode 100644 proto/titan/farming/farm.proto create mode 100644 proto/titan/farming/genesis.proto create mode 100644 proto/titan/farming/params.proto create mode 100644 proto/titan/farming/query.proto create mode 100644 proto/titan/farming/reward.proto create mode 100644 proto/titan/farming/staking_info.proto create mode 100644 proto/titan/farming/tx.proto create mode 100644 testutil/keeper/farming.go create mode 100644 x/farming/abci.go create mode 100644 x/farming/client/cli/query.go create mode 100644 x/farming/client/cli/query_distribution_info.go create mode 100644 x/farming/client/cli/query_distribution_info_test.go create mode 100644 x/farming/client/cli/query_farm.go create mode 100644 x/farming/client/cli/query_farm_test.go create mode 100644 x/farming/client/cli/query_params.go create mode 100644 x/farming/client/cli/query_reward.go create mode 100644 x/farming/client/cli/query_reward_test.go create mode 100644 x/farming/client/cli/query_staking_info.go create mode 100644 x/farming/client/cli/query_staking_info_test.go create mode 100644 x/farming/client/cli/tx.go create mode 100644 x/farming/client/cli/tx_add_reward.go create mode 100644 x/farming/client/cli/tx_harvest.go create mode 100644 x/farming/client/cli/tx_stake.go create mode 100644 x/farming/client/cli/tx_unstake.go create mode 100644 x/farming/genesis.go create mode 100644 x/farming/genesis_test.go create mode 100644 x/farming/keeper/distribution_info.go create mode 100644 x/farming/keeper/distribution_info_test.go create mode 100644 x/farming/keeper/farm.go create mode 100644 x/farming/keeper/farm_test.go create mode 100644 x/farming/keeper/keeper.go create mode 100644 x/farming/keeper/msg_server.go create mode 100644 x/farming/keeper/msg_server_add_reward.go create mode 100644 x/farming/keeper/msg_server_add_reward_test.go create mode 100644 x/farming/keeper/msg_server_harvest.go create mode 100644 x/farming/keeper/msg_server_harvest_test.go create mode 100644 x/farming/keeper/msg_server_stake.go create mode 100644 x/farming/keeper/msg_server_stake_test.go create mode 100644 x/farming/keeper/msg_server_test.go create mode 100644 x/farming/keeper/msg_server_unstake.go create mode 100644 x/farming/keeper/msg_server_unstake_test.go create mode 100644 x/farming/keeper/params.go create mode 100644 x/farming/keeper/params_test.go create mode 100644 x/farming/keeper/query.go create mode 100644 x/farming/keeper/query_distribution_info.go create mode 100644 x/farming/keeper/query_distribution_info_test.go create mode 100644 x/farming/keeper/query_farm.go create mode 100644 x/farming/keeper/query_farm_test.go create mode 100644 x/farming/keeper/query_params.go create mode 100644 x/farming/keeper/query_params_test.go create mode 100644 x/farming/keeper/query_reward.go create mode 100644 x/farming/keeper/query_reward_test.go create mode 100644 x/farming/keeper/query_staking_info.go create mode 100644 x/farming/keeper/query_staking_info_test.go create mode 100644 x/farming/keeper/reward.go create mode 100644 x/farming/keeper/reward_test.go create mode 100644 x/farming/keeper/staking_info.go create mode 100644 x/farming/keeper/staking_info_test.go create mode 100644 x/farming/module.go create mode 100644 x/farming/module_simulation.go create mode 100644 x/farming/simulation/add_reward.go create mode 100644 x/farming/simulation/harvest.go create mode 100644 x/farming/simulation/helpers.go create mode 100644 x/farming/simulation/stake.go create mode 100644 x/farming/simulation/unstake.go create mode 100644 x/farming/testutil/expected_keepers_mocks.go create mode 100644 x/farming/types/codec.go create mode 100644 x/farming/types/distribution_info.pb.go create mode 100644 x/farming/types/errors.go create mode 100644 x/farming/types/event.pb.go create mode 100644 x/farming/types/expected_keepers.go create mode 100644 x/farming/types/farm.pb.go create mode 100644 x/farming/types/genesis.go create mode 100644 x/farming/types/genesis.pb.go create mode 100644 x/farming/types/genesis_test.go create mode 100644 x/farming/types/key_distribution_info.go create mode 100644 x/farming/types/key_farm.go create mode 100644 x/farming/types/key_reward.go create mode 100644 x/farming/types/key_staking_info.go create mode 100644 x/farming/types/keys.go create mode 100644 x/farming/types/message_add_reward.go create mode 100644 x/farming/types/message_add_reward_test.go create mode 100644 x/farming/types/message_harvest.go create mode 100644 x/farming/types/message_harvest_test.go create mode 100644 x/farming/types/message_stake.go create mode 100644 x/farming/types/message_stake_test.go create mode 100644 x/farming/types/message_unstake.go create mode 100644 x/farming/types/message_unstake_test.go create mode 100644 x/farming/types/params.go create mode 100644 x/farming/types/params.pb.go create mode 100644 x/farming/types/query.pb.go create mode 100644 x/farming/types/query.pb.gw.go create mode 100644 x/farming/types/reward.pb.go create mode 100644 x/farming/types/staking_info.pb.go create mode 100644 x/farming/types/tx.pb.go create mode 100644 x/farming/types/types.go diff --git a/app/app.go b/app/app.go index bade4c15..af5ce2d5 100644 --- a/app/app.go +++ b/app/app.go @@ -167,6 +167,10 @@ import ( tokenfactorykeeper "github.com/titantkx/titan/x/tokenfactory/keeper" tokenfactorytypes "github.com/titantkx/titan/x/tokenfactory/types" + "github.com/titantkx/titan/x/farming" + farmingkeeper "github.com/titantkx/titan/x/farming/keeper" + farmingtypes "github.com/titantkx/titan/x/farming/types" + // this line is used by starport scaffolding # stargate/app/moduleImport appparams "github.com/titantkx/titan/app/params" @@ -241,6 +245,7 @@ var ( nftmint.AppModuleBasic{}, nfttransfer.AppModuleBasic{}, tokenfactory.AppModuleBasic{}, + farming.AppModuleBasic{}, // this line is used by starport scaffolding # stargate/app/moduleBasic ) @@ -262,6 +267,7 @@ var ( nftminttypes.ModuleName: nil, nfttransfertypes.ModuleName: nil, tokenfactorytypes.ModuleName: {authtypes.Minter, authtypes.Burner}, + farmingtypes.ModuleName: nil, // this line is used by starport scaffolding # stargate/app/maccPerms } ) @@ -342,6 +348,8 @@ type App struct { NFTTransferKeeper nfttransferkeeper.Keeper TokenfactoryKeeper tokenfactorykeeper.Keeper + + FarmingKeeper farmingkeeper.Keeper // this line is used by starport scaffolding # stargate/app/keeperDeclaration // mm is the module manager @@ -407,6 +415,7 @@ func New( nftminttypes.StoreKey, nfttransfertypes.StoreKey, tokenfactorytypes.StoreKey, + farmingtypes.StoreKey, // this line is used by starport scaffolding # stargate/app/storeKey ) tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey, evmtypes.TransientKey, feemarkettypes.TransientKey) @@ -742,6 +751,14 @@ func New( authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) + app.FarmingKeeper = *farmingkeeper.NewKeeper( + appCodec, + keys[farmingtypes.StoreKey], + keys[farmingtypes.MemStoreKey], + app.GetSubspace(farmingtypes.ModuleName), + app.BankKeeper, + ) + // this line is used by starport scaffolding # stargate/app/keeperDefinition /**** IBC Routing ****/ @@ -858,6 +875,7 @@ func New( nftmint.NewAppModule(appCodec, app.NftmintKeeper, app.AccountKeeper, app.BankKeeper), nfttransfer.NewAppModule(app.NFTTransferKeeper), tokenfactory.NewAppModule(app.TokenfactoryKeeper, app.AccountKeeper, app.BankKeeper), + farming.NewAppModule(appCodec, app.FarmingKeeper, app.AccountKeeper, app.BankKeeper), // this line is used by starport scaffolding # stargate/app/appModule crisis.NewAppModule(app.CrisisKeeper, skipGenesisInvariants, app.GetSubspace(crisistypes.ModuleName)), // always be last to make sure that it checks for all invariants and not only part of them @@ -900,6 +918,7 @@ func New( nftminttypes.ModuleName, nfttransfertypes.ModuleName, tokenfactorytypes.ModuleName, + farmingtypes.ModuleName, // this line is used by starport scaffolding # stargate/app/beginBlockers ) @@ -934,6 +953,7 @@ func New( nftminttypes.ModuleName, nfttransfertypes.ModuleName, tokenfactorytypes.ModuleName, + farmingtypes.ModuleName, // this line is used by starport scaffolding # stargate/app/endBlockers ) @@ -979,6 +999,7 @@ func New( nftminttypes.ModuleName, nfttransfertypes.ModuleName, tokenfactorytypes.ModuleName, + farmingtypes.ModuleName, // this line is used by starport scaffolding # stargate/app/initGenesis } app.mm.SetOrderInitGenesis(genesisModuleOrder...) @@ -1279,6 +1300,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino paramsKeeper.Subspace(validatorrewardtypes.ModuleName) paramsKeeper.Subspace(nftminttypes.ModuleName) + paramsKeeper.Subspace(farmingtypes.ModuleName) // this line is used by starport scaffolding # stargate/app/paramSubspace return paramsKeeper diff --git a/docs/static/openapi.yml b/docs/static/openapi.yml index 792e5176..782719ea 100644 --- a/docs/static/openapi.yml +++ b/docs/static/openapi.yml @@ -57229,36 +57229,96 @@ paths: additionalProperties: {} tags: - Query - /titantkx/titan/nftmint/minting_info: + /titantkx/titan/farming/distribution_info: get: - summary: MintingInfos queries a list of minting info. - operationId: TitanNftmintMintingInfos + summary: DistributionInfo queries the distribution info. + operationId: TitanFarmingDistributionInfo responses: '200': description: A successful response. schema: type: object properties: - minting_info: + distribution_info: + type: object + properties: + last_distribution_time: + type: string + format: date-time + description: DistributionInfo defines the reward distribution info. + description: >- + QueryDistributionInfoResponse is response type for the + Query/DistributionInfo RPC method. + default: + description: An unexpected error response. + schema: + type: object + properties: + code: + type: integer + format: int32 + message: + type: string + details: type: array items: type: object properties: - class_id: - type: string - description: class_id is a unique identifier of the class. - owner: + '@type': type: string - description: owner is the owner address of the class. - next_token_id: + additionalProperties: {} + tags: + - Query + /titantkx/titan/farming/farm: + get: + summary: FarmAll queries all farms. + operationId: TitanFarmingFarmAll + responses: + '200': + description: A successful response. + schema: + type: object + properties: + farm: + type: array + items: + type: object + properties: + token: type: string - format: uint64 - description: >- - next_token_id is the unique identifier of the next token - that will be + rewards: + type: array + items: + type: object + properties: + sender: + type: string + amount: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an + amount. - minted under this class. - description: MintingInfo defines the minting info for a class. + + NOTE: The amount field is an Int which + implements the custom method + + signatures required by gogoproto. + end_time: + type: string + format: date-time + start_time: + type: string + format: date-time + description: FarmReward defines the farming rewards. + description: Farm defines the farming rewards for a token. pagination: type: object properties: @@ -57288,10 +57348,8 @@ paths: PageResponse page = 2; } description: >- - QueryMintingInfosResponse is response type for the - Query/QueryMintingInfos - - RPC method. + QueryFarmAllResponse is response type for the Query/AllFarm RPC + method. default: description: An unexpected error response. schema: @@ -57369,39 +57427,55 @@ paths: type: boolean tags: - Query - /titantkx/titan/nftmint/minting_info/{class_id}: + /titantkx/titan/farming/farm/{token}: get: - summary: MintingInfo queries the minting info of a given class. - operationId: TitanNftmintMintingInfo + summary: Farm queries a farm. + operationId: TitanFarmingFarm responses: '200': description: A successful response. schema: type: object properties: - minting_info: + farm: type: object properties: - class_id: - type: string - description: class_id is a unique identifier of the class. - owner: - type: string - description: owner is the owner address of the class. - next_token_id: + token: type: string - format: uint64 - description: >- - next_token_id is the unique identifier of the next token - that will be + rewards: + type: array + items: + type: object + properties: + sender: + type: string + amount: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an + amount. - minted under this class. - description: MintingInfo defines the minting info for a class. - description: >- - QueryMintingInfoResponse is response type for the - Query/QueryMintingInfo RPC - method. + NOTE: The amount field is an Int which implements + the custom method + + signatures required by gogoproto. + end_time: + type: string + format: date-time + start_time: + type: string + format: date-time + description: FarmReward defines the farming rewards. + description: Farm defines the farming rewards for a token. + description: QueryFarmResponse is response type for the Query/Farm RPC method. default: description: An unexpected error response. schema: @@ -57421,16 +57495,16 @@ paths: type: string additionalProperties: {} parameters: - - name: class_id + - name: token in: path required: true type: string tags: - Query - /titantkx/titan/nftmint/params: + /titantkx/titan/farming/params: get: summary: Parameters queries the parameters of the module. - operationId: TitanNftmintParams + operationId: TitanFarmingParams responses: '200': description: A successful response. @@ -57463,32 +57537,72 @@ paths: additionalProperties: {} tags: - Query - /titantkx/titan/nftmint/system_info: + /titantkx/titan/farming/reward: get: - summary: SystemInfo queries the system info of the module. - operationId: TitanNftmintSystemInfo + summary: Reward queries all farming rewards. + operationId: TitanFarmingRewardAll responses: '200': description: A successful response. schema: type: object properties: - system_info: + reward: + type: array + items: + type: object + properties: + farmer: + type: string + amount: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an + amount. + + + NOTE: The amount field is an Int which implements the + custom method + + signatures required by gogoproto. + description: Reward defines the farming rewards of the farmer. + pagination: type: object properties: - next_class_id: + 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 - description: >- - next_class_id is the unique identifier of the next class - that will be + title: >- + total is total number of results available if + PageRequest.count_total - created. - description: SystemInfo defines the system info of this module. - description: >- - QuerySystemInfoResponse is response type for the - Query/QuerySystemInfo + was set, its value is undefined otherwise + description: >- + PageResponse is to be embedded in gRPC response messages where + the + + corresponding request message has used PageRequest. + message SomeResponse { + repeated Bar results = 1; + PageResponse page = 2; + } + description: >- + QueryRewardAllResponse is response type for the Query/AllReward RPC method. default: description: An unexpected error response. @@ -57508,28 +57622,100 @@ paths: '@type': type: string additionalProperties: {} + 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 tags: - Query - /titantkx/titan/validatorreward/params: + /titantkx/titan/farming/reward/{farmer}: get: - summary: Parameters queries the parameters of the module. - operationId: TitanValidatorrewardParams + summary: Reward queries farming rewards of a farmer. + operationId: TitanFarmingReward responses: '200': description: A successful response. schema: type: object properties: - params: - description: params holds all the parameters of this module. + reward: type: object properties: - rate: - type: string - authority: + farmer: type: string + amount: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an amount. + + + NOTE: The amount field is an Int which implements the + custom method + + signatures required by gogoproto. + description: Reward defines the farming rewards of the farmer. description: >- - QueryParamsResponse is response type for the Query/Params RPC + QueryRewardResponse is response type for the Query/Reward RPC method. default: description: An unexpected error response. @@ -57549,38 +57735,68 @@ paths: '@type': type: string additionalProperties: {} + parameters: + - name: farmer + in: path + required: true + type: string tags: - Query - /titantkx/titan/validatorreward/reward_pool: + /titantkx/titan/farming/staking_info/{token}: get: - summary: Queries a list of RewardPool items. - operationId: TitanValidatorrewardRewardPool + summary: StakingInfoAll queries all staking info of a token. + operationId: TitanFarmingStakingInfoAll responses: '200': description: A successful response. schema: type: object properties: - pool: + staking_info: type: array items: type: object properties: - denom: + token: + type: string + staker: type: string amount: type: string description: >- - Coin defines a token with a denomination and an amount. + StakingInfo defines the staking info of a staker for a + token. + pagination: + 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 + description: >- + PageResponse is to be embedded in gRPC response messages where + the - NOTE: The amount field is an Int which implements the custom - method + corresponding request message has used PageRequest. - signatures required by gogoproto. + message SomeResponse { + repeated Bar results = 1; + PageResponse page = 2; + } description: >- - QueryRewardPoolResponse is response type for the Query/RewardPool - RPC method. + QueryStakingInfoAllResponse is response type for the + Query/AllStakingInfo RPC method. default: description: An unexpected error response. schema: @@ -57599,82 +57815,742 @@ paths: '@type': type: string additionalProperties: {} - tags: - - Query -definitions: - cosmos.auth.v1beta1.AddressBytesToStringResponse: - type: object - properties: - address_string: - type: string - description: >- - AddressBytesToStringResponse is the response type for AddressString rpc - method. - - - Since: cosmos-sdk 0.46 - cosmos.auth.v1beta1.AddressStringToBytesResponse: - type: object - properties: - address_bytes: - type: string - format: byte - description: >- - AddressStringToBytesResponse is the response type for AddressBytes rpc - method. - - - Since: cosmos-sdk 0.46 - cosmos.auth.v1beta1.BaseAccount: - type: object - properties: - address: - type: string - pub_key: - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of the - serialized - - protocol buffer message. This string must contain at least + parameters: + - name: token + 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. - one "/" character. The last segment of the URL's path must - represent + It is less efficient than using key. Only one of offset or key + should - the fully qualified name of the type (as in + 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. - `path/google.protobuf.Duration`). The name should be in a - canonical form + 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 - (e.g., leading "." is not accepted). + 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 - In practice, teams usually precompile into the binary all types - that they + 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. - 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 + Since: cosmos-sdk 0.43 + in: query + required: false + type: boolean + tags: + - Query + /titantkx/titan/farming/staking_info/{token}/{staker}: + get: + summary: StakingInfo queries the staking info of a staker for a token. + operationId: TitanFarmingStakingInfo + responses: + '200': + description: A successful response. + schema: + type: object + properties: + staking_info: + type: object + properties: + token: + type: string + staker: + type: string + amount: + type: string + description: StakingInfo defines the staking info of a staker for a token. + description: >- + QueryStakingInfoResponse is response type for the + Query/StakingInfo RPC method. + default: + description: An unexpected error response. + schema: + type: object + properties: + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + '@type': + type: string + additionalProperties: {} + parameters: + - name: token + in: path + required: true + type: string + - name: staker + in: path + required: true + type: string + tags: + - Query + /titantkx/titan/nftmint/minting_info: + get: + summary: MintingInfos queries a list of minting info. + operationId: TitanNftmintMintingInfos + responses: + '200': + description: A successful response. + schema: + type: object + properties: + minting_info: + type: array + items: + type: object + properties: + class_id: + type: string + description: class_id is a unique identifier of the class. + owner: + type: string + description: owner is the owner address of the class. + next_token_id: + type: string + format: uint64 + description: >- + next_token_id is the unique identifier of the next token + that will be - server that maps type URLs to message definitions as follows: + minted under this class. + description: MintingInfo defines the minting info for a class. + pagination: + 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 + description: >- + PageResponse is to be embedded in gRPC response messages where + the - * If no scheme is provided, `https` is assumed. + corresponding request message has used PageRequest. - * 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.) + message SomeResponse { + repeated Bar results = 1; + PageResponse page = 2; + } + description: >- + QueryMintingInfosResponse is response type for the + Query/QueryMintingInfos - Note: this functionality is not currently available in the + RPC method. + default: + description: An unexpected error response. + schema: + type: object + properties: + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + '@type': + type: string + additionalProperties: {} + parameters: + - name: pagination.key + description: |- + key is a value returned in PageResponse.next_key to begin + querying the next page most efficiently. Only one of offset or key + should be set. + in: query + required: false + type: string + format: byte + - name: pagination.offset + description: >- + offset is a numeric offset that can be used when key is unavailable. + + It is less efficient than using key. Only one of offset or key + should + + be set. + in: query + required: false + type: string + format: uint64 + - name: pagination.limit + description: >- + limit is the total number of results to be returned in the result + page. + + If left empty it will default to a value to be set by each app. + in: query + required: false + type: string + format: uint64 + - name: pagination.count_total + description: >- + count_total is set to true to indicate that the result set should + include + + a count of the total number of items available for pagination in + UIs. + + count_total is only respected when offset is used. It is ignored + when key + + is set. + in: query + required: false + type: boolean + - name: pagination.reverse + description: >- + reverse is set to true if results are to be returned in the + descending order. + + + Since: cosmos-sdk 0.43 + in: query + required: false + type: boolean + tags: + - Query + /titantkx/titan/nftmint/minting_info/{class_id}: + get: + summary: MintingInfo queries the minting info of a given class. + operationId: TitanNftmintMintingInfo + responses: + '200': + description: A successful response. + schema: + type: object + properties: + minting_info: + type: object + properties: + class_id: + type: string + description: class_id is a unique identifier of the class. + owner: + type: string + description: owner is the owner address of the class. + next_token_id: + type: string + format: uint64 + description: >- + next_token_id is the unique identifier of the next token + that will be + + minted under this class. + description: MintingInfo defines the minting info for a class. + description: >- + QueryMintingInfoResponse is response type for the + Query/QueryMintingInfo RPC + + method. + default: + description: An unexpected error response. + schema: + type: object + properties: + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + '@type': + type: string + additionalProperties: {} + parameters: + - name: class_id + in: path + required: true + type: string + tags: + - Query + /titantkx/titan/nftmint/params: + get: + summary: Parameters queries the parameters of the module. + operationId: TitanNftmintParams + responses: + '200': + description: A successful response. + schema: + type: object + properties: + params: + description: params holds all the parameters of this module. + type: object + description: >- + QueryParamsResponse is response type for the Query/Params RPC + method. + default: + description: An unexpected error response. + schema: + type: object + properties: + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + '@type': + type: string + additionalProperties: {} + tags: + - Query + /titantkx/titan/nftmint/system_info: + get: + summary: SystemInfo queries the system info of the module. + operationId: TitanNftmintSystemInfo + responses: + '200': + description: A successful response. + schema: + type: object + properties: + system_info: + type: object + properties: + next_class_id: + type: string + format: uint64 + description: >- + next_class_id is the unique identifier of the next class + that will be + + created. + description: SystemInfo defines the system info of this module. + description: >- + QuerySystemInfoResponse is response type for the + Query/QuerySystemInfo + + RPC method. + default: + description: An unexpected error response. + schema: + type: object + properties: + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + '@type': + type: string + additionalProperties: {} + tags: + - Query + /titan/tokenfactory/v1beta1/denoms/{denom}/authority_metadata: + get: + summary: |- + DenomAuthorityMetadata defines a gRPC query method for fetching + DenomAuthorityMetadata for a particular denom. + operationId: TitanTokenfactoryV1Beta1DenomAuthorityMetadata + responses: + '200': + description: A successful response. + schema: + type: object + properties: + authority_metadata: + type: object + properties: + admin: + type: string + title: Can be empty for no admin, or a valid titan address + description: >- + DenomAuthorityMetadata specifies metadata for addresses that + have specific + + capabilities over a token factory denom. Right now there is + only one Admin + + permission, but is planned to be extended to the future. + description: |- + QueryDenomAuthorityMetadataResponse is response type for the + Query/DenomAuthorityMetadata RPC method. + default: + description: An unexpected error response. + schema: + type: object + properties: + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + '@type': + type: string + additionalProperties: {} + parameters: + - name: denom + in: path + required: true + type: string + tags: + - Query + /titan/tokenfactory/v1beta1/denoms_from_creator/{creator}: + get: + summary: |- + DenomsFromCreator defines a gRPC query method for fetching all + denominations created by a specific admin/creator. + operationId: TitanTokenfactoryV1Beta1DenomsFromCreator + responses: + '200': + description: A successful response. + schema: + type: object + properties: + denoms: + type: array + items: + type: string + description: |- + QueryDenomsFromCreatorResponse is response type for the + Query/DenomsFromCreator RPC method. + default: + description: An unexpected error response. + schema: + type: object + properties: + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + '@type': + type: string + additionalProperties: {} + parameters: + - name: creator + in: path + required: true + type: string + tags: + - Query + /titan/tokenfactory/v1beta1/params: + get: + summary: >- + Params defines a gRPC query method that returns the tokenfactory + module's + + parameters. + operationId: TitanTokenfactoryV1Beta1Params + responses: + '200': + description: A successful response. + schema: + type: object + properties: + params: + description: params defines the parameters of the module. + type: object + properties: + denom_creation_fee: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an amount. + + + NOTE: The amount field is an Int which implements the + custom method + + signatures required by gogoproto. + description: >- + DenomCreationFee defines the fee to be charged on the + creation of a new + + denom. The fee is drawn from the MsgCreateDenom's sender + account, and + + transferred to the community pool. + denom_creation_gas_consume: + type: string + format: uint64 + description: >- + DenomCreationGasConsume defines the gas cost for creating + a new denom. + + This is intended as a spam deterrence mechanism. + + + See: https://github.com/CosmWasm/token-factory/issues/11 + description: >- + QueryParamsResponse is the response type for the Query/Params RPC + method. + default: + description: An unexpected error response. + schema: + type: object + properties: + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + '@type': + type: string + additionalProperties: {} + tags: + - Query + /titantkx/titan/validatorreward/params: + get: + summary: Parameters queries the parameters of the module. + operationId: TitanValidatorrewardParams + responses: + '200': + description: A successful response. + schema: + type: object + properties: + params: + description: params holds all the parameters of this module. + type: object + properties: + rate: + type: string + authority: + type: string + description: >- + QueryParamsResponse is response type for the Query/Params RPC + method. + default: + description: An unexpected error response. + schema: + type: object + properties: + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + '@type': + type: string + additionalProperties: {} + tags: + - Query + /titantkx/titan/validatorreward/reward_pool: + get: + summary: Queries a list of RewardPool items. + operationId: TitanValidatorrewardRewardPool + responses: + '200': + description: A successful response. + schema: + type: object + properties: + pool: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an amount. + + + NOTE: The amount field is an Int which implements the custom + method + + signatures required by gogoproto. + description: >- + QueryRewardPoolResponse is response type for the Query/RewardPool + RPC method. + default: + description: An unexpected error response. + schema: + type: object + properties: + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + '@type': + type: string + additionalProperties: {} + tags: + - Query +definitions: + cosmos.auth.v1beta1.AddressBytesToStringResponse: + type: object + properties: + address_string: + type: string + description: >- + AddressBytesToStringResponse is the response type for AddressString rpc + method. + + + Since: cosmos-sdk 0.46 + cosmos.auth.v1beta1.AddressStringToBytesResponse: + type: object + properties: + address_bytes: + type: string + format: byte + description: >- + AddressStringToBytesResponse is the response type for AddressBytes rpc + method. + + + Since: cosmos-sdk 0.46 + cosmos.auth.v1beta1.BaseAccount: + type: object + properties: + address: + type: string + pub_key: + type: object + properties: + '@type': + 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 @@ -88804,41 +89680,339 @@ definitions: representation of the deserialized, embedded message, with an - additional field `@type` which contains the type URL. Example: + 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" + } + client_id: + type: string + title: client ID associated with the consensus state + proof: + type: string + format: byte + title: merkle proof of existence + proof_height: + title: height at which the proof was retrieved + type: object + properties: + revision_number: + type: string + format: uint64 + title: the revision that the client is currently on + revision_height: + type: string + format: uint64 + title: the height within the given revision + description: >- + Normally the RevisionHeight is incremented at each height while + keeping + + RevisionNumber the same. However some consensus algorithms may choose + to + + reset the height in certain conditions e.g. hard forks, state-machine + + breaking changes In these cases, the RevisionNumber is incremented so + that + + height continues to be monitonically increasing even as the + RevisionHeight + + gets reset + title: |- + QueryConnectionConsensusStateResponse is the response type for the + Query/ConnectionConsensusState RPC method + ibc.core.connection.v1.QueryConnectionParamsResponse: + type: object + properties: + params: + description: params defines the parameters of the module. + type: object + properties: + max_expected_time_per_block: + type: string + format: uint64 + description: >- + maximum expected time per block (in nanoseconds), used to enforce + block delay. This parameter should reflect the + + largest amount of time that the chain might reasonably take to + produce the next block under normal operating + + conditions. A safe choice is 3-5x the expected time per block. + description: >- + QueryConnectionParamsResponse is the response type for the + Query/ConnectionParams RPC method. + ibc.core.connection.v1.QueryConnectionResponse: + type: object + properties: + connection: + title: connection associated with the request identifier + type: object + properties: + client_id: + type: string + description: client associated with this connection. + versions: + type: array + items: + type: object + properties: + identifier: + type: string + title: unique version identifier + features: + type: array + items: + type: string + title: list of features compatible with the specified identifier + description: >- + Version defines the versioning scheme used to negotiate the IBC + verison in + + the connection handshake. + description: >- + IBC version which can be utilised to determine encodings or + protocols for + + channels or packets utilising this connection. + state: + description: current state of the connection end. + type: string + enum: + - STATE_UNINITIALIZED_UNSPECIFIED + - STATE_INIT + - STATE_TRYOPEN + - STATE_OPEN + default: STATE_UNINITIALIZED_UNSPECIFIED + counterparty: + description: counterparty chain associated with this connection. + type: object + properties: + client_id: + type: string + description: >- + identifies the client on the counterparty chain associated + with a given + + connection. + connection_id: + type: string + description: >- + identifies the connection end on the counterparty chain + associated with a + + given connection. + prefix: + description: commitment merkle prefix of the counterparty chain. + type: object + properties: + key_prefix: + type: string + format: byte + title: >- + MerklePrefix is merkle path prefixed to the key. + + The constructed key from the Path and the key will be + append(Path.KeyPath, + + append(Path.KeyPrefix, key...)) + delay_period: + type: string + format: uint64 + description: >- + delay period that must pass before a consensus state can be used + for + + packet-verification NOTE: delay period logic is only implemented + by some + + clients. + description: >- + ConnectionEnd defines a stateful object on a chain connected to + another + + separate one. + + NOTE: there must only be 2 defined ConnectionEnds to establish + + a connection between two chains. + proof: + type: string + format: byte + title: merkle proof of existence + proof_height: + title: height at which the proof was retrieved + type: object + properties: + revision_number: + type: string + format: uint64 + title: the revision that the client is currently on + revision_height: + type: string + format: uint64 + title: the height within the given revision + description: >- + Normally the RevisionHeight is incremented at each height while + keeping + + RevisionNumber the same. However some consensus algorithms may choose + to + + reset the height in certain conditions e.g. hard forks, state-machine + + breaking changes In these cases, the RevisionNumber is incremented so + that + + height continues to be monitonically increasing even as the + RevisionHeight + + gets reset + description: >- + QueryConnectionResponse is the response type for the Query/Connection RPC + + method. Besides the connection end, it includes a proof and the height + from + + which the proof was retrieved. + ibc.core.connection.v1.QueryConnectionsResponse: + type: object + properties: + connections: + type: array + items: + type: object + properties: + id: + type: string + description: connection identifier. + client_id: + type: string + description: client associated with this connection. + versions: + type: array + items: + type: object + properties: + identifier: + type: string + title: unique version identifier + features: + type: array + items: + type: string + title: list of features compatible with the specified identifier + description: >- + Version defines the versioning scheme used to negotiate the + IBC verison in + + the connection handshake. + title: >- + IBC version which can be utilised to determine encodings or + protocols for - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } + channels or packets utilising this connection + state: + description: current state of the connection end. + type: string + enum: + - STATE_UNINITIALIZED_UNSPECIFIED + - STATE_INIT + - STATE_TRYOPEN + - STATE_OPEN + default: STATE_UNINITIALIZED_UNSPECIFIED + counterparty: + description: counterparty chain associated with this connection. + type: object + properties: + client_id: + type: string + description: >- + identifies the client on the counterparty chain associated + with a given - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } + connection. + connection_id: + type: string + description: >- + identifies the connection end on the counterparty chain + associated with a - If the embedded message type is well-known and has a custom JSON + given connection. + prefix: + description: commitment merkle prefix of the counterparty chain. + type: object + properties: + key_prefix: + type: string + format: byte + title: >- + MerklePrefix is merkle path prefixed to the key. - representation, that representation will be embedded adding a field + The constructed key from the Path and the key will be + append(Path.KeyPath, - `value` which holds the custom JSON in addition to the `@type` + append(Path.KeyPrefix, key...)) + delay_period: + type: string + format: uint64 + description: delay period associated with this connection. + description: |- + IdentifiedConnection defines a connection with additional connection + identifier field. + description: list of stored connections of the chain. + pagination: + title: pagination 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 - field. Example (for message [google.protobuf.Duration][]): + was set, its value is undefined otherwise + description: |- + PageResponse is to be embedded in gRPC response messages where the + corresponding request message has used PageRequest. - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - client_id: - type: string - title: client ID associated with the consensus state - proof: - type: string - format: byte - title: merkle proof of existence - proof_height: - title: height at which the proof was retrieved + message SomeResponse { + repeated Bar results = 1; + PageResponse page = 2; + } + height: + title: query block height type: object properties: revision_number: @@ -88858,258 +90032,387 @@ definitions: reset the height in certain conditions e.g. hard forks, state-machine - breaking changes In these cases, the RevisionNumber is incremented so - that + breaking changes In these cases, the RevisionNumber is incremented so + that + + height continues to be monitonically increasing even as the + RevisionHeight + + gets reset + description: >- + QueryConnectionsResponse is the response type for the Query/Connections + RPC + + method. + ibc.core.connection.v1.State: + type: string + enum: + - STATE_UNINITIALIZED_UNSPECIFIED + - STATE_INIT + - STATE_TRYOPEN + - STATE_OPEN + default: STATE_UNINITIALIZED_UNSPECIFIED + description: |- + State defines if a connection is in one of the following states: + INIT, TRYOPEN, OPEN or UNINITIALIZED. + + - STATE_UNINITIALIZED_UNSPECIFIED: Default State + - STATE_INIT: A connection end has just started the opening handshake. + - STATE_TRYOPEN: A connection end has acknowledged the handshake step on the counterparty + chain. + - STATE_OPEN: A connection end has completed the handshake. + ibc.core.connection.v1.Version: + type: object + properties: + identifier: + type: string + title: unique version identifier + features: + type: array + items: + type: string + title: list of features compatible with the specified identifier + description: |- + Version defines the versioning scheme used to negotiate the IBC verison in + the connection handshake. + packetforward.v1.MsgUpdateParamsResponse: + type: object + description: |- + MsgUpdateParamsResponse defines the response structure for executing a + MsgUpdateParams message. + + Since: cosmos-sdk 0.47 + packetforward.v1.Params: + type: object + properties: + fee_percentage: + type: string + description: Params defines the set of packetforward parameters. + packetforward.v1.QueryParamsResponse: + type: object + properties: + params: + description: params defines the parameters of the module. + type: object + properties: + fee_percentage: + type: string + description: QueryParamsResponse is the response type for the Query/Params RPC method. + titan.farming.DistributionInfo: + type: object + properties: + last_distribution_time: + type: string + format: date-time + description: DistributionInfo defines the reward distribution info. + titan.farming.Farm: + type: object + properties: + token: + type: string + rewards: + type: array + items: + type: object + properties: + sender: + type: string + amount: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an amount. + + + NOTE: The amount field is an Int which implements the custom + method + + signatures required by gogoproto. + end_time: + type: string + format: date-time + start_time: + type: string + format: date-time + description: FarmReward defines the farming rewards. + description: Farm defines the farming rewards for a token. + titan.farming.FarmReward: + type: object + properties: + sender: + type: string + amount: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: |- + Coin defines a token with a denomination and an amount. + + NOTE: The amount field is an Int which implements the custom method + signatures required by gogoproto. + end_time: + type: string + format: date-time + start_time: + type: string + format: date-time + description: FarmReward defines the farming rewards. + titan.farming.MsgAddRewardResponse: + type: object + description: MsgAddRewardResponse defines the Msg/AddReward response type. + titan.farming.MsgHarvestResponse: + type: object + description: MsgHarvestResponse defines the Msg/Harvest response type. + titan.farming.MsgStakeResponse: + type: object + description: MsgStakeResponse defines the Msg/Stake response type. + titan.farming.MsgUnstakeResponse: + type: object + description: MsgUnstakeResponse defines the Msg/Unstake response type. + titan.farming.Params: + type: object + description: Params defines the parameters for the module. + titan.farming.QueryDistributionInfoResponse: + type: object + properties: + distribution_info: + type: object + properties: + last_distribution_time: + type: string + format: date-time + description: DistributionInfo defines the reward distribution info. + description: >- + QueryDistributionInfoResponse is response type for the + Query/DistributionInfo RPC method. + titan.farming.QueryFarmAllResponse: + type: object + properties: + farm: + type: array + items: + type: object + properties: + token: + type: string + rewards: + type: array + items: + type: object + properties: + sender: + type: string + amount: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an amount. + - height continues to be monitonically increasing even as the - RevisionHeight + NOTE: The amount field is an Int which implements the + custom method - gets reset - title: |- - QueryConnectionConsensusStateResponse is the response type for the - Query/ConnectionConsensusState RPC method - ibc.core.connection.v1.QueryConnectionParamsResponse: - type: object - properties: - params: - description: params defines the parameters of the module. + signatures required by gogoproto. + end_time: + type: string + format: date-time + start_time: + type: string + format: date-time + description: FarmReward defines the farming rewards. + description: Farm defines the farming rewards for a token. + pagination: type: object properties: - max_expected_time_per_block: + 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 - description: >- - maximum expected time per block (in nanoseconds), used to enforce - block delay. This parameter should reflect the + title: >- + total is total number of results available if + PageRequest.count_total - largest amount of time that the chain might reasonably take to - produce the next block under normal operating + was set, its value is undefined otherwise + description: |- + PageResponse is to be embedded in gRPC response messages where the + corresponding request message has used PageRequest. - conditions. A safe choice is 3-5x the expected time per block. - description: >- - QueryConnectionParamsResponse is the response type for the - Query/ConnectionParams RPC method. - ibc.core.connection.v1.QueryConnectionResponse: + message SomeResponse { + repeated Bar results = 1; + PageResponse page = 2; + } + description: QueryFarmAllResponse is response type for the Query/AllFarm RPC method. + titan.farming.QueryFarmResponse: type: object properties: - connection: - title: connection associated with the request identifier + farm: type: object properties: - client_id: + token: type: string - description: client associated with this connection. - versions: + rewards: type: array items: type: object properties: - identifier: + sender: type: string - title: unique version identifier - features: + amount: type: array items: - type: string - title: list of features compatible with the specified identifier - description: >- - Version defines the versioning scheme used to negotiate the IBC - verison in - - the connection handshake. - description: >- - IBC version which can be utilised to determine encodings or - protocols for - - channels or packets utilising this connection. - state: - description: current state of the connection end. - type: string - enum: - - STATE_UNINITIALIZED_UNSPECIFIED - - STATE_INIT - - STATE_TRYOPEN - - STATE_OPEN - default: STATE_UNINITIALIZED_UNSPECIFIED - counterparty: - description: counterparty chain associated with this connection. - type: object - properties: - client_id: - type: string - description: >- - identifies the client on the counterparty chain associated - with a given - - connection. - connection_id: - type: string - description: >- - identifies the connection end on the counterparty chain - associated with a - - given connection. - prefix: - description: commitment merkle prefix of the counterparty chain. - type: object - properties: - key_prefix: - type: string - format: byte - title: >- - MerklePrefix is merkle path prefixed to the key. - - The constructed key from the Path and the key will be - append(Path.KeyPath, - - append(Path.KeyPrefix, key...)) - delay_period: - type: string - format: uint64 - description: >- - delay period that must pass before a consensus state can be used - for - - packet-verification NOTE: delay period logic is only implemented - by some - - clients. - description: >- - ConnectionEnd defines a stateful object on a chain connected to - another + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an amount. - separate one. - NOTE: there must only be 2 defined ConnectionEnds to establish + NOTE: The amount field is an Int which implements the + custom method - a connection between two chains. - proof: - type: string - format: byte - title: merkle proof of existence - proof_height: - title: height at which the proof was retrieved + signatures required by gogoproto. + end_time: + type: string + format: date-time + start_time: + type: string + format: date-time + description: FarmReward defines the farming rewards. + description: Farm defines the farming rewards for a token. + description: QueryFarmResponse is response type for the Query/Farm RPC method. + titan.farming.QueryParamsResponse: + type: object + properties: + params: + description: params holds all the parameters of this module. type: object - properties: - revision_number: - type: string - format: uint64 - title: the revision that the client is currently on - revision_height: - type: string - format: uint64 - title: the height within the given revision - description: >- - Normally the RevisionHeight is incremented at each height while - keeping - - RevisionNumber the same. However some consensus algorithms may choose - to - - reset the height in certain conditions e.g. hard forks, state-machine - - breaking changes In these cases, the RevisionNumber is incremented so - that - - height continues to be monitonically increasing even as the - RevisionHeight - - gets reset - description: >- - QueryConnectionResponse is the response type for the Query/Connection RPC - - method. Besides the connection end, it includes a proof and the height - from - - which the proof was retrieved. - ibc.core.connection.v1.QueryConnectionsResponse: + description: QueryParamsResponse is response type for the Query/Params RPC method. + titan.farming.QueryRewardAllResponse: type: object properties: - connections: + reward: type: array items: type: object properties: - id: + farmer: type: string - description: connection identifier. - client_id: - type: string - description: client associated with this connection. - versions: + amount: type: array items: type: object properties: - identifier: + denom: + type: string + amount: type: string - title: unique version identifier - features: - type: array - items: - type: string - title: list of features compatible with the specified identifier description: >- - Version defines the versioning scheme used to negotiate the - IBC verison in + Coin defines a token with a denomination and an amount. - the connection handshake. - title: >- - IBC version which can be utilised to determine encodings or - protocols for - channels or packets utilising this connection - state: - description: current state of the connection end. - type: string - enum: - - STATE_UNINITIALIZED_UNSPECIFIED - - STATE_INIT - - STATE_TRYOPEN - - STATE_OPEN - default: STATE_UNINITIALIZED_UNSPECIFIED - counterparty: - description: counterparty chain associated with this connection. + NOTE: The amount field is an Int which implements the custom + method + + signatures required by gogoproto. + description: Reward defines the farming rewards of the farmer. + pagination: + 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 + description: |- + PageResponse is to be embedded in gRPC response messages where the + corresponding request message has used PageRequest. + + message SomeResponse { + repeated Bar results = 1; + PageResponse page = 2; + } + description: >- + QueryRewardAllResponse is response type for the Query/AllReward RPC + method. + titan.farming.QueryRewardResponse: + type: object + properties: + reward: + type: object + properties: + farmer: + type: string + amount: + type: array + items: type: object properties: - client_id: + denom: type: string - description: >- - identifies the client on the counterparty chain associated - with a given - - connection. - connection_id: + amount: type: string - description: >- - identifies the connection end on the counterparty chain - associated with a + description: >- + Coin defines a token with a denomination and an amount. - given connection. - prefix: - description: commitment merkle prefix of the counterparty chain. - type: object - properties: - key_prefix: - type: string - format: byte - title: >- - MerklePrefix is merkle path prefixed to the key. - The constructed key from the Path and the key will be - append(Path.KeyPath, + NOTE: The amount field is an Int which implements the custom + method - append(Path.KeyPrefix, key...)) - delay_period: + signatures required by gogoproto. + description: Reward defines the farming rewards of the farmer. + description: QueryRewardResponse is response type for the Query/Reward RPC method. + titan.farming.QueryStakingInfoAllResponse: + type: object + properties: + staking_info: + type: array + items: + type: object + properties: + token: type: string - format: uint64 - description: delay period associated with this connection. - description: |- - IdentifiedConnection defines a connection with additional connection - identifier field. - description: list of stored connections of the chain. + staker: + type: string + amount: + type: string + description: StakingInfo defines the staking info of a staker for a token. pagination: - title: pagination response type: object properties: next_key: @@ -89135,93 +90438,55 @@ definitions: repeated Bar results = 1; PageResponse page = 2; } - height: - title: query block height + description: >- + QueryStakingInfoAllResponse is response type for the Query/AllStakingInfo + RPC method. + titan.farming.QueryStakingInfoResponse: + type: object + properties: + staking_info: type: object properties: - revision_number: + token: type: string - format: uint64 - title: the revision that the client is currently on - revision_height: + staker: type: string - format: uint64 - title: the height within the given revision - description: >- - Normally the RevisionHeight is incremented at each height while - keeping - - RevisionNumber the same. However some consensus algorithms may choose - to - - reset the height in certain conditions e.g. hard forks, state-machine - - breaking changes In these cases, the RevisionNumber is incremented so - that - - height continues to be monitonically increasing even as the - RevisionHeight - - gets reset + amount: + type: string + description: StakingInfo defines the staking info of a staker for a token. description: >- - QueryConnectionsResponse is the response type for the Query/Connections - RPC - + QueryStakingInfoResponse is response type for the Query/StakingInfo RPC method. - ibc.core.connection.v1.State: - type: string - enum: - - STATE_UNINITIALIZED_UNSPECIFIED - - STATE_INIT - - STATE_TRYOPEN - - STATE_OPEN - default: STATE_UNINITIALIZED_UNSPECIFIED - description: |- - State defines if a connection is in one of the following states: - INIT, TRYOPEN, OPEN or UNINITIALIZED. - - - STATE_UNINITIALIZED_UNSPECIFIED: Default State - - STATE_INIT: A connection end has just started the opening handshake. - - STATE_TRYOPEN: A connection end has acknowledged the handshake step on the counterparty - chain. - - STATE_OPEN: A connection end has completed the handshake. - ibc.core.connection.v1.Version: + titan.farming.Reward: type: object properties: - identifier: + farmer: type: string - title: unique version identifier - features: + amount: type: array items: - type: string - title: list of features compatible with the specified identifier - description: |- - Version defines the versioning scheme used to negotiate the IBC verison in - the connection handshake. - packetforward.v1.MsgUpdateParamsResponse: - type: object - description: |- - MsgUpdateParamsResponse defines the response structure for executing a - MsgUpdateParams message. + type: object + properties: + denom: + type: string + amount: + type: string + description: |- + Coin defines a token with a denomination and an amount. - Since: cosmos-sdk 0.47 - packetforward.v1.Params: + NOTE: The amount field is an Int which implements the custom method + signatures required by gogoproto. + description: Reward defines the farming rewards of the farmer. + titan.farming.StakingInfo: type: object properties: - fee_percentage: + token: type: string - description: Params defines the set of packetforward parameters. - packetforward.v1.QueryParamsResponse: - type: object - properties: - params: - description: params defines the parameters of the module. - type: object - properties: - fee_percentage: - type: string - description: QueryParamsResponse is the response type for the Query/Params RPC method. + staker: + type: string + amount: + type: string + description: StakingInfo defines the staking info of a staker for a token. titan.nftmint.MintingInfo: type: object properties: @@ -89372,6 +90637,144 @@ definitions: next_class_id is the unique identifier of the next class that will be created. description: SystemInfo defines the system info of this module. + titan.tokenfactory.v1beta1.DenomAuthorityMetadata: + type: object + properties: + admin: + type: string + title: Can be empty for no admin, or a valid titan address + description: |- + DenomAuthorityMetadata specifies metadata for addresses that have specific + capabilities over a token factory denom. Right now there is only one Admin + permission, but is planned to be extended to the future. + titan.tokenfactory.v1beta1.MsgBurnResponse: + type: object + description: MsgMintResponse defines the Msg/Burn response type. + titan.tokenfactory.v1beta1.MsgChangeAdminResponse: + type: object + description: MsgMintResponse defines the Msg/ChangeAdmin response type. + titan.tokenfactory.v1beta1.MsgCreateDenomResponse: + type: object + properties: + new_token_denom: + type: string + description: MsgMintResponse defines the Msg/CreateDenom response type. + titan.tokenfactory.v1beta1.MsgMintResponse: + type: object + description: MsgMintResponse defines the Msg/Mint response type. + titan.tokenfactory.v1beta1.MsgSetDenomMetadataResponse: + type: object + description: MsgMintResponse defines the Msg/SetDenomMetadata response type. + titan.tokenfactory.v1beta1.MsgUpdateParamsResponse: + type: object + description: MsgUpdateParamsResponse defines the Msg/UpdateParams response type. + titan.tokenfactory.v1beta1.Params: + type: object + properties: + denom_creation_fee: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: |- + Coin defines a token with a denomination and an amount. + + NOTE: The amount field is an Int which implements the custom method + signatures required by gogoproto. + description: >- + DenomCreationFee defines the fee to be charged on the creation of a + new + + denom. The fee is drawn from the MsgCreateDenom's sender account, and + + transferred to the community pool. + denom_creation_gas_consume: + type: string + format: uint64 + description: |- + DenomCreationGasConsume defines the gas cost for creating a new denom. + This is intended as a spam deterrence mechanism. + + See: https://github.com/CosmWasm/token-factory/issues/11 + description: Params defines the parameters for the tokenfactory module. + titan.tokenfactory.v1beta1.QueryDenomAuthorityMetadataResponse: + type: object + properties: + authority_metadata: + type: object + properties: + admin: + type: string + title: Can be empty for no admin, or a valid titan address + description: >- + DenomAuthorityMetadata specifies metadata for addresses that have + specific + + capabilities over a token factory denom. Right now there is only one + Admin + + permission, but is planned to be extended to the future. + description: |- + QueryDenomAuthorityMetadataResponse is response type for the + Query/DenomAuthorityMetadata RPC method. + titan.tokenfactory.v1beta1.QueryDenomsFromCreatorResponse: + type: object + properties: + denoms: + type: array + items: + type: string + description: |- + QueryDenomsFromCreatorResponse is response type for the + Query/DenomsFromCreator RPC method. + titan.tokenfactory.v1beta1.QueryParamsResponse: + type: object + properties: + params: + description: params defines the parameters of the module. + type: object + properties: + denom_creation_fee: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an amount. + + + NOTE: The amount field is an Int which implements the custom + method + + signatures required by gogoproto. + description: >- + DenomCreationFee defines the fee to be charged on the creation of + a new + + denom. The fee is drawn from the MsgCreateDenom's sender account, + and + + transferred to the community pool. + denom_creation_gas_consume: + type: string + format: uint64 + description: >- + DenomCreationGasConsume defines the gas cost for creating a new + denom. + + This is intended as a spam deterrence mechanism. + + + See: https://github.com/CosmWasm/token-factory/issues/11 + description: QueryParamsResponse is the response type for the Query/Params RPC method. titan.validatorreward.MsgFundRewardPoolResponse: type: object description: MsgFundRewardPoolResponse defines the Msg/FundRewardPool response type. diff --git a/proto/titan/farming/distribution_info.proto b/proto/titan/farming/distribution_info.proto new file mode 100644 index 00000000..3ea806ef --- /dev/null +++ b/proto/titan/farming/distribution_info.proto @@ -0,0 +1,12 @@ +syntax = "proto3"; +package titan.farming; + +import "gogoproto/gogo.proto"; +import "google/protobuf/timestamp.proto"; + +option go_package = "github.com/titantkx/titan/x/farming/types"; + +// DistributionInfo defines the reward distribution info. +message DistributionInfo { + google.protobuf.Timestamp last_distribution_time = 1 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false]; +} diff --git a/proto/titan/farming/event.proto b/proto/titan/farming/event.proto new file mode 100644 index 00000000..aeb05563 --- /dev/null +++ b/proto/titan/farming/event.proto @@ -0,0 +1,57 @@ +syntax = "proto3"; +package titan.farming; + +import "amino/amino.proto"; +import "cosmos/base/v1beta1/coin.proto"; +import "cosmos_proto/cosmos.proto"; +import "gogoproto/gogo.proto"; +import "google/protobuf/timestamp.proto"; + +option go_package = "github.com/titantkx/titan/x/farming/types"; + +// EventAddReward is emitted on AddReward. +message EventAddReward { + string sender = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string token = 2; // Staking token + repeated cosmos.base.v1beta1.Coin amount = 3 [ + (gogoproto.nullable) = false, + (amino.dont_omitempty) = true, + (amino.encoding) = "legacy_coins", + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" + ]; // Reward amount + google.protobuf.Timestamp end_time = 4 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false]; + google.protobuf.Timestamp start_time = 5 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false]; +} + +// EventStake is emitted on Stake. +message EventStake { + string sender = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + repeated cosmos.base.v1beta1.Coin amount = 2 [ + (gogoproto.nullable) = false, + (amino.dont_omitempty) = true, + (amino.encoding) = "legacy_coins", + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" + ]; +} + +// EventUnstake is emitted on Unstake. +message EventUnstake { + string sender = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + repeated cosmos.base.v1beta1.Coin amount = 2 [ + (gogoproto.nullable) = false, + (amino.dont_omitempty) = true, + (amino.encoding) = "legacy_coins", + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" + ]; +} + +// EventHarvest is emitted on Harvest. +message EventHarvest { + string sender = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + repeated cosmos.base.v1beta1.Coin amount = 2 [ + (gogoproto.nullable) = false, + (amino.dont_omitempty) = true, + (amino.encoding) = "legacy_coins", + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" + ]; +} diff --git a/proto/titan/farming/farm.proto b/proto/titan/farming/farm.proto new file mode 100644 index 00000000..66909a9b --- /dev/null +++ b/proto/titan/farming/farm.proto @@ -0,0 +1,29 @@ +syntax = "proto3"; +package titan.farming; + +import "amino/amino.proto"; +import "cosmos/base/v1beta1/coin.proto"; +import "cosmos_proto/cosmos.proto"; +import "gogoproto/gogo.proto"; +import "google/protobuf/timestamp.proto"; + +option go_package = "github.com/titantkx/titan/x/farming/types"; + +// Farm defines the farming rewards for a token. +message Farm { + string token = 1; + repeated FarmReward rewards = 2; +} + +// FarmReward defines the farming rewards. +message FarmReward { + string sender = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + repeated cosmos.base.v1beta1.Coin amount = 2 [ + (gogoproto.nullable) = false, + (amino.dont_omitempty) = true, + (amino.encoding) = "legacy_coins", + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" + ]; + google.protobuf.Timestamp end_time = 3 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false]; + google.protobuf.Timestamp start_time = 4 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false]; +} diff --git a/proto/titan/farming/genesis.proto b/proto/titan/farming/genesis.proto new file mode 100644 index 00000000..ea67409b --- /dev/null +++ b/proto/titan/farming/genesis.proto @@ -0,0 +1,21 @@ +syntax = "proto3"; + +package titan.farming; + +import "gogoproto/gogo.proto"; +import "titan/farming/distribution_info.proto"; +import "titan/farming/farm.proto"; +import "titan/farming/params.proto"; +import "titan/farming/reward.proto"; +import "titan/farming/staking_info.proto"; + +option go_package = "github.com/titantkx/titan/x/farming/types"; + +// GenesisState defines the farming module's genesis state. +message GenesisState { + Params params = 1 [(gogoproto.nullable) = false]; + repeated Farm farm_list = 2 [(gogoproto.nullable) = false]; + repeated StakingInfo staking_info_list = 3 [(gogoproto.nullable) = false]; + DistributionInfo distribution_info = 4; + repeated Reward reward_list = 5 [(gogoproto.nullable) = false]; +} diff --git a/proto/titan/farming/params.proto b/proto/titan/farming/params.proto new file mode 100644 index 00000000..60b82333 --- /dev/null +++ b/proto/titan/farming/params.proto @@ -0,0 +1,11 @@ +syntax = "proto3"; +package titan.farming; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/titantkx/titan/x/farming/types"; + +// Params defines the parameters for the module. +message Params { + option (gogoproto.goproto_stringer) = false; +} diff --git a/proto/titan/farming/query.proto b/proto/titan/farming/query.proto new file mode 100644 index 00000000..6db02058 --- /dev/null +++ b/proto/titan/farming/query.proto @@ -0,0 +1,139 @@ +syntax = "proto3"; + +package titan.farming; + +import "cosmos/base/query/v1beta1/pagination.proto"; +import "cosmos_proto/cosmos.proto"; +import "gogoproto/gogo.proto"; +import "google/api/annotations.proto"; +import "titan/farming/distribution_info.proto"; +import "titan/farming/farm.proto"; +import "titan/farming/params.proto"; +import "titan/farming/reward.proto"; +import "titan/farming/staking_info.proto"; + +option go_package = "github.com/titantkx/titan/x/farming/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 = "/titantkx/titan/farming/params"; + } + + // Farm queries a farm. + rpc Farm(QueryFarmRequest) returns (QueryFarmResponse) { + option (google.api.http).get = "/titantkx/titan/farming/farm/{token}"; + } + + // FarmAll queries all farms. + rpc FarmAll(QueryFarmAllRequest) returns (QueryFarmAllResponse) { + option (google.api.http).get = "/titantkx/titan/farming/farm"; + } + + // StakingInfo queries the staking info of a staker for a token. + rpc StakingInfo(QueryStakingInfoRequest) returns (QueryStakingInfoResponse) { + option (google.api.http).get = "/titantkx/titan/farming/staking_info/{token}/{staker}"; + } + + // StakingInfoAll queries all staking info of a token. + rpc StakingInfoAll(QueryStakingInfoAllRequest) returns (QueryStakingInfoAllResponse) { + option (google.api.http).get = "/titantkx/titan/farming/staking_info/{token}"; + } + + // DistributionInfo queries the distribution info. + rpc DistributionInfo(QueryDistributionInfoRequest) returns (QueryDistributionInfoResponse) { + option (google.api.http).get = "/titantkx/titan/farming/distribution_info"; + } + + // Reward queries farming rewards of a farmer. + rpc Reward(QueryRewardRequest) returns (QueryRewardResponse) { + option (google.api.http).get = "/titantkx/titan/farming/reward/{farmer}"; + } + + // Reward queries all farming rewards. + rpc RewardAll(QueryRewardAllRequest) returns (QueryRewardAllResponse) { + option (google.api.http).get = "/titantkx/titan/farming/reward"; + } +} +// 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]; +} + +// QueryFarmRequest is request type for the Query/Farm RPC method. +message QueryFarmRequest { + string token = 1; +} + +// QueryFarmResponse is response type for the Query/Farm RPC method. +message QueryFarmResponse { + Farm farm = 1 [(gogoproto.nullable) = false]; +} + +// QueryFarmAllRequest is request type for the Query/AllFarm RPC method. +message QueryFarmAllRequest { + cosmos.base.query.v1beta1.PageRequest pagination = 1; +} + +// QueryFarmAllResponse is response type for the Query/AllFarm RPC method. +message QueryFarmAllResponse { + repeated Farm farm = 1 [(gogoproto.nullable) = false]; + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + +// QueryStakingInfoRequest is request type for the Query/StakingInfo RPC method. +message QueryStakingInfoRequest { + string token = 1; + string staker = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; +} + +// QueryStakingInfoResponse is response type for the Query/StakingInfo RPC method. +message QueryStakingInfoResponse { + StakingInfo staking_info = 1 [(gogoproto.nullable) = false]; +} + +// QueryStakingInfoAllRequest is request type for the Query/AllStakingInfo RPC method. +message QueryStakingInfoAllRequest { + string token = 1; + cosmos.base.query.v1beta1.PageRequest pagination = 2; +} + +// QueryStakingInfoAllResponse is response type for the Query/AllStakingInfo RPC method. +message QueryStakingInfoAllResponse { + repeated StakingInfo staking_info = 1 [(gogoproto.nullable) = false]; + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + +// QueryDistributionInfoRequest is request type for the Query/DistributionInfo RPC method. +message QueryDistributionInfoRequest {} + +// QueryDistributionInfoResponse is response type for the Query/DistributionInfo RPC method. +message QueryDistributionInfoResponse { + DistributionInfo distribution_info = 1 [(gogoproto.nullable) = false]; +} + +// QueryRewardRequest is request type for the Query/Reward RPC method. +message QueryRewardRequest { + string farmer = 1; +} + +// QueryRewardResponse is response type for the Query/Reward RPC method. +message QueryRewardResponse { + Reward reward = 1 [(gogoproto.nullable) = false]; +} + +// QueryRewardAllRequest is request type for the Query/AllReward RPC method. +message QueryRewardAllRequest { + cosmos.base.query.v1beta1.PageRequest pagination = 1; +} + +// QueryRewardAllResponse is response type for the Query/AllReward RPC method. +message QueryRewardAllResponse { + repeated Reward reward = 1 [(gogoproto.nullable) = false]; + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} diff --git a/proto/titan/farming/reward.proto b/proto/titan/farming/reward.proto new file mode 100644 index 00000000..6c737eae --- /dev/null +++ b/proto/titan/farming/reward.proto @@ -0,0 +1,20 @@ +syntax = "proto3"; +package titan.farming; + +import "amino/amino.proto"; +import "cosmos/base/v1beta1/coin.proto"; +import "cosmos_proto/cosmos.proto"; +import "gogoproto/gogo.proto"; + +option go_package = "github.com/titantkx/titan/x/farming/types"; + +// Reward defines the farming rewards of the farmer. +message Reward { + string farmer = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + repeated cosmos.base.v1beta1.Coin amount = 2 [ + (gogoproto.nullable) = false, + (amino.dont_omitempty) = true, + (amino.encoding) = "legacy_coins", + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" + ]; +} diff --git a/proto/titan/farming/staking_info.proto b/proto/titan/farming/staking_info.proto new file mode 100644 index 00000000..a1aac1ea --- /dev/null +++ b/proto/titan/farming/staking_info.proto @@ -0,0 +1,20 @@ +syntax = "proto3"; +package titan.farming; + +import "amino/amino.proto"; +import "cosmos_proto/cosmos.proto"; +import "gogoproto/gogo.proto"; + +option go_package = "github.com/titantkx/titan/x/farming/types"; + +// StakingInfo defines the staking info of a staker for a token. +message StakingInfo { + string token = 1; + string staker = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string amount = 3 [ + (cosmos_proto.scalar) = "cosmos.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", + (gogoproto.nullable) = false, + (amino.dont_omitempty) = true + ]; +} diff --git a/proto/titan/farming/tx.proto b/proto/titan/farming/tx.proto new file mode 100644 index 00000000..23b26df1 --- /dev/null +++ b/proto/titan/farming/tx.proto @@ -0,0 +1,79 @@ +syntax = "proto3"; + +package titan.farming; + +import "amino/amino.proto"; +import "cosmos/base/v1beta1/coin.proto"; +import "cosmos_proto/cosmos.proto"; +import "gogoproto/gogo.proto"; +import "google/protobuf/timestamp.proto"; + +option go_package = "github.com/titantkx/titan/x/farming/types"; + +// Msg defines the Msg service. +service Msg { + // AddReward defines a method to add farming rewards. + rpc AddReward(MsgAddReward) returns (MsgAddRewardResponse); + + // Stake defines a method to stake tokens. + rpc Stake(MsgStake) returns (MsgStakeResponse); + + // Unstake defines a method to unstake tokens. + rpc Unstake(MsgUnstake) returns (MsgUnstakeResponse); + + // Harvest defines a method to add harvest farming rewards. + rpc Harvest(MsgHarvest) returns (MsgHarvestResponse); +} + +// MsgStake represents a message to add farming rewards. +message MsgAddReward { + string sender = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string token = 2; // Staking token + repeated cosmos.base.v1beta1.Coin amount = 3 [ + (gogoproto.nullable) = false, + (amino.dont_omitempty) = true, + (amino.encoding) = "legacy_coins", + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" + ]; // Reward amount + google.protobuf.Timestamp end_time = 4 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false]; + google.protobuf.Timestamp start_time = 5 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false]; +} + +// MsgAddRewardResponse defines the Msg/AddReward response type. +message MsgAddRewardResponse {} + +// MsgStake represents a message to stake tokens. +message MsgStake { + string sender = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + repeated cosmos.base.v1beta1.Coin amount = 2 [ + (gogoproto.nullable) = false, + (amino.dont_omitempty) = true, + (amino.encoding) = "legacy_coins", + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" + ]; +} + +// MsgStakeResponse defines the Msg/Stake response type. +message MsgStakeResponse {} + +// MsgUnstake represents a message to unstake tokens. +message MsgUnstake { + string sender = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + repeated cosmos.base.v1beta1.Coin amount = 2 [ + (gogoproto.nullable) = false, + (amino.dont_omitempty) = true, + (amino.encoding) = "legacy_coins", + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" + ]; +} + +// MsgUnstakeResponse defines the Msg/Unstake response type. +message MsgUnstakeResponse {} + +// MsgHarvest represents a message to harvest farming rewards. +message MsgHarvest { + string sender = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; +} + +// MsgHarvestResponse defines the Msg/Harvest response type. +message MsgHarvestResponse {} diff --git a/scripts/mockgen.sh b/scripts/mockgen.sh index 5356ccc6..fcb6c888 100755 --- a/scripts/mockgen.sh +++ b/scripts/mockgen.sh @@ -8,3 +8,4 @@ $mockgen_cmd -source=x/gov/types/expected_keepers.go -package testutil -destinat $mockgen_cmd -source=x/validatorreward/types/expected_keepers.go -package testutil -destination x/validatorreward/testutil/expected_keepers_mocks.go $mockgen_cmd -source=x/nftmint/types/expected_keepers.go -package testutil -destination x/nftmint/testutil/expected_keepers_mocks.go $mockgen_cmd -source=x/tokenfactory/types/expected_keepers.go -package testutil -destination x/tokenfactory/testutil/expected_keepers_mocks.go +$mockgen_cmd -source=x/farming/types/expected_keepers.go -package testutil -destination x/farming/testutil/expected_keepers_mocks.go diff --git a/testutil/keeper/farming.go b/testutil/keeper/farming.go new file mode 100644 index 00000000..7b469b6f --- /dev/null +++ b/testutil/keeper/farming.go @@ -0,0 +1,57 @@ +package keeper + +import ( + "testing" + + 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" + "github.com/titantkx/titan/x/farming/keeper" + "github.com/titantkx/titan/x/farming/types" +) + +func FarmingKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) { + return FarmingKeeperWithMocks(t, nil) +} + +func FarmingKeeperWithMocks(t testing.TB, bankKeeper types.BankKeeper) (*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, + "FarmingParams", + ) + k := keeper.NewKeeper( + cdc, + storeKey, + memStoreKey, + paramsSubspace, + bankKeeper, + ) + + ctx := sdk.NewContext(stateStore, tmproto.Header{}, false, log.NewNopLogger()) + + // Initialize params + k.SetParams(ctx, types.DefaultParams()) + + return k, ctx +} diff --git a/testutil/sample/sample.go b/testutil/sample/sample.go index 422e1c7d..356b4d14 100644 --- a/testutil/sample/sample.go +++ b/testutil/sample/sample.go @@ -23,10 +23,6 @@ func ClassId() string { return strconv.FormatUint(mathrand.Uint64(), 10) } -func Number(min int, max int) int { - return mathrand.Intn(max-min+1) + min -} - func Name() string { return faker.Name() } diff --git a/x/farming/abci.go b/x/farming/abci.go new file mode 100644 index 00000000..82d7340a --- /dev/null +++ b/x/farming/abci.go @@ -0,0 +1,85 @@ +package farming + +import ( + "time" + + "cosmossdk.io/math" + abci "github.com/cometbft/cometbft/abci/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/titantkx/titan/x/farming/keeper" + "github.com/titantkx/titan/x/farming/types" +) + +// BeginBlocker add farming reward to stakers +func BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock, k keeper.Keeper) { + var lastDistributionTime time.Time + + distributionInfo, found := k.GetDistributionInfo(ctx) + if found { + lastDistributionTime = distributionInfo.LastDistributionTime + } + + farms := k.GetAllFarm(ctx) + + for _, farm := range farms { + stakingInfos := k.GetAllStakingInfo(ctx, farm.Token) + totalStakedAmount := math.NewInt(0) + + for _, stakingInfo := range stakingInfos { + totalStakedAmount = totalStakedAmount.Add(stakingInfo.Amount) + } + + var pendingRewards []*types.FarmReward + + for _, reward := range farm.Rewards { + if reward.StartTime.After(req.Header.Time) { + continue + } + + var totalDistributedRewardAmount sdk.Coins + + if !reward.EndTime.After(req.Header.Time) { + totalDistributedRewardAmount = reward.Amount + } else { + var beginRewardDistributionTime time.Time + + if lastDistributionTime.After(reward.StartTime) { + beginRewardDistributionTime = lastDistributionTime + } else { + beginRewardDistributionTime = reward.StartTime + } + + totalDistributedRewardAmount = reward.Amount. + MulInt(sdk.NewInt(int64(req.Header.Time.Sub(beginRewardDistributionTime)))). + QuoInt(sdk.NewInt(int64(reward.EndTime.Sub(beginRewardDistributionTime)))) + } + + for _, stakingInfo := range stakingInfos { + distributedRewardAmount := totalDistributedRewardAmount. + MulInt(stakingInfo.Amount). + QuoInt(totalStakedAmount) + + reward.Amount = reward.Amount.Sub(distributedRewardAmount...) + k.AddReward(ctx, stakingInfo.Staker, distributedRewardAmount) + } + + if reward.EndTime.After(req.Header.Time) { + pendingRewards = append(pendingRewards, reward) + } else if !reward.Amount.IsZero() { + // Refund unused rewards to the sender + k.AddReward(ctx, reward.Sender, reward.Amount) + } + } + + farm.Rewards = pendingRewards + + if len(farm.Rewards) == 0 { + k.RemoveFarm(ctx, farm.Token) + } else { + k.SetFarm(ctx, farm) + } + } + + distributionInfo.LastDistributionTime = req.Header.Time + k.SetDistributionInfo(ctx, distributionInfo) +} diff --git a/x/farming/client/cli/query.go b/x/farming/client/cli/query.go new file mode 100644 index 00000000..9b8fde6f --- /dev/null +++ b/x/farming/client/cli/query.go @@ -0,0 +1,38 @@ +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/titantkx/titan/x/farming/types" +) + +// GetQueryCmd returns the cli query commands for this module +func GetQueryCmd(_ string) *cobra.Command { + // Group farming queries under a subcommand + cmd := &cobra.Command{ + Use: types.ModuleName, + Short: fmt.Sprintf("Querying commands for the %s module", types.ModuleName), + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + cmd.AddCommand(CmdQueryParams()) + cmd.AddCommand(CmdListFarm()) + cmd.AddCommand(CmdShowFarm()) + cmd.AddCommand(CmdListStakingInfo()) + cmd.AddCommand(CmdShowStakingInfo()) + cmd.AddCommand(CmdShowDistributionInfo()) + cmd.AddCommand(CmdListReward()) + cmd.AddCommand(CmdShowReward()) + // this line is used by starport scaffolding # 1 + + return cmd +} diff --git a/x/farming/client/cli/query_distribution_info.go b/x/farming/client/cli/query_distribution_info.go new file mode 100644 index 00000000..8a73e120 --- /dev/null +++ b/x/farming/client/cli/query_distribution_info.go @@ -0,0 +1,38 @@ +package cli + +import ( + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/spf13/cobra" + + "github.com/titantkx/titan/x/farming/types" +) + +func CmdShowDistributionInfo() *cobra.Command { + cmd := &cobra.Command{ + Use: "show-distribution-info", + Short: "Show distribution info", + Args: cobra.NoArgs, + RunE: func(cmd *cobra.Command, _ []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + params := &types.QueryDistributionInfoRequest{} + + res, err := queryClient.DistributionInfo(cmd.Context(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/farming/client/cli/query_distribution_info_test.go b/x/farming/client/cli/query_distribution_info_test.go new file mode 100644 index 00000000..730bc1e5 --- /dev/null +++ b/x/farming/client/cli/query_distribution_info_test.go @@ -0,0 +1,67 @@ +package cli_test + +import ( + "fmt" + "testing" + + tmcli "github.com/cometbft/cometbft/libs/cli" + clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" + "github.com/stretchr/testify/require" + "google.golang.org/grpc/status" + + "github.com/titantkx/titan/testutil/network" + "github.com/titantkx/titan/testutil/nullify" + "github.com/titantkx/titan/x/farming/client/cli" + "github.com/titantkx/titan/x/farming/types" +) + +func networkWithDistributionInfoObjects(t *testing.T) (*network.Network, types.DistributionInfo) { + t.Helper() + cfg := network.DefaultConfig() + state := types.GenesisState{} + distributionInfo := &types.DistributionInfo{} + nullify.Fill(&distributionInfo) + state.DistributionInfo = distributionInfo + buf, err := cfg.Codec.MarshalJSON(&state) + require.NoError(t, err) + cfg.GenesisState[types.ModuleName] = buf + return network.New(t, cfg), *state.DistributionInfo +} + +func TestShowDistributionInfo(t *testing.T) { + net, obj := networkWithDistributionInfoObjects(t) + + ctx := net.Validators[0].ClientCtx + common := []string{ + fmt.Sprintf("--%s=json", tmcli.OutputFlag), + } + tests := []struct { + desc string + args []string + err error + obj types.DistributionInfo + }{ + { + desc: "get", + args: common, + obj: obj, + }, + } + for _, tc := range tests { + t.Run(tc.desc, func(t *testing.T) { + var args []string + args = append(args, tc.args...) + out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdShowDistributionInfo(), args) + if tc.err != nil { + stat, ok := status.FromError(tc.err) + require.True(t, ok) + require.ErrorIs(t, stat.Err(), tc.err) + } else { + require.NoError(t, err) + var resp types.QueryDistributionInfoResponse + require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) + require.NotNil(t, resp.DistributionInfo) + } + }) + } +} diff --git a/x/farming/client/cli/query_farm.go b/x/farming/client/cli/query_farm.go new file mode 100644 index 00000000..4523f4b1 --- /dev/null +++ b/x/farming/client/cli/query_farm.go @@ -0,0 +1,79 @@ +//nolint:dupl +package cli + +import ( + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/spf13/cobra" + + "github.com/titantkx/titan/x/farming/types" +) + +func CmdListFarm() *cobra.Command { + cmd := &cobra.Command{ + Use: "list-farm", + Short: "List all farms", + RunE: func(cmd *cobra.Command, _ []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + pageReq, err := client.ReadPageRequest(cmd.Flags()) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + params := &types.QueryFarmAllRequest{ + Pagination: pageReq, + } + + res, err := queryClient.FarmAll(cmd.Context(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddPaginationFlagsToCmd(cmd, cmd.Use) + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +func CmdShowFarm() *cobra.Command { + cmd := &cobra.Command{ + Use: "show-farm [token]", + Short: "Show a farm", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) (err error) { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + argToken := args[0] + + params := &types.QueryFarmRequest{ + Token: argToken, + } + + res, err := queryClient.Farm(cmd.Context(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/farming/client/cli/query_farm_test.go b/x/farming/client/cli/query_farm_test.go new file mode 100644 index 00000000..dc44301a --- /dev/null +++ b/x/farming/client/cli/query_farm_test.go @@ -0,0 +1,173 @@ +//nolint:dupl +package cli_test + +import ( + "fmt" + "strconv" + "testing" + "time" + + tmcli "github.com/cometbft/cometbft/libs/cli" + "github.com/cosmos/cosmos-sdk/client/flags" + clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + "github.com/titantkx/titan/testutil/network" + "github.com/titantkx/titan/testutil/nullify" + "github.com/titantkx/titan/testutil/sample" + "github.com/titantkx/titan/x/farming/client/cli" + "github.com/titantkx/titan/x/farming/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +// Prevent strconv unused error +var _ = strconv.IntSize + +func networkWithFarmObjects(t *testing.T, n int) (*network.Network, []types.Farm) { + t.Helper() + cfg := network.DefaultConfig() + state := types.GenesisState{} + for i := 0; i < n; i++ { + farm := types.Farm{ + Token: strconv.Itoa(i), + Rewards: []*types.FarmReward{ + { + Sender: sample.AccAddress().String(), + Amount: sdk.NewCoins(sdk.NewCoin("tkx", sdk.NewInt(1000))), + EndTime: time.Now().Add(1 * time.Hour), + StartTime: time.Now(), + }, + }, + } + state.FarmList = append(state.FarmList, farm) + } + buf, err := cfg.Codec.MarshalJSON(&state) + require.NoError(t, err) + cfg.GenesisState[types.ModuleName] = buf + return network.New(t, cfg), state.FarmList +} + +func TestShowFarm(t *testing.T) { + net, objs := networkWithFarmObjects(t, 2) + + ctx := net.Validators[0].ClientCtx + common := []string{ + fmt.Sprintf("--%s=json", tmcli.OutputFlag), + } + tests := []struct { + desc string + idToken string + + args []string + err error + obj types.Farm + }{ + { + desc: "found", + idToken: objs[0].Token, + + args: common, + obj: objs[0], + }, + { + desc: "not found", + idToken: strconv.Itoa(100000), + + args: common, + err: status.Error(codes.NotFound, "not found"), + }, + } + for _, tc := range tests { + t.Run(tc.desc, func(t *testing.T) { + args := []string{ + tc.idToken, + } + args = append(args, tc.args...) + out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdShowFarm(), args) + if tc.err != nil { + stat, ok := status.FromError(tc.err) + require.True(t, ok) + require.ErrorIs(t, stat.Err(), tc.err) + } else { + require.NoError(t, err) + var resp types.QueryFarmResponse + require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) + require.NotNil(t, resp.Farm) + require.Equal(t, + nullify.Fill(&tc.obj), + nullify.Fill(&resp.Farm), + ) + } + }) + } +} + +func TestListFarm(t *testing.T) { + net, objs := networkWithFarmObjects(t, 5) + + ctx := net.Validators[0].ClientCtx + request := func(next []byte, offset, limit uint64, total bool) []string { + args := []string{ + fmt.Sprintf("--%s=json", tmcli.OutputFlag), + } + if next == nil { + args = append(args, fmt.Sprintf("--%s=%d", flags.FlagOffset, offset)) + } else { + args = append(args, fmt.Sprintf("--%s=%s", flags.FlagPageKey, next)) + } + args = append(args, fmt.Sprintf("--%s=%d", flags.FlagLimit, limit)) + if total { + args = append(args, fmt.Sprintf("--%s", flags.FlagCountTotal)) + } + return args + } + t.Run("ByOffset", func(t *testing.T) { + step := 2 + for i := 0; i < len(objs); i += step { + //nolint:gosec // G115 + args := request(nil, uint64(i), uint64(step), false) + out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdListFarm(), args) + require.NoError(t, err) + var resp types.QueryFarmAllResponse + require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) + require.LessOrEqual(t, len(resp.Farm), step) + require.Subset(t, + nullify.Fill(objs), + nullify.Fill(resp.Farm), + ) + } + }) + t.Run("ByKey", func(t *testing.T) { + step := 2 + var next []byte + for i := 0; i < len(objs); i += step { + //nolint:gosec // G115 + args := request(next, 0, uint64(step), false) + out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdListFarm(), args) + require.NoError(t, err) + var resp types.QueryFarmAllResponse + require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) + require.LessOrEqual(t, len(resp.Farm), step) + require.Subset(t, + nullify.Fill(objs), + nullify.Fill(resp.Farm), + ) + next = resp.Pagination.NextKey + } + }) + t.Run("Total", func(t *testing.T) { + args := request(nil, 0, uint64(len(objs)), true) + out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdListFarm(), args) + require.NoError(t, err) + var resp types.QueryFarmAllResponse + require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) + require.NoError(t, err) + //nolint:gosec // G115 + require.Equal(t, len(objs), int(resp.Pagination.Total)) + require.ElementsMatch(t, + nullify.Fill(objs), + nullify.Fill(resp.Farm), + ) + }) +} diff --git a/x/farming/client/cli/query_params.go b/x/farming/client/cli/query_params.go new file mode 100644 index 00000000..db0eee37 --- /dev/null +++ b/x/farming/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/titantkx/titan/x/farming/types" +) + +func CmdQueryParams() *cobra.Command { + cmd := &cobra.Command{ + Use: "params", + Short: "Show the parameters of the module", + Args: cobra.NoArgs, + RunE: func(cmd *cobra.Command, _ []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/farming/client/cli/query_reward.go b/x/farming/client/cli/query_reward.go new file mode 100644 index 00000000..0bf1dc40 --- /dev/null +++ b/x/farming/client/cli/query_reward.go @@ -0,0 +1,79 @@ +//nolint:dupl +package cli + +import ( + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/spf13/cobra" + + "github.com/titantkx/titan/x/farming/types" +) + +func CmdListReward() *cobra.Command { + cmd := &cobra.Command{ + Use: "list-reward", + Short: "List all rewards", + RunE: func(cmd *cobra.Command, _ []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + pageReq, err := client.ReadPageRequest(cmd.Flags()) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + params := &types.QueryRewardAllRequest{ + Pagination: pageReq, + } + + res, err := queryClient.RewardAll(cmd.Context(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddPaginationFlagsToCmd(cmd, cmd.Use) + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +func CmdShowReward() *cobra.Command { + cmd := &cobra.Command{ + Use: "show-reward [farmer]", + Short: "Show rewards of a farmer", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) (err error) { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + argFarmer := args[0] + + params := &types.QueryRewardRequest{ + Farmer: argFarmer, + } + + res, err := queryClient.Reward(cmd.Context(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/farming/client/cli/query_reward_test.go b/x/farming/client/cli/query_reward_test.go new file mode 100644 index 00000000..0186f287 --- /dev/null +++ b/x/farming/client/cli/query_reward_test.go @@ -0,0 +1,164 @@ +//nolint:dupl +package cli_test + +import ( + "fmt" + "strconv" + "testing" + + tmcli "github.com/cometbft/cometbft/libs/cli" + "github.com/cosmos/cosmos-sdk/client/flags" + clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" + "github.com/stretchr/testify/require" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + "github.com/titantkx/titan/testutil/network" + "github.com/titantkx/titan/testutil/nullify" + "github.com/titantkx/titan/x/farming/client/cli" + "github.com/titantkx/titan/x/farming/types" +) + +// Prevent strconv unused error +var _ = strconv.IntSize + +func networkWithRewardObjects(t *testing.T, n int) (*network.Network, []types.Reward) { + t.Helper() + cfg := network.DefaultConfig() + state := types.GenesisState{} + for i := 0; i < n; i++ { + reward := types.Reward{ + Farmer: strconv.Itoa(i), + } + nullify.Fill(&reward) + state.RewardList = append(state.RewardList, reward) + } + buf, err := cfg.Codec.MarshalJSON(&state) + require.NoError(t, err) + cfg.GenesisState[types.ModuleName] = buf + return network.New(t, cfg), state.RewardList +} + +func TestShowReward(t *testing.T) { + net, objs := networkWithRewardObjects(t, 2) + + ctx := net.Validators[0].ClientCtx + common := []string{ + fmt.Sprintf("--%s=json", tmcli.OutputFlag), + } + tests := []struct { + desc string + idFarmer string + + args []string + err error + obj types.Reward + }{ + { + desc: "found", + idFarmer: objs[0].Farmer, + + args: common, + obj: objs[0], + }, + { + desc: "not found", + idFarmer: strconv.Itoa(100000), + + args: common, + err: status.Error(codes.NotFound, "not found"), + }, + } + for _, tc := range tests { + t.Run(tc.desc, func(t *testing.T) { + args := []string{ + tc.idFarmer, + } + args = append(args, tc.args...) + out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdShowReward(), args) + if tc.err != nil { + stat, ok := status.FromError(tc.err) + require.True(t, ok) + require.ErrorIs(t, stat.Err(), tc.err) + } else { + require.NoError(t, err) + var resp types.QueryRewardResponse + require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) + require.NotNil(t, resp.Reward) + require.Equal(t, + nullify.Fill(&tc.obj), + nullify.Fill(&resp.Reward), + ) + } + }) + } +} + +func TestListReward(t *testing.T) { + net, objs := networkWithRewardObjects(t, 5) + + ctx := net.Validators[0].ClientCtx + request := func(next []byte, offset, limit uint64, total bool) []string { + args := []string{ + fmt.Sprintf("--%s=json", tmcli.OutputFlag), + } + if next == nil { + args = append(args, fmt.Sprintf("--%s=%d", flags.FlagOffset, offset)) + } else { + args = append(args, fmt.Sprintf("--%s=%s", flags.FlagPageKey, next)) + } + args = append(args, fmt.Sprintf("--%s=%d", flags.FlagLimit, limit)) + if total { + args = append(args, fmt.Sprintf("--%s", flags.FlagCountTotal)) + } + return args + } + t.Run("ByOffset", func(t *testing.T) { + step := 2 + for i := 0; i < len(objs); i += step { + //nolint:gosec // G115 + args := request(nil, uint64(i), uint64(step), false) + out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdListReward(), args) + require.NoError(t, err) + var resp types.QueryRewardAllResponse + require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) + require.LessOrEqual(t, len(resp.Reward), step) + require.Subset(t, + nullify.Fill(objs), + nullify.Fill(resp.Reward), + ) + } + }) + t.Run("ByKey", func(t *testing.T) { + step := 2 + var next []byte + for i := 0; i < len(objs); i += step { + //nolint:gosec // G115 + args := request(next, 0, uint64(step), false) + out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdListReward(), args) + require.NoError(t, err) + var resp types.QueryRewardAllResponse + require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) + require.LessOrEqual(t, len(resp.Reward), step) + require.Subset(t, + nullify.Fill(objs), + nullify.Fill(resp.Reward), + ) + next = resp.Pagination.NextKey + } + }) + t.Run("Total", func(t *testing.T) { + args := request(nil, 0, uint64(len(objs)), true) + out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdListReward(), args) + require.NoError(t, err) + var resp types.QueryRewardAllResponse + require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) + require.NoError(t, err) + //nolint:gosec // G115 + require.Equal(t, len(objs), int(resp.Pagination.Total)) + require.ElementsMatch(t, + nullify.Fill(objs), + nullify.Fill(resp.Reward), + ) + }) +} diff --git a/x/farming/client/cli/query_staking_info.go b/x/farming/client/cli/query_staking_info.go new file mode 100644 index 00000000..126b92ec --- /dev/null +++ b/x/farming/client/cli/query_staking_info.go @@ -0,0 +1,87 @@ +package cli + +import ( + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/spf13/cobra" + + "github.com/titantkx/titan/x/farming/types" +) + +func CmdListStakingInfo() *cobra.Command { + cmd := &cobra.Command{ + Use: "list-staking-info [token]", + Short: "List all staking info of a token", + Args: cobra.RangeArgs(0, 1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + pageReq, err := client.ReadPageRequest(cmd.Flags()) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + var argToken string + if len(args) > 0 { + argToken = args[0] + } + + params := &types.QueryStakingInfoAllRequest{ + Token: argToken, + Pagination: pageReq, + } + + res, err := queryClient.StakingInfoAll(cmd.Context(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddPaginationFlagsToCmd(cmd, cmd.Use) + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +func CmdShowStakingInfo() *cobra.Command { + cmd := &cobra.Command{ + Use: "show-staking-info [token] [staker]", + Short: "Show staking info of a staker for a token", + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) (err error) { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + argToken := args[0] + argStaker := args[1] + + params := &types.QueryStakingInfoRequest{ + Token: argToken, + Staker: argStaker, + } + + res, err := queryClient.StakingInfo(cmd.Context(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/farming/client/cli/query_staking_info_test.go b/x/farming/client/cli/query_staking_info_test.go new file mode 100644 index 00000000..f3970187 --- /dev/null +++ b/x/farming/client/cli/query_staking_info_test.go @@ -0,0 +1,171 @@ +//nolint:dupl +package cli_test + +import ( + "fmt" + "strconv" + "testing" + + "cosmossdk.io/math" + tmcli "github.com/cometbft/cometbft/libs/cli" + "github.com/cosmos/cosmos-sdk/client/flags" + clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" + "github.com/stretchr/testify/require" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + "github.com/titantkx/titan/testutil/network" + "github.com/titantkx/titan/testutil/nullify" + "github.com/titantkx/titan/x/farming/client/cli" + "github.com/titantkx/titan/x/farming/types" +) + +// Prevent strconv unused error +var _ = strconv.IntSize + +func networkWithStakingInfoObjects(t *testing.T, n int) (*network.Network, []types.StakingInfo) { + t.Helper() + cfg := network.DefaultConfig() + state := types.GenesisState{} + for i := 0; i < n; i++ { + stakingInfo := types.StakingInfo{ + Token: strconv.Itoa(i), + Staker: strconv.Itoa(i), + Amount: math.NewInt(int64(i)), + } + nullify.Fill(&stakingInfo) + state.StakingInfoList = append(state.StakingInfoList, stakingInfo) + } + buf, err := cfg.Codec.MarshalJSON(&state) + require.NoError(t, err) + cfg.GenesisState[types.ModuleName] = buf + return network.New(t, cfg), state.StakingInfoList +} + +func TestShowStakingInfo(t *testing.T) { + net, objs := networkWithStakingInfoObjects(t, 2) + + ctx := net.Validators[0].ClientCtx + common := []string{ + fmt.Sprintf("--%s=json", tmcli.OutputFlag), + } + tests := []struct { + desc string + idToken string + idStaker string + + args []string + err error + obj types.StakingInfo + }{ + { + desc: "found", + idToken: objs[0].Token, + idStaker: objs[0].Staker, + + args: common, + obj: objs[0], + }, + { + desc: "not found", + idToken: strconv.Itoa(100000), + idStaker: strconv.Itoa(100000), + + args: common, + err: status.Error(codes.NotFound, "not found"), + }, + } + for _, tc := range tests { + t.Run(tc.desc, func(t *testing.T) { + args := []string{ + tc.idToken, + tc.idStaker, + } + args = append(args, tc.args...) + out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdShowStakingInfo(), args) + if tc.err != nil { + stat, ok := status.FromError(tc.err) + require.True(t, ok) + require.ErrorIs(t, stat.Err(), tc.err) + } else { + require.NoError(t, err) + var resp types.QueryStakingInfoResponse + require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) + require.NotNil(t, resp.StakingInfo) + require.Equal(t, + nullify.Fill(&tc.obj), + nullify.Fill(&resp.StakingInfo), + ) + } + }) + } +} + +func TestListStakingInfo(t *testing.T) { + net, objs := networkWithStakingInfoObjects(t, 5) + + ctx := net.Validators[0].ClientCtx + request := func(next []byte, offset, limit uint64, total bool) []string { + args := []string{ + fmt.Sprintf("--%s=json", tmcli.OutputFlag), + } + if next == nil { + args = append(args, fmt.Sprintf("--%s=%d", flags.FlagOffset, offset)) + } else { + args = append(args, fmt.Sprintf("--%s=%s", flags.FlagPageKey, next)) + } + args = append(args, fmt.Sprintf("--%s=%d", flags.FlagLimit, limit)) + if total { + args = append(args, fmt.Sprintf("--%s", flags.FlagCountTotal)) + } + return args + } + t.Run("ByOffset", func(t *testing.T) { + step := 2 + for i := 0; i < len(objs); i += step { + //nolint:gosec // G115 + args := request(nil, uint64(i), uint64(step), false) + out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdListStakingInfo(), args) + require.NoError(t, err) + var resp types.QueryStakingInfoAllResponse + require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) + require.LessOrEqual(t, len(resp.StakingInfo), step) + require.Subset(t, + nullify.Fill(objs), + nullify.Fill(resp.StakingInfo), + ) + } + }) + t.Run("ByKey", func(t *testing.T) { + step := 2 + var next []byte + for i := 0; i < len(objs); i += step { + //nolint:gosec // G115 + args := request(next, 0, uint64(step), false) + out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdListStakingInfo(), args) + require.NoError(t, err) + var resp types.QueryStakingInfoAllResponse + require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) + require.LessOrEqual(t, len(resp.StakingInfo), step) + require.Subset(t, + nullify.Fill(objs), + nullify.Fill(resp.StakingInfo), + ) + next = resp.Pagination.NextKey + } + }) + t.Run("Total", func(t *testing.T) { + args := request(nil, 0, uint64(len(objs)), true) + out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdListStakingInfo(), args) + require.NoError(t, err) + var resp types.QueryStakingInfoAllResponse + require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) + require.NoError(t, err) + //nolint:gosec // G115 + require.Equal(t, len(objs), int(resp.Pagination.Total)) + require.ElementsMatch(t, + nullify.Fill(objs), + nullify.Fill(resp.StakingInfo), + ) + }) +} diff --git a/x/farming/client/cli/tx.go b/x/farming/client/cli/tx.go new file mode 100644 index 00000000..1387a0ca --- /dev/null +++ b/x/farming/client/cli/tx.go @@ -0,0 +1,40 @@ +package cli + +import ( + "fmt" + "time" + + "github.com/spf13/cobra" + + "github.com/cosmos/cosmos-sdk/client" + // "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/titantkx/titan/x/farming/types" +) + +var DefaultRelativePacketTimeoutTimestamp = uint64((time.Duration(10) * time.Minute).Nanoseconds()) + +const ( + //nolint:unused + flagPacketTimeoutTimestamp = "packet-timeout-timestamp" + //nolint:unused + listSeparator = "," +) + +// 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(CmdAddReward()) + cmd.AddCommand(CmdStake()) + cmd.AddCommand(CmdUnstake()) + cmd.AddCommand(CmdHarvest()) + // this line is used by starport scaffolding # 1 + + return cmd +} diff --git a/x/farming/client/cli/tx_add_reward.go b/x/farming/client/cli/tx_add_reward.go new file mode 100644 index 00000000..c38d3e61 --- /dev/null +++ b/x/farming/client/cli/tx_add_reward.go @@ -0,0 +1,65 @@ +package cli + +import ( + "strconv" + "time" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/spf13/cobra" + "github.com/titantkx/titan/x/farming/types" +) + +var _ = strconv.Itoa(0) + +func CmdAddReward() *cobra.Command { + cmd := &cobra.Command{ + Use: "add-reward [token] [rewards] [end-time] [start-time]", + Short: "Add farming rewards for a token", + Args: cobra.RangeArgs(3, 4), + RunE: func(cmd *cobra.Command, args []string) (err error) { + argToken := args[0] + + argAmount, err := sdk.ParseCoinsNormalized(args[1]) + if err != nil { + return err + } + + argEndTime, err := time.Parse(time.RFC3339, args[2]) + if err != nil { + return err + } + + var argStartTime time.Time + if len(args) > 3 { + argStartTime, err = time.Parse(time.RFC3339, args[3]) + if err != nil { + return err + } + } + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + msg := types.NewMsgAddReward( + clientCtx.GetFromAddress().String(), + argToken, + argAmount, + argEndTime, + argStartTime, + ) + if err := msg.ValidateBasic(); err != nil { + return err + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} diff --git a/x/farming/client/cli/tx_harvest.go b/x/farming/client/cli/tx_harvest.go new file mode 100644 index 00000000..99149ac6 --- /dev/null +++ b/x/farming/client/cli/tx_harvest.go @@ -0,0 +1,39 @@ +package cli + +import ( + "strconv" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" + "github.com/spf13/cobra" + "github.com/titantkx/titan/x/farming/types" +) + +var _ = strconv.Itoa(0) + +func CmdHarvest() *cobra.Command { + cmd := &cobra.Command{ + Use: "harvest", + Short: "Harvest farming rewards", + Args: cobra.ExactArgs(0), + RunE: func(cmd *cobra.Command, _ []string) (err error) { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + msg := types.NewMsgHarvest( + clientCtx.GetFromAddress().String(), + ) + if err := msg.ValidateBasic(); err != nil { + return err + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} diff --git a/x/farming/client/cli/tx_stake.go b/x/farming/client/cli/tx_stake.go new file mode 100644 index 00000000..2d2b50d4 --- /dev/null +++ b/x/farming/client/cli/tx_stake.go @@ -0,0 +1,46 @@ +package cli + +import ( + "strconv" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/spf13/cobra" + "github.com/titantkx/titan/x/farming/types" +) + +var _ = strconv.Itoa(0) + +func CmdStake() *cobra.Command { + cmd := &cobra.Command{ + Use: "stake [amount]", + Short: "Stake tokens to receive farming rewards", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) (err error) { + argAmount, err := sdk.ParseCoinsNormalized(args[0]) + if err != nil { + return err + } + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + msg := types.NewMsgStake( + clientCtx.GetFromAddress().String(), + argAmount, + ) + if err := msg.ValidateBasic(); err != nil { + return err + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} diff --git a/x/farming/client/cli/tx_unstake.go b/x/farming/client/cli/tx_unstake.go new file mode 100644 index 00000000..db50aa80 --- /dev/null +++ b/x/farming/client/cli/tx_unstake.go @@ -0,0 +1,46 @@ +package cli + +import ( + "strconv" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/spf13/cobra" + "github.com/titantkx/titan/x/farming/types" +) + +var _ = strconv.Itoa(0) + +func CmdUnstake() *cobra.Command { + cmd := &cobra.Command{ + Use: "unstake [amount]", + Short: "Unstake tokens", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) (err error) { + argAmount, err := sdk.ParseCoinsNormalized(args[0]) + if err != nil { + return err + } + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + msg := types.NewMsgUnstake( + clientCtx.GetFromAddress().String(), + argAmount, + ) + if err := msg.ValidateBasic(); err != nil { + return err + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} diff --git a/x/farming/genesis.go b/x/farming/genesis.go new file mode 100644 index 00000000..5ee06b68 --- /dev/null +++ b/x/farming/genesis.go @@ -0,0 +1,47 @@ +package farming + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/titantkx/titan/x/farming/keeper" + "github.com/titantkx/titan/x/farming/types" +) + +// InitGenesis initializes the module's state from a provided genesis state. +func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) { + // Set all the farm + for _, elem := range genState.FarmList { + k.SetFarm(ctx, elem) + } + // Set all the stakingInfo + for _, elem := range genState.StakingInfoList { + k.SetStakingInfo(ctx, elem) + } + // Set if defined + if genState.DistributionInfo != nil { + k.SetDistributionInfo(ctx, *genState.DistributionInfo) + } + // Set all the reward + for _, elem := range genState.RewardList { + k.SetReward(ctx, elem) + } + // this line is used by starport scaffolding # genesis/module/init + k.SetParams(ctx, genState.Params) +} + +// ExportGenesis returns the module's exported genesis +func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { + genesis := types.DefaultGenesis() + genesis.Params = k.GetParams(ctx) + + genesis.FarmList = k.GetAllFarm(ctx) + genesis.StakingInfoList = k.GetAllStakingInfo(ctx, "") + // Get distributionInfo + distributionInfo, found := k.GetDistributionInfo(ctx) + if found { + genesis.DistributionInfo = &distributionInfo + } + genesis.RewardList = k.GetAllReward(ctx) + // this line is used by starport scaffolding # genesis/module/export + + return genesis +} diff --git a/x/farming/genesis_test.go b/x/farming/genesis_test.go new file mode 100644 index 00000000..080fa40b --- /dev/null +++ b/x/farming/genesis_test.go @@ -0,0 +1,76 @@ +package farming_test + +import ( + "testing" + "time" + + "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + keepertest "github.com/titantkx/titan/testutil/keeper" + "github.com/titantkx/titan/testutil/nullify" + "github.com/titantkx/titan/testutil/sample" + "github.com/titantkx/titan/x/farming" + "github.com/titantkx/titan/x/farming/types" +) + +func TestGenesis(t *testing.T) { + genesisState := types.GenesisState{ + Params: types.DefaultParams(), + + FarmList: []types.Farm{ + { + Token: "0", + Rewards: []*types.FarmReward{ + { + Sender: sample.AccAddress().String(), + Amount: sdk.NewCoins(sdk.NewCoin("bitcoin", sdk.NewInt(1000))), + EndTime: time.Now().Add(1 * time.Hour), + StartTime: time.Now(), + }, + }, + }, + { + Token: "1", + }, + }, + StakingInfoList: []types.StakingInfo{ + { + Token: "0", + Staker: "0", + Amount: math.NewInt(100), + }, + { + Token: "1", + Staker: "1", + Amount: math.NewInt(1000), + }, + }, + DistributionInfo: &types.DistributionInfo{ + LastDistributionTime: time.Now(), + }, + RewardList: []types.Reward{ + { + Farmer: "0", + }, + { + Farmer: "1", + }, + }, + // this line is used by starport scaffolding # genesis/test/state + } + + k, ctx := keepertest.FarmingKeeper(t) + farming.InitGenesis(ctx, *k, genesisState) + got := farming.ExportGenesis(ctx, *k) + require.NotNil(t, got) + + nullify.Fill(&genesisState) + nullify.Fill(got) + + require.ElementsMatch(t, genesisState.FarmList, got.FarmList) + require.ElementsMatch(t, genesisState.StakingInfoList, got.StakingInfoList) + require.True(t, genesisState.DistributionInfo.LastDistributionTime.Equal(got.DistributionInfo.LastDistributionTime)) + require.ElementsMatch(t, genesisState.RewardList, got.RewardList) + // this line is used by starport scaffolding # genesis/test/assert +} diff --git a/x/farming/keeper/distribution_info.go b/x/farming/keeper/distribution_info.go new file mode 100644 index 00000000..f7c2f9ee --- /dev/null +++ b/x/farming/keeper/distribution_info.go @@ -0,0 +1,27 @@ +package keeper + +import ( + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/titantkx/titan/x/farming/types" +) + +// SetDistributionInfo set distributionInfo in the store +func (k Keeper) SetDistributionInfo(ctx sdk.Context, distributionInfo types.DistributionInfo) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.DistributionInfoKey)) + b := k.cdc.MustMarshal(&distributionInfo) + store.Set([]byte{0}, b) +} + +// GetDistributionInfo returns distributionInfo +func (k Keeper) GetDistributionInfo(ctx sdk.Context) (val types.DistributionInfo, found bool) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.DistributionInfoKey)) + + b := store.Get([]byte{0}) + if b == nil { + return val, false + } + + k.cdc.MustUnmarshal(b, &val) + return val, true +} diff --git a/x/farming/keeper/distribution_info_test.go b/x/farming/keeper/distribution_info_test.go new file mode 100644 index 00000000..f3e492fd --- /dev/null +++ b/x/farming/keeper/distribution_info_test.go @@ -0,0 +1,30 @@ +package keeper_test + +import ( + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + + keepertest "github.com/titantkx/titan/testutil/keeper" + "github.com/titantkx/titan/testutil/nullify" + "github.com/titantkx/titan/x/farming/keeper" + "github.com/titantkx/titan/x/farming/types" +) + +func createTestDistributionInfo(keeper *keeper.Keeper, ctx sdk.Context) types.DistributionInfo { + item := types.DistributionInfo{} + keeper.SetDistributionInfo(ctx, item) + return item +} + +func TestDistributionInfoGet(t *testing.T) { + keeper, ctx := keepertest.FarmingKeeper(t) + item := createTestDistributionInfo(keeper, ctx) + rst, found := keeper.GetDistributionInfo(ctx) + require.True(t, found) + require.Equal(t, + nullify.Fill(&item), + nullify.Fill(&rst), + ) +} diff --git a/x/farming/keeper/farm.go b/x/farming/keeper/farm.go new file mode 100644 index 00000000..d33f8d95 --- /dev/null +++ b/x/farming/keeper/farm.go @@ -0,0 +1,53 @@ +package keeper + +import ( + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/titantkx/titan/x/farming/types" +) + +// SetFarm set a specific farm in the store from its index +func (k Keeper) SetFarm(ctx sdk.Context, farm types.Farm) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.FarmKeyPrefix)) + b := k.cdc.MustMarshal(&farm) + store.Set(types.FarmKey( + farm.Token, + ), b) +} + +// GetFarm returns a farm from its index +func (k Keeper) GetFarm(ctx sdk.Context, token string) (val types.Farm, found bool) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.FarmKeyPrefix)) + + b := store.Get(types.FarmKey(token)) + if b == nil { + return val, false + } + + k.cdc.MustUnmarshal(b, &val) + return val, true +} + +// RemoveFarm removes a farm from the store +func (k Keeper) RemoveFarm(ctx sdk.Context, token string) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.FarmKeyPrefix)) + store.Delete(types.FarmKey( + token, + )) +} + +// GetAllFarm returns all farm +func (k Keeper) GetAllFarm(ctx sdk.Context) (list []types.Farm) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.FarmKeyPrefix)) + iterator := sdk.KVStorePrefixIterator(store, []byte{}) + + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + var val types.Farm + k.cdc.MustUnmarshal(iterator.Value(), &val) + list = append(list, val) + } + + return +} diff --git a/x/farming/keeper/farm_test.go b/x/farming/keeper/farm_test.go new file mode 100644 index 00000000..c4011db6 --- /dev/null +++ b/x/farming/keeper/farm_test.go @@ -0,0 +1,65 @@ +//nolint:dupl +package keeper_test + +import ( + "strconv" + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + keepertest "github.com/titantkx/titan/testutil/keeper" + "github.com/titantkx/titan/testutil/nullify" + "github.com/titantkx/titan/x/farming/keeper" + "github.com/titantkx/titan/x/farming/types" +) + +// Prevent strconv unused error +var _ = strconv.IntSize + +func createNFarm(keeper *keeper.Keeper, ctx sdk.Context, n int) []types.Farm { + items := make([]types.Farm, n) + for i := range items { + items[i].Token = strconv.Itoa(i) + + keeper.SetFarm(ctx, items[i]) + } + return items +} + +func TestFarmGet(t *testing.T) { + keeper, ctx := keepertest.FarmingKeeper(t) + items := createNFarm(keeper, ctx, 10) + for _, item := range items { + rst, found := keeper.GetFarm(ctx, + item.Token, + ) + require.True(t, found) + require.Equal(t, + nullify.Fill(&item), + nullify.Fill(&rst), + ) + } +} + +func TestFarmRemove(t *testing.T) { + keeper, ctx := keepertest.FarmingKeeper(t) + items := createNFarm(keeper, ctx, 10) + for _, item := range items { + keeper.RemoveFarm(ctx, + item.Token, + ) + _, found := keeper.GetFarm(ctx, + item.Token, + ) + require.False(t, found) + } +} + +func TestFarmGetAll(t *testing.T) { + keeper, ctx := keepertest.FarmingKeeper(t) + items := createNFarm(keeper, ctx, 10) + require.ElementsMatch(t, + nullify.Fill(items), + nullify.Fill(keeper.GetAllFarm(ctx)), + ) +} diff --git a/x/farming/keeper/keeper.go b/x/farming/keeper/keeper.go new file mode 100644 index 00000000..92426bfa --- /dev/null +++ b/x/farming/keeper/keeper.go @@ -0,0 +1,48 @@ +package keeper + +import ( + "fmt" + + "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" + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" + + "github.com/titantkx/titan/x/farming/types" +) + +type ( + Keeper struct { + cdc codec.BinaryCodec + storeKey storetypes.StoreKey + memKey storetypes.StoreKey + paramstore paramtypes.Subspace + bankKeeper types.BankKeeper + } +) + +func NewKeeper( + cdc codec.BinaryCodec, + storeKey, + memKey storetypes.StoreKey, + ps paramtypes.Subspace, + bankKeeper types.BankKeeper, +) *Keeper { + // set KeyTable if it has not already been set + if !ps.HasKeyTable() { + ps = ps.WithKeyTable(types.ParamKeyTable()) + } + + return &Keeper{ + cdc: cdc, + storeKey: storeKey, + memKey: memKey, + paramstore: ps, + bankKeeper: bankKeeper, + } +} + +func (k Keeper) Logger(ctx sdk.Context) log.Logger { + return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) +} diff --git a/x/farming/keeper/msg_server.go b/x/farming/keeper/msg_server.go new file mode 100644 index 00000000..aeb7455e --- /dev/null +++ b/x/farming/keeper/msg_server.go @@ -0,0 +1,17 @@ +package keeper + +import ( + "github.com/titantkx/titan/x/farming/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/farming/keeper/msg_server_add_reward.go b/x/farming/keeper/msg_server_add_reward.go new file mode 100644 index 00000000..774f8146 --- /dev/null +++ b/x/farming/keeper/msg_server_add_reward.go @@ -0,0 +1,57 @@ +package keeper + +import ( + "context" + "time" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/titantkx/titan/x/farming/types" +) + +func (k msgServer) AddReward(goCtx context.Context, msg *types.MsgAddReward) (*types.MsgAddRewardResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + if err := k.bankKeeper.SendCoinsFromAccountToModule(ctx, sdk.MustAccAddressFromBech32(msg.Sender), types.ModuleName, msg.Amount); err != nil { + return nil, err + } + + farm, ok := k.GetFarm(ctx, msg.Token) + if !ok { + farm = types.Farm{Token: msg.Token} + } + + if msg.StartTime.IsZero() { + msg.StartTime = ctx.BlockTime() + } + + if msg.StartTime.Before(ctx.BlockTime()) { + return nil, types.WrapErrorf(types.ErrInvalidTime, "reward must start after %s", ctx.BlockTime().Format(time.RFC3339)) + } + + if !msg.EndTime.After(msg.StartTime) { + return nil, types.WrapErrorf(types.ErrInvalidTime, "reward must end after %s", msg.StartTime.Format(time.RFC3339)) + } + + farm.Rewards = append(farm.Rewards, &types.FarmReward{ + Sender: msg.Sender, + Amount: msg.Amount, + EndTime: msg.EndTime, + StartTime: msg.StartTime, + }) + + k.SetFarm(ctx, farm) + + event := &types.EventAddReward{ + Sender: msg.Sender, + Token: msg.Token, + Amount: msg.Amount, + EndTime: msg.EndTime, + StartTime: msg.StartTime, + } + + if err := ctx.EventManager().EmitTypedEvent(event); err != nil { + return nil, types.WrapInternalError(err) + } + + return &types.MsgAddRewardResponse{}, nil +} diff --git a/x/farming/keeper/msg_server_add_reward_test.go b/x/farming/keeper/msg_server_add_reward_test.go new file mode 100644 index 00000000..f4f1ccfe --- /dev/null +++ b/x/farming/keeper/msg_server_add_reward_test.go @@ -0,0 +1,55 @@ +package keeper_test + +import ( + "testing" + "time" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + "github.com/titantkx/titan/testutil/sample" + "github.com/titantkx/titan/utils" + "github.com/titantkx/titan/x/farming/types" +) + +func TestAddReward(t *testing.T) { + ms, ctx, ctrl, k, bankKeeper := setupMsgServerWithMocks(t) + defer ctrl.Finish() + + msg := &types.MsgAddReward{ + Sender: sample.AccAddress().String(), + Token: "bitcoin", + Amount: sdk.NewCoins(sdk.NewCoin("tkx", sdk.NewInt(1000))), + EndTime: time.Now().Add(300 * time.Hour), + StartTime: time.Now().Add(1 * time.Hour), + } + + bankKeeper.EXPECT().SendCoinsFromAccountToModule(ctx, sdk.MustAccAddressFromBech32(msg.Sender), types.ModuleName, msg.Amount).Return(nil) + + resp, err := ms.AddReward(ctx, msg) + + require.NoError(t, err) + require.NotNil(t, resp) + + sdkCtx := sdk.UnwrapSDKContext(ctx) + eventAddReward, err := utils.GetTypedEvent(sdkCtx, &types.EventAddReward{}) + + require.NoError(t, err) + require.NotNil(t, eventAddReward) + require.Equal(t, msg.Sender, eventAddReward.Sender) + require.Equal(t, msg.Token, eventAddReward.Token) + require.Equal(t, msg.Amount, eventAddReward.Amount) + require.True(t, msg.StartTime.Equal(eventAddReward.StartTime)) + require.True(t, msg.EndTime.Equal(eventAddReward.EndTime)) + + farm, found := k.GetFarm(sdkCtx, "bitcoin") + + require.True(t, found) + require.NotEmpty(t, farm.Rewards) + + reward := farm.Rewards[0] + + require.Equal(t, msg.Sender, reward.Sender) + require.Equal(t, msg.Amount, reward.Amount) + require.True(t, msg.StartTime.Equal(eventAddReward.StartTime)) + require.True(t, msg.EndTime.Equal(eventAddReward.EndTime)) +} diff --git a/x/farming/keeper/msg_server_harvest.go b/x/farming/keeper/msg_server_harvest.go new file mode 100644 index 00000000..fb32aebf --- /dev/null +++ b/x/farming/keeper/msg_server_harvest.go @@ -0,0 +1,34 @@ +package keeper + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/titantkx/titan/x/farming/types" +) + +func (k msgServer) Harvest(goCtx context.Context, msg *types.MsgHarvest) (*types.MsgHarvestResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + reward, found := k.GetReward(ctx, msg.Sender) + if !found { + return nil, types.ErrNoReward + } + + if err := k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, sdk.MustAccAddressFromBech32(reward.Farmer), reward.Amount); err != nil { + return nil, err + } + + k.RemoveReward(ctx, msg.Sender) + + event := &types.EventHarvest{ + Sender: msg.Sender, + Amount: reward.Amount, + } + + if err := ctx.EventManager().EmitTypedEvent(event); err != nil { + return nil, types.WrapInternalError(err) + } + + return &types.MsgHarvestResponse{}, nil +} diff --git a/x/farming/keeper/msg_server_harvest_test.go b/x/farming/keeper/msg_server_harvest_test.go new file mode 100644 index 00000000..c8b1bcde --- /dev/null +++ b/x/farming/keeper/msg_server_harvest_test.go @@ -0,0 +1,46 @@ +package keeper_test + +import ( + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + "github.com/titantkx/titan/testutil/sample" + "github.com/titantkx/titan/utils" + "github.com/titantkx/titan/x/farming/types" +) + +func TestHarvest(t *testing.T) { + ms, ctx, ctrl, k, bankKeeper := setupMsgServerWithMocks(t) + defer ctrl.Finish() + + sdkCtx := sdk.UnwrapSDKContext(ctx) + + sender := sample.AccAddress() + reward := sdk.NewCoins(sdk.NewCoin("tkx", sdk.NewInt(1000))) + + k.SetReward(sdkCtx, types.Reward{ + Farmer: sender.String(), + Amount: reward, + }) + + bankKeeper.EXPECT().SendCoinsFromModuleToAccount(ctx, types.ModuleName, sender, reward).Return(nil) + + resp, err := ms.Harvest(ctx, &types.MsgHarvest{ + Sender: sender.String(), + }) + + require.NoError(t, err) + require.NotNil(t, resp) + + eventHarvest, err := utils.GetTypedEvent(sdkCtx, &types.EventHarvest{}) + + require.NoError(t, err) + require.NotNil(t, eventHarvest) + require.Equal(t, sender.String(), eventHarvest.Sender) + require.Equal(t, reward, eventHarvest.Amount) + + _, found := k.GetReward(sdkCtx, sender.String()) + + require.False(t, found) +} diff --git a/x/farming/keeper/msg_server_stake.go b/x/farming/keeper/msg_server_stake.go new file mode 100644 index 00000000..58f93265 --- /dev/null +++ b/x/farming/keeper/msg_server_stake.go @@ -0,0 +1,41 @@ +package keeper + +import ( + "context" + + "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/titantkx/titan/x/farming/types" +) + +func (k msgServer) Stake(goCtx context.Context, msg *types.MsgStake) (*types.MsgStakeResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + if err := k.bankKeeper.SendCoinsFromAccountToModule(ctx, sdk.MustAccAddressFromBech32(msg.Sender), types.ModuleName, msg.Amount); err != nil { + return nil, err + } + + for _, coin := range msg.Amount { + stakingInfo, ok := k.GetStakingInfo(ctx, coin.Denom, msg.Sender) + if !ok { + stakingInfo = types.StakingInfo{ + Token: coin.Denom, + Staker: msg.Sender, + Amount: math.NewInt(0), + } + } + stakingInfo.Amount = stakingInfo.Amount.Add(coin.Amount) + k.SetStakingInfo(ctx, stakingInfo) + } + + event := &types.EventStake{ + Sender: msg.Sender, + Amount: msg.Amount, + } + + if err := ctx.EventManager().EmitTypedEvent(event); err != nil { + return nil, types.WrapInternalError(err) + } + + return &types.MsgStakeResponse{}, nil +} diff --git a/x/farming/keeper/msg_server_stake_test.go b/x/farming/keeper/msg_server_stake_test.go new file mode 100644 index 00000000..11e25a7f --- /dev/null +++ b/x/farming/keeper/msg_server_stake_test.go @@ -0,0 +1,41 @@ +package keeper_test + +import ( + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + "github.com/titantkx/titan/testutil/sample" + "github.com/titantkx/titan/utils" + "github.com/titantkx/titan/x/farming/types" +) + +func TestStake(t *testing.T) { + ms, ctx, ctrl, k, bankKeeper := setupMsgServerWithMocks(t) + defer ctrl.Finish() + + msg := &types.MsgStake{ + Sender: sample.AccAddress().String(), + Amount: sdk.NewCoins(sdk.NewCoin("tkx", sdk.NewInt(1000))), + } + + bankKeeper.EXPECT().SendCoinsFromAccountToModule(ctx, sdk.MustAccAddressFromBech32(msg.Sender), types.ModuleName, msg.Amount).Return(nil) + + resp, err := ms.Stake(ctx, msg) + + require.NoError(t, err) + require.NotNil(t, resp) + + sdkCtx := sdk.UnwrapSDKContext(ctx) + eventStake, err := utils.GetTypedEvent(sdkCtx, &types.EventStake{}) + + require.NoError(t, err) + require.NotNil(t, eventStake) + require.Equal(t, msg.Sender, eventStake.Sender) + require.Equal(t, msg.Amount, eventStake.Amount) + + stakingInfo, found := k.GetStakingInfo(sdkCtx, "tkx", msg.Sender) + + require.True(t, found) + require.Equal(t, sdk.NewInt(1000), stakingInfo.Amount) +} diff --git a/x/farming/keeper/msg_server_test.go b/x/farming/keeper/msg_server_test.go new file mode 100644 index 00000000..dc782973 --- /dev/null +++ b/x/farming/keeper/msg_server_test.go @@ -0,0 +1,34 @@ +package keeper_test + +import ( + "context" + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/golang/mock/gomock" + "github.com/stretchr/testify/require" + keepertest "github.com/titantkx/titan/testutil/keeper" + "github.com/titantkx/titan/x/farming/keeper" + "github.com/titantkx/titan/x/farming/testutil" + "github.com/titantkx/titan/x/farming/types" +) + +func setupMsgServer(t testing.TB) (types.MsgServer, context.Context, *keeper.Keeper) { + k, ctx := keepertest.FarmingKeeper(t) + return keeper.NewMsgServerImpl(*k), sdk.WrapSDKContext(ctx), k +} + +func setupMsgServerWithMocks(t *testing.T) (types.MsgServer, context.Context, *gomock.Controller, *keeper.Keeper, *testutil.MockBankKeeper) { + ctrl := gomock.NewController(t) + bankKeeper := testutil.NewMockBankKeeper(ctrl) + k, ctx := keepertest.FarmingKeeperWithMocks(t, bankKeeper) + msgSrv := keeper.NewMsgServerImpl(*k) + return msgSrv, sdk.WrapSDKContext(ctx), ctrl, k, bankKeeper +} + +func TestMsgServer(t *testing.T) { + ms, ctx, k := setupMsgServer(t) + require.NotNil(t, ms) + require.NotNil(t, ctx) + require.NotNil(t, k) +} diff --git a/x/farming/keeper/msg_server_unstake.go b/x/farming/keeper/msg_server_unstake.go new file mode 100644 index 00000000..7db28219 --- /dev/null +++ b/x/farming/keeper/msg_server_unstake.go @@ -0,0 +1,42 @@ +package keeper + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/titantkx/titan/x/farming/types" +) + +func (k msgServer) Unstake(goCtx context.Context, msg *types.MsgUnstake) (*types.MsgUnstakeResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + for _, coin := range msg.Amount { + stakingInfo, ok := k.GetStakingInfo(ctx, coin.Denom, msg.Sender) + if !ok || stakingInfo.Amount.LT(coin.Amount) { + return nil, types.ErrStakingBalanceNotEnough + } + + stakingInfo.Amount = stakingInfo.Amount.Sub(coin.Amount) + + if stakingInfo.Amount.IsZero() { + k.RemoveStakingInfo(ctx, stakingInfo.Token, stakingInfo.Staker) + } else { + k.SetStakingInfo(ctx, stakingInfo) + } + } + + if err := k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, sdk.MustAccAddressFromBech32(msg.Sender), msg.Amount); err != nil { + return nil, err + } + + event := &types.EventUnstake{ + Sender: msg.Sender, + Amount: msg.Amount, + } + + if err := ctx.EventManager().EmitTypedEvent(event); err != nil { + return nil, types.WrapInternalError(err) + } + + return &types.MsgUnstakeResponse{}, nil +} diff --git a/x/farming/keeper/msg_server_unstake_test.go b/x/farming/keeper/msg_server_unstake_test.go new file mode 100644 index 00000000..3d6f20ea --- /dev/null +++ b/x/farming/keeper/msg_server_unstake_test.go @@ -0,0 +1,88 @@ +package keeper_test + +import ( + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + "github.com/titantkx/titan/testutil/sample" + "github.com/titantkx/titan/utils" + "github.com/titantkx/titan/x/farming/types" +) + +func TestUnstake(t *testing.T) { + ms, ctx, ctrl, k, bankKeeper := setupMsgServerWithMocks(t) + defer ctrl.Finish() + + sdkCtx := sdk.UnwrapSDKContext(ctx) + + sender := sample.AccAddress() + + k.SetStakingInfo(sdkCtx, types.StakingInfo{ + Token: "tkx", + Staker: sender.String(), + Amount: sdk.NewInt(10000), + }) + + msg := &types.MsgUnstake{ + Sender: sender.String(), + Amount: sdk.NewCoins(sdk.NewCoin("tkx", sdk.NewInt(1000))), + } + + bankKeeper.EXPECT().SendCoinsFromModuleToAccount(ctx, types.ModuleName, sender, msg.Amount).Return(nil) + + resp, err := ms.Unstake(ctx, msg) + + require.NoError(t, err) + require.NotNil(t, resp) + + eventUnstake, err := utils.GetTypedEvent(sdkCtx, &types.EventUnstake{}) + + require.NoError(t, err) + require.NotNil(t, eventUnstake) + require.Equal(t, msg.Sender, eventUnstake.Sender) + require.Equal(t, msg.Amount, eventUnstake.Amount) + + stakingInfo, found := k.GetStakingInfo(sdkCtx, "tkx", sender.String()) + + require.True(t, found) + require.Equal(t, sdk.NewInt(9000), stakingInfo.Amount) +} + +func TestUnstakeAl(t *testing.T) { + ms, ctx, ctrl, k, bankKeeper := setupMsgServerWithMocks(t) + defer ctrl.Finish() + + sdkCtx := sdk.UnwrapSDKContext(ctx) + + sender := sample.AccAddress() + + k.SetStakingInfo(sdkCtx, types.StakingInfo{ + Token: "tkx", + Staker: sender.String(), + Amount: sdk.NewInt(1000), + }) + + msg := &types.MsgUnstake{ + Sender: sender.String(), + Amount: sdk.NewCoins(sdk.NewCoin("tkx", sdk.NewInt(1000))), + } + + bankKeeper.EXPECT().SendCoinsFromModuleToAccount(ctx, types.ModuleName, sender, msg.Amount).Return(nil) + + resp, err := ms.Unstake(ctx, msg) + + require.NoError(t, err) + require.NotNil(t, resp) + + eventUnstake, err := utils.GetTypedEvent(sdkCtx, &types.EventUnstake{}) + + require.NoError(t, err) + require.NotNil(t, eventUnstake) + require.Equal(t, msg.Sender, eventUnstake.Sender) + require.Equal(t, msg.Amount, eventUnstake.Amount) + + _, found := k.GetStakingInfo(sdkCtx, "tkx", sender.String()) + + require.False(t, found) +} diff --git a/x/farming/keeper/params.go b/x/farming/keeper/params.go new file mode 100644 index 00000000..542697b1 --- /dev/null +++ b/x/farming/keeper/params.go @@ -0,0 +1,16 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/titantkx/titan/x/farming/types" +) + +// GetParams get all parameters as types.Params +func (k Keeper) GetParams(_ sdk.Context) types.Params { + return types.NewParams() +} + +// SetParams set the params +func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { + k.paramstore.SetParamSet(ctx, ¶ms) +} diff --git a/x/farming/keeper/params_test.go b/x/farming/keeper/params_test.go new file mode 100644 index 00000000..ec5dca3b --- /dev/null +++ b/x/farming/keeper/params_test.go @@ -0,0 +1,18 @@ +package keeper_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + testkeeper "github.com/titantkx/titan/testutil/keeper" + "github.com/titantkx/titan/x/farming/types" +) + +func TestGetParams(t *testing.T) { + k, ctx := testkeeper.FarmingKeeper(t) + params := types.DefaultParams() + + k.SetParams(ctx, params) + + require.EqualValues(t, params, k.GetParams(ctx)) +} diff --git a/x/farming/keeper/query.go b/x/farming/keeper/query.go new file mode 100644 index 00000000..196ec471 --- /dev/null +++ b/x/farming/keeper/query.go @@ -0,0 +1,7 @@ +package keeper + +import ( + "github.com/titantkx/titan/x/farming/types" +) + +var _ types.QueryServer = Keeper{} diff --git a/x/farming/keeper/query_distribution_info.go b/x/farming/keeper/query_distribution_info.go new file mode 100644 index 00000000..09c856ee --- /dev/null +++ b/x/farming/keeper/query_distribution_info.go @@ -0,0 +1,24 @@ +package keeper + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/titantkx/titan/x/farming/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +func (k Keeper) DistributionInfo(goCtx context.Context, req *types.QueryDistributionInfoRequest) (*types.QueryDistributionInfoResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + ctx := sdk.UnwrapSDKContext(goCtx) + + val, found := k.GetDistributionInfo(ctx) + if !found { + return nil, status.Error(codes.NotFound, "not found") + } + + return &types.QueryDistributionInfoResponse{DistributionInfo: val}, nil +} diff --git a/x/farming/keeper/query_distribution_info_test.go b/x/farming/keeper/query_distribution_info_test.go new file mode 100644 index 00000000..d08c0cad --- /dev/null +++ b/x/farming/keeper/query_distribution_info_test.go @@ -0,0 +1,50 @@ +package keeper_test + +import ( + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + keepertest "github.com/titantkx/titan/testutil/keeper" + "github.com/titantkx/titan/testutil/nullify" + "github.com/titantkx/titan/x/farming/types" +) + +func TestDistributionInfoQuery(t *testing.T) { + keeper, ctx := keepertest.FarmingKeeper(t) + wctx := sdk.WrapSDKContext(ctx) + item := createTestDistributionInfo(keeper, ctx) + tests := []struct { + desc string + request *types.QueryDistributionInfoRequest + response *types.QueryDistributionInfoResponse + err error + }{ + { + desc: "First", + request: &types.QueryDistributionInfoRequest{}, + response: &types.QueryDistributionInfoResponse{DistributionInfo: item}, + }, + { + desc: "InvalidRequest", + err: status.Error(codes.InvalidArgument, "invalid request"), + }, + } + for _, tc := range tests { + t.Run(tc.desc, func(t *testing.T) { + response, err := keeper.DistributionInfo(wctx, tc.request) + if tc.err != nil { + require.ErrorIs(t, err, tc.err) + } else { + require.NoError(t, err) + require.Equal(t, + nullify.Fill(tc.response), + nullify.Fill(response), + ) + } + }) + } +} diff --git a/x/farming/keeper/query_farm.go b/x/farming/keeper/query_farm.go new file mode 100644 index 00000000..48c2964c --- /dev/null +++ b/x/farming/keeper/query_farm.go @@ -0,0 +1,57 @@ +//nolint:dupl +package keeper + +import ( + "context" + + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/query" + "github.com/titantkx/titan/x/farming/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +func (k Keeper) FarmAll(goCtx context.Context, req *types.QueryFarmAllRequest) (*types.QueryFarmAllResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + var farms []types.Farm + ctx := sdk.UnwrapSDKContext(goCtx) + + store := ctx.KVStore(k.storeKey) + farmStore := prefix.NewStore(store, types.KeyPrefix(types.FarmKeyPrefix)) + + pageRes, err := query.Paginate(farmStore, req.Pagination, func(_ []byte, value []byte) error { + var farm types.Farm + if err := k.cdc.Unmarshal(value, &farm); err != nil { + return err + } + + farms = append(farms, farm) + return nil + }) + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } + + return &types.QueryFarmAllResponse{Farm: farms, Pagination: pageRes}, nil +} + +func (k Keeper) Farm(goCtx context.Context, req *types.QueryFarmRequest) (*types.QueryFarmResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + ctx := sdk.UnwrapSDKContext(goCtx) + + val, found := k.GetFarm( + ctx, + req.Token, + ) + if !found { + return nil, status.Error(codes.NotFound, "not found") + } + + return &types.QueryFarmResponse{Farm: val}, nil +} diff --git a/x/farming/keeper/query_farm_test.go b/x/farming/keeper/query_farm_test.go new file mode 100644 index 00000000..b761ee41 --- /dev/null +++ b/x/farming/keeper/query_farm_test.go @@ -0,0 +1,131 @@ +//nolint:dupl +package keeper_test + +import ( + "strconv" + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/query" + "github.com/stretchr/testify/require" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + keepertest "github.com/titantkx/titan/testutil/keeper" + "github.com/titantkx/titan/testutil/nullify" + "github.com/titantkx/titan/x/farming/types" +) + +// Prevent strconv unused error +var _ = strconv.IntSize + +func TestFarmQuerySingle(t *testing.T) { + keeper, ctx := keepertest.FarmingKeeper(t) + wctx := sdk.WrapSDKContext(ctx) + msgs := createNFarm(keeper, ctx, 2) + tests := []struct { + desc string + request *types.QueryFarmRequest + response *types.QueryFarmResponse + err error + }{ + { + desc: "First", + request: &types.QueryFarmRequest{ + Token: msgs[0].Token, + }, + response: &types.QueryFarmResponse{Farm: msgs[0]}, + }, + { + desc: "Second", + request: &types.QueryFarmRequest{ + Token: msgs[1].Token, + }, + response: &types.QueryFarmResponse{Farm: msgs[1]}, + }, + { + desc: "KeyNotFound", + request: &types.QueryFarmRequest{ + Token: strconv.Itoa(100000), + }, + err: status.Error(codes.NotFound, "not found"), + }, + { + desc: "InvalidRequest", + err: status.Error(codes.InvalidArgument, "invalid request"), + }, + } + for _, tc := range tests { + t.Run(tc.desc, func(t *testing.T) { + response, err := keeper.Farm(wctx, tc.request) + if tc.err != nil { + require.ErrorIs(t, err, tc.err) + } else { + require.NoError(t, err) + require.Equal(t, + nullify.Fill(tc.response), + nullify.Fill(response), + ) + } + }) + } +} + +func TestFarmQueryPaginated(t *testing.T) { + keeper, ctx := keepertest.FarmingKeeper(t) + wctx := sdk.WrapSDKContext(ctx) + msgs := createNFarm(keeper, ctx, 5) + + request := func(next []byte, offset, limit uint64, total bool) *types.QueryFarmAllRequest { + return &types.QueryFarmAllRequest{ + Pagination: &query.PageRequest{ + Key: next, + Offset: offset, + Limit: limit, + CountTotal: total, + }, + } + } + t.Run("ByOffset", func(t *testing.T) { + step := 2 + for i := 0; i < len(msgs); i += step { + //nolint:gosec // G115 + resp, err := keeper.FarmAll(wctx, request(nil, uint64(i), uint64(step), false)) + require.NoError(t, err) + require.LessOrEqual(t, len(resp.Farm), step) + require.Subset(t, + nullify.Fill(msgs), + nullify.Fill(resp.Farm), + ) + } + }) + t.Run("ByKey", func(t *testing.T) { + step := 2 + var next []byte + for i := 0; i < len(msgs); i += step { + //nolint:gosec // G115 + resp, err := keeper.FarmAll(wctx, request(next, 0, uint64(step), false)) + require.NoError(t, err) + require.LessOrEqual(t, len(resp.Farm), step) + require.Subset(t, + nullify.Fill(msgs), + nullify.Fill(resp.Farm), + ) + next = resp.Pagination.NextKey + } + }) + t.Run("Total", func(t *testing.T) { + resp, err := keeper.FarmAll(wctx, request(nil, 0, 0, true)) + require.NoError(t, err) + //nolint:gosec // G115 + require.Equal(t, len(msgs), int(resp.Pagination.Total)) + require.ElementsMatch(t, + nullify.Fill(msgs), + nullify.Fill(resp.Farm), + ) + }) + t.Run("InvalidRequest", func(t *testing.T) { + _, err := keeper.FarmAll(wctx, nil) + require.ErrorIs(t, err, status.Error(codes.InvalidArgument, "invalid request")) + }) +} diff --git a/x/farming/keeper/query_params.go b/x/farming/keeper/query_params.go new file mode 100644 index 00000000..8584fd11 --- /dev/null +++ b/x/farming/keeper/query_params.go @@ -0,0 +1,19 @@ +package keeper + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/titantkx/titan/x/farming/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/farming/keeper/query_params_test.go b/x/farming/keeper/query_params_test.go new file mode 100644 index 00000000..8123532f --- /dev/null +++ b/x/farming/keeper/query_params_test.go @@ -0,0 +1,21 @@ +package keeper_test + +import ( + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + testkeeper "github.com/titantkx/titan/testutil/keeper" + "github.com/titantkx/titan/x/farming/types" +) + +func TestParamsQuery(t *testing.T) { + keeper, ctx := testkeeper.FarmingKeeper(t) + wctx := sdk.WrapSDKContext(ctx) + params := types.DefaultParams() + keeper.SetParams(ctx, params) + + response, err := keeper.Params(wctx, &types.QueryParamsRequest{}) + require.NoError(t, err) + require.Equal(t, &types.QueryParamsResponse{Params: params}, response) +} diff --git a/x/farming/keeper/query_reward.go b/x/farming/keeper/query_reward.go new file mode 100644 index 00000000..023a9cc6 --- /dev/null +++ b/x/farming/keeper/query_reward.go @@ -0,0 +1,57 @@ +//nolint:dupl +package keeper + +import ( + "context" + + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/query" + "github.com/titantkx/titan/x/farming/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +func (k Keeper) RewardAll(goCtx context.Context, req *types.QueryRewardAllRequest) (*types.QueryRewardAllResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + var rewards []types.Reward + ctx := sdk.UnwrapSDKContext(goCtx) + + store := ctx.KVStore(k.storeKey) + rewardStore := prefix.NewStore(store, types.KeyPrefix(types.RewardKeyPrefix)) + + pageRes, err := query.Paginate(rewardStore, req.Pagination, func(_ []byte, value []byte) error { + var reward types.Reward + if err := k.cdc.Unmarshal(value, &reward); err != nil { + return err + } + + rewards = append(rewards, reward) + return nil + }) + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } + + return &types.QueryRewardAllResponse{Reward: rewards, Pagination: pageRes}, nil +} + +func (k Keeper) Reward(goCtx context.Context, req *types.QueryRewardRequest) (*types.QueryRewardResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + ctx := sdk.UnwrapSDKContext(goCtx) + + val, found := k.GetReward( + ctx, + req.Farmer, + ) + if !found { + return nil, status.Error(codes.NotFound, "not found") + } + + return &types.QueryRewardResponse{Reward: val}, nil +} diff --git a/x/farming/keeper/query_reward_test.go b/x/farming/keeper/query_reward_test.go new file mode 100644 index 00000000..fb920afa --- /dev/null +++ b/x/farming/keeper/query_reward_test.go @@ -0,0 +1,131 @@ +//nolint:dupl +package keeper_test + +import ( + "strconv" + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/query" + "github.com/stretchr/testify/require" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + keepertest "github.com/titantkx/titan/testutil/keeper" + "github.com/titantkx/titan/testutil/nullify" + "github.com/titantkx/titan/x/farming/types" +) + +// Prevent strconv unused error +var _ = strconv.IntSize + +func TestRewardQuerySingle(t *testing.T) { + keeper, ctx := keepertest.FarmingKeeper(t) + wctx := sdk.WrapSDKContext(ctx) + msgs := createNReward(keeper, ctx, 2) + tests := []struct { + desc string + request *types.QueryRewardRequest + response *types.QueryRewardResponse + err error + }{ + { + desc: "First", + request: &types.QueryRewardRequest{ + Farmer: msgs[0].Farmer, + }, + response: &types.QueryRewardResponse{Reward: msgs[0]}, + }, + { + desc: "Second", + request: &types.QueryRewardRequest{ + Farmer: msgs[1].Farmer, + }, + response: &types.QueryRewardResponse{Reward: msgs[1]}, + }, + { + desc: "KeyNotFound", + request: &types.QueryRewardRequest{ + Farmer: strconv.Itoa(100000), + }, + err: status.Error(codes.NotFound, "not found"), + }, + { + desc: "InvalidRequest", + err: status.Error(codes.InvalidArgument, "invalid request"), + }, + } + for _, tc := range tests { + t.Run(tc.desc, func(t *testing.T) { + response, err := keeper.Reward(wctx, tc.request) + if tc.err != nil { + require.ErrorIs(t, err, tc.err) + } else { + require.NoError(t, err) + require.Equal(t, + nullify.Fill(tc.response), + nullify.Fill(response), + ) + } + }) + } +} + +func TestRewardQueryPaginated(t *testing.T) { + keeper, ctx := keepertest.FarmingKeeper(t) + wctx := sdk.WrapSDKContext(ctx) + msgs := createNReward(keeper, ctx, 5) + + request := func(next []byte, offset, limit uint64, total bool) *types.QueryRewardAllRequest { + return &types.QueryRewardAllRequest{ + Pagination: &query.PageRequest{ + Key: next, + Offset: offset, + Limit: limit, + CountTotal: total, + }, + } + } + t.Run("ByOffset", func(t *testing.T) { + step := 2 + for i := 0; i < len(msgs); i += step { + //nolint:gosec // G115 + resp, err := keeper.RewardAll(wctx, request(nil, uint64(i), uint64(step), false)) + require.NoError(t, err) + require.LessOrEqual(t, len(resp.Reward), step) + require.Subset(t, + nullify.Fill(msgs), + nullify.Fill(resp.Reward), + ) + } + }) + t.Run("ByKey", func(t *testing.T) { + step := 2 + var next []byte + for i := 0; i < len(msgs); i += step { + //nolint:gosec // G115 + resp, err := keeper.RewardAll(wctx, request(next, 0, uint64(step), false)) + require.NoError(t, err) + require.LessOrEqual(t, len(resp.Reward), step) + require.Subset(t, + nullify.Fill(msgs), + nullify.Fill(resp.Reward), + ) + next = resp.Pagination.NextKey + } + }) + t.Run("Total", func(t *testing.T) { + resp, err := keeper.RewardAll(wctx, request(nil, 0, 0, true)) + require.NoError(t, err) + //nolint:gosec // G115 + require.Equal(t, len(msgs), int(resp.Pagination.Total)) + require.ElementsMatch(t, + nullify.Fill(msgs), + nullify.Fill(resp.Reward), + ) + }) + t.Run("InvalidRequest", func(t *testing.T) { + _, err := keeper.RewardAll(wctx, nil) + require.ErrorIs(t, err, status.Error(codes.InvalidArgument, "invalid request")) + }) +} diff --git a/x/farming/keeper/query_staking_info.go b/x/farming/keeper/query_staking_info.go new file mode 100644 index 00000000..a8d15dcf --- /dev/null +++ b/x/farming/keeper/query_staking_info.go @@ -0,0 +1,60 @@ +package keeper + +import ( + "context" + + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/query" + "github.com/titantkx/titan/x/farming/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +func (k Keeper) StakingInfoAll(goCtx context.Context, req *types.QueryStakingInfoAllRequest) (*types.QueryStakingInfoAllResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + var stakingInfos []types.StakingInfo + ctx := sdk.UnwrapSDKContext(goCtx) + + store := ctx.KVStore(k.storeKey) + stakingInfoStore := prefix.NewStore(store, types.KeyPrefix(types.StakingInfoKeyPrefix)) + if req.Token != "" { + stakingInfoStore = prefix.NewStore(stakingInfoStore, types.StakingInfoKey(req.Token, "")) + } + + pageRes, err := query.Paginate(stakingInfoStore, req.Pagination, func(_ []byte, value []byte) error { + var stakingInfo types.StakingInfo + if err := k.cdc.Unmarshal(value, &stakingInfo); err != nil { + return err + } + + stakingInfos = append(stakingInfos, stakingInfo) + return nil + }) + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } + + return &types.QueryStakingInfoAllResponse{StakingInfo: stakingInfos, Pagination: pageRes}, nil +} + +func (k Keeper) StakingInfo(goCtx context.Context, req *types.QueryStakingInfoRequest) (*types.QueryStakingInfoResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + ctx := sdk.UnwrapSDKContext(goCtx) + + val, found := k.GetStakingInfo( + ctx, + req.Token, + req.Staker, + ) + if !found { + return nil, status.Error(codes.NotFound, "not found") + } + + return &types.QueryStakingInfoResponse{StakingInfo: val}, nil +} diff --git a/x/farming/keeper/query_staking_info_test.go b/x/farming/keeper/query_staking_info_test.go new file mode 100644 index 00000000..6a1da237 --- /dev/null +++ b/x/farming/keeper/query_staking_info_test.go @@ -0,0 +1,134 @@ +//nolint:dupl +package keeper_test + +import ( + "strconv" + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/query" + "github.com/stretchr/testify/require" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + keepertest "github.com/titantkx/titan/testutil/keeper" + "github.com/titantkx/titan/testutil/nullify" + "github.com/titantkx/titan/x/farming/types" +) + +// Prevent strconv unused error +var _ = strconv.IntSize + +func TestStakingInfoQuerySingle(t *testing.T) { + keeper, ctx := keepertest.FarmingKeeper(t) + wctx := sdk.WrapSDKContext(ctx) + msgs := createNStakingInfo(keeper, ctx, 2) + tests := []struct { + desc string + request *types.QueryStakingInfoRequest + response *types.QueryStakingInfoResponse + err error + }{ + { + desc: "First", + request: &types.QueryStakingInfoRequest{ + Token: msgs[0].Token, + Staker: msgs[0].Staker, + }, + response: &types.QueryStakingInfoResponse{StakingInfo: msgs[0]}, + }, + { + desc: "Second", + request: &types.QueryStakingInfoRequest{ + Token: msgs[1].Token, + Staker: msgs[1].Staker, + }, + response: &types.QueryStakingInfoResponse{StakingInfo: msgs[1]}, + }, + { + desc: "KeyNotFound", + request: &types.QueryStakingInfoRequest{ + Token: strconv.Itoa(100000), + Staker: strconv.Itoa(100000), + }, + err: status.Error(codes.NotFound, "not found"), + }, + { + desc: "InvalidRequest", + err: status.Error(codes.InvalidArgument, "invalid request"), + }, + } + for _, tc := range tests { + t.Run(tc.desc, func(t *testing.T) { + response, err := keeper.StakingInfo(wctx, tc.request) + if tc.err != nil { + require.ErrorIs(t, err, tc.err) + } else { + require.NoError(t, err) + require.Equal(t, + nullify.Fill(tc.response), + nullify.Fill(response), + ) + } + }) + } +} + +func TestStakingInfoQueryPaginated(t *testing.T) { + keeper, ctx := keepertest.FarmingKeeper(t) + wctx := sdk.WrapSDKContext(ctx) + msgs := createNStakingInfo(keeper, ctx, 5) + + request := func(next []byte, offset, limit uint64, total bool) *types.QueryStakingInfoAllRequest { + return &types.QueryStakingInfoAllRequest{ + Pagination: &query.PageRequest{ + Key: next, + Offset: offset, + Limit: limit, + CountTotal: total, + }, + } + } + t.Run("ByOffset", func(t *testing.T) { + step := 2 + for i := 0; i < len(msgs); i += step { + //nolint:gosec // G115 + resp, err := keeper.StakingInfoAll(wctx, request(nil, uint64(i), uint64(step), false)) + require.NoError(t, err) + require.LessOrEqual(t, len(resp.StakingInfo), step) + require.Subset(t, + nullify.Fill(msgs), + nullify.Fill(resp.StakingInfo), + ) + } + }) + t.Run("ByKey", func(t *testing.T) { + step := 2 + var next []byte + for i := 0; i < len(msgs); i += step { + //nolint:gosec // G115 + resp, err := keeper.StakingInfoAll(wctx, request(next, 0, uint64(step), false)) + require.NoError(t, err) + require.LessOrEqual(t, len(resp.StakingInfo), step) + require.Subset(t, + nullify.Fill(msgs), + nullify.Fill(resp.StakingInfo), + ) + next = resp.Pagination.NextKey + } + }) + t.Run("Total", func(t *testing.T) { + resp, err := keeper.StakingInfoAll(wctx, request(nil, 0, 0, true)) + require.NoError(t, err) + //nolint:gosec // G115 + require.Equal(t, len(msgs), int(resp.Pagination.Total)) + require.ElementsMatch(t, + nullify.Fill(msgs), + nullify.Fill(resp.StakingInfo), + ) + }) + t.Run("InvalidRequest", func(t *testing.T) { + _, err := keeper.StakingInfoAll(wctx, nil) + require.ErrorIs(t, err, status.Error(codes.InvalidArgument, "invalid request")) + }) +} diff --git a/x/farming/keeper/reward.go b/x/farming/keeper/reward.go new file mode 100644 index 00000000..7cc3f84a --- /dev/null +++ b/x/farming/keeper/reward.go @@ -0,0 +1,69 @@ +package keeper + +import ( + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/titantkx/titan/x/farming/types" +) + +// AddReward add reward for a farmer +func (k Keeper) AddReward(ctx sdk.Context, farmer string, amount sdk.Coins) { + reward, found := k.GetReward(ctx, farmer) + if !found { + reward = types.Reward{ + Farmer: farmer, + Amount: sdk.NewCoins(), + } + } + + reward.Amount = reward.Amount.Add(amount...) + k.SetReward(ctx, reward) +} + +// SetReward set a specific reward in the store from its index +func (k Keeper) SetReward(ctx sdk.Context, reward types.Reward) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.RewardKeyPrefix)) + b := k.cdc.MustMarshal(&reward) + store.Set(types.RewardKey( + reward.Farmer, + ), b) +} + +// GetReward returns a reward from its index +func (k Keeper) GetReward(ctx sdk.Context, farmer string) (val types.Reward, found bool) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.RewardKeyPrefix)) + + b := store.Get(types.RewardKey( + farmer, + )) + if b == nil { + return val, false + } + + k.cdc.MustUnmarshal(b, &val) + return val, true +} + +// RemoveReward removes a reward from the store +func (k Keeper) RemoveReward(ctx sdk.Context, farmer string) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.RewardKeyPrefix)) + store.Delete(types.RewardKey( + farmer, + )) +} + +// GetAllReward returns all reward +func (k Keeper) GetAllReward(ctx sdk.Context) (list []types.Reward) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.RewardKeyPrefix)) + iterator := sdk.KVStorePrefixIterator(store, []byte{}) + + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + var val types.Reward + k.cdc.MustUnmarshal(iterator.Value(), &val) + list = append(list, val) + } + + return +} diff --git a/x/farming/keeper/reward_test.go b/x/farming/keeper/reward_test.go new file mode 100644 index 00000000..761cc712 --- /dev/null +++ b/x/farming/keeper/reward_test.go @@ -0,0 +1,65 @@ +//nolint:dupl +package keeper_test + +import ( + "strconv" + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + keepertest "github.com/titantkx/titan/testutil/keeper" + "github.com/titantkx/titan/testutil/nullify" + "github.com/titantkx/titan/x/farming/keeper" + "github.com/titantkx/titan/x/farming/types" +) + +// Prevent strconv unused error +var _ = strconv.IntSize + +func createNReward(keeper *keeper.Keeper, ctx sdk.Context, n int) []types.Reward { + items := make([]types.Reward, n) + for i := range items { + items[i].Farmer = strconv.Itoa(i) + + keeper.SetReward(ctx, items[i]) + } + return items +} + +func TestRewardGet(t *testing.T) { + keeper, ctx := keepertest.FarmingKeeper(t) + items := createNReward(keeper, ctx, 10) + for _, item := range items { + rst, found := keeper.GetReward(ctx, + item.Farmer, + ) + require.True(t, found) + require.Equal(t, + nullify.Fill(&item), + nullify.Fill(&rst), + ) + } +} + +func TestRewardRemove(t *testing.T) { + keeper, ctx := keepertest.FarmingKeeper(t) + items := createNReward(keeper, ctx, 10) + for _, item := range items { + keeper.RemoveReward(ctx, + item.Farmer, + ) + _, found := keeper.GetReward(ctx, + item.Farmer, + ) + require.False(t, found) + } +} + +func TestRewardGetAll(t *testing.T) { + keeper, ctx := keepertest.FarmingKeeper(t) + items := createNReward(keeper, ctx, 10) + require.ElementsMatch(t, + nullify.Fill(items), + nullify.Fill(keeper.GetAllReward(ctx)), + ) +} diff --git a/x/farming/keeper/staking_info.go b/x/farming/keeper/staking_info.go new file mode 100644 index 00000000..9d9fa5e6 --- /dev/null +++ b/x/farming/keeper/staking_info.go @@ -0,0 +1,72 @@ +package keeper + +import ( + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/titantkx/titan/x/farming/types" +) + +// SetStakingInfo set a specific stakingInfo in the store from its index +func (k Keeper) SetStakingInfo(ctx sdk.Context, stakingInfo types.StakingInfo) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.StakingInfoKeyPrefix)) + b := k.cdc.MustMarshal(&stakingInfo) + store.Set(types.StakingInfoKey( + stakingInfo.Token, + stakingInfo.Staker, + ), b) +} + +// GetStakingInfo returns a stakingInfo from its index +func (k Keeper) GetStakingInfo( + ctx sdk.Context, + token string, + staker string, +) (val types.StakingInfo, found bool) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.StakingInfoKeyPrefix)) + + b := store.Get(types.StakingInfoKey( + token, + staker, + )) + if b == nil { + return val, false + } + + k.cdc.MustUnmarshal(b, &val) + return val, true +} + +// RemoveStakingInfo removes a stakingInfo from the store +func (k Keeper) RemoveStakingInfo( + ctx sdk.Context, + token string, + staker string, +) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.StakingInfoKeyPrefix)) + store.Delete(types.StakingInfoKey( + token, + staker, + )) +} + +// GetAllStakingInfo returns all stakingInfo +func (k Keeper) GetAllStakingInfo(ctx sdk.Context, token string) (list []types.StakingInfo) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.StakingInfoKeyPrefix)) + + prefix := []byte{} + if token != "" { + prefix = types.StakingInfoKey(token, "") + } + + iterator := sdk.KVStorePrefixIterator(store, prefix) + + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + var val types.StakingInfo + k.cdc.MustUnmarshal(iterator.Value(), &val) + list = append(list, val) + } + + return +} diff --git a/x/farming/keeper/staking_info_test.go b/x/farming/keeper/staking_info_test.go new file mode 100644 index 00000000..451561ee --- /dev/null +++ b/x/farming/keeper/staking_info_test.go @@ -0,0 +1,70 @@ +package keeper_test + +import ( + "strconv" + "testing" + + "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + keepertest "github.com/titantkx/titan/testutil/keeper" + "github.com/titantkx/titan/testutil/nullify" + "github.com/titantkx/titan/x/farming/keeper" + "github.com/titantkx/titan/x/farming/types" +) + +// Prevent strconv unused error +var _ = strconv.IntSize + +func createNStakingInfo(keeper *keeper.Keeper, ctx sdk.Context, n int) []types.StakingInfo { + items := make([]types.StakingInfo, n) + for i := range items { + items[i].Token = strconv.Itoa(i) + items[i].Staker = strconv.Itoa(i) + items[i].Amount = math.NewInt(int64(i)) + + keeper.SetStakingInfo(ctx, items[i]) + } + return items +} + +func TestStakingInfoGet(t *testing.T) { + keeper, ctx := keepertest.FarmingKeeper(t) + items := createNStakingInfo(keeper, ctx, 10) + for _, item := range items { + rst, found := keeper.GetStakingInfo(ctx, + item.Token, + item.Staker, + ) + require.True(t, found) + require.Equal(t, + nullify.Fill(&item), + nullify.Fill(&rst), + ) + } +} + +func TestStakingInfoRemove(t *testing.T) { + keeper, ctx := keepertest.FarmingKeeper(t) + items := createNStakingInfo(keeper, ctx, 10) + for _, item := range items { + keeper.RemoveStakingInfo(ctx, + item.Token, + item.Staker, + ) + _, found := keeper.GetStakingInfo(ctx, + item.Token, + item.Staker, + ) + require.False(t, found) + } +} + +func TestStakingInfoGetAll(t *testing.T) { + keeper, ctx := keepertest.FarmingKeeper(t) + items := createNStakingInfo(keeper, ctx, 10) + require.ElementsMatch(t, + nullify.Fill(items), + nullify.Fill(keeper.GetAllStakingInfo(ctx, "")), + ) +} diff --git a/x/farming/module.go b/x/farming/module.go new file mode 100644 index 00000000..a806da43 --- /dev/null +++ b/x/farming/module.go @@ -0,0 +1,153 @@ +package farming + +import ( + "context" + "encoding/json" + "fmt" + + // 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/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/codec" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + "github.com/titantkx/titan/x/farming/client/cli" + "github.com/titantkx/titan/x/farming/keeper" + "github.com/titantkx/titan/x/farming/types" +) + +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, marshaled 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, _ 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) { + if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil { + panic(err) + } +} + +// 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 types.AccountKeeper + bankKeeper types.BankKeeper +} + +func NewAppModule( + cdc codec.Codec, + keeper keeper.Keeper, + accountKeeper types.AccountKeeper, + bankKeeper types.BankKeeper, +) AppModule { + return AppModule{ + AppModuleBasic: NewAppModuleBasic(cdc), + keeper: keeper, + accountKeeper: accountKeeper, + bankKeeper: bankKeeper, + } +} + +// 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(ctx sdk.Context, req abci.RequestBeginBlock) { + BeginBlocker(ctx, req, am.keeper) +} + +// 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/farming/module_simulation.go b/x/farming/module_simulation.go new file mode 100644 index 00000000..e4bf306b --- /dev/null +++ b/x/farming/module_simulation.go @@ -0,0 +1,168 @@ +package farming + +import ( + "math/rand" + + "github.com/cosmos/cosmos-sdk/baseapp" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + "github.com/cosmos/cosmos-sdk/x/simulation" + "github.com/titantkx/titan/testutil/sample" + farmingsimulation "github.com/titantkx/titan/x/farming/simulation" + "github.com/titantkx/titan/x/farming/types" +) + +// avoid unused import issue +var ( + _ = sample.AccAddress + _ = farmingsimulation.FindAccount + _ = simulation.MsgEntryKind + _ = baseapp.Paramspace + _ = rand.Rand{} +) + +const ( + //nolint:gosec // this is not credentials + opWeightMsgAddReward = "op_weight_msg_add_reward" + // TODO: Determine the simulation weight value + defaultWeightMsgAddReward int = 100 + + //nolint:gosec // this is not credentials + opWeightMsgStake = "op_weight_msg_stake" + // TODO: Determine the simulation weight value + defaultWeightMsgStake int = 100 + + //nolint:gosec // this is not credentials + opWeightMsgUnstake = "op_weight_msg_unstake" + // TODO: Determine the simulation weight value + defaultWeightMsgUnstake int = 100 + + //nolint:gosec // this is not credentials + opWeightMsgHarvest = "op_weight_msg_harvest" + // TODO: Determine the simulation weight value + defaultWeightMsgHarvest int = 100 + + // this line is used by starport scaffolding # simapp/module/const +) + +// GenerateGenesisState creates a randomized GenState of the module. +func (AppModule) GenerateGenesisState(simState *module.SimulationState) { + accs := make([]string, len(simState.Accounts)) + for i, acc := range simState.Accounts { + accs[i] = acc.Address.String() + } + farmingGenesis := types.GenesisState{ + Params: types.DefaultParams(), + FarmList: []types.Farm{ + { + Token: "0", + }, + { + Token: "1", + }, + }, + // this line is used by starport scaffolding # simapp/module/genesisState + } + simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(&farmingGenesis) +} + +// RegisterStoreDecoder registers a decoder. +func (am AppModule) RegisterStoreDecoder(_ sdk.StoreDecoderRegistry) {} + +// ProposalContents doesn't return any content functions for governance proposals. +func (AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedProposalContent { //nolint:staticcheck + return nil +} + +// WeightedOperations returns the all the gov module operations with their respective weights. +func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation { + operations := make([]simtypes.WeightedOperation, 0) + + var weightMsgAddReward int + simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgAddReward, &weightMsgAddReward, nil, + func(_ *rand.Rand) { + weightMsgAddReward = defaultWeightMsgAddReward + }, + ) + operations = append(operations, simulation.NewWeightedOperation( + weightMsgAddReward, + farmingsimulation.SimulateMsgAddReward(am.accountKeeper, am.bankKeeper, am.keeper), + )) + + var weightMsgStake int + simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgStake, &weightMsgStake, nil, + func(_ *rand.Rand) { + weightMsgStake = defaultWeightMsgStake + }, + ) + operations = append(operations, simulation.NewWeightedOperation( + weightMsgStake, + farmingsimulation.SimulateMsgStake(am.accountKeeper, am.bankKeeper, am.keeper), + )) + + var weightMsgUnstake int + simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgUnstake, &weightMsgUnstake, nil, + func(_ *rand.Rand) { + weightMsgUnstake = defaultWeightMsgUnstake + }, + ) + operations = append(operations, simulation.NewWeightedOperation( + weightMsgUnstake, + farmingsimulation.SimulateMsgUnstake(am.accountKeeper, am.bankKeeper, am.keeper), + )) + + var weightMsgHarvest int + simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgHarvest, &weightMsgHarvest, nil, + func(_ *rand.Rand) { + weightMsgHarvest = defaultWeightMsgHarvest + }, + ) + operations = append(operations, simulation.NewWeightedOperation( + weightMsgHarvest, + farmingsimulation.SimulateMsgHarvest(am.accountKeeper, am.bankKeeper, am.keeper), + )) + + // this line is used by starport scaffolding # simapp/module/operation + + return operations +} + +// ProposalMsgs returns msgs used for governance proposals for simulations. +func (am AppModule) ProposalMsgs(_ module.SimulationState) []simtypes.WeightedProposalMsg { + return []simtypes.WeightedProposalMsg{ + simulation.NewWeightedProposalMsg( + opWeightMsgAddReward, + defaultWeightMsgAddReward, + func(_ *rand.Rand, _ sdk.Context, _ []simtypes.Account) sdk.Msg { + farmingsimulation.SimulateMsgAddReward(am.accountKeeper, am.bankKeeper, am.keeper) + return nil + }, + ), + simulation.NewWeightedProposalMsg( + opWeightMsgStake, + defaultWeightMsgStake, + func(_ *rand.Rand, _ sdk.Context, _ []simtypes.Account) sdk.Msg { + farmingsimulation.SimulateMsgStake(am.accountKeeper, am.bankKeeper, am.keeper) + return nil + }, + ), + simulation.NewWeightedProposalMsg( + opWeightMsgUnstake, + defaultWeightMsgUnstake, + func(_ *rand.Rand, _ sdk.Context, _ []simtypes.Account) sdk.Msg { + farmingsimulation.SimulateMsgUnstake(am.accountKeeper, am.bankKeeper, am.keeper) + return nil + }, + ), + simulation.NewWeightedProposalMsg( + opWeightMsgHarvest, + defaultWeightMsgHarvest, + func(_ *rand.Rand, _ sdk.Context, _ []simtypes.Account) sdk.Msg { + farmingsimulation.SimulateMsgHarvest(am.accountKeeper, am.bankKeeper, am.keeper) + return nil + }, + ), + // this line is used by starport scaffolding # simapp/module/OpMsg + } +} diff --git a/x/farming/simulation/add_reward.go b/x/farming/simulation/add_reward.go new file mode 100644 index 00000000..466cccaa --- /dev/null +++ b/x/farming/simulation/add_reward.go @@ -0,0 +1,26 @@ +package simulation + +import ( + "math/rand" + + "github.com/cosmos/cosmos-sdk/baseapp" + sdk "github.com/cosmos/cosmos-sdk/types" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + "github.com/titantkx/titan/x/farming/keeper" + "github.com/titantkx/titan/x/farming/types" +) + +func SimulateMsgAddReward(_ types.AccountKeeper, _ types.BankKeeper, _ keeper.Keeper) simtypes.Operation { + //nolint:revive // keep `chainID` for clear meaning + return func(r *rand.Rand, _ *baseapp.BaseApp, _ sdk.Context, accs []simtypes.Account, chainID string, + ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + simAccount, _ := simtypes.RandomAcc(r, accs) + msg := &types.MsgAddReward{ + Sender: simAccount.Address.String(), + } + + // TODO: Handling the AddReward simulation + + return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "AddReward simulation not implemented"), nil, nil + } +} diff --git a/x/farming/simulation/harvest.go b/x/farming/simulation/harvest.go new file mode 100644 index 00000000..b66645f9 --- /dev/null +++ b/x/farming/simulation/harvest.go @@ -0,0 +1,26 @@ +package simulation + +import ( + "math/rand" + + "github.com/cosmos/cosmos-sdk/baseapp" + sdk "github.com/cosmos/cosmos-sdk/types" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + "github.com/titantkx/titan/x/farming/keeper" + "github.com/titantkx/titan/x/farming/types" +) + +func SimulateMsgHarvest(_ types.AccountKeeper, _ types.BankKeeper, _ keeper.Keeper) simtypes.Operation { + //nolint:revive // keep `chainID` for clear meaning + return func(r *rand.Rand, _ *baseapp.BaseApp, _ sdk.Context, accs []simtypes.Account, chainID string, + ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + simAccount, _ := simtypes.RandomAcc(r, accs) + msg := &types.MsgHarvest{ + Sender: simAccount.Address.String(), + } + + // TODO: Handling the Harvest simulation + + return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "Harvest simulation not implemented"), nil, nil + } +} diff --git a/x/farming/simulation/helpers.go b/x/farming/simulation/helpers.go new file mode 100644 index 00000000..92c437c0 --- /dev/null +++ b/x/farming/simulation/helpers.go @@ -0,0 +1,15 @@ +package simulation + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" +) + +// FindAccount find a specific address from an account list +func FindAccount(accs []simtypes.Account, address string) (simtypes.Account, bool) { + creator, err := sdk.AccAddressFromBech32(address) + if err != nil { + panic(err) + } + return simtypes.FindAccount(accs, creator) +} diff --git a/x/farming/simulation/stake.go b/x/farming/simulation/stake.go new file mode 100644 index 00000000..a85b14ea --- /dev/null +++ b/x/farming/simulation/stake.go @@ -0,0 +1,26 @@ +package simulation + +import ( + "math/rand" + + "github.com/cosmos/cosmos-sdk/baseapp" + sdk "github.com/cosmos/cosmos-sdk/types" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + "github.com/titantkx/titan/x/farming/keeper" + "github.com/titantkx/titan/x/farming/types" +) + +func SimulateMsgStake(_ types.AccountKeeper, _ types.BankKeeper, _ keeper.Keeper) simtypes.Operation { + //nolint:revive // keep `chainID` for clear meaning + return func(r *rand.Rand, _ *baseapp.BaseApp, _ sdk.Context, accs []simtypes.Account, chainID string, + ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + simAccount, _ := simtypes.RandomAcc(r, accs) + msg := &types.MsgStake{ + Sender: simAccount.Address.String(), + } + + // TODO: Handling the Stake simulation + + return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "Stake simulation not implemented"), nil, nil + } +} diff --git a/x/farming/simulation/unstake.go b/x/farming/simulation/unstake.go new file mode 100644 index 00000000..66cdc9a4 --- /dev/null +++ b/x/farming/simulation/unstake.go @@ -0,0 +1,26 @@ +package simulation + +import ( + "math/rand" + + "github.com/cosmos/cosmos-sdk/baseapp" + sdk "github.com/cosmos/cosmos-sdk/types" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + "github.com/titantkx/titan/x/farming/keeper" + "github.com/titantkx/titan/x/farming/types" +) + +func SimulateMsgUnstake(_ types.AccountKeeper, _ types.BankKeeper, _ keeper.Keeper) simtypes.Operation { + //nolint:revive // keep `chainID` for clear meaning + return func(r *rand.Rand, _ *baseapp.BaseApp, _ sdk.Context, accs []simtypes.Account, chainID string, + ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + simAccount, _ := simtypes.RandomAcc(r, accs) + msg := &types.MsgUnstake{ + Sender: simAccount.Address.String(), + } + + // TODO: Handling the Unstake simulation + + return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "Unstake simulation not implemented"), nil, nil + } +} diff --git a/x/farming/testutil/expected_keepers_mocks.go b/x/farming/testutil/expected_keepers_mocks.go new file mode 100644 index 00000000..a7c896a1 --- /dev/null +++ b/x/farming/testutil/expected_keepers_mocks.go @@ -0,0 +1,115 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: x/farming/types/expected_keepers.go + +// Package testutil is a generated GoMock package. +package testutil + +import ( + reflect "reflect" + + types "github.com/cosmos/cosmos-sdk/types" + types0 "github.com/cosmos/cosmos-sdk/x/auth/types" + gomock "github.com/golang/mock/gomock" +) + +// MockAccountKeeper is a mock of AccountKeeper interface. +type MockAccountKeeper struct { + ctrl *gomock.Controller + recorder *MockAccountKeeperMockRecorder +} + +// MockAccountKeeperMockRecorder is the mock recorder for MockAccountKeeper. +type MockAccountKeeperMockRecorder struct { + mock *MockAccountKeeper +} + +// NewMockAccountKeeper creates a new mock instance. +func NewMockAccountKeeper(ctrl *gomock.Controller) *MockAccountKeeper { + mock := &MockAccountKeeper{ctrl: ctrl} + mock.recorder = &MockAccountKeeperMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockAccountKeeper) EXPECT() *MockAccountKeeperMockRecorder { + return m.recorder +} + +// GetAccount mocks base method. +func (m *MockAccountKeeper) GetAccount(ctx types.Context, addr types.AccAddress) types0.AccountI { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetAccount", ctx, addr) + ret0, _ := ret[0].(types0.AccountI) + return ret0 +} + +// GetAccount indicates an expected call of GetAccount. +func (mr *MockAccountKeeperMockRecorder) GetAccount(ctx, addr interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAccount", reflect.TypeOf((*MockAccountKeeper)(nil).GetAccount), ctx, addr) +} + +// MockBankKeeper is a mock of BankKeeper interface. +type MockBankKeeper struct { + ctrl *gomock.Controller + recorder *MockBankKeeperMockRecorder +} + +// MockBankKeeperMockRecorder is the mock recorder for MockBankKeeper. +type MockBankKeeperMockRecorder struct { + mock *MockBankKeeper +} + +// NewMockBankKeeper creates a new mock instance. +func NewMockBankKeeper(ctrl *gomock.Controller) *MockBankKeeper { + mock := &MockBankKeeper{ctrl: ctrl} + mock.recorder = &MockBankKeeperMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockBankKeeper) EXPECT() *MockBankKeeperMockRecorder { + return m.recorder +} + +// SendCoinsFromAccountToModule mocks base method. +func (m *MockBankKeeper) SendCoinsFromAccountToModule(ctx types.Context, senderAddr types.AccAddress, recipientModule string, amt types.Coins) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SendCoinsFromAccountToModule", ctx, senderAddr, recipientModule, amt) + ret0, _ := ret[0].(error) + return ret0 +} + +// SendCoinsFromAccountToModule indicates an expected call of SendCoinsFromAccountToModule. +func (mr *MockBankKeeperMockRecorder) SendCoinsFromAccountToModule(ctx, senderAddr, recipientModule, amt interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendCoinsFromAccountToModule", reflect.TypeOf((*MockBankKeeper)(nil).SendCoinsFromAccountToModule), ctx, senderAddr, recipientModule, amt) +} + +// SendCoinsFromModuleToAccount mocks base method. +func (m *MockBankKeeper) SendCoinsFromModuleToAccount(ctx types.Context, senderModule string, recipientAddr types.AccAddress, amt types.Coins) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SendCoinsFromModuleToAccount", ctx, senderModule, recipientAddr, amt) + ret0, _ := ret[0].(error) + return ret0 +} + +// SendCoinsFromModuleToAccount indicates an expected call of SendCoinsFromModuleToAccount. +func (mr *MockBankKeeperMockRecorder) SendCoinsFromModuleToAccount(ctx, senderModule, recipientAddr, amt interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendCoinsFromModuleToAccount", reflect.TypeOf((*MockBankKeeper)(nil).SendCoinsFromModuleToAccount), ctx, senderModule, recipientAddr, amt) +} + +// SpendableCoins mocks base method. +func (m *MockBankKeeper) SpendableCoins(ctx types.Context, addr types.AccAddress) types.Coins { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SpendableCoins", ctx, addr) + ret0, _ := ret[0].(types.Coins) + return ret0 +} + +// SpendableCoins indicates an expected call of SpendableCoins. +func (mr *MockBankKeeperMockRecorder) SpendableCoins(ctx, addr interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SpendableCoins", reflect.TypeOf((*MockBankKeeper)(nil).SpendableCoins), ctx, addr) +} diff --git a/x/farming/types/codec.go b/x/farming/types/codec.go new file mode 100644 index 00000000..30fbe707 --- /dev/null +++ b/x/farming/types/codec.go @@ -0,0 +1,39 @@ +package types + +import ( + "github.com/cosmos/cosmos-sdk/codec" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/msgservice" +) + +func RegisterCodec(cdc *codec.LegacyAmino) { + cdc.RegisterConcrete(&MsgAddReward{}, "farming/AddReward", nil) + cdc.RegisterConcrete(&MsgStake{}, "farming/Stake", nil) + cdc.RegisterConcrete(&MsgUnstake{}, "farming/Unstake", nil) + cdc.RegisterConcrete(&MsgHarvest{}, "farming/Harvest", nil) + // this line is used by starport scaffolding # 2 +} + +func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { + registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgAddReward{}, + ) + registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgStake{}, + ) + registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgUnstake{}, + ) + registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgHarvest{}, + ) + // 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/farming/types/distribution_info.pb.go b/x/farming/types/distribution_info.pb.go new file mode 100644 index 00000000..1a6b1568 --- /dev/null +++ b/x/farming/types/distribution_info.pb.go @@ -0,0 +1,327 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: titan/farming/distribution_info.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + github_com_cosmos_gogoproto_types "github.com/cosmos/gogoproto/types" + _ "google.golang.org/protobuf/types/known/timestamppb" + io "io" + math "math" + math_bits "math/bits" + time "time" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf +var _ = time.Kitchen + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// DistributionInfo defines the reward distribution info. +type DistributionInfo struct { + LastDistributionTime time.Time `protobuf:"bytes,1,opt,name=last_distribution_time,json=lastDistributionTime,proto3,stdtime" json:"last_distribution_time"` +} + +func (m *DistributionInfo) Reset() { *m = DistributionInfo{} } +func (m *DistributionInfo) String() string { return proto.CompactTextString(m) } +func (*DistributionInfo) ProtoMessage() {} +func (*DistributionInfo) Descriptor() ([]byte, []int) { + return fileDescriptor_e51cb1e83d3ea1e0, []int{0} +} +func (m *DistributionInfo) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *DistributionInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_DistributionInfo.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 *DistributionInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_DistributionInfo.Merge(m, src) +} +func (m *DistributionInfo) XXX_Size() int { + return m.Size() +} +func (m *DistributionInfo) XXX_DiscardUnknown() { + xxx_messageInfo_DistributionInfo.DiscardUnknown(m) +} + +var xxx_messageInfo_DistributionInfo proto.InternalMessageInfo + +func (m *DistributionInfo) GetLastDistributionTime() time.Time { + if m != nil { + return m.LastDistributionTime + } + return time.Time{} +} + +func init() { + proto.RegisterType((*DistributionInfo)(nil), "titan.farming.DistributionInfo") +} + +func init() { + proto.RegisterFile("titan/farming/distribution_info.proto", fileDescriptor_e51cb1e83d3ea1e0) +} + +var fileDescriptor_e51cb1e83d3ea1e0 = []byte{ + // 232 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x2d, 0xc9, 0x2c, 0x49, + 0xcc, 0xd3, 0x4f, 0x4b, 0x2c, 0xca, 0xcd, 0xcc, 0x4b, 0xd7, 0x4f, 0xc9, 0x2c, 0x2e, 0x29, 0xca, + 0x4c, 0x2a, 0x2d, 0xc9, 0xcc, 0xcf, 0x8b, 0xcf, 0xcc, 0x4b, 0xcb, 0xd7, 0x2b, 0x28, 0xca, 0x2f, + 0xc9, 0x17, 0xe2, 0x05, 0x2b, 0xd3, 0x83, 0x2a, 0x93, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0xcb, + 0xe8, 0x83, 0x58, 0x10, 0x45, 0x52, 0xf2, 0xe9, 0xf9, 0xf9, 0xe9, 0x39, 0xa9, 0xfa, 0x60, 0x5e, + 0x52, 0x69, 0x9a, 0x7e, 0x49, 0x66, 0x6e, 0x6a, 0x71, 0x49, 0x62, 0x6e, 0x01, 0x44, 0x81, 0x52, + 0x1e, 0x97, 0x80, 0x0b, 0x92, 0x05, 0x9e, 0x79, 0x69, 0xf9, 0x42, 0x51, 0x5c, 0x62, 0x39, 0x89, + 0xc5, 0x25, 0xf1, 0x28, 0x36, 0x83, 0x34, 0x4a, 0x30, 0x2a, 0x30, 0x6a, 0x70, 0x1b, 0x49, 0xe9, + 0x41, 0x4c, 0xd5, 0x83, 0x99, 0xaa, 0x17, 0x02, 0x33, 0xd5, 0x89, 0xe3, 0xc4, 0x3d, 0x79, 0x86, + 0x09, 0xf7, 0xe5, 0x19, 0x83, 0x44, 0x40, 0x66, 0x20, 0x9b, 0x0d, 0x52, 0xe4, 0xe4, 0x7c, 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, 0x9a, 0xe9, 0x99, 0x25, 0x19, 0xa5, 0x49, + 0x7a, 0xc9, 0xf9, 0xb9, 0xfa, 0x60, 0xaf, 0x95, 0x64, 0x57, 0x40, 0x18, 0xfa, 0x15, 0xf0, 0xc0, + 0x28, 0xa9, 0x2c, 0x48, 0x2d, 0x4e, 0x62, 0x03, 0x5b, 0x6c, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, + 0x37, 0xf4, 0xed, 0x47, 0x2a, 0x01, 0x00, 0x00, +} + +func (m *DistributionInfo) 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 *DistributionInfo) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *DistributionInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + n1, err1 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.LastDistributionTime, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.LastDistributionTime):]) + if err1 != nil { + return 0, err1 + } + i -= n1 + i = encodeVarintDistributionInfo(dAtA, i, uint64(n1)) + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func encodeVarintDistributionInfo(dAtA []byte, offset int, v uint64) int { + offset -= sovDistributionInfo(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *DistributionInfo) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = github_com_cosmos_gogoproto_types.SizeOfStdTime(m.LastDistributionTime) + n += 1 + l + sovDistributionInfo(uint64(l)) + return n +} + +func sovDistributionInfo(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozDistributionInfo(x uint64) (n int) { + return sovDistributionInfo(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *DistributionInfo) 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 ErrIntOverflowDistributionInfo + } + 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: DistributionInfo: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DistributionInfo: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field LastDistributionTime", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDistributionInfo + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthDistributionInfo + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthDistributionInfo + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_cosmos_gogoproto_types.StdTimeUnmarshal(&m.LastDistributionTime, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipDistributionInfo(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthDistributionInfo + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipDistributionInfo(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, ErrIntOverflowDistributionInfo + } + 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, ErrIntOverflowDistributionInfo + } + 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, ErrIntOverflowDistributionInfo + } + 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, ErrInvalidLengthDistributionInfo + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupDistributionInfo + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthDistributionInfo + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthDistributionInfo = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowDistributionInfo = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupDistributionInfo = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/farming/types/errors.go b/x/farming/types/errors.go new file mode 100644 index 00000000..b1b4335f --- /dev/null +++ b/x/farming/types/errors.go @@ -0,0 +1,29 @@ +package types + +// DONTCOVER + +import ( + sdkerrors "cosmossdk.io/errors" +) + +// x/farming module sentinel errors +var ( + ErrInternal = sdkerrors.Register(ModuleName, 1100, "internal error") + ErrInvalidTime = sdkerrors.Register(ModuleName, 1101, "invalid time") + ErrInvalidToken = sdkerrors.Register(ModuleName, 1102, "invalid token") + ErrInvalidStakingAmount = sdkerrors.Register(ModuleName, 1103, "invalid staking amount") + ErrStakingBalanceNotEnough = sdkerrors.Register(ModuleName, 1104, "staking balance not enough") + ErrNoReward = sdkerrors.Register(ModuleName, 1105, "no reward") +) + +func WrapError(err error, description string) error { + return sdkerrors.Wrap(err, description) +} + +func WrapErrorf(err error, format string, args ...interface{}) error { + return sdkerrors.Wrapf(err, format, args...) +} + +func WrapInternalError(err error) error { + return sdkerrors.Wrapf(ErrInternal, ErrInternal.Error(), err) +} diff --git a/x/farming/types/event.pb.go b/x/farming/types/event.pb.go new file mode 100644 index 00000000..e096357d --- /dev/null +++ b/x/farming/types/event.pb.go @@ -0,0 +1,1257 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: titan/farming/event.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/cosmos/cosmos-sdk/types/tx/amino" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + github_com_cosmos_gogoproto_types "github.com/cosmos/gogoproto/types" + _ "google.golang.org/protobuf/types/known/timestamppb" + io "io" + math "math" + math_bits "math/bits" + time "time" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf +var _ = time.Kitchen + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// EventAddReward is emitted on AddReward. +type EventAddReward struct { + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + Token string `protobuf:"bytes,2,opt,name=token,proto3" json:"token,omitempty"` + Amount github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,3,rep,name=amount,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"amount"` + EndTime time.Time `protobuf:"bytes,4,opt,name=end_time,json=endTime,proto3,stdtime" json:"end_time"` + StartTime time.Time `protobuf:"bytes,5,opt,name=start_time,json=startTime,proto3,stdtime" json:"start_time"` +} + +func (m *EventAddReward) Reset() { *m = EventAddReward{} } +func (m *EventAddReward) String() string { return proto.CompactTextString(m) } +func (*EventAddReward) ProtoMessage() {} +func (*EventAddReward) Descriptor() ([]byte, []int) { + return fileDescriptor_ce381573f1c1ec73, []int{0} +} +func (m *EventAddReward) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EventAddReward) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EventAddReward.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 *EventAddReward) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventAddReward.Merge(m, src) +} +func (m *EventAddReward) XXX_Size() int { + return m.Size() +} +func (m *EventAddReward) XXX_DiscardUnknown() { + xxx_messageInfo_EventAddReward.DiscardUnknown(m) +} + +var xxx_messageInfo_EventAddReward proto.InternalMessageInfo + +func (m *EventAddReward) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +func (m *EventAddReward) GetToken() string { + if m != nil { + return m.Token + } + return "" +} + +func (m *EventAddReward) GetAmount() github_com_cosmos_cosmos_sdk_types.Coins { + if m != nil { + return m.Amount + } + return nil +} + +func (m *EventAddReward) GetEndTime() time.Time { + if m != nil { + return m.EndTime + } + return time.Time{} +} + +func (m *EventAddReward) GetStartTime() time.Time { + if m != nil { + return m.StartTime + } + return time.Time{} +} + +// EventStake is emitted on Stake. +type EventStake struct { + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + Amount github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,2,rep,name=amount,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"amount"` +} + +func (m *EventStake) Reset() { *m = EventStake{} } +func (m *EventStake) String() string { return proto.CompactTextString(m) } +func (*EventStake) ProtoMessage() {} +func (*EventStake) Descriptor() ([]byte, []int) { + return fileDescriptor_ce381573f1c1ec73, []int{1} +} +func (m *EventStake) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EventStake) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EventStake.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 *EventStake) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventStake.Merge(m, src) +} +func (m *EventStake) XXX_Size() int { + return m.Size() +} +func (m *EventStake) XXX_DiscardUnknown() { + xxx_messageInfo_EventStake.DiscardUnknown(m) +} + +var xxx_messageInfo_EventStake proto.InternalMessageInfo + +func (m *EventStake) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +func (m *EventStake) GetAmount() github_com_cosmos_cosmos_sdk_types.Coins { + if m != nil { + return m.Amount + } + return nil +} + +// EventUnstake is emitted on Unstake. +type EventUnstake struct { + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + Amount github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,2,rep,name=amount,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"amount"` +} + +func (m *EventUnstake) Reset() { *m = EventUnstake{} } +func (m *EventUnstake) String() string { return proto.CompactTextString(m) } +func (*EventUnstake) ProtoMessage() {} +func (*EventUnstake) Descriptor() ([]byte, []int) { + return fileDescriptor_ce381573f1c1ec73, []int{2} +} +func (m *EventUnstake) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EventUnstake) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EventUnstake.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 *EventUnstake) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventUnstake.Merge(m, src) +} +func (m *EventUnstake) XXX_Size() int { + return m.Size() +} +func (m *EventUnstake) XXX_DiscardUnknown() { + xxx_messageInfo_EventUnstake.DiscardUnknown(m) +} + +var xxx_messageInfo_EventUnstake proto.InternalMessageInfo + +func (m *EventUnstake) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +func (m *EventUnstake) GetAmount() github_com_cosmos_cosmos_sdk_types.Coins { + if m != nil { + return m.Amount + } + return nil +} + +// EventHarvest is emitted on Harvest. +type EventHarvest struct { + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + Amount github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,2,rep,name=amount,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"amount"` +} + +func (m *EventHarvest) Reset() { *m = EventHarvest{} } +func (m *EventHarvest) String() string { return proto.CompactTextString(m) } +func (*EventHarvest) ProtoMessage() {} +func (*EventHarvest) Descriptor() ([]byte, []int) { + return fileDescriptor_ce381573f1c1ec73, []int{3} +} +func (m *EventHarvest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EventHarvest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EventHarvest.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 *EventHarvest) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventHarvest.Merge(m, src) +} +func (m *EventHarvest) XXX_Size() int { + return m.Size() +} +func (m *EventHarvest) XXX_DiscardUnknown() { + xxx_messageInfo_EventHarvest.DiscardUnknown(m) +} + +var xxx_messageInfo_EventHarvest proto.InternalMessageInfo + +func (m *EventHarvest) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +func (m *EventHarvest) GetAmount() github_com_cosmos_cosmos_sdk_types.Coins { + if m != nil { + return m.Amount + } + return nil +} + +func init() { + proto.RegisterType((*EventAddReward)(nil), "titan.farming.EventAddReward") + proto.RegisterType((*EventStake)(nil), "titan.farming.EventStake") + proto.RegisterType((*EventUnstake)(nil), "titan.farming.EventUnstake") + proto.RegisterType((*EventHarvest)(nil), "titan.farming.EventHarvest") +} + +func init() { proto.RegisterFile("titan/farming/event.proto", fileDescriptor_ce381573f1c1ec73) } + +var fileDescriptor_ce381573f1c1ec73 = []byte{ + // 455 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x54, 0xbd, 0x6e, 0x13, 0x41, + 0x10, 0xf6, 0x3a, 0xc4, 0x24, 0x9b, 0x80, 0xc4, 0xc9, 0xc5, 0xd9, 0xc5, 0xd9, 0x72, 0x65, 0x22, + 0x65, 0x97, 0x84, 0x07, 0x40, 0xb1, 0x05, 0xa2, 0xbe, 0x40, 0x43, 0x63, 0xed, 0x79, 0x27, 0xc7, + 0xc9, 0xb9, 0x5d, 0xeb, 0x76, 0x6c, 0xe2, 0xb7, 0x48, 0xcd, 0x13, 0x20, 0xaa, 0x14, 0x34, 0x88, + 0x17, 0x48, 0x19, 0x51, 0x41, 0x43, 0x90, 0x5d, 0xe4, 0x35, 0xd0, 0xfe, 0x04, 0x68, 0xa1, 0x88, + 0xe4, 0xe6, 0x6e, 0x67, 0xbe, 0x99, 0xf9, 0xe6, 0xfb, 0xb4, 0x5a, 0xda, 0xc2, 0x02, 0x85, 0xe2, + 0x27, 0xa2, 0x2a, 0x0b, 0x95, 0x73, 0x98, 0x83, 0x42, 0x36, 0xad, 0x34, 0xea, 0xe8, 0x81, 0x83, + 0x58, 0x80, 0xda, 0x8f, 0x44, 0x59, 0x28, 0xcd, 0xdd, 0xd7, 0x57, 0xb4, 0x93, 0xb1, 0x36, 0xa5, + 0x36, 0x3c, 0x13, 0x06, 0xf8, 0xfc, 0x20, 0x03, 0x14, 0x07, 0x7c, 0xac, 0x0b, 0x15, 0xf0, 0x96, + 0xc7, 0x47, 0x2e, 0xe2, 0x3e, 0x08, 0x50, 0x33, 0xd7, 0xb9, 0xf6, 0x79, 0x7b, 0x0a, 0xd9, 0x4e, + 0xae, 0x75, 0x7e, 0x0a, 0xdc, 0x45, 0xd9, 0xec, 0x84, 0x63, 0x51, 0x82, 0x41, 0x51, 0x4e, 0x7d, + 0x41, 0xef, 0x7b, 0x9d, 0x3e, 0x7c, 0x6e, 0x77, 0x3c, 0x92, 0x32, 0x85, 0x77, 0xa2, 0x92, 0xd1, + 0x13, 0xda, 0x30, 0xa0, 0x24, 0x54, 0x31, 0xe9, 0x92, 0xfe, 0xf6, 0x20, 0xfe, 0xfa, 0x69, 0xbf, + 0x19, 0xb8, 0x8e, 0xa4, 0xac, 0xc0, 0x98, 0x63, 0xac, 0x0a, 0x95, 0xa7, 0xa1, 0x2e, 0x6a, 0xd2, + 0x4d, 0xd4, 0x13, 0x50, 0x71, 0xdd, 0x36, 0xa4, 0x3e, 0x88, 0x16, 0xb4, 0x21, 0x4a, 0x3d, 0x53, + 0x18, 0x6f, 0x74, 0x37, 0xfa, 0x3b, 0x87, 0x2d, 0x16, 0x86, 0x58, 0x75, 0x2c, 0xa8, 0x63, 0x43, + 0x5d, 0xa8, 0xc1, 0x8b, 0xcb, 0x1f, 0x9d, 0xda, 0xc7, 0xeb, 0x4e, 0x3f, 0x2f, 0xf0, 0xed, 0x2c, + 0x63, 0x63, 0x5d, 0x06, 0x75, 0xe1, 0xb7, 0x6f, 0xe4, 0x84, 0xe3, 0x62, 0x0a, 0xc6, 0x35, 0x98, + 0xf7, 0x37, 0x17, 0x7b, 0xbb, 0xa7, 0x90, 0x8b, 0xf1, 0x62, 0x64, 0xfd, 0x31, 0x1f, 0x6e, 0x2e, + 0xf6, 0x48, 0x1a, 0x08, 0xa3, 0x67, 0x74, 0x0b, 0x94, 0x1c, 0x59, 0xb1, 0xf1, 0xbd, 0x2e, 0xe9, + 0xef, 0x1c, 0xb6, 0x99, 0x77, 0x82, 0xdd, 0x3a, 0xc1, 0x5e, 0xdd, 0x3a, 0x31, 0xd8, 0xb2, 0xec, + 0xe7, 0xd7, 0x1d, 0x92, 0xde, 0x07, 0x25, 0x6d, 0x3e, 0x1a, 0x52, 0x6a, 0x50, 0x54, 0xe8, 0x47, + 0x6c, 0xfe, 0xc3, 0x88, 0x6d, 0xd7, 0x67, 0x91, 0xde, 0x67, 0x42, 0xa9, 0xf3, 0xf6, 0x18, 0xc5, + 0x04, 0xfe, 0xc3, 0xd7, 0x3f, 0x0e, 0xd6, 0xef, 0xd8, 0xc1, 0xde, 0x17, 0x42, 0x77, 0xdd, 0xee, + 0xaf, 0x95, 0x59, 0xe3, 0xed, 0x5f, 0x8a, 0x6a, 0x0e, 0x06, 0xd7, 0x6a, 0xfb, 0xc1, 0xf0, 0x72, + 0x99, 0x90, 0xab, 0x65, 0x42, 0x7e, 0x2e, 0x13, 0x72, 0xbe, 0x4a, 0x6a, 0x57, 0xab, 0xa4, 0xf6, + 0x6d, 0x95, 0xd4, 0xde, 0x3c, 0xfe, 0x8b, 0xc1, 0x3d, 0x26, 0x38, 0x39, 0xf3, 0x07, 0x7e, 0xf6, + 0xfb, 0xc9, 0x71, 0x44, 0x59, 0xc3, 0xdd, 0xd2, 0xa7, 0xbf, 0x02, 0x00, 0x00, 0xff, 0xff, 0xa0, + 0x7b, 0xe3, 0x5b, 0x90, 0x04, 0x00, 0x00, +} + +func (m *EventAddReward) 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 *EventAddReward) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventAddReward) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + n1, err1 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.StartTime, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.StartTime):]) + if err1 != nil { + return 0, err1 + } + i -= n1 + i = encodeVarintEvent(dAtA, i, uint64(n1)) + i-- + dAtA[i] = 0x2a + n2, err2 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.EndTime, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.EndTime):]) + if err2 != nil { + return 0, err2 + } + i -= n2 + i = encodeVarintEvent(dAtA, i, uint64(n2)) + i-- + dAtA[i] = 0x22 + if len(m.Amount) > 0 { + for iNdEx := len(m.Amount) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Amount[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintEvent(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + if len(m.Token) > 0 { + i -= len(m.Token) + copy(dAtA[i:], m.Token) + i = encodeVarintEvent(dAtA, i, uint64(len(m.Token))) + i-- + dAtA[i] = 0x12 + } + if len(m.Sender) > 0 { + i -= len(m.Sender) + copy(dAtA[i:], m.Sender) + i = encodeVarintEvent(dAtA, i, uint64(len(m.Sender))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *EventStake) 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 *EventStake) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventStake) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Amount) > 0 { + for iNdEx := len(m.Amount) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Amount[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintEvent(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if len(m.Sender) > 0 { + i -= len(m.Sender) + copy(dAtA[i:], m.Sender) + i = encodeVarintEvent(dAtA, i, uint64(len(m.Sender))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *EventUnstake) 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 *EventUnstake) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventUnstake) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Amount) > 0 { + for iNdEx := len(m.Amount) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Amount[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintEvent(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if len(m.Sender) > 0 { + i -= len(m.Sender) + copy(dAtA[i:], m.Sender) + i = encodeVarintEvent(dAtA, i, uint64(len(m.Sender))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *EventHarvest) 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 *EventHarvest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventHarvest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Amount) > 0 { + for iNdEx := len(m.Amount) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Amount[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintEvent(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if len(m.Sender) > 0 { + i -= len(m.Sender) + copy(dAtA[i:], m.Sender) + i = encodeVarintEvent(dAtA, i, uint64(len(m.Sender))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintEvent(dAtA []byte, offset int, v uint64) int { + offset -= sovEvent(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *EventAddReward) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovEvent(uint64(l)) + } + l = len(m.Token) + if l > 0 { + n += 1 + l + sovEvent(uint64(l)) + } + if len(m.Amount) > 0 { + for _, e := range m.Amount { + l = e.Size() + n += 1 + l + sovEvent(uint64(l)) + } + } + l = github_com_cosmos_gogoproto_types.SizeOfStdTime(m.EndTime) + n += 1 + l + sovEvent(uint64(l)) + l = github_com_cosmos_gogoproto_types.SizeOfStdTime(m.StartTime) + n += 1 + l + sovEvent(uint64(l)) + return n +} + +func (m *EventStake) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovEvent(uint64(l)) + } + if len(m.Amount) > 0 { + for _, e := range m.Amount { + l = e.Size() + n += 1 + l + sovEvent(uint64(l)) + } + } + return n +} + +func (m *EventUnstake) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovEvent(uint64(l)) + } + if len(m.Amount) > 0 { + for _, e := range m.Amount { + l = e.Size() + n += 1 + l + sovEvent(uint64(l)) + } + } + return n +} + +func (m *EventHarvest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovEvent(uint64(l)) + } + if len(m.Amount) > 0 { + for _, e := range m.Amount { + l = e.Size() + n += 1 + l + sovEvent(uint64(l)) + } + } + return n +} + +func sovEvent(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozEvent(x uint64) (n int) { + return sovEvent(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *EventAddReward) 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 ErrIntOverflowEvent + } + 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: EventAddReward: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventAddReward: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEvent + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvent + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Sender = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Token", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEvent + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvent + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Token = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthEvent + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthEvent + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Amount = append(m.Amount, types.Coin{}) + if err := m.Amount[len(m.Amount)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EndTime", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthEvent + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthEvent + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_cosmos_gogoproto_types.StdTimeUnmarshal(&m.EndTime, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StartTime", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthEvent + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthEvent + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_cosmos_gogoproto_types.StdTimeUnmarshal(&m.StartTime, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipEvent(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvent + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *EventStake) 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 ErrIntOverflowEvent + } + 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: EventStake: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventStake: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEvent + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvent + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Sender = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthEvent + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthEvent + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Amount = append(m.Amount, types.Coin{}) + if err := m.Amount[len(m.Amount)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipEvent(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvent + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *EventUnstake) 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 ErrIntOverflowEvent + } + 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: EventUnstake: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventUnstake: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEvent + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvent + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Sender = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthEvent + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthEvent + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Amount = append(m.Amount, types.Coin{}) + if err := m.Amount[len(m.Amount)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipEvent(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvent + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *EventHarvest) 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 ErrIntOverflowEvent + } + 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: EventHarvest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventHarvest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEvent + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvent + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Sender = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthEvent + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthEvent + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Amount = append(m.Amount, types.Coin{}) + if err := m.Amount[len(m.Amount)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipEvent(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvent + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipEvent(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, ErrIntOverflowEvent + } + 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, ErrIntOverflowEvent + } + 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, ErrIntOverflowEvent + } + 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, ErrInvalidLengthEvent + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupEvent + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthEvent + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthEvent = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowEvent = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupEvent = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/farming/types/expected_keepers.go b/x/farming/types/expected_keepers.go new file mode 100644 index 00000000..bf41317b --- /dev/null +++ b/x/farming/types/expected_keepers.go @@ -0,0 +1,20 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/auth/types" +) + +// AccountKeeper defines the expected account keeper used for simulations (noalias) +type AccountKeeper interface { + GetAccount(ctx sdk.Context, addr sdk.AccAddress) types.AccountI + // Methods imported from account should be defined here +} + +// BankKeeper defines the expected interface needed to retrieve account balances. +type BankKeeper interface { + SpendableCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins + // Methods imported from bank should be defined here + SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error + SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error +} diff --git a/x/farming/types/farm.pb.go b/x/farming/types/farm.pb.go new file mode 100644 index 00000000..cec05258 --- /dev/null +++ b/x/farming/types/farm.pb.go @@ -0,0 +1,738 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: titan/farming/farm.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/cosmos/cosmos-sdk/types/tx/amino" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + github_com_cosmos_gogoproto_types "github.com/cosmos/gogoproto/types" + _ "google.golang.org/protobuf/types/known/timestamppb" + io "io" + math "math" + math_bits "math/bits" + time "time" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf +var _ = time.Kitchen + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// Farm defines the farming rewards for a token. +type Farm struct { + Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` + Rewards []*FarmReward `protobuf:"bytes,2,rep,name=rewards,proto3" json:"rewards,omitempty"` +} + +func (m *Farm) Reset() { *m = Farm{} } +func (m *Farm) String() string { return proto.CompactTextString(m) } +func (*Farm) ProtoMessage() {} +func (*Farm) Descriptor() ([]byte, []int) { + return fileDescriptor_a56e8f061d8bd3d8, []int{0} +} +func (m *Farm) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Farm) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Farm.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 *Farm) XXX_Merge(src proto.Message) { + xxx_messageInfo_Farm.Merge(m, src) +} +func (m *Farm) XXX_Size() int { + return m.Size() +} +func (m *Farm) XXX_DiscardUnknown() { + xxx_messageInfo_Farm.DiscardUnknown(m) +} + +var xxx_messageInfo_Farm proto.InternalMessageInfo + +func (m *Farm) GetToken() string { + if m != nil { + return m.Token + } + return "" +} + +func (m *Farm) GetRewards() []*FarmReward { + if m != nil { + return m.Rewards + } + return nil +} + +// FarmReward defines the farming rewards. +type FarmReward struct { + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + Amount github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,2,rep,name=amount,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"amount"` + EndTime time.Time `protobuf:"bytes,3,opt,name=end_time,json=endTime,proto3,stdtime" json:"end_time"` + StartTime time.Time `protobuf:"bytes,4,opt,name=start_time,json=startTime,proto3,stdtime" json:"start_time"` +} + +func (m *FarmReward) Reset() { *m = FarmReward{} } +func (m *FarmReward) String() string { return proto.CompactTextString(m) } +func (*FarmReward) ProtoMessage() {} +func (*FarmReward) Descriptor() ([]byte, []int) { + return fileDescriptor_a56e8f061d8bd3d8, []int{1} +} +func (m *FarmReward) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *FarmReward) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_FarmReward.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 *FarmReward) XXX_Merge(src proto.Message) { + xxx_messageInfo_FarmReward.Merge(m, src) +} +func (m *FarmReward) XXX_Size() int { + return m.Size() +} +func (m *FarmReward) XXX_DiscardUnknown() { + xxx_messageInfo_FarmReward.DiscardUnknown(m) +} + +var xxx_messageInfo_FarmReward proto.InternalMessageInfo + +func (m *FarmReward) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +func (m *FarmReward) GetAmount() github_com_cosmos_cosmos_sdk_types.Coins { + if m != nil { + return m.Amount + } + return nil +} + +func (m *FarmReward) GetEndTime() time.Time { + if m != nil { + return m.EndTime + } + return time.Time{} +} + +func (m *FarmReward) GetStartTime() time.Time { + if m != nil { + return m.StartTime + } + return time.Time{} +} + +func init() { + proto.RegisterType((*Farm)(nil), "titan.farming.Farm") + proto.RegisterType((*FarmReward)(nil), "titan.farming.FarmReward") +} + +func init() { proto.RegisterFile("titan/farming/farm.proto", fileDescriptor_a56e8f061d8bd3d8) } + +var fileDescriptor_a56e8f061d8bd3d8 = []byte{ + // 425 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x92, 0xbf, 0x6e, 0xdb, 0x30, + 0x10, 0xc6, 0xc5, 0x24, 0x75, 0x12, 0xa6, 0x1d, 0x2a, 0x78, 0x50, 0x3c, 0x48, 0x46, 0x26, 0x35, + 0x40, 0xc8, 0x26, 0x79, 0x80, 0xa2, 0x32, 0x90, 0xbd, 0x6a, 0xa7, 0x2e, 0x06, 0x25, 0x31, 0x2c, + 0xe1, 0x90, 0x34, 0x48, 0xba, 0x8d, 0xdf, 0x22, 0x73, 0x9f, 0xa0, 0xe8, 0x94, 0xa1, 0x7b, 0xd7, + 0x8c, 0x41, 0xa7, 0x4e, 0x4d, 0x61, 0x0f, 0x7e, 0x8d, 0x82, 0x7f, 0xec, 0xb6, 0x63, 0x16, 0x91, + 0x77, 0xdf, 0x77, 0x77, 0xba, 0x9f, 0x04, 0x33, 0xcb, 0x2d, 0x91, 0xf8, 0x92, 0x68, 0xc1, 0x25, + 0xf3, 0x27, 0x9a, 0x6a, 0x65, 0x55, 0xfa, 0xcc, 0x2b, 0x28, 0x2a, 0x83, 0xe7, 0x44, 0x70, 0xa9, + 0xb0, 0x7f, 0x06, 0xc7, 0x20, 0x6f, 0x95, 0x11, 0xca, 0xe0, 0x86, 0x18, 0x8a, 0x3f, 0x9e, 0x36, + 0xd4, 0x92, 0x53, 0xdc, 0x2a, 0x2e, 0xa3, 0x7e, 0x18, 0xf4, 0xb1, 0x8f, 0x70, 0x08, 0xa2, 0xd4, + 0x67, 0x8a, 0xa9, 0x90, 0x77, 0xb7, 0x98, 0x2d, 0x98, 0x52, 0xec, 0x8a, 0x62, 0x1f, 0x35, 0xb3, + 0x4b, 0x6c, 0xb9, 0xa0, 0xc6, 0x12, 0x31, 0x0d, 0x86, 0xa3, 0x37, 0x70, 0xe7, 0x82, 0x68, 0x91, + 0xf6, 0xe1, 0x13, 0xab, 0x26, 0x54, 0x66, 0x60, 0x08, 0xca, 0xfd, 0x3a, 0x04, 0xe9, 0x39, 0xdc, + 0xd5, 0xf4, 0x13, 0xd1, 0x9d, 0xc9, 0xb6, 0x86, 0xdb, 0xe5, 0xc1, 0xd9, 0x21, 0xfa, 0x6f, 0x07, + 0xe4, 0x6a, 0x6b, 0xef, 0xa8, 0xd7, 0xce, 0xa3, 0xef, 0x5b, 0x10, 0xfe, 0xcd, 0xa7, 0x2f, 0x61, + 0xcf, 0x50, 0xd9, 0x51, 0x1d, 0x5a, 0x57, 0xd9, 0x8f, 0x6f, 0x27, 0xfd, 0xf8, 0xea, 0xaf, 0xbb, + 0x4e, 0x53, 0x63, 0xde, 0x5a, 0xcd, 0x25, 0xab, 0xa3, 0x2f, 0x9d, 0xc3, 0x1e, 0x11, 0x6a, 0x26, + 0xed, 0x66, 0x68, 0xb4, 0x3b, 0x2c, 0x28, 0x62, 0x41, 0x23, 0xc5, 0x65, 0x75, 0x71, 0xf7, 0xab, + 0x48, 0xbe, 0x3e, 0x14, 0x25, 0xe3, 0xf6, 0xc3, 0xac, 0x41, 0xad, 0x12, 0x11, 0x4b, 0x3c, 0x4e, + 0x4c, 0x37, 0xc1, 0x76, 0x3e, 0xa5, 0xc6, 0x17, 0x98, 0xcf, 0xab, 0xdb, 0xe3, 0xa7, 0x57, 0x94, + 0x91, 0x76, 0x3e, 0x76, 0x60, 0xcd, 0x97, 0xd5, 0xed, 0x31, 0xa8, 0xe3, 0xc0, 0xf4, 0x15, 0xdc, + 0xa3, 0xb2, 0x1b, 0x3b, 0x4a, 0xd9, 0xf6, 0x10, 0x94, 0x07, 0x67, 0x03, 0x14, 0x10, 0xa2, 0x35, + 0x42, 0xf4, 0x6e, 0x8d, 0xb0, 0xda, 0x73, 0xd3, 0x6f, 0x1e, 0x0a, 0x50, 0xef, 0x52, 0xd9, 0xb9, + 0x7c, 0x3a, 0x82, 0xd0, 0x58, 0xa2, 0x6d, 0x68, 0xb1, 0xf3, 0x88, 0x16, 0xfb, 0xbe, 0xce, 0x29, + 0xd5, 0xe8, 0x6e, 0x91, 0x83, 0xfb, 0x45, 0x0e, 0x7e, 0x2f, 0x72, 0x70, 0xb3, 0xcc, 0x93, 0xfb, + 0x65, 0x9e, 0xfc, 0x5c, 0xe6, 0xc9, 0xfb, 0x17, 0xff, 0xec, 0xe9, 0xbf, 0x84, 0x9d, 0x5c, 0x87, + 0x0b, 0xbe, 0xde, 0xfc, 0x72, 0x7e, 0xdd, 0xa6, 0xe7, 0xa7, 0x9d, 0xff, 0x09, 0x00, 0x00, 0xff, + 0xff, 0xac, 0x5a, 0x8d, 0x56, 0x90, 0x02, 0x00, 0x00, +} + +func (m *Farm) 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 *Farm) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Farm) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Rewards) > 0 { + for iNdEx := len(m.Rewards) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Rewards[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintFarm(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if len(m.Token) > 0 { + i -= len(m.Token) + copy(dAtA[i:], m.Token) + i = encodeVarintFarm(dAtA, i, uint64(len(m.Token))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *FarmReward) 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 *FarmReward) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *FarmReward) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + n1, err1 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.StartTime, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.StartTime):]) + if err1 != nil { + return 0, err1 + } + i -= n1 + i = encodeVarintFarm(dAtA, i, uint64(n1)) + i-- + dAtA[i] = 0x22 + n2, err2 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.EndTime, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.EndTime):]) + if err2 != nil { + return 0, err2 + } + i -= n2 + i = encodeVarintFarm(dAtA, i, uint64(n2)) + i-- + dAtA[i] = 0x1a + if len(m.Amount) > 0 { + for iNdEx := len(m.Amount) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Amount[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintFarm(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if len(m.Sender) > 0 { + i -= len(m.Sender) + copy(dAtA[i:], m.Sender) + i = encodeVarintFarm(dAtA, i, uint64(len(m.Sender))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintFarm(dAtA []byte, offset int, v uint64) int { + offset -= sovFarm(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Farm) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Token) + if l > 0 { + n += 1 + l + sovFarm(uint64(l)) + } + if len(m.Rewards) > 0 { + for _, e := range m.Rewards { + l = e.Size() + n += 1 + l + sovFarm(uint64(l)) + } + } + return n +} + +func (m *FarmReward) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovFarm(uint64(l)) + } + if len(m.Amount) > 0 { + for _, e := range m.Amount { + l = e.Size() + n += 1 + l + sovFarm(uint64(l)) + } + } + l = github_com_cosmos_gogoproto_types.SizeOfStdTime(m.EndTime) + n += 1 + l + sovFarm(uint64(l)) + l = github_com_cosmos_gogoproto_types.SizeOfStdTime(m.StartTime) + n += 1 + l + sovFarm(uint64(l)) + return n +} + +func sovFarm(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozFarm(x uint64) (n int) { + return sovFarm(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Farm) 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 ErrIntOverflowFarm + } + 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: Farm: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Farm: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Token", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFarm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthFarm + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthFarm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Token = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Rewards", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFarm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthFarm + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthFarm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Rewards = append(m.Rewards, &FarmReward{}) + if err := m.Rewards[len(m.Rewards)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipFarm(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthFarm + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *FarmReward) 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 ErrIntOverflowFarm + } + 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: FarmReward: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: FarmReward: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFarm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthFarm + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthFarm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Sender = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFarm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthFarm + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthFarm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Amount = append(m.Amount, types.Coin{}) + if err := m.Amount[len(m.Amount)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EndTime", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFarm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthFarm + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthFarm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_cosmos_gogoproto_types.StdTimeUnmarshal(&m.EndTime, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StartTime", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFarm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthFarm + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthFarm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_cosmos_gogoproto_types.StdTimeUnmarshal(&m.StartTime, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipFarm(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthFarm + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipFarm(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, ErrIntOverflowFarm + } + 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, ErrIntOverflowFarm + } + 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, ErrIntOverflowFarm + } + 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, ErrInvalidLengthFarm + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupFarm + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthFarm + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthFarm = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowFarm = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupFarm = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/farming/types/genesis.go b/x/farming/types/genesis.go new file mode 100644 index 00000000..13d00b06 --- /dev/null +++ b/x/farming/types/genesis.go @@ -0,0 +1,93 @@ +package types + +import ( + "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +// DefaultIndex is the default global index +const DefaultIndex uint64 = 1 + +// DefaultGenesis returns the default genesis state +func DefaultGenesis() *GenesisState { + return &GenesisState{ + FarmList: []Farm{}, + StakingInfoList: []StakingInfo{}, + DistributionInfo: nil, + RewardList: []Reward{}, + // 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 { + // Check for duplicated index in farm + farmIndexMap := make(map[string]struct{}) + + for _, elem := range gs.FarmList { + index := string(FarmKey(elem.Token)) + if _, ok := farmIndexMap[index]; ok { + return fmt.Errorf("duplicated index for farm") + } + farmIndexMap[index] = struct{}{} + + for _, reward := range elem.Rewards { + _, err := sdk.AccAddressFromBech32(reward.Sender) + if err != nil { + return WrapErrorf(sdkerrors.ErrInvalidAddress, "invalid reward sender address (%s)", err) + } + + if !reward.Amount.IsValid() || !reward.Amount.IsAllPositive() { + return WrapError(sdkerrors.ErrInvalidCoins, reward.Amount.String()) + } + + if reward.EndTime.IsZero() { + return WrapErrorf(ErrInvalidTime, "reward end time cannot be zero") + } + + if !reward.StartTime.IsZero() && !reward.StartTime.Before(reward.EndTime) { + return WrapErrorf(ErrInvalidTime, "reward start time must be smaller than end time") + } + } + } + // Check for duplicated index in stakingInfo + stakingInfoIndexMap := make(map[string]struct{}) + + for _, elem := range gs.StakingInfoList { + index := string(StakingInfoKey(elem.Token, elem.Staker)) + if _, ok := stakingInfoIndexMap[index]; ok { + return fmt.Errorf("duplicated index for stakingInfo") + } + stakingInfoIndexMap[index] = struct{}{} + + if sdk.ValidateDenom(elem.Token) != nil { + return WrapErrorf(ErrInvalidToken, "invalid token: %s", elem.Token) + } + + _, err := sdk.AccAddressFromBech32(elem.Staker) + if err != nil { + return WrapErrorf(sdkerrors.ErrInvalidAddress, "invalid staker address (%s)", err) + } + + if !elem.Amount.IsPositive() { + return ErrInvalidStakingAmount + } + } + // Check for duplicated index in reward + rewardIndexMap := make(map[string]struct{}) + + for _, elem := range gs.RewardList { + index := string(RewardKey(elem.Farmer)) + if _, ok := rewardIndexMap[index]; ok { + return fmt.Errorf("duplicated index for reward") + } + rewardIndexMap[index] = struct{}{} + } + // this line is used by starport scaffolding # genesis/types/validate + + return gs.Params.Validate() +} diff --git a/x/farming/types/genesis.pb.go b/x/farming/types/genesis.pb.go new file mode 100644 index 00000000..9637e34f --- /dev/null +++ b/x/farming/types/genesis.pb.go @@ -0,0 +1,576 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: titan/farming/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 farming module's genesis state. +type GenesisState struct { + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` + FarmList []Farm `protobuf:"bytes,2,rep,name=farm_list,json=farmList,proto3" json:"farm_list"` + StakingInfoList []StakingInfo `protobuf:"bytes,3,rep,name=staking_info_list,json=stakingInfoList,proto3" json:"staking_info_list"` + DistributionInfo *DistributionInfo `protobuf:"bytes,4,opt,name=distribution_info,json=distributionInfo,proto3" json:"distribution_info,omitempty"` + RewardList []Reward `protobuf:"bytes,5,rep,name=reward_list,json=rewardList,proto3" json:"reward_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_3376d6f5f93efbe0, []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) GetFarmList() []Farm { + if m != nil { + return m.FarmList + } + return nil +} + +func (m *GenesisState) GetStakingInfoList() []StakingInfo { + if m != nil { + return m.StakingInfoList + } + return nil +} + +func (m *GenesisState) GetDistributionInfo() *DistributionInfo { + if m != nil { + return m.DistributionInfo + } + return nil +} + +func (m *GenesisState) GetRewardList() []Reward { + if m != nil { + return m.RewardList + } + return nil +} + +func init() { + proto.RegisterType((*GenesisState)(nil), "titan.farming.GenesisState") +} + +func init() { proto.RegisterFile("titan/farming/genesis.proto", fileDescriptor_3376d6f5f93efbe0) } + +var fileDescriptor_3376d6f5f93efbe0 = []byte{ + // 345 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x91, 0xcf, 0x4a, 0xf3, 0x40, + 0x14, 0xc5, 0x93, 0xb6, 0x5f, 0xf9, 0x9c, 0x2a, 0x6a, 0x54, 0x08, 0x11, 0xd2, 0x22, 0x08, 0x75, + 0x93, 0x40, 0x0b, 0xae, 0x5c, 0x55, 0x51, 0x84, 0x2e, 0xa4, 0xdd, 0xb9, 0x29, 0x53, 0x9b, 0x8e, + 0x43, 0xcd, 0x4c, 0x99, 0xb9, 0xc5, 0xfa, 0x16, 0x3e, 0x56, 0x97, 0xdd, 0x08, 0xae, 0x44, 0xda, + 0x17, 0x91, 0xf9, 0x53, 0x4d, 0xa2, 0xab, 0x0c, 0xf3, 0x3b, 0xe7, 0xe4, 0xdc, 0x3b, 0xe8, 0x18, + 0x28, 0x60, 0x16, 0x8f, 0xb1, 0x48, 0x29, 0x23, 0x31, 0x49, 0x58, 0x22, 0xa9, 0x8c, 0xa6, 0x82, + 0x03, 0xf7, 0x76, 0x34, 0x8c, 0x2c, 0x0c, 0x0e, 0x09, 0x27, 0x5c, 0x93, 0x58, 0x9d, 0x8c, 0x28, + 0x38, 0xcd, 0x27, 0x8c, 0xa8, 0x04, 0x41, 0x87, 0x33, 0xa0, 0x9c, 0x0d, 0x28, 0x1b, 0x6f, 0x64, + 0x7e, 0x5e, 0xa6, 0xbe, 0x96, 0x04, 0x79, 0x32, 0xc5, 0x02, 0xa7, 0xf2, 0x6f, 0x26, 0x92, 0x67, + 0x2c, 0x46, 0x96, 0x35, 0xf2, 0x4c, 0x02, 0x9e, 0x50, 0x46, 0x32, 0xff, 0x3c, 0x79, 0x2b, 0xa1, + 0xed, 0x1b, 0x33, 0x51, 0x1f, 0x30, 0x24, 0x5e, 0x1b, 0x55, 0x4d, 0xbc, 0xef, 0x36, 0xdc, 0x66, + 0xad, 0x75, 0x14, 0xe5, 0x26, 0x8c, 0xee, 0x34, 0xec, 0x54, 0x16, 0x1f, 0x75, 0xa7, 0x67, 0xa5, + 0xde, 0x39, 0xda, 0x52, 0x7c, 0xf0, 0x44, 0x25, 0xf8, 0xa5, 0x46, 0xb9, 0x59, 0x6b, 0x1d, 0x14, + 0x7c, 0xd7, 0x58, 0xa4, 0xd6, 0xf5, 0x5f, 0xdd, 0x75, 0xa9, 0x04, 0xaf, 0x8b, 0xf6, 0xb3, 0x9d, + 0x8c, 0xbf, 0xac, 0xfd, 0x41, 0xc1, 0xdf, 0x37, 0xba, 0x5b, 0x36, 0xe6, 0x36, 0x66, 0x57, 0xfe, + 0x5c, 0x6d, 0xd2, 0x7e, 0xad, 0xd6, 0xaf, 0xe8, 0x29, 0xea, 0x85, 0xb4, 0xab, 0x8c, 0x4e, 0xf9, + 0x7b, 0x7b, 0xa3, 0xc2, 0x8d, 0x77, 0x81, 0x6a, 0x66, 0x97, 0xa6, 0xd5, 0x3f, 0xdd, 0xaa, 0xb8, + 0x8d, 0x9e, 0x56, 0xd8, 0x42, 0xc8, 0xe8, 0x55, 0x97, 0xce, 0xe5, 0x62, 0x15, 0xba, 0xcb, 0x55, + 0xe8, 0x7e, 0xae, 0x42, 0xf7, 0x75, 0x1d, 0x3a, 0xcb, 0x75, 0xe8, 0xbc, 0xaf, 0x43, 0xe7, 0xfe, + 0x8c, 0x50, 0x78, 0x9c, 0x0d, 0xa3, 0x07, 0x9e, 0xc6, 0x3a, 0x0c, 0x26, 0x73, 0x73, 0x88, 0xe7, + 0xdf, 0x2f, 0x05, 0x2f, 0xd3, 0x44, 0x0e, 0xab, 0xfa, 0x8d, 0xda, 0x5f, 0x01, 0x00, 0x00, 0xff, + 0xff, 0xcb, 0x71, 0xe6, 0x8c, 0x82, 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.RewardList) > 0 { + for iNdEx := len(m.RewardList) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.RewardList[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + } + } + if m.DistributionInfo != nil { + { + size, err := m.DistributionInfo.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + if len(m.StakingInfoList) > 0 { + for iNdEx := len(m.StakingInfoList) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.StakingInfoList[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.FarmList) > 0 { + for iNdEx := len(m.FarmList) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.FarmList[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.FarmList) > 0 { + for _, e := range m.FarmList { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.StakingInfoList) > 0 { + for _, e := range m.StakingInfoList { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if m.DistributionInfo != nil { + l = m.DistributionInfo.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + if len(m.RewardList) > 0 { + for _, e := range m.RewardList { + 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 FarmList", 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.FarmList = append(m.FarmList, Farm{}) + if err := m.FarmList[len(m.FarmList)-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 StakingInfoList", 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.StakingInfoList = append(m.StakingInfoList, StakingInfo{}) + if err := m.StakingInfoList[len(m.StakingInfoList)-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 DistributionInfo", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.DistributionInfo == nil { + m.DistributionInfo = &DistributionInfo{} + } + if err := m.DistributionInfo.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RewardList", 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.RewardList = append(m.RewardList, Reward{}) + if err := m.RewardList[len(m.RewardList)-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/farming/types/genesis_test.go b/x/farming/types/genesis_test.go new file mode 100644 index 00000000..120042ab --- /dev/null +++ b/x/farming/types/genesis_test.go @@ -0,0 +1,118 @@ +package types_test + +import ( + "testing" + "time" + + "cosmossdk.io/math" + "github.com/stretchr/testify/require" + "github.com/titantkx/titan/testutil/sample" + "github.com/titantkx/titan/x/farming/types" +) + +func TestGenesisState_Validate(t *testing.T) { + tests := []struct { + desc string + genState *types.GenesisState + valid bool + }{ + { + desc: "default is valid", + genState: types.DefaultGenesis(), + valid: true, + }, + { + desc: "valid genesis state", + genState: &types.GenesisState{ + FarmList: []types.Farm{ + { + Token: "tkx", + }, + { + Token: "btc", + }, + }, + StakingInfoList: []types.StakingInfo{ + { + Token: "tkx", + Staker: sample.AccAddress().String(), + Amount: math.NewInt(100), + }, + { + Token: "btc", + Staker: sample.AccAddress().String(), + Amount: math.NewInt(1000), + }, + }, + DistributionInfo: &types.DistributionInfo{ + LastDistributionTime: time.Now(), + }, + RewardList: []types.Reward{ + { + Farmer: "0", + }, + { + Farmer: "1", + }, + }, + // this line is used by starport scaffolding # types/genesis/validField + }, + valid: true, + }, + { + desc: "duplicated farm", + genState: &types.GenesisState{ + FarmList: []types.Farm{ + { + Token: "tkx", + }, + { + Token: "tkx", + }, + }, + }, + valid: false, + }, + { + desc: "duplicated stakingInfo", + genState: &types.GenesisState{ + StakingInfoList: []types.StakingInfo{ + { + Token: "tkx", + Staker: "titan184hrxl49ktwu2aqsvjfafy47cvh850e9qanagj", + }, + { + Token: "tkx", + Staker: "titan184hrxl49ktwu2aqsvjfafy47cvh850e9qanagj", + }, + }, + }, + valid: false, + }, + { + desc: "duplicated reward", + genState: &types.GenesisState{ + RewardList: []types.Reward{ + { + Farmer: "0", + }, + { + Farmer: "0", + }, + }, + }, + valid: false, + }, + // this line is used by starport scaffolding # types/genesis/testcase + } + for _, tc := range tests { + t.Run(tc.desc, func(t *testing.T) { + err := tc.genState.Validate() + if tc.valid { + require.NoError(t, err) + } else { + require.Error(t, err) + } + }) + } +} diff --git a/x/farming/types/key_distribution_info.go b/x/farming/types/key_distribution_info.go new file mode 100644 index 00000000..33c4049c --- /dev/null +++ b/x/farming/types/key_distribution_info.go @@ -0,0 +1,6 @@ +package types + +const ( + // DistributionInfoKey is the key to retrieve DistributionInfo + DistributionInfoKey = "DistributionInfo/value/" +) diff --git a/x/farming/types/key_farm.go b/x/farming/types/key_farm.go new file mode 100644 index 00000000..227f2b22 --- /dev/null +++ b/x/farming/types/key_farm.go @@ -0,0 +1,21 @@ +package types + +import "encoding/binary" + +var _ binary.ByteOrder + +const ( + // FarmKeyPrefix is the prefix to retrieve all Farm + FarmKeyPrefix = "Farm/value/" +) + +// FarmKey returns the store key to retrieve a Farm from the index fields +func FarmKey(token string) []byte { + var key []byte + + tokenBytes := []byte(token) + key = append(key, tokenBytes...) + key = append(key, []byte("/")...) + + return key +} diff --git a/x/farming/types/key_reward.go b/x/farming/types/key_reward.go new file mode 100644 index 00000000..15a189f3 --- /dev/null +++ b/x/farming/types/key_reward.go @@ -0,0 +1,21 @@ +package types + +import "encoding/binary" + +var _ binary.ByteOrder + +const ( + // RewardKeyPrefix is the prefix to retrieve all Reward + RewardKeyPrefix = "Reward/value/" +) + +// RewardKey returns the store key to retrieve a Reward from the index fields +func RewardKey(farmer string) []byte { + var key []byte + + farmerBytes := []byte(farmer) + key = append(key, farmerBytes...) + key = append(key, []byte("/")...) + + return key +} diff --git a/x/farming/types/key_staking_info.go b/x/farming/types/key_staking_info.go new file mode 100644 index 00000000..2572dd3a --- /dev/null +++ b/x/farming/types/key_staking_info.go @@ -0,0 +1,21 @@ +package types + +import ( + "encoding/binary" + "fmt" +) + +var _ binary.ByteOrder + +const ( + // StakingInfoKeyPrefix is the prefix to retrieve all StakingInfo + StakingInfoKeyPrefix = "StakingInfo/value/" +) + +// StakingInfoKey returns the store key to retrieve a StakingInfo from the index fields +func StakingInfoKey(token string, staker string) []byte { + if staker != "" { + return []byte(fmt.Sprintf("%s/%s/", token, staker)) + } + return []byte(token + "/") +} diff --git a/x/farming/types/keys.go b/x/farming/types/keys.go new file mode 100644 index 00000000..de283ebf --- /dev/null +++ b/x/farming/types/keys.go @@ -0,0 +1,19 @@ +package types + +const ( + // ModuleName defines the module name + ModuleName = "farming" + + // 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_farming" +) + +func KeyPrefix(p string) []byte { + return []byte(p) +} diff --git a/x/farming/types/message_add_reward.go b/x/farming/types/message_add_reward.go new file mode 100644 index 00000000..f6f52c75 --- /dev/null +++ b/x/farming/types/message_add_reward.go @@ -0,0 +1,68 @@ +package types + +import ( + "time" + + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +const TypeMsgAddReward = "add_reward" + +var _ sdk.Msg = &MsgAddReward{} + +func NewMsgAddReward(sender string, token string, amount sdk.Coins, endTime time.Time, startTime time.Time) *MsgAddReward { + return &MsgAddReward{ + Sender: sender, + Token: token, + Amount: amount, + EndTime: endTime, + StartTime: startTime, + } +} + +func (msg *MsgAddReward) Route() string { + return RouterKey +} + +func (msg *MsgAddReward) Type() string { + return TypeMsgAddReward +} + +func (msg *MsgAddReward) GetSigners() []sdk.AccAddress { + sender, err := sdk.AccAddressFromBech32(msg.Sender) + if err != nil { + panic(err) + } + return []sdk.AccAddress{sender} +} + +func (msg *MsgAddReward) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +func (msg *MsgAddReward) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.Sender) + if err != nil { + return WrapErrorf(sdkerrors.ErrInvalidAddress, "invalid sender address (%s)", err) + } + + if sdk.ValidateDenom(msg.Token) != nil { + return WrapErrorf(ErrInvalidToken, "invalid token: %s", msg.Token) + } + + if !msg.Amount.IsValid() || !msg.Amount.IsAllPositive() { + return WrapError(sdkerrors.ErrInvalidCoins, msg.Amount.String()) + } + + if msg.EndTime.IsZero() { + return WrapError(ErrInvalidTime, "end time cannot be zero") + } + + if !msg.StartTime.IsZero() && !msg.StartTime.Before(msg.EndTime) { + return WrapError(ErrInvalidTime, "start time must be smaller than end time") + } + + return nil +} diff --git a/x/farming/types/message_add_reward_test.go b/x/farming/types/message_add_reward_test.go new file mode 100644 index 00000000..adf9bddf --- /dev/null +++ b/x/farming/types/message_add_reward_test.go @@ -0,0 +1,103 @@ +package types + +import ( + "testing" + "time" + + "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/stretchr/testify/require" + "github.com/titantkx/titan/testutil/sample" +) + +func TestMsgAddReward_ValidateBasic(t *testing.T) { + tests := []struct { + name string + msg MsgAddReward + err error + }{ + { + name: "valid", + msg: MsgAddReward{ + Sender: sample.AccAddress().String(), + Token: "bitcoin", + Amount: sdk.NewCoins(sdk.NewCoin("tkx", math.NewInt(500000000))), + EndTime: time.Now().Add(1 * time.Hour), + StartTime: time.Now(), + }, + }, + { + name: "valid zero start time", + msg: MsgAddReward{ + Sender: sample.AccAddress().String(), + Token: "bitcoin", + Amount: sdk.NewCoins(sdk.NewCoin("tkx", math.NewInt(500000000))), + EndTime: time.Now().Add(1 * time.Hour), + }, + }, + { + name: "invalid token", + msg: MsgAddReward{ + Sender: sample.AccAddress().String(), + Token: "123", + Amount: sdk.NewCoins(sdk.NewCoin("tkx", math.NewInt(500000000))), + EndTime: time.Now().Add(1 * time.Hour), + StartTime: time.Now(), + }, + err: ErrInvalidToken, + }, + { + name: "invalid address", + msg: MsgAddReward{ + Sender: "invalid_address", + Token: "bitcoin", + Amount: sdk.NewCoins(sdk.NewCoin("tkx", math.NewInt(500000000))), + EndTime: time.Now().Add(1 * time.Hour), + StartTime: time.Now(), + }, + err: sdkerrors.ErrInvalidAddress, + }, + { + name: "zero reward", + msg: MsgAddReward{ + Sender: sample.AccAddress().String(), + Token: "bitcoin", + EndTime: time.Now().Add(1 * time.Hour), + StartTime: time.Now(), + }, + err: sdkerrors.ErrInvalidCoins, + }, + { + name: "zero end time", + msg: MsgAddReward{ + Sender: sample.AccAddress().String(), + Token: "bitcoin", + Amount: sdk.NewCoins(sdk.NewCoin("tkx", math.NewInt(500000000))), + StartTime: time.Now(), + }, + err: ErrInvalidTime, + }, + { + name: "start after end", + msg: MsgAddReward{ + Sender: sample.AccAddress().String(), + Token: "bitcoin", + Amount: sdk.NewCoins(sdk.NewCoin("tkx", math.NewInt(500000000))), + EndTime: time.Now().Add(1 * time.Hour), + StartTime: time.Now().Add(2 * time.Hour), + }, + err: ErrInvalidTime, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.msg.ValidateBasic() + if tt.err != nil { + require.ErrorIs(t, err, tt.err) + return + } + require.NoError(t, err) + }) + } +} diff --git a/x/farming/types/message_harvest.go b/x/farming/types/message_harvest.go new file mode 100644 index 00000000..e86f5aa4 --- /dev/null +++ b/x/farming/types/message_harvest.go @@ -0,0 +1,46 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +const TypeMsgHarvest = "harvest" + +var _ sdk.Msg = &MsgHarvest{} + +func NewMsgHarvest(sender string) *MsgHarvest { + return &MsgHarvest{ + Sender: sender, + } +} + +func (msg *MsgHarvest) Route() string { + return RouterKey +} + +func (msg *MsgHarvest) Type() string { + return TypeMsgHarvest +} + +func (msg *MsgHarvest) GetSigners() []sdk.AccAddress { + sender, err := sdk.AccAddressFromBech32(msg.Sender) + if err != nil { + panic(err) + } + return []sdk.AccAddress{sender} +} + +func (msg *MsgHarvest) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +func (msg *MsgHarvest) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.Sender) + if err != nil { + return WrapErrorf(sdkerrors.ErrInvalidAddress, "invalid sender address (%s)", err) + } + + return nil +} diff --git a/x/farming/types/message_harvest_test.go b/x/farming/types/message_harvest_test.go new file mode 100644 index 00000000..657f2317 --- /dev/null +++ b/x/farming/types/message_harvest_test.go @@ -0,0 +1,41 @@ +package types + +import ( + "testing" + + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/stretchr/testify/require" + "github.com/titantkx/titan/testutil/sample" +) + +func TestMsgHarvest_ValidateBasic(t *testing.T) { + tests := []struct { + name string + msg MsgHarvest + err error + }{ + { + name: "valid address", + msg: MsgHarvest{ + Sender: sample.AccAddress().String(), + }, + }, + { + name: "invalid address", + msg: MsgHarvest{ + Sender: "invalid_address", + }, + err: sdkerrors.ErrInvalidAddress, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.msg.ValidateBasic() + if tt.err != nil { + require.ErrorIs(t, err, tt.err) + return + } + require.NoError(t, err) + }) + } +} diff --git a/x/farming/types/message_stake.go b/x/farming/types/message_stake.go new file mode 100644 index 00000000..674e5b44 --- /dev/null +++ b/x/farming/types/message_stake.go @@ -0,0 +1,52 @@ +//nolint:dupl +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +const TypeMsgStake = "stake" + +var _ sdk.Msg = &MsgStake{} + +func NewMsgStake(sender string, amount sdk.Coins) *MsgStake { + return &MsgStake{ + Sender: sender, + Amount: amount, + } +} + +func (msg *MsgStake) Route() string { + return RouterKey +} + +func (msg *MsgStake) Type() string { + return TypeMsgStake +} + +func (msg *MsgStake) GetSigners() []sdk.AccAddress { + sender, err := sdk.AccAddressFromBech32(msg.Sender) + if err != nil { + panic(err) + } + return []sdk.AccAddress{sender} +} + +func (msg *MsgStake) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +func (msg *MsgStake) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.Sender) + if err != nil { + return WrapErrorf(sdkerrors.ErrInvalidAddress, "invalid sender address (%s)", err) + } + + if !msg.Amount.IsValid() || !msg.Amount.IsAllPositive() { + return WrapError(sdkerrors.ErrInvalidCoins, msg.Amount.String()) + } + + return nil +} diff --git a/x/farming/types/message_stake_test.go b/x/farming/types/message_stake_test.go new file mode 100644 index 00000000..1a7aeaab --- /dev/null +++ b/x/farming/types/message_stake_test.go @@ -0,0 +1,52 @@ +package types + +import ( + "testing" + + "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/stretchr/testify/require" + "github.com/titantkx/titan/testutil/sample" +) + +func TestMsgStake_ValidateBasic(t *testing.T) { + tests := []struct { + name string + msg MsgStake + err error + }{ + { + name: "valid", + msg: MsgStake{ + Sender: sample.AccAddress().String(), + Amount: sdk.NewCoins(sdk.NewCoin("tkx", math.NewInt(500000000))), + }, + }, + { + name: "invalid address", + msg: MsgStake{ + Sender: "invalid_address", + Amount: sdk.NewCoins(sdk.NewCoin("tkx", math.NewInt(500000000))), + }, + err: sdkerrors.ErrInvalidAddress, + }, + { + name: "zero amount", + msg: MsgStake{ + Sender: sample.AccAddress().String(), + }, + err: sdkerrors.ErrInvalidCoins, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.msg.ValidateBasic() + if tt.err != nil { + require.ErrorIs(t, err, tt.err) + return + } + require.NoError(t, err) + }) + } +} diff --git a/x/farming/types/message_unstake.go b/x/farming/types/message_unstake.go new file mode 100644 index 00000000..5f08c2c7 --- /dev/null +++ b/x/farming/types/message_unstake.go @@ -0,0 +1,52 @@ +//nolint:dupl +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +const TypeMsgUnstake = "unstake" + +var _ sdk.Msg = &MsgUnstake{} + +func NewMsgUnstake(sender string, amount sdk.Coins) *MsgUnstake { + return &MsgUnstake{ + Sender: sender, + Amount: amount, + } +} + +func (msg *MsgUnstake) Route() string { + return RouterKey +} + +func (msg *MsgUnstake) Type() string { + return TypeMsgUnstake +} + +func (msg *MsgUnstake) GetSigners() []sdk.AccAddress { + sender, err := sdk.AccAddressFromBech32(msg.Sender) + if err != nil { + panic(err) + } + return []sdk.AccAddress{sender} +} + +func (msg *MsgUnstake) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +func (msg *MsgUnstake) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.Sender) + if err != nil { + return WrapErrorf(sdkerrors.ErrInvalidAddress, "invalid sender address (%s)", err) + } + + if !msg.Amount.IsValid() || !msg.Amount.IsAllPositive() { + return WrapError(sdkerrors.ErrInvalidCoins, msg.Amount.String()) + } + + return nil +} diff --git a/x/farming/types/message_unstake_test.go b/x/farming/types/message_unstake_test.go new file mode 100644 index 00000000..af624081 --- /dev/null +++ b/x/farming/types/message_unstake_test.go @@ -0,0 +1,51 @@ +package types + +import ( + "testing" + + "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/stretchr/testify/require" + "github.com/titantkx/titan/testutil/sample" +) + +func TestMsgUnstake_ValidateBasic(t *testing.T) { + tests := []struct { + name string + msg MsgUnstake + err error + }{ + { + name: "valid", + msg: MsgUnstake{ + Sender: sample.AccAddress().String(), + Amount: sdk.NewCoins(sdk.NewCoin("tkx", math.NewInt(500000000))), + }, + }, + { + name: "invalid address", + msg: MsgUnstake{ + Sender: "invalid_address", + }, + err: sdkerrors.ErrInvalidAddress, + }, + { + name: "zero amount", + msg: MsgUnstake{ + Sender: sample.AccAddress().String(), + }, + err: sdkerrors.ErrInvalidCoins, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.msg.ValidateBasic() + if tt.err != nil { + require.ErrorIs(t, err, tt.err) + return + } + require.NoError(t, err) + }) + } +} diff --git a/x/farming/types/params.go b/x/farming/types/params.go new file mode 100644 index 00000000..357196ad --- /dev/null +++ b/x/farming/types/params.go @@ -0,0 +1,39 @@ +package types + +import ( + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" + "gopkg.in/yaml.v2" +) + +var _ paramtypes.ParamSet = (*Params)(nil) + +// ParamKeyTable the param key table for launch module +func ParamKeyTable() paramtypes.KeyTable { + return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) +} + +// NewParams creates a new Params instance +func NewParams() Params { + return Params{} +} + +// DefaultParams returns a default set of parameters +func DefaultParams() Params { + return NewParams() +} + +// ParamSetPairs get the params.ParamSet +func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { + return paramtypes.ParamSetPairs{} +} + +// Validate validates the set of params +func (p Params) Validate() error { + return nil +} + +// String implements the Stringer interface. +func (p Params) String() string { + out, _ := yaml.Marshal(p) + return string(out) +} diff --git a/x/farming/types/params.pb.go b/x/farming/types/params.pb.go new file mode 100644 index 00000000..0e481c79 --- /dev/null +++ b/x/farming/types/params.pb.go @@ -0,0 +1,264 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: titan/farming/params.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 + +// Params defines the parameters for the module. +type Params struct { +} + +func (m *Params) Reset() { *m = Params{} } +func (*Params) ProtoMessage() {} +func (*Params) Descriptor() ([]byte, []int) { + return fileDescriptor_0557e34a60e0b40e, []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 init() { + proto.RegisterType((*Params)(nil), "titan.farming.Params") +} + +func init() { proto.RegisterFile("titan/farming/params.proto", fileDescriptor_0557e34a60e0b40e) } + +var fileDescriptor_0557e34a60e0b40e = []byte{ + // 146 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2a, 0xc9, 0x2c, 0x49, + 0xcc, 0xd3, 0x4f, 0x4b, 0x2c, 0xca, 0xcd, 0xcc, 0x4b, 0xd7, 0x2f, 0x48, 0x2c, 0x4a, 0xcc, 0x2d, + 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x05, 0xcb, 0xe9, 0x41, 0xe5, 0xa4, 0x44, 0xd2, + 0xf3, 0xd3, 0xf3, 0xc1, 0x32, 0xfa, 0x20, 0x16, 0x44, 0x91, 0x12, 0x1f, 0x17, 0x5b, 0x00, 0x58, + 0x93, 0x15, 0xcb, 0x8c, 0x05, 0xf2, 0x0c, 0x4e, 0xce, 0x27, 0x1e, 0xc9, 0x31, 0x5e, 0x78, 0x24, + 0xc7, 0xf8, 0xe0, 0x91, 0x1c, 0xe3, 0x84, 0xc7, 0x72, 0x0c, 0x17, 0x1e, 0xcb, 0x31, 0xdc, 0x78, + 0x2c, 0xc7, 0x10, 0xa5, 0x99, 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0xab, 0x0f, + 0x36, 0xb9, 0x24, 0xbb, 0x02, 0xc2, 0xd0, 0xaf, 0x80, 0x3b, 0xa0, 0xa4, 0xb2, 0x20, 0xb5, 0x38, + 0x89, 0x0d, 0x6c, 0xb6, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x8c, 0x29, 0xc9, 0xe1, 0x9e, 0x00, + 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 + 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 + 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 { + 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/farming/types/query.pb.go b/x/farming/types/query.pb.go new file mode 100644 index 00000000..0cffd5df --- /dev/null +++ b/x/farming/types/query.pb.go @@ -0,0 +1,3533 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: titan/farming/query.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + query "github.com/cosmos/cosmos-sdk/types/query" + _ "github.com/cosmos/gogoproto/gogoproto" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + _ "google.golang.org/genproto/googleapis/api/annotations" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// QueryParamsRequest is request type for the Query/Params RPC method. +type QueryParamsRequest struct { +} + +func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} } +func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryParamsRequest) ProtoMessage() {} +func (*QueryParamsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_f60be7619b820df0, []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_f60be7619b820df0, []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{} +} + +// QueryFarmRequest is request type for the Query/Farm RPC method. +type QueryFarmRequest struct { + Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` +} + +func (m *QueryFarmRequest) Reset() { *m = QueryFarmRequest{} } +func (m *QueryFarmRequest) String() string { return proto.CompactTextString(m) } +func (*QueryFarmRequest) ProtoMessage() {} +func (*QueryFarmRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_f60be7619b820df0, []int{2} +} +func (m *QueryFarmRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryFarmRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryFarmRequest.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 *QueryFarmRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryFarmRequest.Merge(m, src) +} +func (m *QueryFarmRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryFarmRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryFarmRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryFarmRequest proto.InternalMessageInfo + +func (m *QueryFarmRequest) GetToken() string { + if m != nil { + return m.Token + } + return "" +} + +// QueryFarmResponse is response type for the Query/Farm RPC method. +type QueryFarmResponse struct { + Farm Farm `protobuf:"bytes,1,opt,name=farm,proto3" json:"farm"` +} + +func (m *QueryFarmResponse) Reset() { *m = QueryFarmResponse{} } +func (m *QueryFarmResponse) String() string { return proto.CompactTextString(m) } +func (*QueryFarmResponse) ProtoMessage() {} +func (*QueryFarmResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_f60be7619b820df0, []int{3} +} +func (m *QueryFarmResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryFarmResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryFarmResponse.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 *QueryFarmResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryFarmResponse.Merge(m, src) +} +func (m *QueryFarmResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryFarmResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryFarmResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryFarmResponse proto.InternalMessageInfo + +func (m *QueryFarmResponse) GetFarm() Farm { + if m != nil { + return m.Farm + } + return Farm{} +} + +// QueryFarmAllRequest is request type for the Query/AllFarm RPC method. +type QueryFarmAllRequest struct { + Pagination *query.PageRequest `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryFarmAllRequest) Reset() { *m = QueryFarmAllRequest{} } +func (m *QueryFarmAllRequest) String() string { return proto.CompactTextString(m) } +func (*QueryFarmAllRequest) ProtoMessage() {} +func (*QueryFarmAllRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_f60be7619b820df0, []int{4} +} +func (m *QueryFarmAllRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryFarmAllRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryFarmAllRequest.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 *QueryFarmAllRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryFarmAllRequest.Merge(m, src) +} +func (m *QueryFarmAllRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryFarmAllRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryFarmAllRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryFarmAllRequest proto.InternalMessageInfo + +func (m *QueryFarmAllRequest) GetPagination() *query.PageRequest { + if m != nil { + return m.Pagination + } + return nil +} + +// QueryFarmAllResponse is response type for the Query/AllFarm RPC method. +type QueryFarmAllResponse struct { + Farm []Farm `protobuf:"bytes,1,rep,name=farm,proto3" json:"farm"` + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryFarmAllResponse) Reset() { *m = QueryFarmAllResponse{} } +func (m *QueryFarmAllResponse) String() string { return proto.CompactTextString(m) } +func (*QueryFarmAllResponse) ProtoMessage() {} +func (*QueryFarmAllResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_f60be7619b820df0, []int{5} +} +func (m *QueryFarmAllResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryFarmAllResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryFarmAllResponse.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 *QueryFarmAllResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryFarmAllResponse.Merge(m, src) +} +func (m *QueryFarmAllResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryFarmAllResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryFarmAllResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryFarmAllResponse proto.InternalMessageInfo + +func (m *QueryFarmAllResponse) GetFarm() []Farm { + if m != nil { + return m.Farm + } + return nil +} + +func (m *QueryFarmAllResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination + } + return nil +} + +// QueryStakingInfoRequest is request type for the Query/StakingInfo RPC method. +type QueryStakingInfoRequest struct { + Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` + Staker string `protobuf:"bytes,2,opt,name=staker,proto3" json:"staker,omitempty"` +} + +func (m *QueryStakingInfoRequest) Reset() { *m = QueryStakingInfoRequest{} } +func (m *QueryStakingInfoRequest) String() string { return proto.CompactTextString(m) } +func (*QueryStakingInfoRequest) ProtoMessage() {} +func (*QueryStakingInfoRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_f60be7619b820df0, []int{6} +} +func (m *QueryStakingInfoRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryStakingInfoRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryStakingInfoRequest.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 *QueryStakingInfoRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryStakingInfoRequest.Merge(m, src) +} +func (m *QueryStakingInfoRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryStakingInfoRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryStakingInfoRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryStakingInfoRequest proto.InternalMessageInfo + +func (m *QueryStakingInfoRequest) GetToken() string { + if m != nil { + return m.Token + } + return "" +} + +func (m *QueryStakingInfoRequest) GetStaker() string { + if m != nil { + return m.Staker + } + return "" +} + +// QueryStakingInfoResponse is response type for the Query/StakingInfo RPC method. +type QueryStakingInfoResponse struct { + StakingInfo StakingInfo `protobuf:"bytes,1,opt,name=staking_info,json=stakingInfo,proto3" json:"staking_info"` +} + +func (m *QueryStakingInfoResponse) Reset() { *m = QueryStakingInfoResponse{} } +func (m *QueryStakingInfoResponse) String() string { return proto.CompactTextString(m) } +func (*QueryStakingInfoResponse) ProtoMessage() {} +func (*QueryStakingInfoResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_f60be7619b820df0, []int{7} +} +func (m *QueryStakingInfoResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryStakingInfoResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryStakingInfoResponse.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 *QueryStakingInfoResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryStakingInfoResponse.Merge(m, src) +} +func (m *QueryStakingInfoResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryStakingInfoResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryStakingInfoResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryStakingInfoResponse proto.InternalMessageInfo + +func (m *QueryStakingInfoResponse) GetStakingInfo() StakingInfo { + if m != nil { + return m.StakingInfo + } + return StakingInfo{} +} + +// QueryStakingInfoAllRequest is request type for the Query/AllStakingInfo RPC method. +type QueryStakingInfoAllRequest struct { + Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` + Pagination *query.PageRequest `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryStakingInfoAllRequest) Reset() { *m = QueryStakingInfoAllRequest{} } +func (m *QueryStakingInfoAllRequest) String() string { return proto.CompactTextString(m) } +func (*QueryStakingInfoAllRequest) ProtoMessage() {} +func (*QueryStakingInfoAllRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_f60be7619b820df0, []int{8} +} +func (m *QueryStakingInfoAllRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryStakingInfoAllRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryStakingInfoAllRequest.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 *QueryStakingInfoAllRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryStakingInfoAllRequest.Merge(m, src) +} +func (m *QueryStakingInfoAllRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryStakingInfoAllRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryStakingInfoAllRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryStakingInfoAllRequest proto.InternalMessageInfo + +func (m *QueryStakingInfoAllRequest) GetToken() string { + if m != nil { + return m.Token + } + return "" +} + +func (m *QueryStakingInfoAllRequest) GetPagination() *query.PageRequest { + if m != nil { + return m.Pagination + } + return nil +} + +// QueryStakingInfoAllResponse is response type for the Query/AllStakingInfo RPC method. +type QueryStakingInfoAllResponse struct { + StakingInfo []StakingInfo `protobuf:"bytes,1,rep,name=staking_info,json=stakingInfo,proto3" json:"staking_info"` + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryStakingInfoAllResponse) Reset() { *m = QueryStakingInfoAllResponse{} } +func (m *QueryStakingInfoAllResponse) String() string { return proto.CompactTextString(m) } +func (*QueryStakingInfoAllResponse) ProtoMessage() {} +func (*QueryStakingInfoAllResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_f60be7619b820df0, []int{9} +} +func (m *QueryStakingInfoAllResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryStakingInfoAllResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryStakingInfoAllResponse.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 *QueryStakingInfoAllResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryStakingInfoAllResponse.Merge(m, src) +} +func (m *QueryStakingInfoAllResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryStakingInfoAllResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryStakingInfoAllResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryStakingInfoAllResponse proto.InternalMessageInfo + +func (m *QueryStakingInfoAllResponse) GetStakingInfo() []StakingInfo { + if m != nil { + return m.StakingInfo + } + return nil +} + +func (m *QueryStakingInfoAllResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination + } + return nil +} + +// QueryDistributionInfoRequest is request type for the Query/DistributionInfo RPC method. +type QueryDistributionInfoRequest struct { +} + +func (m *QueryDistributionInfoRequest) Reset() { *m = QueryDistributionInfoRequest{} } +func (m *QueryDistributionInfoRequest) String() string { return proto.CompactTextString(m) } +func (*QueryDistributionInfoRequest) ProtoMessage() {} +func (*QueryDistributionInfoRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_f60be7619b820df0, []int{10} +} +func (m *QueryDistributionInfoRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryDistributionInfoRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryDistributionInfoRequest.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 *QueryDistributionInfoRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryDistributionInfoRequest.Merge(m, src) +} +func (m *QueryDistributionInfoRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryDistributionInfoRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryDistributionInfoRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryDistributionInfoRequest proto.InternalMessageInfo + +// QueryDistributionInfoResponse is response type for the Query/DistributionInfo RPC method. +type QueryDistributionInfoResponse struct { + DistributionInfo DistributionInfo `protobuf:"bytes,1,opt,name=distribution_info,json=distributionInfo,proto3" json:"distribution_info"` +} + +func (m *QueryDistributionInfoResponse) Reset() { *m = QueryDistributionInfoResponse{} } +func (m *QueryDistributionInfoResponse) String() string { return proto.CompactTextString(m) } +func (*QueryDistributionInfoResponse) ProtoMessage() {} +func (*QueryDistributionInfoResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_f60be7619b820df0, []int{11} +} +func (m *QueryDistributionInfoResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryDistributionInfoResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryDistributionInfoResponse.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 *QueryDistributionInfoResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryDistributionInfoResponse.Merge(m, src) +} +func (m *QueryDistributionInfoResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryDistributionInfoResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryDistributionInfoResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryDistributionInfoResponse proto.InternalMessageInfo + +func (m *QueryDistributionInfoResponse) GetDistributionInfo() DistributionInfo { + if m != nil { + return m.DistributionInfo + } + return DistributionInfo{} +} + +// QueryRewardRequest is request type for the Query/Reward RPC method. +type QueryRewardRequest struct { + Farmer string `protobuf:"bytes,1,opt,name=farmer,proto3" json:"farmer,omitempty"` +} + +func (m *QueryRewardRequest) Reset() { *m = QueryRewardRequest{} } +func (m *QueryRewardRequest) String() string { return proto.CompactTextString(m) } +func (*QueryRewardRequest) ProtoMessage() {} +func (*QueryRewardRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_f60be7619b820df0, []int{12} +} +func (m *QueryRewardRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryRewardRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryRewardRequest.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 *QueryRewardRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryRewardRequest.Merge(m, src) +} +func (m *QueryRewardRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryRewardRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryRewardRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryRewardRequest proto.InternalMessageInfo + +func (m *QueryRewardRequest) GetFarmer() string { + if m != nil { + return m.Farmer + } + return "" +} + +// QueryRewardResponse is response type for the Query/Reward RPC method. +type QueryRewardResponse struct { + Reward Reward `protobuf:"bytes,1,opt,name=reward,proto3" json:"reward"` +} + +func (m *QueryRewardResponse) Reset() { *m = QueryRewardResponse{} } +func (m *QueryRewardResponse) String() string { return proto.CompactTextString(m) } +func (*QueryRewardResponse) ProtoMessage() {} +func (*QueryRewardResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_f60be7619b820df0, []int{13} +} +func (m *QueryRewardResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryRewardResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryRewardResponse.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 *QueryRewardResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryRewardResponse.Merge(m, src) +} +func (m *QueryRewardResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryRewardResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryRewardResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryRewardResponse proto.InternalMessageInfo + +func (m *QueryRewardResponse) GetReward() Reward { + if m != nil { + return m.Reward + } + return Reward{} +} + +// QueryRewardAllRequest is request type for the Query/AllReward RPC method. +type QueryRewardAllRequest struct { + Pagination *query.PageRequest `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryRewardAllRequest) Reset() { *m = QueryRewardAllRequest{} } +func (m *QueryRewardAllRequest) String() string { return proto.CompactTextString(m) } +func (*QueryRewardAllRequest) ProtoMessage() {} +func (*QueryRewardAllRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_f60be7619b820df0, []int{14} +} +func (m *QueryRewardAllRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryRewardAllRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryRewardAllRequest.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 *QueryRewardAllRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryRewardAllRequest.Merge(m, src) +} +func (m *QueryRewardAllRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryRewardAllRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryRewardAllRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryRewardAllRequest proto.InternalMessageInfo + +func (m *QueryRewardAllRequest) GetPagination() *query.PageRequest { + if m != nil { + return m.Pagination + } + return nil +} + +// QueryRewardAllResponse is response type for the Query/AllReward RPC method. +type QueryRewardAllResponse struct { + Reward []Reward `protobuf:"bytes,1,rep,name=reward,proto3" json:"reward"` + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryRewardAllResponse) Reset() { *m = QueryRewardAllResponse{} } +func (m *QueryRewardAllResponse) String() string { return proto.CompactTextString(m) } +func (*QueryRewardAllResponse) ProtoMessage() {} +func (*QueryRewardAllResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_f60be7619b820df0, []int{15} +} +func (m *QueryRewardAllResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryRewardAllResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryRewardAllResponse.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 *QueryRewardAllResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryRewardAllResponse.Merge(m, src) +} +func (m *QueryRewardAllResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryRewardAllResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryRewardAllResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryRewardAllResponse proto.InternalMessageInfo + +func (m *QueryRewardAllResponse) GetReward() []Reward { + if m != nil { + return m.Reward + } + return nil +} + +func (m *QueryRewardAllResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination + } + return nil +} + +func init() { + proto.RegisterType((*QueryParamsRequest)(nil), "titan.farming.QueryParamsRequest") + proto.RegisterType((*QueryParamsResponse)(nil), "titan.farming.QueryParamsResponse") + proto.RegisterType((*QueryFarmRequest)(nil), "titan.farming.QueryFarmRequest") + proto.RegisterType((*QueryFarmResponse)(nil), "titan.farming.QueryFarmResponse") + proto.RegisterType((*QueryFarmAllRequest)(nil), "titan.farming.QueryFarmAllRequest") + proto.RegisterType((*QueryFarmAllResponse)(nil), "titan.farming.QueryFarmAllResponse") + proto.RegisterType((*QueryStakingInfoRequest)(nil), "titan.farming.QueryStakingInfoRequest") + proto.RegisterType((*QueryStakingInfoResponse)(nil), "titan.farming.QueryStakingInfoResponse") + proto.RegisterType((*QueryStakingInfoAllRequest)(nil), "titan.farming.QueryStakingInfoAllRequest") + proto.RegisterType((*QueryStakingInfoAllResponse)(nil), "titan.farming.QueryStakingInfoAllResponse") + proto.RegisterType((*QueryDistributionInfoRequest)(nil), "titan.farming.QueryDistributionInfoRequest") + proto.RegisterType((*QueryDistributionInfoResponse)(nil), "titan.farming.QueryDistributionInfoResponse") + proto.RegisterType((*QueryRewardRequest)(nil), "titan.farming.QueryRewardRequest") + proto.RegisterType((*QueryRewardResponse)(nil), "titan.farming.QueryRewardResponse") + proto.RegisterType((*QueryRewardAllRequest)(nil), "titan.farming.QueryRewardAllRequest") + proto.RegisterType((*QueryRewardAllResponse)(nil), "titan.farming.QueryRewardAllResponse") +} + +func init() { proto.RegisterFile("titan/farming/query.proto", fileDescriptor_f60be7619b820df0) } + +var fileDescriptor_f60be7619b820df0 = []byte{ + // 869 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x56, 0x4f, 0x4f, 0x13, 0x4f, + 0x18, 0xee, 0xf2, 0xa7, 0xbf, 0x1f, 0x2f, 0x6a, 0x60, 0x28, 0x58, 0x56, 0x5c, 0xea, 0x0a, 0x85, + 0x42, 0xd9, 0x15, 0xd0, 0x78, 0xf2, 0x40, 0x31, 0x18, 0x3d, 0x61, 0xb9, 0x99, 0x98, 0x66, 0x4a, + 0x97, 0x75, 0x03, 0xdd, 0x2d, 0xbb, 0x5b, 0x01, 0x09, 0x89, 0xf1, 0x03, 0x18, 0x13, 0x13, 0x6f, + 0x26, 0xde, 0xbd, 0xfa, 0x21, 0x38, 0x12, 0xbd, 0x78, 0x30, 0xc6, 0x80, 0x1f, 0xc4, 0xec, 0xcc, + 0x5b, 0xba, 0xbb, 0xdd, 0x6d, 0x8b, 0xc1, 0xd3, 0x32, 0xf3, 0x3e, 0xf3, 0x3c, 0xcf, 0xcc, 0x3b, + 0xf3, 0x50, 0x18, 0x77, 0x0d, 0x97, 0x9a, 0xea, 0x16, 0xb5, 0xab, 0x86, 0xa9, 0xab, 0xbb, 0x75, + 0xcd, 0x3e, 0x50, 0x6a, 0xb6, 0xe5, 0x5a, 0xe4, 0x2a, 0x2b, 0x29, 0x58, 0x12, 0xe7, 0x36, 0x2d, + 0xa7, 0x6a, 0x39, 0x6a, 0x99, 0x3a, 0x1a, 0xc7, 0xa9, 0x2f, 0x17, 0xcb, 0x9a, 0x4b, 0x17, 0xd5, + 0x1a, 0xd5, 0x0d, 0x93, 0xba, 0x86, 0x65, 0xf2, 0xa5, 0xe2, 0x38, 0xc7, 0x96, 0xd8, 0x48, 0xe5, + 0x03, 0x2c, 0xa5, 0x74, 0x4b, 0xb7, 0xf8, 0xbc, 0xf7, 0x17, 0xce, 0x4e, 0xe8, 0x96, 0xa5, 0xef, + 0x68, 0x2a, 0xad, 0x19, 0x2a, 0x35, 0x4d, 0xcb, 0x65, 0x6c, 0x8d, 0x35, 0xd3, 0x41, 0x93, 0x15, + 0xc3, 0x71, 0x6d, 0xa3, 0x5c, 0xf7, 0x20, 0x25, 0xc3, 0xdc, 0x6a, 0x90, 0xa4, 0x83, 0x30, 0xef, + 0x8b, 0x15, 0x31, 0x58, 0xa9, 0x51, 0x9b, 0x56, 0x9d, 0xe8, 0x9a, 0xad, 0xed, 0x51, 0xbb, 0x82, + 0xb5, 0x4c, 0xb0, 0xe6, 0xb8, 0x74, 0xdb, 0x30, 0x75, 0x9f, 0xa6, 0x9c, 0x02, 0xf2, 0xd4, 0x3b, + 0x8b, 0x75, 0x46, 0x59, 0xd4, 0x76, 0xeb, 0x9a, 0xe3, 0xca, 0x4f, 0x60, 0x24, 0x30, 0xeb, 0xd4, + 0x2c, 0xd3, 0xd1, 0xc8, 0x32, 0x24, 0xb9, 0x74, 0x5a, 0xc8, 0x08, 0xb3, 0x83, 0x4b, 0xa3, 0x4a, + 0xe0, 0x88, 0x15, 0x0e, 0x2f, 0xf4, 0x1d, 0xff, 0x9c, 0x4c, 0x14, 0x11, 0x2a, 0xcf, 0xc2, 0x10, + 0xe3, 0x5a, 0xa3, 0x76, 0x15, 0xf9, 0x49, 0x0a, 0xfa, 0x5d, 0x6b, 0x5b, 0x33, 0x19, 0xcf, 0x40, + 0x91, 0x0f, 0xe4, 0x02, 0x0c, 0xfb, 0x90, 0xa8, 0xb9, 0x00, 0x7d, 0x1e, 0x3d, 0x2a, 0x8e, 0x84, + 0x14, 0x3d, 0x28, 0xea, 0x31, 0x98, 0xfc, 0x1c, 0x9d, 0x7b, 0x85, 0x95, 0x9d, 0x9d, 0x86, 0xe0, + 0x1a, 0x40, 0xb3, 0xc9, 0xc8, 0x95, 0x55, 0xb0, 0xb1, 0xde, 0x8d, 0x50, 0xf8, 0xcd, 0xc1, 0x1b, + 0xa1, 0xac, 0x53, 0x5d, 0xc3, 0xb5, 0x45, 0xdf, 0x4a, 0xf9, 0xad, 0x00, 0xa9, 0x20, 0x7f, 0x8b, + 0xcd, 0xde, 0x2e, 0x6c, 0x92, 0x47, 0x01, 0x3f, 0x3d, 0xcc, 0xcf, 0x4c, 0x47, 0x3f, 0x5c, 0x2b, + 0x60, 0x88, 0xc2, 0x75, 0xe6, 0x67, 0x83, 0xb7, 0xf6, 0xb1, 0xb9, 0x65, 0xb5, 0x3d, 0x64, 0x72, + 0x07, 0x92, 0xde, 0x35, 0xd0, 0x6c, 0xa6, 0x3a, 0x50, 0x48, 0x7f, 0xfd, 0xb2, 0x90, 0x42, 0xe1, + 0x95, 0x4a, 0xc5, 0xd6, 0x1c, 0x67, 0xc3, 0xb5, 0x0d, 0x53, 0x2f, 0x22, 0x4e, 0x2e, 0x41, 0xba, + 0x55, 0x02, 0xb7, 0xbd, 0x0a, 0x57, 0xfc, 0x97, 0x0a, 0x4f, 0x56, 0x0c, 0x6d, 0xdf, 0xb7, 0x12, + 0x4f, 0x61, 0xd0, 0x69, 0x4e, 0xc9, 0xaf, 0x40, 0x0c, 0x0b, 0xf8, 0x5a, 0x17, 0xbd, 0x8d, 0xb5, + 0x88, 0x03, 0xfc, 0x9b, 0x86, 0x7e, 0x16, 0xe0, 0x46, 0xa4, 0x78, 0xec, 0x06, 0x7b, 0x2f, 0xbc, + 0xc1, 0xcb, 0xeb, 0xb6, 0x04, 0x13, 0xcc, 0xec, 0x43, 0x5f, 0x82, 0xf8, 0x5a, 0x2e, 0x3b, 0x70, + 0x33, 0xa6, 0x8e, 0xdb, 0x29, 0xc2, 0x70, 0x4b, 0xfa, 0x60, 0xd3, 0x26, 0x43, 0x7b, 0x0a, 0x73, + 0xe0, 0xc6, 0x86, 0x2a, 0xa1, 0x79, 0x39, 0x8f, 0x11, 0x52, 0x64, 0xc9, 0xd3, 0x68, 0xdb, 0x18, + 0x24, 0x3d, 0x26, 0xcd, 0xc6, 0xbe, 0xe1, 0xe8, 0x3c, 0x5a, 0x1a, 0xe8, 0x66, 0xb4, 0xf0, 0xe4, + 0x8a, 0x89, 0x16, 0x0e, 0x6f, 0x44, 0x0b, 0x87, 0xca, 0x25, 0x18, 0xf5, 0x71, 0xfd, 0x83, 0xe7, + 0xfe, 0x41, 0x80, 0xb1, 0xb0, 0x42, 0x84, 0xe1, 0xde, 0x2e, 0x0d, 0x5f, 0xda, 0x45, 0x58, 0xfa, + 0xf1, 0x3f, 0xf4, 0x33, 0x63, 0x64, 0x0f, 0x92, 0x3c, 0x76, 0xc9, 0xad, 0x90, 0x83, 0xd6, 0x5c, + 0x17, 0xe5, 0x76, 0x10, 0x2e, 0x23, 0x67, 0xdf, 0x7c, 0xfb, 0xfd, 0xbe, 0x27, 0x43, 0x24, 0x95, + 0x61, 0xdd, 0xed, 0x7d, 0x35, 0xea, 0xbf, 0x0f, 0xd9, 0x83, 0x3e, 0x2f, 0xd6, 0xc8, 0x64, 0x14, + 0xa7, 0x2f, 0xec, 0xc5, 0x4c, 0x3c, 0x00, 0x25, 0xf3, 0x4c, 0x32, 0x4b, 0xa6, 0xe2, 0x24, 0xbd, + 0xaf, 0x7a, 0xc8, 0x5e, 0xfe, 0x11, 0xd9, 0x87, 0xff, 0x30, 0x7d, 0x89, 0x1c, 0x47, 0xdd, 0xbc, + 0x0b, 0xe2, 0xed, 0xb6, 0x18, 0x74, 0x30, 0xc5, 0x1c, 0x48, 0x64, 0xa2, 0x9d, 0x03, 0xf2, 0x51, + 0x80, 0x41, 0xdf, 0x53, 0x27, 0xd9, 0x28, 0xea, 0xd6, 0x24, 0x16, 0x67, 0x3a, 0xe2, 0xd0, 0xc6, + 0x03, 0x66, 0xe3, 0x3e, 0xb9, 0x17, 0x67, 0xc3, 0x9f, 0x45, 0x8d, 0x03, 0x51, 0x0f, 0x79, 0x50, + 0x1f, 0x79, 0xfe, 0xae, 0x05, 0x73, 0x8c, 0xe4, 0x3a, 0x48, 0xfb, 0x0e, 0x6a, 0xae, 0x1b, 0x28, + 0x1a, 0xbd, 0xcb, 0x8c, 0x2a, 0x24, 0x7f, 0x11, 0xa3, 0xe4, 0x93, 0x00, 0x43, 0xe1, 0x58, 0x21, + 0xf3, 0x51, 0xb2, 0x31, 0x01, 0x27, 0xe6, 0xbb, 0x03, 0xa3, 0xcb, 0x45, 0xe6, 0x72, 0x9e, 0xe4, + 0xe2, 0x5c, 0xb6, 0x64, 0x21, 0x79, 0x2d, 0x40, 0x92, 0x3f, 0xdd, 0xe8, 0xf7, 0x14, 0x08, 0xb9, + 0xe8, 0xf7, 0x14, 0x4c, 0x36, 0x59, 0x65, 0x26, 0x72, 0x64, 0x26, 0xce, 0x04, 0xcf, 0x06, 0xf5, + 0x90, 0x07, 0xe4, 0x91, 0x67, 0x61, 0xe0, 0x3c, 0x6f, 0xc8, 0x54, 0xbc, 0x84, 0xaf, 0x77, 0xd3, + 0x1d, 0x50, 0xdd, 0xbe, 0x6d, 0xee, 0xa5, 0xb0, 0x7a, 0x7c, 0x2a, 0x09, 0x27, 0xa7, 0x92, 0xf0, + 0xeb, 0x54, 0x12, 0xde, 0x9d, 0x49, 0x89, 0x93, 0x33, 0x29, 0xf1, 0xfd, 0x4c, 0x4a, 0x3c, 0xcb, + 0xe9, 0x86, 0xfb, 0xa2, 0x5e, 0x56, 0x36, 0xad, 0x6a, 0x98, 0x63, 0xff, 0x9c, 0xc5, 0x3d, 0xa8, + 0x69, 0x4e, 0x39, 0xc9, 0x7e, 0x61, 0x2e, 0xff, 0x09, 0x00, 0x00, 0xff, 0xff, 0x99, 0xc7, 0x9e, + 0x6e, 0xa3, 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 + +// 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) + // Farm queries a farm. + Farm(ctx context.Context, in *QueryFarmRequest, opts ...grpc.CallOption) (*QueryFarmResponse, error) + // FarmAll queries all farms. + FarmAll(ctx context.Context, in *QueryFarmAllRequest, opts ...grpc.CallOption) (*QueryFarmAllResponse, error) + // StakingInfo queries the staking info of a staker for a token. + StakingInfo(ctx context.Context, in *QueryStakingInfoRequest, opts ...grpc.CallOption) (*QueryStakingInfoResponse, error) + // StakingInfoAll queries all staking info of a token. + StakingInfoAll(ctx context.Context, in *QueryStakingInfoAllRequest, opts ...grpc.CallOption) (*QueryStakingInfoAllResponse, error) + // DistributionInfo queries the distribution info. + DistributionInfo(ctx context.Context, in *QueryDistributionInfoRequest, opts ...grpc.CallOption) (*QueryDistributionInfoResponse, error) + // Reward queries farming rewards of a farmer. + Reward(ctx context.Context, in *QueryRewardRequest, opts ...grpc.CallOption) (*QueryRewardResponse, error) + // Reward queries all farming rewards. + RewardAll(ctx context.Context, in *QueryRewardAllRequest, opts ...grpc.CallOption) (*QueryRewardAllResponse, 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, "/titan.farming.Query/Params", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) Farm(ctx context.Context, in *QueryFarmRequest, opts ...grpc.CallOption) (*QueryFarmResponse, error) { + out := new(QueryFarmResponse) + err := c.cc.Invoke(ctx, "/titan.farming.Query/Farm", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) FarmAll(ctx context.Context, in *QueryFarmAllRequest, opts ...grpc.CallOption) (*QueryFarmAllResponse, error) { + out := new(QueryFarmAllResponse) + err := c.cc.Invoke(ctx, "/titan.farming.Query/FarmAll", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) StakingInfo(ctx context.Context, in *QueryStakingInfoRequest, opts ...grpc.CallOption) (*QueryStakingInfoResponse, error) { + out := new(QueryStakingInfoResponse) + err := c.cc.Invoke(ctx, "/titan.farming.Query/StakingInfo", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) StakingInfoAll(ctx context.Context, in *QueryStakingInfoAllRequest, opts ...grpc.CallOption) (*QueryStakingInfoAllResponse, error) { + out := new(QueryStakingInfoAllResponse) + err := c.cc.Invoke(ctx, "/titan.farming.Query/StakingInfoAll", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) DistributionInfo(ctx context.Context, in *QueryDistributionInfoRequest, opts ...grpc.CallOption) (*QueryDistributionInfoResponse, error) { + out := new(QueryDistributionInfoResponse) + err := c.cc.Invoke(ctx, "/titan.farming.Query/DistributionInfo", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) Reward(ctx context.Context, in *QueryRewardRequest, opts ...grpc.CallOption) (*QueryRewardResponse, error) { + out := new(QueryRewardResponse) + err := c.cc.Invoke(ctx, "/titan.farming.Query/Reward", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) RewardAll(ctx context.Context, in *QueryRewardAllRequest, opts ...grpc.CallOption) (*QueryRewardAllResponse, error) { + out := new(QueryRewardAllResponse) + err := c.cc.Invoke(ctx, "/titan.farming.Query/RewardAll", 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) + // Farm queries a farm. + Farm(context.Context, *QueryFarmRequest) (*QueryFarmResponse, error) + // FarmAll queries all farms. + FarmAll(context.Context, *QueryFarmAllRequest) (*QueryFarmAllResponse, error) + // StakingInfo queries the staking info of a staker for a token. + StakingInfo(context.Context, *QueryStakingInfoRequest) (*QueryStakingInfoResponse, error) + // StakingInfoAll queries all staking info of a token. + StakingInfoAll(context.Context, *QueryStakingInfoAllRequest) (*QueryStakingInfoAllResponse, error) + // DistributionInfo queries the distribution info. + DistributionInfo(context.Context, *QueryDistributionInfoRequest) (*QueryDistributionInfoResponse, error) + // Reward queries farming rewards of a farmer. + Reward(context.Context, *QueryRewardRequest) (*QueryRewardResponse, error) + // Reward queries all farming rewards. + RewardAll(context.Context, *QueryRewardAllRequest) (*QueryRewardAllResponse, error) +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") +} +func (*UnimplementedQueryServer) Farm(ctx context.Context, req *QueryFarmRequest) (*QueryFarmResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Farm not implemented") +} +func (*UnimplementedQueryServer) FarmAll(ctx context.Context, req *QueryFarmAllRequest) (*QueryFarmAllResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method FarmAll not implemented") +} +func (*UnimplementedQueryServer) StakingInfo(ctx context.Context, req *QueryStakingInfoRequest) (*QueryStakingInfoResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method StakingInfo not implemented") +} +func (*UnimplementedQueryServer) StakingInfoAll(ctx context.Context, req *QueryStakingInfoAllRequest) (*QueryStakingInfoAllResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method StakingInfoAll not implemented") +} +func (*UnimplementedQueryServer) DistributionInfo(ctx context.Context, req *QueryDistributionInfoRequest) (*QueryDistributionInfoResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method DistributionInfo not implemented") +} +func (*UnimplementedQueryServer) Reward(ctx context.Context, req *QueryRewardRequest) (*QueryRewardResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Reward not implemented") +} +func (*UnimplementedQueryServer) RewardAll(ctx context.Context, req *QueryRewardAllRequest) (*QueryRewardAllResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RewardAll 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: "/titan.farming.Query/Params", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_Farm_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryFarmRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Farm(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/titan.farming.Query/Farm", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Farm(ctx, req.(*QueryFarmRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_FarmAll_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryFarmAllRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).FarmAll(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/titan.farming.Query/FarmAll", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).FarmAll(ctx, req.(*QueryFarmAllRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_StakingInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryStakingInfoRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).StakingInfo(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/titan.farming.Query/StakingInfo", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).StakingInfo(ctx, req.(*QueryStakingInfoRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_StakingInfoAll_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryStakingInfoAllRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).StakingInfoAll(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/titan.farming.Query/StakingInfoAll", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).StakingInfoAll(ctx, req.(*QueryStakingInfoAllRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_DistributionInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryDistributionInfoRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).DistributionInfo(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/titan.farming.Query/DistributionInfo", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).DistributionInfo(ctx, req.(*QueryDistributionInfoRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_Reward_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryRewardRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Reward(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/titan.farming.Query/Reward", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Reward(ctx, req.(*QueryRewardRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_RewardAll_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryRewardAllRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).RewardAll(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/titan.farming.Query/RewardAll", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).RewardAll(ctx, req.(*QueryRewardAllRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "titan.farming.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Params", + Handler: _Query_Params_Handler, + }, + { + MethodName: "Farm", + Handler: _Query_Farm_Handler, + }, + { + MethodName: "FarmAll", + Handler: _Query_FarmAll_Handler, + }, + { + MethodName: "StakingInfo", + Handler: _Query_StakingInfo_Handler, + }, + { + MethodName: "StakingInfoAll", + Handler: _Query_StakingInfoAll_Handler, + }, + { + MethodName: "DistributionInfo", + Handler: _Query_DistributionInfo_Handler, + }, + { + MethodName: "Reward", + Handler: _Query_Reward_Handler, + }, + { + MethodName: "RewardAll", + Handler: _Query_RewardAll_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "titan/farming/query.proto", +} + +func (m *QueryParamsRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryParamsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryParamsResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *QueryFarmRequest) 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 *QueryFarmRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryFarmRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Token) > 0 { + i -= len(m.Token) + copy(dAtA[i:], m.Token) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Token))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryFarmResponse) 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 *QueryFarmResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryFarmResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Farm.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *QueryFarmAllRequest) 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 *QueryFarmAllRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryFarmAllRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryFarmAllResponse) 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 *QueryFarmAllResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryFarmAllResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Farm) > 0 { + for iNdEx := len(m.Farm) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Farm[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *QueryStakingInfoRequest) 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 *QueryStakingInfoRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryStakingInfoRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Staker) > 0 { + i -= len(m.Staker) + copy(dAtA[i:], m.Staker) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Staker))) + i-- + dAtA[i] = 0x12 + } + if len(m.Token) > 0 { + i -= len(m.Token) + copy(dAtA[i:], m.Token) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Token))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryStakingInfoResponse) 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 *QueryStakingInfoResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryStakingInfoResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.StakingInfo.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *QueryStakingInfoAllRequest) 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 *QueryStakingInfoAllRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryStakingInfoAllRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Token) > 0 { + i -= len(m.Token) + copy(dAtA[i:], m.Token) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Token))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryStakingInfoAllResponse) 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 *QueryStakingInfoAllResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryStakingInfoAllResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.StakingInfo) > 0 { + for iNdEx := len(m.StakingInfo) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.StakingInfo[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *QueryDistributionInfoRequest) 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 *QueryDistributionInfoRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryDistributionInfoRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryDistributionInfoResponse) 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 *QueryDistributionInfoResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryDistributionInfoResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.DistributionInfo.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *QueryRewardRequest) 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 *QueryRewardRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryRewardRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Farmer) > 0 { + i -= len(m.Farmer) + copy(dAtA[i:], m.Farmer) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Farmer))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryRewardResponse) 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 *QueryRewardResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryRewardResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Reward.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *QueryRewardAllRequest) 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 *QueryRewardAllRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryRewardAllRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryRewardAllResponse) 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 *QueryRewardAllResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryRewardAllResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Reward) > 0 { + for iNdEx := len(m.Reward) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Reward[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = 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 (m *QueryFarmRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Token) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryFarmResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Farm.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryFarmAllRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryFarmAllResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Farm) > 0 { + for _, e := range m.Farm { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryStakingInfoRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Token) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.Staker) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryStakingInfoResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.StakingInfo.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryStakingInfoAllRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Token) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryStakingInfoAllResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.StakingInfo) > 0 { + for _, e := range m.StakingInfo { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryDistributionInfoRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryDistributionInfoResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.DistributionInfo.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryRewardRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Farmer) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryRewardResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Reward.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryRewardAllRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryRewardAllResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Reward) > 0 { + for _, e := range m.Reward { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func sovQuery(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QueryParamsRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryParamsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryFarmRequest) 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: QueryFarmRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryFarmRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Token", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Token = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryFarmResponse) 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: QueryFarmResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryFarmResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Farm", 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.Farm.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryFarmAllRequest) 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: QueryFarmAllRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryFarmAllRequest: 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 ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryFarmAllResponse) 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: QueryFarmAllResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryFarmAllResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Farm", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Farm = append(m.Farm, Farm{}) + if err := m.Farm[len(m.Farm)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryStakingInfoRequest) 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: QueryStakingInfoRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryStakingInfoRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Token", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Token = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Staker", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Staker = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryStakingInfoResponse) 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: QueryStakingInfoResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryStakingInfoResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StakingInfo", 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.StakingInfo.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryStakingInfoAllRequest) 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: QueryStakingInfoAllRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryStakingInfoAllRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Token", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Token = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryStakingInfoAllResponse) 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: QueryStakingInfoAllResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryStakingInfoAllResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StakingInfo", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.StakingInfo = append(m.StakingInfo, StakingInfo{}) + if err := m.StakingInfo[len(m.StakingInfo)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryDistributionInfoRequest) 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: QueryDistributionInfoRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryDistributionInfoRequest: 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 *QueryDistributionInfoResponse) 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: QueryDistributionInfoResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryDistributionInfoResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DistributionInfo", 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.DistributionInfo.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryRewardRequest) 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: QueryRewardRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryRewardRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Farmer", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Farmer = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryRewardResponse) 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: QueryRewardResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryRewardResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Reward", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 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.Reward.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryRewardAllRequest) 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: QueryRewardAllRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryRewardAllRequest: 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 ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryRewardAllResponse) 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: QueryRewardAllResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryRewardAllResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Reward", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Reward = append(m.Reward, Reward{}) + if err := m.Reward[len(m.Reward)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func 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/farming/types/query.pb.gw.go b/x/farming/types/query.pb.gw.go new file mode 100644 index 00000000..5bdc518b --- /dev/null +++ b/x/farming/types/query.pb.gw.go @@ -0,0 +1,828 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: titan/farming/query.proto + +/* +Package types is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package types + +import ( + "context" + "io" + "net/http" + + "github.com/golang/protobuf/descriptor" + "github.com/golang/protobuf/proto" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/grpc-ecosystem/grpc-gateway/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" +) + +// Suppress "imported and not used" errors +var _ codes.Code +var _ io.Reader +var _ status.Status +var _ = runtime.String +var _ = utilities.NewDoubleArray +var _ = descriptor.ForMessage +var _ = metadata.Join + +func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsRequest + var metadata runtime.ServerMetadata + + msg, err := client.Params(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsRequest + var metadata runtime.ServerMetadata + + msg, err := server.Params(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_Farm_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryFarmRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["token"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "token") + } + + protoReq.Token, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "token", err) + } + + msg, err := client.Farm(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Farm_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryFarmRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["token"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "token") + } + + protoReq.Token, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "token", err) + } + + msg, err := server.Farm(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_FarmAll_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Query_FarmAll_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryFarmAllRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_FarmAll_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.FarmAll(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_FarmAll_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryFarmAllRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_FarmAll_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.FarmAll(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_StakingInfo_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryStakingInfoRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["token"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "token") + } + + protoReq.Token, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "token", err) + } + + val, ok = pathParams["staker"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "staker") + } + + protoReq.Staker, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "staker", err) + } + + msg, err := client.StakingInfo(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_StakingInfo_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryStakingInfoRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["token"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "token") + } + + protoReq.Token, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "token", err) + } + + val, ok = pathParams["staker"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "staker") + } + + protoReq.Staker, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "staker", err) + } + + msg, err := server.StakingInfo(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_StakingInfoAll_0 = &utilities.DoubleArray{Encoding: map[string]int{"token": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} +) + +func request_Query_StakingInfoAll_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryStakingInfoAllRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["token"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "token") + } + + protoReq.Token, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "token", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_StakingInfoAll_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.StakingInfoAll(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_StakingInfoAll_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryStakingInfoAllRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["token"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "token") + } + + protoReq.Token, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "token", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_StakingInfoAll_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.StakingInfoAll(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_DistributionInfo_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryDistributionInfoRequest + var metadata runtime.ServerMetadata + + msg, err := client.DistributionInfo(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_DistributionInfo_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryDistributionInfoRequest + var metadata runtime.ServerMetadata + + msg, err := server.DistributionInfo(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_Reward_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryRewardRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["farmer"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "farmer") + } + + protoReq.Farmer, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "farmer", err) + } + + msg, err := client.Reward(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Reward_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryRewardRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["farmer"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "farmer") + } + + protoReq.Farmer, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "farmer", err) + } + + msg, err := server.Reward(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_RewardAll_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Query_RewardAll_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryRewardAllRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_RewardAll_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.RewardAll(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_RewardAll_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryRewardAllRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_RewardAll_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.RewardAll(ctx, &protoReq) + return msg, metadata, err + +} + +// RegisterQueryHandlerServer registers the http handlers for service Query to "mux". +// UnaryRPC :call QueryServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { + + mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_Params_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_Farm_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_Farm_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_Farm_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_FarmAll_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_FarmAll_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_FarmAll_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_StakingInfo_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_StakingInfo_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_StakingInfo_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_StakingInfoAll_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_StakingInfoAll_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_StakingInfoAll_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_DistributionInfo_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_DistributionInfo_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_DistributionInfo_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_Reward_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_Reward_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_Reward_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_RewardAll_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_RewardAll_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_RewardAll_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.Dial(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterQueryHandler(ctx, mux, conn) +} + +// RegisterQueryHandler registers the http handlers for service Query to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn)) +} + +// RegisterQueryHandlerClient registers the http handlers for service Query +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "QueryClient" to call the correct interceptors. +func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { + + mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_Params_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_Farm_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_Farm_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_Farm_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_FarmAll_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_FarmAll_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_FarmAll_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_StakingInfo_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_StakingInfo_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_StakingInfo_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_StakingInfoAll_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_StakingInfoAll_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_StakingInfoAll_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_DistributionInfo_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_DistributionInfo_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_DistributionInfo_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_Reward_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_Reward_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_Reward_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_RewardAll_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_RewardAll_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_RewardAll_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{"titantkx", "titan", "farming", "params"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_Farm_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"titantkx", "titan", "farming", "farm", "token"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_FarmAll_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"titantkx", "titan", "farming", "farm"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_StakingInfo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 1, 0, 4, 1, 5, 5}, []string{"titantkx", "titan", "farming", "staking_info", "token", "staker"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_StakingInfoAll_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"titantkx", "titan", "farming", "staking_info", "token"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_DistributionInfo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"titantkx", "titan", "farming", "distribution_info"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_Reward_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"titantkx", "titan", "farming", "reward", "farmer"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_RewardAll_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"titantkx", "titan", "farming", "reward"}, "", runtime.AssumeColonVerbOpt(false))) +) + +var ( + forward_Query_Params_0 = runtime.ForwardResponseMessage + + forward_Query_Farm_0 = runtime.ForwardResponseMessage + + forward_Query_FarmAll_0 = runtime.ForwardResponseMessage + + forward_Query_StakingInfo_0 = runtime.ForwardResponseMessage + + forward_Query_StakingInfoAll_0 = runtime.ForwardResponseMessage + + forward_Query_DistributionInfo_0 = runtime.ForwardResponseMessage + + forward_Query_Reward_0 = runtime.ForwardResponseMessage + + forward_Query_RewardAll_0 = runtime.ForwardResponseMessage +) diff --git a/x/farming/types/reward.pb.go b/x/farming/types/reward.pb.go new file mode 100644 index 00000000..e634b3fc --- /dev/null +++ b/x/farming/types/reward.pb.go @@ -0,0 +1,392 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: titan/farming/reward.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/cosmos/cosmos-sdk/types/tx/amino" + _ "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 + +// Reward defines the farming rewards of the farmer. +type Reward struct { + Farmer string `protobuf:"bytes,1,opt,name=farmer,proto3" json:"farmer,omitempty"` + Amount github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,2,rep,name=amount,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"amount"` +} + +func (m *Reward) Reset() { *m = Reward{} } +func (m *Reward) String() string { return proto.CompactTextString(m) } +func (*Reward) ProtoMessage() {} +func (*Reward) Descriptor() ([]byte, []int) { + return fileDescriptor_01e70246ad5a5e2b, []int{0} +} +func (m *Reward) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Reward) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Reward.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 *Reward) XXX_Merge(src proto.Message) { + xxx_messageInfo_Reward.Merge(m, src) +} +func (m *Reward) XXX_Size() int { + return m.Size() +} +func (m *Reward) XXX_DiscardUnknown() { + xxx_messageInfo_Reward.DiscardUnknown(m) +} + +var xxx_messageInfo_Reward proto.InternalMessageInfo + +func (m *Reward) GetFarmer() string { + if m != nil { + return m.Farmer + } + return "" +} + +func (m *Reward) GetAmount() github_com_cosmos_cosmos_sdk_types.Coins { + if m != nil { + return m.Amount + } + return nil +} + +func init() { + proto.RegisterType((*Reward)(nil), "titan.farming.Reward") +} + +func init() { proto.RegisterFile("titan/farming/reward.proto", fileDescriptor_01e70246ad5a5e2b) } + +var fileDescriptor_01e70246ad5a5e2b = []byte{ + // 310 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2a, 0xc9, 0x2c, 0x49, + 0xcc, 0xd3, 0x4f, 0x4b, 0x2c, 0xca, 0xcd, 0xcc, 0x4b, 0xd7, 0x2f, 0x4a, 0x2d, 0x4f, 0x2c, 0x4a, + 0xd1, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x05, 0xcb, 0xe9, 0x41, 0xe5, 0xa4, 0x04, 0x13, + 0x73, 0x33, 0xf3, 0xf2, 0xf5, 0xc1, 0x24, 0x44, 0x85, 0x94, 0x5c, 0x72, 0x7e, 0x71, 0x6e, 0x7e, + 0xb1, 0x7e, 0x52, 0x62, 0x71, 0xaa, 0x7e, 0x99, 0x61, 0x52, 0x6a, 0x49, 0xa2, 0xa1, 0x7e, 0x72, + 0x7e, 0x66, 0x1e, 0x54, 0x5e, 0x12, 0x22, 0x1f, 0x0f, 0xe6, 0xe9, 0x43, 0x38, 0x50, 0x29, 0x91, + 0xf4, 0xfc, 0xf4, 0x7c, 0x88, 0x38, 0x88, 0x05, 0x11, 0x55, 0xda, 0xca, 0xc8, 0xc5, 0x16, 0x04, + 0x76, 0x83, 0x90, 0x01, 0x17, 0x1b, 0xc8, 0xe6, 0xd4, 0x22, 0x09, 0x46, 0x05, 0x46, 0x0d, 0x4e, + 0x27, 0x89, 0x4b, 0x5b, 0x74, 0x45, 0xa0, 0x46, 0x38, 0xa6, 0xa4, 0x14, 0xa5, 0x16, 0x17, 0x07, + 0x97, 0x14, 0x65, 0xe6, 0xa5, 0x07, 0x41, 0xd5, 0x09, 0x55, 0x72, 0xb1, 0x25, 0xe6, 0xe6, 0x97, + 0xe6, 0x95, 0x48, 0x30, 0x29, 0x30, 0x6b, 0x70, 0x1b, 0x49, 0xea, 0x41, 0x95, 0x83, 0x9c, 0xa7, + 0x07, 0x75, 0x9e, 0x9e, 0x73, 0x7e, 0x66, 0x9e, 0x93, 0xdb, 0x89, 0x7b, 0xf2, 0x0c, 0xab, 0xee, + 0xcb, 0x6b, 0xa4, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0x42, 0x9d, 0x07, 0xa5, + 0x74, 0x8b, 0x53, 0xb2, 0xf5, 0x4b, 0x2a, 0x0b, 0x52, 0x8b, 0xc1, 0x1a, 0x8a, 0x67, 0x3d, 0xdf, + 0xa0, 0xc5, 0x93, 0x93, 0x9a, 0x9e, 0x98, 0x5c, 0x19, 0x0f, 0xf2, 0x60, 0xf1, 0x8a, 0xe7, 0x1b, + 0xb4, 0x18, 0x83, 0xa0, 0x16, 0x3a, 0x39, 0x9f, 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, 0x26, 0x92, 0x0d, 0xe0, 0xf0, 0x2c, 0xc9, 0xae, 0x80, 0x30, 0xf4, 0x2b, 0xe0, 0xc1, + 0x0e, 0xb6, 0x28, 0x89, 0x0d, 0x1c, 0x06, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0x2d, 0x74, + 0x65, 0xa3, 0x94, 0x01, 0x00, 0x00, +} + +func (m *Reward) 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 *Reward) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Reward) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Amount) > 0 { + for iNdEx := len(m.Amount) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Amount[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintReward(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if len(m.Farmer) > 0 { + i -= len(m.Farmer) + copy(dAtA[i:], m.Farmer) + i = encodeVarintReward(dAtA, i, uint64(len(m.Farmer))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintReward(dAtA []byte, offset int, v uint64) int { + offset -= sovReward(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Reward) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Farmer) + if l > 0 { + n += 1 + l + sovReward(uint64(l)) + } + if len(m.Amount) > 0 { + for _, e := range m.Amount { + l = e.Size() + n += 1 + l + sovReward(uint64(l)) + } + } + return n +} + +func sovReward(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozReward(x uint64) (n int) { + return sovReward(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Reward) 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 ErrIntOverflowReward + } + 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: Reward: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Reward: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Farmer", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowReward + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthReward + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthReward + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Farmer = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowReward + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthReward + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthReward + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Amount = append(m.Amount, types.Coin{}) + if err := m.Amount[len(m.Amount)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipReward(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthReward + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipReward(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, ErrIntOverflowReward + } + 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, ErrIntOverflowReward + } + 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, ErrIntOverflowReward + } + 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, ErrInvalidLengthReward + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupReward + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthReward + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthReward = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowReward = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupReward = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/farming/types/staking_info.pb.go b/x/farming/types/staking_info.pb.go new file mode 100644 index 00000000..4162fff5 --- /dev/null +++ b/x/farming/types/staking_info.pb.go @@ -0,0 +1,426 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: titan/farming/staking_info.proto + +package types + +import ( + cosmossdk_io_math "cosmossdk.io/math" + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + _ "github.com/cosmos/cosmos-sdk/types/tx/amino" + _ "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 + +// StakingInfo defines the staking info of a staker for a token. +type StakingInfo struct { + Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` + Staker string `protobuf:"bytes,2,opt,name=staker,proto3" json:"staker,omitempty"` + Amount cosmossdk_io_math.Int `protobuf:"bytes,3,opt,name=amount,proto3,customtype=cosmossdk.io/math.Int" json:"amount"` +} + +func (m *StakingInfo) Reset() { *m = StakingInfo{} } +func (m *StakingInfo) String() string { return proto.CompactTextString(m) } +func (*StakingInfo) ProtoMessage() {} +func (*StakingInfo) Descriptor() ([]byte, []int) { + return fileDescriptor_dc2cf0ffff1c61f5, []int{0} +} +func (m *StakingInfo) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *StakingInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_StakingInfo.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 *StakingInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_StakingInfo.Merge(m, src) +} +func (m *StakingInfo) XXX_Size() int { + return m.Size() +} +func (m *StakingInfo) XXX_DiscardUnknown() { + xxx_messageInfo_StakingInfo.DiscardUnknown(m) +} + +var xxx_messageInfo_StakingInfo proto.InternalMessageInfo + +func (m *StakingInfo) GetToken() string { + if m != nil { + return m.Token + } + return "" +} + +func (m *StakingInfo) GetStaker() string { + if m != nil { + return m.Staker + } + return "" +} + +func init() { + proto.RegisterType((*StakingInfo)(nil), "titan.farming.StakingInfo") +} + +func init() { proto.RegisterFile("titan/farming/staking_info.proto", fileDescriptor_dc2cf0ffff1c61f5) } + +var fileDescriptor_dc2cf0ffff1c61f5 = []byte{ + // 290 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x28, 0xc9, 0x2c, 0x49, + 0xcc, 0xd3, 0x4f, 0x4b, 0x2c, 0xca, 0xcd, 0xcc, 0x4b, 0xd7, 0x2f, 0x2e, 0x49, 0xcc, 0xce, 0xcc, + 0x4b, 0x8f, 0xcf, 0xcc, 0x4b, 0xcb, 0xd7, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x05, 0xab, + 0xd0, 0x83, 0xaa, 0x90, 0x12, 0x4c, 0xcc, 0xcd, 0xcc, 0xcb, 0xd7, 0x07, 0x93, 0x10, 0x15, 0x52, + 0x92, 0xc9, 0xf9, 0xc5, 0xb9, 0xf9, 0xc5, 0xf1, 0x60, 0x9e, 0x3e, 0x84, 0x03, 0x95, 0x12, 0x49, + 0xcf, 0x4f, 0xcf, 0x87, 0x88, 0x83, 0x58, 0x10, 0x51, 0xa5, 0xf9, 0x8c, 0x5c, 0xdc, 0xc1, 0x10, + 0x9b, 0x3c, 0xf3, 0xd2, 0xf2, 0x85, 0x44, 0xb8, 0x58, 0x4b, 0xf2, 0xb3, 0x53, 0xf3, 0x24, 0x18, + 0x15, 0x18, 0x35, 0x38, 0x83, 0x20, 0x1c, 0x21, 0x03, 0x2e, 0x36, 0x90, 0x73, 0x52, 0x8b, 0x24, + 0x98, 0x40, 0xc2, 0x4e, 0x12, 0x97, 0xb6, 0xe8, 0x8a, 0x40, 0x4d, 0x77, 0x4c, 0x49, 0x29, 0x4a, + 0x2d, 0x2e, 0x0e, 0x2e, 0x29, 0xca, 0xcc, 0x4b, 0x0f, 0x82, 0xaa, 0x13, 0xf2, 0xe0, 0x62, 0x4b, + 0xcc, 0xcd, 0x2f, 0xcd, 0x2b, 0x91, 0x60, 0x06, 0xeb, 0x30, 0x38, 0x71, 0x4f, 0x9e, 0xe1, 0xd6, + 0x3d, 0x79, 0x51, 0x88, 0xae, 0xe2, 0x94, 0x6c, 0xbd, 0xcc, 0x7c, 0xfd, 0xdc, 0xc4, 0x92, 0x0c, + 0x3d, 0xcf, 0xbc, 0x92, 0x4b, 0x5b, 0x74, 0xb9, 0xa0, 0xc6, 0x79, 0xe6, 0x95, 0xac, 0x78, 0xbe, + 0x41, 0x8b, 0x31, 0x08, 0xaa, 0xdf, 0xc9, 0xf9, 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, 0x34, 0xd3, 0x33, 0x4b, 0x32, 0x4a, 0x93, 0xf4, 0x92, 0xf3, 0x73, 0xf5, 0xc1, 0x21, + 0x53, 0x92, 0x5d, 0x01, 0x61, 0xe8, 0x57, 0xc0, 0x83, 0xb1, 0xa4, 0xb2, 0x20, 0xb5, 0x38, 0x89, + 0x0d, 0xec, 0x5b, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x64, 0x95, 0x66, 0x0f, 0x64, 0x01, + 0x00, 0x00, +} + +func (m *StakingInfo) 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 *StakingInfo) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *StakingInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.Amount.Size() + i -= size + if _, err := m.Amount.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintStakingInfo(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if len(m.Staker) > 0 { + i -= len(m.Staker) + copy(dAtA[i:], m.Staker) + i = encodeVarintStakingInfo(dAtA, i, uint64(len(m.Staker))) + i-- + dAtA[i] = 0x12 + } + if len(m.Token) > 0 { + i -= len(m.Token) + copy(dAtA[i:], m.Token) + i = encodeVarintStakingInfo(dAtA, i, uint64(len(m.Token))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintStakingInfo(dAtA []byte, offset int, v uint64) int { + offset -= sovStakingInfo(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *StakingInfo) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Token) + if l > 0 { + n += 1 + l + sovStakingInfo(uint64(l)) + } + l = len(m.Staker) + if l > 0 { + n += 1 + l + sovStakingInfo(uint64(l)) + } + l = m.Amount.Size() + n += 1 + l + sovStakingInfo(uint64(l)) + return n +} + +func sovStakingInfo(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozStakingInfo(x uint64) (n int) { + return sovStakingInfo(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *StakingInfo) 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 ErrIntOverflowStakingInfo + } + 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: StakingInfo: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: StakingInfo: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Token", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStakingInfo + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthStakingInfo + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthStakingInfo + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Token = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Staker", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStakingInfo + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthStakingInfo + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthStakingInfo + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Staker = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStakingInfo + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthStakingInfo + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthStakingInfo + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Amount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipStakingInfo(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthStakingInfo + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipStakingInfo(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, ErrIntOverflowStakingInfo + } + 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, ErrIntOverflowStakingInfo + } + 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, ErrIntOverflowStakingInfo + } + 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, ErrInvalidLengthStakingInfo + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupStakingInfo + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthStakingInfo + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthStakingInfo = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowStakingInfo = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupStakingInfo = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/farming/types/tx.pb.go b/x/farming/types/tx.pb.go new file mode 100644 index 00000000..524bb790 --- /dev/null +++ b/x/farming/types/tx.pb.go @@ -0,0 +1,1882 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: titan/farming/tx.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/cosmos/cosmos-sdk/types/tx/amino" + _ "github.com/cosmos/gogoproto/gogoproto" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + github_com_cosmos_gogoproto_types "github.com/cosmos/gogoproto/types" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + _ "google.golang.org/protobuf/types/known/timestamppb" + io "io" + math "math" + math_bits "math/bits" + time "time" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf +var _ = time.Kitchen + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// MsgStake represents a message to add farming rewards. +type MsgAddReward struct { + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + Token string `protobuf:"bytes,2,opt,name=token,proto3" json:"token,omitempty"` + Amount github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,3,rep,name=amount,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"amount"` + EndTime time.Time `protobuf:"bytes,4,opt,name=end_time,json=endTime,proto3,stdtime" json:"end_time"` + StartTime time.Time `protobuf:"bytes,5,opt,name=start_time,json=startTime,proto3,stdtime" json:"start_time"` +} + +func (m *MsgAddReward) Reset() { *m = MsgAddReward{} } +func (m *MsgAddReward) String() string { return proto.CompactTextString(m) } +func (*MsgAddReward) ProtoMessage() {} +func (*MsgAddReward) Descriptor() ([]byte, []int) { + return fileDescriptor_1401287e52610841, []int{0} +} +func (m *MsgAddReward) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgAddReward) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgAddReward.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 *MsgAddReward) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgAddReward.Merge(m, src) +} +func (m *MsgAddReward) XXX_Size() int { + return m.Size() +} +func (m *MsgAddReward) XXX_DiscardUnknown() { + xxx_messageInfo_MsgAddReward.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgAddReward proto.InternalMessageInfo + +func (m *MsgAddReward) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +func (m *MsgAddReward) GetToken() string { + if m != nil { + return m.Token + } + return "" +} + +func (m *MsgAddReward) GetAmount() github_com_cosmos_cosmos_sdk_types.Coins { + if m != nil { + return m.Amount + } + return nil +} + +func (m *MsgAddReward) GetEndTime() time.Time { + if m != nil { + return m.EndTime + } + return time.Time{} +} + +func (m *MsgAddReward) GetStartTime() time.Time { + if m != nil { + return m.StartTime + } + return time.Time{} +} + +// MsgAddRewardResponse defines the Msg/AddReward response type. +type MsgAddRewardResponse struct { +} + +func (m *MsgAddRewardResponse) Reset() { *m = MsgAddRewardResponse{} } +func (m *MsgAddRewardResponse) String() string { return proto.CompactTextString(m) } +func (*MsgAddRewardResponse) ProtoMessage() {} +func (*MsgAddRewardResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_1401287e52610841, []int{1} +} +func (m *MsgAddRewardResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgAddRewardResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgAddRewardResponse.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 *MsgAddRewardResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgAddRewardResponse.Merge(m, src) +} +func (m *MsgAddRewardResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgAddRewardResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgAddRewardResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgAddRewardResponse proto.InternalMessageInfo + +// MsgStake represents a message to stake tokens. +type MsgStake struct { + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + Amount github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,2,rep,name=amount,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"amount"` +} + +func (m *MsgStake) Reset() { *m = MsgStake{} } +func (m *MsgStake) String() string { return proto.CompactTextString(m) } +func (*MsgStake) ProtoMessage() {} +func (*MsgStake) Descriptor() ([]byte, []int) { + return fileDescriptor_1401287e52610841, []int{2} +} +func (m *MsgStake) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgStake) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgStake.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 *MsgStake) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgStake.Merge(m, src) +} +func (m *MsgStake) XXX_Size() int { + return m.Size() +} +func (m *MsgStake) XXX_DiscardUnknown() { + xxx_messageInfo_MsgStake.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgStake proto.InternalMessageInfo + +func (m *MsgStake) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +func (m *MsgStake) GetAmount() github_com_cosmos_cosmos_sdk_types.Coins { + if m != nil { + return m.Amount + } + return nil +} + +// MsgStakeResponse defines the Msg/Stake response type. +type MsgStakeResponse struct { +} + +func (m *MsgStakeResponse) Reset() { *m = MsgStakeResponse{} } +func (m *MsgStakeResponse) String() string { return proto.CompactTextString(m) } +func (*MsgStakeResponse) ProtoMessage() {} +func (*MsgStakeResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_1401287e52610841, []int{3} +} +func (m *MsgStakeResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgStakeResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgStakeResponse.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 *MsgStakeResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgStakeResponse.Merge(m, src) +} +func (m *MsgStakeResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgStakeResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgStakeResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgStakeResponse proto.InternalMessageInfo + +// MsgUnstake represents a message to unstake tokens. +type MsgUnstake struct { + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + Amount github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,2,rep,name=amount,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"amount"` +} + +func (m *MsgUnstake) Reset() { *m = MsgUnstake{} } +func (m *MsgUnstake) String() string { return proto.CompactTextString(m) } +func (*MsgUnstake) ProtoMessage() {} +func (*MsgUnstake) Descriptor() ([]byte, []int) { + return fileDescriptor_1401287e52610841, []int{4} +} +func (m *MsgUnstake) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUnstake) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUnstake.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 *MsgUnstake) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUnstake.Merge(m, src) +} +func (m *MsgUnstake) XXX_Size() int { + return m.Size() +} +func (m *MsgUnstake) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUnstake.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUnstake proto.InternalMessageInfo + +func (m *MsgUnstake) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +func (m *MsgUnstake) GetAmount() github_com_cosmos_cosmos_sdk_types.Coins { + if m != nil { + return m.Amount + } + return nil +} + +// MsgUnstakeResponse defines the Msg/Unstake response type. +type MsgUnstakeResponse struct { +} + +func (m *MsgUnstakeResponse) Reset() { *m = MsgUnstakeResponse{} } +func (m *MsgUnstakeResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUnstakeResponse) ProtoMessage() {} +func (*MsgUnstakeResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_1401287e52610841, []int{5} +} +func (m *MsgUnstakeResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUnstakeResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUnstakeResponse.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 *MsgUnstakeResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUnstakeResponse.Merge(m, src) +} +func (m *MsgUnstakeResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgUnstakeResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUnstakeResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUnstakeResponse proto.InternalMessageInfo + +// MsgHarvest represents a message to harvest farming rewards. +type MsgHarvest struct { + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` +} + +func (m *MsgHarvest) Reset() { *m = MsgHarvest{} } +func (m *MsgHarvest) String() string { return proto.CompactTextString(m) } +func (*MsgHarvest) ProtoMessage() {} +func (*MsgHarvest) Descriptor() ([]byte, []int) { + return fileDescriptor_1401287e52610841, []int{6} +} +func (m *MsgHarvest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgHarvest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgHarvest.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 *MsgHarvest) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgHarvest.Merge(m, src) +} +func (m *MsgHarvest) XXX_Size() int { + return m.Size() +} +func (m *MsgHarvest) XXX_DiscardUnknown() { + xxx_messageInfo_MsgHarvest.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgHarvest proto.InternalMessageInfo + +func (m *MsgHarvest) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +// MsgHarvestResponse defines the Msg/Harvest response type. +type MsgHarvestResponse struct { +} + +func (m *MsgHarvestResponse) Reset() { *m = MsgHarvestResponse{} } +func (m *MsgHarvestResponse) String() string { return proto.CompactTextString(m) } +func (*MsgHarvestResponse) ProtoMessage() {} +func (*MsgHarvestResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_1401287e52610841, []int{7} +} +func (m *MsgHarvestResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgHarvestResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgHarvestResponse.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 *MsgHarvestResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgHarvestResponse.Merge(m, src) +} +func (m *MsgHarvestResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgHarvestResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgHarvestResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgHarvestResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*MsgAddReward)(nil), "titan.farming.MsgAddReward") + proto.RegisterType((*MsgAddRewardResponse)(nil), "titan.farming.MsgAddRewardResponse") + proto.RegisterType((*MsgStake)(nil), "titan.farming.MsgStake") + proto.RegisterType((*MsgStakeResponse)(nil), "titan.farming.MsgStakeResponse") + proto.RegisterType((*MsgUnstake)(nil), "titan.farming.MsgUnstake") + proto.RegisterType((*MsgUnstakeResponse)(nil), "titan.farming.MsgUnstakeResponse") + proto.RegisterType((*MsgHarvest)(nil), "titan.farming.MsgHarvest") + proto.RegisterType((*MsgHarvestResponse)(nil), "titan.farming.MsgHarvestResponse") +} + +func init() { proto.RegisterFile("titan/farming/tx.proto", fileDescriptor_1401287e52610841) } + +var fileDescriptor_1401287e52610841 = []byte{ + // 560 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x54, 0x4f, 0x6f, 0x12, 0x41, + 0x14, 0x67, 0xa9, 0x50, 0x98, 0xd6, 0x44, 0x37, 0xa4, 0xc2, 0x9a, 0x2c, 0x88, 0x17, 0x6c, 0xd2, + 0x19, 0x8b, 0x77, 0x0d, 0x90, 0xa8, 0x17, 0x2e, 0x5b, 0xbd, 0x78, 0x21, 0x03, 0x3b, 0x1d, 0x37, + 0x74, 0x67, 0xc8, 0xbe, 0xa1, 0xc2, 0xb7, 0xe8, 0xd9, 0x4f, 0xa0, 0x9e, 0x7a, 0x30, 0x31, 0x7e, + 0x83, 0x1e, 0x1b, 0x2f, 0x7a, 0xb2, 0x06, 0x0e, 0xfd, 0x1a, 0x66, 0x77, 0x66, 0x01, 0x6d, 0x6b, + 0x52, 0x0f, 0x26, 0x5e, 0x76, 0xe7, 0xbd, 0xdf, 0x7b, 0xbf, 0x99, 0xdf, 0x6f, 0xfe, 0xa0, 0x2d, + 0x15, 0x28, 0x2a, 0xc8, 0x3e, 0x8d, 0xc2, 0x40, 0x70, 0xa2, 0x26, 0x78, 0x14, 0x49, 0x25, 0xed, + 0x9b, 0x49, 0x1e, 0x9b, 0xbc, 0x73, 0x9b, 0x86, 0x81, 0x90, 0x24, 0xf9, 0xea, 0x0a, 0xc7, 0x1d, + 0x48, 0x08, 0x25, 0x90, 0x3e, 0x05, 0x46, 0x0e, 0x77, 0xfb, 0x4c, 0xd1, 0x5d, 0x32, 0x90, 0x81, + 0x30, 0x78, 0x45, 0xe3, 0xbd, 0x24, 0x22, 0x3a, 0x30, 0x50, 0x89, 0x4b, 0x2e, 0x75, 0x3e, 0x1e, + 0x99, 0x6c, 0x95, 0x4b, 0xc9, 0x0f, 0x18, 0x49, 0xa2, 0xfe, 0x78, 0x9f, 0xa8, 0x20, 0x64, 0xa0, + 0x68, 0x38, 0xd2, 0x05, 0xf5, 0xaf, 0x59, 0xb4, 0xd9, 0x05, 0xde, 0xf2, 0x7d, 0x8f, 0xbd, 0xa1, + 0x91, 0x6f, 0x3f, 0x44, 0x79, 0x60, 0xc2, 0x67, 0x51, 0xd9, 0xaa, 0x59, 0x8d, 0x62, 0xbb, 0xfc, + 0xe5, 0xe3, 0x4e, 0xc9, 0xcc, 0xd4, 0xf2, 0xfd, 0x88, 0x01, 0xec, 0xa9, 0x28, 0x10, 0xdc, 0x33, + 0x75, 0x76, 0x09, 0xe5, 0x94, 0x1c, 0x32, 0x51, 0xce, 0xc6, 0x0d, 0x9e, 0x0e, 0xec, 0x29, 0xca, + 0xd3, 0x50, 0x8e, 0x85, 0x2a, 0xaf, 0xd5, 0xd6, 0x1a, 0x1b, 0xcd, 0x0a, 0x36, 0x24, 0xb1, 0x36, + 0x6c, 0xb4, 0xe1, 0x8e, 0x0c, 0x44, 0xfb, 0xe9, 0xc9, 0xf7, 0x6a, 0xe6, 0xc3, 0x59, 0xb5, 0xc1, + 0x03, 0xf5, 0x7a, 0xdc, 0xc7, 0x03, 0x19, 0x1a, 0x6d, 0xe6, 0xb7, 0x03, 0xfe, 0x90, 0xa8, 0xe9, + 0x88, 0x41, 0xd2, 0x00, 0x6f, 0xcf, 0x8f, 0xb7, 0x37, 0x0f, 0x18, 0xa7, 0x83, 0x69, 0x2f, 0x76, + 0x07, 0xde, 0x9d, 0x1f, 0x6f, 0x5b, 0x9e, 0x99, 0xd0, 0x7e, 0x82, 0x0a, 0x4c, 0xf8, 0xbd, 0x58, + 0x6a, 0xf9, 0x46, 0xcd, 0x6a, 0x6c, 0x34, 0x1d, 0xac, 0x7d, 0xc0, 0xa9, 0x0f, 0xf8, 0x45, 0xea, + 0x43, 0xbb, 0x10, 0xcf, 0x7e, 0x74, 0x56, 0xb5, 0xbc, 0x75, 0x26, 0xfc, 0x38, 0x6f, 0x77, 0x10, + 0x02, 0x45, 0x23, 0xa5, 0x29, 0x72, 0xd7, 0xa0, 0x28, 0x26, 0x7d, 0x31, 0x52, 0xdf, 0x42, 0xa5, + 0x55, 0x63, 0x3d, 0x06, 0x23, 0x29, 0x80, 0xd5, 0x3f, 0x59, 0xa8, 0xd0, 0x05, 0xbe, 0xa7, 0xe8, + 0x90, 0xfd, 0x85, 0xdb, 0x4b, 0x5f, 0xb3, 0xff, 0xd8, 0xd7, 0xba, 0x8d, 0x6e, 0xa5, 0x0b, 0x5f, + 0xa8, 0xf9, 0x6c, 0x21, 0xd4, 0x05, 0xfe, 0x52, 0xc0, 0xff, 0xa7, 0xa7, 0x84, 0xec, 0xe5, 0xd2, + 0x17, 0x8a, 0x1e, 0x27, 0x82, 0x9e, 0xd3, 0xe8, 0x90, 0x81, 0xba, 0xbe, 0x20, 0xc3, 0x6a, 0xfa, + 0x53, 0xd6, 0xe6, 0xfb, 0x2c, 0x5a, 0xeb, 0x02, 0xb7, 0xbb, 0xa8, 0xb8, 0xbc, 0x6b, 0x77, 0xf1, + 0x2f, 0x2f, 0x02, 0x5e, 0x3d, 0x2f, 0xce, 0xfd, 0x3f, 0x80, 0x29, 0xad, 0xdd, 0x42, 0x39, 0x7d, + 0x90, 0xee, 0x5c, 0xac, 0x4e, 0x00, 0xa7, 0x7a, 0x05, 0xb0, 0xa0, 0x78, 0x86, 0xd6, 0xd3, 0xdd, + 0xab, 0x5c, 0xac, 0x35, 0x90, 0x73, 0xef, 0x4a, 0x68, 0x95, 0x28, 0x75, 0xed, 0x12, 0x22, 0x03, + 0x5d, 0x46, 0xf4, 0x9b, 0x57, 0xed, 0xce, 0xc9, 0xcc, 0xb5, 0x4e, 0x67, 0xae, 0xf5, 0x63, 0xe6, + 0x5a, 0x47, 0x73, 0x37, 0x73, 0x3a, 0x77, 0x33, 0xdf, 0xe6, 0x6e, 0xe6, 0xd5, 0x83, 0x95, 0x9d, + 0x4f, 0x68, 0xd4, 0x70, 0xa2, 0x07, 0x64, 0xb2, 0x7c, 0x6f, 0xe3, 0x03, 0xd0, 0xcf, 0x27, 0xf7, + 0xf4, 0xd1, 0xcf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x97, 0x6e, 0x9f, 0xac, 0x8d, 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 { + // AddReward defines a method to add farming rewards. + AddReward(ctx context.Context, in *MsgAddReward, opts ...grpc.CallOption) (*MsgAddRewardResponse, error) + // Stake defines a method to stake tokens. + Stake(ctx context.Context, in *MsgStake, opts ...grpc.CallOption) (*MsgStakeResponse, error) + // Unstake defines a method to unstake tokens. + Unstake(ctx context.Context, in *MsgUnstake, opts ...grpc.CallOption) (*MsgUnstakeResponse, error) + // Harvest defines a method to add harvest farming rewards. + Harvest(ctx context.Context, in *MsgHarvest, opts ...grpc.CallOption) (*MsgHarvestResponse, error) +} + +type msgClient struct { + cc grpc1.ClientConn +} + +func NewMsgClient(cc grpc1.ClientConn) MsgClient { + return &msgClient{cc} +} + +func (c *msgClient) AddReward(ctx context.Context, in *MsgAddReward, opts ...grpc.CallOption) (*MsgAddRewardResponse, error) { + out := new(MsgAddRewardResponse) + err := c.cc.Invoke(ctx, "/titan.farming.Msg/AddReward", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) Stake(ctx context.Context, in *MsgStake, opts ...grpc.CallOption) (*MsgStakeResponse, error) { + out := new(MsgStakeResponse) + err := c.cc.Invoke(ctx, "/titan.farming.Msg/Stake", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) Unstake(ctx context.Context, in *MsgUnstake, opts ...grpc.CallOption) (*MsgUnstakeResponse, error) { + out := new(MsgUnstakeResponse) + err := c.cc.Invoke(ctx, "/titan.farming.Msg/Unstake", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) Harvest(ctx context.Context, in *MsgHarvest, opts ...grpc.CallOption) (*MsgHarvestResponse, error) { + out := new(MsgHarvestResponse) + err := c.cc.Invoke(ctx, "/titan.farming.Msg/Harvest", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// MsgServer is the server API for Msg service. +type MsgServer interface { + // AddReward defines a method to add farming rewards. + AddReward(context.Context, *MsgAddReward) (*MsgAddRewardResponse, error) + // Stake defines a method to stake tokens. + Stake(context.Context, *MsgStake) (*MsgStakeResponse, error) + // Unstake defines a method to unstake tokens. + Unstake(context.Context, *MsgUnstake) (*MsgUnstakeResponse, error) + // Harvest defines a method to add harvest farming rewards. + Harvest(context.Context, *MsgHarvest) (*MsgHarvestResponse, error) +} + +// UnimplementedMsgServer can be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { +} + +func (*UnimplementedMsgServer) AddReward(ctx context.Context, req *MsgAddReward) (*MsgAddRewardResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method AddReward not implemented") +} +func (*UnimplementedMsgServer) Stake(ctx context.Context, req *MsgStake) (*MsgStakeResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Stake not implemented") +} +func (*UnimplementedMsgServer) Unstake(ctx context.Context, req *MsgUnstake) (*MsgUnstakeResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Unstake not implemented") +} +func (*UnimplementedMsgServer) Harvest(ctx context.Context, req *MsgHarvest) (*MsgHarvestResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Harvest not implemented") +} + +func RegisterMsgServer(s grpc1.Server, srv MsgServer) { + s.RegisterService(&_Msg_serviceDesc, srv) +} + +func _Msg_AddReward_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgAddReward) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).AddReward(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/titan.farming.Msg/AddReward", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).AddReward(ctx, req.(*MsgAddReward)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_Stake_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgStake) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).Stake(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/titan.farming.Msg/Stake", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).Stake(ctx, req.(*MsgStake)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_Unstake_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUnstake) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).Unstake(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/titan.farming.Msg/Unstake", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).Unstake(ctx, req.(*MsgUnstake)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_Harvest_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgHarvest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).Harvest(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/titan.farming.Msg/Harvest", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).Harvest(ctx, req.(*MsgHarvest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Msg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "titan.farming.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "AddReward", + Handler: _Msg_AddReward_Handler, + }, + { + MethodName: "Stake", + Handler: _Msg_Stake_Handler, + }, + { + MethodName: "Unstake", + Handler: _Msg_Unstake_Handler, + }, + { + MethodName: "Harvest", + Handler: _Msg_Harvest_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "titan/farming/tx.proto", +} + +func (m *MsgAddReward) 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 *MsgAddReward) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgAddReward) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + n1, err1 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.StartTime, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.StartTime):]) + if err1 != nil { + return 0, err1 + } + i -= n1 + i = encodeVarintTx(dAtA, i, uint64(n1)) + i-- + dAtA[i] = 0x2a + n2, err2 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.EndTime, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.EndTime):]) + if err2 != nil { + return 0, err2 + } + i -= n2 + i = encodeVarintTx(dAtA, i, uint64(n2)) + i-- + dAtA[i] = 0x22 + if len(m.Amount) > 0 { + for iNdEx := len(m.Amount) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Amount[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + if len(m.Token) > 0 { + i -= len(m.Token) + copy(dAtA[i:], m.Token) + i = encodeVarintTx(dAtA, i, uint64(len(m.Token))) + i-- + dAtA[i] = 0x12 + } + if len(m.Sender) > 0 { + i -= len(m.Sender) + copy(dAtA[i:], m.Sender) + i = encodeVarintTx(dAtA, i, uint64(len(m.Sender))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgAddRewardResponse) 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 *MsgAddRewardResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgAddRewardResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgStake) 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 *MsgStake) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgStake) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Amount) > 0 { + for iNdEx := len(m.Amount) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Amount[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if len(m.Sender) > 0 { + i -= len(m.Sender) + copy(dAtA[i:], m.Sender) + i = encodeVarintTx(dAtA, i, uint64(len(m.Sender))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgStakeResponse) 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 *MsgStakeResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgStakeResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgUnstake) 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 *MsgUnstake) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUnstake) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Amount) > 0 { + for iNdEx := len(m.Amount) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Amount[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if len(m.Sender) > 0 { + i -= len(m.Sender) + copy(dAtA[i:], m.Sender) + i = encodeVarintTx(dAtA, i, uint64(len(m.Sender))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgUnstakeResponse) 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 *MsgUnstakeResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUnstakeResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgHarvest) 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 *MsgHarvest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgHarvest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Sender) > 0 { + i -= len(m.Sender) + copy(dAtA[i:], m.Sender) + i = encodeVarintTx(dAtA, i, uint64(len(m.Sender))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgHarvestResponse) 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 *MsgHarvestResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgHarvestResponse) 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 *MsgAddReward) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Token) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if len(m.Amount) > 0 { + for _, e := range m.Amount { + l = e.Size() + n += 1 + l + sovTx(uint64(l)) + } + } + l = github_com_cosmos_gogoproto_types.SizeOfStdTime(m.EndTime) + n += 1 + l + sovTx(uint64(l)) + l = github_com_cosmos_gogoproto_types.SizeOfStdTime(m.StartTime) + n += 1 + l + sovTx(uint64(l)) + return n +} + +func (m *MsgAddRewardResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgStake) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if len(m.Amount) > 0 { + for _, e := range m.Amount { + l = e.Size() + n += 1 + l + sovTx(uint64(l)) + } + } + return n +} + +func (m *MsgStakeResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgUnstake) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if len(m.Amount) > 0 { + for _, e := range m.Amount { + l = e.Size() + n += 1 + l + sovTx(uint64(l)) + } + } + return n +} + +func (m *MsgUnstakeResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgHarvest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgHarvestResponse) 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 *MsgAddReward) 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: MsgAddReward: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgAddReward: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Sender = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Token", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Token = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Amount = append(m.Amount, types.Coin{}) + if err := m.Amount[len(m.Amount)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EndTime", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_cosmos_gogoproto_types.StdTimeUnmarshal(&m.EndTime, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StartTime", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_cosmos_gogoproto_types.StdTimeUnmarshal(&m.StartTime, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgAddRewardResponse) 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: MsgAddRewardResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgAddRewardResponse: 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 *MsgStake) 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: MsgStake: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgStake: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Sender = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Amount = append(m.Amount, types.Coin{}) + if err := m.Amount[len(m.Amount)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgStakeResponse) 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: MsgStakeResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgStakeResponse: 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 *MsgUnstake) 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: MsgUnstake: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUnstake: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Sender = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Amount = append(m.Amount, types.Coin{}) + if err := m.Amount[len(m.Amount)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUnstakeResponse) 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: MsgUnstakeResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUnstakeResponse: 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 *MsgHarvest) 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: MsgHarvest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgHarvest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Sender = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgHarvestResponse) 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: MsgHarvestResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgHarvestResponse: 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/farming/types/types.go b/x/farming/types/types.go new file mode 100644 index 00000000..ab1254f4 --- /dev/null +++ b/x/farming/types/types.go @@ -0,0 +1 @@ +package types