Skip to content

fix: i18n hardcoded strings, fee config, and loading states (#694, #6… - #746

Open
maisamariwanta-crypto wants to merge 1 commit into
Pi-Defi-world:devfrom
maisamariwanta-crypto:fix/i18n-hardcoded-strings-fee-config
Open

fix: i18n hardcoded strings, fee config, and loading states (#694, #6…#746
maisamariwanta-crypto wants to merge 1 commit into
Pi-Defi-world:devfrom
maisamariwanta-crypto:fix/i18n-hardcoded-strings-fee-config

Conversation

@maisamariwanta-crypto

@maisamariwanta-crypto maisamariwanta-crypto commented Jul 27, 2026

Copy link
Copy Markdown

…83, #680, #681)
Closes #680
Closes #681
Closes #683
Closes #694

Description

Why

How to test

Screenshots / Recordings

Checklist

  • Self-reviewed the diff
  • Added or updated tests (if applicable)
  • No new TypeScript or lint errors (pnpm typecheck && pnpm lint)
  • Tested on mobile viewport (if UI change)
  • Accessibility checked (keyboard navigation, screen reader)

Summary by CodeRabbit

  • New Features
    • Added localized text across Lending, Mint, Savings, Wallet, wallet setup, session expiry, and error screens.
    • Added configurable network and processing fee displays with fallback values.
    • Added English translations for new financial, wallet, session, loading, and error messages.
  • Bug Fixes
    • Improved consistency of user-facing validation, error, status, and success messages across supported screens.

…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')
@drips-wave

drips-wave Bot commented Jul 27, 2026

Copy link
Copy Markdown

@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! 🚀

Learn more about application limits

@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The 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.

Changes

Localization and configurable fees

Layer / File(s) Summary
Translation and fee contracts
hooks/use-config.ts, lib/i18n/locales/en.ts
Adds translation groups and exposes configurable network and processing fee values with defaults.
Configurable Mint and Burn fees
app/mint/page.tsx
Passes localized fee labels and configuration-derived values through Mint and Burn forms and tab displays.
Lending interface localization
app/lending/page.tsx
Localizes lending validation, submission messages, fields, statuses, navigation, and application listings.
Savings interface localization
app/savings/page.tsx
Localizes dashboard content, metrics, controls, and goal-creation dialog text.
Wallet page localization
app/wallet/page.tsx
Localizes wallet generation, import, connection flows, errors, headings, controls, and instructional text.
Wallet setup modal localization
components/wallet-setup-modal.tsx
Localizes wallet setup options, validation, synchronization errors, modal content, and import controls.
Shared error and session messages
components/error-boundary.tsx, components/session-expiry-warning.tsx
Localizes error fallback and session-expiration interface text.

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

Possibly related issues

  • Pi-Defi-world/acbu-frontend issue 641 — Covers Mint fee configuration and i18n changes that overlap with this PR.
  • Pi-Defi-world/acbu-frontend issue 680 — Directly addressed by localizing session-expiry warning strings.
  • Pi-Defi-world/acbu-frontend issue 683 — Directly addressed for Mint fee values and labels.
  • Pi-Defi-world/acbu-frontend issue 694 — Directly addressed across the listed pages and components.

Possibly related PRs

Suggested reviewers: junman140

🚥 Pre-merge checks | ✅ 2 | ❌ 3

❌ Failed checks (3 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description summarizes the main changes, but the How to test section is empty and several template sections remain unfilled. Add concrete Description, Why, and step-by-step How to test details, and either fill or remove the optional screenshots/checklist sections.
Linked Issues check ⚠️ Warning The PR covers #680 and #694, but it does not show loading states for #681 or send-page fee updates for #683. Add loading indicators to lending, savings, and send pages, and update send-page fee text to use config-derived values.
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and matches the main change set: i18n cleanup plus fee config and loading-state updates.
Out of Scope Changes check ✅ Passed The changes align with the stated i18n, fee-config, and loading-state work, with no obvious unrelated code additions.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
⚔️ Resolve merge conflicts
  • Resolve merge conflict in branch fix/i18n-hardcoded-strings-fee-config

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.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 8b38817 and ccf6351.

📒 Files selected for processing (9)
  • app/lending/page.tsx
  • app/mint/page.tsx
  • app/savings/page.tsx
  • app/wallet/page.tsx
  • components/error-boundary.tsx
  • components/session-expiry-warning.tsx
  • components/wallet-setup-modal.tsx
  • hooks/use-config.ts
  • lib/i18n/locales/en.ts

Comment thread app/lending/page.tsx
Comment on lines 233 to +236
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')

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

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 the Backend sync failed fallback passed into pendingSyncWithError with a translated fallback key.
  • components/wallet-setup-modal.tsx#L117-L119: replace the direct Invalid 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.

Comment thread hooks/use-config.ts
Comment on lines +22 to +32
/**
* 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;

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 | 🟠 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: correct processingFeeValue and retain these keys as the canonical localized fallbacks.
  • app/mint/page.tsx#L320-L321: resolve missing config values through t('mint.networkFeeValue') and t('mint.processingFeeValue'), or make useConfig() locale-aware.
📍 Affects 3 files
  • hooks/use-config.ts#L22-L32 (this comment)
  • lib/i18n/locales/en.ts#L88-L91
  • app/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.

Comment thread hooks/use-config.ts
Comment on lines +114 to +123
// 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 };

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.

🗄️ 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.

Suggested change
// 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.

@Junman140

Copy link
Copy Markdown
Member

@maisamariwanta-crypto fix conflicts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants