@smoothsend/sdk 2.3.4 → 2.3.5

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.
Files changed (52) hide show
  1. package/dist/aptos/index.cjs +160 -0
  2. package/dist/aptos/index.cjs.map +1 -1
  3. package/dist/aptos/index.d.ts +65 -749
  4. package/dist/aptos/index.js +160 -3
  5. package/dist/aptos/index.js.map +1 -1
  6. package/dist/aptos-entry.d.ts +1 -0
  7. package/dist/aptos-entry.d.ts.map +1 -1
  8. package/dist/aptos-privy/SmoothSendAptosProvider.d.ts +7 -0
  9. package/dist/aptos-privy/SmoothSendAptosProvider.d.ts.map +1 -0
  10. package/dist/aptos-privy/index.cjs +40 -0
  11. package/dist/aptos-privy/index.cjs.map +1 -0
  12. package/dist/aptos-privy/index.d.ts +4 -0
  13. package/dist/aptos-privy/index.d.ts.map +1 -0
  14. package/dist/aptos-privy/index.js +34 -0
  15. package/dist/aptos-privy/index.js.map +1 -0
  16. package/dist/aptos-privy/normalizePrivyAptosWallet.d.ts +4 -0
  17. package/dist/aptos-privy/normalizePrivyAptosWallet.d.ts.map +1 -0
  18. package/dist/aptos-privy/privyAptosSigner.d.ts +32 -0
  19. package/dist/aptos-privy/privyAptosSigner.d.ts.map +1 -0
  20. package/dist/aptos-privy/types.d.ts +71 -0
  21. package/dist/aptos-privy/types.d.ts.map +1 -0
  22. package/dist/aptos-privy/useSmoothSendAptosPrivy.d.ts +13 -0
  23. package/dist/aptos-privy/useSmoothSendAptosPrivy.d.ts.map +1 -0
  24. package/dist/aptos-privy/useSmoothSendPrivyWrite.d.ts +13 -0
  25. package/dist/aptos-privy/useSmoothSendPrivyWrite.d.ts.map +1 -0
  26. package/dist/aptos-privy-entry.d.ts +9 -0
  27. package/dist/aptos-privy-entry.d.ts.map +1 -0
  28. package/dist/chunks/shared-2xx2VLH3.js +453 -0
  29. package/dist/chunks/shared-2xx2VLH3.js.map +1 -0
  30. package/dist/chunks/shared-B8UdyBTN.d.ts +143 -0
  31. package/dist/chunks/shared-BJv1JV1H.cjs +702 -0
  32. package/dist/chunks/shared-BJv1JV1H.cjs.map +1 -0
  33. package/dist/chunks/shared-BXvqbQ6f.d.ts +262 -0
  34. package/dist/chunks/shared-Bh4xtpHv.js +740 -0
  35. package/dist/chunks/shared-Bh4xtpHv.js.map +1 -0
  36. package/dist/chunks/shared-BlIQttCf.d.ts +1279 -0
  37. package/dist/chunks/shared-BoRfHN1w.js +1511 -0
  38. package/dist/chunks/shared-BoRfHN1w.js.map +1 -0
  39. package/dist/chunks/shared-CPpb2n9T.d.ts +780 -0
  40. package/dist/chunks/shared-CzR0rIwZ.cjs +635 -0
  41. package/dist/chunks/shared-CzR0rIwZ.cjs.map +1 -0
  42. package/dist/chunks/shared-DQbEIiTE.cjs +746 -0
  43. package/dist/chunks/shared-DQbEIiTE.cjs.map +1 -0
  44. package/dist/chunks/shared-DzwYUjQn.cjs +457 -0
  45. package/dist/chunks/shared-DzwYUjQn.cjs.map +1 -0
  46. package/dist/chunks/shared-KUvoQkzf.d.ts +471 -0
  47. package/dist/chunks/shared-XH1iLZjy.js +629 -0
  48. package/dist/chunks/shared-XH1iLZjy.js.map +1 -0
  49. package/dist/chunks/shared-kovW7ATj.js +694 -0
  50. package/dist/chunks/shared-kovW7ATj.js.map +1 -0
  51. package/dist/index.d.ts +1 -1
  52. package/package.json +1 -1
@@ -1,783 +1,99 @@
1
1
  export { S as SmoothSendSDK, S as default } from '../chunks/shared-RVkwmkG7.js';
