@miden-sdk/react 0.13.0 → 0.13.1

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/dist/index.d.mts CHANGED
@@ -1,6 +1,7 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import * as react from 'react';
2
3
  import { ReactNode } from 'react';
3
- import { Account, AccountHeader, AccountId, TransactionRequest, WebClient, AccountFile, InputNoteRecord, ConsumableNoteRecord, TransactionId, TransactionFilter, TransactionRecord, TransactionProver } from '@miden-sdk/miden-sdk';
4
+ import { AccountStorageMode, Account, AccountHeader, AccountId, TransactionRequest, WebClient, AccountFile, InputNoteRecord, ConsumableNoteRecord, TransactionId, TransactionFilter, TransactionRecord, TransactionProver } from '@miden-sdk/miden-sdk';
4
5
  export { Account, AccountFile, AccountHeader, AccountId, AccountStorageMode, ConsumableNoteRecord, InputNoteRecord, NoteType, TransactionFilter, TransactionId, TransactionRecord, TransactionRequest, WebClient } from '@miden-sdk/miden-sdk';
5
6
 
6
7
  declare module "@miden-sdk/miden-sdk" {
@@ -10,6 +11,79 @@ declare module "@miden-sdk/miden-sdk" {
10
11
  }
11
12
  }
12
13
 
14
+ /**
15
+ * Sign callback for WebClient.createClientWithExternalKeystore.
16
+ * Called when a transaction needs to be signed.
17
+ *
18
+ * @param pubKey - Public key commitment bytes
19
+ * @param signingInputs - Serialized signing inputs
20
+ * @returns Promise resolving to the signature bytes
21
+ */
22
+ type SignCallback = (pubKey: Uint8Array, signingInputs: Uint8Array) => Promise<Uint8Array>;
23
+ /**
24
+ * Account type for signer accounts.
25
+ * Matches the AccountType enum from the SDK.
26
+ */
27
+ type SignerAccountType = "RegularAccountImmutableCode" | "RegularAccountUpdatableCode" | "FungibleFaucet" | "NonFungibleFaucet";
28
+ /**
29
+ * Account configuration provided by the signer.
30
+ * Used to initialize the account in the client store.
31
+ */
32
+ interface SignerAccountConfig {
33
+ /** Public key commitment (for auth component) */
34
+ publicKeyCommitment: Uint8Array;
35
+ /** Account type */
36
+ accountType: SignerAccountType;
37
+ /** Storage mode (public/private/network) */
38
+ storageMode: AccountStorageMode;
39
+ /** Optional seed for deterministic account ID */
40
+ accountSeed?: Uint8Array;
41
+ }
42
+ /**
43
+ * Context value provided by signer providers (Para, Turnkey, MidenFi, etc.).
44
+ * Includes everything needed for MidenProvider to create an external keystore client
45
+ * and for apps to show connect/disconnect UI.
46
+ */
47
+ interface SignerContextValue {
48
+ /** Sign callback for external keystore */
49
+ signCb: SignCallback;
50
+ /** Account config for initialization (only valid when connected) */
51
+ accountConfig: SignerAccountConfig;
52
+ /** Store name suffix for IndexedDB isolation (e.g., "para_walletId") */
53
+ storeName: string;
54
+ /** Display name for UI (e.g., "Para", "Turnkey", "MidenFi") */
55
+ name: string;
56
+ /** Whether the signer is connected and ready */
57
+ isConnected: boolean;
58
+ /** Connect to the signer (triggers auth flow) */
59
+ connect: () => Promise<void>;
60
+ /** Disconnect from the signer */
61
+ disconnect: () => Promise<void>;
62
+ }
63
+ /**
64
+ * React context for signer - null when no signer provider is present.
65
+ * Signer providers (ParaSignerProvider, TurnkeySignerProvider, etc.) populate this context.
66
+ */
67
+ declare const SignerContext: react.Context<SignerContextValue | null>;
68
+ /**
69
+ * Hook for apps and MidenProvider to interact with the current signer.
70
+ * Returns null if no signer provider is present (local keystore mode).
71
+ *
72
+ * @example
73
+ * ```tsx
74
+ * function ConnectButton() {
75
+ * const signer = useSigner();
76
+ * if (!signer) return null; // Local keystore mode
77
+ *
78
+ * const { isConnected, connect, disconnect, name } = signer;
79
+ * return isConnected
80
+ * ? <button onClick={disconnect}>Disconnect {name}</button>
81
+ * : <button onClick={connect}>Connect with {name}</button>;
82
+ * }
83
+ * ```
84
+ */
85
+ declare function useSigner(): SignerContextValue | null;
86
+
13
87
  type RpcUrlConfig = string | "devnet" | "testnet" | "localhost" | "local";
