Skip to content

Commit

Permalink
fix cli, add upgrade handler
Browse files Browse the repository at this point in the history
  • Loading branch information
slandymani committed Nov 27, 2024
1 parent e5135ae commit 84edfc5
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 8 deletions.
3 changes: 3 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
circuitkeeper "cosmossdk.io/x/circuit/keeper"
circuittypes "cosmossdk.io/x/circuit/types"
"github.com/ODIN-PROTOCOL/odin-core/app/upgrades/v10_0"
"github.com/ODIN-PROTOCOL/odin-core/app/upgrades/v11_0"
"github.com/ODIN-PROTOCOL/odin-core/x/onft"
onftkeeper "github.com/ODIN-PROTOCOL/odin-core/x/onft/keeper"
wasmkeeper "github.com/ODIN-PROTOCOL/wasmd/x/wasm/keeper"
Expand Down Expand Up @@ -243,6 +244,7 @@ var (
v8_3.Upgrade,
v9_3.Upgrade,
v10_0.Upgrade,
v11_0.Upgrade,
}
)

Expand Down Expand Up @@ -670,6 +672,7 @@ func NewOdinApp(
messenger := wasmkeeper.NewMessageHandlerChain(
onftkeeper.NewMintNFTMessageHandler(app.ONFTKeeper), //should be first
wasmkeeper.NewDefaultMessageHandler(
&app.WasmKeeper,
app.MsgServiceRouter(),
app.IBCKeeper.ChannelKeeper,
app.IBCKeeper.ChannelKeeper,
Expand Down
38 changes: 38 additions & 0 deletions app/upgrades/v11_0/upgrades.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package v11_0

import (
"context"

storetypes "cosmossdk.io/store/types"
upgradetypes "cosmossdk.io/x/upgrade/types"
"github.com/ODIN-PROTOCOL/odin-core/app/keepers"
"github.com/ODIN-PROTOCOL/odin-core/app/upgrades"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
)

func CreateUpgradeHandler(
mm *module.Manager,
configurator module.Configurator,
_ upgrades.AppManager,
_ *keepers.AppKeepers,
) upgradetypes.UpgradeHandler {
return func(ctx context.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
goCtx := sdk.UnwrapSDKContext(ctx)
goCtx.Logger().Info("Starting module migrations...")

vm, err := mm.RunMigrations(ctx, configurator, vm)
if err != nil {
return vm, err
}

goCtx.Logger().Info("Upgrade v11 complete")
return vm, nil
}
}

var Upgrade = upgrades.Upgrade{
UpgradeName: "v0.11.0",
CreateUpgradeHandler: CreateUpgradeHandler,
StoreUpgrades: storetypes.StoreUpgrades{},
}
9 changes: 1 addition & 8 deletions cmd/odind/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"github.com/cosmos/cosmos-sdk/client/pruning"
"github.com/cosmos/cosmos-sdk/client/rpc"
"github.com/cosmos/cosmos-sdk/client/snapshot"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
"github.com/cosmos/cosmos-sdk/server"
serverconfig "github.com/cosmos/cosmos-sdk/server/config"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
Expand Down Expand Up @@ -111,15 +110,9 @@ func NewRootCmd() (rootCMD *cobra.Command, params params.EncodingConfig) {
initClientCtx, _ = config.ReadDefaultValuesFromDefaultClientConfig(initClientCtx)

autoCliOpts.ClientCtx = initClientCtx
autoCliOpts.Keyring, _ = keyring.NewAutoCLIKeyring(initClientCtx.Keyring)
//autoCliOpts.Keyring, _ = keyring.NewAutoCLIKeyring(initClientCtx.Keyring)
autoCliOpts.ClientCtx.KeyringDir = ""

// TODO!: Add Textual signing mode to app.go
enabledSignModes := append(tx.DefaultSignModes, signing.SignMode_SIGN_MODE_TEXTUAL)
autoCliOpts.TxConfigOpts = tx.ConfigOptions{
EnabledSignModes: enabledSignModes,
TextualCoinMetadataQueryFn: authtxconfig.NewGRPCCoinMetadataQueryFn(initClientCtx),
}
if err := autoCliOpts.EnhanceRootCommand(rootCmd); err != nil {
panic(err)
}
Expand Down

0 comments on commit 84edfc5

Please sign in to comment.