Fix URL construction

pull/5285/head
Manuel Wedler 4 months ago committed by Aniket
parent 486bb46349
commit 34fc57c0fe
  1. 4
      apps/contract-verification/src/app/Verifiers/BlockscoutVerifier.ts
  2. 8
      apps/contract-verification/src/app/Verifiers/EtherscanVerifier.ts
  3. 6
      apps/contract-verification/src/app/Verifiers/SourcifyVerifier.ts

@ -1,4 +1,4 @@
import { EtherscanVerifier } from "./EtherscanVerifier";
import { EtherscanVerifier } from './EtherscanVerifier'
export class BlockscoutVerifier extends EtherscanVerifier {
constructor(apiUrl: string) {
@ -7,7 +7,7 @@ export class BlockscoutVerifier extends EtherscanVerifier {
}
getContractCodeUrl(address: string): string {
const url = new URL(`address/${address}`, this.explorerUrl)
const url = new URL(this.explorerUrl + `/address/${address}`)
url.searchParams.append('tab', 'contract')
return url.href
}

@ -45,7 +45,7 @@ export class EtherscanVerifier extends AbstractVerifier {
body.constructorArguements = submittedContract.abiEncodedConstructorArgs
}
const url = new URL('api', this.apiUrl)
const url = new URL(this.apiUrl + '/api')
url.searchParams.append('module', 'contract')
url.searchParams.append('action', 'verifysourcecode')
if (this.apiKey) {
@ -78,7 +78,7 @@ export class EtherscanVerifier extends AbstractVerifier {
// TODO retry with backoff in case this throws error
async checkVerificationStatus(receiptId: string): Promise<VerificationStatus> {
const url = new URL('api', this.apiUrl)
const url = new URL(this.apiUrl + '/api')
url.searchParams.append('module', 'contract')
url.searchParams.append('action', 'checkverifystatus')
url.searchParams.append('guid', receiptId)
@ -121,7 +121,7 @@ export class EtherscanVerifier extends AbstractVerifier {
}
async lookup(contractAddress: string, chainId: string): Promise<LookupResponse> {
const url = new URL('api', this.apiUrl)
const url = new URL(this.apiUrl + '/api')
url.searchParams.append('module', 'contract')
url.searchParams.append('action', 'getabi')
url.searchParams.append('address', contractAddress)
@ -152,7 +152,7 @@ export class EtherscanVerifier extends AbstractVerifier {
}
getContractCodeUrl(address: string): string {
const url = new URL(`address/${address}#code`, this.explorerUrl)
const url = new URL(this.explorerUrl + `/address/${address}#code`)
return url.href
}
}

@ -65,7 +65,7 @@ export class SourcifyVerifier extends AbstractVerifier {
console.log(body)
const response = await fetch(new URL('verify', this.apiUrl).href, {
const response = await fetch(new URL(this.apiUrl + '/verify').href, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
@ -98,7 +98,7 @@ export class SourcifyVerifier extends AbstractVerifier {
}
async lookup(contractAddress: string, chainId: string): Promise<LookupResponse> {
const url = new URL('check-all-by-addresses', this.apiUrl)
const url = new URL(this.apiUrl + '/check-all-by-addresses')
url.searchParams.append('addresses', contractAddress)
url.searchParams.append('chainIds', chainId)
@ -128,7 +128,7 @@ export class SourcifyVerifier extends AbstractVerifier {
}
getContractCodeUrl(address: string, chainId: string, fullMatch: boolean): string {
const url = new URL(`contracts/${fullMatch ? 'full_match' : 'partial_match'}/${chainId}/${address}`, this.explorerUrl)
const url = new URL(this.explorerUrl + `/contracts/${fullMatch ? 'full_match' : 'partial_match'}/${chainId}/${address}`)
return url.href
}
}

Loading…
Cancel
Save