@miden-sdk/react 0.15.0-alpha.4 → 0.15.0-alpha.5
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 +3 -0
- package/README.md +146 -7
- package/dist/index.d.ts +222 -10
- package/dist/index.mjs +356 -121
- package/dist/{index.d.mts → lazy.d.ts} +222 -10
- package/dist/lazy.mjs +3860 -0
- package/dist/mt/lazy.d.ts +1711 -0
- package/dist/mt/lazy.mjs +3860 -0
- package/dist/mt.d.ts +1711 -0
- package/dist/{index.js → mt.mjs} +703 -505
- package/lazy/package.json +5 -0
- package/mt/lazy/package.json +5 -0
- package/mt/package.json +5 -0
- package/package.json +22 -14
package/dist/index.mjs
CHANGED
|
@@ -443,15 +443,6 @@ function useSigner() {
|
|
|
443
443
|
}
|
|
444
444
|
|
|
445
445
|
// src/utils/signerAccount.ts
|
|
446
|
-
var WASM_ACCOUNT_TYPE = {
|
|
447
|
-
FungibleFaucet: 0,
|
|
448
|
-
NonFungibleFaucet: 1,
|
|
449
|
-
RegularAccountImmutableCode: 2,
|
|
450
|
-
RegularAccountUpdatableCode: 3
|
|
451
|
-
};
|
|
452
|
-
function getAccountType(accountType) {
|
|
453
|
-
return WASM_ACCOUNT_TYPE[accountType] ?? WASM_ACCOUNT_TYPE.RegularAccountImmutableCode;
|
|
454
|
-
}
|
|
455
446
|
function isPrivateStorageMode(storageMode) {
|
|
456
447
|
return storageMode.toString() === "private";
|
|
457
448
|
}
|
|
@@ -463,8 +454,10 @@ async function initializeSignerAccount(client, config) {
|
|
|
463
454
|
try {
|
|
464
455
|
await client.importAccountById(accountId2);
|
|
465
456
|
} catch (e) {
|
|
466
|
-
const
|
|
467
|
-
|
|
457
|
+
const code = e?.code;
|
|
458
|
+
const isFreshAccount = code === "ACCOUNT_NOT_FOUND_ON_CHAIN";
|
|
459
|
+
const isAlreadyTracked = code === "ACCOUNT_ALREADY_TRACKED";
|
|
460
|
+
if (!isAlreadyTracked && !isFreshAccount) {
|
|
468
461
|
throw e;
|
|
469
462
|
}
|
|
470
463
|
}
|
|
@@ -473,13 +466,12 @@ async function initializeSignerAccount(client, config) {
|
|
|
473
466
|
}
|
|
474
467
|
const commitmentWord = Word2.deserialize(config.publicKeyCommitment);
|
|
475
468
|
const seed = config.accountSeed ?? crypto.getRandomValues(new Uint8Array(32));
|
|
476
|
-
const accountType = getAccountType(config.accountType);
|
|
477
469
|
let builder = new AccountBuilder(seed).withAuthComponent(
|
|
478
470
|
AccountComponent.createAuthComponentFromCommitment(
|
|
479
471
|
commitmentWord,
|
|
480
472
|
AuthScheme2.AuthEcdsaK256Keccak
|
|
481
473
|
)
|
|
482
|
-
).
|
|
474
|
+
).storageMode(config.storageMode).withBasicWalletComponent();
|
|
483
475
|
if (config.customComponents?.length) {
|
|
484
476
|
for (const component of config.customComponents) {
|
|
485
477
|
if (component == null || typeof component.getProcedures !== "function") {
|
|
@@ -644,7 +636,9 @@ function MidenProvider({
|
|
|
644
636
|
storeName,
|
|
645
637
|
signerContext.getKeyCb,
|
|
646
638
|
signerContext.insertKeyCb,
|
|
647
|
-
wrappedSignCb
|
|
639
|
+
wrappedSignCb,
|
|
640
|
+
void 0,
|
|
641
|
+
resolvedConfig.useWorker
|
|
648
642
|
);
|
|
649
643
|
if (cancelled) return;
|
|
650
644
|
const accountId = await initializeSignerAccount(
|
|
@@ -660,7 +654,10 @@ function MidenProvider({
|
|
|
660
654
|
webClient = await WebClient.createClient(
|
|
661
655
|
resolvedConfig.rpcUrl,
|
|
662
656
|
resolvedConfig.noteTransportUrl,
|
|
663
|
-
seed
|
|
657
|
+
seed,
|
|
658
|
+
void 0,
|
|
659
|
+
void 0,
|
|
660
|
+
resolvedConfig.useWorker
|
|
664
661
|
);
|
|
665
662
|
if (cancelled) return;
|
|
666
663
|
}
|
|
@@ -1204,6 +1201,27 @@ var parseAssetAmount = (input, decimals) => {
|
|
|
1204
1201
|
};
|
|
1205
1202
|
|
|
1206
1203
|
// src/utils/notes.ts
|
|
1204
|
+
var resolveNoteInput = async (input, client) => {
|
|
1205
|
+
if (typeof input === "string") {
|
|
1206
|
+
const record2 = await client.getInputNote(input);
|
|
1207
|
+
if (!record2) {
|
|
1208
|
+
throw new Error(`Note not found: ${input}`);
|
|
1209
|
+
}
|
|
1210
|
+
return record2.toNote();
|
|
1211
|
+
}
|
|
1212
|
+
if (typeof input.toNote === "function") {
|
|
1213
|
+
return input.toNote();
|
|
1214
|
+
}
|
|
1215
|
+
if (typeof input.id === "function") {
|
|
1216
|
+
return input;
|
|
1217
|
+
}
|
|
1218
|
+
const hex = input.toString();
|
|
1219
|
+
const record = await client.getInputNote(hex);
|
|
1220
|
+
if (!record) {
|
|
1221
|
+
throw new Error(`Note not found: ${hex}`);
|
|
1222
|
+
}
|
|
1223
|
+
return record.toNote();
|
|
1224
|
+
};
|
|
1207
1225
|
var getInputNoteRecord = (note) => {
|
|
1208
1226
|
const maybeConsumable = note;
|
|
1209
1227
|
if (typeof maybeConsumable.inputNoteRecord === "function") {
|
|
@@ -1214,7 +1232,9 @@ var getInputNoteRecord = (note) => {
|
|
|
1214
1232
|
var getNoteSummary = (note, getAssetMetadata) => {
|
|
1215
1233
|
try {
|
|
1216
1234
|
const record = getInputNoteRecord(note);
|
|
1217
|
-
const
|
|
1235
|
+
const rawId = record.id();
|
|
1236
|
+
if (!rawId) return null;
|
|
1237
|
+
const id = rawId.toString();
|
|
1218
1238
|
const assets = [];
|
|
1219
1239
|
try {
|
|
1220
1240
|
const details = record.details();
|
|
@@ -1473,38 +1493,23 @@ import { NoteFilter as NoteFilter2 } from "@miden-sdk/miden-sdk";
|
|
|
1473
1493
|
// src/utils/noteAttachment.ts
|
|
1474
1494
|
import {
|
|
1475
1495
|
NoteAttachment,
|
|
1476
|
-
NoteAttachmentKind,
|
|
1477
1496
|
NoteAttachmentScheme,
|
|
1478
1497
|
Word
|
|
1479
1498
|
} from "@miden-sdk/miden-sdk";
|
|
1480
1499
|
function readNoteAttachment(note) {
|
|
1481
1500
|
try {
|
|
1482
|
-
const
|
|
1483
|
-
if (!
|
|
1484
|
-
const
|
|
1485
|
-
if (
|
|
1486
|
-
const
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
(v) => BigInt(v)
|
|
1495
|
-
);
|
|
1496
|
-
return { values, kind: "word" };
|
|
1497
|
-
}
|
|
1498
|
-
if (kind === NoteAttachmentKind.Array) {
|
|
1499
|
-
const arr = attachment.asArray?.();
|
|
1500
|
-
if (!arr) return null;
|
|
1501
|
-
const u64s = arr.toU64s();
|
|
1502
|
-
const values = Array.from(u64s).map(
|
|
1503
|
-
(v) => BigInt(v)
|
|
1504
|
-
);
|
|
1505
|
-
return { values, kind: "array" };
|
|
1506
|
-
}
|
|
1507
|
-
return null;
|
|
1501
|
+
const attachments = note.attachments?.();
|
|
1502
|
+
if (!attachments || attachments.length === 0) return null;
|
|
1503
|
+
const words = attachments[0].toWords();
|
|
1504
|
+
if (words.length === 0) return null;
|
|
1505
|
+
const values = [];
|
|
1506
|
+
for (const word of words) {
|
|
1507
|
+
for (const value of word.toU64s()) {
|
|
1508
|
+
values.push(BigInt(value));
|
|
1509
|
+
}
|
|
1510
|
+
}
|
|
1511
|
+
if (values.every((value) => value === 0n)) return null;
|
|
1512
|
+
return { values, kind: words.length === 1 ? "word" : "array" };
|
|
1508
1513
|
} catch {
|
|
1509
1514
|
return null;
|
|
1510
1515
|
}
|
|
@@ -1515,7 +1520,7 @@ function createNoteAttachment(values) {
|
|
|
1515
1520
|
bigints.push(BigInt(values[i]));
|
|
1516
1521
|
}
|
|
1517
1522
|
if (bigints.length === 0) {
|
|
1518
|
-
return
|
|
1523
|
+
return emptyAttachment();
|
|
1519
1524
|
}
|
|
1520
1525
|
const scheme = NoteAttachmentScheme.none();
|
|
1521
1526
|
if (bigints.length <= 4) {
|
|
@@ -1523,7 +1528,7 @@ function createNoteAttachment(values) {
|
|
|
1523
1528
|
bigints.push(0n);
|
|
1524
1529
|
}
|
|
1525
1530
|
const word = new Word(BigUint64Array.from(bigints));
|
|
1526
|
-
return NoteAttachment.
|
|
1531
|
+
return NoteAttachment.fromWord(scheme, word);
|
|
1527
1532
|
}
|
|
1528
1533
|
while (bigints.length % 4 !== 0) {
|
|
1529
1534
|
bigints.push(0n);
|
|
@@ -1532,13 +1537,12 @@ function createNoteAttachment(values) {
|
|
|
1532
1537
|
for (let i = 0; i < bigints.length; i += 4) {
|
|
1533
1538
|
words.push(new Word(BigUint64Array.from(bigints.slice(i, i + 4))));
|
|
1534
1539
|
}
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
return newArray.call(NoteAttachment, scheme, words);
|
|
1540
|
+
return NoteAttachment.fromWords(scheme, words);
|
|
1541
|
+
}
|
|
1542
|
+
function emptyAttachment() {
|
|
1543
|
+
const scheme = NoteAttachmentScheme.none();
|
|
1544
|
+
const word = new Word(BigUint64Array.from([0n, 0n, 0n, 0n]));
|
|
1545
|
+
return NoteAttachment.fromWord(scheme, word);
|
|
1542
1546
|
}
|
|
1543
1547
|
|
|
1544
1548
|
// src/hooks/useNoteStream.ts
|
|
@@ -1647,7 +1651,9 @@ function useNoteStream(options = {}) {
|
|
|
1647
1651
|
}
|
|
1648
1652
|
function buildStreamedNote(record, noteFirstSeen) {
|
|
1649
1653
|
try {
|
|
1650
|
-
const
|
|
1654
|
+
const rawId = record.id();
|
|
1655
|
+
if (!rawId) return null;
|
|
1656
|
+
const id = rawId.toString();
|
|
1651
1657
|
const metadata = record.metadata?.();
|
|
1652
1658
|
const senderHex = metadata?.sender?.()?.toString?.();
|
|
1653
1659
|
const sender = senderHex ? toBech32AccountId(senderHex) : "";
|
|
@@ -1862,8 +1868,6 @@ function getStorageMode(mode) {
|
|
|
1862
1868
|
return AccountStorageMode.private();
|
|
1863
1869
|
case "public":
|
|
1864
1870
|
return AccountStorageMode.public();
|
|
1865
|
-
case "network":
|
|
1866
|
-
return AccountStorageMode.network();
|
|
1867
1871
|
default:
|
|
1868
1872
|
return AccountStorageMode.private();
|
|
1869
1873
|
}
|
|
@@ -1897,6 +1901,7 @@ function useCreateFaucet() {
|
|
|
1897
1901
|
storageMode,
|
|
1898
1902
|
false,
|
|
1899
1903
|
// nonFungible - currently only fungible faucets supported
|
|
1904
|
+
options.tokenName ?? options.tokenSymbol,
|
|
1900
1905
|
options.tokenSymbol,
|
|
1901
1906
|
decimals,
|
|
1902
1907
|
BigInt(options.maxSupply),
|
|
@@ -1937,8 +1942,6 @@ function getStorageMode2(mode) {
|
|
|
1937
1942
|
return AccountStorageMode2.private();
|
|
1938
1943
|
case "public":
|
|
1939
1944
|
return AccountStorageMode2.public();
|
|
1940
|
-
case "network":
|
|
1941
|
-
return AccountStorageMode2.network();
|
|
1942
1945
|
default:
|
|
1943
1946
|
return AccountStorageMode2.private();
|
|
1944
1947
|
}
|
|
@@ -2155,7 +2158,6 @@ import {
|
|
|
2155
2158
|
FungibleAsset,
|
|
2156
2159
|
Note,
|
|
2157
2160
|
NoteAssets,
|
|
2158
|
-
NoteAttachment as NoteAttachment2,
|
|
2159
2161
|
NoteType as NoteType2,
|
|
2160
2162
|
NoteArray,
|
|
2161
2163
|
TransactionRequestBuilder
|
|
@@ -2234,7 +2236,7 @@ function useSend() {
|
|
|
2234
2236
|
toId,
|
|
2235
2237
|
assets,
|
|
2236
2238
|
noteType,
|
|
2237
|
-
|
|
2239
|
+
emptyAttachment()
|
|
2238
2240
|
);
|
|
2239
2241
|
const ownOutputs = new NoteArray();
|
|
2240
2242
|
ownOutputs.push(p2idNote);
|
|
@@ -2245,7 +2247,7 @@ function useSend() {
|
|
|
2245
2247
|
txRequest,
|
|
2246
2248
|
prover
|
|
2247
2249
|
) : await client.submitNewTransaction(execFromId, txRequest);
|
|
2248
|
-
return { txId: txId.
|
|
2250
|
+
return { txId: txId.toHex(), note: p2idNote };
|
|
2249
2251
|
});
|
|
2250
2252
|
setStage("complete");
|
|
2251
2253
|
setResult(returnResult);
|
|
@@ -2297,7 +2299,6 @@ function useSend() {
|
|
|
2297
2299
|
() => client.submitProvenTransaction(provenTransaction, txResult)
|
|
2298
2300
|
);
|
|
2299
2301
|
const txIdHex = txResult.id().toHex();
|
|
2300
|
-
const txIdString = txResult.id().toString();
|
|
2301
2302
|
let fullNote = null;
|
|
2302
2303
|
if (noteType === NoteType2.Private) {
|
|
2303
2304
|
fullNote = extractFullNote(txResult);
|
|
@@ -2321,7 +2322,7 @@ function useSend() {
|
|
|
2321
2322
|
);
|
|
2322
2323
|
}
|
|
2323
2324
|
const sendResult = {
|
|
2324
|
-
txId:
|
|
2325
|
+
txId: txIdHex,
|
|
2325
2326
|
note: null
|
|
2326
2327
|
};
|
|
2327
2328
|
setStage("complete");
|
|
@@ -2372,7 +2373,6 @@ import {
|
|
|
2372
2373
|
FungibleAsset as FungibleAsset2,
|
|
2373
2374
|
Note as Note2,
|
|
2374
2375
|
NoteAssets as NoteAssets2,
|
|
2375
|
-
NoteAttachment as NoteAttachment3,
|
|
2376
2376
|
NoteType as NoteType3,
|
|
2377
2377
|
NoteArray as NoteArray2,
|
|
2378
2378
|
TransactionRequestBuilder as TransactionRequestBuilder2
|
|
@@ -2417,7 +2417,7 @@ function useMultiSend() {
|
|
|
2417
2417
|
new FungibleAsset2(iterAssetId, BigInt(amount))
|
|
2418
2418
|
]);
|
|
2419
2419
|
const resolvedNoteType = recipientNoteType ? getNoteType(recipientNoteType) : noteType;
|
|
2420
|
-
const noteAttachment = attachment !== void 0 && attachment !== null ? createNoteAttachment(attachment) :
|
|
2420
|
+
const noteAttachment = attachment !== void 0 && attachment !== null ? createNoteAttachment(attachment) : emptyAttachment();
|
|
2421
2421
|
const note = Note2.createP2IDNote(
|
|
2422
2422
|
iterSenderId,
|
|
2423
2423
|
receiverId,
|
|
@@ -2433,7 +2433,11 @@ function useMultiSend() {
|
|
|
2433
2433
|
};
|
|
2434
2434
|
}
|
|
2435
2435
|
);
|
|
2436
|
-
const
|
|
2436
|
+
const ownOutputs = new NoteArray2();
|
|
2437
|
+
for (const o of outputs) {
|
|
2438
|
+
ownOutputs.push(o.note);
|
|
2439
|
+
}
|
|
2440
|
+
const txRequest = new TransactionRequestBuilder2().withOwnOutputNotes(ownOutputs).build();
|
|
2437
2441
|
const txSenderId = parseAccountId(options.from);
|
|
2438
2442
|
const txResult = await client.executeTransaction(txSenderId, txRequest);
|
|
2439
2443
|
setStage("proving");
|
|
@@ -2450,7 +2454,6 @@ function useMultiSend() {
|
|
|
2450
2454
|
txResult
|
|
2451
2455
|
);
|
|
2452
2456
|
const txIdHex = txResult.id().toHex();
|
|
2453
|
-
const txIdString = txResult.id().toString();
|
|
2454
2457
|
await client.applyTransaction(txResult, submissionHeight);
|
|
2455
2458
|
const hasPrivate = outputs.some((o) => o.noteType === NoteType3.Private);
|
|
2456
2459
|
if (hasPrivate) {
|
|
@@ -2468,7 +2471,7 @@ function useMultiSend() {
|
|
|
2468
2471
|
}
|
|
2469
2472
|
}
|
|
2470
2473
|
}
|
|
2471
|
-
const txSummary = { transactionId:
|
|
2474
|
+
const txSummary = { transactionId: txIdHex };
|
|
2472
2475
|
setStage("complete");
|
|
2473
2476
|
setResult(txSummary);
|
|
2474
2477
|
await sync();
|
|
@@ -2617,7 +2620,7 @@ function useMint() {
|
|
|
2617
2620
|
txRequest,
|
|
2618
2621
|
prover
|
|
2619
2622
|
) : await client.submitNewTransaction(faucetIdObj, txRequest);
|
|
2620
|
-
return { transactionId: txId.
|
|
2623
|
+
return { transactionId: txId.toHex() };
|
|
2621
2624
|
});
|
|
2622
2625
|
setStage("complete");
|
|
2623
2626
|
setResult(txResult);
|
|
@@ -2693,16 +2696,25 @@ function useConsume() {
|
|
|
2693
2696
|
}
|
|
2694
2697
|
}
|
|
2695
2698
|
if (lookupIds.length > 0) {
|
|
2699
|
+
const lookupIdStrings = lookupIds.map((id) => id.toString());
|
|
2696
2700
|
const filter = new NoteFilter3(NoteFilterTypes2.List, lookupIds);
|
|
2697
2701
|
const noteRecords = await client.getInputNotes(filter);
|
|
2698
|
-
if (noteRecords.length !==
|
|
2702
|
+
if (noteRecords.length !== lookupIdStrings.length) {
|
|
2699
2703
|
throw new Error("Some notes could not be found for provided IDs");
|
|
2700
2704
|
}
|
|
2701
2705
|
const recordById = new Map(
|
|
2702
|
-
noteRecords.map((r) =>
|
|
2706
|
+
noteRecords.map((r) => {
|
|
2707
|
+
const id = r.id();
|
|
2708
|
+
if (!id) {
|
|
2709
|
+
throw new Error(
|
|
2710
|
+
"getInputNotes returned a record without a note id"
|
|
2711
|
+
);
|
|
2712
|
+
}
|
|
2713
|
+
return [id.toString(), r];
|
|
2714
|
+
})
|
|
2703
2715
|
);
|
|
2704
2716
|
for (let j = 0; j < lookupIndices.length; j++) {
|
|
2705
|
-
const record = recordById.get(
|
|
2717
|
+
const record = recordById.get(lookupIdStrings[j]);
|
|
2706
2718
|
if (!record) {
|
|
2707
2719
|
throw new Error(
|
|
2708
2720
|
"Some notes could not be found for provided IDs"
|
|
@@ -2718,7 +2730,7 @@ function useConsume() {
|
|
|
2718
2730
|
txRequest,
|
|
2719
2731
|
prover
|
|
2720
2732
|
) : await client.submitNewTransaction(accountIdObj, txRequest);
|
|
2721
|
-
return { transactionId: txId.
|
|
2733
|
+
return { transactionId: txId.toHex() };
|
|
2722
2734
|
});
|
|
2723
2735
|
setStage("complete");
|
|
2724
2736
|
setResult(txResult);
|
|
@@ -2792,7 +2804,7 @@ function useSwap() {
|
|
|
2792
2804
|
txRequest,
|
|
2793
2805
|
prover
|
|
2794
2806
|
) : await client.submitNewTransaction(accountIdObj, txRequest);
|
|
2795
|
-
return { transactionId: txId.
|
|
2807
|
+
return { transactionId: txId.toHex() };
|
|
2796
2808
|
});
|
|
2797
2809
|
setStage("complete");
|
|
2798
2810
|
setResult(txResult);
|
|
@@ -2825,8 +2837,228 @@ function useSwap() {
|
|
|
2825
2837
|
};
|
|
2826
2838
|
}
|
|
2827
2839
|
|
|
2840
|
+
// src/hooks/usePswapCreate.ts
|
|
2841
|
+
import { useCallback as useCallback19, useState as useState15 } from "react";
|
|
2842
|
+
function usePswapCreate() {
|
|
2843
|
+
const { client, isReady, sync, runExclusive, prover } = useMiden();
|
|
2844
|
+
const runExclusiveSafe = runExclusive ?? runExclusiveDirect;
|
|
2845
|
+
const [result, setResult] = useState15(null);
|
|
2846
|
+
const [isLoading, setIsLoading] = useState15(false);
|
|
2847
|
+
const [stage, setStage] = useState15("idle");
|
|
2848
|
+
const [error, setError] = useState15(null);
|
|
2849
|
+
const pswapCreate = useCallback19(
|
|
2850
|
+
async (options) => {
|
|
2851
|
+
if (!client || !isReady) {
|
|
2852
|
+
throw new Error("Miden client is not ready");
|
|
2853
|
+
}
|
|
2854
|
+
const offeredAmount = BigInt(options.offeredAmount);
|
|
2855
|
+
const requestedAmount = BigInt(options.requestedAmount);
|
|
2856
|
+
if (offeredAmount <= 0n) {
|
|
2857
|
+
throw new Error("offeredAmount must be greater than 0");
|
|
2858
|
+
}
|
|
2859
|
+
if (requestedAmount <= 0n) {
|
|
2860
|
+
throw new Error("requestedAmount must be greater than 0");
|
|
2861
|
+
}
|
|
2862
|
+
setIsLoading(true);
|
|
2863
|
+
setStage("executing");
|
|
2864
|
+
setError(null);
|
|
2865
|
+
try {
|
|
2866
|
+
const noteType = getNoteType(options.noteType ?? DEFAULTS.NOTE_TYPE);
|
|
2867
|
+
const paybackNoteType = getNoteType(
|
|
2868
|
+
options.paybackNoteType ?? DEFAULTS.NOTE_TYPE
|
|
2869
|
+
);
|
|
2870
|
+
const accountIdObj = parseAccountId(options.accountId);
|
|
2871
|
+
const offeredFaucetIdObj = parseAccountId(options.offeredFaucetId);
|
|
2872
|
+
const requestedFaucetIdObj = parseAccountId(options.requestedFaucetId);
|
|
2873
|
+
setStage("proving");
|
|
2874
|
+
const txResult = await runExclusiveSafe(async () => {
|
|
2875
|
+
const txRequest = await client.newPswapCreateTransactionRequest(
|
|
2876
|
+
accountIdObj,
|
|
2877
|
+
offeredFaucetIdObj,
|
|
2878
|
+
offeredAmount,
|
|
2879
|
+
requestedFaucetIdObj,
|
|
2880
|
+
requestedAmount,
|
|
2881
|
+
noteType,
|
|
2882
|
+
paybackNoteType
|
|
2883
|
+
);
|
|
2884
|
+
const txId = prover ? await client.submitNewTransactionWithProver(
|
|
2885
|
+
accountIdObj,
|
|
2886
|
+
txRequest,
|
|
2887
|
+
prover
|
|
2888
|
+
) : await client.submitNewTransaction(accountIdObj, txRequest);
|
|
2889
|
+
return { transactionId: txId.toHex() };
|
|
2890
|
+
});
|
|
2891
|
+
setStage("complete");
|
|
2892
|
+
setResult(txResult);
|
|
2893
|
+
await sync();
|
|
2894
|
+
return txResult;
|
|
2895
|
+
} catch (err) {
|
|
2896
|
+
const error2 = err instanceof Error ? err : new Error(String(err));
|
|
2897
|
+
setError(error2);
|
|
2898
|
+
setStage("idle");
|
|
2899
|
+
throw error2;
|
|
2900
|
+
} finally {
|
|
2901
|
+
setIsLoading(false);
|
|
2902
|
+
}
|
|
2903
|
+
},
|
|
2904
|
+
[client, isReady, prover, runExclusive, sync]
|
|
2905
|
+
);
|
|
2906
|
+
const reset = useCallback19(() => {
|
|
2907
|
+
setResult(null);
|
|
2908
|
+
setIsLoading(false);
|
|
2909
|
+
setStage("idle");
|
|
2910
|
+
setError(null);
|
|
2911
|
+
}, []);
|
|
2912
|
+
return {
|
|
2913
|
+
pswapCreate,
|
|
2914
|
+
result,
|
|
2915
|
+
isLoading,
|
|
2916
|
+
stage,
|
|
2917
|
+
error,
|
|
2918
|
+
reset
|
|
2919
|
+
};
|
|
2920
|
+
}
|
|
2921
|
+
|
|
2922
|
+
// src/hooks/usePswapConsume.ts
|
|
2923
|
+
import { useCallback as useCallback20, useState as useState16 } from "react";
|
|
2924
|
+
function usePswapConsume() {
|
|
2925
|
+
const { client, isReady, sync, runExclusive, prover } = useMiden();
|
|
2926
|
+
const runExclusiveSafe = runExclusive ?? runExclusiveDirect;
|
|
2927
|
+
const [result, setResult] = useState16(null);
|
|
2928
|
+
const [isLoading, setIsLoading] = useState16(false);
|
|
2929
|
+
const [stage, setStage] = useState16("idle");
|
|
2930
|
+
const [error, setError] = useState16(null);
|
|
2931
|
+
const pswapConsume = useCallback20(
|
|
2932
|
+
async (options) => {
|
|
2933
|
+
if (!client || !isReady) {
|
|
2934
|
+
throw new Error("Miden client is not ready");
|
|
2935
|
+
}
|
|
2936
|
+
const fillAmount = BigInt(options.fillAmount);
|
|
2937
|
+
const noteFillAmount = BigInt(options.noteFillAmount ?? 0);
|
|
2938
|
+
if (fillAmount <= 0n) {
|
|
2939
|
+
throw new Error("fillAmount must be greater than 0");
|
|
2940
|
+
}
|
|
2941
|
+
if (noteFillAmount < 0n) {
|
|
2942
|
+
throw new Error("noteFillAmount must not be negative");
|
|
2943
|
+
}
|
|
2944
|
+
setIsLoading(true);
|
|
2945
|
+
setStage("executing");
|
|
2946
|
+
setError(null);
|
|
2947
|
+
try {
|
|
2948
|
+
const accountIdObj = parseAccountId(options.accountId);
|
|
2949
|
+
setStage("proving");
|
|
2950
|
+
const txResult = await runExclusiveSafe(async () => {
|
|
2951
|
+
const note = await resolveNoteInput(options.note, client);
|
|
2952
|
+
const txRequest = await client.newPswapConsumeTransactionRequest(
|
|
2953
|
+
note,
|
|
2954
|
+
accountIdObj,
|
|
2955
|
+
fillAmount,
|
|
2956
|
+
noteFillAmount
|
|
2957
|
+
);
|
|
2958
|
+
const txId = prover ? await client.submitNewTransactionWithProver(
|
|
2959
|
+
accountIdObj,
|
|
2960
|
+
txRequest,
|
|
2961
|
+
prover
|
|
2962
|
+
) : await client.submitNewTransaction(accountIdObj, txRequest);
|
|
2963
|
+
return { transactionId: txId.toHex() };
|
|
2964
|
+
});
|
|
2965
|
+
setStage("complete");
|
|
2966
|
+
setResult(txResult);
|
|
2967
|
+
await sync();
|
|
2968
|
+
return txResult;
|
|
2969
|
+
} catch (err) {
|
|
2970
|
+
const error2 = err instanceof Error ? err : new Error(String(err));
|
|
2971
|
+
setError(error2);
|
|
2972
|
+
setStage("idle");
|
|
2973
|
+
throw error2;
|
|
2974
|
+
} finally {
|
|
2975
|
+
setIsLoading(false);
|
|
2976
|
+
}
|
|
2977
|
+
},
|
|
2978
|
+
[client, isReady, prover, runExclusive, sync]
|
|
2979
|
+
);
|
|
2980
|
+
const reset = useCallback20(() => {
|
|
2981
|
+
setResult(null);
|
|
2982
|
+
setIsLoading(false);
|
|
2983
|
+
setStage("idle");
|
|
2984
|
+
setError(null);
|
|
2985
|
+
}, []);
|
|
2986
|
+
return {
|
|
2987
|
+
pswapConsume,
|
|
2988
|
+
result,
|
|
2989
|
+
isLoading,
|
|
2990
|
+
stage,
|
|
2991
|
+
error,
|
|
2992
|
+
reset
|
|
2993
|
+
};
|
|
2994
|
+
}
|
|
2995
|
+
|
|
2996
|
+
// src/hooks/usePswapCancel.ts
|
|
2997
|
+
import { useCallback as useCallback21, useState as useState17 } from "react";
|
|
2998
|
+
function usePswapCancel() {
|
|
2999
|
+
const { client, isReady, sync, runExclusive, prover } = useMiden();
|
|
3000
|
+
const runExclusiveSafe = runExclusive ?? runExclusiveDirect;
|
|
3001
|
+
const [result, setResult] = useState17(null);
|
|
3002
|
+
const [isLoading, setIsLoading] = useState17(false);
|
|
3003
|
+
const [stage, setStage] = useState17("idle");
|
|
3004
|
+
const [error, setError] = useState17(null);
|
|
3005
|
+
const pswapCancel = useCallback21(
|
|
3006
|
+
async (options) => {
|
|
3007
|
+
if (!client || !isReady) {
|
|
3008
|
+
throw new Error("Miden client is not ready");
|
|
3009
|
+
}
|
|
3010
|
+
setIsLoading(true);
|
|
3011
|
+
setStage("executing");
|
|
3012
|
+
setError(null);
|
|
3013
|
+
try {
|
|
3014
|
+
const accountIdObj = parseAccountId(options.accountId);
|
|
3015
|
+
setStage("proving");
|
|
3016
|
+
const txResult = await runExclusiveSafe(async () => {
|
|
3017
|
+
const note = await resolveNoteInput(options.note, client);
|
|
3018
|
+
const txRequest = await client.newPswapCancelTransactionRequest(
|
|
3019
|
+
note,
|
|
3020
|
+
accountIdObj
|
|
3021
|
+
);
|
|
3022
|
+
const txId = prover ? await client.submitNewTransactionWithProver(
|
|
3023
|
+
accountIdObj,
|
|
3024
|
+
txRequest,
|
|
3025
|
+
prover
|
|
3026
|
+
) : await client.submitNewTransaction(accountIdObj, txRequest);
|
|
3027
|
+
return { transactionId: txId.toHex() };
|
|
3028
|
+
});
|
|
3029
|
+
setStage("complete");
|
|
3030
|
+
setResult(txResult);
|
|
3031
|
+
await sync();
|
|
3032
|
+
return txResult;
|
|
3033
|
+
} catch (err) {
|
|
3034
|
+
const error2 = err instanceof Error ? err : new Error(String(err));
|
|
3035
|
+
setError(error2);
|
|
3036
|
+
setStage("idle");
|
|
3037
|
+
throw error2;
|
|
3038
|
+
} finally {
|
|
3039
|
+
setIsLoading(false);
|
|
3040
|
+
}
|
|
3041
|
+
},
|
|
3042
|
+
[client, isReady, prover, runExclusive, sync]
|
|
3043
|
+
);
|
|
3044
|
+
const reset = useCallback21(() => {
|
|
3045
|
+
setResult(null);
|
|
3046
|
+
setIsLoading(false);
|
|
3047
|
+
setStage("idle");
|
|
3048
|
+
setError(null);
|
|
3049
|
+
}, []);
|
|
3050
|
+
return {
|
|
3051
|
+
pswapCancel,
|
|
3052
|
+
result,
|
|
3053
|
+
isLoading,
|
|
3054
|
+
stage,
|
|
3055
|
+
error,
|
|
3056
|
+
reset
|
|
3057
|
+
};
|
|
3058
|
+
}
|
|
3059
|
+
|
|
2828
3060
|
// src/hooks/useTransaction.ts
|
|
2829
|
-
import { useCallback as
|
|
3061
|
+
import { useCallback as useCallback22, useRef as useRef6, useState as useState18 } from "react";
|
|
2830
3062
|
|
|
2831
3063
|
// src/utils/transactions.ts
|
|
2832
3064
|
import { NoteType as NoteType4, TransactionFilter as TransactionFilter4 } from "@miden-sdk/miden-sdk";
|
|
@@ -2873,11 +3105,11 @@ function useTransaction() {
|
|
|
2873
3105
|
const { client, isReady, sync, runExclusive } = useMiden();
|
|
2874
3106
|
const runExclusiveSafe = runExclusive ?? runExclusiveDirect;
|
|
2875
3107
|
const isBusyRef = useRef6(false);
|
|
2876
|
-
const [result, setResult] =
|
|
2877
|
-
const [isLoading, setIsLoading] =
|
|
2878
|
-
const [stage, setStage] =
|
|
2879
|
-
const [error, setError] =
|
|
2880
|
-
const execute =
|
|
3108
|
+
const [result, setResult] = useState18(null);
|
|
3109
|
+
const [isLoading, setIsLoading] = useState18(false);
|
|
3110
|
+
const [stage, setStage] = useState18("idle");
|
|
3111
|
+
const [error, setError] = useState18(null);
|
|
3112
|
+
const execute = useCallback22(
|
|
2881
3113
|
async (options) => {
|
|
2882
3114
|
if (!client || !isReady) {
|
|
2883
3115
|
throw new Error("Miden client is not ready");
|
|
@@ -2927,7 +3159,7 @@ function useTransaction() {
|
|
|
2927
3159
|
);
|
|
2928
3160
|
}
|
|
2929
3161
|
}
|
|
2930
|
-
const txSummary = { transactionId: txId.
|
|
3162
|
+
const txSummary = { transactionId: txId.toHex() };
|
|
2931
3163
|
setStage("complete");
|
|
2932
3164
|
setResult(txSummary);
|
|
2933
3165
|
await sync();
|
|
@@ -2944,7 +3176,7 @@ function useTransaction() {
|
|
|
2944
3176
|
},
|
|
2945
3177
|
[client, isReady, runExclusive, sync]
|
|
2946
3178
|
);
|
|
2947
|
-
const reset =
|
|
3179
|
+
const reset = useCallback22(() => {
|
|
2948
3180
|
setResult(null);
|
|
2949
3181
|
setIsLoading(false);
|
|
2950
3182
|
setStage("idle");
|
|
@@ -2967,7 +3199,7 @@ async function resolveRequest(request, client) {
|
|
|
2967
3199
|
}
|
|
2968
3200
|
|
|
2969
3201
|
// src/hooks/useExecuteProgram.ts
|
|
2970
|
-
import { useCallback as
|
|
3202
|
+
import { useCallback as useCallback23, useRef as useRef7, useState as useState19 } from "react";
|
|
2971
3203
|
import {
|
|
2972
3204
|
AdviceInputs,
|
|
2973
3205
|
ForeignAccount,
|
|
@@ -2981,10 +3213,10 @@ function useExecuteProgram() {
|
|
|
2981
3213
|
const { client, isReady, sync, runExclusive } = useMiden();
|
|
2982
3214
|
const runExclusiveSafe = runExclusive ?? runExclusiveDirect;
|
|
2983
3215
|
const isBusyRef = useRef7(false);
|
|
2984
|
-
const [result, setResult] =
|
|
2985
|
-
const [isLoading, setIsLoading] =
|
|
2986
|
-
const [error, setError] =
|
|
2987
|
-
const execute =
|
|
3216
|
+
const [result, setResult] = useState19(null);
|
|
3217
|
+
const [isLoading, setIsLoading] = useState19(false);
|
|
3218
|
+
const [error, setError] = useState19(null);
|
|
3219
|
+
const execute = useCallback23(
|
|
2988
3220
|
async (options) => {
|
|
2989
3221
|
if (!client || !isReady) {
|
|
2990
3222
|
throw new Error("Miden client is not ready");
|
|
@@ -3043,7 +3275,7 @@ function useExecuteProgram() {
|
|
|
3043
3275
|
},
|
|
3044
3276
|
[client, isReady, runExclusive, sync]
|
|
3045
3277
|
);
|
|
3046
|
-
const reset =
|
|
3278
|
+
const reset = useCallback23(() => {
|
|
3047
3279
|
setResult(null);
|
|
3048
3280
|
setIsLoading(false);
|
|
3049
3281
|
setError(null);
|
|
@@ -3058,7 +3290,7 @@ function useExecuteProgram() {
|
|
|
3058
3290
|
}
|
|
3059
3291
|
|
|
3060
3292
|
// src/hooks/useCompile.ts
|
|
3061
|
-
import { useCallback as
|
|
3293
|
+
import { useCallback as useCallback24, useMemo as useMemo8 } from "react";
|
|
3062
3294
|
import { CompilerResource, getWasmOrThrow } from "@miden-sdk/miden-sdk";
|
|
3063
3295
|
function useCompile() {
|
|
3064
3296
|
const { client, isReady } = useMiden();
|
|
@@ -3066,21 +3298,21 @@ function useCompile() {
|
|
|
3066
3298
|
() => client && isReady ? new CompilerResource(client, getWasmOrThrow) : null,
|
|
3067
3299
|
[client, isReady]
|
|
3068
3300
|
);
|
|
3069
|
-
const requireResource =
|
|
3301
|
+
const requireResource = useCallback24(() => {
|
|
3070
3302
|
if (!resource) {
|
|
3071
3303
|
throw new Error("Miden client is not ready");
|
|
3072
3304
|
}
|
|
3073
3305
|
return resource;
|
|
3074
3306
|
}, [resource]);
|
|
3075
|
-
const component =
|
|
3307
|
+
const component = useCallback24(
|
|
3076
3308
|
async (options) => requireResource().component(options),
|
|
3077
3309
|
[requireResource]
|
|
3078
3310
|
);
|
|
3079
|
-
const txScript =
|
|
3311
|
+
const txScript = useCallback24(
|
|
3080
3312
|
async (options) => requireResource().txScript(options),
|
|
3081
3313
|
[requireResource]
|
|
3082
3314
|
);
|
|
3083
|
-
const noteScript =
|
|
3315
|
+
const noteScript = useCallback24(
|
|
3084
3316
|
async (options) => requireResource().noteScript(options),
|
|
3085
3317
|
[requireResource]
|
|
3086
3318
|
);
|
|
@@ -3088,14 +3320,14 @@ function useCompile() {
|
|
|
3088
3320
|
}
|
|
3089
3321
|
|
|
3090
3322
|
// src/hooks/useSessionAccount.ts
|
|
3091
|
-
import { useCallback as
|
|
3323
|
+
import { useCallback as useCallback25, useEffect as useEffect9, useRef as useRef8, useState as useState20 } from "react";
|
|
3092
3324
|
import { AccountStorageMode as AccountStorageMode3 } from "@miden-sdk/miden-sdk";
|
|
3093
3325
|
function useSessionAccount(options) {
|
|
3094
3326
|
const { client, isReady, sync } = useMiden();
|
|
3095
3327
|
const setAccounts = useMidenStore((state) => state.setAccounts);
|
|
3096
|
-
const [sessionAccountId, setSessionAccountId] =
|
|
3097
|
-
const [step, setStep] =
|
|
3098
|
-
const [error, setError] =
|
|
3328
|
+
const [sessionAccountId, setSessionAccountId] = useState20(null);
|
|
3329
|
+
const [step, setStep] = useState20("idle");
|
|
3330
|
+
const [error, setError] = useState20(null);
|
|
3099
3331
|
const cancelledRef = useRef8(false);
|
|
3100
3332
|
const isBusyRef = useRef8(false);
|
|
3101
3333
|
const storagePrefix = options.storagePrefix ?? "miden-session";
|
|
@@ -3123,7 +3355,7 @@ function useSessionAccount(options) {
|
|
|
3123
3355
|
localStorage.removeItem(`${storagePrefix}:ready`);
|
|
3124
3356
|
}
|
|
3125
3357
|
}, [storagePrefix]);
|
|
3126
|
-
const initialize =
|
|
3358
|
+
const initialize = useCallback25(async () => {
|
|
3127
3359
|
if (!client || !isReady) {
|
|
3128
3360
|
throw new Error("Miden client is not ready");
|
|
3129
3361
|
}
|
|
@@ -3192,7 +3424,7 @@ function useSessionAccount(options) {
|
|
|
3192
3424
|
maxWaitMs,
|
|
3193
3425
|
setAccounts
|
|
3194
3426
|
]);
|
|
3195
|
-
const reset =
|
|
3427
|
+
const reset = useCallback25(() => {
|
|
3196
3428
|
cancelledRef.current = true;
|
|
3197
3429
|
isBusyRef.current = false;
|
|
3198
3430
|
setSessionAccountId(null);
|
|
@@ -3241,13 +3473,13 @@ async function waitAndConsume(client, walletId, pollIntervalMs, maxWaitMs, cance
|
|
|
3241
3473
|
}
|
|
3242
3474
|
|
|
3243
3475
|
// src/hooks/useExportStore.ts
|
|
3244
|
-
import { useCallback as
|
|
3476
|
+
import { useCallback as useCallback26, useState as useState21 } from "react";
|
|
3245
3477
|
import { exportStore as sdkExportStore } from "@miden-sdk/miden-sdk";
|
|
3246
3478
|
function useExportStore() {
|
|
3247
3479
|
const { client, isReady, runExclusive } = useMiden();
|
|
3248
|
-
const [isExporting, setIsExporting] =
|
|
3249
|
-
const [error, setError] =
|
|
3250
|
-
const exportStore =
|
|
3480
|
+
const [isExporting, setIsExporting] = useState21(false);
|
|
3481
|
+
const [error, setError] = useState21(null);
|
|
3482
|
+
const exportStore = useCallback26(async () => {
|
|
3251
3483
|
if (!client || !isReady) {
|
|
3252
3484
|
throw new Error("Miden client is not ready");
|
|
3253
3485
|
}
|
|
@@ -3265,7 +3497,7 @@ function useExportStore() {
|
|
|
3265
3497
|
setIsExporting(false);
|
|
3266
3498
|
}
|
|
3267
3499
|
}, [client, isReady, runExclusive]);
|
|
3268
|
-
const reset =
|
|
3500
|
+
const reset = useCallback26(() => {
|
|
3269
3501
|
setIsExporting(false);
|
|
3270
3502
|
setError(null);
|
|
3271
3503
|
}, []);
|
|
@@ -3278,13 +3510,13 @@ function useExportStore() {
|
|
|
3278
3510
|
}
|
|
3279
3511
|
|
|
3280
3512
|
// src/hooks/useImportStore.ts
|
|
3281
|
-
import { useCallback as
|
|
3513
|
+
import { useCallback as useCallback27, useState as useState22 } from "react";
|
|
3282
3514
|
import { importStore as sdkImportStore } from "@miden-sdk/miden-sdk";
|
|
3283
3515
|
function useImportStore() {
|
|
3284
3516
|
const { client, isReady, runExclusive, sync } = useMiden();
|
|
3285
|
-
const [isImporting, setIsImporting] =
|
|
3286
|
-
const [error, setError] =
|
|
3287
|
-
const importStore =
|
|
3517
|
+
const [isImporting, setIsImporting] = useState22(false);
|
|
3518
|
+
const [error, setError] = useState22(null);
|
|
3519
|
+
const importStore = useCallback27(
|
|
3288
3520
|
async (storeDump, storeName, options) => {
|
|
3289
3521
|
if (!client || !isReady) {
|
|
3290
3522
|
throw new Error("Miden client is not ready");
|
|
@@ -3306,7 +3538,7 @@ function useImportStore() {
|
|
|
3306
3538
|
},
|
|
3307
3539
|
[client, isReady, runExclusive, sync]
|
|
3308
3540
|
);
|
|
3309
|
-
const reset =
|
|
3541
|
+
const reset = useCallback27(() => {
|
|
3310
3542
|
setIsImporting(false);
|
|
3311
3543
|
setError(null);
|
|
3312
3544
|
}, []);
|
|
@@ -3319,13 +3551,13 @@ function useImportStore() {
|
|
|
3319
3551
|
}
|
|
3320
3552
|
|
|
3321
3553
|
// src/hooks/useImportNote.ts
|
|
3322
|
-
import { useCallback as
|
|
3554
|
+
import { useCallback as useCallback28, useState as useState23 } from "react";
|
|
3323
3555
|
import { NoteFile } from "@miden-sdk/miden-sdk";
|
|
3324
3556
|
function useImportNote() {
|
|
3325
3557
|
const { client, isReady, runExclusive, sync } = useMiden();
|
|
3326
|
-
const [isImporting, setIsImporting] =
|
|
3327
|
-
const [error, setError] =
|
|
3328
|
-
const importNote =
|
|
3558
|
+
const [isImporting, setIsImporting] = useState23(false);
|
|
3559
|
+
const [error, setError] = useState23(null);
|
|
3560
|
+
const importNote = useCallback28(
|
|
3329
3561
|
async (noteBytes) => {
|
|
3330
3562
|
if (!client || !isReady) {
|
|
3331
3563
|
throw new Error("Miden client is not ready");
|
|
@@ -3349,7 +3581,7 @@ function useImportNote() {
|
|
|
3349
3581
|
},
|
|
3350
3582
|
[client, isReady, runExclusive, sync]
|
|
3351
3583
|
);
|
|
3352
|
-
const reset =
|
|
3584
|
+
const reset = useCallback28(() => {
|
|
3353
3585
|
setIsImporting(false);
|
|
3354
3586
|
setError(null);
|
|
3355
3587
|
}, []);
|
|
@@ -3362,13 +3594,13 @@ function useImportNote() {
|
|
|
3362
3594
|
}
|
|
3363
3595
|
|
|
3364
3596
|
// src/hooks/useExportNote.ts
|
|
3365
|
-
import { useCallback as
|
|
3597
|
+
import { useCallback as useCallback29, useState as useState24 } from "react";
|
|
3366
3598
|
import { NoteExportFormat } from "@miden-sdk/miden-sdk";
|
|
3367
3599
|
function useExportNote() {
|
|
3368
3600
|
const { client, isReady, runExclusive } = useMiden();
|
|
3369
|
-
const [isExporting, setIsExporting] =
|
|
3370
|
-
const [error, setError] =
|
|
3371
|
-
const exportNote =
|
|
3601
|
+
const [isExporting, setIsExporting] = useState24(false);
|
|
3602
|
+
const [error, setError] = useState24(null);
|
|
3603
|
+
const exportNote = useCallback29(
|
|
3372
3604
|
async (noteId) => {
|
|
3373
3605
|
if (!client || !isReady) {
|
|
3374
3606
|
throw new Error("Miden client is not ready");
|
|
@@ -3390,7 +3622,7 @@ function useExportNote() {
|
|
|
3390
3622
|
},
|
|
3391
3623
|
[client, isReady, runExclusive]
|
|
3392
3624
|
);
|
|
3393
|
-
const reset =
|
|
3625
|
+
const reset = useCallback29(() => {
|
|
3394
3626
|
setIsExporting(false);
|
|
3395
3627
|
setError(null);
|
|
3396
3628
|
}, []);
|
|
@@ -3403,12 +3635,12 @@ function useExportNote() {
|
|
|
3403
3635
|
}
|
|
3404
3636
|
|
|
3405
3637
|
// src/hooks/useSyncControl.ts
|
|
3406
|
-
import { useCallback as
|
|
3638
|
+
import { useCallback as useCallback30 } from "react";
|
|
3407
3639
|
function useSyncControl() {
|
|
3408
3640
|
const isPaused = useMidenStore((state) => state.syncPaused);
|
|
3409
3641
|
const setSyncPaused = useMidenStore((state) => state.setSyncPaused);
|
|
3410
|
-
const pauseSync =
|
|
3411
|
-
const resumeSync =
|
|
3642
|
+
const pauseSync = useCallback30(() => setSyncPaused(true), [setSyncPaused]);
|
|
3643
|
+
const resumeSync = useCallback30(() => setSyncPaused(false), [setSyncPaused]);
|
|
3412
3644
|
return {
|
|
3413
3645
|
pauseSync,
|
|
3414
3646
|
resumeSync,
|
|
@@ -3610,6 +3842,9 @@ export {
|
|
|
3610
3842
|
useMultiSigner,
|
|
3611
3843
|
useNoteStream,
|
|
3612
3844
|
useNotes,
|
|
3845
|
+
usePswapCancel,
|
|
3846
|
+
usePswapConsume,
|
|
3847
|
+
usePswapCreate,
|
|
3613
3848
|
useSend,
|
|
3614
3849
|
useSessionAccount,
|
|
3615
3850
|
useSigner,
|