@miden-sdk/react 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.
- package/CLAUDE.md +4 -0
- package/README.md +58 -0
- package/dist/index.d.ts +128 -3
- package/dist/index.mjs +337 -134
- package/dist/lazy.d.ts +128 -3
- package/dist/lazy.mjs +337 -134
- package/dist/mt/lazy.d.ts +128 -3
- package/dist/mt/lazy.mjs +337 -134
- package/dist/mt.d.ts +128 -3
- package/dist/mt.mjs +337 -134
- package/package.json +3 -3
package/dist/mt/lazy.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import * as react from 'react';
|
|
3
3
|
import { ReactNode } from 'react';
|
|
4
|
-
import { AccountId, Account, AccountHeader, AccountStorageMode, AccountComponent, NoteId, InputNoteRecord, Note, StorageMode, AuthScheme, TransactionScript, AdviceInputs, AccountStorageRequirements, TransactionRequest, WasmWebClient, AccountFile, NoteVisibility, ConsumableNoteRecord, NoteInput, TransactionId, TransactionFilter, TransactionRecord, TransactionProver, CompileComponentOptions, CompileTxScriptOptions, CompileNoteScriptOptions, NoteScript, NoteAttachment } from '@miden-sdk/miden-sdk';
|
|
5
|
-
export { Account, AccountFile, AccountHeader, AccountId, AccountStorageMode, AuthScheme, ConsumableNoteRecord, InputNoteRecord, Note, NoteType, TransactionFilter, TransactionId, TransactionRecord, TransactionRequest, WasmWebClient as WebClient } from '@miden-sdk/miden-sdk';
|
|
4
|
+
import { AccountId, Account, AccountHeader, AccountStorageMode, AccountComponent, NoteId, InputNoteRecord, Note, StorageMode, AuthScheme, TransactionScript, AdviceInputs, AccountStorageRequirements, TransactionRequest, WasmWebClient, AccountFile, NoteVisibility, ConsumableNoteRecord, NoteInput, PswapLineageRecord, TransactionId, TransactionFilter, TransactionRecord, TransactionProver, CompileComponentOptions, CompileTxScriptOptions, CompileNoteScriptOptions, NoteScript, NoteAttachment } from '@miden-sdk/miden-sdk';
|
|
5
|
+
export { Account, AccountFile, AccountHeader, AccountId, AccountStorageMode, AuthScheme, ConsumableNoteRecord, InputNoteRecord, Note, NoteType, PswapLineageRecord, TransactionFilter, TransactionId, TransactionRecord, TransactionRequest, WasmWebClient as WebClient } from '@miden-sdk/miden-sdk';
|
|
6
6
|
|
|
7
7
|
declare module "@miden-sdk/miden-sdk" {
|
|
8
8
|
interface Account {
|
|
@@ -462,6 +462,29 @@ interface PswapCancelOptions {
|
|
|
462
462
|
*/
|
|
463
463
|
note: NoteInput;
|
|
464
464
|
}
|
|
465
|
+
interface PswapCancelByOrderOptions {
|
|
466
|
+
/**
|
|
467
|
+
* Stable order id of the lineage to cancel (decimal string or bigint).
|
|
468
|
+
* `number` is not accepted: a PSWAP order id is `u64`-shaped and routinely
|
|
469
|
+
* exceeds `Number.MAX_SAFE_INTEGER`, which a JS `number` cannot represent
|
|
470
|
+
* without silent precision loss.
|
|
471
|
+
*/
|
|
472
|
+
orderId: string | bigint;
|
|
473
|
+
}
|
|
474
|
+
interface PswapLineagesResult {
|
|
475
|
+
/** Tracked PSWAP lineages. */
|
|
476
|
+
lineages: PswapLineageRecord[];
|
|
477
|
+
isLoading: boolean;
|
|
478
|
+
error: Error | null;
|
|
479
|
+
refetch: () => Promise<void>;
|
|
480
|
+
}
|
|
481
|
+
interface PswapLineageResult {
|
|
482
|
+
/** The tracked lineage, or `null` if not tracked. */
|
|
483
|
+
lineage: PswapLineageRecord | null;
|
|
484
|
+
isLoading: boolean;
|
|
485
|
+
error: Error | null;
|
|
486
|
+
refetch: () => Promise<void>;
|
|
487
|
+
}
|
|
465
488
|
interface ExecuteTransactionOptions {
|
|
466
489
|
/** Account ID the transaction applies to */
|
|
467
490
|
accountId: AccountRef;
|
|
@@ -814,6 +837,74 @@ declare function useAssetMetadata(assetIds?: string[]): {
|
|
|
814
837
|
assetMetadata: Map<string, AssetMetadata>;
|
|
815
838
|
};
|
|
816
839
|
|
|
840
|
+
/**
|
|
841
|
+
* Hook to list every partial-swap (PSWAP) lineage tracked by this client.
|
|
842
|
+
*
|
|
843
|
+
* A lineage records how a PSWAP note has been filled round by round, from the
|
|
844
|
+
* original note through each remainder to the current tip. The list refreshes
|
|
845
|
+
* after each successful sync.
|
|
846
|
+
*
|
|
847
|
+
* @example
|
|
848
|
+
* ```tsx
|
|
849
|
+
* function LineageList() {
|
|
850
|
+
* const { lineages, isLoading } = usePswapLineages();
|
|
851
|
+
* if (isLoading) return <div>Loading...</div>;
|
|
852
|
+
* return (
|
|
853
|
+
* <ul>
|
|
854
|
+
* {lineages.map((l) => (
|
|
855
|
+
* <li key={l.orderId()}>
|
|
856
|
+
* {l.orderId()} — {l.remainingOffered().toString()} remaining
|
|
857
|
+
* </li>
|
|
858
|
+
* ))}
|
|
859
|
+
* </ul>
|
|
860
|
+
* );
|
|
861
|
+
* }
|
|
862
|
+
* ```
|
|
863
|
+
*/
|
|
864
|
+
declare function usePswapLineages(): PswapLineagesResult;
|
|
865
|
+
type UsePswapLineagesResult = PswapLineagesResult;
|
|
866
|
+
|
|
867
|
+
/**
|
|
868
|
+
* Hook to list the partial-swap (PSWAP) lineages created by a specific local
|
|
869
|
+
* account. Refreshes after each successful sync.
|
|
870
|
+
*
|
|
871
|
+
* @param account - Creator account (hex, bech32, `Account`, or `AccountId`).
|
|
872
|
+
*
|
|
873
|
+
* @example
|
|
874
|
+
* ```tsx
|
|
875
|
+
* function MyLineages({ accountId }: { accountId: string }) {
|
|
876
|
+
* const { lineages, isLoading } = usePswapLineagesFor(accountId);
|
|
877
|
+
* if (isLoading) return <div>Loading...</div>;
|
|
878
|
+
* return <div>{lineages.length} open orders</div>;
|
|
879
|
+
* }
|
|
880
|
+
* ```
|
|
881
|
+
*/
|
|
882
|
+
declare function usePswapLineagesFor(account: AccountRef | null | undefined): PswapLineagesResult;
|
|
883
|
+
type UsePswapLineagesForResult = PswapLineagesResult;
|
|
884
|
+
|
|
885
|
+
/**
|
|
886
|
+
* Hook to fetch a single partial-swap (PSWAP) lineage by its stable order id.
|
|
887
|
+
* Returns `null` if this client is not tracking the order. Refreshes after each
|
|
888
|
+
* successful sync.
|
|
889
|
+
*
|
|
890
|
+
* @param orderId - Stable order id (decimal string or bigint). `number` is
|
|
891
|
+
* not accepted: a PSWAP order id is `u64`-shaped and routinely exceeds
|
|
892
|
+
* `Number.MAX_SAFE_INTEGER`, which a JS `number` cannot represent without
|
|
893
|
+
* silent precision loss.
|
|
894
|
+
*
|
|
895
|
+
* @example
|
|
896
|
+
* ```tsx
|
|
897
|
+
* function OrderStatus({ orderId }: { orderId: string }) {
|
|
898
|
+
* const { lineage, isLoading } = usePswapLineage(orderId);
|
|
899
|
+
* if (isLoading) return <div>Loading...</div>;
|
|
900
|
+
* if (!lineage) return <div>Not tracked</div>;
|
|
901
|
+
* return <div>State: {lineage.state()}</div>;
|
|
902
|
+
* }
|
|
903
|
+
* ```
|
|
904
|
+
*/
|
|
905
|
+
declare function usePswapLineage(orderId: string | bigint | null | undefined): PswapLineageResult;
|
|
906
|
+
type UsePswapLineageResult = PswapLineageResult;
|
|
907
|
+
|
|
817
908
|
interface UseCreateWalletResult {
|
|
818
909
|
/** Create a new wallet with optional configuration */
|
|
819
910
|
createWallet: (options?: CreateWalletOptions) => Promise<Account>;
|
|
@@ -1296,6 +1387,40 @@ interface UsePswapCancelResult {
|
|
|
1296
1387
|
*/
|
|
1297
1388
|
declare function usePswapCancel(): UsePswapCancelResult;
|
|
1298
1389
|
|
|
1390
|
+
interface UsePswapCancelByOrderResult {
|
|
1391
|
+
/** Cancel a PSWAP lineage by its stable order id, reclaiming the unfilled offered asset. */
|
|
1392
|
+
pswapCancelByOrder: (options: PswapCancelByOrderOptions) => Promise<TransactionResult>;
|
|
1393
|
+
/** The transaction result */
|
|
1394
|
+
result: TransactionResult | null;
|
|
1395
|
+
/** Whether the transaction is in progress */
|
|
1396
|
+
isLoading: boolean;
|
|
1397
|
+
/** Current stage of the transaction */
|
|
1398
|
+
stage: TransactionStage;
|
|
1399
|
+
/** Error if transaction failed */
|
|
1400
|
+
error: Error | null;
|
|
1401
|
+
/** Reset the hook state */
|
|
1402
|
+
reset: () => void;
|
|
1403
|
+
}
|
|
1404
|
+
/**
|
|
1405
|
+
* Hook to cancel a PSWAP lineage by its stable order id and reclaim the
|
|
1406
|
+
* unfilled offered asset on the lineage's current tip. Unlike
|
|
1407
|
+
* {@link usePswapCancel}, the creator account and tip note are resolved from
|
|
1408
|
+
* the locally tracked lineage, so only the order id is required.
|
|
1409
|
+
*
|
|
1410
|
+
* @example
|
|
1411
|
+
* ```tsx
|
|
1412
|
+
* function CancelOrderButton({ orderId }: { orderId: string }) {
|
|
1413
|
+
* const { pswapCancelByOrder, isLoading, stage } = usePswapCancelByOrder();
|
|
1414
|
+
* return (
|
|
1415
|
+
* <button onClick={() => pswapCancelByOrder({ orderId })} disabled={isLoading}>
|
|
1416
|
+
* {isLoading ? stage : "Cancel order"}
|
|
1417
|
+
* </button>
|
|
1418
|
+
* );
|
|
1419
|
+
* }
|
|
1420
|
+
* ```
|
|
1421
|
+
*/
|
|
1422
|
+
declare function usePswapCancelByOrder(): UsePswapCancelByOrderResult;
|
|
1423
|
+
|
|
1299
1424
|
interface UseTransactionResult {
|
|
1300
1425
|
/** Execute a transaction request end-to-end */
|
|
1301
1426
|
execute: (options: ExecuteTransactionOptions) => Promise<TransactionResult>;
|
|
@@ -1715,4 +1840,4 @@ declare function createMidenStorage(prefix: string): {
|
|
|
1715
1840
|
clear(): void;
|
|
1716
1841
|
};
|
|
1717
1842
|
|
|
1718
|
-
export { type AccountRef, type AccountResult, type AccountsResult, type AssetBalance, type AssetMetadata, type ConsumeOptions, type CreateFaucetOptions, type CreateWalletOptions, DEFAULTS, type ExecuteProgramOptions, type ExecuteProgramResult, type ExecuteTransactionOptions, type ImportAccountOptions, type ImportStoreOptions, type MidenConfig, MidenError, type MidenErrorCode, MidenProvider, type MidenState, type MigrateStorageOptions, type MintOptions, type MultiSendOptions, type MultiSendRecipient, type MultiSignerContextValue, MultiSignerProvider, type MutationResult, type NoteAsset, type NoteAttachmentData, type NoteSummary, type NotesFilter, type NotesResult, type ProverConfig, type ProverTarget, type ProverUrls, type PswapCancelOptions, type PswapConsumeOptions, type PswapCreateOptions, type QueryResult, type RpcUrlConfig, type SendOptions, type SendResult, type SessionAccountStep, type SignCallback, type SignerAccountConfig, type SignerAccountType, SignerContext, type SignerContextValue, SignerSlot, type StreamedNote, type SwapOptions, type SyncState, type TransactionHistoryOptions, type TransactionHistoryResult, type TransactionResult, type TransactionStage, type TransactionStatus, type UseCompileResult, type UseConsumeResult, type UseCreateFaucetResult, type UseCreateWalletResult, type UseExecuteProgramResult, type UseExportNoteResult, type UseExportStoreResult, type UseImportAccountResult, type UseImportNoteResult, type UseImportStoreResult, type UseMintResult, type UseMultiSendResult, type UseNoteStreamOptions, type UseNoteStreamReturn, type UsePswapCancelResult, type UsePswapConsumeResult, type UsePswapCreateResult, type UseSendResult, type UseSessionAccountOptions, type UseSessionAccountReturn, type UseSwapResult, type UseSyncControlResult, type UseSyncStateResult, type UseTransactionHistoryResult, type UseTransactionResult, type UseWaitForCommitResult, type UseWaitForNotesResult, type WaitForCommitOptions, type WaitForNotesOptions, type WalletAdapterLike, accountIdsEqual, bigIntToBytes, bytesToBigInt, clearMidenStorage, concatBytes, createMidenStorage, createNoteAttachment, ensureAccountBech32, formatAssetAmount, formatNoteSummary, getNoteSummary, installAccountBech32, migrateStorage, normalizeAccountId, parseAssetAmount, readNoteAttachment, toBech32AccountId, useAccount, useAccounts, useAssetMetadata, useCompile, useConsume, useCreateFaucet, useCreateWallet, useExecuteProgram, useExportNote, useExportStore, useImportAccount, useImportNote, useImportStore, useMiden, useMidenClient, useMint, useMultiSend, useMultiSigner, useNoteStream, useNotes, usePswapCancel, usePswapConsume, usePswapCreate, useSend, useSessionAccount, useSigner, useSwap, useSyncControl, useSyncState, useTransaction, useTransactionHistory, useWaitForCommit, useWaitForNotes, waitForWalletDetection, wrapWasmError };
|
|
1843
|
+
export { type AccountRef, type AccountResult, type AccountsResult, type AssetBalance, type AssetMetadata, type ConsumeOptions, type CreateFaucetOptions, type CreateWalletOptions, DEFAULTS, type ExecuteProgramOptions, type ExecuteProgramResult, type ExecuteTransactionOptions, type ImportAccountOptions, type ImportStoreOptions, type MidenConfig, MidenError, type MidenErrorCode, MidenProvider, type MidenState, type MigrateStorageOptions, type MintOptions, type MultiSendOptions, type MultiSendRecipient, type MultiSignerContextValue, MultiSignerProvider, type MutationResult, type NoteAsset, type NoteAttachmentData, type NoteSummary, type NotesFilter, type NotesResult, type ProverConfig, type ProverTarget, type ProverUrls, type PswapCancelByOrderOptions, type PswapCancelOptions, type PswapConsumeOptions, type PswapCreateOptions, type PswapLineageResult, type PswapLineagesResult, type QueryResult, type RpcUrlConfig, type SendOptions, type SendResult, type SessionAccountStep, type SignCallback, type SignerAccountConfig, type SignerAccountType, SignerContext, type SignerContextValue, SignerSlot, type StreamedNote, type SwapOptions, type SyncState, type TransactionHistoryOptions, type TransactionHistoryResult, type TransactionResult, type TransactionStage, type TransactionStatus, type UseCompileResult, type UseConsumeResult, type UseCreateFaucetResult, type UseCreateWalletResult, type UseExecuteProgramResult, type UseExportNoteResult, type UseExportStoreResult, type UseImportAccountResult, type UseImportNoteResult, type UseImportStoreResult, type UseMintResult, type UseMultiSendResult, type UseNoteStreamOptions, type UseNoteStreamReturn, type UsePswapCancelByOrderResult, type UsePswapCancelResult, type UsePswapConsumeResult, type UsePswapCreateResult, type UsePswapLineageResult, type UsePswapLineagesForResult, type UsePswapLineagesResult, type UseSendResult, type UseSessionAccountOptions, type UseSessionAccountReturn, type UseSwapResult, type UseSyncControlResult, type UseSyncStateResult, type UseTransactionHistoryResult, type UseTransactionResult, type UseWaitForCommitResult, type UseWaitForNotesResult, type WaitForCommitOptions, type WaitForNotesOptions, type WalletAdapterLike, accountIdsEqual, bigIntToBytes, bytesToBigInt, clearMidenStorage, concatBytes, createMidenStorage, createNoteAttachment, ensureAccountBech32, formatAssetAmount, formatNoteSummary, getNoteSummary, installAccountBech32, migrateStorage, normalizeAccountId, parseAssetAmount, readNoteAttachment, toBech32AccountId, useAccount, useAccounts, useAssetMetadata, useCompile, useConsume, useCreateFaucet, useCreateWallet, useExecuteProgram, useExportNote, useExportStore, useImportAccount, useImportNote, useImportStore, useMiden, useMidenClient, useMint, useMultiSend, useMultiSigner, useNoteStream, useNotes, usePswapCancel, usePswapCancelByOrder, usePswapConsume, usePswapCreate, usePswapLineage, usePswapLineages, usePswapLineagesFor, useSend, useSessionAccount, useSigner, useSwap, useSyncControl, useSyncState, useTransaction, useTransactionHistory, useWaitForCommit, useWaitForNotes, waitForWalletDetection, wrapWasmError };
|