diff --git a/.env.wsteth.swe_mainnet b/.env.wsteth.swe_mainnet new file mode 100644 index 00000000..b071a54f --- /dev/null +++ b/.env.wsteth.swe_mainnet @@ -0,0 +1,90 @@ +RPC_ETH_MAINNET= +RPC_ETH_GOERLI= + +RPC_OPT_MAINNET=https://mainnet.optimism.io +RPC_OPT_GOERLI=https://goerli.optimism.io + +RPC_ARB_MAINNET=https://arb1.arbitrum.io/rpc +RPC_ARB_GOERLI=https://goerli-rollup.arbitrum.io/rpc + +# ############################ +# Etherscan +# ############################ + +ETHERSCAN_API_KEY_ETH= +ETHERSCAN_API_KEY_ARB= +ETHERSCAN_API_KEY_OPT= + +# ############################ +# Bridge/Gateway Deployment +# ############################ + +# Address of the token to deploy the bridge/gateway for +TOKEN= + +# Name of the network environments used by deployment scripts. +# Might be one of: "mainnet", "goerli". +NETWORK=mainnet + +# Run deployment in the forking network instead of public ones +FORKING=true + +# Private key of the deployer account used for deployment process +ETH_DEPLOYER_PRIVATE_KEY= +OPT_DEPLOYER_PRIVATE_KEY= +ARB_DEPLOYER_PRIVATE_KEY= + +L1_DEV_MULTISIG= ? +L1_PROXY_ADMIN= 0x3e40D73EB977Dc6a537aF587D48316feE66E9C8c +L1_BRIDGE_ADMIN= 0x3e40D73EB977Dc6a537aF587D48316feE66E9C8c +L1_DEPOSITS_ENABLED=false +L1_WITHDRAWALS_ENABLED=true +L1_DEPOSITS_ENABLERS=["0x3e40D73EB977Dc6a537aF587D48316feE66E9C8c","0x3cd9F71F80AB08ea5a7Dca348B5e94BC595f26A0"] +L1_DEPOSITS_DISABLERS=["0x3e40D73EB977Dc6a537aF587D48316feE66E9C8c","0x73b047fe6337183A454c5217241D780a932777bD"] +L1_WITHDRAWALS_ENABLERS=["0x3e40D73EB977Dc6a537aF587D48316feE66E9C8c"] +L1_WITHDRAWALS_DISABLERS=["0x3e40D73EB977Dc6a537aF587D48316feE66E9C8c","0x73b047fe6337183A454c5217241D780a932777bD"] + +L2_PROXY_ADMIN= +L2_BRIDGE_ADMIN= +L2_DEPOSITS_ENABLED=true +L2_WITHDRAWALS_ENABLED=true +L2_DEPOSITS_ENABLERS=[] +L2_DEPOSITS_DISABLERS=[] +L2_WITHDRAWALS_ENABLERS=[] +L2_WITHDRAWALS_DISABLERS=[] + +# ############################ +# Integration Acceptance & E2E Testing +# ############################ + +TESTING_ARB_NETWORK= +TESTING_ARB_L1_TOKEN=0x7AEE39c46f20135114e85A03C02aB4FE73fB8127 +TESTING_ARB_L2_TOKEN=0x775ede8029C117effce283b3391E420EacF3c85F +TESTING_ARB_L1_ERC20_TOKEN_GATEWAY=0x0A7e12b563Ba623646a31a09F0182e8aD45D6cfD +TESTING_ARB_L2_ERC20_TOKEN_GATEWAY=0x8c269989D839eE9DaEe64D57C8c41404DF87F722 +TESTING_ARB_L1_GATEWAY_ROUTER=0xa2a8F940752aDc4A3278B63B96d56D72D2b075B1 +TESTING_ARB_L2_GATEWAY_ROUTER=0x57f54f87C44d816f60b92864e23b8c0897D4d81D + +TESTING_OPT_NETWORK= +TESTING_OPT_L1_TOKEN=0xaF8a2F0aE374b03376155BF745A3421Dac711C12 +TESTING_OPT_L2_TOKEN=0xAED5F9aaF167923D34174b8E636aaF040A11f6F7 +TESTING_OPT_L1_ERC20_TOKEN_BRIDGE=0x243b661276670bD17399C488E7287ea4D416115b +TESTING_OPT_L2_ERC20_TOKEN_BRIDGE=0x447CD1794d209Ac4E6B4097B34658bc00C4d0a51 + +# ############################ +# Integration Testing +# ############################ + +TESTING_USE_DEPLOYED_CONTRACTS=false +TESTING_L1_TOKENS_HOLDER= + +TESTING_ARB_GOV_BRIDGE_EXECUTOR= +TESTING_OPT_GOV_BRIDGE_EXECUTOR= + +# ############################ +# E2E Testing +# ############################ + +TESTING_PRIVATE_KEY= +TESTING_OPT_LDO_HOLDER_PRIVATE_KEY= +TESTING_ARB_LDO_HOLDER_PRIVATE_KEY= diff --git a/hardhat.config.ts b/hardhat.config.ts index ed47221c..21baca9a 100644 --- a/hardhat.config.ts +++ b/hardhat.config.ts @@ -83,6 +83,13 @@ const config: HardhatUserConfig = { opt_sepolia_fork: { url: "http://localhost:9545", }, + + swe_mainnet: { + url: env.string("RPC_SWELL_MAINNET", ""), + }, + swe_sepolia: { + url: env.string("RPC_SWELL_SEPOLIA", ""), + }, }, gasReporter: { enabled: env.string("REPORT_GAS", "false") !== "false", diff --git a/package.json b/package.json index 820a38ee..d028768a 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,8 @@ "optimism:test:integration": "hardhat test ./test/optimism/*.integration.test.ts", "optimism:test:acceptance": "hardhat test ./test/optimism/*.acceptance.test.ts", "optimism:test:executor": "hardhat test ./test/bridge-executor/optimism.integration.test.ts", - "optimism:test:launch": "REVERT=false hardhat test ./test/optimism/{_launch.test.ts,bridging.integration.test.ts}" + "optimism:test:launch": "REVERT=false hardhat test ./test/optimism/{_launch.test.ts,bridging.integration.test.ts}", + "swellchain:deploy": "ts-node --files ./scripts/swellchain/deploy-bridge.ts" }, "keywords": [], "author": "", diff --git a/scripts/swellchain/deploy-bridge.ts b/scripts/swellchain/deploy-bridge.ts new file mode 100644 index 00000000..4b4ceed3 --- /dev/null +++ b/scripts/swellchain/deploy-bridge.ts @@ -0,0 +1,80 @@ +import env from "../../utils/env"; +import prompt from "../../utils/prompt"; +import network from "../../utils/network"; +import deployment from "../../utils/deployment"; +import { BridgingManagement } from "../../utils/bridging-management"; +import swellchain from "../../utils/swellchain"; + + +async function main() { + const networkName = env.network(); + const ethOptNetwork = network.multichain(["eth", "swe"], networkName); + + const [ethDeployer] = ethOptNetwork.getSigners(env.privateKey(), { + forking: env.forking(), + }); + const [, sweDeployer] = ethOptNetwork.getSigners( + env.string("SWE_DEPLOYER_PRIVATE_KEY"), + { + forking: env.forking(), + } + ); + + const deploymentConfig = deployment.loadMultiChainDeploymentConfig(); + + const [l1DeployScript, l2DeployScript] = await swellchain + .deployment(networkName, { logger: console }) + .erc20TokenBridgeDeployScript( + deploymentConfig.token, + { + deployer: ethDeployer, + admins: { + proxy: deploymentConfig.l1.proxyAdmin, + bridge: ethDeployer.address, + }, + }, + { + deployer: sweDeployer, + admins: { + proxy: deploymentConfig.l2.proxyAdmin, + bridge: sweDeployer.address, + }, + } + ); + + await deployment.printMultiChainDeploymentConfig( + "Deploy Swellchain Bridge", + ethDeployer, + sweDeployer, + deploymentConfig, + l1DeployScript, + l2DeployScript + ); + + await prompt.proceed(); + + await l1DeployScript.run(); + await l2DeployScript.run(); + + const l1ERC20TokenBridgeProxyDeployStepIndex = 1; + const l1BridgingManagement = new BridgingManagement( + l1DeployScript.getContractAddress(l1ERC20TokenBridgeProxyDeployStepIndex), + ethDeployer, + { logger: console } + ); + + const l2ERC20TokenBridgeProxyDeployStepIndex = 3; + const l2BridgingManagement = new BridgingManagement( + l2DeployScript.getContractAddress(l2ERC20TokenBridgeProxyDeployStepIndex), + sweDeployer, + { logger: console } + ); + + await l1BridgingManagement.setup(deploymentConfig.l1); + await l2BridgingManagement.setup(deploymentConfig.l2); +} + +main().catch((error) => { + console.error(error); + process.exitCode = 1; +}); diff --git a/scripts/swellchain/finalize-message.ts b/scripts/swellchain/finalize-message.ts new file mode 100644 index 00000000..c99c92f2 --- /dev/null +++ b/scripts/swellchain/finalize-message.ts @@ -0,0 +1,34 @@ +import { CrossChainMessenger, MessageStatus } from "@eth-optimism/sdk"; +import env from "../../utils/env"; +import network from "../../utils/network"; + +async function main() { + const networkName = env.network(); + const [l1Signer, l2Signer] = network + .multichain(["eth", "swe"], networkName) + .getSigners(env.privateKey(), { forking: false }); + + const txHash = env.string("TX_HASH"); + + const crossDomainMessenger = new CrossChainMessenger({ + l1ChainId: network.chainId("eth", networkName), + l2ChainId: network.chainId("swe", networkName), + l1SignerOrProvider: l1Signer, + l2SignerOrProvider: l2Signer, + }); + + const status = await crossDomainMessenger.getMessageStatus(txHash); + + if (status !== MessageStatus.READY_FOR_RELAY) { + throw new Error(`Invalid tx status: ${status}`); + } + + console.log("Finalizing the L2 -> L1 message"); + await crossDomainMessenger.finalizeMessage(txHash); + console.log("Message successfully finalized!"); +} + +main().catch((error) => { + console.error(error); + process.exitCode = 1; +}); diff --git a/scripts/swellchain/prove-message.ts b/scripts/swellchain/prove-message.ts new file mode 100644 index 00000000..cc287b6b --- /dev/null +++ b/scripts/swellchain/prove-message.ts @@ -0,0 +1,37 @@ +import { CrossChainMessenger, MessageStatus } from "@eth-optimism/sdk"; +import env from "../../utils/env"; +import network from "../../utils/network"; + +async function main() { + const networkName = env.network(); + const [l1Signer, l2Signer] = network + .multichain(["eth", "swe"], networkName) + .getSigners(env.privateKey(), { forking: false }); + + const txHash = env.string("TX_HASH"); + + const crossChainMessenger = new CrossChainMessenger({ + l1ChainId: network.chainId("eth", networkName), + l2ChainId: network.chainId("swe", networkName), + l1SignerOrProvider: l1Signer, + l2SignerOrProvider: l2Signer, + bedrock: true, + }); + + const status = await crossChainMessenger.getMessageStatus(txHash); + + if (status !== MessageStatus.READY_TO_PROVE) { + throw new Error(`Invalid tx status: ${status}`); + } + + console.log("Prove the L2 -> L1 message"); + const tx = await crossChainMessenger.proveMessage(txHash); + console.log(`Waiting for the prove tx ${tx.hash}...`); + await tx.wait(); + console.log(`Message was proved successfully!`); +} + +main().catch((error) => { + console.error(error); + process.exitCode = 1; +}); diff --git a/scripts/swellchain/update-ethereum-executor.ts b/scripts/swellchain/update-ethereum-executor.ts new file mode 100644 index 00000000..ac05474e --- /dev/null +++ b/scripts/swellchain/update-ethereum-executor.ts @@ -0,0 +1,149 @@ +import { assert } from "chai"; +import { ethers } from "hardhat"; +import { GovBridgeExecutor__factory } from "../../typechain"; +import env from "../../utils/env"; +import lido from "../../utils/lido"; +import network from "../../utils/network"; +import swellchain from "../../utils/swellchain"; +import prompt from "../../utils/prompt"; + +// Set address of the bridge executor to run the script +const GOV_BRIDGE_EXECUTOR = ""; + +async function main() { + const isForking = env.forking(); + const networkName = env.network(); + const ethSweNetwork = network.multichain(["eth", "swe"], networkName); + + const [l1LDOHolder] = ethSweNetwork.getSigners( + env.string("TESTING_SWE_LDO_HOLDER_PRIVATE_KEY"), + { forking: isForking } + ); + const [, sweRunner] = ethSweNetwork.getSigners(env.privateKey(), { + forking: isForking, + }); + + const govBridgeExecutor = GovBridgeExecutor__factory.connect( + GOV_BRIDGE_EXECUTOR, + sweRunner + ); + + const newEthExecutorLidoDAO = lido(networkName, l1LDOHolder); + const oldEthExecutorLidoDAO = lido( + networkName === "mainnet" ? "mainnet_test" : networkName, + l1LDOHolder + ); + const prevEthGovExecutorAddress = + await govBridgeExecutor.getEthereumGovernanceExecutor(); + + assert.equal( + oldEthExecutorLidoDAO.agent.address.toLocaleLowerCase(), + prevEthGovExecutorAddress.toLowerCase(), + `${oldEthExecutorLidoDAO.agent.address} is not current ethereumGovernanceExecutor` + ); + + console.log(` · Is forking: ${isForking}`); + console.log(` · Network Name: ${networkName}`); + console.log( + ` · Prev Ethereum Governance Executor: ${prevEthGovExecutorAddress}` + ); + console.log( + ` · New Ethereum Governance Executor: ${newEthExecutorLidoDAO.agent.address}` + ); + console.log(` · LDO Holder: ${l1LDOHolder.address}`); + console.log(` · LDO Holder ETH balance: ${await l1LDOHolder.getBalance()}`); + console.log(` · L2 tx runner: ${sweRunner.address}`); + console.log(` · L2 tx runner ETH balance: ${await sweRunner.getBalance()}`); + + await prompt.proceed(); + + console.log(`Preparing the voting tx...`); + + const sweAddresses = swellchain.addresses(networkName); + + // Prepare data for Governance Bridge Executor + const executorCalldata = await govBridgeExecutor.interface.encodeFunctionData( + "queue", + [ + [GOV_BRIDGE_EXECUTOR], + [0], + ["updateEthereumGovernanceExecutor(address)"], + [ + ethers.utils.defaultAbiCoder.encode( + ["address"], + [newEthExecutorLidoDAO.agent.address] + ), + ], + [false], + ] + ); + + const { callvalue, calldata } = await swellchain + .messaging(networkName, { forking: isForking }) + .prepareL2Message({ + calldata: executorCalldata, + recipient: GOV_BRIDGE_EXECUTOR, + sender: oldEthExecutorLidoDAO.agent.address, + }); + + const createVoteTx = await oldEthExecutorLidoDAO.createVote( + l1LDOHolder, + "Update ethereumGovernanceExecutor on Swellchain Governance Bridge Executor", + { + address: oldEthExecutorLidoDAO.agent.address, + signature: "execute(address,uint256,bytes)", + decodedCallData: [ + sweAddresses.L1CrossDomainMessenger, + callvalue, + calldata, + ], + } + ); + + console.log("Creating voting to update ethereumGovernanceExecutor..."); + await createVoteTx.wait(); + console.log(`Vote was created!`); + + const votesCount = await oldEthExecutorLidoDAO.voting.votesLength(); + const voteId = votesCount.sub(1); + + console.log(`New vote id ${voteId.toString()}`); + console.log(`Voting for and executing the vote...`); + + const voteAndExecuteTx = await oldEthExecutorLidoDAO.voteAndExecute( + l1LDOHolder, + voteId, + true + ); + const executeTxReceipt = await voteAndExecuteTx.wait(); + + console.log(`Vote ${voteId.toString()} was executed!`); + + console.log(`Waiting for L2 transaction...`); + await swellchain + .messaging(networkName, { forking: isForking }) + .waitForL2Message(executeTxReceipt.transactionHash); + + console.log(`Message delivered to L2`); + + console.log("Executing the queued task..."); + // execute task on L2 + const tasksCount = await govBridgeExecutor.getActionsSetCount(); + const targetTaskId = tasksCount.toNumber() - 1; + + const tx = await govBridgeExecutor.execute(targetTaskId); + await tx.wait(); + console.log(`Task executed on L2!`); + + const ethereumGovernanceExecutor = + await govBridgeExecutor.getEthereumGovernanceExecutor(); + + console.log( + `New ethereum governance executor is: ${ethereumGovernanceExecutor}` + ); +} + +main().catch((error) => { + console.error(error); + process.exitCode = 1; +}); diff --git a/utils/network.ts b/utils/network.ts index 1564aa27..a52f122e 100644 --- a/utils/network.ts +++ b/utils/network.ts @@ -6,7 +6,7 @@ import { HardhatRuntimeEnvironment, HttpNetworkConfig } from "hardhat/types"; import env from "./env"; -type ChainNameShort = "arb" | "opt" | "eth"; +type ChainNameShort = "arb" | "opt" | "eth" | "swe"; export type NetworkName = "sepolia" | "mainnet"; export type SignerOrProvider = Signer | Provider; @@ -23,6 +23,10 @@ const HARDHAT_NETWORK_NAMES = { sepolia: "opt_sepolia", mainnet: "opt_mainnet", }, + swe: { + sepolia: "swe_sepolia", + mainnet: "swe_mainnet", + }, }; const HARDHAT_NETWORK_NAMES_FORK = { @@ -38,6 +42,10 @@ const HARDHAT_NETWORK_NAMES_FORK = { sepolia: "opt_sepolia_fork", mainnet: "opt_mainnet_fork", }, + swe: { + sepolia: "swe_sepolia_fork", + mainnet: "swe_mainnet_fork", + }, }; export function getConfig(networkName: string, hre: HardhatRuntimeEnvironment) { @@ -129,6 +137,10 @@ function getChainId(protocol: ChainNameShort, networkName: NetworkName) { mainnet: 42161, sepolia: 421613, }, + swe:{ + mainnet: 1923, + sepolia: 1924, + } }; const chainId = chainIds[protocol][networkName]; if (!chainId) { @@ -148,6 +160,9 @@ function getBlockExplorerBaseUrlByChainId(chainId: number) { // optimism 10: "https://optimistic.etherscan.io", 11155420: "https://blockscout.com/optimism/sepolia", + // swellchain + 1923: "https://swell-mainnet.alt.technology", + 1924: "https://swell-testnet.alt.technology", // forked node 31337: "https://etherscan.io", }; diff --git a/utils/swellchain/addresses.ts b/utils/swellchain/addresses.ts new file mode 100644 index 00000000..82b73c71 --- /dev/null +++ b/utils/swellchain/addresses.ts @@ -0,0 +1,26 @@ +import { NetworkName } from "../network"; +import { SweContractAddresses, CommonOptions } from "./types"; + +const SwellchainMainnetAddresses: SweContractAddresses = { + L1CrossDomainMessenger: "0x0000000000000000000000000000000000000000", // todo + L2CrossDomainMessenger: "0x4200000000000000000000000000000000000007" +}; + +const SwellchainSepoliaAddresses: SweContractAddresses = { + L1CrossDomainMessenger: "0x0000000000000000000000000000000000000000", // todo + L2CrossDomainMessenger: "0x4200000000000000000000000000000000000007", +}; + +export default function addresses( + networkName: NetworkName, + options: CommonOptions = {} +) { + switch (networkName) { + case "mainnet": + return { ...SwellchainMainnetAddresses, ...options.customAddresses }; + case "sepolia": + return { ...SwellchainSepoliaAddresses, ...options.customAddresses }; + default: + throw new Error(`Network "${networkName}" is not supported`); + } +} diff --git a/utils/swellchain/artifacts/OptimismBridgeExecutor.json b/utils/swellchain/artifacts/OptimismBridgeExecutor.json new file mode 100644 index 00000000..13e87433 --- /dev/null +++ b/utils/swellchain/artifacts/OptimismBridgeExecutor.json @@ -0,0 +1,714 @@ +{ + "_format": "hh-sol-artifact-1", + "contractName": "OptimismBridgeExecutor", + "sourceName": "contracts/bridges/OptimismBridgeExecutor.sol", + "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "ovmL2CrossDomainMessenger", + "type": "address" + }, + { + "internalType": "address", + "name": "ethereumGovernanceExecutor", + "type": "address" + }, + { + "internalType": "uint256", + "name": "delay", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "gracePeriod", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "minimumDelay", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "maximumDelay", + "type": "uint256" + }, + { + "internalType": "address", + "name": "guardian", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [], + "name": "DelayLongerThanMax", + "type": "error" + }, + { + "inputs": [], + "name": "DelayShorterThanMin", + "type": "error" + }, + { + "inputs": [], + "name": "DuplicateAction", + "type": "error" + }, + { + "inputs": [], + "name": "EmptyTargets", + "type": "error" + }, + { + "inputs": [], + "name": "FailedActionExecution", + "type": "error" + }, + { + "inputs": [], + "name": "GracePeriodTooShort", + "type": "error" + }, + { + "inputs": [], + "name": "InconsistentParamsLength", + "type": "error" + }, + { + "inputs": [], + "name": "InsufficientBalance", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidActionsSetId", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidInitParams", + "type": "error" + }, + { + "inputs": [], + "name": "MaximumDelayTooShort", + "type": "error" + }, + { + "inputs": [], + "name": "MinimumDelayTooLong", + "type": "error" + }, + { + "inputs": [], + "name": "NotGuardian", + "type": "error" + }, + { + "inputs": [], + "name": "OnlyCallableByThis", + "type": "error" + }, + { + "inputs": [], + "name": "OnlyQueuedActions", + "type": "error" + }, + { + "inputs": [], + "name": "TimelockNotFinished", + "type": "error" + }, + { + "inputs": [], + "name": "UnauthorizedEthereumExecutor", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "id", + "type": "uint256" + } + ], + "name": "ActionsSetCanceled", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "id", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "initiatorExecution", + "type": "address" + }, + { + "indexed": false, + "internalType": "bytes[]", + "name": "returnedData", + "type": "bytes[]" + } + ], + "name": "ActionsSetExecuted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "id", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "address[]", + "name": "targets", + "type": "address[]" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "values", + "type": "uint256[]" + }, + { + "indexed": false, + "internalType": "string[]", + "name": "signatures", + "type": "string[]" + }, + { + "indexed": false, + "internalType": "bytes[]", + "name": "calldatas", + "type": "bytes[]" + }, + { + "indexed": false, + "internalType": "bool[]", + "name": "withDelegatecalls", + "type": "bool[]" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "executionTime", + "type": "uint256" + } + ], + "name": "ActionsSetQueued", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "oldDelay", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newDelay", + "type": "uint256" + } + ], + "name": "DelayUpdate", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldEthereumGovernanceExecutor", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newEthereumGovernanceExecutor", + "type": "address" + } + ], + "name": "EthereumGovernanceExecutorUpdate", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "oldGracePeriod", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newGracePeriod", + "type": "uint256" + } + ], + "name": "GracePeriodUpdate", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldGuardian", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newGuardian", + "type": "address" + } + ], + "name": "GuardianUpdate", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "oldMaximumDelay", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newMaximumDelay", + "type": "uint256" + } + ], + "name": "MaximumDelayUpdate", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "oldMinimumDelay", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newMinimumDelay", + "type": "uint256" + } + ], + "name": "MinimumDelayUpdate", + "type": "event" + }, + { + "inputs": [], + "name": "OVM_L2_CROSS_DOMAIN_MESSENGER", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "actionsSetId", + "type": "uint256" + } + ], + "name": "cancel", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "actionsSetId", + "type": "uint256" + } + ], + "name": "execute", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "target", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "executeDelegateCall", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + }, + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "actionsSetId", + "type": "uint256" + } + ], + "name": "getActionsSetById", + "outputs": [ + { + "components": [ + { + "internalType": "address[]", + "name": "targets", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "values", + "type": "uint256[]" + }, + { + "internalType": "string[]", + "name": "signatures", + "type": "string[]" + }, + { + "internalType": "bytes[]", + "name": "calldatas", + "type": "bytes[]" + }, + { + "internalType": "bool[]", + "name": "withDelegatecalls", + "type": "bool[]" + }, + { + "internalType": "uint256", + "name": "executionTime", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "executed", + "type": "bool" + }, + { + "internalType": "bool", + "name": "canceled", + "type": "bool" + } + ], + "internalType": "struct IExecutorBase.ActionsSet", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getActionsSetCount", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "actionsSetId", + "type": "uint256" + } + ], + "name": "getCurrentState", + "outputs": [ + { + "internalType": "enum IExecutorBase.ActionsSetState", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getDelay", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getEthereumGovernanceExecutor", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getGracePeriod", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getGuardian", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getMaximumDelay", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getMinimumDelay", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "actionHash", + "type": "bytes32" + } + ], + "name": "isActionQueued", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "targets", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "values", + "type": "uint256[]" + }, + { + "internalType": "string[]", + "name": "signatures", + "type": "string[]" + }, + { + "internalType": "bytes[]", + "name": "calldatas", + "type": "bytes[]" + }, + { + "internalType": "bool[]", + "name": "withDelegatecalls", + "type": "bool[]" + } + ], + "name": "queue", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "receiveFunds", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "delay", + "type": "uint256" + } + ], + "name": "updateDelay", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "ethereumGovernanceExecutor", + "type": "address" + } + ], + "name": "updateEthereumGovernanceExecutor", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "gracePeriod", + "type": "uint256" + } + ], + "name": "updateGracePeriod", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "guardian", + "type": "address" + } + ], + "name": "updateGuardian", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "maximumDelay", + "type": "uint256" + } + ], + "name": "updateMaximumDelay", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "minimumDelay", + "type": "uint256" + } + ], + "name": "updateMinimumDelay", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "bytecode": "0x60a06040523480156200001157600080fd5b50604051620027ec380380620027ec833981016040819052620000349162000280565b8585858585858484848484610258841080620000505750818310155b806200005b57508285105b806200006657508185115b156200008557604051630a5addd160e21b815260040160405180910390fd5b6200009085620000f6565b6200009b8462000137565b620000a68362000178565b620000b182620001b9565b620000bc81620001fa565b5050600880546001600160a01b0319166001600160a01b039a8b16179055505050509a90931660805250620002f198505050505050505050565b60005460408051918252602082018390527f43de56b886294fc29767e51a88b5c67fd24aefebc5ddf813b1d9b91b1df38444910160405180910390a1600055565b60015460408051918252602082018390527f9953f3a71052edcd4ae7a0f97302839d1dda32ab93c1039207c91c866b094f72910160405180910390a1600155565b60025460408051918252602082018390527fc534cdcbe9b52100810d787afd57e4174322776fcb58872ea706f23e9319fa8d910160405180910390a1600255565b60035460408051918252602082018390527faf46013422363beb5e6f00ab923cffe3574670494c864de2828b9d7c201fdde5910160405180910390a1600355565b600454604080516001600160a01b03928316815291831660208301527f85bd8788d3c4a160f0f6254229589f137d5633a870dcb46f99ffe07b4da1894b910160405180910390a1600480546001600160a01b0319166001600160a01b0392909216919091179055565b80516001600160a01b03811681146200027b57600080fd5b919050565b600080600080600080600060e0888a0312156200029c57600080fd5b620002a78862000263565b9650620002b76020890162000263565b955060408801519450606088015193506080880151925060a08801519150620002e360c0890162000263565b905092959891949750929550565b6080516124d16200031b6000396000818161021e01528181610c300152610c7901526124d16000f3fe6080604052600436106101345760003560e01c8063b3c82e92116100ab578063d9a4cbdf1161006f578063d9a4cbdf14610361578063dbd1838814610381578063e471b02614610396578063e68a5c3d146103b6578063fc525395146103d6578063fe0d94c1146103f657600080fd5b8063b3c82e92146102cb578063b68df16d146102f8578063c3a7688614610319578063cebc9a8214610337578063d89aac391461034c57600080fd5b80635ab98d5a116100fd5780635ab98d5a146101cc57806364d62353146101ec5780636a4df1df1461020c5780638533f33714610258578063a75b87d21461026d578063b1fc87961461028b57600080fd5b80625c33e11461013957806303c276211461013b578063083a73a21461015f57806340e58ee51461017f5780635748c1301461019f575b600080fd5b005b34801561014757600080fd5b506002545b6040519081526020015b60405180910390f35b34801561016b57600080fd5b5061013961017a366004611a8d565b610409565b34801561018b57600080fd5b5061013961019a366004611a8d565b610462565b3480156101ab57600080fd5b506101bf6101ba366004611a8d565b61070d565b6040516101569190611abc565b3480156101d857600080fd5b506101396101e7366004611a8d565b6107a3565b3480156101f857600080fd5b50610139610207366004611a8d565b6107ef565b34801561021857600080fd5b506102407f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b039091168152602001610156565b34801561026457600080fd5b5060055461014c565b34801561027957600080fd5b506004546001600160a01b0316610240565b34801561029757600080fd5b506102bb6102a6366004611a8d565b60009081526007602052604090205460ff1690565b6040519015158152602001610156565b3480156102d757600080fd5b506102eb6102e6366004611a8d565b610821565b6040516101569190611c3b565b61030b610306366004611d1c565b610b94565b604051610156929190611da1565b34801561032557600080fd5b506008546001600160a01b0316610240565b34801561034357600080fd5b5060005461014c565b34801561035857600080fd5b5060035461014c565b34801561036d57600080fd5b5061013961037c3660046120fb565b610c25565b34801561038d57600080fd5b5060015461014c565b3480156103a257600080fd5b506101396103b1366004611a8d565b610d26565b3480156103c257600080fd5b506101396103d13660046121cd565b610d71565b3480156103e257600080fd5b506101396103f13660046121cd565b610dfa565b610139610404366004611a8d565b610e23565b33301461042957604051631dbf5f2360e01b815260040160405180910390fd5b600254811161044b5760405163cb2f2b2360e01b815260040160405180910390fd5b6104548161114b565b61045f60005461118c565b50565b6004546001600160a01b0316331461048d576040516377b6878160e11b815260040160405180910390fd5b60006104988261070d565b60038111156104a9576104a9611aa6565b146104c75760405163050ac78b60e11b815260040160405180910390fd5b60008181526006602081905260408220908101805461ff001916610100179055805490915b818110156106dc576106d483600001828154811061050c5761050c6121f1565b6000918252602090912001546001850180546001600160a01b03909216918490811061053a5761053a6121f1565b906000526020600020015485600201848154811061055a5761055a6121f1565b90600052602060002001805461056f90612207565b80601f016020809104026020016040519081016040528092919081815260200182805461059b90612207565b80156105e85780601f106105bd576101008083540402835291602001916105e8565b820191906000526020600020905b8154815290600101906020018083116105cb57829003601f168201915b5050505050866003018581548110610602576106026121f1565b90600052602060002001805461061790612207565b80601f016020809104026020016040519081016040528092919081815260200182805461064390612207565b80156106905780601f1061066557610100808354040283529160200191610690565b820191906000526020600020905b81548152906001019060200180831161067357829003601f168201915b505050505087600501548860040187815481106106af576106af6121f1565b90600052602060002090602091828204019190069054906101000a900460ff166111d2565b6001016104ec565b5060405183907f0743c673685efcbf3db8591d9e1d98336bc844fe4f4599e6f7efb6d71c02563490600090a2505050565b600081600554116107315760405163e5bc0e7b60e01b815260040160405180910390fd5b600082815260066020819052604090912090810154610100900460ff161561075c5750600292915050565b600681015460ff16156107725750600192915050565b6001548160050154610784919061223c565b4211156107945750600392915050565b50600092915050565b50919050565b3330146107c357604051631dbf5f2360e01b815260040160405180910390fd5b6102588110156107e6576040516301f6f9e560e71b815260040160405180910390fd5b61045f81611224565b33301461080f57604051631dbf5f2360e01b815260040160405180910390fd5b6108188161118c565b61045f81611265565b61086d6040518061010001604052806060815260200160608152602001606081526020016060815260200160608152602001600081526020016000151581526020016000151581525090565b6000828152600660209081526040918290208251815461012093810282018401909452610100810184815290939192849284918401828280156108d957602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116108bb575b505050505081526020016001820180548060200260200160405190810160405280929190818152602001828054801561093157602002820191906000526020600020905b81548152602001906001019080831161091d575b5050505050815260200160028201805480602002602001604051908101604052809291908181526020016000905b82821015610a0b57838290600052602060002001805461097e90612207565b80601f01602080910402602001604051908101604052809291908181526020018280546109aa90612207565b80156109f75780601f106109cc576101008083540402835291602001916109f7565b820191906000526020600020905b8154815290600101906020018083116109da57829003601f168201915b50505050508152602001906001019061095f565b50505050815260200160038201805480602002602001604051908101604052809291908181526020016000905b82821015610ae4578382906000526020600020018054610a5790612207565b80601f0160208091040260200160405190810160405280929190818152602001828054610a8390612207565b8015610ad05780601f10610aa557610100808354040283529160200191610ad0565b820191906000526020600020905b815481529060010190602001808311610ab357829003601f168201915b505050505081526020019060010190610a38565b50505050815260200160048201805480602002602001604051908101604052809291908181526020018280548015610b5b57602002820191906000526020600020906000905b825461010083900a900460ff161515815260206001928301818104948501949093039092029101808411610b2a5790505b50505091835250506005820154602082015260069091015460ff8082161515604084015261010090910416151560609091015292915050565b60006060333014610bb857604051631dbf5f2360e01b815260040160405180910390fd5b60006060866001600160a01b03168686604051610bd6929190612262565b600060405180830381855af49150503d8060008114610c11576040519150601f19603f3d011682016040523d82523d6000602084013e610c16565b606091505b50909890975095505050505050565b336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016141580610cf4575060085460408051636e296e4560e01b815290516001600160a01b03928316927f00000000000000000000000000000000000000000000000000000000000000001691636e296e459160048083019260209291908290030181865afa158015610cc4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ce89190612272565b6001600160a01b031614155b15610d12576040516359e8359960e01b815260040160405180910390fd5b610d1f85858585856112a6565b5050505050565b333014610d4657604051631dbf5f2360e01b815260040160405180910390fd5b6003548110610d68576040516301b1029b60e61b815260040160405180910390fd5b61045481611513565b333014610d9157604051631dbf5f2360e01b815260040160405180910390fd5b600854604080516001600160a01b03928316815291831660208301527f01dd0ca50426f21c1b37ce7f3e95eef45b4a55bc5da80a7b67b2c65a7463caf0910160405180910390a1600880546001600160a01b0319166001600160a01b0392909216919091179055565b333014610e1a57604051631dbf5f2360e01b815260040160405180910390fd5b61045f81611554565b6000610e2e8261070d565b6003811115610e3f57610e3f611aa6565b14610e5d5760405163050ac78b60e11b815260040160405180910390fd5b60008181526006602052604090206005810154421015610e9057604051635192dd5560e01b815260040160405180910390fd5b60068101805460ff19166001179055805460008167ffffffffffffffff811115610ebc57610ebc611dc4565b604051908082528060200260200182016040528015610eef57816020015b6060815260200190600190039081610eda5790505b50905060005b82811015611102576110dd846000018281548110610f1557610f156121f1565b6000918252602090912001546001860180546001600160a01b039092169184908110610f4357610f436121f1565b9060005260206000200154866002018481548110610f6357610f636121f1565b906000526020600020018054610f7890612207565b80601f0160208091040260200160405190810160405280929190818152602001828054610fa490612207565b8015610ff15780601f10610fc657610100808354040283529160200191610ff1565b820191906000526020600020905b815481529060010190602001808311610fd457829003601f168201915b505050505087600301858154811061100b5761100b6121f1565b90600052602060002001805461102090612207565b80601f016020809104026020016040519081016040528092919081815260200182805461104c90612207565b80156110995780601f1061106e57610100808354040283529160200191611099565b820191906000526020600020905b81548152906001019060200180831161107c57829003601f168201915b505050505088600501548960040187815481106110b8576110b86121f1565b90600052602060002090602091828204019190069054906101000a900460ff166115bd565b8282815181106110ef576110ef6121f1565b6020908102919091010152600101610ef5565b50336001600160a01b0316847ff5efc4bb09a12b6c9561a7e7ab02938a72a4351316b473d574fdaaa89c43eb9a8360405161113d919061228f565b60405180910390a350505050565b60035460408051918252602082018390527faf46013422363beb5e6f00ab923cffe3574670494c864de2828b9d7c201fdde5910160405180910390a1600355565b6002548110156111af576040516361759e6560e01b815260040160405180910390fd5b60035481111561045f576040516386dac63560e01b815260040160405180910390fd5b60008686868686866040516020016111ef969594939291906122a2565b60408051601f198184030181529181528151602092830120600090815260079092529020805460ff1916905550505050505050565b60015460408051918252602082018390527f9953f3a71052edcd4ae7a0f97302839d1dda32ab93c1039207c91c866b094f72910160405180910390a1600155565b60005460408051918252602082018390527f43de56b886294fc29767e51a88b5c67fd24aefebc5ddf813b1d9b91b1df38444910160405180910390a1600055565b84516112c557604051636a8e3e9360e11b815260040160405180910390fd5b84518451811415806112d8575083518114155b806112e4575082518114155b806112f0575081518114155b1561130e57604051630d10f63b60e01b815260040160405180910390fd5b6005546000805461131f904261223c565b600580546001019055905060005b83811015611440576000898281518110611349576113496121f1565b6020026020010151898381518110611363576113636121f1565b602002602001015189848151811061137d5761137d6121f1565b6020026020010151898581518110611397576113976121f1565b6020026020010151868a87815181106113b2576113b26121f1565b60200260200101516040516020016113cf969594939291906122a2565b6040516020818303038152906040528051906020012090506114008160009081526007602052604090205460ff1690565b1561141e57604051633b2f04e360e21b815260040160405180910390fd5b6000908152600760205260409020805460ff191660019081179091550161132d565b506000828152600660209081526040909120895190916114649183918c01906117a3565b50875161147a90600183019060208b0190611808565b50865161149090600283019060208a0190611843565b5085516114a6906003830190602089019061189c565b5084516114bc90600483019060208801906118f5565b50818160050181905550827f0325966a4aa089b42f4766ec96f599405102bb309e065f24874aff59082dbc8b8a8a8a8a8a88604051611500969594939291906122f6565b60405180910390a2505050505050505050565b60025460408051918252602082018390527fc534cdcbe9b52100810d787afd57e4174322776fcb58872ea706f23e9319fa8d910160405180910390a1600255565b600454604080516001600160a01b03928316815291831660208301527f85bd8788d3c4a160f0f6254229589f137d5633a870dcb46f99ffe07b4da1894b910160405180910390a1600480546001600160a01b0319166001600160a01b0392909216919091179055565b6060854710156115e057604051631e9acf1760e31b815260040160405180910390fd5b60008787878787876040516020016115fd969594939291906122a2565b60408051601f198184030181529181528151602092830120600081815260079093529120805460ff19169055865190915060609061163c575084611668565b86805190602001208660405160200161165692919061239d565b60405160208183030381529060405290505b6000606085156116ea5760405163b68df16d60e01b8152309063b68df16d908c90611699908f9088906004016123ce565b60006040518083038185885af11580156116b7573d6000803e3d6000fd5b50505050506040513d6000823e601f3d908101601f191682016040526116e091908101906123f2565b909250905061174c565b8a6001600160a01b03168a84604051611703919061247f565b60006040518083038185875af1925050503d8060008114611740576040519150601f19603f3d011682016040523d82523d6000602084013e611745565b606091505b5090925090505b6117568282611765565b9b9a5050505050505050505050565b6060821561177457508061179d565b8151156117845781518083602001fd5b6040516332f63ed360e21b815260040160405180910390fd5b92915050565b8280548282559060005260206000209081019282156117f8579160200282015b828111156117f857825182546001600160a01b0319166001600160a01b039091161782556020909201916001909101906117c3565b50611804929150611991565b5090565b8280548282559060005260206000209081019282156117f8579160200282015b828111156117f8578251825591602001919060010190611828565b828054828255906000526020600020908101928215611890579160200282015b8281111561189057825180516118809184916020909101906119a6565b5091602001919060010190611863565b50611804929150611a19565b8280548282559060005260206000209081019282156118e9579160200282015b828111156118e957825180516118d99184916020909101906119a6565b50916020019190600101906118bc565b50611804929150611a36565b82805482825590600052602060002090601f016020900481019282156117f85791602002820160005b8382111561195b57835183826101000a81548160ff021916908315150217905550926020019260010160208160000104928301926001030261191e565b80156119885782816101000a81549060ff021916905560010160208160000104928301926001030261195b565b50506118049291505b5b808211156118045760008155600101611992565b8280546119b290612207565b90600052602060002090601f0160209004810192826119d457600085556117f8565b82601f106119ed57805160ff19168380011785556117f8565b828001600101855582156117f857918201828111156117f8578251825591602001919060010190611828565b80821115611804576000611a2d8282611a53565b50600101611a19565b80821115611804576000611a4a8282611a53565b50600101611a36565b508054611a5f90612207565b6000825580601f10611a6f575050565b601f01602090049060005260206000209081019061045f9190611991565b600060208284031215611a9f57600080fd5b5035919050565b634e487b7160e01b600052602160045260246000fd5b6020810160048310611ade57634e487b7160e01b600052602160045260246000fd5b91905290565b600081518084526020808501945080840160005b83811015611b1d5781516001600160a01b031687529582019590820190600101611af8565b509495945050505050565b600081518084526020808501945080840160005b83811015611b1d57815187529582019590820190600101611b3c565b60005b83811015611b73578181015183820152602001611b5b565b83811115611b82576000848401525b50505050565b60008151808452611ba0816020860160208601611b58565b601f01601f19169290920160200192915050565b600081518084526020808501808196508360051b8101915082860160005b85811015611bfc578284038952611bea848351611b88565b98850198935090840190600101611bd2565b5091979650505050505050565b600081518084526020808501945080840160005b83811015611b1d578151151587529582019590820190600101611c1d565b6020815260008251610100806020850152611c5a610120850183611ae4565b91506020850151601f1980868503016040870152611c788483611b28565b93506040870151915080868503016060870152611c958483611bb4565b93506060870151915080868503016080870152611cb28483611bb4565b935060808701519150808685030160a087015250611cd08382611c09565b92505060a085015160c085015260c0850151611cf060e086018215159052565b5060e0850151801515858301525090949350505050565b6001600160a01b038116811461045f57600080fd5b600080600060408486031215611d3157600080fd5b8335611d3c81611d07565b9250602084013567ffffffffffffffff80821115611d5957600080fd5b818601915086601f830112611d6d57600080fd5b813581811115611d7c57600080fd5b876020828501011115611d8e57600080fd5b6020830194508093505050509250925092565b8215158152604060208201526000611dbc6040830184611b88565b949350505050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff81118282101715611e0357611e03611dc4565b604052919050565b600067ffffffffffffffff821115611e2557611e25611dc4565b5060051b60200190565b600082601f830112611e4057600080fd5b81356020611e55611e5083611e0b565b611dda565b82815260059290921b84018101918181019086841115611e7457600080fd5b8286015b84811015611e98578035611e8b81611d07565b8352918301918301611e78565b509695505050505050565b600082601f830112611eb457600080fd5b81356020611ec4611e5083611e0b565b82815260059290921b84018101918181019086841115611ee357600080fd5b8286015b84811015611e985780358352918301918301611ee7565b600067ffffffffffffffff821115611f1857611f18611dc4565b50601f01601f191660200190565b6000611f34611e5084611efe565b9050828152838383011115611f4857600080fd5b828260208301376000602084830101529392505050565b600082601f830112611f7057600080fd5b81356020611f80611e5083611e0b565b82815260059290921b84018101918181019086841115611f9f57600080fd5b8286015b84811015611e9857803567ffffffffffffffff811115611fc35760008081fd5b8701603f81018913611fd55760008081fd5b611fe6898683013560408401611f26565b845250918301918301611fa3565b600082601f83011261200557600080fd5b81356020612015611e5083611e0b565b82815260059290921b8401810191818101908684111561203457600080fd5b8286015b84811015611e9857803567ffffffffffffffff8111156120585760008081fd5b8701603f8101891361206a5760008081fd5b61207b898683013560408401611f26565b845250918301918301612038565b801515811461045f57600080fd5b600082601f8301126120a857600080fd5b813560206120b8611e5083611e0b565b82815260059290921b840181019181810190868411156120d757600080fd5b8286015b84811015611e985780356120ee81612089565b83529183019183016120db565b600080600080600060a0868803121561211357600080fd5b853567ffffffffffffffff8082111561212b57600080fd5b61213789838a01611e2f565b9650602088013591508082111561214d57600080fd5b61215989838a01611ea3565b9550604088013591508082111561216f57600080fd5b61217b89838a01611f5f565b9450606088013591508082111561219157600080fd5b61219d89838a01611ff4565b935060808801359150808211156121b357600080fd5b506121c088828901612097565b9150509295509295909350565b6000602082840312156121df57600080fd5b81356121ea81611d07565b9392505050565b634e487b7160e01b600052603260045260246000fd5b600181811c9082168061221b57607f821691505b6020821081141561079d57634e487b7160e01b600052602260045260246000fd5b6000821982111561225d57634e487b7160e01b600052601160045260246000fd5b500190565b8183823760009101908152919050565b60006020828403121561228457600080fd5b81516121ea81611d07565b6020815260006121ea6020830184611bb4565b60018060a01b038716815285602082015260c0604082015260006122c960c0830187611b88565b82810360608401526122db8187611b88565b6080840195909552505090151560a090910152949350505050565b60c0808252875190820181905260009060209060e0840190828b01845b828110156123385781516001600160a01b031684529284019290840190600101612313565b5050508381038285015261234c818a611b28565b91505082810360408401526123618188611bb4565b905082810360608401526123758187611bb4565b905082810360808401526123898186611c09565b9150508260a0830152979650505050505050565b6001600160e01b03198316815281516000906123c0816004850160208701611b58565b919091016004019392505050565b6001600160a01b0383168152604060208201819052600090611dbc90830184611b88565b6000806040838503121561240557600080fd5b825161241081612089565b602084015190925067ffffffffffffffff81111561242d57600080fd5b8301601f8101851361243e57600080fd5b805161244c611e5082611efe565b81815286602083850101111561246157600080fd5b612472826020830160208601611b58565b8093505050509250929050565b60008251612491818460208701611b58565b919091019291505056fea26469706673582212203a6ac9c0481ab3d9520b931410e440829aecdacacf855023a51ad521e9fa6dab64736f6c634300080a0033", + "deployedBytecode": "0x6080604052600436106101345760003560e01c8063b3c82e92116100ab578063d9a4cbdf1161006f578063d9a4cbdf14610361578063dbd1838814610381578063e471b02614610396578063e68a5c3d146103b6578063fc525395146103d6578063fe0d94c1146103f657600080fd5b8063b3c82e92146102cb578063b68df16d146102f8578063c3a7688614610319578063cebc9a8214610337578063d89aac391461034c57600080fd5b80635ab98d5a116100fd5780635ab98d5a146101cc57806364d62353146101ec5780636a4df1df1461020c5780638533f33714610258578063a75b87d21461026d578063b1fc87961461028b57600080fd5b80625c33e11461013957806303c276211461013b578063083a73a21461015f57806340e58ee51461017f5780635748c1301461019f575b600080fd5b005b34801561014757600080fd5b506002545b6040519081526020015b60405180910390f35b34801561016b57600080fd5b5061013961017a366004611a8d565b610409565b34801561018b57600080fd5b5061013961019a366004611a8d565b610462565b3480156101ab57600080fd5b506101bf6101ba366004611a8d565b61070d565b6040516101569190611abc565b3480156101d857600080fd5b506101396101e7366004611a8d565b6107a3565b3480156101f857600080fd5b50610139610207366004611a8d565b6107ef565b34801561021857600080fd5b506102407f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b039091168152602001610156565b34801561026457600080fd5b5060055461014c565b34801561027957600080fd5b506004546001600160a01b0316610240565b34801561029757600080fd5b506102bb6102a6366004611a8d565b60009081526007602052604090205460ff1690565b6040519015158152602001610156565b3480156102d757600080fd5b506102eb6102e6366004611a8d565b610821565b6040516101569190611c3b565b61030b610306366004611d1c565b610b94565b604051610156929190611da1565b34801561032557600080fd5b506008546001600160a01b0316610240565b34801561034357600080fd5b5060005461014c565b34801561035857600080fd5b5060035461014c565b34801561036d57600080fd5b5061013961037c3660046120fb565b610c25565b34801561038d57600080fd5b5060015461014c565b3480156103a257600080fd5b506101396103b1366004611a8d565b610d26565b3480156103c257600080fd5b506101396103d13660046121cd565b610d71565b3480156103e257600080fd5b506101396103f13660046121cd565b610dfa565b610139610404366004611a8d565b610e23565b33301461042957604051631dbf5f2360e01b815260040160405180910390fd5b600254811161044b5760405163cb2f2b2360e01b815260040160405180910390fd5b6104548161114b565b61045f60005461118c565b50565b6004546001600160a01b0316331461048d576040516377b6878160e11b815260040160405180910390fd5b60006104988261070d565b60038111156104a9576104a9611aa6565b146104c75760405163050ac78b60e11b815260040160405180910390fd5b60008181526006602081905260408220908101805461ff001916610100179055805490915b818110156106dc576106d483600001828154811061050c5761050c6121f1565b6000918252602090912001546001850180546001600160a01b03909216918490811061053a5761053a6121f1565b906000526020600020015485600201848154811061055a5761055a6121f1565b90600052602060002001805461056f90612207565b80601f016020809104026020016040519081016040528092919081815260200182805461059b90612207565b80156105e85780601f106105bd576101008083540402835291602001916105e8565b820191906000526020600020905b8154815290600101906020018083116105cb57829003601f168201915b5050505050866003018581548110610602576106026121f1565b90600052602060002001805461061790612207565b80601f016020809104026020016040519081016040528092919081815260200182805461064390612207565b80156106905780601f1061066557610100808354040283529160200191610690565b820191906000526020600020905b81548152906001019060200180831161067357829003601f168201915b505050505087600501548860040187815481106106af576106af6121f1565b90600052602060002090602091828204019190069054906101000a900460ff166111d2565b6001016104ec565b5060405183907f0743c673685efcbf3db8591d9e1d98336bc844fe4f4599e6f7efb6d71c02563490600090a2505050565b600081600554116107315760405163e5bc0e7b60e01b815260040160405180910390fd5b600082815260066020819052604090912090810154610100900460ff161561075c5750600292915050565b600681015460ff16156107725750600192915050565b6001548160050154610784919061223c565b4211156107945750600392915050565b50600092915050565b50919050565b3330146107c357604051631dbf5f2360e01b815260040160405180910390fd5b6102588110156107e6576040516301f6f9e560e71b815260040160405180910390fd5b61045f81611224565b33301461080f57604051631dbf5f2360e01b815260040160405180910390fd5b6108188161118c565b61045f81611265565b61086d6040518061010001604052806060815260200160608152602001606081526020016060815260200160608152602001600081526020016000151581526020016000151581525090565b6000828152600660209081526040918290208251815461012093810282018401909452610100810184815290939192849284918401828280156108d957602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116108bb575b505050505081526020016001820180548060200260200160405190810160405280929190818152602001828054801561093157602002820191906000526020600020905b81548152602001906001019080831161091d575b5050505050815260200160028201805480602002602001604051908101604052809291908181526020016000905b82821015610a0b57838290600052602060002001805461097e90612207565b80601f01602080910402602001604051908101604052809291908181526020018280546109aa90612207565b80156109f75780601f106109cc576101008083540402835291602001916109f7565b820191906000526020600020905b8154815290600101906020018083116109da57829003601f168201915b50505050508152602001906001019061095f565b50505050815260200160038201805480602002602001604051908101604052809291908181526020016000905b82821015610ae4578382906000526020600020018054610a5790612207565b80601f0160208091040260200160405190810160405280929190818152602001828054610a8390612207565b8015610ad05780601f10610aa557610100808354040283529160200191610ad0565b820191906000526020600020905b815481529060010190602001808311610ab357829003601f168201915b505050505081526020019060010190610a38565b50505050815260200160048201805480602002602001604051908101604052809291908181526020018280548015610b5b57602002820191906000526020600020906000905b825461010083900a900460ff161515815260206001928301818104948501949093039092029101808411610b2a5790505b50505091835250506005820154602082015260069091015460ff8082161515604084015261010090910416151560609091015292915050565b60006060333014610bb857604051631dbf5f2360e01b815260040160405180910390fd5b60006060866001600160a01b03168686604051610bd6929190612262565b600060405180830381855af49150503d8060008114610c11576040519150601f19603f3d011682016040523d82523d6000602084013e610c16565b606091505b50909890975095505050505050565b336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016141580610cf4575060085460408051636e296e4560e01b815290516001600160a01b03928316927f00000000000000000000000000000000000000000000000000000000000000001691636e296e459160048083019260209291908290030181865afa158015610cc4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ce89190612272565b6001600160a01b031614155b15610d12576040516359e8359960e01b815260040160405180910390fd5b610d1f85858585856112a6565b5050505050565b333014610d4657604051631dbf5f2360e01b815260040160405180910390fd5b6003548110610d68576040516301b1029b60e61b815260040160405180910390fd5b61045481611513565b333014610d9157604051631dbf5f2360e01b815260040160405180910390fd5b600854604080516001600160a01b03928316815291831660208301527f01dd0ca50426f21c1b37ce7f3e95eef45b4a55bc5da80a7b67b2c65a7463caf0910160405180910390a1600880546001600160a01b0319166001600160a01b0392909216919091179055565b333014610e1a57604051631dbf5f2360e01b815260040160405180910390fd5b61045f81611554565b6000610e2e8261070d565b6003811115610e3f57610e3f611aa6565b14610e5d5760405163050ac78b60e11b815260040160405180910390fd5b60008181526006602052604090206005810154421015610e9057604051635192dd5560e01b815260040160405180910390fd5b60068101805460ff19166001179055805460008167ffffffffffffffff811115610ebc57610ebc611dc4565b604051908082528060200260200182016040528015610eef57816020015b6060815260200190600190039081610eda5790505b50905060005b82811015611102576110dd846000018281548110610f1557610f156121f1565b6000918252602090912001546001860180546001600160a01b039092169184908110610f4357610f436121f1565b9060005260206000200154866002018481548110610f6357610f636121f1565b906000526020600020018054610f7890612207565b80601f0160208091040260200160405190810160405280929190818152602001828054610fa490612207565b8015610ff15780601f10610fc657610100808354040283529160200191610ff1565b820191906000526020600020905b815481529060010190602001808311610fd457829003601f168201915b505050505087600301858154811061100b5761100b6121f1565b90600052602060002001805461102090612207565b80601f016020809104026020016040519081016040528092919081815260200182805461104c90612207565b80156110995780601f1061106e57610100808354040283529160200191611099565b820191906000526020600020905b81548152906001019060200180831161107c57829003601f168201915b505050505088600501548960040187815481106110b8576110b86121f1565b90600052602060002090602091828204019190069054906101000a900460ff166115bd565b8282815181106110ef576110ef6121f1565b6020908102919091010152600101610ef5565b50336001600160a01b0316847ff5efc4bb09a12b6c9561a7e7ab02938a72a4351316b473d574fdaaa89c43eb9a8360405161113d919061228f565b60405180910390a350505050565b60035460408051918252602082018390527faf46013422363beb5e6f00ab923cffe3574670494c864de2828b9d7c201fdde5910160405180910390a1600355565b6002548110156111af576040516361759e6560e01b815260040160405180910390fd5b60035481111561045f576040516386dac63560e01b815260040160405180910390fd5b60008686868686866040516020016111ef969594939291906122a2565b60408051601f198184030181529181528151602092830120600090815260079092529020805460ff1916905550505050505050565b60015460408051918252602082018390527f9953f3a71052edcd4ae7a0f97302839d1dda32ab93c1039207c91c866b094f72910160405180910390a1600155565b60005460408051918252602082018390527f43de56b886294fc29767e51a88b5c67fd24aefebc5ddf813b1d9b91b1df38444910160405180910390a1600055565b84516112c557604051636a8e3e9360e11b815260040160405180910390fd5b84518451811415806112d8575083518114155b806112e4575082518114155b806112f0575081518114155b1561130e57604051630d10f63b60e01b815260040160405180910390fd5b6005546000805461131f904261223c565b600580546001019055905060005b83811015611440576000898281518110611349576113496121f1565b6020026020010151898381518110611363576113636121f1565b602002602001015189848151811061137d5761137d6121f1565b6020026020010151898581518110611397576113976121f1565b6020026020010151868a87815181106113b2576113b26121f1565b60200260200101516040516020016113cf969594939291906122a2565b6040516020818303038152906040528051906020012090506114008160009081526007602052604090205460ff1690565b1561141e57604051633b2f04e360e21b815260040160405180910390fd5b6000908152600760205260409020805460ff191660019081179091550161132d565b506000828152600660209081526040909120895190916114649183918c01906117a3565b50875161147a90600183019060208b0190611808565b50865161149090600283019060208a0190611843565b5085516114a6906003830190602089019061189c565b5084516114bc90600483019060208801906118f5565b50818160050181905550827f0325966a4aa089b42f4766ec96f599405102bb309e065f24874aff59082dbc8b8a8a8a8a8a88604051611500969594939291906122f6565b60405180910390a2505050505050505050565b60025460408051918252602082018390527fc534cdcbe9b52100810d787afd57e4174322776fcb58872ea706f23e9319fa8d910160405180910390a1600255565b600454604080516001600160a01b03928316815291831660208301527f85bd8788d3c4a160f0f6254229589f137d5633a870dcb46f99ffe07b4da1894b910160405180910390a1600480546001600160a01b0319166001600160a01b0392909216919091179055565b6060854710156115e057604051631e9acf1760e31b815260040160405180910390fd5b60008787878787876040516020016115fd969594939291906122a2565b60408051601f198184030181529181528151602092830120600081815260079093529120805460ff19169055865190915060609061163c575084611668565b86805190602001208660405160200161165692919061239d565b60405160208183030381529060405290505b6000606085156116ea5760405163b68df16d60e01b8152309063b68df16d908c90611699908f9088906004016123ce565b60006040518083038185885af11580156116b7573d6000803e3d6000fd5b50505050506040513d6000823e601f3d908101601f191682016040526116e091908101906123f2565b909250905061174c565b8a6001600160a01b03168a84604051611703919061247f565b60006040518083038185875af1925050503d8060008114611740576040519150601f19603f3d011682016040523d82523d6000602084013e611745565b606091505b5090925090505b6117568282611765565b9b9a5050505050505050505050565b6060821561177457508061179d565b8151156117845781518083602001fd5b6040516332f63ed360e21b815260040160405180910390fd5b92915050565b8280548282559060005260206000209081019282156117f8579160200282015b828111156117f857825182546001600160a01b0319166001600160a01b039091161782556020909201916001909101906117c3565b50611804929150611991565b5090565b8280548282559060005260206000209081019282156117f8579160200282015b828111156117f8578251825591602001919060010190611828565b828054828255906000526020600020908101928215611890579160200282015b8281111561189057825180516118809184916020909101906119a6565b5091602001919060010190611863565b50611804929150611a19565b8280548282559060005260206000209081019282156118e9579160200282015b828111156118e957825180516118d99184916020909101906119a6565b50916020019190600101906118bc565b50611804929150611a36565b82805482825590600052602060002090601f016020900481019282156117f85791602002820160005b8382111561195b57835183826101000a81548160ff021916908315150217905550926020019260010160208160000104928301926001030261191e565b80156119885782816101000a81549060ff021916905560010160208160000104928301926001030261195b565b50506118049291505b5b808211156118045760008155600101611992565b8280546119b290612207565b90600052602060002090601f0160209004810192826119d457600085556117f8565b82601f106119ed57805160ff19168380011785556117f8565b828001600101855582156117f857918201828111156117f8578251825591602001919060010190611828565b80821115611804576000611a2d8282611a53565b50600101611a19565b80821115611804576000611a4a8282611a53565b50600101611a36565b508054611a5f90612207565b6000825580601f10611a6f575050565b601f01602090049060005260206000209081019061045f9190611991565b600060208284031215611a9f57600080fd5b5035919050565b634e487b7160e01b600052602160045260246000fd5b6020810160048310611ade57634e487b7160e01b600052602160045260246000fd5b91905290565b600081518084526020808501945080840160005b83811015611b1d5781516001600160a01b031687529582019590820190600101611af8565b509495945050505050565b600081518084526020808501945080840160005b83811015611b1d57815187529582019590820190600101611b3c565b60005b83811015611b73578181015183820152602001611b5b565b83811115611b82576000848401525b50505050565b60008151808452611ba0816020860160208601611b58565b601f01601f19169290920160200192915050565b600081518084526020808501808196508360051b8101915082860160005b85811015611bfc578284038952611bea848351611b88565b98850198935090840190600101611bd2565b5091979650505050505050565b600081518084526020808501945080840160005b83811015611b1d578151151587529582019590820190600101611c1d565b6020815260008251610100806020850152611c5a610120850183611ae4565b91506020850151601f1980868503016040870152611c788483611b28565b93506040870151915080868503016060870152611c958483611bb4565b93506060870151915080868503016080870152611cb28483611bb4565b935060808701519150808685030160a087015250611cd08382611c09565b92505060a085015160c085015260c0850151611cf060e086018215159052565b5060e0850151801515858301525090949350505050565b6001600160a01b038116811461045f57600080fd5b600080600060408486031215611d3157600080fd5b8335611d3c81611d07565b9250602084013567ffffffffffffffff80821115611d5957600080fd5b818601915086601f830112611d6d57600080fd5b813581811115611d7c57600080fd5b876020828501011115611d8e57600080fd5b6020830194508093505050509250925092565b8215158152604060208201526000611dbc6040830184611b88565b949350505050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff81118282101715611e0357611e03611dc4565b604052919050565b600067ffffffffffffffff821115611e2557611e25611dc4565b5060051b60200190565b600082601f830112611e4057600080fd5b81356020611e55611e5083611e0b565b611dda565b82815260059290921b84018101918181019086841115611e7457600080fd5b8286015b84811015611e98578035611e8b81611d07565b8352918301918301611e78565b509695505050505050565b600082601f830112611eb457600080fd5b81356020611ec4611e5083611e0b565b82815260059290921b84018101918181019086841115611ee357600080fd5b8286015b84811015611e985780358352918301918301611ee7565b600067ffffffffffffffff821115611f1857611f18611dc4565b50601f01601f191660200190565b6000611f34611e5084611efe565b9050828152838383011115611f4857600080fd5b828260208301376000602084830101529392505050565b600082601f830112611f7057600080fd5b81356020611f80611e5083611e0b565b82815260059290921b84018101918181019086841115611f9f57600080fd5b8286015b84811015611e9857803567ffffffffffffffff811115611fc35760008081fd5b8701603f81018913611fd55760008081fd5b611fe6898683013560408401611f26565b845250918301918301611fa3565b600082601f83011261200557600080fd5b81356020612015611e5083611e0b565b82815260059290921b8401810191818101908684111561203457600080fd5b8286015b84811015611e9857803567ffffffffffffffff8111156120585760008081fd5b8701603f8101891361206a5760008081fd5b61207b898683013560408401611f26565b845250918301918301612038565b801515811461045f57600080fd5b600082601f8301126120a857600080fd5b813560206120b8611e5083611e0b565b82815260059290921b840181019181810190868411156120d757600080fd5b8286015b84811015611e985780356120ee81612089565b83529183019183016120db565b600080600080600060a0868803121561211357600080fd5b853567ffffffffffffffff8082111561212b57600080fd5b61213789838a01611e2f565b9650602088013591508082111561214d57600080fd5b61215989838a01611ea3565b9550604088013591508082111561216f57600080fd5b61217b89838a01611f5f565b9450606088013591508082111561219157600080fd5b61219d89838a01611ff4565b935060808801359150808211156121b357600080fd5b506121c088828901612097565b9150509295509295909350565b6000602082840312156121df57600080fd5b81356121ea81611d07565b9392505050565b634e487b7160e01b600052603260045260246000fd5b600181811c9082168061221b57607f821691505b6020821081141561079d57634e487b7160e01b600052602260045260246000fd5b6000821982111561225d57634e487b7160e01b600052601160045260246000fd5b500190565b8183823760009101908152919050565b60006020828403121561228457600080fd5b81516121ea81611d07565b6020815260006121ea6020830184611bb4565b60018060a01b038716815285602082015260c0604082015260006122c960c0830187611b88565b82810360608401526122db8187611b88565b6080840195909552505090151560a090910152949350505050565b60c0808252875190820181905260009060209060e0840190828b01845b828110156123385781516001600160a01b031684529284019290840190600101612313565b5050508381038285015261234c818a611b28565b91505082810360408401526123618188611bb4565b905082810360608401526123758187611bb4565b905082810360808401526123898186611c09565b9150508260a0830152979650505050505050565b6001600160e01b03198316815281516000906123c0816004850160208701611b58565b919091016004019392505050565b6001600160a01b0383168152604060208201819052600090611dbc90830184611b88565b6000806040838503121561240557600080fd5b825161241081612089565b602084015190925067ffffffffffffffff81111561242d57600080fd5b8301601f8101851361243e57600080fd5b805161244c611e5082611efe565b81815286602083850101111561246157600080fd5b612472826020830160208601611b58565b8093505050509250929050565b60008251612491818460208701611b58565b919091019291505056fea26469706673582212203a6ac9c0481ab3d9520b931410e440829aecdacacf855023a51ad521e9fa6dab64736f6c634300080a0033", + "linkReferences": {}, + "deployedLinkReferences": {} +} diff --git a/utils/swellchain/contracts.ts b/utils/swellchain/contracts.ts new file mode 100644 index 00000000..4ef4f06d --- /dev/null +++ b/utils/swellchain/contracts.ts @@ -0,0 +1,38 @@ +import { + CrossDomainMessengerStub__factory, + L1CrossDomainMessenger__factory, + L2CrossDomainMessenger__factory, +} from "../../typechain"; +import addresses from "./addresses"; +import { CommonOptions } from "./types"; +import network, { NetworkName } from "../network"; + +interface ContractsOptions extends CommonOptions { + forking: boolean; +} + +export default function contracts( + networkName: NetworkName, + options: ContractsOptions +) { + const [l1Provider, l2Provider] = network + .multichain(["eth", "swe"], networkName) + .getProviders(options); + + const sweAddresses = addresses(networkName, options); + + return { + L1CrossDomainMessenger: L1CrossDomainMessenger__factory.connect( + sweAddresses.L1CrossDomainMessenger, + l1Provider + ), + L1CrossDomainMessengerStub: CrossDomainMessengerStub__factory.connect( + sweAddresses.L1CrossDomainMessenger, + l1Provider + ), + L2CrossDomainMessenger: L2CrossDomainMessenger__factory.connect( + sweAddresses.L2CrossDomainMessenger, + l2Provider + ), + }; +} diff --git a/utils/swellchain/deployment.ts b/utils/swellchain/deployment.ts new file mode 100644 index 00000000..a9d339ff --- /dev/null +++ b/utils/swellchain/deployment.ts @@ -0,0 +1,153 @@ +import { assert } from "chai"; +import { Overrides, Wallet } from "ethers"; +import { + ERC20Bridged__factory, + IERC20Metadata__factory, + L1ERC20TokenBridge__factory, + L2ERC20TokenBridge__factory, + OssifiableProxy__factory, +} from "../../typechain"; + +import addresses from "./addresses"; +import { CommonOptions } from "./types"; +import network, { NetworkName } from "../network"; +import { DeployScript, Logger } from "../deployment/DeployScript"; + +interface OptL1DeployScriptParams { + deployer: Wallet; + admins: { proxy: string; bridge: string }; +} + +interface OptL2DeployScriptParams extends OptL1DeployScriptParams { + l2Token?: { name?: string; symbol?: string }; +} + +interface OptDeploymentOptions extends CommonOptions { + logger?: Logger; + overrides?: Overrides; +} + +export default function deployment( + networkName: NetworkName, + options: OptDeploymentOptions = {} +) { + const sweAddresses = addresses(networkName, options); + return { + async erc20TokenBridgeDeployScript( + l1Token: string, + l1Params: OptL1DeployScriptParams, + l2Params: OptL2DeployScriptParams + ) { + const [ + expectedL1TokenBridgeImplAddress, + expectedL1TokenBridgeProxyAddress, + ] = await network.predictAddresses(l1Params.deployer, 2); + + const [ + expectedL2TokenImplAddress, + expectedL2TokenProxyAddress, + expectedL2TokenBridgeImplAddress, + expectedL2TokenBridgeProxyAddress, + ] = await network.predictAddresses(l2Params.deployer, 4); + + const l1DeployScript = new DeployScript( + l1Params.deployer, + options?.logger + ) + .addStep({ + factory: L1ERC20TokenBridge__factory, + args: [ + sweAddresses.L1CrossDomainMessenger, + expectedL2TokenBridgeProxyAddress, + l1Token, + expectedL2TokenProxyAddress, + options?.overrides, + ], + afterDeploy: (c) => + assert.equal(c.address, expectedL1TokenBridgeImplAddress), + }) + .addStep({ + factory: OssifiableProxy__factory, + args: [ + expectedL1TokenBridgeImplAddress, + l1Params.admins.proxy, + L1ERC20TokenBridge__factory.createInterface().encodeFunctionData( + "initialize", + [l1Params.admins.bridge] + ), + options?.overrides, + ], + afterDeploy: (c) => + assert.equal(c.address, expectedL1TokenBridgeProxyAddress), + }); + + const l1TokenInfo = IERC20Metadata__factory.connect( + l1Token, + l1Params.deployer + ); + + const [decimals, l2TokenName, l2TokenSymbol] = await Promise.all([ + l1TokenInfo.decimals(), + l2Params.l2Token?.name ?? l1TokenInfo.name(), + l2Params.l2Token?.symbol ?? l1TokenInfo.symbol(), + ]); + + const l2DeployScript = new DeployScript( + l2Params.deployer, + options?.logger + ) + .addStep({ + factory: ERC20Bridged__factory, + args: [ + l2TokenName, + l2TokenSymbol, + decimals, + expectedL2TokenBridgeProxyAddress, + options?.overrides, + ], + afterDeploy: (c) => + assert.equal(c.address, expectedL2TokenImplAddress), + }) + .addStep({ + factory: OssifiableProxy__factory, + args: [ + expectedL2TokenImplAddress, + l2Params.admins.proxy, + ERC20Bridged__factory.createInterface().encodeFunctionData( + "initialize", + [l2TokenName, l2TokenSymbol] + ), + options?.overrides, + ], + afterDeploy: (c) => + assert.equal(c.address, expectedL2TokenProxyAddress), + }) + .addStep({ + factory: L2ERC20TokenBridge__factory, + args: [ + sweAddresses.L2CrossDomainMessenger, + expectedL1TokenBridgeProxyAddress, + l1Token, + expectedL2TokenProxyAddress, + options?.overrides, + ], + afterDeploy: (c) => + assert.equal(c.address, expectedL2TokenBridgeImplAddress), + }) + .addStep({ + factory: OssifiableProxy__factory, + args: [ + expectedL2TokenBridgeImplAddress, + l2Params.admins.proxy, + L2ERC20TokenBridge__factory.createInterface().encodeFunctionData( + "initialize", + [l2Params.admins.bridge] + ), + options?.overrides, + ], + }); + + return [l1DeployScript, l2DeployScript]; + }, + }; +} diff --git a/utils/swellchain/index.ts b/utils/swellchain/index.ts new file mode 100644 index 00000000..0ca0e9a2 --- /dev/null +++ b/utils/swellchain/index.ts @@ -0,0 +1,13 @@ +import addresses from "./addresses"; +import contracts from "./contracts"; +import deployment from "./deployment"; +import testing from "./testing"; +import messaging from "./messaging"; + +export default { + testing, + addresses, + contracts, + messaging, + deployment, +}; diff --git a/utils/swellchain/messaging.ts b/utils/swellchain/messaging.ts new file mode 100644 index 00000000..21898fbf --- /dev/null +++ b/utils/swellchain/messaging.ts @@ -0,0 +1,48 @@ +import contracts from "./contracts"; +import network, { NetworkName } from "../network"; +import { CommonOptions } from "./types"; +import { CrossChainMessenger, MessageStatus } from "@eth-optimism/sdk"; + +interface ContractsOptions extends CommonOptions { + forking: boolean; +} + +interface MessageData { + sender: string; + recipient: string; + calldata: string; + gasLimit?: number; +} + +export default function messaging( + networkName: NetworkName, + options: ContractsOptions +) { + const [ethProvider, sweProvider] = network + .multichain(["eth", "swe"], networkName) + .getProviders(options); + + const optContracts = contracts(networkName, options); + const crossChainMessenger = new CrossChainMessenger({ + l2ChainId: network.chainId("swe", networkName), + l1SignerOrProvider: ethProvider, + l2SignerOrProvider: sweProvider, + l1ChainId: network.chainId("eth", networkName), + }); + return { + prepareL2Message(msg: MessageData) { + const calldata = + optContracts.L1CrossDomainMessenger.interface.encodeFunctionData( + "sendMessage", + [msg.recipient, msg.calldata, msg.gasLimit || 1_000_000] + ); + return { calldata, callvalue: 0 }; + }, + async waitForL2Message(txHash: string) { + await crossChainMessenger.waitForMessageStatus( + txHash, + MessageStatus.RELAYED + ); + }, + }; +} diff --git a/utils/swellchain/testing.ts b/utils/swellchain/testing.ts new file mode 100644 index 00000000..1ab2c300 --- /dev/null +++ b/utils/swellchain/testing.ts @@ -0,0 +1,299 @@ +import { Signer } from "ethers"; +import { JsonRpcProvider } from "@ethersproject/providers"; + +import { + IERC20, + ERC20Bridged, + IERC20__factory, + L1ERC20TokenBridge, + L2ERC20TokenBridge, + ERC20Bridged__factory, + ERC20BridgedStub__factory, + L1ERC20TokenBridge__factory, + L2ERC20TokenBridge__factory, + CrossDomainMessengerStub__factory, +} from "../../typechain"; +import addresses from "./addresses"; +import contracts from "./contracts"; +import deployment from "./deployment"; +import testingUtils from "../testing"; +import { BridgingManagement } from "../bridging-management"; +import network, { NetworkName, SignerOrProvider } from "../network"; + +export default function testing(networkName: NetworkName) { + const sweAddresses = addresses(networkName); + const ethSweNetworks = network.multichain(["eth", "swe"], networkName); + + return { + async getAcceptanceTestSetup() { + const [ethProvider, sweProvider] = ethSweNetworks.getProviders({ + forking: true, + }); + + const bridgeContracts = await loadDeployedBridges( + ethProvider, + sweProvider + ); + + await printLoadedTestConfig(networkName, bridgeContracts); + + return { + l1Provider: ethProvider, + l2Provider: sweProvider, + ...bridgeContracts, + }; + }, + async getIntegrationTestSetup() { + const hasDeployedContracts = + testingUtils.env.USE_DEPLOYED_CONTRACTS(false); + + const [ethProvider, sweProvider] = ethSweNetworks.getProviders({ + forking: true, + }); + + const bridgeContracts = hasDeployedContracts + ? await loadDeployedBridges(ethProvider, sweProvider) + : await deployTestBridge(networkName, ethProvider, sweProvider); + + const [l1ERC20TokenBridgeAdminAddress] = + await BridgingManagement.getAdmins(bridgeContracts.l1ERC20TokenBridge); + + const [l2ERC20TokenBridgeAdminAddress] = + await BridgingManagement.getAdmins(bridgeContracts.l2ERC20TokenBridge); + + const l1TokensHolder = hasDeployedContracts + ? await testingUtils.impersonate( + testingUtils.env.L1_TOKENS_HOLDER(), + ethProvider + ) + : testingUtils.accounts.deployer(ethProvider); + + if (hasDeployedContracts) { + await printLoadedTestConfig( + networkName, + bridgeContracts, + l1TokensHolder + ); + } + + // if the L1 bridge admin is a contract, remove it's code to + // make it behave as EOA + await ethProvider.send("hardhat_setCode", [ + l1ERC20TokenBridgeAdminAddress, + "0x", + ]); + + // same for the L2 bridge admin + await sweProvider.send("hardhat_setCode", [ + l2ERC20TokenBridgeAdminAddress, + "0x", + ]); + + const sweContracts = contracts(networkName, { forking: true }); + + return { + l1Provider: ethProvider, + l2Provider: sweProvider, + l1TokensHolder, + ...bridgeContracts, + l1CrossDomainMessenger: sweContracts.L1CrossDomainMessengerStub, + l2CrossDomainMessenger: sweContracts.L2CrossDomainMessenger, + l1ERC20TokenBridgeAdmin: await testingUtils.impersonate( + l1ERC20TokenBridgeAdminAddress, + ethProvider + ), + l2ERC20TokenBridgeAdmin: await testingUtils.impersonate( + l2ERC20TokenBridgeAdminAddress, + sweProvider + ) + }; + }, + async getE2ETestSetup() { + const testerPrivateKey = testingUtils.env.TESTING_PRIVATE_KEY(); + const [ethProvider, sweProvider] = ethSweNetworks.getProviders({ + forking: false, + }); + const [l1Tester, l2Tester] = ethSweNetworks.getSigners(testerPrivateKey, { + forking: false, + }); + + const bridgeContracts = await loadDeployedBridges(l1Tester, l2Tester); + + await printLoadedTestConfig(networkName, bridgeContracts, l1Tester); + + return { + l1Tester, + l2Tester, + l1Provider: ethProvider, + l2Provider: sweProvider, + ...bridgeContracts, + }; + }, + async stubL1CrossChainMessengerContract() { + const [ethProvider] = ethSweNetworks.getProviders({ forking: true }); + const deployer = testingUtils.accounts.deployer(ethProvider); + const stub = await new CrossDomainMessengerStub__factory( + deployer + ).deploy(); + const stubBytecode = await ethProvider.send("eth_getCode", [ + stub.address, + ]); + + await ethProvider.send("hardhat_setCode", [ + sweAddresses.L1CrossDomainMessenger, + stubBytecode, + ]); + }, + }; +} + +async function loadDeployedBridges( + l1SignerOrProvider: SignerOrProvider, + l2SignerOrProvider: SignerOrProvider +) { + return { + l1Token: IERC20__factory.connect( + testingUtils.env.OPT_L1_TOKEN(), + l1SignerOrProvider + ), + ...connectBridgeContracts( + { + l2Token: testingUtils.env.OPT_L2_TOKEN(), + l1ERC20TokenBridge: testingUtils.env.OPT_L1_ERC20_TOKEN_BRIDGE(), + l2ERC20TokenBridge: testingUtils.env.OPT_L2_ERC20_TOKEN_BRIDGE(), + }, + l1SignerOrProvider, + l2SignerOrProvider + ), + }; +} + +async function deployTestBridge( + networkName: NetworkName, + ethProvider: JsonRpcProvider, + sweProvider: JsonRpcProvider +) { + const ethDeployer = testingUtils.accounts.deployer(ethProvider); + const sweDeployer = testingUtils.accounts.deployer(sweProvider); + + const l1Token = await new ERC20BridgedStub__factory(ethDeployer).deploy( + "Test Token", + "TT" + ); + + const [ethDeployScript, sweDeployScript] = await deployment( + networkName + ).erc20TokenBridgeDeployScript( + l1Token.address, + { + deployer: ethDeployer, + admins: { proxy: ethDeployer.address, bridge: ethDeployer.address }, + }, + { + deployer: sweDeployer, + admins: { proxy: sweDeployer.address, bridge: sweDeployer.address }, + } + ); + + await ethDeployScript.run(); + await sweDeployScript.run(); + + const l1ERC20TokenBridgeProxyDeployStepIndex = 1; + const l1BridgingManagement = new BridgingManagement( + ethDeployScript.getContractAddress(l1ERC20TokenBridgeProxyDeployStepIndex), + ethDeployer + ); + + const l2ERC20TokenBridgeProxyDeployStepIndex = 3; + const l2BridgingManagement = new BridgingManagement( + sweDeployScript.getContractAddress(l2ERC20TokenBridgeProxyDeployStepIndex), + sweDeployer + ); + + await l1BridgingManagement.setup({ + bridgeAdmin: ethDeployer.address, + depositsEnabled: true, + withdrawalsEnabled: true, + }); + + await l2BridgingManagement.setup({ + bridgeAdmin: sweDeployer.address, + depositsEnabled: true, + withdrawalsEnabled: true, + }); + + return { + l1Token: l1Token.connect(ethProvider), + ...connectBridgeContracts( + { + l2Token: sweDeployScript.getContractAddress(1), + l1ERC20TokenBridge: ethDeployScript.getContractAddress(1), + l2ERC20TokenBridge: sweDeployScript.getContractAddress(3), + }, + ethProvider, + sweProvider + ), + }; +} + +function connectBridgeContracts( + addresses: { + l2Token: string; + l1ERC20TokenBridge: string; + l2ERC20TokenBridge: string; + }, + ethSignerOrProvider: SignerOrProvider, + sweSignerOrProvider: SignerOrProvider +) { + const l1ERC20TokenBridge = L1ERC20TokenBridge__factory.connect( + addresses.l1ERC20TokenBridge, + ethSignerOrProvider + ); + const l2ERC20TokenBridge = L2ERC20TokenBridge__factory.connect( + addresses.l2ERC20TokenBridge, + sweSignerOrProvider + ); + const l2Token = ERC20Bridged__factory.connect( + addresses.l2Token, + sweSignerOrProvider + ); + return { + l2Token, + l1ERC20TokenBridge, + l2ERC20TokenBridge, + }; +} + +async function printLoadedTestConfig( + networkName: NetworkName, + bridgeContracts: { + l1Token: IERC20; + l2Token: ERC20Bridged; + l1ERC20TokenBridge: L1ERC20TokenBridge; + l2ERC20TokenBridge: L2ERC20TokenBridge; + }, + l1TokensHolder?: Signer +) { + console.log("Using the deployed contracts for testing"); + console.log( + "In case of unexpected fails, please, make sure that you are forking correct Ethereum/Swellchain networks" + ); + console.log(` · Network Name: ${networkName}`); + console.log(` · L1 Token: ${bridgeContracts.l1Token.address}`); + console.log(` · L2 Token: ${bridgeContracts.l2Token.address}`); + if (l1TokensHolder) { + const l1TokensHolderAddress = await l1TokensHolder.getAddress(); + console.log(` · L1 Tokens Holder: ${l1TokensHolderAddress}`); + const holderBalance = await bridgeContracts.l1Token.balanceOf( + l1TokensHolderAddress + ); + console.log(` · L1 Tokens Holder Balance: ${holderBalance.toString()}`); + } + console.log( + ` · L1 ERC20 Token Bridge: ${bridgeContracts.l1ERC20TokenBridge.address}` + ); + console.log( + ` · L2 ERC20 Token Bridge: ${bridgeContracts.l2ERC20TokenBridge.address}` + ); + console.log(); +} diff --git a/utils/swellchain/types.ts b/utils/swellchain/types.ts new file mode 100644 index 00000000..6cb3a943 --- /dev/null +++ b/utils/swellchain/types.ts @@ -0,0 +1,9 @@ +export type SweContractNames = + | "L1CrossDomainMessenger" + | "L2CrossDomainMessenger"; + +export type SweContractAddresses = Record; +export type CustomSweContractAddresses = Partial; +export interface CommonOptions { + customAddresses?: CustomSweContractAddresses; +}