@miden-sdk/react 0.13.3 → 0.14.0-alpha
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/dist/index.d.mts +13 -13
- package/dist/index.d.ts +13 -13
- package/dist/index.js +103 -108
- package/dist/index.mjs +16 -22
- package/package.json +9 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import * as react from 'react';
|
|
3
3
|
import { ReactNode } from 'react';
|
|
4
|
-
import { AccountStorageMode, AccountComponent, Account, AccountHeader, AccountId, TransactionRequest,
|
|
5
|
-
export { Account, AccountFile, AccountHeader, AccountId, AccountStorageMode, ConsumableNoteRecord, InputNoteRecord, NoteType, TransactionFilter, TransactionId, TransactionRecord, TransactionRequest, WebClient } from '@miden-sdk/miden-sdk';
|
|
4
|
+
import { AccountStorageMode, AccountComponent, Account, AccountHeader, AuthScheme, AccountId, TransactionRequest, WasmWebClient, AccountFile, InputNoteRecord, ConsumableNoteRecord, TransactionId, TransactionFilter, TransactionRecord, TransactionProver, NoteAttachment } from '@miden-sdk/miden-sdk';
|
|
5
|
+
export { Account, AccountFile, AccountHeader, AccountId, AccountStorageMode, AuthScheme, ConsumableNoteRecord, InputNoteRecord, NoteType, TransactionFilter, TransactionId, TransactionRecord, TransactionRequest, WasmWebClient as WebClient } from '@miden-sdk/miden-sdk';
|
|
6
6
|
|
|
7
7
|
declare module "@miden-sdk/miden-sdk" {
|
|
8
8
|
interface Account {
|
|
@@ -112,7 +112,7 @@ interface MidenConfig {
|
|
|
112
112
|
proverTimeoutMs?: number | bigint;
|
|
113
113
|
}
|
|
114
114
|
interface MidenState {
|
|
115
|
-
client:
|
|
115
|
+
client: WasmWebClient | null;
|
|
116
116
|
isReady: boolean;
|
|
117
117
|
isInitializing: boolean;
|
|
118
118
|
error: Error | null;
|
|
@@ -219,8 +219,8 @@ interface CreateWalletOptions {
|
|
|
219
219
|
storageMode?: "private" | "public" | "network";
|
|
220
220
|
/** Whether code can be updated. Default: true */
|
|
221
221
|
mutable?: boolean;
|
|
222
|
-
/** Auth scheme
|
|
223
|
-
authScheme?:
|
|
222
|
+
/** Auth scheme. Default: AuthScheme.AuthRpoFalcon512 */
|
|
223
|
+
authScheme?: AuthScheme;
|
|
224
224
|
/** Initial seed for deterministic account ID */
|
|
225
225
|
initSeed?: Uint8Array;
|
|
226
226
|
}
|
|
@@ -233,8 +233,8 @@ interface CreateFaucetOptions {
|
|
|
233
233
|
maxSupply: bigint;
|
|
234
234
|
/** Storage mode. Default: private */
|
|
235
235
|
storageMode?: "private" | "public" | "network";
|
|
236
|
-
/** Auth scheme
|
|
237
|
-
authScheme?:
|
|
236
|
+
/** Auth scheme. Default: AuthScheme.AuthRpoFalcon512 */
|
|
237
|
+
authScheme?: AuthScheme;
|
|
238
238
|
}
|
|
239
239
|
type ImportAccountOptions = {
|
|
240
240
|
type: "file";
|
|
@@ -246,7 +246,7 @@ type ImportAccountOptions = {
|
|
|
246
246
|
type: "seed";
|
|
247
247
|
seed: Uint8Array;
|
|
248
248
|
mutable?: boolean;
|
|
249
|
-
authScheme?:
|
|
249
|
+
authScheme?: AuthScheme;
|
|
250
250
|
};
|
|
251
251
|
interface SendOptions {
|
|
252
252
|
/** Sender account ID */
|
|
@@ -373,7 +373,7 @@ interface ExecuteTransactionOptions {
|
|
|
373
373
|
/** Account ID the transaction applies to */
|
|
374
374
|
accountId: string | AccountId;
|
|
375
375
|
/** Transaction request or builder */
|
|
376
|
-
request: TransactionRequest | ((client:
|
|
376
|
+
request: TransactionRequest | ((client: WasmWebClient) => TransactionRequest | Promise<TransactionRequest>);
|
|
377
377
|
/** Skip auto-sync before transaction. Default: false */
|
|
378
378
|
skipSync?: boolean;
|
|
379
379
|
}
|
|
@@ -434,7 +434,7 @@ interface UseSessionAccountOptions {
|
|
|
434
434
|
walletOptions?: {
|
|
435
435
|
storageMode?: "private" | "public";
|
|
436
436
|
mutable?: boolean;
|
|
437
|
-
authScheme?:
|
|
437
|
+
authScheme?: AuthScheme;
|
|
438
438
|
};
|
|
439
439
|
/** Polling interval for funding note detection (ms). Default: 3000 */
|
|
440
440
|
pollIntervalMs?: number;
|
|
@@ -463,7 +463,7 @@ declare const DEFAULTS: {
|
|
|
463
463
|
readonly AUTO_SYNC_INTERVAL: 15000;
|
|
464
464
|
readonly STORAGE_MODE: "private";
|
|
465
465
|
readonly WALLET_MUTABLE: true;
|
|
466
|
-
readonly AUTH_SCHEME:
|
|
466
|
+
readonly AUTH_SCHEME: AuthScheme.AuthRpoFalcon512;
|
|
467
467
|
readonly NOTE_TYPE: "private";
|
|
468
468
|
readonly FAUCET_DECIMALS: 8;
|
|
469
469
|
};
|
|
@@ -472,7 +472,7 @@ type ProverConfigSubset = Pick<MidenConfig, "prover" | "proverUrls" | "proverTim
|
|
|
472
472
|
declare function resolveTransactionProver(config: ProverConfigSubset): TransactionProver | null;
|
|
473
473
|
|
|
474
474
|
interface MidenContextValue {
|
|
475
|
-
client:
|
|
475
|
+
client: WasmWebClient | null;
|
|
476
476
|
isReady: boolean;
|
|
477
477
|
isInitializing: boolean;
|
|
478
478
|
error: Error | null;
|
|
@@ -492,7 +492,7 @@ interface MidenProviderProps {
|
|
|
492
492
|
}
|
|
493
493
|
declare function MidenProvider({ children, config, loadingComponent, errorComponent, }: MidenProviderProps): react_jsx_runtime.JSX.Element;
|
|
494
494
|
declare function useMiden(): MidenContextValue;
|
|
495
|
-
declare function useMidenClient():
|
|
495
|
+
declare function useMidenClient(): WasmWebClient;
|
|
496
496
|
|
|
497
497
|
/**
|
|
498
498
|
* Hook to list all accounts in the client.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import * as react from 'react';
|
|
3
3
|
import { ReactNode } from 'react';
|
|
4
|
-
import { AccountStorageMode, AccountComponent, Account, AccountHeader, AccountId, TransactionRequest,
|
|
5
|
-
export { Account, AccountFile, AccountHeader, AccountId, AccountStorageMode, ConsumableNoteRecord, InputNoteRecord, NoteType, TransactionFilter, TransactionId, TransactionRecord, TransactionRequest, WebClient } from '@miden-sdk/miden-sdk';
|
|
4
|
+
import { AccountStorageMode, AccountComponent, Account, AccountHeader, AuthScheme, AccountId, TransactionRequest, WasmWebClient, AccountFile, InputNoteRecord, ConsumableNoteRecord, TransactionId, TransactionFilter, TransactionRecord, TransactionProver, NoteAttachment } from '@miden-sdk/miden-sdk';
|
|
5
|
+
export { Account, AccountFile, AccountHeader, AccountId, AccountStorageMode, AuthScheme, ConsumableNoteRecord, InputNoteRecord, NoteType, TransactionFilter, TransactionId, TransactionRecord, TransactionRequest, WasmWebClient as WebClient } from '@miden-sdk/miden-sdk';
|
|
6
6
|
|
|
7
7
|
declare module "@miden-sdk/miden-sdk" {
|
|
8
8
|
interface Account {
|
|
@@ -112,7 +112,7 @@ interface MidenConfig {
|
|
|
112
112
|
proverTimeoutMs?: number | bigint;
|
|
113
113
|
}
|
|
114
114
|
interface MidenState {
|
|
115
|
-
client:
|
|
115
|
+
client: WasmWebClient | null;
|
|
116
116
|
isReady: boolean;
|
|
117
117
|
isInitializing: boolean;
|
|
118
118
|
error: Error | null;
|
|
@@ -219,8 +219,8 @@ interface CreateWalletOptions {
|
|
|
219
219
|
storageMode?: "private" | "public" | "network";
|
|
220
220
|
/** Whether code can be updated. Default: true */
|
|
221
221
|
mutable?: boolean;
|
|
222
|
-
/** Auth scheme
|
|
223
|
-
authScheme?:
|
|
222
|
+
/** Auth scheme. Default: AuthScheme.AuthRpoFalcon512 */
|
|
223
|
+
authScheme?: AuthScheme;
|
|
224
224
|
/** Initial seed for deterministic account ID */
|
|
225
225
|
initSeed?: Uint8Array;
|
|
226
226
|
}
|
|
@@ -233,8 +233,8 @@ interface CreateFaucetOptions {
|
|
|
233
233
|
maxSupply: bigint;
|
|
234
234
|
/** Storage mode. Default: private */
|
|
235
235
|
storageMode?: "private" | "public" | "network";
|
|
236
|
-
/** Auth scheme
|
|
237
|
-
authScheme?:
|
|
236
|
+
/** Auth scheme. Default: AuthScheme.AuthRpoFalcon512 */
|
|
237
|
+
authScheme?: AuthScheme;
|
|
238
238
|
}
|
|
239
239
|
type ImportAccountOptions = {
|
|
240
240
|
type: "file";
|
|
@@ -246,7 +246,7 @@ type ImportAccountOptions = {
|
|
|
246
246
|
type: "seed";
|
|
247
247
|
seed: Uint8Array;
|
|
248
248
|
mutable?: boolean;
|
|
249
|
-
authScheme?:
|
|
249
|
+
authScheme?: AuthScheme;
|
|
250
250
|
};
|
|
251
251
|
interface SendOptions {
|
|
252
252
|
/** Sender account ID */
|
|
@@ -373,7 +373,7 @@ interface ExecuteTransactionOptions {
|
|
|
373
373
|
/** Account ID the transaction applies to */
|
|
374
374
|
accountId: string | AccountId;
|
|
375
375
|
/** Transaction request or builder */
|
|
376
|
-
request: TransactionRequest | ((client:
|
|
376
|
+
request: TransactionRequest | ((client: WasmWebClient) => TransactionRequest | Promise<TransactionRequest>);
|
|
377
377
|
/** Skip auto-sync before transaction. Default: false */
|
|
378
378
|
skipSync?: boolean;
|
|
379
379
|
}
|
|
@@ -434,7 +434,7 @@ interface UseSessionAccountOptions {
|
|
|
434
434
|
walletOptions?: {
|
|
435
435
|
storageMode?: "private" | "public";
|
|
436
436
|
mutable?: boolean;
|
|
437
|
-
authScheme?:
|
|
437
|
+
authScheme?: AuthScheme;
|
|
438
438
|
};
|
|
439
439
|
/** Polling interval for funding note detection (ms). Default: 3000 */
|
|
440
440
|
pollIntervalMs?: number;
|
|
@@ -463,7 +463,7 @@ declare const DEFAULTS: {
|
|
|
463
463
|
readonly AUTO_SYNC_INTERVAL: 15000;
|
|
464
464
|
readonly STORAGE_MODE: "private";
|
|
465
465
|
readonly WALLET_MUTABLE: true;
|
|
466
|
-
readonly AUTH_SCHEME:
|
|
466
|
+
readonly AUTH_SCHEME: AuthScheme.AuthRpoFalcon512;
|
|
467
467
|
readonly NOTE_TYPE: "private";
|
|
468
468
|
readonly FAUCET_DECIMALS: 8;
|
|
469
469
|
};
|
|
@@ -472,7 +472,7 @@ type ProverConfigSubset = Pick<MidenConfig, "prover" | "proverUrls" | "proverTim
|
|
|
472
472
|
declare function resolveTransactionProver(config: ProverConfigSubset): TransactionProver | null;
|
|
473
473
|
|
|
474
474
|
interface MidenContextValue {
|
|
475
|
-
client:
|
|
475
|
+
client: WasmWebClient | null;
|
|
476
476
|
isReady: boolean;
|
|
477
477
|
isInitializing: boolean;
|
|
478
478
|
error: Error | null;
|
|
@@ -492,7 +492,7 @@ interface MidenProviderProps {
|
|
|
492
492
|
}
|
|
493
493
|
declare function MidenProvider({ children, config, loadingComponent, errorComponent, }: MidenProviderProps): react_jsx_runtime.JSX.Element;
|
|
494
494
|
declare function useMiden(): MidenContextValue;
|
|
495
|
-
declare function useMidenClient():
|
|
495
|
+
declare function useMidenClient(): WasmWebClient;
|
|
496
496
|
|
|
497
497
|
/**
|
|
498
498
|
* Hook to list all accounts in the client.
|
package/dist/index.js
CHANGED
|
@@ -30,6 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/index.ts
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
|
+
AuthScheme: () => import_miden_sdk4.AuthScheme,
|
|
33
34
|
DEFAULTS: () => DEFAULTS,
|
|
34
35
|
MidenError: () => MidenError,
|
|
35
36
|
MidenProvider: () => MidenProvider,
|
|
@@ -354,16 +355,17 @@ var toBech32AccountId = (accountId) => {
|
|
|
354
355
|
|
|
355
356
|
// src/context/MidenProvider.tsx
|
|
356
357
|
var import_react2 = require("react");
|
|
357
|
-
var
|
|
358
|
+
var import_miden_sdk6 = require("@miden-sdk/miden-sdk");
|
|
358
359
|
|
|
359
360
|
// src/types/index.ts
|
|
361
|
+
var import_miden_sdk4 = require("@miden-sdk/miden-sdk");
|
|
360
362
|
var DEFAULTS = {
|
|
361
363
|
RPC_URL: void 0,
|
|
362
364
|
// Will use SDK's testnet default
|
|
363
365
|
AUTO_SYNC_INTERVAL: 15e3,
|
|
364
366
|
STORAGE_MODE: "private",
|
|
365
367
|
WALLET_MUTABLE: true,
|
|
366
|
-
AUTH_SCHEME:
|
|
368
|
+
AUTH_SCHEME: import_miden_sdk4.AuthScheme.AuthRpoFalcon512,
|
|
367
369
|
NOTE_TYPE: "private",
|
|
368
370
|
FAUCET_DECIMALS: 8
|
|
369
371
|
};
|
|
@@ -407,7 +409,7 @@ function resolveRpcUrl(rpcUrl) {
|
|
|
407
409
|
}
|
|
408
410
|
|
|
409
411
|
// src/utils/prover.ts
|
|
410
|
-
var
|
|
412
|
+
var import_miden_sdk5 = require("@miden-sdk/miden-sdk");
|
|
411
413
|
var DEFAULT_PROVER_URLS = {
|
|
412
414
|
devnet: "https://tx-prover.devnet.miden.io",
|
|
413
415
|
testnet: "https://tx-prover.testnet.miden.io"
|
|
@@ -420,19 +422,19 @@ function resolveTransactionProver(config) {
|
|
|
420
422
|
if (typeof prover === "string") {
|
|
421
423
|
const normalized = prover.trim().toLowerCase();
|
|
422
424
|
if (normalized === "local") {
|
|
423
|
-
return
|
|
425
|
+
return import_miden_sdk5.TransactionProver.newLocalProver();
|
|
424
426
|
}
|
|
425
427
|
if (normalized === "devnet" || normalized === "testnet") {
|
|
426
428
|
const url = config.proverUrls?.[normalized] ?? DEFAULT_PROVER_URLS[normalized] ?? null;
|
|
427
429
|
if (!url) {
|
|
428
430
|
throw new Error(`Missing ${normalized} prover URL`);
|
|
429
431
|
}
|
|
430
|
-
return
|
|
432
|
+
return import_miden_sdk5.TransactionProver.newRemoteProver(
|
|
431
433
|
url,
|
|
432
434
|
normalizeTimeout(config.proverTimeoutMs)
|
|
433
435
|
);
|
|
434
436
|
}
|
|
435
|
-
return
|
|
437
|
+
return import_miden_sdk5.TransactionProver.newRemoteProver(
|
|
436
438
|
prover,
|
|
437
439
|
normalizeTimeout(config.proverTimeoutMs)
|
|
438
440
|
);
|
|
@@ -444,7 +446,7 @@ function createRemoteProver(config, fallbackTimeout) {
|
|
|
444
446
|
if (!url) {
|
|
445
447
|
throw new Error("Remote prover requires a URL");
|
|
446
448
|
}
|
|
447
|
-
return
|
|
449
|
+
return import_miden_sdk5.TransactionProver.newRemoteProver(
|
|
448
450
|
url,
|
|
449
451
|
normalizeTimeout(timeoutMs ?? fallbackTimeout)
|
|
450
452
|
);
|
|
@@ -467,35 +469,28 @@ function useSigner() {
|
|
|
467
469
|
}
|
|
468
470
|
|
|
469
471
|
// src/utils/signerAccount.ts
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
return AccountType.FungibleFaucet;
|
|
479
|
-
case "NonFungibleFaucet":
|
|
480
|
-
return AccountType.NonFungibleFaucet;
|
|
481
|
-
default:
|
|
482
|
-
return AccountType.RegularAccountImmutableCode;
|
|
483
|
-
}
|
|
472
|
+
var WASM_ACCOUNT_TYPE = {
|
|
473
|
+
FungibleFaucet: 0,
|
|
474
|
+
NonFungibleFaucet: 1,
|
|
475
|
+
RegularAccountImmutableCode: 2,
|
|
476
|
+
RegularAccountUpdatableCode: 3
|
|
477
|
+
};
|
|
478
|
+
function getAccountType(accountType) {
|
|
479
|
+
return WASM_ACCOUNT_TYPE[accountType] ?? WASM_ACCOUNT_TYPE.RegularAccountImmutableCode;
|
|
484
480
|
}
|
|
485
481
|
function isPrivateStorageMode(storageMode) {
|
|
486
482
|
return storageMode.toString() === "private";
|
|
487
483
|
}
|
|
488
484
|
async function initializeSignerAccount(client, config) {
|
|
489
|
-
const { AccountBuilder, AccountComponent, Word: Word2 } = await import("@miden-sdk/miden-sdk");
|
|
485
|
+
const { AccountBuilder, AccountComponent, AuthScheme: AuthScheme2, Word: Word2 } = await import("@miden-sdk/miden-sdk");
|
|
490
486
|
await client.syncState();
|
|
491
487
|
const commitmentWord = Word2.deserialize(config.publicKeyCommitment);
|
|
492
488
|
const seed = config.accountSeed ?? crypto.getRandomValues(new Uint8Array(32));
|
|
493
|
-
const accountType =
|
|
489
|
+
const accountType = getAccountType(config.accountType);
|
|
494
490
|
let builder = new AccountBuilder(seed).withAuthComponent(
|
|
495
491
|
AccountComponent.createAuthComponentFromCommitment(
|
|
496
492
|
commitmentWord,
|
|
497
|
-
|
|
498
|
-
// ECDSA auth scheme (K256/Keccak)
|
|
493
|
+
AuthScheme2.AuthEcdsaK256Keccak
|
|
499
494
|
)
|
|
500
495
|
).accountType(accountType).storageMode(config.storageMode).withBasicWalletComponent();
|
|
501
496
|
if (config.customComponents?.length) {
|
|
@@ -623,7 +618,7 @@ function MidenProvider({
|
|
|
623
618
|
let didSignerInit = false;
|
|
624
619
|
if (signerContext && signerContext.isConnected) {
|
|
625
620
|
const storeName = `MidenClientDB_${signerContext.storeName}`;
|
|
626
|
-
webClient = await
|
|
621
|
+
webClient = await import_miden_sdk6.WasmWebClient.createClientWithExternalKeystore(
|
|
627
622
|
resolvedConfig.rpcUrl,
|
|
628
623
|
resolvedConfig.noteTransportUrl,
|
|
629
624
|
resolvedConfig.seed,
|
|
@@ -644,7 +639,7 @@ function MidenProvider({
|
|
|
644
639
|
didSignerInit = true;
|
|
645
640
|
} else {
|
|
646
641
|
const seed = resolvedConfig.seed;
|
|
647
|
-
webClient = await
|
|
642
|
+
webClient = await import_miden_sdk6.WasmWebClient.createClient(
|
|
648
643
|
resolvedConfig.rpcUrl,
|
|
649
644
|
resolvedConfig.noteTransportUrl,
|
|
650
645
|
seed
|
|
@@ -810,7 +805,7 @@ var import_react5 = require("react");
|
|
|
810
805
|
|
|
811
806
|
// src/hooks/useAssetMetadata.ts
|
|
812
807
|
var import_react4 = require("react");
|
|
813
|
-
var
|
|
808
|
+
var import_miden_sdk7 = require("@miden-sdk/miden-sdk");
|
|
814
809
|
var inflight = /* @__PURE__ */ new Map();
|
|
815
810
|
var rpcClients = /* @__PURE__ */ new Map();
|
|
816
811
|
var getRpcClient = (rpcUrl) => {
|
|
@@ -818,8 +813,8 @@ var getRpcClient = (rpcUrl) => {
|
|
|
818
813
|
const existing = rpcClients.get(key);
|
|
819
814
|
if (existing) return existing;
|
|
820
815
|
try {
|
|
821
|
-
const endpoint = rpcUrl ? new
|
|
822
|
-
const client = new
|
|
816
|
+
const endpoint = rpcUrl ? new import_miden_sdk7.Endpoint(rpcUrl) : import_miden_sdk7.Endpoint.testnet();
|
|
817
|
+
const client = new import_miden_sdk7.RpcClient(endpoint);
|
|
823
818
|
rpcClients.set(key, client);
|
|
824
819
|
return client;
|
|
825
820
|
} catch {
|
|
@@ -833,7 +828,7 @@ var fetchAssetMetadata = async (rpcClient, assetId) => {
|
|
|
833
828
|
const fetched = await rpcClient.getAccountDetails(accountId);
|
|
834
829
|
const account = fetched.account?.();
|
|
835
830
|
if (!account) return null;
|
|
836
|
-
const faucet =
|
|
831
|
+
const faucet = import_miden_sdk7.BasicFungibleFaucetComponent.fromAccount(account);
|
|
837
832
|
const symbol = faucet.symbol().toString();
|
|
838
833
|
const decimals = faucet.decimals();
|
|
839
834
|
return { assetId, symbol, decimals };
|
|
@@ -965,7 +960,7 @@ function useAccount(accountId) {
|
|
|
965
960
|
|
|
966
961
|
// src/hooks/useNotes.ts
|
|
967
962
|
var import_react6 = require("react");
|
|
968
|
-
var
|
|
963
|
+
var import_miden_sdk9 = require("@miden-sdk/miden-sdk");
|
|
969
964
|
|
|
970
965
|
// src/utils/amounts.ts
|
|
971
966
|
var formatAssetAmount = (amount, decimals) => {
|
|
@@ -1069,30 +1064,30 @@ function accountIdsEqual(a, b) {
|
|
|
1069
1064
|
}
|
|
1070
1065
|
|
|
1071
1066
|
// src/utils/noteFilters.ts
|
|
1072
|
-
var
|
|
1067
|
+
var import_miden_sdk8 = require("@miden-sdk/miden-sdk");
|
|
1073
1068
|
function getNoteFilterType(status) {
|
|
1074
1069
|
switch (status) {
|
|
1075
1070
|
case "consumed":
|
|
1076
|
-
return
|
|
1071
|
+
return import_miden_sdk8.NoteFilterTypes.Consumed;
|
|
1077
1072
|
case "committed":
|
|
1078
|
-
return
|
|
1073
|
+
return import_miden_sdk8.NoteFilterTypes.Committed;
|
|
1079
1074
|
case "expected":
|
|
1080
|
-
return
|
|
1075
|
+
return import_miden_sdk8.NoteFilterTypes.Expected;
|
|
1081
1076
|
case "processing":
|
|
1082
|
-
return
|
|
1077
|
+
return import_miden_sdk8.NoteFilterTypes.Processing;
|
|
1083
1078
|
case "all":
|
|
1084
1079
|
default:
|
|
1085
|
-
return
|
|
1080
|
+
return import_miden_sdk8.NoteFilterTypes.All;
|
|
1086
1081
|
}
|
|
1087
1082
|
}
|
|
1088
1083
|
function getNoteType(type) {
|
|
1089
1084
|
switch (type) {
|
|
1090
1085
|
case "private":
|
|
1091
|
-
return
|
|
1086
|
+
return import_miden_sdk8.NoteType.Private;
|
|
1092
1087
|
case "public":
|
|
1093
|
-
return
|
|
1088
|
+
return import_miden_sdk8.NoteType.Public;
|
|
1094
1089
|
default:
|
|
1095
|
-
return
|
|
1090
|
+
return import_miden_sdk8.NoteType.Private;
|
|
1096
1091
|
}
|
|
1097
1092
|
}
|
|
1098
1093
|
async function waitForTransactionCommit(client, runExclusiveSafe, txIdHex, maxWaitMs = 1e4, delayMs = 1e3) {
|
|
@@ -1101,7 +1096,7 @@ async function waitForTransactionCommit(client, runExclusiveSafe, txIdHex, maxWa
|
|
|
1101
1096
|
while (Date.now() < deadline) {
|
|
1102
1097
|
await runExclusiveSafe(() => client.syncState());
|
|
1103
1098
|
const records = await runExclusiveSafe(
|
|
1104
|
-
() => client.getTransactions(
|
|
1099
|
+
() => client.getTransactions(import_miden_sdk8.TransactionFilter.all())
|
|
1105
1100
|
);
|
|
1106
1101
|
const record = records.find(
|
|
1107
1102
|
(r) => normalizeHex(r.id().toHex()) === targetHex
|
|
@@ -1147,7 +1142,7 @@ function useNotes(options) {
|
|
|
1147
1142
|
const { fetchedNotes, fetchedConsumable } = await runExclusiveSafe(
|
|
1148
1143
|
async () => {
|
|
1149
1144
|
const filterType = getNoteFilterType(options?.status);
|
|
1150
|
-
const filter = new
|
|
1145
|
+
const filter = new import_miden_sdk9.NoteFilter(filterType);
|
|
1151
1146
|
const notesResult = await client.getInputNotes(filter);
|
|
1152
1147
|
let consumableResult;
|
|
1153
1148
|
if (options?.accountId) {
|
|
@@ -1276,10 +1271,10 @@ function useNotes(options) {
|
|
|
1276
1271
|
|
|
1277
1272
|
// src/hooks/useNoteStream.ts
|
|
1278
1273
|
var import_react7 = require("react");
|
|
1279
|
-
var
|
|
1274
|
+
var import_miden_sdk11 = require("@miden-sdk/miden-sdk");
|
|
1280
1275
|
|
|
1281
1276
|
// src/utils/noteAttachment.ts
|
|
1282
|
-
var
|
|
1277
|
+
var import_miden_sdk10 = require("@miden-sdk/miden-sdk");
|
|
1283
1278
|
function readNoteAttachment(note) {
|
|
1284
1279
|
try {
|
|
1285
1280
|
const metadata = note.metadata?.();
|
|
@@ -1288,8 +1283,8 @@ function readNoteAttachment(note) {
|
|
|
1288
1283
|
if (!attachment) return null;
|
|
1289
1284
|
const kind = attachment.kind?.();
|
|
1290
1285
|
if (!kind) return null;
|
|
1291
|
-
if (kind ===
|
|
1292
|
-
if (kind ===
|
|
1286
|
+
if (kind === import_miden_sdk10.NoteAttachmentKind.None) return null;
|
|
1287
|
+
if (kind === import_miden_sdk10.NoteAttachmentKind.Word) {
|
|
1293
1288
|
const word = attachment.asWord?.();
|
|
1294
1289
|
if (!word) return null;
|
|
1295
1290
|
const u64s = word.toU64s();
|
|
@@ -1298,7 +1293,7 @@ function readNoteAttachment(note) {
|
|
|
1298
1293
|
);
|
|
1299
1294
|
return { values, kind: "word" };
|
|
1300
1295
|
}
|
|
1301
|
-
if (kind ===
|
|
1296
|
+
if (kind === import_miden_sdk10.NoteAttachmentKind.Array) {
|
|
1302
1297
|
const arr = attachment.asArray?.();
|
|
1303
1298
|
if (!arr) return null;
|
|
1304
1299
|
const u64s = arr.toU64s();
|
|
@@ -1318,30 +1313,30 @@ function createNoteAttachment(values) {
|
|
|
1318
1313
|
bigints.push(BigInt(values[i]));
|
|
1319
1314
|
}
|
|
1320
1315
|
if (bigints.length === 0) {
|
|
1321
|
-
return new
|
|
1316
|
+
return new import_miden_sdk10.NoteAttachment();
|
|
1322
1317
|
}
|
|
1323
|
-
const scheme =
|
|
1318
|
+
const scheme = import_miden_sdk10.NoteAttachmentScheme.none();
|
|
1324
1319
|
if (bigints.length <= 4) {
|
|
1325
1320
|
while (bigints.length < 4) {
|
|
1326
1321
|
bigints.push(0n);
|
|
1327
1322
|
}
|
|
1328
|
-
const word = new
|
|
1329
|
-
return
|
|
1323
|
+
const word = new import_miden_sdk10.Word(BigUint64Array.from(bigints));
|
|
1324
|
+
return import_miden_sdk10.NoteAttachment.newWord(scheme, word);
|
|
1330
1325
|
}
|
|
1331
1326
|
while (bigints.length % 4 !== 0) {
|
|
1332
1327
|
bigints.push(0n);
|
|
1333
1328
|
}
|
|
1334
1329
|
const words = [];
|
|
1335
1330
|
for (let i = 0; i < bigints.length; i += 4) {
|
|
1336
|
-
words.push(new
|
|
1331
|
+
words.push(new import_miden_sdk10.Word(BigUint64Array.from(bigints.slice(i, i + 4))));
|
|
1337
1332
|
}
|
|
1338
|
-
const newArray =
|
|
1333
|
+
const newArray = import_miden_sdk10.NoteAttachment["newArray"];
|
|
1339
1334
|
if (typeof newArray !== "function") {
|
|
1340
1335
|
throw new Error(
|
|
1341
1336
|
"NoteAttachment.newArray is not available. Ensure @miden-sdk/miden-sdk >= 0.13.1."
|
|
1342
1337
|
);
|
|
1343
1338
|
}
|
|
1344
|
-
return newArray.call(
|
|
1339
|
+
return newArray.call(import_miden_sdk10.NoteAttachment, scheme, words);
|
|
1345
1340
|
}
|
|
1346
1341
|
|
|
1347
1342
|
// src/hooks/useNoteStream.ts
|
|
@@ -1377,7 +1372,7 @@ function useNoteStream(options = {}) {
|
|
|
1377
1372
|
setError(null);
|
|
1378
1373
|
try {
|
|
1379
1374
|
const filterType = getNoteFilterType(status);
|
|
1380
|
-
const filter = new
|
|
1375
|
+
const filter = new import_miden_sdk11.NoteFilter(filterType);
|
|
1381
1376
|
const fetched = await runExclusiveSafe(
|
|
1382
1377
|
() => client.getInputNotes(filter)
|
|
1383
1378
|
);
|
|
@@ -1491,7 +1486,7 @@ function buildStreamedNote(record, noteFirstSeen) {
|
|
|
1491
1486
|
|
|
1492
1487
|
// src/hooks/useTransactionHistory.ts
|
|
1493
1488
|
var import_react8 = require("react");
|
|
1494
|
-
var
|
|
1489
|
+
var import_miden_sdk12 = require("@miden-sdk/miden-sdk");
|
|
1495
1490
|
function useTransactionHistory(options = {}) {
|
|
1496
1491
|
const { client, isReady, runExclusive } = useMiden();
|
|
1497
1492
|
const runExclusiveSafe = runExclusive ?? runExclusiveDirect;
|
|
@@ -1569,14 +1564,14 @@ function buildFilter(filter, ids, idsHex) {
|
|
|
1569
1564
|
return { filter };
|
|
1570
1565
|
}
|
|
1571
1566
|
if (!ids || ids.length === 0) {
|
|
1572
|
-
return { filter:
|
|
1567
|
+
return { filter: import_miden_sdk12.TransactionFilter.all() };
|
|
1573
1568
|
}
|
|
1574
1569
|
const allTransactionIds = ids.every((id) => typeof id !== "string");
|
|
1575
1570
|
if (allTransactionIds) {
|
|
1576
|
-
return { filter:
|
|
1571
|
+
return { filter: import_miden_sdk12.TransactionFilter.ids(ids) };
|
|
1577
1572
|
}
|
|
1578
1573
|
return {
|
|
1579
|
-
filter:
|
|
1574
|
+
filter: import_miden_sdk12.TransactionFilter.all(),
|
|
1580
1575
|
localFilterHexes: idsHex ?? []
|
|
1581
1576
|
};
|
|
1582
1577
|
}
|
|
@@ -1602,9 +1597,9 @@ function useSyncState() {
|
|
|
1602
1597
|
|
|
1603
1598
|
// src/hooks/useCreateWallet.ts
|
|
1604
1599
|
var import_react10 = require("react");
|
|
1605
|
-
var
|
|
1600
|
+
var import_miden_sdk13 = require("@miden-sdk/miden-sdk");
|
|
1606
1601
|
function useCreateWallet() {
|
|
1607
|
-
const { client, isReady,
|
|
1602
|
+
const { client, isReady, runExclusive } = useMiden();
|
|
1608
1603
|
const runExclusiveSafe = runExclusive ?? runExclusiveDirect;
|
|
1609
1604
|
const setAccounts = useMidenStore((state) => state.setAccounts);
|
|
1610
1605
|
const [wallet, setWallet] = (0, import_react10.useState)(null);
|
|
@@ -1615,7 +1610,6 @@ function useCreateWallet() {
|
|
|
1615
1610
|
if (!client || !isReady) {
|
|
1616
1611
|
throw new Error("Miden client is not ready");
|
|
1617
1612
|
}
|
|
1618
|
-
await sync();
|
|
1619
1613
|
setIsCreating(true);
|
|
1620
1614
|
setError(null);
|
|
1621
1615
|
try {
|
|
@@ -1664,19 +1658,19 @@ function useCreateWallet() {
|
|
|
1664
1658
|
function getStorageMode(mode) {
|
|
1665
1659
|
switch (mode) {
|
|
1666
1660
|
case "private":
|
|
1667
|
-
return
|
|
1661
|
+
return import_miden_sdk13.AccountStorageMode.private();
|
|
1668
1662
|
case "public":
|
|
1669
|
-
return
|
|
1663
|
+
return import_miden_sdk13.AccountStorageMode.public();
|
|
1670
1664
|
case "network":
|
|
1671
|
-
return
|
|
1665
|
+
return import_miden_sdk13.AccountStorageMode.network();
|
|
1672
1666
|
default:
|
|
1673
|
-
return
|
|
1667
|
+
return import_miden_sdk13.AccountStorageMode.private();
|
|
1674
1668
|
}
|
|
1675
1669
|
}
|
|
1676
1670
|
|
|
1677
1671
|
// src/hooks/useCreateFaucet.ts
|
|
1678
1672
|
var import_react11 = require("react");
|
|
1679
|
-
var
|
|
1673
|
+
var import_miden_sdk14 = require("@miden-sdk/miden-sdk");
|
|
1680
1674
|
function useCreateFaucet() {
|
|
1681
1675
|
const { client, isReady, runExclusive } = useMiden();
|
|
1682
1676
|
const runExclusiveSafe = runExclusive ?? runExclusiveDirect;
|
|
@@ -1739,19 +1733,19 @@ function useCreateFaucet() {
|
|
|
1739
1733
|
function getStorageMode2(mode) {
|
|
1740
1734
|
switch (mode) {
|
|
1741
1735
|
case "private":
|
|
1742
|
-
return
|
|
1736
|
+
return import_miden_sdk14.AccountStorageMode.private();
|
|
1743
1737
|
case "public":
|
|
1744
|
-
return
|
|
1738
|
+
return import_miden_sdk14.AccountStorageMode.public();
|
|
1745
1739
|
case "network":
|
|
1746
|
-
return
|
|
1740
|
+
return import_miden_sdk14.AccountStorageMode.network();
|
|
1747
1741
|
default:
|
|
1748
|
-
return
|
|
1742
|
+
return import_miden_sdk14.AccountStorageMode.private();
|
|
1749
1743
|
}
|
|
1750
1744
|
}
|
|
1751
1745
|
|
|
1752
1746
|
// src/hooks/useImportAccount.ts
|
|
1753
1747
|
var import_react12 = require("react");
|
|
1754
|
-
var
|
|
1748
|
+
var import_miden_sdk15 = require("@miden-sdk/miden-sdk");
|
|
1755
1749
|
function useImportAccount() {
|
|
1756
1750
|
const { client, isReady, runExclusive } = useMiden();
|
|
1757
1751
|
const runExclusiveSafe = runExclusive ?? runExclusiveDirect;
|
|
@@ -1872,10 +1866,10 @@ function resolveAccountId(accountId) {
|
|
|
1872
1866
|
}
|
|
1873
1867
|
async function resolveAccountFile(file) {
|
|
1874
1868
|
if (file instanceof Uint8Array) {
|
|
1875
|
-
return
|
|
1869
|
+
return import_miden_sdk15.AccountFile.deserialize(file);
|
|
1876
1870
|
}
|
|
1877
1871
|
if (file instanceof ArrayBuffer) {
|
|
1878
|
-
return
|
|
1872
|
+
return import_miden_sdk15.AccountFile.deserialize(new Uint8Array(file));
|
|
1879
1873
|
}
|
|
1880
1874
|
return file;
|
|
1881
1875
|
}
|
|
@@ -1905,7 +1899,7 @@ function bytesEqual(left, right) {
|
|
|
1905
1899
|
|
|
1906
1900
|
// src/hooks/useSend.ts
|
|
1907
1901
|
var import_react13 = require("react");
|
|
1908
|
-
var
|
|
1902
|
+
var import_miden_sdk16 = require("@miden-sdk/miden-sdk");
|
|
1909
1903
|
|
|
1910
1904
|
// src/utils/errors.ts
|
|
1911
1905
|
var MidenError = class extends Error {
|
|
@@ -2020,17 +2014,17 @@ function useSend() {
|
|
|
2020
2014
|
let txRequest;
|
|
2021
2015
|
if (hasAttachment) {
|
|
2022
2016
|
const attachment = createNoteAttachment(options.attachment);
|
|
2023
|
-
const assets = new
|
|
2024
|
-
new
|
|
2017
|
+
const assets = new import_miden_sdk16.NoteAssets([
|
|
2018
|
+
new import_miden_sdk16.FungibleAsset(assetIdObj, amount)
|
|
2025
2019
|
]);
|
|
2026
|
-
const note =
|
|
2020
|
+
const note = import_miden_sdk16.Note.createP2IDNote(
|
|
2027
2021
|
fromAccountId,
|
|
2028
2022
|
toAccountId,
|
|
2029
2023
|
assets,
|
|
2030
2024
|
noteType,
|
|
2031
2025
|
attachment
|
|
2032
2026
|
);
|
|
2033
|
-
txRequest = new
|
|
2027
|
+
txRequest = new import_miden_sdk16.TransactionRequestBuilder().withOwnOutputNotes(new import_miden_sdk16.OutputNoteArray([import_miden_sdk16.OutputNote.full(note)])).build();
|
|
2034
2028
|
} else {
|
|
2035
2029
|
txRequest = client.newSendTransactionRequest(
|
|
2036
2030
|
fromAccountId,
|
|
@@ -2056,13 +2050,13 @@ function useSend() {
|
|
|
2056
2050
|
const txIdHex = txResult.id().toHex();
|
|
2057
2051
|
const txIdString = txResult.id().toString();
|
|
2058
2052
|
let fullNote = null;
|
|
2059
|
-
if (noteType ===
|
|
2053
|
+
if (noteType === import_miden_sdk16.NoteType.Private) {
|
|
2060
2054
|
fullNote = extractFullNote(txResult);
|
|
2061
2055
|
}
|
|
2062
2056
|
await runExclusiveSafe(
|
|
2063
2057
|
() => client.applyTransaction(txResult, submissionHeight)
|
|
2064
2058
|
);
|
|
2065
|
-
if (noteType ===
|
|
2059
|
+
if (noteType === import_miden_sdk16.NoteType.Private) {
|
|
2066
2060
|
if (!fullNote) {
|
|
2067
2061
|
throw new Error("Missing full note for private send");
|
|
2068
2062
|
}
|
|
@@ -2122,7 +2116,7 @@ function extractFullNote(txResult) {
|
|
|
2122
2116
|
|
|
2123
2117
|
// src/hooks/useMultiSend.ts
|
|
2124
2118
|
var import_react14 = require("react");
|
|
2125
|
-
var
|
|
2119
|
+
var import_miden_sdk17 = require("@miden-sdk/miden-sdk");
|
|
2126
2120
|
function useMultiSend() {
|
|
2127
2121
|
const { client, isReady, sync, runExclusive, prover } = useMiden();
|
|
2128
2122
|
const runExclusiveSafe = runExclusive ?? runExclusiveDirect;
|
|
@@ -2159,12 +2153,12 @@ function useMultiSend() {
|
|
|
2159
2153
|
const iterSenderId = parseAccountId(options.from);
|
|
2160
2154
|
const iterAssetId = parseAccountId(options.assetId);
|
|
2161
2155
|
const receiverId = parseAccountId(to);
|
|
2162
|
-
const assets = new
|
|
2163
|
-
new
|
|
2156
|
+
const assets = new import_miden_sdk17.NoteAssets([
|
|
2157
|
+
new import_miden_sdk17.FungibleAsset(iterAssetId, amount)
|
|
2164
2158
|
]);
|
|
2165
2159
|
const resolvedNoteType = recipientNoteType ? getNoteType(recipientNoteType) : noteType;
|
|
2166
|
-
const noteAttachment = attachment !== void 0 && attachment !== null ? createNoteAttachment(attachment) : new
|
|
2167
|
-
const note =
|
|
2160
|
+
const noteAttachment = attachment !== void 0 && attachment !== null ? createNoteAttachment(attachment) : new import_miden_sdk17.NoteAttachment();
|
|
2161
|
+
const note = import_miden_sdk17.Note.createP2IDNote(
|
|
2168
2162
|
iterSenderId,
|
|
2169
2163
|
receiverId,
|
|
2170
2164
|
assets,
|
|
@@ -2173,15 +2167,15 @@ function useMultiSend() {
|
|
|
2173
2167
|
);
|
|
2174
2168
|
const recipientAddress = parseAddress(to, receiverId);
|
|
2175
2169
|
return {
|
|
2176
|
-
outputNote:
|
|
2170
|
+
outputNote: import_miden_sdk17.OutputNote.full(note),
|
|
2177
2171
|
note,
|
|
2178
2172
|
recipientAddress,
|
|
2179
2173
|
noteType: resolvedNoteType
|
|
2180
2174
|
};
|
|
2181
2175
|
}
|
|
2182
2176
|
);
|
|
2183
|
-
const txRequest = new
|
|
2184
|
-
new
|
|
2177
|
+
const txRequest = new import_miden_sdk17.TransactionRequestBuilder().withOwnOutputNotes(
|
|
2178
|
+
new import_miden_sdk17.OutputNoteArray(outputs.map((o) => o.outputNote))
|
|
2185
2179
|
).build();
|
|
2186
2180
|
const txSenderId = parseAccountId(options.from);
|
|
2187
2181
|
const txResult = await runExclusiveSafe(
|
|
@@ -2200,7 +2194,7 @@ function useMultiSend() {
|
|
|
2200
2194
|
await runExclusiveSafe(
|
|
2201
2195
|
() => client.applyTransaction(txResult, submissionHeight)
|
|
2202
2196
|
);
|
|
2203
|
-
const hasPrivate = outputs.some((o) => o.noteType ===
|
|
2197
|
+
const hasPrivate = outputs.some((o) => o.noteType === import_miden_sdk17.NoteType.Private);
|
|
2204
2198
|
if (hasPrivate) {
|
|
2205
2199
|
await waitForTransactionCommit(
|
|
2206
2200
|
client,
|
|
@@ -2208,7 +2202,7 @@ function useMultiSend() {
|
|
|
2208
2202
|
txIdHex
|
|
2209
2203
|
);
|
|
2210
2204
|
for (const output of outputs) {
|
|
2211
|
-
if (output.noteType ===
|
|
2205
|
+
if (output.noteType === import_miden_sdk17.NoteType.Private) {
|
|
2212
2206
|
await runExclusiveSafe(
|
|
2213
2207
|
() => client.sendPrivateNote(output.note, output.recipientAddress)
|
|
2214
2208
|
);
|
|
@@ -2250,7 +2244,7 @@ function useMultiSend() {
|
|
|
2250
2244
|
|
|
2251
2245
|
// src/hooks/useInternalTransfer.ts
|
|
2252
2246
|
var import_react15 = require("react");
|
|
2253
|
-
var
|
|
2247
|
+
var import_miden_sdk18 = require("@miden-sdk/miden-sdk");
|
|
2254
2248
|
function useInternalTransfer() {
|
|
2255
2249
|
const { client, isReady, sync, runExclusive, prover } = useMiden();
|
|
2256
2250
|
const runExclusiveSafe = runExclusive ?? runExclusiveDirect;
|
|
@@ -2267,18 +2261,18 @@ function useInternalTransfer() {
|
|
|
2267
2261
|
const senderId = parseAccountId(options.from);
|
|
2268
2262
|
const receiverId = parseAccountId(options.to);
|
|
2269
2263
|
const assetId = parseAccountId(options.assetId);
|
|
2270
|
-
const assets = new
|
|
2271
|
-
new
|
|
2264
|
+
const assets = new import_miden_sdk18.NoteAssets([
|
|
2265
|
+
new import_miden_sdk18.FungibleAsset(assetId, options.amount)
|
|
2272
2266
|
]);
|
|
2273
|
-
const note =
|
|
2267
|
+
const note = import_miden_sdk18.Note.createP2IDNote(
|
|
2274
2268
|
senderId,
|
|
2275
2269
|
receiverId,
|
|
2276
2270
|
assets,
|
|
2277
2271
|
noteType,
|
|
2278
|
-
new
|
|
2272
|
+
new import_miden_sdk18.NoteAttachment()
|
|
2279
2273
|
);
|
|
2280
2274
|
const noteId = note.id().toString();
|
|
2281
|
-
const createRequest = new
|
|
2275
|
+
const createRequest = new import_miden_sdk18.TransactionRequestBuilder().withOwnOutputNotes(new import_miden_sdk18.OutputNoteArray([import_miden_sdk18.OutputNote.full(note)])).build();
|
|
2282
2276
|
const createTxId = await runExclusiveSafe(
|
|
2283
2277
|
() => prover ? client.submitNewTransactionWithProver(
|
|
2284
2278
|
senderId,
|
|
@@ -2286,7 +2280,7 @@ function useInternalTransfer() {
|
|
|
2286
2280
|
prover
|
|
2287
2281
|
) : client.submitNewTransaction(senderId, createRequest)
|
|
2288
2282
|
);
|
|
2289
|
-
const consumeRequest = new
|
|
2283
|
+
const consumeRequest = new import_miden_sdk18.TransactionRequestBuilder().withInputNotes(new import_miden_sdk18.NoteAndArgsArray([new import_miden_sdk18.NoteAndArgs(note, null)])).build();
|
|
2290
2284
|
const consumeTxId = await runExclusiveSafe(
|
|
2291
2285
|
() => prover ? client.submitNewTransactionWithProver(
|
|
2292
2286
|
receiverId,
|
|
@@ -2388,7 +2382,7 @@ function useInternalTransfer() {
|
|
|
2388
2382
|
|
|
2389
2383
|
// src/hooks/useWaitForCommit.ts
|
|
2390
2384
|
var import_react16 = require("react");
|
|
2391
|
-
var
|
|
2385
|
+
var import_miden_sdk19 = require("@miden-sdk/miden-sdk");
|
|
2392
2386
|
function useWaitForCommit() {
|
|
2393
2387
|
const { client, isReady, runExclusive } = useMiden();
|
|
2394
2388
|
const runExclusiveSafe = runExclusive ?? runExclusiveDirect;
|
|
@@ -2409,7 +2403,7 @@ function useWaitForCommit() {
|
|
|
2409
2403
|
);
|
|
2410
2404
|
const records = await runExclusiveSafe(
|
|
2411
2405
|
() => client.getTransactions(
|
|
2412
|
-
typeof txId === "string" ?
|
|
2406
|
+
typeof txId === "string" ? import_miden_sdk19.TransactionFilter.all() : import_miden_sdk19.TransactionFilter.ids([txId])
|
|
2413
2407
|
)
|
|
2414
2408
|
);
|
|
2415
2409
|
const record = records.find(
|
|
@@ -2542,7 +2536,7 @@ function useMint() {
|
|
|
2542
2536
|
|
|
2543
2537
|
// src/hooks/useConsume.ts
|
|
2544
2538
|
var import_react19 = require("react");
|
|
2545
|
-
var
|
|
2539
|
+
var import_miden_sdk20 = require("@miden-sdk/miden-sdk");
|
|
2546
2540
|
function useConsume() {
|
|
2547
2541
|
const { client, isReady, sync, runExclusive, prover } = useMiden();
|
|
2548
2542
|
const runExclusiveSafe = runExclusive ?? runExclusiveDirect;
|
|
@@ -2566,9 +2560,9 @@ function useConsume() {
|
|
|
2566
2560
|
setStage("proving");
|
|
2567
2561
|
const txResult = await runExclusiveSafe(async () => {
|
|
2568
2562
|
const noteIds = options.noteIds.map(
|
|
2569
|
-
(noteId) =>
|
|
2563
|
+
(noteId) => import_miden_sdk20.NoteId.fromHex(noteId)
|
|
2570
2564
|
);
|
|
2571
|
-
const filter = new
|
|
2565
|
+
const filter = new import_miden_sdk20.NoteFilter(import_miden_sdk20.NoteFilterTypes.List, noteIds);
|
|
2572
2566
|
const noteRecords = await client.getInputNotes(filter);
|
|
2573
2567
|
const notes = noteRecords.map((record) => record.toNote());
|
|
2574
2568
|
if (notes.length === 0) {
|
|
@@ -2773,7 +2767,7 @@ async function resolveRequest(request, client) {
|
|
|
2773
2767
|
|
|
2774
2768
|
// src/hooks/useSessionAccount.ts
|
|
2775
2769
|
var import_react22 = require("react");
|
|
2776
|
-
var
|
|
2770
|
+
var import_miden_sdk21 = require("@miden-sdk/miden-sdk");
|
|
2777
2771
|
function useSessionAccount(options) {
|
|
2778
2772
|
const { client, isReady, sync, runExclusive } = useMiden();
|
|
2779
2773
|
const runExclusiveSafe = runExclusive ?? runExclusiveDirect;
|
|
@@ -2903,11 +2897,11 @@ function useSessionAccount(options) {
|
|
|
2903
2897
|
function getStorageMode3(mode) {
|
|
2904
2898
|
switch (mode) {
|
|
2905
2899
|
case "private":
|
|
2906
|
-
return
|
|
2900
|
+
return import_miden_sdk21.AccountStorageMode.private();
|
|
2907
2901
|
case "public":
|
|
2908
|
-
return
|
|
2902
|
+
return import_miden_sdk21.AccountStorageMode.public();
|
|
2909
2903
|
default:
|
|
2910
|
-
return
|
|
2904
|
+
return import_miden_sdk21.AccountStorageMode.public();
|
|
2911
2905
|
}
|
|
2912
2906
|
}
|
|
2913
2907
|
async function waitAndConsume(client, runExclusiveSafe, walletId, pollIntervalMs, maxWaitMs, cancelledRef) {
|
|
@@ -3085,6 +3079,7 @@ function createMidenStorage(prefix) {
|
|
|
3085
3079
|
installAccountBech32();
|
|
3086
3080
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3087
3081
|
0 && (module.exports = {
|
|
3082
|
+
AuthScheme,
|
|
3088
3083
|
DEFAULTS,
|
|
3089
3084
|
MidenError,
|
|
3090
3085
|
MidenProvider,
|
package/dist/index.mjs
CHANGED
|
@@ -288,16 +288,17 @@ import {
|
|
|
288
288
|
useMemo,
|
|
289
289
|
useState
|
|
290
290
|
} from "react";
|
|
291
|
-
import { WebClient } from "@miden-sdk/miden-sdk";
|
|
291
|
+
import { WasmWebClient as WebClient } from "@miden-sdk/miden-sdk";
|
|
292
292
|
|
|
293
293
|
// src/types/index.ts
|
|
294
|
+
import { AuthScheme } from "@miden-sdk/miden-sdk";
|
|
294
295
|
var DEFAULTS = {
|
|
295
296
|
RPC_URL: void 0,
|
|
296
297
|
// Will use SDK's testnet default
|
|
297
298
|
AUTO_SYNC_INTERVAL: 15e3,
|
|
298
299
|
STORAGE_MODE: "private",
|
|
299
300
|
WALLET_MUTABLE: true,
|
|
300
|
-
AUTH_SCHEME:
|
|
301
|
+
AUTH_SCHEME: AuthScheme.AuthRpoFalcon512,
|
|
301
302
|
NOTE_TYPE: "private",
|
|
302
303
|
FAUCET_DECIMALS: 8
|
|
303
304
|
};
|
|
@@ -401,35 +402,28 @@ function useSigner() {
|
|
|
401
402
|
}
|
|
402
403
|
|
|
403
404
|
// src/utils/signerAccount.ts
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
return AccountType.FungibleFaucet;
|
|
413
|
-
case "NonFungibleFaucet":
|
|
414
|
-
return AccountType.NonFungibleFaucet;
|
|
415
|
-
default:
|
|
416
|
-
return AccountType.RegularAccountImmutableCode;
|
|
417
|
-
}
|
|
405
|
+
var WASM_ACCOUNT_TYPE = {
|
|
406
|
+
FungibleFaucet: 0,
|
|
407
|
+
NonFungibleFaucet: 1,
|
|
408
|
+
RegularAccountImmutableCode: 2,
|
|
409
|
+
RegularAccountUpdatableCode: 3
|
|
410
|
+
};
|
|
411
|
+
function getAccountType(accountType) {
|
|
412
|
+
return WASM_ACCOUNT_TYPE[accountType] ?? WASM_ACCOUNT_TYPE.RegularAccountImmutableCode;
|
|
418
413
|
}
|
|
419
414
|
function isPrivateStorageMode(storageMode) {
|
|
420
415
|
return storageMode.toString() === "private";
|
|
421
416
|
}
|
|
422
417
|
async function initializeSignerAccount(client, config) {
|
|
423
|
-
const { AccountBuilder, AccountComponent, Word: Word2 } = await import("@miden-sdk/miden-sdk");
|
|
418
|
+
const { AccountBuilder, AccountComponent, AuthScheme: AuthScheme2, Word: Word2 } = await import("@miden-sdk/miden-sdk");
|
|
424
419
|
await client.syncState();
|
|
425
420
|
const commitmentWord = Word2.deserialize(config.publicKeyCommitment);
|
|
426
421
|
const seed = config.accountSeed ?? crypto.getRandomValues(new Uint8Array(32));
|
|
427
|
-
const accountType =
|
|
422
|
+
const accountType = getAccountType(config.accountType);
|
|
428
423
|
let builder = new AccountBuilder(seed).withAuthComponent(
|
|
429
424
|
AccountComponent.createAuthComponentFromCommitment(
|
|
430
425
|
commitmentWord,
|
|
431
|
-
|
|
432
|
-
// ECDSA auth scheme (K256/Keccak)
|
|
426
|
+
AuthScheme2.AuthEcdsaK256Keccak
|
|
433
427
|
)
|
|
434
428
|
).accountType(accountType).storageMode(config.storageMode).withBasicWalletComponent();
|
|
435
429
|
if (config.customComponents?.length) {
|
|
@@ -1551,7 +1545,7 @@ function useSyncState() {
|
|
|
1551
1545
|
import { useCallback as useCallback8, useState as useState6 } from "react";
|
|
1552
1546
|
import { AccountStorageMode } from "@miden-sdk/miden-sdk";
|
|
1553
1547
|
function useCreateWallet() {
|
|
1554
|
-
const { client, isReady,
|
|
1548
|
+
const { client, isReady, runExclusive } = useMiden();
|
|
1555
1549
|
const runExclusiveSafe = runExclusive ?? runExclusiveDirect;
|
|
1556
1550
|
const setAccounts = useMidenStore((state) => state.setAccounts);
|
|
1557
1551
|
const [wallet, setWallet] = useState6(null);
|
|
@@ -1562,7 +1556,6 @@ function useCreateWallet() {
|
|
|
1562
1556
|
if (!client || !isReady) {
|
|
1563
1557
|
throw new Error("Miden client is not ready");
|
|
1564
1558
|
}
|
|
1565
|
-
await sync();
|
|
1566
1559
|
setIsCreating(true);
|
|
1567
1560
|
setError(null);
|
|
1568
1561
|
try {
|
|
@@ -3058,6 +3051,7 @@ function createMidenStorage(prefix) {
|
|
|
3058
3051
|
// src/index.ts
|
|
3059
3052
|
installAccountBech32();
|
|
3060
3053
|
export {
|
|
3054
|
+
AuthScheme,
|
|
3061
3055
|
DEFAULTS,
|
|
3062
3056
|
MidenError,
|
|
3063
3057
|
MidenProvider,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@miden-sdk/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0-alpha",
|
|
4
4
|
"description": "React hooks library for Miden Web Client",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"test:all": "VITE_CJS_IGNORE_WARNING=1 vitest run && playwright test"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
|
-
"@miden-sdk/miden-sdk": "^0.
|
|
31
|
+
"@miden-sdk/miden-sdk": "^0.14.0",
|
|
32
32
|
"react": ">=18.0.0"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
@@ -66,5 +66,12 @@
|
|
|
66
66
|
},
|
|
67
67
|
"bugs": {
|
|
68
68
|
"url": "https://github.com/0xMiden/miden-client/issues"
|
|
69
|
+
},
|
|
70
|
+
"resolutions": {
|
|
71
|
+
"@isaacs/brace-expansion": ">=5.0.1",
|
|
72
|
+
"esbuild": ">=0.25.0",
|
|
73
|
+
"minimatch": ">=10.2.1",
|
|
74
|
+
"rollup": ">=4.59.0",
|
|
75
|
+
"qs": ">=6.15.0"
|
|
69
76
|
}
|
|
70
77
|
}
|