@smoothsend/sdk 2.3.6 → 2.3.7

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 (77) hide show
  1. package/LICENSE +22 -22
  2. package/README.md +349 -349
  3. package/dist/adapters/evm.d.ts +39 -0
  4. package/dist/adapters/evm.d.ts.map +1 -0
  5. package/dist/config/chains.d.ts +7 -0
  6. package/dist/config/chains.d.ts.map +1 -0
  7. package/dist/index.esm.js +3 -1846
  8. package/dist/index.esm.js.map +1 -1
  9. package/dist/services/chainConfigService.d.ts +49 -0
  10. package/dist/services/chainConfigService.d.ts.map +1 -0
  11. package/package.json +120 -120
  12. package/dist/aptos-privy/index.cjs +0 -40
  13. package/dist/aptos-privy/index.cjs.map +0 -1
  14. package/dist/aptos-privy/index.js +0 -34
  15. package/dist/aptos-privy/index.js.map +0 -1
  16. package/dist/aptos-privy/normalizePrivyAptosWallet.d.ts +0 -4
  17. package/dist/aptos-privy/normalizePrivyAptosWallet.d.ts.map +0 -1
  18. package/dist/aptos-privy/privyAptosSigner.d.ts +0 -32
  19. package/dist/aptos-privy/privyAptosSigner.d.ts.map +0 -1
  20. package/dist/aptos-privy/useSmoothSendAptosPrivy.d.ts +0 -13
  21. package/dist/aptos-privy/useSmoothSendAptosPrivy.d.ts.map +0 -1
  22. package/dist/aptos-privy-entry.d.ts +0 -9
  23. package/dist/aptos-privy-entry.d.ts.map +0 -1
  24. package/dist/chunks/SmoothSendSDK-C_ofuBkk.cjs +0 -1519
  25. package/dist/chunks/SmoothSendSDK-C_ofuBkk.cjs.map +0 -1
  26. package/dist/chunks/SmoothSendSDK-CaV_PCIG.js +0 -1511
  27. package/dist/chunks/SmoothSendSDK-CaV_PCIG.js.map +0 -1
  28. package/dist/chunks/SmoothSendSDK.d-9GBgZONY.d.ts +0 -262
  29. package/dist/chunks/TrueGaslessClient-DThO4Tpb.cjs +0 -1237
  30. package/dist/chunks/TrueGaslessClient-DThO4Tpb.cjs.map +0 -1
  31. package/dist/chunks/TrueGaslessClient-l2uFvNAa.js +0 -1228
  32. package/dist/chunks/TrueGaslessClient-l2uFvNAa.js.map +0 -1
  33. package/dist/chunks/shared-2xx2VLH3.js +0 -453
  34. package/dist/chunks/shared-2xx2VLH3.js.map +0 -1
  35. package/dist/chunks/shared-B8UdyBTN.d.ts +0 -143
  36. package/dist/chunks/shared-BJv1JV1H.cjs +0 -702
  37. package/dist/chunks/shared-BJv1JV1H.cjs.map +0 -1
  38. package/dist/chunks/shared-BXvqbQ6f.d.ts +0 -262
  39. package/dist/chunks/shared-Bh4xtpHv.js +0 -740
  40. package/dist/chunks/shared-Bh4xtpHv.js.map +0 -1
  41. package/dist/chunks/shared-BlIQttCf.d.ts +0 -1279
  42. package/dist/chunks/shared-BoRfHN1w.js +0 -1511
  43. package/dist/chunks/shared-BoRfHN1w.js.map +0 -1
  44. package/dist/chunks/shared-CNF22ESH.js +0 -557
  45. package/dist/chunks/shared-CNF22ESH.js.map +0 -1
  46. package/dist/chunks/shared-CPpb2n9T.d.ts +0 -780
  47. package/dist/chunks/shared-CaQMAGQR.js +0 -1511
  48. package/dist/chunks/shared-CaQMAGQR.js.map +0 -1
  49. package/dist/chunks/shared-Cgb7mhwI.d.ts +0 -471
  50. package/dist/chunks/shared-Cn4duBJT.d.ts +0 -1279
  51. package/dist/chunks/shared-CzR0rIwZ.cjs +0 -635
  52. package/dist/chunks/shared-CzR0rIwZ.cjs.map +0 -1
  53. package/dist/chunks/shared-DEurKmpI.cjs +0 -1519
  54. package/dist/chunks/shared-DEurKmpI.cjs.map +0 -1
  55. package/dist/chunks/shared-DQbEIiTE.cjs +0 -746
  56. package/dist/chunks/shared-DQbEIiTE.cjs.map +0 -1
  57. package/dist/chunks/shared-DYAVFARB.d.ts +0 -472
  58. package/dist/chunks/shared-DzwYUjQn.cjs +0 -457
  59. package/dist/chunks/shared-DzwYUjQn.cjs.map +0 -1
  60. package/dist/chunks/shared-KUvoQkzf.d.ts +0 -471
  61. package/dist/chunks/shared-RVkwmkG7.d.ts +0 -262
  62. package/dist/chunks/shared-XH1iLZjy.js +0 -629
  63. package/dist/chunks/shared-XH1iLZjy.js.map +0 -1
  64. package/dist/chunks/shared-kovW7ATj.js +0 -694
  65. package/dist/chunks/shared-kovW7ATj.js.map +0 -1
  66. package/dist/chunks/shared-viO0MYao.d.ts +0 -459
  67. package/dist/chunks/shared-x1-VC-Li.cjs +0 -568
  68. package/dist/chunks/shared-x1-VC-Li.cjs.map +0 -1
  69. package/dist/chunks/useSmoothSendAvax-BHeW_6x8.cjs +0 -1865
  70. package/dist/chunks/useSmoothSendAvax-BHeW_6x8.cjs.map +0 -1
  71. package/dist/chunks/useSmoothSendAvax-ZuHw1aYi.js +0 -1848
  72. package/dist/chunks/useSmoothSendAvax-ZuHw1aYi.js.map +0 -1
  73. package/dist/chunks/version-CNF22ESH.js +0 -557
  74. package/dist/chunks/version-CNF22ESH.js.map +0 -1
  75. package/dist/chunks/version-x1-VC-Li.cjs +0 -568
  76. package/dist/chunks/version-x1-VC-Li.cjs.map +0 -1
  77. package/dist/chunks/version.d-Cn4duBJT.d.ts +0 -1279
