From 2c84dd0722d8dc2c87c3c9cf4b4037c7cbecffd8 Mon Sep 17 00:00:00 2001 From: ljankovic-txfusion Date: Mon, 27 Jan 2025 12:50:40 +0100 Subject: [PATCH] refactor(zksync): simplify artifact utility functions --- solidity/core-utils/zksync/utils.ts | 51 +++++------------------------ 1 file changed, 8 insertions(+), 43 deletions(-) diff --git a/solidity/core-utils/zksync/utils.ts b/solidity/core-utils/zksync/utils.ts index 780e7fda59..64be6859a1 100644 --- a/solidity/core-utils/zksync/utils.ts +++ b/solidity/core-utils/zksync/utils.ts @@ -1,58 +1,23 @@ import { zkSyncContractArtifacts } from './artifacts.js'; import { ZKSyncArtifact } from './types.js'; -type ArtifactMap = Record; - -/** - * @dev Exports the list of artifact names. - * @return An array of artifact names. - */ -export async function getZKSyncArtifactNames(): Promise { - return zkSyncContractArtifacts.map((artifact) => artifact.contractName); -} - -/** - * @dev Checks if a ZkSync artifact exists by its name. - * @param name The name of the artifact to check. - * @return True if the artifact exists, false otherwise. - */ -export async function artifactExists(name: string): Promise { - return zkSyncContractArtifacts.some( - (artifact) => artifact.contractName === name, - ); -} - /** - * @dev Loads a ZkSync artifact by its name. - * @param name The name of the artifact to load. + * @dev Get a ZkSync artifact by its name. + * @param name The name of the artifact to get. * @return The loaded ZKSyncArtifact or undefined if it cannot be found. */ -export async function loadZKSyncArtifact( +export function getZKSyncArtifactByName( name: string, -): Promise { +): ZKSyncArtifact | undefined { return zkSyncContractArtifacts.find( (artifact) => artifact.contractName === name, ); } /** - * @dev Loads all ZkSync artifacts into a map. - * @return A map of artifact names to their corresponding ZkSync artifacts. - */ -export async function loadAllZKSyncArtifacts(): Promise { - return zkSyncContractArtifacts.reduce((map, artifact) => { - map[artifact.contractName] = artifact; - return map; - }, {} as ArtifactMap); -} - -/** - * @dev Retrieves a specific ZkSync artifact by its name. - * @param name The name of the artifact to retrieve. - * @return The ZkSyncArtifact or undefined if it cannot be found. + * @dev Loads all ZkSync artifacts into an array. + * @return An array of ZkSync artifacts. */ -export async function getZKSyncArtifactByName( - name: string, -): Promise { - return loadZKSyncArtifact(name); +export function loadAllZKSyncArtifacts(): ZKSyncArtifact[] { + return zkSyncContractArtifacts; }