diff --git a/app/upgrades.go b/app/upgrades.go index d1dbf5fa8f..9d462ae576 100644 --- a/app/upgrades.go +++ b/app/upgrades.go @@ -18,6 +18,7 @@ import ( attributetypes "github.com/provenance-io/provenance/x/attribute/types" markertypes "github.com/provenance-io/provenance/x/marker/types" metadatatypes "github.com/provenance-io/provenance/x/metadata/types" + nametypes "github.com/provenance-io/provenance/x/name/types" ) // appUpgrade is an internal structure for defining all things for an upgrade. @@ -396,3 +397,34 @@ func migrateMetadataOSLocatorParams(ctx sdk.Context, app *App) { ctx.Logger().Info("Done migrating metadata os locator params.") } + +// migrateNameParams migrates to new Name Params store +// TODO: Remove with the umber handlers. +func migrateNameParams(ctx sdk.Context, app *App) { + ctx.Logger().Info("Migrating name params.") + nameParamSpace := app.ParamsKeeper.Subspace(nametypes.ModuleName) + + params := nametypes.DefaultParams() + + // TODO: all param keys from types/params with the umber handlers. + if nameParamSpace.Has(ctx, nametypes.ParamStoreKeyMaxNameLevels) { + nameParamSpace.Get(ctx, nametypes.ParamStoreKeyMaxNameLevels, ¶ms.MaxNameLevels) + } + + if nameParamSpace.Has(ctx, nametypes.ParamStoreKeyMaxSegmentLength) { + nameParamSpace.Get(ctx, nametypes.ParamStoreKeyMaxSegmentLength, ¶ms.MaxSegmentLength) + } + + if nameParamSpace.Has(ctx, nametypes.ParamStoreKeyMinSegmentLength) { + nameParamSpace.Get(ctx, nametypes.ParamStoreKeyMinSegmentLength, ¶ms.MinSegmentLength) + } + + if nameParamSpace.Has(ctx, nametypes.ParamStoreKeyAllowUnrestrictedNames) { + nameParamSpace.Get(ctx, nametypes.ParamStoreKeyAllowUnrestrictedNames, ¶ms.AllowUnrestrictedNames) + } + + // Set migrated params in the new store + app.NameKeeper.SetParams(ctx, params) + + ctx.Logger().Info("Done migrating name params.") +} diff --git a/x/name/types/params.go b/x/name/types/params.go index b267f7d141..9e100756b8 100644 --- a/x/name/types/params.go +++ b/x/name/types/params.go @@ -15,6 +15,7 @@ const ( ) // Parameter store keys +// TODO: remove with the umber (v1.19.x) handlers. var ( // maximum length of name segment to allow ParamStoreKeyMaxSegmentLength = []byte("MaxSegmentLength") @@ -27,6 +28,7 @@ var ( ) // ParamKeyTable for slashing module +// TODO: remove with the umber (v1.19.x) handlers. func ParamKeyTable() paramtypes.KeyTable { return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) } @@ -47,6 +49,7 @@ func NewParams( } // ParamSetPairs - Implements params.ParamSet +// TODO: remove with the umber (v1.19.x) handlers. func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { return paramtypes.ParamSetPairs{ paramtypes.NewParamSetPair(ParamStoreKeyMaxSegmentLength, &p.MaxSegmentLength, validateIntParam),