Skip to content

Guestbook frontend: use the SDK's token amount helper instead of dividing by 1e7 #2965

Closed

Description

@oceans404

Page: https://developers.stellar.org/docs/build/apps/guestbook/frontend
File: docs/build/apps/guestbook/frontend.mdx:202

What's wrong:
The page tells readers the balance "comes back in stroops, so there's a / 1e7 in the markup". Floating-point division can show rounding errors, and the pattern gets copied into payment code where it matters.

Change needed:
Point readers at the SDK's amount helper for display, and mention its counterpart for parsing user input.

Correct reference:

How to check the fix:

  • The guestbook app on @stellar/stellar-sdk 17.x shows the same balance as before.
  • The page no longer tells readers to divide by 1e7.
  • pnpm validate passes.

Why it matters: No HackMeridian 2026 repo used the SDK's amount helpers; several did float maths on amounts, and two shipped rounding fixes.

Activity

  1. stellar-doxie commented on Nov 1, 2026

    @stellar-doxie
    Contributor

    🤖 Automated message from the Stellar Triage Bot.

    I saw this issue. I have not worked on it, because nobody has called me in yet.

    How to reach me:

    • Anyone with write permission can call me in. Comment /triage, add the bot:take label, or assign @kaankacar, @ElliotFriend or @wmendes.
    • The issue author can send me away with /triage stop. People with write permission can also add the bot:hands-off label.
  2. added
    bot:take
    on Nov 1, 2026
  3. oceans404 commented on Nov 1, 2026

    @oceans404
    ContributorAuthor

    /triage

  4. stellar-doxie commented on Nov 1, 2026

    @stellar-doxie
    Contributor

    🤖 Automated message from the Stellar Triage Bot.

    Working this because @oceans404 added bot:take.

    I am checking the page and the SDK helpers now. I will post the result here.

  5. stellar-doxie commented on Nov 1, 2026

    @stellar-doxie
    Contributor

    🤖 Automated message from the Stellar Triage Bot.

    Working this because @oceans404 added bot:take.

    @kaankacar @ElliotFriend, one decision is needed: should the guestbook page recommend the SDK amount helpers while its companion app still divides by 1e7?

    Facts I checked:

    • The page only describes the markup. The division is in the app: Settings.svelte:122 has parseFloat((Number(balance) / 1e7).toFixed(2)).
    • Soroban.formatTokenAmount and Soroban.parseTokenAmount are exported from @stellar/stellar-sdk in 16.4.1 and 17.4.0. The app pins ^16.3.0.
    • formatTokenAmount(balance, 7) shows all 7 decimals. The app now rounds to 2, so the shown balance changes.
    • The donate flow takes whole tokens through the kit, so the app does not parse user input.

    Options:

    1. Change the app first, then I update the page to match.
    2. Docs only: say the markup converts stroops to XLM, and add a <Tip> that names both helpers for amount math. Page and app stay in sync.
    3. Leave the page as it is.

    I can open the PR for option 1 or 2 when you pick.

  6. added
    bot:needs-decision
    on Nov 1, 2026
  7. removed
    bot:needs-decision
    on Nov 9, 2026
  8. added a commit that references this issue on Nov 10, 2026
    ff2be0d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bot:takejs-sdk-v17

    Type

    No type

    Projects

    • Status
      No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions