Co-authored-by: Amaury <1293565+amaurym@users.noreply.github.com> Co-authored-by: Likhita Polavarapu <78951027+likhita-809@users.noreply.github.com>
27 lines
712 B
Go
27 lines
712 B
Go
package simulation
|
|
|
|
import (
|
|
"bytes"
|
|
"fmt"
|
|
|
|
"cosmossdk.io/x/feegrant"
|
|
"github.com/cosmos/cosmos-sdk/codec"
|
|
"github.com/cosmos/cosmos-sdk/types/kv"
|
|
)
|
|
|
|
// NewDecodeStore returns a decoder function closure that unmarshals the KVPair's
|
|
// Value to the corresponding feegrant type.
|
|
func NewDecodeStore(cdc codec.Codec) func(kvA, kvB kv.Pair) string {
|
|
return func(kvA, kvB kv.Pair) string {
|
|
switch {
|
|
case bytes.Equal(kvA.Key[:1], feegrant.FeeAllowanceKeyPrefix):
|
|
var grantA, grantB feegrant.Grant
|
|
cdc.MustUnmarshal(kvA.Value, &grantA)
|
|
cdc.MustUnmarshal(kvB.Value, &grantB)
|
|
return fmt.Sprintf("%v\n%v", grantA, grantB)
|
|
default:
|
|
panic(fmt.Sprintf("invalid feegrant key %X", kvA.Key))
|
|
}
|
|
}
|
|
}
|