Skip to content

Commit

Permalink
return funds im upgrade handler
Browse files Browse the repository at this point in the history
  • Loading branch information
rbajollari committed Oct 22, 2024
1 parent 34e94c1 commit b4e96fc
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions app/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,20 @@ func (app *App) registerUpgrade0_5_2(_ upgradetypes.Plan) {
// delete all payments in the store before upgrade
payments := app.GmpKeeper.GetAllPayments(sdkCtx)
for _, payment := range payments {
sdkCtx.Logger().Info("returning funds and deleting payment")
relayerAddr, err := sdk.AccAddressFromBech32(payment.Relayer)
if err != nil {
sdkCtx.Logger().Error("error getting relayer address", "error", err)
}
err = app.BankKeeper.SendCoinsFromModuleToAccount(
ctx,
gmptypes.ModuleName,
relayerAddr,
sdk.NewCoins(payment.Token),
)
if err != nil {
sdkCtx.Logger().Error("error sending coins to relayer", "error", err)
}
app.GmpKeeper.DeletePayment(sdkCtx, payment)
}
return app.mm.RunMigrations(ctx, app.configurator, fromVM)
Expand Down

0 comments on commit b4e96fc

Please sign in to comment.