From 34fc57c0fea078efb63e7c723e93ec76fdbf180a Mon Sep 17 00:00:00 2001 From: Manuel Wedler Date: Fri, 19 Jul 2024 14:48:14 +0200 Subject: [PATCH] Fix URL construction --- .../src/app/Verifiers/BlockscoutVerifier.ts | 4 ++-- .../src/app/Verifiers/EtherscanVerifier.ts | 8 ++++---- .../src/app/Verifiers/SourcifyVerifier.ts | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/apps/contract-verification/src/app/Verifiers/BlockscoutVerifier.ts b/apps/contract-verification/src/app/Verifiers/BlockscoutVerifier.ts index a05a7b1229..aca3c62cc1 100644 --- a/apps/contract-verification/src/app/Verifiers/BlockscoutVerifier.ts +++ b/apps/contract-verification/src/app/Verifiers/BlockscoutVerifier.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 } diff --git a/apps/contract-verification/src/app/Verifiers/EtherscanVerifier.ts b/apps/contract-verification/src/app/Verifiers/EtherscanVerifier.ts index 2a5e222dab..09c631ec1d 100644 --- a/apps/contract-verification/src/app/Verifiers/EtherscanVerifier.ts +++ b/apps/contract-verification/src/app/Verifiers/EtherscanVerifier.ts @@ -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 { - 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 { - 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 } } diff --git a/apps/contract-verification/src/app/Verifiers/SourcifyVerifier.ts b/apps/contract-verification/src/app/Verifiers/SourcifyVerifier.ts index c5a73dbaaf..91ac341d03 100644 --- a/apps/contract-verification/src/app/Verifiers/SourcifyVerifier.ts +++ b/apps/contract-verification/src/app/Verifiers/SourcifyVerifier.ts @@ -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 { - 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 } }