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"
|
2020-02-24 08:05:21 -08:00
|
|
|
"github.com/cosmos/cosmos-sdk/x/mint/types"
|
2019-08-13 15:16:03 -07:00
|
|
|
)
|
|
|
|
|
2020-04-21 14:33:56 -07:00
|
|
|
// 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))
|
|
|
|
}
|
2019-08-13 15:16:03 -07:00
|
|
|
}
|
|
|
|
}
|