Skip to content

Simplify web tutorials and enable all in CI#166

Merged
partylikeits1983 merged 9 commits intomainfrom
wiktor-opt
Mar 4, 2026
Merged

Simplify web tutorials and enable all in CI#166
partylikeits1983 merged 9 commits intomainfrom
wiktor-opt

Conversation

@WiktorStarczewski
Copy link
Contributor

Summary

  • Remove unnecessary client.sync() calls — waitFor() and execute() already sync internally, so explicit syncs after these calls were redundant
  • Extract MASM code from inline template literals into separate .masm files with a webpack loader
  • Simplify counter value display using Word.toU64s() instead of manual hex conversion
  • Update getOrImport helpers to accept bech32 strings directly
  • Update tutorials for simplified notes API (listAvailable, send, consume)
  • Update send() API from authenticated: false to returnNote: true
  • Enable all web tutorials in CI (previously incrementCounterContract and foreignProcedureInvocation were skipped)
  • Fix empty array expansion in run_tutorials.sh for set -u compatibility

Test plan

  • All 5 web tutorials pass (yarn tutorials --web)
  • Previously skipped tutorials (incrementCounterContract, foreignProcedureInvocation) pass when explicitly run

- listAvailable now returns InputNoteRecord[] directly
- consume accepts notes array instead of noteIds
- Remove .inputNoteRecord() and .map(n => n.id()) boilerplate
Remove Address.fromBech32(...).accountId() ceremony — getOrImport
already accepts AccountRef (which includes bech32 strings).
Move inline MASM template strings from foreignProcedureInvocation.ts
into dedicated .masm files (counter_contract.masm, count_reader.masm).
Add webpack asset/source rule for .masm imports and a TypeScript module
declaration. Restructure FPI tutorial to show file creation steps.
Extract inline MASM from incrementCounterContract.ts into the shared
counter_contract.masm file. Restructure counter contract tutorial with
dedicated MASM and bundler config steps.

Remove unnecessary client.sync() calls across all web tutorials where
local state is already up to date (after account creation, after
consume with no subsequent chain query, etc.).
waitFor() already calls syncStateWithTimeout(0) on each polling
iteration, so explicit sync after it is redundant. execute() updates
local account state directly, so sync before accounts.get() is also
unnecessary.
Enable incrementCounterContract and foreignProcedureInvocation in CI by
clearing WEB_SKIPPED. Guard empty-array references with the
${arr[@]+"${arr[@]}"} idiom so set -u does not trigger unbound-variable
errors.
@Keinberger
Copy link
Collaborator

Hey @WiktorStarczewski, thanks for the quick follow-up on #164! Really nice cleanup, the MASM
extraction alone is a big win IMO since that code was duplicated between the counter and FPI
tutorials. Killing the redundant syncs and enabling all tutorials in CI is great too!

I went through the full diff and it looks solid. Two small nits:

  • The closing ::: for the tip admonition blocks looks like it's indented under the list item. I think it needs to be at the start of its own line (unindented) to close properly. Could you double check that it renders correctly?
  • For toU64s()[3], could we add a small inline comment explaining why index 3? Something like // counter value is stored in the last felt of the word. Not blocking, just a readability thing since the magic number might trip someone up :)

LGTM, let's merge once you've verified the admonition rendering. Thanks!

Copy link
Collaborator

@partylikeits1983 partylikeits1983 left a comment

Choose a reason for hiding this comment

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

Very nice!

@partylikeits1983 partylikeits1983 merged commit 1f2b1c7 into main Mar 4, 2026
6 checks passed
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.

3 participants