2
- import { AptosConfig, AnyRawTransaction, AccountAuthenticator, PendingTransactionResponse, Account, InputGenerateTransactionPayloadData, Aptos } from '@aptos-labs/ts-sdk';
3
- import { N as IChainAdapter, S as SupportedChain, d as ChainConfig, e as TransferRequest, F as FeeEstimate, l as SignedTransferData, h as TransferResult, g as TransferQuote, k as SignatureData, m as TokenBalance, T as TokenInfo, u as HealthResponse } from '../chunks/shared-Cn4duBJT.js';
4
- 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, C as ChainEcosystem, c as ChainInfo, D as DomainSeparatorResponse, i as EVMTransferData, E as ErrorResponse, q as EstimateGasRequest, M as EventListener, G as GasEstimateResponse, H as HttpClient, 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, I as SmoothSendConfig, O as SmoothSendError, K as StellarWallet, b as SuccessResponse, r as TransferData, L as TransferEvent, n as TransferQuoteRequest, f as TransferQuoteResponse, v as TransferStatusResponse, U as UsageMetadata, V as VERSION, X as ValidationError, Z as createErrorFromResponse, _ as createNetworkError } from '../chunks/shared-Cn4duBJT.js';
2
+ export { A as AptosAdapter, B as BuildTransferParams, i as BuildTransferResult, C as CreateSessionOptions, E as ExecuteGaslessParams, o as ExecuteGaslessResult, F as FeeEstimateResult, f as ScriptComposerClient, h as ScriptComposerConfig, d as SessionInfo, b as SmoothSendSession, S as SmoothSendTransactionSubmitter, a as SmoothSendTransactionSubmitterConfig, e as SubmitResult, j as SubmitSignedTransactionParams, k as SubmitTransactionResult, T as TransactionSubmitter, l as TrueGaslessClient, n as TrueGaslessConfig, U as UseSmoothSendResult, g as createScriptComposerClient, c as createSmoothSendSubmitter, m as createTrueGaslessClient, u as useSmoothSend } from '../chunks/shared-CPpb2n9T.js';
3
+ 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';
4
+ import * as react_jsx_runtime from 'react/jsx-runtime';
5
+ import { ReactNode } from 'react';
6
+ import '@aptos-labs/ts-sdk';
5
7
  import 'axios';
6
8
 
7
9
  /**
8
- * SmoothSend Transaction Submitter
10
+ * Types for the Aptos Privy integration.
9
11
  *
10
- * A TransactionSubmitter implementation that integrates with the Aptos Wallet Adapter
11
- * to enable gasless transactions via SmoothSend's relayer network.
12
- *
13
- * @example
14
- * ```typescript
15
- * import { SmoothSendTransactionSubmitter } from '@smoothsend/sdk';
16
- * import { AptosWalletAdapterProvider } from '@aptos-labs/wallet-adapter-react';
17
- *
18
- * // Create the transaction submitter
19
- * const transactionSubmitter = new SmoothSendTransactionSubmitter({
20
- * apiKey: 'pk_nogas_your_api_key_here',
21
- * network: 'testnet'
22
- * });
23
- *
24
- * // Use in your wallet provider - that's it!
25
- * <AptosWalletAdapterProvider
26
- * dappConfig={{
27
- * network: Network.TESTNET,
28
- * transactionSubmitter: transactionSubmitter
29
- * }}
30
- * >
31
- * <App />
32
- * </AptosWalletAdapterProvider>
33
- * ```
12
+ * Privy Aptos wallets use Ed25519 keys. The frontend React SDK exposes
13
+ * `signMessage` (returns a hex signature), while the Node SDK exposes
14
+ * `rawSign`. Both produce the same Ed25519 signature over arbitrary bytes.
34
15
  */
