@sip-protocol/sdk 0.1.0

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,3640 @@
1
+ import * as _sip_protocol_types from '@sip-protocol/types';
2
+ import { ZKProof, HexString, Commitment, PrivacyLevel, ShieldedIntent, CreateIntentParams, TrackedIntent, ChainId, StealthMetaAddress, Quote, FulfillmentResult, ViewingKey, StealthAddress, StealthAddressRecovery, EncryptedTransaction, Hash, Asset, IntentInput, IntentOutput, OneClickConfig, OneClickToken, OneClickQuoteRequest, OneClickQuoteResponse, OneClickDepositSubmit, OneClickStatusResponse, OneClickWithdrawal, DefuseAssetId, OneClickSwapStatus, ChainType, SIPSolver, Solver, SolverCapabilities, SolverVisibleIntent, SolverQuote, FulfillmentStatus, ZcashConfig, ZcashAddressInfo, ZcashNewAccount, ZcashReceiverType, ZcashAccountAddress, ZcashAccountBalance, ZcashUnspentNote, ZcashShieldedSendParams, ZcashOperation, ZcashBlockHeader, ZcashBlock, ZcashBlockchainInfo, ZcashNetworkInfo, WalletAdapter as WalletAdapter$1, WalletConnectionState, WalletEventType, WalletEventHandler, WalletEvent, Signature, UnsignedTransaction, SignedTransaction, TransactionReceipt, WalletErrorCodeType, WalletRegistryEntry, WalletInfo, PrivateWalletAdapter, WalletAdapterFactory } from '@sip-protocol/types';
3
+ export { Asset, ChainId, Commitment, CreateIntentParams, DefuseAssetId, FulfillmentCommitment, FulfillmentProof, FulfillmentRequest, FulfillmentResult, FulfillmentStatus, Hash, HexString, WalletAdapter as IWalletAdapter, IntentStatus, NATIVE_TOKENS, OneClickConfig, OneClickDepositMode, OneClickErrorCode, OneClickQuoteRequest, OneClickQuoteResponse, OneClickStatusResponse, OneClickSwapStatus, OneClickSwapType, PrivacyLevel, PrivateWalletAdapter, Quote, SIPSolver, SIP_VERSION, ShieldedIntent, Signature, SignedTransaction, Solver, SolverCapabilities, SolverEvent, SolverEventListener, SolverQuote, SolverVisibleIntent, StealthAddress, StealthAddressRecovery, StealthMetaAddress, SwapRoute, SwapRouteStep, TrackedIntent, TransactionReceipt, UnsignedTransaction, ViewingKey, WalletAccountChangedEvent, WalletAdapterFactory, WalletChainChangedEvent, WalletConnectEvent, WalletConnectionState, WalletDisconnectEvent, WalletErrorCode, WalletErrorEvent, WalletEvent, WalletEventHandler, WalletEventType, WalletInfo, WalletRegistryEntry, WalletShieldedSendParams, WalletShieldedSendResult, ZKProof, ZcashAccountAddress, ZcashAccountBalance, ZcashAddressInfo, ZcashAddressType, ZcashBlock, ZcashBlockHeader, ZcashBlockchainInfo, ZcashConfig, ZcashErrorCode, ZcashNetwork, ZcashNetworkInfo, ZcashNewAccount, ZcashOperation, ZcashOperationError, ZcashOperationStatus, ZcashOperationTxResult, ZcashPool, ZcashPoolBalance, ZcashPrivacyPolicy, ZcashReceiverType, ZcashSendRecipient, ZcashShieldedSendParams, ZcashUnspentNote, isPrivate, supportsViewingKey } from '@sip-protocol/types';
4
+
5
+ /**
6
+ * Custom errors for SIP Protocol SDK
7
+ *
8
+ * Provides a comprehensive error hierarchy with:
9
+ * - Machine-readable error codes
10
+ * - Human-readable messages
11
+ * - Original cause preservation
12
+ * - Additional debugging context
13
+ * - Serialization for logging
14
+ */
15
+ /**
16
+ * Machine-readable error codes for programmatic error handling
17
+ */
18
+ declare enum ErrorCode {
19
+ UNKNOWN = "SIP_1000",
20
+ INTERNAL = "SIP_1001",
21
+ NOT_IMPLEMENTED = "SIP_1002",
22
+ VALIDATION_FAILED = "SIP_2000",
23
+ INVALID_INPUT = "SIP_2001",
24
+ INVALID_CHAIN = "SIP_2002",
25
+ INVALID_PRIVACY_LEVEL = "SIP_2003",
26
+ INVALID_AMOUNT = "SIP_2004",
27
+ INVALID_HEX = "SIP_2005",
28
+ INVALID_KEY = "SIP_2006",
29
+ INVALID_ADDRESS = "SIP_2007",
30
+ MISSING_REQUIRED = "SIP_2008",
31
+ OUT_OF_RANGE = "SIP_2009",
32
+ CRYPTO_FAILED = "SIP_3000",
33
+ ENCRYPTION_FAILED = "SIP_3001",
34
+ DECRYPTION_FAILED = "SIP_3002",
35
+ KEY_DERIVATION_FAILED = "SIP_3003",
36
+ COMMITMENT_FAILED = "SIP_3004",
37
+ SIGNATURE_FAILED = "SIP_3005",
38
+ INVALID_CURVE_POINT = "SIP_3006",
39
+ INVALID_SCALAR = "SIP_3007",
40
+ PROOF_FAILED = "SIP_4000",
41
+ PROOF_GENERATION_FAILED = "SIP_4001",
42
+ PROOF_VERIFICATION_FAILED = "SIP_4002",
43
+ PROOF_NOT_IMPLEMENTED = "SIP_4003",
44
+ PROOF_PROVIDER_NOT_READY = "SIP_4004",
45
+ INVALID_PROOF_PARAMS = "SIP_4005",
46
+ INTENT_FAILED = "SIP_5000",
47
+ INTENT_EXPIRED = "SIP_5001",
48
+ INTENT_CANCELLED = "SIP_5002",
49
+ INTENT_NOT_FOUND = "SIP_5003",
50
+ INTENT_INVALID_STATE = "SIP_5004",
51
+ PROOFS_REQUIRED = "SIP_5005",
52
+ QUOTE_EXPIRED = "SIP_5006",
53
+ NETWORK_FAILED = "SIP_6000",
54
+ NETWORK_TIMEOUT = "SIP_6001",
55
+ NETWORK_UNAVAILABLE = "SIP_6002",
56
+ RPC_ERROR = "SIP_6003",
57
+ API_ERROR = "SIP_6004",
58
+ RATE_LIMITED = "SIP_6005",
59
+ WALLET_ERROR = "SIP_7000",
60
+ WALLET_NOT_CONNECTED = "SIP_7001",
61
+ WALLET_CONNECTION_FAILED = "SIP_7002",
62
+ WALLET_SIGNING_FAILED = "SIP_7003",
63
+ WALLET_TRANSACTION_FAILED = "SIP_7004"
64
+ }
65
+ /**
66
+ * Serialized error format for logging and transmission
67
+ */
68
+ interface SerializedError {
69
+ name: string;
70
+ code: ErrorCode;
71
+ message: string;
72
+ field?: string;
73
+ context?: Record<string, unknown>;
74
+ cause?: string;
75
+ stack?: string;
76
+ timestamp: string;
77
+ }
78
+ /**
79
+ * Base error class for SIP Protocol
80
+ *
81
+ * All SDK errors extend this class and include:
82
+ * - `code`: Machine-readable error code for programmatic handling
83
+ * - `cause`: Original error if this error wraps another
84
+ * - `context`: Additional debugging information
85
+ *
86
+ * @example
87
+ * ```typescript
88
+ * try {
89
+ * await sip.execute(intent, quote)
90
+ * } catch (e) {
91
+ * if (e instanceof SIPError) {
92
+ * console.log(`Error ${e.code}: ${e.message}`)
93
+ * if (e.cause) console.log('Caused by:', e.cause)
94
+ * }
95
+ * }
96
+ * ```
97
+ */
98
+ declare class SIPError extends Error {
99
+ /** Machine-readable error code */
100
+ readonly code: ErrorCode;
101
+ /** Additional debugging context */
102
+ readonly context?: Record<string, unknown>;
103
+ /** Timestamp when error was created */
104
+ readonly timestamp: Date;
105
+ constructor(message: string, code?: ErrorCode, options?: {
106
+ cause?: Error;
107
+ context?: Record<string, unknown>;
108
+ });
109
+ /**
110
+ * Serialize error for logging or transmission
111
+ */
112
+ toJSON(): SerializedError;
113
+ /**
114
+ * Create a string representation for logging
115
+ */
116
+ toString(): string;
117
+ }
118
+ /**
119
+ * Error thrown when input validation fails
120
+ *
121
+ * Provides detailed information about what validation failed
122
+ * and optionally which field caused the error.
123
+ *
124
+ * @example
125
+ * ```typescript
126
+ * throw new ValidationError('Amount must be positive', 'input.amount')
127
+ *
128
+ * // With error code
129
+ * throw new ValidationError('Invalid chain ID', 'chain', {
130
+ * code: ErrorCode.INVALID_CHAIN,
131
+ * context: { received: 'invalid-chain' }
132
+ * })
133
+ * ```
134
+ */
135
+ declare class ValidationError extends SIPError {
136
+ /** The field that failed validation (if applicable) */
137
+ readonly field?: string;
138
+ constructor(message: string, field?: string, context?: Record<string, unknown>, code?: ErrorCode);
139
+ toJSON(): SerializedError;
140
+ }
141
+ /**
142
+ * Error thrown when cryptographic operations fail
143
+ *
144
+ * Covers encryption, decryption, key derivation, commitments, and signatures.
145
+ *
146
+ * @example
147
+ * ```typescript
148
+ * throw new CryptoError('Decryption failed', ErrorCode.DECRYPTION_FAILED, {
149
+ * cause: originalError,
150
+ * context: { operation: 'decryptWithViewing' }
151
+ * })
152
+ * ```
153
+ */
154
+ declare class CryptoError extends SIPError {
155
+ /** The cryptographic operation that failed */
156
+ readonly operation?: string;
157
+ constructor(message: string, code?: ErrorCode, options?: {
158
+ cause?: Error;
159
+ context?: Record<string, unknown>;
160
+ operation?: string;
161
+ });
162
+ }
163
+ /**
164
+ * Error thrown when encryption functions are called but not yet implemented
165
+ *
166
+ * @deprecated Use CryptoError with ErrorCode.NOT_IMPLEMENTED instead
167
+ */
168
+ declare class EncryptionNotImplementedError extends CryptoError {
169
+ /** The type of encryption operation */
170
+ readonly operationType: 'encrypt' | 'decrypt';
171
+ /** Reference to the specification document */
172
+ readonly specReference: string;
173
+ constructor(operation: 'encrypt' | 'decrypt', specReference: string);
174
+ }
175
+ /**
176
+ * Error thrown when proof operations fail
177
+ *
178
+ * Covers proof generation, verification, and related operations.
179
+ *
180
+ * @example
181
+ * ```typescript
182
+ * throw new ProofError('Proof verification failed', ErrorCode.PROOF_VERIFICATION_FAILED, {
183
+ * context: { proofType: 'funding', publicInputs: [...] }
184
+ * })
185
+ * ```
186
+ */
187
+ declare class ProofError extends SIPError {
188
+ /** The type of proof involved */
189
+ readonly proofType?: 'funding' | 'validity' | 'fulfillment' | 'viewing';
190
+ constructor(message: string, code?: ErrorCode, options?: {
191
+ cause?: Error;
192
+ context?: Record<string, unknown>;
193
+ proofType?: 'funding' | 'validity' | 'fulfillment' | 'viewing';
194
+ });
195
+ }
196
+ /**
197
+ * Error thrown when a proof function is called but not yet implemented
198
+ *
199
+ * This error indicates that real ZK proof generation is required but not available.
200
+ *
201
+ * @example
202
+ * ```typescript
203
+ * // Use ProofProvider for proof generation
204
+ * const provider = new NoirProofProvider(config)
205
+ * await provider.initialize()
206
+ * const result = await provider.generateFundingProof(params)
207
+ * ```
208
+ */
209
+ declare class ProofNotImplementedError extends ProofError {
210
+ /** Reference to the specification document */
211
+ readonly specReference: string;
212
+ constructor(proofType: 'funding' | 'validity' | 'fulfillment' | 'viewing', specReference: string);
213
+ }
214
+ /**
215
+ * Error thrown when intent operations fail
216
+ *
217
+ * Covers intent creation, execution, and lifecycle errors.
218
+ *
219
+ * @example
220
+ * ```typescript
221
+ * throw new IntentError('Intent has expired', ErrorCode.INTENT_EXPIRED, {
222
+ * context: { intentId, expiry, now: Date.now() }
223
+ * })
224
+ * ```
225
+ */
226
+ declare class IntentError extends SIPError {
227
+ /** The intent ID involved (if available) */
228
+ readonly intentId?: string;
229
+ constructor(message: string, code?: ErrorCode, options?: {
230
+ cause?: Error;
231
+ context?: Record<string, unknown>;
232
+ intentId?: string;
233
+ });
234
+ }
235
+ /**
236
+ * Error thrown when external service communication fails
237
+ *
238
+ * Covers RPC calls, API requests, and network connectivity issues.
239
+ *
240
+ * @example
241
+ * ```typescript
242
+ * throw new NetworkError('RPC request failed', ErrorCode.RPC_ERROR, {
243
+ * cause: originalError,
244
+ * context: { endpoint: 'https://...', method: 'eth_call' }
245
+ * })
246
+ * ```
247
+ */
248
+ declare class NetworkError extends SIPError {
249
+ /** The endpoint that failed (if applicable) */
250
+ readonly endpoint?: string;
251
+ /** HTTP status code (if applicable) */
252
+ readonly statusCode?: number;
253
+ constructor(message: string, code?: ErrorCode, options?: {
254
+ cause?: Error;
255
+ context?: Record<string, unknown>;
256
+ endpoint?: string;
257
+ statusCode?: number;
258
+ });
259
+ }
260
+ /**
261
+ * Check if an error is a SIP Protocol error
262
+ */
263
+ declare function isSIPError(error: unknown): error is SIPError;
264
+ /**
265
+ * Check if an error has a specific error code
266
+ */
267
+ declare function hasErrorCode(error: unknown, code: ErrorCode): boolean;
268
+ /**
269
+ * Wrap an unknown error as a SIPError
270
+ *
271
+ * Useful for catching and re-throwing with additional context.
272
+ *
273
+ * @example
274
+ * ```typescript
275
+ * try {
276
+ * await riskyOperation()
277
+ * } catch (e) {
278
+ * throw wrapError(e, 'Operation failed', ErrorCode.INTERNAL)
279
+ * }
280
+ * ```
281
+ */
282
+ declare function wrapError(error: unknown, message: string, code?: ErrorCode, context?: Record<string, unknown>): SIPError;
283
+ /**
284
+ * Extract error message from unknown error
285
+ */
286
+ declare function getErrorMessage(error: unknown): string;
287
+
288
+ /**
289
+ * Proof Provider Interface
290
+ *
291
+ * Defines a pluggable interface for ZK proof generation and verification.
292
+ * This allows different backends (Noir, mock for testing) to be swapped.
293
+ *
294
+ * @see docs/specs/ZK-ARCHITECTURE.md for framework decision (Noir)
295
+ */
296
+
297
+ /**
298
+ * Supported proof framework types
299
+ */
300
+ type ProofFramework = 'noir' | 'mock';
301
+ /**
302
+ * Parameters for generating a Funding Proof
303
+ *
304
+ * Proves: balance >= minimumRequired without revealing balance
305
+ *
306
+ * @see docs/specs/FUNDING-PROOF.md
307
+ */
308
+ interface FundingProofParams {
309
+ /** User's actual balance (private) */
310
+ balance: bigint;
311
+ /** Minimum amount required for the intent (public) */
312
+ minimumRequired: bigint;
313
+ /** Blinding factor for the commitment (private) */
314
+ blindingFactor: Uint8Array;
315
+ /** Asset identifier (public) */
316
+ assetId: string;
317
+ /** User's address for ownership proof (private) */
318
+ userAddress: string;
319
+ /** Signature proving ownership of the address (private) */
320
+ ownershipSignature: Uint8Array;
321
+ }
322
+ /**
323
+ * Parameters for generating a Validity Proof
324
+ *
325
+ * Proves: intent is authorized by sender without revealing sender
326
+ *
327
+ * @see docs/specs/VALIDITY-PROOF.md
328
+ */
329
+ interface ValidityProofParams {
330
+ /** Hash of the intent (public) */
331
+ intentHash: HexString;
332
+ /** Sender's address (private) */
333
+ senderAddress: string;
334
+ /** Blinding factor for sender commitment (private) */
335
+ senderBlinding: Uint8Array;
336
+ /** Sender's secret key (private) */
337
+ senderSecret: Uint8Array;
338
+ /** Signature authorizing the intent (private) */
339
+ authorizationSignature: Uint8Array;
340
+ /** Nonce for nullifier generation (private) */
341
+ nonce: Uint8Array;
342
+ /** Intent timestamp (public) */
343
+ timestamp: number;
344
+ /** Intent expiry (public) */
345
+ expiry: number;
346
+ }
347
+ /**
348
+ * Parameters for generating a Fulfillment Proof
349
+ *
350
+ * Proves: solver delivered output >= minimum to correct recipient
351
+ *
352
+ * @see docs/specs/FULFILLMENT-PROOF.md
353
+ */
354
+ interface FulfillmentProofParams {
355
+ /** Hash of the original intent (public) */
356
+ intentHash: HexString;
357
+ /** Actual output amount delivered (private) */
358
+ outputAmount: bigint;
359
+ /** Blinding factor for output commitment (private) */
360
+ outputBlinding: Uint8Array;
361
+ /** Minimum required output from intent (public) */
362
+ minOutputAmount: bigint;
363
+ /** Recipient's stealth address (public) */
364
+ recipientStealth: HexString;
365
+ /** Solver's identifier (public) */
366
+ solverId: string;
367
+ /** Solver's secret for authorization (private) */
368
+ solverSecret: Uint8Array;
369
+ /** Oracle attestation of delivery (private) */
370
+ oracleAttestation: OracleAttestation;
371
+ /** Time of fulfillment (public) */
372
+ fulfillmentTime: number;
373
+ /** Intent expiry (public) */
374
+ expiry: number;
375
+ }
376
+ /**
377
+ * Oracle attestation for cross-chain verification
378
+ */
379
+ interface OracleAttestation {
380
+ /** Recipient who received funds */
381
+ recipient: HexString;
382
+ /** Amount received */
383
+ amount: bigint;
384
+ /** Transaction hash on destination chain */
385
+ txHash: HexString;
386
+ /** Block number containing the transaction */
387
+ blockNumber: bigint;
388
+ /** Oracle signature (threshold signature for multi-oracle) */
389
+ signature: Uint8Array;
390
+ }
391
+ /**
392
+ * Result of proof generation
393
+ */
394
+ interface ProofResult {
395
+ /** The generated proof */
396
+ proof: ZKProof;
397
+ /** Public inputs used in the proof */
398
+ publicInputs: HexString[];
399
+ /** Commitment (if generated as part of proof) */
400
+ commitment?: Commitment;
401
+ }
402
+ /**
403
+ * Proof Provider Interface
404
+ *
405
+ * Implementations of this interface provide ZK proof generation and verification.
406
+ * The SDK uses this interface to remain agnostic to the underlying ZK framework.
407
+ *
408
+ * @example
409
+ * ```typescript
410
+ * // Use mock provider for testing
411
+ * const mockProvider = new MockProofProvider()
412
+ *
413
+ * // Use Noir provider for production
414
+ * const noirProvider = new NoirProofProvider()
415
+ *
416
+ * // Configure SIP client with provider
417
+ * const sip = new SIP({
418
+ * network: 'testnet',
419
+ * proofProvider: noirProvider,
420
+ * })
421
+ * ```
422
+ */
423
+ interface ProofProvider {
424
+ /**
425
+ * The ZK framework this provider uses
426
+ */
427
+ readonly framework: ProofFramework;
428
+ /**
429
+ * Whether the provider is ready to generate proofs
430
+ * (e.g., circuits compiled, keys loaded)
431
+ */
432
+ readonly isReady: boolean;
433
+ /**
434
+ * Initialize the provider (compile circuits, load keys, etc.)
435
+ *
436
+ * @throws Error if initialization fails
437
+ */
438
+ initialize(): Promise<void>;
439
+ /**
440
+ * Generate a Funding Proof
441
+ *
442
+ * Proves that the user has sufficient balance without revealing the exact amount.
443
+ *
444
+ * @param params - Funding proof parameters
445
+ * @returns The generated proof with public inputs
446
+ * @throws ProofGenerationError if proof generation fails
447
+ *
448
+ * @see docs/specs/FUNDING-PROOF.md (~22,000 constraints)
449
+ */
450
+ generateFundingProof(params: FundingProofParams): Promise<ProofResult>;
451
+ /**
452
+ * Generate a Validity Proof
453
+ *
454
+ * Proves that the intent is authorized without revealing the sender.
455
+ *
456
+ * @param params - Validity proof parameters
457
+ * @returns The generated proof with public inputs
458
+ * @throws ProofGenerationError if proof generation fails
459
+ *
460
+ * @see docs/specs/VALIDITY-PROOF.md (~72,000 constraints)
461
+ */
462
+ generateValidityProof(params: ValidityProofParams): Promise<ProofResult>;
463
+ /**
464
+ * Generate a Fulfillment Proof
465
+ *
466
+ * Proves that the solver correctly delivered the output.
467
+ *
468
+ * @param params - Fulfillment proof parameters
469
+ * @returns The generated proof with public inputs
470
+ * @throws ProofGenerationError if proof generation fails
471
+ *
472
+ * @see docs/specs/FULFILLMENT-PROOF.md (~22,000 constraints)
473
+ */
474
+ generateFulfillmentProof(params: FulfillmentProofParams): Promise<ProofResult>;
475
+ /**
476
+ * Verify a proof
477
+ *
478
+ * @param proof - The proof to verify
479
+ * @returns true if the proof is valid, false otherwise
480
+ */
481
+ verifyProof(proof: ZKProof): Promise<boolean>;
482
+ }
483
+ /**
484
+ * Error thrown when proof generation fails
485
+ */
486
+ declare class ProofGenerationError extends Error {
487
+ readonly proofType: 'funding' | 'validity' | 'fulfillment';
488
+ readonly cause?: Error;
489
+ constructor(proofType: 'funding' | 'validity' | 'fulfillment', message: string, cause?: Error);
490
+ }
491
+
492
+ /**
493
+ * Mock Proof Provider
494
+ *
495
+ * ⚠️ WARNING: FOR TESTING ONLY - DO NOT USE IN PRODUCTION ⚠️
496
+ *
497
+ * This provider generates fake proofs that provide NO cryptographic guarantees.
498
+ * It is intended solely for:
499
+ * - Unit testing
500
+ * - Integration testing
501
+ * - Development/debugging
502
+ *
503
+ * The mock proofs are clearly marked and will be rejected by any real verifier.
504
+ */
505
+
506
+ /**
507
+ * Mock Proof Provider for testing
508
+ *
509
+ * @example
510
+ * ```typescript
511
+ * // Only use in tests
512
+ * const provider = new MockProofProvider()
513
+ * await provider.initialize()
514
+ *
515
+ * const result = await provider.generateFundingProof({
516
+ * balance: 100n,
517
+ * minimumRequired: 50n,
518
+ * // ... other params
519
+ * })
520
+ * ```
521
+ */
522
+ declare class MockProofProvider implements ProofProvider {
523
+ readonly framework: ProofFramework;
524
+ private _isReady;
525
+ private _warningShown;
526
+ get isReady(): boolean;
527
+ /**
528
+ * Initialize the mock provider
529
+ *
530
+ * Logs a warning to console about mock usage.
531
+ */
532
+ initialize(): Promise<void>;
533
+ /**
534
+ * Generate a mock funding proof
535
+ *
536
+ * ⚠️ This proof provides NO cryptographic guarantees!
537
+ */
538
+ generateFundingProof(params: FundingProofParams): Promise<ProofResult>;
539
+ /**
540
+ * Generate a mock validity proof
541
+ *
542
+ * ⚠️ This proof provides NO cryptographic guarantees!
543
+ */
544
+ generateValidityProof(params: ValidityProofParams): Promise<ProofResult>;
545
+ /**
546
+ * Generate a mock fulfillment proof
547
+ *
548
+ * ⚠️ This proof provides NO cryptographic guarantees!
549
+ */
550
+ generateFulfillmentProof(params: FulfillmentProofParams): Promise<ProofResult>;
551
+ /**
552
+ * Verify a mock proof
553
+ *
554
+ * Only verifies that the proof has the mock prefix.
555
+ * ⚠️ This provides NO cryptographic verification!
556
+ */
557
+ verifyProof(proof: ZKProof): Promise<boolean>;
558
+ /**
559
+ * Check if a proof is a mock proof
560
+ */
561
+ static isMockProof(proof: ZKProof): boolean;
562
+ private ensureReady;
563
+ private generateMockProofData;
564
+ private hashToHex;
565
+ }
566
+
567
+ /**
568
+ * Noir Proof Provider
569
+ *
570
+ * Production-ready ZK proof provider using Noir (Aztec) circuits.
571
+ *
572
+ * This provider generates cryptographically sound proofs using:
573
+ * - Funding Proof: ~22,000 constraints (docs/specs/FUNDING-PROOF.md)
574
+ * - Validity Proof: ~72,000 constraints (docs/specs/VALIDITY-PROOF.md)
575
+ * - Fulfillment Proof: ~22,000 constraints (docs/specs/FULFILLMENT-PROOF.md)
576
+ *
577
+ * @see docs/specs/ZK-ARCHITECTURE.md for framework decision
578
+ */
579
+
580
+ /**
581
+ * Noir Proof Provider Configuration
582
+ */
583
+ interface NoirProviderConfig {
584
+ /**
585
+ * Path to compiled circuit artifacts
586
+ * If not provided, uses bundled artifacts
587
+ */
588
+ artifactsPath?: string;
589
+ /**
590
+ * Backend to use for proof generation
591
+ * @default 'barretenberg' (UltraPlonk)
592
+ */
593
+ backend?: 'barretenberg';
594
+ /**
595
+ * Enable verbose logging for debugging
596
+ * @default false
597
+ */
598
+ verbose?: boolean;
599
+ }
600
+ /**
601
+ * Noir Proof Provider
602
+ *
603
+ * Production ZK proof provider using Noir circuits.
604
+ *
605
+ * @example
606
+ * ```typescript
607
+ * const provider = new NoirProofProvider({
608
+ * artifactsPath: './circuits/target',
609
+ * })
610
+ *
611
+ * await provider.initialize()
612
+ *
613
+ * const result = await provider.generateFundingProof({
614
+ * balance: 100n,
615
+ * minimumRequired: 50n,
616
+ * // ... other params
617
+ * })
618
+ * ```
619
+ */
620
+ declare class NoirProofProvider implements ProofProvider {
621
+ readonly framework: ProofFramework;
622
+ private _isReady;
623
+ private config;
624
+ private artifacts;
625
+ constructor(config?: NoirProviderConfig);
626
+ get isReady(): boolean;
627
+ /**
628
+ * Initialize the Noir provider
629
+ *
630
+ * Loads circuit artifacts and initializes the proving backend.
631
+ *
632
+ * @throws Error if circuits are not yet implemented
633
+ */
634
+ initialize(): Promise<void>;
635
+ /**
636
+ * Generate a Funding Proof using Noir circuits
637
+ *
638
+ * @see docs/specs/FUNDING-PROOF.md
639
+ */
640
+ generateFundingProof(_params: FundingProofParams): Promise<ProofResult>;
641
+ /**
642
+ * Generate a Validity Proof using Noir circuits
643
+ *
644
+ * @see docs/specs/VALIDITY-PROOF.md
645
+ */
646
+ generateValidityProof(_params: ValidityProofParams): Promise<ProofResult>;
647
+ /**
648
+ * Generate a Fulfillment Proof using Noir circuits
649
+ *
650
+ * @see docs/specs/FULFILLMENT-PROOF.md
651
+ */
652
+ generateFulfillmentProof(_params: FulfillmentProofParams): Promise<ProofResult>;
653
+ /**
654
+ * Verify a Noir proof
655
+ */
656
+ verifyProof(_proof: ZKProof): Promise<boolean>;
657
+ private ensureReady;
658
+ }
659
+
660
+ /**
661
+ * Options for creating a shielded intent
662
+ */
663
+ interface CreateIntentOptions {
664
+ /** Sender address (for ownership proof) */
665
+ senderAddress?: string;
666
+ /**
667
+ * Proof provider for generating ZK proofs
668
+ * If provided and privacy level requires proofs, they will be generated automatically
669
+ */
670
+ proofProvider?: ProofProvider;
671
+ }
672
+ /**
673
+ * Builder class for creating shielded intents
674
+ */
675
+ declare class IntentBuilder {
676
+ private params;
677
+ private senderAddress?;
678
+ private proofProvider?;
679
+ /**
680
+ * Set the input for the intent
681
+ *
682
+ * @throws {ValidationError} If chain or amount is invalid
683
+ */
684
+ input(chain: string, token: string, amount: number | bigint, sourceAddress?: string): this;
685
+ /**
686
+ * Set the output for the intent
687
+ *
688
+ * @throws {ValidationError} If chain is invalid
689
+ */
690
+ output(chain: string, token: string, minAmount?: number | bigint): this;
691
+ /**
692
+ * Set the privacy level
693
+ *
694
+ * @throws {ValidationError} If privacy level is invalid
695
+ */
696
+ privacy(level: PrivacyLevel): this;
697
+ /**
698
+ * Set the recipient's stealth meta-address
699
+ *
700
+ * @throws {ValidationError} If stealth meta-address format is invalid
701
+ */
702
+ recipient(metaAddress: string): this;
703
+ /**
704
+ * Set slippage tolerance
705
+ *
706
+ * @param percent - Slippage percentage (e.g., 1 for 1%)
707
+ * @throws {ValidationError} If slippage is out of range
708
+ */
709
+ slippage(percent: number): this;
710
+ /**
711
+ * Set time-to-live in seconds
712
+ *
713
+ * @throws {ValidationError} If TTL is not a positive integer
714
+ */
715
+ ttl(seconds: number): this;
716
+ /**
717
+ * Set the proof provider for automatic proof generation
718
+ *
719
+ * @param provider - The proof provider to use
720
+ * @returns this for chaining
721
+ *
722
+ * @example
723
+ * ```typescript
724
+ * const intent = await builder
725
+ * .input('near', 'NEAR', 100n)
726
+ * .output('zcash', 'ZEC', 95n)
727
+ * .privacy(PrivacyLevel.SHIELDED)
728
+ * .withProvider(mockProvider)
729
+ * .build()
730
+ * ```
731
+ */
732
+ withProvider(provider: ProofProvider): this;
733
+ /**
734
+ * Build the shielded intent
735
+ *
736
+ * If a proof provider is set and the privacy level requires proofs,
737
+ * they will be generated automatically.
738
+ *
739
+ * @returns Promise resolving to the shielded intent
740
+ */
741
+ build(): Promise<ShieldedIntent>;
742
+ }
743
+ /**
744
+ * Create a new shielded intent
745
+ *
746
+ * @param params - Intent creation parameters
747
+ * @param options - Optional configuration (sender address, proof provider)
748
+ * @returns Promise resolving to the shielded intent
749
+ *
750
+ * @example
751
+ * ```typescript
752
+ * // Without proof provider (proofs need to be attached later)
753
+ * const intent = await createShieldedIntent(params)
754
+ *
755
+ * // With proof provider (proofs generated automatically for SHIELDED/COMPLIANT)
756
+ * const intent = await createShieldedIntent(params, {
757
+ * senderAddress: wallet.address,
758
+ * proofProvider: mockProvider,
759
+ * })
760
+ * ```
761
+ */
762
+ declare function createShieldedIntent(params: CreateIntentParams, options?: CreateIntentOptions): Promise<ShieldedIntent>;
763
+ /**
764
+ * Attach proofs to a shielded intent
765
+ *
766
+ * For SHIELDED and COMPLIANT modes, proofs are required before the intent
767
+ * can be submitted. This function attaches the proofs to an intent.
768
+ *
769
+ * @param intent - The intent to attach proofs to
770
+ * @param fundingProof - The funding proof (balance >= minimum)
771
+ * @param validityProof - The validity proof (authorization)
772
+ * @returns The intent with proofs attached
773
+ */
774
+ declare function attachProofs(intent: ShieldedIntent, fundingProof: _sip_protocol_types.ZKProof, validityProof: _sip_protocol_types.ZKProof): ShieldedIntent;
775
+ /**
776
+ * Check if an intent has all required proofs
777
+ */
778
+ declare function hasRequiredProofs(intent: ShieldedIntent): boolean;
779
+ /**
780
+ * Wrap a shielded intent with status tracking
781
+ */
782
+ declare function trackIntent(intent: ShieldedIntent): TrackedIntent;
783
+ /**
784
+ * Check if an intent has expired
785
+ */
786
+ declare function isExpired(intent: ShieldedIntent): boolean;
787
+ /**
788
+ * Get time remaining until intent expires (in seconds)
789
+ */
790
+ declare function getTimeRemaining(intent: ShieldedIntent): number;
791
+ /**
792
+ * Serialize a shielded intent to JSON
793
+ */
794
+ declare function serializeIntent(intent: ShieldedIntent): string;
795
+ /**
796
+ * Deserialize a shielded intent from JSON
797
+ */
798
+ declare function deserializeIntent(json: string): ShieldedIntent;
799
+ /**
800
+ * Get a human-readable summary of the intent
801
+ */
802
+ declare function getIntentSummary(intent: ShieldedIntent): string;
803
+
804
+ /**
805
+ * SIP SDK Main Client
806
+ *
807
+ * High-level interface for interacting with the Shielded Intents Protocol.
808
+ */
809
+
810
+ /**
811
+ * SIP SDK configuration
812
+ */
813
+ interface SIPConfig {
814
+ /** Network: mainnet or testnet */
815
+ network: 'mainnet' | 'testnet';
816
+ /** Default privacy level */
817
+ defaultPrivacy?: PrivacyLevel;
818
+ /** RPC endpoints for chains */
819
+ rpcEndpoints?: Partial<Record<ChainId, string>>;
820
+ /**
821
+ * Proof provider for ZK proof generation
822
+ *
823
+ * If not provided, proof generation will not be available.
824
+ * Use MockProofProvider for testing, NoirProofProvider for production.
825
+ *
826
+ * @example
827
+ * ```typescript
828
+ * import { MockProofProvider } from '@sip-protocol/sdk'
829
+ *
830
+ * const sip = new SIP({
831
+ * network: 'testnet',
832
+ * proofProvider: new MockProofProvider(),
833
+ * })
834
+ * ```
835
+ */
836
+ proofProvider?: ProofProvider;
837
+ }
838
+ /**
839
+ * Wallet adapter interface
840
+ */
841
+ interface WalletAdapter {
842
+ /** Connected chain */
843
+ chain: ChainId;
844
+ /** Wallet address */
845
+ address: string;
846
+ /** Sign a message */
847
+ signMessage(message: string): Promise<string>;
848
+ /** Sign a transaction */
849
+ signTransaction(tx: unknown): Promise<unknown>;
850
+ }
851
+ /**
852
+ * Main SIP SDK class
853
+ */
854
+ declare class SIP {
855
+ private config;
856
+ private wallet?;
857
+ private stealthKeys?;
858
+ private proofProvider?;
859
+ constructor(config: SIPConfig);
860
+ /**
861
+ * Get the configured proof provider
862
+ */
863
+ getProofProvider(): ProofProvider | undefined;
864
+ /**
865
+ * Set or update the proof provider
866
+ */
867
+ setProofProvider(provider: ProofProvider): void;
868
+ /**
869
+ * Check if proof provider is available and ready
870
+ */
871
+ hasProofProvider(): boolean;
872
+ /**
873
+ * Connect a wallet
874
+ */
875
+ connect(wallet: WalletAdapter): void;
876
+ /**
877
+ * Disconnect wallet
878
+ */
879
+ disconnect(): void;
880
+ /**
881
+ * Check if wallet is connected
882
+ */
883
+ isConnected(): boolean;
884
+ /**
885
+ * Get connected wallet
886
+ */
887
+ getWallet(): WalletAdapter | undefined;
888
+ /**
889
+ * Generate and store stealth keys for this session
890
+ *
891
+ * @throws {ValidationError} If chain is invalid
892
+ */
893
+ generateStealthKeys(chain: ChainId, label?: string): StealthMetaAddress;
894
+ /**
895
+ * Get the encoded stealth meta-address for receiving
896
+ */
897
+ getStealthAddress(): string | undefined;
898
+ /**
899
+ * Create a new intent builder
900
+ *
901
+ * The builder is automatically configured with the SIP client's proof provider
902
+ * (if one is set), so proofs will be generated automatically when `.build()` is called.
903
+ *
904
+ * @example
905
+ * ```typescript
906
+ * const intent = await sip.intent()
907
+ * .input('near', 'NEAR', 100n)
908
+ * .output('zcash', 'ZEC', 95n)
909
+ * .privacy(PrivacyLevel.SHIELDED)
910
+ * .build()
911
+ * ```
912
+ */
913
+ intent(): IntentBuilder;
914
+ /**
915
+ * Create a shielded intent directly
916
+ *
917
+ * Uses the SIP client's configured proof provider (if any) to generate proofs
918
+ * automatically for SHIELDED and COMPLIANT privacy levels.
919
+ */
920
+ createIntent(params: CreateIntentParams): Promise<TrackedIntent>;
921
+ /**
922
+ * Get quotes for an intent (mock implementation)
923
+ */
924
+ getQuotes(intent: ShieldedIntent): Promise<Quote[]>;
925
+ /**
926
+ * Execute an intent with a selected quote (mock implementation)
927
+ */
928
+ execute(intent: TrackedIntent, quote: Quote): Promise<FulfillmentResult>;
929
+ /**
930
+ * Generate a viewing key for compliant mode
931
+ */
932
+ generateViewingKey(path?: string): ViewingKey;
933
+ /**
934
+ * Derive a child viewing key
935
+ */
936
+ deriveViewingKey(masterKey: ViewingKey, childPath: string): ViewingKey;
937
+ /**
938
+ * Get network configuration
939
+ */
940
+ getNetwork(): 'mainnet' | 'testnet';
941
+ }
942
+ /**
943
+ * Create a new SIP instance with default testnet config
944
+ */
945
+ declare function createSIP(network?: 'mainnet' | 'testnet'): SIP;
946
+
947
+ /**
948
+ * Stealth Address Generation for SIP Protocol
949
+ *
950
+ * Implements EIP-5564 style stealth addresses using secp256k1.
951
+ * Provides unlinkable one-time addresses for privacy-preserving transactions.
952
+ *
953
+ * Flow:
954
+ * 1. Recipient generates stealth meta-address (spending key P, viewing key Q)
955
+ * 2. Sender generates ephemeral keypair (r, R = r*G)
956
+ * 3. Sender computes shared secret: S = r * P
957
+ * 4. Sender derives stealth address: A = Q + hash(S)*G
958
+ * 5. Recipient scans: for each R, compute S = p * R, check if A matches
959
+ */
960
+
961
+ /**
962
+ * Generate a new stealth meta-address keypair
963
+ *
964
+ * @param chain - Target chain for the addresses
965
+ * @param label - Optional human-readable label
966
+ * @returns Stealth meta-address and private keys
967
+ * @throws {ValidationError} If chain is invalid
968
+ */
969
+ declare function generateStealthMetaAddress(chain: ChainId, label?: string): {
970
+ metaAddress: StealthMetaAddress;
971
+ spendingPrivateKey: HexString;
972
+ viewingPrivateKey: HexString;
973
+ };
974
+ /**
975
+ * Generate a one-time stealth address for a recipient
976
+ *
977
+ * @param recipientMetaAddress - Recipient's published stealth meta-address
978
+ * @returns Stealth address data (address + ephemeral key for publication)
979
+ * @throws {ValidationError} If recipientMetaAddress is invalid
980
+ */
981
+ declare function generateStealthAddress(recipientMetaAddress: StealthMetaAddress): {
982
+ stealthAddress: StealthAddress;
983
+ sharedSecret: HexString;
984
+ };
985
+ /**
986
+ * Derive the private key for a stealth address (for recipient to claim funds)
987
+ *
988
+ * @param stealthAddress - The stealth address to recover
989
+ * @param spendingPrivateKey - Recipient's spending private key
990
+ * @param viewingPrivateKey - Recipient's viewing private key
991
+ * @returns Recovery data including derived private key
992
+ * @throws {ValidationError} If any input is invalid
993
+ */
994
+ declare function deriveStealthPrivateKey(stealthAddress: StealthAddress, spendingPrivateKey: HexString, viewingPrivateKey: HexString): StealthAddressRecovery;
995
+ /**
996
+ * Check if a stealth address was intended for this recipient
997
+ * Uses view tag for efficient filtering before full computation
998
+ *
999
+ * @param stealthAddress - Stealth address to check
1000
+ * @param spendingPrivateKey - Recipient's spending private key
1001
+ * @param viewingPrivateKey - Recipient's viewing private key
1002
+ * @returns true if this address belongs to the recipient
1003
+ * @throws {ValidationError} If any input is invalid
1004
+ */
1005
+ declare function checkStealthAddress(stealthAddress: StealthAddress, spendingPrivateKey: HexString, viewingPrivateKey: HexString): boolean;
1006
+ /**
1007
+ * Encode a stealth meta-address as a string
1008
+ * Format: sip:{chain}:{spendingKey}:{viewingKey}
1009
+ */
1010
+ declare function encodeStealthMetaAddress(metaAddress: StealthMetaAddress): string;
1011
+ /**
1012
+ * Decode a stealth meta-address from a string
1013
+ *
1014
+ * @param encoded - Encoded stealth meta-address (format: sip:<chain>:<spendingKey>:<viewingKey>)
1015
+ * @returns Decoded StealthMetaAddress
1016
+ * @throws {ValidationError} If format is invalid or keys are malformed
1017
+ */
1018
+ declare function decodeStealthMetaAddress(encoded: string): StealthMetaAddress;
1019
+
1020
+ /**
1021
+ * Privacy level handling for SIP Protocol
1022
+ *
1023
+ * Provides authenticated encryption using XChaCha20-Poly1305 for viewing key
1024
+ * selective disclosure. This allows transaction details to be encrypted and
1025
+ * later revealed to auditors holding the viewing key.
1026
+ *
1027
+ * ## Security Properties
1028
+ * - **Confidentiality**: Only viewing key holders can decrypt
1029
+ * - **Integrity**: Authentication tag prevents tampering
1030
+ * - **Nonce-misuse resistance**: XChaCha20 uses 24-byte nonces
1031
+ */
1032
+
1033
+ /**
1034
+ * Privacy configuration for an intent
1035
+ */
1036
+ interface PrivacyConfig {
1037
+ /** The privacy level */
1038
+ level: PrivacyLevel;
1039
+ /** Viewing key (required for compliant mode) */
1040
+ viewingKey?: ViewingKey;
1041
+ /** Whether to use stealth addresses */
1042
+ useStealth: boolean;
1043
+ /** Whether to encrypt transaction data */
1044
+ encryptData: boolean;
1045
+ }
1046
+ /**
1047
+ * Get privacy configuration for a privacy level
1048
+ */
1049
+ declare function getPrivacyConfig(level: PrivacyLevel, viewingKey?: ViewingKey): PrivacyConfig;
1050
+ /**
1051
+ * Generate a new viewing key
1052
+ */
1053
+ declare function generateViewingKey(path?: string): ViewingKey;
1054
+ /**
1055
+ * Derive a child viewing key using BIP32-style hierarchical derivation
1056
+ *
1057
+ * Uses HMAC-SHA512 for proper key derivation:
1058
+ * - childKey = HMAC-SHA512(masterKey, childPath)
1059
+ * - Takes first 32 bytes as the derived key
1060
+ *
1061
+ * This provides:
1062
+ * - Cryptographic standard compliance (similar to BIP32)
1063
+ * - One-way derivation (cannot derive parent from child)
1064
+ * - Non-correlatable keys (different paths produce unrelated keys)
1065
+ */
1066
+ declare function deriveViewingKey(masterKey: ViewingKey, childPath: string): ViewingKey;
1067
+ /**
1068
+ * Transaction data that can be encrypted for viewing
1069
+ */
1070
+ interface TransactionData {
1071
+ sender: string;
1072
+ recipient: string;
1073
+ amount: string;
1074
+ timestamp: number;
1075
+ }
1076
+ /**
1077
+ * Encrypt transaction data for viewing key holders
1078
+ *
1079
+ * Uses XChaCha20-Poly1305 authenticated encryption with:
1080
+ * - 24-byte random nonce (nonce-misuse resistant)
1081
+ * - HKDF-derived encryption key
1082
+ * - 16-byte authentication tag (included in ciphertext)
1083
+ *
1084
+ * @param data - Transaction data to encrypt
1085
+ * @param viewingKey - Viewing key for encryption
1086
+ * @returns Encrypted transaction with nonce and key hash
1087
+ *
1088
+ * @example
1089
+ * ```typescript
1090
+ * const encrypted = encryptForViewing(
1091
+ * { sender: '0x...', recipient: '0x...', amount: '100', timestamp: 123 },
1092
+ * viewingKey
1093
+ * )
1094
+ * // encrypted.ciphertext contains the encrypted data
1095
+ * // encrypted.nonce is needed for decryption
1096
+ * // encrypted.viewingKeyHash identifies which key can decrypt
1097
+ * ```
1098
+ */
1099
+ declare function encryptForViewing(data: TransactionData, viewingKey: ViewingKey): EncryptedTransaction;
1100
+ /**
1101
+ * Decrypt transaction data with viewing key
1102
+ *
1103
+ * Performs authenticated decryption using XChaCha20-Poly1305.
1104
+ * The authentication tag is verified before returning data.
1105
+ *
1106
+ * @param encrypted - Encrypted transaction data
1107
+ * @param viewingKey - Viewing key for decryption
1108
+ * @returns Decrypted transaction data
1109
+ * @throws {Error} If decryption fails (wrong key, tampered data, etc.)
1110
+ *
1111
+ * @example
1112
+ * ```typescript
1113
+ * try {
1114
+ * const data = decryptWithViewing(encrypted, viewingKey)
1115
+ * console.log(`Amount: ${data.amount}`)
1116
+ * } catch (e) {
1117
+ * console.error('Decryption failed - wrong key or tampered data')
1118
+ * }
1119
+ * ```
1120
+ */
1121
+ declare function decryptWithViewing(encrypted: EncryptedTransaction, viewingKey: ViewingKey): TransactionData;
1122
+ /**
1123
+ * Get human-readable description of privacy level
1124
+ */
1125
+ declare function getPrivacyDescription(level: PrivacyLevel): string;
1126
+
1127
+ /**
1128
+ * Cryptographic utilities for SIP Protocol
1129
+ *
1130
+ * For ZK proofs, use ProofProvider:
1131
+ * @see ./proofs/interface.ts for the proof provider interface
1132
+ * @see ./proofs/mock.ts for testing
1133
+ * @see ./proofs/noir.ts for production (Noir circuits)
1134
+ *
1135
+ * For Pedersen commitments, use the dedicated commitment module:
1136
+ * @see ./commitment.ts for secure Pedersen commitment implementation
1137
+ */
1138
+
1139
+ /**
1140
+ * Create a Pedersen commitment to a value
1141
+ *
1142
+ * @deprecated Use `commit()` from './commitment' for new code.
1143
+ * This wrapper maintains backward compatibility.
1144
+ *
1145
+ * @param value - The value to commit to
1146
+ * @param blindingFactor - Optional blinding factor (random if not provided)
1147
+ * @returns Commitment object (legacy format)
1148
+ */
1149
+ declare function createCommitment(value: bigint, blindingFactor?: Uint8Array): Commitment;
1150
+ /**
1151
+ * Verify a Pedersen commitment (requires knowing the value and blinding factor)
1152
+ *
1153
+ * @deprecated Use `verifyOpening()` from './commitment' for new code.
1154
+ */
1155
+ declare function verifyCommitment(commitment: Commitment, expectedValue: bigint): boolean;
1156
+ /**
1157
+ * Generate a random intent ID
1158
+ */
1159
+ declare function generateIntentId(): string;
1160
+ /**
1161
+ * Hash data using SHA256
1162
+ */
1163
+ declare function hash(data: string | Uint8Array): Hash;
1164
+ /**
1165
+ * Generate random bytes
1166
+ */
1167
+ declare function generateRandomBytes(length: number): HexString;
1168
+
1169
+ /**
1170
+ * Pedersen Commitment Implementation
1171
+ *
1172
+ * Cryptographically secure Pedersen commitments on secp256k1.
1173
+ *
1174
+ * ## Security Properties
1175
+ *
1176
+ * - **Hiding (Computational)**: Cannot determine value from commitment
1177
+ * - **Binding (Computational)**: Cannot open commitment to different value
1178
+ * - **Homomorphic**: C(v1) + C(v2) = C(v1 + v2) when blindings sum
1179
+ *
1180
+ * ## Generator H Construction
1181
+ *
1182
+ * H is constructed using "nothing-up-my-sleeve" (NUMS) method:
1183
+ * - Take a well-known string "SIP-PEDERSEN-GENERATOR-H"
1184
+ * - Hash it to get x-coordinate candidate
1185
+ * - Iterate until we find a valid curve point
1186
+ * - This ensures nobody knows the discrete log of H w.r.t. G
1187
+ *
1188
+ * @see docs/specs/SIP-SPEC.md Section 3.3 - Pedersen Commitment
1189
+ */
1190
+
1191
+ /**
1192
+ * A Pedersen commitment with associated blinding factor
1193
+ */
1194
+ interface PedersenCommitment {
1195
+ /**
1196
+ * The commitment point C = v*G + r*H (compressed, 33 bytes)
1197
+ */
1198
+ commitment: HexString;
1199
+ /**
1200
+ * The blinding factor r (32 bytes, secret)
1201
+ * Required to open/verify the commitment
1202
+ */
1203
+ blinding: HexString;
1204
+ }
1205
+ /**
1206
+ * A commitment point without the blinding factor (for public sharing)
1207
+ */
1208
+ interface CommitmentPoint {
1209
+ /**
1210
+ * The commitment point (compressed, 33 bytes)
1211
+ */
1212
+ commitment: HexString;
1213
+ }
1214
+ /**
1215
+ * Create a Pedersen commitment to a value
1216
+ *
1217
+ * C = v*G + r*H
1218
+ *
1219
+ * Where:
1220
+ * - v = value (the amount being committed)
1221
+ * - r = blinding factor (random, keeps value hidden)
1222
+ * - G = base generator
1223
+ * - H = independent generator (NUMS)
1224
+ *
1225
+ * @param value - The value to commit to (must be < curve order)
1226
+ * @param blinding - Optional blinding factor (random 32 bytes if not provided)
1227
+ * @returns The commitment and blinding factor
1228
+ *
1229
+ * @example
1230
+ * ```typescript
1231
+ * // Create a commitment to 100 tokens
1232
+ * const { commitment, blinding } = commit(100n)
1233
+ *
1234
+ * // Later, prove the commitment contains 100
1235
+ * const valid = verifyOpening(commitment, 100n, blinding)
1236
+ * ```
1237
+ */
1238
+ declare function commit(value: bigint, blinding?: Uint8Array): PedersenCommitment;
1239
+ /**
1240
+ * Verify that a commitment opens to a specific value
1241
+ *
1242
+ * Recomputes C' = v*G + r*H and checks if C' == C
1243
+ *
1244
+ * @param commitment - The commitment point to verify
1245
+ * @param value - The claimed value
1246
+ * @param blinding - The blinding factor used
1247
+ * @returns true if the commitment opens correctly
1248
+ */
1249
+ declare function verifyOpening(commitment: HexString, value: bigint, blinding: HexString): boolean;
1250
+ /**
1251
+ * Create a commitment to zero with a specific blinding factor
1252
+ *
1253
+ * C = 0*G + r*H = r*H
1254
+ *
1255
+ * Useful for creating balance proofs.
1256
+ *
1257
+ * @param blinding - The blinding factor
1258
+ * @returns Commitment to zero
1259
+ */
1260
+ declare function commitZero(blinding: Uint8Array): PedersenCommitment;
1261
+ /**
1262
+ * Add two commitments homomorphically
1263
+ *
1264
+ * C1 + C2 = (v1*G + r1*H) + (v2*G + r2*H) = (v1+v2)*G + (r1+r2)*H
1265
+ *
1266
+ * Note: The blinding factors also add. If you need to verify the sum,
1267
+ * you must also sum the blinding factors.
1268
+ *
1269
+ * @param c1 - First commitment point
1270
+ * @param c2 - Second commitment point
1271
+ * @returns Sum of commitments
1272
+ * @throws {ValidationError} If commitments are invalid hex strings
1273
+ */
1274
+ declare function addCommitments(c1: HexString, c2: HexString): CommitmentPoint;
1275
+ /**
1276
+ * Subtract two commitments homomorphically
1277
+ *
1278
+ * C1 - C2 = (v1-v2)*G + (r1-r2)*H
1279
+ *
1280
+ * @param c1 - First commitment point
1281
+ * @param c2 - Second commitment point (to subtract)
1282
+ * @returns Difference of commitments
1283
+ * @throws {ValidationError} If commitments are invalid
1284
+ */
1285
+ declare function subtractCommitments(c1: HexString, c2: HexString): CommitmentPoint;
1286
+ /**
1287
+ * Add blinding factors (for use with homomorphic addition)
1288
+ *
1289
+ * When you add commitments, the result commits to (v1+v2) with
1290
+ * blinding (r1+r2). Use this to compute the combined blinding.
1291
+ *
1292
+ * @param b1 - First blinding factor
1293
+ * @param b2 - Second blinding factor
1294
+ * @returns Sum of blindings (mod curve order)
1295
+ */
1296
+ declare function addBlindings(b1: HexString, b2: HexString): HexString;
1297
+ /**
1298
+ * Subtract blinding factors (for use with homomorphic subtraction)
1299
+ *
1300
+ * @param b1 - First blinding factor
1301
+ * @param b2 - Second blinding factor (to subtract)
1302
+ * @returns Difference of blindings (mod curve order)
1303
+ */
1304
+ declare function subtractBlindings(b1: HexString, b2: HexString): HexString;
1305
+ /**
1306
+ * Get the generators for ZK proof integration
1307
+ *
1308
+ * Returns the G and H points for use in Noir circuits.
1309
+ */
1310
+ declare function getGenerators(): {
1311
+ G: {
1312
+ x: HexString;
1313
+ y: HexString;
1314
+ };
1315
+ H: {
1316
+ x: HexString;
1317
+ y: HexString;
1318
+ };
1319
+ };
1320
+ /**
1321
+ * Generate a random blinding factor
1322
+ */
1323
+ declare function generateBlinding(): HexString;
1324
+
1325
+ /**
1326
+ * Input validation utilities for SIP Protocol SDK
1327
+ *
1328
+ * Provides comprehensive validation for all public API inputs.
1329
+ */
1330
+
1331
+ /**
1332
+ * Check if a string is a valid chain ID
1333
+ */
1334
+ declare function isValidChainId(chain: string): chain is ChainId;
1335
+ /**
1336
+ * Check if a value is a valid privacy level
1337
+ */
1338
+ declare function isValidPrivacyLevel(level: unknown): level is PrivacyLevel;
1339
+ /**
1340
+ * Check if a string is valid hex format (with 0x prefix)
1341
+ */
1342
+ declare function isValidHex(value: string): value is HexString;
1343
+ /**
1344
+ * Check if a hex string has a specific byte length
1345
+ */
1346
+ declare function isValidHexLength(value: string, byteLength: number): boolean;
1347
+ /**
1348
+ * Check if an amount is valid (positive bigint)
1349
+ */
1350
+ declare function isValidAmount(value: unknown): value is bigint;
1351
+ /**
1352
+ * Check if an amount is non-negative
1353
+ */
1354
+ declare function isNonNegativeAmount(value: unknown): value is bigint;
1355
+ /**
1356
+ * Check if slippage is in valid range (0 to 1, exclusive of 1)
1357
+ */
1358
+ declare function isValidSlippage(value: number): boolean;
1359
+ /**
1360
+ * Check if a string is a valid stealth meta-address
1361
+ */
1362
+ declare function isValidStealthMetaAddress(addr: string): boolean;
1363
+ /**
1364
+ * Check if a public key is valid (compressed secp256k1: 33 bytes)
1365
+ */
1366
+ declare function isValidCompressedPublicKey(key: string): boolean;
1367
+ /**
1368
+ * Check if a private key is valid (32 bytes)
1369
+ */
1370
+ declare function isValidPrivateKey(key: string): boolean;
1371
+ /**
1372
+ * Validate an asset object
1373
+ */
1374
+ declare function validateAsset(asset: unknown, field: string): asserts asset is Asset;
1375
+ /**
1376
+ * Validate intent input
1377
+ */
1378
+ declare function validateIntentInput(input: unknown, field?: string): asserts input is IntentInput;
1379
+ /**
1380
+ * Validate intent output
1381
+ */
1382
+ declare function validateIntentOutput(output: unknown, field?: string): asserts output is IntentOutput;
1383
+ /**
1384
+ * Validate CreateIntentParams
1385
+ */
1386
+ declare function validateCreateIntentParams(params: unknown): asserts params is CreateIntentParams;
1387
+ /**
1388
+ * Validate a viewing key (32-byte hex string)
1389
+ */
1390
+ declare function validateViewingKey(key: unknown, field?: string): void;
1391
+ /**
1392
+ * Check if a bigint is a valid scalar (1 <= x < n)
1393
+ */
1394
+ declare function isValidScalar(value: bigint): boolean;
1395
+ /**
1396
+ * Validate a scalar value
1397
+ */
1398
+ declare function validateScalar(value: unknown, field: string): asserts value is bigint;
1399
+
1400
+ /**
1401
+ * NEAR 1Click API HTTP Client
1402
+ *
1403
+ * Provides typed access to the NEAR Intents 1Click API for cross-chain swaps.
1404
+ *
1405
+ * @see https://docs.near-intents.org/near-intents/integration/distribution-channels/1click-api
1406
+ */
1407
+
1408
+ /**
1409
+ * HTTP client for NEAR 1Click API
1410
+ *
1411
+ * @example
1412
+ * ```typescript
1413
+ * const client = new OneClickClient({
1414
+ * jwtToken: process.env.NEAR_INTENTS_JWT,
1415
+ * })
1416
+ *
1417
+ * // Get available tokens
1418
+ * const tokens = await client.getTokens()
1419
+ *
1420
+ * // Request a quote
1421
+ * const quote = await client.quote({
1422
+ * swapType: OneClickSwapType.EXACT_INPUT,
1423
+ * originAsset: 'near:mainnet:wrap.near',
1424
+ * destinationAsset: 'eth:1:native',
1425
+ * amount: '1000000000000000000000000',
1426
+ * refundTo: 'user.near',
1427
+ * recipient: '0x742d35Cc...',
1428
+ * depositType: 'near',
1429
+ * refundType: 'near',
1430
+ * recipientType: 'eth',
1431
+ * })
1432
+ *
1433
+ * // Check status
1434
+ * const status = await client.getStatus(quote.depositAddress)
1435
+ * ```
1436
+ */
1437
+ declare class OneClickClient {
1438
+ private readonly baseUrl;
1439
+ private readonly jwtToken?;
1440
+ private readonly timeout;
1441
+ private readonly fetchFn;
1442
+ constructor(config?: OneClickConfig);
1443
+ /**
1444
+ * Get all supported tokens
1445
+ *
1446
+ * @returns Array of supported tokens with metadata
1447
+ */
1448
+ getTokens(): Promise<OneClickToken[]>;
1449
+ /**
1450
+ * Request a swap quote
1451
+ *
1452
+ * @param request - Quote request parameters
1453
+ * @returns Quote response with deposit address and amounts
1454
+ * @throws {NetworkError} On API errors
1455
+ * @throws {ValidationError} On invalid parameters
1456
+ */
1457
+ quote(request: OneClickQuoteRequest): Promise<OneClickQuoteResponse>;
1458
+ /**
1459
+ * Request a dry quote (preview without deposit address)
1460
+ *
1461
+ * Useful for UI price estimates without committing to a swap.
1462
+ *
1463
+ * @param request - Quote request parameters (dry flag set automatically)
1464
+ * @returns Quote preview without deposit address
1465
+ */
1466
+ dryQuote(request: Omit<OneClickQuoteRequest, 'dry'>): Promise<OneClickQuoteResponse>;
1467
+ /**
1468
+ * Submit deposit transaction notification
1469
+ *
1470
+ * Call this after depositing to the depositAddress to speed up detection.
1471
+ *
1472
+ * @param deposit - Deposit submission details
1473
+ * @returns Updated quote response
1474
+ */
1475
+ submitDeposit(deposit: OneClickDepositSubmit): Promise<OneClickQuoteResponse>;
1476
+ /**
1477
+ * Get swap status
1478
+ *
1479
+ * @param depositAddress - Deposit address from quote
1480
+ * @param depositMemo - Optional memo for memo-based deposits
1481
+ * @returns Current swap status
1482
+ */
1483
+ getStatus(depositAddress: string, depositMemo?: string): Promise<OneClickStatusResponse>;
1484
+ /**
1485
+ * Poll status until terminal state or timeout
1486
+ *
1487
+ * @param depositAddress - Deposit address from quote
1488
+ * @param options - Polling options
1489
+ * @returns Final status when terminal state reached
1490
+ */
1491
+ waitForStatus(depositAddress: string, options?: {
1492
+ /** Polling interval in ms (default: 3000) */
1493
+ interval?: number;
1494
+ /** Maximum wait time in ms (default: 300000 = 5 minutes) */
1495
+ timeout?: number;
1496
+ /** Callback on each status check */
1497
+ onStatus?: (status: OneClickStatusResponse) => void;
1498
+ }): Promise<OneClickStatusResponse>;
1499
+ /**
1500
+ * Get withdrawals for ANY_INPUT deposits
1501
+ *
1502
+ * @param depositAddress - Deposit address
1503
+ * @param depositMemo - Optional deposit memo
1504
+ * @param options - Pagination options
1505
+ * @returns Array of withdrawals
1506
+ */
1507
+ getWithdrawals(depositAddress: string, depositMemo?: string, options?: {
1508
+ timestampFrom?: string;
1509
+ page?: number;
1510
+ limit?: number;
1511
+ sortOrder?: 'asc' | 'desc';
1512
+ }): Promise<OneClickWithdrawal[]>;
1513
+ private validateQuoteRequest;
1514
+ private get;
1515
+ private post;
1516
+ private request;
1517
+ private parseError;
1518
+ private mapErrorCode;
1519
+ private delay;
1520
+ }
1521
+
1522
+ /**
1523
+ * NEAR Intents Adapter for SIP Protocol
1524
+ *
1525
+ * Bridges SIP SDK with NEAR 1Click API, providing privacy-preserving
1526
+ * cross-chain swaps using stealth addresses.
1527
+ */
1528
+
1529
+ /**
1530
+ * Swap request parameters (simplified interface for adapter)
1531
+ */
1532
+ interface SwapRequest {
1533
+ /** Unique request ID */
1534
+ requestId: string;
1535
+ /** Privacy level for the swap */
1536
+ privacyLevel: PrivacyLevel;
1537
+ /** Input asset */
1538
+ inputAsset: Asset;
1539
+ /** Input amount in smallest units */
1540
+ inputAmount: bigint;
1541
+ /** Output asset */
1542
+ outputAsset: Asset;
1543
+ /** Minimum output amount */
1544
+ minOutputAmount?: bigint;
1545
+ }
1546
+ /**
1547
+ * Result of preparing a swap with SIP privacy
1548
+ */
1549
+ interface PreparedSwap {
1550
+ /** Original swap request */
1551
+ request: SwapRequest;
1552
+ /** 1Click quote request */
1553
+ quoteRequest: OneClickQuoteRequest;
1554
+ /** Generated stealth address (for shielded/compliant modes) */
1555
+ stealthAddress?: {
1556
+ address: HexString;
1557
+ ephemeralPublicKey: HexString;
1558
+ viewTag: number;
1559
+ };
1560
+ /** Shared secret for stealth address derivation (keep private!) */
1561
+ sharedSecret?: HexString;
1562
+ }
1563
+ /**
1564
+ * Result of executing a swap
1565
+ */
1566
+ interface SwapResult {
1567
+ /** Request ID */
1568
+ requestId: string;
1569
+ /** 1Click quote ID */
1570
+ quoteId: string;
1571
+ /** Deposit address for input tokens */
1572
+ depositAddress: string;
1573
+ /** Expected input amount */
1574
+ amountIn: string;
1575
+ /** Expected output amount */
1576
+ amountOut: string;
1577
+ /** Current status */
1578
+ status: OneClickSwapStatus;
1579
+ /** Deposit transaction hash (after deposit) */
1580
+ depositTxHash?: string;
1581
+ /** Settlement transaction hash (after success) */
1582
+ settlementTxHash?: string;
1583
+ /** Stealth address for recipient (if privacy mode) */
1584
+ stealthRecipient?: string;
1585
+ /** Ephemeral public key (for recipient to derive stealth key) */
1586
+ ephemeralPublicKey?: string;
1587
+ }
1588
+ /**
1589
+ * Configuration for NEAR Intents adapter
1590
+ */
1591
+ interface NEARIntentsAdapterConfig {
1592
+ /** OneClickClient instance or config */
1593
+ client?: OneClickClient;
1594
+ /** Base URL for 1Click API */
1595
+ baseUrl?: string;
1596
+ /** JWT token for authentication */
1597
+ jwtToken?: string;
1598
+ /** Default slippage tolerance in basis points (100 = 1%) */
1599
+ defaultSlippage?: number;
1600
+ /** Default deadline offset in seconds */
1601
+ defaultDeadlineOffset?: number;
1602
+ /** Custom asset mappings (merged with defaults) */
1603
+ assetMappings?: Record<string, DefuseAssetId>;
1604
+ }
1605
+ /**
1606
+ * NEAR Intents Adapter
1607
+ *
1608
+ * Provides privacy-preserving cross-chain swaps via NEAR 1Click API.
1609
+ *
1610
+ * @example
1611
+ * ```typescript
1612
+ * const adapter = new NEARIntentsAdapter({
1613
+ * jwtToken: process.env.NEAR_INTENTS_JWT,
1614
+ * })
1615
+ *
1616
+ * // Or with custom asset mappings (e.g., testnet)
1617
+ * const testnetAdapter = new NEARIntentsAdapter({
1618
+ * jwtToken: process.env.NEAR_INTENTS_JWT,
1619
+ * assetMappings: {
1620
+ * 'near:testUSDC': 'near:testnet:usdc.test',
1621
+ * },
1622
+ * })
1623
+ *
1624
+ * // Prepare a swap with stealth recipient
1625
+ * const prepared = await adapter.prepareSwap(intent, recipientMetaAddress)
1626
+ *
1627
+ * // Get quote
1628
+ * const quote = await adapter.getQuote(prepared)
1629
+ *
1630
+ * // Execute (after depositing to depositAddress)
1631
+ * const result = await adapter.trackSwap(quote.depositAddress)
1632
+ * ```
1633
+ */
1634
+ declare class NEARIntentsAdapter {
1635
+ private readonly client;
1636
+ private readonly defaultSlippage;
1637
+ private readonly defaultDeadlineOffset;
1638
+ private readonly assetMappings;
1639
+ constructor(config?: NEARIntentsAdapterConfig);
1640
+ /**
1641
+ * Get the underlying OneClick client
1642
+ */
1643
+ getClient(): OneClickClient;
1644
+ /**
1645
+ * Prepare a swap request
1646
+ *
1647
+ * For shielded/compliant modes, generates a stealth address for the recipient.
1648
+ *
1649
+ * @param request - Swap request parameters
1650
+ * @param recipientMetaAddress - Recipient's stealth meta-address (for privacy modes)
1651
+ * @param senderAddress - Sender's address for refunds
1652
+ * @returns Prepared swap with quote request
1653
+ */
1654
+ prepareSwap(request: SwapRequest, recipientMetaAddress?: StealthMetaAddress | string, senderAddress?: string): Promise<PreparedSwap>;
1655
+ /**
1656
+ * Get a quote for a prepared swap
1657
+ *
1658
+ * @param prepared - Prepared swap from prepareSwap()
1659
+ * @returns Quote response with deposit address
1660
+ */
1661
+ getQuote(prepared: PreparedSwap): Promise<OneClickQuoteResponse>;
1662
+ /**
1663
+ * Get a dry quote (preview without deposit address)
1664
+ *
1665
+ * @param prepared - Prepared swap
1666
+ * @returns Quote preview
1667
+ */
1668
+ getDryQuote(prepared: PreparedSwap): Promise<OneClickQuoteResponse>;
1669
+ /**
1670
+ * Notify 1Click of deposit transaction
1671
+ *
1672
+ * @param depositAddress - Deposit address from quote
1673
+ * @param txHash - Deposit transaction hash
1674
+ * @param nearAccount - NEAR account (if depositing from NEAR)
1675
+ */
1676
+ notifyDeposit(depositAddress: string, txHash: string, nearAccount?: string): Promise<void>;
1677
+ /**
1678
+ * Get current swap status
1679
+ *
1680
+ * @param depositAddress - Deposit address from quote
1681
+ * @returns Current status
1682
+ */
1683
+ getStatus(depositAddress: string): Promise<OneClickStatusResponse>;
1684
+ /**
1685
+ * Wait for swap to complete
1686
+ *
1687
+ * @param depositAddress - Deposit address from quote
1688
+ * @param options - Polling options
1689
+ * @returns Final status
1690
+ */
1691
+ waitForCompletion(depositAddress: string, options?: {
1692
+ interval?: number;
1693
+ timeout?: number;
1694
+ onStatus?: (status: OneClickStatusResponse) => void;
1695
+ }): Promise<OneClickStatusResponse>;
1696
+ /**
1697
+ * Execute a full swap flow
1698
+ *
1699
+ * This is a convenience method that:
1700
+ * 1. Prepares the swap with stealth address
1701
+ * 2. Gets a quote
1702
+ * 3. Returns all info needed for the user to deposit
1703
+ *
1704
+ * @param request - Swap request parameters
1705
+ * @param recipientMetaAddress - Recipient's stealth meta-address
1706
+ * @param senderAddress - Sender's address for refunds
1707
+ * @returns Swap result with deposit instructions
1708
+ */
1709
+ initiateSwap(request: SwapRequest, recipientMetaAddress?: StealthMetaAddress | string, senderAddress?: string): Promise<SwapResult>;
1710
+ /**
1711
+ * Convert SIP asset to Defuse asset identifier
1712
+ */
1713
+ mapAsset(chain: ChainId, symbol: string): DefuseAssetId;
1714
+ /**
1715
+ * Convert SIP chain ID to 1Click chain type
1716
+ */
1717
+ mapChainType(chain: ChainId): ChainType;
1718
+ private validateRequest;
1719
+ private buildQuoteRequest;
1720
+ }
1721
+ /**
1722
+ * Create a new NEAR Intents adapter
1723
+ */
1724
+ declare function createNEARIntentsAdapter(config?: NEARIntentsAdapterConfig): NEARIntentsAdapter;
1725
+
1726
+ /**
1727
+ * Mock Solver Implementation
1728
+ *
1729
+ * Reference implementation of the SIPSolver interface for testing
1730
+ * and development. Demonstrates how solvers should interact with
1731
+ * shielded intents while preserving privacy.
1732
+ */
1733
+
1734
+ /**
1735
+ * Configuration for MockSolver
1736
+ */
1737
+ interface MockSolverConfig {
1738
+ /** Solver name */
1739
+ name?: string;
1740
+ /** Supported chains */
1741
+ supportedChains?: ChainId[];
1742
+ /** Base fee percentage (0-1) */
1743
+ feePercent?: number;
1744
+ /** Simulated execution time in ms */
1745
+ executionDelay?: number;
1746
+ /** Failure rate for testing (0-1) */
1747
+ failureRate?: number;
1748
+ /** Quote spread percentage (0-1) */
1749
+ spreadPercent?: number;
1750
+ }
1751
+ /**
1752
+ * Mock implementation of SIPSolver for testing
1753
+ *
1754
+ * This solver demonstrates the privacy-preserving interaction pattern:
1755
+ * - Only accesses visible fields of intents
1756
+ * - Cannot see sender identity or exact input amounts
1757
+ * - Generates valid quotes based on output requirements
1758
+ *
1759
+ * @example
1760
+ * ```typescript
1761
+ * const solver = new MockSolver({ name: 'Test Solver' })
1762
+ *
1763
+ * // Check if solver can handle intent
1764
+ * if (await solver.canHandle(visibleIntent)) {
1765
+ * const quote = await solver.generateQuote(visibleIntent)
1766
+ * if (quote) {
1767
+ * const result = await solver.fulfill(intent, quote)
1768
+ * }
1769
+ * }
1770
+ * ```
1771
+ */
1772
+ declare class MockSolver implements SIPSolver {
1773
+ readonly info: Solver;
1774
+ readonly capabilities: SolverCapabilities;
1775
+ private readonly feePercent;
1776
+ private readonly executionDelay;
1777
+ private readonly failureRate;
1778
+ private readonly spreadPercent;
1779
+ private readonly pendingFulfillments;
1780
+ constructor(config?: MockSolverConfig);
1781
+ /**
1782
+ * Check if this solver can handle the given intent
1783
+ *
1784
+ * Privacy-preserving: Only accesses visible fields
1785
+ */
1786
+ canHandle(intent: SolverVisibleIntent): Promise<boolean>;
1787
+ /**
1788
+ * Generate a quote for the intent
1789
+ *
1790
+ * Privacy-preserving:
1791
+ * - Does NOT access sender identity (only senderCommitment visible)
1792
+ * - Does NOT know exact input amount (only inputCommitment visible)
1793
+ * - Quotes based solely on output requirements
1794
+ */
1795
+ generateQuote(intent: SolverVisibleIntent): Promise<SolverQuote | null>;
1796
+ /**
1797
+ * Fulfill an intent with the given quote
1798
+ *
1799
+ * In production, this would:
1800
+ * 1. Lock collateral
1801
+ * 2. Execute the swap on destination chain
1802
+ * 3. Generate fulfillment proof
1803
+ * 4. Release collateral after verification
1804
+ *
1805
+ * Privacy preserved:
1806
+ * - Funds go to stealth address (unlinkable)
1807
+ * - Solver never learns recipient's real identity
1808
+ */
1809
+ fulfill(intent: ShieldedIntent, quote: SolverQuote): Promise<FulfillmentResult>;
1810
+ /**
1811
+ * Cancel a pending fulfillment
1812
+ */
1813
+ cancel(intentId: string): Promise<boolean>;
1814
+ /**
1815
+ * Get fulfillment status
1816
+ */
1817
+ getStatus(intentId: string): Promise<FulfillmentStatus | null>;
1818
+ /**
1819
+ * Reset solver state (for testing)
1820
+ */
1821
+ reset(): void;
1822
+ private delay;
1823
+ }
1824
+ /**
1825
+ * Create a mock solver with default configuration
1826
+ */
1827
+ declare function createMockSolver(config?: MockSolverConfig): MockSolver;
1828
+
1829
+ /**
1830
+ * Zcash RPC Client
1831
+ *
1832
+ * HTTP client for interacting with zcashd node via JSON-RPC.
1833
+ * Supports both mainnet and testnet with automatic retry logic.
1834
+ *
1835
+ * @example
1836
+ * ```typescript
1837
+ * const client = new ZcashRPCClient({
1838
+ * username: 'rpcuser',
1839
+ * password: 'rpcpassword',
1840
+ * testnet: true,
1841
+ * })
1842
+ *
1843
+ * // Create new account and get address
1844
+ * const { account } = await client.createAccount()
1845
+ * const { address } = await client.getAddressForAccount(account)
1846
+ *
1847
+ * // Send shielded transaction
1848
+ * const opId = await client.sendShielded({
1849
+ * fromAddress: address,
1850
+ * recipients: [{ address: recipientAddr, amount: 0.1 }],
1851
+ * })
1852
+ *
1853
+ * // Wait for completion
1854
+ * const result = await client.waitForOperation(opId)
1855
+ * ```
1856
+ */
1857
+
1858
+ /**
1859
+ * Error thrown when Zcash RPC call fails
1860
+ */
1861
+ declare class ZcashRPCError extends Error {
1862
+ readonly code: number;
1863
+ readonly data?: unknown | undefined;
1864
+ constructor(message: string, code: number, data?: unknown | undefined);
1865
+ /**
1866
+ * Check if error is due to insufficient funds
1867
+ */
1868
+ isInsufficientFunds(): boolean;
1869
+ /**
1870
+ * Check if error is due to invalid address
1871
+ */
1872
+ isInvalidAddress(): boolean;
1873
+ /**
1874
+ * Check if error is due to wallet being locked
1875
+ */
1876
+ isWalletLocked(): boolean;
1877
+ }
1878
+ /**
1879
+ * Zcash RPC Client
1880
+ *
1881
+ * Provides type-safe access to zcashd JSON-RPC API with automatic
1882
+ * retry logic and proper error handling.
1883
+ *
1884
+ * @security IMPORTANT: Always use HTTPS in production environments.
1885
+ * This client uses HTTP Basic Authentication which transmits credentials
1886
+ * in base64-encoded cleartext. Without TLS/HTTPS, credentials and all
1887
+ * RPC data are vulnerable to network sniffing and man-in-the-middle attacks.
1888
+ *
1889
+ * Production configuration should use:
1890
+ * - HTTPS endpoint (e.g., https://your-node.com:8232)
1891
+ * - Valid TLS certificates
1892
+ * - Secure credential storage
1893
+ * - Network-level access controls
1894
+ */
1895
+ declare class ZcashRPCClient {
1896
+ private readonly config;
1897
+ private readonly baseUrl;
1898
+ private requestId;
1899
+ constructor(config: ZcashConfig);
1900
+ /**
1901
+ * Validate a Zcash address
1902
+ *
1903
+ * @param address - Address to validate (t-addr, z-addr, or unified)
1904
+ * @returns Address validation info
1905
+ */
1906
+ validateAddress(address: string): Promise<ZcashAddressInfo>;
1907
+ /**
1908
+ * Create a new HD account
1909
+ *
1910
+ * @returns New account number
1911
+ */
1912
+ createAccount(): Promise<ZcashNewAccount>;
1913
+ /**
1914
+ * Get or derive an address for an account
1915
+ *
1916
+ * @param account - Account number
1917
+ * @param receiverTypes - Optional receiver types (default: best shielded + p2pkh)
1918
+ * @param diversifierIndex - Optional specific diversifier index
1919
+ * @returns Account address info
1920
+ */
1921
+ getAddressForAccount(account: number, receiverTypes?: ZcashReceiverType[], diversifierIndex?: number): Promise<ZcashAccountAddress>;
1922
+ /**
1923
+ * Generate a new shielded address (DEPRECATED)
1924
+ *
1925
+ * @deprecated Use createAccount() and getAddressForAccount() instead
1926
+ * @param type - Address type ('sapling' or 'sprout')
1927
+ * @returns New shielded address
1928
+ */
1929
+ generateShieldedAddress(type?: 'sapling' | 'sprout'): Promise<string>;
1930
+ /**
1931
+ * List all shielded addresses in the wallet
1932
+ *
1933
+ * @returns Array of shielded addresses
1934
+ */
1935
+ listAddresses(): Promise<string[]>;
1936
+ /**
1937
+ * Get balance for an account
1938
+ *
1939
+ * @param account - Account number
1940
+ * @param minConf - Minimum confirmations (default: 1)
1941
+ * @returns Account balance by pool
1942
+ */
1943
+ getAccountBalance(account: number, minConf?: number): Promise<ZcashAccountBalance>;
1944
+ /**
1945
+ * Get balance for an address (DEPRECATED)
1946
+ *
1947
+ * @deprecated Use getAccountBalance() instead
1948
+ * @param address - Address to check
1949
+ * @param minConf - Minimum confirmations
1950
+ * @returns Balance in ZEC
1951
+ */
1952
+ getBalance(address: string, minConf?: number): Promise<number>;
1953
+ /**
1954
+ * Get total wallet balance
1955
+ *
1956
+ * @param minConf - Minimum confirmations
1957
+ * @returns Total balances (transparent, private, total)
1958
+ */
1959
+ getTotalBalance(minConf?: number): Promise<{
1960
+ transparent: string;
1961
+ private: string;
1962
+ total: string;
1963
+ }>;
1964
+ /**
1965
+ * List unspent shielded notes
1966
+ *
1967
+ * @param minConf - Minimum confirmations (default: 1)
1968
+ * @param maxConf - Maximum confirmations (default: 9999999)
1969
+ * @param includeWatchonly - Include watchonly addresses
1970
+ * @param addresses - Filter by addresses
1971
+ * @returns Array of unspent notes
1972
+ */
1973
+ listUnspent(minConf?: number, maxConf?: number, includeWatchonly?: boolean, addresses?: string[]): Promise<ZcashUnspentNote[]>;
1974
+ /**
1975
+ * Send a shielded transaction
1976
+ *
1977
+ * @param params - Send parameters
1978
+ * @returns Operation ID for tracking
1979
+ */
1980
+ sendShielded(params: ZcashShieldedSendParams): Promise<string>;
1981
+ /**
1982
+ * Shield coinbase UTXOs to a shielded address
1983
+ *
1984
+ * @param fromAddress - Transparent address with coinbase
1985
+ * @param toAddress - Shielded destination
1986
+ * @param fee - Optional fee
1987
+ * @param limit - Max UTXOs to shield
1988
+ * @returns Operation ID
1989
+ */
1990
+ shieldCoinbase(fromAddress: string, toAddress: string, fee?: number, limit?: number): Promise<{
1991
+ operationid: string;
1992
+ shieldingUTXOs: number;
1993
+ shieldingValue: number;
1994
+ }>;
1995
+ /**
1996
+ * Get status of async operations
1997
+ *
1998
+ * @param operationIds - Optional specific operation IDs
1999
+ * @returns Array of operation statuses
2000
+ */
2001
+ getOperationStatus(operationIds?: string[]): Promise<ZcashOperation[]>;
2002
+ /**
2003
+ * Get and remove completed operation results
2004
+ *
2005
+ * @param operationIds - Optional specific operation IDs
2006
+ * @returns Array of operation results
2007
+ */
2008
+ getOperationResult(operationIds?: string[]): Promise<ZcashOperation[]>;
2009
+ /**
2010
+ * List all operation IDs
2011
+ *
2012
+ * @param status - Optional filter by status
2013
+ * @returns Array of operation IDs
2014
+ */
2015
+ listOperationIds(status?: string): Promise<string[]>;
2016
+ /**
2017
+ * Wait for an operation to complete
2018
+ *
2019
+ * @param operationId - Operation ID to wait for
2020
+ * @param pollInterval - Poll interval in ms (default: 1000)
2021
+ * @param timeout - Max wait time in ms (default: 300000 = 5 min)
2022
+ * @returns Completed operation
2023
+ * @throws ZcashRPCError if operation fails or times out
2024
+ */
2025
+ waitForOperation(operationId: string, pollInterval?: number, timeout?: number): Promise<ZcashOperation>;
2026
+ /**
2027
+ * Get current block count
2028
+ *
2029
+ * @returns Current block height
2030
+ */
2031
+ getBlockCount(): Promise<number>;
2032
+ /**
2033
+ * Get block hash at height
2034
+ *
2035
+ * @param height - Block height
2036
+ * @returns Block hash
2037
+ */
2038
+ getBlockHash(height: number): Promise<string>;
2039
+ /**
2040
+ * Get block header
2041
+ *
2042
+ * @param hashOrHeight - Block hash or height
2043
+ * @returns Block header
2044
+ */
2045
+ getBlockHeader(hashOrHeight: string | number): Promise<ZcashBlockHeader>;
2046
+ /**
2047
+ * Get full block data
2048
+ *
2049
+ * @param hashOrHeight - Block hash or height
2050
+ * @returns Block data
2051
+ */
2052
+ getBlock(hashOrHeight: string | number): Promise<ZcashBlock>;
2053
+ /**
2054
+ * Get blockchain info
2055
+ *
2056
+ * @returns Blockchain information
2057
+ */
2058
+ getBlockchainInfo(): Promise<ZcashBlockchainInfo>;
2059
+ /**
2060
+ * Get network info
2061
+ *
2062
+ * @returns Network information
2063
+ */
2064
+ getNetworkInfo(): Promise<ZcashNetworkInfo>;
2065
+ /**
2066
+ * Export viewing key for address
2067
+ *
2068
+ * @param address - Shielded address
2069
+ * @returns Viewing key
2070
+ */
2071
+ exportViewingKey(address: string): Promise<string>;
2072
+ /**
2073
+ * Import viewing key
2074
+ *
2075
+ * @param viewingKey - The viewing key to import
2076
+ * @param rescan - Rescan the wallet (default: whenkeyisnew)
2077
+ * @param startHeight - Start height for rescan
2078
+ */
2079
+ importViewingKey(viewingKey: string, rescan?: 'yes' | 'no' | 'whenkeyisnew', startHeight?: number): Promise<void>;
2080
+ /**
2081
+ * Make a raw RPC call
2082
+ *
2083
+ * @param method - RPC method name
2084
+ * @param params - Method parameters
2085
+ * @returns RPC response result
2086
+ */
2087
+ call<T>(method: string, params?: unknown[]): Promise<T>;
2088
+ /**
2089
+ * Execute HTTP request to RPC endpoint
2090
+ */
2091
+ private executeRequest;
2092
+ private delay;
2093
+ /**
2094
+ * Check if client is configured for testnet
2095
+ */
2096
+ get isTestnet(): boolean;
2097
+ /**
2098
+ * Get the RPC endpoint URL
2099
+ */
2100
+ get endpoint(): string;
2101
+ }
2102
+ /**
2103
+ * Create a Zcash RPC client
2104
+ *
2105
+ * @param config - Client configuration
2106
+ * @returns ZcashRPCClient instance
2107
+ *
2108
+ * @security IMPORTANT: Always use HTTPS in production environments.
2109
+ * HTTP Basic Auth transmits credentials in cleartext without TLS/HTTPS.
2110
+ * Configure your zcashd node with TLS certificates and use https:// URLs.
2111
+ *
2112
+ * @example
2113
+ * ```typescript
2114
+ * // ✅ Production (HTTPS)
2115
+ * const client = createZcashClient({
2116
+ * host: 'https://your-node.com',
2117
+ * port: 8232,
2118
+ * username: process.env.ZCASH_RPC_USER,
2119
+ * password: process.env.ZCASH_RPC_PASS,
2120
+ * })
2121
+ *
2122
+ * // ⚠️ Development only (HTTP)
2123
+ * const testClient = createZcashClient({
2124
+ * host: '127.0.0.1',
2125
+ * port: 18232,
2126
+ * username: 'test',
2127
+ * password: 'test',
2128
+ * testnet: true,
2129
+ * })
2130
+ * ```
2131
+ */
2132
+ declare function createZcashClient(config: ZcashConfig): ZcashRPCClient;
2133
+
2134
+ /**
2135
+ * Zcash Shielded Transaction Service
2136
+ *
2137
+ * High-level service for managing Zcash shielded transactions,
2138
+ * providing integration with SIP Protocol privacy levels.
2139
+ *
2140
+ * @example
2141
+ * ```typescript
2142
+ * const service = new ZcashShieldedService({
2143
+ * rpcConfig: { username: 'user', password: 'pass', testnet: true },
2144
+ * })
2145
+ *
2146
+ * // Initialize and create account
2147
+ * await service.initialize()
2148
+ *
2149
+ * // Send shielded transaction
2150
+ * const result = await service.sendShielded({
2151
+ * to: recipientAddress,
2152
+ * amount: 1.5,
2153
+ * memo: 'Payment for services',
2154
+ * privacyLevel: PrivacyLevel.SHIELDED,
2155
+ * })
2156
+ *
2157
+ * // Check incoming transactions
2158
+ * const received = await service.getReceivedNotes()
2159
+ * ```
2160
+ */
2161
+
2162
+ /**
2163
+ * Configuration for ZcashShieldedService
2164
+ */
2165
+ interface ZcashShieldedServiceConfig {
2166
+ /** RPC client configuration */
2167
+ rpcConfig: ZcashConfig;
2168
+ /** Default account to use (default: 0) */
2169
+ defaultAccount?: number;
2170
+ /** Default minimum confirmations (default: 1) */
2171
+ defaultMinConf?: number;
2172
+ /** Poll interval for operations in ms (default: 1000) */
2173
+ operationPollInterval?: number;
2174
+ /** Operation timeout in ms (default: 300000 = 5 min) */
2175
+ operationTimeout?: number;
2176
+ }
2177
+ /**
2178
+ * Shielded send parameters
2179
+ */
2180
+ interface ShieldedSendParams {
2181
+ /** Recipient address (shielded or unified) */
2182
+ to: string;
2183
+ /** Amount in ZEC */
2184
+ amount: number;
2185
+ /** Optional memo (max 512 bytes) */
2186
+ memo?: string;
2187
+ /** SIP privacy level */
2188
+ privacyLevel?: PrivacyLevel;
2189
+ /** Source address (uses default if not specified) */
2190
+ from?: string;
2191
+ /** Minimum confirmations for inputs */
2192
+ minConf?: number;
2193
+ /** Custom fee (uses ZIP-317 default if not specified) */
2194
+ fee?: number;
2195
+ }
2196
+ /**
2197
+ * Result of a shielded send operation
2198
+ */
2199
+ interface ShieldedSendResult {
2200
+ /** Transaction ID */
2201
+ txid: string;
2202
+ /** Operation ID (for tracking) */
2203
+ operationId: string;
2204
+ /** Amount sent (excluding fee) */
2205
+ amount: number;
2206
+ /** Fee paid */
2207
+ fee: number;
2208
+ /** Recipient address */
2209
+ to: string;
2210
+ /** Sender address */
2211
+ from: string;
2212
+ /** Timestamp */
2213
+ timestamp: number;
2214
+ }
2215
+ /**
2216
+ * Received note information
2217
+ */
2218
+ interface ReceivedNote {
2219
+ /** Transaction ID */
2220
+ txid: string;
2221
+ /** Amount received */
2222
+ amount: number;
2223
+ /** Memo content (if any) */
2224
+ memo?: string;
2225
+ /** Number of confirmations */
2226
+ confirmations: number;
2227
+ /** Whether spendable */
2228
+ spendable: boolean;
2229
+ /** Pool type (sapling/orchard) */
2230
+ pool: 'sapling' | 'orchard';
2231
+ /** Receiving address */
2232
+ address: string;
2233
+ /** Whether this is change */
2234
+ isChange: boolean;
2235
+ }
2236
+ /**
2237
+ * Shielded balance summary
2238
+ */
2239
+ interface ShieldedBalance {
2240
+ /** Total confirmed balance in ZEC */
2241
+ confirmed: number;
2242
+ /** Total unconfirmed balance in ZEC */
2243
+ unconfirmed: number;
2244
+ /** Balance by pool */
2245
+ pools: {
2246
+ transparent: number;
2247
+ sapling: number;
2248
+ orchard: number;
2249
+ };
2250
+ /** Number of spendable notes */
2251
+ spendableNotes: number;
2252
+ }
2253
+ /**
2254
+ * Viewing key export result
2255
+ */
2256
+ interface ExportedViewingKey {
2257
+ /** The viewing key */
2258
+ key: string;
2259
+ /** Associated address */
2260
+ address: string;
2261
+ /** Account number */
2262
+ account: number;
2263
+ /** Creation timestamp */
2264
+ exportedAt: number;
2265
+ }
2266
+ /**
2267
+ * Zcash Shielded Transaction Service
2268
+ *
2269
+ * Provides high-level operations for Zcash shielded transactions
2270
+ * with SIP Protocol integration.
2271
+ */
2272
+ declare class ZcashShieldedService {
2273
+ private readonly client;
2274
+ private readonly config;
2275
+ private initialized;
2276
+ private accountAddress;
2277
+ private account;
2278
+ constructor(config: ZcashShieldedServiceConfig);
2279
+ /**
2280
+ * Initialize the service
2281
+ *
2282
+ * Creates an account if needed and retrieves the default address.
2283
+ */
2284
+ initialize(): Promise<void>;
2285
+ /**
2286
+ * Ensure the service is initialized
2287
+ */
2288
+ private ensureInitialized;
2289
+ /**
2290
+ * Get the default shielded address
2291
+ */
2292
+ getAddress(): string;
2293
+ /**
2294
+ * Generate a new diversified address for the account
2295
+ *
2296
+ * Each address is unlinkable but controlled by the same account.
2297
+ */
2298
+ generateNewAddress(): Promise<string>;
2299
+ /**
2300
+ * Validate an address
2301
+ */
2302
+ validateAddress(address: string): Promise<ZcashAddressInfo>;
2303
+ /**
2304
+ * Check if an address is a shielded address
2305
+ */
2306
+ isShieldedAddress(address: string): Promise<boolean>;
2307
+ /**
2308
+ * Get shielded balance summary
2309
+ */
2310
+ getBalance(minConf?: number): Promise<ShieldedBalance>;
2311
+ /**
2312
+ * Send a shielded transaction
2313
+ *
2314
+ * @param params - Send parameters
2315
+ * @returns Send result with txid
2316
+ */
2317
+ sendShielded(params: ShieldedSendParams): Promise<ShieldedSendResult>;
2318
+ /**
2319
+ * Send shielded transaction with SIP integration
2320
+ *
2321
+ * Higher-level method that handles privacy level mapping.
2322
+ */
2323
+ sendWithPrivacy(to: string, amount: number, privacyLevel: PrivacyLevel, memo?: string): Promise<ShieldedSendResult>;
2324
+ /**
2325
+ * Get received notes (incoming shielded transactions)
2326
+ *
2327
+ * @param minConf - Minimum confirmations
2328
+ * @param onlySpendable - Only return spendable notes
2329
+ */
2330
+ getReceivedNotes(minConf?: number, onlySpendable?: boolean): Promise<ReceivedNote[]>;
2331
+ /**
2332
+ * Get pending (unconfirmed) incoming transactions
2333
+ */
2334
+ getPendingNotes(): Promise<ReceivedNote[]>;
2335
+ /**
2336
+ * Wait for incoming note with specific criteria
2337
+ *
2338
+ * @param predicate - Function to match the expected note
2339
+ * @param timeout - Timeout in ms
2340
+ * @param pollInterval - Poll interval in ms
2341
+ */
2342
+ waitForNote(predicate: (note: ReceivedNote) => boolean, timeout?: number, pollInterval?: number): Promise<ReceivedNote>;
2343
+ /**
2344
+ * Export viewing key for an address
2345
+ *
2346
+ * The viewing key allows monitoring incoming transactions
2347
+ * without spending capability.
2348
+ */
2349
+ exportViewingKey(address?: string): Promise<ExportedViewingKey>;
2350
+ /**
2351
+ * Import viewing key for monitoring
2352
+ *
2353
+ * Allows monitoring transactions to an address without spending.
2354
+ */
2355
+ importViewingKey(viewingKey: string, rescan?: 'yes' | 'no' | 'whenkeyisnew', startHeight?: number): Promise<void>;
2356
+ /**
2357
+ * Export viewing key for compliance/audit
2358
+ *
2359
+ * Specifically for SIP COMPLIANT privacy level.
2360
+ */
2361
+ exportForCompliance(): Promise<{
2362
+ viewingKey: ExportedViewingKey;
2363
+ privacyLevel: PrivacyLevel;
2364
+ disclaimer: string;
2365
+ }>;
2366
+ /**
2367
+ * Get status of an operation
2368
+ */
2369
+ getOperationStatus(operationId: string): Promise<ZcashOperation | null>;
2370
+ /**
2371
+ * List all pending operations
2372
+ */
2373
+ listPendingOperations(): Promise<ZcashOperation[]>;
2374
+ /**
2375
+ * Get current block height
2376
+ */
2377
+ getBlockHeight(): Promise<number>;
2378
+ /**
2379
+ * Check if connected to testnet
2380
+ */
2381
+ isTestnet(): boolean;
2382
+ /**
2383
+ * Map SIP privacy level to Zcash privacy policy
2384
+ */
2385
+ private mapPrivacyLevelToPolicy;
2386
+ /**
2387
+ * Map RPC unspent note to ReceivedNote
2388
+ */
2389
+ private mapNoteToReceived;
2390
+ private delay;
2391
+ /**
2392
+ * Get underlying RPC client for advanced operations
2393
+ */
2394
+ get rpcClient(): ZcashRPCClient;
2395
+ /**
2396
+ * Get current account number
2397
+ */
2398
+ get currentAccount(): number;
2399
+ }
2400
+ /**
2401
+ * Create a Zcash shielded service instance
2402
+ */
2403
+ declare function createZcashShieldedService(config: ZcashShieldedServiceConfig): ZcashShieldedService;
2404
+
2405
+ /**
2406
+ * Base Wallet Adapter
2407
+ *
2408
+ * Abstract base class that provides common functionality for wallet adapters.
2409
+ * Chain-specific implementations extend this class.
2410
+ */
2411
+
2412
+ /**
2413
+ * Abstract base class for wallet adapters
2414
+ *
2415
+ * Provides:
2416
+ * - Event emitter infrastructure
2417
+ * - Connection state management
2418
+ * - Common validation logic
2419
+ *
2420
+ * Subclasses must implement:
2421
+ * - connect() / disconnect()
2422
+ * - signMessage() / signTransaction() / signAndSendTransaction()
2423
+ * - getBalance() / getTokenBalance()
2424
+ *
2425
+ * @example
2426
+ * ```typescript
2427
+ * class MyWalletAdapter extends BaseWalletAdapter {
2428
+ * readonly chain = 'solana'
2429
+ * readonly name = 'my-wallet'
2430
+ *
2431
+ * async connect(): Promise<void> {
2432
+ * // Implementation
2433
+ * }
2434
+ *
2435
+ * // ... other required methods
2436
+ * }
2437
+ * ```
2438
+ */
2439
+ declare abstract class BaseWalletAdapter implements WalletAdapter$1 {
2440
+ abstract readonly chain: ChainId;
2441
+ abstract readonly name: string;
2442
+ protected _address: string;
2443
+ protected _publicKey: HexString | '';
2444
+ protected _connectionState: WalletConnectionState;
2445
+ get address(): string;
2446
+ get publicKey(): HexString | '';
2447
+ get connectionState(): WalletConnectionState;
2448
+ private eventHandlers;
2449
+ /**
2450
+ * Subscribe to wallet events
2451
+ */
2452
+ on<T extends WalletEventType>(event: T, handler: WalletEventHandler<Extract<WalletEvent, {
2453
+ type: T;
2454
+ }>>): void;
2455
+ /**
2456
+ * Unsubscribe from wallet events
2457
+ */
2458
+ off<T extends WalletEventType>(event: T, handler: WalletEventHandler<Extract<WalletEvent, {
2459
+ type: T;
2460
+ }>>): void;
2461
+ /**
2462
+ * Emit a wallet event
2463
+ */
2464
+ protected emit<T extends WalletEvent>(event: T): void;
2465
+ /**
2466
+ * Emit a connect event
2467
+ */
2468
+ protected emitConnect(address: string, chain: ChainId): void;
2469
+ /**
2470
+ * Emit a disconnect event
2471
+ */
2472
+ protected emitDisconnect(reason?: string): void;
2473
+ /**
2474
+ * Emit an account changed event
2475
+ */
2476
+ protected emitAccountChanged(previousAddress: string, newAddress: string): void;
2477
+ /**
2478
+ * Emit a chain changed event
2479
+ */
2480
+ protected emitChainChanged(previousChain: ChainId, newChain: ChainId): void;
2481
+ /**
2482
+ * Emit an error event
2483
+ */
2484
+ protected emitError(code: string, message: string, details?: unknown): void;
2485
+ /**
2486
+ * Check if wallet is connected
2487
+ */
2488
+ isConnected(): boolean;
2489
+ /**
2490
+ * Ensure wallet is connected, throw if not
2491
+ */
2492
+ protected requireConnected(): void;
2493
+ /**
2494
+ * Set connection state and emit events
2495
+ */
2496
+ protected setConnected(address: string, publicKey: HexString): void;
2497
+ /**
2498
+ * Set disconnected state and emit events
2499
+ */
2500
+ protected setDisconnected(reason?: string): void;
2501
+ /**
2502
+ * Set error state and emit events
2503
+ */
2504
+ protected setError(code: string, message: string, details?: unknown): void;
2505
+ abstract connect(): Promise<void>;
2506
+ abstract disconnect(): Promise<void>;
2507
+ abstract signMessage(message: Uint8Array): Promise<Signature>;
2508
+ abstract signTransaction(tx: UnsignedTransaction): Promise<SignedTransaction>;
2509
+ abstract signAndSendTransaction(tx: UnsignedTransaction): Promise<TransactionReceipt>;
2510
+ abstract getBalance(): Promise<bigint>;
2511
+ abstract getTokenBalance(asset: Asset): Promise<bigint>;
2512
+ }
2513
+ /**
2514
+ * Mock wallet adapter for testing
2515
+ *
2516
+ * Provides a complete wallet implementation with mock data.
2517
+ * Useful for testing and development without real wallet connections.
2518
+ *
2519
+ * @example
2520
+ * ```typescript
2521
+ * const mockWallet = new MockWalletAdapter({
2522
+ * chain: 'solana',
2523
+ * address: 'SoLaNaAddReSS...',
2524
+ * balance: 1000000000n, // 1 SOL
2525
+ * })
2526
+ *
2527
+ * await mockWallet.connect()
2528
+ * const balance = await mockWallet.getBalance()
2529
+ * ```
2530
+ */
2531
+ declare class MockWalletAdapter extends BaseWalletAdapter {
2532
+ readonly chain: ChainId;
2533
+ readonly name: string;
2534
+ private mockAddress;
2535
+ private mockPublicKey;
2536
+ private mockBalance;
2537
+ private mockTokenBalances;
2538
+ private shouldFailConnect;
2539
+ private shouldFailSign;
2540
+ constructor(options: {
2541
+ chain: ChainId;
2542
+ address?: string;
2543
+ publicKey?: HexString;
2544
+ balance?: bigint;
2545
+ tokenBalances?: Record<string, bigint>;
2546
+ name?: string;
2547
+ shouldFailConnect?: boolean;
2548
+ shouldFailSign?: boolean;
2549
+ });
2550
+ connect(): Promise<void>;
2551
+ disconnect(): Promise<void>;
2552
+ signMessage(message: Uint8Array): Promise<Signature>;
2553
+ signTransaction(tx: UnsignedTransaction): Promise<SignedTransaction>;
2554
+ signAndSendTransaction(tx: UnsignedTransaction): Promise<TransactionReceipt>;
2555
+ getBalance(): Promise<bigint>;
2556
+ getTokenBalance(asset: Asset): Promise<bigint>;
2557
+ /**
2558
+ * Set mock balance (for testing)
2559
+ */
2560
+ setMockBalance(balance: bigint): void;
2561
+ /**
2562
+ * Set mock token balance (for testing)
2563
+ */
2564
+ setMockTokenBalance(asset: Asset, balance: bigint): void;
2565
+ /**
2566
+ * Simulate account change (for testing)
2567
+ */
2568
+ simulateAccountChange(newAddress: string): void;
2569
+ }
2570
+
2571
+ /**
2572
+ * Wallet-specific errors for SIP SDK
2573
+ */
2574
+
2575
+ /**
2576
+ * Error thrown by wallet adapters
2577
+ */
2578
+ declare class WalletError extends SIPError {
2579
+ readonly walletCode: WalletErrorCodeType;
2580
+ constructor(message: string, walletCode?: WalletErrorCodeType, options?: {
2581
+ cause?: Error;
2582
+ context?: Record<string, unknown>;
2583
+ });
2584
+ /**
2585
+ * Check if this is a connection-related error
2586
+ */
2587
+ isConnectionError(): boolean;
2588
+ /**
2589
+ * Check if this is a signing-related error
2590
+ */
2591
+ isSigningError(): boolean;
2592
+ /**
2593
+ * Check if this is a transaction-related error
2594
+ */
2595
+ isTransactionError(): boolean;
2596
+ /**
2597
+ * Check if this is a privacy-related error
2598
+ */
2599
+ isPrivacyError(): boolean;
2600
+ /**
2601
+ * Check if this error was caused by user rejection
2602
+ */
2603
+ isUserRejection(): boolean;
2604
+ }
2605
+ /**
2606
+ * Create a WalletError for not connected state
2607
+ */
2608
+ declare function notConnectedError(): WalletError;
2609
+ /**
2610
+ * Create a WalletError for feature not supported
2611
+ */
2612
+ declare function featureNotSupportedError(feature: string, code?: WalletErrorCodeType): WalletError;
2613
+
2614
+ /**
2615
+ * Wallet Registry
2616
+ *
2617
+ * Manages wallet adapter registration and discovery.
2618
+ * Allows applications to register and detect available wallets.
2619
+ */
2620
+
2621
+ /**
2622
+ * Global wallet registry
2623
+ *
2624
+ * Manages available wallet adapters and provides discovery functionality.
2625
+ *
2626
+ * @example
2627
+ * ```typescript
2628
+ * // Register a wallet adapter
2629
+ * walletRegistry.register({
2630
+ * info: {
2631
+ * id: 'phantom',
2632
+ * name: 'Phantom',
2633
+ * chains: ['solana'],
2634
+ * supportsPrivacy: false,
2635
+ * },
2636
+ * factory: () => new PhantomWalletAdapter(),
2637
+ * detect: () => typeof window !== 'undefined' && 'phantom' in window,
2638
+ * })
2639
+ *
2640
+ * // Get available wallets for a chain
2641
+ * const solanaWallets = walletRegistry.getAvailableWallets('solana')
2642
+ *
2643
+ * // Create a wallet adapter
2644
+ * const wallet = walletRegistry.create('phantom')
2645
+ * ```
2646
+ */
2647
+ declare class WalletRegistry {
2648
+ private entries;
2649
+ /**
2650
+ * Register a wallet adapter
2651
+ *
2652
+ * @param entry - The wallet registry entry
2653
+ */
2654
+ register(entry: WalletRegistryEntry): void;
2655
+ /**
2656
+ * Unregister a wallet adapter
2657
+ *
2658
+ * @param id - The wallet identifier
2659
+ */
2660
+ unregister(id: string): void;
2661
+ /**
2662
+ * Get wallet info by ID
2663
+ *
2664
+ * @param id - The wallet identifier
2665
+ * @returns The wallet info or undefined
2666
+ */
2667
+ getInfo(id: string): WalletInfo | undefined;
2668
+ /**
2669
+ * Get all registered wallet infos
2670
+ *
2671
+ * @returns Array of all wallet infos
2672
+ */
2673
+ getAllWallets(): WalletInfo[];
2674
+ /**
2675
+ * Get wallets that support a specific chain
2676
+ *
2677
+ * @param chain - The chain to filter by
2678
+ * @returns Array of wallet infos that support the chain
2679
+ */
2680
+ getWalletsForChain(chain: ChainId): WalletInfo[];
2681
+ /**
2682
+ * Get available (detected) wallets
2683
+ *
2684
+ * @param chain - Optional chain to filter by
2685
+ * @returns Array of wallet infos for detected wallets
2686
+ */
2687
+ getAvailableWallets(chain?: ChainId): WalletInfo[];
2688
+ /**
2689
+ * Get wallets that support privacy features
2690
+ *
2691
+ * @param chain - Optional chain to filter by
2692
+ * @returns Array of wallet infos with privacy support
2693
+ */
2694
+ getPrivacyWallets(chain?: ChainId): WalletInfo[];
2695
+ /**
2696
+ * Check if a wallet is available (detected)
2697
+ *
2698
+ * @param id - The wallet identifier
2699
+ * @returns True if wallet is detected
2700
+ */
2701
+ isAvailable(id: string): boolean;
2702
+ /**
2703
+ * Create a wallet adapter instance
2704
+ *
2705
+ * @param id - The wallet identifier
2706
+ * @returns A new wallet adapter instance
2707
+ * @throws If wallet is not registered
2708
+ */
2709
+ create(id: string): WalletAdapter$1 | PrivateWalletAdapter;
2710
+ /**
2711
+ * Create and connect a wallet adapter
2712
+ *
2713
+ * @param id - The wallet identifier
2714
+ * @returns A connected wallet adapter
2715
+ * @throws If wallet is not registered or connection fails
2716
+ */
2717
+ connect(id: string): Promise<WalletAdapter$1 | PrivateWalletAdapter>;
2718
+ /**
2719
+ * Clear all registered wallets
2720
+ */
2721
+ clear(): void;
2722
+ }
2723
+ /**
2724
+ * Global wallet registry instance
2725
+ */
2726
+ declare const walletRegistry: WalletRegistry;
2727
+ /**
2728
+ * Helper to register a wallet adapter
2729
+ */
2730
+ declare function registerWallet(entry: WalletRegistryEntry): void;
2731
+ /**
2732
+ * Helper to create a wallet adapter factory
2733
+ */
2734
+ declare function createWalletFactory<T extends WalletAdapter$1 | PrivateWalletAdapter>(AdapterClass: new () => T): WalletAdapterFactory;
2735
+ /**
2736
+ * Check if an adapter is a PrivateWalletAdapter
2737
+ */
2738
+ declare function isPrivateWalletAdapter(adapter: WalletAdapter$1 | PrivateWalletAdapter): adapter is PrivateWalletAdapter;
2739
+
2740
+ /**
2741
+ * Solana Wallet Types
2742
+ *
2743
+ * Type definitions for Solana wallet integration.
2744
+ * These types match the interface of injected Solana wallet providers
2745
+ * like Phantom, Solflare, and Backpack.
2746
+ */
2747
+
2748
+ /**
2749
+ * Solana public key interface
2750
+ * Matches @solana/web3.js PublicKey
2751
+ */
2752
+ interface SolanaPublicKey {
2753
+ toBase58(): string;
2754
+ toBytes(): Uint8Array;
2755
+ toString(): string;
2756
+ }
2757
+ /**
2758
+ * Solana transaction interface
2759
+ * Matches @solana/web3.js Transaction
2760
+ */
2761
+ interface SolanaTransaction {
2762
+ /** Transaction signature after signing */
2763
+ signature?: Uint8Array;
2764
+ /** Serialized transaction */
2765
+ serialize(): Uint8Array;
2766
+ /** Add signature to transaction */
2767
+ addSignature(pubkey: SolanaPublicKey, signature: Uint8Array): void;
2768
+ }
2769
+ /**
2770
+ * Solana versioned transaction (v0)
2771
+ * Matches @solana/web3.js VersionedTransaction
2772
+ */
2773
+ interface SolanaVersionedTransaction {
2774
+ serialize(): Uint8Array;
2775
+ signatures: Uint8Array[];
2776
+ }
2777
+ /**
2778
+ * Solana send options
2779
+ */
2780
+ interface SolanaSendOptions {
2781
+ /** Skip preflight transaction checks */
2782
+ skipPreflight?: boolean;
2783
+ /** Preflight commitment level */
2784
+ preflightCommitment?: 'processed' | 'confirmed' | 'finalized';
2785
+ /** Maximum retries */
2786
+ maxRetries?: number;
2787
+ }
2788
+ /**
2789
+ * Solana connection interface for RPC calls
2790
+ */
2791
+ interface SolanaConnection {
2792
+ /** Get account balance in lamports */
2793
+ getBalance(publicKey: SolanaPublicKey): Promise<number>;
2794
+ /** Get token account balance */
2795
+ getTokenAccountBalance(publicKey: SolanaPublicKey): Promise<{
2796
+ value: {
2797
+ amount: string;
2798
+ decimals: number;
2799
+ };
2800
+ }>;
2801
+ /** Get latest blockhash */
2802
+ getLatestBlockhash(): Promise<{
2803
+ blockhash: string;
2804
+ lastValidBlockHeight: number;
2805
+ }>;
2806
+ /** Send raw transaction */
2807
+ sendRawTransaction(rawTransaction: Uint8Array, options?: SolanaSendOptions): Promise<string>;
2808
+ /** Confirm transaction */
2809
+ confirmTransaction(signature: string, commitment?: 'processed' | 'confirmed' | 'finalized'): Promise<{
2810
+ value: {
2811
+ err: unknown;
2812
+ };
2813
+ }>;
2814
+ }
2815
+ /**
2816
+ * Injected Solana wallet provider interface
2817
+ * This is what Phantom/Solflare/etc inject into window
2818
+ */
2819
+ interface SolanaWalletProvider {
2820
+ /** Provider is Phantom */
2821
+ isPhantom?: boolean;
2822
+ /** Provider is Solflare */
2823
+ isSolflare?: boolean;
2824
+ /** Provider is Backpack */
2825
+ isBackpack?: boolean;
2826
+ /** Public key when connected */
2827
+ publicKey: SolanaPublicKey | null;
2828
+ /** Whether wallet is connected */
2829
+ isConnected: boolean;
2830
+ /** Connect to wallet */
2831
+ connect(options?: {
2832
+ onlyIfTrusted?: boolean;
2833
+ }): Promise<{
2834
+ publicKey: SolanaPublicKey;
2835
+ }>;
2836
+ /** Disconnect from wallet */
2837
+ disconnect(): Promise<void>;
2838
+ /** Sign a message */
2839
+ signMessage(message: Uint8Array, encoding?: 'utf8'): Promise<{
2840
+ signature: Uint8Array;
2841
+ }>;
2842
+ /** Sign a transaction */
2843
+ signTransaction<T extends SolanaTransaction | SolanaVersionedTransaction>(transaction: T): Promise<T>;
2844
+ /** Sign multiple transactions */
2845
+ signAllTransactions<T extends SolanaTransaction | SolanaVersionedTransaction>(transactions: T[]): Promise<T[]>;
2846
+ /** Sign and send transaction */
2847
+ signAndSendTransaction<T extends SolanaTransaction | SolanaVersionedTransaction>(transaction: T, options?: SolanaSendOptions): Promise<{
2848
+ signature: string;
2849
+ }>;
2850
+ /** Event handling */
2851
+ on(event: 'connect' | 'disconnect' | 'accountChanged', handler: (...args: unknown[]) => void): void;
2852
+ off(event: 'connect' | 'disconnect' | 'accountChanged', handler: (...args: unknown[]) => void): void;
2853
+ }
2854
+ /**
2855
+ * Solana wallet name/type
2856
+ */
2857
+ type SolanaWalletName = 'phantom' | 'solflare' | 'backpack' | 'generic';
2858
+ /**
2859
+ * Solana network/cluster
2860
+ */
2861
+ type SolanaCluster = 'mainnet-beta' | 'testnet' | 'devnet' | 'localnet';
2862
+ /**
2863
+ * Solana adapter configuration
2864
+ */
2865
+ interface SolanaAdapterConfig {
2866
+ /** Wallet to connect to */
2867
+ wallet?: SolanaWalletName;
2868
+ /** Solana cluster/network */
2869
+ cluster?: SolanaCluster;
2870
+ /** RPC endpoint URL */
2871
+ rpcEndpoint?: string;
2872
+ /** Custom wallet provider (for testing) */
2873
+ provider?: SolanaWalletProvider;
2874
+ /** Custom connection (for testing) */
2875
+ connection?: SolanaConnection;
2876
+ }
2877
+ /**
2878
+ * Solana-specific unsigned transaction
2879
+ */
2880
+ interface SolanaUnsignedTransaction {
2881
+ /** The Solana transaction object */
2882
+ transaction: SolanaTransaction | SolanaVersionedTransaction;
2883
+ /** Whether this is a versioned transaction */
2884
+ isVersioned?: boolean;
2885
+ /** Send options */
2886
+ sendOptions?: SolanaSendOptions;
2887
+ }
2888
+ /**
2889
+ * Extended signature with Solana-specific data
2890
+ */
2891
+ interface SolanaSignature {
2892
+ /** Raw signature bytes */
2893
+ signature: HexString;
2894
+ /** Solana public key (base58) */
2895
+ publicKey: HexString;
2896
+ /** Base58 encoded signature (Solana standard) */
2897
+ base58Signature?: string;
2898
+ }
2899
+ /**
2900
+ * Get the injected Solana wallet provider
2901
+ */
2902
+ declare function getSolanaProvider(wallet?: SolanaWalletName): SolanaWalletProvider | undefined;
2903
+ /**
2904
+ * Detect which Solana wallets are installed
2905
+ */
2906
+ declare function detectSolanaWallets(): SolanaWalletName[];
2907
+ /**
2908
+ * Convert Solana public key to hex string
2909
+ */
2910
+ declare function solanaPublicKeyToHex(pubkey: SolanaPublicKey): HexString;
2911
+ /**
2912
+ * Convert base58 string to hex
2913
+ */
2914
+ declare function base58ToHex(base58: string): HexString;
2915
+
2916
+ /**
2917
+ * Solana Wallet Adapter
2918
+ *
2919
+ * Implementation of WalletAdapter for Solana chain.
2920
+ * Supports Phantom, Solflare, Backpack, and generic Solana wallets.
2921
+ */
2922
+
2923
+ /**
2924
+ * Solana wallet adapter
2925
+ *
2926
+ * Provides SIP-compatible wallet interface for Solana.
2927
+ * Works with Phantom, Solflare, Backpack, and other Solana wallets.
2928
+ *
2929
+ * @example Browser usage with Phantom
2930
+ * ```typescript
2931
+ * const wallet = new SolanaWalletAdapter({ wallet: 'phantom' })
2932
+ * await wallet.connect()
2933
+ *
2934
+ * const balance = await wallet.getBalance()
2935
+ * console.log(`Balance: ${balance} lamports`)
2936
+ *
2937
+ * // Sign a message
2938
+ * const sig = await wallet.signMessage(new TextEncoder().encode('Hello'))
2939
+ * ```
2940
+ *
2941
+ * @example With custom RPC endpoint
2942
+ * ```typescript
2943
+ * const wallet = new SolanaWalletAdapter({
2944
+ * wallet: 'phantom',
2945
+ * cluster: 'devnet',
2946
+ * rpcEndpoint: 'https://my-rpc.example.com',
2947
+ * })
2948
+ * ```
2949
+ */
2950
+ declare class SolanaWalletAdapter extends BaseWalletAdapter {
2951
+ readonly chain: "solana";
2952
+ readonly name: string;
2953
+ private provider;
2954
+ private connection;
2955
+ private walletName;
2956
+ private cluster;
2957
+ private rpcEndpoint;
2958
+ private connectHandler?;
2959
+ private disconnectHandler?;
2960
+ private accountChangedHandler?;
2961
+ constructor(config?: SolanaAdapterConfig);
2962
+ /**
2963
+ * Get the current Solana cluster
2964
+ */
2965
+ getCluster(): SolanaCluster;
2966
+ /**
2967
+ * Get the RPC endpoint
2968
+ */
2969
+ getRpcEndpoint(): string;
2970
+ /**
2971
+ * Set the RPC endpoint
2972
+ */
2973
+ setRpcEndpoint(endpoint: string): void;
2974
+ /**
2975
+ * Get or create a connection for RPC calls
2976
+ */
2977
+ private getConnection;
2978
+ /**
2979
+ * Connect to the wallet
2980
+ */
2981
+ connect(): Promise<void>;
2982
+ /**
2983
+ * Disconnect from the wallet
2984
+ */
2985
+ disconnect(): Promise<void>;
2986
+ /**
2987
+ * Sign a message
2988
+ */
2989
+ signMessage(message: Uint8Array): Promise<Signature>;
2990
+ /**
2991
+ * Sign a transaction
2992
+ *
2993
+ * The transaction data should be a SolanaTransaction or SolanaVersionedTransaction
2994
+ */
2995
+ signTransaction(tx: UnsignedTransaction): Promise<SignedTransaction>;
2996
+ /**
2997
+ * Sign and send a transaction
2998
+ */
2999
+ signAndSendTransaction(tx: UnsignedTransaction): Promise<TransactionReceipt>;
3000
+ /**
3001
+ * Sign multiple transactions at once
3002
+ *
3003
+ * Solana-specific method for batch signing
3004
+ */
3005
+ signAllTransactions<T extends SolanaTransaction | SolanaVersionedTransaction>(transactions: T[]): Promise<T[]>;
3006
+ /**
3007
+ * Get native SOL balance
3008
+ */
3009
+ getBalance(): Promise<bigint>;
3010
+ /**
3011
+ * Get SPL token balance
3012
+ */
3013
+ getTokenBalance(asset: Asset): Promise<bigint>;
3014
+ /**
3015
+ * Set up wallet event handlers
3016
+ */
3017
+ private setupEventHandlers;
3018
+ /**
3019
+ * Clean up wallet event handlers
3020
+ */
3021
+ private cleanupEventHandlers;
3022
+ }
3023
+ /**
3024
+ * Create a Solana wallet adapter with default configuration
3025
+ */
3026
+ declare function createSolanaAdapter(config?: SolanaAdapterConfig): SolanaWalletAdapter;
3027
+
3028
+ /**
3029
+ * Mock Solana Wallet Adapter
3030
+ *
3031
+ * Testing implementation of Solana wallet adapter.
3032
+ * Provides full mock functionality without requiring browser environment.
3033
+ */
3034
+
3035
+ /**
3036
+ * Configuration for mock Solana adapter
3037
+ */
3038
+ interface MockSolanaAdapterConfig {
3039
+ /** Mock address (base58) */
3040
+ address?: string;
3041
+ /** Mock balance in lamports */
3042
+ balance?: bigint;
3043
+ /** Token balances by mint address */
3044
+ tokenBalances?: Record<string, bigint>;
3045
+ /** Whether to simulate connection failure */
3046
+ shouldFailConnect?: boolean;
3047
+ /** Whether to simulate signing failure */
3048
+ shouldFailSign?: boolean;
3049
+ /** Whether to simulate transaction failure */
3050
+ shouldFailTransaction?: boolean;
3051
+ /** Simulated cluster */
3052
+ cluster?: SolanaCluster;
3053
+ /** Simulated latency in ms */
3054
+ latency?: number;
3055
+ }
3056
+ /**
3057
+ * Mock Solana wallet adapter for testing
3058
+ *
3059
+ * Provides full Solana wallet functionality with mock data.
3060
+ * No browser environment or actual wallet required.
3061
+ *
3062
+ * @example
3063
+ * ```typescript
3064
+ * const wallet = new MockSolanaAdapter({
3065
+ * address: 'TestWalletAddress123',
3066
+ * balance: 5_000_000_000n, // 5 SOL
3067
+ * })
3068
+ *
3069
+ * await wallet.connect()
3070
+ * const balance = await wallet.getBalance() // 5_000_000_000n
3071
+ *
3072
+ * // Simulate failures
3073
+ * const failingWallet = new MockSolanaAdapter({
3074
+ * shouldFailSign: true,
3075
+ * })
3076
+ * ```
3077
+ */
3078
+ declare class MockSolanaAdapter extends BaseWalletAdapter {
3079
+ readonly chain: "solana";
3080
+ readonly name = "mock-solana";
3081
+ private mockAddress;
3082
+ private mockPublicKey;
3083
+ private mockBalance;
3084
+ private mockTokenBalances;
3085
+ private shouldFailConnect;
3086
+ private shouldFailSign;
3087
+ private shouldFailTransaction;
3088
+ private cluster;
3089
+ private latency;
3090
+ private signedTransactions;
3091
+ private sentTransactions;
3092
+ constructor(config?: MockSolanaAdapterConfig);
3093
+ /**
3094
+ * Get the current Solana cluster
3095
+ */
3096
+ getCluster(): SolanaCluster;
3097
+ /**
3098
+ * Connect to the mock wallet
3099
+ */
3100
+ connect(): Promise<void>;
3101
+ /**
3102
+ * Disconnect from the mock wallet
3103
+ */
3104
+ disconnect(): Promise<void>;
3105
+ /**
3106
+ * Sign a message
3107
+ */
3108
+ signMessage(message: Uint8Array): Promise<Signature>;
3109
+ /**
3110
+ * Sign a transaction
3111
+ */
3112
+ signTransaction(tx: UnsignedTransaction): Promise<SignedTransaction>;
3113
+ /**
3114
+ * Sign and send a transaction
3115
+ */
3116
+ signAndSendTransaction(tx: UnsignedTransaction): Promise<TransactionReceipt>;
3117
+ /**
3118
+ * Sign multiple transactions
3119
+ */
3120
+ signAllTransactions<T extends SolanaTransaction | SolanaVersionedTransaction>(transactions: T[]): Promise<T[]>;
3121
+ /**
3122
+ * Get SOL balance
3123
+ */
3124
+ getBalance(): Promise<bigint>;
3125
+ /**
3126
+ * Get token balance
3127
+ */
3128
+ getTokenBalance(asset: Asset): Promise<bigint>;
3129
+ /**
3130
+ * Set mock balance
3131
+ */
3132
+ setMockBalance(balance: bigint): void;
3133
+ /**
3134
+ * Set mock token balance
3135
+ */
3136
+ setMockTokenBalance(mintAddress: string, balance: bigint): void;
3137
+ /**
3138
+ * Get all signed transactions (for verification)
3139
+ */
3140
+ getSignedTransactions(): Array<SolanaTransaction | SolanaVersionedTransaction>;
3141
+ /**
3142
+ * Get all sent transaction signatures (for verification)
3143
+ */
3144
+ getSentTransactions(): string[];
3145
+ /**
3146
+ * Clear transaction history
3147
+ */
3148
+ clearTransactionHistory(): void;
3149
+ /**
3150
+ * Simulate an account change event
3151
+ */
3152
+ simulateAccountChange(newAddress: string): void;
3153
+ /**
3154
+ * Simulate a disconnect event
3155
+ */
3156
+ simulateDisconnect(): void;
3157
+ private simulateLatency;
3158
+ }
3159
+ /**
3160
+ * Create a mock Solana wallet provider for testing real adapter
3161
+ */
3162
+ declare function createMockSolanaProvider(config?: MockSolanaAdapterConfig): SolanaWalletProvider;
3163
+ /**
3164
+ * Create a mock Solana connection for testing
3165
+ */
3166
+ declare function createMockSolanaConnection(config?: MockSolanaAdapterConfig): SolanaConnection;
3167
+ /**
3168
+ * Create a mock Solana adapter
3169
+ */
3170
+ declare function createMockSolanaAdapter(config?: MockSolanaAdapterConfig): MockSolanaAdapter;
3171
+
3172
+ /**
3173
+ * Ethereum Wallet Types
3174
+ *
3175
+ * Type definitions for Ethereum wallet integration.
3176
+ * Follows EIP-1193 (Provider API) and EIP-712 (Typed Data Signing).
3177
+ */
3178
+
3179
+ /**
3180
+ * EIP-1193 Provider interface
3181
+ * Standard interface for Ethereum providers (MetaMask, etc.)
3182
+ */
3183
+ interface EIP1193Provider {
3184
+ /** Make an Ethereum JSON-RPC request */
3185
+ request<T = unknown>(args: EIP1193RequestArguments): Promise<T>;
3186
+ /** Event emitter for provider events */
3187
+ on(event: string, handler: (...args: unknown[]) => void): void;
3188
+ removeListener(event: string, handler: (...args: unknown[]) => void): void;
3189
+ /** Provider is MetaMask */
3190
+ isMetaMask?: boolean;
3191
+ /** Provider is Coinbase Wallet */
3192
+ isCoinbaseWallet?: boolean;
3193
+ /** Selected address (may be undefined before connection) */
3194
+ selectedAddress?: string | null;
3195
+ /** Chain ID in hex format */
3196
+ chainId?: string;
3197
+ /** Whether provider is connected */
3198
+ isConnected?(): boolean;
3199
+ }
3200
+ /**
3201
+ * EIP-1193 Request arguments
3202
+ */
3203
+ interface EIP1193RequestArguments {
3204
+ method: string;
3205
+ params?: unknown[] | Record<string, unknown>;
3206
+ }
3207
+ /**
3208
+ * EIP-1193 Provider events
3209
+ */
3210
+ type EIP1193Event = 'connect' | 'disconnect' | 'chainChanged' | 'accountsChanged' | 'message';
3211
+ /**
3212
+ * EIP-1193 Connect info
3213
+ */
3214
+ interface EIP1193ConnectInfo {
3215
+ chainId: string;
3216
+ }
3217
+ /**
3218
+ * EIP-1193 Provider RPC error
3219
+ */
3220
+ interface EIP1193ProviderRpcError extends Error {
3221
+ code: number;
3222
+ data?: unknown;
3223
+ }
3224
+ /**
3225
+ * EIP-712 Typed data domain
3226
+ */
3227
+ interface EIP712Domain {
3228
+ name?: string;
3229
+ version?: string;
3230
+ chainId?: number;
3231
+ verifyingContract?: string;
3232
+ salt?: string;
3233
+ }
3234
+ /**
3235
+ * EIP-712 Type definition
3236
+ */
3237
+ interface EIP712TypeDefinition {
3238
+ name: string;
3239
+ type: string;
3240
+ }
3241
+ /**
3242
+ * EIP-712 Types object
3243
+ */
3244
+ interface EIP712Types {
3245
+ EIP712Domain?: EIP712TypeDefinition[];
3246
+ [key: string]: EIP712TypeDefinition[] | undefined;
3247
+ }
3248
+ /**
3249
+ * EIP-712 Typed data for signing
3250
+ */
3251
+ interface EIP712TypedData {
3252
+ domain: EIP712Domain;
3253
+ types: EIP712Types;
3254
+ primaryType: string;
3255
+ message: Record<string, unknown>;
3256
+ }
3257
+ /**
3258
+ * Ethereum transaction request
3259
+ */
3260
+ interface EthereumTransactionRequest {
3261
+ /** Sender address */
3262
+ from?: string;
3263
+ /** Recipient address */
3264
+ to?: string;
3265
+ /** Value in wei (hex) */
3266
+ value?: string;
3267
+ /** Transaction data (hex) */
3268
+ data?: string;
3269
+ /** Gas limit (hex) */
3270
+ gas?: string;
3271
+ /** Gas price (hex) - legacy */
3272
+ gasPrice?: string;
3273
+ /** Max fee per gas (hex) - EIP-1559 */
3274
+ maxFeePerGas?: string;
3275
+ /** Max priority fee per gas (hex) - EIP-1559 */
3276
+ maxPriorityFeePerGas?: string;
3277
+ /** Nonce (hex) */
3278
+ nonce?: string;
3279
+ /** Chain ID */
3280
+ chainId?: number;
3281
+ }
3282
+ /**
3283
+ * Ethereum transaction receipt
3284
+ */
3285
+ interface EthereumTransactionReceipt {
3286
+ /** Transaction hash */
3287
+ transactionHash: string;
3288
+ /** Block number */
3289
+ blockNumber: string;
3290
+ /** Block hash */
3291
+ blockHash: string;
3292
+ /** Sender address */
3293
+ from: string;
3294
+ /** Recipient address */
3295
+ to: string | null;
3296
+ /** Gas used */
3297
+ gasUsed: string;
3298
+ /** Effective gas price */
3299
+ effectiveGasPrice: string;
3300
+ /** Status (1 = success, 0 = failure) */
3301
+ status: string;
3302
+ /** Contract address (if deployment) */
3303
+ contractAddress: string | null;
3304
+ }
3305
+ /**
3306
+ * Token metadata for wallet_watchAsset
3307
+ */
3308
+ interface EthereumTokenMetadata {
3309
+ /** Token contract address */
3310
+ address: string;
3311
+ /** Token symbol */
3312
+ symbol: string;
3313
+ /** Token decimals */
3314
+ decimals: number;
3315
+ /** Token image URL (optional) */
3316
+ image?: string;
3317
+ }
3318
+ /**
3319
+ * Common Ethereum chain IDs
3320
+ */
3321
+ declare const EthereumChainId: {
3322
+ readonly MAINNET: 1;
3323
+ readonly GOERLI: 5;
3324
+ readonly SEPOLIA: 11155111;
3325
+ readonly POLYGON: 137;
3326
+ readonly POLYGON_MUMBAI: 80001;
3327
+ readonly ARBITRUM: 42161;
3328
+ readonly ARBITRUM_GOERLI: 421613;
3329
+ readonly OPTIMISM: 10;
3330
+ readonly OPTIMISM_GOERLI: 420;
3331
+ readonly BASE: 8453;
3332
+ readonly BASE_GOERLI: 84531;
3333
+ readonly LOCALHOST: 1337;
3334
+ };
3335
+ type EthereumChainIdType = (typeof EthereumChainId)[keyof typeof EthereumChainId];
3336
+ /**
3337
+ * Chain metadata for wallet_addEthereumChain
3338
+ */
3339
+ interface EthereumChainMetadata {
3340
+ chainId: string;
3341
+ chainName: string;
3342
+ nativeCurrency: {
3343
+ name: string;
3344
+ symbol: string;
3345
+ decimals: number;
3346
+ };
3347
+ rpcUrls: string[];
3348
+ blockExplorerUrls?: string[];
3349
+ iconUrls?: string[];
3350
+ }
3351
+ /**
3352
+ * Ethereum wallet name/type
3353
+ */
3354
+ type EthereumWalletName = 'metamask' | 'coinbase' | 'walletconnect' | 'generic';
3355
+ /**
3356
+ * Ethereum adapter configuration
3357
+ */
3358
+ interface EthereumAdapterConfig {
3359
+ /** Wallet to connect to */
3360
+ wallet?: EthereumWalletName;
3361
+ /** Target chain ID */
3362
+ chainId?: number;
3363
+ /** RPC endpoint URL (for balance queries) */
3364
+ rpcEndpoint?: string;
3365
+ /** Custom provider (for testing) */
3366
+ provider?: EIP1193Provider;
3367
+ }
3368
+ /**
3369
+ * Get the injected Ethereum provider
3370
+ */
3371
+ declare function getEthereumProvider(wallet?: EthereumWalletName): EIP1193Provider | undefined;
3372
+ /**
3373
+ * Detect which Ethereum wallets are installed
3374
+ */
3375
+ declare function detectEthereumWallets(): EthereumWalletName[];
3376
+ /**
3377
+ * Convert number to hex string with 0x prefix
3378
+ */
3379
+ declare function toHex(value: number | bigint): HexString;
3380
+ /**
3381
+ * Convert hex string to bigint
3382
+ */
3383
+ declare function fromHex(hex: string): bigint;
3384
+ /**
3385
+ * Convert hex string to number
3386
+ */
3387
+ declare function hexToNumber(hex: string): number;
3388
+ /**
3389
+ * Pad address to checksum format
3390
+ */
3391
+ declare function normalizeAddress(address: string): HexString;
3392
+ /**
3393
+ * Get default RPC endpoint for chain
3394
+ */
3395
+ declare function getDefaultRpcEndpoint(chainId: number): string;
3396
+
3397
+ /**
3398
+ * Ethereum Wallet Adapter
3399
+ *
3400
+ * Implementation of WalletAdapter for Ethereum wallets (MetaMask, Coinbase, etc.).
3401
+ * Uses EIP-1193 provider standard for wallet communication.
3402
+ */
3403
+
3404
+ /**
3405
+ * Ethereum wallet adapter implementation
3406
+ *
3407
+ * @example
3408
+ * ```typescript
3409
+ * const adapter = new EthereumWalletAdapter({
3410
+ * wallet: 'metamask',
3411
+ * chainId: 1,
3412
+ * })
3413
+ *
3414
+ * await adapter.connect()
3415
+ * const balance = await adapter.getBalance()
3416
+ * ```
3417
+ */
3418
+ declare class EthereumWalletAdapter extends BaseWalletAdapter {
3419
+ readonly chain: "ethereum";
3420
+ readonly name: string;
3421
+ private provider;
3422
+ private _chainId;
3423
+ private _rpcEndpoint;
3424
+ private walletType;
3425
+ private boundAccountsChanged;
3426
+ private boundChainChanged;
3427
+ private boundDisconnect;
3428
+ constructor(config?: EthereumAdapterConfig);
3429
+ /**
3430
+ * Get current chain ID
3431
+ */
3432
+ getChainId(): number;
3433
+ /**
3434
+ * Get RPC endpoint URL
3435
+ */
3436
+ getRpcEndpoint(): string;
3437
+ /**
3438
+ * Set RPC endpoint URL
3439
+ */
3440
+ setRpcEndpoint(endpoint: string): void;
3441
+ /**
3442
+ * Connect to Ethereum wallet
3443
+ */
3444
+ connect(): Promise<void>;
3445
+ /**
3446
+ * Disconnect from wallet
3447
+ */
3448
+ disconnect(): Promise<void>;
3449
+ /**
3450
+ * Sign a message
3451
+ */
3452
+ signMessage(message: Uint8Array): Promise<Signature>;
3453
+ /**
3454
+ * Sign typed data (EIP-712)
3455
+ */
3456
+ signTypedData(typedData: EIP712TypedData): Promise<Signature>;
3457
+ /**
3458
+ * Sign a transaction without sending
3459
+ */
3460
+ signTransaction(tx: UnsignedTransaction): Promise<SignedTransaction>;
3461
+ /**
3462
+ * Sign and send a transaction
3463
+ */
3464
+ signAndSendTransaction(tx: UnsignedTransaction): Promise<TransactionReceipt>;
3465
+ /**
3466
+ * Get ETH balance
3467
+ */
3468
+ getBalance(): Promise<bigint>;
3469
+ /**
3470
+ * Get ERC-20 token balance
3471
+ */
3472
+ getTokenBalance(asset: Asset): Promise<bigint>;
3473
+ /**
3474
+ * Switch to a different chain
3475
+ */
3476
+ switchChain(chainId: number): Promise<void>;
3477
+ /**
3478
+ * Wait for transaction confirmation
3479
+ */
3480
+ waitForTransaction(txHash: string, confirmations?: number): Promise<EthereumTransactionReceipt>;
3481
+ /**
3482
+ * Set up provider event listeners
3483
+ */
3484
+ private setupEventListeners;
3485
+ /**
3486
+ * Remove provider event listeners
3487
+ */
3488
+ private removeEventListeners;
3489
+ /**
3490
+ * Handle accounts changed event
3491
+ */
3492
+ private handleAccountsChanged;
3493
+ /**
3494
+ * Handle chain changed event
3495
+ */
3496
+ private handleChainChanged;
3497
+ /**
3498
+ * Handle disconnect event
3499
+ */
3500
+ private handleDisconnect;
3501
+ }
3502
+ /**
3503
+ * Factory function to create Ethereum adapter
3504
+ */
3505
+ declare function createEthereumAdapter(config?: EthereumAdapterConfig): EthereumWalletAdapter;
3506
+
3507
+ /**
3508
+ * Mock Ethereum Wallet Adapter
3509
+ *
3510
+ * Mock implementation for testing without browser environment.
3511
+ * Simulates EIP-1193 provider behavior.
3512
+ */
3513
+
3514
+ /**
3515
+ * Mock Ethereum adapter configuration
3516
+ */
3517
+ interface MockEthereumAdapterConfig {
3518
+ /** Mock address */
3519
+ address?: string;
3520
+ /** Mock chain ID */
3521
+ chainId?: number;
3522
+ /** Initial ETH balance in wei */
3523
+ balance?: bigint;
3524
+ /** Token balances by address */
3525
+ tokenBalances?: Record<string, bigint>;
3526
+ /** Should connection fail */
3527
+ shouldFailConnect?: boolean;
3528
+ /** Should signing fail */
3529
+ shouldFailSign?: boolean;
3530
+ /** Should transaction fail */
3531
+ shouldFailTransaction?: boolean;
3532
+ }
3533
+ /**
3534
+ * Mock Ethereum wallet adapter for testing
3535
+ *
3536
+ * @example
3537
+ * ```typescript
3538
+ * const adapter = new MockEthereumAdapter({
3539
+ * address: '0x1234...',
3540
+ * balance: 1_000_000_000_000_000_000n, // 1 ETH
3541
+ * })
3542
+ *
3543
+ * await adapter.connect()
3544
+ * const balance = await adapter.getBalance()
3545
+ * ```
3546
+ */
3547
+ declare class MockEthereumAdapter extends BaseWalletAdapter {
3548
+ readonly chain: "ethereum";
3549
+ readonly name = "mock-ethereum";
3550
+ private _chainId;
3551
+ private _balance;
3552
+ private _tokenBalances;
3553
+ private _mockAddress;
3554
+ private _shouldFailConnect;
3555
+ private _shouldFailSign;
3556
+ private _shouldFailTransaction;
3557
+ private _signedTransactions;
3558
+ private _sentTransactions;
3559
+ private _signatureCounter;
3560
+ private _txCounter;
3561
+ constructor(config?: MockEthereumAdapterConfig);
3562
+ /**
3563
+ * Get current chain ID
3564
+ */
3565
+ getChainId(): number;
3566
+ /**
3567
+ * Connect to mock wallet
3568
+ */
3569
+ connect(): Promise<void>;
3570
+ /**
3571
+ * Disconnect from mock wallet
3572
+ */
3573
+ disconnect(): Promise<void>;
3574
+ /**
3575
+ * Sign a message
3576
+ */
3577
+ signMessage(message: Uint8Array): Promise<Signature>;
3578
+ /**
3579
+ * Sign typed data (EIP-712)
3580
+ */
3581
+ signTypedData(typedData: EIP712TypedData): Promise<Signature>;
3582
+ /**
3583
+ * Sign a transaction
3584
+ */
3585
+ signTransaction(tx: UnsignedTransaction): Promise<SignedTransaction>;
3586
+ /**
3587
+ * Sign and send a transaction
3588
+ */
3589
+ signAndSendTransaction(tx: UnsignedTransaction): Promise<TransactionReceipt>;
3590
+ /**
3591
+ * Get ETH balance
3592
+ */
3593
+ getBalance(): Promise<bigint>;
3594
+ /**
3595
+ * Get ERC-20 token balance
3596
+ */
3597
+ getTokenBalance(asset: Asset): Promise<bigint>;
3598
+ /**
3599
+ * Switch chain (mock)
3600
+ */
3601
+ switchChain(chainId: number): Promise<void>;
3602
+ /**
3603
+ * Set mock ETH balance
3604
+ */
3605
+ setMockBalance(balance: bigint): void;
3606
+ /**
3607
+ * Set mock token balance
3608
+ */
3609
+ setMockTokenBalance(tokenAddress: string, balance: bigint): void;
3610
+ /**
3611
+ * Get signed transactions history
3612
+ */
3613
+ getSignedTransactions(): UnsignedTransaction[];
3614
+ /**
3615
+ * Get sent transaction hashes
3616
+ */
3617
+ getSentTransactions(): string[];
3618
+ /**
3619
+ * Clear transaction history
3620
+ */
3621
+ clearTransactionHistory(): void;
3622
+ /**
3623
+ * Simulate account change
3624
+ */
3625
+ simulateAccountChange(newAddress: string): void;
3626
+ /**
3627
+ * Simulate disconnect
3628
+ */
3629
+ simulateDisconnect(): void;
3630
+ }
3631
+ /**
3632
+ * Factory function to create mock Ethereum adapter
3633
+ */
3634
+ declare function createMockEthereumAdapter(config?: MockEthereumAdapterConfig): MockEthereumAdapter;
3635
+ /**
3636
+ * Create a mock EIP-1193 provider for testing
3637
+ */
3638
+ declare function createMockEthereumProvider(config?: MockEthereumAdapterConfig): EIP1193Provider;
3639
+
3640
+ export { BaseWalletAdapter, type CommitmentPoint, type CreateIntentOptions, CryptoError, type EIP1193ConnectInfo, type EIP1193Event, type EIP1193Provider, type EIP1193ProviderRpcError, type EIP1193RequestArguments, type EIP712Domain, type EIP712TypeDefinition, type EIP712TypedData, type EIP712Types, EncryptionNotImplementedError, ErrorCode, type EthereumAdapterConfig, EthereumChainId, type EthereumChainIdType, type EthereumChainMetadata, type EthereumTokenMetadata, type EthereumTransactionReceipt, type EthereumTransactionRequest, EthereumWalletAdapter, type EthereumWalletName, type ExportedViewingKey, type FulfillmentProofParams, type FundingProofParams, IntentBuilder, IntentError, MockEthereumAdapter, type MockEthereumAdapterConfig, MockProofProvider, MockSolanaAdapter, type MockSolanaAdapterConfig, MockSolver, type MockSolverConfig, MockWalletAdapter, NEARIntentsAdapter, type NEARIntentsAdapterConfig, NetworkError, NoirProofProvider, type NoirProviderConfig, OneClickClient, type OracleAttestation, type PedersenCommitment, type PreparedSwap, type PrivacyConfig, ProofError, type ProofFramework, ProofGenerationError, ProofNotImplementedError, type ProofProvider, type ProofResult, type ReceivedNote, SIP, type SIPConfig, SIPError, type SerializedError, type ShieldedBalance, type ShieldedSendParams, type ShieldedSendResult, type SolanaAdapterConfig, type SolanaCluster, type SolanaConnection, type SolanaPublicKey, type SolanaSendOptions, type SolanaSignature, type SolanaTransaction, type SolanaUnsignedTransaction, type SolanaVersionedTransaction, SolanaWalletAdapter, type SolanaWalletName, type SolanaWalletProvider, type SwapRequest, type SwapResult, type TransactionData, ValidationError, type ValidityProofParams, type WalletAdapter, WalletError, ZcashRPCClient, ZcashRPCError, ZcashShieldedService, type ZcashShieldedServiceConfig, addBlindings, addCommitments, attachProofs, base58ToHex, checkStealthAddress, commit, commitZero, createCommitment, createEthereumAdapter, createMockEthereumAdapter, createMockEthereumProvider, createMockSolanaAdapter, createMockSolanaConnection, createMockSolanaProvider, createMockSolver, createNEARIntentsAdapter, createSIP, createShieldedIntent, createSolanaAdapter, createWalletFactory, createZcashClient, createZcashShieldedService, decodeStealthMetaAddress, decryptWithViewing, deriveStealthPrivateKey, deriveViewingKey, deserializeIntent, detectEthereumWallets, detectSolanaWallets, encodeStealthMetaAddress, encryptForViewing, featureNotSupportedError, fromHex, generateBlinding, generateIntentId, generateRandomBytes, generateStealthAddress, generateStealthMetaAddress, generateViewingKey, getDefaultRpcEndpoint, getErrorMessage, getEthereumProvider, getGenerators, getIntentSummary, getPrivacyConfig, getPrivacyDescription, getSolanaProvider, getTimeRemaining, hasErrorCode, hasRequiredProofs, hash, hexToNumber, isExpired, isNonNegativeAmount, isPrivateWalletAdapter, isSIPError, isValidAmount, isValidChainId, isValidCompressedPublicKey, isValidHex, isValidHexLength, isValidPrivacyLevel, isValidPrivateKey, isValidScalar, isValidSlippage, isValidStealthMetaAddress, normalizeAddress, notConnectedError, registerWallet, serializeIntent, solanaPublicKeyToHex, subtractBlindings, subtractCommitments, toHex, trackIntent, validateAsset, validateCreateIntentParams, validateIntentInput, validateIntentOutput, validateScalar, validateViewingKey, verifyCommitment, verifyOpening, walletRegistry, wrapError };