Merge PR #4011: Mint/Inflation Querier, LCD and CLI

* A few godoc updates

* More minor tweaks and reformatting

* Implement initial minting querier

* Implement stringer interface for minting params

* Minor cleanup

* Add minting CLI commands

* Implement inflation query command

* Implement annual provisions query and CLI command

* Update x/mint/client/module_client.go

Co-Authored-By: alexanderbez <alexanderbez@users.noreply.github.com>

* Update x/mint/client/module_client.go

Co-Authored-By: alexanderbez <alexanderbez@users.noreply.github.com>

* Update x/mint/client/module_client.go

Co-Authored-By: alexanderbez <alexanderbez@users.noreply.github.com>

* Update x/mint/querier.go

Co-Authored-By: alexanderbez <alexanderbez@users.noreply.github.com>

* Add minting REST client routes/handlers

* Fix build issues

* Implement querier unit tests

* Update gaiacli docs

* Implement LCD tests

* Update Swagger docs

* Add pending log entry

* add examples

Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com>

* revert adding examples

Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com>
This commit is contained in:
Alexander Bezobchuk
2019-04-01 10:28:36 -07:00
committed by Jack Zampolin
parent 120e08f12d
commit b95ade93bd
17 changed files with 635 additions and 30 deletions
+28
View File
@@ -11,6 +11,8 @@ import (
"testing"
"time"
"github.com/cosmos/cosmos-sdk/x/mint"
"github.com/stretchr/testify/require"
"github.com/cosmos/cosmos-sdk/client"
@@ -1005,3 +1007,29 @@ func TestDistributionFlow(t *testing.T) {
resultTx = doWithdrawDelegatorAllRewards(t, port, seed, name1, pw, addr, fees)
require.Equal(t, uint32(0), resultTx.Code)
}
func TestMintingQueries(t *testing.T) {
kb, err := keys.NewKeyBaseFromDir(InitClientHome(t, ""))
require.NoError(t, err)
addr, _ := CreateAddr(t, name1, pw, kb)
cleanup, _, _, port := InitializeTestLCD(t, 1, []sdk.AccAddress{addr}, true)
defer cleanup()
res, body := Request(t, port, "GET", "/minting/parameters", nil)
require.Equal(t, http.StatusOK, res.StatusCode, body)
var params mint.Params
require.NoError(t, cdc.UnmarshalJSON([]byte(body), &params))
res, body = Request(t, port, "GET", "/minting/inflation", nil)
require.Equal(t, http.StatusOK, res.StatusCode, body)
var inflation sdk.Dec
require.NoError(t, cdc.UnmarshalJSON([]byte(body), &inflation))
res, body = Request(t, port, "GET", "/minting/annual-provisions", nil)
require.Equal(t, http.StatusOK, res.StatusCode, body)
var annualProvisions sdk.Dec
require.NoError(t, cdc.UnmarshalJSON([]byte(body), &annualProvisions))
}
+93
View File
@@ -122,6 +122,7 @@ paths:
description: Block height
required: true
type: number
x-example: 1
responses:
200:
description: The block at a specific height
@@ -167,6 +168,7 @@ paths:
description: Block height
required: true
type: number
x-example: 1
responses:
200:
description: The validator set at a specific block height
@@ -198,6 +200,7 @@ paths:
description: Tx hash
required: true
type: string
x-example: 88D6B85EAB87D43CDF50F39C22FC2237A37FEDC4CE723200AD0AF48CBEDBC317
responses:
200:
description: Tx with the provided hash
@@ -219,14 +222,17 @@ paths:
type: string
description: "transaction tags such as 'action=submit-proposal' and 'proposer=cosmos1g9ahr6xhht5rmqven628nklxluzyv8z9jqjcmc' which results in the following endpoint: 'GET /txs?action=submit-proposal&proposer=cosmos1g9ahr6xhht5rmqven628nklxluzyv8z9jqjcmc'"
required: true
x-example: 'TODO'
- in: query
name: page
description: Page number
type: integer
x-example: 1
- in: query
name: limit
description: Maximum number of items per page
type: integer
x-example: 1
responses:
200:
description: All txs matching the provided tags
@@ -313,6 +319,7 @@ paths:
description: Account address in bech32 format
required: true
type: string
x-example: cosmos16gdxm24ht2mxtpz9cma6tr6a6d47x63hlq4pxt
responses:
200:
description: Account balances
@@ -339,6 +346,7 @@ paths:
description: Account address in bech32 format
required: true
type: string
x-example: cosmos16gdxm24ht2mxtpz9cma6tr6a6d47x63hlq4pxt
- in: body
name: account
description: The sender and tx information
@@ -374,6 +382,7 @@ paths:
description: Account address
required: true
type: string
x-example: cosmos16gdxm24ht2mxtpz9cma6tr6a6d47x63hlq4pxt
responses:
200:
description: Account information on the blockchain
@@ -408,6 +417,7 @@ paths:
description: Bech32 AccAddress of Delegator
required: true
type: string
x-example: cosmos167w96tdvmazakdwkw2u57227eduula2cy572lf
get:
summary: Get all delegations from a delegator
tags:
@@ -466,11 +476,13 @@ paths:
description: Bech32 AccAddress of Delegator
required: true
type: string
x-example: cosmos167w96tdvmazakdwkw2u57227eduula2cy572lf
- in: path
name: validatorAddr
description: Bech32 OperatorAddress of validator
required: true
type: string
x-example: cosmosvaloper1qwl879nx9t6kef4supyazayf7vjhennyh568ys
get:
summary: Query the current delegation between a delegator and a validator
tags:
@@ -493,6 +505,7 @@ paths:
description: Bech32 AccAddress of Delegator
required: true
type: string
x-example: cosmos167w96tdvmazakdwkw2u57227eduula2cy572lf
get:
summary: Get all unbonding delegations from a delegator
tags:
@@ -552,11 +565,13 @@ paths:
description: Bech32 AccAddress of Delegator
required: true
type: string
x-example: cosmos167w96tdvmazakdwkw2u57227eduula2cy572lf
- in: path
name: validatorAddr
description: Bech32 OperatorAddress of validator
required: true
type: string
x-example: cosmosvaloper1qwl879nx9t6kef4supyazayf7vjhennyh568ys
get:
summary: Query all unbonding delegations between a delegator and a validator
tags:
@@ -613,6 +628,7 @@ paths:
description: Bech32 AccAddress of Delegator
required: true
type: string
x-example: cosmos167w96tdvmazakdwkw2u57227eduula2cy572lf
post:
summary: Submit a redelegation
parameters:
@@ -655,6 +671,7 @@ paths:
description: Bech32 AccAddress of Delegator
required: true
type: string
x-example: cosmos167w96tdvmazakdwkw2u57227eduula2cy572lf
get:
summary: Query all validators that a delegator is bonded to
tags:
@@ -679,11 +696,13 @@ paths:
description: Bech32 AccAddress of Delegator
required: true
type: string
x-example: cosmos167w96tdvmazakdwkw2u57227eduula2cy572lf
- in: path
name: validatorAddr
description: Bech32 ValAddress of Delegator
required: true
type: string
x-example: cosmosvaloper1qwl879nx9t6kef4supyazayf7vjhennyh568ys
get:
summary: Query a validator that a delegator is bonded to
tags:
@@ -706,6 +725,7 @@ paths:
description: Bech32 AccAddress of Delegator
required: true
type: string
x-example: cosmos167w96tdvmazakdwkw2u57227eduula2cy572lf
get:
summary: Get all staking txs (i.e msgs) from a delegator
tags:
@@ -748,6 +768,7 @@ paths:
description: Bech32 OperatorAddress of validator
required: true
type: string
x-example: cosmosvaloper1qwl879nx9t6kef4supyazayf7vjhennyh568ys
get:
summary: Query the information from a single validator
tags:
@@ -770,6 +791,7 @@ paths:
description: Bech32 OperatorAddress of validator
required: true
type: string
x-example: cosmosvaloper1qwl879nx9t6kef4supyazayf7vjhennyh568ys
get:
summary: Get all delegations from a validator
tags:
@@ -794,6 +816,7 @@ paths:
description: Bech32 OperatorAddress of validator
required: true
type: string
x-example: cosmosvaloper1qwl879nx9t6kef4supyazayf7vjhennyh568ys
get:
summary: Get all unbonding delegations from a validator
tags:
@@ -881,6 +904,7 @@ paths:
name: validatorPubKey
required: true
in: path
x-example: cosmosvalconspub1zcjduepq7mft6gfls57a0a42d7uhx656cckhfvtrlmw744jv4q0mvlv0dypskehfk8
responses:
200:
description: OK
@@ -906,11 +930,13 @@ paths:
description: Page number
type: integer
required: true
x-example: 1
- in: query
name: limit
description: Maximum number of items per page
type: integer
required: true
x-example: 5
responses:
200:
description: OK
@@ -940,6 +966,7 @@ paths:
name: validatorAddr
required: true
in: path
x-example: cosmosvaloper1qwl879nx9t6kef4supyazayf7vjhennyh568ys
- description: ""
name: UnjailBody
in: body
@@ -1076,6 +1103,7 @@ paths:
name: proposalId
required: true
in: path
x-example: '1'
responses:
200:
description: OK
@@ -1098,6 +1126,7 @@ paths:
name: proposalId
required: true
in: path
x-example: '1'
responses:
200:
description: OK
@@ -1120,6 +1149,7 @@ paths:
name: proposalId
required: true
in: path
x-example: '1'
responses:
200:
description: OK
@@ -1146,6 +1176,7 @@ paths:
name: proposalId
required: true
in: path
x-example: '1'
- description: ""
name: post_deposit_body
in: body
@@ -1186,11 +1217,13 @@ paths:
name: proposalId
required: true
in: path
x-example: '1'
- type: string
description: Bech32 depositor address
name: depositor
required: true
in: path
x-example: cosmos1xl6453f6q6dv5770c9ue6hspdc0vxfuqtudkhz
responses:
200:
description: OK
@@ -1216,6 +1249,7 @@ paths:
name: proposalId
required: true
in: path
x-example: '1'
responses:
200:
description: OK
@@ -1242,6 +1276,7 @@ paths:
name: proposalId
required: true
in: path
x-example: '1'
- description: valid value of `"option"` field can be `"yes"`, `"no"`, `"no_with_veto"` and `"abstain"`
name: post_vote_body
in: body
@@ -1281,11 +1316,13 @@ paths:
name: proposalId
required: true
in: path
x-example: '1'
- type: string
description: Bech32 voter address
name: voter
required: true
in: path
x-example: cosmos1qwl879nx9t6kef4supyazayf7vjhennyjqwjgr
responses:
200:
description: OK
@@ -1311,6 +1348,7 @@ paths:
name: proposalId
required: true
in: path
x-example: '1'
responses:
200:
description: OK
@@ -1404,6 +1442,7 @@ paths:
description: Bech32 AccAddress of Delegator
required: true
type: string
x-example: cosmos167w96tdvmazakdwkw2u57227eduula2cy572lf
get:
summary: Get the total rewards balance from all delegations
description: Get the sum of all the rewards earned by delegations by a single delegator
@@ -1456,11 +1495,13 @@ paths:
description: Bech32 AccAddress of Delegator
required: true
type: string
x-example: cosmos167w96tdvmazakdwkw2u57227eduula2cy572lf
- in: path
name: validatorAddr
description: Bech32 OperatorAddress of validator
required: true
type: string
x-example: cosmosvaloper1qwl879nx9t6kef4supyazayf7vjhennyh568ys
get:
summary: Query a delegation reward
description: Query a single delegation reward by a delegator
@@ -1513,6 +1554,7 @@ paths:
description: Bech32 AccAddress of Delegator
required: true
type: string
x-example: cosmos167w96tdvmazakdwkw2u57227eduula2cy572lf
get:
summary: Get the rewards withdrawal address
description: Get the delegations' rewards withdrawal address. This is the address in which the user will receive the reward funds
@@ -1565,6 +1607,7 @@ paths:
description: Bech32 OperatorAddress of validator
required: true
type: string
x-example: cosmosvaloper1qwl879nx9t6kef4supyazayf7vjhennyh568ys
get:
summary: Validator distribution information
description: Query the distribution information of a single validator
@@ -1588,6 +1631,7 @@ paths:
description: Bech32 OperatorAddress of validator
required: true
type: string
x-example: cosmosvaloper1qwl879nx9t6kef4supyazayf7vjhennyh568ys
get:
summary: Fee distribution outstanding rewards of a single validator
tags:
@@ -1610,6 +1654,7 @@ paths:
description: Bech32 OperatorAddress of validator
required: true
type: string
x-example: cosmosvaloper1qwl879nx9t6kef4supyazayf7vjhennyh568ys
get:
summary: Commission and self-delegation rewards of a single validator
description: Query the commission and self-delegation rewards of validator.
@@ -1691,6 +1736,54 @@ paths:
type: string
500:
description: Internal Server Error
/minting/parameters:
get:
summary: Minting module parameters
produces:
- application/json
responses:
200:
description: OK
schema:
properties:
mint_denom:
type: string
inflation_rate_change:
type: string
inflation_max:
type: string
inflation_min:
type: string
goal_bonded:
type: string
blocks_per_year:
type: integer
500:
description: Internal Server Error
/minting/inflation:
get:
summary: Current minting inflation value
produces:
- application/json
responses:
200:
description: OK
schema:
type: string
500:
description: Internal Server Error
/minting/annual-provisions:
get:
summary: Current minting annual provisions value
produces:
- application/json
responses:
200:
description: OK
schema:
type: string
500:
description: Internal Server Error
definitions:
CheckTxResult:
type: object
+2
View File
@@ -42,6 +42,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/gov"
govrest "github.com/cosmos/cosmos-sdk/x/gov/client/rest"
gcutils "github.com/cosmos/cosmos-sdk/x/gov/client/utils"
mintrest "github.com/cosmos/cosmos-sdk/x/mint/client/rest"
"github.com/cosmos/cosmos-sdk/x/slashing"
slashingrest "github.com/cosmos/cosmos-sdk/x/slashing/client/rest"
"github.com/cosmos/cosmos-sdk/x/staking"
@@ -411,6 +412,7 @@ func registerRoutes(rs *RestServer) {
stakingrest.RegisterRoutes(rs.CliCtx, rs.Mux, rs.Cdc, rs.KeyBase)
slashingrest.RegisterRoutes(rs.CliCtx, rs.Mux, rs.Cdc, rs.KeyBase)
govrest.RegisterRoutes(rs.CliCtx, rs.Mux, rs.Cdc)
mintrest.RegisterRoutes(rs.CliCtx, rs.Mux, rs.Cdc)
}
// Request makes a test LCD test request. It returns a response object and a