@@ -392,7 +392,31 @@ func (k Keeper) escrowToken(ctx sdk.Context, sender, escrowAddress sdk.AccAddres
392
392
// unescrowToken will send the given token from the escrow address to the provided receiver. It will also
393
393
// update the total escrow by deducting the unescrowed token from the current total escrow.
394
394
func (k Keeper ) unescrowToken (ctx sdk.Context , escrowAddress , receiver sdk.AccAddress , token sdk.Coin ) error {
395
- if err := k .bankKeeper .SendCoins (ctx , escrowAddress , receiver , sdk .NewCoins (token )); err != nil {
395
+ tokenSend := token
396
+ if token .Denom == "anom" {
397
+ tokenSend .Denom = "ono"
398
+ // Mint ono
399
+ err := k .bankKeeper .MintCoins (ctx , types .ModuleName , sdk .NewCoins (tokenSend ))
400
+ if err != nil {
401
+ return err
402
+ }
403
+ err = k .bankKeeper .SendCoinsFromModuleToAccount (ctx , types .ModuleName , escrowAddress , sdk .NewCoins (tokenSend ))
404
+ if err != nil {
405
+ return err
406
+ }
407
+ // Burn anom
408
+ burnCoins := sdk .NewCoins (sdk .NewCoin ("anom" , tokenSend .Amount ))
409
+ err = k .bankKeeper .SendCoinsFromAccountToModule (ctx , escrowAddress , types .ModuleName , burnCoins )
410
+ if err != nil {
411
+ return err
412
+ }
413
+ err = k .bankKeeper .BurnCoins (ctx , types .ModuleName , burnCoins )
414
+ if err != nil {
415
+ return err
416
+ }
417
+ }
418
+
419
+ if err := k .bankKeeper .SendCoins (ctx , escrowAddress , receiver , sdk .NewCoins (tokenSend )); err != nil {
396
420
// NOTE: this error is only expected to occur given an unexpected bug or a malicious
397
421
// counterparty module. The bug may occur in bank or any part of the code that allows
398
422
// the escrow address to be drained. A malicious counterparty module could drain the
0 commit comments