cosmos-sdk/x/mint/simulation/decoder.go

28 lines
743 B
Go

package simulation
import (
"bytes"
"fmt"
tmkv "github.com/tendermint/tendermint/libs/kv"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/x/mint/types"
)
// NewDecodeStore returns a decoder function closure that umarshals the KVPair's
// Value to the corresponding mint type.
func NewDecodeStore(cdc codec.Marshaler) func(kvA, kvB tmkv.Pair) string {
return func(kvA, kvB tmkv.Pair) string {
switch {
case bytes.Equal(kvA.Key, types.MinterKey):
var minterA, minterB types.Minter
cdc.MustUnmarshalBinaryBare(kvA.Value, &minterA)
cdc.MustUnmarshalBinaryBare(kvB.Value, &minterB)
return fmt.Sprintf("%v\n%v", minterA, minterB)
default:
panic(fmt.Sprintf("invalid mint key %X", kvA.Key))
}
}
}