Skip to content

Sync guestbook tutorial snippets with the companion app - #3084

Merged
ElliotFriend merged 3 commits into
mainfrom
2965-guestbook-token-amount-helper
Nov 10, 2026
Merged

ElliotFriend merged 3 commits into
mainfrom
2965-guestbook-token-amount-helper

Conversation

@ElliotFriend

Copy link
Copy Markdown
Contributor

Fixes #2965

Brings the guestbook tutorial back in line with ElliotFriend/ye-olde-guestbook@a276f710.

frontend.mdx, Reading the balance

  • The Settings snippet now matches the app. It converts stroops with Soroban.formatTokenAmount(balance, 7) and truncates to two decimals with Intl.NumberFormat, instead of parseFloat((Number(balance) / 1e7).toFixed(2)).
  • The "there's a / 1e7 in the markup" sentence is replaced. A <Tip> now names formatTokenAmount for display and parseTokenAmount for user input.
  • Side effect worth knowing: for a balance of 99999999999 stroops, the old code showed 10000, which is more than the account holds. The new code shows 9,999.99. I checked this on @stellar/stellar-sdk 17.4.0.

smart-contract.mdx

  • Matches the contract's clippy cleanup (c289c8a3): implicit returns in write_message, edit_message, get_message, and save_message, and 0u32 instead of 0 as u32.

Checks

  • I compared every titled code block and Rust block in docs/build/apps/guestbook/ line by line against the app at a276f710. The only remaining differences are intentional: explanatory comments added in the docs, and the omitted toasts in the Signup and Login snippets.
  • The setup commands and scripts also match the app.
  • Prettier and pnpm validate pass.

🤖 Generated with Claude Code

- Format the Settings balance with Soroban.formatTokenAmount instead of
  dividing by 1e7, and point readers at parseTokenAmount for input.
- Match the contract's clippy cleanups (implicit returns, 0u32 literal).

Fixes #2965

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@mintlify

mintlify Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated
stellar-docs 🟢 Ready View Preview Nov 10, 2026, 4:13 PM

@kaankacar kaankacar left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM! A couple nonblockers that I just wanted to point out:

  • Afaik roundingMode: "trunc" only works in recent browsers, like Chrome 106 which was released in 2022. Older browsers ignore the option and round instead, so they would show 10,000 again. I don't think it'll a problem for us since not a lot of people have pre-2022 chromes :)
  • The app's lockfile pins @stellar/stellar-sdk 16.4.1. The SDK after the v17 has hardened regex for stripping trailing zeroes. In SDK 16.4.1, that regex has a weak spot. Give it a very long string full of zeroes, like "10000.000…0001" with thousands of zeroes, and it slows to a crawl. This can be used to freeze an app. The guestbook reads the balance from the network so it's always a short number so this doesn't apply to the guestbook for now, but might in a relevant PR.

Match the companion app: cut the fraction with string math so older
browsers that ignore roundingMode don't round the balance up. Also tell
readers to validate input before parseTokenAmount, and to keep
formatTokenAmount to trusted values before SDK 17.

Refs #2965

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ElliotFriend
ElliotFriend merged commit ff2be0d into main Nov 10, 2026
8 checks passed
@ElliotFriend
ElliotFriend deleted the 2965-guestbook-token-amount-helper branch November 10, 2026 16:18

This branch was successfully deployed

1 active deployment
staging — a5354411 Deployed Nov 10, 2026 by mintlify[bot]
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.

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

2 participants