Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not allow gasTokens to be managed by hard asset manager #153

Merged
merged 2 commits into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion contracts/ForkableBridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ contract ForkableBridge is
if (to != children[0] && to != children[1]) {
revert InvalidDestinationForHardAsset();
}
if (token == gasTokenAddress) {
revert GasTokenIsNotHardAsset();
}
IERC20(token).transfer(to, amount);
}

Expand Down Expand Up @@ -178,8 +181,12 @@ contract ForkableBridge is
* @dev Allows aynone to take out their forkonomic tokens
* and send them to the children-bridge contracts
* Notice that forkonomic tokens are special, as they their main contract
* is on L1, but they are still forkable tokens as all the tokens from
* is on L1, but they are still forkable tokens, as their contract is forked as well.
* We allow to send tokens only to one child, just in case the one child contract
* was updated shortly after the fork and contains an error (e.g. reverts on sending)
* @param amount Amount of tokens to be sent to the children-bridge contracts
* @param useFirstChild boolean indicating for which child the operation should be run
* @param useChildTokenAllowance boolean indicating if the child token allowance (previously burned tokens) should be used
*/
function sendForkonomicTokensToChild(
uint256 amount,
Expand Down
2 changes: 2 additions & 0 deletions contracts/interfaces/IForkableBridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ interface IForkableBridge is IForkableStructure, IPolygonZkEVMBridge {
error NotAuthorized();
/// @dev Error thrown when trying to send bridged tokens to a child contract
error InvalidDestinationForHardAsset();
/// @dev Error thrown when hardasset manager tries to send gas token to a child contract
error GasTokenIsNotHardAsset();

/**
* @dev Function to initialize the contract
Expand Down
7 changes: 7 additions & 0 deletions test/ForkableBridge.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,13 @@ contract ForkableBridgeTest is Test {
to
);

vm.expectRevert(IForkableBridge.GasTokenIsNotHardAsset.selector);
vm.prank(hardAssetManger);
forkableBridge.transferHardAssetsToChild(
address(gasTokenAddress),
amount,
child2
);
vm.expectRevert(
IForkableBridge.InvalidDestinationForHardAsset.selector
);
Expand Down
Loading