diff --git a/smart-contracts/contracts/periphery/TokenManagerV5/LockAndReleaseOrNativeTokenManagerUpgradeableV5.sol b/smart-contracts/contracts/periphery/TokenManagerV5/LockAndReleaseOrNativeTokenManagerUpgradeableV5.sol index d738a34..522ff03 100644 --- a/smart-contracts/contracts/periphery/TokenManagerV5/LockAndReleaseOrNativeTokenManagerUpgradeableV5.sol +++ b/smart-contracts/contracts/periphery/TokenManagerV5/LockAndReleaseOrNativeTokenManagerUpgradeableV5.sol @@ -20,6 +20,8 @@ contract LockAndReleaseOrNativeTokenManagerUpgradeableV5 is ILockAndReleaseOrNativeTokenManager, TokenManagerUpgradeableV4 { + using SafeERC20 for IERC20; + address public constant NATIVE_ASSET_HASH = address(0); /// @custom:oz-upgrades-unsafe-allow constructor @@ -40,7 +42,7 @@ contract LockAndReleaseOrNativeTokenManagerUpgradeableV5 is (bool success, ) = payable(this).call{ value: amount }(""); require(success, "Native asset transfer failed"); } else { - IERC20(token).transferFrom(from, address(this), amount); + IERC20(token).safeTransferFrom(from, address(this), amount); } emit Locked(token, from, amount); } @@ -55,7 +57,7 @@ contract LockAndReleaseOrNativeTokenManagerUpgradeableV5 is (bool success, ) = recipient.call{value: amount}(""); require(success, "Native asset transfer failed"); } else { - IERC20(token).transfer(recipient, amount); + IERC20(token).safeTransfer(recipient, amount); } emit Released(token, recipient, amount); } diff --git a/smart-contracts/test/periphery/TokenManagerDeployers/LockAndReleaseOrNativeTokenManagerDeployer.sol b/smart-contracts/test/periphery/TokenManagerDeployers/LockAndReleaseOrNativeTokenManagerDeployer.sol index 8f698ad..4a3292f 100644 --- a/smart-contracts/test/periphery/TokenManagerDeployers/LockAndReleaseOrNativeTokenManagerDeployer.sol +++ b/smart-contracts/test/periphery/TokenManagerDeployers/LockAndReleaseOrNativeTokenManagerDeployer.sol @@ -29,7 +29,9 @@ abstract contract LockAndReleaseOrNativeTokenManagerDeployer is return LockAndReleaseOrNativeTokenManagerUpgradeableV3(payable(address(proxy))); } - function deployLockAndReleaseOrNativeTokenManagerV4( + // Named like this to prevent those who we don't want to have access constructing one. + // You should be using V5. + function deployLockAndReleaseOrNativeTokenManagerV4x( address chainGateway, uint fees ) public returns (LockAndReleaseOrNativeTokenManagerUpgradeableV4) { diff --git a/smart-contracts/test/zilbridge/TokenManager.tether.t.sol b/smart-contracts/test/zilbridge/TokenManager.tether.t.sol index c9f3a66..1492c6f 100644 --- a/smart-contracts/test/zilbridge/TokenManager.tether.t.sol +++ b/smart-contracts/test/zilbridge/TokenManager.tether.t.sol @@ -78,7 +78,7 @@ contract TokenManagerTetherTest is Tester, IRelayerEvents, LockAndReleaseOrNativ console.log("balance ", address(this).balance); tokenManager.transfer{value: fees}( address(tetherToken), remoteChainId, remoteUser, AMOUNT); assertEq(tetherToken.balanceOf(address(tokenManager)), AMOUNT); - assertEq(tetherToken.balanceOf(sourceUser), 0); + assertEq(tetherToken.balanceOf(sourceUser), SUPPLY-AMOUNT); assertEq(address(tokenManager).balance, fees); vm.stopPrank(); } @@ -101,7 +101,7 @@ contract TokenManagerTetherTest is Tester, IRelayerEvents, LockAndReleaseOrNativ address(tokenManager), data, 1_000_000, 0, signatures); - assertEq(tetherToken.balanceOf(sourceUser), AMOUNT); + assertEq(tetherToken.balanceOf(sourceUser), SUPPLY); assertEq(tetherToken.balanceOf(address(tokenManager)), 0); vm.stopPrank(); }