|
| 1 | +// scripts/step5b.ts |
| 2 | +import * as fs from 'fs'; |
| 3 | +import { ethers } from 'hardhat'; |
| 4 | +import { waitForInput } from './helper-functions'; |
| 5 | +import { EnvironmentInfo, loadEnvironmentInfo } from './environment'; |
| 6 | +import { newWalletOptions, WalletOptions } from './wallet-options'; |
| 7 | + |
| 8 | +// Clone wallet-contracts-v3 repo |
| 9 | +// cd wallet-contracts-v3 |
| 10 | +// forge build src/ |
| 11 | + |
| 12 | +// Path to the compiled artifact from wallet-contracts-v3 repo |
| 13 | +const STAGE1_MODULE_ARTIFACT_PATH = process.env.STAGE1_MODULE_ARTIFACT || |
| 14 | + '/path_to/wallet-contracts-v3/out/Stage1Module.sol/Stage1Module.json'; |
| 15 | + |
| 16 | +async function step5b(): Promise<EnvironmentInfo> { |
| 17 | + const env = loadEnvironmentInfo((await ethers.provider.getNetwork()).name); |
| 18 | + const { network } = env; |
| 19 | + |
| 20 | + // Load artifact from external v3 repo |
| 21 | + const artifact = JSON.parse(fs.readFileSync(STAGE1_MODULE_ARTIFACT_PATH, 'utf8')); |
| 22 | + |
| 23 | + const factoryAddress = '0x8Fa5088dF65855E0DaF87FA6591659893b24871d'; |
| 24 | + const entryPointAddress = '0x0000000071727De22E5E9d8BAf0edAc6f37da032'; |
| 25 | + const immutableSignerAddress = '0xcff469E561D9dCe5B1185CD2AC1Fa961F8fbDe61'; |
| 26 | + const startupWalletImplAddress = '0x8FD900677aabcbB368e0a27566cCd0C7435F1926'; |
| 27 | + |
| 28 | + console.log(`[${network}] Deploying Stage1Module from external artifact...`); |
| 29 | + console.log(`[${network}] Artifact path: ${STAGE1_MODULE_ARTIFACT_PATH}`); |
| 30 | + console.log(`[${network}] Factory: ${factoryAddress}`); |
| 31 | + console.log(`[${network}] EntryPoint: ${entryPointAddress}`); |
| 32 | + console.log(`[${network}] ImmutableSigner: ${immutableSignerAddress}`); |
| 33 | + console.log(`[${network}] StartupWalletImpl: ${startupWalletImplAddress}`); |
| 34 | + |
| 35 | + await waitForInput(); |
| 36 | + |
| 37 | + const wallets: WalletOptions = await newWalletOptions(env); |
| 38 | + const signer = wallets.getWallet(); |
| 39 | + |
| 40 | + // Deploy using bytecode from external artifact |
| 41 | + const factory = new ethers.ContractFactory( |
| 42 | + artifact.abi, |
| 43 | + artifact.bytecode.object, |
| 44 | + signer |
| 45 | + ); |
| 46 | + |
| 47 | + const stage1Module = await factory.deploy( |
| 48 | + factoryAddress, |
| 49 | + entryPointAddress, |
| 50 | + immutableSignerAddress, |
| 51 | + startupWalletImplAddress |
| 52 | + ); |
| 53 | + await stage1Module.deployed(); |
| 54 | + |
| 55 | + console.log(`[${network}] Stage1Module deployed to: ${stage1Module.address}`); |
| 56 | + |
| 57 | + fs.writeFileSync('step5b.json', JSON.stringify({ |
| 58 | + stage1Module: stage1Module.address, |
| 59 | + }, null, 2)); |
| 60 | + |
| 61 | + return env; |
| 62 | +} |
| 63 | + |
| 64 | +step5b() |
| 65 | + .then((env) => console.log('Done!')) |
| 66 | + .catch(console.error); |
0 commit comments