parent
724b1ad695
commit
3f6b3a16c4
@ -0,0 +1,14 @@ |
|||||||
|
import { EtherscanVerifier } from "./EtherscanVerifier"; |
||||||
|
|
||||||
|
export class BlockscoutVerifier extends EtherscanVerifier { |
||||||
|
constructor(apiUrl: string) { |
||||||
|
// apiUrl and explorerUrl are the same for Blockscout
|
||||||
|
super(apiUrl, apiUrl, undefined) |
||||||
|
} |
||||||
|
|
||||||
|
getContractCodeUrl(address: string): string { |
||||||
|
const url = new URL(`address/${address}`, this.explorerUrl) |
||||||
|
url.searchParams.append('tab', 'contract') |
||||||
|
return url.href |
||||||
|
} |
||||||
|
} |
@ -1,22 +1,30 @@ |
|||||||
import { VerifierIdentifier, VerifierSettings } from '../types/VerificationTypes' |
import { VerifierIdentifier, VerifierSettings } from '../types/VerificationTypes' |
||||||
import { AbstractVerifier } from './AbstractVerifier' |
import { AbstractVerifier } from './AbstractVerifier' |
||||||
|
import { BlockscoutVerifier } from './BlockscoutVerifier' |
||||||
import { EtherscanVerifier } from './EtherscanVerifier' |
import { EtherscanVerifier } from './EtherscanVerifier' |
||||||
import { SourcifyVerifier } from './SourcifyVerifier' |
import { SourcifyVerifier } from './SourcifyVerifier' |
||||||
|
|
||||||
export { AbstractVerifier } from './AbstractVerifier' |
export { AbstractVerifier } from './AbstractVerifier' |
||||||
|
export { BlockscoutVerifier } from './BlockscoutVerifier' |
||||||
export { SourcifyVerifier } from './SourcifyVerifier' |
export { SourcifyVerifier } from './SourcifyVerifier' |
||||||
export { EtherscanVerifier } from './EtherscanVerifier' |
export { EtherscanVerifier } from './EtherscanVerifier' |
||||||
|
|
||||||
export function getVerifier(identifier: VerifierIdentifier, settings: VerifierSettings): AbstractVerifier { |
export function getVerifier(identifier: VerifierIdentifier, settings: VerifierSettings): AbstractVerifier { |
||||||
switch (identifier) { |
switch (identifier) { |
||||||
case 'Sourcify': |
case 'Sourcify': |
||||||
|
if (!settings.explorerUrl) { |
||||||
|
throw new Error('The Sourcify verifier requires an explorer URL.') |
||||||
|
} |
||||||
return new SourcifyVerifier(settings.apiUrl, settings.explorerUrl) |
return new SourcifyVerifier(settings.apiUrl, settings.explorerUrl) |
||||||
case 'Etherscan': |
case 'Etherscan': |
||||||
|
if (!settings.explorerUrl) { |
||||||
|
throw new Error('The Etherscan verifier requires an explorer URL.') |
||||||
|
} |
||||||
if (!settings.apiKey) { |
if (!settings.apiKey) { |
||||||
throw new Error('The Etherscan verifier requires an API key.') |
throw new Error('The Etherscan verifier requires an API key.') |
||||||
} |
} |
||||||
return new EtherscanVerifier(settings.apiUrl, settings.explorerUrl, settings.apiKey) |
return new EtherscanVerifier(settings.apiUrl, settings.explorerUrl, settings.apiKey) |
||||||
case 'Blockscout': |
case 'Blockscout': |
||||||
return new EtherscanVerifier(settings.apiUrl, settings.explorerUrl) |
return new BlockscoutVerifier(settings.apiUrl) |
||||||
} |
} |
||||||
} |
} |
||||||
|
Loading…
Reference in new issue