Skip to content
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

Conflict when multiple explorer API keys provided #568

Open
vovikhangcdv opened this issue Jul 22, 2024 · 2 comments · May be fixed by #569
Open

Conflict when multiple explorer API keys provided #568

vovikhangcdv opened this issue Jul 22, 2024 · 2 comments · May be fixed by #569
Labels
bug Something isn't working

Comments

@vovikhangcdv
Copy link
Contributor

vovikhangcdv commented Jul 22, 2024

When you use the --etherscan-apikey along with other explorer API key parameters, such as --optim-apikey, the etherscan API key will be added as the first apikey parameter, with other explorer's keys following. This will cause the etherscan key to be counted and loaded when requesting explorer API, which is not expected when used with other explorers such as Optim, and it will result in an invalid API key error.

For example:

❯ crytic-compile optim:0x5499178919c79086fd580d6c5f332a4253244d91 --etherscan-apikey $ETHERSCAN_API_KEY --optim-apikey $OPTIM_API_KEY
ERROR:CryticCompile:Invalid etherscan API Key
ERROR:CryticCompile:Invalid etherscan API Key: https://api-optimistic.etherscan.io/api?module=contract&action=getsourcecode&address=0x5499178919c79086fd580d6c5f332a4253244d91&apikey=<$ETHERSCAN_API_KEY>&apikey=<$OPTIM_API_KEY>

Expected Behavior:
It should work seamlessly, and the provided priority API key should adhere to the explorer's address prefix.

@elopez
Copy link
Member

elopez commented Jul 22, 2024

Hi! thanks for the report. It looks like the optimism scanner includes the word "etherscan" on the URL, causing the check implemented here not be accurate:

https://github.com/crytic/crytic-compile/blob/603218d/crytic_compile/platform/etherscan.py#L252-L287

We should rework this to be more precise; maybe we can check the hostname from e.g. the list in SUPPORTED_NETWORK

@elopez elopez added the bug Something isn't working label Jul 22, 2024
@vovikhangcdv vovikhangcdv linked a pull request Jul 22, 2024 that will close this issue
@vovikhangcdv
Copy link
Contributor Author

Hi, I created a fix pr #569

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants