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 {
* @custom:legacy
* @notice Emitted whenever a withdrawal from L2 to L1 is initiated.
*
* @param _l1Token Address of the token on L1.
* @param _l2Token Address of the corresponding token on L2.
* @param _from Address of the withdrawer.
* @param _to Address of the recipient on L1.
* @param _amount Amount of the ERC20 withdrawn.
* @param _data Extra data attached to the withdrawal.
* @param _l1Token Address of the token on L1.
* @param _l2Token Address of the corresponding token on L2.
* @param _from Address of the withdrawer.
* @param _to Address of the recipient on L1.
* @param _amount Amount of the ERC20 withdrawn.
* @param _extraData Extra data attached to the withdrawal.
*/
event WithdrawalInitiated(
address indexed _l1Token,
......@@ -35,19 +35,19 @@ contract L2StandardBridge is StandardBridge {
address indexed _from,
address _to,
uint256 _amount,
bytes _data
bytes _extraData
);
/**
* @custom:legacy
* @notice Emitted whenever an ERC20 deposit is finalized.
*
* @param _l1Token Address of the token on L1.
* @param _l2Token Address of the corresponding token on L2.
* @param _from Address of the depositor.
* @param _to Address of the recipient on L2.
* @param _amount Amount of the ERC20 deposited.
* @param _data Extra data attached to the deposit.
* @param _l1Token Address of the token on L1.
* @param _l2Token Address of the corresponding token on L2.
* @param _from Address of the depositor.
* @param _to Address of the recipient on L2.
* @param _amount Amount of the ERC20 deposited.
* @param _extraData Extra data attached to the deposit.
*/
event DepositFinalized(
address indexed _l1Token,
......@@ -55,19 +55,19 @@ contract L2StandardBridge is StandardBridge {
address indexed _from,
address _to,
uint256 _amount,
bytes _data
bytes _extraData
);
/**
* @custom:legacy
* @notice Emitted whenever a deposit fails.
*
* @param _l1Token Address of the token on L1.
* @param _l2Token Address of the corresponding token on L2.
* @param _from Address of the depositor.
* @param _to Address of the recipient on L2.
* @param _amount Amount of the ERC20 deposited.
* @param _data Extra data attached to the deposit.
* @param _l1Token Address of the token on L1.
* @param _l2Token Address of the corresponding token on L2.
* @param _from Address of the depositor.
* @param _to Address of the recipient on L2.
* @param _amount Amount of the ERC20 deposited.
* @param _extraData Extra data attached to the deposit.
*/
event DepositFailed(
address indexed _l1Token,
......@@ -75,7 +75,7 @@ contract L2StandardBridge is StandardBridge {
address indexed _from,
address _to,
uint256 _amount,
bytes _data
bytes _extraData
);
/**
......@@ -94,15 +94,15 @@ contract L2StandardBridge is StandardBridge {
* @param _l2Token Address 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 _data Extra data attached to the withdrawal.
* @param _extraData Extra data attached to the withdrawal.
*/
function withdraw(
address _l2Token,
uint256 _amount,
uint32 _minGasLimit,
bytes calldata _data
bytes calldata _extraData
) 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 {
* @param _to Recipient account on L1.
* @param _amount Amount of the L2 token to withdraw.
* @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(
address _l2Token,
address _to,
uint256 _amount,
uint32 _minGasLimit,
bytes calldata _data
bytes calldata _extraData
) external payable virtual {
_initiateWithdrawal(_l2Token, msg.sender, _to, _amount, _minGasLimit, _data);
_initiateWithdrawal(_l2Token, msg.sender, _to, _amount, _minGasLimit, _extraData);
}
/**
* @custom:legacy
* @notice Finalizes a deposit from L1 to L2.
*
* @param _l1Token Address of the L1 token to deposit.
* @param _l2Token Address of the corresponding L2 token.
* @param _from Address of the depositor.
* @param _to Address of the recipient.
* @param _amount Amount of the tokens being deposited.
* @param _data Extra data attached to the deposit.
* @param _l1Token Address of the L1 token to deposit.
* @param _l2Token Address of the corresponding L2 token.
* @param _from Address of the depositor.
* @param _to Address of the recipient.
* @param _amount Amount of the tokens being deposited.
* @param _extraData Extra data attached to the deposit.
*/
function finalizeDeposit(
address _l1Token,
......@@ -146,14 +146,14 @@ contract L2StandardBridge is StandardBridge {
address _from,
address _to,
uint256 _amount,
bytes calldata _data
bytes calldata _extraData
) external payable virtual {
if (_l1Token == address(0) && _l2Token == Lib_PredeployAddresses.OVM_ETH) {
finalizeBridgeETH(_from, _to, _amount, _data);
finalizeBridgeETH(_from, _to, _amount, _extraData);
} 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 {
* @param _to Recipient account on L1.
* @param _amount Amount of the L2 token to withdraw.
* @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(
address _l2Token,
......@@ -173,15 +173,15 @@ contract L2StandardBridge is StandardBridge {
address _to,
uint256 _amount,
uint32 _minGasLimit,
bytes calldata _data
bytes calldata _extraData
) internal {
address l1Token = OptimismMintableERC20(_l2Token).l1Token();
if (_l2Token == Lib_PredeployAddresses.OVM_ETH) {
require(msg.value == _amount, "ETH withdrawals must include sufficient ETH value.");
_initiateBridgeETH(_from, _to, _amount, _minGasLimit, _data);
_initiateBridgeETH(_from, _to, _amount, _minGasLimit, _extraData);
} 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 {
address indexed _from,
address indexed _to,
uint256 _amount,
bytes _data
bytes _extraData
);
event ETHBridgeFinalized(
address indexed _from,
address indexed _to,
uint256 _amount,
bytes _data
bytes _extraData
);
event ERC20BridgeInitiated(
......@@ -47,7 +47,7 @@ abstract contract StandardBridge {
address indexed _from,
address _to,
uint256 _amount,
bytes _data
bytes _extraData
);
event ERC20BridgeFinalized(
......@@ -56,7 +56,7 @@ abstract contract StandardBridge {
address indexed _from,
address _to,
uint256 _amount,
bytes _data
bytes _extraData
);
event ERC20BridgeFailed(
......@@ -65,7 +65,7 @@ abstract contract StandardBridge {
address indexed _from,
address _to,
uint256 _amount,
bytes _data
bytes _extraData
);
/*************
......@@ -139,8 +139,8 @@ abstract contract StandardBridge {
/**
* @notice Send ETH to the message sender on the remote domain
*/
function bridgeETH(uint32 _minGasLimit, bytes calldata _data) public payable onlyEOA {
_initiateBridgeETH(msg.sender, msg.sender, msg.value, _minGasLimit, _data);
function bridgeETH(uint32 _minGasLimit, bytes calldata _extraData) public payable onlyEOA {
_initiateBridgeETH(msg.sender, msg.sender, msg.value, _minGasLimit, _extraData);
}
/**
......@@ -150,9 +150,9 @@ abstract contract StandardBridge {
function bridgeETHTo(
address _to,
uint32 _minGasLimit,
bytes calldata _data
bytes calldata _extraData
) 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 {
address _remoteToken,
uint256 _amount,
uint32 _minGasLimit,
bytes calldata _data
bytes calldata _extraData
) public virtual onlyEOA {
_initiateBridgeERC20(
_localToken,
......@@ -172,7 +172,7 @@ abstract contract StandardBridge {
msg.sender,
_amount,
_minGasLimit,
_data
_extraData
);
}
......@@ -185,7 +185,7 @@ abstract contract StandardBridge {
address _to,
uint256 _amount,
uint32 _minGasLimit,
bytes calldata _data
bytes calldata _extraData
) public virtual {
_initiateBridgeERC20(
_localToken,
......@@ -194,7 +194,7 @@ abstract contract StandardBridge {
_to,
_amount,
_minGasLimit,
_data
_extraData
);
}
......@@ -205,12 +205,12 @@ abstract contract StandardBridge {
address _from,
address _to,
uint256 _amount,
bytes calldata _data
bytes calldata _extraData
) public payable onlyOtherBridge {
require(msg.value == _amount, "Amount sent does not match amount required.");
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));
require(success, "ETH transfer failed.");
}
......@@ -224,10 +224,10 @@ abstract contract StandardBridge {
address _from,
address _to,
uint256 _amount,
bytes calldata _data
bytes calldata _extraData
) public onlyOtherBridge {
try this.completeOutboundTransfer(_localToken, _remoteToken, _to, _amount) {
emit ERC20BridgeFinalized(_localToken, _remoteToken, _from, _to, _amount, _data);
emit ERC20BridgeFinalized(_localToken, _remoteToken, _from, _to, _amount, _extraData);
} catch {
// Something went wrong during the bridging process, return to sender.
// Can happen if a bridge UI specifies the wrong L2 token.
......@@ -240,9 +240,9 @@ abstract contract StandardBridge {
_from,
_amount,
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 {
address _to,
uint256 _amount,
uint32 _minGasLimit,
bytes memory _data
bytes memory _extraData
) internal {
emit ETHBridgeInitiated(_from, _to, _amount, _data);
emit ETHBridgeInitiated(_from, _to, _amount, _extraData);
messenger.sendMessage{ value: _amount }(
address(otherBridge),
abi.encodeWithSelector(this.finalizeBridgeETH.selector, _from, _to, _amount, _data),
abi.encodeWithSelector(
this.finalizeBridgeETH.selector,
_from,
_to,
_amount,
_extraData
),
_minGasLimit
);
}
......@@ -314,7 +320,7 @@ abstract contract StandardBridge {
address _to,
uint256 _amount,
uint32 _minGasLimit,
bytes calldata _data
bytes calldata _extraData
) internal {
// Make sure external function calls can't be used to trigger calls to
// completeOutboundTransfer. We only make external (write) calls to _localToken.
......@@ -340,7 +346,7 @@ abstract contract StandardBridge {
_to,
_amount,
_minGasLimit,
_data
_extraData
);
}
......@@ -354,7 +360,7 @@ abstract contract StandardBridge {
address _to,
uint256 _amount,
uint32 _minGasLimit,
bytes calldata _data
bytes calldata _extraData
) internal {
messenger.sendMessage(
address(otherBridge),
......@@ -368,12 +374,12 @@ abstract contract StandardBridge {
_from,
_to,
_amount,
_data
_extraData
),
_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