Skip to content

fix: align Subscan requests with free plan limits#2183

Merged
Nick-1979 merged 1 commit into
mainfrom
subscanFreePlanAdjustments
Jun 4, 2026
Merged

fix: align Subscan requests with free plan limits#2183
Nick-1979 merged 1 commit into
mainfrom
subscanFreePlanAdjustments

Conversation

@Nick-1979

@Nick-1979 Nick-1979 commented Jun 4, 2026

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • Refactor
    • Centralized Subscan API rate limiting and pagination configuration into a dedicated utility module, replacing hardcoded values throughout the codebase with standardized constants for consistent API behavior.

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@coderabbitai

coderabbitai Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 00ecd069-543c-47cb-8008-932613dfe3c8

📥 Commits

Reviewing files that changed from the base of the PR and between a0240c1 and 6359cbb.

📒 Files selected for processing (7)
  • packages/extension-polkagate/src/class/subscanQueue.ts
  • packages/extension-polkagate/src/popup/history/hookUtils/consts.ts
  • packages/extension-polkagate/src/popup/notification/constant.ts
  • packages/extension-polkagate/src/util/api/getNominationPoolsClaimedRewards.ts
  • packages/extension-polkagate/src/util/api/getRewardsSlashes.ts
  • packages/extension-polkagate/src/util/api/getTransfers.ts
  • packages/extension-polkagate/src/util/subscanLimits.ts

📝 Walkthrough

Walkthrough

This PR consolidates hardcoded Subscan configuration limits (rate limiting, page size) into a central utility module (subscanLimits.ts) and updates all consumers throughout the codebase to import and use these centralized constants instead of hardcoded values.

Changes

Subscan Limits Centralization

Layer / File(s) Summary
Central Subscan limits module
packages/extension-polkagate/src/util/subscanLimits.ts
New utility module exports two constants: SUBSCAN_FREE_PAGE_SIZE (25) and SUBSCAN_FREE_REQUESTS_PER_SECOND (2) to serve as a single source of truth for Subscan free-tier configuration.
Queue rate limit and UI constant synchronization
packages/extension-polkagate/src/class/subscanQueue.ts, packages/extension-polkagate/src/popup/history/hookUtils/consts.ts, packages/extension-polkagate/src/popup/notification/constant.ts
Queue rate limiting is updated to use SUBSCAN_FREE_REQUESTS_PER_SECOND instead of hardcoded 3, and UI pagination constants (TRANSFERS_PAGE_SIZE, EXTRINSICS_PAGE_SIZE, REFERENDA_COUNT_TO_TRACK_DOT) are consolidated to reference SUBSCAN_FREE_PAGE_SIZE.
API pagination enforcement
packages/extension-polkagate/src/util/api/getNominationPoolsClaimedRewards.ts, packages/extension-polkagate/src/util/api/getRewardsSlashes.ts, packages/extension-polkagate/src/util/api/getTransfers.ts
Three API functions now cap their Subscan request row parameters to SUBSCAN_FREE_PAGE_SIZE using Math.min() or direct assignment, ensuring all remote pagination respects the free-tier limit.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

Possibly related PRs

  • PolkaGate/extension#2095: Directly precedes this PR by introducing centralized Subscan rate-limited queue configuration that this PR builds upon with expanded centralization.

Suggested reviewers

  • AMIRKHANEF

Poem

🐰 Scattered limits, once hardcoded far and wide,
Now nestle in one module, side by side,
Twenty-five requests, and a rate so fair,
Subscan's free-tier limits, shared everywhere!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: aligning Subscan API requests with free plan rate limits and page size constraints.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch subscanFreePlanAdjustments

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.

@Nick-1979 Nick-1979 merged commit eab20df into main Jun 4, 2026
10 checks passed
@Nick-1979 Nick-1979 deleted the subscanFreePlanAdjustments branch June 4, 2026 20:15
github-actions Bot pushed a commit that referenced this pull request Jun 4, 2026
# [2.12.0](v2.11.0...v2.12.0) (2026-06-04)

### Bug Fixes

* align Subscan requests with free plan limits ([#2183](#2183)) ([eab20df](eab20df))

### Features

* add biometric auth for password-gated flows ([#2182](#2182)) ([4848935](4848935)), closes [#2164](#2164)
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.

1 participant