diff --git a/src/child/ChildERC20Bridge.sol b/src/child/ChildERC20Bridge.sol index 06e3051b..ceff0ed7 100644 --- a/src/child/ChildERC20Bridge.sol +++ b/src/child/ChildERC20Bridge.sol @@ -314,9 +314,12 @@ contract ChildERC20Bridge is * @notice Private function to handle withdrawal of L1 native ETH. */ function _withdrawETH(uint256 amount) private returns (address) { - if (!IChildERC20(childETHToken).burn(msg.sender, amount)) { + try IChildERC20(childETHToken).burn(msg.sender, amount) returns (bool success) { + if (!success) revert BurnFailed(); + } catch { revert BurnFailed(); } + return NATIVE_ETH; } @@ -330,7 +333,9 @@ contract ChildERC20Bridge is IWIMX wIMX = IWIMX(wIMXToken); // Transfer to contract - if (!wIMX.transferFrom(msg.sender, address(this), amount)) { + try wIMX.transferFrom(msg.sender, address(this), amount) returns (bool success) { + if (!success) revert TransferWIMXFailed(); + } catch { revert TransferWIMXFailed(); } @@ -372,7 +377,9 @@ contract ChildERC20Bridge is } // Burn tokens - if (!IChildERC20(childToken).burn(msg.sender, amount)) { + try IChildERC20(childToken).burn(msg.sender, amount) returns (bool success) { + if (!success) revert BurnFailed(); + } catch { revert BurnFailed(); } @@ -486,7 +493,9 @@ contract ChildERC20Bridge is revert EmptyTokenContract(); } - if (!IChildERC20(childToken).mint(receiver, amount)) { + try IChildERC20(childToken).mint(receiver, amount) returns (bool success) { + if (!success) revert MintFailed(); + } catch { revert MintFailed(); } diff --git a/test/unit/child/ChildERC20Bridge.t.sol b/test/unit/child/ChildERC20Bridge.t.sol index 85386706..1b1db243 100644 --- a/test/unit/child/ChildERC20Bridge.t.sol +++ b/test/unit/child/ChildERC20Bridge.t.sol @@ -628,7 +628,7 @@ contract ChildERC20BridgeUnitTest is Test, IChildERC20BridgeEvents, IChildERC20B changePrank(attacker); // Execute withdraw - vm.expectRevert("ReentrancyGuard: reentrant call"); + vm.expectRevert(BurnFailed.selector); childBridge.withdraw{value: 1 ether}(ChildERC20(address(attackToken)), 100); } } diff --git a/test/unit/child/withdrawals/ChildERC20BridgeWithdrawETH.t.sol b/test/unit/child/withdrawals/ChildERC20BridgeWithdrawETH.t.sol index 92680ec5..7c88aa08 100644 --- a/test/unit/child/withdrawals/ChildERC20BridgeWithdrawETH.t.sol +++ b/test/unit/child/withdrawals/ChildERC20BridgeWithdrawETH.t.sol @@ -74,7 +74,7 @@ contract ChildERC20BridgeWithdrawETHUnitTest is Test, IChildERC20BridgeEvents, I uint256 withdrawAmount = 101 ether; uint256 withdrawFee = 300; - vm.expectRevert(bytes("ERC20: burn amount exceeds balance")); + vm.expectRevert(BurnFailed.selector); childBridge.withdrawETH{value: withdrawFee}(withdrawAmount); } diff --git a/test/unit/child/withdrawals/ChildERC20BridgeWithdrawETHTo.t.sol b/test/unit/child/withdrawals/ChildERC20BridgeWithdrawETHTo.t.sol index 7c474695..d2589b54 100644 --- a/test/unit/child/withdrawals/ChildERC20BridgeWithdrawETHTo.t.sol +++ b/test/unit/child/withdrawals/ChildERC20BridgeWithdrawETHTo.t.sol @@ -94,7 +94,7 @@ contract ChildERC20BridgeWithdrawETHToUnitTest is Test, IChildERC20BridgeEvents, uint256 withdrawAmount = 101 ether; uint256 withdrawFee = 300; - vm.expectRevert(bytes("ERC20: burn amount exceeds balance")); + vm.expectRevert(BurnFailed.selector); childBridge.withdrawETHTo{value: withdrawFee}(address(this), withdrawAmount); } diff --git a/test/unit/child/withdrawals/ChildERC20BridgeWithdrawWIMX.t.sol b/test/unit/child/withdrawals/ChildERC20BridgeWithdrawWIMX.t.sol index a14fb6a1..6e30a934 100644 --- a/test/unit/child/withdrawals/ChildERC20BridgeWithdrawWIMX.t.sol +++ b/test/unit/child/withdrawals/ChildERC20BridgeWithdrawWIMX.t.sol @@ -74,7 +74,7 @@ contract ChildERC20BridgeWithdrawWIMXUnitTest is Test, IChildERC20BridgeEvents, uint256 withdrawFee = 300; wIMXToken.approve(address(childBridge), withdrawAmount); - vm.expectRevert(bytes("Wrapped IMX: Insufficient balance")); + vm.expectRevert(TransferWIMXFailed.selector); childBridge.withdrawWIMX{value: withdrawFee}(withdrawAmount); } @@ -83,7 +83,7 @@ contract ChildERC20BridgeWithdrawWIMXUnitTest is Test, IChildERC20BridgeEvents, uint256 withdrawFee = 300; wIMXToken.approve(address(childBridge), withdrawAmount - 1); - vm.expectRevert(bytes("Wrapped IMX: Insufficient allowance")); + vm.expectRevert(TransferWIMXFailed.selector); childBridge.withdrawWIMX{value: withdrawFee}(withdrawAmount); } diff --git a/test/unit/child/withdrawals/ChildERC20BridgeWithdrawWIMXTo.t.sol b/test/unit/child/withdrawals/ChildERC20BridgeWithdrawWIMXTo.t.sol index 0ffe48c7..02c10e95 100644 --- a/test/unit/child/withdrawals/ChildERC20BridgeWithdrawWIMXTo.t.sol +++ b/test/unit/child/withdrawals/ChildERC20BridgeWithdrawWIMXTo.t.sol @@ -83,7 +83,7 @@ contract ChildERC20BridgeWithdrawWIMXToUnitTest is Test, IChildERC20BridgeEvents uint256 withdrawFee = 300; wIMXToken.approve(address(childBridge), withdrawAmount); - vm.expectRevert(bytes("Wrapped IMX: Insufficient balance")); + vm.expectRevert(TransferWIMXFailed.selector); childBridge.withdrawWIMXTo{value: withdrawFee}(address(this), withdrawAmount); } @@ -92,7 +92,7 @@ contract ChildERC20BridgeWithdrawWIMXToUnitTest is Test, IChildERC20BridgeEvents uint256 withdrawFee = 300; wIMXToken.approve(address(childBridge), withdrawAmount - 1); - vm.expectRevert(bytes("Wrapped IMX: Insufficient allowance")); + vm.expectRevert(TransferWIMXFailed.selector); childBridge.withdrawWIMXTo{value: withdrawFee}(address(this), withdrawAmount); }