veilix-sdk 0.3.0 → 0.3.1
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/{VeilixSDK-BfiPKwIa.d.ts → VeilixSDK-BLZZ5yVj.d.ts} +83 -81
- package/dist/{VeilixSDK-sbYKDbdy.d.cts → VeilixSDK-CpjyQiV7.d.cts} +83 -81
- package/dist/circuits/paths.cjs.map +1 -1
- package/dist/circuits/paths.js.map +1 -1
- package/dist/index.cjs +46 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +46 -16
- package/dist/index.js.map +1 -1
- package/dist/react/index.cjs +46 -16
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +1 -1
- package/dist/react/index.d.ts +1 -1
- package/dist/react/index.js +46 -16
- package/dist/react/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PublicKey, Keypair,
|
|
1
|
+
import { Connection, PublicKey, Keypair, TransactionInstruction, VersionedTransaction, Transaction } from '@solana/web3.js';
|
|
2
2
|
import { Buffer as Buffer$1 } from 'buffer';
|
|
3
3
|
import { MerkleTree } from 'fixed-merkle-tree';
|
|
4
4
|
import { OracleJob } from '@switchboard-xyz/common';
|
|
@@ -6,6 +6,86 @@ import { Program } from '@coral-xyz/anchor';
|
|
|
6
6
|
import { Wallet } from '@coral-xyz/anchor/dist/cjs/provider';
|
|
7
7
|
import { C as CircuitPaths } from './constants-C-u6nmCv.js';
|
|
8
8
|
|
|
9
|
+
type Network = "mainnet" | "devnet";
|
|
10
|
+
declare const MAINNET_TOKEN_MINTS: {
|
|
11
|
+
readonly Veilix: "GAFN64LvtCBoc5BHncVn3JEJGpq42rUzQjPmvMK2UhZH";
|
|
12
|
+
readonly Bitcoin: "3NZ9JMVBmGAqocybic2c7LQCJScmgsAZ6vQqTDzcqmJh";
|
|
13
|
+
readonly Ethereum: "7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs";
|
|
14
|
+
readonly USDC: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";
|
|
15
|
+
};
|
|
16
|
+
type TokenSymbol = keyof typeof MAINNET_TOKEN_MINTS;
|
|
17
|
+
declare const TOKEN_DECIMALS: {
|
|
18
|
+
readonly Solana: 9;
|
|
19
|
+
readonly Veilix: 9;
|
|
20
|
+
readonly Ethereum: 8;
|
|
21
|
+
readonly Bitcoin: 8;
|
|
22
|
+
readonly USDC: 6;
|
|
23
|
+
};
|
|
24
|
+
type TokenDecimalsSymbol = keyof typeof TOKEN_DECIMALS;
|
|
25
|
+
|
|
26
|
+
type Relayer = {
|
|
27
|
+
isValid: true;
|
|
28
|
+
label: string;
|
|
29
|
+
url: string;
|
|
30
|
+
key: number;
|
|
31
|
+
value: string;
|
|
32
|
+
fee: unknown;
|
|
33
|
+
recentActivities: unknown;
|
|
34
|
+
userPubkey: unknown;
|
|
35
|
+
workers: unknown;
|
|
36
|
+
totalFeeEarningsSol: unknown;
|
|
37
|
+
totalWithdrawCount: unknown;
|
|
38
|
+
stakedAmount: unknown;
|
|
39
|
+
volume24hSol: unknown;
|
|
40
|
+
volume7dSol: unknown;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
interface VeilixSdkInitOptions {
|
|
44
|
+
/** Wallet for Anchor provider transactions. */
|
|
45
|
+
wallet: Wallet;
|
|
46
|
+
/**
|
|
47
|
+
* Solana JSON-RPC endpoint (Node/scripts). Omit when passing {@link connection}
|
|
48
|
+
* from `@solana/wallet-adapter-react` (`useConnection()`).
|
|
49
|
+
*/
|
|
50
|
+
rpcEndpoint?: string;
|
|
51
|
+
/** Existing connection (e.g. `useConnection()` in React). */
|
|
52
|
+
connection?: Connection;
|
|
53
|
+
/**
|
|
54
|
+
* Cluster override when the RPC URL does not contain `devnet` / `mainnet` hints
|
|
55
|
+
* (common with private RPC providers).
|
|
56
|
+
*/
|
|
57
|
+
network: Network;
|
|
58
|
+
/**
|
|
59
|
+
* Base URL/path for withdraw circuit artifacts in the browser.
|
|
60
|
+
* Defaults to `/node_modules/<pkg>/dist/circuits/` on localhost and the
|
|
61
|
+
* pinned, SHA-256-verified jsDelivr CDN in production (domain-independent).
|
|
62
|
+
* Set this to self-host instead, e.g. `"/circuits/"` (verified, with CDN fallback)
|
|
63
|
+
* or `"https://cdn.example.com/veilix/circuits/"`.
|
|
64
|
+
*/
|
|
65
|
+
circuitPathsBase?: string;
|
|
66
|
+
/** Indexer base URL override (defaults to the Veilix indexer of {@link network}). */
|
|
67
|
+
indexerUrl?: string;
|
|
68
|
+
/** Address-risk API base URL override. */
|
|
69
|
+
riskApiUrl?: string;
|
|
70
|
+
}
|
|
71
|
+
interface VeilixSdkRuntimeConfig {
|
|
72
|
+
rpcEndpoint: string;
|
|
73
|
+
/** Cluster inferred from {@link rpcEndpoint}. */
|
|
74
|
+
network: Network;
|
|
75
|
+
programId: string;
|
|
76
|
+
indexerUrl: string;
|
|
77
|
+
riskApiUrl: string;
|
|
78
|
+
/** Active relayers for {@link network}, loaded at SDK initialization. */
|
|
79
|
+
relayers: Relayer[];
|
|
80
|
+
connection: Connection;
|
|
81
|
+
wallet: Wallet;
|
|
82
|
+
program: Program;
|
|
83
|
+
/** Set by {@link VeilixSDK.getEncryptionKey}; required for on-chain note backup. */
|
|
84
|
+
encryptKey?: Uint8Array;
|
|
85
|
+
/** Resolved withdraw circuit wasm/zkey URLs for browser proof generation. */
|
|
86
|
+
circuitPaths?: CircuitPaths;
|
|
87
|
+
}
|
|
88
|
+
|
|
9
89
|
type VeilixMerkleTree = MerkleTree;
|
|
10
90
|
/** Rebuild an asset tree from its leaves (commitments in index order). */
|
|
11
91
|
declare function buildMerkleTree(leaves: Array<bigint | string>): VeilixMerkleTree;
|
|
@@ -197,6 +277,8 @@ type BuildDepositTxParams = {
|
|
|
197
277
|
computeUnitLimit?: number;
|
|
198
278
|
/** Shared, already verified circuit artifacts (see `prepareCircuitArtifacts`). */
|
|
199
279
|
circuitArtifacts?: PreparedCircuitArtifacts;
|
|
280
|
+
/** Seals `onChainBackup`. Defaults to this SDK instance's key. */
|
|
281
|
+
encryptKey?: Uint8Array;
|
|
200
282
|
};
|
|
201
283
|
/** Body of the relayer `POST /relay` (also one item of indexer `POST /submit`). */
|
|
202
284
|
type RelayPayload = {
|
|
@@ -380,86 +462,6 @@ type ScanOwnedNotesOptions = {
|
|
|
380
462
|
includeSpent?: boolean;
|
|
381
463
|
};
|
|
382
464
|
|
|
383
|
-
type Network = "mainnet" | "devnet";
|
|
384
|
-
declare const MAINNET_TOKEN_MINTS: {
|
|
385
|
-
readonly Veilix: "GAFN64LvtCBoc5BHncVn3JEJGpq42rUzQjPmvMK2UhZH";
|
|
386
|
-
readonly Bitcoin: "3NZ9JMVBmGAqocybic2c7LQCJScmgsAZ6vQqTDzcqmJh";
|
|
387
|
-
readonly Ethereum: "7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs";
|
|
388
|
-
readonly USDC: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";
|
|
389
|
-
};
|
|
390
|
-
type TokenSymbol = keyof typeof MAINNET_TOKEN_MINTS;
|
|
391
|
-
declare const TOKEN_DECIMALS: {
|
|
392
|
-
readonly Solana: 9;
|
|
393
|
-
readonly Veilix: 9;
|
|
394
|
-
readonly Ethereum: 8;
|
|
395
|
-
readonly Bitcoin: 8;
|
|
396
|
-
readonly USDC: 6;
|
|
397
|
-
};
|
|
398
|
-
type TokenDecimalsSymbol = keyof typeof TOKEN_DECIMALS;
|
|
399
|
-
|
|
400
|
-
type Relayer = {
|
|
401
|
-
isValid: true;
|
|
402
|
-
label: string;
|
|
403
|
-
url: string;
|
|
404
|
-
key: number;
|
|
405
|
-
value: string;
|
|
406
|
-
fee: unknown;
|
|
407
|
-
recentActivities: unknown;
|
|
408
|
-
userPubkey: unknown;
|
|
409
|
-
workers: unknown;
|
|
410
|
-
totalFeeEarningsSol: unknown;
|
|
411
|
-
totalWithdrawCount: unknown;
|
|
412
|
-
stakedAmount: unknown;
|
|
413
|
-
volume24hSol: unknown;
|
|
414
|
-
volume7dSol: unknown;
|
|
415
|
-
};
|
|
416
|
-
|
|
417
|
-
interface VeilixSdkInitOptions {
|
|
418
|
-
/** Wallet for Anchor provider transactions. */
|
|
419
|
-
wallet: Wallet;
|
|
420
|
-
/**
|
|
421
|
-
* Solana JSON-RPC endpoint (Node/scripts). Omit when passing {@link connection}
|
|
422
|
-
* from `@solana/wallet-adapter-react` (`useConnection()`).
|
|
423
|
-
*/
|
|
424
|
-
rpcEndpoint?: string;
|
|
425
|
-
/** Existing connection (e.g. `useConnection()` in React). */
|
|
426
|
-
connection?: Connection;
|
|
427
|
-
/**
|
|
428
|
-
* Cluster override when the RPC URL does not contain `devnet` / `mainnet` hints
|
|
429
|
-
* (common with private RPC providers).
|
|
430
|
-
*/
|
|
431
|
-
network: Network;
|
|
432
|
-
/**
|
|
433
|
-
* Base URL/path for withdraw circuit artifacts in the browser.
|
|
434
|
-
* Defaults to `/node_modules/<pkg>/dist/circuits/` on localhost and the
|
|
435
|
-
* pinned, SHA-256-verified jsDelivr CDN in production (domain-independent).
|
|
436
|
-
* Set this to self-host instead, e.g. `"/circuits/"` (verified, with CDN fallback)
|
|
437
|
-
* or `"https://cdn.example.com/veilix/circuits/"`.
|
|
438
|
-
*/
|
|
439
|
-
circuitPathsBase?: string;
|
|
440
|
-
/** Indexer base URL override (defaults to the Veilix indexer of {@link network}). */
|
|
441
|
-
indexerUrl?: string;
|
|
442
|
-
/** Address-risk API base URL override. */
|
|
443
|
-
riskApiUrl?: string;
|
|
444
|
-
}
|
|
445
|
-
interface VeilixSdkRuntimeConfig {
|
|
446
|
-
rpcEndpoint: string;
|
|
447
|
-
/** Cluster inferred from {@link rpcEndpoint}. */
|
|
448
|
-
network: Network;
|
|
449
|
-
programId: string;
|
|
450
|
-
indexerUrl: string;
|
|
451
|
-
riskApiUrl: string;
|
|
452
|
-
/** Active relayers for {@link network}, loaded at SDK initialization. */
|
|
453
|
-
relayers: Relayer[];
|
|
454
|
-
connection: Connection;
|
|
455
|
-
wallet: Wallet;
|
|
456
|
-
program: Program;
|
|
457
|
-
/** Set by {@link VeilixSDK.getEncryptionKey}; required for on-chain note backup. */
|
|
458
|
-
encryptKey?: Uint8Array;
|
|
459
|
-
/** Resolved withdraw circuit wasm/zkey URLs for browser proof generation. */
|
|
460
|
-
circuitPaths?: CircuitPaths;
|
|
461
|
-
}
|
|
462
|
-
|
|
463
465
|
type WithdrawParams = {
|
|
464
466
|
/** Secret note to spend. */
|
|
465
467
|
note: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PublicKey, Keypair,
|
|
1
|
+
import { Connection, PublicKey, Keypair, TransactionInstruction, VersionedTransaction, Transaction } from '@solana/web3.js';
|
|
2
2
|
import { Buffer as Buffer$1 } from 'buffer';
|
|
3
3
|
import { MerkleTree } from 'fixed-merkle-tree';
|
|
4
4
|
import { OracleJob } from '@switchboard-xyz/common';
|
|
@@ -6,6 +6,86 @@ import { Program } from '@coral-xyz/anchor';
|
|
|
6
6
|
import { Wallet } from '@coral-xyz/anchor/dist/cjs/provider';
|
|
7
7
|
import { C as CircuitPaths } from './constants-C-u6nmCv.cjs';
|
|
8
8
|
|
|
9
|
+
type Network = "mainnet" | "devnet";
|
|
10
|
+
declare const MAINNET_TOKEN_MINTS: {
|
|
11
|
+
readonly Veilix: "GAFN64LvtCBoc5BHncVn3JEJGpq42rUzQjPmvMK2UhZH";
|
|
12
|
+
readonly Bitcoin: "3NZ9JMVBmGAqocybic2c7LQCJScmgsAZ6vQqTDzcqmJh";
|
|
13
|
+
readonly Ethereum: "7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs";
|
|
14
|
+
readonly USDC: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";
|
|
15
|
+
};
|
|
16
|
+
type TokenSymbol = keyof typeof MAINNET_TOKEN_MINTS;
|
|
17
|
+
declare const TOKEN_DECIMALS: {
|
|
18
|
+
readonly Solana: 9;
|
|
19
|
+
readonly Veilix: 9;
|
|
20
|
+
readonly Ethereum: 8;
|
|
21
|
+
readonly Bitcoin: 8;
|
|
22
|
+
readonly USDC: 6;
|
|
23
|
+
};
|
|
24
|
+
type TokenDecimalsSymbol = keyof typeof TOKEN_DECIMALS;
|
|
25
|
+
|
|
26
|
+
type Relayer = {
|
|
27
|
+
isValid: true;
|
|
28
|
+
label: string;
|
|
29
|
+
url: string;
|
|
30
|
+
key: number;
|
|
31
|
+
value: string;
|
|
32
|
+
fee: unknown;
|
|
33
|
+
recentActivities: unknown;
|
|
34
|
+
userPubkey: unknown;
|
|
35
|
+
workers: unknown;
|
|
36
|
+
totalFeeEarningsSol: unknown;
|
|
37
|
+
totalWithdrawCount: unknown;
|
|
38
|
+
stakedAmount: unknown;
|
|
39
|
+
volume24hSol: unknown;
|
|
40
|
+
volume7dSol: unknown;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
interface VeilixSdkInitOptions {
|
|
44
|
+
/** Wallet for Anchor provider transactions. */
|
|
45
|
+
wallet: Wallet;
|
|
46
|
+
/**
|
|
47
|
+
* Solana JSON-RPC endpoint (Node/scripts). Omit when passing {@link connection}
|
|
48
|
+
* from `@solana/wallet-adapter-react` (`useConnection()`).
|
|
49
|
+
*/
|
|
50
|
+
rpcEndpoint?: string;
|
|
51
|
+
/** Existing connection (e.g. `useConnection()` in React). */
|
|
52
|
+
connection?: Connection;
|
|
53
|
+
/**
|
|
54
|
+
* Cluster override when the RPC URL does not contain `devnet` / `mainnet` hints
|
|
55
|
+
* (common with private RPC providers).
|
|
56
|
+
*/
|
|
57
|
+
network: Network;
|
|
58
|
+
/**
|
|
59
|
+
* Base URL/path for withdraw circuit artifacts in the browser.
|
|
60
|
+
* Defaults to `/node_modules/<pkg>/dist/circuits/` on localhost and the
|
|
61
|
+
* pinned, SHA-256-verified jsDelivr CDN in production (domain-independent).
|
|
62
|
+
* Set this to self-host instead, e.g. `"/circuits/"` (verified, with CDN fallback)
|
|
63
|
+
* or `"https://cdn.example.com/veilix/circuits/"`.
|
|
64
|
+
*/
|
|
65
|
+
circuitPathsBase?: string;
|
|
66
|
+
/** Indexer base URL override (defaults to the Veilix indexer of {@link network}). */
|
|
67
|
+
indexerUrl?: string;
|
|
68
|
+
/** Address-risk API base URL override. */
|
|
69
|
+
riskApiUrl?: string;
|
|
70
|
+
}
|
|
71
|
+
interface VeilixSdkRuntimeConfig {
|
|
72
|
+
rpcEndpoint: string;
|
|
73
|
+
/** Cluster inferred from {@link rpcEndpoint}. */
|
|
74
|
+
network: Network;
|
|
75
|
+
programId: string;
|
|
76
|
+
indexerUrl: string;
|
|
77
|
+
riskApiUrl: string;
|
|
78
|
+
/** Active relayers for {@link network}, loaded at SDK initialization. */
|
|
79
|
+
relayers: Relayer[];
|
|
80
|
+
connection: Connection;
|
|
81
|
+
wallet: Wallet;
|
|
82
|
+
program: Program;
|
|
83
|
+
/** Set by {@link VeilixSDK.getEncryptionKey}; required for on-chain note backup. */
|
|
84
|
+
encryptKey?: Uint8Array;
|
|
85
|
+
/** Resolved withdraw circuit wasm/zkey URLs for browser proof generation. */
|
|
86
|
+
circuitPaths?: CircuitPaths;
|
|
87
|
+
}
|
|
88
|
+
|
|
9
89
|
type VeilixMerkleTree = MerkleTree;
|
|
10
90
|
/** Rebuild an asset tree from its leaves (commitments in index order). */
|
|
11
91
|
declare function buildMerkleTree(leaves: Array<bigint | string>): VeilixMerkleTree;
|
|
@@ -197,6 +277,8 @@ type BuildDepositTxParams = {
|
|
|
197
277
|
computeUnitLimit?: number;
|
|
198
278
|
/** Shared, already verified circuit artifacts (see `prepareCircuitArtifacts`). */
|
|
199
279
|
circuitArtifacts?: PreparedCircuitArtifacts;
|
|
280
|
+
/** Seals `onChainBackup`. Defaults to this SDK instance's key. */
|
|
281
|
+
encryptKey?: Uint8Array;
|
|
200
282
|
};
|
|
201
283
|
/** Body of the relayer `POST /relay` (also one item of indexer `POST /submit`). */
|
|
202
284
|
type RelayPayload = {
|
|
@@ -380,86 +462,6 @@ type ScanOwnedNotesOptions = {
|
|
|
380
462
|
includeSpent?: boolean;
|
|
381
463
|
};
|
|
382
464
|
|
|
383
|
-
type Network = "mainnet" | "devnet";
|
|
384
|
-
declare const MAINNET_TOKEN_MINTS: {
|
|
385
|
-
readonly Veilix: "GAFN64LvtCBoc5BHncVn3JEJGpq42rUzQjPmvMK2UhZH";
|
|
386
|
-
readonly Bitcoin: "3NZ9JMVBmGAqocybic2c7LQCJScmgsAZ6vQqTDzcqmJh";
|
|
387
|
-
readonly Ethereum: "7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs";
|
|
388
|
-
readonly USDC: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";
|
|
389
|
-
};
|
|
390
|
-
type TokenSymbol = keyof typeof MAINNET_TOKEN_MINTS;
|
|
391
|
-
declare const TOKEN_DECIMALS: {
|
|
392
|
-
readonly Solana: 9;
|
|
393
|
-
readonly Veilix: 9;
|
|
394
|
-
readonly Ethereum: 8;
|
|
395
|
-
readonly Bitcoin: 8;
|
|
396
|
-
readonly USDC: 6;
|
|
397
|
-
};
|
|
398
|
-
type TokenDecimalsSymbol = keyof typeof TOKEN_DECIMALS;
|
|
399
|
-
|
|
400
|
-
type Relayer = {
|
|
401
|
-
isValid: true;
|
|
402
|
-
label: string;
|
|
403
|
-
url: string;
|
|
404
|
-
key: number;
|
|
405
|
-
value: string;
|
|
406
|
-
fee: unknown;
|
|
407
|
-
recentActivities: unknown;
|
|
408
|
-
userPubkey: unknown;
|
|
409
|
-
workers: unknown;
|
|
410
|
-
totalFeeEarningsSol: unknown;
|
|
411
|
-
totalWithdrawCount: unknown;
|
|
412
|
-
stakedAmount: unknown;
|
|
413
|
-
volume24hSol: unknown;
|
|
414
|
-
volume7dSol: unknown;
|
|
415
|
-
};
|
|
416
|
-
|
|
417
|
-
interface VeilixSdkInitOptions {
|
|
418
|
-
/** Wallet for Anchor provider transactions. */
|
|
419
|
-
wallet: Wallet;
|
|
420
|
-
/**
|
|
421
|
-
* Solana JSON-RPC endpoint (Node/scripts). Omit when passing {@link connection}
|
|
422
|
-
* from `@solana/wallet-adapter-react` (`useConnection()`).
|
|
423
|
-
*/
|
|
424
|
-
rpcEndpoint?: string;
|
|
425
|
-
/** Existing connection (e.g. `useConnection()` in React). */
|
|
426
|
-
connection?: Connection;
|
|
427
|
-
/**
|
|
428
|
-
* Cluster override when the RPC URL does not contain `devnet` / `mainnet` hints
|
|
429
|
-
* (common with private RPC providers).
|
|
430
|
-
*/
|
|
431
|
-
network: Network;
|
|
432
|
-
/**
|
|
433
|
-
* Base URL/path for withdraw circuit artifacts in the browser.
|
|
434
|
-
* Defaults to `/node_modules/<pkg>/dist/circuits/` on localhost and the
|
|
435
|
-
* pinned, SHA-256-verified jsDelivr CDN in production (domain-independent).
|
|
436
|
-
* Set this to self-host instead, e.g. `"/circuits/"` (verified, with CDN fallback)
|
|
437
|
-
* or `"https://cdn.example.com/veilix/circuits/"`.
|
|
438
|
-
*/
|
|
439
|
-
circuitPathsBase?: string;
|
|
440
|
-
/** Indexer base URL override (defaults to the Veilix indexer of {@link network}). */
|
|
441
|
-
indexerUrl?: string;
|
|
442
|
-
/** Address-risk API base URL override. */
|
|
443
|
-
riskApiUrl?: string;
|
|
444
|
-
}
|
|
445
|
-
interface VeilixSdkRuntimeConfig {
|
|
446
|
-
rpcEndpoint: string;
|
|
447
|
-
/** Cluster inferred from {@link rpcEndpoint}. */
|
|
448
|
-
network: Network;
|
|
449
|
-
programId: string;
|
|
450
|
-
indexerUrl: string;
|
|
451
|
-
riskApiUrl: string;
|
|
452
|
-
/** Active relayers for {@link network}, loaded at SDK initialization. */
|
|
453
|
-
relayers: Relayer[];
|
|
454
|
-
connection: Connection;
|
|
455
|
-
wallet: Wallet;
|
|
456
|
-
program: Program;
|
|
457
|
-
/** Set by {@link VeilixSDK.getEncryptionKey}; required for on-chain note backup. */
|
|
458
|
-
encryptKey?: Uint8Array;
|
|
459
|
-
/** Resolved withdraw circuit wasm/zkey URLs for browser proof generation. */
|
|
460
|
-
circuitPaths?: CircuitPaths;
|
|
461
|
-
}
|
|
462
|
-
|
|
463
465
|
type WithdrawParams = {
|
|
464
466
|
/** Secret note to spend. */
|
|
465
467
|
note: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../package.json","../../src/circuits/constants.ts","../../src/circuits/paths.ts"],"names":[],"mappings":";;;;AAAA,IAAA,eAAA,GAAA;AAAA,EACE,IAAA,EAAQ,YAmGV,CAAA;;;ACjGO,IAAM,eAAe,eAAA,CAAY;AAMjC,IAAM,qBAAA,GAAwB;AAC9B,IAAM,qBAAA,GAAwB;AAK9B,IAAM,uBAAA,GAA0B;AAAA,EACrC,IAAA,EAAM,kEAAA;AAAA,EACN,IAAA,EAAM;AACR;AAGO,IAAM,wBAAA,GAA2B;AAUjC,IAAM,mBAAA,GAAsB,YAAA;AAC5B,IAAM,mBAAA,GAAsB,OAAA;AAQ5B,SAAS,4BAA4B,IAAA,EAA4B;AACtE,EAAA,MAAM,OAAO,IAAA,CAAK,QAAA,CAAS,GAAG,CAAA,GAAI,IAAA,GAAO,GAAG,IAAI,CAAA,CAAA,CAAA;AAChD,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,CAAA,EAAG,IAAI,CAAA,SAAA,EAAY,qBAAqB,CAAA,CAAA;AAAA,IAC9C,IAAA,EAAM,CAAA,EAAG,IAAI,CAAA,SAAA,EAAY,qBAAqB,CAAA;AAAA,GAChD;AACF;AASO,SAAS,wBAAA,GAAmC;AACjD,EAAA,OAAO,CAAA,6BAAA,EAAgC,mBAAmB,CAAA,CAAA,EAAI,mBAAmB,CAAA,eAAA,CAAA;AACnF;AAGO,SAAS,yBAAA,GAA0C;AACxD,EAAA,MAAM,OAAO,wBAAA,EAAyB;A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M,IAAI,GAAA,CAAI,CAAA,EAAA,EAAK,qBAAqB,CAAA,CAAA,EAAI,2PAAe,CAAA,CAAE;AAAA,GAC/D;AACF","file":"paths.cjs","sourcesContent":["{\n \"name\": \"veilix-sdk\",\n \"version\": \"0.3.0\",\n \"description\": \"Veilix Privacy SDK\",\n \"type\": \"module\",\n \"main\": \"./dist/index.cjs\",\n \"module\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"sideEffects\": false,\n \"exports\": {\n \".\": {\n \"import\": {\n \"types\": \"./dist/index.d.ts\",\n \"default\": \"./dist/index.js\"\n },\n \"require\": {\n \"types\": \"./dist/index.d.cts\",\n \"default\": \"./dist/index.cjs\"\n }\n },\n \"./circuits/paths\": {\n \"import\": \"./dist/circuits/paths.js\",\n \"require\": \"./dist/circuits/paths.cjs\",\n \"default\": \"./dist/circuits/paths.js\"\n },\n \"./circuits/*\": \"./dist/circuits/*\",\n \"./vite\": {\n \"import\": {\n \"types\": \"./dist/vite/index.d.ts\",\n \"default\": \"./dist/vite/index.js\"\n },\n \"require\": {\n \"types\": \"./dist/vite/index.d.cts\",\n \"default\": \"./dist/vite/index.cjs\"\n }\n },\n \"./react\": {\n \"import\": {\n \"types\": \"./dist/react/index.d.ts\",\n \"default\": \"./dist/react/index.js\"\n },\n \"require\": {\n \"types\": \"./dist/react/index.d.cts\",\n \"default\": \"./dist/react/index.cjs\"\n }\n },\n \"./package.json\": \"./package.json\"\n },\n \"peerDependencies\": {\n \"@solana/wallet-adapter-react\": \">=0.15.0\",\n \"react\": \">=18\"\n },\n \"peerDependenciesMeta\": {\n \"@solana/wallet-adapter-react\": {\n \"optional\": true\n },\n \"react\": {\n \"optional\": true\n }\n },\n \"files\": [\n \"dist\"\n ],\n \"scripts\": {\n \"prepare:snarkjs\": \"node scripts/prepare-snarkjs.mjs\",\n \"build\": \"npm run prepare:snarkjs && tsup\",\n \"dev\": \"npm run prepare:snarkjs && tsup --watch\",\n \"typecheck\": \"npm run prepare:snarkjs && tsc --noEmit\",\n \"prepublishOnly\": \"npm run build\"\n },\n \"keywords\": [\n \"veilix-sdk\",\n \"sdk\"\n ],\n \"license\": \"MIT\",\n \"devDependencies\": {\n \"@solana/wallet-adapter-react\": \"^0.15.39\",\n \"@types/bn.js\": \"^5.2.0\",\n \"@types/node\": \"^26.0.0\",\n \"@types/react\": \"^19.1.8\",\n \"react\": \"^19.1.0\",\n \"tsup\": \"^8.5.0\",\n \"typescript\": \"^5.8.3\"\n },\n \"engines\": {\n \"node\": \">=18\"\n },\n \"dependencies\": {\n \"@coral-xyz/anchor\": \"^0.31.1\",\n \"@solana/spl-token\": \"^0.4.14\",\n \"@solana/web3.js\": \"^1.98.4\",\n \"@switchboard-xyz/common\": \"^5.8.1\",\n \"@switchboard-xyz/on-demand\": \"^3.10.1\",\n \"bn.js\": \"^5.2.5\",\n \"buffer\": \"^6.0.3\",\n \"ffjavascript\": \"^0.3.1\",\n \"fixed-merkle-tree\": \"^0.7.3\",\n \"poseidon-hash\": \"^1.0.1\",\n \"tweetnacl\": \"^1.0.3\"\n }\n}\n","import packageJson from \"../../package.json\";\n\n/** npm package name (used to load the standalone circuits module). */\nexport const PACKAGE_NAME = packageJson.name;\n\n/** Published npm version (pins CDN circuit URLs in production). */\nexport const PACKAGE_VERSION = packageJson.version;\n\n/** Withdraw circuit artifact filenames (published under `veilix-sdk/circuits/`). */\nexport const WITHDRAW_CIRCUIT_WASM = \"withdraw.wasm\";\nexport const WITHDRAW_CIRCUIT_ZKEY = \"withdraw.zkey\";\n/**\n * Pinned SHA-256 hashes for the published withdraw circuit artifacts.\n * These are verified in-browser before passing artifacts to snarkjs.\n */\nexport const WITHDRAW_CIRCUIT_SHA256 = {\n wasm: \"5f9eb88bcbc1b3dd5669dad6fdd3b91d59dd2d617ad0b34827af8a498d13fa60\",\n zkey: \"73e0d2328eca8f48024b69b42d659b68d7dd2f067d762079e859ffff34360a1a\",\n} as const;\n\n/** Optional self-hosted path convention (opt-in via `circuitPathsBase`). */\nexport const SELF_HOSTED_CIRCUIT_BASE = \"/circuits/\";\n\n/**\n * Stable published source for the pinned circuit artifacts.\n *\n * Decoupled from {@link PACKAGE_VERSION} on purpose: the withdraw circuit is a\n * fixed cryptographic artifact, so SDK code releases must not change where the\n * verified circuits are fetched from. Bump these together with\n * {@link WITHDRAW_CIRCUIT_SHA256} only when the circuit itself changes.\n */\nexport const CIRCUIT_CDN_PACKAGE = \"veilix-sdk\";\nexport const CIRCUIT_CDN_VERSION = \"0.2.0\";\n\nexport type CircuitPaths = {\n wasm: string;\n zkey: string;\n};\n\n/** Resolve circuit URLs when the caller knows the package `dist/` root. */\nexport function resolveCircuitPathsFromBase(base: string): CircuitPaths {\n const root = base.endsWith(\"/\") ? base : `${base}/`;\n return {\n wasm: `${root}circuits/${WITHDRAW_CIRCUIT_WASM}`,\n zkey: `${root}circuits/${WITHDRAW_CIRCUIT_ZKEY}`,\n };\n}\n\n/**\n * Base URL for circuit files on jsDelivr.\n *\n * Pinned to {@link CIRCUIT_CDN_PACKAGE}@{@link CIRCUIT_CDN_VERSION} (not the\n * current SDK version) so the bytes always match {@link WITHDRAW_CIRCUIT_SHA256}.\n * This URL is independent of the consuming app's origin/domain.\n */\nexport function resolveNpmCdnCircuitBase(): string {\n return `https://cdn.jsdelivr.net/npm/${CIRCUIT_CDN_PACKAGE}@${CIRCUIT_CDN_VERSION}/dist/circuits/`;\n}\n\n/** Trusted jsDelivr fallback paths for pinned withdraw circuit artifacts. */\nexport function resolveNpmCdnCircuitPaths(): CircuitPaths {\n const base = resolveNpmCdnCircuitBase();\n return {\n wasm: `${base}${WITHDRAW_CIRCUIT_WASM}`,\n zkey: `${base}${WITHDRAW_CIRCUIT_ZKEY}`,\n };\n}\n\nfunction isLocalDevHost(hostname: string): boolean {\n return (\n hostname === \"localhost\" ||\n hostname === \"127.0.0.1\" ||\n hostname === \"[::1]\"\n );\n}\n\n/**\n * Browser circuit URLs.\n *\n * - Local dev (Vite): `/node_modules/<pkg>/dist/circuits/` — Vite serves node_modules.\n * - Production: pinned, domain-independent jsDelivr CDN (verified by SHA-256 before use).\n *\n * The production default does not depend on the app's own origin/domain, so it\n * works on any deployed host with no copy step. Artifacts are always integrity\n * checked before proving (see {@link WITHDRAW_CIRCUIT_SHA256}). To self-host\n * instead, pass {@link VeilixSdkInitOptions.circuitPathsBase} (e.g. `\"/circuits/\"`);\n * it is verified too and falls back to the CDN if unavailable.\n */\nexport function resolveBrowserCircuitPaths(\n baseOverride?: string\n): CircuitPaths | null {\n if (typeof window === \"undefined\") {\n return null;\n }\n\n if (baseOverride !== undefined) {\n return resolveCircuitPathsFromBase(baseOverride);\n }\n\n if (isLocalDevHost(window.location.hostname)) {\n const base = `/node_modules/${PACKAGE_NAME}/dist/circuits/`;\n return {\n wasm: `${base}${WITHDRAW_CIRCUIT_WASM}`,\n zkey: `${base}${WITHDRAW_CIRCUIT_ZKEY}`,\n };\n }\n\n return resolveNpmCdnCircuitPaths();\n}\n","import {\n WITHDRAW_CIRCUIT_WASM,\n WITHDRAW_CIRCUIT_ZKEY,\n resolveBrowserCircuitPaths,\n resolveCircuitPathsFromBase,\n type CircuitPaths,\n} from \"./constants\";\n\nexport {\n PACKAGE_NAME,\n SELF_HOSTED_CIRCUIT_BASE,\n WITHDRAW_CIRCUIT_SHA256,\n WITHDRAW_CIRCUIT_WASM,\n WITHDRAW_CIRCUIT_ZKEY,\n resolveBrowserCircuitPaths,\n resolveCircuitPathsFromBase,\n resolveNpmCdnCircuitPaths,\n resolveNpmCdnCircuitBase,\n type CircuitPaths,\n} from \"./constants\";\n\n/**\n * Resolve default Groth16 circuit URLs.\n *\n * Published as `veilix-sdk/circuits/paths` so `import.meta.url` stays next to\n * `withdraw.wasm` and `withdraw.zkey` in `dist/circuits/` (Node / unbundled ESM).\n *\n * In the browser, defaults to `/node_modules/<pkg>/dist/circuits/` on localhost\n * and the pinned, SHA-256-verified jsDelivr CDN in production (domain-independent).\n * Override via {@link VeilixSdkInitOptions.circuitPathsBase},\n * {@link resolveCircuitPathsFromBase}, or {@link GenerateWithdrawProofOptions}.\n */\nexport function resolveCircuitPaths(base?: string): CircuitPaths {\n if (base !== undefined) {\n return resolveCircuitPathsFromBase(base);\n }\n\n const browser = resolveBrowserCircuitPaths();\n if (browser) {\n return browser;\n }\n\n return {\n wasm: new URL(`./${WITHDRAW_CIRCUIT_WASM}`, import.meta.url).href,\n zkey: new URL(`./${WITHDRAW_CIRCUIT_ZKEY}`, import.meta.url).href,\n };\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../package.json","../../src/circuits/constants.ts","../../src/circuits/paths.ts"],"names":[],"mappings":";;;;AAAA,IAAA,eAAA,GAAA;AAAA,EACE,IAAA,EAAQ,YAmGV,CAAA;;;ACjGO,IAAM,eAAe,eAAA,CAAY;AAMjC,IAAM,qBAAA,GAAwB;AAC9B,IAAM,qBAAA,GAAwB;AAK9B,IAAM,uBAAA,GAA0B;AAAA,EACrC,IAAA,EAAM,kEAAA;AAAA,EACN,IAAA,EAAM;AACR;AAGO,IAAM,wBAAA,GAA2B;AAUjC,IAAM,mBAAA,GAAsB,YAAA;AAC5B,IAAM,mBAAA,GAAsB,OAAA;AAQ5B,SAAS,4BAA4B,IAAA,EAA4B;AACtE,EAAA,MAAM,OAAO,IAAA,CAAK,QAAA,CAAS,GAAG,CAAA,GAAI,IAAA,GAAO,GAAG,IAAI,CAAA,CAAA,CAAA;AAChD,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,CAAA,EAAG,IAAI,CAAA,SAAA,EAAY,qBAAqB,CAAA,CAAA;AAAA,IAC9C,IAAA,EAAM,CAAA,EAAG,IAAI,CAAA,SAAA,EAAY,qBAAqB,CAAA;AAAA,GAChD;AACF;AASO,SAAS,wBAAA,GAAmC;AACjD,EAAA,OAAO,CAAA,6BAAA,EAAgC,mBAAmB,CAAA,CAAA,EAAI,mBAAmB,CAAA,eAAA,CAAA;AACnF;AAGO,SAAS,yBAAA,GAA0C;AACxD,EAAA,MAAM,OAA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,IAC7D,IAAA,EAAM,IAAI,GAAA,CAAI,CAAA,EAAA,EAAK,qBAAqB,CAAA,CAAA,EAAI,2PAAe,CAAA,CAAE;AAAA,GAC/D;AACF","file":"paths.cjs","sourcesContent":["{\n \"name\": \"veilix-sdk\",\n \"version\": \"0.3.1\",\n \"description\": \"Veilix Privacy SDK\",\n \"type\": \"module\",\n \"main\": \"./dist/index.cjs\",\n \"module\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"sideEffects\": false,\n \"exports\": {\n \".\": {\n \"import\": {\n \"types\": \"./dist/index.d.ts\",\n \"default\": \"./dist/index.js\"\n },\n \"require\": {\n \"types\": \"./dist/index.d.cts\",\n \"default\": \"./dist/index.cjs\"\n }\n },\n \"./circuits/paths\": {\n \"import\": \"./dist/circuits/paths.js\",\n \"require\": \"./dist/circuits/paths.cjs\",\n \"default\": \"./dist/circuits/paths.js\"\n },\n \"./circuits/*\": \"./dist/circuits/*\",\n \"./vite\": {\n \"import\": {\n \"types\": \"./dist/vite/index.d.ts\",\n \"default\": \"./dist/vite/index.js\"\n },\n \"require\": {\n \"types\": \"./dist/vite/index.d.cts\",\n \"default\": \"./dist/vite/index.cjs\"\n }\n },\n \"./react\": {\n \"import\": {\n \"types\": \"./dist/react/index.d.ts\",\n \"default\": \"./dist/react/index.js\"\n },\n \"require\": {\n \"types\": \"./dist/react/index.d.cts\",\n \"default\": \"./dist/react/index.cjs\"\n }\n },\n \"./package.json\": \"./package.json\"\n },\n \"peerDependencies\": {\n \"@solana/wallet-adapter-react\": \">=0.15.0\",\n \"react\": \">=18\"\n },\n \"peerDependenciesMeta\": {\n \"@solana/wallet-adapter-react\": {\n \"optional\": true\n },\n \"react\": {\n \"optional\": true\n }\n },\n \"files\": [\n \"dist\"\n ],\n \"scripts\": {\n \"prepare:snarkjs\": \"node scripts/prepare-snarkjs.mjs\",\n \"build\": \"npm run prepare:snarkjs && tsup\",\n \"dev\": \"npm run prepare:snarkjs && tsup --watch\",\n \"typecheck\": \"npm run prepare:snarkjs && tsc --noEmit\",\n \"prepublishOnly\": \"npm run build\"\n },\n \"keywords\": [\n \"veilix-sdk\",\n \"sdk\"\n ],\n \"license\": \"MIT\",\n \"devDependencies\": {\n \"@solana/wallet-adapter-react\": \"^0.15.39\",\n \"@types/bn.js\": \"^5.2.0\",\n \"@types/node\": \"^26.0.0\",\n \"@types/react\": \"^19.1.8\",\n \"react\": \"^19.1.0\",\n \"tsup\": \"^8.5.0\",\n \"typescript\": \"^5.8.3\"\n },\n \"engines\": {\n \"node\": \">=18\"\n },\n \"dependencies\": {\n \"@coral-xyz/anchor\": \"^0.31.1\",\n \"@solana/spl-token\": \"^0.4.14\",\n \"@solana/web3.js\": \"^1.98.4\",\n \"@switchboard-xyz/common\": \"^5.8.1\",\n \"@switchboard-xyz/on-demand\": \"^3.10.1\",\n \"bn.js\": \"^5.2.5\",\n \"buffer\": \"^6.0.3\",\n \"ffjavascript\": \"^0.3.1\",\n \"fixed-merkle-tree\": \"^0.7.3\",\n \"poseidon-hash\": \"^1.0.1\",\n \"tweetnacl\": \"^1.0.3\"\n }\n}\n","import packageJson from \"../../package.json\";\n\n/** npm package name (used to load the standalone circuits module). */\nexport const PACKAGE_NAME = packageJson.name;\n\n/** Published npm version (pins CDN circuit URLs in production). */\nexport const PACKAGE_VERSION = packageJson.version;\n\n/** Withdraw circuit artifact filenames (published under `veilix-sdk/circuits/`). */\nexport const WITHDRAW_CIRCUIT_WASM = \"withdraw.wasm\";\nexport const WITHDRAW_CIRCUIT_ZKEY = \"withdraw.zkey\";\n/**\n * Pinned SHA-256 hashes for the published withdraw circuit artifacts.\n * These are verified in-browser before passing artifacts to snarkjs.\n */\nexport const WITHDRAW_CIRCUIT_SHA256 = {\n wasm: \"5f9eb88bcbc1b3dd5669dad6fdd3b91d59dd2d617ad0b34827af8a498d13fa60\",\n zkey: \"73e0d2328eca8f48024b69b42d659b68d7dd2f067d762079e859ffff34360a1a\",\n} as const;\n\n/** Optional self-hosted path convention (opt-in via `circuitPathsBase`). */\nexport const SELF_HOSTED_CIRCUIT_BASE = \"/circuits/\";\n\n/**\n * Stable published source for the pinned circuit artifacts.\n *\n * Decoupled from {@link PACKAGE_VERSION} on purpose: the withdraw circuit is a\n * fixed cryptographic artifact, so SDK code releases must not change where the\n * verified circuits are fetched from. Bump these together with\n * {@link WITHDRAW_CIRCUIT_SHA256} only when the circuit itself changes.\n */\nexport const CIRCUIT_CDN_PACKAGE = \"veilix-sdk\";\nexport const CIRCUIT_CDN_VERSION = \"0.2.0\";\n\nexport type CircuitPaths = {\n wasm: string;\n zkey: string;\n};\n\n/** Resolve circuit URLs when the caller knows the package `dist/` root. */\nexport function resolveCircuitPathsFromBase(base: string): CircuitPaths {\n const root = base.endsWith(\"/\") ? base : `${base}/`;\n return {\n wasm: `${root}circuits/${WITHDRAW_CIRCUIT_WASM}`,\n zkey: `${root}circuits/${WITHDRAW_CIRCUIT_ZKEY}`,\n };\n}\n\n/**\n * Base URL for circuit files on jsDelivr.\n *\n * Pinned to {@link CIRCUIT_CDN_PACKAGE}@{@link CIRCUIT_CDN_VERSION} (not the\n * current SDK version) so the bytes always match {@link WITHDRAW_CIRCUIT_SHA256}.\n * This URL is independent of the consuming app's origin/domain.\n */\nexport function resolveNpmCdnCircuitBase(): string {\n return `https://cdn.jsdelivr.net/npm/${CIRCUIT_CDN_PACKAGE}@${CIRCUIT_CDN_VERSION}/dist/circuits/`;\n}\n\n/** Trusted jsDelivr fallback paths for pinned withdraw circuit artifacts. */\nexport function resolveNpmCdnCircuitPaths(): CircuitPaths {\n const base = resolveNpmCdnCircuitBase();\n return {\n wasm: `${base}${WITHDRAW_CIRCUIT_WASM}`,\n zkey: `${base}${WITHDRAW_CIRCUIT_ZKEY}`,\n };\n}\n\nfunction isLocalDevHost(hostname: string): boolean {\n return (\n hostname === \"localhost\" ||\n hostname === \"127.0.0.1\" ||\n hostname === \"[::1]\"\n );\n}\n\n/**\n * Browser circuit URLs.\n *\n * - Local dev (Vite): `/node_modules/<pkg>/dist/circuits/` — Vite serves node_modules.\n * - Production: pinned, domain-independent jsDelivr CDN (verified by SHA-256 before use).\n *\n * The production default does not depend on the app's own origin/domain, so it\n * works on any deployed host with no copy step. Artifacts are always integrity\n * checked before proving (see {@link WITHDRAW_CIRCUIT_SHA256}). To self-host\n * instead, pass {@link VeilixSdkInitOptions.circuitPathsBase} (e.g. `\"/circuits/\"`);\n * it is verified too and falls back to the CDN if unavailable.\n */\nexport function resolveBrowserCircuitPaths(\n baseOverride?: string\n): CircuitPaths | null {\n if (typeof window === \"undefined\") {\n return null;\n }\n\n if (baseOverride !== undefined) {\n return resolveCircuitPathsFromBase(baseOverride);\n }\n\n if (isLocalDevHost(window.location.hostname)) {\n const base = `/node_modules/${PACKAGE_NAME}/dist/circuits/`;\n return {\n wasm: `${base}${WITHDRAW_CIRCUIT_WASM}`,\n zkey: `${base}${WITHDRAW_CIRCUIT_ZKEY}`,\n };\n }\n\n return resolveNpmCdnCircuitPaths();\n}\n","import {\n WITHDRAW_CIRCUIT_WASM,\n WITHDRAW_CIRCUIT_ZKEY,\n resolveBrowserCircuitPaths,\n resolveCircuitPathsFromBase,\n type CircuitPaths,\n} from \"./constants\";\n\nexport {\n PACKAGE_NAME,\n SELF_HOSTED_CIRCUIT_BASE,\n WITHDRAW_CIRCUIT_SHA256,\n WITHDRAW_CIRCUIT_WASM,\n WITHDRAW_CIRCUIT_ZKEY,\n resolveBrowserCircuitPaths,\n resolveCircuitPathsFromBase,\n resolveNpmCdnCircuitPaths,\n resolveNpmCdnCircuitBase,\n type CircuitPaths,\n} from \"./constants\";\n\n/**\n * Resolve default Groth16 circuit URLs.\n *\n * Published as `veilix-sdk/circuits/paths` so `import.meta.url` stays next to\n * `withdraw.wasm` and `withdraw.zkey` in `dist/circuits/` (Node / unbundled ESM).\n *\n * In the browser, defaults to `/node_modules/<pkg>/dist/circuits/` on localhost\n * and the pinned, SHA-256-verified jsDelivr CDN in production (domain-independent).\n * Override via {@link VeilixSdkInitOptions.circuitPathsBase},\n * {@link resolveCircuitPathsFromBase}, or {@link GenerateWithdrawProofOptions}.\n */\nexport function resolveCircuitPaths(base?: string): CircuitPaths {\n if (base !== undefined) {\n return resolveCircuitPathsFromBase(base);\n }\n\n const browser = resolveBrowserCircuitPaths();\n if (browser) {\n return browser;\n }\n\n return {\n wasm: new URL(`./${WITHDRAW_CIRCUIT_WASM}`, import.meta.url).href,\n zkey: new URL(`./${WITHDRAW_CIRCUIT_ZKEY}`, import.meta.url).href,\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../package.json","../../src/circuits/constants.ts","../../src/circuits/paths.ts"],"names":[],"mappings":";AAAA,IAAA,eAAA,GAAA;AAAA,EACE,IAAA,EAAQ,YAmGV,CAAA;;;ACjGO,IAAM,eAAe,eAAA,CAAY;AAMjC,IAAM,qBAAA,GAAwB;AAC9B,IAAM,qBAAA,GAAwB;AAK9B,IAAM,uBAAA,GAA0B;AAAA,EACrC,IAAA,EAAM,kEAAA;AAAA,EACN,IAAA,EAAM;AACR;AAGO,IAAM,wBAAA,GAA2B;AAUjC,IAAM,mBAAA,GAAsB,YAAA;AAC5B,IAAM,mBAAA,GAAsB,OAAA;AAQ5B,SAAS,4BAA4B,IAAA,EAA4B;AACtE,EAAA,MAAM,OAAO,IAAA,CAAK,QAAA,CAAS,GAAG,CAAA,GAAI,IAAA,GAAO,GAAG,IAAI,CAAA,CAAA,CAAA;AAChD,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,CAAA,EAAG,IAAI,CAAA,SAAA,EAAY,qBAAqB,CAAA,CAAA;AAAA,IAC9C,IAAA,EAAM,CAAA,EAAG,IAAI,CAAA,SAAA,EAAY,qBAAqB,CAAA;AAAA,GAChD;AACF;AASO,SAAS,wBAAA,GAAmC;AACjD,EAAA,OAAO,CAAA,6BAAA,EAAgC,mBAAmB,CAAA,CAAA,EAAI,mBAAmB,CAAA,eAAA,CAAA;AACnF;AAGO,SAAS,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EAAI,MAAA,CAAA,IAAA,CAAY,GAAG,CAAA,CAAE,IAAA;AAAA,IAC7D,IAAA,EAAM,IAAI,GAAA,CAAI,CAAA,EAAA,EAAK,qBAAqB,CAAA,CAAA,EAAI,MAAA,CAAA,IAAA,CAAY,GAAG,CAAA,CAAE;AAAA,GAC/D;AACF","file":"paths.js","sourcesContent":["{\n \"name\": \"veilix-sdk\",\n \"version\": \"0.3.0\",\n \"description\": \"Veilix Privacy SDK\",\n \"type\": \"module\",\n \"main\": \"./dist/index.cjs\",\n \"module\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"sideEffects\": false,\n \"exports\": {\n \".\": {\n \"import\": {\n \"types\": \"./dist/index.d.ts\",\n \"default\": \"./dist/index.js\"\n },\n \"require\": {\n \"types\": \"./dist/index.d.cts\",\n \"default\": \"./dist/index.cjs\"\n }\n },\n \"./circuits/paths\": {\n \"import\": \"./dist/circuits/paths.js\",\n \"require\": \"./dist/circuits/paths.cjs\",\n \"default\": \"./dist/circuits/paths.js\"\n },\n \"./circuits/*\": \"./dist/circuits/*\",\n \"./vite\": {\n \"import\": {\n \"types\": \"./dist/vite/index.d.ts\",\n \"default\": \"./dist/vite/index.js\"\n },\n \"require\": {\n \"types\": \"./dist/vite/index.d.cts\",\n \"default\": \"./dist/vite/index.cjs\"\n }\n },\n \"./react\": {\n \"import\": {\n \"types\": \"./dist/react/index.d.ts\",\n \"default\": \"./dist/react/index.js\"\n },\n \"require\": {\n \"types\": \"./dist/react/index.d.cts\",\n \"default\": \"./dist/react/index.cjs\"\n }\n },\n \"./package.json\": \"./package.json\"\n },\n \"peerDependencies\": {\n \"@solana/wallet-adapter-react\": \">=0.15.0\",\n \"react\": \">=18\"\n },\n \"peerDependenciesMeta\": {\n \"@solana/wallet-adapter-react\": {\n \"optional\": true\n },\n \"react\": {\n \"optional\": true\n }\n },\n \"files\": [\n \"dist\"\n ],\n \"scripts\": {\n \"prepare:snarkjs\": \"node scripts/prepare-snarkjs.mjs\",\n \"build\": \"npm run prepare:snarkjs && tsup\",\n \"dev\": \"npm run prepare:snarkjs && tsup --watch\",\n \"typecheck\": \"npm run prepare:snarkjs && tsc --noEmit\",\n \"prepublishOnly\": \"npm run build\"\n },\n \"keywords\": [\n \"veilix-sdk\",\n \"sdk\"\n ],\n \"license\": \"MIT\",\n \"devDependencies\": {\n \"@solana/wallet-adapter-react\": \"^0.15.39\",\n \"@types/bn.js\": \"^5.2.0\",\n \"@types/node\": \"^26.0.0\",\n \"@types/react\": \"^19.1.8\",\n \"react\": \"^19.1.0\",\n \"tsup\": \"^8.5.0\",\n \"typescript\": \"^5.8.3\"\n },\n \"engines\": {\n \"node\": \">=18\"\n },\n \"dependencies\": {\n \"@coral-xyz/anchor\": \"^0.31.1\",\n \"@solana/spl-token\": \"^0.4.14\",\n \"@solana/web3.js\": \"^1.98.4\",\n \"@switchboard-xyz/common\": \"^5.8.1\",\n \"@switchboard-xyz/on-demand\": \"^3.10.1\",\n \"bn.js\": \"^5.2.5\",\n \"buffer\": \"^6.0.3\",\n \"ffjavascript\": \"^0.3.1\",\n \"fixed-merkle-tree\": \"^0.7.3\",\n \"poseidon-hash\": \"^1.0.1\",\n \"tweetnacl\": \"^1.0.3\"\n }\n}\n","import packageJson from \"../../package.json\";\n\n/** npm package name (used to load the standalone circuits module). */\nexport const PACKAGE_NAME = packageJson.name;\n\n/** Published npm version (pins CDN circuit URLs in production). */\nexport const PACKAGE_VERSION = packageJson.version;\n\n/** Withdraw circuit artifact filenames (published under `veilix-sdk/circuits/`). */\nexport const WITHDRAW_CIRCUIT_WASM = \"withdraw.wasm\";\nexport const WITHDRAW_CIRCUIT_ZKEY = \"withdraw.zkey\";\n/**\n * Pinned SHA-256 hashes for the published withdraw circuit artifacts.\n * These are verified in-browser before passing artifacts to snarkjs.\n */\nexport const WITHDRAW_CIRCUIT_SHA256 = {\n wasm: \"5f9eb88bcbc1b3dd5669dad6fdd3b91d59dd2d617ad0b34827af8a498d13fa60\",\n zkey: \"73e0d2328eca8f48024b69b42d659b68d7dd2f067d762079e859ffff34360a1a\",\n} as const;\n\n/** Optional self-hosted path convention (opt-in via `circuitPathsBase`). */\nexport const SELF_HOSTED_CIRCUIT_BASE = \"/circuits/\";\n\n/**\n * Stable published source for the pinned circuit artifacts.\n *\n * Decoupled from {@link PACKAGE_VERSION} on purpose: the withdraw circuit is a\n * fixed cryptographic artifact, so SDK code releases must not change where the\n * verified circuits are fetched from. Bump these together with\n * {@link WITHDRAW_CIRCUIT_SHA256} only when the circuit itself changes.\n */\nexport const CIRCUIT_CDN_PACKAGE = \"veilix-sdk\";\nexport const CIRCUIT_CDN_VERSION = \"0.2.0\";\n\nexport type CircuitPaths = {\n wasm: string;\n zkey: string;\n};\n\n/** Resolve circuit URLs when the caller knows the package `dist/` root. */\nexport function resolveCircuitPathsFromBase(base: string): CircuitPaths {\n const root = base.endsWith(\"/\") ? base : `${base}/`;\n return {\n wasm: `${root}circuits/${WITHDRAW_CIRCUIT_WASM}`,\n zkey: `${root}circuits/${WITHDRAW_CIRCUIT_ZKEY}`,\n };\n}\n\n/**\n * Base URL for circuit files on jsDelivr.\n *\n * Pinned to {@link CIRCUIT_CDN_PACKAGE}@{@link CIRCUIT_CDN_VERSION} (not the\n * current SDK version) so the bytes always match {@link WITHDRAW_CIRCUIT_SHA256}.\n * This URL is independent of the consuming app's origin/domain.\n */\nexport function resolveNpmCdnCircuitBase(): string {\n return `https://cdn.jsdelivr.net/npm/${CIRCUIT_CDN_PACKAGE}@${CIRCUIT_CDN_VERSION}/dist/circuits/`;\n}\n\n/** Trusted jsDelivr fallback paths for pinned withdraw circuit artifacts. */\nexport function resolveNpmCdnCircuitPaths(): CircuitPaths {\n const base = resolveNpmCdnCircuitBase();\n return {\n wasm: `${base}${WITHDRAW_CIRCUIT_WASM}`,\n zkey: `${base}${WITHDRAW_CIRCUIT_ZKEY}`,\n };\n}\n\nfunction isLocalDevHost(hostname: string): boolean {\n return (\n hostname === \"localhost\" ||\n hostname === \"127.0.0.1\" ||\n hostname === \"[::1]\"\n );\n}\n\n/**\n * Browser circuit URLs.\n *\n * - Local dev (Vite): `/node_modules/<pkg>/dist/circuits/` — Vite serves node_modules.\n * - Production: pinned, domain-independent jsDelivr CDN (verified by SHA-256 before use).\n *\n * The production default does not depend on the app's own origin/domain, so it\n * works on any deployed host with no copy step. Artifacts are always integrity\n * checked before proving (see {@link WITHDRAW_CIRCUIT_SHA256}). To self-host\n * instead, pass {@link VeilixSdkInitOptions.circuitPathsBase} (e.g. `\"/circuits/\"`);\n * it is verified too and falls back to the CDN if unavailable.\n */\nexport function resolveBrowserCircuitPaths(\n baseOverride?: string\n): CircuitPaths | null {\n if (typeof window === \"undefined\") {\n return null;\n }\n\n if (baseOverride !== undefined) {\n return resolveCircuitPathsFromBase(baseOverride);\n }\n\n if (isLocalDevHost(window.location.hostname)) {\n const base = `/node_modules/${PACKAGE_NAME}/dist/circuits/`;\n return {\n wasm: `${base}${WITHDRAW_CIRCUIT_WASM}`,\n zkey: `${base}${WITHDRAW_CIRCUIT_ZKEY}`,\n };\n }\n\n return resolveNpmCdnCircuitPaths();\n}\n","import {\n WITHDRAW_CIRCUIT_WASM,\n WITHDRAW_CIRCUIT_ZKEY,\n resolveBrowserCircuitPaths,\n resolveCircuitPathsFromBase,\n type CircuitPaths,\n} from \"./constants\";\n\nexport {\n PACKAGE_NAME,\n SELF_HOSTED_CIRCUIT_BASE,\n WITHDRAW_CIRCUIT_SHA256,\n WITHDRAW_CIRCUIT_WASM,\n WITHDRAW_CIRCUIT_ZKEY,\n resolveBrowserCircuitPaths,\n resolveCircuitPathsFromBase,\n resolveNpmCdnCircuitPaths,\n resolveNpmCdnCircuitBase,\n type CircuitPaths,\n} from \"./constants\";\n\n/**\n * Resolve default Groth16 circuit URLs.\n *\n * Published as `veilix-sdk/circuits/paths` so `import.meta.url` stays next to\n * `withdraw.wasm` and `withdraw.zkey` in `dist/circuits/` (Node / unbundled ESM).\n *\n * In the browser, defaults to `/node_modules/<pkg>/dist/circuits/` on localhost\n * and the pinned, SHA-256-verified jsDelivr CDN in production (domain-independent).\n * Override via {@link VeilixSdkInitOptions.circuitPathsBase},\n * {@link resolveCircuitPathsFromBase}, or {@link GenerateWithdrawProofOptions}.\n */\nexport function resolveCircuitPaths(base?: string): CircuitPaths {\n if (base !== undefined) {\n return resolveCircuitPathsFromBase(base);\n }\n\n const browser = resolveBrowserCircuitPaths();\n if (browser) {\n return browser;\n }\n\n return {\n wasm: new URL(`./${WITHDRAW_CIRCUIT_WASM}`, import.meta.url).href,\n zkey: new URL(`./${WITHDRAW_CIRCUIT_ZKEY}`, import.meta.url).href,\n };\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../package.json","../../src/circuits/constants.ts","../../src/circuits/paths.ts"],"names":[],"mappings":";AAAA,IAAA,eAAA,GAAA;AAAA,EACE,IAAA,EAAQ,YAmGV,CAAA;;;ACjGO,IAAM,eAAe,eAAA,CAAY;AAMjC,IAAM,qBAAA,GAAwB;AAC9B,IAAM,qBAAA,GAAwB;AAK9B,IAAM,uBAAA,GAA0B;AAAA,EACrC,IAAA,EAAM,kEAAA;AAAA,EACN,IAAA,EAAM;AACR;AAGO,IAAM,wBAAA,GAA2B;AAUjC,IAAM,mBAAA,GAAsB,YAAA;AAC5B,IAAM,mBAAA,GAAsB,OAAA;AAQ5B,SAAS,4BAA4B,IAAA,EAA4B;AACtE,EAAA,MAAM,OAAO,IAAA,CAAK,QAAA,CAAS,GAAG,CAAA,GAAI,IAAA,GAAO,GAAG,IAAI,CAAA,CAAA,CAAA;AAChD,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,CAAA,EAAG,IAAI,CAAA,SAAA,EAAY,qBAAqB,CAAA,CAAA;AAAA,IAC9C,IAAA,EAAM,CAAA,EAAG,IAAI,CAAA,SAAA,EAAY,qBAAqB,CAAA;AAAA,GAChD;AACF;AASO,SAAS,wBAAA,GAAmC;AACjD,EAAA,OAAO,CAAA,6BAAA,EAAgC,mBAAmB,CAAA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,IAAI,GAAA,CAAI,CAAA,EAAA,EAAK,qBAAqB,CAAA,CAAA,EAAI,MAAA,CAAA,IAAA,CAAY,GAAG,CAAA,CAAE,IAAA;AAAA,IAC7D,IAAA,EAAM,IAAI,GAAA,CAAI,CAAA,EAAA,EAAK,qBAAqB,CAAA,CAAA,EAAI,MAAA,CAAA,IAAA,CAAY,GAAG,CAAA,CAAE;AAAA,GAC/D;AACF","file":"paths.js","sourcesContent":["{\n \"name\": \"veilix-sdk\",\n \"version\": \"0.3.1\",\n \"description\": \"Veilix Privacy SDK\",\n \"type\": \"module\",\n \"main\": \"./dist/index.cjs\",\n \"module\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"sideEffects\": false,\n \"exports\": {\n \".\": {\n \"import\": {\n \"types\": \"./dist/index.d.ts\",\n \"default\": \"./dist/index.js\"\n },\n \"require\": {\n \"types\": \"./dist/index.d.cts\",\n \"default\": \"./dist/index.cjs\"\n }\n },\n \"./circuits/paths\": {\n \"import\": \"./dist/circuits/paths.js\",\n \"require\": \"./dist/circuits/paths.cjs\",\n \"default\": \"./dist/circuits/paths.js\"\n },\n \"./circuits/*\": \"./dist/circuits/*\",\n \"./vite\": {\n \"import\": {\n \"types\": \"./dist/vite/index.d.ts\",\n \"default\": \"./dist/vite/index.js\"\n },\n \"require\": {\n \"types\": \"./dist/vite/index.d.cts\",\n \"default\": \"./dist/vite/index.cjs\"\n }\n },\n \"./react\": {\n \"import\": {\n \"types\": \"./dist/react/index.d.ts\",\n \"default\": \"./dist/react/index.js\"\n },\n \"require\": {\n \"types\": \"./dist/react/index.d.cts\",\n \"default\": \"./dist/react/index.cjs\"\n }\n },\n \"./package.json\": \"./package.json\"\n },\n \"peerDependencies\": {\n \"@solana/wallet-adapter-react\": \">=0.15.0\",\n \"react\": \">=18\"\n },\n \"peerDependenciesMeta\": {\n \"@solana/wallet-adapter-react\": {\n \"optional\": true\n },\n \"react\": {\n \"optional\": true\n }\n },\n \"files\": [\n \"dist\"\n ],\n \"scripts\": {\n \"prepare:snarkjs\": \"node scripts/prepare-snarkjs.mjs\",\n \"build\": \"npm run prepare:snarkjs && tsup\",\n \"dev\": \"npm run prepare:snarkjs && tsup --watch\",\n \"typecheck\": \"npm run prepare:snarkjs && tsc --noEmit\",\n \"prepublishOnly\": \"npm run build\"\n },\n \"keywords\": [\n \"veilix-sdk\",\n \"sdk\"\n ],\n \"license\": \"MIT\",\n \"devDependencies\": {\n \"@solana/wallet-adapter-react\": \"^0.15.39\",\n \"@types/bn.js\": \"^5.2.0\",\n \"@types/node\": \"^26.0.0\",\n \"@types/react\": \"^19.1.8\",\n \"react\": \"^19.1.0\",\n \"tsup\": \"^8.5.0\",\n \"typescript\": \"^5.8.3\"\n },\n \"engines\": {\n \"node\": \">=18\"\n },\n \"dependencies\": {\n \"@coral-xyz/anchor\": \"^0.31.1\",\n \"@solana/spl-token\": \"^0.4.14\",\n \"@solana/web3.js\": \"^1.98.4\",\n \"@switchboard-xyz/common\": \"^5.8.1\",\n \"@switchboard-xyz/on-demand\": \"^3.10.1\",\n \"bn.js\": \"^5.2.5\",\n \"buffer\": \"^6.0.3\",\n \"ffjavascript\": \"^0.3.1\",\n \"fixed-merkle-tree\": \"^0.7.3\",\n \"poseidon-hash\": \"^1.0.1\",\n \"tweetnacl\": \"^1.0.3\"\n }\n}\n","import packageJson from \"../../package.json\";\n\n/** npm package name (used to load the standalone circuits module). */\nexport const PACKAGE_NAME = packageJson.name;\n\n/** Published npm version (pins CDN circuit URLs in production). */\nexport const PACKAGE_VERSION = packageJson.version;\n\n/** Withdraw circuit artifact filenames (published under `veilix-sdk/circuits/`). */\nexport const WITHDRAW_CIRCUIT_WASM = \"withdraw.wasm\";\nexport const WITHDRAW_CIRCUIT_ZKEY = \"withdraw.zkey\";\n/**\n * Pinned SHA-256 hashes for the published withdraw circuit artifacts.\n * These are verified in-browser before passing artifacts to snarkjs.\n */\nexport const WITHDRAW_CIRCUIT_SHA256 = {\n wasm: \"5f9eb88bcbc1b3dd5669dad6fdd3b91d59dd2d617ad0b34827af8a498d13fa60\",\n zkey: \"73e0d2328eca8f48024b69b42d659b68d7dd2f067d762079e859ffff34360a1a\",\n} as const;\n\n/** Optional self-hosted path convention (opt-in via `circuitPathsBase`). */\nexport const SELF_HOSTED_CIRCUIT_BASE = \"/circuits/\";\n\n/**\n * Stable published source for the pinned circuit artifacts.\n *\n * Decoupled from {@link PACKAGE_VERSION} on purpose: the withdraw circuit is a\n * fixed cryptographic artifact, so SDK code releases must not change where the\n * verified circuits are fetched from. Bump these together with\n * {@link WITHDRAW_CIRCUIT_SHA256} only when the circuit itself changes.\n */\nexport const CIRCUIT_CDN_PACKAGE = \"veilix-sdk\";\nexport const CIRCUIT_CDN_VERSION = \"0.2.0\";\n\nexport type CircuitPaths = {\n wasm: string;\n zkey: string;\n};\n\n/** Resolve circuit URLs when the caller knows the package `dist/` root. */\nexport function resolveCircuitPathsFromBase(base: string): CircuitPaths {\n const root = base.endsWith(\"/\") ? base : `${base}/`;\n return {\n wasm: `${root}circuits/${WITHDRAW_CIRCUIT_WASM}`,\n zkey: `${root}circuits/${WITHDRAW_CIRCUIT_ZKEY}`,\n };\n}\n\n/**\n * Base URL for circuit files on jsDelivr.\n *\n * Pinned to {@link CIRCUIT_CDN_PACKAGE}@{@link CIRCUIT_CDN_VERSION} (not the\n * current SDK version) so the bytes always match {@link WITHDRAW_CIRCUIT_SHA256}.\n * This URL is independent of the consuming app's origin/domain.\n */\nexport function resolveNpmCdnCircuitBase(): string {\n return `https://cdn.jsdelivr.net/npm/${CIRCUIT_CDN_PACKAGE}@${CIRCUIT_CDN_VERSION}/dist/circuits/`;\n}\n\n/** Trusted jsDelivr fallback paths for pinned withdraw circuit artifacts. */\nexport function resolveNpmCdnCircuitPaths(): CircuitPaths {\n const base = resolveNpmCdnCircuitBase();\n return {\n wasm: `${base}${WITHDRAW_CIRCUIT_WASM}`,\n zkey: `${base}${WITHDRAW_CIRCUIT_ZKEY}`,\n };\n}\n\nfunction isLocalDevHost(hostname: string): boolean {\n return (\n hostname === \"localhost\" ||\n hostname === \"127.0.0.1\" ||\n hostname === \"[::1]\"\n );\n}\n\n/**\n * Browser circuit URLs.\n *\n * - Local dev (Vite): `/node_modules/<pkg>/dist/circuits/` — Vite serves node_modules.\n * - Production: pinned, domain-independent jsDelivr CDN (verified by SHA-256 before use).\n *\n * The production default does not depend on the app's own origin/domain, so it\n * works on any deployed host with no copy step. Artifacts are always integrity\n * checked before proving (see {@link WITHDRAW_CIRCUIT_SHA256}). To self-host\n * instead, pass {@link VeilixSdkInitOptions.circuitPathsBase} (e.g. `\"/circuits/\"`);\n * it is verified too and falls back to the CDN if unavailable.\n */\nexport function resolveBrowserCircuitPaths(\n baseOverride?: string\n): CircuitPaths | null {\n if (typeof window === \"undefined\") {\n return null;\n }\n\n if (baseOverride !== undefined) {\n return resolveCircuitPathsFromBase(baseOverride);\n }\n\n if (isLocalDevHost(window.location.hostname)) {\n const base = `/node_modules/${PACKAGE_NAME}/dist/circuits/`;\n return {\n wasm: `${base}${WITHDRAW_CIRCUIT_WASM}`,\n zkey: `${base}${WITHDRAW_CIRCUIT_ZKEY}`,\n };\n }\n\n return resolveNpmCdnCircuitPaths();\n}\n","import {\n WITHDRAW_CIRCUIT_WASM,\n WITHDRAW_CIRCUIT_ZKEY,\n resolveBrowserCircuitPaths,\n resolveCircuitPathsFromBase,\n type CircuitPaths,\n} from \"./constants\";\n\nexport {\n PACKAGE_NAME,\n SELF_HOSTED_CIRCUIT_BASE,\n WITHDRAW_CIRCUIT_SHA256,\n WITHDRAW_CIRCUIT_WASM,\n WITHDRAW_CIRCUIT_ZKEY,\n resolveBrowserCircuitPaths,\n resolveCircuitPathsFromBase,\n resolveNpmCdnCircuitPaths,\n resolveNpmCdnCircuitBase,\n type CircuitPaths,\n} from \"./constants\";\n\n/**\n * Resolve default Groth16 circuit URLs.\n *\n * Published as `veilix-sdk/circuits/paths` so `import.meta.url` stays next to\n * `withdraw.wasm` and `withdraw.zkey` in `dist/circuits/` (Node / unbundled ESM).\n *\n * In the browser, defaults to `/node_modules/<pkg>/dist/circuits/` on localhost\n * and the pinned, SHA-256-verified jsDelivr CDN in production (domain-independent).\n * Override via {@link VeilixSdkInitOptions.circuitPathsBase},\n * {@link resolveCircuitPathsFromBase}, or {@link GenerateWithdrawProofOptions}.\n */\nexport function resolveCircuitPaths(base?: string): CircuitPaths {\n if (base !== undefined) {\n return resolveCircuitPathsFromBase(base);\n }\n\n const browser = resolveBrowserCircuitPaths();\n if (browser) {\n return browser;\n }\n\n return {\n wasm: new URL(`./${WITHDRAW_CIRCUIT_WASM}`, import.meta.url).href,\n zkey: new URL(`./${WITHDRAW_CIRCUIT_ZKEY}`, import.meta.url).href,\n };\n}\n"]}
|
package/dist/index.cjs
CHANGED
|
@@ -8289,7 +8289,7 @@ function getDepositQueueForNetwork(network) {
|
|
|
8289
8289
|
// package.json
|
|
8290
8290
|
var package_default = {
|
|
8291
8291
|
name: "veilix-sdk",
|
|
8292
|
-
version: "0.3.
|
|
8292
|
+
version: "0.3.1"};
|
|
8293
8293
|
|
|
8294
8294
|
// src/circuits/constants.ts
|
|
8295
8295
|
var PACKAGE_NAME = package_default.name;
|
|
@@ -8464,10 +8464,19 @@ async function createRuntimeConfig(options) {
|
|
|
8464
8464
|
};
|
|
8465
8465
|
}
|
|
8466
8466
|
function pushRuntimeContext(config) {
|
|
8467
|
+
const active = runtimeContextStack.find((other) => other.programId !== config.programId);
|
|
8468
|
+
if (active) {
|
|
8469
|
+
throw new Error(
|
|
8470
|
+
`veilix-sdk: another SDK instance is running on program ${active.programId}; instances on different networks must run one at a time`
|
|
8471
|
+
);
|
|
8472
|
+
}
|
|
8467
8473
|
runtimeContextStack.push(config);
|
|
8468
8474
|
}
|
|
8469
|
-
function popRuntimeContext() {
|
|
8470
|
-
runtimeContextStack.
|
|
8475
|
+
function popRuntimeContext(config) {
|
|
8476
|
+
const index = runtimeContextStack.lastIndexOf(config);
|
|
8477
|
+
if (index !== -1) {
|
|
8478
|
+
runtimeContextStack.splice(index, 1);
|
|
8479
|
+
}
|
|
8471
8480
|
}
|
|
8472
8481
|
function getConfig() {
|
|
8473
8482
|
const active = runtimeContextStack.at(-1);
|
|
@@ -17658,9 +17667,11 @@ async function buildDepositTx({
|
|
|
17658
17667
|
onChainBackup = false,
|
|
17659
17668
|
computeUnitPrice = 5e3,
|
|
17660
17669
|
computeUnitLimit = DEPOSIT_COMPUTE_UNIT_LIMIT,
|
|
17661
|
-
circuitArtifacts
|
|
17670
|
+
circuitArtifacts,
|
|
17671
|
+
encryptKey
|
|
17662
17672
|
}) {
|
|
17663
17673
|
const { connection } = getConfig();
|
|
17674
|
+
const sealKey = onChainBackup ? encryptKey ?? requireEncryptKey() : null;
|
|
17664
17675
|
const sender = toPublicKey(senderPublicKey);
|
|
17665
17676
|
const utxo = decodeNote(note);
|
|
17666
17677
|
const mint = utxo.mint;
|
|
@@ -17673,7 +17684,7 @@ async function buildDepositTx({
|
|
|
17673
17684
|
`veilix-sdk: deposit amount ${utxo.amount} exceeds the tree limit of ${tree.maxDepositAmount}`
|
|
17674
17685
|
);
|
|
17675
17686
|
}
|
|
17676
|
-
const encryptedOutput1 =
|
|
17687
|
+
const encryptedOutput1 = sealKey ? encryptNoteOutput(sealKey, utxo) : new Uint8Array();
|
|
17677
17688
|
const encryptedOutput2 = new Uint8Array();
|
|
17678
17689
|
const proved = await withCircuitArtifacts(
|
|
17679
17690
|
circuitArtifacts,
|
|
@@ -17728,16 +17739,15 @@ async function buildInitNotesInstructionIfNeeded(sender) {
|
|
|
17728
17739
|
if (await fetchNotesAccount(sender)) return null;
|
|
17729
17740
|
return program.methods.initNotes().accountsPartial({ user: sender }).instruction();
|
|
17730
17741
|
}
|
|
17731
|
-
async function resolveEncryptKey() {
|
|
17732
|
-
const config = getConfig();
|
|
17742
|
+
async function resolveEncryptKey(config) {
|
|
17733
17743
|
if (!config.encryptKey) {
|
|
17734
17744
|
config.encryptKey = await getEncryptionKey(config.wallet);
|
|
17735
17745
|
}
|
|
17736
17746
|
return config.encryptKey;
|
|
17737
17747
|
}
|
|
17738
|
-
async function buildBackupNotesInstruction(sender, notes) {
|
|
17739
|
-
const { program } =
|
|
17740
|
-
const key2 = await resolveEncryptKey();
|
|
17748
|
+
async function buildBackupNotesInstruction(sender, notes, config = getConfig()) {
|
|
17749
|
+
const { program } = config;
|
|
17750
|
+
const key2 = await resolveEncryptKey(config);
|
|
17741
17751
|
return program.methods.backupNotes(notes.map((note) => encryptData(key2, note))).accountsPartial({ user: sender }).instruction();
|
|
17742
17752
|
}
|
|
17743
17753
|
async function isExtendBackupPdaNeeded(walletPubkey, newNotesLength) {
|
|
@@ -17750,7 +17760,8 @@ function buildRequestHeapIx() {
|
|
|
17750
17760
|
return web3_js.ComputeBudgetProgram.requestHeapFrame({ bytes: 32 * 1024 });
|
|
17751
17761
|
}
|
|
17752
17762
|
async function buildBackupNotesTx(senderPublicKey, notes) {
|
|
17753
|
-
const
|
|
17763
|
+
const config = getConfig();
|
|
17764
|
+
const { connection } = config;
|
|
17754
17765
|
const sender = toPublicKey(senderPublicKey);
|
|
17755
17766
|
const tx = new web3_js.Transaction();
|
|
17756
17767
|
const initIx = await buildInitNotesInstructionIfNeeded(sender);
|
|
@@ -17759,7 +17770,7 @@ async function buildBackupNotesTx(senderPublicKey, notes) {
|
|
|
17759
17770
|
} else if (await isExtendBackupPdaNeeded(sender, notes.length)) {
|
|
17760
17771
|
tx.add(buildRequestHeapIx());
|
|
17761
17772
|
}
|
|
17762
|
-
tx.add(await buildBackupNotesInstruction(sender, notes));
|
|
17773
|
+
tx.add(await buildBackupNotesInstruction(sender, notes, config));
|
|
17763
17774
|
tx.recentBlockhash = (await connection.getLatestBlockhash()).blockhash;
|
|
17764
17775
|
tx.feePayer = sender;
|
|
17765
17776
|
return tx;
|
|
@@ -18891,6 +18902,8 @@ var SEND_OPTIONS = { skipPreflight: false, maxRetries: 3 };
|
|
|
18891
18902
|
var SUBMIT_MAX_PROOFS = 8;
|
|
18892
18903
|
var NOTE_INDEX_TIMEOUT_MS = 12e4;
|
|
18893
18904
|
var NOTE_INDEX_POLL_MS = 4e3;
|
|
18905
|
+
var SEND_ATTEMPTS = 4;
|
|
18906
|
+
var SEND_RETRY_MS = 2e3;
|
|
18894
18907
|
function sleep(ms) {
|
|
18895
18908
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
18896
18909
|
}
|
|
@@ -18912,7 +18925,18 @@ async function signTransactions(wallet, transactions) {
|
|
|
18912
18925
|
}
|
|
18913
18926
|
async function sendAndConfirm(signed) {
|
|
18914
18927
|
const { connection } = getConfig();
|
|
18915
|
-
const
|
|
18928
|
+
const raw = signed.serialize();
|
|
18929
|
+
let signature;
|
|
18930
|
+
for (let attempt = 1; signature === void 0; attempt++) {
|
|
18931
|
+
try {
|
|
18932
|
+
signature = await connection.sendRawTransaction(raw, SEND_OPTIONS);
|
|
18933
|
+
} catch (error) {
|
|
18934
|
+
if (attempt >= SEND_ATTEMPTS || !/blockhash not found/i.test(errorMessage(error))) {
|
|
18935
|
+
throw error;
|
|
18936
|
+
}
|
|
18937
|
+
await sleep(SEND_RETRY_MS);
|
|
18938
|
+
}
|
|
18939
|
+
}
|
|
18916
18940
|
const { value } = await connection.confirmTransaction(signature, "confirmed");
|
|
18917
18941
|
if (value.err) {
|
|
18918
18942
|
throw new Error(`Deposit transaction failed: ${JSON.stringify(value.err)}`);
|
|
@@ -18958,6 +18982,7 @@ async function executeVeilixTransfer(items, options = {}) {
|
|
|
18958
18982
|
const { wallet, network, relayers, encryptKey } = getConfig();
|
|
18959
18983
|
const sender = wallet.publicKey;
|
|
18960
18984
|
const onChainBackup = options.onChainBackup ?? !!encryptKey;
|
|
18985
|
+
const sealKey = onChainBackup ? encryptKey ?? requireEncryptKey() : void 0;
|
|
18961
18986
|
const prepared = prepareDeposits(items);
|
|
18962
18987
|
result.notes = prepared.map((deposit) => deposit.note);
|
|
18963
18988
|
const circuitArtifacts = await prepareWithdrawCircuitArtifacts();
|
|
@@ -18968,7 +18993,8 @@ async function executeVeilixTransfer(items, options = {}) {
|
|
|
18968
18993
|
senderPublicKey: sender,
|
|
18969
18994
|
note: deposit.note,
|
|
18970
18995
|
onChainBackup,
|
|
18971
|
-
circuitArtifacts
|
|
18996
|
+
circuitArtifacts,
|
|
18997
|
+
...sealKey ? { encryptKey: sealKey } : {}
|
|
18972
18998
|
});
|
|
18973
18999
|
} catch (error) {
|
|
18974
19000
|
result.depositFailed.push(toDepositFailure(deposit, error));
|
|
@@ -18979,6 +19005,10 @@ async function executeVeilixTransfer(items, options = {}) {
|
|
|
18979
19005
|
result.error = true;
|
|
18980
19006
|
return result;
|
|
18981
19007
|
}
|
|
19008
|
+
const { blockhash } = await getConfig().connection.getLatestBlockhash();
|
|
19009
|
+
toSend.forEach((deposit) => {
|
|
19010
|
+
deposit.tx.message.recentBlockhash = blockhash;
|
|
19011
|
+
});
|
|
18982
19012
|
const signed = await signTransactions(wallet, toSend.map((deposit) => deposit.tx));
|
|
18983
19013
|
if (options.downloadNotes ?? true) {
|
|
18984
19014
|
downloadNotesCsv(toSend.map((deposit) => deposit.note));
|
|
@@ -19082,7 +19112,7 @@ var VeilixSDK = class _VeilixSDK {
|
|
|
19082
19112
|
try {
|
|
19083
19113
|
return fn();
|
|
19084
19114
|
} finally {
|
|
19085
|
-
popRuntimeContext();
|
|
19115
|
+
popRuntimeContext(this.config);
|
|
19086
19116
|
}
|
|
19087
19117
|
}
|
|
19088
19118
|
async runAsync(fn) {
|
|
@@ -19090,7 +19120,7 @@ var VeilixSDK = class _VeilixSDK {
|
|
|
19090
19120
|
try {
|
|
19091
19121
|
return await fn();
|
|
19092
19122
|
} finally {
|
|
19093
|
-
popRuntimeContext();
|
|
19123
|
+
popRuntimeContext(this.config);
|
|
19094
19124
|
}
|
|
19095
19125
|
}
|
|
19096
19126
|
// ── Config ───────────────────────────────────────────────────────────
|