Skip to content

Comments

fix: blockscout balances#764

Merged
kvhnuke merged 2 commits intodevelopfrom
devop/fix-blockscout-tokens
Oct 8, 2025
Merged

fix: blockscout balances#764
kvhnuke merged 2 commits intodevelopfrom
devop/fix-blockscout-tokens

Conversation

@kvhnuke
Copy link
Contributor

@kvhnuke kvhnuke commented Oct 7, 2025

Summary by CodeRabbit

  • Bug Fixes

    • Fixed API URL construction for Blockscout-backed networks so native and ERC‑20 balances load more reliably; users should see fewer failed requests, more consistent balances, and reduced loading/error states (including after network switches).
  • Chores

    • Extension package version bumped to 2.13.1 (no user-facing behavior changes).

@github-actions
Copy link

github-actions bot commented Oct 7, 2025

💼 Build Files
chrome: enkrypt-chrome-592fb227.zip
firefox: enkrypt-firefox-592fb227.zip

💉 Virus total analysis
chrome: 592fb227
firefox: 592fb227

@coderabbitai
Copy link

coderabbitai bot commented Oct 7, 2025

Walkthrough

Updated URL construction in the Blockscout asset handler to strip any trailing or embedded api? from the base endpoint via NetworkEndpoints[chain].replace('api?', '') before building native and ERC‑20 token balance API URLs. Fetching, validation, mapping to TokenBalance, and error handling remain unchanged.

Changes

Cohort / File(s) Summary
Blockscout balance URL construction
packages/extension/src/providers/ethereum/libs/assets-handlers/blockscout.ts
Adjusts native and token balance endpoint construction to use NetworkEndpoints[chain].replace('api?', '') before appending paths. No changes to response handling, mapping, or exported signatures.
Package version bump
packages/extension/package.json
Bumps @enkryptcom/extension version from 2.13.0 to 2.13.1. No functional code changes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • SemajaM
  • gamalielhere
  • NickKelly1

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 “fix: blockscout balances” clearly and concisely describes the primary change, which updates the Blockscout balance URL construction logic to ensure correct API endpoints. It directly references the core fix performed in the code and avoids vague or unrelated terms. This makes it easy for reviewers and future readers to understand the main purpose of the pull request at a glance.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch devop/fix-blockscout-tokens

📜 Recent 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 dfcdc2a and 592fb22.

📒 Files selected for processing (1)
  • packages/extension/package.json (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • packages/extension/package.json
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: buildAll
  • GitHub Check: test
  • GitHub Check: test

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: 1

🧹 Nitpick comments (1)
packages/extension/src/providers/ethereum/libs/assets-handlers/blockscout.ts (1)

31-32: Consider URL utility for more robust endpoint handling.

The current string replace approach works for the immediate fix, but consider using the URL API or a dedicated URL utility for more robust endpoint manipulation in the future. This would handle edge cases like:

  • Preserving legitimate query parameters
  • Handling trailing slashes consistently
  • Case-insensitive matching if needed

For example, using the URL API:

const buildBlockscoutUrl = (base: string, path: string): string => {
  // Remove 'api?' if present (case-insensitive)
  const cleanBase = base.replace(/api\?/i, '');
  // Ensure no double slashes when joining
  const normalizedBase = cleanBase.endsWith('/') ? cleanBase.slice(0, -1) : cleanBase;
  return `${normalizedBase}/${path}`;
};

const nativeTokenUrl = buildBlockscoutUrl(
  NetworkEndpoints[chain], 
  `api/v2/addresses/${encodedAddress}`
);
const tokenBalancesUrl = buildBlockscoutUrl(
  NetworkEndpoints[chain],
  `api/v2/addresses/${encodedAddress}/tokens?type=ERC-20`
);
📜 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 dfcdc2a.

📒 Files selected for processing (1)
  • packages/extension/src/providers/ethereum/libs/assets-handlers/blockscout.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: buildAll
  • GitHub Check: test
  • GitHub Check: test

@kvhnuke kvhnuke merged commit 0e366a7 into develop Oct 8, 2025
3 of 5 checks passed
@kvhnuke kvhnuke deleted the devop/fix-blockscout-tokens branch October 8, 2025 18:29
@coderabbitai coderabbitai bot mentioned this pull request 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.

2 participants