@miden-sdk/react 0.14.5 → 0.15.0-alpha.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/CLAUDE.md +66 -47
- package/LICENSE +21 -0
- package/README.md +7 -7
- package/dist/index.d.mts +9 -7
- package/dist/index.d.ts +9 -7
- package/dist/index.js +156 -180
- package/dist/index.mjs +30 -65
- package/package.json +30 -35
- package/dist/lazy.d.mts +0 -1497
- package/dist/lazy.d.ts +0 -1497
- package/dist/lazy.js +0 -3686
- package/dist/lazy.mjs +0 -3660
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 index_exports = {};
|
|
32
|
+
__export(index_exports, {
|
|
33
|
+
AuthScheme: () => import_miden_sdk4.AuthScheme,
|
|
34
34
|
DEFAULTS: () => DEFAULTS,
|
|
35
35
|
MidenError: () => MidenError,
|
|
36
36
|
MidenProvider: () => MidenProvider,
|
|
@@ -44,9 +44,11 @@ __export(src_exports, {
|
|
|
44
44
|
concatBytes: () => concatBytes,
|
|
45
45
|
createMidenStorage: () => createMidenStorage,
|
|
46
46
|
createNoteAttachment: () => createNoteAttachment,
|
|
47
|
+
ensureAccountBech32: () => ensureAccountBech32,
|
|
47
48
|
formatAssetAmount: () => formatAssetAmount,
|
|
48
49
|
formatNoteSummary: () => formatNoteSummary,
|
|
49
50
|
getNoteSummary: () => getNoteSummary,
|
|
51
|
+
installAccountBech32: () => installAccountBech32,
|
|
50
52
|
migrateStorage: () => migrateStorage,
|
|
51
53
|
normalizeAccountId: () => normalizeAccountId,
|
|
52
54
|
parseAssetAmount: () => parseAssetAmount,
|
|
@@ -85,13 +87,13 @@ __export(src_exports, {
|
|
|
85
87
|
waitForWalletDetection: () => waitForWalletDetection,
|
|
86
88
|
wrapWasmError: () => wrapWasmError
|
|
87
89
|
});
|
|
88
|
-
module.exports = __toCommonJS(
|
|
90
|
+
module.exports = __toCommonJS(index_exports);
|
|
89
91
|
|
|
90
92
|
// src/types/augmentations.ts
|
|
91
|
-
var
|
|
93
|
+
var import_miden_sdk = require("@miden-sdk/miden-sdk");
|
|
92
94
|
|
|
93
95
|
// src/utils/accountBech32.ts
|
|
94
|
-
var
|
|
96
|
+
var import_miden_sdk3 = require("@miden-sdk/miden-sdk");
|
|
95
97
|
|
|
96
98
|
// src/store/MidenStore.ts
|
|
97
99
|
var import_zustand = require("zustand");
|
|
@@ -238,19 +240,19 @@ var useAssetMetadataStore = () => useMidenStore((state) => state.assetMetadata);
|
|
|
238
240
|
var useNoteFirstSeenStore = () => useMidenStore((state) => state.noteFirstSeen);
|
|
239
241
|
|
|
240
242
|
// src/utils/accountParsing.ts
|
|
241
|
-
var
|
|
243
|
+
var import_miden_sdk2 = require("@miden-sdk/miden-sdk");
|
|
242
244
|
var normalizeAccountIdInput = (value) => value.trim().replace(/^miden:/i, "");
|
|
243
245
|
var isBech32Input = (value) => value.startsWith("m") || value.startsWith("M");
|
|
244
246
|
var normalizeHexInput = (value) => value.startsWith("0x") || value.startsWith("0X") ? value : `0x${value}`;
|
|
245
247
|
var parseAccountIdFromString = (value) => {
|
|
246
248
|
if (isBech32Input(value)) {
|
|
247
249
|
try {
|
|
248
|
-
return
|
|
250
|
+
return import_miden_sdk2.Address.fromBech32(value).accountId();
|
|
249
251
|
} catch {
|
|
250
|
-
return
|
|
252
|
+
return import_miden_sdk2.AccountId.fromBech32(value);
|
|
251
253
|
}
|
|
252
254
|
}
|
|
253
|
-
return
|
|
255
|
+
return import_miden_sdk2.AccountId.fromHex(normalizeHexInput(value));
|
|
254
256
|
};
|
|
255
257
|
var parseAccountId = (value) => {
|
|
256
258
|
if (typeof value === "string") {
|
|
@@ -277,49 +279,49 @@ function isFaucetId(accountId) {
|
|
|
277
279
|
var parseAddress = (value, accountId) => {
|
|
278
280
|
if (typeof value !== "string") {
|
|
279
281
|
const resolvedId = accountId ?? parseAccountId(value);
|
|
280
|
-
return
|
|
282
|
+
return import_miden_sdk2.Address.fromAccountId(resolvedId, "BasicWallet");
|
|
281
283
|
}
|
|
282
284
|
const normalized = normalizeAccountIdInput(value);
|
|
283
285
|
if (isBech32Input(normalized)) {
|
|
284
286
|
try {
|
|
285
|
-
return
|
|
287
|
+
return import_miden_sdk2.Address.fromBech32(normalized);
|
|
286
288
|
} catch {
|
|
287
|
-
const resolvedAccountId2 = accountId ??
|
|
288
|
-
return
|
|
289
|
+
const resolvedAccountId2 = accountId ?? import_miden_sdk2.AccountId.fromBech32(normalized);
|
|
290
|
+
return import_miden_sdk2.Address.fromAccountId(resolvedAccountId2, "BasicWallet");
|
|
289
291
|
}
|
|
290
292
|
}
|
|
291
|
-
const resolvedAccountId = accountId ??
|
|
292
|
-
return
|
|
293
|
+
const resolvedAccountId = accountId ?? import_miden_sdk2.AccountId.fromHex(normalizeHexInput(normalized));
|
|
294
|
+
return import_miden_sdk2.Address.fromAccountId(resolvedAccountId, "BasicWallet");
|
|
293
295
|
};
|
|
294
296
|
|
|
295
297
|
// src/utils/accountBech32.ts
|
|
296
298
|
var inferNetworkId = () => {
|
|
297
299
|
const { rpcUrl } = useMidenStore.getState().config;
|
|
298
300
|
if (!rpcUrl) {
|
|
299
|
-
return
|
|
301
|
+
return import_miden_sdk3.NetworkId.testnet();
|
|
300
302
|
}
|
|
301
303
|
const url = rpcUrl.toLowerCase();
|
|
302
304
|
if (url.includes("devnet") || url.includes("mdev")) {
|
|
303
|
-
return
|
|
305
|
+
return import_miden_sdk3.NetworkId.devnet();
|
|
304
306
|
}
|
|
305
307
|
if (url.includes("mainnet")) {
|
|
306
|
-
return
|
|
308
|
+
return import_miden_sdk3.NetworkId.mainnet();
|
|
307
309
|
}
|
|
308
310
|
if (url.includes("testnet") || url.includes("mtst")) {
|
|
309
|
-
return
|
|
311
|
+
return import_miden_sdk3.NetworkId.testnet();
|
|
310
312
|
}
|
|
311
|
-
return
|
|
313
|
+
return import_miden_sdk3.NetworkId.testnet();
|
|
312
314
|
};
|
|
313
315
|
var toBech32FromAccountId = (id) => {
|
|
314
316
|
try {
|
|
315
|
-
const address =
|
|
317
|
+
const address = import_miden_sdk3.Address.fromAccountId(id, "BasicWallet");
|
|
316
318
|
return address.toBech32(inferNetworkId());
|
|
317
319
|
} catch {
|
|
318
320
|
}
|
|
319
321
|
try {
|
|
320
322
|
const maybeBech32 = id.toBech32?.(
|
|
321
323
|
inferNetworkId(),
|
|
322
|
-
|
|
324
|
+
import_miden_sdk3.AccountInterface.BasicWallet
|
|
323
325
|
);
|
|
324
326
|
if (typeof maybeBech32 === "string") {
|
|
325
327
|
return maybeBech32;
|
|
@@ -349,7 +351,7 @@ var defineBech32 = (target) => {
|
|
|
349
351
|
}
|
|
350
352
|
};
|
|
351
353
|
var installAccountBech32 = () => {
|
|
352
|
-
const proto =
|
|
354
|
+
const proto = import_miden_sdk3.Account.prototype;
|
|
353
355
|
if (proto.bech32id) {
|
|
354
356
|
return;
|
|
355
357
|
}
|
|
@@ -382,17 +384,17 @@ var toBech32AccountId = (accountId) => {
|
|
|
382
384
|
|
|
383
385
|
// src/context/MidenProvider.tsx
|
|
384
386
|
var import_react2 = require("react");
|
|
385
|
-
var
|
|
387
|
+
var import_miden_sdk6 = require("@miden-sdk/miden-sdk");
|
|
386
388
|
|
|
387
389
|
// src/types/index.ts
|
|
388
|
-
var
|
|
390
|
+
var import_miden_sdk4 = require("@miden-sdk/miden-sdk");
|
|
389
391
|
var DEFAULTS = {
|
|
390
392
|
RPC_URL: void 0,
|
|
391
393
|
// Will use SDK's testnet default
|
|
392
394
|
AUTO_SYNC_INTERVAL: 15e3,
|
|
393
395
|
STORAGE_MODE: "private",
|
|
394
396
|
WALLET_MUTABLE: true,
|
|
395
|
-
AUTH_SCHEME:
|
|
397
|
+
AUTH_SCHEME: import_miden_sdk4.AuthScheme.AuthRpoFalcon512,
|
|
396
398
|
NOTE_TYPE: "private",
|
|
397
399
|
FAUCET_DECIMALS: 8
|
|
398
400
|
};
|
|
@@ -436,7 +438,7 @@ function resolveRpcUrl(rpcUrl) {
|
|
|
436
438
|
}
|
|
437
439
|
|
|
438
440
|
// src/utils/prover.ts
|
|
439
|
-
var
|
|
441
|
+
var import_miden_sdk5 = require("@miden-sdk/miden-sdk");
|
|
440
442
|
var DEFAULT_PROVER_URLS = {
|
|
441
443
|
devnet: "https://tx-prover.devnet.miden.io",
|
|
442
444
|
testnet: "https://tx-prover.testnet.miden.io"
|
|
@@ -475,19 +477,16 @@ function resolveProverTarget(target, config) {
|
|
|
475
477
|
if (typeof target === "string") {
|
|
476
478
|
const normalized = target.trim().toLowerCase();
|
|
477
479
|
if (normalized === "local" || normalized === "localhost") {
|
|
478
|
-
return
|
|
480
|
+
return import_miden_sdk5.TransactionProver.newLocalProver();
|
|
479
481
|
}
|
|
480
482
|
if (normalized === "devnet" || normalized === "testnet") {
|
|
481
|
-
const url = config.proverUrls?.[normalized] ?? DEFAULT_PROVER_URLS[normalized]
|
|
482
|
-
|
|
483
|
-
throw new Error(`Missing ${normalized} prover URL`);
|
|
484
|
-
}
|
|
485
|
-
return import_lazy5.TransactionProver.newRemoteProver(
|
|
483
|
+
const url = config.proverUrls?.[normalized] ?? DEFAULT_PROVER_URLS[normalized];
|
|
484
|
+
return import_miden_sdk5.TransactionProver.newRemoteProver(
|
|
486
485
|
url,
|
|
487
486
|
normalizeTimeout(config.proverTimeoutMs)
|
|
488
487
|
);
|
|
489
488
|
}
|
|
490
|
-
return
|
|
489
|
+
return import_miden_sdk5.TransactionProver.newRemoteProver(
|
|
491
490
|
target,
|
|
492
491
|
normalizeTimeout(config.proverTimeoutMs)
|
|
493
492
|
);
|
|
@@ -499,7 +498,7 @@ function createRemoteProver(config, fallbackTimeout) {
|
|
|
499
498
|
if (!url) {
|
|
500
499
|
throw new Error("Remote prover requires a URL");
|
|
501
500
|
}
|
|
502
|
-
return
|
|
501
|
+
return import_miden_sdk5.TransactionProver.newRemoteProver(
|
|
503
502
|
url,
|
|
504
503
|
normalizeTimeout(timeoutMs ?? fallbackTimeout)
|
|
505
504
|
);
|
|
@@ -535,13 +534,7 @@ function isPrivateStorageMode(storageMode) {
|
|
|
535
534
|
return storageMode.toString() === "private";
|
|
536
535
|
}
|
|
537
536
|
async function initializeSignerAccount(client, config) {
|
|
538
|
-
const {
|
|
539
|
-
AccountBuilder,
|
|
540
|
-
AccountComponent,
|
|
541
|
-
AuthScheme: AuthScheme2,
|
|
542
|
-
Word: Word2,
|
|
543
|
-
resolveAuthScheme: resolveAuthScheme5
|
|
544
|
-
} = await import("@miden-sdk/miden-sdk");
|
|
537
|
+
const { AccountBuilder, AccountComponent, AuthScheme: AuthScheme2, Word: Word2 } = await import("@miden-sdk/miden-sdk");
|
|
545
538
|
await client.syncState();
|
|
546
539
|
if (config.importAccountId) {
|
|
547
540
|
const accountId2 = parseAccountId(config.importAccountId);
|
|
@@ -562,7 +555,7 @@ async function initializeSignerAccount(client, config) {
|
|
|
562
555
|
let builder = new AccountBuilder(seed).withAuthComponent(
|
|
563
556
|
AccountComponent.createAuthComponentFromCommitment(
|
|
564
557
|
commitmentWord,
|
|
565
|
-
|
|
558
|
+
AuthScheme2.AuthEcdsaK256Keccak
|
|
566
559
|
)
|
|
567
560
|
).accountType(accountType).storageMode(config.storageMode).withBasicWalletComponent();
|
|
568
561
|
if (config.customComponents?.length) {
|
|
@@ -635,20 +628,15 @@ function MidenProvider({
|
|
|
635
628
|
}),
|
|
636
629
|
[config]
|
|
637
630
|
);
|
|
638
|
-
const
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
resolvedConfig.prover,
|
|
648
|
-
resolvedConfig.proverTimeoutMs,
|
|
649
|
-
resolvedConfig.proverUrls?.devnet,
|
|
650
|
-
resolvedConfig.proverUrls?.testnet
|
|
651
|
-
]);
|
|
631
|
+
const defaultProver = (0, import_react2.useMemo)(
|
|
632
|
+
() => resolveTransactionProver(resolvedConfig),
|
|
633
|
+
[
|
|
634
|
+
resolvedConfig.prover,
|
|
635
|
+
resolvedConfig.proverTimeoutMs,
|
|
636
|
+
resolvedConfig.proverUrls?.devnet,
|
|
637
|
+
resolvedConfig.proverUrls?.testnet
|
|
638
|
+
]
|
|
639
|
+
);
|
|
652
640
|
const runExclusive = (0, import_react2.useCallback)(
|
|
653
641
|
async (fn) => clientLockRef.current.runExclusive(fn),
|
|
654
642
|
[]
|
|
@@ -727,7 +715,7 @@ function MidenProvider({
|
|
|
727
715
|
if (signerContext && signerIsConnected === true) {
|
|
728
716
|
const storeName = `MidenClientDB_${signerContext.storeName}`;
|
|
729
717
|
signCbRef.current = signerContext.signCb;
|
|
730
|
-
webClient = await
|
|
718
|
+
webClient = await import_miden_sdk6.WasmWebClient.createClientWithExternalKeystore(
|
|
731
719
|
resolvedConfig.rpcUrl,
|
|
732
720
|
resolvedConfig.noteTransportUrl,
|
|
733
721
|
resolvedConfig.seed,
|
|
@@ -747,7 +735,7 @@ function MidenProvider({
|
|
|
747
735
|
currentStoreNameRef.current = signerContext.storeName;
|
|
748
736
|
} else {
|
|
749
737
|
const seed = resolvedConfig.seed;
|
|
750
|
-
webClient = await
|
|
738
|
+
webClient = await import_miden_sdk6.WasmWebClient.createClient(
|
|
751
739
|
resolvedConfig.rpcUrl,
|
|
752
740
|
resolvedConfig.noteTransportUrl,
|
|
753
741
|
seed
|
|
@@ -1091,7 +1079,7 @@ var import_react6 = require("react");
|
|
|
1091
1079
|
|
|
1092
1080
|
// src/hooks/useAssetMetadata.ts
|
|
1093
1081
|
var import_react5 = require("react");
|
|
1094
|
-
var
|
|
1082
|
+
var import_miden_sdk7 = require("@miden-sdk/miden-sdk");
|
|
1095
1083
|
var inflight = /* @__PURE__ */ new Map();
|
|
1096
1084
|
var rpcClients = /* @__PURE__ */ new Map();
|
|
1097
1085
|
var getRpcClient = (rpcUrl) => {
|
|
@@ -1099,8 +1087,8 @@ var getRpcClient = (rpcUrl) => {
|
|
|
1099
1087
|
const existing = rpcClients.get(key);
|
|
1100
1088
|
if (existing) return existing;
|
|
1101
1089
|
try {
|
|
1102
|
-
const endpoint = rpcUrl ? new
|
|
1103
|
-
const client = new
|
|
1090
|
+
const endpoint = rpcUrl ? new import_miden_sdk7.Endpoint(rpcUrl) : import_miden_sdk7.Endpoint.testnet();
|
|
1091
|
+
const client = new import_miden_sdk7.RpcClient(endpoint);
|
|
1104
1092
|
rpcClients.set(key, client);
|
|
1105
1093
|
return client;
|
|
1106
1094
|
} catch {
|
|
@@ -1114,7 +1102,7 @@ var fetchAssetMetadata = async (rpcClient, assetId) => {
|
|
|
1114
1102
|
const fetched = await rpcClient.getAccountDetails(accountId);
|
|
1115
1103
|
const account = fetched.account?.();
|
|
1116
1104
|
if (!account) return null;
|
|
1117
|
-
const faucet =
|
|
1105
|
+
const faucet = import_miden_sdk7.BasicFungibleFaucetComponent.fromAccount(account);
|
|
1118
1106
|
const symbol = faucet.symbol().toString();
|
|
1119
1107
|
const decimals = faucet.decimals();
|
|
1120
1108
|
return { assetId, symbol, decimals };
|
|
@@ -1240,7 +1228,7 @@ function useAccount(accountId) {
|
|
|
1240
1228
|
|
|
1241
1229
|
// src/hooks/useNotes.ts
|
|
1242
1230
|
var import_react7 = require("react");
|
|
1243
|
-
var
|
|
1231
|
+
var import_miden_sdk9 = require("@miden-sdk/miden-sdk");
|
|
1244
1232
|
|
|
1245
1233
|
// src/utils/amounts.ts
|
|
1246
1234
|
var formatAssetAmount = (amount, decimals) => {
|
|
@@ -1345,30 +1333,30 @@ function accountIdsEqual(a, b) {
|
|
|
1345
1333
|
}
|
|
1346
1334
|
|
|
1347
1335
|
// src/utils/noteFilters.ts
|
|
1348
|
-
var
|
|
1336
|
+
var import_miden_sdk8 = require("@miden-sdk/miden-sdk");
|
|
1349
1337
|
function getNoteFilterType(status) {
|
|
1350
1338
|
switch (status) {
|
|
1351
1339
|
case "consumed":
|
|
1352
|
-
return
|
|
1340
|
+
return import_miden_sdk8.NoteFilterTypes.Consumed;
|
|
1353
1341
|
case "committed":
|
|
1354
|
-
return
|
|
1342
|
+
return import_miden_sdk8.NoteFilterTypes.Committed;
|
|
1355
1343
|
case "expected":
|
|
1356
|
-
return
|
|
1344
|
+
return import_miden_sdk8.NoteFilterTypes.Expected;
|
|
1357
1345
|
case "processing":
|
|
1358
|
-
return
|
|
1346
|
+
return import_miden_sdk8.NoteFilterTypes.Processing;
|
|
1359
1347
|
case "all":
|
|
1360
1348
|
default:
|
|
1361
|
-
return
|
|
1349
|
+
return import_miden_sdk8.NoteFilterTypes.All;
|
|
1362
1350
|
}
|
|
1363
1351
|
}
|
|
1364
1352
|
function getNoteType(type) {
|
|
1365
1353
|
switch (type) {
|
|
1366
1354
|
case "private":
|
|
1367
|
-
return
|
|
1355
|
+
return import_miden_sdk8.NoteType.Private;
|
|
1368
1356
|
case "public":
|
|
1369
|
-
return
|
|
1357
|
+
return import_miden_sdk8.NoteType.Public;
|
|
1370
1358
|
default:
|
|
1371
|
-
return
|
|
1359
|
+
return import_miden_sdk8.NoteType.Private;
|
|
1372
1360
|
}
|
|
1373
1361
|
}
|
|
1374
1362
|
async function waitForTransactionCommit(client, runExclusiveSafe, txIdHex, maxWaitMs = 1e4, delayMs = 1e3) {
|
|
@@ -1377,7 +1365,7 @@ async function waitForTransactionCommit(client, runExclusiveSafe, txIdHex, maxWa
|
|
|
1377
1365
|
while (Date.now() < deadline) {
|
|
1378
1366
|
await runExclusiveSafe(() => client.syncState());
|
|
1379
1367
|
const records = await runExclusiveSafe(
|
|
1380
|
-
() => client.getTransactions(
|
|
1368
|
+
() => client.getTransactions(import_miden_sdk8.TransactionFilter.all())
|
|
1381
1369
|
);
|
|
1382
1370
|
const record = records.find(
|
|
1383
1371
|
(r) => normalizeHex(r.id().toHex()) === targetHex
|
|
@@ -1420,7 +1408,7 @@ function useNotes(options) {
|
|
|
1420
1408
|
setError(null);
|
|
1421
1409
|
try {
|
|
1422
1410
|
const filterType = getNoteFilterType(options?.status);
|
|
1423
|
-
const filter = new
|
|
1411
|
+
const filter = new import_miden_sdk9.NoteFilter(filterType);
|
|
1424
1412
|
const fetchedNotes = await client.getInputNotes(filter);
|
|
1425
1413
|
let fetchedConsumable;
|
|
1426
1414
|
if (options?.accountId) {
|
|
@@ -1542,10 +1530,10 @@ function useNotes(options) {
|
|
|
1542
1530
|
|
|
1543
1531
|
// src/hooks/useNoteStream.ts
|
|
1544
1532
|
var import_react8 = require("react");
|
|
1545
|
-
var
|
|
1533
|
+
var import_miden_sdk11 = require("@miden-sdk/miden-sdk");
|
|
1546
1534
|
|
|
1547
1535
|
// src/utils/noteAttachment.ts
|
|
1548
|
-
var
|
|
1536
|
+
var import_miden_sdk10 = require("@miden-sdk/miden-sdk");
|
|
1549
1537
|
function readNoteAttachment(note) {
|
|
1550
1538
|
try {
|
|
1551
1539
|
const metadata = note.metadata?.();
|
|
@@ -1554,8 +1542,8 @@ function readNoteAttachment(note) {
|
|
|
1554
1542
|
if (!attachment) return null;
|
|
1555
1543
|
const kind = attachment.kind?.();
|
|
1556
1544
|
if (!kind) return null;
|
|
1557
|
-
if (kind ===
|
|
1558
|
-
if (kind ===
|
|
1545
|
+
if (kind === import_miden_sdk10.NoteAttachmentKind.None) return null;
|
|
1546
|
+
if (kind === import_miden_sdk10.NoteAttachmentKind.Word) {
|
|
1559
1547
|
const word = attachment.asWord?.();
|
|
1560
1548
|
if (!word) return null;
|
|
1561
1549
|
const u64s = word.toU64s();
|
|
@@ -1564,7 +1552,7 @@ function readNoteAttachment(note) {
|
|
|
1564
1552
|
);
|
|
1565
1553
|
return { values, kind: "word" };
|
|
1566
1554
|
}
|
|
1567
|
-
if (kind ===
|
|
1555
|
+
if (kind === import_miden_sdk10.NoteAttachmentKind.Array) {
|
|
1568
1556
|
const arr = attachment.asArray?.();
|
|
1569
1557
|
if (!arr) return null;
|
|
1570
1558
|
const u64s = arr.toU64s();
|
|
@@ -1584,30 +1572,30 @@ function createNoteAttachment(values) {
|
|
|
1584
1572
|
bigints.push(BigInt(values[i]));
|
|
1585
1573
|
}
|
|
1586
1574
|
if (bigints.length === 0) {
|
|
1587
|
-
return new
|
|
1575
|
+
return new import_miden_sdk10.NoteAttachment();
|
|
1588
1576
|
}
|
|
1589
|
-
const scheme =
|
|
1577
|
+
const scheme = import_miden_sdk10.NoteAttachmentScheme.none();
|
|
1590
1578
|
if (bigints.length <= 4) {
|
|
1591
1579
|
while (bigints.length < 4) {
|
|
1592
1580
|
bigints.push(0n);
|
|
1593
1581
|
}
|
|
1594
|
-
const word = new
|
|
1595
|
-
return
|
|
1582
|
+
const word = new import_miden_sdk10.Word(BigUint64Array.from(bigints));
|
|
1583
|
+
return import_miden_sdk10.NoteAttachment.newWord(scheme, word);
|
|
1596
1584
|
}
|
|
1597
1585
|
while (bigints.length % 4 !== 0) {
|
|
1598
1586
|
bigints.push(0n);
|
|
1599
1587
|
}
|
|
1600
1588
|
const words = [];
|
|
1601
1589
|
for (let i = 0; i < bigints.length; i += 4) {
|
|
1602
|
-
words.push(new
|
|
1590
|
+
words.push(new import_miden_sdk10.Word(BigUint64Array.from(bigints.slice(i, i + 4))));
|
|
1603
1591
|
}
|
|
1604
|
-
const newArray =
|
|
1592
|
+
const newArray = import_miden_sdk10.NoteAttachment["newArray"];
|
|
1605
1593
|
if (typeof newArray !== "function") {
|
|
1606
1594
|
throw new Error(
|
|
1607
1595
|
"NoteAttachment.newArray is not available. Ensure @miden-sdk/miden-sdk >= 0.13.1."
|
|
1608
1596
|
);
|
|
1609
1597
|
}
|
|
1610
|
-
return newArray.call(
|
|
1598
|
+
return newArray.call(import_miden_sdk10.NoteAttachment, scheme, words);
|
|
1611
1599
|
}
|
|
1612
1600
|
|
|
1613
1601
|
// src/hooks/useNoteStream.ts
|
|
@@ -1642,7 +1630,7 @@ function useNoteStream(options = {}) {
|
|
|
1642
1630
|
setError(null);
|
|
1643
1631
|
try {
|
|
1644
1632
|
const filterType = getNoteFilterType(status);
|
|
1645
|
-
const filter = new
|
|
1633
|
+
const filter = new import_miden_sdk11.NoteFilter(filterType);
|
|
1646
1634
|
const fetched = await client.getInputNotes(filter);
|
|
1647
1635
|
setNotesIfChanged(fetched);
|
|
1648
1636
|
} catch (err) {
|
|
@@ -1754,7 +1742,7 @@ function buildStreamedNote(record, noteFirstSeen) {
|
|
|
1754
1742
|
|
|
1755
1743
|
// src/hooks/useTransactionHistory.ts
|
|
1756
1744
|
var import_react9 = require("react");
|
|
1757
|
-
var
|
|
1745
|
+
var import_miden_sdk12 = require("@miden-sdk/miden-sdk");
|
|
1758
1746
|
function useTransactionHistory(options = {}) {
|
|
1759
1747
|
const { client, isReady } = useMiden();
|
|
1760
1748
|
const { lastSyncTime } = useSyncStateStore();
|
|
@@ -1829,14 +1817,14 @@ function buildFilter(filter, ids, idsHex) {
|
|
|
1829
1817
|
return { filter };
|
|
1830
1818
|
}
|
|
1831
1819
|
if (!ids || ids.length === 0) {
|
|
1832
|
-
return { filter:
|
|
1820
|
+
return { filter: import_miden_sdk12.TransactionFilter.all() };
|
|
1833
1821
|
}
|
|
1834
1822
|
const allTransactionIds = ids.every((id) => typeof id !== "string");
|
|
1835
1823
|
if (allTransactionIds) {
|
|
1836
|
-
return { filter:
|
|
1824
|
+
return { filter: import_miden_sdk12.TransactionFilter.ids(ids) };
|
|
1837
1825
|
}
|
|
1838
1826
|
return {
|
|
1839
|
-
filter:
|
|
1827
|
+
filter: import_miden_sdk12.TransactionFilter.all(),
|
|
1840
1828
|
localFilterHexes: idsHex ?? []
|
|
1841
1829
|
};
|
|
1842
1830
|
}
|
|
@@ -1862,7 +1850,7 @@ function useSyncState() {
|
|
|
1862
1850
|
|
|
1863
1851
|
// src/hooks/useCreateWallet.ts
|
|
1864
1852
|
var import_react11 = require("react");
|
|
1865
|
-
var
|
|
1853
|
+
var import_miden_sdk13 = require("@miden-sdk/miden-sdk");
|
|
1866
1854
|
|
|
1867
1855
|
// src/utils/runExclusive.ts
|
|
1868
1856
|
var runExclusiveDirect = async (fn) => fn();
|
|
@@ -1887,9 +1875,7 @@ function useCreateWallet() {
|
|
|
1887
1875
|
options.storageMode ?? DEFAULTS.STORAGE_MODE
|
|
1888
1876
|
);
|
|
1889
1877
|
const mutable = options.mutable ?? DEFAULTS.WALLET_MUTABLE;
|
|
1890
|
-
const authScheme =
|
|
1891
|
-
options.authScheme ?? DEFAULTS.AUTH_SCHEME
|
|
1892
|
-
);
|
|
1878
|
+
const authScheme = options.authScheme ?? DEFAULTS.AUTH_SCHEME;
|
|
1893
1879
|
const newWallet = await runExclusiveSafe(async () => {
|
|
1894
1880
|
const createdWallet = await client.newWallet(
|
|
1895
1881
|
storageMode,
|
|
@@ -1930,19 +1916,19 @@ function useCreateWallet() {
|
|
|
1930
1916
|
function getStorageMode(mode) {
|
|
1931
1917
|
switch (mode) {
|
|
1932
1918
|
case "private":
|
|
1933
|
-
return
|
|
1919
|
+
return import_miden_sdk13.AccountStorageMode.private();
|
|
1934
1920
|
case "public":
|
|
1935
|
-
return
|
|
1921
|
+
return import_miden_sdk13.AccountStorageMode.public();
|
|
1936
1922
|
case "network":
|
|
1937
|
-
return
|
|
1923
|
+
return import_miden_sdk13.AccountStorageMode.network();
|
|
1938
1924
|
default:
|
|
1939
|
-
return
|
|
1925
|
+
return import_miden_sdk13.AccountStorageMode.private();
|
|
1940
1926
|
}
|
|
1941
1927
|
}
|
|
1942
1928
|
|
|
1943
1929
|
// src/hooks/useCreateFaucet.ts
|
|
1944
1930
|
var import_react12 = require("react");
|
|
1945
|
-
var
|
|
1931
|
+
var import_miden_sdk14 = require("@miden-sdk/miden-sdk");
|
|
1946
1932
|
function useCreateFaucet() {
|
|
1947
1933
|
const { client, isReady, runExclusive } = useMiden();
|
|
1948
1934
|
const runExclusiveSafe = runExclusive ?? runExclusiveDirect;
|
|
@@ -1962,9 +1948,7 @@ function useCreateFaucet() {
|
|
|
1962
1948
|
options.storageMode ?? DEFAULTS.STORAGE_MODE
|
|
1963
1949
|
);
|
|
1964
1950
|
const decimals = options.decimals ?? DEFAULTS.FAUCET_DECIMALS;
|
|
1965
|
-
const authScheme =
|
|
1966
|
-
options.authScheme ?? DEFAULTS.AUTH_SCHEME
|
|
1967
|
-
);
|
|
1951
|
+
const authScheme = options.authScheme ?? DEFAULTS.AUTH_SCHEME;
|
|
1968
1952
|
const newFaucet = await runExclusiveSafe(async () => {
|
|
1969
1953
|
const createdFaucet = await client.newFaucet(
|
|
1970
1954
|
storageMode,
|
|
@@ -2007,19 +1991,19 @@ function useCreateFaucet() {
|
|
|
2007
1991
|
function getStorageMode2(mode) {
|
|
2008
1992
|
switch (mode) {
|
|
2009
1993
|
case "private":
|
|
2010
|
-
return
|
|
1994
|
+
return import_miden_sdk14.AccountStorageMode.private();
|
|
2011
1995
|
case "public":
|
|
2012
|
-
return
|
|
1996
|
+
return import_miden_sdk14.AccountStorageMode.public();
|
|
2013
1997
|
case "network":
|
|
2014
|
-
return
|
|
1998
|
+
return import_miden_sdk14.AccountStorageMode.network();
|
|
2015
1999
|
default:
|
|
2016
|
-
return
|
|
2000
|
+
return import_miden_sdk14.AccountStorageMode.private();
|
|
2017
2001
|
}
|
|
2018
2002
|
}
|
|
2019
2003
|
|
|
2020
2004
|
// src/hooks/useImportAccount.ts
|
|
2021
2005
|
var import_react13 = require("react");
|
|
2022
|
-
var
|
|
2006
|
+
var import_miden_sdk15 = require("@miden-sdk/miden-sdk");
|
|
2023
2007
|
|
|
2024
2008
|
// src/utils/errors.ts
|
|
2025
2009
|
var MidenError = class extends Error {
|
|
@@ -2152,9 +2136,7 @@ function useImportAccount() {
|
|
|
2152
2136
|
}
|
|
2153
2137
|
case "seed": {
|
|
2154
2138
|
const mutable = options.mutable ?? DEFAULTS.WALLET_MUTABLE;
|
|
2155
|
-
const authScheme =
|
|
2156
|
-
options.authScheme ?? DEFAULTS.AUTH_SCHEME
|
|
2157
|
-
);
|
|
2139
|
+
const authScheme = options.authScheme ?? DEFAULTS.AUTH_SCHEME;
|
|
2158
2140
|
return await client.importPublicAccountFromSeed(
|
|
2159
2141
|
options.seed,
|
|
2160
2142
|
mutable,
|
|
@@ -2193,10 +2175,10 @@ function useImportAccount() {
|
|
|
2193
2175
|
}
|
|
2194
2176
|
async function resolveAccountFile(file) {
|
|
2195
2177
|
if (file instanceof Uint8Array) {
|
|
2196
|
-
return
|
|
2178
|
+
return import_miden_sdk15.AccountFile.deserialize(file);
|
|
2197
2179
|
}
|
|
2198
2180
|
if (file instanceof ArrayBuffer) {
|
|
2199
|
-
return
|
|
2181
|
+
return import_miden_sdk15.AccountFile.deserialize(new Uint8Array(file));
|
|
2200
2182
|
}
|
|
2201
2183
|
return file;
|
|
2202
2184
|
}
|
|
@@ -2226,7 +2208,7 @@ function bytesEqual(left, right) {
|
|
|
2226
2208
|
|
|
2227
2209
|
// src/hooks/useSend.ts
|
|
2228
2210
|
var import_react14 = require("react");
|
|
2229
|
-
var
|
|
2211
|
+
var import_miden_sdk16 = require("@miden-sdk/miden-sdk");
|
|
2230
2212
|
function useSend() {
|
|
2231
2213
|
const { client, isReady, sync, runExclusive, prover } = useMiden();
|
|
2232
2214
|
const runExclusiveSafe = runExclusive ?? runExclusiveDirect;
|
|
@@ -2293,19 +2275,19 @@ function useSend() {
|
|
|
2293
2275
|
const fromId = parseAccountId(options.from);
|
|
2294
2276
|
const toId = parseAccountId(options.to);
|
|
2295
2277
|
const assetObj = parseAccountId(assetId);
|
|
2296
|
-
const assets = new
|
|
2297
|
-
new
|
|
2278
|
+
const assets = new import_miden_sdk16.NoteAssets([
|
|
2279
|
+
new import_miden_sdk16.FungibleAsset(assetObj, BigInt(amount))
|
|
2298
2280
|
]);
|
|
2299
|
-
const p2idNote =
|
|
2281
|
+
const p2idNote = import_miden_sdk16.Note.createP2IDNote(
|
|
2300
2282
|
fromId,
|
|
2301
2283
|
toId,
|
|
2302
2284
|
assets,
|
|
2303
2285
|
noteType,
|
|
2304
|
-
new
|
|
2286
|
+
new import_miden_sdk16.NoteAttachment()
|
|
2305
2287
|
);
|
|
2306
|
-
const ownOutputs = new
|
|
2288
|
+
const ownOutputs = new import_miden_sdk16.NoteArray();
|
|
2307
2289
|
ownOutputs.push(p2idNote);
|
|
2308
|
-
const txRequest = new
|
|
2290
|
+
const txRequest = new import_miden_sdk16.TransactionRequestBuilder().withOwnOutputNotes(ownOutputs).build();
|
|
2309
2291
|
const execFromId = parseAccountId(options.from);
|
|
2310
2292
|
const txId = prover ? await client.submitNewTransactionWithProver(
|
|
2311
2293
|
execFromId,
|
|
@@ -2326,19 +2308,19 @@ function useSend() {
|
|
|
2326
2308
|
let txRequest;
|
|
2327
2309
|
if (hasAttachment) {
|
|
2328
2310
|
const attachment = createNoteAttachment(options.attachment);
|
|
2329
|
-
const assets = new
|
|
2330
|
-
new
|
|
2311
|
+
const assets = new import_miden_sdk16.NoteAssets([
|
|
2312
|
+
new import_miden_sdk16.FungibleAsset(assetIdObj, amount)
|
|
2331
2313
|
]);
|
|
2332
|
-
const note =
|
|
2314
|
+
const note = import_miden_sdk16.Note.createP2IDNote(
|
|
2333
2315
|
fromAccountId,
|
|
2334
2316
|
toAccountId,
|
|
2335
2317
|
assets,
|
|
2336
2318
|
noteType,
|
|
2337
2319
|
attachment
|
|
2338
2320
|
);
|
|
2339
|
-
txRequest = new
|
|
2321
|
+
txRequest = new import_miden_sdk16.TransactionRequestBuilder().withOwnOutputNotes(new import_miden_sdk16.NoteArray([note])).build();
|
|
2340
2322
|
} else {
|
|
2341
|
-
txRequest = client.newSendTransactionRequest(
|
|
2323
|
+
txRequest = await client.newSendTransactionRequest(
|
|
2342
2324
|
fromAccountId,
|
|
2343
2325
|
toAccountId,
|
|
2344
2326
|
assetIdObj,
|
|
@@ -2355,7 +2337,7 @@ function useSend() {
|
|
|
2355
2337
|
const proverConfig = useMidenStore.getState().config;
|
|
2356
2338
|
const provenTransaction = await proveWithFallback(
|
|
2357
2339
|
(resolvedProver) => runExclusiveSafe(
|
|
2358
|
-
() =>
|
|
2340
|
+
() => client.proveTransaction(txResult, resolvedProver)
|
|
2359
2341
|
),
|
|
2360
2342
|
proverConfig
|
|
2361
2343
|
);
|
|
@@ -2366,13 +2348,13 @@ function useSend() {
|
|
|
2366
2348
|
const txIdHex = txResult.id().toHex();
|
|
2367
2349
|
const txIdString = txResult.id().toString();
|
|
2368
2350
|
let fullNote = null;
|
|
2369
|
-
if (noteType ===
|
|
2351
|
+
if (noteType === import_miden_sdk16.NoteType.Private) {
|
|
2370
2352
|
fullNote = extractFullNote(txResult);
|
|
2371
2353
|
}
|
|
2372
2354
|
await runExclusiveSafe(
|
|
2373
2355
|
() => client.applyTransaction(txResult, submissionHeight)
|
|
2374
2356
|
);
|
|
2375
|
-
if (noteType ===
|
|
2357
|
+
if (noteType === import_miden_sdk16.NoteType.Private) {
|
|
2376
2358
|
if (!fullNote) {
|
|
2377
2359
|
throw new Error("Missing full note for private send");
|
|
2378
2360
|
}
|
|
@@ -2435,7 +2417,7 @@ function extractFullNote(txResult) {
|
|
|
2435
2417
|
|
|
2436
2418
|
// src/hooks/useMultiSend.ts
|
|
2437
2419
|
var import_react15 = require("react");
|
|
2438
|
-
var
|
|
2420
|
+
var import_miden_sdk17 = require("@miden-sdk/miden-sdk");
|
|
2439
2421
|
function useMultiSend() {
|
|
2440
2422
|
const { client, isReady, sync, prover, signerConnected } = useMiden();
|
|
2441
2423
|
const isBusyRef = (0, import_react15.useRef)(false);
|
|
@@ -2472,12 +2454,12 @@ function useMultiSend() {
|
|
|
2472
2454
|
const iterSenderId = parseAccountId(options.from);
|
|
2473
2455
|
const iterAssetId = parseAccountId(options.assetId);
|
|
2474
2456
|
const receiverId = parseAccountId(to);
|
|
2475
|
-
const assets = new
|
|
2476
|
-
new
|
|
2457
|
+
const assets = new import_miden_sdk17.NoteAssets([
|
|
2458
|
+
new import_miden_sdk17.FungibleAsset(iterAssetId, BigInt(amount))
|
|
2477
2459
|
]);
|
|
2478
2460
|
const resolvedNoteType = recipientNoteType ? getNoteType(recipientNoteType) : noteType;
|
|
2479
|
-
const noteAttachment = attachment !== void 0 && attachment !== null ? createNoteAttachment(attachment) : new
|
|
2480
|
-
const note =
|
|
2461
|
+
const noteAttachment = attachment !== void 0 && attachment !== null ? createNoteAttachment(attachment) : new import_miden_sdk17.NoteAttachment();
|
|
2462
|
+
const note = import_miden_sdk17.Note.createP2IDNote(
|
|
2481
2463
|
iterSenderId,
|
|
2482
2464
|
receiverId,
|
|
2483
2465
|
assets,
|
|
@@ -2492,14 +2474,14 @@ function useMultiSend() {
|
|
|
2492
2474
|
};
|
|
2493
2475
|
}
|
|
2494
2476
|
);
|
|
2495
|
-
const txRequest = new
|
|
2477
|
+
const txRequest = new import_miden_sdk17.TransactionRequestBuilder().withOwnOutputNotes(new import_miden_sdk17.NoteArray(outputs.map((o) => o.note))).build();
|
|
2496
2478
|
const txSenderId = parseAccountId(options.from);
|
|
2497
2479
|
const txResult = await client.executeTransaction(txSenderId, txRequest);
|
|
2498
2480
|
setStage("proving");
|
|
2499
2481
|
const proverConfig = useMidenStore.getState().config;
|
|
2500
2482
|
const provenTransaction = await proveWithFallback(
|
|
2501
2483
|
(resolvedProver) => runExclusiveDirect(
|
|
2502
|
-
() =>
|
|
2484
|
+
() => client.proveTransaction(txResult, resolvedProver)
|
|
2503
2485
|
),
|
|
2504
2486
|
proverConfig
|
|
2505
2487
|
);
|
|
@@ -2511,7 +2493,7 @@ function useMultiSend() {
|
|
|
2511
2493
|
const txIdHex = txResult.id().toHex();
|
|
2512
2494
|
const txIdString = txResult.id().toString();
|
|
2513
2495
|
await client.applyTransaction(txResult, submissionHeight);
|
|
2514
|
-
const hasPrivate = outputs.some((o) => o.noteType ===
|
|
2496
|
+
const hasPrivate = outputs.some((o) => o.noteType === import_miden_sdk17.NoteType.Private);
|
|
2515
2497
|
if (hasPrivate) {
|
|
2516
2498
|
await waitForTransactionCommit(
|
|
2517
2499
|
client,
|
|
@@ -2519,7 +2501,7 @@ function useMultiSend() {
|
|
|
2519
2501
|
txIdHex
|
|
2520
2502
|
);
|
|
2521
2503
|
for (const output of outputs) {
|
|
2522
|
-
if (output.noteType ===
|
|
2504
|
+
if (output.noteType === import_miden_sdk17.NoteType.Private) {
|
|
2523
2505
|
await client.sendPrivateNote(
|
|
2524
2506
|
output.note,
|
|
2525
2507
|
output.recipientAddress
|
|
@@ -2562,7 +2544,7 @@ function useMultiSend() {
|
|
|
2562
2544
|
|
|
2563
2545
|
// src/hooks/useWaitForCommit.ts
|
|
2564
2546
|
var import_react16 = require("react");
|
|
2565
|
-
var
|
|
2547
|
+
var import_miden_sdk18 = require("@miden-sdk/miden-sdk");
|
|
2566
2548
|
function useWaitForCommit() {
|
|
2567
2549
|
const { client, isReady } = useMiden();
|
|
2568
2550
|
const waitForCommit = (0, import_react16.useCallback)(
|
|
@@ -2579,7 +2561,7 @@ function useWaitForCommit() {
|
|
|
2579
2561
|
while (Date.now() < deadline) {
|
|
2580
2562
|
await client.syncState();
|
|
2581
2563
|
const records = await client.getTransactions(
|
|
2582
|
-
typeof txId === "string" ?
|
|
2564
|
+
typeof txId === "string" ? import_miden_sdk18.TransactionFilter.all() : import_miden_sdk18.TransactionFilter.ids([txId])
|
|
2583
2565
|
);
|
|
2584
2566
|
const record = records.find(
|
|
2585
2567
|
(item) => normalizeHex3(item.id().toHex()) === targetHex
|
|
@@ -2665,7 +2647,7 @@ function useMint() {
|
|
|
2665
2647
|
const faucetIdObj = parseAccountId(options.faucetId);
|
|
2666
2648
|
setStage("proving");
|
|
2667
2649
|
const txResult = await runExclusiveSafe(async () => {
|
|
2668
|
-
const txRequest = client.newMintTransactionRequest(
|
|
2650
|
+
const txRequest = await client.newMintTransactionRequest(
|
|
2669
2651
|
targetAccountIdObj,
|
|
2670
2652
|
faucetIdObj,
|
|
2671
2653
|
noteType,
|
|
@@ -2711,7 +2693,7 @@ function useMint() {
|
|
|
2711
2693
|
|
|
2712
2694
|
// src/hooks/useConsume.ts
|
|
2713
2695
|
var import_react19 = require("react");
|
|
2714
|
-
var
|
|
2696
|
+
var import_miden_sdk19 = require("@miden-sdk/miden-sdk");
|
|
2715
2697
|
function useConsume() {
|
|
2716
2698
|
const { client, isReady, sync, runExclusive, prover } = useMiden();
|
|
2717
2699
|
const runExclusiveSafe = runExclusive ?? runExclusiveDirect;
|
|
@@ -2741,7 +2723,7 @@ function useConsume() {
|
|
|
2741
2723
|
const item = options.notes[i];
|
|
2742
2724
|
if (typeof item === "string") {
|
|
2743
2725
|
lookupIndices.push(i);
|
|
2744
|
-
lookupIds.push(
|
|
2726
|
+
lookupIds.push(import_miden_sdk19.NoteId.fromHex(item));
|
|
2745
2727
|
} else if (item !== null && typeof item === "object" && typeof item.toNote === "function") {
|
|
2746
2728
|
resolved[i] = item.toNote();
|
|
2747
2729
|
} else if (item !== null && typeof item === "object" && typeof item.id === "function") {
|
|
@@ -2752,7 +2734,7 @@ function useConsume() {
|
|
|
2752
2734
|
}
|
|
2753
2735
|
}
|
|
2754
2736
|
if (lookupIds.length > 0) {
|
|
2755
|
-
const filter = new
|
|
2737
|
+
const filter = new import_miden_sdk19.NoteFilter(import_miden_sdk19.NoteFilterTypes.List, lookupIds);
|
|
2756
2738
|
const noteRecords = await client.getInputNotes(filter);
|
|
2757
2739
|
if (noteRecords.length !== lookupIds.length) {
|
|
2758
2740
|
throw new Error("Some notes could not be found for provided IDs");
|
|
@@ -2771,12 +2753,6 @@ function useConsume() {
|
|
|
2771
2753
|
}
|
|
2772
2754
|
}
|
|
2773
2755
|
const notes = resolved;
|
|
2774
|
-
if (notes.length === 0) {
|
|
2775
|
-
throw new Error("No notes found for provided IDs");
|
|
2776
|
-
}
|
|
2777
|
-
if (notes.length !== options.notes.length) {
|
|
2778
|
-
throw new Error("Some notes could not be found for provided IDs");
|
|
2779
|
-
}
|
|
2780
2756
|
const txRequest = client.newConsumeTransactionRequest(notes);
|
|
2781
2757
|
const txId = prover ? await client.submitNewTransactionWithProver(
|
|
2782
2758
|
accountIdObj,
|
|
@@ -2843,7 +2819,7 @@ function useSwap() {
|
|
|
2843
2819
|
const requestedFaucetIdObj = parseAccountId(options.requestedFaucetId);
|
|
2844
2820
|
setStage("proving");
|
|
2845
2821
|
const txResult = await runExclusiveSafe(async () => {
|
|
2846
|
-
const txRequest = client.newSwapTransactionRequest(
|
|
2822
|
+
const txRequest = await client.newSwapTransactionRequest(
|
|
2847
2823
|
accountIdObj,
|
|
2848
2824
|
offeredFaucetIdObj,
|
|
2849
2825
|
BigInt(options.offeredAmount),
|
|
@@ -2894,13 +2870,13 @@ function useSwap() {
|
|
|
2894
2870
|
var import_react21 = require("react");
|
|
2895
2871
|
|
|
2896
2872
|
// src/utils/transactions.ts
|
|
2897
|
-
var
|
|
2873
|
+
var import_miden_sdk20 = require("@miden-sdk/miden-sdk");
|
|
2898
2874
|
async function waitForTransactionCommit2(client, runExclusiveSafe, txId, maxWaitMs = 1e4, delayMs = 1e3) {
|
|
2899
2875
|
let waited = 0;
|
|
2900
2876
|
while (waited < maxWaitMs) {
|
|
2901
2877
|
await runExclusiveSafe(() => client.syncState());
|
|
2902
2878
|
const [record] = await runExclusiveSafe(
|
|
2903
|
-
() => client.getTransactions(
|
|
2879
|
+
() => client.getTransactions(import_miden_sdk20.TransactionFilter.ids([txId]))
|
|
2904
2880
|
);
|
|
2905
2881
|
if (record) {
|
|
2906
2882
|
const status = record.transactionStatus();
|
|
@@ -2922,7 +2898,7 @@ function extractFullNotes(txResult) {
|
|
|
2922
2898
|
const notes = executedTx?.outputNotes?.().notes?.() ?? [];
|
|
2923
2899
|
const result = [];
|
|
2924
2900
|
for (const note of notes) {
|
|
2925
|
-
if (note.noteType?.() ===
|
|
2901
|
+
if (note.noteType?.() === import_miden_sdk20.NoteType.Private) {
|
|
2926
2902
|
const full = note.intoFull?.();
|
|
2927
2903
|
if (full) result.push(full);
|
|
2928
2904
|
}
|
|
@@ -2970,7 +2946,7 @@ function useTransaction() {
|
|
|
2970
2946
|
const proverConfig = useMidenStore.getState().config;
|
|
2971
2947
|
const provenTransaction = await proveWithFallback(
|
|
2972
2948
|
(resolvedProver) => runExclusiveSafe(
|
|
2973
|
-
() =>
|
|
2949
|
+
() => client.proveTransaction(txResult, resolvedProver)
|
|
2974
2950
|
),
|
|
2975
2951
|
proverConfig
|
|
2976
2952
|
);
|
|
@@ -3033,7 +3009,7 @@ async function resolveRequest(request, client) {
|
|
|
3033
3009
|
|
|
3034
3010
|
// src/hooks/useExecuteProgram.ts
|
|
3035
3011
|
var import_react22 = require("react");
|
|
3036
|
-
var
|
|
3012
|
+
var import_miden_sdk21 = require("@miden-sdk/miden-sdk");
|
|
3037
3013
|
function isForeignAccountWrapper(fa) {
|
|
3038
3014
|
return fa !== null && typeof fa === "object" && "id" in fa && typeof fa.id !== "function";
|
|
3039
3015
|
}
|
|
@@ -3064,18 +3040,18 @@ function useExecuteProgram() {
|
|
|
3064
3040
|
}
|
|
3065
3041
|
const programResult = await runExclusiveSafe(async () => {
|
|
3066
3042
|
const accountIdObj = parseAccountId(options.accountId);
|
|
3067
|
-
const adviceInputs = options.adviceInputs ?? new
|
|
3043
|
+
const adviceInputs = options.adviceInputs ?? new import_miden_sdk21.AdviceInputs();
|
|
3068
3044
|
let foreignAccountsArray;
|
|
3069
3045
|
if (options.foreignAccounts?.length) {
|
|
3070
3046
|
const accounts = options.foreignAccounts.map((fa) => {
|
|
3071
3047
|
const wrapper = isForeignAccountWrapper(fa);
|
|
3072
3048
|
const id = parseAccountId(wrapper ? fa.id : fa);
|
|
3073
|
-
const storage = wrapper && fa.storage ? fa.storage : new
|
|
3074
|
-
return
|
|
3049
|
+
const storage = wrapper && fa.storage ? fa.storage : new import_miden_sdk21.AccountStorageRequirements();
|
|
3050
|
+
return import_miden_sdk21.ForeignAccount.public(id, storage);
|
|
3075
3051
|
});
|
|
3076
|
-
foreignAccountsArray = new
|
|
3052
|
+
foreignAccountsArray = new import_miden_sdk21.ForeignAccountArray(accounts);
|
|
3077
3053
|
} else {
|
|
3078
|
-
foreignAccountsArray = new
|
|
3054
|
+
foreignAccountsArray = new import_miden_sdk21.ForeignAccountArray();
|
|
3079
3055
|
}
|
|
3080
3056
|
const feltArray = await client.executeProgram(
|
|
3081
3057
|
accountIdObj,
|
|
@@ -3119,11 +3095,11 @@ function useExecuteProgram() {
|
|
|
3119
3095
|
|
|
3120
3096
|
// src/hooks/useCompile.ts
|
|
3121
3097
|
var import_react23 = require("react");
|
|
3122
|
-
var
|
|
3098
|
+
var import_miden_sdk22 = require("@miden-sdk/miden-sdk");
|
|
3123
3099
|
function useCompile() {
|
|
3124
3100
|
const { client, isReady } = useMiden();
|
|
3125
3101
|
const resource = (0, import_react23.useMemo)(
|
|
3126
|
-
() => client && isReady ? new
|
|
3102
|
+
() => client && isReady ? new import_miden_sdk22.CompilerResource(client, import_miden_sdk22.getWasmOrThrow) : null,
|
|
3127
3103
|
[client, isReady]
|
|
3128
3104
|
);
|
|
3129
3105
|
const requireResource = (0, import_react23.useCallback)(() => {
|
|
@@ -3149,7 +3125,7 @@ function useCompile() {
|
|
|
3149
3125
|
|
|
3150
3126
|
// src/hooks/useSessionAccount.ts
|
|
3151
3127
|
var import_react24 = require("react");
|
|
3152
|
-
var
|
|
3128
|
+
var import_miden_sdk23 = require("@miden-sdk/miden-sdk");
|
|
3153
3129
|
function useSessionAccount(options) {
|
|
3154
3130
|
const { client, isReady, sync } = useMiden();
|
|
3155
3131
|
const setAccounts = useMidenStore((state) => state.setAccounts);
|
|
@@ -3163,9 +3139,7 @@ function useSessionAccount(options) {
|
|
|
3163
3139
|
const maxWaitMs = options.maxWaitMs ?? 6e4;
|
|
3164
3140
|
const storageMode = options.walletOptions?.storageMode ?? "public";
|
|
3165
3141
|
const mutable = options.walletOptions?.mutable ?? DEFAULTS.WALLET_MUTABLE;
|
|
3166
|
-
const authScheme =
|
|
3167
|
-
options.walletOptions?.authScheme ?? DEFAULTS.AUTH_SCHEME
|
|
3168
|
-
);
|
|
3142
|
+
const authScheme = options.walletOptions?.authScheme ?? DEFAULTS.AUTH_SCHEME;
|
|
3169
3143
|
const fundRef = (0, import_react24.useRef)(options.fund);
|
|
3170
3144
|
fundRef.current = options.fund;
|
|
3171
3145
|
(0, import_react24.useEffect)(() => {
|
|
@@ -3275,11 +3249,11 @@ function useSessionAccount(options) {
|
|
|
3275
3249
|
function getStorageMode3(mode) {
|
|
3276
3250
|
switch (mode) {
|
|
3277
3251
|
case "private":
|
|
3278
|
-
return
|
|
3252
|
+
return import_miden_sdk23.AccountStorageMode.private();
|
|
3279
3253
|
case "public":
|
|
3280
|
-
return
|
|
3254
|
+
return import_miden_sdk23.AccountStorageMode.public();
|
|
3281
3255
|
default:
|
|
3282
|
-
return
|
|
3256
|
+
return import_miden_sdk23.AccountStorageMode.public();
|
|
3283
3257
|
}
|
|
3284
3258
|
}
|
|
3285
3259
|
async function waitAndConsume(client, walletId, pollIntervalMs, maxWaitMs, cancelledRef) {
|
|
@@ -3304,7 +3278,7 @@ async function waitAndConsume(client, walletId, pollIntervalMs, maxWaitMs, cance
|
|
|
3304
3278
|
|
|
3305
3279
|
// src/hooks/useExportStore.ts
|
|
3306
3280
|
var import_react25 = require("react");
|
|
3307
|
-
var
|
|
3281
|
+
var import_miden_sdk24 = require("@miden-sdk/miden-sdk");
|
|
3308
3282
|
function useExportStore() {
|
|
3309
3283
|
const { client, isReady, runExclusive } = useMiden();
|
|
3310
3284
|
const [isExporting, setIsExporting] = (0, import_react25.useState)(false);
|
|
@@ -3316,8 +3290,8 @@ function useExportStore() {
|
|
|
3316
3290
|
setIsExporting(true);
|
|
3317
3291
|
setError(null);
|
|
3318
3292
|
try {
|
|
3319
|
-
const storeName = client.storeIdentifier();
|
|
3320
|
-
const snapshot = await runExclusive(() => (0,
|
|
3293
|
+
const storeName = await client.storeIdentifier();
|
|
3294
|
+
const snapshot = await runExclusive(() => (0, import_miden_sdk24.exportStore)(storeName));
|
|
3321
3295
|
return snapshot;
|
|
3322
3296
|
} catch (err) {
|
|
3323
3297
|
const error2 = err instanceof Error ? err : new Error(String(err));
|
|
@@ -3341,7 +3315,7 @@ function useExportStore() {
|
|
|
3341
3315
|
|
|
3342
3316
|
// src/hooks/useImportStore.ts
|
|
3343
3317
|
var import_react26 = require("react");
|
|
3344
|
-
var
|
|
3318
|
+
var import_miden_sdk25 = require("@miden-sdk/miden-sdk");
|
|
3345
3319
|
function useImportStore() {
|
|
3346
3320
|
const { client, isReady, runExclusive, sync } = useMiden();
|
|
3347
3321
|
const [isImporting, setIsImporting] = (0, import_react26.useState)(false);
|
|
@@ -3354,7 +3328,7 @@ function useImportStore() {
|
|
|
3354
3328
|
setIsImporting(true);
|
|
3355
3329
|
setError(null);
|
|
3356
3330
|
try {
|
|
3357
|
-
await runExclusive(() => (0,
|
|
3331
|
+
await runExclusive(() => (0, import_miden_sdk25.importStore)(storeName, storeDump));
|
|
3358
3332
|
if (!options?.skipSync) {
|
|
3359
3333
|
await sync();
|
|
3360
3334
|
}
|
|
@@ -3382,7 +3356,7 @@ function useImportStore() {
|
|
|
3382
3356
|
|
|
3383
3357
|
// src/hooks/useImportNote.ts
|
|
3384
3358
|
var import_react27 = require("react");
|
|
3385
|
-
var
|
|
3359
|
+
var import_miden_sdk26 = require("@miden-sdk/miden-sdk");
|
|
3386
3360
|
function useImportNote() {
|
|
3387
3361
|
const { client, isReady, runExclusive, sync } = useMiden();
|
|
3388
3362
|
const [isImporting, setIsImporting] = (0, import_react27.useState)(false);
|
|
@@ -3395,7 +3369,7 @@ function useImportNote() {
|
|
|
3395
3369
|
setIsImporting(true);
|
|
3396
3370
|
setError(null);
|
|
3397
3371
|
try {
|
|
3398
|
-
const noteFile =
|
|
3372
|
+
const noteFile = import_miden_sdk26.NoteFile.deserialize(noteBytes);
|
|
3399
3373
|
const noteId = await runExclusive(
|
|
3400
3374
|
() => client.importNoteFile(noteFile)
|
|
3401
3375
|
);
|
|
@@ -3425,7 +3399,7 @@ function useImportNote() {
|
|
|
3425
3399
|
|
|
3426
3400
|
// src/hooks/useExportNote.ts
|
|
3427
3401
|
var import_react28 = require("react");
|
|
3428
|
-
var
|
|
3402
|
+
var import_miden_sdk27 = require("@miden-sdk/miden-sdk");
|
|
3429
3403
|
function useExportNote() {
|
|
3430
3404
|
const { client, isReady, runExclusive } = useMiden();
|
|
3431
3405
|
const [isExporting, setIsExporting] = (0, import_react28.useState)(false);
|
|
@@ -3439,7 +3413,7 @@ function useExportNote() {
|
|
|
3439
3413
|
setError(null);
|
|
3440
3414
|
try {
|
|
3441
3415
|
const noteFile = await runExclusive(
|
|
3442
|
-
() => client.exportNoteFile(noteId,
|
|
3416
|
+
() => client.exportNoteFile(noteId, import_miden_sdk27.NoteExportFormat.Full)
|
|
3443
3417
|
);
|
|
3444
3418
|
return noteFile.serialize();
|
|
3445
3419
|
} catch (err) {
|
|
@@ -3643,9 +3617,11 @@ installAccountBech32();
|
|
|
3643
3617
|
concatBytes,
|
|
3644
3618
|
createMidenStorage,
|
|
3645
3619
|
createNoteAttachment,
|
|
3620
|
+
ensureAccountBech32,
|
|
3646
3621
|
formatAssetAmount,
|
|
3647
3622
|
formatNoteSummary,
|
|
3648
3623
|
getNoteSummary,
|
|
3624
|
+
installAccountBech32,
|
|
3649
3625
|
migrateStorage,
|
|
3650
3626
|
normalizeAccountId,
|
|
3651
3627
|
parseAssetAmount,
|