UNPKG

@openzeppelin/hardhat-upgrades

Version:

[![Docs](https://img.shields.io/badge/docs-%F0%9F%93%84-blue)](https://docs.openzeppelin.com/upgrades-plugins/hardhat-upgrades) [![NPM Package](https://img.shields.io/npm/v/@openzeppelin/hardhat-upgrades.svg)](https://www.npmjs.org/package/@openzeppelin/h

37 lines • 1.68 kB
import { UpgradesError } from '@openzeppelin/upgrades-core'; import debug from './debug.js'; export const RESPONSE_OK = '1'; /** * Gets the Etherscan instance from the network connection (hardhat-verify v3.0.10+). * Requires @nomicfoundation/hardhat-verify to be loaded and the network to expose verification.etherscan. */ export async function getEtherscanFromConnection(hre) { const connection = await hre.network.getOrCreate(); const verification = connection.verification; if (!verification?.etherscan) { throw new UpgradesError('Etherscan verification is not available for this network.', () => 'Ensure @nomicfoundation/hardhat-verify v3.0.10+ is installed and that the network supports Etherscan (e.g. etherscan config in hardhat.config).'); } return verification.etherscan; } /** * Call the Etherscan API via hardhat-verify's customApiCall (adds apikey and chainid as needed). */ export async function callEtherscanApi(etherscan, params, options) { try { const response = await etherscan.customApiCall(params, options); debug('Etherscan response', JSON.stringify(response)); return response; } catch (e) { const message = e instanceof Error ? e.message : String(e); throw new UpgradesError(`Etherscan API call failed: ${message}`); } } /** * Submit contract for verification and poll for status using the Etherscan instance. */ export async function verifyAndGetStatus(params, etherscan) { const guid = await etherscan.verify(params); return etherscan.pollVerificationStatus(guid, params.contractAddress, params.contractName); } //# sourceMappingURL=etherscan-api.js.map