Skip to content

Commit

Permalink
fix: refund unused tokens on revert
Browse files Browse the repository at this point in the history
  • Loading branch information
fadeev committed Jan 8, 2025
1 parent 9b99ad6 commit 7dbe453
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions contracts/nft/contracts/zetachain/UniversalNFTCore.sol
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,12 @@ abstract contract UniversalNFTCore is
_safeMint(sender, tokenId);
_setTokenURI(tokenId, uri);
emit TokenTransferReverted(sender, tokenId, uri);

if (context.amount > 0 && context.asset != address(0)) {
if (!IZRC20(context.asset).transfer(sender, context.amount)) {
revert TransferFailed();
}
}
}

/**
Expand Down
6 changes: 6 additions & 0 deletions contracts/token/contracts/zetachain/UniversalTokenCore.sol
Original file line number Diff line number Diff line change
Expand Up @@ -249,5 +249,11 @@ abstract contract UniversalTokenCore is
);
_mint(sender, amount);
emit TokenTransferReverted(sender, amount);

if (context.amount > 0 && context.asset != address(0)) {
if (!IZRC20(context.asset).transfer(sender, context.amount)) {
revert TransferFailed();
}
}
}
}

0 comments on commit 7dbe453

Please sign in to comment.