Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: stargate custom mint module #86

Merged
merged 4 commits into from
May 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 15 additions & 23 deletions docs/core/proto-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -4437,10 +4437,7 @@ Params holds parameters for the mint module.
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `mint_denom` | [string](#string) | | type of coin to mint |
| `inflation_rate_change` | [string](#string) | | maximum annual change in inflation rate |
| `inflation_max` | [string](#string) | | maximum inflation rate |
| `inflation_min` | [string](#string) | | minimum inflation rate |
| `goal_bonded` | [string](#string) | | goal of percent bonded atoms |
| `inflation_rate` | [string](#string) | | maximum annual change in inflation rate |
| `blocks_per_year` | [uint64](#uint64) | | expected blocks per year |


Expand Down Expand Up @@ -6527,6 +6524,7 @@ RPC method.
| ----- | ---- | ----- | ----------- |
| `events` | [string](#string) | repeated | events is the list of transaction event type. |
| `pagination` | [cosmos.base.query.v1beta1.PageRequest](#cosmos.base.query.v1beta1.PageRequest) | | pagination defines an pagination for the request. |
| `order_by` | [OrderBy](#cosmos.tx.v1beta1.OrderBy) | | |



Expand Down Expand Up @@ -6599,6 +6597,19 @@ BroadcastMode specifies the broadcast mode for the TxService.Broadcast RPC metho
| BROADCAST_MODE_ASYNC | 3 | BROADCAST_MODE_ASYNC defines a tx broadcasting mode where the client returns immediately. |



<a name="cosmos.tx.v1beta1.OrderBy"></a>

### OrderBy
OrderBy defines the sorting order

| Name | Number | Description |
| ---- | ------ | ----------- |
| ORDER_BY_UNSPECIFIED | 0 | ORDER_BY_UNSPECIFIED specifies an unknown sorting order. OrderBy defaults to ASC in this case. |
| ORDER_BY_ASC | 1 | ORDER_BY_ASC defines ascending order |
| ORDER_BY_DESC | 2 | ORDER_BY_DESC defines descending order |


<!-- end enums -->

<!-- end HasExtensions -->
Expand Down Expand Up @@ -9491,11 +9502,6 @@ GenesisState defines the ibc module's genesis state.

<!-- end services -->

| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `events` | [string](#string) | repeated | events is the list of transaction event type. |
| `pagination` | [cosmos.base.query.v1beta1.PageRequest](#cosmos.base.query.v1beta1.PageRequest) | | pagination defines an pagination for the request. |
| `order_by` | [OrderBy](#cosmos.tx.v1beta1.OrderBy) | | |


<a name="ibc/lightclients/localhost/v1/localhost.proto"></a>
Expand Down Expand Up @@ -9571,20 +9577,6 @@ state and if the client is frozen.



<a name="cosmos.tx.v1beta1.OrderBy"></a>

### OrderBy
OrderBy defines the sorting order

| Name | Number | Description |
| ---- | ------ | ----------- |
| ORDER_BY_UNSPECIFIED | 0 | ORDER_BY_UNSPECIFIED specifies an unknown sorting order. OrderBy defaults to ASC in this case. |
| ORDER_BY_ASC | 1 | ORDER_BY_ASC defines ascending order |
| ORDER_BY_DESC | 2 | ORDER_BY_DESC defines descending order |


<!-- end enums -->




Expand Down
22 changes: 2 additions & 20 deletions proto/cosmos/mint/v1beta1/mint.proto
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,8 @@ message Params {
// type of coin to mint
string mint_denom = 1;
// maximum annual change in inflation rate
string inflation_rate_change = 2 [
(gogoproto.moretags) = "yaml:\"inflation_rate_change\"",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
// maximum inflation rate
string inflation_max = 3 [
(gogoproto.moretags) = "yaml:\"inflation_max\"",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
// minimum inflation rate
string inflation_min = 4 [
(gogoproto.moretags) = "yaml:\"inflation_min\"",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
// goal of percent bonded atoms
string goal_bonded = 5 [
(gogoproto.moretags) = "yaml:\"goal_bonded\"",
string inflation_rate = 2 [
(gogoproto.moretags) = "yaml:\"inflation_rate\"",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
Expand Down
4 changes: 2 additions & 2 deletions x/bank/client/cli/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryTotalSupply() {
expected: &types.QueryTotalSupplyResponse{
Supply: sdk.NewCoins(
sdk.NewCoin(fmt.Sprintf("%stoken", val.Moniker), s.cfg.AccountTokens),
sdk.NewCoin(s.cfg.BondDenom, s.cfg.StakingTokens.Add(sdk.NewInt(10))),
sdk.NewCoin(s.cfg.BondDenom, s.cfg.StakingTokens.Add(sdk.NewInt(2))),
)},
},
{
Expand All @@ -193,7 +193,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryTotalSupply() {
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
},
respType: &sdk.Coin{},
expected: &sdk.Coin{s.cfg.BondDenom, s.cfg.StakingTokens.Add(sdk.NewInt(10))},
expected: &sdk.Coin{s.cfg.BondDenom, s.cfg.StakingTokens.Add(sdk.NewInt(2))},
},
{
name: "total supply of a bogus denom",
Expand Down
8 changes: 4 additions & 4 deletions x/bank/client/rest/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func (s *IntegrationTestSuite) TestTotalSupplyGRPCHandler() {
&types.QueryTotalSupplyResponse{
Supply: sdk.NewCoins(
sdk.NewCoin(fmt.Sprintf("%stoken", val.Moniker), s.cfg.AccountTokens),
sdk.NewCoin(s.cfg.BondDenom, s.cfg.StakingTokens.Add(sdk.NewInt(10))),
sdk.NewCoin(s.cfg.BondDenom, s.cfg.StakingTokens.Add(sdk.NewInt(2))),
),
},
},
Expand All @@ -48,7 +48,7 @@ func (s *IntegrationTestSuite) TestTotalSupplyGRPCHandler() {
},
&types.QuerySupplyOfResponse{},
&types.QuerySupplyOfResponse{
Amount: sdk.NewCoin(s.cfg.BondDenom, s.cfg.StakingTokens.Add(sdk.NewInt(10))),
Amount: sdk.NewCoin(s.cfg.BondDenom, s.cfg.StakingTokens.Add(sdk.NewInt(2))),
},
},
{
Expand All @@ -59,7 +59,7 @@ func (s *IntegrationTestSuite) TestTotalSupplyGRPCHandler() {
},
&types.QuerySupplyOfResponse{},
&types.QuerySupplyOfResponse{
Amount: sdk.NewCoin(s.cfg.BondDenom, s.cfg.StakingTokens.Add(sdk.NewInt(20))),
Amount: sdk.NewCoin(s.cfg.BondDenom, s.cfg.StakingTokens.Add(sdk.NewInt(4))),
},
},
{
Expand All @@ -70,7 +70,7 @@ func (s *IntegrationTestSuite) TestTotalSupplyGRPCHandler() {
},
&types.QuerySupplyOfResponse{},
&types.QuerySupplyOfResponse{
Amount: sdk.NewCoin(s.cfg.BondDenom, s.cfg.StakingTokens.Add(sdk.NewInt(10))),
Amount: sdk.NewCoin(s.cfg.BondDenom, s.cfg.StakingTokens.Add(sdk.NewInt(2))),
},
},
{
Expand Down
4 changes: 2 additions & 2 deletions x/bank/client/rest/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,14 @@ func (s *IntegrationTestSuite) TestTotalSupplyHandlerFn() {
&sdk.Coins{},
sdk.NewCoins(
sdk.NewCoin(fmt.Sprintf("%stoken", val.Moniker), s.cfg.AccountTokens),
sdk.NewCoin(s.cfg.BondDenom, s.cfg.StakingTokens.Add(sdk.NewInt(10))),
sdk.NewCoin(s.cfg.BondDenom, s.cfg.StakingTokens.Add(sdk.NewInt(2))),
),
},
{
"total supply of a specific denom",
fmt.Sprintf("%s/bank/total/%s?height=1", baseURL, s.cfg.BondDenom),
&sdk.Coin{},
sdk.NewCoin(s.cfg.BondDenom, s.cfg.StakingTokens.Add(sdk.NewInt(10))),
sdk.NewCoin(s.cfg.BondDenom, s.cfg.StakingTokens.Add(sdk.NewInt(2))),
},
{
"total supply of a bogus denom",
Expand Down
24 changes: 11 additions & 13 deletions x/distribution/client/cli/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ func (s *IntegrationTestSuite) SetupTest() {

inflation := sdk.MustNewDecFromStr("1.0")
mintData.Minter.Inflation = inflation
mintData.Params.InflationMin = inflation
mintData.Params.InflationMax = inflation

mintDataBz, err := cfg.Codec.MarshalJSON(&mintData)
s.Require().NoError(err)
Expand Down Expand Up @@ -134,7 +132,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryValidatorOutstandingRewards() {
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
},
false,
`{"rewards":[{"denom":"stake","amount":"232.260000000000000000"}]}`,
`{"rewards":[{"denom":"stake","amount":"5.880000000000000000"}]}`,
},
{
"text output",
Expand All @@ -145,7 +143,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryValidatorOutstandingRewards() {
},
false,
`rewards:
- amount: "232.260000000000000000"
- amount: "5.880000000000000000"
denom: stake`,
},
}
Expand Down Expand Up @@ -197,7 +195,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryValidatorCommission() {
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
},
false,
`{"commission":[{"denom":"stake","amount":"116.130000000000000000"}]}`,
`{"commission":[{"denom":"stake","amount":"2.940000000000000000"}]}`,
},
{
"text output",
Expand All @@ -208,7 +206,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryValidatorCommission() {
},
false,
`commission:
- amount: "116.130000000000000000"
- amount: "2.940000000000000000"
denom: stake`,
},
}
Expand Down Expand Up @@ -350,7 +348,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryDelegatorRewards() {
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
},
false,
fmt.Sprintf(`{"rewards":[{"validator_address":"%s","reward":[{"denom":"stake","amount":"387.100000000000000000"}]}],"total":[{"denom":"stake","amount":"387.100000000000000000"}]}`, valAddr.String()),
fmt.Sprintf(`{"rewards":[{"validator_address":"%s","reward":[{"denom":"stake","amount":"9.800000000000000000"}]}],"total":[{"denom":"stake","amount":"9.800000000000000000"}]}`, valAddr.String()),
},
{
"json output (specific validator)",
Expand All @@ -360,7 +358,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryDelegatorRewards() {
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
},
false,
`{"rewards":[{"denom":"stake","amount":"387.100000000000000000"}]}`,
`{"rewards":[{"denom":"stake","amount":"9.800000000000000000"}]}`,
},
{
"text output",
Expand All @@ -372,11 +370,11 @@ func (s *IntegrationTestSuite) TestGetCmdQueryDelegatorRewards() {
false,
fmt.Sprintf(`rewards:
- reward:
- amount: "387.100000000000000000"
- amount: "9.800000000000000000"
denom: stake
validator_address: %s
total:
- amount: "387.100000000000000000"
- amount: "9.800000000000000000"
denom: stake`, valAddr.String()),
},
{
Expand All @@ -388,7 +386,7 @@ total:
},
false,
`rewards:
- amount: "387.100000000000000000"
- amount: "9.800000000000000000"
denom: stake`,
},
}
Expand Down Expand Up @@ -425,13 +423,13 @@ func (s *IntegrationTestSuite) TestGetCmdQueryCommunityPool() {
{
"json output",
[]string{fmt.Sprintf("--%s=3", flags.FlagHeight), fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
`{"pool":[{"denom":"stake","amount":"4.740000000000000000"}]}`,
`{"pool":[{"denom":"stake","amount":"0.120000000000000000"}]}`,
},
{
"text output",
[]string{fmt.Sprintf("--%s=text", tmcli.OutputFlag), fmt.Sprintf("--%s=3", flags.FlagHeight)},
`pool:
- amount: "4.740000000000000000"
- amount: "0.120000000000000000"
denom: stake`,
},
}
Expand Down
8 changes: 4 additions & 4 deletions x/distribution/client/rest/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func (s *IntegrationTestSuite) TestQueryOutstandingRewardsGRPC() {
val := s.network.Validators[0]
baseURL := val.APIAddress

rewards, err := sdk.ParseDecCoins("19.6stake")
rewards, err := sdk.ParseDecCoins("3.92stake")
s.Require().NoError(err)

testCases := []struct {
Expand Down Expand Up @@ -125,7 +125,7 @@ func (s *IntegrationTestSuite) TestQueryValidatorCommissionGRPC() {
val := s.network.Validators[0]
baseURL := val.APIAddress

commission, err := sdk.ParseDecCoins("9.8stake")
commission, err := sdk.ParseDecCoins("1.96stake")
s.Require().NoError(err)

testCases := []struct {
Expand Down Expand Up @@ -238,7 +238,7 @@ func (s *IntegrationTestSuite) TestQueryDelegatorRewardsGRPC() {
val := s.network.Validators[0]
baseUrl := val.APIAddress

rewards, err := sdk.ParseDecCoins("9.8stake")
rewards, err := sdk.ParseDecCoins("1.96stake")
s.Require().NoError(err)

testCases := []struct {
Expand Down Expand Up @@ -418,7 +418,7 @@ func (s *IntegrationTestSuite) TestQueryValidatorCommunityPoolGRPC() {
val := s.network.Validators[0]
baseURL := val.APIAddress

communityPool, err := sdk.ParseDecCoins("0.4stake")
communityPool, err := sdk.ParseDecCoins("0.08stake")
s.Require().NoError(err)

testCases := []struct {
Expand Down
2 changes: 1 addition & 1 deletion x/evidence/types/evidence.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions x/gov/types/gov.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions x/ibc/light-clients/07-tendermint/types/tendermint.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion x/mint/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func BeginBlocker(ctx sdk.Context, k keeper.Keeper) {
// recalculate inflation rate
totalStakingSupply := k.StakingTokenSupply(ctx)
bondedRatio := k.BondedRatio(ctx)
minter.Inflation = minter.NextInflationRate(params, bondedRatio)
minter.Inflation = minter.NextInflationRate(params)
minter.AnnualProvisions = minter.NextAnnualProvisions(params, totalStakingSupply)
k.SetMinter(ctx, minter)

Expand Down
Loading