feat(community): add switchover param (#1704)

* add community params type

* add get/set params methods

* add community genesis state type

* add community init/export genesis

* add querier methods for params

* add query cli cmd

* update changelog

* update protonet genesis

* Add `RewardsPerSecond` param to `x/community` module (#1707)

* Add RewardsPerSecond param to community

* Update rewards per second param to int

* Add rewards_per_second to protonet genesis

* Use default rewards per second of 744191

* Include value if negative in Validate error

* Rename RewardsPerSecond param to StakingRewardsPerSecond

* Add changelog entry

* Add param migration, update consensus version to 2

* Update proto docs

* Update staking_rewards_per_second param name in protonet genesis (#1730)

* Update godoc

Co-authored-by: Robert Pirtle <Astropirtle@gmail.com>

* add genesis state tests

* document what 0 upgrade time means

* update kvtool to include new params

---------

Co-authored-by: drklee3 <derrick@dlee.dev>
Co-authored-by: Robert Pirtle <Astropirtle@gmail.com>
This commit is contained in:
Ruaridh 2023-09-22 09:05:12 -07:00 committed by GitHub
parent 0598b99063
commit bc260d8091
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
30 changed files with 1893 additions and 54 deletions

View File

@ -39,10 +39,15 @@ Ref: https://keepachangelog.com/en/1.0.0/
### Features ### Features
- (metrics) [#1668] Adds non-state breaking x/metrics module for custom telemetry. - (metrics) [#1668] Adds non-state breaking x/metrics module for custom telemetry.
- (metrics) [#1669] Add performance timing metrics to all Begin/EndBlockers - (metrics) [#1669] Add performance timing metrics to all Begin/EndBlockers
- (community) [#1704] Add module params
### Bug Fixes ### Bug Fixes
- (evmutil) [#1655] Initialize x/evmutil module account in InitGenesis - (evmutil) [#1655] Initialize x/evmutil module account in InitGenesis
## State Machine Breaking
- (community) [#1704] Add param to control when inflation will be disabled
- (community) [#1707] Default staking rewards per second set to `744191`
## [v0.24.0] ## [v0.24.0]
### Features ### Features
@ -280,6 +285,7 @@ the [changelog](https://github.com/cosmos/cosmos-sdk/blob/v0.38.4/CHANGELOG.md).
- [#257](https://github.com/Kava-Labs/kava/pulls/257) Include scripts to run - [#257](https://github.com/Kava-Labs/kava/pulls/257) Include scripts to run
large-scale simulations remotely using aws-batch large-scale simulations remotely using aws-batch
[#1707]: https://github.com/Kava-Labs/kava/pull/1707
[#1668]: https://github.com/Kava-Labs/kava/pull/1668 [#1668]: https://github.com/Kava-Labs/kava/pull/1668
[#1669]: https://github.com/Kava-Labs/kava/pull/1669 [#1669]: https://github.com/Kava-Labs/kava/pull/1669
[#1655]: https://github.com/Kava-Labs/kava/pull/1655 [#1655]: https://github.com/Kava-Labs/kava/pull/1655

View File

@ -372,7 +372,7 @@ func NewApp(
evmtypes.StoreKey, feemarkettypes.StoreKey, authzkeeper.StoreKey, evmtypes.StoreKey, feemarkettypes.StoreKey, authzkeeper.StoreKey,
capabilitytypes.StoreKey, kavadisttypes.StoreKey, auctiontypes.StoreKey, capabilitytypes.StoreKey, kavadisttypes.StoreKey, auctiontypes.StoreKey,
issuancetypes.StoreKey, bep3types.StoreKey, pricefeedtypes.StoreKey, issuancetypes.StoreKey, bep3types.StoreKey, pricefeedtypes.StoreKey,
swaptypes.StoreKey, cdptypes.StoreKey, hardtypes.StoreKey, swaptypes.StoreKey, cdptypes.StoreKey, hardtypes.StoreKey, communitytypes.StoreKey,
committeetypes.StoreKey, incentivetypes.StoreKey, evmutiltypes.StoreKey, committeetypes.StoreKey, incentivetypes.StoreKey, evmutiltypes.StoreKey,
savingstypes.StoreKey, earntypes.StoreKey, minttypes.StoreKey, savingstypes.StoreKey, earntypes.StoreKey, minttypes.StoreKey,
) )
@ -637,6 +637,8 @@ func NewApp(
// x/community's deposit/withdraw to lend proposals depend on hard keeper. // x/community's deposit/withdraw to lend proposals depend on hard keeper.
app.communityKeeper = communitykeeper.NewKeeper( app.communityKeeper = communitykeeper.NewKeeper(
appCodec,
keys[communitytypes.StoreKey],
app.accountKeeper, app.accountKeeper,
app.bankKeeper, app.bankKeeper,
&cdpKeeper, &cdpKeeper,

View File

@ -1 +1 @@
a967d2fdda299ec8e1e3b99fb55bd06ecfdb0469 master

View File

@ -1315,7 +1315,10 @@
"votes": [] "votes": []
}, },
"community": { "community": {
"params": {} "params": {
"upgrade_time_disable_inflation": "2023-11-01T00:00:00Z",
"staking_rewards_per_second": "744191"
}
}, },
"crisis": { "crisis": {
"constant_fee": { "constant_fee": {

View File

@ -181,6 +181,12 @@
- [Msg](#kava.committee.v1beta1.Msg) - [Msg](#kava.committee.v1beta1.Msg)
- [kava/community/v1beta1/params.proto](#kava/community/v1beta1/params.proto)
- [Params](#kava.community.v1beta1.Params)
- [kava/community/v1beta1/genesis.proto](#kava/community/v1beta1/genesis.proto)
- [GenesisState](#kava.community.v1beta1.GenesisState)
- [kava/community/v1beta1/proposal.proto](#kava/community/v1beta1/proposal.proto) - [kava/community/v1beta1/proposal.proto](#kava/community/v1beta1/proposal.proto)
- [CommunityCDPRepayDebtProposal](#kava.community.v1beta1.CommunityCDPRepayDebtProposal) - [CommunityCDPRepayDebtProposal](#kava.community.v1beta1.CommunityCDPRepayDebtProposal)
- [CommunityCDPWithdrawCollateralProposal](#kava.community.v1beta1.CommunityCDPWithdrawCollateralProposal) - [CommunityCDPWithdrawCollateralProposal](#kava.community.v1beta1.CommunityCDPWithdrawCollateralProposal)
@ -190,6 +196,8 @@
- [kava/community/v1beta1/query.proto](#kava/community/v1beta1/query.proto) - [kava/community/v1beta1/query.proto](#kava/community/v1beta1/query.proto)
- [QueryBalanceRequest](#kava.community.v1beta1.QueryBalanceRequest) - [QueryBalanceRequest](#kava.community.v1beta1.QueryBalanceRequest)
- [QueryBalanceResponse](#kava.community.v1beta1.QueryBalanceResponse) - [QueryBalanceResponse](#kava.community.v1beta1.QueryBalanceResponse)
- [QueryParamsRequest](#kava.community.v1beta1.QueryParamsRequest)
- [QueryParamsResponse](#kava.community.v1beta1.QueryParamsResponse)
- [QueryTotalBalanceRequest](#kava.community.v1beta1.QueryTotalBalanceRequest) - [QueryTotalBalanceRequest](#kava.community.v1beta1.QueryTotalBalanceRequest)
- [QueryTotalBalanceResponse](#kava.community.v1beta1.QueryTotalBalanceResponse) - [QueryTotalBalanceResponse](#kava.community.v1beta1.QueryTotalBalanceResponse)
@ -2882,6 +2890,69 @@ Msg defines the committee Msg service
<a name="kava/community/v1beta1/params.proto"></a>
<p align="right"><a href="#top">Top</a></p>
## kava/community/v1beta1/params.proto
<a name="kava.community.v1beta1.Params"></a>
### Params
Params defines the parameters of the community module.
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `upgrade_time_disable_inflation` | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | upgrade_time_disable_inflation is the time at which to disable mint and kavadist module inflation. If set to 0, inflation will be disabled from block 1. |
| `staking_rewards_per_second` | [string](#string) | | staking_rewards_per_second is the amount paid out to delegators each block from the community account |
<!-- end messages -->
<!-- end enums -->
<!-- end HasExtensions -->
<!-- end services -->
<a name="kava/community/v1beta1/genesis.proto"></a>
<p align="right"><a href="#top">Top</a></p>
## kava/community/v1beta1/genesis.proto
<a name="kava.community.v1beta1.GenesisState"></a>
### GenesisState
GenesisState defines the community module's genesis state.
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `params` | [Params](#kava.community.v1beta1.Params) | | params defines all the paramaters related to commmunity |
<!-- end messages -->
<!-- end enums -->
<!-- end HasExtensions -->
<!-- end services -->
<a name="kava/community/v1beta1/proposal.proto"></a> <a name="kava/community/v1beta1/proposal.proto"></a>
<p align="right"><a href="#top">Top</a></p> <p align="right"><a href="#top">Top</a></p>
@ -3002,6 +3073,31 @@ QueryBalanceResponse defines the response type for querying x/community balance.
<a name="kava.community.v1beta1.QueryParamsRequest"></a>
### QueryParamsRequest
QueryParams defines the request type for querying x/community params.
<a name="kava.community.v1beta1.QueryParamsResponse"></a>
### QueryParamsResponse
QueryParamsResponse defines the response type for querying x/community params.
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `params` | [Params](#kava.community.v1beta1.Params) | | params represents the community module parameters |
<a name="kava.community.v1beta1.QueryTotalBalanceRequest"></a> <a name="kava.community.v1beta1.QueryTotalBalanceRequest"></a>
### QueryTotalBalanceRequest ### QueryTotalBalanceRequest
@ -3041,6 +3137,7 @@ Query defines the gRPC querier service for x/community.
| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | | Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint |
| ----------- | ------------ | ------------- | ------------| ------- | -------- | | ----------- | ------------ | ------------- | ------------| ------- | -------- |
| `Params` | [QueryParamsRequest](#kava.community.v1beta1.QueryParamsRequest) | [QueryParamsResponse](#kava.community.v1beta1.QueryParamsResponse) | Params queires the module params. | GET|/kava/community/v1beta1/params|
| `Balance` | [QueryBalanceRequest](#kava.community.v1beta1.QueryBalanceRequest) | [QueryBalanceResponse](#kava.community.v1beta1.QueryBalanceResponse) | Balance queries the balance of all coins of x/community module. | GET|/kava/community/v1beta1/balance| | `Balance` | [QueryBalanceRequest](#kava.community.v1beta1.QueryBalanceRequest) | [QueryBalanceResponse](#kava.community.v1beta1.QueryBalanceResponse) | Balance queries the balance of all coins of x/community module. | GET|/kava/community/v1beta1/balance|
| `TotalBalance` | [QueryTotalBalanceRequest](#kava.community.v1beta1.QueryTotalBalanceRequest) | [QueryTotalBalanceResponse](#kava.community.v1beta1.QueryTotalBalanceResponse) | TotalBalance queries the balance of all coins, including x/distribution, x/community, and supplied balances. | GET|/kava/community/v1beta1/total_balance| | `TotalBalance` | [QueryTotalBalanceRequest](#kava.community.v1beta1.QueryTotalBalanceRequest) | [QueryTotalBalanceResponse](#kava.community.v1beta1.QueryTotalBalanceResponse) | TotalBalance queries the balance of all coins, including x/distribution, x/community, and supplied balances. | GET|/kava/community/v1beta1/total_balance|

View File

@ -0,0 +1,13 @@
syntax = "proto3";
package kava.community.v1beta1;
import "gogoproto/gogo.proto";
import "kava/community/v1beta1/params.proto";
option go_package = "github.com/kava-labs/kava/x/community/types";
// GenesisState defines the community module's genesis state.
message GenesisState {
// params defines all the paramaters related to commmunity
Params params = 1 [(gogoproto.nullable) = false];
}

View File

@ -0,0 +1,25 @@
syntax = "proto3";
package kava.community.v1beta1;
import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
import "google/protobuf/timestamp.proto";
option go_package = "github.com/kava-labs/kava/x/community/types";
// Params defines the parameters of the community module.
message Params {
// upgrade_time_disable_inflation is the time at which to disable mint and kavadist module inflation.
// If set to 0, inflation will be disabled from block 1.
google.protobuf.Timestamp upgrade_time_disable_inflation = 1 [
(gogoproto.stdtime) = true,
(gogoproto.nullable) = false
];
// staking_rewards_per_second is the amount paid out to delegators each block from the community account
string staking_rewards_per_second = 2 [
(cosmos_proto.scalar) = "cosmos.Int",
(gogoproto.customtype) = "cosmossdk.io/math.Int",
(gogoproto.nullable) = false
];
}

View File

@ -4,11 +4,17 @@ package kava.community.v1beta1;
import "cosmos/base/v1beta1/coin.proto"; import "cosmos/base/v1beta1/coin.proto";
import "gogoproto/gogo.proto"; import "gogoproto/gogo.proto";
import "google/api/annotations.proto"; import "google/api/annotations.proto";
import "kava/community/v1beta1/params.proto";
option go_package = "github.com/kava-labs/kava/x/community/types"; option go_package = "github.com/kava-labs/kava/x/community/types";
// Query defines the gRPC querier service for x/community. // Query defines the gRPC querier service for x/community.
service Query { service Query {
// Params queires the module params.
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
option (google.api.http).get = "/kava/community/v1beta1/params";
}
// Balance queries the balance of all coins of x/community module. // Balance queries the balance of all coins of x/community module.
rpc Balance(QueryBalanceRequest) returns (QueryBalanceResponse) { rpc Balance(QueryBalanceRequest) returns (QueryBalanceResponse) {
option (google.api.http).get = "/kava/community/v1beta1/balance"; option (google.api.http).get = "/kava/community/v1beta1/balance";
@ -21,6 +27,15 @@ service Query {
} }
} }
// QueryParams defines the request type for querying x/community params.
message QueryParamsRequest {}
// QueryParamsResponse defines the response type for querying x/community params.
message QueryParamsResponse {
// params represents the community module parameters
Params params = 1 [(gogoproto.nullable) = false];
}
// QueryBalanceRequest defines the request type for querying x/community balance. // QueryBalanceRequest defines the request type for querying x/community balance.
message QueryBalanceRequest {} message QueryBalanceRequest {}

@ -1 +1 @@
Subproject commit b093fc9f2a28cf57b4a6924f45919edcfe551eaf Subproject commit 434f7d12322e4713429fe2cc73027938e11eb5a0

View File

@ -1,10 +1,13 @@
package cli package cli
import ( import (
"context"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/flags"
"github.com/kava-labs/kava/x/community/types" "github.com/kava-labs/kava/x/community/types"
) )
@ -19,7 +22,8 @@ func GetQueryCmd() *cobra.Command {
} }
commands := []*cobra.Command{ commands := []*cobra.Command{
GetCmdQueryBalance(), getCmdQueryParams(),
getCmdQueryBalance(),
} }
for _, cmd := range commands { for _, cmd := range commands {
@ -31,8 +35,32 @@ func GetQueryCmd() *cobra.Command {
return communityQueryCmd return communityQueryCmd
} }
// GetCmdQueryBalance implements a command to return the current community pool balance. func getCmdQueryParams() *cobra.Command {
func GetCmdQueryBalance() *cobra.Command { return &cobra.Command{
Use: "params",
Short: "get the community module parameters",
Long: "Get the current community module parameters.",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}
queryClient := types.NewQueryClient(clientCtx)
res, err := queryClient.Params(context.Background(), &types.QueryParamsRequest{})
if err != nil {
return err
}
return clientCtx.PrintProto(&res.Params)
},
}
}
// getCmdQueryBalance implements a command to return the current community pool balance.
func getCmdQueryBalance() *cobra.Command {
return &cobra.Command{ return &cobra.Command{
Use: "balance", Use: "balance",
Short: "Query the current balance of the community module account", Short: "Query the current balance of the community module account",

View File

@ -10,10 +10,22 @@ import (
"github.com/kava-labs/kava/x/community/types" "github.com/kava-labs/kava/x/community/types"
) )
// InitGenesis initializes the community module account // InitGenesis initializes the community module account and stores the genesis state
func InitGenesis(ctx sdk.Context, k keeper.Keeper, ak types.AccountKeeper) { func InitGenesis(ctx sdk.Context, k keeper.Keeper, ak types.AccountKeeper, gs types.GenesisState) {
// check if the module account exists // check if the module account exists
if moduleAcc := ak.GetModuleAccount(ctx, types.ModuleAccountName); moduleAcc == nil { if moduleAcc := ak.GetModuleAccount(ctx, types.ModuleAccountName); moduleAcc == nil {
panic(fmt.Sprintf("%s module account has not been set", types.ModuleAccountName)) panic(fmt.Sprintf("%s module account has not been set", types.ModuleAccountName))
} }
k.SetParams(ctx, gs.Params)
}
// ExportGenesis exports the store to a genesis state
func ExportGenesis(ctx sdk.Context, k keeper.Keeper) types.GenesisState {
params, found := k.GetParams(ctx)
if !found {
params = types.Params{}
}
return types.NewGenesisState(params)
} }

View File

@ -2,12 +2,16 @@ package community_test
import ( import (
"testing" "testing"
"time"
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
sdkmath "cosmossdk.io/math"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/kava-labs/kava/x/community" "github.com/kava-labs/kava/x/community"
"github.com/kava-labs/kava/x/community/testutil" "github.com/kava-labs/kava/x/community/testutil"
"github.com/kava-labs/kava/x/community/types"
) )
type genesisTestSuite struct { type genesisTestSuite struct {
@ -23,12 +27,18 @@ func TestGenesisTestSuite(t *testing.T) {
} }
func (suite *genesisTestSuite) TestInitGenesis() { func (suite *genesisTestSuite) TestInitGenesis() {
suite.SetupTest()
accountKeeper := suite.App.GetAccountKeeper() accountKeeper := suite.App.GetAccountKeeper()
genesisState := types.NewGenesisState(
types.NewParams(
time.Date(1998, 1, 1, 0, 0, 0, 0, time.UTC),
sdkmath.NewInt(1000),
),
)
suite.NotPanics(func() { suite.NotPanics(func() {
community.InitGenesis(suite.Ctx, suite.Keeper, accountKeeper) community.InitGenesis(suite.Ctx, suite.Keeper, accountKeeper, genesisState)
}) })
// check for module account this way b/c GetModuleAccount creates if not existing. // check for module account this way b/c GetModuleAccount creates if not existing.
@ -36,4 +46,34 @@ func (suite *genesisTestSuite) TestInitGenesis() {
suite.NotNil(acc) suite.NotNil(acc)
_, ok := acc.(authtypes.ModuleAccountI) _, ok := acc.(authtypes.ModuleAccountI)
suite.True(ok) suite.True(ok)
storedParams, found := suite.App.GetCommunityKeeper().GetParams(suite.Ctx)
suite.True(found)
suite.Equal(genesisState.Params, storedParams)
}
func (suite *genesisTestSuite) TestExportGenesis() {
params := types.NewParams(
time.Date(1998, 1, 1, 0, 0, 0, 0, time.UTC),
sdkmath.NewInt(1000),
)
suite.Keeper.SetParams(suite.Ctx, params)
genesisState := community.ExportGenesis(suite.Ctx, suite.Keeper)
suite.Equal(params, genesisState.Params)
}
func (suite *genesisTestSuite) TestInitExportIsLossless() {
genesisState := types.NewGenesisState(
types.NewParams(
time.Date(1998, 1, 1, 0, 0, 0, 0, time.UTC),
sdkmath.NewInt(1000),
),
)
community.InitGenesis(suite.Ctx, suite.Keeper, suite.App.GetAccountKeeper(), genesisState)
exportedState := community.ExportGenesis(suite.Ctx, suite.Keeper)
suite.Equal(genesisState, exportedState)
} }

View File

@ -4,6 +4,9 @@ import (
"context" "context"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"github.com/kava-labs/kava/x/community/types" "github.com/kava-labs/kava/x/community/types"
) )
@ -18,6 +21,20 @@ func NewQueryServerImpl(k Keeper) types.QueryServer {
return &queryServer{keeper: k} return &queryServer{keeper: k}
} }
// Params implements the gRPC service handler for querying x/community params.
func (s queryServer) Params(c context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) {
ctx := sdk.UnwrapSDKContext(c)
params, found := s.keeper.GetParams(ctx)
if !found {
return nil, status.Error(codes.NotFound, "params not found")
}
return &types.QueryParamsResponse{
Params: params,
}, nil
}
// Balance implements the gRPC service handler for querying x/community balance. // Balance implements the gRPC service handler for querying x/community balance.
func (s queryServer) Balance(c context.Context, _ *types.QueryBalanceRequest) (*types.QueryBalanceResponse, error) { func (s queryServer) Balance(c context.Context, _ *types.QueryBalanceRequest) (*types.QueryBalanceResponse, error) {
ctx := sdk.UnwrapSDKContext(c) ctx := sdk.UnwrapSDKContext(c)

View File

@ -3,6 +3,7 @@ package keeper_test
import ( import (
"context" "context"
"testing" "testing"
"time"
sdkmath "cosmossdk.io/math" sdkmath "cosmossdk.io/math"
"github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/baseapp"
@ -32,6 +33,23 @@ func TestGrpcQueryTestSuite(t *testing.T) {
suite.Run(t, new(grpcQueryTestSuite)) suite.Run(t, new(grpcQueryTestSuite))
} }
func (suite *grpcQueryTestSuite) TestGrpcQueryParams() {
p := types.NewParams(
time.Date(1998, 1, 1, 0, 0, 0, 0, time.UTC),
sdkmath.NewInt(1000),
)
suite.Keeper.SetParams(suite.Ctx, p)
res, err := suite.queryClient.Params(context.Background(), &types.QueryParamsRequest{})
suite.Require().NoError(err)
suite.Equal(
types.QueryParamsResponse{
Params: p,
},
*res,
)
}
func (suite *grpcQueryTestSuite) TestGrpcQueryBalance() { func (suite *grpcQueryTestSuite) TestGrpcQueryBalance() {
var expCoins sdk.Coins var expCoins sdk.Coins

View File

@ -3,14 +3,19 @@ package keeper
import ( import (
"fmt" "fmt"
"github.com/cosmos/cosmos-sdk/codec"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/tendermint/tendermint/libs/log" "github.com/tendermint/tendermint/libs/log"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/kava-labs/kava/x/community/types" "github.com/kava-labs/kava/x/community/types"
) )
// Keeper of the community store // Keeper of the community store
type Keeper struct { type Keeper struct {
key storetypes.StoreKey
cdc codec.Codec
bankKeeper types.BankKeeper bankKeeper types.BankKeeper
cdpKeeper types.CdpKeeper cdpKeeper types.CdpKeeper
distrKeeper types.DistributionKeeper distrKeeper types.DistributionKeeper
@ -21,7 +26,15 @@ type Keeper struct {
} }
// NewKeeper creates a new community Keeper instance // NewKeeper creates a new community Keeper instance
func NewKeeper(ak types.AccountKeeper, bk types.BankKeeper, ck types.CdpKeeper, dk types.DistributionKeeper, hk types.HardKeeper) Keeper { func NewKeeper(
cdc codec.Codec,
key storetypes.StoreKey,
ak types.AccountKeeper,
bk types.BankKeeper,
ck types.CdpKeeper,
dk types.DistributionKeeper,
hk types.HardKeeper,
) Keeper {
// ensure community module account is set // ensure community module account is set
addr := ak.GetModuleAddress(types.ModuleAccountName) addr := ak.GetModuleAddress(types.ModuleAccountName)
if addr == nil { if addr == nil {
@ -33,6 +46,9 @@ func NewKeeper(ak types.AccountKeeper, bk types.BankKeeper, ck types.CdpKeeper,
} }
return Keeper{ return Keeper{
key: key,
cdc: cdc,
bankKeeper: bk, bankKeeper: bk,
cdpKeeper: ck, cdpKeeper: ck,
distrKeeper: dk, distrKeeper: dk,

View File

@ -0,0 +1,27 @@
package keeper
import (
sdk "github.com/cosmos/cosmos-sdk/types"
v2 "github.com/kava-labs/kava/x/community/migrations/v2"
)
// Migrator is a struct for handling in-place store migrations.
type Migrator struct {
keeper Keeper
}
// NewMigrator returns a new Migrator.
func NewMigrator(keeper Keeper) Migrator {
return Migrator{
keeper: keeper,
}
}
// Migrate1to2 migrates from version 1 to 2.
func (m Migrator) Migrate1to2(ctx sdk.Context) error {
return v2.Migrate(
ctx,
ctx.KVStore(m.keeper.key),
m.keeper.cdc,
)
}

View File

@ -0,0 +1,36 @@
package keeper
import (
"fmt"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/kava-labs/kava/x/community/types"
)
// GetParams returns the params from the store
func (k Keeper) GetParams(ctx sdk.Context) (types.Params, bool) {
store := ctx.KVStore(k.key)
bz := store.Get(types.ParamsKey)
if bz == nil {
return types.Params{}, false
}
params := types.Params{}
k.cdc.MustUnmarshal(bz, &params)
return params, true
}
// SetParams sets params on the store
func (k Keeper) SetParams(ctx sdk.Context, params types.Params) {
if err := params.Validate(); err != nil {
panic(fmt.Sprintf("invalid params: %s", err))
}
store := ctx.KVStore(k.key)
bz := k.cdc.MustMarshal(&params)
store.Set(types.ParamsKey, bz)
}

View File

@ -0,0 +1,74 @@
package keeper_test
import (
"testing"
"time"
sdkmath "cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/stretchr/testify/suite"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
tmtime "github.com/tendermint/tendermint/types/time"
"github.com/kava-labs/kava/app"
"github.com/kava-labs/kava/x/community/keeper"
"github.com/kava-labs/kava/x/community/types"
)
// Test suite used for all store tests
type StoreTestSuite struct {
suite.Suite
App app.TestApp
Ctx sdk.Context
Keeper keeper.Keeper
}
// The default state used by each test
func (suite *StoreTestSuite) SetupTest() {
app.SetSDKConfig()
suite.App = app.NewTestApp()
suite.Ctx = suite.App.NewContext(true, tmproto.Header{Height: 1, Time: tmtime.Now()})
suite.Keeper = suite.App.GetCommunityKeeper()
}
func TestStoreTestSuite(t *testing.T) {
suite.Run(t, new(StoreTestSuite))
}
func (suite *StoreTestSuite) TestGetSetParams() {
suite.Run("get params returns not found on empty store", func() {
_, found := suite.Keeper.GetParams(suite.Ctx)
suite.Require().False(found)
})
suite.Run("set params cannot store invalid params", func() {
invalid := types.Params{UpgradeTimeDisableInflation: time.Date(-1, 1, 1, 0, 0, 0, 0, time.UTC)}
suite.Panics(func() {
suite.Keeper.SetParams(suite.Ctx, invalid)
})
})
suite.Run("get params returns stored params", func() {
suite.Keeper.SetParams(suite.Ctx, types.DefaultParams())
storedParams, found := suite.Keeper.GetParams(suite.Ctx)
suite.True(found)
suite.Equal(types.DefaultParams(), storedParams)
})
suite.Run("set overwrite previous value", func() {
suite.Keeper.SetParams(suite.Ctx, types.DefaultParams())
params := types.NewParams(
time.Date(1998, 1, 1, 0, 0, 0, 0, time.UTC),
sdkmath.NewInt(1000),
)
suite.Keeper.SetParams(suite.Ctx, params)
storedParams, found := suite.Keeper.GetParams(suite.Ctx)
suite.True(found)
suite.NotEqual(params, types.DefaultParams())
suite.Equal(params, storedParams)
})
}

View File

@ -0,0 +1,38 @@
package v2
import (
"time"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/kava-labs/kava/x/community/types"
)
const (
ModuleName = "mint"
)
// Migrate migrates the x/community module state from the consensus version 1 to
// version 2. Specifically, sets new parameters in the module state.
func Migrate(
ctx sdk.Context,
store storetypes.KVStore,
cdc codec.BinaryCodec,
) error {
params := types.NewParams(
// 2023-11-01T00:00:00Z
time.Date(2023, 11, 1, 0, 0, 0, 0, time.UTC),
sdk.NewInt(744191),
)
if err := params.Validate(); err != nil {
return err
}
bz := cdc.MustMarshal(&params)
store.Set(types.ParamsKey, bz)
return nil
}

View File

@ -0,0 +1,48 @@
package v2_test
import (
"testing"
"time"
"github.com/stretchr/testify/require"
"github.com/cosmos/cosmos-sdk/testutil"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/kava-labs/kava/app"
v2 "github.com/kava-labs/kava/x/community/migrations/v2"
"github.com/kava-labs/kava/x/community/types"
)
func TestMigrateStore(t *testing.T) {
tApp := app.NewTestApp()
cdc := tApp.AppCodec()
storeKey := sdk.NewKVStoreKey("community")
ctx := testutil.DefaultContext(storeKey, sdk.NewTransientStoreKey("transient_test"))
store := ctx.KVStore(storeKey)
require.Nil(
t,
store.Get(types.ParamsKey),
"params shouldn't exist in store before migration",
)
require.NoError(t, v2.Migrate(ctx, store, cdc))
paramsBytes := store.Get(types.ParamsKey)
require.NotNil(t, paramsBytes, "params should be in store after migration")
var params types.Params
cdc.MustUnmarshal(paramsBytes, &params)
t.Logf("params: %+v", params)
require.Equal(
t,
types.NewParams(
time.Date(2023, 11, 1, 0, 0, 0, 0, time.UTC),
sdk.NewInt(744191),
),
params,
"params should be correct after migration",
)
}

View File

@ -3,6 +3,7 @@ package community
import ( import (
"context" "context"
"encoding/json" "encoding/json"
"fmt"
"github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/spf13/cobra" "github.com/spf13/cobra"
@ -20,6 +21,9 @@ import (
"github.com/kava-labs/kava/x/community/types" "github.com/kava-labs/kava/x/community/types"
) )
// ConsensusVersion defines the current module consensus version.
const ConsensusVersion = 2
var ( var (
_ module.AppModule = AppModule{} _ module.AppModule = AppModule{}
_ module.AppModuleBasic = AppModuleBasic{} _ module.AppModuleBasic = AppModuleBasic{}
@ -40,13 +44,19 @@ func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
} }
// DefaultGenesis default genesis state // DefaultGenesis default genesis state
func (AppModuleBasic) DefaultGenesis(_ codec.JSONCodec) json.RawMessage { func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage {
return []byte("{}") gs := types.DefaultGenesisState()
return cdc.MustMarshalJSON(&gs)
} }
// ValidateGenesis module validate genesis // ValidateGenesis module validate genesis
func (AppModuleBasic) ValidateGenesis(_ codec.JSONCodec, _ client.TxEncodingConfig, _ json.RawMessage) error { func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, bz json.RawMessage) error {
return nil var gs types.GenesisState
err := cdc.UnmarshalJSON(bz, &gs)
if err != nil {
return err
}
return gs.Validate()
} }
// RegisterInterfaces implements InterfaceModule.RegisterInterfaces // RegisterInterfaces implements InterfaceModule.RegisterInterfaces
@ -113,23 +123,32 @@ func (am AppModule) LegacyQuerierHandler(_ *codec.LegacyAmino) sdk.Querier {
} }
// ConsensusVersion implements AppModule/ConsensusVersion. // ConsensusVersion implements AppModule/ConsensusVersion.
func (AppModule) ConsensusVersion() uint64 { return 1 } func (AppModule) ConsensusVersion() uint64 { return ConsensusVersion }
// RegisterServices registers module services. // RegisterServices registers module services.
func (am AppModule) RegisterServices(cfg module.Configurator) { func (am AppModule) RegisterServices(cfg module.Configurator) {
types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper))
types.RegisterQueryServer(cfg.QueryServer(), keeper.NewQueryServerImpl(am.keeper)) types.RegisterQueryServer(cfg.QueryServer(), keeper.NewQueryServerImpl(am.keeper))
m := keeper.NewMigrator(am.keeper)
if err := cfg.RegisterMigration(types.ModuleName, 1, m.Migrate1to2); err != nil {
panic(fmt.Sprintf("failed to migrate x/community from version 1 to 2: %v", err))
}
} }
// InitGenesis module init-genesis // InitGenesis module init-genesis
func (am AppModule) InitGenesis(ctx sdk.Context, _ codec.JSONCodec, _ json.RawMessage) []abci.ValidatorUpdate { func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, gs json.RawMessage) []abci.ValidatorUpdate {
InitGenesis(ctx, am.keeper, am.accountKeeper) var genState types.GenesisState
cdc.MustUnmarshalJSON(gs, &genState)
InitGenesis(ctx, am.keeper, am.accountKeeper, genState)
return []abci.ValidatorUpdate{} return []abci.ValidatorUpdate{}
} }
// ExportGenesis module export genesis // ExportGenesis module export genesis
func (am AppModule) ExportGenesis(_ sdk.Context, cdc codec.JSONCodec) json.RawMessage { func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage {
return am.DefaultGenesis(cdc) gs := ExportGenesis(ctx, am.keeper)
return cdc.MustMarshalJSON(&gs)
} }
// BeginBlock module begin-block // BeginBlock module begin-block

View File

@ -0,0 +1,20 @@
package types
// NewGenesisState returns a new genesis state object
func NewGenesisState(params Params) GenesisState {
return GenesisState{
Params: params,
}
}
// DefaultGenesisState returns default genesis state
func DefaultGenesisState() GenesisState {
return NewGenesisState(
DefaultParams(),
)
}
// Validate checks the params are valid
func (gs GenesisState) Validate() error {
return gs.Params.Validate()
}

View File

@ -0,0 +1,324 @@
// Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: kava/community/v1beta1/genesis.proto
package types
import (
fmt "fmt"
_ "github.com/gogo/protobuf/gogoproto"
proto "github.com/gogo/protobuf/proto"
io "io"
math "math"
math_bits "math/bits"
)
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
// GenesisState defines the community module's genesis state.
type GenesisState struct {
// params defines all the paramaters related to commmunity
Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"`
}
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_ccf84d82ea3861e0, []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 init() {
proto.RegisterType((*GenesisState)(nil), "kava.community.v1beta1.GenesisState")
}
func init() {
proto.RegisterFile("kava/community/v1beta1/genesis.proto", fileDescriptor_ccf84d82ea3861e0)
}
var fileDescriptor_ccf84d82ea3861e0 = []byte{
// 201 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0xc9, 0x4e, 0x2c, 0x4b,
0xd4, 0x4f, 0xce, 0xcf, 0xcd, 0x2d, 0xcd, 0xcb, 0x2c, 0xa9, 0xd4, 0x2f, 0x33, 0x4c, 0x4a, 0x2d,
0x49, 0x34, 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9,
0x17, 0x12, 0x03, 0xa9, 0xd2, 0x83, 0xab, 0xd2, 0x83, 0xaa, 0x92, 0x12, 0x49, 0xcf, 0x4f, 0xcf,
0x07, 0x2b, 0xd1, 0x07, 0xb1, 0x20, 0xaa, 0xa5, 0x94, 0x71, 0x98, 0x59, 0x90, 0x58, 0x94, 0x98,
0x0b, 0x35, 0x52, 0xc9, 0x87, 0x8b, 0xc7, 0x1d, 0x62, 0x47, 0x70, 0x49, 0x62, 0x49, 0xaa, 0x90,
0x0d, 0x17, 0x1b, 0x44, 0x5e, 0x82, 0x51, 0x81, 0x51, 0x83, 0xdb, 0x48, 0x4e, 0x0f, 0xbb, 0x9d,
0x7a, 0x01, 0x60, 0x55, 0x4e, 0x2c, 0x27, 0xee, 0xc9, 0x33, 0x04, 0x41, 0xf5, 0x38, 0xb9, 0x9e,
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, 0x76, 0x7a, 0x66, 0x49, 0x46, 0x69,
0x12, 0xc8, 0x20, 0x7d, 0x90, 0x89, 0xba, 0x39, 0x89, 0x49, 0xc5, 0x60, 0x96, 0x7e, 0x05, 0x92,
0x1b, 0x4b, 0x2a, 0x0b, 0x52, 0x8b, 0x93, 0xd8, 0xc0, 0x6e, 0x33, 0x06, 0x04, 0x00, 0x00, 0xff,
0xff, 0xb3, 0x0f, 0x84, 0xbd, 0x16, 0x01, 0x00, 0x00,
}
func (m *GenesisState) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalToSizedBuffer(dAtA[:size])
if err != nil {
return nil, err
}
return dAtA[:n], nil
}
func (m *GenesisState) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
{
size, err := m.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))
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
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")
)

View File

@ -0,0 +1,61 @@
package types_test
import (
"testing"
"time"
"github.com/stretchr/testify/require"
sdkmath "cosmossdk.io/math"
"github.com/kava-labs/kava/x/community/types"
)
func TestDefaultGenesisState(t *testing.T) {
defaultGen := types.DefaultGenesisState()
require.NoError(t, defaultGen.Validate())
require.Equal(t, types.DefaultParams(), defaultGen.Params)
}
func TestGenesisState_Validate(t *testing.T) {
testCases := []struct {
name string
genesis types.GenesisState
expectedErr string
}{
{
name: "valid state",
genesis: types.GenesisState{
Params: types.Params{
UpgradeTimeDisableInflation: time.Time{},
StakingRewardsPerSecond: sdkmath.NewInt(1000),
},
},
expectedErr: "",
},
{
name: "invalid params",
genesis: types.GenesisState{
Params: types.Params{
UpgradeTimeDisableInflation: time.Time{},
StakingRewardsPerSecond: sdkmath.Int{},
},
},
expectedErr: "StakingRewardsPerSecond should not be nil",
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
err := tc.genesis.Validate()
if tc.expectedErr == "" {
require.NoError(t, err)
} else {
require.Error(t, err)
require.Contains(t, err.Error(), tc.expectedErr)
}
})
}
}

View File

@ -7,6 +7,9 @@ const (
// ModuleAccountName is the name of the module's account // ModuleAccountName is the name of the module's account
ModuleAccountName = ModuleName ModuleAccountName = ModuleName
// StoreKey Top level store key where all module items will be stored
StoreKey = ModuleName
// RouterKey is the top-level router key for the module // RouterKey is the top-level router key for the module
RouterKey = ModuleName RouterKey = ModuleName
@ -17,3 +20,8 @@ const (
// It is used to determine the address of the old community pool to be returned with the legacy balance. // It is used to determine the address of the old community pool to be returned with the legacy balance.
LegacyCommunityPoolModuleName = "distribution" LegacyCommunityPoolModuleName = "distribution"
) )
// key prefixes for store
var (
ParamsKey = []byte{0x01}
)

View File

@ -0,0 +1,49 @@
package types
import (
"errors"
fmt "fmt"
"time"
sdkmath "cosmossdk.io/math"
)
var (
DefaultUpgradeTimeDisableInflation = time.Time{}
// DefaultStakingRewardsPerSecond is ~4.6 KAVA per block, 6.3s block time
DefaultStakingRewardsPerSecond = sdkmath.NewInt(744191)
)
// NewParams returns a new params object
func NewParams(
upgradeTime time.Time,
stakingRewardsPerSecond sdkmath.Int,
) Params {
return Params{
UpgradeTimeDisableInflation: upgradeTime,
StakingRewardsPerSecond: stakingRewardsPerSecond,
}
}
// DefaultParams returns default params
func DefaultParams() Params {
return NewParams(
DefaultUpgradeTimeDisableInflation,
DefaultStakingRewardsPerSecond,
)
}
// Validate checks the params are valid
func (p Params) Validate() error {
// p.UpgradeTimeDisableInflation.IsZero() is a valid state. It's taken to mean inflation will be disabled on the block 1.
if p.StakingRewardsPerSecond.IsNil() {
return errors.New("StakingRewardsPerSecond should not be nil")
}
if p.StakingRewardsPerSecond.IsNegative() {
return fmt.Errorf("StakingRewardsPerSecond should not be negative: %s", p.StakingRewardsPerSecond)
}
return nil
}

View File

@ -0,0 +1,385 @@
// Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: kava/community/v1beta1/params.proto
package types
import (
cosmossdk_io_math "cosmossdk.io/math"
fmt "fmt"
_ "github.com/cosmos/cosmos-proto"
_ "github.com/gogo/protobuf/gogoproto"
proto "github.com/gogo/protobuf/proto"
github_com_gogo_protobuf_types "github.com/gogo/protobuf/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
// Params defines the parameters of the community module.
type Params struct {
// upgrade_time_disable_inflation is the time at which to disable mint and kavadist module inflation.
// If set to 0, inflation will be disabled from block 1.
UpgradeTimeDisableInflation time.Time `protobuf:"bytes,1,opt,name=upgrade_time_disable_inflation,json=upgradeTimeDisableInflation,proto3,stdtime" json:"upgrade_time_disable_inflation"`
// staking_rewards_per_second is the amount paid out to delegators each block from the community account
StakingRewardsPerSecond cosmossdk_io_math.Int `protobuf:"bytes,2,opt,name=staking_rewards_per_second,json=stakingRewardsPerSecond,proto3,customtype=cosmossdk.io/math.Int" json:"staking_rewards_per_second"`
}
func (m *Params) Reset() { *m = Params{} }
func (m *Params) String() string { return proto.CompactTextString(m) }
func (*Params) ProtoMessage() {}
func (*Params) Descriptor() ([]byte, []int) {
return fileDescriptor_0a48475520900507, []int{0}
}
func (m *Params) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_Params.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalToSizedBuffer(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (m *Params) XXX_Merge(src proto.Message) {
xxx_messageInfo_Params.Merge(m, src)
}
func (m *Params) XXX_Size() int {
return m.Size()
}
func (m *Params) XXX_DiscardUnknown() {
xxx_messageInfo_Params.DiscardUnknown(m)
}
var xxx_messageInfo_Params proto.InternalMessageInfo
func (m *Params) GetUpgradeTimeDisableInflation() time.Time {
if m != nil {
return m.UpgradeTimeDisableInflation
}
return time.Time{}
}
func init() {
proto.RegisterType((*Params)(nil), "kava.community.v1beta1.Params")
}
func init() {
proto.RegisterFile("kava/community/v1beta1/params.proto", fileDescriptor_0a48475520900507)
}
var fileDescriptor_0a48475520900507 = []byte{
// 336 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x91, 0xcf, 0x4e, 0x2a, 0x31,
0x14, 0x87, 0xa7, 0x77, 0x41, 0xae, 0xe3, 0x8e, 0xf8, 0x07, 0xc7, 0x64, 0x86, 0xe8, 0x86, 0x84,
0xd0, 0x06, 0x7d, 0x03, 0xa2, 0x0b, 0x76, 0x04, 0x5d, 0xb9, 0x69, 0x3a, 0x4c, 0x29, 0x0d, 0xd3,
0x76, 0xd2, 0x76, 0x50, 0xde, 0x82, 0x87, 0xf1, 0x21, 0x58, 0x12, 0x57, 0xc6, 0x44, 0x34, 0xf0,
0x22, 0xa6, 0xd3, 0xc1, 0xb8, 0x3b, 0xe7, 0xf4, 0xeb, 0xd7, 0xfc, 0x4e, 0xc3, 0xeb, 0x39, 0x59,
0x10, 0x34, 0x51, 0x42, 0x94, 0x92, 0xdb, 0x25, 0x5a, 0xf4, 0x53, 0x6a, 0x49, 0x1f, 0x15, 0x44,
0x13, 0x61, 0x60, 0xa1, 0x95, 0x55, 0xcd, 0x33, 0x07, 0xc1, 0x5f, 0x08, 0xd6, 0x50, 0x74, 0x31,
0x51, 0x46, 0x28, 0x83, 0x2b, 0x0a, 0xf9, 0xc6, 0x5f, 0x89, 0x4e, 0x98, 0x62, 0xca, 0xcf, 0x5d,
0x55, 0x4f, 0x13, 0xa6, 0x14, 0xcb, 0x29, 0xaa, 0xba, 0xb4, 0x9c, 0x22, 0xcb, 0x05, 0x35, 0x96,
0x88, 0xc2, 0x03, 0x57, 0x9f, 0x20, 0x6c, 0x8c, 0xaa, 0xa7, 0x9b, 0x3c, 0x8c, 0xcb, 0x82, 0x69,
0x92, 0x51, 0xec, 0x28, 0x9c, 0x71, 0x43, 0xd2, 0x9c, 0x62, 0x2e, 0xa7, 0x39, 0xb1, 0x5c, 0xc9,
0x16, 0x68, 0x83, 0xce, 0xf1, 0x4d, 0x04, 0xbd, 0x14, 0x1e, 0xa4, 0xf0, 0xf1, 0x20, 0x1d, 0xfc,
0x5f, 0x6f, 0x93, 0x60, 0xf5, 0x95, 0x80, 0xf1, 0x65, 0xed, 0x72, 0x67, 0x77, 0xde, 0x34, 0x3c,
0x88, 0x9a, 0xb3, 0x30, 0x32, 0x96, 0xcc, 0xb9, 0x64, 0x58, 0xd3, 0x67, 0xa2, 0x33, 0x83, 0x0b,
0xaa, 0xb1, 0xa1, 0x13, 0x25, 0xb3, 0xd6, 0xbf, 0x36, 0xe8, 0x1c, 0x0d, 0xba, 0x4e, 0xf5, 0xb1,
0x4d, 0x4e, 0x7d, 0x4c, 0x93, 0xcd, 0x21, 0x57, 0x48, 0x10, 0x3b, 0x83, 0x43, 0x69, 0xdf, 0x5e,
0x7b, 0x61, 0x9d, 0x7f, 0x28, 0xed, 0xf8, 0xbc, 0xd6, 0x8d, 0xbd, 0x6d, 0x44, 0xf5, 0x43, 0xe5,
0x1a, 0xdc, 0xaf, 0x77, 0x31, 0xd8, 0xec, 0x62, 0xf0, 0xbd, 0x8b, 0xc1, 0x6a, 0x1f, 0x07, 0x9b,
0x7d, 0x1c, 0xbc, 0xef, 0xe3, 0xe0, 0xa9, 0xcb, 0xb8, 0x9d, 0x95, 0xa9, 0xdb, 0x32, 0x72, 0xeb,
0xee, 0xe5, 0x24, 0x35, 0x55, 0x85, 0x5e, 0xfe, 0xfc, 0x8f, 0x5d, 0x16, 0xd4, 0xa4, 0x8d, 0x2a,
0xeb, 0xed, 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xc5, 0xad, 0xf1, 0xc6, 0xbe, 0x01, 0x00, 0x00,
}
func (m *Params) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalToSizedBuffer(dAtA[:size])
if err != nil {
return nil, err
}
return dAtA[:n], nil
}
func (m *Params) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
{
size := m.StakingRewardsPerSecond.Size()
i -= size
if _, err := m.StakingRewardsPerSecond.MarshalTo(dAtA[i:]); err != nil {
return 0, err
}
i = encodeVarintParams(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0x12
n1, err1 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.UpgradeTimeDisableInflation, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.UpgradeTimeDisableInflation):])
if err1 != nil {
return 0, err1
}
i -= n1
i = encodeVarintParams(dAtA, i, uint64(n1))
i--
dAtA[i] = 0xa
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
l = github_com_gogo_protobuf_types.SizeOfStdTime(m.UpgradeTimeDisableInflation)
n += 1 + l + sovParams(uint64(l))
l = m.StakingRewardsPerSecond.Size()
n += 1 + l + sovParams(uint64(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 {
case 1:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field UpgradeTimeDisableInflation", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowParams
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthParams
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthParams
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
if err := github_com_gogo_protobuf_types.StdTimeUnmarshal(&m.UpgradeTimeDisableInflation, dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
case 2:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field StakingRewardsPerSecond", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowParams
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLen |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthParams
}
postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthParams
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
if err := m.StakingRewardsPerSecond.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
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")
)

View File

@ -0,0 +1,57 @@
package types_test
import (
"testing"
"time"
"github.com/stretchr/testify/require"
sdkmath "cosmossdk.io/math"
"github.com/kava-labs/kava/x/community/types"
)
func TestParamsValidate(t *testing.T) {
testCases := []struct {
name string
params types.Params
expectedErr string
}{
{
name: "valid parms",
params: types.Params{
UpgradeTimeDisableInflation: time.Time{},
StakingRewardsPerSecond: sdkmath.NewInt(1000),
},
expectedErr: "",
},
{
name: "nil rewards per second",
params: types.Params{
UpgradeTimeDisableInflation: time.Time{},
StakingRewardsPerSecond: sdkmath.Int{},
},
expectedErr: "StakingRewardsPerSecond should not be nil",
},
{
name: "negative rewards per second",
params: types.Params{
UpgradeTimeDisableInflation: time.Time{},
StakingRewardsPerSecond: sdkmath.NewInt(-5),
},
expectedErr: "StakingRewardsPerSecond should not be negative",
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
err := tc.params.Validate()
if tc.expectedErr == "" {
require.NoError(t, err)
} else {
require.Error(t, err)
require.Contains(t, err.Error(), tc.expectedErr)
}
})
}
}

View File

@ -31,6 +31,89 @@ var _ = math.Inf
// proto package needs to be updated. // proto package needs to be updated.
const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
// QueryParams defines the request type for querying x/community params.
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_f236f06c43149273, []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 defines the response type for querying x/community params.
type QueryParamsResponse struct {
// params represents the community module parameters
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_f236f06c43149273, []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{}
}
// QueryBalanceRequest defines the request type for querying x/community balance. // QueryBalanceRequest defines the request type for querying x/community balance.
type QueryBalanceRequest struct { type QueryBalanceRequest struct {
} }
@ -39,7 +122,7 @@ func (m *QueryBalanceRequest) Reset() { *m = QueryBalanceRequest{} }
func (m *QueryBalanceRequest) String() string { return proto.CompactTextString(m) } func (m *QueryBalanceRequest) String() string { return proto.CompactTextString(m) }
func (*QueryBalanceRequest) ProtoMessage() {} func (*QueryBalanceRequest) ProtoMessage() {}
func (*QueryBalanceRequest) Descriptor() ([]byte, []int) { func (*QueryBalanceRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_f236f06c43149273, []int{0} return fileDescriptor_f236f06c43149273, []int{2}
} }
func (m *QueryBalanceRequest) XXX_Unmarshal(b []byte) error { func (m *QueryBalanceRequest) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b) return m.Unmarshal(b)
@ -77,7 +160,7 @@ func (m *QueryBalanceResponse) Reset() { *m = QueryBalanceResponse{} }
func (m *QueryBalanceResponse) String() string { return proto.CompactTextString(m) } func (m *QueryBalanceResponse) String() string { return proto.CompactTextString(m) }
func (*QueryBalanceResponse) ProtoMessage() {} func (*QueryBalanceResponse) ProtoMessage() {}
func (*QueryBalanceResponse) Descriptor() ([]byte, []int) { func (*QueryBalanceResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_f236f06c43149273, []int{1} return fileDescriptor_f236f06c43149273, []int{3}
} }
func (m *QueryBalanceResponse) XXX_Unmarshal(b []byte) error { func (m *QueryBalanceResponse) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b) return m.Unmarshal(b)
@ -121,7 +204,7 @@ func (m *QueryTotalBalanceRequest) Reset() { *m = QueryTotalBalanceReque
func (m *QueryTotalBalanceRequest) String() string { return proto.CompactTextString(m) } func (m *QueryTotalBalanceRequest) String() string { return proto.CompactTextString(m) }
func (*QueryTotalBalanceRequest) ProtoMessage() {} func (*QueryTotalBalanceRequest) ProtoMessage() {}
func (*QueryTotalBalanceRequest) Descriptor() ([]byte, []int) { func (*QueryTotalBalanceRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_f236f06c43149273, []int{2} return fileDescriptor_f236f06c43149273, []int{4}
} }
func (m *QueryTotalBalanceRequest) XXX_Unmarshal(b []byte) error { func (m *QueryTotalBalanceRequest) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b) return m.Unmarshal(b)
@ -161,7 +244,7 @@ func (m *QueryTotalBalanceResponse) Reset() { *m = QueryTotalBalanceResp
func (m *QueryTotalBalanceResponse) String() string { return proto.CompactTextString(m) } func (m *QueryTotalBalanceResponse) String() string { return proto.CompactTextString(m) }
func (*QueryTotalBalanceResponse) ProtoMessage() {} func (*QueryTotalBalanceResponse) ProtoMessage() {}
func (*QueryTotalBalanceResponse) Descriptor() ([]byte, []int) { func (*QueryTotalBalanceResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_f236f06c43149273, []int{3} return fileDescriptor_f236f06c43149273, []int{5}
} }
func (m *QueryTotalBalanceResponse) XXX_Unmarshal(b []byte) error { func (m *QueryTotalBalanceResponse) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b) return m.Unmarshal(b)
@ -198,6 +281,8 @@ func (m *QueryTotalBalanceResponse) GetPool() github_com_cosmos_cosmos_sdk_types
} }
func init() { func init() {
proto.RegisterType((*QueryParamsRequest)(nil), "kava.community.v1beta1.QueryParamsRequest")
proto.RegisterType((*QueryParamsResponse)(nil), "kava.community.v1beta1.QueryParamsResponse")
proto.RegisterType((*QueryBalanceRequest)(nil), "kava.community.v1beta1.QueryBalanceRequest") proto.RegisterType((*QueryBalanceRequest)(nil), "kava.community.v1beta1.QueryBalanceRequest")
proto.RegisterType((*QueryBalanceResponse)(nil), "kava.community.v1beta1.QueryBalanceResponse") proto.RegisterType((*QueryBalanceResponse)(nil), "kava.community.v1beta1.QueryBalanceResponse")
proto.RegisterType((*QueryTotalBalanceRequest)(nil), "kava.community.v1beta1.QueryTotalBalanceRequest") proto.RegisterType((*QueryTotalBalanceRequest)(nil), "kava.community.v1beta1.QueryTotalBalanceRequest")
@ -209,33 +294,37 @@ func init() {
} }
var fileDescriptor_f236f06c43149273 = []byte{ var fileDescriptor_f236f06c43149273 = []byte{
// 411 bytes of a gzipped FileDescriptorProto // 478 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x92, 0x4f, 0x8e, 0xd3, 0x30, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x93, 0x31, 0x6f, 0x13, 0x31,
0x14, 0xc6, 0x93, 0x42, 0x41, 0x32, 0xac, 0x42, 0x41, 0x6d, 0x54, 0xa5, 0x10, 0x09, 0xb5, 0x52, 0x14, 0xc7, 0x63, 0xda, 0x06, 0xc9, 0x65, 0x32, 0x01, 0xb5, 0xa7, 0xca, 0x29, 0x87, 0xa0, 0x11,
0xa9, 0xdd, 0x3f, 0x37, 0x28, 0x70, 0x00, 0x2a, 0x56, 0x6c, 0x90, 0x13, 0xac, 0x10, 0x35, 0xf5, 0x25, 0xe7, 0x26, 0x5d, 0x99, 0x02, 0xec, 0x10, 0x98, 0x58, 0x90, 0xef, 0xb0, 0x8e, 0x53, 0x2f,
0x4b, 0x6b, 0xa7, 0x22, 0xdb, 0xee, 0x91, 0x90, 0xb8, 0x01, 0x4b, 0xce, 0xc0, 0x01, 0xba, 0xac, 0xf7, 0xae, 0xb1, 0x53, 0x91, 0xb5, 0x1b, 0x03, 0x12, 0x12, 0xdf, 0x80, 0x91, 0x4f, 0x92, 0xb1,
0xc4, 0x66, 0x56, 0x33, 0xa3, 0x76, 0x0e, 0x32, 0xb2, 0xe3, 0xa9, 0x3a, 0xa3, 0x74, 0xd4, 0x59, 0x12, 0x0b, 0x13, 0xa0, 0x84, 0x0f, 0x82, 0x6c, 0x3f, 0xa2, 0x04, 0x72, 0x51, 0x98, 0xce, 0x7a,
0xd9, 0xb2, 0xdf, 0xf7, 0x7d, 0x3f, 0xbf, 0x67, 0xe4, 0x4f, 0xe9, 0x92, 0x92, 0x10, 0x66, 0xb3, 0x7e, 0xff, 0xf7, 0xff, 0xf9, 0x6f, 0x1f, 0x0d, 0xcf, 0xe4, 0x85, 0x14, 0x09, 0x0c, 0x06, 0xa3,
0x8c, 0xc7, 0x32, 0x27, 0xcb, 0x41, 0xc0, 0x24, 0x1d, 0x90, 0x79, 0xc6, 0x16, 0x39, 0x4e, 0x17, 0x22, 0x33, 0x63, 0x71, 0xd1, 0x89, 0x95, 0x91, 0x1d, 0x71, 0x3e, 0x52, 0xc3, 0x71, 0x54, 0x0e,
0x20, 0xc1, 0x79, 0xa5, 0x6a, 0xf0, 0xbe, 0x06, 0x9b, 0x1a, 0xd7, 0x0b, 0x41, 0xcc, 0x40, 0x90, 0xc1, 0x00, 0xbb, 0x6d, 0x7b, 0xa2, 0x79, 0x4f, 0x84, 0x3d, 0x01, 0x4f, 0x40, 0x0f, 0x40, 0x8b,
0x80, 0x0a, 0xb6, 0x17, 0x86, 0x10, 0xf3, 0x42, 0xe7, 0xd6, 0x22, 0x88, 0x40, 0x6f, 0x89, 0xda, 0x58, 0x6a, 0x35, 0x17, 0x26, 0x90, 0x15, 0x5e, 0x17, 0x34, 0x52, 0x48, 0xc1, 0x2d, 0x85, 0x5d,
0x99, 0xd3, 0x66, 0x04, 0x10, 0x25, 0x8c, 0xd0, 0x34, 0x26, 0x94, 0x73, 0x90, 0x54, 0xc6, 0xc0, 0x61, 0xf5, 0x20, 0x05, 0x48, 0x73, 0x25, 0x64, 0x99, 0x09, 0x59, 0x14, 0x60, 0xa4, 0xc9, 0xa0,
0x45, 0x71, 0xeb, 0xbf, 0x44, 0x2f, 0x3e, 0xa9, 0xe8, 0x31, 0x4d, 0x28, 0x0f, 0xd9, 0x84, 0xcd, 0xd0, 0xb8, 0x7b, 0xb7, 0x82, 0xa7, 0x94, 0x43, 0x39, 0xc0, 0xa6, 0xb0, 0x41, 0xd9, 0x73, 0xcb,
0x33, 0x26, 0xa4, 0x9f, 0xa3, 0xda, 0xed, 0x63, 0x91, 0x02, 0x17, 0xcc, 0xa1, 0xa8, 0xaa, 0x02, 0xf7, 0xcc, 0x15, 0xfb, 0xea, 0x7c, 0xa4, 0xb4, 0x09, 0x5f, 0xd0, 0x9b, 0x4b, 0x55, 0x5d, 0x42,
0x45, 0xdd, 0x7e, 0xfd, 0xa8, 0xf3, 0x6c, 0xd8, 0xc0, 0x05, 0x12, 0x56, 0x48, 0x37, 0x9c, 0xf8, 0xa1, 0x15, 0x7b, 0x44, 0xeb, 0x5e, 0xbc, 0x47, 0x0e, 0x49, 0x6b, 0xb7, 0xcb, 0xa3, 0xd5, 0xc7,
0x3d, 0xc4, 0x7c, 0xdc, 0x5f, 0x9f, 0xb7, 0xac, 0xbf, 0x17, 0xad, 0x4e, 0x14, 0xcb, 0xef, 0x59, 0x89, 0xbc, 0xae, 0xb7, 0x3d, 0xf9, 0xde, 0xac, 0xf5, 0x51, 0x13, 0xde, 0xc2, 0xa1, 0x3d, 0x99,
0xa0, 0x9e, 0x43, 0x0c, 0x7f, 0xb1, 0xf4, 0xc4, 0xb7, 0x29, 0x91, 0x79, 0xca, 0x84, 0x16, 0x88, 0xcb, 0x22, 0x51, 0x7f, 0xbc, 0xc6, 0xb4, 0xb1, 0x5c, 0x46, 0x33, 0x49, 0x77, 0x6c, 0x00, 0xd6,
0x49, 0xe1, 0xec, 0xbb, 0xa8, 0xae, 0xa3, 0x3f, 0x83, 0xa4, 0xc9, 0x1d, 0xac, 0x95, 0x8d, 0x1a, 0x6b, 0xab, 0xb5, 0xdb, 0xdd, 0x8f, 0x7c, 0x44, 0x91, 0x8d, 0x68, 0x6e, 0xf4, 0x18, 0xb2, 0xa2,
0x25, 0x97, 0x06, 0x8e, 0xa1, 0xc7, 0x29, 0x40, 0x62, 0xd8, 0x9a, 0xa5, 0x6c, 0x1f, 0x58, 0xa8, 0x77, 0x62, 0x6d, 0xbe, 0xfc, 0x68, 0xb6, 0xd2, 0xcc, 0xbc, 0x1d, 0xc5, 0x96, 0x47, 0x60, 0x9e,
0xf1, 0x46, 0x06, 0xaf, 0x7b, 0x02, 0x9e, 0xd1, 0x88, 0x89, 0xb6, 0x1f, 0xfe, 0xab, 0xa0, 0xaa, 0xfe, 0xd3, 0xd6, 0x6f, 0xce, 0x84, 0x19, 0x97, 0x4a, 0x3b, 0x81, 0xee, 0xfb, 0xc9, 0x61, 0x40,
0x86, 0x70, 0x7e, 0xda, 0xe8, 0xa9, 0x81, 0x70, 0xba, 0xb8, 0x7c, 0x6a, 0xb8, 0xa4, 0xbd, 0xee, 0xf7, 0x9c, 0xf5, 0x4b, 0x30, 0x32, 0xff, 0x0b, 0xeb, 0x92, 0xd0, 0xfd, 0x15, 0x9b, 0x08, 0xa7,
0xbb, 0xd3, 0x8a, 0x8b, 0x77, 0xf9, 0xed, 0xd5, 0xff, 0xab, 0xdf, 0x95, 0x37, 0x4e, 0x8b, 0x1c, 0xe8, 0x76, 0x09, 0x90, 0x23, 0xdb, 0xc1, 0x4a, 0xb6, 0x27, 0x2a, 0x71, 0x78, 0xa7, 0x88, 0x77,
0xf9, 0x3c, 0x81, 0x61, 0xf8, 0x63, 0xa3, 0xe7, 0x87, 0x9d, 0x71, 0xfa, 0xf7, 0xe6, 0x94, 0x74, 0xbc, 0x01, 0x1e, 0x6a, 0x74, 0xdf, 0x8d, 0xef, 0x4e, 0xb6, 0xe8, 0x8e, 0x83, 0x60, 0xef, 0x09,
0xd8, 0x1d, 0x3c, 0x40, 0x61, 0xf0, 0x7a, 0x1a, 0xaf, 0xed, 0xbc, 0x3d, 0x86, 0x27, 0x95, 0xea, 0xad, 0xfb, 0x54, 0xd9, 0x83, 0xaa, 0xd4, 0xff, 0xbd, 0xc8, 0xe0, 0x78, 0xa3, 0x5e, 0x7f, 0xa8,
0xab, 0x81, 0x1c, 0x7f, 0x5c, 0x6f, 0x3d, 0x7b, 0xb3, 0xf5, 0xec, 0xcb, 0xad, 0x67, 0xff, 0xda, 0xf0, 0xfe, 0xe5, 0xd7, 0x5f, 0x9f, 0xae, 0x1d, 0x32, 0x2e, 0xd6, 0xbe, 0x1c, 0xf6, 0x81, 0xd0,
0x79, 0xd6, 0x66, 0xe7, 0x59, 0x67, 0x3b, 0xcf, 0xfa, 0x72, 0x38, 0x0b, 0x65, 0xd5, 0x4b, 0x68, 0xeb, 0x18, 0x08, 0x5b, 0x6f, 0xb0, 0x9c, 0x69, 0xf0, 0x70, 0xb3, 0x66, 0xc4, 0x39, 0x72, 0x38,
0x20, 0x0a, 0xd3, 0x1f, 0x07, 0xb6, 0x7a, 0x28, 0xc1, 0x13, 0xfd, 0x7f, 0x47, 0xd7, 0x01, 0x00, 0x77, 0x58, 0xb3, 0x0a, 0x27, 0x46, 0x86, 0xcf, 0x84, 0xde, 0x58, 0xbc, 0x25, 0x76, 0xb2, 0xd6,
0x00, 0xff, 0xff, 0x67, 0x9d, 0xae, 0xd2, 0x51, 0x03, 0x00, 0x00, 0x67, 0xc5, 0x6d, 0x07, 0x9d, 0xff, 0x50, 0x20, 0x5e, 0xdb, 0xe1, 0x1d, 0xb1, 0x7b, 0x55, 0x78,
0xc6, 0xaa, 0x5e, 0x23, 0x64, 0xef, 0xe9, 0x64, 0xca, 0xc9, 0xd5, 0x94, 0x93, 0x9f, 0x53, 0x4e,
0x3e, 0xce, 0x78, 0xed, 0x6a, 0xc6, 0x6b, 0xdf, 0x66, 0xbc, 0xf6, 0x6a, 0xf1, 0x5d, 0xd8, 0x51,
0xed, 0x5c, 0xc6, 0xda, 0x0f, 0x7d, 0xb7, 0x30, 0xd6, 0x3d, 0x90, 0xb8, 0xee, 0x7e, 0xdb, 0xd3,
0xdf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x62, 0x63, 0xf8, 0x10, 0x6d, 0x04, 0x00, 0x00,
} }
// Reference imports to suppress errors if they are not otherwise used. // Reference imports to suppress errors if they are not otherwise used.
@ -250,6 +339,8 @@ const _ = grpc.SupportPackageIsVersion4
// //
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. // 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 { type QueryClient interface {
// Params queires the module params.
Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error)
// Balance queries the balance of all coins of x/community module. // Balance queries the balance of all coins of x/community module.
Balance(ctx context.Context, in *QueryBalanceRequest, opts ...grpc.CallOption) (*QueryBalanceResponse, error) Balance(ctx context.Context, in *QueryBalanceRequest, opts ...grpc.CallOption) (*QueryBalanceResponse, error)
// TotalBalance queries the balance of all coins, including x/distribution, // TotalBalance queries the balance of all coins, including x/distribution,
@ -265,6 +356,15 @@ func NewQueryClient(cc grpc1.ClientConn) QueryClient {
return &queryClient{cc} 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, "/kava.community.v1beta1.Query/Params", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *queryClient) Balance(ctx context.Context, in *QueryBalanceRequest, opts ...grpc.CallOption) (*QueryBalanceResponse, error) { func (c *queryClient) Balance(ctx context.Context, in *QueryBalanceRequest, opts ...grpc.CallOption) (*QueryBalanceResponse, error) {
out := new(QueryBalanceResponse) out := new(QueryBalanceResponse)
err := c.cc.Invoke(ctx, "/kava.community.v1beta1.Query/Balance", in, out, opts...) err := c.cc.Invoke(ctx, "/kava.community.v1beta1.Query/Balance", in, out, opts...)
@ -285,6 +385,8 @@ func (c *queryClient) TotalBalance(ctx context.Context, in *QueryTotalBalanceReq
// QueryServer is the server API for Query service. // QueryServer is the server API for Query service.
type QueryServer interface { type QueryServer interface {
// Params queires the module params.
Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error)
// Balance queries the balance of all coins of x/community module. // Balance queries the balance of all coins of x/community module.
Balance(context.Context, *QueryBalanceRequest) (*QueryBalanceResponse, error) Balance(context.Context, *QueryBalanceRequest) (*QueryBalanceResponse, error)
// TotalBalance queries the balance of all coins, including x/distribution, // TotalBalance queries the balance of all coins, including x/distribution,
@ -296,6 +398,9 @@ type QueryServer interface {
type UnimplementedQueryServer struct { 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) Balance(ctx context.Context, req *QueryBalanceRequest) (*QueryBalanceResponse, error) { func (*UnimplementedQueryServer) Balance(ctx context.Context, req *QueryBalanceRequest) (*QueryBalanceResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method Balance not implemented") return nil, status.Errorf(codes.Unimplemented, "method Balance not implemented")
} }
@ -307,6 +412,24 @@ func RegisterQueryServer(s grpc1.Server, srv QueryServer) {
s.RegisterService(&_Query_serviceDesc, srv) 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: "/kava.community.v1beta1.Query/Params",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Query_Balance_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { func _Query_Balance_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(QueryBalanceRequest) in := new(QueryBalanceRequest)
if err := dec(in); err != nil { if err := dec(in); err != nil {
@ -347,6 +470,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{
ServiceName: "kava.community.v1beta1.Query", ServiceName: "kava.community.v1beta1.Query",
HandlerType: (*QueryServer)(nil), HandlerType: (*QueryServer)(nil),
Methods: []grpc.MethodDesc{ Methods: []grpc.MethodDesc{
{
MethodName: "Params",
Handler: _Query_Params_Handler,
},
{ {
MethodName: "Balance", MethodName: "Balance",
Handler: _Query_Balance_Handler, Handler: _Query_Balance_Handler,
@ -360,6 +487,62 @@ var _Query_serviceDesc = grpc.ServiceDesc{
Metadata: "kava/community/v1beta1/query.proto", Metadata: "kava/community/v1beta1/query.proto",
} }
func (m *QueryParamsRequest) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalToSizedBuffer(dAtA[:size])
if err != nil {
return nil, err
}
return dAtA[:n], nil
}
func (m *QueryParamsRequest) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *QueryParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
return len(dAtA) - i, nil
}
func (m *QueryParamsResponse) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalToSizedBuffer(dAtA[:size])
if err != nil {
return nil, err
}
return dAtA[:n], nil
}
func (m *QueryParamsResponse) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
{
size, err := m.Params.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintQuery(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0xa
return len(dAtA) - i, nil
}
func (m *QueryBalanceRequest) Marshal() (dAtA []byte, err error) { func (m *QueryBalanceRequest) Marshal() (dAtA []byte, err error) {
size := m.Size() size := m.Size()
dAtA = make([]byte, size) dAtA = make([]byte, size)
@ -491,6 +674,26 @@ func encodeVarintQuery(dAtA []byte, offset int, v uint64) int {
dAtA[offset] = uint8(v) dAtA[offset] = uint8(v)
return base 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 *QueryBalanceRequest) Size() (n int) { func (m *QueryBalanceRequest) Size() (n int) {
if m == nil { if m == nil {
return 0 return 0
@ -545,6 +748,139 @@ func sovQuery(x uint64) (n int) {
func sozQuery(x uint64) (n int) { func sozQuery(x uint64) (n int) {
return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) 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 *QueryBalanceRequest) Unmarshal(dAtA []byte) error { func (m *QueryBalanceRequest) Unmarshal(dAtA []byte) error {
l := len(dAtA) l := len(dAtA)
iNdEx := 0 iNdEx := 0

View File

@ -33,6 +33,24 @@ var _ = utilities.NewDoubleArray
var _ = descriptor.ForMessage var _ = descriptor.ForMessage
var _ = metadata.Join 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_Balance_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { func request_Query_Balance_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq QueryBalanceRequest var protoReq QueryBalanceRequest
var metadata runtime.ServerMetadata var metadata runtime.ServerMetadata
@ -75,6 +93,29 @@ func local_request_Query_TotalBalance_0(ctx context.Context, marshaler runtime.M
// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. // 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 { 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_Balance_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { mux.Handle("GET", pattern_Query_Balance_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context()) ctx, cancel := context.WithCancel(req.Context())
defer cancel() defer cancel()
@ -162,6 +203,26 @@ func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc
// "QueryClient" to call the correct interceptors. // "QueryClient" to call the correct interceptors.
func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { 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_Balance_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { mux.Handle("GET", pattern_Query_Balance_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context()) ctx, cancel := context.WithCancel(req.Context())
defer cancel() defer cancel()
@ -206,12 +267,16 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie
} }
var ( var (
pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"kava", "community", "v1beta1", "params"}, "", runtime.AssumeColonVerbOpt(false)))
pattern_Query_Balance_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"kava", "community", "v1beta1", "balance"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_Balance_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"kava", "community", "v1beta1", "balance"}, "", runtime.AssumeColonVerbOpt(false)))
pattern_Query_TotalBalance_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"kava", "community", "v1beta1", "total_balance"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_TotalBalance_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"kava", "community", "v1beta1", "total_balance"}, "", runtime.AssumeColonVerbOpt(false)))
) )
var ( var (
forward_Query_Params_0 = runtime.ForwardResponseMessage
forward_Query_Balance_0 = runtime.ForwardResponseMessage forward_Query_Balance_0 = runtime.ForwardResponseMessage
forward_Query_TotalBalance_0 = runtime.ForwardResponseMessage forward_Query_TotalBalance_0 = runtime.ForwardResponseMessage