forked from cosmos/cosmos-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
decoder.go
26 lines (23 loc) · 751 Bytes
/
decoder.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package simulation
import (
"bytes"
"fmt"
"github.com/JaTochNietDan/cosmos-sdk/codec"
"github.com/JaTochNietDan/cosmos-sdk/types/kv"
"github.com/JaTochNietDan/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 kv.Pair) string {
return func(kvA, kvB kv.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))
}
}
}