@miden-sdk/react 0.14.1 → 0.14.3
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 +1 -0
- package/README.md +45 -0
- package/dist/index.d.mts +29 -2
- package/dist/index.d.ts +29 -2
- package/dist/index.js +76 -44
- package/dist/index.mjs +49 -18
- package/package.json +2 -2
package/CLAUDE.md
CHANGED
|
@@ -393,6 +393,7 @@ account.bech32id(); // "miden1qy35..."
|
|
|
393
393
|
| `useConsume()` | `TransactionResult` | Claim notes |
|
|
394
394
|
| `useSwap()` | `TransactionResult` | Atomic swap |
|
|
395
395
|
| `useTransaction()` | `TransactionResult` | Custom transaction |
|
|
396
|
+
| `useCompile()` | `{ component, txScript, noteScript }` | Compile MASM into `AccountComponent` / `TransactionScript` / `NoteScript` |
|
|
396
397
|
|
|
397
398
|
## Type Imports
|
|
398
399
|
|
package/README.md
CHANGED
|
@@ -952,6 +952,51 @@ function CustomTransactionButton({ accountId }: { accountId: string }) {
|
|
|
952
952
|
}
|
|
953
953
|
```
|
|
954
954
|
|
|
955
|
+
#### `useCompile()`
|
|
956
|
+
|
|
957
|
+
Compile MASM source into an `AccountComponent`, `TransactionScript`, or
|
|
958
|
+
`NoteScript`. Mirrors `MidenClient.compile` from `@miden-sdk/miden-sdk`, so the
|
|
959
|
+
shape is identical whether you're in a React app or calling the SDK directly.
|
|
960
|
+
|
|
961
|
+
Returns three async methods, one per output type:
|
|
962
|
+
|
|
963
|
+
| Method | Input | Output |
|
|
964
|
+
|---|---|---|
|
|
965
|
+
| `component(options)` | `{ code, slots?, supportAllTypes? }` | `AccountComponent` |
|
|
966
|
+
| `txScript(options)` | `{ code, libraries? }` | `TransactionScript` |
|
|
967
|
+
| `noteScript(options)` | `{ code, libraries? }` | `NoteScript` |
|
|
968
|
+
|
|
969
|
+
Each `libraries` entry takes `{ namespace, code, linking? }`. `linking` accepts
|
|
970
|
+
the `Linking` enum (`Linking.Dynamic`, `Linking.Static`) or the raw strings
|
|
971
|
+
`"dynamic"` / `"static"`. Dynamic is the default and matches the FPI pattern
|
|
972
|
+
used in the tutorials.
|
|
973
|
+
|
|
974
|
+
```tsx
|
|
975
|
+
import { useCompile } from '@miden-sdk/react';
|
|
976
|
+
import { Linking } from '@miden-sdk/miden-sdk';
|
|
977
|
+
|
|
978
|
+
function ScriptBuilder({ libSource, noteSource }: { libSource: string; noteSource: string }) {
|
|
979
|
+
const { noteScript, isReady } = useCompile();
|
|
980
|
+
|
|
981
|
+
const handleBuild = async () => {
|
|
982
|
+
const script = await noteScript({
|
|
983
|
+
code: noteSource,
|
|
984
|
+
libraries: [
|
|
985
|
+
{ namespace: 'my_lib::module', code: libSource, linking: Linking.Dynamic },
|
|
986
|
+
],
|
|
987
|
+
});
|
|
988
|
+
// pass `script` to useTransaction, useExecuteProgram, or your own flow
|
|
989
|
+
};
|
|
990
|
+
|
|
991
|
+
return <button onClick={handleBuild} disabled={!isReady}>Compile</button>;
|
|
992
|
+
}
|
|
993
|
+
```
|
|
994
|
+
|
|
995
|
+
Compile is local and synchronous in practice — the hook doesn't expose
|
|
996
|
+
`isLoading` / `stage` / `error` state. Errors from the underlying compiler
|
|
997
|
+
(bad MASM, unresolved imports) throw from the returned promise; handle them
|
|
998
|
+
with regular `try`/`catch`.
|
|
999
|
+
|
|
955
1000
|
#### `useExecuteProgram()`
|
|
956
1001
|
|
|
957
1002
|
Execute a program (view call) against an account and read the resulting stack
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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, TransactionId, TransactionFilter, TransactionRecord, TransactionProver, NoteAttachment } 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, TransactionId, TransactionFilter, TransactionRecord, TransactionProver, CompileComponentOptions, CompileTxScriptOptions, CompileNoteScriptOptions, NoteScript, NoteAttachment } from '@miden-sdk/miden-sdk';
|
|
5
5
|
export { Account, AccountFile, AccountHeader, AccountId, AccountStorageMode, AuthScheme, ConsumableNoteRecord, InputNoteRecord, Note, NoteType, TransactionFilter, TransactionId, TransactionRecord, TransactionRequest, WasmWebClient as WebClient } from '@miden-sdk/miden-sdk';
|
|
6
6
|
|
|
7
7
|
declare module "@miden-sdk/miden-sdk" {
|
|
@@ -1168,6 +1168,33 @@ interface UseExecuteProgramResult {
|
|
|
1168
1168
|
}
|
|
1169
1169
|
declare function useExecuteProgram(): UseExecuteProgramResult;
|
|
1170
1170
|
|
|
1171
|
+
interface UseCompileResult {
|
|
1172
|
+
/** Compile MASM source into an AccountComponent. */
|
|
1173
|
+
component: (options: CompileComponentOptions) => Promise<AccountComponent>;
|
|
1174
|
+
/** Compile MASM source into a TransactionScript. */
|
|
1175
|
+
txScript: (options: CompileTxScriptOptions) => Promise<TransactionScript>;
|
|
1176
|
+
/** Compile MASM source into a NoteScript. */
|
|
1177
|
+
noteScript: (options: CompileNoteScriptOptions) => Promise<NoteScript>;
|
|
1178
|
+
/** Whether the underlying client is ready to compile. */
|
|
1179
|
+
isReady: boolean;
|
|
1180
|
+
}
|
|
1181
|
+
/**
|
|
1182
|
+
* Hook for compiling MASM source into `AccountComponent`, `TransactionScript`,
|
|
1183
|
+
* or `NoteScript`. Wraps `CompilerResource` from `@miden-sdk/miden-sdk` so the
|
|
1184
|
+
* shape is identical to `MidenClient.compile`.
|
|
1185
|
+
*
|
|
1186
|
+
* @example
|
|
1187
|
+
* ```tsx
|
|
1188
|
+
* const { noteScript, isReady } = useCompile();
|
|
1189
|
+
*
|
|
1190
|
+
* const script = await noteScript({
|
|
1191
|
+
* code: noteSource,
|
|
1192
|
+
* libraries: [{ namespace: "my_lib", code: libSource, linking: Linking.Dynamic }],
|
|
1193
|
+
* });
|
|
1194
|
+
* ```
|
|
1195
|
+
*/
|
|
1196
|
+
declare function useCompile(): UseCompileResult;
|
|
1197
|
+
|
|
1171
1198
|
/**
|
|
1172
1199
|
* Hook to manage a session wallet lifecycle: create -> fund -> consume.
|
|
1173
1200
|
*
|
|
@@ -1467,4 +1494,4 @@ declare function createMidenStorage(prefix: string): {
|
|
|
1467
1494
|
clear(): void;
|
|
1468
1495
|
};
|
|
1469
1496
|
|
|
1470
|
-
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 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 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 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, formatAssetAmount, formatNoteSummary, getNoteSummary, migrateStorage, normalizeAccountId, parseAssetAmount, readNoteAttachment, toBech32AccountId, useAccount, useAccounts, useAssetMetadata, useConsume, useCreateFaucet, useCreateWallet, useExecuteProgram, useExportNote, useExportStore, useImportAccount, useImportNote, useImportStore, useMiden, useMidenClient, useMint, useMultiSend, useMultiSigner, useNoteStream, useNotes, useSend, useSessionAccount, useSigner, useSwap, useSyncControl, useSyncState, useTransaction, useTransactionHistory, useWaitForCommit, useWaitForNotes, waitForWalletDetection, wrapWasmError };
|
|
1497
|
+
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 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 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, formatAssetAmount, formatNoteSummary, getNoteSummary, 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, useSend, useSessionAccount, useSigner, useSwap, useSyncControl, useSyncState, useTransaction, useTransactionHistory, useWaitForCommit, useWaitForNotes, waitForWalletDetection, wrapWasmError };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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, TransactionId, TransactionFilter, TransactionRecord, TransactionProver, NoteAttachment } 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, TransactionId, TransactionFilter, TransactionRecord, TransactionProver, CompileComponentOptions, CompileTxScriptOptions, CompileNoteScriptOptions, NoteScript, NoteAttachment } from '@miden-sdk/miden-sdk';
|
|
5
5
|
export { Account, AccountFile, AccountHeader, AccountId, AccountStorageMode, AuthScheme, ConsumableNoteRecord, InputNoteRecord, Note, NoteType, TransactionFilter, TransactionId, TransactionRecord, TransactionRequest, WasmWebClient as WebClient } from '@miden-sdk/miden-sdk';
|
|
6
6
|
|
|
7
7
|
declare module "@miden-sdk/miden-sdk" {
|
|
@@ -1168,6 +1168,33 @@ interface UseExecuteProgramResult {
|
|
|
1168
1168
|
}
|
|
1169
1169
|
declare function useExecuteProgram(): UseExecuteProgramResult;
|
|
1170
1170
|
|
|
1171
|
+
interface UseCompileResult {
|
|
1172
|
+
/** Compile MASM source into an AccountComponent. */
|
|
1173
|
+
component: (options: CompileComponentOptions) => Promise<AccountComponent>;
|
|
1174
|
+
/** Compile MASM source into a TransactionScript. */
|
|
1175
|
+
txScript: (options: CompileTxScriptOptions) => Promise<TransactionScript>;
|
|
1176
|
+
/** Compile MASM source into a NoteScript. */
|
|
1177
|
+
noteScript: (options: CompileNoteScriptOptions) => Promise<NoteScript>;
|
|
1178
|
+
/** Whether the underlying client is ready to compile. */
|
|
1179
|
+
isReady: boolean;
|
|
1180
|
+
}
|
|
1181
|
+
/**
|
|
1182
|
+
* Hook for compiling MASM source into `AccountComponent`, `TransactionScript`,
|
|
1183
|
+
* or `NoteScript`. Wraps `CompilerResource` from `@miden-sdk/miden-sdk` so the
|
|
1184
|
+
* shape is identical to `MidenClient.compile`.
|
|
1185
|
+
*
|
|
1186
|
+
* @example
|
|
1187
|
+
* ```tsx
|
|
1188
|
+
* const { noteScript, isReady } = useCompile();
|
|
1189
|
+
*
|
|
1190
|
+
* const script = await noteScript({
|
|
1191
|
+
* code: noteSource,
|
|
1192
|
+
* libraries: [{ namespace: "my_lib", code: libSource, linking: Linking.Dynamic }],
|
|
1193
|
+
* });
|
|
1194
|
+
* ```
|
|
1195
|
+
*/
|
|
1196
|
+
declare function useCompile(): UseCompileResult;
|
|
1197
|
+
|
|
1171
1198
|
/**
|
|
1172
1199
|
* Hook to manage a session wallet lifecycle: create -> fund -> consume.
|
|
1173
1200
|
*
|
|
@@ -1467,4 +1494,4 @@ declare function createMidenStorage(prefix: string): {
|
|
|
1467
1494
|
clear(): void;
|
|
1468
1495
|
};
|
|
1469
1496
|
|
|
1470
|
-
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 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 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 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, formatAssetAmount, formatNoteSummary, getNoteSummary, migrateStorage, normalizeAccountId, parseAssetAmount, readNoteAttachment, toBech32AccountId, useAccount, useAccounts, useAssetMetadata, useConsume, useCreateFaucet, useCreateWallet, useExecuteProgram, useExportNote, useExportStore, useImportAccount, useImportNote, useImportStore, useMiden, useMidenClient, useMint, useMultiSend, useMultiSigner, useNoteStream, useNotes, useSend, useSessionAccount, useSigner, useSwap, useSyncControl, useSyncState, useTransaction, useTransactionHistory, useWaitForCommit, useWaitForNotes, waitForWalletDetection, wrapWasmError };
|
|
1497
|
+
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 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 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, formatAssetAmount, formatNoteSummary, getNoteSummary, 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, useSend, useSessionAccount, useSigner, useSwap, useSyncControl, useSyncState, useTransaction, useTransactionHistory, useWaitForCommit, useWaitForNotes, waitForWalletDetection, wrapWasmError };
|
package/dist/index.js
CHANGED
|
@@ -55,6 +55,7 @@ __export(index_exports, {
|
|
|
55
55
|
useAccount: () => useAccount,
|
|
56
56
|
useAccounts: () => useAccounts,
|
|
57
57
|
useAssetMetadata: () => useAssetMetadata,
|
|
58
|
+
useCompile: () => useCompile,
|
|
58
59
|
useConsume: () => useConsume,
|
|
59
60
|
useCreateFaucet: () => useCreateFaucet,
|
|
60
61
|
useCreateWallet: () => useCreateWallet,
|
|
@@ -3099,26 +3100,56 @@ function useExecuteProgram() {
|
|
|
3099
3100
|
};
|
|
3100
3101
|
}
|
|
3101
3102
|
|
|
3102
|
-
// src/hooks/
|
|
3103
|
+
// src/hooks/useCompile.ts
|
|
3103
3104
|
var import_react23 = require("react");
|
|
3104
3105
|
var import_miden_sdk22 = require("@miden-sdk/miden-sdk");
|
|
3106
|
+
function useCompile() {
|
|
3107
|
+
const { client, isReady } = useMiden();
|
|
3108
|
+
const resource = (0, import_react23.useMemo)(
|
|
3109
|
+
() => client && isReady ? new import_miden_sdk22.CompilerResource(client, import_miden_sdk22.getWasmOrThrow) : null,
|
|
3110
|
+
[client, isReady]
|
|
3111
|
+
);
|
|
3112
|
+
const requireResource = (0, import_react23.useCallback)(() => {
|
|
3113
|
+
if (!resource) {
|
|
3114
|
+
throw new Error("Miden client is not ready");
|
|
3115
|
+
}
|
|
3116
|
+
return resource;
|
|
3117
|
+
}, [resource]);
|
|
3118
|
+
const component = (0, import_react23.useCallback)(
|
|
3119
|
+
async (options) => requireResource().component(options),
|
|
3120
|
+
[requireResource]
|
|
3121
|
+
);
|
|
3122
|
+
const txScript = (0, import_react23.useCallback)(
|
|
3123
|
+
async (options) => requireResource().txScript(options),
|
|
3124
|
+
[requireResource]
|
|
3125
|
+
);
|
|
3126
|
+
const noteScript = (0, import_react23.useCallback)(
|
|
3127
|
+
async (options) => requireResource().noteScript(options),
|
|
3128
|
+
[requireResource]
|
|
3129
|
+
);
|
|
3130
|
+
return { component, txScript, noteScript, isReady };
|
|
3131
|
+
}
|
|
3132
|
+
|
|
3133
|
+
// src/hooks/useSessionAccount.ts
|
|
3134
|
+
var import_react24 = require("react");
|
|
3135
|
+
var import_miden_sdk23 = require("@miden-sdk/miden-sdk");
|
|
3105
3136
|
function useSessionAccount(options) {
|
|
3106
3137
|
const { client, isReady, sync } = useMiden();
|
|
3107
3138
|
const setAccounts = useMidenStore((state) => state.setAccounts);
|
|
3108
|
-
const [sessionAccountId, setSessionAccountId] = (0,
|
|
3109
|
-
const [step, setStep] = (0,
|
|
3110
|
-
const [error, setError] = (0,
|
|
3111
|
-
const cancelledRef = (0,
|
|
3112
|
-
const isBusyRef = (0,
|
|
3139
|
+
const [sessionAccountId, setSessionAccountId] = (0, import_react24.useState)(null);
|
|
3140
|
+
const [step, setStep] = (0, import_react24.useState)("idle");
|
|
3141
|
+
const [error, setError] = (0, import_react24.useState)(null);
|
|
3142
|
+
const cancelledRef = (0, import_react24.useRef)(false);
|
|
3143
|
+
const isBusyRef = (0, import_react24.useRef)(false);
|
|
3113
3144
|
const storagePrefix = options.storagePrefix ?? "miden-session";
|
|
3114
3145
|
const pollIntervalMs = options.pollIntervalMs ?? 3e3;
|
|
3115
3146
|
const maxWaitMs = options.maxWaitMs ?? 6e4;
|
|
3116
3147
|
const storageMode = options.walletOptions?.storageMode ?? "public";
|
|
3117
3148
|
const mutable = options.walletOptions?.mutable ?? DEFAULTS.WALLET_MUTABLE;
|
|
3118
3149
|
const authScheme = options.walletOptions?.authScheme ?? DEFAULTS.AUTH_SCHEME;
|
|
3119
|
-
const fundRef = (0,
|
|
3150
|
+
const fundRef = (0, import_react24.useRef)(options.fund);
|
|
3120
3151
|
fundRef.current = options.fund;
|
|
3121
|
-
(0,
|
|
3152
|
+
(0, import_react24.useEffect)(() => {
|
|
3122
3153
|
try {
|
|
3123
3154
|
const stored = localStorage.getItem(`${storagePrefix}:accountId`);
|
|
3124
3155
|
const storedReady = localStorage.getItem(`${storagePrefix}:ready`);
|
|
@@ -3135,7 +3166,7 @@ function useSessionAccount(options) {
|
|
|
3135
3166
|
localStorage.removeItem(`${storagePrefix}:ready`);
|
|
3136
3167
|
}
|
|
3137
3168
|
}, [storagePrefix]);
|
|
3138
|
-
const initialize = (0,
|
|
3169
|
+
const initialize = (0, import_react24.useCallback)(async () => {
|
|
3139
3170
|
if (!client || !isReady) {
|
|
3140
3171
|
throw new Error("Miden client is not ready");
|
|
3141
3172
|
}
|
|
@@ -3204,7 +3235,7 @@ function useSessionAccount(options) {
|
|
|
3204
3235
|
maxWaitMs,
|
|
3205
3236
|
setAccounts
|
|
3206
3237
|
]);
|
|
3207
|
-
const reset = (0,
|
|
3238
|
+
const reset = (0, import_react24.useCallback)(() => {
|
|
3208
3239
|
cancelledRef.current = true;
|
|
3209
3240
|
isBusyRef.current = false;
|
|
3210
3241
|
setSessionAccountId(null);
|
|
@@ -3225,11 +3256,11 @@ function useSessionAccount(options) {
|
|
|
3225
3256
|
function getStorageMode3(mode) {
|
|
3226
3257
|
switch (mode) {
|
|
3227
3258
|
case "private":
|
|
3228
|
-
return
|
|
3259
|
+
return import_miden_sdk23.AccountStorageMode.private();
|
|
3229
3260
|
case "public":
|
|
3230
|
-
return
|
|
3261
|
+
return import_miden_sdk23.AccountStorageMode.public();
|
|
3231
3262
|
default:
|
|
3232
|
-
return
|
|
3263
|
+
return import_miden_sdk23.AccountStorageMode.public();
|
|
3233
3264
|
}
|
|
3234
3265
|
}
|
|
3235
3266
|
async function waitAndConsume(client, walletId, pollIntervalMs, maxWaitMs, cancelledRef) {
|
|
@@ -3253,13 +3284,13 @@ async function waitAndConsume(client, walletId, pollIntervalMs, maxWaitMs, cance
|
|
|
3253
3284
|
}
|
|
3254
3285
|
|
|
3255
3286
|
// src/hooks/useExportStore.ts
|
|
3256
|
-
var
|
|
3257
|
-
var
|
|
3287
|
+
var import_react25 = require("react");
|
|
3288
|
+
var import_miden_sdk24 = require("@miden-sdk/miden-sdk");
|
|
3258
3289
|
function useExportStore() {
|
|
3259
3290
|
const { client, isReady, runExclusive } = useMiden();
|
|
3260
|
-
const [isExporting, setIsExporting] = (0,
|
|
3261
|
-
const [error, setError] = (0,
|
|
3262
|
-
const exportStore = (0,
|
|
3291
|
+
const [isExporting, setIsExporting] = (0, import_react25.useState)(false);
|
|
3292
|
+
const [error, setError] = (0, import_react25.useState)(null);
|
|
3293
|
+
const exportStore = (0, import_react25.useCallback)(async () => {
|
|
3263
3294
|
if (!client || !isReady) {
|
|
3264
3295
|
throw new Error("Miden client is not ready");
|
|
3265
3296
|
}
|
|
@@ -3267,7 +3298,7 @@ function useExportStore() {
|
|
|
3267
3298
|
setError(null);
|
|
3268
3299
|
try {
|
|
3269
3300
|
const storeName = client.storeIdentifier();
|
|
3270
|
-
const snapshot = await runExclusive(() => (0,
|
|
3301
|
+
const snapshot = await runExclusive(() => (0, import_miden_sdk24.exportStore)(storeName));
|
|
3271
3302
|
return snapshot;
|
|
3272
3303
|
} catch (err) {
|
|
3273
3304
|
const error2 = err instanceof Error ? err : new Error(String(err));
|
|
@@ -3277,7 +3308,7 @@ function useExportStore() {
|
|
|
3277
3308
|
setIsExporting(false);
|
|
3278
3309
|
}
|
|
3279
3310
|
}, [client, isReady, runExclusive]);
|
|
3280
|
-
const reset = (0,
|
|
3311
|
+
const reset = (0, import_react25.useCallback)(() => {
|
|
3281
3312
|
setIsExporting(false);
|
|
3282
3313
|
setError(null);
|
|
3283
3314
|
}, []);
|
|
@@ -3290,13 +3321,13 @@ function useExportStore() {
|
|
|
3290
3321
|
}
|
|
3291
3322
|
|
|
3292
3323
|
// src/hooks/useImportStore.ts
|
|
3293
|
-
var
|
|
3294
|
-
var
|
|
3324
|
+
var import_react26 = require("react");
|
|
3325
|
+
var import_miden_sdk25 = require("@miden-sdk/miden-sdk");
|
|
3295
3326
|
function useImportStore() {
|
|
3296
3327
|
const { client, isReady, runExclusive, sync } = useMiden();
|
|
3297
|
-
const [isImporting, setIsImporting] = (0,
|
|
3298
|
-
const [error, setError] = (0,
|
|
3299
|
-
const importStore = (0,
|
|
3328
|
+
const [isImporting, setIsImporting] = (0, import_react26.useState)(false);
|
|
3329
|
+
const [error, setError] = (0, import_react26.useState)(null);
|
|
3330
|
+
const importStore = (0, import_react26.useCallback)(
|
|
3300
3331
|
async (storeDump, storeName, options) => {
|
|
3301
3332
|
if (!client || !isReady) {
|
|
3302
3333
|
throw new Error("Miden client is not ready");
|
|
@@ -3304,7 +3335,7 @@ function useImportStore() {
|
|
|
3304
3335
|
setIsImporting(true);
|
|
3305
3336
|
setError(null);
|
|
3306
3337
|
try {
|
|
3307
|
-
await runExclusive(() => (0,
|
|
3338
|
+
await runExclusive(() => (0, import_miden_sdk25.importStore)(storeName, storeDump));
|
|
3308
3339
|
if (!options?.skipSync) {
|
|
3309
3340
|
await sync();
|
|
3310
3341
|
}
|
|
@@ -3318,7 +3349,7 @@ function useImportStore() {
|
|
|
3318
3349
|
},
|
|
3319
3350
|
[client, isReady, runExclusive, sync]
|
|
3320
3351
|
);
|
|
3321
|
-
const reset = (0,
|
|
3352
|
+
const reset = (0, import_react26.useCallback)(() => {
|
|
3322
3353
|
setIsImporting(false);
|
|
3323
3354
|
setError(null);
|
|
3324
3355
|
}, []);
|
|
@@ -3331,13 +3362,13 @@ function useImportStore() {
|
|
|
3331
3362
|
}
|
|
3332
3363
|
|
|
3333
3364
|
// src/hooks/useImportNote.ts
|
|
3334
|
-
var
|
|
3335
|
-
var
|
|
3365
|
+
var import_react27 = require("react");
|
|
3366
|
+
var import_miden_sdk26 = require("@miden-sdk/miden-sdk");
|
|
3336
3367
|
function useImportNote() {
|
|
3337
3368
|
const { client, isReady, runExclusive, sync } = useMiden();
|
|
3338
|
-
const [isImporting, setIsImporting] = (0,
|
|
3339
|
-
const [error, setError] = (0,
|
|
3340
|
-
const importNote = (0,
|
|
3369
|
+
const [isImporting, setIsImporting] = (0, import_react27.useState)(false);
|
|
3370
|
+
const [error, setError] = (0, import_react27.useState)(null);
|
|
3371
|
+
const importNote = (0, import_react27.useCallback)(
|
|
3341
3372
|
async (noteBytes) => {
|
|
3342
3373
|
if (!client || !isReady) {
|
|
3343
3374
|
throw new Error("Miden client is not ready");
|
|
@@ -3345,7 +3376,7 @@ function useImportNote() {
|
|
|
3345
3376
|
setIsImporting(true);
|
|
3346
3377
|
setError(null);
|
|
3347
3378
|
try {
|
|
3348
|
-
const noteFile =
|
|
3379
|
+
const noteFile = import_miden_sdk26.NoteFile.deserialize(noteBytes);
|
|
3349
3380
|
const noteId = await runExclusive(
|
|
3350
3381
|
() => client.importNoteFile(noteFile)
|
|
3351
3382
|
);
|
|
@@ -3361,7 +3392,7 @@ function useImportNote() {
|
|
|
3361
3392
|
},
|
|
3362
3393
|
[client, isReady, runExclusive, sync]
|
|
3363
3394
|
);
|
|
3364
|
-
const reset = (0,
|
|
3395
|
+
const reset = (0, import_react27.useCallback)(() => {
|
|
3365
3396
|
setIsImporting(false);
|
|
3366
3397
|
setError(null);
|
|
3367
3398
|
}, []);
|
|
@@ -3374,13 +3405,13 @@ function useImportNote() {
|
|
|
3374
3405
|
}
|
|
3375
3406
|
|
|
3376
3407
|
// src/hooks/useExportNote.ts
|
|
3377
|
-
var
|
|
3378
|
-
var
|
|
3408
|
+
var import_react28 = require("react");
|
|
3409
|
+
var import_miden_sdk27 = require("@miden-sdk/miden-sdk");
|
|
3379
3410
|
function useExportNote() {
|
|
3380
3411
|
const { client, isReady, runExclusive } = useMiden();
|
|
3381
|
-
const [isExporting, setIsExporting] = (0,
|
|
3382
|
-
const [error, setError] = (0,
|
|
3383
|
-
const exportNote = (0,
|
|
3412
|
+
const [isExporting, setIsExporting] = (0, import_react28.useState)(false);
|
|
3413
|
+
const [error, setError] = (0, import_react28.useState)(null);
|
|
3414
|
+
const exportNote = (0, import_react28.useCallback)(
|
|
3384
3415
|
async (noteId) => {
|
|
3385
3416
|
if (!client || !isReady) {
|
|
3386
3417
|
throw new Error("Miden client is not ready");
|
|
@@ -3389,7 +3420,7 @@ function useExportNote() {
|
|
|
3389
3420
|
setError(null);
|
|
3390
3421
|
try {
|
|
3391
3422
|
const noteFile = await runExclusive(
|
|
3392
|
-
() => client.exportNoteFile(noteId,
|
|
3423
|
+
() => client.exportNoteFile(noteId, import_miden_sdk27.NoteExportFormat.Full)
|
|
3393
3424
|
);
|
|
3394
3425
|
return noteFile.serialize();
|
|
3395
3426
|
} catch (err) {
|
|
@@ -3402,7 +3433,7 @@ function useExportNote() {
|
|
|
3402
3433
|
},
|
|
3403
3434
|
[client, isReady, runExclusive]
|
|
3404
3435
|
);
|
|
3405
|
-
const reset = (0,
|
|
3436
|
+
const reset = (0, import_react28.useCallback)(() => {
|
|
3406
3437
|
setIsExporting(false);
|
|
3407
3438
|
setError(null);
|
|
3408
3439
|
}, []);
|
|
@@ -3415,12 +3446,12 @@ function useExportNote() {
|
|
|
3415
3446
|
}
|
|
3416
3447
|
|
|
3417
3448
|
// src/hooks/useSyncControl.ts
|
|
3418
|
-
var
|
|
3449
|
+
var import_react29 = require("react");
|
|
3419
3450
|
function useSyncControl() {
|
|
3420
3451
|
const isPaused = useMidenStore((state) => state.syncPaused);
|
|
3421
3452
|
const setSyncPaused = useMidenStore((state) => state.setSyncPaused);
|
|
3422
|
-
const pauseSync = (0,
|
|
3423
|
-
const resumeSync = (0,
|
|
3453
|
+
const pauseSync = (0, import_react29.useCallback)(() => setSyncPaused(true), [setSyncPaused]);
|
|
3454
|
+
const resumeSync = (0, import_react29.useCallback)(() => setSyncPaused(false), [setSyncPaused]);
|
|
3424
3455
|
return {
|
|
3425
3456
|
pauseSync,
|
|
3426
3457
|
resumeSync,
|
|
@@ -3604,6 +3635,7 @@ installAccountBech32();
|
|
|
3604
3635
|
useAccount,
|
|
3605
3636
|
useAccounts,
|
|
3606
3637
|
useAssetMetadata,
|
|
3638
|
+
useCompile,
|
|
3607
3639
|
useConsume,
|
|
3608
3640
|
useCreateFaucet,
|
|
3609
3641
|
useCreateWallet,
|
package/dist/index.mjs
CHANGED
|
@@ -3066,8 +3066,38 @@ function useExecuteProgram() {
|
|
|
3066
3066
|
};
|
|
3067
3067
|
}
|
|
3068
3068
|
|
|
3069
|
+
// src/hooks/useCompile.ts
|
|
3070
|
+
import { useCallback as useCallback21, useMemo as useMemo8 } from "react";
|
|
3071
|
+
import { CompilerResource, getWasmOrThrow } from "@miden-sdk/miden-sdk";
|
|
3072
|
+
function useCompile() {
|
|
3073
|
+
const { client, isReady } = useMiden();
|
|
3074
|
+
const resource = useMemo8(
|
|
3075
|
+
() => client && isReady ? new CompilerResource(client, getWasmOrThrow) : null,
|
|
3076
|
+
[client, isReady]
|
|
3077
|
+
);
|
|
3078
|
+
const requireResource = useCallback21(() => {
|
|
3079
|
+
if (!resource) {
|
|
3080
|
+
throw new Error("Miden client is not ready");
|
|
3081
|
+
}
|
|
3082
|
+
return resource;
|
|
3083
|
+
}, [resource]);
|
|
3084
|
+
const component = useCallback21(
|
|
3085
|
+
async (options) => requireResource().component(options),
|
|
3086
|
+
[requireResource]
|
|
3087
|
+
);
|
|
3088
|
+
const txScript = useCallback21(
|
|
3089
|
+
async (options) => requireResource().txScript(options),
|
|
3090
|
+
[requireResource]
|
|
3091
|
+
);
|
|
3092
|
+
const noteScript = useCallback21(
|
|
3093
|
+
async (options) => requireResource().noteScript(options),
|
|
3094
|
+
[requireResource]
|
|
3095
|
+
);
|
|
3096
|
+
return { component, txScript, noteScript, isReady };
|
|
3097
|
+
}
|
|
3098
|
+
|
|
3069
3099
|
// src/hooks/useSessionAccount.ts
|
|
3070
|
-
import { useCallback as
|
|
3100
|
+
import { useCallback as useCallback22, useEffect as useEffect9, useRef as useRef8, useState as useState17 } from "react";
|
|
3071
3101
|
import { AccountStorageMode as AccountStorageMode3 } from "@miden-sdk/miden-sdk";
|
|
3072
3102
|
function useSessionAccount(options) {
|
|
3073
3103
|
const { client, isReady, sync } = useMiden();
|
|
@@ -3102,7 +3132,7 @@ function useSessionAccount(options) {
|
|
|
3102
3132
|
localStorage.removeItem(`${storagePrefix}:ready`);
|
|
3103
3133
|
}
|
|
3104
3134
|
}, [storagePrefix]);
|
|
3105
|
-
const initialize =
|
|
3135
|
+
const initialize = useCallback22(async () => {
|
|
3106
3136
|
if (!client || !isReady) {
|
|
3107
3137
|
throw new Error("Miden client is not ready");
|
|
3108
3138
|
}
|
|
@@ -3171,7 +3201,7 @@ function useSessionAccount(options) {
|
|
|
3171
3201
|
maxWaitMs,
|
|
3172
3202
|
setAccounts
|
|
3173
3203
|
]);
|
|
3174
|
-
const reset =
|
|
3204
|
+
const reset = useCallback22(() => {
|
|
3175
3205
|
cancelledRef.current = true;
|
|
3176
3206
|
isBusyRef.current = false;
|
|
3177
3207
|
setSessionAccountId(null);
|
|
@@ -3220,13 +3250,13 @@ async function waitAndConsume(client, walletId, pollIntervalMs, maxWaitMs, cance
|
|
|
3220
3250
|
}
|
|
3221
3251
|
|
|
3222
3252
|
// src/hooks/useExportStore.ts
|
|
3223
|
-
import { useCallback as
|
|
3253
|
+
import { useCallback as useCallback23, useState as useState18 } from "react";
|
|
3224
3254
|
import { exportStore as sdkExportStore } from "@miden-sdk/miden-sdk";
|
|
3225
3255
|
function useExportStore() {
|
|
3226
3256
|
const { client, isReady, runExclusive } = useMiden();
|
|
3227
3257
|
const [isExporting, setIsExporting] = useState18(false);
|
|
3228
3258
|
const [error, setError] = useState18(null);
|
|
3229
|
-
const exportStore =
|
|
3259
|
+
const exportStore = useCallback23(async () => {
|
|
3230
3260
|
if (!client || !isReady) {
|
|
3231
3261
|
throw new Error("Miden client is not ready");
|
|
3232
3262
|
}
|
|
@@ -3244,7 +3274,7 @@ function useExportStore() {
|
|
|
3244
3274
|
setIsExporting(false);
|
|
3245
3275
|
}
|
|
3246
3276
|
}, [client, isReady, runExclusive]);
|
|
3247
|
-
const reset =
|
|
3277
|
+
const reset = useCallback23(() => {
|
|
3248
3278
|
setIsExporting(false);
|
|
3249
3279
|
setError(null);
|
|
3250
3280
|
}, []);
|
|
@@ -3257,13 +3287,13 @@ function useExportStore() {
|
|
|
3257
3287
|
}
|
|
3258
3288
|
|
|
3259
3289
|
// src/hooks/useImportStore.ts
|
|
3260
|
-
import { useCallback as
|
|
3290
|
+
import { useCallback as useCallback24, useState as useState19 } from "react";
|
|
3261
3291
|
import { importStore as sdkImportStore } from "@miden-sdk/miden-sdk";
|
|
3262
3292
|
function useImportStore() {
|
|
3263
3293
|
const { client, isReady, runExclusive, sync } = useMiden();
|
|
3264
3294
|
const [isImporting, setIsImporting] = useState19(false);
|
|
3265
3295
|
const [error, setError] = useState19(null);
|
|
3266
|
-
const importStore =
|
|
3296
|
+
const importStore = useCallback24(
|
|
3267
3297
|
async (storeDump, storeName, options) => {
|
|
3268
3298
|
if (!client || !isReady) {
|
|
3269
3299
|
throw new Error("Miden client is not ready");
|
|
@@ -3285,7 +3315,7 @@ function useImportStore() {
|
|
|
3285
3315
|
},
|
|
3286
3316
|
[client, isReady, runExclusive, sync]
|
|
3287
3317
|
);
|
|
3288
|
-
const reset =
|
|
3318
|
+
const reset = useCallback24(() => {
|
|
3289
3319
|
setIsImporting(false);
|
|
3290
3320
|
setError(null);
|
|
3291
3321
|
}, []);
|
|
@@ -3298,13 +3328,13 @@ function useImportStore() {
|
|
|
3298
3328
|
}
|
|
3299
3329
|
|
|
3300
3330
|
// src/hooks/useImportNote.ts
|
|
3301
|
-
import { useCallback as
|
|
3331
|
+
import { useCallback as useCallback25, useState as useState20 } from "react";
|
|
3302
3332
|
import { NoteFile } from "@miden-sdk/miden-sdk";
|
|
3303
3333
|
function useImportNote() {
|
|
3304
3334
|
const { client, isReady, runExclusive, sync } = useMiden();
|
|
3305
3335
|
const [isImporting, setIsImporting] = useState20(false);
|
|
3306
3336
|
const [error, setError] = useState20(null);
|
|
3307
|
-
const importNote =
|
|
3337
|
+
const importNote = useCallback25(
|
|
3308
3338
|
async (noteBytes) => {
|
|
3309
3339
|
if (!client || !isReady) {
|
|
3310
3340
|
throw new Error("Miden client is not ready");
|
|
@@ -3328,7 +3358,7 @@ function useImportNote() {
|
|
|
3328
3358
|
},
|
|
3329
3359
|
[client, isReady, runExclusive, sync]
|
|
3330
3360
|
);
|
|
3331
|
-
const reset =
|
|
3361
|
+
const reset = useCallback25(() => {
|
|
3332
3362
|
setIsImporting(false);
|
|
3333
3363
|
setError(null);
|
|
3334
3364
|
}, []);
|
|
@@ -3341,13 +3371,13 @@ function useImportNote() {
|
|
|
3341
3371
|
}
|
|
3342
3372
|
|
|
3343
3373
|
// src/hooks/useExportNote.ts
|
|
3344
|
-
import { useCallback as
|
|
3374
|
+
import { useCallback as useCallback26, useState as useState21 } from "react";
|
|
3345
3375
|
import { NoteExportFormat } from "@miden-sdk/miden-sdk";
|
|
3346
3376
|
function useExportNote() {
|
|
3347
3377
|
const { client, isReady, runExclusive } = useMiden();
|
|
3348
3378
|
const [isExporting, setIsExporting] = useState21(false);
|
|
3349
3379
|
const [error, setError] = useState21(null);
|
|
3350
|
-
const exportNote =
|
|
3380
|
+
const exportNote = useCallback26(
|
|
3351
3381
|
async (noteId) => {
|
|
3352
3382
|
if (!client || !isReady) {
|
|
3353
3383
|
throw new Error("Miden client is not ready");
|
|
@@ -3369,7 +3399,7 @@ function useExportNote() {
|
|
|
3369
3399
|
},
|
|
3370
3400
|
[client, isReady, runExclusive]
|
|
3371
3401
|
);
|
|
3372
|
-
const reset =
|
|
3402
|
+
const reset = useCallback26(() => {
|
|
3373
3403
|
setIsExporting(false);
|
|
3374
3404
|
setError(null);
|
|
3375
3405
|
}, []);
|
|
@@ -3382,12 +3412,12 @@ function useExportNote() {
|
|
|
3382
3412
|
}
|
|
3383
3413
|
|
|
3384
3414
|
// src/hooks/useSyncControl.ts
|
|
3385
|
-
import { useCallback as
|
|
3415
|
+
import { useCallback as useCallback27 } from "react";
|
|
3386
3416
|
function useSyncControl() {
|
|
3387
3417
|
const isPaused = useMidenStore((state) => state.syncPaused);
|
|
3388
3418
|
const setSyncPaused = useMidenStore((state) => state.setSyncPaused);
|
|
3389
|
-
const pauseSync =
|
|
3390
|
-
const resumeSync =
|
|
3419
|
+
const pauseSync = useCallback27(() => setSyncPaused(true), [setSyncPaused]);
|
|
3420
|
+
const resumeSync = useCallback27(() => setSyncPaused(false), [setSyncPaused]);
|
|
3391
3421
|
return {
|
|
3392
3422
|
pauseSync,
|
|
3393
3423
|
resumeSync,
|
|
@@ -3570,6 +3600,7 @@ export {
|
|
|
3570
3600
|
useAccount,
|
|
3571
3601
|
useAccounts,
|
|
3572
3602
|
useAssetMetadata,
|
|
3603
|
+
useCompile,
|
|
3573
3604
|
useConsume,
|
|
3574
3605
|
useCreateFaucet,
|
|
3575
3606
|
useCreateWallet,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@miden-sdk/react",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.3",
|
|
4
4
|
"description": "React hooks library for Miden Web Client",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"test:all": "VITE_CJS_IGNORE_WARNING=1 vitest run && playwright test"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
|
-
"@miden-sdk/miden-sdk": "^0.14.
|
|
31
|
+
"@miden-sdk/miden-sdk": "^0.14.2",
|
|
32
32
|
"react": ">=18.0.0"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|