Skip to content

feat: reduce Polkadot unstaking period to 2 days#2186

Merged
Nick-1979 merged 8 commits into
mainfrom
reducedUnstaking
Jul 11, 2026
Merged

feat: reduce Polkadot unstaking period to 2 days#2186
Nick-1979 merged 8 commits into
mainfrom
reducedUnstaking

Conversation

@Nick-1979

@Nick-1979 Nick-1979 commented Jul 8, 2026

Copy link
Copy Markdown
Member

remove deprecated fast unstaking

Summary by CodeRabbit

  • Bug Fixes
    • Updated unstaking timing text and calculations to use nominator-specific unbonding duration, including different behavior for validator vs non-validator views.
  • Removed Features
    • Removed the Solo “Fast Unstake” option (fullscreen/popup flow and route entry) from the staking UI.
  • Chores
    • Cleaned up fast-unstake-related localization strings across supported languages.
    • Bumped the extension version to 2.12.1.

@Nick-1979 Nick-1979 self-assigned this Jul 8, 2026
@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@Nick-1979, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 50 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 07e8f815-152e-4c3f-a09b-279c97c8bca5

📥 Commits

Reviewing files that changed from the base of the PR and between 47fe1f5 and 7d2b45c.

📒 Files selected for processing (3)
  • packages/extension-base/src/utils/AiUtils/documents/extrinsics.ts
  • packages/extension-polkagate/src/popup/staking/solo-new/index.tsx
  • packages/extension/package.json
📝 Walkthrough

Walkthrough

This PR removes the Solo “Fast Unstake” feature and its routing, popup handling, hooks, components, buttons, and translations. It adds nominator-specific unbonding duration calculations, updates validator detection, and bumps the extension version to 2.12.1.

Changes

Fast Unstake removal and nominator unbonding duration

Layer / File(s) Summary
Add nominator unbonding duration
packages/extension-polkagate/src/util/types.ts, packages/extension-polkagate/src/hooks/useStakingConsts.ts
Adds and computes nominatorUnbondingDuration, including refetching when cached constants lack the new field.
Use nominator duration and validator status in staking flows
packages/extension-polkagate/src/hooks/useIsValidator.ts, packages/extension-polkagate/src/hooks/useStakingInfoSolo.ts, packages/extension-polkagate/src/hooks/useStakingApi/useUnstakingPool.ts, packages/extension-polkagate/src/popup/staking/stakingInfo/index.tsx
Uses validator status to select unbonding duration and applies the nominator duration to redeem-date and staking information displays.
Remove Fast Unstake components and hooks
packages/extension-polkagate/src/fullscreen/stake/..., packages/extension-polkagate/src/hooks/..., packages/extension-polkagate/src/popup/staking/...
Deletes Fast Unstake UI wiring, supporting hooks, exports, popup handling, enum entry, and action buttons.
Remove Fast Unstake route wiring
packages/extension-ui/src/Popup/routes/stakingRoutes.ts
Removes the FastUnstake import and /solo/:genesisHash/fastUnstake route.
Remove Fast Unstake translations
packages/extension/public/locales/{de,en,es,fr,hi,pt,ru,zh}/translation.json
Removes fast-unstake eligibility and instruction strings while retaining or adjusting adjacent staking labels.
Bump extension version
packages/extension/package.json, packages/extension/src/packageInfo.ts
Changes the extension version from 2.12.0 to 2.12.1.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

Suggested labels: priority

Suggested reviewers: AMIRKHANEF

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.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 matches the main change: fast unstaking is removed and the unstaking period is updated to the new shorter duration.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch reducedUnstaking

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.

@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Reduce Polkadot nominator unbonding to 2 days; remove fast unstake

✨ Enhancement ⚙️ Configuration changes 🕐 20-40 Minutes

Grey Divider

AI Description

• Use chain nominator fast-unbond constant to show ~2-day nominator unstaking.
• Update unstaking ETA/redeem-date UI to use nominator-specific unbonding duration.
• Remove deprecated fast-unstake flow (UI/hooks/routes/i18n) and bump extension version.
Diagram

graph TD
  A{{"Chain staking consts"}} --> B["useStakingConsts"] --> C["StakingConsts model"] --> D["Unstaking ETA (useUnstakingPool)"] --> E["StakingInfo UI"]
  C --> F["Solo staking stats (useStakingInfoSolo)"]
  G["Popup/routes wiring"] --> H["Fast unstake flow (removed)"]
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Hardcode 2-day unbonding for Polkadot nominators
  • ➕ Simpler implementation (no new const wiring)
  • ➕ Avoids runtime-const availability issues on older metadata
  • ➖ Incorrect for other chains/environments and future runtime changes
  • ➖ Requires manual updates if Polkadot parameters change again
2. Keep fast-unstake behind a feature flag / chain capability check
  • ➕ Allows gradual removal and rollback if needed
  • ➕ Preserves UI for chains where fast-unstake still exists
  • ➖ Ongoing maintenance burden (eligibility logic, i18n, routing, QA)
  • ➖ More conditional complexity across popup/fullscreen flows
3. Fallback to bondingDuration-derived unbonding if nominator const missing
  • ➕ More resilient across chains/runtimes that don’t expose the new constant
  • ➕ Prevents showing undefined/incorrect timelines
  • ➖ Adds branching and testing surface area
  • ➖ May mask configuration issues if the const was expected to exist

Recommendation: The PR’s approach—deriving nominator unbonding from runtime constants and removing the deprecated fast-unstake feature—is the best long-term direction because it keeps timelines chain-driven and reduces dead feature surface. The main follow-up to consider is a defensive fallback (or explicit handling) when staking.nominatorFastUnbondDuration is unavailable, to avoid undefined durations in edge networks/older runtimes.

Files changed (19) +23 / -106

Enhancement (5) +14 / -7
useUnstakingPool.tsCompute pool redeem date using nominator unbonding duration +1/-1

Compute pool redeem date using nominator unbonding duration

• Switches redeem-date calculation from 'unbondingDuration' to 'nominatorUnbondingDuration'. This makes pool unstaking timelines reflect the new ~2-day unbonding period for nominators.

packages/extension-polkagate/src/hooks/useStakingApi/useUnstakingPool.ts

useStakingConsts.tsAdd nominator-specific unbonding duration derived from chain consts +3/-1

Add nominator-specific unbonding duration derived from chain consts

• Reads 'staking.nominatorFastUnbondDuration' and computes 'nominatorUnbondingDuration' in days alongside the existing 'unbondingDuration'. Persists the expanded const set to localStorage for reuse.

packages/extension-polkagate/src/hooks/useStakingConsts.ts

useStakingInfoSolo.tsShow validator vs nominator unstaking period in solo staking stats +7/-3

Show validator vs nominator unstaking period in solo staking stats

• Adds 'useSelectedAccount' + 'useIsValidator' and displays 'unbondingDuration' for validators while using 'nominatorUnbondingDuration' for nominators. This updates the “Days to receive funds back” stat to match role-specific behavior.

packages/extension-polkagate/src/hooks/useStakingInfoSolo.ts

index.tsxUpdate staking info copy to use nominator unbonding duration +2/-2

Update staking info copy to use nominator unbonding duration

• Replaces uses of 'stakingConsts.unbondingDuration' with 'stakingConsts.nominatorUnbondingDuration' in the unstaking explainer row. Users now see the reduced nominator redeem timeline in the staking info modal.

packages/extension-polkagate/src/popup/staking/stakingInfo/index.tsx

types.tsExtend StakingConsts with nominatorUnbondingDuration +1/-0

Extend StakingConsts with nominatorUnbondingDuration

• Adds a 'nominatorUnbondingDuration' field (days) to the 'StakingConsts' interface. This enables type-safe propagation of role-specific unbonding values throughout the app.

packages/extension-polkagate/src/util/types.ts

Refactor (4) +0 / -18
PopUpHandlerSolo.tsxRemove fullscreen fast-unstake popup route +0/-10

Remove fullscreen fast-unstake popup route

• Drops the FastUnstake import and removes the FAST_UNSTAKE popup case from the solo staking fullscreen popup handler. This eliminates the deprecated fast-unstake entry point in fullscreen mode.

packages/extension-polkagate/src/fullscreen/stake/new-solo/PopUpHandlerSolo.tsx

index.tsStop exporting deprecated exposure-check hook +0/-1

Stop exporting deprecated exposure-check hook

• Removes 'useIsExposed' from the public hooks barrel export, reflecting the fast-unstake deprecation. This prevents new call sites from depending on the removed hook.

packages/extension-polkagate/src/hooks/index.ts

index.tsRemove fast-unstaking API hook export +0/-1

Remove fast-unstaking API hook export

• Removes 'useFastUnstaking' from the staking API hook index. This aligns hook exports with removal of the fast-unstake feature.

packages/extension-polkagate/src/hooks/useStakingApi/index.ts

stakingRoutes.tsRemove fast-unstake route from popup staking routes +0/-6

Remove fast-unstake route from popup staking routes

• Deletes the FastUnstake import and removes the '/solo/:genesisHash/fastUnstake' route entry. This eliminates navigation paths to the deprecated feature in the popup UI.

packages/extension-ui/src/Popup/routes/stakingRoutes.ts

Documentation (8) +7 / -79
translation.jsonRemove fast-unstake related German translations +1/-10

Remove fast-unstake related German translations

• Deletes strings used exclusively by the fast-unstake flow (eligibility checks, guidance, and menu label). Keeps the remaining staking translations intact.

packages/extension/public/locales/de/translation.json

translation.jsonRemove fast-unstake related English translation keys +0/-9

Remove fast-unstake related English translation keys

• Removes translation keys that were only referenced by the deprecated fast-unstake UI. This reduces unused i18n surface after feature removal.

packages/extension/public/locales/en/translation.json

translation.jsonRemove fast-unstake related Spanish translations +1/-10

Remove fast-unstake related Spanish translations

• Deletes fast-unstake eligibility/status text and related menu labels from Spanish translations. Aligns i18n with removal of the fast-unstake screens.

packages/extension/public/locales/es/translation.json

translation.jsonRemove fast-unstake related French translations +1/-10

Remove fast-unstake related French translations

• Removes fast-unstake-only strings from French locale entries. Prevents unused translation keys after deprecating the flow.

packages/extension/public/locales/fr/translation.json

translation.jsonRemove fast-unstake related Hindi translations +1/-10

Remove fast-unstake related Hindi translations

• Deletes Hindi strings tied to fast-unstake eligibility and guidance. Keeps locale content consistent with removed navigation and UI.

packages/extension/public/locales/hi/translation.json

translation.jsonRemove fast-unstake related Portuguese translations +1/-10

Remove fast-unstake related Portuguese translations

• Removes Portuguese translation entries only used by the fast-unstake UI and menu. Reduces unused i18n keys post-deprecation.

packages/extension/public/locales/pt/translation.json

translation.jsonRemove fast-unstake related Russian translations +1/-10

Remove fast-unstake related Russian translations

• Deletes Russian translations for fast-unstake eligibility checks and related hints. Matches removal of fast-unstake routing and UI components.

packages/extension/public/locales/ru/translation.json

translation.jsonRemove fast-unstake related Chinese translations +1/-10

Remove fast-unstake related Chinese translations

• Removes fast-unstake-specific translation keys from the Chinese locale file. Ensures i18n reflects the updated staking feature set.

packages/extension/public/locales/zh/translation.json

Other (2) +2 / -2
package.jsonBump extension package version to 2.12.1 +1/-1

Bump extension package version to 2.12.1

• Updates the extension package version from 2.12.0 to 2.12.1 to reflect the staking behavior change and feature removal.

packages/extension/package.json

packageInfo.tsUpdate auto-generated packageInfo version to 2.12.1 +1/-1

Update auto-generated packageInfo version to 2.12.1

• Updates the generated packageInfo version constant to match package.json. Keeps build-time metadata consistent.

packages/extension/src/packageInfo.ts

@qodo-code-review

qodo-code-review Bot commented Jul 8, 2026

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (2) 📜 Skill insights (0)

Context used
✅ Compliance rules (platform): 14 rules

Grey Divider


Action required

1. Broken FastUnstake navigation ✓ Resolved 🐞 Bug ≡ Correctness
Description
Solo staking popup still navigates to /solo/:genesisHash/fastUnstake, but the route was removed
from STAKING_ROUTES, so the button leads to an unhandled path.
Code

packages/extension-ui/src/Popup/routes/stakingRoutes.ts[L95-99]

-  {
-    Component: FastUnstake,
-    path: '/solo/:genesisHash/fastUnstake',
-    trigger: 'solo-fast-unstake'
-  },
Evidence
The popup Solo page still defines onFastUnstake and conditionally renders a Fast Unstake button,
but STAKING_ROUTES no longer contains a matching /solo/:genesisHash/fastUnstake route.

packages/extension-polkagate/src/popup/staking/solo-new/index.tsx[70-114]
packages/extension-ui/src/Popup/routes/stakingRoutes.ts[83-128]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
The `/solo/:genesisHash/fastUnstake` route was removed, but the Solo staking UI still renders a “Fast Unstake” button and navigates to that route, causing broken navigation.

### Issue Context
Fast-unstake appears to be deprecated/removed in this PR; remaining entrypoints should be removed (or the route/component restored).

### Fix Focus Areas
- packages/extension-polkagate/src/popup/staking/solo-new/index.tsx[70-114]
- packages/extension-ui/src/Popup/routes/stakingRoutes.ts[83-128]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. Staking const cache mismatch ✓ Resolved 🐞 Bug ☼ Reliability
Description
useStakingConsts unconditionally reads apiAt.consts.staking.nominatorFastUnbondDuration and
caches the result; existing localStorage entries (or chains lacking the const) can yield missing
nominatorUnbondingDuration until the cache refreshes, breaking consumers.
Code

packages/extension-polkagate/src/hooks/useStakingConsts.ts[R35-38]

+      const nominatorFastUnbondDuration = apiAt.consts['staking']['nominatorFastUnbondDuration'].toPrimitive() as number;
      const sessionsPerEra = apiAt.consts['staking']['sessionsPerEra'].toPrimitive() as number;

      const { epochDuration, expectedBlockTime, maxNominations } = stakingConsts;
Evidence
The hook directly calls .toPrimitive() on apiAt.consts.staking.nominatorFastUnbondDuration and
writes a cached object to localStorage, but when reading from localStorage it does not
validate/migrate fields. It also only refreshes cached consts when eraIndex differs, so a schema
change can persist until the next era refresh.

packages/extension-polkagate/src/hooks/useStakingConsts.ts[22-69]
packages/extension-polkagate/src/hooks/useStakingConsts.ts[71-99]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`useStakingConsts` assumes `nominatorFastUnbondDuration` always exists and also trusts the cached localStorage object schema. When the cached object predates the new `nominatorUnbondingDuration` field (or the chain doesn’t expose the new const), consumers may see `undefined` values.

### Issue Context
The hook only refreshes cached consts when `eraIndex` changes. After an app upgrade, the era may not change immediately, so stale cached data can persist.

### Fix Focus Areas
- packages/extension-polkagate/src/hooks/useStakingConsts.ts[22-99]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


3. Fullscreen FAST_UNSTAKE dead ✓ Resolved 🐞 Bug ≡ Correctness
Description
Fullscreen staking still opens StakingPopUps.FAST_UNSTAKE, but PopUpHandlerSolo no longer
handles that enum value, so clicking it results in an empty popup state.
Code

packages/extension-polkagate/src/fullscreen/stake/new-solo/PopUpHandlerSolo.tsx[L109-116]

-      case StakingPopUps.FAST_UNSTAKE:
-        return (
-          <FastUnstake
-            address={address}
-            genesisHash={genesisHash}
-            onClose={popupCloser}
-          />
-        );
Evidence
The FAST_UNSTAKE enum value still exists and the fullscreen portfolio renders a button that opens
it, but the popup handler switch does not include a FAST_UNSTAKE case and falls through to `default:
return null`.

packages/extension-polkagate/src/fullscreen/stake/util/utils.ts[22-40]
packages/extension-polkagate/src/fullscreen/stake/partials/StakingPortfolioAndTiles.tsx[162-189]
packages/extension-polkagate/src/fullscreen/stake/new-solo/PopUpHandlerSolo.tsx[33-137]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
The fullscreen UI still exposes a FAST_UNSTAKE action, but the popup handler no longer renders anything for it, creating a dead interaction.

### Issue Context
This PR removes deprecated fast-unstake. Fullscreen UI should not offer a FAST_UNSTAKE popup unless it is implemented.

### Fix Focus Areas
- packages/extension-polkagate/src/fullscreen/stake/partials/StakingPortfolioAndTiles.tsx[162-189]
- packages/extension-polkagate/src/fullscreen/stake/util/utils.ts[22-40]
- packages/extension-polkagate/src/fullscreen/stake/new-solo/PopUpHandlerSolo.tsx[33-137]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

4. Version bumped to 2.12.1 📘 Rule violation § Compliance
Description
This PR bumps the package version and updates an auto-generated packageInfo constant, but that
change is not described in the PR scope/description. Undocumented versioning/release metadata
changes make the change set harder to audit and can be considered out-of-scope.
Code

packages/extension/package.json[18]

+  "version": "2.12.1",
Evidence
The compliance rule requires all changed lines to be traceable to a documented request/scope. The
diff shows a version bump in package.json and a matching update in an auto-generated file, but the
PR description only mentions removing deprecated fast unstaking and reducing unstaking period.

Rule 660844: Changed lines must be justified by a documented user or stakeholder request
packages/extension/package.json[18-18]
packages/extension/src/packageInfo.ts[6-6]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The PR changes package versioning metadata (`2.12.0` -> `2.12.1`) and the corresponding auto-generated `packageInfo` version without documenting this in the PR description/scope.

## Issue Context
PR title/description focus on reducing unstaking period and removing deprecated fast unstaking; version bumps and generated metadata updates should be explicitly called out or reverted if not intended.

## Fix Focus Areas
- packages/extension/package.json[18-18]
- packages/extension/src/packageInfo.ts[6-6]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


5. Pool redeem date NaN ✓ Resolved 🐞 Bug ≡ Correctness
Description
useUnstakingPool computes redeemDate from stakingConsts.nominatorUnbondingDuration without
validating it, so a missing/invalid value produces an “Invalid Date” string.
Code

packages/extension-polkagate/src/hooks/useStakingApi/useUnstakingPool.ts[47]

+      const date = Date.now() + stakingInfo.stakingConsts?.nominatorUnbondingDuration * 24 * 60 * 60 * 1000;
Evidence
The current code multiplies stakingInfo.stakingConsts?.nominatorUnbondingDuration into
milliseconds and immediately formats it as a date. If the cached stakingConsts object lacks the new
field, the math results in NaN and new Date(NaN) becomes invalid.

packages/extension-polkagate/src/hooks/useStakingApi/useUnstakingPool.ts[45-53]
packages/extension-polkagate/src/hooks/useStakingConsts.ts[71-99]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`redeemDate` is computed using `nominatorUnbondingDuration` without checking it is defined/finite. If it is missing (e.g., stale cached stakingConsts), `Date.now() + undefined * ...` becomes `NaN`.

### Issue Context
`stakingInfo.stakingConsts` comes from `useStakingConsts`, which may return cached values.

### Fix Focus Areas
- packages/extension-polkagate/src/hooks/useStakingApi/useUnstakingPool.ts[45-53]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


6. Validator duration flicker ✓ Resolved 🐞 Bug ➹ Performance
Description
useStakingInfoSolo re-queries validator status via useIsValidator (async) and treats undefined
as false, temporarily showing nominator unbonding for validators and duplicating work already done
in useSoloStakingInfo.
Code

packages/extension-polkagate/src/hooks/useStakingInfoSolo.ts[R16-20]

+import useSelectedAccount from './useSelectedAccount';
+import useIsValidator from './useIsValidator';

export interface StatsSolo {
  value: number | BN | undefined;
Evidence
useStakingInfoSolo calls useIsValidator(...) and immediately uses it in a ternary, but
useIsValidator only sets state after an async validators.keys() call, so its initial undefined
is treated as false. Separately, useSoloStakingInfo already calls useIsValidator and exposes
isValidator on the returned stakingInfo object.

packages/extension-polkagate/src/hooks/useStakingInfoSolo.ts[26-46]
packages/extension-polkagate/src/hooks/useIsValidator.ts[9-29]
packages/extension-polkagate/src/hooks/useSoloStakingInfo.ts[166-176]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`useStakingInfoSolo` introduces a new validator-status fetch that starts as `undefined` and later resolves, which can briefly show the wrong unbonding duration; it also repeats the validator lookup already computed by `useSoloStakingInfo`.

### Issue Context
`useIsValidator` currently calls `api.query.staking.validators.keys()` and then checks inclusion, which is heavier than necessary and is now triggered on the info screens.

### Fix Focus Areas
- packages/extension-polkagate/src/hooks/useStakingInfoSolo.ts[26-47]
- packages/extension-polkagate/src/hooks/useIsValidator.ts[9-29]
- packages/extension-polkagate/src/hooks/useSoloStakingInfo.ts[166-176]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


7. Locale JSON missing final newline 📘 Rule violation ⚙ Maintainability
Description
Several modified locale translation.json files now end without a trailing newline, which is a
formatting-only change unrelated to the requested behavior change. This can introduce noisy diffs
and tooling/lint issues.
Code

packages/extension/public/locales/de/translation.json[985]

+}
Evidence
The rule prohibits unrelated formatting-only edits adjacent to the requested change. The diff
explicitly shows \ No newline at end of file for several locale files, indicating a non-functional
formatting change.

Rule 660840: Avoid unrelated changes to adjacent code and formatting
packages/extension/public/locales/de/translation.json[985-985]
packages/extension/public/locales/es/translation.json[985-985]
packages/extension/public/locales/fr/translation.json[985-985]
packages/extension/public/locales/hi/translation.json[985-985]
packages/extension/public/locales/pt/translation.json[985-985]
packages/extension/public/locales/ru/translation.json[985-985]
packages/extension/public/locales/zh/translation.json[985-985]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Multiple locale `translation.json` files were modified to remove the final newline (reported as `\ No newline at end of file`). This is an unrelated formatting change.

## Issue Context
The PR's goal is functional (reduce unstaking period / remove deprecated fast unstaking). Trailing newline removal is not necessary for these changes and creates avoidable diff noise.

## Fix Focus Areas
- packages/extension/public/locales/de/translation.json[985-985]
- packages/extension/public/locales/es/translation.json[985-985]
- packages/extension/public/locales/fr/translation.json[985-985]
- packages/extension/public/locales/hi/translation.json[985-985]
- packages/extension/public/locales/pt/translation.json[985-985]
- packages/extension/public/locales/ru/translation.json[985-985]
- packages/extension/public/locales/zh/translation.json[985-985]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Qodo Logo

Comment thread packages/extension/package.json
Comment thread packages/extension/public/locales/de/translation.json
Comment on lines 35 to 38
const nominatorFastUnbondDuration = apiAt.consts['staking']['nominatorFastUnbondDuration'].toPrimitive() as number;
const sessionsPerEra = apiAt.consts['staking']['sessionsPerEra'].toPrimitive() as number;

const { epochDuration, expectedBlockTime, maxNominations } = stakingConsts;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Action required

5. Staking const cache mismatch 🐞 Bug ☼ Reliability

useStakingConsts unconditionally reads apiAt.consts.staking.nominatorFastUnbondDuration and
caches the result; existing localStorage entries (or chains lacking the const) can yield missing
nominatorUnbondingDuration until the cache refreshes, breaking consumers.
Agent Prompt
### Issue description
`useStakingConsts` assumes `nominatorFastUnbondDuration` always exists and also trusts the cached localStorage object schema. When the cached object predates the new `nominatorUnbondingDuration` field (or the chain doesn’t expose the new const), consumers may see `undefined` values.

### Issue Context
The hook only refreshes cached consts when `eraIndex` changes. After an app upgrade, the era may not change immediately, so stale cached data can persist.

### Fix Focus Areas
- packages/extension-polkagate/src/hooks/useStakingConsts.ts[22-99]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

const redeemDate = useMemo(() => {
if (stakingInfo.stakingConsts) {
const date = Date.now() + stakingInfo.stakingConsts?.unbondingDuration * 24 * 60 * 60 * 1000;
const date = Date.now() + stakingInfo.stakingConsts?.nominatorUnbondingDuration * 24 * 60 * 60 * 1000;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Remediation recommended

6. Pool redeem date nan 🐞 Bug ≡ Correctness

useUnstakingPool computes redeemDate from stakingConsts.nominatorUnbondingDuration without
validating it, so a missing/invalid value produces an “Invalid Date” string.
Agent Prompt
### Issue description
`redeemDate` is computed using `nominatorUnbondingDuration` without checking it is defined/finite. If it is missing (e.g., stale cached stakingConsts), `Date.now() + undefined * ...` becomes `NaN`.

### Issue Context
`stakingInfo.stakingConsts` comes from `useStakingConsts`, which may return cached values.

### Fix Focus Areas
- packages/extension-polkagate/src/hooks/useStakingApi/useUnstakingPool.ts[45-53]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment on lines 16 to 20
import useSelectedAccount from './useSelectedAccount';
import useIsValidator from './useIsValidator';

export interface StatsSolo {
value: number | BN | undefined;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Remediation recommended

7. Validator duration flicker 🐞 Bug ➹ Performance

useStakingInfoSolo re-queries validator status via useIsValidator (async) and treats undefined
as false, temporarily showing nominator unbonding for validators and duplicating work already done
in useSoloStakingInfo.
Agent Prompt
### Issue description
`useStakingInfoSolo` introduces a new validator-status fetch that starts as `undefined` and later resolves, which can briefly show the wrong unbonding duration; it also repeats the validator lookup already computed by `useSoloStakingInfo`.

### Issue Context
`useIsValidator` currently calls `api.query.staking.validators.keys()` and then checks inclusion, which is heavier than necessary and is now triggered on the info screens.

### Fix Focus Areas
- packages/extension-polkagate/src/hooks/useStakingInfoSolo.ts[26-47]
- packages/extension-polkagate/src/hooks/useIsValidator.ts[9-29]
- packages/extension-polkagate/src/hooks/useSoloStakingInfo.ts[166-176]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

path: '/solo/:genesisHash/pendingReward',
trigger: 'solo-stake-pending-rewards'
},
{

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Action required

3. Broken fastunstake navigation 🐞 Bug ≡ Correctness

Solo staking popup still navigates to /solo/:genesisHash/fastUnstake, but the route was removed
from STAKING_ROUTES, so the button leads to an unhandled path.
Agent Prompt
### Issue description
The `/solo/:genesisHash/fastUnstake` route was removed, but the Solo staking UI still renders a “Fast Unstake” button and navigates to that route, causing broken navigation.

### Issue Context
Fast-unstake appears to be deprecated/removed in this PR; remaining entrypoints should be removed (or the route/component restored).

### Fix Focus Areas
- packages/extension-polkagate/src/popup/staking/solo-new/index.tsx[70-114]
- packages/extension-ui/src/Popup/routes/stakingRoutes.ts[83-128]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

/>
);

case StakingPopUps.FAST_UNSTAKE:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Action required

4. Fullscreen fast_unstake dead 🐞 Bug ≡ Correctness

Fullscreen staking still opens StakingPopUps.FAST_UNSTAKE, but PopUpHandlerSolo no longer
handles that enum value, so clicking it results in an empty popup state.
Agent Prompt
### Issue description
The fullscreen UI still exposes a FAST_UNSTAKE action, but the popup handler no longer renders anything for it, creating a dead interaction.

### Issue Context
This PR removes deprecated fast-unstake. Fullscreen UI should not offer a FAST_UNSTAKE popup unless it is implemented.

### Fix Focus Areas
- packages/extension-polkagate/src/fullscreen/stake/partials/StakingPortfolioAndTiles.tsx[162-189]
- packages/extension-polkagate/src/fullscreen/stake/util/utils.ts[22-40]
- packages/extension-polkagate/src/fullscreen/stake/new-solo/PopUpHandlerSolo.tsx[33-137]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/extension-polkagate/src/hooks/useStakingConsts.ts (1)

76-84: 🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

Stale localStorage cache will lack nominatorUnbondingDuration, causing NaN/undefined downstream.

Old cached StakingConsts (saved before this PR) won't have nominatorUnbondingDuration. Fresh consts are only fetched when eraIndex !== savedConsts?.eraIndex (line 93), so if the era hasn't advanced since the last cache, the stale object is returned with nominatorUnbondingDuration as undefined. This causes:

  • useUnstakingPool line 47: undefined * 24 * 60 * 60 * 1000NaN → "Invalid Date" in the unstaking confirmation flow
  • stakingInfo/index.tsx lines 118-119: "undefined days" in the info text
  • useStakingInfoSolo line 42: undefined value for nominators

The issue self-corrects within one era (~24h on Polkadot), but affects the unstaking transaction UI in the interim.

🛡️ Proposed fix: invalidate stale cache entries missing the new field
     if (localSavedStakingConsts) {
       const parsedConsts = JSON.parse(localSavedStakingConsts) as StakingConsts;
+
+      // Invalidate stale cache entries that predate nominatorUnbondingDuration
+      if (parsedConsts.nominatorUnbondingDuration === undefined) {
+        window.localStorage.removeItem(`${chainName}_stakingConsts`);
+        return;
+      }
+
       parsedConsts.existentialDeposit = new BN(parsedConsts.existentialDeposit);
       parsedConsts.minNominatorBond = new BN(parsedConsts.minNominatorBond);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/extension-polkagate/src/hooks/useStakingConsts.ts` around lines 76 -
84, The cached staking consts in useStakingConsts can be stale because older
localStorage entries do not include nominatorUnbondingDuration, so the hook
should invalidate or refresh any parsed cache missing that field before calling
setSavedConsts. Update the useStakingConsts cache-read path to detect missing
nominatorUnbondingDuration on the parsed StakingConsts and treat it like an
invalid cache entry, forcing a refetch of fresh staking consts rather than
returning the stale object.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/extension-polkagate/src/hooks/useStakingConsts.ts`:
- Line 35: The direct access to nominatorFastUnbondDuration in getStakingConsts
can fail on runtimes that do not expose the async staking constant, so guard
this lookup in useStakingConsts and fall back to bondingDuration or omit the
field when it is missing. Update the staking-const collection logic so the rest
of the constants still resolve even if nominatorFastUnbondDuration is
unavailable.

In `@packages/extension-polkagate/src/hooks/useStakingInfoSolo.ts`:
- Around line 29-30: The `useStakingInfoSolo` hook is currently deriving
`isValidator` from `useSelectedAccount()`, which can point to the wrong account
when this hook is used for a staking account different from the globally
selected one. Update the hook to derive the validator check from `stakingInfo`
instead, and pass that account’s address into `useIsValidator` alongside
`genesisHash` so the unbonding duration is calculated for the correct staking
account.

---

Outside diff comments:
In `@packages/extension-polkagate/src/hooks/useStakingConsts.ts`:
- Around line 76-84: The cached staking consts in useStakingConsts can be stale
because older localStorage entries do not include nominatorUnbondingDuration, so
the hook should invalidate or refresh any parsed cache missing that field before
calling setSavedConsts. Update the useStakingConsts cache-read path to detect
missing nominatorUnbondingDuration on the parsed StakingConsts and treat it like
an invalid cache entry, forcing a refetch of fresh staking consts rather than
returning the stale object.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: dca91fa7-97ab-41cc-a745-0845602df92b

📥 Commits

Reviewing files that changed from the base of the PR and between be049be and a902d13.

📒 Files selected for processing (23)
  • packages/extension-polkagate/src/fullscreen/stake/new-solo/PopUpHandlerSolo.tsx
  • packages/extension-polkagate/src/fullscreen/stake/new-solo/fastUnstaking/index.tsx
  • packages/extension-polkagate/src/hooks/index.ts
  • packages/extension-polkagate/src/hooks/useIsExposed.ts
  • packages/extension-polkagate/src/hooks/useStakingApi/index.ts
  • packages/extension-polkagate/src/hooks/useStakingApi/useFastUnstaking.ts
  • packages/extension-polkagate/src/hooks/useStakingApi/useUnstakingPool.ts
  • packages/extension-polkagate/src/hooks/useStakingConsts.ts
  • packages/extension-polkagate/src/hooks/useStakingInfoSolo.ts
  • packages/extension-polkagate/src/popup/staking/solo-new/fast-unstake/FastUnstake.tsx
  • packages/extension-polkagate/src/popup/staking/stakingInfo/index.tsx
  • packages/extension-polkagate/src/util/types.ts
  • packages/extension-ui/src/Popup/routes/stakingRoutes.ts
  • packages/extension/package.json
  • packages/extension/public/locales/de/translation.json
  • packages/extension/public/locales/en/translation.json
  • packages/extension/public/locales/es/translation.json
  • packages/extension/public/locales/fr/translation.json
  • packages/extension/public/locales/hi/translation.json
  • packages/extension/public/locales/pt/translation.json
  • packages/extension/public/locales/ru/translation.json
  • packages/extension/public/locales/zh/translation.json
  • packages/extension/src/packageInfo.ts
💤 Files with no reviewable changes (9)
  • packages/extension-polkagate/src/hooks/useStakingApi/index.ts
  • packages/extension-polkagate/src/hooks/index.ts
  • packages/extension-polkagate/src/fullscreen/stake/new-solo/fastUnstaking/index.tsx
  • packages/extension-polkagate/src/hooks/useStakingApi/useFastUnstaking.ts
  • packages/extension-polkagate/src/hooks/useIsExposed.ts
  • packages/extension-ui/src/Popup/routes/stakingRoutes.ts
  • packages/extension-polkagate/src/fullscreen/stake/new-solo/PopUpHandlerSolo.tsx
  • packages/extension-polkagate/src/popup/staking/solo-new/fast-unstake/FastUnstake.tsx
  • packages/extension/public/locales/en/translation.json

const existentialDepositString = apiAt.consts['balances']['existentialDeposit'].toString();
const existentialDeposit = new BN(existentialDepositString);
const bondingDuration = apiAt.consts['staking']['bondingDuration'].toPrimitive() as number;
const nominatorFastUnbondDuration = apiAt.consts['staking']['nominatorFastUnbondDuration'].toPrimitive() as number;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Search for references to nominatorFastUnbondDuration and related fast-unbond constants
rg -n "nominatorFastUnbondDuration\|fastUnbond\|FastUnbond" --type ts -C 3

# Check for chain definitions or runtime version gating
rg -n "chain.*runtime\|runtime.*version\|specVersion" --type ts -g '!**/node_modules/**' -C 2 | head -40

Repository: PolkaGate/extension

Length of output: 157


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Locate the hook and inspect its surrounding implementation
git ls-files 'packages/extension-polkagate/src/hooks/useStakingConsts.ts'
wc -l packages/extension-polkagate/src/hooks/useStakingConsts.ts
cat -n packages/extension-polkagate/src/hooks/useStakingConsts.ts | sed -n '1,220p'

# Find any runtime/version gating or fallback handling around staking consts
rg -n "nominatorFastUnbondDuration|stakingConsts|getStakingConsts|consts\\['staking'\\]|consts\\.staking|tryCatch|catch" packages/extension-polkagate/src -C 3

# Search for supported chain/runtime detection in the package
rg -n "specVersion|runtimeVersion|chain.*runtime|runtime.*chain|supported chain|supports.*staking" packages/extension-polkagate/src -C 3

Repository: PolkaGate/extension

Length of output: 50376


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect the staking const hook in a bounded slice
wc -l packages/extension-polkagate/src/hooks/useStakingConsts.ts
cat -n packages/extension-polkagate/src/hooks/useStakingConsts.ts | sed -n '1,220p'

# Show any nearby runtime checks or defensive access around the new constant
rg -n "nominatorFastUnbondDuration|staking.*const|consts\\['staking'\\]|consts\\.staking|unwrapOr|isNone|option|catch" packages/extension-polkagate/src/hooks/useStakingConsts.ts packages/extension-polkagate/src -C 2

# Find supported chain lists / staking-capable chain metadata in the package
rg -n "supported.*chain|staking.*supported|is.*staking|nominate|bond|unbond|validator" packages/extension-polkagate/src -g '!**/*.map' -C 2 | head -120

Repository: PolkaGate/extension

Length of output: 50376


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Read the staking const hook with line numbers in a narrow slice
sed -n '1,180p' packages/extension-polkagate/src/hooks/useStakingConsts.ts | nl -ba

# Find where this hook is consumed and whether callers already expect null/fallback behavior
rg -n "useStakingConsts\\(" packages/extension-polkagate/src -C 2
rg -n "stakingConsts" packages/extension-polkagate/src -C 2

# Check whether the same staking constants pattern is used elsewhere without guards
rg -n "consts\\['staking'\\]\\['(historyDepth|maxUnlockingChunks|bondingDuration|sessionsPerEra|maxExposurePageSize)'" packages/extension-polkagate/src -C 2

Repository: PolkaGate/extension

Length of output: 197


🌐 Web query:

Polkadot staking pallet nominatorFastUnbondDuration runtime constant supported chains older runtimes

💡 Result:

The NominatorFastUnbondDuration runtime constant is a configuration parameter introduced in the pallet-staking-async module of the Polkadot SDK [1][2]. Key Technical Details: - Purpose: It defines the number of eras that pure (non-slashable) nominators must wait to unbond their funds [1][3]. - Mechanism: When the runtime flag AreNominatorsSlashable is set to false, nominators who have not recently acted as validators can utilize this shortened unbonding duration instead of the standard BondingDuration [1][4]. - Usage: If a nominator is slashable, or has recently served as a validator, they remain subject to the full BondingDuration to ensure slashes can be applied during the unbonding period [1][5]. - Recommendation: The recommended value is typically 2 eras [6][2]. Compatibility and Older Runtimes: - Availability: This constant is specific to pallet-staking-async [1][2]. It is not present in the traditional pallet-staking used in older Polkadot/Substrate runtimes. - Support: Chains utilizing standard, older versions of the staking pallet do not support this constant [2]. Migrating to the newer pallet-staking-async architecture is required to leverage this feature [2]. - Implementation: It was integrated into the Polkadot SDK via PR #10502, which was merged in January 2026 [2]. Consequently, it is only available in runtimes built on SDK versions released after this timeframe [2]. Top Results: [1][2][4][5]

Citations:


Guard nominatorFastUnbondDuration with a fallback — this constant only exists on pallet-staking-async; older staking runtimes don’t expose it, so this direct access can make getStakingConsts fail and clear the full staking const set for that chain. Fallback to bondingDuration or skip the field when it’s absent.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/extension-polkagate/src/hooks/useStakingConsts.ts` at line 35, The
direct access to nominatorFastUnbondDuration in getStakingConsts can fail on
runtimes that do not expose the async staking constant, so guard this lookup in
useStakingConsts and fall back to bondingDuration or omit the field when it is
missing. Update the staking-const collection logic so the rest of the constants
still resolve even if nominatorFastUnbondDuration is unavailable.

Comment on lines +29 to +30
const address = useSelectedAccount()?.address;
const isValidator = useIsValidator(address, genesisHash);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Find all callers of useStakingInfoSolo to verify stakingInfo is always for the selected account
rg -n "useStakingInfoSolo" --type ts -C 5 -g '!**/useStakingInfoSolo.ts'

Repository: PolkaGate/extension

Length of output: 157


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo '=== locate hook file ==='
fd -a 'useStakingInfoSolo.ts' .

echo '=== search broader references ==='
rg -n --hidden --glob '!**/node_modules/**' --glob '!**/dist/**' --glob '!**/build/**' 'useStakingInfoSolo|useStakingInfoSolo\s*\(' .

echo '=== search stakingInfo-related hook imports/calls in extension package ==='
rg -n --hidden --glob '!**/node_modules/**' --glob '!**/dist/**' --glob '!**/build/**' 'useStakingInfo|stakingInfo' packages/extension-polkagate/src

Repository: PolkaGate/extension

Length of output: 33774


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo '=== hook implementation ==='
sed -n '1,220p' packages/extension-polkagate/src/hooks/useStakingInfoSolo.ts

echo '=== fullscreen new-solo Info ==='
sed -n '1,220p' packages/extension-polkagate/src/fullscreen/stake/new-solo/Info.tsx

echo '=== fullscreen new-solo parent ==='
sed -n '1,220p' packages/extension-polkagate/src/fullscreen/stake/new-solo/index.tsx

echo '=== popup solo Info ==='
sed -n '1,180p' packages/extension-polkagate/src/popup/staking/solo-new/Info.tsx

Repository: PolkaGate/extension

Length of output: 12448


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo '=== useIsValidator ==='
sed -n '1,220p' packages/extension-polkagate/src/hooks/useIsValidator.ts

echo '=== useSoloStakingInfo ==='
sed -n '1,220p' packages/extension-polkagate/src/hooks/useSoloStakingInfo.ts

echo '=== search SoloStakingInfo validator-related fields/usages ==='
rg -n --hidden --glob '!**/node_modules/**' --glob '!**/dist/**' --glob '!**/build/**' 'isValidator|validator' packages/extension-polkagate/src/hooks/useSoloStakingInfo.ts packages/extension-polkagate/src -g '!**/useIsValidator.ts'

Repository: PolkaGate/extension

Length of output: 50375


🏁 Script executed:

#!/bin/bash
set -euo pipefail

rg -n --hidden --glob '!**/node_modules/**' --glob '!**/dist/**' --glob '!**/build/**' '/fullscreen-stake/solo/|fullscreenURL=.*solo|fullscreen-stake/pool' packages/extension-polkagate/src

Repository: PolkaGate/extension

Length of output: 4780


Derive isValidator from stakingInfo, not useSelectedAccount(). This hook can be rendered for a staking account that differs from the globally selected one, so the unbonding duration may be shown for the wrong address.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/extension-polkagate/src/hooks/useStakingInfoSolo.ts` around lines 29
- 30, The `useStakingInfoSolo` hook is currently deriving `isValidator` from
`useSelectedAccount()`, which can point to the wrong account when this hook is
used for a staking account different from the globally selected one. Update the
hook to derive the validator check from `stakingInfo` instead, and pass that
account’s address into `useIsValidator` alongside `genesisHash` so the unbonding
duration is calculated for the correct staking account.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/extension-polkagate/src/hooks/useIsValidator.ts`:
- Around line 15-23: Update the useEffect containing the validators query to
track cancellation during each invocation and return cleanup that marks the
invocation inactive. Only call setIsValidator for responses from the active
invocation, while preserving the existing query and error handling behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: aa231175-0139-482a-8635-1ecece1d0c04

📥 Commits

Reviewing files that changed from the base of the PR and between 78ff7c2 and e154218.

📒 Files selected for processing (2)
  • packages/extension-polkagate/src/hooks/useIsValidator.ts
  • packages/extension-polkagate/src/hooks/useStakingInfoSolo.ts

Comment on lines 15 to +23
useEffect(() => {
if (!api || !address) {
if (!api || !formatted) {
return;
}

api.query['staking']['validators'].keys().then((intentions) => {
const isValidator = intentions
.map(({ args }: { args: any[] }) => args[0].toString())
.includes(formatted);

setIsValidator(isValidator);
api.query['staking']['validators'](formatted).then((prefs: { isStorageFallback?: boolean }) => {
setIsValidator(!prefs.isStorageFallback);
}).catch(console.error);
}, [address, api, formatted]);
}, [api, formatted]);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Add cleanup to prevent stale async responses.

The effect has no cleanup function. If formatted changes while a query is in-flight, the old promise can resolve after the new one, leaving isValidator set for the wrong address until the next account switch.

🔒 Suggested fix: ignore stale responses with a cancelled flag
   useEffect(() => {
     if (!api || !formatted) {
       return;
     }
 
-    api.query['staking']['validators'](formatted).then((prefs: { isStorageFallback?: boolean }) => {
-      setIsValidator(!prefs.isStorageFallback);
-    }).catch(console.error);
+    let cancelled = false;
+
+    api.query['staking']['validators'](formatted).then((prefs: { isStorageFallback?: boolean }) => {
+      if (!cancelled) {
+        setIsValidator(!prefs.isStorageFallback);
+      }
+    }).catch(console.error);
+
+    return () => { cancelled = true; };
   }, [api, formatted]);
📝 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
useEffect(() => {
if (!api || !address) {
if (!api || !formatted) {
return;
}
api.query['staking']['validators'].keys().then((intentions) => {
const isValidator = intentions
.map(({ args }: { args: any[] }) => args[0].toString())
.includes(formatted);
setIsValidator(isValidator);
api.query['staking']['validators'](formatted).then((prefs: { isStorageFallback?: boolean }) => {
setIsValidator(!prefs.isStorageFallback);
}).catch(console.error);
}, [address, api, formatted]);
}, [api, formatted]);
useEffect(() => {
if (!api || !formatted) {
return;
}
let cancelled = false;
api.query['staking']['validators'](formatted).then((prefs: { isStorageFallback?: boolean }) => {
if (!cancelled) {
setIsValidator(!prefs.isStorageFallback);
}
}).catch(console.error);
return () => { cancelled = true; };
}, [api, formatted]);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/extension-polkagate/src/hooks/useIsValidator.ts` around lines 15 -
23, Update the useEffect containing the validators query to track cancellation
during each invocation and return cleanup that marks the invocation inactive.
Only call setIsValidator for responses from the active invocation, while
preserving the existing query and error handling behavior.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/extension-polkagate/src/popup/staking/solo-new/index.tsx (1)

73-73: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Remove the now-unused onFastUnstake callback.

onFastUnstake is dead code — the Fast Unstake button that referenced it was removed from the buttons array. Per coding guidelines, remove variables and functions made unused by your changes.

🗑️ Proposed fix
-  const onFastUnstake = useCallback(() => navigate('/solo/' + genesisHash + '/fastUnstake') as void, [genesisHash, navigate]);
   const onUnstake = useCallback(() => navigate('/solo/' + genesisHash + '/unstake') as void, [genesisHash, navigate]);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/extension-polkagate/src/popup/staking/solo-new/index.tsx` at line
73, Remove the unused onFastUnstake callback from the solo staking component,
including its useCallback definition and dependencies, since no remaining button
references it.

Source: Coding guidelines

🧹 Nitpick comments (1)
packages/extension-polkagate/src/popup/staking/solo-new/index.tsx (1)

45-45: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Remove the unused api destructuringapi is no longer referenced in packages/extension-polkagate/src/popup/staking/solo-new/index.tsx, so drop it from useChainInfo(genesisHash).

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/extension-polkagate/src/popup/staking/solo-new/index.tsx` at line
45, Update the useChainInfo destructuring in the staking component to remove the
unused api variable, retaining only the decimal and token values used by the
component.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@packages/extension-polkagate/src/popup/staking/solo-new/index.tsx`:
- Line 73: Remove the unused onFastUnstake callback from the solo staking
component, including its useCallback definition and dependencies, since no
remaining button references it.

---

Nitpick comments:
In `@packages/extension-polkagate/src/popup/staking/solo-new/index.tsx`:
- Line 45: Update the useChainInfo destructuring in the staking component to
remove the unused api variable, retaining only the decimal and token values used
by the component.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 1973e101-c305-4283-b698-2e829c45db39

📥 Commits

Reviewing files that changed from the base of the PR and between e154218 and 47fe1f5.

📒 Files selected for processing (12)
  • packages/extension-polkagate/src/fullscreen/stake/partials/StakingPortfolioAndTiles.tsx
  • packages/extension-polkagate/src/fullscreen/stake/util/utils.ts
  • packages/extension-polkagate/src/hooks/useIsValidator.ts
  • packages/extension-polkagate/src/popup/staking/solo-new/index.tsx
  • packages/extension/public/locales/de/translation.json
  • packages/extension/public/locales/en/translation.json
  • packages/extension/public/locales/es/translation.json
  • packages/extension/public/locales/fr/translation.json
  • packages/extension/public/locales/hi/translation.json
  • packages/extension/public/locales/pt/translation.json
  • packages/extension/public/locales/ru/translation.json
  • packages/extension/public/locales/zh/translation.json
💤 Files with no reviewable changes (9)
  • packages/extension/public/locales/zh/translation.json
  • packages/extension/public/locales/de/translation.json
  • packages/extension/public/locales/hi/translation.json
  • packages/extension/public/locales/es/translation.json
  • packages/extension-polkagate/src/fullscreen/stake/util/utils.ts
  • packages/extension/public/locales/ru/translation.json
  • packages/extension/public/locales/en/translation.json
  • packages/extension/public/locales/fr/translation.json
  • packages/extension/public/locales/pt/translation.json
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/extension-polkagate/src/hooks/useIsValidator.ts

@Nick-1979
Nick-1979 merged commit f0786dc into main Jul 11, 2026
7 checks passed
@Nick-1979
Nick-1979 deleted the reducedUnstaking branch July 11, 2026 13:40
github-actions Bot pushed a commit that referenced this pull request Jul 11, 2026
# [2.13.0](v2.12.1...v2.13.0) (2026-07-11)

### Features

* reduce Polkadot unstaking period to 2 days ([#2186](#2186)) ([f0786dc](f0786dc))
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