@miden-sdk/react 0.14.2 → 0.14.4
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/README.md +58 -0
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +146 -141
- package/dist/index.mjs +17 -12
- package/dist/lazy.d.mts +1497 -0
- package/dist/lazy.d.ts +1497 -0
- package/dist/lazy.js +3672 -0
- package/dist/lazy.mjs +3637 -0
- package/package.json +9 -4
package/dist/index.js
CHANGED
|
@@ -28,9 +28,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
29
|
|
|
30
30
|
// src/index.ts
|
|
31
|
-
var
|
|
32
|
-
__export(
|
|
33
|
-
AuthScheme: () =>
|
|
31
|
+
var src_exports = {};
|
|
32
|
+
__export(src_exports, {
|
|
33
|
+
AuthScheme: () => import_lazy4.AuthScheme,
|
|
34
34
|
DEFAULTS: () => DEFAULTS,
|
|
35
35
|
MidenError: () => MidenError,
|
|
36
36
|
MidenProvider: () => MidenProvider,
|
|
@@ -85,13 +85,13 @@ __export(index_exports, {
|
|
|
85
85
|
waitForWalletDetection: () => waitForWalletDetection,
|
|
86
86
|
wrapWasmError: () => wrapWasmError
|
|
87
87
|
});
|
|
88
|
-
module.exports = __toCommonJS(
|
|
88
|
+
module.exports = __toCommonJS(src_exports);
|
|
89
89
|
|
|
90
90
|
// src/types/augmentations.ts
|
|
91
|
-
var
|
|
91
|
+
var import_lazy = require("@miden-sdk/miden-sdk");
|
|
92
92
|
|
|
93
93
|
// src/utils/accountBech32.ts
|
|
94
|
-
var
|
|
94
|
+
var import_lazy3 = require("@miden-sdk/miden-sdk");
|
|
95
95
|
|
|
96
96
|
// src/store/MidenStore.ts
|
|
97
97
|
var import_zustand = require("zustand");
|
|
@@ -238,19 +238,19 @@ var useAssetMetadataStore = () => useMidenStore((state) => state.assetMetadata);
|
|
|
238
238
|
var useNoteFirstSeenStore = () => useMidenStore((state) => state.noteFirstSeen);
|
|
239
239
|
|
|
240
240
|
// src/utils/accountParsing.ts
|
|
241
|
-
var
|
|
241
|
+
var import_lazy2 = require("@miden-sdk/miden-sdk");
|
|
242
242
|
var normalizeAccountIdInput = (value) => value.trim().replace(/^miden:/i, "");
|
|
243
243
|
var isBech32Input = (value) => value.startsWith("m") || value.startsWith("M");
|
|
244
244
|
var normalizeHexInput = (value) => value.startsWith("0x") || value.startsWith("0X") ? value : `0x${value}`;
|
|
245
245
|
var parseAccountIdFromString = (value) => {
|
|
246
246
|
if (isBech32Input(value)) {
|
|
247
247
|
try {
|
|
248
|
-
return
|
|
248
|
+
return import_lazy2.Address.fromBech32(value).accountId();
|
|
249
249
|
} catch {
|
|
250
|
-
return
|
|
250
|
+
return import_lazy2.AccountId.fromBech32(value);
|
|
251
251
|
}
|
|
252
252
|
}
|
|
253
|
-
return
|
|
253
|
+
return import_lazy2.AccountId.fromHex(normalizeHexInput(value));
|
|
254
254
|
};
|
|
255
255
|
var parseAccountId = (value) => {
|
|
256
256
|
if (typeof value === "string") {
|
|
@@ -277,49 +277,49 @@ function isFaucetId(accountId) {
|
|
|
277
277
|
var parseAddress = (value, accountId) => {
|
|
278
278
|
if (typeof value !== "string") {
|
|
279
279
|
const resolvedId = accountId ?? parseAccountId(value);
|
|
280
|
-
return
|
|
280
|
+
return import_lazy2.Address.fromAccountId(resolvedId, "BasicWallet");
|
|
281
281
|
}
|
|
282
282
|
const normalized = normalizeAccountIdInput(value);
|
|
283
283
|
if (isBech32Input(normalized)) {
|
|
284
284
|
try {
|
|
285
|
-
return
|
|
285
|
+
return import_lazy2.Address.fromBech32(normalized);
|
|
286
286
|
} catch {
|
|
287
|
-
const resolvedAccountId2 = accountId ??
|
|
288
|
-
return
|
|
287
|
+
const resolvedAccountId2 = accountId ?? import_lazy2.AccountId.fromBech32(normalized);
|
|
288
|
+
return import_lazy2.Address.fromAccountId(resolvedAccountId2, "BasicWallet");
|
|
289
289
|
}
|
|
290
290
|
}
|
|
291
|
-
const resolvedAccountId = accountId ??
|
|
292
|
-
return
|
|
291
|
+
const resolvedAccountId = accountId ?? import_lazy2.AccountId.fromHex(normalizeHexInput(normalized));
|
|
292
|
+
return import_lazy2.Address.fromAccountId(resolvedAccountId, "BasicWallet");
|
|
293
293
|
};
|
|
294
294
|
|
|
295
295
|
// src/utils/accountBech32.ts
|
|
296
296
|
var inferNetworkId = () => {
|
|
297
297
|
const { rpcUrl } = useMidenStore.getState().config;
|
|
298
298
|
if (!rpcUrl) {
|
|
299
|
-
return
|
|
299
|
+
return import_lazy3.NetworkId.testnet();
|
|
300
300
|
}
|
|
301
301
|
const url = rpcUrl.toLowerCase();
|
|
302
302
|
if (url.includes("devnet") || url.includes("mdev")) {
|
|
303
|
-
return
|
|
303
|
+
return import_lazy3.NetworkId.devnet();
|
|
304
304
|
}
|
|
305
305
|
if (url.includes("mainnet")) {
|
|
306
|
-
return
|
|
306
|
+
return import_lazy3.NetworkId.mainnet();
|
|
307
307
|
}
|
|
308
308
|
if (url.includes("testnet") || url.includes("mtst")) {
|
|
309
|
-
return
|
|
309
|
+
return import_lazy3.NetworkId.testnet();
|
|
310
310
|
}
|
|
311
|
-
return
|
|
311
|
+
return import_lazy3.NetworkId.testnet();
|
|
312
312
|
};
|
|
313
313
|
var toBech32FromAccountId = (id) => {
|
|
314
314
|
try {
|
|
315
|
-
const address =
|
|
315
|
+
const address = import_lazy3.Address.fromAccountId(id, "BasicWallet");
|
|
316
316
|
return address.toBech32(inferNetworkId());
|
|
317
317
|
} catch {
|
|
318
318
|
}
|
|
319
319
|
try {
|
|
320
320
|
const maybeBech32 = id.toBech32?.(
|
|
321
321
|
inferNetworkId(),
|
|
322
|
-
|
|
322
|
+
import_lazy3.AccountInterface.BasicWallet
|
|
323
323
|
);
|
|
324
324
|
if (typeof maybeBech32 === "string") {
|
|
325
325
|
return maybeBech32;
|
|
@@ -349,7 +349,7 @@ var defineBech32 = (target) => {
|
|
|
349
349
|
}
|
|
350
350
|
};
|
|
351
351
|
var installAccountBech32 = () => {
|
|
352
|
-
const proto =
|
|
352
|
+
const proto = import_lazy3.Account.prototype;
|
|
353
353
|
if (proto.bech32id) {
|
|
354
354
|
return;
|
|
355
355
|
}
|
|
@@ -382,17 +382,17 @@ var toBech32AccountId = (accountId) => {
|
|
|
382
382
|
|
|
383
383
|
// src/context/MidenProvider.tsx
|
|
384
384
|
var import_react2 = require("react");
|
|
385
|
-
var
|
|
385
|
+
var import_lazy6 = require("@miden-sdk/miden-sdk");
|
|
386
386
|
|
|
387
387
|
// src/types/index.ts
|
|
388
|
-
var
|
|
388
|
+
var import_lazy4 = require("@miden-sdk/miden-sdk");
|
|
389
389
|
var DEFAULTS = {
|
|
390
390
|
RPC_URL: void 0,
|
|
391
391
|
// Will use SDK's testnet default
|
|
392
392
|
AUTO_SYNC_INTERVAL: 15e3,
|
|
393
393
|
STORAGE_MODE: "private",
|
|
394
394
|
WALLET_MUTABLE: true,
|
|
395
|
-
AUTH_SCHEME:
|
|
395
|
+
AUTH_SCHEME: import_lazy4.AuthScheme.AuthRpoFalcon512,
|
|
396
396
|
NOTE_TYPE: "private",
|
|
397
397
|
FAUCET_DECIMALS: 8
|
|
398
398
|
};
|
|
@@ -436,7 +436,7 @@ function resolveRpcUrl(rpcUrl) {
|
|
|
436
436
|
}
|
|
437
437
|
|
|
438
438
|
// src/utils/prover.ts
|
|
439
|
-
var
|
|
439
|
+
var import_lazy5 = require("@miden-sdk/miden-sdk");
|
|
440
440
|
var DEFAULT_PROVER_URLS = {
|
|
441
441
|
devnet: "https://tx-prover.devnet.miden.io",
|
|
442
442
|
testnet: "https://tx-prover.testnet.miden.io"
|
|
@@ -475,19 +475,19 @@ function resolveProverTarget(target, config) {
|
|
|
475
475
|
if (typeof target === "string") {
|
|
476
476
|
const normalized = target.trim().toLowerCase();
|
|
477
477
|
if (normalized === "local" || normalized === "localhost") {
|
|
478
|
-
return
|
|
478
|
+
return import_lazy5.TransactionProver.newLocalProver();
|
|
479
479
|
}
|
|
480
480
|
if (normalized === "devnet" || normalized === "testnet") {
|
|
481
481
|
const url = config.proverUrls?.[normalized] ?? DEFAULT_PROVER_URLS[normalized] ?? null;
|
|
482
482
|
if (!url) {
|
|
483
483
|
throw new Error(`Missing ${normalized} prover URL`);
|
|
484
484
|
}
|
|
485
|
-
return
|
|
485
|
+
return import_lazy5.TransactionProver.newRemoteProver(
|
|
486
486
|
url,
|
|
487
487
|
normalizeTimeout(config.proverTimeoutMs)
|
|
488
488
|
);
|
|
489
489
|
}
|
|
490
|
-
return
|
|
490
|
+
return import_lazy5.TransactionProver.newRemoteProver(
|
|
491
491
|
target,
|
|
492
492
|
normalizeTimeout(config.proverTimeoutMs)
|
|
493
493
|
);
|
|
@@ -499,7 +499,7 @@ function createRemoteProver(config, fallbackTimeout) {
|
|
|
499
499
|
if (!url) {
|
|
500
500
|
throw new Error("Remote prover requires a URL");
|
|
501
501
|
}
|
|
502
|
-
return
|
|
502
|
+
return import_lazy5.TransactionProver.newRemoteProver(
|
|
503
503
|
url,
|
|
504
504
|
normalizeTimeout(timeoutMs ?? fallbackTimeout)
|
|
505
505
|
);
|
|
@@ -629,15 +629,20 @@ function MidenProvider({
|
|
|
629
629
|
}),
|
|
630
630
|
[config]
|
|
631
631
|
);
|
|
632
|
-
const defaultProver = (0, import_react2.
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
632
|
+
const [defaultProver, setDefaultProver] = (0, import_react2.useState)(null);
|
|
633
|
+
(0, import_react2.useEffect)(() => {
|
|
634
|
+
if (!isReady) {
|
|
635
|
+
setDefaultProver(null);
|
|
636
|
+
return;
|
|
637
|
+
}
|
|
638
|
+
setDefaultProver(resolveTransactionProver(resolvedConfig));
|
|
639
|
+
}, [
|
|
640
|
+
isReady,
|
|
641
|
+
resolvedConfig.prover,
|
|
642
|
+
resolvedConfig.proverTimeoutMs,
|
|
643
|
+
resolvedConfig.proverUrls?.devnet,
|
|
644
|
+
resolvedConfig.proverUrls?.testnet
|
|
645
|
+
]);
|
|
641
646
|
const runExclusive = (0, import_react2.useCallback)(
|
|
642
647
|
async (fn) => clientLockRef.current.runExclusive(fn),
|
|
643
648
|
[]
|
|
@@ -716,7 +721,7 @@ function MidenProvider({
|
|
|
716
721
|
if (signerContext && signerIsConnected === true) {
|
|
717
722
|
const storeName = `MidenClientDB_${signerContext.storeName}`;
|
|
718
723
|
signCbRef.current = signerContext.signCb;
|
|
719
|
-
webClient = await
|
|
724
|
+
webClient = await import_lazy6.WasmWebClient.createClientWithExternalKeystore(
|
|
720
725
|
resolvedConfig.rpcUrl,
|
|
721
726
|
resolvedConfig.noteTransportUrl,
|
|
722
727
|
resolvedConfig.seed,
|
|
@@ -736,7 +741,7 @@ function MidenProvider({
|
|
|
736
741
|
currentStoreNameRef.current = signerContext.storeName;
|
|
737
742
|
} else {
|
|
738
743
|
const seed = resolvedConfig.seed;
|
|
739
|
-
webClient = await
|
|
744
|
+
webClient = await import_lazy6.WasmWebClient.createClient(
|
|
740
745
|
resolvedConfig.rpcUrl,
|
|
741
746
|
resolvedConfig.noteTransportUrl,
|
|
742
747
|
seed
|
|
@@ -1080,7 +1085,7 @@ var import_react6 = require("react");
|
|
|
1080
1085
|
|
|
1081
1086
|
// src/hooks/useAssetMetadata.ts
|
|
1082
1087
|
var import_react5 = require("react");
|
|
1083
|
-
var
|
|
1088
|
+
var import_lazy7 = require("@miden-sdk/miden-sdk");
|
|
1084
1089
|
var inflight = /* @__PURE__ */ new Map();
|
|
1085
1090
|
var rpcClients = /* @__PURE__ */ new Map();
|
|
1086
1091
|
var getRpcClient = (rpcUrl) => {
|
|
@@ -1088,8 +1093,8 @@ var getRpcClient = (rpcUrl) => {
|
|
|
1088
1093
|
const existing = rpcClients.get(key);
|
|
1089
1094
|
if (existing) return existing;
|
|
1090
1095
|
try {
|
|
1091
|
-
const endpoint = rpcUrl ? new
|
|
1092
|
-
const client = new
|
|
1096
|
+
const endpoint = rpcUrl ? new import_lazy7.Endpoint(rpcUrl) : import_lazy7.Endpoint.testnet();
|
|
1097
|
+
const client = new import_lazy7.RpcClient(endpoint);
|
|
1093
1098
|
rpcClients.set(key, client);
|
|
1094
1099
|
return client;
|
|
1095
1100
|
} catch {
|
|
@@ -1103,7 +1108,7 @@ var fetchAssetMetadata = async (rpcClient, assetId) => {
|
|
|
1103
1108
|
const fetched = await rpcClient.getAccountDetails(accountId);
|
|
1104
1109
|
const account = fetched.account?.();
|
|
1105
1110
|
if (!account) return null;
|
|
1106
|
-
const faucet =
|
|
1111
|
+
const faucet = import_lazy7.BasicFungibleFaucetComponent.fromAccount(account);
|
|
1107
1112
|
const symbol = faucet.symbol().toString();
|
|
1108
1113
|
const decimals = faucet.decimals();
|
|
1109
1114
|
return { assetId, symbol, decimals };
|
|
@@ -1229,7 +1234,7 @@ function useAccount(accountId) {
|
|
|
1229
1234
|
|
|
1230
1235
|
// src/hooks/useNotes.ts
|
|
1231
1236
|
var import_react7 = require("react");
|
|
1232
|
-
var
|
|
1237
|
+
var import_lazy9 = require("@miden-sdk/miden-sdk");
|
|
1233
1238
|
|
|
1234
1239
|
// src/utils/amounts.ts
|
|
1235
1240
|
var formatAssetAmount = (amount, decimals) => {
|
|
@@ -1334,30 +1339,30 @@ function accountIdsEqual(a, b) {
|
|
|
1334
1339
|
}
|
|
1335
1340
|
|
|
1336
1341
|
// src/utils/noteFilters.ts
|
|
1337
|
-
var
|
|
1342
|
+
var import_lazy8 = require("@miden-sdk/miden-sdk");
|
|
1338
1343
|
function getNoteFilterType(status) {
|
|
1339
1344
|
switch (status) {
|
|
1340
1345
|
case "consumed":
|
|
1341
|
-
return
|
|
1346
|
+
return import_lazy8.NoteFilterTypes.Consumed;
|
|
1342
1347
|
case "committed":
|
|
1343
|
-
return
|
|
1348
|
+
return import_lazy8.NoteFilterTypes.Committed;
|
|
1344
1349
|
case "expected":
|
|
1345
|
-
return
|
|
1350
|
+
return import_lazy8.NoteFilterTypes.Expected;
|
|
1346
1351
|
case "processing":
|
|
1347
|
-
return
|
|
1352
|
+
return import_lazy8.NoteFilterTypes.Processing;
|
|
1348
1353
|
case "all":
|
|
1349
1354
|
default:
|
|
1350
|
-
return
|
|
1355
|
+
return import_lazy8.NoteFilterTypes.All;
|
|
1351
1356
|
}
|
|
1352
1357
|
}
|
|
1353
1358
|
function getNoteType(type) {
|
|
1354
1359
|
switch (type) {
|
|
1355
1360
|
case "private":
|
|
1356
|
-
return
|
|
1361
|
+
return import_lazy8.NoteType.Private;
|
|
1357
1362
|
case "public":
|
|
1358
|
-
return
|
|
1363
|
+
return import_lazy8.NoteType.Public;
|
|
1359
1364
|
default:
|
|
1360
|
-
return
|
|
1365
|
+
return import_lazy8.NoteType.Private;
|
|
1361
1366
|
}
|
|
1362
1367
|
}
|
|
1363
1368
|
async function waitForTransactionCommit(client, runExclusiveSafe, txIdHex, maxWaitMs = 1e4, delayMs = 1e3) {
|
|
@@ -1366,7 +1371,7 @@ async function waitForTransactionCommit(client, runExclusiveSafe, txIdHex, maxWa
|
|
|
1366
1371
|
while (Date.now() < deadline) {
|
|
1367
1372
|
await runExclusiveSafe(() => client.syncState());
|
|
1368
1373
|
const records = await runExclusiveSafe(
|
|
1369
|
-
() => client.getTransactions(
|
|
1374
|
+
() => client.getTransactions(import_lazy8.TransactionFilter.all())
|
|
1370
1375
|
);
|
|
1371
1376
|
const record = records.find(
|
|
1372
1377
|
(r) => normalizeHex(r.id().toHex()) === targetHex
|
|
@@ -1409,7 +1414,7 @@ function useNotes(options) {
|
|
|
1409
1414
|
setError(null);
|
|
1410
1415
|
try {
|
|
1411
1416
|
const filterType = getNoteFilterType(options?.status);
|
|
1412
|
-
const filter = new
|
|
1417
|
+
const filter = new import_lazy9.NoteFilter(filterType);
|
|
1413
1418
|
const fetchedNotes = await client.getInputNotes(filter);
|
|
1414
1419
|
let fetchedConsumable;
|
|
1415
1420
|
if (options?.accountId) {
|
|
@@ -1531,10 +1536,10 @@ function useNotes(options) {
|
|
|
1531
1536
|
|
|
1532
1537
|
// src/hooks/useNoteStream.ts
|
|
1533
1538
|
var import_react8 = require("react");
|
|
1534
|
-
var
|
|
1539
|
+
var import_lazy11 = require("@miden-sdk/miden-sdk");
|
|
1535
1540
|
|
|
1536
1541
|
// src/utils/noteAttachment.ts
|
|
1537
|
-
var
|
|
1542
|
+
var import_lazy10 = require("@miden-sdk/miden-sdk");
|
|
1538
1543
|
function readNoteAttachment(note) {
|
|
1539
1544
|
try {
|
|
1540
1545
|
const metadata = note.metadata?.();
|
|
@@ -1543,8 +1548,8 @@ function readNoteAttachment(note) {
|
|
|
1543
1548
|
if (!attachment) return null;
|
|
1544
1549
|
const kind = attachment.kind?.();
|
|
1545
1550
|
if (!kind) return null;
|
|
1546
|
-
if (kind ===
|
|
1547
|
-
if (kind ===
|
|
1551
|
+
if (kind === import_lazy10.NoteAttachmentKind.None) return null;
|
|
1552
|
+
if (kind === import_lazy10.NoteAttachmentKind.Word) {
|
|
1548
1553
|
const word = attachment.asWord?.();
|
|
1549
1554
|
if (!word) return null;
|
|
1550
1555
|
const u64s = word.toU64s();
|
|
@@ -1553,7 +1558,7 @@ function readNoteAttachment(note) {
|
|
|
1553
1558
|
);
|
|
1554
1559
|
return { values, kind: "word" };
|
|
1555
1560
|
}
|
|
1556
|
-
if (kind ===
|
|
1561
|
+
if (kind === import_lazy10.NoteAttachmentKind.Array) {
|
|
1557
1562
|
const arr = attachment.asArray?.();
|
|
1558
1563
|
if (!arr) return null;
|
|
1559
1564
|
const u64s = arr.toU64s();
|
|
@@ -1573,30 +1578,30 @@ function createNoteAttachment(values) {
|
|
|
1573
1578
|
bigints.push(BigInt(values[i]));
|
|
1574
1579
|
}
|
|
1575
1580
|
if (bigints.length === 0) {
|
|
1576
|
-
return new
|
|
1581
|
+
return new import_lazy10.NoteAttachment();
|
|
1577
1582
|
}
|
|
1578
|
-
const scheme =
|
|
1583
|
+
const scheme = import_lazy10.NoteAttachmentScheme.none();
|
|
1579
1584
|
if (bigints.length <= 4) {
|
|
1580
1585
|
while (bigints.length < 4) {
|
|
1581
1586
|
bigints.push(0n);
|
|
1582
1587
|
}
|
|
1583
|
-
const word = new
|
|
1584
|
-
return
|
|
1588
|
+
const word = new import_lazy10.Word(BigUint64Array.from(bigints));
|
|
1589
|
+
return import_lazy10.NoteAttachment.newWord(scheme, word);
|
|
1585
1590
|
}
|
|
1586
1591
|
while (bigints.length % 4 !== 0) {
|
|
1587
1592
|
bigints.push(0n);
|
|
1588
1593
|
}
|
|
1589
1594
|
const words = [];
|
|
1590
1595
|
for (let i = 0; i < bigints.length; i += 4) {
|
|
1591
|
-
words.push(new
|
|
1596
|
+
words.push(new import_lazy10.Word(BigUint64Array.from(bigints.slice(i, i + 4))));
|
|
1592
1597
|
}
|
|
1593
|
-
const newArray =
|
|
1598
|
+
const newArray = import_lazy10.NoteAttachment["newArray"];
|
|
1594
1599
|
if (typeof newArray !== "function") {
|
|
1595
1600
|
throw new Error(
|
|
1596
1601
|
"NoteAttachment.newArray is not available. Ensure @miden-sdk/miden-sdk >= 0.13.1."
|
|
1597
1602
|
);
|
|
1598
1603
|
}
|
|
1599
|
-
return newArray.call(
|
|
1604
|
+
return newArray.call(import_lazy10.NoteAttachment, scheme, words);
|
|
1600
1605
|
}
|
|
1601
1606
|
|
|
1602
1607
|
// src/hooks/useNoteStream.ts
|
|
@@ -1631,7 +1636,7 @@ function useNoteStream(options = {}) {
|
|
|
1631
1636
|
setError(null);
|
|
1632
1637
|
try {
|
|
1633
1638
|
const filterType = getNoteFilterType(status);
|
|
1634
|
-
const filter = new
|
|
1639
|
+
const filter = new import_lazy11.NoteFilter(filterType);
|
|
1635
1640
|
const fetched = await client.getInputNotes(filter);
|
|
1636
1641
|
setNotesIfChanged(fetched);
|
|
1637
1642
|
} catch (err) {
|
|
@@ -1743,7 +1748,7 @@ function buildStreamedNote(record, noteFirstSeen) {
|
|
|
1743
1748
|
|
|
1744
1749
|
// src/hooks/useTransactionHistory.ts
|
|
1745
1750
|
var import_react9 = require("react");
|
|
1746
|
-
var
|
|
1751
|
+
var import_lazy12 = require("@miden-sdk/miden-sdk");
|
|
1747
1752
|
function useTransactionHistory(options = {}) {
|
|
1748
1753
|
const { client, isReady } = useMiden();
|
|
1749
1754
|
const { lastSyncTime } = useSyncStateStore();
|
|
@@ -1818,14 +1823,14 @@ function buildFilter(filter, ids, idsHex) {
|
|
|
1818
1823
|
return { filter };
|
|
1819
1824
|
}
|
|
1820
1825
|
if (!ids || ids.length === 0) {
|
|
1821
|
-
return { filter:
|
|
1826
|
+
return { filter: import_lazy12.TransactionFilter.all() };
|
|
1822
1827
|
}
|
|
1823
1828
|
const allTransactionIds = ids.every((id) => typeof id !== "string");
|
|
1824
1829
|
if (allTransactionIds) {
|
|
1825
|
-
return { filter:
|
|
1830
|
+
return { filter: import_lazy12.TransactionFilter.ids(ids) };
|
|
1826
1831
|
}
|
|
1827
1832
|
return {
|
|
1828
|
-
filter:
|
|
1833
|
+
filter: import_lazy12.TransactionFilter.all(),
|
|
1829
1834
|
localFilterHexes: idsHex ?? []
|
|
1830
1835
|
};
|
|
1831
1836
|
}
|
|
@@ -1851,7 +1856,7 @@ function useSyncState() {
|
|
|
1851
1856
|
|
|
1852
1857
|
// src/hooks/useCreateWallet.ts
|
|
1853
1858
|
var import_react11 = require("react");
|
|
1854
|
-
var
|
|
1859
|
+
var import_lazy13 = require("@miden-sdk/miden-sdk");
|
|
1855
1860
|
|
|
1856
1861
|
// src/utils/runExclusive.ts
|
|
1857
1862
|
var runExclusiveDirect = async (fn) => fn();
|
|
@@ -1917,19 +1922,19 @@ function useCreateWallet() {
|
|
|
1917
1922
|
function getStorageMode(mode) {
|
|
1918
1923
|
switch (mode) {
|
|
1919
1924
|
case "private":
|
|
1920
|
-
return
|
|
1925
|
+
return import_lazy13.AccountStorageMode.private();
|
|
1921
1926
|
case "public":
|
|
1922
|
-
return
|
|
1927
|
+
return import_lazy13.AccountStorageMode.public();
|
|
1923
1928
|
case "network":
|
|
1924
|
-
return
|
|
1929
|
+
return import_lazy13.AccountStorageMode.network();
|
|
1925
1930
|
default:
|
|
1926
|
-
return
|
|
1931
|
+
return import_lazy13.AccountStorageMode.private();
|
|
1927
1932
|
}
|
|
1928
1933
|
}
|
|
1929
1934
|
|
|
1930
1935
|
// src/hooks/useCreateFaucet.ts
|
|
1931
1936
|
var import_react12 = require("react");
|
|
1932
|
-
var
|
|
1937
|
+
var import_lazy14 = require("@miden-sdk/miden-sdk");
|
|
1933
1938
|
function useCreateFaucet() {
|
|
1934
1939
|
const { client, isReady, runExclusive } = useMiden();
|
|
1935
1940
|
const runExclusiveSafe = runExclusive ?? runExclusiveDirect;
|
|
@@ -1992,19 +1997,19 @@ function useCreateFaucet() {
|
|
|
1992
1997
|
function getStorageMode2(mode) {
|
|
1993
1998
|
switch (mode) {
|
|
1994
1999
|
case "private":
|
|
1995
|
-
return
|
|
2000
|
+
return import_lazy14.AccountStorageMode.private();
|
|
1996
2001
|
case "public":
|
|
1997
|
-
return
|
|
2002
|
+
return import_lazy14.AccountStorageMode.public();
|
|
1998
2003
|
case "network":
|
|
1999
|
-
return
|
|
2004
|
+
return import_lazy14.AccountStorageMode.network();
|
|
2000
2005
|
default:
|
|
2001
|
-
return
|
|
2006
|
+
return import_lazy14.AccountStorageMode.private();
|
|
2002
2007
|
}
|
|
2003
2008
|
}
|
|
2004
2009
|
|
|
2005
2010
|
// src/hooks/useImportAccount.ts
|
|
2006
2011
|
var import_react13 = require("react");
|
|
2007
|
-
var
|
|
2012
|
+
var import_lazy15 = require("@miden-sdk/miden-sdk");
|
|
2008
2013
|
|
|
2009
2014
|
// src/utils/errors.ts
|
|
2010
2015
|
var MidenError = class extends Error {
|
|
@@ -2176,10 +2181,10 @@ function useImportAccount() {
|
|
|
2176
2181
|
}
|
|
2177
2182
|
async function resolveAccountFile(file) {
|
|
2178
2183
|
if (file instanceof Uint8Array) {
|
|
2179
|
-
return
|
|
2184
|
+
return import_lazy15.AccountFile.deserialize(file);
|
|
2180
2185
|
}
|
|
2181
2186
|
if (file instanceof ArrayBuffer) {
|
|
2182
|
-
return
|
|
2187
|
+
return import_lazy15.AccountFile.deserialize(new Uint8Array(file));
|
|
2183
2188
|
}
|
|
2184
2189
|
return file;
|
|
2185
2190
|
}
|
|
@@ -2209,7 +2214,7 @@ function bytesEqual(left, right) {
|
|
|
2209
2214
|
|
|
2210
2215
|
// src/hooks/useSend.ts
|
|
2211
2216
|
var import_react14 = require("react");
|
|
2212
|
-
var
|
|
2217
|
+
var import_lazy16 = require("@miden-sdk/miden-sdk");
|
|
2213
2218
|
function useSend() {
|
|
2214
2219
|
const { client, isReady, sync, runExclusive, prover } = useMiden();
|
|
2215
2220
|
const runExclusiveSafe = runExclusive ?? runExclusiveDirect;
|
|
@@ -2276,19 +2281,19 @@ function useSend() {
|
|
|
2276
2281
|
const fromId = parseAccountId(options.from);
|
|
2277
2282
|
const toId = parseAccountId(options.to);
|
|
2278
2283
|
const assetObj = parseAccountId(assetId);
|
|
2279
|
-
const assets = new
|
|
2280
|
-
new
|
|
2284
|
+
const assets = new import_lazy16.NoteAssets([
|
|
2285
|
+
new import_lazy16.FungibleAsset(assetObj, BigInt(amount))
|
|
2281
2286
|
]);
|
|
2282
|
-
const p2idNote =
|
|
2287
|
+
const p2idNote = import_lazy16.Note.createP2IDNote(
|
|
2283
2288
|
fromId,
|
|
2284
2289
|
toId,
|
|
2285
2290
|
assets,
|
|
2286
2291
|
noteType,
|
|
2287
|
-
new
|
|
2292
|
+
new import_lazy16.NoteAttachment()
|
|
2288
2293
|
);
|
|
2289
|
-
const ownOutputs = new
|
|
2294
|
+
const ownOutputs = new import_lazy16.NoteArray();
|
|
2290
2295
|
ownOutputs.push(p2idNote);
|
|
2291
|
-
const txRequest = new
|
|
2296
|
+
const txRequest = new import_lazy16.TransactionRequestBuilder().withOwnOutputNotes(ownOutputs).build();
|
|
2292
2297
|
const execFromId = parseAccountId(options.from);
|
|
2293
2298
|
const txId = prover ? await client.submitNewTransactionWithProver(
|
|
2294
2299
|
execFromId,
|
|
@@ -2309,17 +2314,17 @@ function useSend() {
|
|
|
2309
2314
|
let txRequest;
|
|
2310
2315
|
if (hasAttachment) {
|
|
2311
2316
|
const attachment = createNoteAttachment(options.attachment);
|
|
2312
|
-
const assets = new
|
|
2313
|
-
new
|
|
2317
|
+
const assets = new import_lazy16.NoteAssets([
|
|
2318
|
+
new import_lazy16.FungibleAsset(assetIdObj, amount)
|
|
2314
2319
|
]);
|
|
2315
|
-
const note =
|
|
2320
|
+
const note = import_lazy16.Note.createP2IDNote(
|
|
2316
2321
|
fromAccountId,
|
|
2317
2322
|
toAccountId,
|
|
2318
2323
|
assets,
|
|
2319
2324
|
noteType,
|
|
2320
2325
|
attachment
|
|
2321
2326
|
);
|
|
2322
|
-
txRequest = new
|
|
2327
|
+
txRequest = new import_lazy16.TransactionRequestBuilder().withOwnOutputNotes(new import_lazy16.NoteArray([note])).build();
|
|
2323
2328
|
} else {
|
|
2324
2329
|
txRequest = client.newSendTransactionRequest(
|
|
2325
2330
|
fromAccountId,
|
|
@@ -2338,7 +2343,7 @@ function useSend() {
|
|
|
2338
2343
|
const proverConfig = useMidenStore.getState().config;
|
|
2339
2344
|
const provenTransaction = await proveWithFallback(
|
|
2340
2345
|
(resolvedProver) => runExclusiveSafe(
|
|
2341
|
-
() => client.
|
|
2346
|
+
() => resolvedProver ? client.proveTransactionWithProver(txResult, resolvedProver) : client.proveTransaction(txResult)
|
|
2342
2347
|
),
|
|
2343
2348
|
proverConfig
|
|
2344
2349
|
);
|
|
@@ -2349,13 +2354,13 @@ function useSend() {
|
|
|
2349
2354
|
const txIdHex = txResult.id().toHex();
|
|
2350
2355
|
const txIdString = txResult.id().toString();
|
|
2351
2356
|
let fullNote = null;
|
|
2352
|
-
if (noteType ===
|
|
2357
|
+
if (noteType === import_lazy16.NoteType.Private) {
|
|
2353
2358
|
fullNote = extractFullNote(txResult);
|
|
2354
2359
|
}
|
|
2355
2360
|
await runExclusiveSafe(
|
|
2356
2361
|
() => client.applyTransaction(txResult, submissionHeight)
|
|
2357
2362
|
);
|
|
2358
|
-
if (noteType ===
|
|
2363
|
+
if (noteType === import_lazy16.NoteType.Private) {
|
|
2359
2364
|
if (!fullNote) {
|
|
2360
2365
|
throw new Error("Missing full note for private send");
|
|
2361
2366
|
}
|
|
@@ -2418,7 +2423,7 @@ function extractFullNote(txResult) {
|
|
|
2418
2423
|
|
|
2419
2424
|
// src/hooks/useMultiSend.ts
|
|
2420
2425
|
var import_react15 = require("react");
|
|
2421
|
-
var
|
|
2426
|
+
var import_lazy17 = require("@miden-sdk/miden-sdk");
|
|
2422
2427
|
function useMultiSend() {
|
|
2423
2428
|
const { client, isReady, sync, prover, signerConnected } = useMiden();
|
|
2424
2429
|
const isBusyRef = (0, import_react15.useRef)(false);
|
|
@@ -2455,12 +2460,12 @@ function useMultiSend() {
|
|
|
2455
2460
|
const iterSenderId = parseAccountId(options.from);
|
|
2456
2461
|
const iterAssetId = parseAccountId(options.assetId);
|
|
2457
2462
|
const receiverId = parseAccountId(to);
|
|
2458
|
-
const assets = new
|
|
2459
|
-
new
|
|
2463
|
+
const assets = new import_lazy17.NoteAssets([
|
|
2464
|
+
new import_lazy17.FungibleAsset(iterAssetId, BigInt(amount))
|
|
2460
2465
|
]);
|
|
2461
2466
|
const resolvedNoteType = recipientNoteType ? getNoteType(recipientNoteType) : noteType;
|
|
2462
|
-
const noteAttachment = attachment !== void 0 && attachment !== null ? createNoteAttachment(attachment) : new
|
|
2463
|
-
const note =
|
|
2467
|
+
const noteAttachment = attachment !== void 0 && attachment !== null ? createNoteAttachment(attachment) : new import_lazy17.NoteAttachment();
|
|
2468
|
+
const note = import_lazy17.Note.createP2IDNote(
|
|
2464
2469
|
iterSenderId,
|
|
2465
2470
|
receiverId,
|
|
2466
2471
|
assets,
|
|
@@ -2475,14 +2480,14 @@ function useMultiSend() {
|
|
|
2475
2480
|
};
|
|
2476
2481
|
}
|
|
2477
2482
|
);
|
|
2478
|
-
const txRequest = new
|
|
2483
|
+
const txRequest = new import_lazy17.TransactionRequestBuilder().withOwnOutputNotes(new import_lazy17.NoteArray(outputs.map((o) => o.note))).build();
|
|
2479
2484
|
const txSenderId = parseAccountId(options.from);
|
|
2480
2485
|
const txResult = await client.executeTransaction(txSenderId, txRequest);
|
|
2481
2486
|
setStage("proving");
|
|
2482
2487
|
const proverConfig = useMidenStore.getState().config;
|
|
2483
2488
|
const provenTransaction = await proveWithFallback(
|
|
2484
2489
|
(resolvedProver) => runExclusiveDirect(
|
|
2485
|
-
() => client.
|
|
2490
|
+
() => resolvedProver ? client.proveTransactionWithProver(txResult, resolvedProver) : client.proveTransaction(txResult)
|
|
2486
2491
|
),
|
|
2487
2492
|
proverConfig
|
|
2488
2493
|
);
|
|
@@ -2494,7 +2499,7 @@ function useMultiSend() {
|
|
|
2494
2499
|
const txIdHex = txResult.id().toHex();
|
|
2495
2500
|
const txIdString = txResult.id().toString();
|
|
2496
2501
|
await client.applyTransaction(txResult, submissionHeight);
|
|
2497
|
-
const hasPrivate = outputs.some((o) => o.noteType ===
|
|
2502
|
+
const hasPrivate = outputs.some((o) => o.noteType === import_lazy17.NoteType.Private);
|
|
2498
2503
|
if (hasPrivate) {
|
|
2499
2504
|
await waitForTransactionCommit(
|
|
2500
2505
|
client,
|
|
@@ -2502,7 +2507,7 @@ function useMultiSend() {
|
|
|
2502
2507
|
txIdHex
|
|
2503
2508
|
);
|
|
2504
2509
|
for (const output of outputs) {
|
|
2505
|
-
if (output.noteType ===
|
|
2510
|
+
if (output.noteType === import_lazy17.NoteType.Private) {
|
|
2506
2511
|
await client.sendPrivateNote(
|
|
2507
2512
|
output.note,
|
|
2508
2513
|
output.recipientAddress
|
|
@@ -2545,7 +2550,7 @@ function useMultiSend() {
|
|
|
2545
2550
|
|
|
2546
2551
|
// src/hooks/useWaitForCommit.ts
|
|
2547
2552
|
var import_react16 = require("react");
|
|
2548
|
-
var
|
|
2553
|
+
var import_lazy18 = require("@miden-sdk/miden-sdk");
|
|
2549
2554
|
function useWaitForCommit() {
|
|
2550
2555
|
const { client, isReady } = useMiden();
|
|
2551
2556
|
const waitForCommit = (0, import_react16.useCallback)(
|
|
@@ -2562,7 +2567,7 @@ function useWaitForCommit() {
|
|
|
2562
2567
|
while (Date.now() < deadline) {
|
|
2563
2568
|
await client.syncState();
|
|
2564
2569
|
const records = await client.getTransactions(
|
|
2565
|
-
typeof txId === "string" ?
|
|
2570
|
+
typeof txId === "string" ? import_lazy18.TransactionFilter.all() : import_lazy18.TransactionFilter.ids([txId])
|
|
2566
2571
|
);
|
|
2567
2572
|
const record = records.find(
|
|
2568
2573
|
(item) => normalizeHex3(item.id().toHex()) === targetHex
|
|
@@ -2694,7 +2699,7 @@ function useMint() {
|
|
|
2694
2699
|
|
|
2695
2700
|
// src/hooks/useConsume.ts
|
|
2696
2701
|
var import_react19 = require("react");
|
|
2697
|
-
var
|
|
2702
|
+
var import_lazy19 = require("@miden-sdk/miden-sdk");
|
|
2698
2703
|
function useConsume() {
|
|
2699
2704
|
const { client, isReady, sync, runExclusive, prover } = useMiden();
|
|
2700
2705
|
const runExclusiveSafe = runExclusive ?? runExclusiveDirect;
|
|
@@ -2724,7 +2729,7 @@ function useConsume() {
|
|
|
2724
2729
|
const item = options.notes[i];
|
|
2725
2730
|
if (typeof item === "string") {
|
|
2726
2731
|
lookupIndices.push(i);
|
|
2727
|
-
lookupIds.push(
|
|
2732
|
+
lookupIds.push(import_lazy19.NoteId.fromHex(item));
|
|
2728
2733
|
} else if (item !== null && typeof item === "object" && typeof item.toNote === "function") {
|
|
2729
2734
|
resolved[i] = item.toNote();
|
|
2730
2735
|
} else if (item !== null && typeof item === "object" && typeof item.id === "function") {
|
|
@@ -2735,7 +2740,7 @@ function useConsume() {
|
|
|
2735
2740
|
}
|
|
2736
2741
|
}
|
|
2737
2742
|
if (lookupIds.length > 0) {
|
|
2738
|
-
const filter = new
|
|
2743
|
+
const filter = new import_lazy19.NoteFilter(import_lazy19.NoteFilterTypes.List, lookupIds);
|
|
2739
2744
|
const noteRecords = await client.getInputNotes(filter);
|
|
2740
2745
|
if (noteRecords.length !== lookupIds.length) {
|
|
2741
2746
|
throw new Error("Some notes could not be found for provided IDs");
|
|
@@ -2877,13 +2882,13 @@ function useSwap() {
|
|
|
2877
2882
|
var import_react21 = require("react");
|
|
2878
2883
|
|
|
2879
2884
|
// src/utils/transactions.ts
|
|
2880
|
-
var
|
|
2885
|
+
var import_lazy20 = require("@miden-sdk/miden-sdk");
|
|
2881
2886
|
async function waitForTransactionCommit2(client, runExclusiveSafe, txId, maxWaitMs = 1e4, delayMs = 1e3) {
|
|
2882
2887
|
let waited = 0;
|
|
2883
2888
|
while (waited < maxWaitMs) {
|
|
2884
2889
|
await runExclusiveSafe(() => client.syncState());
|
|
2885
2890
|
const [record] = await runExclusiveSafe(
|
|
2886
|
-
() => client.getTransactions(
|
|
2891
|
+
() => client.getTransactions(import_lazy20.TransactionFilter.ids([txId]))
|
|
2887
2892
|
);
|
|
2888
2893
|
if (record) {
|
|
2889
2894
|
const status = record.transactionStatus();
|
|
@@ -2905,7 +2910,7 @@ function extractFullNotes(txResult) {
|
|
|
2905
2910
|
const notes = executedTx?.outputNotes?.().notes?.() ?? [];
|
|
2906
2911
|
const result = [];
|
|
2907
2912
|
for (const note of notes) {
|
|
2908
|
-
if (note.noteType?.() ===
|
|
2913
|
+
if (note.noteType?.() === import_lazy20.NoteType.Private) {
|
|
2909
2914
|
const full = note.intoFull?.();
|
|
2910
2915
|
if (full) result.push(full);
|
|
2911
2916
|
}
|
|
@@ -2953,7 +2958,7 @@ function useTransaction() {
|
|
|
2953
2958
|
const proverConfig = useMidenStore.getState().config;
|
|
2954
2959
|
const provenTransaction = await proveWithFallback(
|
|
2955
2960
|
(resolvedProver) => runExclusiveSafe(
|
|
2956
|
-
() => client.
|
|
2961
|
+
() => resolvedProver ? client.proveTransactionWithProver(txResult, resolvedProver) : client.proveTransaction(txResult)
|
|
2957
2962
|
),
|
|
2958
2963
|
proverConfig
|
|
2959
2964
|
);
|
|
@@ -3016,7 +3021,7 @@ async function resolveRequest(request, client) {
|
|
|
3016
3021
|
|
|
3017
3022
|
// src/hooks/useExecuteProgram.ts
|
|
3018
3023
|
var import_react22 = require("react");
|
|
3019
|
-
var
|
|
3024
|
+
var import_lazy21 = require("@miden-sdk/miden-sdk");
|
|
3020
3025
|
function isForeignAccountWrapper(fa) {
|
|
3021
3026
|
return fa !== null && typeof fa === "object" && "id" in fa && typeof fa.id !== "function";
|
|
3022
3027
|
}
|
|
@@ -3047,18 +3052,18 @@ function useExecuteProgram() {
|
|
|
3047
3052
|
}
|
|
3048
3053
|
const programResult = await runExclusiveSafe(async () => {
|
|
3049
3054
|
const accountIdObj = parseAccountId(options.accountId);
|
|
3050
|
-
const adviceInputs = options.adviceInputs ?? new
|
|
3055
|
+
const adviceInputs = options.adviceInputs ?? new import_lazy21.AdviceInputs();
|
|
3051
3056
|
let foreignAccountsArray;
|
|
3052
3057
|
if (options.foreignAccounts?.length) {
|
|
3053
3058
|
const accounts = options.foreignAccounts.map((fa) => {
|
|
3054
3059
|
const wrapper = isForeignAccountWrapper(fa);
|
|
3055
3060
|
const id = parseAccountId(wrapper ? fa.id : fa);
|
|
3056
|
-
const storage = wrapper && fa.storage ? fa.storage : new
|
|
3057
|
-
return
|
|
3061
|
+
const storage = wrapper && fa.storage ? fa.storage : new import_lazy21.AccountStorageRequirements();
|
|
3062
|
+
return import_lazy21.ForeignAccount.public(id, storage);
|
|
3058
3063
|
});
|
|
3059
|
-
foreignAccountsArray = new
|
|
3064
|
+
foreignAccountsArray = new import_lazy21.ForeignAccountArray(accounts);
|
|
3060
3065
|
} else {
|
|
3061
|
-
foreignAccountsArray = new
|
|
3066
|
+
foreignAccountsArray = new import_lazy21.ForeignAccountArray();
|
|
3062
3067
|
}
|
|
3063
3068
|
const feltArray = await client.executeProgram(
|
|
3064
3069
|
accountIdObj,
|
|
@@ -3102,11 +3107,11 @@ function useExecuteProgram() {
|
|
|
3102
3107
|
|
|
3103
3108
|
// src/hooks/useCompile.ts
|
|
3104
3109
|
var import_react23 = require("react");
|
|
3105
|
-
var
|
|
3110
|
+
var import_lazy22 = require("@miden-sdk/miden-sdk");
|
|
3106
3111
|
function useCompile() {
|
|
3107
3112
|
const { client, isReady } = useMiden();
|
|
3108
3113
|
const resource = (0, import_react23.useMemo)(
|
|
3109
|
-
() => client && isReady ? new
|
|
3114
|
+
() => client && isReady ? new import_lazy22.CompilerResource(client, import_lazy22.getWasmOrThrow) : null,
|
|
3110
3115
|
[client, isReady]
|
|
3111
3116
|
);
|
|
3112
3117
|
const requireResource = (0, import_react23.useCallback)(() => {
|
|
@@ -3132,7 +3137,7 @@ function useCompile() {
|
|
|
3132
3137
|
|
|
3133
3138
|
// src/hooks/useSessionAccount.ts
|
|
3134
3139
|
var import_react24 = require("react");
|
|
3135
|
-
var
|
|
3140
|
+
var import_lazy23 = require("@miden-sdk/miden-sdk");
|
|
3136
3141
|
function useSessionAccount(options) {
|
|
3137
3142
|
const { client, isReady, sync } = useMiden();
|
|
3138
3143
|
const setAccounts = useMidenStore((state) => state.setAccounts);
|
|
@@ -3256,11 +3261,11 @@ function useSessionAccount(options) {
|
|
|
3256
3261
|
function getStorageMode3(mode) {
|
|
3257
3262
|
switch (mode) {
|
|
3258
3263
|
case "private":
|
|
3259
|
-
return
|
|
3264
|
+
return import_lazy23.AccountStorageMode.private();
|
|
3260
3265
|
case "public":
|
|
3261
|
-
return
|
|
3266
|
+
return import_lazy23.AccountStorageMode.public();
|
|
3262
3267
|
default:
|
|
3263
|
-
return
|
|
3268
|
+
return import_lazy23.AccountStorageMode.public();
|
|
3264
3269
|
}
|
|
3265
3270
|
}
|
|
3266
3271
|
async function waitAndConsume(client, walletId, pollIntervalMs, maxWaitMs, cancelledRef) {
|
|
@@ -3285,7 +3290,7 @@ async function waitAndConsume(client, walletId, pollIntervalMs, maxWaitMs, cance
|
|
|
3285
3290
|
|
|
3286
3291
|
// src/hooks/useExportStore.ts
|
|
3287
3292
|
var import_react25 = require("react");
|
|
3288
|
-
var
|
|
3293
|
+
var import_lazy24 = require("@miden-sdk/miden-sdk");
|
|
3289
3294
|
function useExportStore() {
|
|
3290
3295
|
const { client, isReady, runExclusive } = useMiden();
|
|
3291
3296
|
const [isExporting, setIsExporting] = (0, import_react25.useState)(false);
|
|
@@ -3298,7 +3303,7 @@ function useExportStore() {
|
|
|
3298
3303
|
setError(null);
|
|
3299
3304
|
try {
|
|
3300
3305
|
const storeName = client.storeIdentifier();
|
|
3301
|
-
const snapshot = await runExclusive(() => (0,
|
|
3306
|
+
const snapshot = await runExclusive(() => (0, import_lazy24.exportStore)(storeName));
|
|
3302
3307
|
return snapshot;
|
|
3303
3308
|
} catch (err) {
|
|
3304
3309
|
const error2 = err instanceof Error ? err : new Error(String(err));
|
|
@@ -3322,7 +3327,7 @@ function useExportStore() {
|
|
|
3322
3327
|
|
|
3323
3328
|
// src/hooks/useImportStore.ts
|
|
3324
3329
|
var import_react26 = require("react");
|
|
3325
|
-
var
|
|
3330
|
+
var import_lazy25 = require("@miden-sdk/miden-sdk");
|
|
3326
3331
|
function useImportStore() {
|
|
3327
3332
|
const { client, isReady, runExclusive, sync } = useMiden();
|
|
3328
3333
|
const [isImporting, setIsImporting] = (0, import_react26.useState)(false);
|
|
@@ -3335,7 +3340,7 @@ function useImportStore() {
|
|
|
3335
3340
|
setIsImporting(true);
|
|
3336
3341
|
setError(null);
|
|
3337
3342
|
try {
|
|
3338
|
-
await runExclusive(() => (0,
|
|
3343
|
+
await runExclusive(() => (0, import_lazy25.importStore)(storeName, storeDump));
|
|
3339
3344
|
if (!options?.skipSync) {
|
|
3340
3345
|
await sync();
|
|
3341
3346
|
}
|
|
@@ -3363,7 +3368,7 @@ function useImportStore() {
|
|
|
3363
3368
|
|
|
3364
3369
|
// src/hooks/useImportNote.ts
|
|
3365
3370
|
var import_react27 = require("react");
|
|
3366
|
-
var
|
|
3371
|
+
var import_lazy26 = require("@miden-sdk/miden-sdk");
|
|
3367
3372
|
function useImportNote() {
|
|
3368
3373
|
const { client, isReady, runExclusive, sync } = useMiden();
|
|
3369
3374
|
const [isImporting, setIsImporting] = (0, import_react27.useState)(false);
|
|
@@ -3376,7 +3381,7 @@ function useImportNote() {
|
|
|
3376
3381
|
setIsImporting(true);
|
|
3377
3382
|
setError(null);
|
|
3378
3383
|
try {
|
|
3379
|
-
const noteFile =
|
|
3384
|
+
const noteFile = import_lazy26.NoteFile.deserialize(noteBytes);
|
|
3380
3385
|
const noteId = await runExclusive(
|
|
3381
3386
|
() => client.importNoteFile(noteFile)
|
|
3382
3387
|
);
|
|
@@ -3406,7 +3411,7 @@ function useImportNote() {
|
|
|
3406
3411
|
|
|
3407
3412
|
// src/hooks/useExportNote.ts
|
|
3408
3413
|
var import_react28 = require("react");
|
|
3409
|
-
var
|
|
3414
|
+
var import_lazy27 = require("@miden-sdk/miden-sdk");
|
|
3410
3415
|
function useExportNote() {
|
|
3411
3416
|
const { client, isReady, runExclusive } = useMiden();
|
|
3412
3417
|
const [isExporting, setIsExporting] = (0, import_react28.useState)(false);
|
|
@@ -3420,7 +3425,7 @@ function useExportNote() {
|
|
|
3420
3425
|
setError(null);
|
|
3421
3426
|
try {
|
|
3422
3427
|
const noteFile = await runExclusive(
|
|
3423
|
-
() => client.exportNoteFile(noteId,
|
|
3428
|
+
() => client.exportNoteFile(noteId, import_lazy27.NoteExportFormat.Full)
|
|
3424
3429
|
);
|
|
3425
3430
|
return noteFile.serialize();
|
|
3426
3431
|
} catch (err) {
|