@miden-sdk/miden-sdk 0.15.3 → 0.15.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/README.md +69 -0
  2. package/dist/mt/{Cargo-D2qNRrNR.js → Cargo-DjVnfWKi.js} +424 -88
  3. package/dist/mt/Cargo-DjVnfWKi.js.map +1 -0
  4. package/dist/mt/api-types.d.ts +130 -0
  5. package/dist/mt/assets/miden_client_web.wasm +0 -0
  6. package/dist/mt/crates/miden_client_web.d.ts +93 -3
  7. package/dist/mt/docs-entry.d.ts +2 -0
  8. package/dist/mt/eager.js +1 -1
  9. package/dist/mt/index.d.ts +3 -0
  10. package/dist/mt/index.js +211 -13
  11. package/dist/mt/index.js.map +1 -1
  12. package/dist/mt/wasm.js +1 -1
  13. package/dist/mt/workerHelpers.js +1 -1
  14. package/dist/mt/workers/{Cargo-D2qNRrNR-n_GEbq73.js → Cargo-DjVnfWKi-DvLbB_Zb.js} +424 -88
  15. package/dist/mt/workers/Cargo-DjVnfWKi-DvLbB_Zb.js.map +1 -0
  16. package/dist/mt/workers/assets/miden_client_web.wasm +0 -0
  17. package/dist/mt/workers/web-client-methods-worker.js +425 -88
  18. package/dist/mt/workers/web-client-methods-worker.js.map +1 -1
  19. package/dist/mt/workers/web-client-methods-worker.module.js +1 -1
  20. package/dist/mt/workers/web-client-methods-worker.module.js.map +1 -1
  21. package/dist/mt/workers/workerHelpers.js +1 -1
  22. package/dist/st/{Cargo-BP7-0qVT.js → Cargo-Cwpuvlbc.js} +433 -98
  23. package/dist/st/Cargo-Cwpuvlbc.js.map +1 -0
  24. package/dist/st/api-types.d.ts +130 -0
  25. package/dist/st/assets/miden_client_web.wasm +0 -0
  26. package/dist/st/crates/miden_client_web.d.ts +93 -3
  27. package/dist/st/docs-entry.d.ts +2 -0
  28. package/dist/st/eager.js +1 -1
  29. package/dist/st/index.d.ts +3 -0
  30. package/dist/st/index.js +211 -13
  31. package/dist/st/index.js.map +1 -1
  32. package/dist/st/wasm.js +1 -1
  33. package/dist/st/workers/{Cargo-BP7-0qVT-CmfAy6bf.js → Cargo-Cwpuvlbc-B0V_MEMU.js} +433 -98
  34. package/dist/st/workers/Cargo-Cwpuvlbc-B0V_MEMU.js.map +1 -0
  35. package/dist/st/workers/assets/miden_client_web.wasm +0 -0
  36. package/dist/st/workers/web-client-methods-worker.js +434 -98
  37. package/dist/st/workers/web-client-methods-worker.js.map +1 -1
  38. package/dist/st/workers/web-client-methods-worker.module.js +1 -1
  39. package/dist/st/workers/web-client-methods-worker.module.js.map +1 -1
  40. package/js/node-index.js +1 -0
  41. package/js/resources/transactions.js +198 -12
  42. package/package.json +4 -4
  43. package/dist/mt/Cargo-D2qNRrNR.js.map +0 -1
  44. package/dist/mt/workers/Cargo-D2qNRrNR-n_GEbq73.js.map +0 -1
  45. package/dist/st/Cargo-BP7-0qVT.js.map +0 -1
  46. package/dist/st/workers/Cargo-BP7-0qVT-CmfAy6bf.js.map +0 -1
@@ -374,6 +374,21 @@ export interface MintOptions extends TransactionOptions {
374
374
  type?: NoteVisibility;
375
375
  }
376
376
 
377
+ export interface BridgeOptions extends TransactionOptions {
378
+ /** Account that creates and funds the bridge note (the sender / executing account). */
379
+ account: AccountRef;
380
+ /** Bridge account that consumes the note and burns the bridged asset. */
381
+ bridgeAccount: AccountRef;
382
+ /** Faucet / token ID of the fungible asset to bridge. */
383
+ token: AccountRef;
384
+ /** Amount of the asset to bridge. */
385
+ amount: number | bigint;
386
+ /** AggLayer-assigned network ID of the destination chain. */
387
+ destinationNetwork: number;
388
+ /** Destination Ethereum address on the destination network (0x-prefixed hex). */
389
+ destinationAddress: string;
390
+ }
391
+
377
392
  export interface ConsumeOptions extends TransactionOptions {
378
393
  account: AccountRef;
379
394
  notes: NoteInput | NoteInput[];
@@ -384,6 +399,73 @@ export interface ConsumeAllOptions extends TransactionOptions {
384
399
  maxNotes?: number;
385
400
  }
386
401
 
402
+ /**
403
+ * A single operation inside a transaction batch. The shape mirrors the
404
+ * singular options types (`SendOptions`, `MintOptions`, ...) minus the
405
+ * `account` field — the executing account is set once at the batch level
406
+ * and shared by every operation (V1 single-account constraint).
407
+ */
408
+ export type BatchOperation =
409
+ | {
410
+ kind: "send";
411
+ to: AccountRef;
412
+ token: AccountRef;
413
+ amount: number | bigint;
414
+ type?: NoteVisibility;
415
+ reclaimAfter?: number;
416
+ timelockUntil?: number;
417
+ }
418
+ | {
419
+ kind: "mint";
420
+ to: AccountRef;
421
+ amount: number | bigint;
422
+ type?: NoteVisibility;
423
+ }
424
+ | {
425
+ kind: "consume";
426
+ notes: NoteInput | NoteInput[];
427
+ }
428
+ | {
429
+ kind: "swap";
430
+ offer: Asset;
431
+ request: Asset;
432
+ type?: NoteVisibility;
433
+ paybackType?: NoteVisibility;
434
+ }
435
+ | {
436
+ kind: "execute";
437
+ script: TransactionScript;
438
+ foreignAccounts?: (
439
+ | AccountRef
440
+ | { id: AccountRef; storage?: AccountStorageRequirements }
441
+ )[];
442
+ }
443
+ | {
444
+ /** Escape hatch for pre-built TransactionRequests. */
445
+ kind: "custom";
446
+ request: TransactionRequest;
447
+ };
448
+
449
+ export interface BatchOptions {
450
+ /** The account executing every operation in the batch (single-account in V1). */
451
+ account: AccountRef;
452
+ /** Operations to execute atomically as a batch. Must be non-empty. */
453
+ operations: BatchOperation[];
454
+ /**
455
+ * Wait until the batch's block has been observed in the local sync height.
456
+ * Differs from singular `waitForConfirmation`: the V1 batch API returns
457
+ * only a block number, so we poll chain height rather than per-tx status.
458
+ */
459
+ waitForConfirmation?: boolean;
460
+ /** Wall-clock polling timeout for `waitForConfirmation` (default 60_000ms). */
461
+ timeout?: number;
462
+ }
463
+
464
+ export interface BatchSubmitResult {
465
+ /** The block number the batch was accepted into. */
466
+ blockNumber: number;
467
+ }
468
+
387
469
  export interface SwapOptions extends TransactionOptions {
388
470
  account: AccountRef;
389
471
  offer: Asset;
@@ -484,6 +566,16 @@ export interface PreviewMintOptions {
484
566
  type?: NoteVisibility;
485
567
  }
486
568
 
569
+ export interface PreviewBridgeOptions {
570
+ operation: "bridge";
571
+ account: AccountRef;
572
+ bridgeAccount: AccountRef;
573
+ token: AccountRef;
574
+ amount: number | bigint;
575
+ destinationNetwork: number;
576
+ destinationAddress: string;
577
+ }
578
+
487
579
  export interface PreviewConsumeOptions {
488
580
  operation: "consume";
489
581
  account: AccountRef;
@@ -531,6 +623,7 @@ export interface PreviewCustomOptions {
531
623
  export type PreviewOptions =
532
624
  | PreviewSendOptions
533
625
  | PreviewMintOptions
626
+ | PreviewBridgeOptions
534
627
  | PreviewConsumeOptions
535
628
  | PreviewSwapOptions
536
629
  | PreviewPswapCreateOptions
@@ -730,6 +823,15 @@ export interface TransactionsResource {
730
823
  * @param options - Mint options including the faucet, recipient, and amount.
731
824
  */
732
825
  mint(options: MintOptions): Promise<TransactionSubmitResult>;
826
+ /**
827
+ * Bridge a fungible asset out to another network via the AggLayer. Emits a
828
+ * single public B2AGG (Bridge-to-AggLayer) note that the bridge account
829
+ * consumes, burning the asset so it can be claimed at the destination
830
+ * Ethereum address on the destination network.
831
+ *
832
+ * @param options - Sender, bridge account, token, amount, and destination.
833
+ */
834
+ bridge(options: BridgeOptions): Promise<TransactionSubmitResult>;
733
835
  /**
734
836
  * Consume one or more notes for an account.
735
837
  *
@@ -803,6 +905,34 @@ export interface TransactionsResource {
803
905
  options?: TransactionOptions
804
906
  ): Promise<TransactionSubmitResult>;
805
907
 
908
+ /**
909
+ * Execute a heterogeneous batch of operations against a single account.
910
+ * Each operation is built, proven individually and as a batch, and all
911
+ * operations are submitted atomically — either every tx in the batch
912
+ * lands or none does.
913
+ *
914
+ * V1 supports only same-account batches (mirrors the underlying Rust
915
+ * `Client::new_transaction_batch()` constraint).
916
+ *
917
+ * @param options - Batch options including the account and operations.
918
+ */
919
+ batch(options: BatchOptions): Promise<BatchSubmitResult>;
920
+
921
+ /**
922
+ * Submit pre-built TransactionRequests as an atomic batch. Plural
923
+ * counterpart of {@link submit} — for callers that already have built
924
+ * requests in hand and want to skip the high-level operation builders.
925
+ *
926
+ * @param account - The account executing every transaction in the batch.
927
+ * @param requests - Pre-built transaction requests (must be non-empty).
928
+ * @param options - Optional batch settings (waitForConfirmation, timeout, prover).
929
+ */
930
+ submitBatch(
931
+ account: AccountRef,
932
+ requests: TransactionRequest[],
933
+ options?: Omit<BatchOptions, "account" | "operations">
934
+ ): Promise<BatchSubmitResult>;
935
+
806
936
  /** Execute a program (view call) and return the resulting stack output. */
807
937
  executeProgram(options: ExecuteProgramOptions): Promise<FeltArray>;
808
938
 
@@ -967,10 +967,13 @@ export class AuthSecretKey {
967
967
  }
968
968
 
969
969
  /**
970
- * Provides metadata for a basic fungible faucet account component.
970
+ * Provides metadata for a fungible faucet account component.
971
971
  *
972
- * Reads the on-chain [`FungibleFaucet`] component for the account, which holds the
973
- * per-token info (symbol/decimals/maxSupply).
972
+ * Reads the on-chain `FungibleFaucet` component for the account, which holds the per-token
973
+ * info (symbol, decimals, supply, and the descriptive metadata). The same component backs both
974
+ * "basic" public faucets and network-style faucets — in the current protocol the distinction is
975
+ * a function of the surrounding account configuration (account type, auth, access control), not
976
+ * of the faucet component itself — so this reads metadata from either kind of faucet account.
974
977
  */
975
978
  export class BasicFungibleFaucetComponent {
976
979
  private constructor();
@@ -980,10 +983,22 @@ export class BasicFungibleFaucetComponent {
980
983
  * Returns the number of decimal places for the token.
981
984
  */
982
985
  decimals(): number;
986
+ /**
987
+ * Returns the optional free-form token description, or `undefined` when unset.
988
+ */
989
+ description(): string | undefined;
990
+ /**
991
+ * Returns the optional external link (e.g. project website), or `undefined` when unset.
992
+ */
993
+ externalLink(): string | undefined;
983
994
  /**
984
995
  * Extracts faucet metadata from an account.
985
996
  */
986
997
  static fromAccount(account: Account): BasicFungibleFaucetComponent;
998
+ /**
999
+ * Returns the optional token logo URI, or `undefined` when unset.
1000
+ */
1001
+ logoUri(): string | undefined;
987
1002
  /**
988
1003
  * Returns the maximum token supply.
989
1004
  */
@@ -992,6 +1007,14 @@ export class BasicFungibleFaucetComponent {
992
1007
  * Returns the faucet's token symbol.
993
1008
  */
994
1009
  symbol(): TokenSymbol;
1010
+ /**
1011
+ * Returns the human-readable token name.
1012
+ */
1013
+ tokenName(): string;
1014
+ /**
1015
+ * Returns the current token supply (the amount minted so far).
1016
+ */
1017
+ tokenSupply(): Felt;
995
1018
  }
996
1019
 
997
1020
  /**
@@ -1242,6 +1265,43 @@ export class Endpoint {
1242
1265
  readonly protocol: string;
1243
1266
  }
1244
1267
 
1268
+ /**
1269
+ * A 20-byte Ethereum address, used as the destination of an `AggLayer` bridge-out (B2AGG) note.
1270
+ *
1271
+ * Construct one from a hex string with [`EthAddress::from_hex`] (the `0x` prefix is optional) or
1272
+ * from raw bytes with [`EthAddress::from_bytes`]. The canonical lowercase, `0x`-prefixed hex form
1273
+ * is available via [`EthAddress::to_hex`] (also exposed as `toString`).
1274
+ */
1275
+ export class EthAddress {
1276
+ private constructor();
1277
+ free(): void;
1278
+ [Symbol.dispose](): void;
1279
+ /**
1280
+ * Builds an Ethereum address from its raw 20-byte big-endian representation.
1281
+ *
1282
+ * Returns an error if the input is not exactly 20 bytes long.
1283
+ */
1284
+ static fromBytes(bytes: Uint8Array): EthAddress;
1285
+ /**
1286
+ * Builds an Ethereum address from a hex string (with or without the `0x` prefix).
1287
+ *
1288
+ * Returns an error if the string is not valid hex or does not encode exactly 20 bytes.
1289
+ */
1290
+ static fromHex(hex: string): EthAddress;
1291
+ /**
1292
+ * Returns the raw 20-byte big-endian representation of the address.
1293
+ */
1294
+ toBytes(): Uint8Array;
1295
+ /**
1296
+ * Returns the canonical lowercase, `0x`-prefixed hex representation of the address.
1297
+ */
1298
+ toHex(): string;
1299
+ /**
1300
+ * Returns the canonical lowercase, `0x`-prefixed hex representation of the address.
1301
+ */
1302
+ toString(): string;
1303
+ }
1304
+
1245
1305
  /**
1246
1306
  * Describes the result of executing a transaction program for the Miden protocol.
1247
1307
  *
@@ -2142,6 +2202,16 @@ export class Note {
2142
2202
  * unchanged.
2143
2203
  */
2144
2204
  commitment(): Word;
2205
+ /**
2206
+ * Builds a B2AGG (Bridge-to-AggLayer) note that bridges the given assets out to another
2207
+ * network via the `AggLayer`.
2208
+ *
2209
+ * The note is always public and is consumed by `bridge_account`, which burns the assets so
2210
+ * they can be claimed on the destination network at `destination_address` (an Ethereum
2211
+ * address on the AggLayer-assigned `destination_network`). The assets must be fungible assets
2212
+ * issued by a network faucet.
2213
+ */
2214
+ static createB2AggNote(sender: AccountId, bridge_account: AccountId, assets: NoteAssets, destination_network: number, destination_address: EthAddress): Note;
2145
2215
  /**
2146
2216
  * Builds a P2IDE note that can be reclaimed or timelocked based on block heights.
2147
2217
  */
@@ -4669,6 +4739,16 @@ export class WebClient {
4669
4739
  * but callers only need a single await instead of two.
4670
4740
  */
4671
4741
  newAccountWithSecretKey(account: Account, secret_key: AuthSecretKey): Promise<void>;
4742
+ /**
4743
+ * Builds a transaction request that bridges a fungible asset out to another network via the
4744
+ * `AggLayer`.
4745
+ *
4746
+ * The request emits a single public B2AGG (Bridge-to-AggLayer) note holding `amount` units of
4747
+ * the `faucet_id` asset. The note is consumed by `bridge_account_id`, which burns the asset so
4748
+ * it can be claimed at `destination_address` (an Ethereum address) on the AggLayer-assigned
4749
+ * `destination_network`.
4750
+ */
4751
+ newB2AggTransactionRequest(sender_account_id: AccountId, bridge_account_id: AccountId, faucet_id: AccountId, amount: bigint, destination_network: number, destination_address: EthAddress): Promise<TransactionRequest>;
4672
4752
  newConsumeTransactionRequest(list_of_notes: Note[]): TransactionRequest;
4673
4753
  /**
4674
4754
  * Creates, persists, and returns a new fungible faucet account.
@@ -4744,6 +4824,16 @@ export class WebClient {
4744
4824
  * the chain tip is performed, and the required block header is retrieved.
4745
4825
  */
4746
4826
  submitNewTransaction(account_id: AccountId, transaction_request: TransactionRequest): Promise<TransactionId>;
4827
+ /**
4828
+ * Executes a batch of transactions against the specified account, proves them individually
4829
+ * and as a batch, submits the batch to the network, and atomically applies the per-tx
4830
+ * updates to the local store. Returns the block number the batch was accepted into.
4831
+ *
4832
+ * All transactions must target the same local account — the `account_id` argument.
4833
+ * Each element of `transaction_requests` is the serialized-bytes form of a
4834
+ * `TransactionRequest` (obtained via `tx_request.serialize()`)
4835
+ */
4836
+ submitNewTransactionBatch(account_id: AccountId, transaction_requests: Uint8Array[]): Promise<number>;
4747
4837
  /**
4748
4838
  * Executes a transaction specified by the request against the specified account, proves it
4749
4839
  * with the user provided prover, submits it to the network, and updates the local database.
@@ -14,6 +14,8 @@ export {
14
14
  AccountStorage,
15
15
  AdviceMap,
16
16
  AssetVault,
17
+ BasicFungibleFaucetComponent,
18
+ EthAddress,
17
19
  Felt,
18
20
  InputNoteRecord,
19
21
  Note,
package/dist/mt/eager.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { getWasmOrThrow } from './index.js';
2
2
  export { AccountType, AuthScheme, CompilerResource, Linking, MidenArrays, MidenClient, MockWasmWebClient, MockWasmWebClient as MockWebClient, NoteVisibility, StorageMode, StorageResult, StorageView, WasmWebClient, buildSwapTag, createP2IDENote, createP2IDNote, withSyncLock, wordToBigInt } from './index.js';
3
- export { Account, AccountArray, AccountBuilder, AccountBuilderResult, AccountCode, AccountComponent, AccountComponentCode, AccountDelta, AccountFile, AccountHeader, AccountId, AccountIdArray, AccountInterface, AccountProof, AccountReader, AccountStatus, AccountStorage, AccountStorageDelta, AccountStorageMode, AccountStorageRequirements, AccountVaultDelta, Address, AdviceInputs, AdviceMap, AssetVault, AuthFalcon512RpoMultisigConfig, AuthSecretKey, BasicFungibleFaucetComponent, BlockHeader, CodeBuilder, CommittedNote, ConsumableNoteRecord, Endpoint, ExecutedTransaction, Felt, FeltArray, FetchedAccount, FetchedNote, FlattenedU8Vec, ForeignAccount, ForeignAccountArray, FungibleAsset, FungibleAssetDelta, FungibleAssetDeltaItem, GetProceduresResultItem, InputNote, InputNoteRecord, InputNoteState, InputNotes, IntoUnderlyingByteSource, IntoUnderlyingSink, IntoUnderlyingSource, JsAccountUpdate, JsSettingMutation, JsStateSyncUpdate, JsStorageMapEntry, JsStorageSlot, JsVaultAsset, Library, MerklePath, NetworkId, NetworkNoteStatusInfo, NetworkType, Note, NoteAndArgs, NoteAndArgsArray, NoteArray, NoteAssets, NoteAttachment, NoteAttachmentScheme, NoteConsumability, NoteConsumptionStatus, NoteDetails, NoteDetailsAndTag, NoteDetailsAndTagArray, NoteExecutionHint, NoteExportFormat, NoteFile, NoteFilter, NoteFilterTypes, NoteHeader, NoteId, NoteIdAndArgs, NoteIdAndArgsArray, NoteInclusionProof, NoteLocation, NoteMetadata, NoteRecipient, NoteRecipientArray, NoteScript, NoteStorage, NoteSyncBlock, NoteSyncInfo, NoteTag, NoteType, OutputNote, OutputNoteArray, OutputNoteRecord, OutputNoteState, OutputNotes, Package, PartialNote, Poseidon2, ProcedureThreshold, Program, ProvenTransaction, PswapLineageRecord, PswapLineageState, PublicKey, RpcClient, Rpo256, SerializedInputNoteData, SerializedOutputNoteData, SerializedTransactionData, Signature, SigningInputs, SigningInputsType, SlotAndKeys, SparseMerklePath, StorageMap, StorageMapEntry, StorageMapEntryJs, StorageMapInfo, StorageMapUpdate, StorageSlot, StorageSlotArray, SyncSummary, TestUtils, TokenSymbol, TransactionArgs, TransactionFilter, TransactionId, TransactionProver, TransactionRecord, TransactionRequest, TransactionRequestBuilder, TransactionResult, TransactionScript, TransactionScriptInputPair, TransactionScriptInputPairArray, TransactionStatus, TransactionStoreUpdate, TransactionSummary, WebClient, WebKeystoreApi, Word, createAuthFalcon512RpoMultisig, exportStore, importStore, initSync, initThreadPool, mtProbeAsync, mtProbeSync, parallelSumBench, rayonThreadCount, sequentialSumBench, setupLogging, wbg_rayon_PoolBuilder, wbg_rayon_start_worker } from './Cargo-D2qNRrNR.js';
3
+ export { Account, AccountArray, AccountBuilder, AccountBuilderResult, AccountCode, AccountComponent, AccountComponentCode, AccountDelta, AccountFile, AccountHeader, AccountId, AccountIdArray, AccountInterface, AccountProof, AccountReader, AccountStatus, AccountStorage, AccountStorageDelta, AccountStorageMode, AccountStorageRequirements, AccountVaultDelta, Address, AdviceInputs, AdviceMap, AssetVault, AuthFalcon512RpoMultisigConfig, AuthSecretKey, BasicFungibleFaucetComponent, BlockHeader, CodeBuilder, CommittedNote, ConsumableNoteRecord, Endpoint, EthAddress, ExecutedTransaction, Felt, FeltArray, FetchedAccount, FetchedNote, FlattenedU8Vec, ForeignAccount, ForeignAccountArray, FungibleAsset, FungibleAssetDelta, FungibleAssetDeltaItem, GetProceduresResultItem, InputNote, InputNoteRecord, InputNoteState, InputNotes, IntoUnderlyingByteSource, IntoUnderlyingSink, IntoUnderlyingSource, JsAccountUpdate, JsSettingMutation, JsStateSyncUpdate, JsStorageMapEntry, JsStorageSlot, JsVaultAsset, Library, MerklePath, NetworkId, NetworkNoteStatusInfo, NetworkType, Note, NoteAndArgs, NoteAndArgsArray, NoteArray, NoteAssets, NoteAttachment, NoteAttachmentScheme, NoteConsumability, NoteConsumptionStatus, NoteDetails, NoteDetailsAndTag, NoteDetailsAndTagArray, NoteExecutionHint, NoteExportFormat, NoteFile, NoteFilter, NoteFilterTypes, NoteHeader, NoteId, NoteIdAndArgs, NoteIdAndArgsArray, NoteInclusionProof, NoteLocation, NoteMetadata, NoteRecipient, NoteRecipientArray, NoteScript, NoteStorage, NoteSyncBlock, NoteSyncInfo, NoteTag, NoteType, OutputNote, OutputNoteArray, OutputNoteRecord, OutputNoteState, OutputNotes, Package, PartialNote, Poseidon2, ProcedureThreshold, Program, ProvenTransaction, PswapLineageRecord, PswapLineageState, PublicKey, RpcClient, Rpo256, SerializedInputNoteData, SerializedOutputNoteData, SerializedTransactionData, Signature, SigningInputs, SigningInputsType, SlotAndKeys, SparseMerklePath, StorageMap, StorageMapEntry, StorageMapEntryJs, StorageMapInfo, StorageMapUpdate, StorageSlot, StorageSlotArray, SyncSummary, TestUtils, TokenSymbol, TransactionArgs, TransactionFilter, TransactionId, TransactionProver, TransactionRecord, TransactionRequest, TransactionRequestBuilder, TransactionResult, TransactionScript, TransactionScriptInputPair, TransactionScriptInputPairArray, TransactionStatus, TransactionStoreUpdate, TransactionSummary, WebClient, WebKeystoreApi, Word, createAuthFalcon512RpoMultisig, exportStore, importStore, initSync, initThreadPool, mtProbeAsync, mtProbeSync, parallelSumBench, rayonThreadCount, sequentialSumBench, setupLogging, wbg_rayon_PoolBuilder, wbg_rayon_start_worker } from './Cargo-DjVnfWKi.js';
4
4
  import './wasm.js';
5
5
 
6
6
  // Eager entry point for @miden-sdk/miden-sdk (browser builds).
@@ -62,6 +62,9 @@ export declare class StorageResult {
62
62
  /** Returns all four Felts of the stored Word. Pass-through to Word.toFelts(). */
63
63
  toFelts(): Felt[];
64
64
 
65
+ /** Returns all four elements of the stored Word as a BigUint64Array. Pass-through to Word.toU64s(). */
66
+ toU64s(): BigUint64Array;
67
+
65
68
  /** The first Felt of the stored Word. */
66
69
  felt(): Felt | undefined;
67
70
 
package/dist/mt/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import loadWasm from './wasm.js';
2
- export { Account, AccountArray, AccountBuilder, AccountBuilderResult, AccountCode, AccountComponent, AccountComponentCode, AccountDelta, AccountFile, AccountHeader, AccountId, AccountIdArray, AccountInterface, AccountProof, AccountReader, AccountStatus, AccountStorage, AccountStorageDelta, AccountStorageMode, AccountStorageRequirements, AccountVaultDelta, Address, AdviceInputs, AdviceMap, AssetVault, AuthFalcon512RpoMultisigConfig, AuthSecretKey, BasicFungibleFaucetComponent, BlockHeader, CodeBuilder, CommittedNote, ConsumableNoteRecord, Endpoint, ExecutedTransaction, Felt, FeltArray, FetchedAccount, FetchedNote, FlattenedU8Vec, ForeignAccount, ForeignAccountArray, FungibleAsset, FungibleAssetDelta, FungibleAssetDeltaItem, GetProceduresResultItem, InputNote, InputNoteRecord, InputNoteState, InputNotes, IntoUnderlyingByteSource, IntoUnderlyingSink, IntoUnderlyingSource, JsAccountUpdate, JsSettingMutation, JsStateSyncUpdate, JsStorageMapEntry, JsStorageSlot, JsVaultAsset, Library, MerklePath, NetworkId, NetworkNoteStatusInfo, NetworkType, Note, NoteAndArgs, NoteAndArgsArray, NoteArray, NoteAssets, NoteAttachment, NoteAttachmentScheme, NoteConsumability, NoteConsumptionStatus, NoteDetails, NoteDetailsAndTag, NoteDetailsAndTagArray, NoteExecutionHint, NoteExportFormat, NoteFile, NoteFilter, NoteFilterTypes, NoteHeader, NoteId, NoteIdAndArgs, NoteIdAndArgsArray, NoteInclusionProof, NoteLocation, NoteMetadata, NoteRecipient, NoteRecipientArray, NoteScript, NoteStorage, NoteSyncBlock, NoteSyncInfo, NoteTag, NoteType, OutputNote, OutputNoteArray, OutputNoteRecord, OutputNoteState, OutputNotes, Package, PartialNote, Poseidon2, ProcedureThreshold, Program, ProvenTransaction, PswapLineageRecord, PswapLineageState, PublicKey, RpcClient, Rpo256, SerializedInputNoteData, SerializedOutputNoteData, SerializedTransactionData, Signature, SigningInputs, SigningInputsType, SlotAndKeys, SparseMerklePath, StorageMap, StorageMapEntry, StorageMapEntryJs, StorageMapInfo, StorageMapUpdate, StorageSlot, StorageSlotArray, SyncSummary, TestUtils, TokenSymbol, TransactionArgs, TransactionFilter, TransactionId, TransactionProver, TransactionRecord, TransactionRequest, TransactionRequestBuilder, TransactionResult, TransactionScript, TransactionScriptInputPair, TransactionScriptInputPairArray, TransactionStatus, TransactionStoreUpdate, TransactionSummary, WebClient, WebKeystoreApi, Word, createAuthFalcon512RpoMultisig, exportStore, importStore, initSync, initThreadPool, mtProbeAsync, mtProbeSync, parallelSumBench, rayonThreadCount, sequentialSumBench, setupLogging, wbg_rayon_PoolBuilder, wbg_rayon_start_worker } from './Cargo-D2qNRrNR.js';
2
+ export { Account, AccountArray, AccountBuilder, AccountBuilderResult, AccountCode, AccountComponent, AccountComponentCode, AccountDelta, AccountFile, AccountHeader, AccountId, AccountIdArray, AccountInterface, AccountProof, AccountReader, AccountStatus, AccountStorage, AccountStorageDelta, AccountStorageMode, AccountStorageRequirements, AccountVaultDelta, Address, AdviceInputs, AdviceMap, AssetVault, AuthFalcon512RpoMultisigConfig, AuthSecretKey, BasicFungibleFaucetComponent, BlockHeader, CodeBuilder, CommittedNote, ConsumableNoteRecord, Endpoint, EthAddress, ExecutedTransaction, Felt, FeltArray, FetchedAccount, FetchedNote, FlattenedU8Vec, ForeignAccount, ForeignAccountArray, FungibleAsset, FungibleAssetDelta, FungibleAssetDeltaItem, GetProceduresResultItem, InputNote, InputNoteRecord, InputNoteState, InputNotes, IntoUnderlyingByteSource, IntoUnderlyingSink, IntoUnderlyingSource, JsAccountUpdate, JsSettingMutation, JsStateSyncUpdate, JsStorageMapEntry, JsStorageSlot, JsVaultAsset, Library, MerklePath, NetworkId, NetworkNoteStatusInfo, NetworkType, Note, NoteAndArgs, NoteAndArgsArray, NoteArray, NoteAssets, NoteAttachment, NoteAttachmentScheme, NoteConsumability, NoteConsumptionStatus, NoteDetails, NoteDetailsAndTag, NoteDetailsAndTagArray, NoteExecutionHint, NoteExportFormat, NoteFile, NoteFilter, NoteFilterTypes, NoteHeader, NoteId, NoteIdAndArgs, NoteIdAndArgsArray, NoteInclusionProof, NoteLocation, NoteMetadata, NoteRecipient, NoteRecipientArray, NoteScript, NoteStorage, NoteSyncBlock, NoteSyncInfo, NoteTag, NoteType, OutputNote, OutputNoteArray, OutputNoteRecord, OutputNoteState, OutputNotes, Package, PartialNote, Poseidon2, ProcedureThreshold, Program, ProvenTransaction, PswapLineageRecord, PswapLineageState, PublicKey, RpcClient, Rpo256, SerializedInputNoteData, SerializedOutputNoteData, SerializedTransactionData, Signature, SigningInputs, SigningInputsType, SlotAndKeys, SparseMerklePath, StorageMap, StorageMapEntry, StorageMapEntryJs, StorageMapInfo, StorageMapUpdate, StorageSlot, StorageSlotArray, SyncSummary, TestUtils, TokenSymbol, TransactionArgs, TransactionFilter, TransactionId, TransactionProver, TransactionRecord, TransactionRequest, TransactionRequestBuilder, TransactionResult, TransactionScript, TransactionScriptInputPair, TransactionScriptInputPairArray, TransactionStatus, TransactionStoreUpdate, TransactionSummary, WebClient, WebKeystoreApi, Word, createAuthFalcon512RpoMultisig, exportStore, importStore, initSync, initThreadPool, mtProbeAsync, mtProbeSync, parallelSumBench, rayonThreadCount, sequentialSumBench, setupLogging, wbg_rayon_PoolBuilder, wbg_rayon_start_worker } from './Cargo-DjVnfWKi.js';
3
3
 
4
4
  const WorkerAction = Object.freeze({
5
5
  INIT: "init",
@@ -640,6 +640,24 @@ class TransactionsResource {
640
640
  return { txId, result };
641
641
  }
642
642
 
643
+ async bridge(opts) {
644
+ this.#client.assertNotTerminated();
645
+ const wasm = await this.#getWasm();
646
+ const { accountId, request } = await this.#buildB2AggRequest(opts, wasm);
647
+
648
+ const { txId, result } = await this.#submitOrSubmitWithProver(
649
+ accountId,
650
+ request,
651
+ opts.prover
652
+ );
653
+
654
+ if (opts.waitForConfirmation) {
655
+ await this.waitFor(txId.toHex(), { timeout: opts.timeout });
656
+ }
657
+
658
+ return { txId, result };
659
+ }
660
+
643
661
  async consume(opts) {
644
662
  this.#client.assertNotTerminated();
645
663
  const wasm = await this.#getWasm();
@@ -802,6 +820,10 @@ class TransactionsResource {
802
820
  ({ accountId, request } = await this.#buildMintRequest(opts, wasm));
803
821
  break;
804
822
  }
823
+ case "bridge": {
824
+ ({ accountId, request } = await this.#buildB2AggRequest(opts, wasm));
825
+ break;
826
+ }
805
827
  case "consume": {
806
828
  ({ accountId, request } = await this.#buildConsumeRequest(opts, wasm));
807
829
  break;
@@ -846,6 +868,163 @@ class TransactionsResource {
846
868
  async execute(opts) {
847
869
  this.#client.assertNotTerminated();
848
870
  const wasm = await this.#getWasm();
871
+ const { accountId, request } = this.#buildExecuteRequest(opts, wasm);
872
+
873
+ const { txId, result } = await this.#submitOrSubmitWithProver(
874
+ accountId,
875
+ request,
876
+ opts.prover
877
+ );
878
+
879
+ if (opts.waitForConfirmation) {
880
+ await this.waitFor(txId.toHex(), { timeout: opts.timeout });
881
+ }
882
+
883
+ return { txId, result };
884
+ }
885
+
886
+ /**
887
+ * Submit a heterogeneous batch of operations against a single account. All
888
+ * operations are executed, proven individually and as a batch, and submitted
889
+ * atomically — either every tx in the batch lands or none does.
890
+ *
891
+ * @param {BatchOptions} opts - Batch options including the account, operations array, and confirmation settings.
892
+ * @returns {Promise<BatchSubmitResult>} The block number the batch was accepted into.
893
+ */
894
+ async batch(opts) {
895
+ this.#client.assertNotTerminated();
896
+ const wasm = await this.#getWasm();
897
+
898
+ if (!opts || !opts.account) {
899
+ throw new Error("batch: `account` is required");
900
+ }
901
+ if (!Array.isArray(opts.operations) || opts.operations.length === 0) {
902
+ throw new Error("batch: `operations` must be a non-empty array");
903
+ }
904
+
905
+ // Build each TransactionRequest. Per-op builders all use the batch-level
906
+ // `account` — V1 only supports same-account batches, mirroring the Rust
907
+ // constraint. We forward `opts.account` into each per-op options object so
908
+ // the existing builders' `resolveAccountRef` produces fresh AccountIds
909
+ // when needed.
910
+ const requests = [];
911
+ for (let i = 0; i < opts.operations.length; i++) {
912
+ const op = opts.operations[i];
913
+ let built;
914
+ switch (op?.kind) {
915
+ case "send":
916
+ built = await this.#buildSendRequest(
917
+ { ...op, account: opts.account },
918
+ wasm
919
+ );
920
+ break;
921
+ case "mint":
922
+ built = await this.#buildMintRequest(
923
+ { ...op, account: opts.account },
924
+ wasm
925
+ );
926
+ break;
927
+ case "consume":
928
+ built = await this.#buildConsumeRequest(
929
+ { ...op, account: opts.account },
930
+ wasm
931
+ );
932
+ break;
933
+ case "swap":
934
+ built = await this.#buildSwapRequest(
935
+ { ...op, account: opts.account },
936
+ wasm
937
+ );
938
+ break;
939
+ case "execute":
940
+ built = this.#buildExecuteRequest(
941
+ { ...op, account: opts.account },
942
+ wasm
943
+ );
944
+ break;
945
+ case "custom":
946
+ if (!op.request) {
947
+ throw new Error(
948
+ `batch: operation[${i}] of kind "custom" is missing \`request\``
949
+ );
950
+ }
951
+ built = { request: op.request };
952
+ break;
953
+ default:
954
+ throw new Error(
955
+ `batch: operation[${i}] has unknown kind "${op?.kind}"`
956
+ );
957
+ }
958
+ requests.push(built.request);
959
+ }
960
+
961
+ return this.submitBatch(opts.account, requests, opts);
962
+ }
963
+
964
+ /**
965
+ * Submit pre-built TransactionRequests as an atomic batch. Lower-level
966
+ * counterpart of `batch()` — for callers that already have built requests in
967
+ * hand. Equivalent to `submit()` but plural.
968
+ *
969
+ * @param {AccountRef} account - The account executing the batch.
970
+ * @param {TransactionRequest[]} requests - Pre-built transaction requests.
971
+ * @param {object} [options] - Optional settings (waitForConfirmation, timeout).
972
+ * The batch is proved with the client's configured prover; the V1 batch API
973
+ * has no per-call prover override.
974
+ * @returns {Promise<BatchSubmitResult>} The block number the batch was accepted into.
975
+ */
976
+ async submitBatch(account, requests, options) {
977
+ this.#client.assertNotTerminated();
978
+ const wasm = await this.#getWasm();
979
+
980
+ if (!Array.isArray(requests) || requests.length === 0) {
981
+ throw new Error("submitBatch: `requests` must be a non-empty array");
982
+ }
983
+
984
+ const accountId = resolveAccountRef(account, wasm);
985
+ const blockNumber = await this.#inner.submitNewTransactionBatch(
986
+ accountId,
987
+ requests.map((r) => r.serialize())
988
+ );
989
+
990
+ if (options?.waitForConfirmation) {
991
+ await this.#waitForBlock(blockNumber, options);
992
+ }
993
+
994
+ return { blockNumber };
995
+ }
996
+
997
+ /**
998
+ * Polls until the local sync height reaches `blockNumber` or the timeout
999
+ * expires. The Rust V1 batch API returns only a block number — there are no
1000
+ * per-tx ids to poll on, so we wait on the chain height instead.
1001
+ *
1002
+ * @param {number} blockNumber - The block height to wait for.
1003
+ * @param {object} [opts] - Polling options (timeout, interval).
1004
+ */
1005
+ async #waitForBlock(blockNumber, opts) {
1006
+ const timeout = opts?.timeout ?? 60_000;
1007
+ const interval = opts?.interval ?? 5_000;
1008
+ const start = Date.now();
1009
+
1010
+ while (true) {
1011
+ if (timeout > 0 && Date.now() - start >= timeout) {
1012
+ throw new Error(
1013
+ `Batch confirmation timed out after ${timeout}ms (waiting for block ${blockNumber})`
1014
+ );
1015
+ }
1016
+ try {
1017
+ await this.#inner.syncStateWithTimeout(0);
1018
+ } catch {
1019
+ // sync may fail transiently; continue polling
1020
+ }
1021
+ const height = await this.#inner.getSyncHeight();
1022
+ if (height >= blockNumber) return;
1023
+ await new Promise((resolve) => setTimeout(resolve, interval));
1024
+ }
1025
+ }
1026
+
1027
+ #buildExecuteRequest(opts, wasm) {
849
1028
  const accountId = resolveAccountRef(opts.account, wasm);
850
1029
 
851
1030
  let builder = new wasm.TransactionRequestBuilder().withCustomScript(
@@ -873,18 +1052,7 @@ class TransactionsResource {
873
1052
  );
874
1053
  }
875
1054
 
876
- const request = builder.build();
877
- const { txId, result } = await this.#submitOrSubmitWithProver(
878
- accountId,
879
- request,
880
- opts.prover
881
- );
882
-
883
- if (opts.waitForConfirmation) {
884
- await this.waitFor(txId.toHex(), { timeout: opts.timeout });
885
- }
886
-
887
- return { txId, result };
1055
+ return { accountId, request: builder.build() };
888
1056
  }
889
1057
 
890
1058
  async executeProgram(opts) {
@@ -1057,6 +1225,24 @@ class TransactionsResource {
1057
1225
  return { accountId, request };
1058
1226
  }
1059
1227
 
1228
+ async #buildB2AggRequest(opts, wasm) {
1229
+ const accountId = resolveAccountRef(opts.account, wasm);
1230
+ const bridgeAccountId = resolveAccountRef(opts.bridgeAccount, wasm);
1231
+ const faucetId = resolveAccountRef(opts.token, wasm);
1232
+ const amount = BigInt(opts.amount);
1233
+ const destinationAddress = wasm.EthAddress.fromHex(opts.destinationAddress);
1234
+
1235
+ const request = await this.#inner.newB2AggTransactionRequest(
1236
+ accountId,
1237
+ bridgeAccountId,
1238
+ faucetId,
1239
+ amount,
1240
+ opts.destinationNetwork,
1241
+ destinationAddress
1242
+ );
1243
+ return { accountId, request };
1244
+ }
1245
+
1060
1246
  async #buildConsumeRequest(opts, wasm) {
1061
1247
  const accountId = resolveAccountRef(opts.account, wasm);
1062
1248
  const noteInputs = Array.isArray(opts.notes) ? opts.notes : [opts.notes];
@@ -2487,6 +2673,17 @@ class StorageResult {
2487
2673
  return this.#word.toFelts();
2488
2674
  }
2489
2675
 
2676
+ /**
2677
+ * Returns all four elements of the stored Word as a BigUint64Array.
2678
+ * Pass-through to Word.toU64s() — ensures code that expects a Word-like
2679
+ * object (e.g., `result.toU64s()[0]`) works on StorageResult.
2680
+ * @returns {BigUint64Array}
2681
+ */
2682
+ toU64s() {
2683
+ if (!this.#word) return new BigUint64Array();
2684
+ return this.#word.toU64s();
2685
+ }
2686
+
2490
2687
  /**
2491
2688
  * The first Felt of the stored Word.
2492
2689
  * Returns the WASM Felt object — use .asInt() to get its BigInt value.
@@ -2639,6 +2836,7 @@ const SYNC_METHODS = new Set([
2639
2836
  "buildSwapTag",
2640
2837
  "createCodeBuilder",
2641
2838
  "lastAuthError",
2839
+ "newB2AggTransactionRequest",
2642
2840
  "newConsumeTransactionRequest",
2643
2841
  "newMintTransactionRequest",
2644
2842
  "newPswapCancelTransactionRequest",