Skip to content

Commit d07edd7

Browse files
committed
errors
1 parent 926a9f9 commit d07edd7

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

examples/swap/contracts/Swap.sol

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ contract Swap is
3232
error InvalidAddress();
3333
error Unauthorized();
3434
error ApprovalFailed();
35-
error TransferFailed();
35+
error TransferFailed(string);
3636
error InsufficientAmount(string);
3737

3838
event TokenSwap(
@@ -141,7 +141,9 @@ contract Swap is
141141
amount
142142
);
143143
if (!success) {
144-
revert TransferFailed();
144+
revert TransferFailed(
145+
"Failed to transfer ZRC-20 tokens from the sender to the contract"
146+
);
145147
}
146148

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

189191
uint256 minInput = quoteMinInput(inputToken, targetToken);
190192
if (amount < minInput) {
191-
revert InsufficientAmount("not enough tokens");
193+
revert InsufficientAmount(
194+
"The input amount is less than the min amount required to cover the withdraw gas fee"
195+
);
192196
}
193197

194198
if (gasZRC20 == inputToken) {
@@ -256,7 +260,9 @@ contract Swap is
256260
out
257261
);
258262
if (!success) {
259-
revert TransferFailed();
263+
revert TransferFailed(
264+
"Failed to transfer target tokens to the recipient on ZetaChain"
265+
);
260266
}
261267
}
262268
}

0 commit comments

Comments
 (0)