From 8383e95f71bbbd45d0d335472c961de52eb8882b Mon Sep 17 00:00:00 2001 From: ljankovic-txfusion Date: Tue, 15 Oct 2024 14:15:45 +0200 Subject: [PATCH] chore: reverted/added comments --- .../sdk/src/deploy/verify/ContractVerifier.ts | 11 ++++----- typescript/sdk/src/utils/zksync.ts | 24 ++++++++++++------- yarn.lock | 4 ++-- 3 files changed, 23 insertions(+), 16 deletions(-) diff --git a/typescript/sdk/src/deploy/verify/ContractVerifier.ts b/typescript/sdk/src/deploy/verify/ContractVerifier.ts index c28963e32..992d2de3b 100644 --- a/typescript/sdk/src/deploy/verify/ContractVerifier.ts +++ b/typescript/sdk/src/deploy/verify/ContractVerifier.ts @@ -37,13 +37,12 @@ export class ContractVerifier { const compilerversion = `v${buildArtifact.solcLongVersion}`; - // TODO: make it compatible with ZKSync compiler // double check compiler version matches expected format - // const versionRegex = /v(\d.\d.\d+)\+commit.\w+/; - // const matches = versionRegex.exec(compilerversion); - // if (!matches) { - // throw new Error(`Invalid compiler version ${compilerversion}`); - // } + const versionRegex = /v(\d.\d.\d+)\+commit.\w+/; + const matches = versionRegex.exec(compilerversion); + if (!matches) { + throw new Error(`Invalid compiler version ${compilerversion}`); + } // set compiler options // only license type is configurable, empty if not provided diff --git a/typescript/sdk/src/utils/zksync.ts b/typescript/sdk/src/utils/zksync.ts index 1875abe68..6d63efaed 100644 --- a/typescript/sdk/src/utils/zksync.ts +++ b/typescript/sdk/src/utils/zksync.ts @@ -3,25 +3,33 @@ import { loadAllZkArtifacts, } from '@hyperlane-xyz/core/artifacts'; +/** + * @dev Retrieves a ZkSync artifact by its contract name or qualified name. + * @param name The name of the contract or qualified name in the format "sourceName:contractName". + * @return The corresponding ZkSyncArtifact if found, or undefined if not found. + */ export const getZKArtifactByContractName = async ( name: string, ): Promise => { + // Load all ZkSync artifacts const allArtifacts = await loadAllZkArtifacts(); - const artifact = (Object.values(allArtifacts) as ZkSyncArtifact[]).find( + // Find the artifact that matches the contract name or qualified name + const artifact = Object.values(allArtifacts).find( ({ contractName, sourceName }) => { - if (contractName.toLowerCase() === name.toLowerCase()) { - return true; - } + const lowerCaseContractName = contractName.toLowerCase(); + const lowerCaseName = name.toLowerCase(); - const qualifiedName = `${sourceName}:${contractName}`; - if (name === qualifiedName) { + // Check if the contract name matches + if (lowerCaseContractName === lowerCaseName) { return true; } - return false; + // Check if the qualified name matches + const qualifiedName = `${sourceName}:${contractName}`; + return qualifiedName === name; // Return true if qualified name matches }, ); - return artifact as any; + return artifact; }; diff --git a/yarn.lock b/yarn.lock index 2938eb3e3..a693d2800 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7371,7 +7371,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=06cbd9&locator=%40hyperlane-xyz%2Fsdk%40workspace%3Atypescript%2Fsdk" + resolution: "@hyperlane-xyz/core@file:../../solidity#../../solidity::hash=ec11db&locator=%40hyperlane-xyz%2Fsdk%40workspace%3Atypescript%2Fsdk" dependencies: "@arbitrum/nitro-contracts": "npm:^1.2.1" "@eth-optimism/contracts": "npm:^0.6.0" @@ -7385,7 +7385,7 @@ __metadata: "@ethersproject/abi": "*" "@ethersproject/providers": "*" "@types/sinon-chai": "*" - checksum: 35d74457493971b0d55745c2d7ad4da2b707295385127d44463f78f3cca9600e586bc898797fb56136b29a6d96826b2e91c50e4660500ebd4796c1fee1c50ae9 + checksum: 3a73365a7269417ff9e21de55c57fb5705354c6be31a12f256d365ef58387503a8896e7b2d68dff8577cf525a9d7ea0b2cc128a5bf2b4ec2e4b966b0e2dc98dc languageName: node linkType: hard