@miden-sdk/miden-sdk 0.14.2 → 0.14.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.
- package/README.md +86 -0
- package/dist/{Cargo-D44KIErf.js → Cargo-Bwjf7IkR.js} +143 -89
- package/dist/Cargo-Bwjf7IkR.js.map +1 -0
- package/dist/api-types.d.ts +33 -0
- package/dist/assets/miden_client_web.wasm +0 -0
- package/dist/crates/miden_client_web.d.ts +47 -3
- package/dist/eager.js +35 -0
- package/dist/eager.js.map +1 -0
- package/dist/index.js +327 -126
- package/dist/index.js.map +1 -1
- package/dist/wasm.js +1 -1
- package/dist/workers/{Cargo-D44KIErf-BV9FX7WD.js → Cargo-Bwjf7IkR-Cz54YuXA.js} +143 -89
- package/dist/workers/Cargo-Bwjf7IkR-Cz54YuXA.js.map +1 -0
- package/dist/workers/assets/miden_client_web.wasm +0 -0
- package/dist/workers/web-client-methods-worker.js +156 -98
- package/dist/workers/web-client-methods-worker.js.map +1 -1
- package/dist/workers/web-client-methods-worker.module.js +13 -9
- package/dist/workers/web-client-methods-worker.module.js.map +1 -1
- package/package.json +11 -4
- package/dist/Cargo-D44KIErf.js.map +0 -1
- package/dist/workers/Cargo-D44KIErf-BV9FX7WD.js.map +0 -1
package/dist/api-types.d.ts
CHANGED
|
@@ -921,6 +921,15 @@ export declare class MidenClient {
|
|
|
921
921
|
static createDevnet(options?: ClientOptions): Promise<MidenClient>;
|
|
922
922
|
/** Creates a mock client for testing. */
|
|
923
923
|
static createMock(options?: MockOptions): Promise<MidenClient>;
|
|
924
|
+
/**
|
|
925
|
+
* Resolves once the WASM module is initialized and safe to use.
|
|
926
|
+
*
|
|
927
|
+
* Idempotent and shared across callers — concurrent invocations await the
|
|
928
|
+
* same in-flight promise, and post-init callers resolve immediately.
|
|
929
|
+
* Primarily useful on the `/lazy` entry (Next.js / Capacitor) where no
|
|
930
|
+
* top-level await runs at import time; harmless on the eager entry.
|
|
931
|
+
*/
|
|
932
|
+
static ready(): Promise<void>;
|
|
924
933
|
|
|
925
934
|
readonly accounts: AccountsResource;
|
|
926
935
|
readonly transactions: TransactionsResource;
|
|
@@ -934,6 +943,30 @@ export declare class MidenClient {
|
|
|
934
943
|
sync(options?: { timeout?: number }): Promise<SyncSummary>;
|
|
935
944
|
/** Returns the current sync height. */
|
|
936
945
|
getSyncHeight(): Promise<number>;
|
|
946
|
+
/**
|
|
947
|
+
* Resolves once every serialized WASM call that was already on the
|
|
948
|
+
* internal call chain when `waitForIdle()` was called (execute, submit,
|
|
949
|
+
* prove, apply, sync, or account creation) has settled. Use this from
|
|
950
|
+
* callers that need to perform a non-WASM-side action — e.g. clearing
|
|
951
|
+
* an in-memory auth key on wallet lock — after the kernel finishes, so
|
|
952
|
+
* its auth callback doesn't race with the key being cleared. Does NOT
|
|
953
|
+
* wait for calls enqueued after `waitForIdle()` returns.
|
|
954
|
+
*
|
|
955
|
+
* Caveat for `sync`: a `syncState` blocked on its sync lock (Web
|
|
956
|
+
* Locks) has not yet reached the internal chain, so `waitForIdle`
|
|
957
|
+
* does not await it. Other serialized methods are always observed.
|
|
958
|
+
*
|
|
959
|
+
* Returns immediately if nothing was in flight.
|
|
960
|
+
*/
|
|
961
|
+
waitForIdle(): Promise<void>;
|
|
962
|
+
/**
|
|
963
|
+
* Returns the raw JS value that the most recent sign-callback invocation
|
|
964
|
+
* threw, or `null` if the last sign call succeeded (or no call has
|
|
965
|
+
* happened yet). Useful for recovering structured metadata (e.g. a
|
|
966
|
+
* `reason: 'locked'` property) that the kernel-level `auth::request`
|
|
967
|
+
* diagnostic would otherwise erase.
|
|
968
|
+
*/
|
|
969
|
+
lastAuthError(): unknown;
|
|
937
970
|
/** Returns the client-level default prover. */
|
|
938
971
|
readonly defaultProver: TransactionProver | null;
|
|
939
972
|
/** Terminates the underlying Web Worker. After this, all method calls throw. */
|
|
Binary file
|
|
@@ -1005,6 +1005,15 @@ export class BlockHeader {
|
|
|
1005
1005
|
* Returns the commitment to the block contents.
|
|
1006
1006
|
*/
|
|
1007
1007
|
commitment(): Word;
|
|
1008
|
+
/**
|
|
1009
|
+
* Returns the account ID of the fungible faucet whose assets are accepted as the native
|
|
1010
|
+
* asset of the blockchain (i.e. the asset used for paying transaction verification fees).
|
|
1011
|
+
*
|
|
1012
|
+
* This is stored on-chain as part of the block's fee parameters, which means consumers can
|
|
1013
|
+
* discover the native faucet by reading any block header rather than hardcoding it per
|
|
1014
|
+
* network.
|
|
1015
|
+
*/
|
|
1016
|
+
nativeAssetId(): AccountId;
|
|
1008
1017
|
/**
|
|
1009
1018
|
* Returns the note commitment root.
|
|
1010
1019
|
*/
|
|
@@ -4316,6 +4325,31 @@ export class WebClient {
|
|
|
4316
4325
|
importNoteFile(note_file: NoteFile): Promise<NoteId>;
|
|
4317
4326
|
importPublicAccountFromSeed(init_seed: Uint8Array, mutable: boolean, auth_scheme: AuthScheme): Promise<Account>;
|
|
4318
4327
|
insertAccountAddress(account_id: AccountId, address: Address): Promise<void>;
|
|
4328
|
+
/**
|
|
4329
|
+
* Returns the raw JS value that the most recent sign-callback invocation
|
|
4330
|
+
* threw, or `null` if the last sign call succeeded (or no call has
|
|
4331
|
+
* happened yet).
|
|
4332
|
+
*
|
|
4333
|
+
* Combined with the serialized-call discipline enforced at the JS
|
|
4334
|
+
* `WebClient` wrapper, this lets a caller that caught a failed
|
|
4335
|
+
* `executeTransaction` / `submitNewTransaction` recover the original
|
|
4336
|
+
* JS error the signing callback threw — preserving any structured
|
|
4337
|
+
* metadata (e.g. a `reason: 'locked'` property) that the kernel-level
|
|
4338
|
+
* `auth::request` diagnostic would otherwise have erased.
|
|
4339
|
+
*
|
|
4340
|
+
* # Usage (TS)
|
|
4341
|
+
* ```ts
|
|
4342
|
+
* try {
|
|
4343
|
+
* await client.submitNewTransaction(acc, req);
|
|
4344
|
+
* } catch (e) {
|
|
4345
|
+
* const authErr = client.lastAuthError();
|
|
4346
|
+
* if (authErr && authErr.reason === 'locked') {
|
|
4347
|
+
* // wait for unlock, then retry
|
|
4348
|
+
* }
|
|
4349
|
+
* }
|
|
4350
|
+
* ```
|
|
4351
|
+
*/
|
|
4352
|
+
lastAuthError(): any;
|
|
4319
4353
|
/**
|
|
4320
4354
|
* Returns all the existing setting keys from the store.
|
|
4321
4355
|
*/
|
|
@@ -4338,10 +4372,20 @@ export class WebClient {
|
|
|
4338
4372
|
newWallet(storage_mode: AccountStorageMode, mutable: boolean, auth_scheme: AuthScheme, init_seed?: Uint8Array | null): Promise<Account>;
|
|
4339
4373
|
proveBlock(): void;
|
|
4340
4374
|
/**
|
|
4341
|
-
* Generates a transaction proof using
|
|
4342
|
-
* prover if none is supplied.
|
|
4375
|
+
* Generates a transaction proof using the client's default (local) prover.
|
|
4343
4376
|
*/
|
|
4344
|
-
proveTransaction(transaction_result: TransactionResult
|
|
4377
|
+
proveTransaction(transaction_result: TransactionResult): Promise<ProvenTransaction>;
|
|
4378
|
+
/**
|
|
4379
|
+
* Generates a transaction proof using the provided prover.
|
|
4380
|
+
*
|
|
4381
|
+
* Takes the prover by reference so the JS-side handle is NOT consumed
|
|
4382
|
+
* by wasm-bindgen. Taking `TransactionProver` by value would transfer
|
|
4383
|
+
* ownership on each call, invalidating the JS object's internal WASM
|
|
4384
|
+
* handle; after one use, subsequent calls from JS would pass a dangling
|
|
4385
|
+
* handle that wasm-bindgen interprets as `None`, silently falling back
|
|
4386
|
+
* to the local prover.
|
|
4387
|
+
*/
|
|
4388
|
+
proveTransactionWithProver(transaction_result: TransactionResult, prover: TransactionProver): Promise<ProvenTransaction>;
|
|
4345
4389
|
/**
|
|
4346
4390
|
* Prunes historical account states for the specified account up to the given nonce.
|
|
4347
4391
|
*
|
package/dist/eager.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { getWasmOrThrow } from './index.js';
|
|
2
|
+
export { AccountType, AuthScheme, CompilerResource, Linking, MidenArrays, MidenClient, MockWasmWebClient, NoteVisibility, StorageMode, WasmWebClient, buildSwapTag, createP2IDENote, createP2IDNote } 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, JsStateSyncUpdate, JsStorageMapEntry, JsStorageSlot, JsVaultAsset, Library, MerklePath, NetworkId, NetworkType, Note, NoteAndArgs, NoteAndArgsArray, NoteArray, NoteAssets, NoteAttachment, NoteAttachmentKind, 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, PublicKey, RpcClient, Rpo256, SerializedInputNoteData, SerializedOutputNoteData, SerializedTransactionData, Signature, SigningInputs, SigningInputsType, SlotAndKeys, SparseMerklePath, StorageMap, StorageMapEntry, 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, setupLogging } from './Cargo-Bwjf7IkR.js';
|
|
4
|
+
import './wasm.js';
|
|
5
|
+
|
|
6
|
+
// Eager entry point for @miden-sdk/miden-sdk.
|
|
7
|
+
//
|
|
8
|
+
// Awaits WASM initialization at module top level, so importing this module
|
|
9
|
+
// guarantees that any wasm-bindgen constructor (`new RpcClient(...)`,
|
|
10
|
+
// `AccountId.fromHex(...)`, `TransactionProver.newRemoteProver(...)`, etc.)
|
|
11
|
+
// is safe to call synchronously on the next line. No explicit
|
|
12
|
+
// `await MidenClient.ready()` / `isReady` gate is required.
|
|
13
|
+
//
|
|
14
|
+
// This is the default entry (`@miden-sdk/miden-sdk` → `./dist/eager.js`).
|
|
15
|
+
//
|
|
16
|
+
// When NOT to use this entry:
|
|
17
|
+
// - **Capacitor mobile apps** (Miden Wallet iOS/Android): Capacitor's
|
|
18
|
+
// `capacitor://localhost` scheme handler interacts poorly with top-level
|
|
19
|
+
// await in the main WKWebView. Verified empirically: TLA in a Capacitor
|
|
20
|
+
// host WKWebView hangs module evaluation indefinitely, while the same
|
|
21
|
+
// TLA in the dApp-browser WKWebView (vanilla HTTPS) resolves in <100ms.
|
|
22
|
+
// - **Next.js / SSR**: TLA blocks server-side module evaluation.
|
|
23
|
+
// - **Framework adapters (@miden-sdk/react, etc.)**: they manage readiness
|
|
24
|
+
// via their own state machine (e.g. `isReady`) and should not impose
|
|
25
|
+
// TLA on consumer bundles.
|
|
26
|
+
//
|
|
27
|
+
// For those contexts, import from `@miden-sdk/miden-sdk/lazy` — identical
|
|
28
|
+
// API surface, no top-level await, callers are responsible for awaiting
|
|
29
|
+
// `MidenClient.ready()` (or the equivalent) before touching wasm-bindgen
|
|
30
|
+
// types.
|
|
31
|
+
|
|
32
|
+
await getWasmOrThrow();
|
|
33
|
+
|
|
34
|
+
export { getWasmOrThrow };
|
|
35
|
+
//# sourceMappingURL=eager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eager.js","sources":["../js/eager.js"],"sourcesContent":["// Eager entry point for @miden-sdk/miden-sdk.\n//\n// Awaits WASM initialization at module top level, so importing this module\n// guarantees that any wasm-bindgen constructor (`new RpcClient(...)`,\n// `AccountId.fromHex(...)`, `TransactionProver.newRemoteProver(...)`, etc.)\n// is safe to call synchronously on the next line. No explicit\n// `await MidenClient.ready()` / `isReady` gate is required.\n//\n// This is the default entry (`@miden-sdk/miden-sdk` → `./dist/eager.js`).\n//\n// When NOT to use this entry:\n// - **Capacitor mobile apps** (Miden Wallet iOS/Android): Capacitor's\n// `capacitor://localhost` scheme handler interacts poorly with top-level\n// await in the main WKWebView. Verified empirically: TLA in a Capacitor\n// host WKWebView hangs module evaluation indefinitely, while the same\n// TLA in the dApp-browser WKWebView (vanilla HTTPS) resolves in <100ms.\n// - **Next.js / SSR**: TLA blocks server-side module evaluation.\n// - **Framework adapters (@miden-sdk/react, etc.)**: they manage readiness\n// via their own state machine (e.g. `isReady`) and should not impose\n// TLA on consumer bundles.\n//\n// For those contexts, import from `@miden-sdk/miden-sdk/lazy` — identical\n// API surface, no top-level await, callers are responsible for awaiting\n// `MidenClient.ready()` (or the equivalent) before touching wasm-bindgen\n// types.\nimport { getWasmOrThrow } from \"./index.js\";\n\nawait getWasmOrThrow();\n\nexport * from \"./index.js\";\n"],"names":[],"mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,MAAM,cAAc,EAAE;;;;"}
|