14
88
  type ProverConfig = "local" | "devnet" | "testnet" | string | {
15
89
  url: string;
@@ -307,6 +381,8 @@ interface MidenContextValue {
307
381
  sync: () => Promise<void>;
308
382
  runExclusive: <T>(fn: () => Promise<T>) => Promise<T>;
309
383
  prover: ReturnType<typeof resolveTransactionProver>;
384
+ /** Account ID from signer (only set when using external signer) */
385
+ signerAccountId: string | null;
310
386
  }
311
387
  interface MidenProviderProps {
312
388
  children: ReactNode;
@@ -924,4 +1000,4 @@ declare const parseAssetAmount: (input: string, decimals?: number) => bigint;
924
1000
  declare const getNoteSummary: (note: ConsumableNoteRecord | InputNoteRecord, getAssetMetadata?: (assetId: string) => AssetMetadata | undefined) => NoteSummary | null;
925
1001
  declare const formatNoteSummary: (summary: NoteSummary, formatAsset?: (asset: NoteAsset) => string) => string;
926
1002
 
927
- export { type AccountResult, type AccountsResult, type AssetBalance, type AssetMetadata, type ConsumeOptions, type CreateFaucetOptions, type CreateWalletOptions, DEFAULTS, type ExecuteTransactionOptions, type ImportAccountOptions, type InternalTransferChainOptions, type InternalTransferOptions, type InternalTransferResult, type MidenConfig, MidenProvider, type MidenState, type MintOptions, type MultiSendOptions, type MultiSendRecipient, type MutationResult, type NoteAsset, type NoteSummary, type NotesFilter, type NotesResult, type ProverConfig, type ProverUrls, type QueryResult, type RpcUrlConfig, type SendOptions, type SwapOptions, type SyncState, type TransactionHistoryOptions, type TransactionHistoryResult, type TransactionResult, type TransactionStage, type TransactionStatus, type UseConsumeResult, type UseCreateFaucetResult, type UseCreateWalletResult, type UseImportAccountResult, type UseInternalTransferResult, type UseMintResult, type UseMultiSendResult, type UseSendResult, type UseSwapResult, type UseSyncStateResult, type UseTransactionHistoryResult, type UseTransactionResult, type UseWaitForCommitResult, type UseWaitForNotesResult, type WaitForCommitOptions, type WaitForNotesOptions, formatAssetAmount, formatNoteSummary, getNoteSummary, parseAssetAmount, toBech32AccountId, useAccount, useAccounts, useAssetMetadata, useConsume, useCreateFaucet, useCreateWallet, useImportAccount, useInternalTransfer, useMiden, useMidenClient, useMint, useMultiSend, useNotes, useSend, useSwap, useSyncState, useTransaction, useTransactionHistory, useWaitForCommit, useWaitForNotes };
1003
+ export { type AccountResult, type AccountsResult, type AssetBalance, type AssetMetadata, type ConsumeOptions, type CreateFaucetOptions, type CreateWalletOptions, DEFAULTS, type ExecuteTransactionOptions, type ImportAccountOptions, type InternalTransferChainOptions, type InternalTransferOptions, type InternalTransferResult, type MidenConfig, MidenProvider, type MidenState, type MintOptions, type MultiSendOptions, type MultiSendRecipient, type MutationResult, type NoteAsset, type NoteSummary, type NotesFilter, type NotesResult, type ProverConfig, type ProverUrls, type QueryResult, type RpcUrlConfig, type SendOptions, type SignCallback, type SignerAccountConfig, type SignerAccountType, SignerContext, type SignerContextValue, type SwapOptions, type SyncState, type TransactionHistoryOptions, type TransactionHistoryResult, type TransactionResult, type TransactionStage, type TransactionStatus, type UseConsumeResult, type UseCreateFaucetResult, type UseCreateWalletResult, type UseImportAccountResult, type UseInternalTransferResult, type UseMintResult, type UseMultiSendResult, type UseSendResult, type UseSwapResult, type UseSyncStateResult, type UseTransactionHistoryResult, type UseTransactionResult, type UseWaitForCommitResult, type UseWaitForNotesResult, type WaitForCommitOptions, type WaitForNotesOptions, formatAssetAmount, formatNoteSummary, getNoteSummary, parseAssetAmount, toBech32AccountId, useAccount, useAccounts, useAssetMetadata, useConsume, useCreateFaucet, useCreateWallet, useImportAccount, useInternalTransfer, useMiden, useMidenClient, useMint, useMultiSend, useNotes, useSend, useSigner, useSwap, useSyncState, useTransaction, useTransactionHistory, useWaitForCommit, useWaitForNotes };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import * as react from 'react';
2
3
  import { ReactNode } from 'react';
3
- import { Account, AccountHeader, AccountId, TransactionRequest, WebClient, AccountFile, InputNoteRecord, ConsumableNoteRecord, TransactionId, TransactionFilter, TransactionRecord, TransactionProver } from '@miden-sdk/miden-sdk';
4
+ import { AccountStorageMode, Account, AccountHeader, AccountId, TransactionRequest, WebClient, AccountFile, InputNoteRecord, ConsumableNoteRecord, TransactionId, TransactionFilter, TransactionRecord, TransactionProver } from '@miden-sdk/miden-sdk';
4
5
  export { Account, AccountFile, AccountHeader, AccountId, AccountStorageMode, ConsumableNoteRecord, InputNoteRecord, NoteType, TransactionFilter, TransactionId, TransactionRecord, TransactionRequest, WebClient } from '@miden-sdk/miden-sdk';
5
6
 
6
7
  declare module "@miden-sdk/miden-sdk" {
@@ -10,6 +11,79 @@ declare module "@miden-sdk/miden-sdk" {
10
11
  }
11
12
  }
12
13
 
14
+ /**
15
+ * Sign callback for WebClient.createClientWithExternalKeystore.
16
+ * Called when a transaction needs to be signed.
17
+ *
18
+ * @param pubKey - Public key commitment bytes
19
+ * @param signingInputs - Serialized signing inputs
20
+ * @returns Promise resolving to the signature bytes
21
+ */
22
+ type SignCallback = (pubKey: Uint8Array, signingInputs: Uint8Array) => Promise<Uint8Array>;
23
+ /**
24
+ * Account type for signer accounts.
25
+ * Matches the AccountType enum from the SDK.
26
+ */
27
+ type SignerAccountType = "RegularAccountImmutableCode" | "RegularAccountUpdatableCode" | "FungibleFaucet" | "NonFungibleFaucet";
28
+ /**
29
+ * Account configuration provided by the signer.
30
+ * Used to initialize the account in the client store.
31
+ */
32
+ interface SignerAccountConfig {
33
+ /** Public key commitment (for auth component) */
34
+ publicKeyCommitment: Uint8Array;
35
+ /** Account type */
36
+ accountType: SignerAccountType;
37
+ /** Storage mode (public/private/network) */
38
+ storageMode: AccountStorageMode;
39
+ /** Optional seed for deterministic account ID */
40
+ accountSeed?: Uint8Array;
41
+ }
42
+ /**
43
+ * Context value provided by signer providers (Para, Turnkey, MidenFi, etc.).
44
+ * Includes everything needed for MidenProvider to create an external keystore client
45
+ * and for apps to show connect/disconnect UI.
46
+ */
47
+ interface SignerContextValue {
48
+ /** Sign callback for external keystore */
49
+ signCb: SignCallback;
50
+ /** Account config for initialization (only valid when connected) */
51
+ accountConfig: SignerAccountConfig;
52
+ /** Store name suffix for IndexedDB isolation (e.g., "para_walletId") */
53
+ storeName: string;
54
+ /** Display name for UI (e.g., "Para", "Turnkey", "MidenFi") */
55
+ name: string;
56
+ /** Whether the signer is connected and ready */
57
+ isConnected: boolean;
58
+ /** Connect to the signer (triggers auth flow) */
59
+ connect: () => Promise<void>;
60
+ /** Disconnect from the signer */
61
+ disconnect: () => Promise<void>;
62
+ }
63
+ /**
64
+ * React context for signer - null when no signer provider is present.
65
+ * Signer providers (ParaSignerProvider, TurnkeySignerProvider, etc.) populate this context.
66
+ */
67
+ declare const SignerContext: react.Context<SignerContextValue | null>;
68
+ /**
69
+ * Hook for apps and MidenProvider to interact with the current signer.
70
+ * Returns null if no signer provider is present (local keystore mode).
71
+ *
72
+ * @example
73
+ * ```tsx
74
+ * function ConnectButton() {
75
+ * const signer = useSigner();
76
+ * if (!signer) return null; // Local keystore mode
77
+ *
78
+ * const { isConnected, connect, disconnect, name } = signer;
79
+ * return isConnected
80
+ * ? <button onClick={disconnect}>Disconnect {name}</button>
81
+ * : <button onClick={connect}>Connect with {name}</button>;
82
+ * }
83
+ * ```
84
+ */
85
+ declare function useSigner(): SignerContextValue | null;
86
+
13
87
  type RpcUrlConfig = string | "devnet" | "testnet" | "localhost" | "local";
14
88
  type ProverConfig = "local" | "devnet" | "testnet" | string | {
15
89
  url: string;
@@ -307,6 +381,8 @@ interface MidenContextValue {
307
381
  sync: () => Promise<void>;
308
382
  runExclusive: <T>(fn: () => Promise<T>) => Promise<T>;
309
383
  prover: ReturnType<typeof resolveTransactionProver>;
384
+ /** Account ID from signer (only set when using external signer) */
385
+ signerAccountId: string | null;
310
386
  }
311
387
  interface MidenProviderProps {
312
388
  children: ReactNode;
@@ -924,4 +1000,4 @@ declare const parseAssetAmount: (input: string, decimals?: number) => bigint;
924
1000
  declare const getNoteSummary: (note: ConsumableNoteRecord | InputNoteRecord, getAssetMetadata?: (assetId: string) => AssetMetadata | undefined) => NoteSummary | null;
925
1001
  declare const formatNoteSummary: (summary: NoteSummary, formatAsset?: (asset: NoteAsset) => string) => string;
926
1002
 
927
- export { type AccountResult, type AccountsResult, type AssetBalance, type AssetMetadata, type ConsumeOptions, type CreateFaucetOptions, type CreateWalletOptions, DEFAULTS, type ExecuteTransactionOptions, type ImportAccountOptions, type InternalTransferChainOptions, type InternalTransferOptions, type InternalTransferResult, type MidenConfig, MidenProvider, type MidenState, type MintOptions, type MultiSendOptions, type MultiSendRecipient, type MutationResult, type NoteAsset, type NoteSummary, type NotesFilter, type NotesResult, type ProverConfig, type ProverUrls, type QueryResult, type RpcUrlConfig, type SendOptions, type SwapOptions, type SyncState, type TransactionHistoryOptions, type TransactionHistoryResult, type TransactionResult, type TransactionStage, type TransactionStatus, type UseConsumeResult, type UseCreateFaucetResult, type UseCreateWalletResult, type UseImportAccountResult, type UseInternalTransferResult, type UseMintResult, type UseMultiSendResult, type UseSendResult, type UseSwapResult, type UseSyncStateResult, type UseTransactionHistoryResult, type UseTransactionResult, type UseWaitForCommitResult, type UseWaitForNotesResult, type WaitForCommitOptions, type WaitForNotesOptions, formatAssetAmount, formatNoteSummary, getNoteSummary, parseAssetAmount, toBech32AccountId, useAccount, useAccounts, useAssetMetadata, useConsume, useCreateFaucet, useCreateWallet, useImportAccount, useInternalTransfer, useMiden, useMidenClient, useMint, useMultiSend, useNotes, useSend, useSwap, useSyncState, useTransaction, useTransactionHistory, useWaitForCommit, useWaitForNotes };
1003
+ export { type AccountResult, type AccountsResult, type AssetBalance, type AssetMetadata, type ConsumeOptions, type CreateFaucetOptions, type CreateWalletOptions, DEFAULTS, type ExecuteTransactionOptions, type ImportAccountOptions, type InternalTransferChainOptions, type InternalTransferOptions, type InternalTransferResult, type MidenConfig, MidenProvider, type MidenState, type MintOptions, type MultiSendOptions, type MultiSendRecipient, type MutationResult, type NoteAsset, type NoteSummary, type NotesFilter, type NotesResult, type ProverConfig, type ProverUrls, type QueryResult, type RpcUrlConfig, type SendOptions, type SignCallback, type SignerAccountConfig, type SignerAccountType, SignerContext, type SignerContextValue, type SwapOptions, type SyncState, type TransactionHistoryOptions, type TransactionHistoryResult, type TransactionResult, type TransactionStage, type TransactionStatus, type UseConsumeResult, type UseCreateFaucetResult, type UseCreateWalletResult, type UseImportAccountResult, type UseInternalTransferResult, type UseMintResult, type UseMultiSendResult, type UseSendResult, type UseSwapResult, type UseSyncStateResult, type UseTransactionHistoryResult, type UseTransactionResult, type UseWaitForCommitResult, type UseWaitForNotesResult, type WaitForCommitOptions, type WaitForNotesOptions, formatAssetAmount, formatNoteSummary, getNoteSummary, parseAssetAmount, toBech32AccountId, useAccount, useAccounts, useAssetMetadata, useConsume, useCreateFaucet, useCreateWallet, useImportAccount, useInternalTransfer, useMiden, useMidenClient, useMint, useMultiSend, useNotes, useSend, useSigner, useSwap, useSyncState, useTransaction, useTransactionHistory, useWaitForCommit, useWaitForNotes };