Merge PR #5790: Standarize the representation of Governance param changes on cli requests.
This commit is contained in:
commit
241894adf5
@ -44,6 +44,7 @@ balances or a single balance by denom when the `denom` query parameter is presen
|
||||
* (client) [\#5640](https://github.com/cosmos/cosmos-sdk/pull/5640) The rest server endpoint `/swagger-ui/` is replaced by ´/´.
|
||||
* (x/auth) [\#5702](https://github.com/cosmos/cosmos-sdk/pull/5702) The `x/auth` querier route has changed from `"acc"` to `"auth"`.
|
||||
* (store/types) [\#5730](https://github.com/cosmos/cosmos-sdk/pull/5730) store.types.Cp() is removed in favour of types.CopyBytes().
|
||||
* (client) [\#5640](https://github.com/cosmos/cosmos-sdk/issues/5783) Unify all coins representations on JSON client requests for governance proposals.
|
||||
* [\#5785](https://github.com/cosmos/cosmos-sdk/issues/5785) JSON strings coerced to valid UTF-8 bytes at JSON marshalling time
|
||||
are now replaced by human-readable expressions. This change can potentially break compatibility with all those client side tools
|
||||
that parse log messages.
|
||||
|
||||
@ -220,18 +220,8 @@ Where proposal.json contains:
|
||||
"title": "Community Pool Spend",
|
||||
"description": "Pay me some Atoms!",
|
||||
"recipient": "cosmos1s5afhd6gxevu37mkqcvvsj8qeylhn0rz46zdlq",
|
||||
"amount": [
|
||||
{
|
||||
"denom": "stake",
|
||||
"amount": "10000"
|
||||
}
|
||||
],
|
||||
"deposit": [
|
||||
{
|
||||
"denom": "stake",
|
||||
"amount": "10000"
|
||||
}
|
||||
]
|
||||
"amount": "1000stake",
|
||||
"deposit": "1000stake"
|
||||
}
|
||||
`,
|
||||
version.ClientName,
|
||||
@ -248,9 +238,18 @@ Where proposal.json contains:
|
||||
}
|
||||
|
||||
from := cliCtx.GetFromAddress()
|
||||
content := types.NewCommunityPoolSpendProposal(proposal.Title, proposal.Description, proposal.Recipient, proposal.Amount)
|
||||
|
||||
msg := gov.NewMsgSubmitProposal(content, proposal.Deposit, from)
|
||||
amount, err := sdk.ParseCoins(proposal.Amount)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
content := types.NewCommunityPoolSpendProposal(proposal.Title, proposal.Description, proposal.Recipient, amount)
|
||||
|
||||
deposit, err := sdk.ParseCoins(proposal.Deposit)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
msg := gov.NewMsgSubmitProposal(content, deposit, from)
|
||||
if err := msg.ValidateBasic(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@ -1,8 +1,11 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/tendermint/tendermint/crypto/secp256k1"
|
||||
|
||||
@ -77,3 +80,30 @@ func Test_splitAndCall_Splitting(t *testing.T) {
|
||||
assert.NoError(t, err, "")
|
||||
assert.Equal(t, 3, callCount)
|
||||
}
|
||||
|
||||
func TestParseProposal(t *testing.T) {
|
||||
cdc := codec.New()
|
||||
okJSON, err := ioutil.TempFile("", "proposal")
|
||||
require.Nil(t, err, "unexpected error")
|
||||
okJSON.WriteString(`
|
||||
{
|
||||
"title": "Community Pool Spend",
|
||||
"description": "Pay me some Atoms!",
|
||||
"recipient": "cosmos1s5afhd6gxevu37mkqcvvsj8qeylhn0rz46zdlq",
|
||||
"amount": "1000stake",
|
||||
"deposit": "1000stake"
|
||||
}
|
||||
`)
|
||||
|
||||
proposal, err := ParseCommunityPoolSpendProposalJSON(cdc, okJSON.Name())
|
||||
require.NoError(t, err)
|
||||
|
||||
addr, err := sdk.AccAddressFromBech32("cosmos1s5afhd6gxevu37mkqcvvsj8qeylhn0rz46zdlq")
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Equal(t, "Community Pool Spend", proposal.Title)
|
||||
require.Equal(t, "Pay me some Atoms!", proposal.Description)
|
||||
require.Equal(t, addr, proposal.Recipient)
|
||||
require.Equal(t, "1000stake", proposal.Deposit)
|
||||
require.Equal(t, "1000stake", proposal.Amount)
|
||||
}
|
||||
|
||||
@ -13,8 +13,8 @@ type (
|
||||
Title string `json:"title" yaml:"title"`
|
||||
Description string `json:"description" yaml:"description"`
|
||||
Recipient sdk.AccAddress `json:"recipient" yaml:"recipient"`
|
||||
Amount sdk.Coins `json:"amount" yaml:"amount"`
|
||||
Deposit sdk.Coins `json:"deposit" yaml:"deposit"`
|
||||
Amount string `json:"amount" yaml:"amount"`
|
||||
Deposit string `json:"deposit" yaml:"deposit"`
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@ -53,12 +53,7 @@ Where proposal.json contains:
|
||||
"value": 105
|
||||
}
|
||||
],
|
||||
"deposit": [
|
||||
{
|
||||
"denom": "stake",
|
||||
"amount": "10000"
|
||||
}
|
||||
]
|
||||
"deposit": "1000stake"
|
||||
}
|
||||
`,
|
||||
version.ClientName,
|
||||
@ -77,7 +72,12 @@ Where proposal.json contains:
|
||||
from := cliCtx.GetFromAddress()
|
||||
content := paramproposal.NewParameterChangeProposal(proposal.Title, proposal.Description, proposal.Changes.ToParamChanges())
|
||||
|
||||
msg := govtypes.NewMsgSubmitProposal(content, proposal.Deposit, from)
|
||||
deposit, err := sdk.ParseCoins(proposal.Deposit)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
msg := govtypes.NewMsgSubmitProposal(content, deposit, from)
|
||||
if err := msg.ValidateBasic(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
45
x/params/client/cli/tx_test.go
Normal file
45
x/params/client/cli/tx_test.go
Normal file
@ -0,0 +1,45 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/x/params/client/utils"
|
||||
)
|
||||
|
||||
func TestParseProposal(t *testing.T) {
|
||||
cdc := codec.New()
|
||||
okJSON, err := ioutil.TempFile("", "proposal")
|
||||
require.Nil(t, err, "unexpected error")
|
||||
okJSON.WriteString(`
|
||||
{
|
||||
"title": "Staking Param Change",
|
||||
"description": "Update max validators",
|
||||
"changes": [
|
||||
{
|
||||
"subspace": "staking",
|
||||
"key": "MaxValidators",
|
||||
"value": 1
|
||||
}
|
||||
],
|
||||
"deposit": "1000stake"
|
||||
}
|
||||
`)
|
||||
|
||||
proposal, err := utils.ParseParamChangeProposalJSON(cdc, okJSON.Name())
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Equal(t, "Staking Param Change", proposal.Title)
|
||||
require.Equal(t, "Update max validators", proposal.Description)
|
||||
require.Equal(t, "1000stake", proposal.Deposit)
|
||||
require.Equal(t, utils.ParamChangesJSON{
|
||||
{
|
||||
Subspace: "staking",
|
||||
Key: "MaxValidators",
|
||||
Value: []byte{0x31},
|
||||
},
|
||||
}, proposal.Changes)
|
||||
}
|
||||
@ -29,7 +29,7 @@ type (
|
||||
Title string `json:"title" yaml:"title"`
|
||||
Description string `json:"description" yaml:"description"`
|
||||
Changes ParamChangesJSON `json:"changes" yaml:"changes"`
|
||||
Deposit sdk.Coins `json:"deposit" yaml:"deposit"`
|
||||
Deposit string `json:"deposit" yaml:"deposit"`
|
||||
}
|
||||
|
||||
// ParamChangeProposalReq defines a parameter change proposal request body.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user