pull/2166/head
yann300 3 years ago
parent 26b2bf8a8a
commit 178d448bbf
  1. 2
      libs/remix-core-plugin/src/lib/helpers/fetch-etherscan.ts

@ -10,7 +10,7 @@ export const fetchContractFromEtherscan = async (plugin, network, contractAddres
// etherscan api doc https://docs.etherscan.io/api-endpoints/contracts // etherscan api doc https://docs.etherscan.io/api-endpoints/contracts
if (data.message === 'OK' && data.status === "1") { if (data.message === 'OK' && data.status === "1") {
if (data.result.length) { if (data.result.length) {
if (data.result[0].SourceCode === '') throw new Error('contract not verified') if (data.result[0].SourceCode === '') throw new Error('contract not verified in Etherscan')
if (data.result[0].SourceCode.startsWith('{')) { if (data.result[0].SourceCode.startsWith('{')) {
data.result[0].SourceCode = JSON.parse(data.result[0].SourceCode.replace(/(?:\r\n|\r|\n)/g, '').replace(/^{{/,'{').replace(/}}$/,'}')) data.result[0].SourceCode = JSON.parse(data.result[0].SourceCode.replace(/(?:\r\n|\r|\n)/g, '').replace(/^{{/,'{').replace(/}}$/,'}'))
} }

Loading…
Cancel
Save