docs(tutorials): add "Browser dApp with an injected wallet" tutorial#1109
docs(tutorials): add "Browser dApp with an injected wallet" tutorial#1109DpacJones wants to merge 6 commits into
Conversation
Adds a tutorial showing how to deploy a Compact contract, call a circuit, and read contract state from a minimal browser dApp that delegates chain sync, balancing, proving, and signing to an injected wallet (Lace or 1AM) via the DApp connector API — avoiding a headless wallet sync. Targets the current SDK line (midnight-js 4.x, compact-runtime 0.15, ledger v8) and works on preview and preprod. Linked from the Tutorials landing page. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
@DpacJones is attempting to deploy a commit to the Midnight Foundation Team on Vercel. A member of the Team first needs to authorize it. |
oduameh
left a comment
There was a problem hiding this comment.
Good tutorial covering a real gap in the docs (wallet-delegated browser DApp). The architecture is sound and the code examples verified against the current SDK types via tsc --noEmit. Build passes locally.
A few items to address before merge:
Must fix:
- Em-dashes throughout (8 instances in tutorial, 1 in tile) -- our style uses commas, periods, or parentheses
descriptionexceeds 120-160 char limit (212 chars)- Indexer URL uses
/api/v3/graphql, should be/api/v4/graphql inMemoryPrivateStateProvider()is used but never imported or defined- Missing
_category_.yamlfor thebrowser-dapp/directory. All other tutorial directories include one (verified: bboard, bship, leaderboard, zk-loan, private-party). Without it, the sidebar label and collapsible behavior fall back to Docusaurus defaults. Consider adding:
position: 60
label: 'Browser DApp'
description: "Intermediate: deploy, call, and read contract state from a browser DApp with an injected wallet."
collapsible: true
collapsed: true
link:
type: doc
id: tutorials/browser-dapp/indexcompact-runtime0.15 is outdated (0.16.0 is latest)
Should fix:
- "dApp" should be "DApp" per brand guide (6 instances)
- Missing
toc_max_heading_level: 2in frontmatter FinalizedTransactionshould useimport typeas anyin 6 places obscures type information- No next-steps section
- Tags missing difficulty level
Suggestions are batch-committable.
| 'https://indexer.preview.midnight.network/api/v3/graphql', | ||
| 'wss://indexer.preview.midnight.network/api/v3/graphql/ws', |
There was a problem hiding this comment.
The current indexer API version is v4. The indexer 4.0.0 release notes state: "v3 is available as an alias of v4 to support migration windows for existing clients." All other tutorials use v4 (verified against docs/tutorials/bboard/bboard-cli-implementation.mdx:192).
| 'https://indexer.preview.midnight.network/api/v3/graphql', | |
| 'wss://indexer.preview.midnight.network/api/v3/graphql/ws', | |
| 'https://indexer.preview.midnight.network/api/v4/graphql', | |
| 'wss://indexer.preview.midnight.network/api/v4/graphql/ws', |
Bump the coordinated SDK set so the tutorial targets the current line. compact-js exact-pins compact-runtime, so the runtime cannot be bumped in isolation; move the whole set together: - compact-js ^2.5.0 -> ^2.5.1 (2.5.1 pins compact-runtime 0.16.0) - compact-runtime ^0.15.0 -> ^0.16.0 - ledger-v8 ^8.0.0 -> ^8.0.3 - document the compactc 0.31.x / language 0.23 / runtime 0.16 coupling in prerequisites and troubleshooting Address review feedback: - fix undefined inMemoryPrivateStateProvider (would throw ReferenceError): add the import and cross-link the Leaderboard tutorial's complete in-memory PrivateStateProvider implementation - add missing browser-dapp/_category_.yaml so the sidebar label and collapsible behavior match the other tutorial directories - correct hosted indexer URL from /api/v3/graphql to /api/v4/graphql
|
Thanks @oduameh, this was a really thorough review, appreciated. Pushed a commit addressing the must-fixes: Fixed in the latest push
On the runtime bump: bumping compact-runtime alone to ^0.16.0 actually reintroduces a version mismatch, because @midnight-ntwrk/compact-js@2.5.0 exact-pins compact-runtime@0.15.0 — npm still resolves 0.15 transitively and proving fails at runtime. tsc --noEmit won't catch it, since the mismatch surfaces at proof time, not compile time. So I moved the coordinated set together:
…and documented the compactc 0.31.x / language 0.23 / runtime 0.16 coupling in the prerequisites and troubleshooting, since the reader's compiled bindings have to match the runtime they install. Accepting your inline suggestions for the remaining style items (em-dashes, dApp→DApp, description length, toc_max_heading_level, import type FinalizedTransaction, difficulty tag) — batching those now. Still considering the as any cleanup via a CompiledContract.make() type param like zk-loan does — will follow up if I can preserve the types cleanly through the chain. Thanks again! |
Co-authored-by: Emmanuel Ameh <oduameh@gmail.com> Signed-off-by: Dpac / Dennis <dpacjones@gmail.com>
Style cleanup the batch suggestions did not reach: - frontmatter title: dApp -> DApp (the H1 was fixed, the title was not) - troubleshooting "dApp tab" -> "DApp tab" - replace the two em-dashes introduced in the 0.16 prerequisites and version-drift notes with periods, per the docs style guide
Adds a tutorial showing how to deploy a Compact contract, call a circuit, and read contract state from a minimal browser dApp that delegates chain sync, balancing, proving, and signing to an injected wallet (Lace or 1AM) via the DApp connector API — avoiding a headless wallet sync. Targets the current SDK line (midnight-js 4.x, compact-runtime 0.15, ledger v8) and works on preview and preprod. Linked from the Tutorials landing page.