35
-
36
16
  /**
37
- * Configuration options for SmoothSendTransactionSubmitter
38
- */
39
- interface SmoothSendTransactionSubmitterConfig {
40
- /**
41
- * Your SmoothSend API key
42
- * - Use `pk_nogas_*` for frontend applications (CORS protected)
43
- * - Use `sk_nogas_*` for backend applications only
44
- */
17
+ * A function that signs a raw byte-hash and returns a hex signature.
18
+ * Matches the shape of Privy's React `signMessage` return value.
19
+ */
20
+ type PrivyAptosSignFn = (args: {
21
+ message: Uint8Array;
22
+ }) => Promise<string>;
23
+ /**
24
+ * Configuration for the Aptos Privy provider context.
25
+ */
26
+ interface SmoothSendAptosProviderConfig {
45
27
  apiKey: string;
46
- /**
47
- * Network to use
48
- * @default 'testnet'
49
- */
50
28
  network?: 'testnet' | 'mainnet';
51
- /**
52
- * Gateway URL (usually you don't need to change this)
53
- * @default 'https://proxy.smoothsend.xyz'
54
- */
55
29
  gatewayUrl?: string;
56
- /**
57
- * Request timeout in milliseconds
58
- * @default 30000
59
- */
60
- timeout?: number;
61
- /**
62
- * A function that returns a captcha token (e.g. from Cloudflare Turnstile or reCAPTCHA).
63
- * Called before each transaction if the project requires captcha verification.
64
- * Return null/undefined to skip captcha.
65
- */
66
- getCaptchaToken?: () => Promise<string | null | undefined>;
67
- /**
68
- * Enable debug logging
69
- * @default false
70
- */
71
30
  debug?: boolean;
72
- /**
73
- * Enable session key mode — user signs once, all subsequent transactions
74
- * are signed silently by an in-memory session key. Zero wallet popups after setup.
75
- *
76
- * Uses Aptos Account Abstraction (AIP-103 Permissioned Signers) — enforced on-chain.
77
- * Live on mainnet and testnet (as of April 2025).
78
- * SmoothSend pays gas for the one-time session setup transaction too.
79
- *
80
- * @default false
81
- *
82
- * @example
83
- * ```typescript
84
- * const smoothSend = new SmoothSendTransactionSubmitter({
85
- * apiKey: 'pk_nogas_xxx',
86
- * network: 'mainnet',
87
- * session: true,
88
- * });
89
- * ```
90
- */
91
- session?: boolean;
92
- /**
93
- * How long the session key stays valid.
94
- * Format: number + unit (s, m, h, d)
95
- * Use "never" for client-side indefinite session validity.
96
- * @default '24h'
97
- */
98
- sessionDuration?: string;
99
- }
100
- /**
101
- * TransactionSubmitter interface compatible with @aptos-labs/ts-sdk v2.x
102
- * This interface allows the SmoothSendTransactionSubmitter to work as a drop-in
103
- * replacement for the default transaction submitter in the Aptos Wallet Adapter.
104
- */
105
- interface TransactionSubmitter {
106
- submitTransaction(args: {
107
- aptosConfig: AptosConfig;
108
- transaction: AnyRawTransaction;
109
- senderAuthenticator: AccountAuthenticator;
110
- feePayerAuthenticator?: AccountAuthenticator;
111
- additionalSignersAuthenticators?: Array<AccountAuthenticator>;
112
- pluginParams?: Record<string, unknown>;
113
- }): Promise<PendingTransactionResponse>;
114
- }
115
- /**
116
- * SmoothSend Transaction Submitter
117
- *
118
- * Implements the TransactionSubmitter interface to enable gasless transactions
119
- * through the Aptos Wallet Adapter. Simply pass this to your AptosWalletAdapterProvider
120
- * and all transactions will automatically be submitted as gasless through SmoothSend.
121
- */
122
- declare class SmoothSendTransactionSubmitter implements TransactionSubmitter {
123
- private readonly apiKey;
124
- private readonly network;
125
- private readonly gatewayUrl;
126
- private readonly timeout;
127
- private readonly getCaptchaToken?;
128
- private readonly debug;
129
- readonly sessionEnabled: boolean;
130
- private readonly sessionDuration;
131
- private _session;
132
- constructor(config: SmoothSendTransactionSubmitterConfig);
133
- /**
134
- * Whether a valid session is currently active.
135
- */
136
- hasSession(): boolean;
137
- /**
138
- * Create a session key for the given master account.
139
- * Called once by useSmoothSend when session: true and no session exists.
140
- * SmoothSend pays gas for the setup transaction.
141
- *
142
- * @param masterAccount - The user's wallet account (from wallet adapter)
143
- */
144
- createSession(masterAccount: Account): Promise<void>;
145
- private isPermissionedSignerEnabled;
146
- private signSenderAuthenticator;
147
- /**
148
- * Submit a transaction using the active session key — no wallet popup.
149
- * Called by useSmoothSend after session is established.
150
- */
151
- submitWithSession(functionName: `${string}::${string}::${string}`, functionArguments?: any[], typeArguments?: string[]): Promise<PendingTransactionResponse>;
152
- private _parseDuration;
153
- /**
154
- * Submit a transaction through SmoothSend's gasless relayer
155
- *
156
- * This method is called automatically by the Aptos Wallet Adapter when
157
- * you use signAndSubmitTransaction. The transaction is submitted to
158
- * SmoothSend's relayer which sponsors the gas fees.
159
- */
160
- submitTransaction(args: {
161
- aptosConfig: AptosConfig;
162
- transaction: AnyRawTransaction;
163
- senderAuthenticator: AccountAuthenticator;
164
- feePayerAuthenticator?: AccountAuthenticator;
165
- additionalSignersAuthenticators?: Array<AccountAuthenticator>;
166
- pluginParams?: Record<string, unknown>;
167
- }): Promise<PendingTransactionResponse>;
168
- /**
169
- * Resolve the effective network from aptosConfig.
170
- * aptosConfig.network is the source of truth set by AptosWalletAdapterProvider.
171
- */
172
- private resolveNetwork;
173
- /**
174
- * Make an HTTP request to the SmoothSend gateway
175
- */
176
- private makeRequest;
177
- private sponsoredFunctionsCache;
178
- private sponsoredFunctionsCacheAt;
179
- private readonly SPONSORED_CACHE_TTL;
180
- /**
181
- * Fetch the list of sponsored functions for this API key's project.
182
- * Results are cached for 5 minutes. Returns ['*'] if all functions are sponsored.
183
- */
184
- getSponsoredFunctions(): Promise<string[]>;
185
- /**
186
- * Check if a specific function is sponsored for gasless execution.
187
- * @param functionName - Full function identifier, e.g. "0x123::module::function"
188
- */
189
- isSponsored(functionName: string): Promise<boolean>;
190
- /**
191
- */
192
- getConfig(): Readonly<SmoothSendTransactionSubmitterConfig>;
193
31
  }
194
32
  /**
195
- * Create a SmoothSend transaction submitter with minimal configuration
196
- *
197
- * @example
198
- * ```typescript
199
- * const submitter = createSmoothSendSubmitter('pk_nogas_your_key');
200
- * ```
33
+ * Parameters for the `useSmoothSendPrivyWrite` hook (Aptos).
201
34
  */
202
- declare function createSmoothSendSubmitter(apiKey: string, options?: Partial<Omit<SmoothSendTransactionSubmitterConfig, 'apiKey'>>): SmoothSendTransactionSubmitter;
203
-
204
- /**
205
- * useSmoothSend — React hook for automatic gasless / user-pays-gas routing
206
- *
207
- * Drop-in replacement for useWallet()'s signAndSubmitTransaction.
208
- * Fetches the project's sponsored-functions list from the gateway on mount
209
- * and routes each transaction automatically:
210
- * - Function in allowlist → fee-payer gasless path via SmoothSend
211
- * - Function not in allowlist → regular wallet submission (user pays gas)
212
- *
213
- * When submitter has session: true, the first transaction triggers a one-time
214
- * wallet sign to register a session key on-chain. Every transaction after that
215
- * is signed silently — zero wallet popups.
216
- *
217
- * Requires: react >=17, @aptos-labs/wallet-adapter-react >=3, @aptos-labs/ts-sdk >=1
218
- *
219
- * @example
220
- * ```tsx
221
- * // Replace useWallet() with useSmoothSend() where you submit transactions.
222
- * // No other changes needed.
223
- *
224
- * const { signAndSubmitTransaction } = useSmoothSend(submitter);
225
- * await signAndSubmitTransaction({ data: { function: '0x1::coin::transfer', functionArguments: [to, amount] } });
226
- * ```
227
- */
228
-
229
- interface UseSmoothSendResult {
230
- /**
231
- * Smart signAndSubmitTransaction — same signature as the wallet adapter's version.
232
- * Sponsored functions go gasless via SmoothSend; others fall back to user-pays-gas.
233
- * With session: true, zero wallet popups after the first transaction.
234
- */
235
- signAndSubmitTransaction: (input: {
236
- data: any;
237
- options?: any;
238
- }) => Promise<any>;
239
- /**
240
- * Whether a session key is currently active (only relevant when session: true).
241
- * Updates reactively when session is created or expires.
242
- */
243
- hasSession: boolean;
244
- }
245
- declare function useSmoothSend(submitter: SmoothSendTransactionSubmitter): UseSmoothSendResult;
246
-
247
- interface CreateSessionOptions {
248
- /**
249
- * The master account that owns the Aptos address.
250
- * Can be a KeylessAccount (Google/Apple login), Ed25519Account, or any Account
251
- * that implements the Aptos Account interface.
252
- *
253
- * @example keylessAccount from aptos.deriveKeylessAccount(...)
254
- * @example Account.fromPrivateKey({ privateKey })
255
- */
256
- signer: Account;
257
- /**
258
- * How long the session should stay valid.
259
- * Format: number + unit (s = seconds, m = minutes, h = hours, d = days)
260
- * @example '2h' | '24h' | '7d' | 'never'
261
- */
262
- expiresIn: string;
263
- /**
264
- * Network to use. Inferred from submitter if not provided.
265
- */
35
+ interface UseSmoothSendAptosPrivyWriteParams {
36
+ /** Ed25519 public key hex of the Privy Aptos wallet (32 bytes, no 0x prefix or with) */
37
+ publicKey: string;
38
+ /** Aptos account address from Privy */
39
+ address: string;
40
+ /** Sign raw bytes — maps to Privy's `signMessage` / `rawSign` */
41
+ signTransaction: PrivyAptosSignFn;
42
+ /** Override provider-level API key */
43
+ apiKey?: string;
44
+ /** Override provider-level network */
266
45
  network?: 'testnet' | 'mainnet';
267
- }
268
- interface SessionInfo {
269
- /** The user's main account address — sender for all transactions */
270
- masterAddress: string;
271
- /** The temporary session key address (for debugging / display) */
272
- sessionKeyAddress: string;
273
- /** When this session expires (Unix timestamp in ms) */
274
- expiresAt: number;
275
- /** Network this session operates on */
276
- network: 'testnet' | 'mainnet';
277
- }
278
- interface SubmitResult {
279
- hash: string;
280
- }
281
- /**
282
- * A session that lets your app submit transactions on behalf of a user
283
- * without any wallet popup after the initial one-time setup.
284
- *
285
- * Uses Aptos AIP-103 Permissioned Signers — authorization is enforced
286
- * on-chain by `0x1::permissioned_delegation`. No custom Move contract needed.
287
- *
288
- * @example
289
- * // 1. One-time setup (user signs once — can be keyless/Google login)
290
- * const session = await SmoothSendSession.create({
291
- * signer: keylessAccount,
292
- * expiresIn: '24h',
293
- * }, submitter)
294
- *
295
- * // 2. Every action after — zero popups, zero gas
296
- * await session.submit('0xgame::player::move', ['north'])
297
- * await session.submit('0xgame::player::attack', [enemyId])
298
- */
299
- declare class SmoothSendSession {
300
- private readonly sessionAccount;
301
- private readonly abstractedAccount;
302
- private readonly masterAddress;
303
- private readonly expiresAtMs;
304
- private readonly submitter;
305
- private readonly aptosClient;
306
- private readonly _network;
307
- private constructor();
308
- /**
309
- * Create a new session.
310
- *
311
- * Registers the session key on-chain via
312
- * `0x1::permissioned_delegation::add_permissioned_handle`.
313
- * SmoothSend pays the gas for this setup transaction too.
314
- *
315
- * After this returns, the user never needs to approve anything again
316
- * until the session expires or is revoked.
317
- */
318
- static create(options: CreateSessionOptions, submitter: SmoothSendTransactionSubmitter): Promise<SmoothSendSession>;
319
- /**
320
- * Submit a transaction silently — no wallet popup, zero gas.
321
- *
322
- * The transaction sender on-chain is still the user's main address.
323
- * The session key signs it, and `permissioned_delegation::authenticate`
324
- * validates the authorization at the VM level.
325
- *
326
- * @param functionName Full Move function identifier e.g. '0xgame::player::move'
327
- * @param functionArguments Arguments matching the Move function signature
328
- * @param typeArguments Optional type arguments for generic functions
329
- *
330
- * @example
331
- * await session.submit('0xgame::player::move', ['north'])
332
- * await session.submit('0x1::coin::transfer', [recipientAddr, 1000000n])
333
- */
334
- submit(functionName: `${string}::${string}::${string}`, functionArguments?: any[], typeArguments?: string[]): Promise<SubmitResult>;
335
- /**
336
- * Whether this session is still valid (not yet expired).
337
- */
338
- isValid(): boolean;
339
- /**
340
- * Milliseconds until this session expires. Returns 0 if already expired.
341
- */
342
- expiresInMs(): number;
343
- /**
344
- * Session metadata — useful for display or debugging.
345
- */
346
- get info(): SessionInfo;
347
- }
348
-
349
- /**
350
- * Script Composer Client
351
- *
352
- * Wrapper for Script Composer gasless transactions.
353
- * Use this for token transfers on mainnet with free tier (fee deducted from token).
354
- *
355
- * @remarks
356
- * Script Composer builds a batched transaction that:
357
- * 1. Withdraws (amount + fee) from sender
358
- * 2. Deposits amount to recipient
359
- * 3. Deposits fee to treasury
360
- *
361
- * This allows gasless transactions where the fee is paid in the token being transferred.
362
- *
363
- * @example
364
- * ```typescript
365
- * import { ScriptComposerClient } from '@smoothsend/aptos-sdk';
366
- *
367
- * const client = new ScriptComposerClient({
368
- * apiKey: 'pk_nogas_xxx',
369
- * network: 'mainnet'
370
- * });
371
- *
372
- * // Step 1: Build transaction (fee calculated automatically)
373
- * const { transactionBytes, fee, totalAmount } = await client.buildTransfer({
374
- * sender: wallet.address,
375
- * recipient: '0x123...',
376
- * amount: '1000000', // 1 USDC (6 decimals)
377
- * assetType: '0x...::usdc::USDC',
378
- * decimals: 6,
379
- * symbol: 'USDC'
380
- * });
381
- *
382
- * // Step 2: Sign with wallet
383
- * const signedTx = await wallet.signTransaction(transactionBytes);
384
- *
385
- * // Step 3: Submit
386
- * const result = await client.submitSignedTransaction({
387
- * transactionBytes: signedTx.transactionBytes,
388
- * authenticatorBytes: signedTx.authenticatorBytes
389
- * });
390
- *
391
- * console.log('Tx:', result.txHash);
392
- * ```
393
- */
394
- /**
395
- * Configuration for Script Composer Client
396
- */
397
- interface ScriptComposerConfig {
398
- /** API key for authentication (pk_nogas_* or sk_nogas_*) */
399
- apiKey: string;
400
- /** Network to use: 'testnet' or 'mainnet' */
401
- network: 'testnet' | 'mainnet';
402
- /** Custom proxy URL (optional, defaults to proxy.smoothsend.xyz) */
403
- proxyUrl?: string;
404
- /** Request timeout in milliseconds (default: 30000) */
405
- timeout?: number;
406
- /** Enable debug logging */
46
+ /** Override provider-level gateway URL */
47
+ gatewayUrl?: string;
407
48
  debug?: boolean;
408
49
  }
409
50
  /**
410
- * Parameters for building a Script Composer transfer
411
- */
412
- interface BuildTransferParams {
413
- /** Sender's wallet address */
414
- sender: string;
415
- /** Recipient's wallet address */
416
- recipient: string;
417
- /** Amount in smallest units (e.g., 1000000 for 1 USDC) */
418
- amount: string;
419
- /** Full asset type address (e.g., '0x...::usdc::USDC') */
420
- assetType: string;
421
- /** Token decimals (e.g., 6 for USDC, 8 for APT) */
422
- decimals: number;
423
- /** Token symbol (e.g., 'USDC', 'APT') */
424
- symbol: string;
425
- }
426
- /**
427
- * Result from building a transfer
51
+ * Return type from `useSmoothSendPrivyWrite` (Aptos).
428
52
  */
429
- interface BuildTransferResult {
430
- /** Success status */
431
- success: boolean;
432
- /** Request ID for tracking */
433
- requestId: string;
434
- /** Serialized transaction bytes for wallet signing */
435
- transactionBytes: number[];
436
- /** Transaction details */
437
- transaction: {
438
- sender: string;
439
- recipient: string;
440
- amount: string;
441
- assetType: string;
442
- network: string;
443
- };
444
- /** Fee amount in smallest units */
445
- fee: string;
446
- /** Total amount (amount + fee) in smallest units */
447
- totalAmount: string;
448
- /** Fee breakdown with formatted values */
449
- feeBreakdown: {
450
- amount: string;
451
- fee: string;
452
- totalAmount: string;
453
- formatted: {
454
- amount: string;
455
- fee: string;
456
- totalAmount: string;
457
- };
458
- pricing: {
459
- tier: string;
460
- zeroFees: boolean;
461
- feeInUsd: number;
462
- tokenPrice: number | null;
463
- description: string;
464
- };
465
- };
53
+ interface UseSmoothSendAptosPrivyWriteResult {
54
+ submitTransaction: (input: AptosTransactionInput) => Promise<AptosTransactionResult>;
55
+ isPending: boolean;
56
+ data: AptosTransactionResult | null;
57
+ error: Error | null;
58
+ reset: () => void;
466
59
  }
467
60
  /**
468
- * Parameters for submitting a signed transaction
61
+ * Aptos transaction input — mirrors the `data` field from `aptos.transaction.build.simple`.
469
62
  */
470
- interface SubmitSignedTransactionParams {
471
- /** Serialized transaction bytes (from wallet signing) */
472
- transactionBytes: number[];
473
- /** Serialized authenticator bytes (from wallet signing) */
474
- authenticatorBytes: number[];
63
+ interface AptosTransactionInput {
64
+ /** Fully qualified Move function, e.g. `0x1::coin::transfer` */
65
+ function: `${string}::${string}::${string}`;
66
+ /** Type arguments, e.g. `['0x1::aptos_coin::AptosCoin']` */
67
+ typeArguments?: string[];
68
+ /** Function arguments, e.g. `['0xrecipient', 100]` */
69
+ functionArguments?: any[];
475
70
  }
476
71
  /**
477
- * Result from submitting a transaction
72
+ * Result of a successful Aptos gasless transaction.
478
73
  */
479
- interface SubmitTransactionResult {
480
- /** Success status */
481
- success: boolean;
482
- /** Request ID for tracking */
483
- requestId: string;
484
- /** Transaction hash */
485
- txHash: string;
486
- /** Gas used */
487
- gasUsed?: string;
488
- /** VM status */
489
- vmStatus?: string;
490
- /** Sender address */
491
- sender?: string;
492
- }
493
- /**
494
- * Fee estimation result
495
- */
496
- interface FeeEstimateResult {
497
- /** Success status */
74
+ interface AptosTransactionResult {
75
+ hash: string;
76
+ sender: string;
498
77
  success: boolean;
499
- /** Request ID for tracking */
500
- requestId: string;
501
- /** Fee estimation details */
502
- estimation: {
503
- /** Amount in smallest units */
504
- amount: string;
505
- /** Fee in smallest units */
506
- fee: string;
507
- /** Total amount in smallest units */
508
- totalAmount: string;
509
- /** Formatted values for display */
510
- formatted: {
511
- amount: string;
512
- fee: string;
513
- totalAmount: string;
514
- };
515
- /** Pricing information */
516
- pricing: {
517
- tier: string;
518
- zeroFees: boolean;
519
- feeInUsd: number;
520
- tokenPrice: number | null;
521
- description: string;
522
- };
523
- /** Usage information */
524
- usage: {
525
- monthlyLimit: number;
526
- usedThisMonth: number;
527
- remaining: number;
528
- };
529
- };
530
78
  }
531
- /**
532
- * Script Composer Client
533
- *
534
- * For gasless token transfers with fee deducted from the token.
535
- * Use this on mainnet with free tier, or anytime you want fee-in-token.
536
- */
537
- declare class ScriptComposerClient {
538
- private httpClient;
539
- private config;
540
- constructor(config: ScriptComposerConfig);
541
- private isBrowser;
542
- private log;
543
- /**
544
- * Estimate fee for a transfer without building the transaction
545
- *
546
- * @param params Transfer parameters
547
- * @returns Fee estimation with pricing details
548
- */
549
- estimateFee(params: BuildTransferParams): Promise<FeeEstimateResult>;
550
- /**
551
- * Build a gasless transfer transaction
552
- *
553
- * Returns unsigned transaction bytes that must be signed by the user's wallet.
554
- * The fee will be deducted from the token being transferred.
555
- *
556
- * @param params Transfer parameters
557
- * @returns Transaction bytes for signing and fee details
558
- */
559
- buildTransfer(params: BuildTransferParams): Promise<BuildTransferResult>;
560
- /**
561
- * Submit a signed transaction
562
- *
563
- * After the user signs the transaction bytes returned by buildTransfer(),
564
- * use this method to submit the signed transaction.
565
- *
566
- * @param params Signed transaction bytes
567
- * @returns Transaction result with hash
568
- */
569
- submitSignedTransaction(params: SubmitSignedTransactionParams): Promise<SubmitTransactionResult>;
570
- /**
571
- * Complete transfer flow: build, sign, and submit
572
- *
573
- * Convenience method that handles the entire flow.
574
- * Requires a wallet that can sign transactions.
575
- *
576
- * @param params Transfer parameters
577
- * @param wallet Wallet with signTransaction method
578
- * @returns Transaction result
579
- *
580
- * @example
581
- * ```typescript
582
- * const result = await client.transfer({
583
- * sender: wallet.address,
584
- * recipient: '0x123...',
585
- * amount: '1000000',
586
- * assetType: USDC_ADDRESS,
587
- * decimals: 6,
588
- * symbol: 'USDC'
589
- * }, wallet);
590
- * ```
591
- */
592
- transfer(params: BuildTransferParams, wallet: {
593
- signTransaction: (txBytes: number[]) => Promise<{
594
- transactionBytes: number[];
595
- authenticatorBytes: number[];
596
- }>;
597
- }): Promise<SubmitTransactionResult>;
598
- /**
599
- * Get current network
600
- */
601
- getNetwork(): 'testnet' | 'mainnet';
602
- /**
603
- * Set network
604
- */
605
- setNetwork(network: 'testnet' | 'mainnet'): void;
606
- }
607
- /**
608
- * Create a Script Composer client (convenience function)
609
- */
610
- declare function createScriptComposerClient(config: ScriptComposerConfig): ScriptComposerClient;
79
+
80
+ declare function SmoothSendAptosProvider({ apiKey, network, gatewayUrl, debug, children, }: SmoothSendAptosProviderConfig & {
81
+ children: ReactNode;
82
+ }): react_jsx_runtime.JSX.Element;
83
+ declare function useSmoothSendAptosContext(): SmoothSendAptosProviderConfig | null;
611
84
 
612
85
  /**
613
- * True Gasless Client
614
- *
615
- * Designed for server-side (backend) environments to securely build, sign,
616
- * and submit 100% sponsored gasless transactions using a Secret Key.
86
+ * useSmoothSendPrivyWrite — Aptos gasless hook for Privy embedded wallets.
617
87
  *
618
- * @example
619
- * ```typescript
620
- * import { TrueGaslessClient } from '@smoothsend/sdk';
621
- * import { Account } from '@aptos-labs/ts-sdk';
88
+ * Builds the transaction with `withFeePayer: true`, asks Privy to sign the
89
+ * sender portion (Ed25519), then submits the serialized tx + authenticator
90
+ * to the SmoothSend gateway/relayer which adds the fee-payer signature
91
+ * and broadcasts to the Aptos network.
622
92
  *
623
- * const backendWallet = Account.fromPrivateKey({ privateKey: '...' });
624
- * const client = new TrueGaslessClient({ apiKey: 'sk_nogas_...', network: 'mainnet' });
625
- *
626
- * const result = await client.execute({
627
- * senderAccount: backendWallet,
628
- * payload: {
629
- * function: "0x123::my_module::mint_nft",
630
- * functionArguments: []
631
- * }
632
- * });
633
- *
634
- * console.log("Gasless NFT Minted!", result.txHash);
635
- * ```
93
+ * No backend changes needed — reuses the existing Aptos relayer.
636
94
  */
637
95
 
638
- interface TrueGaslessConfig {
639
- /** API key for authentication (must be sk_nogas_* for backend) */
640
- apiKey: string;
641
- /** Network to use: 'testnet' | 'mainnet' */
642
- network: 'testnet' | 'mainnet';
643
- /** Custom proxy URL (optional) */
644
- proxyUrl?: string;
645
- /** Request timeout in milliseconds */
646
- timeout?: number;
647
- /** Enable debug logging */
648
- debug?: boolean;
649
- }
650
- interface ExecuteGaslessParams {
651
- /** The backend sender wallet identity */
652
- senderAccount: Account;
653
- /** Raw transaction payload to execute */
654
- payload: InputGenerateTransactionPayloadData;
655
- }
656
- interface ExecuteGaslessResult {
657
- success: boolean;
658
- requestId?: string;
659
- txHash?: string;
660
- gasUsed?: string;
661
- vmStatus?: string;
662
- sender?: string;
663
- }
664
- declare class TrueGaslessClient {
665
- private httpClient;
666
- private config;
667
- private aptos;
668
- constructor(config: TrueGaslessConfig);
669
- private log;
670
- /**
671
- * Builds, signs (as sender), and relays an arbitrary payload for complete sponsorship.
672
- */
673
- execute(params: ExecuteGaslessParams): Promise<ExecuteGaslessResult>;
674
- /**
675
- * Expose the core Aptos instance to allow backend developers to access chain state if needed
676
- */
677
- getAptosClient(): Aptos;
678
- }
679
- /**
680
- * Helper to initialize TrueGaslessClient
681
- */
682
- declare function createTrueGaslessClient(config: TrueGaslessConfig): TrueGaslessClient;
683
-
684
- /**
685
- * Aptos Multi-Chain Adapter - v2 Proxy Architecture
686
- * Handles all Aptos chains (aptos-testnet, aptos-mainnet)
687
- * Routes all requests through proxy.smoothsend.xyz with API key authentication
688
- * Supports Aptos-specific features like gasless transactions and Move-based contracts
689
- */
690
- declare class AptosAdapter implements IChainAdapter {
691
- readonly chain: SupportedChain;
692
- readonly config: ChainConfig;
693
- private httpClient;
694
- private apiKey;
695
- private network;
696
- constructor(chain: SupportedChain, config: ChainConfig, apiKey: string, network?: 'testnet' | 'mainnet', includeOrigin?: boolean);
697
- /**
698
- * Build API path for proxy worker routing to Aptos relayer
699
- * All requests route through /api/v1/relayer/aptos/* endpoints
700
- */
701
- private getApiPath;
702
- /**
703
- * Update network parameter for subsequent requests
704
- * Network is passed via X-Network header to proxy worker
705
- */
706
- setNetwork(network: 'testnet' | 'mainnet'): void;
707
- /**
708
- * Get current network
709
- */
710
- getNetwork(): 'testnet' | 'mainnet';
711
- /**
712
- * Estimate fee for a transfer (v2 interface method)
713
- * Routes through proxy: POST /api/v1/relayer/aptos/quote
714
- */
715
- estimateFee(request: TransferRequest): Promise<FeeEstimate>;
716
- /**
717
- * Execute gasless transfer (v2 interface method)
718
- * Routes through proxy: POST /api/v1/relayer/aptos/execute
719
- */
720
- executeGaslessTransfer(signedData: SignedTransferData): Promise<TransferResult>;
721
- /**
722
- * Get quote for a transfer (legacy method, kept for backward compatibility)
723
- * Routes through proxy: POST /api/v1/relayer/aptos/quote
724
- */
725
- getQuote(request: TransferRequest): Promise<TransferQuote>;
726
- prepareTransfer(request: TransferRequest, quote: TransferQuote): Promise<SignatureData>;
727
- executeTransfer(signedData: SignedTransferData): Promise<TransferResult>;
728
- getBalance(address: string, token?: string): Promise<TokenBalance[]>;
729
- getTokenInfo(token: string): Promise<TokenInfo>;
730
- getNonce(address: string): Promise<string>;
731
- getTransactionStatus(txHash: string): Promise<any>;
732
- /**
733
- * Get health status of Aptos relayer through proxy
734
- * Routes through proxy: GET /api/v1/relayer/aptos/health
735
- */
736
- getHealth(): Promise<HealthResponse>;
737
- validateAddress(address: string): boolean;
738
- validateAmount(amount: string): boolean;
739
- /**
740
- * Get Aptos token address from symbol
741
- * Mirrors aptosrelayer/config/chains.json
742
- */
743
- private getAptosTokenAddress;
744
- /**
745
- * Build Aptos explorer URL for transaction
746
- */
747
- private buildAptosExplorerUrl;
748
- /**
749
- * Validate serialized transaction data for proxy worker
750
- * @param signedData The signed transfer data to validate
751
- */
752
- private validateSerializedTransactionData;
753
- /**
754
- * Enhanced address validation with detailed error messages
755
- * @param address The address to validate
756
- * @returns true if valid, throws error if invalid
757
- */
758
- validateAddressStrict(address: string): boolean;
759
- /**
760
- * Verify that a public key corresponds to an expected address
761
- * This mirrors the enhanced verification in the relayer
762
- * @param publicKey The public key to verify
763
- * @param expectedAddress The expected address
764
- * @returns true if they match
765
- */
766
- verifyPublicKeyAddress(publicKey: string, expectedAddress: string): Promise<boolean>;
767
- /**
768
- * Enhanced transaction preparation with better signature data structure
769
- * @param request Transfer request
770
- * @param quote Transfer quote
771
- * @returns Signature data with enhanced structure
772
- */
773
- prepareTransferEnhanced(request: TransferRequest, quote: TransferQuote): Promise<SignatureData & {
774
- metadata: any;
775
- }>;
776
- /**
777
- * Aptos-specific Move contract interaction
778
- */
779
- callMoveFunction(functionName: string, args: any[]): Promise<any>;
780
- }
96
+ declare function useSmoothSendPrivyWrite(params: UseSmoothSendAptosPrivyWriteParams): UseSmoothSendAptosPrivyWriteResult;
781
97
 
782
- export { AptosAdapter, ChainConfig, FeeEstimate, HealthResponse, IChainAdapter, ScriptComposerClient, SignatureData, SignedTransferData, SmoothSendSession, SmoothSendTransactionSubmitter, SupportedChain, TokenBalance, TokenInfo, TransferQuote, TransferRequest, TransferResult, TrueGaslessClient, createScriptComposerClient, createSmoothSendSubmitter, createTrueGaslessClient, useSmoothSend };
783
- export type { BuildTransferParams, BuildTransferResult, CreateSessionOptions, ExecuteGaslessParams, ExecuteGaslessResult, FeeEstimateResult, ScriptComposerConfig, SessionInfo, SmoothSendTransactionSubmitterConfig, SubmitResult, SubmitSignedTransactionParams, SubmitTransactionResult, TransactionSubmitter, TrueGaslessConfig, UseSmoothSendResult };
98
+ export { SmoothSendAptosProvider, useSmoothSendAptosContext, useSmoothSendPrivyWrite };
99
+ export type { AptosTransactionInput, AptosTransactionResult, PrivyAptosSignFn, SmoothSendAptosProviderConfig, UseSmoothSendAptosPrivyWriteParams, UseSmoothSendAptosPrivyWriteResult };