Repository navigation
Sync guestbook tutorial snippets with the companion app - #3084
Merged
Merged
Conversation
- 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]>
Contributor
|
Preview deployment for your docs. Learn more about Mintlify Previews.
|
5 tasks
kaankacar
approved these changes
Nov 10, 2026
Contributor
There was a problem hiding this comment.
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]>
Refs #2965 Co-Authored-By: Claude Opus 5.5 <[email protected]>
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2965
Brings the guestbook tutorial back in line with ElliotFriend/ye-olde-guestbook@a276f710.
frontend.mdx, Reading the balanceSoroban.formatTokenAmount(balance, 7)and truncates to two decimals withIntl.NumberFormat, instead ofparseFloat((Number(balance) / 1e7).toFixed(2))./ 1e7in the markup" sentence is replaced. A<Tip>now namesformatTokenAmountfor display andparseTokenAmountfor user input.10000, which is more than the account holds. The new code shows9,999.99. I checked this on@stellar/stellar-sdk17.4.0.smart-contract.mdxwrite_message,edit_message,get_message, andsave_message, and0u32instead of0 as u32.Checks
docs/build/apps/guestbook/line by line against the app ata276f710. The only remaining differences are intentional: explanatory comments added in the docs, and the omitted toasts in the Signup and Login snippets.pnpm validatepass.🤖 Generated with Claude Code