|
| 1 | +// SPDX-License-Identifier: Apache-2.0 |
| 2 | +// |
| 3 | +// Copyright 2025 NASD Inc. All Rights Reserved. |
| 4 | +// |
| 5 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | +// you may not use this file except in compliance with the License. |
| 7 | +// You may obtain a copy of the License at |
| 8 | +// |
| 9 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +// |
| 11 | +// Unless required by applicable law or agreed to in writing, software |
| 12 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | +// See the License for the specific language governing permissions and |
| 15 | +// limitations under the License. |
| 16 | + |
| 17 | +package v12alpha2 |
| 18 | + |
| 19 | +import ( |
| 20 | + "context" |
| 21 | + "fmt" |
| 22 | + |
| 23 | + upgradetypes "cosmossdk.io/x/upgrade/types" |
| 24 | + ftfkeeper "github.com/circlefin/noble-fiattokenfactory/x/fiattokenfactory/keeper" |
| 25 | + ftftypes "github.com/circlefin/noble-fiattokenfactory/x/fiattokenfactory/types" |
| 26 | + sdk "github.com/cosmos/cosmos-sdk/types" |
| 27 | + "github.com/cosmos/cosmos-sdk/types/module" |
| 28 | +) |
| 29 | + |
| 30 | +func CreateUpgradeHandler( |
| 31 | + mm *module.Manager, |
| 32 | + cfg module.Configurator, |
| 33 | + ftfKeeper *ftfkeeper.Keeper, |
| 34 | +) upgradetypes.UpgradeHandler { |
| 35 | + return func(ctx context.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { |
| 36 | + chainID := sdk.UnwrapSDKContext(ctx).ChainID() |
| 37 | + if chainID != DevnetChainID { |
| 38 | + return vm, fmt.Errorf("%s upgrade not allowed to execute on %s chain", UpgradeName, chainID) |
| 39 | + } |
| 40 | + |
| 41 | + vm, err := mm.RunMigrations(ctx, cfg, vm) |
| 42 | + if err != nil { |
| 43 | + return vm, err |
| 44 | + } |
| 45 | + |
| 46 | + // Because the paused store was not intialized in the devnet genesis, |
| 47 | + // it must be configured here for USDC transfers to be successful. |
| 48 | + ftfKeeper.SetPaused(ctx, ftftypes.Paused{Paused: false}) |
| 49 | + |
| 50 | + return vm, nil |
| 51 | + } |
| 52 | +} |
0 commit comments