@miden-sdk/miden-sdk 0.15.1 → 0.15.2

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 (43) hide show
  1. package/README.md +39 -0
  2. package/dist/mt/{Cargo-D6y7aDQ8.js → Cargo-BbpPeJYa.js} +288 -79
  3. package/dist/mt/Cargo-BbpPeJYa.js.map +1 -0
  4. package/dist/mt/api-types.d.ts +54 -0
  5. package/dist/mt/assets/miden_client_web.wasm +0 -0
  6. package/dist/mt/crates/miden_client_web.d.ts +102 -0
  7. package/dist/mt/docs-entry.d.ts +3 -0
  8. package/dist/mt/eager.js +1 -1
  9. package/dist/mt/index.js +134 -1
  10. package/dist/mt/index.js.map +1 -1
  11. package/dist/mt/wasm.js +1 -1
  12. package/dist/mt/workerHelpers.js +1 -1
  13. package/dist/mt/workers/{Cargo-D6y7aDQ8-BbSVnZEb.js → Cargo-BbpPeJYa-BlSVzh6v.js} +288 -79
  14. package/dist/mt/workers/{Cargo-D6y7aDQ8-BbSVnZEb.js.map → Cargo-BbpPeJYa-BlSVzh6v.js.map} +1 -1
  15. package/dist/mt/workers/assets/miden_client_web.wasm +0 -0
  16. package/dist/mt/workers/web-client-methods-worker.js +290 -79
  17. package/dist/mt/workers/web-client-methods-worker.js.map +1 -1
  18. package/dist/mt/workers/web-client-methods-worker.module.js +1 -1
  19. package/dist/mt/workers/web-client-methods-worker.module.js.map +1 -1
  20. package/dist/mt/workers/workerHelpers.js +1 -1
  21. package/dist/st/{Cargo-LzqxI7kL.js → Cargo-Dlo4tWNG.js} +285 -78
  22. package/dist/st/Cargo-Dlo4tWNG.js.map +1 -0
  23. package/dist/st/api-types.d.ts +54 -0
  24. package/dist/st/assets/miden_client_web.wasm +0 -0
  25. package/dist/st/crates/miden_client_web.d.ts +102 -0
  26. package/dist/st/docs-entry.d.ts +3 -0
  27. package/dist/st/eager.js +1 -1
  28. package/dist/st/index.js +134 -1
  29. package/dist/st/index.js.map +1 -1
  30. package/dist/st/wasm.js +1 -1
  31. package/dist/st/workers/{Cargo-LzqxI7kL-9fqTseKT.js → Cargo-Dlo4tWNG-BPaiqKyy.js} +285 -78
  32. package/dist/st/workers/Cargo-Dlo4tWNG-BPaiqKyy.js.map +1 -0
  33. package/dist/st/workers/assets/miden_client_web.wasm +0 -0
  34. package/dist/st/workers/web-client-methods-worker.js +287 -78
  35. package/dist/st/workers/web-client-methods-worker.js.map +1 -1
  36. package/dist/st/workers/web-client-methods-worker.module.js +1 -1
  37. package/dist/st/workers/web-client-methods-worker.module.js.map +1 -1
  38. package/js/client.js +2 -0
  39. package/js/resources/pswap.js +132 -0
  40. package/package.json +4 -4
  41. package/dist/mt/Cargo-D6y7aDQ8.js.map +0 -1
  42. package/dist/st/Cargo-LzqxI7kL.js.map +0 -1
  43. package/dist/st/workers/Cargo-LzqxI7kL-9fqTseKT.js.map +0 -1
@@ -32,6 +32,7 @@ import type {
32
32
  NoteScript,
33
33
  AdviceInputs,
34
34
  FeltArray,
35
+ PswapLineageRecord,
35
36
  } from "./crates/miden_client_web.js";
36
37
 
37
38
  // Import the full namespace for the MidenArrayConstructors type
@@ -426,6 +427,18 @@ export interface PswapCancelOptions extends TransactionOptions {
426
427
  note: NoteInput;
427
428
  }
428
429
 
