Skip to content

Commit

Permalink
fix(core): Handle already verified response after successful submission
Browse files Browse the repository at this point in the history
  • Loading branch information
RPate97 committed Apr 9, 2024
1 parent 0da20a7 commit 0c375c0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .changeset/early-buses-watch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sphinx-labs/core': patch
---

Handle alreay verified response after successful verification submission
26 changes: 17 additions & 9 deletions packages/core/src/etherscan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,21 @@ export const verifyDeploymentWithRetries = async (
}
}

export const handleAlreadyVerifiedResponse = (
err: any,
address: string,
contractURL: string
) => {
if ((err.message as string)?.toLowerCase().includes('already verified')) {
console.log(
`The contract ${address} has already been verified on Etherscan:\n${contractURL}`
)
return { success: true }
} else {
return { success: false, message: err.message }
}
}

export const attemptVerification = async (
address: string,
encodedConstructorArgs: string,
Expand Down Expand Up @@ -237,14 +252,7 @@ export const attemptVerification = async (
)
guid = response.message
} catch (err) {
if ((err.message as string).toLowerCase().includes('already verified')) {
console.log(
`The contract ${address} has already been verified on Etherscan:\n${contractURL}`
)
return { success: true }
} else {
return { success: false, message: err.message }
}
return handleAlreadyVerifiedResponse(err, address, contractURL)
}

const networkName = fetchNameForNetwork(BigInt(chainId))
Expand All @@ -263,7 +271,7 @@ export const attemptVerification = async (
try {
verificationStatus = await etherscan.getVerificationStatus(guid)
} catch (err) {
return { success: false, message: err.message }
return handleAlreadyVerifiedResponse(err, address, contractURL)
}

if (!(verificationStatus.isFailure() || verificationStatus.isSuccess())) {
Expand Down

0 comments on commit 0c375c0

Please sign in to comment.