|
| 1 | +import { ethers } from 'hardhat' |
| 2 | +import { ContractFactory, Contract, Overrides } from 'ethers' |
| 3 | +import '@nomiclabs/hardhat-ethers' |
| 4 | +import { deployContract } from './deploymentUtils' |
| 5 | +import { ArbSys__factory } from '../build/types' |
| 6 | +import { ARB_SYS_ADDRESS } from '@arbitrum/sdk/dist/lib/dataEntities/constants' |
| 7 | +import { Toolkit4844 } from '../test/contract/toolkit4844' |
| 8 | + |
| 9 | +async function _isRunningOnArbitrum(signer: any): Promise<Boolean> { |
| 10 | + const arbSys = ArbSys__factory.connect(ARB_SYS_ADDRESS, signer) |
| 11 | + try { |
| 12 | + await arbSys.arbOSVersion() |
| 13 | + return true |
| 14 | + } catch (error) { |
| 15 | + return false |
| 16 | + } |
| 17 | +} |
| 18 | + |
| 19 | +async function main() { |
| 20 | + const [signer] = await ethers.getSigners() |
| 21 | + |
| 22 | + try { |
| 23 | + |
| 24 | + const rollupCreator = await deployContract('RollupCreator', signer) |
| 25 | + // deploy Sequencer Inbox, |
| 26 | + const isOnArb = await _isRunningOnArbitrum(signer) |
| 27 | + const reader4844 = isOnArb |
| 28 | + ? ethers.constants.AddressZero |
| 29 | + : (await Toolkit4844.deployReader4844(signer)).address |
| 30 | + |
| 31 | + // NOTE: maxDataSize is set for an L3, if deploying an L2 use "const maxDataSize = 117964" |
| 32 | + const maxDataSize = 104857 |
| 33 | + const ethSequencerInbox = await deployContract('SequencerInbox', signer, [ |
| 34 | + maxDataSize, |
| 35 | + reader4844, |
| 36 | + false, |
| 37 | + ]) |
| 38 | + |
| 39 | + const erc20SequencerInbox = await deployContract('SequencerInbox', signer, [ |
| 40 | + maxDataSize, |
| 41 | + reader4844, |
| 42 | + true, |
| 43 | + ]) |
| 44 | + |
| 45 | + const bridgeCreator = await deployContract('BridgeCreator', signer, [ |
| 46 | + [ |
| 47 | + // BRIDGE_ADDRESS, |
| 48 | + ethSequencerInbox.address, |
| 49 | + // INBOX_ADDRESS, |
| 50 | + // RollupEventInbox, |
| 51 | + // Outbox, |
| 52 | + ], |
| 53 | + [ |
| 54 | + // ERC20Bridge address, |
| 55 | + erc20SequencerInbox.address, |
| 56 | + // ERC20Inbox address , |
| 57 | + // ERC20RollupEventInbox address , |
| 58 | + // ERC20Outbox address , |
| 59 | + ], |
| 60 | + ]) |
| 61 | + |
| 62 | + // deploy OSP |
| 63 | + |
| 64 | + const prover0 = await deployContract('OneStepProver0', signer) |
| 65 | + const proverMem = await deployContract('OneStepProverMemory', signer) |
| 66 | + const proverMath = await deployContract('OneStepProverMath', signer) |
| 67 | + const proverHostIo = await deployContract('OneStepProverHostIo', signer) |
| 68 | + const osp: Contract = await deployContract('OneStepProofEntry', signer, [ |
| 69 | + prover0.address, |
| 70 | + proverMem.address, |
| 71 | + proverMath.address, |
| 72 | + proverHostIo.address, |
| 73 | + ]) |
| 74 | + |
| 75 | + // Call setTemplates with the deployed contract addresses |
| 76 | + console.log('Waiting for the Template to be set on the Rollup Creator') |
| 77 | + await rollupCreator.setTemplates( |
| 78 | + bridgeCreator.address, |
| 79 | + osp, |
| 80 | + // ChallengeManager address, |
| 81 | + // RollupAdmin address, |
| 82 | + // RollupUser address, |
| 83 | + // UpgradeExecutor address, |
| 84 | + // ValidatorUtils address, |
| 85 | + // ValidatorWalletCreator address, |
| 86 | + // deployHelper address |
| 87 | + ) |
| 88 | + console.log('Template is set on the Rollup Creator') |
| 89 | + } catch (error) { |
| 90 | + console.error( |
| 91 | + 'Deployment failed:', |
| 92 | + error instanceof Error ? error.message : error |
| 93 | + ) |
| 94 | + } |
| 95 | +} |
| 96 | + |
| 97 | +main() |
| 98 | + .then(() => process.exit(0)) |
| 99 | + .catch((error: Error) => { |
| 100 | + console.error(error) |
| 101 | + process.exit(1) |
| 102 | + }) |
0 commit comments