Commit 358c37cf authored by Maurelian's avatar Maurelian

fix(ctb): Add _emit functions to support legacy events

fix(ctb): Add _emitETHBridgeInitiated

fix(ctb): Add _emitERC20BridgeFinalized

fix(ctb): Add remaining event wrapper functions
parent 36eeae15
This diff is collapsed.
This diff is collapsed.
...@@ -126,7 +126,6 @@ contract L1StandardBridge is StandardBridge, Semver { ...@@ -126,7 +126,6 @@ contract L1StandardBridge is StandardBridge, Semver {
uint256 _amount, uint256 _amount,
bytes calldata _extraData bytes calldata _extraData
) external onlyOtherBridge { ) external onlyOtherBridge {
emit ERC20WithdrawalFinalized(_l1Token, _l2Token, _from, _to, _amount, _extraData);
finalizeBridgeERC20(_l1Token, _l2Token, _from, _to, _amount, _extraData); finalizeBridgeERC20(_l1Token, _l2Token, _from, _to, _amount, _extraData);
} }
...@@ -242,7 +241,6 @@ contract L1StandardBridge is StandardBridge, Semver { ...@@ -242,7 +241,6 @@ contract L1StandardBridge is StandardBridge, Semver {
uint256 _amount, uint256 _amount,
bytes calldata _extraData bytes calldata _extraData
) external payable onlyOtherBridge { ) external payable onlyOtherBridge {
emit ETHWithdrawalFinalized(_from, _to, _amount, _extraData);
finalizeBridgeETH(_from, _to, _amount, _extraData); finalizeBridgeETH(_from, _to, _amount, _extraData);
} }
...@@ -270,7 +268,6 @@ contract L1StandardBridge is StandardBridge, Semver { ...@@ -270,7 +268,6 @@ contract L1StandardBridge is StandardBridge, Semver {
uint32 _minGasLimit, uint32 _minGasLimit,
bytes memory _extraData bytes memory _extraData
) internal { ) internal {
emit ETHDepositInitiated(_from, _to, msg.value, _extraData);
_initiateBridgeETH(_from, _to, msg.value, _minGasLimit, _extraData); _initiateBridgeETH(_from, _to, msg.value, _minGasLimit, _extraData);
} }
...@@ -294,7 +291,62 @@ contract L1StandardBridge is StandardBridge, Semver { ...@@ -294,7 +291,62 @@ contract L1StandardBridge is StandardBridge, Semver {
uint32 _minGasLimit, uint32 _minGasLimit,
bytes memory _extraData bytes memory _extraData
) internal { ) internal {
emit ERC20DepositInitiated(_l1Token, _l2Token, _from, _to, _amount, _extraData);
_initiateBridgeERC20(_l1Token, _l2Token, _from, _to, _amount, _minGasLimit, _extraData); _initiateBridgeERC20(_l1Token, _l2Token, _from, _to, _amount, _minGasLimit, _extraData);
} }
/**
* @inheritdoc StandardBridge
*/
function _emitETHBridgeInitiated(
address _from,
address _to,
uint256 _amount,
bytes memory _extraData
) internal override {
emit ETHDepositInitiated(_from, _to, _amount, _extraData);
emit ETHBridgeInitiated(_from, _to, _amount, _extraData);
}
/**
* @inheritdoc StandardBridge
*/
function _emitETHBridgeFinalized(
address _from,
address _to,
uint256 _amount,
bytes memory _extraData
) internal override {
emit ETHWithdrawalFinalized(_from, _to, _amount, _extraData);
emit ETHBridgeFinalized(_from, _to, _amount, _extraData);
}
/**
* @inheritdoc StandardBridge
*/
function _emitERC20BridgeInitiated(
address _localToken,
address _remoteToken,
address _from,
address _to,
uint256 _amount,
bytes memory _extraData
) internal override {
emit ERC20DepositInitiated(_localToken, _remoteToken, _from, _to, _amount, _extraData);
emit ERC20BridgeInitiated(_localToken, _remoteToken, _from, _to, _amount, _extraData);
}
/**
* @inheritdoc StandardBridge
*/
function _emitERC20BridgeFinalized(
address _localToken,
address _remoteToken,
address _from,
address _to,
uint256 _amount,
bytes memory _extraData
) internal override {
emit ERC20WithdrawalFinalized(_localToken, _remoteToken, _from, _to, _amount, _extraData);
emit ERC20BridgeFinalized(_localToken, _remoteToken, _from, _to, _amount, _extraData);
}
} }
...@@ -148,8 +148,6 @@ contract L2StandardBridge is StandardBridge, Semver { ...@@ -148,8 +148,6 @@ contract L2StandardBridge is StandardBridge, Semver {
} else { } else {
finalizeBridgeERC20(_l2Token, _l1Token, _from, _to, _amount, _extraData); finalizeBridgeERC20(_l2Token, _l1Token, _from, _to, _amount, _extraData);
} }
emit DepositFinalized(_l1Token, _l2Token, _from, _to, _amount, _extraData);
} }
/** /**
...@@ -187,7 +185,75 @@ contract L2StandardBridge is StandardBridge, Semver { ...@@ -187,7 +185,75 @@ contract L2StandardBridge is StandardBridge, Semver {
} else { } else {
_initiateBridgeERC20(_l2Token, l1Token, _from, _to, _amount, _minGasLimit, _extraData); _initiateBridgeERC20(_l2Token, l1Token, _from, _to, _amount, _minGasLimit, _extraData);
} }
}
/**
* @inheritdoc StandardBridge
*/
function _emitETHBridgeInitiated(
address _from,
address _to,
uint256 _amount,
bytes memory _extraData
) internal override {
emit ETHBridgeInitiated(_from, _to, _amount, _extraData);
emit WithdrawalInitiated(
address(0),
Predeploys.LEGACY_ERC20_ETH,
_from,
_to,
_amount,
_extraData
);
}
/**
* @inheritdoc StandardBridge
*/
function _emitETHBridgeFinalized(
address _from,
address _to,
uint256 _amount,
bytes memory _extraData
) internal override {
emit ETHBridgeFinalized(_from, _to, _amount, _extraData);
emit DepositFinalized(
address(0),
Predeploys.LEGACY_ERC20_ETH,
_from,
_to,
_amount,
_extraData
);
}
/**
* @inheritdoc StandardBridge
*/
function _emitERC20BridgeInitiated(
address _localToken,
address _remoteToken,
address _from,
address _to,
uint256 _amount,
bytes memory _extraData
) internal override {
emit WithdrawalInitiated(_remoteToken, _localToken, _from, _to, _amount, _extraData);
emit ERC20BridgeInitiated(_localToken, _remoteToken, _from, _to, _amount, _extraData);
}
emit WithdrawalInitiated(l1Token, _l2Token, _from, _to, _amount, _extraData); /**
* @inheritdoc StandardBridge
*/
function _emitERC20BridgeFinalized(
address _localToken,
address _remoteToken,
address _from,
address _to,
uint256 _amount,
bytes memory _extraData
) internal override {
emit ERC20BridgeFinalized(_localToken, _remoteToken, _from, _to, _amount, _extraData);
emit DepositFinalized(_remoteToken, _localToken, _from, _to, _amount, _extraData);
} }
} }
...@@ -301,7 +301,7 @@ abstract contract StandardBridge { ...@@ -301,7 +301,7 @@ abstract contract StandardBridge {
require(_to != address(this), "StandardBridge: cannot send to self"); require(_to != address(this), "StandardBridge: cannot send to self");
require(_to != address(MESSENGER), "StandardBridge: cannot send to messenger"); require(_to != address(MESSENGER), "StandardBridge: cannot send to messenger");
emit ETHBridgeFinalized(_from, _to, _amount, _extraData); _emitETHBridgeFinalized(_from, _to, _amount, _extraData);
bool success = SafeCall.call(_to, gasleft(), _amount, hex""); bool success = SafeCall.call(_to, gasleft(), _amount, hex"");
require(success, "StandardBridge: ETH transfer failed"); require(success, "StandardBridge: ETH transfer failed");
...@@ -340,7 +340,7 @@ abstract contract StandardBridge { ...@@ -340,7 +340,7 @@ abstract contract StandardBridge {
IERC20(_localToken).safeTransfer(_to, _amount); IERC20(_localToken).safeTransfer(_to, _amount);
} }
emit ERC20BridgeFinalized(_localToken, _remoteToken, _from, _to, _amount, _extraData); _emitERC20BridgeFinalized(_localToken, _remoteToken, _from, _to, _amount, _extraData);
} }
/** /**
...@@ -366,7 +366,7 @@ abstract contract StandardBridge { ...@@ -366,7 +366,7 @@ abstract contract StandardBridge {
"StandardBridge: bridging ETH must include sufficient ETH value" "StandardBridge: bridging ETH must include sufficient ETH value"
); );
emit ETHBridgeInitiated(_from, _to, _amount, _extraData); _emitETHBridgeInitiated(_from, _to, _amount, _extraData);
MESSENGER.sendMessage{ value: _amount }( MESSENGER.sendMessage{ value: _amount }(
address(OTHER_BRIDGE), address(OTHER_BRIDGE),
...@@ -414,7 +414,7 @@ abstract contract StandardBridge { ...@@ -414,7 +414,7 @@ abstract contract StandardBridge {
deposits[_localToken][_remoteToken] = deposits[_localToken][_remoteToken] + _amount; deposits[_localToken][_remoteToken] = deposits[_localToken][_remoteToken] + _amount;
} }
emit ERC20BridgeInitiated(_localToken, _remoteToken, _from, _to, _amount, _extraData); _emitERC20BridgeInitiated(_localToken, _remoteToken, _from, _to, _amount, _extraData);
MESSENGER.sendMessage( MESSENGER.sendMessage(
address(OTHER_BRIDGE), address(OTHER_BRIDGE),
...@@ -463,4 +463,83 @@ abstract contract StandardBridge { ...@@ -463,4 +463,83 @@ abstract contract StandardBridge {
{ {
return _otherToken == OptimismMintableERC20(_mintableToken).l1Token(); return _otherToken == OptimismMintableERC20(_mintableToken).l1Token();
} }
/** @notice Emits the ETHBridgeInitiated event and if necessary the appropriate legacy event
* when an ETH bridge is finalized on this chain.
*
* @param _from Address of the sender.
* @param _to Address of the receiver.
* @param _amount Amount of ETH sent.
* @param _extraData Extra data sent with the transaction.
*/
function _emitETHBridgeInitiated(
address _from,
address _to,
uint256 _amount,
bytes memory _extraData
) internal virtual {
emit ETHBridgeInitiated(_from, _to, _amount, _extraData);
}
/**
* @notice Emits the ETHBridgeFinalized and if necessary the appropriate legacy event when an
* ETH bridge is finalized on this chain.
*
* @param _from Address of the sender.
* @param _to Address of the receiver.
* @param _amount Amount of ETH sent.
* @param _extraData Extra data sent with the transaction.
*/
function _emitETHBridgeFinalized(
address _from,
address _to,
uint256 _amount,
bytes memory _extraData
) internal virtual {
emit ETHBridgeFinalized(_from, _to, _amount, _extraData);
}
/**
* @notice Emits the ERC20BridgeInitiated event and if necessary the appropriate legacy
* event when an ERC20 bridge is initiated to the other chain.
*
* @param _localToken Address of the ERC20 on this chain.
* @param _remoteToken Address of the ERC20 on the remote chain.
* @param _from Address of the sender.
* @param _to Address of the receiver.
* @param _amount Amount of the ERC20 sent.
* @param _extraData Extra data sent with the transaction.
*/
function _emitERC20BridgeInitiated(
address _localToken,
address _remoteToken,
address _from,
address _to,
uint256 _amount,
bytes memory _extraData
) internal virtual {
emit ERC20BridgeInitiated(_localToken, _remoteToken, _from, _to, _amount, _extraData);
}
/**
* @notice Emits the ERC20BridgeFinalized event and if necessary the appropriate legacy
* event when an ERC20 bridge is initiated to the other chain.
*
* @param _localToken Address of the ERC20 on this chain.
* @param _remoteToken Address of the ERC20 on the remote chain.
* @param _from Address of the sender.
* @param _to Address of the receiver.
* @param _amount Amount of the ERC20 sent.
* @param _extraData Extra data sent with the transaction.
*/
function _emitERC20BridgeFinalized(
address _localToken,
address _remoteToken,
address _from,
address _to,
uint256 _amount,
bytes memory _extraData
) internal virtual {
emit ERC20BridgeFinalized(_remoteToken, _localToken, _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