* change abci file to use BinaryBare * change all calls to EncodeLengthPrefixed to BinaryBare in distribution keeper store. * change all calls to EncodeLengthPrefixed to BinaryBare in mint keeper store. * change all calls to EncodeLengthPrefixed to BinaryBare in auth keeper store. * change all calls to EncodeLengthPrefixed to BinaryBare in distribution keeper store. * change all calls to EncodeLengthPrefixed to BinaryBare in staking keeper store. * change all calls to EncodeLengthPrefixed to BinaryBare in staking keeper store. * change all calls to EncodeLengthPrefixed to BinaryBare in gov keeper store. * change all calls to EncodeLengthPrefixed to BinaryBare in slashing keeper store. * update decoder test * migrate decoder * migrate gov simulation decoder * migrate baseapp_test * refactor QuerySubspace * refactor coedc std codec * migrate keybase * migrate iavl store * migrate root multi * migrate ante basic * migrate tx type to bare * migrate auth client * update auth types * update decoder * migrate supply decoder * migrate stake encoding * migrate staking simulation * migrate genutil * migrate simapp test helpers * migrate docs * upgrade changelog * Update CHANGELOG.md Co-Authored-By: Alexander Bezobchuk <alexanderbez@users.noreply.github.com> Co-authored-by: Alexander Bezobchuk <alexanderbez@users.noreply.github.com>
58 lines
2.1 KiB
Go
58 lines
2.1 KiB
Go
package simulation
|
|
|
|
import (
|
|
"bytes"
|
|
"fmt"
|
|
|
|
tmkv "github.com/tendermint/tendermint/libs/kv"
|
|
|
|
"github.com/cosmos/cosmos-sdk/codec"
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
"github.com/cosmos/cosmos-sdk/x/staking/types"
|
|
)
|
|
|
|
// DecodeStore unmarshals the KVPair's Value to the corresponding staking type
|
|
func DecodeStore(cdc *codec.Codec, kvA, kvB tmkv.Pair) string {
|
|
switch {
|
|
case bytes.Equal(kvA.Key[:1], types.LastTotalPowerKey):
|
|
var powerA, powerB sdk.Int
|
|
cdc.MustUnmarshalBinaryBare(kvA.Value, &powerA)
|
|
cdc.MustUnmarshalBinaryBare(kvB.Value, &powerB)
|
|
return fmt.Sprintf("%v\n%v", powerA, powerB)
|
|
|
|
case bytes.Equal(kvA.Key[:1], types.ValidatorsKey):
|
|
var validatorA, validatorB types.Validator
|
|
cdc.MustUnmarshalBinaryBare(kvA.Value, &validatorA)
|
|
cdc.MustUnmarshalBinaryBare(kvB.Value, &validatorB)
|
|
return fmt.Sprintf("%v\n%v", validatorA, validatorB)
|
|
|
|
case bytes.Equal(kvA.Key[:1], types.LastValidatorPowerKey),
|
|
bytes.Equal(kvA.Key[:1], types.ValidatorsByConsAddrKey),
|
|
bytes.Equal(kvA.Key[:1], types.ValidatorsByPowerIndexKey):
|
|
return fmt.Sprintf("%v\n%v", sdk.ValAddress(kvA.Value), sdk.ValAddress(kvB.Value))
|
|
|
|
case bytes.Equal(kvA.Key[:1], types.DelegationKey):
|
|
var delegationA, delegationB types.Delegation
|
|
cdc.MustUnmarshalBinaryBare(kvA.Value, &delegationA)
|
|
cdc.MustUnmarshalBinaryBare(kvB.Value, &delegationB)
|
|
return fmt.Sprintf("%v\n%v", delegationA, delegationB)
|
|
|
|
case bytes.Equal(kvA.Key[:1], types.UnbondingDelegationKey),
|
|
bytes.Equal(kvA.Key[:1], types.UnbondingDelegationByValIndexKey):
|
|
var ubdA, ubdB types.UnbondingDelegation
|
|
cdc.MustUnmarshalBinaryBare(kvA.Value, &ubdA)
|
|
cdc.MustUnmarshalBinaryBare(kvB.Value, &ubdB)
|
|
return fmt.Sprintf("%v\n%v", ubdA, ubdB)
|
|
|
|
case bytes.Equal(kvA.Key[:1], types.RedelegationKey),
|
|
bytes.Equal(kvA.Key[:1], types.RedelegationByValSrcIndexKey):
|
|
var redA, redB types.Redelegation
|
|
cdc.MustUnmarshalBinaryBare(kvA.Value, &redA)
|
|
cdc.MustUnmarshalBinaryBare(kvB.Value, &redB)
|
|
return fmt.Sprintf("%v\n%v", redA, redB)
|
|
|
|
default:
|
|
panic(fmt.Sprintf("invalid staking key prefix %X", kvA.Key[:1]))
|
|
}
|
|
}
|