Skip to content

faucet: validate address and show readable dispense errors#1860

Open
Gmin2 wants to merge 1 commit into
LayerTwo-Labs:masterfrom
Gmin2:faucet-address-validation
Open

faucet: validate address and show readable dispense errors#1860
Gmin2 wants to merge 1 commit into
LayerTwo-Labs:masterfrom
Gmin2:faucet-address-validation

Conversation

@Gmin2

@Gmin2 Gmin2 commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

two small UX fixes on the faucet form.

  1. address sanity check before sending. an empty or obviously typo'd address (e.g. "notanaddress") used to be sent to the node and come back as a raw 500. now it is caught client-side with an inline message. the check is deliberately loose (bech32 / base58 shape only, no checksum or network), the node stays the source of truth, so it never rejects a valid address.

  2. readable dispense errors. on failure the form showed Failed to dispense coins: [ConnectError: [internal] dispense coins: -5: ...]. now the connect error is mapped to a short message for the common cases (invalid address, amount out of range, faucet out of funds / rate-limited) with a generic fallback.

verified: tsc, biome and prettier clean; helper logic checked against the actual signet error responses (invalid address, wrong-network address, over-limit amount) and against valid/invalid address samples; page renders against signet.

@octobocto octobocto left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It's possible to extract the message from connect! Not sure of the exact field, but I think it's ConnectError.from(err).message.

For dispenseErrorMessage, set the correct errors directly in the backend instead! Converting the backend error messages is brittle.

@Gmin2
Gmin2 force-pushed the faucet-address-validation branch from f14bfa4 to 7f127f3 Compare July 3, 2026 12:24
@Gmin2

Gmin2 commented Jul 3, 2026

Copy link
Copy Markdown
Contributor Author

thanks, in 7f127f3 dropped dispenseErrorMessage (and the client-side regex) entirely, the frontend now just shows ConnectError.from(err).rawMessage. used rawMessage rather than message so the ui does not get the [code] prefix and also fix the the invalid-address case was falling through to CodeInternal with the raw core string. it now returns a clean CodeInvalidArgument

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.

2 participants