Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions engine/cld/legacy/cli/commands/evm_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

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

The variable err is being replaced with a newly formatted error, but the original err variable may contain valuable context (such as stack traces or wrapped errors). Consider wrapping the original error using fmt.Errorf(\"failed to get contract creation tx: %s: %w\", errMsg, err) to preserve the error chain, or verify that err is truly nil at this point in the code path.

Copilot uses AI. Check for mistakes.
}

return GetContractCreationTxFallback(ctx, endpoint, addressStr, apiKey)
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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)
}
Expand Down