Skip to content

Commit

Permalink
Do not allow gasTokens to be managed by hard asset manager
Browse files Browse the repository at this point in the history
  • Loading branch information
josojo committed Jan 3, 2024
1 parent a299831 commit 1131db4
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
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
9 changes: 9 additions & 0 deletions test/ForkableBridge.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,15 @@ 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

0 comments on commit 1131db4

Please sign in to comment.