|
|
|
@ -1,7 +1,7 @@ |
|
|
|
|
import {CompilerAbstract} from '@remix-project/remix-solidity' |
|
|
|
|
import {AbstractVerifier} from './AbstractVerifier' |
|
|
|
|
import {EtherscanReceipt} from '../Receipts/EtherscanReceipt' |
|
|
|
|
import {EtherscanResponse} from '../types/VerificationTypes' |
|
|
|
|
import {EtherscanRequest, EtherscanResponse} from '../types/VerificationTypes' |
|
|
|
|
|
|
|
|
|
export class EtherscanVerifier extends AbstractVerifier { |
|
|
|
|
apiKey: string |
|
|
|
@ -11,21 +11,25 @@ export class EtherscanVerifier extends AbstractVerifier { |
|
|
|
|
this.apiKey = apiKey |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
async verify(chainId: string, address: string, compilerAbstract: CompilerAbstract, selectedContractFileAndName: string) { |
|
|
|
|
async verify(chainId: string, address: string, compilerAbstract: CompilerAbstract, selectedContractFileAndName: string, abiEncodedConstructorArgs?: string) { |
|
|
|
|
const CODE_FORMAT = 'solidity-standard-json-input' |
|
|
|
|
|
|
|
|
|
const [_triggerFilePath, selectedFilePath, selectedContractName] = selectedContractFileAndName.split(':') |
|
|
|
|
// TODO: Handle version Vyper contracts. This relies on Solidity metadata.
|
|
|
|
|
const metadata = JSON.parse(compilerAbstract.data.contracts[selectedFilePath][selectedContractName].metadata) |
|
|
|
|
const body = { |
|
|
|
|
const body: EtherscanRequest = { |
|
|
|
|
chainId, |
|
|
|
|
codeformat: CODE_FORMAT, |
|
|
|
|
sourceCode: compilerAbstract.input, |
|
|
|
|
sourceCode: JSON.stringify(compilerAbstract.input), |
|
|
|
|
contractaddress: address, |
|
|
|
|
contractname: selectedContractFileAndName, |
|
|
|
|
compilerversion: metadata.compiler.version, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (abiEncodedConstructorArgs) { |
|
|
|
|
body.constructorArguements = abiEncodedConstructorArgs |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const url = new URL('api', this.apiUrl) |
|
|
|
|
url.searchParams.append('module', 'contract') |
|
|
|
|
url.searchParams.append('action', 'verifysourcecode') |
|
|
|
|