Add BlockscoutVerifier

pull/5285/head
Manuel Wedler 4 months ago committed by Aniket
parent 724b1ad695
commit 3f6b3a16c4
  1. 14
      apps/contract-verification/src/app/Verifiers/BlockscoutVerifier.ts
  2. 2
      apps/contract-verification/src/app/Verifiers/EtherscanVerifier.ts
  3. 10
      apps/contract-verification/src/app/Verifiers/index.ts
  4. 4
      apps/contract-verification/src/app/app.tsx
  5. 2
      apps/contract-verification/src/app/types/VerificationTypes.ts

@ -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
}
}

@ -25,7 +25,7 @@ interface EtherscanCheckStatusResponse {
} }
export class EtherscanVerifier extends AbstractVerifier { export class EtherscanVerifier extends AbstractVerifier {
constructor(apiUrl: string, explorerUrl: string, private apiKey?: string) { constructor(apiUrl: string, explorerUrl: string, protected apiKey?: string) {
super(apiUrl, explorerUrl) super(apiUrl, explorerUrl)
} }

@ -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)
} }
} }

@ -27,8 +27,8 @@ const App = () => {
useEffect(() => { useEffect(() => {
// const sourcifyVerifier = new SourcifyVerifier('http://sourcify.dev/server/', 'Sourcify') // const sourcifyVerifier = new SourcifyVerifier('http://sourcify.dev/server/', 'Sourcify')
const sourcifyVerifier = new SourcifyVerifier('http://localhost:5555/') const sourcifyVerifier = new SourcifyVerifier('http://localhost:5555/', 'todo')
const etherscanVerifier = new EtherscanVerifier('https://api.etherscan.io', 'API_KEY') const etherscanVerifier = new EtherscanVerifier('https://api.etherscan.io', 'todo', 'API_KEY')
setVerifiers([sourcifyVerifier, etherscanVerifier]) setVerifiers([sourcifyVerifier, etherscanVerifier])
// TODO: Fix 'compilationFinished' event types. The interface is outdated at https://github.com/ethereum/remix-plugin/blob/master/packages/api/src/lib/compiler/api.ts. It does not include data, input, or version. See the current parameters: https://github.com/ethereum/remix-project/blob/9f6c5be882453a555055f07171701459e4ae88a4/libs/remix-solidity/src/compiler/compiler.ts#L189 // TODO: Fix 'compilationFinished' event types. The interface is outdated at https://github.com/ethereum/remix-plugin/blob/master/packages/api/src/lib/compiler/api.ts. It does not include data, input, or version. See the current parameters: https://github.com/ethereum/remix-project/blob/9f6c5be882453a555055f07171701459e4ae88a4/libs/remix-solidity/src/compiler/compiler.ts#L189

@ -21,7 +21,7 @@ export type VerifierIdentifier = 'Sourcify' | 'Etherscan' | 'Blockscout'
export interface VerifierSettings { export interface VerifierSettings {
apiUrl: string apiUrl: string
explorerUrl: string explorerUrl?: string
apiKey?: string apiKey?: string
} }

Loading…
Cancel
Save