Send Soroban token transfer amounts to `/simulate-token-transfer` as strings
Maintainers usually reply within 2 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 85/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- typescript
Research direction
Start in extension/src/popup/components/send/SendAmount/hooks/useSimulateTxData.tsx at the /simulate-token-transfer request and check the request type in @shared/api/internal.ts. Send the parsed base-unit amount as an integer string, then review the simulate-token-transfer stubs in extension/e2e-tests for numeric amount assertions. Done when sending 1.5 units of an 18-decimal token posts "1500000000000000000" and the simulated transfer carries that amount.
Written by the indexing model from the issue text.
Description
Affects sends of high-decimal Soroban tokens today. It also blocks the backend from rejecting unsafe numeric amounts (stellar/freighter-backend#331).
TL;DR: The send flow converts the base-unit amount to a JS number before posting it to /simulate-token-transfer. Anything above Number.MAX_SAFE_INTEGER (~9.007e15) gets rounded in the browser, so the backend builds the transfer from a different amount than the user entered. For an 18-decimal token, that's any send over ~0.009 tokens. Send the amount as an integer string instead. The backend already accepts strings up to the i128 max.
Details
Where:
extension/src/popup/components/send/SendAmount/hooks/useSimulateTxData.tsx:566sendsamount: parsedAmount.toNumber()@shared/api/internal.tstypesparams.amountasnumber
Fix:
- Send
parsedAmount.toFixed()(toFixed()with no argument never switches to exponential notation). - Change the request type to
amount: string. - Update the
simulate-token-transferstubs inextension/e2e-testsif any assert on a numeric amount.
Mobile already does this (BigNumber(amount).shiftedBy(decimals).toFixed(0) in transactionService.ts), so no counterpart is needed.
Related, optional: extension/src/popup/helpers/sorobanSwap.ts:146, :253 and :257 also call .toNumber() on parsed amounts for Soroswap quotes and swap args. That's a different endpoint, but the precision loss is the same.
Acceptance: a send of 1.5 units of an 18-decimal token posts "1500000000000000000", and the simulated transfer carries that exact amount.
Once this release has rolled out, the backend can reject non-safe numeric amounts: stellar/freighter-backend#331 (https://github.com/stellar/freighter-backend/pull/331#discussion_r4542794041).
- Dominant language
- TypeScript
- Stars
- 122
- Forks
- 62
- Avg merge
- 4d 19h
- Merged PRs (30d)
- 41
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from stellar/freighter
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 2 days
-
Write the banner publishing guidePossibly taken @aristidesstaffieri claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
stellar/freighter#3152 · 1 assignee ·
Maintainers usually reply within 2 days
-
Dont call blockaid on empty token listMay be free again A pull request for this issue was closed without being merged. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 2 days
-
follow-up
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 2 days
-
follow-up
Difficulty 1/5 Under an hour Newbie friendliness 84/100
Maintainers usually reply within 2 days
All issues in stellar/freighter
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
tenstorrent/ttnn-visualizer#2526 ·
Maintainers usually reply within 1 day
-
trySessionCache calls /get-session twice when minting session_data (cache miss or expired cookie)Open
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
neondatabase/neon-js#301 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
tashfeenahmed/freellmapi#2305 ·
Maintainers usually reply within 1 day