Skip to content

Commit fc68901

Browse files
Support new "already verified" message from Etherscan (#2520)
Etherscan just changed how it replies to "already verified" contracts in their APIs. Before it was creating a verification job and returning the id. Now it simply returns the status "Contract source code already verified" without creating the verification job
2 parents b648ad6 + c3e8e62 commit fc68901

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

services/server/src/server/services/storageServices/EtherscanVerifyApiService.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const DEFAULT_ETHERSCAN_CHAINLIST_ENDPOINT =
2323
"https://api.etherscan.io/v2/chainlist";
2424
const DEFAULT_BLOCKSCOUT_CHAINLIST_ENDPOINT =
2525
"https://chains.blockscout.com/api/chains";
26-
const BLOCKSCOUT_ALREADY_VERIFIED = "BLOCKSCOUT_ALREADY_VERIFIED";
26+
const VERIFIER_ALREADY_VERIFIED = "VERIFIER_ALREADY_VERIFIED";
2727
const ROUTESCAN_CHAINLIST_ENDPOINTS = [
2828
{
2929
workspace: "mainnet",
@@ -327,7 +327,7 @@ export const buildJobExternalVerificationsObject = (
327327
if (
328328
verifierData.verificationId &&
329329
// We need to handle the special case for a blockscout already verified contract
330-
verifierData.verificationId !== BLOCKSCOUT_ALREADY_VERIFIED
330+
verifierData.verificationId !== VERIFIER_ALREADY_VERIFIED
331331
) {
332332
try {
333333
const apiBaseUrl = verifierService?.getApiUrl(
@@ -530,14 +530,16 @@ export class EtherscanVerifyApiService implements WStorageService {
530530
return;
531531
}
532532

533-
// Handle the "already verified" case for Blockscout by storing
534-
// { verificationId: "BLOCKSCOUT_ALREADY_VERIFIED" }
533+
// Handle the "already verified" case for Blockscout and Etherscan by storing
534+
// { verificationId: "VERIFIER_ALREADY_VERIFIED" }
535535
if (
536-
this.IDENTIFIER === WStorageIdentifiers.BlockscoutVerify &&
537-
response.result === "Smart-contract already verified."
536+
(this.IDENTIFIER === WStorageIdentifiers.BlockscoutVerify &&
537+
response.result === "Smart-contract already verified.") ||
538+
(this.IDENTIFIER === WStorageIdentifiers.EtherscanVerify &&
539+
response.result === "Contract source code already verified")
538540
) {
539541
this.storeExternalVerificationResult(jobData, {
540-
verificationId: BLOCKSCOUT_ALREADY_VERIFIED,
542+
verificationId: VERIFIER_ALREADY_VERIFIED,
541543
});
542544
return;
543545
}

services/server/test/integration/apiv2/jobs.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ describe("GET /v2/verify/:verificationId", function () {
116116
verificationId: "some-external-id",
117117
},
118118
BlockscoutVerify: {
119-
verificationId: "BLOCKSCOUT_ALREADY_VERIFIED",
119+
verificationId: "VERIFIER_ALREADY_VERIFIED",
120120
},
121121
RoutescanVerify: {
122122
error: "some error",
@@ -132,7 +132,7 @@ describe("GET /v2/verify/:verificationId", function () {
132132
chainFixture.defaultContractAddress,
133133
},
134134
blockscout: {
135-
verificationId: "BLOCKSCOUT_ALREADY_VERIFIED",
135+
verificationId: "VERIFIER_ALREADY_VERIFIED",
136136
explorerUrl:
137137
"https://eth.blockscout.io/address/" +
138138
chainFixture.defaultContractAddress,

0 commit comments

Comments
 (0)