feat: add batch builder implementation (web-sdk side)#31
Open
WiktorStarczewski wants to merge 14 commits into
Open
feat: add batch builder implementation (web-sdk side)#31WiktorStarczewski wants to merge 14 commits into
WiktorStarczewski wants to merge 14 commits into
Conversation
Migrated from 0xMiden/miden-client#2109 (author: juan518munoz) as part of the web-sdk split. Original PR: 0xMiden/miden-client#2109 The patch contains 3-way merge conflicts; resolution needed before merge.
…h-p2) Repoint workspace deps at miden-client#2109's branch so CI compiles against the batch-builder Rust changes from that PR. Revert before merge — see PR description for the merge sequence.
The previous push (072cd1e — pin miden-client to upstream PR branch) did not trigger GitHub Actions for some reason. This empty commit forces a fresh workflow dispatch.
Collaborator
Author
|
closing+reopening to trigger CI (the previous pushes mysteriously didn't fire workflow runs) |
WiktorStarczewski
added a commit
that referenced
this pull request
Apr 30, 2026
Now that miden-client#1835's wiktor-storekeys branch has been merged with miden-client@dab6cf7b (the same snapshot of next that web-sdk currently pins), the dep retarget that #23/#25/#26/#31 use works for this PR too. Local 'cargo check --workspace --target wasm32-unknown-unknown' is clean (was 23 errors before the upstream merge, due to the alpha-protocol mismatch the PR description mentions). Revert before merge — see PR description merge gate.
…test.ts This PR's migration of miden-client#2109 added a transactions.test.ts file under crates/idxdb-store/src/ts/ to cover applyTransactionBatch (the new batch builder entrypoint). Independently, next has gained its own transactions.test.ts at the same path, covering different functions (getTransactions, insertTransactionScript, upsertTransactionRecord). Two files at the same path is a 'both added' merge conflict that prevents GitHub from creating the pull_request merge ref — which in turn means no CI workflows fire on this PR (matching the symptom we saw: every push since the dep retarget produced zero workflow runs). Renaming this PR's file to transactions-batch.test.ts lets both files coexist after merge: next's file keeps its name, ours gets a more specific name that matches its content.
This was referenced Apr 30, 2026
…ual dep retarget Cargo.toml + Cargo.lock match origin/next; the 'Client PR: #2109' marker drives the runtime dep injection.
|
🔗 Linked client PR:
This run is testing against the linked PR's head. The published artifact will use the canonical Local-dev parity: |
…atch-builder-merge-next
Wraps the underlying `submitNewTransactionBatch` wasm primitive in the
resource-based MidenClient surface so consumers don't have to touch
`TransactionRequest` or call `.serialize()` themselves.
await client.transactions.batch({
account: senderId,
operations: [
{ kind: 'send', to: alice, token: usdc, amount: 50, type: 'public' },
{ kind: 'send', to: bob, token: usdc, amount: 30, type: 'public' },
{ kind: 'consume', notes: pendingNotes },
],
waitForConfirmation: true,
});
Two methods added on TransactionsResource:
- `batch(options)` — high-level, BatchOperation[] discriminated by `kind`
(send / mint / consume / swap / execute / custom). Reuses the existing
per-op private builders so the singular and batch paths share construction.
- `submitBatch(account, requests, options?)` — escape hatch for callers
that already have built TransactionRequests.
Also extracts `#buildExecuteRequest` from `execute()` so the batch
"execute" kind reuses the same foreign-account handling.
waitForConfirmation polls local sync height (the V1 batch primitive
returns only a block number — no per-tx ids to poll on).
V1 single-account constraint mirrors the underlying Rust API; mixing
accounts across operations is not supported.
- crates/web-client/README.md: new "Batch Operations" subsection under Usage, mirrors the singular-op subsections (Send Tokens / Consume Notes / etc). Shows the BatchOperation discriminated-union pattern, the V1 single-account constraint, and the submitBatch escape hatch. - CHANGELOG.md: [FEATURE][web] entry under 0.15.0 (TBD) for the new batch resource API. Links web-sdk#31 + miden-client#2109. - CLAUDE.md: replaced the vague "update relevant per-package CLAUDE.md" bullet with a precise mapping of every doc surface that has to be touched for MidenClient and React-SDK public-API changes (api-types, resource JSDoc, README, per-package CLAUDE.md, root CHANGELOG). New "Documenting public-API changes" section calls out the conventions (terse tone, no speculative docs, cross-link PRs, one fact per place) so future contributors don't miss a surface.
This was referenced May 4, 2026
Moved to dedicated PRs against main and next (web-sdk#126, web-sdk#127) so the doc-process change can land independently of this batch feature.
1. Clippy WASM (export.rs:69): drop redundant `&` before `account_id.to_string()` — clippy's `useless_borrows_in_formatting` lint fired here under the upstream-patched toolchain. Pre-existing code, not from this PR's batch additions. 2. Web client tests (Node.js): the job was missing the `Inject linked miden-client PR` step, so it built miden-client-web against `next`'s miden-client which doesn't have `Client::new_transaction_batch` yet — only the linked PR (#2109) does. Added the step to the Node.js test job, mirroring how Clippy WASM and the web-client build job already wire it. 3. web-client unit tests coverage gate (95% global): added 11 vitest cases covering `batch()` and `submitBatch()` — every operation kind dispatches correctly, every error path throws, the waitForConfirmation poll loop exercises the success / transient sync failure / timeout branches. Local run: lines/statements 99.75%, functions 100%, branches 99.34%. transactions.js specifically 100/100 lines/funcs. Shard-3 (`accounts-and-keys`) failed with cascading "TypeError: Failed to fetch" errors after the runner hit RPC 429s during cache fetch — flake. Will resolve on the next run.
Closes the doc-surface gap I called out in the doc-process audit:
- docs/external/src/web-client/library/transactions.md: ports the
pre-split transactions narrative from miden-docs (last seen at
d172117^ on the wiktor-ts-react-docs branch before deletion under
'rely on CI ingestion') with two changes:
* import path updated to @miden-sdk/miden-sdk
* appended a Batch Operations section covering the new
transactions.batch / submitBatch surface, the BatchOperation
kind union, the V1 single-account / no-per-tx-id constraints,
and the waitForConfirmation block-height polling semantics.
- docs/external/src/web-client/{_category_.yml,library/_category_.yml}:
minimal Docusaurus scaffolding so the directory is valid for ingestion
by miden-docs's deploy-docs.yml when that workflow is wired up to
pull from this repo.
- docs/typedoc/web-client/: regenerated 107-file typedoc tree picking
up the new BatchOperation / BatchOptions / BatchSubmitResult types
and the batch / submitBatch methods on TransactionsResource. The CI
step Check that web client documentation is up-to-date passes
trivially today (the dir wasn't tracked, so git diff --exit-code had
nothing to compare); committing it now means future drift is caught.
Note: deploy-docs.yml in 0xMiden/miden-docs currently does not ingest
from web-sdk — only from miden-client. Adding docs/external/src/ here
unblocks that ingestion when the workflow is updated; until then this
content lives in-repo as the canonical source.
The CI step "Check that web client documentation is up-to-date" runs `pnpm typedoc` to regenerate fresh and then `git diff --exit-code` over docs/typedoc/web-client/. Since the dir hasn't been tracked since the web/WASM split, the diff has nothing to compare and the step is a warning-only smoke test — typedoc is intermediate build output, not source. Reverts the 107-file autogen commit from cd4f75d. Keeps the hand-written narrative + scaffolding under docs/external/src/. Will adjust the doc-process rule in CLAUDE.md (PRs #126/#127) to match this policy.
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.
Client PR: #2109
Migrated from miden-client#2109 (author: @juan518munoz) as part of the web-sdk split (#1992 / #2135).
The miden-client-side changes (the bulk of the original PR) stay on miden-client#2109.