diff --git a/x/auth/client/rest/broadcast.go b/x/auth/client/rest/broadcast.go index 0a625d4400..9aff327fb9 100644 --- a/x/auth/client/rest/broadcast.go +++ b/x/auth/client/rest/broadcast.go @@ -11,8 +11,8 @@ import ( // BroadcastReq defines a tx broadcasting request. type BroadcastReq struct { - Tx types.StdTx `json:"tx"` - Mode string `json:"mode"` + Tx types.StdTx `json:"tx" yaml:"tx"` + Mode string `json:"mode" yaml:"mode"` } // BroadcastTxRequest implements a tx broadcasting handler that is responsible diff --git a/x/auth/client/rest/encode.go b/x/auth/client/rest/encode.go index 36e5469029..c1b7f739fd 100644 --- a/x/auth/client/rest/encode.go +++ b/x/auth/client/rest/encode.go @@ -12,7 +12,7 @@ import ( // EncodeResp defines a tx encoding response. type EncodeResp struct { - Tx string `json:"tx"` + Tx string `json:"tx" yaml:"tx"` } // EncodeTxRequestHandlerFn returns the encode tx REST handler. In particular, diff --git a/x/auth/client/utils/tx.go b/x/auth/client/utils/tx.go index 8445b0212a..0a5646eb7b 100644 --- a/x/auth/client/utils/tx.go +++ b/x/auth/client/utils/tx.go @@ -21,7 +21,7 @@ import ( // GasEstimateResponse defines a response definition for tx gas estimation. type GasEstimateResponse struct { - GasEstimate uint64 `json:"gas_estimate"` + GasEstimate uint64 `json:"gas_estimate" yaml:"gas_estimate"` } func (gr GasEstimateResponse) String() string { diff --git a/x/auth/test_common.go b/x/auth/test_common.go index eef914aebe..43496c5392 100644 --- a/x/auth/test_common.go +++ b/x/auth/test_common.go @@ -25,11 +25,10 @@ type testInput struct { // moduleAccount defines an account for modules that holds coins on a pool type moduleAccount struct { *types.BaseAccount - Name string `json:"name"` // name of the module - Permission string `json:"permission"` // permission of module account (minter/burner/holder) + Name string `json:"name" yaml:"name"` // name of the module + Permission string `json:"permission" yaml"permission"` // permission of module account (minter/burner/holder) } - // GetName returns the the name of the holder's module func (ma moduleAccount) GetName() string { return ma.Name @@ -40,7 +39,6 @@ func (ma moduleAccount) GetPermission() string { return ma.Permission } - func setupTestInput() testInput { db := dbm.NewMemDB() diff --git a/x/auth/types/account.go b/x/auth/types/account.go index f198419a11..daaad1ecda 100644 --- a/x/auth/types/account.go +++ b/x/auth/types/account.go @@ -22,11 +22,11 @@ var _ exported.Account = (*BaseAccount)(nil) // However one doesn't have to use BaseAccount as long as your struct // implements Account. type BaseAccount struct { - Address sdk.AccAddress `json:"address"` - Coins sdk.Coins `json:"coins"` - PubKey crypto.PubKey `json:"public_key"` - AccountNumber uint64 `json:"account_number"` - Sequence uint64 `json:"sequence"` + Address sdk.AccAddress `json:"address" yaml:"address"` + Coins sdk.Coins `json:"coins" yaml:"coins"` + PubKey crypto.PubKey `json:"public_key" yaml:"public_key"` + AccountNumber uint64 `json:"account_number" yaml:"account_number"` + Sequence uint64 `json:"sequence" yaml:"sequence"` } // NewBaseAccount creates a new BaseAccount object diff --git a/x/auth/types/genesis.go b/x/auth/types/genesis.go index 3cf059fb56..4c02e68f4e 100644 --- a/x/auth/types/genesis.go +++ b/x/auth/types/genesis.go @@ -6,7 +6,7 @@ import ( // GenesisState - all auth state that must be provided at genesis type GenesisState struct { - Params Params `json:"params"` + Params Params `json:"params" yaml:"params"` } // NewGenesisState - Create a new genesis state diff --git a/x/auth/types/params.go b/x/auth/types/params.go index ed0f488114..4d0768feac 100644 --- a/x/auth/types/params.go +++ b/x/auth/types/params.go @@ -33,11 +33,11 @@ var _ subspace.ParamSet = &Params{} // Params defines the parameters for the auth module. type Params struct { - MaxMemoCharacters uint64 `json:"max_memo_characters"` - TxSigLimit uint64 `json:"tx_sig_limit"` - TxSizeCostPerByte uint64 `json:"tx_size_cost_per_byte"` - SigVerifyCostED25519 uint64 `json:"sig_verify_cost_ed25519"` - SigVerifyCostSecp256k1 uint64 `json:"sig_verify_cost_secp256k1"` + MaxMemoCharacters uint64 `json:"max_memo_characters" yaml:"max_memo_characters"` + TxSigLimit uint64 `json:"tx_sig_limit" yaml:"tx_sig_limit"` + TxSizeCostPerByte uint64 `json:"tx_size_cost_per_byte" yaml:"tx_size_cost_per_byte"` + SigVerifyCostED25519 uint64 `json:"sig_verify_cost_ed25519" yaml:"sig_verify_cost_ed25519"` + SigVerifyCostSecp256k1 uint64 `json:"sig_verify_cost_secp256k1" yaml:"sig_verify_cost_secp256k1"` } // NewParams creates a new Params object diff --git a/x/auth/types/stdsignmsg.go b/x/auth/types/stdsignmsg.go index 889982811a..e018dac400 100644 --- a/x/auth/types/stdsignmsg.go +++ b/x/auth/types/stdsignmsg.go @@ -8,12 +8,12 @@ import ( // a Msg with the other requirements for a StdSignDoc before // it is signed. For use in the CLI. type StdSignMsg struct { - ChainID string `json:"chain_id"` - AccountNumber uint64 `json:"account_number"` - Sequence uint64 `json:"sequence"` - Fee StdFee `json:"fee"` - Msgs []sdk.Msg `json:"msgs"` - Memo string `json:"memo"` + ChainID string `json:"chain_id" yaml:"chain_id"` + AccountNumber uint64 `json:"account_number" yaml:"account_number"` + Sequence uint64 `json:"sequence" yaml:"sequence"` + Fee StdFee `json:"fee" yaml:"fee"` + Msgs []sdk.Msg `json:"msgs" yaml:"msgs"` + Memo string `json:"memo" yaml:"memo"` } // get message bytes diff --git a/x/auth/types/stdtx.go b/x/auth/types/stdtx.go index 18cdfaf0a0..9e71b1127d 100644 --- a/x/auth/types/stdtx.go +++ b/x/auth/types/stdtx.go @@ -6,6 +6,7 @@ import ( "github.com/tendermint/tendermint/crypto" "github.com/tendermint/tendermint/crypto/multisig" + yaml "gopkg.in/yaml.v2" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" @@ -20,10 +21,10 @@ var ( // StdTx is a standard way to wrap a Msg with Fee and Signatures. // NOTE: the first signature is the fee payer (Signatures must not be nil). type StdTx struct { - Msgs []sdk.Msg `json:"msg"` - Fee StdFee `json:"fee"` - Signatures []StdSignature `json:"signatures"` - Memo string `json:"memo"` + Msgs []sdk.Msg `json:"msg" yaml:"msg"` + Fee StdFee `json:"fee" yaml:"fee"` + Signatures []StdSignature `json:"signatures" yaml:"signatures"` + Memo string `json:"memo" yaml:"memo"` } func NewStdTx(msgs []sdk.Msg, fee StdFee, sigs []StdSignature, memo string) StdTx { @@ -112,8 +113,8 @@ func (tx StdTx) GetSignatures() []StdSignature { return tx.Signatures } // gas to be used by the transaction. The ratio yields an effective "gasprice", // which must be above some miminum to be accepted into the mempool. type StdFee struct { - Amount sdk.Coins `json:"amount"` - Gas uint64 `json:"gas"` + Amount sdk.Coins `json:"amount" yaml:"amount"` + Gas uint64 `json:"gas" yaml:"gas"` } // NewStdFee returns a new instance of StdFee @@ -157,12 +158,12 @@ func (fee StdFee) GasPrices() sdk.DecCoins { // and the Sequence numbers for each signature (prevent // inchain replay and enforce tx ordering per account). type StdSignDoc struct { - AccountNumber uint64 `json:"account_number"` - ChainID string `json:"chain_id"` - Fee json.RawMessage `json:"fee"` - Memo string `json:"memo"` - Msgs []json.RawMessage `json:"msgs"` - Sequence uint64 `json:"sequence"` + AccountNumber uint64 `json:"account_number" yaml:"account_number"` + ChainID string `json:"chain_id" yaml:"chain_id"` + Fee json.RawMessage `json:"fee" yaml:"fee"` + Memo string `json:"memo" yaml:"memo"` + Msgs []json.RawMessage `json:"msgs" yaml:"msgs"` + Sequence uint64 `json:"sequence" yaml:"sequence"` } // StdSignBytes returns the bytes to sign for a transaction. @@ -187,8 +188,8 @@ func StdSignBytes(chainID string, accnum uint64, sequence uint64, fee StdFee, ms // StdSignature represents a sig type StdSignature struct { - crypto.PubKey `json:"pub_key"` // optional - Signature []byte `json:"signature"` + crypto.PubKey `json:"pub_key" yaml:"pub_key"` // optional + Signature []byte `json:"signature" yaml:"signature"` } // DefaultTxDecoder logic for standard transaction decoding @@ -217,3 +218,32 @@ func DefaultTxEncoder(cdc *codec.Codec) sdk.TxEncoder { return cdc.MarshalBinaryLengthPrefixed(tx) } } + +// MarshalYAML returns the YAML representation of the signature. +func (ss StdSignature) MarshalYAML() (interface{}, error) { + var ( + bz []byte + pubkey string + err error + ) + + if ss.PubKey != nil { + pubkey, err = sdk.Bech32ifyAccPub(ss.PubKey) + if err != nil { + return nil, err + } + } + + bz, err = yaml.Marshal(struct { + PubKey string + Signature string + }{ + PubKey: pubkey, + Signature: fmt.Sprintf("%s", ss.Signature), + }) + if err != nil { + return nil, err + } + + return string(bz), err +} diff --git a/x/auth/types/stdtx_test.go b/x/auth/types/stdtx_test.go index d6315d5fb9..661db3fd47 100644 --- a/x/auth/types/stdtx_test.go +++ b/x/auth/types/stdtx_test.go @@ -9,6 +9,7 @@ import ( "github.com/tendermint/tendermint/crypto" "github.com/tendermint/tendermint/crypto/ed25519" "github.com/tendermint/tendermint/libs/log" + yaml "gopkg.in/yaml.v2" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" @@ -133,3 +134,31 @@ func TestDefaultTxEncoder(t *testing.T) { require.NoError(t, err) require.Equal(t, cdcBytes, encoderBytes) } + +func TestStdSignatureMarshalYAML(t *testing.T) { + _, pubKey, _ := KeyTestPubAddr() + + testCases := []struct { + sig StdSignature + output string + }{ + { + StdSignature{}, + "|\n pubkey: \"\"\n signature: \"\"\n", + }, + { + StdSignature{PubKey: pubKey, Signature: []byte("dummySig")}, + fmt.Sprintf("|\n pubkey: %s\n signature: dummySig\n", sdk.MustBech32ifyAccPub(pubKey)), + }, + { + StdSignature{PubKey: pubKey, Signature: nil}, + fmt.Sprintf("|\n pubkey: %s\n signature: \"\"\n", sdk.MustBech32ifyAccPub(pubKey)), + }, + } + + for i, tc := range testCases { + bz, err := yaml.Marshal(tc.sig) + require.NoError(t, err) + require.Equal(t, tc.output, string(bz), "test case #%d", i) + } +} diff --git a/x/bank/client/rest/tx.go b/x/bank/client/rest/tx.go index 9522167abf..10ac15abc7 100644 --- a/x/bank/client/rest/tx.go +++ b/x/bank/client/rest/tx.go @@ -21,8 +21,8 @@ func RegisterRoutes(cliCtx context.CLIContext, r *mux.Router) { // SendReq defines the properties of a send request's body. type SendReq struct { - BaseReq rest.BaseReq `json:"base_req"` - Amount sdk.Coins `json:"amount"` + BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"` + Amount sdk.Coins `json:"amount" yaml:"amount"` } // SendRequestHandlerFn - http request handler to send coins to a address. diff --git a/x/bank/genesis.go b/x/bank/genesis.go index 1bdf4e7ff9..bfd08153bb 100644 --- a/x/bank/genesis.go +++ b/x/bank/genesis.go @@ -6,7 +6,7 @@ import ( // GenesisState is the bank state that must be provided at genesis. type GenesisState struct { - SendEnabled bool `json:"send_enabled"` + SendEnabled bool `json:"send_enabled" yaml:"send_enabled"` } // NewGenesisState creates a new genesis state. diff --git a/x/bank/internal/types/msgs.go b/x/bank/internal/types/msgs.go index 0f3d8e1fef..58336e24d9 100644 --- a/x/bank/internal/types/msgs.go +++ b/x/bank/internal/types/msgs.go @@ -9,9 +9,9 @@ const RouterKey = ModuleName // MsgSend - high level transaction of the coin module type MsgSend struct { - FromAddress sdk.AccAddress `json:"from_address"` - ToAddress sdk.AccAddress `json:"to_address"` - Amount sdk.Coins `json:"amount"` + FromAddress sdk.AccAddress `json:"from_address" yaml:"from_address"` + ToAddress sdk.AccAddress `json:"to_address" yaml:"to_address"` + Amount sdk.Coins `json:"amount" yaml:"amount"` } var _ sdk.Msg = MsgSend{} @@ -56,8 +56,8 @@ func (msg MsgSend) GetSigners() []sdk.AccAddress { // MsgMultiSend - high level transaction of the coin module type MsgMultiSend struct { - Inputs []Input `json:"inputs"` - Outputs []Output `json:"outputs"` + Inputs []Input `json:"inputs" yaml:"inputs"` + Outputs []Output `json:"outputs" yaml:"outputs"` } var _ sdk.Msg = MsgMultiSend{} @@ -103,8 +103,8 @@ func (msg MsgMultiSend) GetSigners() []sdk.AccAddress { // Input models transaction input type Input struct { - Address sdk.AccAddress `json:"address"` - Coins sdk.Coins `json:"coins"` + Address sdk.AccAddress `json:"address" yaml:"address"` + Coins sdk.Coins `json:"coins" yaml:"coins"` } // ValidateBasic - validate transaction input @@ -131,8 +131,8 @@ func NewInput(addr sdk.AccAddress, coins sdk.Coins) Input { // Output models transaction outputs type Output struct { - Address sdk.AccAddress `json:"address"` - Coins sdk.Coins `json:"coins"` + Address sdk.AccAddress `json:"address" yaml:"address"` + Coins sdk.Coins `json:"coins" yaml:"coins"` } // ValidateBasic - validate transaction output diff --git a/x/crisis/internal/types/genesis.go b/x/crisis/internal/types/genesis.go index 921f4cdf02..b38fd67166 100644 --- a/x/crisis/internal/types/genesis.go +++ b/x/crisis/internal/types/genesis.go @@ -8,7 +8,7 @@ import ( // GenesisState - crisis genesis state type GenesisState struct { - ConstantFee sdk.Coin `json:"constant_fee"` + ConstantFee sdk.Coin `json:"constant_fee" yaml:"constant_fee"` } // NewGenesisState creates a new GenesisState object diff --git a/x/crisis/internal/types/msgs.go b/x/crisis/internal/types/msgs.go index e14b152830..e16ffb528e 100644 --- a/x/crisis/internal/types/msgs.go +++ b/x/crisis/internal/types/msgs.go @@ -6,9 +6,9 @@ import ( // MsgVerifyInvariant - message struct to verify a particular invariance type MsgVerifyInvariant struct { - Sender sdk.AccAddress `json:"sender"` - InvariantModuleName string `json:"invariant_module_name"` - InvariantRoute string `json:"invariant_route"` + Sender sdk.AccAddress `json:"sender" yaml:"sender"` + InvariantModuleName string `json:"invariant_module_name" yaml:"invariant_module_name"` + InvariantRoute string `json:"invariant_route" yaml:"invariant_route"` } // ensure Msg interface compliance at compile time diff --git a/x/distribution/client/cli/utils.go b/x/distribution/client/cli/utils.go index a9b52973af..2860162502 100644 --- a/x/distribution/client/cli/utils.go +++ b/x/distribution/client/cli/utils.go @@ -10,11 +10,11 @@ import ( type ( // CommunityPoolSpendProposalJSON defines a CommunityPoolSpendProposal with a deposit CommunityPoolSpendProposalJSON struct { - Title string `json:"title"` - Description string `json:"description"` - Recipient sdk.AccAddress `json:"recipient"` - Amount sdk.Coins `json:"amount"` - Deposit sdk.Coins `json:"deposit"` + 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"` } ) diff --git a/x/distribution/client/rest/query.go b/x/distribution/client/rest/query.go index 31a0feca57..15b5c7fe07 100644 --- a/x/distribution/client/rest/query.go +++ b/x/distribution/client/rest/query.go @@ -129,9 +129,9 @@ func delegatorWithdrawalAddrHandlerFn(cliCtx context.CLIContext, queryRoute stri // ValidatorDistInfo defines the properties of // validator distribution information response. type ValidatorDistInfo struct { - OperatorAddress sdk.AccAddress `json:"operator_address"` - SelfBondRewards sdk.DecCoins `json:"self_bond_rewards"` - ValidatorCommission types.ValidatorAccumulatedCommission `json:"val_commission"` + OperatorAddress sdk.AccAddress `json:"operator_address" yaml:"operator_address"` + SelfBondRewards sdk.DecCoins `json:"self_bond_rewards" yaml:"self_bond_rewards"` + ValidatorCommission types.ValidatorAccumulatedCommission `json:"val_commission" yaml:"val_commission"` } // NewValidatorDistInfo creates a new instance of ValidatorDistInfo. diff --git a/x/distribution/client/rest/tx.go b/x/distribution/client/rest/tx.go index 7f1410b4d2..6dbb6f26ea 100644 --- a/x/distribution/client/rest/tx.go +++ b/x/distribution/client/rest/tx.go @@ -43,12 +43,12 @@ func registerTxRoutes(cliCtx context.CLIContext, r *mux.Router, queryRoute strin type ( withdrawRewardsReq struct { - BaseReq rest.BaseReq `json:"base_req"` + BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"` } setWithdrawalAddrReq struct { - BaseReq rest.BaseReq `json:"base_req"` - WithdrawAddress sdk.AccAddress `json:"withdraw_address"` + BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"` + WithdrawAddress sdk.AccAddress `json:"withdraw_address" yaml:"withdraw_address"` } ) diff --git a/x/distribution/client/rest/utils.go b/x/distribution/client/rest/utils.go index 29e0830e76..3f7a3d0020 100644 --- a/x/distribution/client/rest/utils.go +++ b/x/distribution/client/rest/utils.go @@ -8,13 +8,13 @@ import ( type ( // CommunityPoolSpendProposalReq defines a community pool spend proposal request body. CommunityPoolSpendProposalReq struct { - BaseReq rest.BaseReq `json:"base_req"` + BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"` - Title string `json:"title"` - Description string `json:"description"` - Recipient sdk.AccAddress `json:"recipient"` - Amount sdk.Coins `json:"amount"` - Proposer sdk.AccAddress `json:"proposer"` - Deposit sdk.Coins `json:"deposit"` + 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"` + Proposer sdk.AccAddress `json:"proposer" yaml:"proposer"` + Deposit sdk.Coins `json:"deposit" yaml:"deposit"` } ) diff --git a/x/distribution/types/delegator.go b/x/distribution/types/delegator.go index fcbc48560a..8c9e0b9933 100644 --- a/x/distribution/types/delegator.go +++ b/x/distribution/types/delegator.go @@ -12,9 +12,9 @@ import ( // delegators within the validator may be left with less than a full token, // thus sdk.Dec is used type DelegatorStartingInfo struct { - PreviousPeriod uint64 `json:"previous_period"` // period at which the delegation should withdraw starting from - Stake sdk.Dec `json:"stake"` // amount of staking token delegated - Height uint64 `json:"creation_height"` // height at which delegation was created + PreviousPeriod uint64 `json:"previous_period" yaml:"previous_period"` // period at which the delegation should withdraw starting from + Stake sdk.Dec `json:"stake" yaml:"stake"` // amount of staking token delegated + Height uint64 `json:"creation_height" yaml:"creation_height"` // height at which delegation was created } // create a new DelegatorStartingInfo diff --git a/x/distribution/types/fee_pool.go b/x/distribution/types/fee_pool.go index caf9905e1d..b542ced7be 100644 --- a/x/distribution/types/fee_pool.go +++ b/x/distribution/types/fee_pool.go @@ -8,7 +8,7 @@ import ( // global fee pool for distribution type FeePool struct { - CommunityPool sdk.DecCoins `json:"community_pool"` // pool for community funds yet to be spent + CommunityPool sdk.DecCoins `json:"community_pool" yaml:"community_pool"` // pool for community funds yet to be spent } // zero fee pool diff --git a/x/distribution/types/genesis.go b/x/distribution/types/genesis.go index 1e27cff3f1..db4f119668 100644 --- a/x/distribution/types/genesis.go +++ b/x/distribution/types/genesis.go @@ -9,65 +9,65 @@ import ( // the address for where distributions rewards are withdrawn to by default // this struct is only used at genesis to feed in default withdraw addresses type DelegatorWithdrawInfo struct { - DelegatorAddress sdk.AccAddress `json:"delegator_address"` - WithdrawAddress sdk.AccAddress `json:"withdraw_address"` + DelegatorAddress sdk.AccAddress `json:"delegator_address" yaml:"delegator_address"` + WithdrawAddress sdk.AccAddress `json:"withdraw_address" yaml:"withdraw_address"` } // used for import/export via genesis json type ValidatorOutstandingRewardsRecord struct { - ValidatorAddress sdk.ValAddress `json:"validator_address"` - OutstandingRewards sdk.DecCoins `json:"outstanding_rewards"` + ValidatorAddress sdk.ValAddress `json:"validator_address" yaml:"validator_address"` + OutstandingRewards sdk.DecCoins `json:"outstanding_rewards" yaml:"outstanding_rewards"` } // used for import / export via genesis json type ValidatorAccumulatedCommissionRecord struct { - ValidatorAddress sdk.ValAddress `json:"validator_address"` - Accumulated ValidatorAccumulatedCommission `json:"accumulated"` + ValidatorAddress sdk.ValAddress `json:"validator_address" yaml:"validator_address"` + Accumulated ValidatorAccumulatedCommission `json:"accumulated" yaml:"accumulated"` } // used for import / export via genesis json type ValidatorHistoricalRewardsRecord struct { - ValidatorAddress sdk.ValAddress `json:"validator_address"` - Period uint64 `json:"period"` - Rewards ValidatorHistoricalRewards `json:"rewards"` + ValidatorAddress sdk.ValAddress `json:"validator_address" yaml:"validator_address"` + Period uint64 `json:"period" yaml:"period"` + Rewards ValidatorHistoricalRewards `json:"rewards" yaml:"rewards"` } // used for import / export via genesis json type ValidatorCurrentRewardsRecord struct { - ValidatorAddress sdk.ValAddress `json:"validator_address"` - Rewards ValidatorCurrentRewards `json:"rewards"` + ValidatorAddress sdk.ValAddress `json:"validator_address" yaml:"validator_address"` + Rewards ValidatorCurrentRewards `json:"rewards" yaml:"rewards"` } // used for import / export via genesis json type DelegatorStartingInfoRecord struct { - DelegatorAddress sdk.AccAddress `json:"delegator_address"` - ValidatorAddress sdk.ValAddress `json:"validator_address"` - StartingInfo DelegatorStartingInfo `json:"starting_info"` + DelegatorAddress sdk.AccAddress `json:"delegator_address" yaml:"delegator_address"` + ValidatorAddress sdk.ValAddress `json:"validator_address" yaml:"validator_address"` + StartingInfo DelegatorStartingInfo `json:"starting_info" yaml:"starting_info"` } // used for import / export via genesis json type ValidatorSlashEventRecord struct { - ValidatorAddress sdk.ValAddress `json:"validator_address"` - Height uint64 `json:"height"` - Period uint64 `json:"period"` - Event ValidatorSlashEvent `json:"validator_slash_event"` + ValidatorAddress sdk.ValAddress `json:"validator_address" yaml:"validator_address"` + Height uint64 `json:"height" yaml:"height"` + Period uint64 `json:"period" yaml:"period"` + Event ValidatorSlashEvent `json:"validator_slash_event" yaml:"validator_slash_event"` } // GenesisState - all distribution state that must be provided at genesis type GenesisState struct { - FeePool FeePool `json:"fee_pool"` - CommunityTax sdk.Dec `json:"community_tax"` - BaseProposerReward sdk.Dec `json:"base_proposer_reward"` - BonusProposerReward sdk.Dec `json:"bonus_proposer_reward"` - WithdrawAddrEnabled bool `json:"withdraw_addr_enabled"` - DelegatorWithdrawInfos []DelegatorWithdrawInfo `json:"delegator_withdraw_infos"` - PreviousProposer sdk.ConsAddress `json:"previous_proposer"` - OutstandingRewards []ValidatorOutstandingRewardsRecord `json:"outstanding_rewards"` - ValidatorAccumulatedCommissions []ValidatorAccumulatedCommissionRecord `json:"validator_accumulated_commissions"` - ValidatorHistoricalRewards []ValidatorHistoricalRewardsRecord `json:"validator_historical_rewards"` - ValidatorCurrentRewards []ValidatorCurrentRewardsRecord `json:"validator_current_rewards"` - DelegatorStartingInfos []DelegatorStartingInfoRecord `json:"delegator_starting_infos"` - ValidatorSlashEvents []ValidatorSlashEventRecord `json:"validator_slash_events"` + FeePool FeePool `json:"fee_pool" yaml:"fee_pool"` + CommunityTax sdk.Dec `json:"community_tax" yaml:"community_tax"` + BaseProposerReward sdk.Dec `json:"base_proposer_reward" yaml:"base_proposer_reward"` + BonusProposerReward sdk.Dec `json:"bonus_proposer_reward" yaml:"bonus_proposer_reward"` + WithdrawAddrEnabled bool `json:"withdraw_addr_enabled" yaml:"withdraw_addr_enabled"` + DelegatorWithdrawInfos []DelegatorWithdrawInfo `json:"delegator_withdraw_infos" yaml:"delegator_withdraw_infos"` + PreviousProposer sdk.ConsAddress `json:"previous_proposer" yaml:"previous_proposer"` + OutstandingRewards []ValidatorOutstandingRewardsRecord `json:"outstanding_rewards" yaml:"outstanding_rewards"` + ValidatorAccumulatedCommissions []ValidatorAccumulatedCommissionRecord `json:"validator_accumulated_commissions" yaml:"validator_accumulated_commissions"` + ValidatorHistoricalRewards []ValidatorHistoricalRewardsRecord `json:"validator_historical_rewards" yaml:"validator_historical_rewards"` + ValidatorCurrentRewards []ValidatorCurrentRewardsRecord `json:"validator_current_rewards" yaml:"validator_current_rewards"` + DelegatorStartingInfos []DelegatorStartingInfoRecord `json:"delegator_starting_infos" yaml:"delegator_starting_infos"` + ValidatorSlashEvents []ValidatorSlashEventRecord `json:"validator_slash_events" yaml:"validator_slash_events"` } func NewGenesisState(feePool FeePool, communityTax, baseProposerReward, bonusProposerReward sdk.Dec, diff --git a/x/distribution/types/msg.go b/x/distribution/types/msg.go index ca96357be5..a5eb8422be 100644 --- a/x/distribution/types/msg.go +++ b/x/distribution/types/msg.go @@ -10,8 +10,8 @@ var _, _, _ sdk.Msg = &MsgSetWithdrawAddress{}, &MsgWithdrawDelegatorReward{}, & // msg struct for changing the withdraw address for a delegator (or validator self-delegation) type MsgSetWithdrawAddress struct { - DelegatorAddress sdk.AccAddress `json:"delegator_address"` - WithdrawAddress sdk.AccAddress `json:"withdraw_address"` + DelegatorAddress sdk.AccAddress `json:"delegator_address" yaml:"delegator_address"` + WithdrawAddress sdk.AccAddress `json:"withdraw_address" yaml:"withdraw_address"` } func NewMsgSetWithdrawAddress(delAddr, withdrawAddr sdk.AccAddress) MsgSetWithdrawAddress { @@ -48,8 +48,8 @@ func (msg MsgSetWithdrawAddress) ValidateBasic() sdk.Error { // msg struct for delegation withdraw from a single validator type MsgWithdrawDelegatorReward struct { - DelegatorAddress sdk.AccAddress `json:"delegator_address"` - ValidatorAddress sdk.ValAddress `json:"validator_address"` + DelegatorAddress sdk.AccAddress `json:"delegator_address" yaml:"delegator_address"` + ValidatorAddress sdk.ValAddress `json:"validator_address" yaml:"validator_address"` } func NewMsgWithdrawDelegatorReward(delAddr sdk.AccAddress, valAddr sdk.ValAddress) MsgWithdrawDelegatorReward { @@ -86,7 +86,7 @@ func (msg MsgWithdrawDelegatorReward) ValidateBasic() sdk.Error { // msg struct for validator withdraw type MsgWithdrawValidatorCommission struct { - ValidatorAddress sdk.ValAddress `json:"validator_address"` + ValidatorAddress sdk.ValAddress `json:"validator_address" yaml:"validator_address"` } func NewMsgWithdrawValidatorCommission(valAddr sdk.ValAddress) MsgWithdrawValidatorCommission { diff --git a/x/distribution/types/proposal.go b/x/distribution/types/proposal.go index 068876841a..0562d81df1 100644 --- a/x/distribution/types/proposal.go +++ b/x/distribution/types/proposal.go @@ -23,10 +23,10 @@ func init() { // CommunityPoolSpendProposal spends from the community pool type CommunityPoolSpendProposal struct { - Title string `json:"title"` - Description string `json:"description"` - Recipient sdk.AccAddress `json:"recipient"` - Amount sdk.Coins `json:"amount"` + 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"` } // NewCommunityPoolSpendProposal creates a new community pool spned proposal. diff --git a/x/distribution/types/querier.go b/x/distribution/types/querier.go index 1e4bf56dc6..32ed642ddf 100644 --- a/x/distribution/types/querier.go +++ b/x/distribution/types/querier.go @@ -22,7 +22,7 @@ const ( // params for query 'custom/distr/validator_outstanding_rewards' type QueryValidatorOutstandingRewardsParams struct { - ValidatorAddress sdk.ValAddress `json:"validator_address"` + ValidatorAddress sdk.ValAddress `json:"validator_address" yaml:"validator_address"` } // creates a new instance of QueryValidatorOutstandingRewardsParams @@ -34,7 +34,7 @@ func NewQueryValidatorOutstandingRewardsParams(validatorAddr sdk.ValAddress) Que // params for query 'custom/distr/validator_commission' type QueryValidatorCommissionParams struct { - ValidatorAddress sdk.ValAddress `json:"validator_address"` + ValidatorAddress sdk.ValAddress `json:"validator_address" yaml:"validator_address"` } // creates a new instance of QueryValidatorCommissionParams @@ -46,9 +46,9 @@ func NewQueryValidatorCommissionParams(validatorAddr sdk.ValAddress) QueryValida // params for query 'custom/distr/validator_slashes' type QueryValidatorSlashesParams struct { - ValidatorAddress sdk.ValAddress `json:"validator_address"` - StartingHeight uint64 `json:"starting_height"` - EndingHeight uint64 `json:"ending_height"` + ValidatorAddress sdk.ValAddress `json:"validator_address" yaml:"validator_address"` + StartingHeight uint64 `json:"starting_height" yaml:"starting_height"` + EndingHeight uint64 `json:"ending_height" yaml:"ending_height"` } // creates a new instance of QueryValidatorSlashesParams @@ -62,8 +62,8 @@ func NewQueryValidatorSlashesParams(validatorAddr sdk.ValAddress, startingHeight // params for query 'custom/distr/delegation_rewards' type QueryDelegationRewardsParams struct { - DelegatorAddress sdk.AccAddress `json:"delegator_address"` - ValidatorAddress sdk.ValAddress `json:"validator_address"` + DelegatorAddress sdk.AccAddress `json:"delegator_address" yaml:"delegator_address"` + ValidatorAddress sdk.ValAddress `json:"validator_address" yaml:"validator_address"` } // creates a new instance of QueryDelegationRewardsParams @@ -76,7 +76,7 @@ func NewQueryDelegationRewardsParams(delegatorAddr sdk.AccAddress, validatorAddr // params for query 'custom/distr/delegator_total_rewards' and 'custom/distr/delegator_validators' type QueryDelegatorParams struct { - DelegatorAddress sdk.AccAddress `json:"delegator_address"` + DelegatorAddress sdk.AccAddress `json:"delegator_address" yaml:"delegator_address"` } // creates a new instance of QueryDelegationRewardsParams @@ -88,7 +88,7 @@ func NewQueryDelegatorParams(delegatorAddr sdk.AccAddress) QueryDelegatorParams // params for query 'custom/distr/withdraw_addr' type QueryDelegatorWithdrawAddrParams struct { - DelegatorAddress sdk.AccAddress `json:"delegator_address"` + DelegatorAddress sdk.AccAddress `json:"delegator_address" yaml:"delegator_address"` } // NewQueryDelegatorWithdrawAddrParams creates a new instance of QueryDelegatorWithdrawAddrParams. diff --git a/x/distribution/types/query.go b/x/distribution/types/query.go index 7eeadaa480..d286631409 100644 --- a/x/distribution/types/query.go +++ b/x/distribution/types/query.go @@ -10,8 +10,8 @@ import ( // QueryDelegatorTotalRewardsResponse defines the properties of // QueryDelegatorTotalRewards query's response. type QueryDelegatorTotalRewardsResponse struct { - Rewards []DelegationDelegatorReward `json:"rewards"` - Total sdk.DecCoins `json:"total"` + Rewards []DelegationDelegatorReward `json:"rewards" yaml:"rewards"` + Total sdk.DecCoins `json:"total" yaml:"total"` } // NewQueryDelegatorTotalRewardsResponse constructs a QueryDelegatorTotalRewardsResponse @@ -35,8 +35,8 @@ func (res QueryDelegatorTotalRewardsResponse) String() string { // DelegationDelegatorReward defines the properties // of a delegator's delegation reward. type DelegationDelegatorReward struct { - ValidatorAddress sdk.ValAddress `json:"validator_address"` - Reward sdk.DecCoins `json:"reward"` + ValidatorAddress sdk.ValAddress `json:"validator_address" yaml:"validator_address"` + Reward sdk.DecCoins `json:"reward" yaml:"reward"` } // NewDelegationDelegatorReward constructs a DelegationDelegatorReward. diff --git a/x/distribution/types/validator.go b/x/distribution/types/validator.go index a7fc0dd2a9..9ff1f4c9aa 100644 --- a/x/distribution/types/validator.go +++ b/x/distribution/types/validator.go @@ -19,8 +19,8 @@ import ( // + number of slashes which ended the associated period (and might need to read that record) // + one per validator for the zeroeth period, set on initialization type ValidatorHistoricalRewards struct { - CumulativeRewardRatio sdk.DecCoins `json:"cumulative_reward_ratio"` - ReferenceCount uint16 `json:"reference_count"` + CumulativeRewardRatio sdk.DecCoins `json:"cumulative_reward_ratio" yaml:"cumulative_reward_ratio"` + ReferenceCount uint16 `json:"reference_count" yaml:"reference_count"` } // create a new ValidatorHistoricalRewards @@ -35,8 +35,8 @@ func NewValidatorHistoricalRewards(cumulativeRewardRatio sdk.DecCoins, reference // kept as a running counter and incremented each block // as long as the validator's tokens remain constant type ValidatorCurrentRewards struct { - Rewards sdk.DecCoins `json:"rewards"` // current rewards - Period uint64 `json:"period"` // current period + Rewards sdk.DecCoins `json:"rewards" yaml:"rewards"` // current rewards + Period uint64 `json:"period" yaml:"period"` // current period } // create a new ValidatorCurrentRewards @@ -61,8 +61,8 @@ func InitialValidatorAccumulatedCommission() ValidatorAccumulatedCommission { // needed to calculate appropriate amounts of staking token // for delegations which withdraw after a slash has occurred type ValidatorSlashEvent struct { - ValidatorPeriod uint64 `json:"validator_period"` // period when the slash occurred - Fraction sdk.Dec `json:"fraction"` // slash fraction + ValidatorPeriod uint64 `json:"validator_period" yaml:"validator_period"` // period when the slash occurred + Fraction sdk.Dec `json:"fraction" yaml:"fraction"` // slash fraction } // create a new ValidatorSlashEvent diff --git a/x/genaccounts/genesis_account.go b/x/genaccounts/genesis_account.go index bb5dc8ab74..d4fd99a785 100644 --- a/x/genaccounts/genesis_account.go +++ b/x/genaccounts/genesis_account.go @@ -14,21 +14,21 @@ import ( // GenesisAccount is a struct for account initialization used exclusively during genesis type GenesisAccount struct { - Address sdk.AccAddress `json:"address"` - Coins sdk.Coins `json:"coins"` - Sequence uint64 `json:"sequence_number"` - AccountNumber uint64 `json:"account_number"` + Address sdk.AccAddress `json:"address" yaml:"address"` + Coins sdk.Coins `json:"coins" yaml:"coins"` + Sequence uint64 `json:"sequence_number" yaml:"sequence_number"` + AccountNumber uint64 `json:"account_number" yaml:"account_number"` // vesting account fields - OriginalVesting sdk.Coins `json:"original_vesting"` // total vesting coins upon initialization - DelegatedFree sdk.Coins `json:"delegated_free"` // delegated vested coins at time of delegation - DelegatedVesting sdk.Coins `json:"delegated_vesting"` // delegated vesting coins at time of delegation - StartTime int64 `json:"start_time"` // vesting start time (UNIX Epoch time) - EndTime int64 `json:"end_time"` // vesting end time (UNIX Epoch time) + OriginalVesting sdk.Coins `json:"original_vesting" yaml:"original_vesting"` // total vesting coins upon initialization + DelegatedFree sdk.Coins `json:"delegated_free" yaml:"delegated_free"` // delegated vested coins at time of delegation + DelegatedVesting sdk.Coins `json:"delegated_vesting" yaml:"delegated_vesting"` // delegated vesting coins at time of delegation + StartTime int64 `json:"start_time" yaml:"start_time"` // vesting start time (UNIX Epoch time) + EndTime int64 `json:"end_time" yaml:"end_time"` // vesting end time (UNIX Epoch time) // module account fields - ModuleName string `json:"module_name"` // name of the module account - ModulePermission string `json:"module_permission"` // permission of module account + ModuleName string `json:"module_name" yaml:"module_name"` // name of the module account + ModulePermission string `json:"module_permission" yaml:"module_permission"` // permission of module account } // Validate checks for errors on the vesting and module account parameters diff --git a/x/genutil/client/cli/init.go b/x/genutil/client/cli/init.go index 57ed063a4f..947f9b64b1 100644 --- a/x/genutil/client/cli/init.go +++ b/x/genutil/client/cli/init.go @@ -26,11 +26,11 @@ const ( ) type printInfo struct { - Moniker string `json:"moniker"` - ChainID string `json:"chain_id"` - NodeID string `json:"node_id"` - GenTxsDir string `json:"gentxs_dir"` - AppMessage json.RawMessage `json:"app_message"` + Moniker string `json:"moniker" yaml:"moniker"` + ChainID string `json:"chain_id" yaml:"chain_id"` + NodeID string `json:"node_id" yaml:"node_id"` + GenTxsDir string `json:"gentxs_dir" yaml:"gentxs_dir"` + AppMessage json.RawMessage `json:"app_message" yaml:"app_message"` } func newPrintInfo(moniker, chainID, nodeID, genTxsDir string, diff --git a/x/genutil/genesis_state.go b/x/genutil/genesis_state.go index 8ce4a9c1e4..4f4b47e545 100644 --- a/x/genutil/genesis_state.go +++ b/x/genutil/genesis_state.go @@ -15,7 +15,7 @@ import ( // State to Unmarshal type GenesisState struct { - GenTxs []json.RawMessage `json:"gentxs"` + GenTxs []json.RawMessage `json:"gentxs" yaml:"gentxs"` } // NewGenesisState creates a new GenesisState object diff --git a/x/gov/client/rest/rest.go b/x/gov/client/rest/rest.go index 79121d33f7..9312a4e769 100644 --- a/x/gov/client/rest/rest.go +++ b/x/gov/client/rest/rest.go @@ -64,26 +64,26 @@ func RegisterRoutes(cliCtx context.CLIContext, r *mux.Router, phs []ProposalREST // PostProposalReq defines the properties of a proposal request's body. type PostProposalReq struct { - BaseReq rest.BaseReq `json:"base_req"` - Title string `json:"title"` // Title of the proposal - Description string `json:"description"` // Description of the proposal - ProposalType string `json:"proposal_type"` // Type of proposal. Initial set {PlainTextProposal, SoftwareUpgradeProposal} - Proposer sdk.AccAddress `json:"proposer"` // Address of the proposer - InitialDeposit sdk.Coins `json:"initial_deposit"` // Coins to add to the proposal's deposit + BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"` + Title string `json:"title" yaml:"title"` // Title of the proposal + Description string `json:"description" yaml:"description"` // Description of the proposal + ProposalType string `json:"proposal_type" yaml:"proposal_type"` // Type of proposal. Initial set {PlainTextProposal, SoftwareUpgradeProposal} + Proposer sdk.AccAddress `json:"proposer" yaml:"proposer"` // Address of the proposer + InitialDeposit sdk.Coins `json:"initial_deposit" yaml:"initial_deposit"` // Coins to add to the proposal's deposit } // DepositReq defines the properties of a deposit request's body. type DepositReq struct { - BaseReq rest.BaseReq `json:"base_req"` - Depositor sdk.AccAddress `json:"depositor"` // Address of the depositor - Amount sdk.Coins `json:"amount"` // Coins to add to the proposal's deposit + BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"` + Depositor sdk.AccAddress `json:"depositor" yaml:"depositor"` // Address of the depositor + Amount sdk.Coins `json:"amount" yaml:"amount"` // Coins to add to the proposal's deposit } // VoteReq defines the properties of a vote request's body. type VoteReq struct { - BaseReq rest.BaseReq `json:"base_req"` - Voter sdk.AccAddress `json:"voter"` // address of the voter - Option string `json:"option"` // option from OptionSet chosen by the voter + BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"` + Voter sdk.AccAddress `json:"voter" yaml:"voter"` // address of the voter + Option string `json:"option" yaml:"option"` // option from OptionSet chosen by the voter } func postProposalHandlerFn(cliCtx context.CLIContext) http.HandlerFunc { diff --git a/x/gov/client/utils/query.go b/x/gov/client/utils/query.go index f6d0fa83f0..0e29b6f4fb 100644 --- a/x/gov/client/utils/query.go +++ b/x/gov/client/utils/query.go @@ -17,8 +17,8 @@ const ( // Proposer contains metadata of a governance proposal used for querying a // proposer. type Proposer struct { - ProposalID uint64 `json:"proposal_id"` - Proposer string `json:"proposer"` + ProposalID uint64 `json:"proposal_id" yaml:"proposal_id"` + Proposer string `json:"proposer" yaml:"proposer"` } // NewProposer returns a new Proposer given id and proposer diff --git a/x/gov/genesis.go b/x/gov/genesis.go index ea87444da7..2ac972c4fd 100644 --- a/x/gov/genesis.go +++ b/x/gov/genesis.go @@ -16,13 +16,13 @@ const ( // GenesisState - all staking state that must be provided at genesis type GenesisState struct { - StartingProposalID uint64 `json:"starting_proposal_id"` - Deposits Deposits `json:"deposits"` - Votes Votes `json:"votes"` - Proposals []Proposal `json:"proposals"` - DepositParams DepositParams `json:"deposit_params"` - VotingParams VotingParams `json:"voting_params"` - TallyParams TallyParams `json:"tally_params"` + StartingProposalID uint64 `json:"starting_proposal_id" yaml:"starting_proposal_id"` + Deposits Deposits `json:"deposits" yaml:"deposits"` + Votes Votes `json:"votes" yaml:"votes"` + Proposals []Proposal `json:"proposals" yaml:"proposals"` + DepositParams DepositParams `json:"deposit_params" yaml:"deposit_params"` + VotingParams VotingParams `json:"voting_params" yaml:"voting_params"` + TallyParams TallyParams `json:"tally_params" yaml:"tally_params"` } // NewGenesisState creates a new genesis state for the governance module diff --git a/x/gov/types/deposit.go b/x/gov/types/deposit.go index 5afe443f80..2ec06e8e8e 100644 --- a/x/gov/types/deposit.go +++ b/x/gov/types/deposit.go @@ -8,9 +8,9 @@ import ( // Deposit type Deposit struct { - ProposalID uint64 `json:"proposal_id"` // proposalID of the proposal - Depositor sdk.AccAddress `json:"depositor"` // Address of the depositor - Amount sdk.Coins `json:"amount"` // Deposit amount + ProposalID uint64 `json:"proposal_id" yaml:"proposal_id"` // proposalID of the proposal + Depositor sdk.AccAddress `json:"depositor" yaml:"depositor"` // Address of the depositor + Amount sdk.Coins `json:"amount" yaml:"amount"` // Deposit amount } // NewDeposit creates a new Deposit instance diff --git a/x/gov/types/msgs.go b/x/gov/types/msgs.go index e594773c3a..57fc2e0ce6 100644 --- a/x/gov/types/msgs.go +++ b/x/gov/types/msgs.go @@ -17,9 +17,9 @@ var _, _, _ sdk.Msg = MsgSubmitProposal{}, MsgDeposit{}, MsgVote{} // MsgSubmitProposal type MsgSubmitProposal struct { - Content Content `json:"content"` - InitialDeposit sdk.Coins `json:"initial_deposit"` // Initial deposit paid by sender. Must be strictly positive - Proposer sdk.AccAddress `json:"proposer"` // Address of the proposer + Content Content `json:"content" yaml:"content"` + InitialDeposit sdk.Coins `json:"initial_deposit" yaml:"initial_deposit"` // Initial deposit paid by sender. Must be strictly positive + Proposer sdk.AccAddress `json:"proposer" yaml:"proposer"` // Address of the proposer } func NewMsgSubmitProposal(content Content, initialDeposit sdk.Coins, proposer sdk.AccAddress) MsgSubmitProposal { @@ -77,9 +77,9 @@ func (msg MsgSubmitProposal) GetSigners() []sdk.AccAddress { // MsgDeposit type MsgDeposit struct { - ProposalID uint64 `json:"proposal_id"` // ID of the proposal - Depositor sdk.AccAddress `json:"depositor"` // Address of the depositor - Amount sdk.Coins `json:"amount"` // Coins to add to the proposal's deposit + ProposalID uint64 `json:"proposal_id" yaml:"proposal_id"` // ID of the proposal + Depositor sdk.AccAddress `json:"depositor" yaml:"depositor"` // Address of the depositor + Amount sdk.Coins `json:"amount" yaml:"amount"` // Coins to add to the proposal's deposit } func NewMsgDeposit(depositor sdk.AccAddress, proposalID uint64, amount sdk.Coins) MsgDeposit { @@ -127,9 +127,9 @@ func (msg MsgDeposit) GetSigners() []sdk.AccAddress { // MsgVote type MsgVote struct { - ProposalID uint64 `json:"proposal_id"` // ID of the proposal - Voter sdk.AccAddress `json:"voter"` // address of the voter - Option VoteOption `json:"option"` // option from OptionSet chosen by the voter + ProposalID uint64 `json:"proposal_id" yaml:"proposal_id"` // ID of the proposal + Voter sdk.AccAddress `json:"voter" yaml:"voter"` // address of the voter + Option VoteOption `json:"option" yaml:"option"` // option from OptionSet chosen by the voter } func NewMsgVote(voter sdk.AccAddress, proposalID uint64, option VoteOption) MsgVote { diff --git a/x/gov/types/params.go b/x/gov/types/params.go index 9a766452b5..9ae33e75a0 100644 --- a/x/gov/types/params.go +++ b/x/gov/types/params.go @@ -26,8 +26,8 @@ func ParamKeyTable() params.KeyTable { // Param around deposits for governance type DepositParams struct { - MinDeposit sdk.Coins `json:"min_deposit,omitempty"` // Minimum deposit for a proposal to enter voting period. - MaxDepositPeriod time.Duration `json:"max_deposit_period,omitempty"` // Maximum period for Atom holders to deposit on a proposal. Initial value: 2 months + MinDeposit sdk.Coins `json:"min_deposit,omitempty" yaml:"min_deposit,omitempty"` // Minimum deposit for a proposal to enter voting period. + MaxDepositPeriod time.Duration `json:"max_deposit_period,omitempty" yaml:"max_deposit_period,omitempty"` // Maximum period for Atom holders to deposit on a proposal. Initial value: 2 months } // NewDepositParams creates a new DepositParams object @@ -51,9 +51,9 @@ func (dp DepositParams) Equal(dp2 DepositParams) bool { // Param around Tallying votes in governance type TallyParams struct { - Quorum sdk.Dec `json:"quorum,omitempty"` // Minimum percentage of total stake needed to vote for a result to be considered valid - Threshold sdk.Dec `json:"threshold,omitempty"` // Minimum proportion of Yes votes for proposal to pass. Initial value: 0.5 - Veto sdk.Dec `json:"veto,omitempty"` // Minimum value of Veto votes to Total votes ratio for proposal to be vetoed. Initial value: 1/3 + Quorum sdk.Dec `json:"quorum,omitempty" yaml:"quorum,omitempty"` // Minimum percentage of total stake needed to vote for a result to be considered valid + Threshold sdk.Dec `json:"threshold,omitempty" yaml:"threshold,omitempty"` // Minimum proportion of Yes votes for proposal to pass. Initial value: 0.5 + Veto sdk.Dec `json:"veto,omitempty" yaml:"veto,omitempty"` // Minimum value of Veto votes to Total votes ratio for proposal to be vetoed. Initial value: 1/3 } // NewTallyParams creates a new TallyParams object @@ -75,7 +75,7 @@ func (tp TallyParams) String() string { // Param around Voting in governance type VotingParams struct { - VotingPeriod time.Duration `json:"voting_period,omitempty"` // Length of the voting period. + VotingPeriod time.Duration `json:"voting_period,omitempty" yaml:"voting_period,omitempty"` // Length of the voting period. } // NewVotingParams creates a new VotingParams object @@ -92,9 +92,9 @@ func (vp VotingParams) String() string { // Params returns all of the governance params type Params struct { - VotingParams VotingParams `json:"voting_params"` - TallyParams TallyParams `json:"tally_params"` - DepositParams DepositParams `json:"deposit_params"` + VotingParams VotingParams `json:"voting_params" yaml:"voting_params"` + TallyParams TallyParams `json:"tally_params" yaml:"tally_params"` + DepositParams DepositParams `json:"deposit_params" yaml:"deposit_parmas"` } func (gp Params) String() string { diff --git a/x/gov/types/proposal.go b/x/gov/types/proposal.go index ef18eaf15c..a44b80730b 100644 --- a/x/gov/types/proposal.go +++ b/x/gov/types/proposal.go @@ -12,18 +12,18 @@ import ( // Proposal defines a struct used by the governance module to allow for voting // on network changes. type Proposal struct { - Content `json:"content"` // Proposal content interface + Content `json:"content" yaml:"content"` // Proposal content interface - ProposalID uint64 `json:"id"` // ID of the proposal - Status ProposalStatus `json:"proposal_status"` // Status of the Proposal {Pending, Active, Passed, Rejected} - FinalTallyResult TallyResult `json:"final_tally_result"` // Result of Tallys + ProposalID uint64 `json:"id" yaml:"id"` // ID of the proposal + Status ProposalStatus `json:"proposal_status" yaml:"proposal_status"` // Status of the Proposal {Pending, Active, Passed, Rejected} + FinalTallyResult TallyResult `json:"final_tally_result" yaml:"final_tally_result"` // Result of Tallys - SubmitTime time.Time `json:"submit_time"` // Time of the block where TxGovSubmitProposal was included - DepositEndTime time.Time `json:"deposit_end_time"` // Time that the Proposal would expire if deposit amount isn't met - TotalDeposit sdk.Coins `json:"total_deposit"` // Current deposit on this proposal. Initial value is set at InitialDeposit + SubmitTime time.Time `json:"submit_time" yaml:"submit_time"` // Time of the block where TxGovSubmitProposal was included + DepositEndTime time.Time `json:"deposit_end_time" yaml:"deposit_end_time"` // Time that the Proposal would expire if deposit amount isn't met + TotalDeposit sdk.Coins `json:"total_deposit" yaml:"total_deposit"` // Current deposit on this proposal. Initial value is set at InitialDeposit - VotingStartTime time.Time `json:"voting_start_time"` // Time of the block where MinDeposit was reached. -1 if MinDeposit is not reached - VotingEndTime time.Time `json:"voting_end_time"` // Time that the VotingPeriod for this proposal will end and votes will be tallied + VotingStartTime time.Time `json:"voting_start_time" yaml:"voting_start_time"` // Time of the block where MinDeposit was reached. -1 if MinDeposit is not reached + VotingEndTime time.Time `json:"voting_end_time" yaml:"voting_end_time"` // Time that the VotingPeriod for this proposal will end and votes will be tallied } func NewProposal(content Content, id uint64, submitTime, depositEndTime time.Time) Proposal { @@ -197,10 +197,10 @@ func (status ProposalStatus) Format(s fmt.State, verb rune) { // Tally Results type TallyResult struct { - Yes sdk.Int `json:"yes"` - Abstain sdk.Int `json:"abstain"` - No sdk.Int `json:"no"` - NoWithVeto sdk.Int `json:"no_with_veto"` + Yes sdk.Int `json:"yes" yaml:"yes"` + Abstain sdk.Int `json:"abstain" yaml:"abstain"` + No sdk.Int `json:"no" yaml:"no"` + NoWithVeto sdk.Int `json:"no_with_veto" yaml:"no_with_veto"` } func NewTallyResult(yes, abstain, no, noWithVeto sdk.Int) TallyResult { @@ -255,8 +255,8 @@ const ( // Text Proposal type TextProposal struct { - Title string `json:"title"` - Description string `json:"description"` + Title string `json:"title" yaml:"title"` + Description string `json:"description" yaml:"description"` } func NewTextProposal(title, description string) Content { @@ -284,8 +284,8 @@ func (tp TextProposal) String() string { // TODO: We have to add fields for SUP specific arguments e.g. commit hash, // upgrade date, etc. type SoftwareUpgradeProposal struct { - Title string `json:"title"` - Description string `json:"description"` + Title string `json:"title" yaml:"title"` + Description string `json:"description" yaml:"description"` } func NewSoftwareUpgradeProposal(title, description string) Content { diff --git a/x/gov/types/vote.go b/x/gov/types/vote.go index abec4dc338..39783913ad 100644 --- a/x/gov/types/vote.go +++ b/x/gov/types/vote.go @@ -9,9 +9,9 @@ import ( // Vote type Vote struct { - ProposalID uint64 `json:"proposal_id"` // proposalID of the proposal - Voter sdk.AccAddress `json:"voter"` // address of the voter - Option VoteOption `json:"option"` // option from OptionSet chosen by the voter + ProposalID uint64 `json:"proposal_id" yaml:"proposal_id"` // proposalID of the proposal + Voter sdk.AccAddress `json:"voter" yaml:"voter"` // address of the voter + Option VoteOption `json:"option" yaml:"option"` // option from OptionSet chosen by the voter } // NewVote creates a new Vote instance diff --git a/x/mint/genesis.go b/x/mint/genesis.go index 5346756073..68722158e6 100644 --- a/x/mint/genesis.go +++ b/x/mint/genesis.go @@ -6,8 +6,8 @@ import ( // GenesisState - minter state type GenesisState struct { - Minter Minter `json:"minter"` // minter object - Params Params `json:"params"` // inflation params + Minter Minter `json:"minter" yaml:"minter"` // minter object + Params Params `json:"params" yaml:"params"` // inflation params } // NewGenesisState creates a new GenesisState object diff --git a/x/mint/internal/types/minter.go b/x/mint/internal/types/minter.go index ee7ca7c662..e07716acd7 100644 --- a/x/mint/internal/types/minter.go +++ b/x/mint/internal/types/minter.go @@ -8,8 +8,8 @@ import ( // Minter represents the minting state. type Minter struct { - Inflation sdk.Dec `json:"inflation"` // current annual inflation rate - AnnualProvisions sdk.Dec `json:"annual_provisions"` // current annual expected provisions + Inflation sdk.Dec `json:"inflation" yaml:"inflation"` // current annual inflation rate + AnnualProvisions sdk.Dec `json:"annual_provisions" yaml:"annual_provisions"` // current annual expected provisions } // NewMinter returns a new Minter object with the given inflation and annual diff --git a/x/mint/internal/types/params.go b/x/mint/internal/types/params.go index 28e0730006..864d8ef32e 100644 --- a/x/mint/internal/types/params.go +++ b/x/mint/internal/types/params.go @@ -19,12 +19,12 @@ var ( // mint parameters type Params struct { - MintDenom string `json:"mint_denom"` // type of coin to mint - InflationRateChange sdk.Dec `json:"inflation_rate_change"` // maximum annual change in inflation rate - InflationMax sdk.Dec `json:"inflation_max"` // maximum inflation rate - InflationMin sdk.Dec `json:"inflation_min"` // minimum inflation rate - GoalBonded sdk.Dec `json:"goal_bonded"` // goal of percent bonded atoms - BlocksPerYear uint64 `json:"blocks_per_year"` // expected blocks per year + MintDenom string `json:"mint_denom" yaml:"mint_denom"` // type of coin to mint + InflationRateChange sdk.Dec `json:"inflation_rate_change" yaml:"inflation_rate_change"` // maximum annual change in inflation rate + InflationMax sdk.Dec `json:"inflation_max" yaml:"inflation_max"` // maximum inflation rate + InflationMin sdk.Dec `json:"inflation_min" yaml:"inflation_min"` // minimum inflation rate + GoalBonded sdk.Dec `json:"goal_bonded" yaml:"goal_bonded"` // goal of percent bonded atoms + BlocksPerYear uint64 `json:"blocks_per_year" yaml:"blocks_per_year"` // expected blocks per year } // ParamTable for minting module. diff --git a/x/params/client/utils/utils.go b/x/params/client/utils/utils.go index 245d5c06b6..6bcbeb43a5 100644 --- a/x/params/client/utils/utils.go +++ b/x/params/client/utils/utils.go @@ -18,30 +18,30 @@ type ( // ParamChangeJSON defines a parameter change used in JSON input. This // allows values to be specified in raw JSON instead of being string encoded. ParamChangeJSON struct { - Subspace string `json:"subspace"` - Key string `json:"key"` - Subkey string `json:"subkey,omitempty"` - Value json.RawMessage `json:"value"` + Subspace string `json:"subspace" yaml:"subspace"` + Key string `json:"key" yaml:"key"` + Subkey string `json:"subkey,omitempty" yaml:"subkey,omitempty"` + Value json.RawMessage `json:"value" yaml:"value"` } // ParamChangeProposalJSON defines a ParameterChangeProposal with a deposit used // to parse parameter change proposals from a JSON file. ParamChangeProposalJSON struct { - Title string `json:"title"` - Description string `json:"description"` - Changes ParamChangesJSON `json:"changes"` - Deposit sdk.Coins `json:"deposit"` + 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"` } // ParamChangeProposalReq defines a parameter change proposal request body. ParamChangeProposalReq struct { - BaseReq rest.BaseReq `json:"base_req"` + BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"` - Title string `json:"title"` - Description string `json:"description"` - Changes ParamChangesJSON `json:"changes"` - Proposer sdk.AccAddress `json:"proposer"` - Deposit sdk.Coins `json:"deposit"` + Title string `json:"title" yaml:"title"` + Description string `json:"description" yaml:"description"` + Changes ParamChangesJSON `json:"changes" yaml:"changes"` + Proposer sdk.AccAddress `json:"proposer" yaml:"proposer"` + Deposit sdk.Coins `json:"deposit" yaml:"deposit"` } ) diff --git a/x/params/keeper_test.go b/x/params/keeper_test.go index 27c4e94a08..1d4b4823ab 100644 --- a/x/params/keeper_test.go +++ b/x/params/keeper_test.go @@ -181,8 +181,8 @@ func TestSubspace(t *testing.T) { } type paramJSON struct { - Param1 int64 `json:"param1,omitempty"` - Param2 string `json:"param2,omitempty"` + Param1 int64 `json:"param1,omitempty" yaml:"param1,omitempty"` + Param2 string `json:"param2,omitempty" yaml:"param2,omitempty"` } func TestJSONUpdate(t *testing.T) { diff --git a/x/params/proposal_handler_test.go b/x/params/proposal_handler_test.go index b6cc5b34fa..120a60e90a 100644 --- a/x/params/proposal_handler_test.go +++ b/x/params/proposal_handler_test.go @@ -32,13 +32,13 @@ var ( ) type testParamsSlashingRate struct { - DoubleSign uint16 `json:"double_sign,omitempty"` - Downtime uint16 `json:"downtime,omitempty"` + DoubleSign uint16 `json:"double_sign,omitempty" yaml:"double_sign,omitempty"` + Downtime uint16 `json:"downtime,omitempty" yaml:"downtime,omitempty"` } type testParams struct { - MaxValidators uint16 `json:"max_validators"` // maximum number of validators (max uint16 = 65535) - SlashingRate testParamsSlashingRate `json:"slashing_rate"` + MaxValidators uint16 `json:"max_validators" yaml:"max_validators"` // maximum number of validators (max uint16 = 65535) + SlashingRate testParamsSlashingRate `json:"slashing_rate" yaml:"slashing_rate"` } func (tp *testParams) ParamSetPairs() subspace.ParamSetPairs { diff --git a/x/params/types/proposal.go b/x/params/types/proposal.go index 9c4ff7eebc..1039a082e5 100644 --- a/x/params/types/proposal.go +++ b/x/params/types/proposal.go @@ -24,9 +24,9 @@ func init() { // ParameterChangeProposal defines a proposal which contains multiple parameter // changes. type ParameterChangeProposal struct { - Title string `json:"title"` - Description string `json:"description"` - Changes []ParamChange `json:"changes"` + Title string `json:"title" yaml:"title"` + Description string `json:"description" yaml:"description"` + Changes []ParamChange `json:"changes" yaml:"changes"` } func NewParameterChangeProposal(title, description string, changes []ParamChange) ParameterChangeProposal { @@ -79,10 +79,10 @@ func (pcp ParameterChangeProposal) String() string { // ParamChange defines a parameter change. type ParamChange struct { - Subspace string `json:"subspace"` - Key string `json:"key"` - Subkey string `json:"subkey,omitempty"` - Value string `json:"value"` + Subspace string `json:"subspace" yaml:"subspace"` + Key string `json:"key" yaml:"key"` + Subkey string `json:"subkey,omitempty" yaml:"subkey,omitempty"` + Value string `json:"value" yaml:"value"` } func NewParamChange(subspace, key, value string) ParamChange { diff --git a/x/simulation/log.go b/x/simulation/log.go index c145b5c713..a865fbee60 100644 --- a/x/simulation/log.go +++ b/x/simulation/log.go @@ -23,7 +23,7 @@ func NewLogWriter(testingmode bool) LogWriter { // log writter type StandardLogWriter struct { - OpEntries []OperationEntry `json:"op_entries"` + OpEntries []OperationEntry `json:"op_entries" yaml:"op_entries"` } // add an entry to the log writter diff --git a/x/simulation/operation.go b/x/simulation/operation.go index 3b1c26d2b5..d894067af7 100644 --- a/x/simulation/operation.go +++ b/x/simulation/operation.go @@ -34,10 +34,10 @@ const ( // OperationEntry - an operation entry for logging (ex. BeginBlock, EndBlock, XxxMsg, etc) type OperationEntry struct { - EntryKind string `json:"entry_kind"` - Height int64 `json:"height"` - Order int64 `json:"order"` - Operation json.RawMessage `json:"operation"` + EntryKind string `json:"entry_kind" yaml:"entry_kind"` + Height int64 `json:"height" yaml:"height"` + Order int64 `json:"order" yaml:"order"` + Operation json.RawMessage `json:"operation" yaml:"operation"` } // BeginBlockEntry - operation entry for begin block @@ -93,11 +93,11 @@ func (oe OperationEntry) MustMarshal() json.RawMessage { // OperationMsg - structure for operation output type OperationMsg struct { - Route string `json:"route"` - Name string `json:"name"` - Comment string `json:"comment"` - OK bool `json:"ok"` - Msg json.RawMessage `json:"msg"` + Route string `json:"route" yaml:"route"` + Name string `json:"name" yaml:"name"` + Comment string `json:"comment" yaml:"comment"` + OK bool `json:"ok" yaml:"ok"` + Msg json.RawMessage `json:"msg" yaml:"msg"` } // OperationMsg - create a new operation message from sdk.Msg diff --git a/x/slashing/client/rest/tx.go b/x/slashing/client/rest/tx.go index 39b330ab69..16186d35dd 100644 --- a/x/slashing/client/rest/tx.go +++ b/x/slashing/client/rest/tx.go @@ -22,7 +22,7 @@ func registerTxRoutes(cliCtx context.CLIContext, r *mux.Router) { // Unjail TX body type UnjailReq struct { - BaseReq rest.BaseReq `json:"base_req"` + BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"` } func unjailRequestHandlerFn(cliCtx context.CLIContext) http.HandlerFunc { diff --git a/x/slashing/types/genesis.go b/x/slashing/types/genesis.go index 804ef579ea..b72c0637b2 100644 --- a/x/slashing/types/genesis.go +++ b/x/slashing/types/genesis.go @@ -9,9 +9,9 @@ import ( // GenesisState - all slashing state that must be provided at genesis type GenesisState struct { - Params Params `json:"params"` - SigningInfos map[string]ValidatorSigningInfo `json:"signing_infos"` - MissedBlocks map[string][]MissedBlock `json:"missed_blocks"` + Params Params `json:"params" yaml:"params"` + SigningInfos map[string]ValidatorSigningInfo `json:"signing_infos" yaml:"signing_infos"` + MissedBlocks map[string][]MissedBlock `json:"missed_blocks" yaml:"missed_blocks"` } // NewGenesisState creates a new GenesisState object @@ -28,8 +28,8 @@ func NewGenesisState( // MissedBlock type MissedBlock struct { - Index int64 `json:"index"` - Missed bool `json:"missed"` + Index int64 `json:"index" yaml:"index"` + Missed bool `json:"missed" yaml:"missed"` } // DefaultGenesisState - default GenesisState used by Cosmos Hub diff --git a/x/slashing/types/msg.go b/x/slashing/types/msg.go index 2988cb7dcc..a167ae44b4 100644 --- a/x/slashing/types/msg.go +++ b/x/slashing/types/msg.go @@ -9,7 +9,7 @@ var _ sdk.Msg = &MsgUnjail{} // MsgUnjail - struct for unjailing jailed validator type MsgUnjail struct { - ValidatorAddr sdk.ValAddress `json:"address"` // address of the validator operator + ValidatorAddr sdk.ValAddress `json:"address" yaml:"address"` // address of the validator operator } func NewMsgUnjail(validatorAddr sdk.ValAddress) MsgUnjail { diff --git a/x/slashing/types/params.go b/x/slashing/types/params.go index 321834c695..532324a28d 100644 --- a/x/slashing/types/params.go +++ b/x/slashing/types/params.go @@ -41,12 +41,12 @@ func ParamKeyTable() params.KeyTable { // Params - used for initializing default parameter for slashing at genesis type Params struct { - MaxEvidenceAge time.Duration `json:"max_evidence_age"` - SignedBlocksWindow int64 `json:"signed_blocks_window"` - MinSignedPerWindow sdk.Dec `json:"min_signed_per_window"` - DowntimeJailDuration time.Duration `json:"downtime_jail_duration"` - SlashFractionDoubleSign sdk.Dec `json:"slash_fraction_double_sign"` - SlashFractionDowntime sdk.Dec `json:"slash_fraction_downtime"` + MaxEvidenceAge time.Duration `json:"max_evidence_age" yaml:"max_evidence_age"` + SignedBlocksWindow int64 `json:"signed_blocks_window" yaml:"signed_blocks_window"` + MinSignedPerWindow sdk.Dec `json:"min_signed_per_window" yaml:"min_signed_per_window"` + DowntimeJailDuration time.Duration `json:"downtime_jail_duration" yaml:"downtime_jail_duration"` + SlashFractionDoubleSign sdk.Dec `json:"slash_fraction_double_sign" yaml:"slash_fraction_double_sign"` + SlashFractionDowntime sdk.Dec `json:"slash_fraction_downtime" yaml:"slash_fraction_downtime"` } // NewParams creates a new Params object diff --git a/x/slashing/types/signing_info.go b/x/slashing/types/signing_info.go index dba9e434c3..804db7b976 100644 --- a/x/slashing/types/signing_info.go +++ b/x/slashing/types/signing_info.go @@ -9,12 +9,12 @@ import ( // Signing info for a validator type ValidatorSigningInfo struct { - Address sdk.ConsAddress `json:"address"` // validator consensus address - StartHeight int64 `json:"start_height"` // height at which validator was first a candidate OR was unjailed - IndexOffset int64 `json:"index_offset"` // index offset into signed block bit array - JailedUntil time.Time `json:"jailed_until"` // timestamp validator cannot be unjailed until - Tombstoned bool `json:"tombstoned"` // whether or not a validator has been tombstoned (killed out of validator set) - MissedBlocksCounter int64 `json:"missed_blocks_counter"` // missed blocks counter (to avoid scanning the array every time) + Address sdk.ConsAddress `json:"address" yaml:"address"` // validator consensus address + StartHeight int64 `json:"start_height" yaml:"start_height"` // height at which validator was first a candidate OR was unjailed + IndexOffset int64 `json:"index_offset" yaml:"index_offset"` // index offset into signed block bit array + JailedUntil time.Time `json:"jailed_until" yaml:"jailed_until"` // timestamp validator cannot be unjailed until + Tombstoned bool `json:"tombstoned" yaml:"tombstoned"` // whether or not a validator has been tombstoned (killed out of validator set) + MissedBlocksCounter int64 `json:"missed_blocks_counter" yaml:"missed_blocks_counter"` // missed blocks counter (to avoid scanning the array every time) } // Construct a new `ValidatorSigningInfo` struct diff --git a/x/staking/client/rest/tx.go b/x/staking/client/rest/tx.go index e755c9a4e0..bd6016bed1 100644 --- a/x/staking/client/rest/tx.go +++ b/x/staking/client/rest/tx.go @@ -31,27 +31,27 @@ func registerTxRoutes(cliCtx context.CLIContext, r *mux.Router) { type ( // DelegateRequest defines the properties of a delegation request's body. DelegateRequest struct { - BaseReq rest.BaseReq `json:"base_req"` - DelegatorAddress sdk.AccAddress `json:"delegator_address"` // in bech32 - ValidatorAddress sdk.ValAddress `json:"validator_address"` // in bech32 - Amount sdk.Coin `json:"amount"` + BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"` + DelegatorAddress sdk.AccAddress `json:"delegator_address" yaml:"delegator_address"` // in bech32 + ValidatorAddress sdk.ValAddress `json:"validator_address" yaml:"validator_address"` // in bech32 + Amount sdk.Coin `json:"amount" yaml:"amount"` } // RedelegateRequest defines the properties of a redelegate request's body. RedelegateRequest struct { - BaseReq rest.BaseReq `json:"base_req"` - DelegatorAddress sdk.AccAddress `json:"delegator_address"` // in bech32 - ValidatorSrcAddress sdk.ValAddress `json:"validator_src_address"` // in bech32 - ValidatorDstAddress sdk.ValAddress `json:"validator_dst_address"` // in bech32 - Amount sdk.Coin `json:"amount"` + BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"` + DelegatorAddress sdk.AccAddress `json:"delegator_address" yaml:"delegator_address"` // in bech32 + ValidatorSrcAddress sdk.ValAddress `json:"validator_src_address" yaml:"validator_src_address"` // in bech32 + ValidatorDstAddress sdk.ValAddress `json:"validator_dst_address" yaml:"validator_dst_address"` // in bech32 + Amount sdk.Coin `json:"amount" yaml:"amount"` } // UndelegateRequest defines the properties of a undelegate request's body. UndelegateRequest struct { - BaseReq rest.BaseReq `json:"base_req"` - DelegatorAddress sdk.AccAddress `json:"delegator_address"` // in bech32 - ValidatorAddress sdk.ValAddress `json:"validator_address"` // in bech32 - Amount sdk.Coin `json:"amount"` + BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"` + DelegatorAddress sdk.AccAddress `json:"delegator_address" yaml:"delegator_address"` // in bech32 + ValidatorAddress sdk.ValAddress `json:"validator_address" yaml:"validator_address"` // in bech32 + Amount sdk.Coin `json:"amount" yaml:"amount"` } ) diff --git a/x/staking/types/commission.go b/x/staking/types/commission.go index 26aa308c6b..db0269df8b 100644 --- a/x/staking/types/commission.go +++ b/x/staking/types/commission.go @@ -11,15 +11,15 @@ type ( // Commission defines a commission parameters for a given validator. Commission struct { CommissionRates - UpdateTime time.Time `json:"update_time"` // the last time the commission rate was changed + UpdateTime time.Time `json:"update_time" yaml:"update_time"` // the last time the commission rate was changed } // CommissionRates defines the initial commission rates to be used for creating a // validator. CommissionRates struct { - Rate sdk.Dec `json:"rate"` // the commission rate charged to delegators, as a fraction - MaxRate sdk.Dec `json:"max_rate"` // maximum commission rate which validator can ever charge, as a fraction - MaxChangeRate sdk.Dec `json:"max_change_rate"` // maximum daily increase of the validator commission, as a fraction + Rate sdk.Dec `json:"rate" yaml:"rate"` // the commission rate charged to delegators, as a fraction + MaxRate sdk.Dec `json:"max_rate" yaml:"max_rate"` // maximum commission rate which validator can ever charge, as a fraction + MaxChangeRate sdk.Dec `json:"max_change_rate" yaml:"max_change_rate"` // maximum daily increase of the validator commission, as a fraction } ) diff --git a/x/staking/types/delegation.go b/x/staking/types/delegation.go index 04c4344d92..d25059a509 100644 --- a/x/staking/types/delegation.go +++ b/x/staking/types/delegation.go @@ -36,9 +36,9 @@ var _ exported.DelegationI = Delegation{} // owned by one delegator, and is associated with the voting power of one // validator. type Delegation struct { - DelegatorAddress sdk.AccAddress `json:"delegator_address"` - ValidatorAddress sdk.ValAddress `json:"validator_address"` - Shares sdk.Dec `json:"shares"` + DelegatorAddress sdk.AccAddress `json:"delegator_address" yaml:"delegator_address"` + ValidatorAddress sdk.ValAddress `json:"validator_address" yaml:"validator_address"` + Shares sdk.Dec `json:"shares" yaml:"shares"` } // NewDelegation creates a new delegation object @@ -106,17 +106,17 @@ func (d Delegations) String() (out string) { // UnbondingDelegation stores all of a single delegator's unbonding bonds // for a single validator in an time-ordered list type UnbondingDelegation struct { - DelegatorAddress sdk.AccAddress `json:"delegator_address"` // delegator - ValidatorAddress sdk.ValAddress `json:"validator_address"` // validator unbonding from operator addr - Entries []UnbondingDelegationEntry `json:"entries"` // unbonding delegation entries + DelegatorAddress sdk.AccAddress `json:"delegator_address" yaml:"delegator_address"` // delegator + ValidatorAddress sdk.ValAddress `json:"validator_address" yaml:"validator_address"` // validator unbonding from operator addr + Entries []UnbondingDelegationEntry `json:"entries" yaml:"entries"` // unbonding delegation entries } // UnbondingDelegationEntry - entry to an UnbondingDelegation type UnbondingDelegationEntry struct { - CreationHeight int64 `json:"creation_height"` // height which the unbonding took place - CompletionTime time.Time `json:"completion_time"` // time at which the unbonding delegation will complete - InitialBalance sdk.Int `json:"initial_balance"` // atoms initially scheduled to receive at completion - Balance sdk.Int `json:"balance"` // atoms to receive at completion + CreationHeight int64 `json:"creation_height" yaml:"creation_height"` // height which the unbonding took place + CompletionTime time.Time `json:"completion_time" yaml:"completion_time"` // time at which the unbonding delegation will complete + InitialBalance sdk.Int `json:"initial_balance" yaml:"initial_balance"` // atoms initially scheduled to receive at completion + Balance sdk.Int `json:"balance" yaml:"balance"` // atoms to receive at completion } // IsMature - is the current entry mature @@ -220,18 +220,18 @@ func (ubds UnbondingDelegations) String() (out string) { // redelegating bonds from a particular source validator to a // particular destination validator type Redelegation struct { - DelegatorAddress sdk.AccAddress `json:"delegator_address"` // delegator - ValidatorSrcAddress sdk.ValAddress `json:"validator_src_address"` // validator redelegation source operator addr - ValidatorDstAddress sdk.ValAddress `json:"validator_dst_address"` // validator redelegation destination operator addr - Entries []RedelegationEntry `json:"entries"` // redelegation entries + DelegatorAddress sdk.AccAddress `json:"delegator_address" yaml:"delegator_address"` // delegator + ValidatorSrcAddress sdk.ValAddress `json:"validator_src_address" yaml:"validator_src_address"` // validator redelegation source operator addr + ValidatorDstAddress sdk.ValAddress `json:"validator_dst_address" yaml:"validator_dst_address"` // validator redelegation destination operator addr + Entries []RedelegationEntry `json:"entries" yaml:"entries"` // redelegation entries } // RedelegationEntry - entry to a Redelegation type RedelegationEntry struct { - CreationHeight int64 `json:"creation_height"` // height at which the redelegation took place - CompletionTime time.Time `json:"completion_time"` // time at which the redelegation will complete - InitialBalance sdk.Int `json:"initial_balance"` // initial balance when redelegation started - SharesDst sdk.Dec `json:"shares_dst"` // amount of destination-validator shares created by redelegation + CreationHeight int64 `json:"creation_height" yaml:"creation_height"` // height at which the redelegation took place + CompletionTime time.Time `json:"completion_time" yaml:"completion_time"` // time at which the redelegation will complete + InitialBalance sdk.Int `json:"initial_balance" yaml:"initial_balance"` // initial balance when redelegation started + SharesDst sdk.Dec `json:"shares_dst" yaml:"shares_dst"` // amount of destination-validator shares created by redelegation } // NewRedelegation - create a new redelegation object @@ -352,7 +352,7 @@ func (d Redelegations) String() (out string) { // in addition to shares which is more suitable for client responses. type DelegationResponse struct { Delegation - Balance sdk.Int `json:"balance"` + Balance sdk.Int `json:"balance" yaml:"balance"` } func NewDelegationResp(d sdk.AccAddress, v sdk.ValAddress, s sdk.Dec, b sdk.Int) DelegationResponse { @@ -394,7 +394,7 @@ func (d DelegationResponses) String() (out string) { // responses. type RedelegationResponse struct { Redelegation - Entries []RedelegationEntryResponse `json:"entries"` // nolint: structtag + Entries []RedelegationEntryResponse `json:"entries" yaml:"entries"` // nolint: structtag } // RedelegationEntryResponse is equivalent to a RedelegationEntry except that it diff --git a/x/staking/types/genesis.go b/x/staking/types/genesis.go index dc5edf76cd..52e4fdef87 100644 --- a/x/staking/types/genesis.go +++ b/x/staking/types/genesis.go @@ -6,14 +6,14 @@ import ( // GenesisState - all staking state that must be provided at genesis type GenesisState struct { - Params Params `json:"params"` - LastTotalPower sdk.Int `json:"last_total_power"` - LastValidatorPowers []LastValidatorPower `json:"last_validator_powers"` - Validators Validators `json:"validators"` - Delegations Delegations `json:"delegations"` - UnbondingDelegations []UnbondingDelegation `json:"unbonding_delegations"` - Redelegations []Redelegation `json:"redelegations"` - Exported bool `json:"exported"` + Params Params `json:"params" yaml:"params"` + LastTotalPower sdk.Int `json:"last_total_power" yaml:"last_total_power"` + LastValidatorPowers []LastValidatorPower `json:"last_validator_powers" yaml:"last_validator_powers"` + Validators Validators `json:"validators" yaml:"validators"` + Delegations Delegations `json:"delegations" yaml:"delegations"` + UnbondingDelegations []UnbondingDelegation `json:"unbonding_delegations" yaml:"unbonding_delegations"` + Redelegations []Redelegation `json:"redelegations" yaml:"redelegations"` + Exported bool `json:"exported" yaml:"exported"` } // Last validator power, needed for validator set update logic diff --git a/x/staking/types/msg.go b/x/staking/types/msg.go index 04bc01f18c..cc991389ca 100644 --- a/x/staking/types/msg.go +++ b/x/staking/types/msg.go @@ -22,23 +22,23 @@ var ( // MsgCreateValidator - struct for bonding transactions type MsgCreateValidator struct { - Description Description `json:"description"` - Commission CommissionRates `json:"commission"` - MinSelfDelegation sdk.Int `json:"min_self_delegation"` - DelegatorAddress sdk.AccAddress `json:"delegator_address"` - ValidatorAddress sdk.ValAddress `json:"validator_address"` - PubKey crypto.PubKey `json:"pubkey"` - Value sdk.Coin `json:"value"` + Description Description `json:"description" yaml:"description"` + Commission CommissionRates `json:"commission" yaml:"commission"` + MinSelfDelegation sdk.Int `json:"min_self_delegation" yaml:"min_self_delegation"` + DelegatorAddress sdk.AccAddress `json:"delegator_address" yaml:"delegator_address"` + ValidatorAddress sdk.ValAddress `json:"validator_address" yaml:"validator_address"` + PubKey crypto.PubKey `json:"pubkey" yaml:"pubkey"` + Value sdk.Coin `json:"value" yaml:"value"` } type msgCreateValidatorJSON struct { - Description Description `json:"description"` - Commission CommissionRates `json:"commission"` - MinSelfDelegation sdk.Int `json:"min_self_delegation"` - DelegatorAddress sdk.AccAddress `json:"delegator_address"` - ValidatorAddress sdk.ValAddress `json:"validator_address"` - PubKey string `json:"pubkey"` - Value sdk.Coin `json:"value"` + Description Description `json:"description" yaml:"description"` + Commission CommissionRates `json:"commission" yaml:"commission"` + MinSelfDelegation sdk.Int `json:"min_self_delegation" yaml:"min_self_delegation"` + DelegatorAddress sdk.AccAddress `json:"delegator_address" yaml:"delegator_address"` + ValidatorAddress sdk.ValAddress `json:"validator_address" yaml:"validator_address"` + PubKey string `json:"pubkey" yaml:"pubkey"` + Value sdk.Coin `json:"value" yaml:"value"` } // Default way to create validator. Delegator address and validator address are the same @@ -155,15 +155,15 @@ func (msg MsgCreateValidator) ValidateBasic() sdk.Error { // MsgEditValidator - struct for editing a validator type MsgEditValidator struct { Description - ValidatorAddress sdk.ValAddress `json:"address"` + ValidatorAddress sdk.ValAddress `json:"address" yaml:"address"` // We pass a reference to the new commission rate and min self delegation as it's not mandatory to // update. If not updated, the deserialized rate will be zero with no way to // distinguish if an update was intended. // // REF: #2373 - CommissionRate *sdk.Dec `json:"commission_rate"` - MinSelfDelegation *sdk.Int `json:"min_self_delegation"` + CommissionRate *sdk.Dec `json:"commission_rate" yaml:"commission_rate"` + MinSelfDelegation *sdk.Int `json:"min_self_delegation" yaml:"min_self_delegation"` } func NewMsgEditValidator(valAddr sdk.ValAddress, description Description, newRate *sdk.Dec, newMinSelfDelegation *sdk.Int) MsgEditValidator { @@ -213,9 +213,9 @@ func (msg MsgEditValidator) ValidateBasic() sdk.Error { // MsgDelegate - struct for bonding transactions type MsgDelegate struct { - DelegatorAddress sdk.AccAddress `json:"delegator_address"` - ValidatorAddress sdk.ValAddress `json:"validator_address"` - Amount sdk.Coin `json:"amount"` + DelegatorAddress sdk.AccAddress `json:"delegator_address" yaml:"delegator_address"` + ValidatorAddress sdk.ValAddress `json:"validator_address" yaml:"validator_address"` + Amount sdk.Coin `json:"amount" yaml:"amount"` } func NewMsgDelegate(delAddr sdk.AccAddress, valAddr sdk.ValAddress, amount sdk.Coin) MsgDelegate { @@ -257,10 +257,10 @@ func (msg MsgDelegate) ValidateBasic() sdk.Error { // MsgDelegate - struct for bonding transactions type MsgBeginRedelegate struct { - DelegatorAddress sdk.AccAddress `json:"delegator_address"` - ValidatorSrcAddress sdk.ValAddress `json:"validator_src_address"` - ValidatorDstAddress sdk.ValAddress `json:"validator_dst_address"` - Amount sdk.Coin `json:"amount"` + DelegatorAddress sdk.AccAddress `json:"delegator_address" yaml:"delegator_address"` + ValidatorSrcAddress sdk.ValAddress `json:"validator_src_address" yaml:"validator_src_address"` + ValidatorDstAddress sdk.ValAddress `json:"validator_dst_address" yaml:"validator_dst_address"` + Amount sdk.Coin `json:"amount" yaml:"amount"` } func NewMsgBeginRedelegate(delAddr sdk.AccAddress, valSrcAddr, @@ -306,9 +306,9 @@ func (msg MsgBeginRedelegate) ValidateBasic() sdk.Error { // MsgUndelegate - struct for unbonding transactions type MsgUndelegate struct { - DelegatorAddress sdk.AccAddress `json:"delegator_address"` - ValidatorAddress sdk.ValAddress `json:"validator_address"` - Amount sdk.Coin `json:"amount"` + DelegatorAddress sdk.AccAddress `json:"delegator_address" yaml:"delegator_address"` + ValidatorAddress sdk.ValAddress `json:"validator_address" yaml:"validator_address"` + Amount sdk.Coin `json:"amount" yaml:"amount"` } func NewMsgUndelegate(delAddr sdk.AccAddress, valAddr sdk.ValAddress, amount sdk.Coin) MsgUndelegate { diff --git a/x/staking/types/params.go b/x/staking/types/params.go index c0f0e63627..a2afa8a608 100644 --- a/x/staking/types/params.go +++ b/x/staking/types/params.go @@ -35,11 +35,11 @@ var _ params.ParamSet = (*Params)(nil) // Params defines the high level settings for staking type Params struct { - UnbondingTime time.Duration `json:"unbonding_time"` // time duration of unbonding - MaxValidators uint16 `json:"max_validators"` // maximum number of validators (max uint16 = 65535) - MaxEntries uint16 `json:"max_entries"` // max entries for either unbonding delegation or redelegation (per pair/trio) + UnbondingTime time.Duration `json:"unbonding_time" yaml:"unbonding_time"` // time duration of unbonding + MaxValidators uint16 `json:"max_validators" yaml:"max_validators"` // maximum number of validators (max uint16 = 65535) + MaxEntries uint16 `json:"max_entries" yaml:"max_entries"` // max entries for either unbonding delegation or redelegation (per pair/trio) // note: we need to be a bit careful about potential overflow here, since this is user-determined - BondDenom string `json:"bond_denom"` // bondable coin denomination + BondDenom string `json:"bond_denom" yaml:"bond_denom"` // bondable coin denomination } func NewParams(unbondingTime time.Duration, maxValidators, maxEntries uint16, diff --git a/x/staking/types/pool.go b/x/staking/types/pool.go index 03da4f3cbd..ca9ed5f2b9 100644 --- a/x/staking/types/pool.go +++ b/x/staking/types/pool.go @@ -18,8 +18,8 @@ const ( // Pool - tracking bonded and not-bonded token supply of the bond denomination type Pool struct { - NotBondedTokens sdk.Int `json:"not_bonded_tokens"` // tokens which are not bonded to a validator (unbonded or unbonding) - BondedTokens sdk.Int `json:"bonded_tokens"` // tokens which are currently bonded to a validator + NotBondedTokens sdk.Int `json:"not_bonded_tokens" yaml:"not_bonded_tokens"` // tokens which are not bonded to a validator (unbonded or unbonding) + BondedTokens sdk.Int `json:"bonded_tokens" yaml:"bonded_tokens"` // tokens which are currently bonded to a validator } // NewPool creates a new Pool instance used for queries diff --git a/x/staking/types/validator.go b/x/staking/types/validator.go index 8dbea554ea..014ff84d3a 100644 --- a/x/staking/types/validator.go +++ b/x/staking/types/validator.go @@ -36,17 +36,17 @@ var _ exported.ValidatorI = Validator{} // divided by the current exchange rate. Voting power can be calculated as total // bonded shares multiplied by exchange rate. type Validator struct { - OperatorAddress sdk.ValAddress `json:"operator_address"` // address of the validator's operator; bech encoded in JSON - ConsPubKey crypto.PubKey `json:"consensus_pubkey"` // the consensus public key of the validator; bech encoded in JSON - Jailed bool `json:"jailed"` // has the validator been jailed from bonded status? - Status sdk.BondStatus `json:"status"` // validator status (bonded/unbonding/unbonded) - Tokens sdk.Int `json:"tokens"` // delegated tokens (incl. self-delegation) - DelegatorShares sdk.Dec `json:"delegator_shares"` // total shares issued to a validator's delegators - Description Description `json:"description"` // description terms for the validator - UnbondingHeight int64 `json:"unbonding_height"` // if unbonding, height at which this validator has begun unbonding - UnbondingCompletionTime time.Time `json:"unbonding_time"` // if unbonding, min time for the validator to complete unbonding - Commission Commission `json:"commission"` // commission parameters - MinSelfDelegation sdk.Int `json:"min_self_delegation"` // validator's self declared minimum self delegation + OperatorAddress sdk.ValAddress `json:"operator_address" yaml:"operator_address"` // address of the validator's operator; bech encoded in JSON + ConsPubKey crypto.PubKey `json:"consensus_pubkey" yaml:"consensus_pubkey"` // the consensus public key of the validator; bech encoded in JSON + Jailed bool `json:"jailed" yaml:"jailed"` // has the validator been jailed from bonded status? + Status sdk.BondStatus `json:"status" yaml:"status"` // validator status (bonded/unbonding/unbonded) + Tokens sdk.Int `json:"tokens" yaml:"tokens"` // delegated tokens (incl. self-delegation) + DelegatorShares sdk.Dec `json:"delegator_shares" yaml:"delegator_shares"` // total shares issued to a validator's delegators + Description Description `json:"description" yaml:"description"` // description terms for the validator + UnbondingHeight int64 `json:"unbonding_height" yaml:"unbonding_height"` // if unbonding, height at which this validator has begun unbonding + UnbondingCompletionTime time.Time `json:"unbonding_time" yaml:"unbonding_time"` // if unbonding, min time for the validator to complete unbonding + Commission Commission `json:"commission" yaml:"commission"` // commission parameters + MinSelfDelegation sdk.Int `json:"min_self_delegation" yaml:"min_self_delegation"` // validator's self declared minimum self delegation } // custom marshal yaml function due to consensus pubkey @@ -163,17 +163,17 @@ func (v Validator) String() string { // this is a helper struct used for JSON de- and encoding only type bechValidator struct { - OperatorAddress sdk.ValAddress `json:"operator_address"` // the bech32 address of the validator's operator - ConsPubKey string `json:"consensus_pubkey"` // the bech32 consensus public key of the validator - Jailed bool `json:"jailed"` // has the validator been jailed from bonded status? - Status sdk.BondStatus `json:"status"` // validator status (bonded/unbonding/unbonded) - Tokens sdk.Int `json:"tokens"` // delegated tokens (incl. self-delegation) - DelegatorShares sdk.Dec `json:"delegator_shares"` // total shares issued to a validator's delegators - Description Description `json:"description"` // description terms for the validator - UnbondingHeight int64 `json:"unbonding_height"` // if unbonding, height at which this validator has begun unbonding - UnbondingCompletionTime time.Time `json:"unbonding_time"` // if unbonding, min time for the validator to complete unbonding - Commission Commission `json:"commission"` // commission parameters - MinSelfDelegation sdk.Int `json:"min_self_delegation"` // minimum self delegation + OperatorAddress sdk.ValAddress `json:"operator_address" yaml:"operator_address"` // the bech32 address of the validator's operator + ConsPubKey string `json:"consensus_pubkey" yaml:"consensus_pubkey"` // the bech32 consensus public key of the validator + Jailed bool `json:"jailed" yaml:"jailed"` // has the validator been jailed from bonded status? + Status sdk.BondStatus `json:"status" yaml:"status"` // validator status (bonded/unbonding/unbonded) + Tokens sdk.Int `json:"tokens" yaml:"tokens"` // delegated tokens (incl. self-delegation) + DelegatorShares sdk.Dec `json:"delegator_shares" yaml:"delegator_shares"` // total shares issued to a validator's delegators + Description Description `json:"description" yaml:"description"` // description terms for the validator + UnbondingHeight int64 `json:"unbonding_height" yaml:"unbonding_height"` // if unbonding, height at which this validator has begun unbonding + UnbondingCompletionTime time.Time `json:"unbonding_time" yaml:"unbonding_time"` // if unbonding, min time for the validator to complete unbonding + Commission Commission `json:"commission" yaml:"commission"` // commission parameters + MinSelfDelegation sdk.Int `json:"min_self_delegation" yaml:"min_self_delegation"` // minimum self delegation } // MarshalJSON marshals the validator to JSON using Bech32 @@ -260,10 +260,10 @@ const DoNotModifyDesc = "[do-not-modify]" // Description - description fields for a validator type Description struct { - Moniker string `json:"moniker"` // name - Identity string `json:"identity"` // optional identity signature (ex. UPort or Keybase) - Website string `json:"website"` // optional website link - Details string `json:"details"` // optional details + Moniker string `json:"moniker" yaml:"moniker"` // name + Identity string `json:"identity" yaml:"identity"` // optional identity signature (ex. UPort or Keybase) + Website string `json:"website" yaml:"website"` // optional website link + Details string `json:"details" yaml:"details"` // optional details } // NewDescription returns a new Description with the provided values. diff --git a/x/staking/types/validator_test.go b/x/staking/types/validator_test.go index cd9fcf7917..02af66f59b 100644 --- a/x/staking/types/validator_test.go +++ b/x/staking/types/validator_test.go @@ -295,9 +295,9 @@ func TestValidatorMarshalYAML(t *testing.T) { commission: commissionrates: rate: "0.000000000000000000" - maxrate: "0.000000000000000000" - maxchangerate: "0.000000000000000000" - updatetime: 1970-01-01T00:00:00Z + max_rate: "0.000000000000000000" + max_change_rate: "0.000000000000000000" + update_time: 1970-01-01T00:00:00Z minselfdelegation: "1" `, validator.OperatorAddress.String(), bechifiedPub) require.Equal(t, want, string(bs)) diff --git a/x/supply/internal/types/account.go b/x/supply/internal/types/account.go index 55a1bf1bd2..32f0249df0 100644 --- a/x/supply/internal/types/account.go +++ b/x/supply/internal/types/account.go @@ -17,8 +17,8 @@ var _ exported.ModuleAccountI = (*ModuleAccount)(nil) // ModuleAccount defines an account for modules that holds coins on a pool type ModuleAccount struct { *authtypes.BaseAccount - Name string `json:"name"` // name of the module - Permission string `json:"permission"` // permission of module account (minter/burner/holder) + Name string `json:"name" yaml:"name"` // name of the module + Permission string `json:"permission" yaml:"permission"` // permission of module account (minter/burner/holder) } // NewModuleAddress creates an AccAddress from the hash of the module's name diff --git a/x/supply/internal/types/genesis.go b/x/supply/internal/types/genesis.go index ed0188fc41..e2e690cfd2 100644 --- a/x/supply/internal/types/genesis.go +++ b/x/supply/internal/types/genesis.go @@ -2,7 +2,7 @@ package types // GenesisState is the supply state that must be provided at genesis. type GenesisState struct { - Supply Supply `json:"supply"` + Supply Supply `json:"supply" yaml:"supply"` } // NewGenesisState creates a new genesis state. diff --git a/x/supply/internal/types/supply.go b/x/supply/internal/types/supply.go index 9a02c66089..e3513cad4d 100644 --- a/x/supply/internal/types/supply.go +++ b/x/supply/internal/types/supply.go @@ -9,7 +9,7 @@ import ( // Supply represents a struct that passively keeps track of the total supply amounts in the network type Supply struct { - Total sdk.Coins `json:"total_supply"` // total supply of tokens registered on the chain + Total sdk.Coins `json:"total_supply" yaml:"total_supply"` // total supply of tokens registered on the chain } // NewSupply creates a new Supply instance diff --git a/x/supply/internal/types/supply_test.go b/x/supply/internal/types/supply_test.go index 68e0073235..74756256a7 100644 --- a/x/supply/internal/types/supply_test.go +++ b/x/supply/internal/types/supply_test.go @@ -4,9 +4,10 @@ import ( "fmt" "testing" - sdk "github.com/cosmos/cosmos-sdk/types" "gopkg.in/yaml.v2" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" ) @@ -20,7 +21,7 @@ func TestSupplyMarshalYAML(t *testing.T) { bzCoins, err := yaml.Marshal(coins) require.NoError(t, err) - want := fmt.Sprintf(`total: + want := fmt.Sprintf(`total_supply: %s`, string(bzCoins)) require.Equal(t, want, string(bz))