fix: i18n hardcoded strings, fee config, and loading states (#694, #6… - #746
Conversation
…world#694, Pi-Defi-world#683, Pi-Defi-world#680, Pi-Defi-world#681) - Replace all hardcoded English strings with t() calls in error-boundary, session-expiry-warning, wallet-setup-modal, wallet/page, savings/page, lending/page (Pi-Defi-world#694, Pi-Defi-world#680) - Add errorBoundary, wallet, savings, lending, session key groups to lib/i18n/locales/en.ts; extend common section with shared labels - Add DEFAULT_FEES constants and networkFee/processingFee fields to useConfig() hook so fee display values come from backend config with safe fallbacks (Pi-Defi-world#683) - Replace undefined MINT_NETWORK_FEE_TEXT / BURN_PROCESSING_FEE_TEXT constants in mint/page.tsx with config-derived values via useConfig(), and swap hardcoded label strings for t('mint.networkFeeLabel') / t('mint.processingFeeLabel')
|
@maisamariwanta-crypto Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
📝 WalkthroughWalkthroughThe PR replaces hardcoded English UI text with i18n keys across lending, savings, wallet, error, and session interfaces. Mint and Burn fee labels and values now use translations and configuration-backed fallbacks. ChangesLocalization and configurable fees
Estimated code review effort: 3 (Moderate) | ~25 minutes Possibly related issues
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 2 | ❌ 3❌ Failed checks (3 warnings)
✅ Passed checks (2 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
⚔️ Resolve merge conflicts
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 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 `@app/lending/page.tsx`:
- Around line 233-236: Replace the English fallback used by the lending page’s
pending sync error flow with an existing translated message/key before passing
it to pendingSyncWithError in app/lending/page.tsx lines 233-236. Also replace
the direct English catch fallback in the wallet setup modal with a translated
message/key in components/wallet-setup-modal.tsx lines 117-119, preserving
backend error messages when available.
In `@hooks/use-config.ts`:
- Around line 22-32: Unify fee fallbacks across the three affected sites: in
hooks/use-config.ts, remove the duplicated English defaults or make them
locale-aware and ensure the processing fallback uses burn/processing wording; in
lib/i18n/locales/en.ts, correct mint.processingFeeValue while keeping the
localized fee keys canonical; in app/mint/page.tsx, update the missing-config
fallback around the mint page fee handling to resolve t('mint.networkFeeValue')
and t('mint.processingFeeValue'), or otherwise make useConfig() locale-aware.
- Around line 114-123: Update the fee extraction in the config hook to validate
that backend network_fee and processing_fee values are non-empty strings before
returning them. Fall back to DEFAULT_FEES.networkFee or
DEFAULT_FEES.processingFee for null, undefined, empty, or non-string values, and
keep the returned fee fields string-safe for rendering.
🪄 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 Plus
Run ID: e5afc407-d8ff-48dc-b81c-57764b8d967c
📒 Files selected for processing (9)
app/lending/page.tsxapp/mint/page.tsxapp/savings/page.tsxapp/wallet/page.tsxcomponents/error-boundary.tsxcomponents/session-expiry-warning.tsxcomponents/wallet-setup-modal.tsxhooks/use-config.tslib/i18n/locales/en.ts
| setWarningMessage( | ||
| errorMessage | ||
| ? `Pending backend sync — backoffice stub captured the submission. (${errorMessage})` | ||
| : 'Pending backend sync — backoffice stub captured the submission.' | ||
| ? t('lending.pendingSyncWithError', { error: errorMessage }) | ||
| : t('lending.pendingSync') |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Keep fallback failures translatable. These flows still construct English fallback errors outside the locale catalog, causing mixed-language error UI when no backend error message is available.
app/lending/page.tsx#L233-L236: replace theBackend sync failedfallback passed intopendingSyncWithErrorwith a translated fallback key.components/wallet-setup-modal.tsx#L117-L119: replace the directInvalid seed or failed to import.catch fallback with a translated message/key.
📍 Affects 2 files
app/lending/page.tsx#L233-L236(this comment)components/wallet-setup-modal.tsx#L117-L119
🤖 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 `@app/lending/page.tsx` around lines 233 - 236, Replace the English fallback
used by the lending page’s pending sync error flow with an existing translated
message/key before passing it to pendingSyncWithError in app/lending/page.tsx
lines 233-236. Also replace the direct English catch fallback in the wallet
setup modal with a translated message/key in components/wallet-setup-modal.tsx
lines 117-119, preserving backend error messages when available.
| /** | ||
| * Default fee values used as fallback when the config API is unavailable | ||
| * or does not return fee information. | ||
| */ | ||
| export const DEFAULT_FEES = { | ||
| /** Network fee shown on the mint form (displayed to user). */ | ||
| networkFee: 'Estimated at confirmation', | ||
| /** Processing fee shown on the burn/redeem form (displayed to user). */ | ||
| processingFee: '0.3% mint fee', | ||
| } as const; | ||
|
|
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Unify the fee fallback contract and correct the burn wording.
The hook’s hardcoded English defaults bypass the new locale values, and the processing fallback incorrectly says “mint fee” even though it is displayed on the burn/redeem form.
hooks/use-config.ts#L22-L32: remove the duplicated English fallback text or make it locale-aware, and change the processing fallback to burn/processing wording.lib/i18n/locales/en.ts#L88-L91: correctprocessingFeeValueand retain these keys as the canonical localized fallbacks.app/mint/page.tsx#L320-L321: resolve missing config values throught('mint.networkFeeValue')andt('mint.processingFeeValue'), or makeuseConfig()locale-aware.
📍 Affects 3 files
hooks/use-config.ts#L22-L32(this comment)lib/i18n/locales/en.ts#L88-L91app/mint/page.tsx#L320-L321
🤖 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 `@hooks/use-config.ts` around lines 22 - 32, Unify fee fallbacks across the
three affected sites: in hooks/use-config.ts, remove the duplicated English
defaults or make them locale-aware and ensure the processing fallback uses
burn/processing wording; in lib/i18n/locales/en.ts, correct
mint.processingFeeValue while keeping the localized fee keys canonical; in
app/mint/page.tsx, update the missing-config fallback around the mint page fee
handling to resolve t('mint.networkFeeValue') and t('mint.processingFeeValue'),
or otherwise make useConfig() locale-aware.
| // Fee values: read from config if the API exposes them, otherwise use defaults. | ||
| // The PublicAssetsConfig type doesn't currently include fee fields, so we | ||
| // defensively cast to access any future fee fields from the backend. | ||
| const configAny = config as Record<string, unknown> | null; | ||
| const networkFee = | ||
| (configAny?.['network_fee'] as string | undefined) ?? DEFAULT_FEES.networkFee; | ||
| const processingFee = | ||
| (configAny?.['processing_fee'] as string | undefined) ?? DEFAULT_FEES.processingFee; | ||
|
|
||
| return { config, loading, error, refresh, networkFee, processingFee }; |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
Validate backend fee values at runtime.
The as string casts do not validate API data, and ?? only handles null/undefined. Empty strings or non-string values can therefore be returned despite the string interface, producing blank/misleading fee rows or a React render failure for object values.
Proposed validation
+const feeOrDefault = (value: unknown, fallback: string) =>
+ typeof value === 'string' && value.trim() !== '' ? value : fallback;
+
const configAny = config as Record<string, unknown> | null;
- const networkFee =
- (configAny?.['network_fee'] as string | undefined) ?? DEFAULT_FEES.networkFee;
- const processingFee =
- (configAny?.['processing_fee'] as string | undefined) ?? DEFAULT_FEES.processingFee;
+ const networkFee = feeOrDefault(
+ configAny?.['network_fee'],
+ DEFAULT_FEES.networkFee,
+ );
+ const processingFee = feeOrDefault(
+ configAny?.['processing_fee'],
+ DEFAULT_FEES.processingFee,
+ );📝 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.
| // Fee values: read from config if the API exposes them, otherwise use defaults. | |
| // The PublicAssetsConfig type doesn't currently include fee fields, so we | |
| // defensively cast to access any future fee fields from the backend. | |
| const configAny = config as Record<string, unknown> | null; | |
| const networkFee = | |
| (configAny?.['network_fee'] as string | undefined) ?? DEFAULT_FEES.networkFee; | |
| const processingFee = | |
| (configAny?.['processing_fee'] as string | undefined) ?? DEFAULT_FEES.processingFee; | |
| return { config, loading, error, refresh, networkFee, processingFee }; | |
| // Fee values: read from config if the API exposes them, otherwise use defaults. | |
| // The PublicAssetsConfig type doesn't currently include fee fields, so we | |
| // defensively cast to access any future fee fields from the backend. | |
| const feeOrDefault = (value: unknown, fallback: string) => | |
| typeof value === 'string' && value.trim() !== '' ? value : fallback; | |
| const configAny = config as Record<string, unknown> | null; | |
| const networkFee = feeOrDefault( | |
| configAny?.['network_fee'], | |
| DEFAULT_FEES.networkFee, | |
| ); | |
| const processingFee = feeOrDefault( | |
| configAny?.['processing_fee'], | |
| DEFAULT_FEES.processingFee, | |
| ); | |
| return { config, loading, error, refresh, networkFee, processingFee }; |
🤖 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 `@hooks/use-config.ts` around lines 114 - 123, Update the fee extraction in the
config hook to validate that backend network_fee and processing_fee values are
non-empty strings before returning them. Fall back to DEFAULT_FEES.networkFee or
DEFAULT_FEES.processingFee for null, undefined, empty, or non-string values, and
keep the returned fee fields string-safe for rendering.
|
@maisamariwanta-crypto fix conflicts |
…83, #680, #681)
Closes #680
Closes #681
Closes #683
Closes #694
Description
Why
How to test
Screenshots / Recordings
Checklist
pnpm typecheck && pnpm lint)Summary by CodeRabbit