diff --git a/.gitmodules b/.gitmodules index 1bb71f281..d5392fba8 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,6 +4,3 @@ [submodule "solidity/lib/fx-portal"] path = solidity/lib/fx-portal url = https://github.com/0xPolygon/fx-portal -[submodule "solidity/solidity/lib/foundry-zksync"] - path = solidity/solidity/lib/foundry-zksync - url = https://github.com/matter-labs/foundry-zksync diff --git a/solidity/generate-artifact-exports.mjs b/solidity/generate-artifact-exports.mjs index 8887bb5c9..35cff4755 100755 --- a/solidity/generate-artifact-exports.mjs +++ b/solidity/generate-artifact-exports.mjs @@ -6,19 +6,11 @@ import { fileURLToPath } from 'url'; const cwd = process.cwd(); const zksyncArtifacts = glob(cwd, [ - `!./artifacts-zk/contracts/interfaces/**/*`, `!./artifacts-zk/contracts/**/*.dbg.json`, `!./artifacts-zk/@openzeppelin/**/*.dbg.json`, `./artifacts-zk/contracts/**/+([a-zA-Z0-9_]).json`, `./artifacts-zk/@openzeppelin/**/+([a-zA-Z0-9_]).json`, ]); -const evmArtifacts = glob(cwd, [ - `!./artifacts/contracts/interfaces/**/*`, - `!./artifacts/contracts/**/*.dbg.json`, - `!./artifacts/@openzeppelin/**/*.dbg.json`, - `./artifacts/contracts/**/+([a-zA-Z0-9_]).json`, - `./artifacts/@openzeppelin/**/+([a-zA-Z0-9_]).json`, -]); const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); @@ -28,41 +20,25 @@ const outputFile = join(__dirname, 'types/zksync/artifacts/index.ts'); const outputDir = join(__dirname, 'types/zksync/artifacts'); const zkSyncFileNames = new Set(); -const evmFileNames = new Set(); + +let zkSyncArtifactMap = {}; // Start building the TypeScript export string let exportStatements = zksyncArtifacts .map((file) => { - let fileName = `${basename(file, '.json')}__artifact`; - const fileContent = readFileSync(file, 'utf-8'); const jsonObject = JSON.parse(fileContent); + const contractName = jsonObject.contractName; + let fileName = `${basename(file, '.json')}__artifact`; if (zkSyncFileNames.has(fileName)) { return; } zkSyncFileNames.add(fileName); - // Create a TypeScript object export statement - return `export const ${fileName} = ${JSON.stringify( - jsonObject, - null, - 2, - )} as const;`; - }) - .join('\n\n'); - -exportStatements += evmArtifacts - .map((file) => { - let fileName = `${basename(file, '.json')}__evm_artifact`; + // Add to artifact map + zkSyncArtifactMap[contractName] = fileName; - const fileContent = readFileSync(file, 'utf-8'); - const jsonObject = JSON.parse(fileContent); - - if (evmFileNames.has(fileName)) { - return; - } - evmFileNames.add(fileName); // Create a TypeScript object export statement return `export const ${fileName} = ${JSON.stringify( jsonObject, @@ -76,10 +52,6 @@ exportStatements += `\n\nexport const zksyncArtifacts : any[] = [\n${Array.from( zkSyncFileNames, ).join(',\n')}\n] as const;`; -exportStatements += `\n\nexport const evmArtifacts: any[] = [\n${Array.from( - evmFileNames, -).join(',\n')}\n] as const;`; - if (!existsSync(outputDir)) { mkdirSync(outputDir, { recursive: true }); } diff --git a/solidity/package.json b/solidity/package.json index af3886c2e..5d60ffc95 100644 --- a/solidity/package.json +++ b/solidity/package.json @@ -69,7 +69,7 @@ ], "license": "Apache-2.0", "scripts": { - "build": "yarn hardhat-esm compile && yarn hardhat-zk compile && tsc && ts-node generate-artifact-exports.mjs && ./exportBuildArtifact.sh", + "build": "yarn hardhat-esm compile && yarn hardhat-zk compile && ts-node generate-artifact-exports.mjs && tsc && ./exportBuildArtifact.sh", "lint": "solhint contracts/**/*.sol", "clean": "yarn hardhat-esm clean && yarn hardhat-zk clean && rm -rf ./dist ./cache ./cache-zk ./types ./coverage ./out ./forge-cache ./fixtures", "coverage": "yarn fixtures && ./coverage.sh", diff --git a/solidity/test/merkle.test.ts b/solidity/test/merkle.test.ts index dec436f3e..f2a3d5d39 100644 --- a/solidity/test/merkle.test.ts +++ b/solidity/test/merkle.test.ts @@ -1,8 +1,5 @@ -import { Deployer } from '@matterlabs/hardhat-zksync-deploy'; import { expect } from 'chai'; import { utils } from 'ethers'; -import hre from 'hardhat'; -import { Provider, Wallet } from 'zksync-ethers'; import merkleTestCases from '../../vectors/merkle.json' assert { type: 'json' }; import { TestMerkle, TestMerkle__factory } from '../types'; @@ -14,20 +11,13 @@ describe('Merkle', async () => { const { testName, leaves, expectedRoot, proofs } = testCase; describe(testName, async () => { - let merkle: any; + let merkle: TestMerkle; before(async () => { - // const signer = await getSigner(); + const signer = await getSigner(); - const provider = new Provider('http://127.0.0.1:8011'); - - const deployerWallet = new Wallet( - '0x3d3cbc973389cb26f657686445bcc75662b415b656078503592ac8c1abb8810e', - provider, - ); - const deployer = new Deployer(hre, deployerWallet); - const artifact = await deployer.loadArtifact('TestMerkle'); - merkle = await deployer.deploy(artifact, []); + const merkleFactory = new TestMerkle__factory(signer); + merkle = await merkleFactory.deploy(); //insert the leaves for (const leaf of leaves) { diff --git a/solidity/test/message.test.ts b/solidity/test/message.test.ts index cc16e94c8..83bde28b6 100644 --- a/solidity/test/message.test.ts +++ b/solidity/test/message.test.ts @@ -1,8 +1,5 @@ -import { Deployer } from '@matterlabs/hardhat-zksync-deploy'; import { expect } from 'chai'; import { utils } from 'ethers'; -import hre from 'hardhat'; -import { Provider, Wallet } from 'zksync-ethers'; import { addressToBytes32, @@ -20,23 +17,18 @@ const localDomain = 2000; const nonce = 11; describe('Message', async () => { - let messageLib: any; + let messageLib: TestMessage; let version: number; before(async () => { - const provider = new Provider('http://127.0.0.1:8011'); + const signer = await getSigner(); - const deployerWallet = new Wallet( - '0x3d3cbc973389cb26f657686445bcc75662b415b656078503592ac8c1abb8810e', - provider, - ); - const deployer = new Deployer(hre, deployerWallet); - let artifact = await deployer.loadArtifact('TestMessage'); - messageLib = await deployer.deploy(artifact, []); - - artifact = await deployer.loadArtifact('Mailbox'); - const mailbox = await deployer.deploy(artifact, [localDomain]); + const Message = new TestMessage__factory(signer); + messageLib = await Message.deploy(); + // For consistency with the Mailbox version + const Mailbox = new Mailbox__factory(signer); + const mailbox = await Mailbox.deploy(localDomain); version = await mailbox.VERSION(); }); diff --git a/solidity/test/mockMailbox.test.ts b/solidity/test/mockMailbox.test.ts index ca93fe6a4..db49a7585 100644 --- a/solidity/test/mockMailbox.test.ts +++ b/solidity/test/mockMailbox.test.ts @@ -1,8 +1,5 @@ -import { Deployer } from '@matterlabs/hardhat-zksync-deploy'; import { expect } from 'chai'; import { utils } from 'ethers'; -import hre from 'hardhat'; -import { Provider, Wallet } from 'zksync-ethers'; import { addressToBytes32 } from '@hyperlane-xyz/utils'; @@ -15,28 +12,16 @@ const DESTINATION_DOMAIN = 2000; describe('MockMailbox', function () { it('should be able to mock sending and receiving a message', async function () { - const provider = new Provider('http://127.0.0.1:8011'); - - const deployerWallet = new Wallet( - '0x3d3cbc973389cb26f657686445bcc75662b415b656078503592ac8c1abb8810e', - provider, - ); - - const deployer = new Deployer(hre, deployerWallet); - - let artifact = await deployer.loadArtifact('MockMailbox'); - const originMailbox = await deployer.deploy(artifact, [ORIGIN_DOMAIN]); - const destinationMailbox = await deployer.deploy(artifact, [ - DESTINATION_DOMAIN, - ]); - + const signer = await getSigner(); + const mailboxFactory = new MockMailbox__factory(signer); + const testRecipientFactory = new TestRecipient__factory(signer); + const originMailbox = await mailboxFactory.deploy(ORIGIN_DOMAIN); + const destinationMailbox = await mailboxFactory.deploy(DESTINATION_DOMAIN); await originMailbox.addRemoteMailbox( DESTINATION_DOMAIN, destinationMailbox.address, ); - - artifact = await deployer.loadArtifact('TestRecipient'); - const recipient = await deployer.deploy(artifact, []); + const recipient = await testRecipientFactory.deploy(); const body = utils.toUtf8Bytes('This is a test message'); diff --git a/solidity/test/testrecipient.test.ts b/solidity/test/testrecipient.test.ts index ac4482e72..acdbf573e 100644 --- a/solidity/test/testrecipient.test.ts +++ b/solidity/test/testrecipient.test.ts @@ -1,8 +1,5 @@ -import { Deployer } from '@matterlabs/hardhat-zksync-deploy'; import { expect } from 'chai'; import { utils } from 'ethers'; -import hre from 'hardhat'; -import { Provider, Wallet } from 'zksync-ethers'; import { addressToBytes32 } from '@hyperlane-xyz/utils'; @@ -12,27 +9,20 @@ import { getSigner } from './signer'; const testData = utils.hexlify(utils.toUtf8Bytes('test')); describe('TestRecipient', () => { - let recipient: any; + let recipient: TestRecipient; let signerAddress: string; before(async () => { - const provider = new Provider('http://127.0.0.1:8011'); - - const deployerWallet = new Wallet( - '0x3d3cbc973389cb26f657686445bcc75662b415b656078503592ac8c1abb8810e', - provider, - ); - const deployer = new Deployer(hre, deployerWallet); - - let artifact = await deployer.loadArtifact('TestRecipient'); - recipient = await deployer.deploy(artifact, []); + const signer = await getSigner(); + signerAddress = await signer.getAddress(); + const recipientFactory = new TestRecipient__factory(signer); + recipient = await recipientFactory.deploy(); }); it('handles a message', async () => { await expect( recipient.handle(0, addressToBytes32(signerAddress), testData), ).to.emit(recipient, 'ReceivedMessage'); - expect(await recipient.lastSender()).to.eql( addressToBytes32(signerAddress), ); diff --git a/typescript/cli/src/config/warp.ts b/typescript/cli/src/config/warp.ts index 4f6e7fcf3..240e0e39d 100644 --- a/typescript/cli/src/config/warp.ts +++ b/typescript/cli/src/config/warp.ts @@ -221,8 +221,18 @@ export function readWarpCoreConfig(filePath: string): WarpCoreConfig { */ function createDefaultWarpIsmConfig(owner: Address): IsmConfig { return { - type: IsmType.STORAGE_MERKLE_ROOT_MULTISIG, - validators: [owner], + type: IsmType.AGGREGATION, + modules: [ + { + type: IsmType.TRUSTED_RELAYER, + relayer: owner, + }, + { + type: IsmType.FALLBACK_ROUTING, + domains: {}, + owner, + }, + ], threshold: 1, }; } diff --git a/typescript/cli/src/context/context.ts b/typescript/cli/src/context/context.ts index 6a0572e17..6308f1230 100644 --- a/typescript/cli/src/context/context.ts +++ b/typescript/cli/src/context/context.ts @@ -17,10 +17,7 @@ import { import { isHttpsUrl, isNullish, rootLogger } from '@hyperlane-xyz/utils'; import { isSignCommand } from '../commands/signCommands.js'; -import { - // forkNetworkToMultiProvider, - verifyAnvil, -} from '../deploy/dry-run.js'; +import { forkNetworkToMultiProvider, verifyAnvil } from '../deploy/dry-run.js'; import { logBlue } from '../logger.js'; import { runSingleChainSelectionStep } from '../utils/chains.js'; import { detectAndConfirmOrPrompt } from '../utils/input.js'; @@ -110,13 +107,13 @@ export async function getDryRunContext( await verifyAnvil(); let multiProvider = await getMultiProvider(registry); - // multiProvider = await forkNetworkToMultiProvider(multiProvider, chain); + multiProvider = await forkNetworkToMultiProvider(multiProvider, chain); const { impersonatedKey, impersonatedSigner } = await getImpersonatedSigner({ fromAddress, key, skipConfirmation, }); - // multiProvider.setSharedSigner(impersonatedSigner); + multiProvider.setSharedSigner(impersonatedSigner); return { registry, diff --git a/typescript/sdk/src/app/typechain.test.ts b/typescript/sdk/src/app/typechain.test.ts deleted file mode 100644 index 39d0ffc51..000000000 --- a/typescript/sdk/src/app/typechain.test.ts +++ /dev/null @@ -1,27 +0,0 @@ -import * as ethers from 'ethers'; -import { Contract, ContractFactory, Provider, Wallet } from 'zksync-ethers'; - -import { TestMerkle__factory } from '@hyperlane-xyz/core'; - -describe('MultiProtocolApp', async () => { - const provider = new Provider('http://127.0.0.1:8011'); - - const deployerWallet = new Wallet( - '0x3d3cbc973389cb26f657686445bcc75662b415b656078503592ac8c1abb8810e', - provider, - ); - - const factory = new ContractFactory( - TestMerkle__factory.abi, - TestMerkle__factory.bytecode, - deployerWallet, - 'create2', - ); - - let token = (await factory.deploy({ - customData: { salt: ethers.utils.hexlify(ethers.utils.randomBytes(32)) }, - })) as Contract; - - const tokenAddress = token.address; - console.log(`Contract address: ${tokenAddress}`); -}); diff --git a/typescript/sdk/src/consts/testChains.ts b/typescript/sdk/src/consts/testChains.ts index dd2288208..4be206cc3 100644 --- a/typescript/sdk/src/consts/testChains.ts +++ b/typescript/sdk/src/consts/testChains.ts @@ -28,16 +28,16 @@ export const test1: ChainMetadata = { blocks: { confirmations: 1, estimateBlockTime: 3, - reorgPeriod: 1, + reorgPeriod: 0, }, - chainId: 260, + chainId: 9913371, displayName: 'Test 1', - domainId: 260, + domainId: 9913371, isTestnet: true, name: 'test1', nativeToken: { decimals: 18, name: 'Ether', symbol: 'ETH' }, protocol: ProtocolType.Ethereum, - rpcUrls: [{ http: 'http://127.0.0.1:8011' }], + rpcUrls: [{ http: 'http://127.0.0.1:8545' }], }; export const test2: ChainMetadata = { @@ -47,9 +47,9 @@ export const test2: ChainMetadata = { estimateBlockTime: 3, reorgPeriod: 1, }, - chainId: 260, + chainId: 9913372, displayName: 'Test 2', - domainId: 260, + domainId: 9913372, name: 'test2', }; @@ -60,22 +60,17 @@ export const test3: ChainMetadata = { estimateBlockTime: 3, reorgPeriod: 2, }, - chainId: 260, + chainId: 9913373, displayName: 'Test 3', - domainId: 260, + domainId: 9913373, name: 'test3', }; export const test4: ChainMetadata = { ...test1, - blocks: { - confirmations: 1, - estimateBlockTime: 3, - reorgPeriod: 2, - }, - chainId: 260, + chainId: 31337, displayName: 'Test 4', - domainId: 260, + domainId: 31337, name: 'test4', }; diff --git a/typescript/sdk/src/core/EvmCoreModule.hardhat-test.ts b/typescript/sdk/src/core/EvmCoreModule.hardhat-test.ts index 6772f87e2..509e443d1 100644 --- a/typescript/sdk/src/core/EvmCoreModule.hardhat-test.ts +++ b/typescript/sdk/src/core/EvmCoreModule.hardhat-test.ts @@ -22,7 +22,7 @@ import { EvmCoreModule } from './EvmCoreModule.js'; import { CoreConfig } from './types.js'; describe('EvmCoreModule', async () => { - const CHAIN = TestChainName.test1; + const CHAIN = TestChainName.test4; const DELAY = 1892391283182; let config: CoreConfig; let signer: SignerWithAddress; diff --git a/typescript/sdk/src/core/HyperlaneCoreDeployer.ts b/typescript/sdk/src/core/HyperlaneCoreDeployer.ts index 51fe908ba..c30f5130b 100644 --- a/typescript/sdk/src/core/HyperlaneCoreDeployer.ts +++ b/typescript/sdk/src/core/HyperlaneCoreDeployer.ts @@ -19,12 +19,7 @@ import { MultiProvider } from '../providers/MultiProvider.js'; import { ChainMap, ChainName } from '../types.js'; import { TestRecipientDeployer } from './TestRecipientDeployer.js'; -import { - CoreAddresses, - CoreFactories, - coreFactories, - coreFactoriesArtifacts, -} from './contracts.js'; +import { CoreAddresses, CoreFactories, coreFactories } from './contracts.js'; import { CoreConfig } from './types.js'; export class HyperlaneCoreDeployer extends HyperlaneDeployer< @@ -41,7 +36,7 @@ export class HyperlaneCoreDeployer extends HyperlaneDeployer< concurrentDeploy: boolean = false, chainTimeoutMs: number = 1000 * 60 * 10, // 10 minutes ) { - super(multiProvider, coreFactories, coreFactoriesArtifacts, { + super(multiProvider, coreFactories, { logger: rootLogger.child({ module: 'CoreDeployer' }), chainTimeoutMs, ismFactory, diff --git a/typescript/sdk/src/core/HyperlaneRelayer.ts b/typescript/sdk/src/core/HyperlaneRelayer.ts index 39aeafb9e..c9fd53719 100644 --- a/typescript/sdk/src/core/HyperlaneRelayer.ts +++ b/typescript/sdk/src/core/HyperlaneRelayer.ts @@ -168,7 +168,7 @@ export class HyperlaneRelayer { 12, // 12 attempts ); - this.logger.debug({ message, metadata }, `Relaying message ${message.id}`); + this.logger.info({ message, metadata }, `Relaying message ${message.id}`); return this.core.deliver(message, metadata); } diff --git a/typescript/sdk/src/core/TestRecipientDeployer.ts b/typescript/sdk/src/core/TestRecipientDeployer.ts index aed23b38b..9d0fd40a8 100644 --- a/typescript/sdk/src/core/TestRecipientDeployer.ts +++ b/typescript/sdk/src/core/TestRecipientDeployer.ts @@ -1,5 +1,4 @@ import { TestRecipient, TestRecipient__factory } from '@hyperlane-xyz/core'; -import { TestRecipient__artifact } from '@hyperlane-xyz/core/artifacts'; import { Address, rootLogger } from '@hyperlane-xyz/utils'; import { HyperlaneDeployer } from '../deploy/HyperlaneDeployer.js'; @@ -24,9 +23,6 @@ export type TestRecipientAddresses = { export const testRecipientFactories = { testRecipient: new TestRecipient__factory(), }; -export const testRecipientFactoriesArtifacts = { - testRecipient: TestRecipient__artifact, -}; export class TestRecipientDeployer extends HyperlaneDeployer< TestRecipientConfig, @@ -37,16 +33,11 @@ export class TestRecipientDeployer extends HyperlaneDeployer< contractVerifier?: ContractVerifier, concurrentDeploy = false, ) { - super( - multiProvider, - testRecipientFactories, - testRecipientFactoriesArtifacts, - { - logger: rootLogger.child({ module: 'TestRecipientDeployer' }), - contractVerifier, - concurrentDeploy, - }, - ); + super(multiProvider, testRecipientFactories, { + logger: rootLogger.child({ module: 'TestRecipientDeployer' }), + contractVerifier, + concurrentDeploy, + }); } async deployContracts( @@ -57,15 +48,14 @@ export class TestRecipientDeployer extends HyperlaneDeployer< const testRecipient = await this.deployContract(chain, 'testRecipient', []); if (config.interchainSecurityModule) { - this.logger.info(`Checking TestRecipient ISM on ${chain}`); + this.logger.debug(`Checking TestRecipient ISM on ${chain}`); await this.configureIsm( chain, testRecipient, config.interchainSecurityModule, - (tr: TestRecipient) => tr.interchainSecurityModule(), - (tr: TestRecipient, ism) => - tr.populateTransaction.setInterchainSecurityModule(ism), + (tr) => tr.interchainSecurityModule(), + (tr, ism) => tr.populateTransaction.setInterchainSecurityModule(ism), ); } else { this.logger.warn(`No ISM config provided for TestRecipient on ${chain}`); diff --git a/typescript/sdk/src/core/contracts.ts b/typescript/sdk/src/core/contracts.ts index 31fa2c4b7..cfe0b41fc 100644 --- a/typescript/sdk/src/core/contracts.ts +++ b/typescript/sdk/src/core/contracts.ts @@ -3,11 +3,6 @@ import { ProxyAdmin__factory, ValidatorAnnounce__factory, } from '@hyperlane-xyz/core'; -import { - Mailbox__artifact, - ProxyAdmin__artifact, - ValidatorAnnounce__artifact, -} from '@hyperlane-xyz/core/artifacts'; import { HyperlaneAddresses } from '../contracts/types.js'; @@ -17,12 +12,6 @@ export const coreFactories = { mailbox: new Mailbox__factory(), }; -export const coreFactoriesArtifacts = { - validatorAnnounce: ValidatorAnnounce__artifact, - proxyAdmin: ProxyAdmin__artifact, - mailbox: Mailbox__artifact, -}; - export type CoreFactories = typeof coreFactories; export type CoreAddresses = HyperlaneAddresses; diff --git a/typescript/sdk/src/deploy/EvmModuleDeployer.ts b/typescript/sdk/src/deploy/EvmModuleDeployer.ts index 3421d4b48..f63bf094c 100644 --- a/typescript/sdk/src/deploy/EvmModuleDeployer.ts +++ b/typescript/sdk/src/deploy/EvmModuleDeployer.ts @@ -28,7 +28,6 @@ export class EvmModuleDeployer { constructor( protected readonly multiProvider: MultiProvider, protected readonly factories: Factories, - protected readonly artifacts: any, protected readonly logger = rootLogger.child({ module: 'EvmModuleDeployer', }), @@ -57,7 +56,6 @@ export class EvmModuleDeployer { constructorArgs: Parameters; initializeArgs?: Parameters>['initialize']>; implementationAddress?: Address; - artifact?: any; }): Promise> { this.logger.info( `Deploying ${contractName} on ${chain} with constructor args (${constructorArgs.join( @@ -67,6 +65,10 @@ export class EvmModuleDeployer { const artifact = getArtifactByContractName(contractName); + if (!artifact) { + throw new Error(`No ZKSync artifact found for contract: ${contractName}`); + } + const contract = await this.multiProvider.handleDeploy( chain, factory, @@ -133,7 +135,6 @@ export class EvmModuleDeployer { contractName, constructorArgs, initializeArgs, - artifact: this.artifacts[contractKey], }); return contract; } diff --git a/typescript/sdk/src/deploy/HyperlaneDeployer.ts b/typescript/sdk/src/deploy/HyperlaneDeployer.ts index f86de944d..7d02c27d2 100644 --- a/typescript/sdk/src/deploy/HyperlaneDeployer.ts +++ b/typescript/sdk/src/deploy/HyperlaneDeployer.ts @@ -16,6 +16,7 @@ import { buildArtifact as coreBuildArtifact } from '@hyperlane-xyz/core/buildArt import { Address, ProtocolType, + addBufferToGasLimit, eqAddress, isZeroishAddress, rootLogger, @@ -54,6 +55,7 @@ import { } from './verify/types.js'; import { buildVerificationInput, + getContractVerificationInput, shouldAddVerificationInput, } from './verify/utils.js'; @@ -81,7 +83,6 @@ export abstract class HyperlaneDeployer< constructor( protected readonly multiProvider: MultiProvider, protected readonly factories: Factories, - protected readonly artifacts: any, protected readonly options: DeployerOptions = {}, protected readonly recoverVerificationInputs = false, protected readonly icaAddresses = {}, @@ -299,15 +300,13 @@ export abstract class HyperlaneDeployer< } if (!matches) { await this.runIfOwner(chain, contract, async () => { - this.logger.info(`Set ISM on ${chain} with address ${targetIsm}`); + this.logger.debug(`Set ISM on ${chain} with address ${targetIsm}`); await this.multiProvider.sendTransaction( chain, setIsm(contract, targetIsm), ); - await new Promise((resolve) => setTimeout(resolve, 3000)); - if (!eqAddress(targetIsm, await getIsm(contract))) { throw new Error(`Set ISM failed on ${chain}`); } @@ -351,7 +350,7 @@ export abstract class HyperlaneDeployer< client: MailboxClient, config: MailboxClientConfig, ): Promise { - this.logger.info( + this.logger.debug( `Initializing mailbox client (if not already) on ${local}...`, ); if (config.hook) { @@ -385,7 +384,7 @@ export abstract class HyperlaneDeployer< constructorArgs: Parameters, initializeArgs?: Parameters>['initialize']>, shouldRecover = true, - implementationAddress?: Address | null, + implementationAddress?: Address, ): Promise> { if (shouldRecover) { const cachedContract = this.readCache(chain, factory, contractName); @@ -409,6 +408,8 @@ export abstract class HyperlaneDeployer< )})...`, ); + const { protocol } = this.multiProvider.getChainMetadata(chain); + const artifact = getArtifactByContractName(contractName); const contract = await this.multiProvider.handleDeploy( @@ -429,22 +430,38 @@ export abstract class HyperlaneDeployer< `Skipping: Contract ${contractName} (${contract.address}) on ${chain} is already initialized`, ); } else { - this.logger.info( + this.logger.debug( `Initializing ${contractName} (${contract.address}) on ${chain}...`, ); - // Estimate gas for the initialize transaction - // const estimatedGas = await contract.estimateGas.initialize( - // ...initializeArgs, - // ); - - // deploy with 10% buffer on gas limit const overrides = this.multiProvider.getTransactionOverrides(chain); - const initTx = await contract.initialize(...initializeArgs, { - // gasLimit: estimatedGas.add(estimatedGas.div(10)), - ...overrides, - }); + let enhancedOverrides; + if (protocol === ProtocolType.ZKSync) { + this.logger.info('Skipping gas estimation on ZKSync...'); + + // deploy with 10% buffer on gas limit + enhancedOverrides = { + // TODO: zksync gas estimation + ...overrides, + }; + } else { + // Estimate gas for the initialize transaction + const estimatedGas = await contract.estimateGas.initialize( + ...initializeArgs, + ); + + // deploy with 10% buffer on gas limit + enhancedOverrides = { + gasLimit: addBufferToGasLimit(estimatedGas), + ...overrides, + }; + } + + const initTx = await contract.initialize( + ...initializeArgs, + enhancedOverrides, + ); this.logger.info(`Contract ${contractName} initialized`); const receipt = await this.multiProvider.handleTx(chain, initTx); @@ -454,25 +471,30 @@ export abstract class HyperlaneDeployer< } } - // const verificationInput = getContractVerificationInput({ - // name: contractName, - // contract, - // bytecode: factory.bytecode, - // expectedimplementation: implementationAddress, - // }); - - // this.addVerificationArtifacts(chain, [verificationInput]); - - // // try verifying contract - // try { - // await this.options.contractVerifier?.verifyContract( - // chain, - // verificationInput, - // ); - // } catch (error) { - // // log error but keep deploying, can also verify post-deployment if needed - // this.logger.debug(`Error verifying contract: ${error}`); - // } + // TODO: ZKSync contract verification + if (protocol === ProtocolType.ZKSync) { + this.logger.info('Skipping contract verification on ZKSync...'); + } else { + const verificationInput = getContractVerificationInput({ + name: contractName, + contract, + bytecode: factory.bytecode, + expectedimplementation: implementationAddress, + }); + + this.addVerificationArtifacts(chain, [verificationInput]); + + // try verifying contract + try { + await this.options.contractVerifier?.verifyContract( + chain, + verificationInput, + ); + } catch (error) { + // log error but keep deploying, can also verify post-deployment if needed + this.logger.debug(`Error verifying contract: ${error}`); + } + } return contract; } @@ -507,7 +529,6 @@ export abstract class HyperlaneDeployer< constructorArgs, initializeArgs, shouldRecover, - null, ); this.writeCache(chain, contractName, contract.address); return contract; diff --git a/typescript/sdk/src/deploy/HyperlaneProxyFactoryDeployer.ts b/typescript/sdk/src/deploy/HyperlaneProxyFactoryDeployer.ts index 31c12f4bb..d8584f250 100644 --- a/typescript/sdk/src/deploy/HyperlaneProxyFactoryDeployer.ts +++ b/typescript/sdk/src/deploy/HyperlaneProxyFactoryDeployer.ts @@ -8,7 +8,6 @@ import { HyperlaneDeployer } from './HyperlaneDeployer.js'; import { ProxyFactoryFactories, proxyFactoryFactories, - proxyFactoryFactoriesArtifacts, proxyFactoryImplementations, } from './contracts.js'; import { ContractVerifier } from './verify/ContractVerifier.js'; @@ -22,16 +21,11 @@ export class HyperlaneProxyFactoryDeployer extends HyperlaneDeployer< contractVerifier?: ContractVerifier, concurrentDeploy: boolean = false, ) { - super( - multiProvider, - proxyFactoryFactories, - proxyFactoryFactoriesArtifacts, - { - logger: rootLogger.child({ module: 'IsmFactoryDeployer' }), - contractVerifier, - concurrentDeploy, - }, - ); + super(multiProvider, proxyFactoryFactories, { + logger: rootLogger.child({ module: 'IsmFactoryDeployer' }), + contractVerifier, + concurrentDeploy, + }); } async deployContracts( diff --git a/typescript/sdk/src/deploy/contracts.ts b/typescript/sdk/src/deploy/contracts.ts index 2f6f5701a..06756d08c 100644 --- a/typescript/sdk/src/deploy/contracts.ts +++ b/typescript/sdk/src/deploy/contracts.ts @@ -7,16 +7,6 @@ import { StaticMessageIdMultisigIsmFactory__factory, StaticMessageIdWeightedMultisigIsmFactory__factory, } from '@hyperlane-xyz/core'; -import { - DomainRoutingIsmFactory__artifact, - ProxyAdmin__artifact, - StaticAggregationHookFactory__artifact, - StaticAggregationIsmFactory__artifact, - StaticMerkleRootMultisigIsmFactory__artifact, - StaticMerkleRootWeightedMultisigIsmFactory__artifact, - StaticMessageIdMultisigIsmFactory__artifact, - StaticMessageIdWeightedMultisigIsmFactory__artifact, -} from '@hyperlane-xyz/core/artifacts'; // Any name changes here should also be reflected in the example artifacts. // E.g. typescript/cli/examples/contract-artifacts.yaml @@ -35,29 +25,9 @@ export const proxyFactoryFactories = { }; export type ProxyFactoryFactories = typeof proxyFactoryFactories; -export type ProxyFactoryFactoriesArtifacts = - typeof proxyFactoryFactoriesArtifacts; type ProxyFactoryImplementations = Record; -export const proxyFactoryFactoriesArtifacts: Record< - keyof ProxyFactoryFactories | string, - any -> = { - staticMerkleRootMultisigIsmFactory: - StaticMerkleRootMultisigIsmFactory__artifact, - staticMessageIdMultisigIsmFactory: - StaticMessageIdMultisigIsmFactory__artifact, - staticAggregationIsmFactory: StaticAggregationIsmFactory__artifact, - staticAggregationHookFactory: StaticAggregationHookFactory__artifact, - domainRoutingIsmFactory: DomainRoutingIsmFactory__artifact, - staticMerkleRootWeightedMultisigIsmFactory: - StaticMerkleRootWeightedMultisigIsmFactory__artifact, - staticMessageIdWeightedMultisigIsmFactory: - StaticMessageIdWeightedMultisigIsmFactory__artifact, - proxyAdmin: ProxyAdmin__artifact, -} as const; - // must match contract names for verification export const proxyFactoryImplementations: ProxyFactoryImplementations = { staticMerkleRootMultisigIsmFactory: 'StaticMerkleRootMultisigIsm', diff --git a/typescript/sdk/src/gas/contracts.ts b/typescript/sdk/src/gas/contracts.ts index 210197d74..0dfe6d8f6 100644 --- a/typescript/sdk/src/gas/contracts.ts +++ b/typescript/sdk/src/gas/contracts.ts @@ -3,21 +3,11 @@ import { ProxyAdmin__factory, StorageGasOracle__factory, } from '@hyperlane-xyz/core'; -import { - InterchainGasPaymaster__artifact, - ProxyAdmin__artifact, - StorageGasOracle__artifact, -} from '@hyperlane-xyz/core/artifacts'; export const igpFactories = { interchainGasPaymaster: new InterchainGasPaymaster__factory(), storageGasOracle: new StorageGasOracle__factory(), proxyAdmin: new ProxyAdmin__factory(), }; -export const igpFactoriesArtifacts = { - interchainGasPaymaster: InterchainGasPaymaster__artifact, - storageGasOracle: StorageGasOracle__artifact, - proxyAdmin: ProxyAdmin__artifact, -}; export type IgpFactories = typeof igpFactories; diff --git a/typescript/sdk/src/hook/EvmHookModule.hardhat-test.ts b/typescript/sdk/src/hook/EvmHookModule.hardhat-test.ts index 3fd7ccb2a..82abd5b44 100644 --- a/typescript/sdk/src/hook/EvmHookModule.hardhat-test.ts +++ b/typescript/sdk/src/hook/EvmHookModule.hardhat-test.ts @@ -170,7 +170,7 @@ function randomHookConfig( } describe('EvmHookModule', async () => { - const chain = TestChainName.test1; + const chain = TestChainName.test4; let multiProvider: MultiProvider; let coreAddresses: CoreAddresses; @@ -687,15 +687,15 @@ describe('EvmHookModule', async () => { ); // add multiple new domains - exampleRoutingConfig.domains[TestChainName.test1] = { + exampleRoutingConfig.domains[TestChainName.test2] = { + type: HookType.MERKLE_TREE, + }; + exampleRoutingConfig.domains[TestChainName.test3] = { + type: HookType.MERKLE_TREE, + }; + exampleRoutingConfig.domains[TestChainName.test4] = { type: HookType.MERKLE_TREE, }; - // exampleRoutingConfig.domains[TestChainName.test3] = { - // type: HookType.MERKLE_TREE, - // }; - // exampleRoutingConfig.domains[TestChainName.test4] = { - // type: HookType.MERKLE_TREE, - // }; // expect 1 tx to update the domains await expectTxsAndUpdate(hook, exampleRoutingConfig, 1); diff --git a/typescript/sdk/src/hook/EvmHookModule.ts b/typescript/sdk/src/hook/EvmHookModule.ts index 2394152f3..ef8185140 100644 --- a/typescript/sdk/src/hook/EvmHookModule.ts +++ b/typescript/sdk/src/hook/EvmHookModule.ts @@ -44,11 +44,7 @@ import { CoreAddresses } from '../core/contracts.js'; import { EvmModuleDeployer } from '../deploy/EvmModuleDeployer.js'; import { ProxyFactoryFactories } from '../deploy/contracts.js'; import { ContractVerifier } from '../deploy/verify/ContractVerifier.js'; -import { - IgpFactories, - igpFactories, - igpFactoriesArtifacts, -} from '../gas/contracts.js'; +import { IgpFactories, igpFactories } from '../gas/contracts.js'; import { IgpConfig } from '../gas/types.js'; import { EvmIsmModule } from '../ism/EvmIsmModule.js'; import { ArbL2ToL1IsmConfig, IsmType, OpStackIsmConfig } from '../ism/types.js'; @@ -57,12 +53,7 @@ import { AnnotatedEV5Transaction } from '../providers/ProviderType.js'; import { ChainNameOrId } from '../types.js'; import { EvmHookReader } from './EvmHookReader.js'; -import { - DeployedHook, - HookFactories, - hookFactories, - hookFactoriesArtifacts, -} from './contracts.js'; +import { DeployedHook, HookFactories, hookFactories } from './contracts.js'; import { HookConfigSchema } from './schemas.js'; import { AggregationHookConfig, @@ -120,10 +111,6 @@ export class EvmHookModule extends HyperlaneModule< ...hookFactories, ...igpFactories, }, - { - ...hookFactoriesArtifacts, - ...igpFactoriesArtifacts, - }, this.logger, contractVerifier, ); diff --git a/typescript/sdk/src/hook/HyperlaneHookDeployer.ts b/typescript/sdk/src/hook/HyperlaneHookDeployer.ts index b98a89d08..5bbc30fe7 100644 --- a/typescript/sdk/src/hook/HyperlaneHookDeployer.ts +++ b/typescript/sdk/src/hook/HyperlaneHookDeployer.ts @@ -27,12 +27,7 @@ import { IsmType, OpStackIsmConfig } from '../ism/types.js'; import { MultiProvider } from '../providers/MultiProvider.js'; import { ChainMap, ChainName } from '../types.js'; -import { - DeployedHook, - HookFactories, - hookFactories, - hookFactoriesArtifacts, -} from './contracts.js'; +import { DeployedHook, HookFactories, hookFactories } from './contracts.js'; import { AggregationHookConfig, DomainRoutingHookConfig, @@ -60,7 +55,7 @@ export class HyperlaneHookDeployer extends HyperlaneDeployer< concurrentDeploy, ), ) { - super(multiProvider, hookFactories, hookFactoriesArtifacts, { + super(multiProvider, hookFactories, { logger: rootLogger.child({ module: 'HookDeployer' }), contractVerifier, concurrentDeploy, diff --git a/typescript/sdk/src/hook/contracts.ts b/typescript/sdk/src/hook/contracts.ts index 3743c96dc..4d9f51b86 100644 --- a/typescript/sdk/src/hook/contracts.ts +++ b/typescript/sdk/src/hook/contracts.ts @@ -9,17 +9,6 @@ import { ProtocolFee__factory, StaticAggregationHook__factory, } from '@hyperlane-xyz/core'; -import { - ArbL2ToL1Hook__artifact, - DomainRoutingHook__artifact, - FallbackDomainRoutingHook__artifact, - InterchainGasPaymaster__artifact, - MerkleTreeHook__artifact, - OPStackHook__artifact, - PausableHook__artifact, - ProtocolFee__artifact, - StaticAggregationHook__artifact, -} from '@hyperlane-xyz/core/artifacts'; import { ValueOf } from '@hyperlane-xyz/utils'; import { HookType } from './types.js'; @@ -35,17 +24,6 @@ export const hookFactories = { [HookType.PAUSABLE]: new PausableHook__factory(), [HookType.ARB_L2_TO_L1]: new ArbL2ToL1Hook__factory(), }; -export const hookFactoriesArtifacts = { - [HookType.MERKLE_TREE]: MerkleTreeHook__artifact, - [HookType.PROTOCOL_FEE]: ProtocolFee__artifact, - [HookType.INTERCHAIN_GAS_PAYMASTER]: InterchainGasPaymaster__artifact, // unused - [HookType.AGGREGATION]: StaticAggregationHook__artifact, // unused - [HookType.OP_STACK]: OPStackHook__artifact, - [HookType.ROUTING]: DomainRoutingHook__artifact, - [HookType.FALLBACK_ROUTING]: FallbackDomainRoutingHook__artifact, - [HookType.PAUSABLE]: PausableHook__artifact, - [HookType.ARB_L2_TO_L1]: ArbL2ToL1Hook__artifact, -}; export type HookFactories = typeof hookFactories; diff --git a/typescript/sdk/src/ism/EvmIsmModule.hardhat-test.ts b/typescript/sdk/src/ism/EvmIsmModule.hardhat-test.ts index e98426f5e..3c079d138 100644 --- a/typescript/sdk/src/ism/EvmIsmModule.hardhat-test.ts +++ b/typescript/sdk/src/ism/EvmIsmModule.hardhat-test.ts @@ -94,7 +94,7 @@ describe('EvmIsmModule', async () => { let mailboxAddress: Address; let fundingAccount: Signer; - const chain = TestChainName.test1; + const chain = TestChainName.test4; let factoryAddresses: HyperlaneAddresses; let factoryContracts: HyperlaneContracts; @@ -132,7 +132,7 @@ describe('EvmIsmModule', async () => { owner: (await multiProvider.getSignerAddress(chain)).toLowerCase(), domains: Object.fromEntries( testChains - .filter((c) => c !== TestChainName.test1) + .filter((c) => c !== TestChainName.test4) .map((c) => [c, randomMultisigIsmConfig(3, 5)]), ), }; diff --git a/typescript/sdk/src/ism/EvmIsmModule.ts b/typescript/sdk/src/ism/EvmIsmModule.ts index 5bbf52721..7dea1ca39 100644 --- a/typescript/sdk/src/ism/EvmIsmModule.ts +++ b/typescript/sdk/src/ism/EvmIsmModule.ts @@ -22,7 +22,6 @@ import { TrustedRelayerIsm__factory, } from '@hyperlane-xyz/core'; import { DefaultFallbackRoutingIsm__artifact } from '@hyperlane-xyz/core/artifacts'; -// import { TrustedRelayerIsm__artifact } from '@hyperlane-xyz/core/artifacts'; import { Address, Domain, @@ -102,7 +101,6 @@ export class EvmIsmModule extends HyperlaneModule< this.deployer = new EvmModuleDeployer( this.multiProvider, {}, - {}, this.logger, contractVerifier, ); @@ -656,7 +654,6 @@ export class EvmIsmModule extends HyperlaneModule< (domain, _): _ is IsmConfig => { const domainId = this.multiProvider.tryGetDomainId(domain); if (domainId === null) { - console.log('inside filterRoutingIsmDomains'); this.logger.warn( `Domain ${domain} doesn't have chain metadata provided, skipping ...`, ); diff --git a/typescript/sdk/src/metadata/ChainMetadataManager.ts b/typescript/sdk/src/metadata/ChainMetadataManager.ts index d22b38977..3a3d02745 100644 --- a/typescript/sdk/src/metadata/ChainMetadataManager.ts +++ b/typescript/sdk/src/metadata/ChainMetadataManager.ts @@ -61,21 +61,21 @@ export class ChainMetadataManager { addChain(metadata: ChainMetadata): void { ChainMetadataSchema.parse(metadata); // Ensure no two chains have overlapping names/domainIds/chainIds - // for (const chainMetadata of Object.values(this.metadata)) { - // const { name, chainId, domainId } = chainMetadata; - // if (name == metadata.name) - // throw new Error(`Duplicate chain name: ${name}`); - // Chain and Domain Ids should be globally unique - // const idCollision = - // chainId == metadata.chainId || - // domainId == metadata.chainId || - // (metadata.domainId && - // (chainId == metadata.domainId || domainId == metadata.domainId)); - // if (idCollision) - // throw new Error( - // `Chain/Domain id collision: ${name} and ${metadata.name}`, - // ); - // } + for (const chainMetadata of Object.values(this.metadata)) { + const { name, chainId, domainId } = chainMetadata; + if (name == metadata.name) + throw new Error(`Duplicate chain name: ${name}`); + // Chain and Domain Ids should be globally unique + const idCollision = + chainId == metadata.chainId || + domainId == metadata.chainId || + (metadata.domainId && + (chainId == metadata.domainId || domainId == metadata.domainId)); + if (idCollision) + throw new Error( + `Chain/Domain id collision: ${name} and ${metadata.name}`, + ); + } this.metadata[metadata.name] = metadata; } @@ -439,9 +439,9 @@ export class ChainMetadataManager { } if (!intersection.length) { - // throw new Error( - // `No chains shared between known chains and list (${knownChains} and ${chains})`, - // ); + throw new Error( + `No chains shared between known chains and list (${knownChains} and ${chains})`, + ); } const intersectionMetadata = pick(this.metadata, intersection); diff --git a/typescript/sdk/src/middleware/account/InterchainAccountDeployer.ts b/typescript/sdk/src/middleware/account/InterchainAccountDeployer.ts index c4d68f244..b7f0480cf 100644 --- a/typescript/sdk/src/middleware/account/InterchainAccountDeployer.ts +++ b/typescript/sdk/src/middleware/account/InterchainAccountDeployer.ts @@ -13,7 +13,6 @@ import { ChainName } from '../../types.js'; import { InterchainAccountFactories, interchainAccountFactories, - interchainAccountFactoriesArtifacts, } from './contracts.js'; export type InterchainAccountConfig = ProxiedRouterConfig; @@ -27,15 +26,10 @@ export class InterchainAccountDeployer extends ProxiedRouterDeployer< contractVerifier?: ContractVerifier, concurrentDeploy?: boolean, ) { - super( - multiProvider, - interchainAccountFactories, - interchainAccountFactoriesArtifacts, - { - contractVerifier, - concurrentDeploy, - }, - ); + super(multiProvider, interchainAccountFactories, { + contractVerifier, + concurrentDeploy, + }); } routerContractName(): string { return 'interchainAccountRouter'; diff --git a/typescript/sdk/src/middleware/account/accounts.hardhat-test.ts b/typescript/sdk/src/middleware/account/accounts.hardhat-test.ts index 5af3c92bd..78cb86fbd 100644 --- a/typescript/sdk/src/middleware/account/accounts.hardhat-test.ts +++ b/typescript/sdk/src/middleware/account/accounts.hardhat-test.ts @@ -1,6 +1,7 @@ +import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers.js'; import { expect } from 'chai'; import { constants } from 'ethers'; -import { Provider, Wallet } from 'zksync-ethers'; +import hre from 'hardhat'; import { InterchainAccountRouter, @@ -27,7 +28,7 @@ describe('InterchainAccounts', async () => { const localChain = TestChainName.test1; const remoteChain = TestChainName.test2; - let signer: Wallet; + let signer: SignerWithAddress; let contracts: HyperlaneContractsMap; let local: InterchainAccountRouter; let remote: InterchainAccountRouter; @@ -37,12 +38,7 @@ describe('InterchainAccounts', async () => { let config: ChainMap; before(async () => { - const prov = new Provider('http://127.0.0.1:8011', 260); - - signer = new Wallet( - '0x3d3cbc973389cb26f657686445bcc75662b415b656078503592ac8c1abb8810e', - prov, - ); + [signer] = await hre.ethers.getSigners(); multiProvider = MultiProvider.createTestMultiProvider({ signer }); const ismFactoryDeployer = new HyperlaneProxyFactoryDeployer(multiProvider); const ismFactory = new HyperlaneIsmFactory( diff --git a/typescript/sdk/src/middleware/account/contracts.ts b/typescript/sdk/src/middleware/account/contracts.ts index 1d6303349..7aaa16ad7 100644 --- a/typescript/sdk/src/middleware/account/contracts.ts +++ b/typescript/sdk/src/middleware/account/contracts.ts @@ -2,25 +2,13 @@ import { InterchainAccountIsm__factory, InterchainAccountRouter__factory, } from '@hyperlane-xyz/core'; -import { - InterchainAccountIsm__artifact, - InterchainAccountRouter__artifact, -} from '@hyperlane-xyz/core/artifacts'; -import { - proxiedFactories, - proxiedFactoriesArtifacts, -} from '../../router/types.js'; +import { proxiedFactories } from '../../router/types.js'; export const interchainAccountFactories = { interchainAccountRouter: new InterchainAccountRouter__factory(), interchainAccountIsm: new InterchainAccountIsm__factory(), ...proxiedFactories, }; -export const interchainAccountFactoriesArtifacts = { - interchainAccountRouter: InterchainAccountRouter__artifact, - interchainAccountIsm: InterchainAccountIsm__artifact, - ...proxiedFactoriesArtifacts, -}; export type InterchainAccountFactories = typeof interchainAccountFactories; diff --git a/typescript/sdk/src/middleware/liquidity-layer/LiquidityLayerRouterDeployer.ts b/typescript/sdk/src/middleware/liquidity-layer/LiquidityLayerRouterDeployer.ts index 974119669..ba1733dbd 100644 --- a/typescript/sdk/src/middleware/liquidity-layer/LiquidityLayerRouterDeployer.ts +++ b/typescript/sdk/src/middleware/liquidity-layer/LiquidityLayerRouterDeployer.ts @@ -21,7 +21,6 @@ import { ChainMap, ChainName } from '../../types.js'; import { LiquidityLayerFactories, liquidityLayerFactories, - liquidityLayerFactoriesArtifacts, } from './contracts.js'; export enum BridgeAdapterType { @@ -65,15 +64,10 @@ export class LiquidityLayerDeployer extends ProxiedRouterDeployer< contractVerifier?: ContractVerifier, concurrentDeploy = false, ) { - super( - multiProvider, - liquidityLayerFactories, - liquidityLayerFactoriesArtifacts, - { - contractVerifier, - concurrentDeploy, - }, - ); + super(multiProvider, liquidityLayerFactories, { + contractVerifier, + concurrentDeploy, + }); } routerContractName(): string { diff --git a/typescript/sdk/src/middleware/liquidity-layer/contracts.ts b/typescript/sdk/src/middleware/liquidity-layer/contracts.ts index 37d4f40bb..ef88008b9 100644 --- a/typescript/sdk/src/middleware/liquidity-layer/contracts.ts +++ b/typescript/sdk/src/middleware/liquidity-layer/contracts.ts @@ -3,16 +3,8 @@ import { LiquidityLayerRouter__factory, PortalAdapter__factory, } from '@hyperlane-xyz/core'; -import { - CircleBridgeAdapter__artifact, - LiquidityLayerRouter__artifact, - PortalAdapter__artifact, -} from '@hyperlane-xyz/core/artifacts'; -import { - proxiedFactories, - proxiedFactoriesArtifacts, -} from '../../router/types.js'; +import { proxiedFactories } from '../../router/types.js'; export const liquidityLayerFactories = { circleBridgeAdapter: new CircleBridgeAdapter__factory(), @@ -20,11 +12,5 @@ export const liquidityLayerFactories = { liquidityLayerRouter: new LiquidityLayerRouter__factory(), ...proxiedFactories, }; -export const liquidityLayerFactoriesArtifacts = { - circleBridgeAdapter: CircleBridgeAdapter__artifact, - portalAdapter: PortalAdapter__artifact, - liquidityLayerRouter: LiquidityLayerRouter__artifact, - ...proxiedFactoriesArtifacts, -}; export type LiquidityLayerFactories = typeof liquidityLayerFactories; diff --git a/typescript/sdk/src/providers/SmartProvider/SmartProvider.foundry-test.ts b/typescript/sdk/src/providers/SmartProvider/SmartProvider.foundry-test.ts index 8fbb76d08..d0470de81 100644 --- a/typescript/sdk/src/providers/SmartProvider/SmartProvider.foundry-test.ts +++ b/typescript/sdk/src/providers/SmartProvider/SmartProvider.foundry-test.ts @@ -12,7 +12,7 @@ import { const PK = '0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80'; const NETWORK = 31337; -const URL = 'http://127.0.0.1:8011'; +const URL = 'http://127.0.0.1:8545'; describe('SmartProvider', async () => { let signer: Wallet; diff --git a/typescript/sdk/src/providers/transactions/submitter/ethersV5/EV5ImpersonatedAccountTxSubmitter.ts b/typescript/sdk/src/providers/transactions/submitter/ethersV5/EV5ImpersonatedAccountTxSubmitter.ts index 38a26ac1f..9a6866e35 100644 --- a/typescript/sdk/src/providers/transactions/submitter/ethersV5/EV5ImpersonatedAccountTxSubmitter.ts +++ b/typescript/sdk/src/providers/transactions/submitter/ethersV5/EV5ImpersonatedAccountTxSubmitter.ts @@ -3,7 +3,10 @@ import { Logger } from 'pino'; import { rootLogger } from '@hyperlane-xyz/utils'; -import { stopImpersonatingAccount } from '../../../../utils/fork.js'; +import { + impersonateAccount, + stopImpersonatingAccount, +} from '../../../../utils/fork.js'; import { MultiProvider } from '../../../MultiProvider.js'; import { PopulatedTransactions } from '../../types.js'; import { TxSubmitterType } from '../TxSubmitterTypes.js'; @@ -29,10 +32,10 @@ export class EV5ImpersonatedAccountTxSubmitter extends EV5JsonRpcTxSubmitter { public async submit( ...txs: PopulatedTransactions ): Promise { - // const impersonatedAccount = await impersonateAccount( - // this.props.userAddress, - // ); - // this.multiProvider.setSharedSigner(impersonatedAccount); + const impersonatedAccount = await impersonateAccount( + this.props.userAddress, + ); + this.multiProvider.setSharedSigner(impersonatedAccount); const transactionReceipts = await super.submit(...txs); await stopImpersonatingAccount(this.props.userAddress); return transactionReceipts; diff --git a/typescript/sdk/src/router/ProxiedRouterDeployer.ts b/typescript/sdk/src/router/ProxiedRouterDeployer.ts index 23bc94c67..8f4d03d2f 100644 --- a/typescript/sdk/src/router/ProxiedRouterDeployer.ts +++ b/typescript/sdk/src/router/ProxiedRouterDeployer.ts @@ -26,7 +26,6 @@ export abstract class ProxiedRouterDeployer< constructor( multiProvider: MultiProvider, factories: Factories, - artifacts: any, options?: DeployerOptions, ) { super( @@ -35,7 +34,6 @@ export abstract class ProxiedRouterDeployer< ...factories, ...proxiedFactories, }, - artifacts, options, ); } diff --git a/typescript/sdk/src/router/types.ts b/typescript/sdk/src/router/types.ts index 8ca23a403..2b0c81de5 100644 --- a/typescript/sdk/src/router/types.ts +++ b/typescript/sdk/src/router/types.ts @@ -6,10 +6,6 @@ import { Router, TimelockController__factory, } from '@hyperlane-xyz/core'; -import { - ProxyAdmin__artifact, - TimelockController__artifact, -} from '@hyperlane-xyz/core/artifacts'; import { Address, AddressBytes32 } from '@hyperlane-xyz/utils'; import { HyperlaneFactories } from '../contracts/types.js'; @@ -42,10 +38,6 @@ export const proxiedFactories: ProxiedFactories = { proxyAdmin: new ProxyAdmin__factory(), timelockController: new TimelockController__factory(), }; -export const proxiedFactoriesArtifacts = { - proxyAdmin: ProxyAdmin__artifact, - timelockController: TimelockController__artifact, -}; export enum ClientViolationType { InterchainSecurityModule = 'ClientIsm', diff --git a/typescript/sdk/src/token/EvmERC20WarpModule.hardhat-test.ts b/typescript/sdk/src/token/EvmERC20WarpModule.hardhat-test.ts index 5084581b0..82a8e77a4 100644 --- a/typescript/sdk/src/token/EvmERC20WarpModule.hardhat-test.ts +++ b/typescript/sdk/src/token/EvmERC20WarpModule.hardhat-test.ts @@ -1,8 +1,12 @@ +import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers.js'; import { expect } from 'chai'; import { constants } from 'ethers'; -import { Provider, Wallet } from 'zksync-ethers'; +import hre from 'hardhat'; import { + ERC20Test, + ERC20Test__factory, + ERC4626Test__factory, GasRouter, HypERC20__factory, HypERC4626Collateral__factory, @@ -10,10 +14,6 @@ import { Mailbox, Mailbox__factory, } from '@hyperlane-xyz/core'; -import { - ERC20Test__artifact, - ERC4626Test__artifact, -} from '@hyperlane-xyz/core/artifacts'; import { EvmIsmModule, HyperlaneAddresses, @@ -36,7 +36,6 @@ import { AnnotatedEV5Transaction } from '../providers/ProviderType.js'; import { RemoteRouters } from '../router/types.js'; import { randomAddress } from '../test/testUtils.js'; import { ChainMap } from '../types.js'; -import { ZKDeployer } from '../zksync/ZKDeployer.js'; import { EvmERC20WarpModule } from './EvmERC20WarpModule.js'; import { TokenType } from './config.js'; @@ -54,25 +53,20 @@ describe('EvmERC20WarpHyperlaneModule', async () => { const TOKEN_NAME = 'fake'; const TOKEN_SUPPLY = '100000000000000000000'; const TOKEN_DECIMALS = 18; - const chain = TestChainName.test1; + const chain = TestChainName.test4; let mailbox: Mailbox; let hookAddress: string; let ismAddress: string; let ismFactory: HyperlaneIsmFactory; let factories: HyperlaneContractsMap; let ismFactoryAddresses: HyperlaneAddresses; - let token: any; - let signer: Wallet; + let erc20Factory: ERC20Test__factory; + let token: ERC20Test; + let signer: SignerWithAddress; let multiProvider: MultiProvider; let coreApp: TestCoreApp; let routerConfigMap: ChainMap; let baseConfig: RouterConfig; - const prov = new Provider('http://127.0.0.1:8011', 260); - - signer = new Wallet( - '0x3d3cbc973389cb26f657686445bcc75662b415b656078503592ac8c1abb8810e', - prov, - ); async function validateCoreValues(deployedToken: GasRouter) { expect(await deployedToken.mailbox()).to.equal(mailbox.address); @@ -90,30 +84,24 @@ describe('EvmERC20WarpHyperlaneModule', async () => { } before(async () => { + [signer] = await hre.ethers.getSigners(); multiProvider = MultiProvider.createTestMultiProvider({ signer }); - const ismFactoryDeployer = new HyperlaneProxyFactoryDeployer(multiProvider); - factories = await ismFactoryDeployer.deploy( multiProvider.mapKnownChains(() => ({})), ); - ismFactoryAddresses = serializeContracts(factories[chain]); - ismFactory = new HyperlaneIsmFactory(factories, multiProvider); - coreApp = await new TestCoreDeployer(multiProvider, ismFactory).deployApp(); - routerConfigMap = coreApp.getRouterConfig(signer.address); - const deployer = new ZKDeployer(signer); - - token = await deployer.deploy(ERC20Test__artifact, [ + erc20Factory = new ERC20Test__factory(signer); + token = await erc20Factory.deploy( TOKEN_NAME, TOKEN_NAME, TOKEN_SUPPLY, TOKEN_DECIMALS, - ]); + ); baseConfig = routerConfigMap[chain]; @@ -129,6 +117,7 @@ describe('EvmERC20WarpHyperlaneModule', async () => { token: token.address, hook: hookAddress, }; + // Deploy using WarpModule const evmERC20WarpModule = await EvmERC20WarpModule.create({ chain, @@ -144,14 +133,12 @@ describe('EvmERC20WarpHyperlaneModule', async () => { }); it('should create with a collateral vault config', async () => { - const deployer = new ZKDeployer(signer); - - const vault = await deployer.deploy(ERC4626Test__artifact, [ + const vaultFactory = new ERC4626Test__factory(signer); + const vault = await vaultFactory.deploy( token.address, TOKEN_NAME, TOKEN_NAME, - ]); - + ); const config = { type: TokenType.collateralVault, token: vault.address, @@ -358,7 +345,7 @@ describe('EvmERC20WarpHyperlaneModule', async () => { expect(txs.length).to.equal(0); }); - it.skip('should update a mutable Ism', async () => { + it('should update a mutable Ism', async () => { const ismConfig: IsmConfig = { type: IsmType.ROUTING, owner: signer.address, @@ -366,8 +353,6 @@ describe('EvmERC20WarpHyperlaneModule', async () => { '1': ismAddress, }, }; - console.log('before EvmIsmModule'); - const ism = await EvmIsmModule.create({ chain, multiProvider, @@ -376,10 +361,7 @@ describe('EvmERC20WarpHyperlaneModule', async () => { mailbox: mailbox.address, }); - console.log({ ism }); const { deployedIsm } = ism.serialize(); - console.log('deployedIsm'); - // Deploy using WarpModule const config = { ...baseConfig, diff --git a/typescript/sdk/src/token/EvmERC20WarpRouteReader.hardhat-test.ts b/typescript/sdk/src/token/EvmERC20WarpRouteReader.hardhat-test.ts index 914a43011..d5f7a6ee1 100644 --- a/typescript/sdk/src/token/EvmERC20WarpRouteReader.hardhat-test.ts +++ b/typescript/sdk/src/token/EvmERC20WarpRouteReader.hardhat-test.ts @@ -1,11 +1,15 @@ +import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers.js'; import { expect } from 'chai'; -import { Contract, Provider, Wallet } from 'zksync-ethers'; +import hre from 'hardhat'; -import { Mailbox, Mailbox__factory } from '@hyperlane-xyz/core'; import { - ERC20Test__artifact, - ERC4626Test__artifact, -} from '@hyperlane-xyz/core/artifacts'; + ERC20Test, + ERC20Test__factory, + ERC4626, + ERC4626Test__factory, + Mailbox, + Mailbox__factory, +} from '@hyperlane-xyz/core'; import { HyperlaneContractsMap, RouterConfig, @@ -21,7 +25,6 @@ import { ProxyFactoryFactories } from '../deploy/contracts.js'; import { HyperlaneIsmFactory } from '../ism/HyperlaneIsmFactory.js'; import { MultiProvider } from '../providers/MultiProvider.js'; import { ChainMap } from '../types.js'; -import { ZKDeployer } from '../zksync/ZKDeployer.js'; import { EvmERC20WarpRouteReader } from './EvmERC20WarpRouteReader.js'; import { TokenType } from './config.js'; @@ -35,60 +38,43 @@ describe('ERC20WarpRouterReader', async () => { const chain = TestChainName.test4; let ismFactory: HyperlaneIsmFactory; let factories: HyperlaneContractsMap; - // let erc20Factory: ERC20Test__factory; - let token: Contract; - let signer: Wallet; + let erc20Factory: ERC20Test__factory; + let token: ERC20Test; + let signer: SignerWithAddress; let deployer: HypERC20Deployer; - let zkDeployer: any; let multiProvider: MultiProvider; let coreApp: TestCoreApp; let routerConfigMap: ChainMap; let baseConfig: RouterConfig; let mailbox: Mailbox; let evmERC20WarpRouteReader: EvmERC20WarpRouteReader; - let vault: Contract; - + let vault: ERC4626; beforeEach(async () => { - const prov = new Provider('http://127.0.0.1:8011', 260); - - signer = new Wallet( - '0x3d3cbc973389cb26f657686445bcc75662b415b656078503592ac8c1abb8810e', - prov, - ); - - zkDeployer = new ZKDeployer(signer); - multiProvider = MultiProvider.createTestMultiProvider({ - signer, - }); - deployer = new HypERC20Deployer(multiProvider); - + [signer] = await hre.ethers.getSigners(); + multiProvider = MultiProvider.createTestMultiProvider({ signer }); const ismFactoryDeployer = new HyperlaneProxyFactoryDeployer(multiProvider); factories = await ismFactoryDeployer.deploy( multiProvider.mapKnownChains(() => ({})), ); - ismFactory = new HyperlaneIsmFactory(factories, multiProvider); coreApp = await new TestCoreDeployer(multiProvider, ismFactory).deployApp(); - routerConfigMap = coreApp.getRouterConfig(signer.address); - token = await zkDeployer.deploy(ERC20Test__artifact, [ + erc20Factory = new ERC20Test__factory(signer); + token = await erc20Factory.deploy( TOKEN_NAME, TOKEN_NAME, TOKEN_SUPPLY, TOKEN_DECIMALS, - ]); + ); baseConfig = routerConfigMap[chain]; - mailbox = Mailbox__factory.connect(baseConfig.mailbox, signer); evmERC20WarpRouteReader = new EvmERC20WarpRouteReader(multiProvider, chain); + deployer = new HypERC20Deployer(multiProvider); - vault = await zkDeployer.deploy(ERC4626Test__artifact, [ - token.address, - TOKEN_NAME, - TOKEN_NAME, - ]); + const vaultFactory = new ERC4626Test__factory(signer); + vault = await vaultFactory.deploy(token.address, TOKEN_NAME, TOKEN_NAME); }); it('should derive a token type from contract', async () => { @@ -99,42 +85,43 @@ describe('ERC20WarpRouterReader', async () => { TokenType.native, ] as const; - typesToDerive.forEach(async (type) => { - const hook = await mailbox.defaultHook(); - const config = { - [chain]: { - type, - token: - type === TokenType.collateralVault ? vault.address : token.address, - hook: hook, - name: TOKEN_NAME, - symbol: TOKEN_NAME, - decimals: TOKEN_DECIMALS, - totalSupply: TOKEN_SUPPLY, - gas: GAS, - ...baseConfig, - }, - }; - - const warpRoute = await deployer.deploy(config); - - const derivedTokenType = await evmERC20WarpRouteReader.deriveTokenType( - warpRoute[chain][type].address, - ); - expect(derivedTokenType).to.equal(type); - }); + await Promise.all( + typesToDerive.map(async (type) => { + // Create config + const config = { + [chain]: { + type, + token: + type === TokenType.collateralVault + ? vault.address + : token.address, + hook: await mailbox.defaultHook(), + name: TOKEN_NAME, + symbol: TOKEN_NAME, + decimals: TOKEN_DECIMALS, + totalSupply: TOKEN_SUPPLY, + gas: GAS, + ...baseConfig, + }, + }; + // Deploy warp route with config + const warpRoute = await deployer.deploy(config); + const derivedTokenType = await evmERC20WarpRouteReader.deriveTokenType( + warpRoute[chain][type].address, + ); + expect(derivedTokenType).to.equal(type); + }), + ); }); it('should derive collateral config correctly', async () => { // Create config - const hook = await mailbox.defaultHook(); - const interchainsecurityModule = await mailbox.defaultIsm(); const config = { [chain]: { type: TokenType.collateral, token: token.address, - hook: hook, - interchainsecurityModule: interchainsecurityModule, + hook: await mailbox.defaultHook(), + interchainsecurityModule: await mailbox.defaultIsm(), ...baseConfig, }, }; diff --git a/typescript/sdk/src/token/contracts.ts b/typescript/sdk/src/token/contracts.ts index 12af2f21a..6ab8419b8 100644 --- a/typescript/sdk/src/token/contracts.ts +++ b/typescript/sdk/src/token/contracts.ts @@ -14,22 +14,6 @@ import { HypXERC20Lockbox__factory, HypXERC20__factory, } from '@hyperlane-xyz/core'; -import { - FastHypERC20Collateral__artifact, - FastHypERC20__artifact, - HypERC20Collateral__artifact, - HypERC20__artifact, - HypERC721Collateral__artifact, - HypERC721URICollateral__artifact, - HypERC721URIStorage__artifact, - HypERC721__artifact, - HypERC4626Collateral__artifact, - HypFiatToken__artifact, - HypNativeScaled__artifact, - HypNative__artifact, - HypXERC20Lockbox__artifact, - HypXERC20__artifact, -} from '@hyperlane-xyz/core/artifacts'; import { TokenType } from './config.js'; @@ -59,18 +43,6 @@ export const hypERC20factories = { [TokenType.native]: new HypNative__factory(), [TokenType.nativeScaled]: new HypNativeScaled__factory(), }; -export const hypERC20factoriesArtifacts: any = { - [TokenType.fastCollateral]: FastHypERC20Collateral__artifact, - [TokenType.fastSynthetic]: FastHypERC20__artifact, - [TokenType.synthetic]: HypERC20__artifact, - [TokenType.collateral]: HypERC20Collateral__artifact, - [TokenType.collateralVault]: HypERC4626Collateral__artifact, - [TokenType.collateralFiat]: HypFiatToken__artifact, - [TokenType.XERC20]: HypXERC20__artifact, - [TokenType.XERC20Lockbox]: HypXERC20Lockbox__artifact, - [TokenType.native]: HypNative__artifact, - [TokenType.nativeScaled]: HypNativeScaled__artifact, -}; export type HypERC20Factories = typeof hypERC20factories; @@ -89,12 +61,7 @@ export const hypERC721factories = { [TokenType.syntheticUri]: new HypERC721URIStorage__factory(), [TokenType.synthetic]: new HypERC721__factory(), }; -export const hypERC721factoriesArtifacts = { - [TokenType.collateralUri]: HypERC721URICollateral__artifact, - [TokenType.collateral]: HypERC721Collateral__artifact, - [TokenType.syntheticUri]: HypERC721URIStorage__artifact, - [TokenType.synthetic]: HypERC721__artifact, -}; + export type HypERC721Factories = typeof hypERC721factories; export type TokenFactories = HypERC20Factories | HypERC721Factories; diff --git a/typescript/sdk/src/token/deploy.hardhat-test.ts b/typescript/sdk/src/token/deploy.hardhat-test.ts index 3da97f9a9..772813943 100644 --- a/typescript/sdk/src/token/deploy.hardhat-test.ts +++ b/typescript/sdk/src/token/deploy.hardhat-test.ts @@ -1,7 +1,8 @@ +import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers.js'; import { expect } from 'chai'; -import { Wallet } from 'zksync-ethers'; +import hre from 'hardhat'; -import { ERC20Test__artifact } from '@hyperlane-xyz/core/artifacts'; +import { ERC20Test__factory } from '@hyperlane-xyz/core'; import { Address, objMap } from '@hyperlane-xyz/utils'; import { TestChainName } from '../consts/testChains.js'; @@ -10,7 +11,6 @@ import { TestCoreDeployer } from '../core/TestCoreDeployer.js'; import { HyperlaneProxyFactoryDeployer } from '../deploy/HyperlaneProxyFactoryDeployer.js'; import { HyperlaneIsmFactory } from '../ism/HyperlaneIsmFactory.js'; import { MultiProvider } from '../providers/MultiProvider.js'; -import { ZKDeployer } from '../zksync/ZKDeployer.js'; import { EvmERC20WarpRouteReader } from './EvmERC20WarpRouteReader.js'; import { TokenType } from './config.js'; @@ -21,7 +21,7 @@ import { WarpRouteDeployConfig } from './types.js'; const chain = TestChainName.test1; describe('TokenDeployer', async () => { - let signer: Wallet; + let signer: SignerWithAddress; let deployer: HypERC20Deployer; let multiProvider: MultiProvider; let coreApp: TestCoreApp; @@ -29,9 +29,7 @@ describe('TokenDeployer', async () => { let token: Address; before(async () => { - signer = new Wallet( - '0x3d3cbc973389cb26f657686445bcc75662b415b656078503592ac8c1abb8810e', - ); + [signer] = await hre.ethers.getSigners(); multiProvider = MultiProvider.createTestMultiProvider({ signer }); const ismFactoryDeployer = new HyperlaneProxyFactoryDeployer(multiProvider); const factories = await ismFactoryDeployer.deploy( @@ -53,16 +51,12 @@ describe('TokenDeployer', async () => { ); const { name, decimals, symbol, totalSupply } = config[chain]; - - const deployer = new ZKDeployer(signer); - - const contract = await deployer.deploy(ERC20Test__artifact, [ + const contract = await new ERC20Test__factory(signer).deploy( name!, symbol!, totalSupply!, decimals!, - ]); - + ); token = contract.address; }); diff --git a/typescript/sdk/src/token/deploy.ts b/typescript/sdk/src/token/deploy.ts index 916145319..c32e912e8 100644 --- a/typescript/sdk/src/token/deploy.ts +++ b/typescript/sdk/src/token/deploy.ts @@ -25,10 +25,8 @@ import { TokenFactories, hypERC20contracts, hypERC20factories, - hypERC20factoriesArtifacts, hypERC721contracts, hypERC721factories, - hypERC721factoriesArtifacts, } from './contracts.js'; import { TokenRouterConfig, @@ -45,13 +43,12 @@ abstract class TokenDeployer< constructor( multiProvider: MultiProvider, factories: Factories, - artifacts: any, loggerName: string, ismFactory?: HyperlaneIsmFactory, contractVerifier?: ContractVerifier, concurrentDeploy = false, ) { - super(multiProvider, factories, artifacts, { + super(multiProvider, factories, { logger: rootLogger.child({ module: loggerName }), ismFactory, contractVerifier, @@ -195,7 +192,6 @@ export class HypERC20Deployer extends TokenDeployer { super( multiProvider, hypERC20factories, - hypERC20factoriesArtifacts, 'HypERC20Deployer', ismFactory, contractVerifier, @@ -231,7 +227,6 @@ export class HypERC721Deployer extends TokenDeployer { super( multiProvider, hypERC721factories, - hypERC721factoriesArtifacts, 'HypERC721Deployer', ismFactory, contractVerifier, diff --git a/typescript/sdk/src/utils/fork.ts b/typescript/sdk/src/utils/fork.ts index 4bbca8e68..7215133ae 100644 --- a/typescript/sdk/src/utils/fork.ts +++ b/typescript/sdk/src/utils/fork.ts @@ -57,7 +57,7 @@ export const setFork = async ( }, ]); - // multiProvider.setProvider(chain, provider); + multiProvider.setProvider(chain, provider); rootLogger.info(`✅ Successfully forked ${chain} for dry-run`); }; diff --git a/typescript/sdk/src/zksync/ZKDeployer.ts b/typescript/sdk/src/zksync/ZKDeployer.ts index 8e5d2bfce..8d2c95aeb 100644 --- a/typescript/sdk/src/zksync/ZKDeployer.ts +++ b/typescript/sdk/src/zksync/ZKDeployer.ts @@ -1,7 +1,9 @@ import * as ethers from 'ethers'; import * as zk from 'zksync-ethers'; -import { evmArtifacts, zksyncArtifacts } from '@hyperlane-xyz/core/artifacts'; +import { zksyncArtifacts } from '@hyperlane-xyz/core/artifacts'; + +import { ZkSyncArtifact } from '../utils/zksync.js'; /** * An entity capable of deploying contracts to the zkSync network. @@ -23,40 +25,38 @@ export class ZKDeployer { } public loadArtifact(contractTitle: string): Promise { - const artifact = zksyncArtifacts.find(({ contractName, sourceName }) => { - if (contractName === contractTitle) { - return true; - } - - const qualifiedName = `${sourceName}:${contractName}`; - if (contractTitle === qualifiedName) { - return true; - } + const artifact = (zksyncArtifacts as ZkSyncArtifact[]).find( + ({ contractName, sourceName }) => { + if (contractName === contractTitle) { + return true; + } + + const qualifiedName = `${sourceName}:${contractName}`; + if (contractTitle === qualifiedName) { + return true; + } + + return false; + }, + ); - return false; - }); + if (!artifact) { + throw new Error( + `No ZKSync artifact for contract ${contractTitle} found!`, + ); + } return artifact as any; } public static loadArtifactByBytecode(bytecodeExt: string): Promise { - const artifact = zksyncArtifacts.find( + const artifact = (zksyncArtifacts as ZkSyncArtifact[]).find( ({ bytecode }) => bytecode === bytecodeExt, ); return artifact as any; } - public loadArtifactByEvmBytecode(bytecodeExt: string): Promise { - const evmArtifact = evmArtifacts.find( - ({ bytecode }) => bytecode === bytecodeExt, - ); - - const artifact = this.loadArtifact(evmArtifact.contractName); - - return artifact as any; - } - /** * Estimates the price of calling a deploy transaction in ETH. * diff --git a/yarn.lock b/yarn.lock index f9cccf292..909026f75 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5067,7 +5067,7 @@ __metadata: "@hyperlane-xyz/core@file:../../solidity::locator=%40hyperlane-xyz%2Fsdk%40workspace%3Atypescript%2Fsdk": version: 5.1.0 - resolution: "@hyperlane-xyz/core@file:../../solidity#../../solidity::hash=52f19a&locator=%40hyperlane-xyz%2Fsdk%40workspace%3Atypescript%2Fsdk" + resolution: "@hyperlane-xyz/core@file:../../solidity#../../solidity::hash=8ad3e4&locator=%40hyperlane-xyz%2Fsdk%40workspace%3Atypescript%2Fsdk" dependencies: "@arbitrum/nitro-contracts": "npm:^1.2.1" "@eth-optimism/contracts": "npm:^0.6.0" @@ -5081,7 +5081,7 @@ __metadata: "@ethersproject/abi": "*" "@ethersproject/providers": "*" "@types/sinon-chai": "*" - checksum: 26fbd298737af087b37175effe46c80edc73e8c2360e306993508abbe51e193239942c1c79d0756b7b4453b3a29a38efe6b439534f82e8f764494c59da7e9770 + checksum: 8491835dddc8eca474666ce60edd70985c3c94f7689a32f2d7afabfcaf1cce327faa909a63c413192f24cfc291792ce4c23ac4717f9d01059784748150e56a60 languageName: node linkType: hard