Skip to content

Commit

Permalink
Update v1.2.0 upgrade code
Browse files Browse the repository at this point in the history
  • Loading branch information
Charles Dusek committed Jun 14, 2024
1 parent 3365ec3 commit 4173972
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions app/upgrades/v1.2.0/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ func CreateUpgradeHandler(
return func(ctx sdk.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
ctx.Logger().Info("Starting module migrations...")

marketAccount := keepers.AccountKeeper.GetModuleAccount(ctx, markettypes.ModuleName)

// Deactivate all drops and remove owners
drops := keepers.MarketKeeper.GetAllDrop(ctx)
for _, drop := range drops {
Expand Down Expand Up @@ -47,17 +49,30 @@ func CreateUpgradeHandler(
keepers.MarketKeeper.SetMember(ctx, member)
}

// Set order status to balances to zero
// Set order status to canceled
orders := keepers.MarketKeeper.GetAllOrder(ctx)
for _, order := range orders {
if order.Status == "active" {
order.Status = "canceled"
order.Prev = 0
order.Next = 0
order.UpdTime = ctx.BlockHeader().Time.Unix()
coinRefund := sdk.NewCoin(order.DenomBid, order.Amount)
marketBal := keepers.BankKeeper.GetBalance(ctx, marketAccount.GetAddress(), order.DenomBid)
if marketBal.Amount.GTE(order.Amount) {
refundAddr, _ := sdk.AccAddressFromBech32(order.Owner)
keepers.BankKeeper.SendCoinsFromModuleToAccount(
ctx,
markettypes.ModuleName,
refundAddr,
sdk.NewCoins(coinRefund),
)
}

keepers.MarketKeeper.SetOrder(ctx, order)
}
keepers.MarketKeeper.SetOrder(ctx, order)
}

marketAccount := keepers.AccountKeeper.GetModuleAccount(ctx, markettypes.ModuleName)

marketCoins := keepers.BankKeeper.GetAllBalances(ctx, marketAccount.GetAddress())

reclaimer, _ := sdk.AccAddressFromBech32("onomy1yc0lg97cy5e80jyajtkz0zke2rr4734anugf9g")
Expand Down

0 comments on commit 4173972

Please sign in to comment.