2019-10-01 02:53:14 +00:00
|
|
|
package simulation
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
"fmt"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/cosmos/cosmos-sdk/codec"
|
2020-04-29 14:10:41 +00:00
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
2020-04-23 16:35:58 +00:00
|
|
|
"github.com/tendermint/tendermint/libs/kv"
|
2020-04-30 14:13:31 +00:00
|
|
|
|
|
|
|
"github.com/kava-labs/kava/x/validator-vesting/types"
|
2019-10-01 02:53:14 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// DecodeStore unmarshals the KVPair's Value to the corresponding auth type
|
2020-04-23 16:35:58 +00:00
|
|
|
func DecodeStore(cdc *codec.Codec, kvA, kvB kv.Pair) string {
|
2019-10-01 02:53:14 +00:00
|
|
|
switch {
|
|
|
|
case bytes.Equal(kvA.Key[:1], types.ValidatorVestingAccountPrefix):
|
2020-04-29 14:10:41 +00:00
|
|
|
var accA, accB sdk.AccAddress
|
|
|
|
accA = sdk.AccAddress(kvA.Key[1:])
|
|
|
|
accB = sdk.AccAddress(kvB.Key[1:])
|
2019-10-01 02:53:14 +00:00
|
|
|
return fmt.Sprintf("%v\n%v", accA, accB)
|
|
|
|
case bytes.Equal(kvA.Key, types.BlocktimeKey):
|
|
|
|
var btA, btB time.Time
|
|
|
|
cdc.MustUnmarshalBinaryLengthPrefixed(kvA.Value, &btA)
|
|
|
|
cdc.MustUnmarshalBinaryLengthPrefixed(kvB.Value, &btB)
|
|
|
|
return fmt.Sprintf("%v\n%v", btA, btB)
|
|
|
|
default:
|
2020-04-01 18:36:46 +00:00
|
|
|
panic(fmt.Sprintf("invalid %s key %X", types.ModuleName, kvA.Key))
|
2019-10-01 02:53:14 +00:00
|
|
|
}
|
|
|
|
}
|