Skip to content

Commit

Permalink
errors
Browse files Browse the repository at this point in the history
  • Loading branch information
fadeev committed Jan 13, 2025
1 parent 926a9f9 commit d07edd7
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions examples/swap/contracts/Swap.sol
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ contract Swap is
error InvalidAddress();
error Unauthorized();
error ApprovalFailed();
error TransferFailed();
error TransferFailed(string);
error InsufficientAmount(string);

event TokenSwap(
Expand Down Expand Up @@ -141,7 +141,9 @@ contract Swap is
amount
);
if (!success) {
revert TransferFailed();
revert TransferFailed(
"Failed to transfer ZRC-20 tokens from the sender to the contract"
);
}

(uint256 out, address gasZRC20, uint256 gasFee) = handleGasAndSwap(
Expand Down Expand Up @@ -188,7 +190,9 @@ contract Swap is

uint256 minInput = quoteMinInput(inputToken, targetToken);
if (amount < minInput) {
revert InsufficientAmount("not enough tokens");
revert InsufficientAmount(
"The input amount is less than the min amount required to cover the withdraw gas fee"
);
}

if (gasZRC20 == inputToken) {
Expand Down Expand Up @@ -256,7 +260,9 @@ contract Swap is
out
);
if (!success) {
revert TransferFailed();
revert TransferFailed(
"Failed to transfer target tokens to the recipient on ZetaChain"
);
}
}
}
Expand Down

0 comments on commit d07edd7

Please sign in to comment.