Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Removing unnecessary software upgrade handlers #370

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 1 addition & 89 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ func New(

app.GovKeeper = *govKeeper.SetHooks(
govtypes.NewMultiGovHooks(
// register the governance hooks
// register the governance hooks
),
)

Expand Down Expand Up @@ -719,94 +719,6 @@ func (app *App) GetSubspace(moduleName string) paramstypes.Subspace {
}

func (app *App) RegisterUpgradeHandlers(cfg module.Configurator) {
const municipalInflationTargetAddress = "fetch1n8d5466h8he33uedc0vsgtahal0mrz55glre03"

// NOTE(pb): The `fetchd-v0.10.7` upgrade handler *MUST* be present due to the mainnent, where this is the *LAST*
// executed upgrade. Presence of this handler is enforced by the `x/upgrade/abci.go#L31-L40` (see the
// https://github.com/fetchai/cosmos-sdk/blob/09cf7baf4297a30acd8d09d9db7dd97d79ffe008/x/upgrade/abci.go#L31-L40).
app.UpgradeKeeper.SetUpgradeHandler("fetchd-v0.10.7", func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
return app.mm.RunMigrations(ctx, cfg, fromVM)
})

// NOTE(pb): The `v0.11.2` upgrade handler *MUST* be present due to Dorado-1 testnet, where this is the *LAST*
// executed upgrade. Please see the details in the NOTE above.
app.UpgradeKeeper.SetUpgradeHandler("v0.11.2", func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
mobixInfl, err := sdk.NewDecFromStr("0.03")
if err != nil {
return module.VersionMap{}, err
}
minter := app.MintKeeper.GetMinter(ctx)
minter.MunicipalInflation = []*minttypes.MunicipalInflationPair{
{Denom: "nanomobx", Inflation: minttypes.NewMunicipalInflation(municipalInflationTargetAddress, mobixInfl)},
}

app.MintKeeper.SetMinter(ctx, minter)

return app.mm.RunMigrations(ctx, cfg, fromVM)
})

app.UpgradeKeeper.SetUpgradeHandler("v0.11.3", func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
// Introducing the NOMX token **IF** it does not exist yet:
const nomxDenom = "nanonomx"
const nomxName = "NOMX"
const nomxSupply = 1000000000000000000 // = 10^18 < 2^63 (max(int64))
if !app.BankKeeper.HasSupply(ctx, nomxDenom) {
coinsToMint := sdk.NewCoins(sdk.NewInt64Coin(nomxDenom, nomxSupply))
app.MintKeeper.MintCoins(ctx, coinsToMint)

acc, err := sdk.AccAddressFromBech32(municipalInflationTargetAddress)
if err != nil {
panic(err)
}

err = app.BankKeeper.SendCoinsFromModuleToAccount(ctx, minttypes.ModuleName, acc, coinsToMint)
if err != nil {
panic(err)
}

ctx.EventManager().EmitEvent(
sdk.NewEvent(
minttypes.EventTypeMunicipalMint,
sdk.NewAttribute(minttypes.AttributeKeyDenom, nomxDenom),
sdk.NewAttribute(minttypes.AttributeKeyTargetAddr, municipalInflationTargetAddress),
sdk.NewAttribute(sdk.AttributeKeyAmount, coinsToMint.String()),
),
)

nomxMetadata := banktypes.Metadata{
Base: nomxDenom,
Name: nomxName,
Symbol: nomxName,
Display: nomxName,
Description: nomxName + " token",
DenomUnits: []*banktypes.DenomUnit{
{Denom: nomxName, Exponent: 9, Aliases: nil},
{Denom: "mnomx", Exponent: 6, Aliases: nil},
{Denom: "unomx", Exponent: 3, Aliases: nil},
{Denom: nomxDenom, Exponent: 0, Aliases: nil},
},
}

app.BankKeeper.SetDenomMetaData(ctx, nomxMetadata)
}

// Municipal Inflation for MOBX & NOMX tokens:
inflation, err := sdk.NewDecFromStr("0.03")
if err != nil {
return module.VersionMap{}, err
}

minter := app.MintKeeper.GetMinter(ctx)
municipalInflation := minttypes.NewMunicipalInflation(municipalInflationTargetAddress, inflation)
minter.MunicipalInflation = []*minttypes.MunicipalInflationPair{
{Denom: "nanomobx", Inflation: municipalInflation},
{Denom: nomxDenom, Inflation: municipalInflation},
}

app.MintKeeper.SetMinter(ctx, minter)

return app.mm.RunMigrations(ctx, cfg, fromVM)
})
}

// RegisterAPIRoutes registers all application module routes with the provided
Expand Down
Loading