Skip to content

Commit

Permalink
(feat) A version of the lock and release token manager which copes wi…
Browse files Browse the repository at this point in the history
…th old contracts (due to an idea of JH's).

(fix) Remove the ability to construct V4 - you should use V5.
  • Loading branch information
rrw-zilliqa committed Jan 14, 2025
1 parent 03eaa0a commit bdf03e8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
}
Expand All @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions smart-contracts/test/zilbridge/TokenManager.tether.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand All @@ -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();
}
Expand Down

0 comments on commit bdf03e8

Please sign in to comment.