|
|
@ -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(/}}$/,'}')) |
|
|
|
} |
|
|
|
} |
|
|
|