Skip to content

fix(widget): distinguish balance read failures from insufficient funds - #889

Open
BiscuitCoder wants to merge 1 commit into
lifinance:mainfrom
BiscuitCoder:codex/balance-read-error
Open

BiscuitCoder wants to merge 1 commit into
lifinance:mainfrom
BiscuitCoder:codex/balance-read-error

Conversation

@BiscuitCoder

Copy link
Copy Markdown

Which Linear task is linked to this PR?

No Linear task; external bug-fix contribution.

Why was it implemented this way?

The SDK uses LiFiErrorCode.BalanceError both for insufficient funds and for balances it cannot read. The Widget currently maps every such error to “The balance is too low” and a message claiming the requested amount remains in the wallet. An unavailable RPC, missing balance or timeout does not establish either fact.

Recognize the SDK's specific Could not read wallet balance. message within the BalanceError case and show “Could not read wallet balance” / “Your wallet balance could not be checked. Please try again.” Other balance errors and error codes retain their existing behavior.

The execution state only carries the error code and message, not a structured balance-failure reason. The check deliberately matches the SDK message exactly rather than guessing from HTTP statuses or arbitrary provider errors. Regression tests run the installed SDK's CheckBalanceTask with failing, missing, stalled and insufficient balances, then pass its serialized error fields to the Widget. This also detects a future change to the SDK message contract.

English source strings follow the repository's Crowdin workflow. No dependency changes, RPC requests or timeout changes. Includes a Widget patch changeset.

Validation:

  • Before the fix: the RPC rejection, missing-balance and timeout cases failed.
  • After the fix: all 281 Widget tests passed (21 files), including six new regression cases.
  • Widget type check, changed-file Biome check and Changesets status passed.

Visual showcase (Screenshots or Videos)

For an SDK balance read failure:

Before After
Title The balance is too low Could not read wallet balance
Description Transaction was not sent. 1 USDC on Ethereum remain in your wallet. Your wallet balance could not be checked. Please try again.

A confirmed shortfall still uses the existing insufficient-balance message.

Checklist before requesting a review

  • I have performed a self-review and testing of my code.
  • This pull request is focused and addresses a single problem.
  • If this PR modifies the Widget API or adds new features that require documentation, I have updated the documentation in the public-docs repository. (Not applicable: internal bug fix.)

@changeset-bot

changeset-bot Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 2f0b4fc

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@lifi/widget Patch
@lifi/widget-checkout Patch
nft-checkout Patch
tanstack-router-example Patch

Not sure what this means? Click here to learn what changesets are.

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

@BiscuitCoder
BiscuitCoder force-pushed the codex/balance-read-error branch from d268e69 to 2f0b4fc Compare September 29, 2026 15:16

This branch has not been deployed

No deployments
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