@miden-sdk/miden-sdk 0.15.6 → 0.15.7
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.
- package/README.md +15 -0
- package/dist/mt/{Cargo-mvyTli7g.js → Cargo-CnGom-_z.js} +119 -76
- package/dist/mt/Cargo-CnGom-_z.js.map +1 -0
- package/dist/mt/api-types.d.ts +120 -0
- package/dist/mt/assets/miden_client_web.wasm +0 -0
- package/dist/mt/crates/miden_client_web.d.ts +32 -0
- package/dist/mt/docs-entry.d.ts +3 -0
- package/dist/mt/eager.js +1 -1
- package/dist/mt/index.js +252 -5
- package/dist/mt/index.js.map +1 -1
- package/dist/mt/wasm.js +1 -1
- package/dist/mt/workerHelpers.js +1 -1
- package/dist/mt/workers/{Cargo-mvyTli7g-BwMMSyoq.js → Cargo-CnGom-_z-X_3VwTbo.js} +119 -76
- package/dist/mt/workers/{Cargo-mvyTli7g-BwMMSyoq.js.map → Cargo-CnGom-_z-X_3VwTbo.js.map} +1 -1
- package/dist/mt/workers/assets/miden_client_web.wasm +0 -0
- package/dist/mt/workers/web-client-methods-worker.js +120 -76
- package/dist/mt/workers/web-client-methods-worker.js.map +1 -1
- package/dist/mt/workers/web-client-methods-worker.module.js +1 -1
- package/dist/mt/workers/web-client-methods-worker.module.js.map +1 -1
- package/dist/mt/workers/workerHelpers.js +1 -1
- package/dist/st/{Cargo-Cysp4vto.js → Cargo-DR9fiMbE.js} +117 -75
- package/dist/st/Cargo-DR9fiMbE.js.map +1 -0
- package/dist/st/api-types.d.ts +120 -0
- package/dist/st/assets/miden_client_web.wasm +0 -0
- package/dist/st/crates/miden_client_web.d.ts +32 -0
- package/dist/st/docs-entry.d.ts +3 -0
- package/dist/st/eager.js +1 -1
- package/dist/st/index.js +252 -5
- package/dist/st/index.js.map +1 -1
- package/dist/st/wasm.js +1 -1
- package/dist/st/workers/{Cargo-Cysp4vto-BIw-TeJn.js → Cargo-DR9fiMbE-C0G0clA_.js} +117 -75
- package/dist/st/workers/{Cargo-Cysp4vto-BIw-TeJn.js.map → Cargo-DR9fiMbE-C0G0clA_.js.map} +1 -1
- package/dist/st/workers/assets/miden_client_web.wasm +0 -0
- package/dist/st/workers/web-client-methods-worker.js +118 -75
- package/dist/st/workers/web-client-methods-worker.js.map +1 -1
- package/dist/st/workers/web-client-methods-worker.module.js +1 -1
- package/dist/st/workers/web-client-methods-worker.module.js.map +1 -1
- package/js/node-index.js +1 -0
- package/js/resources/transactions.js +251 -4
- package/package.json +4 -4
- package/dist/mt/Cargo-mvyTli7g.js.map +0 -1
- package/dist/st/Cargo-Cysp4vto.js.map +0 -1
package/dist/st/api-types.d.ts
CHANGED
|
@@ -14,6 +14,8 @@ import type {
|
|
|
14
14
|
TransactionId,
|
|
15
15
|
TransactionRequest,
|
|
16
16
|
TransactionResult,
|
|
17
|
+
TransactionStoreUpdate,
|
|
18
|
+
ProvenTransaction,
|
|
17
19
|
TransactionSummary,
|
|
18
20
|
TransactionRecord,
|
|
19
21
|
InputNoteRecord,
|
|
@@ -511,6 +513,81 @@ export interface BatchSubmitResult {
|
|
|
511
513
|
blockNumber: number;
|
|
512
514
|
}
|
|
513
515
|
|
|
516
|
+
/** Options for {@link TransactionExecution.prove}. */
|
|
517
|
+
export interface ProveOptions {
|
|
518
|
+
/**
|
|
519
|
+
* Per-call prover override. Falls back to the client's default prover, or
|
|
520
|
+
* the built-in local prover if none is configured.
|
|
521
|
+
*
|
|
522
|
+
* A prover is consumed by the call — build (or clone) a fresh one per
|
|
523
|
+
* `prove()`. Reusing an already-passed prover silently falls back to the
|
|
524
|
+
* built-in local prover.
|
|
525
|
+
*/
|
|
526
|
+
prover?: TransactionProver;
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
/**
|
|
530
|
+
* A locally-executed transaction — nothing proven, submitted, or persisted yet.
|
|
531
|
+
* First stage of the manual transaction lifecycle, returned by
|
|
532
|
+
* {@link TransactionsResource.executeRequest}. Advance it with {@link prove}.
|
|
533
|
+
*/
|
|
534
|
+
export interface TransactionExecution {
|
|
535
|
+
/** The raw execution artifact (account delta, output notes, …). */
|
|
536
|
+
readonly result: TransactionResult;
|
|
537
|
+
/** The executed transaction's id. */
|
|
538
|
+
readonly id: TransactionId;
|
|
539
|
+
/**
|
|
540
|
+
* Prove this execution, then continue with {@link TransactionProof.submit}.
|
|
541
|
+
* Pure computation — touches neither the network nor the local store.
|
|
542
|
+
*
|
|
543
|
+
* @param options - Optional per-call prover override.
|
|
544
|
+
*/
|
|
545
|
+
prove(options?: ProveOptions): Promise<TransactionProof>;
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
/**
|
|
549
|
+
* A proven transaction, ready for the network. Second stage of the manual
|
|
550
|
+
* transaction lifecycle, returned by {@link TransactionExecution.prove}.
|
|
551
|
+
* Advance it with {@link submit}.
|
|
552
|
+
*/
|
|
553
|
+
export interface TransactionProof {
|
|
554
|
+
/** The raw proof — e.g. to serialize and submit from a different client. */
|
|
555
|
+
readonly proof: ProvenTransaction;
|
|
556
|
+
/** The execution result this proof was produced from. */
|
|
557
|
+
readonly result: TransactionResult;
|
|
558
|
+
/**
|
|
559
|
+
* Submit the proof to the network, then persist with
|
|
560
|
+
* {@link TransactionSubmission.apply}. Does NOT persist locally on its own.
|
|
561
|
+
*/
|
|
562
|
+
submit(): Promise<TransactionSubmission>;
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
/**
|
|
566
|
+
* A submitted transaction. Final stage of the manual transaction lifecycle,
|
|
567
|
+
* returned by {@link TransactionProof.submit}. Persist it with {@link apply},
|
|
568
|
+
* or block until it commits with {@link waitForConfirmation}.
|
|
569
|
+
*/
|
|
570
|
+
export interface TransactionSubmission {
|
|
571
|
+
/** The block height the transaction was submitted at. */
|
|
572
|
+
readonly blockNumber: number;
|
|
573
|
+
/** The execution result that was submitted. */
|
|
574
|
+
readonly result: TransactionResult;
|
|
575
|
+
/**
|
|
576
|
+
* Persist the transaction into the local store, firing registered
|
|
577
|
+
* transaction observers (e.g. PSWAP lineage tracking). Until this runs the
|
|
578
|
+
* local store is unaware of the transaction.
|
|
579
|
+
*
|
|
580
|
+
* @returns The pre-apply store update.
|
|
581
|
+
*/
|
|
582
|
+
apply(): Promise<TransactionStoreUpdate>;
|
|
583
|
+
/**
|
|
584
|
+
* Poll local sync height until the transaction commits on-chain.
|
|
585
|
+
*
|
|
586
|
+
* @param options - Polling options (timeout, interval, onProgress).
|
|
587
|
+
*/
|
|
588
|
+
waitForConfirmation(options?: WaitOptions): Promise<void>;
|
|
589
|
+
}
|
|
590
|
+
|
|
514
591
|
export interface SwapOptions extends TransactionOptions {
|
|
515
592
|
account: AccountRef;
|
|
516
593
|
offer: Asset;
|
|
@@ -957,6 +1034,49 @@ export interface TransactionsResource {
|
|
|
957
1034
|
options?: TransactionOptions
|
|
958
1035
|
): Promise<TransactionSubmitResult>;
|
|
959
1036
|
|
|
1037
|
+
/**
|
|
1038
|
+
* Execute a transaction request locally — nothing is proven, submitted, or
|
|
1039
|
+
* persisted. Returns a {@link TransactionExecution} handle; advance the
|
|
1040
|
+
* lifecycle by chaining `.prove()` → `.submit()` → `.apply()`, benchmarking
|
|
1041
|
+
* or error-handling each stage independently:
|
|
1042
|
+
*
|
|
1043
|
+
* ```ts
|
|
1044
|
+
* const executed = await client.transactions.executeRequest(account, request);
|
|
1045
|
+
* const proven = await executed.prove({ prover });
|
|
1046
|
+
* const submitted = await proven.submit();
|
|
1047
|
+
* await submitted.apply();
|
|
1048
|
+
* ```
|
|
1049
|
+
*
|
|
1050
|
+
* {@link submit} runs every stage in one call. The stages are not atomic as a
|
|
1051
|
+
* group: awaiting other mutating calls on the same account between them can
|
|
1052
|
+
* interleave state — drive the chain as an uninterrupted sequence per account.
|
|
1053
|
+
*
|
|
1054
|
+
* @param account - The account executing the transaction.
|
|
1055
|
+
* @param request - The pre-built transaction request.
|
|
1056
|
+
* @returns A handle to the executed transaction, ready to prove.
|
|
1057
|
+
*/
|
|
1058
|
+
executeRequest(
|
|
1059
|
+
account: AccountRef,
|
|
1060
|
+
request: TransactionRequest
|
|
1061
|
+
): Promise<TransactionExecution>;
|
|
1062
|
+
|
|
1063
|
+
/**
|
|
1064
|
+
* Submit a proof produced somewhere that shares nothing with this client —
|
|
1065
|
+
* e.g. a detached prover that never saw the local store. Returns a
|
|
1066
|
+
* {@link TransactionSubmission} handle; call `.apply()` on it to persist
|
|
1067
|
+
* locally. For the in-process flow prefer
|
|
1068
|
+
* `executeRequest(...)` → `.prove()` → `.submit()`, which threads the proof
|
|
1069
|
+
* and result for you.
|
|
1070
|
+
*
|
|
1071
|
+
* @param proof - A proof for `result`, proven elsewhere.
|
|
1072
|
+
* @param result - The matching execution result.
|
|
1073
|
+
* @returns A handle to the submitted transaction, ready to apply.
|
|
1074
|
+
*/
|
|
1075
|
+
submitProven(
|
|
1076
|
+
proof: ProvenTransaction,
|
|
1077
|
+
result: TransactionResult
|
|
1078
|
+
): Promise<TransactionSubmission>;
|
|
1079
|
+
|
|
960
1080
|
/**
|
|
961
1081
|
* Execute a heterogeneous batch of operations against a single account.
|
|
962
1082
|
* Each operation is built, proven individually and as a batch, and all
|
|
Binary file
|
|
@@ -912,6 +912,25 @@ export class AdviceMap {
|
|
|
912
912
|
constructor();
|
|
913
913
|
}
|
|
914
914
|
|
|
915
|
+
/**
|
|
916
|
+
* Whether a faucet's asset callbacks run when an asset is added to an account or a note.
|
|
917
|
+
*
|
|
918
|
+
* The flag is part of an asset's vault key, so two assets from the same faucet with different
|
|
919
|
+
* flags occupy different vault slots and do not merge. Assets minted by a faucet that registers
|
|
920
|
+
* transfer policies carry `Enabled`; everything else carries `Disabled`.
|
|
921
|
+
*/
|
|
922
|
+
export enum AssetCallbackFlag {
|
|
923
|
+
/**
|
|
924
|
+
* The faucet's callbacks are not invoked for this asset. This is the default for an asset
|
|
925
|
+
* built via the `FungibleAsset` constructor.
|
|
926
|
+
*/
|
|
927
|
+
Disabled = 0,
|
|
928
|
+
/**
|
|
929
|
+
* The faucet's callbacks are invoked before this asset is added to an account or a note.
|
|
930
|
+
*/
|
|
931
|
+
Enabled = 1,
|
|
932
|
+
}
|
|
933
|
+
|
|
915
934
|
/**
|
|
916
935
|
* A container for an unlimited number of assets.
|
|
917
936
|
*
|
|
@@ -1595,6 +1614,10 @@ export class FungibleAsset {
|
|
|
1595
1614
|
* Returns the amount of fungible units.
|
|
1596
1615
|
*/
|
|
1597
1616
|
amount(): bigint;
|
|
1617
|
+
/**
|
|
1618
|
+
* Returns whether this asset invokes its faucet's callbacks.
|
|
1619
|
+
*/
|
|
1620
|
+
callbacks(): AssetCallbackFlag;
|
|
1598
1621
|
/**
|
|
1599
1622
|
* Returns the faucet account that minted this asset.
|
|
1600
1623
|
*/
|
|
@@ -1607,6 +1630,15 @@ export class FungibleAsset {
|
|
|
1607
1630
|
* Creates a fungible asset for the given faucet and amount.
|
|
1608
1631
|
*/
|
|
1609
1632
|
constructor(faucet_id: AccountId, amount: bigint);
|
|
1633
|
+
/**
|
|
1634
|
+
* Returns a copy of this asset carrying the given callback flag.
|
|
1635
|
+
*
|
|
1636
|
+
* The flag is part of the asset's vault key, so it must match the flag the issuing faucet
|
|
1637
|
+
* applies — an asset built with the wrong flag addresses a different vault slot than the one
|
|
1638
|
+
* holding the balance. The constructor always produces `Disabled`; pass `Enabled` only for
|
|
1639
|
+
* assets from a faucet that registers transfer policies.
|
|
1640
|
+
*/
|
|
1641
|
+
withCallbacks(callbacks: AssetCallbackFlag): FungibleAsset;
|
|
1610
1642
|
}
|
|
1611
1643
|
|
|
1612
1644
|
/**
|
package/dist/st/docs-entry.d.ts
CHANGED
|
@@ -24,6 +24,7 @@ export {
|
|
|
24
24
|
NoteFile,
|
|
25
25
|
NoteId,
|
|
26
26
|
NoteTag,
|
|
27
|
+
ProvenTransaction,
|
|
27
28
|
PswapLineageRecord,
|
|
28
29
|
PswapLineageState,
|
|
29
30
|
RawOutputNote,
|
|
@@ -33,6 +34,8 @@ export {
|
|
|
33
34
|
TransactionProver,
|
|
34
35
|
TransactionRecord,
|
|
35
36
|
TransactionRequest,
|
|
37
|
+
TransactionResult,
|
|
38
|
+
TransactionStoreUpdate,
|
|
36
39
|
TransactionSummary,
|
|
37
40
|
Word,
|
|
38
41
|
} from "./crates/miden_client_web.js";
|
package/dist/st/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, 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, NetworkAccountTarget, 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, sequentialSumBench, setupLogging } from './Cargo-
|
|
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, AssetCallbackFlag, 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, NetworkAccountTarget, 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, sequentialSumBench, setupLogging } from './Cargo-DR9fiMbE.js';
|
|
4
4
|
import './wasm.js';
|
|
5
5
|
|
|
6
6
|
// Eager entry point for @miden-sdk/miden-sdk (browser builds).
|
package/dist/st/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, 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, NetworkAccountTarget, 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, sequentialSumBench, setupLogging } from './Cargo-
|
|
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, AssetCallbackFlag, 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, NetworkAccountTarget, 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, sequentialSumBench, setupLogging } from './Cargo-DR9fiMbE.js';
|
|
3
3
|
|
|
4
4
|
const WorkerAction = Object.freeze({
|
|
5
5
|
INIT: "init",
|
|
@@ -547,6 +547,26 @@ class AccountsResource {
|
|
|
547
547
|
}
|
|
548
548
|
}
|
|
549
549
|
|
|
550
|
+
/**
|
|
551
|
+
* Prove an executed transaction, resolving the prover exactly the way the
|
|
552
|
+
* one-shot `submit()` pipeline does: the per-call prover if given, else the
|
|
553
|
+
* client's default prover, else the built-in local prover. Shared by
|
|
554
|
+
* {@link TransactionExecution.prove} and the internal pipeline so the two can
|
|
555
|
+
* never drift.
|
|
556
|
+
*
|
|
557
|
+
* @param {*} inner - The WASM WebClient.
|
|
558
|
+
* @param {*} defaultProver - The client's configured default prover, or null.
|
|
559
|
+
* @param {*} result - The execution result to prove.
|
|
560
|
+
* @param {{ prover?: * }} [opts] - Optional per-call prover override.
|
|
561
|
+
* @returns {Promise<*>} The proven transaction.
|
|
562
|
+
*/
|
|
563
|
+
async function proveResult(inner, defaultProver, result, opts) {
|
|
564
|
+
const prover = opts?.prover ?? defaultProver;
|
|
565
|
+
return prover
|
|
566
|
+
? await inner.proveTransaction(result, prover)
|
|
567
|
+
: await inner.proveTransaction(result);
|
|
568
|
+
}
|
|
569
|
+
|
|
550
570
|
class TransactionsResource {
|
|
551
571
|
#inner;
|
|
552
572
|
#getWasm;
|
|
@@ -1188,6 +1208,65 @@ class TransactionsResource {
|
|
|
1188
1208
|
);
|
|
1189
1209
|
}
|
|
1190
1210
|
|
|
1211
|
+
/**
|
|
1212
|
+
* Execute a transaction request locally — nothing is proven, submitted, or
|
|
1213
|
+
* persisted. Returns a {@link TransactionExecution} handle; advance the
|
|
1214
|
+
* lifecycle by chaining `.prove()` → `.submit()` → `.apply()`, benchmarking
|
|
1215
|
+
* or error-handling each stage independently. Use {@link submit} to run every
|
|
1216
|
+
* stage in one call.
|
|
1217
|
+
*
|
|
1218
|
+
* ```ts
|
|
1219
|
+
* const executed = await client.transactions.executeRequest(account, request);
|
|
1220
|
+
* const proven = await executed.prove({ prover });
|
|
1221
|
+
* const submitted = await proven.submit();
|
|
1222
|
+
* await submitted.apply();
|
|
1223
|
+
* ```
|
|
1224
|
+
*
|
|
1225
|
+
* The stages are NOT atomic as a group: awaiting other mutating calls on the
|
|
1226
|
+
* same account between them can interleave state. Drive the chain as an
|
|
1227
|
+
* uninterrupted sequence per account.
|
|
1228
|
+
*
|
|
1229
|
+
* @param {AccountRef} account - The account executing the transaction.
|
|
1230
|
+
* @param {TransactionRequest} request - The pre-built transaction request.
|
|
1231
|
+
* @returns {Promise<TransactionExecution>} A handle to the executed
|
|
1232
|
+
* transaction, ready to prove.
|
|
1233
|
+
*/
|
|
1234
|
+
async executeRequest(account, request) {
|
|
1235
|
+
this.#client.assertNotTerminated();
|
|
1236
|
+
const wasm = await this.#getWasm();
|
|
1237
|
+
const accountId = resolveAccountRef(account, wasm);
|
|
1238
|
+
const result = await this.#inner.executeTransaction(accountId, request);
|
|
1239
|
+
return new TransactionExecution(this.#inner, this.#client, this, result);
|
|
1240
|
+
}
|
|
1241
|
+
|
|
1242
|
+
/**
|
|
1243
|
+
* Submit a proof produced somewhere that shares nothing with this client —
|
|
1244
|
+
* e.g. a detached prover that never saw the local store. Returns a
|
|
1245
|
+
* {@link TransactionSubmission} handle; call `.apply()` on it to persist
|
|
1246
|
+
* locally. For the in-process flow prefer
|
|
1247
|
+
* `executeRequest(...)` → `.prove()` → `.submit()`, which threads the proof
|
|
1248
|
+
* and result for you.
|
|
1249
|
+
*
|
|
1250
|
+
* @param {ProvenTransaction} proof - A proof for `result`, proven elsewhere.
|
|
1251
|
+
* @param {TransactionResult} result - The matching execution result.
|
|
1252
|
+
* @returns {Promise<TransactionSubmission>} A handle to the submitted
|
|
1253
|
+
* transaction, ready to apply.
|
|
1254
|
+
*/
|
|
1255
|
+
async submitProven(proof, result) {
|
|
1256
|
+
this.#client.assertNotTerminated();
|
|
1257
|
+
const blockNumber = await this.#inner.submitProvenTransaction(
|
|
1258
|
+
proof,
|
|
1259
|
+
result
|
|
1260
|
+
);
|
|
1261
|
+
return new TransactionSubmission(
|
|
1262
|
+
this.#inner,
|
|
1263
|
+
this.#client,
|
|
1264
|
+
this,
|
|
1265
|
+
result,
|
|
1266
|
+
blockNumber
|
|
1267
|
+
);
|
|
1268
|
+
}
|
|
1269
|
+
|
|
1191
1270
|
async list(query) {
|
|
1192
1271
|
this.#client.assertNotTerminated();
|
|
1193
1272
|
const wasm = await this.#getWasm();
|
|
@@ -1478,10 +1557,12 @@ class TransactionsResource {
|
|
|
1478
1557
|
|
|
1479
1558
|
async #submitOrSubmitWithProver(accountId, request, perCallProver) {
|
|
1480
1559
|
const result = await this.#inner.executeTransaction(accountId, request);
|
|
1481
|
-
const
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1560
|
+
const proven = await proveResult(
|
|
1561
|
+
this.#inner,
|
|
1562
|
+
this.#client.defaultProver,
|
|
1563
|
+
result,
|
|
1564
|
+
{ prover: perCallProver }
|
|
1565
|
+
);
|
|
1485
1566
|
const txId = result.id();
|
|
1486
1567
|
const height = await this.#inner.submitProvenTransaction(proven, result);
|
|
1487
1568
|
await this.#inner.applyTransaction(result, height);
|
|
@@ -1489,6 +1570,172 @@ class TransactionsResource {
|
|
|
1489
1570
|
}
|
|
1490
1571
|
}
|
|
1491
1572
|
|
|
1573
|
+
/**
|
|
1574
|
+
* A locally-executed transaction — nothing proven, submitted, or persisted yet.
|
|
1575
|
+
* First stage of the manual transaction lifecycle, returned by
|
|
1576
|
+
* {@link TransactionsResource.executeRequest}. Advance it with {@link prove}.
|
|
1577
|
+
*/
|
|
1578
|
+
class TransactionExecution {
|
|
1579
|
+
#inner;
|
|
1580
|
+
#client;
|
|
1581
|
+
#resource;
|
|
1582
|
+
#result;
|
|
1583
|
+
|
|
1584
|
+
constructor(inner, client, resource, result) {
|
|
1585
|
+
this.#inner = inner;
|
|
1586
|
+
this.#client = client;
|
|
1587
|
+
this.#resource = resource;
|
|
1588
|
+
this.#result = result;
|
|
1589
|
+
}
|
|
1590
|
+
|
|
1591
|
+
/** The raw execution artifact (account delta, output notes, …). */
|
|
1592
|
+
get result() {
|
|
1593
|
+
return this.#result;
|
|
1594
|
+
}
|
|
1595
|
+
|
|
1596
|
+
/** The executed transaction's id. */
|
|
1597
|
+
get id() {
|
|
1598
|
+
return this.#result.id();
|
|
1599
|
+
}
|
|
1600
|
+
|
|
1601
|
+
/**
|
|
1602
|
+
* Prove this execution. Uses the per-call prover when provided, falling back
|
|
1603
|
+
* to the client's default prover (or the built-in local prover). Pure
|
|
1604
|
+
* computation — touches neither the network nor the local store.
|
|
1605
|
+
*
|
|
1606
|
+
* A `TransactionProver` is consumed by the call: build (or clone) a fresh
|
|
1607
|
+
* prover per `prove()`. Reusing an already-passed prover silently falls back
|
|
1608
|
+
* to the built-in local prover.
|
|
1609
|
+
*
|
|
1610
|
+
* @param {ProveOptions} [opts] - Optional per-call prover override.
|
|
1611
|
+
* @returns {Promise<TransactionProof>} A handle to the proven transaction,
|
|
1612
|
+
* ready to submit.
|
|
1613
|
+
*/
|
|
1614
|
+
async prove(opts) {
|
|
1615
|
+
this.#client.assertNotTerminated();
|
|
1616
|
+
const proven = await proveResult(
|
|
1617
|
+
this.#inner,
|
|
1618
|
+
this.#client.defaultProver,
|
|
1619
|
+
this.#result,
|
|
1620
|
+
opts
|
|
1621
|
+
);
|
|
1622
|
+
return new TransactionProof(
|
|
1623
|
+
this.#inner,
|
|
1624
|
+
this.#client,
|
|
1625
|
+
this.#resource,
|
|
1626
|
+
proven,
|
|
1627
|
+
this.#result
|
|
1628
|
+
);
|
|
1629
|
+
}
|
|
1630
|
+
}
|
|
1631
|
+
|
|
1632
|
+
/**
|
|
1633
|
+
* A proven transaction, ready for the network. Second stage of the manual
|
|
1634
|
+
* transaction lifecycle, returned by {@link TransactionExecution.prove}.
|
|
1635
|
+
* Advance it with {@link submit}.
|
|
1636
|
+
*/
|
|
1637
|
+
class TransactionProof {
|
|
1638
|
+
#inner;
|
|
1639
|
+
#client;
|
|
1640
|
+
#resource;
|
|
1641
|
+
#proof;
|
|
1642
|
+
#result;
|
|
1643
|
+
|
|
1644
|
+
constructor(inner, client, resource, proof, result) {
|
|
1645
|
+
this.#inner = inner;
|
|
1646
|
+
this.#client = client;
|
|
1647
|
+
this.#resource = resource;
|
|
1648
|
+
this.#proof = proof;
|
|
1649
|
+
this.#result = result;
|
|
1650
|
+
}
|
|
1651
|
+
|
|
1652
|
+
/** The raw proof — e.g. to serialize and submit from a different client. */
|
|
1653
|
+
get proof() {
|
|
1654
|
+
return this.#proof;
|
|
1655
|
+
}
|
|
1656
|
+
|
|
1657
|
+
/** The execution result this proof was produced from. */
|
|
1658
|
+
get result() {
|
|
1659
|
+
return this.#result;
|
|
1660
|
+
}
|
|
1661
|
+
|
|
1662
|
+
/**
|
|
1663
|
+
* Submit the proof to the network. Does NOT persist locally — call
|
|
1664
|
+
* {@link TransactionSubmission.apply} on the returned handle; skipping it
|
|
1665
|
+
* leaves the local store out of sync until the next full sync.
|
|
1666
|
+
*
|
|
1667
|
+
* @returns {Promise<TransactionSubmission>} A handle to the submitted
|
|
1668
|
+
* transaction, ready to apply.
|
|
1669
|
+
*/
|
|
1670
|
+
async submit() {
|
|
1671
|
+
this.#client.assertNotTerminated();
|
|
1672
|
+
const blockNumber = await this.#inner.submitProvenTransaction(
|
|
1673
|
+
this.#proof,
|
|
1674
|
+
this.#result
|
|
1675
|
+
);
|
|
1676
|
+
return new TransactionSubmission(
|
|
1677
|
+
this.#inner,
|
|
1678
|
+
this.#client,
|
|
1679
|
+
this.#resource,
|
|
1680
|
+
this.#result,
|
|
1681
|
+
blockNumber
|
|
1682
|
+
);
|
|
1683
|
+
}
|
|
1684
|
+
}
|
|
1685
|
+
|
|
1686
|
+
/**
|
|
1687
|
+
* A submitted transaction. Final stage of the manual transaction lifecycle,
|
|
1688
|
+
* returned by {@link TransactionProof.submit}. Persist it locally with
|
|
1689
|
+
* {@link apply}, or block until it commits with {@link waitForConfirmation}.
|
|
1690
|
+
*/
|
|
1691
|
+
class TransactionSubmission {
|
|
1692
|
+
#inner;
|
|
1693
|
+
#client;
|
|
1694
|
+
#resource;
|
|
1695
|
+
#result;
|
|
1696
|
+
#blockNumber;
|
|
1697
|
+
|
|
1698
|
+
constructor(inner, client, resource, result, blockNumber) {
|
|
1699
|
+
this.#inner = inner;
|
|
1700
|
+
this.#client = client;
|
|
1701
|
+
this.#resource = resource;
|
|
1702
|
+
this.#result = result;
|
|
1703
|
+
this.#blockNumber = blockNumber;
|
|
1704
|
+
}
|
|
1705
|
+
|
|
1706
|
+
/** The block height the transaction was submitted at. */
|
|
1707
|
+
get blockNumber() {
|
|
1708
|
+
return this.#blockNumber;
|
|
1709
|
+
}
|
|
1710
|
+
|
|
1711
|
+
/** The execution result that was submitted. */
|
|
1712
|
+
get result() {
|
|
1713
|
+
return this.#result;
|
|
1714
|
+
}
|
|
1715
|
+
|
|
1716
|
+
/**
|
|
1717
|
+
* Persist the transaction into the local store, firing registered
|
|
1718
|
+
* transaction observers (e.g. PSWAP lineage tracking). Until this runs the
|
|
1719
|
+
* local store is unaware of the transaction.
|
|
1720
|
+
*
|
|
1721
|
+
* @returns {Promise<TransactionStoreUpdate>} The pre-apply store update.
|
|
1722
|
+
*/
|
|
1723
|
+
async apply() {
|
|
1724
|
+
this.#client.assertNotTerminated();
|
|
1725
|
+
return await this.#inner.applyTransaction(this.#result, this.#blockNumber);
|
|
1726
|
+
}
|
|
1727
|
+
|
|
1728
|
+
/**
|
|
1729
|
+
* Poll local sync height until the transaction commits on-chain. Convenience
|
|
1730
|
+
* wrapper over {@link TransactionsResource.waitFor}.
|
|
1731
|
+
*
|
|
1732
|
+
* @param {WaitOptions} [opts] - Polling options (timeout, interval, onProgress).
|
|
1733
|
+
*/
|
|
1734
|
+
async waitForConfirmation(opts) {
|
|
1735
|
+
return await this.#resource.waitFor(this.#result.id().toHex(), opts);
|
|
1736
|
+
}
|
|
1737
|
+
}
|
|
1738
|
+
|
|
1492
1739
|
class NotesResource {
|
|
1493
1740
|
#inner;
|
|
1494
1741
|
#getWasm;
|