Skip to content

Commit

Permalink
start migration of os params, remove empty param keeper
Browse files Browse the repository at this point in the history
  • Loading branch information
nullpointer0x00 committed Apr 15, 2024
1 parent 14908f1 commit 18d8c06
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 49 deletions.
3 changes: 1 addition & 2 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ func New(
)

app.MetadataKeeper = metadatakeeper.NewKeeper(
appCodec, keys[metadatatypes.StoreKey], app.GetSubspace(metadatatypes.ModuleName), app.AccountKeeper, app.AuthzKeeper, app.AttributeKeeper, app.MarkerKeeper,
appCodec, keys[metadatatypes.StoreKey], app.AccountKeeper, app.AuthzKeeper, app.AttributeKeeper, app.MarkerKeeper,
)

app.HoldKeeper = holdkeeper.NewKeeper(
Expand Down Expand Up @@ -1361,7 +1361,6 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
paramsKeeper.Subspace(govtypes.ModuleName).WithKeyTable(govtypesv1.ParamKeyTable())
paramsKeeper.Subspace(crisistypes.ModuleName)

paramsKeeper.Subspace(metadatatypes.ModuleName) // TODO[1760]: params: Migrate metadata params.
paramsKeeper.Subspace(markertypes.ModuleName) // TODO[1760]: params: Migrate marker params.
paramsKeeper.Subspace(nametypes.ModuleName) // TODO[1760]: params: Migrate name params.
paramsKeeper.Subspace(attributetypes.ModuleName) // TODO[1760]: params: Migrate attribute params.
Expand Down
4 changes: 1 addition & 3 deletions x/metadata/keeper/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (

// InitGenesis creates the initial genesis state for the metadata module.
func (k Keeper) InitGenesis(ctx sdk.Context, data *types.GenesisState) {
k.SetParams(ctx, data.Params)
k.SetOSLocatorParams(ctx, data.OSLocatorParams)
if err := data.Validate(); err != nil {
panic(err)
Expand Down Expand Up @@ -78,7 +77,6 @@ func (k Keeper) InitGenesis(ctx sdk.Context, data *types.GenesisState) {

// ExportGenesis exports the current keeper state of the metadata module.ExportGenesis
func (k Keeper) ExportGenesis(ctx sdk.Context) (data *types.GenesisState) {
params := k.GetParams(ctx)
oslocatorparams := k.GetOSLocatorParams(ctx)
scopes := make([]types.Scope, 0)
sessions := make([]types.Session, 0)
Expand Down Expand Up @@ -163,5 +161,5 @@ func (k Keeper) ExportGenesis(ctx sdk.Context) (data *types.GenesisState) {
markerNetAssetValues[i] = markerNavs
}

return types.NewGenesisState(params, oslocatorparams, scopes, sessions, records, scopeSpecs, contractSpecs, recordSpecs, objectStoreLocators, markerNetAssetValues)
return types.NewGenesisState(types.Params{}, oslocatorparams, scopes, sessions, records, scopeSpecs, contractSpecs, recordSpecs, objectStoreLocators, markerNetAssetValues)
}
15 changes: 4 additions & 11 deletions x/metadata/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (

"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"

"github.com/provenance-io/provenance/x/metadata/types"
)
Expand Down Expand Up @@ -108,9 +107,8 @@ type MetadataKeeperI interface {
// Keeper is the concrete state-based API for the metadata module.
type Keeper struct {
// Key to access the key-value store from sdk.Context
storeKey storetypes.StoreKey
cdc codec.BinaryCodec
paramSpace paramtypes.Subspace
storeKey storetypes.StoreKey
cdc codec.BinaryCodec

// To check if accounts exist and set public keys.
authKeeper AuthKeeper
Expand All @@ -127,17 +125,12 @@ type Keeper struct {

// NewKeeper creates new instances of the metadata Keeper.
func NewKeeper(
cdc codec.BinaryCodec, key storetypes.StoreKey, paramSpace paramtypes.Subspace,
authKeeper AuthKeeper, authzKeeper AuthzKeeper, attrKeeper AttrKeeper, markerKeeper MarkerKeeper,
cdc codec.BinaryCodec, key storetypes.StoreKey, authKeeper AuthKeeper,
authzKeeper AuthzKeeper, attrKeeper AttrKeeper, markerKeeper MarkerKeeper,
) Keeper {
// set KeyTable if it has not already been set
if !paramSpace.HasKeyTable() {
paramSpace = paramSpace.WithKeyTable(types.OSParamKeyTable())
}
return Keeper{
storeKey: key,
cdc: cdc,
paramSpace: paramSpace,
authKeeper: authKeeper,
authzKeeper: authzKeeper,
attrKeeper: attrKeeper,
Expand Down
5 changes: 1 addition & 4 deletions x/metadata/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,7 @@ func ownerPartyList(addresses ...string) []types.Party {
}

func (s *KeeperTestSuite) TestParams() {
s.T().Run("param tests", func(t *testing.T) {
p := s.app.MetadataKeeper.GetParams(s.ctx)
assert.NotNil(t, p)

s.T().Run("os param tests", func(t *testing.T) {
osp := s.app.MetadataKeeper.GetOSLocatorParams(s.ctx)
assert.NotNil(t, osp)
assert.Equal(t, osp.MaxUriLength, s.app.MetadataKeeper.GetMaxURILength(s.ctx))
Expand Down
12 changes: 6 additions & 6 deletions x/metadata/keeper/oslocatorparams.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ func (k Keeper) GetOSLocatorParams(ctx sdk.Context) (osLocatorParams types.OSLoc

// SetParams sets the distribution parameters to the param space.
func (k Keeper) SetOSLocatorParams(ctx sdk.Context, params types.OSLocatorParams) {
k.paramSpace.SetParamSet(ctx, &params)
// k.paramSpace.SetParamSet(ctx, &params)
}

// GetMaxURILength gets the configured parameter for max uri length on a locator record (or the default if unset)
func (k Keeper) GetMaxURILength(ctx sdk.Context) (max uint32) {
max = types.DefaultMaxURILength
if k.paramSpace.Has(ctx, types.ParamStoreKeyMaxValueLength) {
k.paramSpace.Get(ctx, types.ParamStoreKeyMaxValueLength, &max)
}
return
// max = types.DefaultMaxURILength
// if k.paramSpace.Has(ctx, types.ParamStoreKeyMaxValueLength) {
// k.paramSpace.Get(ctx, types.ParamStoreKeyMaxValueLength, &max)
// }
return 0
}
15 changes: 0 additions & 15 deletions x/metadata/keeper/params.go

This file was deleted.

10 changes: 2 additions & 8 deletions x/metadata/keeper/query_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,7 @@ var _ types.QueryServer = Keeper{}
// Params queries params of metadata module.
func (k Keeper) Params(c context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) {
defer telemetry.MeasureSince(time.Now(), types.ModuleName, "query", "Params")
ctx := sdk.UnwrapSDKContext(c)
var params types.Params
k.paramSpace.GetParamSet(ctx, &params)

resp := &types.QueryParamsResponse{Params: params}
resp := &types.QueryParamsResponse{Params: types.Params{}}
if req != nil && req.IncludeRequest {
resp.Request = req
}
Expand Down Expand Up @@ -1046,9 +1042,7 @@ func (k Keeper) GetByAddr(c context.Context, req *types.GetByAddrRequest) (*type
func (k Keeper) OSLocatorParams(c context.Context, request *types.OSLocatorParamsRequest) (*types.OSLocatorParamsResponse, error) {
defer telemetry.MeasureSince(time.Now(), types.ModuleName, "query", "OSLocatorParams")
ctx := sdk.UnwrapSDKContext(c)
var params types.OSLocatorParams
k.paramSpace.GetParamSet(ctx, &params)

params := k.GetOSLocatorParams(ctx)
resp := &types.OSLocatorParamsResponse{Params: params}
if request != nil && request.IncludeRequest {
resp.Request = request
Expand Down

0 comments on commit 18d8c06

Please sign in to comment.