2019-08-13 15:16:03 -07:00
|
|
|
package simulation
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
"fmt"
|
|
|
|
|
2020-01-16 13:46:51 -08:00
|
|
|
tmkv "github.com/tendermint/tendermint/libs/kv"
|
2019-08-13 15:16:03 -07:00
|
|
|
|
|
|
|
"github.com/cosmos/cosmos-sdk/codec"
|
|
|
|
"github.com/cosmos/cosmos-sdk/x/auth/exported"
|
|
|
|
"github.com/cosmos/cosmos-sdk/x/auth/types"
|
|
|
|
)
|
|
|
|
|
|
|
|
// DecodeStore unmarshals the KVPair's Value to the corresponding auth type
|
2020-01-16 13:46:51 -08:00
|
|
|
func DecodeStore(cdc *codec.Codec, kvA, kvB tmkv.Pair) string {
|
2019-08-13 15:16:03 -07:00
|
|
|
switch {
|
|
|
|
case bytes.Equal(kvA.Key[:1], types.AddressStoreKeyPrefix):
|
|
|
|
var accA, accB exported.Account
|
|
|
|
cdc.MustUnmarshalBinaryBare(kvA.Value, &accA)
|
|
|
|
cdc.MustUnmarshalBinaryBare(kvB.Value, &accB)
|
|
|
|
return fmt.Sprintf("%v\n%v", accA, accB)
|
2020-02-18 04:50:13 -08:00
|
|
|
|
2019-08-13 15:16:03 -07:00
|
|
|
case bytes.Equal(kvA.Key, types.GlobalAccountNumberKey):
|
|
|
|
var globalAccNumberA, globalAccNumberB uint64
|
2020-03-13 12:58:43 -07:00
|
|
|
cdc.MustUnmarshalBinaryBare(kvA.Value, &globalAccNumberA)
|
|
|
|
cdc.MustUnmarshalBinaryBare(kvB.Value, &globalAccNumberB)
|
2019-08-13 15:16:03 -07:00
|
|
|
return fmt.Sprintf("GlobalAccNumberA: %d\nGlobalAccNumberB: %d", globalAccNumberA, globalAccNumberB)
|
2020-02-18 04:50:13 -08:00
|
|
|
|
2019-08-13 15:16:03 -07:00
|
|
|
default:
|
|
|
|
panic(fmt.Sprintf("invalid account key %X", kvA.Key))
|
|
|
|
}
|
|
|
|
}
|