@@ -1,629 +0,0 @@
1
- import { useMemo, useState, useRef, useCallback } from 'react';
2
- import { Network, Aptos, AptosConfig, Account, MoveVector, AccountAddress, AbstractedAccount, generateSigningMessageForTransaction, AccountAuthenticatorEd25519, Ed25519PublicKey, Ed25519Signature } from '@aptos-labs/ts-sdk';
3
-
4
- /**
5
- * Pre-compiled Move script bytecode for add_permissioned_handle
6
- *
7
- * This bytecode is used to register session keys on-chain via the
8
- * `0x1::permissioned_delegation::add_permissioned_handle` function.
9
- *
10
- * The function cannot be called as an entry function directly — only via a Move script.
11
- * This bytecode handles:
12
- * - Takes the session public key bytes (vector<u8>) as input
13
- * - Constructs DelegationKey from the bytes
14
- * - Passes option::none() for rate limiter
15
- * - Hardcodes u64::MAX for expiration (on-chain handle never expires)
16
- *
17
- * Source: aptos-labs/aptos-ts-sdk tests/e2e/transaction/helper.ts
18
- */
19
- const ADD_PERMISSIONED_HANDLE_BYTECODE = 'a11ceb0b0700000a0801001002101603262c04520405563d079301d70208ea034010aa041f0103010401060109010d010e011201140002080002080700030b0700040c0f0005100701000001050301010001020704050001030a05060001050f01080100010311090a000106130b01000107150b0100010002030702060c0a020001080001060c010a02010801010802010803010b0401090004060c08020b0401080303010c03060c060c03050802030b04010803060c0c083c53454c463e5f30046d61696e094170746f73436f696e0a6170746f735f636f696e04636f696e196d6967726174655f746f5f66756e6769626c655f73746f72650765643235353139256e65775f756e76616c6964617465645f7075626c69635f6b65795f66726f6d5f627974657314556e76616c6964617465645075626c69634b657917' +
20
- '7065726d697373696f6e65645f64656c65676174696f6e0f67656e5f656432353531395f6b65790d44656c65676174696f6e4b65790b526174654c696d697465720c726174655f6c696d69746572066f7074696f6e046e6f6e65064f7074696f6e176164645f7065726d697373696f6e65645f68616e646c65167072696d6172795f66756e6769626c655f73746f7265146772616e745f6170745f7065726d697373696f6e167472616e73616374696f6e5f76616c69646174696f6e146772616e745f6761735f7065726d697373696f6effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000000000000000000000000000000000000000000000000000000000000114636f6d70696c6174696f6e5f6d65746164617461090003322e3003322e3100000c170a0038000b01110111020c020a0038010c040b020b040600a0724e1809000011040c060a000e060600e1f5050000000011050b000e060600e1f50500000000110602';
21
-
22
- /**
23
- * SmoothSend Transaction Submitter
24
- *
25
- * A TransactionSubmitter implementation that integrates with the Aptos Wallet Adapter
26
- * to enable gasless transactions via SmoothSend's relayer network.
27
- *
28
- * @example
29
- * ```typescript
30
- * import { SmoothSendTransactionSubmitter } from '@smoothsend/sdk';
31
- * import { AptosWalletAdapterProvider } from '@aptos-labs/wallet-adapter-react';
32
- *
33
- * // Create the transaction submitter
34
- * const transactionSubmitter = new SmoothSendTransactionSubmitter({
35
- * apiKey: 'pk_nogas_your_api_key_here',
36
- * network: 'testnet'
37
- * });
38
- *
39
- * // Use in your wallet provider - that's it!
40
- * <AptosWalletAdapterProvider
41
- * dappConfig={{
42
- * network: Network.TESTNET,
43
- * transactionSubmitter: transactionSubmitter
44
- * }}
45
- * >
46
- * <App />
47
- * </AptosWalletAdapterProvider>
48
- * ```
49
- */
50
- /**
51
- * SmoothSend Transaction Submitter
52
- *
53
- * Implements the TransactionSubmitter interface to enable gasless transactions
54
- * through the Aptos Wallet Adapter. Simply pass this to your AptosWalletAdapterProvider
55
- * and all transactions will automatically be submitted as gasless through SmoothSend.
56
- */
57
- class SmoothSendTransactionSubmitter {
58
- constructor(config) {
59
- this._session = null;
60
- this.sponsoredFunctionsCache = null;
61
- this.sponsoredFunctionsCacheAt = 0;
62
- this.SPONSORED_CACHE_TTL = 5 * 60 * 1000; // 5 minutes
63
- if (!config.apiKey) {
64
- throw new Error('SmoothSend API key is required. Get your key at dashboard.smoothsend.xyz');
65
- }
66
- // Validate API key format
67
- if (!config.apiKey.startsWith('pk_nogas_') &&
68
- !config.apiKey.startsWith('sk_nogas_') &&
69
- !config.apiKey.startsWith('no_gas_')) {
70
- throw new Error('Invalid API key format. Key must start with pk_nogas_, sk_nogas_, or no_gas_');
71
- }
72
- // Warn if using secret key in browser
73
- if (config.apiKey.startsWith('sk_nogas_') && typeof window !== 'undefined') {
74
- console.warn('⚠️ WARNING: Secret key detected in browser environment.\n' +
75
- 'Secret keys (sk_nogas_*) should only be used in server-side code.\n' +
76
- 'Use public keys (pk_nogas_*) for frontend applications.');
77
- }
78
- this.apiKey = config.apiKey;
79
- this.network = config.network || 'testnet';
80
- this.gatewayUrl = config.gatewayUrl || 'https://proxy.smoothsend.xyz';
81
- this.timeout = config.timeout || 30000;
82
- this.getCaptchaToken = config.getCaptchaToken;
83
- this.debug = config.debug || false;
84
- this.sessionEnabled = config.session || false;
85
- this.sessionDuration = config.sessionDuration || '24h';
86
- }
87
- // ─── Session key methods ────────────────────────────────────────────────────
88
- /**
89
- * Whether a valid session is currently active.
90
- */
91
- hasSession() {
92
- return this._session !== null && Date.now() < this._session.expiresAtMs;
93
- }
94
- /**
95
- * Create a session key for the given master account.
96
- * Called once by useSmoothSend when session: true and no session exists.
97
- * SmoothSend pays gas for the setup transaction.
98
- *
99
- * @param masterAccount - The user's wallet account (from wallet adapter)
100
- */
101
- async createSession(masterAccount) {
102
- const network = this.network === 'mainnet' ? Network.MAINNET : Network.TESTNET;
103
- const aptosClient = new Aptos(new AptosConfig({ network }));
104
- // Generate fresh in-memory session keypair
105
- const sessionAccount = Account.generate();
106
- const expiresAtMs = Date.now() + this._parseDuration(this.sessionDuration);
107
- // Step 1: Register session key on-chain via pre-compiled Move script
108
- const setupTx = await aptosClient.transaction.build.simple({
109
- sender: masterAccount.accountAddress,
110
- withFeePayer: true,
111
- data: {
112
- bytecode: ADD_PERMISSIONED_HANDLE_BYTECODE,
113
- functionArguments: [MoveVector.U8(sessionAccount.publicKey.toUint8Array())],
114
- },
115
- options: {
116
- replayProtectionNonce: BigInt(Math.floor(Math.random() * Number.MAX_SAFE_INTEGER)),
117
- },
118
- });
119
- const senderAuth = await this.signSenderAuthenticator(masterAccount, setupTx, aptosClient);
120
- const setupResult = await this.submitTransaction({
121
- aptosConfig: aptosClient.config,
122
- transaction: setupTx,
123
- senderAuthenticator: senderAuth,
124
- });
125
- await aptosClient.waitForTransaction({ transactionHash: setupResult.hash });
126
- if (this.debug) {
127
- console.log('[SmoothSend] Session key registered on-chain:', setupResult.hash);
128
- }
129
- // Step 2: Enable account abstraction (idempotent — skip if already on)
130
- const aaEnabled = await aptosClient.abstraction.isAccountAbstractionEnabled({
131
- accountAddress: masterAccount.accountAddress,
132
- authenticationFunction: '0x1::permissioned_delegation::authenticate',
133
- });
134
- if (!aaEnabled) {
135
- const aaTx = await aptosClient.transaction.build.simple({
136
- sender: masterAccount.accountAddress,
137
- withFeePayer: true,
138
- data: {
139
- function: '0x1::account_abstraction::add_authentication_function',
140
- functionArguments: [
141
- AccountAddress.fromString('0x1'),
142
- 'permissioned_delegation',
143
- 'authenticate',
144
- ],
145
- },
146
- options: {
147
- replayProtectionNonce: BigInt(Math.floor(Math.random() * Number.MAX_SAFE_INTEGER)),
148
- },
149
- });
150
- const aaAuth = await this.signSenderAuthenticator(masterAccount, aaTx, aptosClient);
151
- const aaResult = await this.submitTransaction({
152
- aptosConfig: aptosClient.config,
153
- transaction: aaTx,
154
- senderAuthenticator: aaAuth,
155
- });
156
- await aptosClient.waitForTransaction({ transactionHash: aaResult.hash });
157
- if (this.debug) {
158
- console.log('[SmoothSend] Account abstraction enabled:', aaResult.hash);
159
- }
160
- }
161
- // Build AbstractedAccount — signs future txs with session key,
162
- // sender on-chain = master address, chain validates via permissioned_delegation
163
- const abstractedAccount = AbstractedAccount.fromPermissionedSigner({
164
- signer: sessionAccount,
165
- accountAddress: masterAccount.accountAddress,
166
- });
167
- this._session = {
168
- sessionAccount,
169
- abstractedAccount,
170
- masterAddress: masterAccount.accountAddress,
171
- expiresAtMs,
172
- aptosClient,
173
- };
174
- }
175
- async isPermissionedSignerEnabled(aptosClient) {
176
- try {
177
- const result = await aptosClient.view({
178
- payload: {
179
- function: '0x1::features::is_permissioned_signer_enabled',
180
- functionArguments: [],
181
- },
182
- });
183
- return Array.isArray(result) && result[0] === true;
184
- }
185
- catch (error) {
186
- if (this.debug) {
187
- console.warn('[SmoothSend] Failed to probe permissioned signer feature:', error);
188
- }
189
- return false;
190
- }
191
- }
192
- async signSenderAuthenticator(signer, transaction, aptosClient) {
193
- const walletLikeSigner = signer;
194
- // Wallet-adapter compatible path (returns { authenticator, rawTransaction } in v8)
195
- if (typeof walletLikeSigner?.signTransactionWithAuthenticator === 'function') {
196
- const result = await walletLikeSigner.signTransactionWithAuthenticator(transaction);
197
- return (result?.authenticator ?? result);
198
- }
199
- // Native ts-sdk account path
200
- return aptosClient.transaction.sign({
201
- signer,
202
- transaction,
203
- });
204
- }
205
- /**
206
- * Submit a transaction using the active session key — no wallet popup.
207
- * Called by useSmoothSend after session is established.
208
- */
209
- async submitWithSession(functionName, functionArguments = [], typeArguments = []) {
210
- if (!this._session || !this.hasSession()) {
211
- throw new Error('[SmoothSend] No active session. Call createSession() first.');
212
- }
213
- const { abstractedAccount, masterAddress, aptosClient } = this._session;
214
- const tx = await aptosClient.transaction.build.simple({
215
- sender: masterAddress,
216
- withFeePayer: true,
217
- data: {
218
- function: functionName,
219
- functionArguments,
220
- ...(typeArguments.length > 0 ? { typeArguments } : {}),
221
- },
222
- options: {
223
- replayProtectionNonce: BigInt(Math.floor(Math.random() * Number.MAX_SAFE_INTEGER)),
224
- },
225
- });
226
- const senderAuth = aptosClient.transaction.sign({
227
- signer: abstractedAccount,
228
- transaction: tx,
229
- });
230
- return this.submitTransaction({
231
- aptosConfig: aptosClient.config,
232
- transaction: tx,
233
- senderAuthenticator: senderAuth,
234
- });
235
- }
236
- _parseDuration(duration) {
237
- if (duration === 'never') {
238
- // Client-side "never expires" mode; on-chain handle already uses u64::MAX.
239
- return Number.MAX_SAFE_INTEGER;
240
- }
241
- const n = parseInt(duration, 10);
242
- if (isNaN(n))
243
- throw new Error(`Invalid sessionDuration "${duration}". Use e.g. "2h", "24h", "7d", or "never".`);
244
- if (duration.endsWith('s'))
245
- return n * 1000;
246
- if (duration.endsWith('m'))
247
- return n * 60 * 1000;
248
- if (duration.endsWith('h'))
249
- return n * 3600 * 1000;
250
- if (duration.endsWith('d'))
251
- return n * 86400 * 1000;
252
- throw new Error(`Unknown unit in "${duration}". Supported: s, m, h, d, or "never".`);
253
- }
254
- // ─── Transaction submission ──────────────────────────────────────────────────
255
- /**
256
- * Submit a transaction through SmoothSend's gasless relayer
257
- *
258
- * This method is called automatically by the Aptos Wallet Adapter when
259
- * you use signAndSubmitTransaction. The transaction is submitted to
260
- * SmoothSend's relayer which sponsors the gas fees.
261
- */
262
- async submitTransaction(args) {
263
- const { aptosConfig, transaction, senderAuthenticator, pluginParams } = args;
264
- // Auto-detect network from aptosConfig (source of truth from wallet adapter)
265
- // Falls back to constructor value if aptosConfig doesn't have a recognized network
266
- const detectedNetwork = this.resolveNetwork(aptosConfig);
267
- if (this.debug) {
268
- console.log('[SmoothSend] Submitting gasless transaction:', {
269
- sender: transaction.rawTransaction?.sender?.toString(),
270
- configNetwork: this.network,
271
- detectedNetwork,
272
- });
273
- }
274
- if (detectedNetwork !== this.network && this.debug) {
275
- console.warn(`[SmoothSend] Network mismatch: constructor=${this.network}, aptosConfig=${detectedNetwork}. ` +
276
- `Using aptosConfig network (${detectedNetwork}).`);
277
- }
278
- try {
279
- // Serialize transaction and authenticator to bytes
280
- const transactionBytes = Array.from(transaction.bcsToBytes());
281
- const authenticatorBytes = Array.from(senderAuthenticator.bcsToBytes());
282
- // Prepare request payload — always use the detected network
283
- const payload = {
284
- transactionBytes,
285
- authenticatorBytes,
286
- network: detectedNetwork,
287
- functionName: pluginParams?.functionName || 'unknown',
288
- };
289
- // Make request to SmoothSend gateway
290
- const response = await this.makeRequest('/api/v1/relayer/gasless-transaction', payload, detectedNetwork);
291
- if (!response.success || !response.txnHash) {
292
- throw new Error(response.error || response.details || 'Transaction submission failed');
293
- }
294
- if (this.debug) {
295
- console.log('[SmoothSend] Transaction successful:', {
296
- hash: response.txnHash,
297
- gasUsed: response.gasUsed,
298
- });
299
- }
300
- // Return in the format expected by Aptos SDK
301
- return {
302
- hash: response.txnHash,
303
- sender: response.sender || transaction.rawTransaction?.sender?.toString() || '',
304
- sequence_number: transaction.rawTransaction?.sequence_number?.toString() || '0',
305
- max_gas_amount: transaction.rawTransaction?.max_gas_amount?.toString() || '0',
306
- gas_unit_price: transaction.rawTransaction?.gas_unit_price?.toString() || '0',
307
- expiration_timestamp_secs: transaction.rawTransaction?.expiration_timestamp_secs?.toString() || '0',
308
- payload: {},
309
- signature: undefined,
310
- };
311
- }
312
- catch (error) {
313
- if (this.debug) {
314
- console.error('[SmoothSend] Transaction failed:', error);
315
- }
316
- throw new Error(`SmoothSend gasless transaction failed: ${error.message}`);
317
- }
318
- }
319
- /**
320
- * Resolve the effective network from aptosConfig.
321
- * aptosConfig.network is the source of truth set by AptosWalletAdapterProvider.
322
- */
323
- resolveNetwork(aptosConfig) {
324
- try {
325
- const configNetwork = aptosConfig?.network;
326
- if (configNetwork === 'testnet' || configNetwork === 'mainnet') {
327
- return configNetwork;
328
- }
329
- if (typeof configNetwork === 'string') {
330
- const normalized = configNetwork.toLowerCase();
331
- if (normalized === 'testnet' || normalized === 'mainnet') {
332
- return normalized;
333
- }
334
- }
335
- }
336
- catch {
337
- // fall through
338
- }
339
- return this.network;
340
- }
341
- /**
342
- * Make an HTTP request to the SmoothSend gateway
343
- */
344
- async makeRequest(endpoint, payload, network, method = 'POST') {
345
- const effectiveNetwork = network || this.network;
346
- const url = `${this.gatewayUrl}${endpoint}`;
347
- const headers = {
348
- 'Content-Type': 'application/json',
349
- 'X-API-Key': this.apiKey,
350
- 'X-Chain': `aptos-${effectiveNetwork}`,
351
- };
352
- // Add Origin header for public keys in browser
353
- if (this.apiKey.startsWith('pk_nogas_') && typeof window !== 'undefined') {
354
- headers['Origin'] = window.location.origin;
355
- }
356
- // Add captcha token if the project requires it
357
- if (this.getCaptchaToken) {
358
- try {
359
- const token = await this.getCaptchaToken();
360
- if (token) {
361
- headers['X-Captcha-Token'] = token;
362
- }
363
- }
364
- catch (e) {
365
- if (this.debug) {
366
- console.warn('[SmoothSend] Failed to get captcha token:', e);
367
- }
368
- }
369
- }
370
- const controller = new AbortController();
371
- const timeoutId = setTimeout(() => controller.abort(), this.timeout);
372
- try {
373
- const response = await fetch(url, {
374
- method,
375
- headers,
376
- body: method === 'GET' ? undefined : JSON.stringify(payload),
377
- signal: controller.signal,
378
- });
379
- clearTimeout(timeoutId);
380
- if (!response.ok) {
381
- const errorData = await response.json().catch(() => ({}));
382
- throw new Error(errorData.error || errorData.message || `HTTP ${response.status}`);
383
- }
384
- return await response.json();
385
- }
386
- catch (error) {
387
- clearTimeout(timeoutId);
388
- if (error.name === 'AbortError') {
389
- throw new Error('Request timed out');
390
- }
391
- throw error;
392
- }
393
- }
394
- /**
395
- * Fetch the list of sponsored functions for this API key's project.
396
- * Results are cached for 5 minutes. Returns ['*'] if all functions are sponsored.
397
- */
398
- async getSponsoredFunctions() {
399
- const now = Date.now();
400
- if (this.sponsoredFunctionsCache !== null && now - this.sponsoredFunctionsCacheAt < this.SPONSORED_CACHE_TTL) {
401
- return this.sponsoredFunctionsCache;
402
- }
403
- try {
404
- const response = await this.makeRequest('/api/v1/sponsorship', {}, undefined, 'GET');
405
- const fns = response.sponsoredFunctions;
406
- this.sponsoredFunctionsCache = Array.isArray(fns) ? fns : ['*'];
407
- }
408
- catch {
409
- this.sponsoredFunctionsCache = ['*']; // fail-open: assume all sponsored
410
- }
411
- this.sponsoredFunctionsCacheAt = now;
412
- return this.sponsoredFunctionsCache;
413
- }
414
- /**
415
- * Check if a specific function is sponsored for gasless execution.
416
- * @param functionName - Full function identifier, e.g. "0x123::module::function"
417
- */
418
- async isSponsored(functionName) {
419
- const fns = await this.getSponsoredFunctions();
420
- if (fns.includes('*'))
421
- return true;
422
- const normalize = (id) => id.replace(/^(0x)0+([1-9a-f][0-9a-f]*)(::.+)$/i, '$1$2$3').toLowerCase();
423
- const normalized = normalize(functionName);
424
- return fns.some(f => normalize(f) === normalized);
425
- }
426
- /**
427
- */
428
- getConfig() {
429
- return {
430
- apiKey: this.apiKey.substring(0, 15) + '...', // Don't expose full key
431
- network: this.network,
432
- gatewayUrl: this.gatewayUrl,
433
- timeout: this.timeout,
434
- debug: this.debug,
435
- };
436
- }
437
- }
438
- /**
439
- * Create a SmoothSend transaction submitter with minimal configuration
440
- *
441
- * @example
442
- * ```typescript
443
- * const submitter = createSmoothSendSubmitter('pk_nogas_your_key');
444
- * ```
445
- */
446
- function createSmoothSendSubmitter(apiKey, options) {
447
- return new SmoothSendTransactionSubmitter({
448
- apiKey,
449
- ...options,
450
- });
451
- }
452
-
453
- /**
454
- * `useSmoothSendAptosPrivy` — Aptos + Privy gasless writes via SmoothSend.
455
- *
456
- * Privy's embedded ed25519 wallet signs the signing-message hash via
457
- * `signRawHash`. SmoothSend's relayer then adds the fee-payer signature and
458
- * submits, so the end user pays 0 APT gas.
459
- *
460
- * This hook is a thin shell over the existing `SmoothSendTransactionSubmitter`
461
- * — same gasless gateway path used by all other Aptos integrations.
462
- */
463
- function bytesToHex(bytes) {
464
- let hex = '0x';
465
- for (let i = 0; i < bytes.length; i++) {
466
- hex += bytes[i].toString(16).padStart(2, '0');
467
- }
468
- return hex;
469
- }
470
- function stripHexPrefix(value) {
471
- return value.startsWith('0x') ? value.slice(2) : value;
472
- }
473
- function useSmoothSendAptosPrivy(params) {
474
- const network = params.network ?? 'testnet';
475
- const aptos = useMemo(() => {
476
- const networkEnum = network === 'mainnet' ? Network.MAINNET : Network.TESTNET;
477
- const cfg = { network: networkEnum };
478
- if (params.fullnode)
479
- cfg.fullnode = params.fullnode;
480
- if (params.aptosApiKey) {
481
- cfg.clientConfig = { API_KEY: params.aptosApiKey };
482
- }
483
- return new Aptos(new AptosConfig(cfg));
484
- }, [network, params.fullnode, params.aptosApiKey]);
485
- const submitter = useMemo(() => new SmoothSendTransactionSubmitter({
486
- apiKey: params.apiKey,
487
- network,
488
- gatewayUrl: params.gatewayUrl,
489
- debug: params.debug,
490
- }), [params.apiKey, network, params.gatewayUrl, params.debug]);
491
- const [isPending, setIsPending] = useState(false);
492
- const [data, setData] = useState(undefined);
493
- const [error, setError] = useState(null);
494
- const inFlight = useRef(false);
495
- const reset = useCallback(() => {
496
- setIsPending(false);
497
- setData(undefined);
498
- setError(null);
499
- }, []);
500
- const isReady = !!params.address && !!params.publicKey && !!params.signRawHash;
501
- const signAndSubmitTransaction = useCallback(async (input) => {
502
- if (inFlight.current) {
503
- throw new Error('[SmoothSend Aptos+Privy] Another transaction is already in flight');
504
- }
505
- if (!params.address) {
506
- throw new Error('[SmoothSend Aptos+Privy] Missing Privy Aptos wallet address. Make sure the user is logged in and an embedded Aptos wallet exists.');
507
- }
508
- if (!params.publicKey) {
509
- throw new Error('[SmoothSend Aptos+Privy] Missing Privy Aptos wallet publicKey (32-byte ed25519 hex).');
510
- }
511
- if (!params.signRawHash) {
512
- throw new Error('[SmoothSend Aptos+Privy] Missing signRawHash adapter. Wire up Privy useSignRawHash with chainType: "aptos".');
513
- }
514
- inFlight.current = true;
515
- setIsPending(true);
516
- setError(null);
517
- try {
518
- const sender = AccountAddress.from(params.address);
519
- const rawTxn = await aptos.transaction.build.simple({
520
- sender,
521
- withFeePayer: true,
522
- data: {
523
- function: input.function,
524
- typeArguments: input.typeArguments,
525
- functionArguments: input.functionArguments,
526
- },
527
- options: input.maxGasAmount
528
- ? { maxGasAmount: input.maxGasAmount }
529
- : undefined,
530
- });
531
- const signingMessage = generateSigningMessageForTransaction(rawTxn);
532
- const messageHex = bytesToHex(signingMessage);
533
- if (params.debug) {
534
- // eslint-disable-next-line no-console
535
- console.log('[SmoothSend Aptos+Privy] Signing', {
536
- sender: params.address,
537
- messageHexLen: messageHex.length,
538
- });
539
- }
540
- const signatureHex = await params.signRawHash({ hash: messageHex });
541
- const sigClean = stripHexPrefix(signatureHex);
542
- const senderAuthenticator = new AccountAuthenticatorEd25519(new Ed25519PublicKey(params.publicKey), new Ed25519Signature(sigClean));
543
- const response = await submitter.submitTransaction({
544
- aptosConfig: aptos.config,
545
- transaction: rawTxn,
546
- senderAuthenticator,
547
- });
548
- setData(response);
549
- return response;
550
- }
551
- catch (e) {
552
- const err = e instanceof Error ? e : new Error(String(e));
553
- setError(err);
554
- throw err;
555
- }
556
- finally {
557
- inFlight.current = false;
558
- setIsPending(false);
559
- }
560
- }, [
561
- aptos,
562
- submitter,
563
- params.address,
564
- params.publicKey,
565
- params.signRawHash,
566
- params.debug,
567
- ]);
568
- const status = isPending
569
- ? 'pending'
570
- : error
571
- ? 'error'
572
- : data
573
- ? 'success'
574
- : 'idle';
575
- return {
576
- signAndSubmitTransaction,
577
- isPending,
578
- isIdle: status === 'idle',
579
- status,
580
- data,
581
- error,
582
- address: params.address,
583
- isReady,
584
- reset,
585
- };
586
- }
587
-
588
- /**
589
- * Adapter that wraps Privy's `useSignRawHash().signRawHash` (Tier-2 chains)
590
- * into the `PrivyAptosRawSigner` shape expected by `useSmoothSendAptosPrivy`.
591
- *
592
- * The SDK does NOT import `@privy-io/react-auth` directly — the dApp passes
593
- * the function in. This keeps Privy as an optional dependency.
594
- *
595
- * @example
596
- * ```tsx
597
- * import { useSignRawHash } from '@privy-io/react-auth/extended-chains';
598
- * import { createPrivyAptosSigner, useSmoothSendAptosPrivy } from '@smoothsend/sdk/aptos';
599
- *
600
- * const { signRawHash } = useSignRawHash();
601
- * const signer = createPrivyAptosSigner({ wallet: aptosWallet, signRawHash });
602
- *
603
- * const { signAndSubmitTransaction } = useSmoothSendAptosPrivy({
604
- * apiKey, network: 'testnet',
605
- * address: aptosWallet?.address,
606
- * publicKey: aptosWallet?.publicKey,
607
- * signRawHash: signer,
608
- * });
609
- * ```
610
- */
611
- function createPrivyAptosSigner(params) {
612
- return async ({ hash }) => {
613
- if (!params.wallet?.address) {
614
- throw new Error('[SmoothSend Aptos+Privy] Privy Aptos wallet not found. Make sure the user is logged in and an embedded wallet with chainType="aptos" exists.');
615
- }
616
- const result = await params.signRawHash({
617
- address: params.wallet.address,
618
- chainType: 'aptos',
619
- hash: hash.startsWith('0x') ? hash : `0x${hash}`,
620
- });
621
- if (!result?.signature) {
622
- throw new Error('[SmoothSend Aptos+Privy] Privy signRawHash returned an empty signature');
623
- }
624
- return result.signature;
625
- };
626
- }
627
-
628
- export { ADD_PERMISSIONED_HANDLE_BYTECODE as A, SmoothSendTransactionSubmitter as S, createSmoothSendSubmitter as a, createPrivyAptosSigner as c, useSmoothSendAptosPrivy as u };
629
- //# sourceMappingURL=shared-XH1iLZjy.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"shared-XH1iLZjy.js","sources":["../../src/session/constants.ts","../../src/wallet-adapter/SmoothSendTransactionSubmitter.ts","../../src/aptos-privy/useSmoothSendAptosPrivy.tsx","../../src/aptos-privy/privyAptosSigner.ts"],"sourcesContent":[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