* codec: Rename codec and marshaler interfaces, ref: 8413 * codec: remove BinaryBare * changelog update * Update comments and documentation * adding doc string comments * Update CHANGELOG.md Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com> * Update codec/codec.go Co-authored-by: Marko <marbar3778@yahoo.com> Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com> Co-authored-by: Amaury <1293565+amaurym@users.noreply.github.com> Co-authored-by: Marko <marbar3778@yahoo.com>
27 lines
718 B
Go
27 lines
718 B
Go
package simulation
|
|
|
|
import (
|
|
"bytes"
|
|
"fmt"
|
|
|
|
"github.com/cosmos/cosmos-sdk/codec"
|
|
"github.com/cosmos/cosmos-sdk/types/kv"
|
|
"github.com/cosmos/cosmos-sdk/x/authz/types"
|
|
)
|
|
|
|
// NewDecodeStore returns a decoder function closure that umarshals the KVPair's
|
|
// Value to the corresponding authz 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], types.GrantKey):
|
|
var grantA, grantB types.AuthorizationGrant
|
|
cdc.MustUnmarshal(kvA.Value, &grantA)
|
|
cdc.MustUnmarshal(kvB.Value, &grantB)
|
|
return fmt.Sprintf("%v\n%v", grantA, grantB)
|
|
default:
|
|
panic(fmt.Sprintf("invalid authz key %X", kvA.Key))
|
|
}
|
|
}
|
|
}
|