Skip to content

Add POST /v2/verify/etherscan/{chainId}/{address} endpoint #2090

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Apr 23, 2025

Conversation

manuelwedler
Copy link
Contributor

Closes #1912

As per specification: https://sourcify.stoplight.io/docs/sourcify-apiv2/ago7z944i2qg8-import-from-etherscan

Notes:

  • I reused our etherscan.common.ts logic from API v1 and refactored it. It's now called etherscan-util.ts.
  • Previously, we were compiling in order to get the contract path from Etherscan, since Etherscan does not provide this information directly. I found a solution to remove the compilation step. I added a Solidity parser which I use to parse all sources. I infer the contract path by finding the source which contains the provided contract name. I think that's the best solution we can come up with for finding the contract path.
  • Inside API v2, we first fetch the result from Etherscan within the server main thread. This is to provide better UX and return early in case we encounter an error. For example, the contract could not be verified on Etherscan. Processing the Etherscan result (including the new parsing) happens inside the workers.
  • The Etherscan API key is optional at the moment. We didn't make a final decision on this yet. We can still make it required.

I decided to move the processing step into the worker because parsing can be computationally expensive. Fetching from Etherscan can still be done easily inside the server main thread which provides better UX.
@manuelwedler manuelwedler force-pushed the apiv2-verify-etherscan branch from 22e3c92 to e6040b0 Compare April 17, 2025 14:40
@marcocastignoli marcocastignoli self-assigned this Apr 22, 2025
@marcocastignoli marcocastignoli moved this from Triage to Sprint - In Progress in Sourcify Public Apr 22, 2025
Copy link
Member

@marcocastignoli marcocastignoli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The endpoint is not present in the Swagger page: http://localhost:5555/api-docs/#/

@manuelwedler
Copy link
Contributor Author

The endpoint is not present in the Swagger page: http://localhost:5555/api-docs/#/

Good catch! Just updated the spec

Copy link
Member

@marcocastignoli marcocastignoli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job! I think we can update the etherscan instances tests to use the new /v2 apis

@marcocastignoli marcocastignoli moved this from Sprint - In Progress to Sprint - Up Next in Sourcify Public Apr 22, 2025
@marcocastignoli marcocastignoli moved this from Sprint - Up Next to Sprint - In Progress in Sourcify Public Apr 22, 2025
@marcocastignoli marcocastignoli moved this from Sprint - In Progress to Sprint - Done in Sourcify Public Apr 22, 2025
@marcocastignoli marcocastignoli moved this from Sprint - Done to Sprint - Needs Review in Sourcify Public Apr 22, 2025
Copy link
Member

@marcocastignoli marcocastignoli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!! 🚀

@manuelwedler manuelwedler merged commit 534ce04 into staging Apr 23, 2025
6 checks passed
@github-project-automation github-project-automation bot moved this from Sprint - Needs Review to Sprint - Done in Sourcify Public Apr 23, 2025
@manuelwedler manuelwedler deleted the apiv2-verify-etherscan branch April 23, 2025 12:59
@marcocastignoli marcocastignoli moved this from Sprint - Done to COMPLETED in Sourcify Public Apr 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: COMPLETED
Development

Successfully merging this pull request may close these issues.

Implement POST /v2/verify/etherscan/{chainId}/{address} endpoint
2 participants