Merge PR #4678: Clean YAML output

This commit is contained in:
Aayushi Jain 2019-07-05 19:25:56 -04:00 committed by Alexander Bezobchuk
parent 2fdbf631e7
commit 1a7f31f7c8
65 changed files with 452 additions and 394 deletions

View File

@ -11,8 +11,8 @@ import (
// BroadcastReq defines a tx broadcasting request. // BroadcastReq defines a tx broadcasting request.
type BroadcastReq struct { type BroadcastReq struct {
Tx types.StdTx `json:"tx"` Tx types.StdTx `json:"tx" yaml:"tx"`
Mode string `json:"mode"` Mode string `json:"mode" yaml:"mode"`
} }
// BroadcastTxRequest implements a tx broadcasting handler that is responsible // BroadcastTxRequest implements a tx broadcasting handler that is responsible

View File

@ -12,7 +12,7 @@ import (
// EncodeResp defines a tx encoding response. // EncodeResp defines a tx encoding response.
type EncodeResp struct { type EncodeResp struct {
Tx string `json:"tx"` Tx string `json:"tx" yaml:"tx"`
} }
// EncodeTxRequestHandlerFn returns the encode tx REST handler. In particular, // EncodeTxRequestHandlerFn returns the encode tx REST handler. In particular,

View File

@ -21,7 +21,7 @@ import (
// GasEstimateResponse defines a response definition for tx gas estimation. // GasEstimateResponse defines a response definition for tx gas estimation.
type GasEstimateResponse struct { type GasEstimateResponse struct {
GasEstimate uint64 `json:"gas_estimate"` GasEstimate uint64 `json:"gas_estimate" yaml:"gas_estimate"`
} }
func (gr GasEstimateResponse) String() string { func (gr GasEstimateResponse) String() string {

View File

@ -25,11 +25,10 @@ type testInput struct {
// moduleAccount defines an account for modules that holds coins on a pool // moduleAccount defines an account for modules that holds coins on a pool
type moduleAccount struct { type moduleAccount struct {
*types.BaseAccount *types.BaseAccount
Name string `json:"name"` // name of the module Name string `json:"name" yaml:"name"` // name of the module
Permission string `json:"permission"` // permission of module account (minter/burner/holder) Permission string `json:"permission" yaml"permission"` // permission of module account (minter/burner/holder)
} }
// GetName returns the the name of the holder's module // GetName returns the the name of the holder's module
func (ma moduleAccount) GetName() string { func (ma moduleAccount) GetName() string {
return ma.Name return ma.Name
@ -40,7 +39,6 @@ func (ma moduleAccount) GetPermission() string {
return ma.Permission return ma.Permission
} }
func setupTestInput() testInput { func setupTestInput() testInput {
db := dbm.NewMemDB() db := dbm.NewMemDB()

View File

@ -22,11 +22,11 @@ var _ exported.Account = (*BaseAccount)(nil)
// However one doesn't have to use BaseAccount as long as your struct // However one doesn't have to use BaseAccount as long as your struct
// implements Account. // implements Account.
type BaseAccount struct { type BaseAccount struct {
Address sdk.AccAddress `json:"address"` Address sdk.AccAddress `json:"address" yaml:"address"`
Coins sdk.Coins `json:"coins"` Coins sdk.Coins `json:"coins" yaml:"coins"`
PubKey crypto.PubKey `json:"public_key"` PubKey crypto.PubKey `json:"public_key" yaml:"public_key"`
AccountNumber uint64 `json:"account_number"` AccountNumber uint64 `json:"account_number" yaml:"account_number"`
Sequence uint64 `json:"sequence"` Sequence uint64 `json:"sequence" yaml:"sequence"`
} }
// NewBaseAccount creates a new BaseAccount object // NewBaseAccount creates a new BaseAccount object

View File

@ -6,7 +6,7 @@ import (
// GenesisState - all auth state that must be provided at genesis // GenesisState - all auth state that must be provided at genesis
type GenesisState struct { type GenesisState struct {
Params Params `json:"params"` Params Params `json:"params" yaml:"params"`
} }
// NewGenesisState - Create a new genesis state // NewGenesisState - Create a new genesis state

View File

@ -33,11 +33,11 @@ var _ subspace.ParamSet = &Params{}
// Params defines the parameters for the auth module. // Params defines the parameters for the auth module.
type Params struct { type Params struct {
MaxMemoCharacters uint64 `json:"max_memo_characters"` MaxMemoCharacters uint64 `json:"max_memo_characters" yaml:"max_memo_characters"`
TxSigLimit uint64 `json:"tx_sig_limit"` TxSigLimit uint64 `json:"tx_sig_limit" yaml:"tx_sig_limit"`
TxSizeCostPerByte uint64 `json:"tx_size_cost_per_byte"` TxSizeCostPerByte uint64 `json:"tx_size_cost_per_byte" yaml:"tx_size_cost_per_byte"`
SigVerifyCostED25519 uint64 `json:"sig_verify_cost_ed25519"` SigVerifyCostED25519 uint64 `json:"sig_verify_cost_ed25519" yaml:"sig_verify_cost_ed25519"`
SigVerifyCostSecp256k1 uint64 `json:"sig_verify_cost_secp256k1"` SigVerifyCostSecp256k1 uint64 `json:"sig_verify_cost_secp256k1" yaml:"sig_verify_cost_secp256k1"`
} }
// NewParams creates a new Params object // NewParams creates a new Params object

View File

@ -8,12 +8,12 @@ import (
// a Msg with the other requirements for a StdSignDoc before // a Msg with the other requirements for a StdSignDoc before
// it is signed. For use in the CLI. // it is signed. For use in the CLI.
type StdSignMsg struct { type StdSignMsg struct {
ChainID string `json:"chain_id"` ChainID string `json:"chain_id" yaml:"chain_id"`
AccountNumber uint64 `json:"account_number"` AccountNumber uint64 `json:"account_number" yaml:"account_number"`
Sequence uint64 `json:"sequence"` Sequence uint64 `json:"sequence" yaml:"sequence"`
Fee StdFee `json:"fee"` Fee StdFee `json:"fee" yaml:"fee"`
Msgs []sdk.Msg `json:"msgs"` Msgs []sdk.Msg `json:"msgs" yaml:"msgs"`
Memo string `json:"memo"` Memo string `json:"memo" yaml:"memo"`
} }
// get message bytes // get message bytes

View File

@ -6,6 +6,7 @@ import (
"github.com/tendermint/tendermint/crypto" "github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/crypto/multisig" "github.com/tendermint/tendermint/crypto/multisig"
yaml "gopkg.in/yaml.v2"
"github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types" 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. // 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). // NOTE: the first signature is the fee payer (Signatures must not be nil).
type StdTx struct { type StdTx struct {
Msgs []sdk.Msg `json:"msg"` Msgs []sdk.Msg `json:"msg" yaml:"msg"`
Fee StdFee `json:"fee"` Fee StdFee `json:"fee" yaml:"fee"`
Signatures []StdSignature `json:"signatures"` Signatures []StdSignature `json:"signatures" yaml:"signatures"`
Memo string `json:"memo"` Memo string `json:"memo" yaml:"memo"`
} }
func NewStdTx(msgs []sdk.Msg, fee StdFee, sigs []StdSignature, memo string) StdTx { 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", // 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. // which must be above some miminum to be accepted into the mempool.
type StdFee struct { type StdFee struct {
Amount sdk.Coins `json:"amount"` Amount sdk.Coins `json:"amount" yaml:"amount"`
Gas uint64 `json:"gas"` Gas uint64 `json:"gas" yaml:"gas"`
} }
// NewStdFee returns a new instance of StdFee // 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 // and the Sequence numbers for each signature (prevent
// inchain replay and enforce tx ordering per account). // inchain replay and enforce tx ordering per account).
type StdSignDoc struct { type StdSignDoc struct {
AccountNumber uint64 `json:"account_number"` AccountNumber uint64 `json:"account_number" yaml:"account_number"`
ChainID string `json:"chain_id"` ChainID string `json:"chain_id" yaml:"chain_id"`
Fee json.RawMessage `json:"fee"` Fee json.RawMessage `json:"fee" yaml:"fee"`
Memo string `json:"memo"` Memo string `json:"memo" yaml:"memo"`
Msgs []json.RawMessage `json:"msgs"` Msgs []json.RawMessage `json:"msgs" yaml:"msgs"`
Sequence uint64 `json:"sequence"` Sequence uint64 `json:"sequence" yaml:"sequence"`
} }
// StdSignBytes returns the bytes to sign for a transaction. // 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 // StdSignature represents a sig
type StdSignature struct { type StdSignature struct {
crypto.PubKey `json:"pub_key"` // optional crypto.PubKey `json:"pub_key" yaml:"pub_key"` // optional
Signature []byte `json:"signature"` Signature []byte `json:"signature" yaml:"signature"`
} }
// DefaultTxDecoder logic for standard transaction decoding // DefaultTxDecoder logic for standard transaction decoding
@ -217,3 +218,32 @@ func DefaultTxEncoder(cdc *codec.Codec) sdk.TxEncoder {
return cdc.MarshalBinaryLengthPrefixed(tx) 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
}

View File

@ -9,6 +9,7 @@ import (
"github.com/tendermint/tendermint/crypto" "github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/crypto/ed25519" "github.com/tendermint/tendermint/crypto/ed25519"
"github.com/tendermint/tendermint/libs/log" "github.com/tendermint/tendermint/libs/log"
yaml "gopkg.in/yaml.v2"
"github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
@ -133,3 +134,31 @@ func TestDefaultTxEncoder(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
require.Equal(t, cdcBytes, encoderBytes) 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)
}
}

View File

@ -21,8 +21,8 @@ func RegisterRoutes(cliCtx context.CLIContext, r *mux.Router) {
// SendReq defines the properties of a send request's body. // SendReq defines the properties of a send request's body.
type SendReq struct { type SendReq struct {
BaseReq rest.BaseReq `json:"base_req"` BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"`
Amount sdk.Coins `json:"amount"` Amount sdk.Coins `json:"amount" yaml:"amount"`
} }
// SendRequestHandlerFn - http request handler to send coins to a address. // SendRequestHandlerFn - http request handler to send coins to a address.

View File

@ -6,7 +6,7 @@ import (
// GenesisState is the bank state that must be provided at genesis. // GenesisState is the bank state that must be provided at genesis.
type GenesisState struct { type GenesisState struct {
SendEnabled bool `json:"send_enabled"` SendEnabled bool `json:"send_enabled" yaml:"send_enabled"`
} }
// NewGenesisState creates a new genesis state. // NewGenesisState creates a new genesis state.

View File

@ -9,9 +9,9 @@ const RouterKey = ModuleName
// MsgSend - high level transaction of the coin module // MsgSend - high level transaction of the coin module
type MsgSend struct { type MsgSend struct {
FromAddress sdk.AccAddress `json:"from_address"` FromAddress sdk.AccAddress `json:"from_address" yaml:"from_address"`
ToAddress sdk.AccAddress `json:"to_address"` ToAddress sdk.AccAddress `json:"to_address" yaml:"to_address"`
Amount sdk.Coins `json:"amount"` Amount sdk.Coins `json:"amount" yaml:"amount"`
} }
var _ sdk.Msg = MsgSend{} var _ sdk.Msg = MsgSend{}
@ -56,8 +56,8 @@ func (msg MsgSend) GetSigners() []sdk.AccAddress {
// MsgMultiSend - high level transaction of the coin module // MsgMultiSend - high level transaction of the coin module
type MsgMultiSend struct { type MsgMultiSend struct {
Inputs []Input `json:"inputs"` Inputs []Input `json:"inputs" yaml:"inputs"`
Outputs []Output `json:"outputs"` Outputs []Output `json:"outputs" yaml:"outputs"`
} }
var _ sdk.Msg = MsgMultiSend{} var _ sdk.Msg = MsgMultiSend{}
@ -103,8 +103,8 @@ func (msg MsgMultiSend) GetSigners() []sdk.AccAddress {
// Input models transaction input // Input models transaction input
type Input struct { type Input struct {
Address sdk.AccAddress `json:"address"` Address sdk.AccAddress `json:"address" yaml:"address"`
Coins sdk.Coins `json:"coins"` Coins sdk.Coins `json:"coins" yaml:"coins"`
} }
// ValidateBasic - validate transaction input // ValidateBasic - validate transaction input
@ -131,8 +131,8 @@ func NewInput(addr sdk.AccAddress, coins sdk.Coins) Input {
// Output models transaction outputs // Output models transaction outputs
type Output struct { type Output struct {
Address sdk.AccAddress `json:"address"` Address sdk.AccAddress `json:"address" yaml:"address"`
Coins sdk.Coins `json:"coins"` Coins sdk.Coins `json:"coins" yaml:"coins"`
} }
// ValidateBasic - validate transaction output // ValidateBasic - validate transaction output

View File

@ -8,7 +8,7 @@ import (
// GenesisState - crisis genesis state // GenesisState - crisis genesis state
type GenesisState struct { type GenesisState struct {
ConstantFee sdk.Coin `json:"constant_fee"` ConstantFee sdk.Coin `json:"constant_fee" yaml:"constant_fee"`
} }
// NewGenesisState creates a new GenesisState object // NewGenesisState creates a new GenesisState object

View File

@ -6,9 +6,9 @@ import (
// MsgVerifyInvariant - message struct to verify a particular invariance // MsgVerifyInvariant - message struct to verify a particular invariance
type MsgVerifyInvariant struct { type MsgVerifyInvariant struct {
Sender sdk.AccAddress `json:"sender"` Sender sdk.AccAddress `json:"sender" yaml:"sender"`
InvariantModuleName string `json:"invariant_module_name"` InvariantModuleName string `json:"invariant_module_name" yaml:"invariant_module_name"`
InvariantRoute string `json:"invariant_route"` InvariantRoute string `json:"invariant_route" yaml:"invariant_route"`
} }
// ensure Msg interface compliance at compile time // ensure Msg interface compliance at compile time

View File

@ -10,11 +10,11 @@ import (
type ( type (
// CommunityPoolSpendProposalJSON defines a CommunityPoolSpendProposal with a deposit // CommunityPoolSpendProposalJSON defines a CommunityPoolSpendProposal with a deposit
CommunityPoolSpendProposalJSON struct { CommunityPoolSpendProposalJSON struct {
Title string `json:"title"` Title string `json:"title" yaml:"title"`
Description string `json:"description"` Description string `json:"description" yaml:"description"`
Recipient sdk.AccAddress `json:"recipient"` Recipient sdk.AccAddress `json:"recipient" yaml:"recipient"`
Amount sdk.Coins `json:"amount"` Amount sdk.Coins `json:"amount" yaml:"amount"`
Deposit sdk.Coins `json:"deposit"` Deposit sdk.Coins `json:"deposit" yaml:"deposit"`
} }
) )

View File

@ -129,9 +129,9 @@ func delegatorWithdrawalAddrHandlerFn(cliCtx context.CLIContext, queryRoute stri
// ValidatorDistInfo defines the properties of // ValidatorDistInfo defines the properties of
// validator distribution information response. // validator distribution information response.
type ValidatorDistInfo struct { type ValidatorDistInfo struct {
OperatorAddress sdk.AccAddress `json:"operator_address"` OperatorAddress sdk.AccAddress `json:"operator_address" yaml:"operator_address"`
SelfBondRewards sdk.DecCoins `json:"self_bond_rewards"` SelfBondRewards sdk.DecCoins `json:"self_bond_rewards" yaml:"self_bond_rewards"`
ValidatorCommission types.ValidatorAccumulatedCommission `json:"val_commission"` ValidatorCommission types.ValidatorAccumulatedCommission `json:"val_commission" yaml:"val_commission"`
} }
// NewValidatorDistInfo creates a new instance of ValidatorDistInfo. // NewValidatorDistInfo creates a new instance of ValidatorDistInfo.

View File

@ -43,12 +43,12 @@ func registerTxRoutes(cliCtx context.CLIContext, r *mux.Router, queryRoute strin
type ( type (
withdrawRewardsReq struct { withdrawRewardsReq struct {
BaseReq rest.BaseReq `json:"base_req"` BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"`
} }
setWithdrawalAddrReq struct { setWithdrawalAddrReq struct {
BaseReq rest.BaseReq `json:"base_req"` BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"`
WithdrawAddress sdk.AccAddress `json:"withdraw_address"` WithdrawAddress sdk.AccAddress `json:"withdraw_address" yaml:"withdraw_address"`
} }
) )

View File

@ -8,13 +8,13 @@ import (
type ( type (
// CommunityPoolSpendProposalReq defines a community pool spend proposal request body. // CommunityPoolSpendProposalReq defines a community pool spend proposal request body.
CommunityPoolSpendProposalReq struct { CommunityPoolSpendProposalReq struct {
BaseReq rest.BaseReq `json:"base_req"` BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"`
Title string `json:"title"` Title string `json:"title" yaml:"title"`
Description string `json:"description"` Description string `json:"description" yaml:"description"`
Recipient sdk.AccAddress `json:"recipient"` Recipient sdk.AccAddress `json:"recipient" yaml:"recipient"`
Amount sdk.Coins `json:"amount"` Amount sdk.Coins `json:"amount" yaml:"amount"`
Proposer sdk.AccAddress `json:"proposer"` Proposer sdk.AccAddress `json:"proposer" yaml:"proposer"`
Deposit sdk.Coins `json:"deposit"` Deposit sdk.Coins `json:"deposit" yaml:"deposit"`
} }
) )

View File

@ -12,9 +12,9 @@ import (
// delegators within the validator may be left with less than a full token, // delegators within the validator may be left with less than a full token,
// thus sdk.Dec is used // thus sdk.Dec is used
type DelegatorStartingInfo struct { type DelegatorStartingInfo struct {
PreviousPeriod uint64 `json:"previous_period"` // period at which the delegation should withdraw starting from PreviousPeriod uint64 `json:"previous_period" yaml:"previous_period"` // period at which the delegation should withdraw starting from
Stake sdk.Dec `json:"stake"` // amount of staking token delegated Stake sdk.Dec `json:"stake" yaml:"stake"` // amount of staking token delegated
Height uint64 `json:"creation_height"` // height at which delegation was created Height uint64 `json:"creation_height" yaml:"creation_height"` // height at which delegation was created
} }
// create a new DelegatorStartingInfo // create a new DelegatorStartingInfo

View File

@ -8,7 +8,7 @@ import (
// global fee pool for distribution // global fee pool for distribution
type FeePool struct { 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 // zero fee pool

View File

@ -9,65 +9,65 @@ import (
// the address for where distributions rewards are withdrawn to by default // the address for where distributions rewards are withdrawn to by default
// this struct is only used at genesis to feed in default withdraw addresses // this struct is only used at genesis to feed in default withdraw addresses
type DelegatorWithdrawInfo struct { type DelegatorWithdrawInfo struct {
DelegatorAddress sdk.AccAddress `json:"delegator_address"` DelegatorAddress sdk.AccAddress `json:"delegator_address" yaml:"delegator_address"`
WithdrawAddress sdk.AccAddress `json:"withdraw_address"` WithdrawAddress sdk.AccAddress `json:"withdraw_address" yaml:"withdraw_address"`
} }
// used for import/export via genesis json // used for import/export via genesis json
type ValidatorOutstandingRewardsRecord struct { type ValidatorOutstandingRewardsRecord struct {
ValidatorAddress sdk.ValAddress `json:"validator_address"` ValidatorAddress sdk.ValAddress `json:"validator_address" yaml:"validator_address"`
OutstandingRewards sdk.DecCoins `json:"outstanding_rewards"` OutstandingRewards sdk.DecCoins `json:"outstanding_rewards" yaml:"outstanding_rewards"`
} }
// used for import / export via genesis json // used for import / export via genesis json
type ValidatorAccumulatedCommissionRecord struct { type ValidatorAccumulatedCommissionRecord struct {
ValidatorAddress sdk.ValAddress `json:"validator_address"` ValidatorAddress sdk.ValAddress `json:"validator_address" yaml:"validator_address"`
Accumulated ValidatorAccumulatedCommission `json:"accumulated"` Accumulated ValidatorAccumulatedCommission `json:"accumulated" yaml:"accumulated"`
} }
// used for import / export via genesis json // used for import / export via genesis json
type ValidatorHistoricalRewardsRecord struct { type ValidatorHistoricalRewardsRecord struct {
ValidatorAddress sdk.ValAddress `json:"validator_address"` ValidatorAddress sdk.ValAddress `json:"validator_address" yaml:"validator_address"`
Period uint64 `json:"period"` Period uint64 `json:"period" yaml:"period"`
Rewards ValidatorHistoricalRewards `json:"rewards"` Rewards ValidatorHistoricalRewards `json:"rewards" yaml:"rewards"`
} }
// used for import / export via genesis json // used for import / export via genesis json
type ValidatorCurrentRewardsRecord struct { type ValidatorCurrentRewardsRecord struct {
ValidatorAddress sdk.ValAddress `json:"validator_address"` ValidatorAddress sdk.ValAddress `json:"validator_address" yaml:"validator_address"`
Rewards ValidatorCurrentRewards `json:"rewards"` Rewards ValidatorCurrentRewards `json:"rewards" yaml:"rewards"`
} }
// used for import / export via genesis json // used for import / export via genesis json
type DelegatorStartingInfoRecord struct { type DelegatorStartingInfoRecord struct {
DelegatorAddress sdk.AccAddress `json:"delegator_address"` DelegatorAddress sdk.AccAddress `json:"delegator_address" yaml:"delegator_address"`
ValidatorAddress sdk.ValAddress `json:"validator_address"` ValidatorAddress sdk.ValAddress `json:"validator_address" yaml:"validator_address"`
StartingInfo DelegatorStartingInfo `json:"starting_info"` StartingInfo DelegatorStartingInfo `json:"starting_info" yaml:"starting_info"`
} }
// used for import / export via genesis json // used for import / export via genesis json
type ValidatorSlashEventRecord struct { type ValidatorSlashEventRecord struct {
ValidatorAddress sdk.ValAddress `json:"validator_address"` ValidatorAddress sdk.ValAddress `json:"validator_address" yaml:"validator_address"`
Height uint64 `json:"height"` Height uint64 `json:"height" yaml:"height"`
Period uint64 `json:"period"` Period uint64 `json:"period" yaml:"period"`
Event ValidatorSlashEvent `json:"validator_slash_event"` Event ValidatorSlashEvent `json:"validator_slash_event" yaml:"validator_slash_event"`
} }
// GenesisState - all distribution state that must be provided at genesis // GenesisState - all distribution state that must be provided at genesis
type GenesisState struct { type GenesisState struct {
FeePool FeePool `json:"fee_pool"` FeePool FeePool `json:"fee_pool" yaml:"fee_pool"`
CommunityTax sdk.Dec `json:"community_tax"` CommunityTax sdk.Dec `json:"community_tax" yaml:"community_tax"`
BaseProposerReward sdk.Dec `json:"base_proposer_reward"` BaseProposerReward sdk.Dec `json:"base_proposer_reward" yaml:"base_proposer_reward"`
BonusProposerReward sdk.Dec `json:"bonus_proposer_reward"` BonusProposerReward sdk.Dec `json:"bonus_proposer_reward" yaml:"bonus_proposer_reward"`
WithdrawAddrEnabled bool `json:"withdraw_addr_enabled"` WithdrawAddrEnabled bool `json:"withdraw_addr_enabled" yaml:"withdraw_addr_enabled"`
DelegatorWithdrawInfos []DelegatorWithdrawInfo `json:"delegator_withdraw_infos"` DelegatorWithdrawInfos []DelegatorWithdrawInfo `json:"delegator_withdraw_infos" yaml:"delegator_withdraw_infos"`
PreviousProposer sdk.ConsAddress `json:"previous_proposer"` PreviousProposer sdk.ConsAddress `json:"previous_proposer" yaml:"previous_proposer"`
OutstandingRewards []ValidatorOutstandingRewardsRecord `json:"outstanding_rewards"` OutstandingRewards []ValidatorOutstandingRewardsRecord `json:"outstanding_rewards" yaml:"outstanding_rewards"`
ValidatorAccumulatedCommissions []ValidatorAccumulatedCommissionRecord `json:"validator_accumulated_commissions"` ValidatorAccumulatedCommissions []ValidatorAccumulatedCommissionRecord `json:"validator_accumulated_commissions" yaml:"validator_accumulated_commissions"`
ValidatorHistoricalRewards []ValidatorHistoricalRewardsRecord `json:"validator_historical_rewards"` ValidatorHistoricalRewards []ValidatorHistoricalRewardsRecord `json:"validator_historical_rewards" yaml:"validator_historical_rewards"`
ValidatorCurrentRewards []ValidatorCurrentRewardsRecord `json:"validator_current_rewards"` ValidatorCurrentRewards []ValidatorCurrentRewardsRecord `json:"validator_current_rewards" yaml:"validator_current_rewards"`
DelegatorStartingInfos []DelegatorStartingInfoRecord `json:"delegator_starting_infos"` DelegatorStartingInfos []DelegatorStartingInfoRecord `json:"delegator_starting_infos" yaml:"delegator_starting_infos"`
ValidatorSlashEvents []ValidatorSlashEventRecord `json:"validator_slash_events"` ValidatorSlashEvents []ValidatorSlashEventRecord `json:"validator_slash_events" yaml:"validator_slash_events"`
} }
func NewGenesisState(feePool FeePool, communityTax, baseProposerReward, bonusProposerReward sdk.Dec, func NewGenesisState(feePool FeePool, communityTax, baseProposerReward, bonusProposerReward sdk.Dec,

View File

@ -10,8 +10,8 @@ var _, _, _ sdk.Msg = &MsgSetWithdrawAddress{}, &MsgWithdrawDelegatorReward{}, &
// msg struct for changing the withdraw address for a delegator (or validator self-delegation) // msg struct for changing the withdraw address for a delegator (or validator self-delegation)
type MsgSetWithdrawAddress struct { type MsgSetWithdrawAddress struct {
DelegatorAddress sdk.AccAddress `json:"delegator_address"` DelegatorAddress sdk.AccAddress `json:"delegator_address" yaml:"delegator_address"`
WithdrawAddress sdk.AccAddress `json:"withdraw_address"` WithdrawAddress sdk.AccAddress `json:"withdraw_address" yaml:"withdraw_address"`
} }
func NewMsgSetWithdrawAddress(delAddr, withdrawAddr sdk.AccAddress) MsgSetWithdrawAddress { 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 // msg struct for delegation withdraw from a single validator
type MsgWithdrawDelegatorReward struct { type MsgWithdrawDelegatorReward struct {
DelegatorAddress sdk.AccAddress `json:"delegator_address"` DelegatorAddress sdk.AccAddress `json:"delegator_address" yaml:"delegator_address"`
ValidatorAddress sdk.ValAddress `json:"validator_address"` ValidatorAddress sdk.ValAddress `json:"validator_address" yaml:"validator_address"`
} }
func NewMsgWithdrawDelegatorReward(delAddr sdk.AccAddress, valAddr sdk.ValAddress) MsgWithdrawDelegatorReward { func NewMsgWithdrawDelegatorReward(delAddr sdk.AccAddress, valAddr sdk.ValAddress) MsgWithdrawDelegatorReward {
@ -86,7 +86,7 @@ func (msg MsgWithdrawDelegatorReward) ValidateBasic() sdk.Error {
// msg struct for validator withdraw // msg struct for validator withdraw
type MsgWithdrawValidatorCommission struct { type MsgWithdrawValidatorCommission struct {
ValidatorAddress sdk.ValAddress `json:"validator_address"` ValidatorAddress sdk.ValAddress `json:"validator_address" yaml:"validator_address"`
} }
func NewMsgWithdrawValidatorCommission(valAddr sdk.ValAddress) MsgWithdrawValidatorCommission { func NewMsgWithdrawValidatorCommission(valAddr sdk.ValAddress) MsgWithdrawValidatorCommission {

View File

@ -23,10 +23,10 @@ func init() {
// CommunityPoolSpendProposal spends from the community pool // CommunityPoolSpendProposal spends from the community pool
type CommunityPoolSpendProposal struct { type CommunityPoolSpendProposal struct {
Title string `json:"title"` Title string `json:"title" yaml:"title"`
Description string `json:"description"` Description string `json:"description" yaml:"description"`
Recipient sdk.AccAddress `json:"recipient"` Recipient sdk.AccAddress `json:"recipient" yaml:"recipient"`
Amount sdk.Coins `json:"amount"` Amount sdk.Coins `json:"amount" yaml:"amount"`
} }
// NewCommunityPoolSpendProposal creates a new community pool spned proposal. // NewCommunityPoolSpendProposal creates a new community pool spned proposal.

View File

@ -22,7 +22,7 @@ const (
// params for query 'custom/distr/validator_outstanding_rewards' // params for query 'custom/distr/validator_outstanding_rewards'
type QueryValidatorOutstandingRewardsParams struct { type QueryValidatorOutstandingRewardsParams struct {
ValidatorAddress sdk.ValAddress `json:"validator_address"` ValidatorAddress sdk.ValAddress `json:"validator_address" yaml:"validator_address"`
} }
// creates a new instance of QueryValidatorOutstandingRewardsParams // creates a new instance of QueryValidatorOutstandingRewardsParams
@ -34,7 +34,7 @@ func NewQueryValidatorOutstandingRewardsParams(validatorAddr sdk.ValAddress) Que
// params for query 'custom/distr/validator_commission' // params for query 'custom/distr/validator_commission'
type QueryValidatorCommissionParams struct { type QueryValidatorCommissionParams struct {
ValidatorAddress sdk.ValAddress `json:"validator_address"` ValidatorAddress sdk.ValAddress `json:"validator_address" yaml:"validator_address"`
} }
// creates a new instance of QueryValidatorCommissionParams // creates a new instance of QueryValidatorCommissionParams
@ -46,9 +46,9 @@ func NewQueryValidatorCommissionParams(validatorAddr sdk.ValAddress) QueryValida
// params for query 'custom/distr/validator_slashes' // params for query 'custom/distr/validator_slashes'
type QueryValidatorSlashesParams struct { type QueryValidatorSlashesParams struct {
ValidatorAddress sdk.ValAddress `json:"validator_address"` ValidatorAddress sdk.ValAddress `json:"validator_address" yaml:"validator_address"`
StartingHeight uint64 `json:"starting_height"` StartingHeight uint64 `json:"starting_height" yaml:"starting_height"`
EndingHeight uint64 `json:"ending_height"` EndingHeight uint64 `json:"ending_height" yaml:"ending_height"`
} }
// creates a new instance of QueryValidatorSlashesParams // creates a new instance of QueryValidatorSlashesParams
@ -62,8 +62,8 @@ func NewQueryValidatorSlashesParams(validatorAddr sdk.ValAddress, startingHeight
// params for query 'custom/distr/delegation_rewards' // params for query 'custom/distr/delegation_rewards'
type QueryDelegationRewardsParams struct { type QueryDelegationRewardsParams struct {
DelegatorAddress sdk.AccAddress `json:"delegator_address"` DelegatorAddress sdk.AccAddress `json:"delegator_address" yaml:"delegator_address"`
ValidatorAddress sdk.ValAddress `json:"validator_address"` ValidatorAddress sdk.ValAddress `json:"validator_address" yaml:"validator_address"`
} }
// creates a new instance of QueryDelegationRewardsParams // 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' // params for query 'custom/distr/delegator_total_rewards' and 'custom/distr/delegator_validators'
type QueryDelegatorParams struct { type QueryDelegatorParams struct {
DelegatorAddress sdk.AccAddress `json:"delegator_address"` DelegatorAddress sdk.AccAddress `json:"delegator_address" yaml:"delegator_address"`
} }
// creates a new instance of QueryDelegationRewardsParams // creates a new instance of QueryDelegationRewardsParams
@ -88,7 +88,7 @@ func NewQueryDelegatorParams(delegatorAddr sdk.AccAddress) QueryDelegatorParams
// params for query 'custom/distr/withdraw_addr' // params for query 'custom/distr/withdraw_addr'
type QueryDelegatorWithdrawAddrParams struct { 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. // NewQueryDelegatorWithdrawAddrParams creates a new instance of QueryDelegatorWithdrawAddrParams.

View File

@ -10,8 +10,8 @@ import (
// QueryDelegatorTotalRewardsResponse defines the properties of // QueryDelegatorTotalRewardsResponse defines the properties of
// QueryDelegatorTotalRewards query's response. // QueryDelegatorTotalRewards query's response.
type QueryDelegatorTotalRewardsResponse struct { type QueryDelegatorTotalRewardsResponse struct {
Rewards []DelegationDelegatorReward `json:"rewards"` Rewards []DelegationDelegatorReward `json:"rewards" yaml:"rewards"`
Total sdk.DecCoins `json:"total"` Total sdk.DecCoins `json:"total" yaml:"total"`
} }
// NewQueryDelegatorTotalRewardsResponse constructs a QueryDelegatorTotalRewardsResponse // NewQueryDelegatorTotalRewardsResponse constructs a QueryDelegatorTotalRewardsResponse
@ -35,8 +35,8 @@ func (res QueryDelegatorTotalRewardsResponse) String() string {
// DelegationDelegatorReward defines the properties // DelegationDelegatorReward defines the properties
// of a delegator's delegation reward. // of a delegator's delegation reward.
type DelegationDelegatorReward struct { type DelegationDelegatorReward struct {
ValidatorAddress sdk.ValAddress `json:"validator_address"` ValidatorAddress sdk.ValAddress `json:"validator_address" yaml:"validator_address"`
Reward sdk.DecCoins `json:"reward"` Reward sdk.DecCoins `json:"reward" yaml:"reward"`
} }
// NewDelegationDelegatorReward constructs a DelegationDelegatorReward. // NewDelegationDelegatorReward constructs a DelegationDelegatorReward.

View File

@ -19,8 +19,8 @@ import (
// + number of slashes which ended the associated period (and might need to read that record) // + 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 // + one per validator for the zeroeth period, set on initialization
type ValidatorHistoricalRewards struct { type ValidatorHistoricalRewards struct {
CumulativeRewardRatio sdk.DecCoins `json:"cumulative_reward_ratio"` CumulativeRewardRatio sdk.DecCoins `json:"cumulative_reward_ratio" yaml:"cumulative_reward_ratio"`
ReferenceCount uint16 `json:"reference_count"` ReferenceCount uint16 `json:"reference_count" yaml:"reference_count"`
} }
// create a new ValidatorHistoricalRewards // create a new ValidatorHistoricalRewards
@ -35,8 +35,8 @@ func NewValidatorHistoricalRewards(cumulativeRewardRatio sdk.DecCoins, reference
// kept as a running counter and incremented each block // kept as a running counter and incremented each block
// as long as the validator's tokens remain constant // as long as the validator's tokens remain constant
type ValidatorCurrentRewards struct { type ValidatorCurrentRewards struct {
Rewards sdk.DecCoins `json:"rewards"` // current rewards Rewards sdk.DecCoins `json:"rewards" yaml:"rewards"` // current rewards
Period uint64 `json:"period"` // current period Period uint64 `json:"period" yaml:"period"` // current period
} }
// create a new ValidatorCurrentRewards // create a new ValidatorCurrentRewards
@ -61,8 +61,8 @@ func InitialValidatorAccumulatedCommission() ValidatorAccumulatedCommission {
// needed to calculate appropriate amounts of staking token // needed to calculate appropriate amounts of staking token
// for delegations which withdraw after a slash has occurred // for delegations which withdraw after a slash has occurred
type ValidatorSlashEvent struct { type ValidatorSlashEvent struct {
ValidatorPeriod uint64 `json:"validator_period"` // period when the slash occurred ValidatorPeriod uint64 `json:"validator_period" yaml:"validator_period"` // period when the slash occurred
Fraction sdk.Dec `json:"fraction"` // slash fraction Fraction sdk.Dec `json:"fraction" yaml:"fraction"` // slash fraction
} }
// create a new ValidatorSlashEvent // create a new ValidatorSlashEvent

View File

@ -14,21 +14,21 @@ import (
// GenesisAccount is a struct for account initialization used exclusively during genesis // GenesisAccount is a struct for account initialization used exclusively during genesis
type GenesisAccount struct { type GenesisAccount struct {
Address sdk.AccAddress `json:"address"` Address sdk.AccAddress `json:"address" yaml:"address"`
Coins sdk.Coins `json:"coins"` Coins sdk.Coins `json:"coins" yaml:"coins"`
Sequence uint64 `json:"sequence_number"` Sequence uint64 `json:"sequence_number" yaml:"sequence_number"`
AccountNumber uint64 `json:"account_number"` AccountNumber uint64 `json:"account_number" yaml:"account_number"`
// vesting account fields // vesting account fields
OriginalVesting sdk.Coins `json:"original_vesting"` // total vesting coins upon initialization OriginalVesting sdk.Coins `json:"original_vesting" yaml:"original_vesting"` // total vesting coins upon initialization
DelegatedFree sdk.Coins `json:"delegated_free"` // delegated vested coins at time of delegation DelegatedFree sdk.Coins `json:"delegated_free" yaml:"delegated_free"` // delegated vested coins at time of delegation
DelegatedVesting sdk.Coins `json:"delegated_vesting"` // delegated vesting 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"` // vesting start time (UNIX Epoch time) StartTime int64 `json:"start_time" yaml:"start_time"` // vesting start time (UNIX Epoch time)
EndTime int64 `json:"end_time"` // vesting end time (UNIX Epoch time) EndTime int64 `json:"end_time" yaml:"end_time"` // vesting end time (UNIX Epoch time)
// module account fields // module account fields
ModuleName string `json:"module_name"` // name of the module account ModuleName string `json:"module_name" yaml:"module_name"` // name of the module account
ModulePermission string `json:"module_permission"` // permission of 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 // Validate checks for errors on the vesting and module account parameters

View File

@ -26,11 +26,11 @@ const (
) )
type printInfo struct { type printInfo struct {
Moniker string `json:"moniker"` Moniker string `json:"moniker" yaml:"moniker"`
ChainID string `json:"chain_id"` ChainID string `json:"chain_id" yaml:"chain_id"`
NodeID string `json:"node_id"` NodeID string `json:"node_id" yaml:"node_id"`
GenTxsDir string `json:"gentxs_dir"` GenTxsDir string `json:"gentxs_dir" yaml:"gentxs_dir"`
AppMessage json.RawMessage `json:"app_message"` AppMessage json.RawMessage `json:"app_message" yaml:"app_message"`
} }
func newPrintInfo(moniker, chainID, nodeID, genTxsDir string, func newPrintInfo(moniker, chainID, nodeID, genTxsDir string,

View File

@ -15,7 +15,7 @@ import (
// State to Unmarshal // State to Unmarshal
type GenesisState struct { type GenesisState struct {
GenTxs []json.RawMessage `json:"gentxs"` GenTxs []json.RawMessage `json:"gentxs" yaml:"gentxs"`
} }
// NewGenesisState creates a new GenesisState object // NewGenesisState creates a new GenesisState object

View File

@ -64,26 +64,26 @@ func RegisterRoutes(cliCtx context.CLIContext, r *mux.Router, phs []ProposalREST
// PostProposalReq defines the properties of a proposal request's body. // PostProposalReq defines the properties of a proposal request's body.
type PostProposalReq struct { type PostProposalReq struct {
BaseReq rest.BaseReq `json:"base_req"` BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"`
Title string `json:"title"` // Title of the proposal Title string `json:"title" yaml:"title"` // Title of the proposal
Description string `json:"description"` // Description of the proposal Description string `json:"description" yaml:"description"` // Description of the proposal
ProposalType string `json:"proposal_type"` // Type of proposal. Initial set {PlainTextProposal, SoftwareUpgradeProposal} ProposalType string `json:"proposal_type" yaml:"proposal_type"` // Type of proposal. Initial set {PlainTextProposal, SoftwareUpgradeProposal}
Proposer sdk.AccAddress `json:"proposer"` // Address of the proposer Proposer sdk.AccAddress `json:"proposer" yaml:"proposer"` // Address of the proposer
InitialDeposit sdk.Coins `json:"initial_deposit"` // Coins to add to the proposal's deposit 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. // DepositReq defines the properties of a deposit request's body.
type DepositReq struct { type DepositReq struct {
BaseReq rest.BaseReq `json:"base_req"` BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"`
Depositor sdk.AccAddress `json:"depositor"` // Address of the depositor Depositor sdk.AccAddress `json:"depositor" yaml:"depositor"` // Address of the depositor
Amount sdk.Coins `json:"amount"` // Coins to add to the proposal's deposit 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. // VoteReq defines the properties of a vote request's body.
type VoteReq struct { type VoteReq struct {
BaseReq rest.BaseReq `json:"base_req"` BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"`
Voter sdk.AccAddress `json:"voter"` // address of the voter Voter sdk.AccAddress `json:"voter" yaml:"voter"` // address of the voter
Option string `json:"option"` // option from OptionSet chosen by the voter Option string `json:"option" yaml:"option"` // option from OptionSet chosen by the voter
} }
func postProposalHandlerFn(cliCtx context.CLIContext) http.HandlerFunc { func postProposalHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {

View File

@ -17,8 +17,8 @@ const (
// Proposer contains metadata of a governance proposal used for querying a // Proposer contains metadata of a governance proposal used for querying a
// proposer. // proposer.
type Proposer struct { type Proposer struct {
ProposalID uint64 `json:"proposal_id"` ProposalID uint64 `json:"proposal_id" yaml:"proposal_id"`
Proposer string `json:"proposer"` Proposer string `json:"proposer" yaml:"proposer"`
} }
// NewProposer returns a new Proposer given id and proposer // NewProposer returns a new Proposer given id and proposer

View File

@ -16,13 +16,13 @@ const (
// GenesisState - all staking state that must be provided at genesis // GenesisState - all staking state that must be provided at genesis
type GenesisState struct { type GenesisState struct {
StartingProposalID uint64 `json:"starting_proposal_id"` StartingProposalID uint64 `json:"starting_proposal_id" yaml:"starting_proposal_id"`
Deposits Deposits `json:"deposits"` Deposits Deposits `json:"deposits" yaml:"deposits"`
Votes Votes `json:"votes"` Votes Votes `json:"votes" yaml:"votes"`
Proposals []Proposal `json:"proposals"` Proposals []Proposal `json:"proposals" yaml:"proposals"`
DepositParams DepositParams `json:"deposit_params"` DepositParams DepositParams `json:"deposit_params" yaml:"deposit_params"`
VotingParams VotingParams `json:"voting_params"` VotingParams VotingParams `json:"voting_params" yaml:"voting_params"`
TallyParams TallyParams `json:"tally_params"` TallyParams TallyParams `json:"tally_params" yaml:"tally_params"`
} }
// NewGenesisState creates a new genesis state for the governance module // NewGenesisState creates a new genesis state for the governance module

View File

@ -8,9 +8,9 @@ import (
// Deposit // Deposit
type Deposit struct { type Deposit struct {
ProposalID uint64 `json:"proposal_id"` // proposalID of the proposal ProposalID uint64 `json:"proposal_id" yaml:"proposal_id"` // proposalID of the proposal
Depositor sdk.AccAddress `json:"depositor"` // Address of the depositor Depositor sdk.AccAddress `json:"depositor" yaml:"depositor"` // Address of the depositor
Amount sdk.Coins `json:"amount"` // Deposit amount Amount sdk.Coins `json:"amount" yaml:"amount"` // Deposit amount
} }
// NewDeposit creates a new Deposit instance // NewDeposit creates a new Deposit instance

View File

@ -17,9 +17,9 @@ var _, _, _ sdk.Msg = MsgSubmitProposal{}, MsgDeposit{}, MsgVote{}
// MsgSubmitProposal // MsgSubmitProposal
type MsgSubmitProposal struct { type MsgSubmitProposal struct {
Content Content `json:"content"` Content Content `json:"content" yaml:"content"`
InitialDeposit sdk.Coins `json:"initial_deposit"` // Initial deposit paid by sender. Must be strictly positive InitialDeposit sdk.Coins `json:"initial_deposit" yaml:"initial_deposit"` // Initial deposit paid by sender. Must be strictly positive
Proposer sdk.AccAddress `json:"proposer"` // Address of the proposer Proposer sdk.AccAddress `json:"proposer" yaml:"proposer"` // Address of the proposer
} }
func NewMsgSubmitProposal(content Content, initialDeposit sdk.Coins, proposer sdk.AccAddress) MsgSubmitProposal { func NewMsgSubmitProposal(content Content, initialDeposit sdk.Coins, proposer sdk.AccAddress) MsgSubmitProposal {
@ -77,9 +77,9 @@ func (msg MsgSubmitProposal) GetSigners() []sdk.AccAddress {
// MsgDeposit // MsgDeposit
type MsgDeposit struct { type MsgDeposit struct {
ProposalID uint64 `json:"proposal_id"` // ID of the proposal ProposalID uint64 `json:"proposal_id" yaml:"proposal_id"` // ID of the proposal
Depositor sdk.AccAddress `json:"depositor"` // Address of the depositor Depositor sdk.AccAddress `json:"depositor" yaml:"depositor"` // Address of the depositor
Amount sdk.Coins `json:"amount"` // Coins to add to the proposal's deposit 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 { func NewMsgDeposit(depositor sdk.AccAddress, proposalID uint64, amount sdk.Coins) MsgDeposit {
@ -127,9 +127,9 @@ func (msg MsgDeposit) GetSigners() []sdk.AccAddress {
// MsgVote // MsgVote
type MsgVote struct { type MsgVote struct {
ProposalID uint64 `json:"proposal_id"` // ID of the proposal ProposalID uint64 `json:"proposal_id" yaml:"proposal_id"` // ID of the proposal
Voter sdk.AccAddress `json:"voter"` // address of the voter Voter sdk.AccAddress `json:"voter" yaml:"voter"` // address of the voter
Option VoteOption `json:"option"` // option from OptionSet chosen by 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 { func NewMsgVote(voter sdk.AccAddress, proposalID uint64, option VoteOption) MsgVote {

View File

@ -26,8 +26,8 @@ func ParamKeyTable() params.KeyTable {
// Param around deposits for governance // Param around deposits for governance
type DepositParams struct { type DepositParams struct {
MinDeposit sdk.Coins `json:"min_deposit,omitempty"` // Minimum deposit for a proposal to enter voting period. 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"` // Maximum period for Atom holders to deposit on a proposal. Initial value: 2 months 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 // NewDepositParams creates a new DepositParams object
@ -51,9 +51,9 @@ func (dp DepositParams) Equal(dp2 DepositParams) bool {
// Param around Tallying votes in governance // Param around Tallying votes in governance
type TallyParams struct { type TallyParams struct {
Quorum sdk.Dec `json:"quorum,omitempty"` // Minimum percentage of total stake needed to vote for a result to be considered valid 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"` // Minimum proportion of Yes votes for proposal to pass. Initial value: 0.5 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"` // Minimum value of Veto votes to Total votes ratio for proposal to be vetoed. Initial value: 1/3 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 // NewTallyParams creates a new TallyParams object
@ -75,7 +75,7 @@ func (tp TallyParams) String() string {
// Param around Voting in governance // Param around Voting in governance
type VotingParams struct { 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 // NewVotingParams creates a new VotingParams object
@ -92,9 +92,9 @@ func (vp VotingParams) String() string {
// Params returns all of the governance params // Params returns all of the governance params
type Params struct { type Params struct {
VotingParams VotingParams `json:"voting_params"` VotingParams VotingParams `json:"voting_params" yaml:"voting_params"`
TallyParams TallyParams `json:"tally_params"` TallyParams TallyParams `json:"tally_params" yaml:"tally_params"`
DepositParams DepositParams `json:"deposit_params"` DepositParams DepositParams `json:"deposit_params" yaml:"deposit_parmas"`
} }
func (gp Params) String() string { func (gp Params) String() string {

View File

@ -12,18 +12,18 @@ import (
// Proposal defines a struct used by the governance module to allow for voting // Proposal defines a struct used by the governance module to allow for voting
// on network changes. // on network changes.
type Proposal struct { 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 ProposalID uint64 `json:"id" yaml:"id"` // ID of the proposal
Status ProposalStatus `json:"proposal_status"` // Status of the Proposal {Pending, Active, Passed, Rejected} Status ProposalStatus `json:"proposal_status" yaml:"proposal_status"` // Status of the Proposal {Pending, Active, Passed, Rejected}
FinalTallyResult TallyResult `json:"final_tally_result"` // Result of Tallys 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 SubmitTime time.Time `json:"submit_time" yaml:"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 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"` // Current deposit on this proposal. Initial value is set at InitialDeposit 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 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"` // Time that the VotingPeriod for this proposal will end and votes will be tallied 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 { 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 // Tally Results
type TallyResult struct { type TallyResult struct {
Yes sdk.Int `json:"yes"` Yes sdk.Int `json:"yes" yaml:"yes"`
Abstain sdk.Int `json:"abstain"` Abstain sdk.Int `json:"abstain" yaml:"abstain"`
No sdk.Int `json:"no"` No sdk.Int `json:"no" yaml:"no"`
NoWithVeto sdk.Int `json:"no_with_veto"` NoWithVeto sdk.Int `json:"no_with_veto" yaml:"no_with_veto"`
} }
func NewTallyResult(yes, abstain, no, noWithVeto sdk.Int) TallyResult { func NewTallyResult(yes, abstain, no, noWithVeto sdk.Int) TallyResult {
@ -255,8 +255,8 @@ const (
// Text Proposal // Text Proposal
type TextProposal struct { type TextProposal struct {
Title string `json:"title"` Title string `json:"title" yaml:"title"`
Description string `json:"description"` Description string `json:"description" yaml:"description"`
} }
func NewTextProposal(title, description string) Content { 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, // TODO: We have to add fields for SUP specific arguments e.g. commit hash,
// upgrade date, etc. // upgrade date, etc.
type SoftwareUpgradeProposal struct { type SoftwareUpgradeProposal struct {
Title string `json:"title"` Title string `json:"title" yaml:"title"`
Description string `json:"description"` Description string `json:"description" yaml:"description"`
} }
func NewSoftwareUpgradeProposal(title, description string) Content { func NewSoftwareUpgradeProposal(title, description string) Content {

View File

@ -9,9 +9,9 @@ import (
// Vote // Vote
type Vote struct { type Vote struct {
ProposalID uint64 `json:"proposal_id"` // proposalID of the proposal ProposalID uint64 `json:"proposal_id" yaml:"proposal_id"` // proposalID of the proposal
Voter sdk.AccAddress `json:"voter"` // address of the voter Voter sdk.AccAddress `json:"voter" yaml:"voter"` // address of the voter
Option VoteOption `json:"option"` // option from OptionSet chosen by the voter Option VoteOption `json:"option" yaml:"option"` // option from OptionSet chosen by the voter
} }
// NewVote creates a new Vote instance // NewVote creates a new Vote instance

View File

@ -6,8 +6,8 @@ import (
// GenesisState - minter state // GenesisState - minter state
type GenesisState struct { type GenesisState struct {
Minter Minter `json:"minter"` // minter object Minter Minter `json:"minter" yaml:"minter"` // minter object
Params Params `json:"params"` // inflation params Params Params `json:"params" yaml:"params"` // inflation params
} }
// NewGenesisState creates a new GenesisState object // NewGenesisState creates a new GenesisState object

View File

@ -8,8 +8,8 @@ import (
// Minter represents the minting state. // Minter represents the minting state.
type Minter struct { type Minter struct {
Inflation sdk.Dec `json:"inflation"` // current annual inflation rate Inflation sdk.Dec `json:"inflation" yaml:"inflation"` // current annual inflation rate
AnnualProvisions sdk.Dec `json:"annual_provisions"` // current annual expected provisions 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 // NewMinter returns a new Minter object with the given inflation and annual

View File

@ -19,12 +19,12 @@ var (
// mint parameters // mint parameters
type Params struct { type Params struct {
MintDenom string `json:"mint_denom"` // type of coin to mint MintDenom string `json:"mint_denom" yaml:"mint_denom"` // type of coin to mint
InflationRateChange sdk.Dec `json:"inflation_rate_change"` // maximum annual change in inflation rate InflationRateChange sdk.Dec `json:"inflation_rate_change" yaml:"inflation_rate_change"` // maximum annual change in inflation rate
InflationMax sdk.Dec `json:"inflation_max"` // maximum inflation rate InflationMax sdk.Dec `json:"inflation_max" yaml:"inflation_max"` // maximum inflation rate
InflationMin sdk.Dec `json:"inflation_min"` // minimum inflation rate InflationMin sdk.Dec `json:"inflation_min" yaml:"inflation_min"` // minimum inflation rate
GoalBonded sdk.Dec `json:"goal_bonded"` // goal of percent bonded atoms GoalBonded sdk.Dec `json:"goal_bonded" yaml:"goal_bonded"` // goal of percent bonded atoms
BlocksPerYear uint64 `json:"blocks_per_year"` // expected blocks per year BlocksPerYear uint64 `json:"blocks_per_year" yaml:"blocks_per_year"` // expected blocks per year
} }
// ParamTable for minting module. // ParamTable for minting module.

View File

@ -18,30 +18,30 @@ type (
// ParamChangeJSON defines a parameter change used in JSON input. This // ParamChangeJSON defines a parameter change used in JSON input. This
// allows values to be specified in raw JSON instead of being string encoded. // allows values to be specified in raw JSON instead of being string encoded.
ParamChangeJSON struct { ParamChangeJSON struct {
Subspace string `json:"subspace"` Subspace string `json:"subspace" yaml:"subspace"`
Key string `json:"key"` Key string `json:"key" yaml:"key"`
Subkey string `json:"subkey,omitempty"` Subkey string `json:"subkey,omitempty" yaml:"subkey,omitempty"`
Value json.RawMessage `json:"value"` Value json.RawMessage `json:"value" yaml:"value"`
} }
// ParamChangeProposalJSON defines a ParameterChangeProposal with a deposit used // ParamChangeProposalJSON defines a ParameterChangeProposal with a deposit used
// to parse parameter change proposals from a JSON file. // to parse parameter change proposals from a JSON file.
ParamChangeProposalJSON struct { ParamChangeProposalJSON struct {
Title string `json:"title"` Title string `json:"title" yaml:"title"`
Description string `json:"description"` Description string `json:"description" yaml:"description"`
Changes ParamChangesJSON `json:"changes"` Changes ParamChangesJSON `json:"changes" yaml:"changes"`
Deposit sdk.Coins `json:"deposit"` Deposit sdk.Coins `json:"deposit" yaml:"deposit"`
} }
// ParamChangeProposalReq defines a parameter change proposal request body. // ParamChangeProposalReq defines a parameter change proposal request body.
ParamChangeProposalReq struct { ParamChangeProposalReq struct {
BaseReq rest.BaseReq `json:"base_req"` BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"`
Title string `json:"title"` Title string `json:"title" yaml:"title"`
Description string `json:"description"` Description string `json:"description" yaml:"description"`
Changes ParamChangesJSON `json:"changes"` Changes ParamChangesJSON `json:"changes" yaml:"changes"`
Proposer sdk.AccAddress `json:"proposer"` Proposer sdk.AccAddress `json:"proposer" yaml:"proposer"`
Deposit sdk.Coins `json:"deposit"` Deposit sdk.Coins `json:"deposit" yaml:"deposit"`
} }
) )

View File

@ -181,8 +181,8 @@ func TestSubspace(t *testing.T) {
} }
type paramJSON struct { type paramJSON struct {
Param1 int64 `json:"param1,omitempty"` Param1 int64 `json:"param1,omitempty" yaml:"param1,omitempty"`
Param2 string `json:"param2,omitempty"` Param2 string `json:"param2,omitempty" yaml:"param2,omitempty"`
} }
func TestJSONUpdate(t *testing.T) { func TestJSONUpdate(t *testing.T) {

View File

@ -32,13 +32,13 @@ var (
) )
type testParamsSlashingRate struct { type testParamsSlashingRate struct {
DoubleSign uint16 `json:"double_sign,omitempty"` DoubleSign uint16 `json:"double_sign,omitempty" yaml:"double_sign,omitempty"`
Downtime uint16 `json:"downtime,omitempty"` Downtime uint16 `json:"downtime,omitempty" yaml:"downtime,omitempty"`
} }
type testParams struct { type testParams struct {
MaxValidators uint16 `json:"max_validators"` // maximum number of validators (max uint16 = 65535) MaxValidators uint16 `json:"max_validators" yaml:"max_validators"` // maximum number of validators (max uint16 = 65535)
SlashingRate testParamsSlashingRate `json:"slashing_rate"` SlashingRate testParamsSlashingRate `json:"slashing_rate" yaml:"slashing_rate"`
} }
func (tp *testParams) ParamSetPairs() subspace.ParamSetPairs { func (tp *testParams) ParamSetPairs() subspace.ParamSetPairs {

View File

@ -24,9 +24,9 @@ func init() {
// ParameterChangeProposal defines a proposal which contains multiple parameter // ParameterChangeProposal defines a proposal which contains multiple parameter
// changes. // changes.
type ParameterChangeProposal struct { type ParameterChangeProposal struct {
Title string `json:"title"` Title string `json:"title" yaml:"title"`
Description string `json:"description"` Description string `json:"description" yaml:"description"`
Changes []ParamChange `json:"changes"` Changes []ParamChange `json:"changes" yaml:"changes"`
} }
func NewParameterChangeProposal(title, description string, changes []ParamChange) ParameterChangeProposal { func NewParameterChangeProposal(title, description string, changes []ParamChange) ParameterChangeProposal {
@ -79,10 +79,10 @@ func (pcp ParameterChangeProposal) String() string {
// ParamChange defines a parameter change. // ParamChange defines a parameter change.
type ParamChange struct { type ParamChange struct {
Subspace string `json:"subspace"` Subspace string `json:"subspace" yaml:"subspace"`
Key string `json:"key"` Key string `json:"key" yaml:"key"`
Subkey string `json:"subkey,omitempty"` Subkey string `json:"subkey,omitempty" yaml:"subkey,omitempty"`
Value string `json:"value"` Value string `json:"value" yaml:"value"`
} }
func NewParamChange(subspace, key, value string) ParamChange { func NewParamChange(subspace, key, value string) ParamChange {

View File

@ -23,7 +23,7 @@ func NewLogWriter(testingmode bool) LogWriter {
// log writter // log writter
type StandardLogWriter struct { type StandardLogWriter struct {
OpEntries []OperationEntry `json:"op_entries"` OpEntries []OperationEntry `json:"op_entries" yaml:"op_entries"`
} }
// add an entry to the log writter // add an entry to the log writter

View File

@ -34,10 +34,10 @@ const (
// OperationEntry - an operation entry for logging (ex. BeginBlock, EndBlock, XxxMsg, etc) // OperationEntry - an operation entry for logging (ex. BeginBlock, EndBlock, XxxMsg, etc)
type OperationEntry struct { type OperationEntry struct {
EntryKind string `json:"entry_kind"` EntryKind string `json:"entry_kind" yaml:"entry_kind"`
Height int64 `json:"height"` Height int64 `json:"height" yaml:"height"`
Order int64 `json:"order"` Order int64 `json:"order" yaml:"order"`
Operation json.RawMessage `json:"operation"` Operation json.RawMessage `json:"operation" yaml:"operation"`
} }
// BeginBlockEntry - operation entry for begin block // BeginBlockEntry - operation entry for begin block
@ -93,11 +93,11 @@ func (oe OperationEntry) MustMarshal() json.RawMessage {
// OperationMsg - structure for operation output // OperationMsg - structure for operation output
type OperationMsg struct { type OperationMsg struct {
Route string `json:"route"` Route string `json:"route" yaml:"route"`
Name string `json:"name"` Name string `json:"name" yaml:"name"`
Comment string `json:"comment"` Comment string `json:"comment" yaml:"comment"`
OK bool `json:"ok"` OK bool `json:"ok" yaml:"ok"`
Msg json.RawMessage `json:"msg"` Msg json.RawMessage `json:"msg" yaml:"msg"`
} }
// OperationMsg - create a new operation message from sdk.Msg // OperationMsg - create a new operation message from sdk.Msg

View File

@ -22,7 +22,7 @@ func registerTxRoutes(cliCtx context.CLIContext, r *mux.Router) {
// Unjail TX body // Unjail TX body
type UnjailReq struct { 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 { func unjailRequestHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {

View File

@ -9,9 +9,9 @@ import (
// GenesisState - all slashing state that must be provided at genesis // GenesisState - all slashing state that must be provided at genesis
type GenesisState struct { type GenesisState struct {
Params Params `json:"params"` Params Params `json:"params" yaml:"params"`
SigningInfos map[string]ValidatorSigningInfo `json:"signing_infos"` SigningInfos map[string]ValidatorSigningInfo `json:"signing_infos" yaml:"signing_infos"`
MissedBlocks map[string][]MissedBlock `json:"missed_blocks"` MissedBlocks map[string][]MissedBlock `json:"missed_blocks" yaml:"missed_blocks"`
} }
// NewGenesisState creates a new GenesisState object // NewGenesisState creates a new GenesisState object
@ -28,8 +28,8 @@ func NewGenesisState(
// MissedBlock // MissedBlock
type MissedBlock struct { type MissedBlock struct {
Index int64 `json:"index"` Index int64 `json:"index" yaml:"index"`
Missed bool `json:"missed"` Missed bool `json:"missed" yaml:"missed"`
} }
// DefaultGenesisState - default GenesisState used by Cosmos Hub // DefaultGenesisState - default GenesisState used by Cosmos Hub

View File

@ -9,7 +9,7 @@ var _ sdk.Msg = &MsgUnjail{}
// MsgUnjail - struct for unjailing jailed validator // MsgUnjail - struct for unjailing jailed validator
type MsgUnjail struct { 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 { func NewMsgUnjail(validatorAddr sdk.ValAddress) MsgUnjail {

View File

@ -41,12 +41,12 @@ func ParamKeyTable() params.KeyTable {
// Params - used for initializing default parameter for slashing at genesis // Params - used for initializing default parameter for slashing at genesis
type Params struct { type Params struct {
MaxEvidenceAge time.Duration `json:"max_evidence_age"` MaxEvidenceAge time.Duration `json:"max_evidence_age" yaml:"max_evidence_age"`
SignedBlocksWindow int64 `json:"signed_blocks_window"` SignedBlocksWindow int64 `json:"signed_blocks_window" yaml:"signed_blocks_window"`
MinSignedPerWindow sdk.Dec `json:"min_signed_per_window"` MinSignedPerWindow sdk.Dec `json:"min_signed_per_window" yaml:"min_signed_per_window"`
DowntimeJailDuration time.Duration `json:"downtime_jail_duration"` DowntimeJailDuration time.Duration `json:"downtime_jail_duration" yaml:"downtime_jail_duration"`
SlashFractionDoubleSign sdk.Dec `json:"slash_fraction_double_sign"` SlashFractionDoubleSign sdk.Dec `json:"slash_fraction_double_sign" yaml:"slash_fraction_double_sign"`
SlashFractionDowntime sdk.Dec `json:"slash_fraction_downtime"` SlashFractionDowntime sdk.Dec `json:"slash_fraction_downtime" yaml:"slash_fraction_downtime"`
} }
// NewParams creates a new Params object // NewParams creates a new Params object

View File

@ -9,12 +9,12 @@ import (
// Signing info for a validator // Signing info for a validator
type ValidatorSigningInfo struct { type ValidatorSigningInfo struct {
Address sdk.ConsAddress `json:"address"` // validator consensus address Address sdk.ConsAddress `json:"address" yaml:"address"` // validator consensus address
StartHeight int64 `json:"start_height"` // height at which validator was first a candidate OR was unjailed StartHeight int64 `json:"start_height" yaml:"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 IndexOffset int64 `json:"index_offset" yaml:"index_offset"` // index offset into signed block bit array
JailedUntil time.Time `json:"jailed_until"` // timestamp validator cannot be unjailed until JailedUntil time.Time `json:"jailed_until" yaml:"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) 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"` // missed blocks counter (to avoid scanning the array every time) 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 // Construct a new `ValidatorSigningInfo` struct

View File

@ -31,27 +31,27 @@ func registerTxRoutes(cliCtx context.CLIContext, r *mux.Router) {
type ( type (
// DelegateRequest defines the properties of a delegation request's body. // DelegateRequest defines the properties of a delegation request's body.
DelegateRequest struct { DelegateRequest struct {
BaseReq rest.BaseReq `json:"base_req"` BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"`
DelegatorAddress sdk.AccAddress `json:"delegator_address"` // in bech32 DelegatorAddress sdk.AccAddress `json:"delegator_address" yaml:"delegator_address"` // in bech32
ValidatorAddress sdk.ValAddress `json:"validator_address"` // in bech32 ValidatorAddress sdk.ValAddress `json:"validator_address" yaml:"validator_address"` // in bech32
Amount sdk.Coin `json:"amount"` Amount sdk.Coin `json:"amount" yaml:"amount"`
} }
// RedelegateRequest defines the properties of a redelegate request's body. // RedelegateRequest defines the properties of a redelegate request's body.
RedelegateRequest struct { RedelegateRequest struct {
BaseReq rest.BaseReq `json:"base_req"` BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"`
DelegatorAddress sdk.AccAddress `json:"delegator_address"` // in bech32 DelegatorAddress sdk.AccAddress `json:"delegator_address" yaml:"delegator_address"` // in bech32
ValidatorSrcAddress sdk.ValAddress `json:"validator_src_address"` // in bech32 ValidatorSrcAddress sdk.ValAddress `json:"validator_src_address" yaml:"validator_src_address"` // in bech32
ValidatorDstAddress sdk.ValAddress `json:"validator_dst_address"` // in bech32 ValidatorDstAddress sdk.ValAddress `json:"validator_dst_address" yaml:"validator_dst_address"` // in bech32
Amount sdk.Coin `json:"amount"` Amount sdk.Coin `json:"amount" yaml:"amount"`
} }
// UndelegateRequest defines the properties of a undelegate request's body. // UndelegateRequest defines the properties of a undelegate request's body.
UndelegateRequest struct { UndelegateRequest struct {
BaseReq rest.BaseReq `json:"base_req"` BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"`
DelegatorAddress sdk.AccAddress `json:"delegator_address"` // in bech32 DelegatorAddress sdk.AccAddress `json:"delegator_address" yaml:"delegator_address"` // in bech32
ValidatorAddress sdk.ValAddress `json:"validator_address"` // in bech32 ValidatorAddress sdk.ValAddress `json:"validator_address" yaml:"validator_address"` // in bech32
Amount sdk.Coin `json:"amount"` Amount sdk.Coin `json:"amount" yaml:"amount"`
} }
) )

View File

@ -11,15 +11,15 @@ type (
// Commission defines a commission parameters for a given validator. // Commission defines a commission parameters for a given validator.
Commission struct { Commission struct {
CommissionRates 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 // CommissionRates defines the initial commission rates to be used for creating a
// validator. // validator.
CommissionRates struct { CommissionRates struct {
Rate sdk.Dec `json:"rate"` // the commission rate charged to delegators, 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"` // maximum commission rate which validator can ever charge, 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"` // maximum daily increase of the validator commission, as a fraction MaxChangeRate sdk.Dec `json:"max_change_rate" yaml:"max_change_rate"` // maximum daily increase of the validator commission, as a fraction
} }
) )

View File

@ -36,9 +36,9 @@ var _ exported.DelegationI = Delegation{}
// owned by one delegator, and is associated with the voting power of one // owned by one delegator, and is associated with the voting power of one
// validator. // validator.
type Delegation struct { type Delegation struct {
DelegatorAddress sdk.AccAddress `json:"delegator_address"` DelegatorAddress sdk.AccAddress `json:"delegator_address" yaml:"delegator_address"`
ValidatorAddress sdk.ValAddress `json:"validator_address"` ValidatorAddress sdk.ValAddress `json:"validator_address" yaml:"validator_address"`
Shares sdk.Dec `json:"shares"` Shares sdk.Dec `json:"shares" yaml:"shares"`
} }
// NewDelegation creates a new delegation object // 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 // UnbondingDelegation stores all of a single delegator's unbonding bonds
// for a single validator in an time-ordered list // for a single validator in an time-ordered list
type UnbondingDelegation struct { type UnbondingDelegation struct {
DelegatorAddress sdk.AccAddress `json:"delegator_address"` // delegator DelegatorAddress sdk.AccAddress `json:"delegator_address" yaml:"delegator_address"` // delegator
ValidatorAddress sdk.ValAddress `json:"validator_address"` // validator unbonding from operator addr ValidatorAddress sdk.ValAddress `json:"validator_address" yaml:"validator_address"` // validator unbonding from operator addr
Entries []UnbondingDelegationEntry `json:"entries"` // unbonding delegation entries Entries []UnbondingDelegationEntry `json:"entries" yaml:"entries"` // unbonding delegation entries
} }
// UnbondingDelegationEntry - entry to an UnbondingDelegation // UnbondingDelegationEntry - entry to an UnbondingDelegation
type UnbondingDelegationEntry struct { type UnbondingDelegationEntry struct {
CreationHeight int64 `json:"creation_height"` // height which the unbonding took place CreationHeight int64 `json:"creation_height" yaml:"creation_height"` // height which the unbonding took place
CompletionTime time.Time `json:"completion_time"` // time at which the unbonding delegation will complete CompletionTime time.Time `json:"completion_time" yaml:"completion_time"` // time at which the unbonding delegation will complete
InitialBalance sdk.Int `json:"initial_balance"` // atoms initially scheduled to receive at completion InitialBalance sdk.Int `json:"initial_balance" yaml:"initial_balance"` // atoms initially scheduled to receive at completion
Balance sdk.Int `json:"balance"` // atoms to receive at completion Balance sdk.Int `json:"balance" yaml:"balance"` // atoms to receive at completion
} }
// IsMature - is the current entry mature // 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 // redelegating bonds from a particular source validator to a
// particular destination validator // particular destination validator
type Redelegation struct { type Redelegation struct {
DelegatorAddress sdk.AccAddress `json:"delegator_address"` // delegator DelegatorAddress sdk.AccAddress `json:"delegator_address" yaml:"delegator_address"` // delegator
ValidatorSrcAddress sdk.ValAddress `json:"validator_src_address"` // validator redelegation source operator addr ValidatorSrcAddress sdk.ValAddress `json:"validator_src_address" yaml:"validator_src_address"` // validator redelegation source operator addr
ValidatorDstAddress sdk.ValAddress `json:"validator_dst_address"` // validator redelegation destination operator addr ValidatorDstAddress sdk.ValAddress `json:"validator_dst_address" yaml:"validator_dst_address"` // validator redelegation destination operator addr
Entries []RedelegationEntry `json:"entries"` // redelegation entries Entries []RedelegationEntry `json:"entries" yaml:"entries"` // redelegation entries
} }
// RedelegationEntry - entry to a Redelegation // RedelegationEntry - entry to a Redelegation
type RedelegationEntry struct { type RedelegationEntry struct {
CreationHeight int64 `json:"creation_height"` // height at which the redelegation took place CreationHeight int64 `json:"creation_height" yaml:"creation_height"` // height at which the redelegation took place
CompletionTime time.Time `json:"completion_time"` // time at which the redelegation will complete CompletionTime time.Time `json:"completion_time" yaml:"completion_time"` // time at which the redelegation will complete
InitialBalance sdk.Int `json:"initial_balance"` // initial balance when redelegation started InitialBalance sdk.Int `json:"initial_balance" yaml:"initial_balance"` // initial balance when redelegation started
SharesDst sdk.Dec `json:"shares_dst"` // amount of destination-validator shares created by redelegation SharesDst sdk.Dec `json:"shares_dst" yaml:"shares_dst"` // amount of destination-validator shares created by redelegation
} }
// NewRedelegation - create a new redelegation object // 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. // in addition to shares which is more suitable for client responses.
type DelegationResponse struct { type DelegationResponse struct {
Delegation 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 { 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. // responses.
type RedelegationResponse struct { type RedelegationResponse struct {
Redelegation Redelegation
Entries []RedelegationEntryResponse `json:"entries"` // nolint: structtag Entries []RedelegationEntryResponse `json:"entries" yaml:"entries"` // nolint: structtag
} }
// RedelegationEntryResponse is equivalent to a RedelegationEntry except that it // RedelegationEntryResponse is equivalent to a RedelegationEntry except that it

View File

@ -6,14 +6,14 @@ import (
// GenesisState - all staking state that must be provided at genesis // GenesisState - all staking state that must be provided at genesis
type GenesisState struct { type GenesisState struct {
Params Params `json:"params"` Params Params `json:"params" yaml:"params"`
LastTotalPower sdk.Int `json:"last_total_power"` LastTotalPower sdk.Int `json:"last_total_power" yaml:"last_total_power"`
LastValidatorPowers []LastValidatorPower `json:"last_validator_powers"` LastValidatorPowers []LastValidatorPower `json:"last_validator_powers" yaml:"last_validator_powers"`
Validators Validators `json:"validators"` Validators Validators `json:"validators" yaml:"validators"`
Delegations Delegations `json:"delegations"` Delegations Delegations `json:"delegations" yaml:"delegations"`
UnbondingDelegations []UnbondingDelegation `json:"unbonding_delegations"` UnbondingDelegations []UnbondingDelegation `json:"unbonding_delegations" yaml:"unbonding_delegations"`
Redelegations []Redelegation `json:"redelegations"` Redelegations []Redelegation `json:"redelegations" yaml:"redelegations"`
Exported bool `json:"exported"` Exported bool `json:"exported" yaml:"exported"`
} }
// Last validator power, needed for validator set update logic // Last validator power, needed for validator set update logic

View File

@ -22,23 +22,23 @@ var (
// MsgCreateValidator - struct for bonding transactions // MsgCreateValidator - struct for bonding transactions
type MsgCreateValidator struct { type MsgCreateValidator struct {
Description Description `json:"description"` Description Description `json:"description" yaml:"description"`
Commission CommissionRates `json:"commission"` Commission CommissionRates `json:"commission" yaml:"commission"`
MinSelfDelegation sdk.Int `json:"min_self_delegation"` MinSelfDelegation sdk.Int `json:"min_self_delegation" yaml:"min_self_delegation"`
DelegatorAddress sdk.AccAddress `json:"delegator_address"` DelegatorAddress sdk.AccAddress `json:"delegator_address" yaml:"delegator_address"`
ValidatorAddress sdk.ValAddress `json:"validator_address"` ValidatorAddress sdk.ValAddress `json:"validator_address" yaml:"validator_address"`
PubKey crypto.PubKey `json:"pubkey"` PubKey crypto.PubKey `json:"pubkey" yaml:"pubkey"`
Value sdk.Coin `json:"value"` Value sdk.Coin `json:"value" yaml:"value"`
} }
type msgCreateValidatorJSON struct { type msgCreateValidatorJSON struct {
Description Description `json:"description"` Description Description `json:"description" yaml:"description"`
Commission CommissionRates `json:"commission"` Commission CommissionRates `json:"commission" yaml:"commission"`
MinSelfDelegation sdk.Int `json:"min_self_delegation"` MinSelfDelegation sdk.Int `json:"min_self_delegation" yaml:"min_self_delegation"`
DelegatorAddress sdk.AccAddress `json:"delegator_address"` DelegatorAddress sdk.AccAddress `json:"delegator_address" yaml:"delegator_address"`
ValidatorAddress sdk.ValAddress `json:"validator_address"` ValidatorAddress sdk.ValAddress `json:"validator_address" yaml:"validator_address"`
PubKey string `json:"pubkey"` PubKey string `json:"pubkey" yaml:"pubkey"`
Value sdk.Coin `json:"value"` Value sdk.Coin `json:"value" yaml:"value"`
} }
// Default way to create validator. Delegator address and validator address are the same // 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 // MsgEditValidator - struct for editing a validator
type MsgEditValidator struct { type MsgEditValidator struct {
Description 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 // 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 // update. If not updated, the deserialized rate will be zero with no way to
// distinguish if an update was intended. // distinguish if an update was intended.
// //
// REF: #2373 // REF: #2373
CommissionRate *sdk.Dec `json:"commission_rate"` CommissionRate *sdk.Dec `json:"commission_rate" yaml:"commission_rate"`
MinSelfDelegation *sdk.Int `json:"min_self_delegation"` 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 { 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 // MsgDelegate - struct for bonding transactions
type MsgDelegate struct { type MsgDelegate struct {
DelegatorAddress sdk.AccAddress `json:"delegator_address"` DelegatorAddress sdk.AccAddress `json:"delegator_address" yaml:"delegator_address"`
ValidatorAddress sdk.ValAddress `json:"validator_address"` ValidatorAddress sdk.ValAddress `json:"validator_address" yaml:"validator_address"`
Amount sdk.Coin `json:"amount"` Amount sdk.Coin `json:"amount" yaml:"amount"`
} }
func NewMsgDelegate(delAddr sdk.AccAddress, valAddr sdk.ValAddress, amount sdk.Coin) MsgDelegate { 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 // MsgDelegate - struct for bonding transactions
type MsgBeginRedelegate struct { type MsgBeginRedelegate struct {
DelegatorAddress sdk.AccAddress `json:"delegator_address"` DelegatorAddress sdk.AccAddress `json:"delegator_address" yaml:"delegator_address"`
ValidatorSrcAddress sdk.ValAddress `json:"validator_src_address"` ValidatorSrcAddress sdk.ValAddress `json:"validator_src_address" yaml:"validator_src_address"`
ValidatorDstAddress sdk.ValAddress `json:"validator_dst_address"` ValidatorDstAddress sdk.ValAddress `json:"validator_dst_address" yaml:"validator_dst_address"`
Amount sdk.Coin `json:"amount"` Amount sdk.Coin `json:"amount" yaml:"amount"`
} }
func NewMsgBeginRedelegate(delAddr sdk.AccAddress, valSrcAddr, func NewMsgBeginRedelegate(delAddr sdk.AccAddress, valSrcAddr,
@ -306,9 +306,9 @@ func (msg MsgBeginRedelegate) ValidateBasic() sdk.Error {
// MsgUndelegate - struct for unbonding transactions // MsgUndelegate - struct for unbonding transactions
type MsgUndelegate struct { type MsgUndelegate struct {
DelegatorAddress sdk.AccAddress `json:"delegator_address"` DelegatorAddress sdk.AccAddress `json:"delegator_address" yaml:"delegator_address"`
ValidatorAddress sdk.ValAddress `json:"validator_address"` ValidatorAddress sdk.ValAddress `json:"validator_address" yaml:"validator_address"`
Amount sdk.Coin `json:"amount"` Amount sdk.Coin `json:"amount" yaml:"amount"`
} }
func NewMsgUndelegate(delAddr sdk.AccAddress, valAddr sdk.ValAddress, amount sdk.Coin) MsgUndelegate { func NewMsgUndelegate(delAddr sdk.AccAddress, valAddr sdk.ValAddress, amount sdk.Coin) MsgUndelegate {

View File

@ -35,11 +35,11 @@ var _ params.ParamSet = (*Params)(nil)
// Params defines the high level settings for staking // Params defines the high level settings for staking
type Params struct { type Params struct {
UnbondingTime time.Duration `json:"unbonding_time"` // time duration of unbonding UnbondingTime time.Duration `json:"unbonding_time" yaml:"unbonding_time"` // time duration of unbonding
MaxValidators uint16 `json:"max_validators"` // maximum number of validators (max uint16 = 65535) MaxValidators uint16 `json:"max_validators" yaml:"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) 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 // 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, func NewParams(unbondingTime time.Duration, maxValidators, maxEntries uint16,

View File

@ -18,8 +18,8 @@ const (
// Pool - tracking bonded and not-bonded token supply of the bond denomination // Pool - tracking bonded and not-bonded token supply of the bond denomination
type Pool struct { type Pool struct {
NotBondedTokens sdk.Int `json:"not_bonded_tokens"` // tokens which are not bonded to a validator (unbonded or unbonding) 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"` // tokens which are currently bonded to a validator 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 // NewPool creates a new Pool instance used for queries

View File

@ -36,17 +36,17 @@ var _ exported.ValidatorI = Validator{}
// divided by the current exchange rate. Voting power can be calculated as total // divided by the current exchange rate. Voting power can be calculated as total
// bonded shares multiplied by exchange rate. // bonded shares multiplied by exchange rate.
type Validator struct { type Validator struct {
OperatorAddress sdk.ValAddress `json:"operator_address"` // address of the validator's operator; bech encoded in JSON 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"` // the consensus public key of the validator; 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"` // has the validator been jailed from bonded status? Jailed bool `json:"jailed" yaml:"jailed"` // has the validator been jailed from bonded status?
Status sdk.BondStatus `json:"status"` // validator status (bonded/unbonding/unbonded) Status sdk.BondStatus `json:"status" yaml:"status"` // validator status (bonded/unbonding/unbonded)
Tokens sdk.Int `json:"tokens"` // delegated tokens (incl. self-delegation) Tokens sdk.Int `json:"tokens" yaml:"tokens"` // delegated tokens (incl. self-delegation)
DelegatorShares sdk.Dec `json:"delegator_shares"` // total shares issued to a validator's delegators DelegatorShares sdk.Dec `json:"delegator_shares" yaml:"delegator_shares"` // total shares issued to a validator's delegators
Description Description `json:"description"` // description terms for the validator Description Description `json:"description" yaml:"description"` // description terms for the validator
UnbondingHeight int64 `json:"unbonding_height"` // if unbonding, height at which this validator has begun unbonding UnbondingHeight int64 `json:"unbonding_height" yaml:"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 UnbondingCompletionTime time.Time `json:"unbonding_time" yaml:"unbonding_time"` // if unbonding, min time for the validator to complete unbonding
Commission Commission `json:"commission"` // commission parameters Commission Commission `json:"commission" yaml:"commission"` // commission parameters
MinSelfDelegation sdk.Int `json:"min_self_delegation"` // validator's self declared minimum self delegation 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 // 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 // this is a helper struct used for JSON de- and encoding only
type bechValidator struct { type bechValidator struct {
OperatorAddress sdk.ValAddress `json:"operator_address"` // the bech32 address of the validator's operator OperatorAddress sdk.ValAddress `json:"operator_address" yaml:"operator_address"` // the bech32 address of the validator's operator
ConsPubKey string `json:"consensus_pubkey"` // the bech32 consensus public key of the validator ConsPubKey string `json:"consensus_pubkey" yaml:"consensus_pubkey"` // the bech32 consensus public key of the validator
Jailed bool `json:"jailed"` // has the validator been jailed from bonded status? Jailed bool `json:"jailed" yaml:"jailed"` // has the validator been jailed from bonded status?
Status sdk.BondStatus `json:"status"` // validator status (bonded/unbonding/unbonded) Status sdk.BondStatus `json:"status" yaml:"status"` // validator status (bonded/unbonding/unbonded)
Tokens sdk.Int `json:"tokens"` // delegated tokens (incl. self-delegation) Tokens sdk.Int `json:"tokens" yaml:"tokens"` // delegated tokens (incl. self-delegation)
DelegatorShares sdk.Dec `json:"delegator_shares"` // total shares issued to a validator's delegators DelegatorShares sdk.Dec `json:"delegator_shares" yaml:"delegator_shares"` // total shares issued to a validator's delegators
Description Description `json:"description"` // description terms for the validator Description Description `json:"description" yaml:"description"` // description terms for the validator
UnbondingHeight int64 `json:"unbonding_height"` // if unbonding, height at which this validator has begun unbonding UnbondingHeight int64 `json:"unbonding_height" yaml:"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 UnbondingCompletionTime time.Time `json:"unbonding_time" yaml:"unbonding_time"` // if unbonding, min time for the validator to complete unbonding
Commission Commission `json:"commission"` // commission parameters Commission Commission `json:"commission" yaml:"commission"` // commission parameters
MinSelfDelegation sdk.Int `json:"min_self_delegation"` // minimum self delegation MinSelfDelegation sdk.Int `json:"min_self_delegation" yaml:"min_self_delegation"` // minimum self delegation
} }
// MarshalJSON marshals the validator to JSON using Bech32 // MarshalJSON marshals the validator to JSON using Bech32
@ -260,10 +260,10 @@ const DoNotModifyDesc = "[do-not-modify]"
// Description - description fields for a validator // Description - description fields for a validator
type Description struct { type Description struct {
Moniker string `json:"moniker"` // name Moniker string `json:"moniker" yaml:"moniker"` // name
Identity string `json:"identity"` // optional identity signature (ex. UPort or Keybase) Identity string `json:"identity" yaml:"identity"` // optional identity signature (ex. UPort or Keybase)
Website string `json:"website"` // optional website link Website string `json:"website" yaml:"website"` // optional website link
Details string `json:"details"` // optional details Details string `json:"details" yaml:"details"` // optional details
} }
// NewDescription returns a new Description with the provided values. // NewDescription returns a new Description with the provided values.

View File

@ -295,9 +295,9 @@ func TestValidatorMarshalYAML(t *testing.T) {
commission: commission:
commissionrates: commissionrates:
rate: "0.000000000000000000" rate: "0.000000000000000000"
maxrate: "0.000000000000000000" max_rate: "0.000000000000000000"
maxchangerate: "0.000000000000000000" max_change_rate: "0.000000000000000000"
updatetime: 1970-01-01T00:00:00Z update_time: 1970-01-01T00:00:00Z
minselfdelegation: "1" minselfdelegation: "1"
`, validator.OperatorAddress.String(), bechifiedPub) `, validator.OperatorAddress.String(), bechifiedPub)
require.Equal(t, want, string(bs)) require.Equal(t, want, string(bs))

View File

@ -17,8 +17,8 @@ var _ exported.ModuleAccountI = (*ModuleAccount)(nil)
// ModuleAccount defines an account for modules that holds coins on a pool // ModuleAccount defines an account for modules that holds coins on a pool
type ModuleAccount struct { type ModuleAccount struct {
*authtypes.BaseAccount *authtypes.BaseAccount
Name string `json:"name"` // name of the module Name string `json:"name" yaml:"name"` // name of the module
Permission string `json:"permission"` // permission of module account (minter/burner/holder) 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 // NewModuleAddress creates an AccAddress from the hash of the module's name

View File

@ -2,7 +2,7 @@ package types
// GenesisState is the supply state that must be provided at genesis. // GenesisState is the supply state that must be provided at genesis.
type GenesisState struct { type GenesisState struct {
Supply Supply `json:"supply"` Supply Supply `json:"supply" yaml:"supply"`
} }
// NewGenesisState creates a new genesis state. // NewGenesisState creates a new genesis state.

View File

@ -9,7 +9,7 @@ import (
// Supply represents a struct that passively keeps track of the total supply amounts in the network // Supply represents a struct that passively keeps track of the total supply amounts in the network
type Supply struct { 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 // NewSupply creates a new Supply instance

View File

@ -4,9 +4,10 @@ import (
"fmt" "fmt"
"testing" "testing"
sdk "github.com/cosmos/cosmos-sdk/types"
"gopkg.in/yaml.v2" "gopkg.in/yaml.v2"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )
@ -20,7 +21,7 @@ func TestSupplyMarshalYAML(t *testing.T) {
bzCoins, err := yaml.Marshal(coins) bzCoins, err := yaml.Marshal(coins)
require.NoError(t, err) require.NoError(t, err)
want := fmt.Sprintf(`total: want := fmt.Sprintf(`total_supply:
%s`, string(bzCoins)) %s`, string(bzCoins))
require.Equal(t, want, string(bz)) require.Equal(t, want, string(bz))