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: umfx denom metadata migration #103

Merged
merged 6 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ DOCKER := $(shell which docker)
LEDGER_ENABLED ?= true
BINDIR ?= $(GOPATH)/bin
BUILD_DIR = ./build
VERSION = v0.0.1-alpha.17
VERSION = v0.0.1-alpha.18

export GO111MODULE = on

Expand Down
5 changes: 3 additions & 2 deletions app/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ import (
upgradetypes "cosmossdk.io/x/upgrade/types"

"github.com/liftedinit/manifest-ledger/app/upgrades"
"github.com/liftedinit/manifest-ledger/app/upgrades/next"
"github.com/liftedinit/manifest-ledger/app/upgrades/noop"
)

// Upgrades list of chain upgrades
var Upgrades []upgrades.Upgrade
var Upgrades = []upgrades.Upgrade{next.NewUpgrade()}

// RegisterUpgradeHandlers registers the chain upgrade handlers
func (app *ManifestApp) RegisterUpgradeHandlers() {
Expand All @@ -19,7 +20,7 @@ func (app *ManifestApp) RegisterUpgradeHandlers() {
Upgrades = append(Upgrades, noop.NewUpgrade(app.Version()))
}

keepers := upgrades.AppKeepers{AccountKeeper: app.AccountKeeper}
keepers := upgrades.AppKeepers{AccountKeeper: app.AccountKeeper, BankKeeper: app.BankKeeper}
// register all upgrade handlers
for _, upgrade := range Upgrades {
app.UpgradeKeeper.SetUpgradeHandler(
Expand Down
57 changes: 57 additions & 0 deletions app/upgrades/next/upgrades.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package next

import (
"context"

storetypes "cosmossdk.io/store/types"
upgradetypes "cosmossdk.io/x/upgrade/types"

"github.com/cosmos/cosmos-sdk/types/module"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"

"github.com/liftedinit/manifest-ledger/app/upgrades"
)

func NewUpgrade() upgrades.Upgrade {
return upgrades.Upgrade{
UpgradeName: "umfx-denom-metadata",
CreateUpgradeHandler: CreateUpgradeHandler,
StoreUpgrades: storetypes.StoreUpgrades{
Added: []string{},
Deleted: []string{},
},
}
}

func CreateUpgradeHandler(
mm *module.Manager,
configurator module.Configurator,
keepers *upgrades.AppKeepers,
) upgradetypes.UpgradeHandler {
return func(ctx context.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
metadata := banktypes.Metadata{
Description: "The Manifest Network token",
DenomUnits: []*banktypes.DenomUnit{
{
Denom: "umfx",
Exponent: 0,
Aliases: []string{},
},
{
Denom: "mfx",
Exponent: 6,
Aliases: []string{},
},
},
Base: "umfx",
Display: "MFX",
Symbol: "MFX",
Name: "Manifest Network Token",
}

// Set the new metadata in the bank keeper
keepers.BankKeeper.SetDenomMetaData(ctx, metadata)

fmorency marked this conversation as resolved.
Show resolved Hide resolved
return mm.RunMigrations(ctx, configurator, fromVM)
}
}
4 changes: 3 additions & 1 deletion app/upgrades/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ import (

"github.com/cosmos/cosmos-sdk/types/module"
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
)

type AppKeepers struct {
authkeeper.AccountKeeper
AccountKeeper authkeeper.AccountKeeper
BankKeeper bankkeeper.BaseKeeper
}

// Upgrade defines a struct containing necessary fields that a SoftwareUpgradeProposal
Expand Down
Loading