[HOT FIX] Fix blockscout urls#763
Conversation
WalkthroughUpdated Etherscan provider configuration for Rootstock/RootstockTestnet endpoints and adjusted getAddressActivity URL construction to insert "api?" only for Blockscout-based endpoints. No public API signatures changed. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant C as Caller
participant E as EtherscanProvider
participant EP as Endpoint
rect rgb(240,245,252)
note over E: getAddressActivity
C->>E: getAddressActivity(address, params)
E->>EP: Inspect endpoint URL
alt Endpoint contains "blockscout.com"
note right of E: New behavior: insert "api?"
E->>EP: Build URL = endpoint + "api?" + query
else Other endpoints
E->>EP: Build URL = endpoint + query
end
E-->>C: Return fetched activity
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
packages/extension/src/providers/ethereum/libs/activity-handlers/providers/etherscan/configs.ts(1 hunks)packages/extension/src/providers/ethereum/libs/activity-handlers/providers/etherscan/index.ts(1 hunks)
| [NetworkNames.Rootstock]: 'https://blockscout.com/rsk/mainnet/', | ||
| [NetworkNames.RootstockTestnet]: | ||
| 'https://rootstock-testnet.blockscout.com/api?', | ||
| 'https://rootstock-testnet.blockscout.com/', |
There was a problem hiding this comment.
Critical: Incomplete fix will break other Blockscout networks.
Only Rootstock endpoints were updated to remove api?, but other Blockscout endpoints (lines 4, 6, 9, 10, 11, 38, 71) still include api?. The conditional logic added in index.ts at line 24 checks for 'blockscout.com' and will add api? to all matching endpoints, causing double api? in URLs for those networks.
For example, Ethereum's endpoint https://eth.blockscout.com/api? will become:
https://eth.blockscout.com/api?api?module=account&action=txlist&...
This will break API calls for Ethereum, Matic, KaruraEVM, AstarEVM, ShidenEVM, Aurora, and EthereumClassic.
Apply this diff to remove api? from all Blockscout endpoints for consistency:
- [NetworkNames.Ethereum]: 'https://eth.blockscout.com/api?',
+ [NetworkNames.Ethereum]: 'https://eth.blockscout.com/',
[NetworkNames.Binance]: 'https://api.etherscan.io/v2/api?chainid=56&',
- [NetworkNames.Matic]: 'https://polygon.blockscout.com/api?',
+ [NetworkNames.Matic]: 'https://polygon.blockscout.com/',
[NetworkNames.Moonbeam]: 'https://api.etherscan.io/v2/api?chainid=1284&',
[NetworkNames.Moonriver]: 'https://api.etherscan.io/v2/api?chainid=1285&',
- [NetworkNames.KaruraEVM]: 'https://blockscout.karura.network/api?',
- [NetworkNames.AstarEVM]: 'https://blockscout.com/astar/api?',
- [NetworkNames.ShidenEVM]: 'https://blockscout.com/shiden/api?',
+ [NetworkNames.KaruraEVM]: 'https://blockscout.karura.network/',
+ [NetworkNames.AstarEVM]: 'https://blockscout.com/astar/',
+ [NetworkNames.ShidenEVM]: 'https://blockscout.com/shiden/',
[NetworkNames.Optimism]: 'https://api.etherscan.io/v2/api?chainid=10&',
[NetworkNames.EdgeEVM]: 'https://edgscan.live/api?',And later in the file:
- [NetworkNames.Aurora]: 'https://explorer.mainnet.aurora.dev/api?',
+ [NetworkNames.Aurora]: 'https://explorer.mainnet.aurora.dev/',
[NetworkNames.PuppyNet]: 'https://puppyscan.shib.io/api?',And:
- [NetworkNames.EthereumClassic]: 'https://etc.blockscout.com/api?',
+ [NetworkNames.EthereumClassic]: 'https://etc.blockscout.com/',📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| [NetworkNames.Rootstock]: 'https://blockscout.com/rsk/mainnet/', | |
| [NetworkNames.RootstockTestnet]: | |
| 'https://rootstock-testnet.blockscout.com/api?', | |
| 'https://rootstock-testnet.blockscout.com/', | |
| export const ProviderEndpoints: Record<NetworkNames, string> = { | |
| // … other networks … | |
| [NetworkNames.Ethereum]: 'https://eth.blockscout.com/', | |
| [NetworkNames.Binance]: 'https://api.etherscan.io/v2/api?chainid=56&', | |
| [NetworkNames.Matic]: 'https://polygon.blockscout.com/', | |
| [NetworkNames.Moonbeam]: 'https://api.etherscan.io/v2/api?chainid=1284&', | |
| [NetworkNames.Moonriver]: 'https://api.etherscan.io/v2/api?chainid=1285&', | |
| [NetworkNames.KaruraEVM]: 'https://blockscout.karura.network/', | |
| [NetworkNames.AstarEVM]: 'https://blockscout.com/astar/', | |
| [NetworkNames.ShidenEVM]: 'https://blockscout.com/shiden/', | |
| [NetworkNames.Optimism]: 'https://api.etherscan.io/v2/api?chainid=10&', | |
| [NetworkNames.EdgeEVM]: 'https://edgscan.live/api?', | |
| [NetworkNames.Rootstock]: 'https://blockscout.com/rsk/mainnet/', | |
| [NetworkNames.RootstockTestnet]: 'https://rootstock-testnet.blockscout.com/', | |
| // … any other networks … | |
| [NetworkNames.Aurora]: 'https://explorer.mainnet.aurora.dev/', | |
| [NetworkNames.PuppyNet]: 'https://puppyscan.shib.io/api?', | |
| [NetworkNames.EthereumClassic]: 'https://etc.blockscout.com/', | |
| }; |
🤖 Prompt for AI Agents
In
packages/extension/src/providers/ethereum/libs/activity-handlers/providers/etherscan/configs.ts
(inspect lines ~4,6,9,10,11,14-16,38,71), several Blockscout endpoints still
include the literal "api?" which will be doubled by the new conditional in
index.ts; remove the trailing "api?" from all Blockscout URLs so they match the
Rootstock fix (leave the base URL and trailing slash if present), ensuring all
Blockscout entries are uniform and rely on the centralized logic to append
"api?" when needed.
| { | ||
| // Note: would like to add offset=50 (i.e. results per page) but it seems to cause polygon API to hang | ||
| url: `${endpoint}module=account&action=txlist&address=${address}&sort=desc`, | ||
| url: `${endpoint}${endpoint.includes('blockscout.com') ? 'api?': ''}module=account&action=txlist&address=${address}&sort=desc`, |
There was a problem hiding this comment.
🧩 Analysis chain
Verify the conditional logic once configs.ts is fixed.
After removing api? from all Blockscout endpoints in configs.ts, ensure this conditional correctly handles the URL construction. Currently, the logic assumes all endpoints containing 'blockscout.com' need api? added, which is correct only if configs.ts is consistent.
Run this verification script after applying the config changes to ensure all Blockscout URLs are formed correctly:
🏁 Script executed:
#!/bin/bash
# Description: Verify all Blockscout endpoint definitions and their usage pattern
echo "=== Checking Blockscout endpoints in configs.ts ==="
rg -n "blockscout\.(com|network)" packages/extension/src/providers/ethereum/libs/activity-handlers/providers/etherscan/configs.ts
echo -e "\n=== Verifying no double 'api?' in constructed URLs ==="
# Check if any endpoint still has 'api?' that would conflict with the conditional
rg -n "blockscout.*api\?" packages/extension/src/providers/ethereum/libs/activity-handlers/providers/etherscan/configs.tsLength of output: 975
Prevent double api? in Blockscout URLs
Blockscout endpoints in configs.ts currently include the api? suffix, so the endpoint.includes('blockscout.com') check appends a second api?, yielding ...?api?api?module.... Strip the suffix from all Blockscout endpoints in configs.ts, or modify the conditional to only append api? when !endpoint.endsWith('?').
🤖 Prompt for AI Agents
In
packages/extension/src/providers/ethereum/libs/activity-handlers/providers/etherscan/index.ts
around line 24, the URL construction can append a duplicate 'api?' for
Blockscout endpoints because some endpoints already end with 'api?'; change the
conditional so it only appends 'api?' when the endpoint does not already end
with a question mark (e.g., use endpoint.includes('blockscout.com') &&
!endpoint.endsWith('?')), ensuring the final URL contains a single 'api?' and
preserves existing query separators.
|
fixed #765 |
Description
The blockscout url change in this commit: c8edc6e is breaking the url format and blockscout api is not working for the networks using blockscout api.
Bug screentshot
Summary by CodeRabbit