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
......@@ -16,44 +16,44 @@ contract L1StandardBridge is StandardBridge {
* @custom:legacy
* @notice Emitted whenever a deposit of ETH from L1 into L2 is initiated.
*
* @param _from Address of the depositor.
* @param _to Address of the recipient on L2.
* @param _amount Amount of ETH deposited.
* @param _data Extra data attached to the deposit.
* @param _from Address of the depositor.
* @param _to Address of the recipient on L2.
* @param _amount Amount of ETH deposited.
* @param _extraData Extra data attached to the deposit.
*/
event ETHDepositInitiated(
address indexed _from,
address indexed _to,
uint256 _amount,
bytes _data
bytes _extraData
);
/**
* @custom:legacy
* @notice Emitted whenever a withdrawal of ETH from L2 to L1 is finalized.
*
* @param _from Address of the withdrawer.
* @param _to Address of the recipient on L1.
* @param _amount Amount of ETH withdrawn.
* @param _data Extra data attached to the withdrawal.
* @param _from Address of the withdrawer.
* @param _to Address of the recipient on L1.
* @param _amount Amount of ETH withdrawn.
* @param _extraData Extra data attached to the withdrawal.
*/
event ETHWithdrawalFinalized(
address indexed _from,
address indexed _to,
uint256 _amount,
bytes _data
bytes _extraData
);
/**
* @custom:legacy
* @notice Emitted whenever an ERC20 deposit is initiated.
*
* @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 ERC20DepositInitiated(
address indexed _l1Token,
......@@ -61,19 +61,19 @@ contract L1StandardBridge is StandardBridge {
address indexed _from,
address _to,
uint256 _amount,
bytes _data
bytes _extraData
);
/**
* @custom:legacy
* @notice Emitted whenever an ERC20 withdrawal is finalized.
*
* @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 ERC20WithdrawalFinalized(
address indexed _l1Token,
......@@ -81,7 +81,7 @@ contract L1StandardBridge is StandardBridge {
address indexed _from,
address _to,
uint256 _amount,
bytes _data
bytes _extraData
);
/**
......@@ -108,12 +108,12 @@ contract L1StandardBridge is StandardBridge {
* @notice Deposits some amount of ETH into the sender's account on L2.
*
* @param _minGasLimit Minimum gas limit for the deposit message on L2.
* @param _data Optional data to forward to L2. Data supplied here will not be used to
* @param _extraData Optional data to forward to L2. Data supplied here will not be used to
* execute any code on L2 and is only emitted as extra data for the
* convenience of off-chain tooling.
*/
function depositETH(uint32 _minGasLimit, bytes calldata _data) external payable onlyEOA {
_initiateETHDeposit(msg.sender, msg.sender, _minGasLimit, _data);
function depositETH(uint32 _minGasLimit, bytes calldata _extraData) external payable onlyEOA {
_initiateETHDeposit(msg.sender, msg.sender, _minGasLimit, _extraData);
}
/**
......@@ -126,16 +126,16 @@ contract L1StandardBridge is StandardBridge {
*
* @param _to Address of the recipient on L2.
* @param _minGasLimit Minimum gas limit for the deposit message on L2.
* @param _data Optional data to forward to L2. Data supplied here will not be used to
* @param _extraData Optional data to forward to L2. Data supplied here will not be used to
* execute any code on L2 and is only emitted as extra data for the
* convenience of off-chain tooling.
*/
function depositETHTo(
address _to,
uint32 _minGasLimit,
bytes calldata _data
bytes calldata _extraData
) external payable {
_initiateETHDeposit(msg.sender, _to, _minGasLimit, _data);
_initiateETHDeposit(msg.sender, _to, _minGasLimit, _extraData);
}
/**
......@@ -146,7 +146,7 @@ contract L1StandardBridge is StandardBridge {
* @param _l2Token Address of the corresponding token on L2.
* @param _amount Amount of the ERC20 to deposit.
* @param _minGasLimit Minimum gas limit for the deposit message on L2.
* @param _data Optional data to forward to L2. Data supplied here will not be used to
* @param _extraData Optional data to forward to L2. Data supplied here will not be used to
* execute any code on L2 and is only emitted as extra data for the
* convenience of off-chain tooling.
*/
......@@ -155,7 +155,7 @@ contract L1StandardBridge is StandardBridge {
address _l2Token,
uint256 _amount,
uint32 _minGasLimit,
bytes calldata _data
bytes calldata _extraData
) external virtual onlyEOA {
_initiateERC20Deposit(
_l1Token,
......@@ -164,7 +164,7 @@ contract L1StandardBridge is StandardBridge {
msg.sender,
_amount,
_minGasLimit,
_data
_extraData
);
}
......@@ -177,7 +177,7 @@ contract L1StandardBridge is StandardBridge {
* @param _to Address of the recipient on L2.
* @param _amount Amount of the ERC20 to deposit.
* @param _minGasLimit Minimum gas limit for the deposit message on L2.
* @param _data Optional data to forward to L2. Data supplied here will not be used to
* @param _extraData Optional data to forward to L2. Data supplied here will not be used to
* execute any code on L2 and is only emitted as extra data for the
* convenience of off-chain tooling.
*/
......@@ -187,40 +187,48 @@ contract L1StandardBridge is StandardBridge {
address _to,
uint256 _amount,
uint32 _minGasLimit,
bytes calldata _data
bytes calldata _extraData
) external virtual {
_initiateERC20Deposit(_l1Token, _l2Token, msg.sender, _to, _amount, _minGasLimit, _data);
_initiateERC20Deposit(
_l1Token,
_l2Token,
msg.sender,
_to,
_amount,
_minGasLimit,
_extraData
);
}
/**
* @custom:legacy
* @notice Finalizes a withdrawal of ETH from L2.
*
* @param _from Address of the withdrawer on L2.
* @param _to Address of the recipient on L1.
* @param _amount Amount of ETH to withdraw.
* @param _data Optional data forwarded from L2.
* @param _from Address of the withdrawer on L2.
* @param _to Address of the recipient on L1.
* @param _amount Amount of ETH to withdraw.
* @param _extraData Optional data forwarded from L2.
*/
function finalizeETHWithdrawal(
address _from,
address _to,
uint256 _amount,
bytes calldata _data
bytes calldata _extraData
) external payable onlyOtherBridge {
emit ETHWithdrawalFinalized(_from, _to, _amount, _data);
finalizeBridgeETH(_from, _to, _amount, _data);
emit ETHWithdrawalFinalized(_from, _to, _amount, _extraData);
finalizeBridgeETH(_from, _to, _amount, _extraData);
}
/**
* @custom:legacy
* @notice Finalizes a withdrawal of ERC20 tokens from L2.
*
* @param _l1Token Address of the token on L1.
* @param _l2Token Address of the corresponding token on L2.
* @param _from Address of the withdrawer on L2.
* @param _to Address of the recipient on L1.
* @param _amount Amount of ETH to withdraw.
* @param _data Optional data forwarded from L2.
* @param _l1Token Address of the token on L1.
* @param _l2Token Address of the corresponding token on L2.
* @param _from Address of the withdrawer on L2.
* @param _to Address of the recipient on L1.
* @param _amount Amount of ETH to withdraw.
* @param _extraData Optional data forwarded from L2.
*/
function finalizeERC20Withdrawal(
address _l1Token,
......@@ -228,10 +236,10 @@ contract L1StandardBridge is StandardBridge {
address _from,
address _to,
uint256 _amount,
bytes calldata _data
bytes calldata _extraData
) external onlyOtherBridge {
emit ERC20WithdrawalFinalized(_l1Token, _l2Token, _from, _to, _amount, _data);
finalizeBridgeERC20(_l1Token, _l2Token, _from, _to, _amount, _data);
emit ERC20WithdrawalFinalized(_l1Token, _l2Token, _from, _to, _amount, _extraData);
finalizeBridgeERC20(_l1Token, _l2Token, _from, _to, _amount, _extraData);
}
/**
......@@ -240,16 +248,16 @@ contract L1StandardBridge is StandardBridge {
* @param _from Address of the sender on L1.
* @param _to Address of the recipient on L2.
* @param _minGasLimit Minimum gas limit for the deposit message on L2.
* @param _data Optional data to forward to L2.
* @param _extraData Optional data to forward to L2.
*/
function _initiateETHDeposit(
address _from,
address _to,
uint32 _minGasLimit,
bytes memory _data
bytes memory _extraData
) internal {
emit ETHDepositInitiated(_from, _to, msg.value, _data);
_initiateBridgeETH(_from, _to, msg.value, _minGasLimit, _data);
emit ETHDepositInitiated(_from, _to, msg.value, _extraData);
_initiateBridgeETH(_from, _to, msg.value, _minGasLimit, _extraData);
}
/**
......@@ -261,7 +269,7 @@ contract L1StandardBridge is StandardBridge {
* @param _to Address of the recipient on L2.
* @param _amount Amount of the ERC20 to deposit.
* @param _minGasLimit Minimum gas limit for the deposit message on L2.
* @param _data Optional data to forward to L2.
* @param _extraData Optional data to forward to L2.
*/
function _initiateERC20Deposit(
address _l1Token,
......@@ -270,9 +278,9 @@ contract L1StandardBridge is StandardBridge {
address _to,
uint256 _amount,
uint32 _minGasLimit,
bytes calldata _data
bytes calldata _extraData
) internal {
emit ERC20DepositInitiated(_l1Token, _l2Token, _from, _to, _amount, _data);
_initiateBridgeERC20(_l1Token, _l2Token, _from, _to, _amount, _minGasLimit, _data);
emit ERC20DepositInitiated(_l1Token, _l2Token, _from, _to, _amount, _extraData);
_initiateBridgeERC20(_l1Token, _l2Token, _from, _to, _amount, _minGasLimit, _extraData);
}
}
......@@ -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