arc-sdk-test 0.0.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.
@@ -0,0 +1,341 @@
1
+ import { PublicKey, Keypair, Connection, TransactionInstruction, Transaction } from '@solana/web3.js';
2
+ import { OracleJob } from '@switchboard-xyz/common';
3
+ import { Program } from '@coral-xyz/anchor';
4
+ import { Wallet } from '@coral-xyz/anchor/dist/cjs/provider';
5
+ export { Wallet } from '@coral-xyz/anchor/dist/cjs/provider';
6
+
7
+ type IndexerAsset = string | {
8
+ mint?: string;
9
+ asset?: string;
10
+ } | null;
11
+
12
+ /** Frontend wallet adapter or backend {@link Keypair}. */
13
+ type EncryptKeyWallet = Keypair | {
14
+ signMessage: (message: Uint8Array) => Promise<Uint8Array> | Uint8Array;
15
+ };
16
+ type BuildDepositTxParams = {
17
+ senderPublicKey: PublicKey | string;
18
+ /** Supported token mint address for the active cluster (native SOL or SPL mint). */
19
+ tokenMint: PublicKey | string;
20
+ depositAmount: number | string;
21
+ onChainBackup?: boolean;
22
+ computeUnitPrice?: number;
23
+ };
24
+ type FetchWalletBalanceOptions = {
25
+ includeDeposits?: boolean;
26
+ indexerAsset?: IndexerAsset;
27
+ };
28
+ type BuildRelayPayloadParams = {
29
+ args: unknown[];
30
+ proofHex: string;
31
+ denomination: number | bigint | string;
32
+ withdrawAddress: unknown;
33
+ relayerPubkey: unknown;
34
+ mint?: unknown;
35
+ };
36
+ type RelayPayload = Record<string, unknown>;
37
+
38
+ type DepositParams = {
39
+ nullifier: string;
40
+ secret: string;
41
+ amount: string;
42
+ commitment: string;
43
+ nullifierHash: string;
44
+ mint: string | null;
45
+ };
46
+ type GenerateDepositParamsResult = {
47
+ params: DepositParams;
48
+ note: string;
49
+ };
50
+ type GenerateWithdrawProofOptions = {
51
+ /** Override WASM path/URL (required when the SDK is bundled for the browser). */
52
+ circuitWasmPath?: string;
53
+ /** Override zkey path/URL (required when the SDK is bundled for the browser). */
54
+ circuitZkeyPath?: string;
55
+ };
56
+
57
+ type Network = "mainnet" | "devnet";
58
+ declare const MAINNET_TOKEN_MINTS: {
59
+ readonly Arcane: "3jSL5nnnYcRLmTqFmwvY1Mikh42fQsT7p7NvXPYzanon";
60
+ readonly Bitcoin: "3NZ9JMVBmGAqocybic2c7LQCJScmgsAZ6vQqTDzcqmJh";
61
+ readonly Ethereum: "7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs";
62
+ readonly USDC: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";
63
+ };
64
+ type TokenSymbol = keyof typeof MAINNET_TOKEN_MINTS;
65
+ declare const TOKEN_DECIMALS: {
66
+ readonly Solana: 9;
67
+ readonly Arcane: 9;
68
+ readonly Ethereum: 8;
69
+ readonly Bitcoin: 8;
70
+ readonly USDC: 6;
71
+ };
72
+ type TokenDecimalsSymbol = keyof typeof TOKEN_DECIMALS;
73
+ /** Supported deposit denominations per token (same on mainnet and devnet). */
74
+ declare const DEPOSIT_AMOUNTS: {
75
+ readonly Solana: readonly [0.1, 1, 5, 10, 50, 100, 500];
76
+ readonly Arcane: readonly [1, 10, 50, 100, 500, 1000, 10000, 100000, 1000000];
77
+ readonly Bitcoin: readonly [0.01, 0.05, 0.1, 0.5, 1, 5];
78
+ readonly Ethereum: readonly [0.1, 1, 10, 50, 100, 500];
79
+ readonly USDC: readonly [1, 10, 50, 100, 1000, 10000, 100000, 1000000];
80
+ };
81
+ type DepositTokenSymbol = keyof typeof DEPOSIT_AMOUNTS;
82
+
83
+ type Relayer = {
84
+ isValid: true;
85
+ label: string;
86
+ url: string;
87
+ key: number;
88
+ value: string;
89
+ fee: unknown;
90
+ recentActivities: unknown;
91
+ userPubkey: unknown;
92
+ workers: unknown;
93
+ totalFeeEarningsSol: unknown;
94
+ totalWithdrawCount: unknown;
95
+ stakedAmount: unknown;
96
+ volume24hSol: unknown;
97
+ volume7dSol: unknown;
98
+ };
99
+
100
+ interface ArcaneSdkInitOptions {
101
+ /** Range API key (frontend: VITE_RANGE_API_KEY). */
102
+ rangeApiKey: string;
103
+ /** Solana JSON-RPC endpoint (frontend/backend: RPC_ENDPOINT). */
104
+ rpcEndpoint: string;
105
+ /** Wallet for Anchor provider transactions. */
106
+ wallet: Wallet;
107
+ }
108
+ interface ArcaneSdkRuntimeConfig {
109
+ rangeApiKey: string;
110
+ rpcEndpoint: string;
111
+ /** Cluster inferred from {@link rpcEndpoint}. */
112
+ network: Network;
113
+ programId: string;
114
+ /** Active relayers for {@link network}, loaded at SDK initialization. */
115
+ relayers: Relayer[];
116
+ connection: Connection;
117
+ wallet: Wallet;
118
+ program: Program;
119
+ /** Set by {@link ArcaneSDK.getEncryptionKey}; required for on-chain note backup. */
120
+ encryptKey?: Uint8Array;
121
+ }
122
+
123
+ /** Withdraw circuit artifact filenames (published under `arc-sdk-test/circuits/`). */
124
+ declare const WITHDRAW_CIRCUIT_WASM = "withdraw.wasm";
125
+ declare const WITHDRAW_CIRCUIT_ZKEY = "withdraw.zkey";
126
+ type CircuitPaths = {
127
+ wasm: string;
128
+ zkey: string;
129
+ };
130
+
131
+ type WithdrawParams = {
132
+ /** Secret note from the original deposit. */
133
+ note: string;
134
+ /** Withdrawal recipient public key. */
135
+ recipient: PublicKey | string;
136
+ };
137
+ type WithdrawResult = {
138
+ txHash: string;
139
+ jobId: string;
140
+ relayer: Relayer;
141
+ };
142
+
143
+ type QuoteRelayer = {
144
+ url: string;
145
+ [key: string]: unknown;
146
+ };
147
+ type QuoteTransaction = Record<string, unknown>;
148
+ type QuoteSplit = {
149
+ denomination: number;
150
+ totalRelayerFee: number;
151
+ relayer: QuoteRelayer;
152
+ transaction: QuoteTransaction;
153
+ };
154
+ type Quote = {
155
+ amount: number;
156
+ transactionCount: number;
157
+ recipientAmount: number;
158
+ totalRelayerFee: number;
159
+ etaSeconds: number;
160
+ splits: QuoteSplit[];
161
+ };
162
+ type GetQuoteResponse = {
163
+ success: boolean;
164
+ quote: Quote;
165
+ };
166
+ type GetQuoteParams = {
167
+ amount: number | string;
168
+ amountLamports: number | string | bigint;
169
+ recipient: PublicKey | string;
170
+ /** Indexer asset label (default `SOL`). */
171
+ asset?: string;
172
+ /** Cluster for the quote (default active SDK network). */
173
+ network?: Network;
174
+ };
175
+ /** Fetch a withdraw quote from the indexer. Requires SDK init or an active instance context. */
176
+ declare function getQuote(params: GetQuoteParams): Promise<GetQuoteResponse>;
177
+
178
+ type ResolvedNoteAsset = {
179
+ key: string;
180
+ tokenName: TokenDecimalsSymbol;
181
+ unit: string;
182
+ multiplier: bigint;
183
+ mint: string | null;
184
+ poolAmounts: readonly number[];
185
+ decimals: number;
186
+ };
187
+
188
+ type ArcaneTransferItem = {
189
+ mint: PublicKey;
190
+ /** Human-readable token amount (e.g. `"1.5"` SOL). */
191
+ amount: string;
192
+ recipient: PublicKey;
193
+ };
194
+ type ArcaneTransferDepositFailure = {
195
+ amount: string;
196
+ mint: string;
197
+ recipient: string;
198
+ };
199
+ type ArcaneTransferWithdrawFailure = {
200
+ note: string;
201
+ recipient: string;
202
+ };
203
+ type ArcaneTransferResult = {
204
+ error: boolean;
205
+ depositFailed: ArcaneTransferDepositFailure[];
206
+ withdrawFailed: ArcaneTransferWithdrawFailure[];
207
+ };
208
+
209
+ declare const MALICIOUS_RECIPIENT_ERROR = "Recipient address flagged as malicious";
210
+
211
+ /**
212
+ * Arcane SDK client. Create one instance per configuration (network, RPC, API keys).
213
+ *
214
+ * @example
215
+ * ```js
216
+ * const { ArcaneSDK } = require('arc-sdk-test');
217
+ * const sdk = await ArcaneSDK.create({
218
+ * rangeApiKey: process.env.RANGE_API_KEY,
219
+ * rpcEndpoint: 'https://api.devnet.solana.com',
220
+ * wallet,
221
+ * });
222
+ * console.log(sdk.config.relayers);
223
+ * ```
224
+ *
225
+ * @example
226
+ * ```ts
227
+ * import { ArcaneSDK } from 'arc-sdk-test';
228
+ * const sdk = await ArcaneSDK.create({ rangeApiKey, rpcEndpoint, wallet });
229
+ * await sdk.getEncryptionKey(wallet);
230
+ * await sdk.buildDepositTx({ senderPublicKey: wallet.publicKey, tokenMint: NATIVE_MINT, depositAmount: 1, onChainBackup: true });
231
+ * ```
232
+ */
233
+ declare class ArcaneSDK {
234
+ static readonly VERSION = "0.0.1";
235
+ readonly config: ArcaneSdkRuntimeConfig;
236
+ private constructor();
237
+ /** Create an SDK instance (loads relayers for the inferred network). */
238
+ static create(options: ArcaneSdkInitOptions): Promise<ArcaneSDK>;
239
+ private run;
240
+ private runAsync;
241
+ getConfig(): ArcaneSdkRuntimeConfig;
242
+ getRangeApiKey(): string;
243
+ getRpcEndpoint(): string;
244
+ getNetwork(): Network;
245
+ getProgramIdString(): string;
246
+ /** Encryption key derived by {@link getEncryptionKey}; undefined until set. */
247
+ get encryptKey(): Uint8Array | undefined;
248
+ /** Relayers loaded at initialization; use {@link fetchRelayers} to refresh. */
249
+ get relayers(): Relayer[];
250
+ getIndexerUrl(): string;
251
+ getRiskApiUrl(): string;
252
+ getTokenMints(): {
253
+ Solana: string;
254
+ Arcane: "3jSL5nnnYcRLmTqFmwvY1Mikh42fQsT7p7NvXPYzanon" | "ARCxcL6oX2pd4bKmUxhdoARaaHdKU6TJrTTthPANPQtQ";
255
+ Bitcoin: "" | "3NZ9JMVBmGAqocybic2c7LQCJScmgsAZ6vQqTDzcqmJh";
256
+ Ethereum: "" | "7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs";
257
+ USDC: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v" | "4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU";
258
+ };
259
+ getArcaneTokenMint(): string;
260
+ getTokenMint(symbol: TokenSymbol): string;
261
+ getDepositAmounts(symbol: DepositTokenSymbol): readonly number[];
262
+ getTokenDecimals(symbol: TokenDecimalsSymbol): number;
263
+ resolveCircuitPaths(base?: string): CircuitPaths;
264
+ getRangeRiskScoreJob(address: string): OracleJob;
265
+ getOracleQuote(payer: Keypair | PublicKey, addressToCheck: string): Promise<{
266
+ queueAccount: PublicKey;
267
+ sigVerifyIx: TransactionInstruction;
268
+ }>;
269
+ getProgramId(): PublicKey;
270
+ getPoolPDA(denominationLamports: number | bigint): [PublicKey, number];
271
+ getTokenPoolPDA(mint: PublicKey | string, denominationSmallestUnits: number | bigint): [PublicKey, number];
272
+ getTreasuryPDA(): [PublicKey, number];
273
+ getCommitmentPDA(commitmentBigInt: bigint | number | string): [PublicKey, number];
274
+ getNullifierPDA(nullifierHashBigInt: bigint | number | string): [PublicKey, number];
275
+ getNetworkStatePDA(): [PublicKey, number];
276
+ buildDepositTx(params: BuildDepositTxParams): Promise<{
277
+ tx: Transaction;
278
+ note: string;
279
+ }>;
280
+ /**
281
+ * Withdraw to `recipient` using a secret `note`.
282
+ * Relayer is chosen at random from {@link config.relayers}.
283
+ */
284
+ withdraw(params: WithdrawParams): Promise<WithdrawResult>;
285
+ /**
286
+ * Private transfer: deposit into the pool (split by supported denominations),
287
+ * then withdraw each successful note to the recipient.
288
+ *
289
+ * Requires {@link getEncryptionKey} before calling (deposits use on-chain backup).
290
+ */
291
+ arcaneTransfer(items: ArcaneTransferItem[]): Promise<ArcaneTransferResult>;
292
+ /** Validate a withdraw recipient against the risk API. */
293
+ assertWithdrawRecipientAllowed(address: string): Promise<void>;
294
+ /** Resolve the token asset encoded in a secret note. */
295
+ resolveNoteAsset(amount: string, mint?: string | null, tokenNameHint?: TokenDecimalsSymbol): ResolvedNoteAsset;
296
+ fetchPlatformFee(): Promise<string>;
297
+ /** Fetch a withdraw quote from the indexer. */
298
+ getQuote(params: GetQuoteParams): Promise<GetQuoteResponse>;
299
+ fetchCommitments(denomination: number | bigint | string, indexerAsset?: IndexerAsset): Promise<unknown>;
300
+ validateNullifier(nullifierHash: string, indexerAsset?: IndexerAsset): Promise<unknown>;
301
+ fetchTxStatus(commitmentHex: string, nullifierHashHex: string, indexerAsset?: IndexerAsset): Promise<unknown>;
302
+ fetchDepositCountByCommitment(commitment: string, denomination: number | bigint | string, indexerAsset?: IndexerAsset): Promise<unknown>;
303
+ fetchWalletBalance(wallet: string, options?: FetchWalletBalanceOptions): Promise<unknown>;
304
+ /** Re-fetch relayers from the indexer and update {@link config.relayers}. */
305
+ fetchRelayers(): Promise<Relayer[]>;
306
+ fetchLatestTransactions(type?: string, indexerAsset?: IndexerAsset): Promise<unknown>;
307
+ fetchTxCounts(type?: string, indexerAsset?: IndexerAsset): Promise<unknown>;
308
+ normalizePubkeyString(value: unknown): string;
309
+ buildRelayPayload(params: BuildRelayPayloadParams): RelayPayload;
310
+ submitToRelayer(relayerUrl: string, payload: RelayPayload): Promise<unknown>;
311
+ pollRelayerJob(relayerUrl: string, jobId: string, maxWaitMs?: number): Promise<unknown>;
312
+ /**
313
+ * Derives the note encryption key from a wallet signature and stores it on
314
+ * {@link config.encryptKey}. Required before {@link buildDepositTx} with
315
+ * `onChainBackup: true`.
316
+ *
317
+ * Accepts a frontend wallet adapter (`signMessage`) or a backend {@link Keypair}.
318
+ */
319
+ getEncryptionKey(wallet: EncryptKeyWallet): Promise<Uint8Array>;
320
+ encryptData(key: Uint8Array, plaintext: string): Uint8Array<ArrayBufferLike>;
321
+ decryptData(key: Uint8Array, combined: Uint8Array): string;
322
+ generateRandomFieldElement(): bigint;
323
+ createCommitment(nullifier: bigint | number | string, secret: bigint | number | string): bigint;
324
+ createNullifierHash(nullifier: bigint | number | string): bigint;
325
+ generateDepositParams(amountLamports: bigint | number | string, mint?: string | null): GenerateDepositParamsResult;
326
+ parseSecretNote(note: string): Record<string, string>;
327
+ publicKeyToFieldElement(publicKeyBytes: Uint8Array | number[]): bigint;
328
+ amountToFieldElement(amount: bigint | number | string): bigint;
329
+ generateMerkleProof(depositParams: Record<string, unknown>, leaves: unknown[]): unknown;
330
+ generateWithdrawProof(depositParams: Record<string, unknown>, leaves: unknown[], recipient: PublicKey | string, relayer: PublicKey | string, fee: bigint | number | string, refund: bigint | number | string, options?: GenerateWithdrawProofOptions): Promise<unknown>;
331
+ convertProofToBytes(proof: unknown): Promise<number[] | Uint8Array<ArrayBufferLike>>;
332
+ to32ByteBuffer(bigInt: bigint | number | string): Uint8Array<ArrayBufferLike>;
333
+ toFixedHex(value: bigint | number | string, length?: number): string;
334
+ toFieldElementHex(value: bigint | number | string): string;
335
+ formatNoteForDisplay(note: string, segmentLen?: number): string;
336
+ appendIndexerAsset(params: URLSearchParams, indexerAsset?: IndexerAsset): void;
337
+ /** Program ID for a cluster without an SDK instance. */
338
+ static getProgramIdForNetwork(network: Network): string;
339
+ }
340
+
341
+ export { ArcaneSDK, type ArcaneSdkInitOptions, type ArcaneSdkRuntimeConfig, type ArcaneTransferDepositFailure, type ArcaneTransferItem, type ArcaneTransferResult, type ArcaneTransferWithdrawFailure, type BuildDepositTxParams, type BuildRelayPayloadParams, type CircuitPaths, type DepositTokenSymbol, type EncryptKeyWallet, type FetchWalletBalanceOptions, type GenerateDepositParamsResult, type GenerateWithdrawProofOptions, type GetQuoteParams, type GetQuoteResponse, type IndexerAsset, MALICIOUS_RECIPIENT_ERROR, type Network, type Quote, type QuoteRelayer, type QuoteSplit, type QuoteTransaction, type RelayPayload, type Relayer, type ResolvedNoteAsset, type TokenDecimalsSymbol, type TokenSymbol, WITHDRAW_CIRCUIT_WASM, WITHDRAW_CIRCUIT_ZKEY, type WithdrawParams, type WithdrawResult, ArcaneSDK as default, getQuote };
@@ -0,0 +1,341 @@
1
+ import { PublicKey, Keypair, Connection, TransactionInstruction, Transaction } from '@solana/web3.js';
2
+ import { OracleJob } from '@switchboard-xyz/common';
3
+ import { Program } from '@coral-xyz/anchor';
4
+ import { Wallet } from '@coral-xyz/anchor/dist/cjs/provider';
5
+ export { Wallet } from '@coral-xyz/anchor/dist/cjs/provider';
6
+
7
+ type IndexerAsset = string | {
8
+ mint?: string;
9
+ asset?: string;
10
+ } | null;
11
+
12
+ /** Frontend wallet adapter or backend {@link Keypair}. */
13
+ type EncryptKeyWallet = Keypair | {
14
+ signMessage: (message: Uint8Array) => Promise<Uint8Array> | Uint8Array;
15
+ };
16
+ type BuildDepositTxParams = {
17
+ senderPublicKey: PublicKey | string;
18
+ /** Supported token mint address for the active cluster (native SOL or SPL mint). */
19
+ tokenMint: PublicKey | string;
20
+ depositAmount: number | string;
21
+ onChainBackup?: boolean;
22
+ computeUnitPrice?: number;
23
+ };
24
+ type FetchWalletBalanceOptions = {
25
+ includeDeposits?: boolean;
26
+ indexerAsset?: IndexerAsset;
27
+ };
28
+ type BuildRelayPayloadParams = {
29
+ args: unknown[];
30
+ proofHex: string;
31
+ denomination: number | bigint | string;
32
+ withdrawAddress: unknown;
33
+ relayerPubkey: unknown;
34
+ mint?: unknown;
35
+ };
36
+ type RelayPayload = Record<string, unknown>;
37
+
38
+ type DepositParams = {
39
+ nullifier: string;
40
+ secret: string;
41
+ amount: string;
42
+ commitment: string;
43
+ nullifierHash: string;
44
+ mint: string | null;
45
+ };
46
+ type GenerateDepositParamsResult = {
47
+ params: DepositParams;
48
+ note: string;
49
+ };
50
+ type GenerateWithdrawProofOptions = {
51
+ /** Override WASM path/URL (required when the SDK is bundled for the browser). */
52
+ circuitWasmPath?: string;
53
+ /** Override zkey path/URL (required when the SDK is bundled for the browser). */
54
+ circuitZkeyPath?: string;
55
+ };
56
+
57
+ type Network = "mainnet" | "devnet";
58
+ declare const MAINNET_TOKEN_MINTS: {
59
+ readonly Arcane: "3jSL5nnnYcRLmTqFmwvY1Mikh42fQsT7p7NvXPYzanon";
60
+ readonly Bitcoin: "3NZ9JMVBmGAqocybic2c7LQCJScmgsAZ6vQqTDzcqmJh";
61
+ readonly Ethereum: "7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs";
62
+ readonly USDC: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";
63
+ };
64
+ type TokenSymbol = keyof typeof MAINNET_TOKEN_MINTS;
65
+ declare const TOKEN_DECIMALS: {
66
+ readonly Solana: 9;
67
+ readonly Arcane: 9;
68
+ readonly Ethereum: 8;
69
+ readonly Bitcoin: 8;
70
+ readonly USDC: 6;
71
+ };
72
+ type TokenDecimalsSymbol = keyof typeof TOKEN_DECIMALS;
73
+ /** Supported deposit denominations per token (same on mainnet and devnet). */
74
+ declare const DEPOSIT_AMOUNTS: {
75
+ readonly Solana: readonly [0.1, 1, 5, 10, 50, 100, 500];
76
+ readonly Arcane: readonly [1, 10, 50, 100, 500, 1000, 10000, 100000, 1000000];
77
+ readonly Bitcoin: readonly [0.01, 0.05, 0.1, 0.5, 1, 5];
78
+ readonly Ethereum: readonly [0.1, 1, 10, 50, 100, 500];
79
+ readonly USDC: readonly [1, 10, 50, 100, 1000, 10000, 100000, 1000000];
80
+ };
81
+ type DepositTokenSymbol = keyof typeof DEPOSIT_AMOUNTS;
82
+
83
+ type Relayer = {
84
+ isValid: true;
85
+ label: string;
86
+ url: string;
87
+ key: number;
88
+ value: string;
89
+ fee: unknown;
90
+ recentActivities: unknown;
91
+ userPubkey: unknown;
92
+ workers: unknown;
93
+ totalFeeEarningsSol: unknown;
94
+ totalWithdrawCount: unknown;
95
+ stakedAmount: unknown;
96
+ volume24hSol: unknown;
97
+ volume7dSol: unknown;
98
+ };
99
+
100
+ interface ArcaneSdkInitOptions {
101
+ /** Range API key (frontend: VITE_RANGE_API_KEY). */
102
+ rangeApiKey: string;
103
+ /** Solana JSON-RPC endpoint (frontend/backend: RPC_ENDPOINT). */
104
+ rpcEndpoint: string;
105
+ /** Wallet for Anchor provider transactions. */
106
+ wallet: Wallet;
107
+ }
108
+ interface ArcaneSdkRuntimeConfig {
109
+ rangeApiKey: string;
110
+ rpcEndpoint: string;
111
+ /** Cluster inferred from {@link rpcEndpoint}. */
112
+ network: Network;
113
+ programId: string;
114
+ /** Active relayers for {@link network}, loaded at SDK initialization. */
115
+ relayers: Relayer[];
116
+ connection: Connection;
117
+ wallet: Wallet;
118
+ program: Program;
119
+ /** Set by {@link ArcaneSDK.getEncryptionKey}; required for on-chain note backup. */
120
+ encryptKey?: Uint8Array;
121
+ }
122
+
123
+ /** Withdraw circuit artifact filenames (published under `arc-sdk-test/circuits/`). */
124
+ declare const WITHDRAW_CIRCUIT_WASM = "withdraw.wasm";
125
+ declare const WITHDRAW_CIRCUIT_ZKEY = "withdraw.zkey";
126
+ type CircuitPaths = {
127
+ wasm: string;
128
+ zkey: string;
129
+ };
130
+
131
+ type WithdrawParams = {
132
+ /** Secret note from the original deposit. */
133
+ note: string;
134
+ /** Withdrawal recipient public key. */
135
+ recipient: PublicKey | string;
136
+ };
137
+ type WithdrawResult = {
138
+ txHash: string;
139
+ jobId: string;
140
+ relayer: Relayer;
141
+ };
142
+
143
+ type QuoteRelayer = {
144
+ url: string;
145
+ [key: string]: unknown;
146
+ };
147
+ type QuoteTransaction = Record<string, unknown>;
148
+ type QuoteSplit = {
149
+ denomination: number;
150
+ totalRelayerFee: number;
151
+ relayer: QuoteRelayer;
152
+ transaction: QuoteTransaction;
153
+ };
154
+ type Quote = {
155
+ amount: number;
156
+ transactionCount: number;
157
+ recipientAmount: number;
158
+ totalRelayerFee: number;
159
+ etaSeconds: number;
160
+ splits: QuoteSplit[];
161
+ };
162
+ type GetQuoteResponse = {
163
+ success: boolean;
164
+ quote: Quote;
165
+ };
166
+ type GetQuoteParams = {
167
+ amount: number | string;
168
+ amountLamports: number | string | bigint;
169
+ recipient: PublicKey | string;
170
+ /** Indexer asset label (default `SOL`). */
171
+ asset?: string;
172
+ /** Cluster for the quote (default active SDK network). */
173
+ network?: Network;
174
+ };
175
+ /** Fetch a withdraw quote from the indexer. Requires SDK init or an active instance context. */
176
+ declare function getQuote(params: GetQuoteParams): Promise<GetQuoteResponse>;
177
+
178
+ type ResolvedNoteAsset = {
179
+ key: string;
180
+ tokenName: TokenDecimalsSymbol;
181
+ unit: string;
182
+ multiplier: bigint;
183
+ mint: string | null;
184
+ poolAmounts: readonly number[];
185
+ decimals: number;
186
+ };
187
+
188
+ type ArcaneTransferItem = {
189
+ mint: PublicKey;
190
+ /** Human-readable token amount (e.g. `"1.5"` SOL). */
191
+ amount: string;
192
+ recipient: PublicKey;
193
+ };
194
+ type ArcaneTransferDepositFailure = {
195
+ amount: string;
196
+ mint: string;
197
+ recipient: string;
198
+ };
199
+ type ArcaneTransferWithdrawFailure = {
200
+ note: string;
201
+ recipient: string;
202
+ };
203
+ type ArcaneTransferResult = {
204
+ error: boolean;
205
+ depositFailed: ArcaneTransferDepositFailure[];
206
+ withdrawFailed: ArcaneTransferWithdrawFailure[];
207
+ };
208
+
209
+ declare const MALICIOUS_RECIPIENT_ERROR = "Recipient address flagged as malicious";
210
+
211
+ /**
212
+ * Arcane SDK client. Create one instance per configuration (network, RPC, API keys).
213
+ *
214
+ * @example
215
+ * ```js
216
+ * const { ArcaneSDK } = require('arc-sdk-test');
217
+ * const sdk = await ArcaneSDK.create({
218
+ * rangeApiKey: process.env.RANGE_API_KEY,
219
+ * rpcEndpoint: 'https://api.devnet.solana.com',
220
+ * wallet,
221
+ * });
222
+ * console.log(sdk.config.relayers);
223
+ * ```
224
+ *
225
+ * @example
226
+ * ```ts
227
+ * import { ArcaneSDK } from 'arc-sdk-test';
228
+ * const sdk = await ArcaneSDK.create({ rangeApiKey, rpcEndpoint, wallet });
229
+ * await sdk.getEncryptionKey(wallet);
230
+ * await sdk.buildDepositTx({ senderPublicKey: wallet.publicKey, tokenMint: NATIVE_MINT, depositAmount: 1, onChainBackup: true });
231
+ * ```
232
+ */
233
+ declare class ArcaneSDK {
234
+ static readonly VERSION = "0.0.1";
235
+ readonly config: ArcaneSdkRuntimeConfig;
236
+ private constructor();
237
+ /** Create an SDK instance (loads relayers for the inferred network). */
238
+ static create(options: ArcaneSdkInitOptions): Promise<ArcaneSDK>;
239
+ private run;
240
+ private runAsync;
241
+ getConfig(): ArcaneSdkRuntimeConfig;
242
+ getRangeApiKey(): string;
243
+ getRpcEndpoint(): string;
244
+ getNetwork(): Network;
245
+ getProgramIdString(): string;
246
+ /** Encryption key derived by {@link getEncryptionKey}; undefined until set. */
247
+ get encryptKey(): Uint8Array | undefined;
248
+ /** Relayers loaded at initialization; use {@link fetchRelayers} to refresh. */
249
+ get relayers(): Relayer[];
250
+ getIndexerUrl(): string;
251
+ getRiskApiUrl(): string;
252
+ getTokenMints(): {
253
+ Solana: string;
254
+ Arcane: "3jSL5nnnYcRLmTqFmwvY1Mikh42fQsT7p7NvXPYzanon" | "ARCxcL6oX2pd4bKmUxhdoARaaHdKU6TJrTTthPANPQtQ";
255
+ Bitcoin: "" | "3NZ9JMVBmGAqocybic2c7LQCJScmgsAZ6vQqTDzcqmJh";
256
+ Ethereum: "" | "7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs";
257
+ USDC: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v" | "4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU";
258
+ };
259
+ getArcaneTokenMint(): string;
260
+ getTokenMint(symbol: TokenSymbol): string;
261
+ getDepositAmounts(symbol: DepositTokenSymbol): readonly number[];
262
+ getTokenDecimals(symbol: TokenDecimalsSymbol): number;
263
+ resolveCircuitPaths(base?: string): CircuitPaths;
264
+ getRangeRiskScoreJob(address: string): OracleJob;
265
+ getOracleQuote(payer: Keypair | PublicKey, addressToCheck: string): Promise<{
266
+ queueAccount: PublicKey;
267
+ sigVerifyIx: TransactionInstruction;
268
+ }>;
269
+ getProgramId(): PublicKey;
270
+ getPoolPDA(denominationLamports: number | bigint): [PublicKey, number];
271
+ getTokenPoolPDA(mint: PublicKey | string, denominationSmallestUnits: number | bigint): [PublicKey, number];
272
+ getTreasuryPDA(): [PublicKey, number];
273
+ getCommitmentPDA(commitmentBigInt: bigint | number | string): [PublicKey, number];
274
+ getNullifierPDA(nullifierHashBigInt: bigint | number | string): [PublicKey, number];
275
+ getNetworkStatePDA(): [PublicKey, number];
276
+ buildDepositTx(params: BuildDepositTxParams): Promise<{
277
+ tx: Transaction;
278
+ note: string;
279
+ }>;
280
+ /**
281
+ * Withdraw to `recipient` using a secret `note`.
282
+ * Relayer is chosen at random from {@link config.relayers}.
283
+ */
284
+ withdraw(params: WithdrawParams): Promise<WithdrawResult>;
285
+ /**
286
+ * Private transfer: deposit into the pool (split by supported denominations),
287
+ * then withdraw each successful note to the recipient.
288
+ *
289
+ * Requires {@link getEncryptionKey} before calling (deposits use on-chain backup).
290
+ */
291
+ arcaneTransfer(items: ArcaneTransferItem[]): Promise<ArcaneTransferResult>;
292
+ /** Validate a withdraw recipient against the risk API. */
293
+ assertWithdrawRecipientAllowed(address: string): Promise<void>;
294
+ /** Resolve the token asset encoded in a secret note. */
295
+ resolveNoteAsset(amount: string, mint?: string | null, tokenNameHint?: TokenDecimalsSymbol): ResolvedNoteAsset;
296
+ fetchPlatformFee(): Promise<string>;
297
+ /** Fetch a withdraw quote from the indexer. */
298
+ getQuote(params: GetQuoteParams): Promise<GetQuoteResponse>;
299
+ fetchCommitments(denomination: number | bigint | string, indexerAsset?: IndexerAsset): Promise<unknown>;
300
+ validateNullifier(nullifierHash: string, indexerAsset?: IndexerAsset): Promise<unknown>;
301
+ fetchTxStatus(commitmentHex: string, nullifierHashHex: string, indexerAsset?: IndexerAsset): Promise<unknown>;
302
+ fetchDepositCountByCommitment(commitment: string, denomination: number | bigint | string, indexerAsset?: IndexerAsset): Promise<unknown>;
303
+ fetchWalletBalance(wallet: string, options?: FetchWalletBalanceOptions): Promise<unknown>;
304
+ /** Re-fetch relayers from the indexer and update {@link config.relayers}. */
305
+ fetchRelayers(): Promise<Relayer[]>;
306
+ fetchLatestTransactions(type?: string, indexerAsset?: IndexerAsset): Promise<unknown>;
307
+ fetchTxCounts(type?: string, indexerAsset?: IndexerAsset): Promise<unknown>;
308
+ normalizePubkeyString(value: unknown): string;
309
+ buildRelayPayload(params: BuildRelayPayloadParams): RelayPayload;
310
+ submitToRelayer(relayerUrl: string, payload: RelayPayload): Promise<unknown>;
311
+ pollRelayerJob(relayerUrl: string, jobId: string, maxWaitMs?: number): Promise<unknown>;
312
+ /**
313
+ * Derives the note encryption key from a wallet signature and stores it on
314
+ * {@link config.encryptKey}. Required before {@link buildDepositTx} with
315
+ * `onChainBackup: true`.
316
+ *
317
+ * Accepts a frontend wallet adapter (`signMessage`) or a backend {@link Keypair}.
318
+ */
319
+ getEncryptionKey(wallet: EncryptKeyWallet): Promise<Uint8Array>;
320
+ encryptData(key: Uint8Array, plaintext: string): Uint8Array<ArrayBufferLike>;
321
+ decryptData(key: Uint8Array, combined: Uint8Array): string;
322
+ generateRandomFieldElement(): bigint;
323
+ createCommitment(nullifier: bigint | number | string, secret: bigint | number | string): bigint;
324
+ createNullifierHash(nullifier: bigint | number | string): bigint;
325
+ generateDepositParams(amountLamports: bigint | number | string, mint?: string | null): GenerateDepositParamsResult;
326
+ parseSecretNote(note: string): Record<string, string>;
327
+ publicKeyToFieldElement(publicKeyBytes: Uint8Array | number[]): bigint;
328
+ amountToFieldElement(amount: bigint | number | string): bigint;
329
+ generateMerkleProof(depositParams: Record<string, unknown>, leaves: unknown[]): unknown;
330
+ generateWithdrawProof(depositParams: Record<string, unknown>, leaves: unknown[], recipient: PublicKey | string, relayer: PublicKey | string, fee: bigint | number | string, refund: bigint | number | string, options?: GenerateWithdrawProofOptions): Promise<unknown>;
331
+ convertProofToBytes(proof: unknown): Promise<number[] | Uint8Array<ArrayBufferLike>>;
332
+ to32ByteBuffer(bigInt: bigint | number | string): Uint8Array<ArrayBufferLike>;
333
+ toFixedHex(value: bigint | number | string, length?: number): string;
334
+ toFieldElementHex(value: bigint | number | string): string;
335
+ formatNoteForDisplay(note: string, segmentLen?: number): string;
336
+ appendIndexerAsset(params: URLSearchParams, indexerAsset?: IndexerAsset): void;
337
+ /** Program ID for a cluster without an SDK instance. */
338
+ static getProgramIdForNetwork(network: Network): string;
339
+ }
340
+
341
+ export { ArcaneSDK, type ArcaneSdkInitOptions, type ArcaneSdkRuntimeConfig, type ArcaneTransferDepositFailure, type ArcaneTransferItem, type ArcaneTransferResult, type ArcaneTransferWithdrawFailure, type BuildDepositTxParams, type BuildRelayPayloadParams, type CircuitPaths, type DepositTokenSymbol, type EncryptKeyWallet, type FetchWalletBalanceOptions, type GenerateDepositParamsResult, type GenerateWithdrawProofOptions, type GetQuoteParams, type GetQuoteResponse, type IndexerAsset, MALICIOUS_RECIPIENT_ERROR, type Network, type Quote, type QuoteRelayer, type QuoteSplit, type QuoteTransaction, type RelayPayload, type Relayer, type ResolvedNoteAsset, type TokenDecimalsSymbol, type TokenSymbol, WITHDRAW_CIRCUIT_WASM, WITHDRAW_CIRCUIT_ZKEY, type WithdrawParams, type WithdrawResult, ArcaneSDK as default, getQuote };