|
1 | 1 | import { Deployer, Reporter } from "@solarity/hardhat-migrate"; |
2 | 2 |
|
3 | | -import { SPVGateway__factory } from "@ethers-v6"; |
| 3 | +import { SPVGateway__factory, ICreateX__factory } from "@ethers-v6"; |
4 | 4 |
|
5 | 5 | import { getConfig } from "./config/config"; |
| 6 | +import { getSPVGatewayAddr, getSPVGatewaySalt } from "./helpers/helpers"; |
6 | 7 |
|
7 | 8 | export = async (deployer: Deployer) => { |
8 | | - const config = (await getConfig())!; |
| 9 | + const config = await getConfig(); |
9 | 10 |
|
10 | | - const spvGateway = await deployer.deploy(SPVGateway__factory); |
| 11 | + const createXDeployer = await deployer.deployed(ICreateX__factory, "0xba5Ed099633D3B313e4D5F7bdc1305d3c28ba5Ed"); |
11 | 12 |
|
12 | | - await spvGateway["__SPVGateway_init(bytes,uint256,uint256)"]( |
13 | | - config.blockHeader, |
14 | | - config.blockHeight, |
15 | | - config.cumulativeWork, |
| 13 | + const salt = getSPVGatewaySalt(); |
| 14 | + const initCalldata = SPVGateway__factory.createInterface().encodeFunctionData( |
| 15 | + "__SPVGateway_init(bytes,uint64,uint256)", |
| 16 | + [config.blockHeader, config.blockHeight, config.cumulativeWork], |
16 | 17 | ); |
17 | 18 |
|
18 | | - Reporter.reportContracts(["SPVGateway", await spvGateway.getAddress()]); |
| 19 | + await createXDeployer.deployCreate2AndInit(salt, SPVGateway__factory.bytecode, initCalldata, { |
| 20 | + constructorAmount: 0n, |
| 21 | + initCallAmount: 0n, |
| 22 | + }); |
| 23 | + |
| 24 | + const spvGatewayAddr = await getSPVGatewayAddr(createXDeployer); |
| 25 | + |
| 26 | + Reporter.reportContracts(["SPVGateway", spvGatewayAddr]); |
19 | 27 | }; |
0 commit comments