Commit ba109a7e authored by Maurelian's avatar Maurelian

contracts: Fix OZ-M-05 rename _data to _extraData

This commit also expands on the natspec comments to clarify how the additional
data may be used.

fixup! contracts: Fix OZ-M-05 rename _data to _extraData
parent 762092f2
...@@ -22,12 +22,12 @@ contract L2StandardBridge is StandardBridge { ...@@ -22,12 +22,12 @@ contract L2StandardBridge is StandardBridge {
* @custom:legacy * @custom:legacy
* @notice Emitted whenever a withdrawal from L2 to L1 is initiated. * @notice Emitted whenever a withdrawal from L2 to L1 is initiated.
* *
* @param _l1Token Address of the token on L1. * @param _l1Token Address of the token on L1.
* @param _l2Token Address of the corresponding token on L2. * @param _l2Token Address of the corresponding token on L2.
* @param _from Address of the withdrawer. * @param _from Address of the withdrawer.
* @param _to Address of the recipient on L1. * @param _to Address of the recipient on L1.
* @param _amount Amount of the ERC20 withdrawn. * @param _amount Amount of the ERC20 withdrawn.
* @param _data Extra data attached to the withdrawal. * @param _extraData Extra data attached to the withdrawal.
*/ */
event WithdrawalInitiated( event WithdrawalInitiated(
address indexed _l1Token, address indexed _l1Token,
...@@ -35,19 +35,19 @@ contract L2StandardBridge is StandardBridge { ...@@ -35,19 +35,19 @@ contract L2StandardBridge is StandardBridge {
address indexed _from, address indexed _from,
address _to, address _to,
uint256 _amount, uint256 _amount,
bytes _data bytes _extraData
); );
/** /**
* @custom:legacy * @custom:legacy
* @notice Emitted whenever an ERC20 deposit is finalized. * @notice Emitted whenever an ERC20 deposit is finalized.
* *
* @param _l1Token Address of the token on L1. * @param _l1Token Address of the token on L1.
* @param _l2Token Address of the corresponding token on L2. * @param _l2Token Address of the corresponding token on L2.
* @param _from Address of the depositor. * @param _from Address of the depositor.
* @param _to Address of the recipient on L2. * @param _to Address of the recipient on L2.
* @param _amount Amount of the ERC20 deposited. * @param _amount Amount of the ERC20 deposited.
* @param _data Extra data attached to the deposit. * @param _extraData Extra data attached to the deposit.
*/ */
event DepositFinalized( event DepositFinalized(
address indexed _l1Token, address indexed _l1Token,
...@@ -55,19 +55,19 @@ contract L2StandardBridge is StandardBridge { ...@@ -55,19 +55,19 @@ contract L2StandardBridge is StandardBridge {
address indexed _from, address indexed _from,
address _to, address _to,
uint256 _amount, uint256 _amount,
bytes _data bytes _extraData
); );
/** /**
* @custom:legacy * @custom:legacy
* @notice Emitted whenever a deposit fails. * @notice Emitted whenever a deposit fails.
* *
* @param _l1Token Address of the token on L1. * @param _l1Token Address of the token on L1.
* @param _l2Token Address of the corresponding token on L2. * @param _l2Token Address of the corresponding token on L2.
* @param _from Address of the depositor. * @param _from Address of the depositor.
* @param _to Address of the recipient on L2. * @param _to Address of the recipient on L2.
* @param _amount Amount of the ERC20 deposited. * @param _amount Amount of the ERC20 deposited.
* @param _data Extra data attached to the deposit. * @param _extraData Extra data attached to the deposit.
*/ */
event DepositFailed( event DepositFailed(
address indexed _l1Token, address indexed _l1Token,
...@@ -75,7 +75,7 @@ contract L2StandardBridge is StandardBridge { ...@@ -75,7 +75,7 @@ contract L2StandardBridge is StandardBridge {
address indexed _from, address indexed _from,
address _to, address _to,
uint256 _amount, uint256 _amount,
bytes _data bytes _extraData
); );
/** /**
...@@ -94,15 +94,15 @@ contract L2StandardBridge is StandardBridge { ...@@ -94,15 +94,15 @@ contract L2StandardBridge is StandardBridge {
* @param _l2Token Address of the L2 token to withdraw. * @param _l2Token Address of the L2 token to withdraw.
* @param _amount Amount of the L2 token to withdraw. * @param _amount Amount of the L2 token to withdraw.
* @param _minGasLimit Minimum gas limit to use for the transaction. * @param _minGasLimit Minimum gas limit to use for the transaction.
* @param _data Extra data attached to the withdrawal. * @param _extraData Extra data attached to the withdrawal.
*/ */
function withdraw( function withdraw(
address _l2Token, address _l2Token,
uint256 _amount, uint256 _amount,
uint32 _minGasLimit, uint32 _minGasLimit,
bytes calldata _data bytes calldata _extraData
) external payable virtual onlyEOA { ) external payable virtual onlyEOA {
_initiateWithdrawal(_l2Token, msg.sender, msg.sender, _amount, _minGasLimit, _data); _initiateWithdrawal(_l2Token, msg.sender, msg.sender, _amount, _minGasLimit, _extraData);
} }
/** /**
...@@ -117,28 +117,28 @@ contract L2StandardBridge is StandardBridge { ...@@ -117,28 +117,28 @@ contract L2StandardBridge is StandardBridge {
* @param _to Recipient account on L1. * @param _to Recipient account on L1.
* @param _amount Amount of the L2 token to withdraw. * @param _amount Amount of the L2 token to withdraw.
* @param _minGasLimit Minimum gas limit to use for the transaction. * @param _minGasLimit Minimum gas limit to use for the transaction.
* @param _data Extra data attached to the withdrawal. * @param _extraData Extra data attached to the withdrawal.
*/ */
function withdrawTo( function withdrawTo(
address _l2Token, address _l2Token,
address _to, address _to,
uint256 _amount, uint256 _amount,
uint32 _minGasLimit, uint32 _minGasLimit,
bytes calldata _data bytes calldata _extraData
) external payable virtual { ) external payable virtual {
_initiateWithdrawal(_l2Token, msg.sender, _to, _amount, _minGasLimit, _data); _initiateWithdrawal(_l2Token, msg.sender, _to, _amount, _minGasLimit, _extraData);
} }
/** /**
* @custom:legacy * @custom:legacy
* @notice Finalizes a deposit from L1 to L2. * @notice Finalizes a deposit from L1 to L2.
* *
* @param _l1Token Address of the L1 token to deposit. * @param _l1Token Address of the L1 token to deposit.
* @param _l2Token Address of the corresponding L2 token. * @param _l2Token Address of the corresponding L2 token.
* @param _from Address of the depositor. * @param _from Address of the depositor.
* @param _to Address of the recipient. * @param _to Address of the recipient.
* @param _amount Amount of the tokens being deposited. * @param _amount Amount of the tokens being deposited.
* @param _data Extra data attached to the deposit. * @param _extraData Extra data attached to the deposit.
*/ */
function finalizeDeposit( function finalizeDeposit(
address _l1Token, address _l1Token,
...@@ -146,14 +146,14 @@ contract L2StandardBridge is StandardBridge { ...@@ -146,14 +146,14 @@ contract L2StandardBridge is StandardBridge {
address _from, address _from,
address _to, address _to,
uint256 _amount, uint256 _amount,
bytes calldata _data bytes calldata _extraData
) external payable virtual { ) external payable virtual {
if (_l1Token == address(0) && _l2Token == Lib_PredeployAddresses.OVM_ETH) { if (_l1Token == address(0) && _l2Token == Lib_PredeployAddresses.OVM_ETH) {
finalizeBridgeETH(_from, _to, _amount, _data); finalizeBridgeETH(_from, _to, _amount, _extraData);
} else { } else {
finalizeBridgeERC20(_l2Token, _l1Token, _from, _to, _amount, _data); finalizeBridgeERC20(_l2Token, _l1Token, _from, _to, _amount, _extraData);
} }
emit DepositFinalized(_l1Token, _l2Token, _from, _to, _amount, _data); emit DepositFinalized(_l1Token, _l2Token, _from, _to, _amount, _extraData);
} }
/** /**
...@@ -165,7 +165,7 @@ contract L2StandardBridge is StandardBridge { ...@@ -165,7 +165,7 @@ contract L2StandardBridge is StandardBridge {
* @param _to Recipient account on L1. * @param _to Recipient account on L1.
* @param _amount Amount of the L2 token to withdraw. * @param _amount Amount of the L2 token to withdraw.
* @param _minGasLimit Minimum gas limit to use for the transaction. * @param _minGasLimit Minimum gas limit to use for the transaction.
* @param _data Extra data attached to the withdrawal. * @param _extraData Extra data attached to the withdrawal.
*/ */
function _initiateWithdrawal( function _initiateWithdrawal(
address _l2Token, address _l2Token,
...@@ -173,15 +173,15 @@ contract L2StandardBridge is StandardBridge { ...@@ -173,15 +173,15 @@ contract L2StandardBridge is StandardBridge {
address _to, address _to,
uint256 _amount, uint256 _amount,
uint32 _minGasLimit, uint32 _minGasLimit,
bytes calldata _data bytes calldata _extraData
) internal { ) internal {
address l1Token = OptimismMintableERC20(_l2Token).l1Token(); address l1Token = OptimismMintableERC20(_l2Token).l1Token();
if (_l2Token == Lib_PredeployAddresses.OVM_ETH) { if (_l2Token == Lib_PredeployAddresses.OVM_ETH) {
require(msg.value == _amount, "ETH withdrawals must include sufficient ETH value."); require(msg.value == _amount, "ETH withdrawals must include sufficient ETH value.");
_initiateBridgeETH(_from, _to, _amount, _minGasLimit, _data); _initiateBridgeETH(_from, _to, _amount, _minGasLimit, _extraData);
} else { } else {
_initiateBridgeERC20(_l2Token, l1Token, _from, _to, _amount, _minGasLimit, _data); _initiateBridgeERC20(_l2Token, l1Token, _from, _to, _amount, _minGasLimit, _extraData);
} }
emit WithdrawalInitiated(l1Token, _l2Token, _from, _to, _amount, _data); emit WithdrawalInitiated(l1Token, _l2Token, _from, _to, _amount, _extraData);
} }
} }
...@@ -31,14 +31,14 @@ abstract contract StandardBridge { ...@@ -31,14 +31,14 @@ abstract contract StandardBridge {
address indexed _from, address indexed _from,
address indexed _to, address indexed _to,
uint256 _amount, uint256 _amount,
bytes _data bytes _extraData
); );
event ETHBridgeFinalized( event ETHBridgeFinalized(
address indexed _from, address indexed _from,
address indexed _to, address indexed _to,
uint256 _amount, uint256 _amount,
bytes _data bytes _extraData
); );
event ERC20BridgeInitiated( event ERC20BridgeInitiated(
...@@ -47,7 +47,7 @@ abstract contract StandardBridge { ...@@ -47,7 +47,7 @@ abstract contract StandardBridge {
address indexed _from, address indexed _from,
address _to, address _to,
uint256 _amount, uint256 _amount,
bytes _data bytes _extraData
); );
event ERC20BridgeFinalized( event ERC20BridgeFinalized(
...@@ -56,7 +56,7 @@ abstract contract StandardBridge { ...@@ -56,7 +56,7 @@ abstract contract StandardBridge {
address indexed _from, address indexed _from,
address _to, address _to,
uint256 _amount, uint256 _amount,
bytes _data bytes _extraData
); );
event ERC20BridgeFailed( event ERC20BridgeFailed(
...@@ -65,7 +65,7 @@ abstract contract StandardBridge { ...@@ -65,7 +65,7 @@ abstract contract StandardBridge {
address indexed _from, address indexed _from,
address _to, address _to,
uint256 _amount, uint256 _amount,
bytes _data bytes _extraData
); );
/************* /*************
...@@ -139,8 +139,8 @@ abstract contract StandardBridge { ...@@ -139,8 +139,8 @@ abstract contract StandardBridge {
/** /**
* @notice Send ETH to the message sender on the remote domain * @notice Send ETH to the message sender on the remote domain
*/ */
function bridgeETH(uint32 _minGasLimit, bytes calldata _data) public payable onlyEOA { function bridgeETH(uint32 _minGasLimit, bytes calldata _extraData) public payable onlyEOA {
_initiateBridgeETH(msg.sender, msg.sender, msg.value, _minGasLimit, _data); _initiateBridgeETH(msg.sender, msg.sender, msg.value, _minGasLimit, _extraData);
} }
/** /**
...@@ -150,9 +150,9 @@ abstract contract StandardBridge { ...@@ -150,9 +150,9 @@ abstract contract StandardBridge {
function bridgeETHTo( function bridgeETHTo(
address _to, address _to,
uint32 _minGasLimit, uint32 _minGasLimit,
bytes calldata _data bytes calldata _extraData
) public payable { ) public payable {
_initiateBridgeETH(msg.sender, _to, msg.value, _minGasLimit, _data); _initiateBridgeETH(msg.sender, _to, msg.value, _minGasLimit, _extraData);
} }
/** /**
...@@ -163,7 +163,7 @@ abstract contract StandardBridge { ...@@ -163,7 +163,7 @@ abstract contract StandardBridge {
address _remoteToken, address _remoteToken,
uint256 _amount, uint256 _amount,
uint32 _minGasLimit, uint32 _minGasLimit,
bytes calldata _data bytes calldata _extraData
) public virtual onlyEOA { ) public virtual onlyEOA {
_initiateBridgeERC20( _initiateBridgeERC20(
_localToken, _localToken,
...@@ -172,7 +172,7 @@ abstract contract StandardBridge { ...@@ -172,7 +172,7 @@ abstract contract StandardBridge {
msg.sender, msg.sender,
_amount, _amount,
_minGasLimit, _minGasLimit,
_data _extraData
); );
} }
...@@ -185,7 +185,7 @@ abstract contract StandardBridge { ...@@ -185,7 +185,7 @@ abstract contract StandardBridge {
address _to, address _to,
uint256 _amount, uint256 _amount,
uint32 _minGasLimit, uint32 _minGasLimit,
bytes calldata _data bytes calldata _extraData
) public virtual { ) public virtual {
_initiateBridgeERC20( _initiateBridgeERC20(
_localToken, _localToken,
...@@ -194,7 +194,7 @@ abstract contract StandardBridge { ...@@ -194,7 +194,7 @@ abstract contract StandardBridge {
_to, _to,
_amount, _amount,
_minGasLimit, _minGasLimit,
_data _extraData
); );
} }
...@@ -205,12 +205,12 @@ abstract contract StandardBridge { ...@@ -205,12 +205,12 @@ abstract contract StandardBridge {
address _from, address _from,
address _to, address _to,
uint256 _amount, uint256 _amount,
bytes calldata _data bytes calldata _extraData
) public payable onlyOtherBridge { ) public payable onlyOtherBridge {
require(msg.value == _amount, "Amount sent does not match amount required."); require(msg.value == _amount, "Amount sent does not match amount required.");
require(_to != address(this), "Cannot send to self."); require(_to != address(this), "Cannot send to self.");
emit ETHBridgeFinalized(_from, _to, _amount, _data); emit ETHBridgeFinalized(_from, _to, _amount, _extraData);
(bool success, ) = _to.call{ value: _amount }(new bytes(0)); (bool success, ) = _to.call{ value: _amount }(new bytes(0));
require(success, "ETH transfer failed."); require(success, "ETH transfer failed.");
} }
...@@ -224,10 +224,10 @@ abstract contract StandardBridge { ...@@ -224,10 +224,10 @@ abstract contract StandardBridge {
address _from, address _from,
address _to, address _to,
uint256 _amount, uint256 _amount,
bytes calldata _data bytes calldata _extraData
) public onlyOtherBridge { ) public onlyOtherBridge {
try this.completeOutboundTransfer(_localToken, _remoteToken, _to, _amount) { try this.completeOutboundTransfer(_localToken, _remoteToken, _to, _amount) {
emit ERC20BridgeFinalized(_localToken, _remoteToken, _from, _to, _amount, _data); emit ERC20BridgeFinalized(_localToken, _remoteToken, _from, _to, _amount, _extraData);
} catch { } catch {
// Something went wrong during the bridging process, return to sender. // Something went wrong during the bridging process, return to sender.
// Can happen if a bridge UI specifies the wrong L2 token. // Can happen if a bridge UI specifies the wrong L2 token.
...@@ -240,9 +240,9 @@ abstract contract StandardBridge { ...@@ -240,9 +240,9 @@ abstract contract StandardBridge {
_from, _from,
_amount, _amount,
0, // _minGasLimit, 0 is fine here 0, // _minGasLimit, 0 is fine here
_data _extraData
); );
emit ERC20BridgeFailed(_localToken, _remoteToken, _from, _to, _amount, _data); emit ERC20BridgeFailed(_localToken, _remoteToken, _from, _to, _amount, _extraData);
} }
} }
...@@ -293,13 +293,19 @@ abstract contract StandardBridge { ...@@ -293,13 +293,19 @@ abstract contract StandardBridge {
address _to, address _to,
uint256 _amount, uint256 _amount,
uint32 _minGasLimit, uint32 _minGasLimit,
bytes memory _data bytes memory _extraData
) internal { ) internal {
emit ETHBridgeInitiated(_from, _to, _amount, _data); emit ETHBridgeInitiated(_from, _to, _amount, _extraData);
messenger.sendMessage{ value: _amount }( messenger.sendMessage{ value: _amount }(
address(otherBridge), address(otherBridge),
abi.encodeWithSelector(this.finalizeBridgeETH.selector, _from, _to, _amount, _data), abi.encodeWithSelector(
this.finalizeBridgeETH.selector,
_from,
_to,
_amount,
_extraData
),
_minGasLimit _minGasLimit
); );
} }
...@@ -314,7 +320,7 @@ abstract contract StandardBridge { ...@@ -314,7 +320,7 @@ abstract contract StandardBridge {
address _to, address _to,
uint256 _amount, uint256 _amount,
uint32 _minGasLimit, uint32 _minGasLimit,
bytes calldata _data bytes calldata _extraData
) internal { ) internal {
// Make sure external function calls can't be used to trigger calls to // Make sure external function calls can't be used to trigger calls to
// completeOutboundTransfer. We only make external (write) calls to _localToken. // completeOutboundTransfer. We only make external (write) calls to _localToken.
...@@ -340,7 +346,7 @@ abstract contract StandardBridge { ...@@ -340,7 +346,7 @@ abstract contract StandardBridge {
_to, _to,
_amount, _amount,
_minGasLimit, _minGasLimit,
_data _extraData
); );
} }
...@@ -354,7 +360,7 @@ abstract contract StandardBridge { ...@@ -354,7 +360,7 @@ abstract contract StandardBridge {
address _to, address _to,
uint256 _amount, uint256 _amount,
uint32 _minGasLimit, uint32 _minGasLimit,
bytes calldata _data bytes calldata _extraData
) internal { ) internal {
messenger.sendMessage( messenger.sendMessage(
address(otherBridge), address(otherBridge),
...@@ -368,12 +374,12 @@ abstract contract StandardBridge { ...@@ -368,12 +374,12 @@ abstract contract StandardBridge {
_from, _from,
_to, _to,
_amount, _amount,
_data _extraData
), ),
_minGasLimit _minGasLimit
); );
emit ERC20BridgeInitiated(_localToken, _remoteToken, _from, _to, _amount, _data); emit ERC20BridgeInitiated(_localToken, _remoteToken, _from, _to, _amount, _extraData);
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment