@smoothsend/sdk 1.0.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,939 @@
1
+ export { SmoothSendError, AuthenticationError, RateLimitError, ValidationError, NetworkError, createErrorFromResponse, createNetworkError } from './errors';
2
+ /**
3
+ * Supported blockchain chains in the SmoothSend SDK
4
+ *
5
+ * @remarks
6
+ * - `avalanche`: Avalanche C-Chain (EVM-compatible)
7
+ * - `aptos-testnet`: Aptos testnet
8
+ * - `aptos-mainnet`: Aptos mainnet
9
+ */
10
+ export type SupportedChain = 'avalanche' | 'aptos-testnet' | 'aptos-mainnet';
11
+ /**
12
+ * Chain ecosystem types for routing to correct relayers
13
+ *
14
+ * @remarks
15
+ * - `evm`: Ethereum Virtual Machine compatible chains (Avalanche, Base, Arbitrum, etc.)
16
+ * - `aptos`: Aptos blockchain ecosystem
17
+ */
18
+ export type ChainEcosystem = 'evm' | 'aptos';
19
+ /**
20
+ * Mapping of supported chains to their respective ecosystems
21
+ * Used internally for adapter selection and routing
22
+ */
23
+ export declare const CHAIN_ECOSYSTEM_MAP: Record<SupportedChain, ChainEcosystem>;
24
+ /**
25
+ * Base success response structure
26
+ * All successful API responses extend this interface
27
+ */
28
+ export interface SuccessResponse {
29
+ /** Indicates the request was successful */
30
+ success: true;
31
+ }
32
+ /**
33
+ * Base error response structure
34
+ * All error API responses extend this interface
35
+ */
36
+ export interface ErrorResponse {
37
+ /** Indicates the request failed */
38
+ success: false;
39
+ /** Human-readable error message */
40
+ error: string;
41
+ /** Additional error details or validation errors */
42
+ details?: string[];
43
+ /** Unique request identifier for debugging */
44
+ requestId?: string;
45
+ }
46
+ /**
47
+ * Chain information structure
48
+ * Contains metadata about a supported blockchain
49
+ */
50
+ export interface ChainInfo {
51
+ /** Chain identifier (e.g., 'aptos-testnet') */
52
+ name: string;
53
+ /** Human-readable chain name */
54
+ displayName: string;
55
+ /** Numeric chain ID */
56
+ chainId: number;
57
+ /** Block explorer base URL */
58
+ explorerUrl: string;
59
+ /** List of supported token symbols */
60
+ tokens: string[];
61
+ }
62
+ /**
63
+ * Token information structure
64
+ * Contains metadata about a supported token
65
+ */
66
+ export interface TokenInfo {
67
+ /** Token symbol (e.g., 'USDC') */
68
+ symbol: string;
69
+ /** Token contract address */
70
+ address: string;
71
+ /** Number of decimal places */
72
+ decimals: number;
73
+ /** Full token name */
74
+ name: string;
75
+ }
76
+ /**
77
+ * Chain configuration structure
78
+ * Complete configuration for a blockchain network
79
+ */
80
+ export interface ChainConfig {
81
+ /** Chain identifier */
82
+ name: string;
83
+ /** Human-readable chain name */
84
+ displayName: string;
85
+ /** Numeric chain ID */
86
+ chainId: number;
87
+ /** RPC endpoint URL */
88
+ rpcUrl: string;
89
+ /** Relayer service URL */
90
+ relayerUrl: string;
91
+ /** Block explorer base URL */
92
+ explorerUrl: string;
93
+ /** List of supported token symbols */
94
+ tokens: string[];
95
+ /** Native currency information */
96
+ nativeCurrency: {
97
+ /** Currency name */
98
+ name: string;
99
+ /** Currency symbol */
100
+ symbol: string;
101
+ /** Number of decimal places */
102
+ decimals: number;
103
+ };
104
+ }
105
+ /**
106
+ * Transfer request parameters
107
+ * Used to initiate a gasless token transfer
108
+ *
109
+ * @example
110
+ * ```typescript
111
+ * const request: TransferRequest = {
112
+ * from: '0x123...',
113
+ * to: '0x456...',
114
+ * token: 'USDC',
115
+ * amount: '1000000', // 1 USDC (6 decimals)
116
+ * chain: 'aptos-testnet'
117
+ * };
118
+ * ```
119
+ */
120
+ export interface TransferRequest {
121
+ /** Sender's wallet address */
122
+ from: string;
123
+ /** Recipient's wallet address */
124
+ to: string;
125
+ /** Token symbol or contract address */
126
+ token: string;
127
+ /** Amount in smallest unit (wei, octas, etc.) */
128
+ amount: string;
129
+ /** Target blockchain */
130
+ chain: SupportedChain;
131
+ }
132
+ /**
133
+ * Transfer quote response from API
134
+ * Contains fee information for a transfer
135
+ */
136
+ export interface TransferQuoteResponse extends SuccessResponse {
137
+ /** Chain identifier */
138
+ chainName: string;
139
+ /** Token symbol */
140
+ token: string;
141
+ /** Transfer amount */
142
+ amount: string;
143
+ /** Relayer fee amount */
144
+ relayerFee: string;
145
+ /** Total amount (amount + fee) */
146
+ total: string;
147
+ /** Fee as percentage of amount */
148
+ feePercentage: number;
149
+ /** Token contract address */
150
+ contractAddress: string;
151
+ }
152
+ /**
153
+ * Fee estimate response from proxy worker
154
+ * Contains detailed fee information for a transfer
155
+ *
156
+ * @remarks
157
+ * Returned by `estimateFee()` method
158
+ */
159
+ export interface FeeEstimate {
160
+ /** Fee charged by relayer in token units */
161
+ relayerFee: string;
162
+ /** Fee in USD for reference */
163
+ feeInUSD: string;
164
+ /** Full coin type identifier (e.g., '0x1::aptos_coin::AptosCoin') */
165
+ coinType: string;
166
+ /** Estimated gas units */
167
+ estimatedGas: string;
168
+ /** Network (testnet or mainnet) */
169
+ network: 'testnet' | 'mainnet';
170
+ }
171
+ /**
172
+ * Transfer quote information
173
+ * Contains fee breakdown and contract details
174
+ */
175
+ export interface TransferQuote {
176
+ /** Transfer amount */
177
+ amount: string;
178
+ /** Relayer fee amount */
179
+ relayerFee: string;
180
+ /** Total amount (amount + fee) */
181
+ total: string;
182
+ /** Fee as percentage of amount */
183
+ feePercentage: number;
184
+ /** Token contract address */
185
+ contractAddress: string;
186
+ /** Aptos-specific transaction data (optional for backward compatibility) */
187
+ aptosTransactionData?: any;
188
+ }
189
+ /**
190
+ * Relay transfer response from API
191
+ * Contains transaction execution details
192
+ */
193
+ export interface RelayTransferResponse extends SuccessResponse {
194
+ /** Unique transfer identifier */
195
+ transferId: string;
196
+ /** Transaction hash */
197
+ txHash: string;
198
+ /** Block number where transaction was included */
199
+ blockNumber: number;
200
+ /** Gas units consumed */
201
+ gasUsed: string;
202
+ /** Block explorer URL for transaction */
203
+ explorerUrl: string;
204
+ /** Fee paid for the transfer */
205
+ fee: string;
206
+ /** Execution time in milliseconds */
207
+ executionTime: number;
208
+ }
209
+ /**
210
+ * Transfer result structure
211
+ * Contains complete information about a transfer execution
212
+ *
213
+ * @remarks
214
+ * Returned by `executeGaslessTransfer()` and `transfer()` methods
215
+ *
216
+ * @example
217
+ * ```typescript
218
+ * const result = await sdk.executeGaslessTransfer(signedData);
219
+ * console.log(`Transaction: ${result.txHash}`);
220
+ * console.log(`Explorer: ${result.explorerUrl}`);
221
+ * console.log(`Rate limit remaining: ${result.metadata?.rateLimit.remaining}`);
222
+ * ```
223
+ */
224
+ export interface TransferResult {
225
+ /** Indicates if transfer was successful */
226
+ success: boolean;
227
+ /** Transaction hash */
228
+ txHash: string;
229
+ /** Block number where transaction was included */
230
+ blockNumber?: number;
231
+ /** Gas units consumed */
232
+ gasUsed?: string;
233
+ /** Unique transfer identifier */
234
+ transferId?: string;
235
+ /** Block explorer URL for transaction */
236
+ explorerUrl?: string;
237
+ /** Fee paid for the transfer */
238
+ fee?: string;
239
+ /** Execution time in milliseconds */
240
+ executionTime?: number;
241
+ /** Address that paid the gas fee (Aptos-specific) */
242
+ gasFeePaidBy?: string;
243
+ /** Whether user paid in APT (Aptos-specific) */
244
+ userPaidAPT?: boolean;
245
+ /** Transparency information (Aptos-specific) */
246
+ transparency?: string;
247
+ /** VM execution status (Aptos-specific) */
248
+ vmStatus?: string;
249
+ /** Sender address (Aptos-specific) */
250
+ sender?: string;
251
+ /** Chain identifier (Aptos-specific) */
252
+ chain?: string;
253
+ /** Relayer fee amount (Aptos-specific) */
254
+ relayerFee?: string;
255
+ /** Additional message or status information */
256
+ message?: string;
257
+ /** Usage metadata from proxy worker (v2) */
258
+ metadata?: UsageMetadata;
259
+ }
260
+ /**
261
+ * Batch transfer request parameters
262
+ * Used to execute multiple transfers in a single transaction
263
+ *
264
+ * @remarks
265
+ * Batch transfers are more gas-efficient than individual transfers
266
+ */
267
+ export interface BatchTransferRequest {
268
+ /** Array of transfer requests to execute */
269
+ transfers: TransferRequest[];
270
+ /** Target blockchain */
271
+ chain: SupportedChain;
272
+ }
273
+ /**
274
+ * EVM transfer data structure
275
+ * Contains signed transfer data for EVM-compatible chains
276
+ *
277
+ * @remarks
278
+ * Used for Avalanche and other EVM chains
279
+ */
280
+ export interface EVMTransferData {
281
+ /** Chain identifier */
282
+ chainName: string;
283
+ /** Sender address */
284
+ from: string;
285
+ /** Recipient address */
286
+ to: string;
287
+ /** Token symbol */
288
+ tokenSymbol: string;
289
+ /** Transfer amount */
290
+ amount: string;
291
+ /** Relayer fee amount */
292
+ relayerFee: string;
293
+ /** Transaction nonce */
294
+ nonce: string;
295
+ /** Signature deadline timestamp */
296
+ deadline: number;
297
+ /** EIP-712 signature */
298
+ signature: string;
299
+ /** ERC-2612 permit data (optional) */
300
+ permitData?: {
301
+ /** Permit value */
302
+ value: string;
303
+ /** Permit deadline */
304
+ deadline: number;
305
+ /** Signature v component */
306
+ v: number;
307
+ /** Signature r component */
308
+ r: string;
309
+ /** Signature s component */
310
+ s: string;
311
+ };
312
+ }
313
+ /**
314
+ * Legacy type alias for Avalanche transfers
315
+ * @deprecated Use EVMTransferData instead
316
+ */
317
+ export type AvalancheTransferData = EVMTransferData;
318
+ /**
319
+ * Aptos transfer data structure
320
+ * Contains serialized transaction data for secure Aptos transfers
321
+ *
322
+ * @remarks
323
+ * Uses serialized transaction approach for enhanced security
324
+ * Transaction must be built and signed by wallet before submission
325
+ *
326
+ * @example
327
+ * ```typescript
328
+ * const aptosData: AptosTransferData = {
329
+ * transactionBytes: Array.from(signedTx.transactionBytes),
330
+ * authenticatorBytes: Array.from(signedTx.authenticatorBytes)
331
+ * };
332
+ * ```
333
+ */
334
+ export interface AptosTransferData {
335
+ /** Serialized SimpleTransaction as byte array */
336
+ transactionBytes: number[];
337
+ /** Serialized AccountAuthenticator as byte array */
338
+ authenticatorBytes: number[];
339
+ /** Optional function name for debugging/tracking */
340
+ functionName?: string;
341
+ /** Sender address (optional metadata) */
342
+ fromAddress?: string;
343
+ /** Recipient address (optional metadata) */
344
+ toAddress?: string;
345
+ /** Transfer amount (optional metadata) */
346
+ amount?: string;
347
+ /** Coin type identifier (optional metadata) */
348
+ coinType?: string;
349
+ }
350
+ /**
351
+ * EIP-712 signature data structure
352
+ * Contains typed data for signature verification
353
+ */
354
+ export interface SignatureData {
355
+ /** EIP-712 domain separator */
356
+ domain: any;
357
+ /** Type definitions */
358
+ types: any;
359
+ /** Message to sign */
360
+ message: any;
361
+ /** Primary type name */
362
+ primaryType: string;
363
+ /** Enhanced metadata for signature verification */
364
+ metadata?: {
365
+ /** Target chain */
366
+ chain?: SupportedChain;
367
+ /** Sender address */
368
+ fromAddress?: string;
369
+ /** Recipient address */
370
+ toAddress?: string;
371
+ /** Transfer amount */
372
+ amount?: string;
373
+ /** Token symbol */
374
+ token?: string;
375
+ /** Relayer fee */
376
+ relayerFee?: string;
377
+ /** Signature version */
378
+ signatureVersion?: string;
379
+ /** Whether public key is required */
380
+ requiresPublicKey?: boolean;
381
+ /** Verification method */
382
+ verificationMethod?: string;
383
+ };
384
+ }
385
+ /**
386
+ * Signed transfer data for SDK v2
387
+ * Contains serialized transaction bytes for secure Aptos transfers
388
+ *
389
+ * @remarks
390
+ * Used with `executeGaslessTransfer()` method
391
+ * Transaction must be built and signed by wallet before creating this structure
392
+ *
393
+ * @example
394
+ * ```typescript
395
+ * const signedData: SignedTransferData = {
396
+ * transactionBytes: Array.from(signedTx.transactionBytes),
397
+ * authenticatorBytes: Array.from(signedTx.authenticatorBytes),
398
+ * chain: 'aptos-testnet',
399
+ * network: 'testnet'
400
+ * };
401
+ * const result = await sdk.executeGaslessTransfer(signedData);
402
+ * ```
403
+ */
404
+ export interface SignedTransferData {
405
+ /** Serialized transaction (Aptos) */
406
+ transactionBytes: number[];
407
+ /** Serialized authenticator (Aptos) */
408
+ authenticatorBytes: number[];
409
+ /** Target blockchain */
410
+ chain: SupportedChain;
411
+ /** Optional network override (testnet or mainnet) */
412
+ network?: 'testnet' | 'mainnet';
413
+ }
414
+ /**
415
+ * Token balance information
416
+ * Contains balance and metadata for a specific token
417
+ */
418
+ export interface TokenBalance {
419
+ /** Token symbol or address */
420
+ token: string;
421
+ /** Balance in smallest unit */
422
+ balance: string;
423
+ /** Number of decimal places */
424
+ decimals: number;
425
+ /** Token symbol */
426
+ symbol: string;
427
+ /** Full token name (optional) */
428
+ name?: string;
429
+ }
430
+ /**
431
+ * Transfer quote request parameters
432
+ * Used to request fee estimate from API
433
+ */
434
+ export interface TransferQuoteRequest {
435
+ /** Chain identifier */
436
+ chainName: string;
437
+ /** Token symbol */
438
+ token: string;
439
+ /** Transfer amount */
440
+ amount: string;
441
+ }
442
+ /**
443
+ * Prepare signature request parameters
444
+ * Used to get typed data for EIP-712 signature
445
+ */
446
+ export interface PrepareSignatureRequest {
447
+ /** Chain identifier */
448
+ chainName: string;
449
+ /** Sender address */
450
+ from: string;
451
+ /** Recipient address */
452
+ to: string;
453
+ /** Token symbol */
454
+ tokenSymbol: string;
455
+ /** Transfer amount */
456
+ amount: string;
457
+ /** Relayer fee amount */
458
+ relayerFee: string;
459
+ /** Transaction nonce */
460
+ nonce: string;
461
+ /** Signature deadline timestamp */
462
+ deadline: number;
463
+ }
464
+ /**
465
+ * Relay transfer request parameters
466
+ * Used to submit signed transfer to relayer
467
+ */
468
+ export interface RelayTransferRequest {
469
+ /** Chain identifier */
470
+ chainName: string;
471
+ /** Sender address */
472
+ from: string;
473
+ /** Recipient address */
474
+ to: string;
475
+ /** Token symbol */
476
+ tokenSymbol: string;
477
+ /** Transfer amount */
478
+ amount: string;
479
+ /** Relayer fee amount */
480
+ relayerFee: string;
481
+ /** Transaction nonce */
482
+ nonce: string;
483
+ /** Signature deadline timestamp */
484
+ deadline: number;
485
+ /** EIP-712 signature */
486
+ signature: string;
487
+ /** ERC-2612 permit data (optional) */
488
+ permitData?: PermitData;
489
+ }
490
+ /**
491
+ * Batch relay transfer request parameters
492
+ * Used to submit multiple signed transfers in one transaction
493
+ */
494
+ export interface BatchRelayTransferRequest {
495
+ /** Chain identifier */
496
+ chainName: string;
497
+ /** Array of transfer requests */
498
+ transfers: RelayTransferRequest[];
499
+ }
500
+ /**
501
+ * Gas estimate request parameters
502
+ * Used to estimate gas cost for transfers
503
+ */
504
+ export interface EstimateGasRequest {
505
+ /** Chain identifier */
506
+ chainName: string;
507
+ /** Array of transfer data */
508
+ transfers: TransferData[];
509
+ }
510
+ /**
511
+ * Transfer data structure
512
+ * Contains complete transfer information including signature
513
+ */
514
+ export interface TransferData {
515
+ /** Sender address */
516
+ from: string;
517
+ /** Recipient address */
518
+ to: string;
519
+ /** Token symbol or address */
520
+ token: string;
521
+ /** Transfer amount */
522
+ amount: string;
523
+ /** Relayer fee amount */
524
+ relayerFee: string;
525
+ /** Transaction nonce */
526
+ nonce: string;
527
+ /** Signature deadline timestamp */
528
+ deadline: number;
529
+ /** EIP-712 signature */
530
+ signature: string;
531
+ /** ERC-2612 permit data (optional) */
532
+ permitData?: PermitData;
533
+ }
534
+ /**
535
+ * ERC-2612 permit data structure
536
+ * Used for gasless token approvals
537
+ */
538
+ export interface PermitData {
539
+ /** Permit value (amount) */
540
+ value: string;
541
+ /** Permit deadline timestamp */
542
+ deadline: number;
543
+ /** Signature v component */
544
+ v: number;
545
+ /** Signature r component */
546
+ r: string;
547
+ /** Signature s component */
548
+ s: string;
549
+ }
550
+ /**
551
+ * Prepare signature response from API
552
+ * Contains EIP-712 typed data for signing
553
+ */
554
+ export interface PrepareSignatureResponse extends SuccessResponse {
555
+ /** EIP-712 typed data structure */
556
+ typedData: any;
557
+ /** Keccak256 hash of the message */
558
+ messageHash: string;
559
+ /** Human-readable message */
560
+ message: string;
561
+ }
562
+ /**
563
+ * Gas estimate response from API
564
+ * Contains estimated gas cost for transfers
565
+ */
566
+ export interface GasEstimateResponse extends SuccessResponse {
567
+ /** Chain identifier */
568
+ chainName: string;
569
+ /** Estimated gas units */
570
+ gasEstimate: string;
571
+ /** Current gas price */
572
+ gasPrice: string;
573
+ /** Estimated cost in native currency */
574
+ estimatedCost: string;
575
+ /** Number of transfers in batch */
576
+ transferCount: number;
577
+ }
578
+ /**
579
+ * Health check response
580
+ * Contains service health status information
581
+ *
582
+ * @remarks
583
+ * Returned by `getHealth()` and `getChainHealth()` methods
584
+ */
585
+ export interface HealthResponse extends SuccessResponse {
586
+ /** Service status (e.g., 'healthy', 'degraded') */
587
+ status: string;
588
+ /** Response timestamp (ISO 8601) */
589
+ timestamp: string;
590
+ /** Service version */
591
+ version: string;
592
+ }
593
+ /**
594
+ * Domain separator response from API
595
+ * Contains EIP-712 domain separator for a chain
596
+ */
597
+ export interface DomainSeparatorResponse extends SuccessResponse {
598
+ /** Chain identifier */
599
+ chainName: string;
600
+ /** EIP-712 domain separator hash */
601
+ domainSeparator: string;
602
+ }
603
+ /**
604
+ * Transfer status response from API
605
+ * Contains execution status of a transfer
606
+ */
607
+ export interface TransferStatusResponse extends SuccessResponse {
608
+ /** Chain identifier */
609
+ chainName: string;
610
+ /** Transfer transaction hash */
611
+ transferHash: string;
612
+ /** Whether transfer has been executed */
613
+ executed: boolean;
614
+ }
615
+ /**
616
+ * Aptos-specific error codes
617
+ * Used for detailed error handling in Aptos adapter
618
+ *
619
+ * @remarks
620
+ * Error codes are prefixed with APTOS_ for easy identification
621
+ */
622
+ export declare const APTOS_ERROR_CODES: {
623
+ /** Missing signature in request */
624
+ readonly MISSING_SIGNATURE: "APTOS_MISSING_SIGNATURE";
625
+ /** Missing public key for verification */
626
+ readonly MISSING_PUBLIC_KEY: "APTOS_MISSING_PUBLIC_KEY";
627
+ /** Invalid signature format */
628
+ readonly INVALID_SIGNATURE_FORMAT: "APTOS_INVALID_SIGNATURE_FORMAT";
629
+ /** Invalid public key format */
630
+ readonly INVALID_PUBLIC_KEY_FORMAT: "APTOS_INVALID_PUBLIC_KEY_FORMAT";
631
+ /** Address doesn't match public key */
632
+ readonly ADDRESS_MISMATCH: "APTOS_ADDRESS_MISMATCH";
633
+ /** Signature verification failed */
634
+ readonly SIGNATURE_VERIFICATION_FAILED: "APTOS_SIGNATURE_VERIFICATION_FAILED";
635
+ /** Missing transaction data */
636
+ readonly MISSING_TRANSACTION_DATA: "APTOS_MISSING_TRANSACTION_DATA";
637
+ /** Invalid transaction format */
638
+ readonly INVALID_TRANSACTION_FORMAT: "APTOS_INVALID_TRANSACTION_FORMAT";
639
+ /** Empty address provided */
640
+ readonly EMPTY_ADDRESS: "APTOS_EMPTY_ADDRESS";
641
+ /** Invalid address format */
642
+ readonly INVALID_ADDRESS_FORMAT: "APTOS_INVALID_ADDRESS_FORMAT";
643
+ /** Error fetching quote */
644
+ readonly QUOTE_ERROR: "APTOS_QUOTE_ERROR";
645
+ /** Error executing transfer */
646
+ readonly EXECUTE_ERROR: "APTOS_EXECUTE_ERROR";
647
+ /** Error fetching balance */
648
+ readonly BALANCE_ERROR: "APTOS_BALANCE_ERROR";
649
+ /** Error fetching token info */
650
+ readonly TOKEN_INFO_ERROR: "APTOS_TOKEN_INFO_ERROR";
651
+ /** Error checking status */
652
+ readonly STATUS_ERROR: "APTOS_STATUS_ERROR";
653
+ /** Error calling Move function */
654
+ readonly MOVE_CALL_ERROR: "APTOS_MOVE_CALL_ERROR";
655
+ /** Unsupported token */
656
+ readonly UNSUPPORTED_TOKEN: "APTOS_UNSUPPORTED_TOKEN";
657
+ };
658
+ /**
659
+ * Type for Aptos error codes
660
+ * Ensures type safety when using error codes
661
+ */
662
+ export type AptosErrorCode = typeof APTOS_ERROR_CODES[keyof typeof APTOS_ERROR_CODES];
663
+ /**
664
+ * Generic API response structure
665
+ * Used for all API responses with optional data payload
666
+ *
667
+ * @typeParam T - Type of the response data
668
+ *
669
+ * @example
670
+ * ```typescript
671
+ * const response: ApiResponse<TransferResult> = await api.transfer(data);
672
+ * if (response.success && response.data) {
673
+ * console.log('Transfer successful:', response.data.txHash);
674
+ * }
675
+ * ```
676
+ */
677
+ export interface ApiResponse<T = any> {
678
+ /** Indicates if request was successful */
679
+ success: boolean;
680
+ /** Response data (present on success) */
681
+ data?: T;
682
+ /** Error message (present on failure) */
683
+ error?: string;
684
+ /** Additional error details */
685
+ details?: string[];
686
+ /** Unique request identifier */
687
+ requestId?: string;
688
+ /** Error code for programmatic handling */
689
+ errorCode?: string;
690
+ /** Chain where request was made */
691
+ chain?: SupportedChain;
692
+ /** Response timestamp (ISO 8601) */
693
+ timestamp?: string;
694
+ /** Usage metadata from proxy worker (v2) */
695
+ metadata?: UsageMetadata;
696
+ }
697
+ /**
698
+ * SDK configuration for v2 - Proxy-based architecture
699
+ *
700
+ * @remarks
701
+ * All requests route through proxy.smoothsend.xyz with API key authentication
702
+ *
703
+ * @example
704
+ * ```typescript
705
+ * const config: SmoothSendConfig = {
706
+ * apiKey: 'no_gas_abc123...',
707
+ * network: 'testnet',
708
+ * timeout: 30000,
709
+ * retries: 3
710
+ * };
711
+ * const sdk = new SmoothSendSDK(config);
712
+ * ```
713
+ */
714
+ export interface SmoothSendConfig {
715
+ /** API key with no_gas_ prefix for authentication (required) */
716
+ apiKey: string;
717
+ /** Network to use: testnet or mainnet (default: testnet) */
718
+ network?: 'testnet' | 'mainnet';
719
+ /** Request timeout in milliseconds (default: 30000) */
720
+ timeout?: number;
721
+ /** Maximum retry attempts for failed requests (default: 3) */
722
+ retries?: number;
723
+ /** Additional headers to include in requests */
724
+ customHeaders?: Record<string, string>;
725
+ }
726
+ /**
727
+ * Usage metadata from proxy worker response headers
728
+ * Contains rate limiting and usage tracking information
729
+ *
730
+ * @remarks
731
+ * Attached to all transfer results and available via `getUsageStats()`
732
+ *
733
+ * @example
734
+ * ```typescript
735
+ * const result = await sdk.transfer(request, wallet);
736
+ * console.log('Rate limit:', result.metadata?.rateLimit);
737
+ * console.log('Monthly usage:', result.metadata?.monthly);
738
+ *
739
+ * // Check if approaching limits
740
+ * if (parseInt(result.metadata.rateLimit.remaining) < 2) {
741
+ * console.warn('Approaching rate limit!');
742
+ * }
743
+ * ```
744
+ */
745
+ export interface UsageMetadata {
746
+ /** Rate limit information (per minute) */
747
+ rateLimit: {
748
+ /** Maximum requests per minute */
749
+ limit: string;
750
+ /** Remaining requests this minute */
751
+ remaining: string;
752
+ /** When rate limit resets (ISO 8601 timestamp) */
753
+ reset: string;
754
+ };
755
+ /** Monthly usage information */
756
+ monthly: {
757
+ /** Total monthly request limit */
758
+ limit: string;
759
+ /** Requests used this month */
760
+ usage: string;
761
+ /** Remaining requests this month */
762
+ remaining: string;
763
+ };
764
+ /** Unique request identifier for debugging */
765
+ requestId: string;
766
+ }
767
+ /**
768
+ * Transfer event types
769
+ * Emitted during transfer lifecycle for monitoring and debugging
770
+ */
771
+ export interface TransferEvent {
772
+ /** Event type */
773
+ type: 'transfer_initiated' | 'transfer_signed' | 'transfer_submitted' | 'transfer_confirmed' | 'transfer_failed';
774
+ /** Event data (varies by type) */
775
+ data: any;
776
+ /** Event timestamp (Unix milliseconds) */
777
+ timestamp: number;
778
+ /** Chain where event occurred */
779
+ chain: SupportedChain;
780
+ }
781
+ /**
782
+ * Event listener callback function
783
+ * Called when transfer events are emitted
784
+ *
785
+ * @param event - Transfer event object
786
+ *
787
+ * @example
788
+ * ```typescript
789
+ * const listener: EventListener = (event) => {
790
+ * console.log(`Event: ${event.type} on ${event.chain}`);
791
+ * };
792
+ * sdk.addEventListener(listener);
793
+ * ```
794
+ */
795
+ export type EventListener = (event: TransferEvent) => void;
796
+ /**
797
+ * Chain Adapter Interface - v2 Proxy Architecture
798
+ *
799
+ * @remarks
800
+ * All adapters route requests through proxy.smoothsend.xyz with API key authentication.
801
+ * The proxy handles relayer URL routing, so adapters no longer need direct relayer configuration.
802
+ *
803
+ * Key changes from v1:
804
+ * - Removed `config` property (relayer URLs handled by proxy)
805
+ * - Simplified to core methods: estimateFee, executeGaslessTransfer
806
+ * - Removed getQuote, prepareTransfer, getNonce, getTokenInfo (not needed for proxy flow)
807
+ * - Network parameter (testnet/mainnet) passed via HTTP headers, not method parameters
808
+ * - Client-side validation methods remain for address and amount validation
809
+ *
810
+ * Design rationale:
811
+ * - Consistent interface across all chains
812
+ * - Minimal surface area - only essential methods
813
+ * - Async by default for all I/O operations
814
+ * - Client-side validation done locally without network calls
815
+ * - Wallet libraries handle balance queries and transaction building
816
+ *
817
+ * @example
818
+ * ```typescript
819
+ * class MyChainAdapter implements IChainAdapter {
820
+ * readonly chain: SupportedChain = 'aptos-testnet';
821
+ *
822
+ * async estimateFee(request: TransferRequest): Promise<FeeEstimate> {
823
+ * // Implementation
824
+ * }
825
+ *
826
+ * async executeGaslessTransfer(signedData: SignedTransferData): Promise<TransferResult> {
827
+ * // Implementation
828
+ * }
829
+ *
830
+ * // ... other methods
831
+ * }
832
+ * ```
833
+ */
834
+ export interface IChainAdapter {
835
+ /** Chain identifier this adapter handles */
836
+ readonly chain: SupportedChain;
837
+ /**
838
+ * Estimate fee for a transfer
839
+ *
840
+ * @param request - Transfer request parameters
841
+ * @returns Fee estimate with relayer fee and gas information
842
+ * @throws {ValidationError} If request parameters are invalid
843
+ * @throws {NetworkError} If unable to reach proxy/relayer
844
+ *
845
+ * @example
846
+ * ```typescript
847
+ * const estimate = await adapter.estimateFee({
848
+ * from: '0x123...',
849
+ * to: '0x456...',
850
+ * token: 'USDC',
851
+ * amount: '1000000',
852
+ * chain: 'aptos-testnet'
853
+ * });
854
+ * console.log('Fee:', estimate.relayerFee);
855
+ * ```
856
+ */
857
+ estimateFee(request: TransferRequest): Promise<FeeEstimate>;
858
+ /**
859
+ * Execute a gasless transfer with signed transaction data
860
+ *
861
+ * @param signedData - Signed transfer data with serialized transaction
862
+ * @returns Transfer result with transaction hash and metadata
863
+ * @throws {AuthenticationError} If API key is invalid
864
+ * @throws {RateLimitError} If rate limit is exceeded
865
+ * @throws {ValidationError} If signed data is invalid
866
+ * @throws {NetworkError} If unable to reach proxy/relayer
867
+ *
868
+ * @example
869
+ * ```typescript
870
+ * const result = await adapter.executeGaslessTransfer({
871
+ * transactionBytes: [1, 2, 3, ...],
872
+ * authenticatorBytes: [4, 5, 6, ...],
873
+ * chain: 'aptos-testnet',
874
+ * network: 'testnet'
875
+ * });
876
+ * console.log('Transaction:', result.txHash);
877
+ * ```
878
+ */
879
+ executeGaslessTransfer(signedData: SignedTransferData): Promise<TransferResult>;
880
+ /**
881
+ * Get transaction status by hash
882
+ *
883
+ * @param txHash - Transaction hash to query
884
+ * @returns Transaction status information
885
+ * @throws {ValidationError} If transaction hash is invalid
886
+ * @throws {NetworkError} If unable to reach proxy/relayer
887
+ *
888
+ * @example
889
+ * ```typescript
890
+ * const status = await adapter.getTransactionStatus('0xabc123...');
891
+ * console.log('Status:', status);
892
+ * ```
893
+ */
894
+ getTransactionStatus(txHash: string): Promise<any>;
895
+ /**
896
+ * Check health status of the chain's relayer
897
+ *
898
+ * @returns Health response with status and version
899
+ * @throws {NetworkError} If unable to reach proxy/relayer
900
+ *
901
+ * @example
902
+ * ```typescript
903
+ * const health = await adapter.getHealth();
904
+ * console.log('Status:', health.status);
905
+ * ```
906
+ */
907
+ getHealth(): Promise<HealthResponse>;
908
+ /**
909
+ * Validate address format (client-side, no network call)
910
+ *
911
+ * @param address - Address to validate
912
+ * @returns true if address format is valid, false otherwise
913
+ *
914
+ * @example
915
+ * ```typescript
916
+ * const isValid = adapter.validateAddress('0x123...');
917
+ * if (!isValid) {
918
+ * console.error('Invalid address format');
919
+ * }
920
+ * ```
921
+ */
922
+ validateAddress(address: string): boolean;
923
+ /**
924
+ * Validate amount format (client-side, no network call)
925
+ *
926
+ * @param amount - Amount to validate (in smallest unit)
927
+ * @returns true if amount format is valid, false otherwise
928
+ *
929
+ * @example
930
+ * ```typescript
931
+ * const isValid = adapter.validateAmount('1000000');
932
+ * if (!isValid) {
933
+ * console.error('Invalid amount format');
934
+ * }
935
+ * ```
936
+ */
937
+ validateAmount(amount: string): boolean;
938
+ }
939
+ //# sourceMappingURL=index.d.ts.map