430
+ export interface PswapCancelByOrderOptions extends TransactionOptions {
431
+ /**
432
+ * Stable order id of the lineage to cancel, as reported by
433
+ * {@link PswapLineageRecord.orderId}. Accepts the decimal string or a
434
+ * `bigint`. `number` is rejected: a PSWAP order id is `u64`-shaped and
435
+ * routinely exceeds `Number.MAX_SAFE_INTEGER`, which a JS `number` cannot
436
+ * represent without silent precision loss. The creator account and current
437
+ * tip note are resolved from the tracked lineage.
438
+ */
439
+ orderId: string | bigint;
440
+ }
441
+
429
442
  export interface ExecuteOptions extends TransactionOptions {
430
443
  /** Account executing the custom script. */
431
444
  account: AccountRef;
@@ -810,6 +823,46 @@ export interface TransactionsResource {
810
823
  waitFor(txId: string | TransactionId, options?: WaitOptions): Promise<void>;
811
824
  }
812
825
 
826
+ export interface PswapResource {
827
+ /**
828
+ * Returns every partial-swap (PSWAP) lineage tracked by this client. A
829
+ * lineage records how a PSWAP note has been filled round by round, from the
830
+ * original note through each remainder to the current tip.
831
+ */
832
+ lineages(): Promise<PswapLineageRecord[]>;
833
+ /**
834
+ * Returns the PSWAP lineages created by a specific local account.
835
+ *
836
+ * @param account - Creator account (hex, bech32, `Account`, or `AccountId`).
837
+ */
838
+ lineagesFor(account: AccountRef): Promise<PswapLineageRecord[]>;
839
+ /**
840
+ * Returns the lineage for a single order, or `null` if this client is not
841
+ * tracking it — either because the order was not created by this client, or
842
+ * because tracking did not register when it was created. Registration runs as
843
+ * a transaction observer at create time and does not block the create
844
+ * transaction if it fails.
845
+ *
846
+ * @param orderId - Stable order id (decimal string or bigint). `number` is
847
+ * rejected: a PSWAP order id is `u64`-shaped and routinely exceeds
848
+ * `Number.MAX_SAFE_INTEGER`, which a JS `number` cannot represent without
849
+ * silent precision loss.
850
+ */
851
+ lineage(orderId: string | bigint): Promise<PswapLineageRecord | null>;
852
+ /**
853
+ * Reclaim the unfilled offered asset on the current tip of an active
854
+ * lineage, identified by its stable order id. Builds the cancel transaction,
855
+ * resolves the creator account from the tracked lineage, and submits it
856
+ * through the same prove/submit path as the other transaction helpers.
857
+ * Throws if no lineage is tracked for the order.
858
+ *
859
+ * @param options - Order id and optional transaction options.
860
+ */
861
+ cancelByOrder(
862
+ options: PswapCancelByOrderOptions
863
+ ): Promise<TransactionSubmitResult>;
864
+ }
865
+
813
866
  export interface NotesResource {
814
867
  /**
815
868
  * List received (input) notes, optionally filtered by status or IDs.
@@ -1046,6 +1099,7 @@ export declare class MidenClient {
1046
1099
  readonly settings: SettingsResource;
1047
1100
  readonly compile: CompilerResource;
1048
1101
  readonly keystore: KeystoreResource;
1102
+ readonly pswap: PswapResource;
1049
1103
 
1050
1104
  /** Syncs the client: fetches private notes from the Note Transport Layer, then syncs on-chain state. Fails fast on either. */
1051
1105
  sync(): Promise<SyncSummary>;
@@ -3274,6 +3274,67 @@ export class ProvenTransaction {
3274
3274
  serialize(): Uint8Array;
3275
3275
  }
3276
3276
 
3277
+ /**
3278
+ * Read-only view of one PSWAP order's chain state, exposed to JavaScript.
3279
+ * The mutable fields (remaining amounts, depth, tip, state) advance
3280
+ * round-by-round as fills are discovered during sync.
3281
+ */
3282
+ export class PswapLineageRecord {
3283
+ private constructor();
3284
+ free(): void;
3285
+ [Symbol.dispose](): void;
3286
+ /**
3287
+ * Account that created the order and receives every payback.
3288
+ */
3289
+ creatorAccountId(): AccountId;
3290
+ /**
3291
+ * Depth of the current tip: 0 for the original PSWAP, +1 per fill round.
3292
+ */
3293
+ currentDepth(): number;
3294
+ /**
3295
+ * Note id of the current tip in the chain.
3296
+ */
3297
+ currentTipNoteId(): NoteId;
3298
+ /**
3299
+ * Stable identifier shared by every note in the chain, as a decimal string.
3300
+ */
3301
+ orderId(): string;
3302
+ /**
3303
+ * Offered amount still unfilled on the current tip. The offered faucet is
3304
+ * chain-invariant and recovered from the original PSWAP note when needed.
3305
+ */
3306
+ remainingOffered(): bigint;
3307
+ /**
3308
+ * Requested amount still outstanding on the current tip. The requested
3309
+ * faucet is recovered from the original PSWAP note when needed.
3310
+ */
3311
+ remainingRequested(): bigint;
3312
+ /**
3313
+ * Lifecycle state of the order.
3314
+ */
3315
+ state(): PswapLineageState;
3316
+ }
3317
+
3318
+ /**
3319
+ * Lifecycle state of a PSWAP order.
3320
+ *
3321
+ * Discriminants match the on-disk encoding in the store.
3322
+ */
3323
+ export enum PswapLineageState {
3324
+ /**
3325
+ * Still fillable and reclaimable.
3326
+ */
3327
+ Active = 0,
3328
+ /**
3329
+ * Fully filled. Terminal.
3330
+ */
3331
+ FullyFilled = 1,
3332
+ /**
3333
+ * Reclaimed by the creator. Terminal.
3334
+ */
3335
+ Reclaimed = 2,
3336
+ }
3337
+
3277
3338
  export class PublicKey {
3278
3339
  private constructor();
3279
3340
  free(): void;
@@ -4050,6 +4111,10 @@ export class TransactionRequest {
4050
4111
  private constructor();
4051
4112
  free(): void;
4052
4113
  [Symbol.dispose](): void;
4114
+ /**
4115
+ * Returns a copy of the advice map carried by this request.
4116
+ */
4117
+ adviceMap(): AdviceMap;
4053
4118
  /**
4054
4119
  * Returns the authentication argument if present.
4055
4120
  */
@@ -4066,6 +4131,14 @@ export class TransactionRequest {
4066
4131
  * Returns output notes created by the sender account.
4067
4132
  */
4068
4133
  expectedOutputOwnNotes(): Note[];
4134
+ /**
4135
+ * Returns a copy of this request with `advice_map` merged into its advice map.
4136
+ *
4137
+ * Entries are merged with last-write-wins semantics: a key already present in the request is
4138
+ * overwritten by the value from `advice_map`. Use this to inject advice (e.g. a signature
4139
+ * produced by an external signer) after the request has already been built.
4140
+ */
4141
+ extendAdviceMap(advice_map: AdviceMap): TransactionRequest;
4069
4142
  /**
4070
4143
  * Returns the transaction script argument if present.
4071
4144
  */
@@ -4370,7 +4443,22 @@ export class WebClient {
4370
4443
  accountReader(account_id: AccountId): Promise<AccountReader>;
4371
4444
  addAccountSecretKeyToWebStore(account_id: AccountId, secret_key: AuthSecretKey): Promise<void>;
4372
4445
  addTag(tag: string): Promise<void>;
4446
+ /**
4447
+ * Persists a submitted transaction and returns its pre-apply
4448
+ * [`TransactionStoreUpdate`]. Routes through the high-level
4449
+ * `Client::apply_transaction` so registered observers (e.g. PSWAP
4450
+ * tracking) fire.
4451
+ */
4373
4452
  applyTransaction(transaction_result: TransactionResult, submission_height: number): Promise<TransactionStoreUpdate>;
4453
+ /**
4454
+ * Builds a transaction reclaiming the unfilled offered asset on the current
4455
+ * tip of an Active lineage.
4456
+ *
4457
+ * `order_id` is the order's stable identifier as a decimal string. The
4458
+ * returned request flows into the same submit path as the other PSWAP
4459
+ * cancel transactions.
4460
+ */
4461
+ buildPswapCancelByOrder(order_id: string): Promise<TransactionRequest>;
4374
4462
  static buildSwapTag(note_type: NoteType, offered_asset_faucet_id: AccountId, offered_asset_amount: bigint, requested_asset_faucet_id: AccountId, requested_asset_amount: bigint): NoteTag;
4375
4463
  /**
4376
4464
  * Creates a new `WebClient` instance with the specified configuration.
@@ -4496,6 +4584,20 @@ export class WebClient {
4496
4584
  getInputNotes(filter: NoteFilter): Promise<InputNoteRecord[]>;
4497
4585
  getOutputNote(note_id: string): Promise<OutputNoteRecord>;
4498
4586
  getOutputNotes(filter: NoteFilter): Promise<OutputNoteRecord[]>;
4587
+ /**
4588
+ * Returns the lineage for one order, or `null` if not tracked.
4589
+ *
4590
+ * `order_id` is the order's stable identifier as a decimal string.
4591
+ */
4592
+ getPswapLineage(order_id: string): Promise<PswapLineageRecord | undefined>;
4593
+ /**
4594
+ * Returns every PSWAP lineage tracked by this client.
4595
+ */
4596
+ getPswapLineages(): Promise<PswapLineageRecord[]>;
4597
+ /**
4598
+ * Returns lineages created by a specific local account.
4599
+ */
4600
+ getPswapLineagesFor(creator: AccountId): Promise<PswapLineageRecord[]>;
4499
4601
  /**
4500
4602
  * Returns all public key commitments associated with the given account ID.
4501
4603
  *
@@ -12,6 +12,7 @@ export {
12
12
  AccountHeader,
13
13
  AccountId,
14
14
  AccountStorage,
15
+ AdviceMap,
15
16
  AssetVault,
16
17
  Felt,
17
18
  InputNoteRecord,
@@ -20,6 +21,8 @@ export {
20
21
  NoteFile,
21
22
  NoteId,
22
23
  NoteTag,
24
+ PswapLineageRecord,
25
+ PswapLineageState,
23
26
  RawOutputNote,
24
27
  OutputNoteRecord,
25
28
  SyncSummary,
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, 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, 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-LzqxI7kL.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, sequentialSumBench, setupLogging } from './Cargo-Dlo4tWNG.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, 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, 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-LzqxI7kL.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, sequentialSumBench, setupLogging } from './Cargo-Dlo4tWNG.js';
3
3
 
4
4
  const WorkerAction = Object.freeze({
5
5
  INIT: "init",
@@ -1524,6 +1524,137 @@ class KeystoreResource {
1524
1524
  }
1525
1525
  }
1526
1526
 
1527
+ /**
1528
+ * Coerce an `orderId` (string | bigint) to a decimal string for the WASM
1529
+ * `u64` parse on the other side.
1530
+ *
1531
+ * A PSWAP `orderId` is `u64`-shaped and routinely exceeds
1532
+ * `Number.MAX_SAFE_INTEGER` (`2^53 - 1`). JS `number` cannot represent the
1533
+ * full u64 range without silent precision loss, so it is not accepted — pass
1534
+ * `orderId` as a `bigint` or `string` instead.
1535
+ *
1536
+ * @param {string | bigint} orderId
1537
+ * @returns {string}
1538
+ */
1539
+ function normalizeOrderId(orderId) {
1540
+ if (typeof orderId === "bigint") return orderId.toString();
1541
+ if (typeof orderId === "string") return orderId;
1542
+ throw new TypeError(
1543
+ `PSWAP orderId must be a string or bigint; got ${typeof orderId}`
1544
+ );
1545
+ }
1546
+
1547
+ /**
1548
+ * PswapResource surfaces partial-swap (PSWAP) lineage tracking and creator-side
1549
+ * cancellation keyed by a lineage's stable order id.
1550
+ *
1551
+ * A PSWAP note can be filled by many consumers; each fill advances the lineage
1552
+ * to a new remainder note. The client persists that chain locally as it syncs,
1553
+ * and the reader methods here expose it. {@link PswapResource#cancelByOrder}
1554
+ * reclaims the unfilled offered asset on the current tip of an active lineage,
1555
+ * resolving the creator account from the tracked record so the caller only
1556
+ * needs the order id.
1557
+ */
1558
+ class PswapResource {
1559
+ #inner;
1560
+ #getWasm;
1561
+ #client;
1562
+
1563
+ constructor(inner, getWasm, client) {
1564
+ this.#inner = inner;
1565
+ this.#getWasm = getWasm;
1566
+ this.#client = client;
1567
+ }
1568
+
1569
+ /**
1570
+ * Returns every PSWAP lineage tracked by this client.
1571
+ *
1572
+ * @returns {Promise<PswapLineageRecord[]>} All tracked lineages.
1573
+ */
1574
+ async lineages() {
1575
+ this.#client.assertNotTerminated();
1576
+ return await this.#inner.getPswapLineages();
1577
+ }
1578
+
1579
+ /**
1580
+ * Returns lineages created by a specific local account.
1581
+ *
1582
+ * @param {AccountRef} account - Creator account (hex, bech32, Account, or AccountId).
1583
+ * @returns {Promise<PswapLineageRecord[]>} Lineages created by the account.
1584
+ */
1585
+ async lineagesFor(account) {
1586
+ this.#client.assertNotTerminated();
1587
+ const wasm = await this.#getWasm();
1588
+ const accountId = resolveAccountRef(account, wasm);
1589
+ return await this.#inner.getPswapLineagesFor(accountId);
1590
+ }
1591
+
1592
+ /**
1593
+ * Returns the lineage for one order, or null if not tracked.
1594
+ *
1595
+ * @param {string | bigint} orderId - Stable order id. Pass as a `string` or
1596
+ * `bigint` for the full `u64` range; `number` is rejected because it cannot
1597
+ * represent ids above `Number.MAX_SAFE_INTEGER` without precision loss.
1598
+ * @returns {Promise<PswapLineageRecord | null>} The lineage, or null.
1599
+ */
1600
+ async lineage(orderId) {
1601
+ this.#client.assertNotTerminated();
1602
+ const result = await this.#inner.getPswapLineage(normalizeOrderId(orderId));
1603
+ return result ?? null;
1604
+ }
1605
+
1606
+ /**
1607
+ * Builds and submits a transaction reclaiming the unfilled offered asset on
1608
+ * the current tip of an Active lineage. The creator account is resolved from
1609
+ * the tracked lineage, so only the order id is required. Runs through the
1610
+ * same execute/prove/submit path as the other transaction helpers.
1611
+ *
1612
+ * Throws before submitting any transaction when:
1613
+ * - no lineage is tracked for `orderId`, OR
1614
+ * - the lineage is in a terminal state (`FullyFilled` or `Reclaimed`,
1615
+ * guarded by the `buildPswapCancelByOrder` binding).
1616
+ *
1617
+ * Concurrency: the lineage-read, build, and submit steps below are not
1618
+ * atomic against external fills. If another consumer — or this client's own
1619
+ * in-flight tx — advances the lineage tip between the build and submit, the
1620
+ * cancel will target an already-consumed note and the kernel will reject
1621
+ * it with a "note already nullified" error. Treat that as a signal to
1622
+ * re-read the lineage and retry against the new tip.
1623
+ *
1624
+ * @param {PswapCancelByOrderOptions} opts - Order id and optional tx options.
1625
+ * @returns {Promise<TransactionSubmitResult>} The submitted transaction.
1626
+ */
1627
+ async cancelByOrder(opts) {
1628
+ this.#client.assertNotTerminated();
1629
+ const orderId = normalizeOrderId(opts.orderId);
1630
+
1631
+ // Fetch the lineage for the creator account (the cancel's submitter).
1632
+ // The terminal-state guard is authoritative in the `buildPswapCancelByOrder`
1633
+ // binding below, so it is not repeated here.
1634
+ const lineage = await this.#inner.getPswapLineage(orderId);
1635
+ if (!lineage) {
1636
+ throw new Error(`No PSWAP lineage tracked for order ${orderId}`);
1637
+ }
1638
+ const accountId = lineage.creatorAccountId();
1639
+
1640
+ const request = await this.#inner.buildPswapCancelByOrder(orderId);
1641
+
1642
+ const { txId, result } = await this.#client.transactions.submit(
1643
+ accountId,
1644
+ request,
1645
+ { prover: opts.prover }
1646
+ );
1647
+
1648
+ if (opts.waitForConfirmation) {
1649
+ await this.#client.transactions.waitFor(txId.toHex(), {
1650
+ timeout: opts.timeout,
1651
+ });
1652
+ }
1653
+
1654
+ return { txId, result };
1655
+ }
1656
+ }
1657
+
1527
1658
  /**
1528
1659
  * MidenClient wraps the existing proxy-wrapped WebClient with a resource-based API.
1529
1660
  *
@@ -1554,6 +1685,7 @@ class MidenClient {
1554
1685
  this.settings = new SettingsResource(inner, getWasm, this);
1555
1686
  this.compile = new CompilerResource(inner, getWasm, this);
1556
1687
  this.keystore = new KeystoreResource(inner, this);
1688
+ this.pswap = new PswapResource(inner, getWasm, this);
1557
1689
  }
1558
1690
 
1559
1691
  /**
@@ -2503,6 +2635,7 @@ const Linking = Object.freeze({
2503
2635
  // (e.g. newSwapTransactionRequest, newPswapCreateTransactionRequest) are
2504
2636
  // `async fn` in Rust because they take the client's RNG via an async lock.
2505
2637
  const SYNC_METHODS = new Set([
2638
+ "buildPswapCancelByOrder",
2506
2639
  "buildSwapTag",
2507
2640
  "createCodeBuilder",
2508
2641
  "lastAuthError",