@miden-sdk/react 0.14.3 → 0.14.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/README.md +58 -0
- package/dist/index.d.mts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.js +166 -147
- package/dist/index.mjs +51 -23
- package/dist/lazy.d.mts +1497 -0
- package/dist/lazy.d.ts +1497 -0
- package/dist/lazy.js +3686 -0
- package/dist/lazy.mjs +3660 -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.Falcon,
|
|
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
|
);
|
|
@@ -535,7 +535,13 @@ function isPrivateStorageMode(storageMode) {
|
|
|
535
535
|
return storageMode.toString() === "private";
|
|
536
536
|
}
|
|
537
537
|
async function initializeSignerAccount(client, config) {
|
|
538
|
-
const {
|
|
538
|
+
const {
|
|
539
|
+
AccountBuilder,
|
|
540
|
+
AccountComponent,
|
|
541
|
+
AuthScheme: AuthScheme2,
|
|
542
|
+
Word: Word2,
|
|
543
|
+
resolveAuthScheme: resolveAuthScheme5
|
|
544
|
+
} = await import("@miden-sdk/miden-sdk");
|
|
539
545
|
await client.syncState();
|
|
540
546
|
if (config.importAccountId) {
|
|
541
547
|
const accountId2 = parseAccountId(config.importAccountId);
|
|
@@ -556,7 +562,7 @@ async function initializeSignerAccount(client, config) {
|
|
|
556
562
|
let builder = new AccountBuilder(seed).withAuthComponent(
|
|
557
563
|
AccountComponent.createAuthComponentFromCommitment(
|
|
558
564
|
commitmentWord,
|
|
559
|
-
AuthScheme2.
|
|
565
|
+
resolveAuthScheme5(AuthScheme2.ECDSA)
|
|
560
566
|
)
|
|
561
567
|
).accountType(accountType).storageMode(config.storageMode).withBasicWalletComponent();
|
|
562
568
|
if (config.customComponents?.length) {
|
|
@@ -629,15 +635,20 @@ function MidenProvider({
|
|
|
629
635
|
}),
|
|
630
636
|
[config]
|
|
631
637
|
);
|
|
632
|
-
const defaultProver = (0, import_react2.
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
638
|
+
const [defaultProver, setDefaultProver] = (0, import_react2.useState)(null);
|
|
639
|
+
(0, import_react2.useEffect)(() => {
|
|
640
|
+
if (!isReady) {
|
|
641
|
+
setDefaultProver(null);
|
|
642
|
+
return;
|
|
643
|
+
}
|
|
644
|
+
setDefaultProver(resolveTransactionProver(resolvedConfig));
|
|
645
|
+
}, [
|
|
646
|
+
isReady,
|
|
647
|
+
resolvedConfig.prover,
|
|
648
|
+
resolvedConfig.proverTimeoutMs,
|
|
649
|
+
resolvedConfig.proverUrls?.devnet,
|
|
650
|
+
resolvedConfig.proverUrls?.testnet
|
|
651
|
+
]);
|
|
641
652
|
const runExclusive = (0, import_react2.useCallback)(
|
|
642
653
|
async (fn) => clientLockRef.current.runExclusive(fn),
|
|
643
654
|
[]
|
|
@@ -716,7 +727,7 @@ function MidenProvider({
|
|
|
716
727
|
if (signerContext && signerIsConnected === true) {
|
|
717
728
|
const storeName = `MidenClientDB_${signerContext.storeName}`;
|
|
718
729
|
signCbRef.current = signerContext.signCb;
|
|
719
|
-
webClient = await
|
|
730
|
+
webClient = await import_lazy6.WasmWebClient.createClientWithExternalKeystore(
|
|
720
731
|
resolvedConfig.rpcUrl,
|
|
721
732
|
resolvedConfig.noteTransportUrl,
|
|
722
733
|
resolvedConfig.seed,
|
|
@@ -736,7 +747,7 @@ function MidenProvider({
|
|
|
736
747
|
currentStoreNameRef.current = signerContext.storeName;
|
|
737
748
|
} else {
|
|
738
749
|
const seed = resolvedConfig.seed;
|
|
739
|
-
webClient = await
|
|
750
|
+
webClient = await import_lazy6.WasmWebClient.createClient(
|
|
740
751
|
resolvedConfig.rpcUrl,
|
|
741
752
|
resolvedConfig.noteTransportUrl,
|
|
742
753
|
seed
|
|
@@ -1080,7 +1091,7 @@ var import_react6 = require("react");
|
|
|
1080
1091
|
|
|
1081
1092
|
// src/hooks/useAssetMetadata.ts
|
|
1082
1093
|
var import_react5 = require("react");
|
|
1083
|
-
var
|
|
1094
|
+
var import_lazy7 = require("@miden-sdk/miden-sdk");
|
|
1084
1095
|
var inflight = /* @__PURE__ */ new Map();
|
|
1085
1096
|
var rpcClients = /* @__PURE__ */ new Map();
|
|
1086
1097
|
var getRpcClient = (rpcUrl) => {
|
|
@@ -1088,8 +1099,8 @@ var getRpcClient = (rpcUrl) => {
|
|
|
1088
1099
|
const existing = rpcClients.get(key);
|
|
1089
1100
|
if (existing) return existing;
|
|
1090
1101
|
try {
|
|
1091
|
-
const endpoint = rpcUrl ? new
|
|
1092
|
-
const client = new
|
|
1102
|
+
const endpoint = rpcUrl ? new import_lazy7.Endpoint(rpcUrl) : import_lazy7.Endpoint.testnet();
|
|
1103
|
+
const client = new import_lazy7.RpcClient(endpoint);
|
|
1093
1104
|
rpcClients.set(key, client);
|
|
1094
1105
|
return client;
|
|
1095
1106
|
} catch {
|
|
@@ -1103,7 +1114,7 @@ var fetchAssetMetadata = async (rpcClient, assetId) => {
|
|
|
1103
1114
|
const fetched = await rpcClient.getAccountDetails(accountId);
|
|
1104
1115
|
const account = fetched.account?.();
|
|
1105
1116
|
if (!account) return null;
|
|
1106
|
-
const faucet =
|
|
1117
|
+
const faucet = import_lazy7.BasicFungibleFaucetComponent.fromAccount(account);
|
|
1107
1118
|
const symbol = faucet.symbol().toString();
|
|
1108
1119
|
const decimals = faucet.decimals();
|
|
1109
1120
|
return { assetId, symbol, decimals };
|
|
@@ -1229,7 +1240,7 @@ function useAccount(accountId) {
|
|
|
1229
1240
|
|
|
1230
1241
|
// src/hooks/useNotes.ts
|
|
1231
1242
|
var import_react7 = require("react");
|
|
1232
|
-
var
|
|
1243
|
+
var import_lazy9 = require("@miden-sdk/miden-sdk");
|
|
1233
1244
|
|
|
1234
1245
|
// src/utils/amounts.ts
|
|
1235
1246
|
var formatAssetAmount = (amount, decimals) => {
|
|
@@ -1334,30 +1345,30 @@ function accountIdsEqual(a, b) {
|
|
|
1334
1345
|
}
|
|
1335
1346
|
|
|
1336
1347
|
// src/utils/noteFilters.ts
|
|
1337
|
-
var
|
|
1348
|
+
var import_lazy8 = require("@miden-sdk/miden-sdk");
|
|
1338
1349
|
function getNoteFilterType(status) {
|
|
1339
1350
|
switch (status) {
|
|
1340
1351
|
case "consumed":
|
|
1341
|
-
return
|
|
1352
|
+
return import_lazy8.NoteFilterTypes.Consumed;
|
|
1342
1353
|
case "committed":
|
|
1343
|
-
return
|
|
1354
|
+
return import_lazy8.NoteFilterTypes.Committed;
|
|
1344
1355
|
case "expected":
|
|
1345
|
-
return
|
|
1356
|
+
return import_lazy8.NoteFilterTypes.Expected;
|
|
1346
1357
|
case "processing":
|
|
1347
|
-
return
|
|
1358
|
+
return import_lazy8.NoteFilterTypes.Processing;
|
|
1348
1359
|
case "all":
|
|
1349
1360
|
default:
|
|
1350
|
-
return
|
|
1361
|
+
return import_lazy8.NoteFilterTypes.All;
|
|
1351
1362
|
}
|
|
1352
1363
|
}
|
|
1353
1364
|
function getNoteType(type) {
|
|
1354
1365
|
switch (type) {
|
|
1355
1366
|
case "private":
|
|
1356
|
-
return
|
|
1367
|
+
return import_lazy8.NoteType.Private;
|
|
1357
1368
|
case "public":
|
|
1358
|
-
return
|
|
1369
|
+
return import_lazy8.NoteType.Public;
|
|
1359
1370
|
default:
|
|
1360
|
-
return
|
|
1371
|
+
return import_lazy8.NoteType.Private;
|
|
1361
1372
|
}
|
|
1362
1373
|
}
|
|
1363
1374
|
async function waitForTransactionCommit(client, runExclusiveSafe, txIdHex, maxWaitMs = 1e4, delayMs = 1e3) {
|
|
@@ -1366,7 +1377,7 @@ async function waitForTransactionCommit(client, runExclusiveSafe, txIdHex, maxWa
|
|
|
1366
1377
|
while (Date.now() < deadline) {
|
|
1367
1378
|
await runExclusiveSafe(() => client.syncState());
|
|
1368
1379
|
const records = await runExclusiveSafe(
|
|
1369
|
-
() => client.getTransactions(
|
|
1380
|
+
() => client.getTransactions(import_lazy8.TransactionFilter.all())
|
|
1370
1381
|
);
|
|
1371
1382
|
const record = records.find(
|
|
1372
1383
|
(r) => normalizeHex(r.id().toHex()) === targetHex
|
|
@@ -1409,7 +1420,7 @@ function useNotes(options) {
|
|
|
1409
1420
|
setError(null);
|
|
1410
1421
|
try {
|
|
1411
1422
|
const filterType = getNoteFilterType(options?.status);
|
|
1412
|
-
const filter = new
|
|
1423
|
+
const filter = new import_lazy9.NoteFilter(filterType);
|
|
1413
1424
|
const fetchedNotes = await client.getInputNotes(filter);
|
|
1414
1425
|
let fetchedConsumable;
|
|
1415
1426
|
if (options?.accountId) {
|
|
@@ -1531,10 +1542,10 @@ function useNotes(options) {
|
|
|
1531
1542
|
|
|
1532
1543
|
// src/hooks/useNoteStream.ts
|
|
1533
1544
|
var import_react8 = require("react");
|
|
1534
|
-
var
|
|
1545
|
+
var import_lazy11 = require("@miden-sdk/miden-sdk");
|
|
1535
1546
|
|
|
1536
1547
|
// src/utils/noteAttachment.ts
|
|
1537
|
-
var
|
|
1548
|
+
var import_lazy10 = require("@miden-sdk/miden-sdk");
|
|
1538
1549
|
function readNoteAttachment(note) {
|
|
1539
1550
|
try {
|
|
1540
1551
|
const metadata = note.metadata?.();
|
|
@@ -1543,8 +1554,8 @@ function readNoteAttachment(note) {
|
|
|
1543
1554
|
if (!attachment) return null;
|
|
1544
1555
|
const kind = attachment.kind?.();
|
|
1545
1556
|
if (!kind) return null;
|
|
1546
|
-
if (kind ===
|
|
1547
|
-
if (kind ===
|
|
1557
|
+
if (kind === import_lazy10.NoteAttachmentKind.None) return null;
|
|
1558
|
+
if (kind === import_lazy10.NoteAttachmentKind.Word) {
|
|
1548
1559
|
const word = attachment.asWord?.();
|
|
1549
1560
|
if (!word) return null;
|
|
1550
1561
|
const u64s = word.toU64s();
|
|
@@ -1553,7 +1564,7 @@ function readNoteAttachment(note) {
|
|
|
1553
1564
|
);
|
|
1554
1565
|
return { values, kind: "word" };
|
|
1555
1566
|
}
|
|
1556
|
-
if (kind ===
|
|
1567
|
+
if (kind === import_lazy10.NoteAttachmentKind.Array) {
|
|
1557
1568
|
const arr = attachment.asArray?.();
|
|
1558
1569
|
if (!arr) return null;
|
|
1559
1570
|
const u64s = arr.toU64s();
|
|
@@ -1573,30 +1584,30 @@ function createNoteAttachment(values) {
|
|
|
1573
1584
|
bigints.push(BigInt(values[i]));
|
|
1574
1585
|
}
|
|
1575
1586
|
if (bigints.length === 0) {
|
|
1576
|
-
return new
|
|
1587
|
+
return new import_lazy10.NoteAttachment();
|
|
1577
1588
|
}
|
|
1578
|
-
const scheme =
|
|
1589
|
+
const scheme = import_lazy10.NoteAttachmentScheme.none();
|
|
1579
1590
|
if (bigints.length <= 4) {
|
|
1580
1591
|
while (bigints.length < 4) {
|
|
1581
1592
|
bigints.push(0n);
|
|
1582
1593
|
}
|
|
1583
|
-
const word = new
|
|
1584
|
-
return
|
|
1594
|
+
const word = new import_lazy10.Word(BigUint64Array.from(bigints));
|
|
1595
|
+
return import_lazy10.NoteAttachment.newWord(scheme, word);
|
|
1585
1596
|
}
|
|
1586
1597
|
while (bigints.length % 4 !== 0) {
|
|
1587
1598
|
bigints.push(0n);
|
|
1588
1599
|
}
|
|
1589
1600
|
const words = [];
|
|
1590
1601
|
for (let i = 0; i < bigints.length; i += 4) {
|
|
1591
|
-
words.push(new
|
|
1602
|
+
words.push(new import_lazy10.Word(BigUint64Array.from(bigints.slice(i, i + 4))));
|
|
1592
1603
|
}
|
|
1593
|
-
const newArray =
|
|
1604
|
+
const newArray = import_lazy10.NoteAttachment["newArray"];
|
|
1594
1605
|
if (typeof newArray !== "function") {
|
|
1595
1606
|
throw new Error(
|
|
1596
1607
|
"NoteAttachment.newArray is not available. Ensure @miden-sdk/miden-sdk >= 0.13.1."
|
|
1597
1608
|
);
|
|
1598
1609
|
}
|
|
1599
|
-
return newArray.call(
|
|
1610
|
+
return newArray.call(import_lazy10.NoteAttachment, scheme, words);
|
|
1600
1611
|
}
|
|
1601
1612
|
|
|
1602
1613
|
// src/hooks/useNoteStream.ts
|
|
@@ -1631,7 +1642,7 @@ function useNoteStream(options = {}) {
|
|
|
1631
1642
|
setError(null);
|
|
1632
1643
|
try {
|
|
1633
1644
|
const filterType = getNoteFilterType(status);
|
|
1634
|
-
const filter = new
|
|
1645
|
+
const filter = new import_lazy11.NoteFilter(filterType);
|
|
1635
1646
|
const fetched = await client.getInputNotes(filter);
|
|
1636
1647
|
setNotesIfChanged(fetched);
|
|
1637
1648
|
} catch (err) {
|
|
@@ -1743,7 +1754,7 @@ function buildStreamedNote(record, noteFirstSeen) {
|
|
|
1743
1754
|
|
|
1744
1755
|
// src/hooks/useTransactionHistory.ts
|
|
1745
1756
|
var import_react9 = require("react");
|
|
1746
|
-
var
|
|
1757
|
+
var import_lazy12 = require("@miden-sdk/miden-sdk");
|
|
1747
1758
|
function useTransactionHistory(options = {}) {
|
|
1748
1759
|
const { client, isReady } = useMiden();
|
|
1749
1760
|
const { lastSyncTime } = useSyncStateStore();
|
|
@@ -1818,14 +1829,14 @@ function buildFilter(filter, ids, idsHex) {
|
|
|
1818
1829
|
return { filter };
|
|
1819
1830
|
}
|
|
1820
1831
|
if (!ids || ids.length === 0) {
|
|
1821
|
-
return { filter:
|
|
1832
|
+
return { filter: import_lazy12.TransactionFilter.all() };
|
|
1822
1833
|
}
|
|
1823
1834
|
const allTransactionIds = ids.every((id) => typeof id !== "string");
|
|
1824
1835
|
if (allTransactionIds) {
|
|
1825
|
-
return { filter:
|
|
1836
|
+
return { filter: import_lazy12.TransactionFilter.ids(ids) };
|
|
1826
1837
|
}
|
|
1827
1838
|
return {
|
|
1828
|
-
filter:
|
|
1839
|
+
filter: import_lazy12.TransactionFilter.all(),
|
|
1829
1840
|
localFilterHexes: idsHex ?? []
|
|
1830
1841
|
};
|
|
1831
1842
|
}
|
|
@@ -1851,7 +1862,7 @@ function useSyncState() {
|
|
|
1851
1862
|
|
|
1852
1863
|
// src/hooks/useCreateWallet.ts
|
|
1853
1864
|
var import_react11 = require("react");
|
|
1854
|
-
var
|
|
1865
|
+
var import_lazy13 = require("@miden-sdk/miden-sdk");
|
|
1855
1866
|
|
|
1856
1867
|
// src/utils/runExclusive.ts
|
|
1857
1868
|
var runExclusiveDirect = async (fn) => fn();
|
|
@@ -1876,7 +1887,9 @@ function useCreateWallet() {
|
|
|
1876
1887
|
options.storageMode ?? DEFAULTS.STORAGE_MODE
|
|
1877
1888
|
);
|
|
1878
1889
|
const mutable = options.mutable ?? DEFAULTS.WALLET_MUTABLE;
|
|
1879
|
-
const authScheme =
|
|
1890
|
+
const authScheme = (0, import_lazy13.resolveAuthScheme)(
|
|
1891
|
+
options.authScheme ?? DEFAULTS.AUTH_SCHEME
|
|
1892
|
+
);
|
|
1880
1893
|
const newWallet = await runExclusiveSafe(async () => {
|
|
1881
1894
|
const createdWallet = await client.newWallet(
|
|
1882
1895
|
storageMode,
|
|
@@ -1917,19 +1930,19 @@ function useCreateWallet() {
|
|
|
1917
1930
|
function getStorageMode(mode) {
|
|
1918
1931
|
switch (mode) {
|
|
1919
1932
|
case "private":
|
|
1920
|
-
return
|
|
1933
|
+
return import_lazy13.AccountStorageMode.private();
|
|
1921
1934
|
case "public":
|
|
1922
|
-
return
|
|
1935
|
+
return import_lazy13.AccountStorageMode.public();
|
|
1923
1936
|
case "network":
|
|
1924
|
-
return
|
|
1937
|
+
return import_lazy13.AccountStorageMode.network();
|
|
1925
1938
|
default:
|
|
1926
|
-
return
|
|
1939
|
+
return import_lazy13.AccountStorageMode.private();
|
|
1927
1940
|
}
|
|
1928
1941
|
}
|
|
1929
1942
|
|
|
1930
1943
|
// src/hooks/useCreateFaucet.ts
|
|
1931
1944
|
var import_react12 = require("react");
|
|
1932
|
-
var
|
|
1945
|
+
var import_lazy14 = require("@miden-sdk/miden-sdk");
|
|
1933
1946
|
function useCreateFaucet() {
|
|
1934
1947
|
const { client, isReady, runExclusive } = useMiden();
|
|
1935
1948
|
const runExclusiveSafe = runExclusive ?? runExclusiveDirect;
|
|
@@ -1949,7 +1962,9 @@ function useCreateFaucet() {
|
|
|
1949
1962
|
options.storageMode ?? DEFAULTS.STORAGE_MODE
|
|
1950
1963
|
);
|
|
1951
1964
|
const decimals = options.decimals ?? DEFAULTS.FAUCET_DECIMALS;
|
|
1952
|
-
const authScheme =
|
|
1965
|
+
const authScheme = (0, import_lazy14.resolveAuthScheme)(
|
|
1966
|
+
options.authScheme ?? DEFAULTS.AUTH_SCHEME
|
|
1967
|
+
);
|
|
1953
1968
|
const newFaucet = await runExclusiveSafe(async () => {
|
|
1954
1969
|
const createdFaucet = await client.newFaucet(
|
|
1955
1970
|
storageMode,
|
|
@@ -1992,19 +2007,19 @@ function useCreateFaucet() {
|
|
|
1992
2007
|
function getStorageMode2(mode) {
|
|
1993
2008
|
switch (mode) {
|
|
1994
2009
|
case "private":
|
|
1995
|
-
return
|
|
2010
|
+
return import_lazy14.AccountStorageMode.private();
|
|
1996
2011
|
case "public":
|
|
1997
|
-
return
|
|
2012
|
+
return import_lazy14.AccountStorageMode.public();
|
|
1998
2013
|
case "network":
|
|
1999
|
-
return
|
|
2014
|
+
return import_lazy14.AccountStorageMode.network();
|
|
2000
2015
|
default:
|
|
2001
|
-
return
|
|
2016
|
+
return import_lazy14.AccountStorageMode.private();
|
|
2002
2017
|
}
|
|
2003
2018
|
}
|
|
2004
2019
|
|
|
2005
2020
|
// src/hooks/useImportAccount.ts
|
|
2006
2021
|
var import_react13 = require("react");
|
|
2007
|
-
var
|
|
2022
|
+
var import_lazy15 = require("@miden-sdk/miden-sdk");
|
|
2008
2023
|
|
|
2009
2024
|
// src/utils/errors.ts
|
|
2010
2025
|
var MidenError = class extends Error {
|
|
@@ -2137,7 +2152,9 @@ function useImportAccount() {
|
|
|
2137
2152
|
}
|
|
2138
2153
|
case "seed": {
|
|
2139
2154
|
const mutable = options.mutable ?? DEFAULTS.WALLET_MUTABLE;
|
|
2140
|
-
const authScheme =
|
|
2155
|
+
const authScheme = (0, import_lazy15.resolveAuthScheme)(
|
|
2156
|
+
options.authScheme ?? DEFAULTS.AUTH_SCHEME
|
|
2157
|
+
);
|
|
2141
2158
|
return await client.importPublicAccountFromSeed(
|
|
2142
2159
|
options.seed,
|
|
2143
2160
|
mutable,
|
|
@@ -2176,10 +2193,10 @@ function useImportAccount() {
|
|
|
2176
2193
|
}
|
|
2177
2194
|
async function resolveAccountFile(file) {
|
|
2178
2195
|
if (file instanceof Uint8Array) {
|
|
2179
|
-
return
|
|
2196
|
+
return import_lazy15.AccountFile.deserialize(file);
|
|
2180
2197
|
}
|
|
2181
2198
|
if (file instanceof ArrayBuffer) {
|
|
2182
|
-
return
|
|
2199
|
+
return import_lazy15.AccountFile.deserialize(new Uint8Array(file));
|
|
2183
2200
|
}
|
|
2184
2201
|
return file;
|
|
2185
2202
|
}
|
|
@@ -2209,7 +2226,7 @@ function bytesEqual(left, right) {
|
|
|
2209
2226
|
|
|
2210
2227
|
// src/hooks/useSend.ts
|
|
2211
2228
|
var import_react14 = require("react");
|
|
2212
|
-
var
|
|
2229
|
+
var import_lazy16 = require("@miden-sdk/miden-sdk");
|
|
2213
2230
|
function useSend() {
|
|
2214
2231
|
const { client, isReady, sync, runExclusive, prover } = useMiden();
|
|
2215
2232
|
const runExclusiveSafe = runExclusive ?? runExclusiveDirect;
|
|
@@ -2276,19 +2293,19 @@ function useSend() {
|
|
|
2276
2293
|
const fromId = parseAccountId(options.from);
|
|
2277
2294
|
const toId = parseAccountId(options.to);
|
|
2278
2295
|
const assetObj = parseAccountId(assetId);
|
|
2279
|
-
const assets = new
|
|
2280
|
-
new
|
|
2296
|
+
const assets = new import_lazy16.NoteAssets([
|
|
2297
|
+
new import_lazy16.FungibleAsset(assetObj, BigInt(amount))
|
|
2281
2298
|
]);
|
|
2282
|
-
const p2idNote =
|
|
2299
|
+
const p2idNote = import_lazy16.Note.createP2IDNote(
|
|
2283
2300
|
fromId,
|
|
2284
2301
|
toId,
|
|
2285
2302
|
assets,
|
|
2286
2303
|
noteType,
|
|
2287
|
-
new
|
|
2304
|
+
new import_lazy16.NoteAttachment()
|
|
2288
2305
|
);
|
|
2289
|
-
const ownOutputs = new
|
|
2306
|
+
const ownOutputs = new import_lazy16.NoteArray();
|
|
2290
2307
|
ownOutputs.push(p2idNote);
|
|
2291
|
-
const txRequest = new
|
|
2308
|
+
const txRequest = new import_lazy16.TransactionRequestBuilder().withOwnOutputNotes(ownOutputs).build();
|
|
2292
2309
|
const execFromId = parseAccountId(options.from);
|
|
2293
2310
|
const txId = prover ? await client.submitNewTransactionWithProver(
|
|
2294
2311
|
execFromId,
|
|
@@ -2309,17 +2326,17 @@ function useSend() {
|
|
|
2309
2326
|
let txRequest;
|
|
2310
2327
|
if (hasAttachment) {
|
|
2311
2328
|
const attachment = createNoteAttachment(options.attachment);
|
|
2312
|
-
const assets = new
|
|
2313
|
-
new
|
|
2329
|
+
const assets = new import_lazy16.NoteAssets([
|
|
2330
|
+
new import_lazy16.FungibleAsset(assetIdObj, amount)
|
|
2314
2331
|
]);
|
|
2315
|
-
const note =
|
|
2332
|
+
const note = import_lazy16.Note.createP2IDNote(
|
|
2316
2333
|
fromAccountId,
|
|
2317
2334
|
toAccountId,
|
|
2318
2335
|
assets,
|
|
2319
2336
|
noteType,
|
|
2320
2337
|
attachment
|
|
2321
2338
|
);
|
|
2322
|
-
txRequest = new
|
|
2339
|
+
txRequest = new import_lazy16.TransactionRequestBuilder().withOwnOutputNotes(new import_lazy16.NoteArray([note])).build();
|
|
2323
2340
|
} else {
|
|
2324
2341
|
txRequest = client.newSendTransactionRequest(
|
|
2325
2342
|
fromAccountId,
|
|
@@ -2338,7 +2355,7 @@ function useSend() {
|
|
|
2338
2355
|
const proverConfig = useMidenStore.getState().config;
|
|
2339
2356
|
const provenTransaction = await proveWithFallback(
|
|
2340
2357
|
(resolvedProver) => runExclusiveSafe(
|
|
2341
|
-
() => client.
|
|
2358
|
+
() => resolvedProver ? client.proveTransactionWithProver(txResult, resolvedProver) : client.proveTransaction(txResult)
|
|
2342
2359
|
),
|
|
2343
2360
|
proverConfig
|
|
2344
2361
|
);
|
|
@@ -2349,13 +2366,13 @@ function useSend() {
|
|
|
2349
2366
|
const txIdHex = txResult.id().toHex();
|
|
2350
2367
|
const txIdString = txResult.id().toString();
|
|
2351
2368
|
let fullNote = null;
|
|
2352
|
-
if (noteType ===
|
|
2369
|
+
if (noteType === import_lazy16.NoteType.Private) {
|
|
2353
2370
|
fullNote = extractFullNote(txResult);
|
|
2354
2371
|
}
|
|
2355
2372
|
await runExclusiveSafe(
|
|
2356
2373
|
() => client.applyTransaction(txResult, submissionHeight)
|
|
2357
2374
|
);
|
|
2358
|
-
if (noteType ===
|
|
2375
|
+
if (noteType === import_lazy16.NoteType.Private) {
|
|
2359
2376
|
if (!fullNote) {
|
|
2360
2377
|
throw new Error("Missing full note for private send");
|
|
2361
2378
|
}
|
|
@@ -2418,7 +2435,7 @@ function extractFullNote(txResult) {
|
|
|
2418
2435
|
|
|
2419
2436
|
// src/hooks/useMultiSend.ts
|
|
2420
2437
|
var import_react15 = require("react");
|
|
2421
|
-
var
|
|
2438
|
+
var import_lazy17 = require("@miden-sdk/miden-sdk");
|
|
2422
2439
|
function useMultiSend() {
|
|
2423
2440
|
const { client, isReady, sync, prover, signerConnected } = useMiden();
|
|
2424
2441
|
const isBusyRef = (0, import_react15.useRef)(false);
|
|
@@ -2455,12 +2472,12 @@ function useMultiSend() {
|
|
|
2455
2472
|
const iterSenderId = parseAccountId(options.from);
|
|
2456
2473
|
const iterAssetId = parseAccountId(options.assetId);
|
|
2457
2474
|
const receiverId = parseAccountId(to);
|
|
2458
|
-
const assets = new
|
|
2459
|
-
new
|
|
2475
|
+
const assets = new import_lazy17.NoteAssets([
|
|
2476
|
+
new import_lazy17.FungibleAsset(iterAssetId, BigInt(amount))
|
|
2460
2477
|
]);
|
|
2461
2478
|
const resolvedNoteType = recipientNoteType ? getNoteType(recipientNoteType) : noteType;
|
|
2462
|
-
const noteAttachment = attachment !== void 0 && attachment !== null ? createNoteAttachment(attachment) : new
|
|
2463
|
-
const note =
|
|
2479
|
+
const noteAttachment = attachment !== void 0 && attachment !== null ? createNoteAttachment(attachment) : new import_lazy17.NoteAttachment();
|
|
2480
|
+
const note = import_lazy17.Note.createP2IDNote(
|
|
2464
2481
|
iterSenderId,
|
|
2465
2482
|
receiverId,
|
|
2466
2483
|
assets,
|
|
@@ -2475,14 +2492,14 @@ function useMultiSend() {
|
|
|
2475
2492
|
};
|
|
2476
2493
|
}
|
|
2477
2494
|
);
|
|
2478
|
-
const txRequest = new
|
|
2495
|
+
const txRequest = new import_lazy17.TransactionRequestBuilder().withOwnOutputNotes(new import_lazy17.NoteArray(outputs.map((o) => o.note))).build();
|
|
2479
2496
|
const txSenderId = parseAccountId(options.from);
|
|
2480
2497
|
const txResult = await client.executeTransaction(txSenderId, txRequest);
|
|
2481
2498
|
setStage("proving");
|
|
2482
2499
|
const proverConfig = useMidenStore.getState().config;
|
|
2483
2500
|
const provenTransaction = await proveWithFallback(
|
|
2484
2501
|
(resolvedProver) => runExclusiveDirect(
|
|
2485
|
-
() => client.
|
|
2502
|
+
() => resolvedProver ? client.proveTransactionWithProver(txResult, resolvedProver) : client.proveTransaction(txResult)
|
|
2486
2503
|
),
|
|
2487
2504
|
proverConfig
|
|
2488
2505
|
);
|
|
@@ -2494,7 +2511,7 @@ function useMultiSend() {
|
|
|
2494
2511
|
const txIdHex = txResult.id().toHex();
|
|
2495
2512
|
const txIdString = txResult.id().toString();
|
|
2496
2513
|
await client.applyTransaction(txResult, submissionHeight);
|
|
2497
|
-
const hasPrivate = outputs.some((o) => o.noteType ===
|
|
2514
|
+
const hasPrivate = outputs.some((o) => o.noteType === import_lazy17.NoteType.Private);
|
|
2498
2515
|
if (hasPrivate) {
|
|
2499
2516
|
await waitForTransactionCommit(
|
|
2500
2517
|
client,
|
|
@@ -2502,7 +2519,7 @@ function useMultiSend() {
|
|
|
2502
2519
|
txIdHex
|
|
2503
2520
|
);
|
|
2504
2521
|
for (const output of outputs) {
|
|
2505
|
-
if (output.noteType ===
|
|
2522
|
+
if (output.noteType === import_lazy17.NoteType.Private) {
|
|
2506
2523
|
await client.sendPrivateNote(
|
|
2507
2524
|
output.note,
|
|
2508
2525
|
output.recipientAddress
|
|
@@ -2545,7 +2562,7 @@ function useMultiSend() {
|
|
|
2545
2562
|
|
|
2546
2563
|
// src/hooks/useWaitForCommit.ts
|
|
2547
2564
|
var import_react16 = require("react");
|
|
2548
|
-
var
|
|
2565
|
+
var import_lazy18 = require("@miden-sdk/miden-sdk");
|
|
2549
2566
|
function useWaitForCommit() {
|
|
2550
2567
|
const { client, isReady } = useMiden();
|
|
2551
2568
|
const waitForCommit = (0, import_react16.useCallback)(
|
|
@@ -2562,7 +2579,7 @@ function useWaitForCommit() {
|
|
|
2562
2579
|
while (Date.now() < deadline) {
|
|
2563
2580
|
await client.syncState();
|
|
2564
2581
|
const records = await client.getTransactions(
|
|
2565
|
-
typeof txId === "string" ?
|
|
2582
|
+
typeof txId === "string" ? import_lazy18.TransactionFilter.all() : import_lazy18.TransactionFilter.ids([txId])
|
|
2566
2583
|
);
|
|
2567
2584
|
const record = records.find(
|
|
2568
2585
|
(item) => normalizeHex3(item.id().toHex()) === targetHex
|
|
@@ -2694,7 +2711,7 @@ function useMint() {
|
|
|
2694
2711
|
|
|
2695
2712
|
// src/hooks/useConsume.ts
|
|
2696
2713
|
var import_react19 = require("react");
|
|
2697
|
-
var
|
|
2714
|
+
var import_lazy19 = require("@miden-sdk/miden-sdk");
|
|
2698
2715
|
function useConsume() {
|
|
2699
2716
|
const { client, isReady, sync, runExclusive, prover } = useMiden();
|
|
2700
2717
|
const runExclusiveSafe = runExclusive ?? runExclusiveDirect;
|
|
@@ -2724,7 +2741,7 @@ function useConsume() {
|
|
|
2724
2741
|
const item = options.notes[i];
|
|
2725
2742
|
if (typeof item === "string") {
|
|
2726
2743
|
lookupIndices.push(i);
|
|
2727
|
-
lookupIds.push(
|
|
2744
|
+
lookupIds.push(import_lazy19.NoteId.fromHex(item));
|
|
2728
2745
|
} else if (item !== null && typeof item === "object" && typeof item.toNote === "function") {
|
|
2729
2746
|
resolved[i] = item.toNote();
|
|
2730
2747
|
} else if (item !== null && typeof item === "object" && typeof item.id === "function") {
|
|
@@ -2735,7 +2752,7 @@ function useConsume() {
|
|
|
2735
2752
|
}
|
|
2736
2753
|
}
|
|
2737
2754
|
if (lookupIds.length > 0) {
|
|
2738
|
-
const filter = new
|
|
2755
|
+
const filter = new import_lazy19.NoteFilter(import_lazy19.NoteFilterTypes.List, lookupIds);
|
|
2739
2756
|
const noteRecords = await client.getInputNotes(filter);
|
|
2740
2757
|
if (noteRecords.length !== lookupIds.length) {
|
|
2741
2758
|
throw new Error("Some notes could not be found for provided IDs");
|
|
@@ -2877,13 +2894,13 @@ function useSwap() {
|
|
|
2877
2894
|
var import_react21 = require("react");
|
|
2878
2895
|
|
|
2879
2896
|
// src/utils/transactions.ts
|
|
2880
|
-
var
|
|
2897
|
+
var import_lazy20 = require("@miden-sdk/miden-sdk");
|
|
2881
2898
|
async function waitForTransactionCommit2(client, runExclusiveSafe, txId, maxWaitMs = 1e4, delayMs = 1e3) {
|
|
2882
2899
|
let waited = 0;
|
|
2883
2900
|
while (waited < maxWaitMs) {
|
|
2884
2901
|
await runExclusiveSafe(() => client.syncState());
|
|
2885
2902
|
const [record] = await runExclusiveSafe(
|
|
2886
|
-
() => client.getTransactions(
|
|
2903
|
+
() => client.getTransactions(import_lazy20.TransactionFilter.ids([txId]))
|
|
2887
2904
|
);
|
|
2888
2905
|
if (record) {
|
|
2889
2906
|
const status = record.transactionStatus();
|
|
@@ -2905,7 +2922,7 @@ function extractFullNotes(txResult) {
|
|
|
2905
2922
|
const notes = executedTx?.outputNotes?.().notes?.() ?? [];
|
|
2906
2923
|
const result = [];
|
|
2907
2924
|
for (const note of notes) {
|
|
2908
|
-
if (note.noteType?.() ===
|
|
2925
|
+
if (note.noteType?.() === import_lazy20.NoteType.Private) {
|
|
2909
2926
|
const full = note.intoFull?.();
|
|
2910
2927
|
if (full) result.push(full);
|
|
2911
2928
|
}
|
|
@@ -2953,7 +2970,7 @@ function useTransaction() {
|
|
|
2953
2970
|
const proverConfig = useMidenStore.getState().config;
|
|
2954
2971
|
const provenTransaction = await proveWithFallback(
|
|
2955
2972
|
(resolvedProver) => runExclusiveSafe(
|
|
2956
|
-
() => client.
|
|
2973
|
+
() => resolvedProver ? client.proveTransactionWithProver(txResult, resolvedProver) : client.proveTransaction(txResult)
|
|
2957
2974
|
),
|
|
2958
2975
|
proverConfig
|
|
2959
2976
|
);
|
|
@@ -3016,7 +3033,7 @@ async function resolveRequest(request, client) {
|
|
|
3016
3033
|
|
|
3017
3034
|
// src/hooks/useExecuteProgram.ts
|
|
3018
3035
|
var import_react22 = require("react");
|
|
3019
|
-
var
|
|
3036
|
+
var import_lazy21 = require("@miden-sdk/miden-sdk");
|
|
3020
3037
|
function isForeignAccountWrapper(fa) {
|
|
3021
3038
|
return fa !== null && typeof fa === "object" && "id" in fa && typeof fa.id !== "function";
|
|
3022
3039
|
}
|
|
@@ -3047,18 +3064,18 @@ function useExecuteProgram() {
|
|
|
3047
3064
|
}
|
|
3048
3065
|
const programResult = await runExclusiveSafe(async () => {
|
|
3049
3066
|
const accountIdObj = parseAccountId(options.accountId);
|
|
3050
|
-
const adviceInputs = options.adviceInputs ?? new
|
|
3067
|
+
const adviceInputs = options.adviceInputs ?? new import_lazy21.AdviceInputs();
|
|
3051
3068
|
let foreignAccountsArray;
|
|
3052
3069
|
if (options.foreignAccounts?.length) {
|
|
3053
3070
|
const accounts = options.foreignAccounts.map((fa) => {
|
|
3054
3071
|
const wrapper = isForeignAccountWrapper(fa);
|
|
3055
3072
|
const id = parseAccountId(wrapper ? fa.id : fa);
|
|
3056
|
-
const storage = wrapper && fa.storage ? fa.storage : new
|
|
3057
|
-
return
|
|
3073
|
+
const storage = wrapper && fa.storage ? fa.storage : new import_lazy21.AccountStorageRequirements();
|
|
3074
|
+
return import_lazy21.ForeignAccount.public(id, storage);
|
|
3058
3075
|
});
|
|
3059
|
-
foreignAccountsArray = new
|
|
3076
|
+
foreignAccountsArray = new import_lazy21.ForeignAccountArray(accounts);
|
|
3060
3077
|
} else {
|
|
3061
|
-
foreignAccountsArray = new
|
|
3078
|
+
foreignAccountsArray = new import_lazy21.ForeignAccountArray();
|
|
3062
3079
|
}
|
|
3063
3080
|
const feltArray = await client.executeProgram(
|
|
3064
3081
|
accountIdObj,
|
|
@@ -3102,11 +3119,11 @@ function useExecuteProgram() {
|
|
|
3102
3119
|
|
|
3103
3120
|
// src/hooks/useCompile.ts
|
|
3104
3121
|
var import_react23 = require("react");
|
|
3105
|
-
var
|
|
3122
|
+
var import_lazy22 = require("@miden-sdk/miden-sdk");
|
|
3106
3123
|
function useCompile() {
|
|
3107
3124
|
const { client, isReady } = useMiden();
|
|
3108
3125
|
const resource = (0, import_react23.useMemo)(
|
|
3109
|
-
() => client && isReady ? new
|
|
3126
|
+
() => client && isReady ? new import_lazy22.CompilerResource(client, import_lazy22.getWasmOrThrow) : null,
|
|
3110
3127
|
[client, isReady]
|
|
3111
3128
|
);
|
|
3112
3129
|
const requireResource = (0, import_react23.useCallback)(() => {
|
|
@@ -3132,7 +3149,7 @@ function useCompile() {
|
|
|
3132
3149
|
|
|
3133
3150
|
// src/hooks/useSessionAccount.ts
|
|
3134
3151
|
var import_react24 = require("react");
|
|
3135
|
-
var
|
|
3152
|
+
var import_lazy23 = require("@miden-sdk/miden-sdk");
|
|
3136
3153
|
function useSessionAccount(options) {
|
|
3137
3154
|
const { client, isReady, sync } = useMiden();
|
|
3138
3155
|
const setAccounts = useMidenStore((state) => state.setAccounts);
|
|
@@ -3146,7 +3163,9 @@ function useSessionAccount(options) {
|
|
|
3146
3163
|
const maxWaitMs = options.maxWaitMs ?? 6e4;
|
|
3147
3164
|
const storageMode = options.walletOptions?.storageMode ?? "public";
|
|
3148
3165
|
const mutable = options.walletOptions?.mutable ?? DEFAULTS.WALLET_MUTABLE;
|
|
3149
|
-
const authScheme =
|
|
3166
|
+
const authScheme = (0, import_lazy23.resolveAuthScheme)(
|
|
3167
|
+
options.walletOptions?.authScheme ?? DEFAULTS.AUTH_SCHEME
|
|
3168
|
+
);
|
|
3150
3169
|
const fundRef = (0, import_react24.useRef)(options.fund);
|
|
3151
3170
|
fundRef.current = options.fund;
|
|
3152
3171
|
(0, import_react24.useEffect)(() => {
|
|
@@ -3256,11 +3275,11 @@ function useSessionAccount(options) {
|
|
|
3256
3275
|
function getStorageMode3(mode) {
|
|
3257
3276
|
switch (mode) {
|
|
3258
3277
|
case "private":
|
|
3259
|
-
return
|
|
3278
|
+
return import_lazy23.AccountStorageMode.private();
|
|
3260
3279
|
case "public":
|
|
3261
|
-
return
|
|
3280
|
+
return import_lazy23.AccountStorageMode.public();
|
|
3262
3281
|
default:
|
|
3263
|
-
return
|
|
3282
|
+
return import_lazy23.AccountStorageMode.public();
|
|
3264
3283
|
}
|
|
3265
3284
|
}
|
|
3266
3285
|
async function waitAndConsume(client, walletId, pollIntervalMs, maxWaitMs, cancelledRef) {
|
|
@@ -3285,7 +3304,7 @@ async function waitAndConsume(client, walletId, pollIntervalMs, maxWaitMs, cance
|
|
|
3285
3304
|
|
|
3286
3305
|
// src/hooks/useExportStore.ts
|
|
3287
3306
|
var import_react25 = require("react");
|
|
3288
|
-
var
|
|
3307
|
+
var import_lazy24 = require("@miden-sdk/miden-sdk");
|
|
3289
3308
|
function useExportStore() {
|
|
3290
3309
|
const { client, isReady, runExclusive } = useMiden();
|
|
3291
3310
|
const [isExporting, setIsExporting] = (0, import_react25.useState)(false);
|
|
@@ -3298,7 +3317,7 @@ function useExportStore() {
|
|
|
3298
3317
|
setError(null);
|
|
3299
3318
|
try {
|
|
3300
3319
|
const storeName = client.storeIdentifier();
|
|
3301
|
-
const snapshot = await runExclusive(() => (0,
|
|
3320
|
+
const snapshot = await runExclusive(() => (0, import_lazy24.exportStore)(storeName));
|
|
3302
3321
|
return snapshot;
|
|
3303
3322
|
} catch (err) {
|
|
3304
3323
|
const error2 = err instanceof Error ? err : new Error(String(err));
|
|
@@ -3322,7 +3341,7 @@ function useExportStore() {
|
|
|
3322
3341
|
|
|
3323
3342
|
// src/hooks/useImportStore.ts
|
|
3324
3343
|
var import_react26 = require("react");
|
|
3325
|
-
var
|
|
3344
|
+
var import_lazy25 = require("@miden-sdk/miden-sdk");
|
|
3326
3345
|
function useImportStore() {
|
|
3327
3346
|
const { client, isReady, runExclusive, sync } = useMiden();
|
|
3328
3347
|
const [isImporting, setIsImporting] = (0, import_react26.useState)(false);
|
|
@@ -3335,7 +3354,7 @@ function useImportStore() {
|
|
|
3335
3354
|
setIsImporting(true);
|
|
3336
3355
|
setError(null);
|
|
3337
3356
|
try {
|
|
3338
|
-
await runExclusive(() => (0,
|
|
3357
|
+
await runExclusive(() => (0, import_lazy25.importStore)(storeName, storeDump));
|
|
3339
3358
|
if (!options?.skipSync) {
|
|
3340
3359
|
await sync();
|
|
3341
3360
|
}
|
|
@@ -3363,7 +3382,7 @@ function useImportStore() {
|
|
|
3363
3382
|
|
|
3364
3383
|
// src/hooks/useImportNote.ts
|
|
3365
3384
|
var import_react27 = require("react");
|
|
3366
|
-
var
|
|
3385
|
+
var import_lazy26 = require("@miden-sdk/miden-sdk");
|
|
3367
3386
|
function useImportNote() {
|
|
3368
3387
|
const { client, isReady, runExclusive, sync } = useMiden();
|
|
3369
3388
|
const [isImporting, setIsImporting] = (0, import_react27.useState)(false);
|
|
@@ -3376,7 +3395,7 @@ function useImportNote() {
|
|
|
3376
3395
|
setIsImporting(true);
|
|
3377
3396
|
setError(null);
|
|
3378
3397
|
try {
|
|
3379
|
-
const noteFile =
|
|
3398
|
+
const noteFile = import_lazy26.NoteFile.deserialize(noteBytes);
|
|
3380
3399
|
const noteId = await runExclusive(
|
|
3381
3400
|
() => client.importNoteFile(noteFile)
|
|
3382
3401
|
);
|
|
@@ -3406,7 +3425,7 @@ function useImportNote() {
|
|
|
3406
3425
|
|
|
3407
3426
|
// src/hooks/useExportNote.ts
|
|
3408
3427
|
var import_react28 = require("react");
|
|
3409
|
-
var
|
|
3428
|
+
var import_lazy27 = require("@miden-sdk/miden-sdk");
|
|
3410
3429
|
function useExportNote() {
|
|
3411
3430
|
const { client, isReady, runExclusive } = useMiden();
|
|
3412
3431
|
const [isExporting, setIsExporting] = (0, import_react28.useState)(false);
|
|
@@ -3420,7 +3439,7 @@ function useExportNote() {
|
|
|
3420
3439
|
setError(null);
|
|
3421
3440
|
try {
|
|
3422
3441
|
const noteFile = await runExclusive(
|
|
3423
|
-
() => client.exportNoteFile(noteId,
|
|
3442
|
+
() => client.exportNoteFile(noteId, import_lazy27.NoteExportFormat.Full)
|
|
3424
3443
|
);
|
|
3425
3444
|
return noteFile.serialize();
|
|
3426
3445
|
} catch (err) {
|