diff --git a/apps/etherscan/src/app/utils/scripts.ts b/apps/etherscan/src/app/utils/scripts.ts index 11998291d6..9a711dcd87 100644 --- a/apps/etherscan/src/app/utils/scripts.ts +++ b/apps/etherscan/src/app/utils/scripts.ts @@ -5,13 +5,13 @@ export const verifyScript = ` * @param {string} contractArguments - Parameters used in the contract constructor during the initial deployment. It should be the hex encoded value. * @param {string} contractName - Name of the contract * @param {string} contractFile - File where the contract is located -* @param {number | string} chainId - Network chain id +* @param {number | string} chainRef - Network chain id or API URL * @returns {{ guid, status, message, succeed }} verification result */ -export const verify = async (apikey: string, contractAddress: string, contractArguments: string, contractName: string, contractFile: string, chainId: number | string) => { +export const verify = async (apikey: string, contractAddress: string, contractArguments: string, contractName: string, contractFile: string, chainRef: number | string) => { const compilationResultParam = await remix.call('compilerArtefacts' as any, 'getCompilerAbstract', contractFile) console.log('verifying.. ' + contractName) - return await remix.call('etherscan' as any, 'verify', apikey, contractAddress, contractArguments, contractName, compilationResultParam, chainId) + return await remix.call('etherscan' as any, 'verify', apikey, contractAddress, contractArguments, contractName, compilationResultParam, chainRef) }` export const receiptGuidScript = ` diff --git a/apps/etherscan/src/app/utils/verify.ts b/apps/etherscan/src/app/utils/verify.ts index 3d8bd875ae..88732c0c9e 100644 --- a/apps/etherscan/src/app/utils/verify.ts +++ b/apps/etherscan/src/app/utils/verify.ts @@ -21,24 +21,31 @@ export const verify = async ( contractArgumentsParam: string, contractName: string, compilationResultParam: CompilerAbstract, - chainId: number | string, + chainRef: number | string, client: PluginClient, onVerifiedContract: (value: EtherScanReturn) => void, setResults: (value: string) => void ) => { let networkChainId - if (chainId) networkChainId = chainId - else { + let etherscanApi + if (chainRef) { + if (typeof chainRef === 'number') { + networkChainId = chainRef + etherscanApi = getEtherScanApi(networkChainId) + } else if (typeof chainRef === 'string') etherscanApi = chainRef + } else { const { network, networkId } = await getNetworkName(client) if (network === "vm") { return { succeed: false, message: "Cannot verify in the selected network" } - } else networkChainId = networkId + } else { + networkChainId = networkId + etherscanApi = getEtherScanApi(networkChainId) + } } - const etherscanApi = getEtherScanApi(networkChainId) try { const contractMetadata = getContractMetadata(