Merge PR #3673: Message & Codec Registration Consistency

This commit is contained in:
Alexander Bezobchuk 2019-02-25 10:16:52 -05:00 committed by Christopher Goes
parent 21bdecafeb
commit b9be1166f7
52 changed files with 453 additions and 450 deletions

View File

@ -17,6 +17,9 @@
### SDK
* [\#3669] Ensure consistency in message naming, codec registration, and JSON
tags.
### Tendermint
<!--------------------------------- FEATURES --------------------------------->

View File

@ -415,7 +415,7 @@ func TestValidatorsQuery(t *testing.T) {
foundVal = true
}
require.True(t, foundVal, "pk %v, operator %v", operAddrs[0], validators[0].OperatorAddr)
require.True(t, foundVal, "pk %v, operator %v", operAddrs[0], validators[0].OperatorAddress)
}
func TestValidatorQuery(t *testing.T) {
@ -425,7 +425,7 @@ func TestValidatorQuery(t *testing.T) {
require.Equal(t, 1, len(operAddrs))
validator := getValidator(t, port, operAddrs[0])
require.Equal(t, validator.OperatorAddr, operAddrs[0], "The returned validator does not hold the correct data")
require.Equal(t, validator.OperatorAddress, operAddrs[0], "The returned validator does not hold the correct data")
}
func TestBonding(t *testing.T) {
@ -483,11 +483,11 @@ func TestBonding(t *testing.T) {
bondedValidators := getDelegatorValidators(t, port, addr)
require.Len(t, bondedValidators, 1)
require.Equal(t, operAddrs[0], bondedValidators[0].OperatorAddr)
require.Equal(t, operAddrs[0], bondedValidators[0].OperatorAddress)
require.Equal(t, validator.DelegatorShares.Add(amtDec).String(), bondedValidators[0].DelegatorShares.String())
bondedValidator := getDelegatorValidator(t, port, addr, operAddrs[0])
require.Equal(t, operAddrs[0], bondedValidator.OperatorAddr)
require.Equal(t, operAddrs[0], bondedValidator.OperatorAddress)
// testing unbonding
unbondingTokens := sdk.TokensFromTendermintPower(30)
@ -547,7 +547,7 @@ func TestBonding(t *testing.T) {
// query delegations, unbondings and redelegations from validator and delegator
delegatorDels = getDelegatorDelegations(t, port, addr)
require.Len(t, delegatorDels, 1)
require.Equal(t, operAddrs[1], delegatorDels[0].ValidatorAddr)
require.Equal(t, operAddrs[1], delegatorDels[0].ValidatorAddress)
// because the second validator never signs during these tests, if this
// this test takes a long time to run, eventually this second validator

View File

@ -465,9 +465,9 @@ paths:
properties:
base_req:
$ref: "#/definitions/BaseReq"
delegator_addr:
delegator_address:
$ref: "#/definitions/Address"
validator_addr:
validator_address:
$ref: "#/definitions/ValidatorAddress"
delegation:
$ref: "#/definitions/Coin"
@ -550,9 +550,9 @@ paths:
properties:
base_req:
$ref: "#/definitions/BaseReq"
delegator_addr:
delegator_address:
$ref: "#/definitions/Address"
validator_addr:
validator_address:
$ref: "#/definitions/ValidatorAddress"
shares:
type: string
@ -653,11 +653,11 @@ paths:
properties:
base_req:
$ref: "#/definitions/BaseReq"
delegator_addr:
delegator_address:
$ref: "#/definitions/Address"
validator_src_addr:
validator_src_addressess:
$ref: "#/definitions/ValidatorAddress"
validator_dst_addr:
validator_dst_address:
$ref: "#/definitions/ValidatorAddress"
shares:
type: string
@ -2131,9 +2131,9 @@ definitions:
Delegation:
type: object
properties:
delegator_addr:
delegator_address:
type: string
validator_addr:
validator_address:
type: string
shares:
type: string
@ -2142,9 +2142,9 @@ definitions:
UnbondingDelegation:
type: object
properties:
delegator_addr:
delegator_address:
type: string
validator_addr:
validator_address:
type: string
initial_balance:
type: string
@ -2157,11 +2157,11 @@ definitions:
Redelegation:
type: object
properties:
delegator_addr:
delegator_address:
type: string
validator_src_addr:
validator_src_address:
type: string
validator_dst_addr:
validator_dst_address:
type: string
creation_height:
type: integer
@ -2178,7 +2178,7 @@ definitions:
ValidatorDistInfo:
type: object
properties:
operator_addr:
operator_address:
$ref: "#/definitions/ValidatorAddress"
self_bond_rewards:
type: array

View File

@ -814,10 +814,10 @@ func doDelegate(
baseReq := rest.NewBaseReq(from, "", chainID, "", "", accnum, sequence, fees, nil, false)
msg := msgDelegationsInput{
BaseReq: baseReq,
DelegatorAddr: delAddr,
ValidatorAddr: valAddr,
Delegation: sdk.NewCoin(sdk.DefaultBondDenom, amount),
BaseReq: baseReq,
DelegatorAddress: delAddr,
ValidatorAddress: valAddr,
Delegation: sdk.NewCoin(sdk.DefaultBondDenom, amount),
}
req, err := cdc.MarshalJSON(msg)
@ -838,10 +838,10 @@ func doDelegate(
}
type msgDelegationsInput struct {
BaseReq rest.BaseReq `json:"base_req"`
DelegatorAddr sdk.AccAddress `json:"delegator_addr"` // in bech32
ValidatorAddr sdk.ValAddress `json:"validator_addr"` // in bech32
Delegation sdk.Coin `json:"delegation"`
BaseReq rest.BaseReq `json:"base_req"`
DelegatorAddress sdk.AccAddress `json:"delegator_address"` // in bech32
ValidatorAddress sdk.ValAddress `json:"validator_address"` // in bech32
Delegation sdk.Coin `json:"delegation"`
}
// POST /staking/delegators/{delegatorAddr}/delegations Submit delegation
@ -858,10 +858,10 @@ func doUndelegate(
baseReq := rest.NewBaseReq(from, "", chainID, "", "", accnum, sequence, fees, nil, false)
msg := msgUndelegateInput{
BaseReq: baseReq,
DelegatorAddr: delAddr,
ValidatorAddr: valAddr,
SharesAmount: amount.ToDec(),
BaseReq: baseReq,
DelegatorAddress: delAddr,
ValidatorAddress: valAddr,
SharesAmount: amount.ToDec(),
}
req, err := cdc.MarshalJSON(msg)
@ -881,10 +881,10 @@ func doUndelegate(
}
type msgUndelegateInput struct {
BaseReq rest.BaseReq `json:"base_req"`
DelegatorAddr sdk.AccAddress `json:"delegator_addr"` // in bech32
ValidatorAddr sdk.ValAddress `json:"validator_addr"` // in bech32
SharesAmount sdk.Dec `json:"shares"`
BaseReq rest.BaseReq `json:"base_req"`
DelegatorAddress sdk.AccAddress `json:"delegator_address"` // in bech32
ValidatorAddress sdk.ValAddress `json:"validator_address"` // in bech32
SharesAmount sdk.Dec `json:"shares"`
}
// POST /staking/delegators/{delegatorAddr}/delegations Submit delegation
@ -901,11 +901,11 @@ func doBeginRedelegation(
baseReq := rest.NewBaseReq(from, "", chainID, "", "", accnum, sequence, fees, nil, false)
msg := stakingrest.MsgBeginRedelegateInput{
BaseReq: baseReq,
DelegatorAddr: delAddr,
ValidatorSrcAddr: valSrcAddr,
ValidatorDstAddr: valDstAddr,
SharesAmount: amount.ToDec(),
BaseReq: baseReq,
DelegatorAddress: delAddr,
ValidatorSrcAddress: valSrcAddr,
ValidatorDstAddress: valDstAddr,
SharesAmount: amount.ToDec(),
}
req, err := cdc.MarshalJSON(msg)
@ -925,11 +925,11 @@ func doBeginRedelegation(
}
type msgBeginRedelegateInput struct {
BaseReq rest.BaseReq `json:"base_req"`
DelegatorAddr sdk.AccAddress `json:"delegator_addr"` // in bech32
ValidatorSrcAddr sdk.ValAddress `json:"validator_src_addr"` // in bech32
ValidatorDstAddr sdk.ValAddress `json:"validator_dst_addr"` // in bech32
SharesAmount sdk.Dec `json:"shares"`
BaseReq rest.BaseReq `json:"base_req"`
DelegatorAddress sdk.AccAddress `json:"delegator_address"` // in bech32
ValidatorSrcAddress sdk.ValAddress `json:"validator_src_address"` // in bech32
ValidatorDstAddress sdk.ValAddress `json:"validator_dst_address"` // in bech32
SharesAmount sdk.Dec `json:"shares"`
}
// GET /staking/delegators/{delegatorAddr}/delegations Get all delegations from a delegator

View File

@ -89,7 +89,7 @@ func (app *GaiaApp) prepForZeroHeightGenesis(ctx sdk.Context, jailWhiteList []st
// withdraw all delegator rewards
dels := app.stakingKeeper.GetAllDelegations(ctx)
for _, delegation := range dels {
_ = app.distrKeeper.WithdrawDelegationRewards(ctx, delegation.DelegatorAddr, delegation.ValidatorAddr)
_ = app.distrKeeper.WithdrawDelegationRewards(ctx, delegation.DelegatorAddress, delegation.ValidatorAddress)
}
// clear validator slash events
@ -110,7 +110,7 @@ func (app *GaiaApp) prepForZeroHeightGenesis(ctx sdk.Context, jailWhiteList []st
// reinitialize all delegations
for _, del := range dels {
app.distrKeeper.Hooks().BeforeDelegationCreated(ctx, del.DelegatorAddr, del.ValidatorAddr)
app.distrKeeper.Hooks().BeforeDelegationCreated(ctx, del.DelegatorAddress, del.ValidatorAddress)
}
// reset context height

View File

@ -360,8 +360,8 @@ func CollectStdTxs(cdc *codec.Codec, moniker string, genTxsDir string, genDoc tm
msg := msgs[0].(staking.MsgCreateValidator)
// validate delegator and validator addresses and funds against the accounts in the state
delAddr := msg.DelegatorAddr.String()
valAddr := sdk.AccAddress(msg.ValidatorAddr).String()
delAddr := msg.DelegatorAddress.String()
valAddr := sdk.AccAddress(msg.ValidatorAddress).String()
delAcc, delOk := addrMap[delAddr]
_, valOk := addrMap[valAddr]

View File

@ -40,7 +40,7 @@ func makeGenesisState(t *testing.T, genTxs []auth.StdTx) GenesisState {
require.Equal(t, 1, len(msgs))
msg := msgs[0].(staking.MsgCreateValidator)
acc := auth.NewBaseAccountWithAddress(sdk.AccAddress(msg.ValidatorAddr))
acc := auth.NewBaseAccountWithAddress(sdk.AccAddress(msg.ValidatorAddress))
acc.Coins = sdk.Coins{sdk.NewInt64Coin(defaultBondDenom, 150)}
genAccs[i] = NewGenesisAccount(&acc)
stakingData.Pool.NotBondedTokens = stakingData.Pool.NotBondedTokens.Add(sdk.NewInt(150)) // increase the supply

View File

@ -351,7 +351,7 @@ func TestGaiaCLICreateValidator(t *testing.T) {
// Ensure that validator state is as expected
validator := f.QueryStakingValidator(barVal)
require.Equal(t, validator.OperatorAddr, barVal)
require.Equal(t, validator.OperatorAddress, barVal)
require.True(sdk.IntEq(t, newValTokens, validator.Tokens))
// Query delegations to the validator

View File

@ -26,12 +26,12 @@ type IBCPacket struct {
}
// Implements sdk.Msg
type IBCTransferMsg struct {
type MsgIBCTransfer struct {
IBCPacket
}
// Implements sdk.Msg
type IBCReceiveMsg struct {
type MsgIBCReceive struct {
IBCPacket
Relayer sdk.Address
Sequence int64

View File

@ -29,12 +29,12 @@ type TransferPayload struct {
}
// Implements sdk.Msg
type IBCTransferMsg struct {
type MsgIBCTransfer struct {
Packet
}
// Implements sdk.Msg
type IBCReceiveMsg struct {
type MsgIBCReceive struct {
Packet
Relayer sdk.Address
Sequence int64

View File

@ -8,12 +8,12 @@
// Implements sdk.Msg
type IBCTransferMsg struct {
type MsgIBCTransfer struct {
Packet
}
// Implements sdk.Msg
type IBCReceiveMsg struct {
type MsgIBCReceive struct {
Packet
}
@ -42,12 +42,12 @@ type TransferPayload struct {
}
// Implements sdk.Msg
type IBCTransferMsg struct {
type MsgIBCTransfer struct {
Packet
}
// Implements sdk.Msg
type IBCReceiveMsg struct {
type MsgIBCReceive struct {
Packet
Proof iavl.Proof
FromChainID string

View File

@ -6,8 +6,8 @@ import (
// Register concrete types on codec codec
func RegisterCodec(cdc *codec.Codec) {
cdc.RegisterConcrete(MsgSend{}, "cosmos-sdk/Send", nil)
cdc.RegisterConcrete(MsgMultiSend{}, "cosmos-sdk/MultiSend", nil)
cdc.RegisterConcrete(MsgSend{}, "cosmos-sdk/MsgSend", nil)
cdc.RegisterConcrete(MsgMultiSend{}, "cosmos-sdk/MsgMultiSend", nil)
}
var msgCdc = codec.New()

View File

@ -58,7 +58,7 @@ func TestMsgSendGetSignBytes(t *testing.T) {
var msg = NewMsgSend(addr1, addr2, coins)
res := msg.GetSignBytes()
expected := `{"type":"cosmos-sdk/Send","value":{"amount":[{"amount":"10","denom":"atom"}],"from_address":"cosmos1d9h8qat57ljhcm","to_address":"cosmos1da6hgur4wsmpnjyg"}}`
expected := `{"type":"cosmos-sdk/MsgSend","value":{"amount":[{"amount":"10","denom":"atom"}],"from_address":"cosmos1d9h8qat57ljhcm","to_address":"cosmos1da6hgur4wsmpnjyg"}}`
require.Equal(t, expected, string(res))
}
@ -224,7 +224,7 @@ func TestMsgMultiSendGetSignBytes(t *testing.T) {
}
res := msg.GetSignBytes()
expected := `{"type":"cosmos-sdk/MultiSend","value":{"inputs":[{"address":"cosmos1d9h8qat57ljhcm","coins":[{"amount":"10","denom":"atom"}]}],"outputs":[{"address":"cosmos1da6hgur4wsmpnjyg","coins":[{"amount":"10","denom":"atom"}]}]}}`
expected := `{"type":"cosmos-sdk/MsgMultiSend","value":{"inputs":[{"address":"cosmos1d9h8qat57ljhcm","coins":[{"amount":"10","denom":"atom"}]}],"outputs":[{"address":"cosmos1da6hgur4wsmpnjyg","coins":[{"amount":"10","denom":"atom"}]}]}}`
require.Equal(t, expected, string(res))
}

View File

@ -118,7 +118,7 @@ func delegatorWithdrawalAddrHandlerFn(cliCtx context.CLIContext, cdc *codec.Code
// ValidatorDistInfo defines the properties of
// validator distribution information response.
type ValidatorDistInfo struct {
OperatorAddress sdk.AccAddress `json:"operator_addr"`
OperatorAddress sdk.AccAddress `json:"operator_address"`
SelfBondRewards sdk.DecCoins `json:"self_bond_rewards"`
ValidatorCommission types.ValidatorAccumulatedCommission `json:"val_commission"`
}

View File

@ -13,24 +13,24 @@ func InitGenesis(ctx sdk.Context, keeper Keeper, data types.GenesisState) {
keeper.SetBonusProposerReward(ctx, data.BonusProposerReward)
keeper.SetWithdrawAddrEnabled(ctx, data.WithdrawAddrEnabled)
for _, dwi := range data.DelegatorWithdrawInfos {
keeper.SetDelegatorWithdrawAddr(ctx, dwi.DelegatorAddr, dwi.WithdrawAddr)
keeper.SetDelegatorWithdrawAddr(ctx, dwi.DelegatorAddress, dwi.WithdrawAddress)
}
keeper.SetPreviousProposerConsAddr(ctx, data.PreviousProposer)
keeper.SetOutstandingRewards(ctx, data.OutstandingRewards)
for _, acc := range data.ValidatorAccumulatedCommissions {
keeper.SetValidatorAccumulatedCommission(ctx, acc.ValidatorAddr, acc.Accumulated)
keeper.SetValidatorAccumulatedCommission(ctx, acc.ValidatorAddress, acc.Accumulated)
}
for _, his := range data.ValidatorHistoricalRewards {
keeper.SetValidatorHistoricalRewards(ctx, his.ValidatorAddr, his.Period, his.Rewards)
keeper.SetValidatorHistoricalRewards(ctx, his.ValidatorAddress, his.Period, his.Rewards)
}
for _, cur := range data.ValidatorCurrentRewards {
keeper.SetValidatorCurrentRewards(ctx, cur.ValidatorAddr, cur.Rewards)
keeper.SetValidatorCurrentRewards(ctx, cur.ValidatorAddress, cur.Rewards)
}
for _, del := range data.DelegatorStartingInfos {
keeper.SetDelegatorStartingInfo(ctx, del.ValidatorAddr, del.DelegatorAddr, del.StartingInfo)
keeper.SetDelegatorStartingInfo(ctx, del.ValidatorAddress, del.DelegatorAddress, del.StartingInfo)
}
for _, evt := range data.ValidatorSlashEvents {
keeper.SetValidatorSlashEvent(ctx, evt.ValidatorAddr, evt.Height, evt.Event)
keeper.SetValidatorSlashEvent(ctx, evt.ValidatorAddress, evt.Height, evt.Event)
}
}
@ -44,8 +44,8 @@ func ExportGenesis(ctx sdk.Context, keeper Keeper) types.GenesisState {
dwi := make([]types.DelegatorWithdrawInfo, 0)
keeper.IterateDelegatorWithdrawAddrs(ctx, func(del sdk.AccAddress, addr sdk.AccAddress) (stop bool) {
dwi = append(dwi, types.DelegatorWithdrawInfo{
DelegatorAddr: del,
WithdrawAddr: addr,
DelegatorAddress: del,
WithdrawAddress: addr,
})
return false
})
@ -55,8 +55,8 @@ func ExportGenesis(ctx sdk.Context, keeper Keeper) types.GenesisState {
keeper.IterateValidatorAccumulatedCommissions(ctx,
func(addr sdk.ValAddress, commission types.ValidatorAccumulatedCommission) (stop bool) {
acc = append(acc, types.ValidatorAccumulatedCommissionRecord{
ValidatorAddr: addr,
Accumulated: commission,
ValidatorAddress: addr,
Accumulated: commission,
})
return false
},
@ -65,9 +65,9 @@ func ExportGenesis(ctx sdk.Context, keeper Keeper) types.GenesisState {
keeper.IterateValidatorHistoricalRewards(ctx,
func(val sdk.ValAddress, period uint64, rewards types.ValidatorHistoricalRewards) (stop bool) {
his = append(his, types.ValidatorHistoricalRewardsRecord{
ValidatorAddr: val,
Period: period,
Rewards: rewards,
ValidatorAddress: val,
Period: period,
Rewards: rewards,
})
return false
},
@ -76,8 +76,8 @@ func ExportGenesis(ctx sdk.Context, keeper Keeper) types.GenesisState {
keeper.IterateValidatorCurrentRewards(ctx,
func(val sdk.ValAddress, rewards types.ValidatorCurrentRewards) (stop bool) {
cur = append(cur, types.ValidatorCurrentRewardsRecord{
ValidatorAddr: val,
Rewards: rewards,
ValidatorAddress: val,
Rewards: rewards,
})
return false
},
@ -86,9 +86,9 @@ func ExportGenesis(ctx sdk.Context, keeper Keeper) types.GenesisState {
keeper.IterateDelegatorStartingInfos(ctx,
func(val sdk.ValAddress, del sdk.AccAddress, info types.DelegatorStartingInfo) (stop bool) {
dels = append(dels, types.DelegatorStartingInfoRecord{
ValidatorAddr: val,
DelegatorAddr: del,
StartingInfo: info,
ValidatorAddress: val,
DelegatorAddress: del,
StartingInfo: info,
})
return false
},
@ -97,9 +97,9 @@ func ExportGenesis(ctx sdk.Context, keeper Keeper) types.GenesisState {
keeper.IterateValidatorSlashEvents(ctx,
func(val sdk.ValAddress, height uint64, event types.ValidatorSlashEvent) (stop bool) {
slashes = append(slashes, types.ValidatorSlashEventRecord{
ValidatorAddr: val,
Height: height,
Event: event,
ValidatorAddress: val,
Height: height,
Event: event,
})
return false
},

View File

@ -27,13 +27,13 @@ func NewHandler(k keeper.Keeper) sdk.Handler {
func handleMsgModifyWithdrawAddress(ctx sdk.Context, msg types.MsgSetWithdrawAddress, k keeper.Keeper) sdk.Result {
err := k.SetWithdrawAddr(ctx, msg.DelegatorAddr, msg.WithdrawAddr)
err := k.SetWithdrawAddr(ctx, msg.DelegatorAddress, msg.WithdrawAddress)
if err != nil {
return err.Result()
}
tags := sdk.NewTags(
tags.Delegator, []byte(msg.DelegatorAddr.String()),
tags.Delegator, []byte(msg.DelegatorAddress.String()),
)
return sdk.Result{
Tags: tags,
@ -42,14 +42,14 @@ func handleMsgModifyWithdrawAddress(ctx sdk.Context, msg types.MsgSetWithdrawAdd
func handleMsgWithdrawDelegatorReward(ctx sdk.Context, msg types.MsgWithdrawDelegatorReward, k keeper.Keeper) sdk.Result {
err := k.WithdrawDelegationRewards(ctx, msg.DelegatorAddr, msg.ValidatorAddr)
err := k.WithdrawDelegationRewards(ctx, msg.DelegatorAddress, msg.ValidatorAddress)
if err != nil {
return err.Result()
}
tags := sdk.NewTags(
tags.Delegator, []byte(msg.DelegatorAddr.String()),
tags.Validator, []byte(msg.ValidatorAddr.String()),
tags.Delegator, []byte(msg.DelegatorAddress.String()),
tags.Validator, []byte(msg.ValidatorAddress.String()),
)
return sdk.Result{
Tags: tags,
@ -58,13 +58,13 @@ func handleMsgWithdrawDelegatorReward(ctx sdk.Context, msg types.MsgWithdrawDele
func handleMsgWithdrawValidatorCommission(ctx sdk.Context, msg types.MsgWithdrawValidatorCommission, k keeper.Keeper) sdk.Result {
err := k.WithdrawValidatorCommission(ctx, msg.ValidatorAddr)
err := k.WithdrawValidatorCommission(ctx, msg.ValidatorAddress)
if err != nil {
return err.Result()
}
tags := sdk.NewTags(
tags.Validator, []byte(msg.ValidatorAddr.String()),
tags.Validator, []byte(msg.ValidatorAddress.String()),
)
return sdk.Result{
Tags: tags,

View File

@ -101,13 +101,13 @@ func queryOutstandingRewards(ctx sdk.Context, path []string, req abci.RequestQue
// params for query 'custom/distr/validator_commission'
type QueryValidatorCommissionParams struct {
ValidatorAddr sdk.ValAddress `json:"validator_addr"`
ValidatorAddress sdk.ValAddress `json:"validator_address"`
}
// creates a new instance of QueryValidatorCommissionParams
func NewQueryValidatorCommissionParams(validatorAddr sdk.ValAddress) QueryValidatorCommissionParams {
return QueryValidatorCommissionParams{
ValidatorAddr: validatorAddr,
ValidatorAddress: validatorAddr,
}
}
@ -117,7 +117,7 @@ func queryValidatorCommission(ctx sdk.Context, path []string, req abci.RequestQu
if err != nil {
return nil, sdk.ErrUnknownRequest(sdk.AppendMsgToErr("incorrectly formatted request data", err.Error()))
}
commission := k.GetValidatorAccumulatedCommission(ctx, params.ValidatorAddr)
commission := k.GetValidatorAccumulatedCommission(ctx, params.ValidatorAddress)
bz, err := codec.MarshalJSONIndent(k.cdc, commission)
if err != nil {
return nil, sdk.ErrInternal(sdk.AppendMsgToErr("could not marshal result to JSON", err.Error()))
@ -127,17 +127,17 @@ func queryValidatorCommission(ctx sdk.Context, path []string, req abci.RequestQu
// params for query 'custom/distr/validator_slashes'
type QueryValidatorSlashesParams struct {
ValidatorAddr sdk.ValAddress `json:"validator_addr"`
StartingHeight uint64 `json:"starting_height"`
EndingHeight uint64 `json:"ending_height"`
ValidatorAddress sdk.ValAddress `json:"validator_address"`
StartingHeight uint64 `json:"starting_height"`
EndingHeight uint64 `json:"ending_height"`
}
// creates a new instance of QueryValidatorSlashesParams
func NewQueryValidatorSlashesParams(validatorAddr sdk.ValAddress, startingHeight uint64, endingHeight uint64) QueryValidatorSlashesParams {
return QueryValidatorSlashesParams{
ValidatorAddr: validatorAddr,
StartingHeight: startingHeight,
EndingHeight: endingHeight,
ValidatorAddress: validatorAddr,
StartingHeight: startingHeight,
EndingHeight: endingHeight,
}
}
@ -148,7 +148,7 @@ func queryValidatorSlashes(ctx sdk.Context, path []string, req abci.RequestQuery
return nil, sdk.ErrUnknownRequest(sdk.AppendMsgToErr("incorrectly formatted request data", err.Error()))
}
events := make([]types.ValidatorSlashEvent, 0)
k.IterateValidatorSlashEventsBetween(ctx, params.ValidatorAddr, params.StartingHeight, params.EndingHeight,
k.IterateValidatorSlashEventsBetween(ctx, params.ValidatorAddress, params.StartingHeight, params.EndingHeight,
func(height uint64, event types.ValidatorSlashEvent) (stop bool) {
events = append(events, event)
return false
@ -163,15 +163,15 @@ func queryValidatorSlashes(ctx sdk.Context, path []string, req abci.RequestQuery
// params for query 'custom/distr/delegation_rewards'
type QueryDelegationRewardsParams struct {
DelegatorAddr sdk.AccAddress `json:"delegator_addr"`
ValidatorAddr sdk.ValAddress `json:"validator_addr"`
DelegatorAddress sdk.AccAddress `json:"delegator_address"`
ValidatorAddress sdk.ValAddress `json:"validator_address"`
}
// creates a new instance of QueryDelegationRewardsParams
func NewQueryDelegationRewardsParams(delegatorAddr sdk.AccAddress, validatorAddr sdk.ValAddress) QueryDelegationRewardsParams {
return QueryDelegationRewardsParams{
DelegatorAddr: delegatorAddr,
ValidatorAddr: validatorAddr,
DelegatorAddress: delegatorAddr,
ValidatorAddress: validatorAddr,
}
}
@ -185,8 +185,8 @@ func queryDelegationRewards(ctx sdk.Context, _ []string, req abci.RequestQuery,
// cache-wrap context as to not persist state changes during querying
ctx, _ = ctx.CacheContext()
val := k.stakingKeeper.Validator(ctx, params.ValidatorAddr)
del := k.stakingKeeper.Delegation(ctx, params.DelegatorAddr, params.ValidatorAddr)
val := k.stakingKeeper.Validator(ctx, params.ValidatorAddress)
del := k.stakingKeeper.Delegation(ctx, params.DelegatorAddress, params.ValidatorAddress)
endingPeriod := k.incrementValidatorPeriod(ctx, val)
rewards := k.calculateDelegationRewards(ctx, val, del, endingPeriod)
@ -200,13 +200,13 @@ func queryDelegationRewards(ctx sdk.Context, _ []string, req abci.RequestQuery,
// params for query 'custom/distr/delegator_total_rewards' and 'custom/distr/delegator_validators'
type QueryDelegatorParams struct {
DelegatorAddr sdk.AccAddress `json:"delegator_addr"`
DelegatorAddress sdk.AccAddress `json:"delegator_address"`
}
// creates a new instance of QueryDelegationRewardsParams
func NewQueryDelegatorParams(delegatorAddr sdk.AccAddress) QueryDelegatorParams {
return QueryDelegatorParams{
DelegatorAddr: delegatorAddr,
DelegatorAddress: delegatorAddr,
}
}
@ -223,7 +223,7 @@ func queryDelegatorTotalRewards(ctx sdk.Context, _ []string, req abci.RequestQue
var totalRewards sdk.DecCoins
k.stakingKeeper.IterateDelegations(
ctx, params.DelegatorAddr,
ctx, params.DelegatorAddress,
func(_ int64, del sdk.Delegation) (stop bool) {
val := k.stakingKeeper.Validator(ctx, del.GetValidatorAddr())
endingPeriod := k.incrementValidatorPeriod(ctx, val)
@ -255,7 +255,7 @@ func queryDelegatorValidators(ctx sdk.Context, _ []string, req abci.RequestQuery
var validators []sdk.ValAddress
k.stakingKeeper.IterateDelegations(
ctx, params.DelegatorAddr,
ctx, params.DelegatorAddress,
func(_ int64, del sdk.Delegation) (stop bool) {
validators = append(validators[:], del.GetValidatorAddr())
return false
@ -271,12 +271,12 @@ func queryDelegatorValidators(ctx sdk.Context, _ []string, req abci.RequestQuery
// params for query 'custom/distr/withdraw_addr'
type QueryDelegatorWithdrawAddrParams struct {
DelegatorAddr sdk.AccAddress `json:"delegator_addr"`
DelegatorAddress sdk.AccAddress `json:"delegator_address"`
}
// NewQueryDelegatorWithdrawAddrParams creates a new instance of QueryDelegatorWithdrawAddrParams.
func NewQueryDelegatorWithdrawAddrParams(delegatorAddr sdk.AccAddress) QueryDelegatorWithdrawAddrParams {
return QueryDelegatorWithdrawAddrParams{DelegatorAddr: delegatorAddr}
return QueryDelegatorWithdrawAddrParams{DelegatorAddress: delegatorAddr}
}
func queryDelegatorWithdrawAddress(ctx sdk.Context, _ []string, req abci.RequestQuery, k Keeper) ([]byte, sdk.Error) {
@ -288,7 +288,7 @@ func queryDelegatorWithdrawAddress(ctx sdk.Context, _ []string, req abci.Request
// cache-wrap context as to not persist state changes during querying
ctx, _ = ctx.CacheContext()
withdrawAddr := k.GetDelegatorWithdrawAddr(ctx, params.DelegatorAddr)
withdrawAddr := k.GetDelegatorWithdrawAddr(ctx, params.DelegatorAddress)
bz, err := codec.MarshalJSONIndent(k.cdc, withdrawAddr)
if err != nil {

View File

@ -9,41 +9,41 @@ import (
// the address for where distributions rewards are withdrawn to by default
// this struct is only used at genesis to feed in default withdraw addresses
type DelegatorWithdrawInfo struct {
DelegatorAddr sdk.AccAddress `json:"delegator_addr"`
WithdrawAddr sdk.AccAddress `json:"withdraw_addr"`
DelegatorAddress sdk.AccAddress `json:"delegator_address"`
WithdrawAddress sdk.AccAddress `json:"withdraw_address"`
}
// used for import / export via genesis json
type ValidatorAccumulatedCommissionRecord struct {
ValidatorAddr sdk.ValAddress `json:"validator_addr"`
Accumulated ValidatorAccumulatedCommission `json:"accumulated"`
ValidatorAddress sdk.ValAddress `json:"validator_address"`
Accumulated ValidatorAccumulatedCommission `json:"accumulated"`
}
// used for import / export via genesis json
type ValidatorHistoricalRewardsRecord struct {
ValidatorAddr sdk.ValAddress `json:"validator_addr"`
Period uint64 `json:"period"`
Rewards ValidatorHistoricalRewards `json:"rewards"`
ValidatorAddress sdk.ValAddress `json:"validator_address"`
Period uint64 `json:"period"`
Rewards ValidatorHistoricalRewards `json:"rewards"`
}
// used for import / export via genesis json
type ValidatorCurrentRewardsRecord struct {
ValidatorAddr sdk.ValAddress `json:"validator_addr"`
Rewards ValidatorCurrentRewards `json:"rewards"`
ValidatorAddress sdk.ValAddress `json:"validator_address"`
Rewards ValidatorCurrentRewards `json:"rewards"`
}
// used for import / export via genesis json
type DelegatorStartingInfoRecord struct {
DelegatorAddr sdk.AccAddress `json:"delegator_addr"`
ValidatorAddr sdk.ValAddress `json:"validator_addr"`
StartingInfo DelegatorStartingInfo `json:"starting_info"`
DelegatorAddress sdk.AccAddress `json:"delegator_address"`
ValidatorAddress sdk.ValAddress `json:"validator_address"`
StartingInfo DelegatorStartingInfo `json:"starting_info"`
}
// used for import / export via genesis json
type ValidatorSlashEventRecord struct {
ValidatorAddr sdk.ValAddress `json:"validator_addr"`
Height uint64 `json:"height"`
Event ValidatorSlashEvent `json:"validator_slash_event"`
ValidatorAddress sdk.ValAddress `json:"validator_address"`
Height uint64 `json:"height"`
Event ValidatorSlashEvent `json:"validator_slash_event"`
}
// GenesisState - all distribution state that must be provided at genesis

View File

@ -13,14 +13,14 @@ var _, _, _ sdk.Msg = &MsgSetWithdrawAddress{}, &MsgWithdrawDelegatorReward{}, &
// msg struct for changing the withdraw address for a delegator (or validator self-delegation)
type MsgSetWithdrawAddress struct {
DelegatorAddr sdk.AccAddress `json:"delegator_addr"`
WithdrawAddr sdk.AccAddress `json:"withdraw_addr"`
DelegatorAddress sdk.AccAddress `json:"delegator_address"`
WithdrawAddress sdk.AccAddress `json:"withdraw_address"`
}
func NewMsgSetWithdrawAddress(delAddr, withdrawAddr sdk.AccAddress) MsgSetWithdrawAddress {
return MsgSetWithdrawAddress{
DelegatorAddr: delAddr,
WithdrawAddr: withdrawAddr,
DelegatorAddress: delAddr,
WithdrawAddress: withdrawAddr,
}
}
@ -29,7 +29,7 @@ func (msg MsgSetWithdrawAddress) Type() string { return "set_withdraw_address"
// Return address that must sign over msg.GetSignBytes()
func (msg MsgSetWithdrawAddress) GetSigners() []sdk.AccAddress {
return []sdk.AccAddress{sdk.AccAddress(msg.DelegatorAddr)}
return []sdk.AccAddress{sdk.AccAddress(msg.DelegatorAddress)}
}
// get the bytes for the message signer to sign on
@ -40,10 +40,10 @@ func (msg MsgSetWithdrawAddress) GetSignBytes() []byte {
// quick validity check
func (msg MsgSetWithdrawAddress) ValidateBasic() sdk.Error {
if msg.DelegatorAddr.Empty() {
if msg.DelegatorAddress.Empty() {
return ErrNilDelegatorAddr(DefaultCodespace)
}
if msg.WithdrawAddr.Empty() {
if msg.WithdrawAddress.Empty() {
return ErrNilWithdrawAddr(DefaultCodespace)
}
return nil
@ -51,14 +51,14 @@ func (msg MsgSetWithdrawAddress) ValidateBasic() sdk.Error {
// msg struct for delegation withdraw from a single validator
type MsgWithdrawDelegatorReward struct {
DelegatorAddr sdk.AccAddress `json:"delegator_addr"`
ValidatorAddr sdk.ValAddress `json:"validator_addr"`
DelegatorAddress sdk.AccAddress `json:"delegator_address"`
ValidatorAddress sdk.ValAddress `json:"validator_address"`
}
func NewMsgWithdrawDelegatorReward(delAddr sdk.AccAddress, valAddr sdk.ValAddress) MsgWithdrawDelegatorReward {
return MsgWithdrawDelegatorReward{
DelegatorAddr: delAddr,
ValidatorAddr: valAddr,
DelegatorAddress: delAddr,
ValidatorAddress: valAddr,
}
}
@ -67,7 +67,7 @@ func (msg MsgWithdrawDelegatorReward) Type() string { return "withdraw_delegati
// Return address that must sign over msg.GetSignBytes()
func (msg MsgWithdrawDelegatorReward) GetSigners() []sdk.AccAddress {
return []sdk.AccAddress{sdk.AccAddress(msg.DelegatorAddr)}
return []sdk.AccAddress{sdk.AccAddress(msg.DelegatorAddress)}
}
// get the bytes for the message signer to sign on
@ -78,10 +78,10 @@ func (msg MsgWithdrawDelegatorReward) GetSignBytes() []byte {
// quick validity check
func (msg MsgWithdrawDelegatorReward) ValidateBasic() sdk.Error {
if msg.DelegatorAddr.Empty() {
if msg.DelegatorAddress.Empty() {
return ErrNilDelegatorAddr(DefaultCodespace)
}
if msg.ValidatorAddr.Empty() {
if msg.ValidatorAddress.Empty() {
return ErrNilValidatorAddr(DefaultCodespace)
}
return nil
@ -89,12 +89,12 @@ func (msg MsgWithdrawDelegatorReward) ValidateBasic() sdk.Error {
// msg struct for validator withdraw
type MsgWithdrawValidatorCommission struct {
ValidatorAddr sdk.ValAddress `json:"validator_addr"`
ValidatorAddress sdk.ValAddress `json:"validator_address"`
}
func NewMsgWithdrawValidatorCommission(valAddr sdk.ValAddress) MsgWithdrawValidatorCommission {
return MsgWithdrawValidatorCommission{
ValidatorAddr: valAddr,
ValidatorAddress: valAddr,
}
}
@ -103,7 +103,7 @@ func (msg MsgWithdrawValidatorCommission) Type() string { return "withdraw_vali
// Return address that must sign over msg.GetSignBytes()
func (msg MsgWithdrawValidatorCommission) GetSigners() []sdk.AccAddress {
return []sdk.AccAddress{sdk.AccAddress(msg.ValidatorAddr.Bytes())}
return []sdk.AccAddress{sdk.AccAddress(msg.ValidatorAddress.Bytes())}
}
// get the bytes for the message signer to sign on
@ -114,7 +114,7 @@ func (msg MsgWithdrawValidatorCommission) GetSignBytes() []byte {
// quick validity check
func (msg MsgWithdrawValidatorCommission) ValidateBasic() sdk.Error {
if msg.ValidatorAddr.Empty() {
if msg.ValidatorAddress.Empty() {
return ErrNilValidatorAddr(DefaultCodespace)
}
return nil

View File

@ -62,11 +62,11 @@ func TestIBCMsgs(t *testing.T) {
DestChain: destChain,
}
transferMsg := IBCTransferMsg{
transferMsg := MsgIBCTransfer{
IBCPacket: packet,
}
receiveMsg := IBCReceiveMsg{
receiveMsg := MsgIBCReceive{
IBCPacket: packet,
Relayer: addr1,
Sequence: 0,

View File

@ -65,7 +65,7 @@ func buildMsg(from sdk.AccAddress) (sdk.Msg, error) {
packet := ibc.NewIBCPacket(from, to, coins, viper.GetString(client.FlagChainID),
viper.GetString(flagChain))
msg := ibc.IBCTransferMsg{
msg := ibc.MsgIBCTransfer{
IBCPacket: packet,
}

View File

@ -191,7 +191,7 @@ func (c relayCommander) refine(bz []byte, ibcSeq, accSeq uint64, passphrase stri
panic(err)
}
msg := ibc.IBCReceiveMsg{
msg := ibc.MsgIBCReceive{
IBCPacket: packet,
Relayer: c.address,
Sequence: ibcSeq,

View File

@ -55,7 +55,7 @@ func TransferRequestHandlerFn(cdc *codec.Codec, kb keys.Keybase, cliCtx context.
}
packet := ibc.NewIBCPacket(from, to, req.Amount, req.BaseReq.ChainID, destChainID)
msg := ibc.IBCTransferMsg{IBCPacket: packet}
msg := ibc.MsgIBCTransfer{IBCPacket: packet}
clientrest.WriteGenerateStdTxResponse(w, cdc, cliCtx, req.BaseReq, []sdk.Msg{msg})
}

View File

@ -6,6 +6,6 @@ import (
// Register concrete types on codec codec
func RegisterCodec(cdc *codec.Codec) {
cdc.RegisterConcrete(IBCTransferMsg{}, "cosmos-sdk/IBCTransferMsg", nil)
cdc.RegisterConcrete(IBCReceiveMsg{}, "cosmos-sdk/IBCReceiveMsg", nil)
cdc.RegisterConcrete(MsgIBCTransfer{}, "cosmos-sdk/MsgIBCTransfer", nil)
cdc.RegisterConcrete(MsgIBCReceive{}, "cosmos-sdk/MsgIBCReceive", nil)
}

View File

@ -7,9 +7,9 @@ import (
func NewHandler(ibcm Mapper, ck BankKeeper) sdk.Handler {
return func(ctx sdk.Context, msg sdk.Msg) sdk.Result {
switch msg := msg.(type) {
case IBCTransferMsg:
case MsgIBCTransfer:
return handleIBCTransferMsg(ctx, ibcm, ck, msg)
case IBCReceiveMsg:
case MsgIBCReceive:
return handleIBCReceiveMsg(ctx, ibcm, ck, msg)
default:
errMsg := "Unrecognized IBC Msg type: " + msg.Type()
@ -18,8 +18,8 @@ func NewHandler(ibcm Mapper, ck BankKeeper) sdk.Handler {
}
}
// IBCTransferMsg deducts coins from the account and creates an egress IBC packet.
func handleIBCTransferMsg(ctx sdk.Context, ibcm Mapper, ck BankKeeper, msg IBCTransferMsg) sdk.Result {
// MsgIBCTransfer deducts coins from the account and creates an egress IBC packet.
func handleIBCTransferMsg(ctx sdk.Context, ibcm Mapper, ck BankKeeper, msg MsgIBCTransfer) sdk.Result {
packet := msg.IBCPacket
_, _, err := ck.SubtractCoins(ctx, packet.SrcAddr, packet.Coins)
@ -35,8 +35,8 @@ func handleIBCTransferMsg(ctx sdk.Context, ibcm Mapper, ck BankKeeper, msg IBCTr
return sdk.Result{}
}
// IBCReceiveMsg adds coins to the destination address and creates an ingress IBC packet.
func handleIBCReceiveMsg(ctx sdk.Context, ibcm Mapper, ck BankKeeper, msg IBCReceiveMsg) sdk.Result {
// MsgIBCReceive adds coins to the destination address and creates an ingress IBC packet.
func handleIBCReceiveMsg(ctx sdk.Context, ibcm Mapper, ck BankKeeper, msg MsgIBCReceive) sdk.Result {
packet := msg.IBCPacket
seq := ibcm.GetIngressSequence(ctx, packet.SrcChain)

View File

@ -64,8 +64,8 @@ func makeCodec() *codec.Codec {
// Register Msgs
cdc.RegisterInterface((*sdk.Msg)(nil), nil)
cdc.RegisterConcrete(bank.MsgSend{}, "test/ibc/Send", nil)
cdc.RegisterConcrete(IBCTransferMsg{}, "test/ibc/IBCTransferMsg", nil)
cdc.RegisterConcrete(IBCReceiveMsg{}, "test/ibc/IBCReceiveMsg", nil)
cdc.RegisterConcrete(MsgIBCTransfer{}, "test/ibc/MsgIBCTransfer", nil)
cdc.RegisterConcrete(MsgIBCReceive{}, "test/ibc/MsgIBCReceive", nil)
// Register AppAccount
cdc.RegisterInterface((*auth.Account)(nil), nil)
@ -121,7 +121,7 @@ func TestIBC(t *testing.T) {
egl = ibcm.getEgressLength(store, chainid)
require.Equal(t, egl, uint64(0))
msg = IBCTransferMsg{
msg = MsgIBCTransfer{
IBCPacket: packet,
}
res = h(ctx, msg)
@ -137,7 +137,7 @@ func TestIBC(t *testing.T) {
igs = ibcm.GetIngressSequence(ctx, chainid)
require.Equal(t, igs, uint64(0))
msg = IBCReceiveMsg{
msg = MsgIBCReceive{
IBCPacket: packet,
Relayer: src,
Sequence: 0,

View File

@ -62,53 +62,53 @@ func (p IBCPacket) ValidateBasic() sdk.Error {
}
// ----------------------------------
// IBCTransferMsg
// MsgIBCTransfer
// nolint - TODO rename to TransferMsg as folks will reference with ibc.TransferMsg
// IBCTransferMsg defines how another module can send an IBCPacket.
type IBCTransferMsg struct {
// MsgIBCTransfer defines how another module can send an IBCPacket.
type MsgIBCTransfer struct {
IBCPacket
}
// nolint
func (msg IBCTransferMsg) Route() string { return "ibc" }
func (msg IBCTransferMsg) Type() string { return "transfer" }
func (msg MsgIBCTransfer) Route() string { return "ibc" }
func (msg MsgIBCTransfer) Type() string { return "transfer" }
// x/bank/tx.go MsgSend.GetSigners()
func (msg IBCTransferMsg) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{msg.SrcAddr} }
func (msg MsgIBCTransfer) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{msg.SrcAddr} }
// get the sign bytes for ibc transfer message
func (msg IBCTransferMsg) GetSignBytes() []byte {
func (msg MsgIBCTransfer) GetSignBytes() []byte {
return msg.IBCPacket.GetSignBytes()
}
// validate ibc transfer message
func (msg IBCTransferMsg) ValidateBasic() sdk.Error {
func (msg MsgIBCTransfer) ValidateBasic() sdk.Error {
return msg.IBCPacket.ValidateBasic()
}
// ----------------------------------
// IBCReceiveMsg
// MsgIBCReceive
// nolint - TODO rename to ReceiveMsg as folks will reference with ibc.ReceiveMsg
// IBCReceiveMsg defines the message that a relayer uses to post an IBCPacket
// MsgIBCReceive defines the message that a relayer uses to post an IBCPacket
// to the destination chain.
type IBCReceiveMsg struct {
type MsgIBCReceive struct {
IBCPacket
Relayer sdk.AccAddress
Sequence uint64
}
// nolint
func (msg IBCReceiveMsg) Route() string { return "ibc" }
func (msg IBCReceiveMsg) Type() string { return "receive" }
func (msg IBCReceiveMsg) ValidateBasic() sdk.Error { return msg.IBCPacket.ValidateBasic() }
func (msg MsgIBCReceive) Route() string { return "ibc" }
func (msg MsgIBCReceive) Type() string { return "receive" }
func (msg MsgIBCReceive) ValidateBasic() sdk.Error { return msg.IBCPacket.ValidateBasic() }
// x/bank/tx.go MsgSend.GetSigners()
func (msg IBCReceiveMsg) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{msg.Relayer} }
func (msg MsgIBCReceive) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{msg.Relayer} }
// get the sign bytes for ibc receive message
func (msg IBCReceiveMsg) GetSignBytes() []byte {
func (msg MsgIBCReceive) GetSignBytes() []byte {
b, err := msgCdc.MarshalJSON(struct {
IBCPacket json.RawMessage
Relayer sdk.AccAddress

View File

@ -31,11 +31,11 @@ func TestIBCPacketValidation(t *testing.T) {
}
// -------------------------------
// IBCTransferMsg Tests
// MsgIBCTransfer Tests
func TestIBCTransferMsg(t *testing.T) {
packet := constructIBCPacket(true)
msg := IBCTransferMsg{packet}
msg := MsgIBCTransfer{packet}
require.Equal(t, msg.Route(), "ibc")
}
@ -46,10 +46,10 @@ func TestIBCTransferMsgValidation(t *testing.T) {
cases := []struct {
valid bool
msg IBCTransferMsg
msg MsgIBCTransfer
}{
{true, IBCTransferMsg{validPacket}},
{false, IBCTransferMsg{invalidPacket}},
{true, MsgIBCTransfer{validPacket}},
{false, MsgIBCTransfer{invalidPacket}},
}
for i, tc := range cases {
@ -63,11 +63,11 @@ func TestIBCTransferMsgValidation(t *testing.T) {
}
// -------------------------------
// IBCReceiveMsg Tests
// MsgIBCReceive Tests
func TestIBCReceiveMsg(t *testing.T) {
packet := constructIBCPacket(true)
msg := IBCReceiveMsg{packet, sdk.AccAddress([]byte("relayer")), 0}
msg := MsgIBCReceive{packet, sdk.AccAddress([]byte("relayer")), 0}
require.Equal(t, msg.Route(), "ibc")
}
@ -78,10 +78,10 @@ func TestIBCReceiveMsgValidation(t *testing.T) {
cases := []struct {
valid bool
msg IBCReceiveMsg
msg MsgIBCReceive
}{
{true, IBCReceiveMsg{validPacket, sdk.AccAddress([]byte("relayer")), 0}},
{false, IBCReceiveMsg{invalidPacket, sdk.AccAddress([]byte("relayer")), 0}},
{true, MsgIBCReceive{validPacket, sdk.AccAddress([]byte("relayer")), 0}},
{false, MsgIBCReceive{invalidPacket, sdk.AccAddress([]byte("relayer")), 0}},
}
for i, tc := range cases {

View File

@ -116,7 +116,7 @@ func TestSlashingMsgs(t *testing.T) {
mapp.BeginBlock(abci.RequestBeginBlock{})
validator := checkValidator(t, mapp, stakingKeeper, addr1, true)
require.Equal(t, sdk.ValAddress(addr1), validator.OperatorAddr)
require.Equal(t, sdk.ValAddress(addr1), validator.OperatorAddress)
require.Equal(t, sdk.Bonded, validator.Status)
require.True(sdk.IntEq(t, bondTokens, validator.BondedTokens()))
unjailMsg := MsgUnjail{ValidatorAddr: sdk.ValAddress(validator.ConsPubKey.Address())}

View File

@ -127,7 +127,7 @@ func TestStakingMsgs(t *testing.T) {
mApp.BeginBlock(abci.RequestBeginBlock{})
validator := checkValidator(t, mApp, keeper, sdk.ValAddress(addr1), true)
require.Equal(t, sdk.ValAddress(addr1), validator.OperatorAddr)
require.Equal(t, sdk.ValAddress(addr1), validator.OperatorAddress)
require.Equal(t, sdk.Bonded, validator.Status)
require.True(sdk.IntEq(t, bondTokens, validator.BondedTokens()))
@ -141,7 +141,7 @@ func TestStakingMsgs(t *testing.T) {
mApp.BeginBlock(abci.RequestBeginBlock{})
validator = checkValidator(t, mApp, keeper, sdk.ValAddress(addr2), true)
require.Equal(t, sdk.ValAddress(addr2), validator.OperatorAddr)
require.Equal(t, sdk.ValAddress(addr2), validator.OperatorAddress)
require.Equal(t, sdk.Bonded, validator.Status)
require.True(sdk.IntEq(t, bondTokens, validator.Tokens))

View File

@ -33,27 +33,27 @@ func registerTxRoutes(cliCtx context.CLIContext, r *mux.Router, cdc *codec.Codec
type (
// MsgBeginRedelegateInput defines the properties of a delegation request's body.
MsgDelegationsInput struct {
BaseReq rest.BaseReq `json:"base_req"`
DelegatorAddr sdk.AccAddress `json:"delegator_addr"` // in bech32
ValidatorAddr sdk.ValAddress `json:"validator_addr"` // in bech32
Delegation sdk.Coin `json:"delegation"`
BaseReq rest.BaseReq `json:"base_req"`
DelegatorAddress sdk.AccAddress `json:"delegator_address"` // in bech32
ValidatorAddress sdk.ValAddress `json:"validator_address"` // in bech32
Delegation sdk.Coin `json:"delegation"`
}
// MsgBeginRedelegateInput defines the properties of a redelegate request's body.
MsgBeginRedelegateInput struct {
BaseReq rest.BaseReq `json:"base_req"`
DelegatorAddr sdk.AccAddress `json:"delegator_addr"` // in bech32
ValidatorSrcAddr sdk.ValAddress `json:"validator_src_addr"` // in bech32
ValidatorDstAddr sdk.ValAddress `json:"validator_dst_addr"` // in bech32
SharesAmount sdk.Dec `json:"shares"`
BaseReq rest.BaseReq `json:"base_req"`
DelegatorAddress sdk.AccAddress `json:"delegator_address"` // in bech32
ValidatorSrcAddress sdk.ValAddress `json:"validator_src_address"` // in bech32
ValidatorDstAddress sdk.ValAddress `json:"validator_dst_address"` // in bech32
SharesAmount sdk.Dec `json:"shares"`
}
// MsgUndelegateInput defines the properties of a undelegate request's body.
MsgUndelegateInput struct {
BaseReq rest.BaseReq `json:"base_req"`
DelegatorAddr sdk.AccAddress `json:"delegator_addr"` // in bech32
ValidatorAddr sdk.ValAddress `json:"validator_addr"` // in bech32
SharesAmount sdk.Dec `json:"shares"`
BaseReq rest.BaseReq `json:"base_req"`
DelegatorAddress sdk.AccAddress `json:"delegator_address"` // in bech32
ValidatorAddress sdk.ValAddress `json:"validator_address"` // in bech32
SharesAmount sdk.Dec `json:"shares"`
}
)
@ -70,7 +70,7 @@ func postDelegationsHandlerFn(cdc *codec.Codec, kb keys.Keybase, cliCtx context.
return
}
msg := staking.NewMsgDelegate(req.DelegatorAddr, req.ValidatorAddr, req.Delegation)
msg := staking.NewMsgDelegate(req.DelegatorAddress, req.ValidatorAddress, req.Delegation)
if err := msg.ValidateBasic(); err != nil {
rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error())
return
@ -82,7 +82,7 @@ func postDelegationsHandlerFn(cdc *codec.Codec, kb keys.Keybase, cliCtx context.
return
}
if !bytes.Equal(fromAddr, req.DelegatorAddr) {
if !bytes.Equal(fromAddr, req.DelegatorAddress) {
rest.WriteErrorResponse(w, http.StatusUnauthorized, "must use own delegator address")
return
}
@ -104,7 +104,7 @@ func postRedelegationsHandlerFn(cdc *codec.Codec, kb keys.Keybase, cliCtx contex
return
}
msg := staking.NewMsgBeginRedelegate(req.DelegatorAddr, req.ValidatorSrcAddr, req.ValidatorDstAddr, req.SharesAmount)
msg := staking.NewMsgBeginRedelegate(req.DelegatorAddress, req.ValidatorSrcAddress, req.ValidatorDstAddress, req.SharesAmount)
if err := msg.ValidateBasic(); err != nil {
rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error())
return
@ -116,7 +116,7 @@ func postRedelegationsHandlerFn(cdc *codec.Codec, kb keys.Keybase, cliCtx contex
return
}
if !bytes.Equal(fromAddr, req.DelegatorAddr) {
if !bytes.Equal(fromAddr, req.DelegatorAddress) {
rest.WriteErrorResponse(w, http.StatusUnauthorized, "must use own delegator address")
return
}
@ -138,7 +138,7 @@ func postUnbondingDelegationsHandlerFn(cdc *codec.Codec, kb keys.Keybase, cliCtx
return
}
msg := staking.NewMsgUndelegate(req.DelegatorAddr, req.ValidatorAddr, req.SharesAmount)
msg := staking.NewMsgUndelegate(req.DelegatorAddress, req.ValidatorAddress, req.SharesAmount)
if err := msg.ValidateBasic(); err != nil {
rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error())
return
@ -150,7 +150,7 @@ func postUnbondingDelegationsHandlerFn(cdc *codec.Codec, kb keys.Keybase, cliCtx
return
}
if !bytes.Equal(fromAddr, req.DelegatorAddr) {
if !bytes.Equal(fromAddr, req.DelegatorAddress) {
rest.WriteErrorResponse(w, http.StatusUnauthorized, "must use own delegator address")
return
}

View File

@ -37,7 +37,7 @@ func InitGenesis(ctx sdk.Context, keeper Keeper, data types.GenesisState) (res [
// Call the creation hook if not exported
if !data.Exported {
keeper.AfterValidatorCreated(ctx, validator.OperatorAddr)
keeper.AfterValidatorCreated(ctx, validator.OperatorAddress)
}
// Set timeslice if necessary
@ -49,12 +49,12 @@ func InitGenesis(ctx sdk.Context, keeper Keeper, data types.GenesisState) (res [
for _, delegation := range data.Delegations {
// Call the before-creation hook if not exported
if !data.Exported {
keeper.BeforeDelegationCreated(ctx, delegation.DelegatorAddr, delegation.ValidatorAddr)
keeper.BeforeDelegationCreated(ctx, delegation.DelegatorAddress, delegation.ValidatorAddress)
}
keeper.SetDelegation(ctx, delegation)
// Call the after-modification hook if not exported
if !data.Exported {
keeper.AfterDelegationModified(ctx, delegation.DelegatorAddr, delegation.ValidatorAddr)
keeper.AfterDelegationModified(ctx, delegation.DelegatorAddress, delegation.ValidatorAddress)
}
}

View File

@ -28,13 +28,13 @@ func TestInitGenesis(t *testing.T) {
var delegations []Delegation
// initialize the validators
validators[0].OperatorAddr = sdk.ValAddress(keep.Addrs[0])
validators[0].OperatorAddress = sdk.ValAddress(keep.Addrs[0])
validators[0].ConsPubKey = keep.PKs[0]
validators[0].Description = NewDescription("hoop", "", "", "")
validators[0].Status = sdk.Bonded
validators[0].Tokens = valTokens
validators[0].DelegatorShares = valTokens.ToDec()
validators[1].OperatorAddr = sdk.ValAddress(keep.Addrs[1])
validators[1].OperatorAddress = sdk.ValAddress(keep.Addrs[1])
validators[1].ConsPubKey = keep.PKs[1]
validators[1].Description = NewDescription("bloop", "", "", "")
validators[1].Status = sdk.Bonded

View File

@ -54,32 +54,32 @@ func EndBlocker(ctx sdk.Context, k keeper.Keeper) ([]abci.ValidatorUpdate, sdk.T
// Remove all mature unbonding delegations from the ubd queue.
matureUnbonds := k.DequeueAllMatureUBDQueue(ctx, ctx.BlockHeader().Time)
for _, dvPair := range matureUnbonds {
err := k.CompleteUnbonding(ctx, dvPair.DelegatorAddr, dvPair.ValidatorAddr)
err := k.CompleteUnbonding(ctx, dvPair.DelegatorAddress, dvPair.ValidatorAddress)
if err != nil {
continue
}
resTags.AppendTags(sdk.NewTags(
tags.Action, ActionCompleteUnbonding,
tags.Delegator, dvPair.DelegatorAddr.String(),
tags.SrcValidator, dvPair.ValidatorAddr.String(),
tags.Delegator, dvPair.DelegatorAddress.String(),
tags.SrcValidator, dvPair.ValidatorAddress.String(),
))
}
// Remove all mature redelegations from the red queue.
matureRedelegations := k.DequeueAllMatureRedelegationQueue(ctx, ctx.BlockHeader().Time)
for _, dvvTriplet := range matureRedelegations {
err := k.CompleteRedelegation(ctx, dvvTriplet.DelegatorAddr,
dvvTriplet.ValidatorSrcAddr, dvvTriplet.ValidatorDstAddr)
err := k.CompleteRedelegation(ctx, dvvTriplet.DelegatorAddress,
dvvTriplet.ValidatorSrcAddress, dvvTriplet.ValidatorDstAddress)
if err != nil {
continue
}
resTags.AppendTags(sdk.NewTags(
tags.Action, tags.ActionCompleteRedelegation,
tags.Delegator, dvvTriplet.DelegatorAddr.String(),
tags.SrcValidator, dvvTriplet.ValidatorSrcAddr.String(),
tags.DstValidator, dvvTriplet.ValidatorDstAddr.String(),
tags.Delegator, dvvTriplet.DelegatorAddress.String(),
tags.SrcValidator, dvvTriplet.ValidatorSrcAddress.String(),
tags.DstValidator, dvvTriplet.ValidatorDstAddress.String(),
))
}
@ -91,7 +91,7 @@ func EndBlocker(ctx sdk.Context, k keeper.Keeper) ([]abci.ValidatorUpdate, sdk.T
func handleMsgCreateValidator(ctx sdk.Context, msg types.MsgCreateValidator, k keeper.Keeper) sdk.Result {
// check to see if the pubkey or sender has been registered before
if _, found := k.GetValidator(ctx, msg.ValidatorAddr); found {
if _, found := k.GetValidator(ctx, msg.ValidatorAddress); found {
return ErrValidatorOwnerExists(k.Codespace()).Result()
}
@ -116,7 +116,7 @@ func handleMsgCreateValidator(ctx sdk.Context, msg types.MsgCreateValidator, k k
}
}
validator := NewValidator(msg.ValidatorAddr, msg.PubKey, msg.Description)
validator := NewValidator(msg.ValidatorAddress, msg.PubKey, msg.Description)
commission := NewCommissionWithTime(
msg.Commission.Rate, msg.Commission.MaxRate,
msg.Commission.MaxChangeRate, ctx.BlockHeader().Time,
@ -133,17 +133,17 @@ func handleMsgCreateValidator(ctx sdk.Context, msg types.MsgCreateValidator, k k
k.SetNewValidatorByPowerIndex(ctx, validator)
// call the after-creation hook
k.AfterValidatorCreated(ctx, validator.OperatorAddr)
k.AfterValidatorCreated(ctx, validator.OperatorAddress)
// move coins from the msg.Address account to a (self-delegation) delegator account
// the validator account and global shares are updated within here
_, err = k.Delegate(ctx, msg.DelegatorAddr, msg.Value.Amount, validator, true)
_, err = k.Delegate(ctx, msg.DelegatorAddress, msg.Value.Amount, validator, true)
if err != nil {
return err.Result()
}
tags := sdk.NewTags(
tags.DstValidator, msg.ValidatorAddr.String(),
tags.DstValidator, msg.ValidatorAddress.String(),
tags.Moniker, msg.Description.Moniker,
tags.Identity, msg.Description.Identity,
)
@ -155,7 +155,7 @@ func handleMsgCreateValidator(ctx sdk.Context, msg types.MsgCreateValidator, k k
func handleMsgEditValidator(ctx sdk.Context, msg types.MsgEditValidator, k keeper.Keeper) sdk.Result {
// validator must already be registered
validator, found := k.GetValidator(ctx, msg.ValidatorAddr)
validator, found := k.GetValidator(ctx, msg.ValidatorAddress)
if !found {
return ErrNoValidatorFound(k.Codespace()).Result()
}
@ -175,7 +175,7 @@ func handleMsgEditValidator(ctx sdk.Context, msg types.MsgEditValidator, k keepe
}
// call the before-modification hook since we're about to update the commission
k.BeforeValidatorModified(ctx, msg.ValidatorAddr)
k.BeforeValidatorModified(ctx, msg.ValidatorAddress)
validator.Commission = commission
}
@ -193,7 +193,7 @@ func handleMsgEditValidator(ctx sdk.Context, msg types.MsgEditValidator, k keepe
k.SetValidator(ctx, validator)
tags := sdk.NewTags(
tags.DstValidator, msg.ValidatorAddr.String(),
tags.DstValidator, msg.ValidatorAddress.String(),
tags.Moniker, description.Moniker,
tags.Identity, description.Identity,
)
@ -204,7 +204,7 @@ func handleMsgEditValidator(ctx sdk.Context, msg types.MsgEditValidator, k keepe
}
func handleMsgDelegate(ctx sdk.Context, msg types.MsgDelegate, k keeper.Keeper) sdk.Result {
validator, found := k.GetValidator(ctx, msg.ValidatorAddr)
validator, found := k.GetValidator(ctx, msg.ValidatorAddress)
if !found {
return ErrNoValidatorFound(k.Codespace()).Result()
}
@ -213,14 +213,14 @@ func handleMsgDelegate(ctx sdk.Context, msg types.MsgDelegate, k keeper.Keeper)
return ErrBadDenom(k.Codespace()).Result()
}
_, err := k.Delegate(ctx, msg.DelegatorAddr, msg.Value.Amount, validator, true)
_, err := k.Delegate(ctx, msg.DelegatorAddress, msg.Value.Amount, validator, true)
if err != nil {
return err.Result()
}
tags := sdk.NewTags(
tags.Delegator, msg.DelegatorAddr.String(),
tags.DstValidator, msg.ValidatorAddr.String(),
tags.Delegator, msg.DelegatorAddress.String(),
tags.DstValidator, msg.ValidatorAddress.String(),
)
return sdk.Result{
@ -229,15 +229,15 @@ func handleMsgDelegate(ctx sdk.Context, msg types.MsgDelegate, k keeper.Keeper)
}
func handleMsgUndelegate(ctx sdk.Context, msg types.MsgUndelegate, k keeper.Keeper) sdk.Result {
completionTime, err := k.Undelegate(ctx, msg.DelegatorAddr, msg.ValidatorAddr, msg.SharesAmount)
completionTime, err := k.Undelegate(ctx, msg.DelegatorAddress, msg.ValidatorAddress, msg.SharesAmount)
if err != nil {
return err.Result()
}
finishTime := types.MsgCdc.MustMarshalBinaryLengthPrefixed(completionTime)
tags := sdk.NewTags(
tags.Delegator, msg.DelegatorAddr.String(),
tags.SrcValidator, msg.ValidatorAddr.String(),
tags.Delegator, msg.DelegatorAddress.String(),
tags.SrcValidator, msg.ValidatorAddress.String(),
tags.EndTime, completionTime.Format(time.RFC3339),
)
@ -245,17 +245,17 @@ func handleMsgUndelegate(ctx sdk.Context, msg types.MsgUndelegate, k keeper.Keep
}
func handleMsgBeginRedelegate(ctx sdk.Context, msg types.MsgBeginRedelegate, k keeper.Keeper) sdk.Result {
completionTime, err := k.BeginRedelegation(ctx, msg.DelegatorAddr, msg.ValidatorSrcAddr,
msg.ValidatorDstAddr, msg.SharesAmount)
completionTime, err := k.BeginRedelegation(ctx, msg.DelegatorAddress, msg.ValidatorSrcAddress,
msg.ValidatorDstAddress, msg.SharesAmount)
if err != nil {
return err.Result()
}
finishTime := types.MsgCdc.MustMarshalBinaryLengthPrefixed(completionTime)
resTags := sdk.NewTags(
tags.Delegator, msg.DelegatorAddr.String(),
tags.SrcValidator, msg.ValidatorSrcAddr.String(),
tags.DstValidator, msg.ValidatorDstAddr.String(),
tags.Delegator, msg.DelegatorAddress.String(),
tags.SrcValidator, msg.ValidatorSrcAddress.String(),
tags.DstValidator, msg.ValidatorDstAddress.String(),
tags.EndTime, completionTime.Format(time.RFC3339),
)

View File

@ -123,7 +123,7 @@ func TestDuplicatesMsgCreateValidator(t *testing.T) {
validator, found := keeper.GetValidator(ctx, addr1)
require.True(t, found)
assert.Equal(t, sdk.Bonded, validator.Status)
assert.Equal(t, addr1, validator.OperatorAddr)
assert.Equal(t, addr1, validator.OperatorAddress)
assert.Equal(t, pk1, validator.ConsPubKey)
assert.Equal(t, valTokens, validator.BondedTokens())
assert.Equal(t, valTokens.ToDec(), validator.DelegatorShares)
@ -152,7 +152,7 @@ func TestDuplicatesMsgCreateValidator(t *testing.T) {
require.True(t, found)
assert.Equal(t, sdk.Bonded, validator.Status)
assert.Equal(t, addr2, validator.OperatorAddr)
assert.Equal(t, addr2, validator.OperatorAddress)
assert.Equal(t, pk2, validator.ConsPubKey)
assert.True(sdk.IntEq(t, valTokens, validator.Tokens))
assert.True(sdk.DecEq(t, valTokens.ToDec(), validator.DelegatorShares))
@ -197,14 +197,14 @@ func TestDuplicatesMsgCreateValidatorOnBehalfOf(t *testing.T) {
require.True(t, found)
assert.Equal(t, sdk.Bonded, validator.Status)
assert.Equal(t, validatorAddr, validator.OperatorAddr)
assert.Equal(t, validatorAddr, validator.OperatorAddress)
assert.Equal(t, pk, validator.ConsPubKey)
assert.True(sdk.IntEq(t, valTokens, validator.Tokens))
assert.True(sdk.DecEq(t, valTokens.ToDec(), validator.DelegatorShares))
assert.Equal(t, Description{}, validator.Description)
// one validator cannot be created twice even from different delegator
msgCreateValidatorOnBehalfOf.DelegatorAddr = keep.Addrs[2]
msgCreateValidatorOnBehalfOf.DelegatorAddress = keep.Addrs[2]
msgCreateValidatorOnBehalfOf.PubKey = keep.PKs[1]
got = handleMsgCreateValidator(ctx, msgCreateValidatorOnBehalfOf, keeper)
require.False(t, got.IsOK(), "%v", got)

View File

@ -76,15 +76,15 @@ func (k Keeper) GetDelegatorDelegations(ctx sdk.Context, delegator sdk.AccAddres
func (k Keeper) SetDelegation(ctx sdk.Context, delegation types.Delegation) {
store := ctx.KVStore(k.storeKey)
b := types.MustMarshalDelegation(k.cdc, delegation)
store.Set(GetDelegationKey(delegation.DelegatorAddr, delegation.ValidatorAddr), b)
store.Set(GetDelegationKey(delegation.DelegatorAddress, delegation.ValidatorAddress), b)
}
// remove a delegation
func (k Keeper) RemoveDelegation(ctx sdk.Context, delegation types.Delegation) {
// TODO: Consider calling hooks outside of the store wrapper functions, it's unobvious.
k.BeforeDelegationRemoved(ctx, delegation.DelegatorAddr, delegation.ValidatorAddr)
k.BeforeDelegationRemoved(ctx, delegation.DelegatorAddress, delegation.ValidatorAddress)
store := ctx.KVStore(k.storeKey)
store.Delete(GetDelegationKey(delegation.DelegatorAddr, delegation.ValidatorAddr))
store.Delete(GetDelegationKey(delegation.DelegatorAddress, delegation.ValidatorAddress))
}
// return a given amount of all the delegator unbonding-delegations
@ -167,17 +167,17 @@ func (k Keeper) HasMaxUnbondingDelegationEntries(ctx sdk.Context,
func (k Keeper) SetUnbondingDelegation(ctx sdk.Context, ubd types.UnbondingDelegation) {
store := ctx.KVStore(k.storeKey)
bz := types.MustMarshalUBD(k.cdc, ubd)
key := GetUBDKey(ubd.DelegatorAddr, ubd.ValidatorAddr)
key := GetUBDKey(ubd.DelegatorAddress, ubd.ValidatorAddress)
store.Set(key, bz)
store.Set(GetUBDByValIndexKey(ubd.DelegatorAddr, ubd.ValidatorAddr), []byte{}) // index, store empty bytes
store.Set(GetUBDByValIndexKey(ubd.DelegatorAddress, ubd.ValidatorAddress), []byte{}) // index, store empty bytes
}
// remove the unbonding delegation object and associated index
func (k Keeper) RemoveUnbondingDelegation(ctx sdk.Context, ubd types.UnbondingDelegation) {
store := ctx.KVStore(k.storeKey)
key := GetUBDKey(ubd.DelegatorAddr, ubd.ValidatorAddr)
key := GetUBDKey(ubd.DelegatorAddress, ubd.ValidatorAddress)
store.Delete(key)
store.Delete(GetUBDByValIndexKey(ubd.DelegatorAddr, ubd.ValidatorAddr))
store.Delete(GetUBDByValIndexKey(ubd.DelegatorAddress, ubd.ValidatorAddress))
}
// SetUnbondingDelegationEntry adds an entry to the unbonding delegation at
@ -222,7 +222,7 @@ func (k Keeper) InsertUBDQueue(ctx sdk.Context, ubd types.UnbondingDelegation,
completionTime time.Time) {
timeSlice := k.GetUBDQueueTimeSlice(ctx, completionTime)
dvPair := types.DVPair{DelegatorAddr: ubd.DelegatorAddr, ValidatorAddr: ubd.ValidatorAddr}
dvPair := types.DVPair{DelegatorAddress: ubd.DelegatorAddress, ValidatorAddress: ubd.ValidatorAddress}
if len(timeSlice) == 0 {
k.SetUBDQueueTimeSlice(ctx, completionTime, []types.DVPair{dvPair})
} else {
@ -333,10 +333,10 @@ func (k Keeper) HasMaxRedelegationEntries(ctx sdk.Context,
func (k Keeper) SetRedelegation(ctx sdk.Context, red types.Redelegation) {
store := ctx.KVStore(k.storeKey)
bz := types.MustMarshalRED(k.cdc, red)
key := GetREDKey(red.DelegatorAddr, red.ValidatorSrcAddr, red.ValidatorDstAddr)
key := GetREDKey(red.DelegatorAddress, red.ValidatorSrcAddress, red.ValidatorDstAddress)
store.Set(key, bz)
store.Set(GetREDByValSrcIndexKey(red.DelegatorAddr, red.ValidatorSrcAddr, red.ValidatorDstAddr), []byte{})
store.Set(GetREDByValDstIndexKey(red.DelegatorAddr, red.ValidatorSrcAddr, red.ValidatorDstAddr), []byte{})
store.Set(GetREDByValSrcIndexKey(red.DelegatorAddress, red.ValidatorSrcAddress, red.ValidatorDstAddress), []byte{})
store.Set(GetREDByValDstIndexKey(red.DelegatorAddress, red.ValidatorSrcAddress, red.ValidatorDstAddress), []byte{})
}
// SetUnbondingDelegationEntry adds an entry to the unbonding delegation at
@ -376,10 +376,10 @@ func (k Keeper) IterateRedelegations(ctx sdk.Context, fn func(index int64, red t
// remove a redelegation object and associated index
func (k Keeper) RemoveRedelegation(ctx sdk.Context, red types.Redelegation) {
store := ctx.KVStore(k.storeKey)
redKey := GetREDKey(red.DelegatorAddr, red.ValidatorSrcAddr, red.ValidatorDstAddr)
redKey := GetREDKey(red.DelegatorAddress, red.ValidatorSrcAddress, red.ValidatorDstAddress)
store.Delete(redKey)
store.Delete(GetREDByValSrcIndexKey(red.DelegatorAddr, red.ValidatorSrcAddr, red.ValidatorDstAddr))
store.Delete(GetREDByValDstIndexKey(red.DelegatorAddr, red.ValidatorSrcAddr, red.ValidatorDstAddr))
store.Delete(GetREDByValSrcIndexKey(red.DelegatorAddress, red.ValidatorSrcAddress, red.ValidatorDstAddress))
store.Delete(GetREDByValDstIndexKey(red.DelegatorAddress, red.ValidatorSrcAddress, red.ValidatorDstAddress))
}
// redelegation queue timeslice operations
@ -409,9 +409,9 @@ func (k Keeper) InsertRedelegationQueue(ctx sdk.Context, red types.Redelegation,
timeSlice := k.GetRedelegationQueueTimeSlice(ctx, completionTime)
dvvTriplet := types.DVVTriplet{
DelegatorAddr: red.DelegatorAddr,
ValidatorSrcAddr: red.ValidatorSrcAddr,
ValidatorDstAddr: red.ValidatorDstAddr}
DelegatorAddress: red.DelegatorAddress,
ValidatorSrcAddress: red.ValidatorSrcAddress,
ValidatorDstAddress: red.ValidatorDstAddress}
if len(timeSlice) == 0 {
k.SetRedelegationQueueTimeSlice(ctx, completionTime, []types.DVVTriplet{dvvTriplet})
@ -455,20 +455,20 @@ func (k Keeper) Delegate(ctx sdk.Context, delAddr sdk.AccAddress, bondAmt sdk.In
}
// Get or create the delegation object
delegation, found := k.GetDelegation(ctx, delAddr, validator.OperatorAddr)
delegation, found := k.GetDelegation(ctx, delAddr, validator.OperatorAddress)
if !found {
delegation = types.NewDelegation(delAddr, validator.OperatorAddr, sdk.ZeroDec())
delegation = types.NewDelegation(delAddr, validator.OperatorAddress, sdk.ZeroDec())
}
// call the appropriate hook if present
if found {
k.BeforeDelegationSharesModified(ctx, delAddr, validator.OperatorAddr)
k.BeforeDelegationSharesModified(ctx, delAddr, validator.OperatorAddress)
} else {
k.BeforeDelegationCreated(ctx, delAddr, validator.OperatorAddr)
k.BeforeDelegationCreated(ctx, delAddr, validator.OperatorAddress)
}
if subtractAccount {
_, err := k.bankKeeper.DelegateCoins(ctx, delegation.DelegatorAddr, sdk.Coins{sdk.NewCoin(k.GetParams(ctx).BondDenom, bondAmt)})
_, err := k.bankKeeper.DelegateCoins(ctx, delegation.DelegatorAddress, sdk.Coins{sdk.NewCoin(k.GetParams(ctx).BondDenom, bondAmt)})
if err != nil {
return sdk.Dec{}, err
}
@ -481,7 +481,7 @@ func (k Keeper) Delegate(ctx sdk.Context, delAddr sdk.AccAddress, bondAmt sdk.In
k.SetDelegation(ctx, delegation)
// Call the after-modification hook
k.AfterDelegationModified(ctx, delegation.DelegatorAddr, delegation.ValidatorAddr)
k.AfterDelegationModified(ctx, delegation.DelegatorAddress, delegation.ValidatorAddress)
return newShares, nil
}
@ -513,13 +513,13 @@ func (k Keeper) unbond(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValA
// subtract shares from delegation
delegation.Shares = delegation.Shares.Sub(shares)
isValidatorOperator := bytes.Equal(delegation.DelegatorAddr, validator.OperatorAddr)
isValidatorOperator := bytes.Equal(delegation.DelegatorAddress, validator.OperatorAddress)
// if the delegation is the operator of the validator and undelegating will decrease the validator's self delegation below their minimum
// trigger a jail validator
if isValidatorOperator && !validator.Jailed && validator.DelegatorShareExRate().Mul(delegation.Shares).TruncateInt().LT(validator.MinSelfDelegation) {
k.jailValidator(ctx, validator)
validator = k.mustGetValidator(ctx, validator.OperatorAddr)
validator = k.mustGetValidator(ctx, validator.OperatorAddress)
}
// remove the delegation
@ -528,7 +528,7 @@ func (k Keeper) unbond(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValA
} else {
k.SetDelegation(ctx, delegation)
// call the after delegation modification hook
k.AfterDelegationModified(ctx, delegation.DelegatorAddr, delegation.ValidatorAddr)
k.AfterDelegationModified(ctx, delegation.DelegatorAddress, delegation.ValidatorAddress)
}
// remove the shares and coins from the validator
@ -536,7 +536,7 @@ func (k Keeper) unbond(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValA
if validator.DelegatorShares.IsZero() && validator.Status == sdk.Unbonded {
// if not unbonded, we must instead remove validator in EndBlocker once it finishes its unbonding period
k.RemoveValidator(ctx, validator.OperatorAddr)
k.RemoveValidator(ctx, validator.OperatorAddress)
}
return amount, nil
@ -627,7 +627,7 @@ func (k Keeper) CompleteUnbonding(ctx sdk.Context, delAddr sdk.AccAddress,
// track undelegation only when remaining or truncated shares are non-zero
if !entry.Balance.IsZero() {
_, err := k.bankKeeper.UndelegateCoins(ctx, ubd.DelegatorAddr, sdk.Coins{sdk.NewCoin(k.GetParams(ctx).BondDenom, entry.Balance)})
_, err := k.bankKeeper.UndelegateCoins(ctx, ubd.DelegatorAddress, sdk.Coins{sdk.NewCoin(k.GetParams(ctx).BondDenom, entry.Balance)})
if err != nil {
return err
}

View File

@ -86,7 +86,7 @@ func getValidatorPowerRank(validator types.Validator) []byte {
key[0] = ValidatorsByPowerIndexKey[0]
copy(key[1:powerBytesLen+1], powerBytes)
operAddrInvr := cp(validator.OperatorAddr)
operAddrInvr := cp(validator.OperatorAddress)
for i, b := range operAddrInvr {
operAddrInvr[i] = ^b
}

View File

@ -19,7 +19,7 @@ func (k Keeper) GetDelegatorValidators(ctx sdk.Context, delegatorAddr sdk.AccAdd
for ; iterator.Valid() && i < int(maxRetrieve); iterator.Next() {
delegation := types.MustUnmarshalDelegation(k.cdc, iterator.Value())
validator, found := k.GetValidator(ctx, delegation.ValidatorAddr)
validator, found := k.GetValidator(ctx, delegation.ValidatorAddress)
if !found {
panic(types.ErrNoValidatorFound(types.DefaultCodespace))
}
@ -38,7 +38,7 @@ func (k Keeper) GetDelegatorValidator(ctx sdk.Context, delegatorAddr sdk.AccAddr
return validator, types.ErrNoDelegation(types.DefaultCodespace)
}
validator, found = k.GetValidator(ctx, delegation.ValidatorAddr)
validator, found = k.GetValidator(ctx, delegation.ValidatorAddress)
if !found {
panic(types.ErrNoValidatorFound(types.DefaultCodespace))
}
@ -98,10 +98,10 @@ func (k Keeper) GetAllRedelegations(ctx sdk.Context, delegator sdk.AccAddress,
for ; iterator.Valid(); iterator.Next() {
redelegation := types.MustUnmarshalRED(k.cdc, iterator.Value())
if srcValFilter && !(srcValAddress.Equals(redelegation.ValidatorSrcAddr)) {
if srcValFilter && !(srcValAddress.Equals(redelegation.ValidatorSrcAddress)) {
continue
}
if dstValFilter && !(dstValAddress.Equals(redelegation.ValidatorDstAddr)) {
if dstValFilter && !(dstValAddress.Equals(redelegation.ValidatorDstAddress)) {
continue
}
redelegations = append(redelegations, redelegation)

View File

@ -241,7 +241,7 @@ func (k Keeper) slashRedelegation(ctx sdk.Context, validator types.Validator, re
if sharesToUnbond.IsZero() {
continue
}
delegation, found := k.GetDelegation(ctx, redelegation.DelegatorAddr, redelegation.ValidatorDstAddr)
delegation, found := k.GetDelegation(ctx, redelegation.DelegatorAddress, redelegation.ValidatorDstAddress)
if !found {
// If deleted, delegation has zero shares, and we can't unbond any more
continue
@ -250,7 +250,7 @@ func (k Keeper) slashRedelegation(ctx sdk.Context, validator types.Validator, re
sharesToUnbond = delegation.Shares
}
tokensToBurn, err := k.unbond(ctx, redelegation.DelegatorAddr, redelegation.ValidatorDstAddr, sharesToUnbond)
tokensToBurn, err := k.unbond(ctx, redelegation.DelegatorAddress, redelegation.ValidatorDstAddress, sharesToUnbond)
if err != nil {
panic(fmt.Errorf("error unbonding delegator: %v", err))
}

View File

@ -195,7 +195,7 @@ func TestSlashAtNegativeHeight(t *testing.T) {
updates := keeper.ApplyAndReturnValidatorSetUpdates(ctx)
require.Equal(t, 1, len(updates), "cons addr: %v, updates: %v", []byte(consAddr), updates)
validator = keeper.mustGetValidator(ctx, validator.OperatorAddr)
validator = keeper.mustGetValidator(ctx, validator.OperatorAddress)
// power decreased
require.Equal(t, int64(5), validator.GetTendermintPower())
// pool bonded shares decreased
@ -222,7 +222,7 @@ func TestSlashValidatorAtCurrentHeight(t *testing.T) {
updates := keeper.ApplyAndReturnValidatorSetUpdates(ctx)
require.Equal(t, 1, len(updates), "cons addr: %v, updates: %v", []byte(consAddr), updates)
validator = keeper.mustGetValidator(ctx, validator.OperatorAddr)
validator = keeper.mustGetValidator(ctx, validator.OperatorAddress)
// power decreased
require.Equal(t, int64(5), validator.GetTendermintPower())
// pool bonded shares decreased

View File

@ -226,7 +226,7 @@ func TestingUpdateValidator(keeper Keeper, ctx sdk.Context, validator types.Vali
deleted := false
for ; iterator.Valid(); iterator.Next() {
valAddr := parseValidatorPowerRankKey(iterator.Key())
if bytes.Equal(valAddr, validator.OperatorAddr) {
if bytes.Equal(valAddr, validator.OperatorAddress) {
if deleted {
panic("found duplicate power index key")
} else {
@ -239,7 +239,7 @@ func TestingUpdateValidator(keeper Keeper, ctx sdk.Context, validator types.Vali
keeper.SetValidatorByPowerIndex(ctx, validator)
if apply {
keeper.ApplyAndReturnValidatorSetUpdates(ctx)
validator, found := keeper.GetValidator(ctx, validator.OperatorAddr)
validator, found := keeper.GetValidator(ctx, validator.OperatorAddress)
if !found {
panic("validator expected but not found")
}
@ -247,7 +247,7 @@ func TestingUpdateValidator(keeper Keeper, ctx sdk.Context, validator types.Vali
}
cachectx, _ := ctx.CacheContext()
keeper.ApplyAndReturnValidatorSetUpdates(cachectx)
validator, found := keeper.GetValidator(cachectx, validator.OperatorAddr)
validator, found := keeper.GetValidator(cachectx, validator.OperatorAddress)
if !found {
panic("validator expected but not found")
}

View File

@ -189,7 +189,7 @@ func (k Keeper) bondValidator(ctx sdk.Context, validator types.Validator) types.
k.DeleteValidatorQueue(ctx, validator)
// trigger hook
k.AfterValidatorBonded(ctx, validator.ConsAddress(), validator.OperatorAddr)
k.AfterValidatorBonded(ctx, validator.ConsAddress(), validator.OperatorAddress)
return validator
}
@ -224,7 +224,7 @@ func (k Keeper) beginUnbondingValidator(ctx sdk.Context, validator types.Validat
k.InsertValidatorQueue(ctx, validator)
// trigger hook
k.AfterValidatorBeginUnbonding(ctx, validator.ConsAddress(), validator.OperatorAddr)
k.AfterValidatorBeginUnbonding(ctx, validator.ConsAddress(), validator.OperatorAddress)
return validator
}

View File

@ -38,7 +38,7 @@ func (k Keeper) GetValidator(ctx sdk.Context, addr sdk.ValAddress) (validator ty
if val, ok := k.validatorCache[strValue]; ok {
valToReturn := val.val
// Doesn't mutate the cache's value
valToReturn.OperatorAddr = addr
valToReturn.OperatorAddress = addr
return valToReturn, true
}
@ -88,14 +88,14 @@ func (k Keeper) mustGetValidatorByConsAddr(ctx sdk.Context, consAddr sdk.ConsAdd
func (k Keeper) SetValidator(ctx sdk.Context, validator types.Validator) {
store := ctx.KVStore(k.storeKey)
bz := types.MustMarshalValidator(k.cdc, validator)
store.Set(GetValidatorKey(validator.OperatorAddr), bz)
store.Set(GetValidatorKey(validator.OperatorAddress), bz)
}
// validator index
func (k Keeper) SetValidatorByConsAddr(ctx sdk.Context, validator types.Validator) {
store := ctx.KVStore(k.storeKey)
consAddr := sdk.ConsAddress(validator.ConsPubKey.Address())
store.Set(GetValidatorByConsAddrKey(consAddr), validator.OperatorAddr)
store.Set(GetValidatorByConsAddrKey(consAddr), validator.OperatorAddress)
}
// validator index
@ -105,7 +105,7 @@ func (k Keeper) SetValidatorByPowerIndex(ctx sdk.Context, validator types.Valida
return
}
store := ctx.KVStore(k.storeKey)
store.Set(GetValidatorsByPowerIndexKey(validator), validator.OperatorAddr)
store.Set(GetValidatorsByPowerIndexKey(validator), validator.OperatorAddress)
}
// validator index
@ -117,7 +117,7 @@ func (k Keeper) DeleteValidatorByPowerIndex(ctx sdk.Context, validator types.Val
// validator index
func (k Keeper) SetNewValidatorByPowerIndex(ctx sdk.Context, validator types.Validator) {
store := ctx.KVStore(k.storeKey)
store.Set(GetValidatorsByPowerIndexKey(validator), validator.OperatorAddr)
store.Set(GetValidatorsByPowerIndexKey(validator), validator.OperatorAddress)
}
// Update the tokens of an existing validator, update the validators power index key
@ -204,7 +204,7 @@ func (k Keeper) RemoveValidator(ctx sdk.Context, address sdk.ValAddress) {
store.Delete(GetValidatorsByPowerIndexKey(validator))
// call hooks
k.AfterValidatorRemoved(ctx, validator.ConsAddress(), validator.OperatorAddr)
k.AfterValidatorRemoved(ctx, validator.ConsAddress(), validator.OperatorAddress)
}
// get groups of validators
@ -378,9 +378,9 @@ func (k Keeper) InsertValidatorQueue(ctx sdk.Context, val types.Validator) {
timeSlice := k.GetValidatorQueueTimeSlice(ctx, val.UnbondingCompletionTime)
var keys []sdk.ValAddress
if len(timeSlice) == 0 {
keys = []sdk.ValAddress{val.OperatorAddr}
keys = []sdk.ValAddress{val.OperatorAddress}
} else {
keys = append(timeSlice, val.OperatorAddr)
keys = append(timeSlice, val.OperatorAddress)
}
k.SetValidatorQueueTimeSlice(ctx, val.UnbondingCompletionTime, keys)
}
@ -390,7 +390,7 @@ func (k Keeper) DeleteValidatorQueue(ctx sdk.Context, val types.Validator) {
timeSlice := k.GetValidatorQueueTimeSlice(ctx, val.UnbondingCompletionTime)
newTimeSlice := []sdk.ValAddress{}
for _, addr := range timeSlice {
if !bytes.Equal(addr, val.OperatorAddr) {
if !bytes.Equal(addr, val.OperatorAddress) {
newTimeSlice = append(newTimeSlice, addr)
}
}
@ -437,7 +437,7 @@ func (k Keeper) UnbondAllMatureValidatorQueue(ctx sdk.Context) {
}
k.unbondingToUnbonded(ctx, val)
if val.GetDelegatorShares().IsZero() {
k.RemoveValidator(ctx, val.OperatorAddr)
k.RemoveValidator(ctx, val.OperatorAddress)
}
}
store.Delete(validatorTimesliceIterator.Key())

View File

@ -157,7 +157,7 @@ func TestUpdateBondedValidatorsDecreaseCliff(t *testing.T) {
// require all the validators have their respective statuses
for valIdx, status := range expectedValStatus {
valAddr := validators[valIdx].OperatorAddr
valAddr := validators[valIdx].OperatorAddress
val, _ := keeper.GetValidator(ctx, valAddr)
assert.Equal(
@ -284,18 +284,18 @@ func TestValidatorBasics(t *testing.T) {
// shouldn't be able to remove if status is not unbonded
assert.PanicsWithValue(t,
"cannot call RemoveValidator on bonded or unbonding validators",
func() { keeper.RemoveValidator(ctx, validators[1].OperatorAddr) })
func() { keeper.RemoveValidator(ctx, validators[1].OperatorAddress) })
// shouldn't be able to remove if there are still tokens left
validators[1].Status = sdk.Unbonded
keeper.SetValidator(ctx, validators[1])
assert.PanicsWithValue(t,
"attempting to remove a validator which still contains tokens",
func() { keeper.RemoveValidator(ctx, validators[1].OperatorAddr) })
func() { keeper.RemoveValidator(ctx, validators[1].OperatorAddress) })
validators[1].Tokens = sdk.ZeroInt() // ...remove all tokens
keeper.SetValidator(ctx, validators[1]) // ...set the validator
keeper.RemoveValidator(ctx, validators[1].OperatorAddr) // Now it can be removed.
validators[1].Tokens = sdk.ZeroInt() // ...remove all tokens
keeper.SetValidator(ctx, validators[1]) // ...set the validator
keeper.RemoveValidator(ctx, validators[1].OperatorAddress) // Now it can be removed.
_, found = keeper.GetValidator(ctx, addrVals[1])
require.False(t, found)
}
@ -324,11 +324,11 @@ func GetValidatorSortingUnmixed(t *testing.T) {
assert.Equal(t, sdk.NewInt(100), resValidators[2].BondedTokens(), "%v", resValidators)
assert.Equal(t, sdk.NewInt(1), resValidators[3].BondedTokens(), "%v", resValidators)
assert.Equal(t, sdk.NewInt(0), resValidators[4].BondedTokens(), "%v", resValidators)
assert.Equal(t, validators[3].OperatorAddr, resValidators[0].OperatorAddr, "%v", resValidators)
assert.Equal(t, validators[4].OperatorAddr, resValidators[1].OperatorAddr, "%v", resValidators)
assert.Equal(t, validators[1].OperatorAddr, resValidators[2].OperatorAddr, "%v", resValidators)
assert.Equal(t, validators[2].OperatorAddr, resValidators[3].OperatorAddr, "%v", resValidators)
assert.Equal(t, validators[0].OperatorAddr, resValidators[4].OperatorAddr, "%v", resValidators)
assert.Equal(t, validators[3].OperatorAddress, resValidators[0].OperatorAddress, "%v", resValidators)
assert.Equal(t, validators[4].OperatorAddress, resValidators[1].OperatorAddress, "%v", resValidators)
assert.Equal(t, validators[1].OperatorAddress, resValidators[2].OperatorAddress, "%v", resValidators)
assert.Equal(t, validators[2].OperatorAddress, resValidators[3].OperatorAddress, "%v", resValidators)
assert.Equal(t, validators[0].OperatorAddress, resValidators[4].OperatorAddress, "%v", resValidators)
// test a basic increase in voting power
validators[3].Tokens = sdk.NewInt(500)
@ -433,11 +433,11 @@ func GetValidatorSortingMixed(t *testing.T) {
assert.Equal(t, sdk.NewInt(100), resValidators[2].BondedTokens(), "%v", resValidators)
assert.Equal(t, sdk.NewInt(1), resValidators[3].BondedTokens(), "%v", resValidators)
assert.Equal(t, sdk.NewInt(0), resValidators[4].BondedTokens(), "%v", resValidators)
assert.Equal(t, validators[3].OperatorAddr, resValidators[0].OperatorAddr, "%v", resValidators)
assert.Equal(t, validators[4].OperatorAddr, resValidators[1].OperatorAddr, "%v", resValidators)
assert.Equal(t, validators[1].OperatorAddr, resValidators[2].OperatorAddr, "%v", resValidators)
assert.Equal(t, validators[2].OperatorAddr, resValidators[3].OperatorAddr, "%v", resValidators)
assert.Equal(t, validators[0].OperatorAddr, resValidators[4].OperatorAddr, "%v", resValidators)
assert.Equal(t, validators[3].OperatorAddress, resValidators[0].OperatorAddress, "%v", resValidators)
assert.Equal(t, validators[4].OperatorAddress, resValidators[1].OperatorAddress, "%v", resValidators)
assert.Equal(t, validators[1].OperatorAddress, resValidators[2].OperatorAddress, "%v", resValidators)
assert.Equal(t, validators[2].OperatorAddress, resValidators[3].OperatorAddress, "%v", resValidators)
assert.Equal(t, validators[0].OperatorAddress, resValidators[4].OperatorAddress, "%v", resValidators)
}
// TODO separate out into multiple tests
@ -465,7 +465,7 @@ func TestGetValidatorsEdgeCases(t *testing.T) {
}
for i := range powers {
validators[i], found = keeper.GetValidator(ctx, validators[i].OperatorAddr)
validators[i], found = keeper.GetValidator(ctx, validators[i].OperatorAddress)
require.True(t, found)
}
resValidators := keeper.GetBondedValidatorsByPower(ctx)
@ -491,7 +491,7 @@ func TestGetValidatorsEdgeCases(t *testing.T) {
// validator 3 enters bonded validator set
ctx = ctx.WithBlockHeight(40)
validators[3], found = keeper.GetValidator(ctx, validators[3].OperatorAddr)
validators[3], found = keeper.GetValidator(ctx, validators[3].OperatorAddress)
require.True(t, found)
keeper.DeleteValidatorByPowerIndex(ctx, validators[3])
validators[3], pool, _ = validators[3].AddTokensFromDel(pool, sdk.NewInt(1))
@ -521,7 +521,7 @@ func TestGetValidatorsEdgeCases(t *testing.T) {
require.Equal(t, nMax, uint16(len(resValidators)))
assert.True(ValEq(t, validators[0], resValidators[0]))
assert.True(ValEq(t, validators[2], resValidators[1]))
_, exists := keeper.GetValidator(ctx, validators[3].OperatorAddr)
_, exists := keeper.GetValidator(ctx, validators[3].OperatorAddress)
require.True(t, exists)
}
@ -597,7 +597,7 @@ func TestFullValidatorSetPowerChange(t *testing.T) {
}
for i := range powers {
var found bool
validators[i], found = keeper.GetValidator(ctx, validators[i].OperatorAddr)
validators[i], found = keeper.GetValidator(ctx, validators[i].OperatorAddress)
require.True(t, found)
}
assert.Equal(t, sdk.Unbonded, validators[0].Status)
@ -649,8 +649,8 @@ func TestApplyAndReturnValidatorSetUpdatesAllNone(t *testing.T) {
updates := keeper.ApplyAndReturnValidatorSetUpdates(ctx)
assert.Equal(t, 2, len(updates))
validators[0], _ = keeper.GetValidator(ctx, validators[0].OperatorAddr)
validators[1], _ = keeper.GetValidator(ctx, validators[1].OperatorAddr)
validators[0], _ = keeper.GetValidator(ctx, validators[0].OperatorAddress)
validators[1], _ = keeper.GetValidator(ctx, validators[1].OperatorAddress)
assert.Equal(t, validators[0].ABCIValidatorUpdate(), updates[1])
assert.Equal(t, validators[1].ABCIValidatorUpdate(), updates[0])
}
@ -765,7 +765,7 @@ func TestApplyAndReturnValidatorSetUpdatesInserted(t *testing.T) {
keeper.SetValidator(ctx, validators[2])
keeper.SetValidatorByPowerIndex(ctx, validators[2])
updates := keeper.ApplyAndReturnValidatorSetUpdates(ctx)
validators[2], _ = keeper.GetValidator(ctx, validators[2].OperatorAddr)
validators[2], _ = keeper.GetValidator(ctx, validators[2].OperatorAddress)
require.Equal(t, 1, len(updates))
require.Equal(t, validators[2].ABCIValidatorUpdate(), updates[0])
@ -774,7 +774,7 @@ func TestApplyAndReturnValidatorSetUpdatesInserted(t *testing.T) {
keeper.SetValidator(ctx, validators[3])
keeper.SetValidatorByPowerIndex(ctx, validators[3])
updates = keeper.ApplyAndReturnValidatorSetUpdates(ctx)
validators[3], _ = keeper.GetValidator(ctx, validators[3].OperatorAddr)
validators[3], _ = keeper.GetValidator(ctx, validators[3].OperatorAddress)
require.Equal(t, 1, len(updates))
require.Equal(t, validators[3].ABCIValidatorUpdate(), updates[0])
@ -783,7 +783,7 @@ func TestApplyAndReturnValidatorSetUpdatesInserted(t *testing.T) {
keeper.SetValidator(ctx, validators[4])
keeper.SetValidatorByPowerIndex(ctx, validators[4])
updates = keeper.ApplyAndReturnValidatorSetUpdates(ctx)
validators[4], _ = keeper.GetValidator(ctx, validators[4].OperatorAddr)
validators[4], _ = keeper.GetValidator(ctx, validators[4].OperatorAddress)
require.Equal(t, 1, len(updates))
require.Equal(t, validators[4].ABCIValidatorUpdate(), updates[0])
}
@ -825,7 +825,7 @@ func TestApplyAndReturnValidatorSetUpdatesWithCliffValidator(t *testing.T) {
keeper.SetValidator(ctx, validators[2])
keeper.SetValidatorByPowerIndex(ctx, validators[2])
updates = keeper.ApplyAndReturnValidatorSetUpdates(ctx)
validators[2], _ = keeper.GetValidator(ctx, validators[2].OperatorAddr)
validators[2], _ = keeper.GetValidator(ctx, validators[2].OperatorAddress)
require.Equal(t, 2, len(updates), "%v", updates)
require.Equal(t, validators[0].ABCIValidatorUpdateZero(), updates[1])
require.Equal(t, validators[2].ABCIValidatorUpdate(), updates[0])
@ -902,8 +902,8 @@ func TestApplyAndReturnValidatorSetUpdatesNewValidator(t *testing.T) {
// verify initial Tendermint updates are correct
updates := keeper.ApplyAndReturnValidatorSetUpdates(ctx)
require.Equal(t, len(validators), len(updates))
validators[0], _ = keeper.GetValidator(ctx, validators[0].OperatorAddr)
validators[1], _ = keeper.GetValidator(ctx, validators[1].OperatorAddr)
validators[0], _ = keeper.GetValidator(ctx, validators[0].OperatorAddress)
validators[1], _ = keeper.GetValidator(ctx, validators[1].OperatorAddress)
require.Equal(t, validators[0].ABCIValidatorUpdate(), updates[0])
require.Equal(t, validators[1].ABCIValidatorUpdate(), updates[1])
@ -951,9 +951,9 @@ func TestApplyAndReturnValidatorSetUpdatesNewValidator(t *testing.T) {
// verify initial Tendermint updates are correct
updates = keeper.ApplyAndReturnValidatorSetUpdates(ctx)
validator, _ = keeper.GetValidator(ctx, validator.OperatorAddr)
validators[0], _ = keeper.GetValidator(ctx, validators[0].OperatorAddr)
validators[1], _ = keeper.GetValidator(ctx, validators[1].OperatorAddr)
validator, _ = keeper.GetValidator(ctx, validator.OperatorAddress)
validators[0], _ = keeper.GetValidator(ctx, validators[0].OperatorAddress)
validators[1], _ = keeper.GetValidator(ctx, validators[1].OperatorAddress)
require.Equal(t, len(validators)+1, len(updates))
require.Equal(t, validator.ABCIValidatorUpdate(), updates[0])
require.Equal(t, validators[0].ABCIValidatorUpdate(), updates[1])
@ -988,8 +988,8 @@ func TestApplyAndReturnValidatorSetUpdatesBondTransition(t *testing.T) {
// verify initial Tendermint updates are correct
updates := keeper.ApplyAndReturnValidatorSetUpdates(ctx)
require.Equal(t, 2, len(updates))
validators[2], _ = keeper.GetValidator(ctx, validators[2].OperatorAddr)
validators[1], _ = keeper.GetValidator(ctx, validators[1].OperatorAddr)
validators[2], _ = keeper.GetValidator(ctx, validators[2].OperatorAddress)
validators[1], _ = keeper.GetValidator(ctx, validators[1].OperatorAddress)
require.Equal(t, validators[2].ABCIValidatorUpdate(), updates[0])
require.Equal(t, validators[1].ABCIValidatorUpdate(), updates[1])
@ -1000,7 +1000,7 @@ func TestApplyAndReturnValidatorSetUpdatesBondTransition(t *testing.T) {
pool := keeper.GetPool(ctx)
var found bool
validators[0], found = keeper.GetValidator(ctx, validators[0].OperatorAddr)
validators[0], found = keeper.GetValidator(ctx, validators[0].OperatorAddress)
require.True(t, found)
keeper.DeleteValidatorByPowerIndex(ctx, validators[0])
@ -1018,7 +1018,7 @@ func TestApplyAndReturnValidatorSetUpdatesBondTransition(t *testing.T) {
ctx = ctx.WithBlockHeight(2)
pool = keeper.GetPool(ctx)
validators[1], found = keeper.GetValidator(ctx, validators[1].OperatorAddr)
validators[1], found = keeper.GetValidator(ctx, validators[1].OperatorAddress)
require.True(t, found)
keeper.DeleteValidatorByPowerIndex(ctx, validators[0])
@ -1083,7 +1083,7 @@ func TestUpdateValidatorCommission(t *testing.T) {
} else {
tc.validator.Commission = commission
keeper.SetValidator(ctx, tc.validator)
val, found := keeper.GetValidator(ctx, tc.validator.OperatorAddr)
val, found := keeper.GetValidator(ctx, tc.validator.OperatorAddress)
require.True(t, found,
"expected to find validator for test case #%d with rate: %s", i, tc.newRate,

View File

@ -298,7 +298,7 @@ func TestQueryDelegation(t *testing.T) {
// Query unbonging delegation
unbondingTokens := sdk.TokensFromTendermintPower(10)
_, err = keeper.Undelegate(ctx, addrAcc2, val1.OperatorAddr, unbondingTokens.ToDec())
_, err = keeper.Undelegate(ctx, addrAcc2, val1.OperatorAddress, unbondingTokens.ToDec())
require.Nil(t, err)
queryBondParams = NewQueryBondsParams(addrAcc2, addrVal1)
@ -351,13 +351,13 @@ func TestQueryDelegation(t *testing.T) {
// Query redelegation
redelegationTokens := sdk.TokensFromTendermintPower(10)
_, err = keeper.BeginRedelegation(ctx, addrAcc2, val1.OperatorAddr,
val2.OperatorAddr, redelegationTokens.ToDec())
_, err = keeper.BeginRedelegation(ctx, addrAcc2, val1.OperatorAddress,
val2.OperatorAddress, redelegationTokens.ToDec())
require.Nil(t, err)
redel, found := keeper.GetRedelegation(ctx, addrAcc2, val1.OperatorAddr, val2.OperatorAddr)
redel, found := keeper.GetRedelegation(ctx, addrAcc2, val1.OperatorAddress, val2.OperatorAddress)
require.True(t, found)
bz, errRes = cdc.MarshalJSON(NewQueryRedelegationParams(addrAcc2, val1.OperatorAddr, val2.OperatorAddr))
bz, errRes = cdc.MarshalJSON(NewQueryRedelegationParams(addrAcc2, val1.OperatorAddress, val2.OperatorAddress))
require.Nil(t, errRes)
query = abci.RequestQuery{
@ -393,7 +393,7 @@ func TestQueryRedelegations(t *testing.T) {
keeper.BeginRedelegation(ctx, addrAcc2, val1.GetOperator(), val2.GetOperator(), rdAmount.ToDec())
keeper.ApplyAndReturnValidatorSetUpdates(ctx)
redelegation, found := keeper.GetRedelegation(ctx, addrAcc2, val1.OperatorAddr, val2.OperatorAddr)
redelegation, found := keeper.GetRedelegation(ctx, addrAcc2, val1.OperatorAddress, val2.OperatorAddress)
require.True(t, found)
// delegator redelegations

View File

@ -159,9 +159,9 @@ func SimulateMsgUndelegate(m auth.AccountKeeper, k staking.Keeper) simulation.Op
return noOperation, nil, nil
}
msg := staking.MsgUndelegate{
DelegatorAddr: delegatorAddress,
ValidatorAddr: delegation.ValidatorAddr,
SharesAmount: numShares,
DelegatorAddress: delegatorAddress,
ValidatorAddress: delegation.ValidatorAddress,
SharesAmount: numShares,
}
if msg.ValidateBasic() != nil {
return "", nil, fmt.Errorf("expected msg to pass ValidateBasic: %s, got error %v",
@ -201,10 +201,10 @@ func SimulateMsgBeginRedelegate(m auth.AccountKeeper, k staking.Keeper) simulati
return noOperation, nil, nil
}
msg := staking.MsgBeginRedelegate{
DelegatorAddr: delegatorAddress,
ValidatorSrcAddr: srcValidatorAddress,
ValidatorDstAddr: destValidatorAddress,
SharesAmount: amount.ToDec(),
DelegatorAddress: delegatorAddress,
ValidatorSrcAddress: srcValidatorAddress,
ValidatorDstAddress: destValidatorAddress,
SharesAmount: amount.ToDec(),
}
if msg.ValidateBasic() != nil {
return "", nil, fmt.Errorf("expected msg to pass ValidateBasic: %s", msg.GetSignBytes())

View File

@ -9,8 +9,8 @@ func RegisterCodec(cdc *codec.Codec) {
cdc.RegisterConcrete(MsgCreateValidator{}, "cosmos-sdk/MsgCreateValidator", nil)
cdc.RegisterConcrete(MsgEditValidator{}, "cosmos-sdk/MsgEditValidator", nil)
cdc.RegisterConcrete(MsgDelegate{}, "cosmos-sdk/MsgDelegate", nil)
cdc.RegisterConcrete(MsgUndelegate{}, "cosmos-sdk/Undelegate", nil)
cdc.RegisterConcrete(MsgBeginRedelegate{}, "cosmos-sdk/BeginRedelegate", nil)
cdc.RegisterConcrete(MsgUndelegate{}, "cosmos-sdk/MsgUndelegate", nil)
cdc.RegisterConcrete(MsgBeginRedelegate{}, "cosmos-sdk/MsgBeginRedelegate", nil)
}
// generic sealed codec to be used throughout sdk

View File

@ -14,26 +14,26 @@ import (
// It is intended to be used as a marshalable pointer. For example, a DVPair can be used to construct the
// key to getting an UnbondingDelegation from state.
type DVPair struct {
DelegatorAddr sdk.AccAddress
ValidatorAddr sdk.ValAddress
DelegatorAddress sdk.AccAddress
ValidatorAddress sdk.ValAddress
}
// DVVTriplet is struct that just has a delegator-validator-validator triplet with no other data.
// It is intended to be used as a marshalable pointer. For example, a DVVTriplet can be used to construct the
// key to getting a Redelegation from state.
type DVVTriplet struct {
DelegatorAddr sdk.AccAddress
ValidatorSrcAddr sdk.ValAddress
ValidatorDstAddr sdk.ValAddress
DelegatorAddress sdk.AccAddress
ValidatorSrcAddress sdk.ValAddress
ValidatorDstAddress sdk.ValAddress
}
// Delegation represents the bond with tokens held by an account. It is
// owned by one delegator, and is associated with the voting power of one
// validator.
type Delegation struct {
DelegatorAddr sdk.AccAddress `json:"delegator_addr"`
ValidatorAddr sdk.ValAddress `json:"validator_addr"`
Shares sdk.Dec `json:"shares"`
DelegatorAddress sdk.AccAddress `json:"delegator_address"`
ValidatorAddress sdk.ValAddress `json:"validator_address"`
Shares sdk.Dec `json:"shares"`
}
// NewDelegation creates a new delegation object
@ -41,9 +41,9 @@ func NewDelegation(delegatorAddr sdk.AccAddress, validatorAddr sdk.ValAddress,
shares sdk.Dec) Delegation {
return Delegation{
DelegatorAddr: delegatorAddr,
ValidatorAddr: validatorAddr,
Shares: shares,
DelegatorAddress: delegatorAddr,
ValidatorAddress: validatorAddr,
Shares: shares,
}
}
@ -69,8 +69,8 @@ func UnmarshalDelegation(cdc *codec.Codec, value []byte) (delegation Delegation,
// nolint
func (d Delegation) Equal(d2 Delegation) bool {
return bytes.Equal(d.DelegatorAddr, d2.DelegatorAddr) &&
bytes.Equal(d.ValidatorAddr, d2.ValidatorAddr) &&
return bytes.Equal(d.DelegatorAddress, d2.DelegatorAddress) &&
bytes.Equal(d.ValidatorAddress, d2.ValidatorAddress) &&
d.Shares.Equal(d2.Shares)
}
@ -78,8 +78,8 @@ func (d Delegation) Equal(d2 Delegation) bool {
var _ sdk.Delegation = Delegation{}
// nolint - for sdk.Delegation
func (d Delegation) GetDelegatorAddr() sdk.AccAddress { return d.DelegatorAddr }
func (d Delegation) GetValidatorAddr() sdk.ValAddress { return d.ValidatorAddr }
func (d Delegation) GetDelegatorAddr() sdk.AccAddress { return d.DelegatorAddress }
func (d Delegation) GetValidatorAddr() sdk.ValAddress { return d.ValidatorAddress }
func (d Delegation) GetShares() sdk.Dec { return d.Shares }
// String returns a human readable string representation of a Delegation.
@ -87,8 +87,8 @@ func (d Delegation) String() string {
return fmt.Sprintf(`Delegation:
Delegator: %s
Validator: %s
Shares: %s`, d.DelegatorAddr,
d.ValidatorAddr, d.Shares)
Shares: %s`, d.DelegatorAddress,
d.ValidatorAddress, d.Shares)
}
// Delegations is a collection of delegations
@ -104,9 +104,9 @@ func (d Delegations) String() (out string) {
// UnbondingDelegation stores all of a single delegator's unbonding bonds
// for a single validator in an time-ordered list
type UnbondingDelegation struct {
DelegatorAddr sdk.AccAddress `json:"delegator_addr"` // delegator
ValidatorAddr sdk.ValAddress `json:"validator_addr"` // validator unbonding from operator addr
Entries []UnbondingDelegationEntry `json:"entries"` // unbonding delegation entries
DelegatorAddress sdk.AccAddress `json:"delegator_address"` // delegator
ValidatorAddress sdk.ValAddress `json:"validator_address"` // validator unbonding from operator addr
Entries []UnbondingDelegationEntry `json:"entries"` // unbonding delegation entries
}
// UnbondingDelegationEntry - entry to an UnbondingDelegation
@ -129,9 +129,9 @@ func NewUnbondingDelegation(delegatorAddr sdk.AccAddress,
entry := NewUnbondingDelegationEntry(creationHeight, minTime, balance)
return UnbondingDelegation{
DelegatorAddr: delegatorAddr,
ValidatorAddr: validatorAddr,
Entries: []UnbondingDelegationEntry{entry},
DelegatorAddress: delegatorAddr,
ValidatorAddress: validatorAddr,
Entries: []UnbondingDelegationEntry{entry},
}
}
@ -193,7 +193,7 @@ func (d UnbondingDelegation) String() string {
out := fmt.Sprintf(`Unbonding Delegations between:
Delegator: %s
Validator: %s
Entries:`, d.DelegatorAddr, d.ValidatorAddr)
Entries:`, d.DelegatorAddress, d.ValidatorAddress)
for i, entry := range d.Entries {
out += fmt.Sprintf(` Unbonding Delegation %d:
Creation Height: %v
@ -218,10 +218,10 @@ func (ubds UnbondingDelegations) String() (out string) {
// redelegating bonds from a particular source validator to a
// particular destination validator
type Redelegation struct {
DelegatorAddr sdk.AccAddress `json:"delegator_addr"` // delegator
ValidatorSrcAddr sdk.ValAddress `json:"validator_src_addr"` // validator redelegation source operator addr
ValidatorDstAddr sdk.ValAddress `json:"validator_dst_addr"` // validator redelegation destination operator addr
Entries []RedelegationEntry `json:"entries"` // redelegation entries
DelegatorAddress sdk.AccAddress `json:"delegator_address"` // delegator
ValidatorSrcAddress sdk.ValAddress `json:"validator_src_address"` // validator redelegation source operator addr
ValidatorDstAddress sdk.ValAddress `json:"validator_dst_address"` // validator redelegation destination operator addr
Entries []RedelegationEntry `json:"entries"` // redelegation entries
}
// RedelegationEntry - entry to a Redelegation
@ -242,10 +242,10 @@ func NewRedelegation(delegatorAddr sdk.AccAddress, validatorSrcAddr,
minTime, balance, sharesDst)
return Redelegation{
DelegatorAddr: delegatorAddr,
ValidatorSrcAddr: validatorSrcAddr,
ValidatorDstAddr: validatorDstAddr,
Entries: []RedelegationEntry{entry},
DelegatorAddress: delegatorAddr,
ValidatorSrcAddress: validatorSrcAddr,
ValidatorDstAddress: validatorDstAddr,
Entries: []RedelegationEntry{entry},
}
}
@ -315,7 +315,7 @@ func (d Redelegation) String() string {
Delegator: %s
Source Validator: %s
Destination Validator: %s
Entries:`, d.DelegatorAddr, d.ValidatorSrcAddr, d.ValidatorDstAddr)
Entries:`, d.DelegatorAddress, d.ValidatorSrcAddress, d.ValidatorDstAddress)
for i, entry := range d.Entries {
out += fmt.Sprintf(` Redelegation %d:
Creation height: %v

View File

@ -16,7 +16,7 @@ func TestDelegationEqual(t *testing.T) {
ok := d1.Equal(d2)
require.True(t, ok)
d2.ValidatorAddr = addr3
d2.ValidatorAddress = addr3
d2.Shares = sdk.NewDec(200)
ok = d1.Equal(d2)
@ -36,7 +36,7 @@ func TestUnbondingDelegationEqual(t *testing.T) {
ok := ubd1.Equal(ubd2)
require.True(t, ok)
ubd2.ValidatorAddr = addr3
ubd2.ValidatorAddress = addr3
ubd2.Entries[0].CompletionTime = time.Unix(20*20*2, 0)
ok = ubd1.Equal(ubd2)

View File

@ -25,8 +25,8 @@ type MsgCreateValidator struct {
Description Description `json:"description"`
Commission CommissionMsg `json:"commission"`
MinSelfDelegation sdk.Int `json:"min_self_delegation"`
DelegatorAddr sdk.AccAddress `json:"delegator_address"`
ValidatorAddr sdk.ValAddress `json:"validator_address"`
DelegatorAddress sdk.AccAddress `json:"delegator_address"`
ValidatorAddress sdk.ValAddress `json:"validator_address"`
PubKey crypto.PubKey `json:"pubkey"`
Value sdk.Coin `json:"value"`
}
@ -35,8 +35,8 @@ type msgCreateValidatorJSON struct {
Description Description `json:"description"`
Commission CommissionMsg `json:"commission"`
MinSelfDelegation sdk.Int `json:"min_self_delegation"`
DelegatorAddr sdk.AccAddress `json:"delegator_address"`
ValidatorAddr sdk.ValAddress `json:"validator_address"`
DelegatorAddress sdk.AccAddress `json:"delegator_address"`
ValidatorAddress sdk.ValAddress `json:"validator_address"`
PubKey string `json:"pubkey"`
Value sdk.Coin `json:"value"`
}
@ -55,8 +55,8 @@ func NewMsgCreateValidatorOnBehalfOf(delAddr sdk.AccAddress, valAddr sdk.ValAddr
pubkey crypto.PubKey, value sdk.Coin, description Description, commission CommissionMsg, minSelfDelegation sdk.Int) MsgCreateValidator {
return MsgCreateValidator{
Description: description,
DelegatorAddr: delAddr,
ValidatorAddr: valAddr,
DelegatorAddress: delAddr,
ValidatorAddress: valAddr,
PubKey: pubkey,
Value: value,
Commission: commission,
@ -71,12 +71,12 @@ func (msg MsgCreateValidator) Type() string { return "create_validator" }
// Return address(es) that must sign over msg.GetSignBytes()
func (msg MsgCreateValidator) GetSigners() []sdk.AccAddress {
// delegator is first signer so delegator pays fees
addrs := []sdk.AccAddress{msg.DelegatorAddr}
addrs := []sdk.AccAddress{msg.DelegatorAddress}
if !bytes.Equal(msg.DelegatorAddr.Bytes(), msg.ValidatorAddr.Bytes()) {
if !bytes.Equal(msg.DelegatorAddress.Bytes(), msg.ValidatorAddress.Bytes()) {
// if validator addr is not same as delegator addr, validator must sign
// msg as well
addrs = append(addrs, sdk.AccAddress(msg.ValidatorAddr))
addrs = append(addrs, sdk.AccAddress(msg.ValidatorAddress))
}
return addrs
}
@ -87,8 +87,8 @@ func (msg MsgCreateValidator) MarshalJSON() ([]byte, error) {
return json.Marshal(msgCreateValidatorJSON{
Description: msg.Description,
Commission: msg.Commission,
DelegatorAddr: msg.DelegatorAddr,
ValidatorAddr: msg.ValidatorAddr,
DelegatorAddress: msg.DelegatorAddress,
ValidatorAddress: msg.ValidatorAddress,
PubKey: sdk.MustBech32ifyConsPub(msg.PubKey),
Value: msg.Value,
MinSelfDelegation: msg.MinSelfDelegation,
@ -105,8 +105,8 @@ func (msg *MsgCreateValidator) UnmarshalJSON(bz []byte) error {
msg.Description = msgCreateValJSON.Description
msg.Commission = msgCreateValJSON.Commission
msg.DelegatorAddr = msgCreateValJSON.DelegatorAddr
msg.ValidatorAddr = msgCreateValJSON.ValidatorAddr
msg.DelegatorAddress = msgCreateValJSON.DelegatorAddress
msg.ValidatorAddress = msgCreateValJSON.ValidatorAddress
msg.PubKey = sdk.MustGetConsPubKeyBech32(msgCreateValJSON.PubKey)
msg.Value = msgCreateValJSON.Value
msg.MinSelfDelegation = msgCreateValJSON.MinSelfDelegation
@ -123,10 +123,10 @@ func (msg MsgCreateValidator) GetSignBytes() []byte {
// quick validity check
func (msg MsgCreateValidator) ValidateBasic() sdk.Error {
// note that unmarshaling from bech32 ensures either empty or valid
if msg.DelegatorAddr.Empty() {
if msg.DelegatorAddress.Empty() {
return ErrNilDelegatorAddr(DefaultCodespace)
}
if msg.ValidatorAddr.Empty() {
if msg.ValidatorAddress.Empty() {
return ErrNilValidatorAddr(DefaultCodespace)
}
if msg.Value.Amount.LTE(sdk.ZeroInt()) {
@ -151,7 +151,7 @@ func (msg MsgCreateValidator) ValidateBasic() sdk.Error {
// MsgEditValidator - struct for editing a validator
type MsgEditValidator struct {
Description
ValidatorAddr sdk.ValAddress `json:"address"`
ValidatorAddress sdk.ValAddress `json:"address"`
// We pass a reference to the new commission rate and min self delegation as it's not mandatory to
// update. If not updated, the deserialized rate will be zero with no way to
@ -166,7 +166,7 @@ func NewMsgEditValidator(valAddr sdk.ValAddress, description Description, newRat
return MsgEditValidator{
Description: description,
CommissionRate: newRate,
ValidatorAddr: valAddr,
ValidatorAddress: valAddr,
MinSelfDelegation: newMinSelfDelegation,
}
}
@ -175,7 +175,7 @@ func NewMsgEditValidator(valAddr sdk.ValAddress, description Description, newRat
func (msg MsgEditValidator) Route() string { return RouterKey }
func (msg MsgEditValidator) Type() string { return "edit_validator" }
func (msg MsgEditValidator) GetSigners() []sdk.AccAddress {
return []sdk.AccAddress{sdk.AccAddress(msg.ValidatorAddr)}
return []sdk.AccAddress{sdk.AccAddress(msg.ValidatorAddress)}
}
// get the bytes for the message signer to sign on
@ -186,7 +186,7 @@ func (msg MsgEditValidator) GetSignBytes() []byte {
// quick validity check
func (msg MsgEditValidator) ValidateBasic() sdk.Error {
if msg.ValidatorAddr.Empty() {
if msg.ValidatorAddress.Empty() {
return sdk.NewError(DefaultCodespace, CodeInvalidInput, "nil validator address")
}
@ -209,16 +209,16 @@ func (msg MsgEditValidator) ValidateBasic() sdk.Error {
// MsgDelegate - struct for bonding transactions
type MsgDelegate struct {
DelegatorAddr sdk.AccAddress `json:"delegator_addr"`
ValidatorAddr sdk.ValAddress `json:"validator_addr"`
Value sdk.Coin `json:"value"`
DelegatorAddress sdk.AccAddress `json:"delegator_address"`
ValidatorAddress sdk.ValAddress `json:"validator_address"`
Value sdk.Coin `json:"value"`
}
func NewMsgDelegate(delAddr sdk.AccAddress, valAddr sdk.ValAddress, value sdk.Coin) MsgDelegate {
return MsgDelegate{
DelegatorAddr: delAddr,
ValidatorAddr: valAddr,
Value: value,
DelegatorAddress: delAddr,
ValidatorAddress: valAddr,
Value: value,
}
}
@ -226,7 +226,7 @@ func NewMsgDelegate(delAddr sdk.AccAddress, valAddr sdk.ValAddress, value sdk.Co
func (msg MsgDelegate) Route() string { return RouterKey }
func (msg MsgDelegate) Type() string { return "delegate" }
func (msg MsgDelegate) GetSigners() []sdk.AccAddress {
return []sdk.AccAddress{msg.DelegatorAddr}
return []sdk.AccAddress{msg.DelegatorAddress}
}
// get the bytes for the message signer to sign on
@ -237,10 +237,10 @@ func (msg MsgDelegate) GetSignBytes() []byte {
// quick validity check
func (msg MsgDelegate) ValidateBasic() sdk.Error {
if msg.DelegatorAddr.Empty() {
if msg.DelegatorAddress.Empty() {
return ErrNilDelegatorAddr(DefaultCodespace)
}
if msg.ValidatorAddr.Empty() {
if msg.ValidatorAddress.Empty() {
return ErrNilValidatorAddr(DefaultCodespace)
}
if msg.Value.Amount.LTE(sdk.ZeroInt()) {
@ -253,20 +253,20 @@ func (msg MsgDelegate) ValidateBasic() sdk.Error {
// MsgDelegate - struct for bonding transactions
type MsgBeginRedelegate struct {
DelegatorAddr sdk.AccAddress `json:"delegator_addr"`
ValidatorSrcAddr sdk.ValAddress `json:"validator_src_addr"`
ValidatorDstAddr sdk.ValAddress `json:"validator_dst_addr"`
SharesAmount sdk.Dec `json:"shares_amount"`
DelegatorAddress sdk.AccAddress `json:"delegator_address"`
ValidatorSrcAddress sdk.ValAddress `json:"validator_src_address"`
ValidatorDstAddress sdk.ValAddress `json:"validator_dst_address"`
SharesAmount sdk.Dec `json:"shares_amount"`
}
func NewMsgBeginRedelegate(delAddr sdk.AccAddress, valSrcAddr,
valDstAddr sdk.ValAddress, sharesAmount sdk.Dec) MsgBeginRedelegate {
return MsgBeginRedelegate{
DelegatorAddr: delAddr,
ValidatorSrcAddr: valSrcAddr,
ValidatorDstAddr: valDstAddr,
SharesAmount: sharesAmount,
DelegatorAddress: delAddr,
ValidatorSrcAddress: valSrcAddr,
ValidatorDstAddress: valDstAddr,
SharesAmount: sharesAmount,
}
}
@ -274,7 +274,7 @@ func NewMsgBeginRedelegate(delAddr sdk.AccAddress, valSrcAddr,
func (msg MsgBeginRedelegate) Route() string { return RouterKey }
func (msg MsgBeginRedelegate) Type() string { return "begin_redelegate" }
func (msg MsgBeginRedelegate) GetSigners() []sdk.AccAddress {
return []sdk.AccAddress{msg.DelegatorAddr}
return []sdk.AccAddress{msg.DelegatorAddress}
}
// get the bytes for the message signer to sign on
@ -285,13 +285,13 @@ func (msg MsgBeginRedelegate) GetSignBytes() []byte {
// quick validity check
func (msg MsgBeginRedelegate) ValidateBasic() sdk.Error {
if msg.DelegatorAddr.Empty() {
if msg.DelegatorAddress.Empty() {
return ErrNilDelegatorAddr(DefaultCodespace)
}
if msg.ValidatorSrcAddr.Empty() {
if msg.ValidatorSrcAddress.Empty() {
return ErrNilValidatorAddr(DefaultCodespace)
}
if msg.ValidatorDstAddr.Empty() {
if msg.ValidatorDstAddress.Empty() {
return ErrNilValidatorAddr(DefaultCodespace)
}
if msg.SharesAmount.LTE(sdk.ZeroDec()) {
@ -302,23 +302,23 @@ func (msg MsgBeginRedelegate) ValidateBasic() sdk.Error {
// MsgUndelegate - struct for unbonding transactions
type MsgUndelegate struct {
DelegatorAddr sdk.AccAddress `json:"delegator_addr"`
ValidatorAddr sdk.ValAddress `json:"validator_addr"`
SharesAmount sdk.Dec `json:"shares_amount"`
DelegatorAddress sdk.AccAddress `json:"delegator_address"`
ValidatorAddress sdk.ValAddress `json:"validator_address"`
SharesAmount sdk.Dec `json:"shares_amount"`
}
func NewMsgUndelegate(delAddr sdk.AccAddress, valAddr sdk.ValAddress, sharesAmount sdk.Dec) MsgUndelegate {
return MsgUndelegate{
DelegatorAddr: delAddr,
ValidatorAddr: valAddr,
SharesAmount: sharesAmount,
DelegatorAddress: delAddr,
ValidatorAddress: valAddr,
SharesAmount: sharesAmount,
}
}
//nolint
func (msg MsgUndelegate) Route() string { return RouterKey }
func (msg MsgUndelegate) Type() string { return "begin_unbonding" }
func (msg MsgUndelegate) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{msg.DelegatorAddr} }
func (msg MsgUndelegate) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{msg.DelegatorAddress} }
// get the bytes for the message signer to sign on
func (msg MsgUndelegate) GetSignBytes() []byte {
@ -328,10 +328,10 @@ func (msg MsgUndelegate) GetSignBytes() []byte {
// quick validity check
func (msg MsgUndelegate) ValidateBasic() sdk.Error {
if msg.DelegatorAddr.Empty() {
if msg.DelegatorAddress.Empty() {
return ErrNilDelegatorAddr(DefaultCodespace)
}
if msg.ValidatorAddr.Empty() {
if msg.ValidatorAddress.Empty() {
return ErrNilValidatorAddr(DefaultCodespace)
}
if msg.SharesAmount.LTE(sdk.ZeroDec()) {

View File

@ -31,7 +31,7 @@ const (
// divided by the current exchange rate. Voting power can be calculated as total
// bonded shares multiplied by exchange rate.
type Validator struct {
OperatorAddr sdk.ValAddress `json:"operator_address"` // address of the validator's operator; bech encoded in JSON
OperatorAddress sdk.ValAddress `json:"operator_address"` // address of the validator's operator; bech encoded in JSON
ConsPubKey crypto.PubKey `json:"consensus_pubkey"` // the consensus public key of the validator; bech encoded in JSON
Jailed bool `json:"jailed"` // has the validator been jailed from bonded status?
Status sdk.BondStatus `json:"status"` // validator status (bonded/unbonding/unbonded)
@ -65,7 +65,7 @@ func (v Validators) ToSDKValidators() (validators []sdk.Validator) {
// NewValidator - initialize a new validator
func NewValidator(operator sdk.ValAddress, pubKey crypto.PubKey, description Description) Validator {
return Validator{
OperatorAddr: operator,
OperatorAddress: operator,
ConsPubKey: pubKey,
Jailed: false,
Status: sdk.Unbonded,
@ -116,7 +116,7 @@ func (v Validator) String() string {
Unbonding Height: %d
Unbonding Completion Time: %v
Minimum Self Delegation: %v
Commission: %s`, v.OperatorAddr, bechConsPubKey,
Commission: %s`, v.OperatorAddress, bechConsPubKey,
v.Jailed, sdk.BondStatusToString(v.Status), v.Tokens,
v.DelegatorShares, v.Description,
v.UnbondingHeight, v.UnbondingCompletionTime, v.MinSelfDelegation, v.Commission)
@ -124,7 +124,7 @@ func (v Validator) String() string {
// this is a helper struct used for JSON de- and encoding only
type bechValidator struct {
OperatorAddr sdk.ValAddress `json:"operator_address"` // the bech32 address of the validator's operator
OperatorAddress sdk.ValAddress `json:"operator_address"` // the bech32 address of the validator's operator
ConsPubKey string `json:"consensus_pubkey"` // the bech32 consensus public key of the validator
Jailed bool `json:"jailed"` // has the validator been jailed from bonded status?
Status sdk.BondStatus `json:"status"` // validator status (bonded/unbonding/unbonded)
@ -145,7 +145,7 @@ func (v Validator) MarshalJSON() ([]byte, error) {
}
return codec.Cdc.MarshalJSON(bechValidator{
OperatorAddr: v.OperatorAddr,
OperatorAddress: v.OperatorAddress,
ConsPubKey: bechConsPubKey,
Jailed: v.Jailed,
Status: v.Status,
@ -170,7 +170,7 @@ func (v *Validator) UnmarshalJSON(data []byte) error {
return err
}
*v = Validator{
OperatorAddr: bv.OperatorAddr,
OperatorAddress: bv.OperatorAddress,
ConsPubKey: consPubKey,
Jailed: bv.Jailed,
Tokens: bv.Tokens,
@ -188,7 +188,7 @@ func (v *Validator) UnmarshalJSON(data []byte) error {
// only the vitals
func (v Validator) TestEquivalent(v2 Validator) bool {
return v.ConsPubKey.Equals(v2.ConsPubKey) &&
bytes.Equal(v.OperatorAddr, v2.OperatorAddr) &&
bytes.Equal(v.OperatorAddress, v2.OperatorAddress) &&
v.Status.Equal(v2.Status) &&
v.Tokens.Equal(v2.Tokens) &&
v.DelegatorShares.Equal(v2.DelegatorShares) &&
@ -436,7 +436,7 @@ var _ sdk.Validator = Validator{}
func (v Validator) GetJailed() bool { return v.Jailed }
func (v Validator) GetMoniker() string { return v.Description.Moniker }
func (v Validator) GetStatus() sdk.BondStatus { return v.Status }
func (v Validator) GetOperator() sdk.ValAddress { return v.OperatorAddr }
func (v Validator) GetOperator() sdk.ValAddress { return v.OperatorAddress }
func (v Validator) GetConsPubKey() crypto.PubKey { return v.ConsPubKey }
func (v Validator) GetConsAddr() sdk.ConsAddress { return sdk.ConsAddress(v.ConsPubKey.Address()) }
func (v Validator) GetTokens() sdk.Int { return v.Tokens }

View File

@ -73,7 +73,7 @@ func TestABCIValidatorUpdateZero(t *testing.T) {
func TestRemoveTokens(t *testing.T) {
validator := Validator{
OperatorAddr: addr1,
OperatorAddress: addr1,
ConsPubKey: pk1,
Status: sdk.Bonded,
Tokens: sdk.NewInt(100),
@ -149,7 +149,7 @@ func TestAddTokensValidatorUnbonded(t *testing.T) {
// TODO refactor to make simpler like the AddToken tests above
func TestRemoveDelShares(t *testing.T) {
valA := Validator{
OperatorAddr: addr1,
OperatorAddress: addr1,
ConsPubKey: pk1,
Status: sdk.Bonded,
Tokens: sdk.NewInt(100),
@ -177,7 +177,7 @@ func TestRemoveDelShares(t *testing.T) {
poolTokens := sdk.NewInt(5102)
delShares := sdk.NewDec(115)
validator := Validator{
OperatorAddr: addr1,
OperatorAddress: addr1,
ConsPubKey: pk1,
Status: sdk.Bonded,
Tokens: poolTokens,
@ -225,7 +225,7 @@ func TestPossibleOverflow(t *testing.T) {
poolTokens := sdk.NewInt(2159)
delShares := sdk.NewDec(391432570689183511).Quo(sdk.NewDec(40113011844664))
validator := Validator{
OperatorAddr: addr1,
OperatorAddress: addr1,
ConsPubKey: pk1,
Status: sdk.Bonded,
Tokens: poolTokens,