@smoothsend/sdk 2.2.2 → 2.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/aptos/index.cjs +1256 -0
- package/dist/aptos/index.cjs.map +1 -0
- package/dist/aptos/index.d.ts +783 -0
- package/dist/aptos/index.js +1230 -0
- package/dist/aptos/index.js.map +1 -0
- package/dist/aptos-entry.d.ts +36 -0
- package/dist/aptos-entry.d.ts.map +1 -0
- package/dist/avax/index.cjs +1869 -0
- package/dist/avax/index.cjs.map +1 -0
- package/dist/avax/index.d.ts +306 -7
- package/dist/avax/index.js +1849 -0
- package/dist/avax/index.js.map +1 -0
- package/dist/avax-entry.d.ts +24 -0
- package/dist/avax-entry.d.ts.map +1 -0
- package/dist/chunks/SmoothSendSDK-C_ofuBkk.cjs +1519 -0
- package/dist/chunks/SmoothSendSDK-C_ofuBkk.cjs.map +1 -0
- package/dist/chunks/SmoothSendSDK-CaV_PCIG.js +1511 -0
- package/dist/chunks/SmoothSendSDK-CaV_PCIG.js.map +1 -0
- package/dist/chunks/SmoothSendSDK.d-9GBgZONY.d.ts +262 -0
- package/dist/chunks/TrueGaslessClient-DThO4Tpb.cjs +1237 -0
- package/dist/chunks/TrueGaslessClient-DThO4Tpb.cjs.map +1 -0
- package/dist/chunks/TrueGaslessClient-l2uFvNAa.js +1228 -0
- package/dist/chunks/TrueGaslessClient-l2uFvNAa.js.map +1 -0
- package/dist/chunks/shared-CNF22ESH.js +557 -0
- package/dist/chunks/shared-CNF22ESH.js.map +1 -0
- package/dist/chunks/shared-CaQMAGQR.js +1511 -0
- package/dist/chunks/shared-CaQMAGQR.js.map +1 -0
- package/dist/chunks/shared-Cn4duBJT.d.ts +1279 -0
- package/dist/chunks/shared-DEurKmpI.cjs +1519 -0
- package/dist/chunks/shared-DEurKmpI.cjs.map +1 -0
- package/dist/chunks/shared-RVkwmkG7.d.ts +262 -0
- package/dist/chunks/shared-x1-VC-Li.cjs +568 -0
- package/dist/chunks/shared-x1-VC-Li.cjs.map +1 -0
- package/dist/chunks/useSmoothSendAvax-BHeW_6x8.cjs +1865 -0
- package/dist/chunks/useSmoothSendAvax-BHeW_6x8.cjs.map +1 -0
- package/dist/chunks/useSmoothSendAvax-ZuHw1aYi.js +1848 -0
- package/dist/chunks/useSmoothSendAvax-ZuHw1aYi.js.map +1 -0
- package/dist/chunks/version-CNF22ESH.js +557 -0
- package/dist/chunks/version-CNF22ESH.js.map +1 -0
- package/dist/chunks/version-x1-VC-Li.cjs +568 -0
- package/dist/chunks/version-x1-VC-Li.cjs.map +1 -0
- package/dist/chunks/version.d-Cn4duBJT.d.ts +1279 -0
- package/dist/index.cjs +5209 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +11 -2853
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.js +61 -102
- package/dist/index.js.map +1 -1
- package/dist/stellar/index.cjs +27 -0
- package/dist/stellar/index.cjs.map +1 -0
- package/dist/stellar/index.d.ts +214 -0
- package/dist/stellar/index.js +3 -0
- package/dist/stellar/index.js.map +1 -0
- package/dist/stellar-entry.d.ts +37 -0
- package/dist/stellar-entry.d.ts.map +1 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/package.json +23 -24
package/dist/index.d.ts
CHANGED
|
@@ -1,2853 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
* @remarks
|
|
13
|
-
* All SDK errors extend SmoothSendError for consistent error handling
|
|
14
|
-
* Use instanceof checks to handle specific error types
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* ```typescript
|
|
18
|
-
* try {
|
|
19
|
-
* await sdk.transfer(request, wallet);
|
|
20
|
-
* } catch (error) {
|
|
21
|
-
* if (error instanceof AuthenticationError) {
|
|
22
|
-
* console.error('Invalid API key');
|
|
23
|
-
* } else if (error instanceof RateLimitError) {
|
|
24
|
-
* console.error('Rate limit exceeded');
|
|
25
|
-
* }
|
|
26
|
-
* }
|
|
27
|
-
* ```
|
|
28
|
-
*/
|
|
29
|
-
/**
|
|
30
|
-
* Base error class for all SmoothSend SDK errors
|
|
31
|
-
*
|
|
32
|
-
* @remarks
|
|
33
|
-
* All SDK-specific errors extend this class
|
|
34
|
-
* Contains error code, HTTP status code, and additional details
|
|
35
|
-
*
|
|
36
|
-
* @example
|
|
37
|
-
* ```typescript
|
|
38
|
-
* throw new SmoothSendError(
|
|
39
|
-
* 'Something went wrong',
|
|
40
|
-
* 'CUSTOM_ERROR',
|
|
41
|
-
* 500,
|
|
42
|
-
* { additionalInfo: 'details' }
|
|
43
|
-
* );
|
|
44
|
-
* ```
|
|
45
|
-
*/
|
|
46
|
-
declare class SmoothSendError extends Error {
|
|
47
|
-
code: string;
|
|
48
|
-
statusCode?: number | undefined;
|
|
49
|
-
details?: any | undefined;
|
|
50
|
-
/**
|
|
51
|
-
* Creates a new SmoothSendError
|
|
52
|
-
*
|
|
53
|
-
* @param message - Human-readable error message
|
|
54
|
-
* @param code - Error code for programmatic handling
|
|
55
|
-
* @param statusCode - HTTP status code (if applicable)
|
|
56
|
-
* @param details - Additional error details
|
|
57
|
-
*/
|
|
58
|
-
constructor(message: string, code: string, statusCode?: number | undefined, details?: any | undefined);
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Authentication error - thrown when API key is invalid, missing, or expired
|
|
62
|
-
*
|
|
63
|
-
* @remarks
|
|
64
|
-
* HTTP Status Code: 401
|
|
65
|
-
* Indicates authentication failure with the proxy worker
|
|
66
|
-
*
|
|
67
|
-
* @example
|
|
68
|
-
* ```typescript
|
|
69
|
-
* try {
|
|
70
|
-
* await sdk.transfer(request, wallet);
|
|
71
|
-
* } catch (error) {
|
|
72
|
-
* if (error instanceof AuthenticationError) {
|
|
73
|
-
* console.error('Invalid API key:', error.message);
|
|
74
|
-
* console.log('Get a new key at:', error.details.suggestion);
|
|
75
|
-
* }
|
|
76
|
-
* }
|
|
77
|
-
* ```
|
|
78
|
-
*/
|
|
79
|
-
declare class AuthenticationError extends SmoothSendError {
|
|
80
|
-
/**
|
|
81
|
-
* Creates a new AuthenticationError
|
|
82
|
-
*
|
|
83
|
-
* @param message - Human-readable error message
|
|
84
|
-
* @param details - Additional error details
|
|
85
|
-
*/
|
|
86
|
-
constructor(message: string, details?: any);
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Rate limit error - thrown when request rate limit is exceeded
|
|
90
|
-
*
|
|
91
|
-
* @remarks
|
|
92
|
-
* HTTP Status Code: 429
|
|
93
|
-
* Contains rate limit details including reset time
|
|
94
|
-
*
|
|
95
|
-
* @example
|
|
96
|
-
* ```typescript
|
|
97
|
-
* try {
|
|
98
|
-
* await sdk.transfer(request, wallet);
|
|
99
|
-
* } catch (error) {
|
|
100
|
-
* if (error instanceof RateLimitError) {
|
|
101
|
-
* console.error('Rate limit exceeded');
|
|
102
|
-
* console.log(`Limit: ${error.limit}`);
|
|
103
|
-
* console.log(`Remaining: ${error.remaining}`);
|
|
104
|
-
* console.log(`Resets at: ${error.resetTime}`);
|
|
105
|
-
* }
|
|
106
|
-
* }
|
|
107
|
-
* ```
|
|
108
|
-
*/
|
|
109
|
-
declare class RateLimitError extends SmoothSendError {
|
|
110
|
-
limit: number;
|
|
111
|
-
remaining: number;
|
|
112
|
-
resetTime: string;
|
|
113
|
-
/**
|
|
114
|
-
* Creates a new RateLimitError
|
|
115
|
-
*
|
|
116
|
-
* @param message - Human-readable error message
|
|
117
|
-
* @param limit - Maximum requests allowed per period
|
|
118
|
-
* @param remaining - Remaining requests in current period
|
|
119
|
-
* @param resetTime - When the rate limit resets (ISO 8601 timestamp)
|
|
120
|
-
*/
|
|
121
|
-
constructor(message: string, limit: number, remaining: number, resetTime: string);
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Validation error - thrown when request parameters are invalid
|
|
125
|
-
*
|
|
126
|
-
* @remarks
|
|
127
|
-
* HTTP Status Code: 400
|
|
128
|
-
* Contains field name that failed validation
|
|
129
|
-
*
|
|
130
|
-
* @example
|
|
131
|
-
* ```typescript
|
|
132
|
-
* try {
|
|
133
|
-
* await sdk.transfer(request, wallet);
|
|
134
|
-
* } catch (error) {
|
|
135
|
-
* if (error instanceof ValidationError) {
|
|
136
|
-
* console.error(`Invalid ${error.field}:`, error.message);
|
|
137
|
-
* }
|
|
138
|
-
* }
|
|
139
|
-
* ```
|
|
140
|
-
*/
|
|
141
|
-
declare class ValidationError extends SmoothSendError {
|
|
142
|
-
field: string;
|
|
143
|
-
/**
|
|
144
|
-
* Creates a new ValidationError
|
|
145
|
-
*
|
|
146
|
-
* @param message - Human-readable error message
|
|
147
|
-
* @param field - Name of the field that failed validation
|
|
148
|
-
* @param details - Additional error details
|
|
149
|
-
*/
|
|
150
|
-
constructor(message: string, field: string, details?: any);
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* Network error - thrown when network connectivity issues occur
|
|
154
|
-
*
|
|
155
|
-
* @remarks
|
|
156
|
-
* HTTP Status Code: 0 (no HTTP response)
|
|
157
|
-
* Indicates network connectivity problems
|
|
158
|
-
*
|
|
159
|
-
* @example
|
|
160
|
-
* ```typescript
|
|
161
|
-
* try {
|
|
162
|
-
* await sdk.transfer(request, wallet);
|
|
163
|
-
* } catch (error) {
|
|
164
|
-
* if (error instanceof NetworkError) {
|
|
165
|
-
* console.error('Network error:', error.message);
|
|
166
|
-
* console.log('Original error:', error.originalError);
|
|
167
|
-
* }
|
|
168
|
-
* }
|
|
169
|
-
* ```
|
|
170
|
-
*/
|
|
171
|
-
declare class NetworkError extends SmoothSendError {
|
|
172
|
-
originalError?: Error | undefined;
|
|
173
|
-
/**
|
|
174
|
-
* Creates a new NetworkError
|
|
175
|
-
*
|
|
176
|
-
* @param message - Human-readable error message
|
|
177
|
-
* @param originalError - Original error that caused the network failure
|
|
178
|
-
*/
|
|
179
|
-
constructor(message: string, originalError?: Error | undefined);
|
|
180
|
-
}
|
|
181
|
-
/**
|
|
182
|
-
* Helper function to create appropriate error from HTTP response
|
|
183
|
-
*
|
|
184
|
-
* @remarks
|
|
185
|
-
* Parses HTTP error response and creates typed error object
|
|
186
|
-
* Used internally by HTTP client
|
|
187
|
-
*
|
|
188
|
-
* @param statusCode - HTTP status code
|
|
189
|
-
* @param errorData - Error response data from API
|
|
190
|
-
* @param defaultMessage - Default message if none provided in response
|
|
191
|
-
* @returns Typed error object
|
|
192
|
-
*
|
|
193
|
-
* @example
|
|
194
|
-
* ```typescript
|
|
195
|
-
* const error = createErrorFromResponse(401, {
|
|
196
|
-
* error: 'Invalid API key',
|
|
197
|
-
* details: { field: 'apiKey' }
|
|
198
|
-
* });
|
|
199
|
-
* throw error;
|
|
200
|
-
* ```
|
|
201
|
-
*/
|
|
202
|
-
declare function createErrorFromResponse(statusCode: number, errorData: any, defaultMessage?: string): SmoothSendError;
|
|
203
|
-
/**
|
|
204
|
-
* Helper function to create network error from exception
|
|
205
|
-
*
|
|
206
|
-
* @remarks
|
|
207
|
-
* Wraps generic exceptions in NetworkError for consistent error handling
|
|
208
|
-
* Used internally by HTTP client
|
|
209
|
-
*
|
|
210
|
-
* @param error - Original error or exception
|
|
211
|
-
* @returns NetworkError instance
|
|
212
|
-
*
|
|
213
|
-
* @example
|
|
214
|
-
* ```typescript
|
|
215
|
-
* try {
|
|
216
|
-
* await fetch(url);
|
|
217
|
-
* } catch (error) {
|
|
218
|
-
* throw createNetworkError(error);
|
|
219
|
-
* }
|
|
220
|
-
* ```
|
|
221
|
-
*/
|
|
222
|
-
declare function createNetworkError(error: any): NetworkError;
|
|
223
|
-
|
|
224
|
-
/**
|
|
225
|
-
* Supported blockchain chains in the SmoothSend SDK
|
|
226
|
-
*
|
|
227
|
-
* @remarks
|
|
228
|
-
* - `avalanche`: Avalanche C-Chain (EVM-compatible)
|
|
229
|
-
* - `aptos-testnet`: Aptos testnet
|
|
230
|
-
* - `aptos-mainnet`: Aptos mainnet
|
|
231
|
-
*/
|
|
232
|
-
type SupportedChain = 'avalanche' | 'aptos-testnet' | 'aptos-mainnet' | 'stellar-testnet' | 'stellar-mainnet';
|
|
233
|
-
/**
|
|
234
|
-
* Chain ecosystem types for routing to correct relayers
|
|
235
|
-
*
|
|
236
|
-
* @remarks
|
|
237
|
-
* - `evm`: Ethereum Virtual Machine compatible chains (Avalanche, Base, Arbitrum, etc.)
|
|
238
|
-
* - `aptos`: Aptos blockchain ecosystem
|
|
239
|
-
* - `stellar`: Stellar blockchain ecosystem
|
|
240
|
-
*/
|
|
241
|
-
type ChainEcosystem = 'evm' | 'aptos' | 'stellar';
|
|
242
|
-
/**
|
|
243
|
-
* Mapping of supported chains to their respective ecosystems
|
|
244
|
-
* Used internally for adapter selection and routing
|
|
245
|
-
*/
|
|
246
|
-
declare const CHAIN_ECOSYSTEM_MAP: Record<SupportedChain, ChainEcosystem>;
|
|
247
|
-
/**
|
|
248
|
-
* Base success response structure
|
|
249
|
-
* All successful API responses extend this interface
|
|
250
|
-
*/
|
|
251
|
-
interface SuccessResponse {
|
|
252
|
-
/** Indicates the request was successful */
|
|
253
|
-
success: true;
|
|
254
|
-
}
|
|
255
|
-
/**
|
|
256
|
-
* Base error response structure
|
|
257
|
-
* All error API responses extend this interface
|
|
258
|
-
*/
|
|
259
|
-
interface ErrorResponse {
|
|
260
|
-
/** Indicates the request failed */
|
|
261
|
-
success: false;
|
|
262
|
-
/** Human-readable error message */
|
|
263
|
-
error: string;
|
|
264
|
-
/** Additional error details or validation errors */
|
|
265
|
-
details?: string[];
|
|
266
|
-
/** Unique request identifier for debugging */
|
|
267
|
-
requestId?: string;
|
|
268
|
-
}
|
|
269
|
-
/**
|
|
270
|
-
* Chain information structure
|
|
271
|
-
* Contains metadata about a supported blockchain
|
|
272
|
-
*/
|
|
273
|
-
interface ChainInfo {
|
|
274
|
-
/** Chain identifier (e.g., 'aptos-testnet') */
|
|
275
|
-
name: string;
|
|
276
|
-
/** Human-readable chain name */
|
|
277
|
-
displayName: string;
|
|
278
|
-
/** Numeric chain ID */
|
|
279
|
-
chainId: number;
|
|
280
|
-
/** Block explorer base URL */
|
|
281
|
-
explorerUrl: string;
|
|
282
|
-
/** List of supported token symbols */
|
|
283
|
-
tokens: string[];
|
|
284
|
-
}
|
|
285
|
-
/**
|
|
286
|
-
* Token information structure
|
|
287
|
-
* Contains metadata about a supported token
|
|
288
|
-
*/
|
|
289
|
-
interface TokenInfo {
|
|
290
|
-
/** Token symbol (e.g., 'USDC') */
|
|
291
|
-
symbol: string;
|
|
292
|
-
/** Token contract address */
|
|
293
|
-
address: string;
|
|
294
|
-
/** Number of decimal places */
|
|
295
|
-
decimals: number;
|
|
296
|
-
/** Full token name */
|
|
297
|
-
name: string;
|
|
298
|
-
}
|
|
299
|
-
/**
|
|
300
|
-
* Chain configuration structure
|
|
301
|
-
* Complete configuration for a blockchain network
|
|
302
|
-
*/
|
|
303
|
-
interface ChainConfig {
|
|
304
|
-
/** Chain identifier */
|
|
305
|
-
name: string;
|
|
306
|
-
/** Human-readable chain name */
|
|
307
|
-
displayName: string;
|
|
308
|
-
/** Numeric chain ID */
|
|
309
|
-
chainId: number;
|
|
310
|
-
/** RPC endpoint URL */
|
|
311
|
-
rpcUrl: string;
|
|
312
|
-
/** Relayer service URL */
|
|
313
|
-
relayerUrl: string;
|
|
314
|
-
/** Block explorer base URL */
|
|
315
|
-
explorerUrl: string;
|
|
316
|
-
/** List of supported token symbols */
|
|
317
|
-
tokens: string[];
|
|
318
|
-
/** Native currency information */
|
|
319
|
-
nativeCurrency: {
|
|
320
|
-
/** Currency name */
|
|
321
|
-
name: string;
|
|
322
|
-
/** Currency symbol */
|
|
323
|
-
symbol: string;
|
|
324
|
-
/** Number of decimal places */
|
|
325
|
-
decimals: number;
|
|
326
|
-
};
|
|
327
|
-
}
|
|
328
|
-
/**
|
|
329
|
-
* Transfer request parameters
|
|
330
|
-
* Used to initiate a gasless token transfer
|
|
331
|
-
*
|
|
332
|
-
* @example
|
|
333
|
-
* ```typescript
|
|
334
|
-
* const request: TransferRequest = {
|
|
335
|
-
* from: '0x123...',
|
|
336
|
-
* to: '0x456...',
|
|
337
|
-
* token: 'USDC',
|
|
338
|
-
* amount: '1000000', // 1 USDC (6 decimals)
|
|
339
|
-
* chain: 'aptos-testnet'
|
|
340
|
-
* };
|
|
341
|
-
* ```
|
|
342
|
-
*/
|
|
343
|
-
interface TransferRequest {
|
|
344
|
-
/** Sender's wallet address */
|
|
345
|
-
from: string;
|
|
346
|
-
/** Recipient's wallet address */
|
|
347
|
-
to: string;
|
|
348
|
-
/** Token symbol or contract address */
|
|
349
|
-
token: string;
|
|
350
|
-
/** Amount in smallest unit (wei, octas, etc.) */
|
|
351
|
-
amount: string;
|
|
352
|
-
/** Target blockchain */
|
|
353
|
-
chain: SupportedChain;
|
|
354
|
-
}
|
|
355
|
-
/**
|
|
356
|
-
* Transfer quote response from API
|
|
357
|
-
* Contains fee information for a transfer
|
|
358
|
-
*/
|
|
359
|
-
interface TransferQuoteResponse extends SuccessResponse {
|
|
360
|
-
/** Chain identifier */
|
|
361
|
-
chainName: string;
|
|
362
|
-
/** Token symbol */
|
|
363
|
-
token: string;
|
|
364
|
-
/** Transfer amount */
|
|
365
|
-
amount: string;
|
|
366
|
-
/** Relayer fee amount */
|
|
367
|
-
relayerFee: string;
|
|
368
|
-
/** Total amount (amount + fee) */
|
|
369
|
-
total: string;
|
|
370
|
-
/** Fee as percentage of amount */
|
|
371
|
-
feePercentage: number;
|
|
372
|
-
/** Token contract address */
|
|
373
|
-
contractAddress: string;
|
|
374
|
-
}
|
|
375
|
-
/**
|
|
376
|
-
* Fee estimate response from proxy worker
|
|
377
|
-
* Contains detailed fee information for a transfer
|
|
378
|
-
*
|
|
379
|
-
* @remarks
|
|
380
|
-
* Returned by `estimateFee()` method
|
|
381
|
-
*/
|
|
382
|
-
interface FeeEstimate {
|
|
383
|
-
/** Fee charged by relayer in token units */
|
|
384
|
-
relayerFee: string;
|
|
385
|
-
/** Fee in USD for reference */
|
|
386
|
-
feeInUSD: string;
|
|
387
|
-
/** Full coin type identifier (e.g., '0x1::aptos_coin::AptosCoin') */
|
|
388
|
-
coinType: string;
|
|
389
|
-
/** Estimated gas units */
|
|
390
|
-
estimatedGas: string;
|
|
391
|
-
/** Network (testnet or mainnet) */
|
|
392
|
-
network: 'testnet' | 'mainnet';
|
|
393
|
-
}
|
|
394
|
-
/**
|
|
395
|
-
* Transfer quote information
|
|
396
|
-
* Contains fee breakdown and contract details
|
|
397
|
-
*/
|
|
398
|
-
interface TransferQuote {
|
|
399
|
-
/** Transfer amount */
|
|
400
|
-
amount: string;
|
|
401
|
-
/** Relayer fee amount */
|
|
402
|
-
relayerFee: string;
|
|
403
|
-
/** Total amount (amount + fee) */
|
|
404
|
-
total: string;
|
|
405
|
-
/** Fee as percentage of amount */
|
|
406
|
-
feePercentage: number;
|
|
407
|
-
/** Token contract address */
|
|
408
|
-
contractAddress: string;
|
|
409
|
-
/** Aptos-specific transaction data (optional for backward compatibility) */
|
|
410
|
-
aptosTransactionData?: any;
|
|
411
|
-
}
|
|
412
|
-
/**
|
|
413
|
-
* Relay transfer response from API
|
|
414
|
-
* Contains transaction execution details
|
|
415
|
-
*/
|
|
416
|
-
interface RelayTransferResponse extends SuccessResponse {
|
|
417
|
-
/** Unique transfer identifier */
|
|
418
|
-
transferId: string;
|
|
419
|
-
/** Transaction hash */
|
|
420
|
-
txHash: string;
|
|
421
|
-
/** Block number where transaction was included */
|
|
422
|
-
blockNumber: number;
|
|
423
|
-
/** Gas units consumed */
|
|
424
|
-
gasUsed: string;
|
|
425
|
-
/** Block explorer URL for transaction */
|
|
426
|
-
explorerUrl: string;
|
|
427
|
-
/** Fee paid for the transfer */
|
|
428
|
-
fee: string;
|
|
429
|
-
/** Execution time in milliseconds */
|
|
430
|
-
executionTime: number;
|
|
431
|
-
}
|
|
432
|
-
/**
|
|
433
|
-
* Transfer result structure
|
|
434
|
-
* Contains complete information about a transfer execution
|
|
435
|
-
*
|
|
436
|
-
* @remarks
|
|
437
|
-
* Returned by `executeGaslessTransfer()` and `transfer()` methods
|
|
438
|
-
*
|
|
439
|
-
* @example
|
|
440
|
-
* ```typescript
|
|
441
|
-
* const result = await sdk.executeGaslessTransfer(signedData);
|
|
442
|
-
* console.log(`Transaction: ${result.txHash}`);
|
|
443
|
-
* console.log(`Explorer: ${result.explorerUrl}`);
|
|
444
|
-
* console.log(`Rate limit remaining: ${result.metadata?.rateLimit.remaining}`);
|
|
445
|
-
* ```
|
|
446
|
-
*/
|
|
447
|
-
interface TransferResult {
|
|
448
|
-
/** Indicates if transfer was successful */
|
|
449
|
-
success: boolean;
|
|
450
|
-
/** Transaction hash */
|
|
451
|
-
txHash: string;
|
|
452
|
-
/** Block number where transaction was included */
|
|
453
|
-
blockNumber?: number;
|
|
454
|
-
/** Gas units consumed */
|
|
455
|
-
gasUsed?: string;
|
|
456
|
-
/** Unique transfer identifier */
|
|
457
|
-
transferId?: string;
|
|
458
|
-
/** Block explorer URL for transaction */
|
|
459
|
-
explorerUrl?: string;
|
|
460
|
-
/** Fee paid for the transfer */
|
|
461
|
-
fee?: string;
|
|
462
|
-
/** Execution time in milliseconds */
|
|
463
|
-
executionTime?: number;
|
|
464
|
-
/** Address that paid the gas fee (Aptos-specific) */
|
|
465
|
-
gasFeePaidBy?: string;
|
|
466
|
-
/** Whether user paid in APT (Aptos-specific) */
|
|
467
|
-
userPaidAPT?: boolean;
|
|
468
|
-
/** Transparency information (Aptos-specific) */
|
|
469
|
-
transparency?: string;
|
|
470
|
-
/** VM execution status (Aptos-specific) */
|
|
471
|
-
vmStatus?: string;
|
|
472
|
-
/** Sender address (Aptos-specific) */
|
|
473
|
-
sender?: string;
|
|
474
|
-
/** Chain identifier (Aptos-specific) */
|
|
475
|
-
chain?: string;
|
|
476
|
-
/** Relayer fee amount (Aptos-specific) */
|
|
477
|
-
relayerFee?: string;
|
|
478
|
-
/** Additional message or status information */
|
|
479
|
-
message?: string;
|
|
480
|
-
/** Usage metadata from proxy worker (v2) */
|
|
481
|
-
metadata?: UsageMetadata;
|
|
482
|
-
}
|
|
483
|
-
/**
|
|
484
|
-
* Batch transfer request parameters
|
|
485
|
-
* Used to execute multiple transfers in a single transaction
|
|
486
|
-
*
|
|
487
|
-
* @remarks
|
|
488
|
-
* Batch transfers are more gas-efficient than individual transfers
|
|
489
|
-
*/
|
|
490
|
-
interface BatchTransferRequest {
|
|
491
|
-
/** Array of transfer requests to execute */
|
|
492
|
-
transfers: TransferRequest[];
|
|
493
|
-
/** Target blockchain */
|
|
494
|
-
chain: SupportedChain;
|
|
495
|
-
}
|
|
496
|
-
/**
|
|
497
|
-
* EVM transfer data structure
|
|
498
|
-
* Contains signed transfer data for EVM-compatible chains
|
|
499
|
-
*
|
|
500
|
-
* @remarks
|
|
501
|
-
* Used for Avalanche and other EVM chains
|
|
502
|
-
*/
|
|
503
|
-
interface EVMTransferData {
|
|
504
|
-
/** Chain identifier */
|
|
505
|
-
chainName: string;
|
|
506
|
-
/** Sender address */
|
|
507
|
-
from: string;
|
|
508
|
-
/** Recipient address */
|
|
509
|
-
to: string;
|
|
510
|
-
/** Token symbol */
|
|
511
|
-
tokenSymbol: string;
|
|
512
|
-
/** Transfer amount */
|
|
513
|
-
amount: string;
|
|
514
|
-
/** Relayer fee amount */
|
|
515
|
-
relayerFee: string;
|
|
516
|
-
/** Transaction nonce */
|
|
517
|
-
nonce: string;
|
|
518
|
-
/** Signature deadline timestamp */
|
|
519
|
-
deadline: number;
|
|
520
|
-
/** EIP-712 signature */
|
|
521
|
-
signature: string;
|
|
522
|
-
/** ERC-2612 permit data (optional) */
|
|
523
|
-
permitData?: {
|
|
524
|
-
/** Permit value */
|
|
525
|
-
value: string;
|
|
526
|
-
/** Permit deadline */
|
|
527
|
-
deadline: number;
|
|
528
|
-
/** Signature v component */
|
|
529
|
-
v: number;
|
|
530
|
-
/** Signature r component */
|
|
531
|
-
r: string;
|
|
532
|
-
/** Signature s component */
|
|
533
|
-
s: string;
|
|
534
|
-
};
|
|
535
|
-
}
|
|
536
|
-
/**
|
|
537
|
-
* Legacy type alias for Avalanche transfers
|
|
538
|
-
* @deprecated Use EVMTransferData instead
|
|
539
|
-
*/
|
|
540
|
-
type AvalancheTransferData = EVMTransferData;
|
|
541
|
-
/**
|
|
542
|
-
* Aptos transfer data structure
|
|
543
|
-
* Contains serialized transaction data for secure Aptos transfers
|
|
544
|
-
*
|
|
545
|
-
* @remarks
|
|
546
|
-
* Uses serialized transaction approach for enhanced security
|
|
547
|
-
* Transaction must be built and signed by wallet before submission
|
|
548
|
-
*
|
|
549
|
-
* @example
|
|
550
|
-
* ```typescript
|
|
551
|
-
* const aptosData: AptosTransferData = {
|
|
552
|
-
* transactionBytes: Array.from(signedTx.transactionBytes),
|
|
553
|
-
* authenticatorBytes: Array.from(signedTx.authenticatorBytes)
|
|
554
|
-
* };
|
|
555
|
-
* ```
|
|
556
|
-
*/
|
|
557
|
-
interface AptosTransferData {
|
|
558
|
-
/** Serialized SimpleTransaction as byte array */
|
|
559
|
-
transactionBytes: number[];
|
|
560
|
-
/** Serialized AccountAuthenticator as byte array */
|
|
561
|
-
authenticatorBytes: number[];
|
|
562
|
-
/** Optional function name for debugging/tracking */
|
|
563
|
-
functionName?: string;
|
|
564
|
-
/** Sender address (optional metadata) */
|
|
565
|
-
fromAddress?: string;
|
|
566
|
-
/** Recipient address (optional metadata) */
|
|
567
|
-
toAddress?: string;
|
|
568
|
-
/** Transfer amount (optional metadata) */
|
|
569
|
-
amount?: string;
|
|
570
|
-
/** Coin type identifier (optional metadata) */
|
|
571
|
-
coinType?: string;
|
|
572
|
-
}
|
|
573
|
-
/**
|
|
574
|
-
* EIP-712 signature data structure
|
|
575
|
-
* Contains typed data for signature verification
|
|
576
|
-
*/
|
|
577
|
-
interface SignatureData {
|
|
578
|
-
/** EIP-712 domain separator */
|
|
579
|
-
domain: any;
|
|
580
|
-
/** Type definitions */
|
|
581
|
-
types: any;
|
|
582
|
-
/** Message to sign */
|
|
583
|
-
message: any;
|
|
584
|
-
/** Primary type name */
|
|
585
|
-
primaryType: string;
|
|
586
|
-
/** Enhanced metadata for signature verification */
|
|
587
|
-
metadata?: {
|
|
588
|
-
/** Target chain */
|
|
589
|
-
chain?: SupportedChain;
|
|
590
|
-
/** Sender address */
|
|
591
|
-
fromAddress?: string;
|
|
592
|
-
/** Recipient address */
|
|
593
|
-
toAddress?: string;
|
|
594
|
-
/** Transfer amount */
|
|
595
|
-
amount?: string;
|
|
596
|
-
/** Token symbol */
|
|
597
|
-
token?: string;
|
|
598
|
-
/** Relayer fee */
|
|
599
|
-
relayerFee?: string;
|
|
600
|
-
/** Signature version */
|
|
601
|
-
signatureVersion?: string;
|
|
602
|
-
/** Whether public key is required */
|
|
603
|
-
requiresPublicKey?: boolean;
|
|
604
|
-
/** Verification method */
|
|
605
|
-
verificationMethod?: string;
|
|
606
|
-
};
|
|
607
|
-
}
|
|
608
|
-
/**
|
|
609
|
-
* Signed transfer data for SDK v2
|
|
610
|
-
* Contains serialized transaction bytes for secure Aptos transfers
|
|
611
|
-
*
|
|
612
|
-
* @remarks
|
|
613
|
-
* Used with `executeGaslessTransfer()` method
|
|
614
|
-
* Transaction must be built and signed by wallet before creating this structure
|
|
615
|
-
*
|
|
616
|
-
* @example
|
|
617
|
-
* ```typescript
|
|
618
|
-
* const signedData: SignedTransferData = {
|
|
619
|
-
* transactionBytes: Array.from(signedTx.transactionBytes),
|
|
620
|
-
* authenticatorBytes: Array.from(signedTx.authenticatorBytes),
|
|
621
|
-
* chain: 'aptos-testnet',
|
|
622
|
-
* network: 'testnet'
|
|
623
|
-
* };
|
|
624
|
-
* const result = await sdk.executeGaslessTransfer(signedData);
|
|
625
|
-
* ```
|
|
626
|
-
*/
|
|
627
|
-
interface SignedTransferData {
|
|
628
|
-
/** Serialized transaction (Aptos) */
|
|
629
|
-
transactionBytes?: number[];
|
|
630
|
-
/** Serialized authenticator (Aptos) */
|
|
631
|
-
authenticatorBytes?: number[];
|
|
632
|
-
/** Signed XDR transaction (Stellar) */
|
|
633
|
-
signedTransaction?: string;
|
|
634
|
-
/** Target blockchain */
|
|
635
|
-
chain: SupportedChain;
|
|
636
|
-
/** Optional network override (testnet or mainnet) */
|
|
637
|
-
network?: 'testnet' | 'mainnet';
|
|
638
|
-
}
|
|
639
|
-
/**
|
|
640
|
-
* Token balance information
|
|
641
|
-
* Contains balance and metadata for a specific token
|
|
642
|
-
*/
|
|
643
|
-
interface TokenBalance {
|
|
644
|
-
/** Token symbol or address */
|
|
645
|
-
token: string;
|
|
646
|
-
/** Balance in smallest unit */
|
|
647
|
-
balance: string;
|
|
648
|
-
/** Number of decimal places */
|
|
649
|
-
decimals: number;
|
|
650
|
-
/** Token symbol */
|
|
651
|
-
symbol: string;
|
|
652
|
-
/** Full token name (optional) */
|
|
653
|
-
name?: string;
|
|
654
|
-
}
|
|
655
|
-
/**
|
|
656
|
-
* Transfer quote request parameters
|
|
657
|
-
* Used to request fee estimate from API
|
|
658
|
-
*/
|
|
659
|
-
interface TransferQuoteRequest {
|
|
660
|
-
/** Chain identifier */
|
|
661
|
-
chainName: string;
|
|
662
|
-
/** Token symbol */
|
|
663
|
-
token: string;
|
|
664
|
-
/** Transfer amount */
|
|
665
|
-
amount: string;
|
|
666
|
-
}
|
|
667
|
-
/**
|
|
668
|
-
* Prepare signature request parameters
|
|
669
|
-
* Used to get typed data for EIP-712 signature
|
|
670
|
-
*/
|
|
671
|
-
interface PrepareSignatureRequest {
|
|
672
|
-
/** Chain identifier */
|
|
673
|
-
chainName: string;
|
|
674
|
-
/** Sender address */
|
|
675
|
-
from: string;
|
|
676
|
-
/** Recipient address */
|
|
677
|
-
to: string;
|
|
678
|
-
/** Token symbol */
|
|
679
|
-
tokenSymbol: string;
|
|
680
|
-
/** Transfer amount */
|
|
681
|
-
amount: string;
|
|
682
|
-
/** Relayer fee amount */
|
|
683
|
-
relayerFee: string;
|
|
684
|
-
/** Transaction nonce */
|
|
685
|
-
nonce: string;
|
|
686
|
-
/** Signature deadline timestamp */
|
|
687
|
-
deadline: number;
|
|
688
|
-
}
|
|
689
|
-
/**
|
|
690
|
-
* Relay transfer request parameters
|
|
691
|
-
* Used to submit signed transfer to relayer
|
|
692
|
-
*/
|
|
693
|
-
interface RelayTransferRequest {
|
|
694
|
-
/** Chain identifier */
|
|
695
|
-
chainName: string;
|
|
696
|
-
/** Sender address */
|
|
697
|
-
from: string;
|
|
698
|
-
/** Recipient address */
|
|
699
|
-
to: string;
|
|
700
|
-
/** Token symbol */
|
|
701
|
-
tokenSymbol: string;
|
|
702
|
-
/** Transfer amount */
|
|
703
|
-
amount: string;
|
|
704
|
-
/** Relayer fee amount */
|
|
705
|
-
relayerFee: string;
|
|
706
|
-
/** Transaction nonce */
|
|
707
|
-
nonce: string;
|
|
708
|
-
/** Signature deadline timestamp */
|
|
709
|
-
deadline: number;
|
|
710
|
-
/** EIP-712 signature */
|
|
711
|
-
signature: string;
|
|
712
|
-
/** ERC-2612 permit data (optional) */
|
|
713
|
-
permitData?: PermitData;
|
|
714
|
-
}
|
|
715
|
-
/**
|
|
716
|
-
* Batch relay transfer request parameters
|
|
717
|
-
* Used to submit multiple signed transfers in one transaction
|
|
718
|
-
*/
|
|
719
|
-
interface BatchRelayTransferRequest {
|
|
720
|
-
/** Chain identifier */
|
|
721
|
-
chainName: string;
|
|
722
|
-
/** Array of transfer requests */
|
|
723
|
-
transfers: RelayTransferRequest[];
|
|
724
|
-
}
|
|
725
|
-
/**
|
|
726
|
-
* Gas estimate request parameters
|
|
727
|
-
* Used to estimate gas cost for transfers
|
|
728
|
-
*/
|
|
729
|
-
interface EstimateGasRequest {
|
|
730
|
-
/** Chain identifier */
|
|
731
|
-
chainName: string;
|
|
732
|
-
/** Array of transfer data */
|
|
733
|
-
transfers: TransferData[];
|
|
734
|
-
}
|
|
735
|
-
/**
|
|
736
|
-
* Transfer data structure
|
|
737
|
-
* Contains complete transfer information including signature
|
|
738
|
-
*/
|
|
739
|
-
interface TransferData {
|
|
740
|
-
/** Sender address */
|
|
741
|
-
from: string;
|
|
742
|
-
/** Recipient address */
|
|
743
|
-
to: string;
|
|
744
|
-
/** Token symbol or address */
|
|
745
|
-
token: string;
|
|
746
|
-
/** Transfer amount */
|
|
747
|
-
amount: string;
|
|
748
|
-
/** Relayer fee amount */
|
|
749
|
-
relayerFee: string;
|
|
750
|
-
/** Transaction nonce */
|
|
751
|
-
nonce: string;
|
|
752
|
-
/** Signature deadline timestamp */
|
|
753
|
-
deadline: number;
|
|
754
|
-
/** EIP-712 signature */
|
|
755
|
-
signature: string;
|
|
756
|
-
/** ERC-2612 permit data (optional) */
|
|
757
|
-
permitData?: PermitData;
|
|
758
|
-
}
|
|
759
|
-
/**
|
|
760
|
-
* ERC-2612 permit data structure
|
|
761
|
-
* Used for gasless token approvals
|
|
762
|
-
*/
|
|
763
|
-
interface PermitData {
|
|
764
|
-
/** Permit value (amount) */
|
|
765
|
-
value: string;
|
|
766
|
-
/** Permit deadline timestamp */
|
|
767
|
-
deadline: number;
|
|
768
|
-
/** Signature v component */
|
|
769
|
-
v: number;
|
|
770
|
-
/** Signature r component */
|
|
771
|
-
r: string;
|
|
772
|
-
/** Signature s component */
|
|
773
|
-
s: string;
|
|
774
|
-
}
|
|
775
|
-
/**
|
|
776
|
-
* Prepare signature response from API
|
|
777
|
-
* Contains EIP-712 typed data for signing
|
|
778
|
-
*/
|
|
779
|
-
interface PrepareSignatureResponse extends SuccessResponse {
|
|
780
|
-
/** EIP-712 typed data structure */
|
|
781
|
-
typedData: any;
|
|
782
|
-
/** Keccak256 hash of the message */
|
|
783
|
-
messageHash: string;
|
|
784
|
-
/** Human-readable message */
|
|
785
|
-
message: string;
|
|
786
|
-
}
|
|
787
|
-
/**
|
|
788
|
-
* Gas estimate response from API
|
|
789
|
-
* Contains estimated gas cost for transfers
|
|
790
|
-
*/
|
|
791
|
-
interface GasEstimateResponse extends SuccessResponse {
|
|
792
|
-
/** Chain identifier */
|
|
793
|
-
chainName: string;
|
|
794
|
-
/** Estimated gas units */
|
|
795
|
-
gasEstimate: string;
|
|
796
|
-
/** Current gas price */
|
|
797
|
-
gasPrice: string;
|
|
798
|
-
/** Estimated cost in native currency */
|
|
799
|
-
estimatedCost: string;
|
|
800
|
-
/** Number of transfers in batch */
|
|
801
|
-
transferCount: number;
|
|
802
|
-
}
|
|
803
|
-
/**
|
|
804
|
-
* Health check response
|
|
805
|
-
* Contains service health status information
|
|
806
|
-
*
|
|
807
|
-
* @remarks
|
|
808
|
-
* Returned by `getHealth()` and `getChainHealth()` methods
|
|
809
|
-
*/
|
|
810
|
-
interface HealthResponse extends SuccessResponse {
|
|
811
|
-
/** Service status (e.g., 'healthy', 'degraded') */
|
|
812
|
-
status: string;
|
|
813
|
-
/** Response timestamp (ISO 8601) */
|
|
814
|
-
timestamp: string;
|
|
815
|
-
/** Service version */
|
|
816
|
-
version: string;
|
|
817
|
-
}
|
|
818
|
-
/**
|
|
819
|
-
* Domain separator response from API
|
|
820
|
-
* Contains EIP-712 domain separator for a chain
|
|
821
|
-
*/
|
|
822
|
-
interface DomainSeparatorResponse extends SuccessResponse {
|
|
823
|
-
/** Chain identifier */
|
|
824
|
-
chainName: string;
|
|
825
|
-
/** EIP-712 domain separator hash */
|
|
826
|
-
domainSeparator: string;
|
|
827
|
-
}
|
|
828
|
-
/**
|
|
829
|
-
* Transfer status response from API
|
|
830
|
-
* Contains execution status of a transfer
|
|
831
|
-
*/
|
|
832
|
-
interface TransferStatusResponse extends SuccessResponse {
|
|
833
|
-
/** Chain identifier */
|
|
834
|
-
chainName: string;
|
|
835
|
-
/** Transfer transaction hash */
|
|
836
|
-
transferHash: string;
|
|
837
|
-
/** Whether transfer has been executed */
|
|
838
|
-
executed: boolean;
|
|
839
|
-
}
|
|
840
|
-
/**
|
|
841
|
-
* Aptos-specific error codes
|
|
842
|
-
* Used for detailed error handling in Aptos adapter
|
|
843
|
-
*
|
|
844
|
-
* @remarks
|
|
845
|
-
* Error codes are prefixed with APTOS_ for easy identification
|
|
846
|
-
*/
|
|
847
|
-
declare const APTOS_ERROR_CODES: {
|
|
848
|
-
/** Missing signature in request */
|
|
849
|
-
readonly MISSING_SIGNATURE: "APTOS_MISSING_SIGNATURE";
|
|
850
|
-
/** Missing public key for verification */
|
|
851
|
-
readonly MISSING_PUBLIC_KEY: "APTOS_MISSING_PUBLIC_KEY";
|
|
852
|
-
/** Invalid signature format */
|
|
853
|
-
readonly INVALID_SIGNATURE_FORMAT: "APTOS_INVALID_SIGNATURE_FORMAT";
|
|
854
|
-
/** Invalid public key format */
|
|
855
|
-
readonly INVALID_PUBLIC_KEY_FORMAT: "APTOS_INVALID_PUBLIC_KEY_FORMAT";
|
|
856
|
-
/** Address doesn't match public key */
|
|
857
|
-
readonly ADDRESS_MISMATCH: "APTOS_ADDRESS_MISMATCH";
|
|
858
|
-
/** Signature verification failed */
|
|
859
|
-
readonly SIGNATURE_VERIFICATION_FAILED: "APTOS_SIGNATURE_VERIFICATION_FAILED";
|
|
860
|
-
/** Missing transaction data */
|
|
861
|
-
readonly MISSING_TRANSACTION_DATA: "APTOS_MISSING_TRANSACTION_DATA";
|
|
862
|
-
/** Invalid transaction format */
|
|
863
|
-
readonly INVALID_TRANSACTION_FORMAT: "APTOS_INVALID_TRANSACTION_FORMAT";
|
|
864
|
-
/** Empty address provided */
|
|
865
|
-
readonly EMPTY_ADDRESS: "APTOS_EMPTY_ADDRESS";
|
|
866
|
-
/** Invalid address format */
|
|
867
|
-
readonly INVALID_ADDRESS_FORMAT: "APTOS_INVALID_ADDRESS_FORMAT";
|
|
868
|
-
/** Error fetching quote */
|
|
869
|
-
readonly QUOTE_ERROR: "APTOS_QUOTE_ERROR";
|
|
870
|
-
/** Error executing transfer */
|
|
871
|
-
readonly EXECUTE_ERROR: "APTOS_EXECUTE_ERROR";
|
|
872
|
-
/** Error fetching balance */
|
|
873
|
-
readonly BALANCE_ERROR: "APTOS_BALANCE_ERROR";
|
|
874
|
-
/** Error fetching token info */
|
|
875
|
-
readonly TOKEN_INFO_ERROR: "APTOS_TOKEN_INFO_ERROR";
|
|
876
|
-
/** Error checking status */
|
|
877
|
-
readonly STATUS_ERROR: "APTOS_STATUS_ERROR";
|
|
878
|
-
/** Error calling Move function */
|
|
879
|
-
readonly MOVE_CALL_ERROR: "APTOS_MOVE_CALL_ERROR";
|
|
880
|
-
/** Unsupported token */
|
|
881
|
-
readonly UNSUPPORTED_TOKEN: "APTOS_UNSUPPORTED_TOKEN";
|
|
882
|
-
};
|
|
883
|
-
/**
|
|
884
|
-
* Type for Aptos error codes
|
|
885
|
-
* Ensures type safety when using error codes
|
|
886
|
-
*/
|
|
887
|
-
type AptosErrorCode = typeof APTOS_ERROR_CODES[keyof typeof APTOS_ERROR_CODES];
|
|
888
|
-
/**
|
|
889
|
-
* Stellar adapter error codes
|
|
890
|
-
*/
|
|
891
|
-
declare const STELLAR_ERROR_CODES: {
|
|
892
|
-
readonly MISSING_SIGNED_TRANSACTION: "STELLAR_MISSING_SIGNED_TRANSACTION";
|
|
893
|
-
readonly GASLESS_TRANSACTION_ERROR: "STELLAR_GASLESS_TRANSACTION_ERROR";
|
|
894
|
-
readonly STATUS_ERROR: "STELLAR_STATUS_ERROR";
|
|
895
|
-
readonly HEALTH_ERROR: "STELLAR_HEALTH_ERROR";
|
|
896
|
-
readonly INVALID_ADDRESS_FORMAT: "STELLAR_INVALID_ADDRESS_FORMAT";
|
|
897
|
-
};
|
|
898
|
-
/**
|
|
899
|
-
* Generic API response structure
|
|
900
|
-
* Used for all API responses with optional data payload
|
|
901
|
-
*
|
|
902
|
-
* @typeParam T - Type of the response data
|
|
903
|
-
*
|
|
904
|
-
* @example
|
|
905
|
-
* ```typescript
|
|
906
|
-
* const response: ApiResponse<TransferResult> = await api.transfer(data);
|
|
907
|
-
* if (response.success && response.data) {
|
|
908
|
-
* console.log('Transfer successful:', response.data.txHash);
|
|
909
|
-
* }
|
|
910
|
-
* ```
|
|
911
|
-
*/
|
|
912
|
-
interface ApiResponse<T = any> {
|
|
913
|
-
/** Indicates if request was successful */
|
|
914
|
-
success: boolean;
|
|
915
|
-
/** Response data (present on success) */
|
|
916
|
-
data?: T;
|
|
917
|
-
/** Error message (present on failure) */
|
|
918
|
-
error?: string;
|
|
919
|
-
/** Additional error details */
|
|
920
|
-
details?: string[];
|
|
921
|
-
/** Unique request identifier */
|
|
922
|
-
requestId?: string;
|
|
923
|
-
/** Error code for programmatic handling */
|
|
924
|
-
errorCode?: string;
|
|
925
|
-
/** Chain where request was made */
|
|
926
|
-
chain?: SupportedChain;
|
|
927
|
-
/** Response timestamp (ISO 8601) */
|
|
928
|
-
timestamp?: string;
|
|
929
|
-
/** Usage metadata from proxy worker (v2) */
|
|
930
|
-
metadata?: UsageMetadata;
|
|
931
|
-
}
|
|
932
|
-
/**
|
|
933
|
-
* SDK configuration for v2 - Proxy-based architecture
|
|
934
|
-
*
|
|
935
|
-
* @remarks
|
|
936
|
-
* All requests route through proxy.smoothsend.xyz with API key authentication
|
|
937
|
-
*
|
|
938
|
-
* @example
|
|
939
|
-
* ```typescript
|
|
940
|
-
* const config: SmoothSendConfig = {
|
|
941
|
-
* apiKey: 'no_gas_abc123...',
|
|
942
|
-
* network: 'testnet',
|
|
943
|
-
* timeout: 30000,
|
|
944
|
-
* retries: 3
|
|
945
|
-
* };
|
|
946
|
-
* const sdk = new SmoothSendSDK(config);
|
|
947
|
-
* ```
|
|
948
|
-
*/
|
|
949
|
-
interface SmoothSendConfig {
|
|
950
|
-
/** API key with no_gas_ prefix for authentication (required) */
|
|
951
|
-
apiKey: string;
|
|
952
|
-
/** Network to use: testnet or mainnet (default: testnet) */
|
|
953
|
-
network?: 'testnet' | 'mainnet';
|
|
954
|
-
/** Request timeout in milliseconds (default: 30000) */
|
|
955
|
-
timeout?: number;
|
|
956
|
-
/** Maximum retry attempts for failed requests (default: 3) */
|
|
957
|
-
retries?: number;
|
|
958
|
-
/** Additional headers to include in requests */
|
|
959
|
-
customHeaders?: Record<string, string>;
|
|
960
|
-
}
|
|
961
|
-
/**
|
|
962
|
-
* Usage metadata from proxy worker response headers
|
|
963
|
-
* Contains rate limiting and usage tracking information
|
|
964
|
-
*
|
|
965
|
-
* @remarks
|
|
966
|
-
* Attached to all transfer results and available via `getUsageStats()`
|
|
967
|
-
*
|
|
968
|
-
* @example
|
|
969
|
-
* ```typescript
|
|
970
|
-
* const result = await sdk.transfer(request, wallet);
|
|
971
|
-
* console.log('Rate limit:', result.metadata?.rateLimit);
|
|
972
|
-
* console.log('Monthly usage:', result.metadata?.monthly);
|
|
973
|
-
*
|
|
974
|
-
* // Check if approaching limits
|
|
975
|
-
* if (parseInt(result.metadata.rateLimit.remaining) < 2) {
|
|
976
|
-
* console.warn('Approaching rate limit!');
|
|
977
|
-
* }
|
|
978
|
-
* ```
|
|
979
|
-
*/
|
|
980
|
-
interface UsageMetadata {
|
|
981
|
-
/** Rate limit information (per minute) */
|
|
982
|
-
rateLimit: {
|
|
983
|
-
/** Maximum requests per minute */
|
|
984
|
-
limit: string;
|
|
985
|
-
/** Remaining requests this minute */
|
|
986
|
-
remaining: string;
|
|
987
|
-
/** When rate limit resets (ISO 8601 timestamp) */
|
|
988
|
-
reset: string;
|
|
989
|
-
};
|
|
990
|
-
/** Monthly usage information */
|
|
991
|
-
monthly: {
|
|
992
|
-
/** Total monthly request limit */
|
|
993
|
-
limit: string;
|
|
994
|
-
/** Requests used this month */
|
|
995
|
-
usage: string;
|
|
996
|
-
/** Remaining requests this month */
|
|
997
|
-
remaining: string;
|
|
998
|
-
};
|
|
999
|
-
/** Unique request identifier for debugging */
|
|
1000
|
-
requestId: string;
|
|
1001
|
-
}
|
|
1002
|
-
/**
|
|
1003
|
-
* Aptos wallet interface for sdk.transfer()
|
|
1004
|
-
*/
|
|
1005
|
-
interface AptosWallet {
|
|
1006
|
-
buildTransaction: (params: {
|
|
1007
|
-
sender: string;
|
|
1008
|
-
recipient: string;
|
|
1009
|
-
amount: string;
|
|
1010
|
-
coinType: string;
|
|
1011
|
-
relayerFee: string;
|
|
1012
|
-
}) => Promise<any>;
|
|
1013
|
-
signTransaction: (transaction: any) => Promise<{
|
|
1014
|
-
transactionBytes: number[];
|
|
1015
|
-
authenticatorBytes: number[];
|
|
1016
|
-
}>;
|
|
1017
|
-
}
|
|
1018
|
-
/**
|
|
1019
|
-
* Stellar wallet interface for sdk.transfer()
|
|
1020
|
-
* Use with Freighter, Stellar Wallets Kit, or any Stellar-compatible wallet
|
|
1021
|
-
*/
|
|
1022
|
-
interface StellarWallet {
|
|
1023
|
-
buildTransaction: (params: {
|
|
1024
|
-
from: string;
|
|
1025
|
-
to: string;
|
|
1026
|
-
amount: string;
|
|
1027
|
-
token: string;
|
|
1028
|
-
}) => Promise<any>;
|
|
1029
|
-
signTransaction: (transaction: any) => Promise<string>;
|
|
1030
|
-
}
|
|
1031
|
-
/**
|
|
1032
|
-
* Transfer event types
|
|
1033
|
-
* Emitted during transfer lifecycle for monitoring and debugging
|
|
1034
|
-
*/
|
|
1035
|
-
interface TransferEvent {
|
|
1036
|
-
/** Event type */
|
|
1037
|
-
type: 'transfer_initiated' | 'transfer_signed' | 'transfer_submitted' | 'transfer_confirmed' | 'transfer_failed';
|
|
1038
|
-
/** Event data (varies by type) */
|
|
1039
|
-
data: any;
|
|
1040
|
-
/** Event timestamp (Unix milliseconds) */
|
|
1041
|
-
timestamp: number;
|
|
1042
|
-
/** Chain where event occurred */
|
|
1043
|
-
chain: SupportedChain;
|
|
1044
|
-
}
|
|
1045
|
-
/**
|
|
1046
|
-
* Event listener callback function
|
|
1047
|
-
* Called when transfer events are emitted
|
|
1048
|
-
*
|
|
1049
|
-
* @param event - Transfer event object
|
|
1050
|
-
*
|
|
1051
|
-
* @example
|
|
1052
|
-
* ```typescript
|
|
1053
|
-
* const listener: EventListener = (event) => {
|
|
1054
|
-
* console.log(`Event: ${event.type} on ${event.chain}`);
|
|
1055
|
-
* };
|
|
1056
|
-
* sdk.addEventListener(listener);
|
|
1057
|
-
* ```
|
|
1058
|
-
*/
|
|
1059
|
-
type EventListener = (event: TransferEvent) => void;
|
|
1060
|
-
/**
|
|
1061
|
-
* Chain Adapter Interface - v2 Proxy Architecture
|
|
1062
|
-
*
|
|
1063
|
-
* @remarks
|
|
1064
|
-
* All adapters route requests through proxy.smoothsend.xyz with API key authentication.
|
|
1065
|
-
* The proxy handles relayer URL routing, so adapters no longer need direct relayer configuration.
|
|
1066
|
-
*
|
|
1067
|
-
* Key changes from v1:
|
|
1068
|
-
* - Removed `config` property (relayer URLs handled by proxy)
|
|
1069
|
-
* - Simplified to core methods: estimateFee, executeGaslessTransfer
|
|
1070
|
-
* - Removed getQuote, prepareTransfer, getNonce, getTokenInfo (not needed for proxy flow)
|
|
1071
|
-
* - Network parameter (testnet/mainnet) passed via HTTP headers, not method parameters
|
|
1072
|
-
* - Client-side validation methods remain for address and amount validation
|
|
1073
|
-
*
|
|
1074
|
-
* Design rationale:
|
|
1075
|
-
* - Consistent interface across all chains
|
|
1076
|
-
* - Minimal surface area - only essential methods
|
|
1077
|
-
* - Async by default for all I/O operations
|
|
1078
|
-
* - Client-side validation done locally without network calls
|
|
1079
|
-
* - Wallet libraries handle balance queries and transaction building
|
|
1080
|
-
*
|
|
1081
|
-
* @example
|
|
1082
|
-
* ```typescript
|
|
1083
|
-
* class MyChainAdapter implements IChainAdapter {
|
|
1084
|
-
* readonly chain: SupportedChain = 'aptos-testnet';
|
|
1085
|
-
*
|
|
1086
|
-
* async estimateFee(request: TransferRequest): Promise<FeeEstimate> {
|
|
1087
|
-
* // Implementation
|
|
1088
|
-
* }
|
|
1089
|
-
*
|
|
1090
|
-
* async executeGaslessTransfer(signedData: SignedTransferData): Promise<TransferResult> {
|
|
1091
|
-
* // Implementation
|
|
1092
|
-
* }
|
|
1093
|
-
*
|
|
1094
|
-
* // ... other methods
|
|
1095
|
-
* }
|
|
1096
|
-
* ```
|
|
1097
|
-
*/
|
|
1098
|
-
interface IChainAdapter {
|
|
1099
|
-
/** Chain identifier this adapter handles */
|
|
1100
|
-
readonly chain: SupportedChain;
|
|
1101
|
-
/**
|
|
1102
|
-
* Estimate fee for a transfer
|
|
1103
|
-
*
|
|
1104
|
-
* @param request - Transfer request parameters
|
|
1105
|
-
* @returns Fee estimate with relayer fee and gas information
|
|
1106
|
-
* @throws {ValidationError} If request parameters are invalid
|
|
1107
|
-
* @throws {NetworkError} If unable to reach proxy/relayer
|
|
1108
|
-
*
|
|
1109
|
-
* @example
|
|
1110
|
-
* ```typescript
|
|
1111
|
-
* const estimate = await adapter.estimateFee({
|
|
1112
|
-
* from: '0x123...',
|
|
1113
|
-
* to: '0x456...',
|
|
1114
|
-
* token: 'USDC',
|
|
1115
|
-
* amount: '1000000',
|
|
1116
|
-
* chain: 'aptos-testnet'
|
|
1117
|
-
* });
|
|
1118
|
-
* console.log('Fee:', estimate.relayerFee);
|
|
1119
|
-
* ```
|
|
1120
|
-
*/
|
|
1121
|
-
estimateFee(request: TransferRequest): Promise<FeeEstimate>;
|
|
1122
|
-
/**
|
|
1123
|
-
* Execute a gasless transfer with signed transaction data
|
|
1124
|
-
*
|
|
1125
|
-
* @param signedData - Signed transfer data with serialized transaction
|
|
1126
|
-
* @returns Transfer result with transaction hash and metadata
|
|
1127
|
-
* @throws {AuthenticationError} If API key is invalid
|
|
1128
|
-
* @throws {RateLimitError} If rate limit is exceeded
|
|
1129
|
-
* @throws {ValidationError} If signed data is invalid
|
|
1130
|
-
* @throws {NetworkError} If unable to reach proxy/relayer
|
|
1131
|
-
*
|
|
1132
|
-
* @example
|
|
1133
|
-
* ```typescript
|
|
1134
|
-
* const result = await adapter.executeGaslessTransfer({
|
|
1135
|
-
* transactionBytes: [1, 2, 3, ...],
|
|
1136
|
-
* authenticatorBytes: [4, 5, 6, ...],
|
|
1137
|
-
* chain: 'aptos-testnet',
|
|
1138
|
-
* network: 'testnet'
|
|
1139
|
-
* });
|
|
1140
|
-
* console.log('Transaction:', result.txHash);
|
|
1141
|
-
* ```
|
|
1142
|
-
*/
|
|
1143
|
-
executeGaslessTransfer(signedData: SignedTransferData): Promise<TransferResult>;
|
|
1144
|
-
/**
|
|
1145
|
-
* Get transaction status by hash
|
|
1146
|
-
*
|
|
1147
|
-
* @param txHash - Transaction hash to query
|
|
1148
|
-
* @returns Transaction status information
|
|
1149
|
-
* @throws {ValidationError} If transaction hash is invalid
|
|
1150
|
-
* @throws {NetworkError} If unable to reach proxy/relayer
|
|
1151
|
-
*
|
|
1152
|
-
* @example
|
|
1153
|
-
* ```typescript
|
|
1154
|
-
* const status = await adapter.getTransactionStatus('0xabc123...');
|
|
1155
|
-
* console.log('Status:', status);
|
|
1156
|
-
* ```
|
|
1157
|
-
*/
|
|
1158
|
-
getTransactionStatus(txHash: string): Promise<any>;
|
|
1159
|
-
/**
|
|
1160
|
-
* Check health status of the chain's relayer
|
|
1161
|
-
*
|
|
1162
|
-
* @returns Health response with status and version
|
|
1163
|
-
* @throws {NetworkError} If unable to reach proxy/relayer
|
|
1164
|
-
*
|
|
1165
|
-
* @example
|
|
1166
|
-
* ```typescript
|
|
1167
|
-
* const health = await adapter.getHealth();
|
|
1168
|
-
* console.log('Status:', health.status);
|
|
1169
|
-
* ```
|
|
1170
|
-
*/
|
|
1171
|
-
getHealth(): Promise<HealthResponse>;
|
|
1172
|
-
/**
|
|
1173
|
-
* Validate address format (client-side, no network call)
|
|
1174
|
-
*
|
|
1175
|
-
* @param address - Address to validate
|
|
1176
|
-
* @returns true if address format is valid, false otherwise
|
|
1177
|
-
*
|
|
1178
|
-
* @example
|
|
1179
|
-
* ```typescript
|
|
1180
|
-
* const isValid = adapter.validateAddress('0x123...');
|
|
1181
|
-
* if (!isValid) {
|
|
1182
|
-
* console.error('Invalid address format');
|
|
1183
|
-
* }
|
|
1184
|
-
* ```
|
|
1185
|
-
*/
|
|
1186
|
-
validateAddress(address: string): boolean;
|
|
1187
|
-
/**
|
|
1188
|
-
* Validate amount format (client-side, no network call)
|
|
1189
|
-
*
|
|
1190
|
-
* @param amount - Amount to validate (in smallest unit)
|
|
1191
|
-
* @returns true if amount format is valid, false otherwise
|
|
1192
|
-
*
|
|
1193
|
-
* @example
|
|
1194
|
-
* ```typescript
|
|
1195
|
-
* const isValid = adapter.validateAmount('1000000');
|
|
1196
|
-
* if (!isValid) {
|
|
1197
|
-
* console.error('Invalid amount format');
|
|
1198
|
-
* }
|
|
1199
|
-
* ```
|
|
1200
|
-
*/
|
|
1201
|
-
validateAmount(amount: string): boolean;
|
|
1202
|
-
}
|
|
1203
|
-
|
|
1204
|
-
declare class SmoothSendSDK {
|
|
1205
|
-
private adapters;
|
|
1206
|
-
private eventListeners;
|
|
1207
|
-
private config;
|
|
1208
|
-
private keyType;
|
|
1209
|
-
private hasWarnedAboutSecretKey;
|
|
1210
|
-
constructor(config: SmoothSendConfig);
|
|
1211
|
-
/**
|
|
1212
|
-
* Detect key type from API key prefix
|
|
1213
|
-
* Supports pk_nogas_* (public), sk_nogas_* (secret), and no_gas_* (legacy)
|
|
1214
|
-
*/
|
|
1215
|
-
private detectKeyType;
|
|
1216
|
-
/**
|
|
1217
|
-
* Check if running in browser environment
|
|
1218
|
-
* Used for conditional warnings and Origin header logic
|
|
1219
|
-
*/
|
|
1220
|
-
private isBrowserEnvironment;
|
|
1221
|
-
/**
|
|
1222
|
-
* Warn if secret key is used in browser environment
|
|
1223
|
-
* Only warns once per SDK instance
|
|
1224
|
-
*/
|
|
1225
|
-
private warnIfSecretKeyInBrowser;
|
|
1226
|
-
/**
|
|
1227
|
-
* Determine if Origin header should be included in requests
|
|
1228
|
-
* Include Origin header only for public keys in browser environment
|
|
1229
|
-
*/
|
|
1230
|
-
private shouldIncludeOrigin;
|
|
1231
|
-
/**
|
|
1232
|
-
* Get or create adapter for a specific chain on-demand
|
|
1233
|
-
*/
|
|
1234
|
-
private getOrCreateAdapter;
|
|
1235
|
-
addEventListener(listener: EventListener): void;
|
|
1236
|
-
removeEventListener(listener: EventListener): void;
|
|
1237
|
-
private emitEvent;
|
|
1238
|
-
estimateFee(request: TransferRequest): Promise<FeeEstimate & {
|
|
1239
|
-
metadata?: UsageMetadata;
|
|
1240
|
-
}>;
|
|
1241
|
-
/**
|
|
1242
|
-
* Submit a signed Stellar transaction (XDR) for gasless relay.
|
|
1243
|
-
* Use when you've already built and signed the transaction.
|
|
1244
|
-
*
|
|
1245
|
-
* @example
|
|
1246
|
-
* const signedXdr = await stellarWallet.signTransaction(tx);
|
|
1247
|
-
* const result = await sdk.submitStellarTransaction(signedXdr);
|
|
1248
|
-
*/
|
|
1249
|
-
submitStellarTransaction(signedXdr: string): Promise<TransferResult>;
|
|
1250
|
-
executeGaslessTransfer(signedData: SignedTransferData): Promise<TransferResult>;
|
|
1251
|
-
/**
|
|
1252
|
-
* Convenience method for complete transfer flow
|
|
1253
|
-
* Works for both Aptos and Stellar - same 3-line API.
|
|
1254
|
-
*
|
|
1255
|
-
* @param request Transfer request with from, to, token, amount, chain
|
|
1256
|
-
* @param wallet Aptos or Stellar wallet provider
|
|
1257
|
-
* @returns Transfer result with transaction hash and usage metadata
|
|
1258
|
-
*
|
|
1259
|
-
* Aptos wallet: signTransaction returns { transactionBytes, authenticatorBytes }
|
|
1260
|
-
* Stellar wallet: signTransaction returns string (signed XDR)
|
|
1261
|
-
*/
|
|
1262
|
-
transfer(request: TransferRequest, wallet: AptosWallet | StellarWallet): Promise<TransferResult>;
|
|
1263
|
-
private transferStellar;
|
|
1264
|
-
/**
|
|
1265
|
-
* Get transaction status for a specific transaction
|
|
1266
|
-
* Routes through proxy to chain-specific status endpoint
|
|
1267
|
-
*
|
|
1268
|
-
* @param chain Chain where the transaction was executed
|
|
1269
|
-
* @param txHash Transaction hash to query
|
|
1270
|
-
* @returns Transaction status information
|
|
1271
|
-
* @throws SmoothSendError if chain is not supported or status check fails
|
|
1272
|
-
*
|
|
1273
|
-
* @example
|
|
1274
|
-
* ```typescript
|
|
1275
|
-
* const status = await sdk.getTransactionStatus('aptos-testnet', '0x123...');
|
|
1276
|
-
* console.log('Transaction status:', status);
|
|
1277
|
-
* ```
|
|
1278
|
-
*/
|
|
1279
|
-
getTransactionStatus(chain: SupportedChain, txHash: string): Promise<any>;
|
|
1280
|
-
validateAddress(chain: SupportedChain, address: string): boolean;
|
|
1281
|
-
validateAmount(chain: SupportedChain, amount: string): boolean;
|
|
1282
|
-
/**
|
|
1283
|
-
* Check proxy worker health status
|
|
1284
|
-
* Routes directly to proxy's /health endpoint (not chain-specific)
|
|
1285
|
-
*
|
|
1286
|
-
* @returns Health response with status, version, and timestamp
|
|
1287
|
-
* @throws NetworkError if proxy is unavailable
|
|
1288
|
-
* @throws SmoothSendError for other errors
|
|
1289
|
-
*
|
|
1290
|
-
* @example
|
|
1291
|
-
* ```typescript
|
|
1292
|
-
* try {
|
|
1293
|
-
* const health = await sdk.getHealth();
|
|
1294
|
-
* console.log('Proxy status:', health.status);
|
|
1295
|
-
* console.log('Version:', health.version);
|
|
1296
|
-
* } catch (error) {
|
|
1297
|
-
* if (error instanceof NetworkError) {
|
|
1298
|
-
* console.error('Proxy unavailable. Please retry later.');
|
|
1299
|
-
* }
|
|
1300
|
-
* }
|
|
1301
|
-
* ```
|
|
1302
|
-
*/
|
|
1303
|
-
getHealth(): Promise<HealthResponse>;
|
|
1304
|
-
/**
|
|
1305
|
-
* Get list of supported chains (static list)
|
|
1306
|
-
* For dynamic list from proxy, use getSupportedChainsFromProxy()
|
|
1307
|
-
*
|
|
1308
|
-
* @returns Array of supported chain identifiers
|
|
1309
|
-
*
|
|
1310
|
-
* @example
|
|
1311
|
-
* ```typescript
|
|
1312
|
-
* const chains = sdk.getSupportedChains();
|
|
1313
|
-
* console.log('Supported chains:', chains);
|
|
1314
|
-
* // Output: ['aptos-testnet', 'aptos-mainnet']
|
|
1315
|
-
* ```
|
|
1316
|
-
*/
|
|
1317
|
-
getSupportedChains(): SupportedChain[];
|
|
1318
|
-
/**
|
|
1319
|
-
* Get list of supported chains from proxy worker (dynamic)
|
|
1320
|
-
* Queries the proxy for the current list of supported chains
|
|
1321
|
-
*
|
|
1322
|
-
* @returns Promise with array of chain information including status
|
|
1323
|
-
* @throws SmoothSendError if unable to fetch chains from proxy
|
|
1324
|
-
*
|
|
1325
|
-
* @example
|
|
1326
|
-
* ```typescript
|
|
1327
|
-
* const chains = await sdk.getSupportedChainsFromProxy();
|
|
1328
|
-
* chains.forEach(chain => {
|
|
1329
|
-
* console.log(`${chain.name} (${chain.id}): ${chain.status}`);
|
|
1330
|
-
* });
|
|
1331
|
-
* ```
|
|
1332
|
-
*/
|
|
1333
|
-
getSupportedChainsFromProxy(): Promise<Array<{
|
|
1334
|
-
id: string;
|
|
1335
|
-
name: string;
|
|
1336
|
-
ecosystem: string;
|
|
1337
|
-
network: string;
|
|
1338
|
-
status: string;
|
|
1339
|
-
}>>;
|
|
1340
|
-
/**
|
|
1341
|
-
* Check if a specific chain is currently supported
|
|
1342
|
-
*
|
|
1343
|
-
* @param chain Chain identifier to check
|
|
1344
|
-
* @returns true if chain is supported, false otherwise
|
|
1345
|
-
*
|
|
1346
|
-
* @example
|
|
1347
|
-
* ```typescript
|
|
1348
|
-
* if (sdk.isChainSupported('aptos-testnet')) {
|
|
1349
|
-
* console.log('Aptos testnet is supported');
|
|
1350
|
-
* } else {
|
|
1351
|
-
* console.log('Chain not supported');
|
|
1352
|
-
* }
|
|
1353
|
-
* ```
|
|
1354
|
-
*/
|
|
1355
|
-
isChainSupported(chain: string): boolean;
|
|
1356
|
-
/**
|
|
1357
|
-
* Check health status of a specific chain's relayer
|
|
1358
|
-
* Routes through proxy to chain-specific health endpoint
|
|
1359
|
-
*
|
|
1360
|
-
* @param chain Chain identifier to check
|
|
1361
|
-
* @returns Health response for the specific chain
|
|
1362
|
-
* @throws SmoothSendError if chain is not supported or health check fails
|
|
1363
|
-
*
|
|
1364
|
-
* @example
|
|
1365
|
-
* ```typescript
|
|
1366
|
-
* try {
|
|
1367
|
-
* const health = await sdk.getChainHealth('aptos-testnet');
|
|
1368
|
-
* console.log('Aptos testnet status:', health.status);
|
|
1369
|
-
* } catch (error) {
|
|
1370
|
-
* console.error('Chain health check failed:', error.message);
|
|
1371
|
-
* }
|
|
1372
|
-
* ```
|
|
1373
|
-
*/
|
|
1374
|
-
getChainHealth(chain: SupportedChain): Promise<HealthResponse>;
|
|
1375
|
-
/**
|
|
1376
|
-
* Get current usage statistics without making a transfer
|
|
1377
|
-
* Makes a lightweight health check request to retrieve usage metadata
|
|
1378
|
-
*
|
|
1379
|
-
* @returns Usage metadata with rate limit and monthly usage information
|
|
1380
|
-
* @throws Error if unable to retrieve usage stats
|
|
1381
|
-
*
|
|
1382
|
-
* @example
|
|
1383
|
-
* ```typescript
|
|
1384
|
-
* const usage = await sdk.getUsageStats();
|
|
1385
|
-
* console.log('Rate limit:', usage.rateLimit);
|
|
1386
|
-
* console.log('Monthly usage:', usage.monthly);
|
|
1387
|
-
* console.log('Request ID:', usage.requestId);
|
|
1388
|
-
*
|
|
1389
|
-
* // Check if approaching limits
|
|
1390
|
-
* if (parseInt(usage.rateLimit.remaining) < 2) {
|
|
1391
|
-
* console.warn('Approaching rate limit!');
|
|
1392
|
-
* }
|
|
1393
|
-
* ```
|
|
1394
|
-
*/
|
|
1395
|
-
getUsageStats(): Promise<UsageMetadata>;
|
|
1396
|
-
/**
|
|
1397
|
-
* Extract request ID from a transfer result for debugging and support
|
|
1398
|
-
*
|
|
1399
|
-
* @param result Transfer result from executeGaslessTransfer or transfer
|
|
1400
|
-
* @returns Request ID if available, undefined otherwise
|
|
1401
|
-
*
|
|
1402
|
-
* @example
|
|
1403
|
-
* ```typescript
|
|
1404
|
-
* const result = await sdk.executeGaslessTransfer(signedData);
|
|
1405
|
-
* const requestId = sdk.getRequestId(result);
|
|
1406
|
-
* if (requestId) {
|
|
1407
|
-
* console.log('Request ID for support:', requestId);
|
|
1408
|
-
* }
|
|
1409
|
-
* ```
|
|
1410
|
-
*/
|
|
1411
|
-
getRequestId(result: TransferResult): string | undefined;
|
|
1412
|
-
/**
|
|
1413
|
-
* Check if approaching rate limit based on transfer result metadata
|
|
1414
|
-
*
|
|
1415
|
-
* @param result Transfer result with metadata
|
|
1416
|
-
* @param threshold Percentage threshold (0-100) to consider as "approaching" (default: 20)
|
|
1417
|
-
* @returns true if remaining requests are below threshold percentage
|
|
1418
|
-
*
|
|
1419
|
-
* @example
|
|
1420
|
-
* ```typescript
|
|
1421
|
-
* const result = await sdk.transfer(request, wallet);
|
|
1422
|
-
* if (sdk.isApproachingRateLimit(result)) {
|
|
1423
|
-
* console.warn('Approaching rate limit, consider slowing down requests');
|
|
1424
|
-
* }
|
|
1425
|
-
* ```
|
|
1426
|
-
*/
|
|
1427
|
-
isApproachingRateLimit(result: TransferResult, threshold?: number): boolean;
|
|
1428
|
-
/**
|
|
1429
|
-
* Check if approaching monthly usage limit based on transfer result metadata
|
|
1430
|
-
*
|
|
1431
|
-
* @param result Transfer result with metadata
|
|
1432
|
-
* @param threshold Percentage threshold (0-100) to consider as "approaching" (default: 90)
|
|
1433
|
-
* @returns true if monthly usage is above threshold percentage
|
|
1434
|
-
*
|
|
1435
|
-
* @example
|
|
1436
|
-
* ```typescript
|
|
1437
|
-
* const result = await sdk.transfer(request, wallet);
|
|
1438
|
-
* if (sdk.isApproachingMonthlyLimit(result)) {
|
|
1439
|
-
* console.warn('Approaching monthly limit, consider upgrading plan');
|
|
1440
|
-
* }
|
|
1441
|
-
* ```
|
|
1442
|
-
*/
|
|
1443
|
-
isApproachingMonthlyLimit(result: TransferResult, threshold?: number): boolean;
|
|
1444
|
-
/**
|
|
1445
|
-
* Check if a chain belongs to a specific ecosystem
|
|
1446
|
-
*/
|
|
1447
|
-
getChainEcosystem(chain: SupportedChain): ChainEcosystem;
|
|
1448
|
-
/**
|
|
1449
|
-
* Get list of supported chains (static method)
|
|
1450
|
-
* Can be called without instantiating the SDK
|
|
1451
|
-
*
|
|
1452
|
-
* @returns Array of supported chain identifiers
|
|
1453
|
-
*
|
|
1454
|
-
* @example
|
|
1455
|
-
* ```typescript
|
|
1456
|
-
* const chains = SmoothSendSDK.getSupportedChains();
|
|
1457
|
-
* console.log('Supported chains:', chains);
|
|
1458
|
-
* ```
|
|
1459
|
-
*/
|
|
1460
|
-
static getSupportedChains(): SupportedChain[];
|
|
1461
|
-
}
|
|
1462
|
-
|
|
1463
|
-
/**
|
|
1464
|
-
* SmoothSend Transaction Submitter
|
|
1465
|
-
*
|
|
1466
|
-
* A TransactionSubmitter implementation that integrates with the Aptos Wallet Adapter
|
|
1467
|
-
* to enable gasless transactions via SmoothSend's relayer network.
|
|
1468
|
-
*
|
|
1469
|
-
* @example
|
|
1470
|
-
* ```typescript
|
|
1471
|
-
* import { SmoothSendTransactionSubmitter } from '@smoothsend/sdk';
|
|
1472
|
-
* import { AptosWalletAdapterProvider } from '@aptos-labs/wallet-adapter-react';
|
|
1473
|
-
*
|
|
1474
|
-
* // Create the transaction submitter
|
|
1475
|
-
* const transactionSubmitter = new SmoothSendTransactionSubmitter({
|
|
1476
|
-
* apiKey: 'pk_nogas_your_api_key_here',
|
|
1477
|
-
* network: 'testnet'
|
|
1478
|
-
* });
|
|
1479
|
-
*
|
|
1480
|
-
* // Use in your wallet provider - that's it!
|
|
1481
|
-
* <AptosWalletAdapterProvider
|
|
1482
|
-
* dappConfig={{
|
|
1483
|
-
* network: Network.TESTNET,
|
|
1484
|
-
* transactionSubmitter: transactionSubmitter
|
|
1485
|
-
* }}
|
|
1486
|
-
* >
|
|
1487
|
-
* <App />
|
|
1488
|
-
* </AptosWalletAdapterProvider>
|
|
1489
|
-
* ```
|
|
1490
|
-
*/
|
|
1491
|
-
|
|
1492
|
-
/**
|
|
1493
|
-
* Configuration options for SmoothSendTransactionSubmitter
|
|
1494
|
-
*/
|
|
1495
|
-
interface SmoothSendTransactionSubmitterConfig {
|
|
1496
|
-
/**
|
|
1497
|
-
* Your SmoothSend API key
|
|
1498
|
-
* - Use `pk_nogas_*` for frontend applications (CORS protected)
|
|
1499
|
-
* - Use `sk_nogas_*` for backend applications only
|
|
1500
|
-
*/
|
|
1501
|
-
apiKey: string;
|
|
1502
|
-
/**
|
|
1503
|
-
* Network to use
|
|
1504
|
-
* @default 'testnet'
|
|
1505
|
-
*/
|
|
1506
|
-
network?: 'testnet' | 'mainnet';
|
|
1507
|
-
/**
|
|
1508
|
-
* Gateway URL (usually you don't need to change this)
|
|
1509
|
-
* @default 'https://proxy.smoothsend.xyz'
|
|
1510
|
-
*/
|
|
1511
|
-
gatewayUrl?: string;
|
|
1512
|
-
/**
|
|
1513
|
-
* Request timeout in milliseconds
|
|
1514
|
-
* @default 30000
|
|
1515
|
-
*/
|
|
1516
|
-
timeout?: number;
|
|
1517
|
-
/**
|
|
1518
|
-
* A function that returns a captcha token (e.g. from Cloudflare Turnstile or reCAPTCHA).
|
|
1519
|
-
* Called before each transaction if the project requires captcha verification.
|
|
1520
|
-
* Return null/undefined to skip captcha.
|
|
1521
|
-
*/
|
|
1522
|
-
getCaptchaToken?: () => Promise<string | null | undefined>;
|
|
1523
|
-
/**
|
|
1524
|
-
* Enable debug logging
|
|
1525
|
-
* @default false
|
|
1526
|
-
*/
|
|
1527
|
-
debug?: boolean;
|
|
1528
|
-
/**
|
|
1529
|
-
* Enable session key mode — user signs once, all subsequent transactions
|
|
1530
|
-
* are signed silently by an in-memory session key. Zero wallet popups after setup.
|
|
1531
|
-
*
|
|
1532
|
-
* Uses Aptos Account Abstraction (AIP-103 Permissioned Signers) — enforced on-chain.
|
|
1533
|
-
* Live on mainnet and testnet (as of April 2025).
|
|
1534
|
-
* SmoothSend pays gas for the one-time session setup transaction too.
|
|
1535
|
-
*
|
|
1536
|
-
* @default false
|
|
1537
|
-
*
|
|
1538
|
-
* @example
|
|
1539
|
-
* ```typescript
|
|
1540
|
-
* const smoothSend = new SmoothSendTransactionSubmitter({
|
|
1541
|
-
* apiKey: 'pk_nogas_xxx',
|
|
1542
|
-
* network: 'mainnet',
|
|
1543
|
-
* session: true,
|
|
1544
|
-
* });
|
|
1545
|
-
* ```
|
|
1546
|
-
*/
|
|
1547
|
-
session?: boolean;
|
|
1548
|
-
/**
|
|
1549
|
-
* How long the session key stays valid.
|
|
1550
|
-
* Format: number + unit (s, m, h, d)
|
|
1551
|
-
* Use "never" for client-side indefinite session validity.
|
|
1552
|
-
* @default '24h'
|
|
1553
|
-
*/
|
|
1554
|
-
sessionDuration?: string;
|
|
1555
|
-
}
|
|
1556
|
-
/**
|
|
1557
|
-
* TransactionSubmitter interface compatible with @aptos-labs/ts-sdk v2.x
|
|
1558
|
-
* This interface allows the SmoothSendTransactionSubmitter to work as a drop-in
|
|
1559
|
-
* replacement for the default transaction submitter in the Aptos Wallet Adapter.
|
|
1560
|
-
*/
|
|
1561
|
-
interface TransactionSubmitter {
|
|
1562
|
-
submitTransaction(args: {
|
|
1563
|
-
aptosConfig: AptosConfig;
|
|
1564
|
-
transaction: AnyRawTransaction;
|
|
1565
|
-
senderAuthenticator: AccountAuthenticator;
|
|
1566
|
-
feePayerAuthenticator?: AccountAuthenticator;
|
|
1567
|
-
additionalSignersAuthenticators?: Array<AccountAuthenticator>;
|
|
1568
|
-
pluginParams?: Record<string, unknown>;
|
|
1569
|
-
}): Promise<PendingTransactionResponse>;
|
|
1570
|
-
}
|
|
1571
|
-
/**
|
|
1572
|
-
* SmoothSend Transaction Submitter
|
|
1573
|
-
*
|
|
1574
|
-
* Implements the TransactionSubmitter interface to enable gasless transactions
|
|
1575
|
-
* through the Aptos Wallet Adapter. Simply pass this to your AptosWalletAdapterProvider
|
|
1576
|
-
* and all transactions will automatically be submitted as gasless through SmoothSend.
|
|
1577
|
-
*/
|
|
1578
|
-
declare class SmoothSendTransactionSubmitter implements TransactionSubmitter {
|
|
1579
|
-
private readonly apiKey;
|
|
1580
|
-
private readonly network;
|
|
1581
|
-
private readonly gatewayUrl;
|
|
1582
|
-
private readonly timeout;
|
|
1583
|
-
private readonly getCaptchaToken?;
|
|
1584
|
-
private readonly debug;
|
|
1585
|
-
readonly sessionEnabled: boolean;
|
|
1586
|
-
private readonly sessionDuration;
|
|
1587
|
-
private _session;
|
|
1588
|
-
constructor(config: SmoothSendTransactionSubmitterConfig);
|
|
1589
|
-
/**
|
|
1590
|
-
* Whether a valid session is currently active.
|
|
1591
|
-
*/
|
|
1592
|
-
hasSession(): boolean;
|
|
1593
|
-
/**
|
|
1594
|
-
* Create a session key for the given master account.
|
|
1595
|
-
* Called once by useSmoothSend when session: true and no session exists.
|
|
1596
|
-
* SmoothSend pays gas for the setup transaction.
|
|
1597
|
-
*
|
|
1598
|
-
* @param masterAccount - The user's wallet account (from wallet adapter)
|
|
1599
|
-
*/
|
|
1600
|
-
createSession(masterAccount: Account): Promise<void>;
|
|
1601
|
-
private isPermissionedSignerEnabled;
|
|
1602
|
-
private signSenderAuthenticator;
|
|
1603
|
-
/**
|
|
1604
|
-
* Submit a transaction using the active session key — no wallet popup.
|
|
1605
|
-
* Called by useSmoothSend after session is established.
|
|
1606
|
-
*/
|
|
1607
|
-
submitWithSession(functionName: `${string}::${string}::${string}`, functionArguments?: any[], typeArguments?: string[]): Promise<PendingTransactionResponse>;
|
|
1608
|
-
private _parseDuration;
|
|
1609
|
-
/**
|
|
1610
|
-
* Submit a transaction through SmoothSend's gasless relayer
|
|
1611
|
-
*
|
|
1612
|
-
* This method is called automatically by the Aptos Wallet Adapter when
|
|
1613
|
-
* you use signAndSubmitTransaction. The transaction is submitted to
|
|
1614
|
-
* SmoothSend's relayer which sponsors the gas fees.
|
|
1615
|
-
*/
|
|
1616
|
-
submitTransaction(args: {
|
|
1617
|
-
aptosConfig: AptosConfig;
|
|
1618
|
-
transaction: AnyRawTransaction;
|
|
1619
|
-
senderAuthenticator: AccountAuthenticator;
|
|
1620
|
-
feePayerAuthenticator?: AccountAuthenticator;
|
|
1621
|
-
additionalSignersAuthenticators?: Array<AccountAuthenticator>;
|
|
1622
|
-
pluginParams?: Record<string, unknown>;
|
|
1623
|
-
}): Promise<PendingTransactionResponse>;
|
|
1624
|
-
/**
|
|
1625
|
-
* Resolve the effective network from aptosConfig.
|
|
1626
|
-
* aptosConfig.network is the source of truth set by AptosWalletAdapterProvider.
|
|
1627
|
-
*/
|
|
1628
|
-
private resolveNetwork;
|
|
1629
|
-
/**
|
|
1630
|
-
* Make an HTTP request to the SmoothSend gateway
|
|
1631
|
-
*/
|
|
1632
|
-
private makeRequest;
|
|
1633
|
-
private sponsoredFunctionsCache;
|
|
1634
|
-
private sponsoredFunctionsCacheAt;
|
|
1635
|
-
private readonly SPONSORED_CACHE_TTL;
|
|
1636
|
-
/**
|
|
1637
|
-
* Fetch the list of sponsored functions for this API key's project.
|
|
1638
|
-
* Results are cached for 5 minutes. Returns ['*'] if all functions are sponsored.
|
|
1639
|
-
*/
|
|
1640
|
-
getSponsoredFunctions(): Promise<string[]>;
|
|
1641
|
-
/**
|
|
1642
|
-
* Check if a specific function is sponsored for gasless execution.
|
|
1643
|
-
* @param functionName - Full function identifier, e.g. "0x123::module::function"
|
|
1644
|
-
*/
|
|
1645
|
-
isSponsored(functionName: string): Promise<boolean>;
|
|
1646
|
-
/**
|
|
1647
|
-
*/
|
|
1648
|
-
getConfig(): Readonly<SmoothSendTransactionSubmitterConfig>;
|
|
1649
|
-
}
|
|
1650
|
-
/**
|
|
1651
|
-
* Create a SmoothSend transaction submitter with minimal configuration
|
|
1652
|
-
*
|
|
1653
|
-
* @example
|
|
1654
|
-
* ```typescript
|
|
1655
|
-
* const submitter = createSmoothSendSubmitter('pk_nogas_your_key');
|
|
1656
|
-
* ```
|
|
1657
|
-
*/
|
|
1658
|
-
declare function createSmoothSendSubmitter(apiKey: string, options?: Partial<Omit<SmoothSendTransactionSubmitterConfig, 'apiKey'>>): SmoothSendTransactionSubmitter;
|
|
1659
|
-
|
|
1660
|
-
/**
|
|
1661
|
-
* useSmoothSend — React hook for automatic gasless / user-pays-gas routing
|
|
1662
|
-
*
|
|
1663
|
-
* Drop-in replacement for useWallet()'s signAndSubmitTransaction.
|
|
1664
|
-
* Fetches the project's sponsored-functions list from the gateway on mount
|
|
1665
|
-
* and routes each transaction automatically:
|
|
1666
|
-
* - Function in allowlist → fee-payer gasless path via SmoothSend
|
|
1667
|
-
* - Function not in allowlist → regular wallet submission (user pays gas)
|
|
1668
|
-
*
|
|
1669
|
-
* When submitter has session: true, the first transaction triggers a one-time
|
|
1670
|
-
* wallet sign to register a session key on-chain. Every transaction after that
|
|
1671
|
-
* is signed silently — zero wallet popups.
|
|
1672
|
-
*
|
|
1673
|
-
* Requires: react >=17, @aptos-labs/wallet-adapter-react >=3, @aptos-labs/ts-sdk >=1
|
|
1674
|
-
*
|
|
1675
|
-
* @example
|
|
1676
|
-
* ```tsx
|
|
1677
|
-
* // Replace useWallet() with useSmoothSend() where you submit transactions.
|
|
1678
|
-
* // No other changes needed.
|
|
1679
|
-
*
|
|
1680
|
-
* const { signAndSubmitTransaction } = useSmoothSend(submitter);
|
|
1681
|
-
* await signAndSubmitTransaction({ data: { function: '0x1::coin::transfer', functionArguments: [to, amount] } });
|
|
1682
|
-
* ```
|
|
1683
|
-
*/
|
|
1684
|
-
|
|
1685
|
-
interface UseSmoothSendResult {
|
|
1686
|
-
/**
|
|
1687
|
-
* Smart signAndSubmitTransaction — same signature as the wallet adapter's version.
|
|
1688
|
-
* Sponsored functions go gasless via SmoothSend; others fall back to user-pays-gas.
|
|
1689
|
-
* With session: true, zero wallet popups after the first transaction.
|
|
1690
|
-
*/
|
|
1691
|
-
signAndSubmitTransaction: (input: {
|
|
1692
|
-
data: any;
|
|
1693
|
-
options?: any;
|
|
1694
|
-
}) => Promise<any>;
|
|
1695
|
-
/**
|
|
1696
|
-
* Whether a session key is currently active (only relevant when session: true).
|
|
1697
|
-
* Updates reactively when session is created or expires.
|
|
1698
|
-
*/
|
|
1699
|
-
hasSession: boolean;
|
|
1700
|
-
}
|
|
1701
|
-
declare function useSmoothSend(submitter: SmoothSendTransactionSubmitter): UseSmoothSendResult;
|
|
1702
|
-
|
|
1703
|
-
/**
|
|
1704
|
-
* AVAX / ERC-4337 v0.7 types aligned with `chains/avax/bundler` API shapes.
|
|
1705
|
-
*/
|
|
1706
|
-
type AvaxSponsorshipMode = 'developer-sponsored' | 'user-pays-erc20';
|
|
1707
|
-
/** Unpacked UserOperation as accepted by the bundler JSON-RPC + paymaster/sign */
|
|
1708
|
-
interface UserOperationAvax {
|
|
1709
|
-
sender: string;
|
|
1710
|
-
nonce: string;
|
|
1711
|
-
factory?: string;
|
|
1712
|
-
factoryData?: string;
|
|
1713
|
-
initCode?: string;
|
|
1714
|
-
callData: string;
|
|
1715
|
-
callGasLimit?: string;
|
|
1716
|
-
verificationGasLimit?: string;
|
|
1717
|
-
preVerificationGas?: string;
|
|
1718
|
-
maxFeePerGas?: string;
|
|
1719
|
-
maxPriorityFeePerGas?: string;
|
|
1720
|
-
paymaster?: string;
|
|
1721
|
-
paymasterVerificationGasLimit?: string;
|
|
1722
|
-
paymasterPostOpGasLimit?: string;
|
|
1723
|
-
paymasterData?: string;
|
|
1724
|
-
accountGasLimits?: string;
|
|
1725
|
-
gasFees?: string;
|
|
1726
|
-
paymasterAndData?: string;
|
|
1727
|
-
/** Empty (`0x`) until the wallet/account signs the hash UserOp */
|
|
1728
|
-
signature: string;
|
|
1729
|
-
}
|
|
1730
|
-
interface GasEstimateAvax {
|
|
1731
|
-
preVerificationGas: string;
|
|
1732
|
-
verificationGasLimit: string;
|
|
1733
|
-
callGasLimit: string;
|
|
1734
|
-
paymasterVerificationGasLimit?: string;
|
|
1735
|
-
paymasterPostOpGasLimit?: string;
|
|
1736
|
-
}
|
|
1737
|
-
interface PaymasterSignRequestAvax {
|
|
1738
|
-
mode: AvaxSponsorshipMode;
|
|
1739
|
-
userOp: UserOperationAvax;
|
|
1740
|
-
token?: string;
|
|
1741
|
-
receiver?: string;
|
|
1742
|
-
precheckBalance?: boolean;
|
|
1743
|
-
prepaymentRequired?: boolean;
|
|
1744
|
-
allowAnyBundler?: boolean;
|
|
1745
|
-
sponsorUUID?: string;
|
|
1746
|
-
}
|
|
1747
|
-
interface PaymasterSignResponseAvax {
|
|
1748
|
-
success: boolean;
|
|
1749
|
-
requestId?: string;
|
|
1750
|
-
network?: string;
|
|
1751
|
-
paymasterAndData: string;
|
|
1752
|
-
paymasterData?: string;
|
|
1753
|
-
signature?: string;
|
|
1754
|
-
exchangeRate?: string;
|
|
1755
|
-
paymasterDataParts?: Record<string, string>;
|
|
1756
|
-
error?: string;
|
|
1757
|
-
}
|
|
1758
|
-
interface UserOperationReceiptAvax {
|
|
1759
|
-
userOpHash: string;
|
|
1760
|
-
sender: string;
|
|
1761
|
-
nonce: string;
|
|
1762
|
-
paymaster: string;
|
|
1763
|
-
success: boolean;
|
|
1764
|
-
actualGasCost: string;
|
|
1765
|
-
actualGasUsed: string;
|
|
1766
|
-
reason?: string;
|
|
1767
|
-
logs: unknown[];
|
|
1768
|
-
receipt: {
|
|
1769
|
-
transactionHash: string;
|
|
1770
|
-
blockNumber: number;
|
|
1771
|
-
blockHash: string;
|
|
1772
|
-
};
|
|
1773
|
-
}
|
|
1774
|
-
/** Partial UserOp before estimate/paymaster (signature optional, usually `0x` until wallet signs). */
|
|
1775
|
-
type SponsoredUserOpDraftAvax = Omit<UserOperationAvax, 'signature'> & {
|
|
1776
|
-
signature?: string;
|
|
1777
|
-
};
|
|
1778
|
-
|
|
1779
|
-
/**
|
|
1780
|
-
* Avalanche ERC-4337 (EntryPoint v0.7) via SmoothSend gateway — same idea as Aptos submitter.
|
|
1781
|
-
*
|
|
1782
|
-
* Minimal dApp flow:
|
|
1783
|
-
* ```ts
|
|
1784
|
-
* const avax = new SmoothSendAvaxSubmitter({ apiKey, network: 'testnet' });
|
|
1785
|
-
* await avax.submitSponsoredUserOperation({ userOp: draft, signUserOp: wallet.sign });
|
|
1786
|
-
* ```
|
|
1787
|
-
*/
|
|
1788
|
-
|
|
1789
|
-
/** Options for {@link SmoothSendAvaxSubmitter.submitSponsoredUserOperation} */
|
|
1790
|
-
interface SubmitSponsoredAvaxUserOpOptions {
|
|
1791
|
-
/** Sender must match your smart account; nonce/callData/fees from your app */
|
|
1792
|
-
userOp: SponsoredUserOpDraftAvax;
|
|
1793
|
-
/** Wallet / viem / ethers signs the UserOp hash your stack expects */
|
|
1794
|
-
signUserOp: (userOp: UserOperationAvax) => Promise<string>;
|
|
1795
|
-
mode?: AvaxSponsorshipMode;
|
|
1796
|
-
/** Defaults to first entry point from `eth_supportedEntryPoints` */
|
|
1797
|
-
entryPoint?: string;
|
|
1798
|
-
/** Extra `paymaster/sign` fields (`token`, `receiver`, …) for user-pays-ERC20 */
|
|
1799
|
-
paymaster?: Omit<PaymasterSignRequestAvax, 'mode' | 'userOp'>;
|
|
1800
|
-
/** @default true */
|
|
1801
|
-
waitForReceipt?: boolean;
|
|
1802
|
-
receiptPoll?: {
|
|
1803
|
-
pollMs?: number;
|
|
1804
|
-
timeoutMs?: number;
|
|
1805
|
-
};
|
|
1806
|
-
}
|
|
1807
|
-
interface SmoothSendAvaxSubmitterConfig {
|
|
1808
|
-
apiKey: string;
|
|
1809
|
-
network?: 'testnet' | 'mainnet';
|
|
1810
|
-
gatewayUrl?: string;
|
|
1811
|
-
timeout?: number;
|
|
1812
|
-
/**
|
|
1813
|
-
* Gateway chain routing bucket. Default `avalanche` matches `core/gateway` routing.
|
|
1814
|
-
*/
|
|
1815
|
-
chain?: string;
|
|
1816
|
-
/**
|
|
1817
|
-
* Public keys (`pk_nogas_*`) require an `Origin` header matching your project's allowed CORS origins.
|
|
1818
|
-
* Set this for Node/scripts (e.g. `http://localhost:5173`). Browsers send Origin automatically.
|
|
1819
|
-
*/
|
|
1820
|
-
corsOrigin?: string;
|
|
1821
|
-
}
|
|
1822
|
-
declare class SmoothSendAvaxSubmitter {
|
|
1823
|
-
private readonly config;
|
|
1824
|
-
private readonly http;
|
|
1825
|
-
private rpcId;
|
|
1826
|
-
constructor(config: SmoothSendAvaxSubmitterConfig);
|
|
1827
|
-
getConfig(): Readonly<SmoothSendAvaxSubmitterConfig>;
|
|
1828
|
-
/** Merge gas estimate fields into a partial UserOp */
|
|
1829
|
-
static applyGasEstimate(userOp: UserOperationAvax, gas: GasEstimateAvax): UserOperationAvax;
|
|
1830
|
-
/** Attach packed paymaster data returned from {@link paymasterSign} */
|
|
1831
|
-
static applyPaymasterAndData(userOp: UserOperationAvax, paymasterAndData: string): UserOperationAvax;
|
|
1832
|
-
getChainId(): Promise<string>;
|
|
1833
|
-
getSupportedEntryPoints(): Promise<string[]>;
|
|
1834
|
-
estimateUserOperationGas(userOp: UserOperationAvax, entryPoint: string): Promise<GasEstimateAvax>;
|
|
1835
|
-
sendUserOperation(userOp: UserOperationAvax, entryPoint: string): Promise<string>;
|
|
1836
|
-
getUserOperationReceipt(userOpHash: string): Promise<UserOperationReceiptAvax | null>;
|
|
1837
|
-
waitForUserOperationReceipt(userOpHash: string, options?: {
|
|
1838
|
-
pollMs?: number;
|
|
1839
|
-
timeoutMs?: number;
|
|
1840
|
-
}): Promise<UserOperationReceiptAvax | null>;
|
|
1841
|
-
paymasterSign(body: PaymasterSignRequestAvax): Promise<PaymasterSignResponseAvax>;
|
|
1842
|
-
getBundlerHealth(): Promise<unknown>;
|
|
1843
|
-
/**
|
|
1844
|
-
* One call: estimate gas → paymaster/sign → merge → your sign → send → (optional) wait for receipt.
|
|
1845
|
-
*/
|
|
1846
|
-
submitSponsoredUserOperation(opts: SubmitSponsoredAvaxUserOpOptions): Promise<{
|
|
1847
|
-
userOpHash: string;
|
|
1848
|
-
receipt: UserOperationReceiptAvax | null;
|
|
1849
|
-
}>;
|
|
1850
|
-
private rpc;
|
|
1851
|
-
}
|
|
1852
|
-
/**
|
|
1853
|
-
* @alias {@link SmoothSendAvaxSubmitter}
|
|
1854
|
-
*/
|
|
1855
|
-
declare const AvaxSubmitter: typeof SmoothSendAvaxSubmitter;
|
|
1856
|
-
declare function createSmoothSendAvaxSubmitter(config: SmoothSendAvaxSubmitterConfig): SmoothSendAvaxSubmitter;
|
|
1857
|
-
|
|
1858
|
-
/**
|
|
1859
|
-
* Viem helpers for ERC-4337 v0.7 + common smart-account `execute` encoding.
|
|
1860
|
-
* Peer dependency: `viem` (optional install).
|
|
1861
|
-
*/
|
|
1862
|
-
|
|
1863
|
-
/** Typical SimpleAccount-style `execute(dest,value,func)`. */
|
|
1864
|
-
declare const avaxExecuteAbi: readonly [{
|
|
1865
|
-
readonly name: "execute";
|
|
1866
|
-
readonly type: "function";
|
|
1867
|
-
readonly stateMutability: "nonpayable";
|
|
1868
|
-
readonly inputs: readonly [{
|
|
1869
|
-
readonly name: "dest";
|
|
1870
|
-
readonly type: "address";
|
|
1871
|
-
}, {
|
|
1872
|
-
readonly name: "value";
|
|
1873
|
-
readonly type: "uint256";
|
|
1874
|
-
}, {
|
|
1875
|
-
readonly name: "func";
|
|
1876
|
-
readonly type: "bytes";
|
|
1877
|
-
}];
|
|
1878
|
-
readonly outputs: readonly [];
|
|
1879
|
-
}];
|
|
1880
|
-
declare function encodeAvaxExecuteCalldata(to: Address, value: bigint, data?: Hex): Hex;
|
|
1881
|
-
/** Convert API UserOp → viem shape for {@link getUserOperationHash}. */
|
|
1882
|
-
declare function userOperationAvaxToViem(u: UserOperationAvax): UserOperation<'0.7'>;
|
|
1883
|
-
declare function hashUserOperationAvax(params: {
|
|
1884
|
-
chainId: number;
|
|
1885
|
-
entryPointAddress: Address;
|
|
1886
|
-
userOperation: UserOperationAvax;
|
|
1887
|
-
}): Hex;
|
|
1888
|
-
/** EntryPoint v0.7 `getNonce(sender, key)` with key `0`. */
|
|
1889
|
-
declare function readAvaxSenderNonce(params: {
|
|
1890
|
-
publicClient: PublicClient;
|
|
1891
|
-
entryPointAddress: Address;
|
|
1892
|
-
sender: Address;
|
|
1893
|
-
key?: bigint;
|
|
1894
|
-
}): Promise<bigint>;
|
|
1895
|
-
|
|
1896
|
-
/**
|
|
1897
|
-
* Standard SimpleAccountFactory (EntryPoint v0.7) helpers for counterfactual address + init calldata.
|
|
1898
|
-
*/
|
|
1899
|
-
|
|
1900
|
-
/** Minimal ABI for eth-infinitism–style SimpleAccountFactory. */
|
|
1901
|
-
declare const SIMPLE_ACCOUNT_FACTORY_ABI: readonly [{
|
|
1902
|
-
readonly inputs: readonly [{
|
|
1903
|
-
readonly name: "owner";
|
|
1904
|
-
readonly type: "address";
|
|
1905
|
-
}, {
|
|
1906
|
-
readonly name: "salt";
|
|
1907
|
-
readonly type: "uint256";
|
|
1908
|
-
}];
|
|
1909
|
-
readonly name: "createAccount";
|
|
1910
|
-
readonly outputs: readonly [{
|
|
1911
|
-
readonly name: "account";
|
|
1912
|
-
readonly type: "address";
|
|
1913
|
-
}];
|
|
1914
|
-
readonly stateMutability: "nonpayable";
|
|
1915
|
-
readonly type: "function";
|
|
1916
|
-
}, {
|
|
1917
|
-
readonly inputs: readonly [{
|
|
1918
|
-
readonly name: "owner";
|
|
1919
|
-
readonly type: "address";
|
|
1920
|
-
}, {
|
|
1921
|
-
readonly name: "salt";
|
|
1922
|
-
readonly type: "uint256";
|
|
1923
|
-
}];
|
|
1924
|
-
readonly name: "getAddress";
|
|
1925
|
-
readonly outputs: readonly [{
|
|
1926
|
-
readonly name: "";
|
|
1927
|
-
readonly type: "address";
|
|
1928
|
-
}];
|
|
1929
|
-
readonly stateMutability: "view";
|
|
1930
|
-
readonly type: "function";
|
|
1931
|
-
}];
|
|
1932
|
-
declare function predictSimpleAccountAddress(params: {
|
|
1933
|
-
publicClient: PublicClient;
|
|
1934
|
-
factory: Address;
|
|
1935
|
-
owner: Address;
|
|
1936
|
-
salt?: bigint;
|
|
1937
|
-
}): Promise<Address>;
|
|
1938
|
-
declare function encodeCreateAccountFactoryData(owner: Address, salt: bigint): Hex;
|
|
1939
|
-
|
|
1940
|
-
/**
|
|
1941
|
-
* Public gateway defaults for Avalanche AA (no API key).
|
|
1942
|
-
*/
|
|
1943
|
-
/** Canonical ERC-4337 EntryPoint v0.7 on Fuji / Avalanche C-Chain */
|
|
1944
|
-
declare const ENTRY_POINT_V07_ADDRESS: "0x0000000071727De22E5E9d8BAf0edAc6f37da032";
|
|
1945
|
-
type AvaxAaPublicDefaults = {
|
|
1946
|
-
success?: boolean;
|
|
1947
|
-
simpleAccountFactoryFuji: `0x${string}` | null;
|
|
1948
|
-
entryPointV07: typeof ENTRY_POINT_V07_ADDRESS;
|
|
1949
|
-
};
|
|
1950
|
-
/**
|
|
1951
|
-
* Fetch SimpleAccount factory hint from SmoothSend gateway (GET; no auth).
|
|
1952
|
-
* Ops configure {@link https://proxy.smoothsend.xyz} `AVAX_FUJI_SIMPLE_ACCOUNT_FACTORY`; until then this returns null.
|
|
1953
|
-
*/
|
|
1954
|
-
declare function fetchAvaxAaPublicDefaults(gatewayUrl?: string): Promise<AvaxAaPublicDefaults>;
|
|
1955
|
-
|
|
1956
|
-
type SmoothSendAvaxContextValue = {
|
|
1957
|
-
apiKey: string;
|
|
1958
|
-
network: 'testnet' | 'mainnet';
|
|
1959
|
-
/** Set when the SCW is already known. If you use `accountFactory`, you can omit this. */
|
|
1960
|
-
smartAccountAddress?: Address;
|
|
1961
|
-
/**
|
|
1962
|
-
* SimpleAccountFactory (v0.7). When set, the hook derives the counterfactual sender via
|
|
1963
|
-
* `getAddress(owner, salt)` and, if the account has no code, adds `factory` + `factoryData` so the
|
|
1964
|
-
* first sponsored UserOp deploys the SCW and runs `callData` in the same op.
|
|
1965
|
-
*/
|
|
1966
|
-
accountFactory?: Address;
|
|
1967
|
-
accountSalt?: bigint;
|
|
1968
|
-
};
|
|
1969
|
-
declare function SmoothSendAvaxProvider({ apiKey, network, smartAccountAddress, accountFactory, accountSalt, children, }: {
|
|
1970
|
-
apiKey: string;
|
|
1971
|
-
network?: 'testnet' | 'mainnet';
|
|
1972
|
-
smartAccountAddress?: Address;
|
|
1973
|
-
accountFactory?: Address;
|
|
1974
|
-
accountSalt?: bigint;
|
|
1975
|
-
children: ReactNode;
|
|
1976
|
-
}): react_jsx_runtime.JSX.Element;
|
|
1977
|
-
declare function useSmoothSendAvaxContext(): SmoothSendAvaxContextValue | null;
|
|
1978
|
-
type UseSmoothSendAvaxParams = {
|
|
1979
|
-
apiKey?: string;
|
|
1980
|
-
network?: 'testnet' | 'mainnet';
|
|
1981
|
-
smartAccountAddress?: Address;
|
|
1982
|
-
accountFactory?: Address;
|
|
1983
|
-
/** @default 0n */
|
|
1984
|
-
accountSalt?: bigint;
|
|
1985
|
-
publicClient: PublicClient | null | undefined;
|
|
1986
|
-
walletClient: WalletClient | null | undefined;
|
|
1987
|
-
};
|
|
1988
|
-
declare function useSmoothSendAvax(params: UseSmoothSendAvaxParams): {
|
|
1989
|
-
submitter: SmoothSendAvaxSubmitter;
|
|
1990
|
-
submitCall: (args: {
|
|
1991
|
-
to: Address;
|
|
1992
|
-
data?: Hex;
|
|
1993
|
-
value?: bigint;
|
|
1994
|
-
mode?: AvaxSponsorshipMode;
|
|
1995
|
-
paymaster?: Omit<PaymasterSignRequestAvax, 'mode' | 'userOp'>;
|
|
1996
|
-
waitForReceipt?: boolean;
|
|
1997
|
-
}) => ReturnType<SmoothSendAvaxSubmitter['submitSponsoredUserOperation']>;
|
|
1998
|
-
};
|
|
1999
|
-
|
|
2000
|
-
interface CreateSessionOptions {
|
|
2001
|
-
/**
|
|
2002
|
-
* The master account that owns the Aptos address.
|
|
2003
|
-
* Can be a KeylessAccount (Google/Apple login), Ed25519Account, or any Account
|
|
2004
|
-
* that implements the Aptos Account interface.
|
|
2005
|
-
*
|
|
2006
|
-
* @example keylessAccount from aptos.deriveKeylessAccount(...)
|
|
2007
|
-
* @example Account.fromPrivateKey({ privateKey })
|
|
2008
|
-
*/
|
|
2009
|
-
signer: Account;
|
|
2010
|
-
/**
|
|
2011
|
-
* How long the session should stay valid.
|
|
2012
|
-
* Format: number + unit (s = seconds, m = minutes, h = hours, d = days)
|
|
2013
|
-
* @example '2h' | '24h' | '7d' | 'never'
|
|
2014
|
-
*/
|
|
2015
|
-
expiresIn: string;
|
|
2016
|
-
/**
|
|
2017
|
-
* Network to use. Inferred from submitter if not provided.
|
|
2018
|
-
*/
|
|
2019
|
-
network?: 'testnet' | 'mainnet';
|
|
2020
|
-
}
|
|
2021
|
-
interface SessionInfo {
|
|
2022
|
-
/** The user's main account address — sender for all transactions */
|
|
2023
|
-
masterAddress: string;
|
|
2024
|
-
/** The temporary session key address (for debugging / display) */
|
|
2025
|
-
sessionKeyAddress: string;
|
|
2026
|
-
/** When this session expires (Unix timestamp in ms) */
|
|
2027
|
-
expiresAt: number;
|
|
2028
|
-
/** Network this session operates on */
|
|
2029
|
-
network: 'testnet' | 'mainnet';
|
|
2030
|
-
}
|
|
2031
|
-
interface SubmitResult {
|
|
2032
|
-
hash: string;
|
|
2033
|
-
}
|
|
2034
|
-
/**
|
|
2035
|
-
* A session that lets your app submit transactions on behalf of a user
|
|
2036
|
-
* without any wallet popup after the initial one-time setup.
|
|
2037
|
-
*
|
|
2038
|
-
* Uses Aptos AIP-103 Permissioned Signers — authorization is enforced
|
|
2039
|
-
* on-chain by `0x1::permissioned_delegation`. No custom Move contract needed.
|
|
2040
|
-
*
|
|
2041
|
-
* @example
|
|
2042
|
-
* // 1. One-time setup (user signs once — can be keyless/Google login)
|
|
2043
|
-
* const session = await SmoothSendSession.create({
|
|
2044
|
-
* signer: keylessAccount,
|
|
2045
|
-
* expiresIn: '24h',
|
|
2046
|
-
* }, submitter)
|
|
2047
|
-
*
|
|
2048
|
-
* // 2. Every action after — zero popups, zero gas
|
|
2049
|
-
* await session.submit('0xgame::player::move', ['north'])
|
|
2050
|
-
* await session.submit('0xgame::player::attack', [enemyId])
|
|
2051
|
-
*/
|
|
2052
|
-
declare class SmoothSendSession {
|
|
2053
|
-
private readonly sessionAccount;
|
|
2054
|
-
private readonly abstractedAccount;
|
|
2055
|
-
private readonly masterAddress;
|
|
2056
|
-
private readonly expiresAtMs;
|
|
2057
|
-
private readonly submitter;
|
|
2058
|
-
private readonly aptosClient;
|
|
2059
|
-
private readonly _network;
|
|
2060
|
-
private constructor();
|
|
2061
|
-
/**
|
|
2062
|
-
* Create a new session.
|
|
2063
|
-
*
|
|
2064
|
-
* Registers the session key on-chain via
|
|
2065
|
-
* `0x1::permissioned_delegation::add_permissioned_handle`.
|
|
2066
|
-
* SmoothSend pays the gas for this setup transaction too.
|
|
2067
|
-
*
|
|
2068
|
-
* After this returns, the user never needs to approve anything again
|
|
2069
|
-
* until the session expires or is revoked.
|
|
2070
|
-
*/
|
|
2071
|
-
static create(options: CreateSessionOptions, submitter: SmoothSendTransactionSubmitter): Promise<SmoothSendSession>;
|
|
2072
|
-
/**
|
|
2073
|
-
* Submit a transaction silently — no wallet popup, zero gas.
|
|
2074
|
-
*
|
|
2075
|
-
* The transaction sender on-chain is still the user's main address.
|
|
2076
|
-
* The session key signs it, and `permissioned_delegation::authenticate`
|
|
2077
|
-
* validates the authorization at the VM level.
|
|
2078
|
-
*
|
|
2079
|
-
* @param functionName Full Move function identifier e.g. '0xgame::player::move'
|
|
2080
|
-
* @param functionArguments Arguments matching the Move function signature
|
|
2081
|
-
* @param typeArguments Optional type arguments for generic functions
|
|
2082
|
-
*
|
|
2083
|
-
* @example
|
|
2084
|
-
* await session.submit('0xgame::player::move', ['north'])
|
|
2085
|
-
* await session.submit('0x1::coin::transfer', [recipientAddr, 1000000n])
|
|
2086
|
-
*/
|
|
2087
|
-
submit(functionName: `${string}::${string}::${string}`, functionArguments?: any[], typeArguments?: string[]): Promise<SubmitResult>;
|
|
2088
|
-
/**
|
|
2089
|
-
* Whether this session is still valid (not yet expired).
|
|
2090
|
-
*/
|
|
2091
|
-
isValid(): boolean;
|
|
2092
|
-
/**
|
|
2093
|
-
* Milliseconds until this session expires. Returns 0 if already expired.
|
|
2094
|
-
*/
|
|
2095
|
-
expiresInMs(): number;
|
|
2096
|
-
/**
|
|
2097
|
-
* Session metadata — useful for display or debugging.
|
|
2098
|
-
*/
|
|
2099
|
-
get info(): SessionInfo;
|
|
2100
|
-
}
|
|
2101
|
-
|
|
2102
|
-
/**
|
|
2103
|
-
* Script Composer Client
|
|
2104
|
-
*
|
|
2105
|
-
* Wrapper for Script Composer gasless transactions.
|
|
2106
|
-
* Use this for token transfers on mainnet with free tier (fee deducted from token).
|
|
2107
|
-
*
|
|
2108
|
-
* @remarks
|
|
2109
|
-
* Script Composer builds a batched transaction that:
|
|
2110
|
-
* 1. Withdraws (amount + fee) from sender
|
|
2111
|
-
* 2. Deposits amount to recipient
|
|
2112
|
-
* 3. Deposits fee to treasury
|
|
2113
|
-
*
|
|
2114
|
-
* This allows gasless transactions where the fee is paid in the token being transferred.
|
|
2115
|
-
*
|
|
2116
|
-
* @example
|
|
2117
|
-
* ```typescript
|
|
2118
|
-
* import { ScriptComposerClient } from '@smoothsend/aptos-sdk';
|
|
2119
|
-
*
|
|
2120
|
-
* const client = new ScriptComposerClient({
|
|
2121
|
-
* apiKey: 'pk_nogas_xxx',
|
|
2122
|
-
* network: 'mainnet'
|
|
2123
|
-
* });
|
|
2124
|
-
*
|
|
2125
|
-
* // Step 1: Build transaction (fee calculated automatically)
|
|
2126
|
-
* const { transactionBytes, fee, totalAmount } = await client.buildTransfer({
|
|
2127
|
-
* sender: wallet.address,
|
|
2128
|
-
* recipient: '0x123...',
|
|
2129
|
-
* amount: '1000000', // 1 USDC (6 decimals)
|
|
2130
|
-
* assetType: '0x...::usdc::USDC',
|
|
2131
|
-
* decimals: 6,
|
|
2132
|
-
* symbol: 'USDC'
|
|
2133
|
-
* });
|
|
2134
|
-
*
|
|
2135
|
-
* // Step 2: Sign with wallet
|
|
2136
|
-
* const signedTx = await wallet.signTransaction(transactionBytes);
|
|
2137
|
-
*
|
|
2138
|
-
* // Step 3: Submit
|
|
2139
|
-
* const result = await client.submitSignedTransaction({
|
|
2140
|
-
* transactionBytes: signedTx.transactionBytes,
|
|
2141
|
-
* authenticatorBytes: signedTx.authenticatorBytes
|
|
2142
|
-
* });
|
|
2143
|
-
*
|
|
2144
|
-
* console.log('Tx:', result.txHash);
|
|
2145
|
-
* ```
|
|
2146
|
-
*/
|
|
2147
|
-
/**
|
|
2148
|
-
* Configuration for Script Composer Client
|
|
2149
|
-
*/
|
|
2150
|
-
interface ScriptComposerConfig {
|
|
2151
|
-
/** API key for authentication (pk_nogas_* or sk_nogas_*) */
|
|
2152
|
-
apiKey: string;
|
|
2153
|
-
/** Network to use: 'testnet' or 'mainnet' */
|
|
2154
|
-
network: 'testnet' | 'mainnet';
|
|
2155
|
-
/** Custom proxy URL (optional, defaults to proxy.smoothsend.xyz) */
|
|
2156
|
-
proxyUrl?: string;
|
|
2157
|
-
/** Request timeout in milliseconds (default: 30000) */
|
|
2158
|
-
timeout?: number;
|
|
2159
|
-
/** Enable debug logging */
|
|
2160
|
-
debug?: boolean;
|
|
2161
|
-
}
|
|
2162
|
-
/**
|
|
2163
|
-
* Parameters for building a Script Composer transfer
|
|
2164
|
-
*/
|
|
2165
|
-
interface BuildTransferParams {
|
|
2166
|
-
/** Sender's wallet address */
|
|
2167
|
-
sender: string;
|
|
2168
|
-
/** Recipient's wallet address */
|
|
2169
|
-
recipient: string;
|
|
2170
|
-
/** Amount in smallest units (e.g., 1000000 for 1 USDC) */
|
|
2171
|
-
amount: string;
|
|
2172
|
-
/** Full asset type address (e.g., '0x...::usdc::USDC') */
|
|
2173
|
-
assetType: string;
|
|
2174
|
-
/** Token decimals (e.g., 6 for USDC, 8 for APT) */
|
|
2175
|
-
decimals: number;
|
|
2176
|
-
/** Token symbol (e.g., 'USDC', 'APT') */
|
|
2177
|
-
symbol: string;
|
|
2178
|
-
}
|
|
2179
|
-
/**
|
|
2180
|
-
* Result from building a transfer
|
|
2181
|
-
*/
|
|
2182
|
-
interface BuildTransferResult {
|
|
2183
|
-
/** Success status */
|
|
2184
|
-
success: boolean;
|
|
2185
|
-
/** Request ID for tracking */
|
|
2186
|
-
requestId: string;
|
|
2187
|
-
/** Serialized transaction bytes for wallet signing */
|
|
2188
|
-
transactionBytes: number[];
|
|
2189
|
-
/** Transaction details */
|
|
2190
|
-
transaction: {
|
|
2191
|
-
sender: string;
|
|
2192
|
-
recipient: string;
|
|
2193
|
-
amount: string;
|
|
2194
|
-
assetType: string;
|
|
2195
|
-
network: string;
|
|
2196
|
-
};
|
|
2197
|
-
/** Fee amount in smallest units */
|
|
2198
|
-
fee: string;
|
|
2199
|
-
/** Total amount (amount + fee) in smallest units */
|
|
2200
|
-
totalAmount: string;
|
|
2201
|
-
/** Fee breakdown with formatted values */
|
|
2202
|
-
feeBreakdown: {
|
|
2203
|
-
amount: string;
|
|
2204
|
-
fee: string;
|
|
2205
|
-
totalAmount: string;
|
|
2206
|
-
formatted: {
|
|
2207
|
-
amount: string;
|
|
2208
|
-
fee: string;
|
|
2209
|
-
totalAmount: string;
|
|
2210
|
-
};
|
|
2211
|
-
pricing: {
|
|
2212
|
-
tier: string;
|
|
2213
|
-
zeroFees: boolean;
|
|
2214
|
-
feeInUsd: number;
|
|
2215
|
-
tokenPrice: number | null;
|
|
2216
|
-
description: string;
|
|
2217
|
-
};
|
|
2218
|
-
};
|
|
2219
|
-
}
|
|
2220
|
-
/**
|
|
2221
|
-
* Parameters for submitting a signed transaction
|
|
2222
|
-
*/
|
|
2223
|
-
interface SubmitSignedTransactionParams {
|
|
2224
|
-
/** Serialized transaction bytes (from wallet signing) */
|
|
2225
|
-
transactionBytes: number[];
|
|
2226
|
-
/** Serialized authenticator bytes (from wallet signing) */
|
|
2227
|
-
authenticatorBytes: number[];
|
|
2228
|
-
}
|
|
2229
|
-
/**
|
|
2230
|
-
* Result from submitting a transaction
|
|
2231
|
-
*/
|
|
2232
|
-
interface SubmitTransactionResult {
|
|
2233
|
-
/** Success status */
|
|
2234
|
-
success: boolean;
|
|
2235
|
-
/** Request ID for tracking */
|
|
2236
|
-
requestId: string;
|
|
2237
|
-
/** Transaction hash */
|
|
2238
|
-
txHash: string;
|
|
2239
|
-
/** Gas used */
|
|
2240
|
-
gasUsed?: string;
|
|
2241
|
-
/** VM status */
|
|
2242
|
-
vmStatus?: string;
|
|
2243
|
-
/** Sender address */
|
|
2244
|
-
sender?: string;
|
|
2245
|
-
}
|
|
2246
|
-
/**
|
|
2247
|
-
* Fee estimation result
|
|
2248
|
-
*/
|
|
2249
|
-
interface FeeEstimateResult {
|
|
2250
|
-
/** Success status */
|
|
2251
|
-
success: boolean;
|
|
2252
|
-
/** Request ID for tracking */
|
|
2253
|
-
requestId: string;
|
|
2254
|
-
/** Fee estimation details */
|
|
2255
|
-
estimation: {
|
|
2256
|
-
/** Amount in smallest units */
|
|
2257
|
-
amount: string;
|
|
2258
|
-
/** Fee in smallest units */
|
|
2259
|
-
fee: string;
|
|
2260
|
-
/** Total amount in smallest units */
|
|
2261
|
-
totalAmount: string;
|
|
2262
|
-
/** Formatted values for display */
|
|
2263
|
-
formatted: {
|
|
2264
|
-
amount: string;
|
|
2265
|
-
fee: string;
|
|
2266
|
-
totalAmount: string;
|
|
2267
|
-
};
|
|
2268
|
-
/** Pricing information */
|
|
2269
|
-
pricing: {
|
|
2270
|
-
tier: string;
|
|
2271
|
-
zeroFees: boolean;
|
|
2272
|
-
feeInUsd: number;
|
|
2273
|
-
tokenPrice: number | null;
|
|
2274
|
-
description: string;
|
|
2275
|
-
};
|
|
2276
|
-
/** Usage information */
|
|
2277
|
-
usage: {
|
|
2278
|
-
monthlyLimit: number;
|
|
2279
|
-
usedThisMonth: number;
|
|
2280
|
-
remaining: number;
|
|
2281
|
-
};
|
|
2282
|
-
};
|
|
2283
|
-
}
|
|
2284
|
-
/**
|
|
2285
|
-
* Script Composer Client
|
|
2286
|
-
*
|
|
2287
|
-
* For gasless token transfers with fee deducted from the token.
|
|
2288
|
-
* Use this on mainnet with free tier, or anytime you want fee-in-token.
|
|
2289
|
-
*/
|
|
2290
|
-
declare class ScriptComposerClient {
|
|
2291
|
-
private httpClient;
|
|
2292
|
-
private config;
|
|
2293
|
-
constructor(config: ScriptComposerConfig);
|
|
2294
|
-
private isBrowser;
|
|
2295
|
-
private log;
|
|
2296
|
-
/**
|
|
2297
|
-
* Estimate fee for a transfer without building the transaction
|
|
2298
|
-
*
|
|
2299
|
-
* @param params Transfer parameters
|
|
2300
|
-
* @returns Fee estimation with pricing details
|
|
2301
|
-
*/
|
|
2302
|
-
estimateFee(params: BuildTransferParams): Promise<FeeEstimateResult>;
|
|
2303
|
-
/**
|
|
2304
|
-
* Build a gasless transfer transaction
|
|
2305
|
-
*
|
|
2306
|
-
* Returns unsigned transaction bytes that must be signed by the user's wallet.
|
|
2307
|
-
* The fee will be deducted from the token being transferred.
|
|
2308
|
-
*
|
|
2309
|
-
* @param params Transfer parameters
|
|
2310
|
-
* @returns Transaction bytes for signing and fee details
|
|
2311
|
-
*/
|
|
2312
|
-
buildTransfer(params: BuildTransferParams): Promise<BuildTransferResult>;
|
|
2313
|
-
/**
|
|
2314
|
-
* Submit a signed transaction
|
|
2315
|
-
*
|
|
2316
|
-
* After the user signs the transaction bytes returned by buildTransfer(),
|
|
2317
|
-
* use this method to submit the signed transaction.
|
|
2318
|
-
*
|
|
2319
|
-
* @param params Signed transaction bytes
|
|
2320
|
-
* @returns Transaction result with hash
|
|
2321
|
-
*/
|
|
2322
|
-
submitSignedTransaction(params: SubmitSignedTransactionParams): Promise<SubmitTransactionResult>;
|
|
2323
|
-
/**
|
|
2324
|
-
* Complete transfer flow: build, sign, and submit
|
|
2325
|
-
*
|
|
2326
|
-
* Convenience method that handles the entire flow.
|
|
2327
|
-
* Requires a wallet that can sign transactions.
|
|
2328
|
-
*
|
|
2329
|
-
* @param params Transfer parameters
|
|
2330
|
-
* @param wallet Wallet with signTransaction method
|
|
2331
|
-
* @returns Transaction result
|
|
2332
|
-
*
|
|
2333
|
-
* @example
|
|
2334
|
-
* ```typescript
|
|
2335
|
-
* const result = await client.transfer({
|
|
2336
|
-
* sender: wallet.address,
|
|
2337
|
-
* recipient: '0x123...',
|
|
2338
|
-
* amount: '1000000',
|
|
2339
|
-
* assetType: USDC_ADDRESS,
|
|
2340
|
-
* decimals: 6,
|
|
2341
|
-
* symbol: 'USDC'
|
|
2342
|
-
* }, wallet);
|
|
2343
|
-
* ```
|
|
2344
|
-
*/
|
|
2345
|
-
transfer(params: BuildTransferParams, wallet: {
|
|
2346
|
-
signTransaction: (txBytes: number[]) => Promise<{
|
|
2347
|
-
transactionBytes: number[];
|
|
2348
|
-
authenticatorBytes: number[];
|
|
2349
|
-
}>;
|
|
2350
|
-
}): Promise<SubmitTransactionResult>;
|
|
2351
|
-
/**
|
|
2352
|
-
* Get current network
|
|
2353
|
-
*/
|
|
2354
|
-
getNetwork(): 'testnet' | 'mainnet';
|
|
2355
|
-
/**
|
|
2356
|
-
* Set network
|
|
2357
|
-
*/
|
|
2358
|
-
setNetwork(network: 'testnet' | 'mainnet'): void;
|
|
2359
|
-
}
|
|
2360
|
-
/**
|
|
2361
|
-
* Create a Script Composer client (convenience function)
|
|
2362
|
-
*/
|
|
2363
|
-
declare function createScriptComposerClient(config: ScriptComposerConfig): ScriptComposerClient;
|
|
2364
|
-
|
|
2365
|
-
/**
|
|
2366
|
-
* True Gasless Client
|
|
2367
|
-
*
|
|
2368
|
-
* Designed for server-side (backend) environments to securely build, sign,
|
|
2369
|
-
* and submit 100% sponsored gasless transactions using a Secret Key.
|
|
2370
|
-
*
|
|
2371
|
-
* @example
|
|
2372
|
-
* ```typescript
|
|
2373
|
-
* import { TrueGaslessClient } from '@smoothsend/sdk';
|
|
2374
|
-
* import { Account } from '@aptos-labs/ts-sdk';
|
|
2375
|
-
*
|
|
2376
|
-
* const backendWallet = Account.fromPrivateKey({ privateKey: '...' });
|
|
2377
|
-
* const client = new TrueGaslessClient({ apiKey: 'sk_nogas_...', network: 'mainnet' });
|
|
2378
|
-
*
|
|
2379
|
-
* const result = await client.execute({
|
|
2380
|
-
* senderAccount: backendWallet,
|
|
2381
|
-
* payload: {
|
|
2382
|
-
* function: "0x123::my_module::mint_nft",
|
|
2383
|
-
* functionArguments: []
|
|
2384
|
-
* }
|
|
2385
|
-
* });
|
|
2386
|
-
*
|
|
2387
|
-
* console.log("Gasless NFT Minted!", result.txHash);
|
|
2388
|
-
* ```
|
|
2389
|
-
*/
|
|
2390
|
-
|
|
2391
|
-
interface TrueGaslessConfig {
|
|
2392
|
-
/** API key for authentication (must be sk_nogas_* for backend) */
|
|
2393
|
-
apiKey: string;
|
|
2394
|
-
/** Network to use: 'testnet' | 'mainnet' */
|
|
2395
|
-
network: 'testnet' | 'mainnet';
|
|
2396
|
-
/** Custom proxy URL (optional) */
|
|
2397
|
-
proxyUrl?: string;
|
|
2398
|
-
/** Request timeout in milliseconds */
|
|
2399
|
-
timeout?: number;
|
|
2400
|
-
/** Enable debug logging */
|
|
2401
|
-
debug?: boolean;
|
|
2402
|
-
}
|
|
2403
|
-
interface ExecuteGaslessParams {
|
|
2404
|
-
/** The backend sender wallet identity */
|
|
2405
|
-
senderAccount: Account;
|
|
2406
|
-
/** Raw transaction payload to execute */
|
|
2407
|
-
payload: InputGenerateTransactionPayloadData;
|
|
2408
|
-
}
|
|
2409
|
-
interface ExecuteGaslessResult {
|
|
2410
|
-
success: boolean;
|
|
2411
|
-
requestId?: string;
|
|
2412
|
-
txHash?: string;
|
|
2413
|
-
gasUsed?: string;
|
|
2414
|
-
vmStatus?: string;
|
|
2415
|
-
sender?: string;
|
|
2416
|
-
}
|
|
2417
|
-
declare class TrueGaslessClient {
|
|
2418
|
-
private httpClient;
|
|
2419
|
-
private config;
|
|
2420
|
-
private aptos;
|
|
2421
|
-
constructor(config: TrueGaslessConfig);
|
|
2422
|
-
private log;
|
|
2423
|
-
/**
|
|
2424
|
-
* Builds, signs (as sender), and relays an arbitrary payload for complete sponsorship.
|
|
2425
|
-
*/
|
|
2426
|
-
execute(params: ExecuteGaslessParams): Promise<ExecuteGaslessResult>;
|
|
2427
|
-
/**
|
|
2428
|
-
* Expose the core Aptos instance to allow backend developers to access chain state if needed
|
|
2429
|
-
*/
|
|
2430
|
-
getAptosClient(): Aptos;
|
|
2431
|
-
}
|
|
2432
|
-
/**
|
|
2433
|
-
* Helper to initialize TrueGaslessClient
|
|
2434
|
-
*/
|
|
2435
|
-
declare function createTrueGaslessClient(config: TrueGaslessConfig): TrueGaslessClient;
|
|
2436
|
-
|
|
2437
|
-
/**
|
|
2438
|
-
* Aptos Multi-Chain Adapter - v2 Proxy Architecture
|
|
2439
|
-
* Handles all Aptos chains (aptos-testnet, aptos-mainnet)
|
|
2440
|
-
* Routes all requests through proxy.smoothsend.xyz with API key authentication
|
|
2441
|
-
* Supports Aptos-specific features like gasless transactions and Move-based contracts
|
|
2442
|
-
*/
|
|
2443
|
-
declare class AptosAdapter implements IChainAdapter {
|
|
2444
|
-
readonly chain: SupportedChain;
|
|
2445
|
-
readonly config: ChainConfig;
|
|
2446
|
-
private httpClient;
|
|
2447
|
-
private apiKey;
|
|
2448
|
-
private network;
|
|
2449
|
-
constructor(chain: SupportedChain, config: ChainConfig, apiKey: string, network?: 'testnet' | 'mainnet', includeOrigin?: boolean);
|
|
2450
|
-
/**
|
|
2451
|
-
* Build API path for proxy worker routing to Aptos relayer
|
|
2452
|
-
* All requests route through /api/v1/relayer/aptos/* endpoints
|
|
2453
|
-
*/
|
|
2454
|
-
private getApiPath;
|
|
2455
|
-
/**
|
|
2456
|
-
* Update network parameter for subsequent requests
|
|
2457
|
-
* Network is passed via X-Network header to proxy worker
|
|
2458
|
-
*/
|
|
2459
|
-
setNetwork(network: 'testnet' | 'mainnet'): void;
|
|
2460
|
-
/**
|
|
2461
|
-
* Get current network
|
|
2462
|
-
*/
|
|
2463
|
-
getNetwork(): 'testnet' | 'mainnet';
|
|
2464
|
-
/**
|
|
2465
|
-
* Estimate fee for a transfer (v2 interface method)
|
|
2466
|
-
* Routes through proxy: POST /api/v1/relayer/aptos/quote
|
|
2467
|
-
*/
|
|
2468
|
-
estimateFee(request: TransferRequest): Promise<FeeEstimate>;
|
|
2469
|
-
/**
|
|
2470
|
-
* Execute gasless transfer (v2 interface method)
|
|
2471
|
-
* Routes through proxy: POST /api/v1/relayer/aptos/execute
|
|
2472
|
-
*/
|
|
2473
|
-
executeGaslessTransfer(signedData: SignedTransferData): Promise<TransferResult>;
|
|
2474
|
-
/**
|
|
2475
|
-
* Get quote for a transfer (legacy method, kept for backward compatibility)
|
|
2476
|
-
* Routes through proxy: POST /api/v1/relayer/aptos/quote
|
|
2477
|
-
*/
|
|
2478
|
-
getQuote(request: TransferRequest): Promise<TransferQuote>;
|
|
2479
|
-
prepareTransfer(request: TransferRequest, quote: TransferQuote): Promise<SignatureData>;
|
|
2480
|
-
executeTransfer(signedData: SignedTransferData): Promise<TransferResult>;
|
|
2481
|
-
getBalance(address: string, token?: string): Promise<TokenBalance[]>;
|
|
2482
|
-
getTokenInfo(token: string): Promise<TokenInfo>;
|
|
2483
|
-
getNonce(address: string): Promise<string>;
|
|
2484
|
-
getTransactionStatus(txHash: string): Promise<any>;
|
|
2485
|
-
/**
|
|
2486
|
-
* Get health status of Aptos relayer through proxy
|
|
2487
|
-
* Routes through proxy: GET /api/v1/relayer/aptos/health
|
|
2488
|
-
*/
|
|
2489
|
-
getHealth(): Promise<HealthResponse>;
|
|
2490
|
-
validateAddress(address: string): boolean;
|
|
2491
|
-
validateAmount(amount: string): boolean;
|
|
2492
|
-
/**
|
|
2493
|
-
* Get Aptos token address from symbol
|
|
2494
|
-
* Mirrors aptosrelayer/config/chains.json
|
|
2495
|
-
*/
|
|
2496
|
-
private getAptosTokenAddress;
|
|
2497
|
-
/**
|
|
2498
|
-
* Build Aptos explorer URL for transaction
|
|
2499
|
-
*/
|
|
2500
|
-
private buildAptosExplorerUrl;
|
|
2501
|
-
/**
|
|
2502
|
-
* Validate serialized transaction data for proxy worker
|
|
2503
|
-
* @param signedData The signed transfer data to validate
|
|
2504
|
-
*/
|
|
2505
|
-
private validateSerializedTransactionData;
|
|
2506
|
-
/**
|
|
2507
|
-
* Enhanced address validation with detailed error messages
|
|
2508
|
-
* @param address The address to validate
|
|
2509
|
-
* @returns true if valid, throws error if invalid
|
|
2510
|
-
*/
|
|
2511
|
-
validateAddressStrict(address: string): boolean;
|
|
2512
|
-
/**
|
|
2513
|
-
* Verify that a public key corresponds to an expected address
|
|
2514
|
-
* This mirrors the enhanced verification in the relayer
|
|
2515
|
-
* @param publicKey The public key to verify
|
|
2516
|
-
* @param expectedAddress The expected address
|
|
2517
|
-
* @returns true if they match
|
|
2518
|
-
*/
|
|
2519
|
-
verifyPublicKeyAddress(publicKey: string, expectedAddress: string): Promise<boolean>;
|
|
2520
|
-
/**
|
|
2521
|
-
* Enhanced transaction preparation with better signature data structure
|
|
2522
|
-
* @param request Transfer request
|
|
2523
|
-
* @param quote Transfer quote
|
|
2524
|
-
* @returns Signature data with enhanced structure
|
|
2525
|
-
*/
|
|
2526
|
-
prepareTransferEnhanced(request: TransferRequest, quote: TransferQuote): Promise<SignatureData & {
|
|
2527
|
-
metadata: any;
|
|
2528
|
-
}>;
|
|
2529
|
-
/**
|
|
2530
|
-
* Aptos-specific Move contract interaction
|
|
2531
|
-
*/
|
|
2532
|
-
callMoveFunction(functionName: string, args: any[]): Promise<any>;
|
|
2533
|
-
}
|
|
2534
|
-
|
|
2535
|
-
/**
|
|
2536
|
-
* Configuration for HTTP client
|
|
2537
|
-
*/
|
|
2538
|
-
interface HttpClientConfig {
|
|
2539
|
-
apiKey: string;
|
|
2540
|
-
network?: 'testnet' | 'mainnet';
|
|
2541
|
-
timeout?: number;
|
|
2542
|
-
retries?: number;
|
|
2543
|
-
customHeaders?: Record<string, string>;
|
|
2544
|
-
includeOrigin?: boolean;
|
|
2545
|
-
/** Override the default proxy base URL (e.g. for self-hosted relayers) */
|
|
2546
|
-
baseUrl?: string;
|
|
2547
|
-
}
|
|
2548
|
-
/**
|
|
2549
|
-
* HTTP Client for proxy worker integration
|
|
2550
|
-
* Handles authentication, rate limiting, usage tracking, and retry logic
|
|
2551
|
-
*/
|
|
2552
|
-
declare class HttpClient {
|
|
2553
|
-
private client;
|
|
2554
|
-
private apiKey?;
|
|
2555
|
-
private network;
|
|
2556
|
-
private maxRetries;
|
|
2557
|
-
private baseURL;
|
|
2558
|
-
private isProxyMode;
|
|
2559
|
-
private includeOrigin;
|
|
2560
|
-
/**
|
|
2561
|
-
* Constructor supports both old (baseURL, timeout) and new (config object) patterns
|
|
2562
|
-
* for backward compatibility during migration
|
|
2563
|
-
*/
|
|
2564
|
-
constructor(configOrBaseURL: HttpClientConfig | string, timeout?: number);
|
|
2565
|
-
/**
|
|
2566
|
-
* Extract usage metadata from response headers (proxy mode only)
|
|
2567
|
-
* Uses USAGE_HEADERS constants for consistency across systems
|
|
2568
|
-
*/
|
|
2569
|
-
private extractMetadata;
|
|
2570
|
-
/**
|
|
2571
|
-
* Determine if an error should be retried
|
|
2572
|
-
*/
|
|
2573
|
-
private shouldRetry;
|
|
2574
|
-
/**
|
|
2575
|
-
* Calculate exponential backoff delay with jitter
|
|
2576
|
-
*/
|
|
2577
|
-
private calculateBackoff;
|
|
2578
|
-
/**
|
|
2579
|
-
* Execute request with retry logic (proxy mode) or single attempt (legacy mode)
|
|
2580
|
-
*/
|
|
2581
|
-
private executeWithRetry;
|
|
2582
|
-
/**
|
|
2583
|
-
* Handle errors and create appropriate error responses
|
|
2584
|
-
*/
|
|
2585
|
-
private handleError;
|
|
2586
|
-
/**
|
|
2587
|
-
* GET request
|
|
2588
|
-
*/
|
|
2589
|
-
get<T = any>(url: string, config?: AxiosRequestConfig): Promise<ApiResponse<T>>;
|
|
2590
|
-
/**
|
|
2591
|
-
* POST request
|
|
2592
|
-
*/
|
|
2593
|
-
post<T = any>(url: string, data?: any, config?: AxiosRequestConfig): Promise<ApiResponse<T>>;
|
|
2594
|
-
/**
|
|
2595
|
-
* PUT request
|
|
2596
|
-
*/
|
|
2597
|
-
put<T = any>(url: string, data?: any, config?: AxiosRequestConfig): Promise<ApiResponse<T>>;
|
|
2598
|
-
/**
|
|
2599
|
-
* DELETE request
|
|
2600
|
-
*/
|
|
2601
|
-
delete<T = any>(url: string, config?: AxiosRequestConfig): Promise<ApiResponse<T>>;
|
|
2602
|
-
/**
|
|
2603
|
-
* Update network parameter for subsequent requests
|
|
2604
|
-
*/
|
|
2605
|
-
setNetwork(network: 'testnet' | 'mainnet'): void;
|
|
2606
|
-
/**
|
|
2607
|
-
* Get current network
|
|
2608
|
-
*/
|
|
2609
|
-
getNetwork(): 'testnet' | 'mainnet';
|
|
2610
|
-
}
|
|
2611
|
-
|
|
2612
|
-
/**
|
|
2613
|
-
* C-Address (Soroban Smart Account) response types
|
|
2614
|
-
*/
|
|
2615
|
-
interface CAddressCreateResult {
|
|
2616
|
-
cAddress: string;
|
|
2617
|
-
txHash: string;
|
|
2618
|
-
alreadyExisted: boolean;
|
|
2619
|
-
explorerUrl: string;
|
|
2620
|
-
}
|
|
2621
|
-
interface CAddressLookupResult {
|
|
2622
|
-
ownerGAddress: string;
|
|
2623
|
-
cAddress: string | null;
|
|
2624
|
-
hasAccount: boolean;
|
|
2625
|
-
}
|
|
2626
|
-
interface CAddressBalance {
|
|
2627
|
-
asset: string;
|
|
2628
|
-
balance: string;
|
|
2629
|
-
symbol: string;
|
|
2630
|
-
}
|
|
2631
|
-
interface CAddressBalanceResult {
|
|
2632
|
-
cAddress: string;
|
|
2633
|
-
balances: CAddressBalance[];
|
|
2634
|
-
}
|
|
2635
|
-
interface CAddressBuildTransferResult {
|
|
2636
|
-
unsignedXDR: string;
|
|
2637
|
-
networkPassphrase: string;
|
|
2638
|
-
}
|
|
2639
|
-
interface CAddressSubmitResult {
|
|
2640
|
-
txHash: string;
|
|
2641
|
-
explorerUrl: string;
|
|
2642
|
-
}
|
|
2643
|
-
interface CAddressTransaction {
|
|
2644
|
-
type: 'sent' | 'received';
|
|
2645
|
-
asset: string;
|
|
2646
|
-
amount: string;
|
|
2647
|
-
counterparty: string;
|
|
2648
|
-
txHash: string;
|
|
2649
|
-
timestamp: string;
|
|
2650
|
-
ledger: number;
|
|
2651
|
-
}
|
|
2652
|
-
interface CAddressHistoryResult {
|
|
2653
|
-
cAddress: string;
|
|
2654
|
-
transactions: CAddressTransaction[];
|
|
2655
|
-
count: number;
|
|
2656
|
-
}
|
|
2657
|
-
interface CAddressHealthResult {
|
|
2658
|
-
service: string;
|
|
2659
|
-
relayerPublicKey: string;
|
|
2660
|
-
factoryContractId: string;
|
|
2661
|
-
isReady: boolean;
|
|
2662
|
-
network: string;
|
|
2663
|
-
}
|
|
2664
|
-
/**
|
|
2665
|
-
* Stellar C-Address Adapter — SDK for Soroban Smart Account operations
|
|
2666
|
-
*
|
|
2667
|
-
* Provides a clean interface for:
|
|
2668
|
-
* - Creating C-addresses (smart accounts) from G-addresses
|
|
2669
|
-
* - Looking up existing C-addresses by owner
|
|
2670
|
-
* - Querying token balances (XLM, USDC, EURC)
|
|
2671
|
-
* - Building bridge transfers (G→C)
|
|
2672
|
-
* - Building smart account transfers (C→G, C→C)
|
|
2673
|
-
* - Submitting user-signed transactions via fee-bump
|
|
2674
|
-
* - Getting transaction history
|
|
2675
|
-
*
|
|
2676
|
-
* All transactions are gasless — the relayer covers fees via fee-bump.
|
|
2677
|
-
*
|
|
2678
|
-
* @example
|
|
2679
|
-
* ```typescript
|
|
2680
|
-
* import { SmoothSendSDK } from '@smoothsend/sdk';
|
|
2681
|
-
*
|
|
2682
|
-
* const sdk = new SmoothSendSDK({ apiKey: 'pk_nogas_xxx', network: 'testnet' });
|
|
2683
|
-
*
|
|
2684
|
-
* // Create a C-address for a G-address owner
|
|
2685
|
-
* const { cAddress } = await sdk.stellar.cAddress.create('GABCD...');
|
|
2686
|
-
*
|
|
2687
|
-
* // Get balances
|
|
2688
|
-
* const { balances } = await sdk.stellar.cAddress.getBalances(cAddress);
|
|
2689
|
-
*
|
|
2690
|
-
* // Build a bridge transfer (G→C), user signs, relayer fee-bumps
|
|
2691
|
-
* const { unsignedXDR } = await sdk.stellar.cAddress.buildBridgeTransfer({
|
|
2692
|
-
* from: 'GABCD...',
|
|
2693
|
-
* destination: cAddress,
|
|
2694
|
-
* asset: 'USDC',
|
|
2695
|
-
* amount: '10.5',
|
|
2696
|
-
* });
|
|
2697
|
-
* // Sign with wallet (e.g., Freighter)
|
|
2698
|
-
* const signedXDR = await wallet.signTransaction(unsignedXDR);
|
|
2699
|
-
* // Submit — relayer wraps in fee-bump
|
|
2700
|
-
* const { txHash } = await sdk.stellar.cAddress.submitTransfer(signedXDR);
|
|
2701
|
-
* ```
|
|
2702
|
-
*/
|
|
2703
|
-
declare class StellarCAddressAdapter {
|
|
2704
|
-
private httpClient;
|
|
2705
|
-
private basePath;
|
|
2706
|
-
constructor(httpClient: HttpClient, network?: 'testnet' | 'mainnet');
|
|
2707
|
-
/**
|
|
2708
|
-
* Create a new C-address (Soroban Smart Account) for a G-address owner.
|
|
2709
|
-
* If the owner already has a C-address, returns the existing one.
|
|
2710
|
-
*
|
|
2711
|
-
* The relayer pays all deployment fees — completely gasless for the user.
|
|
2712
|
-
*
|
|
2713
|
-
* @param ownerGAddress - The G-address that will control this smart account
|
|
2714
|
-
* @returns The new C-address, tx hash, and whether it already existed
|
|
2715
|
-
*/
|
|
2716
|
-
create(ownerGAddress: string): Promise<CAddressCreateResult>;
|
|
2717
|
-
/**
|
|
2718
|
-
* Look up the C-address for a given G-address owner.
|
|
2719
|
-
* Returns null if no C-address exists for this owner.
|
|
2720
|
-
*
|
|
2721
|
-
* @param ownerGAddress - The G-address to look up
|
|
2722
|
-
*/
|
|
2723
|
-
lookup(ownerGAddress: string): Promise<CAddressLookupResult>;
|
|
2724
|
-
/**
|
|
2725
|
-
* Get token balances for a C-address.
|
|
2726
|
-
* Returns balances for XLM, USDC, and EURC.
|
|
2727
|
-
*
|
|
2728
|
-
* @param cAddress - The C-address to query
|
|
2729
|
-
*/
|
|
2730
|
-
getBalances(cAddress: string): Promise<CAddressBalanceResult>;
|
|
2731
|
-
/**
|
|
2732
|
-
* Build a bridge transfer (G→C) using SAC.transfer.
|
|
2733
|
-
* Returns unsigned XDR for the user to sign with their wallet.
|
|
2734
|
-
* After signing, submit via submitTransfer().
|
|
2735
|
-
*
|
|
2736
|
-
* @param params.from - Sender G-address (signs the tx)
|
|
2737
|
-
* @param params.destination - Recipient C-address (or G-address)
|
|
2738
|
-
* @param params.asset - Asset to transfer: 'XLM', 'USDC', or 'EURC'
|
|
2739
|
-
* @param params.amount - Human-readable amount (e.g., '10.5')
|
|
2740
|
-
*/
|
|
2741
|
-
buildBridgeTransfer(params: {
|
|
2742
|
-
from: string;
|
|
2743
|
-
destination: string;
|
|
2744
|
-
asset: string;
|
|
2745
|
-
amount: string;
|
|
2746
|
-
}): Promise<CAddressBuildTransferResult>;
|
|
2747
|
-
/**
|
|
2748
|
-
* Build a transfer from a C-address (SmartAccount.send).
|
|
2749
|
-
* Returns unsigned XDR for the owner to sign.
|
|
2750
|
-
* After signing, submit via submitTransfer().
|
|
2751
|
-
*
|
|
2752
|
-
* @param params.from - Owner G-address (signs auth)
|
|
2753
|
-
* @param params.cAddress - Source C-address (holds the funds)
|
|
2754
|
-
* @param params.destination - Recipient (G or C address)
|
|
2755
|
-
* @param params.asset - Asset: 'XLM', 'USDC', or 'EURC'
|
|
2756
|
-
* @param params.amount - Human-readable amount
|
|
2757
|
-
*/
|
|
2758
|
-
buildTransfer(params: {
|
|
2759
|
-
from: string;
|
|
2760
|
-
cAddress: string;
|
|
2761
|
-
destination: string;
|
|
2762
|
-
asset: string;
|
|
2763
|
-
amount: string;
|
|
2764
|
-
}): Promise<CAddressBuildTransferResult>;
|
|
2765
|
-
/**
|
|
2766
|
-
* Submit a user-signed transaction.
|
|
2767
|
-
* The relayer wraps it in a fee-bump transaction and submits to the network.
|
|
2768
|
-
* The user pays zero fees — the relayer covers everything.
|
|
2769
|
-
*
|
|
2770
|
-
* @param signedXDR - The user-signed transaction XDR (base64)
|
|
2771
|
-
*/
|
|
2772
|
-
submitTransfer(signedXDR: string): Promise<CAddressSubmitResult>;
|
|
2773
|
-
/**
|
|
2774
|
-
* Get transaction history for a C-address.
|
|
2775
|
-
* Returns recent transfer events (sent/received) across all supported tokens.
|
|
2776
|
-
*
|
|
2777
|
-
* @param cAddress - The C-address to query
|
|
2778
|
-
* @param limit - Maximum number of transactions to return (default: 20)
|
|
2779
|
-
*/
|
|
2780
|
-
getHistory(cAddress: string, limit?: number): Promise<CAddressHistoryResult>;
|
|
2781
|
-
/**
|
|
2782
|
-
* Health check for the C-address bridge service.
|
|
2783
|
-
*/
|
|
2784
|
-
health(): Promise<CAddressHealthResult>;
|
|
2785
|
-
validateGAddress(address: string): void;
|
|
2786
|
-
validateCAddress(address: string): void;
|
|
2787
|
-
validateAddress(address: string): boolean;
|
|
2788
|
-
}
|
|
2789
|
-
|
|
2790
|
-
/**
|
|
2791
|
-
* Stellar Adapter - Gasless transactions via Fee Bump
|
|
2792
|
-
* Routes through proxy.smoothsend.xyz with API key authentication
|
|
2793
|
-
* Supports XLM, USDC, EURC and other Stellar assets
|
|
2794
|
-
*/
|
|
2795
|
-
declare class StellarAdapter implements IChainAdapter {
|
|
2796
|
-
readonly chain: SupportedChain;
|
|
2797
|
-
readonly config: ChainConfig;
|
|
2798
|
-
/** C-Address (Soroban Smart Account) operations */
|
|
2799
|
-
readonly cAddress: StellarCAddressAdapter;
|
|
2800
|
-
private httpClient;
|
|
2801
|
-
private network;
|
|
2802
|
-
constructor(chain: SupportedChain, config: ChainConfig, apiKey: string, network?: 'testnet' | 'mainnet', includeOrigin?: boolean);
|
|
2803
|
-
setNetwork(network: 'testnet' | 'mainnet'): void;
|
|
2804
|
-
getNetwork(): 'testnet' | 'mainnet';
|
|
2805
|
-
/**
|
|
2806
|
-
* Stellar gasless: relayer pays fee. Returns 0 for user.
|
|
2807
|
-
*/
|
|
2808
|
-
estimateFee(_request: TransferRequest): Promise<FeeEstimate>;
|
|
2809
|
-
/**
|
|
2810
|
-
* Submit signed XDR to relayer for Fee Bump wrapping
|
|
2811
|
-
*/
|
|
2812
|
-
executeGaslessTransfer(signedData: SignedTransferData): Promise<TransferResult>;
|
|
2813
|
-
getTransactionStatus(txHash: string): Promise<any>;
|
|
2814
|
-
getHealth(): Promise<HealthResponse>;
|
|
2815
|
-
validateAddress(address: string): boolean;
|
|
2816
|
-
validateAmount(amount: string): boolean;
|
|
2817
|
-
}
|
|
2818
|
-
|
|
2819
|
-
/**
|
|
2820
|
-
* SmoothSend SDK v2.0
|
|
2821
|
-
*
|
|
2822
|
-
* Multi-chain gasless transaction SDK for seamless dApp integration
|
|
2823
|
-
*
|
|
2824
|
-
* @remarks
|
|
2825
|
-
* The SDK provides a simple interface for executing gasless token transfers
|
|
2826
|
-
* across multiple blockchain networks. All requests route through the proxy
|
|
2827
|
-
* worker at proxy.smoothsend.xyz with API key authentication.
|
|
2828
|
-
*
|
|
2829
|
-
* @packageDocumentation
|
|
2830
|
-
*
|
|
2831
|
-
* @example
|
|
2832
|
-
* Aptos:
|
|
2833
|
-
* ```typescript
|
|
2834
|
-
* const sdk = new SmoothSendSDK({ apiKey: 'pk_nogas_xxx', network: 'testnet' });
|
|
2835
|
-
* const result = await sdk.transfer({ from, to, token: 'USDC', amount: '1000000', chain: 'aptos-testnet' }, aptosWallet);
|
|
2836
|
-
* ```
|
|
2837
|
-
*
|
|
2838
|
-
* @example
|
|
2839
|
-
* Stellar (same API):
|
|
2840
|
-
* ```typescript
|
|
2841
|
-
* const sdk = new SmoothSendSDK({ apiKey: 'pk_nogas_xxx', network: 'testnet' });
|
|
2842
|
-
* const result = await sdk.transfer({ from, to, token: 'XLM', amount: '100', chain: 'stellar-testnet' }, stellarWallet);
|
|
2843
|
-
* ```
|
|
2844
|
-
*/
|
|
2845
|
-
|
|
2846
|
-
/**
|
|
2847
|
-
* SDK version
|
|
2848
|
-
* @public
|
|
2849
|
-
*/
|
|
2850
|
-
declare const VERSION = "2.2.1";
|
|
2851
|
-
|
|
2852
|
-
export { APTOS_ERROR_CODES, AptosAdapter, AuthenticationError, AvaxSubmitter, CHAIN_ECOSYSTEM_MAP, ENTRY_POINT_V07_ADDRESS, HttpClient, NetworkError, RateLimitError, SIMPLE_ACCOUNT_FACTORY_ABI, STELLAR_ERROR_CODES, ScriptComposerClient, SmoothSendAvaxProvider, SmoothSendAvaxSubmitter, SmoothSendError, SmoothSendSDK, SmoothSendSession, SmoothSendTransactionSubmitter, StellarAdapter, StellarCAddressAdapter, TrueGaslessClient, VERSION, ValidationError, avaxExecuteAbi, createErrorFromResponse, createNetworkError, createScriptComposerClient, createSmoothSendAvaxSubmitter, createSmoothSendSubmitter, createTrueGaslessClient, SmoothSendSDK as default, encodeAvaxExecuteCalldata, encodeCreateAccountFactoryData, fetchAvaxAaPublicDefaults, hashUserOperationAvax, predictSimpleAccountAddress, readAvaxSenderNonce, useSmoothSend, useSmoothSendAvax, useSmoothSendAvaxContext, userOperationAvaxToViem };
|
|
2853
|
-
export type { ApiResponse, AptosErrorCode, AptosTransferData, AptosWallet, AvalancheTransferData, AvaxAaPublicDefaults, AvaxSponsorshipMode, BatchRelayTransferRequest, BatchTransferRequest, BuildTransferParams, BuildTransferResult, CAddressBalance, CAddressBalanceResult, CAddressBuildTransferResult, CAddressCreateResult, CAddressHealthResult, CAddressHistoryResult, CAddressLookupResult, CAddressSubmitResult, CAddressTransaction, ChainConfig, ChainEcosystem, ChainInfo, CreateSessionOptions, DomainSeparatorResponse, EVMTransferData, ErrorResponse, EstimateGasRequest, EventListener, ExecuteGaslessParams, ExecuteGaslessResult, FeeEstimate, FeeEstimateResult, GasEstimateAvax, GasEstimateResponse, HealthResponse, IChainAdapter, PaymasterSignRequestAvax, PaymasterSignResponseAvax, PermitData, PrepareSignatureRequest, PrepareSignatureResponse, RelayTransferRequest, RelayTransferResponse, ScriptComposerConfig, SessionInfo, SignatureData, SignedTransferData, SmoothSendAvaxContextValue, SmoothSendAvaxSubmitterConfig, SmoothSendConfig, SmoothSendTransactionSubmitterConfig, SponsoredUserOpDraftAvax, StellarWallet, SubmitResult, SubmitSignedTransactionParams, SubmitSponsoredAvaxUserOpOptions, SubmitTransactionResult, SuccessResponse, SupportedChain, TokenBalance, TokenInfo, TransactionSubmitter, TransferData, TransferEvent, TransferQuote, TransferQuoteRequest, TransferQuoteResponse, TransferRequest, TransferResult, TransferStatusResponse, TrueGaslessConfig, UsageMetadata, UseSmoothSendAvaxParams, UseSmoothSendResult, UserOperationAvax, UserOperationReceiptAvax };
|
|
1
|
+
export { S as SmoothSendSDK, S as default } from './chunks/shared-RVkwmkG7.js';
|
|
2
|
+
export { AptosAdapter, BuildTransferParams, BuildTransferResult, CreateSessionOptions, ExecuteGaslessParams, ExecuteGaslessResult, FeeEstimateResult, ScriptComposerClient, ScriptComposerConfig, SessionInfo, SmoothSendSession, SmoothSendTransactionSubmitter, SmoothSendTransactionSubmitterConfig, SubmitResult, SubmitSignedTransactionParams, SubmitTransactionResult, TransactionSubmitter, TrueGaslessClient, TrueGaslessConfig, UseSmoothSendResult, createScriptComposerClient, createSmoothSendSubmitter, createTrueGaslessClient, useSmoothSend } from './aptos/index.js';
|
|
3
|
+
export { AvaxAaPublicDefaults, AvaxSponsorshipMode, AvaxSubmitter, ENTRY_POINT_V07_ADDRESS, GasEstimateAvax, PaymasterSignRequestAvax, PaymasterSignResponseAvax, SIMPLE_ACCOUNT_FACTORY_ABI, SmoothSendAvaxContextValue, SmoothSendAvaxProvider, SmoothSendAvaxSubmitter, SmoothSendAvaxSubmitterConfig, SponsoredUserOpDraftAvax, SubmitSponsoredAvaxUserOpOptions, UseSmoothSendAvaxParams, UserOperationAvax, UserOperationReceiptAvax, avaxExecuteAbi, createSmoothSendAvaxSubmitter, encodeAvaxExecuteCalldata, encodeCreateAccountFactoryData, fetchAvaxAaPublicDefaults, hashUserOperationAvax, predictSimpleAccountAddress, readAvaxSenderNonce, useSmoothSendAvax, useSmoothSendAvaxContext, userOperationAvaxToViem } from './avax/index.js';
|
|
4
|
+
export { CAddressBalance, CAddressBalanceResult, CAddressBuildTransferResult, CAddressCreateResult, CAddressHealthResult, CAddressHistoryResult, CAddressLookupResult, CAddressSubmitResult, CAddressTransaction, StellarAdapter, StellarCAddressAdapter } from './stellar/index.js';
|
|
5
|
+
export { w as APTOS_ERROR_CODES, z as ApiResponse, x as AptosErrorCode, j as AptosTransferData, J as AptosWallet, Q as AuthenticationError, A as AvalancheTransferData, p as BatchRelayTransferRequest, B as BatchTransferRequest, a as CHAIN_ECOSYSTEM_MAP, d as ChainConfig, C as ChainEcosystem, c as ChainInfo, D as DomainSeparatorResponse, i as EVMTransferData, E as ErrorResponse, q as EstimateGasRequest, M as EventListener, F as FeeEstimate, G as GasEstimateResponse, u as HealthResponse, H as HttpClient, N as IChainAdapter, Y as NetworkError, s as PermitData, P as PrepareSignatureRequest, t as PrepareSignatureResponse, W as RateLimitError, o as RelayTransferRequest, R as RelayTransferResponse, y as STELLAR_ERROR_CODES, k as SignatureData, l as SignedTransferData, I as SmoothSendConfig, O as SmoothSendError, K as StellarWallet, b as SuccessResponse, S as SupportedChain, m as TokenBalance, T as TokenInfo, r as TransferData, L as TransferEvent, g as TransferQuote, n as TransferQuoteRequest, f as TransferQuoteResponse, e as TransferRequest, h as TransferResult, v as TransferStatusResponse, U as UsageMetadata, V as VERSION, X as ValidationError, Z as createErrorFromResponse, _ as createNetworkError } from './chunks/shared-Cn4duBJT.js';
|
|
6
|
+
import '@aptos-labs/ts-sdk';
|
|
7
|
+
import 'viem';
|
|
8
|
+
import 'viem/account-abstraction';
|
|
9
|
+
import 'react/jsx-runtime';
|
|
10
|
+
import 'react';
|
|
11
|
+
import 'axios';
|