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/supply/internal/keeper"
|
|
|
|
"github.com/cosmos/cosmos-sdk/x/supply/internal/types"
|
|
|
|
)
|
|
|
|
|
|
|
|
// DecodeStore unmarshals the KVPair's Value to the corresponding supply 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], keeper.SupplyKey):
|
|
|
|
var supplyA, supplyB types.Supply
|
|
|
|
cdc.MustUnmarshalBinaryLengthPrefixed(kvA.Value, &supplyA)
|
|
|
|
cdc.MustUnmarshalBinaryLengthPrefixed(kvB.Value, &supplyB)
|
|
|
|
return fmt.Sprintf("%v\n%v", supplyB, supplyB)
|
|
|
|
default:
|
|
|
|
panic(fmt.Sprintf("invalid supply key %X", kvA.Key))
|
|
|
|
}
|
|
|
|
}
|