Skip to content

Commit

Permalink
Merge pull request #688 from comdex-official/mv9
Browse files Browse the repository at this point in the history
Mv9
  • Loading branch information
dheerajkd30 authored Feb 20, 2023
2 parents 808328e + 37fba50 commit 15484b9
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 4 deletions.
8 changes: 4 additions & 4 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ import (
mv6 "github.com/comdex-official/comdex/app/upgrades/mainnet/v6"
mv7 "github.com/comdex-official/comdex/app/upgrades/mainnet/v7"
mv8 "github.com/comdex-official/comdex/app/upgrades/mainnet/v8"
tv9 "github.com/comdex-official/comdex/app/upgrades/testnet/v9_0_0"
mv9 "github.com/comdex-official/comdex/app/upgrades/mainnet/v9"
)

const (
Expand Down Expand Up @@ -1215,8 +1215,8 @@ func (a *App) ModuleAccountsPermissions() map[string][]string {

func (a *App) registerUpgradeHandlers() {
a.UpgradeKeeper.SetUpgradeHandler(
tv9.UpgradeName,
tv9.CreateUpgradeHandlerV900Beta(a.mm, a.configurator, a.AssetKeeper),
mv9.UpgradeName,
mv9.CreateUpgradeHandlerV900(a.mm, a.configurator, a.AssetKeeper),
)
// When a planned update height is reached, the old binary will panic
// writing on disk the height and name of the update that triggered it
Expand Down Expand Up @@ -1279,7 +1279,7 @@ func upgradeHandlers(upgradeInfo storetypes.UpgradeInfo, a *App, storeUpgrades *
case upgradeInfo.Name == mv8.UpgradeName811 && !a.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height):
storeUpgrades = &storetypes.StoreUpgrades{}

case upgradeInfo.Name == tv9.UpgradeName && !a.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height):
case upgradeInfo.Name == mv9.UpgradeName && !a.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height):
storeUpgrades = &storetypes.StoreUpgrades{}
}

Expand Down
15 changes: 15 additions & 0 deletions app/upgrades/mainnet/v9/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package v9

const (
UpgradeName = "v9.0.0"
UpgradeHeight = ""
UpgradeInfo = `'{
"binaries": {
"darwin/arm64":"",
"darwin/x86_64":"",
"linux/arm64":"",
"linux/x86_64":"",
"windows/x86_64":""
}
}'`
)
71 changes: 71 additions & 0 deletions app/upgrades/mainnet/v9/upgrades.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package v9

import (
assetkeeper "github.com/comdex-official/comdex/x/asset/keeper"
assettypes "github.com/comdex-official/comdex/x/asset/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
)

func UpdateDenomAndAddAsset(ctx sdk.Context, assetKeeper assetkeeper.Keeper) {
asset, found := assetKeeper.GetAsset(ctx, 17)
if found {
asset.Denom = "ibc/50EF138042B553362774A8A9DE967F610E52CAEB3BA864881C9A1436DED98075"
assetKeeper.SetAsset(ctx, asset)
}

assetGDAI := assettypes.Asset{Name: "GDAI", Denom: "ibc/109DD45CF4093BEB472784A0C5B5F4643140900020B74B102B842A4BE2AE45DA", Decimals: sdk.NewInt(1000000000000000000), IsOnChain: false, IsOraclePriceRequired: true, IsCdpMintable: false}

err := assetKeeper.AddAssetRecords(ctx, assetGDAI)
if err != nil {
return
}
getGDAI, found := assetKeeper.GetAssetForDenom(ctx, "ibc/109DD45CF4093BEB472784A0C5B5F4643140900020B74B102B842A4BE2AE45DA")
if !found {
return
}
var (
id = assetKeeper.GetPairID(ctx)
pairGDAI = assettypes.Pair{
Id: id + 1,
AssetIn: getGDAI.Id,
AssetOut: 3,
}
)

assetKeeper.SetPairID(ctx, pairGDAI.Id)
assetKeeper.SetPair(ctx, pairGDAI)

getSTOSMO, found := assetKeeper.GetAssetForDenom(ctx, "ibc/CC482813CC038C614C2615A997621EA5E605ADCCD4040B83B0468BD72533A165")
if !found {
return
}

var (
id2 = assetKeeper.GetPairID(ctx)
pairSTOSMO = assettypes.Pair{
Id: id2 + 1,
AssetIn: getSTOSMO.Id,
AssetOut: 3,
}
)

assetKeeper.SetPairID(ctx, pairSTOSMO.Id)
assetKeeper.SetPair(ctx, pairSTOSMO)
}

func CreateUpgradeHandlerV900(
mm *module.Manager,
configurator module.Configurator,
assetKeeper assetkeeper.Keeper,
) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
vm, err := mm.RunMigrations(ctx, configurator, fromVM)
if err != nil {
return nil, err
}
UpdateDenomAndAddAsset(ctx, assetKeeper)
return vm, err
}
}

0 comments on commit 15484b9

Please sign in to comment.