Skip to content

Commit

Permalink
fix. handling ConvertCoin failure using cached context
Browse files Browse the repository at this point in the history
  • Loading branch information
poorphd authored and dongsam committed Aug 3, 2024
1 parent bd5ee11 commit 1709547
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions x/onboarding/keeper/ibc_callbacks.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,13 @@ func (k Keeper) OnRecvPacket(
// the ICS20 packet data

// Use MsgConvertCoin to convert the Cosmos Coin to an ERC20
if _, err = k.erc20Keeper.ConvertCoin(ctx, convertMsg); err != nil {
// Use cached context to revert the state if the conversion fails

cacheCtx, writeCache := ctx.CacheContext()
if _, err = k.erc20Keeper.ConvertCoin(sdk.WrapSDKContext(cacheCtx), convertMsg); err != nil {
logger.Error("failed to convert coins", "error", err)
return ack
} else {
writeCache()
}

logger.Info(
Expand Down

0 comments on commit 1709547

Please sign in to comment.