From f043fab70710a071aba34c1a89ebf5646b139cbd Mon Sep 17 00:00:00 2001 From: juliopavila Date: Wed, 28 Aug 2024 12:13:54 -0300 Subject: [PATCH] feat: add verification debounce --- package.json | 2 +- src/tooling/verifyMastercopy.ts | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 78b6f35..fa0baac 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@gnosis-guild/zodiac-core", - "version": "2.0.1", + "version": "2.0.2", "description": "Zodiac is a composable design philosophy and collection of standards for building DAO ecosystem tooling.", "author": "Auryn Macmillan ", "license": "LGPL-3.0+", diff --git a/src/tooling/verifyMastercopy.ts b/src/tooling/verifyMastercopy.ts index 89a9a43..490c1a9 100644 --- a/src/tooling/verifyMastercopy.ts +++ b/src/tooling/verifyMastercopy.ts @@ -1,11 +1,23 @@ import { MastercopyArtifact } from "../types"; import { verifySourceCode } from "../artifact/internal/etherscan"; +/** + * Pauses the execution for a specified amount of time. + * + * @param {number} ms - The number of milliseconds to wait. + * @returns {Promise} A promise that resolves after the specified delay. + */ +const sleep = (ms: number): Promise => { + return new Promise((resolve) => setTimeout(resolve, ms)); +}; + /** * Verifies a Mastercopy contract on an Etherscan-like block explorer. * * This function submits the source code and metadata of a Mastercopy contract to a block explorer - * for verification. It interacts with the explorer's API using the provided API key and endpoint. + * for verification. It interacts with the explorer's API + * using the provided API key and endpoint. A debounced timer of 500 milliseconds + * is added between each verification to prevent rate-limiting issues. * * @param {Object} params - The parameters required for verification. * @param {string} params.apiUrlOrChainId - The base URL of the block explorer's API or the chain ID. @@ -30,6 +42,8 @@ export default async function verifyMastercopy({ address: string; noop: boolean; }> { + await sleep(500); + const { noop } = await verifySourceCode({ ...artifact, apiUrlOrChainId,