-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8f63512
commit ab49b0c
Showing
5 changed files
with
89 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package v5 | ||
package v6 | ||
|
||
import ( | ||
storetypes "cosmossdk.io/store/types" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package v6 | ||
|
||
import ( | ||
"context" | ||
|
||
upgradetypes "cosmossdk.io/x/upgrade/types" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/cosmos/cosmos-sdk/types/module" | ||
connecttypes "github.com/skip-mev/connect/v2/pkg/types" | ||
oracletypes "github.com/skip-mev/connect/v2/x/oracle/types" | ||
|
||
"github.com/milkyway-labs/milkyway/v6/app/keepers" | ||
liquidvestingtypes "github.com/milkyway-labs/milkyway/v6/x/liquidvesting/types" | ||
) | ||
|
||
func CreateUpgradeHandler( | ||
mm *module.Manager, | ||
configuration module.Configurator, | ||
keepers *keepers.AppKeepers, | ||
) upgradetypes.UpgradeHandler { | ||
return func(ctx context.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { | ||
vm, err := mm.RunMigrations(ctx, configuration, fromVM) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
// Unwrap the context | ||
sdkCtx := sdk.UnwrapSDKContext(ctx) | ||
|
||
// Overwrite liquidvesting module account. | ||
liquidVestingModuleAddr := keepers.AccountKeeper.GetModuleAddress(liquidvestingtypes.ModuleName) | ||
acc := keepers.AccountKeeper.GetAccount(ctx, liquidVestingModuleAddr) | ||
if acc != nil { | ||
_, ok := acc.(sdk.ModuleAccountI) | ||
if !ok { | ||
keepers.AccountKeeper.RemoveAccount(ctx, acc) | ||
keepers.AccountKeeper.GetModuleAccount(ctx, liquidvestingtypes.ModuleName) | ||
} | ||
} | ||
|
||
// Delete all currency pairs. We use IterateCurrencyPairs instead of | ||
// GetAllCurrencyPairs to check the returned error. | ||
var currencyPairs []connecttypes.CurrencyPair | ||
err = keepers.OracleKeeper.IterateCurrencyPairs(sdkCtx, func(cp connecttypes.CurrencyPair, _ oracletypes.CurrencyPairState) { | ||
currencyPairs = append(currencyPairs, cp) | ||
}) | ||
if err != nil { | ||
return nil, err | ||
} | ||
for _, cp := range currencyPairs { | ||
err = keepers.OracleKeeper.RemoveCurrencyPair(sdkCtx, cp) | ||
if err != nil { | ||
return nil, err | ||
} | ||
} | ||
|
||
return vm, nil | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters