Skip to content

[HOT FIX] Fix blockscout urls#763

Closed
ahsan-javaiid wants to merge 1 commit intoenkryptcom:developfrom
ahsan-javaiid:blockscout-fix
Closed

[HOT FIX] Fix blockscout urls#763
ahsan-javaiid wants to merge 1 commit intoenkryptcom:developfrom
ahsan-javaiid:blockscout-fix

Conversation

@ahsan-javaiid
Copy link
Contributor

@ahsan-javaiid ahsan-javaiid commented Oct 7, 2025

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

image (11) Screenshot 2025-10-07 at 8 30 47 PM

Summary by CodeRabbit

  • Bug Fixes
    • Fixed activity feed issues on Rootstock and Rootstock Testnet by updating network endpoints, preventing failed or missing transactions.
    • Restored compatibility with Blockscout-based explorers by correctly handling api? path segments, ensuring successful activity requests.
    • Improves reliability and consistency of address activity across supported networks with no UI changes required.

@coderabbitai
Copy link

coderabbitai bot commented Oct 7, 2025

Walkthrough

Updated 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

Cohort / File(s) Summary of Changes
Etherscan provider config updates
packages/extension/src/providers/ethereum/libs/activity-handlers/providers/etherscan/configs.ts
Changed Rootstock and RootstockTestnet base URLs from ending with api? to ending with /. No other endpoints altered.
Etherscan provider URL assembly
packages/extension/src/providers/ethereum/libs/activity-handlers/providers/etherscan/index.ts
Modified URL formation in getAddressActivity to prepend api? only when the endpoint contains blockscout.com; otherwise, use endpoint as-is.

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
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • SemajaM8
  • NickKelly1
  • kvhnuke

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title "[HOT FIX] Fix blockscout urls" clearly identifies the primary change of correcting Blockscout URL formatting and aligns directly with the PR objectives without extraneous information. It is concise and specific enough for a teammate to understand the nature of the fix at a glance.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 94a605d and 7734fa1.

📒 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)

Comment on lines +14 to +16
[NetworkNames.Rootstock]: 'https://blockscout.com/rsk/mainnet/',
[NetworkNames.RootstockTestnet]:
'https://rootstock-testnet.blockscout.com/api?',
'https://rootstock-testnet.blockscout.com/',
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.

{
// 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.

@kvhnuke
Copy link
Contributor

kvhnuke commented Oct 8, 2025

fixed #765

@kvhnuke kvhnuke closed this Oct 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants