Skip to content

refactor: validators query cache and search handling#520

Open
petar-omni wants to merge 4 commits into
mainfrom
feat/misc
Open

refactor: validators query cache and search handling#520
petar-omni wants to merge 4 commits into
mainfrom
feat/misc

Conversation

@petar-omni
Copy link
Copy Markdown
Contributor

@petar-omni petar-omni commented May 28, 2026

Summary by CodeRabbit

  • New Features

    • Debounced validator search with server-side filtering
    • Infinite-scroll "load more" for validators with loading indicators and improved empty-state messages
    • Pending-approvals banner for specific theme variant
  • Bug Fixes / Improvements

    • Activity selection and related flows now carry full validator details
    • Positions, provider details and pages use validator objects instead of address-only lists
    • Theme/token additions to support warning banner styling
  • Tests

    • Added tests for validator pagination/search and debounced-value hook

Review Change Stack

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 28, 2026

⚠️ No Changeset found

Latest commit: ef0c79a

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 28, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Converts validator loading to an infinite-query offset paginator with per-address cache and search, migrates validator address lists to ValidatorDto across domain types/hooks, refactors provider-details to accept ValidatorDto, adds debounced validator search, and wires load-more pagination through SelectValidator UI and page contexts.

Changes

Validator Infinite Query & Data Shape Refactor

Layer / File(s) Summary
Infinite Query Pagination & Caching Foundation
packages/widget/src/hooks/api/use-yield-validators.ts
Replace single-shot paginated validator loading with useInfiniteQuery. Add per-address query key, bulk resolver getYieldValidatorsByAddresses, offset/page modes (preferred/other/search), per-page cache writes, optional network filtering, dedupe/merge, and next-page cursor logic.
Debounced Search Utility
packages/widget/src/hooks/use-debounced-value.ts, packages/widget/tests/hooks/use-debounced-value.test.tsx
New useDebouncedValue hook delays search updates; tests validate debounce timing behavior.
Domain Types & Token Lookup
packages/widget/src/domain/types/positions.ts, packages/widget/src/domain/types/yields.ts, packages/widget/src/domain/types/action.ts, packages/widget/src/pages/details/activity-page/types.ts
Migrate positions and activity types to carry ValidatorDto objects instead of address strings; remove getYieldMetadataTokens; narrow token candidate lookup in getActionInputToken; extend ActionYieldDto with validatorsData.
Activity Actions Enrichment
packages/widget/src/hooks/api/use-activity-actions.ts, packages/widget/src/providers/activity-provider/index.tsx, packages/widget/src/pages-dashboard/activity/activity.page.tsx
Enrich activity items with validatorsData via bulk resolver, and add selectedValidators to activity context/store and selection payloads.
Provider Details Contract Simplification
packages/widget/src/hooks/use-provider-details.ts
Refactor getProviderDetails to accept validator: Maybe<ValidatorDto> and simplify useProvidersDetails to iterate over provided validators without additional fetching or merge logic.
Positions Data Shape Migration
packages/widget/src/hooks/use-positions-data.ts, packages/widget/src/pages/details/positions-page/hooks/use-positions.ts, packages/widget/src/pages/details/positions-page/hooks/use-position-list-item.ts
Normalize position balance data to include full validators DTO arrays and replace helper getBalanceValidatorAddresses with getBalanceValidators.
SelectValidator Component Pagination Support
packages/widget/src/components/molecules/select-validator/index.tsx, packages/widget/src/components/molecules/select-validator/styles.css.ts
Add isLoading, onLoadMore, hasMore, isLoadingMore props to SelectValidator; compute infiniteScrollProps, return view_more placeholder when appropriate, and render empty-state text based on search. Add emptyState style.
Earn Page Context: Debounced Search & Pagination
packages/widget/src/pages/details/earn-page/state/earn-page-context.tsx, packages/widget/src/pages/details/earn-page/state/types.ts
Add debounced validator search, forward debounced search into useYieldValidators, remove client-side filtering, update loading readiness logic, and expose hasMoreValidators, isLoadingMoreValidators, and onLoadMoreValidators from context.
SelectValidatorSection & Hook Wiring
packages/widget/src/pages/details/earn-page/components/select-validator-section/index.tsx, packages/widget/src/pages/details/earn-page/components/select-validator-section/use-select-validator.ts, packages/widget/src/pages-dashboard/overview/earn-page/utila-select-validator-section.tsx
Update components to use validatorsData.orDefault([]) from context, remove component-level loader, and pass pagination props from useSelectValidator into SelectValidator.
Position Details & Complete Pages Pagination
packages/widget/src/pages/position-details/hooks/use-position-details.ts, packages/widget/src/pages/position-details/position-details.page.tsx, packages/widget/src/pages-dashboard/position-details/components/position-details-actions.tsx, packages/widget/src/pages/complete/pages/pending-complete.page.tsx, packages/widget/src/pages/complete/pages/stake-complete.page.tsx, packages/widget/src/pages/complete/pages/unstake-complete.page.tsx
Expose validator pagination controls from usePositionDetails and forward them to SelectValidator; update complete pages to pass validators DTOs into useProvidersDetails.
Activity & Steps Pages Validator Wiring
packages/widget/src/pages/steps/pages/activity-steps.page.tsx, packages/widget/src/pages/details/activity-page/hooks/use-action-list-item.ts, packages/widget/src/pages/steps/pages/pending-steps.page.tsx, packages/widget/src/pages/steps/pages/stake-steps.page.tsx, packages/widget/src/pages/steps/pages/unstake-steps.page.tsx, packages/widget/src/pages/complete/hooks/use-activity-complete.hook.ts
Change validator sources from address lists to full ValidatorDto arrays or selectedValidators when calling useProvidersDetails; update related imports and selectors.
Tests: pagination, cache hydration & UI
packages/widget/tests/hooks/validator-loading.test.tsx, packages/widget/tests/components/select-validator-section.test.tsx
Add tests verifying preferred-first loading, deferred non-preferred pagination, per-validator cache hydration, server-side search/pagination dedupe, keep-previous-data during search, and SelectValidator empty-state/search retention.
Translations & ancillary updates
packages/widget/src/hooks/use-estimated-rewards.ts, packages/widget/src/pages/details/earn-page/state/use-stake-enter-request-dto.ts, packages/widget/src/translation/English/translations.json, packages/widget/src/translation/French/translations.json
Update hooks to use new validators contract, adjust DTO assembly for provider args, and add validators_empty / validators_no_results translations.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Suggested reviewers

  • jdomingos
  • Philippoes
  • dnehl

"🐰 I nibble keys and debounce the breeze,
Pages fetch in steps and caches appease.
Validators now wear DTO leaves in rows,
Load more carrots, and watch the UI glow.
Hooray for hops and fewer woes!"

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is completely missing. The repository has a defined template with 'Added' and 'Changed' sections, but no description was provided by the author. Add a comprehensive PR description following the template, documenting the new validators caching/pagination infrastructure and modifications to existing functionality throughout the codebase.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'refactor: validators query cache and search handling' directly reflects the main changes in the PR, which comprehensively refactor validators caching, infinite pagination, and search handling across multiple hooks and components.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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 unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/misc

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

@petar-omni petar-omni changed the title Feat/misc refactor: validators query cache and search handling May 28, 2026
@aws-amplify-eu-central-1
Copy link
Copy Markdown

This pull request is automatically being deployed by Amplify Hosting (learn more).

Access this pull request here: https://pr-520.d2ribjy8evqo6h.amplifyapp.com

@aws-amplify-eu-central-1
Copy link
Copy Markdown

This pull request is automatically being deployed by Amplify Hosting (learn more).

Access this pull request here: https://pr-520.df4xyoi0xyeak.amplifyapp.com

Copy link
Copy Markdown

@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: 3

🧹 Nitpick comments (2)
packages/widget/src/domain/types/action.ts (1)

109-120: Confirm action input token resolution no longer relies on yield metadata tokens

  • getYieldMetadataTokens has no definition/usage in this repo, and getActionInputToken (packages/widget/src/domain/types/action.ts, ~lines 109-120) searches only yieldDto.token / yieldDto.tokens, with fallback to yieldDto.token ?? yieldDto.tokens?.[0].
  • yieldDto.__fallback__.metadata.rewardTokens exists in packages/widget/src/domain/types/yields.ts, but it’s used by getYieldRewardTokens, not by getActionInputToken; so metadata-only reward tokens won’t surface here.
  • If actionDto.rawArguments?.inputToken refers to a token not present in yieldDto.token/yieldDto.tokens, the lookup will silently fall back—consider handling/reporting this mismatch.
🤖 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/widget/src/domain/types/action.ts` around lines 109 - 120, The
current getActionInputToken logic only searches yieldDto.token and
yieldDto.tokens (and then silently falls back to yieldDto.token ??
yieldDto.tokens?.[0]), so actionDto.rawArguments?.inputToken can be missed if it
exists only in yield metadata; update getActionInputToken to also consult
yieldDto.__fallback__?.metadata?.rewardTokens (or a shared
getYieldMetadataTokens helper) when resolving the needle and, if still not
found, surface the mismatch by returning an explicit error/undefined with a
logged warning (or throw) rather than silently falling back; reference
getActionInputToken, yieldDto, actionDto.rawArguments?.inputToken and
yieldDto.__fallback__.metadata.rewardTokens when making the change.
packages/widget/src/components/molecules/select-validator/index.tsx (1)

59-62: ⚡ Quick win

Gate onLoadMore to real next-page availability.

Line 61 currently triggers pagination even when "View all" only reveals already-loaded validators (hasMore is false). Guarding this avoids unnecessary fetch attempts.

♻️ Proposed change
   const _onViewMoreClick = () => {
     onViewMoreClick?.();
-    onLoadMore?.();
+    if (hasMore) {
+      onLoadMore?.();
+    }
     setViewMore(true);
   };
🤖 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/widget/src/components/molecules/select-validator/index.tsx` around
lines 59 - 62, The _onViewMoreClick handler currently always calls onLoadMore
even when no next page exists; update _onViewMoreClick (which calls
onViewMoreClick, onLoadMore, and setViewMore) to check the hasMore flag and only
invoke onLoadMore() when hasMore is true, leaving onViewMoreClick() and
setViewMore(true) to run as before so the UI still reveals already-loaded
validators without triggering unnecessary fetches.
🤖 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/widget/src/hooks/api/use-yield-validators.ts`:
- Around line 190-194: The merged result currently concatenates namePage.items
and addressPage.items which can produce duplicates when a validator matches both
filters; update the merge in the return of the function in
use-yield-validators.ts to deduplicate by validator address (e.g., use a Set
keyed on validator.address or validator.id) so items contains only unique
validators and set total to the unique count (instead of
Math.max(namePage.total, addressPage.total)); ensure you preserve
order/stability as needed when de-duplicating.
- Around line 273-279: The current Promise.all over remainingOffsets (computed
from firstPage.total / PAGE_SIZE) can spawn unbounded concurrent calls to
fetchPage; change this to a controlled concurrency strategy: either process
remainingOffsets in small chunks (e.g., batch size N) or use a concurrency
limiter like p-limit to call fetchPage({ preferred: true, offset }) with at most
N in flight, accumulate results into remainingPages, and preserve order; update
the code around remainingOffsets, remainingPages and fetchPage to use that
throttling approach and make N configurable (or set a sensible default) to avoid
request storms.

In `@packages/widget/src/hooks/use-provider-details.ts`:
- Around line 77-114: The selected-provider branch is incorrectly summing the
provider reward twice and keeps using the outer yieldDto for rewardType; update
the Maybe.chain/map so the selected provider's rewardRate is used once and its
rewardType is derived from that selected yield. Specifically: in the
Maybe.fromRecord(...) chain that uses yields and List.find, change the .map that
currently does v.rewardRate.total + v.rewardRate.total to return the single
selected yield's rewardRate (e.g., v.rewardRate.total) and map to an object
carrying both rewardRate and rewardType computed from the selected yield (use
getYieldRewardType on the found list item), while leaving the .orDefault
fallback as-is (validator.rewardRate?.total and getYieldRewardType(yieldDto)) so
consumer code (rewardRate, rewardType) receives the selected provider values
when present.

---

Nitpick comments:
In `@packages/widget/src/components/molecules/select-validator/index.tsx`:
- Around line 59-62: The _onViewMoreClick handler currently always calls
onLoadMore even when no next page exists; update _onViewMoreClick (which calls
onViewMoreClick, onLoadMore, and setViewMore) to check the hasMore flag and only
invoke onLoadMore() when hasMore is true, leaving onViewMoreClick() and
setViewMore(true) to run as before so the UI still reveals already-loaded
validators without triggering unnecessary fetches.

In `@packages/widget/src/domain/types/action.ts`:
- Around line 109-120: The current getActionInputToken logic only searches
yieldDto.token and yieldDto.tokens (and then silently falls back to
yieldDto.token ?? yieldDto.tokens?.[0]), so actionDto.rawArguments?.inputToken
can be missed if it exists only in yield metadata; update getActionInputToken to
also consult yieldDto.__fallback__?.metadata?.rewardTokens (or a shared
getYieldMetadataTokens helper) when resolving the needle and, if still not
found, surface the mismatch by returning an explicit error/undefined with a
logged warning (or throw) rather than silently falling back; reference
getActionInputToken, yieldDto, actionDto.rawArguments?.inputToken and
yieldDto.__fallback__.metadata.rewardTokens when making the change.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 82698f79-d064-4f31-b243-407ab38e5865

📥 Commits

Reviewing files that changed from the base of the PR and between e7229e5 and 360505e.

📒 Files selected for processing (41)
  • packages/widget/src/components/molecules/select-validator/index.tsx
  • packages/widget/src/components/molecules/select-validator/styles.css.ts
  • packages/widget/src/domain/types/action.ts
  • packages/widget/src/domain/types/positions.ts
  • packages/widget/src/domain/types/yields.ts
  • packages/widget/src/hooks/api/use-activity-actions.ts
  • packages/widget/src/hooks/api/use-yield-validators.ts
  • packages/widget/src/hooks/use-debounced-value.ts
  • packages/widget/src/hooks/use-estimated-rewards.ts
  • packages/widget/src/hooks/use-positions-data.ts
  • packages/widget/src/hooks/use-provider-details.ts
  • packages/widget/src/hooks/use-summary.tsx
  • packages/widget/src/pages-dashboard/activity/activity.page.tsx
  • packages/widget/src/pages-dashboard/overview/earn-page/utila-select-validator-section.tsx
  • packages/widget/src/pages-dashboard/position-details/components/position-details-actions.tsx
  • packages/widget/src/pages/complete/hooks/use-activity-complete.hook.ts
  • packages/widget/src/pages/complete/pages/pending-complete.page.tsx
  • packages/widget/src/pages/complete/pages/stake-complete.page.tsx
  • packages/widget/src/pages/complete/pages/unstake-complete.page.tsx
  • packages/widget/src/pages/details/activity-page/hooks/use-action-list-item.ts
  • packages/widget/src/pages/details/activity-page/state/activity-page.context.tsx
  • packages/widget/src/pages/details/activity-page/types.ts
  • packages/widget/src/pages/details/earn-page/components/select-validator-section/index.tsx
  • packages/widget/src/pages/details/earn-page/components/select-validator-section/use-select-validator.ts
  • packages/widget/src/pages/details/earn-page/state/earn-page-context.tsx
  • packages/widget/src/pages/details/earn-page/state/types.ts
  • packages/widget/src/pages/details/earn-page/state/use-stake-enter-request-dto.ts
  • packages/widget/src/pages/details/positions-page/hooks/use-position-list-item.ts
  • packages/widget/src/pages/details/positions-page/hooks/use-positions.ts
  • packages/widget/src/pages/position-details/hooks/use-position-details.ts
  • packages/widget/src/pages/position-details/position-details.page.tsx
  • packages/widget/src/pages/steps/pages/activity-steps.page.tsx
  • packages/widget/src/pages/steps/pages/pending-steps.page.tsx
  • packages/widget/src/pages/steps/pages/stake-steps.page.tsx
  • packages/widget/src/pages/steps/pages/unstake-steps.page.tsx
  • packages/widget/src/providers/activity-provider/index.tsx
  • packages/widget/src/translation/English/translations.json
  • packages/widget/src/translation/French/translations.json
  • packages/widget/tests/components/select-validator-section.test.tsx
  • packages/widget/tests/hooks/use-debounced-value.test.tsx
  • packages/widget/tests/hooks/validator-loading.test.tsx
💤 Files with no reviewable changes (1)
  • packages/widget/src/domain/types/yields.ts

Comment thread packages/widget/src/hooks/api/use-yield-validators.ts
Comment thread packages/widget/src/hooks/api/use-yield-validators.ts
Comment thread packages/widget/src/hooks/use-provider-details.ts
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 28, 2026

Actionable comments posted: 0

Copy link
Copy Markdown

@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

♻️ Duplicate comments (1)
packages/widget/src/hooks/use-provider-details.ts (1)

86-106: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

rewardType should be derived from the selected provider yield, not yieldDto.

The doubling bug is fixed, but when a selected provider yield is found (line 83), the rewardType should come from that selected yield rather than the outer yieldDto. Currently both line 90 and line 106 use getYieldRewardType(yieldDto), which returns incorrect reward type data for provider-backed validator details.

🐛 Proposed fix
         .chain(({ selectedProviderYieldId }) =>
           yields.chain((list) =>
             List.find((v) => v.id === selectedProviderYieldId, [...list])
           )
         )
-        .map((v) => v.rewardRate.total)
-        .map<{ rewardRate: number | undefined; rewardType: RewardTypes }>(
-          (res) => ({
-            rewardRate: res,
-            rewardType: getYieldRewardType(yieldDto),
+        .map<{ rewardRate: number | undefined; rewardType: RewardTypes }>(
+          (selectedYield) => ({
+            rewardRate: selectedYield.rewardRate.total,
+            rewardType: getYieldRewardType(selectedYield),
           })
         )
         .orDefault({
           rewardRate: validator.rewardRate?.total,
           rewardType: getYieldRewardType(yieldDto),
         });

       return {
         logo: validator.logoURI,
         name: validator.name ?? validator.address,
         rewardRateFormatted: getRewardRateFormatted({
           rewardRate,
           rewardType,
         }),
         rewardRate,
-        rewardType: getYieldRewardType(yieldDto),
+        rewardType,
         address: validator.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/widget/src/hooks/use-provider-details.ts` around lines 86 - 106, The
rewardType is incorrectly being derived from yieldDto everywhere; change it to
derive from the selected provider yield when present. Replace usages of
getYieldRewardType(yieldDto) in the map that builds {rewardRate, rewardType}, in
the orDefault block, and in the returned object so they call
getYieldRewardType(selectedProviderYield) (or compute a single const rewardType
= getYieldRewardType(selectedProviderYield ?? yieldDto) and use that) instead of
getYieldRewardType(yieldDto), ensuring rewardType matches the selected provider
yield.
🧹 Nitpick comments (1)
packages/widget/src/hooks/api/use-yield-validators.ts (1)

299-301: ⚖️ Poor tradeoff

Consider limiting concurrent fetches for remaining preferred pages.

Promise.all over remainingOffsets can fan out many concurrent requests when there are many preferred validators (e.g., 1000 validators = 10 concurrent requests). This could cause rate limiting or cascade latency under high totals.

Consider using a concurrency limiter (e.g., p-limit) or sequential fetching.

🤖 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/widget/src/hooks/api/use-yield-validators.ts` around lines 299 -
301, The current use of Promise.all over remainingOffsets in
use-yield-validators.ts (the remainingPages = await
Promise.all(remainingOffsets.map(offset => fetchPage({ preferred: true, offset
})))) can spawn many concurrent fetchPage calls and cause rate limits; change to
a concurrency-limited approach (e.g., use p-limit or implement a small
batching/sequential loop) to cap concurrent fetchPage executions (suggest 3–5
concurrent requests), keeping the same fetchPage({ preferred: true, offset })
call signature and collecting results into remainingPages in the same order.
🤖 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/widget/src/hooks/api/use-yield-validators.ts`:
- Around line 207-216: The returned total should reflect the server-side totals,
not the deduplicated items length; change the return to set total to
(namePage.total ?? 0) + (addressPage.total ?? 0) (instead of items.length) so
getRawNextOffset can correctly determine if more pages exist; update the return
in the function that calls deduplicateValidatorsByAddress (the block using
namePage, addressPage, items) so pagination logic relying on getRawNextOffset
works properly.

---

Duplicate comments:
In `@packages/widget/src/hooks/use-provider-details.ts`:
- Around line 86-106: The rewardType is incorrectly being derived from yieldDto
everywhere; change it to derive from the selected provider yield when present.
Replace usages of getYieldRewardType(yieldDto) in the map that builds
{rewardRate, rewardType}, in the orDefault block, and in the returned object so
they call getYieldRewardType(selectedProviderYield) (or compute a single const
rewardType = getYieldRewardType(selectedProviderYield ?? yieldDto) and use that)
instead of getYieldRewardType(yieldDto), ensuring rewardType matches the
selected provider yield.

---

Nitpick comments:
In `@packages/widget/src/hooks/api/use-yield-validators.ts`:
- Around line 299-301: The current use of Promise.all over remainingOffsets in
use-yield-validators.ts (the remainingPages = await
Promise.all(remainingOffsets.map(offset => fetchPage({ preferred: true, offset
})))) can spawn many concurrent fetchPage calls and cause rate limits; change to
a concurrency-limited approach (e.g., use p-limit or implement a small
batching/sequential loop) to cap concurrent fetchPage executions (suggest 3–5
concurrent requests), keeping the same fetchPage({ preferred: true, offset })
call signature and collecting results into remainingPages in the same order.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 01dcaf15-88df-41ed-8a3e-aef4f0f317f0

📥 Commits

Reviewing files that changed from the base of the PR and between b23643d and 3f89d93.

📒 Files selected for processing (3)
  • packages/widget/src/hooks/api/use-yield-validators.ts
  • packages/widget/src/hooks/use-provider-details.ts
  • packages/widget/tests/hooks/validator-loading.test.tsx

Comment thread packages/widget/src/hooks/api/use-yield-validators.ts
Copy link
Copy Markdown

@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: 0

Caution

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

⚠️ Outside diff range comments (1)
packages/widget/src/hooks/api/use-yield-validators.ts (1)

106-110: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Avoid caching { address } fallback placeholders forever in getYieldValidatorsByAddresses (lines 106-110)

  • { address } still satisfies ValidatorDto because packages/widget/src/generated/api/yield.ts requires only address; the rest of the fields are optional.
  • The issue is behavioral: on “not found” or fetch errors the code returns { address }, and React Query caches it with staleTime: Number.POSITIVE_INFINITY, so later lookups for the same yieldId/address may keep returning an incomplete placeholder indefinitely.
  • Consider not caching the fallback (filter it out), using a finite staleTime for fallback, or distinguishing “not found” from “error”.
🤖 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/widget/src/hooks/api/use-yield-validators.ts` around lines 106 -
110, getYieldValidatorsByAddresses currently returns a placeholder object {
address } on not-found/error which gets cached forever; change the function
(getYieldValidatorsByAddresses) so that when a validator is missing or a fetch
fails you return [address, undefined] (or null) instead of [address, { address
}], and then filter out these undefined/null entries before building the final
result that React Query will cache (or alternatively propagate the error so
react-query treats it as an error); this prevents caching incomplete placeholder
ValidatorDto objects indefinitely and ensures callers handle missing validators
explicitly.
🤖 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/widget/src/hooks/api/use-yield-validators.ts`:
- Around line 106-110: getYieldValidatorsByAddresses currently returns a
placeholder object { address } on not-found/error which gets cached forever;
change the function (getYieldValidatorsByAddresses) so that when a validator is
missing or a fetch fails you return [address, undefined] (or null) instead of
[address, { address }], and then filter out these undefined/null entries before
building the final result that React Query will cache (or alternatively
propagate the error so react-query treats it as an error); this prevents caching
incomplete placeholder ValidatorDto objects indefinitely and ensures callers
handle missing validators explicitly.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 745e8bf7-eda3-4ff3-8571-756f5af45427

📥 Commits

Reviewing files that changed from the base of the PR and between 3f89d93 and 662961f.

📒 Files selected for processing (3)
  • packages/widget/src/hooks/api/use-yield-validators.ts
  • packages/widget/src/hooks/use-provider-details.ts
  • packages/widget/tests/hooks/validator-loading.test.tsx
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/widget/tests/hooks/validator-loading.test.tsx
  • packages/widget/src/hooks/use-provider-details.ts

Copy link
Copy Markdown

@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

🤖 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/widget/src/main.tsx`:
- Around line 20-38: The stub external provider (bittensorExternalProviders with
provider.signMessage, switchChain, sendTransaction returning a fake tx hash)
must be gated by an explicit environment flag; update the code that creates
bittensorExternalProviders so it only assigns the fake provider when a flag like
USE_MOCK_EXTERNAL_PROVIDER (or equivalent config) is truthy, otherwise leave
provider undefined or load the real provider; ensure the fake sendTransaction no
longer runs in production by moving the stub implementation behind that flag
check and return no fake tx hash when the flag is not set.

In `@packages/widget/src/translation/English/translations.json`:
- Around line 261-262: Add matching French translations for the new English keys
to restore localization parity: update the French translations.json to include
entries for "pending_approvals" and "pending_approvals_desc" with appropriate
French copy (e.g., localized strings conveying "Pending approvals" and "Please
open your wallet to review and securely sign the transaction"), ensuring key
names exactly match the English keys so the i18n lookup finds them.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ea8398a6-34a4-4d51-8e21-36cc68fce610

📥 Commits

Reviewing files that changed from the base of the PR and between 662961f and 2994579.

📒 Files selected for processing (8)
  • packages/widget/src/main.tsx
  • packages/widget/src/pages/steps/pages/common.page.tsx
  • packages/widget/src/pages/steps/pages/styles.css.ts
  • packages/widget/src/styles/theme/variant-overrides/utila.ts
  • packages/widget/src/styles/tokens/colors/contract.ts
  • packages/widget/src/styles/tokens/colors/values.ts
  • packages/widget/src/translation/English/translations.json
  • packages/widget/src/translation/French/translations.json
✅ Files skipped from review due to trivial changes (3)
  • packages/widget/src/pages/steps/pages/styles.css.ts
  • packages/widget/src/styles/tokens/colors/values.ts
  • packages/widget/src/translation/French/translations.json

Comment thread packages/widget/src/main.tsx Outdated
Comment thread packages/widget/src/translation/English/translations.json
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