|
| 1 | +// We require the Hardhat Runtime Environment explicitly here. This is optional |
| 2 | +// but useful for running the script in a standalone fashion through `node <script>`. |
| 3 | +// |
| 4 | +// When running the script with `hardhat run <script>` you'll find the Hardhat |
| 5 | +// Runtime Environment's members available in the global scope. |
| 6 | +const hre = require("hardhat"); |
| 7 | +const fs = require("fs"); |
| 8 | +const { address } = require("../test/helpers/constants"); |
| 9 | +const { Wallet } = require("ethers"); |
| 10 | +const { UV_FS_O_FILEMAP } = require("constants"); |
| 11 | +const ethers = hre.ethers; |
| 12 | +require("dotenv").config(); |
| 13 | +const logging = true; |
| 14 | +const show_verify = true; |
| 15 | +const shouldDeployMock20 = false; |
| 16 | +async function main() { |
| 17 | + const url = process.env.NETWORK_RPC_URL; |
| 18 | + console.log("Using RPC: " + url); |
| 19 | + if (!url) { |
| 20 | + console.error("Missing NETWORK_RPC_URL. Aborting.."); |
| 21 | + return null; |
| 22 | + } |
| 23 | + const provider = new ethers.providers.JsonRpcProvider(url); |
| 24 | + const network = provider.getNetwork(); |
| 25 | + // utils |
| 26 | + const networkDetails = await network; |
| 27 | + |
| 28 | + let wallet; |
| 29 | + if (process.env.MNEMONIC) |
| 30 | + wallet = new Wallet.fromMnemonic(process.env.MNEMONIC); |
| 31 | + if (process.env.PRIVATE_KEY) wallet = new Wallet(process.env.PRIVATE_KEY); |
| 32 | + if (!wallet) { |
| 33 | + console.error("Missing MNEMONIC or PRIVATE_KEY. Aborting.."); |
| 34 | + return null; |
| 35 | + } |
| 36 | + owner = wallet.connect(provider); |
| 37 | + let gasLimit = 3000000; |
| 38 | + let gasPrice = null; |
| 39 | + let sleepAmount = 10; |
| 40 | + let OPFOwner = null; |
| 41 | + let RouterAddress = null; |
| 42 | + console.log("Using chain " + networkDetails.chainId); |
| 43 | + switch (networkDetails.chainId) { |
| 44 | + case 1: |
| 45 | + networkName = "mainnet"; |
| 46 | + OPFOwner = "0x0d27cd67c4A3fd3Eb9C7C757582f59089F058167"; |
| 47 | + RouterAddress = "0x8149276f275EEFAc110D74AFE8AFECEaeC7d1593"; |
| 48 | + gasLimit = 2500000; |
| 49 | + gasPrice = ethers.utils.parseUnits("1", "gwei"); |
| 50 | + break; |
| 51 | + case 10: |
| 52 | + networkName = "optimism"; |
| 53 | + OPFOwner = "0xC7EC1970B09224B317c52d92f37F5e1E4fF6B687"; |
| 54 | + RouterAddress = "0xf26c6C93f9f1d725e149d95f8E7B2334a406aD10"; |
| 55 | + gasPrice = ethers.utils.parseUnits("0.001", "gwei"); |
| 56 | + gasLimit = 2800000; |
| 57 | + break; |
| 58 | + case 0x89: |
| 59 | + networkName = "polygon"; |
| 60 | + OPFOwner = "0x6272E00741C16b9A337E29DB672d51Af09eA87dD"; |
| 61 | + RouterAddress = "0x78e1317186786591912A10a7aF2490B8B4697A93"; |
| 62 | + gasLimit = 19000000; |
| 63 | + gasPrice = ethers.utils.parseUnits("30", "gwei"); |
| 64 | + break; |
| 65 | + case 8453: |
| 66 | + networkName = "base"; |
| 67 | + OPFOwner = "0x4169e846f1524Cf0ac02Bd4B04fa33242709Cf64"; |
| 68 | + RouterAddress = "0xEF62FB495266C72a5212A11Dce8baa79Ec0ABeB1"; |
| 69 | + gasPrice = ethers.utils.parseUnits("0.009260", "gwei"); |
| 70 | + gasLimit = 28000000; |
| 71 | + break; |
| 72 | + case 23294: |
| 73 | + networkName = "oasis_saphire"; |
| 74 | + OPFOwner = "0x086E7F0588755af5AF5f8194542Fd8328238F3C1"; |
| 75 | + RouterAddress = "0xd8992Ed72C445c35Cb4A2be468568Ed1079357c8"; |
| 76 | + gasPrice = ethers.utils.parseUnits("100", "gwei"); |
| 77 | + gasLimit = 15000000; |
| 78 | + break; |
| 79 | + case 23295: |
| 80 | + networkName = "oasis_saphire_testnet"; |
| 81 | + OPFOwner = "0xC7EC1970B09224B317c52d92f37F5e1E4fF6B687"; |
| 82 | + RouterAddress = "0x5FBC2A29f7C8e4533dECD14Dc1c561A8eF0d4e31"; |
| 83 | + gasPrice = ethers.utils.parseUnits("100", "gwei"); |
| 84 | + gasLimit = 28000000; |
| 85 | + break; |
| 86 | + case 11155111: |
| 87 | + networkName = "sepolia"; |
| 88 | + OPFOwner = "0xC7EC1970B09224B317c52d92f37F5e1E4fF6B687"; |
| 89 | + RouterAddress = "0x2112Eb973af1DBf83a4f11eda82f7a7527D7Fde5"; |
| 90 | + gasPrice = ethers.utils.parseUnits("1", "gwei"); |
| 91 | + gasLimit = 28000000; |
| 92 | + break; |
| 93 | + case 11155420: |
| 94 | + networkName = "optimism_sepolia"; |
| 95 | + OPFOwner = "0xC7EC1970B09224B317c52d92f37F5e1E4fF6B687"; |
| 96 | + RouterAddress = "0x1B083D8584dd3e6Ff37d04a6e7e82b5F622f3985"; |
| 97 | + gasPrice = ethers.utils.parseUnits("5", "gwei"); |
| 98 | + gasLimit = 28000000; |
| 99 | + break; |
| 100 | + default: |
| 101 | + OPFOwner = "0x0d27cd67c4A3fd3Eb9C7C757582f59089F058167"; |
| 102 | + networkName = "development"; |
| 103 | + routerOwner = OPFOwner; |
| 104 | + shouldDeployOceanMock = true; |
| 105 | + sleepAmount = 0; |
| 106 | + break; |
| 107 | + } |
| 108 | + |
| 109 | + let options; |
| 110 | + if (gasPrice) { |
| 111 | + options = { gasLimit: gasLimit, gasPrice: gasPrice }; |
| 112 | + } else { |
| 113 | + options = { gasLimit }; |
| 114 | + } |
| 115 | + |
| 116 | + console.log("Deployer nonce:", await owner.getTransactionCount()); |
| 117 | + |
| 118 | + if (logging) console.info("Deploying Accesslists"); |
| 119 | + const AccessListFactory = await ethers.getContractFactory( |
| 120 | + "AccessListFactory" |
| 121 | + ); |
| 122 | + const AccessList = await ethers.getContractFactory("AccessList"); |
| 123 | + const accessListContract = await AccessList.connect(owner).deploy({gasLimit: 2500000}); |
| 124 | + await accessListContract.deployTransaction.wait(); |
| 125 | + console.log("accessListContract deployed to:", accessListContract.address); |
| 126 | + if (show_verify) { |
| 127 | + console.log("\tRun the following to verify on etherscan"); |
| 128 | + console.log( |
| 129 | + "\tnpx hardhat verify --network " + |
| 130 | + networkName + |
| 131 | + " " + |
| 132 | + accessListContract.address |
| 133 | + ); |
| 134 | + } |
| 135 | + const accessListFactoryContract = await AccessListFactory.connect( |
| 136 | + owner |
| 137 | + ).deploy(accessListContract.address,{gasLimit: 2500000}); |
| 138 | + await accessListFactoryContract.deployTransaction.wait(); |
| 139 | + console.log("AccessListFactory deployed to:", accessListFactoryContract.address); |
| 140 | + if (show_verify) { |
| 141 | + console.log("\tRun the following to verify on etherscan"); |
| 142 | + console.log( |
| 143 | + "\tnpx hardhat verify --network " + |
| 144 | + networkName + |
| 145 | + " " + |
| 146 | + accessListFactoryContract.address + |
| 147 | + " " + |
| 148 | + accessListContract.address |
| 149 | + ); |
| 150 | + } |
| 151 | +} |
| 152 | + |
| 153 | +async function sleep(s) { |
| 154 | + return new Promise((resolve) => { |
| 155 | + setTimeout(resolve, s * 1000); |
| 156 | + }); |
| 157 | +} |
| 158 | +// We recommend this pattern to be able to use async/await everywhere |
| 159 | +// and properly handle errors. |
| 160 | +main() |
| 161 | + .then(() => process.exit(0)) |
| 162 | + .catch((error) => { |
| 163 | + console.error(error); |
| 164 | + process.exit(1); |
| 165 | + }); |
0 commit comments