Skip to content

feat: add multi-account support for batch builder - #161

Open
juan518munoz wants to merge 6 commits into
mainfrom
jmunoz-batch-builder-multi-account
Open

feat: add multi-account support for batch builder#161
juan518munoz wants to merge 6 commits into
mainfrom
jmunoz-batch-builder-multi-account

Conversation

@juan518munoz

@juan518munoz juan518munoz commented May 28, 2026

Copy link
Copy Markdown
Collaborator

Mirror of 0xMiden/rust-sdk#2177, continues #31 by adding support for multiple accounts in a batch transaction through BatchBuilder.

@juan518munoz
juan518munoz force-pushed the jmunoz-batch-builder-multi-account branch 3 times, most recently from a2db11c to 6f08f36 Compare June 17, 2026 17:41
@igamigo

igamigo commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator

@juan518munoz after having merged #31 this got various conflicts, can we rebase with the latest changes?

Add BATCH_BUSY to MidenErrorCode (thrown by useBatch on concurrent batches)
and re-export the batch types (UseBatchResult, BatchOptions, BatchResult,
BatchItemInput) from the package entry so they are part of the public surface
and pass knip.
Use slice as_chunks::<4>() instead of chunks_exact(4) in note_attachment
to clear the clippy chunks_exact_to_as_chunks lint enforced on the pinned
nightly. Bump the react-sdk peerDependency and wallet example dependency
on @miden-sdk/miden-sdk to ^0.15.4 to match the web-client version bump.
@juan518munoz
juan518munoz force-pushed the jmunoz-batch-builder-multi-account branch from 7695dbd to 095d425 Compare June 29, 2026 19:30
@juan518munoz
juan518munoz changed the base branch from wiktor/migrate-2109-batch-builder to main June 29, 2026 19:30
@juan518munoz

Copy link
Copy Markdown
Collaborator Author

Heads up

Rebased this PR into main as #31 has already been merged, but the PR did not change dest branch automatically.

…er rebase

The rebase onto main left BatchItem mis-sorted in node-index.js (with a
stray grouping comment) and the react-sdk peer range bumped to ^0.15.4
while web-client is still 0.15.3. Restore alphabetical ordering to match
the napi-reexports generator and pin the peer range to ^0.15.3.

@igamigo igamigo left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM, thanks!

Comment thread packages/react-sdk/src/types/index.ts Outdated
Comment on lines +371 to +372
/** Pre-built `TransactionRequest`. */
request: unknown;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Shoudl this be TransactionRequest instead of unknown?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Comment thread CHANGELOG.md Outdated

* [FEATURE][web,react] AggLayer bridge-out (B2AGG) note support. `client.transactions.bridge({ account, bridgeAccount, token, amount, destinationNetwork, destinationAddress })` bridges a fungible asset out to another network — emitting a single public B2AGG (Bridge-to-AggLayer) note that the bridge account consumes, burning the asset so it can be claimed at the destination Ethereum address on the AggLayer-assigned `destinationNetwork`. The lower-level builders are also exposed: `Note.createB2AggNote(sender, bridgeAccount, assets, destinationNetwork, destinationAddress)` and `client.newB2AggTransactionRequest(...)`. A new `EthAddress` class carries the 20-byte destination address (`EthAddress.fromHex("0x…")` / `EthAddress.fromBytes(bytes)`, with `toHex()` / `toBytes()`). The `@miden-sdk/react` `useBridge()` hook wraps the build-and-submit flow: `bridge({ from, bridgeAccount, assetId, amount, destinationNetwork, destinationAddress })`. Builds on the `miden-agglayer` re-export already present in the bundled `miden-client` — no new dependency. (closes [#173](https://github.com/0xMiden/web-sdk/issues/173))
* [FEATURE][web] Added `client.transactions.batch({ account, operations })` to `MidenClient` for atomic multi-tx batches against a single account. Operations are discriminated by `kind` (`"send" | "mint" | "consume" | "swap" | "execute" | "custom"`) and reuse the same options shape as their singular counterparts. Returns `{ blockNumber }`. Companion `submitBatch(account, requests, options?)` is the lower-level escape hatch for pre-built `TransactionRequest`s. Wraps the underlying WASM `submitNewTransactionBatch` so consumers don't have to call `.serialize()` themselves. ([web-sdk#31](https://github.com/0xMiden/web-sdk/pull/31), client [#2109](https://github.com/0xMiden/miden-client/pull/2109))
* [FEATURE][web] Added `client.transactions.batch({ operations })` to `MidenClient` for atomic multi-tx batches across one or more local accounts. Each operation specifies its executing `account`; a batch may mix operations across any combination of tracked accounts, and a later transaction may consume a note produced by an earlier one (cross-account in-batch note flow supported). Operations are discriminated by `kind` (`"send" | "mint" | "consume" | "swap" | "execute" | "custom"`) and reuse the same options shape as their singular counterparts. Returns `{ blockNumber }`. Companion `submitBatch(items, options?)` takes an array of `{ account, request }` pairs and is the lower-level escape hatch for pre-built `TransactionRequest`s. Wraps the underlying WASM `submitNewTransactionBatch(items: BatchItem[])`, where each `BatchItem` is a `(AccountId, TransactionRequest)` pair built via `new BatchItem(accountId, request)`. ([web-sdk#31](https://github.com/0xMiden/web-sdk/pull/31), client [#2109](https://github.com/0xMiden/miden-client/pull/2109), [#2177](https://github.com/0xMiden/miden-client/pull/2177))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: Seems this also contains changes for the React SDK

Suggested change
* [FEATURE][web] Added `client.transactions.batch({ operations })` to `MidenClient` for atomic multi-tx batches across one or more local accounts. Each operation specifies its executing `account`; a batch may mix operations across any combination of tracked accounts, and a later transaction may consume a note produced by an earlier one (cross-account in-batch note flow supported). Operations are discriminated by `kind` (`"send" | "mint" | "consume" | "swap" | "execute" | "custom"`) and reuse the same options shape as their singular counterparts. Returns `{ blockNumber }`. Companion `submitBatch(items, options?)` takes an array of `{ account, request }` pairs and is the lower-level escape hatch for pre-built `TransactionRequest`s. Wraps the underlying WASM `submitNewTransactionBatch(items: BatchItem[])`, where each `BatchItem` is a `(AccountId, TransactionRequest)` pair built via `new BatchItem(accountId, request)`. ([web-sdk#31](https://github.com/0xMiden/web-sdk/pull/31), client [#2109](https://github.com/0xMiden/miden-client/pull/2109), [#2177](https://github.com/0xMiden/miden-client/pull/2177))
* [FEATURE][web, react] Added `client.transactions.batch({ operations })` to `MidenClient` for atomic multi-tx batches across one or more local accounts. Each operation specifies its executing `account`; a batch may mix operations across any combination of tracked accounts, and a later transaction may consume a note produced by an earlier one (cross-account in-batch note flow supported). Operations are discriminated by `kind` (`"send" | "mint" | "consume" | "swap" | "execute" | "custom"`) and reuse the same options shape as their singular counterparts. Returns `{ blockNumber }`. Companion `submitBatch(items, options?)` takes an array of `{ account, request }` pairs and is the lower-level escape hatch for pre-built `TransactionRequest`s. Wraps the underlying WASM `submitNewTransactionBatch(items: BatchItem[])`, where each `BatchItem` is a `(AccountId, TransactionRequest)` pair built via `new BatchItem(accountId, request)`. ([web-sdk#31](https://github.com/0xMiden/web-sdk/pull/31), client [#2109](https://github.com/0xMiden/miden-client/pull/2109), [#2177](https://github.com/0xMiden/miden-client/pull/2177))

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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.

2 participants