Repository navigation
fix(receive): handle tokens with unsupported units gracefully - #1036
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
bf252d5 to
b85038c
Compare
|
@jbojcic1 i completely changed the approach to just validate the token in the route loader rather than trying to thread unsupported tokens through the actual receive flow |
There was a problem hiding this comment.
I would call this unsupported cashu token page. The token is not invalid but just not supported by our wallet atm.
| }; | ||
|
|
||
| const cashuProtocolUnitToCurrency: { | ||
| export const cashuProtocolUnitToCurrency: { |
There was a problem hiding this comment.
I would create some validate token method and export that
| loaderData, | ||
| }: Route.ComponentProps) { | ||
| const { token } = loaderData; | ||
| if (!loaderData.valid) { |
There was a problem hiding this comment.
I'd call this loader data property isTokenSupported
a4d8fcf to
13c7eeb
Compare
|
@jbojcic1 I took all your suggestions |
Pasting or deep-linking a Cashu token whose unit isn't sat or usd crashed /receive/cashu/token because tokenToMoney threw synchronously inside render-path hooks. The route loaders now run validateCashuToken right after decode and short-circuit to UnsupportedCashuTokenPage with a reason-specific message. Send flow is unaffected — internally-generated tokens always have a supported unit derived from Currency. validateCashuToken returns a discriminated union so future checks (empty proofs, blocklisted mint, etc.) plug in as additional early-return branches.
13c7eeb to
e2835eb
Compare
On master when a user inputs a token with an unsupported unit the app crashes:
This PR makes the UI handle the error by not building the source account (because we can't convert the token amount to Money) and rendering the error display.
You can test with this token which has a unit of
eur: