Skip to content

Commit

Permalink
add migration method, add remove todos
Browse files Browse the repository at this point in the history
  • Loading branch information
nullpointer0x00 committed Apr 17, 2024
1 parent 6e5abfe commit d540056
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
32 changes: 32 additions & 0 deletions app/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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, &params.MaxNameLevels)
}

if nameParamSpace.Has(ctx, nametypes.ParamStoreKeyMaxSegmentLength) {
nameParamSpace.Get(ctx, nametypes.ParamStoreKeyMaxSegmentLength, &params.MaxSegmentLength)
}

if nameParamSpace.Has(ctx, nametypes.ParamStoreKeyMinSegmentLength) {
nameParamSpace.Get(ctx, nametypes.ParamStoreKeyMinSegmentLength, &params.MinSegmentLength)
}

if nameParamSpace.Has(ctx, nametypes.ParamStoreKeyAllowUnrestrictedNames) {
nameParamSpace.Get(ctx, nametypes.ParamStoreKeyAllowUnrestrictedNames, &params.AllowUnrestrictedNames)
}

// Set migrated params in the new store
app.NameKeeper.SetParams(ctx, params)

ctx.Logger().Info("Done migrating name params.")
}
3 changes: 3 additions & 0 deletions x/name/types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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{})
}
Expand All @@ -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),
Expand Down

0 comments on commit d540056

Please sign in to comment.