Commit a095d32d authored by Michael Amadi's avatar Michael Amadi Committed by GitHub

fix failing interfaces (#12648)

* fix failing interfaces

* fix crossl2inbox, revert some changes

* fix semgrep error
parent 02d58323
......@@ -32,10 +32,6 @@ import { IL2CrossDomainMessenger } from "src/L2/interfaces/IL2CrossDomainMesseng
import { IGasPriceOracle } from "src/L2/interfaces/IGasPriceOracle.sol";
import { IL1Block } from "src/L2/interfaces/IL1Block.sol";
interface IInitializable {
function initialize(address _addr) external;
}
struct L1Dependencies {
address payable l1CrossDomainMessengerProxy;
address payable l1StandardBridgeProxy;
......
......@@ -26,9 +26,8 @@ var excludeContracts = []string{
"IEAS", "ISchemaResolver", "ISchemaRegistry",
// TODO: Interfaces that need to be fixed
"IInitializable", "ILegacyMintableERC20", "IOptimismMintableERC20",
"IOptimismMintableERC721", "KontrolCheatsBase", "IWETH", "IDelayedWETH", "ISuperchainWETH",
"IL2ToL2CrossDomainMessenger", "ICrossL2Inbox", "ISystemConfigInterop", "IResolvedDelegateProxy",
"IInitializable", "IOptimismMintableERC20", "ILegacyMintableERC20",
"KontrolCheatsBase", "ISystemConfigInterop", "IResolvedDelegateProxy",
}
type ContractDefinition struct {
......
......@@ -16,8 +16,8 @@
"sourceCodeHash": "0x289de9f40898b6305deecc6b60cdf566aa6c6a1444f713c3a0af23ea7878207e"
},
"src/L1/L1StandardBridge.sol": {
"initCodeHash": "0x2868b09ecbe9f2bbc885605c2886b4c79f1c8e4171626c63776603b1b84698a8",
"sourceCodeHash": "0xc03da137b3ea72e0109fb284229283b21a0303104afbe37d2fe86ad806392a7f"
"initCodeHash": "0x802f72745bb9a82dc049377bb9cf6b58f35aec388aeb957b28a5e14f28d91bc1",
"sourceCodeHash": "0x24b784645b065a5393a2115a078d67f91eb09afd5e70baf81daf975381f16155"
},
"src/L1/L2OutputOracle.sol": {
"initCodeHash": "0x1182bfb87c4ab399b912ca7fe18cdbf4b24c414e078fb0a55bd3c44d442d3ed1",
......@@ -60,8 +60,8 @@
"sourceCodeHash": "0x983e8e248c61e362ba6a01dd2e217a535c9bb828dc0b4421f5f27e0577f2e14c"
},
"src/L2/CrossL2Inbox.sol": {
"initCodeHash": "0x66b052adce7e9194d054952d67d08b53964120067600358243ec86c85b90877b",
"sourceCodeHash": "0x38e6127ec6be99eb8c38c2c9d6e82761b33dde446bba250dc2c1b84983449e4e"
"initCodeHash": "0x31ecaebf368ab3333e80c6dc004b3c9f9a31f813c3138ab388bb3eead9f1b4ee",
"sourceCodeHash": "0xa1779d84a14332dcdd167293171d0fe2629d759a23d7cc34ffe2bde7e1605dbc"
},
"src/L2/ETHLiquidity.sol": {
"initCodeHash": "0x713c18f95a6a746d0703f475f3ae10c106c9b9ecb64d881a2e61b8969b581371",
......@@ -88,24 +88,24 @@
"sourceCodeHash": "0x56edf0f36366326a92722ae3c7502bce3d80b2ee5e354181dc09ba801437a488"
},
"src/L2/L2ERC721Bridge.sol": {
"initCodeHash": "0xb8236514beabcc1830e5e7e9eccb965e30d01f8bbb5a2d8b4f3d241c2d12819b",
"sourceCodeHash": "0x268e34289b7b8a5d1785af1907bd07d1c8ce4a9e3ea1685bdd9a77904dab3557"
"initCodeHash": "0xaed0528e8b81817a0c3b41513c02e7fd678f58e34b98f02ea33d5a770a064c2f",
"sourceCodeHash": "0xf8569c75b801f38f8a5a41e94e90f159ddc5f5412804b26e3e564755a50631b8"
},
"src/L2/L2StandardBridge.sol": {
"initCodeHash": "0x651eed10044d0b19b7e4eba864345df15e252be1401f39a552ec0d2f9c4df064",
"sourceCodeHash": "0xb55e58b5d4912edf05026878a5f5ac8019372212ed2a77843775d595fbf51b84"
"initCodeHash": "0xcb4aa19f0cd43a35cb5c65f26c3cfd7c41f1d1e5bcc15aef6096d385df7272c9",
"sourceCodeHash": "0x89771b53b7f6e64d943afb2a4bf15395efcf20d5302b76a18e52fa7cce8cdc56"
},
"src/L2/L2StandardBridgeInterop.sol": {
"initCodeHash": "0xd43d07c2ba5a73af56181c0221c28f3b495851b03cf8e35f9b009857bb9538a6",
"sourceCodeHash": "0x36087332a4365ee172eed8fa35aa48e804b08279e97332058a588c2d4ae30c6b"
"initCodeHash": "0xc4eaece28d2cfca3c51247c3cce320a167a83c7fd13aea5736549d2b25e0b139",
"sourceCodeHash": "0x9e80044adf5f83c30b520ee153b75be5a152081c9e1271e7e618ecfccd1fb4ac"
},
"src/L2/L2ToL1MessagePasser.sol": {
"initCodeHash": "0x13fe3729beb9ed966c97bef09acb9fe5043fe651d453145073d05f2567fa988d",
"sourceCodeHash": "0xd08a2e6514dbd44e16aa312a1b27b2841a9eab5622cbd05a39c30f543fad673c"
},
"src/L2/L2ToL2CrossDomainMessenger.sol": {
"initCodeHash": "0x6eb3718548d97b69c201a75c27a3a5a77400ebd5e0a9bdcc06e2cc28f9b4a689",
"sourceCodeHash": "0x4bb08a8a9d5de37d1fb2dd8a9bcc483305510c32508f0be2d54757e6e257aedb"
"initCodeHash": "0x2a1a1ee4f47175ce661ee8e4e50cfa879b082dcb5278b1d66ddda00ed77bb744",
"sourceCodeHash": "0xa76133db7f449ae742f9ba988ad86ccb5672475f61298b9fefe411b63b63e9f6"
},
"src/L2/OptimismSuperchainERC20.sol": {
"initCodeHash": "0x24d85d246858d1aff78ae86c614dd0dc0f63b3326b2b662e3462c3a6f9b7965e",
......@@ -164,8 +164,8 @@
"sourceCodeHash": "0x9cb0851b6e471461f2bb369bd72eef4cffe8a0d1345546608a2aa6795540211d"
},
"src/dispute/FaultDisputeGame.sol": {
"initCodeHash": "0xf97d35adc72c7bcbb5415ff1b183af0a4e3c951696d1dde213df61df50c848b9",
"sourceCodeHash": "0x27b4ab6f75004d01ff177b2b26e500a8ad06e906fcd36b920daa067f27f97da6"
"initCodeHash": "0x1480098a19f71ce6b4f4548880c8794402315ed3efa6793241a3df0fae864205",
"sourceCodeHash": "0x2f084f3f0e52017beb2ecf571178b94ba885cca987ada472d9e178b486a91d9e"
},
"src/legacy/DeployerWhitelist.sol": {
"initCodeHash": "0x0b8177ed75b69eddbb9ce6537683f69a9935efed86a1d6faa8feaafbd151c1bd",
......@@ -208,20 +208,20 @@
"sourceCodeHash": "0xd1479c60087f352385b6d5379ef3cc07839f671d617626b4c94ece91da781ef2"
},
"src/universal/OptimismMintableERC20.sol": {
"initCodeHash": "0x28c88484e1932253d6d12954492ac8a70744dc15c84429089af9944e5b158fd9",
"sourceCodeHash": "0x740b4043436d1b314ee3ba145acfcde60b6abd8416ea594f2b8e890b5d0bce6b"
"initCodeHash": "0x9cd677275b175812f1d5f90a127dbf7b3592714fd842a7a0de3988d716ca3eac",
"sourceCodeHash": "0x5611d8082f68af566554d7f09640b4b1f0e3efee4da1372b68fc7fc538a35ac7"
},
"src/universal/OptimismMintableERC20Factory.sol": {
"initCodeHash": "0x9cd4102d3ca811d5dc67ae99ce7de95812264575a789f96a6057600e55dcab64",
"sourceCodeHash": "0xc70c8c11d6e754eabe746bbee47a5e1051f71f7a83913f62ebcce8db989a1357"
"initCodeHash": "0x03ad07bd7f89a29f1850fa8b5d377daf0e1d5aef6cb458a127df520549e8e8e6",
"sourceCodeHash": "0xdb6ec93782a4a217475195507740794a4f5553b9032e7ba31dc48b81f579a940"
},
"src/universal/OptimismMintableERC721.sol": {
"initCodeHash": "0xec037be7fc28e072944b0a9e55d4278b92d6c68ccb41049ab52eafca59c6e023",
"sourceCodeHash": "0x5ea7c1b0cef5609f25c4193f5795fc9ce8f3ae08dbbf2945afe38e5af58f32c3"
"initCodeHash": "0x8aa309f2676d5267b6c9e411f88dc6e4badce414b8d66b330df3f60e9836380e",
"sourceCodeHash": "0x03bf7ad4d2b751bdead9930fc8f89b8e55d40dd4b2f5670fd339e87ae81f8b49"
},
"src/universal/OptimismMintableERC721Factory.sol": {
"initCodeHash": "0x63d2ceafd3f3b3b54e31749574563e8022fef9c6da7bb8c7a113b3dbf571cfa2",
"sourceCodeHash": "0x705e270925fcad14e805b5ec1bbbb9e78b5b44e3b128f284b0113a4d68c82ef6"
"initCodeHash": "0x5ea977ba35558c3b75bebe28900548c763d205e40d6cf7660292b8e96bf3aea8",
"sourceCodeHash": "0x063ca3a0a2e3c592173af6157e383b5aaeff752000f98648a5c71260bb26590a"
},
"src/universal/StorageSetter.sol": {
"initCodeHash": "0x21b3059e9b13b330f76d02b61f61dcfa3abf3517a0b56afa0895c4b8291740bf",
......
......@@ -55,7 +55,7 @@
"type": "uint256"
}
],
"internalType": "struct ICrossL2Inbox.Identifier",
"internalType": "struct Identifier",
"name": "_id",
"type": "tuple"
},
......@@ -164,7 +164,7 @@
"type": "uint256"
}
],
"internalType": "struct ICrossL2Inbox.Identifier",
"internalType": "struct Identifier",
"name": "_id",
"type": "tuple"
},
......@@ -230,7 +230,7 @@
}
],
"indexed": false,
"internalType": "struct ICrossL2Inbox.Identifier",
"internalType": "struct Identifier",
"name": "id",
"type": "tuple"
}
......
......@@ -99,7 +99,7 @@
"type": "uint256"
}
],
"internalType": "struct ICrossL2Inbox.Identifier",
"internalType": "struct Identifier",
"name": "_id",
"type": "tuple"
},
......
......@@ -75,8 +75,8 @@ contract L1StandardBridge is StandardBridge, ISemver {
);
/// @notice Semantic version.
/// @custom:semver 2.2.1-beta.1
string public constant version = "2.2.1-beta.1";
/// @custom:semver 2.2.1-beta.2
string public constant version = "2.2.1-beta.2";
/// @notice Address of the SuperchainConfig contract.
ISuperchainConfig public superchainConfig;
......
......@@ -4,7 +4,6 @@ pragma solidity 0.8.25;
import { Predeploys } from "src/libraries/Predeploys.sol";
import { TransientContext, TransientReentrancyAware } from "src/libraries/TransientContext.sol";
import { ISemver } from "src/universal/interfaces/ISemver.sol";
import { ICrossL2Inbox } from "src/L2/interfaces/ICrossL2Inbox.sol";
import { SafeCall } from "src/libraries/SafeCall.sol";
import { IDependencySet } from "src/L2/interfaces/IDependencySet.sol";
import { IL1BlockInterop } from "src/L2/interfaces/IL1BlockInterop.sol";
......@@ -30,12 +29,21 @@ error TargetCallFailed();
/// @notice Thrown when trying to execute a cross chain message on a deposit transaction.
error NoExecutingDeposits();
/// @notice The struct for a pointer to a message payload in a remote (or local) chain.
struct Identifier {
address origin;
uint256 blockNumber;
uint256 logIndex;
uint256 timestamp;
uint256 chainId;
}
/// @custom:proxied true
/// @custom:predeploy 0x4200000000000000000000000000000000000022
/// @title CrossL2Inbox
/// @notice The CrossL2Inbox is responsible for executing a cross chain message on the destination
/// chain. It is permissionless to execute a cross chain message on behalf of any user.
contract CrossL2Inbox is ICrossL2Inbox, ISemver, TransientReentrancyAware {
contract CrossL2Inbox is ISemver, TransientReentrancyAware {
/// @notice Storage slot that the interop start timestamp is stored at.
/// Equal to bytes32(uint256(keccak256("crossl2inbox.interopstart")) - 1)
bytes32 internal constant INTEROP_START_SLOT = 0x5c769ee0ee8887661922049dc52480bb60322d765161507707dd9b190af5c149;
......@@ -65,8 +73,8 @@ contract CrossL2Inbox is ICrossL2Inbox, ISemver, TransientReentrancyAware {
address internal constant DEPOSITOR_ACCOUNT = 0xDeaDDEaDDeAdDeAdDEAdDEaddeAddEAdDEAd0001;
/// @notice Semantic version.
/// @custom:semver 1.0.0-beta.8
string public constant version = "1.0.0-beta.8";
/// @custom:semver 1.0.0-beta.9
string public constant version = "1.0.0-beta.9";
/// @notice Emitted when a cross chain message is being executed.
/// @param msgHash Hash of message payload being executed.
......
......@@ -26,8 +26,8 @@ import { ISemver } from "src/universal/interfaces/ISemver.sol";
/// wait for the one-week challenge period to elapse before their Optimism-native NFT
/// can be refunded on L2.
contract L2ERC721Bridge is ERC721Bridge, ISemver {
/// @custom:semver 1.8.0-beta.1
string public constant version = "1.8.0-beta.1";
/// @custom:semver 1.8.0-beta.2
string public constant version = "1.8.0-beta.2";
/// @notice Constructs the L2ERC721Bridge contract.
constructor() ERC721Bridge() {
......
......@@ -58,9 +58,9 @@ contract L2StandardBridge is StandardBridge, ISemver {
);
/// @notice Semantic version.
/// @custom:semver 1.11.1-beta.2
/// @custom:semver 1.11.1-beta.3
function version() public pure virtual returns (string memory) {
return "1.11.1-beta.2";
return "1.11.1-beta.3";
}
/// @notice Constructs the L2StandardBridge contract.
......
......@@ -40,9 +40,9 @@ contract L2StandardBridgeInterop is L2StandardBridge {
event Converted(address indexed from, address indexed to, address indexed caller, uint256 amount);
/// @notice Semantic version.
/// @custom:semver +interop-beta.1
/// @custom:semver +interop-beta.2
function version() public pure override returns (string memory) {
return string.concat(super.version(), "+interop-beta.1");
return string.concat(super.version(), "+interop-beta.2");
}
/// @notice Converts `amount` of `from` token to `to` token.
......
......@@ -4,9 +4,7 @@ pragma solidity 0.8.25;
import { Encoding } from "src/libraries/Encoding.sol";
import { Hashing } from "src/libraries/Hashing.sol";
import { Predeploys } from "src/libraries/Predeploys.sol";
import { CrossL2Inbox } from "src/L2/CrossL2Inbox.sol";
import { ICrossL2Inbox } from "src/L2/interfaces/ICrossL2Inbox.sol";
import { IL2ToL2CrossDomainMessenger } from "src/L2/interfaces/IL2ToL2CrossDomainMessenger.sol";
import { CrossL2Inbox, Identifier } from "src/L2/CrossL2Inbox.sol";
import { ISemver } from "src/universal/interfaces/ISemver.sol";
import { SafeCall } from "src/libraries/SafeCall.sol";
import { TransientReentrancyAware } from "src/libraries/TransientContext.sol";
......@@ -47,7 +45,7 @@ error TargetCallFailed();
/// @notice The L2ToL2CrossDomainMessenger is a higher level abstraction on top of the CrossL2Inbox that provides
/// features necessary for secure transfers ERC20 tokens between L2 chains. Messages sent through the
/// L2ToL2CrossDomainMessenger on the source chain receive both replay protection as well as domain binding.
contract L2ToL2CrossDomainMessenger is IL2ToL2CrossDomainMessenger, ISemver, TransientReentrancyAware {
contract L2ToL2CrossDomainMessenger is ISemver, TransientReentrancyAware {
/// @notice Storage slot for the sender of the current cross domain message.
/// Equal to bytes32(uint256(keccak256("l2tol2crossdomainmessenger.sender")) - 1)
bytes32 internal constant CROSS_DOMAIN_MESSAGE_SENDER_SLOT =
......@@ -67,8 +65,8 @@ contract L2ToL2CrossDomainMessenger is IL2ToL2CrossDomainMessenger, ISemver, Tra
uint16 public constant messageVersion = uint16(0);
/// @notice Semantic version.
/// @custom:semver 1.0.0-beta.9
string public constant version = "1.0.0-beta.9";
/// @custom:semver 1.0.0-beta.10
string public constant version = "1.0.0-beta.10";
/// @notice Mapping of message hashes to boolean receipt values. Note that a message will only be present in this
/// mapping if it has successfully been relayed on this chain, and can therefore not be relayed again.
......@@ -153,14 +151,7 @@ contract L2ToL2CrossDomainMessenger is IL2ToL2CrossDomainMessenger, ISemver, Tra
/// currently being replayed.
/// @param _id Identifier of the SentMessage event to be relayed
/// @param _sentMessage Message payload of the `SentMessage` event
function relayMessage(
ICrossL2Inbox.Identifier calldata _id,
bytes calldata _sentMessage
)
external
payable
nonReentrant
{
function relayMessage(Identifier calldata _id, bytes calldata _sentMessage) external payable nonReentrant {
// Ensure the log came from the messenger. Since the log origin is the CDM, there isn't a scenario where
// this can be invoked from the CrossL2Inbox as the SentMessage log is not calldata for this function
if (_id.origin != Predeploys.L2_TO_L2_CROSS_DOMAIN_MESSENGER) {
......
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
struct Identifier {
address origin;
uint256 blockNumber;
uint256 logIndex;
uint256 timestamp;
uint256 chainId;
}
/// @title ICrossL2Inbox
/// @notice Interface for the CrossL2Inbox contract.
interface ICrossL2Inbox {
/// @notice The struct for a pointer to a message payload in a remote (or local) chain.
struct Identifier {
address origin;
uint256 blockNumber;
uint256 logIndex;
uint256 timestamp;
uint256 chainId;
}
error ReentrantCall();
/// @notice Thrown when the caller is not DEPOSITOR_ACCOUNT when calling `setInteropStart()`
error NotDepositor();
/// @notice Thrown when attempting to set interop start when it's already set.
error InteropStartAlreadySet();
/// @notice Thrown when a non-written transient storage slot is attempted to be read from.
error NotEntered();
/// @notice Thrown when trying to execute a cross chain message with an invalid Identifier timestamp.
error InvalidTimestamp();
/// @notice Thrown when trying to execute a cross chain message with an invalid Identifier chain ID.
error InvalidChainId();
/// @notice Thrown when trying to execute a cross chain message and the target call fails.
error TargetCallFailed();
/// @notice Thrown when trying to execute a cross chain message on a deposit transaction.
error NoExecutingDeposits();
event ExecutingMessage(bytes32 indexed msgHash, Identifier id);
function version() external view returns (string memory);
/// @notice Returns the interop start timestamp.
/// @return interopStart_ interop start timestamp.
function interopStart() external view returns (uint256 interopStart_);
/// @notice Returns the origin address of the Identifier.
/// @return origin_ The origin address of the Identifier.
function origin() external view returns (address origin_);
function origin() external view returns (address);
/// @notice Returns the block number of the Identifier.
/// @return blockNumber_ The block number of the Identifier.
function blockNumber() external view returns (uint256 blockNumber_);
function blockNumber() external view returns (uint256);
/// @notice Returns the log index of the Identifier.
/// @return logIndex_ The log index of the Identifier.
function logIndex() external view returns (uint256 logIndex_);
function logIndex() external view returns (uint256);
/// @notice Returns the timestamp of the Identifier.
/// @return timestamp_ The timestamp of the Identifier.
function timestamp() external view returns (uint256 timestamp_);
function timestamp() external view returns (uint256);
/// @notice Returns the chain ID of the Identifier.
/// @return chainId_ The chain ID of the Identifier.
function chainId() external view returns (uint256 chainId_);
function chainId() external view returns (uint256);
function setInteropStart() external;
/// @notice Executes a cross chain message on the destination chain.
/// @param _id An Identifier pointing to the initiating message.
/// @param _target Account that is called with _msg.
/// @param _msg The message payload, matching the initiating message.
function executeMessage(
ICrossL2Inbox.Identifier calldata _id,
address _target,
bytes calldata _msg
)
external
payable;
/// @param _message The message payload, matching the initiating message.
function executeMessage(Identifier calldata _id, address _target, bytes calldata _message) external payable;
/// @notice Validates a cross chain message on the destination chain
/// and emits an ExecutingMessage event. This function is useful
......
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import { ICrossL2Inbox } from "src/L2/interfaces/ICrossL2Inbox.sol";
struct Identifier {
address origin;
uint256 blockNumber;
uint256 logIndex;
uint256 timestamp;
uint256 chainId;
}
/// @title IL2ToL2CrossDomainMessenger
/// @notice Interface for the L2ToL2CrossDomainMessenger contract.
interface IL2ToL2CrossDomainMessenger {
/// @notice Thrown when a non-written slot in transient storage is attempted to be read from.
error NotEntered();
/// @notice Thrown when attempting to relay a message where payload origin is not L2ToL2CrossDomainMessenger.
error IdOriginNotL2ToL2CrossDomainMessenger();
/// @notice Thrown when the payload provided to the relay is not a SentMessage event.
error EventPayloadNotSentMessage();
/// @notice Thrown when attempting to send a message to the chain that the message is being sent from.
error MessageDestinationSameChain();
/// @notice Thrown when attempting to relay a message whose destination chain is not the chain relaying it.
error MessageDestinationNotRelayChain();
/// @notice Thrown when attempting to relay a message whose target is CrossL2Inbox.
error MessageTargetCrossL2Inbox();
/// @notice Thrown when attempting to relay a message whose target is L2ToL2CrossDomainMessenger.
error MessageTargetL2ToL2CrossDomainMessenger();
/// @notice Thrown when attempting to relay a message that has already been relayed.
error MessageAlreadyRelayed();
/// @notice Thrown when a reentrant call is detected.
error ReentrantCall();
/// @notice Thrown when a call to the target contract during message relay fails.
error TargetCallFailed();
/// @notice Emitted whenever a message is sent to a destination
/// @param destination Chain ID of the destination chain.
/// @param target Target contract or wallet address.
/// @param messageNonce Nonce associated with the messsage sent
/// @param sender Address initiating this message call
/// @param message Message payload to call target with.
event SentMessage(
uint256 indexed destination, address indexed target, uint256 indexed messageNonce, address sender, bytes message
);
/// @notice Emitted whenever a message is successfully relayed on this chain.
/// @param source Chain ID of the source chain.
/// @param messageNonce Nonce associated with the messsage sent
/// @param messageHash Hash of the message that was relayed.
event RelayedMessage(uint256 indexed source, uint256 indexed messageNonce, bytes32 indexed messageHash);
function version() external view returns (string memory);
/// @notice Mapping of message hashes to boolean receipt values. Note that a message will only
/// be present in this mapping if it has successfully been relayed on this chain, and
/// can therefore not be relayed again.
/// @param _msgHash message hash to check.
/// @return Returns true if the message corresponding to the `_msgHash` was successfully relayed.
function successfulMessages(bytes32 _msgHash) external view returns (bool);
function successfulMessages(bytes32) external view returns (bool);
/// @notice Retrieves the next message nonce. Message version will be added to the upper two
/// bytes of the message nonce. Message version allows us to treat messages as having
......@@ -41,18 +94,16 @@ interface IL2ToL2CrossDomainMessenger {
/// @param _message Message to trigger the target address with.
/// @return msgHash_ The hash of the message being sent, which can be used for tracking whether
/// the message has successfully been relayed.
function sendMessage(
uint256 _destination,
address _target,
bytes calldata _message
)
external
returns (bytes32 msgHash_);
function sendMessage(uint256 _destination, address _target, bytes calldata _message) external returns (bytes32);
/// @notice Relays a message that was sent by the other CrossDomainMessenger contract. Can only
/// be executed via cross-chain call from the other messenger OR if the message was
/// already received once and is currently being replayed.
/// @param _id Identifier of the SentMessage event to be relayed
/// @param _sentMessage Message payload of the `SentMessage` event
function relayMessage(ICrossL2Inbox.Identifier calldata _id, bytes calldata _sentMessage) external payable;
function relayMessage(Identifier calldata _id, bytes calldata _sentMessage) external payable;
function messageVersion() external view returns (uint16);
function __constructor__() external;
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import { IWETH } from "src/universal/interfaces/IWETH.sol";
import { IWETH98 } from "src/universal/interfaces/IWETH98.sol";
import { ICrosschainERC20 } from "src/L2/interfaces/ICrosschainERC20.sol";
import { ISemver } from "src/universal/interfaces/ISemver.sol";
interface ISuperchainWETH is IWETH, ICrosschainERC20, ISemver {
interface ISuperchainWETH is IWETH98, ICrosschainERC20, ISemver {
error Unauthorized();
error NotCustomGasToken();
function balanceOf(address src) external view returns (uint256);
function withdraw(uint256 _amount) external;
function __constructor__() external;
}
......@@ -147,8 +147,8 @@ contract FaultDisputeGame is Clone, ISemver {
uint256 internal constant HEADER_BLOCK_NUMBER_INDEX = 8;
/// @notice Semantic version.
/// @custom:semver 1.3.1-beta.5
string public constant version = "1.3.1-beta.5";
/// @custom:semver 1.3.1-beta.6
string public constant version = "1.3.1-beta.6";
/// @notice The starting timestamp of the game
Timestamp public createdAt;
......
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import { IWETH } from "src/universal/interfaces/IWETH.sol";
import { IWETH98 } from "src/universal/interfaces/IWETH98.sol";
import { ISuperchainConfig } from "src/L1/interfaces/ISuperchainConfig.sol";
interface IDelayedWETH is IWETH {
interface IDelayedWETH is IWETH98 {
struct WithdrawalRequest {
uint256 amount;
uint256 timestamp;
}
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
event Initialized(uint8 version);
event Unwrap(address indexed src, uint256 wad);
fallback() external payable;
......@@ -25,8 +27,10 @@ interface IDelayedWETH is IWETH {
function renounceOwnership() external;
function unlock(address _guy, uint256 _wad) external;
function withdraw(address _guy, uint256 _wad) external;
function withdrawals(address _owner, address _guy) external view returns (uint256, uint256);
function withdrawals(address, address) external view returns (uint256 amount, uint256 timestamp);
function version() external view returns (string memory);
function withdraw(uint256 _wad) external override;
function __constructor__(uint256 _delay) external;
}
......@@ -7,7 +7,7 @@ import { ILegacyMintableERC20 } from "src/universal/OptimismMintableERC20.sol";
/// @title LegacyMintableERC20
/// @notice The legacy implementation of the OptimismMintableERC20. This
/// contract is deprecated and should no longer be used.
contract LegacyMintableERC20 is ILegacyMintableERC20, ERC20 {
contract LegacyMintableERC20 is ERC20 {
/// @notice Emitted when the token is minted by the bridge.
event Mint(address indexed _account, uint256 _amount);
......
......@@ -4,7 +4,8 @@ pragma solidity 0.8.15;
import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import { ERC20Permit } from "@openzeppelin/contracts/token/ERC20/extensions/draft-ERC20Permit.sol";
import { IERC165 } from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
import { ILegacyMintableERC20, IOptimismMintableERC20 } from "src/universal/interfaces/IOptimismMintableERC20.sol";
import { IOptimismMintableERC20 } from "src/universal/interfaces/IOptimismMintableERC20.sol";
import { ILegacyMintableERC20 } from "src/universal/interfaces/ILegacyMintableERC20.sol";
import { ISemver } from "src/universal/interfaces/ISemver.sol";
import { Preinstalls } from "src/libraries/Preinstalls.sol";
......@@ -14,7 +15,7 @@ import { Preinstalls } from "src/libraries/Preinstalls.sol";
/// use an OptimismMintablERC20 as the L2 representation of an L1 token, or vice-versa.
/// Designed to be backwards compatible with the older StandardL2ERC20 token which was only
/// meant for use on L2.
contract OptimismMintableERC20 is IOptimismMintableERC20, ILegacyMintableERC20, ERC20Permit, ISemver {
contract OptimismMintableERC20 is ERC20Permit, ISemver {
/// @notice Address of the corresponding version of this token on the remote chain.
address public immutable REMOTE_TOKEN;
......@@ -41,8 +42,8 @@ contract OptimismMintableERC20 is IOptimismMintableERC20, ILegacyMintableERC20,
}
/// @notice Semantic version.
/// @custom:semver 1.4.0-beta.1
string public constant version = "1.4.0-beta.1";
/// @custom:semver 1.4.0-beta.2
string public constant version = "1.4.0-beta.2";
/// @notice Getter function for the permit2 address. It deterministically deployed
/// so it will always be at the same address. It is also included as a preinstall,
......@@ -96,15 +97,7 @@ contract OptimismMintableERC20 is IOptimismMintableERC20, ILegacyMintableERC20,
/// @notice Allows the StandardBridge on this network to mint tokens.
/// @param _to Address to mint tokens to.
/// @param _amount Amount of tokens to mint.
function mint(
address _to,
uint256 _amount
)
external
virtual
override(IOptimismMintableERC20, ILegacyMintableERC20)
onlyBridge
{
function mint(address _to, uint256 _amount) external virtual onlyBridge {
_mint(_to, _amount);
emit Mint(_to, _amount);
}
......@@ -112,15 +105,7 @@ contract OptimismMintableERC20 is IOptimismMintableERC20, ILegacyMintableERC20,
/// @notice Allows the StandardBridge on this network to burn tokens.
/// @param _from Address to burn tokens from.
/// @param _amount Amount of tokens to burn.
function burn(
address _from,
uint256 _amount
)
external
virtual
override(IOptimismMintableERC20, ILegacyMintableERC20)
onlyBridge
{
function burn(address _from, uint256 _amount) external virtual onlyBridge {
_burn(_from, _amount);
emit Burn(_from, _amount);
}
......
......@@ -48,8 +48,8 @@ contract OptimismMintableERC20Factory is ISemver, Initializable, IOptimismERC20F
/// the OptimismMintableERC20 token contract since this contract
/// is responsible for deploying OptimismMintableERC20 contracts.
/// @notice Semantic version.
/// @custom:semver 1.10.1-beta.3
string public constant version = "1.10.1-beta.3";
/// @custom:semver 1.10.1-beta.4
string public constant version = "1.10.1-beta.4";
/// @notice Constructs the OptimismMintableERC20Factory contract.
constructor() {
......
......@@ -3,7 +3,6 @@ pragma solidity 0.8.15;
import { ERC721Enumerable } from "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import { ERC721 } from "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import { IERC165 } from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
import { Strings } from "@openzeppelin/contracts/utils/Strings.sol";
import { IOptimismMintableERC721 } from "src/universal/interfaces/IOptimismMintableERC721.sol";
import { ISemver } from "src/universal/interfaces/ISemver.sol";
......@@ -12,14 +11,24 @@ import { ISemver } from "src/universal/interfaces/ISemver.sol";
/// @notice This contract is the remote representation for some token that lives on another network,
/// typically an Optimism representation of an Ethereum-based token. Standard reference
/// implementation that can be extended or modified according to your needs.
contract OptimismMintableERC721 is ERC721Enumerable, IOptimismMintableERC721, ISemver {
/// @inheritdoc IOptimismMintableERC721
contract OptimismMintableERC721 is ERC721Enumerable, ISemver {
/// @notice Emitted when a token is minted.
/// @param account Address of the account the token was minted to.
/// @param tokenId Token ID of the minted token.
event Mint(address indexed account, uint256 tokenId);
/// @notice Emitted when a token is burned.
/// @param account Address of the account the token was burned from.
/// @param tokenId Token ID of the burned token.
event Burn(address indexed account, uint256 tokenId);
/// @notice Chain ID of the chain where the remote token is deployed.
uint256 public immutable REMOTE_CHAIN_ID;
/// @inheritdoc IOptimismMintableERC721
/// @notice Address of the token on the remote domain.
address public immutable REMOTE_TOKEN;
/// @inheritdoc IOptimismMintableERC721
/// @notice Address of the ERC721 bridge on this network.
address public immutable BRIDGE;
/// @notice Base token URI for this token.
......@@ -32,8 +41,8 @@ contract OptimismMintableERC721 is ERC721Enumerable, IOptimismMintableERC721, IS
}
/// @notice Semantic version.
/// @custom:semver 1.3.1-beta.2
string public constant version = "1.3.1-beta.2";
/// @custom:semver 1.3.1-beta.3
string public constant version = "1.3.1-beta.3";
/// @param _bridge Address of the bridge on this network.
/// @param _remoteChainId Chain ID where the remote token is deployed.
......@@ -70,29 +79,34 @@ contract OptimismMintableERC721 is ERC721Enumerable, IOptimismMintableERC721, IS
);
}
/// @inheritdoc IOptimismMintableERC721
/// @notice Chain ID of the chain where the remote token is deployed.
function remoteChainId() external view returns (uint256) {
return REMOTE_CHAIN_ID;
}
/// @inheritdoc IOptimismMintableERC721
/// @notice Address of the token on the remote domain.
function remoteToken() external view returns (address) {
return REMOTE_TOKEN;
}
/// @inheritdoc IOptimismMintableERC721
/// @notice Address of the ERC721 bridge on this network.
function bridge() external view returns (address) {
return BRIDGE;
}
/// @inheritdoc IOptimismMintableERC721
/// @notice Mints some token ID for a user, checking first that contract recipients
/// are aware of the ERC721 protocol to prevent tokens from being forever locked.
/// @param _to Address of the user to mint the token for.
/// @param _tokenId Token ID to mint.
function safeMint(address _to, uint256 _tokenId) external virtual onlyBridge {
_safeMint(_to, _tokenId);
emit Mint(_to, _tokenId);
}
/// @inheritdoc IOptimismMintableERC721
/// @notice Burns a token ID from a user.
/// @param _from Address of the user to burn the token from.
/// @param _tokenId Token ID to burn.
function burn(address _from, uint256 _tokenId) external virtual onlyBridge {
_burn(_tokenId);
......@@ -102,7 +116,7 @@ contract OptimismMintableERC721 is ERC721Enumerable, IOptimismMintableERC721, IS
/// @notice Checks if a given interface ID is supported by this contract.
/// @param _interfaceId The interface ID to check.
/// @return True if the interface ID is supported, false otherwise.
function supportsInterface(bytes4 _interfaceId) public view override(ERC721Enumerable, IERC165) returns (bool) {
function supportsInterface(bytes4 _interfaceId) public view override(ERC721Enumerable) returns (bool) {
bytes4 iface = type(IOptimismMintableERC721).interfaceId;
return _interfaceId == iface || super.supportsInterface(_interfaceId);
}
......
......@@ -25,8 +25,8 @@ contract OptimismMintableERC721Factory is ISemver {
event OptimismMintableERC721Created(address indexed localToken, address indexed remoteToken, address deployer);
/// @notice Semantic version.
/// @custom:semver 1.4.1-beta.3
string public constant version = "1.4.1-beta.3";
/// @custom:semver 1.4.1-beta.4
string public constant version = "1.4.1-beta.4";
/// @notice The semver MUST be bumped any time that there is a change in
/// the OptimismMintableERC721 token contract since this contract
......
......@@ -6,7 +6,8 @@ import { ERC165Checker } from "@openzeppelin/contracts/utils/introspection/ERC16
import { Address } from "@openzeppelin/contracts/utils/Address.sol";
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import { SafeCall } from "src/libraries/SafeCall.sol";
import { IOptimismMintableERC20, ILegacyMintableERC20 } from "src/universal/interfaces/IOptimismMintableERC20.sol";
import { IOptimismMintableERC20 } from "src/universal/interfaces/IOptimismMintableERC20.sol";
import { ILegacyMintableERC20 } from "src/universal/interfaces/ILegacyMintableERC20.sol";
import { ICrossDomainMessenger } from "src/universal/interfaces/ICrossDomainMessenger.sol";
import { OptimismMintableERC20 } from "src/universal/OptimismMintableERC20.sol";
import { Initializable } from "@openzeppelin/contracts/proxy/utils/Initializable.sol";
......
......@@ -19,16 +19,38 @@
pragma solidity 0.8.15;
import { IWETH } from "src/universal/interfaces/IWETH.sol";
/// @title WETH98
/// @notice WETH98 is a version of WETH9 upgraded for Solidity 0.8.x.
contract WETH98 is IWETH {
contract WETH98 {
/// @notice Returns the number of decimals the token uses.
/// @return The number of decimals the token uses.
uint8 public constant decimals = 18;
mapping(address => uint256) internal _balanceOf;
mapping(address => mapping(address => uint256)) internal _allowance;
/// @notice Emitted when an approval is made.
/// @param src The address that approved the transfer.
/// @param guy The address that was approved to transfer.
/// @param wad The amount that was approved to transfer.
event Approval(address indexed src, address indexed guy, uint256 wad);
/// @notice Emitted when a transfer is made.
/// @param src The address that transferred the WETH.
/// @param dst The address that received the WETH.
/// @param wad The amount of WETH that was transferred.
event Transfer(address indexed src, address indexed dst, uint256 wad);
/// @notice Emitted when a deposit is made.
/// @param dst The address that deposited the WETH.
/// @param wad The amount of WETH that was deposited.
event Deposit(address indexed dst, uint256 wad);
/// @notice Emitted when a withdrawal is made.
/// @param src The address that withdrew the WETH.
/// @param wad The amount of WETH that was withdrawn.
event Withdrawal(address indexed src, uint256 wad);
/// @notice Pipes to deposit.
receive() external payable {
deposit();
......@@ -39,33 +61,41 @@ contract WETH98 is IWETH {
deposit();
}
/// @inheritdoc IWETH
function name() external view virtual override returns (string memory) {
/// @notice Returns the name of the token.
/// @return name_ The name of the token.
function name() external view virtual returns (string memory) {
return "Wrapped Ether";
}
/// @inheritdoc IWETH
function symbol() external view virtual override returns (string memory) {
/// @notice Returns the symbol of the token.
/// @return symbol_ The symbol of the token.
function symbol() external view virtual returns (string memory) {
return "WETH";
}
/// @inheritdoc IWETH
/// @notice Returns the amount of WETH that the spender can transfer on behalf of the owner.
/// @param owner The address that owns the WETH.
/// @param spender The address that is approved to transfer the WETH.
/// @return The amount of WETH that the spender can transfer on behalf of the owner.
function allowance(address owner, address spender) public view virtual returns (uint256) {
return _allowance[owner][spender];
}
/// @inheritdoc IWETH
/// @notice Returns the balance of the given address.
/// @param src The address to query the balance of.
/// @return The balance of the given address.
function balanceOf(address src) public view returns (uint256) {
return _balanceOf[src];
}
/// @inheritdoc IWETH
/// @notice Allows WETH to be deposited by sending ether to the contract.
function deposit() public payable virtual {
_balanceOf[msg.sender] += msg.value;
emit Deposit(msg.sender, msg.value);
}
/// @inheritdoc IWETH
/// @notice Withdraws an amount of ETH.
/// @param wad The amount of ETH to withdraw.
function withdraw(uint256 wad) public virtual {
require(_balanceOf[msg.sender] >= wad);
_balanceOf[msg.sender] -= wad;
......@@ -73,24 +103,35 @@ contract WETH98 is IWETH {
emit Withdrawal(msg.sender, wad);
}
/// @inheritdoc IWETH
/// @notice Returns the total supply of WETH.
/// @return The total supply of WETH.
function totalSupply() external view returns (uint256) {
return address(this).balance;
}
/// @inheritdoc IWETH
/// @notice Approves the given address to transfer the WETH on behalf of the caller.
/// @param guy The address that is approved to transfer the WETH.
/// @param wad The amount that is approved to transfer.
/// @return True if the approval was successful.
function approve(address guy, uint256 wad) external returns (bool) {
_allowance[msg.sender][guy] = wad;
emit Approval(msg.sender, guy, wad);
return true;
}
/// @inheritdoc IWETH
/// @notice Transfers the given amount of WETH to the given address.
/// @param dst The address to transfer the WETH to.
/// @param wad The amount of WETH to transfer.
/// @return True if the transfer was successful.
function transfer(address dst, uint256 wad) external returns (bool) {
return transferFrom(msg.sender, dst, wad);
}
/// @inheritdoc IWETH
/// @notice Transfers the given amount of WETH from the given address to the given address.
/// @param src The address to transfer the WETH from.
/// @param dst The address to transfer the WETH to.
/// @param wad The amount of WETH to transfer.
/// @return True if the transfer was successful.
function transferFrom(address src, address dst, uint256 wad) public returns (bool) {
require(_balanceOf[src] >= wad);
......
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import { IERC165 } from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
/// @custom:legacy
/// @title ILegacyMintableERC20
/// @notice This interface was available on the legacy L2StandardERC20 contract.
/// It remains available on the OptimismMintableERC20 contract for
/// backwards compatibility.
interface ILegacyMintableERC20 is IERC165 {
function l1Token() external view returns (address);
function mint(address _to, uint256 _amount) external;
function burn(address _from, uint256 _amount) external;
}
......@@ -16,16 +16,3 @@ interface IOptimismMintableERC20 is IERC165 {
function burn(address _from, uint256 _amount) external;
}
/// @custom:legacy
/// @title ILegacyMintableERC20
/// @notice This interface was available on the legacy L2StandardERC20 contract.
/// It remains available on the OptimismMintableERC20 contract for
/// backwards compatibility.
interface ILegacyMintableERC20 is IERC165 {
function l1Token() external view returns (address);
function mint(address _to, uint256 _amount) external;
function burn(address _from, uint256 _amount) external;
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import { IERC721Enumerable } from "@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol";
/// @title IOptimismMintableERC721
/// @notice Interface for contracts that are compatible with the OptimismMintableERC721 standard.
/// Tokens that follow this standard can be easily transferred across the ERC721 bridge.
interface IOptimismMintableERC721 is IERC721Enumerable {
/// @notice Emitted when a token is minted.
/// @param account Address of the account the token was minted to.
/// @param tokenId Token ID of the minted token.
event Mint(address indexed account, uint256 tokenId);
interface IOptimismMintableERC721 {
function __constructor__(
address _bridge,
uint256 _remoteChainId,
address _remoteToken,
string memory _name,
string memory _symbol
)
external;
/// @notice Emitted when a token is burned.
/// @param account Address of the account the token was burned from.
/// @param tokenId Token ID of the burned token.
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
event Burn(address indexed account, uint256 tokenId);
event Mint(address indexed account, uint256 tokenId);
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
function totalSupply() external view returns (uint256);
function approve(address to, uint256 tokenId) external;
function isApprovedForAll(address owner, address operator) external view returns (bool);
function symbol() external view returns (string memory);
function tokenByIndex(uint256 index) external view returns (uint256);
function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256);
function transferFrom(address from, address to, uint256 tokenId) external;
function balanceOf(address owner) external view returns (uint256);
function baseTokenURI() external view returns (string memory);
function getApproved(uint256 tokenId) external view returns (address);
function name() external view returns (string memory);
function ownerOf(uint256 tokenId) external view returns (address);
function safeTransferFrom(address from, address to, uint256 tokenId) external;
function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) external;
function setApprovalForAll(address operator, bool approved) external;
function supportsInterface(bytes4 _interfaceId) external view returns (bool);
function tokenURI(uint256 tokenId) external view returns (string memory);
function version() external view returns (string memory);
/// @notice Mints some token ID for a user, checking first that contract recipients
/// are aware of the ERC721 protocol to prevent tokens from being forever locked.
/// @param _to Address of the user to mint the token for.
/// @param _tokenId Token ID to mint.
function safeMint(address _to, uint256 _tokenId) external;
/// @notice Burns a token ID from a user.
/// @param _from Address of the user to burn the token from.
/// @param _tokenId Token ID to burn.
function burn(address _from, uint256 _tokenId) external;
/// @notice Chain ID of the chain where the remote token is deployed.
function REMOTE_CHAIN_ID() external view returns (uint256);
/// @notice Address of the token on the remote domain.
function REMOTE_TOKEN() external view returns (address);
/// @notice Address of the ERC721 bridge on this network.
function BRIDGE() external view returns (address);
/// @notice Chain ID of the chain where the remote token is deployed.
function remoteChainId() external view returns (uint256);
/// @notice Address of the token on the remote domain.
function remoteToken() external view returns (address);
/// @notice Address of the ERC721 bridge on this network.
function bridge() external view returns (address);
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/// @title IWETH
/// @notice Interface for WETH9.
interface IWETH {
/// @notice Emitted when an approval is made.
/// @param src The address that approved the transfer.
/// @param guy The address that was approved to transfer.
/// @param wad The amount that was approved to transfer.
event Approval(address indexed src, address indexed guy, uint256 wad);
/// @notice Emitted when a transfer is made.
/// @param src The address that transferred the WETH.
/// @param dst The address that received the WETH.
/// @param wad The amount of WETH that was transferred.
event Transfer(address indexed src, address indexed dst, uint256 wad);
/// @notice Emitted when a deposit is made.
/// @param dst The address that deposited the WETH.
/// @param wad The amount of WETH that was deposited.
event Deposit(address indexed dst, uint256 wad);
/// @notice Emitted when a withdrawal is made.
/// @param src The address that withdrew the WETH.
/// @param wad The amount of WETH that was withdrawn.
event Withdrawal(address indexed src, uint256 wad);
/// @notice Returns the name of the token.
/// @return The name of the token.
function name() external view returns (string memory);
/// @notice Returns the symbol of the token.
/// @return The symbol of the token.
function symbol() external view returns (string memory);
/// @notice Returns the number of decimals the token uses.
/// @return The number of decimals the token uses.
function decimals() external pure returns (uint8);
/// @notice Returns the balance of the given address.
/// @param owner The address to query the balance of.
/// @return The balance of the given address.
function balanceOf(address owner) external view returns (uint256);
/// @notice Returns the amount of WETH that the spender can transfer on behalf of the owner.
/// @param owner The address that owns the WETH.
/// @param spender The address that is approved to transfer the WETH.
/// @return The amount of WETH that the spender can transfer on behalf of the owner.
function allowance(address owner, address spender) external view returns (uint256);
/// @notice Allows WETH to be deposited by sending ether to the contract.
function deposit() external payable;
/// @notice Withdraws an amount of ETH.
/// @param wad The amount of ETH to withdraw.
function withdraw(uint256 wad) external;
/// @notice Returns the total supply of WETH.
/// @return The total supply of WETH.
function totalSupply() external view returns (uint256);
/// @notice Approves the given address to transfer the WETH on behalf of the caller.
/// @param guy The address that is approved to transfer the WETH.
/// @param wad The amount that is approved to transfer.
/// @return True if the approval was successful.
function approve(address guy, uint256 wad) external returns (bool);
/// @notice Transfers the given amount of WETH to the given address.
/// @param dst The address to transfer the WETH to.
/// @param wad The amount of WETH to transfer.
/// @return True if the transfer was successful.
function transfer(address dst, uint256 wad) external returns (bool);
/// @notice Transfers the given amount of WETH from the given address to the given address.
/// @param src The address to transfer the WETH from.
/// @param dst The address to transfer the WETH to.
/// @param wad The amount of WETH to transfer.
/// @return True if the transfer was successful.
function transferFrom(address src, address dst, uint256 wad) external returns (bool);
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/// @title IWETH
/// @notice Interface for WETH9.
interface IWETH98 {
receive() external payable;
fallback() external payable;
event Approval(address indexed src, address indexed guy, uint256 wad);
event Transfer(address indexed src, address indexed dst, uint256 wad);
event Deposit(address indexed dst, uint256 wad);
event Withdrawal(address indexed src, uint256 wad);
function name() external view returns (string memory);
function symbol() external view returns (string memory);
function decimals() external view returns (uint8);
function balanceOf(address src) external view returns (uint256);
function allowance(address owner, address spender) external view returns (uint256);
function deposit() external payable;
function withdraw(uint256 wad) external;
function totalSupply() external view returns (uint256);
function approve(address guy, uint256 wad) external returns (bool);
function transfer(address dst, uint256 wad) external returns (bool);
function transferFrom(address src, address dst, uint256 wad) external returns (bool);
}
......@@ -11,6 +11,7 @@ import { TransientContext } from "src/libraries/TransientContext.sol";
// Target contracts
import {
CrossL2Inbox,
Identifier,
NotEntered,
NoExecutingDeposits,
InvalidTimestamp,
......@@ -20,7 +21,6 @@ import {
InteropStartAlreadySet
} from "src/L2/CrossL2Inbox.sol";
import { IL1BlockInterop } from "src/L2/interfaces/IL1BlockInterop.sol";
import { ICrossL2Inbox } from "src/L2/interfaces/ICrossL2Inbox.sol";
/// @title CrossL2InboxWithModifiableTransientStorage
/// @dev CrossL2Inbox contract with methods to modify the transient storage.
......@@ -141,7 +141,7 @@ contract CrossL2InboxTest is Test {
/// @dev Tests that the `executeMessage` function succeeds.
function testFuzz_executeMessage_succeeds(
ICrossL2Inbox.Identifier memory _id,
Identifier memory _id,
address _target,
bytes calldata _message,
uint256 _value
......@@ -200,14 +200,14 @@ contract CrossL2InboxTest is Test {
/// @dev Mock reentrant function that calls the `executeMessage` function.
/// @param _id Identifier to pass to the `executeMessage` function.
function mockReentrant(ICrossL2Inbox.Identifier calldata _id) external payable {
function mockReentrant(Identifier calldata _id) external payable {
crossL2Inbox.executeMessage({ _id: _id, _target: address(0), _message: "" });
}
/// @dev Tests that the `executeMessage` function successfully handles reentrant calls.
function testFuzz_executeMessage_reentrant_succeeds(
ICrossL2Inbox.Identifier memory _id1, // identifier passed to `executeMessage` by the initial call.
ICrossL2Inbox.Identifier memory _id2, // identifier passed to `executeMessage` by the reentrant call.
Identifier memory _id1, // identifier passed to `executeMessage` by the initial call.
Identifier memory _id2, // identifier passed to `executeMessage` by the reentrant call.
uint256 _value
)
external
......@@ -272,7 +272,7 @@ contract CrossL2InboxTest is Test {
/// @dev Tests that the `executeMessage` function reverts if the transaction comes from a deposit.
function testFuzz_executeMessage_isDeposit_reverts(
ICrossL2Inbox.Identifier calldata _id,
Identifier calldata _id,
address _target,
bytes calldata _message,
uint256 _value
......@@ -298,7 +298,7 @@ contract CrossL2InboxTest is Test {
/// @dev Tests that the `executeMessage` function reverts when called with an identifier with an invalid timestamp.
function testFuzz_executeMessage_invalidTimestamp_reverts(
ICrossL2Inbox.Identifier calldata _id,
Identifier calldata _id,
address _target,
bytes calldata _message,
uint256 _value
......@@ -329,7 +329,7 @@ contract CrossL2InboxTest is Test {
/// @dev Tests that the `executeMessage` function reverts when called with an identifier with a timestamp earlier
/// than INTEROP_START timestamp
function testFuzz_executeMessage_invalidTimestamp_interopStart_reverts(
ICrossL2Inbox.Identifier memory _id,
Identifier memory _id,
address _target,
bytes calldata _message,
uint256 _value
......@@ -360,7 +360,7 @@ contract CrossL2InboxTest is Test {
/// @dev Tests that the `executeMessage` function reverts when called with an identifier with a chain ID not in
/// dependency set.
function testFuzz_executeMessage_invalidChainId_reverts(
ICrossL2Inbox.Identifier memory _id,
Identifier memory _id,
address _target,
bytes calldata _message,
uint256 _value
......@@ -398,7 +398,7 @@ contract CrossL2InboxTest is Test {
/// @dev Tests that the `executeMessage` function reverts when the target call fails.
function testFuzz_executeMessage_targetCallFailed_reverts(
ICrossL2Inbox.Identifier memory _id,
Identifier memory _id,
address _target,
bytes calldata _message,
uint256 _value
......@@ -443,13 +443,7 @@ contract CrossL2InboxTest is Test {
crossL2Inbox.executeMessage{ value: _value }({ _id: _id, _target: _target, _message: _message });
}
function testFuzz_validateMessage_succeeds(
ICrossL2Inbox.Identifier memory _id,
bytes32 _messageHash
)
external
setInteropStart
{
function testFuzz_validateMessage_succeeds(Identifier memory _id, bytes32 _messageHash) external setInteropStart {
// Ensure that the id's timestamp is valid (less than or equal to the current block timestamp and greater than
// interop start time)
_id.timestamp = bound(_id.timestamp, interopStartTime + 1, block.timestamp);
......@@ -476,12 +470,7 @@ contract CrossL2InboxTest is Test {
crossL2Inbox.validateMessage(_id, _messageHash);
}
function testFuzz_validateMessage_isDeposit_reverts(
ICrossL2Inbox.Identifier calldata _id,
bytes32 _messageHash
)
external
{
function testFuzz_validateMessage_isDeposit_reverts(Identifier calldata _id, bytes32 _messageHash) external {
// Ensure it is a deposit transaction
vm.mockCall({
callee: Predeploys.L1_BLOCK_ATTRIBUTES,
......@@ -499,7 +488,7 @@ contract CrossL2InboxTest is Test {
/// @dev Tests that the `validateMessage` function reverts when called with an identifier with a timestamp later
/// than current block.timestamp.
function testFuzz_validateMessage_invalidTimestamp_reverts(
ICrossL2Inbox.Identifier calldata _id,
Identifier calldata _id,
bytes32 _messageHash
)
external
......@@ -525,7 +514,7 @@ contract CrossL2InboxTest is Test {
/// @dev Tests that the `validateMessage` function reverts when called with an identifier with a timestamp earlier
/// than INTEROP_START timestamp
function testFuzz_validateMessage_invalidTimestamp_interopStart_reverts(
ICrossL2Inbox.Identifier memory _id,
Identifier memory _id,
bytes32 _messageHash
)
external
......@@ -551,7 +540,7 @@ contract CrossL2InboxTest is Test {
/// @dev Tests that the `validateMessage` function reverts when called with an identifier with a chain ID not in the
/// dependency set.
function testFuzz_validateMessage_invalidChainId_reverts(
ICrossL2Inbox.Identifier memory _id,
Identifier memory _id,
bytes32 _messageHash
)
external
......
......@@ -10,8 +10,7 @@ import { Predeploys } from "src/libraries/Predeploys.sol";
import { Hashing } from "src/libraries/Hashing.sol";
// Target contract
import { CrossL2Inbox } from "src/L2/CrossL2Inbox.sol";
import { ICrossL2Inbox } from "src/L2/interfaces/ICrossL2Inbox.sol";
import { CrossL2Inbox, Identifier } from "src/L2/CrossL2Inbox.sol";
import {
L2ToL2CrossDomainMessenger,
NotEntered,
......@@ -218,8 +217,8 @@ contract L2ToL2CrossDomainMessengerTest is Test {
vm.mockCall({ callee: _target, msgValue: _value, data: _message, returnData: abi.encode(true) });
// Construct the SentMessage payload & identifier
ICrossL2Inbox.Identifier memory id =
ICrossL2Inbox.Identifier(Predeploys.L2_TO_L2_CROSS_DOMAIN_MESSENGER, _blockNum, _logIndex, _time, _source);
Identifier memory id =
Identifier(Predeploys.L2_TO_L2_CROSS_DOMAIN_MESSENGER, _blockNum, _logIndex, _time, _source);
bytes memory sentMessage = abi.encodePacked(
abi.encode(L2ToL2CrossDomainMessenger.SentMessage.selector, block.chainid, _target, _nonce), // topics
abi.encode(_sender, _message) // data
......@@ -264,8 +263,8 @@ contract L2ToL2CrossDomainMessengerTest is Test {
vm.expectRevert(EventPayloadNotSentMessage.selector);
// Point to a different remote log that the inbox validates
ICrossL2Inbox.Identifier memory id =
ICrossL2Inbox.Identifier(Predeploys.L2_TO_L2_CROSS_DOMAIN_MESSENGER, _blockNum, _logIndex, _time, _source);
Identifier memory id =
Identifier(Predeploys.L2_TO_L2_CROSS_DOMAIN_MESSENGER, _blockNum, _logIndex, _time, _source);
bytes memory sentMessage =
abi.encode(L2ToL2CrossDomainMessenger.RelayedMessage.selector, _source, _nonce, _msgHash);
......@@ -325,8 +324,8 @@ contract L2ToL2CrossDomainMessengerTest is Test {
vm.expectCall({ callee: target, msgValue: _value, data: message });
// Construct and relay the message
ICrossL2Inbox.Identifier memory id =
ICrossL2Inbox.Identifier(Predeploys.L2_TO_L2_CROSS_DOMAIN_MESSENGER, _blockNum, _logIndex, _time, _source);
Identifier memory id =
Identifier(Predeploys.L2_TO_L2_CROSS_DOMAIN_MESSENGER, _blockNum, _logIndex, _time, _source);
bytes memory sentMessage = abi.encodePacked(
abi.encode(L2ToL2CrossDomainMessenger.SentMessage.selector, block.chainid, target, _nonce), // topics
abi.encode(_sender, message) // data
......@@ -368,8 +367,7 @@ contract L2ToL2CrossDomainMessengerTest is Test {
vm.expectRevert(ReentrantCall.selector);
ICrossL2Inbox.Identifier memory id =
ICrossL2Inbox.Identifier(Predeploys.L2_TO_L2_CROSS_DOMAIN_MESSENGER, 1, 1, 1, _source);
Identifier memory id = Identifier(Predeploys.L2_TO_L2_CROSS_DOMAIN_MESSENGER, 1, 1, 1, _source);
bytes memory sentMessage = abi.encodePacked(
abi.encode(L2ToL2CrossDomainMessenger.SentMessage.selector, block.chainid, address(0), _nonce), // topics
abi.encode(_sender, "") // data
......@@ -407,8 +405,8 @@ contract L2ToL2CrossDomainMessengerTest is Test {
vm.expectCall({ callee: target, msgValue: _value, data: message });
// Construct and relay the message
ICrossL2Inbox.Identifier memory id =
ICrossL2Inbox.Identifier(Predeploys.L2_TO_L2_CROSS_DOMAIN_MESSENGER, _blockNum, _logIndex, _time, _source1);
Identifier memory id =
Identifier(Predeploys.L2_TO_L2_CROSS_DOMAIN_MESSENGER, _blockNum, _logIndex, _time, _source1);
bytes memory sentMessage = abi.encodePacked(
abi.encode(L2ToL2CrossDomainMessenger.SentMessage.selector, block.chainid, target, _nonce), // topics
abi.encode(_sender1, message) // data
......@@ -457,7 +455,7 @@ contract L2ToL2CrossDomainMessengerTest is Test {
// Expect a revert with the IdOriginNotL2ToL2CrossDomainMessenger
vm.expectRevert(IdOriginNotL2ToL2CrossDomainMessenger.selector);
ICrossL2Inbox.Identifier memory id = ICrossL2Inbox.Identifier(_origin, _blockNum, _logIndex, _time, _source);
Identifier memory id = Identifier(_origin, _blockNum, _logIndex, _time, _source);
bytes memory sentMessage = abi.encodePacked(
abi.encode(L2ToL2CrossDomainMessenger.SentMessage.selector, block.chainid, _target, _nonce), // topics
abi.encode(_sender, _message) // data
......@@ -489,8 +487,8 @@ contract L2ToL2CrossDomainMessengerTest is Test {
// Expect a revert with the MessageDestinationNotRelayChain selector
vm.expectRevert(MessageDestinationNotRelayChain.selector);
ICrossL2Inbox.Identifier memory id =
ICrossL2Inbox.Identifier(Predeploys.L2_TO_L2_CROSS_DOMAIN_MESSENGER, _blockNum, _logIndex, _time, _source);
Identifier memory id =
Identifier(Predeploys.L2_TO_L2_CROSS_DOMAIN_MESSENGER, _blockNum, _logIndex, _time, _source);
bytes memory sentMessage = abi.encodePacked(
abi.encode(L2ToL2CrossDomainMessenger.SentMessage.selector, _destination, _target, _nonce), // topics
abi.encode(_sender, _message) // data
......@@ -526,8 +524,8 @@ contract L2ToL2CrossDomainMessengerTest is Test {
// Call `relayMessage` with CrossL2Inbox as the target to provoke revert. The current chain is the destination
// to prevent revert due to invalid destination
ICrossL2Inbox.Identifier memory id =
ICrossL2Inbox.Identifier(Predeploys.L2_TO_L2_CROSS_DOMAIN_MESSENGER, _blockNum, _logIndex, _time, _source);
Identifier memory id =
Identifier(Predeploys.L2_TO_L2_CROSS_DOMAIN_MESSENGER, _blockNum, _logIndex, _time, _source);
bytes memory sentMessage = abi.encodePacked(
abi.encode(
L2ToL2CrossDomainMessenger.SentMessage.selector, block.chainid, Predeploys.CROSS_L2_INBOX, _nonce
......@@ -565,8 +563,8 @@ contract L2ToL2CrossDomainMessengerTest is Test {
// Call `relayMessage` with L2ToL2CrossDomainMessenger as the target to provoke revert. The current chain is the
// destination to prevent revert due to invalid destination
ICrossL2Inbox.Identifier memory id =
ICrossL2Inbox.Identifier(Predeploys.L2_TO_L2_CROSS_DOMAIN_MESSENGER, _blockNum, _logIndex, _time, _source);
Identifier memory id =
Identifier(Predeploys.L2_TO_L2_CROSS_DOMAIN_MESSENGER, _blockNum, _logIndex, _time, _source);
bytes memory sentMessage = abi.encodePacked(
abi.encode(
L2ToL2CrossDomainMessenger.SentMessage.selector,
......@@ -620,8 +618,8 @@ contract L2ToL2CrossDomainMessengerTest is Test {
_source, _nonce, keccak256(abi.encode(block.chainid, _source, _nonce, _sender, _target, _message))
);
ICrossL2Inbox.Identifier memory id =
ICrossL2Inbox.Identifier(Predeploys.L2_TO_L2_CROSS_DOMAIN_MESSENGER, _blockNum, _logIndex, _time, _source);
Identifier memory id =
Identifier(Predeploys.L2_TO_L2_CROSS_DOMAIN_MESSENGER, _blockNum, _logIndex, _time, _source);
bytes memory sentMessage = abi.encodePacked(
abi.encode(L2ToL2CrossDomainMessenger.SentMessage.selector, block.chainid, _target, _nonce), // topics
abi.encode(_sender, _message) // data
......@@ -670,8 +668,8 @@ contract L2ToL2CrossDomainMessengerTest is Test {
// Ensure that the target contract reverts
vm.mockCallRevert({ callee: _target, msgValue: _value, data: _message, revertData: abi.encode(false) });
ICrossL2Inbox.Identifier memory id =
ICrossL2Inbox.Identifier(Predeploys.L2_TO_L2_CROSS_DOMAIN_MESSENGER, _blockNum, _logIndex, _time, _source);
Identifier memory id =
Identifier(Predeploys.L2_TO_L2_CROSS_DOMAIN_MESSENGER, _blockNum, _logIndex, _time, _source);
bytes memory sentMessage = abi.encodePacked(
abi.encode(L2ToL2CrossDomainMessenger.SentMessage.selector, block.chainid, _target, _nonce), // topics
abi.encode(_sender, _message) // data
......
......@@ -45,7 +45,7 @@ import { IGasPriceOracle } from "src/L2/interfaces/IGasPriceOracle.sol";
import { IL1Block } from "src/L2/interfaces/IL1Block.sol";
import { ISuperchainWETH } from "src/L2/interfaces/ISuperchainWETH.sol";
import { IETHLiquidity } from "src/L2/interfaces/IETHLiquidity.sol";
import { IWETH } from "src/universal/interfaces/IWETH.sol";
import { IWETH98 } from "src/universal/interfaces/IWETH98.sol";
import { IGovernanceToken } from "src/governance/interfaces/IGovernanceToken.sol";
import { ILegacyMessagePasser } from "src/legacy/interfaces/ILegacyMessagePasser.sol";
import { ISuperchainTokenBridge } from "src/L2/interfaces/ISuperchainTokenBridge.sol";
......@@ -105,7 +105,7 @@ contract Setup {
IL1Block l1Block = IL1Block(Predeploys.L1_BLOCK_ATTRIBUTES);
IGovernanceToken governanceToken = IGovernanceToken(Predeploys.GOVERNANCE_TOKEN);
ILegacyMessagePasser legacyMessagePasser = ILegacyMessagePasser(Predeploys.LEGACY_MESSAGE_PASSER);
IWETH weth = IWETH(payable(Predeploys.WETH));
IWETH98 weth = IWETH98(payable(Predeploys.WETH));
ISuperchainWETH superchainWeth = ISuperchainWETH(payable(Predeploys.SUPERCHAIN_WETH));
IETHLiquidity ethLiquidity = IETHLiquidity(Predeploys.ETH_LIQUIDITY);
ISuperchainTokenBridge superchainTokenBridge = ISuperchainTokenBridge(Predeploys.SUPERCHAIN_TOKEN_BRIDGE);
......
......@@ -2,7 +2,8 @@
pragma solidity 0.8.15;
import { Bridge_Initializer } from "test/setup/Bridge_Initializer.sol";
import { ILegacyMintableERC20, IOptimismMintableERC20 } from "src/universal/interfaces/IOptimismMintableERC20.sol";
import { IOptimismMintableERC20 } from "src/universal/interfaces/IOptimismMintableERC20.sol";
import { ILegacyMintableERC20 } from "src/universal/interfaces/ILegacyMintableERC20.sol";
import { IERC165 } from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
contract OptimismMintableERC20_Test is Bridge_Initializer {
......
......@@ -30,7 +30,7 @@ contract StandardBridgeTester is StandardBridge {
/// @title LegacyMintable
/// @notice Simple implementation of the legacy OptimismMintableERC20.
contract LegacyMintable is ERC20, ILegacyMintableERC20 {
contract LegacyMintable is ERC20 {
constructor(string memory _name, string memory _ticker) ERC20(_name, _ticker) { }
function l1Token() external pure returns (address) {
......
......@@ -46,6 +46,8 @@ rules:
pattern-regex: function\s+\w+\s*\(\s*([^)]*?\b\w+\s+(?!_)(?!memory\b)(?!calldata\b)(?!storage\b)(?!payable\b)\w+\s*(?=,|\)))
paths:
exclude:
- packages/contracts-bedrock/src/universal/interfaces/IOptimismMintableERC721.sol
- packages/contracts-bedrock/src/universal/interfaces/IWETH98.sol
- op-chain-ops/script/testdata/scripts/ScriptExample.s.sol
- packages/contracts-bedrock/test
- packages/contracts-bedrock/scripts/libraries/Solarray.sol
......@@ -64,6 +66,7 @@ rules:
pattern-regex: returns\s*(\w+\s*)?\(\s*([^)]*?\b\w+\s+(?!memory\b)(?!calldata\b)(?!storage\b)(?!payable\b)\w+(?<!_)\s*(?=,|\)))
paths:
exclude:
- packages/contracts-bedrock/src/dispute/interfaces/IDelayedWETH.sol
- op-chain-ops/script/testdata/scripts/ScriptExample.s.sol
- packages/contracts-bedrock/test/safe-tools
- packages/contracts-bedrock/scripts/libraries/Solarray.sol
......
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