Skip to content

feat(tutorials): runnable block for the numbers a payment needs - #420

Open
IanoNjuguna wants to merge 1 commit into
IntersectMBO:fix/tutorial-code-samplesfrom
IanoNjuguna:feat/tutorial-live-codeblock
Open

IanoNjuguna wants to merge 1 commit into
IntersectMBO:fix/tutorial-code-samplesfrom
IanoNjuguna:feat/tutorial-live-codeblock

Conversation

@IanoNjuguna

@IanoNjuguna IanoNjuguna commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Description

Two config lines, the theme, and one new section in the wallet tutorial.

@docusaurus/theme-live-codeblock turns a fenced block marked jsx live into an editable React playground whose output renders under it. The tutorial gains a section between "Build the payment" and "Sign and submit" that computes the three numbers a payment form needs before any wallet is involved:

  • lovelace from ADA, since the ledger has no decimals
  • the native-asset unit, that is policy ID plus asset name in hex
  • the address prefix, which says whether the recipient is on a testnet or mainnet

A reader who types addr1… into the recipient field watches the network line change before they ever reach a wallet. That is the mistake the section exists to catch.

Part of #419. Stacked on #418.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

Testing

  • I have tested these changes locally
  • I have checked for broken links
  • Code examples have been tested

Checklist

  • My code follows the style guidelines
  • I have performed a self-review
  • I have made corresponding changes to documentation

Verification

Built locally and served the static output, then drove the playground through CDP rather than eyeballing it:

npm run build                     SUCCESS, incremental 33s
blocks on the page                1, renders with an editable editor and a RESULT panel
type addr1… into recipient        network line changes preview / preprod testnet → mainnet
React state, not a static render  the change happens with no reload

Cost, measured against the deployed site rather than estimated:

main.js without the theme   539 KB raw, 160 KB gzipped
main.js with the theme      552 KB raw, 160 KB gzipped
extra chunk on mount        22 KB, fetched when a playground mounts
client-side babel           none, the block is compiled at build time

So the theme costs about 13 KB raw on the shared bundle and one lazily fetched chunk per page that actually contains a block. Pages without blocks are unchanged.

Notes

  • The wallet calls cannot be live: anything importing @meshsdk/core would throw in the browser. Those snippets stay ordinary blocks with the copy button, so the section deliberately stops at the arithmetic.
  • A live block is compiled at build time, so a syntax error in one fails the build. That is a property worth having: these examples cannot drift into text that does not compile.
  • The default values are a real preview address and a real policy ID, not placeholders.
  • The page it complements is docs(how-to-guide): a beginner page for amounts, units and addresses #421, which carries the reference version of the same three numbers.

@docusaurus/theme-live-codeblock, one block on the wallet tutorial, and the
three numbers a payment form can compute before a wallet is involved: lovelace
from ADA, the native-asset unit, and the address prefix that says which
network the recipient is on.

The wallet calls cannot run in a playground, so the block deliberately stops
before them; it is the pure part that a first-timer gets wrong in a wallet
rather than in code.

This branch has not been deployed

No deployments
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.

1 participant