diff --git a/x/attribute/keeper/params.go b/x/attribute/keeper/params.go index 4a11661564..5bf88c49bf 100644 --- a/x/attribute/keeper/params.go +++ b/x/attribute/keeper/params.go @@ -6,23 +6,34 @@ import ( "github.com/provenance-io/provenance/x/attribute/types" ) -// GetParams returns the total set of account parameters. +// GetParams returns the attribute Params. func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) { - return types.Params{ - MaxValueLength: k.GetMaxValueLength(ctx), + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.AttributeParamPrefix) + if bz == nil { + return types.Params{ + MaxValueLength: types.DefaultMaxValueLength, + } } + err := k.cdc.Unmarshal(bz, ¶ms) + if err != nil { + panic(err) + } + return params } -// SetParams sets the account parameters to the param space. +// SetParams sets the account parameters to the param store. func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { - k.paramSpace.SetParamSet(ctx, ¶ms) + bz, err := k.cdc.Marshal(¶ms) + if err != nil { + panic(err) + } + + store := ctx.KVStore(k.storeKey) + store.Set(types.AttributeParamPrefix, bz) } -// GetMaxValueLength returns the current distribution community tax (or default if unset) +// GetMaxValueLength returns the max value for attribute length. func (k Keeper) GetMaxValueLength(ctx sdk.Context) (maxValueLength uint32) { - maxValueLength = types.DefaultMaxValueLength - if k.paramSpace.Has(ctx, types.ParamStoreKeyMaxValueLength) { - k.paramSpace.Get(ctx, types.ParamStoreKeyMaxValueLength, &maxValueLength) - } - return + return k.GetParams(ctx).MaxValueLength } diff --git a/x/attribute/types/keys.go b/x/attribute/types/keys.go index 3b61a12962..e80ef2f642 100644 --- a/x/attribute/types/keys.go +++ b/x/attribute/types/keys.go @@ -31,6 +31,7 @@ var ( AttributeKeyPrefix = []byte{0x02} AttributeAddrLookupKeyPrefix = []byte{0x03} AttributeExpirationKeyPrefix = []byte{0x04} + AttributeParamPrefix = []byte{0x05} ) // AddrAttributeKey creates a key for an account attribute