Skip to content
Closed
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ const NetworkEndpoints: Record<string, string> = {
[NetworkNames.ShidenEVM]: 'https://blockscout.com/shiden/api?',
[NetworkNames.Optimism]: 'https://api.etherscan.io/v2/api?chainid=10&',
[NetworkNames.EdgeEVM]: 'https://edgscan.live/api?',
[NetworkNames.Rootstock]: 'https://blockscout.com/rsk/mainnet/api?',
[NetworkNames.Rootstock]: 'https://blockscout.com/rsk/mainnet/',
[NetworkNames.RootstockTestnet]:
'https://rootstock-testnet.blockscout.com/api?',
'https://rootstock-testnet.blockscout.com/',
Comment on lines +14 to +16
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

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.

Suggested change
[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.

[NetworkNames.SkaleBlockBrawlers]:
'https://frayed-decent-antares.explorer.mainnet.skalenodes.com/api?',
[NetworkNames.SkaleCalypso]:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const getAddressActivity = async (
return cacheFetch(
{
// 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`,
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 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.ts

Length 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.

headers,
},
TTL,
Expand Down
Loading