-
Notifications
You must be signed in to change notification settings - Fork 2
Fix: Etherscan API V1 deprecated; add V2 API support #692
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -54,8 +54,8 @@ type ContractCreationResult struct { | |
|
|
||
| // GetContractCreationTx finds contract creation tx by querying getcontractcreation action. | ||
| // It is a short-cut provided by most Etherscan instances. | ||
| func GetContractCreationTx(ctx context.Context, endpoint string, addressStr string, apiKey string) (string, error) { | ||
| url := fmt.Sprintf("%s?module=contract&action=getcontractcreation&contractaddresses=%s&apikey=%s", endpoint, addressStr, apiKey) | ||
| func GetContractCreationTx(ctx context.Context, endpoint string, chainIDStr, addressStr string, apiKey string) (string, error) { | ||
| url := fmt.Sprintf("%s?chainid=%s&module=contract&action=getcontractcreation&contractaddresses=%s&apikey=%s", endpoint, chainIDStr, addressStr, apiKey) | ||
|
|
||
| ctx, cancel := context.WithTimeout(ctx, etherscanTimeout) | ||
| defer cancel() | ||
|
|
@@ -97,7 +97,7 @@ func GetContractCreationTx(ctx context.Context, endpoint string, addressStr stri | |
| } | ||
| // If API call failed due to reasons other than action unsupported, there is no fallback. | ||
| if !strings.Contains(errMsg, "invalid Action name") { | ||
| return "", err | ||
| return "", fmt.Errorf("failed to get contract creation tx: %s", errMsg) | ||
|
||
| } | ||
|
|
||
| return GetContractCreationTxFallback(ctx, endpoint, addressStr, apiKey) | ||
|
|
@@ -187,7 +187,7 @@ func buildContractVerifyCmd( | |
| } | ||
|
|
||
| cmd := []string{ | ||
| "forge", "contract verify", "--watch", | ||
| "forge", "verify-contract", "--watch", | ||
| "--compiler-version", compilerVersion, | ||
| "--optimizer-runs", strconv.FormatUint(optimizerRuns, 10), | ||
| "--chain-id", chainID, | ||
|
|
@@ -273,7 +273,7 @@ func verifyContract( | |
| lggr.Infof("contract %s is already verified", contractAddress) | ||
| return nil | ||
| } | ||
| contractCreationTx, err := GetContractCreationTx(ctx, explorer.URL, contractAddress, explorer.APIKey) | ||
| contractCreationTx, err := GetContractCreationTx(ctx, explorer.URL, chainID, contractAddress, explorer.APIKey) | ||
| if err != nil { | ||
| return fmt.Errorf("failed to get contract creation tx: %w", err) | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to make this change in a backwards compatible way to avoid breaking domains that they are still using v1 and are not ready to migrate?
For example you could introduce a new functions here
GetContractCreationTxV2🤔There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I talk with the team and we don't think this us used anywhere else apart from the framework so we could update it in place
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@DimitriosNaikopoulos great, let me know. AFAICT the EtherscanV1 API is fully deprecated so no need for backwards compatibility. Thanks for taking a look at this!