From d2ebcbf4265c23d0353624bde01ca2d88f36f652 Mon Sep 17 00:00:00 2001 From: Reinis Martinsons <77973553+Reinis-FRP@users.noreply.github.com> Date: Tue, 20 Feb 2024 13:51:42 +0200 Subject: [PATCH] feat: core networks for osnap (#2) * feat: support core testnet Signed-off-by: Reinis Martinsons * feat: support core mainnet Signed-off-by: Reinis Martinsons * fix: comment on limited core support Signed-off-by: Reinis Martinsons * feat: add core hardhat config Signed-off-by: Reinis Martinsons * fix: deployment tasks Signed-off-by: Reinis Martinsons * fix: remove comment Signed-off-by: Reinis Martinsons --------- Signed-off-by: Reinis Martinsons --- hardhat.config.ts | 26 ++++++++++++++++++++++++++ sdk/contracts.ts | 14 ++++++++++++++ sdk/factory/mastercopyDeployer.ts | 2 +- sdk/factory/singletonFactory.ts | 10 ++++++---- tasks/deploy-replay.ts | 2 +- tasks/singleton-deployment.ts | 2 +- 6 files changed, 49 insertions(+), 7 deletions(-) diff --git a/hardhat.config.ts b/hardhat.config.ts index c682e9f..1147be7 100644 --- a/hardhat.config.ts +++ b/hardhat.config.ts @@ -110,6 +110,14 @@ export default { ...sharedNetworkConfig, url: `https://linea-goerli.infura.io/v3/${INFURA_KEY}`, }, + core: { + ...sharedNetworkConfig, + url: "https://rpc.coredao.org", + }, + coreTestnet: { + ...sharedNetworkConfig, + url: "https://rpc.test.btcs.network", + }, }, namedAccounts: { deployer: 0, @@ -119,5 +127,23 @@ export default { }, etherscan: { apiKey: ETHERSCAN_API_KEY, + customChains: [ + { + network: "coreTestnet", + chainId: 1115, + urls: { + apiURL: "https://api.test.btcs.network/api", + browserURL: "https://scan.test.btcs.network/", + }, + }, + { + network: "core", + chainId: 1116, + urls: { + apiURL: "https://openapi.coredao.org/api", + browserURL: "https://scan.coredao.org/", + }, + }, + ], }, }; diff --git a/sdk/contracts.ts b/sdk/contracts.ts index 5a42911..49e75c9 100644 --- a/sdk/contracts.ts +++ b/sdk/contracts.ts @@ -53,6 +53,8 @@ export enum SupportedNetworks { HardhatNetwork = 31337, LineaGoerli = 59140, Sepolia = 11155111, + CoreTestnet = 1115, + Core = 1116, } // const canonicalMasterCopyAddress = (contract: KnownContracts) => { @@ -215,6 +217,18 @@ export const ContractVersions: Record< }, [SupportedNetworks.LineaGoerli]: CanonicalAddresses, [SupportedNetworks.Sepolia]: CanonicalAddresses, + [SupportedNetworks.CoreTestnet]: { + ...CanonicalAddresses, + [KnownContracts.OPTIMISTIC_GOVERNOR]: { + "1.2.0": "0xD43463Fadd73373bE260b67F5825274F4403dAF0", + }, + }, + [SupportedNetworks.Core]: { + ...CanonicalAddresses, + [KnownContracts.OPTIMISTIC_GOVERNOR]: { + "1.2.0": "0x596Fd6A5A185c67aBD1c845b39f593fBA9C233aa", + }, + }, }; /** Addresses of the head versions of all contracts */ diff --git a/sdk/factory/mastercopyDeployer.ts b/sdk/factory/mastercopyDeployer.ts index 3ebef99..e27634f 100644 --- a/sdk/factory/mastercopyDeployer.ts +++ b/sdk/factory/mastercopyDeployer.ts @@ -106,7 +106,7 @@ export const deployMastercopyWithInitData = async ( const initCodeHash = keccak256(initCode); const computedTargetAddress = getCreate2Address( - await singletonFactory.address(), + await singletonFactory.getAddress(), salt, initCodeHash ); diff --git a/sdk/factory/singletonFactory.ts b/sdk/factory/singletonFactory.ts index 4531356..e3e6bb8 100644 --- a/sdk/factory/singletonFactory.ts +++ b/sdk/factory/singletonFactory.ts @@ -33,10 +33,12 @@ export const getSingletonFactory = async ( "Singleton factory is not deployed on this chain. Deploying singleton factory..." ); // fund the singleton factory deployer account - await signer.sendTransaction({ - to: singletonDeployer, - value: parseEther("0.0247"), - }); + await ( + await signer.sendTransaction({ + to: singletonDeployer, + value: parseEther("0.0247"), + }) + ).wait(); // deploy the singleton factory await ( diff --git a/tasks/deploy-replay.ts b/tasks/deploy-replay.ts index 772026f..d5b6ea4 100644 --- a/tasks/deploy-replay.ts +++ b/tasks/deploy-replay.ts @@ -17,7 +17,7 @@ export const deploy = async (_: unknown, hre: HardhatRuntimeEnvironment) => { console.log(`\n\x1B[4m\x1B[1m${hre.network.name}\x1B[0m`); const [deployer] = await hre.ethers.getSigners(); - const signer = hre.ethers.provider.getSigner(deployer.address); + const signer = await hre.ethers.provider.getSigner(deployer.address); for (let index = 0; index < contracts.length; index++) { const initData: InitData | undefined = MasterCopyInitData[contracts[index]]; diff --git a/tasks/singleton-deployment.ts b/tasks/singleton-deployment.ts index 5e28fde..4669778 100644 --- a/tasks/singleton-deployment.ts +++ b/tasks/singleton-deployment.ts @@ -16,7 +16,7 @@ export const deploy = async (_: unknown, hre: HardhatRuntimeEnvironment) => { } const [deployer] = await hre.ethers.getSigners(); - await deployModuleFactory(hre.ethers.provider.getSigner(deployer.address)); + await deployModuleFactory(await hre.ethers.provider.getSigner(deployer.address)); }; task(